]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom
authornds <natalia.donis@opencascade.com>
Thu, 22 May 2014 14:32:07 +0000 (18:32 +0400)
committernds <natalia.donis@opencascade.com>
Thu, 22 May 2014 14:32:07 +0000 (18:32 +0400)
Conflicts:
src/PartSet/PartSet_OperationEditLine.cpp

12 files changed:
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationEditLine.cpp
src/PartSet/PartSet_OperationEditLine.h
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/PartSet/PartSet_OperationSketchBase.cpp
src/PartSet/PartSet_OperationSketchBase.h
src/PartSet/PartSet_OperationSketchLine.cpp
src/PartSet/PartSet_OperationSketchLine.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_Viewer.cpp

index b54dc192afca8965a7bb3250fbbdc6222cd8b3b6..606c5789966eee02a806b0a68e020ab71126e0ed 100644 (file)
@@ -128,8 +128,11 @@ void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
                                        myWorkshop->operationMgr()->currentOperation());
   if (aPreviewOp)
   {
-    std::list<XGUI_ViewerPrs> aPresentations = myWorkshop->displayer()->GetViewerPrs();
-    aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView(), aPresentations);
+    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->GetSelected();
+    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->GetHighlighted();
+
+    aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
   }
 }
 
@@ -139,8 +142,11 @@ void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
                                        myWorkshop->operationMgr()->currentOperation());
   if (aPreviewOp)
   {
-    std::list<XGUI_ViewerPrs> aPresentations = myWorkshop->displayer()->GetViewerPrs();
-    aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aPresentations);
+    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->GetSelected();
+    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->GetHighlighted();
+
+    aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
   }
 }
 
@@ -173,8 +179,10 @@ void PartSet_Module::onLaunchOperation(std::string theName, boost::shared_ptr<Mo
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp)
   {
-    std::list<XGUI_ViewerPrs> aPresentations = myWorkshop->displayer()->GetViewerPrs();
-    aPreviewOp->init(theFeature, aPresentations);
+    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->GetSelected();
+    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->GetHighlighted();
+    aPreviewOp->init(theFeature, aSelected, aHighlighted);
   }
   myWorkshop->actionsMgr()->setActionChecked(anOperation->getDescription()->operationId(), true);
   sendOperation(anOperation);
@@ -197,6 +205,10 @@ void PartSet_Module::onStopSelection(const std::list<XGUI_ViewerPrs>& theFeature
     }
   }
   aDisplayer->StopSelection(theFeatures, isStop, false);
+
+  XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
+  aViewer->enableSelection(!isStop);
+
   aDisplayer->UpdateViewer();
 }
 
index 4cfbc3e9a4bb1326f056894e0697338626140828..d630bb2c3c914dcd9847677b2cc1a13d82fac739 100644 (file)
@@ -54,10 +54,28 @@ std::list<int> PartSet_OperationEditLine::getSelectionModes(boost::shared_ptr<Mo
 }
 
 void PartSet_OperationEditLine::init(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                                     const std::list<XGUI_ViewerPrs>& thePresentations)
+                                     const std::list<XGUI_ViewerPrs>& theSelected,
+                                     const std::list<XGUI_ViewerPrs>& theHighlighted)
 {
   setFeature(theFeature);
-  myFeatures = thePresentations;
+
+  if (!theHighlighted.empty()) {
+    // if there is highlighted object, we check whether it is in the list of selected objects
+    // in that case this object is a handle of the moved lines. If there no such object in the selection,
+    // the hightlighted object should moved and the selection is skipped. The skipped selection will be
+    // deselected in the viewer by blockSelection signal in the startOperation method.
+    bool isSelected = false;
+    std::list<XGUI_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
+    for (; anIt != aLast && !isSelected; anIt++) {
+      isSelected = (*anIt).feature() == feature();
+    }
+    if (!isSelected)
+      myFeatures = theHighlighted;
+    else
+      myFeatures = theSelected;
+  }
+  else
+    myFeatures = theSelected;
 }
 
 boost::shared_ptr<ModelAPI_Feature> PartSet_OperationEditLine::sketch() const
