Sketcher: Fix is active. (#24124)
* Sketcher: Fix is active. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Sketcher: Delint and compiler warning cleanup --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Chris Hennes <chennes@gmail.com>
This commit is contained in:
@@ -173,7 +173,7 @@ void CmdSketcherConvertToNURBS::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherConvertToNURBS::isActive()
|
||||
{
|
||||
return isSketcherBSplineActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// Increase degree of the spline
|
||||
@@ -208,7 +208,7 @@ void CmdSketcherIncreaseDegree::activated(int iMsg)
|
||||
|
||||
// get the needed lists and objects
|
||||
const std::vector<std::string>& SubNames = selection[0].getSubNames();
|
||||
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
|
||||
auto* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Increase B-spline degree"));
|
||||
|
||||
@@ -221,13 +221,9 @@ void CmdSketcherIncreaseDegree::activated(int iMsg)
|
||||
const Part::Geometry* geo = Obj->getGeometry(GeoId);
|
||||
|
||||
if (geo->is<Part::GeomBSplineCurve>()) {
|
||||
Gui::cmdAppObjectArgs(selection[0].getObject(),
|
||||
"increaseBSplineDegree(%d) ",
|
||||
GeoId);
|
||||
Gui::cmdAppObjectArgs(Obj, "increaseBSplineDegree(%d) ", GeoId);
|
||||
// add new control points
|
||||
Gui::cmdAppObjectArgs(selection[0].getObject(),
|
||||
"exposeInternalGeometry(%d)",
|
||||
GeoId);
|
||||
Gui::cmdAppObjectArgs(Obj, "exposeInternalGeometry(%d)", GeoId);
|
||||
}
|
||||
else {
|
||||
ignored = true;
|
||||
@@ -249,7 +245,7 @@ void CmdSketcherIncreaseDegree::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherIncreaseDegree::isActive()
|
||||
{
|
||||
return isSketcherBSplineActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingBSplineActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
|
||||
@@ -332,9 +328,39 @@ void CmdSketcherDecreaseDegree::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherDecreaseDegree::isActive()
|
||||
{
|
||||
return isSketcherBSplineActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingBSplineActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
bool isCommandNeedingBSplineKnotActive(Gui::Document* doc)
|
||||
{
|
||||
if (!isCommandActive(doc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<Gui::SelectionObject> sel =
|
||||
Gui::Selection().getSelectionEx(doc->getDocument()->getName(),
|
||||
Sketcher::SketchObject::getClassTypeId());
|
||||
if (sel.size() == 1) {
|
||||
const std::vector<std::string>& names = sel[0].getSubNames();
|
||||
if (names.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* Obj = static_cast<Sketcher::SketchObject*>(sel[0].getObject());
|
||||
const std::string& name = names[0];
|
||||
|
||||
int geoId {GeoEnum::GeoUndef};
|
||||
PointPos posId {PointPos::none};
|
||||
getIdsFromName(name, Obj, geoId, posId);
|
||||
|
||||
int splineGeoId {GeoEnum::GeoUndef};
|
||||
int knotIndexOCC {-1};
|
||||
|
||||
return isBsplineKnotOrEndPoint(Obj, geoId, posId)
|
||||
&& findBSplineAndKnotIndex(Obj, geoId, posId, splineGeoId, knotIndexOCC);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdSketcherIncreaseKnotMultiplicity)
|
||||
|
||||
@@ -480,7 +506,7 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherIncreaseKnotMultiplicity::isActive()
|
||||
{
|
||||
return isSketcherBSplineActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingBSplineKnotActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdSketcherDecreaseKnotMultiplicity)
|
||||
@@ -615,7 +641,7 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherDecreaseKnotMultiplicity::isActive()
|
||||
{
|
||||
return isSketcherBSplineActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingBSplineKnotActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
|
||||
@@ -717,7 +743,7 @@ void CmdSketcherCompModifyKnotMultiplicity::updateAction(int /*mode*/)
|
||||
|
||||
bool CmdSketcherCompModifyKnotMultiplicity::isActive()
|
||||
{
|
||||
return isSketcherBSplineActive(getActiveGuiDocument(), false);
|
||||
return isCommandNeedingBSplineKnotActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
class DrawSketchHandlerBSplineInsertKnot: public DrawSketchHandler
|
||||
@@ -940,7 +966,7 @@ void CmdSketcherInsertKnot::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherInsertKnot::isActive()
|
||||
{
|
||||
return isSketcherBSplineActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingBSplineActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdSketcherJoinCurves)
|
||||
@@ -1096,7 +1122,7 @@ void CmdSketcherJoinCurves::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherJoinCurves::isActive()
|
||||
{
|
||||
return isSketcherBSplineActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingBSplineActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
void CreateSketcherCommandsBSpline()
|
||||
|
||||
@@ -79,7 +79,7 @@ void CmdSketcherBSplineDegree::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherBSplineDegree::isActive()
|
||||
{
|
||||
return isSketcherBSplineActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// Show/Hide B-spline polygon
|
||||
@@ -108,7 +108,7 @@ void CmdSketcherBSplinePolygon::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherBSplinePolygon::isActive()
|
||||
{
|
||||
return isSketcherBSplineActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// Show/Hide B-spline comb
|
||||
@@ -137,7 +137,7 @@ void CmdSketcherBSplineComb::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherBSplineComb::isActive()
|
||||
{
|
||||
return isSketcherBSplineActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
//
|
||||
@@ -166,7 +166,7 @@ void CmdSketcherBSplineKnotMultiplicity::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherBSplineKnotMultiplicity::isActive()
|
||||
{
|
||||
return isSketcherBSplineActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
//
|
||||
@@ -195,7 +195,7 @@ void CmdSketcherBSplinePoleWeight::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherBSplinePoleWeight::isActive()
|
||||
{
|
||||
return isSketcherBSplineActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// Composite drop down menu for show/hide BSpline information layer
|
||||
@@ -341,7 +341,7 @@ void CmdSketcherCompBSplineShowHideGeometryInformation::updateAction(int /*mode*
|
||||
|
||||
bool CmdSketcherCompBSplineShowHideGeometryInformation::isActive()
|
||||
{
|
||||
return isSketcherBSplineActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -238,7 +238,7 @@ void CmdSketcherCopyClipboard::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherCopyClipboard::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -278,7 +278,7 @@ void CmdSketcherCut::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherCut::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -327,7 +327,7 @@ void CmdSketcherPaste::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherPaste::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -411,7 +411,7 @@ void CmdSketcherSelectConstraints::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherSelectConstraints::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -455,7 +455,7 @@ void CmdSketcherSelectOrigin::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherSelectOrigin::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -496,7 +496,7 @@ void CmdSketcherSelectVerticalAxis::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherSelectVerticalAxis::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -537,7 +537,7 @@ void CmdSketcherSelectHorizontalAxis::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherSelectHorizontalAxis::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -595,7 +595,7 @@ void CmdSketcherSelectRedundantConstraints::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherSelectRedundantConstraints::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -650,7 +650,7 @@ void CmdSketcherSelectMalformedConstraints::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherSelectMalformedConstraints::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -706,7 +706,7 @@ void CmdSketcherSelectPartiallyRedundantConstraints::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherSelectPartiallyRedundantConstraints::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -763,7 +763,7 @@ void CmdSketcherSelectConflictingConstraints::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherSelectConflictingConstraints::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -884,7 +884,7 @@ void CmdSketcherSelectElementsAssociatedWithConstraints::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherSelectElementsAssociatedWithConstraints::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingConstraintActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -973,7 +973,7 @@ void CmdSketcherSelectElementsWithDoFs::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherSelectElementsWithDoFs::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -1088,7 +1088,7 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherRestoreInternalAlignmentGeometry::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -1123,7 +1123,7 @@ void CmdSketcherSymmetry::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherSymmetry::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -1501,7 +1501,7 @@ void CmdSketcherCopy::activate()
|
||||
|
||||
bool CmdSketcherCopy::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -1551,7 +1551,7 @@ void CmdSketcherClone::activate()
|
||||
|
||||
bool CmdSketcherClone::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
class CmdSketcherMove: public SketcherCopy
|
||||
@@ -1598,7 +1598,7 @@ void CmdSketcherMove::activate()
|
||||
|
||||
bool CmdSketcherMove::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -1709,7 +1709,7 @@ void CmdSketcherCompCopy::languageChange()
|
||||
|
||||
bool CmdSketcherCompCopy::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -2058,7 +2058,7 @@ void CmdSketcherRectangularArray::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherRectangularArray::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -2123,7 +2123,7 @@ void CmdSketcherDeleteAllGeometry::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherDeleteAllGeometry::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -2189,7 +2189,7 @@ void CmdSketcherDeleteAllConstraints::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherDeleteAllConstraints::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), false);
|
||||
return isCommandActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -2310,7 +2310,7 @@ void CmdSketcherRemoveAxesAlignment::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherRemoveAxesAlignment::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
|
||||
@@ -2393,7 +2393,7 @@ void CmdSketcherOffset::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherOffset::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// Rotate tool =====================================================================
|
||||
@@ -2427,7 +2427,7 @@ void CmdSketcherRotate::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherRotate::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// Scale tool =====================================================================
|
||||
@@ -2461,7 +2461,7 @@ void CmdSketcherScale::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherScale::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
// Translate / rectangular pattern tool =======================================================
|
||||
@@ -2495,7 +2495,7 @@ void CmdSketcherTranslate::activated(int iMsg)
|
||||
|
||||
bool CmdSketcherTranslate::isActive()
|
||||
{
|
||||
return isCommandActive(getActiveGuiDocument(), true);
|
||||
return isCommandNeedingGeometryActive(getActiveGuiDocument());
|
||||
}
|
||||
|
||||
void CreateSketcherCommandsConstraintAccel()
|
||||
|
||||
@@ -493,7 +493,7 @@ bool SketcherGui::isSketchInEdit(Gui::Document* doc)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SketcherGui::isCommandActive(Gui::Document* doc, bool actsOnSelection)
|
||||
bool SketcherGui::isCommandActive(Gui::Document* doc)
|
||||
{
|
||||
if (isSketchInEdit(doc)) {
|
||||
auto mode =
|
||||
@@ -501,29 +501,79 @@ bool SketcherGui::isCommandActive(Gui::Document* doc, bool actsOnSelection)
|
||||
|
||||
if (mode == ViewProviderSketch::STATUS_NONE
|
||||
|| mode == ViewProviderSketch::STATUS_SKETCH_UseHandler) {
|
||||
|
||||
if (!actsOnSelection) {
|
||||
return true;
|
||||
}
|
||||
return Gui::Selection().countObjectsOfType<Sketcher::SketchObject>() > 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SketcherGui::isSketcherBSplineActive(Gui::Document* doc, bool actsOnSelection)
|
||||
bool SketcherGui::isCommandNeedingConstraintActive(Gui::Document* doc)
|
||||
{
|
||||
if (doc) {
|
||||
// checks if a Sketch Viewprovider is in Edit and is in no special mode
|
||||
if (doc->getInEdit()
|
||||
&& doc->getInEdit()->isDerivedFrom<SketcherGui::ViewProviderSketch>()) {
|
||||
if (static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit())->getSketchMode()
|
||||
== ViewProviderSketch::STATUS_NONE) {
|
||||
if (!actsOnSelection) {
|
||||
if (!isCommandActive(doc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<Gui::SelectionObject> sel =
|
||||
Gui::Selection().getSelectionEx(doc->getDocument()->getName(),
|
||||
Sketcher::SketchObject::getClassTypeId());
|
||||
if (sel.size() == 1) {
|
||||
for (const std::string& name : sel[0].getSubNames()) {
|
||||
if (name.starts_with("Constraint")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SketcherGui::isCommandNeedingGeometryActive(Gui::Document* doc)
|
||||
{
|
||||
if (!isCommandActive(doc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<Gui::SelectionObject> sel =
|
||||
Gui::Selection().getSelectionEx(doc->getDocument()->getName(),
|
||||
Sketcher::SketchObject::getClassTypeId());
|
||||
if (sel.size() == 1) {
|
||||
auto* Obj = static_cast<Sketcher::SketchObject*>(sel[0].getObject());
|
||||
for (const std::string& name : sel[0].getSubNames()) {
|
||||
int geoId {GeoEnum::GeoUndef};
|
||||
PointPos posId {PointPos::none};
|
||||
getIdsFromName(name, Obj, geoId, posId);
|
||||
|
||||
if (geoId != GeoEnum::GeoUndef) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SketcherGui::isCommandNeedingBSplineActive(Gui::Document* doc)
|
||||
{
|
||||
if (!isCommandActive(doc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<Gui::SelectionObject> sel =
|
||||
Gui::Selection().getSelectionEx(doc->getDocument()->getName(),
|
||||
Sketcher::SketchObject::getClassTypeId());
|
||||
if (sel.size() == 1) {
|
||||
auto* Obj = static_cast<Sketcher::SketchObject*>(sel[0].getObject());
|
||||
for (const std::string& name : sel[0].getSubNames()) {
|
||||
|
||||
int geoId {GeoEnum::GeoUndef};
|
||||
PointPos posId {PointPos::none};
|
||||
getIdsFromName(name, Obj, geoId, posId);
|
||||
|
||||
if (geoId != GeoEnum::GeoUndef) {
|
||||
const Part::Geometry* geo = Obj->getGeometry(geoId);
|
||||
|
||||
if (geo && geo->is<Part::GeomBSplineCurve>()) {
|
||||
return true;
|
||||
}
|
||||
return Gui::Selection().countObjectsOfType<Sketcher::SketchObject>() > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,9 +196,10 @@ bool isSketchInEdit(Gui::Document* doc);
|
||||
|
||||
/// Returns whether an edit mode command should be activated or not. It is only activated if the
|
||||
/// sketcher is no special state or a sketchHandler is active.
|
||||
bool isCommandActive(Gui::Document* doc, bool actsOnSelection = false);
|
||||
|
||||
bool isSketcherBSplineActive(Gui::Document* doc, bool actsOnSelection);
|
||||
bool isCommandActive(Gui::Document* doc);
|
||||
bool isCommandNeedingConstraintActive(Gui::Document* doc);
|
||||
bool isCommandNeedingGeometryActive(Gui::Document* doc);
|
||||
bool isCommandNeedingBSplineActive(Gui::Document* doc);
|
||||
|
||||
SketcherGui::ViewProviderSketch* getInactiveHandlerEditModeSketchViewProvider(Gui::Document* doc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user