示例#1
0
文件: Log.cpp 项目: nemerle/boomerang
void Log::logDirect(LogLevel level, const char *file, int line, const QString &msg)
{
    if (!canLog(level)) {
        return;
    }

    char prettyFile[40]; // truncated file name
    truncateFileName(prettyFile, 40, file);

    QString header  = "%1 | %2 | %3 | %4\n";
    QString logLine = header.arg(levelToString(level)).arg(prettyFile).arg(line, 4).arg(msg);
    this->write(logLine);

    if (level == LogLevel::Fatal) {
        abort();
    }
}
// Callback for all other GUI Devices
void ManageBackgroundScreen::GuiDeviceCallBack( GuiDevice* device )
{
    assert( m_ScreenMgr );

    MainVSPScreen* main = dynamic_cast<MainVSPScreen*>( m_ScreenMgr->GetScreen( m_ScreenMgr->VSP_MAIN_SCREEN ) );
    if( !main )
    {
        return;
    }

    VSPGUI::VspGlWindow * glwin = main->GetGLWindow();

    VSPGraphic::Viewport * viewport = glwin->getGraphicEngine()->getDisplay()->getViewport();
    if( !viewport )
    {
        return;
    }

    if ( device == &m_Color )
    {
        m_Color.GetFlButton()->value( 1 );
        m_Image.GetFlButton()->value( 0 );
        viewport->getBackground()->removeImage();
        viewport->getBackground()->setBackgroundMode( VSPGraphic::Common::VSP_BACKGROUND_COLOR );
    }
    else if ( device == &m_Image )
    {
        m_Color.GetFlButton()->value( 0 );
        m_Image.GetFlButton()->value( 1 );
        viewport->getBackground()->setBackgroundMode( VSPGraphic::Common::VSP_BACKGROUND_IMAGE );

        if ( m_ImageFile.compare( "" ) != 0 )
        {
            viewport->getBackground()->attachImage( VSPGraphic::GlobalTextureRepo()->get2DTexture( m_ImageFile.c_str() ) );
        }
    }
    else if ( device == &m_FileSelect )
    {
        std::string fileName = m_ScreenMgr->GetSelectFileScreen()->FileChooser(
                "Select Image File", "*.{jpg,png,tga,bmp,gif}", false );

        if( !fileName.empty() )
        {
            viewport->getBackground()->removeImage();
            viewport->getBackground()->attachImage( VSPGraphic::GlobalTextureRepo()->get2DTexture( fileName.c_str() ) );
            m_ImageFile = fileName;
            m_FileOutput.Update( truncateFileName( fileName, 40 ).c_str() );
        }
    }
    else if ( device == &m_PreserveAspect )
    {
        if ( m_PreserveAspect.GetFlButton()->value() == 1 )
        {
            viewport->getBackground()->preserveAR( true );
        }
        else
        {
            viewport->getBackground()->preserveAR( false );
        }
    }
    else if ( device == &m_ResetDefaults )
    {
        viewport->getBackground()->reset();
        colorChooser->rgb( viewport->getBackground()->getRed(), viewport->getBackground()->getGreen(),
                           viewport->getBackground()->getBlue() );
        m_FileOutput.Update("");
        m_ImageFile = "";

        //Reset Scale & Offset
        m_WidthScaleValue.Set( viewport->getBackground()->getScaleW() );
        m_HeightScaleValue.Set( viewport->getBackground()->getScaleH() );

        m_XOffsetValue.Set( viewport->getBackground()->getOffsetX() );
        m_YOffsetValue.Set( viewport->getBackground()->getOffsetY() );
    }

    m_ScreenMgr->SetUpdateFlag( true );
}
bool CfdMeshScreen::Update()
{
    int i;

    LoadSetChoice();

    CfdMeshMgr.UpdateSourcesAndWakes();
    CfdMeshMgr.UpdateDomain();

    //==== Base Len ====//

    m_BodyEdgeSizeSlider.Update( CfdMeshMgr.GetGridDensityPtr()->m_BaseLen.GetID() );
    m_MinEdgeSizeSlider.Update( CfdMeshMgr.GetGridDensityPtr()->m_MinLen.GetID() );
    m_MaxGapSizeSlider.Update( CfdMeshMgr.GetGridDensityPtr()->m_MaxGap.GetID() );
    m_NumCircSegmentSlider.Update( CfdMeshMgr.GetGridDensityPtr()->m_NCircSeg.GetID() );
    m_GrowRatioSlider.Update( CfdMeshMgr.GetGridDensityPtr()->m_GrowRatio.GetID() );
    m_IntersectSubSurfsButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_IntersectSubSurfs.GetID() );

    m_FarXScaleSlider.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_FarXScale.GetID() );
    m_FarYScaleSlider.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_FarYScale.GetID() );
    m_FarZScaleSlider.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_FarZScale.GetID() );


//  char xstr[255];
//  char ystr[255];
//  char zstr[255];
//  sprintf( xstr, "%0.4f", CfdMeshMgr.GetFarLength() );
//  sprintf( ystr, "%0.4f", CfdMeshMgr.GetFarWidth() );
//  sprintf( zstr, "%0.4f", CfdMeshMgr.GetFarHeight() );
//  m_CfdMeshUI->farXScaleAbsInput->value(xstr);
//  m_CfdMeshUI->farYScaleAbsInput->value(ystr);
//  m_CfdMeshUI->farZScaleAbsInput->value(zstr);


    m_FarXLocationSlider.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_FarXLocation.GetID() );
    m_FarYLocationSlider.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_FarYLocation.GetID() );
    m_FarZLocationSlider.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_FarZLocation.GetID() );

    m_FarEdgeLengthSlider.Update( CfdMeshMgr.GetGridDensityPtr()->m_FarMaxLen.GetID() );
    m_FarGapSizeSlider.Update( CfdMeshMgr.GetGridDensityPtr()->m_FarMaxGap.GetID() );
    m_FarCircSegmentSlider.Update( CfdMeshMgr.GetGridDensityPtr()->m_FarNCircSeg.GetID() );

    m_WakeScaleSlider.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_WakeScale.GetID() );
    m_WakeAngleSlider.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_WakeAngle.GetID() );

    //==== Load Geom Choice ====//
    m_GeomVec = m_Vehicle->GetGeomVec();

    m_CfdMeshUI->compChoice->clear();
    m_CfdMeshUI->surfChoice->clear();
    m_CfdMeshUI->wakeCompChoice->clear();
    m_CfdMeshUI->farCompChoice->clear();
    map< string, int > compIDMap;
    map< string, int > wingCompIDMap;
    m_WingGeomVec.clear();

    int iwing = 0;
    for ( i = 0 ; i < ( int )m_GeomVec.size() ; i++ )
    {
        char str[256];
        Geom* g = m_Vehicle->FindGeom( m_GeomVec[i] );
        if ( g )
        {
            sprintf( str, "%d_%s", i, g->GetName().c_str() );
            m_CfdMeshUI->compChoice->add( str );
            if( g->HasWingTypeSurfs() )
            {
                m_CfdMeshUI->wakeCompChoice->add( str );
                wingCompIDMap[ m_GeomVec[i] ] = iwing;
                m_WingGeomVec.push_back( m_GeomVec[i] );
                iwing ++;
            }
            m_CfdMeshUI->farCompChoice->add( str );
            compIDMap[ m_GeomVec[i] ] = i;
        }
    }

    string currSourceGeomID = CfdMeshMgr.GetCurrSourceGeomID();
    if( currSourceGeomID.length() == 0 && m_GeomVec.size() > 0 )
    {
        // Handle case default case.
        currSourceGeomID = m_GeomVec[0];
        CfdMeshMgr.SetCurrSourceGeomID( currSourceGeomID );
    }
    Geom* currGeom = m_Vehicle->FindGeom( currSourceGeomID );
    m_CfdMeshUI->compChoice->value( compIDMap[ currSourceGeomID ] );

    string wakeGeomID = CfdMeshMgr.GetWakeGeomID();
    if( wakeGeomID.length() == 0 && m_WingGeomVec.size() > 0 )
    {
        // Handle case default case.
        wakeGeomID = m_WingGeomVec[0];
        CfdMeshMgr.SetWakeGeomID( wakeGeomID );
    }
    Geom* wakeGeom = m_Vehicle->FindGeom( wakeGeomID );
    m_CfdMeshUI->wakeCompChoice->value( wingCompIDMap[ wakeGeomID ] );

    string farGeomID = CfdMeshMgr.GetCfdSettingsPtr()->GetFarGeomID();
    if( farGeomID.length() == 0 && m_GeomVec.size() > 0 )
    {
        // Handle case default case.
        farGeomID = m_GeomVec[0];
        CfdMeshMgr.GetCfdSettingsPtr()->SetFarGeomID( farGeomID );
    }
    m_CfdMeshUI->farCompChoice->value( compIDMap[ farGeomID ] );

    BaseSource* source = CfdMeshMgr.GetCurrSource();

    if ( source )
    {
        m_LengthSlider.Activate();
        m_RadiusSlider.Activate();
        m_CfdMeshUI->SourceNameInput->activate();

        m_LengthSlider.Update( source->m_Len.GetID() );
        m_RadiusSlider.Update( source->m_Rad.GetID() );

        m_CfdMeshUI->SourceNameInput->value( source->GetName().c_str() );

        if ( source->GetType() == vsp::POINT_SOURCE )
        {
            m_U1Slider.Activate();
            m_W1Slider.Activate();

            PointSource* ps = ( PointSource* )source;

            m_U1Slider.Update( ps->m_ULoc.GetID() );
            m_W1Slider.Update( ps->m_WLoc.GetID() );

            m_CfdMeshUI->EditSourceTitle->label( "Edit Point Source" );

            m_Length2Slider.Deactivate();
            m_Radius2Slider.Deactivate();
            m_U2Slider.Deactivate();
            m_W2Slider.Deactivate();
        }
        else if ( source->GetType() == vsp::LINE_SOURCE )
        {
            m_Length2Slider.Activate();
            m_Radius2Slider.Activate();
            m_U1Slider.Activate();
            m_W1Slider.Activate();
            m_U2Slider.Activate();
            m_W2Slider.Activate();

            LineSource* ps = ( LineSource* )source;

            m_U1Slider.Update( ps->m_ULoc1.GetID() );
            m_W1Slider.Update( ps->m_WLoc1.GetID() );

            m_U2Slider.Update( ps->m_ULoc2.GetID() );
            m_W2Slider.Update( ps->m_WLoc2.GetID() );

            m_Length2Slider.Update( ps->m_Len2.GetID() );
            m_Radius2Slider.Update( ps->m_Rad2.GetID() );

            m_CfdMeshUI->EditSourceTitle->label( "Edit Line Source" );
        }
        else if ( source->GetType() == vsp::BOX_SOURCE )
        {
            m_U1Slider.Activate();
            m_W1Slider.Activate();
            m_U2Slider.Activate();
            m_W2Slider.Activate();

            BoxSource* ps = ( BoxSource* )source;

            m_U1Slider.Update( ps->m_ULoc1.GetID() );
            m_W1Slider.Update( ps->m_WLoc1.GetID() );

            m_U2Slider.Update( ps->m_ULoc2.GetID() );
            m_W2Slider.Update( ps->m_WLoc2.GetID() );

            m_CfdMeshUI->EditSourceTitle->label( "Edit Box Source" );

            m_Length2Slider.Deactivate();
            m_Radius2Slider.Deactivate();
        }
    }
    else
    {
        m_LengthSlider.Deactivate();
        m_RadiusSlider.Deactivate();
        m_Length2Slider.Deactivate();
        m_Radius2Slider.Deactivate();
        m_U1Slider.Deactivate();
        m_W1Slider.Deactivate();
        m_U2Slider.Deactivate();
        m_W2Slider.Deactivate();
        m_CfdMeshUI->SourceNameInput->deactivate();
        m_CfdMeshUI->EditSourceTitle->label( "" );
    }

    //==== Load Up Source Browser ====//
    int currSourceID = -1;

    m_CfdMeshUI->sourceBrowser->clear();

    if( currGeom )
    {
        vector< BaseSource* > sVec = currGeom->GetCfdMeshMainSourceVec();
        for ( i = 0 ; i < ( int )sVec.size() ; i++ )
        {
            if ( source == sVec[i] )
            {
                currSourceID = i;
            }
            m_CfdMeshUI->sourceBrowser->add( sVec[i]->GetName().c_str() );
        }
        if ( currSourceID >= 0 && currSourceID < ( int )sVec.size() )
        {
            m_CfdMeshUI->sourceBrowser->select( currSourceID + 1 );
        }

        int nmain = currGeom->GetNumMainSurfs();
        for ( i = 0; i < nmain; i++ )
        {
            char str[256];
            sprintf( str, "Surf_%d", i );
            m_CfdMeshUI->surfChoice->add( str );
        }
        int currMainSurfID = CfdMeshMgr.GetCurrMainSurfIndx();
        if( currMainSurfID >= 0 && currMainSurfID < nmain )
        {
            m_CfdMeshUI->surfChoice->value( currMainSurfID );
        }
    }

    m_DrawMeshButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_DrawMeshFlag.GetID() );
    m_DrawSourceButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_DrawSourceFlag.GetID() );
    m_DrawFarButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_DrawFarFlag.GetID() );
    m_DrawFarPreButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_DrawFarPreFlag.GetID() );
    m_DrawBadButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_DrawBadFlag.GetID() );
    m_DrawSymmButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_DrawSymmFlag.GetID() );
    m_DrawWakeButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_DrawWakeFlag.GetID() );
    m_DrawTagsButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->m_ColorTagsFlag.GetID() );

    if ( CfdMeshMgr.GetCfdSettingsPtr()->GetHalfMeshFlag() )
    {
        m_CfdMeshUI->halfMeshButton->value( 1 );
    }
    else
    {
        m_CfdMeshUI->halfMeshButton->value( 0 );
    }

    if ( CfdMeshMgr.GetGridDensityPtr()->GetRigorLimit() )
    {
        m_CfdMeshUI->rigorLimitButton->value( 1 );
    }
    else
    {
        m_CfdMeshUI->rigorLimitButton->value( 0 );
    }

    string datname = CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileName( vsp::CFD_DAT_FILE_NAME );
    m_CfdMeshUI->datName->value( truncateFileName( datname, 40 ).c_str() );
    string keyname = CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileName( vsp::CFD_KEY_FILE_NAME );
    m_CfdMeshUI->keyName->value( truncateFileName( keyname, 40 ).c_str() );
    string objname = CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileName( vsp::CFD_OBJ_FILE_NAME );
    m_CfdMeshUI->objName->value( truncateFileName( objname, 40 ).c_str() );
    string polyname = CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileName( vsp::CFD_POLY_FILE_NAME );
    m_CfdMeshUI->polyName->value( truncateFileName( polyname, 40 ).c_str() );
    string stlname = CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileName( vsp::CFD_STL_FILE_NAME );
    m_CfdMeshUI->stlName->value( truncateFileName( stlname, 40 ).c_str() );
    string triname = CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileName( vsp::CFD_TRI_FILE_NAME );
    m_CfdMeshUI->triName->value( truncateFileName( triname, 40 ).c_str() );
    string gmshname = CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileName( vsp::CFD_GMSH_FILE_NAME );
    m_CfdMeshUI->gmshName->value( truncateFileName( gmshname, 40 ).c_str() );
    string srfname = CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileName( vsp::CFD_SRF_FILE_NAME );
    m_CfdMeshUI->srfName->value( truncateFileName( srfname, 40 ).c_str() );
    string tkeyname = CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileName( vsp::CFD_TKEY_FILE_NAME );
    m_CfdMeshUI->tkeyName->value( truncateFileName( tkeyname, 40).c_str() );

    //==== Export Flags ====//

    m_DatToggleButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileFlag( vsp::CFD_DAT_FILE_NAME )->GetID() );
    m_KeyToggleButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileFlag( vsp::CFD_KEY_FILE_NAME )->GetID() );
    m_ObjToggleButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileFlag( vsp::CFD_OBJ_FILE_NAME )->GetID() );
    m_PolyToggleButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileFlag( vsp::CFD_POLY_FILE_NAME )->GetID() );
    m_StlToggleButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileFlag( vsp::CFD_STL_FILE_NAME )->GetID() );
    m_StlMultiSolidToggleButton.Update( m_Vehicle->m_STLMultiSolid.GetID() );
    m_TriToggleButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileFlag( vsp::CFD_TRI_FILE_NAME )->GetID() );
    m_GmshToggleButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileFlag( vsp::CFD_GMSH_FILE_NAME )->GetID() );
    m_SrfToggleButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileFlag( vsp::CFD_SRF_FILE_NAME )->GetID() );
    m_TkeyToggleButton.Update( CfdMeshMgr.GetCfdSettingsPtr()->GetExportFileFlag( vsp::CFD_TKEY_FILE_NAME)->GetID() );

    //==== Wake Flag ====//
    if( wakeGeom )
    {
        if ( wakeGeom->GetWakeActiveFlag() )
        {
            m_CfdMeshUI->addWakeButton->value( 1 );
        }
        else
        {
            m_CfdMeshUI->addWakeButton->value( 0 );
        }
    }

    //=== Domain tab GUI active areas ===//
    if ( CfdMeshMgr.GetCfdSettingsPtr()->GetFarMeshFlag() )
    {
        m_CfdMeshUI->farParametersGroup->activate();

        if( CfdMeshMgr.GetCfdSettingsPtr()->GetFarCompFlag() )
        {
            m_CfdMeshUI->farBoxGroup->deactivate();
            m_CfdMeshUI->farCompGroup->activate();
        }
        else
        {
            m_CfdMeshUI->farBoxGroup->activate();
            m_CfdMeshUI->farCompGroup->deactivate();

            if( CfdMeshMgr.GetCfdSettingsPtr()->GetFarManLocFlag() )
            {
                m_CfdMeshUI->farXYZLocationGroup->activate();
            }
            else
            {
                m_CfdMeshUI->farXYZLocationGroup->deactivate();
            }
        }
    }
    else
    {
        m_CfdMeshUI->farParametersGroup->deactivate();
    }

    //=== Domain tab GUI radio & highlight buttons ===//
    if( CfdMeshMgr.GetCfdSettingsPtr()->GetFarMeshFlag() )
    {
        m_CfdMeshUI->farMeshButton->value( 1 );
    }
    else
    {
        m_CfdMeshUI->farMeshButton->value( 0 );
    }

    if( CfdMeshMgr.GetCfdSettingsPtr()->GetFarCompFlag() )
    {
        m_CfdMeshUI->farComponentGenButton->setonly();
    }
    else
    {
        m_CfdMeshUI->farBoxGenButton->setonly();
    }

    if( CfdMeshMgr.GetCfdSettingsPtr()->GetFarAbsSizeFlag() )
    {
        m_CfdMeshUI->farAbsSizeButton->value( 1 );
        m_CfdMeshUI->farRelSizeButton->value( 0 );
    }
    else
    {
        m_CfdMeshUI->farAbsSizeButton->value( 0 );
        m_CfdMeshUI->farRelSizeButton->value( 1 );
    }

    if( CfdMeshMgr.GetCfdSettingsPtr()->GetFarManLocFlag() )
    {
        m_CfdMeshUI->farManLocButton->value( 1 );
        m_CfdMeshUI->farCenLocButton->value( 0 );
    }
    else
    {
        m_CfdMeshUI->farManLocButton->value( 0 );
        m_CfdMeshUI->farCenLocButton->value( 1 );
    }

    return false;
}
示例#4
0
bool FitModelScreen::Update()
{
    int i;
    int index;
    char str[256];

    // Update the number of selected points.
    sprintf( str, "%d", FitModelMgr.GetNumSelected() );
    m_NSelOutput.Update( str );

    m_TargetGeomPicker.Update();

    m_UToggleGroup.Update( FitModelMgr.m_UType.GetID() );
    m_USlider.Update( FitModelMgr.m_UTargetPt.GetID() );

    m_WToggleGroup.Update( FitModelMgr.m_WType.GetID() );
    m_WSlider.Update( FitModelMgr.m_WTargetPt.GetID() );

    m_SelOneButton.Update( FitModelMgr.m_SelectOneFlag.GetID() );
    m_SelBoxButton.Update( FitModelMgr.m_SelectBoxFlag.GetID() );

    // Update Fixed target point browser
    m_TargetPtBrowser->clear();

    static int ptwidths[] = { 75, 35, 35, 35, 35, 37, 35, 38 }; // widths for each column
    m_TargetPtBrowser->column_widths( ptwidths );    // assign array to widget
    m_TargetPtBrowser->column_char( ':' );         // use : as the column character

    sprintf( str, "@[email protected]:@b@[email protected]:@b@[email protected]:@b@[email protected]:@b@[email protected]:@b@[email protected]:@b@[email protected]:@b@[email protected]" );
    m_TargetPtBrowser->add( str );

    int num_fix = FitModelMgr.GetNumTargetPt();
    for ( i = 0 ; i < num_fix ; i++ )
    {
        TargetPt* tpt = FitModelMgr.GetTargetPt( i );
        if( tpt )
        {
            Geom* g = VehicleMgr.GetVehicle()->FindGeom( tpt->GetMatchGeom() );
            if( g )
            {
                char *fix = "fix";
                char *free = "free";

                char *ut;
                char *wt;

                if( tpt->GetUType() == TargetPt::FIXED )
                {
                    ut = fix;
                }
                else
                {
                    ut = free;
                }

                if( tpt->GetWType() == TargetPt::FIXED )
                {
                    wt = fix;
                }
                else
                {
                    wt = free;
                }


                sprintf( str, "%s:%4.2f:%4.2f:%4.2f:%4.2f:%s:%4.2f:%s", g->GetName().c_str(), tpt->GetPt().x(), tpt->GetPt().y(), tpt->GetPt().z(), tpt->GetUW().x(), ut, tpt->GetUW().y(), wt );
                m_TargetPtBrowser->add( str );
            }
        }
    }

    index = FitModelMgr.GetCurrTargetPtIndex();
    if ( index >= 0 && index < num_fix )
    {
        m_TargetPtBrowser->select( index + 2 );
    }

    sprintf( str, "%d", num_fix );
    m_NTgtOutput.Update( str );

    // Check that all Parms exist.  Needed in case a Geom with DesVars is
    // deleted.
    FitModelMgr.CheckVars();

    // Re-sort DesVars.  Needed in case a Geom's name is changed.
    if ( !FitModelMgr.SortVars() )
    {
        RebuildAdjustTab();
    }

    //==== Update Parm Picker ====//
    m_ParmPicker.Update();

    //==== Update Parm Tree Picker ====//
    m_ParmTreePicker.Update( FitModelMgr.GetVarVec() );

    //==== Update Parm Browser ====//
    varBrowser->clear();

    static int widths[] = { 75, 75, 90 }; // widths for each column
    varBrowser->column_widths( widths );    // assign array to widget
    varBrowser->column_char( ':' );         // use : as the column character

    sprintf( str, "@[email protected]_A:@[email protected]:@[email protected]" );
    varBrowser->add( str );

    int num_vars = FitModelMgr.GetNumVars();
    for ( i = 0 ; i < num_vars ; i++ )
    {
        string c_name, g_name, p_name;
        ParmMgr.GetNames( FitModelMgr.GetVar( i ), c_name, g_name, p_name );

        sprintf( str, "%s:%s:%s", c_name.c_str(), g_name.c_str(), p_name.c_str() );
        varBrowser->add( str );
    }

    index = FitModelMgr.GetCurrVarIndex();
    if ( index >= 0 && index < num_vars )
    {
        varBrowser->select( index + 2 );
    }

    sprintf( str, "%d", num_vars );
    m_NVarOutput.Update( str );

    // Parameter GUI got out of sync.  Probably from File->New or similar.
    if ( m_NVarLast != num_vars )
    {
        RebuildAdjustTab();
    }

    //==== Update Parm Adjust Tab ====//
    for ( int i = 0 ; i < num_vars ; i++ )
    {
        m_ParmSliderVec[i].Update( FitModelMgr.GetVar( i ) );
    }

    FitModelMgr.UpdateNumOptVars();
    sprintf( str, "%d", FitModelMgr.GetNumOptVars() );
    m_DOFOutput.Update( str );
    sprintf( str, "%d", num_fix * 3 );
    m_CondOutput.Update( str );

    m_DistOutput.Update( std::to_string( static_cast<long double> (FitModelMgr.m_DistMetric) ) );

    //===== Save/Load =====//
    m_SaveOutput.Update( truncateFileName( FitModelMgr.GetSaveFitFileName(), 40 ) );
    m_LoadOutput.Update( truncateFileName( FitModelMgr.GetLoadFitFileName(), 40 ) );

    if ( m_SaveOutput.GetString() == "" )
    {
        m_Save.Deactivate();
    }
    else
    {
        m_Save.Activate();
    }
    if ( m_LoadOutput.GetString() == "" )
    {
        m_Load.Deactivate();
    }
    else
    {
        m_Load.Activate();
    }

    m_FLTK_Window->redraw();

    return false;
}
示例#5
0
void FeaStructScreen::update()
{
	char str[256];

	//==== Default Elem Size ====//
	m_DefEdgeSlider->SetVal( feaMeshMgrPtr->GetDefElemSize() );
	m_DefEdgeSlider->UpdateGui();

	m_ThickScaleSlider->SetVal( feaMeshMgrPtr->GetThickScale() );
	m_ThickScaleSlider->UpdateGui();

	//==== SectID ====//
	sprintf( str, "        %d ", feaMeshMgrPtr->GetCurrSectID() );
	feaStructUI->sectIDInput->value(str);

	//==== Spar Rib ID ====//
	sprintf( str, "        %d ", feaMeshMgrPtr->GetCurrSparID() );
	if ( feaMeshMgrPtr->GetNumSpars() == 0 )		
		sprintf( str, " " );
	feaStructUI->sparIDInput->value(str);

	sprintf( str, "        %d ", feaMeshMgrPtr->GetCurrRibID() );
	if ( feaMeshMgrPtr->GetNumRibs() == 0 )		
		sprintf( str, " " );
	feaStructUI->ribIDInput->value(str);

	FeaRib* rib = feaMeshMgrPtr->GetCurrRib();
	if ( rib )
	{
		feaStructUI->ribEditGroup->show();
		m_RibThickSlider->SetVal( rib->m_Thick );
		m_RibThickSlider->UpdateGui();

		m_RibDensitySlider->SetVal( rib->GetDensity() );
		m_RibDensitySlider->UpdateGui();

		m_RibPosSlider->SetVal( rib->m_PerSpan );
		m_RibPosSlider->UpdateGui();

		m_RibSweepSlider->SetVal( rib->m_Sweep );
		m_RibSweepSlider->UpdateGui();

		if ( rib->m_AbsSweepFlag )
		{
			feaStructUI->ribSweepAbsButton->value(1);
			feaStructUI->ribSweepRelButton->value(0);
		}
		else
		{
			feaStructUI->ribSweepAbsButton->value(0);
			feaStructUI->ribSweepRelButton->value(1);
		}
		if ( rib->m_TrimFlag )
			feaStructUI->trimRibButton->value(1);
		else
			feaStructUI->trimRibButton->value(0);
	}
	else
	{
		feaStructUI->ribEditGroup->hide();
	}


	FeaSpar* spar = feaMeshMgrPtr->GetCurrSpar();
	if ( spar )
	{
		feaStructUI->sparEditGroup->show();
		m_SparThickSlider->SetVal( spar->m_Thick );
		m_SparThickSlider->UpdateGui();

		m_SparDensitySlider->SetVal( spar->GetDensity() );
		m_SparDensitySlider->UpdateGui();

		m_SparPosSlider->SetVal( spar->m_PerChord );
		m_SparPosSlider->UpdateGui();

		m_SparSweepSlider->SetVal( spar->m_Sweep );
		m_SparSweepSlider->UpdateGui();

		if ( spar->m_AbsSweepFlag )
		{
			feaStructUI->sparSweepAbsButton->value(1);
			feaStructUI->sparSweepRelButton->value(0);
		}
		else
		{
			feaStructUI->sparSweepAbsButton->value(0);
			feaStructUI->sparSweepRelButton->value(1);
		}
		if ( spar->m_TrimFlag )
			feaStructUI->trimSparButton->value(1);
		else
			feaStructUI->trimSparButton->value(0);
	}
	else
	{
		feaStructUI->sparEditGroup->hide();
	}

	//===== Upper Skin ====//
	FeaSkin* upskin = feaMeshMgrPtr->GetCurrUpperSkin();
	if ( upskin && upskin->GetExportFlag() )
	{
		feaStructUI->upperSkinEditGroup->show();
		feaStructUI->upSkinExportNoButton->value(0);
		feaStructUI->upSkinExportYesButton->value(1);

		m_UpDefThickSlider->SetVal( upskin->GetDefaultThick() );
		m_UpDefThickSlider->UpdateGui();

		m_UpDensitySlider->SetVal( upskin->GetDensity() );
		m_UpDensitySlider->UpdateGui();

		FeaSpliceLine* sl = upskin->GetCurrSpliceLine();
		if ( sl )
		{
			m_UpSpliceLineLocSlider->SetVal( sl->m_PerSpan );
			m_UpSpliceLineLocSlider->UpdateGui();

			FeaSplice* splice = sl->GetEditSplice();
			if ( splice )
			{
				m_UpSpliceLocSlider->SetVal( splice->m_Pos );
				m_UpSpliceLocSlider->UpdateGui();
				m_UpSpliceThickSlider->SetVal( splice->m_Thick );
				m_UpSpliceThickSlider->UpdateGui();
			}
		}
	
		//==== Splice Line ID ====//
		sprintf( str, "        %d ", upskin->GetCurrSpliceLineID() );
		if ( (int)upskin->m_SpliceLineVec.size() == 0 )		
			sprintf( str, " " );
		feaStructUI->upSpliceLineIDInput->value(str);
	}
	else
	{
		feaStructUI->upperSkinEditGroup->hide();
		feaStructUI->upSkinExportNoButton->value(1);
		feaStructUI->upSkinExportYesButton->value(0);
		feaStructUI->upSpliceLineIDInput->value("");
	}

	m_UpSkinGLWin->setDrawBase( NULL );
	if ( upskin )
	{
		FeaSpliceLine* sl = upskin->GetCurrSpliceLine();
		if ( sl )
		{
			m_UpSkinGLWin->setDrawBase( sl );

			if ( sl->GetMode() == FeaSpliceLine::ADD_MODE )
				feaStructUI->upSkinAddSpliceButton->value(1);
			else
				feaStructUI->upSkinAddSpliceButton->value(0);
				
			if ( sl->GetMode() == FeaSpliceLine::DEL_MODE )
				feaStructUI->upSkinDelSpliceButton->value(1);
			else
				feaStructUI->upSkinDelSpliceButton->value(0);
		}
	}
	m_UpSkinGLWin->redraw();

	//===== Lower Skin ====//
	FeaSkin* lowskin = feaMeshMgrPtr->GetCurrLowerSkin();
	if ( lowskin && lowskin->GetExportFlag() )
	{
		feaStructUI->lowerSkinEditGroup->show();
		feaStructUI->lowSkinExportNoButton->value(0);
		feaStructUI->lowSkinExportYesButton->value(1);

		m_LowDefThickSlider->SetVal( lowskin->GetDefaultThick() );
		m_LowDefThickSlider->UpdateGui();

		m_LowDensitySlider->SetVal( lowskin->GetDensity() );
		m_LowDensitySlider->UpdateGui();

		FeaSpliceLine* sl = lowskin->GetCurrSpliceLine();
		if ( sl )
		{
			m_LowSpliceLineLocSlider->SetVal( sl->m_PerSpan );
			m_LowSpliceLineLocSlider->UpdateGui();

			FeaSplice* splice = sl->GetEditSplice();
			if ( splice )
			{
				m_LowSpliceLocSlider->SetVal( splice->m_Pos );
				m_LowSpliceLocSlider->UpdateGui();
				m_LowSpliceThickSlider->SetVal( splice->m_Thick );
				m_LowSpliceThickSlider->UpdateGui();
			}
		}
	
		//==== Splice Line ID ====//
		sprintf( str, "        %d ", lowskin->GetCurrSpliceLineID() );
		if ( (int)lowskin->m_SpliceLineVec.size() == 0 )		
			sprintf( str, " " );
		feaStructUI->lowSpliceLineIDInput->value(str);
	}
	else
	{
		feaStructUI->lowerSkinEditGroup->hide();
		feaStructUI->lowSkinExportNoButton->value(1);
		feaStructUI->lowSkinExportYesButton->value(0);
		feaStructUI->lowSpliceLineIDInput->value("");
	}

	m_LowSkinGLWin->setDrawBase( NULL );
	if ( lowskin )
	{
		FeaSpliceLine* sl = lowskin->GetCurrSpliceLine();
		if ( sl )
		{
			m_LowSkinGLWin->setDrawBase( sl );

			if ( sl->GetMode() == FeaSpliceLine::ADD_MODE )
				feaStructUI->lowSkinAddSpliceButton->value(1);
			else
				feaStructUI->lowSkinAddSpliceButton->value(0);
				
			if ( sl->GetMode() == FeaSpliceLine::DEL_MODE )
				feaStructUI->lowSkinDelSpliceButton->value(1);
			else
				feaStructUI->lowSkinDelSpliceButton->value(0);
		}
	}
	m_LowSkinGLWin->redraw();


	//==== Point Mass ====//
	FeaPointMass* pmass = feaMeshMgrPtr->GetCurrPointMass();
	if ( pmass )
	{
		feaStructUI->ptMassEditGroup->show();
		m_pmXPosSlider->SetVal( pmass->m_Pos.x() );
		m_pmYPosSlider->SetVal( pmass->m_Pos.y() );
		m_pmZPosSlider->SetVal( pmass->m_Pos.z() );
		m_pmXPosSlider->UpdateGui();
		m_pmYPosSlider->UpdateGui();
		m_pmZPosSlider->UpdateGui();

		//==== Point Mass ID ====//
		sprintf( str, "        %d ", feaMeshMgrPtr->GetCurrPointMassID() );
		if ( feaMeshMgrPtr->GetNumPointMasses() == 0 )		
			sprintf( str, " " );
		feaStructUI->ptMassIDInput->value(str);

		sprintf( str, "%f", pmass->m_AttachPos.x() );
		feaStructUI->XAttachInput->value( str );
		sprintf( str, "%f", pmass->m_AttachPos.y() );
		feaStructUI->YAttachInput->value( str );
		sprintf( str, "%f", pmass->m_AttachPos.z() );
		feaStructUI->ZAttachInput->value( str );
	}
	else
	{
		feaStructUI->ptMassEditGroup->hide();
		feaStructUI->ptMassIDInput->value("");
	}

	if ( feaMeshMgrPtr->GetDrawAttachPointsFlag() )
		feaStructUI->moveAttachPointButton->value( 1 );
	else
		feaStructUI->moveAttachPointButton->value( 0 );

	Stringc massname = feaMeshMgrPtr->GetFeaExportFileName( FeaMeshMgr::MASS_FILE_NAME );
	feaStructUI->massName->value( truncateFileName(massname, 40 ) );
	Stringc nastranname = feaMeshMgrPtr->GetFeaExportFileName( FeaMeshMgr::NASTRAN_FILE_NAME );
	feaStructUI->nastranName->value( truncateFileName(nastranname, 40 ) );
	Stringc geomname = feaMeshMgrPtr->GetFeaExportFileName( FeaMeshMgr::GEOM_FILE_NAME );
	feaStructUI->geomName->value( truncateFileName(geomname, 40 ) );
	Stringc thickname = feaMeshMgrPtr->GetFeaExportFileName( FeaMeshMgr::THICK_FILE_NAME );
	feaStructUI->thickName->value( truncateFileName(thickname, 40 ) );
	Stringc stlname = feaMeshMgrPtr->GetFeaExportFileName( FeaMeshMgr::STL_FEA_NAME );
	feaStructUI->stlName->value( truncateFileName(stlname, 40 ) );

}