]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Mon, 28 Apr 2014 13:11:15 +0000 (17:11 +0400)
committernds <natalia.donis@opencascade.com>
Mon, 28 Apr 2014 13:11:15 +0000 (17:11 +0400)
Line visualization by the mouse click/move

17 files changed:
src/ModuleBase/ModuleBase_Operation.cpp
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Listener.cpp [new file with mode: 0644]
src/PartSet/PartSet_Listener.h [new file with mode: 0644]
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/PartSet/PartSet_OperationSketchBase.h
src/PartSet/PartSet_OperationSketchLine.cpp
src/PartSet/PartSet_OperationSketchLine.h
src/PartSet/PartSet_Tools.cpp [new file with mode: 0644]
src/PartSet/PartSet_Tools.h [new file with mode: 0644]
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_Viewer.cpp
src/XGUI/XGUI_Viewer.h

index 519efbf13ebacbf35de46b6122d47232925a8f21..f31a292e0c4ef4c8d6a494a29dfcc22b0b081833 100644 (file)
@@ -16,8 +16,6 @@
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Document.h>
 
-#include <GeomDataAPI_Point2D.h>
-
 #ifdef _DEBUG
 #include <QDebug>
 #endif
index 5a999aabae5229a06c830c01788a0ee3d81046a7..3744b2d4c831579b16370f16a1d6ed53b0ddb8e0 100644 (file)
@@ -5,17 +5,21 @@ SET(CMAKE_AUTOMOC ON)
 
 SET(PROJECT_HEADERS
        PartSet.h
+       PartSet_Listener.h
        PartSet_Module.h
        PartSet_OperationSketchBase.h
        PartSet_OperationSketch.h
        PartSet_OperationSketchLine.h
+       PartSet_Tools.h
 )
 
 SET(PROJECT_SOURCES
+       PartSet_Listener.cpp
        PartSet_Module.cpp
        PartSet_OperationSketchBase.cpp
        PartSet_OperationSketch.cpp
        PartSet_OperationSketchLine.cpp
+       PartSet_Tools.cpp
 )
 
 SET(PROJECT_RESOURCES 
@@ -47,6 +51,7 @@ SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES})
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI 
                     ${CMAKE_SOURCE_DIR}/src/Config
                     ${CMAKE_SOURCE_DIR}/src/Events
+                    ${CMAKE_SOURCE_DIR}/src/Model
                     ${CMAKE_SOURCE_DIR}/src/ModuleBase
                     ${CMAKE_SOURCE_DIR}/src/ModelAPI
                     ${CMAKE_SOURCE_DIR}/src/GeomDataAPI
diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp
new file mode 100644 (file)
index 0000000..580186b
--- /dev/null
@@ -0,0 +1,37 @@
+// File:        PartSet_Listener.h
+// Created:     28 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_Listener.h>
+
+#include <PartSet_Module.h>
+
+#include <Events_Loop.h>
+#include <Model_Events.h>
+
+#ifdef _DEBUG
+#include <QDebug>
+#endif
+
+using namespace std;
+
+PartSet_Listener::PartSet_Listener(PartSet_Module* theModule)
+: myModule(theModule)
+{
+  Events_Loop* aLoop = Events_Loop::loop();
+  Events_ID aFeatureUpdatedId = aLoop->eventByName(EVENT_FEATURE_UPDATED);
+  aLoop->registerListener(this, aFeatureUpdatedId);
+}
+
+PartSet_Listener::~PartSet_Listener()
+{
+}
+
+//******************************************************
+void PartSet_Listener::processEvent(const Events_Message* theMessage)
+{
+  if (QString(theMessage->eventID().eventText()) == EVENT_FEATURE_UPDATED)
+  {
+    myModule->visualizePreview(true);
+  }
+}
diff --git a/src/PartSet/PartSet_Listener.h b/src/PartSet/PartSet_Listener.h
new file mode 100644 (file)
index 0000000..0512245
--- /dev/null
@@ -0,0 +1,35 @@
+// File:        PartSet_Listener.h
+// Created:     28 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_Listener_H
+#define PartSet_Listener_H
+
+#include "PartSet.h"
+
+#include <Events_Listener.h>
+
+class PartSet_Module;
+
+/*!
+ \class PartSet_Listener
+ * \brief The operation for the sketch feature creation
+*/
+class PARTSET_EXPORT PartSet_Listener : public Events_Listener
+{
+public:
+  /// Constructor
+  /// \param theId the feature identifier
+  /// \param theParent the operation parent
+  PartSet_Listener(PartSet_Module* theModule);
+  /// Destructor
+  virtual ~PartSet_Listener();
+
+  /// This method is called by loop when the event is started to process.
+  virtual void processEvent(const Events_Message* theMessage);
+
+private:
+  PartSet_Module* myModule; ///< the current module
+};
+
+#endif
index c91631f06b3eb6e6ad7fae0466a893ce0b9b663e..b6ae9bfe0e9cbb329331670f4c09bda07d25c318 100644 (file)
@@ -1,6 +1,8 @@
 #include <PartSet_Module.h>
 #include <PartSet_OperationSketch.h>
 #include <PartSet_OperationSketchLine.h>
