How to produce “Preview”

For some Rhino commands, after selecting all curves and “Press Enter”, Rhino will pop up a dialog and show the “preview”. Could you tell us how you make the preview? Do you just create an ordinary surface and ask Rhino to show it? Do you have some C++ samples for the “preview”? Many thanks.

Hi @XNurbs,

There are two ways to draw preview geometry:

1.) Create a CRhinoGetPoint-derived class, override the CRhinoGetPoint::DynamicDraw virtual function, and add your drawing code.

You will find several code samples that demonstrate this, in the developers samples repo on GitHub.

2.) Create a CRhinoDisplayConduit-derived class and implement your drawing code.

Here is an overview on conduits:

https://developer.rhino3d.com/guides/rhinocommon/display-conduits/

Again, you will find several code samples that demonstrate this, in the developers samples repo on GitHub.

– Dale

Dale,

Many thanks.

For your Lofting command, after selecting all curves and “Press Enter”, Rhino will pop up a dialog and show the lofting “preview”. Does the Lofting command just create an ordinary surface and show it? Or it uses a CRhinoDisplayConduit-derived class? The Lofting style is suitable for our plugin.

Hi @XNurbs,

The Loft command uses an MFC dialog box that inherits from CRhinoDialog. The dialog box is semi-modal in that the user can use view commands and operations while the dialog box is displayed. There is a semi-model dialog box sample in the developer samples repo on GitHub.

When the dialog appears, it creates a CRhinoDisplayConduit-derived class to draw the preview Brep. The conduit draws the preview Brep in the CSupportChannels::SC_PREDRAWOBJECTS channel.

– Dale

Dale,

We thought the Lofting command just creates an ordinary surface and shows it, so we create an ordinary surface and directly call m_doc.AddObject( brep_object ) to show the preview. Would this method cause any problem? If so, we may have to re-develop the preview. Thank you.

Hi @XNurbs,

For an example of how the Loft command kind of works, study the SampleCirclePreview command found in the SampleUserInterface project in the developer samples.

– Dale

Dale,

We have created a CRhinoDisplayConduit-derived class to draw and highlight the preview Brep. Should we draw in the CSupportChannels::SC_PREOBJECTDRAW channel (we would like to highlight the geometry)? To draw an ON_Brep, we just call CRhinoDisplayPipeline::DrawBrep inside ExecConduit?

Dale,

Could you also tell me how to highlight a preview ON_Brep? Drawing it in the CSupportChannels::SC_PREOBJECTDRAW channel does not highlight it. Also we find m_pDoc->Redraw() does not trigger CSupportChannels::SC_PREOBJECTDRAW. Do you know why?

Many thanks.

Preview geometry should be drawn in the CSupportChannels::SC_DRAWOVERLAY channel, as demonstrated by the sample I referenced.

– Dale

The geometry is not a line or a curve. It is a trimmed surface or a face (a ON_Brep). Your loft command draws the preview Brep in the CSupportChannels::SC_PREDRAWOBJECTS channel. Are you sure it should be drawn in the CSupportChannels::SC_DRAWOVERLAY channel?

Also we need to highlight the preview ON_Brep. How could we do it in the preview?

Pass your favorite color to CRhinoDisplayPipeline::DrawBrep, the function you’ll use to draw the preview Brep.

– Dale

A post was split to a new topic: Draw Breps in Display conduit