[Sketcher] enable BSpline commands in contextual right click menu

This commit is contained in:
Max Wilfinger
2024-01-13 17:33:02 +01:00
committed by Chris Hennes
parent e72efde5eb
commit b57a6b504c
4 changed files with 134 additions and 32 deletions

View File

@@ -15,6 +15,17 @@
xmlns:dc="http://purl.org/dc/elements/1.1/">
<defs
id="defs2871">
<linearGradient
id="linearGradient4">
<stop
style="stop-color:#3f6fab;stop-opacity:1;"
offset="0"
id="stop3" />
<stop
style="stop-color:#729fcf;stop-opacity:1;"
offset="1"
id="stop4" />
</linearGradient>
<linearGradient
id="linearGradient62">
<stop
@@ -417,7 +428,7 @@
x2="-22"
y2="5" />
<linearGradient
xlink:href="#linearGradient3836-9-3"
xlink:href="#linearGradient4"
id="linearGradient97"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.82607043,0,0,0.82533448,-4.0098079,1.346708)"
@@ -425,6 +436,15 @@
y1="18"
x2="-22"
y2="5" />
<linearGradient
y2="131.22015"
x2="154.4444"
y1="161.22015"
x1="164.4444"
gradientTransform="translate(-188.44439,-101.22016)"
gradientUnits="userSpaceOnUse"
id="linearGradient3112"
xlink:href="#linearGradient3815" />
</defs>
<metadata
id="metadata2874">
@@ -464,7 +484,8 @@
transform="matrix(0.1460346,0,0,0.1460346,-220.10298,-55.131225)">
<g
transform="translate(-451.94762,54.987483)"
id="g4428-3-2">
id="g4428-3-2"
style="display:inline">
<path
style="fill:none;stroke:#151819;stroke-width:8.27355;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:8.27355, 16.5471;stroke-dashoffset:8.27355;stroke-opacity:1"
id="path3044-28"
@@ -519,7 +540,7 @@
d="m -24.358888,7.0362241 a 5.782493,5.7773415 0 1 1 8.784093,7.5158349 5.782493,5.7773415 0 0 1 -8.784093,-7.5158349 z" />
</g>
<g
transform="matrix(5.3322609,0,0,5.33226,1983.4426,601.87102)"
transform="matrix(5.3322609,0,0,5.33226,1983.4426,588.17564)"
id="g95"
style="stroke-width:1.2842">
<path
@@ -536,11 +557,11 @@
id="g97"
style="stroke-width:1.2842">
<path
style="fill:none;stroke:#2e0000;stroke-width:2.56841;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
style="fill:none;stroke:#0b1521;stroke-width:2.56841;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path96"
d="M -26.310778,5.3580033 A 8.3519646,8.3515832 0.02039876 1 1 -13.623399,16.222662 8.3519646,8.3515832 0.02039876 1 1 -26.310778,5.3580033 Z" />
<path
style="fill:url(#linearGradient97);fill-opacity:1;stroke:#ef2929;stroke-width:2.56842;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
style="fill:url(#linearGradient97);fill-opacity:1;stroke:#729fcf;stroke-width:2.56842;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path97"
d="m -24.358888,7.0362241 a 5.782493,5.7773415 0 1 1 8.784093,7.5158349 5.782493,5.7773415 0 0 1 -8.784093,-7.5158349 z" />
</g>

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -380,7 +380,7 @@
id="path3826" />
</g>
<g
transform="matrix(0.77869459,0,0,0.77869445,66.2831,20.597628)"
transform="matrix(0.77869459,0,0,0.77869445,63.903318,22.302657)"
id="g3"
style="display:inline;stroke-width:1.2842">
<path
@@ -392,5 +392,9 @@
id="path3"
d="m -24.358888,7.0362241 a 5.782493,5.7773415 0 1 1 8.784093,7.5158349 5.782493,5.7773415 0 0 1 -8.784093,-7.5158349 z" />
</g>
<path
id="path1"
style="fill:none;fill-opacity:1;stroke:#8ae234;stroke-width:2;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1;paint-order:markers fill stroke"
d="m 37.956269,30.704899 c 0,-5.743254 4.655691,-10.39908 10.398778,-10.39908 m 10.398777,10.39908 c 0,5.743253 -4.655691,10.399079 -10.398777,10.39908" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -261,11 +261,11 @@
<linearGradient
id="linearGradient2">
<stop
style="stop-color:#73d216;stop-opacity:1;"
style="stop-color:#d3d7cf;stop-opacity:1;"
offset="0"
id="stop1" />
<stop
style="stop-color:#8ae234;stop-opacity:1;"
style="stop-color:#ffffff;stop-opacity:1;"
offset="1"
id="stop2" />
</linearGradient>
@@ -316,6 +316,15 @@
y1="35.978416"
x2="25.988253"
y2="29.916241" />
<linearGradient
xlink:href="#linearGradient2"
id="linearGradient3"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.82607043,0,0,0.82533448,-4.0098079,1.346708)"
x1="-18"
y1="18"
x2="-22"
y2="5" />
</defs>
<metadata
id="metadata2874">
@@ -368,7 +377,7 @@
</g>
<g
id="g1068-6"
transform="matrix(-1,0,0,1,45.987644,0)">
transform="matrix(-1,0,0,1,47.987644,0)">
<path
style="fill:url(#linearGradient1099);fill-opacity:1;fill-rule:evenodd;stroke:#0b1521;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 13.547502,28.511064 v -7.501616 l -10.4959114,1e-6 V 10.507184 H 13.547502 V 3.005568 l 9.44632,12.752748 z"
@@ -395,5 +404,18 @@
d="M 138.75945,-0.2767731 C 141.87413,39.053035 101.07195,19.660727 91.353198,47.348227"
style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1" />
</g>
<g
transform="matrix(0.77869459,0,0,0.77869445,39.542061,32.862232)"
id="g3"
style="display:inline;stroke-width:1.2842">
<path
style="fill:none;stroke:#151819;stroke-width:2.56841;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2"
d="M -26.310778,5.3580033 A 8.3519646,8.3515832 0.02039876 1 1 -13.623399,16.222662 8.3519646,8.3515832 0.02039876 1 1 -26.310778,5.3580033 Z" />
<path
style="fill:url(#linearGradient3);fill-opacity:1;stroke:#ffffff;stroke-width:2.56842;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path3"
d="m -24.358888,7.0362241 a 5.782493,5.7773415 0 1 1 8.784093,7.5158349 5.782493,5.7773415 0 0 1 -8.784093,-7.5158349 z" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -3886,6 +3886,11 @@ void ViewProviderSketch::generateContextMenu()
int selectedConics = 0;
int selectedPoints = 0;
int selectedConstraints = 0;
int selectedBsplines = 0;
int selectedBsplineKnots = 0;
int selectedOrigin = 0;
int selectedEndPoints = 0;
bool onlyOrigin = false;
Gui::MenuItem menu;
menu.setCommand("Sketcher context");
@@ -3896,31 +3901,70 @@ void ViewProviderSketch::generateContextMenu()
// if something is selected, count different elements in the current selection
if (selection.size() > 0) {
const std::vector<std::string> SubNames = selection[0].getSubNames();
for (auto& name : SubNames) {
if (name.substr(0, 4) == "Edge") {
++selectedEdges;
const Sketcher::SketchObject* obj;
if (selection[0].getObject()->isDerivedFrom<Sketcher::SketchObject>()) {
obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
for (auto& name : SubNames) {
int geoId = std::atoi(name.substr(4, 4000).c_str()) - 1;
if (geoId >= 0) {
const Part::Geometry* geo = getSketchObject()->getGeometry(geoId);
if (isLineSegment(*geo)) {
++selectedLines;
}
else {
++selectedConics;
const Part::Geometry* geo = getSketchObject()->getGeometry(geoId);
if (name.substr(0, 4) == "Edge") {
++selectedEdges;
if (geoId >= 0) {
if (isLineSegment(*geo)) {
++selectedLines;
}
else if (geo->is<Part::GeomBSplineCurve>()) {
++selectedBsplines;
}
else {
++selectedConics;
}
}
}
}
else if (name.substr(0, 4) == "Vert") {
++selectedPoints;
}
else if (name.substr(0, 4) == "Cons") {
++selectedConstraints;
else if (name.substr(0, 4) == "Vert") {
++selectedPoints;
Sketcher::PointPos posId;
getIdsFromName(name, obj, geoId, posId);
if (isBsplineKnotOrEndPoint(obj, geoId, posId)) {
++selectedBsplineKnots;
}
if (Sketcher::PointPos::start != posId || Sketcher::PointPos::end != posId) {
++selectedEndPoints;
}
}
else if (name.substr(0, 4) == "Cons") {
++selectedConstraints;
}
else if (name.substr(2, 5) == "Axis") {
++selectedEdges;
++selectedLines;
++selectedOrigin;
}
else if (name.substr(0, 4) == "Root") {
++selectedPoints;
++selectedOrigin;
}
}
}
if (selectedPoints + selectedEdges == selectedOrigin) {
onlyOrigin = true;
}
// build context menu items depending on the selection
if (selectedEdges >= 1 && selectedPoints == 0) {
if (selectedBsplines > 0 && selectedBsplines == selectedEdges && selectedPoints == 0
&& !onlyOrigin) {
menu << "Sketcher_BSplineInsertKnot"
<< "Sketcher_BSplineIncreaseDegree"
<< "Sketcher_BSplineDecreaseDegree";
}
else if (selectedBsplineKnots > 0 && selectedBsplineKnots == selectedPoints
&& selectedEdges == 0 && !onlyOrigin) {
if (selectedBsplineKnots == 1) {
menu << "Sketcher_BSplineIncreaseKnotMultiplicity"
<< "Sketcher_BSplineDecreaseKnotMultiplicity";
}
}
if (selectedEdges >= 1 && selectedPoints == 0 && selectedBsplines == 0 && !onlyOrigin) {
menu << "Sketcher_Dimension";
if (selectedConics == 0) {
menu << "Sketcher_ConstrainHorVer"
@@ -3948,9 +3992,9 @@ void ViewProviderSketch::generateContextMenu()
menu << "Sketcher_ConstrainTangent";
}
}
else if (selectedEdges == 1 && selectedPoints >= 1) {
else if (selectedEdges == 1 && selectedPoints >= 1 && !onlyOrigin) {
menu << "Sketcher_Dimension";
if (selectedConics == 0) {
if (selectedConics == 0 && selectedBsplines == 0) {
menu << "Sketcher_ConstrainCoincidentUnified"
<< "Sketcher_ConstrainHorVer"
<< "Sketcher_ConstrainVertical"
@@ -3958,6 +4002,10 @@ void ViewProviderSketch::generateContextMenu()
if (selectedPoints == 2) {
menu << "Sketcher_ConstrainSymmetric";
}
if (selectedPoints == 1) {
menu << "Sketcher_ConstrainPerpendicular"
<< "Sketcher_ConstrainTangent";
}
}
else {
menu << "Sketcher_ConstrainCoincidentUnified"
@@ -3965,7 +4013,7 @@ void ViewProviderSketch::generateContextMenu()
<< "Sketcher_ConstrainTangent";
}
}
else if (selectedEdges == 0 && selectedPoints >= 1) {
else if (selectedEdges == 0 && selectedPoints >= 1 && !onlyOrigin) {
menu << "Sketcher_Dimension";
if (selectedPoints > 1) {
@@ -3974,8 +4022,15 @@ void ViewProviderSketch::generateContextMenu()
<< "Sketcher_ConstrainVertical"
<< "Sketcher_ConstrainHorizontal";
}
if (selectedPoints == 2) {
menu << "Sketcher_ConstrainPerpendicular"
<< "Sketcher_ConstrainTangent";
if (selectedEndPoints == 2) {
menu << "Sketcher_JoinCurves";
}
}
}
else if (selectedLines >= 1 && selectedPoints >= 1) {
else if (selectedLines >= 1 && selectedPoints >= 1 && !onlyOrigin) {
menu << "Sketcher_Dimension"
<< "Sketcher_ConstrainHorVer"
<< "Sketcher_ConstrainVertical"