+#include <PartSet_Listener.h>
+#include <PartSet_Tools.h>
 
 #include <ModuleBase_Operation.h>
 
@@ -9,6 +11,8 @@
 #include <XGUI_Viewer.h>
 #include <XGUI_Workshop.h>
 #include <XGUI_OperationMgr.h>
+#include <XGUI_ViewWindow.h>
+#include <XGUI_ViewPort.h>
 
 #include <Config_PointerMessage.h>
 #include <Config_ModuleReader.h>
@@ -37,14 +41,19 @@ extern "C" PARTSET_EXPORT XGUI_Module* createModule(XGUI_Workshop* theWshop)
 PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
 {
   myWorkshop = theWshop;
+  myListener = new PartSet_Listener(this);
+
   XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
 
   connect(anOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
   connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
           this, SLOT(onOperationStopped(ModuleBase_Operation*)));
-  if (!myWorkshop->isSalomeMode())
-    connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
-            this, SLOT(onViewSelectionChanged()));
+  if (!myWorkshop->isSalomeMode()) {
+    connect(myWorkshop->mainWindow()->viewer(), SIGNAL(mouseReleased(QPoint)),
+            this, SLOT(onMouseReleased(QPoint)));
+    connect(myWorkshop->mainWindow()->viewer(), SIGNAL(mouseMoved(QPoint)),
+            this, SLOT(onMouseMoved(QPoint)));
+  }
 }
 
 PartSet_Module::~PartSet_Module()
@@ -131,7 +140,7 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
     visualizePreview(false);
 }
 
-void PartSet_Module::onViewSelectionChanged()
+void PartSet_Module::onMouseReleased(QPoint thePoint)
 {
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
@@ -140,7 +149,33 @@ void PartSet_Module::onViewSelectionChanged()
     if (aViewer) {
       NCollection_List<TopoDS_Shape> aList;
       aViewer->getSelectedShapes(aList);
-      aPreviewOp->setSelectedShapes(aList);
+      XGUI_ViewWindow* aWindow = aViewer->activeViewWindow();
+      if (aWindow) {
+        Handle(V3d_View) aView3d = aWindow->viewPort()->getView();
+        if ( !aView3d.IsNull() ) {
+          gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(thePoint, aView3d);
+          aPreviewOp->setSelectedShapes(aList, aPoint);
+        }
+      }
+    }
+  }
+}
+
+void PartSet_Module::onMouseMoved(QPoint thePoint)
+{
+  ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
+  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+  if (aPreviewOp) {
+    XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+    if (aViewer) {
+      XGUI_ViewWindow* aWindow = aViewer->activeViewWindow();
+      if (aWindow) {
+        Handle(V3d_View) aView3d = aWindow->viewPort()->getView();
+        if ( !aView3d.IsNull() ) {
+          gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(thePoint, aView3d);
+          aPreviewOp->setMouseMovePoint(aPoint);
+        }
+      }
     }
   }
 }
