void CustomGeomMgrSingleton::SetupCustomDefaultSource( int type, int surf_index, double l1, double r1, double u1, double w1, double l2, double r2, double u2, double w2 ) { Geom* gptr = VehicleMgr.GetVehicle()->FindGeom( m_CurrGeom ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); SourceData sd; sd.m_Type = type; sd.m_SurfIndex = surf_index; sd.m_Len1 = l1; sd.m_Rad1 = r1; sd.m_U1 = u1; sd.m_W1 = w1; sd.m_Len2 = l2; sd.m_Rad2 = r2; sd.m_U2 = u2; sd.m_W2 = w2; custom_geom->SetUpDefaultSource( sd ); } }
void TreeDlg::OnTreeComputePath() { GetDlgItems(); ClearOutputText(); HTREEITEM hSelectedItem = mpTreeCtrl->GetSelectedItem(); if (hSelectedItem == NULL) AppendOutputText("No item is selected"); else { GvPath *selectedItemPath = PathOfItem(hSelectedItem); if (selectedItemPath == NULL) AppendOutputText("[PathOfItem(...) returned NULL"); else { UtScalarArray<int> *indexArray = selectedItemPath->GetIndexArray(); int count = selectedItemPath->GetIndexCount(); AppendOutputText("Selected "); Geom *g = selectedItemPath->Resolve(); AppendOutputText(g->GetType()->mpName); AppendOutputText(" at path"); char buf[20]; for (int i=0; i<count; ++i) { sprintf(buf, " %d", (*indexArray)[i]); AppendOutputText(buf); } } } }
void VSPAEROMgrSingleton::Update() { if( m_RefFlag() == MANUAL_REF ) { m_Sref.Activate(); m_bref.Activate(); m_cref.Activate(); } else { Geom* refgeom = VehicleMgr.GetVehicle()->FindGeom( m_RefGeomID ); if( refgeom ) { if( refgeom->GetType().m_Type == MS_WING_GEOM_TYPE ) { WingGeom* refwing = (WingGeom*) refgeom; m_Sref.Set( refwing->m_TotalArea() ); m_bref.Set( refwing->m_TotalSpan() ); m_cref.Set( refwing->m_TotalChord() ); m_Sref.Deactivate(); m_bref.Deactivate(); m_cref.Deactivate(); } } } }
void CustomGeomMgrSingleton::SetCustomCenter( double x, double y, double z ) { Geom* gptr = VehicleMgr.GetVehicle()->FindGeom( m_CurrGeom ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); custom_geom->SetCenter( x, y, z ); } }
//==== Clone Surf And Apply Transform =====// void CustomGeomMgrSingleton::TransformSurf( int index, Matrix4d & mat ) { Geom* gptr = VehicleMgr.GetVehicle()->FindGeom( m_CurrGeom ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); custom_geom->TransformSurf( index, mat ); } }
void CustomGeomMgrSingleton::ClearAllCustomDefaultSources() { Geom* gptr = VehicleMgr.GetVehicle()->FindGeom( m_CurrGeom ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); custom_geom->ClearAllDefaultSources(); } }
//==== Set VSP Surf Type For Current Custom Geom =====// void CustomGeomMgrSingleton::SetVspSurfCfdType( int type, int surf_id ) { Geom* gptr = VehicleMgr.GetVehicle()->FindGeom( m_CurrGeom ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); custom_geom->SetVspSurfCfdType( type, surf_id ); } }
//==== Skin XSec Surf =====// void CustomGeomMgrSingleton::SkinXSecSurf( bool closed_flag ) { Geom* gptr = VehicleMgr.GetVehicle()->FindGeom( m_CurrGeom ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); custom_geom->SkinXSecSurf(closed_flag ); } }
//==== Remove XSec Surface To Current Geom ====// void CustomGeomMgrSingleton::RemoveXSecSurf( const string& id ) { Geom* gptr = VehicleMgr.GetVehicle()->FindGeom( m_CurrGeom ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); custom_geom->RemoveXSecSurf( id ); } }
//===== Check And Clear Trigger Event ====// bool CustomGeomMgrSingleton::CheckClearTriggerEvent( int gui_id ) { Geom* gptr = VehicleMgr.GetVehicle()->FindGeom( m_CurrGeom ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); return custom_geom->CheckClearTriggerEvent( gui_id ); } return false; }
string CustomGeomMgrSingleton::GetCustomParm( int index ) { Geom* gptr = VehicleMgr.GetVehicle()->FindGeom( m_CurrGeom ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); return custom_geom->FindParmID( index ); } return string(); }
//==== Build Update Gui Instruction Vector ====// vector< GuiUpdate > CustomGeomMgrSingleton::GetGuiUpdateVec() { Geom* gptr = VehicleMgr.GetVehicle()->FindGeom( m_CurrGeom ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); return custom_geom->GetGuiUpdateVec(); } vector< GuiUpdate > defvec; return defvec; }
//==== Add Parm To Current Custom Geom ====// string CustomGeomMgrSingleton::AddParm( int type, const string & name, const string & group ) { Vehicle* veh = VehicleMgr.GetVehicle(); Geom* gptr = veh->FindGeom( m_CurrGeom ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); return custom_geom->AddParm( type, name, group ); } return string(); }
//==== Update Gui ====// void CustomGeomMgrSingleton::AddUpdateGui( int gui_id, const string & parm_id ) { Geom* gptr = VehicleMgr.GetVehicle()->FindGeom( m_CurrGeom ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); GuiUpdate gu; gu.m_GuiID = gui_id; gu.m_ParmID = parm_id; custom_geom->AddUpdateGui( gu ); } }
//==== Init Custom Geom ====// void CustomGeomMgrSingleton::InitGeom( const string& id, const string& module_name ) { Vehicle* veh = VehicleMgr.GetVehicle(); Geom* gptr = veh->FindGeom( id ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { m_CurrGeom = id; CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); custom_geom->SetScriptModuleName( module_name ); custom_geom->InitGeom(); m_ModuleGeomIDMap[ module_name ] = id; } }
//=== Paste Custom XSec ====// void CustomGeomMgrSingleton::PasteCustomXSec( const string & xsec_surf_id, int index ) { Geom* gptr = VehicleMgr.GetVehicle()->FindGeom( m_CurrGeom ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); for ( int i = 0 ; i < custom_geom->GetNumXSecSurfs() ; i++ ) { XSecSurf* xs_surf = custom_geom->GetXSecSurf( i ); if ( xs_surf && xs_surf->GetID() == xsec_surf_id ) { xs_surf->PasteXSec( index ); } } } }
//==== Add Gui Device Build Data For Custom Geom ====// int CustomGeomMgrSingleton::AddGui( int type, const string & label, const string & parm_name, const string & group_name, double range ) { Geom* gptr = VehicleMgr.GetVehicle()->FindGeom( m_CurrGeom ); //==== Check If Geom is Valid and Correct Type ====// if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE ) { CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr ); GuiDef gd; gd.m_Type = type; gd.m_Label = label; gd.m_ParmName = parm_name; gd.m_GroupName = group_name; gd.m_Range = range; return custom_geom->AddGui( gd ); } return -1; }
bool VSPAEROScreen::Update() { Vehicle *veh = VehicleMgr.GetVehicle(); VSPAEROMgr.Update(); if( veh ) { //check if the degenfile name has changed string t_ModelNameBase = VSPAEROMgr.m_ModelNameBase; //m_ModelNameBase is built from calling veh->getExportFileName(); if( !t_ModelNameBase.empty() && strcmp( m_ModelNameBasePrevious.c_str(), t_ModelNameBase.c_str() ) != 0 ) { ReadSetup(); } m_ModelNameBasePrevious = t_ModelNameBase; // Reference Wing Choice // find & list all Wing type geometries vector <string> geomVec = veh->GetGeomVec(); m_RefWingChoice.ClearItems(); m_WingGeomVec.clear(); map <string, int> WingCompIDMap; int iwing = 0; for ( int i = 0 ; i < ( int )geomVec.size() ; i++ ) { char str[256]; Geom* g = veh->FindGeom( geomVec[i] ); if ( g ) { sprintf( str, "%d_%s", i, g->GetName().c_str() ); if( g->GetType().m_Type == MS_WING_GEOM_TYPE ) { m_RefWingChoice.AddItem( str ); WingCompIDMap[ geomVec[i] ] = iwing; m_WingGeomVec.push_back( geomVec[i] ); iwing ++; } } } m_RefWingChoice.UpdateItems(); // Update selected value string refGeomID = VSPAEROMgr.m_RefGeomID; if( refGeomID.length() == 0 && m_WingGeomVec.size() > 0 ) { // Handle case default case. refGeomID = m_WingGeomVec[0]; VSPAEROMgr.m_RefGeomID = refGeomID; // Re-trigger reference quantity update with default component. VSPAEROMgr.Update(); } m_RefWingChoice.SetVal( WingCompIDMap[ refGeomID ] ); // Update available set choices m_GeomSetChoice.ClearItems(); m_CGSetChoice.ClearItems(); vector <string> setVec = veh->GetSetNameVec(); for ( int iSet = 0; iSet < setVec.size(); iSet++ ) { m_GeomSetChoice.AddItem( setVec[iSet] ); m_CGSetChoice.AddItem( setVec[iSet] ); } m_GeomSetChoice.UpdateItems(); m_CGSetChoice.UpdateItems(); m_GeomSetChoice.SetVal( VSPAEROMgr.m_GeomSet() ); m_CGSetChoice.SetVal( VSPAEROMgr.m_CGGeomSet() ); // Case Setup m_AeroMethodToggleGroup.Update( VSPAEROMgr.m_AnalysisMethod.GetID() ); switch ( VSPAEROMgr.m_AnalysisMethod.Get() ) { case vsp::VSPAERO_ANALYSIS_METHOD::VORTEX_LATTICE: m_DegenFileName.Activate(); m_DegenFileButton.Activate(); m_CompGeomFileName.Deactivate(); m_CompGeomFileButton.Deactivate(); break; case vsp::VSPAERO_ANALYSIS_METHOD::PANEL: m_DegenFileName.Deactivate(); m_DegenFileButton.Deactivate(); m_CompGeomFileName.Activate(); m_CompGeomFileButton.Activate(); break; default: //do nothing; this should not be reachable break; } m_DegenFileName.Update( veh->getExportFileName( vsp::DEGEN_GEOM_CSV_TYPE ) ); m_CompGeomFileName.Update( veh->getExportFileName( vsp::VSPAERO_PANEL_TRI_TYPE ) ); m_NCPUSlider.Update( VSPAEROMgr.m_NCPU.GetID() ); m_StabilityCalcToggle.Update( VSPAEROMgr.m_StabilityCalcFlag.GetID() ); m_BatchCalculationToggle.Update( VSPAEROMgr.m_BatchModeFlag.GetID() ); //printf("m_SolverProcess.m_ThreadID = %lu\n", m_SolverProcess.m_ThreadID); if( m_SolverThreadIsRunning ) { m_ComputeGeometryButton.Deactivate(); } else { m_ComputeGeometryButton.Activate(); } // Wake Options m_WakeNumIterSlider.Update( VSPAEROMgr.m_WakeNumIter.GetID() ); m_WakeAvgStartIterSlider.Update( VSPAEROMgr.m_WakeAvgStartIter.GetID() ); m_WakeSkipUntilIterSlider.Update( VSPAEROMgr.m_WakeSkipUntilIter.GetID() ); // Reference Quantities m_RefToggle.Update( VSPAEROMgr.m_RefFlag.GetID() ); m_SrefSlider.Update( VSPAEROMgr.m_Sref.GetID() ); m_brefSlider.Update( VSPAEROMgr.m_bref.GetID() ); m_crefSlider.Update( VSPAEROMgr.m_cref.GetID() ); // CG Position m_NumSliceSlider.Update( VSPAEROMgr.m_NumMassSlice.GetID() ); m_XcgSlider.Update( VSPAEROMgr.m_Xcg.GetID() ); m_YcgSlider.Update( VSPAEROMgr.m_Ycg.GetID() ); m_ZcgSlider.Update( VSPAEROMgr.m_Zcg.GetID() ); // Flow Condition // Alpha m_AlphaStartInput.Update( VSPAEROMgr.m_AlphaStart.GetID() ); m_AlphaEndInput.Update( VSPAEROMgr.m_AlphaEnd.GetID() ); m_AlphaNptsInput.Update( VSPAEROMgr.m_AlphaNpts.GetID() ); if ( VSPAEROMgr.m_AlphaNpts.Get() == 1 ) { m_AlphaEndInput.Deactivate(); } else if ( VSPAEROMgr.m_AlphaNpts.Get() > 1 ) { m_AlphaEndInput.Activate(); } // Beta m_BetaStartInput.Update( VSPAEROMgr.m_BetaStart.GetID() ); m_BetaEndInput.Update( VSPAEROMgr.m_BetaEnd.GetID() ); m_BetaNptsInput.Update( VSPAEROMgr.m_BetaNpts.GetID() ); if ( VSPAEROMgr.m_BetaNpts.Get() == 1 ) { m_BetaEndInput.Deactivate(); } else if ( VSPAEROMgr.m_BetaNpts.Get() > 1 ) { m_BetaEndInput.Activate(); } // Mach m_MachStartInput.Update( VSPAEROMgr.m_MachStart.GetID() ); m_MachEndInput.Update( VSPAEROMgr.m_MachEnd.GetID() ); m_MachNptsInput.Update( VSPAEROMgr.m_MachNpts.GetID() ); if ( VSPAEROMgr.m_MachNpts.Get() == 1 ) { m_MachEndInput.Deactivate(); } else if ( VSPAEROMgr.m_MachNpts.Get() > 1 ) { m_MachEndInput.Activate(); } // Create Setup Button if( veh->GetVSPAEROCmd().empty() || !FileExist( VSPAEROMgr.m_DegenFileFull ) || m_SolverThreadIsRunning || m_SolverSetupThreadIsRunning || ( ( VSPAEROMgr.m_AnalysisMethod.Get() == vsp::VSPAERO_ANALYSIS_METHOD::PANEL ) && ( !FileExist( VSPAEROMgr.m_CompGeomFileFull ) ) ) ) { m_SetupButton.Deactivate(); } else { m_SetupButton.Activate(); } // Kill Solver Setup Button if( m_SolverSetupThreadIsRunning ) { m_KillSolverSetupButton.Activate(); } else { m_KillSolverSetupButton.Deactivate(); } // Setup Text Display m_SetupDividerBox->copy_label( std::string( "Setup File: " + GetFilename( VSPAEROMgr.m_SetupFile ) ).c_str() ); // Read Setup Button if( !FileExist( VSPAEROMgr.m_SetupFile ) ) { m_ReadSetup.Deactivate(); } else { m_ReadSetup.Activate(); } // Save Setup Button if( veh->GetVSPAEROCmd().empty() || m_SolverThreadIsRunning || m_SolverSetupThreadIsRunning ) { m_SaveSetup.Deactivate(); } else { m_SaveSetup.Activate(); } // Solver Button if( veh->GetVSPAEROCmd().empty() || !FileExist( VSPAEROMgr.m_DegenFileFull ) || !FileExist( VSPAEROMgr.m_SetupFile ) || m_SolverThreadIsRunning || ( VSPAEROMgr.m_AnalysisMethod.Get() == vsp::VSPAERO_ANALYSIS_METHOD::PANEL && !FileExist( VSPAEROMgr.m_CompGeomFileFull ) ) ) { m_SolverButton.Deactivate(); } else { m_SolverButton.Activate(); } // Kill Solver Button if( m_SolverThreadIsRunning ) { m_KillSolverButton.Activate(); } else { m_KillSolverButton.Deactivate(); } // Plot Window Button if( veh->GetVSPAEROCmd().empty() || !FileExist( VSPAEROMgr.m_DegenFileFull ) || !FileExist( VSPAEROMgr.m_SetupFile ) || ( VSPAEROMgr.m_AnalysisMethod.Get() == vsp::VSPAERO_ANALYSIS_METHOD::PANEL && !FileExist( VSPAEROMgr.m_CompGeomFileFull ) ) ) { m_PlotButton.Deactivate(); } else { m_PlotButton.Activate(); } // Viewer Button if( veh->GetVIEWERCmd().empty() || m_SolverThreadIsRunning || m_ViewerProcess.IsRunning() || !FileExist( VSPAEROMgr.m_AdbFile ) ) { m_ViewerButton.Deactivate(); } else { m_ViewerButton.Activate(); } // Export Button if ( ResultsMgr.GetNumResults( "VSPAERO_Wrapper" ) == 0 ) { m_ExportResultsToCsvButton.Deactivate(); } else { m_ExportResultsToCsvButton.Activate(); } } m_FLTK_Window->redraw(); return false; }