Schematic object encapsulation and other minor improvements.

* Encapsulate file name member of base screen object.
* Encapsulate associated screen member of schematic sheet object.
* Create add screen method to schematic sheet object to simplify setting
  the associated screen.
* Move the change file name code in the schematic sheet object to the edit
  sheet method in the schematic editor frame object to eliminate message
  dialogs.
* Improve reference counting in schematic screen object.
* Add helper type definitions for changing schematic object storage to C++
  containers.
This commit is contained in:
Wayne Stambaugh 2011-01-20 11:34:57 -05:00
parent fbeb411632
commit e560573c5e
46 changed files with 377 additions and 350 deletions

View File

@ -602,7 +602,7 @@ void Pcb3D_GLCanvas::SetLights()
*/ */
void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
{ {
wxFileName fn( m_Parent->m_Parent->GetScreen()->m_FileName ); wxFileName fn( m_Parent->m_Parent->GetScreen()->GetFileName() );
wxString FullFileName; wxString FullFileName;
wxString file_ext, mask; wxString file_ext, mask;
bool fmt_is_jpeg = FALSE; bool fmt_is_jpeg = FALSE;
@ -613,7 +613,7 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
{ {
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" ); file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
mask = wxT( "*." ) + file_ext; mask = wxT( "*." ) + file_ext;
FullFileName = m_Parent->m_Parent->GetScreen()->m_FileName; FullFileName = m_Parent->m_Parent->GetScreen()->GetFileName();
fn.SetExt( file_ext ); fn.SetExt( file_ext );
FullFileName = FullFileName =

View File

@ -487,7 +487,7 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
case WS_FILENAME: case WS_FILENAME:
{ {
wxString fname, fext; wxString fname, fext;
wxFileName::SplitPath( screen->m_FileName, wxFileName::SplitPath( screen->GetFileName(),
(wxString*) NULL, (wxString*) NULL,
&fname, &fname,
&fext ); &fext );

View File

@ -1389,10 +1389,11 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen,
case WS_FILENAME: case WS_FILENAME:
{ {
wxString fname, fext; wxString fname, fext;
wxFileName::SplitPath( screen->m_FileName, (wxString*) NULL, wxFileName::SplitPath( screen->GetFileName(), (wxString*) NULL, &fname, &fext );
&fname, &fext );
if( WsItem->m_Legende ) if( WsItem->m_Legende )
msg = WsItem->m_Legende; msg = WsItem->m_Legende;
msg << fname << wxT( "." ) << fext; msg << fname << wxT( "." ) << fext;
DrawGraphicText( DrawPanel, DC, pos, Color, DrawGraphicText( DrawPanel, DC, pos, Color,
msg, TEXT_ORIENT_HORIZ, size, msg, TEXT_ORIENT_HORIZ, size,

View File

@ -36,7 +36,7 @@ void DeleteSubHierarchy( SCH_SHEET* FirstSheet, bool confirm_deletion )
return; return;
} }
if( FirstSheet->m_AssociatedScreen->IsModify() && confirm_deletion ) if( FirstSheet->GetScreen()->IsModify() && confirm_deletion )
{ {
msg.Printf( _( "Sheet %s (file %s) modified. Save it?" ), msg.Printf( _( "Sheet %s (file %s) modified. Save it?" ),
FirstSheet->m_SheetName.GetData(), FirstSheet->m_SheetName.GetData(),
@ -44,14 +44,14 @@ void DeleteSubHierarchy( SCH_SHEET* FirstSheet, bool confirm_deletion )
if( IsOK( NULL, msg ) ) if( IsOK( NULL, msg ) )
{ {
frame->SaveEEFile( FirstSheet->m_AssociatedScreen, FILE_SAVE_AS ); frame->SaveEEFile( FirstSheet->GetScreen(), FILE_SAVE_AS );
} }
} }
/* free the sub hierarchy */ /* free the sub hierarchy */
if( FirstSheet->m_AssociatedScreen ) if( FirstSheet->GetScreen() )
{ {
EEDrawList = FirstSheet->m_AssociatedScreen->GetDrawItems(); EEDrawList = FirstSheet->GetScreen()->GetDrawItems();
while( EEDrawList != NULL ) while( EEDrawList != NULL )
{ {
@ -64,7 +64,7 @@ void DeleteSubHierarchy( SCH_SHEET* FirstSheet, bool confirm_deletion )
} }
} }
FirstSheet->m_AssociatedScreen->FreeDrawList(); FirstSheet->GetScreen()->FreeDrawList();
} }
} }

View File

@ -153,7 +153,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
fn = m_FileNameCtrl->GetValue(); fn = m_FileNameCtrl->GetValue();
if( !fn.IsOk() ) if( !fn.IsOk() )
fn = screen->m_FileName; fn = screen->GetFileName();
fn.SetExt( wxT( "svg" ) ); fn.SetExt( wxT( "svg" ) );
fn.MakeAbsolute(); fn.MakeAbsolute();

View File

@ -277,7 +277,7 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( int aTypeFile,
static wxFileName fn; static wxFileName fn;
wxFileName current = g_RootSheet->m_AssociatedScreen->m_FileName; wxFileName current = g_RootSheet->GetScreen()->GetFileName();
s_ExportSeparatorSymbol = aExportSeparatorSymbol; s_ExportSeparatorSymbol = aExportSeparatorSymbol;

View File

@ -540,7 +540,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
if( m_writeErcFile ) if( m_writeErcFile )
{ {
fn = g_RootSheet->m_AssociatedScreen->m_FileName; fn = g_RootSheet->GetScreen()->GetFileName();
fn.SetExt( wxT( "erc" ) ); fn.SetExt( wxT( "erc" ) );
wxFileDialog dlg( this, _( "ERC File" ), fn.GetPath(), fn.GetFullName(), wxFileDialog dlg( this, _( "ERC File" ), fn.GetPath(), fn.GetFullName(),

View File

@ -66,17 +66,17 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DrawPanel->DrawCursor( DC ); DrawPanel->DrawCursor( DC );
// Display the sheet filename, and the sheet path, for non root sheets // Display the sheet filename, and the sheet path, for non root sheets
if( GetScreen()->m_FileName == m_DefaultSchematicFileName ) if( GetScreen()->GetFileName() == m_DefaultSchematicFileName )
{ {
wxString msg = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); wxString msg = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
title.Printf( wxT( "%s [%s]" ), GetChars( msg), GetChars( GetScreen()->m_FileName ) ); title.Printf( wxT( "%s [%s]" ), GetChars( msg), GetChars( GetScreen()->GetFileName() ) );
SetTitle( title ); SetTitle( title );
} }
else else
{ {
#if 0 #if 0
title = wxT( "[" ); title = wxT( "[" );
title << GetScreen()->m_FileName << wxT( "] " ) << _( "Sheet" ); title << GetScreen()->GetFileName() << wxT( "] " ) << _( "Sheet" );
title << wxT( " " ) << m_CurrentSheet->PathHumanReadable(); title << wxT( " " ) << m_CurrentSheet->PathHumanReadable();
#else #else
@ -85,7 +85,7 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
// Often the /path/to/filedir is blank because of the FullFileName argument // Often the /path/to/filedir is blank because of the FullFileName argument
// passed to LoadOneEEFile() which currently omits the path on non-root schematics. // passed to LoadOneEEFile() which currently omits the path on non-root schematics.
wxFileName t( GetScreen()->m_FileName ); wxFileName t( GetScreen()->GetFileName() );
title = wxChar( '[' ); title = wxChar( '[' );
title << t.GetName() << wxChar( ' ' ); title << t.GetName() << wxChar( ' ' );

View File

@ -64,7 +64,7 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
case ID_CONFIG_READ: case ID_CONFIG_READ:
{ {
fn = g_RootSheet->m_AssociatedScreen->m_FileName; fn = g_RootSheet->GetScreen()->GetFileName();
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
@ -132,7 +132,7 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event )
case ID_CONFIG_READ: case ID_CONFIG_READ:
{ {
fn = g_RootSheet->m_AssociatedScreen->m_FileName; fn = g_RootSheet->GetScreen()->GetFileName();
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
@ -354,7 +354,7 @@ bool SCH_EDIT_FRAME::LoadProjectFile( const wxString& CfgFileName, bool ForceRer
wxArrayString liblist_tmp = m_ComponentLibFiles; wxArrayString liblist_tmp = m_ComponentLibFiles;
if( CfgFileName.IsEmpty() ) if( CfgFileName.IsEmpty() )
fn = g_RootSheet->m_AssociatedScreen->m_FileName; fn = g_RootSheet->GetScreen()->GetFileName();
else else
fn = CfgFileName; fn = CfgFileName;
@ -397,7 +397,7 @@ void SCH_EDIT_FRAME::SaveProjectFile( wxWindow* displayframe, bool askoverwrite
{ {
wxFileName fn; wxFileName fn;
fn = g_RootSheet->m_AssociatedScreen->m_FileName /*ConfigFileName*/; fn = g_RootSheet->GetScreen()->GetFileName(); /*ConfigFileName*/
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
int options = wxFD_SAVE; int options = wxFD_SAVE;

View File

@ -33,13 +33,13 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* screen, int FileSave )
screen = GetScreen(); screen = GetScreen();
/* If no name exists in the window yet - save as new. */ /* If no name exists in the window yet - save as new. */
if( screen->m_FileName.IsEmpty() ) if( screen->GetFileName().IsEmpty() )
FileSave = FILE_SAVE_NEW; FileSave = FILE_SAVE_NEW;
switch( FileSave ) switch( FileSave )
{ {
case FILE_SAVE_AS: case FILE_SAVE_AS:
schematicFileName = screen->m_FileName; schematicFileName = screen->GetFileName();
backupFileName = schematicFileName; backupFileName = schematicFileName;
/* Rename the old file to a '.bak' one: */ /* Rename the old file to a '.bak' one: */
@ -58,13 +58,13 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* screen, int FileSave )
case FILE_SAVE_NEW: case FILE_SAVE_NEW:
{ {
wxFileDialog dlg( this, _( "Schematic Files" ), wxGetCwd(), wxFileDialog dlg( this, _( "Schematic Files" ), wxGetCwd(),
screen->m_FileName, SchematicFileWildcard, screen->GetFileName(), SchematicFileWildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return false; return false;
screen->m_FileName = dlg.GetPath(); screen->SetFileName( dlg.GetPath() );
schematicFileName = dlg.GetPath(); schematicFileName = dlg.GetPath();
break; break;
@ -82,7 +82,7 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* screen, int FileSave )
} }
if( FileSave == FILE_SAVE_NEW ) if( FileSave == FILE_SAVE_NEW )
screen->m_FileName = schematicFileName.GetFullPath(); screen->SetFileName( schematicFileName.GetFullPath() );
bool success = screen->Save( f ); bool success = screen->Save( f );
@ -146,13 +146,15 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew )
if( screen ) if( screen )
{ {
if( !IsOK( this, _( "Clear schematic hierarchy?" ) ) ) if( !IsOK( this, _( "Discard changes to the current schematic?" ) ) )
return false; return false;
if( g_RootSheet->m_AssociatedScreen->m_FileName != m_DefaultSchematicFileName )
SetLastProject( g_RootSheet->m_AssociatedScreen->m_FileName ); if( g_RootSheet->GetScreen()->GetFileName() != m_DefaultSchematicFileName )
SetLastProject( g_RootSheet->GetScreen()->GetFileName() );
} }
FullFileName = FileName; FullFileName = FileName;
if( ( FullFileName.IsEmpty() ) && !IsNew ) if( ( FullFileName.IsEmpty() ) && !IsNew )
{ {
wxFileDialog dlg( this, _( "Open Schematic" ), wxGetCwd(), wxFileDialog dlg( this, _( "Open Schematic" ), wxGetCwd(),
@ -183,7 +185,7 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew )
wxLogDebug( wxT( "Loading schematic " ) + FullFileName ); wxLogDebug( wxT( "Loading schematic " ) + FullFileName );
wxSetWorkingDirectory( fn.GetPath() ); wxSetWorkingDirectory( fn.GetPath() );
screen->m_FileName = FullFileName; screen->SetFileName( FullFileName );
g_RootSheet->SetFileName( FullFileName ); g_RootSheet->SetFileName( FullFileName );
SetStatusText( wxEmptyString ); SetStatusText( wxEmptyString );
ClearMsgPanel(); ClearMsgPanel();
@ -199,7 +201,7 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew )
screen->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); screen->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
screen->m_Title = NAMELESS_PROJECT; screen->m_Title = NAMELESS_PROJECT;
screen->m_Title += wxT( ".sch" ); screen->m_Title += wxT( ".sch" );
GetScreen()->m_FileName = screen->m_Title; GetScreen()->SetFileName( screen->m_Title );
screen->m_Company.Empty(); screen->m_Company.Empty();
screen->m_Commentaire1.Empty(); screen->m_Commentaire1.Empty();
screen->m_Commentaire2.Empty(); screen->m_Commentaire2.Empty();
@ -230,16 +232,17 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew )
* and after (due to code change): <root_name>-cache.lib * and after (due to code change): <root_name>-cache.lib
* so if the <name>-cache.lib is not found, the old way will be tried * so if the <name>-cache.lib is not found, the old way will be tried
*/ */
fn = g_RootSheet->m_AssociatedScreen->m_FileName; fn = g_RootSheet->GetScreen()->GetFileName();
bool use_oldcachename = false; bool use_oldcachename = false;
wxString cachename = fn.GetName() + wxT( "-cache" ); wxString cachename = fn.GetName() + wxT( "-cache" );
fn.SetName( cachename ); fn.SetName( cachename );
fn.SetExt( CompLibFileExtension ); fn.SetExt( CompLibFileExtension );
if( ! fn.FileExists() ) if( ! fn.FileExists() )
{ {
fn = g_RootSheet->m_AssociatedScreen->m_FileName; fn = g_RootSheet->GetScreen()->GetFileName();
fn.SetExt( wxT( "cache.lib" ) ); fn.SetExt( wxT( "cache.lib" ) );
use_oldcachename = true; use_oldcachename = true;
} }
@ -282,18 +285,17 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew )
PrintMsg( msg ); PrintMsg( msg );
} }
if( !wxFileExists( g_RootSheet->m_AssociatedScreen->m_FileName ) if( !wxFileExists( g_RootSheet->GetScreen()->GetFileName() ) && !LibCacheExist )
&& !LibCacheExist )
{ {
Zoom_Automatique( FALSE ); Zoom_Automatique( FALSE );
msg.Printf( _( "File <%s> not found." ), msg.Printf( _( "File <%s> not found." ),
GetChars( g_RootSheet->m_AssociatedScreen->m_FileName ) ); GetChars( g_RootSheet->GetScreen()->GetFileName() ) );
DisplayInfoMessage( this, msg, 0 ); DisplayInfoMessage( this, msg, 0 );
return false; return false;
} }
// load the project. // load the project.
SAFE_DELETE( g_RootSheet->m_AssociatedScreen ); g_RootSheet->SetScreen( NULL );
bool diag = g_RootSheet->Load( this ); bool diag = g_RootSheet->Load( this );
/* Redraw base screen (ROOT) if necessary. */ /* Redraw base screen (ROOT) if necessary. */
@ -318,7 +320,7 @@ void SCH_EDIT_FRAME::SaveProject()
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
{ {
D( printf( "SaveEEFile, %s\n", CONV_TO_UTF8( screen->m_FileName ) ); ) D( printf( "SaveEEFile, %s\n", CONV_TO_UTF8( screen->GetFileName() ) ); )
SaveEEFile( screen, FILE_SAVE_AS ); SaveEEFile( screen, FILE_SAVE_AS );
} }

View File

@ -49,7 +49,7 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFile
return FALSE; return FALSE;
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
screen->m_FileName = FullFileName; screen->SetFileName( FullFileName );
// D(printf("LoadOneEEFile:%s\n", CONV_TO_UTF8( FullFileName ) ); ) // D(printf("LoadOneEEFile:%s\n", CONV_TO_UTF8( FullFileName ) ); )
@ -64,7 +64,7 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFile
// reader now owns the open FILE. // reader now owns the open FILE.
FILE_LINE_READER reader( f, FullFileName ); FILE_LINE_READER reader( f, FullFileName );
MsgDiag = _( "Loading " ) + screen->m_FileName; MsgDiag = _( "Loading " ) + screen->GetFileName();
PrintMsg( MsgDiag ); PrintMsg( MsgDiag );
if( !reader.ReadLine() if( !reader.ReadLine()
@ -223,7 +223,7 @@ again." );
TestDanglingEnds( screen->GetDrawItems(), NULL ); TestDanglingEnds( screen->GetDrawItems(), NULL );
MsgDiag = _( "Done Loading " ) + screen->m_FileName; MsgDiag = _( "Done Loading " ) + screen->GetFileName();
PrintMsg( MsgDiag ); PrintMsg( MsgDiag );
return true; // Although it may be that file is only partially loaded. return true; // Although it may be that file is only partially loaded.

View File

@ -646,7 +646,7 @@ XNODE* EXPORT_HELP::makeGenericDesignHeader()
DateAndTime( date ); DateAndTime( date );
// the root sheet is a special sheet, call it source // the root sheet is a special sheet, call it source
xdesign->AddChild( node( wxT( "source" ), g_RootSheet->m_AssociatedScreen->m_FileName ) ); xdesign->AddChild( node( wxT( "source" ), g_RootSheet->GetScreen()->GetFileName() ) );
xdesign->AddChild( node( wxT( "date" ), CONV_FROM_UTF8( date )) ); xdesign->AddChild( node( wxT( "date" ), CONV_FROM_UTF8( date )) );

View File

@ -452,7 +452,7 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event )
CurrPage = (EDA_NoteBookPage*) m_NoteBook->GetCurrentPage(); CurrPage = (EDA_NoteBookPage*) m_NoteBook->GetCurrentPage();
/* Calculate the netlist filename */ /* Calculate the netlist filename */
fn = g_RootSheet->m_AssociatedScreen->m_FileName; fn = g_RootSheet->GetScreen()->GetFileName();
switch( CurrPage->m_IdNetType ) switch( CurrPage->m_IdNetType )
{ {
@ -571,7 +571,7 @@ void WinEDA_NetlistFrame::RunSimulator( wxCommandEvent& event )
CommandLine = g_SimulatorCommandLine.AfterFirst( ' ' ); CommandLine = g_SimulatorCommandLine.AfterFirst( ' ' );
/* Calculate the netlist filename */ /* Calculate the netlist filename */
fn = g_RootSheet->m_AssociatedScreen->m_FileName; fn = g_RootSheet->GetScreen()->GetFileName();
fn.SetExt( wxT( "cir" ) ); fn.SetExt( wxT( "cir" ) );
CommandLine += wxT( " \"" ) + fn.GetFullPath() + wxT( "\"" ); CommandLine += wxT( " \"" ) + fn.GetFullPath() + wxT( "\"" );

View File

@ -311,7 +311,7 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
wxPoint pos_sheetname, pos_filename; wxPoint pos_sheetname, pos_filename;
wxPoint pos; wxPoint pos;
plotter->set_color( ReturnLayerColor( Struct->m_Layer ) ); plotter->set_color( ReturnLayerColor( Struct->GetLayer() ) );
int thickness = Struct->GetPenSize(); int thickness = Struct->GetPenSize();
plotter->set_current_line_width( thickness ); plotter->set_current_line_width( thickness );
@ -370,7 +370,7 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP,
thickness, italic, false ); thickness, italic, false );
plotter->set_color( ReturnLayerColor( Struct->m_Layer ) ); plotter->set_color( ReturnLayerColor( Struct->GetLayer() ) );
/* Draw texts : SheetLabel */ /* Draw texts : SheetLabel */
BOOST_FOREACH( SCH_SHEET_PIN & pin_sheet, Struct->GetSheetPins() ) { BOOST_FOREACH( SCH_SHEET_PIN & pin_sheet, Struct->GetSheetPins() ) {

View File

@ -1,10 +1,10 @@
/** /**
* @file sch_items.h * @file sch_junction.h
* *
*/ */
#ifndef _SCH_ITEMS_H_ #ifndef _SCH_JUNCTION_H_
#define _SCH_ITEMS_H_ #define _SCH_JUNCTION_H_
#include "sch_item_struct.h" #include "sch_item_struct.h"
@ -103,4 +103,4 @@ private:
}; };
#endif // _SCH_ITEMS_H_ #endif // _SCH_JUNCTION_H_

View File

@ -88,11 +88,23 @@ SCH_SCREEN::~SCH_SCREEN()
} }
void SCH_SCREEN::IncRefCount()
{
m_refCount++;
wxLogDebug( wxT("Screen %s reference count after increment is %d." ),
GetChars( GetFileName() ), m_refCount );
}
void SCH_SCREEN::DecRefCount() void SCH_SCREEN::DecRefCount()
{ {
wxCHECK_RET( m_refCount != 0, wxCHECK_RET( m_refCount != 0,
wxT( "Screen reference count already zero. Bad programmer!" ) ); wxT( "Screen reference count already zero. Bad programmer!" ) );
m_refCount--; m_refCount--;
wxLogDebug( wxT("Screen %s reference count after decrement is %d." ),
GetChars( GetFileName() ), m_refCount );
} }
@ -736,7 +748,7 @@ void SCH_SCREENS::BuildScreenList( EDA_ITEM* aItem )
if( aItem && aItem->Type() == SCH_SHEET_T ) if( aItem && aItem->Type() == SCH_SHEET_T )
{ {
SCH_SHEET* ds = (SCH_SHEET*) aItem; SCH_SHEET* ds = (SCH_SHEET*) aItem;
aItem = ds->m_AssociatedScreen; aItem = ds->GetScreen();
} }
if( aItem && aItem->Type() == SCH_SCREEN_T ) if( aItem && aItem->Type() == SCH_SCREEN_T )

View File

@ -3,7 +3,7 @@
// Purpose: member functions for SCH_SHEET // Purpose: member functions for SCH_SHEET
// header = sch_sheet.h // header = sch_sheet.h
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Modified by: // Modified by: Wayne Stambaugh
// Created: 08/02/2006 18:37:02 // Created: 08/02/2006 18:37:02
// RCS-ID: // RCS-ID:
// Copyright: // Copyright:
@ -16,7 +16,6 @@
#include "macros.h" #include "macros.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "drawtxt.h" #include "drawtxt.h"
#include "confirm.h"
#include "trigo.h" #include "trigo.h"
#include "richio.h" #include "richio.h"
#include "class_sch_screen.h" #include "class_sch_screen.h"
@ -29,7 +28,8 @@
#include "sch_component.h" #include "sch_component.h"
SCH_SHEET::SCH_SHEET( const wxPoint& pos ) : SCH_ITEM( NULL, SCH_SHEET_T ) SCH_SHEET::SCH_SHEET( const wxPoint& pos ) :
SCH_ITEM( NULL, SCH_SHEET_T )
{ {
m_Layer = LAYER_SHEET; m_Layer = LAYER_SHEET;
m_Pos = pos; m_Pos = pos;
@ -69,7 +69,7 @@ SCH_SHEET::~SCH_SHEET()
// perhaps it should be deleted also. // perhaps it should be deleted also.
if( m_AssociatedScreen ) if( m_AssociatedScreen )
{ {
m_AssociatedScreen->GetRefCount(); m_AssociatedScreen->DecRefCount();
if( m_AssociatedScreen->GetRefCount() == 0 ) if( m_AssociatedScreen->GetRefCount() == 0 )
delete m_AssociatedScreen; delete m_AssociatedScreen;
@ -83,6 +83,38 @@ EDA_ITEM* SCH_SHEET::doClone() const
} }
void SCH_SHEET::SetScreen( SCH_SCREEN* aScreen )
{
if( aScreen == m_AssociatedScreen )
return;
if( m_AssociatedScreen != NULL )
{
m_AssociatedScreen->DecRefCount();
if( m_AssociatedScreen->GetRefCount() == 0 )
{
delete m_AssociatedScreen;
m_AssociatedScreen = NULL;
}
}
m_AssociatedScreen = aScreen;
if( m_AssociatedScreen )
m_AssociatedScreen->IncRefCount();
}
int SCH_SHEET::GetScreenCount() const
{
if( m_AssociatedScreen == NULL )
return 0;
return m_AssociatedScreen->GetRefCount();
}
bool SCH_SHEET::Save( FILE* aFile ) const bool SCH_SHEET::Save( FILE* aFile ) const
{ {
if( fprintf( aFile, "$Sheet\n" ) == EOF if( fprintf( aFile, "$Sheet\n" ) == EOF
@ -380,9 +412,7 @@ bool SCH_SHEET::HasUndefinedLabels()
void SCH_SHEET::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) void SCH_SHEET::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
{ {
/* Place list structures for new sheet. */ /* Place list structures for new sheet. */
bool isnew = ( m_Flags & IS_NEW ) ? true : false; if( IsNew() )
if( isnew )
{ {
if( !frame->EditSheet( this, DC ) ) if( !frame->EditSheet( this, DC ) )
{ {
@ -413,7 +443,7 @@ void SCH_SHEET::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
SCH_ITEM::Place( frame, DC ); //puts it on the GetDrawItems(). SCH_ITEM::Place( frame, DC ); //puts it on the GetDrawItems().
if( isnew ) if( IsNew() )
{ {
frame->SetSheetNumberAndCount(); frame->SetSheetNumberAndCount();
} }
@ -621,28 +651,30 @@ int SCH_SHEET::ComponentCount()
} }
bool SCH_SHEET::SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen ) bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen )
{ {
if( m_AssociatedScreen ) if( m_AssociatedScreen )
{ {
EDA_ITEM* strct = m_AssociatedScreen->GetDrawItems(); EDA_ITEM* item = m_AssociatedScreen->GetDrawItems();
while( strct ) while( item )
{ {
if( strct->Type() == SCH_SHEET_T ) if( item->Type() == SCH_SHEET_T )
{ {
SCH_SHEET* ss = (SCH_SHEET*) strct; SCH_SHEET* sheet = (SCH_SHEET*) item;
if( ss->m_AssociatedScreen
&& ss->m_AssociatedScreen->m_FileName.CmpNoCase( aFilename ) == 0 ) if( sheet->m_AssociatedScreen
&& sheet->m_AssociatedScreen->GetFileName().CmpNoCase( aFilename ) == 0 )
{ {
*aScreen = ss->m_AssociatedScreen; *aScreen = sheet->m_AssociatedScreen;
return true; return true;
} }
if( ss->SearchHierarchy( aFilename, aScreen ) ) if( sheet->SearchHierarchy( aFilename, aScreen ) )
return true; return true;
} }
strct = strct->Next();
item = item->Next();
} }
} }
@ -691,15 +723,13 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
if( screen ) if( screen )
{ {
m_AssociatedScreen = screen; SetScreen( screen );
m_AssociatedScreen->IncRefCount();
//do not need to load the sub-sheets - this has already been done. //do not need to load the sub-sheets - this has already been done.
} }
else else
{ {
m_AssociatedScreen = new SCH_SCREEN(); SetScreen( new SCH_SCREEN() );
m_AssociatedScreen->IncRefCount();
success = aFrame->LoadOneEEFile( m_AssociatedScreen, m_FileName ); success = aFrame->LoadOneEEFile( m_AssociatedScreen, m_FileName );
if( success ) if( success )
@ -753,109 +783,6 @@ wxString SCH_SHEET::GetFileName( void )
} }
bool SCH_SHEET::ChangeFileName( SCH_EDIT_FRAME* aFrame, const wxString& aFileName )
{
if( ( GetFileName() == aFileName ) && m_AssociatedScreen )
return true;
SCH_SCREEN* Screen_to_use = NULL;
wxString msg;
bool LoadFromFile = false;
// do we reload the data from the existing hierarchy
if( g_RootSheet->SearchHierarchy( aFileName, &Screen_to_use ) )
{
if( m_AssociatedScreen ) // upon initial load, this will be null.
{
msg.Printf( _( "A Sub Hierarchy named %s exists, Use it (The \
data in this sheet will be replaced)?" ),
GetChars( aFileName ) );
if( !IsOK( NULL, msg ) )
{
DisplayInfoMessage( (wxWindow*) NULL, _( "Sheet Filename Renaming Aborted" ) );
return false;
}
}
}
else if( wxFileExists( aFileName ) ) // do we reload the data from an existing file
{
msg.Printf( _( "A file named %s exists, load it (otherwise keep \
current sheet data if possible)?" ),
GetChars( aFileName ) );
if( IsOK( NULL, msg ) )
{
LoadFromFile = true;
// Can be NULL if loading a file when creating a new sheet.
if( m_AssociatedScreen )
{
m_AssociatedScreen->DecRefCount(); // be careful with these
if( m_AssociatedScreen->GetRefCount() == 0 )
SAFE_DELETE( m_AssociatedScreen );
m_AssociatedScreen = NULL; // will be created later
}
}
}
// if an associated screen exists, shared between this sheet and others
// sheets, what we do ?
if( m_AssociatedScreen && ( m_AssociatedScreen->GetRefCount() > 1 ) )
{
msg = _( "This sheet uses shared data in a complex hierarchy" );
msg << wxT( "\n" );
msg << _( "Do we convert it in a simple hierarchical sheet (\
otherwise delete current sheet data)" );
if( IsOK( NULL, msg ) )
{
LoadFromFile = true;
wxString oldfilename = m_AssociatedScreen->m_FileName;
m_AssociatedScreen->m_FileName = aFileName;
aFrame->SaveEEFile( m_AssociatedScreen, FILE_SAVE_AS );
m_AssociatedScreen->m_FileName = oldfilename;
}
m_AssociatedScreen->DecRefCount(); //be careful with these
m_AssociatedScreen = NULL; //will be created later
}
SetFileName( aFileName );
// if we use new data (from file or from internal hierarchy), delete the
// current sheet data
if( m_AssociatedScreen && (LoadFromFile || Screen_to_use) )
{
m_AssociatedScreen->DecRefCount();
if( m_AssociatedScreen->GetRefCount() == 0 )
SAFE_DELETE( m_AssociatedScreen );
m_AssociatedScreen = NULL; // so that we reload..
}
if( LoadFromFile )
Load( aFrame );
else if( Screen_to_use )
{
m_AssociatedScreen = Screen_to_use;
m_AssociatedScreen->IncRefCount();
}
//just make a new screen if needed.
if( !m_AssociatedScreen )
{
m_AssociatedScreen = new SCH_SCREEN();
m_AssociatedScreen->IncRefCount(); // be careful with these
}
m_AssociatedScreen->m_FileName = aFileName;
return true;
}
void SCH_SHEET::DisplayInfo( WinEDA_DrawFrame* frame ) void SCH_SHEET::DisplayInfo( WinEDA_DrawFrame* frame )
{ {
frame->ClearMsgPanel(); frame->ClearMsgPanel();

View File

@ -80,11 +80,6 @@ public:
virtual void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, virtual void CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& aPos ); const wxPoint& aPos );
SCH_SHEET_PIN* Next()
{
return (SCH_SHEET_PIN*) Pnext;
}
void SwapData( SCH_SHEET_PIN* copyitem ); void SwapData( SCH_SHEET_PIN* copyitem );
/** /**
@ -202,19 +197,19 @@ typedef boost::ptr_vector<SCH_SHEET_PIN> SCH_SHEET_PIN_LIST;
class SCH_SHEET : public SCH_ITEM class SCH_SHEET : public SCH_ITEM
{ {
public: SCH_SCREEN* m_AssociatedScreen; ///< Screen that contains the physical data for
wxString m_SheetName; /* this is equivalent to C101 for ///< the sheet. In complex hierarchies multiple
* components: it is stored in F0 ... ///< sheets can share a common screen.
* of the file. */ SCH_SHEET_PIN_LIST m_labels; ///< List of sheet connection points.
private:
wxString m_FileName; /* also in SCH_SCREEN (redundant), wxString m_FileName; /* also in SCH_SCREEN (redundant),
* but need it here for loading after * but need it here for loading after
* reading the sheet description from * reading the sheet description from
* file. */ * file. */
protected: public:
SCH_SHEET_PIN_LIST m_labels; /* List of points to be connected.*/ wxString m_SheetName; /* this is equivalent to C101 for
* components: it is stored in F0 ...
* of the file. */
public: public:
int m_SheetNameSize; /* Size (height) of the text, used to int m_SheetNameSize; /* Size (height) of the text, used to
* draw the sheet name */ * draw the sheet name */
@ -222,13 +217,6 @@ public:
* draw the file name */ * draw the file name */
wxPoint m_Pos; wxPoint m_Pos;
wxSize m_Size; /* Position and Size of *sheet symbol */ wxSize m_Size; /* Position and Size of *sheet symbol */
int m_Layer;
SCH_SCREEN* m_AssociatedScreen; /* Associated Screen which
* handle the physical data
* In complex hierarchies we
* can have many SCH_SHEET
* using the same data
*/
public: public:
SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) ); SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) );
@ -242,6 +230,29 @@ public:
return wxT( "SCH_SHEET" ); return wxT( "SCH_SHEET" );
} }
SCH_SCREEN* GetScreen() { return m_AssociatedScreen; }
/**
* Function SetScreen
* sets the screen associated with this sheet to \a aScreen.
* <p>
* The screen reference counting is performed by SetScreen. If \a aScreen is not
* the same as the current screen, the current screen reference count is decremented
* and \a aScreen becomes the screen for the sheet. If the current screen reference
* count reaches zero, the current screen is deleted. NULL is a valid value for
* \a aScreen.
* </p>
* @param aScreen The new screen to associate with the sheet.
*/
void SetScreen( SCH_SCREEN* aScreen );
/**
* Function GetScreenCount
* returns the number of times the associated screen for the sheet is being used. If
* no screen is associated with the sheet, then zero is returned.
*/
int GetScreenCount() const;
/** /**
* Function Save * Function Save
* writes the data structures for this object out to a FILE in "*.sch" * writes the data structures for this object out to a FILE in "*.sch"
@ -385,7 +396,7 @@ public:
* @param aScreen = a location to return a pointer to the screen (if found) * @param aScreen = a location to return a pointer to the screen (if found)
* @return bool if found, and a pointer to the screen * @return bool if found, and a pointer to the screen
*/ */
bool SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen ); bool SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen );
/** /**
* Function LocatePathOfScreen * Function LocatePathOfScreen
@ -421,17 +432,6 @@ public:
m_FileName = aFilename; m_FileName = aFilename;
} }
/**
* Function ChangeFileName
* Set a new filename and manage data and associated screen
* The main difficulty is the filename change in a complex hierarchy.
* - if new filename is not already used: change to the new name (and if an
* existing file is found, load it on request)
* - if new filename is already used (a complex hierarchy) : reference the
* sheet.
* @param aFileName = the new filename
* @param aFrame = the schematic frame
*/
bool ChangeFileName( SCH_EDIT_FRAME* aFrame, const wxString& aFileName ); bool ChangeFileName( SCH_EDIT_FRAME* aFrame, const wxString& aFileName );
//void RemoveSheet(SCH_SHEET* sheet); //void RemoveSheet(SCH_SHEET* sheet);

View File

@ -131,7 +131,7 @@ SCH_SCREEN* SCH_SHEET_PATH::LastScreen()
SCH_SHEET* lastSheet = Last(); SCH_SHEET* lastSheet = Last();
if( lastSheet ) if( lastSheet )
return lastSheet->m_AssociatedScreen; return lastSheet->GetScreen();
return NULL; return NULL;
} }
@ -146,8 +146,8 @@ SCH_ITEM* SCH_SHEET_PATH::LastDrawList()
{ {
SCH_SHEET* lastSheet = Last(); SCH_SHEET* lastSheet = Last();
if( lastSheet && lastSheet->m_AssociatedScreen ) if( lastSheet && lastSheet->GetScreen() )
return lastSheet->m_AssociatedScreen->GetDrawItems(); return lastSheet->GetScreen()->GetDrawItems();
return NULL; return NULL;
} }
@ -157,8 +157,8 @@ SCH_ITEM* SCH_SHEET_PATH::FirstDrawList()
{ {
SCH_ITEM* item = NULL; SCH_ITEM* item = NULL;
if( m_numSheets && m_sheets[0]->m_AssociatedScreen ) if( m_numSheets && m_sheets[0]->GetScreen() )
item = m_sheets[0]->m_AssociatedScreen->GetDrawItems(); item = m_sheets[0]->GetScreen()->GetDrawItems();
/* @fixme - These lists really should be one of the boost pointer containers. This /* @fixme - These lists really should be one of the boost pointer containers. This
* is a brain dead hack to allow reverse iteration of EDA_ITEM linked * is a brain dead hack to allow reverse iteration of EDA_ITEM linked
@ -615,7 +615,7 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
m_List[m_index] = m_currList; m_List[m_index] = m_currList;
m_index++; m_index++;
if( aSheet->m_AssociatedScreen != NULL ) if( aSheet->GetScreen() != NULL )
{ {
EDA_ITEM* strct = m_currList.LastDrawList(); EDA_ITEM* strct = m_currList.LastDrawList();

View File

@ -326,14 +326,13 @@ void SCH_EDIT_FRAME::CreateScreens()
g_RootSheet = new SCH_SHEET(); g_RootSheet = new SCH_SHEET();
} }
if( g_RootSheet->m_AssociatedScreen == NULL ) if( g_RootSheet->GetScreen() == NULL )
{ {
g_RootSheet->m_AssociatedScreen = new SCH_SCREEN(); g_RootSheet->SetScreen( new SCH_SCREEN() );
g_RootSheet->m_AssociatedScreen->IncRefCount();
} }
g_RootSheet->m_AssociatedScreen->m_FileName = m_DefaultSchematicFileName; g_RootSheet->GetScreen()->SetFileName( m_DefaultSchematicFileName );
g_RootSheet->m_AssociatedScreen->m_Date = GenDate(); g_RootSheet->GetScreen()->m_Date = GenDate();
m_CurrentSheet->Clear(); m_CurrentSheet->Clear();
m_CurrentSheet->Push( g_RootSheet ); m_CurrentSheet->Push( g_RootSheet );
@ -396,11 +395,11 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
} }
} }
if( !g_RootSheet->m_AssociatedScreen->m_FileName.IsEmpty() if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty()
&& (g_RootSheet->m_AssociatedScreen->GetDrawItems() != NULL) ) && (g_RootSheet->GetScreen()->GetDrawItems() != NULL) )
SetLastProject( g_RootSheet->m_AssociatedScreen->m_FileName ); SetLastProject( g_RootSheet->GetScreen()->GetFileName() );
ClearProjectDrawList( g_RootSheet->m_AssociatedScreen, TRUE ); ClearProjectDrawList( g_RootSheet->GetScreen(), TRUE );
/* all sub sheets are deleted, only the main sheet is usable */ /* all sub sheets are deleted, only the main sheet is usable */
m_CurrentSheet->Clear(); m_CurrentSheet->Clear();
@ -678,7 +677,7 @@ void SCH_EDIT_FRAME::OnLoadProject( wxCommandEvent& event )
void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
{ {
wxFileName fn = g_RootSheet->m_AssociatedScreen->m_FileName; wxFileName fn = g_RootSheet->GetScreen()->GetFileName();
if( fn.IsOk() ) if( fn.IsOk() )
{ {
@ -695,7 +694,7 @@ void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
{ {
wxFileName fn = g_RootSheet->m_AssociatedScreen->m_FileName; wxFileName fn = g_RootSheet->GetScreen()->GetFileName();
fn.SetExt( NetlistFileExtension ); fn.SetExt( NetlistFileExtension );
@ -765,10 +764,11 @@ void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
dlg.ShowModal(); dlg.ShowModal();
fn = g_RootSheet->m_AssociatedScreen->m_FileName; fn = g_RootSheet->GetScreen()->GetFileName();
wxString default_name = NAMELESS_PROJECT; wxString default_name = NAMELESS_PROJECT;
default_name += wxT( ".sch" ); default_name += wxT( ".sch" );
if( fn.GetFullName() != default_name ) if( fn.GetFullName() != default_name )
{ {
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );

View File

@ -33,19 +33,35 @@ static int s_PreviousSheetHeight;
static wxPoint s_OldPos; /* Former position for cancellation or move ReSize */ static wxPoint s_OldPos; /* Former position for cancellation or move ReSize */
/* Routine to edit the SheetName and the FileName for the sheet "Sheet" */ /**
* Function EditSheet
* is used to edit an existing sheet or add a new sheet to the schematic.
* <p>
* When \a aSheet is a new sheet:
* <ul>
* <li>and the file name already exists in the schematic hierarchy, the screen associated with
* the sheet found in the hierarchy is associated with \a aSheet.</li>
* <li>and the file name already exists on the system, then \a aSheet is loaded with the
* existing file.</li>
* <li>and the file name does not exist in the schematic hierarchy or on the file system, then
* a new screen is created and associated with \a aSheet.</li>
* </ul> </p> <p>
* When \a aSheet is an existing sheet:
* <ul>
* <li>and the file name already exists in the schematic hierarchy, the current associated screen
* is replace by the one found in the hierarchy.</li>
* <li>and the file name already exists on the system, the current associated screen file name
* is changed and the file is loaded.</li>
* <li>and the file name does not exist in the schematic hierarchy or on the file system, the
* current associated screen file name is changed and saved to disk.</li>
* </ul> </p>
*/
bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
{ {
bool edit = true;
if( aSheet == NULL ) if( aSheet == NULL )
return false; return false;
/* Get the new texts */ /* Get the new texts */
aSheet->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
DrawPanel->m_IgnoreMouseEvents = true;
DIALOG_SCH_SHEET_PROPS dlg( this ); DIALOG_SCH_SHEET_PROPS dlg( this );
wxString units = GetUnitsLabel( g_UserUnit ); wxString units = GetUnitsLabel( g_UserUnit );
@ -70,76 +86,135 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
dlg.Fit(); dlg.Fit();
dlg.SetMinSize( dlg.GetSize() ); dlg.SetMinSize( dlg.GetSize() );
if( dlg.ShowModal() == wxID_OK ) if( dlg.ShowModal() == wxID_CANCEL )
{ return false;
wxFileName fileName;
wxString msg;
fileName = dlg.GetFileName(); wxFileName fileName = dlg.GetFileName();
fileName.SetExt( SchematicFileExtension );
if( !fileName.IsOk() ) if( !fileName.IsOk() )
{ {
DisplayError( this, _( "File name is not valid! Aborted" ) ); DisplayError( this, _( "File name is not valid!" ) );
edit = false; return false;
} }
else
{
fileName.SetExt( SchematicFileExtension );
/* m_CurrentSheet->m_AssociatedScreen must be a valid screen, and the wxString msg;
* sheet must have a valid associated filename, wxString tmp;
* so we must call m_CurrentSheet->ChangeFileName to set a filename, bool loadFromFile = false;
* AND always when a new sheet is created ( when SCH_SCREEN* useScreen = NULL;
* m_CurrentSheet->m_AssociatedScreen is null ),
* to create or set an Associated Screen
*/
if( ( fileName.GetFullPath() != aSheet->GetFileName() )
|| ( aSheet->m_AssociatedScreen == NULL ) )
{
msg = _( "Changing the sheet file name can change all the schematic \
structures and cannot be undone.\nOk to continue renaming?" );
if( aSheet->m_AssociatedScreen == NULL || IsOK( NULL, msg ) ) if( !g_RootSheet->SearchHierarchy( fileName.GetFullPath(), &useScreen ) )
{ loadFromFile = fileName.FileExists();
// do not prompt on a new sheet. in fact, we should not allow a
// sheet to be created without a valid associated filename to be
// read from.
GetScreen()->ClearUndoRedoList();
// set filename and the associated screen if( aSheet->GetScreen() == NULL ) // New sheet.
aSheet->ChangeFileName( this, fileName.GetFullPath() ); {
if( ( useScreen != NULL ) || loadFromFile ) // Load from existing file.
{
msg.Printf( _( "A file named \"%s\" already exists" ),
GetChars( fileName.GetFullName() ) );
if( useScreen != NULL )
msg += _( " in the current schematic hierarchy" );
msg += _(".\n\nDo you want to create a sheet with the contents of this file?" );
if( !IsOK( this, msg ) )
return false;
}
else // New file.
{
aSheet->SetScreen( new SCH_SCREEN() );
aSheet->GetScreen()->SetFileName( fileName.GetFullPath() );
}
}
else // Existing sheet.
{
bool isUndoable = true;
bool renameFile = false;
if( fileName.GetFullName().CmpNoCase( aSheet->GetFileName() ) != 0 )
{
// Sheet file name changes cannot be undone.
isUndoable = false;
msg = _( "Changing the sheet file name cannot be undone. " );
if( ( useScreen != NULL ) || loadFromFile ) // Load from existing file.
{
tmp.Printf( _( "A file named \"%s\" already exists" ),
GetChars( fileName.GetFullName() ) );
msg += tmp;
if( useScreen != NULL )
msg += _( " in the current schematic hierarchy" );
msg += _(".\n\nDo you want to replace the sheet with the contents of this file?" );
if( !IsOK( this, msg ) )
return false;
if( loadFromFile )
aSheet->SetScreen( NULL );
}
else // Save to new file name.
{
if( aSheet->GetScreenCount() > 1 )
{
msg += _( "This sheet uses shared data in a complex hierarchy.\n\n" );
msg += _( "Do you wish to convert it to a simple hierarchical sheet?" );
if( !IsOK( NULL, msg ) )
return false;
}
renameFile = true;
} }
} }
else aSheet->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
DrawPanel->m_IgnoreMouseEvents = true;
if( isUndoable )
SaveCopyInUndoList( aSheet, UR_CHANGED ); SaveCopyInUndoList( aSheet, UR_CHANGED );
if( renameFile )
{
aSheet->GetScreen()->SetFileName( fileName.GetFullName() );
SaveEEFile( aSheet->GetScreen(), FILE_SAVE_AS );
// If the the associated screen is shared by more than one sheet, remove the
// screen and reload the file to a new screen. Failure to do this will trash
// the screen reference counting in complex hierarchies.
if( aSheet->GetScreenCount() > 1 )
{
aSheet->SetScreen( NULL );
loadFromFile = true;
}
}
}
aSheet->SetFileName( fileName.GetFullPath() );
if( useScreen )
aSheet->SetScreen( useScreen );
else if( loadFromFile )
aSheet->Load( this );
aSheet->m_FileNameSize = ReturnValueFromString( g_UserUnit, aSheet->m_FileNameSize = ReturnValueFromString( g_UserUnit,
dlg.GetFileNameTextSize(), dlg.GetFileNameTextSize(),
m_InternalUnits ); m_InternalUnits );
aSheet->m_SheetName = dlg.GetSheetName(); aSheet->m_SheetName = dlg.GetSheetName();
aSheet->m_SheetNameSize = ReturnValueFromString( g_UserUnit, aSheet->m_SheetNameSize = ReturnValueFromString( g_UserUnit,
dlg.GetSheetNameTextSize(), dlg.GetSheetNameTextSize(),
m_InternalUnits ); m_InternalUnits );
if( aSheet->m_SheetName.IsEmpty() ) if( aSheet->m_SheetName.IsEmpty() )
{
aSheet->m_SheetName.Printf( wxT( "Sheet%8.8lX" ), GetTimeStamp() ); aSheet->m_SheetName.Printf( wxT( "Sheet%8.8lX" ), GetTimeStamp() );
}
}
}
else
{
edit = false;
}
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = false; DrawPanel->m_IgnoreMouseEvents = false;
aSheet->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); aSheet->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
return edit; return true;
} }
@ -221,7 +296,7 @@ SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC )
sheet->m_Flags = IS_NEW | IS_RESIZED; sheet->m_Flags = IS_NEW | IS_RESIZED;
sheet->m_TimeStamp = GetTimeStamp(); sheet->m_TimeStamp = GetTimeStamp();
sheet->SetParent( GetScreen() ); sheet->SetParent( GetScreen() );
sheet->m_AssociatedScreen = NULL; sheet->SetScreen( NULL );
s_PreviousSheetWidth = SHEET_MIN_WIDTH; s_PreviousSheetWidth = SHEET_MIN_WIDTH;
s_PreviousSheetHeight = SHEET_MIN_HEIGHT; s_PreviousSheetHeight = SHEET_MIN_HEIGHT;

View File

@ -205,10 +205,10 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::Import_PinSheet( SCH_SHEET* Sheet, wxDC* DC )
SCH_SHEET_PIN* NewSheetLabel; SCH_SHEET_PIN* NewSheetLabel;
SCH_HIERLABEL* HLabel = NULL; SCH_HIERLABEL* HLabel = NULL;
if( !Sheet->m_AssociatedScreen ) if( !Sheet->GetScreen() )
return NULL; return NULL;
DrawStruct = Sheet->m_AssociatedScreen->GetDrawItems(); DrawStruct = Sheet->GetScreen()->GetDrawItems();
HLabel = NULL; HLabel = NULL;
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )

View File

@ -75,7 +75,7 @@ void WinEDA_GerberFrame::ExportDataInPcbnewFormat( wxCommandEvent& event )
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
GetScreen()->m_FileName = FullFileName; GetScreen()->SetFileName( FullFileName );
SavePcbFormatAscii( this, dest, LayerLookUpTable ); SavePcbFormatAscii( this, dest, LayerLookUpTable );
fclose( dest ); fclose( dest );
} }

View File

@ -158,17 +158,19 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName )
// Read gerber files: each file is loaded on a new gerbview layer // Read gerber files: each file is loaded on a new gerbview layer
int layer = getActiveLayer(); int layer = getActiveLayer();
for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ ) for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ )
{ {
wxFileName filename = filenamesList[ii]; wxFileName filename = filenamesList[ii];
filename.SetPath( currentPath ); filename.SetPath( currentPath );
GetScreen()->m_FileName = filename.GetFullPath(); GetScreen()->SetFileName( filename.GetFullPath() );
filename.SetExt( g_PenFilenameExt ); filename.SetExt( g_PenFilenameExt );
setActiveLayer( layer, false ); setActiveLayer( layer, false );
if( Read_GERBER_File( GetScreen()->m_FileName, filename.GetFullPath() ) )
if( Read_GERBER_File( GetScreen()->GetFileName(), filename.GetFullPath() ) )
{ {
SetLastProject( GetScreen()->m_FileName ); SetLastProject( GetScreen()->GetFileName() );
layer++; layer++;
if( layer >= NB_LAYERS ) if( layer >= NB_LAYERS )
layer = 0; layer = 0;
@ -209,7 +211,7 @@ static void LoadDCodeFile( WinEDA_GerberFrame* frame,
GetChars( g_PenFilenameExt ), GetChars( g_PenFilenameExt ),
GetChars( g_PenFilenameExt ) ); GetChars( g_PenFilenameExt ) );
wildcard += AllFilesWildcard; wildcard += AllFilesWildcard;
fn = frame->GetScreen()->m_FileName; fn = frame->GetScreen()->GetFileName();
fn.SetExt( g_PenFilenameExt ); fn.SetExt( g_PenFilenameExt );
wxFileDialog dlg( (wxWindow*) frame, _( "Load GERBER DCODE File" ), wxFileDialog dlg( (wxWindow*) frame, _( "Load GERBER DCODE File" ),
fn.GetPath(), fn.GetFullName(), wildcard, fn.GetPath(), fn.GetFullName(), wildcard,

View File

@ -56,6 +56,7 @@ class BASE_SCREEN : public EDA_ITEM
EDA_ITEMS m_items; ///< The drawing items associated with this screen. EDA_ITEMS m_items; ///< The drawing items associated with this screen.
GRIDS m_grids; ///< List of valid grid sizes. GRIDS m_grids; ///< List of valid grid sizes.
EDA_ITEM* m_drawList; ///< Object list for the screen. EDA_ITEM* m_drawList; ///< Object list for the screen.
wxString m_fileName; ///< File used to load the screen.
public: public:
wxPoint m_DrawOrg; /* offsets for drawing the circuit on the screen */ wxPoint m_DrawOrg; /* offsets for drawing the circuit on the screen */
@ -105,7 +106,6 @@ public:
int m_ScreenNumber; int m_ScreenNumber;
int m_NumberOfScreen; int m_NumberOfScreen;
wxString m_FileName;
wxString m_Title; wxString m_Title;
wxString m_Date; wxString m_Date;
wxString m_Revision; wxString m_Revision;
@ -157,6 +157,10 @@ public:
void InitDatas(); void InitDatas();
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
wxString GetFileName() const { return m_fileName; }
void SetPageSize( wxSize& aPageSize ); void SetPageSize( wxSize& aPageSize );
wxSize ReturnPageSize( void ); wxSize ReturnPageSize( void );
virtual int GetInternalUnits( void ); virtual int GetInternalUnits( void );

View File

@ -48,7 +48,7 @@ public:
void DecRefCount(); void DecRefCount();
void IncRefCount() { m_refCount++; } void IncRefCount();
int GetRefCount() const { return m_refCount; } int GetRefCount() const { return m_refCount; }

View File

@ -18,6 +18,8 @@ class wxFindReplaceData;
typedef boost::ptr_vector< SCH_ITEM > SCH_ITEMS; typedef boost::ptr_vector< SCH_ITEM > SCH_ITEMS;
typedef SCH_ITEMS::iterator SCH_ITEMS_ITR;
typedef vector< SCH_ITEMS_ITR > SCH_ITEMS_ITRS;
// Schematic item filter mask for hit test objects in schematic editor. // Schematic item filter mask for hit test objects in schematic editor.

View File

@ -61,7 +61,7 @@ void WinEDA_PcbFrame::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
} }
/* Set the file extension: */ /* Set the file extension: */
fn = GetScreen()->m_FileName; fn = GetScreen()->GetFileName();
fn.SetExt( CsvFileExtension ); fn.SetExt( CsvFileExtension );
wxFileDialog dlg( this, _( "Save Bill of Materials" ), wxGetCwd(), wxFileDialog dlg( this, _( "Save Bill of Materials" ), wxGetCwd(),

View File

@ -243,7 +243,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
if( (CurrentTime - g_SaveTime) > g_TimeOut ) if( (CurrentTime - g_SaveTime) > g_TimeOut )
{ {
wxString tmpFileName = GetScreen()->m_FileName; wxString tmpFileName = GetScreen()->GetFileName();
wxFileName fn = wxFileName( wxEmptyString, g_SaveFileName, PcbFileExtension ); wxFileName fn = wxFileName( wxEmptyString, g_SaveFileName, PcbFileExtension );
bool flgmodify = GetScreen()->IsModify(); bool flgmodify = GetScreen()->IsModify();
@ -254,8 +254,8 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
OnModify(); OnModify();
GetScreen()->SetSave(); // Set the flags m_FlagSave cleared by SetModify() GetScreen()->SetSave(); // Set the flags m_FlagSave cleared by SetModify()
} }
GetScreen()->m_FileName = tmpFileName; GetScreen()->SetFileName( tmpFileName );
SetTitle( GetScreen()->m_FileName ); SetTitle( GetScreen()->GetFileName() );
} }
double scalar = GetScreen()->GetScalingFactor(); double scalar = GetScreen()->GetScalingFactor();

View File

@ -177,7 +177,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref )
fn = m_FileNameCtrl->GetValue(); fn = m_FileNameCtrl->GetValue();
if( !fn.IsOk() ) if( !fn.IsOk() )
{ {
fn = screen->m_FileName; fn = screen->GetFileName();
} }
if( aPrintAll ) if( aPrintAll )

View File

@ -272,7 +272,7 @@ void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& event )
wxString wildcard( _( "DRC report files (.rpt)|*.rpt" ) ); wxString wildcard( _( "DRC report files (.rpt)|*.rpt" ) );
wxString Ext( wxT( "rpt" ) ); wxString Ext( wxT( "rpt" ) );
fn = m_Parent->GetScreen()->m_FileName + wxT( "-drc" ); fn = m_Parent->GetScreen()->GetFileName() + wxT( "-drc" );
fn.SetExt( Ext ); fn.SetExt( Ext );
wxFileDialog dlg( this, _( "Save DRC Report File" ), wxEmptyString, wxFileDialog dlg( this, _( "Save DRC Report File" ), wxEmptyString,
@ -555,7 +555,7 @@ void DIALOG_DRC_CONTROL::writeReport( FILE* fp )
int count; int count;
fprintf( fp, "** Drc report for %s **\n", fprintf( fp, "** Drc report for %s **\n",
CONV_TO_UTF8( m_Parent->GetScreen()->m_FileName ) ); CONV_TO_UTF8( m_Parent->GetScreen()->GetFileName() ) );
wxDateTime now = wxDateTime::Now(); wxDateTime now = wxDateTime::Now();

View File

@ -27,7 +27,7 @@ void WinEDA_PcbFrame::InstallNetlistFrame( wxDC* DC, const wxPoint& pos )
if( !fn.FileExists() ) if( !fn.FileExists() )
{ {
fn = GetScreen()->m_FileName; fn = GetScreen()->GetFileName();
fn.SetExt( NetExtBuffer ); fn.SetExt( NetExtBuffer );
} }

View File

@ -67,7 +67,7 @@ static int mapYto( int y )
*/ */
void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event ) void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
{ {
wxFileName fn = GetScreen()->m_FileName; wxFileName fn = GetScreen()->GetFileName();
wxString msg, ext, wildcard; wxString msg, ext, wildcard;
FILE* file; FILE* file;
@ -540,7 +540,7 @@ bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame )
msg = wxT( "USER " ) + wxGetApp().GetAppName() + wxT( " " ) + msg = wxT( "USER " ) + wxGetApp().GetAppName() + wxT( " " ) +
GetBuildVersion(); GetBuildVersion();
fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file );
msg = wxT( "DRAWING " ) + screen->m_FileName; msg = wxT( "DRAWING " ) + screen->GetFileName();
fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file ); fputs( CONV_TO_UTF8( msg ), file ); fputs( "\n", file );
msg = wxT( "REVISION " ) + screen->m_Revision + wxT( " " ) + msg = wxT( "REVISION " ) + screen->m_Revision + wxT( " " ) +
screen->m_Date; screen->m_Date;

View File

@ -1134,12 +1134,13 @@ void WinEDA_PcbFrame::OnExportVRML( wxCommandEvent& event )
// Build default file name // Build default file name
wxString ext = wxT( "wrl" ); wxString ext = wxT( "wrl" );
fn = GetScreen()->m_FileName; fn = GetScreen()->GetFileName();
fn.SetExt( ext ); fn.SetExt( ext );
DIALOG_EXPORT_3DFILE dlg( this ); DIALOG_EXPORT_3DFILE dlg( this );
dlg.FilePicker()->SetPath( fn.GetFullPath() ); dlg.FilePicker()->SetPath( fn.GetFullPath() );
dlg.SetSubdir( subDirFor3Dshapes ); dlg.SetSubdir( subDirFor3Dshapes );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return; return;

View File

@ -50,7 +50,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
switch( id ) switch( id )
{ {
case ID_LOAD_FILE: case ID_LOAD_FILE:
LoadOnePcbFile( GetScreen()->m_FileName, false, true ); LoadOnePcbFile( GetScreen()->GetFileName(), false, true );
ReCreateAuxiliaryToolbar(); ReCreateAuxiliaryToolbar();
SetToolbars(); SetToolbars();
break; break;
@ -66,7 +66,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
} }
else else
{ {
fn = GetScreen()->m_FileName; fn = GetScreen()->GetFileName();
fn.SetExt( BACKUP_FILE_EXT ); fn.SetExt( BACKUP_FILE_EXT );
} }
@ -85,8 +85,8 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
LoadOnePcbFile( fn.GetFullPath(), false ); LoadOnePcbFile( fn.GetFullPath(), false );
fn.SetExt( PcbFileExtension ); fn.SetExt( PcbFileExtension );
GetScreen()->m_FileName = fn.GetFullPath(); GetScreen()->SetFileName( fn.GetFullPath() );
SetTitle( GetScreen()->m_FileName ); SetTitle( GetScreen()->GetFileName() );
ReCreateAuxiliaryToolbar(); ReCreateAuxiliaryToolbar();
SetToolbars(); SetToolbars();
break; break;
@ -98,16 +98,16 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
case ID_NEW_BOARD: case ID_NEW_BOARD:
Clear_Pcb( true ); Clear_Pcb( true );
GetScreen()->m_FileName.Printf( wxT( "%s%cnoname%s" ), GetScreen()->GetFileName().Printf( wxT( "%s%cnoname%s" ),
GetChars( wxGetCwd() ), DIR_SEP, GetChars( wxGetCwd() ), DIR_SEP,
GetChars( PcbFileExtension ) ); GetChars( PcbFileExtension ) );
SetTitle( GetScreen()->m_FileName ); SetTitle( GetScreen()->GetFileName() );
ReCreateLayerBox( NULL ); ReCreateLayerBox( NULL );
SetToolbars(); SetToolbars();
break; break;
case ID_SAVE_BOARD: case ID_SAVE_BOARD:
SavePcbFile( GetScreen()->m_FileName ); SavePcbFile( GetScreen()->GetFileName() );
break; break;
case ID_SAVE_BOARD_AS: case ID_SAVE_BOARD_AS:
@ -152,7 +152,7 @@ the changes?" ) ) )
if( aAppend ) if( aAppend )
{ {
GetScreen()->m_FileName = wxEmptyString; GetScreen()->SetFileName( wxEmptyString );
OnModify(); OnModify();
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
} }
@ -185,20 +185,20 @@ 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()->m_FileName = fileName.GetFullPath(); GetScreen()->SetFileName( fileName.GetFullPath() );
/* Start read PCB file /* Start read PCB file
*/ */
source = wxFopen( GetScreen()->m_FileName, wxT( "rt" ) ); source = wxFopen( GetScreen()->GetFileName(), wxT( "rt" ) );
if( source == NULL ) if( source == NULL )
{ {
msg.Printf( _( "File <%s> not found" ), GetChars( GetScreen()->m_FileName ) ); msg.Printf( _( "File <%s> not found" ), GetChars( GetScreen()->GetFileName() ) );
DisplayError( this, msg ); DisplayError( this, msg );
return false; return false;
} }
FILE_LINE_READER fileReader( source, GetScreen()->m_FileName ); FILE_LINE_READER fileReader( source, GetScreen()->GetFileName() );
FILTER_READER reader( fileReader ); FILTER_READER reader( fileReader );
@ -225,7 +225,8 @@ this file again." ) );
} }
// Reload the corresponding configuration file: // Reload the corresponding configuration file:
wxSetWorkingDirectory( wxPathOnly( GetScreen()->m_FileName ) ); wxSetWorkingDirectory( wxPathOnly( GetScreen()->GetFileName() ) );
if( aAppend ) if( aAppend )
ReadPcbFile( &reader, true ); ReadPcbFile( &reader, true );
else else
@ -238,7 +239,7 @@ this file again." ) );
m_DisplayViaFill = DisplayOpt.DisplayViaFill; m_DisplayViaFill = DisplayOpt.DisplayViaFill;
ReadPcbFile( &reader, false ); ReadPcbFile( &reader, false );
LoadProjectSettings( GetScreen()->m_FileName ); LoadProjectSettings( GetScreen()->GetFileName() );
} }
GetScreen()->ClrModify(); GetScreen()->ClrModify();
@ -246,20 +247,21 @@ this file again." ) );
/* If append option: change the initial board name to <oldname>-append.brd */ /* If append option: change the initial board name to <oldname>-append.brd */
if( aAppend ) if( aAppend )
{ {
wxString new_filename = GetScreen()->m_FileName.BeforeLast( '.' ); wxString new_filename = GetScreen()->GetFileName().BeforeLast( '.' );
if ( ! new_filename.EndsWith( wxT( "-append" ) ) ) if ( ! new_filename.EndsWith( wxT( "-append" ) ) )
new_filename += wxT( "-append" ); new_filename += wxT( "-append" );
new_filename += wxT( "." ) + PcbFileExtension; new_filename += wxT( "." ) + PcbFileExtension;
OnModify(); OnModify();
GetScreen()->m_FileName = new_filename; GetScreen()->SetFileName( new_filename );
} }
GetScreen()->m_FileName.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); GetScreen()->GetFileName().Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
SetTitle( GetScreen()->m_FileName ); SetTitle( GetScreen()->GetFileName() );
SetLastProject( GetScreen()->m_FileName ); SetLastProject( GetScreen()->GetFileName() );
/* Rebuild the new pad list (for drc and ratsnet control ...) */ /* Rebuild the new pad list (for drc and ratsnet control ...) */
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
@ -331,16 +333,16 @@ bool WinEDA_PcbFrame::SavePcbFile( const wxString& FileName )
if( FileName == wxEmptyString ) if( FileName == wxEmptyString )
{ {
wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString, wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString,
GetScreen()->m_FileName, PcbFileWildcard, GetScreen()->GetFileName(), PcbFileWildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return false; return false;
GetScreen()->m_FileName = dlg.GetPath(); GetScreen()->SetFileName( dlg.GetPath() );
} }
else else
GetScreen()->m_FileName = FileName; GetScreen()->SetFileName( FileName );
/* If changes are made, update the board date */ /* If changes are made, update the board date */
if( GetScreen()->IsModify() ) if( GetScreen()->IsModify() )
@ -348,7 +350,7 @@ bool WinEDA_PcbFrame::SavePcbFile( const wxString& FileName )
GetScreen()->m_Date = GenDate(); GetScreen()->m_Date = GenDate();
} }
pcbFileName = GetScreen()->m_FileName; pcbFileName = GetScreen()->GetFileName();
/* Get the backup file name */ /* Get the backup file name */
backupFileName = pcbFileName; backupFileName = pcbFileName;
@ -387,8 +389,8 @@ bool WinEDA_PcbFrame::SavePcbFile( const wxString& FileName )
if( dest ) if( dest )
{ {
GetScreen()->m_FileName = pcbFileName.GetFullPath(); GetScreen()->SetFileName( pcbFileName.GetFullPath() );
SetTitle( GetScreen()->m_FileName ); SetTitle( GetScreen()->GetFileName() );
SavePcbFormatAscii( dest ); SavePcbFormatAscii( dest );
fclose( dest ); fclose( dest );

View File

@ -134,7 +134,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
return; return;
} }
fnFront = GetScreen()->m_FileName; fnFront = GetScreen()->GetFileName();
frontLayerName = GetBoard()->GetLayerName( LAYER_N_FRONT ); frontLayerName = GetBoard()->GetLayerName( LAYER_N_FRONT );
fnFront.SetName( fnFront.GetName() + frontLayerName ); fnFront.SetName( fnFront.GetName() + frontLayerName );
fnFront.SetExt( wxT( "pos") ); fnFront.SetExt( wxT( "pos") );
@ -149,7 +149,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
if( doBoardBack ) if( doBoardBack )
{ {
fnBack = GetScreen()->m_FileName; fnBack = GetScreen()->GetFileName();
backLayerName = GetBoard()->GetLayerName( LAYER_N_BACK ); backLayerName = GetBoard()->GetLayerName( LAYER_N_BACK );
fnBack.SetName( fnBack.GetName() + backLayerName ); fnBack.SetName( fnBack.GetName() + backLayerName );
fnBack.SetExt( wxT( "pos" ) ); fnBack.SetExt( wxT( "pos" ) );
@ -320,7 +320,7 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
File_Place_Offset = wxPoint( 0, 0 ); File_Place_Offset = wxPoint( 0, 0 );
fn = GetScreen()->m_FileName; fn = GetScreen()->GetFileName();
fn.SetExt( wxT( "rpt" ) ); fn.SetExt( wxT( "rpt" ) );
rptfile = wxFopen( fn.GetFullPath(), wxT( "wt" ) ); rptfile = wxFopen( fn.GetFullPath(), wxT( "wt" ) );

View File

@ -129,7 +129,7 @@ void DIALOG_GENDRILL::GenDrillAndReportFiles( )
if( s_ToolListBuffer.size() > 0 ) //holes? if( s_ToolListBuffer.size() > 0 ) //holes?
{ {
fn = m_Parent->GetScreen()->m_FileName; fn = m_Parent->GetScreen()->GetFileName();
layer_extend.Empty(); layer_extend.Empty();
if( !gen_through_holes ) if( !gen_through_holes )
@ -220,7 +220,7 @@ void DIALOG_GENDRILL::GenDrillAndReportFiles( )
if( m_Choice_Drill_Report->GetSelection() > 0 ) if( m_Choice_Drill_Report->GetSelection() > 0 )
{ {
GenDrillReport( m_Parent->GetScreen()->m_FileName ); GenDrillReport( m_Parent->GetScreen()->GetFileName() );
} }
} }
@ -647,7 +647,7 @@ void DIALOG_GENDRILL::GenDrillReport( const wxString aFileName )
} }
GenDrillReportFile( report_dest, m_Parent->GetBoard(), GenDrillReportFile( report_dest, m_Parent->GetBoard(),
m_Parent->GetScreen()->m_FileName, m_Parent->GetScreen()->GetFileName(),
m_UnitDrillIsInch, m_UnitDrillIsInch,
s_HoleListBuffer, s_HoleListBuffer,
s_ToolListBuffer ); s_ToolListBuffer );

View File

@ -46,7 +46,7 @@ bool WinEDA_PcbFrame::Clear_Pcb( bool aQuery )
SetCurItem( NULL ); SetCurItem( NULL );
/* clear filename, to avoid overwriting an old file */ /* clear filename, to avoid overwriting an old file */
GetScreen()->m_FileName.Empty(); GetScreen()->GetFileName().Empty();
/* Init new grid size */ /* Init new grid size */
wxRealPoint gridsize = GetScreen()->GetGridSize(); wxRealPoint gridsize = GetScreen()->GetGridSize();
@ -101,7 +101,7 @@ bool WinEDA_ModuleEditFrame::Clear_Pcb( bool aQuery )
GetBoard()->m_Modules.DeleteAll(); GetBoard()->m_Modules.DeleteAll();
/* init pointeurs et variables */ /* init pointeurs et variables */
GetScreen()->m_FileName.Empty(); GetScreen()->GetFileName().Empty();
SetCurItem( NULL ); SetCurItem( NULL );

View File

@ -448,14 +448,14 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event )
case wxID_OK: case wxID_OK:
case wxID_YES: case wxID_YES:
SavePcbFile( GetScreen()->m_FileName ); SavePcbFile( GetScreen()->GetFileName() );
break; break;
} }
} }
if( !GetScreen()->m_FileName.IsEmpty() ) if( !GetScreen()->GetFileName().IsEmpty() )
{ {
wxFileName fn = GetScreen()->m_FileName; wxFileName fn = GetScreen()->GetFileName();
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() ); wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
} }
@ -668,7 +668,7 @@ void WinEDA_PcbFrame::SetLanguage( wxCommandEvent& event )
wxString WinEDA_PcbFrame::GetLastNetListRead() wxString WinEDA_PcbFrame::GetLastNetListRead()
{ {
wxFileName absoluteFileName = m_lastNetListRead; wxFileName absoluteFileName = m_lastNetListRead;
wxFileName pcbFileName = GetScreen()->m_FileName; wxFileName pcbFileName = GetScreen()->GetFileName();
if( !absoluteFileName.MakeAbsolute( pcbFileName.GetPath() ) if( !absoluteFileName.MakeAbsolute( pcbFileName.GetPath() )
|| !absoluteFileName.FileExists() ) || !absoluteFileName.FileExists() )
@ -684,7 +684,7 @@ wxString WinEDA_PcbFrame::GetLastNetListRead()
void WinEDA_PcbFrame::SetLastNetListRead( const wxString& aLastNetListRead ) void WinEDA_PcbFrame::SetLastNetListRead( const wxString& aLastNetListRead )
{ {
wxFileName relativeFileName = aLastNetListRead; wxFileName relativeFileName = aLastNetListRead;
wxFileName pcbFileName = GetScreen()->m_FileName; wxFileName pcbFileName = GetScreen()->GetFileName();
if( relativeFileName.MakeRelativeTo( pcbFileName.GetPath() ) if( relativeFileName.MakeRelativeTo( pcbFileName.GetPath() )
&& relativeFileName.GetFullPath() != aLastNetListRead ) && relativeFileName.GetFullPath() != aLastNetListRead )

View File

@ -164,15 +164,14 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
else else
{ // File does not exists: prepare an empty board { // File does not exists: prepare an empty board
wxSetWorkingDirectory( fn.GetPath() ); wxSetWorkingDirectory( fn.GetPath() );
frame->GetScreen()->m_FileName = fn.GetFullPath(); frame->GetScreen()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) );
frame->GetScreen()->m_FileName.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); frame->SetTitle( frame->GetScreen()->GetFileName() );
frame->SetTitle( frame->GetScreen()->m_FileName ); frame->SetLastProject( frame->GetScreen()->GetFileName() );
frame->SetLastProject( frame->GetScreen()->m_FileName );
frame->OnModify(); // Ready to save the new empty board frame->OnModify(); // Ready to save the new empty board
wxString msg; wxString msg;
msg.Printf( _( "File <%s> not existing\nThis is normal for a new project" ), msg.Printf( _( "File <%s> not existing\nThis is normal for a new project" ),
GetChars( frame->GetScreen()->m_FileName ) ); GetChars( frame->GetScreen()->GetFileName() ) );
wxMessageBox( msg ); wxMessageBox( msg );
} }
} }

View File

@ -86,7 +86,7 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event )
case ID_CONFIG_READ: case ID_CONFIG_READ:
{ {
fn = GetScreen()->m_FileName; fn = GetScreen()->GetFileName();
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
@ -175,7 +175,7 @@ void WinEDA_PcbFrame::SaveProjectSettings()
{ {
wxFileName fn; wxFileName fn;
fn = GetScreen()->m_FileName; fn = GetScreen()->GetFileName();
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), fn.GetFullName(), wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), fn.GetFullName(),

View File

@ -285,7 +285,7 @@ void DIALOG_PLOT::Init_Dialog()
// Output directory // Output directory
if( g_PcbPlotOptions.GetOutputDirectory().IsEmpty() ) if( g_PcbPlotOptions.GetOutputDirectory().IsEmpty() )
{ {
fileName = m_Parent->GetScreen()->m_FileName; fileName = m_Parent->GetScreen()->GetFileName();
m_outputDirectoryName->SetValue( fileName.GetPath() ); m_outputDirectoryName->SetValue( fileName.GetPath() );
} }
else else
@ -612,7 +612,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
{ {
s_SelectedLayers |= mask; s_SelectedLayers |= mask;
fn = m_Parent->GetScreen()->m_FileName; fn = m_Parent->GetScreen()->GetFileName();
fn.SetPath( m_outputDirectoryName->GetValue() ); fn.SetPath( m_outputDirectoryName->GetValue() );
// Create file name. // Create file name.

View File

@ -264,7 +264,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
* is the y coordinate values from - PlotAreaSize.y to 0 */ * is the y coordinate values from - PlotAreaSize.y to 0 */
#ifdef USE_WX_ZOOM #ifdef USE_WX_ZOOM
int y_dc_offset = PlotAreaSizeInPixels.y; int y_dc_offset = PlotAreaSizeInPixels.y;
y_dc_offset = (int) y_dc_offset * userscale; y_dc_offset = (int) ( ( double ) y_dc_offset * userscale );
dc->SetDeviceOrigin( 0, y_dc_offset ); dc->SetDeviceOrigin( 0, y_dc_offset );
#endif #endif
int ysize = (int) ( PlotAreaSizeInPixels.y / scaley ); int ysize = (int) ( PlotAreaSizeInPixels.y / scaley );

View File

@ -63,7 +63,7 @@ static const double safetyMargin = 0.1;
// see wxPcbStruct.h // see wxPcbStruct.h
void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event ) void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event )
{ {
wxString fullFileName = GetScreen()->m_FileName; wxString fullFileName = GetScreen()->GetFileName();
wxString path; wxString path;
wxString name; wxString name;
wxString ext; wxString ext;

View File

@ -63,7 +63,7 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
} }
*/ */
wxString fullFileName = GetScreen()->m_FileName; wxString fullFileName = GetScreen()->GetFileName();
wxString path; wxString path;
wxString name; wxString name;
wxString ext; wxString ext;

View File

@ -154,7 +154,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
return 0; /* no change of name */ return 0; /* no change of name */
/* Calculation CMP file name by changing the extension name NetList */ /* Calculation CMP file name by changing the extension name NetList */
fn = m_Parent->GetScreen()->m_FileName; fn = m_Parent->GetScreen()->GetFileName();
fn.SetExt( NetCmpExtBuffer ); fn.SetExt( NetCmpExtBuffer );
FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) );
@ -576,7 +576,7 @@ void WinEDA_PcbFrame::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
} }
/* Calculation file name by changing the extension name to NetList */ /* Calculation file name by changing the extension name to NetList */
fn = GetScreen()->m_FileName; fn = GetScreen()->GetFileName();
fn.SetExt( NetCmpExtBuffer ); fn.SetExt( NetCmpExtBuffer );
wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) + wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) +
NetCmpExtBuffer; NetCmpExtBuffer;