Move eeschema zoom-selection to modern toolset.
Fixes: lp:1825164 * https://bugs.launchpad.net/kicad/+bug/1825164
This commit is contained in:
parent
c88fd514a0
commit
0772b54845
|
@ -109,27 +109,21 @@ bool ZOOM_TOOL::selectRegion()
|
|||
view->SetVisible( &area, false );
|
||||
auto selectionBox = area.ViewBBox();
|
||||
|
||||
VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false );
|
||||
|
||||
if( selectionBox.GetWidth() == 0 || selectionBox.GetHeight() == 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
VECTOR2D vsize = selectionBox.GetSize();
|
||||
VECTOR2D sSize = view->ToWorld( canvas->GetClientSize(), false );
|
||||
VECTOR2D vSize = selectionBox.GetSize();
|
||||
double scale;
|
||||
double ratio = std::max( fabs( vsize.x / screenSize.x ),
|
||||
fabs( vsize.y / screenSize.y ) );
|
||||
double ratio = std::max( fabs( vSize.x / sSize.x ), fabs( vSize.y / sSize.y ) );
|
||||
|
||||
if( evt->IsMouseUp( BUT_LEFT ) )
|
||||
{
|
||||
scale = view->GetScale() / ratio;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale = view->GetScale() * ratio;
|
||||
}
|
||||
|
||||
view->SetScale( scale );
|
||||
view->SetCenter( selectionBox.Centre() );
|
||||
|
|
|
@ -126,8 +126,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
|||
|
||||
// Right vertical toolbar.
|
||||
EVT_TOOL( ID_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnSelectTool )
|
||||
EVT_MENU( ID_MENU_ZOOM_SELECTION, LIB_EDIT_FRAME::OnSelectTool )
|
||||
EVT_TOOL( ID_ZOOM_SELECTION, LIB_EDIT_FRAME::OnSelectTool )
|
||||
EVT_TOOL_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
|
||||
LIB_EDIT_FRAME::OnSelectTool )
|
||||
|
||||
|
@ -1045,7 +1043,6 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event )
|
|||
void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
||||
{
|
||||
int id = aEvent.GetId();
|
||||
int lastToolID = GetToolId();
|
||||
|
||||
if( GetToolId() == ID_NO_TOOL_SELECTED || GetToolId() == ID_ZOOM_SELECTION )
|
||||
m_lastDrawItem = NULL;
|
||||
|
@ -1055,21 +1052,23 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
|||
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
switch( id )
|
||||
{
|
||||
case ID_ZOOM_SELECTION:
|
||||
// moved to modern toolset
|
||||
return;
|
||||
default:
|
||||
// since legacy tools don't activate themsleves, we have to deactivate any modern
|
||||
// tools that might be running until all the legacy tools are moved over....
|
||||
m_toolManager->DeactivateTool();
|
||||
}
|
||||
|
||||
switch( id )
|
||||
{
|
||||
case ID_NO_TOOL_SELECTED:
|
||||
SetToolID( id, GetGalCanvas()->GetDefaultCursor(), wxEmptyString );
|
||||
break;
|
||||
|
||||
case ID_MENU_ZOOM_SELECTION:
|
||||
case ID_ZOOM_SELECTION:
|
||||
// This tool is located on the main toolbar: switch it on or off on click on it
|
||||
if( lastToolID != ID_ZOOM_SELECTION )
|
||||
SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
|
||||
else
|
||||
SetNoToolSelected();
|
||||
break;
|
||||
|
||||
case ID_LIBEDIT_PIN_BUTT:
|
||||
if( part )
|
||||
{
|
||||
|
|
|
@ -202,7 +202,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
|||
|
||||
text = AddHotkeyName( _( "Zoom to Selection" ),
|
||||
g_Schematic_Hotkeys_Descr, HK_ZOOM_SELECTION );
|
||||
AddMenuItem( viewMenu, ID_MENU_ZOOM_SELECTION, text, KiBitmap( zoom_area_xpm ) );
|
||||
AddMenuItem( viewMenu, ID_ZOOM_SELECTION, text, KiBitmap( zoom_area_xpm ) );
|
||||
|
||||
// Redraw
|
||||
text = AddHotkeyName( _( "&Redraw" ), g_Libedit_Hotkeys_Descr, HK_ZOOM_REDRAW );
|
||||
|
|
|
@ -178,7 +178,7 @@ void prepareViewMenu( wxMenu* aParentMenu )
|
|||
|
||||
text = AddHotkeyName( _( "Zoom to Selection" ), g_Eeschema_Hotkeys_Descr, HK_ZOOM_SELECTION );
|
||||
|
||||
AddMenuItem( aParentMenu, ID_MENU_ZOOM_SELECTION, text, KiBitmap( zoom_area_xpm ) );
|
||||
AddMenuItem( aParentMenu, ID_ZOOM_SELECTION, text, KiBitmap( zoom_area_xpm ) );
|
||||
|
||||
text = AddHotkeyName( _( "&Redraw" ), g_Schematic_Hotkeys_Descr, HK_ZOOM_REDRAW );
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
|||
case ID_TEXT_COMMENT_BUTT:
|
||||
case ID_LINE_COMMENT_BUTT:
|
||||
case ID_ADD_IMAGE_BUTT:
|
||||
case ID_ZOOM_SELECTION:
|
||||
return; // Moved to modern toolset
|
||||
default:
|
||||
break;
|
||||
|
@ -102,9 +103,6 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
|||
case ID_NO_TOOL_SELECTED:
|
||||
break;
|
||||
|
||||
case ID_ZOOM_SELECTION:
|
||||
break;
|
||||
|
||||
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
|
||||
DeleteItemAtCrossHair();
|
||||
break;
|
||||
|
|
|
@ -287,8 +287,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
|||
|
||||
// Tools and buttons for vertical toolbar.
|
||||
EVT_TOOL( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnSelectTool )
|
||||
EVT_MENU( ID_MENU_ZOOM_SELECTION, SCH_EDIT_FRAME::OnSelectTool )
|
||||
EVT_TOOL( ID_ZOOM_SELECTION, SCH_EDIT_FRAME::OnSelectTool )
|
||||
EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
|
||||
SCH_EDIT_FRAME::OnSelectTool )
|
||||
EVT_TOOL_RANGE( ID_SCHEMATIC_PLACE_MENU_START, ID_SCHEMATIC_PLACE_MENU_END,
|
||||
|
|
|
@ -501,7 +501,6 @@ void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
|
|||
void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
||||
{
|
||||
int id = aEvent.GetId();
|
||||
int lastToolID = GetToolId();
|
||||
|
||||
// Stop the current command and deselect the current tool.
|
||||
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
|
||||
|
@ -537,6 +536,7 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
|||
case ID_BUS_BUTT:
|
||||
case ID_MENU_LINE_COMMENT_BUTT:
|
||||
case ID_LINE_COMMENT_BUTT:
|
||||
case ID_ZOOM_SELECTION:
|
||||
// moved to modern toolset
|
||||
return;
|
||||
default:
|
||||
|
@ -551,15 +551,6 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
|||
SetNoToolSelected();
|
||||
break;
|
||||
|
||||
case ID_MENU_ZOOM_SELECTION:
|
||||
case ID_ZOOM_SELECTION:
|
||||
// This tool is located on the main toolbar: switch it on or off on click
|
||||
if( lastToolID != ID_ZOOM_SELECTION )
|
||||
SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
|
||||
else
|
||||
SetNoToolSelected();
|
||||
break;
|
||||
|
||||
case ID_MENU_SHEET_SYMBOL_BUTT:
|
||||
case ID_SHEET_SYMBOL_BUTT:
|
||||
SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add sheet" ) );
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <tools/sch_drawing_tool.h>
|
||||
|
||||
#include <sch_actions.h>
|
||||
#include <tool/zoom_tool.h>
|
||||
|
||||
OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
||||
{
|
||||
|
@ -147,6 +148,7 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
|||
void SCH_ACTIONS::RegisterAllTools( TOOL_MANAGER* aToolManager )
|
||||
{
|
||||
aToolManager->RegisterTool( new COMMON_TOOLS );
|
||||
aToolManager->RegisterTool( new ZOOM_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_EDITOR_CONTROL );
|
||||
aToolManager->RegisterTool( new SCH_PICKER_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_DRAWING_TOOL );
|
||||
|
|
|
@ -112,7 +112,7 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
|
|||
|
||||
EVT_SELECT_DCODE( ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, GERBVIEW_FRAME::OnSelectActiveDCode )
|
||||
|
||||
EVT_MENU( ID_MENU_ZOOM_SELECTION, GERBVIEW_FRAME::Process_Special_Functions )
|
||||
EVT_MENU( ID_ZOOM_SELECTION, GERBVIEW_FRAME::Process_Special_Functions )
|
||||
|
||||
// Vertical toolbar:
|
||||
EVT_TOOL( ID_NO_TOOL_SELECTED, GERBVIEW_FRAME::Process_Special_Functions )
|
||||
|
@ -224,7 +224,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
SetNoToolSelected();
|
||||
break;
|
||||
|
||||
case ID_MENU_ZOOM_SELECTION:
|
||||
case ID_ZOOM_SELECTION:
|
||||
// This tool is located on the main toolbar: switch it on or off on click
|
||||
if( GetToolId() != ID_ZOOM_SELECTION )
|
||||
|
|
|
@ -119,7 +119,6 @@ enum main_id
|
|||
ID_EDIT,
|
||||
ID_NO_TOOL_SELECTED,
|
||||
ID_ZOOM_SELECTION,
|
||||
ID_MENU_ZOOM_SELECTION, // similar to ID_ZOOM_SELECTION, used in main memubar
|
||||
ID_SEL_BG_COLOR,
|
||||
|
||||
ID_REPEAT_BUTT,
|
||||
|
|
|
@ -91,7 +91,6 @@ BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME )
|
|||
EVT_TOOL( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode )
|
||||
EVT_TOOL( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode )
|
||||
EVT_TOOL( ID_NO_TOOL_SELECTED, PL_EDITOR_FRAME::Process_Special_Functions )
|
||||
EVT_MENU( ID_MENU_ZOOM_SELECTION, PL_EDITOR_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_ZOOM_SELECTION, PL_EDITOR_FRAME::Process_Special_Functions )
|
||||
EVT_CHOICE( ID_SELECT_COORDINATE_ORIGIN, PL_EDITOR_FRAME::OnSelectCoordOriginCorner)
|
||||
EVT_CHOICE( ID_SELECT_PAGE_NUMBER, PL_EDITOR_FRAME::Process_Special_Functions)
|
||||
|
@ -131,7 +130,6 @@ void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
SetNoToolSelected();
|
||||
break;
|
||||
|
||||
case ID_MENU_ZOOM_SELECTION:
|
||||
case ID_ZOOM_SELECTION:
|
||||
// This tool is located on the main toolbar: switch it on or off on click
|
||||
if( GetToolId() != ID_ZOOM_SELECTION )
|
||||
|
|
|
@ -129,7 +129,7 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
|
|||
AddMenuItem( viewMenu, ID_ZOOM_PAGE, msg, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ) );
|
||||
|
||||
msg = AddHotkeyName( _( "Zoom to Selection" ), PlEditorHotkeysDescr, HK_ZOOM_SELECTION );
|
||||
AddMenuItem( viewMenu, ID_MENU_ZOOM_SELECTION, msg, wxEmptyString, KiBitmap( zoom_area_xpm ) );
|
||||
AddMenuItem( viewMenu, ID_ZOOM_SELECTION, msg, wxEmptyString, KiBitmap( zoom_area_xpm ) );
|
||||
|
||||
viewMenu->AppendSeparator();
|
||||
|
||||
|
|
Loading…
Reference in New Issue