2009-11-04 20:46:53 +00:00
|
|
|
/******************/
|
|
|
|
/* schframe.cpp */
|
|
|
|
/******************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "gestfich.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "bitmaps.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "eeschema_id.h"
|
2008-02-27 19:38:16 +00:00
|
|
|
#include "netlist.h"
|
2010-10-22 12:11:52 +00:00
|
|
|
#include "lib_pin.h"
|
2010-10-04 18:54:14 +00:00
|
|
|
#include "class_library.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "wxEeschemaStruct.h"
|
|
|
|
#include "class_sch_screen.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-11-18 21:16:28 +00:00
|
|
|
#include "dialog_helpers.h"
|
2008-02-27 19:38:16 +00:00
|
|
|
#include "netlist_control.h"
|
2010-02-16 16:21:52 +00:00
|
|
|
#include "libeditframe.h"
|
|
|
|
#include "viewlib_frame.h"
|
2010-02-14 18:14:33 +00:00
|
|
|
#include "hotkeys.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "eeschema_config.h"
|
|
|
|
#include "sch_sheet.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "dialogs/annotate_dialog.h"
|
2010-11-17 21:47:27 +00:00
|
|
|
#include "dialogs/dialog_build_BOM.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "dialogs/dialog_erc.h"
|
|
|
|
#include "dialogs/dialog_print_using_printer.h"
|
2010-10-26 20:25:48 +00:00
|
|
|
#include "dialogs/dialog_schematic_find.h"
|
2010-11-17 21:47:27 +00:00
|
|
|
#include "dialogs/dialog_SVG_print.h"
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
|
|
|
EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, EDA_DRAW_FRAME::OnSockRequestServer )
|
|
|
|
EVT_SOCKET( ID_EDA_SOCKET_EVENT, EDA_DRAW_FRAME::OnSockRequest )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_CLOSE( SCH_EDIT_FRAME::OnCloseWindow )
|
|
|
|
EVT_SIZE( SCH_EDIT_FRAME::OnSize )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_MENU( ID_NEW_PROJECT, SCH_EDIT_FRAME::OnNewProject )
|
|
|
|
EVT_MENU( ID_LOAD_PROJECT, SCH_EDIT_FRAME::OnLoadProject )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, SCH_EDIT_FRAME::OnLoadFile )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_TOOL( ID_NEW_PROJECT, SCH_EDIT_FRAME::OnNewProject )
|
|
|
|
EVT_TOOL( ID_LOAD_PROJECT, SCH_EDIT_FRAME::OnLoadProject )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_MENU( ID_SAVE_PROJECT, SCH_EDIT_FRAME::Save_File )
|
|
|
|
EVT_MENU( ID_SAVE_ONE_SHEET, SCH_EDIT_FRAME::Save_File )
|
|
|
|
EVT_MENU( ID_SAVE_ONE_SHEET_AS, SCH_EDIT_FRAME::Save_File )
|
|
|
|
EVT_TOOL( ID_SAVE_PROJECT, SCH_EDIT_FRAME::Save_File )
|
|
|
|
EVT_MENU( ID_GEN_PLOT_PS, SCH_EDIT_FRAME::ToPlot_PS )
|
|
|
|
EVT_MENU( ID_GEN_PLOT_HPGL, SCH_EDIT_FRAME::ToPlot_HPGL )
|
|
|
|
EVT_MENU( ID_GEN_PLOT_SVG, SCH_EDIT_FRAME::SVG_Print )
|
|
|
|
EVT_MENU( ID_GEN_PLOT_DXF, SCH_EDIT_FRAME::ToPlot_DXF )
|
2011-01-21 19:30:59 +00:00
|
|
|
EVT_MENU( ID_GEN_COPY_SHEET_TO_CLIPBOARD, EDA_DRAW_FRAME::CopyToClipboard )
|
|
|
|
EVT_MENU( ID_GEN_COPY_BLOCK_TO_CLIPBOARD, EDA_DRAW_FRAME::CopyToClipboard )
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_MENU( ID_POPUP_SCH_COPY_ITEM, SCH_EDIT_FRAME::OnCopySchematicItemRequest )
|
2010-01-09 08:50:30 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_MENU( ID_CONFIG_REQ, SCH_EDIT_FRAME::InstallConfigFrame )
|
|
|
|
EVT_MENU( ID_CONFIG_SAVE, SCH_EDIT_FRAME::Process_Config )
|
|
|
|
EVT_MENU( ID_CONFIG_READ, SCH_EDIT_FRAME::Process_Config )
|
2011-02-21 13:54:29 +00:00
|
|
|
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END,
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_EDIT_FRAME::Process_Config )
|
2010-03-20 19:57:59 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_MENU( ID_COLORS_SETUP, SCH_EDIT_FRAME::OnColorConfig )
|
|
|
|
EVT_TOOL( ID_OPTIONS_SETUP, SCH_EDIT_FRAME::OnSetOptions )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, SCH_EDIT_FRAME::SetLanguage )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_TOOL( ID_TO_LIBRARY, SCH_EDIT_FRAME::OnOpenLibraryEditor )
|
|
|
|
EVT_TOOL( ID_TO_LIBVIEW, SCH_EDIT_FRAME::OnOpenLibraryViewer )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_TOOL( ID_TO_PCB, SCH_EDIT_FRAME::OnOpenPcbnew )
|
|
|
|
EVT_TOOL( ID_TO_CVPCB, SCH_EDIT_FRAME::OnOpenCvpcb )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EVT_TOOL( ID_SHEET_SET, EDA_DRAW_FRAME::Process_PageSettings )
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_TOOL( ID_HIERARCHY, SCH_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( wxID_CUT, SCH_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( wxID_COPY, SCH_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( wxID_PASTE, SCH_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( wxID_UNDO, SCH_EDIT_FRAME::GetSchematicFromUndoList )
|
|
|
|
EVT_TOOL( wxID_REDO, SCH_EDIT_FRAME::GetSchematicFromRedoList )
|
|
|
|
EVT_TOOL( ID_GET_ANNOTATE, SCH_EDIT_FRAME::OnAnnotate )
|
|
|
|
EVT_TOOL( wxID_PRINT, SCH_EDIT_FRAME::OnPrint )
|
|
|
|
EVT_TOOL( ID_GET_ERC, SCH_EDIT_FRAME::OnErc )
|
|
|
|
EVT_TOOL( ID_GET_NETLIST, SCH_EDIT_FRAME::OnCreateNetlist )
|
|
|
|
EVT_TOOL( ID_GET_TOOLS, SCH_EDIT_FRAME::OnCreateBillOfMaterials )
|
|
|
|
EVT_TOOL( ID_FIND_ITEMS, SCH_EDIT_FRAME::OnFindItems )
|
|
|
|
EVT_TOOL( ID_BACKANNO_ITEMS, SCH_EDIT_FRAME::OnLoadStuffFile )
|
2009-01-07 15:59:49 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EVT_MENU( ID_GENERAL_HELP, EDA_DRAW_FRAME::GetKicadHelp )
|
|
|
|
EVT_MENU( ID_KICAD_ABOUT, EDA_DRAW_FRAME::GetKicadAbout )
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
// Tools and buttons for vertical toolbar.
|
2011-02-05 19:22:58 +00:00
|
|
|
EVT_TOOL( ID_CANCEL_CURRENT_COMMAND, SCH_EDIT_FRAME::OnCancelCurrentCommand )
|
2011-02-24 20:22:12 +00:00
|
|
|
EVT_TOOL( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnSelectTool )
|
2011-02-21 13:54:29 +00:00
|
|
|
EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
|
|
|
|
SCH_EDIT_FRAME::OnSelectTool )
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2011-02-05 19:22:58 +00:00
|
|
|
EVT_MENU( ID_CANCEL_CURRENT_COMMAND, SCH_EDIT_FRAME::OnCancelCurrentCommand )
|
2009-01-07 15:59:49 +00:00
|
|
|
EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_EDIT_FRAME::Process_Special_Functions )
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
// Tools and buttons options toolbar
|
2009-01-07 15:59:49 +00:00
|
|
|
EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END,
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_EDIT_FRAME::OnSelectOptionToolbar )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-01-07 15:59:49 +00:00
|
|
|
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_EDIT_FRAME::Process_Special_Functions )
|
2009-04-29 17:09:00 +00:00
|
|
|
|
|
|
|
/* Handle user interface update events. */
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_UPDATE_UI( wxID_CUT, SCH_EDIT_FRAME::OnUpdateBlockSelected )
|
|
|
|
EVT_UPDATE_UI( wxID_COPY, SCH_EDIT_FRAME::OnUpdateBlockSelected )
|
|
|
|
EVT_UPDATE_UI( wxID_PASTE, SCH_EDIT_FRAME::OnUpdatePaste )
|
|
|
|
EVT_UPDATE_UI( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnUpdateHiddenPins )
|
|
|
|
EVT_UPDATE_UI( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnUpdateBusOrientation )
|
2011-02-24 20:22:12 +00:00
|
|
|
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnUpdateSelectTool )
|
2011-02-21 13:54:29 +00:00
|
|
|
EVT_UPDATE_UI_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
|
|
|
|
SCH_EDIT_FRAME::OnUpdateSelectTool )
|
2010-03-16 18:22:59 +00:00
|
|
|
|
|
|
|
/* Search dialog events. */
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_FIND_CLOSE( wxID_ANY, SCH_EDIT_FRAME::OnFindDialogClose )
|
|
|
|
EVT_FIND_DRC_MARKER( wxID_ANY, SCH_EDIT_FRAME::OnFindDrcMarker )
|
|
|
|
EVT_FIND( wxID_ANY, SCH_EDIT_FRAME::OnFindSchematicItem )
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father,
|
|
|
|
const wxString& title,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style ) :
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME( father, SCHEMATIC_FRAME, title, pos, size, style )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-01-04 18:52:57 +00:00
|
|
|
m_FrameName = wxT( "SchematicFrame" );
|
|
|
|
m_Draw_Axis = FALSE; // TRUE to show axis
|
2008-02-26 01:07:38 +00:00
|
|
|
m_Draw_Sheet_Ref = TRUE; // TRUE to show sheet references
|
2009-12-02 21:44:03 +00:00
|
|
|
m_CurrentSheet = new SCH_SHEET_PATH();
|
2008-11-24 06:53:43 +00:00
|
|
|
m_CurrentField = NULL;
|
2009-01-04 18:52:57 +00:00
|
|
|
m_Multiflag = 0;
|
|
|
|
m_TextFieldSize = DEFAULT_SIZE_TEXT;
|
|
|
|
m_LibeditFrame = NULL; // Component editor frame.
|
|
|
|
m_ViewlibFrame = NULL; // Frame for browsing component libraries
|
2010-02-24 15:33:03 +00:00
|
|
|
m_DefaultSchematicFileName = NAMELESS_PROJECT;
|
|
|
|
m_DefaultSchematicFileName += wxT( ".sch" );
|
2009-11-04 20:46:53 +00:00
|
|
|
m_ShowAllPins = false;
|
2010-02-02 15:01:09 +00:00
|
|
|
m_previewPosition = wxDefaultPosition;
|
|
|
|
m_previewSize = wxDefaultSize;
|
|
|
|
m_printMonochrome = true;
|
2010-11-29 15:05:01 +00:00
|
|
|
m_printSheetReference = true;
|
2010-02-14 18:14:33 +00:00
|
|
|
m_HotkeysZoomAndGridList = s_Schematic_Hokeys_Descr;
|
2010-03-16 18:22:59 +00:00
|
|
|
m_dlgFindReplace = NULL;
|
|
|
|
m_findReplaceData = new wxFindReplaceData( wxFR_DOWN );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
CreateScreens();
|
|
|
|
|
|
|
|
// Give an icon
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
SetIcon( wxICON( a_icon_eeschema ) );
|
|
|
|
#else
|
|
|
|
SetIcon( wxICON( icon_eeschema ) );
|
|
|
|
#endif
|
|
|
|
|
2011-01-12 21:47:54 +00:00
|
|
|
m_itemToRepeat = NULL;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
/* Get config */
|
2009-04-05 20:49:15 +00:00
|
|
|
LoadSettings();
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
// Internalize grid id to a default value if not found in config or bad:
|
|
|
|
if( (m_LastGridSizeId <= 0)
|
|
|
|
|| ( m_LastGridSizeId < (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000) ) )
|
2009-10-15 11:35:53 +00:00
|
|
|
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
if( DrawPanel )
|
|
|
|
DrawPanel->m_Block_Enable = TRUE;
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
ReCreateMenuBar();
|
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
|
|
|
ReCreateOptToolbar();
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
/* Initialize print and page setup dialog settings. */
|
|
|
|
m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_HIGH );
|
|
|
|
m_pageSetupData.GetPrintData().SetOrientation( wxLANDSCAPE );
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
|
|
|
wxAuiPaneInfo horiz;
|
2009-11-04 20:46:53 +00:00
|
|
|
horiz.Gripper( false );
|
|
|
|
horiz.DockFixed( true );
|
|
|
|
horiz.Movable( false );
|
|
|
|
horiz.Floatable( false );
|
|
|
|
horiz.CloseButton( false );
|
|
|
|
horiz.CaptionVisible( false );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
wxAuiPaneInfo vert( horiz );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
vert.TopDockable( false ).BottomDockable( false );
|
|
|
|
horiz.LeftDockable( false ).RightDockable( false );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( m_HToolBar )
|
|
|
|
m_auimgr.AddPane( m_HToolBar,
|
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( m_VToolBar )
|
2010-10-26 20:25:48 +00:00
|
|
|
m_auimgr.AddPane( m_VToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( m_OptionsToolBar )
|
|
|
|
m_auimgr.AddPane( m_OptionsToolBar,
|
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_OptionsToolBar" ) ).Left() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( DrawPanel )
|
2010-10-26 20:25:48 +00:00
|
|
|
m_auimgr.AddPane( DrawPanel, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
if( MsgPanel )
|
2010-10-26 20:25:48 +00:00
|
|
|
m_auimgr.AddPane( MsgPanel, wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
|
|
|
m_auimgr.Update();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-02-05 02:21:11 +00:00
|
|
|
SetScreen( NULL );
|
2010-03-16 18:22:59 +00:00
|
|
|
SAFE_DELETE( m_CurrentSheet ); // a SCH_SHEET_PATH, on the heap.
|
2011-02-05 02:21:11 +00:00
|
|
|
SAFE_DELETE( g_RootSheet );
|
2010-03-16 18:22:59 +00:00
|
|
|
SAFE_DELETE( m_findReplaceData );
|
2010-10-04 18:54:14 +00:00
|
|
|
CMP_LIBRARY::RemoveAllLibraries();
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_SHEET_PATH* SCH_EDIT_FRAME::GetSheet()
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
|
|
|
return m_CurrentSheet;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function SetSheetNumberAndCount
|
2008-04-30 17:04:22 +00:00
|
|
|
* Set the m_ScreenNumber and m_NumberOfScreen members for screens
|
2009-11-04 20:46:53 +00:00
|
|
|
* must be called after a delete or add sheet command, and when entering a
|
|
|
|
* sheet
|
2008-04-30 17:04:22 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::SetSheetNumberAndCount()
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2010-10-26 20:25:48 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
SCH_SCREENS s_list;
|
2008-04-30 17:04:22 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
/* Set the sheet count, and the sheet number (1 for root sheet)
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
int sheet_count = g_RootSheet->CountSheets();
|
|
|
|
int SheetNumber = 1;
|
|
|
|
wxString current_sheetpath = m_CurrentSheet->Path();
|
|
|
|
SCH_SHEET_LIST SheetList;
|
2009-01-04 18:52:57 +00:00
|
|
|
|
|
|
|
// Examine all sheets path to find the current sheets path,
|
2009-11-04 20:46:53 +00:00
|
|
|
// and count them from root to the current sheet path:
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_PATH* sheet;
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-10-26 20:25:48 +00:00
|
|
|
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
|
2008-04-30 17:04:22 +00:00
|
|
|
{
|
2009-01-04 18:52:57 +00:00
|
|
|
wxString sheetpath = sheet->Path();
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
if( sheetpath == current_sheetpath ) // Current sheet path found
|
|
|
|
break;
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
SheetNumber++; /* Not found, increment sheet
|
|
|
|
* number before this current
|
|
|
|
* path */
|
2008-04-30 17:04:22 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
|
|
|
|
{
|
|
|
|
screen->m_NumberOfScreen = sheet_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetScreen()->m_ScreenNumber = SheetNumber;
|
|
|
|
}
|
2008-04-30 17:04:22 +00:00
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_SCREEN* SCH_EDIT_FRAME::GetScreen() const
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
|
|
|
return m_CurrentSheet->LastScreen();
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
wxString SCH_EDIT_FRAME::GetScreenDesc()
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2008-02-26 01:07:38 +00:00
|
|
|
wxString s = m_CurrentSheet->PathHumanReadable();
|
|
|
|
|
|
|
|
return s;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::CreateScreens()
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2008-02-26 01:07:38 +00:00
|
|
|
if( g_RootSheet == NULL )
|
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
g_RootSheet = new SCH_SHEET();
|
2008-02-26 01:07:38 +00:00
|
|
|
}
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
if( g_RootSheet->GetScreen() == NULL )
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
g_RootSheet->SetScreen( new SCH_SCREEN() );
|
2011-02-05 16:11:24 +00:00
|
|
|
SetScreen( g_RootSheet->GetScreen() );
|
2008-02-26 01:07:38 +00:00
|
|
|
}
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
g_RootSheet->GetScreen()->SetFileName( m_DefaultSchematicFileName );
|
|
|
|
g_RootSheet->GetScreen()->m_Date = GenDate();
|
2008-02-26 01:07:38 +00:00
|
|
|
m_CurrentSheet->Clear();
|
|
|
|
m_CurrentSheet->Push( g_RootSheet );
|
|
|
|
|
2011-02-05 02:21:11 +00:00
|
|
|
if( GetScreen() == NULL )
|
|
|
|
SetScreen( new SCH_SCREEN() );
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2011-02-05 02:21:11 +00:00
|
|
|
GetScreen()->SetZoom( 4 * GetScreen()->m_ZoomScalar );
|
|
|
|
GetScreen()->m_UndoRedoCountMax = 10;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-01-30 22:22:38 +00:00
|
|
|
if( m_LibeditFrame && !m_LibeditFrame->Close() ) // Can close component editor?
|
|
|
|
return;
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_LIST SheetList;
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2011-01-30 22:22:38 +00:00
|
|
|
if( SheetList.IsModified() )
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
|
|
|
wxMessageDialog dialog( this,
|
|
|
|
_( "Schematic modified, Save before exit ?" ),
|
|
|
|
_( "Confirmation" ), wxYES_NO | wxCANCEL |
|
|
|
|
wxICON_EXCLAMATION | wxYES_DEFAULT );
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
switch( dialog.ShowModal() )
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
|
|
|
case wxID_CANCEL:
|
|
|
|
Event.Veto();
|
|
|
|
return;
|
|
|
|
|
|
|
|
case wxID_NO:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_OK:
|
|
|
|
case wxID_YES:
|
|
|
|
SaveProject();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-30 22:22:38 +00:00
|
|
|
SheetList.ClearModifyStatus();
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty()
|
|
|
|
&& (g_RootSheet->GetScreen()->GetDrawItems() != NULL) )
|
|
|
|
SetLastProject( g_RootSheet->GetScreen()->GetFileName() );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
ClearProjectDrawList( g_RootSheet->GetScreen(), TRUE );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* all sub sheets are deleted, only the main sheet is usable */
|
2008-02-26 01:07:38 +00:00
|
|
|
m_CurrentSheet->Clear();
|
|
|
|
SaveSettings();
|
|
|
|
Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
int SCH_EDIT_FRAME::BestZoom()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
int dx, dy;
|
2008-02-26 01:07:38 +00:00
|
|
|
wxSize size;
|
2009-04-05 20:49:15 +00:00
|
|
|
double zoom;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
dx = GetScreen()->m_CurrentSheetDesc->m_Size.x;
|
|
|
|
dy = GetScreen()->m_CurrentSheetDesc->m_Size.y;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
size = DrawPanel->GetClientSize();
|
2010-10-26 20:25:48 +00:00
|
|
|
zoom = MAX( (double) dx / (double) size.x, (double) dy / (double) size.y );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) );
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
return wxRound( zoom * (double) GetScreen()->m_ZoomScalar );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet()
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2009-04-16 08:48:54 +00:00
|
|
|
wxFileName fn = g_RootSheet->GetFileName();
|
2009-01-08 20:29:07 +00:00
|
|
|
|
2010-03-22 08:18:53 +00:00
|
|
|
#ifndef KICAD_GOST
|
|
|
|
wxString filename = fn.GetName();
|
2009-11-04 20:46:53 +00:00
|
|
|
if( ( filename.Len() + m_CurrentSheet->PathHumanReadable().Len() ) < 50 )
|
2010-03-22 08:18:53 +00:00
|
|
|
#else
|
|
|
|
fn.ClearExt();
|
|
|
|
wxString filename = fn.GetFullPath();
|
2010-05-11 14:35:13 +00:00
|
|
|
if( ( filename.Len() + m_CurrentSheet->PathHumanReadable().Len() ) < 80 )
|
2010-03-22 08:18:53 +00:00
|
|
|
#endif
|
|
|
|
|
2009-01-08 20:29:07 +00:00
|
|
|
{
|
|
|
|
filename += m_CurrentSheet->PathHumanReadable();
|
|
|
|
filename.Replace( wxT( "/" ), wxT( "-" ) );
|
|
|
|
filename.RemoveLast();
|
2010-09-30 14:19:09 +00:00
|
|
|
#if defined(KICAD_GOST)
|
|
|
|
filename.Remove( 0, 1 );
|
|
|
|
#endif
|
2009-01-08 20:29:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
filename << wxT( "-" ) << GetScreen()->m_ScreenNumber;
|
2009-01-08 20:29:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return filename;
|
|
|
|
}
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
2010-11-12 16:59:16 +00:00
|
|
|
* Function OnModify
|
2010-02-18 20:07:29 +00:00
|
|
|
* Must be called after a schematic change
|
|
|
|
* in order to set the "modify" flag of the current screen
|
|
|
|
* and update the date in frame reference
|
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnModify( )
|
2010-02-18 20:07:29 +00:00
|
|
|
{
|
2010-10-26 20:25:48 +00:00
|
|
|
GetScreen()->SetModify();
|
2010-02-18 20:07:29 +00:00
|
|
|
|
2010-10-26 20:25:48 +00:00
|
|
|
wxString date = GenDate();
|
|
|
|
SCH_SCREENS s_list;
|
2010-02-18 20:07:29 +00:00
|
|
|
|
|
|
|
// Set the date for each sheet
|
|
|
|
// There are 2 possibilities:
|
|
|
|
// >> change only the current sheet
|
|
|
|
// >> change all sheets.
|
|
|
|
// I believe all sheets in a project must have the same date
|
|
|
|
SCH_SCREEN* screen = s_list.GetFirst();
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2010-02-18 20:07:29 +00:00
|
|
|
for( ; screen != NULL; screen = s_list.GetNext() )
|
|
|
|
screen->m_Date = date;
|
|
|
|
}
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
/*****************************************************************************
|
2009-11-04 20:46:53 +00:00
|
|
|
* Enable or disable menu entry and toolbar buttons according to current
|
|
|
|
* conditions.
|
|
|
|
*****************************************************************************/
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnUpdateBlockSelected( wxUpdateUIEvent& event )
|
2009-04-29 17:09:00 +00:00
|
|
|
{
|
2010-10-26 20:25:48 +00:00
|
|
|
bool enable = ( GetScreen() && GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
event.Enable( enable );
|
2009-04-29 17:09:00 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnUpdatePaste( wxUpdateUIEvent& event )
|
2009-04-29 17:09:00 +00:00
|
|
|
{
|
2011-01-07 19:24:24 +00:00
|
|
|
event.Enable( m_blockItems.GetCount() > 0 );
|
2009-04-29 17:09:00 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
void SCH_EDIT_FRAME::OnUpdateBusOrientation( wxUpdateUIEvent& aEvent )
|
2009-04-29 17:09:00 +00:00
|
|
|
{
|
|
|
|
wxString tool_tip = g_HVLines ?
|
2009-12-02 21:44:03 +00:00
|
|
|
_( "Draw wires and buses in any direction" ) :
|
|
|
|
_( "Draw horizontal and vertical wires and buses only" );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
aEvent.Check( g_HVLines );
|
2010-10-26 20:25:48 +00:00
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_BUS_WIRES_ORIENT, tool_tip );
|
2009-04-29 17:09:00 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
void SCH_EDIT_FRAME::OnUpdateHiddenPins( wxUpdateUIEvent& aEvent )
|
2009-04-29 17:09:00 +00:00
|
|
|
{
|
|
|
|
wxString tool_tip = m_ShowAllPins ? _( "Do not show hidden pins" ) :
|
2009-11-04 20:46:53 +00:00
|
|
|
_( "Show hidden pins" );
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
aEvent.Check( m_ShowAllPins );
|
2009-04-29 17:09:00 +00:00
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_HIDDEN_PINS, tool_tip );
|
|
|
|
}
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnAnnotate( wxCommandEvent& event )
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
2009-10-27 19:30:32 +00:00
|
|
|
DIALOG_ANNOTATE* dlg = new DIALOG_ANNOTATE( this );
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
dlg->ShowModal();
|
|
|
|
dlg->Destroy();
|
|
|
|
}
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2009-07-03 18:25:06 +00:00
|
|
|
DIALOG_ERC* dlg = new DIALOG_ERC( this );
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2008-02-27 19:38:16 +00:00
|
|
|
dlg->ShowModal();
|
|
|
|
dlg->Destroy();
|
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnCreateNetlist( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
if( m_NetlistFormat < NET_TYPE_PCBNEW )
|
|
|
|
m_NetlistFormat = NET_TYPE_PCBNEW;
|
2008-02-27 19:38:16 +00:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2011-02-08 18:39:41 +00:00
|
|
|
NETLIST_DIALOG* dlg = new NETLIST_DIALOG( this );
|
2008-02-27 19:38:16 +00:00
|
|
|
i = dlg->ShowModal();
|
|
|
|
dlg->Destroy();
|
|
|
|
} while( i == NET_PLUGIN_CHANGE );
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2008-02-27 19:38:16 +00:00
|
|
|
// If a plugin is removed or added, rebuild and reopen the new dialog
|
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnCreateBillOfMaterials( wxCommandEvent& )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2009-03-12 15:24:52 +00:00
|
|
|
DIALOG_BUILD_BOM* dlg = new DIALOG_BUILD_BOM( this );
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2008-02-27 19:38:16 +00:00
|
|
|
dlg->ShowModal();
|
|
|
|
dlg->Destroy();
|
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnFindItems( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2010-03-16 18:22:59 +00:00
|
|
|
wxASSERT_MSG( m_findReplaceData != NULL,
|
|
|
|
wxT( "Forgot to create find/replace data. Bad Programmer!" ) );
|
|
|
|
|
2008-02-27 19:38:16 +00:00
|
|
|
this->DrawPanel->m_IgnoreMouseEvents = TRUE;
|
2010-03-16 18:22:59 +00:00
|
|
|
|
|
|
|
if( m_dlgFindReplace )
|
|
|
|
{
|
|
|
|
delete m_dlgFindReplace;
|
|
|
|
m_dlgFindReplace = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_dlgFindReplace = new DIALOG_SCH_FIND( this, m_findReplaceData, m_findDialogPosition,
|
|
|
|
m_findDialogSize );
|
|
|
|
m_dlgFindReplace->SetFindEntries( m_findStringHistoryList );
|
|
|
|
m_dlgFindReplace->SetReplaceEntries( m_replaceStringHistoryList );
|
|
|
|
m_dlgFindReplace->SetMinSize( m_dlgFindReplace->GetBestSize() );
|
|
|
|
m_dlgFindReplace->Show( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnFindDialogClose( wxFindDialogEvent& event )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
2011-02-03 21:57:02 +00:00
|
|
|
// If the user dismissed the dialog with the mouse, this will send the cursor back
|
|
|
|
// to the last item found.
|
|
|
|
OnFindSchematicItem( event );
|
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
if( m_dlgFindReplace )
|
|
|
|
{
|
|
|
|
m_findDialogPosition = m_dlgFindReplace->GetPosition();
|
|
|
|
m_findDialogSize = m_dlgFindReplace->GetSize();
|
|
|
|
m_findStringHistoryList = m_dlgFindReplace->GetFindEntries();
|
|
|
|
m_replaceStringHistoryList = m_dlgFindReplace->GetReplaceEntries();
|
|
|
|
m_dlgFindReplace->Destroy();
|
|
|
|
m_dlgFindReplace = NULL;
|
|
|
|
}
|
|
|
|
|
2011-02-03 21:57:02 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = false;
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2009-01-17 20:31:19 +00:00
|
|
|
wxString fn;
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2009-01-17 20:31:19 +00:00
|
|
|
fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
|
|
|
|
|
|
|
|
if( fn != wxEmptyString )
|
|
|
|
LoadOneEEProject( fn, false );
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
2008-05-07 15:08:16 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnLoadStuffFile( wxCommandEvent& event )
|
2008-05-07 15:08:16 +00:00
|
|
|
{
|
2009-01-04 18:52:57 +00:00
|
|
|
ReadInputStuffFile();
|
2008-05-15 15:59:11 +00:00
|
|
|
DrawPanel->Refresh();
|
2008-05-07 15:08:16 +00:00
|
|
|
}
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnNewProject( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
|
|
|
LoadOneEEProject( wxEmptyString, true );
|
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnLoadProject( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
|
|
|
LoadOneEEProject( wxEmptyString, false );
|
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
wxFileName fn = g_RootSheet->GetScreen()->GetFileName();
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( fn.IsOk() )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2010-05-17 20:35:46 +00:00
|
|
|
fn.SetExt( PcbFileExtension );
|
2010-05-11 14:35:13 +00:00
|
|
|
|
|
|
|
wxString filename = QuoteFullPath( fn );
|
|
|
|
|
|
|
|
ExecuteFile( this, PCBNEW_EXE, filename );
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ExecuteFile( this, PCBNEW_EXE );
|
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
wxFileName fn = g_RootSheet->GetScreen()->GetFileName();
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
fn.SetExt( NetlistFileExtension );
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( fn.IsOk() && fn.FileExists() )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) );
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ExecuteFile( this, CVPCB_EXE );
|
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
if( m_ViewlibFrame )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
m_ViewlibFrame->Show( true );
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-20 21:59:00 +00:00
|
|
|
m_ViewlibFrame = new LIB_VIEW_FRAME( this );
|
2011-02-11 20:48:13 +00:00
|
|
|
m_ViewlibFrame->AdjustScrollBars( wxPoint( 0 , 0 ) );
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
if( m_LibeditFrame )
|
2011-02-11 20:48:13 +00:00
|
|
|
m_LibeditFrame->Show( true );
|
2008-02-27 19:38:16 +00:00
|
|
|
else
|
2010-11-19 16:28:46 +00:00
|
|
|
m_LibeditFrame = new LIB_EDIT_FRAME( this,
|
|
|
|
wxT( "Library Editor" ),
|
|
|
|
wxPoint( -1, -1 ),
|
|
|
|
wxSize( 600, 400 ) );
|
2008-02-27 19:38:16 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
|
|
|
Close( true );
|
|
|
|
}
|
2010-03-20 19:57:59 +00:00
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::SetLanguage( wxCommandEvent& event )
|
2010-03-20 19:57:59 +00:00
|
|
|
{
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_BASE_FRAME::SetLanguage( event );
|
2010-10-26 20:25:48 +00:00
|
|
|
|
2010-03-20 19:57:59 +00:00
|
|
|
if( m_LibeditFrame )
|
2011-01-21 19:30:59 +00:00
|
|
|
m_LibeditFrame->EDA_BASE_FRAME::SetLanguage( event );
|
2010-03-20 19:57:59 +00:00
|
|
|
}
|
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
|
2010-11-11 21:10:27 +00:00
|
|
|
{
|
|
|
|
wxFileName fn;
|
|
|
|
DIALOG_PRINT_USING_PRINTER dlg( this );
|
|
|
|
|
|
|
|
dlg.ShowModal();
|
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
fn = g_RootSheet->GetScreen()->GetFileName();
|
2010-11-11 21:10:27 +00:00
|
|
|
|
|
|
|
wxString default_name = NAMELESS_PROJECT;
|
|
|
|
default_name += wxT( ".sch" );
|
2011-01-20 16:34:57 +00:00
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
if( fn.GetFullName() != default_name )
|
|
|
|
{
|
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
|
|
|
|
}
|
|
|
|
}
|
2010-11-17 21:47:27 +00:00
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::SVG_Print( wxCommandEvent& event )
|
2010-11-17 21:47:27 +00:00
|
|
|
{
|
|
|
|
DIALOG_SVG_PRINT frame( this );
|
|
|
|
|
|
|
|
frame.ShowModal();
|
|
|
|
}
|