[Gui] Make NaviCube axis colors changeable
This commit is contained in:
@@ -56,6 +56,7 @@
|
||||
#include "MainWindow.h"
|
||||
#include "View3DInventorViewer.h"
|
||||
#include "View3DInventor.h"
|
||||
#include "ViewParams.h"
|
||||
|
||||
|
||||
using namespace Eigen;
|
||||
@@ -179,6 +180,10 @@ public:
|
||||
float m_InactiveOpacity = 0.5;
|
||||
SbVec2s m_PosOffset = SbVec2s(0,0);
|
||||
|
||||
App::Color m_xColor;
|
||||
App::Color m_yColor;
|
||||
App::Color m_zColor;
|
||||
|
||||
bool m_Prepared = false;
|
||||
static vector<string> m_commands;
|
||||
bool m_Draggable = false;
|
||||
@@ -212,6 +217,7 @@ int NaviCube::getNaviCubeSize()
|
||||
|
||||
NaviCube::NaviCube(Gui::View3DInventorViewer* viewer) {
|
||||
m_NaviCubeImplementation = new NaviCubeImplementation(viewer);
|
||||
updateColors();
|
||||
}
|
||||
|
||||
NaviCube::~NaviCube() {
|
||||
@@ -828,13 +834,16 @@ void NaviCubeImplementation::drawNaviCube(bool pickMode, float opacity)
|
||||
a, a, a // 0
|
||||
};
|
||||
glVertexPointer(3, GL_FLOAT, 0, pointData);
|
||||
glColor4f(1, 0, 0, opacity);
|
||||
|
||||
glColor4f(m_xColor.r, m_xColor.g, m_xColor.b, opacity);
|
||||
glDrawArrays(GL_LINES, 0, 2);
|
||||
glDrawArrays(GL_POINTS, 0, 2);
|
||||
glColor4f(0, 1, 0, opacity);
|
||||
|
||||
glColor4f(m_yColor.r, m_yColor.g, m_yColor.b, opacity);
|
||||
glDrawArrays(GL_LINES, 2, 2);
|
||||
glDrawArrays(GL_POINTS, 2, 2);
|
||||
glColor4f(0, 0, 1, opacity);
|
||||
|
||||
glColor4f(m_zColor.r, m_zColor.g, m_zColor.b, opacity);
|
||||
glDrawArrays(GL_LINES, 4, 2);
|
||||
glDrawArrays(GL_POINTS, 4, 2);
|
||||
}
|
||||
@@ -1167,6 +1176,18 @@ QString NaviCubeImplementation::str(const char* str) {
|
||||
return QString::fromLatin1(str);
|
||||
}
|
||||
|
||||
void NaviCube::updateColors()
|
||||
{
|
||||
unsigned long colorLong;
|
||||
|
||||
colorLong = Gui::ViewParams::instance()->getAxisXColor();
|
||||
m_NaviCubeImplementation->m_xColor = App::Color(static_cast<uint32_t>(colorLong));
|
||||
colorLong = Gui::ViewParams::instance()->getAxisYColor();
|
||||
m_NaviCubeImplementation->m_yColor = App::Color(static_cast<uint32_t>(colorLong));
|
||||
colorLong = Gui::ViewParams::instance()->getAxisZColor();
|
||||
m_NaviCubeImplementation->m_zColor = App::Color(static_cast<uint32_t>(colorLong));
|
||||
}
|
||||
|
||||
void NaviCube::setNaviCubeCommands(const std::vector<std::string>& cmd)
|
||||
{
|
||||
NaviCubeImplementation::m_commands = cmd;
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
void setCorner(Corner);
|
||||
void setOffset(int x, int y);
|
||||
bool isDraggable();
|
||||
void updateColors();
|
||||
void setDraggable(bool draggable);
|
||||
void setSize(int size);
|
||||
void setChamfer(float size);
|
||||
|
||||
@@ -86,6 +86,9 @@ void View3DSettings::applySettings()
|
||||
OnChange(*hGrp,"UseBackgroundColorMid");
|
||||
OnChange(*hGrp,"ShowFPS");
|
||||
OnChange(*hGrp,"ShowNaviCube");
|
||||
OnChange(*hGrp,"AxisXColor");
|
||||
OnChange(*hGrp,"AxisYColor");
|
||||
OnChange(*hGrp,"AxisZColor");
|
||||
OnChange(*hGrp,"UseVBO");
|
||||
OnChange(*hGrp,"RenderCache");
|
||||
OnChange(*hGrp,"Orthographic");
|
||||
@@ -341,6 +344,11 @@ void View3DSettings::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M
|
||||
_viewer->setEnabledNaviCube(rGrp.GetBool("ShowNaviCube", true));
|
||||
}
|
||||
}
|
||||
else if (strcmp(Reason,"AxisXColor") == 0 || strcmp(Reason,"AxisYColor") == 0 || strcmp(Reason,"AxisZColor") == 0) {
|
||||
for (auto _viewer : _viewers) {
|
||||
_viewer->getNaviCube()->updateColors();
|
||||
}
|
||||
}
|
||||
else if (strcmp(Reason,"UseVBO") == 0) {
|
||||
if (!ignoreVBO) {
|
||||
for (auto _viewer : _viewers) {
|
||||
|
||||
Reference in New Issue
Block a user