Move place symbol to modern toolset.

This commit is contained in:
Jeff Young 2019-04-15 15:34:58 +01:00
parent 4d3e86d795
commit 32c86a4ca4
14 changed files with 318 additions and 173 deletions

View File

@ -244,6 +244,7 @@ set( EESCHEMA_SRCS
tools/sch_actions.cpp
tools/sch_picker_tool.cpp
tools/sch_selection_tool.cpp
tools/selection.cpp
)

View File

@ -46,7 +46,7 @@ SCH_BUS_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusBusEntry()
busEntry->SetFlags( IS_NEW );
GetScreen()->SetCurItem( busEntry );
addCurrentItemToScreen();
AddItemToScreen( busEntry );
return busEntry;
}
@ -57,7 +57,7 @@ SCH_BUS_WIRE_ENTRY* SCH_EDIT_FRAME::CreateBusWireEntry()
busEntry->SetFlags( IS_NEW );
GetScreen()->SetCurItem( busEntry );
addCurrentItemToScreen();
AddItemToScreen( busEntry );
return busEntry;
}

View File

@ -45,7 +45,7 @@ bool PANEL_EESCHEMA_SETTINGS::TransferDataToWindow()
m_spinRepeatLabel->SetValue( m_frame->GetRepeatDeltaLabel() );
m_checkHVOrientation->SetValue( m_frame->GetForceHVLines() );
m_footprintPreview->SetValue( m_frame->GetFootprintPreview() );
m_footprintPreview->SetValue( m_frame->GetShowFootprintPreviews() );
m_checkAutoplaceFields->SetValue( m_frame->GetAutoplaceFields() );
m_checkAutoplaceJustify->SetValue( m_frame->GetAutoplaceJustify() );
@ -72,7 +72,7 @@ bool PANEL_EESCHEMA_SETTINGS::TransferDataFromWindow()
m_frame->SetRepeatDeltaLabel( m_spinRepeatLabel->GetValue() );
m_frame->SetForceHVLines( m_checkHVOrientation->GetValue() );
m_frame->SetFootprintPreview( m_footprintPreview->GetValue() );
m_frame->SetShowFootprintPreviews( m_footprintPreview->GetValue() );
m_frame->SetAutoplaceFields( m_checkAutoplaceFields->GetValue() );
m_frame->SetAutoplaceJustify( m_checkAutoplaceJustify->GetValue() );

View File

