Merge pull request #19890 from Shkolik/sketcher_defining_color
Sketcher: Preference color added for External defining geometry
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
<FCUInt Name="EditedEdgeColor" Value="4294967295"/>
|
||||
<FCUInt Name="ConstructionColor" Value="56575"/>
|
||||
<FCUInt Name="ExternalColor" Value="3425924095"/>
|
||||
<FCUInt Name="ExternalDefiningColor" Value="3425924095"/>
|
||||
<FCUInt Name="InvalidSketchColor" Value="4285333759"/>
|
||||
<FCUInt Name="FullyConstrainedColor" Value="16711935"/>
|
||||
<FCUInt Name="InternalAlignedGeoColor" Value="2998042623"/>
|
||||
|
||||
@@ -161,6 +161,10 @@ void EditModeCoinManager::ParameterObserver::initParameters()
|
||||
[this, &drawingParameters = Client.drawingParameters](const std::string& param) {
|
||||
updateWidth(drawingParameters.ExternalWidth, param, 2);
|
||||
}},
|
||||
{"ExternalDefiningWidth",
|
||||
[this, &drawingParameters = Client.drawingParameters](const std::string& param) {
|
||||
updateWidth(drawingParameters.ExternalDefiningWidth, param, 2);
|
||||
}},
|
||||
{"EdgePattern",
|
||||
[this, &drawingParameters = Client.drawingParameters](const std::string& param) {
|
||||
updatePattern(drawingParameters.CurvePattern, param, 0b1111111111111111);
|
||||
@@ -177,6 +181,10 @@ void EditModeCoinManager::ParameterObserver::initParameters()
|
||||
[this, &drawingParameters = Client.drawingParameters](const std::string& param) {
|
||||
updatePattern(drawingParameters.ExternalPattern, param, 0b1111110011111100);
|
||||
}},
|
||||
{"ExternalDefiningPattern",
|
||||
[this, &drawingParameters = Client.drawingParameters](const std::string& param) {
|
||||
updatePattern(drawingParameters.ExternalDefiningPattern, param, 0b1111111111111111);
|
||||
}},
|
||||
{"CreateLineColor",
|
||||
[this, drawingParameters = Client.drawingParameters](const std::string& param) {
|
||||
updateColor(drawingParameters.CreateCurveColor, param);
|
||||
@@ -241,6 +249,10 @@ void EditModeCoinManager::ParameterObserver::initParameters()
|
||||
[this, drawingParameters = Client.drawingParameters](const std::string& param) {
|
||||
updateColor(drawingParameters.CurveExternalColor, param);
|
||||
}},
|
||||
{"ExternalDefiningColor",
|
||||
[this, drawingParameters = Client.drawingParameters](const std::string& param) {
|
||||
updateColor(drawingParameters.CurveExternalDefiningColor, param);
|
||||
}},
|
||||
{"HighlightColor",
|
||||
[this, drawingParameters = Client.drawingParameters](const std::string& param) {
|
||||
updateColor(drawingParameters.PreselectColor, param);
|
||||
@@ -1119,6 +1131,8 @@ void EditModeCoinManager::updateInventorWidths()
|
||||
drawingParameters.InternalWidth * drawingParameters.pixelScalingFactor;
|
||||
editModeScenegraphNodes.CurvesExternalDrawStyle->lineWidth =
|
||||
drawingParameters.ExternalWidth * drawingParameters.pixelScalingFactor;
|
||||
editModeScenegraphNodes.CurvesExternalDefiningDrawStyle->lineWidth =
|
||||
drawingParameters.ExternalDefiningWidth * drawingParameters.pixelScalingFactor;
|
||||
}
|
||||
|
||||
void EditModeCoinManager::updateInventorPatterns()
|
||||
@@ -1130,6 +1144,8 @@ void EditModeCoinManager::updateInventorPatterns()
|
||||
drawingParameters.InternalPattern;
|
||||
editModeScenegraphNodes.CurvesExternalDrawStyle->linePattern =
|
||||
drawingParameters.ExternalPattern;
|
||||
editModeScenegraphNodes.CurvesExternalDefiningDrawStyle->linePattern =
|
||||
drawingParameters.ExternalDefiningPattern;
|
||||
}
|
||||
|
||||
void EditModeCoinManager::updateInventorColors()
|
||||
|
||||
@@ -41,9 +41,7 @@ int GeometryLayerParameters::getSubLayerIndex(const int geoId,
|
||||
if (isExternal) {
|
||||
auto egf = Sketcher::ExternalGeometryFacade::getFacade(geom->clone());
|
||||
if (egf->testFlag(Sketcher::ExternalGeometryExtension::Defining)) {
|
||||
// Defining external are added to the Normal sublayers because they
|
||||
// share the same line style.
|
||||
return static_cast<int>(SubLayer::Normal);
|
||||
return static_cast<int>(SubLayer::ExternalDefining);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +80,9 @@ SbColor DrawingParameters::PreselectColor(0.88f, 0.88f, 0.0f); // #E1E
|
||||
SbColor DrawingParameters::SelectColor(0.11f, 0.68f, 0.11f); // #1CAD1C -> ( 28,173, 28)
|
||||
SbColor DrawingParameters::PreselectSelectedColor(0.36f, 0.48f, 0.11f); // #5D7B1C -> ( 93,123, 28)
|
||||
SbColor DrawingParameters::CurveExternalColor(0.8f, 0.2f, 0.6f); // #CC3399 -> (204, 51,153)
|
||||
SbColor DrawingParameters::CurveDraftColor(0.0f, 0.0f, 0.86f); // #0000DC -> ( 0, 0,220)
|
||||
SbColor
|
||||
DrawingParameters::CurveExternalDefiningColor(0.8f, 0.2f, 0.6f); // #CC3399 -> (204, 51,153)
|
||||
SbColor DrawingParameters::CurveDraftColor(0.0f, 0.0f, 0.86f); // #0000DC -> ( 0, 0,220)
|
||||
SbColor
|
||||
DrawingParameters::FullyConstraintConstructionElementColor(0.56f,
|
||||
0.66f,
|
||||
|
||||
@@ -116,8 +116,9 @@ struct DrawingParameters
|
||||
static SbColor
|
||||
PreselectSelectedColor; // Color used for preselection when geometry is already selected
|
||||
static SbColor SelectColor; // Color used for selected geometry
|
||||
static SbColor CurveExternalColor; // Color used for external geometry
|
||||
static SbColor CurveDraftColor; // Color used for construction geometry
|
||||
static SbColor CurveExternalColor; // Color used for external geometry
|
||||
static SbColor CurveExternalDefiningColor; // Color used for external defining geometry
|
||||
static SbColor CurveDraftColor; // Color used for construction geometry
|
||||
static SbColor FullyConstraintConstructionElementColor; // Color used for a fully constrained
|
||||
// construction element
|
||||
static SbColor ConstrDimColor; // Color used for a dimensional constraints
|
||||
@@ -139,15 +140,18 @@ struct DrawingParameters
|
||||
int constraintIconSize = 15; // Size of constraint icons
|
||||
int markerSize = 7; // Size used for markers
|
||||
|
||||
int CurveWidth = 2; // width of normal edges
|
||||
int ConstructionWidth = 1; // width of construction edges
|
||||
int InternalWidth = 1; // width of internal edges
|
||||
int ExternalWidth = 1; // width of external edges
|
||||
int CurveWidth = 2; // width of normal edges
|
||||
int ConstructionWidth = 1; // width of construction edges
|
||||
int InternalWidth = 1; // width of internal edges
|
||||
int ExternalWidth = 1; // width of external edges
|
||||
int ExternalDefiningWidth = 1; // width of external defining edges
|
||||
|
||||
unsigned int CurvePattern = 0b1111111111111111; // pattern of normal edges
|
||||
unsigned int ConstructionPattern = 0b1111110011111100; // pattern of construction edges
|
||||
unsigned int InternalPattern = 0b1111110011111100; // pattern of internal edges
|
||||
unsigned int ExternalPattern = 0b1111110011111100; // pattern of external edges
|
||||
unsigned int ExternalDefiningPattern =
|
||||
0b1111111111111111; // pattern of external defining edges
|
||||
//@}
|
||||
|
||||
DrawingParameters()
|
||||
@@ -289,6 +293,7 @@ public:
|
||||
Construction = 1,
|
||||
Internal = 2,
|
||||
External = 3,
|
||||
ExternalDefining = 4
|
||||
};
|
||||
|
||||
void reset()
|
||||
@@ -342,9 +347,15 @@ public:
|
||||
return t == static_cast<int>(SubLayer::External);
|
||||
}
|
||||
|
||||
bool isExternalDefiningSubLayer(int t) const
|
||||
{
|
||||
return t == static_cast<int>(SubLayer::ExternalDefining);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
int CoinLayers = 1; // defaults to a single Coin Geometry Layer.
|
||||
int SubLayers = 4; // Normal, Construction, Internal, External.
|
||||
int SubLayers = 5; // Normal, Construction, Internal, External.
|
||||
};
|
||||
|
||||
/** @brief Struct to hold the results of analysis performed on geometry
|
||||
@@ -410,6 +421,7 @@ struct EditModeScenegraphNodes
|
||||
SoDrawStyle* CurvesConstructionDrawStyle;
|
||||
SoDrawStyle* CurvesInternalDrawStyle;
|
||||
SoDrawStyle* CurvesExternalDrawStyle;
|
||||
SoDrawStyle* CurvesExternalDefiningDrawStyle;
|
||||
SoDrawStyle* HiddenCurvesDrawStyle;
|
||||
//@}
|
||||
|
||||
|
||||
@@ -135,6 +135,16 @@ void EditModeGeometryCoinManager::updateGeometryColor(const GeoListFacade& geoli
|
||||
return false;
|
||||
};
|
||||
|
||||
auto isExternalDefiningGeomPoint = [&geolistfacade](int GeoId) {
|
||||
auto geom = geolistfacade.getGeometryFacadeFromGeoId(GeoId);
|
||||
if (geom) {
|
||||
auto egf = ExternalGeometryFacade::getFacade(geom->clone());
|
||||
auto ref = egf->getRef();
|
||||
return egf->testFlag(ExternalGeometryExtension::Defining);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
auto isCoincident = [&](int GeoId, Sketcher::PointPos PosId) {
|
||||
const std::vector<Sketcher::Constraint*>& constraints =
|
||||
ViewProviderSketchCoinAttorney::getConstraints(viewProvider);
|
||||
@@ -202,7 +212,9 @@ void EditModeGeometryCoinManager::updateGeometryColor(const GeoListFacade& geoli
|
||||
pcolor[i] = drawingParameters.ConstrIcoColor;
|
||||
}
|
||||
else {
|
||||
pcolor[i] = drawingParameters.CurveExternalColor;
|
||||
pcolor[i] = isExternalDefiningGeomPoint(GeoId)
|
||||
? drawingParameters.CurveExternalDefiningColor
|
||||
: drawingParameters.CurveExternalColor;
|
||||
}
|
||||
}
|
||||
else if (issketchinvalid) {
|
||||
@@ -423,7 +435,9 @@ void EditModeGeometryCoinManager::updateGeometryColor(const GeoListFacade& geoli
|
||||
color[i] = drawingParameters.InvalidSketchColor;
|
||||
}
|
||||
else {
|
||||
color[i] = drawingParameters.CurveExternalColor;
|
||||
color[i] = egf->testFlag(ExternalGeometryExtension::Defining)
|
||||
? drawingParameters.CurveExternalDefiningColor
|
||||
: drawingParameters.CurveExternalColor;
|
||||
}
|
||||
for (int k = j; j < k + indexes; j++) {
|
||||
verts[j].getValue(x, y, z);
|
||||
@@ -642,6 +656,15 @@ void EditModeGeometryCoinManager::createEditModeCurveInventorNodes()
|
||||
drawingParameters.ExternalPattern;
|
||||
editModeScenegraphNodes.CurvesExternalDrawStyle->linePatternScaleFactor = 2;
|
||||
|
||||
editModeScenegraphNodes.CurvesExternalDefiningDrawStyle = new SoDrawStyle;
|
||||
editModeScenegraphNodes.CurvesExternalDefiningDrawStyle->setName(
|
||||
"CurvesExternalDefiningDrawStyle");
|
||||
editModeScenegraphNodes.CurvesExternalDefiningDrawStyle->lineWidth =
|
||||
drawingParameters.ExternalDefiningWidth * drawingParameters.pixelScalingFactor;
|
||||
editModeScenegraphNodes.CurvesExternalDefiningDrawStyle->linePattern =
|
||||
drawingParameters.ExternalDefiningPattern;
|
||||
editModeScenegraphNodes.CurvesExternalDefiningDrawStyle->linePatternScaleFactor = 2;
|
||||
|
||||
for (int i = 0; i < geometryLayerParameters.getCoinLayerCount(); i++) {
|
||||
editModeScenegraphNodes.CurvesMaterials.emplace_back();
|
||||
editModeScenegraphNodes.CurvesCoordinate.emplace_back();
|
||||
@@ -674,6 +697,9 @@ void EditModeGeometryCoinManager::createEditModeCurveInventorNodes()
|
||||
else if (geometryLayerParameters.isExternalSubLayer(t)) {
|
||||
sep->addChild(editModeScenegraphNodes.CurvesExternalDrawStyle);
|
||||
}
|
||||
else if (geometryLayerParameters.isExternalDefiningSubLayer(t)) {
|
||||
sep->addChild(editModeScenegraphNodes.CurvesExternalDefiningDrawStyle);
|
||||
}
|
||||
else {
|
||||
sep->addChild(editModeScenegraphNodes.CurvesDrawStyle);
|
||||
}
|
||||
|
||||
@@ -518,6 +518,7 @@ SketcherSettingsAppearance::SketcherSettingsAppearance(QWidget* parent)
|
||||
ui->ConstructionPattern->setIconSize(QSize(70, 12));
|
||||
ui->InternalPattern->setIconSize(QSize(70, 12));
|
||||
ui->ExternalPattern->setIconSize(QSize(70, 12));
|
||||
ui->ExternalDefiningPattern->setIconSize(QSize(70, 12));
|
||||
for (auto& style : styles) {
|
||||
QPixmap px(ui->EdgePattern->iconSize());
|
||||
px.fill(Qt::transparent);
|
||||
@@ -537,6 +538,7 @@ SketcherSettingsAppearance::SketcherSettingsAppearance(QWidget* parent)
|
||||
ui->ConstructionPattern->addItem(QIcon(px), QString(), QVariant(style));
|
||||
ui->InternalPattern->addItem(QIcon(px), QString(), QVariant(style));
|
||||
ui->ExternalPattern->addItem(QIcon(px), QString(), QVariant(style));
|
||||
ui->ExternalDefiningPattern->addItem(QIcon(px), QString(), QVariant(style));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -556,6 +558,7 @@ void SketcherSettingsAppearance::saveSettings()
|
||||
ui->EditedEdgeColor->onSave();
|
||||
ui->ConstructionColor->onSave();
|
||||
ui->ExternalColor->onSave();
|
||||
ui->ExternalDefiningColor->onSave();
|
||||
ui->InvalidSketchColor->onSave();
|
||||
ui->FullyConstrainedColor->onSave();
|
||||
ui->InternalAlignedGeoColor->onSave();
|
||||
@@ -577,6 +580,7 @@ void SketcherSettingsAppearance::saveSettings()
|
||||
ui->ConstructionWidth->onSave();
|
||||
ui->InternalWidth->onSave();
|
||||
ui->ExternalWidth->onSave();
|
||||
ui->ExternalDefiningWidth->onSave();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Sketcher/View");
|
||||
@@ -595,6 +599,10 @@ void SketcherSettingsAppearance::saveSettings()
|
||||
data = ui->ExternalPattern->itemData(ui->ExternalPattern->currentIndex());
|
||||
pattern = data.toInt();
|
||||
hGrp->SetInt("ExternalPattern", pattern);
|
||||
|
||||
data = ui->ExternalDefiningPattern->itemData(ui->ExternalDefiningPattern->currentIndex());
|
||||
pattern = data.toInt();
|
||||
hGrp->SetInt("ExternalDefiningPattern", pattern);
|
||||
}
|
||||
|
||||
void SketcherSettingsAppearance::loadSettings()
|
||||
@@ -605,6 +613,7 @@ void SketcherSettingsAppearance::loadSettings()
|
||||
ui->EditedEdgeColor->onRestore();
|
||||
ui->ConstructionColor->onRestore();
|
||||
ui->ExternalColor->onRestore();
|
||||
ui->ExternalDefiningColor->onRestore();
|
||||
ui->InvalidSketchColor->onRestore();
|
||||
ui->FullyConstrainedColor->onRestore();
|
||||
ui->InternalAlignedGeoColor->onRestore();
|
||||
@@ -626,6 +635,7 @@ void SketcherSettingsAppearance::loadSettings()
|
||||
ui->ConstructionWidth->onRestore();
|
||||
ui->InternalWidth->onRestore();
|
||||
ui->ExternalWidth->onRestore();
|
||||
ui->ExternalDefiningWidth->onRestore();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Sketcher/View");
|
||||
@@ -656,6 +666,13 @@ void SketcherSettingsAppearance::loadSettings()
|
||||
index = 0;
|
||||
}
|
||||
ui->ExternalPattern->setCurrentIndex(index);
|
||||
|
||||
pattern = hGrp->GetInt("ExternalDefiningPattern", 0b1111111111111111);
|
||||
index = ui->ExternalDefiningPattern->findData(QVariant(pattern));
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
ui->ExternalDefiningPattern->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -487,7 +487,7 @@
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_20">
|
||||
<property name="text">
|
||||
<string>External geometry</string>
|
||||
<string>External reference geometry</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -555,7 +555,78 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_21">
|
||||
<property name="text">
|
||||
<string>External defining geometry</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="ExternalDefiningColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Color of external defining geometry in edit mode</string>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>204</red>
|
||||
<green>51</green>
|
||||
<blue>153</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ExternalDefiningColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="3">
|
||||
<widget class="QComboBox" name="ExternalDefiningPattern">
|
||||
<property name="toolTip">
|
||||
<string>Line pattern of external defining edges.</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="4">
|
||||
<widget class="Gui::PrefSpinBox" name="ExternalDefiningWidth">
|
||||
<property name="toolTip">
|
||||
<string>Width of external defining edges.</string>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">px</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string notr="true"> px</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>99</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ExternalDefiningWidth</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Sketcher/View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="label_45">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@@ -568,7 +639,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<item row="11" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="FullyConstrainedColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
@@ -594,14 +665,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Invalid sketch</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<item row="12" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="InvalidSketchColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
|
||||
Reference in New Issue
Block a user