View, Viewer and Context

Could someone please explain the difference. I am trying to build a simple opencascade application using qt. Now I don't want anything fancy, just to click a menu item which
opens up a new window. In this window the standard tutorial 3d bottle is to be displayed.
So I have created a main window which just sets up the menus and actions but also sets up
the graphics driver in its constructor with the following line of code:

m_GraphicDriver=new OpenGl_GraphicDriver("TKOpenGl");

when the menu item is triggered I call the create new window function:

this function should create a new window and display the bottle. Now here is the implementation:

void MainWindow::createWindow(){
//Create the bottle and convert it to AIS_Shape
TopoDS_Shape aBottle=MakeBottle(50,70,30);
Handle(AIS_Shape) AISBottle=new AIS_Shape(aBottle);

qDebug() TCollection_ExtendedString aNameOfViewer ("Visu3D");
Handle(V3d_Viewer) aViewer = new V3d_Viewer (m_GraphicDriver, aNameOfViewer.ToExtString());

qDebug() Handle(AIS_InteractiveContext) aContext;

qDebug() aContext = new AIS_InteractiveContext(aViewer);

qDebug() aContext -> Display(AISBottle);
}

This is ok, and executes fine but there is no window showing up. How can I setup an MDI area
and place widget inside which shows all the 3D stuff?

Thanks

Alexey's picture

Hello!
Now your viewer has no view. You should create view ( _viewer->CreateView() ), then map view to the qt widget window ( see qt examples).

Aris Karagiannidis's picture

Thank you for the answer. But it is not really helping me. I should mention that I am a complete opencascade beginner. Looking at the qt samples Common\src\View.cxx and lines 188 to 210 my function is now:

void MainWindow::createWindow(){
Display *win = new Display(0);

TopoDS_Shape aBottle=MakeBottle(50,70,30);
Handle(AIS_Shape) AISBottle=new AIS_Shape(aBottle);

qDebug() << "Creatinr Viewer";
TCollection_ExtendedString aNameOfViewer ("Visu3D");
Handle(V3d_Viewer) aViewer = new V3d_Viewer (m_GraphicDriver, aNameOfViewer.ToExtString());

qDebug() << "Creating Context";
Handle(AIS_InteractiveContext) aContext;

qDebug() << "Populating Context";
aContext = new AIS_InteractiveContext(aViewer);

qDebug() << "Try to Display";
aContext -> Display(AISBottle); //Display the presentable object in the 3d viewer.

qDebug() << "Creating a View";
Handle(V3d_View) aView = aViewer->CreateView();

qDebug() << "Creating Aspect Handle";
Aspect_Handle aWindowHandle = (Aspect_Handle )winId();

qDebug() << "Creating WNT_Window";
Handle(WNT_Window) hWnd = new WNT_Window (aWindowHandle);

aView->SetWindow(hWnd);
win->show();
}

but now I get a runtime error saying that the application has requested the runtime to terminate it in an unusual way.