diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 005e9b200d..cd7fa7c9a6 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -121,7 +121,6 @@ set ( EESCHEMA_LIBEDIT_SRCS libedit/lib_edit_frame.cpp libedit/libfield.cpp libedit/menubar_libedit.cpp - libedit/pinedit.cpp libedit/symbdraw.cpp libedit/symbedit.cpp libedit/toolbars_libedit.cpp @@ -234,8 +233,10 @@ set( EESCHEMA_SRCS netlist_exporters/netlist_exporter_orcadpcb2.cpp netlist_exporters/netlist_exporter_pspice.cpp + tools/lib_drawing_tools.cpp + tools/lib_pin_tool.cpp tools/sch_actions.cpp - tools/sch_drawing_tool.cpp + tools/sch_drawing_tools.cpp tools/sch_edit_tool.cpp tools/sch_editor_control.cpp tools/sch_inspection_tool.cpp diff --git a/eeschema/dialogs/dialog_lib_edit_text.cpp b/eeschema/dialogs/dialog_lib_edit_text.cpp index 90c7416f07..ff4a21df59 100644 --- a/eeschema/dialogs/dialog_lib_edit_text.cpp +++ b/eeschema/dialogs/dialog_lib_edit_text.cpp @@ -89,10 +89,10 @@ bool DIALOG_LIB_EDIT_TEXT::TransferDataToWindow() } else { - m_textSize.SetValue( m_parent->m_textSize ); + m_textSize.SetValue( m_parent->g_LastTextSize ); - m_CommonUnit->SetValue( !m_parent->m_drawSpecificUnit ); - m_CommonConvert->SetValue( !m_parent->m_drawSpecificConvert ); + m_CommonUnit->SetValue( !m_parent->m_DrawSpecificUnit ); + m_CommonConvert->SetValue( !m_parent->m_DrawSpecificConvert ); m_orientChoice->SetSelection( m_graphicText->GetTextAngle() == TEXT_ANGLE_HORIZ ? 0 : 1 ); } @@ -102,11 +102,11 @@ bool DIALOG_LIB_EDIT_TEXT::TransferDataToWindow() bool DIALOG_LIB_EDIT_TEXT::TransferDataFromWindow() { - m_parent->m_current_text_angle = m_orientChoice->GetSelection() ? TEXT_ANGLE_VERT + m_parent->g_LastTextAngle = m_orientChoice->GetSelection() ? TEXT_ANGLE_VERT : TEXT_ANGLE_HORIZ; - m_parent->m_textSize = m_textSize.GetValue(); - m_parent->m_drawSpecificConvert = !m_CommonConvert->GetValue(); - m_parent->m_drawSpecificUnit = !m_CommonUnit->GetValue(); + m_parent->g_LastTextSize = m_textSize.GetValue(); + m_parent->m_DrawSpecificConvert = !m_CommonConvert->GetValue(); + m_parent->m_DrawSpecificUnit = !m_CommonUnit->GetValue(); if( m_graphicText ) { @@ -116,15 +116,15 @@ bool DIALOG_LIB_EDIT_TEXT::TransferDataFromWindow() m_graphicText->SetText( m_TextValue->GetValue() ); m_graphicText->SetPosition( wxPoint( m_posX.GetValue(), m_posY.GetValue() ) ); - m_graphicText->SetTextSize( wxSize( m_parent->m_textSize, m_parent->m_textSize ) ); - m_graphicText->SetTextAngle( m_parent->m_current_text_angle ); + m_graphicText->SetTextSize( wxSize( m_parent->g_LastTextSize, m_parent->g_LastTextSize ) ); + m_graphicText->SetTextAngle( m_parent->g_LastTextAngle ); - if( m_parent->m_drawSpecificUnit ) + if( m_parent->m_DrawSpecificUnit ) m_graphicText->SetUnit( m_parent->GetUnit() ); else m_graphicText->SetUnit( 0 ); - if( m_parent->m_drawSpecificConvert ) + if( m_parent->m_DrawSpecificConvert ) m_graphicText->SetConvert( m_parent->GetConvert() ); else m_graphicText->SetConvert( 0 ); diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index 2879a62377..5435500593 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -69,17 +69,18 @@ #include #include #include +#include +#include #include #include - int LIB_EDIT_FRAME:: m_unit = 1; int LIB_EDIT_FRAME:: m_convert = 1; LIB_ITEM* LIB_EDIT_FRAME:: m_lastDrawItem = NULL; bool LIB_EDIT_FRAME:: m_showDeMorgan = false; -int LIB_EDIT_FRAME:: m_textSize = -1; -double LIB_EDIT_FRAME:: m_current_text_angle = TEXT_ANGLE_HORIZ; +int LIB_EDIT_FRAME:: g_LastTextSize = -1; +double LIB_EDIT_FRAME:: g_LastTextAngle = TEXT_ANGLE_HORIZ; int LIB_EDIT_FRAME:: m_drawLineWidth = 0; // these values are overridden when reading the config @@ -205,8 +206,8 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : { m_showAxis = true; // true to draw axis SetShowDeMorgan( false ); - m_drawSpecificConvert = true; - m_drawSpecificUnit = false; + m_DrawSpecificConvert = true; + m_DrawSpecificUnit = false; m_hotkeysDescrList = g_Libedit_Hotkeys_Descr; m_syncPinEdit = false; m_repeatPinStep = DEFAULT_REPEAT_OFFSET_PIN; @@ -219,8 +220,8 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_libMgr = nullptr; // Delayed initialization - if( m_textSize == -1 ) - m_textSize = GetDefaultTextSize(); + if( g_LastTextSize == -1 ) + g_LastTextSize = GetDefaultTextSize(); // Initialize grid id to the default value 50 mils: m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; @@ -337,6 +338,8 @@ void LIB_EDIT_FRAME::setupTools() m_toolManager->RegisterTool( new SCH_SELECTION_TOOL ); m_toolManager->RegisterTool( new SCH_PICKER_TOOL ); m_toolManager->RegisterTool( new SCH_INSPECTION_TOOL ); + m_toolManager->RegisterTool( new LIB_PIN_TOOL ); + m_toolManager->RegisterTool( new LIB_DRAWING_TOOLS ); m_toolManager->InitTools(); // Run the selection tool, it is supposed to be always active @@ -1054,7 +1057,7 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event ) // also set default edit options to the better value // Usually if units are locked, graphic items are specific to each unit // and if units are interchangeable, graphic items are common to units - m_drawSpecificUnit = GetCurPart()->UnitsLocked(); + m_DrawSpecificUnit = GetCurPart()->UnitsLocked(); } if( oldName != GetCurPart()->GetName() ) @@ -1091,7 +1094,11 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) switch( id ) { + case ID_NO_TOOL_SELECTED: case ID_ZOOM_SELECTION: + case ID_LIBEDIT_PIN_BUTT: + case ID_LIBEDIT_BODY_TEXT_BUTT: + case ID_LIBEDIT_ANCHOR_ITEM_BUTT: // moved to modern toolset return; default: @@ -1102,31 +1109,6 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) switch( id ) { - case ID_NO_TOOL_SELECTED: - SetToolID( id, GetGalCanvas()->GetDefaultCursor(), wxEmptyString ); - break; - - case ID_LIBEDIT_PIN_BUTT: - if( part ) - { - SetToolID( id, wxCURSOR_PENCIL, _( "Add pin" ) ); - } - else - { - SetToolID( id, wxCURSOR_ARROW, _( "Set pin options" ) ); - - wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); - - cmd.SetId( ID_LIBEDIT_EDIT_PIN ); - GetEventHandler()->ProcessEvent( cmd ); - SetNoToolSelected(); - } - break; - - case ID_LIBEDIT_BODY_TEXT_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) ); - break; - case ID_LIBEDIT_BODY_RECT_BUTT: SetToolID( id, wxCURSOR_PENCIL, _( "Add rectangle" ) ); break; @@ -1143,10 +1125,6 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) SetToolID( id, wxCURSOR_PENCIL, _( "Add line" ) ); break; - case ID_LIBEDIT_ANCHOR_ITEM_BUTT: - SetToolID( id, wxCURSOR_HAND, _( "Set anchor position" ) ); - break; - case ID_LIBEDIT_IMPORT_BODY_BUTT: SetToolID( id, GetGalCanvas()->GetDefaultCursor(), _( "Import" ) ); LoadOneSymbol(); diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index d1ee6100ce..5c92c324b2 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -57,17 +57,6 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME SYMBOL_TREE_PANE* m_treePane; ///< component search tree widget LIB_MANAGER* m_libMgr; ///< manager taking care of temporary modificatoins - /** Convert of the item currently being drawn. */ - bool m_drawSpecificConvert; - - /** - * Specify which component parts the current draw item applies to. - * - * If true, the item being drawn or edited applies only to the selected - * part. Otherwise it applies to all parts in the component. - */ - bool m_drawSpecificUnit; - /** * Set to true to not synchronize pins at the same position when editing * symbols with multiple units or multiple body styles. @@ -116,12 +105,6 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME // these tools must left enabled static bool m_showDeMorgan; - /// The current text size setting. - static int m_textSize; - - /// Current text angle setting. - static double m_current_text_angle; - /// The default pin num text size setting. static int m_textPinNumDefaultSize; @@ -136,10 +119,22 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME int m_defaultLibWidth; - friend class DIALOG_LIB_EDIT_TEXT; +public: + /** Convert of the item currently being drawn. */ + bool m_DrawSpecificConvert; + + /** + * Specify which component parts the current draw item applies to. + * + * If true, the item being drawn or edited applies only to the selected + * part. Otherwise it applies to all parts in the component. + */ + bool m_DrawSpecificUnit; + + static int g_LastTextSize; + static double g_LastTextAngle; public: - LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ); ~LIB_EDIT_FRAME(); diff --git a/eeschema/libedit/libedit.cpp b/eeschema/libedit/libedit.cpp index f0eb75d7ad..938c6a3cbb 100644 --- a/eeschema/libedit/libedit.cpp +++ b/eeschema/libedit/libedit.cpp @@ -707,7 +707,7 @@ void LIB_EDIT_FRAME::loadPart( const wxString& aAlias, const wxString& aLibrary, // Optimize default edit options for this symbol // Usually if units are locked, graphic items are specific to each unit // and if units are interchangeable, graphic items are common to units - m_drawSpecificUnit = part->UnitsLocked() ? true : false; + m_DrawSpecificUnit = part->UnitsLocked() ? true : false; LoadOneLibraryPartAux( alias, aLibrary, aUnit, 0 ); } diff --git a/eeschema/libedit/libedit_onleftclick.cpp b/eeschema/libedit/libedit_onleftclick.cpp index 3f57b11e66..8653760adf 100644 --- a/eeschema/libedit/libedit_onleftclick.cpp +++ b/eeschema/libedit/libedit_onleftclick.cpp @@ -74,18 +74,10 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) } break; - case ID_LIBEDIT_PIN_BUTT: - if( no_item_edited ) - CreatePin( DC ); - else - PlacePin(); - break; - case ID_LIBEDIT_BODY_LINE_BUTT: case ID_LIBEDIT_BODY_ARC_BUTT: case ID_LIBEDIT_BODY_CIRCLE_BUTT: case ID_LIBEDIT_BODY_RECT_BUTT: - case ID_LIBEDIT_BODY_TEXT_BUTT: if( no_item_edited ) SetDrawItem( CreateGraphicItem( part, DC ) ); else if( item ) @@ -104,10 +96,10 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) deleteItem( DC, item ); break; + case ID_LIBEDIT_BODY_TEXT_BUTT: case ID_LIBEDIT_ANCHOR_ITEM_BUTT: - SaveCopyInUndoList( part ); - PlaceAnchor(); - SetNoToolSelected(); + case ID_LIBEDIT_PIN_BUTT: + // Moved to modern toolset break; default: diff --git a/eeschema/libedit/symbdraw.cpp b/eeschema/libedit/symbdraw.cpp index 5e01032765..704a996d08 100644 --- a/eeschema/libedit/symbdraw.cpp +++ b/eeschema/libedit/symbdraw.cpp @@ -63,8 +63,8 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem ) // Init default values (used to create a new draw item) m_drawLineWidth = dialog.GetWidth(); - m_drawSpecificConvert = !dialog.GetApplyToAllConversions(); - m_drawSpecificUnit = !dialog.GetApplyToAllUnits(); + m_DrawSpecificConvert = !dialog.GetApplyToAllConversions(); + m_DrawSpecificUnit = !dialog.GetApplyToAllUnits(); #if 0 /* TODO: see if m_drawFillStyle must retain the last fill option or not. @@ -80,12 +80,12 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem ) if( !DrawItem->InEditMode() ) SaveCopyInUndoList( DrawItem->GetParent() ); - if( m_drawSpecificUnit ) + if( m_DrawSpecificUnit ) DrawItem->SetUnit( GetUnit() ); else DrawItem->SetUnit( 0 ); - if( m_drawSpecificConvert ) + if( m_DrawSpecificConvert ) DrawItem->SetConvert( GetConvert() ); else DrawItem->SetConvert( 0 ); @@ -163,28 +163,7 @@ LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC ) break; case ID_LIBEDIT_BODY_TEXT_BUTT: - { - LIB_TEXT* text = new LIB_TEXT( LibEntry ); - text->SetTextSize( wxSize( m_textSize, m_textSize ) ); - text->SetTextAngle( m_current_text_angle ); - - // Enter the graphic text info - m_canvas->SetIgnoreMouseEvents( true ); - EditSymbolText( NULL, text ); - - m_canvas->SetIgnoreMouseEvents( false ); - m_canvas->MoveCursorToCrossHair(); - - if( text->GetText().IsEmpty() ) - { - delete text; - item = NULL; - } - else - { - item = text; - } - } + // Moved to modern toolset break; default: @@ -203,10 +182,10 @@ LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC ) item->SetFillMode( m_drawFillStyle ); } - if( m_drawSpecificUnit ) + if( m_DrawSpecificUnit ) item->SetUnit( m_unit ); - if( m_drawSpecificConvert ) + if( m_DrawSpecificConvert ) item->SetConvert( m_convert ); // Draw initial symbol: diff --git a/eeschema/libedit/symbedit.cpp b/eeschema/libedit/symbedit.cpp index 5d664c9bde..0949eca0fd 100644 --- a/eeschema/libedit/symbedit.cpp +++ b/eeschema/libedit/symbedit.cpp @@ -23,11 +23,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file symbedit.cpp - * @brief Functions to load and save individual symbols. - */ - #include #include #include @@ -35,14 +30,14 @@ #include #include #include - +#include #include #include #include #include #include #include - +#include void LIB_EDIT_FRAME::LoadOneSymbol() { @@ -211,22 +206,147 @@ void LIB_EDIT_FRAME::SaveOneSymbol() } -void LIB_EDIT_FRAME::PlaceAnchor() +// helper function to sort pins by pin num +bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst ) { - if( LIB_PART* part = GetCurPart() ) - { - const wxPoint& cross_hair = GetCrossHairPosition(); + // Use number as primary key + int test = ref->GetNumber().Cmp( tst->GetNumber() ); - wxPoint offset( -cross_hair.x, cross_hair.y ); - part->SetOffset( offset ); - OnModify(); + // Use DeMorgan variant as secondary key + if( test == 0 ) + test = ref->GetConvert() - tst->GetConvert(); - // Refresh the view without changing the viewport - auto view = GetGalCanvas()->GetView(); - auto center = view->GetCenter(); - center.x += offset.x; - center.y -= offset.y; - view->SetCenter( center ); - view->RecacheAllItems(); - } + // Use unit as tertiary key + if( test == 0 ) + test = ref->GetUnit() - tst->GetUnit(); + + return test < 0; +} + + +void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event ) +{ + LIB_PART* part = GetCurPart(); + + if( !part ) + return; + + wxRealPoint curr_grid_size = GetScreen()->GetGridSize(); + const int min_grid_size = 25; + const int grid_size = KiROUND( curr_grid_size.x ); + const int clamped_grid_size = ( grid_size < min_grid_size ) ? min_grid_size : grid_size; + + LIB_PINS pinList; + + part->GetPins( pinList ); + + if( pinList.size() == 0 ) + { + DisplayInfoMessage( this, _( "No pins!" ) ); + return; + } + + // Sort pins by pin num, so 2 duplicate pins + // (pins with the same number) will be consecutive in list + sort( pinList.begin(), pinList.end(), sort_by_pin_number ); + + // Test for duplicates: + DIALOG_DISPLAY_HTML_TEXT_BASE error_display( this, wxID_ANY, + _( "Marker Information" ), + wxDefaultPosition, + wxSize( 750, 600 ) ); + + int dup_error = 0; + + for( unsigned ii = 1; ii < pinList.size(); ii++ ) + { + LIB_PIN* curr_pin = pinList[ii]; + LIB_PIN* pin = pinList[ii - 1]; + + if( pin->GetNumber() != curr_pin->GetNumber() + || pin->GetConvert() != curr_pin->GetConvert() ) + continue; + + dup_error++; + + /* TODO I dare someone to find a way to make happy translators on + this thing! Lorenzo */ + + wxString msg = wxString::Format( _( + "Duplicate pin %s \"%s\" at location (%.3f, %.3f)" + " conflicts with pin %s \"%s\" at location (%.3f, %.3f)" ), + GetChars( curr_pin->GetNumber() ), + GetChars( curr_pin->GetName() ), + curr_pin->GetPosition().x / 1000.0, + -curr_pin->GetPosition().y / 1000.0, + GetChars( pin->GetNumber() ), + GetChars( pin->GetName() ), + pin->GetPosition().x / 1000.0, + -pin->GetPosition().y / 1000.0 + ); + + if( part->GetUnitCount() > 1 ) + { + msg += wxString::Format( _( " in units %c and %c" ), + 'A' + curr_pin->GetUnit() - 1, + 'A' + pin->GetUnit() - 1 ); + } + + if( m_showDeMorgan ) + { + if( curr_pin->GetConvert() ) + msg += _( " of converted" ); + else + msg += _( " of normal" ); + } + + msg += wxT( ".
" ); + + error_display.m_htmlWindow->AppendToPage( msg ); + } + + // Test for off grid pins: + int offgrid_error = 0; + + for( unsigned ii = 0; ii < pinList.size(); ii++ ) + { + LIB_PIN* pin = pinList[ii]; + + if( ( (pin->GetPosition().x % clamped_grid_size) == 0 ) && + ( (pin->GetPosition().y % clamped_grid_size) == 0 ) ) + continue; + + // "pin" is off grid here. + offgrid_error++; + + wxString msg = wxString::Format( _( + "Off grid pin %s \"%s\" at location (%.3f, %.3f)" ), + GetChars( pin->GetNumber() ), + GetChars( pin->GetName() ), + pin->GetPosition().x / 1000.0, + -pin->GetPosition().y / 1000.0 + ); + + if( part->GetUnitCount() > 1 ) + { + msg += wxString::Format( _( " in symbol %c" ), 'A' + pin->GetUnit() - 1 ); + } + + if( m_showDeMorgan ) + { + if( pin->GetConvert() ) + msg += _( " of converted" ); + else + msg += _( " of normal" ); + } + + msg += wxT( ".
" ); + + error_display.m_htmlWindow->AppendToPage( msg ); + } + + if( !dup_error && !offgrid_error ) + DisplayInfoMessage( this, _( "No off grid or duplicate pins were found." ) ); + else + error_display.ShowModal(); } diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 148942e10e..ce0dd529b6 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include #include #include @@ -429,7 +429,7 @@ void SCH_EDIT_FRAME::setupTools() m_toolManager->RegisterTool( new ZOOM_TOOL ); m_toolManager->RegisterTool( new SCH_SELECTION_TOOL ); m_toolManager->RegisterTool( new SCH_PICKER_TOOL ); - m_toolManager->RegisterTool( new SCH_DRAWING_TOOL ); + m_toolManager->RegisterTool( new SCH_DRAWING_TOOLS ); m_toolManager->RegisterTool( new SCH_WIRE_BUS_TOOL ); m_toolManager->RegisterTool( new SCH_MOVE_TOOL ); m_toolManager->RegisterTool( new SCH_EDIT_TOOL ); diff --git a/eeschema/sch_screen.h b/eeschema/sch_screen.h index 1696f6cc56..ceca931af7 100644 --- a/eeschema/sch_screen.h +++ b/eeschema/sch_screen.h @@ -43,8 +43,6 @@ #include #include -#include <../eeschema/general.h> - class LIB_PIN; class SCH_COMPONENT; diff --git a/eeschema/tools/lib_drawing_tools.cpp b/eeschema/tools/lib_drawing_tools.cpp new file mode 100644 index 0000000000..07837dd618 --- /dev/null +++ b/eeschema/tools/lib_drawing_tools.cpp @@ -0,0 +1,347 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019 KiCad Developers, see AUTHORS.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 + */ + +#include "lib_drawing_tools.h" +#include "lib_pin_tool.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Drawing tool actions +TOOL_ACTION SCH_ACTIONS::placeSymbolPin( "libedit.InteractiveDrawing.placeSymbolPin", + AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LIBEDIT_CREATE_PIN ), + _( "Add Pin" ), _( "Add a pin" ), + pin_xpm, AF_ACTIVATE ); + +TOOL_ACTION SCH_ACTIONS::placeSymbolText( "libedit.InteractiveDrawing.placeSymbolText", + AS_GLOBAL, 0, + _( "Add Text" ), _( "Add a text item" ), + text_xpm, AF_ACTIVATE ); + +TOOL_ACTION SCH_ACTIONS::drawSymbolRectangle( "libedit.InteractiveDrawing.drawSymbolRectangle", + AS_GLOBAL, 0, + _( "Add Rectangle" ), _( "Add a rectangle" ), + add_rectangle_xpm, AF_ACTIVATE ); + +TOOL_ACTION SCH_ACTIONS::drawSymbolCircle( "libedit.InteractiveDrawing.drawSymbolCircle", + AS_GLOBAL, 0, + _( "Add Circle" ), _( "Add a circle" ), + add_circle_xpm, AF_ACTIVATE ); + +TOOL_ACTION SCH_ACTIONS::drawSymbolArc( "libedit.InteractiveDrawing.drawSymbolArc", + AS_GLOBAL, 0, + _( "Add Arc" ), _( "Add an arc" ), + add_circle_xpm, AF_ACTIVATE ); + +TOOL_ACTION SCH_ACTIONS::drawSymbolLines( "libedit.InteractiveDrawing.drawSymbolLines", + AS_GLOBAL, 0, + _( "Add Lines" ), _( "Add connected graphic lines" ), + add_circle_xpm, AF_ACTIVATE ); + +TOOL_ACTION SCH_ACTIONS::placeSymbolAnchor( "libedit.InteractiveDrawing.placeSymbolAnchor", + AS_GLOBAL, 0, + _( "Move symbol anchor" ), _( "Specify a new location for the symobl anchor" ), + anchor_xpm, AF_ACTIVATE ); + + +LIB_DRAWING_TOOLS::LIB_DRAWING_TOOLS() : + TOOL_INTERACTIVE( "libedit.InteractiveDrawing" ), + m_selectionTool( nullptr ), + m_view( nullptr ), + m_controls( nullptr ), + m_frame( nullptr ), + m_menu( *this ) +{ +} + + +LIB_DRAWING_TOOLS::~LIB_DRAWING_TOOLS() +{ +} + + +bool LIB_DRAWING_TOOLS::Init() +{ + m_frame = getEditFrame(); + m_selectionTool = m_toolMgr->GetTool(); + + auto activeTool = [ this ] ( const SELECTION& aSel ) { + return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED ); + }; + + auto& ctxMenu = m_menu.GetMenu(); + + // + // Build the drawing tool menu + // + ctxMenu.AddItem( ACTIONS::cancelInteractive, activeTool, 1 ); + + ctxMenu.AddSeparator( activeTool, 1000 ); + m_menu.AddStandardSubMenus( m_frame ); + + return true; +} + + +void LIB_DRAWING_TOOLS::Reset( RESET_REASON aReason ) +{ + // Init variables used by every drawing tool + m_view = static_cast( getView() ); + m_controls = getViewControls(); + m_frame = getEditFrame(); +} + + +int LIB_DRAWING_TOOLS::PlacePin( const TOOL_EVENT& aEvent ) +{ + m_frame->SetToolID( ID_LIBEDIT_PIN_BUTT, wxCURSOR_PENCIL, _( "Add pin" ) ); + return doTwoClickPlace( LIB_PIN_T ); +} + + +int LIB_DRAWING_TOOLS::PlaceText( const TOOL_EVENT& aEvent ) +{ + m_frame->SetToolID( ID_LIBEDIT_BODY_TEXT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) ); + return doTwoClickPlace( LIB_TEXT_T ); +} + + +int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType ) +{ + VECTOR2I cursorPos = m_controls->GetCursorPosition(); + EDA_ITEM* item = nullptr; + + m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); + m_controls->ShowCursor( true ); + + Activate(); + + // Main loop: keep receiving events + while( OPT_TOOL_EVENT evt = Wait() ) + { + cursorPos = m_controls->GetCursorPosition( !evt->Modifier( MD_ALT ) ); + + if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) ) + { + if( item ) + { + m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); + m_view->ClearPreview(); + delete item; + item = nullptr; + + if( !evt->IsActivate() ) + continue; + } + + break; + } + else if( evt->IsClick( BUT_LEFT ) ) + { + LIB_PART* part = m_frame->GetCurPart(); + + if( !part ) + continue; + + // First click creates... + if( !item ) + { + m_frame->GetCanvas()->SetIgnoreMouseEvents( true ); + + switch( aType ) + { + case LIB_PIN_T: + { + LIB_PIN_TOOL* pinTool = m_toolMgr->GetTool(); + + item = pinTool->CreatePin( wxPoint( cursorPos.x, -cursorPos.y), part ); + break; + } + case LIB_TEXT_T: + { + LIB_TEXT* text = new LIB_TEXT( part ); + text->SetPosition( wxPoint( cursorPos.x, -cursorPos.y) ); + text->SetTextSize( wxSize( m_frame->g_LastTextSize, m_frame->g_LastTextSize ) ); + text->SetTextAngle( m_frame->g_LastTextAngle ); + + DIALOG_LIB_EDIT_TEXT dlg( m_frame, text ); + + if( dlg.ShowModal() != wxID_OK ) + delete text; + else + item = text; + + break; + } + + default: + wxFAIL_MSG( "doTwoClickPlace(): unknown type" ); + } + + m_frame->GetCanvas()->SetIgnoreMouseEvents( false ); + + // Restore cursor after dialog + m_frame->GetCanvas()->MoveCursorToCrossHair(); + + if( item ) + { + item->SetFlags( IS_NEW | IS_MOVED ); + m_view->ClearPreview(); + m_view->AddToPreview( item->Clone() ); + m_selectionTool->AddItemToSel( item ); + } + + m_controls->SetCursorPosition( cursorPos, false ); + } + + // ... and second click places: + else + { + m_frame->SaveCopyInUndoList( part ); + + part->AddDrawItem( (LIB_ITEM*) item ); + item->ClearFlags( item->GetEditFlags() ); + + m_frame->SetDrawItem( nullptr ); + item = nullptr; + m_view->ClearPreview(); + + m_frame->RebuildView(); + m_frame->OnModify(); + } + } + else if( evt->IsClick( BUT_RIGHT ) ) + { + // Warp after context menu only if dragging... + if( !item ) + m_toolMgr->VetoContextMenuMouseWarp(); + + m_menu.ShowContextMenu( m_selectionTool->GetSelection() ); + } + else if( TOOL_EVT_UTILS::IsSelectionEvent( evt.get() ) ) + { + // This happens if our text was replaced out from under us by ConvertTextType() + SELECTION& selection = m_selectionTool->GetSelection(); + + if( selection.GetSize() == 1 ) + { + item = (LIB_ITEM*) selection.Front(); + m_view->ClearPreview(); + m_view->AddToPreview( item->Clone() ); + } + else + item = nullptr; + } + else if( item && ( evt->IsAction( &SCH_ACTIONS::refreshPreview ) || evt->IsMotion() ) ) + { + static_cast( item )->SetPosition( wxPoint( cursorPos.x, -cursorPos.y) ); + m_view->ClearPreview(); + m_view->AddToPreview( item->Clone() ); + } + + // Enable autopanning and cursor capture only when there is a module to be placed + m_controls->SetAutoPan( !!item ); + m_controls->CaptureCursor( !!item ); + } + + m_frame->SetNoToolSelected(); + + return 0; +} + + +int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent ) +{ + m_frame->SetToolID( ID_LIBEDIT_ANCHOR_ITEM_BUTT, wxCURSOR_PENCIL, _( "Move symbol anchor" ) ); + + m_controls->ShowCursor( true ); + m_controls->SetSnapping( true ); + + Activate(); + + // Main loop: keep receiving events + while( OPT_TOOL_EVENT evt = Wait() ) + { + if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) ) + { + break; + } + else if( evt->IsClick( BUT_LEFT ) ) + { + LIB_PART* part = m_frame->GetCurPart(); + + if( !part ) + continue; + + VECTOR2I cursorPos = m_controls->GetCursorPosition( !evt->Modifier( MD_ALT ) ); + wxPoint offset( -cursorPos.x, cursorPos.y ); + + part->SetOffset( offset ); + + // Refresh the view without changing the viewport + auto center = m_view->GetCenter(); + center.x += offset.x; + center.y -= offset.y; + m_view->SetCenter( center ); + m_view->RecacheAllItems(); + m_frame->OnModify(); + } + else if( evt->IsClick( BUT_RIGHT ) ) + { + SELECTION emptySelection; + + m_menu.ShowContextMenu( emptySelection ); + } + } + + m_frame->SetNoToolSelected(); + + return 0; +} + + +void LIB_DRAWING_TOOLS::setTransitions() +{ + Go( &LIB_DRAWING_TOOLS::PlacePin, SCH_ACTIONS::placeSymbolPin.MakeEvent() ); + Go( &LIB_DRAWING_TOOLS::PlaceText, SCH_ACTIONS::placeSymbolText.MakeEvent() ); +// Go( &LIB_DRAWING_TOOLS::DrawRectangle, SCH_ACTIONS::drawSymbolRectangle.MakeEvent() ); +// Go( &LIB_DRAWING_TOOLS::DrawCircle, SCH_ACTIONS::drawSymbolCircle.MakeEvent() ); +// Go( &LIB_DRAWING_TOOLS::DrawArc, SCH_ACTIONS::drawSymbolArc.MakeEvent() ); +// Go( &LIB_DRAWING_TOOLS::DrawLines, SCH_ACTIONS::drawSymbolLines.MakeEvent() ); + Go( &LIB_DRAWING_TOOLS::PlaceAnchor, SCH_ACTIONS::placeSymbolAnchor.MakeEvent() ); +} diff --git a/eeschema/tools/lib_drawing_tools.h b/eeschema/tools/lib_drawing_tools.h new file mode 100644 index 0000000000..5a10054557 --- /dev/null +++ b/eeschema/tools/lib_drawing_tools.h @@ -0,0 +1,86 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019 KiCad Developers, see AUTHORS.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 + */ + +#ifndef LIB_DRAWING_TOOLS_H +#define LIB_DRAWING_TOOLS_H + +#include +#include +#include +#include + + +class LIB_EDIT_FRAME; +class SCH_SELECTION_TOOL; + + +/** + * Class LIB_DRAWING_TOOLS + * + * Tool responsible for drawing/placing items (body outlines, pins, etc.) + */ + +class LIB_DRAWING_TOOLS : public TOOL_INTERACTIVE +{ +public: + LIB_DRAWING_TOOLS(); + ~LIB_DRAWING_TOOLS(); + + /// @copydoc TOOL_INTERACTIVE::Init() + bool Init() override; + + /// @copydoc TOOL_INTERACTIVE::Reset() + void Reset( RESET_REASON aReason ) override; + + ///> Get the SCH_DRAWING_TOOL top-level context menu + inline TOOL_MENU& GetToolMenu() { return m_menu; } + + int PlacePin( const TOOL_EVENT& aEvent ); + int PlaceText( const TOOL_EVENT& aEvent ); + int DrawRectangle( const TOOL_EVENT& aEvent ); + int DrawCircle( const TOOL_EVENT& aEvent ); + int DrawArc( const TOOL_EVENT& aEvent ); + int DrawLines( const TOOL_EVENT& aEvent ); + int PlaceAnchor( const TOOL_EVENT& aEvent ); + +private: + + void createPin(); + + int doTwoClickPlace( KICAD_T aType ); + + int doSingleClickPlace( KICAD_T aType ); + + ///> Sets up handlers for various events. + void setTransitions() override; + +private: + SCH_SELECTION_TOOL* m_selectionTool; + KIGFX::SCH_VIEW* m_view; + KIGFX::VIEW_CONTROLS* m_controls; + LIB_EDIT_FRAME* m_frame; + + TOOL_MENU m_menu; +}; + +#endif /* LIB_DRAWING_TOOLS_H */ diff --git a/eeschema/libedit/pinedit.cpp b/eeschema/tools/lib_pin_tool.cpp similarity index 62% rename from eeschema/libedit/pinedit.cpp rename to eeschema/tools/lib_pin_tool.cpp index 2c138831f5..8d72f9b4c7 100644 --- a/eeschema/libedit/pinedit.cpp +++ b/eeschema/tools/lib_pin_tool.cpp @@ -1,9 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2008-2011 Wayne Stambaugh - * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019 KiCad Developers, see AUTHORS.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 @@ -23,74 +21,91 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file pinedit.cpp - * @brief Eeschema pin edit code. - */ - -#include -#include -#include -#include -#include -#include - +#include +#include #include #include -#include -#include -#include #include - -#include <../common/dialogs/dialog_display_info_HTML_base.h> -#include - #include - -extern void IncrementLabelMember( wxString& name, int aIncrement ); +#include +#include +#include "lib_pin_tool.h" -static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC ); -static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositon, bool aErase ); - - -static wxPoint OldPos; -static ELECTRICAL_PINTYPE LastPinType = PIN_INPUT; -static int LastPinOrient = PIN_RIGHT; -static GRAPHIC_PINSHAPE LastPinShape = PINSHAPE_LINE; -static bool LastPinCommonConvert = false; -static bool LastPinCommonUnit = false; -static bool LastPinVisible = true; +static ELECTRICAL_PINTYPE g_LastPinType = PIN_INPUT; +static int g_LastPinOrient = PIN_RIGHT; +static GRAPHIC_PINSHAPE g_LastPinShape = PINSHAPE_LINE; +static bool g_LastPinCommonConvert = false; +static bool g_LastPinCommonUnit = false; +static bool g_LastPinVisible = true; // The -1 is a non-valid value to trigger delayed initialization -static int LastPinLength = -1; -static int LastPinNameSize = -1; -static int LastPinNumSize = -1; +static int g_LastPinLength = -1; +static int g_LastPinNameSize = -1; +static int g_LastPinNumSize = -1; static int GetLastPinLength() { - if( LastPinLength == -1 ) - LastPinLength = LIB_EDIT_FRAME::GetDefaultPinLength(); + if( g_LastPinLength == -1 ) + g_LastPinLength = LIB_EDIT_FRAME::GetDefaultPinLength(); - return LastPinLength; + return g_LastPinLength; } static int GetLastPinNameSize() { - if( LastPinNameSize == -1 ) - LastPinNameSize = LIB_EDIT_FRAME::GetPinNameDefaultSize(); + if( g_LastPinNameSize == -1 ) + g_LastPinNameSize = LIB_EDIT_FRAME::GetPinNameDefaultSize(); - return LastPinNameSize; + return g_LastPinNameSize; } static int GetLastPinNumSize() { - if( LastPinNumSize == -1 ) - LastPinNumSize = LIB_EDIT_FRAME::GetPinNumDefaultSize(); + if( g_LastPinNumSize == -1 ) + g_LastPinNumSize = LIB_EDIT_FRAME::GetPinNumDefaultSize(); - return LastPinNumSize; + return g_LastPinNumSize; } + +extern void IncrementLabelMember( wxString& name, int aIncrement ); + + +LIB_PIN_TOOL::LIB_PIN_TOOL() : + TOOL_INTERACTIVE( "eeschema.PinEditing" ), + m_selectionTool( nullptr ), + m_frame( nullptr ) +{ +} + + +LIB_PIN_TOOL::~LIB_PIN_TOOL() +{ +} + + +bool LIB_PIN_TOOL::Init() +{ + m_frame = getEditFrame(); + m_selectionTool = m_toolMgr->GetTool(); + + wxASSERT_MSG( m_selectionTool, "eeshema.InteractiveSelection tool is not available" ); + + return true; +} + + +void LIB_PIN_TOOL::Reset( RESET_REASON aReason ) +{ + if( aReason == MODEL_RELOAD ) + { + // Init variables used by every drawing tool + m_frame = getEditFrame(); + } +} + + void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) { if( GetDrawItem() == NULL || GetDrawItem()->Type() != LIB_PIN_T ) @@ -131,17 +146,18 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) pin->SetFlags( item_flags ); // Save the pin properties to use for the next new pin. - LastPinNameSize = pin->GetNameTextSize(); - LastPinNumSize = pin->GetNumberTextSize(); - LastPinOrient = pin->GetOrientation(); - LastPinLength = pin->GetLength(); - LastPinShape = pin->GetShape(); - LastPinType = pin->GetType(); - LastPinCommonConvert = pin->GetConvert() == 0; - LastPinCommonUnit = pin->GetUnit() == 0; - LastPinVisible = pin->IsVisible(); + g_LastPinNameSize = pin->GetNameTextSize(); + g_LastPinNumSize = pin->GetNumberTextSize(); + g_LastPinOrient = pin->GetOrientation(); + g_LastPinLength = pin->GetLength(); + g_LastPinShape = pin->GetShape(); + g_LastPinType = pin->GetType(); + g_LastPinCommonConvert = pin->GetConvert() == 0; + g_LastPinCommonUnit = pin->GetUnit() == 0; + g_LastPinVisible = pin->IsVisible(); } + /** * Clean up after aborting a move pin command. */ @@ -150,7 +166,6 @@ static void AbortPinMove( EDA_DRAW_PANEL* aPanel, wxDC* DC ) LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent(); auto panel = static_cast( aPanel ); - if( parent == NULL ) return; @@ -246,9 +261,9 @@ void LIB_EDIT_FRAME::PlacePin() if( cur_pin->IsNew() ) { - LastPinOrient = cur_pin->GetOrientation(); - LastPinType = cur_pin->GetType(); - LastPinShape = cur_pin->GetShape(); + g_LastPinOrient = cur_pin->GetOrientation(); + g_LastPinType = cur_pin->GetType(); + g_LastPinShape = cur_pin->GetShape(); if( SynchronizePins() ) CreateImagePins( cur_pin ); @@ -275,6 +290,34 @@ void LIB_EDIT_FRAME::PlacePin() } +/* Move pin to the current mouse position. This function is called by the + * cursor management code. */ +static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, + bool aErase ) +{ + LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent(); + + if( parent == NULL ) + return; + + LIB_PIN* cur_pin = (LIB_PIN*) parent->GetDrawItem(); + + if( cur_pin == NULL || cur_pin->Type() != LIB_PIN_T ) + return; + + auto p = aPanel->GetParent()->GetCrossHairPosition( true ); + + // Redraw pin in new position + cur_pin->Move(p); + + KIGFX::SCH_VIEW* view = parent->GetCanvas()->GetView(); + + view->Hide( cur_pin ); + view->ClearPreview(); + view->AddToPreview( cur_pin->Clone() ); +} + + void LIB_EDIT_FRAME::StartMovePin( LIB_ITEM* aItem ) { LIB_PIN* cur_pin = (LIB_PIN*) aItem; @@ -314,84 +357,42 @@ void LIB_EDIT_FRAME::StartMovePin( LIB_ITEM* aItem ) } -/* Move pin to the current mouse position. This function is called by the - * cursor management code. */ -static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, - bool aErase ) -{ - LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent(); - - if( parent == NULL ) - return; - - LIB_PIN* cur_pin = (LIB_PIN*) parent->GetDrawItem(); - - if( cur_pin == NULL || cur_pin->Type() != LIB_PIN_T ) - return; - - auto p = aPanel->GetParent()->GetCrossHairPosition( true ); - - // Redraw pin in new position - cur_pin->Move(p); - - auto view = parent->GetCanvas()->GetView(); - - view->Hide( cur_pin ); - view->ClearPreview(); - view->AddToPreview( cur_pin->Clone() ); -} - - /* * Create a new pin. */ -void LIB_EDIT_FRAME::CreatePin( wxDC* DC ) +LIB_PIN* LIB_PIN_TOOL::CreatePin( const VECTOR2I& aPosition, LIB_PART* aPart ) { - LIB_PART* part = GetCurPart(); + aPart->ClearStatus(); - if( !part ) - return; - - part->ClearStatus(); - - LIB_PIN* pin = new LIB_PIN( part ); - - SetDrawItem( pin ); + LIB_PIN* pin = new LIB_PIN( aPart ); pin->SetFlags( IS_NEW ); - pin->SetUnit( m_unit ); - pin->SetConvert( m_convert ); // Flag pins to consider - if( SynchronizePins() ) + if( m_frame->SynchronizePins() ) pin->SetFlags( IS_LINKED ); - pin->Move( GetCrossHairPosition( ) ); + pin->Move( (wxPoint) aPosition ); pin->SetLength( GetLastPinLength() ); - pin->SetOrientation( LastPinOrient ); - pin->SetType( LastPinType ); - pin->SetShape( LastPinShape ); + pin->SetOrientation( g_LastPinOrient ); + pin->SetType( g_LastPinType ); + pin->SetShape( g_LastPinShape ); pin->SetNameTextSize( GetLastPinNameSize() ); pin->SetNumberTextSize( GetLastPinNumSize() ); - pin->SetConvert( LastPinCommonConvert ? 0 : m_convert ); - pin->SetUnit( LastPinCommonUnit ? 0 : m_unit ); - pin->SetVisible( LastPinVisible ); - m_canvas->SetIgnoreMouseEvents( true ); + pin->SetConvert( g_LastPinCommonConvert ? 0 : m_frame->GetConvert() ); + pin->SetUnit( g_LastPinCommonUnit ? 0 : m_frame->GetUnit() ); + pin->SetVisible( g_LastPinVisible ); + wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); - cmd.SetId( ID_LIBEDIT_EDIT_PIN ); - GetEventHandler()->ProcessEvent( cmd ); - m_canvas->MoveCursorToCrossHair(); - m_canvas->SetIgnoreMouseEvents( false ); + m_frame->OnEditPin( cmd ); if( pin->GetFlags() & IS_CANCELLED ) { - deleteItem( DC, pin ); - } - else - { - ClearTempCopyComponent(); - m_canvas->SetMouseCapture( DrawMovePin, AbortPinMove ); + delete pin; + pin = nullptr; } + + return pin; } @@ -513,21 +514,10 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin ) switch( pin->GetOrientation() ) { - case PIN_UP: - step.x = GetRepeatPinStep(); - break; - - case PIN_DOWN: - step.x = GetRepeatPinStep(); - break; - - case PIN_LEFT: - step.y = - GetRepeatPinStep(); - break; - - case PIN_RIGHT: - step.y = - GetRepeatPinStep(); - break; + case PIN_UP: step.x = GetRepeatPinStep(); break; + case PIN_DOWN: step.x = GetRepeatPinStep(); break; + case PIN_LEFT: step.y = -GetRepeatPinStep(); break; + case PIN_RIGHT: step.y = -GetRepeatPinStep(); break; } pin->Move( pin->GetPosition() + step ); @@ -568,148 +558,3 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin ) } -// helper function to sort pins by pin num -bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst ) -{ - int test = ref->GetNumber().Cmp( tst->GetNumber() ); - - if( test == 0 ) - { - test = ref->GetConvert() - tst->GetConvert(); - } - - if( test == 0 ) - { - test = ref->GetUnit() - tst->GetUnit(); - } - - return test < 0; -} - - -void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event ) -{ - LIB_PART* part = GetCurPart(); - - if( !part ) - return; - - wxRealPoint curr_grid_size = GetScreen()->GetGridSize(); - const int min_grid_size = 25; - const int grid_size = KiROUND( curr_grid_size.x ); - const int clamped_grid_size = ( grid_size < min_grid_size ) ? min_grid_size : grid_size; - - LIB_PINS pinList; - - part->GetPins( pinList ); - - if( pinList.size() == 0 ) - { - DisplayInfoMessage( this, _( "No pins!" ) ); - return; - } - - // Sort pins by pin num, so 2 duplicate pins - // (pins with the same number) will be consecutive in list - sort( pinList.begin(), pinList.end(), sort_by_pin_number ); - - // Test for duplicates: - DIALOG_DISPLAY_HTML_TEXT_BASE error_display( this, wxID_ANY, - _( "Marker Information" ), - wxDefaultPosition, - wxSize( 750, 600 ) ); - - int dup_error = 0; - - for( unsigned ii = 1; ii < pinList.size(); ii++ ) - { - LIB_PIN* curr_pin = pinList[ii]; - LIB_PIN* pin = pinList[ii - 1]; - - if( pin->GetNumber() != curr_pin->GetNumber() - || pin->GetConvert() != curr_pin->GetConvert() ) - continue; - - dup_error++; - - /* TODO I dare someone to find a way to make happy translators on - this thing! Lorenzo */ - - wxString msg = wxString::Format( _( - "Duplicate pin %s \"%s\" at location (%.3f, %.3f)" - " conflicts with pin %s \"%s\" at location (%.3f, %.3f)" ), - GetChars( curr_pin->GetNumber() ), - GetChars( curr_pin->GetName() ), - curr_pin->GetPosition().x / 1000.0, - -curr_pin->GetPosition().y / 1000.0, - GetChars( pin->GetNumber() ), - GetChars( pin->GetName() ), - pin->GetPosition().x / 1000.0, - -pin->GetPosition().y / 1000.0 - ); - - if( part->GetUnitCount() > 1 ) - { - msg += wxString::Format( _( " in units %c and %c" ), - 'A' + curr_pin->GetUnit() - 1, - 'A' + pin->GetUnit() - 1 ); - } - - if( m_showDeMorgan ) - { - if( curr_pin->GetConvert() ) - msg += _( " of converted" ); - else - msg += _( " of normal" ); - } - - msg += wxT( ".
" ); - - error_display.m_htmlWindow->AppendToPage( msg ); - } - - // Test for off grid pins: - int offgrid_error = 0; - - for( unsigned ii = 0; ii < pinList.size(); ii++ ) - { - LIB_PIN* pin = pinList[ii]; - - if( ( (pin->GetPosition().x % clamped_grid_size) == 0 ) && - ( (pin->GetPosition().y % clamped_grid_size) == 0 ) ) - continue; - - // "pin" is off grid here. - offgrid_error++; - - wxString msg = wxString::Format( _( - "Off grid pin %s \"%s\" at location (%.3f, %.3f)" ), - GetChars( pin->GetNumber() ), - GetChars( pin->GetName() ), - pin->GetPosition().x / 1000.0, - -pin->GetPosition().y / 1000.0 - ); - - if( part->GetUnitCount() > 1 ) - { - msg += wxString::Format( _( " in symbol %c" ), 'A' + pin->GetUnit() - 1 ); - } - - if( m_showDeMorgan ) - { - if( pin->GetConvert() ) - msg += _( " of converted" ); - else - msg += _( " of normal" ); - } - - msg += wxT( ".
" ); - - error_display.m_htmlWindow->AppendToPage( msg ); - } - - if( !dup_error && !offgrid_error ) - DisplayInfoMessage( this, _( "No off grid or duplicate pins were found." ) ); - else - error_display.ShowModal(); -} diff --git a/eeschema/tools/lib_pin_tool.h b/eeschema/tools/lib_pin_tool.h new file mode 100644 index 0000000000..d0bebb5e93 --- /dev/null +++ b/eeschema/tools/lib_pin_tool.h @@ -0,0 +1,59 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019 KiCad Developers, see AUTHORS.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 + */ + +#ifndef KICAD_LIB_PIN_TOOL_H +#define KICAD_LIB_PIN_TOOL_H + +#include +#include +#include + + +class LIB_EDIT_FRAME; +class SCH_SELECTION_TOOL; + + +class LIB_PIN_TOOL : public TOOL_INTERACTIVE +{ +public: + LIB_PIN_TOOL(); + ~LIB_PIN_TOOL(); + + /// @copydoc TOOL_INTERACTIVE::Init() + bool Init() override; + + /// @copydoc TOOL_INTERACTIVE::Reset() + void Reset( RESET_REASON aReason ) override; + + LIB_PIN* CreatePin( const VECTOR2I& aPosition, LIB_PART* aPart ); + +private: + ///> Sets up handlers for various events. + void setTransitions() override { } + +private: + SCH_SELECTION_TOOL* m_selectionTool; + LIB_EDIT_FRAME* m_frame; +}; + +#endif //KICAD_LIB_PIN_TOOL_H diff --git a/eeschema/tools/sch_actions.cpp b/eeschema/tools/sch_actions.cpp index 6ca626a2f9..62f70fbad9 100644 --- a/eeschema/tools/sch_actions.cpp +++ b/eeschema/tools/sch_actions.cpp @@ -213,6 +213,15 @@ OPT SCH_ACTIONS::TranslateLegacyId( int aId ) case ID_MOUSE_DOUBLECLICK: return SCH_ACTIONS::cursorDblClick.MakeEvent(); + + case ID_LIBEDIT_PIN_BUTT: + return SCH_ACTIONS::placeSymbolPin.MakeEvent(); + + case ID_LIBEDIT_BODY_TEXT_BUTT: + return SCH_ACTIONS::placeSymbolText.MakeEvent(); + + case ID_LIBEDIT_ANCHOR_ITEM_BUTT: + return SCH_ACTIONS::placeSymbolAnchor.MakeEvent(); } return OPT(); diff --git a/eeschema/tools/sch_actions.h b/eeschema/tools/sch_actions.h index 7b6762fd4a..7e4cd099f9 100644 --- a/eeschema/tools/sch_actions.h +++ b/eeschema/tools/sch_actions.h @@ -72,7 +72,7 @@ public: static TOOL_ACTION lock; static TOOL_ACTION unlock; - // Tools + // Schematic Tools static TOOL_ACTION selectionTool; static TOOL_ACTION pickerTool; static TOOL_ACTION placeSymbol; @@ -103,6 +103,15 @@ public: static TOOL_ACTION finishLine; static TOOL_ACTION finishSheet; + // Symbol Tools + static TOOL_ACTION placeSymbolPin; + static TOOL_ACTION placeSymbolText; + static TOOL_ACTION drawSymbolRectangle; + static TOOL_ACTION drawSymbolCircle; + static TOOL_ACTION drawSymbolArc; + static TOOL_ACTION drawSymbolLines; + static TOOL_ACTION placeSymbolAnchor; + // Editing static TOOL_ACTION move; static TOOL_ACTION drag; diff --git a/eeschema/tools/sch_drawing_tool.cpp b/eeschema/tools/sch_drawing_tools.cpp similarity index 89% rename from eeschema/tools/sch_drawing_tool.cpp rename to eeschema/tools/sch_drawing_tools.cpp index 1ee6a97961..836767c6dc 100644 --- a/eeschema/tools/sch_drawing_tool.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "sch_drawing_tool.h" +#include "sch_drawing_tools.h" #include "sch_selection_tool.h" #include @@ -140,7 +140,7 @@ TOOL_ACTION SCH_ACTIONS::addHierLabel( "eeschema.InteractiveEditing.addHierLabel add_hierarchical_label_xpm, AF_NONE ); -SCH_DRAWING_TOOL::SCH_DRAWING_TOOL() : +SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS() : TOOL_INTERACTIVE( "eeschema.InteractiveDrawing" ), m_selectionTool( nullptr ), m_view( nullptr ), @@ -151,12 +151,12 @@ SCH_DRAWING_TOOL::SCH_DRAWING_TOOL() : }; -SCH_DRAWING_TOOL::~SCH_DRAWING_TOOL() +SCH_DRAWING_TOOLS::~SCH_DRAWING_TOOLS() { } -bool SCH_DRAWING_TOOL::Init() +bool SCH_DRAWING_TOOLS::Init() { m_frame = getEditFrame(); m_selectionTool = m_toolMgr->GetTool(); @@ -184,7 +184,7 @@ bool SCH_DRAWING_TOOL::Init() } -void SCH_DRAWING_TOOL::Reset( RESET_REASON aReason ) +void SCH_DRAWING_TOOLS::Reset( RESET_REASON aReason ) { // Init variables used by every drawing tool m_view = static_cast( getView() ); @@ -193,7 +193,7 @@ void SCH_DRAWING_TOOL::Reset( RESET_REASON aReason ) } -int SCH_DRAWING_TOOL::AddJunction( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::AddJunction( const TOOL_EVENT& aEvent ) { m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); @@ -204,7 +204,7 @@ int SCH_DRAWING_TOOL::AddJunction( const TOOL_EVENT& aEvent ) } -int SCH_DRAWING_TOOL::AddLabel( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::AddLabel( const TOOL_EVENT& aEvent ) { m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); @@ -229,7 +229,7 @@ static SCH_BASE_FRAME::HISTORY_LIST s_SymbolHistoryList; static SCH_BASE_FRAME::HISTORY_LIST s_PowerHistoryList; -int SCH_DRAWING_TOOL::PlaceSymbol( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent ) { SCH_COMPONENT* component = aEvent.Parameter(); @@ -239,7 +239,7 @@ int SCH_DRAWING_TOOL::PlaceSymbol( const TOOL_EVENT& aEvent ) } -int SCH_DRAWING_TOOL::PlacePower( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::PlacePower( const TOOL_EVENT& aEvent ) { SCH_COMPONENT* component = aEvent.Parameter(); SCHLIB_FILTER filter; @@ -251,8 +251,8 @@ int SCH_DRAWING_TOOL::PlacePower( const TOOL_EVENT& aEvent ) } -int SCH_DRAWING_TOOL::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER* aFilter, - SCH_BASE_FRAME::HISTORY_LIST aHistoryList ) +int SCH_DRAWING_TOOLS::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER* aFilter, + SCH_BASE_FRAME::HISTORY_LIST aHistoryList ) { VECTOR2I cursorPos = m_controls->GetCursorPosition(); m_controls->ShowCursor( true ); @@ -377,7 +377,7 @@ int SCH_DRAWING_TOOL::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER } -int SCH_DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent ) { SCH_BITMAP* image = aEvent.Parameter(); @@ -495,35 +495,35 @@ int SCH_DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent ) } -int SCH_DRAWING_TOOL::PlaceNoConnect( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::PlaceNoConnect( const TOOL_EVENT& aEvent ) { m_frame->SetToolID( ID_NOCONN_BUTT, wxCURSOR_PENCIL, _( "Add no connect" ) ); return doSingleClickPlace( SCH_NO_CONNECT_T ); } -int SCH_DRAWING_TOOL::PlaceJunction( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::PlaceJunction( const TOOL_EVENT& aEvent ) { m_frame->SetToolID( ID_JUNCTION_BUTT, wxCURSOR_PENCIL, _( "Add junction" ) ); return doSingleClickPlace( SCH_JUNCTION_T ); } -int SCH_DRAWING_TOOL::PlaceBusWireEntry( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::PlaceBusWireEntry( const TOOL_EVENT& aEvent ) { m_frame->SetToolID( ID_WIRETOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add wire to bus entry" ) ); return doSingleClickPlace( SCH_BUS_WIRE_ENTRY_T ); } -int SCH_DRAWING_TOOL::PlaceBusBusEntry( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::PlaceBusBusEntry( const TOOL_EVENT& aEvent ) { m_frame->SetToolID( ID_BUSTOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add bus to bus entry" ) ); return doSingleClickPlace( SCH_BUS_BUS_ENTRY_T ); } -int SCH_DRAWING_TOOL::doSingleClickPlace( KICAD_T aType ) +int SCH_DRAWING_TOOLS::doSingleClickPlace( KICAD_T aType ) { m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); m_controls->ShowCursor( true ); @@ -591,49 +591,49 @@ int SCH_DRAWING_TOOL::doSingleClickPlace( KICAD_T aType ) } -int SCH_DRAWING_TOOL::PlaceLabel( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::PlaceLabel( const TOOL_EVENT& aEvent ) { m_frame->SetToolID( ID_LABEL_BUTT, wxCURSOR_PENCIL, _( "Add net label" ) ); return doTwoClickPlace( SCH_LABEL_T ); } -int SCH_DRAWING_TOOL::PlaceGlobalLabel( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::PlaceGlobalLabel( const TOOL_EVENT& aEvent ) { m_frame->SetToolID( ID_GLOBALLABEL_BUTT, wxCURSOR_PENCIL, _( "Add global label" ) ); return doTwoClickPlace( SCH_GLOBAL_LABEL_T ); } -int SCH_DRAWING_TOOL::PlaceHierarchicalLabel( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::PlaceHierarchicalLabel( const TOOL_EVENT& aEvent ) { m_frame->SetToolID( ID_HIERLABEL_BUTT, wxCURSOR_PENCIL, _( "Add hierarchical label" ) ); return doTwoClickPlace( SCH_HIER_LABEL_T ); } -int SCH_DRAWING_TOOL::PlaceSheetPin( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::PlaceSheetPin( const TOOL_EVENT& aEvent ) { m_frame->SetToolID( ID_SHEET_PIN_BUTT, wxCURSOR_PENCIL, _( "Add sheet pins" ) ); return doTwoClickPlace( SCH_SHEET_PIN_T ); } -int SCH_DRAWING_TOOL::ImportSheetPin( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::ImportSheetPin( const TOOL_EVENT& aEvent ) { m_frame->SetToolID( ID_IMPORT_HLABEL_BUTT, wxCURSOR_PENCIL, _( "Import sheet pins" ) ); return doTwoClickPlace( SCH_SHEET_PIN_T ); } -int SCH_DRAWING_TOOL::PlaceSchematicText( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::PlaceSchematicText( const TOOL_EVENT& aEvent ) { m_frame->SetToolID( ID_TEXT_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) ); return doTwoClickPlace( SCH_TEXT_T ); } -int SCH_DRAWING_TOOL::doTwoClickPlace( KICAD_T aType ) +int SCH_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType ) { VECTOR2I cursorPos = m_controls->GetCursorPosition(); EDA_ITEM* item = nullptr; @@ -765,14 +765,14 @@ int SCH_DRAWING_TOOL::doTwoClickPlace( KICAD_T aType ) } -int SCH_DRAWING_TOOL::DrawSheet( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent ) { m_frame->SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add sheet" ) ); return doDrawSheet( nullptr ); } -int SCH_DRAWING_TOOL::ResizeSheet( const TOOL_EVENT& aEvent ) +int SCH_DRAWING_TOOLS::ResizeSheet( const TOOL_EVENT& aEvent ) { SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::SheetsOnly ); @@ -788,7 +788,7 @@ int SCH_DRAWING_TOOL::ResizeSheet( const TOOL_EVENT& aEvent ) } -int SCH_DRAWING_TOOL::doDrawSheet( SCH_SHEET *aSheet ) +int SCH_DRAWING_TOOLS::doDrawSheet( SCH_SHEET *aSheet ) { m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); m_controls->ShowCursor( true ); @@ -905,7 +905,7 @@ int SCH_DRAWING_TOOL::doDrawSheet( SCH_SHEET *aSheet ) } -void SCH_DRAWING_TOOL::sizeSheet( SCH_SHEET* aSheet, VECTOR2I aPos ) +void SCH_DRAWING_TOOLS::sizeSheet( SCH_SHEET* aSheet, VECTOR2I aPos ) { wxPoint pos = aSheet->GetPosition(); wxPoint size = (wxPoint) aPos - pos; @@ -929,26 +929,26 @@ void SCH_DRAWING_TOOL::sizeSheet( SCH_SHEET* aSheet, VECTOR2I aPos ) } -void SCH_DRAWING_TOOL::setTransitions() +void SCH_DRAWING_TOOLS::setTransitions() { - Go( &SCH_DRAWING_TOOL::PlaceSymbol, SCH_ACTIONS::placeSymbol.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::PlacePower, SCH_ACTIONS::placePower.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::PlaceNoConnect, SCH_ACTIONS::placeNoConnect.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::PlaceJunction, SCH_ACTIONS::placeJunction.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::PlaceBusWireEntry, SCH_ACTIONS::placeBusWireEntry.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::PlaceBusBusEntry, SCH_ACTIONS::placeBusBusEntry.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::PlaceLabel, SCH_ACTIONS::placeLabel.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::PlaceHierarchicalLabel,SCH_ACTIONS::placeHierarchicalLabel.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::PlaceGlobalLabel, SCH_ACTIONS::placeGlobalLabel.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::DrawSheet, SCH_ACTIONS::drawSheet.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::ResizeSheet, SCH_ACTIONS::resizeSheet.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::PlaceSheetPin, SCH_ACTIONS::placeSheetPin.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::ImportSheetPin, SCH_ACTIONS::importSheetPin.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::PlaceSchematicText, SCH_ACTIONS::placeSchematicText.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::PlaceImage, SCH_ACTIONS::placeImage.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::PlaceSymbol, SCH_ACTIONS::placeSymbol.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::PlacePower, SCH_ACTIONS::placePower.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::PlaceNoConnect, SCH_ACTIONS::placeNoConnect.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::PlaceJunction, SCH_ACTIONS::placeJunction.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::PlaceBusWireEntry, SCH_ACTIONS::placeBusWireEntry.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::PlaceBusBusEntry, SCH_ACTIONS::placeBusBusEntry.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::PlaceLabel, SCH_ACTIONS::placeLabel.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::PlaceHierarchicalLabel,SCH_ACTIONS::placeHierarchicalLabel.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::PlaceGlobalLabel, SCH_ACTIONS::placeGlobalLabel.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::DrawSheet, SCH_ACTIONS::drawSheet.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::ResizeSheet, SCH_ACTIONS::resizeSheet.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::PlaceSheetPin, SCH_ACTIONS::placeSheetPin.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::ImportSheetPin, SCH_ACTIONS::importSheetPin.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::PlaceSchematicText, SCH_ACTIONS::placeSchematicText.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::PlaceImage, SCH_ACTIONS::placeImage.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::AddJunction, SCH_ACTIONS::addJunction.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::AddLabel, SCH_ACTIONS::addLabel.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::AddLabel, SCH_ACTIONS::addGlobalLabel.MakeEvent() ); - Go( &SCH_DRAWING_TOOL::AddLabel, SCH_ACTIONS::addHierLabel.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::AddJunction, SCH_ACTIONS::addJunction.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::AddLabel, SCH_ACTIONS::addLabel.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::AddLabel, SCH_ACTIONS::addGlobalLabel.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::AddLabel, SCH_ACTIONS::addHierLabel.MakeEvent() ); } diff --git a/eeschema/tools/sch_drawing_tool.h b/eeschema/tools/sch_drawing_tools.h similarity index 93% rename from eeschema/tools/sch_drawing_tool.h rename to eeschema/tools/sch_drawing_tools.h index d0575da93e..00c14fa47d 100644 --- a/eeschema/tools/sch_drawing_tool.h +++ b/eeschema/tools/sch_drawing_tools.h @@ -21,8 +21,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef SCH_DRAWING_TOOL_H -#define SCH_DRAWING_TOOL_H +#ifndef SCH_DRAWING_TOOLS_H +#define SCH_DRAWING_TOOLS_H #include #include @@ -39,16 +39,16 @@ class SCH_SELECTION_TOOL; /** - * Class SCH_DRAWING_TOOL + * Class SCH_DRAWING_TOOLS * * Tool responsible for drawing/placing items (symbols, wires, busses, labels, etc.) */ -class SCH_DRAWING_TOOL : public TOOL_INTERACTIVE +class SCH_DRAWING_TOOLS : public TOOL_INTERACTIVE { public: - SCH_DRAWING_TOOL(); - ~SCH_DRAWING_TOOL(); + SCH_DRAWING_TOOLS(); + ~SCH_DRAWING_TOOLS(); /// @copydoc TOOL_INTERACTIVE::Init() bool Init() override; @@ -102,4 +102,4 @@ private: TOOL_MENU m_menu; }; -#endif /* SCH_DRAWING_TOOL_H */ +#endif /* SCH_DRAWING_TOOLS_H */ diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 4e67307932..f4bddb7cb1 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -46,7 +46,7 @@ #include #include #include -#include "sch_drawing_tool.h" +#include "sch_drawing_tools.h" TOOL_ACTION SCH_ACTIONS::duplicate( "eeschema.InteractiveEdit.duplicate", @@ -242,7 +242,7 @@ bool SCH_EDIT_TOOL::Init() { m_frame = getEditFrame(); m_selectionTool = m_toolMgr->GetTool(); - SCH_DRAWING_TOOL* drawingTool = m_toolMgr->GetTool(); + SCH_DRAWING_TOOLS* drawingTool = m_toolMgr->GetTool(); SCH_MOVE_TOOL* moveTool = m_toolMgr->GetTool(); wxASSERT_MSG( m_selectionTool, "eeshema.InteractiveSelection tool is not available" ); diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index f4b824d584..e774efecb5 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 22d70c74a0..99be57246d 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include