]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Tue, 29 Apr 2014 07:37:19 +0000 (11:37 +0400)
committersbh <sergey.belash@opencascade.com>
Tue, 29 Apr 2014 07:37:19 +0000 (11:37 +0400)
Conflicts:
src/XGUI/XGUI_Workshop.h

src/NewGeom/NewGeom_Module.cpp
src/NewGeom/NewGeom_Module.h
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_ObjectsBrowser.h
src/XGUI/XGUI_SelectionMgr.cpp
src/XGUI/XGUI_SelectionMgr.h
src/XGUI/XGUI_ViewWindow.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index ee68ba0c91d0ac5947dec781ea33d085fa4206d7..7285933d12304a230923c714c7e4c3206a733da5 100644 (file)
@@ -6,14 +6,16 @@
 #include <XGUI_Workshop.h>
 
 #include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <LightApp_OCCSelector.h>
 #include <OCCViewer_ViewModel.h>
+#include <SUIT_Selector.h>
 
 #include <SUIT_Desktop.h>
 #include <SUIT_ViewManager.h>
 
 #include <QtxActionMenuMgr.h>
 
-
 extern "C" {
   NewGeom_EXPORT CAM_Module* createModule() {
     return new NewGeom_Module();
@@ -64,6 +66,11 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
   if (isDone) {
     setMenuShown( true );
     setToolShown( true );
+
+    SUIT_ViewManager* aMgr = application()->viewManager(OCCViewer_Viewer::Type());
+    if (aMgr) {
+      OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(aMgr->getViewModel());
+    }
   }
   return isDone;
 }
@@ -173,4 +180,11 @@ Handle(AIS_InteractiveContext) NewGeom_Module::AISContext() const
     aContext = aViewer->getAISContext();
   }
   return aContext;
-}
\ No newline at end of file
+}
+
+//******************************************************
+void NewGeom_Module::selectionChanged()
+{
+  LightApp_Module::selectionChanged();
+  //myWorkshop->salomeViewerSelectionChanged();
+}
index 1440856ff903be33b98a8ea4034e6ab6a1b6ee30..f8f2cb5c07b9c3bb9e9b7205f119abb31ebebe1b 100644 (file)
@@ -23,9 +23,11 @@ public:
   NewGeom_Module();
   virtual ~NewGeom_Module();
 
+  //----- LightAPP_Module interface ---------------
   virtual void initialize( CAM_Application* theApp);
   virtual void windows( QMap<int, int>& theWndMap) const;
   virtual void viewManagers( QStringList& theList) const;
