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>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.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
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxString val = StringFromValue( g_UserUnit, DrawItem->GetWidth() );
|
2010-02-04 17:46:12 +00:00
|
|
|
dialog.SetWidth( val );
|
2012-07-17 15:29:29 +00:00
|
|
|
dialog.SetApplyToAllUnits( DrawItem->GetUnit() == 0 );
|
2010-02-04 17:46:12 +00:00
|
|
|
dialog.EnableApplyToAllUnits( component && component->GetPartCount() > 1 );
|
2012-07-17 15:29:29 +00:00
|
|
|
dialog.SetApplyToAllConversions( DrawItem->GetConvert() == 0 );
|
2010-02-04 17:46:12 +00:00
|
|
|
dialog.EnableApplyToAllConversions( component && component->HasConversion() );
|
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
|
|
|
|
2012-07-17 15:29:29 +00:00
|
|
|
// Init default values (used to create a new draw item)
|
2010-02-04 17:46:12 +00:00
|
|
|
val = dialog.GetWidth();
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
m_drawLineWidth = ValueFromString( 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
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
MSG_PANEL_ITEMS items;
|
|
|
|
DrawItem->GetMsgPanelInfo( items );
|
|
|
|
SetMsgPanel( items );
|
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();
|
2013-08-03 05:15:23 +00:00
|
|
|
item->EndEdit( parent->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 );
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint drawPos = 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 );
|
2013-03-18 19:36:07 +00:00
|
|
|
Text->SetSize( wxSize( m_textSize, m_textSize ) );
|
|
|
|
Text->SetOrientation( 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
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( Text->GetText().IsEmpty() )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
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;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint pos = 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
|
|
|
{
|
2012-09-02 12:06:47 +00:00
|
|
|
m_drawItem->Draw( m_canvas, DC, pos, UNSPECIFIED_COLOR, 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
|
|
|
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 )
|
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
int unit = ((LIB_EDIT_FRAME*)aPanel->GetParent())->GetUnit();
|
|
|
|
wxString text = ((LIB_FIELD*)item)->GetFullText( unit );
|
|
|
|
|
|
|
|
item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
|
2013-05-28 08:05:10 +00:00
|
|
|
UNSPECIFIED_COLOR, g_XorMode, &text,
|
2010-12-22 11:18:38 +00:00
|
|
|
DefaultTransform );
|
|
|
|
}
|
|
|
|
else
|
2013-08-03 05:15:23 +00:00
|
|
|
item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
|
2013-05-28 08:05:10 +00:00
|
|
|
UNSPECIFIED_COLOR, 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();
|
2013-02-26 11:25:30 +00:00
|
|
|
|
|
|
|
// For fields only, move the anchor point of the field
|
|
|
|
// to the cursor position to allow user to see the text justification
|
|
|
|
if( m_drawItem->Type() == LIB_FIELD_T )
|
|
|
|
m_drawItem->BeginEdit( IS_MOVED, m_drawItem->GetPosition() );
|
|
|
|
else
|
2013-08-03 05:15:23 +00:00
|
|
|
m_drawItem->BeginEdit( IS_MOVED, GetCrossHairPosition( true ) );
|
2013-02-26 11:25:30 +00:00
|
|
|
|
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();
|
2013-08-03 05:15:23 +00:00
|
|
|
m_drawItem->BeginEdit( IS_RESIZED, 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-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 );
|
2013-08-03 05:15:23 +00:00
|
|
|
item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ), UNSPECIFIED_COLOR, 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 );
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
m_drawItem->EndEdit( 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
|
|
|
}
|