当前位置: 首页>>代码示例>>C++>>正文


C++ RhinoApp函数代码示例

本文整理汇总了C++中RhinoApp函数的典型用法代码示例。如果您正苦于以下问题:C++ RhinoApp函数的具体用法?C++ RhinoApp怎么用?C++ RhinoApp使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了RhinoApp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RhinoApp

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;
}
开发者ID:619486,项目名称:Rhino5Samples_CPP,代码行数:33,代码来源:cmdSampleAttributeUserData.cpp

示例2: EnglishCommandName

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;
}
开发者ID:jakeread,项目名称:vraptor,代码行数:28,代码来源:cmdVRaptor.cpp

示例3: GetPlugInUserData

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;
}
开发者ID:buonmethuoc,项目名称:Rhino4Samples_CPP,代码行数:28,代码来源:cmdPlugIn2.cpp

示例4: RhinoApp

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" );
}
开发者ID:krzyzacy,项目名称:Rhino5Samples_CPP,代码行数:9,代码来源:SampleContextMenuExtensionPlugIn.cpp

示例5: RhinoApp

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;
}
开发者ID:KingOfMazes,项目名称:Rhino5Samples_CPP,代码行数:57,代码来源:cmdSamplePan.cpp

示例6: Files

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;
}
开发者ID:619486,项目名称:Rhino5Samples_CPP,代码行数:56,代码来源:cmdSampleOpenIges.cpp

示例7: RhinoApp

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;
}
开发者ID:619486,项目名称:Rhino5Samples_CPP,代码行数:53,代码来源:cmdSampleModifyBumpIntensity.cpp

示例8: RhinoApp

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;
}
开发者ID:619486,项目名称:Rhino5Samples_CPP,代码行数:48,代码来源:cmdSampleSubCrvLength.cpp

示例9: AddPlugInUserData

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;
}
开发者ID:buonmethuoc,项目名称:Rhino4Samples_CPP,代码行数:29,代码来源:cmdPlugIn2.cpp

示例10: RhinoFormatPoint

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;
}
开发者ID:619486,项目名称:Rhino5Samples_CPP,代码行数:26,代码来源:cmdSamplePrintGripLocations.cpp

示例11: RhinoApp

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;
    }
  }
}
开发者ID:mcneel,项目名称:Rhino5Samples_CPP,代码行数:27,代码来源:RhinoRectangleObject.cpp

示例12: RhinoApp

void DialogPrincipale::OnBnClickedButton1()
{	
	
	 RhinoApp().RunScript( L"! _GenPianoVis", 0 );

 
}/*CHIUSURA DIALOGPRINCIPALE::ONBNCLICKEDBUTTON1*/
开发者ID:caffeina,项目名称:PluginMonti,代码行数:7,代码来源:DialogPrincipale.cpp

示例13: AFX_MANAGE_STATE

void CVoronoiDialog::OnBnClickedUndoCurves()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	ON_wString cmd = L"! _UndoCurves ";
	RhinoApp().RunScript( cmd , 0 );
	SetState(VORONOI_GENERATION);
}
开发者ID:kbarlow918,项目名称:voronoi,代码行数:7,代码来源:VoronoiDialog.cpp

示例14: SyncVR

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
开发者ID:jakeread,项目名称:vraptor,代码行数:32,代码来源:cmdVRCreateViews.cpp

示例15: EnglishCommandName

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;
}
开发者ID:sbaer,项目名称:ExposeSdk,代码行数:28,代码来源:cmdExposeSdk.cpp


注:本文中的RhinoApp函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。