+  virtual void selectionChanged();
 
   //--- XGUI connector interface -----
   virtual void addFeature(const QString& theWBName,
index 9eece1559f9a44fc8d35bfa67c1c3497d0ca8d04..5fb8796e0eedafb0be7ea2bf9e607af989b1f7a8 100644 (file)
@@ -12,6 +12,7 @@
 #include <XGUI_Workshop.h>
 #include <XGUI_OperationMgr.h>
 #include <XGUI_ViewWindow.h>
+#include <XGUI_SelectionMgr.h>
 #include <XGUI_ViewPort.h>
 
 #include <Config_PointerMessage.h>
@@ -154,11 +155,11 @@ void PartSet_Module::onMouseReleased(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_SelectionMgr* aSelector = myWorkshop->selector();
+    if (aSelector) {
       NCollection_List<TopoDS_Shape> aList;
-      aViewer->getSelectedShapes(aList);
-      XGUI_ViewWindow* aWindow = aViewer->activeViewWindow();
+      aSelector->selectedShapes(aList);
+      XGUI_ViewWindow* aWindow = myWorkshop->mainWindow()->viewer()->activeViewWindow();
       if (aWindow) {
         Handle(V3d_View) aView3d = aWindow->viewPort()->getView();
         if ( !aView3d.IsNull() ) {
index 1b7e710c70ad31f4d24c908ed3bbee774d5b06e0..b0949534bb6e321af70a2c9fe74cfdf484b9f027 100644 (file)
@@ -24,7 +24,7 @@ public:
   XGUI_DocumentDataModel* dataModel() const { return myDocModel; }
 
   //! Returns list of currently selected features
-  QFeatureList selectedData() const { return mySelectedData; }
+  QFeatureList selectedFeatures() const { return mySelectedData; }
 
 signals:
   //! Emited when selection is changed
index c2d2c3de305f0dac81555fe4ee8aaef8a4167ad7..efca3fde5a3ff658a2736867af5e2393a9819d18 100644 (file)
@@ -2,6 +2,8 @@
 #include "XGUI_Workshop.h"
 #include "XGUI_MainWindow.h"
 #include "XGUI_ObjectsBrowser.h"
+#include "XGUI_Viewer.h"
+#include "XGUI_SalomeConnector.h"
 
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_PluginManager.h>
@@ -15,30 +17,80 @@ XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
 {
 }
 
-void XGUI_SelectionMgr::connectObjectBrowser(XGUI_ObjectsBrowser* theOB)
+XGUI_SelectionMgr::~XGUI_SelectionMgr()
 {
-  myObjectBrowser = theOB;
-  connect(myObjectBrowser, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
 }
 
-XGUI_SelectionMgr::~XGUI_SelectionMgr()
+//**************************************************************
+void XGUI_SelectionMgr::connectViewers()
 {
+  connect(myWorkshop->objectBrowser(), SIGNAL(selectionChanged()), 
+    this, SLOT(onObjectBrowserSelection()));
+
+  //Connect to other viewers
+  if (myWorkshop->isSalomeMode()) {
+    connect(myWorkshop, SIGNAL(salomeViewerSelection()),
+      this, SLOT(onViewerSelection()));
+  } else {
+    connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
+      this, SLOT(onViewerSelection()));
+  }
 }
 
-void XGUI_SelectionMgr::onSelectionChanged()
+//**************************************************************
+void XGUI_SelectionMgr::onObjectBrowserSelection()
 {
-  XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->objectBrowser();
-  mySelectedData = aObjBrowser->selectedData();
-  
-  // Set current document
-  if (mySelectedData.size() > 0) {
-    FeaturePtr aFeature = mySelectedData.first();
-
-    boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
-    boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
-    if (aDocRef)
-      aMgr->setCurrentDocument(aDocRef->value());
-  }
+
+  // TODO: Highliht selected objects in Viewer 3d
 
   emit selectionChanged();
+}
+
+//**************************************************************
+void XGUI_SelectionMgr::onViewerSelection()
+{
+  emit selectionChanged();
+}
+
+//**************************************************************
+QFeatureList XGUI_SelectionMgr::selectedFeatures() const 
+{ 
+  return myWorkshop->objectBrowser()->selectedFeatures(); 
+}
+
+//**************************************************************
+QModelIndexList XGUI_SelectionMgr::selectedIndexes() const 
+{ 
+  return myWorkshop->objectBrowser()->selectionModel()->selectedIndexes();
+}
+
+//**************************************************************
+void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const
+{
+  if (myWorkshop->isSalomeMode()) {
+    Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeConnector()->AISContext();
+    theList.Clear();
+    for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
+      theList.Append(aContext->SelectedInteractive());
+  } else {
+    XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+    aViewer->getSelectedObjects(theList);
+  }
+}
+
+//**************************************************************
+void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
+{
+  if (myWorkshop->isSalomeMode()) {
+    theList.Clear();
+    Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeConnector()->AISContext();
+    for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+      TopoDS_Shape aShape = aContext->SelectedShape();
+      if (!aShape.IsNull())
+        theList.Append(aShape);
+    }
+  } else {
+    XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+    aViewer->getSelectedShapes(theList);
+  }
 }
\ No newline at end of file
index 91b4c255fea2d71ddbf482ace5053820048359cf..b75989abbfb6640bc90ec681c263cc800eb8c4c2 100644 (file)
@@ -4,6 +4,11 @@
 #include "XGUI.h"
 #include "XGUI_Constants.h"
 #include <QObject>
+#include <QModelIndexList>
+
+#include <AIS_ListOfInteractive.hxx>
+#include <NCollection_List.hxx>
+#include <TopoDS_Shape.hxx>
 
 class XGUI_Workshop;
 class XGUI_ObjectsBrowser;
@@ -20,24 +25,32 @@ public:
   XGUI_SelectionMgr(XGUI_Workshop* theParent);
   virtual ~XGUI_SelectionMgr();
 
-  //! Returns list of currently selected objects
-  QFeatureList selectedData() const { return mySelectedData; }
+  //! Returns list of currently selected data objects
+  QFeatureList selectedFeatures() const; 
+  
+  //! Returns list of currently selected QModelIndexes
+  QModelIndexList selectedIndexes() const;
+
+  //! Returns list of currently selected AIS objects
+  void selectedAISObjects(AIS_ListOfInteractive& theList) const;
+
+  //! Returns list of currently selected shapes
+  void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
 
-  void connectObjectBrowser(XGUI_ObjectsBrowser* theOB);
+  //! Connects the manager to all viewers accessible by Workshop
+  void connectViewers();
 
 signals:
   //! Emited when selection in a one of viewers was changed
   void selectionChanged();
 
-public slots:
-  void onSelectionChanged();
+private slots:
+  void onObjectBrowserSelection();
+  void onViewerSelection();
 
 private:
-  XGUI_Workshop* myWorkshop;
-  XGUI_ObjectsBrowser* myObjectBrowser;
 
-  //! List of selected features
-  QFeatureList mySelectedData;
+  XGUI_Workshop* myWorkshop;
 };
 
 #endif
index f02499857f78df73bddb95ad02a5685d725d5ed2..2c4809cb86d9af4f5c7511f479e2114926395a51 100644 (file)
@@ -1166,13 +1166,5 @@ void XGUI_ViewWindow::updateToolBar()
   myGripWgt->update();
   myViewBar->update();
   myWindowBar->update();
-  //QTimer::singleShot(50, Qt::VeryCoarseTimer, this, SLOT(repaintToolBar()));
 }
 
-/*void XGUI_ViewWindow::repaintToolBar()
-{
-  QApplication::sync();
-  myGripWgt->repaint();
-  myViewBar->repaint();
-  myWindowBar->repaint();
-}*/
index dd6e1200fc321ab3db8b5f3fd42f04f45d916ab4..e36e3c26998e037642480ed913fb20c29556a4b4 100644 (file)
@@ -63,6 +63,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   // So, displayer will be created on demand.
 
   mySelector = new XGUI_SelectionMgr(this);
+  connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(changeCurrentDocument()));
   myOperationMgr = new XGUI_OperationMgr(this);
   myActionsMgr = new XGUI_ActionsMgr(this);
   myErrorDlg = new XGUI_ErrorDialog(myMainWindow);
@@ -355,7 +356,7 @@ void XGUI_Workshop::onNew()
   QApplication::setOverrideCursor(Qt::WaitCursor);
   if (objectBrowser() == 0) {
     createDockWidgets();
-    mySelector->connectObjectBrowser(objectBrowser());
+    mySelector->connectViewers();
   }
   showObjectBrowser();
   if (!isSalomeMode()) {
@@ -690,3 +691,25 @@ XGUI_Displayer* XGUI_Workshop::displayer() const
   }
   return myDisplayer;
 }
+
+//******************************************************
+void XGUI_Workshop::changeCurrentDocument()
+{
+  QFeatureList aFeatures = objectBrowser()->selectedFeatures();
+  
+  // Set current document
+  if (aFeatures.size() > 0) {
+    FeaturePtr aFeature = aFeatures.first();
+
+    boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+    boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
+    if (aDocRef)
+      aMgr->setCurrentDocument(aDocRef->value());
+  }
+}
+
+//******************************************************
+void XGUI_Workshop::salomeViewerSelectionChanged()
+{
+  emit salomeViewerSelection();
+}
index 6406381ed243554dbcdd6accc9f70c71d4ba051d..3f857ff12400d7f12e68d8f34869a788b504ac65 100644 (file)
@@ -73,6 +73,11 @@ public:
   //! Returns Object browser
   XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
 
+  void salomeViewerSelectionChanged();
+
+signals:
+  void salomeViewerSelection();
+
 public slots:
   void updateCommandStatus();
 
@@ -90,6 +95,7 @@ public slots:
   void hideObjectBrowser();
 
   void onFeatureTriggered();
+  void changeCurrentDocument();
 
 signals:
   void errorOccurred(const QString&);