Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:sdksamples:setconstructionplane [2015/09/14] (current)
Line 1: Line 1:
 +====== How To: Set a View's Construction Plane ======
 +> **Developer:​** //​[[developer:​cplusplusplugins|C++]]//​
 +> **Summary:​** //​Demonstrates how to set a view's construction plane.//
 +
 +===== C++ =====
 +<code c++>
 +CRhinoCommand::​result CCommandTest::​RunCommand(
 +          const CRhinoCommandContext&​ context )
 +{
 +  CRhinoView* view = ::​RhinoApp().ActiveView();​
 +  if( !view )
 +    return CRhinoCommand::​failure;​
 +
 +  CRhinoGetOption go;
 +  go.SetCommandPrompt( L"​Select a construction plane" );
 +  int back_option ​  = go.AddCommandOption( RHCMDOPTNAME(L"​Back"​) );
 +  int bottom_option = go.AddCommandOption( RHCMDOPTNAME(L"​Bottom"​) );
 +  int front_option ​ = go.AddCommandOption( RHCMDOPTNAME(L"​Front"​) );
 +  int left_option ​  = go.AddCommandOption( RHCMDOPTNAME(L"​Left"​) );
 +  int right_option ​ = go.AddCommandOption( RHCMDOPTNAME(L"​Right"​) );
 +  int top_option ​   = go.AddCommandOption( RHCMDOPTNAME(L"​Top"​) );
 +
 +  go.GetOption();​
 +  if( go.CommandResult() != CRhinoCommand::​success )
 +    return go.CommandResult();​
 +
 +  const CRhinoCommandOption* opt = go.Option();​
 +  if( !opt )
 +    return CRhinoCommand::​failure;​
 +
 +  int option_index = opt->​m_option_index;​
 +  ON_3dmConstructionPlane cplane = view->​Viewport().ConstructionPlane();​
 +  if( option_index == back_option )
 +    cplane.m_plane.CreateFromPoints( ON_origin, -ON_xaxis ,ON_zaxis );
 +  else if( option_index == bottom_option )
 +    cplane.m_plane.CreateFromPoints( ON_origin, -ON_xaxis, ON_yaxis );
 +  else if( option_index == front_option )
 +    cplane.m_plane.CreateFromPoints( ON_origin, ON_xaxis, ON_zaxis );
 +  else if( option_index == left_option )
 +    cplane.m_plane.CreateFromPoints( ON_origin, -ON_yaxis, ON_zaxis );
 +  else if( option_index == right_option )
 +    cplane.m_plane.CreateFromPoints( ON_origin, ON_yaxis, ON_zaxis );
 +  else if( option_index == top_option )
 +    cplane.m_plane.CreateFromPoints( ON_origin, ON_xaxis, ON_yaxis );
 +  else
 +    return CRhinoCommand::​failure;​
 +
 +  view->​Viewport().PushConstructionPlane( cplane );
 +  view->​Redraw();​
 +  return CRhinoCommand::​success;​
 +}
 +</​code>​
 +
 +{{tag>​Developer cplusplus}}
  
developer/sdksamples/setconstructionplane.txt ยท Last modified: 2015/09/14 (external edit)