Added color prefs to sketcher create commands

Create geometry commands in sketcher now have configurable crosshair color and editCurve color.
This commit is contained in:
Jeff
2017-11-15 08:51:26 -08:00
committed by wmayer
parent 1f76beba61
commit c770ce7a34
6 changed files with 229 additions and 119 deletions

View File

@@ -27,6 +27,7 @@
# include <QApplication>
#endif
#include <stdlib.h>
#include <qdebug.h>
#include <QString>
#include <GC_MakeEllipse.hxx>
@@ -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);
}

View File

@@ -98,6 +98,7 @@ protected:
void unsetCursor(void);
void applyCursor(void);
void applyCursor(QCursor &newCursor);
void setCrosshairColor();
ViewProviderSketch *sketchgui;
QCursor oldCursor;

View File

@@ -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();
}
/**

View File

@@ -89,6 +89,36 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Making line color</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::PrefColorButton" name="CreateLineColor">
<property name="color">
<color>
<red>204</red>
<green>204</green>
<blue>204</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>CreateLineColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
@@ -101,7 +131,7 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="Gui::PrefColorButton" name="EditedEdgeColor">
<property name="toolTip">
<string>The color of edges being edited</string>
@@ -121,7 +151,7 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
@@ -134,7 +164,7 @@
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="Gui::PrefColorButton" name="EditedVertexColor">
<property name="toolTip">
<string>The color of vertices being edited</string>
@@ -154,7 +184,7 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
@@ -167,27 +197,7 @@
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="Gui::PrefColorButton" name="DatumColor">
<property name="toolTip">
<string>The color of the datum portion of a driving constraint</string>
</property>
<property name="color">
<color>
<red>255</red>
<green>38</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>ConstrainedDimColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="Gui::PrefColorButton" name="ConstructionColor">
<property name="toolTip">
<string>The color of construction geometry in edit mode</string>
@@ -207,7 +217,7 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_20">
<property name="minimumSize">
<size>
@@ -220,7 +230,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="Gui::PrefColorButton" name="ExternalColor">
<property name="toolTip">
<string>The color of external geometry in edit mode</string>
@@ -240,7 +250,7 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_4">
<property name="minimumSize">
<size>
@@ -253,20 +263,7 @@
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_14">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Constraint color</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="Gui::PrefColorButton" name="FullyConstrainedColor">
<property name="toolTip">
<string>The color of fully constrained geometry in edit mode</string>
@@ -286,7 +283,67 @@
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_14">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Constraint color</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="Gui::PrefColorButton" name="ConstrainedColor">
<property name="toolTip">
<string>The color of driving constraints in edit mode</string>
</property>
<property name="color">
<color>
<red>255</red>
<green>38</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>ConstrainedIcoColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Reference Constraint color</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="Gui::PrefColorButton" name="NonDrivingConstraintColor">
<property name="toolTip">
<string>The color of reference constrains and datum in edit mode</string>
</property>
<property name="color">
<color>
<red>0</red>
<green>38</green>
<blue>255</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>NonDrivingConstrDimColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_15">
<property name="minimumSize">
<size>
@@ -299,7 +356,27 @@
</property>
</widget>
</item>
<item row="10" column="0">
<item row="10" column="1">
<widget class="Gui::PrefColorButton" name="DatumColor">
<property name="toolTip">
<string>The color of the datum portion of a driving constraint</string>
</property>
<property name="color">
<color>
<red>255</red>
<green>38</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>ConstrainedDimColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_16">
<property name="minimumSize">
<size>
@@ -312,20 +389,7 @@
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_12">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Default vertex size</string>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="Gui::PrefSpinBox" name="SketcherDatumWidth">
<property name="toolTip">
<string>The default line thickness for new shapes</string>
@@ -348,7 +412,7 @@
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_13">
<widget class="QLabel" name="label_12">
<property name="minimumSize">
<size>
<width>182</width>
@@ -356,11 +420,11 @@
</size>
</property>
<property name="text">
<string>Default line width</string>
<string>Default vertex size</string>
</property>
</widget>
</item>
<item row="11" column="1">
<item row="12" column="1">
<widget class="Gui::PrefSpinBox" name="DefaultSketcherVertexWidth">
<property name="toolTip">
<string>The default line thickness for new shapes</string>
@@ -383,7 +447,7 @@
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="label_13">
<property name="minimumSize">
<size>
<width>182</width>
@@ -391,28 +455,11 @@
</size>
</property>
<property name="text">
<string>Cursor text color</string>
<string>Default line width</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="Gui::PrefColorButton" name="CursorTextColor">
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>255</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>CursorTextColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="Gui::PrefSpinBox" name="DefaultSketcherLineWidth">
<property name="toolTip">
<string>The default line thickness for new shapes</string>
@@ -434,47 +481,60 @@
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_8">
<item row="14" column="0">
<widget class="QLabel" name="label_5">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Reference Constraint color</string>
<string>Cursor text color</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="Gui::PrefColorButton" name="ConstrainedColor">
<property name="toolTip">
<string>The color of driving constraints in edit mode</string>
</property>
<item row="14" column="1">
<widget class="Gui::PrefColorButton" name="CursorTextColor">
<property name="color">
<color>
<red>255</red>
<green>38</green>
<blue>0</blue>
<red>0</red>
<green>0</green>
<blue>255</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>ConstrainedIcoColor</cstring>
<cstring>CursorTextColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="Gui::PrefColorButton" name="NonDrivingConstraintColor">
<property name="toolTip">
<string>The color of reference constrains and datum in edit mode</string>
<item row="15" column="0">
<widget class="QLabel" name="label_19">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Cursor crosshair color</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="Gui::PrefColorButton" name="CursorCrosshairColor">
<property name="color">
<color>
<red>0</red>
<green>38</green>
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>NonDrivingConstrDimColor</cstring>
<cstring>CursorCrosshairColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>

View File

@@ -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<Base::Vector2d> &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<Base::Vector2d>::const_iterator it = EditCurve.begin(); it != EditCurve.end(); ++it,i++)
for (std::vector<Base::Vector2d>::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);

View File

@@ -364,6 +364,7 @@ protected:
// colors
static SbColor VertexColor;
static SbColor CurveColor;
static SbColor CreateCurveColor;
static SbColor CurveDraftColor;
static SbColor CurveExternalColor;
static SbColor CrossColorV;