1 #include "XGUI_ViewerProxy.h"
2 #include "XGUI_Workshop.h"
3 #include "XGUI_MainWindow.h"
4 #include "XGUI_ViewPort.h"
5 #include "XGUI_ViewWindow.h"
6 #include "XGUI_Viewer.h"
7 #include "XGUI_SalomeConnector.h"
10 XGUI_ViewerProxy::XGUI_ViewerProxy(XGUI_Workshop* theParent)
11 : XGUI_SalomeViewer(theParent), myWorkshop(theParent)
16 Handle(AIS_InteractiveContext) XGUI_ViewerProxy::AISContext() const
18 if (myWorkshop->isSalomeMode()) {
19 return myWorkshop->salomeConnector()->viewer()->AISContext();
21 return myWorkshop->mainWindow()->viewer()->AISContext();
25 Handle(V3d_Viewer) XGUI_ViewerProxy::v3dViewer() const
27 if (myWorkshop->isSalomeMode()) {
28 return myWorkshop->salomeConnector()->viewer()->v3dViewer();
30 return myWorkshop->mainWindow()->viewer()->v3dViewer();
34 Handle(V3d_View) XGUI_ViewerProxy::activeView() const
36 if (myWorkshop->isSalomeMode()) {
37 return myWorkshop->salomeConnector()->viewer()->activeView();
39 XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
40 return aViewer->activeViewWindow()->viewPort()->getView();
44 void XGUI_ViewerProxy::setViewProjection(double theX, double theY, double theZ)
46 Handle(V3d_View) aView3d = activeView();
47 if ( !aView3d.IsNull() ) {
48 aView3d->SetProj(theX, theY, theZ);
49 aView3d->FitAll( 0.01, true, true );
50 aView3d->SetZSize(0.);
55 void XGUI_ViewerProxy::connectToViewer()
57 if (myWorkshop->isSalomeMode()) {
58 XGUI_SalomeViewer* aViewer = myWorkshop->salomeConnector()->viewer();
60 connect(aViewer, SIGNAL(lastViewClosed()),
61 this, SIGNAL(lastViewClosed()));
62 connect(aViewer, SIGNAL(tryCloseView()),
63 this, SIGNAL(tryCloseView()));
64 connect(aViewer, SIGNAL(deleteView()),
65 this, SIGNAL(deleteView()));
66 connect(aViewer, SIGNAL(viewCreated()),
67 this, SIGNAL(viewCreated()));
68 connect(aViewer, SIGNAL(activated()),
69 this, SIGNAL(activated()));
71 connect(aViewer, SIGNAL(mousePress(QMouseEvent*)),
72 this, SIGNAL(mousePress(QMouseEvent*)));
74 connect(aViewer, SIGNAL(mouseRelease(QMouseEvent*)),
75 this, SIGNAL(mouseRelease(QMouseEvent*)));
77 connect(aViewer, SIGNAL(mouseDoubleClick(QMouseEvent*)),
78 this, SIGNAL(mouseDoubleClick(QMouseEvent*)));
80 connect(aViewer, SIGNAL(mouseMove(QMouseEvent*)),
81 this, SIGNAL(mouseMove(QMouseEvent*)));
83 connect(aViewer, SIGNAL(keyPress(QKeyEvent*)),
84 this, SIGNAL(keyPress(QKeyEvent*)));
86 connect(aViewer, SIGNAL(keyRelease(QKeyEvent*)),
87 this, SIGNAL(keyRelease(QKeyEvent*)));
89 XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
91 connect(aViewer, SIGNAL(lastViewClosed()),
92 this, SIGNAL(lastViewClosed()));
93 connect(aViewer, SIGNAL(tryCloseView(XGUI_ViewWindow*)),
94 this, SIGNAL(tryCloseView()));
95 connect(aViewer, SIGNAL(deleteView(XGUI_ViewWindow*)),
96 this, SIGNAL(deleteView()));
97 connect(aViewer, SIGNAL(viewCreated(XGUI_ViewWindow*)),
98 this, SIGNAL(viewCreated()));
99 connect(aViewer, SIGNAL(activated(XGUI_ViewWindow*)),
100 this, SIGNAL(activated()));
102 connect(aViewer, SIGNAL(mousePress(XGUI_ViewWindow*, QMouseEvent*)),
103 this, SLOT(onMousePress(XGUI_ViewWindow*, QMouseEvent*)));
104 connect(aViewer, SIGNAL(mouseRelease(XGUI_ViewWindow*, QMouseEvent*)),
105 this, SLOT(onMouseRelease(XGUI_ViewWindow*, QMouseEvent*)));
106 connect(aViewer, SIGNAL(mouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*)),
107 this, SLOT(onMouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*)));
108 connect(aViewer, SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*)),
109 this, SLOT(onMouseMove(XGUI_ViewWindow*, QMouseEvent*)));
110 connect(aViewer, SIGNAL(keyPress(XGUI_ViewWindow*, QKeyEvent*)),
111 this, SLOT(onKeyPress(XGUI_ViewWindow*, QKeyEvent*)));
112 connect(aViewer, SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*)),
113 this, SLOT(onKeyRelease(XGUI_ViewWindow*, QKeyEvent*)));
117 void XGUI_ViewerProxy::onMousePress(XGUI_ViewWindow*, QMouseEvent* theEvent)
119 emit mousePress(theEvent);
122 void XGUI_ViewerProxy::onMouseRelease(XGUI_ViewWindow*, QMouseEvent* theEvent)
124 emit mouseRelease(theEvent);
127 void XGUI_ViewerProxy::onMouseDoubleClick(XGUI_ViewWindow*, QMouseEvent* theEvent)
129 emit mouseDoubleClick(theEvent);
132 void XGUI_ViewerProxy::onMouseMove(XGUI_ViewWindow*, QMouseEvent* theEvent)
134 emit mouseMove(theEvent);
137 void XGUI_ViewerProxy::onKeyPress(XGUI_ViewWindow*, QKeyEvent* theEvent)
139 emit keyPress(theEvent);
142 void XGUI_ViewerProxy::onKeyRelease(XGUI_ViewWindow*, QKeyEvent* theEvent)
144 emit keyRelease(theEvent);
147 //***************************************
148 void XGUI_ViewerProxy::enableSelection(bool isEnabled)
150 if (myWorkshop->isSalomeMode()) {
151 myWorkshop->salomeConnector()->viewer()->enableSelection(isEnabled);
153 myWorkshop->mainWindow()->viewer()->setSelectionEnabled(isEnabled);
157 //***************************************
158 bool XGUI_ViewerProxy::isSelectionEnabled() const
160 if (myWorkshop->isSalomeMode()) {
161 return myWorkshop->salomeConnector()->viewer()->isSelectionEnabled();
163 return myWorkshop->mainWindow()->viewer()->isSelectionEnabled();
167 //***************************************
168 void XGUI_ViewerProxy::enableMultiselection(bool isEnable)
170 if (myWorkshop->isSalomeMode()) {
171 myWorkshop->salomeConnector()->viewer()->enableMultiselection(isEnable);
173 myWorkshop->mainWindow()->viewer()->setMultiSelectionEnabled(isEnable);
177 //***************************************
178 bool XGUI_ViewerProxy::isMultiSelectionEnabled() const
180 if (myWorkshop->isSalomeMode()) {
181 return myWorkshop->salomeConnector()->viewer()->isMultiSelectionEnabled();
183 return myWorkshop->mainWindow()->viewer()->isMultiSelectionEnabled();