Commit 93ebdb2c authored by jean-pierre charras's avatar jean-pierre charras

All: better code to handle opened frames libview, libedit, modview, modedit.

Other minor fixes.
parent b810135e
......@@ -55,16 +55,16 @@ const wxChar* traceAutoSave = wxT( "KicadAutoSave" );
static const wxChar* entryAutoSaveInterval = wxT( "AutoSaveInterval" );
EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* father,
ID_DRAWFRAME_TYPE idtype,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style ) :
wxFrame( father, wxID_ANY, title, pos, size, style )
EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent,
ID_DRAWFRAME_TYPE aFrameType,
const wxString& aTitle,
const wxPoint& aPos, const wxSize& aSize,
long aStyle, const wxString & aFrameName ) :
wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName )
{
wxSize minsize;
m_Ident = idtype;
m_Ident = aFrameType;
m_mainToolBar = NULL;
m_FrameIsActive = true;
m_hasAutoSave = false;
......@@ -79,7 +79,7 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* father,
SetSizeHints( minsize.x, minsize.y, -1, -1, -1, -1 );
if( ( size.x < minsize.x ) || ( size.y < minsize.y ) )
if( ( aSize.x < minsize.x ) || ( aSize.y < minsize.y ) )
SetSize( 0, 0, minsize.x, minsize.y );
// Create child subwindows.
......
......@@ -84,10 +84,12 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, EDA_BASE_FRAME )
END_EVENT_TABLE()
EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* father, ID_DRAWFRAME_TYPE idtype,
const wxString& title,
const wxPoint& pos, const wxSize& size, long style ) :
EDA_BASE_FRAME( father, idtype, title, pos, size, style )
EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* aParent,
ID_DRAWFRAME_TYPE aFrameType,
const wxString& aTitle,
const wxPoint& aPos, const wxSize& aSize,
long aStyle, const wxString & aFrameName ) :
EDA_BASE_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
{
m_drawToolBar = NULL;
m_optionsToolBar = NULL;
......
......@@ -67,6 +67,7 @@ BEGIN_EVENT_TABLE( DISPLAY_FOOTPRINTS_FRAME, PCB_BASE_FRAME )
DISPLAY_FOOTPRINTS_FRAME::OnUpdateLineDrawMode )
END_EVENT_TABLE()
#define DISPLAY_FOOTPRINTS_FRAME_NAME wxT( "CmpFrame" )
/***************************************************************************/
/* DISPLAY_FOOTPRINTS_FRAME: the frame to display the current focused footprint */
......@@ -76,9 +77,10 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* parent,
const wxString& title,
const wxPoint& pos,
const wxSize& size, long style ) :
PCB_BASE_FRAME( parent, CVPCB_DISPLAY_FRAME_TYPE, title, pos, size, style )
PCB_BASE_FRAME( parent, CVPCB_DISPLAY_FRAME_TYPE, title, pos, size,
style, DISPLAY_FOOTPRINTS_FRAME_NAME )
{
m_FrameName = wxT( "CmpFrame" );
m_FrameName = DISPLAY_FOOTPRINTS_FRAME_NAME;
m_showAxis = true; // true to draw axis.
// Give an icon
......
......@@ -103,10 +103,13 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME )
END_EVENT_TABLE()
#define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" )
CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) :
EDA_BASE_FRAME( NULL, CVPCB_FRAME_TYPE, title, wxDefaultPosition, wxDefaultSize, style )
EDA_BASE_FRAME( NULL, CVPCB_FRAME_TYPE, title, wxDefaultPosition,
wxDefaultSize, style, CVPCB_MAINFRAME_NAME )
{
m_FrameName = wxT( "CvpcbFrame" );
m_FrameName = CVPCB_MAINFRAME_NAME;
m_ListCmp = NULL;
m_FootprintList = NULL;
......
......@@ -54,14 +54,12 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( void )
wxSemaphore semaphore( 0, 1 );
wxString cmpname;
/* Close the current Lib browser, if open, and open a new one, in "modal" mode */
if( m_ViewlibFrame )
{
delete m_ViewlibFrame;
m_ViewlibFrame = NULL;
}
// Close the current Lib browser, if open, and open a new one, in "modal" mode:
LIB_VIEW_FRAME * viewlibFrame = LIB_VIEW_FRAME::GetActiveLibraryViewer();;
if( viewlibFrame )
viewlibFrame->Destroy();
m_ViewlibFrame = new LIB_VIEW_FRAME( this, NULL, &semaphore,
viewlibFrame = new LIB_VIEW_FRAME( this, NULL, &semaphore,
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT );
// Show the library viewer frame until it is closed
// Wait for viewer closing event:
......@@ -71,8 +69,8 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( void )
wxMilliSleep( 50 );
}
cmpname = m_ViewlibFrame->GetSelectedComponent();
delete m_ViewlibFrame;
cmpname = viewlibFrame->GetSelectedComponent();
viewlibFrame->Destroy();
return cmpname;
}
......@@ -133,9 +131,9 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
{
cmpName = SelectComponentFromLibBrowser();
if( aUnit )
*aUnit = m_ViewlibFrame->GetUnit();
*aUnit = LIB_VIEW_FRAME::GetUnit();
if( aConvert )
*aConvert = m_ViewlibFrame->GetConvert();
*aConvert = LIB_VIEW_FRAME::GetConvert();
if( !cmpName.IsEmpty() )
AddHistoryComponentName( aHistoryList, cmpName );
return cmpName;
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -194,6 +194,10 @@ static EDA_HOTKEY HkCreatePin( wxT( "Create Pin" ), HK_LIBEDIT_CREATE_PIN, 'P' )
static EDA_HOTKEY HkInsertPin( wxT( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT );
static EDA_HOTKEY HkMoveLibItem( wxT( "Move Library Item" ), HK_LIBEDIT_MOVE_GRAPHIC_ITEM, 'M' );
// Load/save files
static EDA_HOTKEY HkSaveLib( wxT( "Save Lib" ), HK_SAVE_LIB, 'S' + GR_KB_CTRL );
static EDA_HOTKEY HkSaveSchematic( wxT( "Save Schematic" ), HK_SAVE_SCH, 'S' + GR_KB_CTRL );
static EDA_HOTKEY HkLoadSchematic( wxT( "Load Schematic" ), HK_LOAD_SCH, 'L' + GR_KB_CTRL );
// List of common hotkey descriptors
EDA_HOTKEY* s_Common_Hotkey_List[] =
......@@ -213,6 +217,8 @@ EDA_HOTKEY* s_Common_Hotkey_List[] =
// List of hotkey descriptors for schematic
EDA_HOTKEY* s_Schematic_Hotkey_List[] =
{
&HkSaveSchematic,
&HkLoadSchematic,
&HkFindItem,
&HkFindNextItem,
&HkFindNextDrcMarker,
......@@ -250,6 +256,7 @@ EDA_HOTKEY* s_Schematic_Hotkey_List[] =
// List of hotkey descriptors for library editor
EDA_HOTKEY* s_LibEdit_Hotkey_List[] =
{
&HkSaveLib,
&HkCreatePin,
&HkInsertPin,
&HkEdit,
......
......@@ -43,7 +43,10 @@ enum hotkey_id_commnand {
HK_ADD_HIER_SHEET,
HK_ADD_GRAPHIC_TEXT,
HK_ADD_GRAPHIC_POLYLINE,
HK_ADD_NOCONN_FLAG
HK_ADD_NOCONN_FLAG,
HK_SAVE_LIB,
HK_SAVE_SCH,
HK_LOAD_SCH
};
// List of hotkey descriptors for Eeschema
......
......@@ -50,7 +50,6 @@
#include <dialogs/dialog_edit_component_in_lib.h>
#include <dialogs/dialog_libedit_dimensions.h>
//#include <dialog_helpers.h>
#include <menus_helpers.h>
#include <boost/foreach.hpp>
......@@ -185,17 +184,19 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
LIB_EDIT_FRAME::OnUpdateEditingPart )
END_EVENT_TABLE()
#define LIB_EDIT_FRAME_NAME wxT( "LibeditFrame" )
LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style ) :
SCH_BASE_FRAME( aParent, LIBEDITOR_FRAME_TYPE, title, pos, size, style )
SCH_BASE_FRAME( aParent, LIBEDITOR_FRAME_TYPE, title, pos, size,
style, GetLibEditFrameName() )
{
wxASSERT( aParent );
m_FrameName = wxT( "LibeditFrame" );
m_FrameName = GetLibEditFrameName();
m_showAxis = true; // true to draw axis
m_configPath = wxT( "LibraryEditor" );
SetShowDeMorgan( false );
......@@ -276,9 +277,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
LIB_EDIT_FRAME::~LIB_EDIT_FRAME()
{
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) wxGetApp().GetTopWindow();
frame->SetLibraryEditorWindow( NULL );
m_drawItem = m_lastDrawItem = NULL;
if ( m_tempCopyComponent )
......@@ -287,6 +285,23 @@ LIB_EDIT_FRAME::~LIB_EDIT_FRAME()
m_tempCopyComponent = NULL;
}
/**
* Function GetLibEditFrameName (static)
* @return the frame name used when creating the frame
* used to get a reference to this frame, if exists
*/
const wxChar* LIB_EDIT_FRAME::GetLibEditFrameName()
{
return LIB_EDIT_FRAME_NAME;
}
/* return a reference to the current opened Library editor
* or NULL if no Library editor currently opened
*/
LIB_EDIT_FRAME* LIB_EDIT_FRAME::GetActiveLibraryEditor()
{
return (LIB_EDIT_FRAME*) wxWindow::FindWindowByName(GetLibEditFrameName());
}
void LIB_EDIT_FRAME::LoadSettings()
{
......
......@@ -128,6 +128,20 @@ public:
~LIB_EDIT_FRAME();
/**
* Function GetLibEditFrameName (static)
* @return the frame name used when creating the frame
* used to get a reference to this frame, if exists
*/
static const wxChar* GetLibEditFrameName();
/**
* Function GetActiveLibraryEditor (static)
* @return a reference to the current opened Library editor
* or NULL if no Library editor currently opened
*/
static LIB_EDIT_FRAME* GetActiveLibraryEditor();
void ReCreateMenuBar();
/**
......
......@@ -70,14 +70,14 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
// New
AddMenuItem( fileMenu,
ID_NEW_PROJECT,
_( "&New\tCtrl+N" ),
_( "&New" ),
_( "New schematic project" ),
KiBitmap( new_xpm ) );
// Open
text = AddHotkeyName( _( "&Open" ), s_Schematic_Hokeys_Descr, HK_LOAD_SCH );
AddMenuItem( fileMenu,
ID_LOAD_PROJECT,
_( "&Open\tCtrl+O" ),
ID_LOAD_PROJECT, text,
_( "Open an existing schematic project" ),
KiBitmap( open_document_xpm ) );
......@@ -101,9 +101,10 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AppendSeparator();
// Save schematic project
text = AddHotkeyName( _( "&Save Whole Schematic Project" ),
s_Schematic_Hokeys_Descr, HK_SAVE_SCH );
AddMenuItem( fileMenu,
ID_SAVE_PROJECT,
_( "&Save Whole Schematic Project\tCtrl+S" ),
ID_SAVE_PROJECT, text,
_( "Save all sheets in the schematic project" ),
KiBitmap( save_project_xpm ) );
......
......@@ -62,6 +62,14 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
// Menu File:
wxMenu* fileMenu = new wxMenu;
// Select current library
AddMenuItem( fileMenu,
ID_LIBEDIT_SELECT_CURRENT_LIB,
_( "&Current Library" ),
_( "Select working library" ),
KiBitmap( library_xpm ) );
fileMenu->AppendSeparator();
// Save current library
AddMenuItem( fileMenu,
ID_LIBEDIT_SAVE_CURRENT_LIB,
......@@ -82,7 +90,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
// Export as png file
AddMenuItem( fileMenu,
ID_LIBEDIT_GEN_PNG_FILE,
_( "&Create PNG File from Screen" ),
_( "Create &PNG File from Screen" ),
_( "Create a PNG file from the component displayed on screen" ),
KiBitmap( plot_xpm ) );
......
......@@ -31,29 +31,20 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( wxWindow* aParent,
ID_DRAWFRAME_TYPE aWindowType,
const wxString& aTitle,
const wxPoint& aPosition, const wxSize& aSize,
long aStyle ) :
EDA_DRAW_FRAME( aParent, aWindowType, aTitle, aPosition, aSize, aStyle )
long aStyle, const wxString & aFrameName ) :
EDA_DRAW_FRAME( aParent, aWindowType, aTitle, aPosition, aSize, aStyle, aFrameName )
{
m_ViewlibFrame = NULL;
m_LibeditFrame = NULL;
}
void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
{
if( m_ViewlibFrame )
{
m_ViewlibFrame->Show( true );
return;
}
if( m_LibeditFrame && m_LibeditFrame->m_ViewlibFrame )
{
m_LibeditFrame->m_ViewlibFrame->Show( true );
return;
}
LIB_VIEW_FRAME * viewlibFrame = LIB_VIEW_FRAME::GetActiveLibraryViewer();;
m_ViewlibFrame = new LIB_VIEW_FRAME( this );
if( viewlibFrame )
viewlibFrame->Show( true );
else
new LIB_VIEW_FRAME( this );
}
......
......@@ -178,15 +178,15 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
END_EVENT_TABLE()
#define SCH_EDIT_FRAME_NAME wxT( "SchematicFrame" )
SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style ) :
SCH_BASE_FRAME( father, SCHEMATIC_FRAME_TYPE, title, pos, size, style )
SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* aParent, const wxString& aTitle,
const wxPoint& aPosition, const wxSize& aSize,
long aStyle ) :
SCH_BASE_FRAME( aParent, SCHEMATIC_FRAME_TYPE, aTitle, aPosition, aSize,
aStyle, SCH_EDIT_FRAME_NAME )
{
m_FrameName = wxT( "SchematicFrame" );
m_FrameName = SCH_EDIT_FRAME_NAME;
m_showAxis = false; // true to show axis
m_showBorderAndTitleBlock = true; // true to show sheet references
m_CurrentSheet = new SCH_SHEET_PATH();
......@@ -414,10 +414,12 @@ void SCH_EDIT_FRAME::SaveUndoItemInUndoList( SCH_ITEM* aItem )
void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
{
if( m_LibeditFrame && !m_LibeditFrame->Close() ) // Can close component editor?
LIB_EDIT_FRAME * libeditFrame = LIB_EDIT_FRAME::GetActiveLibraryEditor();;
if( libeditFrame && !libeditFrame->Close() ) // Can close component editor?
return;
if( m_ViewlibFrame && !m_ViewlibFrame->Close() ) // Can close component viewer?
LIB_VIEW_FRAME * viewlibFrame = LIB_VIEW_FRAME::GetActiveLibraryViewer();;
if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer?
return;
SCH_SHEET_LIST SheetList;
......@@ -787,19 +789,20 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
component = (SCH_COMPONENT*) item;
}
if( m_LibeditFrame )
LIB_EDIT_FRAME * libeditFrame = LIB_EDIT_FRAME::GetActiveLibraryEditor();;
if( libeditFrame )
{
if( m_LibeditFrame->IsIconized() )
m_LibeditFrame->Iconize( false );
if( libeditFrame->IsIconized() )
libeditFrame->Iconize( false );
m_LibeditFrame->Raise();
libeditFrame->Raise();
}
else
{
m_LibeditFrame = new LIB_EDIT_FRAME( this,
wxT( "Library Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
libeditFrame = new LIB_EDIT_FRAME( this,
wxT( "Library Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
}
if( component )
......@@ -810,7 +813,7 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
return;
CMP_LIBRARY* library = entry->GetLibrary();
m_LibeditFrame->LoadComponentAndSelectLib( entry, library );
libeditFrame->LoadComponentAndSelectLib( entry, library );
}
}
......@@ -825,8 +828,9 @@ void SCH_EDIT_FRAME::SetLanguage( wxCommandEvent& event )
{
EDA_BASE_FRAME::SetLanguage( event );
if( m_LibeditFrame )
m_LibeditFrame->EDA_BASE_FRAME::SetLanguage( event );
LIB_EDIT_FRAME * libeditFrame = LIB_EDIT_FRAME::GetActiveLibraryEditor();;
if( libeditFrame )
libeditFrame->EDA_BASE_FRAME::SetLanguage( event );
}
......
......@@ -34,7 +34,7 @@
#include <wxEeschemaStruct.h>
#include <general.h>
#include <protos.h>
//#include <protos.h>
#include <viewlib_frame.h>
#include <class_library.h>
#include <hotkeys.h>
......@@ -97,16 +97,16 @@ static wxAcceleratorEntry accels[] =
#define ACCEL_TABLE_CNT ( sizeof( accels ) / sizeof( wxAcceleratorEntry ) )
#define EXTRA_BORDER_SIZE 2
#define LIB_VIEW_FRAME_NAME wxT( "ViewlibFrame" )
LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library,
wxSemaphore* semaphore, long style ) :
SCH_BASE_FRAME( father, VIEWER_FRAME_TYPE, _( "Library Browser" ),
wxDefaultPosition, wxDefaultSize, style )
wxDefaultPosition, wxDefaultSize, style, GetLibViewerFrameName() )
{
wxAcceleratorTable table( ACCEL_TABLE_CNT, accels );
m_FrameName = wxT( "ViewlibFrame" );
m_FrameName = GetLibViewerFrameName();
m_configPath = wxT( "LibraryViewer" );
// Give an icon
......@@ -258,10 +258,20 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library,
LIB_VIEW_FRAME::~LIB_VIEW_FRAME()
{
SCH_BASE_FRAME* frame = (SCH_BASE_FRAME*) GetParent();
frame->SetLibraryViewerWindow( NULL );
}
const wxChar* LIB_VIEW_FRAME::GetLibViewerFrameName()
{
return LIB_VIEW_FRAME_NAME;
}
/* return a reference to the current opened Library viewer
* or NULL if no Library viewer currently opened
*/
LIB_VIEW_FRAME* LIB_VIEW_FRAME::GetActiveLibraryViewer()
{
return (LIB_VIEW_FRAME*) wxWindow::FindWindowByName(GetLibViewerFrameName());
}
void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
......
......@@ -79,13 +79,26 @@ public:
~LIB_VIEW_FRAME();
/**
* Function GetLibViewerFrameName (static)
* @return the frame name used when creating the frame
* used to get a reference to this frame, if exists
*/
static const wxChar* GetLibViewerFrameName();
/**
* Function GetActiveLibraryViewer (static)
* @return a reference to the current opened Library viewer
* or NULL if no Library viewer currently opened
*/
static LIB_VIEW_FRAME* GetActiveLibraryViewer();
void OnSize( wxSizeEvent& event );
/**
* Function OnSashDrag
* resizes the child windows when dragging a sash window border.
*/
void OnSashDrag( wxSashEvent& event );
/**
......@@ -132,8 +145,8 @@ public:
wxString& GetEntryName( void ) const { return m_entryName; }
wxString& GetSelectedComponent( void ) const { return m_exportToEeschemaCmpName; }
int GetUnit( void ) { return m_unit; }
int GetConvert( void ) { return m_convert; }
static int GetUnit( void ) { return m_unit; }
static int GetConvert( void ) { return m_convert; }
private:
/**
......
......@@ -58,17 +58,18 @@ static const wxString cfgShowBorderAndTitleBlock( wxT( "ShowBorderAndTitleBloc
/* class GERBVIEW_FRAME for GerbView */
/*************************************/
GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style ) :
EDA_DRAW_FRAME( father, GERBER_FRAME_TYPE, title, pos, size, style )
#define GERBVIEW_FRAME_NAME wxT( "GerberFrame" )
GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* aParent, const wxString& aTitle,
const wxPoint& aPosition, const wxSize& aSize,
long aStyle ) :
EDA_DRAW_FRAME( aParent, GERBER_FRAME_TYPE, aTitle, aPosition, aSize,
aStyle, GERBVIEW_FRAME_NAME )
{
m_colorsSettings = &g_ColorsSettings;
m_Layout = NULL;
m_FrameName = wxT( "GerberFrame" );
m_FrameName = GERBVIEW_FRAME_NAME;
m_show_layer_manager_tools = true;
m_showAxis = true; // true to show X and Y axis on screen
......
......@@ -190,9 +190,9 @@ private:
// An array sting to store warning messages when reaging a gerber file.
wxArrayString m_Messages;
public:
GERBVIEW_FRAME( wxWindow* father, const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
GERBVIEW_FRAME( wxWindow* aParent, const wxString& aTitle,
const wxPoint& aPosition, const wxSize& aSize,
long aStyle = KICAD_DEFAULT_DRAWFRAME_STYLE );
~GERBVIEW_FRAME();
......
......@@ -45,27 +45,15 @@ class LIB_EDIT_FRAME;
*/
class SCH_BASE_FRAME : public EDA_DRAW_FRAME
{
protected:
LIB_VIEW_FRAME* m_ViewlibFrame; // A library viewer, common to SCH_EDIT_FRAME
// and LIB_EDIT_FRAME.
// has no meaning to LIB_VIEW_FRAME
LIB_EDIT_FRAME* m_LibeditFrame; // the library editor.
// Is used mainly in SCH_EDIT_FRAME
// but is defined here because some functions
// need to know if a library editor or a libray
// viewer is currently opened
public:
SCH_BASE_FRAME( wxWindow* aParent,
ID_DRAWFRAME_TYPE aWindowType,
const wxString& aTitle,
const wxPoint& aPosition, const wxSize& aSize,
long aStyle = KICAD_DEFAULT_DRAWFRAME_STYLE );
long aStyle, const wxString & aFrameName );
SCH_SCREEN* GetScreen() const; // overload EDA_DRAW_FRAME
void SetLibraryViewerWindow( LIB_VIEW_FRAME* aFrame ) { m_ViewlibFrame = aFrame; }
void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload EDA_DRAW_FRAME
const PAGE_INFO& GetPageSettings () const; // overload EDA_DRAW_FRAME
const wxSize GetPageSizeIU() const; // overload EDA_DRAW_FRAME
......
......@@ -42,8 +42,6 @@
/* Forward declarations of classes. */
class FOOTPRINT_EDIT_FRAME;
class FOOTPRINT_VIEWER_FRAME;
class BOARD;
class BOARD_CONNECTED_ITEM;
class MODULE;
......@@ -79,8 +77,6 @@ public:
int m_FastGrid2;
EDA_3D_FRAME* m_Draw3DFrame;
FOOTPRINT_EDIT_FRAME* m_ModuleEditFrame;
FOOTPRINT_VIEWER_FRAME * m_ModuleViewerFrame;
protected:
......@@ -96,10 +92,10 @@ protected:
virtual void unitsChangeRefresh();
public:
PCB_BASE_FRAME( wxWindow* father, ID_DRAWFRAME_TYPE idtype,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
PCB_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType,
const wxString& aTitle,
const wxPoint& aPos, const wxSize& aSize,
long aStyle, const wxString & aFrameName );
~PCB_BASE_FRAME();
......@@ -458,16 +454,6 @@ public:
*/
wxString SelectFootprintFromLibBrowser( void );
/**
* Function GetActiveViewerFrame
* @return a reference to the current Module Viewer Frame if exists
* if called from the PCB editor, this is the m_ModuleViewerFrame
* or m_ModuleEditFrame->m_ModuleViewerFrame
* if called from the module editor, this is the m_ModuleViewerFrame
* or parent->m_ModuleViewerFrame
*/
FOOTPRINT_VIEWER_FRAME * GetActiveViewerFrame();
// ratsnest functions
/**
* Function Compile_Ratsnest
......
......@@ -189,10 +189,9 @@ protected:
void addCurrentItemToList( wxDC* aDC );
public:
SCH_EDIT_FRAME( wxWindow* father,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
SCH_EDIT_FRAME( wxWindow* aParent, const wxString& aTitle,
const wxPoint& aPosition, const wxSize& aSize,
long aStyle = KICAD_DEFAULT_DRAWFRAME_STYLE );
~SCH_EDIT_FRAME();
......@@ -200,8 +199,6 @@ public:
void OnCloseWindow( wxCloseEvent& Event );
void SetLibraryEditorWindow( LIB_EDIT_FRAME* aFrame ) { m_LibeditFrame = aFrame; }
bool GetShowAllPins() const { return m_showAllPins; }
void SetShowAllPins( bool aEnable ) { m_showAllPins = aEnable; }
......
......@@ -160,10 +160,11 @@ protected:
virtual bool doAutoSave();
public:
EDA_BASE_FRAME( wxWindow* father, ID_DRAWFRAME_TYPE idtype,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
EDA_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType,
const wxString& aTitle,
const wxPoint& aPos, const wxSize& aSize,
long aStyle,
const wxString & aFrameName );
~EDA_BASE_FRAME();
......@@ -450,10 +451,12 @@ protected:
virtual void unitsChangeRefresh();
public:
EDA_DRAW_FRAME( wxWindow* father, ID_DRAWFRAME_TYPE idtype,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
EDA_DRAW_FRAME( wxWindow* aParent,
ID_DRAWFRAME_TYPE aFrameType,
const wxString& aTitle,
const wxPoint& aPos, const wxSize& aSize,
long aStyle,
const wxString & aFrameName );
~EDA_DRAW_FRAME();
......
......@@ -41,18 +41,20 @@
static const wxString TreeFrameWidthEntry( wxT( "LeftWinWidth" ) );
#define KICAD_MANAGER_FRAME_NAME wxT( "KicadFrame" )
KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent,
const wxString& title,
const wxPoint& pos,
const wxSize& size ) :
EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_TYPE, title, pos, size )
EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_TYPE, title, pos, size,
KICAD_DEFAULT_DRAWFRAME_STYLE, KICAD_MANAGER_FRAME_NAME )
{
wxString msg;
wxString line;
wxSize clientsize;
m_FrameName = wxT( "KicadFrame" );
m_FrameName = KICAD_MANAGER_FRAME_NAME;
m_VToolBar = NULL; // No Vertical tooolbar used here
m_LeftWin = NULL; // A shashwindow that contains the project tree
m_RightWin = NULL; /* A shashwindow that contains the buttons
......
......@@ -76,11 +76,11 @@ BEGIN_EVENT_TABLE( PCB_BASE_FRAME, EDA_DRAW_FRAME )
END_EVENT_TABLE()
PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* father, ID_DRAWFRAME_TYPE idtype,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style) :
EDA_DRAW_FRAME( father, idtype, title, pos, size, style )
PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType,
const wxString& aTitle,
const wxPoint& aPos, const wxSize& aSize,
long aStyle, const wxString & aFrameName) :
EDA_DRAW_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
{
m_Pcb = NULL;
......@@ -92,8 +92,6 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* father, ID_DRAWFRAME_TYPE idtype,
m_DisplayModText = FILLED; // How to display module texts (line/ filled / sketch)
m_DisplayPcbTrackFill = true; // false = sketch , true = filled
m_Draw3DFrame = NULL; // Display Window in 3D mode (OpenGL)
m_ModuleEditFrame = NULL; // Frame for footprint edition
m_ModuleViewerFrame = NULL; // Frame for footprint viewer
m_UserGridSize = wxRealPoint( 100.0, 100.0 );
m_UserGridUnit = INCHES;
......@@ -805,7 +803,6 @@ void PCB_BASE_FRAME::updateGridSelectBox()
}
}
void PCB_BASE_FRAME::updateZoomSelectBox()
{
if( m_zoomSelectBox == NULL )
......@@ -835,38 +832,3 @@ void PCB_BASE_FRAME::updateZoomSelectBox()
m_zoomSelectBox->SetSelection( i + 1 );
}
}
/* Function GetActiveViewerFrame
* return a reference to the current Module Viewer Frame if exists
* if called from the PCB editor, this is the m_ModuleViewerFrame
* or m_ModuleEditFrame->m_ModuleViewerFrame
* if called from the module editor, this is the m_ModuleViewerFrame
* or parent->m_ModuleViewerFrame
*/
FOOTPRINT_VIEWER_FRAME * PCB_BASE_FRAME::GetActiveViewerFrame()
{
if( m_ModuleViewerFrame )
return m_ModuleViewerFrame;
switch( m_Ident )
{
case PCB_FRAME_TYPE:
if( m_ModuleEditFrame )
return ((PCB_BASE_FRAME*)m_ModuleEditFrame)->m_ModuleViewerFrame;
break;
case MODULE_EDITOR_FRAME_TYPE:
return ((PCB_BASE_FRAME*)GetParent())->m_ModuleViewerFrame;
break;
case MODULE_VIEWER_FRAME_TYPE:
return (FOOTPRINT_VIEWER_FRAME *)this;
break;
default:
break;
}
return NULL;
}
......@@ -304,14 +304,13 @@ void FOOTPRINT_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
BLOCK_SELECTOR* block;
BASE_SCREEN* screen = aPanel->GetScreen();
BOARD_ITEM* item;
wxPoint move_offset;
MODULE* currentModule =
( (PCB_BASE_FRAME*) wxGetApp().GetTopWindow() )->m_ModuleEditFrame->GetBoard()->m_Modules;
FOOTPRINT_EDIT_FRAME * moduleEditFrame = FOOTPRINT_EDIT_FRAME::GetActiveFootprintEditor();
block = &screen->m_BlockLocate;
wxASSERT( moduleEditFrame );
MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules;
BLOCK_SELECTOR* block = &screen->m_BlockLocate;
GRSetDrawMode( aDC, g_XorMode );
if( aErase )
......@@ -320,9 +319,8 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
if( currentModule )
{
move_offset.x = -block->GetMoveVector().x;
move_offset.y = -block->GetMoveVector().y;
item = currentModule->m_Drawings;
wxPoint move_offset = -block->GetMoveVector();
BOARD_ITEM* item = currentModule->m_Drawings;
for( ; item != NULL; item = item->Next() )
{
......@@ -360,8 +358,8 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
if( currentModule )
{
item = currentModule->m_Drawings;
move_offset = - block->GetMoveVector();
BOARD_ITEM* item = currentModule->m_Drawings;
wxPoint move_offset = - block->GetMoveVector();
for( ; item != NULL; item = item->Next() )
{
......
......@@ -189,40 +189,42 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_OPEN_MODULE_EDITOR:
if( m_ModuleEditFrame == NULL )
{
m_ModuleEditFrame = new FOOTPRINT_EDIT_FRAME( this,
_( "Module Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
m_ModuleEditFrame->Show( true );
m_ModuleEditFrame->Zoom_Automatique( false );
FOOTPRINT_EDIT_FRAME * editorFrame =
FOOTPRINT_EDIT_FRAME::GetActiveFootprintEditor();
if( editorFrame == NULL )
{
editorFrame = new FOOTPRINT_EDIT_FRAME( this );
editorFrame->Show( true );
editorFrame->Zoom_Automatique( false );
}
else
{
if( m_ModuleEditFrame->IsIconized() )
m_ModuleEditFrame->Iconize( false );
if( editorFrame->IsIconized() )
editorFrame->Iconize( false );
m_ModuleEditFrame->Raise();
editorFrame->Raise();
// Raising the window does not set the focus on Linux. This should work on
// any platform.
if( wxWindow::FindFocus() != m_ModuleEditFrame )
m_ModuleEditFrame->SetFocus();
if( wxWindow::FindFocus() != editorFrame )
editorFrame->SetFocus();
}
}
break;
case ID_OPEN_MODULE_VIEWER:
if( GetActiveViewerFrame() == NULL )
{
m_ModuleViewerFrame = new FOOTPRINT_VIEWER_FRAME( this, NULL );
m_ModuleViewerFrame->Show( true );
m_ModuleViewerFrame->Zoom_Automatique( false );
FOOTPRINT_VIEWER_FRAME * viewer =
FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer();
if( viewer == NULL )
{
viewer = new FOOTPRINT_VIEWER_FRAME( this, NULL );
viewer->Show( true );
viewer->Zoom_Automatique( false );
}
else
{
FOOTPRINT_VIEWER_FRAME * viewer = GetActiveViewerFrame();
if( viewer->IsIconized() )
viewer->Iconize( false );
......@@ -233,6 +235,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( wxWindow::FindFocus() != viewer )
viewer->SetFocus();
}
}
break;
case ID_PCB_GLOBAL_DELETE:
......
......@@ -39,19 +39,16 @@ void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
if( retvalue == 2 )
{
if( m_ModuleEditFrame == NULL )
{
m_ModuleEditFrame = new FOOTPRINT_EDIT_FRAME( this,
_( "Module Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
}
FOOTPRINT_EDIT_FRAME * editorFrame =
FOOTPRINT_EDIT_FRAME::GetActiveFootprintEditor();
if( editorFrame == NULL )
editorFrame = new FOOTPRINT_EDIT_FRAME( this );
m_ModuleEditFrame->Load_Module_From_BOARD( Module );
editorFrame->Load_Module_From_BOARD( Module );
SetCurItem( NULL );
m_ModuleEditFrame->Show( true );
m_ModuleEditFrame->Iconize( false );
editorFrame->Show( true );
editorFrame->Iconize( false );
}
}
......
......@@ -105,17 +105,19 @@ static wxAcceleratorEntry accels[] =
/* Function FOOTPRINT_WIZARD_FRAME
* it's the constructor for the footprint wizard frame, it creates everything inside
*
*/
#define FOOTPRINT_WIZARD_FRAME_NAME wxT( "FootprintWizard" )
FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( FOOTPRINT_EDIT_FRAME* parent,
wxSemaphore* semaphore, long style ) :
PCB_BASE_FRAME( parent, FOOTPRINT_WIZARD_FRAME_TYPE,
_( "Footprint Wizard" ),
wxDefaultPosition, wxDefaultSize, style )
wxDefaultPosition, wxDefaultSize, style, FOOTPRINT_WIZARD_FRAME_NAME )
{
wxAcceleratorTable table( ACCEL_TABLE_CNT, accels );
m_FrameName = wxT( "FootprintWizard" );
m_FrameName = FOOTPRINT_WIZARD_FRAME_NAME;
m_configPath = wxT( "FootprintWizard" );
m_showAxis = true; // true to draw axis.
......
......@@ -38,6 +38,7 @@ class wxListBox;
class wxSemaphore;
class wxGrid;
class wxGridEvent;
class FOOTPRINT_EDIT_FRAME;
/**
......
......@@ -117,18 +117,13 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
wxSemaphore semaphore( 0, 1 );
// Close the current Lib browser, if opened, and open a new one, in "modal" mode:
FOOTPRINT_VIEWER_FRAME * viewer = GetActiveViewerFrame();
FOOTPRINT_VIEWER_FRAME * viewer = FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer();
if( viewer )
{
viewer->Destroy();
// Clear the 2 existing references
m_ModuleViewerFrame = NULL;
if( m_ModuleEditFrame )
m_ModuleEditFrame->m_ModuleViewerFrame = NULL;
}
m_ModuleViewerFrame = new FOOTPRINT_VIEWER_FRAME( this, &semaphore,
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT );
viewer = new FOOTPRINT_VIEWER_FRAME( this, &semaphore,
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT );
// Show the library viewer frame until it is closed
while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event
......@@ -137,8 +132,8 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
wxMilliSleep( 50 );
}
wxString fpname = m_ModuleViewerFrame->GetSelectedFootprint();
m_ModuleViewerFrame->Destroy();
wxString fpname = viewer->GetSelectedFootprint();
viewer->Destroy();
return fpname;
}
......
......@@ -55,6 +55,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
delete menuBar->Remove( 0 );
// Recreate all menus:
wxString text;
// Menu File:
wxMenu* fileMenu = new wxMenu;
......@@ -99,8 +100,9 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AppendSeparator();
// Save module
AddMenuItem( fileMenu, ID_MODEDIT_SAVE_LIBMODULE,
_( "&Save Module in Active Library" ),
text = AddHotkeyName( _( "&Save Module in Active Library" ),
s_Libedit_Hokeys_Descr, HK_SAVE_LIB );
AddMenuItem( fileMenu, ID_MODEDIT_SAVE_LIBMODULE, text,
_( "Save module in active library" ),
KiBitmap( save_library_xpm ) );
......@@ -136,13 +138,15 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
wxMenu* editMenu = new wxMenu;
// Undo
text = AddHotkeyName( _( "&Undo" ), s_Libedit_Hokeys_Descr, HK_UNDO );
AddMenuItem( editMenu, wxID_UNDO,
_( "&Undo" ), _( "Undo last edit" ),
text, _( "Undo last edit" ),
KiBitmap( undo_xpm ) );
// Redo
text = AddHotkeyName( _( "&Redo" ), s_Libedit_Hokeys_Descr, HK_REDO );
AddMenuItem( editMenu, wxID_REDO,
_( "&Redo" ), _( "Redo the last undo action" ),
text, _( "Redo the last undo action" ),
KiBitmap( redo_xpm ) );
// Delete items
......
......@@ -231,15 +231,16 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_OPEN_MODULE_VIEWER:
if( GetActiveViewerFrame() == NULL )
{
m_ModuleViewerFrame = new FOOTPRINT_VIEWER_FRAME( this, NULL );
m_ModuleViewerFrame->Show( true );
m_ModuleViewerFrame->Zoom_Automatique( false );
FOOTPRINT_VIEWER_FRAME * viewer = FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer();
if( viewer == NULL )
{
viewer = new FOOTPRINT_VIEWER_FRAME( this, NULL );
viewer->Show( true );
viewer->Zoom_Automatique( false );
}
else
{
FOOTPRINT_VIEWER_FRAME * viewer = GetActiveViewerFrame();
if( viewer->IsIconized() )
viewer->Iconize( false );
......@@ -250,6 +251,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( wxWindow::FindFocus() != viewer )
viewer->SetFocus();
}
}
break;
case ID_MODEDIT_DELETE_PART:
......
......@@ -14,13 +14,24 @@ public:
MODULE* CurrentModule;
public:
FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent );
~FOOTPRINT_EDIT_FRAME();
/**
* Function GetFootprintEditorFrameName (static)
* @return the frame name used when creating the frame
* used to get a reference to this frame, if exists
*/
static const wxChar* GetFootprintEditorFrameName();
/**
* Function GetActiveFootprintEditor (static)
* @return a reference to the current opened Footprint editor
* or NULL if no Footprint editor currently opened
*/
static FOOTPRINT_EDIT_FRAME* GetActiveFootprintEditor();
BOARD_DESIGN_SETTINGS& GetDesignSettings() const; // overload PCB_BASE_FRAME, get parent's
void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings ); // overload
......
......@@ -142,15 +142,14 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
END_EVENT_TABLE()
#define FOOTPRINT_EDIT_FRAME_NAME wxT( "ModEditFrame" )
FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style ) :
PCB_BASE_FRAME( aParent, MODULE_EDITOR_FRAME_TYPE, wxEmptyString, pos, size, style )
FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent ) :
PCB_BASE_FRAME( aParent, MODULE_EDITOR_FRAME_TYPE, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() )
{
m_FrameName = wxT( "ModEditFrame" );
m_FrameName = GetFootprintEditorFrameName();
m_showBorderAndTitleBlock = false; // true to show the frame references
m_showAxis = true; // true to show X and Y axis on screen
m_showGridAxis = true; // show the grid origin axis
......@@ -161,6 +160,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent,
icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
SetIcon( icon );
// Show a title (frame title + footprint name):
UpdateTitle();
if( !s_Pcb )
......@@ -234,9 +234,6 @@ FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
// Do not delete PCB_SCREEN (by the destructor of EDA_DRAW_FRAME)
SetScreen( NULL );
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent();
frame->m_ModuleEditFrame = NULL;
// Do not allow PCB_BASE_FRAME::~PCB_BASE_FRAME()
// to delete our precious BOARD, which is also in static FOOTPRINT_EDIT_FRAME::s_Pcb.
// That function, PCB_BASE_FRAME::~PCB_BASE_FRAME(), runs immediately next
......@@ -244,6 +241,19 @@ FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
m_Pcb = 0;
}
const wxChar* FOOTPRINT_EDIT_FRAME::GetFootprintEditorFrameName()
{
return FOOTPRINT_EDIT_FRAME_NAME;
}
/* return a reference to the current opened Footprint editor
* or NULL if no Footprint editor currently opened
*/
FOOTPRINT_EDIT_FRAME* FOOTPRINT_EDIT_FRAME::GetActiveFootprintEditor()
{
return (FOOTPRINT_EDIT_FRAME*)
wxWindow::FindWindowByName(GetFootprintEditorFrameName());
}
BOARD_DESIGN_SETTINGS& FOOTPRINT_EDIT_FRAME::GetDesignSettings() const
{
......
......@@ -107,15 +107,16 @@ static wxAcceleratorEntry accels[] =
#define EXTRA_BORDER_SIZE 2
#define FOOTPRINT_VIEWER_FRAME_NAME wxT( "ModViewFrame" )
FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* parent,
wxSemaphore* semaphore, long style ) :
PCB_BASE_FRAME( parent, MODULE_VIEWER_FRAME_TYPE, _( "Footprint Library Browser" ),
wxDefaultPosition, wxDefaultSize, style )
wxDefaultPosition, wxDefaultSize, style, GetFootprintViewerFrameName() )
{
wxAcceleratorTable table( ACCEL_TABLE_CNT, accels );
m_FrameName = wxT( "ModViewFrame" );
m_FrameName = GetFootprintViewerFrameName();
m_configPath = wxT( "FootprintViewer" );
m_showAxis = true; // true to draw axis.
......@@ -264,8 +265,23 @@ FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME()
{
if( m_Draw3DFrame )
m_Draw3DFrame->Destroy();
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent();
frame->m_ModuleViewerFrame = NULL;
}
/* return the frame name used when creating the frame
* used to get a reference to this frame, if exists
*/
const wxChar* FOOTPRINT_VIEWER_FRAME::GetFootprintViewerFrameName()
{
return FOOTPRINT_VIEWER_FRAME_NAME;
}
/* return a reference to the current opened Footprint viewer
* or NULL if no Footprint viewer currently opened
*/
FOOTPRINT_VIEWER_FRAME* FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer()
{
return (FOOTPRINT_VIEWER_FRAME*)
wxWindow::FindWindowByName(GetFootprintViewerFrameName());
}
......@@ -281,9 +297,7 @@ void FOOTPRINT_VIEWER_FRAME::OnCloseWindow( wxCloseEvent& Event )
// to avoid side effects
}
else
{
Destroy();
}
}
......
......@@ -69,6 +69,20 @@ public:
~FOOTPRINT_VIEWER_FRAME();
/**
* Function GetFootprintViewerFrameName (static)
* @return the frame name used when creating the frame
* used to get a reference to this frame, if exists
*/
static const wxChar* GetFootprintViewerFrameName();
/**
* Function GetActiveFootprintViewer (static)
* @return a reference to the current opened Footprint viewer
* or NULL if no Footprint viewer currently opened
*/
static FOOTPRINT_VIEWER_FRAME* GetActiveFootprintViewer();
wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; }
private:
......
......@@ -264,13 +264,15 @@ END_EVENT_TABLE()
///////****************************///////////:
#define PCB_EDIT_FRAME_NAME wxT( "PcbFrame" )
PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
const wxPoint& pos, const wxSize& size,
long style ) :
PCB_BASE_FRAME( parent, PCB_FRAME_TYPE, title, pos, size, style )
PCB_BASE_FRAME( parent, PCB_FRAME_TYPE, title, pos, size,
style, PCB_EDIT_FRAME_NAME )
{
m_FrameName = wxT( "PcbFrame" );
m_FrameName = PCB_EDIT_FRAME_NAME;
m_showBorderAndTitleBlock = true; // true to display sheet references
m_showAxis = false; // true to display X and Y axis
m_showOriginAxis = true;
......@@ -719,8 +721,9 @@ void PCB_EDIT_FRAME::SetLanguage( wxCommandEvent& event )
m_auimgr.Update();
ReFillLayerWidget();
if( m_ModuleEditFrame )
m_ModuleEditFrame->EDA_DRAW_FRAME::SetLanguage( event );
FOOTPRINT_EDIT_FRAME * moduleEditFrame = FOOTPRINT_EDIT_FRAME::GetActiveFootprintEditor();
if( moduleEditFrame )
moduleEditFrame->EDA_DRAW_FRAME::SetLanguage( event );
}
......
......@@ -73,12 +73,12 @@ void PlotBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, int Layer,
* @param aLayerMask = the mask to define the layers to plot
* @param aPlotVia = true to plot vias, false to skip vias (has meaning
* only for solder mask layers).
* @param aPlotMode = the plot mode (files, sketch). Has meaning for some formats only
* @param aPlotOpt = the plot options (files, sketch). Has meaning for some formats only
* @param aSkipNPTH_Pads = true to skip NPTH Pads, when the pad size and the pad hole
* have the same size. Used in GERBER format only.
*/
void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask,
const PCB_PLOT_PARAMS& plot_opts,
const PCB_PLOT_PARAMS& aPlotOpt,
bool aPlotVia, bool aSkipNPTH_Pads );
void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask,
......
......@@ -103,7 +103,7 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask,
break;
case PAD_OVAL:
aPlotter->FlashPadOval( shape_pos, pad->GetSize(),
aPlotter->FlashPadOval( shape_pos, pad->GetSize(),
pad->GetOrientation(), LINE );
break;
......@@ -111,14 +111,14 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask,
{
wxPoint coord[4];
pad->BuildPadPolygon( coord, wxSize(0,0), 0 );
aPlotter->FlashPadTrapez( shape_pos, coord,
aPlotter->FlashPadTrapez( shape_pos, coord,
pad->GetOrientation(), LINE );
}
break;
case PAD_RECT:
default:
aPlotter->FlashPadRect( shape_pos, pad->GetSize(),
aPlotter->FlashPadRect( shape_pos, pad->GetSize(),
pad->GetOrientation(), LINE );
break;
}
......@@ -745,14 +745,14 @@ void PlotBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, int Layer,
* Silk screen layers are not plotted here.
*/
void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
long aLayerMask, const PCB_PLOT_PARAMS& plot_opts,
long aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt,
bool aPlotVia, bool aSkipNPTH_Pads )
{
wxPoint pos;
wxSize size;
wxString msg;
EDA_DRAW_MODE_T aPlotMode = plot_opts.GetMode();
EDA_DRAW_MODE_T aPlotMode = aPlotOpt.GetMode();
// Plot pcb draw items.
for( BOARD_ITEM* item = aBoard->m_Drawings; item; item = item->Next() )
......@@ -760,19 +760,19 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
switch( item->Type() )
{
case PCB_LINE_T:
PlotDrawSegment( aPlotter, plot_opts, (DRAWSEGMENT*) item, aLayerMask, aPlotMode );
PlotDrawSegment( aPlotter, aPlotOpt, (DRAWSEGMENT*) item, aLayerMask, aPlotMode );
break;
case PCB_TEXT_T:
PlotTextePcb( aPlotter, plot_opts, (TEXTE_PCB*) item, aLayerMask, aPlotMode );
PlotTextePcb( aPlotter, aPlotOpt, (TEXTE_PCB*) item, aLayerMask, aPlotMode );
break;
case PCB_DIMENSION_T:
PlotDimension( aPlotter, plot_opts, (DIMENSION*) item, aLayerMask, aPlotMode );
PlotDimension( aPlotter, aPlotOpt, (DIMENSION*) item, aLayerMask, aPlotMode );
break;
case PCB_TARGET_T:
PlotPcbTarget( aPlotter, plot_opts, (PCB_TARGET*) item, aLayerMask, aPlotMode );
PlotPcbTarget( aPlotter, aPlotOpt, (PCB_TARGET*) item, aLayerMask, aPlotMode );
break;
case PCB_MARKER_T:
......@@ -793,7 +793,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
{
case PCB_MODULE_EDGE_T:
if( aLayerMask & GetLayerMask( item->GetLayer() ) )
Plot_1_EdgeModule( aPlotter, plot_opts, (EDGE_MODULE*) item, aPlotMode, aLayerMask );
Plot_1_EdgeModule( aPlotter, aPlotOpt, (EDGE_MODULE*) item, aPlotMode, aLayerMask );
break;
......@@ -973,7 +973,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
if( ( ( 1 << edge_zone->GetLayer() ) & aLayerMask ) == 0 )
continue;
PlotFilledAreas( aPlotter, plot_opts, edge_zone, aPlotMode );
PlotFilledAreas( aPlotter, aPlotOpt, edge_zone, aPlotMode );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment