CRhinoCommand::result CCommandSampleAttributeUserDataGet::RunCommand( const CRhinoCommandContext& context )
{
  // Select object to retrieve user data
	CRhinoGetObject go;
  go.SetCommandPrompt( L"Select object to retrieve user data" );
  go.GetObjects( 1, 1 );
  if( go.CommandResult() != success )
    return go.CommandResult();

  // Validate the selection
  const CRhinoObjRef& ref = go.Object(0);
  const CRhinoObject* obj = ref.Object();
  if( !obj )
    return CRhinoCommand::failure;

  // Get the selected object's attributes
  const CRhinoObjectAttributes& attribs = obj->Attributes();

  // See if our user data is attached
  CSampleAttributeUserData* ud = CSampleAttributeUserData::Cast( attribs.GetUserData(ud->Id()) );
  if( ud )
  {
    // Print data members
    RhinoApp().Print( L"String = %s\n", ud->m_my_string );
    RhinoApp().Print( L"Point = %f,%f,%f\n", ud->m_my_point.x, ud->m_my_point.y, ud->m_my_point.z );
  }
  else
  {
    RhinoApp().Print( L"No user data attached.\n" );
  }

  return CRhinoCommand::success;
}
Пример #2
0
CRhinoCommand::result CCommandVRaptor::RunCommand( const CRhinoCommandContext& context )
{
  // CCommandVRaptor::RunCommand() is called when the user runs the "VRaptor"
  // command or the "VRaptor" command is run by a history operation.

  // TODO: Add command code here.

  // Rhino command that display a dialog box interface should also support
  // a command-line, or scriptable interface.

  ON_wString wStr;
  wStr.Format( L"The raptor is slumbering.\n", EnglishCommandName() );
	  RhinoApp().Print( wStr );

  wStr.Format( L"another one.\n", EnglishCommandName() );
	  RhinoApp().Print( wStr );

  // TODO: Return one of the following values:
  //   CRhinoCommand::success:  The command worked.
  //   CRhinoCommand::failure:  The command failed because of invalid input, inability
  //                            to compute the desired result, or some other reason
  //                            computation reason.
  //   CRhinoCommand::cancel:   The user interactively canceled the command 
  //                            (by pressing ESCAPE, clicking a CANCEL button, etc.)
  //                            in a Get operation, dialog, time consuming computation, etc.

  return CRhinoCommand::success;
}
Пример #3
0
CRhinoCommand::result CCommandPlugIn2Get::RunCommand( const CRhinoCommandContext& context )
{
  CRhinoGetObject go;
  go.SetCommandPrompt( L"Select object" );
  go.GetObjects( 1, 1 );
  if( go.CommandResult() != success )
    return go.CommandResult();

  const CRhinoObject* object = go.Object(0).Object();
  if( 0 == object )
    return failure;

  ON_3dPoint point;
  ON_wString string;
  bool rc = GetPlugInUserData( object, point, string );
  if( rc )
  {
    ON_wString pointstr;
    RhinoFormatPoint( point, pointstr );
    RhinoApp().Print( L"point = %s, string = %s\n", pointstr, string );
  }
  else
  {
    RhinoApp().Print( L"Failed!\n" );
  }

  return success;
}
void CSampleLayerContextMenuExtension::OnCommand( CRhinoContextMenuContext& context, int iAddItemID, UINT nID, CRhinoContextMenu& context_menu )
{
    if( iAddItemID == m_iAddItemID0 )
        RhinoApp().Print( L"Sample Context Menu Item 1 selected.\n" );
    else if( iAddItemID == m_iAddItemID1 )
        RhinoApp().Print( L"Sample Context Menu Item 2 selected.\n" );
    else if( iAddItemID == m_iAddItemID2 )
        RhinoApp().Print( L"Sample Context Menu Item 3 selected.\n" );
}
CRhinoCommand::result CCommandSamplePan::RunCommand( const CRhinoCommandContext& context )
{
  const CRhinoAppViewSettings& view_settings = RhinoApp().AppSettings().ViewSettings();
  double d = view_settings.m_pan_increment;
  if (view_settings.m_pan_reverse_keyboard)
    d = -d;

  CRhinoGetOption go;
  go.SetCommandPrompt(L"Select pan option");
  go.AcceptNothing();

  const int down_option_index  = go.AddCommandOption(RHCMDOPTNAME(L"Down"));
  const int left_option_index  = go.AddCommandOption(RHCMDOPTNAME(L"Left"));
  const int right_option_index = go.AddCommandOption(RHCMDOPTNAME(L"Right"));
  const int up_option_index    = go.AddCommandOption(RHCMDOPTNAME( L"Up"));
  const int in_option_index    = go.AddCommandOption(RHCMDOPTNAME(L"In"));
  const int out_option_index   = go.AddCommandOption(RHCMDOPTNAME(L"Out"));

  for(;;)
  {
    CRhinoGet::result res = go.GetOption();

    if (res != CRhinoGet::option)
      break;

    CRhinoView* view = go.View(); 
    const CRhinoCommandOption* option = go.Option();

    if (0 != view && 0 != option && 0.0 != d)
    {
      CRhinoViewport* viewport = &(view->ActiveViewport());
      if (0 != viewport && viewport->View().m_bLockedProjection)
        viewport = &(view->MainViewport());

      if (0 != viewport)
      {
        if (down_option_index == option->m_option_index)
          viewport->DownUpDolly(-d);
        else if (up_option_index == option->m_option_index)
          viewport->DownUpDolly(d);
        else if (left_option_index == option->m_option_index)
          viewport->LeftRightDolly(-d);
        else if (right_option_index == option->m_option_index)
          viewport->LeftRightDolly(d);
        else if (in_option_index == option->m_option_index)
          viewport->InOutDolly(d);
        else if (out_option_index == option->m_option_index)
          viewport->InOutDolly(-d);
      }

      view->Redraw();
      RhinoApp().SetActiveView(view);
    }
  }  
  
  return CRhinoCommand::success;
}
CRhinoCommand::result CCommandSampleOpenIges::RunCommand( const CRhinoCommandContext& context )
{
  ON_wString filename;

  if( context.IsInteractive() )
  {
    DWORD dwFlags = OFN_ENABLESIZING | OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
    const wchar_t* szFilter = L"IGES Files (*.igs;*.iges)|*.igs; *.iges||";
    CWnd* pParentWnd = CWnd::FromHandle( RhinoApp().MainWnd() );

#if defined(WIN64)
    CFileDialog dialog( TRUE, L"igs", 0, dwFlags, szFilter, pParentWnd, 0, TRUE );
#else
    CFileDialog dialog( TRUE, L"igs", 0, dwFlags, szFilter, pParentWnd );
#endif
    INT_PTR rc = dialog.DoModal();
    if( rc != IDOK )
      return CRhinoCommand::cancel;

    filename = dialog.GetPathName();
  }
  else
  {
    CRhinoGetString gs;
    gs.SetCommandPrompt( L"IGES file to open" );
    gs.GetString();
    if( gs.CommandResult() != CRhinoCommand::success )
      return gs.CommandResult();

    filename = gs.String();
  }

  filename.TrimLeftAndRight();
  if( filename.IsEmpty() )
    return CRhinoCommand::nothing;

  if( !CRhinoFileUtilities::FileExists(filename) )
  {
    RhinoApp().Print( L"File \"%s\" not found.\n", filename );
    return CRhinoCommand::failure;
  }

  // Note, setting the document modified flag to false will prevent the
  // "Do you want to save this file..." mesasge from displaying when you
  // open a file (if the current document has been modified in any way).
  // But, you will (also) loose any modifications to the current document.
  // So, use the following line of code carefully.
  context.m_doc.SetModifiedFlag( FALSE );

  ON_wString script;
  script.Format( L"_-Open \"%s\" _Enter _Enter _Enter", filename );

  RhinoApp().RunScript( script, 0 );

  return CRhinoCommand::success;
}
CRhinoCommand::result CCommandSampleModifyBumpIntensity::RunCommand( const CRhinoCommandContext& context )
{
  CRhinoGetObject go;
  go.SetCommandPrompt( L"Select object to modify bump intensity" );
  go.GetObjects( 1, 1 );
  if( go.CommandResult() != CRhinoCommand::success )
    return go.CommandResult();

  const CRhinoObjRef& ref = go.Object(0);
  const CRhinoObject* obj = ref.Object();
  if( 0 == obj )
    return CRhinoCommand::failure;

  ON_Material material = obj->ObjectMaterial();
  if( material.m_material_index < 0 )
  {
    // I'm assuming the object already has a material. That is,
    // it is not just using the default material.
    RhinoApp().Print( L"Object does not have a material.\n" );
    return CRhinoCommand::nothing;
  }

  int texture_index = material.FindTexture( 0, ON_Texture::bump_texture );
  if( texture_index < 0 )
  {
    // I'm assuming the object's material already has a bump.
    RhinoApp().Print( L"Object does not have a bump texture.\n" );
    return CRhinoCommand::nothing;
  }

  ON_Texture& texture = material.m_textures[texture_index];
  int blend_constant = ON_Round( texture.m_blend_constant_A * 100.0 );

  CRhinoGetInteger gi;
  gi.SetCommandPrompt( L"New bump intensity" );
  gi.SetDefaultInteger( blend_constant );
  gi.SetLowerLimit( 0, false );
  gi.SetUpperLimit( 100, false );
  gi.GetInteger();
  if( gi.CommandResult() != CRhinoCommand::success )
    return gi.CommandResult();

  texture.m_blend_constant_A = (double)gi.Number() / 100.0;
  if( texture.m_blend_constant_A < 1.0)
    texture.m_mode = ON_Texture::blend_texture;
  else
    texture.m_mode = ON_Texture::decal_texture;

  context.m_doc.m_material_table.ModifyMaterial( material, material.m_material_index );
  context.m_doc.Redraw();

  return success;
}
CRhinoCommand::result CCommandSampleSubCrvLength::RunCommand( const CRhinoCommandContext& context )
{
  CRhinoGetObject go;
  go.SetCommandPrompt( L"Select curve to measure" );
  go.SetGeometryFilter( CRhinoGetObject::curve_object );
  go.GetObjects( 1, 1 );
  if( go.CommandResult() != CRhinoCommand::success )
    return go.CommandResult();

  const CRhinoObjRef& ref = go.Object(0);
  const ON_Curve* crv = ref.Curve();
  if( !crv )
    return CRhinoCommand::failure;

  CRhinoGetPoint gp;
  gp.SetCommandPrompt( L"First point on curve" );
  gp.Constrain( *crv );
  gp.GetPoint();
  if( gp.CommandResult() != CRhinoCommand::success )
    return gp.CommandResult();

  double t0;
  if( !crv->GetClosestPoint(gp.Point(), &t0) )
    return CRhinoCommand::nothing;

  gp.SetCommandPrompt( L"Second point on curve" );
  gp.GetPoint();
  if( gp.CommandResult() != CRhinoCommand::success )
    return gp.CommandResult();

  double t1;
  if( !crv->GetClosestPoint(gp.Point(), &t1) )
    return CRhinoCommand::nothing;

  ON_Interval dom;
  if( t0 < t1 )
    dom.Set( t0, t1 );
  else
    dom.Set( t1, t0 );

  double len;
  if( crv->GetLength(&len, 0.0, &dom) )
    RhinoApp().Print( L"Subcurve length = %f.\n", len );
  else
    RhinoApp().Print( L"Unable to calculate length of subcurve.\n" );

	return CRhinoCommand::success;
}
Пример #9
0
CRhinoCommand::result CCommandPlugIn2Add::RunCommand( const CRhinoCommandContext& context )
{
  CRhinoGetObject go;
  go.SetCommandPrompt( L"Select object" );
  go.GetObjects( 1, 1 );
  if( go.CommandResult() != success )
    return go.CommandResult();

  const CRhinoObject* object = go.Object(0).Object();
  if( 0 == object )
    return failure;

  CRhinoGetPoint gp;
  gp.SetCommandPrompt( L"Pick point" );
  gp.GetPoint();
  if( gp.CommandResult() != success )
    return gp.CommandResult();

  CRhinoGetString gs;
  gp.SetCommandPrompt( L"Description" );
  gs.GetString();
  if( gs.CommandResult() != success )
    return gs.CommandResult();

  bool rc = AddPlugInUserData( context.m_doc, object, gp.Point(), gs.String() );
  RhinoApp().Print( L"%s\n", rc ? L"Succeeded!" : L"Failed!" );

  return success;
}
CRhinoCommand::result CCommandSamplePrintGripLocations::RunCommand( const CRhinoCommandContext& context )
{
	CRhinoGetObject go;
  go.SetCommandPrompt( L"Select grips" );
  go.SetGeometryFilter( CRhinoGetObject::grip_object );
  go.GetObjects( 1, 0 );
  if( go.CommandResult() != CRhinoCommand::success )
    return go.CommandResult();

  const int object_count = go.ObjectCount();
  for( int i = 0; i < object_count; i++ )
  {
    const CRhinoGripObject* grip = CRhinoGripObject::Cast( go.Object(i).Object() );
    if( grip )
    {
      ON_3dPoint point = grip->GripLocation();

      ON_wString point_str;
      RhinoFormatPoint( point, point_str );

      RhinoApp().Print( L"Grip %d = %s\n", i, point_str );
    }
  }

  return CRhinoCommand::success;
}
void CRhinoRectangleObject::EnableGrips( bool bGripsOn )
{
  if( bGripsOn )
    theRectangleGripsRegistrar.RegisterGrips();

  if( !bGripsOn || (m_grips && 0 == CRhinoRectangleGrips::RectangleGrips(m_grips)) )
  {
    // turn off wrong kind of grips
    CRhinoObject::EnableGrips( false );
  }

  CRhinoDoc* doc = RhinoApp().ActiveDoc();

  if( bGripsOn && !m_grips )
  {
    const ON_PolylineCurve* pline = Curve();
    if( pline )
    {
      // turn on rectangle grips
      CRhinoRectangleGrips* rectangle_grips = new CRhinoRectangleGrips();
      if( rectangle_grips->CreateGrips( *pline) )
        CRhinoObject::EnableCustomGrips( rectangle_grips );
      else
        delete rectangle_grips;
    }
  }
}
Пример #12
0
void DialogPrincipale::OnBnClickedButton1()
{	
	
	 RhinoApp().RunScript( L"! _GenPianoVis", 0 );

 
}/*CHIUSURA DIALOGPRINCIPALE::ONBNCLICKEDBUTTON1*/
Пример #13
0
void CVoronoiDialog::OnBnClickedUndoCurves()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	ON_wString cmd = L"! _UndoCurves ";
	RhinoApp().RunScript( cmd , 0 );
	SetState(VORONOI_GENERATION);
}
Пример #14
0
static void SyncVR( CRhinoView* lView, CRhinoView* rView) // not calling continuously. much else to add; re:conduits ... pull from example. werk till it werks. then OVRintegration
{
	VR().HMDPoseUpdate();
	if (lView && rView) 
	{ // first we will make it sync the two views as in example

		ON_wString inIf;
		inIf.Format(L"inIf\n");
		RhinoApp().Print( inIf );

		const ON_3dmView& v0 = lView->Viewport().View(); // get Open Nurbs view from 1st CRhinoView* object
		const ON_Viewport& vp0 = lView->Viewport().VP(); // get ON viewport from 1st CRhinoView* object 

		ON_3dmView& v1 = rView->Viewport().m_v; // non-const; ? this important? otherwise same structure as above
		ON_Viewport& vp1 = rView->Viewport().m_v.m_vp; // m_v is settings, m_vp is projection information
		
		vp1.SetProjection( vp0.Projection() ); // so using Viewport().View() to pull from and Viewport().m_v to write to. cannot write to function, yah, duh, all these Things() are functions which return values. not things themselves.
		vp1.SetCameraLocation( vp0.CameraLocation() );
		vp1.SetCameraDirection( vp0.CameraDirection() );
		vp1.SetCameraUp( vp0.CameraUp() ); // breakpoint triggered here
		// v1.SetTargetPoint( v0.TargetPoint() ); // ok so all these assignments make sense

		double fl, fr, ft, fb, fn, ff, fa; // ok dealing with frustrums now: 'Bounding Box' for rendering images. Apparently needs to be kept in sync as well
		vp1.GetFrustumAspect( fa ); // vp1 may be an error -> vp0 . this from example
		vp0.GetFrustum( &fl, &fr, &fb, &ft, &fn, &ff ); // & denotes pointer, I think, or 'disembodied' reference. so the double can be written to?
		vp1.SetFrustum( fl, fr, fb, ft, fn, ff );
		vp1.SetFrustumAspect( fa );

		lView->Viewport().SetTarget( rView->Viewport().Target() ); // this is confusing, though... we have been setting left to right otherwise? ? AND it works both ways!
	}

} // need to setup so this calls everytime at beginning of pipeline
Пример #15
0
void CVoronoiDialog::OnBnClickedUndoTrim()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	ON_wString cmd = L"! _UndoTrim ";
	RhinoApp().RunScript( cmd , 0 );
	SetState(TRIM);
}
Пример #16
0
void CVoronoiDialog::OnBnClickedBurn()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	ON_wString cmd = L"! _BurnData ";
	RhinoApp().RunScript( cmd , 0 );
	OnOK();
}
Пример #17
0
void CVoronoiDialog::OnBnClickedTrim()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	ON_wString cmd = L"! _TrimBrep ";
	RhinoApp().RunScript( cmd , 0 );
	SetState(DONE);
}
Пример #18
0
void CVoronoiDialog::OnBnClickedDelattractor()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	ON_wString cmd = L"! _DelPtAttractor ";

	RhinoApp().RunScript( cmd , 0 );
}
Пример #19
0
void CVoronoiDialog::OnBnClickedClearPoints()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	ON_wString cmd = L"! _UndoPoints ";
	RhinoApp().RunScript( cmd , 0 );
	SetState(POINT_GENERATION);
}
Пример #20
0
void CVoronoiDialog::OnBnClickedViewedit()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	ON_wString cmd = L"! _ViewEdit ";

	RhinoApp().RunScript( cmd , 0 );
}
Пример #21
0
CRhinoCommand::result CCommandExposeSdk::RunCommand( const CRhinoCommandContext& context )
{
  // CCommandExposeSdk::RunCommand() is called when the user runs the "ExposeSdk"
  // command or the "ExposeSdk" command is run by a history operation.

  // TODO: Add command code here.

  // Rhino command that display a dialog box interface should also support
  // a command-line, or scriptable interface.

  ON_wString wStr;
  wStr.Format( L"The \"%s\" command is under construction.\n", EnglishCommandName() );
  if( context.IsInteractive() )
    RhinoMessageBox( wStr, PlugIn()->PlugInName(), MB_OK );
  else
	  RhinoApp().Print( wStr );

  // TODO: Return one of the following values:
  //   CRhinoCommand::success:  The command worked.
  //   CRhinoCommand::failure:  The command failed because of invalid input, inability
  //                            to compute the desired result, or some other reason
  //                            computation reason.
  //   CRhinoCommand::cancel:   The user interactively canceled the command 
  //                            (by pressing ESCAPE, clicking a CANCEL button, etc.)
  //                            in a Get operation, dialog, time consuming computation, etc.

  return CRhinoCommand::success;
}
CRhinoCommand::result CCommandZAnalysisOn::RunCommand( const CRhinoCommandContext& context )
{
  CRhinoGetObject go;
  go.SetCommandPrompt(L"Select objects for Z analysis.");
  go.SetGeometryFilter( ON::brep_object | ON::mesh_object );
  go.GetObjects(1,0);
  if( CRhinoCommand::success != go.CommandResult() )
    return go.CommandResult();

  ON_MeshParameters mp = CRhinoAppRenderMeshSettings::DefaultQualityMeshParameters();
  context.m_doc.Properties().SetAnalysisMeshSettings( mp );

  int count = 0;
  for( int i = 0; i < go.ObjectCount(); i++ )
  {
    const CRhinoObject* rhino_object = go.Object(i).Object();
    if( 0 == rhino_object )
      continue;

    if( rhino_object->InAnalysisMode(theZAnalysisVAM.m_am_id) )
      continue;

    const_cast<CRhinoObject*>(rhino_object)->DestroyMeshes( ON::analysis_mesh, true );

    if( rhino_object->EnableAnalysisMode(theZAnalysisVAM.m_am_id, true) )
      count++;
  }

  RhinoApp().Print( L"%d objects were put into Z analysis mode", count );
  context.m_doc.Redraw();

	return CRhinoCommand::success;
}
void CSampleRhinoEventWatcher::UndoEvent(CRhinoEventWatcher::undo_event type, unsigned int undo_record_serialnumber, const CRhinoCommand* cmd)
{
  ON_wString str;
  switch (type)
  {
  case CRhinoEventWatcher::no_undo_event:
    str = L"No Undo Event";
    break;
  case CRhinoEventWatcher::begin_recording:
    str = L"Begin Recording";
    break;
  case CRhinoEventWatcher::end_recording:
    str = L"End Recording";
    break;
  case CRhinoEventWatcher::begin_undo:
    str = L"Begin Undo";
    break;
  case CRhinoEventWatcher::end_undo:
    str = L"End Undo";
    break;
  case CRhinoEventWatcher::begin_redo:
    str = L"Begin Undo";
    break;
  case CRhinoEventWatcher::end_redo:
    str = L"End Redo";
    break;
  case CRhinoEventWatcher::purge_record:
    str = L"Purge Record";
    break;
  }
  RhinoApp().Print(L"** EVENT: Undo, Type: %s **\n", (const wchar_t*)str);
}
CRhinoCommand::result CCommandSampleTriangulatePolygon::RunCommand( const CRhinoCommandContext& context )
{
  CRhinoGetObject go;
  go.SetCommandPrompt( L"Select closed planar polygon to triangulate" );
  go.SetGeometryFilter( CRhinoGetObject::curve_object );
  go.SetGeometryFilter( CRhinoGetObject::closed_curve );
  go.EnableSubObjectSelect( FALSE );
  go.GetObjects( 1, 1 );
  if( go.CommandResult() != CRhinoCommand::success )
    return go.CommandResult();

  const CRhinoObjRef& ref = go.Object(0);

  ON_3dPointArray vertices;

  const ON_PolylineCurve* pc = ON_PolylineCurve::Cast( ref.Curve() );
  if( pc )
  {
    vertices = pc->m_pline;
  }
  else
  {
    const ON_NurbsCurve* nc = ON_NurbsCurve::Cast( ref.Curve() );
    if( nc )
      nc->IsPolyline( &vertices );
  }

  if( vertices.Count() < 5 )
  {
    RhinoApp().Print( L"Curve not polygon with at least four sides.\n" );
    return CRhinoCommand::nothing;
  }

  int* triangles = (int*)onmalloc( (vertices.Count()-3) * sizeof(int) * 3 );
  if( 0 == triangles )
    return CRhinoCommand::failure; // out of memory
  
  memset( triangles, 0, (vertices.Count()-3) * sizeof(int) * 3 );

  int rc = RhinoTriangulate3dPolygon( vertices.Count()-1, 3, (const double*)vertices.Array(), 3, triangles);
  if( 0 == rc )
  {
    int i;
    for( i = 0; i < vertices.Count()-3; i++ )
    {
      ON_Polyline pline;
      pline.Append( vertices[triangles[i * 3]] );
      pline.Append( vertices[triangles[i * 3 + 1]] );
      pline.Append( vertices[triangles[i * 3 + 2]] );
      pline.Append( pline[0] );
      context.m_doc.AddCurveObject( pline );
    }
    context.m_doc.Redraw();
  }

  onfree( triangles );

  return CRhinoCommand::success;
}
Пример #25
0
void DialogPrincipale::OnBnClickedButton8()
{
	GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);
	UpdateData(true);
	RhinoApp().RunScript( L"! _TrimCylinder", 0);
	
	// TODO: aggiungere qui il codice per la gestione della notifica del controllo.
}
Пример #26
0
void DialogPrincipale::OnBnClickedButton1()
{	
	GetDlgItem(IDC_BUTTON2)->EnableWindow(TRUE);
	UpdateData(true);
	 RhinoApp().RunScript( L"! _GenPianoVis", 0 );

 
}/*CHIUSURA DIALOGPRINCIPALE::ONBNCLICKEDBUTTON1*/
CRhinoCommand::result CCommandSampleMeshVertexLocation::RunCommand( const CRhinoCommandContext& context )
{
  // Select a mesh vertex
  CRhinoGetObject go;
  go.SetCommandPrompt( L"Select mesh vertex" );
  go.SetGeometryFilter( CRhinoGetObject::meshvertex_object );
  go.GetObjects( 1, 1 );
  if( go.CommandResult() != CRhinoCommand::success )
    return go.CommandResult();

  // Get the mesh vertex reference
  const ON_MeshVertexRef* mesh_vertex_ref = go.Object(0).MeshVertex();
  if( 0 == mesh_vertex_ref )
    return CRhinoCommand::failure;

  // Get the mesh topology
  const ON_MeshTopology* mesh_top = mesh_vertex_ref->MeshTopology();
  // Get the topological mesh vertex
  const ON_MeshTopologyVertex* mesh_top_vertex = mesh_vertex_ref->MeshTopologyVertex();
  if( 0 == mesh_top || 0 == mesh_top_vertex )
    return CRhinoCommand::failure;

  // Iterate through all of of the topological mesh edges, that reference
  // this topological mesh vertex, and see if one of the edges is a naked edge.
  bool bBoundaryVertex = false;
  for( int i = 0; i <  mesh_top_vertex->m_tope_count; i++ )
  {
    const ON_MeshTopologyEdge& mesh_top_edge = mesh_top->m_tope[mesh_top_vertex->m_topei[i]];
    // If the edge has only one face, which means it is a naked edge,
    // then the vertex must be on a boundary edge.
    if( 1 == mesh_top_edge.m_topf_count )
    {
      bBoundaryVertex = true;
      break;
    }
  }

  // Report results
  if( bBoundaryVertex )
    RhinoApp().Print( L"Mesh vertex is on a boundary edge.\n" );
  else
    RhinoApp().Print( L"Mesh vertex is on an interior edge.\n" );

	return CRhinoCommand::success;
}
void CMarmaladeEventWatcher::OnBeginCommand(const CRhinoCommand& command, const CRhinoCommandContext& context)
{
	const ON_wString s = L"SetCurrentRenderPlugin";

	if (s.CompareNoCase(const_cast<CRhinoCommand&>(command).EnglishCommandName()) == 0)
	{
		m_uuidOldRenderEngine = RhinoApp().GetDefaultRenderApp();
	}
}
void CTestPreviewDialog::OnBnClickedCancel()
{
	m_preview.Disable();
  CRhinoDoc* doc = RhinoApp().ActiveDoc();
  if( doc )
    doc->Regen();

	OnCancel();
}
void CRhinoRectangleGripsRegistration::RegisterGrips()
{
  if ( !m_pGripsEnabler )
  {
    // register once and only once
    m_pGripsEnabler = new CRhinoRectangleGripsEnabler();
    RhinoApp().RegisterGripsEnabler( m_pGripsEnabler );
  }
}