aLast = myHasConstraintShown.end();
for (; anIt != aLast; anIt++) {
myHasConstraintShown[anIt.key()];
- mySketchMgr->onShowConstraintsToggle(anIt.value(), myHasConstraintShown[anIt.key()]);
+ mySketchMgr->onShowConstraintsToggle(anIt.key(), anIt.value());
}
}
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<GeomAPI_Pln>&)),
mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
- 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,
{
if (myWorkshop->currentOperation() &&
myWorkshop->currentOperation()->id().toStdString() == SketchPlugin_Sketch::ID()) {
- const QMap<PartSet_Tools::ConstraintVisibleState, bool>& aShownStates = mySketchMgr->showConstraintStates();
+ const QMap<PartSet_Tools::ConstraintVisibleState, bool>& 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);
}
}
}
}
- 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<ModuleBase_WidgetEditor*>(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<ModuleBase_WidgetEditor*>(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<ObjectPtr>& theObjects)
{
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
}
}
-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)
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(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));
}
/// \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
void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& 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
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();
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:
aState = anIt.key();
}
if (aFound)
- emit showConstraintToggled(theOn, aState);
+ emit showConstraintToggled(aState, theOn);
}
void PartSet_WidgetSketchLabel::blockAttribute(const bool& theToBlock, bool& isFlushesActived,
void planeSelected(const std::shared_ptr<GeomAPI_Pln>& 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