Commit c58c388a authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Add PCBNew setting to remember last net list read and other minor fixes.

* PCBNew remembers last net list read during the current editing session
  as well as between project editing sessions.  Closes bug 576902.
* Separate PCBNew application settings from project file settings and
  allocate them dynamically instead of statically to make it easier to
  eliminate global variables.
parent 5849675a
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -78,8 +78,9 @@ GerbView
* Add excellon2 drill file support (small good library)
* Fix the polygon bug.
* Switch to use ZONE instead of SEGZONE for polygons.


* Separate application settings and project configuration settings by converting
  static list of parameters in gerbview_config.h to dynamically created lists of
  settings.  See eeschema/eeschema_config.cpp for an example.



+72 −38
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@

#include "wxstruct.h"
#include "base_struct.h"
#include "param_config.h"

#ifndef PCB_INTERNAL_UNIT
#define PCB_INTERNAL_UNIT 10000
@@ -39,8 +40,7 @@ class PCB_LAYER_WIDGET;


/**
 * @info see also class WinEDA_BasePcbFrame: Basic class for pcbnew and
 *gerbview
 * @info see also class WinEDA_BasePcbFrame: Basic class for pcbnew and gerbview.
 */


@@ -57,6 +57,11 @@ protected:

    DRC* m_drc;                     ///< the DRC controller, see drc.cpp

    PARAM_CFG_ARRAY   m_projectFileParams;   ///< List of PCBNew project file settings.
    PARAM_CFG_ARRAY   m_configSettings;      ///< List of PCBNew configuration settings.

    wxString          m_lastNetListRead;     ///< Last net list read with relative path.

    // we'll use lower case function names for private member functions.
    void createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu );
    void createPopUpMenuForFootprints( MODULE* aModule, wxMenu* aPopMenu );
@@ -168,7 +173,7 @@ public:

    /** Function SetGridVisibility() , virtual
     * It may be overloaded by derived classes
     * if you want to store/retrieve the grid visiblity in configuration.
     * if you want to store/retrieve the grid visibility in configuration.
     * @param aVisible = true if the grid must be shown
     */
    virtual void     SetGridVisibility(bool aVisible);
