Salome HOME
GeomAPI_IPresentation in terface created
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 17 Jul 2014 08:27:48 +0000 (12:27 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 17 Jul 2014 08:27:48 +0000 (12:27 +0400)
19 files changed:
src/GeomAPI/CMakeLists.txt
src/GeomAPI/GeomAPI_IPresentable.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_ISelection.h
src/ModuleBase/ModuleBase_ViewerPrs.h
src/ModuleBase/ModuleBase_WidgetValueFeature.cpp
src/ModuleBase/ModuleBase_WidgetValueFeature.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_OperationFeatureEdit.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_TestOCC.cpp
src/PartSet/PartSet_Tools.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_Selection.cpp
src/XGUI/XGUI_Selection.h
src/XGUI/XGUI_SelectionMgr.cpp
src/XGUI/XGUI_Workshop.cpp

index e4bd74bf94f60e02d435a7b3bddca9ada1e095ab..e13d4b27048c5da6b489893bffb70c124f77cad3 100644 (file)
@@ -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 (file)
index 0000000..b28ed8b
--- /dev/null
@@ -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<GeomAPI_AISObject> getAISObject(
+                            boost::shared_ptr<GeomAPI_AISObject> thePrevious) = 0;
+};
+
+typedef boost::shared_ptr<GeomAPI_IPresentable> GeomPresentablePtr;
+
+#endif
\ No newline at end of file
index 9a9e52ed7d94c4c4e290c08160062d22180471e3..33d617de990a71485a8fcab18071c2e6ef7b3d6d 100644 (file)
@@ -38,7 +38,7 @@ public:
   /**
   * Returns list of currently selected results
   */
-  virtual QResultList selectedResults() const = 0;
+  virtual QList<ObjectPtr> selectedPresentations() const = 0;
   
   //! Returns list of currently selected QModelIndexes
   virtual QModelIndexList selectedIndexes() const = 0;
index 274ec2c2aed7e0d78fc0a785cb2b14f5620feb27..4ef5e5bad6e5affbfac1912c568a1fdc240f5a53 100644 (file)
@@ -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
 };
index da9fe5fd354f7c2f5ca58178a398f60233dfcd38..e6a4f818c71b465c2842b37a7f5ced7566376e98 100644 (file)
@@ -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;
 }
index 2de332108f08e3186498abd6d2cab38e70a46d50..1a1f10164d96777536fc5dd93e5842df3b28309c 100644 (file)
@@ -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<GeomAPI_Pnt2d>& point() const;
 
 private:
-  ResultPtr myResult;
+  ObjectPtr myResult;
   boost::shared_ptr<GeomAPI_Pnt2d> myPoint;
 };
 
index 84a9ec96f1c121ca210bd74a0fa487fc529a99dc..fc2ffb51bb4fc85431ca5ec362c9ce0f1d895cf6 100644 (file)
@@ -461,9 +461,10 @@ void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
     boost::shared_ptr<SketchPlugin_Feature> aSPFeature = 
       boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
     if (aSPFeature) {
-      boost::shared_ptr<GeomAPI_AISObject> anAIS = 
-        aSPFeature->getAISObject(aDisplayer->getAISObject(aResult));
-      aDisplayer->redisplay(aResult, anAIS, false);
+      //boost::shared_ptr<GeomAPI_AISObject> anAIS = 
+      //  aSPFeature->getAISObject(aDisplayer->getAISObject(aResult));
+      aDisplayer->display(aSPFeature, false);
+      //aDisplayer->redisplay(aResult, anAIS, false);
     }
   }
   else
index f08d83972f67e4fd554625036240b6962221400a..2e96339ff2fdeb63b218cee443259e817be9a3c3 100644 (file)
@@ -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<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
   bool isApplyed = myActiveWidget->setValue(aValue);
 
index f3b27594e6362b6cc24dc16c30bd6fac8a940657..5b107d34dcba5b93336278c02222f8f04c450558 100644 (file)
@@ -73,11 +73,11 @@ void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3
                                              const std::list<ModuleBase_ViewerPrs>& theSelected,
                                              const std::list<ModuleBase_ViewerPrs>& 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())
   {
index c3391efb91641d8bd248b15d0b24e16ba7f12c45..64ea866aad49339dfd8627eb017214612e16e312 100644 (file)
@@ -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);
index df5567aee9e6ffc55b1d4dd64b3d3cc4678ead72..47e3cf87052a94de060529151200c4d155d9cdf0 100644 (file)
@@ -150,9 +150,10 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
     boost::shared_ptr<GeomAPI_AISObject> aPrevAIS;
     boost::shared_ptr<SketchPlugin_Feature> aSPFeature = 
       boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-    boost::shared_ptr<GeomAPI_AISObject> anAIS = aSPFeature->getAISObject(aPrevAIS);
