Merge pull request #16995 from benj5378/axisColors
[Gui] Axis colors changeable
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
|
||||
#include <sstream>
|
||||
|
||||
# include <Inventor/actions/SoGetBoundingBoxAction.h>
|
||||
# include <Inventor/actions/SoGLRenderAction.h>
|
||||
# include <Inventor/bundles/SoMaterialBundle.h>
|
||||
@@ -50,6 +52,9 @@
|
||||
# include <Inventor/nodes/SoTranslation.h>
|
||||
#endif
|
||||
|
||||
#include <App/Color.h>
|
||||
#include <Gui/ViewParams.h>
|
||||
|
||||
#include "SoAxisCrossKit.h"
|
||||
#include "SoDevicePixelRatioElement.h"
|
||||
|
||||
@@ -218,12 +223,28 @@ SoAxisCrossKit::createAxes()
|
||||
set("xAxis.appearance.drawStyle", "lineWidth 1");
|
||||
set("yAxis.appearance.drawStyle", "lineWidth 1");
|
||||
set("zAxis.appearance.drawStyle", "lineWidth 1");
|
||||
set("xAxis.appearance.material", "diffuseColor 0.5 0.125 0.125");
|
||||
set("xHead.appearance.material", "diffuseColor 0.5 0.125 0.125");
|
||||
set("yAxis.appearance.material", "diffuseColor 0.125 0.5 0.125");
|
||||
set("yHead.appearance.material", "diffuseColor 0.125 0.5 0.125");
|
||||
set("zAxis.appearance.material", "diffuseColor 0.125 0.125 0.5");
|
||||
set("zHead.appearance.material", "diffuseColor 0.125 0.125 0.5");
|
||||
|
||||
unsigned long colorLong;
|
||||
App::Color color;
|
||||
std::stringstream parameterstring;
|
||||
|
||||
colorLong = Gui::ViewParams::instance()->getAxisXColor();
|
||||
color = App::Color(static_cast<uint32_t>(colorLong));
|
||||
parameterstring << "diffuseColor " << color.r << " " << color.g << " " << color.b;
|
||||
set("xAxis.appearance.material", parameterstring.str().c_str());
|
||||
set("xHead.appearance.material", parameterstring.str().c_str());
|
||||
|
||||
colorLong = Gui::ViewParams::instance()->getAxisYColor();
|
||||
color = App::Color(static_cast<uint32_t>(colorLong));
|
||||
parameterstring << "diffuseColor " << color.r << " " << color.g << " " << color.b;
|
||||
set("yAxis.appearance.material", parameterstring.str().c_str());
|
||||
set("yHead.appearance.material", parameterstring.str().c_str());
|
||||
|
||||
colorLong = Gui::ViewParams::instance()->getAxisZColor();
|
||||
color = App::Color(static_cast<uint32_t>(colorLong));
|
||||
parameterstring << "diffuseColor " << color.r << " " << color.g << " " << color.b;
|
||||
set("zAxis.appearance.material", parameterstring.str().c_str());
|
||||
set("zHead.appearance.material", parameterstring.str().c_str());
|
||||
|
||||
// Make unpickable
|
||||
set("xAxis.pickStyle", "style UNPICKABLE");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
</FCParamGroup>
|
||||
<FCParamGroup Name="View">
|
||||
<FCInt Name="AntiAliasing" Value="0"/>
|
||||
<FCUInt Name="AxisXColor" Value="3425907456"/>
|
||||
<FCUInt Name="AxisYColor" Value="869020416"/>
|
||||
<FCUInt Name="AxisZColor" Value="859032576"/>
|
||||
<FCFloat Name="BoundingBoxFontSize" Value="10.0"/>
|
||||
<FCBool Name="CornerCoordSystem" Value="1"/>
|
||||
<FCInt Name="CornerCoordSystemSize" Value="10"/>
|
||||
|
||||
@@ -122,6 +122,117 @@ in the corner -- in % of height/width of viewport</string>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="xAxisLabel">
|
||||
<property name="text">
|
||||
<string>X-axis color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefColorButton" name="xAxisColor">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>AxisXColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>204</red>
|
||||
<green>51</green>
|
||||
<blue>51</blue>
|
||||
</color>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="yAxisLabel">
|
||||
<property name="text">
|
||||
<string>Y-axis color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefColorButton" name="yAxisColor">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>AxisYColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>51</red>
|
||||
<green>204</green>
|
||||
<blue>51</blue>
|
||||
</color>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="zAxisLabel">
|
||||
<property name="text">
|
||||
<string>Z-axis color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefColorButton" name="zAxisColor">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>AxisZColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>51</red>
|
||||
<green>51</green>
|
||||
<blue>204</blue>
|
||||
</color>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="CheckBox_ShowAxisCross">
|
||||
<property name="toolTip">
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Multisample.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
#include <Gui/ViewParams.h>
|
||||
|
||||
#include "DlgSettings3DViewImp.h"
|
||||
#include "ui_DlgSettings3DView.h"
|
||||
@@ -74,6 +75,9 @@ void DlgSettings3DViewImp::saveSettings()
|
||||
ui->sliderIntensity->onSave();
|
||||
ui->radioPerspective->onSave();
|
||||
ui->radioOrthographic->onSave();
|
||||
ui->xAxisColor->onSave();
|
||||
ui->yAxisColor->onSave();
|
||||
ui->zAxisColor->onSave();
|
||||
}
|
||||
|
||||
void DlgSettings3DViewImp::loadSettings()
|
||||
@@ -92,6 +96,9 @@ void DlgSettings3DViewImp::loadSettings()
|
||||
ui->radioPerspective->onRestore();
|
||||
ui->radioOrthographic->onRestore();
|
||||
ui->comboTransparentRender->onRestore();
|
||||
ui->xAxisColor->onRestore();
|
||||
ui->yAxisColor->onRestore();
|
||||
ui->zAxisColor->onRestore();
|
||||
|
||||
loadAntiAliasing();
|
||||
loadRenderCache();
|
||||
@@ -240,3 +247,4 @@ void DlgSettings3DViewImp::onAliasingChanged(int index)
|
||||
|
||||
#include "moc_DlgSettings3DViewImp.cpp"
|
||||
|
||||
|
||||
|
||||
@@ -592,6 +592,8 @@ void View3DInventorViewer::init()
|
||||
|
||||
naviCube = new NaviCube(this);
|
||||
naviCubeEnabled = true;
|
||||
|
||||
updateColors();
|
||||
}
|
||||
|
||||
View3DInventorViewer::~View3DInventorViewer()
|
||||
@@ -3710,6 +3712,25 @@ void View3DInventorViewer::setAxisLetterColor(const SbColor& color)
|
||||
recolor(ZPM_PIXEL_MASK, ZPM_pixel_data, ZPM_WIDTH, ZPM_HEIGHT, ZPM_BYTES_PER_PIXEL);
|
||||
}
|
||||
|
||||
void View3DInventorViewer::updateColors()
|
||||
{
|
||||
unsigned long colorLong;
|
||||
|
||||
colorLong = Gui::ViewParams::instance()->getAxisXColor();
|
||||
m_xColor = App::Color(static_cast<uint32_t>(colorLong));
|
||||
colorLong = Gui::ViewParams::instance()->getAxisYColor();
|
||||
m_yColor = App::Color(static_cast<uint32_t>(colorLong));
|
||||
colorLong = Gui::ViewParams::instance()->getAxisZColor();
|
||||
m_zColor = App::Color(static_cast<uint32_t>(colorLong));
|
||||
|
||||
naviCube->updateColors();
|
||||
|
||||
if(hasAxisCross()) {
|
||||
setAxisCross(false); // Force redraw
|
||||
setAxisCross(true);
|
||||
}
|
||||
}
|
||||
|
||||
void View3DInventorViewer::drawAxisCross()
|
||||
{
|
||||
// NOLINTBEGIN
|
||||
@@ -3817,10 +3838,10 @@ void View3DInventorViewer::drawAxisCross()
|
||||
glPushMatrix();
|
||||
|
||||
if (i == XAXIS) { // X axis.
|
||||
if (stereoMode() != Quarter::SoQTQuarterAdaptor::MONO)
|
||||
glColor3f(0.500F, 0.5F, 0.5F);
|
||||
if (stereoMode() != Quarter::SoQTQuarterAdaptor::MONO) // What is this
|
||||
glColor3f(0.500F, 0.5F, 0.5F); // Why different colors??
|
||||
else
|
||||
glColor3f(0.500F, 0.125F, 0.125F);
|
||||
glColor3f(m_xColor.r, m_xColor.g, m_xColor.b);
|
||||
}
|
||||
else if (i == YAXIS) { // Y axis.
|
||||
glRotatef(90, 0, 0, 1);
|
||||
@@ -3828,7 +3849,7 @@ void View3DInventorViewer::drawAxisCross()
|
||||
if (stereoMode() != Quarter::SoQTQuarterAdaptor::MONO)
|
||||
glColor3f(0.400F, 0.4F, 0.4F);
|
||||
else
|
||||
glColor3f(0.125F, 0.500F, 0.125F);
|
||||
glColor3f(m_yColor.r, m_yColor.g, m_yColor.b);
|
||||
}
|
||||
else { // Z axis.
|
||||
glRotatef(-90, 0, 1, 0);
|
||||
@@ -3836,7 +3857,7 @@ void View3DInventorViewer::drawAxisCross()
|
||||
if (stereoMode() != Quarter::SoQTQuarterAdaptor::MONO)
|
||||
glColor3f(0.300F, 0.3F, 0.3F);
|
||||
else
|
||||
glColor3f(0.125F, 0.125F, 0.500F);
|
||||
glColor3f(m_zColor.r, m_zColor.g, m_zColor.b);
|
||||
}
|
||||
|
||||
drawArrow();
|
||||
|
||||
@@ -434,6 +434,9 @@ public:
|
||||
bool isEnabledVBO() const;
|
||||
void setRenderCache(int);
|
||||
|
||||
//! Update colors of axis in corner to match preferences
|
||||
void updateColors();
|
||||
|
||||
void getDimensions(float& fHeight, float& fWidth) const;
|
||||
float getMaxDimension() const;
|
||||
SbVec3f getCenterPointOnFocalPlane() const;
|
||||
@@ -531,6 +534,10 @@ private:
|
||||
bool vboEnabled;
|
||||
bool naviCubeEnabled;
|
||||
|
||||
App::Color m_xColor;
|
||||
App::Color m_yColor;
|
||||
App::Color m_zColor;
|
||||
|
||||
bool editing;
|
||||
QCursor editCursor, zoomCursor, panCursor, spinCursor;
|
||||
bool redirected;
|
||||
|
||||
@@ -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->updateColors();
|
||||
}
|
||||
}
|
||||
else if (strcmp(Reason,"UseVBO") == 0) {
|
||||
if (!ignoreVBO) {
|
||||
for (auto _viewer : _viewers) {
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
|
||||
#include "Mod/Sketcher/App/ExternalGeometryFacade.h"
|
||||
|
||||
#include <App/Color.h>
|
||||
#include <Gui/ViewParams.h>
|
||||
|
||||
#include "EditModeCoinManagerParameters.h"
|
||||
|
||||
|
||||
@@ -50,10 +53,20 @@ int GeometryLayerParameters::getSubLayerIndex(const int geoId,
|
||||
: SubLayer::Normal);
|
||||
}
|
||||
|
||||
SbColor DrawingParameters::InformationColor(0.0f, 1.0f, 0.0f); // #00FF00 -> ( 0,255, 0)
|
||||
SbColor DrawingParameters::CreateCurveColor(0.5f, 0.5f, 0.5f); // ##7f7f7f -> (127,127,127)
|
||||
SbColor DrawingParameters::CrossColorH(0.8f, 0.4f, 0.4f); // #CC6666 -> (204,102,102)
|
||||
SbColor DrawingParameters::CrossColorV(0.47f, 1.0f, 0.51f); // #83FF83 -> (120,255,131)
|
||||
SbColor DrawingParameters::InformationColor(0.0f, 1.0f, 0.0f); // #00FF00 -> ( 0,255, 0)
|
||||
SbColor DrawingParameters::CreateCurveColor(0.5f, 0.5f, 0.5f); // ##7f7f7f -> (127,127,127)
|
||||
|
||||
namespace
|
||||
{ // Anonymous namespace to avoid making those variables global
|
||||
unsigned long HColorLong = Gui::ViewParams::instance()->getAxisXColor();
|
||||
App::Color Hcolor = App::Color(static_cast<uint32_t>(HColorLong));
|
||||
|
||||
unsigned long VColorLong = Gui::ViewParams::instance()->getAxisYColor();
|
||||
App::Color Vcolor = App::Color(static_cast<uint32_t>(VColorLong));
|
||||
} // namespace
|
||||
SbColor DrawingParameters::CrossColorH(Hcolor.r, Hcolor.g, Hcolor.b);
|
||||
SbColor DrawingParameters::CrossColorV(Vcolor.r, Vcolor.g, Vcolor.b);
|
||||
|
||||
SbColor DrawingParameters::InvalidSketchColor(1.0f, 0.42f, 0.0f); // #FF6D00 -> (255,109, 0)
|
||||
SbColor DrawingParameters::FullyConstrainedColor(0.0f, 1.0f, 0.0f); // #00FF00 -> ( 0,255, 0)
|
||||
SbColor
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
#include <Inventor/nodes/SoText2.h>
|
||||
#include <Inventor/nodes/SoTranslation.h>
|
||||
|
||||
#include <App/Color.h>
|
||||
#include <Gui/ViewParams.h>
|
||||
#include <Gui/Inventor/SmSwitchboard.h>
|
||||
#include <Mod/Sketcher/App/GeoList.h>
|
||||
|
||||
@@ -147,6 +149,20 @@ struct DrawingParameters
|
||||
unsigned int InternalPattern = 0b1111110011111100; // pattern of internal edges
|
||||
unsigned int ExternalPattern = 0b1111110011111100; // pattern of external edges
|
||||
//@}
|
||||
|
||||
DrawingParameters()
|
||||
{
|
||||
unsigned long colorLong;
|
||||
App::Color color;
|
||||
|
||||
colorLong = Gui::ViewParams::instance()->getAxisXColor();
|
||||
color = App::Color(static_cast<uint32_t>(colorLong));
|
||||
CrossColorH = SbColor(color.r, color.g, color.b);
|
||||
|
||||
colorLong = Gui::ViewParams::instance()->getAxisYColor();
|
||||
color = App::Color(static_cast<uint32_t>(colorLong));
|
||||
CrossColorV = SbColor(color.r, color.g, color.b);
|
||||
}
|
||||
};
|
||||
|
||||
/** @brief Struct for storing references to the scenegraph nodes necessary for geometry layers
|
||||
|
||||
Reference in New Issue
Block a user