2010-02-16 16:21:52 +00:00
|
|
|
/**
|
|
|
|
* EESchema - libeditframe.cpp
|
2010-11-19 16:28:46 +00:00
|
|
|
* class LIB_EDIT_FRAME: the component editor frame
|
2010-02-16 16:21:52 +00:00
|
|
|
*
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "common.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "macros.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
#include "eda_doc.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "bitmaps.h"
|
2010-10-20 20:24:26 +00:00
|
|
|
#include "gr_basic.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "class_sch_screen.h"
|
|
|
|
#include "wxEeschemaStruct.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "eeschema_id.h"
|
2010-02-16 16:21:52 +00:00
|
|
|
#include "libeditframe.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_library.h"
|
2010-10-20 20:24:26 +00:00
|
|
|
#include "lib_polyline.h"
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-12-20 19:48:58 +00:00
|
|
|
#include "kicad_device_context.h"
|
2010-02-14 18:14:33 +00:00
|
|
|
#include "hotkeys.h"
|
2009-12-20 19:48:58 +00:00
|
|
|
|
2010-11-17 21:47:27 +00:00
|
|
|
#include "dialogs/dialog_lib_edit_text.h"
|
|
|
|
#include "dialogs/dialog_SVG_print.h"
|
2010-11-18 21:10:52 +00:00
|
|
|
#include "dialogs/dialog_edit_component_in_lib.h"
|
2010-11-19 16:28:46 +00:00
|
|
|
#include "dialogs/dialog_libedit_dimensions.h"
|
2010-11-17 21:47:27 +00:00
|
|
|
|
2010-11-18 21:16:28 +00:00
|
|
|
#include "dialog_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
|
|
|
|
|
|
|
/* Library editor wxConfig entry names. */
|
|
|
|
const wxString lastLibExportPathEntry( wxT( "LastLibraryExportPath" ) );
|
|
|
|
const wxString lastLibImportPathEntry( wxT( "LastLibraryImportPath" ) );
|
|
|
|
const wxString showGridPathEntry( wxT( "ShowGrid" ) );
|
|
|
|
|
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;
|
|
|
|
LIB_DRAW_ITEM* LIB_EDIT_FRAME::m_lastDrawItem = NULL;
|
|
|
|
LIB_DRAW_ITEM* LIB_EDIT_FRAME::m_drawItem = NULL;
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
/************************/
|
|
|
|
/* class LIB_EDIT_FRAME */
|
|
|
|
/************************/
|
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_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, LIB_EDIT_FRAME::OnZoom )
|
|
|
|
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 )
|
|
|
|
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 )
|
|
|
|
|
|
|
|
EVT_KICAD_CHOICEBOX( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnSelectPart )
|
|
|
|
EVT_KICAD_CHOICEBOX( ID_LIBEDIT_SELECT_ALIAS, LIB_EDIT_FRAME::OnSelectAlias )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
/* Right vertical toolbar. */
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_TOOL( ID_NO_SELECT_BUTT, LIB_EDIT_FRAME::Process_Special_Functions )
|
2010-10-04 18:54:14 +00:00
|
|
|
EVT_TOOL_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_EXPORT_BODY_BUTT,
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME::Process_Special_Functions )
|
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-01-21 19:30:59 +00:00
|
|
|
EVT_MENU( ID_GENERAL_HELP, EDA_DRAW_FRAME::GetKicadHelp )
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/* Context menu events and commands. */
|
2010-11-19 16:28:46 +00:00
|
|
|
EVT_MENU( ID_LIBEDIT_EDIT_PIN, LIB_EDIT_FRAME::OnEditPin )
|
|
|
|
EVT_MENU( ID_LIBEDIT_ROTATE_PIN, LIB_EDIT_FRAME::OnRotatePin )
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
EVT_MENU_RANGE( ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM,
|
|
|
|
ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT,
|
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 )
|
2010-10-04 18:54:14 +00:00
|
|
|
EVT_UPDATE_UI_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_EXPORT_BODY_BUTT,
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME::OnUpdateEditingPart )
|
2007-05-06 16:03:28 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
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 ) :
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME( aParent, LIBEDITOR_FRAME, title, pos, size, style )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-03-20 19:57:59 +00:00
|
|
|
wxASSERT( aParent );
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_FrameName = wxT( "LibeditFrame" );
|
|
|
|
m_Draw_Axis = true; // true to draw axis
|
2009-04-05 20:49:15 +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;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
// Give an icon
|
|
|
|
SetIcon( wxIcon( libedit_xpm ) );
|
2011-02-05 02:21:11 +00:00
|
|
|
SetScreen( new SCH_SCREEN() );
|
2009-09-04 18:57:37 +00:00
|
|
|
GetScreen()->m_Center = true;
|
2009-04-05 20:49:15 +00:00
|
|
|
LoadSettings();
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2009-10-15 11:35:53 +00:00
|
|
|
// Initilialize grid id to a default value if not found in config or bad:
|
2009-11-04 20:46:53 +00:00
|
|
|
if( (m_LastGridSizeId <= 0)
|
|
|
|
|| ( m_LastGridSizeId < (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000) ) )
|
2009-10-15 11:35:53 +00:00
|
|
|
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
2009-10-14 19:43:31 +00:00
|
|
|
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
if( DrawPanel )
|
2008-12-30 19:18:56 +00:00
|
|
|
DrawPanel->m_Block_Enable = 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();
|
|
|
|
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
|
|
|
|
|
|
|
#ifdef USE_WX_GRAPHICS_CONTEXT
|
|
|
|
GetScreen()->SetZoom( BestZoom() );
|
|
|
|
#else
|
2009-09-25 18:49:04 +00:00
|
|
|
Zoom_Automatique( false );
|
2010-02-08 18:15:42 +00:00
|
|
|
#endif
|
|
|
|
|
2008-12-30 19:18:56 +00:00
|
|
|
Show( true );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
|
|
|
|
2009-11-02 22:24:55 +00:00
|
|
|
wxAuiPaneInfo horiz;
|
2009-11-04 20:46:53 +00:00
|
|
|
horiz.Gripper( false );
|
|
|
|
horiz.DockFixed( true );
|
|
|
|
horiz.Movable( false );
|
|
|
|
horiz.Floatable( false );
|
|
|
|
horiz.CloseButton( false );
|
|
|
|
horiz.CaptionVisible( false );
|
|
|
|
|
|
|
|
wxAuiPaneInfo vert( horiz );
|
|
|
|
|
|
|
|
vert.TopDockable( false ).BottomDockable( false );
|
|
|
|
horiz.LeftDockable( false ).RightDockable( false );
|
|
|
|
|
|
|
|
m_auimgr.AddPane( m_HToolBar,
|
2010-10-22 12:11:52 +00:00
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
m_auimgr.AddPane( m_VToolBar,
|
2010-10-04 18:54:14 +00:00
|
|
|
wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right() );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
m_auimgr.AddPane( DrawPanel,
|
2010-10-04 18:54:14 +00:00
|
|
|
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
m_auimgr.AddPane( MsgPanel,
|
2010-10-04 18:54:14 +00:00
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
|
2009-11-02 22:24:55 +00:00
|
|
|
m_auimgr.Update();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) wxGetApp().GetTopWindow();
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
frame->m_LibeditFrame = NULL;
|
2009-09-25 18:49:04 +00:00
|
|
|
m_drawItem = m_lastDrawItem = NULL;
|
2010-10-23 10:09:23 +00:00
|
|
|
if ( m_tempCopyComponent )
|
|
|
|
delete m_tempCopyComponent;
|
|
|
|
m_tempCopyComponent = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/**
|
|
|
|
* Load library editor frame specific configuration settings.
|
|
|
|
*
|
|
|
|
* Don't forget to call this base method from any derived classes or the
|
|
|
|
* settings will not get loaded.
|
|
|
|
*/
|
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
|
|
|
|
|
|
|
wxConfigPathChanger cpc( wxGetApp().m_EDA_Config, m_ConfigPath );
|
|
|
|
cfg = wxGetApp().m_EDA_Config;
|
|
|
|
|
|
|
|
m_LastLibExportPath = cfg->Read( lastLibExportPathEntry, ::wxGetCwd() );
|
|
|
|
m_LastLibImportPath = cfg->Read( lastLibImportPathEntry, ::wxGetCwd() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::SetDrawItem( LIB_DRAW_ITEM* drawItem )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
|
|
|
m_drawItem = drawItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/**
|
|
|
|
* Save library editor frame specific configuration settings.
|
|
|
|
*
|
|
|
|
* Don't forget to call this base method from any derived classes or the
|
|
|
|
* settings will not get saved.
|
|
|
|
*/
|
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
|
|
|
|
|
|
|
wxConfigPathChanger cpc( wxGetApp().m_EDA_Config, m_ConfigPath );
|
|
|
|
cfg = wxGetApp().m_EDA_Config;
|
|
|
|
|
|
|
|
cfg->Write( lastLibExportPathEntry, m_LastLibExportPath );
|
|
|
|
cfg->Write( lastLibImportPathEntry, m_LastLibImportPath );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->ClrModify();
|
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() ) );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
int LIB_EDIT_FRAME::BestZoom()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-09-15 04:25:54 +00:00
|
|
|
int dx, dy, ii, jj;
|
|
|
|
wxSize size;
|
|
|
|
EDA_Rect BoundaryBox;
|
|
|
|
|
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();
|
2009-09-25 18:49:04 +00:00
|
|
|
GetScreen()->m_Curseur = BoundaryBox.Centre();
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
dx = GetScreen()->m_CurrentSheetDesc->m_Size.x;
|
|
|
|
dy = GetScreen()->m_CurrentSheetDesc->m_Size.y;
|
2009-09-25 18:49:04 +00:00
|
|
|
GetScreen()->m_Curseur = wxPoint( 0, 0 );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
/*
|
|
|
|
* This fixes a bug where the client size of the drawing area is not
|
|
|
|
* correctly reported until after the window is shown. This is most
|
|
|
|
* likely due to the unmanaged windows ( vertical tool bars and message
|
|
|
|
* panel ) that are drawn in the main window which wxWidgets knows
|
|
|
|
* nothing about. When the library editor is reopened with a component
|
|
|
|
* already loading, the zoom will be calculated correctly.
|
|
|
|
*/
|
|
|
|
if( !IsShownOnScreen() )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_clientSize != wxSize( -1, -1 ) )
|
|
|
|
size = m_clientSize;
|
|
|
|
else
|
|
|
|
size = DrawPanel->GetClientSize();
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_clientSize == wxSize( -1, -1 ) )
|
|
|
|
m_clientSize = DrawPanel->GetClientSize();
|
|
|
|
size = m_clientSize;
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
size -= wxSize( 25, 25 ); // reserve 100 mils margin
|
2010-10-04 18:54:14 +00:00
|
|
|
ii = wxRound( ( (double) dx / (double) size.x ) * (double) GetScreen()->m_ZoomScalar );
|
|
|
|
jj = wxRound( ( (double) dy / (double) size.y ) * (double) GetScreen()->m_ZoomScalar );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
return MAX( ii + 1, jj + 1 );
|
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
|
|
|
{
|
|
|
|
if( m_SelAliasBox == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_SelAliasBox->Clear();
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component == NULL )
|
2009-09-14 13:24:17 +00:00
|
|
|
return;
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
m_SelAliasBox->Append( m_component->GetAliasNames() );
|
2009-09-14 13:24:17 +00:00
|
|
|
m_SelAliasBox->SetSelection( 0 );
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
int index = m_SelAliasBox->FindString( m_aliasName );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
if( index != wxNOT_FOUND )
|
|
|
|
m_SelAliasBox->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
|
|
|
{
|
|
|
|
if( m_SelpartBox == NULL )
|
|
|
|
return;
|
|
|
|
|
2009-09-17 17:48:40 +00:00
|
|
|
if( m_SelpartBox->GetCount() != 0 )
|
2009-09-14 13:24:17 +00:00
|
|
|
m_SelpartBox->Clear();
|
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
if( m_component == NULL || m_component->GetPartCount() <= 1 )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
|
|
|
m_SelpartBox->Append( wxEmptyString );
|
|
|
|
}
|
|
|
|
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 );
|
|
|
|
m_SelpartBox->Append( msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_SelpartBox->SetSelection( ( m_unit > 0 ) ? m_unit - 1 : 0 );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdateEditingPart( 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
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2010-10-04 18:54:14 +00:00
|
|
|
event.Enable( m_library != NULL && ( 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
|
|
|
|
|
|
|
if( m_HToolBar )
|
|
|
|
m_HToolBar->ToggleTool( event.GetId(), g_EditPinByPinIsOn );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
|
|
|
if( m_SelpartBox == NULL )
|
|
|
|
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.
|
|
|
|
*/
|
2009-10-10 17:27:53 +00:00
|
|
|
m_SelpartBox->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
|
|
|
{
|
|
|
|
if( m_HToolBar == NULL )
|
|
|
|
return;
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
event.Enable( GetShowDeMorgan() || ( m_component && m_component->HasConversion() ) );
|
2009-09-25 18:49:04 +00:00
|
|
|
m_HToolBar->ToggleTool( event.GetId(), 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
|
|
|
{
|
|
|
|
if( m_HToolBar == NULL )
|
|
|
|
return;
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
event.Enable( GetShowDeMorgan() || ( m_component && m_component->HasConversion() ) );
|
2009-09-25 18:49:04 +00:00
|
|
|
m_HToolBar->ToggleTool( event.GetId(), 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
|
|
|
{
|
|
|
|
if( m_SelAliasBox == NULL )
|
|
|
|
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.
|
|
|
|
*/
|
2010-10-04 18:54:14 +00:00
|
|
|
m_SelAliasBox->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
|
|
|
{
|
|
|
|
if( m_SelAliasBox == NULL
|
2009-09-25 18:49:04 +00:00
|
|
|
|| m_SelAliasBox->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;
|
2010-10-04 18:54:14 +00:00
|
|
|
m_aliasName = m_SelAliasBox->GetStringSelection();
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
DisplayCmpDoc();
|
2009-09-14 13:24:17 +00:00
|
|
|
DrawPanel->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
2009-09-14 13:24:17 +00:00
|
|
|
DrawPanel->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
|
|
|
{
|
|
|
|
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
|
|
|
|
|
|
|
|
if( event.GetId() == ID_DE_MORGAN_NORMAL_BUTT )
|
|
|
|
m_convert = 1;
|
|
|
|
else
|
|
|
|
m_convert = 2;
|
|
|
|
|
|
|
|
m_lastDrawItem = NULL;
|
|
|
|
DrawPanel->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2008-12-30 19:18:56 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = 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_ROTATE_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:
|
2009-08-12 10:40:01 +00:00
|
|
|
case ID_POPUP_MIRROR_Y_BLOCK:
|
2007-09-15 04:25:54 +00:00
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
|
|
|
case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT:
|
|
|
|
case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT:
|
|
|
|
break;
|
|
|
|
|
2009-12-20 19:48:58 +00:00
|
|
|
case ID_POPUP_LIBEDIT_CANCEL_EDITING:
|
2007-09-15 04:25:54 +00:00
|
|
|
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
2010-02-04 17:46:12 +00:00
|
|
|
DrawPanel->UnManageCursor();
|
2009-12-20 19:48:58 +00:00
|
|
|
else
|
|
|
|
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_DELETE_ITEM:
|
2010-02-04 17:46:12 +00:00
|
|
|
DrawPanel->UnManageCursor();
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-12-20 19:48:58 +00:00
|
|
|
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW, wxEmptyString );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-01-30 22:22:38 +00:00
|
|
|
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
|
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:
|
2010-03-05 19:49:08 +00:00
|
|
|
g_EditPinByPinIsOn = m_HToolBar->GetToolState(ID_LIBEDIT_EDIT_PIN_BY_PIN);
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_PIN_BUTT:
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add pin" ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
SetToolID( id, wxCURSOR_ARROW, _( "Set pin options" ) );
|
2009-10-30 19:26:25 +00:00
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetId( ID_LIBEDIT_EDIT_PIN );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2007-09-15 04:25:54 +00:00
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_NO_SELECT_BUTT:
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_TEXT_BUTT:
|
2009-09-25 18:49:04 +00:00
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_RECT_BUTT:
|
2009-09-25 18:49:04 +00:00
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add rectangle" ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
|
2009-09-25 18:49:04 +00:00
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add circle" ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_ARC_BUTT:
|
2009-09-25 18:49:04 +00:00
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add arc" ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_LINE_BUTT:
|
2009-09-25 18:49:04 +00:00
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add line" ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
|
2009-09-25 18:49:04 +00:00
|
|
|
SetToolID( id, wxCURSOR_HAND, _( "Set anchor position" ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_IMPORT_BODY_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_ARROW, _( "Import" ) );
|
2009-11-04 20:46:53 +00:00
|
|
|
LoadOneSymbol();
|
2007-09-15 04:25:54 +00:00
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_EXPORT_BODY_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_ARROW, _( "Export" ) );
|
|
|
|
SaveOneSymbol();
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
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
|
|
|
{
|
|
|
|
DrawPanel->CursorOff( &dc );
|
|
|
|
|
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:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->CursorOn( &dc );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case ID_LIBEDIT_DELETE_ITEM_BUTT:
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-09-02 18:12:45 +00:00
|
|
|
wxBell();
|
|
|
|
break;
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
|
|
|
|
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
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
2010-10-20 20:24:26 +00:00
|
|
|
int oldFlags = m_drawItem->GetFlags();
|
|
|
|
m_drawItem->SetFlags( 0 );
|
|
|
|
m_drawItem->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform );
|
|
|
|
( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetScreen()->GetCursorDrawPosition() );
|
|
|
|
m_drawItem->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform );
|
|
|
|
m_drawItem->SetFlags( oldFlags );
|
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:
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
DrawPanel->CursorOff( &dc );
|
2009-09-25 18:49:04 +00:00
|
|
|
SaveCopyInUndoList( m_component );
|
2010-12-10 19:47:44 +00:00
|
|
|
if( m_drawItem->Type() == LIB_PIN_T )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
DeletePin( &dc, m_component, (LIB_PIN*) m_drawItem );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
|
|
|
|
else
|
2009-09-25 18:49:04 +00:00
|
|
|
m_component->RemoveDrawItem( m_drawItem, DrawPanel, &dc );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_drawItem = NULL;
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2007-09-15 04:25:54 +00:00
|
|
|
DrawPanel->CursorOn( &dc );
|
|
|
|
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;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
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;
|
|
|
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
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_ROTATE_GRAPHIC_TEXT:
|
2010-12-10 19:47:44 +00:00
|
|
|
if( m_drawItem == NULL && m_drawItem->Type() != LIB_TEXT_T )
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2010-10-20 20:24:26 +00:00
|
|
|
if( !m_drawItem->InEditMode() )
|
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
SaveCopyInUndoList( m_component );
|
2010-10-20 20:24:26 +00:00
|
|
|
m_drawItem->SetUnit( m_unit );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_drawItem->Rotate();
|
2010-10-23 13:49:14 +00:00
|
|
|
DrawPanel->Refresh();
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM:
|
2010-10-20 20:24:26 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( m_drawItem == NULL || ( m_drawItem->Type() != LIB_FIELD_T ) )
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2010-10-20 20:24:26 +00:00
|
|
|
|
|
|
|
if( !m_drawItem->InEditMode() )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
SaveCopyInUndoList( m_component );
|
2010-10-20 20:24:26 +00:00
|
|
|
m_drawItem->SetUnit( m_unit );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_drawItem->Rotate();
|
2010-10-23 13:49:14 +00:00
|
|
|
DrawPanel->Refresh();
|
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_FIELD_EDIT_ITEM:
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
DrawPanel->CursorOff( &dc );
|
2010-12-10 19:47:44 +00:00
|
|
|
if( m_drawItem->Type() == LIB_FIELD_T )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
EditField( &dc, (LIB_FIELD*) m_drawItem );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
2007-09-15 04:25:54 +00:00
|
|
|
DrawPanel->CursorOn( &dc );
|
|
|
|
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:
|
2009-09-25 18:49:04 +00:00
|
|
|
if( (m_drawItem == NULL )
|
2010-12-10 19:47:44 +00:00
|
|
|
|| (m_drawItem->Type() != LIB_PIN_T) )
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
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 );
|
2007-09-15 04:25:54 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
2008-12-30 19:18:56 +00:00
|
|
|
DrawPanel->m_AutoPAN_Request = false;
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_ZOOM;
|
2007-09-15 04:25:54 +00:00
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
2008-12-30 19:18:56 +00:00
|
|
|
DrawPanel->m_AutoPAN_Request = false;
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_DELETE;
|
2007-09-15 04:25:54 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_COPY_BLOCK:
|
2008-12-30 19:18:56 +00:00
|
|
|
DrawPanel->m_AutoPAN_Request = false;
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_COPY;
|
2007-09-15 04:25:54 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SELECT_ITEMS_BLOCK:
|
2008-12-30 19:18:56 +00:00
|
|
|
DrawPanel->m_AutoPAN_Request = false;
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_SELECT_ITEMS_ONLY;
|
2007-09-15 04:25:54 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
2009-08-12 10:40:01 +00:00
|
|
|
case ID_POPUP_MIRROR_Y_BLOCK:
|
2008-12-30 19:18:56 +00:00
|
|
|
DrawPanel->m_AutoPAN_Request = false;
|
2009-08-12 10:40:01 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_MIRROR_Y;
|
2007-09-15 04:25:54 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
2008-12-30 19:18:56 +00:00
|
|
|
DrawPanel->m_AutoPAN_Request = false;
|
2007-09-15 04:25:54 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-12-30 19:18:56 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = false;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
if( m_ID_current_state == 0 )
|
2009-09-25 18:49:04 +00:00
|
|
|
m_lastDrawItem = NULL;
|
2011-01-30 22:22:38 +00:00
|
|
|
|
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 );
|
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-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function TempCopyComponent
|
2010-10-23 10:09:23 +00:00
|
|
|
* create a temporary copy of the current edited component
|
|
|
|
* Used to prepare an Undo ant/or abort command before editing the component
|
|
|
|
*/
|
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;
|
2010-10-23 13:49:14 +00:00
|
|
|
m_tempCopyComponent = NULL;
|
2010-10-23 10:09:23 +00:00
|
|
|
if( m_component )
|
|
|
|
m_tempCopyComponent = new LIB_COMPONENT( *m_component );
|
|
|
|
}
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function RestoreComponent
|
2010-10-23 10:09:23 +00:00
|
|
|
* Restore the current edited component from its temporary copy.
|
|
|
|
* Used to abort a command
|
|
|
|
*/
|
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
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function ClearTempCopyComponent
|
2010-10-23 13:49:14 +00:00
|
|
|
* delete temporary copy of the current component and clear pointer
|
|
|
|
*/
|
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
|
|
|
|
|
|
|
|
|
|
|
/* Creates the SVG print file for the current edited component.
|
|
|
|
*/
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::SVG_Print_Component( const wxString& FullFileName )
|
2010-11-17 21:47:27 +00:00
|
|
|
{
|
|
|
|
DIALOG_SVG_PRINT::DrawSVGPage( this, FullFileName, GetScreen() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_DRAW_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;
|
|
|
|
|
|
|
|
/* Deleting old text. */
|
|
|
|
if( DC && !DrawItem->InEditMode() )
|
|
|
|
DrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransform );
|
|
|
|
|
|
|
|
DIALOG_LIB_EDIT_TEXT* frame = new DIALOG_LIB_EDIT_TEXT( this, (LIB_TEXT*) DrawItem );
|
|
|
|
frame->ShowModal();
|
|
|
|
frame->Destroy();
|
|
|
|
OnModify();
|
|
|
|
|
|
|
|
/* Display new text. */
|
|
|
|
if( DC && !DrawItem->InEditMode() )
|
|
|
|
DrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE, NULL,
|
|
|
|
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() )
|
|
|
|
{
|
|
|
|
// g_EditPinByPinIsOn is set to the better value, if m_UnitSelectionLocked has changed
|
|
|
|
g_EditPinByPinIsOn = GetComponent()->UnitsLocked() ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateAliasSelectList();
|
|
|
|
UpdatePartSelectList();
|
|
|
|
DisplayLibInfos();
|
|
|
|
DisplayCmpDoc();
|
|
|
|
OnModify();
|
|
|
|
DrawPanel->Refresh();
|
|
|
|
}
|
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,
|
|
|
|
wxT( "Cannot create new part from non-existant current part." ) );
|
|
|
|
|
2011-01-30 22:22:38 +00:00
|
|
|
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
|
2010-12-02 21:41:56 +00:00
|
|
|
DrawPanel->CursorOff( &dc );
|
|
|
|
EditField( &dc, &m_component->GetValueField() );
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
DrawPanel->CursorOn( &dc );
|
|
|
|
}
|