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"
9 XGUI_ViewerProxy::XGUI_ViewerProxy(XGUI_Workshop* theParent)
10 : XGUI_SalomeViewer(theParent),
15 Handle(AIS_InteractiveContext) XGUI_ViewerProxy::AISContext() const
17 if (myWorkshop->isSalomeMode()) {
18 return myWorkshop->salomeConnector()->viewer()->AISContext();
20 return myWorkshop->mainWindow()->viewer()->AISContext();
24 Handle(V3d_Viewer) XGUI_ViewerProxy::v3dViewer() const
26 if (myWorkshop->isSalomeMode()) {
27 return myWorkshop->salomeConnector()->viewer()->v3dViewer();
29 return myWorkshop->mainWindow()->viewer()->v3dViewer();
33 Handle(V3d_View) XGUI_ViewerProxy::activeView() const
35 if (myWorkshop->isSalomeMode()) {
36 return myWorkshop->salomeConnector()->viewer()->activeView();
38 XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
39 return (aViewer->activeViewWindow()) ? 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.);
54 void XGUI_ViewerProxy::fitAll()
56 if (myWorkshop->isSalomeMode()) {
57 myWorkshop->salomeConnector()->viewer()->fitAll();
59 XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
60 if (aViewer->activeViewWindow())
61 aViewer->activeViewWindow()->viewPort()->fitAll();
65 void XGUI_ViewerProxy::connectToViewer()
67 if (myWorkshop->isSalomeMode()) {
68 XGUI_SalomeViewer* aViewer = myWorkshop->salomeConnector()->viewer();
70 connect(aViewer, SIGNAL(lastViewClosed()), this, SIGNAL(lastViewClosed()));
71 connect(aViewer, SIGNAL(tryCloseView()), this, SIGNAL(tryCloseView()));
72 connect(aViewer, SIGNAL(deleteView()), this, SIGNAL(deleteView()));
73 connect(aViewer, SIGNAL(viewCreated()), this, SIGNAL(viewCreated()));
74 connect(aViewer, SIGNAL(activated()), this, SIGNAL(activated()));
76 connect(aViewer, SIGNAL(mousePress(QMouseEvent*)), this, SIGNAL(mousePress(QMouseEvent*)));
78 connect(aViewer, SIGNAL(mouseRelease(QMouseEvent*)), this, SIGNAL(mouseRelease(QMouseEvent*)));
80 connect(aViewer, SIGNAL(mouseDoubleClick(QMouseEvent*)), this,
81 SIGNAL(mouseDoubleClick(QMouseEvent*)));
83 connect(aViewer, SIGNAL(mouseMove(QMouseEvent*)), this, SIGNAL(mouseMove(QMouseEvent*)));
85 connect(aViewer, SIGNAL(keyPress(QKeyEvent*)), this, SIGNAL(keyPress(QKeyEvent*)));
87 connect(aViewer, SIGNAL(keyRelease(QKeyEvent*)), this, SIGNAL(keyRelease(QKeyEvent*)));
89 connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
90 connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
91 SIGNAL(contextMenuRequested(QContextMenuEvent*)));
94 XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
96 connect(aViewer, SIGNAL(lastViewClosed()), this, SIGNAL(lastViewClosed()));
97 connect(aViewer, SIGNAL(tryCloseView(XGUI_ViewWindow*)), this, SIGNAL(tryCloseView()));
98 connect(aViewer, SIGNAL(deleteView(XGUI_ViewWindow*)), this, SIGNAL(deleteView()));
99 connect(aViewer, SIGNAL(viewCreated(XGUI_ViewWindow*)), this, SIGNAL(viewCreated()));
100 connect(aViewer, SIGNAL(activated(XGUI_ViewWindow*)), this, SIGNAL(activated()));
102 connect(aViewer, SIGNAL(mousePress(XGUI_ViewWindow*, QMouseEvent*)), this,
103 SLOT(onMousePress(XGUI_ViewWindow*, QMouseEvent*)));
104 connect(aViewer, SIGNAL(mouseRelease(XGUI_ViewWindow*, QMouseEvent*)), this,
105 SLOT(onMouseRelease(XGUI_ViewWindow*, QMouseEvent*)));
106 connect(aViewer, SIGNAL(mouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*)), this,
107 SLOT(onMouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*)));
108 connect(aViewer, SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*)), this,
109 SLOT(onMouseMove(XGUI_ViewWindow*, QMouseEvent*)));
110 connect(aViewer, SIGNAL(keyPress(XGUI_ViewWindow*, QKeyEvent*)), this,
111 SLOT(onKeyPress(XGUI_ViewWindow*, QKeyEvent*)));
112 connect(aViewer, SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*)), this,
113 SLOT(onKeyRelease(XGUI_ViewWindow*, QKeyEvent*)));
115 connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
116 connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
117 SIGNAL(contextMenuRequested(QContextMenuEvent*)));
121 void XGUI_ViewerProxy::onMousePress(XGUI_ViewWindow*, QMouseEvent* theEvent)
123 emit mousePress(theEvent);
126 void XGUI_ViewerProxy::onMouseRelease(XGUI_ViewWindow*, QMouseEvent* theEvent)
128 emit mouseRelease(theEvent);
131 void XGUI_ViewerProxy::onMouseDoubleClick(XGUI_ViewWindow*, QMouseEvent* theEvent)
133 emit mouseDoubleClick(theEvent);
136 void XGUI_ViewerProxy::onMouseMove(XGUI_ViewWindow*, QMouseEvent* theEvent)
138 emit mouseMove(theEvent);
141 void XGUI_ViewerProxy::onKeyPress(XGUI_ViewWindow*, QKeyEvent* theEvent)
143 emit keyPress(theEvent);
146 void XGUI_ViewerProxy::onKeyRelease(XGUI_ViewWindow*, QKeyEvent* theEvent)
148 emit keyRelease(theEvent);
151 //***************************************
152 void XGUI_ViewerProxy::enableSelection(bool isEnabled)
154 if (myWorkshop->isSalomeMode()) {
155 myWorkshop->salomeConnector()->viewer()->enableSelection(isEnabled);
157 myWorkshop->mainWindow()->viewer()->setSelectionEnabled(isEnabled);
161 //***************************************
162 bool XGUI_ViewerProxy::isSelectionEnabled() const
164 if (myWorkshop->isSalomeMode()) {
165 return myWorkshop->salomeConnector()->viewer()->isSelectionEnabled();
167 return myWorkshop->mainWindow()->viewer()->isSelectionEnabled();
171 //***************************************
172 void XGUI_ViewerProxy::enableMultiselection(bool isEnable)
174 if (myWorkshop->isSalomeMode()) {
175 myWorkshop->salomeConnector()->viewer()->enableMultiselection(isEnable);
177 myWorkshop->mainWindow()->viewer()->setMultiSelectionEnabled(isEnable);
181 //***************************************
182 bool XGUI_ViewerProxy::isMultiSelectionEnabled() const
184 if (myWorkshop->isSalomeMode()) {
185 return myWorkshop->salomeConnector()->viewer()->isMultiSelectionEnabled();
187 return myWorkshop->mainWindow()->viewer()->isMultiSelectionEnabled();