diff --git a/src/Gui/CornerCrossLetters.h b/src/Gui/CornerCrossLetters.h index 16b251e3d7..d60c6d35dd 100644 --- a/src/Gui/CornerCrossLetters.h +++ b/src/Gui/CornerCrossLetters.h @@ -16,8 +16,8 @@ namespace Gui { #define XPM_WIDTH (21) #define XPM_HEIGHT (27) #define XPM_BYTES_PER_PIXEL (4) /* 2:RGB16, 3:RGB, 4:RGBA */ -#define XPM_PIXEL_DATA ((unsigned char*) XPM_pixel_data) -static const unsigned char XPM_pixel_data[21 * 27 * 4 + 1] = +#define XPM_PIXEL_MASK ((unsigned char*) ::XPM_pixel_mask) +static const unsigned char XPM_pixel_mask[21 * 27 * 4 + 1] = ("\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" @@ -89,8 +89,8 @@ static const unsigned char XPM_pixel_data[21 * 27 * 4 + 1] = #define YPM_WIDTH (21) #define YPM_HEIGHT (27) #define YPM_BYTES_PER_PIXEL (4) /* 2:RGB16, 3:RGB, 4:RGBA */ -#define YPM_PIXEL_DATA ((unsigned char*) YPM_pixel_data) -static const unsigned char YPM_pixel_data[21 * 27 * 4 + 1] = +#define YPM_PIXEL_MASK ((unsigned char*) ::YPM_pixel_mask) +static const unsigned char YPM_pixel_mask[21 * 27 * 4 + 1] = ("\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" @@ -161,8 +161,8 @@ static const unsigned char YPM_pixel_data[21 * 27 * 4 + 1] = #define ZPM_WIDTH (21) #define ZPM_HEIGHT (27) #define ZPM_BYTES_PER_PIXEL (4) /* 2:RGB16, 3:RGB, 4:RGBA */ -#define ZPM_PIXEL_DATA ((unsigned char*) ZPM_pixel_data) -static const unsigned char ZPM_pixel_data[21 * 27 * 4 + 1] = +#define ZPM_PIXEL_MASK ((unsigned char*) ::ZPM_pixel_mask) +static const unsigned char ZPM_pixel_mask[21 * 27 * 4 + 1] = ("\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" diff --git a/src/Gui/PreferencePages/DlgSettings3DView.ui b/src/Gui/PreferencePages/DlgSettings3DView.ui index 975ebf5538..91b6a33e3c 100644 --- a/src/Gui/PreferencePages/DlgSettings3DView.ui +++ b/src/Gui/PreferencePages/DlgSettings3DView.ui @@ -24,8 +24,8 @@ - - + + Main coordinate system will always be shown in @@ -45,7 +45,7 @@ lower right corner within opened files - + Qt::Horizontal @@ -57,7 +57,7 @@ lower right corner within opened files - + Relative size : @@ -67,7 +67,7 @@ lower right corner within opened files - + Size of main coordinate system representation @@ -93,6 +93,33 @@ in the corner -- in % of height/width of viewport + + + + Letter color: + + + + + + + Axis letter color + + + + 0 + 0 + 0 + + + + AxisLetterColor + + + View + + + @@ -542,7 +569,7 @@ bounding box size of the 3D object that is currently displayed. - + Objects will be projected in orthographic projection @@ -561,7 +588,7 @@ bounding box size of the 3D object that is currently displayed. - + @@ -678,5 +705,11 @@ bounding box size of the 3D object that is currently displayed. SpinBox_CornerCoordSystemSize setEnabled(bool) + + CheckBox_CornerCoordSystem + toggled(bool) + axisLetterColor + setEnabled(bool) + diff --git a/src/Gui/PreferencePages/DlgSettings3DViewImp.cpp b/src/Gui/PreferencePages/DlgSettings3DViewImp.cpp index 2ff0be450e..49f175bb2a 100644 --- a/src/Gui/PreferencePages/DlgSettings3DViewImp.cpp +++ b/src/Gui/PreferencePages/DlgSettings3DViewImp.cpp @@ -85,6 +85,7 @@ void DlgSettings3DViewImp::saveSettings() ui->FloatSpinBox_EyeDistance->onSave(); ui->checkBoxBacklight->onSave(); ui->backlightColor->onSave(); + ui->axisLetterColor->onSave(); ui->sliderIntensity->onSave(); ui->radioPerspective->onSave(); ui->radioOrthographic->onSave(); @@ -101,6 +102,7 @@ void DlgSettings3DViewImp::loadSettings() ui->FloatSpinBox_EyeDistance->onRestore(); ui->checkBoxBacklight->onRestore(); ui->backlightColor->onRestore(); + ui->axisLetterColor->onRestore(); ui->sliderIntensity->onRestore(); ui->radioPerspective->onRestore(); ui->radioOrthographic->onRestore(); diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index d0ebdd14c8..f713e476b1 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -92,7 +92,6 @@ #include "View3DInventorViewer.h" #include "Application.h" -#include "CornerCrossLetters.h" #include "Document.h" #include "GLPainter.h" #include "MainWindow.h" @@ -3427,6 +3426,40 @@ void View3DInventorViewer::setViewing(bool enable) inherited::setViewing(enable); } +unsigned char View3DInventorViewer::XPM_pixel_data[XPM_WIDTH * XPM_HEIGHT * XPM_BYTES_PER_PIXEL + 1] = {}; +unsigned char View3DInventorViewer::YPM_pixel_data[YPM_WIDTH * YPM_HEIGHT * YPM_BYTES_PER_PIXEL + 1] = {}; +unsigned char View3DInventorViewer::ZPM_pixel_data[ZPM_WIDTH * ZPM_HEIGHT * ZPM_BYTES_PER_PIXEL + 1] = {}; + +void View3DInventorViewer::setAxisLetterColor(const SbColor& color) +{ + unsigned packed = color.getPackedValue(); + + auto recolor = + [&](const unsigned char* mask, + unsigned char* data, + unsigned width, + unsigned height, + unsigned bitdepth) { + for (unsigned y = 0; y < height; y++) { + for (unsigned x = 0; x < width; x++) { + unsigned offset = (y * width + x) * bitdepth; + + const unsigned char* src = &mask[offset]; + unsigned char* dst = &data[offset]; + + dst[0] = (packed >> 24) & 0xFF; // RR - from color + dst[1] = (packed >> 16) & 0xFF; // GG - from color + dst[2] = (packed >> 8) & 0xFF; // BB - from color + dst[3] = src[3]; // AA - from mask + } + } + }; + + recolor(XPM_PIXEL_MASK, XPM_pixel_data, XPM_WIDTH, XPM_HEIGHT, XPM_BYTES_PER_PIXEL); + recolor(YPM_PIXEL_MASK, YPM_pixel_data, YPM_WIDTH, YPM_HEIGHT, YPM_BYTES_PER_PIXEL); + recolor(ZPM_PIXEL_MASK, ZPM_pixel_data, ZPM_WIDTH, ZPM_HEIGHT, ZPM_BYTES_PER_PIXEL); +} + void View3DInventorViewer::drawAxisCross() { // NOLINTBEGIN @@ -3584,11 +3617,11 @@ void View3DInventorViewer::drawAxisCross() glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPixelZoom((float)axiscrossSize / 30, (float)axiscrossSize / 30); // 30 = 3 (character pixmap ratio) * 10 (default axiscrossSize) glRasterPos2d(xpos[0], xpos[1]); - glDrawPixels(XPM_WIDTH, XPM_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, XPM_PIXEL_DATA); + glDrawPixels(XPM_WIDTH, XPM_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, XPM_pixel_data); glRasterPos2d(ypos[0], ypos[1]); - glDrawPixels(YPM_WIDTH, YPM_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, YPM_PIXEL_DATA); + glDrawPixels(YPM_WIDTH, YPM_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, YPM_pixel_data); glRasterPos2d(zpos[0], zpos[1]); - glDrawPixels(ZPM_WIDTH, ZPM_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, ZPM_PIXEL_DATA); + glDrawPixels(ZPM_WIDTH, ZPM_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, ZPM_pixel_data); glPixelStorei(GL_UNPACK_ALIGNMENT, unpack); glPopMatrix(); diff --git a/src/Gui/View3DInventorViewer.h b/src/Gui/View3DInventorViewer.h index 58e23fdef0..5efa45de4f 100644 --- a/src/Gui/View3DInventorViewer.h +++ b/src/Gui/View3DInventorViewer.h @@ -41,6 +41,8 @@ #include "Namespace.h" #include "Selection.h" + +#include "CornerCrossLetters.h" #include "View3DInventorSelection.h" #include "Quarter/SoQTQuarterAdaptor.h" @@ -414,6 +416,7 @@ public: const SbColor& midColor); void setNavigationType(Base::Type); + void setAxisLetterColor(const SbColor& color); void setAxisCross(bool on); bool hasAxisCross(); @@ -536,7 +539,11 @@ private: ViewerEventFilter* viewerEventFilter; - PyObject *_viewerPy; + PyObject* _viewerPy; + + static unsigned char XPM_pixel_data[YPM_WIDTH * YPM_HEIGHT * YPM_BYTES_PER_PIXEL + 1]; + static unsigned char YPM_pixel_data[YPM_WIDTH * YPM_HEIGHT * YPM_BYTES_PER_PIXEL + 1]; + static unsigned char ZPM_pixel_data[ZPM_WIDTH * ZPM_HEIGHT * ZPM_BYTES_PER_PIXEL + 1]; // friends friend class NavigationStyle; diff --git a/src/Gui/View3DSettings.cpp b/src/Gui/View3DSettings.cpp index 2d0eb0839c..dc0b0e21c4 100644 --- a/src/Gui/View3DSettings.cpp +++ b/src/Gui/View3DSettings.cpp @@ -73,6 +73,7 @@ void View3DSettings::applySettings() OnChange(*hGrp,"EyeDistance"); OnChange(*hGrp,"CornerCoordSystem"); OnChange(*hGrp,"CornerCoordSystemSize"); + OnChange(*hGrp,"AxisLetterColor"); OnChange(*hGrp,"ShowAxisCross"); OnChange(*hGrp,"UseNavigationAnimations"); OnChange(*hGrp,"UseSpinningAnimations"); @@ -290,6 +291,15 @@ void View3DSettings::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M _viewer->setFeedbackSize(rGrp.GetInt("CornerCoordSystemSize", 10)); } } + else if (strcmp(Reason,"AxisLetterColor") == 0) { + unsigned long backlight = rGrp.GetUnsigned("AxisLetterColor", 0x00000000); // default color (black) + float transparency; + SbColor color; + color.setPackedValue((uint32_t)backlight, transparency); + for (auto _viewer : _viewers) { + _viewer->setAxisLetterColor(color); + } + } else if (strcmp(Reason,"ShowAxisCross") == 0) { for (auto _viewer : _viewers) { _viewer->setAxisCross(rGrp.GetBool("ShowAxisCross", false));