2011-10-28 13:43:37 +00:00
|
|
|
/*
|
|
|
|
* 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) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 2004-2011 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
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2010-02-16 16:21:52 +00:00
|
|
|
/**
|
2011-09-30 18:15:37 +00:00
|
|
|
* @file libeditframe.cpp
|
|
|
|
* @brief LIB_EDIT_FRAME class is the component library editor frame.
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <eda_doc.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <wxEeschemaStruct.h>
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <protos.h>
|
|
|
|
#include <eeschema_id.h>
|
|
|
|
#include <libeditframe.h>
|
|
|
|
#include <class_library.h>
|
|
|
|
#include <lib_polyline.h>
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <kicad_device_context.h>
|
|
|
|
#include <hotkeys.h>
|
2009-12-20 19:48:58 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialogs/dialog_lib_edit_text.h>
|
|
|
|
#include <dialogs/dialog_edit_component_in_lib.h>
|
|
|
|
#include <dialogs/dialog_libedit_dimensions.h>
|
2010-11-17 21:47:27 +00:00
|
|
|
|
2012-04-09 09:16:47 +00:00
|
|
|
#include <menus_helpers.h>
|
2010-11-17 21:47:27 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
#include <boost/foreach.hpp>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2012-03-19 20:57:19 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/* Library editor wxConfig entry names. */
|
|
|
|
const wxString lastLibExportPathEntry( wxT( "LastLibraryExportPath" ) );
|
|
|
|
const wxString lastLibImportPathEntry( wxT( "LastLibraryImportPath" ) );
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
/* This method guarantees unique IDs for the library this run of Eeschema
|
2009-04-05 20:49:15 +00:00
|
|
|
* which prevents ID conflicts and eliminates the need to recompile every
|
|
|
|
* source file in the project when adding IDs to include/id.h. */
|
|
|
|
int ExportPartId = ::wxNewId();
|
|
|
|
int ImportPartId = ::wxNewId();
|
|
|
|
int CreateNewLibAndSavePartId = ::wxNewId();
|
|
|
|
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
/*
|
|
|
|
* Static component library editor members. These are static so their
|
|
|
|
* state is saved between editing sessions. This way the last component
|
|
|
|
* that was being edited will be displayed. These members are protected
|
|
|
|
* making it necessary to use the class access methods.
|
|
|
|
*/
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_COMPONENT* LIB_EDIT_FRAME::m_component = NULL;
|
|
|
|
CMP_LIBRARY* LIB_EDIT_FRAME:: m_library = NULL;
|
|
|
|
|
|
|
|
wxString LIB_EDIT_FRAME:: m_aliasName;
|
|
|
|
int LIB_EDIT_FRAME:: m_unit = 1;
|
|
|
|
int LIB_EDIT_FRAME:: m_convert = 1;
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* LIB_EDIT_FRAME::m_lastDrawItem = NULL;
|
|
|
|
LIB_ITEM* LIB_EDIT_FRAME::m_drawItem = NULL;
|
2010-11-19 16:28:46 +00:00
|
|
|
bool LIB_EDIT_FRAME:: m_showDeMorgan = false;
|
|
|
|
wxSize LIB_EDIT_FRAME:: m_clientSize = wxSize( -1, -1 );
|
|
|
|
int LIB_EDIT_FRAME:: m_textSize = DEFAULT_SIZE_TEXT;
|
|
|
|
int LIB_EDIT_FRAME:: m_textOrientation = TEXT_ORIENT_HORIZ;
|
|
|
|
int LIB_EDIT_FRAME:: m_drawLineWidth = 0;
|
|
|
|
FILL_T LIB_EDIT_FRAME:: m_drawFillStyle = NO_FILL;
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_CLOSE( LIB_EDIT_FRAME::OnCloseWindow )
|
|
|
|
EVT_SIZE( LIB_EDIT_FRAME::OnSize )
|
|
|
|
EVT_ACTIVATE( LIB_EDIT_FRAME::OnActivate )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
/* Main horizontal toolbar. */
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_LIB, LIB_EDIT_FRAME::SaveActiveLibrary )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_SELECT_CURRENT_LIB, LIB_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_DELETE_PART, LIB_EDIT_FRAME::DeleteOnePart )
|
2012-02-19 19:53:11 +00:00
|
|
|
EVT_TOOL( ID_TO_LIBVIEW, LIB_EDIT_FRAME::OnOpenLibraryViewer )
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_TOOL( ID_LIBEDIT_NEW_PART, LIB_EDIT_FRAME::CreateNewLibraryPart )
|
2010-12-02 21:41:56 +00:00
|
|
|
EVT_TOOL( ID_LIBEDIT_NEW_PART_FROM_EXISTING, LIB_EDIT_FRAME::OnCreateNewPartFromExisting )
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_TOOL( ID_LIBEDIT_SELECT_PART, LIB_EDIT_FRAME::LoadOneLibraryPart )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_PART, LIB_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( wxID_UNDO, LIB_EDIT_FRAME::GetComponentFromUndoList )
|
|
|
|
EVT_TOOL( wxID_REDO, LIB_EDIT_FRAME::GetComponentFromRedoList )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_PART, LIB_EDIT_FRAME::OnEditComponentProperties )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, LIB_EDIT_FRAME::InstallFieldsEditorDialog )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnCheckComponent )
|
|
|
|
EVT_TOOL( ID_DE_MORGAN_NORMAL_BUTT, LIB_EDIT_FRAME::OnSelectBodyStyle )
|
|
|
|
EVT_TOOL( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnSelectBodyStyle )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_VIEW_DOC, LIB_EDIT_FRAME::OnViewEntryDoc )
|
|
|
|
EVT_TOOL( ID_LIBEDIT_EDIT_PIN_BY_PIN, LIB_EDIT_FRAME::Process_Special_Functions )
|
|
|
|
EVT_TOOL( ExportPartId, LIB_EDIT_FRAME::OnExportPart )
|
|
|
|
EVT_TOOL( CreateNewLibAndSavePartId, LIB_EDIT_FRAME::OnExportPart )
|
|
|
|
EVT_TOOL( ImportPartId, LIB_EDIT_FRAME::OnImportPart )
|
|
|
|
|
2011-04-19 19:19:41 +00:00
|
|
|
EVT_COMBOBOX( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnSelectPart )
|
|
|
|
EVT_COMBOBOX( ID_LIBEDIT_SELECT_ALIAS, LIB_EDIT_FRAME::OnSelectAlias )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
/* Right vertical toolbar. */
|
2011-02-24 20:22:12 +00:00
|
|
|
EVT_TOOL( ID_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnSelectTool )
|
|
|
|
EVT_TOOL_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
|
2011-02-21 13:54:29 +00:00
|
|
|
LIB_EDIT_FRAME::OnSelectTool )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
/* menubar commands */
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_MENU( wxID_EXIT, LIB_EDIT_FRAME::CloseWindow )
|
|
|
|
EVT_MENU( ID_LIBEDIT_SAVE_CURRENT_LIB_AS, LIB_EDIT_FRAME::SaveActiveLibrary )
|
|
|
|
EVT_MENU( ID_LIBEDIT_GEN_PNG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent )
|
|
|
|
EVT_MENU( ID_LIBEDIT_GEN_SVG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent )
|
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 )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2010-12-02 21:41:56 +00:00
|
|
|
EVT_MENU( ID_COLORS_SETUP, LIB_EDIT_FRAME::OnColorConfig )
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_MENU( ID_CONFIG_REQ, LIB_EDIT_FRAME::InstallConfigFrame )
|
|
|
|
EVT_MENU( ID_CONFIG_SAVE, LIB_EDIT_FRAME::Process_Config )
|
|
|
|
EVT_MENU( ID_CONFIG_READ, LIB_EDIT_FRAME::Process_Config )
|
|
|
|
EVT_MENU( ID_COLORS_SETUP, LIB_EDIT_FRAME::Process_Config )
|
|
|
|
EVT_MENU( ID_LIBEDIT_DIMENSIONS, LIB_EDIT_FRAME::InstallDimensionsDialog )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
// Multiple item selection context menu commands.
|
2011-04-27 19:44:32 +00:00
|
|
|
EVT_MENU_RANGE( ID_SELECT_ITEM_START, ID_SELECT_ITEM_END, LIB_EDIT_FRAME::OnSelectItem )
|
|
|
|
|
2011-02-23 14:20:01 +00:00
|
|
|
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END,
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME::Process_Config )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, LIB_EDIT_FRAME::SetLanguage )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2011-02-28 13:53:49 +00:00
|
|
|
/* Context menu events and commands. */
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_MENU( ID_LIBEDIT_EDIT_PIN, LIB_EDIT_FRAME::OnEditPin )
|
2011-02-28 13:53:49 +00:00
|
|
|
EVT_MENU( ID_LIBEDIT_ROTATE_ITEM, LIB_EDIT_FRAME::OnRotateItem )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
EVT_MENU_RANGE( ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM,
|
2011-02-28 13:53:49 +00:00
|
|
|
ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT,
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME::Process_Special_Functions )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME::Process_Special_Functions )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
/* Update user interface elements. */
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_UPDATE_UI( ExportPartId, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
|
|
|
EVT_UPDATE_UI( CreateNewLibAndSavePartId, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
2010-12-02 21:41:56 +00:00
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_NEW_PART_FROM_EXISTING, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_UPDATE_UI( wxID_UNDO, LIB_EDIT_FRAME::OnUpdateUndo )
|
|
|
|
EVT_UPDATE_UI( wxID_REDO, LIB_EDIT_FRAME::OnUpdateRedo )
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_LIB, LIB_EDIT_FRAME::OnUpdateSaveCurrentLib )
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, LIB_EDIT_FRAME::OnUpdateViewDoc )
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_PIN, LIB_EDIT_FRAME::OnUpdatePinByPin )
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnUpdatePartNumber )
|
|
|
|
EVT_UPDATE_UI( ID_LIBEDIT_SELECT_ALIAS, LIB_EDIT_FRAME::OnUpdateSelectAlias )
|
|
|
|
EVT_UPDATE_UI( ID_DE_MORGAN_NORMAL_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganNormal )
|
|
|
|
EVT_UPDATE_UI( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganConvert )
|
2011-02-24 20:22:12 +00:00
|
|
|
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
|
|
|
EVT_UPDATE_UI_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME::OnUpdateEditingPart )
|
2007-05-06 16:03:28 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2012-09-12 09:53:11 +00:00
|
|
|
#define LIB_EDIT_FRAME_NAME wxT( "LibeditFrame" )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
|
2010-11-19 16:28:46 +00:00
|
|
|
const wxString& title,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style ) :
|
2012-09-12 09:53:11 +00:00
|
|
|
SCH_BASE_FRAME( aParent, LIBEDITOR_FRAME_TYPE, title, pos, size,
|
|
|
|
style, GetLibEditFrameName() )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-03-20 19:57:59 +00:00
|
|
|
wxASSERT( aParent );
|
|
|
|
|
2012-09-12 09:53:11 +00:00
|
|
|
m_FrameName = GetLibEditFrameName();
|
2011-12-14 20:03:15 +00:00
|
|
|
m_showAxis = true; // true to draw axis
|
2011-12-09 16:37:11 +00:00
|
|
|
m_configPath = wxT( "LibraryEditor" );
|
2009-10-10 17:27:53 +00:00
|
|
|
SetShowDeMorgan( false );
|
2009-10-19 19:00:47 +00:00
|
|
|
m_drawSpecificConvert = true;
|
2009-11-04 20:46:53 +00:00
|
|
|
m_drawSpecificUnit = false;
|
2010-10-23 10:09:23 +00:00
|
|
|
m_tempCopyComponent = NULL;
|
2010-02-14 18:14:33 +00:00
|
|
|
m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr;
|
2011-10-28 13:43:37 +00:00
|
|
|
m_editPinsPerPartOrConvert = false;
|
2012-05-06 16:55:51 +00:00
|
|
|
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2011-09-08 05:58:45 +00:00
|
|
|
wxIcon icon;
|
|
|
|
|
2011-09-09 19:30:59 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( libedit_icon_xpm ) );
|
2011-09-08 05:58:45 +00:00
|
|
|
|
|
|
|
SetIcon( icon );
|
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
SetScreen( new SCH_SCREEN() );
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
GetScreen()->m_Center = true;
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2011-02-23 14:20:01 +00:00
|
|
|
GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
LoadSettings();
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
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;
|
2009-10-14 19:43:31 +00:00
|
|
|
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas )
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetEnableBlockCommands( true );
|
2009-12-22 20:08:56 +00:00
|
|
|
|
|
|
|
EnsureActiveLibExists();
|
2010-03-18 20:35:29 +00:00
|
|
|
ReCreateMenuBar();
|
2007-09-15 04:25:54 +00:00
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
2011-02-23 14:20:01 +00:00
|
|
|
CreateOptionToolbar();
|
2007-09-15 04:25:54 +00:00
|
|
|
DisplayLibInfos();
|
2009-09-18 14:56:05 +00:00
|
|
|
DisplayCmpDoc();
|
2009-09-14 13:24:17 +00:00
|
|
|
UpdateAliasSelectList();
|
|
|
|
UpdatePartSelectList();
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
|
|
|
|
2011-09-15 18:25:44 +00:00
|
|
|
EDA_PANEINFO horiz;
|
|
|
|
horiz.HorizontalToolbarPane();
|
|
|
|
|
|
|
|
EDA_PANEINFO vert;
|
|
|
|
vert.VerticalToolbarPane();
|
|
|
|
|
|
|
|
EDA_PANEINFO mesg;
|
|
|
|
mesg.MessageToolbarPane();
|
|
|
|
|
2011-12-16 13:32:23 +00:00
|
|
|
m_auimgr.AddPane( m_mainToolBar,
|
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
m_auimgr.AddPane( m_drawToolBar,
|
2010-10-04 18:54:14 +00:00
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right() );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
m_auimgr.AddPane( m_optionsToolBar,
|
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left() );
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_auimgr.AddPane( m_canvas,
|
2010-10-04 18:54:14 +00:00
|
|
|
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2011-12-12 14:02:37 +00:00
|
|
|
m_auimgr.AddPane( m_messagePanel,
|
2011-09-15 18:25:44 +00:00
|
|
|
wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) );
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2009-11-02 22:24:55 +00:00
|
|
|
m_auimgr.Update();
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2011-04-12 12:41:13 +00:00
|
|
|
Show( true );
|
|
|
|
|
2011-02-23 14:20:01 +00:00
|
|
|
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED, ID_ZOOM_PAGE );
|
|
|
|
wxPostEvent( this, evt );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME::~LIB_EDIT_FRAME()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
m_drawItem = m_lastDrawItem = NULL;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2010-10-23 10:09:23 +00:00
|
|
|
if ( m_tempCopyComponent )
|
|
|
|
delete m_tempCopyComponent;
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2010-10-23 10:09:23 +00:00
|
|
|
m_tempCopyComponent = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2012-09-12 09:53:11 +00:00
|
|
|
/**
|
|
|
|
* 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());
|
|
|
|
}
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::LoadSettings()
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
wxConfig* cfg;
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME::LoadSettings();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
wxConfigPathChanger cpc( wxGetApp().GetSettings(), m_configPath );
|
|
|
|
cfg = wxGetApp().GetSettings();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
m_lastLibExportPath = cfg->Read( lastLibExportPathEntry, ::wxGetCwd() );
|
|
|
|
m_lastLibImportPath = cfg->Read( lastLibImportPathEntry, ::wxGetCwd() );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
void LIB_EDIT_FRAME::SetDrawItem( LIB_ITEM* drawItem )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
|
|
|
m_drawItem = drawItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-12 17:43:16 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::SaveSettings()
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
wxConfig* cfg;
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME::SaveSettings();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
wxConfigPathChanger cpc( wxGetApp().GetSettings(), m_configPath );
|
|
|
|
cfg = wxGetApp().GetSettings();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
cfg->Write( lastLibExportPathEntry, m_lastLibExportPath );
|
|
|
|
cfg->Write( lastLibImportPathEntry, m_lastLibImportPath );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
if( GetScreen()->IsModify() )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2007-11-10 22:36:36 +00:00
|
|
|
if( !IsOK( this, _( "Component was modified!\nDiscard changes?" ) ) )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
Event.Veto();
|
|
|
|
return;
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
else
|
2011-10-28 13:43:37 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->ClrModify();
|
2011-10-28 13:43:37 +00:00
|
|
|
}
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
|
2010-07-23 14:12:37 +00:00
|
|
|
BOOST_FOREACH( const CMP_LIBRARY &lib, CMP_LIBRARY::GetLibraryList() )
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
if( lib.IsModified() )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2009-04-05 20:49:15 +00:00
|
|
|
msg.Printf( _( "Library \"%s\" was modified!\nDiscard changes?" ),
|
2010-10-04 18:54:14 +00:00
|
|
|
GetChars( lib.GetName() ) );
|
2011-02-23 14:20:01 +00:00
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
if( !IsOK( this, msg ) )
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
Event.Veto();
|
|
|
|
return;
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveSettings();
|
|
|
|
Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-05 12:46:14 +00:00
|
|
|
double LIB_EDIT_FRAME::BestZoom()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-04-12 12:41:13 +00:00
|
|
|
/* Please, note: wxMSW before version 2.9 seems have
|
|
|
|
* problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched:
|
|
|
|
* edit file <wxWidgets>/src/msw/dc.cpp
|
|
|
|
* search for line static const int VIEWPORT_EXTENT = 1000;
|
|
|
|
* and replace by static const int VIEWPORT_EXTENT = 10000;
|
|
|
|
*/
|
|
|
|
int dx, dy;
|
2007-09-15 04:25:54 +00:00
|
|
|
wxSize size;
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT BoundaryBox;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
BoundaryBox = m_component->GetBoundingBox( m_unit, m_convert );
|
2007-09-15 04:25:54 +00:00
|
|
|
dx = BoundaryBox.GetWidth();
|
|
|
|
dy = BoundaryBox.GetHeight();
|
2011-10-28 13:43:37 +00:00
|
|
|
GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-05 08:07:11 +00:00
|
|
|
const PAGE_INFO& pageInfo = GetScreen()->GetPageSettings();
|
|
|
|
|
|
|
|
dx = pageInfo.GetSizeIU().x;
|
|
|
|
dy = pageInfo.GetSizeIU().y;
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
size = m_canvas->GetClientSize();
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2011-04-12 12:41:13 +00:00
|
|
|
// Reserve a 10% margin around component bounding box.
|
|
|
|
double margin_scale_factor = 0.8;
|
2011-10-28 13:43:37 +00:00
|
|
|
double zx =(double) dx / ( margin_scale_factor * (double)size.x );
|
2011-07-05 12:46:14 +00:00
|
|
|
double zy = (double) dy / ( margin_scale_factor * (double)size.y );
|
2011-04-12 12:41:13 +00:00
|
|
|
|
2012-09-22 11:19:37 +00:00
|
|
|
double bestzoom = std::max( zx, zy );
|
2011-04-12 12:41:13 +00:00
|
|
|
|
|
|
|
// keep it >= minimal existing zoom (can happen for very small components
|
|
|
|
// for instance when starting a new component
|
|
|
|
if( bestzoom < GetScreen()->m_ZoomList[0] )
|
|
|
|
bestzoom = GetScreen()->m_ZoomList[0];
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2011-03-30 19:20:23 +00:00
|
|
|
return bestzoom;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::UpdateAliasSelectList()
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-09 16:37:11 +00:00
|
|
|
if( m_aliasSelectBox == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
m_aliasSelectBox->Clear();
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
m_aliasSelectBox->Append( m_component->GetAliasNames() );
|
|
|
|
m_aliasSelectBox->SetSelection( 0 );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
int index = m_aliasSelectBox->FindString( m_aliasName );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
if( index != wxNOT_FOUND )
|
2011-12-09 16:37:11 +00:00
|
|
|
m_aliasSelectBox->SetSelection( index );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::UpdatePartSelectList()
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-09 16:37:11 +00:00
|
|
|
if( m_partSelectBox == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
if( m_partSelectBox->GetCount() != 0 )
|
|
|
|
m_partSelectBox->Clear();
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
if( m_component == NULL || m_component->GetPartCount() <= 1 )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-09 16:37:11 +00:00
|
|
|
m_partSelectBox->Append( wxEmptyString );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-05 17:52:41 +00:00
|
|
|
for( int i = 0; i < m_component->GetPartCount(); i++ )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Part %c" ), 'A' + i );
|
2011-12-09 16:37:11 +00:00
|
|
|
m_partSelectBox->Append( msg );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-09 16:37:11 +00:00
|
|
|
m_partSelectBox->SetSelection( ( m_unit > 0 ) ? m_unit - 1 : 0 );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateEditingPart( wxUpdateUIEvent& aEvent )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2011-02-21 13:54:29 +00:00
|
|
|
aEvent.Enable( m_component != NULL );
|
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
if( m_component != NULL && aEvent.GetEventObject() == m_drawToolBar )
|
2011-02-24 20:22:12 +00:00
|
|
|
aEvent.Check( GetToolId() == aEvent.GetId() );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateNotEditingPart( wxUpdateUIEvent& event )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
event.Enable( m_component == NULL );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateUndo( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
event.Enable( m_component != NULL && GetScreen() != NULL
|
2010-10-22 12:11:52 +00:00
|
|
|
&& GetScreen()->GetUndoCommandCount() != 0 && !IsEditingDrawItem() );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateRedo( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
event.Enable( m_component != NULL && GetScreen() != NULL
|
2010-10-22 12:11:52 +00:00
|
|
|
&& GetScreen()->GetRedoCommandCount() != 0 && !IsEditingDrawItem() );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateSaveCurrentLib( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-08-12 17:43:16 +00:00
|
|
|
event.Enable( m_library != NULL && !m_library->IsReadOnly()
|
|
|
|
&& ( m_library->IsModified() || GetScreen()->IsModify() ) );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateViewDoc( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
|
|
|
bool enable = false;
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component != NULL && m_library != NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2010-10-04 18:54:14 +00:00
|
|
|
LIB_ALIAS* alias = m_component->GetAlias( m_aliasName );
|
|
|
|
|
2010-10-22 12:11:52 +00:00
|
|
|
wxCHECK_RET( alias != NULL, wxT( "Alias <" ) + m_aliasName + wxT( "> not found." ) );
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
enable = !alias->GetDocFileName().IsEmpty();
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
event.Enable( enable );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdatePinByPin( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
event.Enable( ( m_component != NULL )
|
2010-02-04 17:46:12 +00:00
|
|
|
&& ( ( m_component->GetPartCount() > 1 ) || m_showDeMorgan ) );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
event.Check( m_editPinsPerPartOrConvert );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-09 16:37:11 +00:00
|
|
|
if( m_partSelectBox == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
/* Using the typical event.Enable() call doesn't seem to work with wxGTK
|
2009-09-14 13:24:17 +00:00
|
|
|
* so use the pointer to alias combobox to directly enable or disable.
|
|
|
|
*/
|
2011-12-09 16:37:11 +00:00
|
|
|
m_partSelectBox->Enable( m_component && m_component->GetPartCount() > 1 );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateDeMorganNormal( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-16 13:32:23 +00:00
|
|
|
if( m_mainToolBar == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
event.Enable( GetShowDeMorgan() || ( m_component && m_component->HasConversion() ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
event.Check( m_convert <= 1 );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateDeMorganConvert( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-16 13:32:23 +00:00
|
|
|
if( m_mainToolBar == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
event.Enable( GetShowDeMorgan() || ( m_component && m_component->HasConversion() ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
event.Check( m_convert > 1 );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateSelectAlias( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-09 16:37:11 +00:00
|
|
|
if( m_aliasSelectBox == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
/* Using the typical event.Enable() call doesn't seem to work with wxGTK
|
2009-09-14 13:24:17 +00:00
|
|
|
* so use the pointer to alias combobox to directly enable or disable.
|
|
|
|
*/
|
2011-12-09 16:37:11 +00:00
|
|
|
m_aliasSelectBox->Enable( m_component != NULL && m_component->GetAliasCount() > 1 );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnSelectAlias( wxCommandEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-12-09 16:37:11 +00:00
|
|
|
if( m_aliasSelectBox == NULL
|
|
|
|
|| ( m_aliasSelectBox->GetStringSelection().CmpNoCase( m_aliasName ) == 0) )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_lastDrawItem = NULL;
|
2011-12-09 16:37:11 +00:00
|
|
|
m_aliasName = m_aliasSelectBox->GetStringSelection();
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
DisplayCmpDoc();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnSelectPart( wxCommandEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
|
|
|
int i = event.GetSelection();
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == m_unit ) )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_lastDrawItem = NULL;
|
|
|
|
m_unit = i + 1;
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2009-09-18 14:56:05 +00:00
|
|
|
DisplayCmpDoc();
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
|
|
|
if( m_component == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString fileName;
|
2010-10-04 18:54:14 +00:00
|
|
|
LIB_ALIAS* alias = m_component->GetAlias( m_aliasName );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
wxCHECK_RET( alias != NULL, wxT( "Alias not found." ) );
|
|
|
|
|
|
|
|
fileName = alias->GetDocFileName();
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
if( !fileName.IsEmpty() )
|
2010-10-04 18:54:14 +00:00
|
|
|
GetAssociatedDocument( this, fileName, &wxGetApp().GetLibraryPathList() );
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
if( event.GetId() == ID_DE_MORGAN_NORMAL_BUTT )
|
|
|
|
m_convert = 1;
|
|
|
|
else
|
|
|
|
m_convert = 2;
|
|
|
|
|
|
|
|
m_lastDrawItem = NULL;
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-02-04 17:46:12 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
wxPoint pos;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( true );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
wxGetMousePosition( &pos.x, &pos.y );
|
|
|
|
pos.y += 20;
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
switch( id ) // Stop placement commands before handling new command.
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
|
|
|
case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
|
2009-10-30 19:26:25 +00:00
|
|
|
case ID_LIBEDIT_EDIT_PIN:
|
2007-09-15 04:25:54 +00:00
|
|
|
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
|
|
|
|
case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM:
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
|
|
|
case ID_POPUP_COPY_BLOCK:
|
|
|
|
case ID_POPUP_SELECT_ITEMS_BLOCK:
|
2011-05-20 18:29:35 +00:00
|
|
|
case ID_POPUP_MIRROR_X_BLOCK:
|
2009-08-12 10:40:01 +00:00
|
|
|
case ID_POPUP_MIRROR_Y_BLOCK:
|
2011-05-20 18:29:35 +00:00
|
|
|
case ID_POPUP_ROTATE_BLOCK:
|
2007-09-15 04:25:54 +00:00
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
|
|
|
case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT:
|
|
|
|
break;
|
|
|
|
|
2009-12-20 19:48:58 +00:00
|
|
|
case ID_POPUP_LIBEDIT_CANCEL_EDITING:
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
|
|
|
m_canvas->EndMouseCapture();
|
2009-12-20 19:48:58 +00:00
|
|
|
else
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
|
2009-12-20 19:48:58 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_DELETE_ITEM:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture();
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(),
|
2011-02-24 20:22:12 +00:00
|
|
|
wxEmptyString );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
switch( id )
|
|
|
|
{
|
2009-12-29 10:35:11 +00:00
|
|
|
case ID_POPUP_LIBEDIT_CANCEL_EDITING:
|
|
|
|
break;
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
case ID_LIBEDIT_SELECT_CURRENT_LIB:
|
|
|
|
SelectActiveLibrary();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_SAVE_CURRENT_PART:
|
|
|
|
SaveOnePartInMemory();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_EDIT_PIN_BY_PIN:
|
2011-12-16 13:32:23 +00:00
|
|
|
m_editPinsPerPartOrConvert = m_mainToolBar->GetToolToggled( ID_LIBEDIT_EDIT_PIN_BY_PIN );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
|
|
|
EndDrawGraphicItem( &dc );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( &dc );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
switch( m_drawItem->Type() )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case LIB_ARC_T:
|
|
|
|
case LIB_CIRCLE_T:
|
|
|
|
case LIB_RECTANGLE_T:
|
|
|
|
case LIB_POLYLINE_T:
|
2009-09-25 18:49:04 +00:00
|
|
|
EditGraphicSymbol( &dc, m_drawItem );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case LIB_TEXT_T:
|
2009-09-25 18:49:04 +00:00
|
|
|
EditSymbolText( &dc, m_drawItem );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOn( &dc );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT:
|
2010-10-20 20:24:26 +00:00
|
|
|
{
|
2007-09-15 04:25:54 +00:00
|
|
|
// Delete the last created segment, while creating a polyline draw item
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2010-10-20 20:24:26 +00:00
|
|
|
int oldFlags = m_drawItem->GetFlags();
|
2011-03-03 01:58:12 +00:00
|
|
|
m_drawItem->ClearFlags();
|
2012-09-02 12:06:47 +00:00
|
|
|
m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform );
|
2011-02-11 20:48:13 +00:00
|
|
|
( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetScreen()->GetCrossHairPosition( true ) );
|
2012-09-02 12:06:47 +00:00
|
|
|
m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform );
|
2010-10-20 20:24:26 +00:00
|
|
|
m_drawItem->SetFlags( oldFlags );
|
2011-07-07 12:54:02 +00:00
|
|
|
m_lastDrawItem = NULL;
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
2010-10-20 20:24:26 +00:00
|
|
|
}
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_DELETE_ITEM:
|
2011-02-24 22:29:43 +00:00
|
|
|
if( m_drawItem )
|
|
|
|
deleteItem( &dc );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST:
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
2011-04-27 19:44:32 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( m_drawItem->Type() == LIB_PIN_T )
|
2007-09-15 04:25:54 +00:00
|
|
|
StartMovePin( &dc );
|
|
|
|
else
|
|
|
|
StartMoveDrawSymbol( &dc );
|
|
|
|
break;
|
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
case ID_POPUP_LIBEDIT_MODIFY_ITEM:
|
|
|
|
|
|
|
|
if( m_drawItem == NULL )
|
|
|
|
break;
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2010-12-10 19:47:44 +00:00
|
|
|
if( m_drawItem->Type() == LIB_RECTANGLE_T
|
|
|
|
|| m_drawItem->Type() == LIB_CIRCLE_T
|
|
|
|
|| m_drawItem->Type() == LIB_POLYLINE_T
|
|
|
|
|| m_drawItem->Type() == LIB_ARC_T
|
2010-02-04 17:46:12 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
StartModifyDrawSymbol( &dc );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM:
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( &dc );
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( m_drawItem->Type() == LIB_FIELD_T )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2012-02-21 17:47:30 +00:00
|
|
|
EditField( (LIB_FIELD*) m_drawItem );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
m_canvas->CrossHairOn( &dc );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
|
|
|
|
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
|
2011-02-21 13:54:29 +00:00
|
|
|
if( ( m_drawItem == NULL ) || ( m_drawItem->Type() != LIB_PIN_T ) )
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
2011-09-01 12:54:34 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
SaveCopyInUndoList( m_component );
|
2009-10-08 13:19:28 +00:00
|
|
|
GlobalSetPins( &dc, (LIB_PIN*) m_drawItem, id );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetCommand( BLOCK_ZOOM );
|
2007-09-15 04:25:54 +00:00
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetCommand( BLOCK_DELETE );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-09-15 04:25:54 +00:00
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_COPY_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetCommand( BLOCK_COPY );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-09-15 04:25:54 +00:00
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SELECT_ITEMS_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetCommand( BLOCK_SELECT_ITEMS_ONLY );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-09-15 04:25:54 +00:00
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
2009-08-12 10:40:01 +00:00
|
|
|
case ID_POPUP_MIRROR_Y_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetCommand( BLOCK_MIRROR_Y );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-09-15 04:25:54 +00:00
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
2011-05-20 18:29:35 +00:00
|
|
|
case ID_POPUP_MIRROR_X_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetCommand( BLOCK_MIRROR_X );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-05-20 18:29:35 +00:00
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ROTATE_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetCommand( BLOCK_ROTATE );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-05-20 18:29:35 +00:00
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-09-15 04:25:54 +00:00
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-11-19 16:28:46 +00:00
|
|
|
DisplayError( this, wxT( "LIB_EDIT_FRAME::Process_Special_Functions error" ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
2009-09-25 18:49:04 +00:00
|
|
|
m_lastDrawItem = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2009-12-22 20:08:56 +00:00
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnActivate( wxActivateEvent& event )
|
2009-12-22 20:08:56 +00:00
|
|
|
{
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME::OnActivate( event );
|
2009-12-22 20:08:56 +00:00
|
|
|
|
|
|
|
// Verify the existence of the current active library
|
|
|
|
// (can be removed or changed by the schematic editor)
|
|
|
|
EnsureActiveLibExists();
|
|
|
|
}
|
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::EnsureActiveLibExists()
|
2009-12-22 20:08:56 +00:00
|
|
|
{
|
|
|
|
if( m_library == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool exists = CMP_LIBRARY::LibraryExists( m_library );
|
2011-10-28 13:43:37 +00:00
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
if( exists )
|
2009-12-22 20:08:56 +00:00
|
|
|
return;
|
|
|
|
else
|
|
|
|
m_library = NULL;
|
|
|
|
}
|
2010-03-20 19:57:59 +00:00
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_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-12-08 20:12:46 +00:00
|
|
|
SCH_EDIT_FRAME *parent = (SCH_EDIT_FRAME *)GetParent();
|
2011-01-21 19:30:59 +00:00
|
|
|
// Call parent->EDA_BASE_FRAME::SetLanguage and NOT
|
2010-12-18 08:59:04 +00:00
|
|
|
// parent->SetLanguage because parent->SetLanguage call
|
|
|
|
// LIB_EDIT_FRAME::SetLanguage
|
2011-01-21 19:30:59 +00:00
|
|
|
parent->EDA_BASE_FRAME::SetLanguage( event );
|
2010-03-20 19:57:59 +00:00
|
|
|
}
|
2010-10-20 20:24:26 +00:00
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::TempCopyComponent()
|
2010-10-20 20:24:26 +00:00
|
|
|
{
|
2010-10-23 10:09:23 +00:00
|
|
|
if( m_tempCopyComponent )
|
|
|
|
delete m_tempCopyComponent;
|
2011-02-24 22:29:43 +00:00
|
|
|
|
2010-10-23 13:49:14 +00:00
|
|
|
m_tempCopyComponent = NULL;
|
2011-02-24 22:29:43 +00:00
|
|
|
|
2010-10-23 10:09:23 +00:00
|
|
|
if( m_component )
|
|
|
|
m_tempCopyComponent = new LIB_COMPONENT( *m_component );
|
|
|
|
}
|
|
|
|
|
2011-08-12 17:43:16 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::RestoreComponent()
|
2010-10-23 10:09:23 +00:00
|
|
|
{
|
2010-10-23 13:49:14 +00:00
|
|
|
if( m_tempCopyComponent == NULL )
|
|
|
|
return;
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2010-10-23 10:09:23 +00:00
|
|
|
if( m_component )
|
|
|
|
delete m_component;
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2010-10-23 10:09:23 +00:00
|
|
|
m_component = m_tempCopyComponent;
|
|
|
|
m_tempCopyComponent = NULL;
|
2010-10-20 20:24:26 +00:00
|
|
|
}
|
2010-10-23 13:49:14 +00:00
|
|
|
|
2011-08-12 17:43:16 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::ClearTempCopyComponent()
|
2010-10-23 13:49:14 +00:00
|
|
|
{
|
|
|
|
delete m_tempCopyComponent;
|
|
|
|
m_tempCopyComponent = NULL;
|
|
|
|
}
|
2010-11-17 21:47:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem )
|
2010-11-17 21:47:27 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if ( ( DrawItem == NULL ) || ( DrawItem->Type() != LIB_TEXT_T ) )
|
2010-11-17 21:47:27 +00:00
|
|
|
return;
|
|
|
|
|
2012-09-02 12:06:47 +00:00
|
|
|
// Deleting old text
|
2010-11-17 21:47:27 +00:00
|
|
|
if( DC && !DrawItem->InEditMode() )
|
2012-09-02 12:06:47 +00:00
|
|
|
DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform );
|
2010-11-17 21:47:27 +00:00
|
|
|
|
|
|
|
DIALOG_LIB_EDIT_TEXT* frame = new DIALOG_LIB_EDIT_TEXT( this, (LIB_TEXT*) DrawItem );
|
|
|
|
frame->ShowModal();
|
|
|
|
frame->Destroy();
|
|
|
|
OnModify();
|
|
|
|
|
2012-09-02 12:06:47 +00:00
|
|
|
// Display new text
|
2010-11-17 21:47:27 +00:00
|
|
|
if( DC && !DrawItem->InEditMode() )
|
2012-09-02 12:06:47 +00:00
|
|
|
DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_DEFAULT_DRAWMODE, NULL,
|
2010-11-17 21:47:27 +00:00
|
|
|
DefaultTransform );
|
|
|
|
}
|
2010-11-18 21:10:52 +00:00
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event )
|
2010-11-18 21:10:52 +00:00
|
|
|
{
|
|
|
|
bool partLocked = GetComponent()->UnitsLocked();
|
|
|
|
|
|
|
|
DIALOG_EDIT_COMPONENT_IN_LIBRARY dlg( this );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( partLocked != GetComponent()->UnitsLocked() )
|
|
|
|
{
|
2011-10-28 13:43:37 +00:00
|
|
|
// m_editPinsPerPartOrConvert is set to the better value, if m_UnitSelectionLocked
|
|
|
|
// has changed
|
|
|
|
m_editPinsPerPartOrConvert = GetComponent()->UnitsLocked() ? true : false;
|
2010-11-18 21:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
UpdateAliasSelectList();
|
|
|
|
UpdatePartSelectList();
|
|
|
|
DisplayLibInfos();
|
|
|
|
DisplayCmpDoc();
|
|
|
|
OnModify();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2010-11-18 21:10:52 +00:00
|
|
|
}
|
2010-11-19 16:28:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
void LIB_EDIT_FRAME::InstallDimensionsDialog( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
DIALOG_LIBEDIT_DIMENSIONS dlg( this );
|
|
|
|
dlg.ShowModal();
|
|
|
|
}
|
2010-12-02 21:41:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
wxCHECK_RET( m_component != NULL,
|
2011-10-28 13:43:37 +00:00
|
|
|
wxT( "Cannot create new part from non-existent current part." ) );
|
2010-12-02 21:41:56 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
|
|
|
m_canvas->CrossHairOff( &dc );
|
2012-02-21 17:47:30 +00:00
|
|
|
EditField( &m_component->GetValueField() );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
m_canvas->CrossHairOn( &dc );
|
2010-12-02 21:41:56 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
int id = aEvent.GetId();
|
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
2011-02-21 13:54:29 +00:00
|
|
|
m_lastDrawItem = NULL;
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(),
|
2011-02-24 20:22:12 +00:00
|
|
|
wxEmptyString );
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
case ID_NO_TOOL_SELECTED:
|
2011-12-22 13:28:11 +00:00
|
|
|
SetToolID( id, m_canvas->GetDefaultCursor(), wxEmptyString );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_PIN_BUTT:
|
|
|
|
if( m_component )
|
|
|
|
{
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add pin" ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetToolID( id, wxCURSOR_ARROW, _( "Set pin options" ) );
|
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetId( ID_LIBEDIT_EDIT_PIN );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2011-12-22 13:28:11 +00:00
|
|
|
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_TEXT_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_RECT_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add rectangle" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add circle" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_ARC_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add arc" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_LINE_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add line" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_HAND, _( "Set anchor position" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_IMPORT_BODY_BUTT:
|
2011-12-22 13:28:11 +00:00
|
|
|
SetToolID( id, m_canvas->GetDefaultCursor(), _( "Import" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
LoadOneSymbol();
|
2011-12-22 13:28:11 +00:00
|
|
|
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_EXPORT_BODY_BUTT:
|
2011-12-22 13:28:11 +00:00
|
|
|
SetToolID( id, m_canvas->GetDefaultCursor(), _( "Export" ) );
|
2011-02-21 13:54:29 +00:00
|
|
|
SaveOneSymbol();
|
2011-12-22 13:28:11 +00:00
|
|
|
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
|
2011-02-21 13:54:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_DELETE_ITEM_BUTT:
|
|
|
|
if( m_component == NULL )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
2011-02-24 22:29:43 +00:00
|
|
|
|
|
|
|
|
2011-02-28 13:53:49 +00:00
|
|
|
void LIB_EDIT_FRAME::OnRotateItem( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( m_drawItem == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( !m_drawItem->InEditMode() )
|
|
|
|
{
|
|
|
|
SaveCopyInUndoList( m_component );
|
|
|
|
m_drawItem->SetUnit( m_unit );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_drawItem->Rotate();
|
2011-08-29 03:04:59 +00:00
|
|
|
OnModify();
|
2011-05-05 18:43:56 +00:00
|
|
|
|
|
|
|
if( !m_drawItem->InEditMode() )
|
|
|
|
m_drawItem->ClearFlags();
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2011-02-28 13:53:49 +00:00
|
|
|
|
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
|
|
|
m_lastDrawItem = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPosition,
|
|
|
|
const KICAD_T aFilterList[] )
|
2011-02-28 13:53:49 +00:00
|
|
|
{
|
|
|
|
if( m_component == NULL )
|
|
|
|
return NULL;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* item = locateItem( aPosition, aFilterList );
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return NULL;
|
2011-02-28 13:53:49 +00:00
|
|
|
|
|
|
|
wxPoint pos = GetScreen()->GetNearestGridPosition( aPosition );
|
|
|
|
|
|
|
|
if( item == NULL && aPosition != pos )
|
2011-04-27 19:44:32 +00:00
|
|
|
item = locateItem( pos, aFilterList );
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LIB_ITEM* LIB_EDIT_FRAME::locateItem( const wxPoint& aPosition, const KICAD_T aFilterList[] )
|
|
|
|
{
|
|
|
|
if( m_component == NULL )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
LIB_ITEM* item = NULL;
|
|
|
|
|
|
|
|
m_collectedItems.Collect( m_component->GetDrawItemList(), aFilterList, aPosition,
|
|
|
|
m_unit, m_convert );
|
|
|
|
|
|
|
|
if( m_collectedItems.GetCount() == 0 )
|
|
|
|
{
|
|
|
|
ClearMsgPanel();
|
|
|
|
}
|
|
|
|
else if( m_collectedItems.GetCount() == 1 )
|
|
|
|
{
|
|
|
|
item = m_collectedItems[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( item == NULL )
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( m_collectedItems.GetCount() <= MAX_SELECT_ITEM_IDS,
|
|
|
|
wxT( "Select item clarification context menu size limit exceeded." ) );
|
|
|
|
|
|
|
|
wxMenu selectMenu;
|
|
|
|
wxMenuItem* title = new wxMenuItem( &selectMenu, wxID_NONE, _( "Clarify Selection" ) );
|
|
|
|
|
|
|
|
selectMenu.Append( title );
|
|
|
|
selectMenu.AppendSeparator();
|
|
|
|
|
|
|
|
for( int i = 0; i < m_collectedItems.GetCount() && i < MAX_SELECT_ITEM_IDS; i++ )
|
|
|
|
{
|
|
|
|
wxString text = m_collectedItems[i]->GetSelectMenuText();
|
2011-08-29 03:04:59 +00:00
|
|
|
BITMAP_DEF xpm = m_collectedItems[i]->GetMenuImage();
|
2011-09-08 05:58:45 +00:00
|
|
|
AddMenuItem( &selectMenu, ID_SELECT_ITEM_START + i, text, KiBitmap( xpm ) );
|
2011-04-27 19:44:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set to NULL in case user aborts the clarification context menu.
|
|
|
|
m_drawItem = NULL;
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAbortRequest( true ); // Changed to false if an item is selected
|
2011-04-27 19:44:32 +00:00
|
|
|
PopupMenu( &selectMenu );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-04-27 19:44:32 +00:00
|
|
|
item = m_drawItem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
item->DisplayInfo( this );
|
|
|
|
else
|
|
|
|
ClearMsgPanel();
|
2011-02-28 13:53:49 +00:00
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-24 22:29:43 +00:00
|
|
|
void LIB_EDIT_FRAME::deleteItem( wxDC* aDC )
|
|
|
|
{
|
|
|
|
wxCHECK_RET( m_drawItem != NULL, wxT( "No drawing item selected to delete." ) );
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( aDC );
|
2011-02-24 22:29:43 +00:00
|
|
|
SaveCopyInUndoList( m_component );
|
|
|
|
|
|
|
|
if( m_drawItem->Type() == LIB_PIN_T )
|
|
|
|
{
|
|
|
|
LIB_PIN* pin = (LIB_PIN*) m_drawItem;
|
|
|
|
wxPoint pos = pin->GetPosition();
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_component->RemoveDrawItem( (LIB_ITEM*) pin, m_canvas, aDC );
|
2011-02-24 22:29:43 +00:00
|
|
|
|
2011-10-28 13:43:37 +00:00
|
|
|
if( SynchronizePins() )
|
2011-02-24 22:29:43 +00:00
|
|
|
{
|
|
|
|
LIB_PIN* tmp = m_component->GetNextPin();
|
|
|
|
|
|
|
|
while( tmp != NULL )
|
|
|
|
{
|
|
|
|
pin = tmp;
|
|
|
|
tmp = m_component->GetNextPin( pin );
|
|
|
|
|
|
|
|
if( pin->GetPosition() != pos )
|
|
|
|
continue;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
m_component->RemoveDrawItem( (LIB_ITEM*) pin );
|
2011-02-24 22:29:43 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-28 13:43:37 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2011-02-24 22:29:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
2011-10-28 13:43:37 +00:00
|
|
|
{
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallEndMouseCapture( aDC );
|
2011-10-28 13:43:37 +00:00
|
|
|
}
|
2011-02-24 22:29:43 +00:00
|
|
|
else
|
2011-10-28 13:43:37 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_component->RemoveDrawItem( m_drawItem, m_canvas, aDC );
|
|
|
|
m_canvas->Refresh();
|
2011-10-28 13:43:37 +00:00
|
|
|
}
|
2011-02-24 22:29:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_drawItem = NULL;
|
2011-07-07 12:54:02 +00:00
|
|
|
m_lastDrawItem = NULL;
|
2011-02-24 22:29:43 +00:00
|
|
|
OnModify();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOn( aDC );
|
2011-02-24 22:29:43 +00:00
|
|
|
}
|
2011-04-27 19:44:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
void LIB_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
int id = aEvent.GetId();
|
|
|
|
int index = id - ID_SELECT_ITEM_START;
|
|
|
|
|
|
|
|
if( (id >= ID_SELECT_ITEM_START && id <= ID_SELECT_ITEM_END)
|
|
|
|
&& (index >= 0 && index < m_collectedItems.GetCount()) )
|
|
|
|
{
|
|
|
|
LIB_ITEM* item = m_collectedItems[index];
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAbortRequest( false );
|
2011-04-27 19:44:32 +00:00
|
|
|
m_drawItem = item;
|
|
|
|
}
|
|
|
|
}
|
2011-10-28 13:43:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool LIB_EDIT_FRAME::SynchronizePins() const
|
|
|
|
{
|
|
|
|
return !m_editPinsPerPartOrConvert && ( m_component && ( m_component->HasConversion() ||
|
|
|
|
m_component->IsMulti()) );
|
|
|
|
}
|