Commit 70569edb authored by Wayne Stambaugh's avatar Wayne Stambaugh

Pcbnew auto save improvements.

* Factor auto save common code into base frame class so all frame windows
  can take advantage of the shiny new auto save goodness.
* Use a timer instead of depending on mouse and keyboard events to trigger
  an auto save.
* Check for auto save file when opening a board and ask user if they
  wish to use the auto save file or the last saved board file.
* Protect all base frame public members.
parent 0dff6b9b
/********************/
/* 3d_toolbar.cpp */
/********************/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_toolbar.cpp
*/
#include "fctsys.h"
......@@ -105,10 +130,9 @@ void EDA_3D_FRAME::ReCreateMenuBar()
{
bool full_options = true;
// If called from the display frame of cvpcb, only some options are
// relevant
if( m_Parent->m_FrameName == wxT( "CmpFrame" ) )
// Called from cvpcb: do not display all options
// If called from the display frame of CvPcb, only some options are relevant
if( m_Parent->GetName() == wxT( "CmpFrame" ) )
// Called from CvPcb: do not display all options
full_options = false;
wxMenuBar* menuBar = new wxMenuBar;
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* EDA_BASE_FRAME Class Functions
* @file basicframe.cpp
* @brief EDA_BASE_FRAME class implementation.
*/
#include <wx/aboutdlg.h>
......@@ -20,9 +45,13 @@
#include "macros.h"
/*
* Class constructor for EDA_BASE_FRAME general options
*/
/// The default auto save interval is 10 minutes.
#define DEFAULT_AUTO_SAVE_INTERVAL 600
static const wxChar* entryAutoSaveInterval = wxT( "AutoSaveInterval" );
EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* father,
int idtype,
const wxString& title,
......@@ -33,9 +62,13 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* father,
{
wxSize minsize;
m_Ident = idtype;
m_HToolBar = NULL;
m_FrameIsActive = TRUE;
m_Ident = idtype;
m_HToolBar = NULL;
m_FrameIsActive = true;
m_hasAutoSave = false;
m_autoSaveState = false;
m_autoSaveInterval = -1;
m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
m_MsgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight();
......@@ -48,15 +81,17 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* father,
SetSize( 0, 0, minsize.x, minsize.y );
// Create child subwindows.
GetClientSize( &m_FrameSize.x, &m_FrameSize.y ); /* dimensions of the user
* area of the main
GetClientSize( &m_FrameSize.x, &m_FrameSize.y ); /* dimensions of the user area of the main
* window */
m_FramePos.x = m_FramePos.y = 0;
m_FramePos.x = m_FramePos.y = 0;
m_FrameSize.y -= m_MsgFrameHeight;
Connect( ID_HELP_COPY_VERSION_STRING,
wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( EDA_BASE_FRAME::CopyVersionInfoToClipboard ) );
Connect( ID_AUTO_SAVE_TIMER, wxEVT_TIMER,
wxTimerEventHandler( EDA_BASE_FRAME::onAutoSaveTimer ) );
}
......@@ -64,8 +99,11 @@ EDA_BASE_FRAME::~EDA_BASE_FRAME()
{
if( wxGetApp().m_HtmlCtrl )
delete wxGetApp().m_HtmlCtrl;
wxGetApp().m_HtmlCtrl = NULL;
delete m_autoSaveTimer;
/* This needed for OSX: avoids further OnDraw processing after this
* destructor and before the native window is destroyed
*/
......@@ -73,19 +111,47 @@ EDA_BASE_FRAME::~EDA_BASE_FRAME()
}
/*
* Virtual function
*/
void EDA_BASE_FRAME::ReCreateMenuBar()
bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
{
if( !wxFrame::ProcessEvent( aEvent ) )
return false;
if( m_hasAutoSave && (m_autoSaveState != isModified()) && (m_autoSaveInterval > 0) )
{
if( !m_autoSaveState )
{
m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
m_autoSaveState = true;
}
else
{
m_autoSaveTimer->Stop();
m_autoSaveState = false;
}
}
return true;
}
void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
{
if( !doAutoSave() )
m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
}
bool EDA_BASE_FRAME::doAutoSave()
{
wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
}
/**
* Function SetLanguage (virtual)
* called on a language menu selection
* when using a derived function, do not forget to call this one
*/
void EDA_BASE_FRAME::ReCreateMenuBar()
{
}
void EDA_BASE_FRAME::SetLanguage( wxCommandEvent& event )
{
int id = event.GetId();
......@@ -97,13 +163,6 @@ void EDA_BASE_FRAME::SetLanguage( wxCommandEvent& event )
}
/**
* Load common frame parameters from configuration.
*
* The method is virtual so you can override it to load frame specific
* parameters. Don't forget to call the base method or your frames won't
* remember their positions and sizes.
*/
void EDA_BASE_FRAME::LoadSettings()
{
wxString text;
......@@ -113,6 +172,7 @@ void EDA_BASE_FRAME::LoadSettings()
config = wxGetApp().m_EDA_Config;
int maximized = 0;
if( config )
{
text = m_FrameName + wxT( "Pos_x" );
......@@ -125,6 +185,12 @@ void EDA_BASE_FRAME::LoadSettings()
config->Read( text, &m_FrameSize.y, 400 );
text = m_FrameName + wxT( "Maximized" );
config->Read( text, &maximized, 0 );
if( m_hasAutoSave )
{
text = m_FrameName + entryAutoSaveInterval;
config->Read( text, &m_autoSaveInterval, DEFAULT_AUTO_SAVE_INTERVAL );
}
}
// Ensure Window title bar is visible
......@@ -143,13 +209,6 @@ void EDA_BASE_FRAME::LoadSettings()
}
/**
* Save common frame parameters from configuration.
*
* The method is virtual so you can override it to save frame specific
* parameters. Don't forget to call the base method or your frames won't
* remember their positions and sizes.
*/
void EDA_BASE_FRAME::SaveSettings()
{
wxString text;
......@@ -173,6 +232,12 @@ void EDA_BASE_FRAME::SaveSettings()
config->Write( text, (long) m_FrameSize.y );
text = m_FrameName + wxT( "Maximized" );
config->Write( text, IsMaximized() );
if( m_hasAutoSave )
{
text = m_FrameName + entryAutoSaveInterval;
config->Write( text, m_autoSaveInterval );
}
}
......@@ -182,9 +247,6 @@ void EDA_BASE_FRAME::PrintMsg( const wxString& text )
}
/*
* Display a bargraph (0 to 50 point length) for a PerCent value from 0 to 100
*/
void EDA_BASE_FRAME::DisplayActivity( int PerCent, const wxString& Text )
{
wxString Line;
......@@ -194,6 +256,7 @@ void EDA_BASE_FRAME::DisplayActivity( int PerCent, const wxString& Text )
PerCent = (PerCent < 0) ? 0 : PerCent;
PerCent = (PerCent > 100) ? 100 : PerCent;
PerCent /= 2; // Bargraph is 0 .. 50 points from 0% to 100%
if( PerCent )
Line.Pad( PerCent, '*' );
......@@ -201,13 +264,11 @@ void EDA_BASE_FRAME::DisplayActivity( int PerCent, const wxString& Text )
}
/*
* Update the list of recent opened files.
*/
void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName,
wxFileHistory * aFileHistory )
wxFileHistory * aFileHistory )
{
wxFileHistory * fileHistory = aFileHistory;
if( fileHistory == NULL )
fileHistory = & wxGetApp().m_fileHistory;
......@@ -215,28 +276,26 @@ void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName,
}
/*
* Fetch the file name from the file history list.
*/
wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
wxFileHistory * aFileHistory )
{
wxString fn, msg;
size_t i;
wxFileHistory * fileHistory = aFileHistory;
if( fileHistory == NULL )
fileHistory = & wxGetApp().m_fileHistory;
int baseId = fileHistory->GetBaseId();
int baseId = fileHistory->GetBaseId();
wxASSERT( cmdId >= baseId
&& cmdId < baseId + ( int )fileHistory->GetCount() );
wxASSERT( cmdId >= baseId && cmdId < baseId + ( int )fileHistory->GetCount() );
i = ( size_t )( cmdId - baseId );
if( i < fileHistory->GetCount() )
{
fn = fileHistory->GetHistoryFile( i );
if( !wxFileName::FileExists( fn ) )
{
msg = type + _( " file <" ) + fn + _( "> was not found." );
......@@ -250,9 +309,6 @@ wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
}
/*
*
*/
void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
{
wxString msg;
......@@ -269,6 +325,7 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
wxString tmp = wxGetApp().m_HelpFileName;
wxGetApp().m_HelpFileName = wxT( "Getting_Started_in_KiCad.pdf" );
wxString helpFile = wxGetApp().GetHelpFile();
if( !helpFile )
{
msg.Printf( _( "Help file %s could not be found." ),
......@@ -276,7 +333,10 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
DisplayError( this, msg );
}
else
{
GetAssociatedDocument( this, helpFile );
}
wxGetApp().m_HelpFileName = tmp;
return;
}
......@@ -302,6 +362,7 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
wxString helpFile = wxGetApp().GetHelpFile();
if( !helpFile )
{
msg.Printf( _( "Help file %s could not be found." ),
......@@ -309,19 +370,16 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
DisplayError( this, msg );
}
else
{
GetAssociatedDocument( this, helpFile );
}
#else
# error Help files format not defined
#endif
}
/*
* Function OnSelectPreferredEditor
* Open a dialog to select the preferred editor that will be used in KiCad
* to edit or display files (reports ... )
* The full filename editor is saved in configuration (global params)
*/
void EDA_BASE_FRAME::OnSelectPreferredEditor( wxCommandEvent& event )
{
wxFileName fn = wxGetApp().m_EditorName;
......@@ -333,7 +391,7 @@ void EDA_BASE_FRAME::OnSelectPreferredEditor( wxCommandEvent& event )
wildcard = _( "Executable file (" ) + wildcard + wxT( ")|" ) + wildcard;
wxFileDialog dlg( this, _( "Select Prefered Editor" ), fn.GetPath(),
wxFileDialog dlg( this, _( "Select Preferred Editor" ), fn.GetPath(),
fn.GetFullName(), wildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
......@@ -348,9 +406,6 @@ void EDA_BASE_FRAME::OnSelectPreferredEditor( wxCommandEvent& event )
}
/*
*
*/
void EDA_BASE_FRAME::GetKicadAbout( wxCommandEvent& event )
{
bool ShowAboutDialog(wxWindow * parent);
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file drawpanel.cpp
*/
......@@ -841,7 +866,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
if( !IsMouseCaptured() ) // No mouse capture in progress.
m_AutoPAN_Request = false;
if( GetParent()->m_FrameIsActive )
if( GetParent()->IsActive() )
SetFocus();
else
return;
......
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_svg_print.cpp
// Author: jean-pierre Charras
// Modified by:
// Licence: GPL
/////////////////////////////////////////////////////////////////////////////
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file dialog_SVG_print.cpp
*/
#include "fctsys.h"
#include "appl_wxstruct.h"
......@@ -100,7 +122,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
SCH_SCREEN* screen = (SCH_SCREEN*) m_Parent->GetScreen();
if( aPrintAll && m_Parent->m_Ident == SCHEMATIC_FRAME )
if( aPrintAll && m_Parent->IsType( SCHEMATIC_FRAME ) )
{
SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_Parent;
SCH_SHEET_PATH* sheetpath, * oldsheetpath = schframe->GetSheet();
......
/***************/
/* lib_pin.cpp */
/***************/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file lib_pin.cpp
*/
#include "fctsys.h"
#include "appl_wxstruct.h"
......@@ -804,7 +829,7 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel,
if( aPanel && aPanel->GetParent() )
frame = (EDA_DRAW_FRAME*)aPanel->GetParent();
if( frame && frame->m_Ident == SCHEMATIC_FRAME &&
if( frame && frame->IsType( SCHEMATIC_FRAME ) &&
! ((SCH_EDIT_FRAME*)frame)->m_ShowAllPins )
return;
......
/* Liste des identificateurs des boutons et menus */
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file id.h
*/
#ifndef ID_H
#define ID_H
......@@ -29,6 +58,7 @@ enum main_id
ID_NEW_BOARD,
ID_SAVE_BOARD,
ID_SAVE_BOARD_AS,
ID_AUTO_SAVE_TIMER,
ID_CONFIG_REQ,
ID_CONFIG_SAVE,
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file wxPcbStruct.h
*/
......@@ -18,6 +43,10 @@
#endif
#define CREATE_BACKUP_FILE true
#define NO_BACKUP_FILE false
/* Forward declarations of classes. */
class PCB_SCREEN;
class BOARD;
......@@ -57,9 +86,6 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME
int m_RecordingMacros;
MACROS_RECORDED m_Macros[10];
int m_saveInterval; ///< Time interval in seconds for automatic saving.
int m_lastSaveTime; ///< Last save time.
protected:
PCB_LAYER_WIDGET* m_Layers;
......@@ -116,6 +142,21 @@ protected:
virtual void unitsChangeRefresh();
/**
* Function doAutoSave
* performs auto save when the board has been modified and not saved within the
* auto save interval.
*
* @return true if the auto save was successful.
*/
virtual bool doAutoSave();
/**
* Function isModified
* returns true if the board has been modified.
*/
virtual bool isModified() const;
public:
LAYER_BOX_SELECTOR* m_SelLayerBox; // a combo box to display and select active layer
wxComboBox* m_SelTrackWidthBox; // a combo box to display and select current track width
......@@ -233,12 +274,6 @@ public:
*/
virtual void SetGridColor(int aColor);
void ResetAutoSaveTimeOut() { m_lastSaveTime = time( NULL ); }
int GetAutoSaveTimeInterval() { return m_saveInterval; }
void SetAutoSaveTimeInterval( int aInterval ) { m_saveInterval = aInterval; }
// Configurations:
void InstallConfigFrame();
void Process_Config( wxCommandEvent& event );
......@@ -684,9 +719,12 @@ public:
*
* @param aFileName The file name to write or wxEmptyString to prompt user for
* file name.
* @param aCreateBackupFile Creates a back of \a aFileName if true. Helper
* definitions #CREATE_BACKUP_FILE and #NO_BACKUP_FILE
* are defined for improved code readability.
* @return True if file was saved successfully.
*/
bool SavePcbFile( const wxString& aFileName );
bool SavePcbFile( const wxString& aFileName, bool aCreateBackupFile = CREATE_BACKUP_FILE );
int SavePcbFormatAscii( FILE* File );
bool WriteGeneralDescrPcb( FILE* File );
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file wxstruct.h
* @brief Base window classes and related definitions.
......@@ -82,7 +107,7 @@ enum id_toolbar {
*/
class EDA_BASE_FRAME : public wxFrame
{
public:
protected:
int m_Ident; // Id Type (pcb, schematic, library..)
wxPoint m_FramePos;
wxSize m_FrameSize;
......@@ -96,13 +121,67 @@ public:
wxAuiManager m_auimgr;
/// Flag to indicate if this frame supports auto save.
bool m_hasAutoSave;
/// Flag to indicate the last auto save state.
bool m_autoSaveState;
/// The auto save interval time in seconds.
int m_autoSaveInterval;
/// The timer used to implement the auto save feature;
wxTimer* m_autoSaveTimer;
/**
* Function onAutoSaveTimer
* handles the auto save timer event.
*/
void onAutoSaveTimer( wxTimerEvent& aEvent );
/**
* Function isModified
* returns the modification status of the application. Override this function if
* your derived frame supports automatic file saving.
*/
virtual bool isModified() const { return false; }
/**
* Function doAutoSave
* should be overridden by the derived class to handle the auto save feature.
*
* @return true if the auto save was successful otherwise false.
*/
virtual bool doAutoSave();
public:
EDA_BASE_FRAME( wxWindow* father, int idtype, const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
~EDA_BASE_FRAME();
/**
* Function ProcessEvent
* overrides the default process event handler to implement the auto save feature.
*
* @warning If you override this function in a derived class, make sure you call
* down to this or the auto save feature will be disabled.
*/
virtual bool ProcessEvent( wxEvent& aEvent );
void SetAutoSaveInterval( int aInterval ) { m_autoSaveInterval = aInterval; }
int GetAutoSaveInterval() const { return m_autoSaveInterval; }
wxString GetName() const { return m_FrameName; }
bool IsActive() const { return m_FrameIsActive; }
bool IsType( int aType ) const { return m_Ident == aType; }
void GetKicadHelp( wxCommandEvent& event );
void GetKicadAbout( wxCommandEvent& event );
/**
......@@ -120,7 +199,22 @@ public:
*/
void AddHelpVersionInfoMenuEntry( wxMenu* aMenu );
/**
* Load common frame parameters from configuration.
*
* The method is virtual so you can override it to load frame specific
* parameters. Don't forget to call the base method or your frames won't
* remember their positions and sizes.
*/
virtual void LoadSettings();
/**
* Save common frame parameters from configuration.
*
* The method is virtual so you can override it to save frame specific
* parameters. Don't forget to call the base method or your frames won't
* remember their positions and sizes.
*/
virtual void SaveSettings();
/**
......@@ -209,6 +303,9 @@ public:
*/
void UpdateFileHistory( const wxString& FullFileName, wxFileHistory * aFileHistory = NULL );
/*
* Display a bargraph (0 to 50 point length) for a PerCent value from 0 to 100
*/
void DisplayActivity( int PerCent, const wxString& Text );
/**
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file class_module.cpp
* @brief MODULE class implementation.
......@@ -708,7 +733,7 @@ void MODULE::DisplayInfo( EDA_DRAW_FRAME* frame )
frame->EraseMsgBox();
if( frame->m_Ident != PCB_FRAME )
if( frame->IsType( PCB_FRAME ) )
flag = true;
frame->AppendMsgPanel( m_Reference->m_Text, m_Value->m_Text, DARKCYAN );
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file class_track.h
* @brief Functions relatives to tracks, vias and segments used to fill zones.
......@@ -985,7 +1010,7 @@ void TRACK::DisplayInfo( EDA_DRAW_FRAME* frame )
DisplayInfoBase( frame );
// Display full track length (in Pcbnew)
if( frame->m_Ident == PCB_FRAME )
if( frame->IsType( PCB_FRAME ) )
{
int trackLen = 0;
int lenDie = 0;
......@@ -1053,7 +1078,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )
frame->AppendMsgPanel( _( "Type" ), msg, DARKCYAN );
// Display Net Name (in Pcbnew)
if( frame->m_Ident == PCB_FRAME )
if( frame->IsType( PCB_FRAME ) )
{
NETINFO_ITEM* net = board->FindNet( GetNet() );
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file pcbnew/controle.cpp
*/
......@@ -241,33 +266,6 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
wxPoint oldpos;
wxPoint pos = GetScreen()->GetNearestGridPosition( aPosition );
// Save the board after the time out :
int CurrentTime = time( NULL );
if( !GetScreen()->IsModify() || GetScreen()->IsSave() )
{
/* If no change, reset the time out */
m_lastSaveTime = CurrentTime;
}
if( (CurrentTime - m_lastSaveTime) > m_saveInterval )
{
wxString tmpFileName = GetScreen()->GetFileName();
wxFileName fn = wxFileName( wxEmptyString, g_SaveFileName, PcbFileExtension );
bool flgmodify = GetScreen()->IsModify();
SavePcbFile( fn.GetFullPath() );
if( flgmodify ) // Set the flags m_Modify cleared by SavePcbFile()
{
OnModify();
GetScreen()->SetSave(); // Set the flags m_FlagSave cleared by SetModify()
}
GetScreen()->SetFileName( tmpFileName );
UpdateTitle();
}
oldpos = GetScreen()->GetCrossHairPosition();
gridSize = GetScreen()->GetGridSize();
......
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_general_options.cpp
// Author: jean-pierre Charras
/////////////////////////////////////////////////////////////////////////////
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file dialog_general_options.cpp
*/
/* functions relatives to the dialogs opened from the main menu :
* Preferences/general
......@@ -55,7 +78,7 @@ void Dialog_GeneralOptions::init()
}
wxString timevalue;
timevalue << GetParent()->GetAutoSaveTimeInterval() / 60;
timevalue << GetParent()->GetAutoSaveInterval() / 60;
m_SaveTime->SetValue( timevalue );
m_MaxShowLinks->SetValue( g_MaxLinksShowed );
......@@ -93,7 +116,7 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event )
GetParent()->ReCreateAuxiliaryToolbar();
GetParent()->m_CursorShape = m_CursorShape->GetSelection();
GetParent()->SetAutoSaveTimeInterval( 60 * m_SaveTime->GetValue() );
GetParent()->SetAutoSaveInterval( m_SaveTime->GetValue() * 60 );
g_RotationAngle = 10 * wxAtoi( m_RotationAngle->GetStringSelection() );
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2010 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file pcbnew/files.cpp
* @brief Read and write board files.
......@@ -14,6 +39,7 @@
#include "3d_viewer.h"
#include "richio.h"
#include "filter_reader.h"
#include "appl_wxstruct.h"
#include "pcbnew.h"
#include "protos.h"
......@@ -169,11 +195,58 @@ the changes?" ) ) )
if( !aAppend )
Clear_Pcb( false ); // pass false since we prompted above for a modified board
GetScreen()->SetFileName( fileName.GetFullPath() );
// Check for board auto save file.
wxFileName autoSaveFileName = fileName;
autoSaveFileName.SetName( wxT( "$" ) + autoSaveFileName.GetName() );
if( autoSaveFileName.FileExists() )
{
int response = wxMessageBox( _( "Well this is embarrassing! It appears that the last \
time you were editing this board the file was not save properly. Do you wish to restore the \
last edits you made?" ), wxGetApp().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
// Make a backup of the current board file, delete the board file, and copy
// the auto save file to the board file name.
if( response == wxYES )
{
/* Get the backup file name */
wxFileName backupFileName = fileName;
backupFileName.SetExt( BACKUP_FILE_EXT );
/* If an old backup file exists, delete it. If an old board file exists, rename
* it to the backup file name
*/
if( fileName.FileExists() )
{
/* rename the "old" file" from xxx.brd to xxx.000 */
if( backupFileName.FileExists() ) /* Remove the old file xxx.000 (if exists) */
wxRemoveFile( backupFileName.GetFullPath() );
if( !wxRenameFile( fileName.GetFullPath(), backupFileName.GetFullPath() ) )
{
msg = _( "Could not create backup file " ) + backupFileName.GetFullPath();
DisplayError( this, msg );
}
}
if( !wxRenameFile( autoSaveFileName.GetFullPath(), fileName.GetFullPath() ) )
{
wxMessageBox( _( "The auto save file could not be renamed to the board file \
name." ),
wxGetApp().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
}
}
else
{
// Remove the auto save file when using the board file as is.
wxRemoveFile( autoSaveFileName.GetFullPath() );
}
}
/* Start read PCB file
*/
GetScreen()->SetFileName( fileName.GetFullPath() );
// Start read PCB file
source = wxFopen( GetScreen()->GetFileName(), wxT( "rt" ) );
if( source == NULL )
......@@ -284,9 +357,6 @@ this file again." ) );
Compile_Ratsnest( NULL, true );
GetBoard()->DisplayInfo( this );
/* reset the auto save timer */
m_lastSaveTime = time( NULL );
// Refresh the 3D view, if any
if( m_Draw3DFrame )
m_Draw3DFrame->NewDisplay();
......@@ -306,7 +376,7 @@ this file again." ) );
}
bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName )
bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupFile )
{
wxFileName backupFileName;
wxFileName pcbFileName;
......@@ -344,31 +414,35 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName )
if( !IsWritable( pcbFileName ) )
return false;
/* Get the backup file name */
backupFileName = pcbFileName;
backupFileName.SetExt( BACKUP_FILE_EXT );
/* If an old backup file exists, delete it.
if an old board file exists, rename it to the backup file name
*/
if( pcbFileName.FileExists() )
if( aCreateBackupFile )
{
/* rename the "old" file" from xxx.brd to xxx.000 */
if( backupFileName.FileExists() ) /* Remove the old file xxx.000 (if exists) */
wxRemoveFile( backupFileName.GetFullPath() );
if( !wxRenameFile( pcbFileName.GetFullPath(), backupFileName.GetFullPath() ) )
/* Get the backup file name */
backupFileName = pcbFileName;
backupFileName.SetExt( BACKUP_FILE_EXT );
/* If an old backup file exists, delete it. If an old board file exists, rename
* it to the backup file name
*/
if( pcbFileName.FileExists() )
{
// Remove the old file xxx.000 if it exists.
if( backupFileName.FileExists() )
wxRemoveFile( backupFileName.GetFullPath() );
// Rename the "old" file" from xxx.brd to xxx.000
if( !wxRenameFile( pcbFileName.GetFullPath(), backupFileName.GetFullPath() ) )
{
msg = _( "Warning: unable to create backup file " ) + backupFileName.GetFullPath();
DisplayError( this, msg );
saveok = false;
}
}
else
{
msg = _( "Warning: unable to create backup file " ) + backupFileName.GetFullPath();
DisplayError( this, msg );
backupFileName.Clear();
saveok = false;
}
}
else
{
backupFileName.Clear();
saveok = false;
}
/* Create the file */
dest = wxFopen( pcbFileName.GetFullPath(), wxT( "wt" ) );
......@@ -394,6 +468,13 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName )
if( saveok )
{
// Delete auto save file on successful save.
wxFileName autoSaveFileName = pcbFileName;
autoSaveFileName.SetName( wxT( "$" ) + pcbFileName.GetName() );
if( autoSaveFileName.FileExists() )
wxRemoveFile( autoSaveFileName.GetFullPath() );
upperTxt = _( "Backup file: " ) + backupFileName.GetFullPath();
}
......@@ -407,8 +488,29 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName )
ClearMsgPanel();
AppendMsgPanel( upperTxt, lowerTxt, CYAN );
m_lastSaveTime = time( NULL ); /* Reset timer for the automatic saving */
GetScreen()->ClrModify();
return true;
}
bool PCB_EDIT_FRAME::doAutoSave()
{
wxFileName tmpFileName = GetScreen()->GetFileName();
wxFileName fn = tmpFileName;
// Auto save file name is the normal file name prepended with $.
fn.SetName( wxT( "$" ) + fn.GetName() );
if( SavePcbFile( fn.GetFullPath(), NO_BACKUP_FILE ) )
{
OnModify();
GetScreen()->SetSave(); // Set the flags m_FlagSave cleared by SetModify()
GetScreen()->SetFileName( tmpFileName.GetFullPath() );
UpdateTitle();
return true;
}
GetScreen()->SetFileName( tmpFileName.GetFullPath() );
return false;
}
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file pcbnew/loadcmp.cpp
* @brief Footprints selection and loading functions.
......@@ -193,7 +217,6 @@ MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryFullFilename,
FILE* file = NULL;
unsigned ii;
bool one_lib = aLibraryFullFilename.IsEmpty() ? false : true;
PCB_EDIT_FRAME* parent = (PCB_EDIT_FRAME*) GetParent();
for( ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
{
......
......@@ -3,6 +3,7 @@
*
* Copyright (C) 2004-2010 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -23,25 +24,26 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/******************************************/
/* pcbframe.cpp - PCB editor main window. */
/******************************************/
/**
* @file pcbframe.cpp
* @brief PCB editor main window implementation.
*/
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "pcbcommon.h" // enum PCB_VISIBLE
#include "collectors.h"
#include "build_version.h"
#include "macros.h"
#include "3d_viewer.h"
#include "pcbnew.h"
#include "protos.h"
#include "pcbnew_id.h"
#include "drc_stuff.h"
#include "3d_viewer.h"
#include "kbool/include/kbool/booleng.h"
#include "layer_widget.h"
#include "dialog_design_rules.h"
#include "class_pcb_layer_widget.h"
......@@ -275,8 +277,9 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
m_show_microwave_tools = false;
m_show_layer_manager_tools = true;
m_HotkeysZoomAndGridList = g_Board_Editor_Hokeys_Descr;
m_hasAutoSave = true;
m_RecordingMacros = -1;
for ( int i = 0; i < 10; i++ )
m_Macros[i].m_Record.clear();
......@@ -410,6 +413,12 @@ PCB_EDIT_FRAME::~PCB_EDIT_FRAME()
}
bool PCB_EDIT_FRAME::isModified() const
{
return GetScreen()->IsModify();
}
void PCB_EDIT_FRAME::ReFillLayerWidget()
{
m_Layers->ReFill();
......@@ -464,6 +473,23 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
}
}
// Delete the auto save file if it exists.
wxFileName fn = GetScreen()->GetFileName();
// Auto save file name is the normal file name prefixed with a '$'.
fn.SetName( wxT( "$" ) + fn.GetName() );
// Remove the auto save file on a normal close of Pcbnew.
if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
{
wxString msg;
msg.Printf( _( "The auto save file <%s> could not be removed!" ),
GetChars( fn.GetFullPath() ) );
wxMessageBox( msg, wxGetApp().GetAppName(), wxOK | wxICON_ERROR, this );
}
SaveSettings();
// do not show the window because ScreenPcb will be deleted and we do not
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file pcbnew.cpp
* @brief Pcbnew main program.
......@@ -151,7 +175,6 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
frame->UpdateTitle();
frame->UpdateFileHistory( frame->GetScreen()->GetFileName() );
frame->OnModify(); // Ready to save the new empty board
frame->ResetAutoSaveTimeOut();
wxString msg;
msg.Printf( _( "File <%s> does not exist.\nThis is normal for a new project" ),
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file pcbnew_config.cpp
*/
......@@ -368,8 +393,6 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings()
// Miscellaneous:
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ), &g_RotationAngle,
900, 450, 900 ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "TimeOut" ), &m_saveInterval,
600, 0, 60000 ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ), &g_MaxLinksShowed,
3, 0, 15 ) );
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowMRa" ),
......
/**************************/
/* printout_controler.cpp */
/**************************/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* printout_controler.cpp
*/
// Set this to 1 if you want to test PostScript printing under MSW.
#define wxTEST_POSTSCRIPT_IN_MSW 1
......@@ -50,13 +74,11 @@ BOARD_PRINTOUT_CONTROLER::BOARD_PRINTOUT_CONTROLER( const PRINT_PARAMETERS& prin
}
/*****************************************************/
bool BOARD_PRINTOUT_CONTROLER::OnPrintPage( int page )
/*****************************************************/
{
int layers_count = NB_LAYERS;
if( m_Parent->m_Ident == GERBER_FRAME )
if( m_Parent->IsType( GERBER_FRAME ) )
layers_count = 32;
int mask_layer = m_PrintParams.m_PrintMaskLayer;
......@@ -65,15 +87,18 @@ bool BOARD_PRINTOUT_CONTROLER::OnPrintPage( int page )
if( m_PrintParams.m_OptionPrintPage == 0 ) // One page per layer
{
int ii, jj, mask = 1;
for( ii = 0, jj = 0; ii < layers_count; ii++ )
{
if( mask_layer & mask )
jj++;
if( jj == page )
{
m_PrintParams.m_PrintMaskLayer = mask;
break;
}
mask <<= 1;
}
}
......@@ -148,7 +173,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
// In module editor, the module is located at 0,0 but for printing
// it is moved to SheetSize.x/2, SheetSize.y/2.
// So the equivalent board must be moved:
if( m_Parent->m_Ident == MODULE_EDITOR_FRAME )
if( m_Parent->IsType( MODULE_EDITOR_FRAME ) )
{
wxPoint mv_offset;
mv_offset.x = SheetSize.x / 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment