]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Create sketch with new model architecture
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 17 Jul 2014 13:29:59 +0000 (17:29 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 17 Jul 2014 13:29:59 +0000 (17:29 +0400)
13 files changed:
src/GeomAPI/GeomAPI_AISObject.cpp
src/GeomAPI/GeomAPI_AISObject.h
src/ModuleBase/ModuleBase_ViewerPrs.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_Selection.cpp

index 5ed7c01d1d0911f1b9147493765e8873c2a976f7..b2bb96faf0dcb7b2cb81c7fd7ebf3505cdec6fa9 100644 (file)
@@ -29,6 +29,9 @@ const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection toler
 
 // Initialization of color constants
 int Colors::COLOR_BROWN = Quantity_NOC_BROWN;
+int Colors::COLOR_RED = Quantity_NOC_RED;
+int Colors::COLOR_GREEN = Quantity_NOC_GREEN;
+int Colors::COLOR_BLUE = Quantity_NOC_BLUE1;
 
 
 GeomAPI_AISObject::GeomAPI_AISObject()
index d3f23859186552521fabc6af4cd2e5cb3af3e5f1..afd7ee95f0724d20d0cb23b1aa70732537ce768c 100644 (file)
@@ -18,6 +18,9 @@ class GeomAPI_Shape;
 struct GEOMAPI_EXPORT Colors
 {
   static int COLOR_BROWN;
+  static int COLOR_RED;
+  static int COLOR_GREEN;
+  static int COLOR_BLUE;
 };
 
 /** \class GeomAPI_AISObject
index 4ef5e5bad6e5affbfac1912c568a1fdc240f5a53..a365c753ab92f961b6699392020bd21df6e1cb34 100644 (file)
@@ -10,6 +10,7 @@
 #include <boost/shared_ptr.hpp>
 #include <TopoDS_Shape.hxx>
 #include <SelectMgr_EntityOwner.hxx>
+#include <AIS_InteractiveObject.hxx>
 
 #include <ModelAPI_Result.h>
 
@@ -59,18 +60,24 @@ public:
   /// \return a shape instance
   const TopoDS_Shape& shape() const { return myShape; }
 
+  void setInteractive(const Handle(AIS_InteractiveObject)& theIO) { myInteractive = theIO; }
+
+  Handle(AIS_InteractiveObject) interactive() const { return myInteractive; }
+
   bool operator==(const ModuleBase_ViewerPrs& thePrs)
   {
     bool aResult = (myResult.get() == thePrs.object().get());
     bool aOwner = (myOwner.Access() == thePrs.owner().Access());
     bool aShape = myShape.IsEqual(thePrs.shape());
-    return aResult && aOwner && aShape;
+    bool aIO = myInteractive == thePrs.interactive();
+    return aResult && aOwner && aShape && aIO;
   }
 
 private:
   ObjectPtr myResult; /// the feature
   Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner
   TopoDS_Shape myShape; /// the shape
+  Handle(AIS_InteractiveObject) myInteractive;
 };
 
 #endif
index fc2ffb51bb4fc85431ca5ec362c9ce0f1d895cf6..4999e4f53ef03d6d221634c176eb9ca8563a21c1 100644 (file)
 
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_AISObject.h>
+#include <AIS_Shape.hxx>
 
 #include <QObject>
 #include <QMouseEvent>
 #include <QString>
 
+#include <GeomAlgoAPI_FaceBuilder.h>
+#include <GeomDataAPI_Dir.h>
+
 #ifdef _DEBUG
 #include <QDebug>
 #endif
 
+
+//const int SKETCH_PLANE_COLOR = Colors::COLOR_BROWN; /// the plane edge color
+const double SKETCH_WIDTH = 4.0; /// the plane edge width
+// face of the square-face displayed for selection of general plane
+const double PLANE_SIZE = 200;
+
+
 /*!Create and return new instance of XGUI_Module*/
 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(XGUI_Workshop* theWshop)
 {
@@ -212,14 +223,26 @@ void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
 {
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
                                        myWorkshop->operationMgr()->currentOperation());
-  if (aPreviewOp)
-  {
+  if (aPreviewOp) {
     XGUI_Selection* aSelection = myWorkshop->selector()->selection();
     // Initialise operation with preliminary selection
     std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
     std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
 
-    aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
+    PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
+    if (aSketchOp) {
+      if ((!aSketchOp->hasSketchPlane()) && (aSelected.size() > 0)) {
+        Handle(AIS_InteractiveObject) aAIS = aSelected.front().interactive();
+        if ((aAIS == myXPlane->impl<Handle(AIS_InteractiveObject)>()) ||
+            (aAIS == myYPlane->impl<Handle(AIS_InteractiveObject)>()) ||
+            (aAIS == myZPlane->impl<Handle(AIS_InteractiveObject)>()) ) {
+
+          Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAIS);
+          aSketchOp->setSketchPlane(aAISShape->Shape());
+        }
+      }
+    } else
+      aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
   }
 }
 
@@ -257,6 +280,7 @@ void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
 
 void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
 {
+  erasePlanes();
   myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
   myWorkshop->actionsMgr()->update();
 
@@ -444,6 +468,53 @@ void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
   Events_Loop::loop()->send(aMessage);
 }
 
+boost::shared_ptr<GeomAPI_Shape> getPlane(double theX, double theY, double theZ)
+{
+  boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
+  boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
+  return GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
+}
+
+void PartSet_Module::showPlanes()
+{
+  XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+  // Show selection planes
+  if (!myXPlane) {
+    boost::shared_ptr<GeomAPI_Shape> aPlaneX = getPlane(1, 0, 0);
+    myXPlane = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
+    myXPlane->createShape(aPlaneX);
+    myXPlane->setColor(Colors::COLOR_RED);
+    myXPlane->setWidth(SKETCH_WIDTH);
+  }
+  if (!myYPlane) {
+    boost::shared_ptr<GeomAPI_Shape> aPlaneY = getPlane(0, 1, 0);
+    myYPlane = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
+    myYPlane->createShape(aPlaneY);
+    myYPlane->setColor(Colors::COLOR_GREEN);
+    myYPlane->setWidth(SKETCH_WIDTH);
+  }
+  if (!myZPlane) {
+    boost::shared_ptr<GeomAPI_Shape> aPlaneZ = getPlane(0, 0, 1);
+    myZPlane = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
+    myZPlane->createShape(aPlaneZ);
+    myZPlane->setColor(Colors::COLOR_BLUE);
+    myZPlane->setWidth(SKETCH_WIDTH);
+  }
+  aDisplayer->display(myXPlane, false);
+  aDisplayer->display(myYPlane, false);
+  aDisplayer->display(myZPlane, false);
+  aDisplayer->updateViewer();
+}
+
+void PartSet_Module::erasePlanes()
+{
+  XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+  aDisplayer->erase(myXPlane, false);
+  aDisplayer->erase(myYPlane, false);
+  aDisplayer->erase(myZPlane, false);
+  aDisplayer->updateViewer();
+}
+
 void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
                                       const bool isUpdateViewer)
 {
@@ -461,9 +532,9 @@ void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
     boost::shared_ptr<SketchPlugin_Feature> aSPFeature = 
       boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
     if (aSPFeature) {
+      showPlanes();
       //boost::shared_ptr<GeomAPI_AISObject> anAIS = 
       //  aSPFeature->getAISObject(aDisplayer->getAISObject(aResult));
-      aDisplayer->display(aSPFeature, false);
       //aDisplayer->redisplay(aResult, anAIS, false);
     }
   }
