2007-08-24 15:10:46 +00:00
|
|
|
/*********************************************************************/
|
2009-09-04 18:57:37 +00:00
|
|
|
/* EESchema - symbdraw.cpp */
|
2007-08-24 15:10:46 +00:00
|
|
|
/* Create, move .. graphic shapes used to build and draw a component */
|
2009-09-04 18:57:37 +00:00
|
|
|
/* (lines, arcs .. */
|
2007-08-24 15:10:46 +00:00
|
|
|
/*********************************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-01-29 14:26:20 +00:00
|
|
|
#include "gr_basic.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "class_sch_screen.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
#include "eeschema_id.h"
|
2010-10-23 10:09:23 +00:00
|
|
|
#include "general.h"
|
2010-02-16 16:21:52 +00:00
|
|
|
#include "libeditframe.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_libentry.h"
|
2010-10-08 20:40:57 +00:00
|
|
|
#include "lib_arc.h"
|
|
|
|
#include "lib_circle.h"
|
|
|
|
#include "lib_polyline.h"
|
|
|
|
#include "lib_rectangle.h"
|
2010-10-22 12:11:52 +00:00
|
|
|
#include "lib_text.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2010-11-17 21:47:27 +00:00
|
|
|
#include "dialogs/dialog_lib_edit_draw_item.h"
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
static void SymbolDisplayDraw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase );
|
|
|
|
static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase );
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-10-20 19:36:58 +00:00
|
|
|
/*
|
|
|
|
* Show the dialog box for editing a graphical item properties
|
2007-08-24 15:10:46 +00:00
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-20 19:36:58 +00:00
|
|
|
if( DrawItem == NULL )
|
2009-09-25 18:49:04 +00:00
|
|
|
return;
|
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
LIB_COMPONENT* component = DrawItem->GetParent();
|
2008-09-09 16:56:47 +00:00
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
DIALOG_LIB_EDIT_DRAW_ITEM dialog( this, DrawItem->GetTypeName() );
|
2008-09-09 16:56:47 +00:00
|
|
|
|
2010-07-12 14:07:09 +00:00
|
|
|
dialog.SetWidthUnits( ReturnUnitSymbol( g_UserUnit ) );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2010-10-08 20:40:57 +00:00
|
|
|
wxString val = ReturnStringFromValue( g_UserUnit, m_drawLineWidth, m_InternalUnits );
|
2010-02-04 17:46:12 +00:00
|
|
|
dialog.SetWidth( val );
|
|
|
|
dialog.SetApplyToAllUnits( !m_drawSpecificUnit );
|
|
|
|
dialog.EnableApplyToAllUnits( component && component->GetPartCount() > 1 );
|
|
|
|
dialog.SetApplyToAllConversions( !m_drawSpecificConvert );
|
|
|
|
dialog.EnableApplyToAllConversions( component && component->HasConversion() );
|
2010-02-25 19:45:34 +00:00
|
|
|
// dialog.SetFillStyle( m_drawFillStyle ); // could better to show the current setting
|
2010-10-25 15:43:42 +00:00
|
|
|
dialog.SetFillStyle( DrawItem->GetFillMode() );
|
2010-02-04 17:46:12 +00:00
|
|
|
dialog.EnableFillStyle( DrawItem->IsFillable() );
|
|
|
|
|
|
|
|
if( dialog.ShowModal() == wxID_CANCEL )
|
2009-10-20 19:36:58 +00:00
|
|
|
return;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
val = dialog.GetWidth();
|
2010-10-08 20:40:57 +00:00
|
|
|
m_drawLineWidth = ReturnValueFromString( g_UserUnit, val, m_InternalUnits );
|
2010-02-04 17:46:12 +00:00
|
|
|
m_drawSpecificConvert = !dialog.GetApplyToAllConversions();
|
|
|
|
m_drawSpecificUnit = !dialog.GetApplyToAllUnits();
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2010-02-25 19:45:34 +00:00
|
|
|
#if 0
|
|
|
|
/* TODO: see if m_drawFillStyle must retain the last fill option or not.
|
|
|
|
* if the last is Filled, having next new graphic items created
|
|
|
|
* with filled body is often bad.
|
2010-10-23 10:09:23 +00:00
|
|
|
* currently m_drawFillStyle is left with the default value (not filled)
|
2010-02-25 19:45:34 +00:00
|
|
|
*/
|
2009-10-20 19:36:58 +00:00
|
|
|
if( DrawItem->IsFillable() )
|
2010-02-04 17:46:12 +00:00
|
|
|
m_drawFillStyle = (FILL_T) dialog.GetFillStyle();
|
2010-02-25 19:45:34 +00:00
|
|
|
#endif
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2010-10-23 10:09:23 +00:00
|
|
|
// Save copy for undo if not in edit (edit command already handle the save copy)
|
2010-10-23 13:49:14 +00:00
|
|
|
if( !DrawItem->InEditMode() )
|
2009-10-20 19:36:58 +00:00
|
|
|
SaveCopyInUndoList( DrawItem->GetParent() );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2009-10-20 19:36:58 +00:00
|
|
|
if( m_drawSpecificUnit )
|
2010-10-25 15:43:42 +00:00
|
|
|
DrawItem->SetUnit( GetUnit() );
|
2009-10-20 19:36:58 +00:00
|
|
|
else
|
2010-10-25 15:43:42 +00:00
|
|
|
DrawItem->SetUnit( 0 );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-10-20 19:36:58 +00:00
|
|
|
if( m_drawSpecificConvert )
|
2010-10-25 15:43:42 +00:00
|
|
|
DrawItem->SetConvert( GetConvert() );
|
2009-10-20 19:36:58 +00:00
|
|
|
else
|
2010-10-25 15:43:42 +00:00
|
|
|
DrawItem->SetConvert( 0 );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-10-20 19:36:58 +00:00
|
|
|
if( DrawItem->IsFillable() )
|
2010-10-25 15:43:42 +00:00
|
|
|
DrawItem->SetFillMode( (FILL_T) dialog.GetFillStyle() );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-10-20 19:36:58 +00:00
|
|
|
DrawItem->SetWidth( m_drawLineWidth );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-10-20 19:36:58 +00:00
|
|
|
if( component )
|
|
|
|
component->GetDrawItemList().sort();
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-10-20 19:36:58 +00:00
|
|
|
DrawItem->DisplayInfo( this );
|
|
|
|
DrawPanel->Refresh();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) Panel->GetParent();
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* item = parent->GetDrawItem();
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return;
|
|
|
|
|
2010-10-23 10:09:23 +00:00
|
|
|
bool newItem = item->IsNew();
|
2011-02-11 20:48:13 +00:00
|
|
|
item->EndEdit( parent->GetScreen()->GetCrossHairPosition( true ), true );
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2010-10-23 10:09:23 +00:00
|
|
|
if( newItem )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
2010-10-23 10:09:23 +00:00
|
|
|
delete item;
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
2010-10-23 10:09:23 +00:00
|
|
|
else
|
|
|
|
parent->RestoreComponent();
|
2010-03-28 14:46:49 +00:00
|
|
|
|
2010-10-23 13:49:14 +00:00
|
|
|
parent->SetDrawItem( NULL );
|
2010-10-20 20:24:26 +00:00
|
|
|
Panel->Refresh();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn );
|
|
|
|
wxPoint drawPos = GetScreen()->GetCrossHairPosition( true );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2010-10-23 13:49:14 +00:00
|
|
|
// no temp copy -> the current version of component will be used for Undo
|
|
|
|
// This is normal when adding new items to the current component
|
|
|
|
ClearTempCopyComponent();
|
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
switch( GetToolId() )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
case ID_LIBEDIT_BODY_ARC_BUTT:
|
2010-10-20 20:24:26 +00:00
|
|
|
m_drawItem = new LIB_ARC( LibEntry );
|
|
|
|
break;
|
2011-02-24 12:35:14 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
|
2010-10-20 20:24:26 +00:00
|
|
|
m_drawItem = new LIB_CIRCLE( LibEntry );
|
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
case ID_LIBEDIT_BODY_RECT_BUTT:
|
2010-10-20 20:24:26 +00:00
|
|
|
m_drawItem = new LIB_RECTANGLE( LibEntry );
|
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
case ID_LIBEDIT_BODY_LINE_BUTT:
|
2010-10-20 20:24:26 +00:00
|
|
|
m_drawItem = new LIB_POLYLINE( LibEntry );
|
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
case ID_LIBEDIT_BODY_TEXT_BUTT:
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_TEXT* Text = new LIB_TEXT( LibEntry );
|
2010-02-04 17:46:12 +00:00
|
|
|
Text->m_Size.x = Text->m_Size.y = m_textSize;
|
|
|
|
Text->m_Orient = m_textOrientation;
|
2010-01-13 13:43:36 +00:00
|
|
|
|
2009-12-29 10:35:11 +00:00
|
|
|
// Enter the graphic text info
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = true;
|
2007-08-24 15:10:46 +00:00
|
|
|
EditSymbolText( NULL, Text );
|
2009-12-29 10:35:11 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = false;
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2010-01-13 13:43:36 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
if( Text->m_Text.IsEmpty() )
|
|
|
|
{
|
2010-10-23 13:49:14 +00:00
|
|
|
delete Text;
|
2009-09-25 18:49:04 +00:00
|
|
|
m_drawItem = NULL;
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-20 20:24:26 +00:00
|
|
|
m_drawItem = Text;
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
2010-10-20 20:24:26 +00:00
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
2009-09-25 18:49:04 +00:00
|
|
|
default:
|
2010-11-19 16:28:46 +00:00
|
|
|
DisplayError( this, wxT( "LIB_EDIT_FRAME::CreateGraphicItem() error" ) );
|
2009-09-25 18:49:04 +00:00
|
|
|
return NULL;
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
2010-10-20 20:24:26 +00:00
|
|
|
m_drawItem->BeginEdit( IS_NEW, drawPos );
|
|
|
|
m_drawItem->SetWidth( m_drawLineWidth );
|
2010-10-25 15:43:42 +00:00
|
|
|
m_drawItem->SetFillMode( m_drawFillStyle );
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2009-10-19 19:00:47 +00:00
|
|
|
if( m_drawSpecificUnit )
|
2010-10-25 15:43:42 +00:00
|
|
|
m_drawItem->SetUnit( m_unit );
|
2009-10-19 19:00:47 +00:00
|
|
|
if( m_drawSpecificConvert )
|
2010-10-25 15:43:42 +00:00
|
|
|
m_drawItem->SetConvert( m_convert );
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2010-10-23 13:49:14 +00:00
|
|
|
// Draw initial symbol:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false );
|
2010-10-20 20:24:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->EndMouseCapture();
|
2010-10-20 20:24:26 +00:00
|
|
|
return NULL;
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2007-08-24 15:10:46 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
return m_drawItem;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Create new library component graphic object.
|
2007-08-24 15:10:46 +00:00
|
|
|
*/
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::GraphicItemBeginDraw( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem == NULL )
|
2007-08-24 15:10:46 +00:00
|
|
|
return;
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
wxPoint pos = GetScreen()->GetCrossHairPosition( true );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
if( m_drawItem->ContinueEdit( pos ) )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
2010-10-20 20:24:26 +00:00
|
|
|
m_drawItem->Draw( DrawPanel, DC, pos, -1, g_XorMode, NULL, DefaultTransform );
|
|
|
|
return;
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
EndDrawGraphicItem( DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
/*
|
2009-11-04 20:46:53 +00:00
|
|
|
* Redraw the graphic shape while moving
|
2009-09-25 18:49:04 +00:00
|
|
|
*/
|
2011-02-03 19:27:28 +00:00
|
|
|
static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* item;
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem();
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
BASE_SCREEN* Screen = aPanel->GetScreen();
|
|
|
|
|
|
|
|
item->SetEraseLastDrawItem( aErase );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2010-12-22 11:18:38 +00:00
|
|
|
// if item is the reference field, we must add the current unit id
|
|
|
|
if( item->Type() == LIB_FIELD_T )
|
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
int unit = ((LIB_EDIT_FRAME*)aPanel->GetParent())->GetUnit();
|
2010-12-22 11:18:38 +00:00
|
|
|
wxString text = ((LIB_FIELD*)item)->GetFullText( unit );
|
2011-02-11 20:48:13 +00:00
|
|
|
item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), -1, g_XorMode, &text,
|
2010-12-22 11:18:38 +00:00
|
|
|
DefaultTransform );
|
|
|
|
}
|
|
|
|
else
|
2011-02-11 20:48:13 +00:00
|
|
|
item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), -1, g_XorMode, NULL,
|
2011-02-03 19:27:28 +00:00
|
|
|
DefaultTransform );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::StartMoveDrawSymbol( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem == NULL )
|
2007-08-24 15:10:46 +00:00
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
SetCursor( wxCURSOR_HAND );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-10-23 10:09:23 +00:00
|
|
|
TempCopyComponent();
|
2011-02-11 20:48:13 +00:00
|
|
|
m_drawItem->BeginEdit( IS_MOVED, GetScreen()->GetCrossHairPosition( true ) );
|
|
|
|
DrawPanel->SetMouseCapture( RedrawWhileMovingCursor, AbortSymbolTraceOn );
|
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true );
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
// @brief Modify a graphic symbol (drag edges etc.)
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::StartModifyDrawSymbol( wxDC* DC )
|
2010-02-04 17:46:12 +00:00
|
|
|
{
|
|
|
|
if( m_drawItem == NULL )
|
|
|
|
return;
|
|
|
|
|
2010-10-23 10:09:23 +00:00
|
|
|
TempCopyComponent();
|
2011-02-11 20:48:13 +00:00
|
|
|
m_drawItem->BeginEdit( IS_RESIZED, GetScreen()->GetCrossHairPosition( true ) );
|
|
|
|
DrawPanel->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn );
|
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, true );
|
2010-02-04 17:46:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! @brief Manage mouse events when creating new graphic object or modifying an graphic object.
|
2011-02-03 19:27:28 +00:00
|
|
|
static void SymbolDisplayDraw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
BASE_SCREEN* Screen = aPanel->GetScreen();
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem();
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
item->SetEraseLastDrawItem( aErase );
|
2011-02-11 20:48:13 +00:00
|
|
|
item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), -1, g_XorMode, NULL,
|
2010-10-20 20:24:26 +00:00
|
|
|
DefaultTransform );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
/*
|
2010-10-23 13:49:14 +00:00
|
|
|
* Place the new graphic object in the list of component drawing objects,
|
|
|
|
* or terminate a draw item edition
|
2007-08-24 15:10:46 +00:00
|
|
|
*/
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::EndDrawGraphicItem( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component == NULL || m_drawItem == NULL )
|
2007-08-24 15:10:46 +00:00
|
|
|
return;
|
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() != ID_NO_TOOL_SELECTED )
|
2007-08-24 15:10:46 +00:00
|
|
|
SetCursor( wxCURSOR_PENCIL );
|
|
|
|
else
|
2011-02-24 20:22:12 +00:00
|
|
|
SetCursor( DrawPanel->GetDefaultCursor() );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2010-10-23 13:49:14 +00:00
|
|
|
if( GetTempCopyComponent() ) // used when editing an existing item
|
|
|
|
SaveCopyInUndoList( GetTempCopyComponent() );
|
|
|
|
else // When creating a new item, there is still no change for the current component
|
|
|
|
// So save it.
|
|
|
|
SaveCopyInUndoList( m_component );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
if( m_drawItem->IsNew() )
|
|
|
|
m_component->AddDrawItem( m_drawItem );
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
m_drawItem->EndEdit( GetScreen()->GetCrossHairPosition( true ) );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
m_drawItem = NULL;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
OnModify();
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( NULL, NULL );
|
2010-10-20 20:24:26 +00:00
|
|
|
DrawPanel->Refresh();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|