Commit aa51c05d authored by stambaughw's avatar stambaughw
Browse files

CVPcb code refactoring, global variable elimination, and UI updates.

* Add methods to read and write project file parameters using dynamically defined list.
* Remove all global variables defined in CVPcb code.
* Dynamically define project file settings so class member variables can be used.
* Separate reading and writing application settings from project file settings.
* Make application UI objects and dialogs respect system UI font.
* Remove non-standard widget colors from CVPcb dialogs.
* Changed CVPcb object link list implementation to use wxList.
* Changed project library and path dialog to make OK button save project file instead of confusing "Save Cfg" button.
* Eliminate some duplicate file wildcard and extension definitions.
* The usual code reformatting, commenting, and spelling fixes.
parent bd3b4baa
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ const wxString SchematicFileExtension( wxT( "sch" ) );
const wxString BoardFileExtension( wxT( "brd" ) );
const wxString NetlistFileExtension( wxT( "net" ) );
const wxString GerberFileExtension( wxT( "pho" ) );
const wxString PdfFileExtension( wxT( "pdf" ) );

/* Proper wxFileDialog wild card definitions. */
const wxString ProjectFileWildcard( _( "Kicad project files (*.pro)|*.pro" ) );
@@ -60,6 +61,7 @@ const wxString BoardFileWildcard( _( "Kicad PCB files (*.brd)|*.brd") );
const wxString SchematicFileWildcard( _( "Kicad schematic files (*.sch)|*.sch" ) );
const wxString NetlistFileWildcard( _( "Kicad netlist files (*.net)|*.net" ) );
const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) );
const wxString PdfFileWildcard( _( "Portable document format files (*.pdf)|*.pdf" ) );
const wxString AllFilesWildcard( _( "All files (*)|*") );


+1 −1
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ bool GetAssociatedDocument( wxFrame* aFrame,
    if( !wxFileExists( fullfilename ) )
    {
        msg = _( "Doc File " );
        msg << wxT("\"") << fullfilename << wxT("\"") << _( " not found" );
        msg << wxT("\"") << aDocName << wxT("\"") << _( " not found" );
        DisplayError( aFrame, msg );
        return FALSE;
    }
+110 −0
Original line number Diff line number Diff line
@@ -179,6 +179,62 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName,
    m_ProjectConfig = NULL;
}


void WinEDA_App::WriteProjectConfig( const wxString&  fileName,
                                     const wxString&  GroupName,
                                     const PARAM_CFG_ARRAY& params )
{
    PARAM_CFG_BASE* param;
    wxString        msg;
    size_t          i;

    ReCreatePrjConfig( fileName, GroupName, FORCE_LOCAL_CONFIG );

    /* Write date ( surtout pour eviter bug de wxFileConfig
     * qui se trompe de rubrique si declaration [xx] en premiere ligne
     * (en fait si groupe vide) */
    m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR );

    msg = DateAndTime();
    m_ProjectConfig->Write( wxT( "update" ), msg );

    msg = GetAppName();
    m_ProjectConfig->Write( wxT( "last_client" ), msg );

    /* Save parameters */
    m_ProjectConfig->DeleteGroup( GroupName );   // Erase all datas
    m_ProjectConfig->Flush();

    m_ProjectConfig->SetPath( GroupName );
    m_ProjectConfig->Write( wxT( "version" ), CONFIG_VERSION );
    m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR );

    for( i = 0; i < params.GetCount(); i++ )
    {
        param = &params[i];
        if( param->m_Group )
            m_ProjectConfig->SetPath( param->m_Group );
        else
            m_ProjectConfig->SetPath( GroupName );

        if( param->m_Setup )
            continue;

        if ( param->m_Type == PARAM_COMMAND_ERASE )    // Erase all data
        {
            if( param->m_Ident )
                m_ProjectConfig->DeleteGroup( param->m_Ident );
        }
        else
            param->SaveParam( m_ProjectConfig );
    }

    m_ProjectConfig->SetPath( UNIX_STRING_DIR_SEP );
    delete m_ProjectConfig;
    m_ProjectConfig = NULL;
}


