New Rhino Viewport C++

Hi,

there is a nice example in Knowledge Base on how to create a new Rhino Viewport, but I have two additional questions:

  1. Is there a trick to make the new Viewport automatically “pop out” into a separate window (instead of dragging it out manually)
  2. Is there a way to limit a set of Conduit objects to be displayed only in that (one) Viewport, and not be seen in the other ones?

Thanks!
Milos

Anyone?
Thanks!

I believe the function you want is CRhinoDoc::CreateRhinoView

Hi Steve,

thanks for the response. But that didn`t help me much…especially because there is no CreateRhinoView function.

Sorry, I was working on OS X and was looking at the wrong header file. There is a function on CRhinoDoc called CreateDerivedRhinoView. You should be able to call it with the following code

CreateDerivedRhinoView(RUNTIME_CLASS(CRhinoView), title, RhinoApp().RhinoCurrent_UUID());

Here is an example of how to create a new view using C++.

Thanks!

I will check it out. How about the second question? Is there a way to limit (Conduit) for objects to be displayed only in (that) one view? And not be seen in any other?

Your conduit knows what viewport is drawing and, thus, can choose whether or not to draw.

bool CMyConduit::ExecConduit(CRhinoDisplayPipeline& dp, UINT channel, bool& terminate)
{
  CRhinoViewport& vp = dp.GetRhinoVP();
  if (vp.ViewportId() == m_my_viewport_id)
  {
    // TODO...
  }
}

Thanks Dale, Ill try it out.

@stevebaer I tried the CreateDerivedRhinoView (which I guess was the answer to the question about how to make a Rhino View that automatically pops out) like this:

context.m_doc.CreateDerivedRhinoView( RUNTIME_CLASS(CRhinoView), L"test", RhinoApp().RhinoCurrent_UUID() );

but Rhino is giving me the following message: Creating view class CRhinoView failed. Specified UUID is either NULL or a Rhino UUID

I dont fully understand the function so I tried replacing the UUID with different "UUID" type things, but it didnt work. Any ideas?

CreateDerivedRhinoView requries that you pass in a derived view, class object derived from CRhinoView.

If you just want a new floating viewport, you can always script the NewFloatingViewport command. Or, you can code up something like the following.

https://github.com/mcneel/Rhino5Samples_CPP/blob/master/SampleCommands/cmdSampleNewFloatingViewport.cpp

Thanks,

I used FloatRhinoView and it sufficed. If I may ask one last question on this topic…I want to completely “redesign” the new viewport and I did some things like:

CRhinoViewport& myviewport = myview->Viewport();
aeviewport.SetShowConstructionGrid(false);

But if I want to change the background color, thickness of the lines, etc. only for this viewport, how do I do that? Do i set attributes over CDisplayPipelineAttributes somehow? What is the proper way?

Thanks a lot!

Yes. Viewport decorations, such as grid, are drawn in the CSupportChannels::SC_DRAWBACKGROUND channel.