Sketcher: Constrain Contextual implementation.

This commit is contained in:
Paddle
2023-06-22 22:32:28 +02:00
parent 423cc42ac8
commit 8a858ae7ec
12 changed files with 1859 additions and 14 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -138,6 +138,13 @@ ViewProviderSketchDrawSketchHandlerAttorney::setAngleSnapping(ViewProviderSketch
vp.setAngleSnapping(enable, referencePoint);
}
inline void
ViewProviderSketchDrawSketchHandlerAttorney::moveConstraint(ViewProviderSketch& vp, int constNum,
const Base::Vector2d& toPos)
{
vp.moveConstraint(constNum, toPos);
}
/**************************** CurveConverter **********************************************/
@@ -1086,3 +1093,9 @@ void DrawSketchHandler::setAngleSnapping(bool enable, Base::Vector2d referencePo
ViewProviderSketchDrawSketchHandlerAttorney::setAngleSnapping(
*sketchgui, enable, referencePoint);
}
void DrawSketchHandler::moveConstraint(int constNum, const Base::Vector2d& toPos)
{
ViewProviderSketchDrawSketchHandlerAttorney::moveConstraint(
*sketchgui, constNum, toPos);
}

View File

@@ -104,6 +104,7 @@ private:
static inline int getPreselectCurve(const ViewProviderSketch& vp);
static inline int getPreselectCross(const ViewProviderSketch& vp);
static inline void moveConstraint(ViewProviderSketch& vp, int constNum, const Base::Vector2d& toPos);
friend class DrawSketchHandler;
};
@@ -230,6 +231,8 @@ protected:
void setAngleSnapping(bool enable, Base::Vector2d referencePoint = Base::Vector2d(0., 0.));
void moveConstraint(int constNum, const Base::Vector2d& toPos);
private:
void setSvgCursor(const QString& svgName, int x, int y,
const std::map<unsigned long, unsigned long>& colorMapping =

View File

@@ -53,6 +53,7 @@ using namespace SketcherGui;
EditDatumDialog::EditDatumDialog(ViewProviderSketch* vp, int ConstrNbr)
: ConstrNbr(ConstrNbr)
, success(false)
{
sketch = vp->getSketchObject();
const std::vector<Sketcher::Constraint*>& Constraints = sketch->Constraints.getValues();
@@ -70,7 +71,7 @@ EditDatumDialog::EditDatumDialog(Sketcher::SketchObject* pcSketch, int ConstrNbr
EditDatumDialog::~EditDatumDialog()
{}
void EditDatumDialog::exec(bool atCursor)
int EditDatumDialog::exec(bool atCursor)
{
// Return if constraint doesn't have editable value
if (Constr->isDimensional()) {
@@ -80,7 +81,7 @@ void EditDatumDialog::exec(bool atCursor)
QObject::tr("Dimensional constraint"),
QObject::tr("Not allowed to edit the datum because the "
"sketch contains conflicting constraints"));
return;
return QDialog::Rejected;
}
Base::Quantity init_val;
@@ -173,8 +174,10 @@ void EditDatumDialog::exec(bool atCursor)
dlg.setGeometry(x, y, dlg.geometry().width(), dlg.geometry().height());
}
dlg.exec();
return dlg.exec();
}
return QDialog::Rejected;
}
void EditDatumDialog::accepted()
@@ -233,6 +236,7 @@ void EditDatumDialog::accepted()
//}
tryAutoRecompute(sketch);
success = true;
}
catch (const Base::Exception& e) {
Gui::NotifyUserError(
@@ -253,6 +257,11 @@ void EditDatumDialog::rejected()
sketch->recomputeFeature();
}
bool EditDatumDialog::isSuccess()
{
return success;
}
void EditDatumDialog::drivingToggled(bool state)
{
if (state) {

View File

@@ -47,12 +47,14 @@ public:
EditDatumDialog(Sketcher::SketchObject* pcSketch, int ConstrNbr);
~EditDatumDialog() override;
void exec(bool atCursor = true);
int exec(bool atCursor = true);
bool isSuccess();
private:
Sketcher::SketchObject* sketch;
Sketcher::Constraint* Constr;
int ConstrNbr;
bool success;
std::unique_ptr<Ui_InsertDatum> ui_ins_datum;
private Q_SLOTS:

View File

@@ -7,6 +7,8 @@
<qresource>
<file>icons/constraints/Constraint_Block.svg</file>
<file>icons/constraints/Constraint_Concentric.svg</file>
<file>icons/constraints/Constraint_Contextual.svg</file>
<file>icons/constraints/Constraint_Contextual_Driven.svg</file>
<file>icons/constraints/Constraint_Diameter.svg</file>
<file>icons/constraints/Constraint_Diameter_Driven.svg</file>
<file>icons/constraints/Constraint_Ellipse_Axis_Angle.svg</file>

View File

@@ -0,0 +1,253 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="64px"
height="64px"
id="svg2816"
version="1.1"
sodipodi:docname="Constraint_Contextual.svg"
inkscape:version="1.1-beta1 (77e7b44db3, 2021-03-28)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<sodipodi:namedview
id="namedview29"
pagecolor="#505050"
bordercolor="#eeeeee"
borderopacity="1"
objecttolerance="10.0"
gridtolerance="10.0"
guidetolerance="10.0"
inkscape:pageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
showgrid="false"
inkscape:zoom="2.0798883"
inkscape:cx="-86.783507"
inkscape:cy="105.05372"
inkscape:window-width="3840"
inkscape:window-height="1571"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="svg2816" />
<defs
id="defs2818">
<linearGradient
id="linearGradient3602">
<stop
style="stop-color:#ff2600;stop-opacity:1"
offset="0"
id="stop3604" />
<stop
style="stop-color:#ff5f00;stop-opacity:1"
offset="1"
id="stop3606" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient3602-7"
id="linearGradient3608-5"
x1="3.909091"
y1="14.363636"
x2="24.81818"
y2="14.363636"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient3602-7">
<stop
style="stop-color:#c51900;stop-opacity:1"
offset="0"
id="stop3604-1" />
<stop
style="stop-color:#ff5f00;stop-opacity:1"
offset="1"
id="stop3606-3" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient3602-5"
id="linearGradient3608-1"
x1="3.909091"
y1="14.363636"
x2="24.81818"
y2="14.363636"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient3602-5">
<stop
style="stop-color:#c51900;stop-opacity:1"
offset="0"
id="stop3604-9" />
<stop
style="stop-color:#ff5f00;stop-opacity:1"
offset="1"
id="stop3606-9" />
</linearGradient>
<linearGradient
y2="14.363636"
x2="24.81818"
y1="14.363636"
x1="3.909091"
gradientUnits="userSpaceOnUse"
id="linearGradient3686"
xlink:href="#linearGradient3602-5" />
<linearGradient
xlink:href="#linearGradient3602-58"
id="linearGradient3608-8"
x1="3.909091"
y1="14.363636"
x2="24.81818"
y2="14.363636"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient3602-58">
<stop
style="stop-color:#c51900;stop-opacity:1"
offset="0"
id="stop3604-2" />
<stop
style="stop-color:#ff5f00;stop-opacity:1"
offset="1"
id="stop3606-2" />
</linearGradient>
<linearGradient
y2="14.363636"
x2="24.81818"
y1="14.363636"
x1="3.909091"
gradientUnits="userSpaceOnUse"
id="linearGradient3726"
xlink:href="#linearGradient3602-58" />
<linearGradient
xlink:href="#linearGradient3838"
id="linearGradient3844"
x1="2802.9631"
y1="538.36249"
x2="2859.7263"
y2="786.05646"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient3838">
<stop
style="stop-color:#34e0e2;stop-opacity:1"
offset="0"
id="stop3840" />
<stop
style="stop-color:#06989a;stop-opacity:1"
offset="1"
id="stop3842" />
</linearGradient>
<linearGradient
y2="786.05646"
x2="2859.7263"
y1="538.36249"
x1="2802.9631"
gradientUnits="userSpaceOnUse"
id="linearGradient3045"
xlink:href="#linearGradient3172" />
<linearGradient
id="linearGradient3172">
<stop
id="stop3174"
offset="0"
style="stop-color:#ef2929;stop-opacity:1" />
<stop
id="stop3176"
offset="1"
style="stop-color:#a40000;stop-opacity:1" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient3172"
id="linearGradient3880"
gradientUnits="userSpaceOnUse"
x1="2802.9631"
y1="626.0874"
x2="2849.4058"
y2="822.17853" />
</defs>
<metadata
id="metadata2821">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:creator>
<cc:Agent>
<dc:title>[wmayer]</dc:title>
</cc:Agent>
</dc:creator>
<dc:date>2011-10-10</dc:date>
<dc:relation>http://www.freecadweb.org/wiki/index.php?title=Artwork</dc:relation>
<dc:publisher>
<cc:Agent>
<dc:title>FreeCAD</dc:title>
</cc:Agent>
</dc:publisher>
<dc:identifier>FreeCAD/src/Mod/Sketcher/Gui/Resources/icons/Constraint_Radius.svg</dc:identifier>
<dc:rights>
<cc:Agent>
<dc:title>FreeCAD LGPL2+</dc:title>
</cc:Agent>
</dc:rights>
<cc:license>https://www.gnu.org/copyleft/lesser.html</cc:license>
<dc:contributor>
<cc:Agent>
<dc:title>[agryson] Alexander Gryson</dc:title>
</cc:Agent>
</dc:contributor>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1-8"
transform="matrix(0.75712781,0.20993414,-0.20993414,0.75712781,12.28185,-11.471359)">
<g
id="g3894"
transform="rotate(-45,34.506097,38.050253)">
<path
id="path3034"
d="M 17,27 V 19 L -4,32 17,45 v -8 h 40 v 8 L 78,32 57,19 v 8 z"
style="fill:#cc0000;stroke:#280000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1" />
<path
id="path3034-3"
d="M 15,29 V 22.6 L -0.2,32 15,41.4 V 35 h 44 v 6.4 L 74.2,32 59,22.6 V 29 Z"
style="fill:none;stroke:#ef2929;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
</g>
<g
id="layer1-3"
transform="matrix(0.7146713,-0.07815157,0.07815157,0.7146713,14.303208,25.181723)">
<path
style="fill:none;stroke:#280000;stroke-width:6.51681;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:10.8;stroke-opacity:1"
id="path3827"
d="m 62.557446,20.443367 a 29.325663,29.325663 0 0 1 -0.632945,23.23123"
transform="matrix(1.2275938,0,0,1.2275937,-37.365562,-7.803863)" />
<path
style="fill:none;stroke:#280000;stroke-width:8;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="M 58,8 6,31 58,56"
id="path3021" />
<path
style="fill:none;stroke:#cc0000;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="M 58,8 6,31 58,56"
id="path3021-3" />
<path
style="fill:none;stroke:#cc0000;stroke-width:3.25841;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:10.8;stroke-opacity:1"
id="path3827-7"
d="m 62.557446,20.443367 a 29.325663,29.325663 0 0 1 -0.632945,23.23123"
transform="matrix(1.2275938,0,0,1.2275937,-37.365562,-7.803863)" />
<path
style="fill:none;stroke:#ef2929;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="M 58,7 6,30 58,55"
id="path3021-3-6" />
<path
style="fill:none;stroke:#ef2929;stroke-width:1.6292;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:10.8;stroke-opacity:1"
id="path3827-7-5"
d="M 62.315568,19.856601 A 29.325663,29.325663 0 0 1 62.18947,43.08705"
transform="matrix(1.2275938,0,0,1.2275937,-38.312148,-7.6702077)" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@@ -0,0 +1,276 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="64px"
height="64px"
id="svg2816"
version="1.1"
sodipodi:docname="Constraint_Contextual_Driven.svg"
inkscape:version="1.1-beta1 (77e7b44db3, 2021-03-28)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<sodipodi:namedview
id="namedview29"
pagecolor="#505050"
bordercolor="#eeeeee"
borderopacity="1"
objecttolerance="10.0"
gridtolerance="10.0"
guidetolerance="10.0"
inkscape:pageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
showgrid="false"
inkscape:zoom="8.0000004"
inkscape:cx="10.1875"
inkscape:cy="31.437499"
inkscape:window-width="3840"
inkscape:window-height="1571"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="svg2816" />
<defs
id="defs2818">
<linearGradient
id="linearGradient3602">
<stop
style="stop-color:#ff2600;stop-opacity:1"
offset="0"
id="stop3604" />
<stop
style="stop-color:#ff5f00;stop-opacity:1"
offset="1"
id="stop3606" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient3602-7"
id="linearGradient3608-5"
x1="3.909091"
y1="14.363636"
x2="24.81818"
y2="14.363636"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient3602-7">
<stop
style="stop-color:#c51900;stop-opacity:1"
offset="0"
id="stop3604-1" />
<stop
style="stop-color:#ff5f00;stop-opacity:1"
offset="1"
id="stop3606-3" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient3602-5"
id="linearGradient3608-1"
x1="3.909091"
y1="14.363636"
x2="24.81818"
y2="14.363636"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient3602-5">
<stop
style="stop-color:#c51900;stop-opacity:1"
offset="0"
id="stop3604-9" />
<stop
style="stop-color:#ff5f00;stop-opacity:1"
offset="1"
id="stop3606-9" />
</linearGradient>
<linearGradient
y2="14.363636"
x2="24.81818"
y1="14.363636"
x1="3.909091"
gradientUnits="userSpaceOnUse"
id="linearGradient3686"
xlink:href="#linearGradient3602-5" />
<linearGradient
xlink:href="#linearGradient3602-58"
id="linearGradient3608-8"
x1="3.909091"
y1="14.363636"
x2="24.81818"
y2="14.363636"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient3602-58">
<stop
style="stop-color:#c51900;stop-opacity:1"
offset="0"
id="stop3604-2" />
<stop
style="stop-color:#ff5f00;stop-opacity:1"
offset="1"
id="stop3606-2" />
</linearGradient>
<linearGradient
y2="14.363636"
x2="24.81818"
y1="14.363636"
x1="3.909091"
gradientUnits="userSpaceOnUse"
id="linearGradient3726"
xlink:href="#linearGradient3602-58" />
<linearGradient
xlink:href="#linearGradient3838"
id="linearGradient3844"
x1="2802.9631"
y1="538.36249"
x2="2859.7263"
y2="786.05646"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient3838">
<stop
style="stop-color:#34e0e2;stop-opacity:1"
offset="0"
id="stop3840" />
<stop
style="stop-color:#06989a;stop-opacity:1"
offset="1"
id="stop3842" />
</linearGradient>
<linearGradient
y2="786.05646"
x2="2859.7263"
y1="538.36249"
x1="2802.9631"
gradientUnits="userSpaceOnUse"
id="linearGradient3045"
xlink:href="#linearGradient3172"
gradientTransform="matrix(0.06580162,0,0,0.06580162,-163.2642,-33.618403)" />
<linearGradient
id="linearGradient3172">
<stop
id="stop3174"
offset="0"
style="stop-color:#ef2929;stop-opacity:1" />
<stop
id="stop3176"
offset="1"
style="stop-color:#a40000;stop-opacity:1" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient3172"
id="linearGradient3880"
gradientUnits="userSpaceOnUse"
x1="2802.9631"
y1="626.0874"
x2="2849.4058"
y2="822.17853"
gradientTransform="matrix(0.06580162,0,0,0.06580162,-163.2642,-33.618403)" />
<linearGradient
y2="786.05646"
x2="2859.7263"
y1="538.36249"
x1="2802.9631"
gradientUnits="userSpaceOnUse"
id="linearGradient3045-5"
xlink:href="#linearGradient3172-5"
gradientTransform="matrix(0.06636937,0,0,0.06636937,-164.8549,-33.96393)" />
<linearGradient
id="linearGradient3172-5">
<stop
id="stop3174-3"
offset="0"
style="stop-color:#729fcf;stop-opacity:1" />
<stop
id="stop3176-7"
offset="1"
style="stop-color:#204a87;stop-opacity:1" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient3172-5"
id="linearGradient3880-7"
gradientUnits="userSpaceOnUse"
x1="2802.9631"
y1="626.0874"
x2="2849.4058"
y2="822.17853"
gradientTransform="matrix(0.06636937,0,0,0.06636937,-164.8549,-33.96393)" />
</defs>
<metadata
id="metadata2821">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:creator>
<cc:Agent>
<dc:title>[wmayer]</dc:title>
</cc:Agent>
</dc:creator>
<dc:date>2011-10-10</dc:date>
<dc:relation>http://www.freecadweb.org/wiki/index.php?title=Artwork</dc:relation>
<dc:publisher>
<cc:Agent>
<dc:title>FreeCAD</dc:title>
</cc:Agent>
</dc:publisher>
<dc:identifier>FreeCAD/src/Mod/Sketcher/Gui/Resources/icons/Constraint_Radius.svg</dc:identifier>
<dc:rights>
<cc:Agent>
<dc:title>FreeCAD LGPL2+</dc:title>
</cc:Agent>
</dc:rights>
<cc:license>https://www.gnu.org/copyleft/lesser.html</cc:license>
<dc:contributor>
<cc:Agent>
<dc:title>[agryson] Alexander Gryson</dc:title>
</cc:Agent>
</dc:contributor>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="g1635"
transform="matrix(0.51941143,-1.9568022,1.9568022,0.51941143,0.58780084,-27.348941)">
<path
id="path3034"
d="m -22.493108,13.040496 2.203872,-2.16593 -9.266859,-2.2655275 2.104275,9.3047995 2.203872,-2.16593 10.829651,11.019359 -2.203872,2.165931 9.2668579,2.265527 -2.104275,-9.3048 -2.2038719,2.16593 z"
style="fill:#3465a4;fill-opacity:1;stroke:#0b1521;stroke-width:0.772508;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1" />
<path
id="path3034-3"
d="m -23.585559,13.03101 1.763098,-1.732744 -6.704817,-1.6423875 1.525718,6.7323235 1.763098,-1.732744 11.912615,12.121295 -1.763097,1.732744 6.7048159,1.642389 -1.525718,-6.732325 -1.7630969,1.732744 z"
style="fill:none;stroke:#729fcf;stroke-width:0.772508;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
<g
id="g1871">
<path
style="fill:none;stroke:#0b1521;stroke-width:5.72501;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:10.8;stroke-opacity:1"
id="path3827"
d="M 44.519147,34.337853 A 25.762545,25.762547 80.851133 0 1 46.27227,54.678614" />
<path
style="fill:none;stroke:#0b1521;stroke-width:5.72501;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="M 56.972313,26.229278 21.857431,46.787299 60.852916,60.359435"
id="path3021" />
<path
style="fill:none;stroke:#3465a4;stroke-width:2.8625;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="M 56.972313,26.229278 21.857431,46.787299 60.852916,60.359435"
id="path3021-3" />
<path
style="fill:none;stroke:#3465a4;stroke-width:2.8625;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:10.8;stroke-opacity:1"
id="path3827-7"
d="M 44.519147,34.337853 A 25.762545,25.762547 80.851133 0 1 46.27227,54.678614" />
<path
style="fill:none;stroke:#729fcf;stroke-width:1.43126;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="M 56.891467,25.518233 21.776586,46.076253 60.772071,59.64839"
id="path3021-3-6" />
<path
style="fill:none;stroke:#729fcf;stroke-width:1.43125;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:10.8;stroke-opacity:1"
id="path3827-7-5"
d="m 43.587524,34.021249 a 25.762545,25.762547 80.851133 0 1 2.195459,20.289777" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@@ -66,6 +66,42 @@ void SketcherSettings::saveSettings()
ui->checkBoxEnableEscape->onSave();
ui->checkBoxNotifyConstraintSubstitutions->onSave();
ui->checkBoxAutoRemoveRedundants->onSave();
// Dimensioning constraints mode
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/dimensioning");
bool singleTool = true;
bool SeparatedTools = false;
int index = ui->dimensioningMode->currentIndex();
switch (index) {
case 1:
singleTool = false;
SeparatedTools = true;
break;
case 2:
singleTool = true;
SeparatedTools = true;
break;
}
hGrp->SetBool("SingleDimensioningTool", singleTool);
hGrp->SetBool("SeparatedDimensioningTools", SeparatedTools);
ui->radiusDiameterMode->setEnabled(index != 1);
bool Diameter = true;
bool Radius = true;
index = ui->radiusDiameterMode->currentIndex();
switch (index) {
case 1:
Diameter = true;
Radius = false;
break;
case 2:
Diameter = false;
Radius = true;
break;
}
hGrp->SetBool("DimensioningDiameter", Diameter);
hGrp->SetBool("DimensioningRadius", Radius);
}
void SketcherSettings::loadSettings()
@@ -76,6 +112,38 @@ void SketcherSettings::loadSettings()
ui->checkBoxEnableEscape->onRestore();
ui->checkBoxNotifyConstraintSubstitutions->onRestore();
ui->checkBoxAutoRemoveRedundants->onRestore();
// Dimensioning constraints mode
ui->dimensioningMode->clear();
ui->dimensioningMode->addItem(tr("Single tool"));
ui->dimensioningMode->addItem(tr("Separated tools"));
ui->dimensioningMode->addItem(tr("Both"));
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/dimensioning");
bool singleTool = hGrp->GetBool("SingleDimensioningTool", true);
bool SeparatedTools = hGrp->GetBool("SeparatedDimensioningTools", false);
int index = SeparatedTools ? (singleTool ? 2 : 1) : 0;
ui->dimensioningMode->setCurrentIndex(index);
connect(ui->dimensioningMode, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SketcherSettings::dimensioningModeChanged);
ui->radiusDiameterMode->setEnabled(index != 1);
// Dimensioning constraints mode
ui->radiusDiameterMode->clear();
ui->radiusDiameterMode->addItem(tr("Auto"));
ui->radiusDiameterMode->addItem(tr("Diameter"));
ui->radiusDiameterMode->addItem(tr("Radius"));
bool Diameter = hGrp->GetBool("DimensioningDiameter", true);
bool Radius = hGrp->GetBool("DimensioningRadius", true);
index = Diameter ? (Radius ? 0 : 1) : 2;
ui->radiusDiameterMode->setCurrentIndex(index);
}
void SketcherSettings::dimensioningModeChanged(int index)
{
ui->radiusDiameterMode->setEnabled(index != 1);
SketcherSettings::requireRestart();
}
/**

View File

@@ -51,6 +51,7 @@ public:
protected:
void changeEvent(QEvent* e) override;
void dimensioningModeChanged(int index);
private:
std::unique_ptr<Ui_SketcherSettings> ui;

View File

@@ -163,6 +163,56 @@ Requires to re-enter edit mode to take effect.</string>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Contextual Constrain</string>
</property>
<layout class="QGridLayout" name="gridLayout_general">
<item row="0" column="0">
<widget class="QLabel" name="dimensioningLabel">
<property name="text">
<string>Dimensioning constraints:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="dimensioningMode">
<property name="toolTip">
<string>Selection the type of dimensioning constraints for your toolbar:
'Single tool': You will have a single tool for all dimensioning constraints : Distance, Distance X / Y, Angle, Radius.
'Separated tools': You will have separated tools for each dimensioning constraint.
'Both': You will have both the 'Constrain Contextual' tool and the individual tool.
This setting is only for the toolbar. Whichever you chose, all tools are always available in the menu and through shortcuts.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="radiusDiameterLabel">
<property name="text">
<string>Dimensioning diameter/radius mode:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="radiusDiameterMode">
<property name="toolTip">
<string>While using Constraint Contextually you may chose how to handle circles and arcs:
'Auto': The tool will apply radius to arcs and diameter to circles.
'Diameter': The tool will apply diameter to both arcs and circles.
'Radius': The tool will apply radius to both arcs and circles.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>

View File

@@ -408,6 +408,7 @@ inline void SketcherAddWorkbenchConstraints<Gui::MenuItem>(Gui::MenuItem& cons)
<< "Sketcher_ConstrainSymmetric"
<< "Sketcher_ConstrainBlock"
<< "Separator"
<< "Sketcher_ConstrainContextual"
<< "Sketcher_ConstrainLock"
<< "Sketcher_ConstrainDistanceX"
<< "Sketcher_ConstrainDistanceY"
@@ -425,6 +426,9 @@ inline void SketcherAddWorkbenchConstraints<Gui::MenuItem>(Gui::MenuItem& cons)
template<>
inline void SketcherAddWorkbenchConstraints<Gui::ToolBarItem>(Gui::ToolBarItem& cons)
{
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Sketcher/dimensioning");
cons << "Sketcher_ConstrainCoincident"
<< "Sketcher_ConstrainPointOnObject"
<< "Sketcher_ConstrainVertical"
@@ -435,15 +439,20 @@ inline void SketcherAddWorkbenchConstraints<Gui::ToolBarItem>(Gui::ToolBarItem&
<< "Sketcher_ConstrainEqual"
<< "Sketcher_ConstrainSymmetric"
<< "Sketcher_ConstrainBlock"
<< "Separator"
<< "Sketcher_ConstrainLock"
<< "Sketcher_ConstrainDistanceX"
<< "Sketcher_ConstrainDistanceY"
<< "Sketcher_ConstrainDistance"
<< "Sketcher_CompConstrainRadDia"
<< "Sketcher_ConstrainAngle"
// << "Sketcher_ConstrainSnellsLaw" // Rarely used, show only in menu
<< "Separator"
<< "Separator";
if (hGrp->GetBool("SingleDimensioningTool", true)) {
cons << "Sketcher_ConstrainContextual";
}
if (hGrp->GetBool("SeparatedDimensioningTools", false)) {
cons << "Sketcher_ConstrainLock"
<< "Sketcher_ConstrainDistanceX"
<< "Sketcher_ConstrainDistanceY"
<< "Sketcher_ConstrainDistance"
<< "Sketcher_CompConstrainRadDia"
<< "Sketcher_ConstrainAngle";
// << "Sketcher_ConstrainSnellsLaw" // Rarely used, show only in menu
}
cons << "Separator"
<< "Sketcher_ToggleDrivingConstraint"
<< "Sketcher_ToggleActiveConstraint";
}