void ON_AngularDimension::SetTextToDefault() { ON_wString s; s.Format( L"<>%c", ON_Annotation::degreesym); SetUserText( s); }
bool ON_3dmProperties::Write(ON_BinaryArchive& file) const { bool rc = true; // This short chunk identifies the version of OpenNURBS that was used to write this file. const unsigned int version_number_to_write = ON_BinaryArchive::ArchiveOpenNURBSVersionToWrite(file.Archive3dmVersion(), ON::Version()); rc = file.BeginWrite3dmChunk(TCODE_PROPERTIES_OPENNURBS_VERSION, version_number_to_write); if (rc) rc = file.EndWrite3dmChunk(); if (!rc) return false; // This chunk added November 5, 2015 const ON_wString archive_full_path = file.ArchiveFullPath().IsEmpty() ? m_3dmArchiveFullPathName : file.ArchiveFullPath(); if (archive_full_path.IsNotEmpty()) { if (!file.BeginWrite3dmChunk(TCODE_PROPERTIES_AS_FILE_NAME, 0)) return false; rc = file.WriteString(file.ArchiveFullPath()); if (!file.EndWrite3dmChunk()) rc = false; if (!rc) return false; } // optional TCODE_PROPERTIES_REVISIONHISTORY chunk - file creation/revision information if ( rc && m_RevisionHistory.IsValid() ) { rc = file.BeginWrite3dmChunk(TCODE_PROPERTIES_REVISIONHISTORY,0); if ( rc ) { rc = m_RevisionHistory.Write(file); if ( !file.EndWrite3dmChunk() ) rc = false; } } // optional TCODE_PROPERTIES_NOTES chunk - file notes if ( rc && m_Notes.IsValid() ) { rc = file.BeginWrite3dmChunk(TCODE_PROPERTIES_NOTES,0); if ( rc ) { rc = m_Notes.Write(file); if ( !file.EndWrite3dmChunk() ) rc = false; } } //// When merging Mac code please note that the //// TCODE_PROPERTIES_PREVIEWIMAGE chunk is OBSOLETE. //// DO NOT WRITE THEM IN V6 FILES. If performance is an //// issue, we will address it some other way. // optional TCODE_PROPERTIES_COMPRESSED_PREVIEWIMAGE chunk - bitmap preview if ( rc && m_PreviewImage.IsValid() && file.Save3dmPreviewImage()) { rc = file.BeginWrite3dmChunk(TCODE_PROPERTIES_COMPRESSED_PREVIEWIMAGE,0); if ( rc ) { rc = m_PreviewImage.WriteCompressed(file); if ( !file.EndWrite3dmChunk() ) rc = false; } } // optional TCODE_PROPERTIES_APPLICATION chunk - application information if ( rc && m_Application.IsValid() ) { rc = file.BeginWrite3dmChunk(TCODE_PROPERTIES_APPLICATION,0); if ( rc ) { rc = m_Application.Write(file); if ( !file.EndWrite3dmChunk() ) rc = false; } } // required TCODE_ENDOFTABLE chunk - marks end of properties table if ( rc ) { rc = file.BeginWrite3dmChunk( TCODE_ENDOFTABLE, 0 ); if ( rc ) { if ( !file.EndWrite3dmChunk() ) rc = false; } } return rc; }
BOOL CSampleExportMeshPlugIn::WriteFile( const wchar_t* filename, int index, CRhinoDoc& doc, const CRhinoFileWriteOptions& options ) { // Description: // Rhino calls WriteFile() to write document geometry to an external file. // Parameters: // filename [in] The name of file to write. // index [in] The index of file extension added to list in AddToFileType(). // doc [in] The current Rhino document. // options [in] File write options. // Remarks: // The plug-in is responsible for opening the file and writing to it. // Return TRUE if successful, otherwise return FALSE. // TODO: Add file export code here. // Are we saving or exporting? bool bExport = options.Mode( CRhinoFileWriteOptions::SelectedMode ); // Are we in interactive or scripted mode? bool bScript = options.Mode( CRhinoFileWriteOptions::BatchMode ); ON_SimpleArray<const CRhinoObject*> objects( 256 ); // Get objects to save/export CRhinoObjectIterator it( doc, CRhinoObjectIterator::undeleted_objects ); if( bExport ) { it.EnableSelectedFilter(); it.EnableVisibleFilter(); } // Do the iteration... const CRhinoObject* obj = 0; for( obj = it.First(); obj; obj = it.Next() ) objects.Append( obj ); ON_ClassArray<CRhinoObjectMesh> meshes( objects.Count() ); ON_MeshParameters mesh_parameters = m_mesh_parameters; int mesh_ui_style = ( bScript ) ? 2 : m_mesh_ui_style; // Get the meshes to save/export CRhinoCommand::result res = RhinoMeshObjects( objects, mesh_parameters, mesh_ui_style, meshes ); if( res == CRhinoCommand::success ) { if( mesh_ui_style >= 0 && mesh_ui_style <= 1 ) m_mesh_ui_style = mesh_ui_style; m_mesh_parameters = mesh_parameters; } else { if( bExport ) RhinoApp().Print( L"\nNo meshes to export.\n" ); else RhinoApp().Print( L"\nNo meshes to save.\n" ); return FALSE; } // Write the mesh file FILE* fp = 0; errno_t err = _wfopen_s( &fp, filename, L"w" ); bool rc = ( 0 == err || 0 != fp ); if( !rc ) { RhinoApp().Print( L"\nUnable to open \"%s\" for writing.\n", filename ); return FALSE; } // Write mesh count ON_wString s; s.Format( L"meshcount=%d\n", meshes.Count() ); rc = ( fputws(s, fp) >= 0 ); int i, j; for( i = 0; rc && i < meshes.Count(); i++ ) { const CRhinoObjectMesh& obj_mesh = meshes[i]; const ON_Mesh* mesh = obj_mesh.m_mesh; rc = ( 0 != mesh ); // Write mesh number if( rc ) { s.Format( L"mesh=%d\n", i ); rc = ( fputws(s, fp) >= 0 ); } // Write mesh vertex count if( rc ) { s.Format( L"vertexcount=%d\n", mesh->m_V.Count() ); rc = ( fputws(s, fp) >= 0 ); } // Write mesh face count if( rc ) { s.Format( L"facecount=%d\n", mesh->m_F.Count() ); rc = ( fputws(s, fp) >= 0 ); } // Write mesh vertices if( rc ) { for( j = 0; rc && j < mesh->m_V.Count(); j++ ) { const ON_3fPoint& p = mesh->m_V[j]; s.Format( L"vertex=(%.16f,%.16f,%.16f)\n", p.x, p.y, p.z ); rc = ( fputws(s, fp) >= 0 ); } } // Write mesh faces if( rc ) { for( j = 0; rc && j < mesh->m_F.Count(); j++ ) { const ON_MeshFace& f = mesh->m_F[j]; s.Format( L"face=(%d,%d,%d,%d)\n", f.vi[0], f.vi[1], f.vi[2], f.vi[3] ); rc = ( fputws(s, fp) >= 0 ); } } } fclose( fp ); return ( rc ) ? TRUE : FALSE; }
BOOL ON_UserStringList::GetDescription( ON_wString& description ) { description.Format("User text (%d entries)",m_e.Count()); return true; }
bool ON_Object::GetUserString( const wchar_t* key, ON_wString& string_value ) const { string_value.Empty(); const ON_UserStringList* us = ON_UserStringList::Cast(GetUserData(ON_UserStringList::m_ON_UserStringList_class_id.Uuid())); return us ? us->GetUserString(key,string_value) : false; }
// virtual ON_UserData override ON_BOOL32 ON__IDefAlternativePathUserData::Archive() const { // don't save empty settings return !m_alternate_path.IsEmpty(); }
ON_BOOL32 ON_HatchExtra::GetDescription( ON_wString& description) { description.Format( "Userdata extension of ON_Hatch (contains basepoint)"); return true; }
// virtual ON_Object override unsigned int ON__IDefAlternativePathUserData::SizeOf() const { return (unsigned int)(sizeof(*this) + m_alternate_path.SizeOf()); }
// virtual ON_Object override ON__UINT32 ON__IDefAlternativePathUserData::DataCRC(ON__UINT32 current_remainder) const { ON__UINT32 crc = ON_CRC32(current_remainder,sizeof(m_bRelativePath),&m_bRelativePath); crc = m_alternate_path.DataCRC(crc); return crc; }
// virtual ON_Object override ON_BOOL32 ON__IDefAlternativePathUserData::IsValid( ON_TextLog* text_log ) const { return !m_alternate_path.IsEmpty(); }
CRhinoCommand::result CCommandSampleImportMeshes::RunCommand( const CRhinoCommandContext& context ) { CWnd* pMainWnd = CWnd::FromHandle(RhinoApp().MainWnd()); if (0 == pMainWnd) return CRhinoCommand::failure; CRhinoGetFileDialog gf; gf.SetScriptMode(context.IsInteractive() ? FALSE : TRUE); BOOL rc = gf.DisplayFileDialog(CRhinoGetFileDialog::open_rhino_only_dialog, 0, pMainWnd); if (!rc) return CRhinoCommand::cancel; ON_wString filename = gf.FileName(); filename.TrimLeftAndRight(); if (filename.IsEmpty()) return CRhinoCommand::nothing; if (!CRhinoFileUtilities::FileExists(filename)) { RhinoApp().Print(L"File not found\n"); return CRhinoCommand::failure; } FILE* archive_fp = ON::OpenFile(filename, L"rb"); if (0 == archive_fp) { RhinoApp().Print(L"Unable to open file\n"); return CRhinoCommand::failure; } ON_BinaryFile archive(ON::read3dm, archive_fp); ONX_Model model; rc = model.Read(archive) ? TRUE : FALSE; ON::CloseFile( archive_fp ); if (!rc) { RhinoApp().Print(L"Error reading file\n"); return CRhinoCommand::failure; } int num_imported = 0; for (int i = 0; i < model.m_object_table.Count(); i++) { const ONX_Model_Object& model_object = model.m_object_table[i]; const ON_Mesh* mesh = ON_Mesh::Cast(model_object.m_object); if (0 != mesh) { // CRhinoDoc::AddMeshObject makes a copy of the input mesh context.m_doc.AddMeshObject(*mesh); num_imported++; } } if (0 == num_imported) RhinoApp().Print(L"No meshes imported\n"); else if (1 == num_imported) RhinoApp().Print(L"1 mesh imported\n"); else RhinoApp().Print(L"%d meshes imported\n", num_imported); context.m_doc.Redraw(); return CRhinoCommand::success; }
CRhinoCommand::result CCommandVRCreateViews::RunCommand( const CRhinoCommandContext& context ) { AFX_MANAGE_STATE( ::RhinoApp().RhinoModuleState() ); // dunno, from example ON_wString wStr; wStr.Format( L"READY SET\n", EnglishCommandName() ); RhinoApp().Print( wStr ); ON_SimpleArray<CRhinoView*> viewList; // don't know what is up with* this* ON_SimpleArray<ON_UUID> viewportIds; CRhinoView* lView = 0; CRhinoView* rView = 0; ON_SimpleArray<CRhinoView*> lrViews; // will contain our vr views int i = 0; // also use this in loops int lr = 0; // use to track 1st and 2nd find // builds a list of (current) viewport IDs context.m_doc.GetViewList( viewList, true, false ); for ( i = 0; i < viewList.Count(); i ++) { CRhinoView* tempView = viewList[i]; // pull view out -> this is redeclared here, in sample, but not in second loop if (tempView) viewportIds.Append( tempView->ActiveViewportID() ); } viewList.Empty(); // empty bc we are going to re-build later when new views context.m_doc.NewView( ON_3dmView() ); context.m_doc.NewView( ON_3dmView() ); // we will build two // find viewport UUID just created context.m_doc.GetViewList( viewList, true, false); for (i = 0; i < viewList.Count(); i++) { CRhinoView* tempView = viewList[i]; if (tempView) { int rc = viewportIds.Search( tempView->ActiveViewportID() ); // returns index of 1st element which satisfies search. returns -1 when no such item found if (rc < 0 ) // if current tempView did not exist prior to this running { if (lr > 0) // and if lr already found 1 { rView = tempView; // right is 2nd view we find break; // so this breaks when we find, and lView is left as the viewList[i] where we found the new viewport, whose ID was not in our list. // and we are left with lView being = viewList[i] at new view } if (lr == 0) { lView = tempView; // left is 1st view lr = 1; } } else tempView = 0; // reset lView to null and re-loop } } lrViews.Append(lView); lrViews.Append(rView); // init points ON_3dPoint locationL = ON_3dPoint(100.0,100.0,100.0); ON_3dPoint locationR = ON_3dPoint(100.0,165.1,100.0); ON_3dPoint targetSetup = ON_3dPoint(0,0,0); if (lView && rView) { for (int i = 0; i < 2; i++) { // RhinoApp().ActiveView()-> ON_3dmView onView = lrViews[i]->ActiveViewport().View(); if(i == 0) onView.m_name = L"lView"; //lrViews[i]->MoveWindow(0,0,VR().resolution.w/2,VR().resolution.h, true); if(i == 1) onView.m_name = L"rView"; //lrViews[i]->MoveWindow(960,0,VR().resolution.w/2,VR().resolution.h, true); lrViews[i]->ActiveViewport().SetView(onView); lrViews[i]->ActiveViewport().m_v.m_vp.ChangeToPerspectiveProjection(50,true,35); lrViews[i]->ActiveViewport().m_v.m_vp.SetCameraLocation(locationL); lrViews[i]->FloatRhinoView(true); lrViews[i]->Redraw(); } } VR().lView = lView; VR().rView = rView; ON_wString SYNC; SYNC.Format(L"SYNCVRBEGIN\n" ); RhinoApp().Print( SYNC ); if (vrConduit.IsEnabled() && ::IsWindow( vrConduit.m_hWnd1 ) && ::IsWindow( vrConduit.m_hWnd2 ) ) // if is already enabled ? { vrConduit.m_pView1 = 0; vrConduit.m_pView2 = 0; vrConduit.Disable(); } else { vrConduit.m_pView1 = lView; vrConduit.m_pView2 = rView; vrConduit.m_hWnd1 = vrConduit.m_pView1->m_hWnd; vrConduit.m_hWnd2 = vrConduit.m_pView2->m_hWnd; SyncVR(lView, rView); // ok it runs once. we should also set them up perspective & looking at 0,0 vrConduit.Bind( *lView ); vrConduit.Bind( *rView ); lView->Redraw(); rView->Redraw(); vrConduit.Enable(); } // but do not update names immediately; have to refresh somehow // now re-name update positions outside of loop: continuously // bring in OVR Tracking and assign to VR Viewports // then, orbit? return CRhinoCommand::success; }
void ON_wString::AppendToArray( const ON_wString& s ) { AppendToArray( s.Length(), s.Array() ); }
void ON_wString::CopyToArray( const ON_wString& s ) { CopyToArray( s.Length(), s.Array() ); }