//==== Copy XSec ====// void XSecSurf::CopyXSec( int index ) { XSec* xs = FindXSec( index ); if ( !xs ) { return; } XSec* saved_xs = FindXSec( m_SavedXSec ); //==== Create Saved XSec ====// if ( saved_xs && ( saved_xs->GetType() != xs->GetType() || saved_xs->GetXSecCurve()->GetType() != xs->GetXSecCurve()->GetType() ) ) { vector_remove_val( m_XSecPtrVec, saved_xs ); delete saved_xs; saved_xs = NULL; } //==== Saved XSec ====// if ( !saved_xs ) { saved_xs = CreateXSec( xs->GetXSecCurve()->GetType() ); } //==== Copy Data ====// if ( saved_xs ) { saved_xs->CopyFrom( xs ); m_SavedXSec = saved_xs->GetID(); } }
//==== Insert Wing Sect ====// void WingGeom::InsertWingSect( int index ) { if ( index > 0 && index < m_XSecSurf.NumXSec() ) { XSec* xs = m_XSecSurf.FindXSec( index ); int type = xs->GetXSecCurve()->GetType(); string ins_id = m_XSecSurf.InsertXSec(type, index); SetActiveXSecIndex( index + 1 ); PasteWingSect( GetActiveXSecIndex() ); } }
//==== Insert XSec ====// void PropGeom::InsertXSec( ) { if ( m_ActiveXSec >= NumXSec() - 1 ) { return; } XSec* xs = GetXSec( m_ActiveXSec ); if ( xs ) { InsertXSec( xs->GetXSecCurve()->GetType() ); } }
//==== Copy XSec Curve====// void XSecSurf::CopyXSecCurve( int index ) { XSec* xs = FindXSec( index ); if ( !xs ) { return; } if ( m_SavedXSecCurve && m_SavedXSecCurve->GetType() != xs->GetXSecCurve()->GetType() ) { delete m_SavedXSecCurve; m_SavedXSecCurve = NULL; } if ( !m_SavedXSecCurve ) { m_SavedXSecCurve = CreateXSecCurve( xs->GetXSecCurve()->GetType() ); } if ( m_SavedXSecCurve ) { m_SavedXSecCurve->CopyFrom( xs->GetXSecCurve() ); } }
//==== Set Active XSec Type ====// void WingGeom::SetActiveAirfoilType( int type ) { XSec* xs = GetXSec( m_ActiveAirfoil ); if ( !xs ) { return; } if ( type == xs->GetXSecCurve()->GetType() ) { return; } m_XSecSurf.ChangeXSecShape( m_ActiveAirfoil, type ); Update(); }
//==== Set Active XSec Type ====// void PropGeom::SetActiveXSecType( int type ) { XSec* xs = GetXSec( m_ActiveXSec ); if ( !xs ) { return; } if ( type == xs->GetXSecCurve()->GetType() ) { return; } m_XSecSurf.ChangeXSecShape( m_ActiveXSec, type ); Update(); }
//==== Drag Parameters ====// void StackGeom::LoadDragFactors( DragFactors& drag_factors ) { double max_xsec_area = 0.000000000001; for ( int i = 0 ; i < ( int )m_XSecSurf.NumXSec() ; i++ ) { XSec* xs = m_XSecSurf.FindXSec( i ); XSecCurve* xsc = xs->GetXSecCurve(); double a = xsc->ComputeArea( ); if ( a > max_xsec_area ) { max_xsec_area = a; } } // drag_factors.m_Length = m_Length(); drag_factors.m_MaxXSecArea = max_xsec_area; // drag_factors.m_LengthToDia = m_Length() / dia; }
void FuselageScreen::GuiDeviceCallBack( GuiDevice* gui_device ) { //==== Find Fuselage Ptr ====// Geom* geom_ptr = m_ScreenMgr->GetCurrGeom(); if ( !geom_ptr || geom_ptr->GetType().m_Type != FUSELAGE_GEOM_TYPE ) { return; } FuselageGeom* fuselage_ptr = dynamic_cast< FuselageGeom* >( geom_ptr ); assert( fuselage_ptr ); if ( gui_device == &m_XSecIndexSelector ) { fuselage_ptr->SetActiveXSecIndex( m_XSecIndexSelector.GetIndex() ); fuselage_ptr->Update(); } else if ( gui_device == &m_XSecTypeChoice ) { int t = m_XSecTypeChoice.GetVal(); fuselage_ptr->SetActiveXSecType( t ); } else if ( gui_device == &m_ShowXSecButton ) { m_ScreenMgr->ShowScreen( ScreenMgr::VSP_XSEC_SCREEN ); } else if ( gui_device == &m_CutXSec ) { fuselage_ptr->CutActiveXSec(); } else if ( gui_device == &m_CopyXSec ) { fuselage_ptr->CopyActiveXSec(); } else if ( gui_device == &m_PasteXSec ) { fuselage_ptr->PasteActiveXSec(); } else if ( gui_device == &m_InsertXSec ) { fuselage_ptr->InsertXSec( ); } else if ( gui_device == &m_ReadFuseFileButton ) { int xsid = fuselage_ptr->GetActiveXSecIndex(); XSec* xs = fuselage_ptr->GetXSec( xsid ); if ( xs ) { XSecCurve* xsc = xs->GetXSecCurve(); if ( xsc ) { if ( xsc->GetType() == XS_FILE_FUSE ) { FileXSec* file_xs = dynamic_cast< FileXSec* >( xsc ); assert( file_xs ); string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Fuselage Cross Section", "*.fxs" ); file_xs->ReadXsecFile( newfile ); file_xs->Update(); xs->Update(); fuselage_ptr->Update(); } } } } else if ( gui_device == &m_AfReadFileButton ) { int xsid = fuselage_ptr->GetActiveXSecIndex(); XSec* xs = fuselage_ptr->GetXSec( xsid ); if ( xs ) { XSecCurve* xsc = xs->GetXSecCurve(); if ( xsc ) { if ( xsc->GetType() == XS_FILE_AIRFOIL ) { FileAirfoil* affile_xs = dynamic_cast< FileAirfoil* >( xsc ); assert( affile_xs ); string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Airfoil File", "*.{af,dat}", false ); affile_xs->ReadFile( newfile ); affile_xs->Update(); xs->Update(); fuselage_ptr->Update(); } } } } else if ( gui_device == &m_DesignPolicyChoice ) { // This is a hack to get the XSecXSlider to update its ranges. This // requires setting the ID to another valid FractionParm's ID. In this // case, m_YLocPercent of the same XSec. It will get set back to // m_XLocPercent in Update() before anyone notices the change. int xsid = fuselage_ptr->GetActiveXSecIndex(); FuseXSec* xs = (FuseXSec*) fuselage_ptr->GetXSec( xsid ); if ( xs ) { m_XSecXSlider.Update( xs->m_YLocPercent.GetID() ); } } SkinScreen::GuiDeviceCallBack( gui_device ); }
void WingScreen::GuiDeviceCallBack( GuiDevice* gui_device ) { //==== Find Fuselage Ptr ====// Geom* geom_ptr = m_ScreenMgr->GetCurrGeom(); if ( !geom_ptr || geom_ptr->GetType().m_Type != MS_WING_GEOM_TYPE ) { return; } WingGeom* wing_ptr = dynamic_cast< WingGeom* >( geom_ptr ); assert( wing_ptr ); if ( gui_device == &m_AfIndexSelector ) { wing_ptr->SetActiveAirfoilIndex( m_AfIndexSelector.GetIndex() ); wing_ptr->Update(); } else if ( gui_device == &m_AfModIndexSelector ) { wing_ptr->SetActiveAirfoilIndex( m_AfModIndexSelector.GetIndex() ); wing_ptr->Update(); } else if ( gui_device == &m_SectIndexSelector ) { wing_ptr->SetActiveXSecIndex( m_SectIndexSelector.GetIndex() ); wing_ptr->Update(); } else if ( gui_device == &m_SplitSectButton ) { int wsid = wing_ptr->GetActiveXSecIndex(); wing_ptr->SplitWingSect( wsid ); wing_ptr->Update(); } else if ( gui_device == &m_CutSectButton ) { int wsid = wing_ptr->GetActiveXSecIndex(); wing_ptr->CutWingSect( wsid ); wing_ptr->Update(); } else if ( gui_device == &m_CopySectButton ) { int wsid = wing_ptr->GetActiveXSecIndex(); wing_ptr->CopyWingSect( wsid ); wing_ptr->Update(); } else if ( gui_device == &m_PasteSectButton ) { int wsid = wing_ptr->GetActiveXSecIndex(); wing_ptr->PasteWingSect( wsid ); wing_ptr->Update(); } else if ( gui_device == &m_InsertSectButton ) { int wsid = wing_ptr->GetActiveXSecIndex(); wing_ptr->InsertWingSect( wsid ); wing_ptr->Update(); } else if ( gui_device == &m_AfTypeChoice ) { int t = m_AfTypeChoice.GetVal(); wing_ptr->SetActiveAirfoilType( t ); wing_ptr->Update(); } else if ( gui_device == &m_ShowXSecButton ) { m_ScreenMgr->ShowScreen( ScreenMgr::VSP_XSEC_SCREEN ); } else if ( gui_device == &m_CopyAfButton ) { int afid = wing_ptr->GetActiveAirfoilIndex(); wing_ptr->CopyAirfoil( afid ); } else if ( gui_device == &m_PasteAfButton ) { int afid = wing_ptr->GetActiveAirfoilIndex(); wing_ptr->PasteAirfoil(afid); wing_ptr->Update(); } else if ( gui_device == &m_ReadFuseFileButton ) { int xsid = wing_ptr->GetActiveAirfoilIndex(); XSec* xs = wing_ptr->GetXSec( xsid ); if ( xs ) { XSecCurve* xsc = xs->GetXSecCurve(); if ( xsc ) { if ( xsc->GetType() == XS_FILE_FUSE ) { FileXSec* file_xs = dynamic_cast< FileXSec* >( xsc ); assert( file_xs ); string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Fuselage Cross Section", "*.fxs" ); file_xs->ReadXsecFile( newfile ); file_xs->Update(); xs->Update(); wing_ptr->Update(); } } } } else if ( gui_device == &m_AfReadFileButton ) { int xsid = wing_ptr->GetActiveAirfoilIndex(); XSec* xs = wing_ptr->GetXSec( xsid ); if ( xs ) { XSecCurve* xsc = xs->GetXSecCurve(); if ( xsc ) { if ( xsc->GetType() == XS_FILE_AIRFOIL ) { FileAirfoil* affile_xs = dynamic_cast< FileAirfoil* >( xsc ); assert( affile_xs ); string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Airfoil File", "*.{af,dat}", false ); affile_xs->ReadFile( newfile ); affile_xs->Update(); xs->Update(); wing_ptr->Update(); } } } } else if ( gui_device == &m_UpPromoteButton ) { int xsid = wing_ptr->GetActiveAirfoilIndex(); XSec* xs = wing_ptr->GetXSec( xsid ); if ( xs ) { XSecCurve* xsc = xs->GetXSecCurve(); if ( xsc ) { if ( xsc->GetType() == XS_CST_AIRFOIL ) { CSTAirfoil* cst_xs = dynamic_cast< CSTAirfoil* >( xsc ); assert( cst_xs ); cst_xs->PromoteUpper(); cst_xs->Update(); xs->Update(); wing_ptr->Update(); } } } } else if ( gui_device == &m_LowPromoteButton ) { int xsid = wing_ptr->GetActiveAirfoilIndex(); XSec* xs = wing_ptr->GetXSec( xsid ); if ( xs ) { XSecCurve* xsc = xs->GetXSecCurve(); if ( xsc ) { if ( xsc->GetType() == XS_CST_AIRFOIL ) { CSTAirfoil* cst_xs = dynamic_cast< CSTAirfoil* >( xsc ); assert( cst_xs ); cst_xs->PromoteLower(); cst_xs->Update(); xs->Update(); wing_ptr->Update(); } } } } else if ( gui_device == &m_UpDemoteButton ) { int xsid = wing_ptr->GetActiveAirfoilIndex(); XSec* xs = wing_ptr->GetXSec( xsid ); if ( xs ) { XSecCurve* xsc = xs->GetXSecCurve(); if ( xsc ) { if ( xsc->GetType() == XS_CST_AIRFOIL ) { CSTAirfoil* cst_xs = dynamic_cast< CSTAirfoil* >( xsc ); assert( cst_xs ); cst_xs->DemoteUpper(); cst_xs->Update(); xs->Update(); wing_ptr->Update(); } } } } else if ( gui_device == &m_LowDemoteButton ) { int xsid = wing_ptr->GetActiveAirfoilIndex(); XSec* xs = wing_ptr->GetXSec( xsid ); if ( xs ) { XSecCurve* xsc = xs->GetXSecCurve(); if ( xsc ) { if ( xsc->GetType() == XS_CST_AIRFOIL ) { CSTAirfoil* cst_xs = dynamic_cast< CSTAirfoil* >( xsc ); assert( cst_xs ); cst_xs->DemoteLower(); cst_xs->Update(); xs->Update(); wing_ptr->Update(); } } } } else if ( ( gui_device == &m_FourFitCSTButton ) || ( gui_device == &m_SixFitCSTButton ) || ( gui_device == &m_AfFileFitCSTButton ) ) { int xsid = wing_ptr->GetActiveAirfoilIndex(); XSec* xs = wing_ptr->GetXSec( xsid ); if ( xs ) { XSecCurve* xsc = xs->GetXSecCurve(); if ( xsc ) { Airfoil* af_xs = dynamic_cast< Airfoil* >( xsc ); if ( af_xs ) { VspCurve c = af_xs->GetOrigCurve(); int deg = af_xs->m_FitDegree(); wing_ptr->SetActiveAirfoilType( XS_CST_AIRFOIL ); XSec* newxs = wing_ptr->GetXSec( xsid ); if ( newxs ) { XSecCurve* newxsc = newxs->GetXSecCurve(); if ( newxsc ) { if ( newxsc->GetType() == XS_CST_AIRFOIL ) { CSTAirfoil* cst_xs = dynamic_cast< CSTAirfoil* >( newxsc ); assert( cst_xs ); cst_xs->FitCurve( c, deg ); cst_xs->Update(); newxs->Update(); wing_ptr->Update(); } } } } } } } else if ( gui_device == &m_TestDriverGroupButton ) { int wsid = wing_ptr->GetActiveXSecIndex(); WingSect* wing_sect = dynamic_cast<WingSect*>(wing_ptr->GetXSec( wsid )); if ( wing_sect ) { vector< string > parm_ids = wing_sect->GetDriverParms(); wing_sect->m_DriverGroup.Test( parm_ids, 1e-4 ); } } GeomScreen::GuiDeviceCallBack( gui_device ); }
void StackScreen::GuiDeviceCallBack( GuiDevice* gui_device ) { //==== Find Fuselage Ptr ====// Geom* geom_ptr = m_ScreenMgr->GetCurrGeom(); if ( !geom_ptr || geom_ptr->GetType().m_Type != STACK_GEOM_TYPE ) { return; } StackGeom* stackgeom_ptr = dynamic_cast< StackGeom* >( geom_ptr ); assert( stackgeom_ptr ); if ( gui_device == &m_XSecIndexSelector ) { stackgeom_ptr->SetActiveXSecIndex( m_XSecIndexSelector.GetIndex() ); stackgeom_ptr->Update(); } else if ( gui_device == &m_XSecTypeChoice ) { int t = m_XSecTypeChoice.GetVal(); stackgeom_ptr->SetActiveXSecType( t ); } else if ( gui_device == &m_ShowXSecButton ) { m_ScreenMgr->ShowScreen( ScreenMgr::VSP_XSEC_SCREEN ); } else if ( gui_device == &m_CutXSec ) { stackgeom_ptr->CutActiveXSec(); } else if ( gui_device == &m_CopyXSec ) { stackgeom_ptr->CopyActiveXSec(); } else if ( gui_device == &m_PasteXSec ) { stackgeom_ptr->PasteActiveXSec(); } else if ( gui_device == &m_InsertXSec ) { stackgeom_ptr->InsertXSec( ); } else if ( gui_device == &m_ReadFuseFileButton ) { int xsid = stackgeom_ptr->GetActiveXSecIndex(); XSec* xs = stackgeom_ptr->GetXSec( xsid ); if ( xs ) { XSecCurve* xsc = xs->GetXSecCurve(); if ( xsc ) { if ( xsc->GetType() == XS_FILE_FUSE ) { FileXSec* file_xs = dynamic_cast< FileXSec* >( xsc ); assert( file_xs ); string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Fuselage Cross Section", "*.fxs" ); file_xs->ReadXsecFile( newfile ); file_xs->Update(); xs->Update(); stackgeom_ptr->Update(); } } } } else if ( gui_device == &m_AfReadFileButton ) { int xsid = stackgeom_ptr->GetActiveXSecIndex(); XSec* xs = stackgeom_ptr->GetXSec( xsid ); if ( xs ) { XSecCurve* xsc = xs->GetXSecCurve(); if ( xsc ) { if ( xsc->GetType() == XS_FILE_AIRFOIL ) { FileAirfoil* affile_xs = dynamic_cast< FileAirfoil* >( xsc ); assert( affile_xs ); string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Airfoil File", "*.{af,dat}" ); affile_xs->ReadFile( newfile ); affile_xs->Update(); xs->Update(); stackgeom_ptr->Update(); } } } } SkinScreen::GuiDeviceCallBack( gui_device ); }