From: vsv Date: Mon, 14 Jul 2014 06:49:40 +0000 (+0400) Subject: Adaptation to new Model architecture X-Git-Tag: V_0.4.4~197 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=141af0409801857d641e2bf61cd414b373e65b0b;p=modules%2Fshaper.git Adaptation to new Model architecture --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 241ac68c4..fb8e67a06 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -483,7 +483,7 @@ ObjectPtr Model_Document::object(const string& theGroupID, const int theIndex) boost::dynamic_pointer_cast(*aFIter)->results(); list >::const_iterator aRIter = aResults.begin(); for(; aRIter != aResults.cend(); aRIter++) { - if ((*aRIter)->isInHistory() && (*aRIter)->group() == theGroupID) { + if ((*aRIter)->isInHistory() && (*aRIter)->groupName() == theGroupID) { if (anIndex == theIndex) return *aRIter; anIndex++; @@ -514,7 +514,7 @@ int Model_Document::size(const string& theGroupID) boost::dynamic_pointer_cast(*aFIter)->results(); list >::const_iterator aRIter = aResults.begin(); for(; aRIter != aResults.cend(); aRIter++) { - if ((*aRIter)->isInHistory() && (*aRIter)->group() == theGroupID) { + if ((*aRIter)->isInHistory() && (*aRIter)->groupName() == theGroupID) { aResult++; } } diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 80ec6cd74..78d9901e6 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -24,6 +24,7 @@ SET(PROJECT_HEADERS ModelAPI_ResultBody.h ModelAPI_ResultConstruction.h ModelAPI_ResultPart.h + ModelAPI_ResultParameters.h ) SET(PROJECT_SOURCES diff --git a/src/ModelAPI/ModelAPI_Result.h b/src/ModelAPI/ModelAPI_Result.h index b84cd0b20..01fa9dde9 100644 --- a/src/ModelAPI/ModelAPI_Result.h +++ b/src/ModelAPI/ModelAPI_Result.h @@ -22,7 +22,7 @@ public: //virtual boost::shared_ptr owner() = 0; /// Returns the group identifier of this result - virtual std::string group() = 0; + virtual std::string groupName() = 0; }; //! Pointer on feature object diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h index 336e6ccd4..09ce4d6b0 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.h +++ b/src/ModelAPI/ModelAPI_ResultBody.h @@ -20,7 +20,11 @@ class ModelAPI_ResultBody : public ModelAPI_Result { public: /// Returns the group identifier of this result - virtual std::string group() + virtual std::string groupName() + { return group(); } + + /// Returns the group identifier of this result + static std::string group() {static std::string MY_GROUP = "Bodies"; return MY_GROUP;} /// Stores the shape (called by the execution method). diff --git a/src/ModelAPI/ModelAPI_ResultConstruction.h b/src/ModelAPI/ModelAPI_ResultConstruction.h index 3c12f482c..4207ff5e3 100644 --- a/src/ModelAPI/ModelAPI_ResultConstruction.h +++ b/src/ModelAPI/ModelAPI_ResultConstruction.h @@ -19,9 +19,14 @@ class ModelAPI_ResultConstruction : public ModelAPI_Result { public: /// Returns the group identifier of this result - virtual std::string group() + virtual std::string groupName() + { return group(); } + + /// Returns the group identifier of this result + static std::string group() {static std::string MY_GROUP = "Construction"; return MY_GROUP;} + /// Returns the shape-result produced by this feature virtual boost::shared_ptr& shape() = 0; diff --git a/src/ModelAPI/ModelAPI_ResultParameters.h b/src/ModelAPI/ModelAPI_ResultParameters.h new file mode 100644 index 000000000..ee4c1430b --- /dev/null +++ b/src/ModelAPI/ModelAPI_ResultParameters.h @@ -0,0 +1,32 @@ +// File: ModelAPI_ResultParameters.h +// Created: 07 Jul 2014 +// Author: Vitaly SMETANNIKOV + +#ifndef ModelAPI_ResultParameters_HeaderFile +#define ModelAPI_ResultParameters_HeaderFile + +#include "ModelAPI_Result.h" + +/**\class ModelAPI_ResultParameters + * \ingroup DataModel + * \brief The construction element result of a feature. + * + * Provides a shape that may be displayed in the viewer. + * Intermediate, light result that in many cases produces a result on the fly. + */ +class ModelAPI_ResultParameters : public ModelAPI_Result +{ +public: + /// Returns the group identifier of this result + virtual std::string groupName() + { return group(); } + + /// Returns the group identifier of this result + static std::string group() + {static std::string MY_GROUP = "Parameters"; return MY_GROUP;} +}; + +//! Pointer on feature object +typedef boost::shared_ptr ResultParametersPtr; + +#endif diff --git a/src/ModelAPI/ModelAPI_ResultPart.h b/src/ModelAPI/ModelAPI_ResultPart.h index 60328906c..c922b1ef4 100644 --- a/src/ModelAPI/ModelAPI_ResultPart.h +++ b/src/ModelAPI/ModelAPI_ResultPart.h @@ -18,7 +18,11 @@ class ModelAPI_ResultPart : public ModelAPI_Result { public: /// Returns the group identifier of this result - virtual std::string group() + virtual std::string groupName() + { return group(); } + + /// Returns the group identifier of this result + static std::string group() {static std::string MY_GROUP = "Parts"; return MY_GROUP;} /// Returns the part-document of this result diff --git a/src/ModuleBase/ModuleBase_Definitions.h b/src/ModuleBase/ModuleBase_Definitions.h index f32657a9e..9e4bfbc02 100644 --- a/src/ModuleBase/ModuleBase_Definitions.h +++ b/src/ModuleBase/ModuleBase_Definitions.h @@ -4,11 +4,13 @@ #include #include +#include typedef QList QIntList; //!< list of int values typedef QList QShortList; //!< list of short int values typedef QList QDoubleList; //!< list of double values typedef QList QFeatureList; //!< List of features +typedef QList QResultList; //!< List of results #endif \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_IWorkshop.h b/src/ModuleBase/ModuleBase_IWorkshop.h index 4d6e920b0..134274398 100644 --- a/src/ModuleBase/ModuleBase_IWorkshop.h +++ b/src/ModuleBase/ModuleBase_IWorkshop.h @@ -7,7 +7,7 @@ #include "ModuleBase.h" -#include +#include #include @@ -30,7 +30,7 @@ public: virtual Handle(AIS_InteractiveContext) AISContext() const = 0; //! Returns list of currently selected data objects - virtual QList selectedFeatures() const = 0; + virtual QList selectedObjects() const = 0; //! Returns instance of loaded module virtual ModuleBase_IModule* module() const = 0; diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp new file mode 100644 index 000000000..3f0069eca --- /dev/null +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -0,0 +1,26 @@ +// File: ModuleBase_Tools.cpp +// Created: 11 July 2014 +// Author: Vitaly Smetannikov + +#include "ModuleBase_Tools.h" +#include +#include + +namespace ModuleBase_Tools +{ + +//****************************************************************** +boost::shared_ptr shape(ResultPtr theResult) +{ + ResultBodyPtr aBody = boost::dynamic_pointer_cast(theResult); + if (aBody) + return aBody->shape(); + + ResultConstructionPtr aConstruct = boost::dynamic_pointer_cast(theResult); + if (aConstruct) + return aConstruct->shape(); + + return boost::shared_ptr(); +} + +} \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h new file mode 100644 index 000000000..f326a9e57 --- /dev/null +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -0,0 +1,25 @@ +// File: ModuleBase_Tools.h +// Created: 11 July 2014 +// Author: Vitaly Smetannikov + + +#ifndef ModuleBase_Tools_H +#define ModuleBase_Tools_H + +#include "ModuleBase.h" + +#include + +class GeomAPI_Shape; + +namespace ModuleBase_Tools +{ + + /** + * Returns returns a shape if the result has a shape method. Otherwise returns NULL pointer + */ + MODULEBASE_EXPORT boost::shared_ptr shape(ResultPtr theResult); + +}; + +#endif \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_ViewerPrs.h b/src/ModuleBase/ModuleBase_ViewerPrs.h index b595ac156..274ec2c2a 100644 --- a/src/ModuleBase/ModuleBase_ViewerPrs.h +++ b/src/ModuleBase/ModuleBase_ViewerPrs.h @@ -11,7 +11,7 @@ #include #include -#include +#include /**\class ModuleBase_ViewerPrs * \ingroup Module base @@ -27,21 +27,21 @@ public: /// \param theFeature a model feature /// \param theShape a viewer shape /// \param theOwner a selection owner - ModuleBase_ViewerPrs(FeaturePtr theFeature, + ModuleBase_ViewerPrs(ResultPtr theResult, const TopoDS_Shape& theShape, Handle_SelectMgr_EntityOwner theOwner) - : myFeature(theFeature), myShape(theShape), myOwner(theOwner) {} + : myResult(theResult), myShape(theShape), myOwner(theOwner) {} /// Destructor virtual ~ModuleBase_ViewerPrs() {} /// Sets the feature. /// \param theFeature a feature instance - void setFeature(FeaturePtr theFeature) { myFeature = theFeature; } + void setFeature(ResultPtr theResult) { myResult = theResult; } /// Returns the feature. /// \return a feature instance - FeaturePtr feature() const { return myFeature; } + ResultPtr result() const { return myResult; } /// Returns the presentation owner /// \param the owner @@ -61,14 +61,14 @@ public: bool operator==(const ModuleBase_ViewerPrs& thePrs) { - bool aFeature = (myFeature.get() == thePrs.feature().get()); + bool aResult = (myResult.get() == thePrs.result().get()); bool aOwner = (myOwner.Access() == thePrs.owner().Access()); bool aShape = myShape.IsEqual(thePrs.shape()); - return aFeature && aOwner && aShape; + return aResult && aOwner && aShape; } private: - FeaturePtr myFeature; /// the feature + ResultPtr myResult; /// the feature Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner TopoDS_Shape myShape; /// the shape }; diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.cpp b/src/ModuleBase/ModuleBase_WidgetFeature.cpp index 7e43f4f55..bfcc1956e 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeature.cpp @@ -74,7 +74,7 @@ bool ModuleBase_WidgetFeature::setFeature(const FeaturePtr& theFeature) return false; myFeature = theFeature; - myEditor->setText(theFeature ? theFeature->data()->getName().c_str() : ""); + myEditor->setText(theFeature ? theFeature->data()->name().c_str() : ""); emit valuesChanged(); return true; } @@ -100,7 +100,7 @@ bool ModuleBase_WidgetFeature::restoreValue(FeaturePtr theFeature) boost::dynamic_pointer_cast(aData->attribute(attributeID())); myFeature = aRef->feature(); - myEditor->setText(myFeature ? myFeature->data()->getName().c_str() : ""); + myEditor->setText(myFeature ? myFeature->data()->name().c_str() : ""); return true; } diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp index 6fd65bf96..b3165fbf0 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp @@ -102,7 +102,7 @@ bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(FeaturePtr theFeature) std::string aText = ""; if (aFeature) - aText = aFeature->data()->getName().c_str(); + aText = aFeature->data()->name().c_str(); else if (myAttribute) aText = myAttribute->attributeType().c_str(); diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index 08e9eb020..36f6af51f 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -5,12 +5,14 @@ #include "ModuleBase_WidgetSelector.h" #include "ModuleBase_IWorkshop.h" +#include "ModuleBase_Tools.h" #include #include #include #include +#include #include #include @@ -104,8 +106,8 @@ bool ModuleBase_WidgetSelector::storeValue(FeaturePtr theFeature) const boost::dynamic_pointer_cast(aData->attribute(attributeID())); FeaturePtr aFeature = aRef->value(); - if (!(aFeature && aFeature->isSame(mySelectedFeature))) { - aRef->setValue(mySelectedFeature); + if (!(aFeature && aFeature->isSame(mySelectedObject))) { + aRef->setValue(mySelectedObject); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); } return true; @@ -118,7 +120,7 @@ bool ModuleBase_WidgetSelector::restoreValue(FeaturePtr theFeature) boost::shared_ptr aRef = aData->reference(attributeID()); bool isBlocked = this->blockSignals(true); - mySelectedFeature = aRef->value(); + mySelectedObject = aRef->value(); updateSelectionName(); this->blockSignals(isBlocked); @@ -138,19 +140,19 @@ QList ModuleBase_WidgetSelector::getControls() const //******************************************************************** void ModuleBase_WidgetSelector::onSelectionChanged() { - QList aFeatures = myWorkshop->selectedFeatures(); - if (aFeatures.size() > 0) { - FeaturePtr aFeature = aFeatures.first(); - if ((!mySelectedFeature) && (!aFeature)) + QList aObjects = myWorkshop->selectedObjects(); + if (aObjects.size() > 0) { + ObjectPtr aObject = aObjects.first(); + if ((!mySelectedObject) && (!aObject)) return; - if (mySelectedFeature && aFeature && mySelectedFeature->isSame(aFeature)) + if (mySelectedObject && aObject && mySelectedObject->isSame(aObject)) return; // Check that the selection corresponds to selection type - if (!isAccepted(aFeature)) return; + if (!isAccepted(aObject)) return; - mySelectedFeature = aFeature; - if (mySelectedFeature) { + mySelectedObject = aObject; + if (mySelectedObject) { updateSelectionName(); activateSelection(false); raisePanel(); @@ -162,9 +164,10 @@ void ModuleBase_WidgetSelector::onSelectionChanged() } //******************************************************************** -bool ModuleBase_WidgetSelector::isAccepted(const FeaturePtr theFeature) const +bool ModuleBase_WidgetSelector::isAccepted(const ObjectPtr theResult) const { - boost::shared_ptr aShapePtr = theFeature->data()->shape(); + ResultPtr aResult = boost::dynamic_pointer_cast(theResult); + boost::shared_ptr aShapePtr = ModuleBase_Tools::shape(aResult); if (!aShapePtr) return false; TopoDS_Shape aShape = aShapePtr->impl(); if (aShape.IsNull()) return false; @@ -188,12 +191,8 @@ bool ModuleBase_WidgetSelector::isAccepted(const FeaturePtr theFeature) const //******************************************************************** void ModuleBase_WidgetSelector::updateSelectionName() { - if (mySelectedFeature) { - std::string aName; - if (mySelectedFeature->data()) - aName = mySelectedFeature->data()->getName(); - else - aName = boost::dynamic_pointer_cast(mySelectedFeature)->getName(); + if (mySelectedObject) { + std::string aName = mySelectedObject->data()->name(); myTextLine->setText(QString::fromStdString(aName)); } else diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.h b/src/ModuleBase/ModuleBase_WidgetSelector.h index 0d411f3b7..61fba0049 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetSelector.h @@ -8,7 +8,7 @@ #include "ModuleBase.h" #include "ModuleBase_ModelWidget.h" -#include +#include #include @@ -49,7 +49,7 @@ public: void setActivationOnStart(bool toActivate) { myActivateOnStart = toActivate; } bool activateOnStart() const { return myActivateOnStart; } - FeaturePtr selectedFeature() const { return mySelectedFeature; } + ObjectPtr selectedFeature() const { return mySelectedObject; } public slots: @@ -66,7 +66,7 @@ private: void enableOthersControls(bool toEnable) const; void updateSelectionName(); void raisePanel() const; - bool isAccepted(const FeaturePtr theFeature) const; + bool isAccepted(const ObjectPtr theFeature) const; static TopAbs_ShapeEnum shapeType(const QString& theType); @@ -79,7 +79,7 @@ private: bool myActivateOnStart; - FeaturePtr mySelectedFeature; + ObjectPtr mySelectedObject; QStringList myShapeTypes; }; diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 8ecb179b3..ee9370825 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -99,7 +99,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const { QMenu* aMenu = new QMenu(); XGUI_SelectionMgr* aSelMgr = myWorkshop->selector(); - QFeatureList aFeatures = aSelMgr->selection()->selectedFeatures(); + QList aFeatures = aSelMgr->selection()->selectedObjects(); if (aFeatures.size() == 1) { PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); FeaturePtr aFeature = aFeatures.first(); @@ -153,13 +153,14 @@ QMenu* XGUI_ContextMenuMgr::viewerMenu() const void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const { XGUI_SelectionMgr* aSelMgr = myWorkshop->selector(); - QFeatureList aFeatures = aSelMgr->selection()->selectedFeatures(); - if (aFeatures.size() > 0) { - if (aFeatures.size() == 1) + QList aObjects = aSelMgr->selection()->selectedObjects(); + if (aObjects.size() > 0) { + if (aObjects.size() == 1) theMenu->addAction(action("EDIT_CMD")); bool isVisible = false; - foreach(FeaturePtr aFeature, aFeatures) { - if (myWorkshop->displayer()->isVisible(aFeature)) { + foreach(ObjectPtr aObject, aObjects) { + ResultPtr aRes = boost::dynamic_pointer_cast(aObject); + if (aRes && myWorkshop->displayer()->isVisible(aRes)) { isVisible = true; break; } diff --git a/src/XGUI/XGUI_DataTreeModel.h b/src/XGUI/XGUI_DataTreeModel.h index 5b9f5a839..1e187ed71 100644 --- a/src/XGUI/XGUI_DataTreeModel.h +++ b/src/XGUI/XGUI_DataTreeModel.h @@ -23,14 +23,14 @@ public: //! Returns Feature object by the given Model index. //! Returns 0 if the given index is not index of a feature - virtual FeaturePtr feature(const QModelIndex& theIndex) const = 0; + virtual ObjectPtr feature(const QModelIndex& theIndex) const = 0; //! Returns QModelIndex which corresponds to the given feature //! If the feature is not found then index is not valid - virtual QModelIndex featureIndex(const FeaturePtr& theFeature) const = 0; + virtual QModelIndex featureIndex(const ObjectPtr& theFeature) const = 0; //! Returns parent index of the given feature - virtual QModelIndex findParent(const FeaturePtr& theFeature) const = 0; + virtual QModelIndex findParent(const ObjectPtr& theFeature) const = 0; //! Returns index corresponded to the group virtual QModelIndex findGroup(const std::string& theGroup) const = 0; @@ -60,7 +60,7 @@ public: virtual bool hasDocument(const DocumentPtr& theDoc) const = 0; //! Return a Part object - virtual FeaturePtr part() const = 0; + virtual ObjectPtr part() const = 0; protected: //! Id of the current part object in the document diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 83f70bf14..ac6b3af89 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -6,7 +6,7 @@ #include "XGUI_Viewer.h" #include "XGUI_Workshop.h" #include "XGUI_ViewerProxy.h" -#include "XGUI_Tools.h" +#include "ModuleBase_Tools.h" #include #include @@ -35,33 +35,31 @@ XGUI_Displayer::~XGUI_Displayer() { } -bool XGUI_Displayer::isVisible(FeaturePtr theFeature) +bool XGUI_Displayer::isVisible(ResultPtr theResult) { - FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature); - return myFeature2AISObjectMap.find(aFeature) != myFeature2AISObjectMap.end(); + return myResult2AISObjectMap.find(theResult) != myResult2AISObjectMap.end(); } -bool XGUI_Displayer::display(FeaturePtr theFeature, bool isUpdateViewer) +bool XGUI_Displayer::display(ResultPtr theResult, bool isUpdateViewer) { - FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature); - boost::shared_ptr aShapePtr = aFeature->data()->shape(); + boost::shared_ptr aShapePtr = ModuleBase_Tools::shape(theResult); if (aShapePtr) { boost::shared_ptr anAIS(new GeomAPI_AISObject()); anAIS->createShape(aShapePtr); - return display(aFeature, anAIS, isUpdateViewer); + return display(theResult, anAIS, isUpdateViewer); } return false; } -bool XGUI_Displayer::display(FeaturePtr theFeature, +bool XGUI_Displayer::display(ResultPtr theResult, boost::shared_ptr theAIS, bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); Handle(AIS_InteractiveObject) anAISIO = theAIS->impl(); if (!anAISIO.IsNull()) { - myFeature2AISObjectMap[theFeature] = theAIS; + myResult2AISObjectMap[theResult] = theAIS; aContext->Display(anAISIO, isUpdateViewer); return true; } @@ -70,16 +68,14 @@ bool XGUI_Displayer::display(FeaturePtr theFeature, -void XGUI_Displayer::erase(FeaturePtr theFeature, +void XGUI_Displayer::erase(ResultPtr theResult, const bool isUpdateViewer) { - FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature); - - if (myFeature2AISObjectMap.find(aFeature) == myFeature2AISObjectMap.end()) + if (myResult2AISObjectMap.find(theResult) == myResult2AISObjectMap.end()) return; Handle(AIS_InteractiveContext) aContext = AISContext(); - boost::shared_ptr anObject = myFeature2AISObjectMap[aFeature]; + boost::shared_ptr anObject = myResult2AISObjectMap[theResult]; if (anObject) { Handle(AIS_InteractiveObject) anAIS = anObject->impl(); if (!anAIS.IsNull()) { @@ -87,11 +83,11 @@ void XGUI_Displayer::erase(FeaturePtr theFeature, } } - myFeature2AISObjectMap.erase(aFeature); + myResult2AISObjectMap.erase(theResult); } -bool XGUI_Displayer::redisplay(FeaturePtr theFeature, +bool XGUI_Displayer::redisplay(ResultPtr theFeature, boost::shared_ptr theAIS, const bool isUpdateViewer) { @@ -108,12 +104,12 @@ bool XGUI_Displayer::redisplay(FeaturePtr theFeature, //aContext->SetPixelTolerance(MOUSE_SENSITIVITY_IN_PIXEL); } // display or redisplay presentation - boost::shared_ptr anObj = myFeature2AISObjectMap[theFeature]; + boost::shared_ptr anObj = myResult2AISObjectMap[theFeature]; if (isVisible(theFeature) && anObj && !anObj->empty()) { aContext->RecomputeSelectionOnly(anAIS); } else { - myFeature2AISObjectMap[theFeature] = theAIS; + myResult2AISObjectMap[theFeature] = theAIS; aContext->Display(anAIS, false); isCreated = true; } @@ -123,15 +119,14 @@ bool XGUI_Displayer::redisplay(FeaturePtr theFeature, return isCreated; } -bool XGUI_Displayer::redisplay(FeaturePtr theFeature, bool isUpdateViewer) +bool XGUI_Displayer::redisplay(ResultPtr theResult, bool isUpdateViewer) { - FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature); - if (!isVisible(aFeature)) + if (!isVisible(theResult)) return false; - boost::shared_ptr aShapePtr = aFeature->data()->shape(); + boost::shared_ptr aShapePtr = ModuleBase_Tools::shape(theResult); if (aShapePtr) { - boost::shared_ptr aAISObj = getAISObject(aFeature); + boost::shared_ptr aAISObj = getAISObject(theResult); Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl()); if (!aAISShape.IsNull()) { aAISShape->Set(aShapePtr->impl()); @@ -142,7 +137,7 @@ bool XGUI_Displayer::redisplay(FeaturePtr theFeature, bool isUpdateViewer) return false; } -void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature, +void XGUI_Displayer::activateInLocalContext(ResultPtr theResult, const std::list& theModes, const bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); @@ -153,9 +148,9 @@ void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature, } // display or redisplay presentation Handle(AIS_InteractiveObject) anAIS; - if (isVisible(theFeature)) + if (isVisible(theResult)) { - boost::shared_ptr anObj = myFeature2AISObjectMap[theFeature]; + boost::shared_ptr anObj = myResult2AISObjectMap[theResult]; if (anObj) anAIS = anObj->impl(); } @@ -176,18 +171,18 @@ void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature, updateViewer(); } -void XGUI_Displayer::stopSelection(const QFeatureList& theFeatures, const bool isStop, +void XGUI_Displayer::stopSelection(const QResultList& theResults, const bool isStop, const bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); Handle(AIS_Shape) anAIS; - QFeatureList::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end(); - FeaturePtr aFeature; + QResultList::const_iterator anIt = theResults.begin(), aLast = theResults.end(); + ResultPtr aFeature; for (; anIt != aLast; anIt++) { aFeature = *anIt; if (isVisible(aFeature)) - anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[aFeature]->impl()); + anAIS = Handle(AIS_Shape)::DownCast(myResult2AISObjectMap[aFeature]->impl()); if (anAIS.IsNull()) continue; @@ -206,7 +201,7 @@ void XGUI_Displayer::stopSelection(const QFeatureList& theFeatures, const bool i updateViewer(); } -void XGUI_Displayer::setSelected(const QFeatureList& theFeatures, const bool isUpdateViewer) +void XGUI_Displayer::setSelected(const QResultList& theResults, const bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); // we need to unhighligth objects manually in the current local context @@ -216,12 +211,11 @@ void XGUI_Displayer::setSelected(const QFeatureList& theFeatures, const bool isU aLocalContext->UnhilightLastDetected(myWorkshop->viewer()->activeView()); aContext->ClearSelected(); - foreach(FeaturePtr aFeature, theFeatures) { - FeaturePtr aRFeature = XGUI_Tools::realFeature(aFeature); - if (myFeature2AISObjectMap.find(aRFeature) == myFeature2AISObjectMap.end()) + foreach(ResultPtr aResult, theResults) { + if (myResult2AISObjectMap.find(aResult) == myResult2AISObjectMap.end()) return; - boost::shared_ptr anObj = myFeature2AISObjectMap[aRFeature]; + boost::shared_ptr anObj = myResult2AISObjectMap[aResult]; if (anObj) { Handle(AIS_InteractiveObject) anAIS = anObj->impl(); @@ -249,21 +243,21 @@ void XGUI_Displayer::setSelected(const QFeatureList& theFeatures, const bool isU Handle(AIS_InteractiveObject) anIO = anIter.Value(); ic->Erase(anIO, false); } - myFeature2AISObjectMap.clear(); + myResult2AISObjectMap.clear(); if (isUpdateViewer) updateViewer(); }*/ -void XGUI_Displayer::eraseDeletedFeatures(const bool isUpdateViewer) +void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); - FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(), - aFLast = myFeature2AISObjectMap.end(); - std::list aRemoved; + ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), + aFLast = myResult2AISObjectMap.end(); + std::list aRemoved; for (; aFIt != aFLast; aFIt++) { - FeaturePtr aFeature = (*aFIt).first; + ResultPtr aFeature = (*aFIt).first; if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) { boost::shared_ptr anObj = (*aFIt).second; if (!anObj) continue; @@ -274,10 +268,10 @@ void XGUI_Displayer::eraseDeletedFeatures(const bool isUpdateViewer) } } } - std::list::const_iterator anIt = aRemoved.begin(), + std::list::const_iterator anIt = aRemoved.begin(), aLast = aRemoved.end(); for (; anIt != aLast; anIt++) { - myFeature2AISObjectMap.erase(myFeature2AISObjectMap.find(*anIt)); + myResult2AISObjectMap.erase(myResult2AISObjectMap.find(*anIt)); } if (isUpdateViewer) @@ -290,19 +284,19 @@ void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer) } boost::shared_ptr XGUI_Displayer::getAISObject( - FeaturePtr theFeature) const + ResultPtr theFeature) const { boost::shared_ptr anIO; - if (myFeature2AISObjectMap.find(theFeature) != myFeature2AISObjectMap.end()) - anIO = (myFeature2AISObjectMap.find(theFeature))->second; + if (myResult2AISObjectMap.find(theFeature) != myResult2AISObjectMap.end()) + anIO = (myResult2AISObjectMap.find(theFeature))->second; return anIO; } -FeaturePtr XGUI_Displayer::getFeature(Handle(AIS_InteractiveObject) theIO) const +ResultPtr XGUI_Displayer::getResult(Handle(AIS_InteractiveObject) theIO) const { - FeaturePtr aFeature; - FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(), - aFLast = myFeature2AISObjectMap.end(); + ResultPtr aFeature; + ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), + aFLast = myResult2AISObjectMap.end(); for (; aFIt != aFLast && !aFeature; aFIt++) { boost::shared_ptr anObj = (*aFIt).second; if (!anObj) continue; diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 2c730c9e8..e047af515 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include @@ -49,27 +49,27 @@ public: /// Returns the feature visibility state. /// \param theFeature a feature instance - bool isVisible(FeaturePtr theFeature); + bool isVisible(ResultPtr theResult); /// Display the feature. Obtain the visualized object from the feature. /// \param theFeature a feature instance /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly /// Returns true if the Feature succesfully displayed - bool display(FeaturePtr theFeature, bool isUpdateViewer = true); + bool display(ResultPtr theFeature, bool isUpdateViewer = true); /// Display the feature and a shape. This shape would be associated to the given feature /// \param theFeature a feature instance /// \param theAIS AIS presentation /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly /// Returns true if the Feature succesfully displayed - bool display(FeaturePtr theFeature, boost::shared_ptr theAIS, bool isUpdateViewer = true); + bool display(ResultPtr theResult, boost::shared_ptr theAIS, bool isUpdateViewer = true); /// Display the shape and activate selection of sub-shapes /// \param theFeature a feature instance /// \param theAIS an AIS object /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly /// \returns true if the presentation is created - bool redisplay(FeaturePtr theFeature, + bool redisplay(ResultPtr theFeature, boost::shared_ptr theAIS, const bool isUpdateViewer = true); @@ -77,7 +77,7 @@ public: * \param theFeature a feature instance * \param isUpdateViewer the parameter whether the viewer should be update immediatelly */ - bool redisplay(FeaturePtr theFeature, bool isUpdateViewer = true); + bool redisplay(ResultPtr theFeature, bool isUpdateViewer = true); /// Redisplay the shape and activate selection of sub-shapes /// \param theFeature a feature instance @@ -89,14 +89,14 @@ public: /// \param theShape a shape /// \param theMode a list of local selection modes /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - void activateInLocalContext(FeaturePtr theFeature, + void activateInLocalContext(ResultPtr theFeature, const std::list& theModes, const bool isUpdateViewer = true); /// Stop the current selection and color the given features to the selection color /// \param theFeatures a list of features to be disabled /// \param theToStop the boolean state whether it it stopped or non stopped /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - void stopSelection(const QFeatureList& theFeatures, const bool isStop, + void stopSelection(const QResultList& theFeatures, const bool isStop, const bool isUpdateViewer); /** @@ -104,12 +104,12 @@ public: * \param theFeatures a list of features to be selected * isUpdateViewer the parameter whether the viewer should be update immediatelly */ - void setSelected(const QFeatureList& theFeatures, bool isUpdateViewer = true); + void setSelected(const QResultList& theFeatures, bool isUpdateViewer = true); /// Erase the feature and a shape. /// \param theFeature a feature instance /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - void erase(FeaturePtr theFeature, const bool isUpdateViewer = true); + void erase(ResultPtr theResult, const bool isUpdateViewer = true); /// Erase all presentations /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly @@ -117,7 +117,7 @@ public: /// Erase AIS interactive objects, which has an empty feature in the internal map /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - void eraseDeletedFeatures(const bool isUpdateViewer = true); + void eraseDeletedResults(const bool isUpdateViewer = true); /// Deactivates selection of sub-shapes /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly @@ -129,12 +129,12 @@ public: /// Searches the interactive object by feature /// \param theFeature the feature or NULL if it not visualized /// \return theIO an interactive object - boost::shared_ptr getAISObject(FeaturePtr theFeature) const; + boost::shared_ptr getAISObject(ResultPtr theFeature) const; /// Searches the feature by interactive object /// \param theIO an interactive object /// \return feature the feature or NULL if it not visualized - FeaturePtr getFeature(Handle(AIS_InteractiveObject) theIO) const; + ResultPtr getResult(Handle(AIS_InteractiveObject) theIO) const; protected: /// Deactivate local selection @@ -147,8 +147,8 @@ protected: protected: XGUI_Workshop* myWorkshop; - typedef std::map > FeatureToAISMap; - FeatureToAISMap myFeature2AISObjectMap; + typedef std::map > ResultToAISMap; + ResultToAISMap myResult2AISObjectMap; }; diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index 9cb80fa22..e0a736170 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -28,9 +28,9 @@ Handle(AIS_InteractiveContext) XGUI_ModuleConnector::AISContext() const } -QFeatureList XGUI_ModuleConnector::selectedFeatures() const +QList XGUI_ModuleConnector::selectedObjects() const { - return myWorkshop->selector()->selection()->selectedFeatures(); + return myWorkshop->selector()->selection()->selectedObjects(); } ModuleBase_IModule* XGUI_ModuleConnector::module() const diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h index 8ef06b321..c7119b79e 100644 --- a/src/XGUI/XGUI_ModuleConnector.h +++ b/src/XGUI/XGUI_ModuleConnector.h @@ -29,7 +29,7 @@ public: virtual Handle(AIS_InteractiveContext) AISContext() const; //! Returns list of currently selected data objects - virtual QFeatureList selectedFeatures() const; + virtual QList selectedObjects() const; //! Returns instance of loaded module virtual ModuleBase_IModule* module() const; diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index a1e5c5ef1..0924af4b5 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -4,6 +4,7 @@ #include "XGUI.h" #include +#include #include #include @@ -20,7 +21,7 @@ public: virtual ~XGUI_DataTree(); //! Returns list of currently selected features - QFeatureList selectedFeatures() const { return mySelectedData; } + QList selectedFeatures() const { return mySelectedData; } XGUI_DocumentDataModel* dataModel() const; @@ -45,7 +46,7 @@ private slots: private: //! List of currently selected data - QFeatureList mySelectedData; + QList mySelectedData; }; @@ -64,7 +65,7 @@ public: XGUI_DocumentDataModel* dataModel() const { return myDocModel; } //! Returns list of currently selected features - QFeatureList selectedFeatures() const { return myFeaturesList; } + QList selectedObjects() const { return myObjectsList; } void setFeaturesSelected(const QFeatureList& theFeatures); @@ -111,7 +112,7 @@ private: QLineEdit* myActiveDocLbl; XGUI_DataTree* myTreeView; - QFeatureList myFeaturesList; + QList myObjectsList; }; #endif \ No newline at end of file diff --git a/src/XGUI/XGUI_PartDataModel.cpp b/src/XGUI/XGUI_PartDataModel.cpp index ced60958b..0bd28f9d7 100644 --- a/src/XGUI/XGUI_PartDataModel.cpp +++ b/src/XGUI/XGUI_PartDataModel.cpp @@ -4,15 +4,18 @@ #include #include #include +#include #include #include #include +#include +#include #include #include -//FeaturePtr featureObj(const FeaturePtr& theFeature) +//ObjectPtr featureObj(const ObjectPtr& theFeature) //{ // ObjectPtr aObject = boost::dynamic_pointer_cast(theFeature); // if (aObject) @@ -42,18 +45,18 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const case ParamObject: { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); - FeaturePtr aFeature = aRootDoc->feature(PARAMETERS_GROUP, theIndex.row()); + ObjectPtr aFeature = aRootDoc->object(PARAMETERS_GROUP, theIndex.row()); if (aFeature) - return boost::dynamic_pointer_cast(aFeature)->getName().c_str(); + return boost::dynamic_pointer_cast(aFeature)->data()->name().c_str(); } case ConstructFolder: return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex)); case ConstructObject: { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); - FeaturePtr aFeature = aRootDoc->feature(CONSTRUCTIONS_GROUP, theIndex.row()); + ObjectPtr aFeature = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row()); if (aFeature) - return boost::dynamic_pointer_cast(aFeature)->getName().c_str(); + return boost::dynamic_pointer_cast(aFeature)->data()->name().c_str(); } } break; @@ -68,7 +71,7 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const case ConstructObject: { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); - FeaturePtr aFeature = aRootDoc->feature(CONSTRUCTIONS_GROUP, theIndex.row()); + ObjectPtr aFeature = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row()); if (aFeature) return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind())); } @@ -149,12 +152,12 @@ bool XGUI_TopDataModel::hasChildren(const QModelIndex& theParent) const return rowCount(theParent) > 0; } -FeaturePtr XGUI_TopDataModel::feature(const QModelIndex& theIndex) const +ObjectPtr XGUI_TopDataModel::feature(const QModelIndex& theIndex) const { switch (theIndex.internalId()) { case ParamsFolder: case ConstructFolder: - return FeaturePtr(); + return ObjectPtr(); case ParamObject: { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); @@ -166,11 +169,11 @@ FeaturePtr XGUI_TopDataModel::feature(const QModelIndex& theIndex) const return aRootDoc->feature(CONSTRUCTIONS_GROUP, theIndex.row()); } } - return FeaturePtr(); + return ObjectPtr(); } -QModelIndex XGUI_TopDataModel::findParent(const FeaturePtr& theFeature) const +QModelIndex XGUI_TopDataModel::findParent(const ObjectPtr& theFeature) const { return findGroup(theFeature->getGroup().c_str()); } @@ -184,7 +187,7 @@ QModelIndex XGUI_TopDataModel::findGroup(const std::string& theGroup) const return QModelIndex(); } -QModelIndex XGUI_TopDataModel::featureIndex(const FeaturePtr& theFeature) const +QModelIndex XGUI_TopDataModel::featureIndex(const ObjectPtr& theFeature) const { QModelIndex aIndex; if (theFeature) { @@ -232,7 +235,7 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons case MyRoot: { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); - FeaturePtr aFeature = aRootDoc->feature(PARTS_GROUP, myId); + ObjectPtr aFeature = aRootDoc->feature(PARTS_GROUP, myId); if (aFeature) return boost::dynamic_pointer_cast(aFeature)->getName().c_str(); } @@ -244,19 +247,19 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex)); case ParamObject: { - FeaturePtr aFeature = featureDocument()->feature(PARAMETERS_GROUP, theIndex.row()); + ObjectPtr aFeature = featureDocument()->feature(PARAMETERS_GROUP, theIndex.row()); if (aFeature) return boost::dynamic_pointer_cast(aFeature)->getName().c_str(); } case ConstructObject: { - FeaturePtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row()); + ObjectPtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row()); if (aFeature) return boost::dynamic_pointer_cast(aFeature)->getName().c_str(); } case HistoryObject: { - FeaturePtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3); + ObjectPtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3); if (aFeature) return aFeature->data()->getName().c_str(); } @@ -274,13 +277,13 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons return QIcon(":pictures/constr_folder.png"); case ConstructObject: { - FeaturePtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row()); + ObjectPtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row()); if (aFeature) return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind())); } case HistoryObject: { - FeaturePtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3); + ObjectPtr aFeature = featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3); if (aFeature) return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind())); } @@ -383,11 +386,11 @@ bool XGUI_PartDataModel::hasChildren(const QModelIndex& theParent) const DocumentPtr XGUI_PartDataModel::featureDocument() const { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); - FeaturePtr aFeature = aRootDoc->feature(PARTS_GROUP, myId, true); + ObjectPtr aFeature = aRootDoc->feature(PARTS_GROUP, myId, true); return aFeature->data()->docRef("PartDocument")->value(); } -FeaturePtr XGUI_PartDataModel::feature(const QModelIndex& theIndex) const +ObjectPtr XGUI_PartDataModel::feature(const QModelIndex& theIndex) const { switch (theIndex.internalId()) { case MyRoot: @@ -398,7 +401,7 @@ FeaturePtr XGUI_PartDataModel::feature(const QModelIndex& theIndex) const case ParamsFolder: case ConstructFolder: case BodiesFolder: - return FeaturePtr(); + return ObjectPtr(); case ParamObject: return featureDocument()->feature(PARAMETERS_GROUP, theIndex.row()); case ConstructObject: @@ -408,7 +411,7 @@ FeaturePtr XGUI_PartDataModel::feature(const QModelIndex& theIndex) const case HistoryObject: return featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3); } - return FeaturePtr(); + return ObjectPtr(); } bool XGUI_PartDataModel::hasDocument(const DocumentPtr& theDoc) const @@ -417,7 +420,7 @@ bool XGUI_PartDataModel::hasDocument(const DocumentPtr& theDoc) const } -QModelIndex XGUI_PartDataModel::findParent(const FeaturePtr& theFeature) const +QModelIndex XGUI_PartDataModel::findParent(const ObjectPtr& theFeature) const { return findGroup(theFeature->getGroup().c_str()); } @@ -431,25 +434,25 @@ QModelIndex XGUI_PartDataModel::findGroup(const std::string& theGroup) const return QModelIndex(); } -FeaturePtr XGUI_PartDataModel::part() const +ObjectPtr XGUI_PartDataModel::part() const { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); - return aRootDoc->feature(PARTS_GROUP, myId, true); + return aRootDoc->object(ModelAPI_ResultPart::group(), myId); } -QModelIndex XGUI_PartDataModel::featureIndex(const FeaturePtr& theFeature) const +QModelIndex XGUI_PartDataModel::featureIndex(const ObjectPtr& theObject) const { QModelIndex aIndex; - if (theFeature) { - if (part() == theFeature) + if (theObject) { + if (part() == theObject) return aIndex; //std::string aGroup = theFeature->getGroup(); - DocumentPtr aDoc = theFeature->document(); - int aNb = aDoc->size(FEATURES_GROUP); + DocumentPtr aDoc = theObject->document(); + int aNb = aDoc->size(ModelAPI_Feature::group()); int aRow = -1; for (int i = 0; i < aNb; i++) { - if (aDoc->feature(FEATURES_GROUP, i) == theFeature) { + if (aDoc->object(ModelAPI_Feature::group(), i) == theObject) { aRow = i; break; } diff --git a/src/XGUI/XGUI_PartDataModel.h b/src/XGUI/XGUI_PartDataModel.h index fabadeb8b..9ebf7669f 100644 --- a/src/XGUI/XGUI_PartDataModel.h +++ b/src/XGUI/XGUI_PartDataModel.h @@ -34,14 +34,14 @@ public: //! Returns Feature object by the given Model index. //! Returns 0 if the given index is not index of a feature - virtual FeaturePtr feature(const QModelIndex& theIndex) const; + virtual ObjectPtr feature(const QModelIndex& theIndex) const; //! Returns QModelIndex which corresponds to the given feature //! If the feature is not found then index is not valid - virtual QModelIndex featureIndex(const FeaturePtr& theFeature) const; + virtual QModelIndex featureIndex(const ObjectPtr& theFeature) const; //! Returns parent index of the given feature - virtual QModelIndex findParent(const FeaturePtr& theFeature) const; + virtual QModelIndex findParent(const ObjectPtr& theFeature) const; //! Returns index corresponded to the group virtual QModelIndex findGroup(const std::string& theGroup) const; @@ -87,23 +87,23 @@ public: //! Returns Feature object by the given Model index. //! Returns 0 if the given index is not index of a feature - virtual FeaturePtr feature(const QModelIndex& theIndex) const; + virtual ObjectPtr feature(const QModelIndex& theIndex) const; //! Returns QModelIndex which corresponds to the given feature //! If the feature is not found then index is not valid - virtual QModelIndex featureIndex(const FeaturePtr& theFeature) const; + virtual QModelIndex featureIndex(const ObjectPtr& theFeature) const; //! Returns true if the given document is a sub-document of this tree virtual bool hasDocument(const DocumentPtr& theDoc) const; //! Returns parent index of the given feature - virtual QModelIndex findParent(const FeaturePtr& theFeature) const; + virtual QModelIndex findParent(const ObjectPtr& theFeature) const; //! Returns index corresponded to the group virtual QModelIndex findGroup(const std::string& theGroup) const; //! Return a Part object - virtual FeaturePtr part() const; + virtual ObjectPtr part() const; private: diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp index 5900aefea..05b4e0ea6 100644 --- a/src/XGUI/XGUI_Selection.cpp +++ b/src/XGUI/XGUI_Selection.cpp @@ -22,7 +22,7 @@ XGUI_Selection::XGUI_Selection(XGUI_Workshop* theWorkshop) std::list XGUI_Selection::getSelected(int theShapeTypeToSkip) const { - std::set aPrsFeatures; + std::set aPrsFeatures; std::list aPresentations; Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); @@ -33,7 +33,7 @@ std::list XGUI_Selection::getSelected(int theShapeTypeToSk if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip) continue; - FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO); + ResultPtr aFeature = myWorkshop->displayer()->getResult(anIO); if (aPrsFeatures.find(aFeature) != aPrsFeatures.end()) continue; Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner(); @@ -45,7 +45,7 @@ std::list XGUI_Selection::getSelected(int theShapeTypeToSk std::list XGUI_Selection::getHighlighted(int theShapeTypeToSkip) const { - std::set aPrsFeatures; + std::set aPrsFeatures; std::list aPresentations; Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); @@ -55,29 +55,33 @@ std::list XGUI_Selection::getHighlighted(int theShapeTypeT if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip) continue; - FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO); - if (aPrsFeatures.find(aFeature) != aPrsFeatures.end()) + ResultPtr aResult = myWorkshop->displayer()->getResult(anIO); + if (aPrsFeatures.find(aResult) != aPrsFeatures.end()) continue; - aPresentations.push_back(ModuleBase_ViewerPrs(aFeature, aShape, NULL)); - aPrsFeatures.insert(aFeature); + aPresentations.push_back(ModuleBase_ViewerPrs(aResult, aShape, NULL)); + aPrsFeatures.insert(aResult); } return aPresentations; } -QFeatureList XGUI_Selection::selectedFeatures() const +QList XGUI_Selection::selectedObjects() const { - return myWorkshop->objectBrowser()->selectedFeatures(); - //QFeatureList aSelectedList; - - //Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); - //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { - // Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive(); - // FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO); - // if (aFeature) - // aSelectedList.append(aFeature); - //} - //return aSelectedList; + return myWorkshop->objectBrowser()->selectedObjects(); +} + +QResultList XGUI_Selection::selectedResults() const +{ + QResultList aSelectedList; + + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { + Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive(); + ResultPtr aResult = myWorkshop->displayer()->getResult(anIO); + if (aResult) + aSelectedList.append(aResult); + } + return aSelectedList; } diff --git a/src/XGUI/XGUI_Selection.h b/src/XGUI/XGUI_Selection.h index c6f92f5ff..84b73f0f7 100644 --- a/src/XGUI/XGUI_Selection.h +++ b/src/XGUI/XGUI_Selection.h @@ -36,9 +36,14 @@ public: std::list getHighlighted(int theShapeTypeToSkip = -1) const; /** - * Returns list of features currently selected in 3d viewer + * Returns list of currently selected objects */ - QFeatureList selectedFeatures() const; + QList selectedObjects() const; + + /** + * Returns list of currently selected results + */ + QResultList selectedResults() const; //! Returns list of currently selected QModelIndexes QModelIndexList selectedIndexes() const; diff --git a/src/XGUI/XGUI_SelectionMgr.h b/src/XGUI/XGUI_SelectionMgr.h index 93f19284c..0519e29d0 100644 --- a/src/XGUI/XGUI_SelectionMgr.h +++ b/src/XGUI/XGUI_SelectionMgr.h @@ -28,18 +28,6 @@ public: XGUI_Selection* selection() const { return mySelection; } - //! Returns list of currently selected data objects - //QFeatureList selectedFeatures() const; - - //! Returns list of currently selected QModelIndexes - //QModelIndexList selectedIndexes() const; - - //! Returns list of currently selected AIS objects - //void selectedAISObjects(AIS_ListOfInteractive& theList) const; - - //! Returns list of currently selected shapes - //void selectedShapes(NCollection_List& theList) const; - //! Connects the manager to all viewers accessible by Workshop void connectViewers(); diff --git a/src/XGUI/XGUI_Tools.cpp b/src/XGUI/XGUI_Tools.cpp index 5cf560636..5672163dc 100644 --- a/src/XGUI/XGUI_Tools.cpp +++ b/src/XGUI/XGUI_Tools.cpp @@ -2,6 +2,7 @@ #include #include +#include #include @@ -71,7 +72,7 @@ std::string featureInfo(FeaturePtr theFeature) } //****************************************************************** -FeaturePtr realFeature(const FeaturePtr theFeature) +/*FeaturePtr realFeature(const FeaturePtr theFeature) { if (theFeature->data()) { return theFeature; @@ -79,6 +80,7 @@ FeaturePtr realFeature(const FeaturePtr theFeature) ObjectPtr aObject = boost::dynamic_pointer_cast(theFeature); return aObject->featureRef(); } -} +}*/ + } diff --git a/src/XGUI/XGUI_Tools.h b/src/XGUI/XGUI_Tools.h index fa1c78af5..0ad21160a 100644 --- a/src/XGUI/XGUI_Tools.h +++ b/src/XGUI/XGUI_Tools.h @@ -9,7 +9,6 @@ #include -class TopoDS_Shape; /*! \brief Return directory part of the file path. @@ -72,11 +71,6 @@ namespace XGUI_Tools \param theFeature a feature */ std::string XGUI_EXPORT featureInfo(FeaturePtr theFeature); - - /** - * Returns pointer on real feature - */ - FeaturePtr realFeature(const FeaturePtr theFeature); } #endif diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index d480ef348..78c7cc717 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -131,7 +131,7 @@ void XGUI_Workshop::startApplication() aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_TO_REDISPLAY)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); activateModule(); if (myMainWindow) { @@ -230,21 +230,21 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) // Process creation of Part if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) { - const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); + const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); onFeatureCreatedMsg(aUpdMsg); } // Redisplay feature - if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_TO_REDISPLAY)) { - const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); + if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) { + const Model_ObjectUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); onFeatureRedisplayMsg(aUpdMsg); } //Update property panel on corresponding message. If there is no current operation (no //property panel), or received message has different feature to the current - do nothing. if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) { - const Model_FeatureUpdatedMessage* anUpdateMsg = - dynamic_cast(theMessage); + const Model_ObjectUpdatedMessage* anUpdateMsg = + dynamic_cast(theMessage); onFeatureUpdatedMsg(anUpdateMsg); } @@ -271,7 +271,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) } //****************************************************** -void XGUI_Workshop::onFeatureUpdatedMsg(const Model_FeatureUpdatedMessage* theMsg) +void XGUI_Workshop::onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg) { std::set aFeatures = theMsg->features(); if (myOperationMgr->hasOperation()) @@ -289,7 +289,7 @@ void XGUI_Workshop::onFeatureUpdatedMsg(const Model_FeatureUpdatedMessage* theMs } //****************************************************** -void XGUI_Workshop::onFeatureRedisplayMsg(const Model_FeatureUpdatedMessage* theMsg) +void XGUI_Workshop::onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theMsg) { std::set aFeatures = theMsg->features(); std::set::const_iterator aIt; @@ -305,7 +305,7 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const Model_FeatureUpdatedMessage* the } //****************************************************** -void XGUI_Workshop::onFeatureCreatedMsg(const Model_FeatureUpdatedMessage* theMsg) +void XGUI_Workshop::onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg) { std::set aFeatures = theMsg->features(); diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 960c4dd89..870e23f19 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -37,7 +37,7 @@ class Config_PointerMessage; class QWidget; class QDockWidget; -class Model_FeatureUpdatedMessage; +class Model_ObjectUpdatedMessage; class QAction; /**\class XGUI_Workshop @@ -152,9 +152,9 @@ protected: void connectWithOperation(ModuleBase_Operation* theOperation); void saveDocument(QString theName); - void onFeatureUpdatedMsg(const Model_FeatureUpdatedMessage* theMsg); - void onFeatureCreatedMsg(const Model_FeatureUpdatedMessage* theMsg); - void onFeatureRedisplayMsg(const Model_FeatureUpdatedMessage* theMsg); + void onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg); + void onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg); + void onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theMsg); QList getModuleCommands() const;