[C++ SDK] Change curve thickness when drawing

I would like to change the curve thickness that I draw when I get a CRhinoDrawGripsSettings object.

Currently I can do this for a polyline:

CRhinoDrawGripsSettings dgs; // defined elsewhere
ON_Polyline pl; // defined elsewhere
int thickness = 2; // <-- here I can change the thickness for a polyline
COLORREF clr = RGB(255,0,0);

dgs.m_dp.DrawPolyline(pl, crl, thickness);

I also want to draw a curve. For that I can’t use the display pipeline m_dp but I can use the viewport m_vp like so:

CRhinoDrawGripsSettings dgs; // defined elsewhere
ON_Curve crv; // defined elsewhere
ON_NurbsCurve nc;
if (crv.GetNurbForm(nc)) {
    COLORREF clr = RGB(255,0,0);
    COLORREF old = dgs.m_vp.DrawColor();
    dgs.m_vp.DrawNurbsCurve(nc); // <-- How to set the thickness for this curve?
    dgs.m_vp.SetDrawColor(old);  // set to previous value

So, what I want to achieve is, given a CRhinoDrawGripsSettings object, to draw a curve with thickness of 2. Currently, I use the viewport to call DrawNurbsCurve but I don’t see how to set the thickness with which the curve is drawn.

Hi Menno,

It is not clear to me why you are using a CRhinoDrawGripsSettings object, which is used for drawing grips and their control polygon.

Keep in mind that drawing routines, found on CRhinoViewport, eventually end calling lower-level drawing routines on CRhinoDisplayPipeline. CRhinoViewport::DrawNurbsCurve, for example, ends up iterating the curve and calling CRhinoDisplayPipeline::DrawBezier.

Thus, if you want to draw a thick NURBS from within conduit, you can do something like this:

  case CSupportChannels::SC_DRAWFOREGROUND:
      if( m_nurbs.IsValid() )
        m_pDisplayAttrs->m_nCurveThickness = 3;
        dp.GetRhinoVP().DrawNurbsCurve( m_nurbs );

I’m drawing some extra supporting geometry as the custom grips on a custom surface object are being drawn. So, I am not drawing from within a conduit and have no access to m_pDisplayAttrs.

I did find, however, the DisplayPipeline.SetCurveThickness function that I can run prior to drawing curves on the viewport using dgs.m_vp.DrawNurbsCurve This also works.

All of the CRhinoViewport “draw” functions actually end up going through the display pipeline which is why this works. We will eventually move all of these draw functions off of CRhinoViewport and on to the display pipeline class, but that won’t happen until at least V6.