-    if (!anAIS->empty())
-      aDisplayer->redisplay(aFeature->firstResult(), anAIS, false);
+    //boost::shared_ptr<GeomAPI_AISObject> anAIS = aSPFeature->getAISObject(aPrevAIS);
+    //if (!anAIS->empty())
+    aDisplayer->display(aFeature, false);
+      //aDisplayer->redisplay(aFeature->firstResult(), anAIS, false);
 
     std::list<int> aModes;
     aModes.push_back(TopAbs_VERTEX);
@@ -207,9 +208,10 @@ void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop)
   boost::shared_ptr<GeomAPI_AISObject> aPrevAIS;
   boost::shared_ptr<SketchPlugin_Feature> aSPFeature = 
     boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-  boost::shared_ptr<GeomAPI_AISObject> anAIS = aSPFeature->getAISObject(aPrevAIS);
-  if (!anAIS->empty())
-    theWorkshop->displayer()->redisplay(aFeature, anAIS, true);
+  //boost::shared_ptr<GeomAPI_AISObject> anAIS = aSPFeature->getAISObject(aPrevAIS);
+  //if (!anAIS->empty())
+  theWorkshop->displayer()->display(aFeature, true);
+  //  theWorkshop->displayer()->redisplay(aFeature, anAIS, true);
   //std::list<int> aModes;
   //aModes.clear();
   //aModes.push_back(TopAbs_VERTEX);
