//==== Update ====//
void WingSect::Update()
{
    m_LateUpdateFlag = false;

    XSecSurf* xsecsurf = (XSecSurf*) GetParentContainerPtr();

    // apply the needed transformation to get section into body orientation
    Matrix4d mat;
    xsecsurf->GetBasicTransformation( m_XSCurve->GetWidth(), mat );

    VspCurve baseCurve = GetUntransformedCurve();

    baseCurve.Transform( mat );

    //==== Apply Transform ====//
    m_TransformedCurve = baseCurve;

    Matrix4d tran_mat;
    tran_mat.translatef( m_XDelta, m_YDelta, m_ZDelta );

    Matrix4d rotate_mat;
    rotate_mat.rotateX( m_XRotate );
    rotate_mat.rotateY( m_YRotate );
    rotate_mat.rotateZ( m_ZRotate );

    Matrix4d cent_mat;
    cent_mat.translatef( -m_XCenterRot, -m_YCenterRot, -m_ZCenterRot );

    Matrix4d inv_cent_mat;
    inv_cent_mat.translatef( m_XCenterRot, m_YCenterRot, m_ZCenterRot );

    m_Transform.loadIdentity();

    m_Transform.postMult( tran_mat.data() );
    m_Transform.postMult( cent_mat.data() );
    m_Transform.postMult( rotate_mat.data() );
    m_Transform.postMult( inv_cent_mat.data() );

    m_Transform.postMult( xsecsurf->GetGlobalXForm().data() );

    m_TransformedCurve.Transform( m_Transform );


    //==== Inform Outboard Section of Change ====//
    int indx = xsecsurf->FindXSecIndex( m_ID );
    if( indx < xsecsurf->NumXSec() - 1 )
    {
        WingSect* nextxs = (WingSect*) xsecsurf->FindXSec( indx + 1);
        if( nextxs )
        {
            nextxs->SetLateUpdateFlag( true );
        }
    }

}
//==== Insert Wing Sect ====//
void WingGeom::SplitWingSect( int index  )
{
    WingSect* ws = GetWingSect( index );
    if ( ws )
    {
        double span = ws->m_Span();
        double rc = ws->m_RootChord();
        double ac = ws->m_AvgChord();
        double tc = ws->m_TipChord();
        double twist = 0.5*ws->m_Twist();

        int curve_type = ws->GetXSecCurve()->GetType();

        string ins_id = m_XSecSurf.InsertXSec( curve_type, index );

        ws->ForceSpanRcTc( span*0.5, rc, ac );
        ws->m_Twist = twist;
        ws->Update();

        XSec* xs = m_XSecSurf.FindXSec( ins_id );
        if ( xs )
        {
            WingSect* ins_ws = dynamic_cast< WingSect* >(xs);
            ins_ws->CopyFrom( ws );
            ins_ws->ForceSpanRcTc( span*0.5, ac, tc );
            ins_ws->m_Twist = twist;
            ins_ws->Update();
        }
    }

}
//==== Compute Rotation Center ====//
void WingGeom::ComputeCenter()
{
    m_Center = vec3d(0,0,0);

    WingSect* ws = ( WingSect* ) m_XSecSurf.FindXSec( 1 );
    if ( ws )
    {
        double len = ws->m_RootChord();
        m_Center.set_x( len*m_Origin() );
    }
}
//==== Get Sum Dihedral ====//
double WingGeom::GetSumDihedral( int sect_id )
{
    if ( sect_id < 1 || sect_id >= (int)m_XSecSurf.NumXSec() )
        return 0.0;

    if ( m_RelativeDihedralFlag() == false )
    {
        WingSect* ws = ( WingSect* ) m_XSecSurf.FindXSec( sect_id );
        return ws->m_Dihedral();
    }

    double sum_dihedral = 0.0;
    for ( int i = 1 ; i <= sect_id ; i++ )
    {
        WingSect* ws = ( WingSect* ) m_XSecSurf.FindXSec( i );
        sum_dihedral += ws->m_Dihedral();
    }

    return sum_dihedral;
}
//==== Scale ====//
void WingGeom::Scale()
{
    double currentScale = m_Scale() / m_LastScale();

    if( abs( 1.0 - currentScale ) > 1e-6 )
    {
        //==== Adjust Sections Area ====//
        vector< WingSect* > ws_vec = GetWingSectVec();
        for ( int i = 1 ; i < (int)ws_vec.size() ; i++ )
        {
            WingSect* ws = ws_vec[i];
            if ( ws )
            {
                double area = ws->m_Area()*currentScale*currentScale;
                ws->ForceAspectTaperArea( ws->m_Aspect(), ws->m_Taper(), area );
            }
        }

        m_LastScale = m_Scale();
    }
}
void WingGeom::AddDefaultSources( double base_len )
{
    vector< WingSect* > ws_vec = GetWingSectVec();
    double nseg = ( ( int ) ws_vec.size() ) - 1;
    double ustart = 0.0;

    if ( m_CapUMinOption() != VspSurf::NO_END_CAP )
    {
        nseg = nseg + 1.0;
        ustart = ustart  + 1.0;
    }

    if ( m_CapUMaxOption() != VspSurf::NO_END_CAP )
    {
        nseg = nseg + 1.0;;
    }

    char str[256];

    LineSource* lsource;

    for ( int i = 1 ; i < (int)ws_vec.size() ; i++ )
    {
        WingSect* ws = ws_vec[i];
        if ( ws )
        {
            double cr = ws->m_RootChord();
            double ct = ws->m_TipChord();

            lsource = new LineSource();
            sprintf( str, "Def_TE_LS_%d", i );
            lsource->SetName( str );
            lsource->m_Len = 0.01 * cr;
            lsource->m_Len2 = 0.01 * ct;
            lsource->m_Rad = 0.2 * cr;
            lsource->m_Rad2 = 0.2 * ct;
            lsource->m_ULoc1 = (i+ustart-1)/nseg;
            lsource->m_WLoc1 = 0.0;
            lsource->m_ULoc2 = (i+ustart)/nseg;
            lsource->m_WLoc2 = 0.0;
            AddCfdMeshSource( lsource );

            lsource = new LineSource();
            sprintf( str, "Def_LE_LS_%d", i );
            lsource->SetName( str );
            lsource->m_Len = 0.01 * cr;
            lsource->m_Len2 = 0.01 * ct;
            lsource->m_Rad = 0.2 * cr;
            lsource->m_Rad2 = 0.2 * ct;
            lsource->m_ULoc1 = (i+ustart-1)/nseg;
            lsource->m_WLoc1 = 0.5;
            lsource->m_ULoc2 = (i+ustart)/nseg;
            lsource->m_WLoc2 = 0.5;
            AddCfdMeshSource( lsource );

            if ( i == ( ( int ) ws_vec.size() - 1 ) )
            {
                lsource = new LineSource();
                lsource->SetName( "Def_Tip_LS" );
                lsource->m_Len = 0.01 * ct;
                lsource->m_Len2 = 0.01 * ct;
                lsource->m_Rad = 0.2 * ct;
                lsource->m_Rad2 = 0.2 * ct;
                lsource->m_ULoc1 = (i+ustart)/nseg;
                lsource->m_WLoc1 = 0.0;
                lsource->m_ULoc2 = (i+ustart)/nseg;
                lsource->m_WLoc2 = 0.5;
                AddCfdMeshSource( lsource );
            }
        }
    }
}
//==== Constructor ====//
WingGeom::WingGeom( Vehicle* vehicle_ptr ) : GeomXSec( vehicle_ptr )
{
    m_Name = "WingGeom";
    m_Type.m_Name = "Wing";
    m_Type.m_Type = MS_WING_GEOM_TYPE;

    m_MinActiveXSec = 1;

    m_Closed = false;

    m_XSecSurf.SetParentContainer( GetID() );
    m_XSecSurf.SetBasicOrientation( vsp::Y_DIR, X_DIR, XS_SHIFT_LE, true );

    m_RelativeDihedralFlag.Init("RelativeDihedralFlag", m_Name, this, 0, 0, 1, true );
    m_RelativeDihedralFlag.SetDescript( "Relative or Absolute Dihedral" );

    m_RelativeTwistFlag.Init("RelativeTwistFlag", m_Name, this, 0, 0, 1, true );
    m_RelativeTwistFlag.SetDescript( "Relative or Absolute Twist" );

    m_RotateAirfoilMatchDiedralFlag.Init("RotateAirfoilMatchDideralFlag", m_Name, this, 0, 0, 1, true );
    m_RotateAirfoilMatchDiedralFlag.SetDescript( "Rotate Airfoil To Stay Tangent To Dihedral (or Not)" );

    m_TotalSpan.Init( "TotalSpan", m_Name, this, 1.0, 1e-6, 1000000.0 );
    m_TotalSpan.SetDescript( "Total Planform Span" );

    m_TotalProjSpan.Init( "TotalProjectedSpan", m_Name, this, 1.0, 1e-6, 1000000.0 );
    m_TotalProjSpan.SetDescript( "Total Projected Planform Span" );

    m_TotalChord.Init( "TotalChord", m_Name, this, 1.0, 0.0, 1000000.0 );
    m_TotalChord.SetDescript( "Total Planform Chord" );

    m_TotalArea.Init( "TotalArea", m_Name, this, 1.0, 1e-10, 1.0e12 );
    m_TotalArea.SetDescript( "Total Planform Area" );

    //==== rename capping controls for wing specific terminology ====//
    m_CapUMinOption.SetDescript("Type of End Cap on Wing Root");
    m_CapUMinOption.Parm::Set(VspSurf::FLAT_END_CAP);
    m_CapUMinTess.SetDescript("Number of tessellated curves on Wing Root");
    m_CapUMaxOption.SetDescript("Type of End Cap on Wing Tip");
    m_CapUMaxOption.Parm::Set(VspSurf::FLAT_END_CAP);
    m_CapUMaxTess.SetDescript("Number of tessellated curves on Wing Tip");

    //==== Init Parms ====//
    m_TessU = 16;
    m_TessW = 31;
    m_ActiveXSec = 1;
    m_ActiveAirfoil = 0;
    m_SymPlanFlag = SYM_XZ;

    //==== Wing XSecs ====//
    m_XSecSurf.SetXSecType( XSEC_WING );
    m_XSecSurf.SetCutMinNumXSecs( 2 );

    m_XSecSurf.AddXSec( vsp::XS_FOUR_SERIES );
    m_XSecSurf.AddXSec( vsp::XS_FOUR_SERIES );

    WingSect* ws;

    ws = ( WingSect* ) m_XSecSurf.FindXSec( 0 );
    ws->SetGroupDisplaySuffix( 0 );

    ws = ( WingSect* ) m_XSecSurf.FindXSec( 1 );
    ws->SetGroupDisplaySuffix( 1 );
    ws->m_Sweep = 30.0;
    ws->m_RootChord = 4.0;
    ws->m_TipChord = 1.0;
    ws->m_Span = 9.0;

    UpdateSurf();
}
//==== Update Wing And Cross Section Placement ====//
void WingGeom::UpdateSurf()
{
    //==== Check If Total Span/Chord/Area Has Changed ====//
    bool total_change_flag = false;
    if ( UpdatedParm( m_TotalSpan.GetID() ) )
    {
        UpdateTotalSpan();
        total_change_flag = true;
    }

    if ( UpdatedParm( m_TotalProjSpan.GetID() ) )
    {
        UpdateTotalProjSpan();
        total_change_flag = true;
    }

    if ( UpdatedParm( m_TotalChord.GetID() ) )
    {
        UpdateTotalChord();
        total_change_flag = true;
    }

    if ( UpdatedParm( m_TotalArea.GetID() ) )
    {
        UpdateTotalArea();
        total_change_flag = true;
    }

    int active_sect = GetActiveXSecIndex();     // Save Active Section

    //==== Set Temp Active XSec Based On Updated Parms ====//
    if ( total_change_flag )
        SetActiveXSecIndex(1);
    else
        SetTempActiveXSec();

    //==== Make Sure Chord Match For Adjacent Wing Sections ====//
    MatchWingSections();

    SetActiveXSecIndex(active_sect);            // Restore Active Section


    // clear the u tessellation vector
    m_TessUVec.clear();

    vector< VspCurve > crv_vec( m_XSecSurf.NumXSec() );

    //==== Compute Parameters For Each Section ====//
    double total_span = 0.0;
    double total_sweep_offset = 0.0;
    double total_dihed_offset = 0.0;
    double total_twist = 0.0;

    //==== Load End Points for Each Section ====//
    for ( int i = 0 ; i < m_XSecSurf.NumXSec() ; i++ )
    {
        WingSect* ws = ( WingSect* ) m_XSecSurf.FindXSec( i );
        if ( ws )
        {
            //==== Reset Group Names ====//
            ws->SetGroupDisplaySuffix( i );

            double rad = ws->m_Span();
            double ty = rad*cos(GetSumDihedral(i)*DEG_2_RAD);
            double tz = rad*sin(GetSumDihedral(i)*DEG_2_RAD);

            double tan_le  = ws->GetTanSweepAt( ws->m_Sweep(), 0.0 );
            double toff    = tan_le*rad;                    // Tip X Offset

            if ( i == 0 )
            {
                ty = 0;
                tz = 0;
                toff = 0;
            }

            total_dihed_offset += tz;
            total_span += ty;
            total_sweep_offset += toff;

            if ( m_RelativeTwistFlag() )
                total_twist += ws->m_Twist();
            else
                total_twist = ws->m_Twist();

            ws->SetProjectedSpan( ty );

            //==== Find Width Parm ====//
            string width_id = ws->GetXSecCurve()->GetWidthParmID();
            Parm* width_parm = ParmMgr.FindParm( width_id );

            if ( width_parm )
            {
                width_parm->Deactivate();
                width_parm->Set( ws->m_TipChord() );
            }

            double dihead_rot = 0.0;
            if ( m_RotateAirfoilMatchDiedralFlag() )
            {
                if ( i == 0 )
                {
                    dihead_rot = GetSumDihedral( i+1 );
                }
                else if ( i ==  m_XSecSurf.NumXSec()-1 )
                {
                    dihead_rot = GetSumDihedral( i );
                }
                else
                {
                    dihead_rot = 0.5*( GetSumDihedral( i ) + GetSumDihedral( i+1 ) );
                }
            }

            //==== Load Transformations =====//
            ws->m_YDelta = total_span;
            ws->m_XDelta = total_sweep_offset;
            ws->m_ZDelta = total_dihed_offset;

            ws->m_YRotate = total_twist;
            ws->m_XRotate = dihead_rot;

            ws->m_XCenterRot = ws->m_XDelta + ws->m_TwistLoc()*ws->m_TipChord();
            ws->m_YCenterRot = ws->m_YDelta;
            ws->m_ZCenterRot = ws->m_ZDelta;

            crv_vec[i] =  ws->GetCurve();

            if ( i > 0 )
            {
                m_TessUVec.push_back( ws->m_SectTessU() );
            }
        }
    }

    m_MainSurfVec[0].SkinC0( crv_vec, false );
    if ( m_XSecSurf.GetFlipUD() )
    {
        m_MainSurfVec[0].FlipNormal();
    }
    m_MainSurfVec[0].SetSurfType( vsp::WING_SURF );

    //==== Load Totals ====//
    m_TotalSpan = ComputeTotalSpan();
    m_TotalProjSpan = ComputeTotalProjSpan();
    m_TotalChord = ComputeTotalChord();
    m_TotalArea = ComputeTotalArea();

}
Exemple #9
0
void MsWingScreen::show(Geom* geomPtr)
{
	char str[256];

	//==== Show General Component Screen ====//
	CompScreen::show(geomPtr);

	currGeom = (Ms_wing_geom*)geomPtr;

	setTitle( currGeom->getName().get_char_star() );

	//==== Wing Stuff ====//
	totalSpanSlider->set_parm_ptr( currGeom->get_total_span() );
	totalSpanInput->set_parm_ptr( currGeom->get_total_span() );

	totalProjSpanSlider->set_parm_ptr( currGeom->get_total_proj_span() );
	totalProjSpanInput->set_parm_ptr( currGeom->get_total_proj_span() );

	totalChordSlider->set_parm_ptr( currGeom->get_avg_chord() );
	totalChordInput->set_parm_ptr( currGeom->get_avg_chord() );

	totalAreaSlider->set_parm_ptr( currGeom->get_total_area() );
	totalAreaInput->set_parm_ptr( currGeom->get_total_area() );

	totalARInput->set_parm_ptr( currGeom->get_total_aspect() );
	totalARInput->deactivate();

	sweepOffsetSlider->set_parm_ptr( currGeom->get_sweep_off() );
	sweepOffsetInput->set_parm_ptr( currGeom->get_sweep_off() );


	ARSlider->set_parm_ptr( currGeom->get_sect_aspect() );
	ARInput->set_parm_ptr( currGeom->get_sect_aspect() );
	TRSlider->set_parm_ptr( currGeom->get_sect_taper() );
	TRInput->set_parm_ptr( currGeom->get_sect_taper() );
	areaSlider->set_parm_ptr( currGeom->get_sect_area() );
	areaInput->set_parm_ptr( currGeom->get_sect_area() );
	spanSlider->set_parm_ptr( currGeom->get_sect_span() );
	spanInput->set_parm_ptr( currGeom->get_sect_span() );
	RCSlider->set_parm_ptr( currGeom->get_sect_rc() );
	RCInput->set_parm_ptr( currGeom->get_sect_rc() );
	TCSlider->set_parm_ptr( currGeom->get_sect_tc() );
	TCInput->set_parm_ptr( currGeom->get_sect_tc() );

	msWingUI->driverChoice->value( currGeom->get_driver() ); 

	sectProjSpanOutput->set_parm_ptr( currGeom->get_sect_proj_span() ); 
	sectProjSpanOutput->deactivate();

	sweepSlider->set_parm_ptr( currGeom->get_sect_sweep() );
	sweepInput->set_parm_ptr( currGeom->get_sect_sweep() );
	sweepLocSlider->set_parm_ptr( currGeom->get_sect_sweep_loc() );
	sweepLocInput->set_parm_ptr( currGeom->get_sect_sweep_loc() );
	twistSlider->set_parm_ptr( currGeom->get_sect_twist() );
	twistInput->set_parm_ptr( currGeom->get_sect_twist() );
	twistLocSlider->set_parm_ptr( currGeom->get_sect_twist_loc() );
	twistLocInput->set_parm_ptr( currGeom->get_sect_twist_loc() );

	//==== Dihedral Stuff ====//
	dihed1Slider->set_parm_ptr( currGeom->get_sect_dihed1() );
	dihed1Input->set_parm_ptr( currGeom->get_sect_dihed1() );
	dihed2Slider->set_parm_ptr( currGeom->get_sect_dihed2() );
	dihed2Input->set_parm_ptr( currGeom->get_sect_dihed2() );

	dihedCrv1Slider->set_parm_ptr( currGeom->get_sect_dihed_crv1() );
	dihedCrv1Input->set_parm_ptr( currGeom->get_sect_dihed_crv1() );
	dihedCrv2Slider->set_parm_ptr( currGeom->get_sect_dihed_crv2() );
	dihedCrv2Input->set_parm_ptr( currGeom->get_sect_dihed_crv2() );

	dihedCrv1StrSlider->set_parm_ptr( currGeom->get_sect_dihed_crv1_str() );
	dihedCrv1StrInput->set_parm_ptr( currGeom->get_sect_dihed_crv1_str() );
	dihedCrv2StrSlider->set_parm_ptr( currGeom->get_sect_dihed_crv2_str() );
	dihedCrv2StrInput->set_parm_ptr( currGeom->get_sect_dihed_crv2_str() );

	degPerSegInput->set_parm_ptr( currGeom->get_deg_per_seg() );
	maxNumSegsInput->set_parm_ptr( currGeom->get_max_num_segs() );

	msWingUI->rotateAirfoilButton->value( currGeom->get_dihed_rot_flag() );
	msWingUI->smoothBlendButton->value( currGeom->get_smooth_blend_flag() );
	msWingUI->numInterpCounter->value( currGeom->get_num_interp() );

	msWingUI->relativeDihedralButton->value( currGeom->get_rel_dihedral_flag() );
	msWingUI->relativeTwistButton->value( currGeom->get_rel_twist_flag() );
	msWingUI->roundedTipsButton->value( currGeom->get_round_end_cap_flag() );

	msWingUI->sectionCounter->value( currGeom->get_curr_sect() );
	msWingUI->jointCounter->value( currGeom->get_curr_joint() );
	msWingUI->airfoilCounter->value( currGeom->get_curr_foil() );

	sprintf( str, "   %d", currGeom->get_num_sect() );
	msWingUI->totalNumSectOutput->value(str);


	//==== Airfoil Stuff ====//
	Af* afp = currGeom->get_af_ptr();
	msWingUI->airfoilTypeChoice->value( afp->get_type()-1 );
	msWingUI->airfoilInvertButton->value( afp->get_inverted_flag() );
	msWingUI->slatButton->value( afp->get_slat_flag() );
	msWingUI->slatShearButton->value( afp->get_slat_shear_flag() );
	msWingUI->flapButton->value( afp->get_flap_flag() );
	msWingUI->flapShearButton->value( afp->get_flap_shear_flag() );

	afCamberSlider->set_parm_ptr( afp->get_camber() );
	afCamberInput->set_parm_ptr(  afp->get_camber() );
	afCamberLocSlider->set_parm_ptr( afp->get_camber_loc() );
	afCamberLocInput->set_parm_ptr(  afp->get_camber_loc() );
	afThickSlider->set_parm_ptr( afp->get_thickness() );
	afThickInput->set_parm_ptr(  afp->get_thickness() );
	afThickLocSlider->set_parm_ptr( afp->get_thickness_loc() );
	afThickLocInput->set_parm_ptr(  afp->get_thickness_loc() );
	afIdealClSlider->set_parm_ptr( afp->get_ideal_cl() );
	afIdealClInput->set_parm_ptr(  afp->get_ideal_cl() );
	afASlider->set_parm_ptr( afp->get_a() );
	afAInput->set_parm_ptr(  afp->get_a() );

	afSlatChordSlider->set_parm_ptr( afp->get_slat_chord() );
	afSlatChordInput->set_parm_ptr(  afp->get_slat_chord() );
	afSlatAngleSlider->set_parm_ptr( afp->get_slat_angle() );
	afSlatAngleInput->set_parm_ptr(  afp->get_slat_angle() );
	afFlapChordSlider->set_parm_ptr( afp->get_flap_chord() );
	afFlapChordInput->set_parm_ptr(  afp->get_flap_chord() );
	afFlapAngleSlider->set_parm_ptr( afp->get_flap_angle() );
	afFlapAngleInput->set_parm_ptr(  afp->get_flap_angle() );

	totalSpanButton->set_parm_ptr( currGeom->get_total_span() );
	totalProjSpanButton->set_parm_ptr( currGeom->get_total_proj_span() );
	totalChordButton->set_parm_ptr( currGeom->get_avg_chord() );
	totalAreaButton->set_parm_ptr( currGeom->get_total_area() );
	sweepOffsetButton->set_parm_ptr( currGeom->get_total_aspect() );

	WingSect* ws = currGeom->getCurrWingSect();

	ARButton->set_parm_ptr( ws->get_ar() );
	TRButton->set_parm_ptr( ws->get_tr() );
	areaButton->set_parm_ptr( ws->get_area() );
	spanButton->set_parm_ptr( ws->get_span() );
	TCButton->set_parm_ptr( ws->get_tc() );
	RCButton->set_parm_ptr( ws->get_rc() );

	sweepButton->set_parm_ptr( ws->get_sweep() );
	sweepLocButton->set_parm_ptr( ws->get_sweepLoc() );
	twistButton->set_parm_ptr( ws->get_twist() );
	twistLocButton->set_parm_ptr( ws->get_twistLoc()  );

	dihed1Button->set_parm_ptr( ws->get_dihedral() );
	dihed2Button->set_parm_ptr( ws->get_dihedral() );
	dihedCrv1Button->set_parm_ptr( ws->get_dihed_crv1() );
	dihedCrv2Button->set_parm_ptr( ws->get_dihed_crv2() );
	dihedCrv1StrButton->set_parm_ptr( ws->get_dihed_crv1_str() );
	dihedCrv2StrButton->set_parm_ptr( ws->get_dihed_crv2_str() );

	afCamberButton->set_parm_ptr( afp->get_camber() );
	afCamberLocButton->set_parm_ptr( afp->get_camber_loc() );
	afThickButton->set_parm_ptr( afp->get_thickness() );
	afThickLocButton->set_parm_ptr( afp->get_thickness_loc() );
	afIdealClButton->set_parm_ptr( afp->get_ideal_cl() );
	afAButton->set_parm_ptr( afp->get_a() );

	afSlatChordButton->set_parm_ptr( afp->get_slat_chord() );
	afSlatAngleButton->set_parm_ptr( afp->get_slat_angle() );
	afFlapChordButton->set_parm_ptr( afp->get_flap_chord() );
	afFlapAngleButton->set_parm_ptr( afp->get_flap_angle() );

	msWingUI->airfoilNameInput->value( afp->get_name() );

	if ( afp->get_type() == NACA_6_SERIES )
		msWingUI->sixSeriesChoice->activate();
	else
		msWingUI->sixSeriesChoice->deactivate();

	leRadiusInput->set_parm_ptr( afp->get_leading_edge_radius() );

	glWin->setDrawBase( afp );
	glWin->redraw();

	msWingUI->UIWindow->show();

}
Exemple #10
0
//==== Update Wing Screen ====//
bool WingScreen::Update()
{
    assert( m_ScreenMgr );
    char str[256];

    Geom* geom_ptr = m_ScreenMgr->GetCurrGeom();
    if ( !geom_ptr || geom_ptr->GetType().m_Type != MS_WING_GEOM_TYPE )
    {
        Hide();
        return false;
    }

    GeomScreen::Update();
    m_NumUSlider.Deactivate();

    WingGeom* wing_ptr = dynamic_cast< WingGeom* >( geom_ptr );
    assert( wing_ptr );

    //==== Plan Parms ===//
    m_PlanSpanSlider.Update( wing_ptr->m_TotalSpan.GetID() );
    m_PlanProjSpanSlider.Update( wing_ptr->m_TotalProjSpan.GetID() );
    m_PlanChordSlider.Update( wing_ptr->m_TotalChord.GetID() );
    m_PlanAreaSlider.Update( wing_ptr->m_TotalArea.GetID() );

    m_LEClusterSlider.Update( wing_ptr->m_LECluster.GetID() );
    m_TEClusterSlider.Update( wing_ptr->m_TECluster.GetID() );

    sprintf( str, "%6.4f", wing_ptr->m_TotalProjSpan() * wing_ptr->m_TotalProjSpan() / wing_ptr->m_TotalArea() );
    m_PlanAROutput.Update( str );

    m_RootCapTypeChoice.Update( wing_ptr->m_CapUMinOption.GetID() );
    m_TipCapTypeChoice.Update( wing_ptr->m_CapUMaxOption.GetID() );
    if ( wing_ptr->m_CapUMinOption() == VspSurf::NO_END_CAP &&
         wing_ptr->m_CapUMaxOption() == VspSurf::NO_END_CAP )
    {
        m_CapTessSlider.Deactivate();
    }
    else
    {
        m_CapTessSlider.Update( wing_ptr->m_CapUMinTess.GetID() );
    }

    WingSect* root_sect = dynamic_cast<WingSect*>(wing_ptr->GetXSec( 0 ));

    if ( root_sect )
    {
        m_IncidenceSlider.Update( root_sect->m_Twist.GetID() );
        m_IncidenceLocSlider.Update( root_sect->m_TwistLoc.GetID() );
    }

    sprintf( str, "       %d", wing_ptr->NumXSec()-1 );
    m_NumSectOutput.Update(  str );

    ////==== Wing Section Index Display ====//
    int ws_index = wing_ptr->GetActiveXSecIndex();
    m_SectIndexSelector.SetIndex( ws_index );

    WingSect* wing_sect = dynamic_cast<WingSect*>(wing_ptr->GetXSec( ws_index ));

    if ( wing_sect )
    {
        m_SectUTessSlider.Update( wing_sect->m_SectTessU.GetID() );

        m_RootClusterSlider.Update( wing_sect->m_RootCluster.GetID() );
        m_TipClusterSlider.Update( wing_sect->m_TipCluster.GetID() );

        m_WingDriverGroupBank.SetDriverGroup( &wing_sect->m_DriverGroup );
        vector< string > parm_ids = wing_sect->GetDriverParms();
        wing_sect->m_DriverGroup.UpdateGroup( parm_ids );
        m_WingDriverGroupBank.Update( parm_ids );

        m_SweepSlider.Update( wing_sect->m_Sweep.GetID() );
        m_SweepLocSlider.Update( wing_sect->m_SweepLoc.GetID() );
        m_SecSweepLocSlider.Update( wing_sect->m_SecSweepLoc.GetID() );
        m_TwistSlider.Update( wing_sect->m_Twist.GetID() );
        m_TwistLocSlider.Update( wing_sect->m_TwistLoc.GetID() );

        m_DihedralSlider.Update( wing_sect->m_Dihedral.GetID() );
        m_DihedralAbsRelToggle.Update( wing_ptr->m_RelativeDihedralFlag.GetID() );
        m_TwistAbsRelToggle.Update( wing_ptr->m_RelativeTwistFlag.GetID() );

        m_RotateFoilMatchDihedral.Update( wing_ptr->m_RotateAirfoilMatchDiedralFlag.GetID() );

        sprintf( str, " %6.4f", wing_sect->GetProjectedSpan() );
        m_SectProjSpanOutput.Update(  str );

    }

    //==== XSec Index Display ===//
    int xsid = wing_ptr->GetActiveAirfoilIndex();
    m_AfIndexSelector.SetIndex( xsid );
    m_AfModIndexSelector.SetIndex( xsid );

    WingSect* ws = ( WingSect* ) wing_ptr->GetXSec( xsid );
    if ( ws )
    {
        XSecCurve* xsc = ws->GetXSecCurve();
        if ( xsc )
        {
            m_AfTypeChoice.SetVal( xsc->GetType() );

            if ( xsc->GetType() == XS_POINT )
            {
                DisplayGroup( NULL );
            }
            else if ( xsc->GetType() == XS_SUPER_ELLIPSE )
            {
                DisplayGroup( &m_SuperGroup );

                SuperXSec* super_xs = dynamic_cast< SuperXSec* >( xsc );
                assert( super_xs );
                m_SuperHeightSlider.Update( super_xs->m_Height.GetID() );
                m_SuperWidthSlider.Update( super_xs->m_Width.GetID() );
                m_SuperMSlider.Update( super_xs->m_M.GetID() );
                m_SuperNSlider.Update( super_xs->m_N.GetID() );
            }
            else if ( xsc->GetType() == XS_CIRCLE )
            {
                DisplayGroup( &m_CircleGroup );

                CircleXSec* circle_xs = dynamic_cast< CircleXSec* >( xsc );
                assert( circle_xs );

                m_DiameterSlider.Update( circle_xs->m_Diameter.GetID() );
            }
            else if ( xsc->GetType() == XS_ELLIPSE )
            {
                DisplayGroup( & m_EllipseGroup );

                EllipseXSec* ellipse_xs = dynamic_cast< EllipseXSec* >( xsc );
                m_EllipseHeightSlider.Update( ellipse_xs->m_Height.GetID() );
                m_EllipseWidthSlider.Update( ellipse_xs->m_Width.GetID() );
            }
            else if ( xsc->GetType() == XS_ROUNDED_RECTANGLE )
            {
                DisplayGroup( & m_RoundedRectGroup );
                RoundedRectXSec* rect_xs = dynamic_cast< RoundedRectXSec* >( xsc );
                assert( rect_xs );

                m_RRHeightSlider.Update( rect_xs->m_Height.GetID() );
                m_RRWidthSlider.Update( rect_xs->m_Width.GetID() );
                m_RRRadiusSlider.Update( rect_xs->m_Radius.GetID() );
            }
            else if ( xsc->GetType() == XS_GENERAL_FUSE )
            {
                DisplayGroup( &m_GenGroup );
                GeneralFuseXSec* gen_xs = dynamic_cast< GeneralFuseXSec* >( xsc );
                assert( gen_xs );

                m_GenHeightSlider.Update( gen_xs->m_Height.GetID() );
                m_GenWidthSlider.Update( gen_xs->m_Width.GetID() );
                m_GenMaxWidthLocSlider.Update( gen_xs->m_MaxWidthLoc.GetID() );
                m_GenCornerRadSlider.Update( gen_xs->m_CornerRad.GetID() );
                m_GenTopTanAngleSlider.Update( gen_xs->m_TopTanAngle.GetID() );
                m_GenBotTanAngleSlider.Update( gen_xs->m_BotTanAngle.GetID() );
                m_GenTopStrSlider.Update( gen_xs->m_TopStr.GetID() );
                m_GenBotStrSlider.Update( gen_xs->m_BotStr.GetID() );
                m_GenUpStrSlider.Update( gen_xs->m_UpStr.GetID() );
                m_GenLowStrSlider.Update( gen_xs->m_LowStr.GetID() );
            }
            else if ( xsc->GetType() == XS_FOUR_SERIES )
            {
                DisplayGroup( &m_FourSeriesGroup );
                FourSeries* fs_xs = dynamic_cast< FourSeries* >( xsc );
                assert( fs_xs );

                m_FourChordSlider.Update( fs_xs->m_Chord.GetID() );
                m_FourThickChordSlider.Update( fs_xs->m_ThickChord.GetID() );
                m_FourCamberSlider.Update( fs_xs->m_Camber.GetID() );
                m_FourCamberLocSlider.Update( fs_xs->m_CamberLoc.GetID() );
                m_FourInvertButton.Update( fs_xs->m_Invert.GetID() );
                m_FourNameOutput.Update( fs_xs->GetAirfoilName() );
                m_FourDegreeCounter.Update( fs_xs->m_FitDegree.GetID() );
                m_FourEqArcLenButton.Update( fs_xs->m_EqArcLen.GetID() );
            }
            else if ( xsc->GetType() == XS_SIX_SERIES )
            {
                DisplayGroup( &m_SixSeriesGroup );
                SixSeries* ss_xs = dynamic_cast< SixSeries* >( xsc );
                assert( ss_xs );

                m_SixChordSlider.Update( ss_xs->m_Chord.GetID() );
                m_SixThickChordSlider.Update( ss_xs->m_ThickChord.GetID() );
                m_SixIdealClSlider.Update( ss_xs->m_IdealCl.GetID() );
                m_SixASlider.Update( ss_xs->m_A.GetID() );

                m_SixInvertButton.Update( ss_xs->m_Invert.GetID() );
                m_SixNameOutput.Update( ss_xs->GetAirfoilName() );
                m_SixSeriesChoice.Update( ss_xs->m_Series.GetID() );
                m_SixDegreeCounter.Update( ss_xs->m_FitDegree.GetID() );
            }
            else if ( xsc->GetType() == XS_BICONVEX )
            {
                DisplayGroup( &m_BiconvexGroup );
                Biconvex* bi_xs = dynamic_cast< Biconvex* >( xsc );
                assert( bi_xs );

                m_BiconvexChordSlider.Update( bi_xs->m_Chord.GetID() );
                m_BiconvexThickChordSlider.Update( bi_xs->m_ThickChord.GetID() );
            }
            else if ( xsc->GetType() == XS_WEDGE )
            {
                DisplayGroup( &m_WedgeGroup );
                Wedge* we_xs = dynamic_cast< Wedge* >( xsc );
                assert( we_xs );

                m_WedgeChordSlider.Update( we_xs->m_Chord.GetID() );
                m_WedgeThickChordSlider.Update( we_xs->m_ThickChord.GetID() );
                m_WedgeThickLocSlider.Update( we_xs->m_ThickLoc.GetID() );
            }
            else if ( xsc->GetType() == XS_FILE_FUSE )
            {
                DisplayGroup( &m_FuseFileGroup );
                FileXSec* file_xs = dynamic_cast< FileXSec* >( xsc );
                assert( file_xs );

                m_FileHeightSlider.Update( file_xs->m_Height.GetID() );
                m_FileWidthSlider.Update( file_xs->m_Width.GetID() );
            }
            else if ( xsc->GetType() == XS_FILE_AIRFOIL )
            {
                DisplayGroup( &m_AfFileGroup );
                FileAirfoil* affile_xs = dynamic_cast< FileAirfoil* >( xsc );
                assert( affile_xs );

                m_AfFileChordSlider.Update( affile_xs->m_Chord.GetID() );
                m_AfFileInvertButton.Update( affile_xs->m_Invert.GetID() );
                m_AfFileNameOutput.Update( affile_xs->GetAirfoilName() );
                m_AfFileDegreeCounter.Update( affile_xs->m_FitDegree.GetID() );
            }
            else if ( xsc->GetType() == XS_CST_AIRFOIL )
            {
                DisplayGroup( &m_CSTAirfoilGroup );
                CSTAirfoil* cst_xs = dynamic_cast< CSTAirfoil* >( xsc );
                assert( cst_xs );

                int num_up = cst_xs->m_UpDeg() + 1;
                int num_low = cst_xs->m_LowDeg() + 1;

                char str[255];
                sprintf( str, "%d", cst_xs->m_UpDeg() );
                m_UpDegreeOutput.Update( str );
                sprintf( str, "%d", cst_xs->m_LowDeg() );
                m_LowDegreeOutput.Update( str );

                m_CSTInvertButton.Update( cst_xs->m_Invert.GetID() );
                m_CSTContLERadButton.Update( cst_xs->m_ContLERad.GetID() );
                m_CSTEqArcLenButton.Update( cst_xs->m_EqArcLen.GetID() );

                if ( ( m_UpCoeffSliderVec.size() != num_up ) || ( m_LowCoeffSliderVec.size() != num_low ) )
                {
                    RebuildCSTGroup( cst_xs );
                }

                for ( int i = 0; i < num_up; i++ )
                {
                    Parm *p = cst_xs->m_UpCoeffParmVec[i];
                    if ( p )
                    {
                        m_UpCoeffSliderVec[i].Update( p->GetID() );
                    }
                }

                for ( int i = 0; i < num_low; i++ )
                {
                    Parm *p = cst_xs->m_LowCoeffParmVec[i];
                    if ( p )
                    {
                        m_LowCoeffSliderVec[i].Update( p->GetID() );
                    }
                }

                if ( cst_xs->m_ContLERad() && num_low > 0 )
                {
                    m_LowCoeffSliderVec[0].Deactivate();
                }
            }

            m_TECloseChoice.Update( xsc->m_TECloseType.GetID() );
            m_TECloseGroup.Update( xsc->m_TECloseAbsRel.GetID() );

            m_CloseThickSlider.Update( xsc->m_TECloseThick.GetID() );
            m_CloseThickChordSlider.Update( xsc->m_TECloseThickChord.GetID() );

            if ( xsc->m_TECloseType() != CLOSE_NONE )
            {
                m_TECloseABSButton.Activate();
                m_TECloseRELButton.Activate();

                if ( xsc->m_TECloseAbsRel() == ABS )
                {
                    m_CloseThickSlider.Activate();
                    m_CloseThickChordSlider.Deactivate();
                }
                else
                {
                    m_CloseThickSlider.Deactivate();
                    m_CloseThickChordSlider.Activate();
                }
            }
            else
            {
                m_CloseThickSlider.Deactivate();
                m_CloseThickChordSlider.Deactivate();

                m_TECloseABSButton.Deactivate();
                m_TECloseRELButton.Deactivate();
            }

            m_TETrimChoice.Update( xsc->m_TETrimType.GetID() );
            m_TETrimGroup.Update( xsc->m_TETrimAbsRel.GetID() );


            m_TrimXSlider.Update( xsc->m_TETrimX.GetID() );
            m_TrimXChordSlider.Update( xsc->m_TETrimXChord.GetID() );
            m_TrimThickSlider.Update( xsc->m_TETrimThick.GetID() );
            m_TrimThickChordSlider.Update( xsc->m_TETrimThickChord.GetID() );

            m_TrimXSlider.Deactivate();
            m_TrimXChordSlider.Deactivate();
            m_TrimThickSlider.Deactivate();
            m_TrimThickChordSlider.Deactivate();
            m_TETrimABSButton.Deactivate();
            m_TETrimRELButton.Deactivate();

            if ( xsc->m_TETrimType() != TRIM_NONE )
            {
                m_TETrimABSButton.Activate();
                m_TETrimRELButton.Activate();
            }

            if ( xsc->m_TETrimType() == TRIM_X )
            {
                if ( xsc->m_TETrimAbsRel() == ABS )
                {
                    m_TrimXSlider.Activate();
                }
                else
                {
                    m_TrimXChordSlider.Activate();
                }
            }
            else if ( xsc->m_TETrimType() == TRIM_THICK )
            {
                if ( xsc->m_TETrimAbsRel() == ABS )
                {
                    m_TrimThickSlider.Activate();
                }
                else
                {
                    m_TrimThickChordSlider.Activate();
                }
            }

            m_AFThetaSlider.Update( xsc->m_Theta.GetID() );
            m_AFScaleSlider.Update( xsc->m_Scale.GetID() );
            m_AFDeltaXSlider.Update( xsc->m_DeltaX.GetID() );
            m_AFDeltaYSlider.Update( xsc->m_DeltaY.GetID() );
            m_AFShiftLESlider.Update( xsc->m_ShiftLE.GetID() );
        }
    }
    return true;
}