@@ -478,11 +549,11 @@ void PartSet_Module::activateFeature(FeaturePtr theFeature, const bool isUpdateV
 {
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-  if (aPreviewOp) {
+/* TODO  if (aPreviewOp) {
     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
     aDisplayer->activateInLocalContext(theFeature->firstResult(), aPreviewOp->getSelectionModes(theFeature),
                                        isUpdateViewer);
-  }
+  }*/
 }
 
 void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
index 4133472f1f6f059276b9e66a3bfb56c1d234bb6f..83bb0b2d08c89c3c34563c33711c01fea57709b4 100644 (file)
@@ -21,6 +21,7 @@ class PartSet_Listener;
 class ModelAPI_Feature;
 class XGUI_ViewerPrs;
 class ModuleBase_Operation;
+class GeomAPI_AISObject;
 
 class PARTSET_EXPORT PartSet_Module: public ModuleBase_IModule
 {
@@ -156,11 +157,20 @@ protected:
   //! Edits the feature
   void editFeature(FeaturePtr theFeature);
 
+
+  //! Shopws working planes in viewer 3d
+  void showPlanes();
+  void erasePlanes();
+
 private:
   XGUI_Workshop* myWorkshop;
   PartSet_Listener* myListener;
 
   std::map<std::string, std::string> myFeaturesInFiles;
+
+  boost::shared_ptr<GeomAPI_AISObject> myXPlane;
+  boost::shared_ptr<GeomAPI_AISObject> myYPlane;
+  boost::shared_ptr<GeomAPI_AISObject> myZPlane;
 };
 
 #endif
index 64ea866aad49339dfd8627eb017214612e16e312..c209af34b548f27dbd995f8143850206d5d77cc3 100644 (file)
@@ -37,6 +37,7 @@
 
 using namespace std;
 
+
 PartSet_OperationSketch::PartSet_OperationSketch(const QString& theId,
                                                     QObject* theParent)
 : PartSet_OperationSketchBase(theId, theParent)
@@ -75,15 +76,7 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie
                                            const std::list<ModuleBase_ViewerPrs>& theSelected,
                                            const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
-  if (!hasSketchPlane()) {
-    if (!theHighlighted.empty()) {
-      ModuleBase_ViewerPrs aPrs = theHighlighted.front();
-      const TopoDS_Shape& aShape = aPrs.shape();
-      if (!aShape.IsNull())
-        setSketchPlane(aShape);
-    }
-  }
-  else {
+  if (hasSketchPlane()){
     // if shift button is pressed and there are some already selected objects, the operation should
     // not be started. We just want to combine some selected objects.
     bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
@@ -109,9 +102,7 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi
                                             const std::list<ModuleBase_ViewerPrs>& theSelected,
                                             const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
-  if (!hasSketchPlane()) {
-  }
-  else {
+  if (hasSketchPlane()) {
     /// TODO: OCC bug: 25034 - the highlighted list should be filled not only for AIS_Shape
     /// but for other IO, for example constraint dimensions.
     /// It is empty and we have to use the process mouse release to start edition operation
@@ -169,6 +160,7 @@ bool PartSet_OperationSketch::isNestedOperationsEnabled() const
   return hasSketchPlane();
 }
 
+
 void PartSet_OperationSketch::startOperation()
 {
   PartSet_OperationSketchBase::startOperation();
index bf8694bb580f7fc90747cf9fe39a3effbe16418b..826baf39d1e885fb16d408d97fd0a13cfc555528 100644 (file)
@@ -86,6 +86,10 @@ public:
   /// \return the boolean value whether the sketch is set
   bool hasSketchPlane() const;
 
+  /// Set the plane to the current sketch
+  /// \param theShape the shape
+  void setSketchPlane(const TopoDS_Shape& theShape);
+
 signals:
   /// signal about the sketch plane is selected
   /// \param theX the value in the X direction of the plane
@@ -100,10 +104,6 @@ protected:
   /// Default impl calls corresponding slot and commits immediately.
   virtual void startOperation();
 
-  /// Set the plane to the current sketch
-  /// \param theShape the shape
-  void setSketchPlane(const TopoDS_Shape& theShape);
-
 private:
   std::list<ModuleBase_ViewerPrs> myFeatures; ///< the features to apply the edit operation
 };
index 6f1b3a66c691cdd62749826ac90fa460844c3af1..7bd7ac8d7f6877f68a5e50af4e99eb19ea62ba73 100644 (file)
@@ -23,10 +23,6 @@ class Handle_AIS_InteractiveObject;
 class SketchPlugin_Feature: public ModelAPI_Feature
 {
 public:
-  /// Returns the AIS preview
-  SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
-                                boost::shared_ptr<GeomAPI_AISObject> thePrevious) = 0;
-
   /// Simple creation of interactive object by the result of the object
   static boost::shared_ptr<GeomAPI_AISObject> simpleAISObject(
     boost::shared_ptr<ModelAPI_Result> theRes, boost::shared_ptr<GeomAPI_AISObject> thePrevious);
index dbfb247824c0f6c6fed9a1ab6e5cb5edd8fe1721..1f0e100ac37bd6286dd20e2bd6e5dbf451262aa6 100644 (file)
 #include <ModelAPI_ResultConstruction.h>
 
 
-const int SKETCH_PLANE_COLOR = Colors::COLOR_BROWN; /// the plane edge color
-const double SKETCH_WIDTH = 4.0; /// the plane edge width
-
 using namespace std;
 
-// face of the square-face displayed for selection of general plane
-const double PLANE_SIZE = 200;
-
 SketchPlugin_Sketch::SketchPlugin_Sketch()
 {
 }
@@ -38,19 +32,6 @@ void SketchPlugin_Sketch::initAttributes()
 
 void SketchPlugin_Sketch::execute() 
 {
-  if (!isPlaneSet()) {
-    std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
-
-    addPlane(1, 0, 0, aFaces); // YZ plane
-    addPlane(0, 1, 0, aFaces); // XZ plane
-    addPlane(0, 0, 1, aFaces); // XY plane
-    boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
-    boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = 
-      document()->createConstruction(data());
-    aConstr->setShape(aCompound);
-    setResult(aConstr);
-    return;
-  }
   if (!data()->isValid())
     return ;
   boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
@@ -97,32 +78,12 @@ void SketchPlugin_Sketch::execute()
   setResult(aConstr);
 }
 
-boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Sketch::getAISObject(
-                                boost::shared_ptr<GeomAPI_AISObject> thePrevious)
-{
-  boost::shared_ptr<GeomAPI_AISObject> aResult = simpleAISObject(firstResult(), thePrevious);
-  aResult->setColor(SKETCH_PLANE_COLOR);
-  aResult->setWidth(SKETCH_WIDTH);
-  //anAIS->Redisplay();
-  return aResult;
-}
-
 const void SketchPlugin_Sketch::addSub(const FeaturePtr& theFeature)
 {
   boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature)->setSketch(this);
   data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->append(theFeature);
 }
 
-void SketchPlugin_Sketch::addPlane(double theX, double theY, double theZ,
-                                   std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const
-{
-  boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
-  boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
-  boost::shared_ptr<GeomAPI_Shape> aFace = 
-    GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
-  theShapes.push_back(aFace);
-}
-
 boost::shared_ptr<GeomAPI_Pnt> SketchPlugin_Sketch::to3D(const double theX, const double theY)
 {
   boost::shared_ptr<GeomDataAPI_Point> aC = 
index 66f96bf4f736c736d0c74cb6680fd00acc937ab3..4fd2a58eb636b0db623407a9b33b8bbe69f00cf9 100644 (file)
@@ -9,14 +9,13 @@
 #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, public GeomAPI_IPresentable
+class SketchPlugin_Sketch: public SketchPlugin_Feature
 {
 public:
   /// Sketch feature kind
@@ -66,10 +65,6 @@ public:
   /// Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
-  /// Returns the AIS preview
-  SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
-                                boost::shared_ptr<GeomAPI_AISObject> thePrevious);
-
   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
   /// \param theFeature sub-feature
   SKETCHPLUGIN_EXPORT virtual const void addSub(
@@ -102,8 +97,8 @@ protected:
   /// \param theY the Y normal value
   /// \param theZ the Z normal value
   /// \param theShapes the list of result shapes
-  void addPlane(double theX, double theY, double theZ,
-                std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const;
+  //void addPlane(double theX, double theY, double theZ,
+  //              std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const;
 
   /// Checks whether the plane is set in the sketch.
   /// \returns the boolean state
index e013befb7b2d0a48f4fcfd5d341c6214771eebcb..92ae9d2a4b4b5ae98788c909f14474723c03e1ff 100644 (file)
@@ -90,7 +90,6 @@ void XGUI_Displayer::erase(ObjectPtr theObject, const bool isUpdateViewer)
     Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
     if (!anAIS.IsNull()) {
       aContext->Erase(anAIS, isUpdateViewer);
-      
     }
   }
   myResult2AISObjectMap.erase(theObject);
@@ -344,3 +343,22 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
 { 
   return myWorkshop->viewer()->AISContext(); 
 }
+
+
+void XGUI_Displayer::display(boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdate)
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
+  if (!anAISIO.IsNull())
+    aContext->Display(anAISIO, isUpdate);
+}
+
+void XGUI_Displayer::erase(boost::shared_ptr<GeomAPI_AISObject> theAIS, const bool isUpdate)
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
+  if (!anAISIO.IsNull()) {
+    aContext->Remove(anAISIO, isUpdate);
+  }
+}
+
index 9304bae9bccaab7d1cfc67fe42af47bdbe760389..df65443a87164d3493862be1e3cf8ebebb9516ec 100644 (file)
@@ -57,6 +57,9 @@ public:
   /// Returns true if the Feature succesfully displayed
   void display(ObjectPtr theObject, bool isUpdateViewer = true);
 
+  /// Display the given AIS object. To hide this object use corresponde erase method
+  void display(boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdate = true);
+
   /// Redisplay the shape and activate selection of sub-shapes
   /// \param theFeature a feature instance
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
@@ -89,6 +92,9 @@ public:
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   void erase(ObjectPtr theObject, const bool isUpdateViewer = true);
 
+  /// Erase the given AIS object displayed by corresponded display method
+  void erase(boost::shared_ptr<GeomAPI_AISObject> theAIS, const bool isUpdate = true);
+
   /// Erase all presentations
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   //void EraseAll(const bool isUpdateViewer = true);
index 8e4636fb92b07e38ab0160022ba5d1c9ec61654b..b42f8c4b9926c24334bde2944e658ebb099a8fe6 100644 (file)
@@ -24,21 +24,28 @@ std::list<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSk
 {
   std::set<ObjectPtr> aPrsFeatures;
   std::list<ModuleBase_ViewerPrs> aPresentations;
+  XGUI_Displayer* aDisplayer = myWorkshop->displayer();
 
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
-    Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
-    TopoDS_Shape aShape = aContext->SelectedShape();
+    ModuleBase_ViewerPrs aPrs;
 
-    if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip)
-      continue;
-
-    ObjectPtr aFeature = myWorkshop->displayer()->getObject(anIO);
-    if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
-      continue;
+    Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
+    aPrs.setInteractive(anIO);
+
+    ObjectPtr aFeature = aDisplayer->getObject(anIO);
+    if (aPrsFeatures.find(aFeature) == aPrsFeatures.end()) {
+      aPrs.setFeature(aFeature);
+      aPrsFeatures.insert(aFeature);
+    }
+    if (aContext->HasOpenedContext()) {
+      TopoDS_Shape aShape = aContext->SelectedShape();
+      if (!aShape.IsNull() && (aShape.ShapeType() != theShapeTypeToSkip))
+        aPrs.setShape(aShape);
+    }
     Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
-    aPresentations.push_back(ModuleBase_ViewerPrs(aFeature, aShape, anOwner));
-    aPrsFeatures.insert(aFeature);
+    aPrs.setOwner(anOwner);
+    aPresentations.push_back(aPrs);
   }
   return aPresentations;
 }
@@ -47,21 +54,26 @@ std::list<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted(int theShapeTypeT
 {
   std::set<ObjectPtr> aPrsFeatures;
   std::list<ModuleBase_ViewerPrs> aPresentations;
+  XGUI_Displayer* aDisplayer = myWorkshop->displayer();
 
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) {
+    ModuleBase_ViewerPrs aPrs;
     Handle(AIS_InteractiveObject) anIO = aContext->DetectedInteractive();
-    TopoDS_Shape aShape = aContext->DetectedShape();
-    if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip)
-      continue;
-
-    ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO);
-    if (aPrsFeatures.find(aResult) != aPrsFeatures.end())
-      continue;
-    aPresentations.push_back(ModuleBase_ViewerPrs(aResult, aShape, NULL));
-    aPrsFeatures.insert(aResult);
+    aPrs.setInteractive(anIO);
+
+    ObjectPtr aResult = aDisplayer->getObject(anIO);
+    if (aPrsFeatures.find(aResult) == aPrsFeatures.end()) {
+      aPrs.setFeature(aResult);
+      aPrsFeatures.insert(aResult);
+    }
+    if (aContext->HasOpenedContext()) {
+      TopoDS_Shape aShape = aContext->DetectedShape();
+      if (!aShape.IsNull() && aShape.ShapeType() != theShapeTypeToSkip)
+        aPrs.setShape(aShape);
+    }
+    aPresentations.push_back(aPrs);
   }
-
   return aPresentations;
 }