2 #include "NewGeom_SalomeViewer.h"
3 #include "NewGeom_OCCSelector.h"
5 #include <OCCViewer_ViewWindow.h>
6 #include <OCCViewer_ViewPort3d.h>
8 #include <SUIT_ViewManager.h>
10 NewGeom_SalomeViewer::NewGeom_SalomeViewer(QObject* theParent)
11 : XGUI_SalomeViewer(theParent), mySelector(0)
16 Handle(AIS_InteractiveContext) NewGeom_SalomeViewer::AISContext() const
18 return mySelector->viewer()->getAISContext();
21 Handle(V3d_Viewer) NewGeom_SalomeViewer::v3dViewer() const
23 return mySelector->viewer()->getViewer3d();
26 Handle(V3d_View) NewGeom_SalomeViewer::activeView() const
28 OCCViewer_Viewer* aViewer = mySelector->viewer();
29 SUIT_ViewManager* aMgr = aViewer->getViewManager();
30 OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(aMgr->getActiveView());
31 return aWnd->getViewPort()->getView();
34 void NewGeom_SalomeViewer::setSelector(NewGeom_OCCSelector* theSel)
37 if (mySelector == theSel)
40 mySelector->viewer()->getViewManager()->disconnect(this);
44 OCCViewer_Viewer* aViewer = mySelector->viewer();
45 SUIT_ViewManager* aMgr = aViewer->getViewManager();
47 connect(aMgr, SIGNAL(lastViewClosed(SUIT_ViewManager*)),
48 this, SIGNAL(lastViewClosed()));
49 connect(aMgr, SIGNAL(tryCloseView(SUIT_ViewManager*)),
50 this, SIGNAL(tryCloseView()));
51 connect(aMgr, SIGNAL(deleteView(SUIT_ViewManager*)),
52 this, SIGNAL(deleteView()));
53 connect(aMgr, SIGNAL(viewCreated(SUIT_ViewManager*)),
54 this, SIGNAL(viewCreated()));
55 connect(aMgr, SIGNAL(activated(SUIT_ViewManager*)),
56 this, SIGNAL(activated()));
58 connect(aMgr, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
59 this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
60 connect(aMgr, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
61 this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
62 connect(aMgr, SIGNAL(mouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)),
63 this, SLOT(onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)));
64 connect(aMgr, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)),
65 this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
66 connect(aMgr, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)),
67 this, SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*)));
68 connect(aMgr, SIGNAL(keyRelease(SUIT_ViewWindow*, QKeyEvent*)),
69 this, SLOT(onKeyRelease(SUIT_ViewWindow*, QKeyEvent*)));
73 void NewGeom_SalomeViewer::onMousePress(SUIT_ViewWindow*, QMouseEvent* theEvent)
75 emit mousePress(theEvent);
78 void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow*, QMouseEvent* theEvent)
80 emit mouseRelease(theEvent);
83 void NewGeom_SalomeViewer::onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent* theEvent)
85 emit mouseDoubleClick(theEvent);
88 void NewGeom_SalomeViewer::onMouseMove(SUIT_ViewWindow*, QMouseEvent* theEvent)
90 emit mouseMove(theEvent);
93 void NewGeom_SalomeViewer::onKeyPress(SUIT_ViewWindow*, QKeyEvent* theEvent)
95 emit keyPress(theEvent);
98 void NewGeom_SalomeViewer::onKeyRelease(SUIT_ViewWindow*, QKeyEvent* theEvent)
100 emit keyRelease(theEvent);