Need Help

Hi I am a new user of Opencascade, My problem is that I am unable to draw or visualize an object when I am trying to draw through a Dialog Box Class. I donot understand what is the problem as there are no errors during compilation, but there is no object(box) appears in the graphics area The code which I have written to display an object after pressing Ok button of dialog box is
CDialog::OnOK();

Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
((CSampleViewer3dApp*)AfxGetApp())->GetGraphicDevice();

Handle(V3d_Viewer)myViewer= new V3d_Viewer(theGraphicDevice,(short *) "Visu3D");

Handle(AIS_InteractiveContext)myAISContext= new AIS_InteractiveContext(myViewer);
myViewer->SetDefaultLights();
myViewer->SetLightOn();

myAISContext =new AIS_InteractiveContext(myViewer);
AfxInitRichEdit();

BRepPrimAPI_MakeBox B(gp_Pnt(0,-400,-100), 800.,600.,400.);
Handle(AIS_Shape) aBox = new AIS_Shape(B.Shape());

myAISContext->SetMaterial(aBox,Graphic3d_NOM_SILVER);
myAISContext->SetColor(aBox,Quantity_NOC_PURPLE1);
myAISContext->SetDisplayMode(aBox,1);
myAISContext->Display(aBox)
The same code when I put in Document class works and displays the object

Could some body help me in this regard

Thanks

Fayyaz

DU's picture

You can see the sample of Cascade "HLR". It means you have to get a safe handle from the dialog field. nevertheless, you can also search the same topic in the forum.

Regards,

Du

Sharjith Naramparambath's picture

Hi,
See the SampleHLR application. Well whatever you did for creating the viewer and the view has to be done in the InitDialog() function and only creation of the topological objects in the OnOK() function.
You also have to override the OnDrawItem() of the CDialog after creating a dummy control into which your viewer will fit. Best Luck!

N Sharjith

Fayyaz's picture

Hi
Thanks for your reply, I have put creation of my viewer and view in InitDialog() function
Could you tell me how to create a dummy control to put veiwer in it and why is it necessary to do so
Thanks
Fayyaz