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
|
2017-05-03 20:20:46 +00:00
|
|
|
* Copyright (C) 2009-2017 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors.
|
2011-12-29 20:11:42 +00:00
|
|
|
*
|
|
|
|
* 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
|
2018-01-08 09:48:33 +00:00
|
|
|
* @brief Create, move .. graphic shapes used to build and draw a symbol (lines, arcs ..)
|
2011-09-30 18:15:37 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_draw_panel.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.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>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <lib_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#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
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <sch_view.h>
|
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 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
|
|
|
|
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;
|
|
|
|
|
2018-06-14 08:26:11 +00:00
|
|
|
DIALOG_LIB_EDIT_DRAW_ITEM dialog( this, DrawItem );
|
2010-02-04 17:46:12 +00:00
|
|
|
|
|
|
|
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)
|
2018-06-14 08:26:11 +00:00
|
|
|
m_drawLineWidth = dialog.GetWidth();
|
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
|
|
|
|
2018-10-18 09:50:43 +00:00
|
|
|
GetCanvas()->GetView()->Update( DrawItem );
|
|
|
|
GetCanvas()->Refresh();
|
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;
|
2018-04-10 10:52:12 +00:00
|
|
|
DrawItem->GetMsgPanelInfo( m_UserUnits, items );
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( items );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
static void AbortSymbolTraceOn( EDA_DRAW_PANEL* aPanel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2018-08-03 12:18:26 +00:00
|
|
|
LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->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 )
|
|
|
|
delete item;
|
|
|
|
else
|
|
|
|
parent->RestoreComponent();
|
2010-03-28 14:46:49 +00:00
|
|
|
|
2010-10-23 13:49:14 +00:00
|
|
|
parent->SetDrawItem( NULL );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
auto view = static_cast<SCH_DRAW_PANEL*>(aPanel)->GetView();
|
|
|
|
view->ClearPreview();
|
|
|
|
view->ShowPreview( false );
|
|
|
|
view->ClearHiddenFlags();
|
|
|
|
parent->RebuildView();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2017-12-18 05:21:00 +00:00
|
|
|
LIB_ITEM* item = GetDrawItem();
|
2018-10-23 16:16:23 +00:00
|
|
|
m_canvas->SetMouseCapture( RedrawWhileMovingCursor, AbortSymbolTraceOn );
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint drawPos = GetCrossHairPosition( true );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2018-01-08 09:48:33 +00:00
|
|
|
// no temp copy -> the current version of symbol will be used for Undo
|
|
|
|
// This is normal when adding new items to the current symbol
|
2010-10-23 13:49:14 +00:00
|
|
|
ClearTempCopyComponent();
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
auto view = static_cast<SCH_DRAW_PANEL*>(m_canvas)->GetView();
|
|
|
|
view->ShowPreview( true );
|
2018-10-22 11:41:38 +00:00
|
|
|
|
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:
|
2017-12-18 05:21:00 +00:00
|
|
|
item = new LIB_ARC( LibEntry );
|
2010-10-20 20:24:26 +00:00
|
|
|
break;
|
2011-02-24 12:35:14 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
|
2017-12-18 05:21:00 +00:00
|
|
|
item = new LIB_CIRCLE( LibEntry );
|
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
|
|
|
case ID_LIBEDIT_BODY_RECT_BUTT:
|
2017-12-18 05:21:00 +00:00
|
|
|
item = new LIB_RECTANGLE( LibEntry );
|
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
|
|
|
case ID_LIBEDIT_BODY_LINE_BUTT:
|
2017-12-18 05:21:00 +00:00
|
|
|
item = new LIB_POLYLINE( LibEntry );
|
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
|
|
|
case ID_LIBEDIT_BODY_TEXT_BUTT:
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
LIB_TEXT* text = new LIB_TEXT( LibEntry );
|
|
|
|
text->SetTextSize( wxSize( m_textSize, m_textSize ) );
|
|
|
|
text->SetTextAngle( m_current_text_angle );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
// Enter the graphic text info
|
|
|
|
m_canvas->SetIgnoreMouseEvents( true );
|
2017-01-23 20:30:11 +00:00
|
|
|
EditSymbolText( NULL, text );
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
if( text->GetText().IsEmpty() )
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
delete text;
|
2017-12-18 05:21:00 +00:00
|
|
|
item = NULL;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-18 05:21:00 +00:00
|
|
|
item = text;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
}
|
2007-08-24 15:10:46 +00:00
|
|
|
}
|
2010-10-20 20:24:26 +00:00
|
|
|
break;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +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
|
|
|
}
|
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
if( item )
|
2007-08-24 15:10:46 +00:00
|
|
|
{
|
2017-12-18 05:21:00 +00:00
|
|
|
item->BeginEdit( IS_NEW, drawPos );
|
2017-05-03 20:20:46 +00:00
|
|
|
|
|
|
|
// Don't set line parameters for text objects.
|
2017-12-18 05:21:00 +00:00
|
|
|
if( item->Type() != LIB_TEXT_T )
|
2017-05-03 20:20:46 +00:00
|
|
|
{
|
2017-12-18 05:21:00 +00:00
|
|
|
item->SetWidth( m_drawLineWidth );
|
|
|
|
item->SetFillMode( m_drawFillStyle );
|
2017-05-03 20:20:46 +00:00
|
|
|
}
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2009-10-19 19:00:47 +00:00
|
|
|
if( m_drawSpecificUnit )
|
2017-12-18 05:21:00 +00:00
|
|
|
item->SetUnit( m_unit );
|
2017-05-03 20:20:46 +00:00
|
|
|
|
2009-10-19 19:00:47 +00:00
|
|
|
if( m_drawSpecificConvert )
|
2017-12-18 05:21:00 +00:00
|
|
|
item->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 );
|
2017-12-18 05:21:00 +00:00
|
|
|
SetDrawItem( item );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
return item;
|
2007-05-06 16:03:28 +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
|
|
|
{
|
2017-12-18 05:21:00 +00:00
|
|
|
if( GetDrawItem() == 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
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
auto view = static_cast<SCH_DRAW_PANEL*>(m_canvas)->GetView();
|
|
|
|
view->ShowPreview( true );
|
2018-10-22 11:41:38 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
if( GetDrawItem()->ContinueEdit( pos ) )
|
2010-10-20 20:24:26 +00:00
|
|
|
return;
|
2018-10-22 11:41:38 +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
|
|
|
{
|
2018-10-18 09:50:43 +00:00
|
|
|
LIB_ITEM* item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem();
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return;
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
auto view = static_cast<SCH_DRAW_PANEL*>(aPanel)->GetView();
|
|
|
|
auto p = aPanel->GetParent()->GetCrossHairPosition( true );
|
|
|
|
|
|
|
|
item->CalcEdit( p );
|
2018-10-22 11:41:38 +00:00
|
|
|
|
2018-10-23 16:16:23 +00:00
|
|
|
view->Hide( item );
|
2018-08-03 12:18:26 +00:00
|
|
|
view->ClearPreview();
|
2018-10-23 16:16:23 +00:00
|
|
|
view->AddToPreview( item->Clone() );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-04 17:19:17 +00:00
|
|
|
void LIB_EDIT_FRAME::StartMoveDrawSymbol( wxDC* DC, LIB_ITEM* aItem )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2018-04-04 17:19:17 +00:00
|
|
|
if( aItem == 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
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
GetGalCanvas()->GetView()->Hide ( aItem );
|
|
|
|
|
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
|
2018-04-04 17:19:17 +00:00
|
|
|
if( aItem->Type() == LIB_FIELD_T )
|
|
|
|
aItem->BeginEdit( IS_MOVED, aItem->GetPosition() );
|
2013-02-26 11:25:30 +00:00
|
|
|
else
|
2018-04-04 17:19:17 +00:00
|
|
|
aItem->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
|
|
|
|
|
|
|
|
2018-04-04 17:19:17 +00:00
|
|
|
void LIB_EDIT_FRAME::StartModifyDrawSymbol( wxDC* DC, LIB_ITEM* aItem )
|
2010-02-04 17:46:12 +00:00
|
|
|
{
|
2018-04-04 17:19:17 +00:00
|
|
|
if( aItem == NULL )
|
2010-02-04 17:46:12 +00:00
|
|
|
return;
|
|
|
|
|
2018-10-11 05:31:17 +00:00
|
|
|
DBG(printf("startmdifyraw\n");)
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2010-10-23 10:09:23 +00:00
|
|
|
TempCopyComponent();
|
2018-04-04 17:19:17 +00:00
|
|
|
aItem->BeginEdit( IS_RESIZED, GetCrossHairPosition( true ) );
|
2018-10-23 16:16:23 +00:00
|
|
|
m_canvas->SetMouseCapture( RedrawWhileMovingCursor, AbortSymbolTraceOn );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, true );
|
2010-02-04 17:46:12 +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
|
|
|
{
|
2017-12-18 05:21:00 +00:00
|
|
|
LIB_ITEM* item = GetDrawItem();
|
|
|
|
|
|
|
|
if( item == NULL )
|
|
|
|
return;
|
|
|
|
|
2017-05-03 20:20:46 +00:00
|
|
|
if( LIB_PART* part = GetCurPart() )
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
{
|
|
|
|
if( GetToolId() != ID_NO_TOOL_SELECTED )
|
|
|
|
SetCursor( wxCURSOR_PENCIL );
|
|
|
|
else
|
2018-08-27 13:28:21 +00:00
|
|
|
SetCursor( (wxStockCursor) GetGalCanvas()->GetDefaultCursor() );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +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
|
2018-01-08 09:48:33 +00:00
|
|
|
// current symbol. So save it.
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
SaveCopyInUndoList( part );
|
|
|
|
}
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
if( item->IsNew() )
|
|
|
|
part->AddDrawItem( item );
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
item->EndEdit( GetCrossHairPosition( true ) );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
2017-12-18 05:21:00 +00:00
|
|
|
SetDrawItem( NULL );
|
2007-08-24 15:10:46 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
m_canvas->SetMouseCapture( NULL, NULL );
|
2018-10-22 11:41:38 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
auto view = static_cast<SCH_DRAW_PANEL*>(m_canvas)->GetView();
|
|
|
|
|
2018-10-11 05:31:17 +00:00
|
|
|
DBG(printf("end: pos %d %d\n", item->GetPosition().x, item->GetPosition().y );)
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
view->ClearHiddenFlags();
|
|
|
|
view->ClearPreview();
|
|
|
|
|
2018-09-04 16:12:15 +00:00
|
|
|
OnModify();
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
}
|
2018-10-22 11:41:38 +00:00
|
|
|
|
|
|
|
RebuildView();
|
|
|
|
GetCanvas()->Refresh();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|