@@ -65,12 +83,27 @@ boost::shared_ptr<ModelAPI_Feature> PartSet_OperationEditLine::sketch() const
   return mySketch;
 }
 
-void PartSet_OperationEditLine::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView)
+void PartSet_OperationEditLine::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                             const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                             const std::list<XGUI_ViewerPrs>& theHighlighted)
 {
-  if (!(theEvent->buttons() &  Qt::LeftButton))
-    return;
-  gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
-  myCurPoint.setPoint(aPoint);
+  if (myFeatures.size() == 1)
+  {
+    boost::shared_ptr<ModelAPI_Feature> aFeature;
+    if (!theHighlighted.empty())
+      aFeature = theHighlighted.front().feature();
+
+    if (aFeature && aFeature == feature()) { // continue the feature edit
+      blockSelection(true);
+    }
+    else {
+      commit();
+      emit featureConstructed(feature(), FM_Deactivation);
+      if (aFeature) {
+        emit launchOperation(PartSet_OperationEditLine::Type(), aFeature);
+      }
+    }
+  }
 }
 
 void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
@@ -109,16 +142,12 @@ void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_Vie
 }
 
 void PartSet_OperationEditLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
-                                              const std::list<XGUI_ViewerPrs>& theSelected)
+                                              const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                              const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
 {
   std::list<XGUI_ViewerPrs> aFeatures = myFeatures;
   if (myFeatures.size() == 1) {
-    if (theSelected.empty())
-      return;
-
-    boost::shared_ptr<ModelAPI_Feature> aFeature = theSelected.front().feature();
-    commit();
-    emit launchOperation(PartSet_OperationEditLine::Type(), aFeature);
+    blockSelection(false);
   }
   else {
     commit();
@@ -135,22 +164,34 @@ void PartSet_OperationEditLine::startOperation()
 {
   // do nothing in order to do not create a new feature
   emit multiSelectionEnabled(false);
-  emit setSelection(std::list<XGUI_ViewerPrs>());
-  emit stopSelection(myFeatures, true);
+
+  blockSelection(true);
+
   myCurPoint.clear();
 }
 
 void PartSet_OperationEditLine::stopOperation()
 {
   emit multiSelectionEnabled(true);
-  bool isSelectFeatures = myFeatures.size() > 1;
-  emit stopSelection(myFeatures, false);
-  if (isSelectFeatures)
-    emit setSelection(myFeatures);
+
+  blockSelection(false, myFeatures.size() > 1);
 
   myFeatures.clear();
 }
 
+void PartSet_OperationEditLine::blockSelection(bool isBlocked, const bool isRestoreSelection)
+{
+  if (isBlocked) {
+    emit setSelection(std::list<XGUI_ViewerPrs>());
+    emit stopSelection(myFeatures, true);
+  }
+  else {
+    emit stopSelection(myFeatures, false);
+    if (isRestoreSelection)
+      emit setSelection(myFeatures);
+  }
+}
+
 boost::shared_ptr<ModelAPI_Feature> PartSet_OperationEditLine::createFeature(const bool /*theFlushMessage*/)
 {
   // do nothing in order to do not create a new feature
index d053067b85517278fe809893065b545dafa7e8d3..219d23b2c9eb4aec94114620833bd5edb4e9f2aa 100644 (file)
@@ -72,28 +72,36 @@ public:
 
   /// Initializes some fields accorging to the feature
   /// \param theFeature the feature
-  /// \param thePresentations the list of additional presentations
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
   virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                    const std::list<XGUI_ViewerPrs>& thePresentations);
+                    const std::list<XGUI_ViewerPrs>& theSelected,
+                    const std::list<XGUI_ViewerPrs>& theHighlighted);
 
   /// Returns the operation sketch feature
   /// \returns the sketch instance
   virtual boost::shared_ptr<ModelAPI_Feature> sketch() const;
 
   /// Processes the mouse pressed in the point
-  /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
-  virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView);
+  /// \param theView a viewer to have the viewer the eye position
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
+  virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
+                            const std::list<XGUI_ViewerPrs>& theSelected,
+                            const std::list<XGUI_ViewerPrs>& theHighlighted);
   /// Gives the current mouse point in the viewer
