]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Viewer.cpp
Salome HOME
8e77443730c02840bd6c513ed5087a83e918a49e
[modules/shaper.git] / src / XGUI / XGUI_Viewer.cpp
1 #include "XGUI_Viewer.h"
2 #include "XGUI_MainWindow.h"
3 #include "XGUI_ViewWindow.h"
4
5 #include <QMdiArea>
6 #include <QMdiSubWindow>
7
8 #include <V3d_View.hxx>
9
10 #include <Aspect_DisplayConnection.hxx>
11 #include <Graphic3d.hxx>
12 #include <Graphic3d_GraphicDriver.hxx>
13
14 #ifdef WIN32
15 #include <WNT_Window.hxx>
16 #else
17 #include <Xw_Window.hxx>
18 #endif
19
20
21 /*!
22     Creates viewer 3d [ static ]
23 */
24 Handle(V3d_Viewer) CreateViewer( const Standard_ExtString name,
25                                                      const Standard_CString displayName,
26                                                      const Standard_CString domain,
27                                                      const Standard_Real viewSize ,
28                                                      const V3d_TypeOfOrientation viewProjection,
29                                                      const Standard_Boolean computedMode,
30                                                      const Standard_Boolean defaultComputedMode )
31 {
32   static Handle(Graphic3d_GraphicDriver) aGraphicDriver;
33   if (aGraphicDriver.IsNull())
34   {
35     Handle(Aspect_DisplayConnection) aDisplayConnection;
36 #ifndef WIN32
37     aDisplayConnection = new Aspect_DisplayConnection( displayName );
38 #else
39     aDisplayConnection = new Aspect_DisplayConnection();
40 #endif
41     aGraphicDriver = Graphic3d::InitGraphicDriver( aDisplayConnection );
42   }
43
44   return new V3d_Viewer( aGraphicDriver, name, domain, viewSize, viewProjection,
45                          Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
46                          computedMode, defaultComputedMode, V3d_TEX_NONE );
47 }
48
49
50
51 XGUI_Viewer::XGUI_Viewer(XGUI_MainWindow* theParent) :
52 QObject(theParent), myMainWindow(theParent)
53 {
54     // init CasCade viewers
55     myV3dViewer = CreateViewer(TCollection_ExtendedString("Viewer3d").ToExtString(),
56                                                    "", "", 1000.0, V3d_XposYnegZpos, Standard_True, Standard_True );
57     //myV3dViewer->Init(); // to avoid creation of the useless perspective view (see OCCT issue 0024267)
58     myV3dViewer->SetDefaultLights();
59
60     // init selector
61     myAISContext = new AIS_InteractiveContext( myV3dViewer );
62     myAISContext->SelectionColor( Quantity_NOC_WHITE );
63   
64     // display isoline on planar faces (box for ex.)
65     myAISContext->IsoOnPlane( true );
66 }
67
68
69 XGUI_Viewer::~XGUI_Viewer(void)
70 {
71 }
72
73
74 QMdiSubWindow* XGUI_Viewer::createView(V3d_TypeOfView theType)
75 {
76     // create view frame
77     XGUI_ViewWindow* view = new XGUI_ViewWindow(this, theType);
78     // get main view window (created by view frame)
79     //OCCViewer_ViewWindow* vw = view->getView(OCCViewer_ViewFrame::MAIN_VIEW);
80     // initialize main view window
81     //initView( vw );
82     // set default background for view window
83     //vw->setBackground( background(0) ); // 0 means MAIN_VIEW (other views are not yet created here)
84     //// connect signal from viewport
85     //connect(view->getViewPort(), SIGNAL(vpClosed()), this, SLOT(onViewClosed()));
86     //connect(view->getViewPort(), SIGNAL(vpMapped()), this, SLOT(onViewMapped()));
87
88     QMdiArea* aMDI = myMainWindow->mdiArea();
89     QMdiSubWindow* aWnd = aMDI->addSubWindow(view, Qt::FramelessWindowHint);
90     aWnd->setGeometry(0,0, aMDI->width() / 2, aMDI->height() / 2);
91     aWnd->show();
92     return aWnd;
93 }