@@ -186,16 +191,67 @@ public:
    // Configurations:
    void             InstallConfigFrame( const wxPoint& pos );
    void             Process_Config( wxCommandEvent& event );
    void             Update_config( wxWindow* displayframe );

    /** Function Read_Config
     * Read the project configuration file
     * @param projectFileName = the config filename
     *  if not found use kicad.pro
     *  if not found : initialize default values
     * @return true if the current config is modified, false if no change
    PARAM_CFG_ARRAY& GetProjectFileParameters();
    void             SaveProjectSettings();

    /**
     * Load the project file configuration settings.
     *
     * @param aProjectFileName = The project filename.
     *  if not found use kicad.pro and initialize default values
     * @return always returns true.
     */
    bool             LoadProjectSettings( const wxString& aProjectFileName );

    /**
     * Get the list of application specific settings.
     *
     * @return - Reference to the list of applications settings.
     */
    PARAM_CFG_ARRAY& GetConfigurationSettings();

    /**
     * Load applications settings specific to PCBNew.
     *
     * This overrides the base class WinEDA_BasePcbFrame::LoadSettings() to
     * handle settings specific common to the PCB layout application.  It
     * calls down to the base class to load settings common to all PCB type
     * drawing frames.  Please put your application settings for PCBNew here
     * to avoid having application settings loaded all over the place.
     */
    virtual void LoadSettings();

    /**
     * Save applications settings common to PCBNew.
     *
     * This overrides the base class WinEDA_BasePcbFrame::SaveSettings() to
     * save settings specific to the PCB layout application main window.  It
     * calls down to the base class to save settings common to all PCB type
     * drawing frames.  Please put your application settings for PCBNew here
     * to avoid having application settings saved all over the place.
     */
    virtual void SaveSettings();

    /**
     * Get the last net list read with the net list dialog box.
     *
     * @return - Absolute path and file name of the last net list file successfully read.
     */
    bool             Read_Config( const wxString& projectFileName );
    wxString         GetLastNetListRead();

    /**
     * Set the last net list successfully read by the net list dialog box.
     *
     * Note: the file path is converted to a path relative to the project file path.  If
     *       the path cannot be made relative, than m_lastNetListRead is set to and empty
     *       string.  This could happen when the net list file is on a different drive than
     *       the project file.  The advantage of relative paths is that is more likely to
     *       work when opening the same project from both Windows and Linux.
     *
     * @param aNetListFile - The last net list file with full path successfully read.
     */
    void             SetLastNetListRead( const wxString& aNetListFile );

    void             OnHotKey( wxDC*           DC,
                               int             hotkey,
@@ -287,7 +343,7 @@ public:
     * Function OnRightClick
     * populates a popup menu with the choices appropriate for the current
     *context.
     * The caller will add the ZOOM menu choices afterwards.
     * The caller will add the ZOOM menu choices afterward.
     * @param aMousePos The current mouse position
     * @param aPopMenu The menu to add to.
     */
@@ -331,7 +387,7 @@ public:
     * @param aRedoCommand = a bool: true for redo, false for undo
     * @param aRebuildRatsnet = a bool: true to rebuild ratsnet (normal use),
     *                          false
     * to just retrieve las state (used in abort commands that do not need to
     * to just retrieve last state (used in abort commands that do not need to
     * rebuild ratsnest)
     */
    void PutDataInPreviousState( PICKED_ITEMS_LIST* aList,
@@ -420,7 +476,7 @@ public:

    void SetToolbars();
    void Process_Settings( wxCommandEvent& event );
    void InstallPcbOptionsFrame( int id );
    void OnConfigurePcbOptions( wxCommandEvent& aEvent );
    void InstallDisplayOptionsDialog( wxCommandEvent& aEvent );
    void InstallPcbGlobalDeleteFrame( const wxPoint& pos );

@@ -963,28 +1019,6 @@ public:
    void         Begin_Self( wxDC* DC );
    MODULE*      Genere_Self( wxDC* DC );

    /**
     * Load applications settings specific to the PCBNew.
     *
     * This overrides the base class WinEDA_BasePcbFrame::LoadSettings() to
     * handle settings specific common to the PCB layout application.  It
     * calls down to the base class to load settings common to all PCB type
     * drawing frames.  Please put your application settings for PCBNew here
     * to avoid having application settings loaded all over the place.
     */
    virtual void LoadSettings();

    /**
     * Save applications settings common to PCB draw frame objects.
     *
     * This overrides the base class WinEDA_BasePcbFrame::SaveSettings() to
     * save settings specific to the PCB layout application main window.  It
     * calls down to the base class to save settings common to all PCB type
     * drawing frames.  Please put your application settings for PCBNew here
     * to avoid having application settings saved all over the place.
     */
    virtual void SaveSettings();

    /** function SetLanguage
     * called on a language menu selection
     */
+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event )
    g_MagneticPadOption   = m_MagneticPadOptCtrl->GetSelection();
    g_MagneticTrackOption = m_MagneticTrackOptCtrl->GetSelection();

    EndModal( 1 );
    EndModal( wxID_OK );
}


+5 −15
Original line number Diff line number Diff line
@@ -16,21 +16,11 @@
extern int g_DrawDefaultLineThickness;


void WinEDA_PcbFrame::InstallPcbOptionsFrame( int id )
{
    switch( id )
    {
    case ID_PCB_DRAWINGS_WIDTHS_SETUP:
void WinEDA_PcbFrame::OnConfigurePcbOptions( wxCommandEvent& aEvent )
{
    DIALOG_GRAPHIC_ITEMS_OPTIONS dlg( this );
        dlg.ShowModal();
    }
    break;

    default:
        wxMessageBox( wxT( "InstallPcbOptionsFrame() id error" ) );
        break;
    }
    dlg.ShowModal();
}


@@ -143,7 +133,7 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::OnOkClick( wxCommandEvent& event )
    if( g_DrawDefaultLineThickness < 0 )
        g_DrawDefaultLineThickness = 0;

    EndModal( 1 );
    EndModal( wxID_OK );
}


+40 −22
Original line number Diff line number Diff line
@@ -18,14 +18,18 @@ extern void TestFor_Duplicate_Missing_And_Extra_Footprints( wxWindow* fram



/*************************************************************************/
void WinEDA_PcbFrame::InstallNetlistFrame( wxDC* DC, const wxPoint& pos )
/*************************************************************************/
{
    /* Setup the default netlist file name according to the board file name */
    wxFileName fn = GetScreen()->m_FileName;
    /* Setup the netlist file name to the last net list file read or the board file
     * name if no last file read is not set.
     */
    wxFileName fn = GetLastNetListRead();

    if( !fn.FileExists() )
    {
        fn = GetScreen()->m_FileName;
        fn.SetExt( NetExtBuffer );
    }

    DIALOG_NETLIST frame( this, DC, fn.GetFullPath() );

@@ -33,7 +37,8 @@ void WinEDA_PcbFrame::InstallNetlistFrame( wxDC* DC, const wxPoint& pos )
}


DIALOG_NETLIST::DIALOG_NETLIST( WinEDA_PcbFrame* aParent, wxDC * aDC, const wxString & aNetlistFull_Filename )
DIALOG_NETLIST::DIALOG_NETLIST( WinEDA_PcbFrame* aParent, wxDC * aDC,
                                const wxString & aNetlistFull_Filename )
    : DIALOG_NETLIST_FBP( aParent )
{
    m_Parent = aParent;
@@ -54,18 +59,30 @@ void DIALOG_NETLIST::Init()

void DIALOG_NETLIST::OnOpenNelistClick( wxCommandEvent& event )
{
    wxString fullfilename;
    wxString lastPath = wxFileName::GetCwd();
    wxString lastNetlistRead = m_Parent->GetLastNetListRead();

    if( !lastNetlistRead.IsEmpty() && !wxFileName::FileExists( lastNetlistRead ) )
    {
        lastNetlistRead = wxEmptyString;
    }
    else
    {
        wxFileName fn = lastNetlistRead;
        lastPath = fn.GetPath();
        lastNetlistRead = fn.GetName();
    }

    wxFileDialog FilesDialog( this, _( "Netlist Selection:" ), wxGetCwd(),
                              wxEmptyString, NetlistFileWildcard,
                              wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );
    wxLogDebug( wxT( "Last net list read path <%s>, file name <%s>." ),
                GetChars( lastPath ), GetChars( lastNetlistRead ) );

    wxFileDialog FilesDialog( this, _( "Select Netlist" ), lastPath, lastNetlistRead,
                              NetlistFileWildcard, wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );

    if( FilesDialog.ShowModal() != wxID_OK )
        return;

    fullfilename = FilesDialog.GetPath( );

    m_NetlistFilenameCtrl->SetValue( fullfilename );
    m_NetlistFilenameCtrl->SetValue( FilesDialog.GetPath() );
}


@@ -85,7 +102,8 @@ void DIALOG_NETLIST::OnReadNetlistFileClick( wxCommandEvent& event )

void DIALOG_NETLIST::OnTestFootprintsClick( wxCommandEvent& event )
{
    TestFor_Duplicate_Missing_And_Extra_Footprints( this, m_NetlistFilenameCtrl->GetValue(), m_Parent->GetBoard() );
    TestFor_Duplicate_Missing_And_Extra_Footprints( this, m_NetlistFilenameCtrl->GetValue(),
                                                    m_Parent->GetBoard() );
}


Loading