Trihedron help

DVN1991

CAD practitioner
Hi everyone,
Could someone help me on how to visualize the orientation cube showing the position of the camera, also how could I orient the camera view along the preferred axis.
Thanks

regards
 

Jonathan

CAD community veteran
Handle(Aspect_DisplayConnection) aDisplayConnection;
myGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);
myViewer = new V3d_Viewer(myGraphicDriver);
myAISContext = new AIS_InteractiveContext(myViewer);

myView = myViewer ->CreateView();
myView->SetProj(V3d_TypeOfOrientation::V3d_TypeOfOrientation_Zup_Left); // sets the camera

Handle(AIS_ViewCube) vc = new AIS_ViewCube(); // create a view cube
myAISContext->Display(vc, true); // display it
 

natalia

Moderator
Staff member
There are many options to change the default style of view cube.
Using some of them the view cube may have the next presentation:

view_cube.jpg

For having this customized view cube, the following settings are appliyed to the presentation:
  • switch off the scene lights for the view cube,
  • change size of the view cube,
  • change text font and size,
  • show edges on border of the view cube,
  • increase distance between view cube and trihedron,
  • change colors of view cube sides, corners and axes,
  • hide tips and sphere on view cube.
The next code do this custom style setting:
C++:
      // prepare material to disable scene lights
      Graphic3d_MaterialAspect material(Graphic3d_NameOfMaterial_DEFAULT);
      material.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
      material.SetSpecularColor(Quantity_NOC_BLACK);
      material.SetAmbientColor(Quantity_NOC_BLACK);
      material.SetDiffuseColor(Quantity_NOC_BLACK);
      material.SetEmissiveColor(Quantity_NOC_BLACK);
      material.SetShininess(0);

      // change color and switch off ligthning on the box sides
      vc->Attributes()->ShadingAspect()->SetColor (Quantity_NOC_WHITE);
      vc->Attributes()->ShadingAspect()->SetMaterial (material);

      vc->BoxCornerStyle()->SetColor (Quantity_Color(150. / 255., 150. / 255., 150. /255., Quantity_TOC_sRGB));
      vc->BoxCornerStyle()->SetMaterial (material);

      vc->BoxEdgeStyle()->SetColor (Quantity_Color(200. / 255., 200. / 255., 200. /255., Quantity_TOC_sRGB));
      vc->BoxEdgeStyle()->SetMaterial (material);

      // show edges on border
      vc->Attributes()->SetFaceBoundaryDraw(true);
      vc->Attributes()->SetupOwnFaceBoundaryAspect();
      vc->Attributes()->FaceBoundaryAspect()->SetColor(Quantity_NOC_BLACK);
      vc->Attributes()->FaceBoundaryAspect()->SetWidth(0.5);

      // manage axes
      vc->Attributes()->SetOwnDatumAspects();
      vc->Attributes()->DatumAspect()->SetToDrawLabels(Standard_False);
      for (Standard_Integer anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis; ++anAxisIter)
      {
        const Prs3d_DatumParts part = (Prs3d_DatumParts )anAxisIter;
        vc->Attributes()->DatumAspect()->ShadingAspect(part)->SetMaterial (material);
        vc->Attributes()->DatumAspect()->ShadingAspect(part)->SetColor(
          Quantity_Color(200. / 255., 200. / 255., 200. /255., Quantity_TOC_sRGB));
      }

      // hide arrows and sphere for axes of trihedron
      vc->SetAxesConeRadius(0.);
      vc->SetAxesSphereRadius(1.);

      vc->SetAxesRadius(0.6);
      vc->SetSize(60);
      vc->SetAxesPadding(15);

      // text height should be after SetSize because it scales this height
      vc->Attributes()->TextAspect()->SetHeight (12);
      vc->Attributes()->TextAspect()->SetFont (Font_NOF_ASCII_DUPLEX);

Please, note that we should manage these setting before calling 'Display' for the view cube in context. If we do this after the view cube is shown, we need to call 'Redisplay' to apply these setting for presentation.
 
Top