/*****************************************************************/
void WinEDA_App::SaveCurrentSetupValues( PARAM_CFG_BASE** aList )
/*****************************************************************/
@@ -277,6 +333,60 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename,
}


bool WinEDA_App::ReadProjectConfig( const wxString&        local_config_filename,
                                    const wxString&        GroupName,
                                    const PARAM_CFG_ARRAY& params,
                                    bool                   Load_Only_if_New )
{
    size_t          i;
    PARAM_CFG_BASE* param;
    wxString        timestamp;

    ReCreatePrjConfig( local_config_filename, GroupName, false );

    m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR );
    timestamp = m_ProjectConfig->Read( wxT( "update" ) );
    if( Load_Only_if_New && ( !timestamp.IsEmpty() )
       && (timestamp == m_CurrentOptionFileDateAndTime) )
    {
        return false;
    }

    m_CurrentOptionFileDateAndTime = timestamp;

    if( !g_Prj_Default_Config_FullFilename.IsEmpty() )
        m_CurrentOptionFile = g_Prj_Default_Config_FullFilename;
    else
    {
        if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() )
            m_CurrentOptionFile = wxGetCwd() + STRING_DIR_SEP +
                g_Prj_Config_LocalFilename;
        else
            m_CurrentOptionFile = g_Prj_Config_LocalFilename;
    }

    for( i = 0; i < params.GetCount(); i++ )
    {
        param = &params[i];

        if( param->m_Group )
            m_ProjectConfig->SetPath( param->m_Group );
        else
            m_ProjectConfig->SetPath( GroupName );

        if( param->m_Setup )
            continue;

        param->ReadParam( m_ProjectConfig );
    }

    delete m_ProjectConfig;
    m_ProjectConfig = NULL;

    return true;
}


/***************************************************************/
void WinEDA_App::ReadCurrentSetupValues( PARAM_CFG_BASE** aList )
/***************************************************************/
+0 −1
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent,

    m_Title = new wxStaticText( parent, -1, Title );

    m_Title->SetForegroundColour( wxColour( 200, 0, 0 ) );
    BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );

    m_FrameText = new   wxTextCtrl( parent, -1, TextToEdit, wxDefaultPosition, Size );
+1 −13
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ set(CVPCB_SRCS
    listboxes.cpp
    listlib.cpp
    loadcmp.cpp
    memoire.cpp
    menucfg.cpp
    readschematicnetlist.cpp
    savecmp.cpp
@@ -29,17 +28,6 @@ set(CVPCB_SRCS
    tool_cvpcb.cpp
    writenetlistpcbnew.cpp)

set(CVPCB_EXTRA_SRCS
#    ../pcbnew/class_board_item.cpp
#    ../pcbnew/class_drawsegment.cpp
#    ../pcbnew/class_edge_mod.cpp
#    ../pcbnew/class_equipot.cpp
#    ../pcbnew/class_module.cpp
#    ../pcbnew/class_text_mod.cpp
    ../pcbnew/ioascii.cpp
#    ../pcbnew/tracemod.cpp
)

if(WIN32)
    if(MINGW)
        # CVPCB_RESOURCES variable is set by the macro.
@@ -58,7 +46,7 @@ if(APPLE)
    set(MACOSX_BUNDLE_NAME cvpcb)
endif(APPLE)

add_executable(cvpcb WIN32 MACOSX_BUNDLE ${CVPCB_SRCS} ${CVPCB_EXTRA_SRCS} ${CVPCB_RESOURCES})
add_executable(cvpcb WIN32 MACOSX_BUNDLE ${CVPCB_SRCS} ${CVPCB_RESOURCES})

target_link_libraries(cvpcb 3d-viewer common pcbcommon polygon bitmaps kbool ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES})

Loading