index d0097bd4dedf3036aec6e942ef4894ea3175b513..08c362a43594b86fe7323de9554cfb7555a512e8 100644 (file)
@@ -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<SketchPlugin_Feature> aSketchFeature = 
-                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(aPrs.result());
+                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(aPrs.object());
     if (!aSketchFeature)
       continue;
     double aDelta = aSketchFeature->distanceToPoint(
index 5fcab3c8b826ab83255979e70b7f4028acbf0124..66f96bf4f736c736d0c74cb6680fd00acc937ab3 100644 (file)
@@ -9,13 +9,14 @@
 #include <SketchPlugin_Feature.h>
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Pln.h>
+#include <GeomAPI_IPresentable.h>
 #include <list>
 
 /**\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
index 649e7f6bd5d80b7799e7c9af967a4ba8cd91a7dc..e013befb7b2d0a48f4fcfd5d341c6214771eebcb 100644 (file)
@@ -13,6 +13,7 @@
 #include <ModelAPI_Object.h>
 
 #include <GeomAPI_Shape.h>
+#include <GeomAPI_IPresentable.h>
 
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_LocalContext.hxx>
@@ -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<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(theResult);
-
-  if (aShapePtr) {
-    boost::shared_ptr<GeomAPI_AISObject> anAIS(new GeomAPI_AISObject());
-    anAIS->createShape(aShapePtr);
-    return display(theResult, anAIS, isUpdateViewer);
+  if (isVisible(theObject)) {
+    redisplay(theObject, isUpdateViewer);
+  } else {
+    boost::shared_ptr<GeomAPI_AISObject> anAIS;
+
+    ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    if (aResult) {
+      boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(aResult);
+      if (aShapePtr) {
+        anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
+        anAIS->createShape(aShapePtr);
+      }
+    } else {
+      GeomPresentablePtr aPrs = boost::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
+      if (aPrs) {
+        anAIS = aPrs->getAISObject(boost::shared_ptr<GeomAPI_AISObject>());
+      }
+    }
+    if (anAIS)
+      display(theObject, anAIS, isUpdateViewer);
   }
-  return false;
 }
 
-bool XGUI_Displayer::display(ResultPtr theResult,
+void XGUI_Displayer::display(ObjectPtr theObject,
                              boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
 
   Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
   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<GeomAPI_AISObject> anObject = myResult2AISObjectMap[theResult];
+  boost::shared_ptr<GeomAPI_AISObject> anObject = myResult2AISObjectMap[theObject];
   if (anObject)  {
     Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
     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<GeomAPI_AISObject> 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<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theResult];
-  if (isVisible(theResult) && anObj && !anObj->empty()) {
-      aContext->RecomputeSelectionOnly(anAIS);
+  boost::shared_ptr<GeomAPI_AISObject> 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<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(theResult);
-  if (aShapePtr) {
-    boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theResult);
-    Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl<Handle(AIS_InteractiveObject)>());
-    if (!aAISShape.IsNull()) {
-      aAISShape->Set(aShapePtr->impl<TopoDS_Shape>());
-      AISContext()->Redisplay(aAISShape);
-      return true;
+  if (!isVisible(theObject))
+    return;
+
+  ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+  if (aResult) {
+    boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(aResult);
+    if (aShapePtr) {
+      boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theObject);
+      Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl<Handle(AIS_InteractiveObject)>());
+      if (!aAISShape.IsNull()) {
+        aAISShape->Set(aShapePtr->impl<TopoDS_Shape>());
+        AISContext()->Redisplay(aAISShape, isUpdateViewer);
+      }
+    }
+  } else {
+    GeomPresentablePtr aPrs = boost::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
+    if (aPrs) {
+      boost::shared_ptr<GeomAPI_AISObject> aAISObj = aPrs->getAISObject(getAISObject(theObject));
+      Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+      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<ResultPtr> aRemoved;
+  std::list<ObjectPtr> aRemoved;
   for (; aFIt != aFLast; aFIt++)
   {
-    ResultPtr aFeature = (*aFIt).first;
+    ObjectPtr aFeature = (*aFIt).first;
     if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) {
       boost::shared_ptr<GeomAPI_AISObject> anObj = (*aFIt).second;
       if (!anObj) continue;
@@ -268,7 +284,7 @@ void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer)
       }
     }
   }
-  std::list<ResultPtr>::const_iterator anIt = aRemoved.begin(),
+  std::list<ObjectPtr>::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<GeomAPI_AISObject> XGUI_Displayer::getAISObject(
-                                              ResultPtr theFeature) const
+boost::shared_ptr<GeomAPI_AISObject> XGUI_Displayer::getAISObject(ObjectPtr theObject) const
 {
   boost::shared_ptr<GeomAPI_AISObject> 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++) {
index e047af515d0da44e9ec35017b378781364b47018..9304bae9bccaab7d1cfc67fe42af47bdbe760389 100644 (file)
@@ -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<GeomAPI_AISObject> 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<GeomAPI_AISObject> 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<GeomAPI_AISObject> getAISObject(ResultPtr theFeature) const;
+  boost::shared_ptr<GeomAPI_AISObject> 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<GeomAPI_AISObject> 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<GeomAPI_AISObject> 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<ResultPtr, boost::shared_ptr<GeomAPI_AISObject> > ResultToAISMap;
+  typedef std::map<ObjectPtr, boost::shared_ptr<GeomAPI_AISObject> > ResultToAISMap;
   ResultToAISMap myResult2AISObjectMap;
 };
 
index 05b4e0ea6d95cf5b8886669138589ef70a0b2339..8e4636fb92b07e38ab0160022ba5d1c9ec61654b 100644 (file)
@@ -22,7 +22,7 @@ XGUI_Selection::XGUI_Selection(XGUI_Workshop* theWorkshop)
 
 std::list<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSkip) const
 {
-  std::set<ResultPtr> aPrsFeatures;
+  std::set<ObjectPtr> aPrsFeatures;
   std::list<ModuleBase_ViewerPrs> aPresentations;
 
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
@@ -33,7 +33,7 @@ std::list<ModuleBase_ViewerPrs> 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<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSk
 
 std::list<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted(int theShapeTypeToSkip) const
 {
-  std::set<ResultPtr> aPrsFeatures;
+  std::set<ObjectPtr> aPrsFeatures;
   std::list<ModuleBase_ViewerPrs> aPresentations;
 
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
@@ -55,7 +55,7 @@ std::list<ModuleBase_ViewerPrs> 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<ObjectPtr> XGUI_Selection::selectedObjects() const
   return myWorkshop->objectBrowser()->selectedObjects();
 }
   
-QResultList XGUI_Selection::selectedResults() const
+QList<ObjectPtr> XGUI_Selection::selectedPresentations() const
 {
-  QResultList aSelectedList;
+  QList<ObjectPtr> 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);
   }
index 9202e97bb748fb8d9a8a8337fc11f96979e1f9d9..dd3b48586ca5b0b0d9291a7e26bb1c50bbf91e0e 100644 (file)
@@ -43,7 +43,7 @@ public:
   /**
   * Returns list of currently selected results
   */
-  virtual QResultList selectedResults() const;
+  virtual QList<ObjectPtr> selectedPresentations() const;
   
   //! Returns list of currently selected QModelIndexes
   virtual QModelIndexList selectedIndexes() const;
index dc5db4e2b604334dac71bceb7ca3f5a1a7e7babd..481db73366a3a4f06714ef767a03a414fbefd2fa 100644 (file)
@@ -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);
   }
index 9f2d068a229830fdc8a78e37ec355f385a43a13b..b047562126338358a2e1aa3da493d386a3549bdc 100644 (file)
@@ -305,40 +305,33 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theM
 {
   std::set<ObjectPtr> aObjects = theMsg->objects();
   std::set<ObjectPtr>::const_iterator aIt;
-  bool isDisplayed = false;
   for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
     ObjectPtr aObj = (*aIt);
-    ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(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<ObjectPtr> aFeatures = theMsg->objects();
+  std::set<ObjectPtr> aObjects = theMsg->objects();
 
   std::set<ObjectPtr>::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<ModelAPI_ResultPart>(*aIt);
     if (aPart) {
       aHasPart = true;
       //break;
     } else {
-      ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(*aIt);
-      if (aRes)
-        isDisplayed = myDisplayer->display(aRes, false);
+      myDisplayer->display(*aIt, false);
+      isDisplayed = true;
     }
   }
   if (isDisplayed)