Commit 48b2661b authored by Wayne Stambaugh's avatar Wayne Stambaugh

EESchema dead code removal and other minor changes.

* Move code from function ClearProjectDrawList() into SCH_SCREEN object
  Clear() method.
* Delete eeschema/delsheet.cpp as none of the code in it is ever called.
* Move global spice and net list command line variables into SCH_EDIT_FRAME
  object as priviate members and provide access methods.
* Remove unnecessary header includes from eeschema/sheet.cpp.
* Minor coding policy fixes.
parent 182d3d4d
......@@ -25,7 +25,6 @@ set(EESCHEMA_SRCS
cross-probing.cpp
dangling_ends.cpp
database.cpp
delsheet.cpp
dialogs/dialog_color_config.cpp
dialogs/dialog_plot_schematic_DXF.cpp
dialogs/dialog_plot_schematic_DXF_base.cpp
......
/****************/
/* delsheet.cpp */
/****************/
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "confirm.h"
#include "class_sch_screen.h"
#include "wxEeschemaStruct.h"
#include "general.h"
#include "protos.h"
#include "sch_sheet.h"
/* Free (delete) all schematic data (include the sub hierarchy sheets )
* for the hierarchical sheet FirstSheet
* FirstSheet is not deleted.
*/
void DeleteSubHierarchy( SCH_SHEET* FirstSheet, bool confirm_deletion )
{
EDA_ITEM* DrawStruct;
EDA_ITEM* EEDrawList;
wxString msg;
SCH_EDIT_FRAME* frame;
frame = (SCH_EDIT_FRAME*)wxGetApp().GetTopWindow();
if( FirstSheet == NULL )
return;
if( FirstSheet->Type() != SCH_SHEET_T )
{
DisplayError( NULL, wxT( "DeleteSubHierarchy error(): NOT a Sheet" ) );
return;
}
if( FirstSheet->GetScreen()->IsModify() && confirm_deletion )
{
msg.Printf( _( "Sheet %s (file %s) modified. Save it?" ),
FirstSheet->m_SheetName.GetData(),
FirstSheet->GetFileName().GetData() );
if( IsOK( NULL, msg ) )
{
frame->SaveEEFile( FirstSheet->GetScreen(), FILE_SAVE_AS );
}
}
/* free the sub hierarchy */
if( FirstSheet->GetScreen() )
{
EEDrawList = FirstSheet->GetScreen()->GetDrawItems();
while( EEDrawList != NULL )
{
DrawStruct = EEDrawList;
EEDrawList = EEDrawList->Next();
if( DrawStruct->Type() == SCH_SHEET_T )
{
DeleteSubHierarchy( (SCH_SHEET*) DrawStruct, confirm_deletion );
}
}
FirstSheet->GetScreen()->FreeDrawList();
}
}
/* free the draw list screen->EEDrawList and the subhierarchies
* clear the screen datas (filenames ..)
*/
bool ClearProjectDrawList( SCH_SCREEN* screen, bool confirm_deletion )
{
if( screen == NULL )
return TRUE;
screen->FreeDrawList();
/* Clear the screen datas */
screen->m_ScreenNumber = screen->m_NumberOfScreen = 1;
screen->m_Title.Empty();
screen->m_Revision.Empty();
screen->m_Company.Empty();
screen->m_Commentaire1.Empty();
screen->m_Commentaire2.Empty();
screen->m_Commentaire3.Empty();
screen->m_Commentaire4.Empty();
screen->m_Date = GenDate();
return TRUE;
}
......@@ -10,6 +10,9 @@ class wxStaticLine;
class wxStdDialogButtonSizer;
extern void SeedLayers();
// Specify the width and height of every (color-displaying / bitmap) button
const int BUTT_SIZE_X = 16;
const int BUTT_SIZE_Y = 16;
......
......@@ -17,7 +17,7 @@
#include "general.h"
#include "protos.h"
#include "hotkeys.h"
#include "dialogs/dialog_color_config.h"
#include "transform.h"
#include <wx/snglinst.h>
......@@ -48,12 +48,6 @@ const wxString CompLibFileExtension( wxT( "lib" ) );
const wxString SymbolFileWildcard( wxT( "Kicad drawing symbol file (*.sym)|*.sym" ) );
const wxString CompLibFileWildcard( wxT( "Kicad component library file (*.lib)|*.lib" ) );
// command line to call the simulator (gnucap, spice..)
wxString g_SimulatorCommandLine;
// command line to call the simulator net lister (gnucap, spice..)
wxString g_NetListerCommandLine;
LayerStruct g_LayerDescr; /* layer colors. */
bool g_EditPinByPinIsOn = false; /* true to do not synchronize pins
......@@ -138,7 +132,7 @@ bool WinEDA_App::OnInit()
frame = new SCH_EDIT_FRAME( NULL, wxT( "EESchema" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) );
SetTopWindow( frame );
frame->Show( TRUE );
frame->Show( true );
if( CreateServer( frame, KICAD_SCH_PORT_SERVICE_NUMBER ) )
{
......@@ -147,7 +141,7 @@ bool WinEDA_App::OnInit()
SetupServerFunction( RemoteCommand );
}
frame->Zoom_Automatique( TRUE );
frame->Zoom_Automatique( true );
/* Load file specified in the command line. */
if( filename.IsOk() )
......@@ -156,6 +150,7 @@ bool WinEDA_App::OnInit()
if( filename.GetExt() != SchematicFileExtension )
filename.SetExt( SchematicFileExtension );
wxSetWorkingDirectory( filename.GetPath() );
if( frame->LoadOneEEProject( filename.GetFullPath(), false ) )
......@@ -164,9 +159,9 @@ bool WinEDA_App::OnInit()
else
{
// Read a default config file if no file to load.
frame->LoadProjectFile( wxEmptyString, TRUE );
frame->DrawPanel->Refresh( TRUE );
frame->LoadProjectFile( wxEmptyString, true );
frame->DrawPanel->Refresh( true );
}
return TRUE;
return true;
}
......@@ -589,7 +589,7 @@ void SCH_EDIT_FRAME::LoadSettings()
// Load netlists options:
cfg->Read( SpiceNetNamesEntry, &g_OptNetListUseNames, false );
cfg->Read( SimulatorCommandEntry, &g_SimulatorCommandLine );
cfg->Read( SimulatorCommandEntry, &m_simulatorCommand );
/* Load find dialog session setting. */
cfg->Read( FindDialogPositionXEntry, &tmp, -1 );
......@@ -675,7 +675,7 @@ void SCH_EDIT_FRAME::SaveSettings()
// Save netlists options:
cfg->Write( SpiceNetNamesEntry, g_OptNetListUseNames );
cfg->Write( SimulatorCommandEntry, g_SimulatorCommandLine );
cfg->Write( SimulatorCommandEntry, m_simulatorCommand );
/* Save find dialog session setting. */
cfg->Write( FindDialogPositionXEntry, m_findDialogPosition.x );
......
......@@ -146,9 +146,6 @@ extern const wxString SymbolFileWildcard;
extern const wxString CompLibFileExtension;
extern const wxString CompLibFileWildcard;
extern wxString g_SimulatorCommandLine;
extern wxString g_NetListerCommandLine;
extern LayerStruct g_LayerDescr;
extern bool g_EditPinByPinIsOn; /* True to prevent displacing
......
......@@ -422,17 +422,16 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam
break;
// If user provided no plugin command line, return now.
if( g_NetListerCommandLine.IsEmpty() )
if( m_netListerCommand.IsEmpty() )
break;
// build full command line from user's format string, e.g.:
// "xsltproc -o %O /usr/local/lib/kicad/plugins/netlist_form_pads-pcb.xsl %I"
// becomes, after the user selects /tmp/s1.net as the output file from the file dialog:
// "xsltproc -o /tmp/s1.net /usr/local/lib/kicad/plugins/netlist_form_pads-pcb.xsl /tmp/s1.tmp"
wxString commandLine = EXPORT_HELP::MakeCommandLine(
g_NetListerCommandLine,
tmpFile.GetFullPath(),
aFullFileName );
wxString commandLine = EXPORT_HELP::MakeCommandLine( m_netListerCommand,
tmpFile.GetFullPath(),
aFullFileName );
D(printf("commandLine:'%s'\n", TO_UTF8( commandLine ) );)
......
......@@ -262,7 +262,7 @@ void NETLIST_DIALOG::InstallPageSpice()
page->m_CommandStringCtrl = new WinEDA_EnterText( page,
_( "Simulator command:" ),
g_SimulatorCommandLine,
m_Parent->GetSimulatorCommand(),
page->m_LowBoxSizer,
wxDefaultSize );
......@@ -436,7 +436,7 @@ void NETLIST_DIALOG::NetlistUpdateOpt()
{
int ii;
g_SimulatorCommandLine = m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->GetValue();
m_Parent->SetSimulatorCommand( m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->GetValue() );
m_Parent->m_NetlistFormat = NET_TYPE_PCBNEW;
for( ii = 0; ii < PANELCUSTOMBASE + CUSTOMPANEL_COUNTMAX; ii++ )
......@@ -512,13 +512,14 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event )
m_Parent->ClearMsgPanel();
if( CurrPage->m_CommandStringCtrl )
g_NetListerCommandLine = CurrPage->m_CommandStringCtrl->GetValue();
m_Parent->SetNetListerCommand( CurrPage->m_CommandStringCtrl->GetValue() );
else
g_NetListerCommandLine.Empty();
m_Parent->SetNetListerCommand( wxEmptyString );
bool addSubPrefix = false;
if( CurrPage->m_AddSubPrefix )
addSubPrefix = CurrPage->m_AddSubPrefix->GetValue();
m_Parent->CreateNetlist( CurrPage->m_IdNetType, dlg.GetPath(), g_OptNetListUseNames,
addSubPrefix );
......@@ -592,12 +593,12 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event )
wxFileName fn;
wxString ExecFile, CommandLine;
g_SimulatorCommandLine = m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->GetValue();
g_SimulatorCommandLine.Trim( false );
g_SimulatorCommandLine.Trim( true );
ExecFile = g_SimulatorCommandLine.BeforeFirst( ' ' );
CommandLine = g_SimulatorCommandLine.AfterFirst( ' ' );
wxString tmp = m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->GetValue();
tmp.Trim( false );
tmp.Trim( true );
m_Parent->SetSimulatorCommand( tmp );
ExecFile = tmp.BeforeFirst( ' ' );
CommandLine = tmp.AfterFirst( ' ' );
/* Calculate the netlist filename */
fn = g_RootSheet->GetScreen()->GetFileName();
......@@ -609,8 +610,10 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event )
CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage();
bool addSubPrefix = false;
if( CurrPage->m_AddSubPrefix )
addSubPrefix = CurrPage->m_AddSubPrefix->GetValue();
if( ! m_Parent->CreateNetlist( CurrPage->m_IdNetType, fn.GetFullPath(),
g_OptNetListUseNames,addSubPrefix ) )
return;
......
......@@ -67,8 +67,8 @@ public:
* Only one page can be created with selected = true.
*/
NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title,
int id_NetType, int idCheckBox, int idCreateFile,
bool selected );
int id_NetType, int idCheckBox, int idCreateFile,
bool selected );
~NETLIST_PAGE_DIALOG() { };
};
......
......@@ -32,9 +32,9 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa
bool SegmentIntersect( wxPoint aSegStart, wxPoint aSegEnd, wxPoint aTestPoint );
/****************/
/*************************/
/* BUS_WIRE_JUNCTION.CPP */
/****************/
/*************************/
void IncrementLabelMember( wxString& name );
......@@ -58,22 +58,21 @@ void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList );
SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct, bool aClone = false );
/***************/
/****************/
/* EEREDRAW.CPP */
/***************/
/****************/
void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& pos, int Color );
/**************/
/* EELAYER.CPP */
/**************/
void SeedLayers();
/***********************************/
/* dialogs/dialog_color_config.cpp */
/***********************************/
EDA_Colors ReturnLayerColor( int Layer );
/**************/
/***************/
/* NETLIST.CPP */
/**************/
/***************/
int IsBusLabel( const wxString& LabelDrawList );
......@@ -84,25 +83,14 @@ void PlotDrawlist( PLOTTER* plotter, SCH_ITEM* drawlist );
/***************/
/* DELSHEET.CPP */
/***************/
void DeleteSubHierarchy( SCH_SHEET* Sheet, bool confirm_deletion );
bool ClearProjectDrawList( SCH_SCREEN* FirstWindow, bool confirm_deletion );
/* free the draw list screen->GetDrawItems() and the subhierarchies
* clear the screen datas (filenames ..)
*/
/**************/
/* PINEDIT.CPP */
/**************/
/***************/
void InstallPineditFrame( LIB_EDIT_FRAME* parent, wxDC* DC, const wxPoint& pos );
/**************/
/***************/
/* SELPART.CPP */
/**************/
/***************/
/**
* Function DisplayComponentsNamesInLib
......@@ -139,9 +127,9 @@ CMP_LIBRARY* SelectLibraryFromList( EDA_DRAW_FRAME* frame );
*/
int GetNameOfPartToLoad( EDA_DRAW_FRAME* frame, CMP_LIBRARY* Lib, wxString& BufName );
/**************/
/***************/
/* LIBARCH.CPP */
/**************/
/***************/
bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName );
......
......@@ -112,6 +112,23 @@ void SCH_SCREEN::DecRefCount()
}
void SCH_SCREEN::Clear()
{
FreeDrawList();
/* Clear the project settings. */
m_ScreenNumber = m_NumberOfScreen = 1;
m_Title.Empty();
m_Revision.Empty();
m_Company.Empty();
m_Commentaire1.Empty();
m_Commentaire2.Empty();
m_Commentaire3.Empty();
m_Commentaire4.Empty();
m_Date = GenDate();
}
void SCH_SCREEN::FreeDrawList()
{
SCH_ITEM* item;
......
......@@ -418,7 +418,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
&& (g_RootSheet->GetScreen()->GetDrawItems() != NULL) )
UpdateFileHistory( g_RootSheet->GetScreen()->GetFileName() );
ClearProjectDrawList( g_RootSheet->GetScreen(), TRUE );
g_RootSheet->GetScreen()->Clear();
/* all sub sheets are deleted, only the main sheet is usable */
m_CurrentSheet->Clear();
......
......@@ -12,21 +12,16 @@
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "macros.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "gestfich.h"
#include "wxEeschemaStruct.h"
#include "class_sch_screen.h"
#include "general.h"
#include "protos.h"
#include "sch_sheet.h"
#include "dialogs/dialog_sch_sheet_props.h"
#include <boost/foreach.hpp>
bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
{
......
......@@ -87,6 +87,12 @@ public:
*/
void SetCurItem( SCH_ITEM* aItem ) { BASE_SCREEN::SetCurItem( (EDA_ITEM*) aItem ); }
/**
* Function Clear
* deletes all draw items and clears the project settings.
*/
void Clear();
/**
* Free all the items from the schematic associated with the screen.
*
......
......@@ -115,6 +115,10 @@ private:
int m_repeatLabelDelta; ///< Repeat label number increment step.
SCH_COLLECTOR m_collectedItems; ///< List of collected items.
SCH_ITEM* m_undoItem; ///< Copy of the current item being edited.
wxString m_simulatorCommand; ///< Command line used to call the circuit
///< simulator (gnucap, spice, ...)
wxString m_netListerCommand; ///< Command line to call a custom net list
///< generator.
static int m_lastSheetPinType; ///< Last sheet pin type.
static wxSize m_lastSheetPinTextSize; ///< Last sheet pin text size.
......@@ -827,8 +831,7 @@ public:
/**
* Load component libraries defined in project file.
*/
void LoadLibraries( void );
void LoadLibraries( void );
/**
* Function PrintPage
......@@ -841,6 +844,14 @@ public:
virtual void PrintPage( wxDC* aDC, int aPrintMask,
bool aPrintMirrorMode, void* aData = NULL );
void SetSimulatorCommand( const wxString& aCommand ) { m_simulatorCommand = aCommand; }
wxString GetSimulatorCommand() const { return m_simulatorCommand; }
void SetNetListerCommand( const wxString& aCommand ) { m_netListerCommand = aCommand; }
wxString GetNetListerCommand() const { return m_netListerCommand; }
DECLARE_EVENT_TABLE()
};
......
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