-  /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
+  /// \param theView a viewer to have the viewer the eye position
   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
   /// Gives the current selected objects to be processed by the operation
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
   /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
  virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
-                            const std::list<XGUI_ViewerPrs>& theSelected);
+                            const std::list<XGUI_ViewerPrs>& theSelected,
+                            const std::list<XGUI_ViewerPrs>& theHighlighted);
 protected:
   /// \brief Virtual method called when operation is started
   /// Virtual method called when operation started (see start() method for more description)
@@ -111,6 +119,13 @@ protected:
   virtual boost::shared_ptr<ModelAPI_Feature> createFeature(const bool theFlushMessage = true);
 
 protected:
+  /// Emits a signal about the selection blocking. Emits a signal to change the selection.
+  /// If the block is true, the signal clear selection, otherwise if restore selection flag allows,
+  /// the internal operation features are to be selected
+  /// \param isBlocked the state whether the operation is blocked or unblocked
+  /// \param isRestoreSelection the state whether the selected objects should be reselected
+  void blockSelection(bool isBlocked, const bool isRestoreSelection = true);
+
   /// \brief Save the point to the line.
   /// \param theFeature the source feature
   /// \param theDeltaX the delta for X coordinate is moved
index cd2e3920d1d39e919a8d215ed2531d97f90b5750..e57a113b73ebc39cc1a6cd82a708afc48c8c795d 100644 (file)
@@ -57,19 +57,11 @@ boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketch::sketch() const
 }
 
 void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                           const std::list<XGUI_ViewerPrs>& theSelected)
+                                           const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                           const std::list<XGUI_ViewerPrs>& theHighlighted)
 {
-  myFeatures = theSelected;
-}
-
-void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                            const std::list<XGUI_ViewerPrs>& theSelected)
-{
-  if (theSelected.empty())
-    return;
-
   if (!myIsEditMode) {
-    XGUI_ViewerPrs aPrs = theSelected.front();
+    XGUI_ViewerPrs aPrs = theHighlighted.front();
     const TopoDS_Shape& aShape = aPrs.shape();
     if (!aShape.IsNull()) {
       setSketchPlane(aShape);
@@ -77,13 +69,14 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi
     }
   }
   else {
-    if (theSelected.size() == 1) {
-      boost::shared_ptr<ModelAPI_Feature> aFeature = theSelected.front().feature();
+    if (theHighlighted.size() == 1) {
+      boost::shared_ptr<ModelAPI_Feature> aFeature = theHighlighted.front().feature();
       if (aFeature)
         emit launchOperation(PartSet_OperationEditLine::Type(), aFeature);
     }
+    else
+      myFeatures = theHighlighted;
   }
-  myFeatures.clear();
 }
 
 void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
index fbb0eb376afba999656a2a675bb42d6e37a76f15..010b28d86f09c60865fef09d35632cd3402b0d0f 100644 (file)
@@ -39,17 +39,13 @@ public:
   virtual boost::shared_ptr<ModelAPI_Feature> sketch() const;
 
   /// Processes the mouse pressed in the point
-  /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
+  /// \param theView a viewer to have the viewer the eye position
   /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
-                            const std::list<XGUI_ViewerPrs>& theSelected);
-  /// Processes the mouse release in the point
-  /// \param thePoint a point clicked in the viewer
-  /// \param theEvent the mouse event
-  /// \param theSelected the list of selected presentations
-  virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
-                             const std::list<XGUI_ViewerPrs>& theSelected);
+                            const std::list<XGUI_ViewerPrs>& theSelected,
+                            const std::list<XGUI_ViewerPrs>& theHighlighted);
   /// Gives the current mouse point in the viewer
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
index 2b83d306f3efbe8ab6305e866c7c4be9a7648195..acf76c60a094e134b5a9691c7e1be72ad383cbbe 100644 (file)
@@ -64,11 +64,13 @@ boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchBase::createFeature(c
 
 
 void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                               const std::list<XGUI_ViewerPrs>& theSelected)
