From: vsv Date: Thu, 2 Apr 2015 13:06:19 +0000 (+0300) Subject: Selection modes for constraint objects X-Git-Tag: V_1.1.0~57^2~25^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=574ec2fbe5ab1d0636a0d17430505a9fb07f1b71;p=modules%2Fshaper.git Selection modes for constraint objects --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 4c6856835..8b16a24cd 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -547,7 +547,7 @@ bool PartSet_Module::deleteObjects() // the abort leads to selection lost on constraint objects. It can be corrected after #386 issue XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); XGUI_Workshop* aWorkshop = aConnector->workshop(); - ModuleBase_ISelection* aSel = aConnector->selection(); + ModuleBase_ISelection* aSel = workshop()->selection(); QObjectPtrList aSelectedObj = aSel->selectedPresentations(); // if there are no selected objects in the viewer, that means that the selection in another // place cased this method. It is necessary to return the false value to understande in above diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index aad09ef0f..be687f220 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -146,7 +146,7 @@ public: /// \param isChecked if true, the feature is a construction void setAuxiliary(const bool isChecked); - + /// Returns state of constraints showing flag bool isConstraintsShown() const { return myIsConstraintsShown; } diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 1b645c062..6be038d19 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -360,8 +361,9 @@ void PartSet_WidgetSketchLabel::setSketchingMode() // Get default selection modes QIntList aModes; - aModes.append(AIS_DSM_Text); - aModes.append(AIS_DSM_Line); + aModes.append(SketcherPrs_Tools::Sel_Dimension_Text); + aModes.append(SketcherPrs_Tools::Sel_Dimension_Line); + aModes.append(SketcherPrs_Tools::Sel_Constraint); aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX)); aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE)); diff --git a/src/SketcherPrs/SketcherPrs_Coincident.cpp b/src/SketcherPrs/SketcherPrs_Coincident.cpp index f7b61d960..3520df998 100644 --- a/src/SketcherPrs/SketcherPrs_Coincident.cpp +++ b/src/SketcherPrs/SketcherPrs_Coincident.cpp @@ -70,9 +70,11 @@ void SketcherPrs_Coincident::Compute(const Handle(PrsMgr_PresentationManager3d)& void SketcherPrs_Coincident::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) { - Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this, 10); - Handle(Select3D_SensitivePoint) aSp = new Select3D_SensitivePoint(aOwn, myPoint); - aSelection->Add(aSp); + if ((aMode == 0) || (aMode == SketcherPrs_Tools::Sel_Constraint)) { + Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this, 10); + Handle(Select3D_SensitivePoint) aSp = new Select3D_SensitivePoint(aOwn, myPoint); + aSelection->Add(aSp); + } } void SketcherPrs_Coincident::SetColor(const Quantity_NameOfColor aCol) diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp index a1564129b..17c316afc 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp @@ -151,3 +151,25 @@ bool SketcherPrs_LengthDimension::getPoints(gp_Pnt& thePnt1, gp_Pnt& thePnt2) co } return false; } + + + +void SketcherPrs_LengthDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, + const Standard_Integer theMode) +{ + Standard_Integer aMode; + switch (theMode) { + case SketcherPrs_Tools::Sel_Dimension_All: + aMode = 0; + break; + case SketcherPrs_Tools::Sel_Dimension_Line: + aMode = 1; + break; + case SketcherPrs_Tools::Sel_Dimension_Text: + aMode = 2; + break; + default: + aMode = theMode; + } + AIS_LengthDimension::ComputeSelection(aSelection, aMode); +} diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.h b/src/SketcherPrs/SketcherPrs_LengthDimension.h index ea4832e7e..5fde8d7aa 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.h +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.h @@ -38,6 +38,10 @@ protected: Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0); + /// Redefinition of virtual function + Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, + const Standard_Integer aMode); + private: bool getPoints(gp_Pnt& thePnt1, gp_Pnt& thePnt2) const; diff --git a/src/SketcherPrs/SketcherPrs_Radius.cpp b/src/SketcherPrs/SketcherPrs_Radius.cpp index cd6e32f39..a3643fe08 100644 --- a/src/SketcherPrs/SketcherPrs_Radius.cpp +++ b/src/SketcherPrs/SketcherPrs_Radius.cpp @@ -99,3 +99,23 @@ void SketcherPrs_Radius::Compute(const Handle(PrsMgr_PresentationManager3d)& the AIS_RadiusDimension::Compute(thePresentationManager, thePresentation, theMode); } + +void SketcherPrs_Radius::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, + const Standard_Integer theMode) +{ + Standard_Integer aMode; + switch (theMode) { + case SketcherPrs_Tools::Sel_Dimension_All: + aMode = 0; + break; + case SketcherPrs_Tools::Sel_Dimension_Line: + aMode = 1; + break; + case SketcherPrs_Tools::Sel_Dimension_Text: + aMode = 2; + break; + default: + aMode = theMode; + } + AIS_RadiusDimension::ComputeSelection(aSelection, aMode); +} diff --git a/src/SketcherPrs/SketcherPrs_Radius.h b/src/SketcherPrs/SketcherPrs_Radius.h index 7b75569da..88a3c613c 100644 --- a/src/SketcherPrs/SketcherPrs_Radius.h +++ b/src/SketcherPrs/SketcherPrs_Radius.h @@ -35,6 +35,10 @@ protected: Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0); + /// Redefinition of virtual function + Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, + const Standard_Integer aMode); + private: /// Constraint feature ModelAPI_Feature* myConstraint; diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp index f73556bac..fad57104d 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp @@ -353,9 +353,11 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& void SketcherPrs_SymbolPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) { - ClearSelected(); - for (int i = 1; i <= mySPoints.Length(); i++) - aSelection->Add(mySPoints.Value(i)); + //ClearSelected(); + if ((aMode == 0) || (aMode == SketcherPrs_Tools::Sel_Constraint)) { + for (int i = 1; i <= mySPoints.Length(); i++) + aSelection->Add(mySPoints.Value(i)); + } } diff --git a/src/SketcherPrs/SketcherPrs_Tools.h b/src/SketcherPrs/SketcherPrs_Tools.h index c040fff59..00a2e9663 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.h +++ b/src/SketcherPrs/SketcherPrs_Tools.h @@ -20,8 +20,26 @@ class GeomDataAPI_Point2D; namespace SketcherPrs_Tools { +/// Enumeration with modes for activation of selection custom presentations +enum SelectionModes { + /// Start of enumeration + Sel_Mode_First = 100, + + /// Selection mode for all constraints exclude dimensions + Sel_Constraint, + + /// Selection mode for whole dimension + Sel_Dimension_All, + + /// Selection mode for line of dimension + Sel_Dimension_Line, + + /// Selection mode foe text of dimension + Sel_Dimension_Text +}; + SKETCHERPRS_EXPORT ObjectPtr getResult(ModelAPI_Feature* theFeature, - const std::string& theAttrName); + const std::string& theAttrName); SKETCHERPRS_EXPORT std::shared_ptr getShape(ObjectPtr theObject); diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index ab9991d50..fdc407f7b 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -68,7 +68,10 @@ void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes) // Convert shape types to selection types QIntList aModes; foreach(int aType, theTypes) { - aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType)); + if (aType > TopAbs_SHAPE) + aModes.append(aType); + else + aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType)); } aDisp->activateObjects(aModes); //TODO: We have to open Local context because at neutral point filters don't work (bug 25340)