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 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 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 ); }