2011-10-15 13:25:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
/**
|
|
|
|
* @file schframe.cpp
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <gestfich.h>
|
2012-03-08 17:47:23 +00:00
|
|
|
#include <confirm.h>
|
2012-04-16 01:25:26 +00:00
|
|
|
#include <base_units.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <protos.h>
|
|
|
|
#include <eeschema_id.h>
|
|
|
|
#include <netlist.h>
|
|
|
|
#include <lib_pin.h>
|
|
|
|
#include <class_library.h>
|
|
|
|
#include <wxEeschemaStruct.h>
|
|
|
|
#include <sch_component.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_helpers.h>
|
|
|
|
#include <netlist_control.h>
|
|
|
|
#include <libeditframe.h>
|
|
|
|
#include <viewlib_frame.h>
|
|
|
|
#include <hotkeys.h>
|
|
|
|
#include <eeschema_config.h>
|
|
|
|
#include <sch_sheet.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialogs/annotate_dialog.h>
|
|
|
|
#include <dialogs/dialog_build_BOM.h>
|
|
|
|
#include <dialogs/dialog_erc.h>
|
|
|
|
#include <dialogs/dialog_print_using_printer.h>
|
|
|
|
#include <dialogs/dialog_schematic_find.h>
|
|
|
|
#include <dialogs/dialog_SVG_print.h>
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2011-11-10 17:01:33 +00:00
|
|
|
#include <wx/display.h>
|
2012-01-14 11:52:46 +00:00
|
|
|
#include <build_version.h>
|
2012-02-16 20:03:33 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2012-01-14 11:52:46 +00:00
|
|
|
|
2011-11-10 17:01:33 +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
|
|
|
|
2011-08-18 19:25:12 +00:00
|
|
|
EVT_MENU( ID_SAVE_PROJECT, SCH_EDIT_FRAME::OnSaveProject )
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_MENU( ID_SAVE_ONE_SHEET, SCH_EDIT_FRAME::Save_File )
|
|
|
|
EVT_MENU( ID_SAVE_ONE_SHEET_AS, 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 )
|
2012-05-03 18:37:56 +00:00
|
|
|
EVT_MENU( ID_GEN_PLOT_PDF, SCH_EDIT_FRAME::ToPlot_PDF )
|
2011-01-21 19:30:59 +00:00
|
|
|
EVT_MENU( ID_GEN_COPY_SHEET_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 )
|
2011-04-04 18:05:55 +00:00
|
|
|
EVT_TOOL( wxID_PREFERENCES, 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 )
|
2011-05-28 18:51:32 +00:00
|
|
|
EVT_TOOL( ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP, SCH_EDIT_FRAME::OnOpenLibraryEditor )
|
2010-12-08 20:12:46 +00:00
|
|
|
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 )
|
2011-12-01 16:49:28 +00:00
|
|
|
EVT_TOOL( wxID_REPLACE, SCH_EDIT_FRAME::OnFindItems )
|
2010-12-08 20:12:46 +00:00
|
|
|
EVT_TOOL( ID_BACKANNO_ITEMS, SCH_EDIT_FRAME::OnLoadStuffFile )
|
2011-10-28 20:30:50 +00:00
|
|
|
EVT_TOOL( ID_SCH_MOVE_ITEM, SCH_EDIT_FRAME::OnMoveItem )
|
2011-04-17 13:54:17 +00:00
|
|
|
EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
|
2011-08-04 18:03:26 +00:00
|
|
|
EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp )
|
2011-05-16 19:32:57 +00:00
|
|
|
EVT_MENU( wxID_ABOUT, EDA_BASE_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-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 )
|
2011-10-27 17:51:22 +00:00
|
|
|
EVT_MENU( ID_SCH_DRAG_ITEM, SCH_EDIT_FRAME::OnDragItem )
|
2011-10-28 20:30:50 +00:00
|
|
|
EVT_MENU_RANGE( ID_SCH_ROTATE_CLOCKWISE, ID_SCH_ROTATE_COUNTERCLOCKWISE,
|
|
|
|
SCH_EDIT_FRAME::OnRotate )
|
2011-10-27 13:34:28 +00:00
|
|
|
EVT_MENU_RANGE( ID_SCH_EDIT_ITEM, ID_SCH_EDIT_COMPONENT_FOOTPRINT,
|
|
|
|
SCH_EDIT_FRAME::OnEditItem )
|
2011-10-28 20:30:50 +00:00
|
|
|
EVT_MENU_RANGE( ID_SCH_MIRROR_X, ID_SCH_ORIENT_NORMAL, SCH_EDIT_FRAME::OnOrient )
|
|
|
|
EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
|
|
|
|
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
|
2011-10-26 20:46:04 +00:00
|
|
|
EVT_TOOL( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnSelectOptionToolbar )
|
|
|
|
EVT_TOOL( ID_TB_OPTIONS_BUS_WIRES_ORIENT, 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 )
|
2011-03-02 00:46:08 +00:00
|
|
|
EVT_MENU_RANGE( ID_POPUP_SCH_SELECT_UNIT1, ID_POPUP_SCH_SELECT_UNIT26,
|
|
|
|
SCH_EDIT_FRAME::OnSelectUnit )
|
2011-03-03 01:58:12 +00:00
|
|
|
EVT_MENU_RANGE( ID_POPUP_SCH_CHANGE_TYPE_TEXT, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
|
|
|
|
SCH_EDIT_FRAME::OnConvertTextType )
|
2011-03-02 00:46:08 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
// Multple item selection context menu commands.
|
2011-04-27 19:44:32 +00:00
|
|
|
EVT_MENU_RANGE( ID_SELECT_ITEM_START, ID_SELECT_ITEM_END, SCH_EDIT_FRAME::OnSelectItem )
|
2011-03-25 19:16:05 +00:00
|
|
|
|
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 )
|
2011-11-17 01:06:08 +00:00
|
|
|
EVT_FIND_REPLACE( wxID_ANY, SCH_EDIT_FRAME::OnFindReplace )
|
2011-12-01 16:49:28 +00:00
|
|
|
EVT_FIND_REPLACE_ALL( wxID_ANY, SCH_EDIT_FRAME::OnFindReplace )
|
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 ) :
|
2012-01-09 17:24:01 +00:00
|
|
|
SCH_BASE_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" );
|
2011-12-14 20:03:15 +00:00
|
|
|
m_showAxis = false; // true to show axis
|
|
|
|
m_showBorderAndTitleBlock = true; // true to show sheet references
|
2011-12-01 16:49:28 +00:00
|
|
|
m_CurrentSheet = new SCH_SHEET_PATH();
|
2009-01-04 18:52:57 +00:00
|
|
|
m_TextFieldSize = DEFAULT_SIZE_TEXT;
|
2010-02-24 15:33:03 +00:00
|
|
|
m_DefaultSchematicFileName = NAMELESS_PROJECT;
|
|
|
|
m_DefaultSchematicFileName += wxT( ".sch" );
|
2011-12-09 16:37:11 +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 );
|
2011-04-05 14:46:51 +00:00
|
|
|
m_undoItem = NULL;
|
2011-10-15 13:25:57 +00:00
|
|
|
m_hasAutoSave = true;
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
CreateScreens();
|
|
|
|
|
|
|
|
// Give an icon
|
2011-09-09 19:30:59 +00:00
|
|
|
wxIcon icon;
|
|
|
|
icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
|
|
|
|
SetIcon( icon );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
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
|
|
|
|
2012-05-06 16:55:51 +00:00
|
|
|
// Initialize grid id to the default value (50 mils):
|
|
|
|
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
|
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
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas )
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetEnableBlockCommands( 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
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
// Initialize common print setup dialog settings.
|
|
|
|
m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
|
|
|
|
m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
|
|
|
|
m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
|
|
|
|
m_pageSetupData.GetPrintData().SetNoCopies( 1 );
|
2010-02-02 15:01:09 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2011-09-15 18:25:44 +00:00
|
|
|
EDA_PANEINFO horiz;
|
|
|
|
horiz.HorizontalToolbarPane();
|
|
|
|
|
|
|
|
EDA_PANEINFO vert;
|
|
|
|
vert.VerticalToolbarPane();
|
|
|
|
|
|
|
|
EDA_PANEINFO mesg;
|
|
|
|
mesg.MessageToolbarPane();
|
2009-11-02 22:24:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-16 13:32:23 +00:00
|
|
|
if( m_mainToolBar )
|
|
|
|
m_auimgr.AddPane( m_mainToolBar,
|
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
if( m_drawToolBar )
|
|
|
|
m_auimgr.AddPane( m_drawToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_drawToolBar" ) ).Right() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2011-12-14 20:03:15 +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
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas )
|
|
|
|
m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2011-12-12 14:02:37 +00:00
|
|
|
if( m_messagePanel )
|
|
|
|
m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().
|
|
|
|
Layer(10) );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
|
|
|
m_auimgr.Update();
|
2011-04-12 12:41:13 +00:00
|
|
|
|
|
|
|
// Now Drawpanel is sized, we can use BestZoom to show the component (if any)
|
2011-07-05 12:46:14 +00:00
|
|
|
GetScreen()->SetZoom( BestZoom() );
|
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-04-05 14:46:51 +00:00
|
|
|
SAFE_DELETE( m_undoItem );
|
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
|
|
|
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
|
|
|
{
|
2012-01-05 08:07:11 +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 );
|
2012-01-09 08:35:06 +00:00
|
|
|
|
|
|
|
TITLE_BLOCK tb = g_RootSheet->GetScreen()->GetTitleBlock();
|
|
|
|
tb.SetDate();
|
|
|
|
g_RootSheet->GetScreen()->SetTitleBlock( tb );
|
|
|
|
|
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 )
|
2012-01-05 08:07:11 +00:00
|
|
|
SetScreen( new SCH_SCREEN() );
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2011-07-05 12:46:14 +00:00
|
|
|
GetScreen()->SetZoom( 32.0 );
|
2011-02-05 02:21:11 +00:00
|
|
|
GetScreen()->m_UndoRedoCountMax = 10;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2011-12-08 21:05:43 +00:00
|
|
|
SCH_SHEET_PATH& SCH_EDIT_FRAME::GetCurrentSheet()
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( m_CurrentSheet != NULL, wxT( "SCH_EDIT_FRAME m_CurrentSheet member is NULL." ) );
|
|
|
|
|
|
|
|
return *m_CurrentSheet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::SetCurrentSheet( const SCH_SHEET_PATH& aSheet )
|
|
|
|
{
|
|
|
|
*m_CurrentSheet = aSheet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-05 14:46:51 +00:00
|
|
|
void SCH_EDIT_FRAME::SetUndoItem( const SCH_ITEM* aItem )
|
|
|
|
{
|
2011-06-16 19:52:12 +00:00
|
|
|
// if aItem != NULL, delete a previous m_undoItem, if exists
|
|
|
|
// if aItme = NULL, just clear m_undoItem,
|
|
|
|
// because when calling SetUndoItem( NULL ), we only clear m_undoItem,
|
|
|
|
// because the owner of m_undoItem is no more me.
|
|
|
|
if( aItem && m_undoItem )
|
2011-04-05 14:46:51 +00:00
|
|
|
{
|
|
|
|
delete m_undoItem;
|
|
|
|
}
|
|
|
|
|
2011-06-16 19:52:12 +00:00
|
|
|
m_undoItem = NULL;
|
2011-04-05 14:46:51 +00:00
|
|
|
|
|
|
|
if( aItem )
|
2012-03-17 14:39:27 +00:00
|
|
|
m_undoItem = (SCH_ITEM*) aItem->Clone();
|
2011-06-16 19:52:12 +00:00
|
|
|
|
2011-04-05 14:46:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::SaveUndoItemInUndoList( SCH_ITEM* aItem )
|
|
|
|
{
|
2011-06-09 13:30:46 +00:00
|
|
|
wxCHECK_RET( aItem != NULL,
|
|
|
|
wxT( "Cannot swap undo item structures. Bad programmer!." ) );
|
|
|
|
wxCHECK_RET( m_undoItem != NULL,
|
|
|
|
wxT( "Cannot swap undo item structures. Bad programmer!." ) );
|
|
|
|
wxCHECK_RET( aItem->Type() == m_undoItem->Type(),
|
2011-04-05 14:46:51 +00:00
|
|
|
wxT( "Cannot swap undo item structures. Bad programmer!." ) );
|
|
|
|
|
|
|
|
aItem->SwapData( m_undoItem );
|
|
|
|
SaveCopyInUndoList( aItem, UR_CHANGED );
|
|
|
|
aItem->SwapData( m_undoItem );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-18 19:25:12 +00:00
|
|
|
void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
|
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
|
|
|
|
2011-04-07 17:48:26 +00:00
|
|
|
if( m_ViewlibFrame && !m_ViewlibFrame->Close() ) // Can close component viewer?
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
{
|
2012-03-08 17:47:23 +00:00
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _("Save the changes in\n<%s>\nbefore closing?"),
|
|
|
|
GetChars( g_RootSheet->GetScreen()->GetFileName() ) );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2012-03-08 17:47:23 +00:00
|
|
|
int ii = DisplayExitDialog( this, msg );
|
|
|
|
|
|
|
|
switch( ii )
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
|
|
|
case wxID_CANCEL:
|
2011-08-18 19:25:12 +00:00
|
|
|
aEvent.Veto();
|
2008-02-26 01:07:38 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case wxID_NO:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_OK:
|
|
|
|
case wxID_YES:
|
2011-08-18 19:25:12 +00:00
|
|
|
wxCommandEvent tmp( ID_SAVE_PROJECT );
|
|
|
|
OnSaveProject( tmp );
|
2008-02-26 01:07:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-10 17:01:33 +00:00
|
|
|
// Close the find dialog and perserve it's setting if it is displayed.
|
|
|
|
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-10-15 13:25:57 +00:00
|
|
|
SCH_SCREENS screens;
|
|
|
|
wxFileName fn;
|
|
|
|
|
|
|
|
for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
|
|
|
|
{
|
|
|
|
fn = screen->GetFileName();
|
|
|
|
|
|
|
|
// Auto save file name is the normal file name prepended with $.
|
|
|
|
fn.SetName( wxT( "$" ) + fn.GetName() );
|
|
|
|
|
|
|
|
if( fn.FileExists() && fn.IsFileWritable() )
|
|
|
|
wxRemoveFile( fn.GetFullPath() );
|
|
|
|
}
|
|
|
|
|
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) )
|
2011-03-17 19:14:45 +00:00
|
|
|
UpdateFileHistory( g_RootSheet->GetScreen()->GetFileName() );
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2011-06-15 18:44:24 +00:00
|
|
|
g_RootSheet->GetScreen()->Clear();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-05 12:46:14 +00:00
|
|
|
double 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;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
dx = GetScreen()->GetPageSettings().GetWidthIU();
|
|
|
|
dy = GetScreen()->GetPageSettings().GetHeightIU();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
size = m_canvas->GetClientSize();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-04-12 12:41:13 +00:00
|
|
|
// Reserve no margin because best zoom shows the full page
|
|
|
|
// and margins are already included in function that draws the sheet refernces
|
|
|
|
double margin_scale_factor = 1.0;
|
2011-07-05 12:46:14 +00:00
|
|
|
double zx =(double) dx / ( margin_scale_factor * (double)size.x );
|
|
|
|
double zy = (double) dy / ( margin_scale_factor * (double)size.y );
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2011-07-05 12:46:14 +00:00
|
|
|
double bestzoom = MAX( zx, zy );
|
2011-04-12 12:41:13 +00:00
|
|
|
|
|
|
|
GetScreen()->SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) );
|
2011-03-30 19:20:23 +00:00
|
|
|
|
|
|
|
return bestzoom;
|
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)
|
2011-04-25 06:05:03 +00:00
|
|
|
#ifndef __WINDOWS__
|
2012-03-26 21:45:05 +00:00
|
|
|
wxString newfn;
|
|
|
|
if( filename.StartsWith( wxT( "-" ), &newfn ) )
|
|
|
|
filename = newfn;
|
2011-04-25 06:05:03 +00:00
|
|
|
#endif
|
2010-09-30 14:19:09 +00:00
|
|
|
#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
|
|
|
|
2011-10-15 13:25:57 +00:00
|
|
|
|
2011-10-28 20:30:50 +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();
|
2011-10-15 13:25:57 +00:00
|
|
|
GetScreen()->SetSave();
|
2010-02-18 20:07:29 +00:00
|
|
|
|
2011-12-21 20:21:15 +00:00
|
|
|
if( m_dlgFindReplace == NULL )
|
|
|
|
m_foundItems.SetForceSearch();
|
|
|
|
|
2010-10-26 20:25:48 +00:00
|
|
|
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
|
2012-01-09 08:35:06 +00:00
|
|
|
s_list.SetDate();
|
2010-02-18 20:07:29 +00:00
|
|
|
}
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2011-12-21 20:21:15 +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
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
bool enable = ( GetScreen() && GetScreen()->m_BlockLocate.GetCommand() == 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 );
|
2011-12-14 20:03:15 +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
|
|
|
{
|
2011-12-09 16:37:11 +00:00
|
|
|
wxString tool_tip = m_showAllPins ? _( "Do not show hidden pins" ) :
|
2009-11-04 20:46:53 +00:00
|
|
|
_( "Show hidden pins" );
|
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
aEvent.Check( m_showAllPins );
|
2011-12-14 20:03:15 +00:00
|
|
|
m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_HIDDEN_PINS, tool_tip );
|
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::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;
|
|
|
|
|
|
|
|
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
|
|
|
|
2011-12-01 16:49:28 +00:00
|
|
|
void SCH_EDIT_FRAME::OnFindItems( wxCommandEvent& aEvent )
|
2008-02-27 19:38:16 +00:00
|
|
|
{
|
2011-12-01 16:49:28 +00:00
|
|
|
wxCHECK_RET( m_findReplaceData != NULL,
|
|
|
|
wxT( "Forgot to create find/replace data. Bad Programmer!" ) );
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
this->GetCanvas()->SetIgnoreMouseEvents( true );
|
2010-03-16 18:22:59 +00:00
|
|
|
|
|
|
|
if( m_dlgFindReplace )
|
|
|
|
{
|
|
|
|
delete m_dlgFindReplace;
|
|
|
|
m_dlgFindReplace = NULL;
|
|
|
|
}
|
|
|
|
|
2011-11-10 17:01:33 +00:00
|
|
|
// Verify the find dialog is not drawn off the visible display area in case the
|
|
|
|
// display configuration has changed since the last time the dialog position was
|
|
|
|
// saved.
|
|
|
|
wxRect displayRect = wxDisplay().GetGeometry();
|
|
|
|
wxRect dialogRect = wxRect( m_findDialogPosition, m_findDialogSize );
|
|
|
|
|
|
|
|
wxPoint position = m_findDialogPosition;
|
|
|
|
|
|
|
|
if( !displayRect.Contains( dialogRect ) )
|
|
|
|
{
|
|
|
|
position = wxDefaultPosition;
|
|
|
|
}
|
|
|
|
|
2011-12-01 16:49:28 +00:00
|
|
|
int style = 0;
|
|
|
|
|
|
|
|
if( aEvent.GetId() == wxID_REPLACE )
|
|
|
|
style = wxFR_REPLACEDIALOG;
|
|
|
|
|
|
|
|
m_dlgFindReplace = new DIALOG_SCH_FIND( this, m_findReplaceData, position, m_findDialogSize,
|
|
|
|
style );
|
2011-11-10 17:01:33 +00:00
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
m_dlgFindReplace->SetFindEntries( m_findStringHistoryList );
|
|
|
|
m_dlgFindReplace->SetReplaceEntries( m_replaceStringHistoryList );
|
|
|
|
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-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( 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();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->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
|
2011-10-28 20:30:50 +00:00
|
|
|
{
|
2008-02-27 19:38:16 +00:00
|
|
|
ExecuteFile( this, PCBNEW_EXE );
|
2011-10-28 20:30:50 +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::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
|
2011-10-28 20:30:50 +00:00
|
|
|
{
|
2008-02-27 19:38:16 +00:00
|
|
|
ExecuteFile( this, CVPCB_EXE );
|
2011-10-28 20:30:50 +00:00
|
|
|
}
|
2008-02-27 19:38:16 +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
|
|
|
{
|
2011-05-28 18:51:32 +00:00
|
|
|
SCH_COMPONENT* component = NULL;
|
|
|
|
if( event.GetId() == ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP )
|
|
|
|
{
|
|
|
|
SCH_ITEM* item = GetScreen()->GetCurItem();
|
2011-10-28 20:30:50 +00:00
|
|
|
|
|
|
|
if( (item == NULL) || (item->GetFlags() != 0) || ( item->Type() != SCH_COMPONENT_T ) )
|
2011-05-28 18:51:32 +00:00
|
|
|
{
|
|
|
|
wxMessageBox( _("Error: not a component or no component" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
component = (SCH_COMPONENT*) item;
|
|
|
|
}
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
if( m_LibeditFrame )
|
2011-05-28 18:51:32 +00:00
|
|
|
{
|
|
|
|
if( m_LibeditFrame->IsIconized() )
|
|
|
|
m_LibeditFrame->Iconize( false );
|
2011-10-28 20:30:50 +00:00
|
|
|
|
2011-05-28 18:51:32 +00:00
|
|
|
m_LibeditFrame->Raise();
|
|
|
|
}
|
2008-02-27 19:38:16 +00:00
|
|
|
else
|
2011-10-28 20:30:50 +00:00
|
|
|
{
|
2010-11-19 16:28:46 +00:00
|
|
|
m_LibeditFrame = new LIB_EDIT_FRAME( this,
|
|
|
|
wxT( "Library Editor" ),
|
|
|
|
wxPoint( -1, -1 ),
|
|
|
|
wxSize( 600, 400 ) );
|
2011-10-28 20:30:50 +00:00
|
|
|
}
|
|
|
|
|
2011-05-28 18:51:32 +00:00
|
|
|
if( component )
|
|
|
|
{
|
|
|
|
LIB_ALIAS* entry = CMP_LIBRARY::FindLibraryEntry( component->GetLibName() );
|
2011-10-28 20:30:50 +00:00
|
|
|
|
2011-05-28 18:51:32 +00:00
|
|
|
if( entry == NULL ) // Should not occur
|
|
|
|
return;
|
2011-10-28 20:30:50 +00:00
|
|
|
|
2011-05-28 18:51:32 +00:00
|
|
|
CMP_LIBRARY* library = entry->GetLibrary();
|
|
|
|
m_LibeditFrame->LoadComponentAndSelectLib( entry, library );
|
|
|
|
}
|
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();
|
|
|
|
}
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2011-10-15 13:25:57 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData )
|
2011-03-28 19:26:31 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE );
|
2012-04-26 21:34:20 +00:00
|
|
|
TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness, IU_PER_MILS );
|
2011-03-28 19:26:31 +00:00
|
|
|
}
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
void SCH_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
int id = aEvent.GetId();
|
2011-04-27 19:44:32 +00:00
|
|
|
int index = id - ID_SELECT_ITEM_START;
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
if( (id >= ID_SELECT_ITEM_START && id <= ID_SELECT_ITEM_END)
|
2011-03-25 19:16:05 +00:00
|
|
|
&& (index >= 0 && index < m_collectedItems.GetCount()) )
|
|
|
|
{
|
|
|
|
SCH_ITEM* item = m_collectedItems[index];
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAbortRequest( false );
|
2011-03-25 19:16:05 +00:00
|
|
|
GetScreen()->SetCurItem( item );
|
|
|
|
}
|
|
|
|
}
|
2011-10-15 13:25:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool SCH_EDIT_FRAME::isAutoSaveRequired() const
|
|
|
|
{
|
|
|
|
SCH_SHEET_LIST SheetList;
|
|
|
|
|
|
|
|
return SheetList.IsAutoSaveRequired();
|
|
|
|
}
|
2012-01-04 22:08:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::addCurrentItemToList( wxDC* aDC )
|
|
|
|
{
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
SCH_ITEM* item = screen->GetCurItem();
|
|
|
|
|
|
|
|
wxCHECK_RET( item != NULL, wxT( "Cannot add current item to list." ) );
|
|
|
|
|
|
|
|
m_canvas->SetAutoPanRequest( false );
|
|
|
|
|
|
|
|
SCH_ITEM* undoItem = item;
|
|
|
|
|
|
|
|
if( item->Type() == SCH_SHEET_PIN_T )
|
|
|
|
{
|
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) item->GetParent();
|
|
|
|
|
|
|
|
wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T),
|
|
|
|
wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
|
|
|
|
|
|
|
|
undoItem = sheet;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item->IsNew() )
|
|
|
|
{
|
|
|
|
if( item->Type() == SCH_SHEET_T )
|
|
|
|
{
|
|
|
|
// Fix the size and position of the new sheet using the last values set by
|
|
|
|
// the m_mouseCaptureCallback function.
|
|
|
|
m_canvas->SetMouseCapture( NULL, NULL );
|
|
|
|
|
|
|
|
if( !EditSheet( (SCH_SHEET*)item, aDC ) )
|
|
|
|
{
|
|
|
|
screen->SetCurItem( NULL );
|
|
|
|
item->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
|
|
|
|
delete item;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetSheetNumberAndCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( undoItem == item )
|
|
|
|
{
|
|
|
|
if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
|
2012-02-26 18:39:39 +00:00
|
|
|
screen->Append( item );
|
2012-01-04 22:08:46 +00:00
|
|
|
|
|
|
|
SetRepeatItem( item );
|
|
|
|
|
|
|
|
SaveCopyInUndoList( undoItem, UR_NEW );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SaveCopyInUndoList( undoItem, UR_CHANGED );
|
|
|
|
( (SCH_SHEET*)undoItem )->AddPin( (SCH_SHEET_PIN*) item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SaveUndoItemInUndoList( undoItem );
|
|
|
|
}
|
|
|
|
|
|
|
|
item->ClearFlags();
|
|
|
|
screen->SetModify();
|
|
|
|
screen->SetCurItem( NULL );
|
|
|
|
m_canvas->SetMouseCapture( NULL, NULL );
|
|
|
|
m_canvas->EndMouseCapture();
|
|
|
|
|
|
|
|
if( item->IsConnectable() )
|
|
|
|
screen->TestDanglingEnds();
|
|
|
|
|
|
|
|
if( aDC )
|
|
|
|
{
|
|
|
|
EDA_CROSS_HAIR_MANAGER( m_canvas, aDC ); // Erase schematic cursor
|
|
|
|
undoItem->Draw( m_canvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
|
|
|
}
|
|
|
|
}
|
2012-01-14 11:52:46 +00:00
|
|
|
|
|
|
|
/* sets the main window title bar text.
|
|
|
|
* If file name defined by SCH_SCREEN::m_FileName is not set, the title is set to the
|
|
|
|
* application name appended with no file.
|
|
|
|
* Otherwise, the title is set to the hierarchical sheet path and the full file name,
|
|
|
|
* and read only is appended to the title if the user does not have write
|
|
|
|
* access to the file.
|
|
|
|
*/
|
|
|
|
void SCH_EDIT_FRAME::UpdateTitle()
|
|
|
|
{
|
|
|
|
wxString title;
|
|
|
|
|
|
|
|
if( GetScreen()->GetFileName() == m_DefaultSchematicFileName )
|
|
|
|
{
|
2012-05-10 06:25:27 +00:00
|
|
|
title.Printf( wxT( "Eeschema %s [%s]" ), GetChars( GetBuildVersion() ),
|
|
|
|
GetChars( GetScreen()->GetFileName() ) );
|
2012-01-14 11:52:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxFileName fn( GetScreen()->GetFileName() );
|
|
|
|
|
|
|
|
// Often the /path/to/filedir is blank because of the FullFileName argument
|
|
|
|
// passed to LoadOneEEFile() which omits the path on non-root schematics.
|
|
|
|
// Making the path absolute solves this problem.
|
|
|
|
fn.MakeAbsolute();
|
2012-05-10 06:25:27 +00:00
|
|
|
title.Printf( wxT( "[ %s %s] (%s)" ),
|
|
|
|
GetChars( fn.GetName() ),
|
|
|
|
GetChars( m_CurrentSheet->PathHumanReadable() ),
|
|
|
|
GetChars( fn.GetPath() ) );
|
2012-01-14 11:52:46 +00:00
|
|
|
|
|
|
|
if( fn.FileExists() )
|
|
|
|
{
|
|
|
|
if( !fn.IsFileWritable() )
|
|
|
|
title << _( " [Read Only]" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
title << _( " [no file]" );
|
|
|
|
|
|
|
|
}
|
2012-05-10 06:25:27 +00:00
|
|
|
|
|
|
|
SetTitle( title );
|
2012-01-14 11:52:46 +00:00
|
|
|
}
|