Move DeMorgan handling to ACTIONs.

This commit is contained in:
Jeff Young 2019-06-01 20:48:01 +01:00
parent 39b91c90dd
commit 7f1ed30ff5
23 changed files with 158 additions and 204 deletions

View File

@ -80,7 +80,6 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
EVT_MENU_OPEN( EDA_DRAW_FRAME::OnMenuOpen )
EVT_MENU_CLOSE( EDA_DRAW_FRAME::OnMenuOpen )
EVT_MENU_HIGHLIGHT_ALL( EDA_DRAW_FRAME::OnMenuOpen )
EVT_MENU_RANGE( ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER, EDA_DRAW_FRAME::OnSelectGrid )
END_EVENT_TABLE()
@ -333,16 +332,6 @@ void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
}
void EDA_DRAW_FRAME::ReCreateAuxiliaryToolbar()
{
}
void EDA_DRAW_FRAME::ReCreateMenuBar()
{
}
int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
wxString* aFullFileName )
{
@ -355,7 +344,7 @@ int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
}
void EDA_DRAW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
void EDA_DRAW_FRAME::PrintPage( wxDC* aDC )
{
wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
}
@ -725,13 +714,6 @@ wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition,
}
void EDA_DRAW_FRAME::SetMousePosition( const wxPoint& aPosition )
{
BASE_SCREEN* screen = GetScreen(); // virtual call
screen->setMousePosition( aPosition );
}
wxPoint EDA_DRAW_FRAME::RefPos( bool useMouse ) const
{
BASE_SCREEN* screen = GetScreen(); // virtual call

View File

@ -63,6 +63,15 @@ void ACTION_TOOLBAR::Toggle( const TOOL_ACTION& aAction, bool aState )
}
void ACTION_TOOLBAR::Toggle( const TOOL_ACTION& aAction, bool aEnabled, bool aChecked )
{
int toolId = aAction.GetId() + ACTION_ID;
EnableTool( toolId, aEnabled );
ToggleTool( toolId, aEnabled && aChecked );
}
void ACTION_TOOLBAR::onToolEvent( wxAuiToolBarEvent& aEvent )
{
OPT_TOOL_EVENT evt;

View File

@ -122,13 +122,13 @@ enum id_eeschema_frm
ID_LIBEDIT_SELECT_PART_NUMBER,
/* Library editor vertical toolbar IDs. */
ID_LIBEDIT_PIN_BUTT,
ID_LIBEDIT_BODY_LINE_BUTT,
ID_LIBEDIT_BODY_ARC_BUTT,
ID_LIBEDIT_BODY_CIRCLE_BUTT,
ID_LIBEDIT_BODY_RECT_BUTT,
ID_LIBEDIT_BODY_TEXT_BUTT,
ID_LIBEDIT_ANCHOR_ITEM_BUTT,
ID_SYMBOL_PIN_TOOL,
ID_SYMBOL_LINE_TOOL,
ID_SYMBOL_ARC_TOOL,
ID_SYMBOL_CIRCLE_TOOL,
ID_SYMBOL_RECT_TOOL,
ID_SYMBOL_TEXT_TOOL,
ID_SYMBOL_ANCHOR_TOOL,
ID_LIBEDIT_IMPORT_BODY_BUTT,
ID_LIBEDIT_EXPORT_BODY_BUTT,
ID_LIBEDIT_DELETE_ITEM_BUTT,

View File

@ -101,8 +101,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
// Main horizontal toolbar.
EVT_TOOL( ID_TO_LIBVIEW, LIB_EDIT_FRAME::OnOpenLibraryViewer )
EVT_TOOL( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnCheckComponent )
EVT_TOOL( ID_DE_MORGAN_NORMAL_BUTT, LIB_EDIT_FRAME::OnSelectBodyStyle )
EVT_TOOL( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnSelectBodyStyle )
EVT_TOOL( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnSyncPinEditClick )
EVT_TOOL( ID_ADD_PART_TO_SCHEMATIC, LIB_EDIT_FRAME::OnAddPartToSchematic )
@ -124,14 +122,8 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
// Update user interface elements.
EVT_UPDATE_UI( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnUpdateHavePart )
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_AS, LIB_EDIT_FRAME::OnUpdateHavePart )
EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnUpdateSyncPinEdit )
EVT_UPDATE_UI( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnUpdatePartNumber )
EVT_UPDATE_UI( ID_DE_MORGAN_NORMAL_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganNormal )
EVT_UPDATE_UI( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganConvert )
EVT_UPDATE_UI_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
LIB_EDIT_FRAME::OnUpdateEditingPart )
END_EVENT_TABLE()
@ -389,17 +381,6 @@ void LIB_EDIT_FRAME::OnUpdateHavePart( wxUpdateUIEvent& aEvent )
}
void LIB_EDIT_FRAME::OnUpdateEditingPart( wxUpdateUIEvent& aEvent )
{
LIB_PART* part = GetCurPart();
aEvent.Enable( part != NULL );
if( part && aEvent.GetEventObject() == m_drawToolBar )
aEvent.Check( GetToolId() == aEvent.GetId() );
}
void LIB_EDIT_FRAME::OnUpdateSyncPinEdit( wxUpdateUIEvent& event )
{
LIB_PART* part = GetCurPart();
@ -421,24 +402,6 @@ void LIB_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event )
}
void LIB_EDIT_FRAME::OnUpdateDeMorganNormal( wxUpdateUIEvent& event )
{
LIB_PART* part = GetCurPart();
event.Enable( GetShowDeMorgan() || ( part && part->HasConversion() ) );
event.Check( m_convert <= 1 );
}
void LIB_EDIT_FRAME::OnUpdateDeMorganConvert( wxUpdateUIEvent& event )
{
LIB_PART* part = GetCurPart();
event.Enable( GetShowDeMorgan() || ( part && part->HasConversion() ) );
event.Check( m_convert > 1 );
}
void LIB_EDIT_FRAME::OnSelectUnit( wxCommandEvent& event )
{
int i = event.GetSelection();
@ -456,18 +419,6 @@ void LIB_EDIT_FRAME::OnSelectUnit( wxCommandEvent& event )
}
void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event )
{
m_toolManager->RunAction( ACTIONS::cancelInteractive, true );
m_toolManager->RunAction( EE_ACTIONS::clearSelection, true );
m_convert = event.GetId() == ID_DE_MORGAN_NORMAL_BUTT ? 1 : 2;
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
RebuildView();
}
void LIB_EDIT_FRAME::OnSyncPinEditClick( wxCommandEvent& event )
{
m_SyncPinEdit = m_mainToolBar->GetToolToggled( ID_LIBEDIT_SYNC_PIN_EDIT );

View File

@ -287,14 +287,10 @@ public:
void ClearSearchTreeSelection();
void OnCheckComponent( wxCommandEvent& event );
void OnSelectBodyStyle( wxCommandEvent& event );
void OnUpdateEditingPart( wxUpdateUIEvent& event );
void OnUpdateHavePart( wxUpdateUIEvent& aEvent );
void OnUpdateSyncPinEdit( wxUpdateUIEvent& event );
void OnUpdatePartNumber( wxUpdateUIEvent& event );
void OnUpdateDeMorganNormal( wxUpdateUIEvent& event );
void OnUpdateDeMorganConvert( wxUpdateUIEvent& event );
void UpdateAfterSymbolProperties( wxString* aOldName, wxArrayString* aOldAliases );
void RebuildSymbolUnitsList();
@ -329,11 +325,13 @@ public:
*/
void OnModify() override;
int GetUnit() { return m_unit; }
int GetUnit() const { return m_unit; }
void SetUnit( int aUnit ) { m_unit = aUnit; }
int GetConvert() { return m_convert; }
int GetConvert() const { return m_convert; }
void SetConvert( int aConvert ) { m_convert = aConvert; }
bool GetShowDeMorgan() { return m_showDeMorgan; }
bool GetShowDeMorgan() const { return m_showDeMorgan; }
void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; }
void ClearMsgPanel() override { DisplayCmpDoc(); }
@ -467,12 +465,8 @@ public:
* Print a page
*
* @param aDC = wxDC given by the calling print function
* @param aPrintMask = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, LSET aPrintMask,
bool aPrintMirrorMode, void* aData = NULL ) override;
void PrintPage( wxDC* aDC ) override;
/**
* Creates the SVG print file for the current edited component.

View File

@ -257,6 +257,8 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, const wxString& a
m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
updateTitle();
RebuildSymbolUnitsList();
SetShowDeMorgan( GetCurPart()->HasConversion() );
SyncMenusAndToolbars();
// Display the document information based on the entry selected just in
// case the entry is an alias.
@ -525,6 +527,7 @@ void LIB_EDIT_FRAME::UpdateAfterSymbolProperties( wxString* aOldName, wxArrayStr
m_treePane->GetLibTree()->SelectLibId( LIB_ID( lib, part->GetName() ) );
RebuildSymbolUnitsList();
SetShowDeMorgan( part->HasConversion() );
updateTitle();
DisplayCmpDoc();

View File

@ -175,7 +175,7 @@ void LIB_EDIT_FRAME::SVG_PlotComponent( const wxString& aFullFileName )
}
void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
void LIB_EDIT_FRAME::PrintPage( wxDC* aDC )
{
LIB_PART* part = GetCurPart();

View File

@ -114,13 +114,8 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
_( "Check duplicate and off grid pins" ) );
KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->AddTool( ID_DE_MORGAN_NORMAL_BUTT, wxEmptyString,
KiScaledBitmap( morgan1_xpm, this ),
_( "Show as \"De Morgan\" normal symbol" ), wxITEM_CHECK );
m_mainToolBar->AddTool( ID_DE_MORGAN_CONVERT_BUTT, wxEmptyString,
KiScaledBitmap( morgan2_xpm, this ),
_( "Show as \"De Morgan\" convert symbol" ), wxITEM_CHECK );
m_mainToolBar->Add( EE_ACTIONS::showDeMorganStandard, ACTION_TOOLBAR::TOGGLE );
m_mainToolBar->Add( EE_ACTIONS::showDeMorganAlternate, ACTION_TOOLBAR::TOGGLE );
KiScaledSeparator( m_mainToolBar, this );
m_partSelectBox = new wxComboBox( m_mainToolBar, ID_LIBEDIT_SELECT_PART_NUMBER, wxEmptyString,
@ -176,7 +171,10 @@ void LIB_EDIT_FRAME::SyncMenusAndToolbars()
m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION );
m_mainToolBar->Toggle( EE_ACTIONS::showDatasheet, GetCurPart() != nullptr );
// JEY TODO: deMorgan buttons...
m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganStandard, GetShowDeMorgan(),
m_convert == LIB_ITEM::LIB_CONVERT::BASE );
m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganAlternate, GetShowDeMorgan(),
m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN );
m_mainToolBar->Refresh();
m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() );
@ -187,13 +185,13 @@ void LIB_EDIT_FRAME::SyncMenusAndToolbars()
m_optionsToolBar->Toggle( EE_ACTIONS::showComponentTree, IsSearchTreeShown() );
m_optionsToolBar->Refresh();
m_drawToolBar->Toggle( EE_ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED );
m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolPin, GetToolId() == ID_LIBEDIT_PIN_BUTT );
m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolText, GetToolId() == ID_LIBEDIT_BODY_TEXT_BUTT );
m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolRectangle, GetToolId() == ID_LIBEDIT_BODY_RECT_BUTT );
m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolCircle, GetToolId() == ID_LIBEDIT_BODY_CIRCLE_BUTT );
m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolArc, GetToolId() == ID_LIBEDIT_BODY_ARC_BUTT );
m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolLines, GetToolId() == ID_LIBEDIT_BODY_LINE_BUTT );
m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolAnchor, GetToolId() == ID_LIBEDIT_ANCHOR_ITEM_BUTT );
m_drawToolBar->Toggle( EE_ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED );
m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolPin, GetToolId() == ID_SYMBOL_PIN_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolText, GetToolId() == ID_SYMBOL_TEXT_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolRectangle, GetToolId() == ID_SYMBOL_RECT_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolCircle, GetToolId() == ID_SYMBOL_CIRCLE_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolArc, GetToolId() == ID_SYMBOL_ARC_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolLines, GetToolId() == ID_SYMBOL_LINE_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolAnchor, GetToolId() == ID_SYMBOL_ANCHOR_TOOL );
m_drawToolBar->Refresh();
}

View File

@ -994,7 +994,7 @@ void SCH_EDIT_FRAME::Print()
}
void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
void SCH_EDIT_FRAME::PrintPage( wxDC* aDC )
{
wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );

View File

@ -1062,12 +1062,8 @@ public:
* Plot or print the current sheet to the clipboard.
*
* @param aDC = wxDC given by the calling print function
* @param aPrintMask = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, LSET aPrintMask,
bool aPrintMirrorMode, void* aData = NULL ) override;
virtual void PrintPage( wxDC* aDC ) override;
void SetSimulatorCommand( const wxString& aCommand ) { m_simulatorCommand = aCommand; }

View File

@ -475,8 +475,7 @@ void SCH_EDIT_FRAME::DrawCurrentSheetToClipboard( wxCommandEvent& aEvt )
dc.SetUserScale( scale, scale );
dc.Clear();
const LSET allLayersMask = LSET().set();
PrintPage( &dc, allLayersMask, false );
PrintPage( &dc );
screen->m_IsPrinting = false;
if( wxTheClipboard->Open() )

View File

@ -68,20 +68,12 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
toolbar->Add( ACTIONS::zoomFitScreen );
KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->AddTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, wxEmptyString,
KiScaledBitmap( morgan1_xpm, this ),
_( "Show as \"De Morgan\" normal symbol" ),
wxITEM_CHECK );
m_mainToolBar->AddTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, wxEmptyString,
KiScaledBitmap( morgan2_xpm, this ),
_( "Show as \"De Morgan\" convert symbol" ),
wxITEM_CHECK );
toolbar->Add( EE_ACTIONS::showDeMorganStandard, ACTION_TOOLBAR::TOGGLE );
toolbar->Add( EE_ACTIONS::showDeMorganAlternate, ACTION_TOOLBAR::TOGGLE );
KiScaledSeparator( m_mainToolBar, this );
m_unitChoice = new wxChoice( m_mainToolBar, ID_LIBVIEW_SELECT_PART_NUMBER, wxDefaultPosition,
wxSize( 150, -1 ) );
m_unitChoice = new wxChoice( m_mainToolBar, ID_LIBVIEW_SELECT_PART_NUMBER,
wxDefaultPosition, wxSize( 150, -1 ) );
m_mainToolBar->AddControl( m_unitChoice );
KiScaledSeparator( m_mainToolBar, this );
@ -160,9 +152,13 @@ void LIB_VIEW_FRAME::ReCreateMenuBar()
void LIB_VIEW_FRAME::SyncMenusAndToolbars()
{
LIB_PART* symbol = GetSelectedSymbol();
LIB_ALIAS* alias = GetSelectedAlias();
m_mainToolBar->Toggle( EE_ACTIONS::showDatasheet, alias && !alias->GetDocFileName().IsEmpty() );
// JEY TODO: deMorgan buttons...
m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganStandard, symbol && symbol->HasConversion(),
m_convert == LIB_FIELD::LIB_CONVERT::BASE );
m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganAlternate, symbol && symbol->HasConversion(),
m_convert == LIB_FIELD::LIB_CONVERT::DEMORGAN );
m_mainToolBar->Refresh();
}

View File

@ -126,7 +126,9 @@ public:
static TOOL_ACTION editValue;
static TOOL_ACTION editFootprint;
static TOOL_ACTION autoplaceFields;
static TOOL_ACTION convertDeMorgan;
static TOOL_ACTION toggleDeMorgan;
static TOOL_ACTION showDeMorganStandard;
static TOOL_ACTION showDeMorganAlternate;
static TOOL_ACTION editSymbolUnit;
static TOOL_ACTION addJunction;
static TOOL_ACTION addLabel;

View File

@ -70,7 +70,7 @@ public:
{
m_frame = getEditFrame<T>();
m_selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
m_isLibEdit = dynamic_cast<LIB_EDIT_FRAME*>( m_frame ) != nullptr;
m_isLibEdit = m_frame->IsType( FRAME_SCH_LIB_EDITOR );
// A basic context manu. Many (but not all) tools will choose to override this.

View File

@ -26,12 +26,13 @@
#include <tool/tool_manager.h>
#include <tools/ee_actions.h>
#include <lib_edit_frame.h>
#include <viewlib_frame.h>
#include <tools/lib_control.h>
TOOL_ACTION EE_ACTIONS::showElectricalTypes( "eeschema.SymbolLibraryControl.showElectricalTypes",
AS_GLOBAL, 0,
_( "Show Pin Electrical Types" ), "",
_( "Show Pin Electrical Types" ), _( "Annotate pins with their electrical types" ),
pin_show_etype_xpm );
@ -43,28 +44,62 @@ TOOL_ACTION EE_ACTIONS::showComponentTree( "eeschema.SymbolLibraryControl.showCo
int LIB_CONTROL::Save( const TOOL_EVENT& aEvent )
{
m_frame->OnSave();
if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) )
static_cast<LIB_EDIT_FRAME*>( m_frame )->OnSave();
return 0;
}
int LIB_CONTROL::SaveAs( const TOOL_EVENT& aEvent )
{
m_frame->OnSaveAs();
if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) )
static_cast<LIB_EDIT_FRAME*>( m_frame )->OnSaveAs();
return 0;
}
int LIB_CONTROL::SaveAll( const TOOL_EVENT& aEvent )
{
m_frame->OnSaveAll();
if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) )
static_cast<LIB_EDIT_FRAME*>( m_frame )->OnSaveAll();
return 0;
}
int LIB_CONTROL::Revert( const TOOL_EVENT& aEvent )
{
m_frame->OnRevert();
if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) )
static_cast<LIB_EDIT_FRAME*>( m_frame )->OnRevert();
return 0;
}
int LIB_CONTROL::OnDeMorgan( const TOOL_EVENT& aEvent )
{
int convert = aEvent.IsAction( &EE_ACTIONS::showDeMorganStandard ) ?
LIB_ITEM::LIB_CONVERT::BASE : LIB_ITEM::LIB_CONVERT::DEMORGAN;
if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) )
{
m_toolMgr->RunAction( ACTIONS::cancelInteractive, true );
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
LIB_EDIT_FRAME* libEditFrame = static_cast<LIB_EDIT_FRAME*>( m_frame );
libEditFrame->SetConvert( convert );
m_toolMgr->ResetTools( TOOL_BASE::MODEL_RELOAD );
libEditFrame->RebuildView();
}
else if( m_frame->IsType( FRAME_SCH_VIEWER ) || m_frame->IsType( FRAME_SCH_VIEWER_MODAL ) )
{
LIB_VIEW_FRAME* libViewFrame = static_cast<LIB_VIEW_FRAME*>( m_frame );
libViewFrame->SetUnitAndConvert( libViewFrame->GetUnit(), convert );
}
return 0;
}
@ -80,12 +115,10 @@ int LIB_CONTROL::ShowLibraryBrowser( const TOOL_EVENT& aEvent )
int LIB_CONTROL::ShowComponentTree( const TOOL_EVENT& aEvent )
{
if( m_isLibEdit )
if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) )
{
LIB_EDIT_FRAME* editFrame = static_cast<LIB_EDIT_FRAME*>( m_frame );
wxCommandEvent dummy;
editFrame->OnToggleSearchTree( dummy );
static_cast<LIB_EDIT_FRAME*>( m_frame )->OnToggleSearchTree( dummy );
}
return 0;
@ -112,6 +145,9 @@ void LIB_CONTROL::setTransitions()
Go( &LIB_CONTROL::SaveAll, ACTIONS::saveAll.MakeEvent() );
Go( &LIB_CONTROL::Revert, ACTIONS::revert.MakeEvent() );
Go( &LIB_CONTROL::OnDeMorgan, EE_ACTIONS::showDeMorganStandard.MakeEvent() );
Go( &LIB_CONTROL::OnDeMorgan, EE_ACTIONS::showDeMorganAlternate.MakeEvent() );
Go( &LIB_CONTROL::ShowLibraryBrowser, EE_ACTIONS::showLibraryBrowser.MakeEvent() );
Go( &LIB_CONTROL::ShowElectricalTypes, EE_ACTIONS::showElectricalTypes.MakeEvent() );
Go( &LIB_CONTROL::ShowComponentTree, EE_ACTIONS::showComponentTree.MakeEvent() );

View File

@ -35,11 +35,11 @@ class LIB_EDIT_FRAME;
*
* Handles actions for the various symbol editor and viewers.
*/
class LIB_CONTROL : public wxEvtHandler, public EE_TOOL_BASE<LIB_EDIT_FRAME>
class LIB_CONTROL : public wxEvtHandler, public EE_TOOL_BASE<SCH_BASE_FRAME>
{
public:
LIB_CONTROL() :
EE_TOOL_BASE<LIB_EDIT_FRAME>( "eeschema.SymbolLibraryControl" )
EE_TOOL_BASE<SCH_BASE_FRAME>( "eeschema.SymbolLibraryControl" )
{ }
virtual ~LIB_CONTROL() { }
@ -49,6 +49,8 @@ public:
int SaveAll( const TOOL_EVENT& aEvent );
int Revert( const TOOL_EVENT& aEvent );
int OnDeMorgan( const TOOL_EVENT& aEvent );
int ShowLibraryBrowser( const TOOL_EVENT& aEvent );
int ShowElectricalTypes( const TOOL_EVENT& aEvent );
int ShowComponentTree( const TOOL_EVENT& aEvent );

View File

@ -118,14 +118,14 @@ bool LIB_DRAWING_TOOLS::Init()
int LIB_DRAWING_TOOLS::PlacePin( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_LIBEDIT_PIN_BUTT, wxCURSOR_PENCIL, _( "Add pin" ) );
m_frame->SetToolID( ID_SYMBOL_PIN_TOOL, wxCURSOR_PENCIL, _( "Add pin" ) );
return doTwoClickPlace( LIB_PIN_T );
}
int LIB_DRAWING_TOOLS::PlaceText( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_LIBEDIT_BODY_TEXT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) );
m_frame->SetToolID( ID_SYMBOL_TEXT_TOOL, wxCURSOR_PENCIL, _( "Add text" ) );
return doTwoClickPlace( LIB_TEXT_T );
}
@ -275,13 +275,13 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_toolMgr->DeactivateTool();
if( aEvent.IsAction( &EE_ACTIONS::drawSymbolArc ) )
m_frame->SetToolID( ID_LIBEDIT_BODY_ARC_BUTT, wxCURSOR_PENCIL, _( "Draw Arc" ) );
m_frame->SetToolID( ID_SYMBOL_ARC_TOOL, wxCURSOR_PENCIL, _( "Draw Arc" ) );
else if( aEvent.IsAction( &EE_ACTIONS::drawSymbolCircle ) )
m_frame->SetToolID( ID_LIBEDIT_BODY_CIRCLE_BUTT, wxCURSOR_PENCIL, _( "Draw Circle" ) );
m_frame->SetToolID( ID_SYMBOL_CIRCLE_TOOL, wxCURSOR_PENCIL, _( "Draw Circle" ) );
else if( aEvent.IsAction( &EE_ACTIONS::drawSymbolLines ) )
m_frame->SetToolID( ID_LIBEDIT_BODY_LINE_BUTT, wxCURSOR_PENCIL, _( "Draw Lines" ) );
m_frame->SetToolID( ID_SYMBOL_LINE_TOOL, wxCURSOR_PENCIL, _( "Draw Lines" ) );
else if( aEvent.IsAction( &EE_ACTIONS::drawSymbolRectangle ) )
m_frame->SetToolID( ID_LIBEDIT_BODY_RECT_BUTT, wxCURSOR_PENCIL, _( "Draw Rectangle" ) );
m_frame->SetToolID( ID_SYMBOL_RECT_TOOL, wxCURSOR_PENCIL, _( "Draw Rectangle" ) );
else
wxCHECK_MSG( false, 0, "Unknown action in LIB_DRAWING_TOOLS::DrawShape()" );
@ -324,10 +324,10 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
switch( m_frame->GetToolId() )
{
case ID_LIBEDIT_BODY_ARC_BUTT: item = new LIB_ARC( part ); break;
case ID_LIBEDIT_BODY_CIRCLE_BUTT: item = new LIB_CIRCLE( part ); break;
case ID_LIBEDIT_BODY_LINE_BUTT: item = new LIB_POLYLINE( part ); break;
case ID_LIBEDIT_BODY_RECT_BUTT: item = new LIB_RECTANGLE( part ); break;
case ID_SYMBOL_ARC_TOOL: item = new LIB_ARC( part ); break;
case ID_SYMBOL_CIRCLE_TOOL: item = new LIB_CIRCLE( part ); break;
case ID_SYMBOL_LINE_TOOL: item = new LIB_POLYLINE( part ); break;
case ID_SYMBOL_RECT_TOOL: item = new LIB_RECTANGLE( part ); break;
}
item->SetWidth( LIB_EDIT_FRAME::g_LastLineWidth );
@ -400,7 +400,7 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_LIBEDIT_ANCHOR_ITEM_BUTT, wxCURSOR_PENCIL, _( "Move symbol anchor" ) );
m_frame->SetToolID( ID_SYMBOL_ANCHOR_TOOL, wxCURSOR_PENCIL, _( "Move symbol anchor" ) );
getViewControls()->ShowCursor( true );
getViewControls()->SetSnapping( true );

View File

@ -99,11 +99,21 @@ TOOL_ACTION EE_ACTIONS::autoplaceFields( "eeschema.InteractiveEdit.autoplaceFiel
_( "Autoplace Fields" ), _( "Runs the automatic placement algorithm on the symbol's fields" ),
autoplace_fields_xpm );
TOOL_ACTION EE_ACTIONS::convertDeMorgan( "eeschema.InteractiveEdit.convertDeMorgan",
TOOL_ACTION EE_ACTIONS::toggleDeMorgan( "eeschema.InteractiveEdit.toggleDeMorgan",
AS_GLOBAL, 0,
_( "DeMorgan Conversion" ), _( "Switch between DeMorgan representations" ),
morgan2_xpm );
TOOL_ACTION EE_ACTIONS::showDeMorganStandard( "eeschema.InteractiveEdit.showDeMorganStandard",
AS_GLOBAL, 0,
_( "DeMorgan Standard" ), _( "Switch to standard DeMorgan representation" ),
morgan1_xpm );
TOOL_ACTION EE_ACTIONS::showDeMorganAlternate( "eeschema.InteractiveEdit.showDeMorganAlternate",
AS_GLOBAL, 0,
_( "DeMorgan Alternate" ), _( "Switch to alternate DeMorgan representation" ),
morgan2_xpm );
TOOL_ACTION EE_ACTIONS::toShapeSlash( "eeschema.InteractiveEdit.toShapeSlash",
AS_GLOBAL, 0,
_( "Set Bus Entry Shape /" ), _( "Change the bus entry shape to /" ),
@ -347,7 +357,7 @@ bool SCH_EDIT_TOOL::Init()
moveMenu.AddItem( EE_ACTIONS::editReference, singleComponentCondition );
moveMenu.AddItem( EE_ACTIONS::editValue, singleComponentCondition );
moveMenu.AddItem( EE_ACTIONS::editFootprint, singleComponentCondition );
moveMenu.AddItem( EE_ACTIONS::convertDeMorgan, E_C::SingleDeMorganSymbol );
moveMenu.AddItem( EE_ACTIONS::toggleDeMorgan, E_C::SingleDeMorganSymbol );
std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu = std::make_shared<SYMBOL_UNIT_MENU>();
symUnitMenu->SetTool( this );
@ -375,7 +385,7 @@ bool SCH_EDIT_TOOL::Init()
drawMenu.AddItem( EE_ACTIONS::editValue, singleComponentCondition, 200 );
drawMenu.AddItem( EE_ACTIONS::editFootprint, singleComponentCondition, 200 );
drawMenu.AddItem( EE_ACTIONS::autoplaceFields, singleComponentCondition, 200 );
drawMenu.AddItem( EE_ACTIONS::convertDeMorgan, E_C::SingleDeMorganSymbol, 200 );
drawMenu.AddItem( EE_ACTIONS::toggleDeMorgan, E_C::SingleDeMorganSymbol, 200 );
std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu2 = std::make_shared<SYMBOL_UNIT_MENU>();
symUnitMenu2->SetTool( drawingTools );
@ -408,7 +418,7 @@ bool SCH_EDIT_TOOL::Init()
selToolMenu.AddItem( EE_ACTIONS::editValue, E_C::SingleSymbol, 200 );
selToolMenu.AddItem( EE_ACTIONS::editFootprint, E_C::SingleSymbol, 200 );
selToolMenu.AddItem( EE_ACTIONS::autoplaceFields, singleComponentCondition, 200 );
selToolMenu.AddItem( EE_ACTIONS::convertDeMorgan, E_C::SingleSymbol, 200 );
selToolMenu.AddItem( EE_ACTIONS::toggleDeMorgan, E_C::SingleSymbol, 200 );
std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu3 = std::make_shared<SYMBOL_UNIT_MENU>();
symUnitMenu3->SetTool( m_selectionTool );
@ -1123,13 +1133,22 @@ int SCH_EDIT_TOOL::ConvertDeMorgan( const TOOL_EVENT& aEvent )
SCH_COMPONENT* component = (SCH_COMPONENT*) selection.Front();
if( component->IsNew() )
m_toolMgr->RunAction( EE_ACTIONS::refreshPreview );
else
if( aEvent.IsAction( &EE_ACTIONS::showDeMorganStandard )
&& component->GetConvert() == LIB_ITEM::LIB_CONVERT::BASE )
return 0;
if( aEvent.IsAction( &EE_ACTIONS::showDeMorganAlternate )
&& component->GetConvert() != LIB_ITEM::LIB_CONVERT::DEMORGAN )
return 0;
if( !component->IsNew() )
m_frame->SaveCopyInUndoList( component, UR_CHANGED );
m_frame->ConvertPart( component );
if( component->IsNew() )
m_toolMgr->RunAction( EE_ACTIONS::refreshPreview );
return 0;
}
@ -1350,7 +1369,9 @@ void SCH_EDIT_TOOL::setTransitions()
Go( &SCH_EDIT_TOOL::EditField, EE_ACTIONS::editValue.MakeEvent() );
Go( &SCH_EDIT_TOOL::EditField, EE_ACTIONS::editFootprint.MakeEvent() );
Go( &SCH_EDIT_TOOL::AutoplaceFields, EE_ACTIONS::autoplaceFields.MakeEvent() );
Go( &SCH_EDIT_TOOL::ConvertDeMorgan, EE_ACTIONS::convertDeMorgan.MakeEvent() );
Go( &SCH_EDIT_TOOL::ConvertDeMorgan, EE_ACTIONS::toggleDeMorgan.MakeEvent() );
Go( &SCH_EDIT_TOOL::ConvertDeMorgan, EE_ACTIONS::showDeMorganStandard.MakeEvent() );
Go( &SCH_EDIT_TOOL::ConvertDeMorgan, EE_ACTIONS::showDeMorganAlternate.MakeEvent() );
Go( &SCH_EDIT_TOOL::ChangeShape, EE_ACTIONS::toShapeSlash.MakeEvent() );
Go( &SCH_EDIT_TOOL::ChangeShape, EE_ACTIONS::toShapeBackslash.MakeEvent() );

View File

@ -86,8 +86,6 @@ BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings )
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, LIB_VIEW_FRAME::OnDisplayHotkeyList )
EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, LIB_VIEW_FRAME::onUpdateNormalBodyStyleButton )
EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, LIB_VIEW_FRAME::onUpdateAltBodyStyleButton )
EVT_UPDATE_UI( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::onUpdateUnitChoice )
END_EVENT_TABLE()
@ -254,11 +252,7 @@ void LIB_VIEW_FRAME::SetUnitAndConvert( int aUnit, int aConvert )
m_convert = aConvert > 0 ? aConvert : LIB_ITEM::LIB_CONVERT::BASE;
m_selection_changed = false;
// Update canvas
GetRenderSettings()->m_ShowUnit = m_unit;
GetRenderSettings()->m_ShowConvert = m_convert;
GetCanvas()->GetView()->MarkDirty();
GetCanvas()->Refresh();
updatePreviewSymbol();
}
@ -315,32 +309,6 @@ void LIB_VIEW_FRAME::updatePreviewSymbol()
}
void LIB_VIEW_FRAME::onUpdateAltBodyStyleButton( wxUpdateUIEvent& aEvent )
{
LIB_PART* symbol = GetSelectedSymbol();
aEvent.Enable( symbol && symbol->HasConversion() );
if( symbol )
aEvent.Check( m_convert > 1 );
else
aEvent.Check( false );
}
void LIB_VIEW_FRAME::onUpdateNormalBodyStyleButton( wxUpdateUIEvent& aEvent )
{
LIB_PART* symbol = GetSelectedSymbol();
aEvent.Enable( symbol && symbol->HasConversion() );
if( symbol )
aEvent.Check( m_convert <= 1 );
else
aEvent.Check( true );
}
bool LIB_VIEW_FRAME::ShowModal( wxString* aSymbol, wxWindow* aParent )
{
if( aSymbol && !aSymbol->IsEmpty() )

View File

@ -329,8 +329,6 @@ public:
*/
wxPoint GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize = NULL ) const;
void SetMousePosition( const wxPoint& aPosition );
/**
* Return the reference position, coming from either the mouse position
* or the cursor position.
@ -423,10 +421,10 @@ public:
void EraseMsgBox();
void ReCreateMenuBar() override { }
virtual void ReCreateHToolbar() = 0;
virtual void ReCreateVToolbar() = 0;
virtual void ReCreateMenuBar() override;
virtual void ReCreateAuxiliaryToolbar();
virtual void ReCreateAuxiliaryToolbar() { }
// Toolbar accessors
ACTION_TOOLBAR* GetMainToolBar() const { return m_mainToolBar; }
@ -677,11 +675,8 @@ public:
* Print the page pointed by current screen, set by the calling print function.
*
* @param aDC = wxDC given by the calling print function
* @param aPrintMask = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData = NULL );
virtual void PrintPage( wxDC* aDC );
/**
* Returns the canvas type stored in the application settings.

View File

@ -53,8 +53,14 @@ public:
*/
void Add( const TOOL_ACTION& aAction, bool aIsToggleEntry = false );
/**
* Applies the default toggle action. For checked items this is check/uncheck; for
* non-checked items it's enable/disable.
*/
void Toggle( const TOOL_ACTION& aAction, bool aState );
void Toggle( const TOOL_ACTION& aAction, bool aEnabled, bool aChecked );
static const bool TOGGLE = true;
protected:

View File

@ -578,7 +578,7 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
}
void PL_EDITOR_FRAME::PrintPage( wxDC* aDC, LSET , bool , void * )
void PL_EDITOR_FRAME::PrintPage( wxDC* aDC )
{
GetScreen()->m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
PrintWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, wxEmptyString );

View File

@ -226,12 +226,8 @@ public:
/** Virtual function PrintPage
* used to print a page
* @param aDC = wxDC given by the calling print function
* @param aPrintMasklayer = a 32 bits mask: bit n = 1 -> layer n is printed
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, LSET aPrintMasklayer, bool aPrintMirrorMode,
void * aData ) override;
virtual void PrintPage( wxDC* aDC ) override;
void OnFileHistory( wxCommandEvent& event );