]> OCCT Git - occt.git/commitdiff
0030662: Documentation - update programming example in Visualization user guide
authorkgv <kgv@opencascade.com>
Fri, 11 Sep 2020 14:37:37 +0000 (17:37 +0300)
committerabv <abv@opencascade.com>
Sat, 12 Sep 2020 17:42:25 +0000 (20:42 +0300)
"A programming example" section has been updated to provide a working code.

dox/user_guides/visualization/visualization.md

index 3337a7842b87aac9f599b47109d3fb6a3ce24f55..fdb948d80731d4781776bd42c4ba5601fb4949c1 100644 (file)
@@ -1542,40 +1542,38 @@ Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver (aDispCon
 // create a Viewer to this Driver
 Handle(V3d_Viewer) aViewer = new V3d_Viewer (aGraphicDriver);
 aViewer->SetDefaultBackgroundColor (Quantity_NOC_DARKVIOLET);
-aViewer->SetDefaultViewProj (V3d_Xpos);
 // Create a structure in this Viewer
-Handle(Graphic3d_Structure) aStruct = new Graphic3d_Structure (aViewer->Viewer());
+Handle(Graphic3d_Structure) aStruct = new Graphic3d_Structure (aViewer->StructureManager());
 aStruct->SetVisual (Graphic3d_TOS_SHADING); // Type of structure
-
 // Create a group of primitives  in this structure
-Handle(Graphic3d_Group) aPrsGroup = new Graphic3d_Group (aStruct);
-
+Handle(Graphic3d_Group) aPrsGroup = aStruct->NewGroup();
 // Fill this group with one quad of size 100
 Handle(Graphic3d_ArrayOfTriangleStrips) aTriangles = new Graphic3d_ArrayOfTriangleStrips (4);
 aTriangles->AddVertex (-100./2., -100./2., 0.0);
 aTriangles->AddVertex (-100./2.,  100./2., 0.0);
 aTriangles->AddVertex ( 100./2., -100./2., 0.0);
 aTriangles->AddVertex ( 100./2.,  100./2., 0.0);
+Handle(Graphic3d_AspectFillArea3d) anAspects = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, Quantity_NOC_RED,
+                                                                               Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0f,
+                                                                               Graphic3d_NOM_GOLD, Graphic3d_NOM_GOLD);
+aPrsGroup->SetGroupPrimitivesAspect (anAspects);
 aPrsGroup->AddPrimitiveArray (aTriangles);
-aPrsGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectFillArea3d());
-
 // Create Ambient and Infinite Lights in this Viewer
 Handle(V3d_AmbientLight)     aLight1 = new V3d_AmbientLight (Quantity_NOC_GRAY50);
-Handle(V3d_DirectionalLight) aLight2 = new V3d_DirectionalLight (V3d_XnegYnegZneg, Quantity_NOC_WHITE);
+Handle(V3d_DirectionalLight) aLight2 = new V3d_DirectionalLight (V3d_Zneg, Quantity_NOC_WHITE, true);
 aViewer->AddLight (aLight1);
 aViewer->AddLight (aLight2);
-
+aViewer->SetLightOn();
 // Create a 3D quality  Window with the same DisplayConnection
 Handle(Xw_Window) aWindow = new Xw_Window (aDispConnection, "Test V3d", 100, 100, 500, 500);
 aWindow->Map(); // Map this Window to this screen
-
 // Create a Perspective  View in this Viewer
 Handle(V3d_View) aView = new V3d_View (aViewer);
 aView->Camera()->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
 // Associate this View with the Window
 aView->SetWindow (aWindow);
-// Display ALL structures in this View
-aViewer->Viewer()->Display();
+// Display presentation in this View
+aStruct->Display();
 // Finally update the Visualization in this View
 aView->Update();
 // Fit view to object size