Move click-to-place tools to modern toolset.

This commit is contained in:
Jeff Young 2019-04-16 00:56:41 +01:00
parent ecfa05e2ca
commit 460909ea9a
28 changed files with 519 additions and 365 deletions

View File

@ -63,7 +63,7 @@ bool CONNECTION_SUBGRAPH::ResolveDrivers( bool aCreateMarkers )
switch( item->Type() )
{
case SCH_SHEET_PIN_T: item_priority = 2; break;
case SCH_HIERARCHICAL_LABEL_T: item_priority = 3; break;
case SCH_HIER_LABEL_T: item_priority = 3; break;
case SCH_LABEL_T: item_priority = 4; break;
case SCH_PIN_T:
{
@ -263,7 +263,7 @@ wxString CONNECTION_SUBGRAPH::GetNameForDriver( SCH_ITEM* aItem )
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_SHEET_PIN_T:
{
auto label = static_cast<SCH_TEXT*>( aItem );
@ -730,7 +730,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
{
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
{
auto text = static_cast<SCH_TEXT*>( driver );
connection->ConfigureFromLabel( text->GetText() );
@ -799,7 +799,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
switch( driver->Type() )
{
case SCH_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
{
m_local_label_cache[std::make_pair( sheet, name )].push_back( subgraph );
break;
@ -972,7 +972,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
// Local labels and hierarchical labels form local neighbor links
switch( driver->Type() )
{
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_LABEL_T:
{
// The actual connection attached to this item will have been overwritten
@ -1270,7 +1270,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
for( auto item : subgraph->m_drivers )
{
if( item->Type() == SCH_HIERARCHICAL_LABEL_T )
if( item->Type() == SCH_HIER_LABEL_T )
{
contains_hier_labels = true;
break;
@ -1394,7 +1394,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
for( auto d : candidate->m_drivers )
{
if( ( d->Type() == SCH_HIERARCHICAL_LABEL_T ) &&
if( ( d->Type() == SCH_HIER_LABEL_T ) &&
( static_cast<SCH_HIERLABEL*>( d )->GetText() == sp_name ) )
hier_label = d;
}
@ -1756,7 +1756,7 @@ bool CONNECTION_GRAPH::ercCheckBusToNetConflicts( CONNECTION_SUBGRAPH* aSubgraph
case SCH_GLOBAL_LABEL_T:
case SCH_SHEET_PIN_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
{
auto text = static_cast<SCH_TEXT*>( item )->GetText();
conn.ConfigureFromLabel( text );
@ -1824,7 +1824,7 @@ bool CONNECTION_GRAPH::ercCheckBusToBusConflicts( CONNECTION_SUBGRAPH* aSubgraph
}
case SCH_SHEET_PIN_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
{
if( !port && item->Connection( sheet )->IsBus() )
port = item;
@ -2122,7 +2122,7 @@ bool CONNECTION_GRAPH::ercCheckLabels( CONNECTION_SUBGRAPH* aSubgraph,
{
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
text = static_cast<SCH_TEXT*>( item );
break;

View File

@ -62,7 +62,7 @@ public:
switch( m_CurrentText->Type() )
{
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_LABEL_T:
// labels can share retained settings probably.
break;
@ -119,7 +119,7 @@ DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTe
switch( m_CurrentText->Type() )
{
case SCH_GLOBAL_LABEL_T: SetTitle( _( "Global Label Properties" ) ); break;
case SCH_HIERARCHICAL_LABEL_T: SetTitle( _( "Hierarchical Label Properties" ) ); break;
case SCH_HIER_LABEL_T: SetTitle( _( "Hierarchical Label Properties" ) ); break;
case SCH_LABEL_T: SetTitle( _( "Label Properties" ) ); break;
case SCH_SHEET_PIN_T: SetTitle( _( "Hierarchical Sheet Pin Properties" ) ); break;
default: SetTitle( _( "Text Properties" ) ); break;
@ -155,7 +155,7 @@ DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTe
SetInitialFocus( m_activeTextCtrl );
m_TextShape->Show( m_CurrentText->Type() == SCH_GLOBAL_LABEL_T ||
m_CurrentText->Type() == SCH_HIERARCHICAL_LABEL_T );
m_CurrentText->Type() == SCH_HIER_LABEL_T );
m_sdbSizer1OK->SetDefault();
Layout();

View File

@ -36,7 +36,7 @@
#include <view/view_group.h>
SCH_BITMAP* SCH_EDIT_FRAME::CreateNewImage( wxDC* aDC )
SCH_BITMAP* SCH_EDIT_FRAME::CreateNewImage()
{
wxFileDialog fileDlg( this, _( "Choose Image" ), wxEmptyString, wxEmptyString,
_( "Image Files " ) + wxImage::GetImageExtWildcard(),

View File

@ -114,7 +114,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( int aType )
lastTextItalic = textItem->IsItalic();
lastTextOrientation = textItem->GetLabelSpinStyle();
if( textItem->Type() == SCH_GLOBAL_LABEL_T || textItem->Type() == SCH_HIERARCHICAL_LABEL_T )
if( textItem->Type() == SCH_GLOBAL_LABEL_T || textItem->Type() == SCH_HIER_LABEL_T )
lastGlobalLabelShape = textItem->GetShape();
// Prepare display to move the new item
@ -152,7 +152,7 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
break;
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL:
type = SCH_HIERARCHICAL_LABEL_T;
type = SCH_HIER_LABEL_T;
break;
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT:
@ -181,7 +181,7 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
newtext = new SCH_GLOBALLABEL( position, txt );
break;
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
newtext = new SCH_HIERLABEL( position, txt );
break;

View File

@ -85,7 +85,7 @@ enum id_eeschema_frm
ID_BUSTOBUS_ENTRY_BUTT,
ID_WIRETOBUS_ENTRY_BUTT,
ID_LABEL_BUTT,
ID_GLABEL_BUTT,
ID_GLOBALLABEL_BUTT,
ID_HIERLABEL_BUTT,
ID_IMPORT_HLABEL_BUTT,
ID_SHEET_PIN_BUTT,

View File

@ -130,7 +130,7 @@ static EDA_HOTKEY HkAddLabel( _HKI( "Add Label" ), HK_ADD_LABEL, 'L', ID_LABEL_B
static EDA_HOTKEY HkAddHierarchicalLabel( _HKI( "Add Hierarchical Label" ), HK_ADD_HLABEL, 'H',
ID_HIERLABEL_BUTT );
static EDA_HOTKEY HkAddGlobalLabel( _HKI( "Add Global Label" ), HK_ADD_GLABEL, GR_KB_CTRL + 'H',
ID_GLABEL_BUTT );
ID_GLOBALLABEL_BUTT );
static EDA_HOTKEY HkAddJunction( _HKI( "Add Junction" ), HK_ADD_JUNCTION, 'J', ID_JUNCTION_BUTT );
static EDA_HOTKEY HkAddComponent( _HKI( "Add Symbol" ), HK_ADD_NEW_COMPONENT, 'A',
ID_SCH_PLACE_COMPONENT );

View File

@ -23,10 +23,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file eeschema/onleftclick.cpp
*/
#include <fctsys.h>
#include <kiway.h>
#include <eeschema_id.h>
@ -35,33 +31,37 @@
#include <sch_edit_frame.h>
#include <sim/sim_plot_frame.h>
#include <menus_helpers.h>
#include <sch_bus_entry.h>
#include <sch_text.h>
#include <sch_marker.h>
#include <sch_junction.h>
#include <sch_line.h>
#include <sch_no_connect.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <sch_bitmap.h>
#include <netlist_object.h>
#include <class_library.h> // for class SCHLIB_FILTER to filter power parts
#include <sch_view.h>
// TODO(hzeller): These pairs of elmenets should be represented by an object, but don't want
// to refactor too much right now to not get in the way with other code changes.
static SCH_BASE_FRAME::HISTORY_LIST s_CmpNameList;
static SCH_BASE_FRAME::HISTORY_LIST s_PowerNameList;
void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
{
switch( GetToolId() )
{
case ID_HIGHLIGHT_BUTT:
case ID_NOCONN_BUTT:
case ID_JUNCTION_BUTT:
case ID_WIRETOBUS_ENTRY_BUTT:
case ID_BUSTOBUS_ENTRY_BUTT:
case ID_SCH_PLACE_COMPONENT:
case ID_PLACE_POWER_BUTT:
case ID_LABEL_BUTT:
case ID_GLOBALLABEL_BUTT:
case ID_HIERLABEL_BUTT:
case ID_TEXT_COMMENT_BUTT:
case ID_ADD_IMAGE_BUTT:
return; // Moved to modern toolset
default:
break;
}
SCH_ITEM* item = GetScreen()->GetCurItem();
wxPoint gridPosition = GetGridPosition( aPosition );
// item_flags != 0 means a current item in edit, or new ...
int item_flags = item ? (item->GetFlags() & ~HIGHLIGHTED) : 0;
@ -74,19 +74,9 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
{
switch( item->Type() )
{
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T:
case SCH_SHEET_PIN_T:
case SCH_SHEET_T:
case SCH_BUS_WIRE_ENTRY_T:
case SCH_BUS_BUS_ENTRY_T:
case SCH_JUNCTION_T:
case SCH_COMPONENT_T:
case SCH_FIELD_T:
case SCH_BITMAP_T:
case SCH_NO_CONNECT_T:
AddItemToScreen( item );
GetCanvas()->GetView()->ClearPreview();
GetCanvas()->GetView()->ClearHiddenFlags();
@ -119,68 +109,6 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_ZOOM_SELECTION:
break;
case ID_HIGHLIGHT_BUTT:
// Moved to modern toolset
break;
case ID_NOCONN_BUTT:
if( item_flags == 0 )
{
if( GetScreen()->GetItem( gridPosition, 0, SCH_NO_CONNECT_T ) == NULL )
{
SCH_NO_CONNECT* no_connect = AddNoConnect( gridPosition );
SetRepeatItem( no_connect );
GetScreen()->SetCurItem( no_connect );
m_canvas->SetAutoPanRequest( true );
}
}
else
{
AddItemToScreen( item );
}
break;
case ID_JUNCTION_BUTT:
if( item_flags == 0 )
{
if( GetScreen()->GetItem( gridPosition, 0, SCH_JUNCTION_T ) == NULL )
{
SCH_JUNCTION* junction = AddJunction( gridPosition );
SetRepeatItem( junction );
GetScreen()->SetCurItem( junction );
m_canvas->SetAutoPanRequest( true );
}
}
else
{
AddItemToScreen( item );
}
break;
case ID_WIRETOBUS_ENTRY_BUTT:
if( item_flags == 0 )
{
CreateBusWireEntry();
m_canvas->SetAutoPanRequest( true );
}
else
{
AddItemToScreen( item );
}
break;
case ID_BUSTOBUS_ENTRY_BUTT:
if( item_flags == 0 )
{
CreateBusBusEntry();
m_canvas->SetAutoPanRequest( true );
}
else
{
AddItemToScreen( item );
}
break;
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
DeleteItemAtCrossHair();
break;
@ -200,60 +128,6 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
m_canvas->SetAutoPanRequest( true );
break;
case ID_TEXT_COMMENT_BUTT:
if( item_flags == 0 )
{
GetScreen()->SetCurItem( CreateNewText( LAYER_NOTES ) );
m_canvas->SetAutoPanRequest( true );
}
else
{
AddItemToScreen( item );
}
break;
case ID_ADD_IMAGE_BUTT:
if( item_flags == 0 )
{
GetScreen()->SetCurItem( CreateNewImage( aDC ) );
m_canvas->SetAutoPanRequest( true );
}
else
{
AddItemToScreen( item );
}
break;
case ID_LABEL_BUTT:
if( item_flags == 0 )
{
GetScreen()->SetCurItem( CreateNewText( LAYER_LOCLABEL ) );
m_canvas->SetAutoPanRequest( true );
}
else
{
AddItemToScreen( item );
}
break;
case ID_GLABEL_BUTT:
case ID_HIERLABEL_BUTT:
if( item_flags == 0 )
{
if( GetToolId() == ID_GLABEL_BUTT )
GetScreen()->SetCurItem( CreateNewText( LAYER_GLOBLABEL ) );
if( GetToolId() == ID_HIERLABEL_BUTT )
GetScreen()->SetCurItem( CreateNewText( LAYER_HIERLABEL ) );
m_canvas->SetAutoPanRequest( true );
}
else
{
AddItemToScreen( item );
}
break;
case ID_SHEET_SYMBOL_BUTT:
if( item_flags == 0 )
{
@ -292,14 +166,6 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
break;
case ID_SCH_PLACE_COMPONENT:
// Moved to modern toolset
break;
case ID_PLACE_POWER_BUTT:
// Moved to modern toolset
break;
#ifdef KICAD_SPICE
case ID_SIM_PROBE:
{
@ -405,7 +271,7 @@ void SCH_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
EditSchematicText( (SCH_TEXT*) item );
break;

View File

@ -122,7 +122,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
PopMenu->AppendSeparator();
break;
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
msg = AddHotkeyName( _( "Edit Hierarchical Label..." ), g_Schematic_Hotkeys_Descr,
HK_EDIT );
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
@ -253,7 +253,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
AddMenusForGLabel( PopMenu, (SCH_GLOBALLABEL*) item );
break;
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
AddMenusForHLabel( PopMenu, (SCH_HIERLABEL*) item );
break;

View File

@ -52,7 +52,7 @@ void SetSchItemParent( SCH_ITEM* Struct, SCH_SCREEN* Screen )
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_COMPONENT_T:
case SCH_LINE_T:
case SCH_BUS_BUS_ENTRY_T:
@ -252,7 +252,7 @@ void SCH_EDIT_FRAME::DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_SHEET_PIN_T:
case SCH_MARKER_T:
case SCH_NO_CONNECT_T:

View File

@ -48,7 +48,7 @@ const KICAD_T SCH_COLLECTOR::AllItems[] = {
SCH_TEXT_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
SCH_HIERARCHICAL_LABEL_T,
SCH_HIER_LABEL_T,
SCH_FIELD_T,
SCH_COMPONENT_T,
LIB_PIN_T,
@ -69,7 +69,7 @@ const KICAD_T SCH_COLLECTOR::AllItemsButPins[] = {
SCH_TEXT_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
SCH_HIERARCHICAL_LABEL_T,
SCH_HIER_LABEL_T,
SCH_FIELD_T,
SCH_COMPONENT_T,
SCH_SHEET_PIN_T,
@ -82,7 +82,7 @@ const KICAD_T SCH_COLLECTOR::EditableItems[] = {
SCH_TEXT_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
SCH_HIERARCHICAL_LABEL_T,
SCH_HIER_LABEL_T,
SCH_FIELD_T,
SCH_COMPONENT_T,
SCH_SHEET_PIN_T,
@ -124,7 +124,7 @@ const KICAD_T SCH_COLLECTOR::MovableItems[] = {
SCH_TEXT_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
SCH_HIERARCHICAL_LABEL_T,
SCH_HIER_LABEL_T,
SCH_FIELD_T,
SCH_COMPONENT_T,
SCH_SHEET_PIN_T,
@ -141,7 +141,7 @@ const KICAD_T SCH_COLLECTOR::DraggableItems[] = {
SCH_LINE_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
SCH_HIERARCHICAL_LABEL_T,
SCH_HIER_LABEL_T,
SCH_COMPONENT_T,
SCH_SHEET_T,
SCH_TEXT_T,
@ -153,7 +153,7 @@ const KICAD_T SCH_COLLECTOR::RotatableItems[] = {
SCH_TEXT_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
SCH_HIERARCHICAL_LABEL_T,
SCH_HIER_LABEL_T,
SCH_FIELD_T,
SCH_COMPONENT_T,
SCH_SHEET_T,
@ -174,7 +174,7 @@ const KICAD_T SCH_COLLECTOR::ParentItems[] = {
SCH_TEXT_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
SCH_HIERARCHICAL_LABEL_T,
SCH_HIER_LABEL_T,
SCH_COMPONENT_T,
SCH_SHEET_PIN_T,
SCH_SHEET_T,
@ -216,7 +216,7 @@ const KICAD_T SCH_COLLECTOR::CopyableItems[] = {
SCH_TEXT_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
SCH_HIERARCHICAL_LABEL_T,
SCH_HIER_LABEL_T,
SCH_COMPONENT_T,
EOT
};
@ -226,7 +226,7 @@ const KICAD_T SCH_COLLECTOR::DoubleClickItems[] = {
SCH_TEXT_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
SCH_HIERARCHICAL_LABEL_T,
SCH_HIER_LABEL_T,
SCH_COMPONENT_T,
SCH_SHEET_T,
SCH_BITMAP_T,

View File

@ -232,7 +232,7 @@ bool SCH_CONNECTION::IsDriver() const
{
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_PIN_T:
case SCH_SHEET_PIN_T:
case SCH_SHEET_T:

View File

@ -304,7 +304,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
// Tools and buttons for vertical toolbar.
EVT_TOOL( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnSelectTool )
EVT_TOOL( ID_HIGHLIGHT_BUTT, SCH_EDIT_FRAME::OnSelectTool )
EVT_MENU( ID_MENU_ZOOM_SELECTION, SCH_EDIT_FRAME::OnSelectTool )
EVT_TOOL( ID_ZOOM_SELECTION, SCH_EDIT_FRAME::OnSelectTool )
EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,

View File

@ -816,10 +816,7 @@ public:
* Checks if a bus unfolding operation is in progress, so that it can be
* properly canceled / commited along with the wire draw operation.
*/
bool IsBusUnfoldInProgress()
{
return m_busUnfold.in_progress;
}
bool IsBusUnfoldInProgress() { return m_busUnfold.in_progress; }
/**
* Cancels a bus unfolding operation, cleaning up the bus entry and label
@ -833,6 +830,16 @@ public:
*/
void FinishBusUnfold();
SCH_NO_CONNECT* AddNoConnect( const wxPoint& aPosition );
SCH_JUNCTION* AddJunction( const wxPoint& aPosition, bool aAppendToUndo = false,
bool aFinal = true );
SCH_BUS_WIRE_ENTRY* CreateBusWireEntry();
SCH_BUS_BUS_ENTRY* CreateBusBusEntry();
SCH_TEXT* CreateNewText( int aType );
SCH_BITMAP* CreateNewImage();
private:
/**
@ -962,25 +969,8 @@ private:
void UpdateTitle();
// Bus Entry
SCH_BUS_WIRE_ENTRY* CreateBusWireEntry();
SCH_BUS_BUS_ENTRY* CreateBusBusEntry();
void SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY_BASE* BusEntry, char entry_shape );
/**
* Add no connect item to the current schematic sheet at \a aPosition.
*
* @param aPosition The position in logical (drawing) units to add the no connect.
* @return The no connect item added.
*/
SCH_NO_CONNECT* AddNoConnect( const wxPoint& aPosition );
/**
* Add a new junction at \a aPosition.
*/
SCH_JUNCTION* AddJunction( const wxPoint& aPosition,
bool aAppendToUndo = false,
bool aFinal = true );
/**
* Collects a unique list of all possible connection points in the schematic.
*
@ -1030,7 +1020,6 @@ private:
void PrepareMoveItem( SCH_ITEM* aItem );
// Text, label, glabel
SCH_TEXT* CreateNewText( int aType );
void EditSchematicText( SCH_TEXT* TextStruct );
void ChangeTextOrient( SCH_TEXT* aTextItem );
@ -1063,7 +1052,6 @@ private:
void DeleteConnection( bool DeleteFullConnection );
// Images:
SCH_BITMAP* CreateNewImage( wxDC* aDC );
void RotateImage( SCH_BITMAP* aItem );
/**

View File

@ -1364,7 +1364,7 @@ SCH_TEXT* SCH_LEGACY_PLUGIN::loadText( FILE_LINE_READER& aReader )
text->SetTextSize( wxSize( size, size ) );
// Parse the global and hierarchical label type.
if( text->Type() == SCH_HIERARCHICAL_LABEL_T || text->Type() == SCH_GLOBAL_LABEL_T )
if( text->Type() == SCH_HIER_LABEL_T || text->Type() == SCH_GLOBAL_LABEL_T )
{
if( strCompare( SheetLabelType[NET_INPUT], line, &line ) )
text->SetShape( NET_INPUT );
@ -1847,7 +1847,7 @@ void SCH_LEGACY_PLUGIN::Format( SCH_SCREEN* aScreen )
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
saveText( static_cast< SCH_TEXT* >( item ) );
break;
default:

View File

@ -589,7 +589,7 @@ bool SCH_LINE::CanConnect( const SCH_ITEM* aItem ) const
case SCH_NO_CONNECT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_BUS_WIRE_ENTRY_T:
case SCH_COMPONENT_T:
case SCH_SHEET_T:

View File

@ -207,7 +207,7 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer )
HANDLE_ITEM(SCH_TEXT_T, SCH_TEXT);
HANDLE_ITEM(SCH_LABEL_T, SCH_TEXT);
HANDLE_ITEM(SCH_FIELD_T, SCH_FIELD);
HANDLE_ITEM(SCH_HIERARCHICAL_LABEL_T, SCH_HIERLABEL);
HANDLE_ITEM(SCH_HIER_LABEL_T, SCH_HIERLABEL);
HANDLE_ITEM(SCH_GLOBAL_LABEL_T, SCH_GLOBALLABEL);
HANDLE_ITEM(SCH_SHEET_T, SCH_SHEET);
HANDLE_ITEM(SCH_SHEET_PIN_T, SCH_HIERLABEL);
@ -1025,7 +1025,7 @@ void SCH_PAINTER::draw( SCH_TEXT *aText, int aLayer )
switch( aText->Type() )
{
case SCH_SHEET_PIN_T: color = m_schSettings.GetLayerColor( LAYER_SHEETLABEL ); break;
case SCH_HIERARCHICAL_LABEL_T: color = m_schSettings.GetLayerColor( LAYER_HIERLABEL ); break;
case SCH_HIER_LABEL_T: color = m_schSettings.GetLayerColor( LAYER_HIERLABEL ); break;
case SCH_GLOBAL_LABEL_T: color = m_schSettings.GetLayerColor( LAYER_GLOBLABEL ); break;
case SCH_LABEL_T: color = m_schSettings.GetLayerColor( LAYER_LOCLABEL ); break;
default: color = m_schSettings.GetLayerColor( LAYER_NOTES ); break;
@ -1035,7 +1035,7 @@ void SCH_PAINTER::draw( SCH_TEXT *aText, int aLayer )
if( conn && conn->IsBus() &&
( aText->Type() == SCH_SHEET_PIN_T ||
aText->Type() == SCH_HIERARCHICAL_LABEL_T ) )
aText->Type() == SCH_HIER_LABEL_T ) )
color = m_schSettings.GetLayerColor( LAYER_BUS );
if( aText->GetState( BRIGHTENED ) )

View File

@ -978,7 +978,7 @@ int SCH_SCREEN::GetNode( const wxPoint& aPosition, EDA_ITEMS& aList )
}
case SCH_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_SHEET_PIN_T:
case SCH_JUNCTION_T:
@ -1054,7 +1054,7 @@ SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy )
{
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
if( item->HitTest( aPosition, aAccuracy ) )
return (SCH_TEXT*) item;

View File

@ -239,7 +239,7 @@ bool SCH_SHEET::HasUndefinedPins()
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{
if( DrawStruct->Type() != SCH_HIERARCHICAL_LABEL_T )
if( DrawStruct->Type() != SCH_HIER_LABEL_T )
continue;
HLabel = static_cast<SCH_HIERLABEL*>( DrawStruct );
@ -349,7 +349,7 @@ void SCH_SHEET::CleanupSheet()
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{
if( DrawStruct->Type() != SCH_HIERARCHICAL_LABEL_T )
if( DrawStruct->Type() != SCH_HIER_LABEL_T )
continue;
HLabel = static_cast<SCH_HIERLABEL*>( DrawStruct );

View File

@ -224,7 +224,7 @@ void SCH_TEXT::Rotate( wxPoint aPosition )
// Global and hierarchical labels spin backwards. Fix here because
// changing SetLabelSpinStyle would break existing designs.
if( this->Type() == SCH_GLOBAL_LABEL_T || this->Type() == SCH_HIERARCHICAL_LABEL_T )
if( this->Type() == SCH_GLOBAL_LABEL_T || this->Type() == SCH_HIER_LABEL_T )
SetLabelSpinStyle( ( spin - 1 >= 0 ? ( spin - 1 ) : 3 ) );
else
SetLabelSpinStyle( ( spin + 1 ) % 4 );
@ -594,7 +594,7 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList )
case SCH_TEXT_T: msg = _( "Graphic Text" ); break;
case SCH_LABEL_T: msg = _( "Label" ); break;
case SCH_GLOBAL_LABEL_T: msg = _( "Global Label" ); break;
case SCH_HIERARCHICAL_LABEL_T: msg = _( "Hierarchical Label" ); break;
case SCH_HIER_LABEL_T: msg = _( "Hierarchical Label" ); break;
case SCH_SHEET_PIN_T: msg = _( "Hierarchical Sheet Pin" ); break;
default: return;
}
@ -626,7 +626,7 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList )
// Display electricat type if it is relevant
if( (Type() == SCH_GLOBAL_LABEL_T) ||
(Type() == SCH_HIERARCHICAL_LABEL_T ) ||
(Type() == SCH_HIER_LABEL_T ) ||
(Type() == SCH_SHEET_PIN_T ) )
{
switch( GetShape() )

View File

@ -298,7 +298,7 @@ class SCH_HIERLABEL : public SCH_TEXT
public:
SCH_HIERLABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString,
KICAD_T aType = SCH_HIERARCHICAL_LABEL_T );
KICAD_T aType = SCH_HIER_LABEL_T );
// Do not create a copy constructor. The one generated by the compiler is adequate.

View File

@ -33,8 +33,6 @@
#include <sch_edit_frame.h>
#include <kicad_device_context.h>
#include <hotkeys_basic.h>
#include <advanced_config.h>
#include <general.h>
#include <eeschema_id.h>
#include <list_operations.h>
@ -48,9 +46,10 @@
#include <sch_sheet_path.h>
#include <sch_view.h>
#include <simulation_cursors.h>
#include <tool/tool_manager.h>
#include <tools/sch_actions.h>
void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
int id = event.GetId();
wxPoint pos;
@ -470,7 +469,7 @@ void SCH_EDIT_FRAME::OnDuplicateItem( wxCommandEvent& event )
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
{
SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone();
newitem->SetFlags( IS_NEW );
@ -527,7 +526,7 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
case SCH_BUS_WIRE_ENTRY_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_TEXT_T:
case SCH_COMPONENT_T:
case SCH_SHEET_PIN_T:
@ -586,20 +585,45 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
// Stop the current command and deselect the current tool.
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
switch( id )
{
case ID_HIGHLIGHT_BUTT:
case ID_MENU_NOCONN_BUTT:
case ID_NOCONN_BUTT:
case ID_MENU_JUNCTION_BUTT:
case ID_JUNCTION_BUTT:
case ID_MENU_LABEL_BUTT:
case ID_LABEL_BUTT:
case ID_MENU_GLABEL_BUTT:
case ID_GLOBALLABEL_BUTT:
case ID_MENU_HIERLABEL_BUTT:
case ID_HIERLABEL_BUTT:
case ID_MENU_TEXT_COMMENT_BUTT:
case ID_TEXT_COMMENT_BUTT:
case ID_MENU_ADD_IMAGE_BUTT:
case ID_ADD_IMAGE_BUTT:
case ID_MENU_WIRETOBUS_ENTRY_BUTT:
case ID_WIRETOBUS_ENTRY_BUTT:
case ID_MENU_BUSTOBUS_ENTRY_BUTT:
case ID_BUSTOBUS_ENTRY_BUTT:
case ID_MENU_PLACE_COMPONENT:
case ID_SCH_PLACE_COMPONENT:
case ID_MENU_PLACE_POWER_BUTT:
case ID_PLACE_POWER_BUTT:
// moved to modern toolset
return;
default:
// since legacy tools don't activate themsleves, we have to deactivate any modern
// tools that might be running until all the legacy tools are moved over....
m_toolManager->DeactivateTool();
}
switch( id )
{
case ID_NO_TOOL_SELECTED:
SetNoToolSelected();
break;
case ID_HIGHLIGHT_BUTT:
// TODO(JE) remove once real-time connectivity is a given
if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity )
RecalculateConnections();
SetToolID( ID_HIGHLIGHT_BUTT, wxCURSOR_HAND, _("Highlight specific net") );
break;
case ID_MENU_ZOOM_SELECTION:
case ID_ZOOM_SELECTION:
// This tool is located on the main toolbar: switch it on or off on click
@ -609,11 +633,6 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
SetNoToolSelected();
break;
case ID_MENU_NOCONN_BUTT:
case ID_NOCONN_BUTT:
SetToolID( ID_NOCONN_BUTT, wxCURSOR_PENCIL, _( "Add no connect" ) );
break;
case ID_MENU_WIRE_BUTT:
case ID_WIRE_BUTT:
SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add wire" ) );
@ -629,46 +648,6 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
SetToolID( ID_LINE_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add lines" ) );
break;
case ID_MENU_JUNCTION_BUTT:
case ID_JUNCTION_BUTT:
SetToolID( ID_JUNCTION_BUTT, wxCURSOR_PENCIL, _( "Add junction" ) );
break;
case ID_MENU_LABEL_BUTT:
case ID_LABEL_BUTT:
SetToolID( ID_LABEL_BUTT, wxCURSOR_PENCIL, _( "Add label" ) );
break;
case ID_MENU_GLABEL_BUTT:
case ID_GLABEL_BUTT:
SetToolID( ID_GLABEL_BUTT, wxCURSOR_PENCIL, _( "Add global label" ) );
break;
case ID_MENU_HIERLABEL_BUTT:
case ID_HIERLABEL_BUTT:
SetToolID( ID_HIERLABEL_BUTT, wxCURSOR_PENCIL, _( "Add hierarchical label" ) );
break;
case ID_MENU_TEXT_COMMENT_BUTT:
case ID_TEXT_COMMENT_BUTT:
SetToolID( ID_TEXT_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) );
break;
case ID_MENU_ADD_IMAGE_BUTT:
case ID_ADD_IMAGE_BUTT:
SetToolID( ID_ADD_IMAGE_BUTT, wxCURSOR_PENCIL, _( "Add image" ) );
break;
case ID_MENU_WIRETOBUS_ENTRY_BUTT:
case ID_WIRETOBUS_ENTRY_BUTT:
SetToolID( ID_WIRETOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add wire to bus entry" ) );
break;
case ID_MENU_BUSTOBUS_ENTRY_BUTT:
case ID_BUSTOBUS_ENTRY_BUTT:
SetToolID( ID_BUSTOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add bus to bus entry" ) );
break;
case ID_MENU_SHEET_SYMBOL_BUTT:
case ID_SHEET_SYMBOL_BUTT:
SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add sheet" ) );
@ -684,16 +663,6 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
SetToolID( ID_IMPORT_HLABEL_BUTT, wxCURSOR_PENCIL, _( "Import sheet pins" ) );
break;
case ID_MENU_PLACE_COMPONENT:
case ID_SCH_PLACE_COMPONENT:
SetToolID( ID_SCH_PLACE_COMPONENT, wxCURSOR_PENCIL, _( "Add component" ) );
break;
case ID_MENU_PLACE_POWER_BUTT:
case ID_PLACE_POWER_BUTT:
SetToolID( ID_PLACE_POWER_BUTT, wxCURSOR_PENCIL, _( "Add power" ) );
break;
case ID_MENU_DELETE_ITEM_BUTT:
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
SetToolID( ID_SCHEMATIC_DELETE_ITEM_BUTT, wxCURSOR_BULLSEYE, _( "Delete item" ) );
@ -1005,7 +974,7 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
m_canvas->MoveCursorToCrossHair();
ChangeTextOrient( (SCH_TEXT*) item );
break;
@ -1061,7 +1030,12 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
RefreshItem( item );
if( item->IsMoving() )
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
{
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
else
m_toolManager->RunAction( SCH_ACTIONS::refreshPreview, true );
}
if( item->GetFlags() == 0 )
screen->SetCurItem( NULL );
@ -1194,7 +1168,7 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
case SCH_TEXT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
EditSchematicText( (SCH_TEXT*) item );
break;
@ -1279,7 +1253,7 @@ void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
case SCH_COMPONENT_T:
case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T:
case SCH_HIERARCHICAL_LABEL_T:
case SCH_HIER_LABEL_T:
case SCH_SHEET_T:
case SCH_TEXT_T:
m_canvas->MoveCursorToCrossHair();
@ -1437,7 +1411,12 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
RefreshItem( item );
if( item->IsMoving() )
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
{
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
else
m_toolManager->RunAction( SCH_ACTIONS::refreshPreview, true );
}
if( item->GetFlags() == 0 )
screen->SetCurItem( NULL );

View File

@ -116,7 +116,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet )
for( ; item != NULL; item = item->Next() )
{
if( item->Type() != SCH_HIERARCHICAL_LABEL_T )
if( item->Type() != SCH_HIER_LABEL_T )
continue;
label = (SCH_HIERLABEL*) item;

View File

@ -232,7 +232,7 @@ void SCH_EDIT_FRAME::ReCreateVToolbar()
KiScaledBitmap( add_line_label_xpm, this ),
HELP_PLACE_NETLABEL, wxITEM_CHECK );
m_drawToolBar->AddTool( ID_GLABEL_BUTT, wxEmptyString, KiScaledBitmap( add_glabel_xpm, this ),
m_drawToolBar->AddTool( ID_GLOBALLABEL_BUTT, wxEmptyString, KiScaledBitmap( add_glabel_xpm, this ),
HELP_PLACE_GLOBALLABEL, wxITEM_CHECK );
m_drawToolBar->AddTool( ID_HIERLABEL_BUTT, wxEmptyString,

View File

@ -34,6 +34,9 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
{
switch( aId )
{
case ID_CANCEL_CURRENT_COMMAND:
return ACTIONS::cancelInteractive.MakeEvent();
case ID_ZOOM_REDRAW:
case ID_POPUP_ZOOM_REDRAW:
case ID_VIEWER_ZOOM_REDRAW:
@ -42,14 +45,14 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
case ID_POPUP_ZOOM_IN:
return ACTIONS::zoomIn.MakeEvent();
case ID_ZOOM_IN: // toolbar button "Zoom In"
case ID_ZOOM_IN:
case ID_VIEWER_ZOOM_IN:
return ACTIONS::zoomInCenter.MakeEvent();
case ID_POPUP_ZOOM_OUT:
return ACTIONS::zoomOut.MakeEvent();
case ID_ZOOM_OUT: // toolbar button "Zoom Out"
case ID_ZOOM_OUT:
case ID_VIEWER_ZOOM_OUT:
return ACTIONS::zoomOutCenter.MakeEvent();
@ -76,11 +79,49 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
case ID_HIGHLIGHT_NET:
return SCH_ACTIONS::highlightNet.MakeEvent();
case ID_MENU_PLACE_COMPONENT:
case ID_SCH_PLACE_COMPONENT:
return SCH_ACTIONS::placeSymbol.MakeEvent();
case ID_MENU_PLACE_POWER_BUTT:
case ID_PLACE_POWER_BUTT:
return SCH_ACTIONS::placePower.MakeEvent();
case ID_MENU_NOCONN_BUTT:
case ID_NOCONN_BUTT:
return SCH_ACTIONS::placeNoConnect.MakeEvent();
case ID_MENU_JUNCTION_BUTT:
case ID_JUNCTION_BUTT:
return SCH_ACTIONS::placeJunction.MakeEvent();
case ID_MENU_WIRETOBUS_ENTRY_BUTT:
case ID_WIRETOBUS_ENTRY_BUTT:
return SCH_ACTIONS::placeBusWireEntry.MakeEvent();
case ID_MENU_BUSTOBUS_ENTRY_BUTT:
case ID_BUSTOBUS_ENTRY_BUTT:
return SCH_ACTIONS::placeBusBusEntry.MakeEvent();
case ID_MENU_LABEL_BUTT:
case ID_LABEL_BUTT:
return SCH_ACTIONS::placeLabel.MakeEvent();
case ID_MENU_GLABEL_BUTT:
case ID_GLOBALLABEL_BUTT:
return SCH_ACTIONS::placeLabel.MakeEvent();
case ID_MENU_HIERLABEL_BUTT:
case ID_HIERLABEL_BUTT:
return SCH_ACTIONS::placeHierarchicalLabel.MakeEvent();
case ID_MENU_TEXT_COMMENT_BUTT:
case ID_TEXT_COMMENT_BUTT:
return SCH_ACTIONS::placeSchematicText.MakeEvent();
case ID_MENU_ADD_IMAGE_BUTT:
case ID_ADD_IMAGE_BUTT:
return SCH_ACTIONS::placeImage.MakeEvent();
}
return OPT<TOOL_EVENT>();

View File

@ -90,6 +90,15 @@ public:
static TOOL_ACTION pickerTool;
static TOOL_ACTION placeSymbol;
static TOOL_ACTION placePower;
static TOOL_ACTION placeNoConnect;
static TOOL_ACTION placeJunction;
static TOOL_ACTION placeBusWireEntry;
static TOOL_ACTION placeBusBusEntry;
static TOOL_ACTION placeLabel;
static TOOL_ACTION placeGlobalLabel;
static TOOL_ACTION placeHierarchicalLabel;
static TOOL_ACTION placeSchematicText;
static TOOL_ACTION placeImage;
// Editing
static TOOL_ACTION properties;
@ -104,6 +113,7 @@ public:
static TOOL_ACTION switchUnits;
static TOOL_ACTION updateUnits;
static TOOL_ACTION deleteItemCursor;
static TOOL_ACTION refreshPreview;
// Net highlighting
static TOOL_ACTION highlightNet;

View File

@ -26,7 +26,12 @@
#include <sch_draw_panel.h>
#include <sch_edit_frame.h>
#include <sch_component.h>
#include <sch_no_connect.h>
#include <sch_junction.h>
#include <sch_bus_entry.h>
#include <sch_text.h>
#include <sch_sheet.h>
#include <sch_bitmap.h>
#include <erc.h>
#include <eeschema_id.h>
#include <netlist_object.h>
@ -37,26 +42,64 @@
#include <tools/sch_editor_control.h>
#include <hotkeys.h>
#include <class_library.h>
#include <advanced_config.h>
TOOL_ACTION SCH_ACTIONS::refreshPreview( "eeschema.EditorControl.refreshPreview",
AS_GLOBAL, 0, "", "" );
TOOL_ACTION SCH_ACTIONS::highlightNet( "eeschema.EditorControl.highlightNet",
AS_GLOBAL, 0, "", "" );
AS_GLOBAL, 0, "", "" );
TOOL_ACTION SCH_ACTIONS::highlightNetSelection( "eeschema.EditorControl.highlightNetSelection",
AS_GLOBAL, 0, "", "" );
AS_GLOBAL, 0, "", "" );
TOOL_ACTION SCH_ACTIONS::highlightNetCursor( "eeschema.EditorControl.highlightNetCursor",
AS_GLOBAL, 0,
_( "Highlight Net" ), _( "Highlight wires and pins of a net" ),
NULL, AF_ACTIVATE );
AS_GLOBAL, 0,
_( "Highlight Net" ), _( "Highlight wires and pins of a net" ), NULL, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::placeSymbol( "eeschema.EditorControl.placeSymbol",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_NEW_COMPONENT ),
_( "Add Symbol" ), _( "Add a symbol" ), NULL, AF_ACTIVATE );
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_NEW_COMPONENT ),
_( "Add Symbol" ), _( "Add a symbol" ), NULL, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::placePower( "eeschema.EditorControl.placePowerPort",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_NEW_POWER ),
_( "Add Power" ), _( "Add a power port" ), NULL, AF_ACTIVATE );
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_NEW_POWER ),
_( "Add Power" ), _( "Add a power port" ), NULL, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::placeNoConnect( "eeschema.EditorControl.placeNoConnect",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_NOCONN_FLAG ),
_( "Add No Connect Flag" ), _( "Add a no-connection flag" ), NULL, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::placeJunction( "eeschema.EditorControl.placeJunction",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_JUNCTION ),
_( "Add Junction" ), _( "Add a junction" ), NULL, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::placeBusWireEntry( "eeschema.EditorControl.placeBusWireEntry",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_WIRE_ENTRY ),
_( "Add Wire to Bus Entry" ), _( "Add a wire entry to a bus" ), NULL, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::placeBusBusEntry( "eeschema.EditorControl.placeBusBusEntry",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_BUS_ENTRY ),
_( "Add Bus to Bus Entry" ), _( "Add a bus entry to a bus" ), NULL, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::placeLabel( "eeschema.EditorControl.placePLabel",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_LABEL ),
_( "Add Label" ), _( "Add a net label" ), NULL, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::placeHierarchicalLabel( "eeschema.EditorControl.placeHierarchicalLabel",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_HLABEL ),
_( "Add Hierarchical Label" ), _( "Add a hierarchical sheet label" ), NULL, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::placeGlobalLabel( "eeschema.EditorControl.placeGlobalLabel",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_GLABEL ),
_( "Add Global Label" ), _( "Add a global label" ), NULL, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::placeSchematicText( "eeschema.EditorControl.placeSchematicText",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_GRAPHIC_TEXT ),
_( "Add Text" ), _( "Add text" ), NULL, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::placeImage( "eeschema.EditorControl.placeImage",
AS_GLOBAL, 0,
_( "Add Image" ), _( "Add bitmap image" ), NULL, AF_ACTIVATE );
SCH_EDITOR_CONTROL::SCH_EDITOR_CONTROL() :
@ -243,12 +286,16 @@ int SCH_EDITOR_CONTROL::HighlightNetSelection( const TOOL_EVENT& aEvent )
int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
{
// TODO(JE) remove once real-time connectivity is a given
if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity )
m_frame->RecalculateConnections();
Activate();
SCH_PICKER_TOOL* picker = m_toolMgr->GetTool<SCH_PICKER_TOOL>();
assert( picker );
m_frame->SetToolID( ID_HIGHLIGHT_BUTT, wxCURSOR_HAND, _( "Highlight net" ) );
m_frame->SetToolID( ID_HIGHLIGHT_BUTT, wxCURSOR_HAND, _( "Highlight specific net" ) );
picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, std::placeholders::_1 ) );
picker->Activate();
Wait();
@ -268,7 +315,7 @@ int SCH_EDITOR_CONTROL::PlaceSymbol( const TOOL_EVENT& aEvent )
m_frame->SetToolID( ID_SCH_PLACE_COMPONENT, wxCURSOR_PENCIL, _( "Add Symbol" ) );
return placeComponent( component, nullptr, s_SymbolHistoryList );
return doPlaceComponent( component, nullptr, s_SymbolHistoryList );
}
@ -280,12 +327,12 @@ int SCH_EDITOR_CONTROL::PlacePower( const TOOL_EVENT& aEvent )
filter.FilterPowerParts( true );
m_frame->SetToolID( ID_PLACE_POWER_BUTT, wxCURSOR_PENCIL, _( "Add Power" ) );
return placeComponent( component, &filter, s_PowerHistoryList );
return doPlaceComponent( component, &filter, s_PowerHistoryList );
}
int SCH_EDITOR_CONTROL::placeComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER* aFilter,
SCH_BASE_FRAME::HISTORY_LIST aHistoryList )
int SCH_EDITOR_CONTROL::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER* aFilter,
SCH_BASE_FRAME::HISTORY_LIST aHistoryList )
{
KIGFX::VIEW_CONTROLS* controls = getViewControls();
VECTOR2I cursorPos = controls->GetCursorPosition();
@ -321,13 +368,12 @@ int SCH_EDITOR_CONTROL::placeComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER
delete aComponent;
aComponent = nullptr;
}
else // let's have another chance placing a module
else
break;
if( evt->IsActivate() ) // now finish unconditionally
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
if( !aComponent )
@ -347,35 +393,34 @@ int SCH_EDITOR_CONTROL::placeComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER
if( sel.LibId.IsValid() )
part = m_frame->GetLibPart( sel.LibId );
if( part )
{
aComponent = new SCH_COMPONENT( *part, sel.LibId, g_CurrentSheet, sel.Unit,
sel.Convert, (wxPoint)cursorPos, true );
// Be sure the link to the corresponding LIB_PART is OK:
aComponent->Resolve( *m_frame->Prj().SchSymbolLibTable() );
// Set any fields that have been modified
for( auto const& i : sel.Fields )
{
auto field = aComponent->GetField( i.first );
if( field )
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 );
}
if( !aComponent )
if( !part )
continue;
aComponent = new SCH_COMPONENT( *part, sel.LibId, g_CurrentSheet, sel.Unit,
sel.Convert, (wxPoint)cursorPos, true );
// Be sure the link to the corresponding LIB_PART is OK:
aComponent->Resolve( *m_frame->Prj().SchSymbolLibTable() );
// Set any fields that have been modified
for( auto const& i : sel.Fields )
{
auto field = aComponent->GetField( i.first );
if( field )
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 );
aComponent->SetFlags( IS_MOVED );
m_frame->SetRepeatItem( aComponent );
m_frame->GetScreen()->SetCurItem( aComponent );
view->ClearPreview();
view->AddToPreview( aComponent->Clone() );
@ -390,14 +435,12 @@ int SCH_EDITOR_CONTROL::placeComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER
aComponent = nullptr;
}
}
else if( evt->IsClick( BUT_RIGHT ) )
{
// JEY TODO
// m_menu.ShowContextMenu( selTool->GetSelection() );
}
else if( aComponent && evt->IsMotion() )
else if( aComponent && ( evt->IsAction( &SCH_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{
aComponent->SetPosition( (wxPoint)cursorPos );
view->ClearPreview();
@ -415,6 +458,223 @@ int SCH_EDITOR_CONTROL::placeComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER
}
int SCH_EDITOR_CONTROL::PlaceNoConnect( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_NOCONN_BUTT, wxCURSOR_PENCIL, _( "Add no connect" ) );
return doSingleClickPlace( SCH_NO_CONNECT_T );
}
int SCH_EDITOR_CONTROL::PlaceJunction( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_JUNCTION_BUTT, wxCURSOR_PENCIL, _( "Add junction" ) );
return doSingleClickPlace( SCH_JUNCTION_T );
}
int SCH_EDITOR_CONTROL::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_EDITOR_CONTROL::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_EDITOR_CONTROL::doSingleClickPlace( KICAD_T aType )
{
KIGFX::VIEW_CONTROLS* controls = getViewControls();
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
controls->ShowCursor( true );
controls->SetSnapping( true );
Activate();
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
{
wxPoint cursorPos = (wxPoint)controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( evt->IsAction( &ACTIONS::cancelInteractive ) || evt->IsActivate() || evt->IsCancel() )
{
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
SCH_ITEM* item = nullptr;
if( !m_frame->GetScreen()->GetItem( cursorPos, 0, aType ) )
{
switch( aType )
{
case SCH_NO_CONNECT_T: item = m_frame->AddNoConnect( cursorPos ); break;
case SCH_JUNCTION_T: item = m_frame->AddJunction( cursorPos ); break;
case SCH_BUS_WIRE_ENTRY_T: item = m_frame->CreateBusWireEntry(); break;
case SCH_BUS_BUS_ENTRY_T: item = m_frame->CreateBusBusEntry(); break;
default: wxFAIL_MSG( "doSingleClickPlace(): unknown type" );
}
}
if( item )
{
m_frame->SetRepeatItem( item );
m_frame->GetScreen()->SetCurItem( item );
}
}
else if( evt->IsClick( BUT_RIGHT ) )
{
// JEY TODO
// m_menu.ShowContextMenu( selTool->GetSelection() );
}
}
m_frame->SetNoToolSelected();
return 0;
}
int SCH_EDITOR_CONTROL::PlaceLabel( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_LABEL_BUTT, wxCURSOR_PENCIL, _( "Add net label" ) );
return doTwoClickPlace( SCH_LABEL_T );
}
int SCH_EDITOR_CONTROL::PlaceGlobalLabel( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_GLOBALLABEL_BUTT, wxCURSOR_PENCIL, _( "Add global label" ) );
return doTwoClickPlace( SCH_GLOBAL_LABEL_T );
}
int SCH_EDITOR_CONTROL::PlaceHierarchicalLabel( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_HIERLABEL_BUTT, wxCURSOR_PENCIL, _( "Add hierarchical label" ) );
return doTwoClickPlace( SCH_HIER_LABEL_T );
}
int SCH_EDITOR_CONTROL::PlaceSchematicText( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_TEXT_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) );
return doTwoClickPlace( SCH_TEXT_T );
}
int SCH_EDITOR_CONTROL::PlaceImage( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_ADD_IMAGE_BUTT, wxCURSOR_PENCIL, _( "Add image" ) );
return doTwoClickPlace( SCH_BITMAP_T );
}
int SCH_EDITOR_CONTROL::doTwoClickPlace( KICAD_T aType )
{
KIGFX::VIEW_CONTROLS* controls = getViewControls();
VECTOR2I cursorPos = controls->GetCursorPosition();
KIGFX::SCH_VIEW* view = static_cast<KIGFX::SCH_VIEW*>( getView() );
SCH_ITEM* item = nullptr;
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
controls->ShowCursor( true );
controls->SetSnapping( true );
Activate();
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
{
cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( evt->IsAction( &ACTIONS::cancelInteractive ) || evt->IsActivate() || evt->IsCancel() )
{
if( item )
{
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
getModel<SCH_SCREEN>()->SetCurItem( nullptr );
view->ClearPreview();
view->ClearHiddenFlags();
delete item;
item = nullptr;
}
else
break;
if( evt->IsActivate() ) // now finish unconditionally
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
if( !item )
{
m_frame->SetRepeatItem( NULL );
m_frame->GetCanvas()->SetIgnoreMouseEvents( true );
switch( aType )
{
case SCH_LABEL_T: item = m_frame->CreateNewText( LAYER_LOCLABEL ); break;
case SCH_HIER_LABEL_T: item = m_frame->CreateNewText( LAYER_HIERLABEL ); break;
case SCH_GLOBAL_LABEL_T: item = m_frame->CreateNewText( LAYER_GLOBLABEL ); break;
case SCH_TEXT_T: item = m_frame->CreateNewText( LAYER_NOTES ); break;
case SCH_BITMAP_T: item = m_frame->CreateNewImage(); break;
default: wxFAIL_MSG( "doTwoClickPlace(): unknown type" );
}
// Restore cursor after dialog
m_frame->GetCanvas()->MoveCursorToCrossHair();
if( item )
{
MSG_PANEL_ITEMS items;
item->GetMsgPanelInfo( m_frame->GetUserUnits(), items );
m_frame->SetMsgPanel( items );
item->SetFlags( IS_MOVED );
view->ClearPreview();
view->AddToPreview( item->Clone() );
}
controls->SetCursorPosition( cursorPos, false );
}
else
{
view->ClearPreview();
m_frame->AddItemToScreen( item );
item = nullptr;
}
}
else if( evt->IsClick( BUT_RIGHT ) )
{
// JEY TODO
// m_menu.ShowContextMenu( selTool->GetSelection() );
}
else if( item && ( evt->IsAction( &SCH_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{
item->SetPosition( (wxPoint)cursorPos );
view->ClearPreview();
view->AddToPreview( item->Clone() );
}
// Enable autopanning and cursor capture only when there is a module to be placed
controls->SetAutoPan( !!item );
controls->CaptureCursor( !!item );
}
m_frame->SetNoToolSelected();
return 0;
}
void SCH_EDITOR_CONTROL::setTransitions()
{
/*
@ -436,4 +696,13 @@ void SCH_EDITOR_CONTROL::setTransitions()
Go( &SCH_EDITOR_CONTROL::PlaceSymbol, SCH_ACTIONS::placeSymbol.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::PlacePower, SCH_ACTIONS::placePower.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::PlaceNoConnect, SCH_ACTIONS::placeNoConnect.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::PlaceJunction, SCH_ACTIONS::placeJunction.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::PlaceBusWireEntry, SCH_ACTIONS::placeBusWireEntry.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::PlaceBusBusEntry, SCH_ACTIONS::placeBusBusEntry.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::PlaceLabel, SCH_ACTIONS::placeLabel.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::PlaceHierarchicalLabel,SCH_ACTIONS::placeHierarchicalLabel.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::PlaceGlobalLabel, SCH_ACTIONS::placeGlobalLabel.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::PlaceSchematicText, SCH_ACTIONS::placeSchematicText.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::PlaceImage, SCH_ACTIONS::placeImage.MakeEvent() );
}

View File

@ -51,19 +51,8 @@ public:
/// @copydoc TOOL_INTERACTIVE::Init()
bool Init() override;
/**
* Function PlaceComponent()
* Displays a dialog to select a module to be added and allows the user to set its position.
*/
int PlaceComponent( const TOOL_EVENT& aEvent );
///> Toggles 'lock' property for selected items.
int ToggleLockSelected( const TOOL_EVENT& aEvent );
///> Locks selected items.
int LockSelected( const TOOL_EVENT& aEvent );
///> Unlocks selected items.
int UnlockSelected( const TOOL_EVENT& aEvent );
///> Reacts to selection change in pcbnew.
@ -72,22 +61,35 @@ public:
///> Notifies pcbnew about the selected item.
int CrossProbeSchToPcb( const TOOL_EVENT& aEvent );
///> Highlights net belonging to the item under the cursor.
///> Highlights net under the cursor.
int HighlightNet( const TOOL_EVENT& aEvent );
///> Highlight all items which match the frame's SelectedNetName.
///> Highlights frame's SelectedNetName.
int HighlightNetSelection( const TOOL_EVENT& aEvent );
///> Launches a tool to pick the item whose net is going to be highlighted.
///> Launches a tool to highlight nets.
int HighlightNetCursor( const TOOL_EVENT& aEvent );
int PlaceSymbol( const TOOL_EVENT& aEvent );
int PlacePower( const TOOL_EVENT& aEvent );
int PlaceNoConnect( const TOOL_EVENT& aEvent );
int PlaceJunction( const TOOL_EVENT& aEvent );
int PlaceBusWireEntry( const TOOL_EVENT& aEvent );
int PlaceBusBusEntry( const TOOL_EVENT& aEvent );
int PlaceLabel( const TOOL_EVENT& aEvent );
int PlaceGlobalLabel( const TOOL_EVENT& aEvent );
int PlaceHierarchicalLabel( const TOOL_EVENT& aEvent );
int PlaceSchematicText( const TOOL_EVENT& aEvent );
int PlaceImage( const TOOL_EVENT& aEvent );
private:
int placeComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER* aFilter,
SCH_BASE_FRAME::HISTORY_LIST aHistoryList );
int doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER* aFilter,
SCH_BASE_FRAME::HISTORY_LIST aHistoryList );
int doSingleClickPlace( KICAD_T aType );
int doTwoClickPlace( KICAD_T aType );
///> Sets up handlers for various events.
void setTransitions() override;

View File

@ -114,7 +114,7 @@ enum KICAD_T
SCH_TEXT_T,
SCH_LABEL_T,
SCH_GLOBAL_LABEL_T,
SCH_HIERARCHICAL_LABEL_T,
SCH_HIER_LABEL_T,
SCH_FIELD_T,
SCH_COMPONENT_T,
SCH_SHEET_PIN_T,