2011-12-29 20:11:42 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2009-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
|
|
|
|
*/
|
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
/**
|
|
|
|
* @file symbdraw.cpp
|
|
|
|
* @brief Create, move .. graphic shapes used to build and draw a component (lines, arcs ..)
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <class_sch_screen.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <eeschema_id.h>
|
|
|
|
#include <general.h>
|
|
|
|
#include <libeditframe.h>
|
|
|
|
#include <class_libentry.h>
|
|
|
|
#include <lib_arc.h>
|
|
|
|
#include <lib_circle.h>
|
|
|
|
#include <lib_polyline.h>
|
|
|
|
#include <lib_rectangle.h>
|
|
|
|
#include <lib_text.h>
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialogs/dialog_lib_edit_draw_item.h>
|
2010-11-17 21:47:27 +00:00
|
|
|
|
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
|
|
|
|
2012-04-13 18:51:24 +00:00
|
|
|
wxString val = ReturnStringFromValue( g_UserUnit, m_drawLineWidth );
|
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();
|
2012-04-16 17:39:32 +00:00
|
|
|
m_drawLineWidth = ReturnValueFromString( g_UserUnit, val );
|
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 );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->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-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn );
|
2011-02-11 20:48:13 +00:00
|
|
|
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
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( true );
|
2007-08-24 15:10:46 +00:00
|
|
|
EditSymbolText( NULL, Text );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->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-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
2010-10-20 20:24:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture();
|
2010-10-20 20:24:26 +00:00
|
|
|
return NULL;
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
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
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_drawItem->Draw( m_canvas, DC, pos, -1, g_XorMode, NULL, DefaultTransform );
|
2010-10-20 20:24:26 +00:00
|
|
|
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 ) );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( RedrawWhileMovingCursor, AbortSymbolTraceOn );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( 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 ) );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( 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
|
2012-02-28 20:14:17 +00:00
|
|
|
SetCursor( (wxStockCursor) m_canvas->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-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( NULL, NULL );
|
|
|
|
m_canvas->Refresh();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|