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" #include "fctsys.h"
...@@ -105,10 +130,9 @@ void EDA_3D_FRAME::ReCreateMenuBar() ...@@ -105,10 +130,9 @@ void EDA_3D_FRAME::ReCreateMenuBar()
{ {
bool full_options = true; bool full_options = true;
// If called from the display frame of cvpcb, only some options are // If called from the display frame of CvPcb, only some options are relevant
// relevant if( m_Parent->GetName() == wxT( "CmpFrame" ) )
if( m_Parent->m_FrameName == wxT( "CmpFrame" ) ) // Called from CvPcb: do not display all options
// Called from cvpcb: do not display all options
full_options = false; full_options = false;
wxMenuBar* menuBar = new wxMenuBar; wxMenuBar* menuBar = new wxMenuBar;
......
This diff is collapsed.
/*
* 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 * @file drawpanel.cpp
*/ */
...@@ -841,7 +866,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) ...@@ -841,7 +866,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
if( !IsMouseCaptured() ) // No mouse capture in progress. if( !IsMouseCaptured() ) // No mouse capture in progress.
m_AutoPAN_Request = false; m_AutoPAN_Request = false;
if( GetParent()->m_FrameIsActive ) if( GetParent()->IsActive() )
SetFocus(); SetFocus();
else else
return; return;
......
///////////////////////////////////////////////////////////////////////////// /*
// Name: dialog_svg_print.cpp * This program source code file is part of KiCad, a free EDA CAD application.
// Author: jean-pierre Charras *
// Modified by: * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
// Licence: GPL * 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 "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
...@@ -100,7 +122,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ) ...@@ -100,7 +122,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
SCH_SCREEN* screen = (SCH_SCREEN*) m_Parent->GetScreen(); 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_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_Parent;
SCH_SHEET_PATH* sheetpath, * oldsheetpath = schframe->GetSheet(); 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 "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
...@@ -804,7 +829,7 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, ...@@ -804,7 +829,7 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel,
if( aPanel && aPanel->GetParent() ) if( aPanel && aPanel->GetParent() )
frame = (EDA_DRAW_FRAME*)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 ) ! ((SCH_EDIT_FRAME*)frame)->m_ShowAllPins )
return; 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 #ifndef ID_H
#define ID_H #define ID_H
...@@ -29,6 +58,7 @@ enum main_id ...@@ -29,6 +58,7 @@ enum main_id
ID_NEW_BOARD, ID_NEW_BOARD,
ID_SAVE_BOARD, ID_SAVE_BOARD,
ID_SAVE_BOARD_AS, ID_SAVE_BOARD_AS,
ID_AUTO_SAVE_TIMER,
ID_CONFIG_REQ, ID_CONFIG_REQ,
ID_CONFIG_SAVE, 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 * @file wxPcbStruct.h
*/ */
...@@ -18,6 +43,10 @@ ...@@ -18,6 +43,10 @@
#endif #endif
#define CREATE_BACKUP_FILE true
#define NO_BACKUP_FILE false
/* Forward declarations of classes. */ /* Forward declarations of classes. */
class PCB_SCREEN; class PCB_SCREEN;
class BOARD; class BOARD;
...@@ -57,9 +86,6 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME ...@@ -57,9 +86,6 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME
int m_RecordingMacros; int m_RecordingMacros;
MACROS_RECORDED m_Macros[10]; MACROS_RECORDED m_Macros[10];
int m_saveInterval; ///< Time interval in seconds for automatic saving.
int m_lastSaveTime; ///< Last save time.
protected: protected:
PCB_LAYER_WIDGET* m_Layers; PCB_LAYER_WIDGET* m_Layers;
...@@ -116,6 +142,21 @@ protected: ...@@ -116,6 +142,21 @@ protected:
virtual void unitsChangeRefresh(); 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: public:
LAYER_BOX_SELECTOR* m_SelLayerBox; // a combo box to display and select active layer 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 wxComboBox* m_SelTrackWidthBox; // a combo box to display and select current track width
...@@ -233,12 +274,6 @@ public: ...@@ -233,12 +274,6 @@ public:
*/ */
virtual void SetGridColor(int aColor); virtual void SetGridColor(int aColor);
void ResetAutoSaveTimeOut() { m_lastSaveTime = time( NULL ); }
int GetAutoSaveTimeInterval() { return m_saveInterval; }
void SetAutoSaveTimeInterval( int aInterval ) { m_saveInterval = aInterval; }
// Configurations: // Configurations:
void InstallConfigFrame(); void InstallConfigFrame();
void Process_Config( wxCommandEvent& event ); void Process_Config( wxCommandEvent& event );
...@@ -684,9 +719,12 @@ public: ...@@ -684,9 +719,12 @@ public:
* *
* @param aFileName The file name to write or wxEmptyString to prompt user for * @param aFileName The file name to write or wxEmptyString to prompt user for
* file name. * 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. * @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 ); int SavePcbFormatAscii( FILE* File );
bool WriteGeneralDescrPcb( 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 * @file wxstruct.h
* @brief Base window classes and related definitions. * @brief Base window classes and related definitions.
...@@ -82,7 +107,7 @@ enum id_toolbar { ...@@ -82,7 +107,7 @@ enum id_toolbar {
*/ */
class EDA_BASE_FRAME : public wxFrame class EDA_BASE_FRAME : public wxFrame
{ {
public: protected:
int m_Ident; // Id Type (pcb, schematic, library..) int m_Ident; // Id Type (pcb, schematic, library..)
wxPoint m_FramePos; wxPoint m_FramePos;
wxSize m_FrameSize; wxSize m_FrameSize;
...@@ -96,13 +121,67 @@ public: ...@@ -96,13 +121,67 @@ public:
wxAuiManager m_auimgr; 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: public:
EDA_BASE_FRAME( wxWindow* father, int idtype, const wxString& title, EDA_BASE_FRAME( wxWindow* father, int idtype, const wxString& title,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
~EDA_BASE_FRAME(); ~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 GetKicadHelp( wxCommandEvent& event );
void GetKicadAbout( wxCommandEvent& event ); void GetKicadAbout( wxCommandEvent& event );
/** /**
...@@ -120,7 +199,22 @@ public: ...@@ -120,7 +199,22 @@ public:
*/ */
void AddHelpVersionInfoMenuEntry( wxMenu* aMenu ); 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(); 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(); virtual void SaveSettings();
/** /**
...@@ -209,6 +303,9 @@ public: ...@@ -209,6 +303,9 @@ public:
*/ */
void UpdateFileHistory( const wxString& FullFileName, wxFileHistory * aFileHistory = NULL ); 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 ); 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 * @file class_module.cpp
* @brief MODULE class implementation. * @brief MODULE class implementation.
...@@ -708,7 +733,7 @@ void MODULE::DisplayInfo( EDA_DRAW_FRAME* frame ) ...@@ -708,7 +733,7 @@ void MODULE::DisplayInfo( EDA_DRAW_FRAME* frame )
frame->EraseMsgBox(); frame->EraseMsgBox();
if( frame->m_Ident != PCB_FRAME ) if( frame->IsType( PCB_FRAME ) )
flag = true; flag = true;
frame->AppendMsgPanel( m_Reference->m_Text, m_Value->m_Text, DARKCYAN ); 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 * @file class_track.h
* @brief Functions relatives to tracks, vias and segments used to fill zones. * @brief Functions relatives to tracks, vias and segments used to fill zones.
...@@ -985,7 +1010,7 @@ void TRACK::DisplayInfo( EDA_DRAW_FRAME* frame ) ...@@ -985,7 +1010,7 @@ void TRACK::DisplayInfo( EDA_DRAW_FRAME* frame )
DisplayInfoBase( frame ); DisplayInfoBase( frame );
// Display full track length (in Pcbnew) // Display full track length (in Pcbnew)
if( frame->m_Ident == PCB_FRAME ) if( frame->IsType( PCB_FRAME ) )
{ {
int trackLen = 0; int trackLen = 0;
int lenDie = 0; int lenDie = 0;
...@@ -1053,7 +1078,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame ) ...@@ -1053,7 +1078,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )
frame->AppendMsgPanel( _( "Type" ), msg, DARKCYAN ); frame->AppendMsgPanel( _( "Type" ), msg, DARKCYAN );
// Display Net Name (in Pcbnew) // Display Net Name (in Pcbnew)
if( frame->m_Ident == PCB_FRAME ) if( frame->IsType( PCB_FRAME ) )
{ {
NETINFO_ITEM* net = board->FindNet( GetNet() ); 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 * @file pcbnew/controle.cpp
*/ */
...@@ -241,33 +266,6 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH ...@@ -241,33 +266,6 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
wxPoint oldpos; wxPoint oldpos;
wxPoint pos = GetScreen()->GetNearestGridPosition( aPosition ); 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(); oldpos = GetScreen()->GetCrossHairPosition();
gridSize = GetScreen()->GetGridSize(); gridSize = GetScreen()->GetGridSize();
......
///////////////////////////////////////////////////////////////////////////// /*
// Name: dialog_general_options.cpp * This program source code file is part of KiCad, a free EDA CAD application.
// Author: jean-pierre Charras *
///////////////////////////////////////////////////////////////////////////// * 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 : /* functions relatives to the dialogs opened from the main menu :
* Preferences/general * Preferences/general
...@@ -55,7 +78,7 @@ void Dialog_GeneralOptions::init() ...@@ -55,7 +78,7 @@ void Dialog_GeneralOptions::init()
} }
wxString timevalue; wxString timevalue;
timevalue << GetParent()->GetAutoSaveTimeInterval() / 60; timevalue << GetParent()->GetAutoSaveInterval() / 60;
m_SaveTime->SetValue( timevalue ); m_SaveTime->SetValue( timevalue );
m_MaxShowLinks->SetValue( g_MaxLinksShowed ); m_MaxShowLinks->SetValue( g_MaxLinksShowed );
...@@ -93,7 +116,7 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event ) ...@@ -93,7 +116,7 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event )
GetParent()->ReCreateAuxiliaryToolbar(); GetParent()->ReCreateAuxiliaryToolbar();
GetParent()->m_CursorShape = m_CursorShape->GetSelection(); 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() ); 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 * @file pcbnew/files.cpp
* @brief Read and write board files. * @brief Read and write board files.
...@@ -14,6 +39,7 @@ ...@@ -14,6 +39,7 @@
#include "3d_viewer.h" #include "3d_viewer.h"
#include "richio.h" #include "richio.h"
#include "filter_reader.h" #include "filter_reader.h"
#include "appl_wxstruct.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "protos.h" #include "protos.h"
...@@ -169,11 +195,58 @@ the changes?" ) ) ) ...@@ -169,11 +195,58 @@ the changes?" ) ) )
if( !aAppend ) if( !aAppend )
Clear_Pcb( false ); // pass false since we prompted above for a modified board 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" ) ); source = wxFopen( GetScreen()->GetFileName(), wxT( "rt" ) );
if( source == NULL ) if( source == NULL )
...@@ -284,9 +357,6 @@ this file again." ) ); ...@@ -284,9 +357,6 @@ this file again." ) );
Compile_Ratsnest( NULL, true ); Compile_Ratsnest( NULL, true );
GetBoard()->DisplayInfo( this ); GetBoard()->DisplayInfo( this );
/* reset the auto save timer */
m_lastSaveTime = time( NULL );
// Refresh the 3D view, if any // Refresh the 3D view, if any
if( m_Draw3DFrame ) if( m_Draw3DFrame )
m_Draw3DFrame->NewDisplay(); m_Draw3DFrame->NewDisplay();
...@@ -306,7 +376,7 @@ this file again." ) ); ...@@ -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 backupFileName;
wxFileName pcbFileName; wxFileName pcbFileName;
...@@ -344,31 +414,35 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName ) ...@@ -344,31 +414,35 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName )
if( !IsWritable( pcbFileName ) ) if( !IsWritable( pcbFileName ) )
return false; return false;
/* Get the backup file name */ if( aCreateBackupFile )
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() )
{ {
/* rename the "old" file" from xxx.brd to xxx.000 */ /* Get the backup file name */
if( backupFileName.FileExists() ) /* Remove the old file xxx.000 (if exists) */ backupFileName = pcbFileName;
wxRemoveFile( backupFileName.GetFullPath() ); backupFileName.SetExt( BACKUP_FILE_EXT );
if( !wxRenameFile( pcbFileName.GetFullPath(), backupFileName.GetFullPath() ) ) /* 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(); backupFileName.Clear();
DisplayError( this, msg );
saveok = false; saveok = false;
} }
} }
else
{
backupFileName.Clear();
saveok = false;
}
/* Create the file */ /* Create the file */
dest = wxFopen( pcbFileName.GetFullPath(), wxT( "wt" ) ); dest = wxFopen( pcbFileName.GetFullPath(), wxT( "wt" ) );
...@@ -394,6 +468,13 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName ) ...@@ -394,6 +468,13 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName )
if( saveok ) 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(); upperTxt = _( "Backup file: " ) + backupFileName.GetFullPath();
} }
...@@ -407,8 +488,29 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName ) ...@@ -407,8 +488,29 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName )
ClearMsgPanel(); ClearMsgPanel();
AppendMsgPanel( upperTxt, lowerTxt, CYAN ); AppendMsgPanel( upperTxt, lowerTxt, CYAN );
m_lastSaveTime = time( NULL ); /* Reset timer for the automatic saving */
GetScreen()->ClrModify(); GetScreen()->ClrModify();
return true; 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 * @file pcbnew/loadcmp.cpp
* @brief Footprints selection and loading functions. * @brief Footprints selection and loading functions.
...@@ -193,7 +217,6 @@ MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryFullFilename, ...@@ -193,7 +217,6 @@ MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryFullFilename,
FILE* file = NULL; FILE* file = NULL;
unsigned ii; unsigned ii;
bool one_lib = aLibraryFullFilename.IsEmpty() ? false : true; bool one_lib = aLibraryFullFilename.IsEmpty() ? false : true;
PCB_EDIT_FRAME* parent = (PCB_EDIT_FRAME*) GetParent();
for( ii = 0; ii < g_LibraryNames.GetCount(); ii++ ) for( ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
{ {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* *
* Copyright (C) 2004-2010 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr * 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) 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. * Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -23,25 +24,26 @@ ...@@ -23,25 +24,26 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/**
/******************************************/ * @file pcbframe.cpp
/* pcbframe.cpp - PCB editor main window. */ * @brief PCB editor main window implementation.
/******************************************/ */
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "pcbnew.h"
#include "wxPcbStruct.h" #include "wxPcbStruct.h"
#include "pcbcommon.h" // enum PCB_VISIBLE #include "pcbcommon.h" // enum PCB_VISIBLE
#include "collectors.h" #include "collectors.h"
#include "build_version.h" #include "build_version.h"
#include "macros.h"
#include "3d_viewer.h"
#include "pcbnew.h"
#include "protos.h" #include "protos.h"
#include "pcbnew_id.h" #include "pcbnew_id.h"
#include "drc_stuff.h" #include "drc_stuff.h"
#include "3d_viewer.h"
#include "kbool/include/kbool/booleng.h"
#include "layer_widget.h" #include "layer_widget.h"
#include "dialog_design_rules.h" #include "dialog_design_rules.h"
#include "class_pcb_layer_widget.h" #include "class_pcb_layer_widget.h"
...@@ -275,8 +277,9 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, ...@@ -275,8 +277,9 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
m_show_microwave_tools = false; m_show_microwave_tools = false;
m_show_layer_manager_tools = true; m_show_layer_manager_tools = true;
m_HotkeysZoomAndGridList = g_Board_Editor_Hokeys_Descr; m_HotkeysZoomAndGridList = g_Board_Editor_Hokeys_Descr;
m_hasAutoSave = true;
m_RecordingMacros = -1; m_RecordingMacros = -1;
for ( int i = 0; i < 10; i++ ) for ( int i = 0; i < 10; i++ )
m_Macros[i].m_Record.clear(); m_Macros[i].m_Record.clear();
...@@ -410,6 +413,12 @@ PCB_EDIT_FRAME::~PCB_EDIT_FRAME() ...@@ -410,6 +413,12 @@ PCB_EDIT_FRAME::~PCB_EDIT_FRAME()
} }
bool PCB_EDIT_FRAME::isModified() const
{
return GetScreen()->IsModify();
}
void PCB_EDIT_FRAME::ReFillLayerWidget() void PCB_EDIT_FRAME::ReFillLayerWidget()
{ {
m_Layers->ReFill(); m_Layers->ReFill();
...@@ -464,6 +473,23 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -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(); SaveSettings();
// do not show the window because ScreenPcb will be deleted and we do not // 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 * @file pcbnew.cpp
* @brief Pcbnew main program. * @brief Pcbnew main program.
...@@ -151,7 +175,6 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); ...@@ -151,7 +175,6 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
frame->UpdateTitle(); frame->UpdateTitle();
frame->UpdateFileHistory( frame->GetScreen()->GetFileName() ); frame->UpdateFileHistory( frame->GetScreen()->GetFileName() );
frame->OnModify(); // Ready to save the new empty board frame->OnModify(); // Ready to save the new empty board
frame->ResetAutoSaveTimeOut();
wxString msg; wxString msg;
msg.Printf( _( "File <%s> does not exist.\nThis is normal for a new project" ), 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 * @file pcbnew_config.cpp
*/ */
...@@ -368,8 +393,6 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() ...@@ -368,8 +393,6 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings()
// Miscellaneous: // Miscellaneous:
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ), &g_RotationAngle, m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ), &g_RotationAngle,
900, 450, 900 ) ); 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, m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ), &g_MaxLinksShowed,
3, 0, 15 ) ); 3, 0, 15 ) );
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowMRa" ), 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. // Set this to 1 if you want to test PostScript printing under MSW.
#define wxTEST_POSTSCRIPT_IN_MSW 1 #define wxTEST_POSTSCRIPT_IN_MSW 1
...@@ -50,13 +74,11 @@ BOARD_PRINTOUT_CONTROLER::BOARD_PRINTOUT_CONTROLER( const PRINT_PARAMETERS& prin ...@@ -50,13 +74,11 @@ BOARD_PRINTOUT_CONTROLER::BOARD_PRINTOUT_CONTROLER( const PRINT_PARAMETERS& prin
} }
/*****************************************************/
bool BOARD_PRINTOUT_CONTROLER::OnPrintPage( int page ) bool BOARD_PRINTOUT_CONTROLER::OnPrintPage( int page )
/*****************************************************/
{ {
int layers_count = NB_LAYERS; int layers_count = NB_LAYERS;
if( m_Parent->m_Ident == GERBER_FRAME ) if( m_Parent->IsType( GERBER_FRAME ) )
layers_count = 32; layers_count = 32;
int mask_layer = m_PrintParams.m_PrintMaskLayer; int mask_layer = m_PrintParams.m_PrintMaskLayer;
...@@ -65,15 +87,18 @@ bool BOARD_PRINTOUT_CONTROLER::OnPrintPage( int page ) ...@@ -65,15 +87,18 @@ bool BOARD_PRINTOUT_CONTROLER::OnPrintPage( int page )
if( m_PrintParams.m_OptionPrintPage == 0 ) // One page per layer if( m_PrintParams.m_OptionPrintPage == 0 ) // One page per layer
{ {
int ii, jj, mask = 1; int ii, jj, mask = 1;
for( ii = 0, jj = 0; ii < layers_count; ii++ ) for( ii = 0, jj = 0; ii < layers_count; ii++ )
{ {
if( mask_layer & mask ) if( mask_layer & mask )
jj++; jj++;
if( jj == page ) if( jj == page )
{ {
m_PrintParams.m_PrintMaskLayer = mask; m_PrintParams.m_PrintMaskLayer = mask;
break; break;
} }
mask <<= 1; mask <<= 1;
} }
} }
...@@ -148,7 +173,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -148,7 +173,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
// In module editor, the module is located at 0,0 but for printing // In module editor, the module is located at 0,0 but for printing
// it is moved to SheetSize.x/2, SheetSize.y/2. // it is moved to SheetSize.x/2, SheetSize.y/2.
// So the equivalent board must be moved: // 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; wxPoint mv_offset;
mv_offset.x = SheetSize.x / 2; 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