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 );
|
view->SetVisible( &area, false );
|
||||||
auto selectionBox = area.ViewBBox();
|
auto selectionBox = area.ViewBBox();
|
||||||
|
|
||||||
VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false );
|
|
||||||
|
|
||||||
if( selectionBox.GetWidth() == 0 || selectionBox.GetHeight() == 0 )
|
if( selectionBox.GetWidth() == 0 || selectionBox.GetHeight() == 0 )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VECTOR2D vsize = selectionBox.GetSize();
|
VECTOR2D sSize = view->ToWorld( canvas->GetClientSize(), false );
|
||||||
|
VECTOR2D vSize = selectionBox.GetSize();
|
||||||
double scale;
|
double scale;
|
||||||
double ratio = std::max( fabs( vsize.x / screenSize.x ),
|
double ratio = std::max( fabs( vSize.x / sSize.x ), fabs( vSize.y / sSize.y ) );
|
||||||
fabs( vsize.y / screenSize.y ) );
|
|
||||||
|
|
||||||
if( evt->IsMouseUp( BUT_LEFT ) )
|
if( evt->IsMouseUp( BUT_LEFT ) )
|
||||||
{
|
|
||||||
scale = view->GetScale() / ratio;
|
scale = view->GetScale() / ratio;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
scale = view->GetScale() * ratio;
|
scale = view->GetScale() * ratio;
|
||||||
}
|
|
||||||
|
|
||||||
view->SetScale( scale );
|
view->SetScale( scale );
|
||||||
view->SetCenter( selectionBox.Centre() );
|
view->SetCenter( selectionBox.Centre() );
|
||||||
|
|
|
@ -126,8 +126,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
||||||
|
|
||||||
// Right vertical toolbar.
|
// Right vertical toolbar.
|
||||||
EVT_TOOL( ID_NO_TOOL_SELECTED, LIB_EDIT_FRAME::OnSelectTool )
|
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,
|
EVT_TOOL_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
|
||||||
LIB_EDIT_FRAME::OnSelectTool )
|
LIB_EDIT_FRAME::OnSelectTool )
|
||||||
|
|
||||||
|
@ -1045,7 +1043,6 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event )
|
||||||
void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
int id = aEvent.GetId();
|
int id = aEvent.GetId();
|
||||||
int lastToolID = GetToolId();
|
|
||||||
|
|
||||||
if( GetToolId() == ID_NO_TOOL_SELECTED || GetToolId() == ID_ZOOM_SELECTION )
|
if( GetToolId() == ID_NO_TOOL_SELECTED || GetToolId() == ID_ZOOM_SELECTION )
|
||||||
m_lastDrawItem = NULL;
|
m_lastDrawItem = NULL;
|
||||||
|
@ -1055,21 +1052,23 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
LIB_PART* part = GetCurPart();
|
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 )
|
switch( id )
|
||||||
{
|
{
|
||||||
case ID_NO_TOOL_SELECTED:
|
case ID_NO_TOOL_SELECTED:
|
||||||
SetToolID( id, GetGalCanvas()->GetDefaultCursor(), wxEmptyString );
|
SetToolID( id, GetGalCanvas()->GetDefaultCursor(), wxEmptyString );
|
||||||
break;
|
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:
|
case ID_LIBEDIT_PIN_BUTT:
|
||||||
if( part )
|
if( part )
|
||||||
{
|
{
|
||||||
|
|
|
@ -202,7 +202,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
||||||
|
|
||||||
text = AddHotkeyName( _( "Zoom to Selection" ),
|
text = AddHotkeyName( _( "Zoom to Selection" ),
|
||||||
g_Schematic_Hotkeys_Descr, HK_ZOOM_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
|
// Redraw
|
||||||
text = AddHotkeyName( _( "&Redraw" ), g_Libedit_Hotkeys_Descr, HK_ZOOM_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 );
|
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 );
|
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_TEXT_COMMENT_BUTT:
|
||||||
case ID_LINE_COMMENT_BUTT:
|
case ID_LINE_COMMENT_BUTT:
|
||||||
case ID_ADD_IMAGE_BUTT:
|
case ID_ADD_IMAGE_BUTT:
|
||||||
|
case ID_ZOOM_SELECTION:
|
||||||
return; // Moved to modern toolset
|
return; // Moved to modern toolset
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -102,9 +103,6 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
||||||
case ID_NO_TOOL_SELECTED:
|
case ID_NO_TOOL_SELECTED:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_ZOOM_SELECTION:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
|
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
|
||||||
DeleteItemAtCrossHair();
|
DeleteItemAtCrossHair();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -287,8 +287,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
||||||
|
|
||||||
// Tools and buttons for vertical toolbar.
|
// Tools and buttons for vertical toolbar.
|
||||||
EVT_TOOL( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnSelectTool )
|
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,
|
EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
|
||||||
SCH_EDIT_FRAME::OnSelectTool )
|
SCH_EDIT_FRAME::OnSelectTool )
|
||||||
EVT_TOOL_RANGE( ID_SCHEMATIC_PLACE_MENU_START, ID_SCHEMATIC_PLACE_MENU_END,
|
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 )
|
void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
int id = aEvent.GetId();
|
int id = aEvent.GetId();
|
||||||
int lastToolID = GetToolId();
|
|
||||||
|
|
||||||
// Stop the current command and deselect the current tool.
|
// Stop the current command and deselect the current tool.
|
||||||
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
|
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_BUS_BUTT:
|
||||||
case ID_MENU_LINE_COMMENT_BUTT:
|
case ID_MENU_LINE_COMMENT_BUTT:
|
||||||
case ID_LINE_COMMENT_BUTT:
|
case ID_LINE_COMMENT_BUTT:
|
||||||
|
case ID_ZOOM_SELECTION:
|
||||||
// moved to modern toolset
|
// moved to modern toolset
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
@ -551,15 +551,6 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
||||||
SetNoToolSelected();
|
SetNoToolSelected();
|
||||||
break;
|
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_MENU_SHEET_SYMBOL_BUTT:
|
||||||
case ID_SHEET_SYMBOL_BUTT:
|
case ID_SHEET_SYMBOL_BUTT:
|
||||||
SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add sheet" ) );
|
SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add sheet" ) );
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <tools/sch_drawing_tool.h>
|
#include <tools/sch_drawing_tool.h>
|
||||||
|
|
||||||
#include <sch_actions.h>
|
#include <sch_actions.h>
|
||||||
|
#include <tool/zoom_tool.h>
|
||||||
|
|
||||||
OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
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 )
|
void SCH_ACTIONS::RegisterAllTools( TOOL_MANAGER* aToolManager )
|
||||||
{
|
{
|
||||||
aToolManager->RegisterTool( new COMMON_TOOLS );
|
aToolManager->RegisterTool( new COMMON_TOOLS );
|
||||||
|
aToolManager->RegisterTool( new ZOOM_TOOL );
|
||||||
aToolManager->RegisterTool( new SCH_EDITOR_CONTROL );
|
aToolManager->RegisterTool( new SCH_EDITOR_CONTROL );
|
||||||
aToolManager->RegisterTool( new SCH_PICKER_TOOL );
|
aToolManager->RegisterTool( new SCH_PICKER_TOOL );
|
||||||
aToolManager->RegisterTool( new SCH_DRAWING_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_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:
|
// Vertical toolbar:
|
||||||
EVT_TOOL( ID_NO_TOOL_SELECTED, GERBVIEW_FRAME::Process_Special_Functions )
|
EVT_TOOL( ID_NO_TOOL_SELECTED, GERBVIEW_FRAME::Process_Special_Functions )
|
||||||
|
@ -224,7 +224,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
SetNoToolSelected();
|
SetNoToolSelected();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_MENU_ZOOM_SELECTION:
|
|
||||||
case ID_ZOOM_SELECTION:
|
case ID_ZOOM_SELECTION:
|
||||||
// This tool is located on the main toolbar: switch it on or off on click
|
// This tool is located on the main toolbar: switch it on or off on click
|
||||||
if( GetToolId() != ID_ZOOM_SELECTION )
|
if( GetToolId() != ID_ZOOM_SELECTION )
|
||||||
|
|
|
@ -119,7 +119,6 @@ enum main_id
|
||||||
ID_EDIT,
|
ID_EDIT,
|
||||||
ID_NO_TOOL_SELECTED,
|
ID_NO_TOOL_SELECTED,
|
||||||
ID_ZOOM_SELECTION,
|
ID_ZOOM_SELECTION,
|
||||||
ID_MENU_ZOOM_SELECTION, // similar to ID_ZOOM_SELECTION, used in main memubar
|
|
||||||
ID_SEL_BG_COLOR,
|
ID_SEL_BG_COLOR,
|
||||||
|
|
||||||
ID_REPEAT_BUTT,
|
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_REAL_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode )
|
||||||
EVT_TOOL( ID_SHOW_PL_EDITOR_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_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_TOOL( ID_ZOOM_SELECTION, PL_EDITOR_FRAME::Process_Special_Functions )
|
||||||
EVT_CHOICE( ID_SELECT_COORDINATE_ORIGIN, PL_EDITOR_FRAME::OnSelectCoordOriginCorner)
|
EVT_CHOICE( ID_SELECT_COORDINATE_ORIGIN, PL_EDITOR_FRAME::OnSelectCoordOriginCorner)
|
||||||
EVT_CHOICE( ID_SELECT_PAGE_NUMBER, PL_EDITOR_FRAME::Process_Special_Functions)
|
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();
|
SetNoToolSelected();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_MENU_ZOOM_SELECTION:
|
|
||||||
case ID_ZOOM_SELECTION:
|
case ID_ZOOM_SELECTION:
|
||||||
// This tool is located on the main toolbar: switch it on or off on click
|
// This tool is located on the main toolbar: switch it on or off on click
|
||||||
if( GetToolId() != ID_ZOOM_SELECTION )
|
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 ) );
|
AddMenuItem( viewMenu, ID_ZOOM_PAGE, msg, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ) );
|
||||||
|
|
||||||
msg = AddHotkeyName( _( "Zoom to Selection" ), PlEditorHotkeysDescr, HK_ZOOM_SELECTION );
|
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();
|
viewMenu->AppendSeparator();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue