From: nds Date: Thu, 25 Feb 2016 13:59:17 +0000 (+0300) Subject: #1334 Show dimensional constraint check-box does not work X-Git-Tag: V_2.2.0~68 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0b6f36afb6768202f1d1c18b69b18f4871c56c8e;p=modules%2Fshaper.git #1334 Show dimensional constraint check-box does not work --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index cf5c2c743..297e0ef10 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -315,7 +315,7 @@ void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation) aLast = myHasConstraintShown.end(); for (; anIt != aLast; anIt++) { myHasConstraintShown[anIt.key()]; - mySketchMgr->onShowConstraintsToggle(anIt.value(), myHasConstraintShown[anIt.key()]); + mySketchMgr->onShowConstraintsToggle(anIt.key(), anIt.value()); } } @@ -562,11 +562,11 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th ModuleBase_ModelWidget* aWgt = NULL; if (theType == "sketch-start-label") { PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, aWorkshop, - theWidgetApi, theParentId, mySketchMgr->showConstraintStates()); + theWidgetApi, theParentId, myHasConstraintShown); connect(aLabelWgt, SIGNAL(planeSelected(const std::shared_ptr&)), mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr&))); - connect(aLabelWgt, SIGNAL(showConstraintToggled(bool, int)), - mySketchMgr, SLOT(onShowConstraintsToggle(bool, int))); + connect(aLabelWgt, SIGNAL(showConstraintToggled(int, bool)), + mySketchMgr, SLOT(onShowConstraintsToggle(int, bool))); aWgt = aLabelWgt; } else if (theType == "sketch-2dpoint_selector") { PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, aWorkshop, @@ -713,13 +713,14 @@ void PartSet_Module::launchOperation(const QString& theCmdId) { if (myWorkshop->currentOperation() && myWorkshop->currentOperation()->id().toStdString() == SketchPlugin_Sketch::ID()) { - const QMap& aShownStates = mySketchMgr->showConstraintStates(); + const QMap& aShownStates = + mySketchMgr->showConstraintStates(); myHasConstraintShown = aShownStates; } if (PartSet_SketcherMgr::constraintsIdList().contains(theCmdId)) { // Show constraints if a constraint was anOperation - mySketchMgr->onShowConstraintsToggle(true, PartSet_Tools::Geometrical); - mySketchMgr->onShowConstraintsToggle(true, PartSet_Tools::Dimensional); + mySketchMgr->onShowConstraintsToggle(PartSet_Tools::Geometrical, true); + mySketchMgr->onShowConstraintsToggle(PartSet_Tools::Dimensional, true); } ModuleBase_IModule::launchOperation(theCmdId); } diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 936c30afc..583e13298 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -1152,31 +1152,87 @@ bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const } } } - if (!isObjectFound) - return aCanDisplay; - - // 4. For created nested feature operation do not display the created feature if - // the mouse curstor leaves the OCC window. - // The correction cases, which ignores this condition: - // a. the property panel values modification - // b. the popup menu activated - // c. widget editor control - #ifndef DEBUG_DO_NOT_BY_ENTER - if (aCanDisplay && isNestedCreateOperation(getCurrentOperation())) { - ModuleBase_ModelWidget* anActiveWidget = getActiveWidget(); - ModuleBase_WidgetEditor* anEditorWdg = anActiveWidget ? dynamic_cast(anActiveWidget) : 0; - // the active widget editor should not influence here. The presentation should be visible always - // when this widget is active. - if (!anEditorWdg && !myIsPopupMenuActive) { - // during a nested create operation, the feature is redisplayed only if the mouse over view - // of there was a value modified in the property panel after the mouse left the view - aCanDisplay = canDisplayCurrentCreatedFeature(); + if (isObjectFound) { + // 4. For created nested feature operation do not display the created feature if + // the mouse curstor leaves the OCC window. + // The correction cases, which ignores this condition: + // a. the property panel values modification + // b. the popup menu activated + // c. widget editor control + #ifndef DEBUG_DO_NOT_BY_ENTER + if (aCanDisplay && isNestedCreateOperation(getCurrentOperation())) { + ModuleBase_ModelWidget* anActiveWidget = getActiveWidget(); + ModuleBase_WidgetEditor* anEditorWdg = anActiveWidget ? dynamic_cast(anActiveWidget) : 0; + // the active widget editor should not influence here. The presentation should be visible always + // when this widget is active. + if (!anEditorWdg && !myIsPopupMenuActive) { + // during a nested create operation, the feature is redisplayed only if the mouse over view + // of there was a value modified in the property panel after the mouse left the view + aCanDisplay = canDisplayCurrentCreatedFeature(); + } } + #endif } - #endif + + // checks the sketcher constraints visibility according to active sketch check box states + if (aCanDisplay) { + bool aProcessed = false; + FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); + if (aFeature.get()) { + bool aConstraintDisplayed = canDisplayConstraint(aFeature, PartSet_Tools::Any, aProcessed); + if (aProcessed) + aCanDisplay = aConstraintDisplayed; + } + } + return aCanDisplay; } +bool PartSet_SketcherMgr::canDisplayConstraint(const FeaturePtr& theFeature, + const PartSet_Tools::ConstraintVisibleState& theState, + bool& isProcessed) const +{ + bool aSwitchedOn = true; + + const QStringList& aConstrIds = constraintsIdList(); + + std::string aKind = theFeature->getKind(); + if (aConstrIds.contains(QString(aKind.c_str()))) { + bool isTypedConstraint = false; + + switch (theState) { + case PartSet_Tools::Dimensional: { + bool isDistance = isDistanceKind(aKind); + if (isDistance) { + isProcessed = true; + aSwitchedOn = myIsConstraintsShown[theState]; + } + } + break; + case PartSet_Tools::Geometrical: { + bool isGeometrical = !isDistanceKind(aKind); + if (isGeometrical) { + isProcessed = true; + aSwitchedOn = myIsConstraintsShown[theState]; + } + } + break; + case PartSet_Tools::Any: { + isProcessed = true; + bool isDistance = isDistanceKind(aKind); + if (isDistance) + aSwitchedOn = myIsConstraintsShown[PartSet_Tools::Dimensional]; + else + aSwitchedOn = myIsConstraintsShown[PartSet_Tools::Geometrical]; + } + break; + default: + break; + } + } + return aSwitchedOn; +} + void PartSet_SketcherMgr::processHiddenObject(const std::list& theObjects) { ModuleBase_OperationFeature* aFOperation = dynamic_cast @@ -1544,7 +1600,7 @@ void PartSet_SketcherMgr::restoreSelection() } } -void PartSet_SketcherMgr::onShowConstraintsToggle(bool theState, int theType) +void PartSet_SketcherMgr::onShowConstraintsToggle(int theType, bool theState) { PartSet_Tools::ConstraintVisibleState aType = (PartSet_Tools::ConstraintVisibleState)theType; if (myIsConstraintsShown.contains(aType) && myIsConstraintsShown[aType] == theState) @@ -1557,25 +1613,12 @@ void PartSet_SketcherMgr::onShowConstraintsToggle(bool theState, int theType) ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); - const QStringList& aConstrIds = constraintsIdList(); for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) { FeaturePtr aSubFeature = myCurrentSketch->subFeature(i); - std::string aKind = aSubFeature->getKind(); - if (aConstrIds.contains(QString(aKind.c_str()))) { - bool isTypedConstraint = false; - if (aType == PartSet_Tools::Dimensional) { - isTypedConstraint = isDistanceKind(aKind); - } - else - isTypedConstraint = !isDistanceKind(aKind); - - if (isTypedConstraint) { - if (theState) - aSubFeature->setDisplayed(true); - else - aSubFeature->setDisplayed(false); - } - } + bool aProcessed = false; + bool aConstraintDisplayed = canDisplayConstraint(aSubFeature, aType, aProcessed); + if (aProcessed) + aSubFeature->setDisplayed(aConstraintDisplayed); } Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); } diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index f13c3cfdf..113abadd2 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -173,6 +173,16 @@ public: /// \param theObject a model object bool canDisplayObject(const ObjectPtr& theObject) const; + /// Returns whether the constraint object can be displayed. It depends on the sketch check + /// box states + /// \param theObject a model object + /// \param theState the constraint visible state state to be checked + /// \param isProcessed an output parameter if it is processed + /// \return result value + bool canDisplayConstraint(const FeaturePtr& theObject, + const PartSet_Tools::ConstraintVisibleState& theState, + bool& isProcessed) const; + /// Check the given objects either there are some results of the current sketch. If so, /// it suggests to delete them as there are no functionality to show back hidden sketch objects /// \param theObjects a list of hidden objects @@ -240,7 +250,7 @@ public slots: void onPlaneSelected(const std::shared_ptr& thePln); /// Toggle show constraints - void onShowConstraintsToggle(bool theState, int theType); + void onShowConstraintsToggle(int theType, bool theState); private slots: /// Process the enter mouse to the view port. If the current operation is a create of diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 3bd8a61b1..197f4df0f 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -115,7 +115,7 @@ bool PartSet_SketcherReetntrantMgr::processMouseMoved(ModuleBase_IViewWindow* /* bool aWidgetIsFilled = false; //bool aCanBeActivatedByMove = false; - FeaturePtr aCurrentFeature = anActiveWidget->feature(); + FeaturePtr aCurrentFeature = aFOperation->feature(); bool isLineFeature = false, isArcFeature = false; if (aCurrentFeature->getKind() == SketchPlugin_Line::ID()) isLineFeature = anActiveWidget->attributeID() == SketchPlugin_Line::START_ID(); diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h index 310ac57a7..1b35d9068 100755 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -46,7 +46,8 @@ public: enum ConstraintVisibleState { Geometrical = 0, // all constrains excepting dimensional - Dimensional // lenght, distance, radius and angle constraints + Dimensional, // lenght, distance, radius and angle constraints + Any // both, geometrical and dimensional, types of constraints }; public: diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index b8c78602c..fa2f50750 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -182,7 +182,7 @@ void PartSet_WidgetSketchLabel::onShowConstraint(bool theOn) aState = anIt.key(); } if (aFound) - emit showConstraintToggled(theOn, aState); + emit showConstraintToggled(aState, theOn); } void PartSet_WidgetSketchLabel::blockAttribute(const bool& theToBlock, bool& isFlushesActived, diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index 600147ed4..0d1d44056 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -86,9 +86,9 @@ signals: void planeSelected(const std::shared_ptr& thePln); /// A show constraint toggled signal - /// \param theState a state of the check box /// \param theType a ConstraintVisibleState value - void showConstraintToggled(bool theState, int theType); + /// \param theState a state of the check box + void showConstraintToggled(int theType, bool theState); protected: /// Creates a backup of the current values of the attribute