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:
parent
fbeb411632
commit
e560573c5e
|
@ -602,7 +602,7 @@ void Pcb3D_GLCanvas::SetLights()
|
|||
*/
|
||||
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 file_ext, mask;
|
||||
bool fmt_is_jpeg = FALSE;
|
||||
|
@ -613,7 +613,7 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
|
|||
{
|
||||
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
|
||||
mask = wxT( "*." ) + file_ext;
|
||||
FullFileName = m_Parent->m_Parent->GetScreen()->m_FileName;
|
||||
FullFileName = m_Parent->m_Parent->GetScreen()->GetFileName();
|
||||
fn.SetExt( file_ext );
|
||||
|
||||
FullFileName =
|
||||
|
|
|
@ -487,7 +487,7 @@ void WinEDA_DrawFrame::PlotWorkSheet( PLOTTER* plotter, BASE_SCREEN* screen )
|
|||
case WS_FILENAME:
|
||||
{
|
||||
wxString fname, fext;
|
||||
wxFileName::SplitPath( screen->m_FileName,
|
||||
wxFileName::SplitPath( screen->GetFileName(),
|
||||
(wxString*) NULL,
|
||||
&fname,
|
||||
&fext );
|
||||
|
|
|
@ -1389,10 +1389,11 @@ void WinEDA_DrawFrame::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen,
|
|||
case WS_FILENAME:
|
||||
{
|
||||
wxString fname, fext;
|
||||
wxFileName::SplitPath( screen->m_FileName, (wxString*) NULL,
|
||||
&fname, &fext );
|
||||
wxFileName::SplitPath( screen->GetFileName(), (wxString*) NULL, &fname, &fext );
|
||||
|
||||
if( WsItem->m_Legende )
|
||||
msg = WsItem->m_Legende;
|
||||
|
||||
msg << fname << wxT( "." ) << fext;
|
||||
DrawGraphicText( DrawPanel, DC, pos, Color,
|
||||
msg, TEXT_ORIENT_HORIZ, size,
|
||||
|
|
|
@ -36,7 +36,7 @@ void DeleteSubHierarchy( SCH_SHEET* FirstSheet, bool confirm_deletion )
|
|||
return;
|
||||
}
|
||||
|
||||
if( FirstSheet->m_AssociatedScreen->IsModify() && confirm_deletion )
|
||||
if( FirstSheet->GetScreen()->IsModify() && confirm_deletion )
|
||||
{
|
||||
msg.Printf( _( "Sheet %s (file %s) modified. Save it?" ),
|
||||
FirstSheet->m_SheetName.GetData(),
|
||||
|
@ -44,14 +44,14 @@ void DeleteSubHierarchy( SCH_SHEET* FirstSheet, bool confirm_deletion )
|
|||
|
||||
if( IsOK( NULL, msg ) )
|
||||
{
|
||||
frame->SaveEEFile( FirstSheet->m_AssociatedScreen, FILE_SAVE_AS );
|
||||
frame->SaveEEFile( FirstSheet->GetScreen(), FILE_SAVE_AS );
|
||||
}
|
||||
}
|
||||
|
||||
/* free the sub hierarchy */
|
||||
if( FirstSheet->m_AssociatedScreen )
|
||||
if( FirstSheet->GetScreen() )
|
||||
{
|
||||
EEDrawList = FirstSheet->m_AssociatedScreen->GetDrawItems();
|
||||
EEDrawList = FirstSheet->GetScreen()->GetDrawItems();
|
||||
|
||||
while( EEDrawList != NULL )
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ void DeleteSubHierarchy( SCH_SHEET* FirstSheet, bool confirm_deletion )
|
|||
}
|
||||
}
|
||||
|
||||
FirstSheet->m_AssociatedScreen->FreeDrawList();
|
||||
FirstSheet->GetScreen()->FreeDrawList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
|
|||
fn = m_FileNameCtrl->GetValue();
|
||||
|
||||
if( !fn.IsOk() )
|
||||
fn = screen->m_FileName;
|
||||
fn = screen->GetFileName();
|
||||
|
||||
fn.SetExt( wxT( "svg" ) );
|
||||
fn.MakeAbsolute();
|
||||
|
|
|
@ -277,7 +277,7 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( int aTypeFile,
|
|||
|
||||
static wxFileName fn;
|
||||
|
||||
wxFileName current = g_RootSheet->m_AssociatedScreen->m_FileName;
|
||||
wxFileName current = g_RootSheet->GetScreen()->GetFileName();
|
||||
|
||||
s_ExportSeparatorSymbol = aExportSeparatorSymbol;
|
||||
|
||||
|
|
|
@ -540,7 +540,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
|
|||
|
||||
if( m_writeErcFile )
|
||||
{
|
||||
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
||||
fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
fn.SetExt( wxT( "erc" ) );
|
||||
|
||||
wxFileDialog dlg( this, _( "ERC File" ), fn.GetPath(), fn.GetFullName(),
|
||||
|
|
|
@ -66,17 +66,17 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
|||
DrawPanel->DrawCursor( DC );
|
||||
|
||||
// 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();
|
||||
title.Printf( wxT( "%s [%s]" ), GetChars( msg), GetChars( GetScreen()->m_FileName ) );
|
||||
title.Printf( wxT( "%s [%s]" ), GetChars( msg), GetChars( GetScreen()->GetFileName() ) );
|
||||
SetTitle( title );
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 0
|
||||
title = wxT( "[" );
|
||||
title << GetScreen()->m_FileName << wxT( "] " ) << _( "Sheet" );
|
||||
title << GetScreen()->GetFileName() << wxT( "] " ) << _( "Sheet" );
|
||||
title << wxT( " " ) << m_CurrentSheet->PathHumanReadable();
|
||||
|
||||
#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
|
||||
// passed to LoadOneEEFile() which currently omits the path on non-root schematics.
|
||||
wxFileName t( GetScreen()->m_FileName );
|
||||
wxFileName t( GetScreen()->GetFileName() );
|
||||
|
||||
title = wxChar( '[' );
|
||||
title << t.GetName() << wxChar( ' ' );
|
||||
|
|
|
@ -64,7 +64,7 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
|||
|
||||
case ID_CONFIG_READ:
|
||||
{
|
||||
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
||||
fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
||||
wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
|
||||
|
@ -132,7 +132,7 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
|||
|
||||
case ID_CONFIG_READ:
|
||||
{
|
||||
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
||||
fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
||||
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;
|
||||
|
||||
if( CfgFileName.IsEmpty() )
|
||||
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
||||
fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
else
|
||||
fn = CfgFileName;
|
||||
|
||||
|
@ -397,7 +397,7 @@ void SCH_EDIT_FRAME::SaveProjectFile( wxWindow* displayframe, bool askoverwrite
|
|||
{
|
||||
wxFileName fn;
|
||||
|
||||
fn = g_RootSheet->m_AssociatedScreen->m_FileName /*ConfigFileName*/;
|
||||
fn = g_RootSheet->GetScreen()->GetFileName(); /*ConfigFileName*/
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
||||
int options = wxFD_SAVE;
|
||||
|
|
|
@ -33,13 +33,13 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* screen, int FileSave )
|
|||
screen = GetScreen();
|
||||
|
||||
/* If no name exists in the window yet - save as new. */
|
||||
if( screen->m_FileName.IsEmpty() )
|
||||
if( screen->GetFileName().IsEmpty() )
|
||||
FileSave = FILE_SAVE_NEW;
|
||||
|
||||
switch( FileSave )
|
||||
{
|
||||
case FILE_SAVE_AS:
|
||||
schematicFileName = screen->m_FileName;
|
||||
schematicFileName = screen->GetFileName();
|
||||
backupFileName = schematicFileName;
|
||||
|
||||
/* 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:
|
||||
{
|
||||
wxFileDialog dlg( this, _( "Schematic Files" ), wxGetCwd(),
|
||||
screen->m_FileName, SchematicFileWildcard,
|
||||
screen->GetFileName(), SchematicFileWildcard,
|
||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return false;
|
||||
|
||||
screen->m_FileName = dlg.GetPath();
|
||||
screen->SetFileName( dlg.GetPath() );
|
||||
schematicFileName = dlg.GetPath();
|
||||
|
||||
break;
|
||||
|
@ -82,7 +82,7 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* screen, int FileSave )
|
|||
}
|
||||
|
||||
if( FileSave == FILE_SAVE_NEW )
|
||||
screen->m_FileName = schematicFileName.GetFullPath();
|
||||
screen->SetFileName( schematicFileName.GetFullPath() );
|
||||
|
||||
bool success = screen->Save( f );
|
||||
|
||||
|
@ -146,13 +146,15 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew )
|
|||
|
||||
if( screen )
|
||||
{
|
||||
if( !IsOK( this, _( "Clear schematic hierarchy?" ) ) )
|
||||
if( !IsOK( this, _( "Discard changes to the current schematic?" ) ) )
|
||||
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;
|
||||
|
||||
if( ( FullFileName.IsEmpty() ) && !IsNew )
|
||||
{
|
||||
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 );
|
||||
wxSetWorkingDirectory( fn.GetPath() );
|
||||
|
||||
screen->m_FileName = FullFileName;
|
||||
screen->SetFileName( FullFileName );
|
||||
g_RootSheet->SetFileName( FullFileName );
|
||||
SetStatusText( wxEmptyString );
|
||||
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->m_Title = NAMELESS_PROJECT;
|
||||
screen->m_Title += wxT( ".sch" );
|
||||
GetScreen()->m_FileName = screen->m_Title;
|
||||
GetScreen()->SetFileName( screen->m_Title );
|
||||
screen->m_Company.Empty();
|
||||
screen->m_Commentaire1.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
|
||||
* 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;
|
||||
wxString cachename = fn.GetName() + wxT( "-cache" );
|
||||
|
||||
fn.SetName( cachename );
|
||||
fn.SetExt( CompLibFileExtension );
|
||||
|
||||
if( ! fn.FileExists() )
|
||||
{
|
||||
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
||||
fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
fn.SetExt( wxT( "cache.lib" ) );
|
||||
use_oldcachename = true;
|
||||
}
|
||||
|
@ -282,18 +285,17 @@ bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& FileName, bool IsNew )
|
|||
PrintMsg( msg );
|
||||
}
|
||||
|
||||
if( !wxFileExists( g_RootSheet->m_AssociatedScreen->m_FileName )
|
||||
&& !LibCacheExist )
|
||||
if( !wxFileExists( g_RootSheet->GetScreen()->GetFileName() ) && !LibCacheExist )
|
||||
{
|
||||
Zoom_Automatique( FALSE );
|
||||
msg.Printf( _( "File <%s> not found." ),
|
||||
GetChars( g_RootSheet->m_AssociatedScreen->m_FileName ) );
|
||||
GetChars( g_RootSheet->GetScreen()->GetFileName() ) );
|
||||
DisplayInfoMessage( this, msg, 0 );
|
||||
return false;
|
||||
}
|
||||
|
||||
// load the project.
|
||||
SAFE_DELETE( g_RootSheet->m_AssociatedScreen );
|
||||
g_RootSheet->SetScreen( NULL );
|
||||
bool diag = g_RootSheet->Load( this );
|
||||
|
||||
/* Redraw base screen (ROOT) if necessary. */
|
||||
|
@ -318,7 +320,7 @@ void SCH_EDIT_FRAME::SaveProject()
|
|||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFile
|
|||
return FALSE;
|
||||
|
||||
screen->SetCurItem( NULL );
|
||||
screen->m_FileName = FullFileName;
|
||||
screen->SetFileName( 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.
|
||||
FILE_LINE_READER reader( f, FullFileName );
|
||||
|
||||
MsgDiag = _( "Loading " ) + screen->m_FileName;
|
||||
MsgDiag = _( "Loading " ) + screen->GetFileName();
|
||||
PrintMsg( MsgDiag );
|
||||
|
||||
if( !reader.ReadLine()
|
||||
|
@ -223,7 +223,7 @@ again." );
|
|||
|
||||
TestDanglingEnds( screen->GetDrawItems(), NULL );
|
||||
|
||||
MsgDiag = _( "Done Loading " ) + screen->m_FileName;
|
||||
MsgDiag = _( "Done Loading " ) + screen->GetFileName();
|
||||
PrintMsg( MsgDiag );
|
||||
|
||||
return true; // Although it may be that file is only partially loaded.
|
||||
|
|
|
@ -646,7 +646,7 @@ XNODE* EXPORT_HELP::makeGenericDesignHeader()
|
|||
DateAndTime( date );
|
||||
|
||||
// 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 )) );
|
||||
|
||||
|
|
|
@ -452,7 +452,7 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event )
|
|||
CurrPage = (EDA_NoteBookPage*) m_NoteBook->GetCurrentPage();
|
||||
|
||||
/* Calculate the netlist filename */
|
||||
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
||||
fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
|
||||
switch( CurrPage->m_IdNetType )
|
||||
{
|
||||
|
@ -571,7 +571,7 @@ void WinEDA_NetlistFrame::RunSimulator( wxCommandEvent& event )
|
|||
CommandLine = g_SimulatorCommandLine.AfterFirst( ' ' );
|
||||
|
||||
/* Calculate the netlist filename */
|
||||
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
||||
fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
fn.SetExt( wxT( "cir" ) );
|
||||
CommandLine += wxT( " \"" ) + fn.GetFullPath() + wxT( "\"" );
|
||||
|
||||
|
|
|
@ -311,7 +311,7 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
|
|||
wxPoint pos_sheetname, pos_filename;
|
||||
wxPoint pos;
|
||||
|
||||
plotter->set_color( ReturnLayerColor( Struct->m_Layer ) );
|
||||
plotter->set_color( ReturnLayerColor( Struct->GetLayer() ) );
|
||||
|
||||
int thickness = Struct->GetPenSize();
|
||||
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,
|
||||
thickness, italic, false );
|
||||
|
||||
plotter->set_color( ReturnLayerColor( Struct->m_Layer ) );
|
||||
plotter->set_color( ReturnLayerColor( Struct->GetLayer() ) );
|
||||
|
||||
/* Draw texts : SheetLabel */
|
||||
BOOST_FOREACH( SCH_SHEET_PIN & pin_sheet, Struct->GetSheetPins() ) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/**
|
||||
* @file sch_items.h
|
||||
* @file sch_junction.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SCH_ITEMS_H_
|
||||
#define _SCH_ITEMS_H_
|
||||
#ifndef _SCH_JUNCTION_H_
|
||||
#define _SCH_JUNCTION_H_
|
||||
|
||||
|
||||
#include "sch_item_struct.h"
|
||||
|
@ -103,4 +103,4 @@ private:
|
|||
};
|
||||
|
||||
|
||||
#endif // _SCH_ITEMS_H_
|
||||
#endif // _SCH_JUNCTION_H_
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
wxCHECK_RET( m_refCount != 0,
|
||||
wxT( "Screen reference count already zero. Bad programmer!" ) );
|
||||
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 )
|
||||
{
|
||||
SCH_SHEET* ds = (SCH_SHEET*) aItem;
|
||||
aItem = ds->m_AssociatedScreen;
|
||||
aItem = ds->GetScreen();
|
||||
}
|
||||
|
||||
if( aItem && aItem->Type() == SCH_SCREEN_T )
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// Purpose: member functions for SCH_SHEET
|
||||
// header = sch_sheet.h
|
||||
// Author: jean-pierre Charras
|
||||
// Modified by:
|
||||
// Modified by: Wayne Stambaugh
|
||||
// Created: 08/02/2006 18:37:02
|
||||
// RCS-ID:
|
||||
// Copyright:
|
||||
|
@ -16,7 +16,6 @@
|
|||
#include "macros.h"
|
||||
#include "class_drawpanel.h"
|
||||
#include "drawtxt.h"
|
||||
#include "confirm.h"
|
||||
#include "trigo.h"
|
||||
#include "richio.h"
|
||||
#include "class_sch_screen.h"
|
||||
|
@ -29,7 +28,8 @@
|
|||
#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_Pos = pos;
|
||||
|
@ -69,7 +69,7 @@ SCH_SHEET::~SCH_SHEET()
|
|||
// perhaps it should be deleted also.
|
||||
if( m_AssociatedScreen )
|
||||
{
|
||||
m_AssociatedScreen->GetRefCount();
|
||||
m_AssociatedScreen->DecRefCount();
|
||||
|
||||
if( m_AssociatedScreen->GetRefCount() == 0 )
|
||||
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
|
||||
{
|
||||
if( fprintf( aFile, "$Sheet\n" ) == EOF
|
||||
|
@ -380,9 +412,7 @@ bool SCH_SHEET::HasUndefinedLabels()
|
|||
void SCH_SHEET::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
|
||||
{
|
||||
/* Place list structures for new sheet. */
|
||||
bool isnew = ( m_Flags & IS_NEW ) ? true : false;
|
||||
|
||||
if( isnew )
|
||||
if( IsNew() )
|
||||
{
|
||||
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().
|
||||
|
||||
if( isnew )
|
||||
if( IsNew() )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
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;
|
||||
if( ss->m_AssociatedScreen
|
||||
&& ss->m_AssociatedScreen->m_FileName.CmpNoCase( aFilename ) == 0 )
|
||||
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
||||
|
||||
if( sheet->m_AssociatedScreen
|
||||
&& sheet->m_AssociatedScreen->GetFileName().CmpNoCase( aFilename ) == 0 )
|
||||
{
|
||||
*aScreen = ss->m_AssociatedScreen;
|
||||
*aScreen = sheet->m_AssociatedScreen;
|
||||
return true;
|
||||
}
|
||||
|
||||
if( ss->SearchHierarchy( aFilename, aScreen ) )
|
||||
if( sheet->SearchHierarchy( aFilename, aScreen ) )
|
||||
return true;
|
||||
}
|
||||
strct = strct->Next();
|
||||
|
||||
item = item->Next();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -691,15 +723,13 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
|
|||
|
||||
if( screen )
|
||||
{
|
||||
m_AssociatedScreen = screen;
|
||||
m_AssociatedScreen->IncRefCount();
|
||||
SetScreen( screen );
|
||||
|
||||
//do not need to load the sub-sheets - this has already been done.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_AssociatedScreen = new SCH_SCREEN();
|
||||
m_AssociatedScreen->IncRefCount();
|
||||
SetScreen( new SCH_SCREEN() );
|
||||
success = aFrame->LoadOneEEFile( m_AssociatedScreen, m_FileName );
|
||||
|
||||
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 )
|
||||
{
|
||||
frame->ClearMsgPanel();
|
||||
|
|
|
@ -80,11 +80,6 @@ public:
|
|||
virtual void CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
|
||||
const wxPoint& aPos );
|
||||
|
||||
SCH_SHEET_PIN* Next()
|
||||
{
|
||||
return (SCH_SHEET_PIN*) Pnext;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
wxString m_SheetName; /* this is equivalent to C101 for
|
||||
* components: it is stored in F0 ...
|
||||
* of the file. */
|
||||
private:
|
||||
SCH_SCREEN* m_AssociatedScreen; ///< Screen that contains the physical data for
|
||||
///< the sheet. In complex hierarchies multiple
|
||||
///< sheets can share a common screen.
|
||||
SCH_SHEET_PIN_LIST m_labels; ///< List of sheet connection points.
|
||||
wxString m_FileName; /* also in SCH_SCREEN (redundant),
|
||||
* but need it here for loading after
|
||||
* reading the sheet description from
|
||||
* file. */
|
||||
|
||||
protected:
|
||||
SCH_SHEET_PIN_LIST m_labels; /* List of points to be connected.*/
|
||||
|
||||
public:
|
||||
wxString m_SheetName; /* this is equivalent to C101 for
|
||||
* components: it is stored in F0 ...
|
||||
* of the file. */
|
||||
public:
|
||||
int m_SheetNameSize; /* Size (height) of the text, used to
|
||||
* draw the sheet name */
|
||||
|
@ -222,13 +217,6 @@ public:
|
|||
* draw the file name */
|
||||
wxPoint m_Pos;
|
||||
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:
|
||||
SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) );
|
||||
|
@ -242,6 +230,29 @@ public:
|
|||
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
|
||||
* 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)
|
||||
* @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
|
||||
|
@ -421,17 +432,6 @@ public:
|
|||
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 );
|
||||
|
||||
//void RemoveSheet(SCH_SHEET* sheet);
|
||||
|
|
|
@ -131,7 +131,7 @@ SCH_SCREEN* SCH_SHEET_PATH::LastScreen()
|
|||
SCH_SHEET* lastSheet = Last();
|
||||
|
||||
if( lastSheet )
|
||||
return lastSheet->m_AssociatedScreen;
|
||||
return lastSheet->GetScreen();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -146,8 +146,8 @@ SCH_ITEM* SCH_SHEET_PATH::LastDrawList()
|
|||
{
|
||||
SCH_SHEET* lastSheet = Last();
|
||||
|
||||
if( lastSheet && lastSheet->m_AssociatedScreen )
|
||||
return lastSheet->m_AssociatedScreen->GetDrawItems();
|
||||
if( lastSheet && lastSheet->GetScreen() )
|
||||
return lastSheet->GetScreen()->GetDrawItems();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -157,8 +157,8 @@ SCH_ITEM* SCH_SHEET_PATH::FirstDrawList()
|
|||
{
|
||||
SCH_ITEM* item = NULL;
|
||||
|
||||
if( m_numSheets && m_sheets[0]->m_AssociatedScreen )
|
||||
item = m_sheets[0]->m_AssociatedScreen->GetDrawItems();
|
||||
if( m_numSheets && m_sheets[0]->GetScreen() )
|
||||
item = m_sheets[0]->GetScreen()->GetDrawItems();
|
||||
|
||||
/* @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
|
||||
|
@ -615,7 +615,7 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
|
|||
m_List[m_index] = m_currList;
|
||||
m_index++;
|
||||
|
||||
if( aSheet->m_AssociatedScreen != NULL )
|
||||
if( aSheet->GetScreen() != NULL )
|
||||
{
|
||||
EDA_ITEM* strct = m_currList.LastDrawList();
|
||||
|
||||
|
|
|
@ -326,14 +326,13 @@ void SCH_EDIT_FRAME::CreateScreens()
|
|||
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->m_AssociatedScreen->IncRefCount();
|
||||
g_RootSheet->SetScreen( new SCH_SCREEN() );
|
||||
}
|
||||
|
||||
g_RootSheet->m_AssociatedScreen->m_FileName = m_DefaultSchematicFileName;
|
||||
g_RootSheet->m_AssociatedScreen->m_Date = GenDate();
|
||||
g_RootSheet->GetScreen()->SetFileName( m_DefaultSchematicFileName );
|
||||
g_RootSheet->GetScreen()->m_Date = GenDate();
|
||||
m_CurrentSheet->Clear();
|
||||
m_CurrentSheet->Push( g_RootSheet );
|
||||
|
||||
|
@ -396,11 +395,11 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
|||
}
|
||||
}
|
||||
|
||||
if( !g_RootSheet->m_AssociatedScreen->m_FileName.IsEmpty()
|
||||
&& (g_RootSheet->m_AssociatedScreen->GetDrawItems() != NULL) )
|
||||
SetLastProject( g_RootSheet->m_AssociatedScreen->m_FileName );
|
||||
if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty()
|
||||
&& (g_RootSheet->GetScreen()->GetDrawItems() != NULL) )
|
||||
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 */
|
||||
m_CurrentSheet->Clear();
|
||||
|
@ -678,7 +677,7 @@ void SCH_EDIT_FRAME::OnLoadProject( 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() )
|
||||
{
|
||||
|
@ -695,7 +694,7 @@ void SCH_EDIT_FRAME::OnOpenPcbnew( 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 );
|
||||
|
||||
|
@ -765,10 +764,11 @@ void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
|
|||
|
||||
dlg.ShowModal();
|
||||
|
||||
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
||||
fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
|
||||
wxString default_name = NAMELESS_PROJECT;
|
||||
default_name += wxT( ".sch" );
|
||||
|
||||
if( fn.GetFullName() != default_name )
|
||||
{
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
|
|
@ -33,19 +33,35 @@ static int s_PreviousSheetHeight;
|
|||
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 edit = true;
|
||||
|
||||
if( aSheet == NULL )
|
||||
return false;
|
||||
|
||||
/* Get the new texts */
|
||||
aSheet->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
|
||||
DrawPanel->m_IgnoreMouseEvents = true;
|
||||
|
||||
DIALOG_SCH_SHEET_PROPS dlg( this );
|
||||
|
||||
wxString units = GetUnitsLabel( g_UserUnit );
|
||||
|
@ -70,76 +86,135 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
|
|||
dlg.Fit();
|
||||
dlg.SetMinSize( dlg.GetSize() );
|
||||
|
||||
if( dlg.ShowModal() == wxID_OK )
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return false;
|
||||
|
||||
wxFileName fileName = dlg.GetFileName();
|
||||
fileName.SetExt( SchematicFileExtension );
|
||||
|
||||
if( !fileName.IsOk() )
|
||||
{
|
||||
wxFileName fileName;
|
||||
wxString msg;
|
||||
DisplayError( this, _( "File name is not valid!" ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
fileName = dlg.GetFileName();
|
||||
wxString msg;
|
||||
wxString tmp;
|
||||
bool loadFromFile = false;
|
||||
SCH_SCREEN* useScreen = NULL;
|
||||
|
||||
if( !fileName.IsOk() )
|
||||
if( !g_RootSheet->SearchHierarchy( fileName.GetFullPath(), &useScreen ) )
|
||||
loadFromFile = fileName.FileExists();
|
||||
|
||||
if( aSheet->GetScreen() == NULL ) // New sheet.
|
||||
{
|
||||
if( ( useScreen != NULL ) || loadFromFile ) // Load from existing file.
|
||||
{
|
||||
DisplayError( this, _( "File name is not valid! Aborted" ) );
|
||||
edit = false;
|
||||
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
|
||||
else // New file.
|
||||
{
|
||||
fileName.SetExt( SchematicFileExtension );
|
||||
aSheet->SetScreen( new SCH_SCREEN() );
|
||||
aSheet->GetScreen()->SetFileName( fileName.GetFullPath() );
|
||||
}
|
||||
}
|
||||
else // Existing sheet.
|
||||
{
|
||||
bool isUndoable = true;
|
||||
bool renameFile = false;
|
||||
|
||||
/* m_CurrentSheet->m_AssociatedScreen must be a valid screen, and the
|
||||
* sheet must have a valid associated filename,
|
||||
* so we must call m_CurrentSheet->ChangeFileName to set a filename,
|
||||
* AND always when a new sheet is created ( when
|
||||
* m_CurrentSheet->m_AssociatedScreen is null ),
|
||||
* to create or set an Associated Screen
|
||||
*/
|
||||
if( ( fileName.GetFullPath() != aSheet->GetFileName() )
|
||||
|| ( aSheet->m_AssociatedScreen == NULL ) )
|
||||
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.
|
||||
{
|
||||
msg = _( "Changing the sheet file name can change all the schematic \
|
||||
structures and cannot be undone.\nOk to continue renaming?" );
|
||||
tmp.Printf( _( "A file named \"%s\" already exists" ),
|
||||
GetChars( fileName.GetFullName() ) );
|
||||
msg += tmp;
|
||||
|
||||
if( aSheet->m_AssociatedScreen == NULL || IsOK( NULL, msg ) )
|
||||
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 )
|
||||
{
|
||||
// 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();
|
||||
msg += _( "This sheet uses shared data in a complex hierarchy.\n\n" );
|
||||
msg += _( "Do you wish to convert it to a simple hierarchical sheet?" );
|
||||
|
||||
// set filename and the associated screen
|
||||
aSheet->ChangeFileName( this, fileName.GetFullPath() );
|
||||
if( !IsOK( NULL, msg ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
renameFile = true;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
SaveCopyInUndoList( aSheet, UR_CHANGED );
|
||||
aSheet->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
DrawPanel->m_IgnoreMouseEvents = true;
|
||||
|
||||
aSheet->m_FileNameSize = ReturnValueFromString( g_UserUnit,
|
||||
dlg.GetFileNameTextSize(),
|
||||
m_InternalUnits );
|
||||
if( isUndoable )
|
||||
SaveCopyInUndoList( aSheet, UR_CHANGED );
|
||||
|
||||
aSheet->m_SheetName = dlg.GetSheetName();
|
||||
aSheet->m_SheetNameSize = ReturnValueFromString( g_UserUnit,
|
||||
dlg.GetSheetNameTextSize(),
|
||||
m_InternalUnits );
|
||||
if( renameFile )
|
||||
{
|
||||
aSheet->GetScreen()->SetFileName( fileName.GetFullName() );
|
||||
SaveEEFile( aSheet->GetScreen(), FILE_SAVE_AS );
|
||||
|
||||
if( aSheet->m_SheetName.IsEmpty() )
|
||||
// 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->m_SheetName.Printf( wxT( "Sheet%8.8lX" ), GetTimeStamp() );
|
||||
aSheet->SetScreen( NULL );
|
||||
loadFromFile = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
edit = false;
|
||||
}
|
||||
|
||||
aSheet->SetFileName( fileName.GetFullPath() );
|
||||
|
||||
if( useScreen )
|
||||
aSheet->SetScreen( useScreen );
|
||||
else if( loadFromFile )
|
||||
aSheet->Load( this );
|
||||
|
||||
aSheet->m_FileNameSize = ReturnValueFromString( g_UserUnit,
|
||||
dlg.GetFileNameTextSize(),
|
||||
m_InternalUnits );
|
||||
aSheet->m_SheetName = dlg.GetSheetName();
|
||||
aSheet->m_SheetNameSize = ReturnValueFromString( g_UserUnit,
|
||||
dlg.GetSheetNameTextSize(),
|
||||
m_InternalUnits );
|
||||
|
||||
if( aSheet->m_SheetName.IsEmpty() )
|
||||
aSheet->m_SheetName.Printf( wxT( "Sheet%8.8lX" ), GetTimeStamp() );
|
||||
|
||||
DrawPanel->MouseToCursorSchema();
|
||||
DrawPanel->m_IgnoreMouseEvents = false;
|
||||
|
||||
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_TimeStamp = GetTimeStamp();
|
||||
sheet->SetParent( GetScreen() );
|
||||
sheet->m_AssociatedScreen = NULL;
|
||||
sheet->SetScreen( NULL );
|
||||
s_PreviousSheetWidth = SHEET_MIN_WIDTH;
|
||||
s_PreviousSheetHeight = SHEET_MIN_HEIGHT;
|
||||
|
||||
|
|
|
@ -205,10 +205,10 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::Import_PinSheet( SCH_SHEET* Sheet, wxDC* DC )
|
|||
SCH_SHEET_PIN* NewSheetLabel;
|
||||
SCH_HIERLABEL* HLabel = NULL;
|
||||
|
||||
if( !Sheet->m_AssociatedScreen )
|
||||
if( !Sheet->GetScreen() )
|
||||
return NULL;
|
||||
|
||||
DrawStruct = Sheet->m_AssociatedScreen->GetDrawItems();
|
||||
DrawStruct = Sheet->GetScreen()->GetDrawItems();
|
||||
HLabel = NULL;
|
||||
|
||||
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
|
||||
|
|
|
@ -75,7 +75,7 @@ void WinEDA_GerberFrame::ExportDataInPcbnewFormat( wxCommandEvent& event )
|
|||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
GetScreen()->m_FileName = FullFileName;
|
||||
GetScreen()->SetFileName( FullFileName );
|
||||
SavePcbFormatAscii( this, dest, LayerLookUpTable );
|
||||
fclose( dest );
|
||||
}
|
||||
|
|
|
@ -158,17 +158,19 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName )
|
|||
|
||||
// Read gerber files: each file is loaded on a new gerbview layer
|
||||
int layer = getActiveLayer();
|
||||
|
||||
for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ )
|
||||
{
|
||||
wxFileName filename = filenamesList[ii];
|
||||
filename.SetPath( currentPath );
|
||||
GetScreen()->m_FileName = filename.GetFullPath();
|
||||
GetScreen()->SetFileName( filename.GetFullPath() );
|
||||
filename.SetExt( g_PenFilenameExt );
|
||||
|
||||
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++;
|
||||
if( layer >= NB_LAYERS )
|
||||
layer = 0;
|
||||
|
@ -209,7 +211,7 @@ static void LoadDCodeFile( WinEDA_GerberFrame* frame,
|
|||
GetChars( g_PenFilenameExt ),
|
||||
GetChars( g_PenFilenameExt ) );
|
||||
wildcard += AllFilesWildcard;
|
||||
fn = frame->GetScreen()->m_FileName;
|
||||
fn = frame->GetScreen()->GetFileName();
|
||||
fn.SetExt( g_PenFilenameExt );
|
||||
wxFileDialog dlg( (wxWindow*) frame, _( "Load GERBER DCODE File" ),
|
||||
fn.GetPath(), fn.GetFullName(), wildcard,
|
||||
|
|
|
@ -56,6 +56,7 @@ class BASE_SCREEN : public EDA_ITEM
|
|||
EDA_ITEMS m_items; ///< The drawing items associated with this screen.
|
||||
GRIDS m_grids; ///< List of valid grid sizes.
|
||||
EDA_ITEM* m_drawList; ///< Object list for the screen.
|
||||
wxString m_fileName; ///< File used to load the screen.
|
||||
|
||||
public:
|
||||
wxPoint m_DrawOrg; /* offsets for drawing the circuit on the screen */
|
||||
|
@ -105,7 +106,6 @@ public:
|
|||
int m_ScreenNumber;
|
||||
int m_NumberOfScreen;
|
||||
|
||||
wxString m_FileName;
|
||||
wxString m_Title;
|
||||
wxString m_Date;
|
||||
wxString m_Revision;
|
||||
|
@ -157,6 +157,10 @@ public:
|
|||
|
||||
void InitDatas();
|
||||
|
||||
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
|
||||
|
||||
wxString GetFileName() const { return m_fileName; }
|
||||
|
||||
void SetPageSize( wxSize& aPageSize );
|
||||
wxSize ReturnPageSize( void );
|
||||
virtual int GetInternalUnits( void );
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
|
||||
void DecRefCount();
|
||||
|
||||
void IncRefCount() { m_refCount++; }
|
||||
void IncRefCount();
|
||||
|
||||
int GetRefCount() const { return m_refCount; }
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ class wxFindReplaceData;
|
|||
|
||||
|
||||
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.
|
||||
|
|
|
@ -61,7 +61,7 @@ void WinEDA_PcbFrame::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
|
|||
}
|
||||
|
||||
/* Set the file extension: */
|
||||
fn = GetScreen()->m_FileName;
|
||||
fn = GetScreen()->GetFileName();
|
||||
fn.SetExt( CsvFileExtension );
|
||||
|
||||
wxFileDialog dlg( this, _( "Save Bill of Materials" ), wxGetCwd(),
|
||||
|
|
|
@ -243,7 +243,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
|
|||
|
||||
if( (CurrentTime - g_SaveTime) > g_TimeOut )
|
||||
{
|
||||
wxString tmpFileName = GetScreen()->m_FileName;
|
||||
wxString tmpFileName = GetScreen()->GetFileName();
|
||||
wxFileName fn = wxFileName( wxEmptyString, g_SaveFileName, PcbFileExtension );
|
||||
bool flgmodify = GetScreen()->IsModify();
|
||||
|
||||
|
@ -254,8 +254,8 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
|
|||
OnModify();
|
||||
GetScreen()->SetSave(); // Set the flags m_FlagSave cleared by SetModify()
|
||||
}
|
||||
GetScreen()->m_FileName = tmpFileName;
|
||||
SetTitle( GetScreen()->m_FileName );
|
||||
GetScreen()->SetFileName( tmpFileName );
|
||||
SetTitle( GetScreen()->GetFileName() );
|
||||
}
|
||||
|
||||
double scalar = GetScreen()->GetScalingFactor();
|
||||
|
|
|
@ -177,7 +177,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref )
|
|||
fn = m_FileNameCtrl->GetValue();
|
||||
if( !fn.IsOk() )
|
||||
{
|
||||
fn = screen->m_FileName;
|
||||
fn = screen->GetFileName();
|
||||
}
|
||||
|
||||
if( aPrintAll )
|
||||
|
|
|
@ -272,7 +272,7 @@ void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& event )
|
|||
wxString wildcard( _( "DRC report files (.rpt)|*.rpt" ) );
|
||||
wxString Ext( wxT( "rpt" ) );
|
||||
|
||||
fn = m_Parent->GetScreen()->m_FileName + wxT( "-drc" );
|
||||
fn = m_Parent->GetScreen()->GetFileName() + wxT( "-drc" );
|
||||
fn.SetExt( Ext );
|
||||
|
||||
wxFileDialog dlg( this, _( "Save DRC Report File" ), wxEmptyString,
|
||||
|
@ -555,7 +555,7 @@ void DIALOG_DRC_CONTROL::writeReport( FILE* fp )
|
|||
int count;
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ void WinEDA_PcbFrame::InstallNetlistFrame( wxDC* DC, const wxPoint& pos )
|
|||
|
||||
if( !fn.FileExists() )
|
||||
{
|
||||
fn = GetScreen()->m_FileName;
|
||||
fn = GetScreen()->GetFileName();
|
||||
fn.SetExt( NetExtBuffer );
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ static int mapYto( int y )
|
|||
*/
|
||||
void WinEDA_PcbFrame::ExportToGenCAD( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName fn = GetScreen()->m_FileName;
|
||||
wxFileName fn = GetScreen()->GetFileName();
|
||||
wxString msg, ext, wildcard;
|
||||
FILE* file;
|
||||
|
||||
|
@ -540,7 +540,7 @@ bool CreateHeaderInfoData( FILE* file, WinEDA_PcbFrame* frame )
|
|||
msg = wxT( "USER " ) + wxGetApp().GetAppName() + wxT( " " ) +
|
||||
GetBuildVersion();
|
||||
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 );
|
||||
msg = wxT( "REVISION " ) + screen->m_Revision + wxT( " " ) +
|
||||
screen->m_Date;
|
||||
|
|
|
@ -1134,12 +1134,13 @@ void WinEDA_PcbFrame::OnExportVRML( wxCommandEvent& event )
|
|||
|
||||
// Build default file name
|
||||
wxString ext = wxT( "wrl" );
|
||||
fn = GetScreen()->m_FileName;
|
||||
fn = GetScreen()->GetFileName();
|
||||
fn.SetExt( ext );
|
||||
|
||||
DIALOG_EXPORT_3DFILE dlg( this );
|
||||
dlg.FilePicker()->SetPath( fn.GetFullPath() );
|
||||
dlg.SetSubdir( subDirFor3Dshapes );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
|
|||
switch( id )
|
||||
{
|
||||
case ID_LOAD_FILE:
|
||||
LoadOnePcbFile( GetScreen()->m_FileName, false, true );
|
||||
LoadOnePcbFile( GetScreen()->GetFileName(), false, true );
|
||||
ReCreateAuxiliaryToolbar();
|
||||
SetToolbars();
|
||||
break;
|
||||
|
@ -66,7 +66,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
|
|||
}
|
||||
else
|
||||
{
|
||||
fn = GetScreen()->m_FileName;
|
||||
fn = GetScreen()->GetFileName();
|
||||
fn.SetExt( BACKUP_FILE_EXT );
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,8 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
|
|||
|
||||
LoadOnePcbFile( fn.GetFullPath(), false );
|
||||
fn.SetExt( PcbFileExtension );
|
||||
GetScreen()->m_FileName = fn.GetFullPath();
|
||||
SetTitle( GetScreen()->m_FileName );
|
||||
GetScreen()->SetFileName( fn.GetFullPath() );
|
||||
SetTitle( GetScreen()->GetFileName() );
|
||||
ReCreateAuxiliaryToolbar();
|
||||
SetToolbars();
|
||||
break;
|
||||
|
@ -98,16 +98,16 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
|
|||
|
||||
case ID_NEW_BOARD:
|
||||
Clear_Pcb( true );
|
||||
GetScreen()->m_FileName.Printf( wxT( "%s%cnoname%s" ),
|
||||
GetScreen()->GetFileName().Printf( wxT( "%s%cnoname%s" ),
|
||||
GetChars( wxGetCwd() ), DIR_SEP,
|
||||
GetChars( PcbFileExtension ) );
|
||||
SetTitle( GetScreen()->m_FileName );
|
||||
SetTitle( GetScreen()->GetFileName() );
|
||||
ReCreateLayerBox( NULL );
|
||||
SetToolbars();
|
||||
break;
|
||||
|
||||
case ID_SAVE_BOARD:
|
||||
SavePcbFile( GetScreen()->m_FileName );
|
||||
SavePcbFile( GetScreen()->GetFileName() );
|
||||
break;
|
||||
|
||||
case ID_SAVE_BOARD_AS:
|
||||
|
@ -152,7 +152,7 @@ the changes?" ) ) )
|
|||
|
||||
if( aAppend )
|
||||
{
|
||||
GetScreen()->m_FileName = wxEmptyString;
|
||||
GetScreen()->SetFileName( wxEmptyString );
|
||||
OnModify();
|
||||
GetBoard()->m_Status_Pcb = 0;
|
||||
}
|
||||
|
@ -185,20 +185,20 @@ the changes?" ) ) )
|
|||
if( !aAppend )
|
||||
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
|
||||
*/
|
||||
|
||||
source = wxFopen( GetScreen()->m_FileName, wxT( "rt" ) );
|
||||
source = wxFopen( GetScreen()->GetFileName(), wxT( "rt" ) );
|
||||
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 );
|
||||
return false;
|
||||
}
|
||||
|
||||
FILE_LINE_READER fileReader( source, GetScreen()->m_FileName );
|
||||
FILE_LINE_READER fileReader( source, GetScreen()->GetFileName() );
|
||||
|
||||
FILTER_READER reader( fileReader );
|
||||
|
||||
|
@ -225,7 +225,8 @@ this file again." ) );
|
|||
}
|
||||
|
||||
// Reload the corresponding configuration file:
|
||||
wxSetWorkingDirectory( wxPathOnly( GetScreen()->m_FileName ) );
|
||||
wxSetWorkingDirectory( wxPathOnly( GetScreen()->GetFileName() ) );
|
||||
|
||||
if( aAppend )
|
||||
ReadPcbFile( &reader, true );
|
||||
else
|
||||
|
@ -238,7 +239,7 @@ this file again." ) );
|
|||
m_DisplayViaFill = DisplayOpt.DisplayViaFill;
|
||||
|
||||
ReadPcbFile( &reader, false );
|
||||
LoadProjectSettings( GetScreen()->m_FileName );
|
||||
LoadProjectSettings( GetScreen()->GetFileName() );
|
||||
}
|
||||
|
||||
GetScreen()->ClrModify();
|
||||
|
@ -246,20 +247,21 @@ this file again." ) );
|
|||
/* If append option: change the initial board name to <oldname>-append.brd */
|
||||
if( aAppend )
|
||||
{
|
||||
wxString new_filename = GetScreen()->m_FileName.BeforeLast( '.' );
|
||||
wxString new_filename = GetScreen()->GetFileName().BeforeLast( '.' );
|
||||
|
||||
if ( ! new_filename.EndsWith( wxT( "-append" ) ) )
|
||||
new_filename += wxT( "-append" );
|
||||
|
||||
new_filename += wxT( "." ) + PcbFileExtension;
|
||||
|
||||
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 );
|
||||
SetLastProject( GetScreen()->m_FileName );
|
||||
SetTitle( GetScreen()->GetFileName() );
|
||||
SetLastProject( GetScreen()->GetFileName() );
|
||||
|
||||
/* Rebuild the new pad list (for drc and ratsnet control ...) */
|
||||
GetBoard()->m_Status_Pcb = 0;
|
||||
|
@ -331,16 +333,16 @@ bool WinEDA_PcbFrame::SavePcbFile( const wxString& FileName )
|
|||
if( FileName == wxEmptyString )
|
||||
{
|
||||
wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString,
|
||||
GetScreen()->m_FileName, PcbFileWildcard,
|
||||
GetScreen()->GetFileName(), PcbFileWildcard,
|
||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return false;
|
||||
|
||||
GetScreen()->m_FileName = dlg.GetPath();
|
||||
GetScreen()->SetFileName( dlg.GetPath() );
|
||||
}
|
||||
else
|
||||
GetScreen()->m_FileName = FileName;
|
||||
GetScreen()->SetFileName( FileName );
|
||||
|
||||
/* If changes are made, update the board date */
|
||||
if( GetScreen()->IsModify() )
|
||||
|
@ -348,7 +350,7 @@ bool WinEDA_PcbFrame::SavePcbFile( const wxString& FileName )
|
|||
GetScreen()->m_Date = GenDate();
|
||||
}
|
||||
|
||||
pcbFileName = GetScreen()->m_FileName;
|
||||
pcbFileName = GetScreen()->GetFileName();
|
||||
|
||||
/* Get the backup file name */
|
||||
backupFileName = pcbFileName;
|
||||
|
@ -387,8 +389,8 @@ bool WinEDA_PcbFrame::SavePcbFile( const wxString& FileName )
|
|||
|
||||
if( dest )
|
||||
{
|
||||
GetScreen()->m_FileName = pcbFileName.GetFullPath();
|
||||
SetTitle( GetScreen()->m_FileName );
|
||||
GetScreen()->SetFileName( pcbFileName.GetFullPath() );
|
||||
SetTitle( GetScreen()->GetFileName() );
|
||||
|
||||
SavePcbFormatAscii( dest );
|
||||
fclose( dest );
|
||||
|
|
|
@ -134,7 +134,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
|
|||
return;
|
||||
}
|
||||
|
||||
fnFront = GetScreen()->m_FileName;
|
||||
fnFront = GetScreen()->GetFileName();
|
||||
frontLayerName = GetBoard()->GetLayerName( LAYER_N_FRONT );
|
||||
fnFront.SetName( fnFront.GetName() + frontLayerName );
|
||||
fnFront.SetExt( wxT( "pos") );
|
||||
|
@ -149,7 +149,7 @@ void WinEDA_PcbFrame::GenModulesPosition( wxCommandEvent& event )
|
|||
|
||||
if( doBoardBack )
|
||||
{
|
||||
fnBack = GetScreen()->m_FileName;
|
||||
fnBack = GetScreen()->GetFileName();
|
||||
backLayerName = GetBoard()->GetLayerName( LAYER_N_BACK );
|
||||
fnBack.SetName( fnBack.GetName() + backLayerName );
|
||||
fnBack.SetExt( wxT( "pos" ) );
|
||||
|
@ -320,7 +320,7 @@ void WinEDA_PcbFrame::GenModuleReport( wxCommandEvent& event )
|
|||
|
||||
File_Place_Offset = wxPoint( 0, 0 );
|
||||
|
||||
fn = GetScreen()->m_FileName;
|
||||
fn = GetScreen()->GetFileName();
|
||||
fn.SetExt( wxT( "rpt" ) );
|
||||
|
||||
rptfile = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
|
||||
|
|
|
@ -129,7 +129,7 @@ void DIALOG_GENDRILL::GenDrillAndReportFiles( )
|
|||
|
||||
if( s_ToolListBuffer.size() > 0 ) //holes?
|
||||
{
|
||||
fn = m_Parent->GetScreen()->m_FileName;
|
||||
fn = m_Parent->GetScreen()->GetFileName();
|
||||
layer_extend.Empty();
|
||||
|
||||
if( !gen_through_holes )
|
||||
|
@ -220,7 +220,7 @@ void DIALOG_GENDRILL::GenDrillAndReportFiles( )
|
|||
|
||||
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(),
|
||||
m_Parent->GetScreen()->m_FileName,
|
||||
m_Parent->GetScreen()->GetFileName(),
|
||||
m_UnitDrillIsInch,
|
||||
s_HoleListBuffer,
|
||||
s_ToolListBuffer );
|
||||
|
|
|
@ -46,7 +46,7 @@ bool WinEDA_PcbFrame::Clear_Pcb( bool aQuery )
|
|||
SetCurItem( NULL );
|
||||
|
||||
/* clear filename, to avoid overwriting an old file */
|
||||
GetScreen()->m_FileName.Empty();
|
||||
GetScreen()->GetFileName().Empty();
|
||||
|
||||
/* Init new grid size */
|
||||
wxRealPoint gridsize = GetScreen()->GetGridSize();
|
||||
|
@ -101,7 +101,7 @@ bool WinEDA_ModuleEditFrame::Clear_Pcb( bool aQuery )
|
|||
GetBoard()->m_Modules.DeleteAll();
|
||||
|
||||
/* init pointeurs et variables */
|
||||
GetScreen()->m_FileName.Empty();
|
||||
GetScreen()->GetFileName().Empty();
|
||||
|
||||
SetCurItem( NULL );
|
||||
|
||||
|
|
|
@ -448,14 +448,14 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event )
|
|||
|
||||
case wxID_OK:
|
||||
case wxID_YES:
|
||||
SavePcbFile( GetScreen()->m_FileName );
|
||||
SavePcbFile( GetScreen()->GetFileName() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !GetScreen()->m_FileName.IsEmpty() )
|
||||
if( !GetScreen()->GetFileName().IsEmpty() )
|
||||
{
|
||||
wxFileName fn = GetScreen()->m_FileName;
|
||||
wxFileName fn = GetScreen()->GetFileName();
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
|
||||
}
|
||||
|
@ -668,7 +668,7 @@ void WinEDA_PcbFrame::SetLanguage( wxCommandEvent& event )
|
|||
wxString WinEDA_PcbFrame::GetLastNetListRead()
|
||||
{
|
||||
wxFileName absoluteFileName = m_lastNetListRead;
|
||||
wxFileName pcbFileName = GetScreen()->m_FileName;
|
||||
wxFileName pcbFileName = GetScreen()->GetFileName();
|
||||
|
||||
if( !absoluteFileName.MakeAbsolute( pcbFileName.GetPath() )
|
||||
|| !absoluteFileName.FileExists() )
|
||||
|
@ -684,7 +684,7 @@ wxString WinEDA_PcbFrame::GetLastNetListRead()
|
|||
void WinEDA_PcbFrame::SetLastNetListRead( const wxString& aLastNetListRead )
|
||||
{
|
||||
wxFileName relativeFileName = aLastNetListRead;
|
||||
wxFileName pcbFileName = GetScreen()->m_FileName;
|
||||
wxFileName pcbFileName = GetScreen()->GetFileName();
|
||||
|
||||
if( relativeFileName.MakeRelativeTo( pcbFileName.GetPath() )
|
||||
&& relativeFileName.GetFullPath() != aLastNetListRead )
|
||||
|
|
|
@ -164,15 +164,14 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
|
|||
else
|
||||
{ // File does not exists: prepare an empty board
|
||||
wxSetWorkingDirectory( fn.GetPath() );
|
||||
frame->GetScreen()->m_FileName = fn.GetFullPath();
|
||||
frame->GetScreen()->m_FileName.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
|
||||
frame->SetTitle( frame->GetScreen()->m_FileName );
|
||||
frame->SetLastProject( frame->GetScreen()->m_FileName );
|
||||
frame->GetScreen()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) );
|
||||
frame->SetTitle( frame->GetScreen()->GetFileName() );
|
||||
frame->SetLastProject( frame->GetScreen()->GetFileName() );
|
||||
frame->OnModify(); // Ready to save the new empty board
|
||||
|
||||
wxString msg;
|
||||
msg.Printf( _( "File <%s> not existing\nThis is normal for a new project" ),
|
||||
GetChars( frame->GetScreen()->m_FileName ) );
|
||||
GetChars( frame->GetScreen()->GetFileName() ) );
|
||||
wxMessageBox( msg );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event )
|
|||
|
||||
case ID_CONFIG_READ:
|
||||
{
|
||||
fn = GetScreen()->m_FileName;
|
||||
fn = GetScreen()->GetFileName();
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
||||
wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
|
||||
|
@ -175,7 +175,7 @@ void WinEDA_PcbFrame::SaveProjectSettings()
|
|||
{
|
||||
wxFileName fn;
|
||||
|
||||
fn = GetScreen()->m_FileName;
|
||||
fn = GetScreen()->GetFileName();
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
||||
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), fn.GetFullName(),
|
||||
|
|
|
@ -285,7 +285,7 @@ void DIALOG_PLOT::Init_Dialog()
|
|||
// Output directory
|
||||
if( g_PcbPlotOptions.GetOutputDirectory().IsEmpty() )
|
||||
{
|
||||
fileName = m_Parent->GetScreen()->m_FileName;
|
||||
fileName = m_Parent->GetScreen()->GetFileName();
|
||||
m_outputDirectoryName->SetValue( fileName.GetPath() );
|
||||
}
|
||||
else
|
||||
|
@ -612,7 +612,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
|
|||
{
|
||||
s_SelectedLayers |= mask;
|
||||
|
||||
fn = m_Parent->GetScreen()->m_FileName;
|
||||
fn = m_Parent->GetScreen()->GetFileName();
|
||||
fn.SetPath( m_outputDirectoryName->GetValue() );
|
||||
|
||||
// Create file name.
|
||||
|
|
|
@ -264,7 +264,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
|
|||
* is the y coordinate values from - PlotAreaSize.y to 0 */
|
||||
#ifdef USE_WX_ZOOM
|
||||
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 );
|
||||
#endif
|
||||
int ysize = (int) ( PlotAreaSizeInPixels.y / scaley );
|
||||
|
|
|
@ -63,7 +63,7 @@ static const double safetyMargin = 0.1;
|
|||
// see wxPcbStruct.h
|
||||
void WinEDA_PcbFrame::ExportToSpecctra( wxCommandEvent& event )
|
||||
{
|
||||
wxString fullFileName = GetScreen()->m_FileName;
|
||||
wxString fullFileName = GetScreen()->GetFileName();
|
||||
wxString path;
|
||||
wxString name;
|
||||
wxString ext;
|
||||
|
|
|
@ -63,7 +63,7 @@ void WinEDA_PcbFrame::ImportSpecctraSession( wxCommandEvent& event )
|
|||
}
|
||||
*/
|
||||
|
||||
wxString fullFileName = GetScreen()->m_FileName;
|
||||
wxString fullFileName = GetScreen()->GetFileName();
|
||||
wxString path;
|
||||
wxString name;
|
||||
wxString ext;
|
||||
|
|
|
@ -154,7 +154,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
|
|||
return 0; /* no change of name */
|
||||
|
||||
/* Calculation CMP file name by changing the extension name NetList */
|
||||
fn = m_Parent->GetScreen()->m_FileName;
|
||||
fn = m_Parent->GetScreen()->GetFileName();
|
||||
fn.SetExt( NetCmpExtBuffer );
|
||||
|
||||
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 */
|
||||
fn = GetScreen()->m_FileName;
|
||||
fn = GetScreen()->GetFileName();
|
||||
fn.SetExt( NetCmpExtBuffer );
|
||||
wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) +
|
||||
NetCmpExtBuffer;
|
||||
|
|
Loading…
Reference in New Issue