1 #include "XGUI_ViewerProxy.h"
2 #include "XGUI_Workshop.h"
3 #include "XGUI_SalomeConnector.h"
4 #include "XGUI_Displayer.h"
6 #include <AppElements_MainWindow.h>
7 #include <AppElements_ViewPort.h>
8 #include <AppElements_ViewWindow.h>
9 #include <AppElements_Viewer.h>
11 XGUI_ViewerProxy::XGUI_ViewerProxy(XGUI_Workshop* theParent)
12 : ModuleBase_IViewer(theParent),
17 Handle(AIS_InteractiveContext) XGUI_ViewerProxy::AISContext() const
19 if (myWorkshop->isSalomeMode()) {
20 return myWorkshop->salomeConnector()->viewer()->AISContext();
22 return myWorkshop->mainWindow()->viewer()->AISContext();
26 Handle(V3d_Viewer) XGUI_ViewerProxy::v3dViewer() const
28 if (myWorkshop->isSalomeMode()) {
29 return myWorkshop->salomeConnector()->viewer()->v3dViewer();
31 return myWorkshop->mainWindow()->viewer()->v3dViewer();
35 Handle(V3d_View) XGUI_ViewerProxy::activeView() const
37 if (myWorkshop->isSalomeMode()) {
38 return myWorkshop->salomeConnector()->viewer()->activeView();
40 AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
41 return (aViewer->activeViewWindow()) ? aViewer->activeViewWindow()->viewPort()->getView() :
46 void XGUI_ViewerProxy::setViewProjection(double theX, double theY, double theZ)
48 Handle(V3d_View) aView3d = activeView();
49 if (!aView3d.IsNull()) {
50 aView3d->SetProj(theX, theY, theZ);
51 aView3d->FitAll(0.01, true, true);
52 aView3d->SetZSize(0.);
56 void XGUI_ViewerProxy::fitAll()
58 if (myWorkshop->isSalomeMode()) {
59 myWorkshop->salomeConnector()->viewer()->fitAll();
61 AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
62 if (aViewer->activeViewWindow())
63 aViewer->activeViewWindow()->viewPort()->fitAll();
67 void XGUI_ViewerProxy::connectToViewer()
69 if (myWorkshop->isSalomeMode()) {
70 ModuleBase_IViewer* aViewer = myWorkshop->salomeConnector()->viewer();
72 connect(aViewer, SIGNAL(lastViewClosed()), this, SIGNAL(lastViewClosed()));
73 connect(aViewer, SIGNAL(tryCloseView(ModuleBase_IViewWindow*)),
74 this, SIGNAL(tryCloseView(ModuleBase_IViewWindow*)));
76 connect(aViewer, SIGNAL(deleteView(ModuleBase_IViewWindow*)),
77 this, SIGNAL(deleteView(ModuleBase_IViewWindow*)));
79 connect(aViewer, SIGNAL(viewCreated(ModuleBase_IViewWindow*)),
80 this, SIGNAL(viewCreated(ModuleBase_IViewWindow*)));
82 connect(aViewer, SIGNAL(activated(ModuleBase_IViewWindow*)),
83 this, SIGNAL(activated(ModuleBase_IViewWindow*)));
85 connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)),
86 this, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)));
88 connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
89 this, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
91 connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)), this,
92 SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
94 connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
95 this, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
97 connect(aViewer, SIGNAL(keyPress(ModuleBase_IViewWindow*, QKeyEvent*)),
98 this, SIGNAL(keyPress(ModuleBase_IViewWindow*, QKeyEvent*)));
100 connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
101 this, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
103 connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
104 connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
105 SIGNAL(contextMenuRequested(QContextMenuEvent*)));
108 AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
110 connect(aViewer, SIGNAL(lastViewClosed()), this, SIGNAL(lastViewClosed()));
112 connect(aViewer, SIGNAL(tryCloseView(AppElements_ViewWindow*)),
113 this, SLOT(onTryCloseView(AppElements_ViewWindow*)));
115 connect(aViewer, SIGNAL(deleteView(AppElements_ViewWindow*)),
116 this, SLOT(onDeleteView(AppElements_ViewWindow*)));
118 connect(aViewer, SIGNAL(viewCreated(AppElements_ViewWindow*)),
119 this, SLOT(onViewCreated(AppElements_ViewWindow*)));
121 connect(aViewer, SIGNAL(activated(AppElements_ViewWindow*)),
122 this, SLOT(onActivated(AppElements_ViewWindow*)));
124 connect(aViewer, SIGNAL(mousePress(AppElements_ViewWindow*, QMouseEvent*)), this,
125 SLOT(onMousePress(AppElements_ViewWindow*, QMouseEvent*)));
127 connect(aViewer, SIGNAL(mouseRelease(AppElements_ViewWindow*, QMouseEvent*)), this,
128 SLOT(onMouseRelease(AppElements_ViewWindow*, QMouseEvent*)));
130 connect(aViewer, SIGNAL(mouseDoubleClick(AppElements_ViewWindow*, QMouseEvent*)), this,
131 SLOT(onMouseDoubleClick(AppElements_ViewWindow*, QMouseEvent*)));
133 connect(aViewer, SIGNAL(mouseMove(AppElements_ViewWindow*, QMouseEvent*)), this,
134 SLOT(onMouseMove(AppElements_ViewWindow*, QMouseEvent*)));
136 connect(aViewer, SIGNAL(keyPress(AppElements_ViewWindow*, QKeyEvent*)), this,
137 SLOT(onKeyPress(AppElements_ViewWindow*, QKeyEvent*)));
139 connect(aViewer, SIGNAL(keyRelease(AppElements_ViewWindow*, QKeyEvent*)), this,
140 SLOT(onKeyRelease(AppElements_ViewWindow*, QKeyEvent*)));
142 connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
143 connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
144 SIGNAL(contextMenuRequested(QContextMenuEvent*)));
149 void XGUI_ViewerProxy::onTryCloseView(AppElements_ViewWindow* theWnd)
151 emit tryCloseView(theWnd);
154 void XGUI_ViewerProxy::onDeleteView(AppElements_ViewWindow* theWnd)
156 emit deleteView(theWnd);
159 void XGUI_ViewerProxy::onViewCreated(AppElements_ViewWindow* theWnd)
161 emit viewCreated(theWnd);
164 void XGUI_ViewerProxy::onActivated(AppElements_ViewWindow* theWnd)
166 emit activated(theWnd);
169 void XGUI_ViewerProxy::onMousePress(AppElements_ViewWindow* theWnd, QMouseEvent* theEvent)
171 emit mousePress(theWnd, theEvent);
174 void XGUI_ViewerProxy::onMouseRelease(AppElements_ViewWindow* theWnd, QMouseEvent* theEvent)
176 emit mouseRelease(theWnd, theEvent);
179 void XGUI_ViewerProxy::onMouseDoubleClick(AppElements_ViewWindow* theWnd, QMouseEvent* theEvent)
181 emit mouseDoubleClick(theWnd, theEvent);
184 void XGUI_ViewerProxy::onMouseMove(AppElements_ViewWindow* theWnd, QMouseEvent* theEvent)
186 emit mouseMove(theWnd, theEvent);
189 void XGUI_ViewerProxy::onKeyPress(AppElements_ViewWindow* theWnd, QKeyEvent* theEvent)
191 emit keyPress(theWnd, theEvent);
194 void XGUI_ViewerProxy::onKeyRelease(AppElements_ViewWindow* theWnd, QKeyEvent* theEvent)
196 emit keyRelease(theWnd, theEvent);
201 //***************************************
202 void XGUI_ViewerProxy::enableSelection(bool isEnabled)
204 if (myWorkshop->isSalomeMode()) {
205 myWorkshop->salomeConnector()->viewer()->enableSelection(isEnabled);
207 myWorkshop->mainWindow()->viewer()->setSelectionEnabled(isEnabled);
211 //***************************************
212 bool XGUI_ViewerProxy::isSelectionEnabled() const
214 if (myWorkshop->isSalomeMode()) {
215 return myWorkshop->salomeConnector()->viewer()->isSelectionEnabled();
217 return myWorkshop->mainWindow()->viewer()->isSelectionEnabled();
221 //***************************************
222 void XGUI_ViewerProxy::enableMultiselection(bool isEnable)
224 if (myWorkshop->isSalomeMode()) {
225 myWorkshop->salomeConnector()->viewer()->enableMultiselection(isEnable);
227 myWorkshop->mainWindow()->viewer()->setMultiSelectionEnabled(isEnable);
231 //***************************************
232 bool XGUI_ViewerProxy::isMultiSelectionEnabled() const
234 if (myWorkshop->isSalomeMode()) {
235 return myWorkshop->salomeConnector()->viewer()->isMultiSelectionEnabled();
237 return myWorkshop->mainWindow()->viewer()->isMultiSelectionEnabled();
241 //***************************************
242 void XGUI_ViewerProxy::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
244 myWorkshop->displayer()->addSelectionFilter(theFilter);
247 //***************************************
248 void XGUI_ViewerProxy::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
250 myWorkshop->displayer()->removeSelectionFilter(theFilter);
253 //***************************************
254 void XGUI_ViewerProxy::clearSelectionFilters()
256 myWorkshop->displayer()->removeFilters();