+                                               const std::list<XGUI_ViewerPrs>& theSelected,
+                                               const std::list<XGUI_ViewerPrs>& theHighlighted)
 {
 }
 void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                                const std::list<XGUI_ViewerPrs>& theSelected)
+                                                const std::list<XGUI_ViewerPrs>& theSelected,
+                                                const std::list<XGUI_ViewerPrs>& theHighlighted)
 {
 }
 void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
index 6b4eb49f4c96a652d5c2a6eb2d0e5b549fee2944..5aa07c3f002c0ab90f8171e5d701c8fe629262ae 100644 (file)
@@ -55,32 +55,37 @@ public:
   virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const = 0;
 
   /// Initializes some fields accorging to the feature
-  /// \param theFeature the feature
-  /// \param thePresentations the list of additional presentations
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
   virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                    const std::list<XGUI_ViewerPrs>& thePresentations) {}
+                    const std::list<XGUI_ViewerPrs>& theSelected,
+                    const std::list<XGUI_ViewerPrs>& theHighlighted) {}
 
   /// Returns the operation sketch feature
   /// \returns the sketch instance
   virtual boost::shared_ptr<ModelAPI_Feature> sketch() const = 0;
 
   /// Processes the mouse pressed in the point
-  /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
+  /// \param theView a viewer to have the viewer the eye position
   /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
-                            const std::list<XGUI_ViewerPrs>& theSelected);
+                            const std::list<XGUI_ViewerPrs>& theSelected,
+                            const std::list<XGUI_ViewerPrs>& theHighlighted);
 
   /// Processes the mouse release in the point
-  /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
+  /// \param theView a viewer to have the viewer the eye position
   /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
   virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
-                             const std::list<XGUI_ViewerPrs>& theSelected);
+                             const std::list<XGUI_ViewerPrs>& theSelected,
+                             const std::list<XGUI_ViewerPrs>& theHighlighted);
 
   /// Processes the mouse move in the point
-  /// \param thePoint a 3D point clicked in the viewer
   /// \param theEvent the mouse event
+  /// \param theView a viewer to have the viewer the eye position
   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
 
   /// Processes the key pressed in the view
index 91ad9ebe607133180df981d9f65a162248a7b5c5..33e03c5e2c4d4c841b9148252902ee0834c3a0a2 100644 (file)
@@ -67,7 +67,8 @@ std::list<int> PartSet_OperationSketchLine::getSelectionModes(boost::shared_ptr<
 }
 
 void PartSet_OperationSketchLine::init(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                                       const std::list<XGUI_ViewerPrs>& /*thePresentations*/)
+                                       const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                       const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
 {
   if (!theFeature || theFeature->getKind() != "SketchLine")
     return;
@@ -82,7 +83,8 @@ boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchLine::sketch() const
 }
 
 void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
-                                                const std::list<XGUI_ViewerPrs>& theSelected)
+                                                const std::list<XGUI_ViewerPrs>& theSelected,
+                                                const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
 {
   double aX, anY;
 
@@ -204,8 +206,16 @@ void PartSet_OperationSketchLine::keyReleased(const int theKey)
       emit launchOperation(PartSet_OperationSketchLine::Type(), boost::shared_ptr<ModelAPI_Feature>());
     }
     break;
+    case Qt::Key_Escape: {
+      if (myPointSelectionMode == SM_DonePoint)
+      {
+        commit();
+        emit featureConstructed(feature(), FM_Deactivation);
+      }
+      else
+        abort();
+    }
     default:
-      PartSet_OperationSketchBase::keyReleased(theKey); 
     break;
   }
 }
index d4b2fc85cf67a4efb20c9cf9ea39a94c43b9df89..db20415c74cb86f54548866d6b52f83077734eb7 100644 (file)
@@ -46,21 +46,24 @@ public:
   virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
 
   /// Initializes some fields accorging to the feature
-  /// \param theFeature the feature
-  /// \param thePresentations the list of additional presentations
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
   virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                    const std::list<XGUI_ViewerPrs>& thePresentations);
+                    const std::list<XGUI_ViewerPrs>& theSelected,
+                    const std::list<XGUI_ViewerPrs>& theHighlighted);
 
   /// Returns the operation sketch feature
   /// \returns the sketch instance
   virtual boost::shared_ptr<ModelAPI_Feature> sketch() const;
 
   /// Gives the current selected objects to be processed by the operation
-  /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
+  /// \param theView a viewer to have the viewer the eye position
   /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
  virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
-                             const std::list<XGUI_ViewerPrs>& theSelected);
+                            const std::list<XGUI_ViewerPrs>& theSelected,
+                            const std::list<XGUI_ViewerPrs>& theHighlighted);
   /// Gives the current mouse point in the viewer
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
index 7f6bb00d77885b772f7febee71cd8fac6d7fa6b7..4073b30b435838c86319ab4286eb1c3e558488b9 100644 (file)
@@ -12,6 +12,7 @@
 #include <ModelAPI_Data.h>
 
 #include <AIS_InteractiveContext.hxx>
+#include <AIS_LocalContext.hxx>
 #include <AIS_ListOfInteractive.hxx>
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
 
@@ -52,7 +53,7 @@ void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
 }*/
 
 
