1 #include "XGUI_Viewer.h"
2 #include "XGUI_MainWindow.h"
3 #include "XGUI_ViewWindow.h"
6 #include <QMdiSubWindow>
8 #include <V3d_View.hxx>
10 #include <Aspect_DisplayConnection.hxx>
11 #include <Graphic3d.hxx>
12 #include <Graphic3d_GraphicDriver.hxx>
15 #include <WNT_Window.hxx>
17 #include <Xw_Window.hxx>
22 Creates viewer 3d [ static ]
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 )
32 static Handle(Graphic3d_GraphicDriver) aGraphicDriver;
33 if (aGraphicDriver.IsNull())
35 Handle(Aspect_DisplayConnection) aDisplayConnection;
37 aDisplayConnection = new Aspect_DisplayConnection( displayName );
39 aDisplayConnection = new Aspect_DisplayConnection();
41 aGraphicDriver = Graphic3d::InitGraphicDriver( aDisplayConnection );
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 );
51 XGUI_Viewer::XGUI_Viewer(XGUI_MainWindow* theParent) :
52 QObject(theParent), myMainWindow(theParent)
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();
61 myAISContext = new AIS_InteractiveContext( myV3dViewer );
62 myAISContext->SelectionColor( Quantity_NOC_WHITE );
64 // display isoline on planar faces (box for ex.)
65 myAISContext->IsoOnPlane( true );
69 XGUI_Viewer::~XGUI_Viewer(void)
74 QMdiSubWindow* XGUI_Viewer::createView(V3d_TypeOfView theType)
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
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()));
88 QMdiArea* aMDI = myMainWindow->mdiArea();
89 QMdiSubWindow* aWnd = aMDI->addSubWindow(view, Qt::FramelessWindowHint);
90 aWnd->setGeometry(0,0, aMDI->width() / 2, aMDI->height() / 2);