@@ -163,14 +198,16 @@ void PartSet_Module::visualizePreview(bool isDisplay)
   if (!aPreviewOp)
     return;
 
+  XGUI_Displayer* aDisplayer = myWorkshop->displayer();
   if (isDisplay) {
     boost::shared_ptr<GeomAPI_Shape> aPreview = aPreviewOp->preview();
-    if (aPreview)
-      myWorkshop->displayer()->LocalSelection(anOperation->feature(),
+    if (aPreview) {
+      aDisplayer->LocalSelection(anOperation->feature(),
                                    aPreview->impl<TopoDS_Shape>(), aPreviewOp->getSelectionMode());
+    }
   }
   else {
-    myWorkshop->displayer()->GlobalSelection(false);
-    myWorkshop->displayer()->Erase(anOperation->feature());
+    aDisplayer->GlobalSelection(false);
+    aDisplayer->Erase(anOperation->feature());
   }
 }
index 523a15ad210a702de378f66562dc510329ff97c5..d210fc513b488a01c349fc749fd4a13bfbf095ee 100644 (file)
@@ -11,6 +11,8 @@
 
 #include <string>
 
+class PartSet_Listener;
+
 class PARTSET_EXPORT PartSet_Module: public QObject, public XGUI_Module
 {
 Q_OBJECT
@@ -25,6 +27,10 @@ public:
 
   virtual void launchOperation(const QString& theCmdId);
 
+  /// Displays or erase the current operation preview, if it has it.
+  /// \param isDisplay the state whether the presentation should be displayed or erased
+  void visualizePreview(bool isDisplay);
+
 public slots:
   void onFeatureTriggered();
   /// SLOT, that is called after the operation is started. Perform some specific for module
@@ -35,20 +41,21 @@ public slots:
   void onOperationStopped(ModuleBase_Operation* theOperation);
   /// SLOT, that is called by the selection in the viewer is changed.
   /// The selection is sent to the current operation if it listen the selection.
-  void onViewSelectionChanged();
+  void onMouseReleased(QPoint thePoint);
+  /// SLOT, that is called by the selection in the viewer is changed.
+  /// The selection is sent to the current operation if it listen the selection.
+  /// \thePoint the mouse point
+  void onMouseMoved(QPoint thePoint);
+
   /// SLOT, to apply to the current viewer the operation
   /// \param theX the X projection value
   /// \param theY the Y projection value
   /// \param theZ the Z projection value
   void onViewerProjectionChange(double theX, double theY, double theZ);
 
-private:
-  /// Displays or erase the current operation preview, if it has it.
-  /// \param isDisplay the state whether the presentation should be displayed or erased
-  void visualizePreview(bool isDisplay);
-
 private:
   XGUI_Workshop* myWorkshop;
+  PartSet_Listener* myListener;
 
   std::map<std::string, std::string> myFeaturesInFiles;
 };
index 32a2199b8d2b6fe1d8acebfaaf2c9ef0f3d8bb81..48bd5f0e34de92fe5da62a1c6b2285c64155bd27 100644 (file)
@@ -35,7 +35,8 @@ int PartSet_OperationSketch::getSelectionMode() const
   return TopAbs_FACE;
 }
 
-void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList)
+void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
+                                                const gp_Pnt& theSelectedPoint)
 {
   if (theList.IsEmpty())
     return;
index 4a4fd74bc547a47978e739aa98ecf0be6c591729..021a8c8cdebf7981a3e5040880668d9188694126 100644 (file)
@@ -31,7 +31,9 @@ public:
 
   /// Gives the current selected objects to be processed by the operation
   /// \param theList a list of interactive selected shapes
-  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList);
+  /// \param theSelectedPoint a point clidked in the viewer
+  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
+                                 const gp_Pnt& theSelectedPoint);
 };
 
 #endif
index 916ebc46648ab9b402ee03581b6e38c2c3027f5f..0e6c242635f6974a48ecbd587af7d503843a5e99 100644 (file)
@@ -8,6 +8,7 @@
 #include "PartSet.h"
 
 #include <TopoDS_Shape.hxx>
+#include <gp_Pnt.hxx>
 #include <NCollection_List.hxx>
 
 #include <ModuleBase_PropPanelOperation.h>
@@ -39,8 +40,13 @@ public:
   virtual int getSelectionMode() const = 0;
 
   /// Gives the current selected objects to be processed by the operation
-  /// \param a list of interactive selected objects
-  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList) = 0;
+  /// \param theList a list of interactive selected shapes
+  /// \param theSelectedPoint a 3D selected point
+  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
+                                 const gp_Pnt& thePoint) = 0;
+  /// Gives the current mouse point in the viewer
+  /// \param thePoint a point clidked in the viewer
+  virtual void setMouseMovePoint(const gp_Pnt& thePoint) {};
 
 signals:
   void viewerProjectionChange(double theX, double theY, double theZ);
index 6ceda06f1366b9ac35429c956ed54b2b7985e39e..57d5f764603bcd745e2e55746595ae8f8b37caf7 100644 (file)
@@ -5,6 +5,10 @@
 #include <PartSet_OperationSketchLine.h>
 
 #include <SketchPlugin_Feature.h>
+#include <GeomDataAPI_Point2D.h>
+#include <ModelAPI_Data.h>
+
+#include <SketchPlugin_Line.h>
 
 #ifdef _DEBUG
 #include <QDebug>
@@ -15,7 +19,8 @@ using namespace std;
 PartSet_OperationSketchLine::PartSet_OperationSketchLine(const QString& theId,
                                                  QObject* theParent,
                                               boost::shared_ptr<ModelAPI_Feature> theFeature)
-: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature)
+: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature),
+  myPointSelectionMode(SM_FirstPoint)
 {
 }
 
@@ -30,13 +35,40 @@ bool PartSet_OperationSketchLine::isGranted() const
 
 int PartSet_OperationSketchLine::getSelectionMode() const
 {
-  return TopAbs_FACE;
+  return 0;//TopAbs_FACE;
 }
 
-void PartSet_OperationSketchLine::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList)
+void PartSet_OperationSketchLine::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
+                                                    const gp_Pnt& thePoint)
 {
   if (theList.IsEmpty())
     return;
+
+  switch (myPointSelectionMode)
+  {
+    case SM_FirstPoint: {
+      setLinePoint(thePoint, LINE_ATTR_START);
+      myPointSelectionMode = SM_SecondPoint;
+    }
+    break;
+    case SM_SecondPoint: {
+      setLinePoint(thePoint, LINE_ATTR_END);
+      commit();
+    }
+    break;
+    case SM_None: {
+
+    }
+    break;
+    default:
+      break;
+  }
+}
+
+void PartSet_OperationSketchLine::setMouseMovePoint(const gp_Pnt& thePoint)
+{
+  if (myPointSelectionMode == SM_SecondPoint)
+    setLinePoint(thePoint, LINE_ATTR_END);
 }
 
 void PartSet_OperationSketchLine::startOperation()
@@ -49,4 +81,23 @@ void PartSet_OperationSketchLine::startOperation()
 
     aFeature->addSub(feature());
   }
+  myPointSelectionMode = SM_FirstPoint;
 }
+
+void PartSet_OperationSketchLine::stopOperation()
+{
+  PartSet_OperationSketchBase::stopOperation();
+
+  myPointSelectionMode = SM_None;
+}
+
+void PartSet_OperationSketchLine::setLinePoint(const gp_Pnt& thePoint,
+                                               const std::string& theAttribute)
+{
+  boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
+  double aX = thePoint.X(), anY = thePoint.Y();
+  aPoint->setValue(aX, anY);
+}
+
index 737c73c36780c098125de5f1a0c2cd5afda724e1..27a03a43f8af98192646aed69c014b04fe319ba3 100644 (file)
@@ -37,7 +37,12 @@ public:
 
   /// Gives the current selected objects to be processed by the operation
   /// \param theList a list of interactive selected shapes
-  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList);
+  /// \param theSelectedPoint a point clidked in the viewer
+  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
+                                 const gp_Pnt& thePoint);
+  /// Gives the current mouse point in the viewer
+  /// \param thePoint a point clidked in the viewer
+  virtual void setMouseMovePoint(const gp_Pnt& thePoint);
 
 protected:
   /// \brief Virtual method called when operation is started
@@ -45,8 +50,24 @@ protected:
   /// After the parent operation body perform, set sketch feature to the created line feature
   virtual void startOperation();
 
+  /// \brief Virtual method called when operation is started
+  /// Virtual method called when operation stopped - committed or aborted.
+  /// After the parent operation body perform, reset selection point mode of the operation
+  virtual void stopOperation();
+
+protected:
+  /// \brief Save the point to the line.
+  /// \param thePoint the 3D point in the viewer
+  /// \param theAttribute the start or end attribute of the line
+  void setLinePoint(const gp_Pnt& thePoint, const std::string& theAttribute);
+
+protected:
+  ///< Structure to lists the possible types of point selection modes
+  enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint, SM_None};
+
 private:
   boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
+  PointSelectionMode myPointSelectionMode; ///< point selection mode
 };
 
 #endif
diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp
new file mode 100644 (file)
index 0000000..8afc9ae
--- /dev/null
@@ -0,0 +1,36 @@
+// File:        PartSet_Tools.h
+// Created:     28 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_Tools.h>
+
+#include <V3d_View.hxx>
+#include <gp_Pln.hxx>
+#include <ProjLib.hxx>
+#include <ElSLib.hxx>
+
+#ifdef _DEBUG
+#include <QDebug>
+#endif
+
+gp_Pnt PartSet_Tools::ConvertClickToPoint(QPoint thePoint, Handle(V3d_View) theView)
+{
+  V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
+  theView->Eye( XEye, YEye, ZEye );
+
+  theView->At( XAt, YAt, ZAt );
+  gp_Pnt EyePoint( XEye, YEye, ZEye );
+  gp_Pnt AtPoint( XAt, YAt, ZAt );
+
+  gp_Vec EyeVector( EyePoint, AtPoint );
+  gp_Dir EyeDir( EyeVector );
+
+  gp_Pln PlaneOfTheView = gp_Pln( AtPoint, EyeDir );
+  Standard_Real X, Y, Z;
+  theView->Convert( thePoint.x(), thePoint.y(), X, Y, Z );
+  gp_Pnt ConvertedPoint( X, Y, Z );
+
+  gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project( PlaneOfTheView, ConvertedPoint );
+  gp_Pnt ResultPoint = ElSLib::Value( ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView );
+  return ResultPoint;
+}
diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h
new file mode 100644 (file)
index 0000000..4139385
--- /dev/null
@@ -0,0 +1,30 @@
+// File:        PartSet_Tools.h
+// Created:     28 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_Tools_H
+#define PartSet_Tools_H
+
+#include "PartSet.h"
+
+#include <gp_Pnt.hxx>
+
+#include <QPoint>
+
+class Handle_V3d_View;
+
+/*!
+ \class PartSet_Tools
+ * \brief The operation for the sketch feature creation
+*/
+class PARTSET_EXPORT PartSet_Tools
+{
+public:
+  /// Converts the 2D screen point to the 3D point on the view according to the point of view
+  /// \param thePoint a screen point
+  /// \param theView a 3D view
+  static gp_Pnt ConvertClickToPoint(QPoint thePoint, Handle_V3d_View theView);
+
+};
+
+#endif
index 5b510bbb67a29d4b9459b4ca92401a9d05463aa7..41c912f1a4e29248576cb291a820f10dc38f6dc5 100644 (file)
@@ -22,6 +22,11 @@ XGUI_Displayer::~XGUI_Displayer()
 {
 }
 
+bool XGUI_Displayer::IsVisible(boost::shared_ptr<ModelAPI_Feature> theFeature)
+{
+  return myFeature2AISObjectMap.find(theFeature) != myFeature2AISObjectMap.end();
+}
+
 void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
                              const bool isUpdateViewer)
 {
@@ -73,6 +78,10 @@ void XGUI_Displayer::LocalSelection(boost::shared_ptr<ModelAPI_Feature> theFeatu
                                     const int theMode, const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
+  
+  if (IsVisible(theFeature)) {
+    Erase(theFeature, false);
+  }
 
   Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
   std::vector<Handle(AIS_InteractiveObject)> aDispAIS;
index 319a07a5e1bf6a6e3e6f63c21b1a49027c7753f9..b6967a2ab5d3366b60117d7ec6f775b63eb12ba6 100644 (file)
@@ -38,6 +38,10 @@ public:
   /// or can not be initialized in constructor
   void setAISContext(const Handle(AIS_InteractiveContext)& theAIS);
 
+  /// Returns the feature visibility state.
+  /// \param theFeature a feature instance
+  bool IsVisible(boost::shared_ptr<ModelAPI_Feature> theFeature);
+
   /// 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
index 0d93d6cc04f8eeee6f995deb253278f79ac49eb9..23560ca86031d369571e2dcf5d864eb5a43d675e 100644 (file)
@@ -190,6 +190,10 @@ QMdiSubWindow* XGUI_Viewer::createView(V3d_TypeOfView theType)
   return aWnd;
 }
 
+XGUI_ViewWindow* XGUI_Viewer::activeViewWindow() const
+{
+  return dynamic_cast<XGUI_ViewWindow*>(myActiveView->widget());
+}
 
 void XGUI_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList)
 {
@@ -502,8 +506,10 @@ void XGUI_Viewer::onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
   XGUI_ViewPort* aViewPort = theWindow->viewPort();
   Handle(V3d_View) aView3d = aViewPort->getView();
 
-  if ( !aView3d.IsNull() )
+  if ( !aView3d.IsNull() ) {
     myAISContext->MoveTo(theEvent->x(), theEvent->y(), aView3d);
+    mouseMoved(theEvent->pos());
+  }
 }
 
 /*!
@@ -513,5 +519,5 @@ void XGUI_Viewer::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEv
 {
   myAISContext->Select();
 
-  emit selectionChanged();
+  emit mouseReleased(theEvent->pos());
 }
index 784ddd3cf67661c77c4b273a9db1646292f26117..23d66656a92bf3badab36e66d613ce5dd5630665 100644 (file)
@@ -14,6 +14,8 @@
 #include <NCollection_List.hxx>
 #include <TopoDS_Shape.hxx>
 
+#include <QPoint>
+
 class XGUI_MainWindow;
 class QMdiSubWindow;
 class XGUI_ViewWindow;
@@ -57,6 +59,9 @@ public:
     return myAISContext;
   }
 
+  //! Returns an active view window or NULL
+  XGUI_ViewWindow* activeViewWindow() const;
+
   /// Return objects selected in 3D viewer
   /// \param theList - list to be filled with selected objects
   void  getSelectedObjects(AIS_ListOfInteractive& theList);
@@ -137,6 +142,8 @@ signals:
   void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
   void activated(XGUI_ViewWindow* theWindow);
   void selectionChanged();
+  void mouseReleased(QPoint thePoint);
+  void mouseMoved(QPoint thePoint);
 
 public slots:
   void onWindowMinimized(QMdiSubWindow*);