Help, about linewidth in V3d_view

I tried drawexe sample :

vinit​
vlayerline 0 300 300 300 10 

it is no problem to show the linewidth 10.

But when I code in my code c++ with Viewer or V3d_view.

I can not let line have linewidth.

I don't know which parameter can controll the display in screen to show linewidth.

If anyone know about this , could you help me?

the setting about my viewer and view:

 


  Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver (myOcctWindow->GetDisplay(), false);
  Handle(V3d_Viewer) aViewer = new V3d_Viewer (aGraphicDriver);
  aViewer->SetDefaultLights();
  aViewer->SetLightOn();
  aViewer->SetDefaultTypeOfView (V3d_PERSPECTIVE);
  aViewer->ActivateGrid (Aspect_GT_Rectangular, Aspect_GDM_Lines);

  myView = aViewer->CreateView();
  myView->SetImmediateUpdate (false);
  myView->SetWindow (myOcctWindow, myOcctWindow->NativeGlContext());
  myView->ChangeRenderingParams().ToShowStats = true;
  myContext = new AIS_InteractiveContext (aViewer);

 

Kirill Gavrilov's picture

There is NO global parameter defining line width in the viewer.
This aspect is configured for specific presentation via related Prs3d_LineAspect/Graphic3d_AspectLine3d property.

Within your code sample you are displaying a rectangular grid, so I suppose that your question is related to this object.
In fact, V3d_RectangularGrid presentation simply does not expose line width property, it is hard-coded as 1.0 and cannot be changed without modifying OCCT:

    Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d (myColor, Aspect_TOL_SOLID, 1.0);
    myGroup->SetPrimitivesAspect (aLineAspect);
haidong ma's picture

@Kirill Gavrilov  , thanks for your fast reply and help.

Firstly, I am sorry for this  wrong pic Screen_Shot_2019-09-24_at_23.53.03.png , it mislead you to the question about  displaying a rectangular grid.

Now I post the whole codes in attachments which is reusing the code from official MFC sample.

I used it in my GLFW demo.

for(int i=0;i<=5;++i)

    for(int j=0;j<=5;++j)

    {

      Handle(Geom_Point) aStart = new Geom_CartesianPoint(gp_Pnt(10*i,10*j,0.));

      Handle(Geom_Point) anEnd = new Geom_CartesianPoint(gp_Pnt(10*i+5,10*j+10,0.));

      Handle(AIS_Line) aLine = new AIS_Line(aStart,anEnd);

      Handle(Prs3d_LineAspect) aLineAttrib =

        new Prs3d_LineAspect((Quantity_NameOfColor)(Quantity_NOC_CADETBLUE+2*i+2*j),

        (Aspect_TypeOfLine)((Aspect_TOL_DASH+i+j)%5),2+i+j);

      aLine->Attributes()->SetLineAspect(aLineAttrib);

      myAISContext->Display(aLine,Standard_False);   

    }

You can see the linewidth in MFC sample, but you still can not see line width in my GLFW demo.

As you said there is NO global parameter defining linewidth in the viewer,  so I don’t know why there is no linewidth in my GLFW demo code.

Kirill Gavrilov's picture

This is because OpenGL within Core Profile does not support line width other than 1.

  const bool toAskCoreProfile = true;
  if (toAskCoreProfile)
  {
    glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
haidong ma's picture

Thanks again for your help. It save me a lot of time.