From: vsv Date: Thu, 17 Jul 2014 08:27:48 +0000 (+0400) Subject: GeomAPI_IPresentation in terface created X-Git-Tag: V_0.4.4~176^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f8a5e3c97b28bc4e8a53a12be59b11544a968d41;p=modules%2Fshaper.git GeomAPI_IPresentation in terface created --- diff --git a/src/GeomAPI/CMakeLists.txt b/src/GeomAPI/CMakeLists.txt index e4bd74bf9..e13d4b270 100644 --- a/src/GeomAPI/CMakeLists.txt +++ b/src/GeomAPI/CMakeLists.txt @@ -19,6 +19,7 @@ SET(PROJECT_HEADERS GeomAPI_Pln.h GeomAPI_Shape.h GeomAPI_AISObject.h + GeomAPI_IPresentable.h ) SET(PROJECT_SOURCES diff --git a/src/GeomAPI/GeomAPI_IPresentable.h b/src/GeomAPI/GeomAPI_IPresentable.h new file mode 100644 index 000000000..b28ed8bb0 --- /dev/null +++ b/src/GeomAPI/GeomAPI_IPresentable.h @@ -0,0 +1,25 @@ +// File: GeomAPI_IPresentable.hxx +// Created: 17 July 2014 +// Author: Vitaly SMETANNIKOV + +#ifndef GeomAPI_IPresentable_HeaderFile +#define GeomAPI_IPresentable_HeaderFile + +#include "GeomAPI_AISObject.h" + +/** +* A class which defines an interface of object which is able to create its own presentation +*/ +class GeomAPI_IPresentable +{ +public: + /** Returns the AIS preview + * \param thePrevious - defines a presentation if it was created previously + */ + virtual boost::shared_ptr getAISObject( + boost::shared_ptr thePrevious) = 0; +}; + +typedef boost::shared_ptr GeomPresentablePtr; + +#endif \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_ISelection.h b/src/ModuleBase/ModuleBase_ISelection.h index 9a9e52ed7..33d617de9 100644 --- a/src/ModuleBase/ModuleBase_ISelection.h +++ b/src/ModuleBase/ModuleBase_ISelection.h @@ -38,7 +38,7 @@ public: /** * Returns list of currently selected results */ - virtual QResultList selectedResults() const = 0; + virtual QList selectedPresentations() const = 0; //! Returns list of currently selected QModelIndexes virtual QModelIndexList selectedIndexes() const = 0; diff --git a/src/ModuleBase/ModuleBase_ViewerPrs.h b/src/ModuleBase/ModuleBase_ViewerPrs.h index 274ec2c2a..4ef5e5bad 100644 --- a/src/ModuleBase/ModuleBase_ViewerPrs.h +++ b/src/ModuleBase/ModuleBase_ViewerPrs.h @@ -27,7 +27,7 @@ public: /// \param theFeature a model feature /// \param theShape a viewer shape /// \param theOwner a selection owner - ModuleBase_ViewerPrs(ResultPtr theResult, + ModuleBase_ViewerPrs(ObjectPtr theResult, const TopoDS_Shape& theShape, Handle_SelectMgr_EntityOwner theOwner) : myResult(theResult), myShape(theShape), myOwner(theOwner) {} @@ -37,11 +37,11 @@ public: /// Sets the feature. /// \param theFeature a feature instance - void setFeature(ResultPtr theResult) { myResult = theResult; } + void setFeature(ObjectPtr theResult) { myResult = theResult; } /// Returns the feature. /// \return a feature instance - ResultPtr result() const { return myResult; } + ObjectPtr object() const { return myResult; } /// Returns the presentation owner /// \param the owner @@ -61,14 +61,14 @@ public: bool operator==(const ModuleBase_ViewerPrs& thePrs) { - bool aResult = (myResult.get() == thePrs.result().get()); + bool aResult = (myResult.get() == thePrs.object().get()); bool aOwner = (myOwner.Access() == thePrs.owner().Access()); bool aShape = myShape.IsEqual(thePrs.shape()); return aResult && aOwner && aShape; } private: - ResultPtr myResult; /// the feature + ObjectPtr myResult; /// the feature Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner TopoDS_Shape myShape; /// the shape }; diff --git a/src/ModuleBase/ModuleBase_WidgetValueFeature.cpp b/src/ModuleBase/ModuleBase_WidgetValueFeature.cpp index da9fe5fd3..e6a4f818c 100644 --- a/src/ModuleBase/ModuleBase_WidgetValueFeature.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValueFeature.cpp @@ -14,12 +14,12 @@ ModuleBase_WidgetValueFeature::~ModuleBase_WidgetValueFeature() { } -void ModuleBase_WidgetValueFeature::setResult(const ResultPtr& theFeature) +void ModuleBase_WidgetValueFeature::setObject(const ObjectPtr& theFeature) { myResult = theFeature; } -const ResultPtr& ModuleBase_WidgetValueFeature::result() const +const ObjectPtr& ModuleBase_WidgetValueFeature::object() const { return myResult; } diff --git a/src/ModuleBase/ModuleBase_WidgetValueFeature.h b/src/ModuleBase/ModuleBase_WidgetValueFeature.h index 2de332108..1a1f10164 100644 --- a/src/ModuleBase/ModuleBase_WidgetValueFeature.h +++ b/src/ModuleBase/ModuleBase_WidgetValueFeature.h @@ -28,11 +28,11 @@ public: /// Fill the widget values by given point /// \param thePoint the point - void setResult(const ResultPtr& theFeature); + void setObject(const ObjectPtr& theFeature); /// Returns the widget values by given point /// \return theFeature the current feature - const ResultPtr& result() const; + const ObjectPtr& object() const; /// Fill the widget values by given point /// \param thePoint the point @@ -43,7 +43,7 @@ public: const boost::shared_ptr& point() const; private: - ResultPtr myResult; + ObjectPtr myResult; boost::shared_ptr myPoint; }; diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 84a9ec96f..fc2ffb51b 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -461,9 +461,10 @@ void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay, boost::shared_ptr aSPFeature = boost::dynamic_pointer_cast(theFeature); if (aSPFeature) { - boost::shared_ptr anAIS = - aSPFeature->getAISObject(aDisplayer->getAISObject(aResult)); - aDisplayer->redisplay(aResult, anAIS, false); + //boost::shared_ptr anAIS = + // aSPFeature->getAISObject(aDisplayer->getAISObject(aResult)); + aDisplayer->display(aSPFeature, false); + //aDisplayer->redisplay(aResult, anAIS, false); } } else diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp index f08d83972..2e96339ff 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.cpp +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -145,10 +145,10 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle } } } - ResultPtr aFeature; + ObjectPtr aFeature; if (!theSelected.empty()) { ModuleBase_ViewerPrs aPrs = theSelected.front(); - aFeature = aPrs.result(); + aFeature = aPrs.object(); } // TODO //else @@ -194,7 +194,7 @@ void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* t if ((myPreSelection.size() > 0) && myActiveWidget) { const ModuleBase_ViewerPrs& aPrs = myPreSelection.front(); ModuleBase_WidgetValueFeature aValue; - aValue.setResult(aPrs.result()); + aValue.setObject(aPrs.object()); if (myActiveWidget->setValue(&aValue)) { myPreSelection.remove(aPrs); emit activateNextWidget(myActiveWidget); @@ -283,7 +283,7 @@ FeaturePtr PartSet_OperationFeatureCreate::createFeature(const bool theFlushMess bool PartSet_OperationFeatureCreate::setWidgetValue(FeaturePtr theFeature, double theX, double theY) { ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature(); - aValue->setResult(theFeature->firstResult()); + aValue->setObject(theFeature); aValue->setPoint(boost::shared_ptr(new GeomAPI_Pnt2d(theX, theY))); bool isApplyed = myActiveWidget->setValue(aValue); diff --git a/src/PartSet/PartSet_OperationFeatureEdit.cpp b/src/PartSet/PartSet_OperationFeatureEdit.cpp index f3b27594e..5b107d34d 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.cpp +++ b/src/PartSet/PartSet_OperationFeatureEdit.cpp @@ -73,11 +73,11 @@ void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3 const std::list& theSelected, const std::list& theHighlighted) { - ResultPtr aFeature; + ObjectPtr aFeature; if (!theHighlighted.empty()) - aFeature = theHighlighted.front().result(); + aFeature = theHighlighted.front().object(); if (!aFeature && !theSelected.empty()) // changed for a constrain - aFeature = theSelected.front().result(); + aFeature = theSelected.front().object(); // TODO /*if (!aFeature || aFeature != feature()) { diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index c3391efb9..64ea866aa 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -91,7 +91,7 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie return; if (theHighlighted.size() == 1) { - ResultPtr aFeature = theHighlighted.front().result(); + ObjectPtr aFeature = theHighlighted.front().object(); if (aFeature) { std::string anOperationType = PartSet_OperationFeatureEdit::Type(); if (theSelected.size() > 1) @@ -117,7 +117,7 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi /// It is empty and we have to use the process mouse release to start edition operation /// for these objects if (theSelected.size() == 1) { - ResultPtr aFeature = theSelected.front().result(); + ObjectPtr aFeature = theSelected.front().object(); // TODO //if (aFeature) // restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature); diff --git a/src/PartSet/PartSet_TestOCC.cpp b/src/PartSet/PartSet_TestOCC.cpp index df5567aee..47e3cf870 100644 --- a/src/PartSet/PartSet_TestOCC.cpp +++ b/src/PartSet/PartSet_TestOCC.cpp @@ -150,9 +150,10 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop) boost::shared_ptr aPrevAIS; boost::shared_ptr aSPFeature = boost::dynamic_pointer_cast(aFeature); - boost::shared_ptr anAIS = aSPFeature->getAISObject(aPrevAIS); - if (!anAIS->empty()) - aDisplayer->redisplay(aFeature->firstResult(), anAIS, false); + //boost::shared_ptr anAIS = aSPFeature->getAISObject(aPrevAIS); + //if (!anAIS->empty()) + aDisplayer->display(aFeature, false); + //aDisplayer->redisplay(aFeature->firstResult(), anAIS, false); std::list aModes; aModes.push_back(TopAbs_VERTEX); @@ -207,9 +208,10 @@ void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop) boost::shared_ptr aPrevAIS; boost::shared_ptr aSPFeature = boost::dynamic_pointer_cast(aFeature); - boost::shared_ptr anAIS = aSPFeature->getAISObject(aPrevAIS); - if (!anAIS->empty()) - theWorkshop->displayer()->redisplay(aFeature, anAIS, true); + //boost::shared_ptr anAIS = aSPFeature->getAISObject(aPrevAIS); + //if (!anAIS->empty()) + theWorkshop->displayer()->display(aFeature, true); + // theWorkshop->displayer()->redisplay(aFeature, anAIS, true); //std::list aModes; //aModes.clear(); //aModes.push_back(TopAbs_VERTEX); diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index d0097bd4d..08c362a43 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -152,10 +152,10 @@ FeaturePtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theVie ModuleBase_ViewerPrs aPrs; for (; anIt != aLast; anIt++) { aPrs = *anIt; - if (!aPrs.result()) + if (!aPrs.object()) continue; boost::shared_ptr aSketchFeature = - boost::dynamic_pointer_cast(aPrs.result()); + boost::dynamic_pointer_cast(aPrs.object()); if (!aSketchFeature) continue; double aDelta = aSketchFeature->distanceToPoint( diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index 5fcab3c8b..66f96bf4f 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -9,13 +9,14 @@ #include #include #include +#include #include /**\class SketchPlugin_Sketch * \ingroup DataModel * \brief Feature for creation of the new part in PartSet. */ -class SketchPlugin_Sketch: public SketchPlugin_Feature +class SketchPlugin_Sketch: public SketchPlugin_Feature, public GeomAPI_IPresentable { public: /// Sketch feature kind diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 649e7f6bd..e013befb7 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -35,47 +36,56 @@ XGUI_Displayer::~XGUI_Displayer() { } -bool XGUI_Displayer::isVisible(ResultPtr theResult) +bool XGUI_Displayer::isVisible(ObjectPtr theObject) { - return myResult2AISObjectMap.find(theResult) != myResult2AISObjectMap.end(); + return myResult2AISObjectMap.find(theObject) != myResult2AISObjectMap.end(); } -bool XGUI_Displayer::display(ResultPtr theResult, bool isUpdateViewer) +void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer) { - boost::shared_ptr aShapePtr = ModuleBase_Tools::shape(theResult); - - if (aShapePtr) { - boost::shared_ptr anAIS(new GeomAPI_AISObject()); - anAIS->createShape(aShapePtr); - return display(theResult, anAIS, isUpdateViewer); + if (isVisible(theObject)) { + redisplay(theObject, isUpdateViewer); + } else { + boost::shared_ptr anAIS; + + ResultPtr aResult = boost::dynamic_pointer_cast(theObject); + if (aResult) { + boost::shared_ptr aShapePtr = ModuleBase_Tools::shape(aResult); + if (aShapePtr) { + anAIS = boost::shared_ptr(new GeomAPI_AISObject()); + anAIS->createShape(aShapePtr); + } + } else { + GeomPresentablePtr aPrs = boost::dynamic_pointer_cast(theObject); + if (aPrs) { + anAIS = aPrs->getAISObject(boost::shared_ptr()); + } + } + if (anAIS) + display(theObject, anAIS, isUpdateViewer); } - return false; } -bool XGUI_Displayer::display(ResultPtr theResult, +void XGUI_Displayer::display(ObjectPtr theObject, boost::shared_ptr theAIS, bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); Handle(AIS_InteractiveObject) anAISIO = theAIS->impl(); if (!anAISIO.IsNull()) { - myResult2AISObjectMap[theResult] = theAIS; + myResult2AISObjectMap[theObject] = theAIS; aContext->Display(anAISIO, isUpdateViewer); - return true; } - return false; } -void XGUI_Displayer::erase(ResultPtr theResult, - const bool isUpdateViewer) +void XGUI_Displayer::erase(ObjectPtr theObject, const bool isUpdateViewer) { - if (myResult2AISObjectMap.find(theResult) == myResult2AISObjectMap.end()) - return; + if (!isVisible(theObject)) return; Handle(AIS_InteractiveContext) aContext = AISContext(); - boost::shared_ptr anObject = myResult2AISObjectMap[theResult]; + boost::shared_ptr anObject = myResult2AISObjectMap[theObject]; if (anObject) { Handle(AIS_InteractiveObject) anAIS = anObject->impl(); if (!anAIS.IsNull()) { @@ -83,11 +93,11 @@ void XGUI_Displayer::erase(ResultPtr theResult, } } - myResult2AISObjectMap.erase(theResult); + myResult2AISObjectMap.erase(theObject); } -bool XGUI_Displayer::redisplay(ResultPtr theResult, +/*bool XGUI_Displayer::redisplay(ObjectPtr theObject, boost::shared_ptr theAIS, const bool isUpdateViewer) { @@ -98,43 +108,49 @@ bool XGUI_Displayer::redisplay(ResultPtr theResult, // Open local context if there is no one if (!aContext->HasOpenedContext()) { aContext->ClearCurrents(false); - aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/); + aContext->OpenLocalContext(false /use displayed objects/, true /allow shape decomposition/); // set mouse sensitivity //aContext->SetSensitivityMode(StdSelect_SM_WINDOW); //aContext->SetPixelTolerance(MOUSE_SENSITIVITY_IN_PIXEL); } // display or redisplay presentation - boost::shared_ptr anObj = myResult2AISObjectMap[theResult]; - if (isVisible(theResult) && anObj && !anObj->empty()) { - aContext->RecomputeSelectionOnly(anAIS); + boost::shared_ptr anObj = myResult2AISObjectMap[theObject]; + if (isVisible(theObject) && anObj && !anObj->empty()) { + aContext->Redisplay(anAIS, isUpdateViewer); + //aContext->RecomputeSelectionOnly(anAIS); } else { - myResult2AISObjectMap[theResult] = theAIS; - aContext->Display(anAIS, false); + myResult2AISObjectMap[theObject] = theAIS; + aContext->Display(anAIS, isUpdateViewer); isCreated = true; } - if (isUpdateViewer) - updateViewer(); - return isCreated; -} +}*/ -bool XGUI_Displayer::redisplay(ResultPtr theResult, bool isUpdateViewer) +void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer) { - if (!isVisible(theResult)) - return false; - - boost::shared_ptr aShapePtr = ModuleBase_Tools::shape(theResult); - if (aShapePtr) { - boost::shared_ptr aAISObj = getAISObject(theResult); - Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl()); - if (!aAISShape.IsNull()) { - aAISShape->Set(aShapePtr->impl()); - AISContext()->Redisplay(aAISShape); - return true; + if (!isVisible(theObject)) + return; + + ResultPtr aResult = boost::dynamic_pointer_cast(theObject); + if (aResult) { + boost::shared_ptr aShapePtr = ModuleBase_Tools::shape(aResult); + if (aShapePtr) { + boost::shared_ptr aAISObj = getAISObject(theObject); + Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl()); + if (!aAISShape.IsNull()) { + aAISShape->Set(aShapePtr->impl()); + AISContext()->Redisplay(aAISShape, isUpdateViewer); + } + } + } else { + GeomPresentablePtr aPrs = boost::dynamic_pointer_cast(theObject); + if (aPrs) { + boost::shared_ptr aAISObj = aPrs->getAISObject(getAISObject(theObject)); + Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl(); + AISContext()->Redisplay(aAISIO, isUpdateViewer); } } - return false; } void XGUI_Displayer::activateInLocalContext(ResultPtr theResult, @@ -254,10 +270,10 @@ void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer) ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), aFLast = myResult2AISObjectMap.end(); - std::list aRemoved; + std::list aRemoved; for (; aFIt != aFLast; aFIt++) { - ResultPtr aFeature = (*aFIt).first; + ObjectPtr aFeature = (*aFIt).first; if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) { boost::shared_ptr anObj = (*aFIt).second; if (!anObj) continue; @@ -268,7 +284,7 @@ void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer) } } } - std::list::const_iterator anIt = aRemoved.begin(), + std::list::const_iterator anIt = aRemoved.begin(), aLast = aRemoved.end(); for (; anIt != aLast; anIt++) { myResult2AISObjectMap.erase(myResult2AISObjectMap.find(*anIt)); @@ -283,18 +299,17 @@ void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer) closeAllContexts(true); } -boost::shared_ptr XGUI_Displayer::getAISObject( - ResultPtr theFeature) const +boost::shared_ptr XGUI_Displayer::getAISObject(ObjectPtr theObject) const { boost::shared_ptr anIO; - if (myResult2AISObjectMap.find(theFeature) != myResult2AISObjectMap.end()) - anIO = (myResult2AISObjectMap.find(theFeature))->second; + if (myResult2AISObjectMap.find(theObject) != myResult2AISObjectMap.end()) + anIO = (myResult2AISObjectMap.find(theObject))->second; return anIO; } -ResultPtr XGUI_Displayer::getResult(Handle(AIS_InteractiveObject) theIO) const +ObjectPtr XGUI_Displayer::getObject(Handle(AIS_InteractiveObject) theIO) const { - ResultPtr aFeature; + ObjectPtr aFeature; ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), aFLast = myResult2AISObjectMap.end(); for (; aFIt != aFLast && !aFeature; aFIt++) { diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index e047af515..9304bae9b 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -49,35 +49,13 @@ public: /// Returns the feature visibility state. /// \param theFeature a feature instance - bool isVisible(ResultPtr theResult); + bool isVisible(ObjectPtr theObject); /// 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(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(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(ResultPtr theFeature, - boost::shared_ptr theAIS, - const bool isUpdateViewer = true); - - /** Redisplay the shape if it was displayed - * \param theFeature a feature instance - * \param isUpdateViewer the parameter whether the viewer should be update immediatelly - */ - bool redisplay(ResultPtr theFeature, bool isUpdateViewer = true); + void display(ObjectPtr theObject, bool isUpdateViewer = true); /// Redisplay the shape and activate selection of sub-shapes /// \param theFeature a feature instance @@ -109,7 +87,7 @@ public: /// Erase the feature and a shape. /// \param theFeature a feature instance /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - void erase(ResultPtr theResult, const bool isUpdateViewer = true); + void erase(ObjectPtr theObject, const bool isUpdateViewer = true); /// Erase all presentations /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly @@ -129,12 +107,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(ResultPtr theFeature) const; + boost::shared_ptr getAISObject(ObjectPtr theFeature) const; /// Searches the feature by interactive object /// \param theIO an interactive object /// \return feature the feature or NULL if it not visualized - ResultPtr getResult(Handle(AIS_InteractiveObject) theIO) const; + ObjectPtr getObject(Handle(AIS_InteractiveObject) theIO) const; protected: /// Deactivate local selection @@ -144,10 +122,32 @@ protected: /// Returns currently installed AIS_InteractiveContext Handle(AIS_InteractiveContext) AISContext() const; + /// 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 + void display(ObjectPtr theObject, 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(ObjectPtr theObject, + // boost::shared_ptr theAIS, + // const bool isUpdateViewer = true); + + /** Redisplay the shape if it was displayed + * \param theFeature a feature instance + * \param isUpdateViewer the parameter whether the viewer should be update immediatelly + */ + void redisplay(ObjectPtr theObject, bool isUpdateViewer = true); + protected: XGUI_Workshop* myWorkshop; - typedef std::map > ResultToAISMap; + typedef std::map > ResultToAISMap; ResultToAISMap myResult2AISObjectMap; }; diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp index 05b4e0ea6..8e4636fb9 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; - ResultPtr aFeature = myWorkshop->displayer()->getResult(anIO); + ObjectPtr aFeature = myWorkshop->displayer()->getObject(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,7 +55,7 @@ std::list XGUI_Selection::getHighlighted(int theShapeTypeT if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip) continue; - ResultPtr aResult = myWorkshop->displayer()->getResult(anIO); + ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO); if (aPrsFeatures.find(aResult) != aPrsFeatures.end()) continue; aPresentations.push_back(ModuleBase_ViewerPrs(aResult, aShape, NULL)); @@ -70,14 +70,14 @@ QList XGUI_Selection::selectedObjects() const return myWorkshop->objectBrowser()->selectedObjects(); } -QResultList XGUI_Selection::selectedResults() const +QList XGUI_Selection::selectedPresentations() const { - QResultList aSelectedList; + QList 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); + ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO); if (aResult) aSelectedList.append(aResult); } diff --git a/src/XGUI/XGUI_Selection.h b/src/XGUI/XGUI_Selection.h index 9202e97bb..dd3b48586 100644 --- a/src/XGUI/XGUI_Selection.h +++ b/src/XGUI/XGUI_Selection.h @@ -43,7 +43,7 @@ public: /** * Returns list of currently selected results */ - virtual QResultList selectedResults() const; + virtual QList selectedPresentations() const; //! Returns list of currently selected QModelIndexes virtual QModelIndexList selectedIndexes() const; diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index dc5db4e2b..481db7336 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -61,7 +61,7 @@ void XGUI_SelectionMgr::onViewerSelection() 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); + ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO); if (aResult) aFeatures.append(aResult); } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 9f2d068a2..b04756212 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -305,40 +305,33 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theM { std::set aObjects = theMsg->objects(); std::set::const_iterator aIt; - bool isDisplayed = false; for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { ObjectPtr aObj = (*aIt); - ResultPtr aRes = boost::dynamic_pointer_cast(aObj); - if (aRes) { - if (aRes->data()) - isDisplayed = myDisplayer->redisplay(aRes, false); - else { - myDisplayer->erase(aRes, false); - isDisplayed = true; - } + if (aObj->data()) + myDisplayer->display(aObj, false); + else { + myDisplayer->erase(aObj, false); } } - if (isDisplayed) - myDisplayer->updateViewer(); + myDisplayer->updateViewer(); } //****************************************************** void XGUI_Workshop::onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg) { - std::set aFeatures = theMsg->objects(); + std::set aObjects = theMsg->objects(); std::set::const_iterator aIt; bool aHasPart = false; bool isDisplayed = false; - for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) { + for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { ResultPartPtr aPart = boost::dynamic_pointer_cast(*aIt); if (aPart) { aHasPart = true; //break; } else { - ResultPtr aRes = boost::dynamic_pointer_cast(*aIt); - if (aRes) - isDisplayed = myDisplayer->display(aRes, false); + myDisplayer->display(*aIt, false); + isDisplayed = true; } } if (isDisplayed)