-std::list<XGUI_ViewerPrs> XGUI_Displayer::GetViewerPrs()
+std::list<XGUI_ViewerPrs> XGUI_Displayer::GetSelected()
 {
   std::set<boost::shared_ptr<ModelAPI_Feature> > aPrsFeatures;
   std::list<XGUI_ViewerPrs> aPresentations;
@@ -62,15 +63,26 @@ std::list<XGUI_ViewerPrs> XGUI_Displayer::GetViewerPrs()
     Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
     TopoDS_Shape aShape = aContext->SelectedShape();
 
-    boost::shared_ptr<ModelAPI_Feature> aFeature;
-    FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(),
-                                    aFLast = myFeature2AISObjectMap.end();
-    for (; aFIt != aFLast && !aFeature; aFIt++) {
-      Handle(AIS_InteractiveObject) anAIS = (*aFIt).second;
-      if (anAIS != anIO)
-        continue;
-      aFeature = (*aFIt).first;
-    }
+    boost::shared_ptr<ModelAPI_Feature> aFeature = GetFeature(anIO);
+    if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
+      continue;
+    aPresentations.push_back(XGUI_ViewerPrs(aFeature, aShape));
+    aPrsFeatures.insert(aFeature);
+  }
+  return aPresentations;
+}
+
+std::list<XGUI_ViewerPrs> XGUI_Displayer::GetHighlighted()
+{
+  std::set<boost::shared_ptr<ModelAPI_Feature> > aPrsFeatures;
+  std::list<XGUI_ViewerPrs> aPresentations;
+
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) {
+    Handle(AIS_InteractiveObject) anIO = aContext->DetectedInteractive();
+    TopoDS_Shape aShape = aContext->DetectedShape();
+
+    boost::shared_ptr<ModelAPI_Feature> aFeature = GetFeature(anIO);
     if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
       continue;
     aPresentations.push_back(XGUI_ViewerPrs(aFeature, aShape));
@@ -203,7 +215,12 @@ void XGUI_Displayer::SetSelected(const std::list<XGUI_ViewerPrs>& theFeatures, c
   boost::shared_ptr<ModelAPI_Feature> aFeature;
 
   Handle(AIS_Shape) anAIS;
-  aContext->ClearSelected();
+  // we need to unhighligth objects manually in the current local context
+  // in couple with the selection clear (TODO)
+  Handle(AIS_LocalContext) aLocalContext = aContext->LocalContext();
+  if (!aLocalContext.IsNull())
+    aLocalContext->UnhilightLastDetected(myWorkshop->viewer()->activeView());
+  aContext->ClearSelected(false);
 
   for (; anIt != aLast; anIt++) {
     aFeature = (*anIt).feature();
@@ -213,6 +230,7 @@ void XGUI_Displayer::SetSelected(const std::list<XGUI_ViewerPrs>& theFeatures, c
       continue;
     aContext->AddOrRemoveSelected(anAIS, false);
   }
   if (isUpdateViewer)
     aContext->UpdateCurrentViewer();
 }
@@ -267,10 +285,24 @@ void XGUI_Displayer::EraseDeletedFeatures(const bool isUpdateViewer)
 
 void XGUI_Displayer::CloseLocalContexts(const bool isUpdateViewer)
 {
-  closeAllContexts(true);
+  CloseAllContexts(true);
+}
+
+boost::shared_ptr<ModelAPI_Feature> XGUI_Displayer::GetFeature(Handle(AIS_InteractiveObject) theIO)
+{
+  boost::shared_ptr<ModelAPI_Feature> aFeature;
+  FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(),
+                                  aFLast = myFeature2AISObjectMap.end();
+  for (; aFIt != aFLast && !aFeature; aFIt++) {
+    Handle(AIS_InteractiveObject) anAIS = (*aFIt).second;
+    if (anAIS != theIO)
+      continue;
+    aFeature = (*aFIt).first;
+  }
+  return aFeature;
 }
 
-void XGUI_Displayer::closeAllContexts(const bool isUpdateViewer)
+void XGUI_Displayer::CloseAllContexts(const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) ic = AISContext();
   if (!ic.IsNull()) {
index 5973cd67e6d1ce064356503dff519a7b2514201e..080fef76a2ae4ed9e7c691599ec001e6da1fdb78 100644 (file)
@@ -58,9 +58,13 @@ public:
   //void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
   //             const bool isUpdateViewer = true);
   
-  /// Returns a list of viewer presentations
+  /// Returns a list of viewer selected presentations
   /// \return list of presentations
-  std::list<XGUI_ViewerPrs> GetViewerPrs();
+  std::list<XGUI_ViewerPrs> GetSelected();
+
+  /// Returns a list of viewer highlited presentations
+  /// \return list of presentations
+  std::list<XGUI_ViewerPrs> GetHighlighted();
 
   /// Display the shape and activate selection of sub-shapes
   /// \param theFeature a feature instance
@@ -111,9 +115,13 @@ public:
   void UpdateViewer();
 
 protected:
+  /// Searches the feature by interactive object
+  /// \param theIO an interactive object
+  /// \return feature the feature or NULL if it not visualized
+  boost::shared_ptr<ModelAPI_Feature> GetFeature(Handle(AIS_InteractiveObject) theIO);
   /// Deactivate local selection
   /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
-  void closeAllContexts(const bool isUpdateViewer);
+  void CloseAllContexts(const bool isUpdateViewer);
 
   /// Returns currently installed AIS_InteractiveContext
   Handle(AIS_InteractiveContext) AISContext() const;
index 734a1a469e48ab9ff6bbed1d29a8302e6c63ab13..3d5af347ade6fc484c4c3f65ec9856abe9ff698f 100644 (file)
@@ -506,9 +506,9 @@ void XGUI_Viewer::onMousePressed(XGUI_ViewWindow* theWindow, QMouseEvent* theEve
 */
 void XGUI_Viewer::onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
 {
+  myCurPnt.setX(theEvent->x()); myCurPnt.setY(theEvent->y());
   if (!mySelectionEnabled) return;
 
-  myCurPnt.setX(theEvent->x()); myCurPnt.setY(theEvent->y());
   Handle(V3d_View) aView3d = theWindow->viewPort()->getView();
   if ( !aView3d.IsNull() ) {
     myAISContext->MoveTo(theEvent->x(), theEvent->y(), aView3d);