1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU VISUGUI : GUI of VISU component
23 // File : VisuGUI_ViewExtender.cxx
24 // Author : Vitaly Smetannikov
27 #include "VisuGUI_ViewExtender.h"
30 #include "VisuGUI_SegmentationMgr.h"
31 #include "VisuGUI_ViewTools.h"
32 #include "VisuGUI_Tools.h"
33 #include <VTKViewer_Actor.h>
35 #include <LightApp_SelectionMgr.h>
36 #include <SalomeApp_Application.h>
38 #include <VISU_PipeLine.hxx>
39 #include <SUIT_ViewManager.h>
40 #include <SUIT_ViewWindow.h>
42 #include <SVTK_ViewModel.h>
43 #include <SVTK_ViewWindow.h>
47 //using namespace std;
49 VisuGUI_ViewExtender::VisuGUI_ViewExtender(VisuGUI* theModule):
54 //****************************************************************
55 VisuGUI_ViewExtender::~VisuGUI_ViewExtender()
57 QMapIterator<SVTK_ViewWindow*, VisuGUI_SegmentationMgr*> aIt(myViewMgrMap);
58 while (aIt.hasNext()) {
64 //****************************************************************
65 int VisuGUI_ViewExtender::createToolbar(SUIT_ViewWindow* theView)
67 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(theView);
68 if (!aViewWindow) return -1;
70 VisuGUI_SegmentationMgr* aMgr = getSegmentationMgr(aViewWindow);
71 return aMgr->createToolbar(theView->toolMgr());
74 //****************************************************************
75 void VisuGUI_ViewExtender::contextMenuPopup(QMenu* theMenu)
77 // SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule);
78 // if (!aViewWindow) return;
80 // SalomeApp_Application* anApp = myModule->getApp();
81 // LightApp_SelectionMgr* aSelectionMgr = VISU::GetSelectionMgr(myModule);
83 // aSelectionMgr->selectedObjects(myListIO);
84 // if (myListIO.IsEmpty()) return;
86 // theMenu->addSeparator();
87 // theMenu->addAction(tr("VISU_SETPLANES_MNU"), this, SLOT(onSetPlanes()));
91 //****************************************************************
92 void VisuGUI_ViewExtender::activate(SUIT_ViewModel* theViewer)
94 // Connect to signal on destroy ViewWindow
95 SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(theViewer);
97 if (!myViewers.contains(aViewer)) {
98 SUIT_ViewManager* aMgr = aViewer->getViewManager();
99 connect(aMgr, SIGNAL(deleteView(SUIT_ViewWindow*)),
100 this, SLOT(onViewDeleted(SUIT_ViewWindow*)));
101 connect(aViewer, SIGNAL(actorAdded(SVTK_ViewWindow*, VTKViewer_Actor*)),
102 this, SLOT(onAddActor(SVTK_ViewWindow*, VTKViewer_Actor*)));
103 myViewers.append(aViewer);
108 //****************************************************************
109 void VisuGUI_ViewExtender::deactivate(SUIT_ViewModel*)
111 QMapIterator<SVTK_ViewWindow*, VisuGUI_SegmentationMgr*> aIt(myViewMgrMap);
112 while (aIt.hasNext()) {
114 aIt.value()->deactivate();
119 //****************************************************************
120 VisuGUI_SegmentationMgr* VisuGUI_ViewExtender::getSegmentationMgr(SVTK_ViewWindow* theWindow)
122 if (myViewMgrMap.contains(theWindow))
123 return myViewMgrMap[theWindow];
125 VisuGUI_SegmentationMgr* aMgr = new VisuGUI_SegmentationMgr(myModule, theWindow);
126 myViewMgrMap[theWindow] = aMgr;
130 //****************************************************************
131 void VisuGUI_ViewExtender::onViewDeleted(SUIT_ViewWindow* theWindow)
133 SVTK_ViewWindow* aWindow = dynamic_cast<SVTK_ViewWindow*>(theWindow);
134 if (!aWindow) return;
136 if (!myViewMgrMap.contains(aWindow)) return;
137 delete myViewMgrMap[aWindow];
138 myViewMgrMap.remove(aWindow);
141 //****************************************************************
142 void VisuGUI_ViewExtender::onAddActor(SVTK_ViewWindow* theWindow, VTKViewer_Actor* theActor)
144 if (!myViewMgrMap.contains(theWindow)) return;
145 myViewMgrMap[theWindow]->onAddActor(theActor);