From c770ce7a343072dd2df74bf5b95ac4a114ce9213 Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 15 Nov 2017 08:51:26 -0800 Subject: [PATCH] Added color prefs to sketcher create commands Create geometry commands in sketcher now have configurable crosshair color and editCurve color. --- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 75 +++-- src/Mod/Sketcher/Gui/DrawSketchHandler.h | 1 + src/Mod/Sketcher/Gui/SketcherSettings.cpp | 4 + .../Sketcher/Gui/SketcherSettingsColors.ui | 256 +++++++++++------- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 11 +- src/Mod/Sketcher/Gui/ViewProviderSketch.h | 1 + 6 files changed, 229 insertions(+), 119 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index e1df861c5d..96dbf25038 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -27,6 +27,7 @@ # include #endif +#include #include #include #include @@ -226,10 +227,24 @@ void removeRedundantHorizontalVertical(Sketcher::SketchObject* psketch, /* Sketch commands =======================================================*/ +static const char cursor_crosshair_color_fmt[] = "+ c #%06lX"; +static char cursor_crosshair_color[11]; + +void DrawSketchHandler::setCrosshairColor() +{ + unsigned long color = 0xFFFFFFFF; // white + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath + ("User parameter:BaseApp/Preferences/View"); + color = hGrp->GetUnsigned("CursorCrosshairColor", color); + // from rgba to rgb + color = (color >> 8) & 0xFFFFFF; + sprintf(cursor_crosshair_color, cursor_crosshair_color_fmt, color); +} + /* XPM */ static const char *cursor_createline[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+.........................", @@ -279,6 +294,7 @@ public: virtual void activated(ViewProviderSketch *) { + setCrosshairColor(); setCursor(QPixmap(cursor_createline),7,7); } @@ -436,7 +452,7 @@ bool CmdSketcherCreateLine::isActive(void) /* XPM */ static const char *cursor_createbox[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+.........................", @@ -486,6 +502,7 @@ public: virtual void activated(ViewProviderSketch *) { + setCrosshairColor(); setCursor(QPixmap(cursor_createbox),7,7); } @@ -674,7 +691,7 @@ bool CmdSketcherCreateRectangle::isActive(void) /* XPM */ static const char *cursor_createlineset[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+.........................", @@ -830,6 +847,7 @@ public: virtual void activated(ViewProviderSketch *) { + setCrosshairColor(); setCursor(QPixmap(cursor_createlineset),7,7); } @@ -1365,7 +1383,7 @@ bool CmdSketcherCreatePolyline::isActive(void) /* XPM */ static const char *cursor_createarc[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+...........###...........", @@ -1424,6 +1442,7 @@ public: virtual void activated(ViewProviderSketch *) { + setCrosshairColor(); setCursor(QPixmap(cursor_createarc),7,7); } @@ -1636,7 +1655,7 @@ bool CmdSketcherCreateArc::isActive(void) /* XPM */ static const char *cursor_create3pointarc[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+...........###...........", @@ -1694,6 +1713,7 @@ public: virtual void activated(ViewProviderSketch *) { + setCrosshairColor(); setCursor(QPixmap(cursor_create3pointarc),7,7); } @@ -2047,7 +2067,7 @@ bool CmdSketcherCompCreateArc::isActive(void) /* XPM */ static const char *cursor_createcircle[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+.........................", @@ -2097,6 +2117,7 @@ public: virtual void activated(ViewProviderSketch *) { + setCrosshairColor(); setCursor(QPixmap(cursor_createcircle),7,7); } @@ -2249,7 +2270,7 @@ bool CmdSketcherCreateCircle::isActive(void) */ static const char *cursor_createellipse[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+.........................", @@ -2357,6 +2378,7 @@ public: */ virtual void activated(ViewProviderSketch *) { + setCrosshairColor(); setCursor(QPixmap(cursor_createellipse),7,7); if (constrMethod == 0) { method = CENTER_PERIAPSIS_B; @@ -3116,7 +3138,7 @@ bool CmdSketcherCreateEllipseBy3Points::isActive(void) /* XPM */ static const char *cursor_createarcofellipse[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+.........................", @@ -3173,6 +3195,7 @@ public: virtual void activated(ViewProviderSketch *) { + setCrosshairColor(); setCursor(QPixmap(cursor_createarcofellipse),7,7); } @@ -3488,7 +3511,7 @@ bool CmdSketcherCreateArcOfEllipse::isActive(void) /* XPM */ static const char *cursor_createarcofhyperbola[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+.........................", @@ -3546,6 +3569,7 @@ public: virtual void activated(ViewProviderSketch * /*sketchgui*/) { + setCrosshairColor(); setCursor(QPixmap(cursor_createarcofhyperbola),7,7); } @@ -3870,7 +3894,7 @@ bool CmdSketcherCreateArcOfHyperbola::isActive(void) /* XPM */ static const char *cursor_createarcofparabola[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+.........................", @@ -3930,6 +3954,7 @@ public: virtual void activated(ViewProviderSketch * /*sketchgui*/) { + setCrosshairColor(); setCursor(QPixmap(cursor_createarcofparabola),7,7); } @@ -4362,7 +4387,7 @@ bool CmdSketcherCompCreateConic::isActive(void) /* XPM */ static const char *cursor_createbspline[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+.........................", @@ -4423,6 +4448,7 @@ public: virtual void activated(ViewProviderSketch *) { + setCrosshairColor(); setCursor(QPixmap(cursor_createbspline),7,7); } @@ -4941,7 +4967,7 @@ bool CmdSketcherCompCreateBSpline::isActive(void) /* XPM */ static const char *cursor_create3pointcircle[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+.........................", @@ -4993,6 +5019,7 @@ public: virtual void activated(ViewProviderSketch *) { + setCrosshairColor(); setCursor(QPixmap(cursor_create3pointcircle),7,7); } @@ -5293,7 +5320,7 @@ bool CmdSketcherCompCreateCircle::isActive(void) /* XPM */ static const char *cursor_createpoint[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+.........................", @@ -5337,6 +5364,7 @@ public: virtual void activated(ViewProviderSketch *) { + setCrosshairColor(); setCursor(QPixmap(cursor_createpoint),7,7); } @@ -5539,7 +5567,7 @@ namespace SketcherGui { /* XPM */ static const char *cursor_createfillet[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "* c red", ". c None", "......+.........................", @@ -5592,6 +5620,7 @@ public: { Gui::Selection().rmvSelectionGate(); Gui::Selection().addSelectionGate(new FilletSelection(sketchgui->getObject())); + setCrosshairColor(); setCursor(QPixmap(cursor_createfillet),7,7); } @@ -5819,7 +5848,7 @@ namespace SketcherGui { /* XPM */ static const char *cursor_trimming[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "* c red", ". c None", "......+.........................", @@ -5869,6 +5898,7 @@ public: Gui::Selection().clearSelection(); Gui::Selection().rmvSelectionGate(); Gui::Selection().addSelectionGate(new TrimmingSelection(sketchgui->getObject())); + setCrosshairColor(); setCursor(QPixmap(cursor_trimming),7,7); } @@ -5986,7 +6016,7 @@ namespace SketcherGui { /* XPM */ static const char *cursor_extension[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "* c red", ". c None", "......+.........................", @@ -6049,6 +6079,7 @@ public: Gui::Selection().rmvSelectionGate(); filterGate = new ExtendSelection(sketchgui->getObject()); Gui::Selection().addSelectionGate(filterGate); + setCrosshairColor(); setCursor(QPixmap(cursor_extension),7,7); } @@ -6360,7 +6391,7 @@ namespace SketcherGui { /* XPM */ static const char *cursor_external[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "* c red", ". c None", "......+.........................", @@ -6418,6 +6449,7 @@ public: Gui::Selection().clearSelection(); Gui::Selection().rmvSelectionGate(); Gui::Selection().addSelectionGate(new ExternalSelection(sketchgui->getObject())); + setCrosshairColor(); setCursor(QPixmap(cursor_external),7,7); } @@ -6580,7 +6612,7 @@ namespace SketcherGui { /* XPM */ static const char *cursor_carboncopy[]={ "32 32 3 1", - "+ c white", + cursor_crosshair_color, "* c red", ". c None", "......+.........................", @@ -6638,6 +6670,7 @@ static const char *cursor_carboncopy[]={ Gui::Selection().clearSelection(); Gui::Selection().rmvSelectionGate(); Gui::Selection().addSelectionGate(new CarbonCopySelection(sketchgui->getObject())); + setCrosshairColor(); setCursor(QPixmap(cursor_carboncopy),7,7); } @@ -6752,7 +6785,7 @@ static const char *cursor_carboncopy[]={ /* XPM */ static const char *cursor_creatslot[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+.........................", @@ -6807,6 +6840,7 @@ public: virtual void activated(ViewProviderSketch *) { + setCrosshairColor(); setCursor(QPixmap(cursor_creatslot),7,7); } @@ -7031,7 +7065,7 @@ bool CmdSketcherCreateSlot::isActive(void) /* XPM */ static const char *cursor_createregularpolygon[]={ "32 32 3 1", -"+ c white", +cursor_crosshair_color, "# c red", ". c None", "......+.........................", @@ -7089,6 +7123,7 @@ public: virtual void activated(ViewProviderSketch *) { + setCrosshairColor(); setCursor(QPixmap(cursor_createregularpolygon),7,7); } diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.h b/src/Mod/Sketcher/Gui/DrawSketchHandler.h index cbdd47a147..ac831c7d99 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.h @@ -98,6 +98,7 @@ protected: void unsetCursor(void); void applyCursor(void); void applyCursor(QCursor &newCursor); + void setCrosshairColor(); ViewProviderSketch *sketchgui; QCursor oldCursor; diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.cpp b/src/Mod/Sketcher/Gui/SketcherSettings.cpp index 228487967e..9be89a7be9 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.cpp +++ b/src/Mod/Sketcher/Gui/SketcherSettings.cpp @@ -236,6 +236,8 @@ void SketcherSettingsColors::saveSettings() ui->DefaultSketcherLineWidth->onSave(); ui->CursorTextColor->onSave(); + ui->CursorCrosshairColor->onSave(); + ui->CreateLineColor->onSave(); } void SketcherSettingsColors::loadSettings() @@ -258,6 +260,8 @@ void SketcherSettingsColors::loadSettings() ui->DefaultSketcherLineWidth->onRestore(); ui->CursorTextColor->onRestore(); + ui->CursorCrosshairColor->onRestore(); + ui->CreateLineColor->onRestore(); } /** diff --git a/src/Mod/Sketcher/Gui/SketcherSettingsColors.ui b/src/Mod/Sketcher/Gui/SketcherSettingsColors.ui index 952e22a1dd..e6f1608c1b 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettingsColors.ui +++ b/src/Mod/Sketcher/Gui/SketcherSettingsColors.ui @@ -89,6 +89,36 @@ + + + + 182 + 0 + + + + Making line color + + + + + + + + 204 + 204 + 204 + + + + CreateLineColor + + + View + + + + @@ -101,7 +131,7 @@ - + The color of edges being edited @@ -121,7 +151,7 @@ - + @@ -134,7 +164,7 @@ - + The color of vertices being edited @@ -154,7 +184,7 @@ - + @@ -167,27 +197,7 @@ - - - - The color of the datum portion of a driving constraint - - - - 255 - 38 - 0 - - - - ConstrainedDimColor - - - View - - - - + The color of construction geometry in edit mode @@ -207,7 +217,7 @@ - + @@ -220,7 +230,7 @@ - + The color of external geometry in edit mode @@ -240,7 +250,7 @@ - + @@ -253,20 +263,7 @@ - - - - - 182 - 0 - - - - Constraint color - - - - + The color of fully constrained geometry in edit mode @@ -286,7 +283,67 @@ + + + + + 182 + 0 + + + + Constraint color + + + + + + + The color of driving constraints in edit mode + + + + 255 + 38 + 0 + + + + ConstrainedIcoColor + + + View + + + + + + Reference Constraint color + + + + + + + The color of reference constrains and datum in edit mode + + + + 0 + 38 + 255 + + + + NonDrivingConstrDimColor + + + View + + + + @@ -299,7 +356,27 @@ - + + + + The color of the datum portion of a driving constraint + + + + 255 + 38 + 0 + + + + ConstrainedDimColor + + + View + + + + @@ -312,20 +389,7 @@ - - - - - 182 - 0 - - - - Default vertex size - - - - + The default line thickness for new shapes @@ -348,7 +412,7 @@ - + 182 @@ -356,11 +420,11 @@ - Default line width + Default vertex size - + The default line thickness for new shapes @@ -383,7 +447,7 @@ - + 182 @@ -391,28 +455,11 @@ - Cursor text color + Default line width - - - - 0 - 0 - 255 - - - - CursorTextColor - - - View - - - - The default line thickness for new shapes @@ -434,47 +481,60 @@ - - + + + + + 182 + 0 + + - Reference Constraint color + Cursor text color - - - - The color of driving constraints in edit mode - + + - 255 - 38 - 0 + 0 + 0 + 255 - ConstrainedIcoColor + CursorTextColor View - - - - The color of reference constrains and datum in edit mode + + + + + 182 + 0 + + + Cursor crosshair color + + + + + - 0 - 38 + 255 + 255 255 - NonDrivingConstrDimColor + CursorCrosshairColor View diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index eaf406e2fe..29222321d3 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -145,6 +145,7 @@ SbColor ViewProviderSketch::InformationColor (0.0f,1.0f,0.0f); // SbColor ViewProviderSketch::PreselectColor (0.88f,0.88f,0.0f); // #E1E100 -> (225,225, 0) SbColor ViewProviderSketch::SelectColor (0.11f,0.68f,0.11f); // #1CAD1C -> ( 28,173, 28) SbColor ViewProviderSketch::PreselectSelectedColor (0.36f,0.48f,0.11f); // #5D7B1C -> ( 93,123, 28) +SbColor ViewProviderSketch::CreateCurveColor (0.8f,0.8f,0.8f); // #CCCCCC -> (204,204,204) // Variables for holding previous click SbTime ViewProviderSketch::prvClickTime; SbVec2s ViewProviderSketch::prvClickPos; @@ -5019,12 +5020,16 @@ void ViewProviderSketch::drawEdit(const std::vector &EditCurve) edit->EditCurveSet->numVertices.setNum(1); edit->EditCurvesCoordinate->point.setNum(EditCurve.size()); + edit->EditCurvesMaterials->diffuseColor.setNum(EditCurve.size()); SbVec3f *verts = edit->EditCurvesCoordinate->point.startEditing(); int32_t *index = edit->EditCurveSet->numVertices.startEditing(); + SbColor *color = edit->EditCurvesMaterials->diffuseColor.startEditing(); int i=0; // setting up the line set - for (std::vector::const_iterator it = EditCurve.begin(); it != EditCurve.end(); ++it,i++) + for (std::vector::const_iterator it = EditCurve.begin(); it != EditCurve.end(); ++it,i++) { verts[i].setValue(it->x,it->y,zEdit); + color[i] = CreateCurveColor; + } index[0] = EditCurve.size(); edit->EditCurvesCoordinate->point.finishEditing(); @@ -5180,6 +5185,10 @@ bool ViewProviderSketch::setEdit(int ModNum) color = (unsigned long)(CurveColor.getPackedValue()); color = hGrp->GetUnsigned("EditedEdgeColor", color); CurveColor.setPackedValue((uint32_t)color, transparency); + // set the create line (curve) color + color = (unsigned long)(CreateCurveColor.getPackedValue()); + color = hGrp->GetUnsigned("CreateLineColor", color); + CreateCurveColor.setPackedValue((uint32_t)color, transparency); // set the construction curve color color = (unsigned long)(CurveDraftColor.getPackedValue()); color = hGrp->GetUnsigned("ConstructionColor", color); diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.h b/src/Mod/Sketcher/Gui/ViewProviderSketch.h index a023dc59a6..443db9751c 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.h +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.h @@ -364,6 +364,7 @@ protected: // colors static SbColor VertexColor; static SbColor CurveColor; + static SbColor CreateCurveColor; static SbColor CurveDraftColor; static SbColor CurveExternalColor; static SbColor CrossColorV;