Implement properties dialogs in modern toolset.
This commit is contained in:
parent
9e2bbcb8b6
commit
2bd4a1b58c
|
@ -22,10 +22,6 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file sch_collectors.cpp
|
||||
*/
|
||||
|
||||
#include <macros.h>
|
||||
#include <trace_helpers.h>
|
||||
|
||||
|
@ -92,27 +88,6 @@ const KICAD_T SCH_COLLECTOR::EditableItems[] = {
|
|||
EOT
|
||||
};
|
||||
|
||||
const KICAD_T SCH_COLLECTOR::CmpFieldValueOnly[] = {
|
||||
SCH_FIELD_LOCATE_VALUE_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
const KICAD_T SCH_COLLECTOR::CmpFieldReferenceOnly[] = {
|
||||
SCH_FIELD_LOCATE_REFERENCE_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
const KICAD_T SCH_COLLECTOR::CmpFieldFootprintOnly[] = {
|
||||
SCH_FIELD_LOCATE_FOOTPRINT_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
const KICAD_T SCH_COLLECTOR::CmpFieldDatasheetOnly[] = {
|
||||
SCH_FIELD_LOCATE_DATASHEET_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T SCH_COLLECTOR::MovableItems[] = {
|
||||
SCH_MARKER_T,
|
||||
SCH_JUNCTION_T,
|
||||
|
@ -164,25 +139,6 @@ const KICAD_T SCH_COLLECTOR::RotatableItems[] = {
|
|||
};
|
||||
|
||||
|
||||
const KICAD_T SCH_COLLECTOR::ParentItems[] = {
|
||||
SCH_MARKER_T,
|
||||
SCH_JUNCTION_T,
|
||||
SCH_NO_CONNECT_T,
|
||||
SCH_BUS_BUS_ENTRY_T,
|
||||
SCH_BUS_WIRE_ENTRY_T,
|
||||
SCH_LINE_T,
|
||||
SCH_TEXT_T,
|
||||
SCH_LABEL_T,
|
||||
SCH_GLOBAL_LABEL_T,
|
||||
SCH_HIER_LABEL_T,
|
||||
SCH_COMPONENT_T,
|
||||
SCH_SHEET_PIN_T,
|
||||
SCH_SHEET_T,
|
||||
SCH_BITMAP_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T SCH_COLLECTOR::ComponentsOnly[] = {
|
||||
SCH_COMPONENT_T,
|
||||
EOT
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2011-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2011-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
|
||||
|
@ -22,10 +22,6 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file sch_collectors.h
|
||||
*/
|
||||
|
||||
#ifndef _SCH_COLLECTORS_H_
|
||||
#define _SCH_COLLECTORS_H_
|
||||
|
||||
|
@ -42,90 +38,17 @@
|
|||
class SCH_COLLECTOR : public COLLECTOR
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* A scan list for all schematic items.
|
||||
*/
|
||||
static const KICAD_T AllItems[];
|
||||
|
||||
/**
|
||||
* A scan list for all editable schematic items.
|
||||
*/
|
||||
static const KICAD_T EditableItems[];
|
||||
|
||||
/**
|
||||
* A scan list for a specific editable field: Value.
|
||||
*/
|
||||
static const KICAD_T CmpFieldValueOnly[];
|
||||
|
||||
/**
|
||||
* A scan list for a specific editable field: Reference.
|
||||
*/
|
||||
static const KICAD_T CmpFieldReferenceOnly[];
|
||||
|
||||
/**
|
||||
* A scan list for a specific editable field: Footprint.
|
||||
*/
|
||||
static const KICAD_T CmpFieldFootprintOnly[];
|
||||
|
||||
/**
|
||||
* A scan list for a specific editable field: Datasheet.
|
||||
*/
|
||||
static const KICAD_T CmpFieldDatasheetOnly[];
|
||||
|
||||
/**
|
||||
* A scan list for all movable schematic items.
|
||||
*/
|
||||
static const KICAD_T MovableItems[];
|
||||
|
||||
/**
|
||||
* A scan list for all draggable schematic items.
|
||||
*/
|
||||
static const KICAD_T DraggableItems[];
|
||||
|
||||
/**
|
||||
* A scan list for all rotatable schematic items.
|
||||
*/
|
||||
static const KICAD_T RotatableItems[];
|
||||
|
||||
/**
|
||||
* A scan list for only parent schematic items.
|
||||
*/
|
||||
static const KICAD_T ParentItems[];
|
||||
|
||||
/**
|
||||
* A scan list for all schematic items except pins.
|
||||
*/
|
||||
static const KICAD_T AllItemsButPins[];
|
||||
|
||||
/**
|
||||
* A scan list for schematic component items only.
|
||||
*/
|
||||
static const KICAD_T ComponentsOnly[];
|
||||
|
||||
/**
|
||||
* A scan list for schematic sheet items only.
|
||||
*/
|
||||
static const KICAD_T SheetsOnly[];
|
||||
|
||||
/**
|
||||
* A scan list for schematic sheet and sheet label items.
|
||||
*/
|
||||
static const KICAD_T SheetsAndSheetLabels[];
|
||||
|
||||
/**
|
||||
* A scan list for schematic items that can be mirrored.
|
||||
*/
|
||||
static const KICAD_T OrientableItems[];
|
||||
|
||||
/**
|
||||
* A scan list for schematic items that can be copied/duplicated.
|
||||
*/
|
||||
static const KICAD_T CopyableItems[];
|
||||
|
||||
/**
|
||||
* A scan list for schematic items that react to a double-click.
|
||||
*/
|
||||
static const KICAD_T DoubleClickItems[];
|
||||
|
||||
/**
|
||||
|
|
|
@ -282,12 +282,9 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
|||
#endif /* KICAD_SPICE */
|
||||
|
||||
EVT_MENU( ID_CANCEL_CURRENT_COMMAND, SCH_EDIT_FRAME::OnCancelCurrentCommand )
|
||||
EVT_MENU_RANGE( ID_SCH_EDIT_ITEM, ID_SCH_EDIT_COMPONENT_FOOTPRINT,
|
||||
SCH_EDIT_FRAME::OnEditItem )
|
||||
EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
|
||||
SCH_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_MENU( ID_SCH_UNFOLD_BUS, SCH_EDIT_FRAME::OnUnfoldBusHotkey )
|
||||
EVT_MENU( ID_POPUP_SCH_DISPLAYDOC_CMP, SCH_EDIT_FRAME::OnEditItem )
|
||||
|
||||
EVT_MENU( ID_MENU_CANVAS_CAIRO, SCH_EDIT_FRAME::OnSwitchCanvas )
|
||||
EVT_MENU( ID_MENU_CANVAS_OPENGL, SCH_EDIT_FRAME::OnSwitchCanvas )
|
||||
|
@ -303,9 +300,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
|||
EVT_MENU_RANGE( ID_POPUP_SCH_CHANGE_TYPE_TEXT, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT,
|
||||
SCH_EDIT_FRAME::OnConvertTextType )
|
||||
|
||||
// Multple item selection context menu commands.
|
||||
EVT_MENU_RANGE( ID_SELECT_ITEM_START, ID_SELECT_ITEM_END, SCH_EDIT_FRAME::OnSelectItem )
|
||||
|
||||
/* Handle user interface update events. */
|
||||
EVT_UPDATE_UI( wxID_PASTE, SCH_EDIT_FRAME::OnUpdatePaste )
|
||||
EVT_UPDATE_UI( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnUpdateHiddenPins )
|
||||
|
@ -1237,21 +1231,6 @@ void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMod
|
|||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
|
||||
{
|
||||
int id = aEvent.GetId();
|
||||
int index = id - ID_SELECT_ITEM_START;
|
||||
|
||||
if( (id >= ID_SELECT_ITEM_START && id <= ID_SELECT_ITEM_END)
|
||||
&& (index >= 0 && index < m_collectedItems.GetCount()) )
|
||||
{
|
||||
SCH_ITEM* item = m_collectedItems[index];
|
||||
m_canvas->SetAbortRequest( false );
|
||||
GetScreen()->SetCurItem( item );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SCH_EDIT_FRAME::isAutoSaveRequired() const
|
||||
{
|
||||
// In case this event happens before g_RootSheet is initialized which does happen
|
||||
|
|
|
@ -787,16 +787,6 @@ private:
|
|||
*/
|
||||
void OnAutoplaceFields( wxCommandEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Handle the #ID_SCH_MOVE_ITEM event used to move schematic items.
|
||||
*/
|
||||
void OnMoveItem( wxCommandEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Handle the #ID_SCH_EDIT_ITEM event used to edit schematic items.
|
||||
*/
|
||||
void OnEditItem( wxCommandEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Handle the #ID_POPUP_SCH_SELECT_ON_PCB event used to select items in Pcbnew
|
||||
* based on the sheet they are placed on.
|
||||
|
@ -858,8 +848,6 @@ private:
|
|||
void OnPreferencesOptions( wxCommandEvent& event );
|
||||
void OnCancelCurrentCommand( wxCommandEvent& aEvent );
|
||||
|
||||
void OnSelectItem( wxCommandEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Command event handler for duplicating the item at the current location.
|
||||
*/
|
||||
|
@ -906,9 +894,6 @@ private:
|
|||
*/
|
||||
void NormalizeSchematicOnFirstLoad();
|
||||
|
||||
// Text, label, glabel
|
||||
void EditSchematicText( SCH_TEXT* TextStruct );
|
||||
|
||||
/**
|
||||
* Command event handler to change a text type to another one.
|
||||
*
|
||||
|
@ -917,20 +902,20 @@ private:
|
|||
*/
|
||||
void OnConvertTextType( wxCommandEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Creates a new segment ( WIRE, BUS ) or terminates the current segment in progress.
|
||||
*
|
||||
* If the end of the current segment is on a different segment, place a junction if needed
|
||||
* and terminates the command. If the end of the current segment is on a pin, terminate
|
||||
* the command. In all other cases starts a new segment.
|
||||
*/
|
||||
void BeginSegment( int type );
|
||||
|
||||
/**
|
||||
* Erase the last segment at the current mouse position.
|
||||
*/
|
||||
void DeleteConnection( bool DeleteFullConnection );
|
||||
|
||||
// Hierarchical Sheet & PinSheet
|
||||
void InstallHierarchyFrame( wxPoint& pos );
|
||||
|
||||
public:
|
||||
/**
|
||||
* Launches the "Edit Text/Label" dialog
|
||||
*/
|
||||
void EditSchematicText( SCH_TEXT* aText );
|
||||
|
||||
/**
|
||||
* Launches the "Edit Image" dialog to modify an image
|
||||
* @param aItem Pointer to the image item to modify
|
||||
|
@ -938,9 +923,6 @@ private:
|
|||
*/
|
||||
bool EditImage( SCH_BITMAP* aItem );
|
||||
|
||||
// Hierarchical Sheet & PinSheet
|
||||
void InstallHierarchyFrame( wxPoint& pos );
|
||||
|
||||
/**
|
||||
* Function EditLine
|
||||
* displays the dialog for editing the parameters of \a aLine.
|
||||
|
@ -950,7 +932,6 @@ private:
|
|||
*/
|
||||
int EditLine( SCH_LINE* aLine, bool aRedraw );
|
||||
|
||||
public:
|
||||
/**
|
||||
* Edit an existing sheet or add a new sheet to the schematic.
|
||||
*
|
||||
|
@ -1069,10 +1050,6 @@ public:
|
|||
*/
|
||||
void OrientComponent( COMPONENT_ORIENTATION_T aOrientation = CMP_NORMAL );
|
||||
|
||||
private:
|
||||
void OnSelectUnit( wxCommandEvent& aEvent );
|
||||
void ConvertPart( SCH_COMPONENT* DrawComponent );
|
||||
|
||||
/**
|
||||
* Display the edit field dialog to edit the parameters of \a aField.
|
||||
*
|
||||
|
@ -1080,6 +1057,10 @@ private:
|
|||
*/
|
||||
void EditComponentFieldText( SCH_FIELD* aField );
|
||||
|
||||
private:
|
||||
void OnSelectUnit( wxCommandEvent& aEvent );
|
||||
void ConvertPart( SCH_COMPONENT* DrawComponent );
|
||||
|
||||
/**
|
||||
* Paste a list of items from the block stack.
|
||||
*/
|
||||
|
|
|
@ -777,6 +777,7 @@ void SCH_SCREEN::SelectBlockItems()
|
|||
}
|
||||
|
||||
|
||||
// JEY TODO: obsolete once LibEdit is moved to modern toolset
|
||||
int SCH_SCREEN::UpdatePickList()
|
||||
{
|
||||
ITEM_PICKER picker;
|
||||
|
|
|
@ -343,169 +343,6 @@ void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent )
|
|||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
|
||||
{
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
|
||||
if( item == NULL )
|
||||
{
|
||||
// If we didn't get here by a hot key, then something has gone wrong.
|
||||
if( aEvent.GetInt() == 0 )
|
||||
return;
|
||||
|
||||
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();
|
||||
|
||||
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
||||
|
||||
// Set the locat filter, according to the edit command
|
||||
const KICAD_T* filterList = SCH_COLLECTOR::EditableItems;
|
||||
const KICAD_T* filterListAux = NULL;
|
||||
|
||||
switch( aEvent.GetId() )
|
||||
{
|
||||
case ID_SCH_EDIT_COMPONENT_REFERENCE:
|
||||
filterList = SCH_COLLECTOR::CmpFieldReferenceOnly;
|
||||
filterListAux = SCH_COLLECTOR::ComponentsOnly;
|
||||
break;
|
||||
|
||||
case ID_SCH_EDIT_COMPONENT_VALUE:
|
||||
filterList = SCH_COLLECTOR::CmpFieldValueOnly;
|
||||
filterListAux = SCH_COLLECTOR::ComponentsOnly;
|
||||
break;
|
||||
|
||||
case ID_SCH_EDIT_COMPONENT_FOOTPRINT:
|
||||
filterList = SCH_COLLECTOR::CmpFieldFootprintOnly;
|
||||
filterListAux = SCH_COLLECTOR::ComponentsOnly;
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_DISPLAYDOC_CMP:
|
||||
filterList = SCH_COLLECTOR::CmpFieldDatasheetOnly;
|
||||
filterListAux = SCH_COLLECTOR::ComponentsOnly;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
item = selTool->SelectPoint( data->GetPosition(), filterList );
|
||||
|
||||
// If no item found, and if an auxiliary filter exists, try to use it
|
||||
if( !item && filterListAux )
|
||||
item = selTool->SelectPoint( data->GetPosition(), filterListAux );
|
||||
|
||||
// Exit if no item found at the current location or the item is already being edited.
|
||||
if( item == NULL || item->GetEditFlags() != 0 )
|
||||
return;
|
||||
}
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
case SCH_COMPONENT_T:
|
||||
{
|
||||
switch( aEvent.GetId() )
|
||||
{
|
||||
case ID_SCH_EDIT_COMPONENT_REFERENCE:
|
||||
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( REFERENCE ) );
|
||||
break;
|
||||
|
||||
case ID_SCH_EDIT_COMPONENT_VALUE:
|
||||
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( VALUE ) );
|
||||
break;
|
||||
|
||||
case ID_SCH_EDIT_COMPONENT_FOOTPRINT:
|
||||
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( FOOTPRINT ) );
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_DISPLAYDOC_CMP:
|
||||
{
|
||||
wxString text = static_cast<SCH_COMPONENT*>( item )->GetField( DATASHEET )->GetText();
|
||||
|
||||
if( !text.IsEmpty() )
|
||||
GetAssociatedDocument( this, text );
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_SCH_EDIT_ITEM:
|
||||
EditComponent( (SCH_COMPONENT*) item );
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( wxString::Format( wxT( "Invalid schematic component edit command ID %d" ),
|
||||
aEvent.GetId() ) );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SCH_SHEET_T:
|
||||
{
|
||||
bool doClearAnnotation;
|
||||
bool doRefresh = false;
|
||||
// Keep trace of existing sheet paths. EditSheet() can modify this list
|
||||
SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
|
||||
|
||||
doRefresh = EditSheet( (SCH_SHEET*) item, g_CurrentSheet, &doClearAnnotation );
|
||||
|
||||
if( doClearAnnotation ) // happens when the current sheet load a existing file
|
||||
{ // we must clear "new" components annotation
|
||||
SCH_SCREENS screensList( g_RootSheet );
|
||||
// We clear annotation of new sheet paths here:
|
||||
screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
|
||||
// Clear annotation of g_CurrentSheet itself, because its sheetpath
|
||||
// is not a new path, but components managed by its sheet path must have
|
||||
// their annotation cleared, becuase they are new:
|
||||
((SCH_SHEET*) item)->GetScreen()->ClearAnnotation( g_CurrentSheet );
|
||||
}
|
||||
|
||||
if( doRefresh )
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
break;
|
||||
|
||||
case SCH_SHEET_PIN_T:
|
||||
EditSheetPin( (SCH_SHEET_PIN*) item, true );
|
||||
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_FIELD_T:
|
||||
EditComponentFieldText( (SCH_FIELD*) 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_LINE_T: // These items have no param to edit
|
||||
EditLine( (SCH_LINE*) item, true );
|
||||
break;
|
||||
case SCH_MARKER_T:
|
||||
case SCH_JUNCTION_T:
|
||||
case SCH_NO_CONNECT_T:
|
||||
break;
|
||||
|
||||
default: // Unexpected item
|
||||
wxFAIL_MSG( wxString( "Cannot edit schematic item type " ) + item->GetClass() );
|
||||
}
|
||||
|
||||
RefreshItem( item );
|
||||
|
||||
if( item->GetEditFlags() == 0 )
|
||||
screen->SetCurItem( nullptr );
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::OnUnfoldBusHotkey( wxCommandEvent& aEvent )
|
||||
{
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
|
|
|
@ -211,6 +211,18 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
|||
|
||||
case ID_REPEAT_BUTT:
|
||||
return SCH_ACTIONS::repeatDrawItem.MakeEvent();
|
||||
|
||||
case ID_SCH_EDIT_ITEM:
|
||||
return SCH_ACTIONS::properties.MakeEvent();
|
||||
|
||||
case ID_SCH_EDIT_COMPONENT_REFERENCE:
|
||||
return SCH_ACTIONS::editReference.MakeEvent();
|
||||
|
||||
case ID_SCH_EDIT_COMPONENT_VALUE:
|
||||
return SCH_ACTIONS::editValue.MakeEvent();
|
||||
|
||||
case ID_SCH_EDIT_COMPONENT_FOOTPRINT:
|
||||
return SCH_ACTIONS::editFootprint.MakeEvent();
|
||||
}
|
||||
|
||||
return OPT<TOOL_EVENT>();
|
||||
|
|
|
@ -121,6 +121,9 @@ public:
|
|||
static TOOL_ACTION mirrorX;
|
||||
static TOOL_ACTION mirrorY;
|
||||
static TOOL_ACTION properties;
|
||||
static TOOL_ACTION editReference;
|
||||
static TOOL_ACTION editValue;
|
||||
static TOOL_ACTION editFootprint;
|
||||
static TOOL_ACTION remove;
|
||||
static TOOL_ACTION addJunction;
|
||||
static TOOL_ACTION addLabel;
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <sch_item_struct.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <list_operations.h>
|
||||
#include <eeschema_id.h>
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::move( "eeschema.InteractiveEdit.move",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MOVE_COMPONENT_OR_ITEM ),
|
||||
|
@ -75,6 +76,18 @@ TOOL_ACTION SCH_ACTIONS::properties( "eeschema.InteractiveEdit.properties",
|
|||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT ),
|
||||
_( "Properties..." ), _( "Displays item properties dialog" ), config_xpm );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::editReference( "eeschema.InteractiveEdit.editReference",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_COMPONENT_REFERENCE ),
|
||||
_( "Edit Reference..." ), _( "Displays reference field dialog" ), config_xpm );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::editValue( "eeschema.InteractiveEdit.editValue",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_COMPONENT_VALUE ),
|
||||
_( "Edit Value..." ), _( "Displays value field dialog" ), config_xpm );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::editFootprint( "eeschema.InteractiveEdit.editFootprint",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_COMPONENT_FOOTPRINT ),
|
||||
_( "Edit Footprint..." ), _( "Displays footprint field dialog" ), config_xpm );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::remove( "eeschema.InteractiveEdit.remove",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DELETE ),
|
||||
_( "Delete" ), _( "Deletes selected item(s)" ), delete_xpm );
|
||||
|
@ -952,6 +965,139 @@ int SCH_EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int SCH_EDIT_TOOL::EditField( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
static KICAD_T Nothing[] = { EOT };
|
||||
static KICAD_T CmpOrReference[] = { SCH_FIELD_LOCATE_REFERENCE_T, SCH_COMPONENT_T, EOT };
|
||||
static KICAD_T CmpOrValue[] = { SCH_FIELD_LOCATE_VALUE_T, SCH_COMPONENT_T, EOT };
|
||||
static KICAD_T CmpOrFootprint[] = { SCH_FIELD_LOCATE_FOOTPRINT_T, SCH_COMPONENT_T, EOT };
|
||||
|
||||
KICAD_T* filter = Nothing;
|
||||
|
||||
if( aEvent.IsAction( &SCH_ACTIONS::editReference ) )
|
||||
filter = CmpOrReference;
|
||||
else if( aEvent.IsAction( &SCH_ACTIONS::editValue ) )
|
||||
filter = CmpOrValue;
|
||||
else if( aEvent.IsAction( &SCH_ACTIONS::editFootprint ) )
|
||||
filter = CmpOrFootprint;
|
||||
|
||||
SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
|
||||
SELECTION& selection = selTool->RequestSelection( filter );
|
||||
SCH_ITEM* item = nullptr;
|
||||
|
||||
if( selection.GetSize() >= 1 )
|
||||
item = (SCH_ITEM*)selection.GetItem( 0 );
|
||||
|
||||
if( !item )
|
||||
return 0;
|
||||
|
||||
if( item->Type() == SCH_COMPONENT_T )
|
||||
{
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
||||
|
||||
if( aEvent.IsAction( &SCH_ACTIONS::editReference ) )
|
||||
m_frame->EditComponentFieldText( component->GetField( REFERENCE ) );
|
||||
else if( aEvent.IsAction( &SCH_ACTIONS::editValue ) )
|
||||
m_frame->EditComponentFieldText( component->GetField( VALUE ) );
|
||||
else if( aEvent.IsAction( &SCH_ACTIONS::editFootprint ) )
|
||||
m_frame->EditComponentFieldText( component->GetField( FOOTPRINT ) );
|
||||
}
|
||||
else if( item->Type() == SCH_FIELD_T )
|
||||
{
|
||||
m_frame->EditComponentFieldText( (SCH_FIELD*) item );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
|
||||
SELECTION& selection = selTool->RequestSelection( SCH_COLLECTOR::EditableItems );
|
||||
SCH_ITEM* item = nullptr;
|
||||
|
||||
if( selection.GetSize() >= 1 )
|
||||
item = (SCH_ITEM*)selection.GetItem( 0 );
|
||||
|
||||
if( !item )
|
||||
return 0;
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
case SCH_COMPONENT_T:
|
||||
m_frame->EditComponent( (SCH_COMPONENT*) item );
|
||||
break;
|
||||
|
||||
case SCH_SHEET_T:
|
||||
{
|
||||
bool doClearAnnotation;
|
||||
bool doRefresh = false;
|
||||
// Keep track of existing sheet paths. EditSheet() can modify this list
|
||||
SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
|
||||
|
||||
doRefresh = m_frame->EditSheet( (SCH_SHEET*) item, g_CurrentSheet, &doClearAnnotation );
|
||||
|
||||
if( doClearAnnotation ) // happens when the current sheet load a existing file
|
||||
{ // we must clear "new" components annotation
|
||||
SCH_SCREENS screensList( g_RootSheet );
|
||||
// We clear annotation of new sheet paths here:
|
||||
screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
|
||||
// Clear annotation of g_CurrentSheet itself, because its sheetpath
|
||||
// is not a new path, but components managed by its sheet path must have
|
||||
// their annotation cleared, becuase they are new:
|
||||
((SCH_SHEET*) item)->GetScreen()->ClearAnnotation( g_CurrentSheet );
|
||||
}
|
||||
|
||||
if( doRefresh )
|
||||
m_frame->GetCanvas()->Refresh();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SCH_SHEET_PIN_T:
|
||||
m_frame->EditSheetPin( (SCH_SHEET_PIN*) item, true );
|
||||
break;
|
||||
|
||||
case SCH_TEXT_T:
|
||||
case SCH_LABEL_T:
|
||||
case SCH_GLOBAL_LABEL_T:
|
||||
case SCH_HIER_LABEL_T:
|
||||
m_frame->EditSchematicText( (SCH_TEXT*) item );
|
||||
break;
|
||||
|
||||
case SCH_FIELD_T:
|
||||
m_frame->EditComponentFieldText( (SCH_FIELD*) item );
|
||||
break;
|
||||
|
||||
case SCH_BITMAP_T:
|
||||
if( m_frame->EditImage( (SCH_BITMAP*) item ) )
|
||||
{
|
||||
// The bitmap is cached in Opengl: clear the cache in case it has become invalid
|
||||
getView()->RecacheAllItems();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SCH_LINE_T:
|
||||
m_frame->EditLine( (SCH_LINE*) item, true );
|
||||
break;
|
||||
|
||||
case SCH_MARKER_T: // These items have no properties to edit
|
||||
case SCH_JUNCTION_T:
|
||||
case SCH_NO_CONNECT_T:
|
||||
break;
|
||||
|
||||
default: // Unexpected item
|
||||
wxFAIL_MSG( wxString( "Cannot edit schematic item type " ) + item->GetClass() );
|
||||
}
|
||||
|
||||
updateView( item );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_TOOL::updateView( EDA_ITEM* aItem )
|
||||
{
|
||||
KICAD_T itemType = aItem->Type();
|
||||
|
@ -985,4 +1131,8 @@ void SCH_EDIT_TOOL::setTransitions()
|
|||
Go( &SCH_EDIT_TOOL::Mirror, SCH_ACTIONS::mirrorX.MakeEvent() );
|
||||
Go( &SCH_EDIT_TOOL::Mirror, SCH_ACTIONS::mirrorY.MakeEvent() );
|
||||
Go( &SCH_EDIT_TOOL::Remove, SCH_ACTIONS::remove.MakeEvent() );
|
||||
Go( &SCH_EDIT_TOOL::Properties, SCH_ACTIONS::properties.MakeEvent() );
|
||||
Go( &SCH_EDIT_TOOL::EditField, SCH_ACTIONS::editReference.MakeEvent() );
|
||||
Go( &SCH_EDIT_TOOL::EditField, SCH_ACTIONS::editValue.MakeEvent() );
|
||||
Go( &SCH_EDIT_TOOL::EditField, SCH_ACTIONS::editFootprint.MakeEvent() );
|
||||
}
|
||||
|
|
|
@ -64,6 +64,9 @@ public:
|
|||
int Duplicate( const TOOL_EVENT& aEvent );
|
||||
int RepeatDrawItem( const TOOL_EVENT& aEvent );
|
||||
|
||||
int Properties( const TOOL_EVENT& aEvent );
|
||||
int EditField( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Function Remove()
|
||||
*
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <sch_edit_frame.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_field.h>
|
||||
#include <view/view.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <view/view_group.h>
|
||||
|
@ -336,22 +337,38 @@ SELECTION& SCH_SELECTION_TOOL::RequestSelection( const KICAD_T aFilterList[] )
|
|||
|
||||
return m_selection;
|
||||
}
|
||||
else
|
||||
else // Trim an existing selection by aFilterList
|
||||
{
|
||||
// Trim an existing selection by aFilterList
|
||||
|
||||
SELECTION originalSelection( m_selection );
|
||||
|
||||
for( EDA_ITEM* item : originalSelection )
|
||||
for( int i = m_selection.GetSize() - 1; i >= 0; --i )
|
||||
{
|
||||
KICAD_T matchType;
|
||||
bool match = false;
|
||||
SCH_ITEM* item = (SCH_ITEM*) m_selection.GetItem( i );
|
||||
KICAD_T matchType;
|
||||
bool match = false;
|
||||
|
||||
for( const KICAD_T* p = aFilterList; (matchType = *p) != EOT && !match; ++p )
|
||||
match = ( item->Type() == matchType );
|
||||
if( item->Type() == SCH_FIELD_T )
|
||||
{
|
||||
SCH_FIELD* field = (SCH_FIELD*) item;
|
||||
|
||||
for( const KICAD_T* p = aFilterList; (matchType = *p) != EOT && !match; ++p )
|
||||
{
|
||||
switch( matchType )
|
||||
{
|
||||
case SCH_FIELD_LOCATE_REFERENCE_T: match = field->GetId() == REFERENCE; break;
|
||||
case SCH_FIELD_LOCATE_VALUE_T: match = field->GetId() == VALUE; break;
|
||||
case SCH_FIELD_LOCATE_FOOTPRINT_T: match = field->GetId() == FOOTPRINT; break;
|
||||
|
||||
default: match = ( item->Type() == matchType ); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( const KICAD_T* p = aFilterList; (matchType = *p) != EOT && !match; ++p )
|
||||
match = ( item->Type() == matchType );
|
||||
}
|
||||
|
||||
if( !match )
|
||||
toggleSelection( static_cast<SCH_ITEM*>( item ) );
|
||||
toggleSelection( item );
|
||||
}
|
||||
|
||||
return m_selection;
|
||||
|
@ -902,13 +919,13 @@ bool SCH_SELECTION_TOOL::selectionContains( const VECTOR2I& aPoint ) const
|
|||
|
||||
void SCH_SELECTION_TOOL::setTransitions()
|
||||
{
|
||||
Go( &SCH_SELECTION_TOOL::Main, SCH_ACTIONS::selectionActivate.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::ClearSelection, SCH_ACTIONS::selectionClear.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::SelectItem, SCH_ACTIONS::selectItem.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::SelectItems, SCH_ACTIONS::selectItems.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::UnselectItem, SCH_ACTIONS::unselectItem.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::UnselectItems, SCH_ACTIONS::unselectItems.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::SelectionMenu, SCH_ACTIONS::selectionMenu.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::Main, SCH_ACTIONS::selectionActivate.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::ClearSelection, SCH_ACTIONS::selectionClear.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::SelectItem, SCH_ACTIONS::selectItem.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::SelectItems, SCH_ACTIONS::selectItems.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::UnselectItem, SCH_ACTIONS::unselectItem.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::UnselectItems, SCH_ACTIONS::unselectItems.MakeEvent() );
|
||||
Go( &SCH_SELECTION_TOOL::SelectionMenu, SCH_ACTIONS::selectionMenu.MakeEvent() );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue