This commit is contained in:
Jeff Young 2019-05-13 22:49:05 +01:00
parent 053c26c96e
commit e850592587
28 changed files with 388 additions and 688 deletions

View File

@ -26,8 +26,6 @@
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <gr_basic.h>
#include <common.h>
#include <bitmaps.h>
#include <macros.h>
#include <id.h>
@ -38,27 +36,14 @@
#include <confirm.h>
#include <kicad_device_context.h>
#include <dialog_helpers.h>
#include <base_units.h>
#include <math/box2.h>
#include <lockfile.h>
#include <trace_helpers.h>
#include <wx/fontdlg.h>
#include <wx/snglinst.h>
#include <view/view.h>
#include <view/view_controls.h>
#include <gal/graphics_abstraction_layer.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/actions.h>
#include <wx/clipbrd.h>
#include <fctsys.h>
#include <gr_basic.h>
#include <common.h>
#include <id.h>
#include <base_screen.h>
#include <confirm.h>
#include <draw_frame.h>
#include <menus_helpers.h>
#include <worksheet_shape_builder.h>
#include <page_info.h>
#include <title_block.h>
@ -99,15 +84,6 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
EVT_MENU_OPEN( EDA_DRAW_FRAME::OnMenuOpen )
EVT_ACTIVATE( EDA_DRAW_FRAME::OnActivate )
EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE, EDA_DRAW_FRAME::OnZoom )
EVT_MENU_RANGE( ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER, EDA_DRAW_FRAME::OnSelectGrid )
EVT_TOOL( ID_TB_OPTIONS_SHOW_GRID, EDA_DRAW_FRAME::OnToggleGridState )
EVT_TOOL_RANGE( ID_TB_OPTIONS_SELECT_UNIT_MM, ID_TB_OPTIONS_SELECT_UNIT_INCH,
EDA_DRAW_FRAME::OnSelectUnits )
EVT_TOOL( ID_TB_OPTIONS_SELECT_CURSOR, EDA_DRAW_FRAME::OnToggleCrossHairStyle )
EVT_UPDATE_UI( wxID_UNDO, EDA_DRAW_FRAME::OnUpdateUndo )
EVT_UPDATE_UI( wxID_REDO, EDA_DRAW_FRAME::OnUpdateRedo )
END_EVENT_TABLE()
@ -304,9 +280,7 @@ void EDA_DRAW_FRAME::OnActivate( wxActivateEvent& event )
void EDA_DRAW_FRAME::OnMenuOpen( wxMenuEvent& event )
{
if( m_canvas )
m_canvas->SetCanStartBlock( -1 );
// TODO Obsolete!
event.Skip();
}
@ -319,16 +293,7 @@ void EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent()
void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
{
// JEY TODO: obsolete when everything moves to COMMON_TOOLS
SetGridVisibility( !IsGridVisible() );
if( IsGalCanvasActive() )
{
GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
GetGalCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
}
m_canvas->Refresh();
wxFAIL_MSG( "Obsolete! Should go through EDITOR_CONTROL." );
}
@ -343,31 +308,9 @@ bool EDA_DRAW_FRAME::GetToolToggled( int aToolId )
}
void EDA_DRAW_FRAME::OnSelectUnits( wxCommandEvent& aEvent )
{
if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM && m_UserUnits != MILLIMETRES )
{
m_UserUnits = MILLIMETRES;
unitsChangeRefresh();
}
else if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_INCH && m_UserUnits != INCHES )
{
m_UserUnits = INCHES;
unitsChangeRefresh();
}
}
void EDA_DRAW_FRAME::OnToggleCrossHairStyle( wxCommandEvent& aEvent )
{
// JEY TODO: obsolete when everything moves to COMMON_TOOLS
auto& galOpts = GetGalDisplayOptions();
galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
galOpts.NotifyChanged();
// make sure the cursor is redrawn
GetCanvas()->Refresh();
wxFAIL_MSG( "Obsolete! Should go through EDITOR_CONTROL." );
}
@ -387,8 +330,6 @@ void EDA_DRAW_FRAME::OnUpdateRedo( wxUpdateUIEvent& aEvent )
void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
{
// JEY TODO: obsolete when everything moves to COMMON_TOOLS
// No need to update the grid select box if it doesn't exist or the grid setting change
// was made using the select box.
if( m_gridSelectBox == NULL || m_auxiliaryToolBar == NULL )
@ -445,59 +386,12 @@ void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event )
void EDA_DRAW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
{
wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
}
void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
{
wxMessageBox( "EDA_DRAW_FRAME::OnSelectGrid(): should be handled by common tools now...." );
int* clientData;
int eventId = ID_POPUP_GRID_LEVEL_100;
if( event.GetEventType() == wxEVT_CHOICE )
{
if( m_gridSelectBox == NULL ) // Should not happen
return;
/*
* Don't use wxCommandEvent::GetClientData() here. It always
* returns NULL in GTK. This solution is not as elegant but
* it works.
*/
int index = m_gridSelectBox->GetSelection();
wxASSERT( index != wxNOT_FOUND );
if( index == int( m_gridSelectBox->GetCount() - 2 ) )
{
// this is the separator
wxUpdateUIEvent dummy;
OnUpdateSelectGrid( dummy );
return;
}
else if( index == int( m_gridSelectBox->GetCount() - 1 ) )
{
wxUpdateUIEvent dummy;
OnUpdateSelectGrid( dummy );
wxCommandEvent dummy2;
OnGridSettings( dummy2 );
return;
}
clientData = (int*) m_gridSelectBox->wxItemContainer::GetClientData( index );
if( clientData != NULL )
eventId = *clientData;
}
else
{
eventId = event.GetId();
}
int idx = eventId - ID_POPUP_GRID_LEVEL_1000;
GetToolManager()->RunAction( "common.Control.gridPreset", true, idx );
wxFAIL_MSG( "Obsolete! Should go through ToolManager." );
}
@ -586,53 +480,58 @@ void EDA_DRAW_FRAME::SetNoToolSelected()
wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
{
wxPoint pos = aPosition;
if( m_currentScreen != NULL && m_snapToGrid )
pos = GetNearestGridPosition( aPosition );
return pos;
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
return aPosition;
}
void EDA_DRAW_FRAME::SetNextGrid()
{
wxFAIL_MSG( "Obsolete! Should go through ToolManager." );
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
}
void EDA_DRAW_FRAME::SetPrevGrid()
{
wxFAIL_MSG( "Obsolete! Should go through ToolManager." );
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
}
void EDA_DRAW_FRAME::SetPresetGrid( int aIndex )
{
wxFAIL_MSG( "Obsolete! Should go through ToolManager." );
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
}
int EDA_DRAW_FRAME::BlockCommand( EDA_KEY key )
{
wxFAIL_MSG( "Obsolete; how'd we get here?" );
return 0;
}
void EDA_DRAW_FRAME::InitBlockPasteInfos()
{
GetScreen()->m_BlockLocate.ClearItemsList();
m_canvas->SetMouseCaptureCallback( NULL );
wxFAIL_MSG( "Obsolete; how'd we get here?" );
}
bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* , EDA_KEY , const wxPoint& , int )
{
wxFAIL_MSG( "Obsolete; how'd we get here?" );
return false;
}
void EDA_DRAW_FRAME::HandleBlockPlace( wxDC* DC )
{
wxFAIL_MSG( "Obsolete; how'd we get here?" );
}
bool EDA_DRAW_FRAME::HandleBlockEnd( wxDC* DC )
{
wxFAIL_MSG( "Obsolete; how'd we get here?" );
return false;
}
@ -651,23 +550,9 @@ void EDA_DRAW_FRAME::UpdateStatusBar()
const wxString EDA_DRAW_FRAME::GetZoomLevelIndicator() const
{
wxString Line;
double level = 0.0;
if( IsGalCanvasActive() )
{
level = m_galCanvas->GetGAL()->GetZoomFactor();
}
else if( BASE_SCREEN* screen = GetScreen() )
{
level = m_zoomLevelCoeff / screen->GetZoom();
}
// returns a human readable value which can be displayed as zoom
// level indicator in dialogs.
Line.Printf( wxT( "Z %.2f" ), level );
return Line;
return wxString::Format( wxT( "Z %.2f" ), m_galCanvas->GetGAL()->GetZoomFactor() );
}
@ -784,84 +669,6 @@ void EDA_DRAW_FRAME::PushPreferences( const EDA_DRAW_PANEL* aParentCanvas )
}
bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
int aExplicitCommand )
{
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
if( ( block->GetCommand() != BLOCK_IDLE ) || ( block->GetState() != STATE_NO_BLOCK ) )
return false;
if( aExplicitCommand == 0 )
block->SetCommand( (BLOCK_COMMAND_T) BlockCommand( aKey ) );
else
block->SetCommand( (BLOCK_COMMAND_T) aExplicitCommand );
if( block->GetCommand() == 0 )
return false;
switch( block->GetCommand() )
{
case BLOCK_IDLE:
break;
case BLOCK_MOVE: // Move
case BLOCK_DRAG: // Drag (block defined)
case BLOCK_DRAG_ITEM: // Drag from a drag item command
case BLOCK_DUPLICATE: // Duplicate
case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references
case BLOCK_DELETE: // Delete
case BLOCK_COPY: // Copy
case BLOCK_FLIP: // Flip
case BLOCK_ZOOM: // Window Zoom
case BLOCK_PRESELECT_MOVE: // Move with preselection list
block->InitData( m_canvas, aPosition );
break;
case BLOCK_PASTE:
block->InitData( m_canvas, aPosition );
block->SetLastCursorPosition( wxPoint( 0, 0 ) );
InitBlockPasteInfos();
if( block->GetCount() == 0 ) // No data to paste
{
DisplayError( this, wxT( "No block to paste" ), 20 );
GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE );
m_canvas->SetMouseCaptureCallback( NULL );
block->SetState( STATE_NO_BLOCK );
block->SetMessageBlock( this );
return true;
}
if( !m_canvas->IsMouseCaptured() )
{
block->ClearItemsList();
DisplayError( this,
wxT( "EDA_DRAW_FRAME::HandleBlockBegin() Err: m_mouseCaptureCallback NULL" ) );
block->SetState( STATE_NO_BLOCK );
block->SetMessageBlock( this );
return true;
}
block->SetState( STATE_BLOCK_MOVE );
m_canvas->CallMouseCapture( aDC, aPosition, false );
break;
default:
{
wxString msg;
msg << wxT( "EDA_DRAW_FRAME::HandleBlockBegin() error: Unknown command " ) <<
block->GetCommand();
DisplayError( this, msg );
}
break;
}
block->SetMessageBlock( this );
return true;
}
void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
{
}
@ -997,22 +804,14 @@ wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const
void EDA_DRAW_FRAME::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid )
{
// While we're now a GAL canvas, we still have a pre-GAL toolset so some code is going
// to look for the crosshair position in the BASE_SCREEN and some code is going to look
// for it in the VIEW_CONTROLS. Better set it in both.
BASE_SCREEN* screen = GetScreen(); // virtual call
screen->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid );
wxPoint snappedPosition = screen->getCrossHairPosition( false );
GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( snappedPosition, false );
GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( aPosition, false );
}
wxPoint EDA_DRAW_FRAME::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize ) const
wxPoint EDA_DRAW_FRAME::GetCursorPosition( bool , wxRealPoint* ) const
{
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->getCursorPosition( aOnGrid, GetGridOrigin(), aGridSize );
wxFAIL_MSG( "Obsolete; use VIEW_CONTROLS instead" );
return wxPoint();
}
@ -1026,8 +825,8 @@ wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition,
wxPoint EDA_DRAW_FRAME::GetCrossHairScreenPosition() const
{
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->getCrossHairScreenPosition();
wxFAIL_MSG( "Obsolete; use VIEW_CONTROLS instead" );
return wxPoint();
}
@ -1197,111 +996,25 @@ double EDA_DRAW_FRAME::bestZoom( double sizeX, double sizeY, double scaleFactor,
void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
{
if ( IsGalCanvasActive() )
m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
}
void EDA_DRAW_FRAME::Window_Zoom( EDA_RECT& Rect )
{
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
}
void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
{
wxMessageBox( "EDA_DRAW_FRAME::OnZoom(): should be handled by zoom tool now...." );
if( m_canvas == NULL )
return;
TOOL_MANAGER* mgr = GetToolManager();
int id = event.GetId();
if( id == ID_KEY_ZOOM_IN )
{
if( GetCanvas()->GetEnableZoomNoCenter() )
mgr->RunAction( "common.Control.zoomIn", true, id );
else
mgr->RunAction( "common.Control.zoomInCenter", true, id );
}
else if( id == ID_KEY_ZOOM_OUT )
{
if( GetCanvas()->GetEnableZoomNoCenter() )
mgr->RunAction( "common.Control.zoomOut", true, id );
else
mgr->RunAction( "common.Control.zoomOutCenter", true, id );
}
else if( id >= ID_POPUP_ZOOM_LEVEL_START && id <= ID_POPUP_ZOOM_LEVEL_END )
{
mgr->RunAction( "common.Control.zoomPreset", true, id - ID_POPUP_ZOOM_LEVEL_START );
}
UpdateStatusBar();
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
}
void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
{
int maxZoomIds;
double zoom;
wxString msg;
BASE_SCREEN* screen = m_canvas->GetScreen();
msg = AddHotkeyName( _( "Center" ), m_hotkeysDescrList, HK_ZOOM_CENTER );
AddMenuItem( MasterMenu, ID_POPUP_ZOOM_CENTER, msg, KiBitmap( zoom_center_on_screen_xpm ) );
msg = AddHotkeyName( _( "Zoom In" ), m_hotkeysDescrList, HK_ZOOM_IN );
AddMenuItem( MasterMenu, ID_POPUP_ZOOM_IN, msg, KiBitmap( zoom_in_xpm ) );
msg = AddHotkeyName( _( "Zoom Out" ), m_hotkeysDescrList, HK_ZOOM_OUT );
AddMenuItem( MasterMenu, ID_POPUP_ZOOM_OUT, msg, KiBitmap( zoom_out_xpm ) );
msg = AddHotkeyName( _( "Redraw View" ), m_hotkeysDescrList, HK_ZOOM_REDRAW );
AddMenuItem( MasterMenu, ID_POPUP_ZOOM_REDRAW, msg, KiBitmap( zoom_redraw_xpm ) );
msg = AddHotkeyName( _( "Zoom to Fit" ), m_hotkeysDescrList, HK_ZOOM_AUTO );
AddMenuItem( MasterMenu, ID_POPUP_ZOOM_PAGE, msg, KiBitmap( zoom_fit_in_page_xpm ) );
wxMenu* zoom_choice = new wxMenu;
AddMenuItem( MasterMenu, zoom_choice,
ID_POPUP_ZOOM_SELECT, _( "Zoom" ),
KiBitmap( zoom_selection_xpm ) );
zoom = screen->GetZoom();
maxZoomIds = ID_POPUP_ZOOM_LEVEL_END - ID_POPUP_ZOOM_LEVEL_START;
maxZoomIds = ( (size_t) maxZoomIds < screen->m_ZoomList.size() ) ?
maxZoomIds : screen->m_ZoomList.size();
// Populate zoom submenu.
for( int i = 0; i < maxZoomIds; i++ )
{
msg.Printf( wxT( "%.2f" ), m_zoomLevelCoeff / screen->m_ZoomList[i] );
zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg,
wxEmptyString, wxITEM_CHECK );
if( zoom == screen->m_ZoomList[i] )
zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_START + i, true );
}
// Create grid submenu as required.
if( screen->GetGridCount() )
{
wxMenu* gridMenu = new wxMenu;
AddMenuItem( MasterMenu, gridMenu, ID_POPUP_GRID_SELECT, _( "Grid" ),
KiBitmap( grid_select_xpm ) );
wxArrayString gridsList;
int icurr = screen->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES );
for( unsigned i = 0; i < gridsList.GetCount(); i++ )
{
GRID_TYPE& grid = screen->GetGrid( i );
gridMenu->Append( grid.m_CmdId, gridsList[i], wxEmptyString, wxITEM_CHECK );
if( (int)i == icurr )
gridMenu->Check( grid.m_CmdId, true );
}
}
MasterMenu->AppendSeparator();
AddMenuItem( MasterMenu, ID_POPUP_CANCEL, _( "Close" ), KiBitmap( cancel_xpm ) );
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
}
@ -1347,15 +1060,6 @@ static bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame );
void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event )
{
DrawPageOnClipboard( this );
if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD )
{
// fixme-gal
//if( GetScreen()->IsBlockActive() )
//m_canvas->SetCursor( wxCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ) );
m_canvas->EndMouseCapture();
}
}

View File

@ -31,7 +31,6 @@
#include <gal/graphics_abstraction_layer.h>
#include <base_screen.h>
#include <hotkeys.h>
#include <tool/common_tools.h>
@ -412,36 +411,34 @@ int COMMON_TOOLS::ToggleGrid( const TOOL_EVENT& aEvent )
}
int COMMON_TOOLS::MetricUnits( const TOOL_EVENT& aEvent )
int COMMON_TOOLS::GridProperties( const TOOL_EVENT& aEvent )
{
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM );
cmd.SetId( ID_GRID_SETTINGS );
m_frame->ProcessEvent( cmd );
return 0;
}
int COMMON_TOOLS::MetricUnits( const TOOL_EVENT& aEvent )
{
m_frame->ChangeUserUnits( MILLIMETRES );
return 0;
}
int COMMON_TOOLS::ImperialUnits( const TOOL_EVENT& aEvent )
{
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH );
m_frame->ProcessEvent( cmd );
m_frame->ChangeUserUnits( INCHES );
return 0;
}
int COMMON_TOOLS::ToggleUnits( const TOOL_EVENT& aEvent )
{
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetId( ( m_frame->GetUserUnits() == INCHES) ? ID_TB_OPTIONS_SELECT_UNIT_MM
: ID_TB_OPTIONS_SELECT_UNIT_INCH );
m_frame->ProcessEvent( cmd );
m_frame->ChangeUserUnits( m_frame->GetUserUnits() == INCHES ? MILLIMETRES : INCHES );
return 0;
}
@ -505,6 +502,7 @@ void COMMON_TOOLS::setTransitions()
Go( &COMMON_TOOLS::GridPrev, ACTIONS::gridPrev.MakeEvent() );
Go( &COMMON_TOOLS::GridPreset, ACTIONS::gridPreset.MakeEvent() );
Go( &COMMON_TOOLS::ToggleGrid, ACTIONS::toggleGrid.MakeEvent() );
Go( &COMMON_TOOLS::GridProperties, ACTIONS::gridProperties.MakeEvent() );
Go( &COMMON_TOOLS::ImperialUnits, ACTIONS::imperialUnits.MakeEvent() );
Go( &COMMON_TOOLS::MetricUnits, ACTIONS::metricUnits.MakeEvent() );

View File

@ -108,16 +108,7 @@ int CVPCB_CONTROL::SwitchCursor( const TOOL_EVENT& aEvent )
int CVPCB_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent )
{
// TODO should not it be refactored to pcb_frame member function?
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
if( m_frame->GetUserUnits() == INCHES )
evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM );
else
evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH );
m_frame->ProcessEvent( evt );
m_frame->ChangeUserUnits( m_frame->GetUserUnits() == INCHES ? MILLIMETRES : INCHES );
return 0;
}

View File

@ -229,6 +229,7 @@ set( EESCHEMA_SRCS
tools/ee_picker_tool.cpp
tools/ee_point_editor.cpp
tools/ee_selection_tool.cpp
tools/lib_editor_control.cpp
tools/lib_drawing_tools.cpp
tools/lib_edit_tool.cpp
tools/lib_move_tool.cpp

View File

@ -20,7 +20,7 @@
#include <sch_connection.h>
#include <connection_graph.h>
#include <tool/tool_manager.h>
#include <dialog_migrate_buses.h>
/**
@ -65,7 +65,7 @@ DIALOG_MIGRATE_BUSES::DIALOG_MIGRATE_BUSES( SCH_EDIT_FRAME* aParent ) :
loadGraphData();
updateUi();
m_frame->Zoom_Automatique( false );
aParent->GetToolManager()->RunAction( "common.Control.zoomFitScreen", true );
}

View File

@ -64,7 +64,6 @@ enum id_eeschema_frm
ID_BUS_MANAGER,
ID_REMAP_SYMBOLS,
ID_EDIT_COMPONENTS_TO_SYMBOLS_LIB_ID,
ID_GRID_SETTINGS,
/* Schematic editor horizontal toolbar IDs */
ID_HIERARCHY,

View File

@ -37,7 +37,7 @@
#include <kiface_i.h>
#include <richio.h>
#include <trace_helpers.h>
#include <tool/tool_manager.h>
#include <eeschema_id.h>
#include <class_library.h>
#include <lib_edit_frame.h>
@ -317,7 +317,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
// Do not leave g_RootSheet == NULL because it is expected to be
// a valid sheet. Therefore create a dummy empty root sheet and screen.
CreateScreens();
Zoom_Automatique( false );
m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
wxString msg;
msg.Printf( _( "Error loading schematic file \"%s\".\n%s" ),
@ -390,7 +390,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
}
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
Zoom_Automatique( false );
m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
SetSheetNumberAndCount();
SyncView();
GetScreen()->ClearDrawingState();
@ -653,7 +653,7 @@ bool SCH_EDIT_FRAME::AppendSchematic()
screens.TestDanglingEnds();
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
Zoom_Automatique( false );
m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
SetSheetNumberAndCount();
SyncView();
@ -881,7 +881,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
GetScreen()->TestDanglingEnds();
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
Zoom_Automatique( false );
m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
SetSheetNumberAndCount();
SyncView();
UpdateTitle();
@ -891,7 +891,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
// Do not leave g_RootSheet == NULL because it is expected to be
// a valid sheet. Therefore create a dummy empty root sheet and screen.
CreateScreens();
Zoom_Automatique( false );
m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
wxString msg;
msg.Printf( _( "Error loading schematic \"%s\".\n%s" ), aFileName, ioe.What() );

View File

@ -274,7 +274,7 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
if( !screen->m_Initialized )
{
Zoom_Automatique( false );
m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
screen->m_Initialized = true;
screen->ClearUndoORRedoList( screen->m_UndoList, 1 );
}

View File

@ -31,7 +31,6 @@
#include <base_screen.h>
#include <confirm.h>
#include <eda_doc.h>
#include <gr_basic.h>
#include <sch_edit_frame.h>
#include <msgpanel.h>
#include <confirm.h>
@ -41,8 +40,6 @@
#include <eeschema_id.h>
#include <lib_edit_frame.h>
#include <class_library.h>
#include <lib_polyline.h>
#include <lib_pin.h>
#include <lib_manager.h>
#include <widgets/symbol_tree_pane.h>
@ -51,14 +48,7 @@
#include <kicad_device_context.h>
#include <ee_hotkeys.h>
#include <eeschema_config.h>
#include <dialogs/dialog_lib_edit_text.h>
#include <dialogs/dialog_edit_component_in_lib.h>
#include <dialogs/dialog_lib_edit_pin_table.h>
#include <wildcards_and_files_ext.h>
#include <menus_helpers.h>
#include <wx/progdlg.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
@ -73,6 +63,7 @@
#include <tools/lib_edit_tool.h>
#include <tools/lib_move_tool.h>
#include <tools/lib_drawing_tools.h>
#include <tools/lib_editor_control.h>
#include <tools/ee_point_editor.h>
#include <sch_view.h>
#include <sch_painter.h>
@ -171,7 +162,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_UPDATE_UI_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_SHOW_ELECTRICAL_TYPE, LIB_EDIT_FRAME::OnUpdateElectricalType )
EVT_UPDATE_UI( ID_LIBEDIT_SHOW_HIDE_SEARCH_TREE, LIB_EDIT_FRAME::OnUpdateSearchTreeTool )
EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, LIB_EDIT_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, LIB_EDIT_FRAME::OnUpdateSwitchCanvas )
@ -227,6 +217,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SyncLibraries( true );
m_treePane = new SYMBOL_TREE_PANE( this, m_libMgr );
setupTools();
ReCreateMenuBar();
ReCreateHToolbar();
ReCreateVToolbar();
@ -253,7 +244,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_auimgr.Update();
setupTools();
GetToolManager()->RunAction( "common.Control.gridPreset", true, m_LastGridSizeId );
Raise();
@ -318,6 +308,7 @@ void LIB_EDIT_FRAME::setupTools()
m_toolManager->RegisterTool( new EE_POINT_EDITOR );
m_toolManager->RegisterTool( new LIB_MOVE_TOOL );
m_toolManager->RegisterTool( new LIB_EDIT_TOOL );
m_toolManager->RegisterTool( new LIB_EDITOR_CONTROL );
m_toolManager->InitTools();
// Run the selection tool, it is supposed to be always active
@ -449,12 +440,6 @@ void LIB_EDIT_FRAME::OnUpdateElectricalType( wxUpdateUIEvent& aEvent )
}
void LIB_EDIT_FRAME::OnUpdateSearchTreeTool( wxUpdateUIEvent& aEvent )
{
aEvent.Check( IsSearchTreeShown() );
}
void LIB_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
{
LIB_ID libId = getTargetLibId();
@ -1009,7 +994,7 @@ void LIB_EDIT_FRAME::emptyScreen()
SetCurPart( nullptr );
SetScreen( m_dummyScreen );
m_dummyScreen->ClearUndoRedoList();
Zoom_Automatique( false );
m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
Refresh();
}

View File

@ -185,10 +185,8 @@ public:
*/
void SetRepeatPinStep( int aStep) { m_repeatPinStep = aStep; }
void ReCreateMenuBar() override;
void InstallConfigFrame( wxCommandEvent& event );
void OnPreferencesOptions( wxCommandEvent& event );
void Process_Config( wxCommandEvent& event );
@ -316,7 +314,6 @@ public:
void OnUpdateDeMorganNormal( wxUpdateUIEvent& event );
void OnUpdateDeMorganConvert( wxUpdateUIEvent& event );
void OnUpdateElectricalType( wxUpdateUIEvent& aEvent );
void OnUpdateSearchTreeTool( wxUpdateUIEvent& aEvent );
void UpdateAfterSymbolProperties( wxString* aOldName, wxArrayString* aOldAliases );
void RebuildSymbolUnitsList();
@ -354,7 +351,6 @@ public:
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
void LoadSettings( wxConfigBase* aCfg ) override;
void SaveSettings( wxConfigBase* aCfg ) override;
/**
@ -419,8 +415,6 @@ private:
*/
virtual void OnActivate( wxActivateEvent& event ) override;
// General:
/**
* Set the current active library to \a aLibrary.
*

View File

@ -193,7 +193,7 @@ bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( const wxString& aAliasName, in
m_SyncPinEdit = !GetCurPart()->UnitsLocked();
GetScreen()->ClearUndoRedoList();
Zoom_Automatique( false );
m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
SetShowDeMorgan( GetCurPart()->HasConversion() );
if( aUnit > 0 )
@ -254,7 +254,7 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, const wxString& a
SetCurPart( new LIB_PART( *lib_part ) );
SetCurLib( aLibrary );
Zoom_Automatique( false );
m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
updateTitle();
RebuildSymbolUnitsList();

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2018 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
@ -23,13 +23,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file eeschema/menubar_libedit.cpp
* @brief (Re)Create the main menubar for the part editor frame (LibEdit)
*/
#include <menus_helpers.h>
#include <pgm_base.h>
#include <tool/conditional_menu.h>
#include <tool/tool_manager.h>
#include <tools/ee_actions.h>
#include <tools/ee_selection_tool.h>
#include "eeschema_id.h"
#include "general.h"
@ -40,6 +39,7 @@
void LIB_EDIT_FRAME::ReCreateMenuBar()
{
EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
// wxWidgets handles the Mac Application menu behind the scenes, but that means
// we always have to start from scratch with a new wxMenuBar.
wxMenuBar* oldMenuBar = GetMenuBar();
@ -170,136 +170,71 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
_( "Show pin table" ),
KiBitmap( pin_table_xpm ) );
//
// Menu View:
wxMenu* viewMenu = new wxMenu;
//
CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool );
AddMenuItem( viewMenu,
ID_TO_LIBVIEW,
_( "Symbol Library Browser" ),
_( "Open the symbol viewer" ),
KiBitmap( library_browse_xpm ) );
auto gridShownCondition = [ this ] ( const SELECTION& aSel ) {
return IsGridVisible();
};
viewMenu->AppendSeparator();
auto imperialUnitsCondition = [ this ] ( const SELECTION& aSel ) {
return GetUserUnits() == INCHES;
};
/**
* Important Note for ZOOM IN and ZOOM OUT commands from menubar:
* we cannot add hotkey info here, because the hotkey HK_ZOOM_IN and HK_ZOOM_OUT
* events(default = WXK_F1 and WXK_F2) are *NOT* equivalent to this menu command:
* zoom in and out from hotkeys are equivalent to the pop up menu zoom
* From here, zooming is made around the screen center
* From hotkeys, zooming is made around the mouse cursor position
* (obviously not possible from the toolbar or menubar command)
*
* in others words HK_ZOOM_IN and HK_ZOOM_OUT *are NOT* accelerators
* for Zoom in and Zoom out sub menus
*/
auto metricUnitsCondition = [ this ] ( const SELECTION& aSel ) {
return GetUserUnits() == MILLIMETRES;
};
// Zoom in
text = _( "Zoom &In" );
AddMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) );
auto fullCrosshairCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalDisplayOptions().m_fullscreenCursor;
};
// Zoom out
text = _( "Zoom &Out" );
AddMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) );
auto compTreeShownCondition = [ this ] ( const SELECTION& aSel ) {
return IsSearchTreeShown();
};
// Fit on screen
text = AddHotkeyName( _( "&Zoom to Fit" ), g_Libedit_Hotkeys_Descr, HK_ZOOM_AUTO );
AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, _( "Zoom to fit symbol" ),
KiBitmap( zoom_fit_in_page_xpm ) );
viewMenu->AddItem( EE_ACTIONS::showLibraryBrowser, EE_CONDITIONS::ShowAlways );
text = AddHotkeyName( _( "Zoom to Selection" ),
g_Schematic_Hotkeys_Descr, HK_ZOOM_SELECTION );
AddMenuItem( viewMenu, ID_ZOOM_SELECTION, text, KiBitmap( zoom_area_xpm ) );
viewMenu->AddSeparator();
viewMenu->AddItem( ACTIONS::zoomInCenter, EE_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomOutCenter, EE_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomFitScreen, EE_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomTool, EE_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomRedraw, EE_CONDITIONS::ShowAlways );
// Redraw
text = AddHotkeyName( _( "&Redraw" ), g_Libedit_Hotkeys_Descr, HK_ZOOM_REDRAW );
AddMenuItem( viewMenu, ID_ZOOM_REDRAW, text, HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) );
viewMenu->AppendSeparator();
AddMenuItem( viewMenu, ID_TB_OPTIONS_SHOW_GRID,
_( "Show &Grid" ), wxEmptyString,
KiBitmap( grid_xpm ), wxITEM_CHECK );
AddMenuItem( viewMenu, ID_GRID_SETTINGS,
_( "Grid Settings..." ), wxEmptyString,
KiBitmap( grid_xpm ) );
viewMenu->AddSeparator();
viewMenu->AddCheckItem( ACTIONS::toggleGrid, gridShownCondition );
viewMenu->AddItem( ACTIONS::gridProperties, EE_CONDITIONS::ShowAlways );
// Units submenu
wxMenu* unitsSubMenu = new wxMenu;
AddMenuItem( unitsSubMenu, ID_TB_OPTIONS_SELECT_UNIT_INCH,
_( "&Imperial" ), _( "Use imperial units" ),
KiBitmap( unit_inch_xpm ), wxITEM_RADIO );
CONDITIONAL_MENU* unitsSubMenu = new CONDITIONAL_MENU( false, selTool );
unitsSubMenu->SetTitle( _( "&Units" ) );
unitsSubMenu->AddCheckItem( ACTIONS::imperialUnits, imperialUnitsCondition );
unitsSubMenu->AddCheckItem( ACTIONS::metricUnits, metricUnitsCondition );
viewMenu->AddMenu( unitsSubMenu );
AddMenuItem( unitsSubMenu, ID_TB_OPTIONS_SELECT_UNIT_MM,
_( "&Metric" ), _( "Use metric units" ),
KiBitmap( unit_mm_xpm ), wxITEM_RADIO );
viewMenu->AddCheckItem( ACTIONS::toggleCursorStyle, fullCrosshairCondition );
AddMenuItem( viewMenu, unitsSubMenu,
-1, _( "&Units" ),
_( "Select which units are displayed" ),
KiBitmap( unit_mm_xpm ) );
AddMenuItem( viewMenu, ID_TB_OPTIONS_SELECT_CURSOR,
_( "Full &Window Crosshair" ),
_( "Change cursor shape" ),
KiBitmap( cursor_shape_xpm ), wxITEM_CHECK );
// Separator
viewMenu->AppendSeparator();
AddMenuItem( viewMenu,
ID_LIBEDIT_SHOW_HIDE_SEARCH_TREE,
_( "&Search Tree" ),
_( "Toggles the search tree visibility" ),
KiBitmap( search_tree_xpm ), wxITEM_CHECK );
viewMenu->AddSeparator();
viewMenu->AddCheckItem( EE_ACTIONS::showComponentTree, compTreeShownCondition );
//
// Menu Place:
wxMenu* placeMenu = new wxMenu;
//
CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool );
// Pin
AddMenuItem( placeMenu,
ID_LIBEDIT_PIN_BUTT,
_( "&Pin" ),
HELP_ADD_PIN,
KiBitmap( pin_xpm ) );
// Graphic text
AddMenuItem( placeMenu,
ID_LIBEDIT_BODY_TEXT_BUTT,
_( "Graphic &Text" ),
HELP_ADD_BODYTEXT,
KiBitmap( text_xpm ) );
// Graphic rectangle
AddMenuItem( placeMenu,
ID_LIBEDIT_BODY_RECT_BUTT,
_( "&Rectangle" ),
HELP_ADD_BODYRECT,
KiBitmap( add_rectangle_xpm ) );
// Graphic Circle
AddMenuItem( placeMenu,
ID_LIBEDIT_BODY_CIRCLE_BUTT,
_( "&Circle" ),
HELP_ADD_BODYCIRCLE,
KiBitmap( add_circle_xpm ) );
// Graphic Arc
AddMenuItem( placeMenu,
ID_LIBEDIT_BODY_ARC_BUTT,
_( "&Arc" ),
HELP_ADD_BODYARC,
KiBitmap( add_arc_xpm ) );
// Graphic Line or Polygon
AddMenuItem( placeMenu,
ID_LIBEDIT_BODY_LINE_BUTT,
_( "&Line or Polygon" ),
HELP_ADD_BODYPOLYGON,
KiBitmap( add_polygon_xpm ) );
placeMenu->AddItem( EE_ACTIONS::placeSymbolPin, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::placeSymbolText, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::drawSymbolRectangle, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::drawSymbolCircle, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::drawSymbolArc, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::drawSymbolLines, EE_CONDITIONS::ShowAlways );
//
// Menu Inspect:
//
wxMenu* inspectMenu = new wxMenu;

View File

@ -245,4 +245,8 @@ void LIB_EDIT_FRAME::SyncMenusAndToolbars()
KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions();
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR, galOpts.m_fullscreenCursor );
m_optionsToolBar->ToggleTool( ID_LIBEDIT_SHOW_HIDE_SEARCH_TREE, IsSearchTreeShown() );
m_optionsToolBar->Refresh();
}

View File

@ -42,11 +42,8 @@ class CONDITIONAL_MENU;
// helper functions that build specific submenus:
// Build the place submenu
static void preparePlaceMenu( CONDITIONAL_MENU* aParentMenu, EE_SELECTION_TOOL* selTool );
// Build the files menu. Because some commands are available only if
// Eeschemat is run outside a project (run alone), aIsOutsideProject is false
// Eeschema is run outside a project (run alone), aIsOutsideProject is false
// when Eeschema is run from Kicad manager, and true is run as stand alone app.
static void prepareFilesMenu( wxMenu* aParentMenu, bool aIsOutsideProject );
@ -62,9 +59,6 @@ static void prepareHelpMenu( wxMenu* aParentMenu );
// Build the edit menu
static void prepareEditMenu( wxMenu* aParentMenu );
// Build the view menu
static void prepareViewMenu( CONDITIONAL_MENU* aParentMenu, EE_SELECTION_TOOL* selTool );
// Build the preferences menu
static void preparePreferencesMenu( SCH_EDIT_FRAME* aFrame, wxMenu* aParentMenu );
@ -78,37 +72,126 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
wxMenuBar* menuBar = new wxMenuBar();
wxString text;
// Recreate all menus:
//
// Menu File:
//
wxMenu* fileMenu = new wxMenu;
prepareFilesMenu( fileMenu, Kiface().IsSingle() );
//
// Menu Edit:
//
wxMenu* editMenu = new wxMenu;
prepareEditMenu( editMenu );
//
// Menu View:
//
CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool );
prepareViewMenu( viewMenu, selTool );
auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
return g_CurrentSheet->Last() != g_RootSheet;
};
auto gridShownCondition = [ this ] ( const SELECTION& aSel ) {
return IsGridVisible();
};
auto imperialUnitsCondition = [ this ] ( const SELECTION& aSel ) {
return GetUserUnits() == INCHES;
};
auto metricUnitsCondition = [ this ] ( const SELECTION& aSel ) {
return GetUserUnits() == MILLIMETRES;
};
auto fullCrosshairCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalDisplayOptions().m_fullscreenCursor;
};
auto hiddenPinsCondition = [ this ] ( const SELECTION& aSel ) {
return GetShowAllPins();
};
viewMenu->AddItem( EE_ACTIONS::showLibraryBrowser, EE_CONDITIONS::ShowAlways );
viewMenu->AddItem( EE_ACTIONS::navigateHierarchy, EE_CONDITIONS::ShowAlways );
viewMenu->AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition );
viewMenu->AddSeparator();
viewMenu->AddItem( ACTIONS::zoomInCenter, EE_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomOutCenter, EE_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomFitScreen, EE_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomTool, EE_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomRedraw, EE_CONDITIONS::ShowAlways );
viewMenu->AddSeparator();
viewMenu->AddCheckItem( ACTIONS::toggleGrid, gridShownCondition );
viewMenu->AddItem( ACTIONS::gridProperties, EE_CONDITIONS::ShowAlways );
// Units submenu
CONDITIONAL_MENU* unitsSubMenu = new CONDITIONAL_MENU( false, selTool );
unitsSubMenu->SetTitle( _( "&Units" ) );
unitsSubMenu->AddCheckItem( ACTIONS::imperialUnits, imperialUnitsCondition );
unitsSubMenu->AddCheckItem( ACTIONS::metricUnits, metricUnitsCondition );
viewMenu->AddMenu( unitsSubMenu );
viewMenu->AddCheckItem( ACTIONS::toggleCursorStyle, fullCrosshairCondition );
viewMenu->AddSeparator();
viewMenu->AddCheckItem( EE_ACTIONS::toggleHiddenPins, hiddenPinsCondition );
#ifdef __APPLE__
viewMenu->AppendSeparator();
#endif
//
// Menu place:
//
CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool );
preparePlaceMenu( placeMenu, selTool );
placeMenu->AddItem( EE_ACTIONS::placeSymbol, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::placePower, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::drawWire, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::drawBus, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::placeBusWireEntry, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::placeBusBusEntry, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::placeNoConnect, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::placeJunction, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::placeLabel, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::placeGlobalLabel, EE_CONDITIONS::ShowAlways );
placeMenu->AddSeparator();
placeMenu->AddItem( EE_ACTIONS::placeHierarchicalLabel, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::drawSheet, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::importSheetPin, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::placeSheetPin, EE_CONDITIONS::ShowAlways );
placeMenu->AddSeparator();
placeMenu->AddItem( EE_ACTIONS::drawLines, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::placeSchematicText, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::placeImage, EE_CONDITIONS::ShowAlways );
//
// Menu Inspect:
//
wxMenu* inspectMenu = new wxMenu;
prepareInspectMenu( inspectMenu );
//
// Menu Tools:
//
wxMenu* toolsMenu = new wxMenu;
prepareToolsMenu( toolsMenu );
//
// Menu Preferences:
//
wxMenu* preferencesMenu = new wxMenu;
preparePreferencesMenu( this, preferencesMenu );
//
// Help Menu:
//
wxMenu* helpMenu = new wxMenu;
prepareHelpMenu( helpMenu );
@ -127,93 +210,6 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
}
void prepareViewMenu( CONDITIONAL_MENU* aParentMenu, EE_SELECTION_TOOL* selTool )
{
SCH_EDIT_FRAME* frame = static_cast<SCH_EDIT_FRAME*>( selTool->GetManager()->GetEditFrame() );
auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
return g_CurrentSheet->Last() != g_RootSheet;
};
auto gridShownCondition = [ frame ] ( const SELECTION& aSel ) {
return frame->IsGridVisible();
};
auto imperialUnitsCondition = [ frame ] ( const SELECTION& aSel ) {
return frame->GetUserUnits() == INCHES;
};
auto metricUnitsCondition = [ frame ] ( const SELECTION& aSel ) {
return frame->GetUserUnits() == MILLIMETRES;
};
auto fullCrosshairCondition = [ frame ] ( const SELECTION& aSel ) {
return frame->GetGalDisplayOptions().m_fullscreenCursor;
};
auto hiddenPinsCondition = [ frame ] ( const SELECTION& aSel ) {
return frame->GetShowAllPins();
};
aParentMenu->AddItem( EE_ACTIONS::showLibraryBrowser, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::navigateHierarchy, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition );
aParentMenu->AddSeparator();
aParentMenu->AddItem( ACTIONS::zoomInCenter, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( ACTIONS::zoomOutCenter, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( ACTIONS::zoomFitScreen, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( ACTIONS::zoomTool, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( ACTIONS::zoomRedraw, EE_CONDITIONS::ShowAlways );
aParentMenu->AddSeparator();
aParentMenu->AddCheckItem( ACTIONS::toggleGrid, gridShownCondition );
aParentMenu->AddItem( ACTIONS::gridProperties, EE_CONDITIONS::ShowAlways );
// Units submenu
CONDITIONAL_MENU* unitsSubMenu = new CONDITIONAL_MENU( false, selTool );
unitsSubMenu->SetTitle( _( "&Units" ) );
unitsSubMenu->AddCheckItem( ACTIONS::imperialUnits, imperialUnitsCondition );
unitsSubMenu->AddCheckItem( ACTIONS::metricUnits, metricUnitsCondition );
aParentMenu->AddMenu( unitsSubMenu );
aParentMenu->AddCheckItem( ACTIONS::toggleCursorStyle, fullCrosshairCondition );
aParentMenu->AddSeparator();
aParentMenu->AddCheckItem( EE_ACTIONS::toggleHiddenPins, hiddenPinsCondition );
#ifdef __APPLE__
aParentMenu->AppendSeparator();
#endif
}
void preparePlaceMenu( CONDITIONAL_MENU* aParentMenu, EE_SELECTION_TOOL* selTool )
{
aParentMenu->AddItem( EE_ACTIONS::placeSymbol, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placePower, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::drawWire, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::drawBus, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeBusWireEntry, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeBusBusEntry, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeNoConnect, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeJunction, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeLabel, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeGlobalLabel, EE_CONDITIONS::ShowAlways );
aParentMenu->AddSeparator();
aParentMenu->AddItem( EE_ACTIONS::placeHierarchicalLabel, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::drawSheet, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::importSheetPin, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeSheetPin, EE_CONDITIONS::ShowAlways );
aParentMenu->AddSeparator();
aParentMenu->AddItem( EE_ACTIONS::drawLines, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeSchematicText, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeImage, EE_CONDITIONS::ShowAlways );
}
void prepareFilesMenu( wxMenu* aParentMenu, bool aIsOutsideProject )
{
wxString text;

View File

@ -279,10 +279,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_MENU_CANVAS_CAIRO, SCH_EDIT_FRAME::OnSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_OPENGL, SCH_EDIT_FRAME::OnSwitchCanvas )
// Tools and buttons options toolbar
EVT_TOOL( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnSelectOptionToolbar )
/* Handle user interface update events. */
EVT_UPDATE_UI( wxID_PASTE, SCH_EDIT_FRAME::OnUpdatePaste )
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnUpdateSelectTool )
@ -292,7 +288,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
SCH_EDIT_FRAME::OnUpdateSelectTool )
EVT_UPDATE_UI( ID_SAVE_PROJECT, SCH_EDIT_FRAME::OnUpdateSave )
EVT_UPDATE_UI( ID_UPDATE_ONE_SHEET, SCH_EDIT_FRAME::OnUpdateSaveSheet )
EVT_UPDATE_UI( ID_SCH_LEAVE_SHEET, SCH_EDIT_FRAME::OnUpdateHierarchySheet )
EVT_UPDATE_UI( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnUpdateRemapSymbols )
EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, SCH_EDIT_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, SCH_EDIT_FRAME::OnUpdateSwitchCanvas )
@ -785,12 +780,6 @@ void SCH_EDIT_FRAME::OnUpdateSaveSheet( wxUpdateUIEvent& aEvent )
}
void SCH_EDIT_FRAME::OnUpdateHierarchySheet( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( g_CurrentSheet->Last() != g_RootSheet );
}
void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event )
{
// See if it's already open...

View File

@ -40,16 +40,8 @@
#include <sch_text.h>
#include <tool/selection.h>
class LIB_EDIT_FRAME;
class LIB_VIEW_FRAME;
class DRAWSEGMENT;
class SCH_ITEM;
class SCH_NO_CONNECT;
class EDA_ITEM;
class SCH_BUS_ENTRY_BASE;
class SCH_BUS_WIRE_ENTRY;
class SCH_BUS_BUS_ENTRY;
class SCH_GLOBALLABEL;
class SCH_TEXT;
class SCH_BITMAP;
class SCH_SHEET;
@ -57,15 +49,11 @@ class SCH_SHEET_PATH;
class SCH_SHEET_PIN;
class SCH_COMPONENT;
class SCH_FIELD;
class LIB_PIN;
class SCH_JUNCTION;
class DIALOG_SCH_FIND;
class DIALOG_ANNOTATE;
class wxFindDialogEvent;
class wxFindReplaceData;
class SCHLIB_FILTER;
class RESCUER;
class CONNECTION_GRAPH;
/// enum used in RotationMiroir()
@ -247,14 +235,8 @@ public:
const wxString& GetPlotDirectoryName() const { return m_plotDirectoryName; }
void SetPlotDirectoryName( const wxString& aDirName ) { m_plotDirectoryName = aDirName; }
void Process_Special_Functions( wxCommandEvent& event );
void Process_Config( wxCommandEvent& event );
/**
* Builds the context menu for unfolding a bus
*/
wxMenu* GetUnfoldBusMenu( SCH_LINE* aBus );
/**
* Return the project file parameter list for Eeschema.
*
@ -283,15 +265,6 @@ public:
void UpdateErcSettings( const ERC_SETTINGS& aSettings ) { m_ercSettings = aSettings; }
/**
* Return a default symbol field name for field \a aFieldNdx for all components.
*
* These field names are not modifiable, but template field names are.
*
* @param aFieldNdx The field number index
*/
static wxString GetDefaultFieldName( int aFieldNdx );
/**
* Insert or append a wanted symbol field name into the field names template.
*
@ -364,7 +337,6 @@ public:
void KiwayMailIn( KIWAY_EXPRESS& aEvent ) override;
bool OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) override { return true; }
void OnSelectOptionToolbar( wxCommandEvent& event );
double BestZoom() override;
/**
@ -785,7 +757,6 @@ private:
void OnFindItems( wxCommandEvent& event );
void OnFindDialogClose( wxFindDialogEvent& event );
void OnFindDrcMarker( wxFindDialogEvent& event );
void OnFindCompnentInLib( wxFindDialogEvent& event );
/**
* Find an item in the schematic matching the search criteria in \a aEvent.
@ -823,11 +794,9 @@ private:
/* User interface update event handlers. */
void OnUpdatePaste( wxUpdateUIEvent& event );
void OnUpdateBusOrientation( wxUpdateUIEvent& event );
void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
void OnUpdateSave( wxUpdateUIEvent& aEvent );
void OnUpdateSaveSheet( wxUpdateUIEvent& aEvent );
void OnUpdateHierarchySheet( wxUpdateUIEvent& aEvent );
void OnUpdateRemapSymbols( wxUpdateUIEvent& aEvent );
/**
@ -1178,8 +1147,6 @@ public:
*/
void RecalculateConnections( bool aDoCleanup = true );
void SetCurrentSheet( SCH_SHEET_PATH *aSheet );
/**
* Allows Eeschema to install its preferences panels into the preferences dialog.
*/

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -23,18 +23,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file tool_sch.cpp
*/
#include <fctsys.h>
#include <sch_draw_panel.h>
#include <sch_edit_frame.h>
#include <kiface_i.h>
#include <bitmaps.h>
#include <sch_view.h>
#include <sch_painter.h>
#include <general.h>
#include <ee_hotkeys.h>
#include <eeschema_id.h>
#include <tool/tool_manager.h>
@ -310,29 +303,10 @@ void SCH_EDIT_FRAME::ReCreateOptToolbar()
}
void SCH_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{
int id = event.GetId();
switch( id )
{
case ID_TB_OPTIONS_HIDDEN_PINS:
m_toolManager->RunAction( EE_ACTIONS::toggleHiddenPins, true );
break;
case ID_TB_OPTIONS_BUS_WIRES_ORIENT:
SetForceHVLines( m_optionsToolBar->GetToolToggled( id ) );
break;
default:
wxFAIL_MSG( wxT( "Unexpected select option tool bar ID." ) );
break;
}
}
void SCH_EDIT_FRAME::SyncMenusAndToolbars()
{
m_mainToolBar->EnableTool( ID_SCH_LEAVE_SHEET, g_CurrentSheet->Last() != g_RootSheet );
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID, IsGridVisible() );
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM, GetUserUnits() != INCHES );
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, GetUserUnits() == INCHES );

View File

@ -39,6 +39,24 @@ OPT<TOOL_EVENT> EE_ACTIONS::TranslateLegacyId( int aId )
case ID_CANCEL_CURRENT_COMMAND:
return ACTIONS::cancelInteractive.MakeEvent();
case ID_TB_OPTIONS_SHOW_GRID:
return ACTIONS::toggleGrid.MakeEvent();
case ID_TB_OPTIONS_SELECT_CURSOR:
return ACTIONS::toggleCursorStyle.MakeEvent();
case ID_TB_OPTIONS_BUS_WIRES_ORIENT:
return EE_ACTIONS::toggleForceHV.MakeEvent();
case ID_TB_OPTIONS_SELECT_UNIT_INCH:
return ACTIONS::imperialUnits.MakeEvent();
case ID_TB_OPTIONS_SELECT_UNIT_MM:
return ACTIONS::metricUnits.MakeEvent();
case ID_TB_OPTIONS_HIDDEN_PINS:
return EE_ACTIONS::toggleHiddenPins.MakeEvent();
case ID_ZOOM_REDRAW:
case ID_VIEWER_ZOOM_REDRAW:
return ACTIONS::zoomRedraw.MakeEvent();

View File

@ -169,6 +169,8 @@ public:
static TOOL_ACTION pushPinLength;
static TOOL_ACTION pushPinNameSize;
static TOOL_ACTION pushPinNumSize;
static TOOL_ACTION showComponentTree;
static TOOL_ACTION toggleForceHV;
// SPICE
static TOOL_ACTION simProbe;

View File

@ -0,0 +1,70 @@
/*
* 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 <fctsys.h>
#include <tool/tool_manager.h>
#include <tools/ee_actions.h>
#include <lib_edit_frame.h>
#include <tools/lib_editor_control.h>
TOOL_ACTION EE_ACTIONS::showComponentTree( "eeschema.SymbolEditorControl.showComponentTree",
AS_GLOBAL, 0,
_( "Show Symbol Tree" ), "",
search_tree_xpm );
LIB_EDITOR_CONTROL::LIB_EDITOR_CONTROL() :
EE_TOOL_BASE<LIB_EDIT_FRAME>( "eeschema.SymbolEditorControl" )
{
}
LIB_EDITOR_CONTROL::~LIB_EDITOR_CONTROL()
{
}
int LIB_EDITOR_CONTROL::ShowLibraryBrowser( const TOOL_EVENT& aEvent )
{
wxCommandEvent dummy;
m_frame->OnOpenLibraryViewer( dummy );
return 0;
}
int LIB_EDITOR_CONTROL::ShowComponentTree( const TOOL_EVENT& aEvent )
{
wxCommandEvent dummy;
m_frame->OnToggleSearchTree( dummy );
return 0;
}
void LIB_EDITOR_CONTROL::setTransitions()
{
Go( &LIB_EDITOR_CONTROL::ShowLibraryBrowser, EE_ACTIONS::showLibraryBrowser.MakeEvent() );
Go( &LIB_EDITOR_CONTROL::ShowComponentTree, EE_ACTIONS::showComponentTree.MakeEvent() );
}

View File

@ -0,0 +1,57 @@
/*
* 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
*/
#ifndef LIB_EDITOR_CONTROL_H
#define LIB_EDITOR_CONTROL_H
#include <sch_base_frame.h>
#include <tools/ee_tool_base.h>
class LIB_EDIT_FRAME;
/**
* Class LIB_EDITOR_CONTROL
*
* Handles actions specific to the schematic editor in eeschema.
*/
class LIB_EDITOR_CONTROL : public wxEvtHandler, public EE_TOOL_BASE<LIB_EDIT_FRAME>
{
public:
LIB_EDITOR_CONTROL();
~LIB_EDITOR_CONTROL();
int ToggleLockSelected( const TOOL_EVENT& aEvent );
int LockSelected( const TOOL_EVENT& aEvent );
int UnlockSelected( const TOOL_EVENT& aEvent );
int ShowLibraryBrowser( const TOOL_EVENT& aEvent );
int ShowComponentTree( const TOOL_EVENT& aEvent );
private:
///> Sets up handlers for various events.
void setTransitions() override;
};
#endif // LIB_EDITOR_CONTROL_H

View File

@ -122,6 +122,11 @@ TOOL_ACTION EE_ACTIONS::toggleHiddenPins( "eeschema.EditorControl.showHiddenPins
_( "Show Hidden Pins" ), "",
hidden_pin_xpm );
TOOL_ACTION EE_ACTIONS::toggleForceHV( "eeschema.EditorControl.forceHVLines",
AS_GLOBAL, 0,
_( "Force H/V Wires and Busses" ), "",
lines90_xpm );
SCH_EDITOR_CONTROL::SCH_EDITOR_CONTROL() :
EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.EditorControl" )
@ -728,6 +733,15 @@ int SCH_EDITOR_CONTROL::ToggleHiddenPins( const TOOL_EVENT& aEvent )
}
int SCH_EDITOR_CONTROL::ToggleForceHV( const TOOL_EVENT& aEvent )
{
m_frame->SetForceHVLines( !m_frame->GetForceHVLines() );
return 0;
}
void SCH_EDITOR_CONTROL::setTransitions()
{
/*
@ -764,4 +778,5 @@ void SCH_EDITOR_CONTROL::setTransitions()
Go( &SCH_EDITOR_CONTROL::NavigateHierarchy, EE_ACTIONS::navigateHierarchy.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::ToggleHiddenPins, EE_ACTIONS::toggleHiddenPins.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::ToggleForceHV, EE_ACTIONS::toggleForceHV.MakeEvent() );
}

View File

@ -82,6 +82,7 @@ public:
int NavigateHierarchy( const TOOL_EVENT& aEvent );
int ToggleHiddenPins( const TOOL_EVENT& aEvent );
int ToggleForceHV( const TOOL_EVENT& aEvent );
private:
///> copy selection to clipboard

View File

@ -682,7 +682,7 @@ void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName )
}
updatePreviewSymbol();
Zoom_Automatique( false );
m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
}
}

View File

@ -235,16 +235,7 @@ int GERBVIEW_CONTROL::ResetCoords( const TOOL_EVENT& aEvent )
int GERBVIEW_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent )
{
// TODO: Refactor to share with pcbnew
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
if( m_frame->GetUserUnits() == INCHES )
evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM );
else
evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH );
m_frame->ProcessEvent( evt );
m_frame->ChangeUserUnits( m_frame->GetUserUnits() == INCHES ? MILLIMETRES : INCHES );
return 0;
}

View File

@ -287,6 +287,12 @@ public:
EDA_UNITS_T GetUserUnits() const override { return m_UserUnits; }
void SetUserUnits( EDA_UNITS_T aUnits ) { m_UserUnits = aUnits; }
void ChangeUserUnits( EDA_UNITS_T aUnits )
{
SetUserUnits( aUnits );
unitsChangeRefresh();
}
/**
* Return the origin of the axis used for plotting and various exports.
*/

View File

@ -228,6 +228,8 @@ enum main_id
ID_POPUP_GRID_LEVEL_0_0_1MM,
ID_POPUP_GRID_USER,
ID_GRID_SETTINGS,
ID_SHEET_SET,
ID_COMPONENT_BUTT,

View File

@ -71,6 +71,7 @@ public:
int GridPrev( const TOOL_EVENT& aEvent );
int GridPreset( const TOOL_EVENT& aEvent );
int ToggleGrid( const TOOL_EVENT& aEvent );
int GridProperties( const TOOL_EVENT& aEvent );
///> Sets up handlers for various events.
void setTransitions() override;