diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 1ec808d1f7..7f3cfdc809 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -179,7 +179,6 @@ set( EESCHEMA_SRCS netlist_generator.cpp netlist_object_list.cpp netlist_object.cpp - onleftclick.cpp onrightclick.cpp operations_on_items_lists.cpp pin_number.cpp diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 03027b65fb..0b9fce9abb 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-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 @@ -208,37 +208,6 @@ SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibTree( } -// JEY TODO: obsolete once mover to modern toolset is complete -void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation ) -{ - SCH_SCREEN* screen = GetScreen(); - SCH_ITEM* item = screen->GetCurItem(); - SCH_COMPONENT* component = (SCH_COMPONENT*) item; - - GetCanvas()->MoveCursorToCrossHair(); - - if( item->GetEditFlags() == 0 ) - SetUndoItem( item ); - - component->SetOrientation( aOrientation ); - - m_canvas->CrossHairOn( ); - - if( item->GetEditFlags() == 0 ) - { - AddItemToScreen( item ); - SchematicCleanUp(); - } - - TestDanglingEnds(); - - RefreshItem( item ); - - if( item->GetEditFlags() == 0 ) - OnModify(); -} - - void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent ) { SCH_SCREEN* screen = GetScreen(); diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp deleted file mode 100644 index 677234260c..0000000000 --- a/eeschema/onleftclick.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 1992-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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/** - * Function OnLeftDClick - * called on a double click event from the drawpanel mouse handler - * if an editable item is found (text, component) - * Call the suitable dialog editor. - * Id a create command is in progress: - * validate and finish the command - */ -void SCH_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition ) -// JEY TODO: move to selection tool double-click handling.... -{ - SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool(); - EDA_ITEM* item = GetScreen()->GetCurItem(); - - switch( GetToolId() ) - { - case ID_NO_TOOL_SELECTED: - if( item == NULL || item->GetEditFlags() == 0 ) - item = selTool->SelectPoint( aPosition, SCH_COLLECTOR::DoubleClickItems ); - - if( item == NULL || item->GetEditFlags() != 0 ) - break; - - switch( item->Type() ) - { - case SCH_SHEET_T: - g_CurrentSheet->push_back( (SCH_SHEET*) item ); - DisplayCurrentSheet(); - break; - - case SCH_COMPONENT_T: - EditComponent( (SCH_COMPONENT*) item ); - GetCanvas()->MoveCursorToCrossHair(); - - if( item->GetEditFlags() == 0 ) - GetScreen()->SetCurItem( nullptr ); - - GetCanvas()->Refresh(); - break; - - case SCH_TEXT_T: - case SCH_LABEL_T: - case SCH_GLOBAL_LABEL_T: - case SCH_HIER_LABEL_T: - EditSchematicText( (SCH_TEXT*) item ); - break; - - case SCH_BITMAP_T: - // The bitmap is cached in Opengl: clear the cache, because - // the cache data is perhaps invalid - if( EditImage( (SCH_BITMAP*) item ) ) - GetCanvas()->GetView()->RecacheAllItems(); - - break; - - case SCH_FIELD_T: - EditComponentFieldText( (SCH_FIELD*) item ); - GetCanvas()->MoveCursorToCrossHair(); - break; - - case SCH_MARKER_T: - ( (SCH_MARKER*) item )->DisplayMarkerInfo( this ); - break; - - default: - break; - } - - break; - } -} diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index b628557fdd..aaeeeacc6c 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.cpp @@ -146,19 +146,6 @@ void SCH_BITMAP::Rotate( wxPoint aPosition ) } -bool SCH_BITMAP::IsSelectStateChanged( const wxRect& aRect ) -{ - bool previousState = IsSelected(); - - if( aRect.Contains( m_pos ) ) - SetFlags( SELECTED ); - else - ClearFlags( SELECTED ); - - return previousState != IsSelected(); -} - - #if defined(DEBUG) void SCH_BITMAP::Show( int nestLevel, std::ostream& os ) const { @@ -167,8 +154,6 @@ void SCH_BITMAP::Show( int nestLevel, std::ostream& os ) const NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << m_pos << "/>\n"; } - - #endif diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h index 1c9505f898..32cd31ce7f 100644 --- a/eeschema/sch_bitmap.h +++ b/eeschema/sch_bitmap.h @@ -139,13 +139,9 @@ public: bool IsMovableFromAnchorPoint() override { return false; } void MirrorY( int aYaxis_position ) override; - void MirrorX( int aXaxis_position ) override; - void Rotate( wxPoint aPosition ) override; - bool IsSelectStateChanged( const wxRect& aRect ) override; - wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override { return wxString( _( "Image" ) ); @@ -154,11 +150,9 @@ public: BITMAP_DEF GetMenuImage() const override; wxPoint GetPosition() const override { return m_pos; } - void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; } bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override; - bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override; void Plot( PLOTTER* aPlotter ) override; diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index b9c7f3a7e1..9cdeabb49b 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -299,21 +299,6 @@ bool SCH_BUS_ENTRY_BASE::IsDangling() const } -bool SCH_BUS_ENTRY_BASE::IsSelectStateChanged( const wxRect& aRect ) -{ - bool previousState = IsSelected(); - - // If either end of the bus entry is inside the selection rectangle, the entire - // bus entry is selected. Bus entries have a fixed length and angle. - if( aRect.Contains( m_pos ) || aRect.Contains( m_End() ) ) - SetFlags( SELECTED ); - else - ClearFlags( SELECTED ); - - return previousState != IsSelected(); -} - - void SCH_BUS_ENTRY_BASE::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { aPoints.push_back( m_pos ); diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index 0b6b8120fe..4fc189fce9 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -94,17 +94,12 @@ public: m_pos += aMoveVector; } - void MirrorY( int aYaxis_position ) override; - void MirrorX( int aXaxis_position ) override; - void Rotate( wxPoint aPosition ) override; bool IsDangling() const override; - bool IsSelectStateChanged( const wxRect& aRect ) override; - bool IsConnectable() const override { return true; } void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override; diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 0fe81ff117..75692759b4 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -1561,21 +1561,6 @@ wxPoint SCH_COMPONENT::GetPinPhysicalPosition( const LIB_PIN* Pin ) const } -bool SCH_COMPONENT::IsSelectStateChanged( const wxRect& aRect ) -{ - bool previousState = IsSelected(); - - EDA_RECT boundingBox = GetBoundingBox(); - - if( aRect.Intersects( boundingBox ) ) - SetFlags( SELECTED ); - else - ClearFlags( SELECTED ); - - return previousState != IsSelected(); -} - - void SCH_COMPONENT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { for( const SCH_PIN& pin : m_pins ) diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 6e942d971b..447cc150ad 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -537,9 +537,7 @@ public: } void MirrorY( int aYaxis_position ) override; - void MirrorX( int aXaxis_position ) override; - void Rotate( wxPoint aPosition ) override; bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) override; @@ -561,8 +559,6 @@ public: wxPoint GetPinPhysicalPosition( const LIB_PIN* Pin ) const; - bool IsSelectStateChanged( const wxRect& aRect ) override; - bool IsConnectable() const override { return true; } bool CanConnect( const SCH_ITEM* aItem ) const override @@ -598,8 +594,7 @@ public: BITMAP_DEF GetMenuImage() const override; - void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, - SCH_SHEET_PATH* aSheetPath ) override; + void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override; bool operator <( const SCH_ITEM& aItem ) const override; @@ -611,11 +606,9 @@ public: bool IsReplaceable() const override { return true; } wxPoint GetPosition() const override { return m_Pos; } - void SetPosition( const wxPoint& aPosition ) override { Move( aPosition - m_Pos ); } bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override; - bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override; void Plot( PLOTTER* aPlotter ) override; diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 3351531d2b..9cd15e5749 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -371,7 +371,6 @@ public: void KiwayMailIn( KIWAY_EXPRESS& aEvent ) override; - void OnLeftDClick( wxDC* aDC, const wxPoint& aPosition ) override; bool OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) override; void OnSelectOptionToolbar( wxCommandEvent& event ); double BestZoom() override; @@ -1031,11 +1030,6 @@ public: public: - /** - * Rotate and mirror a component. - */ - void OrientComponent( COMPONENT_ORIENTATION_T aOrientation = CMP_NORMAL ); - /** * Display the edit field dialog to edit the parameters of \a aField. * diff --git a/eeschema/sch_item_struct.h b/eeschema/sch_item_struct.h index 8302f8971f..63ecb47cac 100644 --- a/eeschema/sch_item_struct.h +++ b/eeschema/sch_item_struct.h @@ -289,18 +289,6 @@ public: virtual bool CanConnect( const SCH_ITEM* aItem ) const { return m_Layer == aItem->GetLayer(); } - /** - * Function IsSelectStateChanged - * checks if the selection state of an item inside \a aRect has changed. - * - * This is used by the block selection code to verify if an item is selected or not. - * True is be return anytime the select state changes. If you need to know the - * the current selection state, use the IsSelected() method. - * - * @param aRect - Rectangle to test against. - */ - virtual bool IsSelectStateChanged( const wxRect& aRect ) { return false; } - /** * Function IsConnectable * returns true if the schematic item can connect to another schematic item. diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 4e25b1f874..282f6c494f 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -126,19 +126,6 @@ void SCH_JUNCTION::GetEndPoints( std::vector & aItemList ) } -bool SCH_JUNCTION::IsSelectStateChanged( const wxRect& aRect ) -{ - bool previousState = IsSelected(); - - if( aRect.Contains( m_pos ) ) - SetFlags( SELECTED ); - else - ClearFlags( SELECTED ); - - return previousState != IsSelected(); -} - - void SCH_JUNCTION::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { aPoints.push_back( m_pos ); diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index b3dfdfead8..ce6362f6b2 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -22,10 +22,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file sch_junction.h - */ - #ifndef _SCH_JUNCTION_H_ #define _SCH_JUNCTION_H_ @@ -71,15 +67,11 @@ public: } void MirrorY( int aYaxis_position ) override; - void MirrorX( int aXaxis_position ) override; - void Rotate( wxPoint aPosition ) override; void GetEndPoints( std::vector & aItemList ) override; - bool IsSelectStateChanged( const wxRect& aRect ) override; - bool IsConnectable() const override { return true; } void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override; @@ -101,13 +93,11 @@ public: void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override; wxPoint GetPosition() const override { return m_pos; } - void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; } bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override; + bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override; - bool HitTest( const EDA_RECT& aRect, bool aContained = false, - int aAccuracy = 0 ) const override; void Plot( PLOTTER* aPlotter ) override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp index ac9ae3eda7..4a38275a2f 100644 --- a/eeschema/sch_marker.cpp +++ b/eeschema/sch_marker.cpp @@ -22,11 +22,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file sch_marker.cpp - * @brief Class SCH_MARKER implementation - */ - #include #include #include @@ -59,6 +54,12 @@ EDA_ITEM* SCH_MARKER::Clone() const } +void SCH_MARKER::SwapData( SCH_ITEM* aItem ) +{ + std::swap( *((SCH_MARKER*) this), *((SCH_MARKER*) aItem ) ); +} + + #if defined(DEBUG) void SCH_MARKER::Show( int nestLevel, std::ostream& os ) const @@ -151,19 +152,6 @@ void SCH_MARKER::MirrorY( int aYaxis_position ) } -bool SCH_MARKER::IsSelectStateChanged( const wxRect& aRect ) -{ - bool previousState = IsSelected(); - - if( aRect.Contains( m_Pos ) ) - SetFlags( SELECTED ); - else - ClearFlags( SELECTED ); - - return previousState != IsSelected(); -} - - bool SCH_MARKER::HitTest( const wxPoint& aPosition, int aAccuracy ) const { return HitTestMarker( aPosition ); diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h index b8c1fdf763..1091471257 100644 --- a/eeschema/sch_marker.h +++ b/eeschema/sch_marker.h @@ -22,11 +22,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file sch_marker.h - * @brief SCH_MARKER class definition. - */ - #ifndef TYPE_SCH_MARKER_H_ #define TYPE_SCH_MARKER_H_ @@ -48,6 +43,8 @@ public: return wxT( "SCH_MARKER" ); } + void SwapData( SCH_ITEM* aItem ) override; + void ViewGetLayers( int aLayers[], int& aCount ) const override; void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; @@ -69,11 +66,8 @@ public: m_Pos += aMoveVector; } - void MirrorY( int aYaxis_position ) override; - void MirrorX( int aXaxis_position ) override; - void Rotate( wxPoint aPosition ) override; /** @@ -89,8 +83,6 @@ public: void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; - bool IsSelectStateChanged( const wxRect& aRect ) override; - wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override { return wxString( _( "ERC Marker" ) ); @@ -99,7 +91,6 @@ public: BITMAP_DEF GetMenuImage() const override; wxPoint GetPosition() const override { return m_Pos; } - void SetPosition( const wxPoint& aPosition ) override { m_Pos = aPosition; } bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override; diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index 0d2480c2ac..d4eab5573b 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -133,19 +133,6 @@ void SCH_NO_CONNECT::Rotate( wxPoint aPosition ) } -bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect ) -{ - bool previousState = IsSelected(); - - if( aRect.Contains( m_pos ) ) - SetFlags( SELECTED ); - else - ClearFlags( SELECTED ); - - return previousState != IsSelected(); -} - - void SCH_NO_CONNECT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { aPoints.push_back( m_pos ); diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h index 04de56c226..2bba432ea3 100644 --- a/eeschema/sch_no_connect.h +++ b/eeschema/sch_no_connect.h @@ -76,13 +76,9 @@ public: } void MirrorY( int aYaxis_position ) override; - void MirrorX( int aXaxis_position ) override; - void Rotate( wxPoint aPosition ) override; - bool IsSelectStateChanged( const wxRect& aRect ) override; - bool IsConnectable() const override { return true; } bool CanConnect( const SCH_ITEM* aItem ) const override @@ -103,11 +99,9 @@ public: void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override; wxPoint GetPosition() const override { return m_pos; } - void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; } bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override; - bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override; void Plot( PLOTTER* aPlotter ) override; diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 5caaac4566..091bbbb5b6 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -783,21 +783,6 @@ bool SCH_SHEET::UpdateDanglingState( std::vector& aItemList ) } -bool SCH_SHEET::IsSelectStateChanged( const wxRect& aRect ) -{ - bool previousState = IsSelected(); - - EDA_RECT boundingBox = GetBoundingBox(); - - if( aRect.Intersects( boundingBox ) ) - SetFlags( SELECTED ); - else - ClearFlags( SELECTED ); - - return previousState != IsSelected(); -} - - void SCH_SHEET::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { for( size_t i = 0; i < GetPins().size(); i++ ) diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 23dc47fb48..b0fab862c5 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -22,11 +22,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file sch_sheet.h - * @brief Definition of the SCH_SHEET class for Eeschema. - */ - #ifndef SCH_SHEEET_H #define SCH_SHEEET_H @@ -168,11 +163,9 @@ public: Offset( aMoveVector ); } - void MirrorY( int aYaxis_position ) override; - - void Rotate( wxPoint aPosition ) override; - void MirrorX( int aXaxis_position ) override; + void MirrorY( int aYaxis_position ) override; + void Rotate( wxPoint aPosition ) override; bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) override; @@ -264,21 +257,17 @@ public: bool IsMovableFromAnchorPoint() override { return false; } wxString GetName() const { return m_name; } - void SetName( const wxString& aName ) { m_name = aName; } int GetSheetNameSize() const { return m_sheetNameSize; } - void SetSheetNameSize( int aSize ) { m_sheetNameSize = aSize; } int GetFileNameSize() const { return m_fileNameSize; } - void SetFileNameSize( int aSize ) { m_fileNameSize = aSize; } SCH_SCREEN* GetScreen() { return m_screen; } wxSize GetSize() { return m_size; } - void SetSize( const wxSize& aSize ) { m_size = aSize; } /** @@ -484,9 +473,7 @@ public: } void MirrorY( int aYaxis_position ) override; - void MirrorX( int aXaxis_position ) override; - void Rotate( wxPoint aPosition ) override; bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) override; @@ -516,8 +503,6 @@ public: bool UpdateDanglingState( std::vector& aItemList ) override; - bool IsSelectStateChanged( const wxRect& aRect ) override; - bool IsConnectable() const override { return true; } bool CanConnect( const SCH_ITEM* aItem ) const override @@ -543,11 +528,9 @@ public: void ViewGetLayers( int aLayers[], int& aCount ) const override; wxPoint GetPosition() const override { return m_pos; } - void SetPosition( const wxPoint& aPosition ) override; bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override; - bool HitTest( const EDA_RECT& aRect, bool aContained = false, int aAccuracy = 0 ) const override; void Plot( PLOTTER* aPlotter ) override; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 374ff064e6..7465947467 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -421,19 +421,6 @@ bool SCH_TEXT::UpdateDanglingState( std::vector& aItemList ) } -bool SCH_TEXT::IsSelectStateChanged( const wxRect& aRect ) -{ - bool previousState = IsSelected(); - - if( aRect.Contains( GetTextPos() ) ) - SetFlags( SELECTED ); - else - ClearFlags( SELECTED ); - - return previousState != IsSelected(); -} - - void SCH_TEXT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { // Normal text labels do not have connection points. All others do. diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index 413083c48c..9e8e55790a 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -130,7 +130,7 @@ public: */ virtual wxPoint GetSchematicTextOffset() const; - virtual void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset ) override; + void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset ) override; /** * Calculate the graphic shape (a polygon) associated to the text. @@ -144,66 +144,58 @@ public: aPoints.clear(); } - virtual void SwapData( SCH_ITEM* aItem ) override; + void SwapData( SCH_ITEM* aItem ) override; - virtual const EDA_RECT GetBoundingBox() const override; + const EDA_RECT GetBoundingBox() const override; - virtual int GetPenSize() const override; + int GetPenSize() const override; // Geometric transforms (used in block operations): - virtual void Move( const wxPoint& aMoveVector ) override + void Move( const wxPoint& aMoveVector ) override { EDA_TEXT::Offset( aMoveVector ); } - virtual void MirrorY( int aYaxis_position ) override; + void MirrorY( int aYaxis_position ) override; + void MirrorX( int aXaxis_position ) override; + void Rotate( wxPoint aPosition ) override; - virtual void MirrorX( int aXaxis_position ) override; + bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) override; - virtual void Rotate( wxPoint aPosition ) override; - - virtual bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) override; - - virtual bool Replace( wxFindReplaceData& aSearchData, void* aAuxData ) override + bool Replace( wxFindReplaceData& aSearchData, void* aAuxData ) override { return EDA_ITEM::Replace( aSearchData, m_Text ); } virtual bool IsReplaceable() const override { return true; } - virtual void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override; + void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override; - virtual bool UpdateDanglingState( std::vector& aItemList ) override; + bool UpdateDanglingState( std::vector& aItemList ) override; - virtual bool IsDangling() const override { return m_isDangling; } + bool IsDangling() const override { return m_isDangling; } + void SetIsDangling( bool aIsDangling ) { m_isDangling = aIsDangling; } - virtual void SetIsDangling( bool aIsDangling ) { m_isDangling = aIsDangling; } + void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override; - virtual bool IsSelectStateChanged( const wxRect& aRect ) override; + bool CanIncrementLabel() const override { return true; } - virtual void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; - virtual bool CanIncrementLabel() const override { return true; } + BITMAP_DEF GetMenuImage() const override; - virtual wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; + void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, SCH_SHEET_PATH* aSheetPath ) override; - virtual BITMAP_DEF GetMenuImage() const override; + wxPoint GetPosition() const override { return EDA_TEXT::GetTextPos(); } + void SetPosition( const wxPoint& aPosition ) override { EDA_TEXT::SetTextPos( aPosition ); } - virtual void GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, - SCH_SHEET_PATH* aSheetPath ) override; + bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override; + bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const override; - virtual wxPoint GetPosition() const override { return EDA_TEXT::GetTextPos(); } + void Plot( PLOTTER* aPlotter ) override; - virtual void SetPosition( const wxPoint& aPosition ) override { EDA_TEXT::SetTextPos( aPosition ); } - - virtual bool HitTest( const wxPoint& aPosition, int aAccuracy ) const override; - - virtual bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const override; - - virtual void Plot( PLOTTER* aPlotter ) override; - - virtual EDA_ITEM* Clone() const override; + EDA_ITEM* Clone() const override; void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; diff --git a/eeschema/tools/sch_drawing_tool.cpp b/eeschema/tools/sch_drawing_tool.cpp index 04d0656604..8f95cc3a45 100644 --- a/eeschema/tools/sch_drawing_tool.cpp +++ b/eeschema/tools/sch_drawing_tool.cpp @@ -419,10 +419,6 @@ int SCH_DRAWING_TOOL::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER field->SetText( i.second ); } - MSG_PANEL_ITEMS items; - aComponent->GetMsgPanelInfo( m_frame->GetUserUnits(), items ); - m_frame->SetMsgPanel( items ); - if( m_frame->GetAutoplaceFields() ) aComponent->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false ); @@ -549,16 +545,14 @@ int SCH_DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent ) continue; } - MSG_PANEL_ITEMS items; - image->GetMsgPanelInfo( m_frame->GetUserUnits(), items ); - m_frame->SetMsgPanel( items ); - image->SetFlags( IS_MOVED ); m_frame->SetRepeatItem( image ); m_frame->GetScreen()->SetCurItem( image ); m_view->ClearPreview(); m_view->AddToPreview( image->Clone() ); + m_toolMgr->RunAction( SCH_ACTIONS::selectItem, true, aComponent ); + m_controls->SetCursorPosition( cursorPos, false ); } else @@ -814,11 +808,6 @@ int SCH_DRAWING_TOOL::doTwoClickPlace( KICAD_T aType ) { m_toolMgr->RunAction( SCH_ACTIONS::selectItem, true, item ); - // JEY TODO: this should be handled by selection event.... - MSG_PANEL_ITEMS items; - item->GetMsgPanelInfo( m_frame->GetUserUnits(), items ); - m_frame->SetMsgPanel( items ); - item->SetFlags( IS_MOVED ); m_view->ClearPreview(); m_view->AddToPreview( item->Clone() ); diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 25f9f7baff..25d4a83ce1 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -628,6 +628,28 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent ) } +int SCH_EDITOR_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) +{ + SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); + SELECTION& selection = selTool->GetSelection(); + + if( selection.GetSize() == 1 ) + { + SCH_ITEM* item = (SCH_ITEM*) selection.GetItem( 0 ); + + MSG_PANEL_ITEMS msgItems; + item->GetMsgPanelInfo( m_frame->GetUserUnits(), msgItems ); + m_frame->SetMsgPanel( msgItems ); + } + else + { + m_frame->ClearMsgPanel(); + } + + return 0; +} + + void SCH_EDITOR_CONTROL::setTransitions() { /* @@ -643,6 +665,10 @@ void SCH_EDITOR_CONTROL::setTransitions() Go( &SCH_EDITOR_CONTROL::CrossProbePcbToSch, SCH_ACTIONS::crossProbeSchToPcb.MakeEvent() ); */ + Go( &SCH_EDITOR_CONTROL::UpdateMessagePanel, EVENTS::SelectedEvent ); + Go( &SCH_EDITOR_CONTROL::UpdateMessagePanel, EVENTS::UnselectedEvent ); + Go( &SCH_EDITOR_CONTROL::UpdateMessagePanel, EVENTS::ClearedEvent ); + #ifdef KICAD_SPICE Go( &SCH_EDITOR_CONTROL::SimProbe, SCH_ACTIONS::simProbe.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::SimTune, SCH_ACTIONS::simTune.MakeEvent() ); diff --git a/eeschema/tools/sch_editor_control.h b/eeschema/tools/sch_editor_control.h index 53737c9e07..0897876cf4 100644 --- a/eeschema/tools/sch_editor_control.h +++ b/eeschema/tools/sch_editor_control.h @@ -59,6 +59,8 @@ public: ///> Notifies pcbnew about the selected item. int CrossProbeSchToPcb( const TOOL_EVENT& aEvent ); + int UpdateMessagePanel( const TOOL_EVENT& aEvent ); + #ifdef KICAD_SPICE int SimProbe( const TOOL_EVENT& aEvent ); int SimTune( const TOOL_EVENT& aEvent ); diff --git a/eeschema/tools/sch_selection_tool.cpp b/eeschema/tools/sch_selection_tool.cpp index da62bb604a..659f0fe2f5 100644 --- a/eeschema/tools/sch_selection_tool.cpp +++ b/eeschema/tools/sch_selection_tool.cpp @@ -271,17 +271,11 @@ SCH_ITEM* SCH_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T } } - // JEY TODO: move to own action triggered by selection event.... if( collector.GetCount() == 1 ) { SCH_ITEM* item = collector[ 0 ]; toggleSelection( item ); - - MSG_PANEL_ITEMS msgItems; - item->GetMsgPanelInfo( m_frame->GetUserUnits(), msgItems ); - m_frame->SetMsgPanel( msgItems ); - return item; } diff --git a/include/id.h b/include/id.h index a6337263c3..8f03626c97 100644 --- a/include/id.h +++ b/include/id.h @@ -161,7 +161,7 @@ enum main_id ID_POPUP_CANCEL_CURRENT_COMMAND, ID_POPUP_CLOSE_CURRENT_TOOL, - // JEY TODO: all the block-specific commands are obsolet after LibEdit moves to modern toolset + // JEY TODO: all the block-specific commands are obsolete after LibEdit moves to modern toolset ID_POPUP_MOVE_BLOCK, ID_POPUP_MOVE_BLOCK_EXACT, ID_POPUP_DRAG_BLOCK, diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 6d66f9e0ee..ebdda24e56 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -974,12 +974,10 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition, GENERAL_COLLECTOR collector; // Find a connected item for which we are going to highlight a net - collector.Collect( board, GENERAL_COLLECTOR::PadsOrTracks, - wxPoint( aPosition.x, aPosition.y ), guide ); + collector.Collect( board, GENERAL_COLLECTOR::PadsOrTracks, (wxPoint) aPosition, guide ); if( collector.GetCount() == 0 ) - collector.Collect( board, GENERAL_COLLECTOR::Zones, - wxPoint( aPosition.x, aPosition.y ), guide ); + collector.Collect( board, GENERAL_COLLECTOR::Zones, (wxPoint) aPosition, guide ); // Clear the previous highlight frame->SendMessageToEESCHEMA( nullptr );