From: nds Date: Wed, 6 Apr 2016 14:53:20 +0000 (+0300) Subject: ModuleBase_ViewerPrs is wrapped into shared_ptr. X-Git-Tag: V_2.3.0~285 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2469ecd08c3b16def494626928ff81e575bdfe3d;p=modules%2Fshaper.git ModuleBase_ViewerPrs is wrapped into shared_ptr. --- diff --git a/src/ModuleBase/ModuleBase_FilterValidated.cpp b/src/ModuleBase/ModuleBase_FilterValidated.cpp index 08314d734..a41f15463 100644 --- a/src/ModuleBase/ModuleBase_FilterValidated.cpp +++ b/src/ModuleBase/ModuleBase_FilterValidated.cpp @@ -28,7 +28,7 @@ Standard_Boolean ModuleBase_FilterValidated::IsOk(const Handle(SelectMgr_EntityO aCurrentWidget = myWorkshop->module()->activeWidget(); ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast (aCurrentWidget); - ModuleBase_ViewerPrs aPrs; + ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs()); myWorkshop->selection()->fillPresentation(aPrs, theOwner); aValid = !aWidgetValidated || aWidgetValidated->isValidSelection(aPrs); diff --git a/src/ModuleBase/ModuleBase_ISelection.cpp b/src/ModuleBase/ModuleBase_ISelection.cpp index ab8008ad7..05bc1d6c1 100644 --- a/src/ModuleBase/ModuleBase_ISelection.cpp +++ b/src/ModuleBase/ModuleBase_ISelection.cpp @@ -9,39 +9,40 @@ #include //******************************************************************** -void ModuleBase_ISelection::appendSelected(const QList theValues, - QList& theValuesTo) +void ModuleBase_ISelection::appendSelected(const QList theValues, + QList& theValuesTo) { // collect the objects from the viewer QObjectPtrList anExistedObjects; - QList::const_iterator aPrsIt = theValuesTo.begin(), + QList::const_iterator aPrsIt = theValuesTo.begin(), aPrsLast = theValuesTo.end(); for (; aPrsIt != aPrsLast; aPrsIt++) { - if ((*aPrsIt).owner() && (*aPrsIt).object()) - anExistedObjects.push_back((*aPrsIt).object()); + if ((*aPrsIt)->owner() && (*aPrsIt)->object()) + anExistedObjects.push_back((*aPrsIt)->object()); } - QList::const_iterator anIt = theValues.begin(), + QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); for (; anIt != aLast; anIt++) { - ObjectPtr anObject = (*anIt).object(); + ObjectPtr anObject = (*anIt)->object(); if (anObject.get() != NULL && !anExistedObjects.contains(anObject)) { - theValuesTo.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL)); + theValuesTo.append(std::shared_ptr( + new ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL))); } } } //******************************************************************** -ResultPtr ModuleBase_ISelection::getResult(const ModuleBase_ViewerPrs& thePrs) +ResultPtr ModuleBase_ISelection::getResult(const ModuleBase_ViewerPrsPtr& thePrs) { ResultPtr aResult; - if (thePrs.object().get()) - aResult = std::dynamic_pointer_cast(thePrs.object()); - else if (!thePrs.owner().IsNull()) { - ObjectPtr anObject = getSelectableObject(thePrs.owner()); + if (thePrs->object().get()) + aResult = std::dynamic_pointer_cast(thePrs->object()); + else if (!thePrs->owner().IsNull()) { + ObjectPtr anObject = getSelectableObject(thePrs->owner()); aResult = std::dynamic_pointer_cast(anObject); } @@ -49,11 +50,11 @@ ResultPtr ModuleBase_ISelection::getResult(const ModuleBase_ViewerPrs& thePrs) } //******************************************************************** -GeomShapePtr ModuleBase_ISelection::getShape(const ModuleBase_ViewerPrs& thePrs) +GeomShapePtr ModuleBase_ISelection::getShape(const ModuleBase_ViewerPrsPtr& thePrs) { GeomShapePtr aShape; - const GeomShapePtr& aPrsShape = thePrs.shape(); + const GeomShapePtr& aPrsShape = thePrs->shape(); // if only result is selected, an empty shape is set to the model if (!aPrsShape.get() || aPrsShape->isNull()) { } @@ -68,14 +69,15 @@ GeomShapePtr ModuleBase_ISelection::getShape(const ModuleBase_ViewerPrs& thePrs) } //******************************************************************** -QList ModuleBase_ISelection::getViewerPrs(const QObjectPtrList& theObjects) +QList ModuleBase_ISelection::getViewerPrs(const QObjectPtrList& theObjects) { - QList aSelectedPrs; + QList aSelectedPrs; QObjectPtrList::const_iterator anIt = theObjects.begin(), aLast = theObjects.end(); for (; anIt != aLast; anIt++) { ObjectPtr anObject = *anIt; if (anObject.get() != NULL) { - aSelectedPrs.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL)); + aSelectedPrs.append(std::shared_ptr( + new ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL))); } } return aSelectedPrs; @@ -83,12 +85,12 @@ QList ModuleBase_ISelection::getViewerPrs(const QObjectPtr //******************************************************************** void ModuleBase_ISelection::filterSelectionOnEqualPoints - (QList& theSelected) + (QList& theSelected) { - QList aCandidatesToRemove; - QList::const_iterator anIt = theSelected.begin(), + QList aCandidatesToRemove; + QList::const_iterator anIt = theSelected.begin(), aLast = theSelected.end(); - QList::const_iterator aSubIt; + QList::const_iterator aSubIt; for (; anIt != aLast; anIt++) { aSubIt = anIt; aSubIt++; @@ -99,19 +101,19 @@ void ModuleBase_ISelection::filterSelectionOnEqualPoints } } } - QList::const_iterator aRemIt = aCandidatesToRemove.begin(), + QList::const_iterator aRemIt = aCandidatesToRemove.begin(), aRemLast = aCandidatesToRemove.end(); for (; aRemIt != aRemLast; aRemIt++) { theSelected.removeAll(*aRemIt); } } -bool ModuleBase_ISelection::isEqualVertices(const ModuleBase_ViewerPrs thePrs1, - const ModuleBase_ViewerPrs thePrs2) +bool ModuleBase_ISelection::isEqualVertices(const ModuleBase_ViewerPrsPtr thePrs1, + const ModuleBase_ViewerPrsPtr thePrs2) { bool isEqual = false; - Handle(StdSelect_BRepOwner) anOwner1 = Handle(StdSelect_BRepOwner)::DownCast(thePrs1.owner()); - Handle(StdSelect_BRepOwner) anOwner2 = Handle(StdSelect_BRepOwner)::DownCast(thePrs2.owner()); + Handle(StdSelect_BRepOwner) anOwner1 = Handle(StdSelect_BRepOwner)::DownCast(thePrs1->owner()); + Handle(StdSelect_BRepOwner) anOwner2 = Handle(StdSelect_BRepOwner)::DownCast(thePrs2->owner()); if (!anOwner1.IsNull() && anOwner1->HasShape() && !anOwner2.IsNull() && anOwner2->HasShape()) { diff --git a/src/ModuleBase/ModuleBase_ISelection.h b/src/ModuleBase/ModuleBase_ISelection.h index 0f9c0cb68..fbfa973a6 100644 --- a/src/ModuleBase/ModuleBase_ISelection.h +++ b/src/ModuleBase/ModuleBase_ISelection.h @@ -36,23 +36,23 @@ class ModuleBase_ISelection /// Returns a list of viewer selected presentations /// \return list of presentations - virtual QList getSelected(const SelectionPlace& thePlace = Browser) const = 0; + virtual QList> getSelected(const SelectionPlace& thePlace = Browser) const = 0; /// The values are appended to the first parameter list if the first list does not contain an item /// with the same object /// \param theValues a list of new values /// \param theValuesTo a list, that will be changed - static void appendSelected(const QList theValues, - QList& theValuesTo); + static void appendSelected(const QList> theValues, + QList>& theValuesTo); /// Returns a list of viewer highlited presentations /// \return list of presentations - virtual QList getHighlighted() const = 0; + virtual QList> getHighlighted() const = 0; /// Fills the viewer presentation parameters by the parameters from the owner /// \param thePrs a container for selection /// \param theOwner a selection owner - virtual void fillPresentation(ModuleBase_ViewerPrs& thePrs, + virtual void fillPresentation(std::shared_ptr& thePrs, const Handle_SelectMgr_EntityOwner& theOwner) const = 0; /** @@ -89,35 +89,35 @@ class ModuleBase_ISelection //! If the shape is equal to the shape of selected object, it returns an empty shape //! \param thePrs a selected object //! \return a shape - MODULEBASE_EXPORT ResultPtr getResult(const ModuleBase_ViewerPrs& thePrs); + MODULEBASE_EXPORT ResultPtr getResult(const std::shared_ptr& thePrs); //! Return the shape from the viewer presentation. //! If the shape is equal to the shape of selected object, it returns an empty shape //! \param thePrs a selected object //! \return a shape - MODULEBASE_EXPORT GeomShapePtr getShape(const ModuleBase_ViewerPrs& thePrs); + MODULEBASE_EXPORT GeomShapePtr getShape(const std::shared_ptr& thePrs); //! Return the IO from the viewer presentation. //! \param thePrs a selected object //! \return an interactive object - virtual MODULEBASE_EXPORT Handle(AIS_InteractiveObject) getIO(const ModuleBase_ViewerPrs& thePrs) = 0; + virtual MODULEBASE_EXPORT Handle(AIS_InteractiveObject) getIO(const std::shared_ptr& thePrs) = 0; //! Wraps the object list into the viewer prs list //! \param theObjects a list of objects //! \return a list of prs, where only object is not empty - static MODULEBASE_EXPORT QList getViewerPrs( + static MODULEBASE_EXPORT QList> getViewerPrs( const QObjectPtrList& theObjects); /// Removes selection items where owners have equal vertices. The first /// owner with the qual vertex stays in the list. static MODULEBASE_EXPORT void filterSelectionOnEqualPoints - (QList& theSelected); + (QList>& theSelected); private: /// Returns true if the presentations have an owner with a vertex and these vertices are equal. /// \param thePrs1 the first viewer selected presentation /// \param thePrs2 the second viewer selected presentation - static bool isEqualVertices(const ModuleBase_ViewerPrs thePrs1, - const ModuleBase_ViewerPrs thePrs2); + static bool isEqualVertices(const std::shared_ptr thePrs1, + const std::shared_ptr thePrs2); }; #endif diff --git a/src/ModuleBase/ModuleBase_IWorkshop.h b/src/ModuleBase/ModuleBase_IWorkshop.h index caeb3dbbd..3c0fa44d1 100644 --- a/src/ModuleBase/ModuleBase_IWorkshop.h +++ b/src/ModuleBase/ModuleBase_IWorkshop.h @@ -99,7 +99,7 @@ Q_OBJECT //! Select features clearing previous selection. //! If the list is empty then selection will be cleared //! \param theValues a list of presentations - virtual void setSelected(const QList& theValues) = 0; + virtual void setSelected(const QList>& theValues) = 0; /// Update of commands status virtual void updateCommandStatus() = 0; diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 279d1e774..3da454d0e 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -104,7 +104,7 @@ Q_OBJECT /// This value should be processed in the widget according to the needs /// \param theValues the wrapped selection values /// \param theToValidate the boolean value whether the value should be checked by filters - virtual bool setSelection(QList& theValues, + virtual bool setSelection(QList>& theValues, const bool theToValidate) { return false; @@ -112,7 +112,7 @@ Q_OBJECT /// Returns values which should be highlighted when the whidget is active /// \param theValues a list of presentations - virtual void getHighlighted(QList& theValues) {}; + virtual void getHighlighted(QList>& theValues) {}; /// Restore value from attribute data to the widget's control. Emits signals before and after store /// \return True in success diff --git a/src/ModuleBase/ModuleBase_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index 0cc1cfea1..f6838a049 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -412,11 +412,11 @@ FeaturePtr ModuleBase_OperationFeature::previousCurrentFeature() void ModuleBase_OperationFeature::initSelection(ModuleBase_ISelection* theSelection, ModuleBase_IViewer* theViewer) { - QList aPreSelected; + QList aPreSelected; // Check that the selected result are not results of operation feature FeaturePtr aFeature = feature(); if (aFeature) { - QList aSelected = theSelection->getSelected(ModuleBase_ISelection::AllControls); + QList aSelected = theSelection->getSelected(ModuleBase_ISelection::AllControls); std::list aResults = aFeature->results(); QObjectPtrList aResList; @@ -424,8 +424,8 @@ void ModuleBase_OperationFeature::initSelection(ModuleBase_ISelection* theSelect for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) aResList.append(*aIt); - foreach (ModuleBase_ViewerPrs aPrs, aSelected) { - if ((!aResList.contains(aPrs.object())) && (aPrs.object() != aFeature)) + foreach (ModuleBase_ViewerPrsPtr aPrs, aSelected) { + if ((!aResList.contains(aPrs->object())) && (aPrs->object() != aFeature)) aPreSelected.append(aPrs); } } else @@ -434,7 +434,7 @@ void ModuleBase_OperationFeature::initSelection(ModuleBase_ISelection* theSelect setPreselection(aPreSelected); } -void ModuleBase_OperationFeature::setPreselection(const QList& theValues) +void ModuleBase_OperationFeature::setPreselection(const QList& theValues) { clearPreselection(); myPreSelection = theValues; diff --git a/src/ModuleBase/ModuleBase_OperationFeature.h b/src/ModuleBase/ModuleBase_OperationFeature.h index b6f5c95fd..48c374a65 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.h +++ b/src/ModuleBase/ModuleBase_OperationFeature.h @@ -100,7 +100,7 @@ Q_OBJECT /// Fill internal map by preselection /// \param theValues a list of preselection - void setPreselection(const QList& theValues); + void setPreselection(const QList>& theValues); /// \brief Set property pane to the operation /// \param theProp a property panel instance @@ -177,7 +177,7 @@ Q_OBJECT bool myIsEditing; /// List of pre-selected object - QList myPreSelection; + QList> myPreSelection; /// If the operation works with feature which is sub-feature of another one /// then this variable has to be initialised by parent feature diff --git a/src/ModuleBase/ModuleBase_ViewerPrs.cpp b/src/ModuleBase/ModuleBase_ViewerPrs.cpp index f11b3b077..43b584bdb 100644 --- a/src/ModuleBase/ModuleBase_ViewerPrs.cpp +++ b/src/ModuleBase/ModuleBase_ViewerPrs.cpp @@ -8,11 +8,6 @@ #include -ModuleBase_ViewerPrs::ModuleBase_ViewerPrs() -{ - -} - ModuleBase_ViewerPrs::ModuleBase_ViewerPrs(ObjectPtr theResult, const GeomShapePtr& theShape, Handle_SelectMgr_EntityOwner theOwner) @@ -43,7 +38,8 @@ bool ModuleBase_ViewerPrs::operator==(const ModuleBase_ViewerPrs& thePrs) Handle(StdSelect_BRepOwner) anOwner1 = Handle(StdSelect_BRepOwner)::DownCast(myOwner); Handle(StdSelect_BRepOwner) anOwner2 = Handle(StdSelect_BRepOwner)::DownCast(thePrs.owner()); if (!anOwner1.IsNull() && !anOwner2.IsNull()) - isEqualOwner = anOwner1->Shape() == anOwner2->Shape(); + isEqualOwner = (anOwner1->Shape().IsNull() && anOwner2->Shape().IsNull()) || + anOwner1->Shape().IsEqual(anOwner2->Shape()); } if (isEqualResult && isEqualShape && @@ -56,7 +52,8 @@ bool ModuleBase_ViewerPrs::operator==(const ModuleBase_ViewerPrs& thePrs) Handle(ModuleBase_BRepOwner) aCSolidOwner2 = Handle(ModuleBase_BRepOwner)::DownCast(thePrs.owner()); isEqualIO = !aCSolidOwner1.IsNull() && !aCSolidOwner2.IsNull(); if (!aCSolidOwner1.IsNull() && !aCSolidOwner1.IsNull()) - isEqualOwner = aCSolidOwner1->Shape() == aCSolidOwner1->Shape(); + isEqualOwner = (aCSolidOwner1->Shape().IsNull() && aCSolidOwner2->Shape().IsNull()) || + aCSolidOwner1->Shape().IsEqual(aCSolidOwner2->Shape()); } return isEqualResult && isEqualShape && isEqualOwner && isEqualIO; diff --git a/src/ModuleBase/ModuleBase_ViewerPrs.h b/src/ModuleBase/ModuleBase_ViewerPrs.h index 39513240b..7a3112b42 100644 --- a/src/ModuleBase/ModuleBase_ViewerPrs.h +++ b/src/ModuleBase/ModuleBase_ViewerPrs.h @@ -23,15 +23,13 @@ class ModuleBase_ViewerPrs { public: - /// Constructor - MODULEBASE_EXPORT ModuleBase_ViewerPrs(); - /// Constructor /// \param theResult an object /// \param theShape a viewer shape /// \param theOwner a selection owner - MODULEBASE_EXPORT ModuleBase_ViewerPrs(ObjectPtr theResult, const GeomShapePtr& theShape, - Handle_SelectMgr_EntityOwner theOwner); + MODULEBASE_EXPORT ModuleBase_ViewerPrs(ObjectPtr theResult = ObjectPtr(), + const GeomShapePtr& theShape = GeomShapePtr(), + Handle_SelectMgr_EntityOwner theOwner = NULL); /// Destructor MODULEBASE_EXPORT virtual ~ModuleBase_ViewerPrs(); @@ -110,4 +108,6 @@ class ModuleBase_ViewerPrs Handle(AIS_InteractiveObject) myInteractive; /// interactive object }; +typedef std::shared_ptr ModuleBase_ViewerPrsPtr; + #endif diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 157eb4f9a..8e2785151 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -215,19 +215,19 @@ bool ModuleBase_WidgetMultiSelector::restoreValueCustom() } //******************************************************************** -bool ModuleBase_WidgetMultiSelector::setSelection(QList& theValues, +bool ModuleBase_WidgetMultiSelector::setSelection(QList& theValues, const bool theToValidate) { - QList aSkippedValues; + QList aSkippedValues; /// remove unused objects from the model attribute. /// It should be performed before new attributes append. removeUnusedAttributeObjects(theValues); - QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); + QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); bool isDone = false; for (; anIt != aLast; anIt++) { - ModuleBase_ViewerPrs aValue = *anIt; + ModuleBase_ViewerPrsPtr aValue = *anIt; bool aProcessed = false; if (!theToValidate || isValidInFilters(aValue)) { aProcessed = setSelectionCustom(aValue); @@ -253,7 +253,7 @@ bool ModuleBase_WidgetMultiSelector::setSelection(QList& t } //******************************************************************** -void ModuleBase_WidgetMultiSelector::getHighlighted(QList& theValues) +void ModuleBase_WidgetMultiSelector::getHighlighted(QList& theValues) { std::set anAttributeIds; getSelectedAttributeIndices(anAttributeIds); @@ -262,7 +262,7 @@ void ModuleBase_WidgetMultiSelector::getHighlighted(QList& } //******************************************************************** -bool ModuleBase_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs) +bool ModuleBase_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs) { bool aValid = ModuleBase_WidgetSelector::isValidSelectionCustom(thePrs); if (aValid) { @@ -340,7 +340,7 @@ QList ModuleBase_WidgetMultiSelector::getControls() const void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged() { activateSelectionAndFilters(true); - QList anEmptyList; + QList anEmptyList; // This method will call Selection changed event which will call onSelectionChanged // To clear mySelection, myListControl and storeValue() // So, we don't need to call it @@ -400,9 +400,9 @@ void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const TopAbs_ShapeEnum } } -QList ModuleBase_WidgetMultiSelector::getAttributeSelection() const +QList ModuleBase_WidgetMultiSelector::getAttributeSelection() const { - QList aSelected; + QList aSelected; convertIndicesToViewerSelection(std::set(), aSelected); return aSelected; } @@ -523,7 +523,7 @@ void ModuleBase_WidgetMultiSelector::getSelectedAttributeIndices(std::set& } void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::set theAttributeIds, - QList& theValues) const + QList& theValues) const { if(myFeature.get() == NULL) return; @@ -540,7 +540,8 @@ void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::setvalue(i); ResultPtr anObject = anAttr->context(); if (anObject.get()) - theValues.append(ModuleBase_ViewerPrs(anObject, anAttr->value(), NULL)); + theValues.append(std::shared_ptr( + new ModuleBase_ViewerPrs(anObject, anAttr->value(), NULL))); } } else if (aType == ModelAPI_AttributeRefList::typeId()) { @@ -551,7 +552,8 @@ void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::setobject(i); if (anObject.get()) { - theValues.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL)); + theValues.append(std::shared_ptr( + new ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL))); } } } @@ -568,14 +570,15 @@ void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::setattribute(i); if (anAttribute.get()) { GeomShapePtr aGeomShape = ModuleBase_Tools::getShape(anAttribute, myWorkshop); - theValues.append(ModuleBase_ViewerPrs(anObject, aGeomShape, NULL)); + theValues.append(std::shared_ptr( + new ModuleBase_ViewerPrs(anObject, aGeomShape, NULL))); } } } } void ModuleBase_WidgetMultiSelector::removeUnusedAttributeObjects - (QList& theValues) + (QList& theValues) { std::map > aGeomSelection = convertSelection(theValues); DataPtr aData = myFeature->data(); @@ -608,11 +611,11 @@ void ModuleBase_WidgetMultiSelector::removeUnusedAttributeObjects } else if (aType == ModelAPI_AttributeRefAttrList::typeId()) { std::set anAttributes; - QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); + QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); ObjectPtr anObject; GeomShapePtr aShape; for (; anIt != aLast; anIt++) { - ModuleBase_ViewerPrs aPrs = *anIt; + ModuleBase_ViewerPrsPtr aPrs = *anIt; getGeomSelection(aPrs, anObject, aShape); AttributePtr anAttr = myWorkshop->module()->findAttribute(anObject, aShape); if (anAttr.get() && anAttributes.find(anAttr) == anAttributes.end()) @@ -637,17 +640,17 @@ void ModuleBase_WidgetMultiSelector::removeUnusedAttributeObjects } std::map > ModuleBase_WidgetMultiSelector::convertSelection - (QList& theValues) + (QList& theValues) { // convert prs list to objects map std::map > aGeomSelection; std::set aShapes; - QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); + QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); ObjectPtr anObject; GeomShapePtr aShape; GeomShapePtr anEmptyShape(new GeomAPI_Shape()); for (; anIt != aLast; anIt++) { - ModuleBase_ViewerPrs aPrs = *anIt; + ModuleBase_ViewerPrsPtr aPrs = *anIt; getGeomSelection(aPrs, anObject, aShape); aShapes.clear(); if (aGeomSelection.find(anObject) != aGeomSelection.end()) // found diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 42e789bfd..ee15240ed 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -70,17 +70,17 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Widge /// This value should be processed in the widget according to the needs /// \param theValues the wrapped selection values /// \param theToValidate a validation of the values flag - virtual bool setSelection(QList& theValues, + virtual bool setSelection(QList>& theValues, const bool theToValidate); /// Returns values which should be highlighted when the whidget is active /// \param theValues a list of presentations - virtual void getHighlighted(QList& theValues); + virtual void getHighlighted(QList>& theValues); /// Checks the widget validity. By default, it returns true. /// \param thePrs a selected presentation in the view /// \return a boolean value - virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs); + virtual bool isValidSelectionCustom(const std::shared_ptr& thePrs); /// Returns true if the event is processed. The default implementation is empty, returns false. virtual bool processDelete(); @@ -125,7 +125,7 @@ protected: /// Return the attribute values wrapped in a list of viewer presentations /// \return a list of viewer presentations, which contains an attribute result and /// a shape. If the attribute do not uses the shape, it is empty - virtual QList getAttributeSelection() const; + virtual QList> getAttributeSelection() const; /// Fills the list control by the attribute values void updateSelectionList(); @@ -144,17 +144,17 @@ protected: /// \param theAttributeIds indices in attribute list to be returned /// \param theValues the result presentations, filled with object and shape of an attribute item void convertIndicesToViewerSelection(std::set theAttributeIds, - QList& theValues) const; + QList>& theValues) const; /// Iterates throgh the model attribute list and remove elements which do not present in the list /// \param theValues the wrapped selection values - virtual void removeUnusedAttributeObjects(QList& theValues); + virtual void removeUnusedAttributeObjects(QList>& theValues); /// Converts viewer presentation selection list to objects and shapes map /// \param theValues the wrapped selection values /// \return selection list std::map > convertSelection - (QList& theValues); + (QList>& theValues); /// Returns true if the object and shape present in the container /// \param theObject a model object, a set of shapes is searched by it diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index fbfe2b799..4d8034ed8 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -32,7 +32,7 @@ ModuleBase_WidgetSelector::~ModuleBase_WidgetSelector() } //******************************************************************** -void ModuleBase_WidgetSelector::getGeomSelection(const ModuleBase_ViewerPrs& thePrs, +void ModuleBase_WidgetSelector::getGeomSelection(const ModuleBase_ViewerPrsPtr& thePrs, ObjectPtr& theObject, GeomShapePtr& theShape) { @@ -44,7 +44,7 @@ void ModuleBase_WidgetSelector::getGeomSelection(const ModuleBase_ViewerPrs& the //******************************************************************** void ModuleBase_WidgetSelector::onSelectionChanged() { - QList aSelected = getFilteredSelected(); + QList aSelected = getFilteredSelected(); bool isDone = setSelection(aSelected, true/*false*/); updateOnSelectionChanged(isDone); } @@ -69,9 +69,9 @@ void ModuleBase_WidgetSelector::updateOnSelectionChanged(const bool theDone) } //******************************************************************** -QList ModuleBase_WidgetSelector::getAttributeSelection() const +QList ModuleBase_WidgetSelector::getAttributeSelection() const { - return QList(); + return QList(); } //******************************************************************** @@ -153,7 +153,7 @@ void ModuleBase_WidgetSelector::activateCustom() } //******************************************************************** -bool ModuleBase_WidgetSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs) +bool ModuleBase_WidgetSelector::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs) { GeomShapePtr aShape = myWorkshop->selection()->getShape(thePrs); ResultPtr aResult = myWorkshop->selection()->getResult(thePrs); @@ -169,7 +169,7 @@ bool ModuleBase_WidgetSelector::isValidSelectionCustom(const ModuleBase_ViewerPr } //******************************************************************** -bool ModuleBase_WidgetSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) +bool ModuleBase_WidgetSelector::setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs) { ObjectPtr anObject; GeomShapePtr aShape; diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.h b/src/ModuleBase/ModuleBase_WidgetSelector.h index a470aa875..152b76f1e 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetSelector.h @@ -49,11 +49,11 @@ Q_OBJECT /// Checks the widget validity. By default, it returns true. /// \param thePrs a selected presentation in the view /// \return a boolean value - virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs); + virtual bool isValidSelectionCustom(const std::shared_ptr& thePrs); /// Fills the attribute with the value of the selected owner /// \param thePrs a selected owner - virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs); + virtual bool setSelectionCustom(const std::shared_ptr& thePrs); /// The methiod called when widget is deactivated virtual void deactivate(); @@ -75,7 +75,7 @@ protected: /// \return a list of viewer presentations, which contains an attribute result and /// a shape. If the attribute do not uses the shape, it is empty // NDS: has body is temporary - virtual QList getAttributeSelection() const; + virtual QList> getAttributeSelection() const; /// Retunrs a list of possible shape types /// \return a list of shapes @@ -100,7 +100,7 @@ protected: /// \param thePrs a selection /// \param theObject an output object /// \param theShape a shape of the selection - virtual void getGeomSelection(const ModuleBase_ViewerPrs& thePrs, + virtual void getGeomSelection(const std::shared_ptr& thePrs, ObjectPtr& theObject, GeomShapePtr& theShape); diff --git a/src/ModuleBase/ModuleBase_WidgetSelectorStore.h b/src/ModuleBase/ModuleBase_WidgetSelectorStore.h index a3584e301..ed727db8c 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelectorStore.h +++ b/src/ModuleBase/ModuleBase_WidgetSelectorStore.h @@ -19,26 +19,26 @@ class ModuleBase_IWorkshop; * \ingroup GUI Provides for an attribute backup of values. It is possible to store/ restore the attribute values. */ -class MODULEBASE_EXPORT ModuleBase_WidgetSelectorStore +class ModuleBase_WidgetSelectorStore { public: /// Constructor - ModuleBase_WidgetSelectorStore(); + MODULEBASE_EXPORT ModuleBase_WidgetSelectorStore(); /// Destructor - virtual ~ModuleBase_WidgetSelectorStore() {} + MODULEBASE_EXPORT virtual ~ModuleBase_WidgetSelectorStore() {} /// Creates a backup of the current values of the attribute /// \param theAttribute a model attribute which parameters are to be stored /// \param theWorkshop a current workshop - void storeAttributeValue(const AttributePtr& theAttribute, - ModuleBase_IWorkshop* theWorkshop); + MODULEBASE_EXPORT void storeAttributeValue(const AttributePtr& theAttribute, + ModuleBase_IWorkshop* theWorkshop); /// Creates a backup of the current values of the attribute /// \param theAttribute a model attribute which parameters are to be restored /// \param theWorkshop a current workshop - void restoreAttributeValue(const AttributePtr& theAttribute, - ModuleBase_IWorkshop* theWorkshop); + MODULEBASE_EXPORT void restoreAttributeValue(const AttributePtr& theAttribute, + ModuleBase_IWorkshop* theWorkshop); private: /// backup parameters of the model attribute. The class processes three types of attribute: diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 1bcedc636..ff003f0e8 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -107,16 +107,17 @@ bool ModuleBase_WidgetShapeSelector::storeValueCustom() const } //******************************************************************** -bool ModuleBase_WidgetShapeSelector::setSelection(QList& theValues, +bool ModuleBase_WidgetShapeSelector::setSelection(QList& theValues, const bool theToValidate) { if (theValues.empty()) { // In order to make reselection possible, set empty object and shape should be done - setSelectionCustom(ModuleBase_ViewerPrs()); + setSelectionCustom(std::shared_ptr(new ModuleBase_ViewerPrs( + ObjectPtr(), GeomShapePtr(), NULL))); return false; } // it removes the processed value from the parameters list - ModuleBase_ViewerPrs aValue = theValues.takeFirst(); + ModuleBase_ViewerPrsPtr aValue = theValues.takeFirst(); bool isDone = false; if (!theToValidate || isValidInFilters(aValue)) { @@ -131,16 +132,16 @@ bool ModuleBase_WidgetShapeSelector::setSelection(QList& t } //******************************************************************** -QList ModuleBase_WidgetShapeSelector::getAttributeSelection() const +QList ModuleBase_WidgetShapeSelector::getAttributeSelection() const { - QList aSelected; + QList aSelected; if(myFeature) { DataPtr aData = myFeature->data(); AttributePtr anAttribute = myFeature->attribute(attributeID()); ObjectPtr anObject = ModuleBase_Tools::getObject(anAttribute); std::shared_ptr aShapePtr = getShape(); - ModuleBase_ViewerPrs aPrs(anObject, aShapePtr, NULL); + ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs(anObject, aShapePtr, NULL)); aSelected.append(aPrs); } return aSelected; diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h index ca7f636ec..35ce69e16 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h @@ -74,7 +74,7 @@ Q_OBJECT /// It is redefined to check the value validity and if it is, fill the attribute with by value /// \param theValues the wrapped selection values /// \param theToValidate a flag on validation of the values - virtual bool setSelection(QList& theValues, + virtual bool setSelection(QList>& theValues, const bool theToValidate); /// Returns list of widget controls @@ -105,7 +105,7 @@ Q_OBJECT /// Return the attribute values wrapped in a list of viewer presentations /// \return a list of viewer presentations, which contains an attribute result and /// a shape. If the attribute do not uses the shape, it is empty - virtual QList getAttributeSelection() const; + virtual QList> getAttributeSelection() const; //----------- Class members ------------- protected: diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index ad16435bc..a78a1c893 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -69,14 +69,14 @@ void ModuleBase_WidgetValidated::restoreAttributeValue(const AttributePtr& theAt } //******************************************************************** -bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrs& thePrs) +bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrsPtr& thePrs) { bool aValid = true; - Handle(SelectMgr_EntityOwner) anOwner = thePrs.owner(); + Handle(SelectMgr_EntityOwner) anOwner = thePrs->owner(); // if an owner is null, the selection happens in the Object browser. // creates a selection owner on the base of object shape and the object AIS object - if (anOwner.IsNull() && thePrs.owner().IsNull() && thePrs.object().get()) { + if (anOwner.IsNull() && thePrs->owner().IsNull() && thePrs->object().get()) { ResultPtr aResult = myWorkshop->selection()->getResult(thePrs); if (aResult.get() && aResult->shape().get()) { // some results have no shape, e.g. the parameter one. So, they should not be validated @@ -111,7 +111,7 @@ bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrs& th } // removes created owner - if (!anOwner.IsNull() && anOwner != thePrs.owner()) { + if (!anOwner.IsNull() && anOwner != thePrs->owner()) { anOwner.Nullify(); myPresentedObject = ObjectPtr(); } @@ -125,7 +125,7 @@ AttributePtr ModuleBase_WidgetValidated::attribute() const } //******************************************************************** -bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& theValue) +bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrsPtr& theValue) { bool aValid = false; if (getValidState(theValue, aValid)) { @@ -140,7 +140,7 @@ bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& th } //******************************************************************** -bool ModuleBase_WidgetValidated::isValidSelectionForAttribute(const ModuleBase_ViewerPrs& theValue, +bool ModuleBase_WidgetValidated::isValidSelectionForAttribute(const ModuleBase_ViewerPrsPtr& theValue, const AttributePtr& theAttribute) { bool aValid = false; @@ -176,7 +176,7 @@ bool ModuleBase_WidgetValidated::isValidSelectionForAttribute(const ModuleBase_V } //******************************************************************** -bool ModuleBase_WidgetValidated::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs) +bool ModuleBase_WidgetValidated::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs) { return true; } @@ -241,7 +241,7 @@ void ModuleBase_WidgetValidated::blockAttribute(const AttributePtr& theAttribute } //******************************************************************** -void ModuleBase_WidgetValidated::storeValidState(const ModuleBase_ViewerPrs& theValue, const bool theValid) +void ModuleBase_WidgetValidated::storeValidState(const ModuleBase_ViewerPrsPtr& theValue, const bool theValid) { bool aValidPrs = myInvalidPrs.contains(theValue); bool anInvalidPrs = myInvalidPrs.contains(theValue); @@ -267,7 +267,7 @@ void ModuleBase_WidgetValidated::storeValidState(const ModuleBase_ViewerPrs& the } //******************************************************************** -bool ModuleBase_WidgetValidated::getValidState(const ModuleBase_ViewerPrs& theValue, bool& theValid) +bool ModuleBase_WidgetValidated::getValidState(const ModuleBase_ViewerPrsPtr& theValue, bool& theValid) { bool aValidPrs = myValidPrs.contains(theValue); bool anInvalidPrs = myInvalidPrs.contains(theValue); @@ -281,12 +281,12 @@ bool ModuleBase_WidgetValidated::getValidState(const ModuleBase_ViewerPrs& theVa } //******************************************************************** -QList ModuleBase_WidgetValidated::getFilteredSelected() +QList ModuleBase_WidgetValidated::getFilteredSelected() { - QList aSelected = myWorkshop->selection()->getSelected( + QList aSelected = myWorkshop->selection()->getSelected( ModuleBase_ISelection::Viewer); - QList anOBSelected = myWorkshop->selection()->getSelected( + QList anOBSelected = myWorkshop->selection()->getSelected( ModuleBase_ISelection::Browser); // filter the OB presentations filterPresentations(anOBSelected); @@ -299,11 +299,11 @@ QList ModuleBase_WidgetValidated::getFilteredSelected() } //******************************************************************** -void ModuleBase_WidgetValidated::filterPresentations(QList& theValues) +void ModuleBase_WidgetValidated::filterPresentations(QList& theValues) { - QList aValidatedValues; + QList aValidatedValues; - QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); + QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); bool isDone = false; for (; anIt != aLast; anIt++) { if (isValidInFilters(*anIt)) @@ -316,16 +316,16 @@ void ModuleBase_WidgetValidated::filterPresentations(QList } //******************************************************************** -void ModuleBase_WidgetValidated::filterCompSolids(QList& theValues) +void ModuleBase_WidgetValidated::filterCompSolids(QList& theValues) { std::set aCompSolids; - QList aValidatedValues; + QList aValidatedValues; // Collect compsolids. - QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); + QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); for (; anIt != aLast; anIt++) { - const ModuleBase_ViewerPrs& aViewerPrs = *anIt; - ObjectPtr anObject = aViewerPrs.object(); + const ModuleBase_ViewerPrsPtr& aViewerPrs = *anIt; + ObjectPtr anObject = aViewerPrs->object(); ResultCompSolidPtr aResultCompSolid = std::dynamic_pointer_cast(anObject); if(aResultCompSolid.get()) { aCompSolids.insert(aResultCompSolid); @@ -335,8 +335,8 @@ void ModuleBase_WidgetValidated::filterCompSolids(QList& t // Filter sub-solids of compsolids. anIt = theValues.begin(); for (; anIt != aLast; anIt++) { - const ModuleBase_ViewerPrs& aViewerPrs = *anIt; - ObjectPtr anObject = aViewerPrs.object(); + const ModuleBase_ViewerPrsPtr& aViewerPrs = *anIt; + ObjectPtr anObject = aViewerPrs->object(); ResultPtr aResult = std::dynamic_pointer_cast(anObject); ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aResult); if(aResCompSolidPtr.get() && (aCompSolids.find(aResCompSolidPtr) != aCompSolids.end())) { diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index 32f47d34e..8b2ae15ba 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -51,7 +51,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg /// restored.The valid/invalid value is cashed. /// \param theValue a selected presentation in the view /// \return a boolean value - virtual bool isValidSelection(const ModuleBase_ViewerPrs& theValue); + virtual bool isValidSelection(const std::shared_ptr& theValue); //! Returns data object by AIS ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const; @@ -63,14 +63,14 @@ protected: /// Checks whether all active viewer filters validate the presentation /// \param thePrs a selected presentation in the view /// \return a boolean value - bool isValidInFilters(const ModuleBase_ViewerPrs& thePrs); + bool isValidInFilters(const std::shared_ptr& thePrs); /// Checks all attribute validators returns valid. It tries on the given selection /// to current attribute by setting the value inside and calling validators. After this, /// the previous attribute value is restored.The valid/invalid value is cashed. /// \param theValue a selected presentation in the view /// \return a boolean value - bool isValidSelectionForAttribute(const ModuleBase_ViewerPrs& theValue, + bool isValidSelectionForAttribute(const std::shared_ptr& theValue, const AttributePtr& theAttribute); /// Retunrs attribute, which should be validated. In default implementation, @@ -94,16 +94,16 @@ protected: /// Checks the widget validity. By default, it returns true. /// \param thePrs a selected presentation in the view /// \return a boolean value - virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs); + virtual bool isValidSelectionCustom(const std::shared_ptr& thePrs); /// Fills the attribute with the value of the selected owner /// \param thePrs a selected owner - virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) = 0; + virtual bool setSelectionCustom(const std::shared_ptr& thePrs) = 0; /// Returns a list of selected presentations in the viewer and object browser /// The presentations from the object browser are filtered by the AIS context filters /// \return a list of presentations - QList getFilteredSelected(); + QList> getFilteredSelected(); /// It obtains selection filters from the workshop and activates them in the active viewer /// \param toActivate a flag about activation or deactivation the filters @@ -134,22 +134,22 @@ protected: /// Gets the validity state of the presentation in an internal map. Returns true if the valid state of value is stored /// \param theValue a viewer presentation /// \param theValid a valid state - bool getValidState(const ModuleBase_ViewerPrs& theValue, bool& theValid); + bool getValidState(const std::shared_ptr& theValue, bool& theValid); /// Store the validity state of the presentation in an internal map /// \param theValue a viewer presentation /// \param theValid a valid state - void storeValidState(const ModuleBase_ViewerPrs& theValue, const bool theValid); + void storeValidState(const std::shared_ptr& theValue, const bool theValid); private: /// Applies AIS context filters to the parameter list. The not approved presentations are /// removed from the parameters. /// \param theValues a list of presentations. - void filterPresentations(QList& theValues); + void filterPresentations(QList>& theValues); /// Remove subshapes of compsolids if whole compsolid is present. /// \param theValues a list of presentations. - void filterCompSolids(QList& theValues); + void filterCompSolids(QList>& theValues); protected: /// Reference to workshop @@ -159,8 +159,8 @@ protected: private: ObjectPtr myPresentedObject; /// back up of the filtered object - QList myValidPrs; /// cash of valid selection presentations - QList myInvalidPrs; /// cash of invalid selection presentations + QList> myValidPrs; /// cash of valid selection presentations + QList> myInvalidPrs; /// cash of invalid selection presentations /// store to backup parameters of the model ModuleBase_WidgetSelectorStore* myAttributeStore; diff --git a/src/PartSet/PartSet_FilterInfinite.cpp b/src/PartSet/PartSet_FilterInfinite.cpp index 7b8d328ba..ce873e62e 100755 --- a/src/PartSet/PartSet_FilterInfinite.cpp +++ b/src/PartSet/PartSet_FilterInfinite.cpp @@ -27,7 +27,7 @@ Standard_Boolean PartSet_FilterInfinite::IsOk(const Handle(SelectMgr_EntityOwner { Standard_Boolean aValid = Standard_True; - ModuleBase_ViewerPrs aPrs; + ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs()); myWorkshop->selection()->fillPresentation(aPrs, theOwner); ResultPtr aResult = myWorkshop->selection()->getResult(aPrs); // to filter infinite construction results diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index a970e4979..ec2bc05b6 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -119,25 +119,25 @@ bool PartSet_MenuMgr::addViewerMenu(QMenu* theMenu, const QMap aPrsList = aSelection->getSelected(ModuleBase_ISelection::Viewer); + QList aPrsList = aSelection->getSelected(ModuleBase_ISelection::Viewer); ResultPtr aResult; FeaturePtr aFeature; - foreach(ModuleBase_ViewerPrs aPrs, aPrsList) { - aResult = std::dynamic_pointer_cast(aPrs.object()); + foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) { + aResult = std::dynamic_pointer_cast(aPrs->object()); if (aResult.get() != NULL) { - const GeomShapePtr& aShape = aPrs.shape(); + const GeomShapePtr& aShape = aPrs->shape(); if (aShape.get() && aShape->isEqual(aResult->shape())) hasFeature = true; else hasAttribute = true; } else { - aFeature = std::dynamic_pointer_cast(aPrs.object()); + aFeature = std::dynamic_pointer_cast(aPrs->object()); hasFeature = (aFeature.get() != NULL); } } if (aPrsList.size() == 1) { - const GeomShapePtr& aShape = aPrsList.first().shape(); + const GeomShapePtr& aShape = aPrsList.first()->shape(); if (aShape.get() && !aShape->isNull() && aShape->shapeType() == GeomAPI_Shape::VERTEX) { // Find 2d coordinates FeaturePtr aSketchFea = myModule->sketchMgr()->activeSketch(); @@ -148,7 +148,7 @@ bool PartSet_MenuMgr::addViewerMenu(QMenu* theMenu, const QMap aSelPnt = PartSet_Tools::convertTo2D(aSketchFea, aPnt3d); // Find coincident in these coordinates - ObjectPtr aObj = aPrsList.first().object(); + ObjectPtr aObj = aPrsList.first()->object(); FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); FeaturePtr aCoincident = PartSet_Tools::findFirstCoincidence(aFeature, aSelPnt); // If we have coincidence then add Detach menu diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index a55a66c48..cb741d4f0 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -565,14 +565,14 @@ bool PartSet_Module::createWidgets(ModuleBase_Operation* theOperation, if (mySketchMgr->activeSketch().get() && aFOperation && aPropertyPanel) { ModuleBase_ISelection* aSelection = workshop()->selection(); // click on a point in sketch leads here with the point is highlighted, not yet selected - QList aPreselection = aSelection->getHighlighted(); + QList aPreselection = aSelection->getHighlighted(); if (aPreselection.size() == 1) { - ModuleBase_ViewerPrs aSelectedPrs = aPreselection[0]; - ObjectPtr anObject = aSelectedPrs.object(); + ModuleBase_ViewerPrsPtr aSelectedPrs = aPreselection[0]; + ObjectPtr anObject = aSelectedPrs->object(); FeaturePtr aFeature = ModelAPI_Feature::feature(anObject); FeaturePtr anOpFeature = aFOperation->feature(); - GeomShapePtr aShape = aSelectedPrs.shape(); + GeomShapePtr aShape = aSelectedPrs->shape(); // click on the digit of dimension constrain comes here with an empty shape, so we need the check if (aFeature == anOpFeature && aShape.get() && !aShape->isNull()) { const TopoDS_Shape& aTDShape = aShape->impl(); @@ -612,10 +612,10 @@ void PartSet_Module::onSelectionChanged() if (isSketcherOp) { // Editing of constraints can be done on selection ModuleBase_ISelection* aSelect = myWorkshop->selection(); - QList aSelected = aSelect->getSelected(); + QList aSelected = aSelect->getSelected(); if (aSelected.size() == 1) { - ModuleBase_ViewerPrs aPrs = aSelected.first(); - ObjectPtr aObject = aPrs.object(); + ModuleBase_ViewerPrsPtr aPrs = aSelected.first(); + ObjectPtr aObject = aPrs->object(); FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); if (aFeature) { std::string aId = aFeature->getKind(); diff --git a/src/PartSet/PartSet_OperationPrs.cpp b/src/PartSet/PartSet_OperationPrs.cpp index 8b50a2ad5..76e143c82 100755 --- a/src/PartSet/PartSet_OperationPrs.cpp +++ b/src/PartSet/PartSet_OperationPrs.cpp @@ -321,7 +321,7 @@ void PartSet_OperationPrs::getHighlightedShapes(ModuleBase_IWorkshop* theWorksho { theObjectShapes.clear(); - QList aValues; + QList aValues; ModuleBase_IPropertyPanel* aPanel = theWorkshop->propertyPanel(); if (aPanel) { ModuleBase_ModelWidget* aWidget = aPanel->activeWidget(); @@ -331,13 +331,13 @@ void PartSet_OperationPrs::getHighlightedShapes(ModuleBase_IWorkshop* theWorksho } QList aShapes; - QList::const_iterator anIIt = aValues.begin(), + QList::const_iterator anIIt = aValues.begin(), aILast = aValues.end(); for (; anIIt != aILast; anIIt++) { - ModuleBase_ViewerPrs aPrs = *anIIt; - ObjectPtr anObject = aPrs.object(); + ModuleBase_ViewerPrsPtr aPrs = *anIIt; + ObjectPtr anObject = aPrs->object(); - GeomShapePtr aGeomShape = aPrs.shape(); + GeomShapePtr aGeomShape = aPrs->shape(); if (!aGeomShape.get() || aGeomShape->isNull()) { ResultPtr aResult = std::dynamic_pointer_cast(anObject); if (aResult.get()) { diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 06fbec26c..8bb6f0083 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -89,15 +89,15 @@ //#define DEBUG_CURSOR /// Returns list of unique objects by sum of objects from List1 and List2 -/*QList getSumList(const QList& theList1, - const QList& theList2) +/*QList getSumList(const QList& theList1, + const QList& theList2) { - QList aRes; - foreach (ModuleBase_ViewerPrs aPrs, theList1) { + QList aRes; + foreach (ModuleBase_ViewerPrsPtr aPrs, theList1) { if (!aRes.contains(aPrs)) aRes.append(aPrs); } - foreach (ModuleBase_ViewerPrs aPrs, theList2) { + foreach (ModuleBase_ViewerPrsPtr aPrs, theList2) { if (!aRes.contains(aPrs)) aRes.append(aPrs); } @@ -109,18 +109,18 @@ // \param theSketch a sketch to project a vertex shape of a presentation to the plane // and find the corresponded attribute // \param theFeatureList an output list of features -void fillFeatureList(const QList& theList, +void fillFeatureList(const QList& theList, const FeaturePtr theSketch, QList& theFeatureList) { - QList aRes; + QList aRes; - QList::const_iterator anIt = theList.begin(), + QList::const_iterator anIt = theList.begin(), aLast = theList.end(); for (; anIt != aLast; anIt++) { - ModuleBase_ViewerPrs aPrs = *anIt; - FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs.object()); + ModuleBase_ViewerPrsPtr aPrs = *anIt; + FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs->object()); if (aFeature.get() && !theFeatureList.contains(aFeature)) theFeatureList.append(aFeature); } @@ -1621,7 +1621,7 @@ void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly) ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); ModuleBase_ISelection* aSelect = aWorkshop->selection(); - QList aHighlighted = aSelect->getHighlighted(); + QList aHighlighted = aSelect->getHighlighted(); QList aFeatureList; if (theHighlightedOnly) { @@ -1630,7 +1630,7 @@ void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly) else { fillFeatureList(aHighlighted, myCurrentSketch, aFeatureList); - QList aSelected = aSelect->getSelected(ModuleBase_ISelection::AllControls); + QList aSelected = aSelect->getSelected(ModuleBase_ISelection::AllControls); fillFeatureList(aSelected, myCurrentSketch, aFeatureList); } diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index f02f52b4b..84205e1a4 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -152,8 +152,9 @@ bool PartSet_SketcherReetntrantMgr::processMouseMoved(ModuleBase_IViewWindow* /* if (isLineFeature) { PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast(anActiveWidget); if (aPoint2DWdg) { // line, start point should be equal last point of the last feature line - QList aSelection; - aSelection.append(ModuleBase_ViewerPrs(aLastFeature, GeomShapePtr(), NULL)); + QList aSelection; + aSelection.append(std::shared_ptr( + new ModuleBase_ViewerPrs(aLastFeature, GeomShapePtr(), NULL))); aWidgetIsFilled = aPoint2DWdg->setSelection(aSelection, true); } } diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 2fdb1da74..96e50d7ac 100755 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -592,11 +592,11 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap return ResultPtr(); } -bool PartSet_Tools::isContainPresentation(const QList& theSelected, - const ModuleBase_ViewerPrs& thePrs) +bool PartSet_Tools::isContainPresentation(const QList& theSelected, + const ModuleBase_ViewerPrsPtr& thePrs) { - foreach (ModuleBase_ViewerPrs aPrs, theSelected) { - if (aPrs.object() == thePrs.object()) + foreach (ModuleBase_ViewerPrsPtr aPrs, theSelected) { + if (aPrs->object() == thePrs->object()) return true; } return false; @@ -658,12 +658,12 @@ ResultPtr PartSet_Tools::findExternalVertex(CompositeFeaturePtr theSketch, std:: } -bool PartSet_Tools::hasVertexShape(const ModuleBase_ViewerPrs& thePrs, FeaturePtr theSketch, +bool PartSet_Tools::hasVertexShape(const ModuleBase_ViewerPrsPtr& thePrs, FeaturePtr theSketch, Handle_V3d_View theView, double& theX, double& theY) { bool aHasVertex = false; - const GeomShapePtr& aShape = thePrs.shape(); + const GeomShapePtr& aShape = thePrs->shape(); if (aShape.get() && !aShape->isNull() && aShape->shapeType() == GeomAPI_Shape::VERTEX) { const TopoDS_Shape& aTDShape = aShape->impl(); diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h index 489fa6615..292e4c84c 100755 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -179,8 +179,8 @@ public: /// \param theSelected a list of presentations /// \param thePrs a presentation to be found /// \return - result of check, true if the list contains the prs - static bool isContainPresentation(const QList& theSelected, - const ModuleBase_ViewerPrs& thePrs); + static bool isContainPresentation(const QList>& theSelected, + const std::shared_ptr& thePrs); /// Returns Result object if the given skietch contains external edge equal to the given /// \param theSketch - the sketch feature @@ -200,7 +200,7 @@ public: /// \param theView a 3D view /// \param theX the output horizontal coordinate of the point /// \param theY the output vertical coordinate of the point - static bool hasVertexShape(const ModuleBase_ViewerPrs& thePrs, FeaturePtr theSketch, + static bool hasVertexShape(const std::shared_ptr& thePrs, FeaturePtr theSketch, Handle_V3d_View theView, double& theX, double& theY); diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index 4bf822bfd..925856843 100755 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -39,12 +39,12 @@ int shapesNbPoints(const ModuleBase_ISelection* theSelection) { - QList aList = theSelection->getSelected(ModuleBase_ISelection::Viewer); + QList aList = theSelection->getSelected(ModuleBase_ISelection::Viewer); ModuleBase_ISelection::filterSelectionOnEqualPoints(aList); int aCount = 0; - foreach (ModuleBase_ViewerPrs aPrs, aList) { - const GeomShapePtr& aShape = aPrs.shape(); + foreach (ModuleBase_ViewerPrsPtr aPrs, aList) { + const GeomShapePtr& aShape = aPrs->shape(); if (aShape.get() && !aShape->isNull()) { if (aShape->shapeType() == GeomAPI_Shape::VERTEX) aCount++; @@ -55,10 +55,10 @@ int shapesNbPoints(const ModuleBase_ISelection* theSelection) int shapesNbLines(const ModuleBase_ISelection* theSelection) { - QList aList = theSelection->getSelected(ModuleBase_ISelection::Viewer); + QList aList = theSelection->getSelected(ModuleBase_ISelection::Viewer); int aCount = 0; - foreach(ModuleBase_ViewerPrs aPrs, aList) { - const GeomShapePtr& aShape = aPrs.shape(); + foreach(ModuleBase_ViewerPrsPtr aPrs, aList) { + const GeomShapePtr& aShape = aPrs->shape(); if (aShape.get() && !aShape->isNull()) { if (aShape->shapeType() == GeomAPI_Shape::EDGE) { const TopoDS_Shape& aTDShape = aShape->impl(); @@ -156,11 +156,10 @@ bool PartSet_RadiusSelection::isValid(const ModuleBase_ISelection* theSelection, if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) { return isEmptySelectionValid(theOperation); } else { - QList aList = theSelection->getSelected(ModuleBase_ISelection::Viewer); - ModuleBase_ViewerPrs aPrs; + QList aList = theSelection->getSelected(ModuleBase_ISelection::Viewer); int aCount = 0; - foreach (ModuleBase_ViewerPrs aPrs, aList) { - const GeomShapePtr& aShape = aPrs.shape(); + foreach (ModuleBase_ViewerPrsPtr aPrs, aList) { + const GeomShapePtr& aShape = aPrs->shape(); if (aShape.get() && !aShape->isNull()) { if (aShape->shapeType() == GeomAPI_Shape::EDGE) { const TopoDS_Shape& aTDShape = aShape->impl(); @@ -182,7 +181,7 @@ bool PartSet_RigidSelection::isValid(const ModuleBase_ISelection* theSelection, if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) { return isEmptySelectionValid(theOperation); } else { - QList aList = theSelection->getSelected(ModuleBase_ISelection::Viewer); + QList aList = theSelection->getSelected(ModuleBase_ISelection::Viewer); return (aList.count() == 1); } } @@ -225,12 +224,12 @@ bool PartSet_TangentSelection::isValid(const ModuleBase_ISelection* theSelection if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) { return isEmptySelectionValid(theOperation); } else { - QList aList = theSelection->getSelected(ModuleBase_ISelection::Viewer); + QList aList = theSelection->getSelected(ModuleBase_ISelection::Viewer); if ((aList.size() == 0) || (aList.size() > 2)) return false; - ModuleBase_ViewerPrs aPrs = aList.first(); - const GeomShapePtr& aShape = aPrs.shape(); + ModuleBase_ViewerPrsPtr aPrs = aList.first(); + const GeomShapePtr& aShape = aPrs->shape(); if (!aShape.get() || aShape->isNull() || aShape->shapeType() != GeomAPI_Shape::EDGE) return false; GeomAPI_Edge aEdge1(aShape); @@ -239,7 +238,7 @@ bool PartSet_TangentSelection::isValid(const ModuleBase_ISelection* theSelection if (aList.size() == 2) { // Check second selection aPrs = aList.last(); - const GeomShapePtr& aShape2 = aPrs.shape(); + const GeomShapePtr& aShape2 = aPrs->shape(); if (!aShape2.get() || aShape2->isNull() || aShape2->shapeType() != GeomAPI_Shape::EDGE) return false; GeomAPI_Edge aEdge2(aShape2); @@ -272,12 +271,11 @@ bool PartSet_EqualSelection::isValid(const ModuleBase_ISelection* theSelection, if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) { return isEmptySelectionValid(theOperation); } else { - QList aList = theSelection->getSelected(ModuleBase_ISelection::Viewer); - ModuleBase_ViewerPrs aPrs; + QList aList = theSelection->getSelected(ModuleBase_ISelection::Viewer); int aCount = 0; int aType = 0; - foreach (ModuleBase_ViewerPrs aPrs, aList) { - GeomShapePtr aShape = aPrs.shape(); + foreach (ModuleBase_ViewerPrsPtr aPrs, aList) { + GeomShapePtr aShape = aPrs->shape(); if (aShape.get() && aShape->isEdge()) { aCount++; GeomAPI_Edge aEdge(aShape); diff --git a/src/PartSet/PartSet_WidgetMultiSelector.cpp b/src/PartSet/PartSet_WidgetMultiSelector.cpp index 380c7da3b..f3e429361 100755 --- a/src/PartSet/PartSet_WidgetMultiSelector.cpp +++ b/src/PartSet/PartSet_WidgetMultiSelector.cpp @@ -43,7 +43,7 @@ PartSet_WidgetMultiSelector::~PartSet_WidgetMultiSelector() } //******************************************************************** -bool PartSet_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs) +bool PartSet_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs) { bool aValid = ModuleBase_WidgetMultiSelector::isValidSelectionCustom(thePrs); if (aValid) { @@ -62,7 +62,7 @@ void PartSet_WidgetMultiSelector::restoreAttributeValue(const AttributePtr& theA myExternalObjectMgr->removeExternal(sketch(), myFeature, myWorkshop, true); } -void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrs& thePrs, +void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrsPtr& thePrs, ObjectPtr& theObject, GeomShapePtr& theShape) { diff --git a/src/PartSet/PartSet_WidgetMultiSelector.h b/src/PartSet/PartSet_WidgetMultiSelector.h index 150f4c6fd..d3d367119 100644 --- a/src/PartSet/PartSet_WidgetMultiSelector.h +++ b/src/PartSet/PartSet_WidgetMultiSelector.h @@ -49,7 +49,7 @@ protected: /// Checks the widget validity. By default, it returns true. /// \param thePrs a selected presentation in the view /// \return a boolean value - virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs); + virtual bool isValidSelectionCustom(const std::shared_ptr& thePrs); /// Creates a backup of the current values of the attribute /// It should be realized in the specific widget because of different @@ -61,7 +61,7 @@ protected: /// \param thePrs a selection /// \param theObject an output object /// \param theShape a shape of the selection - virtual void getGeomSelection(const ModuleBase_ViewerPrs& thePrs, + virtual void getGeomSelection(const std::shared_ptr& thePrs, ObjectPtr& theObject, GeomShapePtr& theShape); diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 11f698ad1..f5e9903da 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -147,15 +147,15 @@ PartSet_WidgetPoint2D::~PartSet_WidgetPoint2D() { } -bool PartSet_WidgetPoint2D::setSelection(QList& theValues, +bool PartSet_WidgetPoint2D::setSelection(QList& theValues, const bool theToValidate) { bool isDone = false; if (theValues.empty()) return isDone; - ModuleBase_ViewerPrs aValue = theValues.takeFirst(); - GeomShapePtr aShape = aValue.shape(); + ModuleBase_ViewerPrsPtr aValue = theValues.takeFirst(); + GeomShapePtr aShape = aValue->shape(); if (aShape.get() && !aShape->isNull()) { Handle(V3d_View) aView = myWorkshop->viewer()->activeView(); double aX, aY; @@ -167,7 +167,7 @@ bool PartSet_WidgetPoint2D::setSelection(QList& theValues, } else if (canBeActivatedByMove()) { if (feature()->getKind() == SketchPlugin_Line::ID()) { - FeaturePtr aFeature = std::dynamic_pointer_cast(aValue.object()); + FeaturePtr aFeature = std::dynamic_pointer_cast(aValue->object()); // Initialize new line with first point equal to end of previous if (aFeature.get()) { std::shared_ptr aData = aFeature->data(); diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index 711e37c1c..c685c5ca0 100755 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -51,7 +51,7 @@ Q_OBJECT /// This value should be processed in the widget according to the needs /// \param theValues the wrapped widget values /// \param theToValidate a validation flag - virtual bool setSelection(QList& theValues, + virtual bool setSelection(QList>& theValues, const bool theToValidate); /// Select the internal content if it can be selected. It is empty in the default realization diff --git a/src/PartSet/PartSet_WidgetShapeSelector.cpp b/src/PartSet/PartSet_WidgetShapeSelector.cpp index 499951c4a..c291eb0ff 100755 --- a/src/PartSet/PartSet_WidgetShapeSelector.cpp +++ b/src/PartSet/PartSet_WidgetShapeSelector.cpp @@ -55,7 +55,7 @@ bool PartSet_WidgetShapeSelector::activateSelectionAndFilters(bool toActivate) } //******************************************************************** -bool PartSet_WidgetShapeSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs) +bool PartSet_WidgetShapeSelector::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs) { bool aValid = ModuleBase_WidgetShapeSelector::isValidSelectionCustom(thePrs); if (aValid) { @@ -65,7 +65,7 @@ bool PartSet_WidgetShapeSelector::isValidSelectionCustom(const ModuleBase_Viewer return aValid; } -void PartSet_WidgetShapeSelector::getGeomSelection(const ModuleBase_ViewerPrs& thePrs, +void PartSet_WidgetShapeSelector::getGeomSelection(const ModuleBase_ViewerPrsPtr& thePrs, ObjectPtr& theObject, GeomShapePtr& theShape) { diff --git a/src/PartSet/PartSet_WidgetShapeSelector.h b/src/PartSet/PartSet_WidgetShapeSelector.h index cb5a425ad..9f8c44da6 100644 --- a/src/PartSet/PartSet_WidgetShapeSelector.h +++ b/src/PartSet/PartSet_WidgetShapeSelector.h @@ -49,13 +49,13 @@ protected: /// Checks the widget validity. By default, it returns true. /// \param thePrs a selected presentation in the view /// \return a boolean value - virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs); + virtual bool isValidSelectionCustom(const std::shared_ptr& thePrs); /// Return an object and geom shape by the viewer presentation /// \param thePrs a selection /// \param theObject an output object /// \param theShape a shape of the selection - virtual void getGeomSelection(const ModuleBase_ViewerPrs& thePrs, + virtual void getGeomSelection(const std::shared_ptr& thePrs, ObjectPtr& theObject, GeomShapePtr& theShape); diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index 1f00cc5a1..91d36980b 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -125,7 +125,7 @@ void PartSet_WidgetSketchCreator::openExtrusionTransaction() } //******************************************************************** -bool PartSet_WidgetSketchCreator::isValidSelection(const ModuleBase_ViewerPrs& theValue) +bool PartSet_WidgetSketchCreator::isValidSelection(const ModuleBase_ViewerPrsPtr& theValue) { bool aValid = false; if (myIsCustomAttribute) { @@ -155,7 +155,7 @@ bool PartSet_WidgetSketchCreator::isValidSelection(const ModuleBase_ViewerPrs& t } //******************************************************************** -bool PartSet_WidgetSketchCreator::isValidSelectionCustom(const ModuleBase_ViewerPrs& theValue) +bool PartSet_WidgetSketchCreator::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& theValue) { return PartSet_WidgetSketchLabel::canFillSketch(theValue); } @@ -254,16 +254,16 @@ bool PartSet_WidgetSketchCreator::hasSubObjects() const return aHasSubObjects; } -bool PartSet_WidgetSketchCreator::setSelection(QList& theValues, +bool PartSet_WidgetSketchCreator::setSelection(QList& theValues, const bool theToValidate) { bool aDone = false; if (!startSketchOperation(theValues)) { myIsCustomAttribute = true; - QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); + QList::const_iterator anIt = theValues.begin(), aLast = theValues.end(); bool aProcessed = false; for (; anIt != aLast; anIt++) { - ModuleBase_ViewerPrs aValue = *anIt; + ModuleBase_ViewerPrsPtr aValue = *anIt; if (!theToValidate || isValidInFilters(aValue)) aProcessed = setSelectionCustom(aValue) || aProcessed; } @@ -284,7 +284,7 @@ bool PartSet_WidgetSketchCreator::setSelection(QList& theV //******************************************************************** void PartSet_WidgetSketchCreator::onSelectionChanged() { - QList aSelected = getFilteredSelected(); + QList aSelected = getFilteredSelected(); bool isDone = setSelection(aSelected, true/*false*/); } @@ -293,14 +293,14 @@ void PartSet_WidgetSketchCreator::updateOnSelectionChanged(const bool theDone) { } -bool PartSet_WidgetSketchCreator::startSketchOperation(const QList& theValues) +bool PartSet_WidgetSketchCreator::startSketchOperation(const QList& theValues) { bool aSketchStarted = false; if (theValues.size() != 1) return aSketchStarted; - ModuleBase_ViewerPrs aValue = theValues.front(); + ModuleBase_ViewerPrsPtr aValue = theValues.front(); if (!PartSet_WidgetSketchLabel::canFillSketch(aValue)) return aSketchStarted; @@ -318,7 +318,7 @@ bool PartSet_WidgetSketchCreator::startSketchOperation(const QList (myModule->createOperation("Sketch")); - QList aValues; + QList aValues; aValues.push_back(aValue); aFOperation->setPreselection(aValues); diff --git a/src/PartSet/PartSet_WidgetSketchCreator.h b/src/PartSet/PartSet_WidgetSketchCreator.h index d94e0d6d9..22d58f750 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.h +++ b/src/PartSet/PartSet_WidgetSketchCreator.h @@ -55,7 +55,7 @@ public: /// This value should be processed in the widget according to the needs /// \param theValues the wrapped selection values /// \param theToValidate a validation of the values flag - virtual bool setSelection(QList& theValues, + virtual bool setSelection(QList>& theValues, const bool theToValidate); /// Editing mode depends on mode of current operation. This value is defined by it. @@ -67,7 +67,7 @@ public: /// restored.The valid/invalid value is cashed. /// \param theValue a selected presentation in the view /// \return a boolean value - virtual bool isValidSelection(const ModuleBase_ViewerPrs& theValue); + virtual bool isValidSelection(const std::shared_ptr& theValue); protected: /// If there is no operation in current session, start operation for modify parameters @@ -77,7 +77,7 @@ protected: /// Checks whether the selection presentation contains preview planes /// \param theValue a selection information /// \return a boolean value - virtual bool isValidSelectionCustom(const ModuleBase_ViewerPrs& theValue); + virtual bool isValidSelectionCustom(const std::shared_ptr& theValue); /// Saves the internal parameters to the given feature /// \return True in success @@ -127,7 +127,7 @@ private: /// Append new Sketch, set the selected plane for the sketch and start Edit operation. /// \param theValues a selection list /// \return true if the sketch is started - bool startSketchOperation(const QList& theValues); + bool startSketchOperation(const QList>& theValues); /// Sets the sub-object to list of base. static void setSketchObjectToList(const CompositeFeaturePtr& theFeature, diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 2524a9ba7..74a7ee5e3 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -132,7 +132,7 @@ PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel() { } -bool PartSet_WidgetSketchLabel::setSelection(QList& theValues, +bool PartSet_WidgetSketchLabel::setSelection(QList& theValues, const bool theToValidate) { // do not use the given selection if the plane of the sketch has been already set. @@ -141,7 +141,7 @@ bool PartSet_WidgetSketchLabel::setSelection(QList& theVal if (plane().get()) return true; - ModuleBase_ViewerPrs aPrs = theValues.first(); + ModuleBase_ViewerPrsPtr aPrs = theValues.first(); bool aDone = setSelectionInternal(theValues, theToValidate); if (aDone) updateByPlaneSelected(aPrs); @@ -157,11 +157,11 @@ QList PartSet_WidgetSketchLabel::getControls() const void PartSet_WidgetSketchLabel::onSelectionChanged() { - QList aSelected = getFilteredSelected(); + QList aSelected = getFilteredSelected(); if (aSelected.empty()) return; - ModuleBase_ViewerPrs aPrs = aSelected.first(); + ModuleBase_ViewerPrsPtr aPrs = aSelected.first(); bool aDone = setSelectionInternal(aSelected, false); if (aDone) { updateByPlaneSelected(aPrs); @@ -209,19 +209,19 @@ void PartSet_WidgetSketchLabel::blockAttribute(const AttributePtr& theAttribute, } } -bool PartSet_WidgetSketchLabel::setSelectionInternal(const QList& theValues, +bool PartSet_WidgetSketchLabel::setSelectionInternal(const QList& theValues, const bool theToValidate) { bool aDone = false; - ModuleBase_ViewerPrs aValue; if (theValues.empty()) { // In order to make reselection possible, set empty object and shape should be done - setSelectionCustom(ModuleBase_ViewerPrs()); + setSelectionCustom(std::shared_ptr( + new ModuleBase_ViewerPrs(ObjectPtr(), GeomShapePtr(), NULL))); aDone = false; } else { // it removes the processed value from the parameters list - aValue = theValues.first();//.takeFirst(); + ModuleBase_ViewerPrsPtr aValue = theValues.first();//.takeFirst(); if (!theToValidate || isValidInFilters(aValue)) aDone = setSelectionCustom(aValue); } @@ -229,12 +229,12 @@ bool PartSet_WidgetSketchLabel::setSelectionInternal(const QListerasePreviewPlanes(myWorkshop); // 2. if the planes were displayed, change the view projection - const GeomShapePtr& aShape = thePrs.shape(); + const GeomShapePtr& aShape = thePrs->shape(); std::shared_ptr aGShape; std::shared_ptr aBaseShape; @@ -340,16 +340,16 @@ void PartSet_WidgetSketchLabel::restoreAttributeValue(const AttributePtr& theAtt } } -bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) +bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs) { return fillSketchPlaneBySelection(feature(), thePrs); } -bool PartSet_WidgetSketchLabel::canFillSketch(const ModuleBase_ViewerPrs& thePrs) +bool PartSet_WidgetSketchLabel::canFillSketch(const ModuleBase_ViewerPrsPtr& thePrs) { bool aCanFillSketch = true; // avoid any selection on sketch object - ObjectPtr anObject = thePrs.object(); + ObjectPtr anObject = thePrs->object(); ResultPtr aResult = std::dynamic_pointer_cast(anObject); if (aResult.get()) { FeaturePtr aFeature = ModelAPI_Feature::feature(aResult); @@ -360,7 +360,7 @@ bool PartSet_WidgetSketchLabel::canFillSketch(const ModuleBase_ViewerPrs& thePrs if (aCanFillSketch) { std::shared_ptr aGeomFace; - GeomShapePtr aGeomShape = thePrs.shape(); + GeomShapePtr aGeomShape = thePrs->shape(); if ((!aGeomShape.get() || aGeomShape->isNull()) && aResult.get()) { aGeomShape = aResult->shape(); } @@ -376,20 +376,20 @@ bool PartSet_WidgetSketchLabel::canFillSketch(const ModuleBase_ViewerPrs& thePrs } bool PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(const FeaturePtr& theFeature, - const ModuleBase_ViewerPrs& thePrs) + const ModuleBase_ViewerPrsPtr& thePrs) { bool isOwnerSet = false; - const GeomShapePtr& aShape = thePrs.shape(); + const GeomShapePtr& aShape = thePrs->shape(); std::shared_ptr aDir; - if (thePrs.object() && (theFeature != thePrs.object())) { + if (thePrs->object() && (theFeature != thePrs->object())) { DataPtr aData = theFeature->data(); AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); if (aSelAttr) { - ResultPtr aRes = std::dynamic_pointer_cast(thePrs.object()); + ResultPtr aRes = std::dynamic_pointer_cast(thePrs->object()); if (aRes) { GeomShapePtr aShapePtr(new GeomAPI_Shape()); if (!aShape.get() || aShape->isNull()) { // selection happens in the OCC viewer diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index e962135ef..30efc49ec 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -55,7 +55,7 @@ public: /// It is redefined to do nothing if the plane of the sketch has been already set. /// \param theValues the wrapped selection values /// \param theToValidate a validation flag - virtual bool setSelection(QList& theValues, + virtual bool setSelection(QList>& theValues, const bool theToValidate); /// Returns list of widget controls @@ -73,10 +73,10 @@ public: virtual void setHighlighted(bool) { /*do nothing*/ }; virtual void enableFocusProcessing(); - static bool canFillSketch(const ModuleBase_ViewerPrs& thePrs); + static bool canFillSketch(const std::shared_ptr& thePrs); static bool fillSketchPlaneBySelection(const FeaturePtr& theFeature, - const ModuleBase_ViewerPrs& thePrs); + const std::shared_ptr& thePrs); signals: /// Signal on plane selection @@ -104,7 +104,7 @@ protected: /// Fills the attribute with the value of the selected owner /// \param thePrs a selected owner - virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs); + virtual bool setSelectionCustom(const std::shared_ptr& thePrs); /// Saves the internal parameters to the given feature /// \return True in success @@ -139,12 +139,12 @@ protected: /// It is redefined to do nothing if the plane of the sketch has been already set. /// \param theValues the wrapped selection values /// \param theToValidate a validation flag - bool setSelectionInternal(const QList& theValues, + bool setSelectionInternal(const QList>& theValues, const bool theToValidate); /// Erase preview planes, disconnect widget, change the view projection /// \param thePrs a selected presentation - void updateByPlaneSelected(const ModuleBase_ViewerPrs& thePrs); + void updateByPlaneSelected(const std::shared_ptr& thePrs); protected: /// Activate or deactivate selection diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 9c81a942c..6122c232f 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -308,14 +308,14 @@ void XGUI_ContextMenuMgr::updateViewerMenu() XGUI_SelectionMgr* aSelMgr = myWorkshop->selector(); XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - QList aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer); + QList aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer); if (aPrsList.size() > 0) { bool isVisible = false; bool isShading = false; bool canBeShaded = false; ObjectPtr aObject; - foreach(ModuleBase_ViewerPrs aPrs, aPrsList) { - aObject = aPrs.object(); + foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) { + aObject = aPrs->object(); ResultPtr aRes = std::dynamic_pointer_cast(aObject); if (aRes && aRes->isDisplayed()) { isVisible = true; @@ -510,7 +510,7 @@ void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const theMenu->addSeparator(); } XGUI_SelectionMgr* aSelMgr = myWorkshop->selector(); - QList aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer); + QList aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer); int aSelected = aPrsList.size(); QActionsList aActions; @@ -528,7 +528,7 @@ void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const theMenu->addSeparator(); } if (aSelected == 1) { - ObjectPtr aObject = aPrsList.first().object(); + ObjectPtr aObject = aPrsList.first()->object(); if (aObject.get() != NULL) { std::string aName = aObject->groupName(); if (myViewerMenu.contains(aName)) diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 20e4c300c..bfb5ce29f 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -541,7 +541,7 @@ bool XGUI_Displayer::isActive(ObjectPtr theObject) const aContext->ActivatedModes(anAIS, aModes); return aModes.Extent() > 0; } -void XGUI_Displayer::setSelected(const QList& theValues, bool theUpdateViewer) +void XGUI_Displayer::setSelected(const QList& theValues, bool theUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); if (aContext.IsNull()) @@ -549,13 +549,13 @@ void XGUI_Displayer::setSelected(const QList& theValues, if (aContext->HasOpenedContext()) { aContext->UnhilightSelected(false); aContext->ClearSelected(false); - foreach (ModuleBase_ViewerPrs aPrs, theValues) { - const GeomShapePtr& aGeomShape = aPrs.shape(); + foreach (ModuleBase_ViewerPrsPtr aPrs, theValues) { + const GeomShapePtr& aGeomShape = aPrs->shape(); if (aGeomShape.get() && !aGeomShape->isNull()) { const TopoDS_Shape& aShape = aGeomShape->impl(); aContext->AddOrRemoveSelected(aShape, false); } else { - ObjectPtr anObject = aPrs.object(); + ObjectPtr anObject = aPrs->object(); ResultPtr aResult = std::dynamic_pointer_cast(anObject); if (aResult.get() && isVisible(aResult)) { AISObjectPtr anObj = myResult2AISObjectMap[aResult]; @@ -574,8 +574,8 @@ void XGUI_Displayer::setSelected(const QList& theValues, } else { aContext->UnhilightCurrents(false); aContext->ClearCurrents(false); - foreach (ModuleBase_ViewerPrs aPrs, theValues) { - ObjectPtr anObject = aPrs.object(); + foreach (ModuleBase_ViewerPrsPtr aPrs, theValues) { + ObjectPtr anObject = aPrs->object(); ResultPtr aResult = std::dynamic_pointer_cast(anObject); if (aResult.get() && isVisible(aResult)) { AISObjectPtr anObj = myResult2AISObjectMap[aResult]; diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 489508c2c..0ef3285f8 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -92,7 +92,7 @@ class XGUI_EXPORT XGUI_Displayer: public QObject /// empty, select it, otherwise select the result. /// \param theValues a list of presentation to be selected /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly - void setSelected(const QList& theValues, bool theUpdateViewer = true); + void setSelected(const QList>& theValues, bool theUpdateViewer = true); /// Unselect all objects void clearSelected(); diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index cf8ec1f37..f3e569bba 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -101,7 +101,7 @@ ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS) return anObject; } -void XGUI_ModuleConnector::setSelected(const QList& theValues) +void XGUI_ModuleConnector::setSelected(const QList& theValues) { XGUI_Displayer* aDisp = myWorkshop->displayer(); if (theValues.isEmpty()) { diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h index 4b2ed19f4..58afc0aa2 100644 --- a/src/XGUI/XGUI_ModuleConnector.h +++ b/src/XGUI/XGUI_ModuleConnector.h @@ -79,7 +79,7 @@ Q_OBJECT //! Select features clearing previous selection. //! If the list is empty then selection will be cleared - virtual void setSelected(const QList& theValues); + virtual void setSelected(const QList>& theValues); /// Update of commands status virtual void updateCommandStatus(); diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp index 27fbd63de..6e9a0abc9 100644 --- a/src/XGUI/XGUI_Selection.cpp +++ b/src/XGUI/XGUI_Selection.cpp @@ -37,9 +37,9 @@ XGUI_Selection::XGUI_Selection(XGUI_Workshop* theWorkshop) { } -QList XGUI_Selection::getSelected(const SelectionPlace& thePlace) const +QList XGUI_Selection::getSelected(const SelectionPlace& thePlace) const { - QList aPresentations; + QList aPresentations; switch (thePlace) { case Browser: @@ -56,17 +56,17 @@ QList XGUI_Selection::getSelected(const SelectionPlace& th return aPresentations; } -Handle(AIS_InteractiveObject) XGUI_Selection::getIO(const ModuleBase_ViewerPrs& thePrs) +Handle(AIS_InteractiveObject) XGUI_Selection::getIO(const ModuleBase_ViewerPrsPtr& thePrs) { - Handle(AIS_InteractiveObject) anIO = thePrs.interactive(); + Handle(AIS_InteractiveObject) anIO = thePrs->interactive(); if (anIO.IsNull()) { - Handle(SelectMgr_EntityOwner) anOwner = thePrs.owner(); + Handle(SelectMgr_EntityOwner) anOwner = thePrs->owner(); if (!anOwner.IsNull()) anIO = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable()); - if (anIO.IsNull() && thePrs.object()) { + if (anIO.IsNull() && thePrs->object()) { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - AISObjectPtr anAISObject = aDisplayer->getAISObject(thePrs.object()); + AISObjectPtr anAISObject = aDisplayer->getAISObject(thePrs->object()); if (anAISObject.get()) anIO = anAISObject->impl(); } @@ -74,13 +74,13 @@ Handle(AIS_InteractiveObject) XGUI_Selection::getIO(const ModuleBase_ViewerPrs& return anIO; } -void XGUI_Selection::getSelectedInViewer(QList& thePresentations) const +void XGUI_Selection::getSelectedInViewer(QList& thePresentations) const { Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); if (!aContext.IsNull() && aContext->HasOpenedContext()) { QList aSelectedIds; // Remember of selected address in order to avoid duplicates for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { - ModuleBase_ViewerPrs aPrs; + ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs()); Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner(); if (aSelectedIds.contains((long)anOwner.Access())) @@ -95,14 +95,14 @@ void XGUI_Selection::getSelectedInViewer(QList& thePresent } } -void XGUI_Selection::getSelectedInBrowser(QList& thePresentations) const +void XGUI_Selection::getSelectedInBrowser(QList& thePresentations) const { // collect the objects of the parameter presentation to avoid a repeted objects in the result QObjectPtrList aPresentationObjects; - QList::const_iterator aPrsIt = thePresentations.begin(), + QList::const_iterator aPrsIt = thePresentations.begin(), aPrsLast = thePresentations.end(); for (; aPrsIt != aPrsLast; aPrsIt++) { - aPresentationObjects.push_back((*aPrsIt).object()); + aPresentationObjects.push_back((*aPrsIt)->object()); } QObjectPtrList anObjects = selectedObjects(); @@ -110,19 +110,20 @@ void XGUI_Selection::getSelectedInBrowser(QList& thePresen for (; anIt != aLast; anIt++) { ObjectPtr anObject = *anIt; if (anObject.get() != NULL && !aPresentationObjects.contains(anObject)) { - thePresentations.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL)); + thePresentations.append(std::shared_ptr( + new ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL))); } } } -void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrs& thePrs, +void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrsPtr& thePrs, const Handle(SelectMgr_EntityOwner)& theOwner) const { - thePrs.setOwner(theOwner); + thePrs->setOwner(theOwner); Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable()); - thePrs.setInteractive(anIO); + thePrs->setInteractive(anIO); // we should not check the appearance of this feature because there can be some selected shapes // for one feature @@ -138,7 +139,7 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrs& thePrs, if (!aShape.IsNull()) { std::shared_ptr aGeomShape = std::shared_ptr(new GeomAPI_Shape()); aGeomShape->setImpl(new TopoDS_Shape(aShape)); - thePrs.setShape(aGeomShape); + thePrs->setShape(aGeomShape); } } else { #ifdef DEBUG_DELIVERY @@ -156,7 +157,7 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrs& thePrs, if (!aEdge.IsNull()) { std::shared_ptr aGeomShape = std::shared_ptr(new GeomAPI_Shape()); aGeomShape->setImpl(new TopoDS_Shape(aEdge)); - thePrs.setShape(aGeomShape); + thePrs->setShape(aGeomShape); } } else { Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast(anIO); @@ -169,7 +170,7 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrs& thePrs, if (!aVertex.IsNull()) { std::shared_ptr aGeomShape = std::shared_ptr(new GeomAPI_Shape()); aGeomShape->setImpl(new TopoDS_Shape(aVertex)); - thePrs.setShape(aGeomShape); + thePrs->setShape(aGeomShape); } } } @@ -188,19 +189,19 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrs& thePrs, ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(aResult); if (aCompSolid.get()) { GeomShapePtr aShape = aCompSolid->shape(); - if (aShape.get() && aShape->isEqual(thePrs.shape())) { - thePrs.setObject(aCompSolid); + if (aShape.get() && aShape->isEqual(thePrs->shape())) { + thePrs->setObject(aCompSolid); return; } } } } - thePrs.setObject(aFeature); + thePrs->setObject(aFeature); } -QList XGUI_Selection::getHighlighted() const +QList XGUI_Selection::getHighlighted() const { - QList aPresentations; + QList aPresentations; Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); if (aContext.IsNull()) return aPresentations; @@ -208,24 +209,24 @@ QList XGUI_Selection::getHighlighted() const QList aSelectedIds; // Remember of selected address in order to avoid duplicates XGUI_Displayer* aDisplayer = myWorkshop->displayer(); for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) { - ModuleBase_ViewerPrs aPrs; + ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs()); Handle(AIS_InteractiveObject) anIO = aContext->DetectedInteractive(); if (aSelectedIds.contains((long)anIO.Access())) continue; aSelectedIds.append((long)anIO.Access()); - aPrs.setInteractive(anIO); + aPrs->setInteractive(anIO); ObjectPtr aResult = aDisplayer->getObject(anIO); // we should not check the appearance of this feature because there can be some selected shapes // for one feature - aPrs.setObject(aResult); + aPrs->setObject(aResult); if (aContext->HasOpenedContext()) { TopoDS_Shape aShape = aContext->DetectedShape(); if (!aShape.IsNull()) { std::shared_ptr aGeomShape = std::shared_ptr(new GeomAPI_Shape()); aGeomShape->setImpl(new TopoDS_Shape(aShape)); - aPrs.setShape(aGeomShape); + aPrs->setShape(aGeomShape); } } aPresentations.push_back(aPrs); diff --git a/src/XGUI/XGUI_Selection.h b/src/XGUI/XGUI_Selection.h index d81ef7eda..f1de36228 100644 --- a/src/XGUI/XGUI_Selection.h +++ b/src/XGUI/XGUI_Selection.h @@ -36,17 +36,17 @@ class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection /// Returns a list of viewer selected presentations /// \return list of presentations - virtual QList getSelected(const SelectionPlace& thePlace = Browser) const; + virtual QList> getSelected(const SelectionPlace& thePlace = Browser) const; /// Fills the viewer presentation parameters by the parameters from the owner /// \param thePrs a container for selection /// \param theOwner a selection owner - virtual void fillPresentation(ModuleBase_ViewerPrs& thePrs, + virtual void fillPresentation(std::shared_ptr& thePrs, const Handle_SelectMgr_EntityOwner& theOwner) const; /// Returns a list of viewer highlited presentations /// \return list of presentations - virtual QList getHighlighted() const; + virtual QList> getHighlighted() const; /** * Returns list of currently selected objects in object browser @@ -93,18 +93,18 @@ class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection //! Return the IO from the viewer presentation. //! \param thePrs a selected object //! \return an interactive object - virtual Handle(AIS_InteractiveObject) getIO(const ModuleBase_ViewerPrs& thePrs); + virtual Handle(AIS_InteractiveObject) getIO(const std::shared_ptr& thePrs); protected: /// Fills the list of presentations by objects selected in the viewer. /// \param thePresentations an output list of presentation - void getSelectedInViewer(QList& thePresentations) const; + void getSelectedInViewer(QList>& thePresentations) const; /// Fills the list of presentations by objects selected in the object browser. /// ViewerPrs contains only object parameter not empty. /// If the given list of presentations already has a viewer presentation with the same object /// as selected in the browser, a new item is not appended to the list of presentations. /// \param thePresentations an output list of presentation - void getSelectedInBrowser(QList& thePresentations) const; + void getSelectedInBrowser(QList>& thePresentations) const; /// Generates a vertex or edge by the give IO if it is an AIS created on trihedron /// \param theIO a selected object diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp old mode 100644 new mode 100755 index fd7729f03..75ac12685 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -93,21 +93,22 @@ void XGUI_SelectionMgr::updateSelectedOwners(bool isUpdateViewer) //************************************************************** void XGUI_SelectionMgr::onObjectBrowserSelection() { - QList aSelectedPrs = + QList aSelectedPrs = myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::Browser); - QList aTmpList = aSelectedPrs; + QList aTmpList = aSelectedPrs; ObjectPtr aObject; FeaturePtr aFeature; - foreach(ModuleBase_ViewerPrs aPrs, aTmpList) { - aObject = aPrs.object(); + foreach(ModuleBase_ViewerPrsPtr aPrs, aTmpList) { + aObject = aPrs->object(); if (aObject.get()) { aFeature = std::dynamic_pointer_cast(aObject); if (aFeature.get()) { const std::list> aResList = aFeature->results(); std::list::const_iterator aIt; for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) { - aSelectedPrs.append(ModuleBase_ViewerPrs((*aIt), GeomShapePtr(), NULL)); + aSelectedPrs.append(std::shared_ptr( + new ModuleBase_ViewerPrs((*aIt), GeomShapePtr(), NULL))); } } } @@ -127,8 +128,8 @@ void XGUI_SelectionMgr::onViewerSelection() FeaturePtr aFeature; Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); if (!aContext.IsNull()) { - QList aPresentations = selection()->getSelected(ModuleBase_ISelection::Viewer); - foreach(ModuleBase_ViewerPrs aPrs, aPresentations) { + QList aPresentations = selection()->getSelected(ModuleBase_ISelection::Viewer); + foreach(ModuleBase_ViewerPrsPtr aPrs, aPresentations) { if (aPrs.object().get()) { aFeatures.append(aPrs.object()); if (aPrs.shape().get()) { @@ -152,7 +153,7 @@ void XGUI_SelectionMgr::onViewerSelection() //************************************************************** void XGUI_SelectionMgr::updateSelectionBy(const ModuleBase_ISelection::SelectionPlace& thePlace) { - QList aSelectedPrs = + QList aSelectedPrs = myWorkshop->selector()->selection()->getSelected(thePlace); if (thePlace == ModuleBase_ISelection::Browser) { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); @@ -168,7 +169,7 @@ void XGUI_SelectionMgr::clearSelection() myWorkshop->objectBrowser()->setObjectsSelected(aFeatures); myWorkshop->objectBrowser()->blockSignals(aBlocked); - QList aSelectedPrs = + QList aSelectedPrs = myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::Browser); XGUI_Displayer* aDisplayer = myWorkshop->displayer();