]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Provide selection mechanism from SALOME (issue #31)
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 29 Apr 2014 12:43:40 +0000 (16:43 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 29 Apr 2014 12:43:40 +0000 (16:43 +0400)
src/NewGeom/NewGeom_Module.cpp
src/NewGeom/NewGeom_Module.h
src/NewGeom/NewGeom_OCCSelector.cpp [new file with mode: 0644]
src/NewGeom/NewGeom_OCCSelector.h [new file with mode: 0644]
src/XGUI/XGUI_Viewer.h

index 7285933d12304a230923c714c7e4c3206a733da5..f56deda0dc3b8c266e7c2c855fa32c01099e1913 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "NewGeom_Module.h"
 #include "NewGeom_DataModel.h"
+#include "NewGeom_OCCSelector.h"
 
 #include <XGUI_Workshop.h>
 
@@ -20,7 +21,7 @@ extern "C" {
   NewGeom_EXPORT CAM_Module* createModule() {
     return new NewGeom_Module();
   }
-  
+    
   NewGeom_EXPORT char* getModuleVersion() {
     return "0.0";
   }
@@ -29,7 +30,7 @@ extern "C" {
 
 //******************************************************
 NewGeom_Module::NewGeom_Module()
-: LightApp_Module( "NewGeom" )
+: LightApp_Module( "NewGeom" ), mySelector(0)
 {
   myWorkshop = new XGUI_Workshop(this);
 }
@@ -67,14 +68,43 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
     setMenuShown( true );
     setToolShown( true );
 
-    SUIT_ViewManager* aMgr = application()->viewManager(OCCViewer_Viewer::Type());
-    if (aMgr) {
-      OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(aMgr->getViewModel());
+    if (!mySelector) {
+      ViewManagerList OCCViewManagers;
+      application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
+      if (OCCViewManagers.size() > 0) {
+        mySelector = createSelector(OCCViewManagers.first());
+      }
     }
   }
   return isDone;
 }
 
+//******************************************************
+void NewGeom_Module::onViewManagerAdded( SUIT_ViewManager* theMgr )
+{
+  if ((!mySelector)) {
+    mySelector = createSelector(theMgr);
+  }
+}
+
+//******************************************************
+NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr)
+{
+  if (theMgr->getType() == OCCViewer_Viewer::Type()) {
+    OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
+    NewGeom_OCCSelector* aSelector = new NewGeom_OCCSelector(aViewer, 
+                                                             getApp()->selectionMgr());
+    LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
+    QList<SUIT_Selector*> aList;
+    aMgr->selectors(aList);
+    foreach(SUIT_Selector* aSel, aList) {
+      aSel->setEnabled(aSel == aSelector);
+    }
+    return aSelector;
+  }
+  return 0;
+}
+
 //******************************************************
 bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
 {
@@ -174,9 +204,8 @@ QAction* NewGeom_Module::command(const QString& theId) const
 Handle(AIS_InteractiveContext) NewGeom_Module::AISContext() const
 {
   Handle(AIS_InteractiveContext) aContext;
-  SUIT_ViewManager* aMgr = application()->viewManager(OCCViewer_Viewer::Type());
-  if (aMgr) {
-    OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(aMgr->getViewModel());
+  OCCViewer_Viewer* aViewer = mySelector->viewer();
+  if (aViewer) {
     aContext = aViewer->getAISContext();
   }
   return aContext;
@@ -186,5 +215,5 @@ Handle(AIS_InteractiveContext) NewGeom_Module::AISContext() const
 void NewGeom_Module::selectionChanged()
 {
   LightApp_Module::selectionChanged();
-  //myWorkshop->salomeViewerSelectionChanged();
+  myWorkshop->salomeViewerSelectionChanged();
 }
index f8f2cb5c07b9c3bb9e9b7205f119abb31ebebe1b..be58a360224af956e984836c986e300de5c4b421 100644 (file)
@@ -10,8 +10,9 @@
 
 #include <QStringList>
 
-class XGUI_Workshop;
-
+class XGUI_Workshop; 
+class NewGeom_OCCSelector;
+class OCCViewer_Viewer;
 /** 
 * An implementation of SALOME connector class for implementation of
 * XGUI functionality as a module of SALOME
@@ -61,17 +62,24 @@ public:
   virtual Handle(AIS_InteractiveContext) AISContext() const;
 
 public slots:
-  bool activateModule( SUIT_Study* theStudy);
-  bool deactivateModule( SUIT_Study* theStudy);
+  virtual bool activateModule( SUIT_Study* theStudy);
+  virtual bool deactivateModule( SUIT_Study* theStudy);
+
+protected slots:
+  virtual void onViewManagerAdded( SUIT_ViewManager* theMgr );
 
 protected:
   CAM_DataModel* createDataModel();
 
 
 private:
+  NewGeom_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
+
   QStringList myActionsList;
 
   XGUI_Workshop* myWorkshop;
+
+  NewGeom_OCCSelector* mySelector;
 };
 
 #endif
diff --git a/src/NewGeom/NewGeom_OCCSelector.cpp b/src/NewGeom/NewGeom_OCCSelector.cpp
new file mode 100644 (file)
index 0000000..b7442ac
--- /dev/null
@@ -0,0 +1,26 @@
+#include "NewGeom_OCCSelector.h"
+
+NewGeom_OCCSelector::NewGeom_OCCSelector( OCCViewer_Viewer* theViewer, 
+                                         SUIT_SelectionMgr* theMgr)
+: LightApp_OCCSelector(theViewer, theMgr)
+{
+}
+
+NewGeom_OCCSelector::~NewGeom_OCCSelector()
+{
+}
+
+void NewGeom_OCCSelector::getSelection( SUIT_DataOwnerPtrList& thePtrList ) const
+{
+  OCCViewer_Viewer* vw = viewer();
+  if (!vw)
+    return;
+}
+
+void NewGeom_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& thePtrList )
+{
+  OCCViewer_Viewer* vw = viewer();
+  if (!vw)
+    return;
+
+}
diff --git a/src/NewGeom/NewGeom_OCCSelector.h b/src/NewGeom/NewGeom_OCCSelector.h
new file mode 100644 (file)
index 0000000..ae6b1cb
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef NewGeom_OCCSelector_H
+#define NewGeom_OCCSelector_H
+
+#include "NewGeom.h"
+
+#include <LightApp_OCCSelector.h>
+
+class NewGeom_EXPORT NewGeom_OCCSelector : public LightApp_OCCSelector
+{
+public:
+  NewGeom_OCCSelector( OCCViewer_Viewer* theViewer, SUIT_SelectionMgr* theMgr );
+  virtual ~NewGeom_OCCSelector();
+
+protected:
+  virtual void getSelection( SUIT_DataOwnerPtrList& theList ) const;
+  virtual void setSelection( const SUIT_DataOwnerPtrList& theList );
+};
+
+#endif
\ No newline at end of file
index b422e4034432576fb6f54861c0f180a1be0c78b9..466951c7ab0342c00e199fb3d1687963ea1eed6e 100644 (file)
@@ -149,8 +149,6 @@ 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*);