@ -209,72 +209,6 @@ SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibTree(
}
SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( const SCHLIB_FILTER* aFilter,
SCH_BASE_FRAME::HISTORY_LIST& aHistoryList,
bool aAllowBrowser )
{
wxString msg;
SetRepeatItem( NULL );
m_canvas->SetIgnoreMouseEvents( true );
auto sel = SelectComponentFromLibTree( aFilter, aHistoryList, aAllowBrowser, 1, 1,
m_footprintPreview );
if( !sel.LibId.IsValid() )
{
m_canvas->SetIgnoreMouseEvents( false );
m_canvas->MoveCursorToCrossHair();
return NULL;
}
m_canvas->SetIgnoreMouseEvents( false );
m_canvas->MoveCursorToCrossHair();
wxString libsource; // the library name to use. If empty, load from any lib
if( aFilter )
libsource = aFilter->GetLibSource();
LIB_ID libId = sel.LibId;
LIB_PART* part = GetLibPart( libId, true );
if( !part )
return NULL;
SCH_COMPONENT* component = new SCH_COMPONENT( *part, libId, g_CurrentSheet,
sel.Unit, sel.Convert,
GetCrossHairPosition(), true );
// Be sure the link to the corresponding LIB_PART is OK:
component->Resolve( *Prj().SchSymbolLibTable() );
// Set any fields that have been modified
for( auto const& i : sel.Fields )
{
auto field = component->GetField( i.first );
if( field )
field->SetText( i.second );
}
MSG_PANEL_ITEMS items;
component->GetMsgPanelInfo( m_UserUnits, items );
SetMsgPanel( items );
component->SetFlags( IS_NEW );
if( m_autoplaceFields )
component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
PrepareMoveItem( component );
return component;
}
void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation )
{
SCH_SCREEN* screen = GetScreen();
@ -292,7 +226,7 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation )
if( item->GetFlags() == 0 )
{
addCurrentItemToScreen();
AddItemToScreen( item );
SchematicCleanUp();
}

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* 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
@ -87,7 +87,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case SCH_FIELD_T:
case SCH_BITMAP_T:
case SCH_NO_CONNECT_T:
addCurrentItemToScreen();
AddItemToScreen( item );
GetCanvas()->GetView()->ClearPreview();
GetCanvas()->GetView()->ClearHiddenFlags();
return;
@ -120,7 +120,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_HIGHLIGHT_BUTT:
// JEY TODO....
// Moved to modern toolset
break;
case ID_NOCONN_BUTT:
@ -136,7 +136,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
addCurrentItemToScreen();
AddItemToScreen( item );
}
break;
@ -153,7 +153,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
addCurrentItemToScreen();
AddItemToScreen( item );
}
break;
@ -165,7 +165,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
addCurrentItemToScreen();
AddItemToScreen( item );
}
break;
@ -177,7 +177,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
addCurrentItemToScreen();
AddItemToScreen( item );
}
break;
@ -208,7 +208,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
addCurrentItemToScreen();
AddItemToScreen( item );
}
break;
@ -220,7 +220,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
addCurrentItemToScreen();
AddItemToScreen( item );
}
break;
@ -232,7 +232,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
addCurrentItemToScreen();
AddItemToScreen( item );
}
break;
@ -250,7 +250,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
addCurrentItemToScreen();
AddItemToScreen( item );
}
break;
@ -267,7 +267,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else
{
addCurrentItemToScreen();
AddItemToScreen( item );
}
break;
@ -288,36 +288,16 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
}
else if( (item->Type() == SCH_SHEET_PIN_T) && (item->GetFlags() != 0) )
{
addCurrentItemToScreen();
AddItemToScreen( item );
}
break;
case ID_SCH_PLACE_COMPONENT:
if( item_flags == 0 )
{
// ERC dialog interferes with moving items so we close it before starting
CloseErc();
GetScreen()->SetCurItem( Load_Component( NULL, s_CmpNameList, true ) );
m_canvas->SetAutoPanRequest( true );
}
else
{
addCurrentItemToScreen();
}
// Moved to modern toolset
break;
case ID_PLACE_POWER_BUTT:
if( item_flags == 0 )
{
SCHLIB_FILTER filter;
filter.FilterPowerParts( true );
GetScreen()->SetCurItem( Load_Component( &filter, s_PowerNameList, false ) );
m_canvas->SetAutoPanRequest( true );
}
else
{
addCurrentItemToScreen();
}
// Moved to modern toolset
break;
#ifdef KICAD_SPICE

View File

@ -1314,22 +1314,21 @@ bool SCH_EDIT_FRAME::isAutoSaveRequired() const
}
void SCH_EDIT_FRAME::addCurrentItemToScreen()
void SCH_EDIT_FRAME::AddItemToScreen( SCH_ITEM* aItem )
{
SCH_SCREEN* screen = GetScreen();
SCH_ITEM* item = screen->GetCurItem();
wxCHECK_RET( item != NULL, wxT( "Cannot add current item to list." ) );
wxCHECK_RET( aItem != NULL, wxT( "Cannot add current aItem to list." ) );
m_canvas->SetAutoPanRequest( false );
SCH_SHEET* parentSheet = nullptr;
SCH_COMPONENT* parentComponent = nullptr;
SCH_ITEM* undoItem = item;
SCH_ITEM* undoItem = aItem;
if( item->Type() == SCH_SHEET_PIN_T )
if( aItem->Type() == SCH_SHEET_PIN_T )
{
parentSheet = (SCH_SHEET*) item->GetParent();
parentSheet = (SCH_SHEET*) aItem->GetParent();
wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
@ -1337,9 +1336,9 @@ void SCH_EDIT_FRAME::addCurrentItemToScreen()
undoItem = parentSheet;
}
else if( item->Type() == SCH_FIELD_T )
else if( aItem->Type() == SCH_FIELD_T )
{
parentComponent = (SCH_COMPONENT*) item->GetParent();
parentComponent = (SCH_COMPONENT*) aItem->GetParent();
wxCHECK_RET( parentComponent && parentComponent->Type() == SCH_COMPONENT_T,
wxT( "Cannot place field in invalid schematic component object." ) );
@ -1347,7 +1346,7 @@ void SCH_EDIT_FRAME::addCurrentItemToScreen()
undoItem = parentComponent;
}
if( item->IsNew() )
if( aItem->IsNew() )
{
// When a new sheet is added to the hierarchy, a clear annotation can be needed
// for all new sheet paths added by the new sheet (if this sheet is loaded from
@ -1355,36 +1354,36 @@ void SCH_EDIT_FRAME::addCurrentItemToScreen()
bool doClearAnnotation = false;
SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
if( item->Type() == SCH_SHEET_T )
if( aItem->Type() == SCH_SHEET_T )
{
// Fix the size and position of the new sheet using the last values set by
// the m_mouseCaptureCallback function.
m_canvas->SetMouseCapture( NULL, NULL );
if( !EditSheet( (SCH_SHEET*)item, g_CurrentSheet, &doClearAnnotation ) )
if( !EditSheet( (SCH_SHEET*)aItem, g_CurrentSheet, &doClearAnnotation ) )
{
screen->SetCurItem( NULL );
delete item;
delete aItem;
return;
}
SetSheetNumberAndCount();
if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
AddToScreen( item );
if( !screen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
AddToScreen( aItem );
SetRepeatItem( item );
SetRepeatItem( aItem );
SaveCopyInUndoList( undoItem, UR_NEW );
}
else if( item->Type() == SCH_SHEET_PIN_T )
else if( aItem->Type() == SCH_SHEET_PIN_T )
{
// Sheet pins are owned by their parent sheet.
SaveCopyInUndoList( undoItem, UR_CHANGED ); // save the parent sheet
parentSheet->AddPin( (SCH_SHEET_PIN*) item );
parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
}
else if( item->Type() == SCH_FIELD_T )
else if( aItem->Type() == SCH_FIELD_T )
{
// Component fields are also owned by their parent, but new component fields
// are handled elsewhere.
@ -1392,10 +1391,10 @@ void SCH_EDIT_FRAME::addCurrentItemToScreen()
}
else
{
if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
AddToScreen( item );
if( !screen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
AddToScreen( aItem );
SetRepeatItem( item );
SetRepeatItem( aItem );
SaveCopyInUndoList( undoItem, UR_NEW );
}
@ -1415,19 +1414,19 @@ void SCH_EDIT_FRAME::addCurrentItemToScreen()
SaveUndoItemInUndoList( undoItem );
}
item->ClearFlags();
aItem->ClearFlags();
screen->SetModify();
screen->SetCurItem( NULL );
m_canvas->SetMouseCapture( NULL, NULL );
m_canvas->EndMouseCapture();
RefreshItem( item );
RefreshItem( aItem );
if( item->IsConnectable() )
if( aItem->IsConnectable() )
{
std::vector< wxPoint > pts;
item->GetConnectionPoints( pts );
aItem->GetConnectionPoints( pts );
for( auto i = pts.begin(); i != pts.end(); i++ )
{

View File

@ -220,12 +220,6 @@ protected:
*/
virtual bool isAutoSaveRequired() const override;
/**
* Add the item currently being edited to the schematic and adds the changes to
* the undo/redo container.
*/
void addCurrentItemToScreen();
void updateFindReplaceView( wxFindDialogEvent& aEvent );
void backAnnotateFootprints( const std::string& aChangedSetOfReferences );
@ -257,8 +251,8 @@ public:
bool GetShowAllPins() const { return m_showAllPins; }
void SetShowAllPins( bool aEnable ) { m_showAllPins = aEnable; }
bool GetFootprintPreview() const { return m_footprintPreview; }
void SetFootprintPreview( bool aEnable ) { m_footprintPreview = aEnable; }
bool GetShowFootprintPreviews() const { return m_footprintPreview; }
void SetShowFootprintPreviews( bool aEnable ) { m_footprintPreview = aEnable; }
bool GetAutoplaceFields() const { return m_autoplaceFields; }
void SetAutoplaceFields( bool aEnable ) { m_autoplaceFields = aEnable; }
@ -406,6 +400,12 @@ public:
void OnSelectOptionToolbar( wxCommandEvent& event );
double BestZoom() override;
/**
* Add the item currently being edited to the schematic and adds the changes to
* the undo/redo container.
*/
void AddItemToScreen( SCH_ITEM* aItem );
/**
* Check the schematic at \a aPosition in logical (drawing) units for a item
* matching the types in \a aFilterList.
@ -1225,27 +1225,6 @@ public:
int GetLabelIncrement() const { return m_repeatLabelDelta; }
private:
/**
* Load a symbol library and places it on the current schematic.
*.
* if libname != "", search in lib "libname"
* else search in all loaded libs
*
* @param aFilter is a filter to pass the allowed lib names list, or library name
* to load the component from and/or some other filters
* if NULL, no filtering.
* @param aHistoryList list remembering recently used component names.
* @param aUseLibBrowser is the flag to determine if the library browser should be launched.
* @return a pointer the SCH_COMPONENT object selected or NULL if no component was selected.
* (TODO(hzeller): This really should be a class doing history, but didn't
* want to change too much while other refactoring is going on)
*/
SCH_COMPONENT* Load_Component( const SCHLIB_FILTER* aFilter,
SCH_BASE_FRAME::HISTORY_LIST& aHistoryList,
bool aUseLibBrowser );
/**
* Display the edit component dialog to edit the parameters of \a aComponent.
*

View File

@ -222,7 +222,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_END_SHEET:
m_canvas->MoveCursorToCrossHair();
addCurrentItemToScreen();
AddItemToScreen( item );
break;
case ID_POPUP_SCH_RESIZE_SHEET:
@ -350,7 +350,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
item = screen->GetCurItem();
if( item )
addCurrentItemToScreen();
AddItemToScreen( item );
break;

View File

@ -75,6 +75,12 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
case ID_HIGHLIGHT_NET:
return SCH_ACTIONS::highlightNet.MakeEvent();
case ID_SCH_PLACE_COMPONENT:
return SCH_ACTIONS::placeSymbol.MakeEvent();
case ID_PLACE_POWER_BUTT:
return SCH_ACTIONS::placePower.MakeEvent();
}
return OPT<TOOL_EVENT>();

View File

@ -80,19 +80,26 @@ public:
static TOOL_ACTION layerChanged; // notification
*/
/// Clipboard
static TOOL_ACTION copyToClipboard;
static TOOL_ACTION pasteFromClipboard;
static TOOL_ACTION cutToClipboard;
// Locking
static TOOL_ACTION toggleLock;
static TOOL_ACTION lock;
static TOOL_ACTION unlock;
// Miscellaneous
// Tools
static TOOL_ACTION selectionTool;
static TOOL_ACTION pickerTool;
static TOOL_ACTION placeSymbol;
static TOOL_ACTION placePower;
// Editing
static TOOL_ACTION properties;
/// Clipboard
static TOOL_ACTION copyToClipboard;
static TOOL_ACTION pasteFromClipboard;
static TOOL_ACTION cutToClipboard;
// Miscellaneous
static TOOL_ACTION switchCursor;
static TOOL_ACTION switchUnits;
static TOOL_ACTION updateUnits;

View File

@ -33,9 +33,10 @@
#include <tool/tool_manager.h>
#include <tools/sch_actions.h>
#include <tools/sch_picker_tool.h>
#include <project.h>
#include <tools/sch_editor_control.h>
#include <hotkeys.h>
#include <class_library.h>
TOOL_ACTION SCH_ACTIONS::highlightNet( "eeschema.EditorControl.highlightNet",
AS_GLOBAL, 0, "", "" );
@ -44,7 +45,18 @@ TOOL_ACTION SCH_ACTIONS::highlightNetSelection( "eeschema.EditorControl.highligh
AS_GLOBAL, 0, "", "" );
TOOL_ACTION SCH_ACTIONS::highlightNetCursor( "eeschema.EditorControl.highlightNetCursor",
AS_GLOBAL, 0, "", "" );
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 );
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 );
SCH_EDITOR_CONTROL::SCH_EDITOR_CONTROL() :
@ -245,6 +257,165 @@ int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
}
// History lists for PlaceSymbol()
static SCH_BASE_FRAME::HISTORY_LIST s_SymbolHistoryList;
static SCH_BASE_FRAME::HISTORY_LIST s_PowerHistoryList;
int SCH_EDITOR_CONTROL::PlaceSymbol( const TOOL_EVENT& aEvent )
{
SCH_COMPONENT* component = aEvent.Parameter<SCH_COMPONENT*>();
m_frame->SetToolID( ID_SCH_PLACE_COMPONENT, wxCURSOR_PENCIL, _( "Add Symbol" ) );
return placeComponent( component, nullptr, s_SymbolHistoryList );
}
int SCH_EDITOR_CONTROL::PlacePower( const TOOL_EVENT& aEvent )
{
SCH_COMPONENT* component = aEvent.Parameter<SCH_COMPONENT*>();
SCHLIB_FILTER filter;
filter.FilterPowerParts( true );
m_frame->SetToolID( ID_PLACE_POWER_BUTT, wxCURSOR_PENCIL, _( "Add Power" ) );
return placeComponent( component, &filter, s_PowerHistoryList );
}
int SCH_EDITOR_CONTROL::placeComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER* aFilter,
SCH_BASE_FRAME::HISTORY_LIST aHistoryList )
{
KIGFX::VIEW_CONTROLS* controls = getViewControls();
VECTOR2I cursorPos = controls->GetCursorPosition();
KIGFX::SCH_VIEW* view = static_cast<KIGFX::SCH_VIEW*>( getView() );
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
controls->ShowCursor( true );
controls->SetSnapping( true );
Activate();
// Add all the drawable parts to preview
if( aComponent )
{
aComponent->SetPosition( (wxPoint)cursorPos );
view->ClearPreview();
view->AddToPreview( aComponent->Clone() );
}
// 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( aComponent )
{
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
getModel<SCH_SCREEN>()->SetCurItem( nullptr );
view->ClearPreview();
view->ClearHiddenFlags();
delete aComponent;
aComponent = nullptr;
}
else // let's have another chance placing a module
break;
if( evt->IsActivate() ) // now finish unconditionally
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
if( !aComponent )
{
// Pick the module to be placed
m_frame->SetRepeatItem( NULL );
m_frame->GetCanvas()->SetIgnoreMouseEvents( true );
auto sel = m_frame->SelectComponentFromLibTree(
aFilter, aHistoryList, true, 1, 1,
m_frame->GetShowFootprintPreviews() );
// Restore cursor after dialog
m_frame->GetCanvas()->MoveCursorToCrossHair();
LIB_PART* part = nullptr;
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 )
continue;
aComponent->SetFlags( IS_MOVED );
view->ClearPreview();
view->AddToPreview( aComponent->Clone() );
controls->SetCursorPosition( cursorPos, false );
}
else
{
view->ClearPreview();
m_frame->AddItemToScreen( aComponent );
aComponent = nullptr;
}
}
else if( evt->IsClick( BUT_RIGHT ) )
{
// JEY TODO
// m_menu.ShowContextMenu( selTool->GetSelection() );
}
else if( aComponent && evt->IsMotion() )
{
aComponent->SetPosition( (wxPoint)cursorPos );
view->ClearPreview();
view->AddToPreview( aComponent->Clone() );
}
// Enable autopanning and cursor capture only when there is a module to be placed
controls->SetAutoPan( !!aComponent );
controls->CaptureCursor( !!aComponent );
}
m_frame->SetNoToolSelected();
return 0;
}
void SCH_EDITOR_CONTROL::setTransitions()
{
/*
@ -263,4 +434,7 @@ void SCH_EDITOR_CONTROL::setTransitions()
Go( &SCH_EDITOR_CONTROL::HighlightNet, SCH_ACTIONS::highlightNet.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::HighlightNetCursor, SCH_ACTIONS::highlightNetCursor.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::HighlightNetSelection, SCH_ACTIONS::highlightNetSelection.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::PlaceSymbol, SCH_ACTIONS::placeSymbol.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::PlacePower, SCH_ACTIONS::placePower.MakeEvent() );
}

View File

@ -25,11 +25,14 @@
#ifndef SCH_EDITOR_CONTROL_H
#define SCH_EDITOR_CONTROL_H
#include <sch_base_frame.h>
#include <tool/tool_interactive.h>
#include <tool/tool_event.h>
#include <tool/tool_menu.h>
class SCH_EDIT_FRAME;
class SCH_COMPONENT;
class SCHLIB_FILTER;
/**
* Class SCH_EDITOR_CONTROL
@ -78,8 +81,14 @@ public:
///> Launches a tool to pick the item whose net is going to be highlighted.
int HighlightNetCursor( const TOOL_EVENT& aEvent );
int PlaceSymbol( const TOOL_EVENT& aEvent );
int PlacePower( const TOOL_EVENT& aEvent );
private:
int placeComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER* aFilter,
SCH_BASE_FRAME::HISTORY_LIST aHistoryList );
///> Sets up handlers for various events.
void setTransitions() override;

View File

@ -0,0 +1,56 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <sch_actions.h>
// Selection tool actions
TOOL_ACTION SCH_ACTIONS::selectionActivate( "eeschema.InteractiveSelection",
AS_GLOBAL, 0,
"", "", NULL, AF_ACTIVATE ); // No description, it is not supposed to be shown anywhere
TOOL_ACTION SCH_ACTIONS::selectionCursor( "eeschema.InteractiveSelection.Cursor",
AS_GLOBAL, 0,
"", "" ); // No description, it is not supposed to be shown anywhere
TOOL_ACTION SCH_ACTIONS::selectItem( "eeschema.InteractiveSelection.SelectItem",
AS_GLOBAL, 0,
"", "" ); // No description, it is not supposed to be shown anywhere
TOOL_ACTION SCH_ACTIONS::selectItems( "eeschema.InteractiveSelection.SelectItems",
AS_GLOBAL, 0,
"", "" ); // No description, it is not supposed to be shown anywhere
TOOL_ACTION SCH_ACTIONS::unselectItem( "eeschema.InteractiveSelection.UnselectItem",
AS_GLOBAL, 0,
"", "" ); // No description, it is not supposed to be shown anywhere
TOOL_ACTION SCH_ACTIONS::unselectItems( "eeschema.InteractiveSelection.UnselectItems",
AS_GLOBAL, 0,
"", "" ); // No description, it is not supposed to be shown anywhere
TOOL_ACTION SCH_ACTIONS::selectionClear( "eeschema.InteractiveSelection.Clear",
AS_GLOBAL, 0,
"", "" ); // No description, it is not supposed to be shown anywhere

View File

@ -475,8 +475,8 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
appK2S.SetExt( "exe" );
#endif
if( !appK2S.FileExists() )
GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
// if( !appK2S.FileExists() )
// GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
}