diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp index 0e3312ae26..0a9895c056 100644 --- a/common/legacy_gal/eda_draw_frame.cpp +++ b/common/legacy_gal/eda_draw_frame.cpp @@ -381,15 +381,57 @@ void EDA_DRAW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMod } +/* + * Respond to selections in the toolbar grid popup + */ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) { - wxFAIL_MSG( "Obsolete! Should go through ToolManager." ); + wxCHECK_RET( m_gridSelectBox, "m_gridSelectBox uninitialized" ); + + int id = m_gridSelectBox->GetCurrentSelection() + ID_POPUP_GRID_FIRST; + + if( id == ID_POPUP_GRID_SEPARATOR ) + { + // wxWidgets will check the separator, which we don't want. + // Re-check the current grid. + wxUpdateUIEvent dummy; + OnUpdateSelectGrid( dummy ); + } + else if( id == ID_POPUP_GRID_SETTINGS ) + { + // wxWidgets will check the Grid Settings... entry, which we don't want. + // R-check the current grid. + wxUpdateUIEvent dummy; + OnUpdateSelectGrid( dummy ); + // Now run the Grid Settings... dialog + wxCommandEvent dummy2; + OnGridSettings( dummy2 ); + } + else if( id >= ID_POPUP_GRID_FIRST && id < ID_POPUP_GRID_SEPARATOR ) + { + m_toolManager->RunAction( ACTIONS::gridPreset, true, id ); + } + + UpdateStatusBar(); + m_galCanvas->Refresh(); } +/* + * Respond to selections in the toolbar zoom popup + */ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) { - wxFAIL_MSG( "Obsolete! Should go through ToolManager." ); + wxCHECK_RET( m_zoomSelectBox, "m_zoomSelectBox uninitialized" ); + + int id = m_zoomSelectBox->GetCurrentSelection(); + + if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) ) + return; + + m_toolManager->RunAction( "common.Control.zoomPreset", true, id ); + UpdateStatusBar(); + m_galCanvas->Refresh(); } @@ -533,37 +575,33 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg ) void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper, const wxString& textLower, COLOR4D color, int pad ) { - if( m_messagePanel == NULL ) - return; - - m_messagePanel->AppendMessage( textUpper, textLower, color, pad ); + if( m_messagePanel ) + m_messagePanel->AppendMessage( textUpper, textLower, color, pad ); } void EDA_DRAW_FRAME::ClearMsgPanel() { - if( m_messagePanel == NULL ) - return; - - m_messagePanel->EraseMsgBox(); + if( m_messagePanel ) + m_messagePanel->EraseMsgBox(); } void EDA_DRAW_FRAME::SetMsgPanel( const MSG_PANEL_ITEMS& aList ) { if( m_messagePanel == NULL ) - return; + { + m_messagePanel->EraseMsgBox(); - m_messagePanel->EraseMsgBox(); - - for( unsigned i = 0; i < aList.size(); i++ ) - m_messagePanel->AppendMessage( aList[i] ); + for( const MSG_PANEL_ITEM& item : aList ) + m_messagePanel->AppendMessage( item ); + } } void EDA_DRAW_FRAME::SetMsgPanel( EDA_ITEM* aItem ) { - wxCHECK_RET( aItem != NULL, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) ); + wxCHECK_RET( aItem, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) ); MSG_PANEL_ITEMS items; aItem->GetMsgPanelInfo( m_UserUnits, items ); @@ -577,7 +615,7 @@ void EDA_DRAW_FRAME::UpdateMsgPanel() } -void EDA_DRAW_FRAME::UseGalCanvas() +void EDA_DRAW_FRAME::ActivateGalCanvas() { EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas(); @@ -594,7 +632,7 @@ void EDA_DRAW_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) GetGalCanvas()->SwitchBackend( aCanvasType ); m_canvasType = GetGalCanvas()->GetBackend(); - UseGalCanvas(); + ActivateGalCanvas(); } @@ -731,103 +769,6 @@ void EDA_DRAW_FRAME::SetScrollCenterPosition( const wxPoint& aPoint ) //------------------------------------------------- -bool EDA_DRAW_FRAME::GeneralControlKeyMovement( int aHotKey, wxPoint *aPos, bool aSnapToGrid ) -{ - bool key_handled = false; - - // If requested snap the current position to the grid - if( aSnapToGrid ) - *aPos = GetNearestGridPosition( *aPos ); - - switch( aHotKey ) - { - // All these keys have almost the same treatment - case GR_KB_CTRL | WXK_NUMPAD8: - case GR_KB_CTRL | WXK_UP: - case GR_KB_CTRL | WXK_NUMPAD2: - case GR_KB_CTRL | WXK_DOWN: - case GR_KB_CTRL | WXK_NUMPAD4: - case GR_KB_CTRL | WXK_LEFT: - case GR_KB_CTRL | WXK_NUMPAD6: - case GR_KB_CTRL | WXK_RIGHT: - case WXK_NUMPAD8: - case WXK_UP: - case WXK_NUMPAD2: - case WXK_DOWN: - case WXK_NUMPAD4: - case WXK_LEFT: - case WXK_NUMPAD6: - case WXK_RIGHT: - key_handled = true; - { - /* Here's a tricky part: when doing cursor key movement, the - * 'previous' point should be taken from memory, *not* from the - * freshly computed position in the event. Otherwise you can't do - * sub-pixel movement. The m_movingCursorWithKeyboard oneshot 'eats' - * the automatic motion event generated by cursor warping */ - wxRealPoint gridSize = GetScreen()->GetGridSize(); - *aPos = GetCrossHairPosition(); - - // Bonus: ^key moves faster (x10) - switch( aHotKey ) - { - case GR_KB_CTRL|WXK_NUMPAD8: - case GR_KB_CTRL|WXK_UP: - aPos->y -= KiROUND( 10 * gridSize.y ); - break; - - case GR_KB_CTRL|WXK_NUMPAD2: - case GR_KB_CTRL|WXK_DOWN: - aPos->y += KiROUND( 10 * gridSize.y ); - break; - - case GR_KB_CTRL|WXK_NUMPAD4: - case GR_KB_CTRL|WXK_LEFT: - aPos->x -= KiROUND( 10 * gridSize.x ); - break; - - case GR_KB_CTRL|WXK_NUMPAD6: - case GR_KB_CTRL|WXK_RIGHT: - aPos->x += KiROUND( 10 * gridSize.x ); - break; - - case WXK_NUMPAD8: - case WXK_UP: - aPos->y -= KiROUND( gridSize.y ); - break; - - case WXK_NUMPAD2: - case WXK_DOWN: - aPos->y += KiROUND( gridSize.y ); - break; - - case WXK_NUMPAD4: - case WXK_LEFT: - aPos->x -= KiROUND( gridSize.x ); - break; - - case WXK_NUMPAD6: - case WXK_RIGHT: - aPos->x += KiROUND( gridSize.x ); - break; - - default: /* Can't happen since we entered the statement */ - break; - } - - m_canvas->MoveCursor( *aPos ); - m_movingCursorWithKeyboard = true; - } - break; - - default: - break; - } - - return key_handled; -} - - const BOX2I EDA_DRAW_FRAME::GetDocumentExtents() const { return BOX2I(); diff --git a/common/legacy_wx/eda_draw_frame.cpp b/common/legacy_wx/eda_draw_frame.cpp index 8c0f71bd31..1ee837379b 100644 --- a/common/legacy_wx/eda_draw_frame.cpp +++ b/common/legacy_wx/eda_draw_frame.cpp @@ -643,7 +643,7 @@ void EDA_DRAW_FRAME::UpdateMsgPanel() } -void EDA_DRAW_FRAME::UseGalCanvas() +void EDA_DRAW_FRAME::ActivateGalCanvas() { KIGFX::GAL* gal = GetGalCanvas()->GetGAL(); @@ -667,7 +667,7 @@ void EDA_DRAW_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) GetGalCanvas()->SwitchBackend( aCanvasType ); m_canvasType = GetGalCanvas()->GetBackend(); - UseGalCanvas(); + ActivateGalCanvas(); } @@ -843,107 +843,10 @@ bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename, } -bool EDA_DRAW_FRAME::GeneralControlKeyMovement( int aHotKey, wxPoint *aPos, bool aSnapToGrid ) -{ - bool key_handled = false; - - // If requested snap the current position to the grid - if( aSnapToGrid ) - *aPos = GetNearestGridPosition( *aPos ); - - switch( aHotKey ) - { - // All these keys have almost the same treatment - case GR_KB_CTRL | WXK_NUMPAD8: - case GR_KB_CTRL | WXK_UP: - case GR_KB_CTRL | WXK_NUMPAD2: - case GR_KB_CTRL | WXK_DOWN: - case GR_KB_CTRL | WXK_NUMPAD4: - case GR_KB_CTRL | WXK_LEFT: - case GR_KB_CTRL | WXK_NUMPAD6: - case GR_KB_CTRL | WXK_RIGHT: - case WXK_NUMPAD8: - case WXK_UP: - case WXK_NUMPAD2: - case WXK_DOWN: - case WXK_NUMPAD4: - case WXK_LEFT: - case WXK_NUMPAD6: - case WXK_RIGHT: - key_handled = true; - { - /* Here's a tricky part: when doing cursor key movement, the - * 'previous' point should be taken from memory, *not* from the - * freshly computed position in the event. Otherwise you can't do - * sub-pixel movement. The m_movingCursorWithKeyboard oneshot 'eats' - * the automatic motion event generated by cursor warping */ - wxRealPoint gridSize = GetScreen()->GetGridSize(); - *aPos = GetCrossHairPosition(); - - // Bonus: ^key moves faster (x10) - switch( aHotKey ) - { - case GR_KB_CTRL|WXK_NUMPAD8: - case GR_KB_CTRL|WXK_UP: - aPos->y -= KiROUND( 10 * gridSize.y ); - break; - - case GR_KB_CTRL|WXK_NUMPAD2: - case GR_KB_CTRL|WXK_DOWN: - aPos->y += KiROUND( 10 * gridSize.y ); - break; - - case GR_KB_CTRL|WXK_NUMPAD4: - case GR_KB_CTRL|WXK_LEFT: - aPos->x -= KiROUND( 10 * gridSize.x ); - break; - - case GR_KB_CTRL|WXK_NUMPAD6: - case GR_KB_CTRL|WXK_RIGHT: - aPos->x += KiROUND( 10 * gridSize.x ); - break; - - case WXK_NUMPAD8: - case WXK_UP: - aPos->y -= KiROUND( gridSize.y ); - break; - - case WXK_NUMPAD2: - case WXK_DOWN: - aPos->y += KiROUND( gridSize.y ); - break; - - case WXK_NUMPAD4: - case WXK_LEFT: - aPos->x -= KiROUND( gridSize.x ); - break; - - case WXK_NUMPAD6: - case WXK_RIGHT: - aPos->x += KiROUND( gridSize.x ); - break; - - default: /* Can't happen since we entered the statement */ - break; - } - - m_canvas->MoveCursor( *aPos ); - m_movingCursorWithKeyboard = true; - } - break; - - default: - break; - } - - return key_handled; -} - - void EDA_DRAW_FRAME::HardRedraw() { - m_canvas->Refresh(); - m_canvas->Update(); + GetGalCanvas()->Refresh(); + GetGalCanvas()->Update(); } diff --git a/common/legacy_wx/eda_draw_panel.cpp b/common/legacy_wx/eda_draw_panel.cpp index ae3cfaff5f..206b0218db 100644 --- a/common/legacy_wx/eda_draw_panel.cpp +++ b/common/legacy_wx/eda_draw_panel.cpp @@ -104,7 +104,6 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id, m_ClipBox.SetX( 0 ); m_ClipBox.SetY( 0 ); m_canStartBlock = -1; // Command block can start if >= 0 - m_ignoreMouseEvents = false; // Be sure a mouse release button event will be ignored when creating the canvas // if the mouse click was not made inside the canvas (can happen sometimes, when // launching a editor from a double click made in another frame) @@ -277,18 +276,6 @@ wxPoint EDA_DRAW_PANEL::GetScreenCenterLogicalPosition() } -void EDA_DRAW_PANEL::MoveCursorToCrossHair() -{ - MoveCursor( GetParent()->GetCrossHairPosition() ); -} - - -void EDA_DRAW_PANEL::MoveCursor( const wxPoint& aPosition ) -{ - // JEY TODO: OBSOLETE -} - - void EDA_DRAW_PANEL::OnActivate( wxActivateEvent& event ) { m_canStartBlock = -1; // Block Command can't start diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index 5f0b20625b..e0fd96b288 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -172,7 +172,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa view->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); - UseGalCanvas(); + ActivateGalCanvas(); // Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.) GetGalCanvas()->GetView()->SetScale( m_lastZoom ); @@ -451,7 +451,7 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay() UpdateStatusBar(); - GetCanvas()->Refresh(); + GetGalCanvas()->Refresh(); Update3DView(); } diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 328197843b..3ebe488199 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -350,7 +350,5 @@ bool DIALOG_LABEL_EDITOR::TransferDataFromWindow() if( m_CurrentText->IsNew() ) SetDefaultTextSize( m_CurrentText->GetTextWidth() ); - m_Parent->GetCanvas()->MoveCursorToCrossHair(); - return true; } diff --git a/eeschema/dialogs/dialog_schematic_find.cpp b/eeschema/dialogs/dialog_schematic_find.cpp index 3d1e0a01dc..3d8de0e3ea 100644 --- a/eeschema/dialogs/dialog_schematic_find.cpp +++ b/eeschema/dialogs/dialog_schematic_find.cpp @@ -162,6 +162,9 @@ void DIALOG_SCH_FIND::OnOptions( wxCommandEvent& aEvent ) if( m_checkCurrentSheetOnly->GetValue() ) flags |= FR_CURRENT_SHEET_ONLY; + if( m_checkReplaceReferences->GetValue() ) + flags |= FR_REPLACE_REFERENCES; + m_findReplaceData->SetFlags( flags ); m_editorControl->UpdateFind( ACTIONS::updateFind.MakeEvent() ); } diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index 6db5638060..189d67a190 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -58,10 +58,6 @@ void SCH_EDIT_FRAME::EditComponentFieldText( SCH_FIELD* aField ) if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved SaveCopyInUndoList( component, UR_CHANGED ); - // Don't use GetText() here. If the field is the reference designator and it's parent - // component has multiple parts, we don't want the part suffix added to the field. - m_canvas->SetIgnoreMouseEvents( true ); - wxString title; title.Printf( _( "Edit %s Field" ), GetChars( aField->GetName() ) ); @@ -70,15 +66,9 @@ void SCH_EDIT_FRAME::EditComponentFieldText( SCH_FIELD* aField ) // The dialog may invoke a kiway player for footprint fields // so we must use a quasimodal if( dlg.ShowQuasiModal() != wxID_OK ) - { - m_canvas->MoveCursorToCrossHair(); - m_canvas->SetIgnoreMouseEvents( false ); return; - } dlg.UpdateField( aField, g_CurrentSheet ); - m_canvas->MoveCursorToCrossHair(); - m_canvas->SetIgnoreMouseEvents( false ); if( m_autoplaceFields ) component->AutoAutoplaceFields( GetScreen() ); @@ -97,8 +87,6 @@ void SCH_EDIT_FRAME::EditComponent( SCH_COMPONENT* aComponent ) wxCHECK_RET( aComponent != nullptr && aComponent->Type() == SCH_COMPONENT_T, wxT( "Invalid component object pointer. Bad Programmer!" ) ); - m_canvas->SetIgnoreMouseEvents( true ); - DIALOG_EDIT_COMPONENT_IN_SCHEMATIC dlg( this, aComponent ); // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal @@ -107,9 +95,6 @@ void SCH_EDIT_FRAME::EditComponent( SCH_COMPONENT* aComponent ) // the QUASIMODAL macros here. int ret = dlg.ShowQuasiModal(); - m_canvas->SetIgnoreMouseEvents( false ); - m_canvas->MoveCursorToCrossHair(); - if( ret == wxID_OK ) { if( m_autoplaceFields ) diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index ccd525b326..e40ad41d8c 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -206,8 +206,6 @@ SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( void SCH_EDIT_FRAME::SelectUnit( SCH_COMPONENT* aComponent, int aUnit ) { - GetCanvas()->MoveCursorToCrossHair(); - LIB_PART* part = GetLibPart( aComponent->GetLibId() ); if( !part ) diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index dba041ec7e..a381577b4b 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -607,7 +607,6 @@ void LIB_EDIT_FRAME::OnImportBody( wxCommandEvent& aEvent ) SetToolID( ID_LIBEDIT_IMPORT_BODY_BUTT, GetGalCanvas()->GetDefaultCursor(), _( "Import" ) ); LoadOneSymbol(); SetNoToolSelected(); - m_canvas->SetIgnoreMouseEvents( false ); } @@ -617,7 +616,6 @@ void LIB_EDIT_FRAME::OnExportBody( wxCommandEvent& aEvent ) SetToolID( ID_LIBEDIT_EXPORT_BODY_BUTT, GetGalCanvas()->GetDefaultCursor(), _( "Export" ) ); SaveOneSymbol(); SetNoToolSelected(); - m_canvas->SetIgnoreMouseEvents( false ); } diff --git a/eeschema/libedit/symbedit.cpp b/eeschema/libedit/symbedit.cpp index b6c5b2f61c..184599cc22 100644 --- a/eeschema/libedit/symbedit.cpp +++ b/eeschema/libedit/symbedit.cpp @@ -53,8 +53,6 @@ void LIB_EDIT_FRAME::LoadOneSymbol() PROJECT& prj = Prj(); SEARCH_STACK* search = prj.SchSearchS(); - m_canvas->SetIgnoreMouseEvents( true ); - wxString default_path = prj.GetRString( PROJECT::SCH_LIB_PATH ); if( !default_path ) @@ -67,10 +65,6 @@ void LIB_EDIT_FRAME::LoadOneSymbol() if( dlg.ShowModal() == wxID_CANCEL ) return; - SetCrossHairPosition( wxPoint( 0, 0 ) ); - m_canvas->MoveCursorToCrossHair(); - m_canvas->SetIgnoreMouseEvents( false ); - wxString filename = dlg.GetPath(); prj.SetRString( PROJECT::SCH_LIB_PATH, filename ); diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index a50a3b0614..c1fd4c1a17 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -400,13 +400,7 @@ void SCH_BASE_FRAME::createCanvas() m_useSingleCanvasPane = true; SetGalCanvas( static_cast( m_canvas ) ); - - // Set up viewport - KIGFX::VIEW* view = GetGalCanvas()->GetView(); - view->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); - view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); - - UseGalCanvas(); + ActivateGalCanvas(); } diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index f232f744b4..899eda06e7 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -85,7 +85,6 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId, Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( SCH_DRAW_PANEL::OnCharHook ), NULL, this ); - m_ignoreMouseEvents = false; // Be sure a mouse release button event will be ignored when creating the canvas // if the mouse click was not made inside the canvas (can happen sometimes, when // launching a editor from a double click made in another frame) @@ -199,12 +198,6 @@ EDA_DRAW_FRAME* SCH_DRAW_PANEL::GetParent() const } -void SCH_DRAW_PANEL::MoveCursorToCrossHair() -{ - GetViewControls()->WarpCursor( GetParent()->GetCrossHairPosition(), true ); -} - - void SCH_DRAW_PANEL::Refresh( bool aEraseBackground, const wxRect* aRect ) { EDA_DRAW_PANEL_GAL::Refresh( aEraseBackground, aRect ); diff --git a/eeschema/sch_draw_panel.h b/eeschema/sch_draw_panel.h index 8e2c9077a1..41036fd624 100644 --- a/eeschema/sch_draw_panel.h +++ b/eeschema/sch_draw_panel.h @@ -46,8 +46,6 @@ public: BASE_SCREEN* GetScreen() override; virtual EDA_DRAW_FRAME* GetParent() const override; - virtual void MoveCursorToCrossHair() override; - KIGFX::SCH_VIEW* GetView() const { return view(); } /// @copydoc wxWindow::Refresh() diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 29c7f62ea0..755953e461 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -182,8 +182,6 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy, } } - m_canvas->SetIgnoreMouseEvents( true ); - if( isUndoable ) SaveCopyInUndoList( aSheet, UR_CHANGED ); @@ -304,9 +302,6 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy, if( aClearAnnotationNewItems ) *aClearAnnotationNewItems = clearAnnotation; - m_canvas->MoveCursorToCrossHair(); - m_canvas->SetIgnoreMouseEvents( false ); - GetCanvas()->GetView()->Update( aSheet ); OnModify(); diff --git a/eeschema/tools/lib_drawing_tools.cpp b/eeschema/tools/lib_drawing_tools.cpp index 894cd83098..8555afdf0f 100644 --- a/eeschema/tools/lib_drawing_tools.cpp +++ b/eeschema/tools/lib_drawing_tools.cpp @@ -173,7 +173,6 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType ) if( !item ) { m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - m_frame->GetCanvas()->SetIgnoreMouseEvents( true ); switch( aType ) { @@ -203,10 +202,8 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType ) wxFAIL_MSG( "doTwoClickPlace(): unknown type" ); } - m_frame->GetCanvas()->SetIgnoreMouseEvents( false ); - // Restore cursor after dialog - m_frame->GetCanvas()->MoveCursorToCrossHair(); + getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true ); if( item ) { diff --git a/eeschema/tools/lib_pin_tool.cpp b/eeschema/tools/lib_pin_tool.cpp index 895f471734..4f523aad3c 100644 --- a/eeschema/tools/lib_pin_tool.cpp +++ b/eeschema/tools/lib_pin_tool.cpp @@ -165,7 +165,6 @@ bool LIB_PIN_TOOL::PlacePin( LIB_PIN* aPin ) if( ask_for_pin && m_frame->SynchronizePins() ) { - m_frame->GetCanvas()->SetIgnoreMouseEvents( true ); wxString msg; msg.Printf( _( "This position is already occupied by another pin, in unit %d." ), test->GetUnit() ); @@ -176,9 +175,6 @@ bool LIB_PIN_TOOL::PlacePin( LIB_PIN* aPin ) bool status = dlg.ShowModal() == wxID_OK; - m_frame->GetCanvas()->MoveCursorToCrossHair(); - m_frame->GetCanvas()->SetIgnoreMouseEvents( false ); - if( !status ) { if( aPin->IsNew() ) diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 8a9e765e7e..b542848316 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -185,7 +185,7 @@ int SCH_DRAWING_TOOLS::AddJunction( const TOOL_EVENT& aEvent ) m_frame->SetCrossHairPosition( (wxPoint) nearest, false ); } - m_frame->GetCanvas()->MoveCursorToCrossHair(); + getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true ); SCH_JUNCTION* junction = m_frame->AddJunction( m_frame->GetCrossHairPosition() ); m_selectionTool->AddItemToSel( junction ); @@ -321,15 +321,11 @@ int SCH_DRAWING_TOOLS::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTE m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); // Pick the module to be placed - m_frame->GetCanvas()->SetIgnoreMouseEvents( true ); - auto sel = m_frame->SelectCompFromLibTree( aFilter, aHistoryList, true, 1, 1, m_frame->GetShowFootprintPreviews()); - m_frame->GetCanvas()->SetIgnoreMouseEvents( false ); - // Restore cursor after dialog - m_frame->GetCanvas()->MoveCursorToCrossHair(); + getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true ); LIB_PART* part = sel.LibId.IsValid() ? m_frame->GetLibPart( sel.LibId ) : nullptr; @@ -446,19 +442,14 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent ) if( !image ) { m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - - m_frame->GetCanvas()->SetIgnoreMouseEvents( true ); - wxFileDialog dlg( m_frame, _( "Choose Image" ), wxEmptyString, wxEmptyString, _( "Image Files " ) + wxImage::GetImageExtWildcard(), wxFD_OPEN ); if( dlg.ShowModal() != wxID_OK ) continue; - m_frame->GetCanvas()->SetIgnoreMouseEvents( false ); - // Restore cursor after dialog - m_frame->GetCanvas()->MoveCursorToCrossHair(); + getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true ); wxString fullFilename = dlg.GetPath(); @@ -695,7 +686,6 @@ int SCH_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType ) if( !item ) { m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - m_frame->GetCanvas()->SetIgnoreMouseEvents( true ); switch( aType ) { @@ -746,10 +736,8 @@ int SCH_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType ) wxFAIL_MSG( "doTwoClickPlace(): unknown type" ); } - m_frame->GetCanvas()->SetIgnoreMouseEvents( false ); - // Restore cursor after dialog - m_frame->GetCanvas()->MoveCursorToCrossHair(); + getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true ); if( item ) { diff --git a/eeschema/tools/sch_wire_bus_tool.cpp b/eeschema/tools/sch_wire_bus_tool.cpp index b07db51952..912a3c8fc3 100644 --- a/eeschema/tools/sch_wire_bus_tool.cpp +++ b/eeschema/tools/sch_wire_bus_tool.cpp @@ -311,7 +311,7 @@ int SCH_WIRE_BUS_TOOL::StartWire( const TOOL_EVENT& aEvent ) Activate(); - m_frame->GetCanvas()->MoveCursorToCrossHair(); + getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true ); SCH_LINE* segment = startSegments( LAYER_WIRE, m_frame->GetCrossHairPosition() ); return doDrawSegments( LAYER_WIRE, segment ); } @@ -343,7 +343,7 @@ int SCH_WIRE_BUS_TOOL::StartBus( const TOOL_EVENT& aEvent ) Activate(); - m_frame->GetCanvas()->MoveCursorToCrossHair(); + getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true ); SCH_LINE* segment = startSegments( LAYER_BUS, m_frame->GetCrossHairPosition() ); return doDrawSegments( LAYER_BUS, segment ); } @@ -454,7 +454,7 @@ int SCH_WIRE_BUS_TOOL::StartLine( const TOOL_EVENT& aEvent) { m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - m_frame->GetCanvas()->MoveCursorToCrossHair(); + getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true ); SCH_LINE* segment = startSegments( LAYER_NOTES, m_frame->GetCrossHairPosition() ); return doDrawSegments( LAYER_BUS, segment ); } diff --git a/gerbview/clear_gbr_drawlayers.cpp b/gerbview/clear_gbr_drawlayers.cpp index f84e9934c4..1a1ffa4db7 100644 --- a/gerbview/clear_gbr_drawlayers.cpp +++ b/gerbview/clear_gbr_drawlayers.cpp @@ -88,5 +88,5 @@ void GERBVIEW_FRAME::Erase_Current_DrawLayer( bool query ) ReFillLayerWidget(); syncLayerBox(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } diff --git a/gerbview/dialogs/panel_gerbview_display_options.cpp b/gerbview/dialogs/panel_gerbview_display_options.cpp index 5374022258..478329ad4f 100644 --- a/gerbview/dialogs/panel_gerbview_display_options.cpp +++ b/gerbview/dialogs/panel_gerbview_display_options.cpp @@ -102,7 +102,7 @@ bool PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataFromWindow() if( needs_repaint ) view->UpdateAllItems( KIGFX::REPAINT ); - m_Parent->GetCanvas()->Refresh(); + m_Parent->GetGalCanvas()->Refresh(); return true; } diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index 1ed31e7ea0..ddcb8209e8 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -161,21 +161,15 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_HIGHLIGHT_CMP_ITEMS: - if( m_SelComponentBox->SetStringSelection( currItem->GetNetAttributes().m_Cmpref ) ) - m_canvas->Refresh(); + m_SelComponentBox->SetStringSelection( currItem->GetNetAttributes().m_Cmpref ); break; case ID_HIGHLIGHT_NET_ITEMS: - if( m_SelNetnameBox->SetStringSelection( UnescapeString( currItem->GetNetAttributes().m_Netname ) ) ) - m_canvas->Refresh(); + m_SelNetnameBox->SetStringSelection( UnescapeString( currItem->GetNetAttributes().m_Netname ) ); break; case ID_HIGHLIGHT_APER_ATTRIBUTE_ITEMS: - { - D_CODE* apertDescr = currItem->GetDcodeDescr(); - if( m_SelAperAttributesBox->SetStringSelection( apertDescr->m_AperFunction ) ) - m_canvas->Refresh(); - } + m_SelAperAttributesBox->SetStringSelection( currItem->GetDcodeDescr()->m_AperFunction ); break; case ID_HIGHLIGHT_REMOVE_ALL: @@ -185,14 +179,14 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( GetGbrImage( GetActiveLayer() ) ) GetGbrImage( GetActiveLayer() )->m_Selected_Tool = 0; - - m_canvas->Refresh(); break; default: wxFAIL_MSG( wxT( "GERBVIEW_FRAME::Process_Special_Functions error" ) ); break; } + + GetGalCanvas()->Refresh(); } @@ -232,7 +226,7 @@ void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event ) if( tool != gerber_image->m_Selected_Tool ) { gerber_image->m_Selected_Tool = tool; - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } } } @@ -287,25 +281,14 @@ void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event ) void GERBVIEW_FRAME::OnSelectDisplayMode( wxCommandEvent& event ) { - int oldMode = GetDisplayMode(); - switch( event.GetId() ) { - case ID_TB_OPTIONS_SHOW_GBR_MODE_0: - SetDisplayMode( 0 ); - break; - - case ID_TB_OPTIONS_SHOW_GBR_MODE_1: - SetDisplayMode( 1 ); - break; - - case ID_TB_OPTIONS_SHOW_GBR_MODE_2: - SetDisplayMode( 2 ); - break; + case ID_TB_OPTIONS_SHOW_GBR_MODE_0: SetDisplayMode( 0 ); break; + case ID_TB_OPTIONS_SHOW_GBR_MODE_1: SetDisplayMode( 1 ); break; + case ID_TB_OPTIONS_SHOW_GBR_MODE_2: SetDisplayMode( 2 ); break; } - if( GetDisplayMode() != oldMode ) - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 7d185ab408..d5c838bad4 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -111,7 +111,7 @@ void GERBVIEW_FRAME::Files_io( wxCommandEvent& event ) case ID_GERBVIEW_ERASE_ALL: Clear_DrawLayers( false ); Zoom_Automatique( false ); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); ClearMsgPanel(); break; @@ -142,7 +142,7 @@ void GERBVIEW_FRAME::Files_io( wxCommandEvent& event ) // Clear all layers Clear_DrawLayers( false ); Zoom_Automatique( false ); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); ClearMsgPanel(); // Load the layers from stored paths @@ -153,17 +153,17 @@ void GERBVIEW_FRAME::Files_io( wxCommandEvent& event ) case ID_GERBVIEW_LOAD_DRILL_FILE: LoadExcellonFiles( wxEmptyString ); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); break; case ID_GERBVIEW_LOAD_ZIP_ARCHIVE_FILE: LoadZipArchiveFile( wxEmptyString ); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); break; case ID_GERBVIEW_LOAD_JOB_FILE: LoadGerberJobFile( wxEmptyString ); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); break; default: diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 64cb4a42b7..fe5390dd8d 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -209,7 +209,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): } GetGalCanvas()->SwitchBackend( canvasType ); - UseGalCanvas(); + ActivateGalCanvas(); // Enable the axes to match legacy draw style auto& galOptions = GetGalDisplayOptions(); @@ -622,7 +622,7 @@ void GERBVIEW_FRAME::SortLayersByX2Attributes() } GetGalCanvas()->GetView()->ReorderLayerData( view_remapping ); - GetCanvas()->Refresh(); + GetGalCanvas()->Refresh(); } @@ -690,8 +690,7 @@ void GERBVIEW_FRAME::UpdateDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions ) } view->UpdateAllItems( KIGFX::COLOR ); - - m_canvas->Refresh( true ); + GetGalCanvas()->Refresh(); } @@ -1112,9 +1111,9 @@ void GERBVIEW_FRAME::unitsChangeRefresh() } -void GERBVIEW_FRAME::UseGalCanvas() +void GERBVIEW_FRAME::ActivateGalCanvas() { - EDA_DRAW_FRAME::UseGalCanvas(); + EDA_DRAW_FRAME::ActivateGalCanvas(); EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas(); diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 53e25de279..e26780af8f 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -586,7 +586,7 @@ public: } ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas - virtual void UseGalCanvas() override; + virtual void ActivateGalCanvas() override; /** * Allows Gerbview to install its preferences panels into the preferences dialog. diff --git a/gerbview/gerbview_layer_widget.cpp b/gerbview/gerbview_layer_widget.cpp index d90672cb3b..e2531a9bc5 100644 --- a/gerbview/gerbview_layer_widget.cpp +++ b/gerbview/gerbview_layer_widget.cpp @@ -192,7 +192,7 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) } myframe->SetVisibleLayers( visibleLayers ); - myframe->GetCanvas()->Refresh(); + myframe->GetGalCanvas()->Refresh(); break; case ID_SORT_GBR_LAYERS: @@ -265,7 +265,7 @@ void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor ) view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->m_colorsSettings ); view->UpdateLayerColor( GERBER_DRAW_LAYER( aLayer ) ); - myframe->GetCanvas()->Refresh(); + myframe->GetGalCanvas()->Refresh(); } @@ -281,7 +281,7 @@ bool GERBER_LAYER_WIDGET::OnLayerSelect( int aLayer ) if( layer != myframe->GetActiveLayer() ) { if( ! OnLayerSelected() ) - myframe->GetCanvas()->Refresh(); + myframe->GetGalCanvas()->Refresh(); } return true; @@ -297,7 +297,7 @@ void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFin myframe->SetVisibleLayers( visibleLayers ); if( isFinal ) - myframe->GetCanvas()->Refresh(); + myframe->GetGalCanvas()->Refresh(); } diff --git a/include/draw_frame.h b/include/draw_frame.h index 34469cb00d..baabcb7449 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -208,17 +208,6 @@ protected: const wxString& wildcard, const wxString& ext, bool isDirectory = false ); - /** - * Handle the common part of GeneralControl dedicated to global - * cursor keys (i.e. cursor movement by keyboard) - * - * @param aHotKey is the hotkey code - * @param aPos is the position of the cursor (initial then new) - * @param aSnapToGrid = true to force the cursor position on grid - * @return true if the hotkey code is handled (captured). - */ - bool GeneralControlKeyMovement( int aHotKey, wxPoint *aPos, bool aSnapToGrid ); - /** * Stores the canvas type in the application settings. */ @@ -736,7 +725,7 @@ public: /** * Use to start up the GAL drawing canvas. */ - virtual void UseGalCanvas(); + virtual void ActivateGalCanvas(); /** * Changes the current rendering backend. diff --git a/include/legacy_gal/class_drawpanel.h b/include/legacy_gal/class_drawpanel.h index 805afd13a5..97105d64e8 100644 --- a/include/legacy_gal/class_drawpanel.h +++ b/include/legacy_gal/class_drawpanel.h @@ -21,8 +21,6 @@ protected: /// of the drawing in internal units. EDA_RECT m_ClipBox; - bool m_ignoreMouseEvents; ///< Ignore mouse events when true. - /* Used to inhibit a response to a mouse left button release, after a double click * (when releasing the left button at the end of the second click. Used in Eeschema * to inhibit a mouse left release command when switching between hierarchical sheets @@ -43,7 +41,6 @@ public: m_cursorLevel( 0 ), m_scrollIncrementX( 1 ), m_scrollIncrementY( 1 ), - m_ignoreMouseEvents( false ), m_ignoreNextLeftButtonRelease( false ), m_PrintIsMirrored( false ), m_doubleClickInterval( 0 ) @@ -68,8 +65,6 @@ public: void SetClipBox( const EDA_RECT& aRect ) { m_ClipBox = aRect; } - void SetIgnoreMouseEvents( bool aIgnore ) { m_ignoreMouseEvents = aIgnore; } - void SetIgnoreLeftButtonReleaseEvent( bool aIgnore ) { m_ignoreNextLeftButtonRelease = aIgnore; } bool GetPrintMirrored() const { return m_PrintIsMirrored; } @@ -130,12 +125,6 @@ public: */ virtual wxPoint GetScreenCenterLogicalPosition() { return wxPoint(0, 0); };; - /** - * Function MoveCursorToCrossHair - * warps the cursor to the current cross hair position. - */ - virtual void MoveCursorToCrossHair() { printf("EDA_DRAW_PANEL:Unimplemented14\n"); };; - /** * Function ToDeviceXY * transforms logical to device coordinates @@ -148,13 +137,6 @@ public: */ virtual wxPoint ToLogicalXY( const wxPoint& pos ) { printf("EDA_DRAW_PANEL:Unimplemented16\n"); return wxPoint(0, 0); };; - /** - * Function MoveCursor - * moves the mouse pointer to \a aPosition in logical (drawing) units. - * @param aPosition The position in logical units to move the cursor. - */ - virtual void MoveCursor( const wxPoint& aPosition ) { printf("EDA_DRAW_PANEL:Unimplemented17\n"); };; - virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL ) {} virtual wxWindow* GetWindow() = 0; diff --git a/include/legacy_wx/class_drawpanel.h b/include/legacy_wx/class_drawpanel.h index 7f4db56cbe..6ebe5efaac 100644 --- a/include/legacy_wx/class_drawpanel.h +++ b/include/legacy_wx/class_drawpanel.h @@ -73,8 +73,6 @@ private: /// of the drawing in internal units. EDA_RECT m_ClipBox; - bool m_ignoreMouseEvents; ///< Ignore mouse events when true. - /* Used to inhibit a response to a mouse left button release, after a double click * (when releasing the left button at the end of the second click. Used in Eeschema * to inhibit a mouse left release command when switching between hierarchical sheets @@ -123,8 +121,6 @@ public: void SetClipBox( const EDA_RECT& aRect ) { m_ClipBox = aRect; } - void SetIgnoreMouseEvents( bool aIgnore ) { m_ignoreMouseEvents = aIgnore; } - void SetIgnoreLeftButtonReleaseEvent( bool aIgnore ) { m_ignoreNextLeftButtonRelease = aIgnore; } bool GetPrintMirrored() const { return m_PrintIsMirrored; } @@ -234,12 +230,6 @@ public: */ wxPoint GetScreenCenterLogicalPosition(); - /** - * Function MoveCursorToCrossHair - * warps the cursor to the current cross hair position. - */ - void MoveCursorToCrossHair(); - /** * Function ToDeviceXY * transforms logical to device coordinates @@ -252,13 +242,6 @@ public: */ wxPoint ToLogicalXY( const wxPoint& pos ); - /** - * Function MoveCursor - * moves the mouse pointer to \a aPosition in logical (drawing) units. - * @param aPosition The position in logical units to move the cursor. - */ - void MoveCursor( const wxPoint& aPosition ); - /* Cursor functions */ /** * Function DrawCrossHair diff --git a/include/pcb_base_frame.h b/include/pcb_base_frame.h index 1a77a6ad95..48ccfd0343 100644 --- a/include/pcb_base_frame.h +++ b/include/pcb_base_frame.h @@ -469,7 +469,7 @@ public: void SetFastGrid2(); ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas - virtual void UseGalCanvas() override; + virtual void ActivateGalCanvas() override; PCB_GENERAL_SETTINGS& Settings() { diff --git a/pagelayout_editor/files.cpp b/pagelayout_editor/files.cpp index cfa93b6989..0aeda8e34d 100644 --- a/pagelayout_editor/files.cpp +++ b/pagelayout_editor/files.cpp @@ -128,7 +128,7 @@ void PL_EDITOR_FRAME::Files_io( wxCommandEvent& event ) else { GetScreen()->SetModify(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); msg.Printf( _( "File \"%s\" inserted" ), GetChars( filename ) ); SetStatusText( msg ); } diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 1bcc62afa0..f262208c7f 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -179,7 +179,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : view->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); - UseGalCanvas(); + ActivateGalCanvas(); m_auimgr.Update(); @@ -287,7 +287,7 @@ void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event ) KIGFX::VIEW* view = GetGalCanvas()->GetView(); view->SetLayerVisible( LAYER_WORKSHEET_PAGE1, m_pageSelectBox->GetSelection() == 0 ); view->SetLayerVisible( LAYER_WORKSHEET_PAGEn, m_pageSelectBox->GetSelection() == 1 ); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } break; @@ -305,7 +305,7 @@ void PL_EDITOR_FRAME::OnSelectCoordOriginCorner( wxCommandEvent& event ) { m_originSelectChoice = m_originSelectBox->GetSelection(); UpdateStatusBar(); // Update grid origin - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } @@ -604,7 +604,7 @@ void PL_EDITOR_FRAME::HardRedraw() m_propertiesPagelayout->CopyPrmsFromItemToPanel( item ); m_propertiesPagelayout->CopyPrmsFromGeneralToPanel(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); } @@ -683,7 +683,6 @@ void PL_EDITOR_FRAME::OnNewPageLayout() UpdateTitleAndInfo(); m_toolManager->RunAction( ACTIONS::zoomFitScreen, true ); - m_canvas->Refresh(); } diff --git a/pagelayout_editor/pl_editor_undo_redo.cpp b/pagelayout_editor/pl_editor_undo_redo.cpp index 4efa6393da..8b71573304 100644 --- a/pagelayout_editor/pl_editor_undo_redo.cpp +++ b/pagelayout_editor/pl_editor_undo_redo.cpp @@ -81,7 +81,9 @@ void PL_EDITOR_FRAME::GetLayoutFromRedoList() HardRedraw(); // items based off of corners will need re-calculating } else - GetCanvas()->Refresh(); + { + GetGalCanvas()->Refresh(); + } OnModify(); } diff --git a/pcbnew/dialogs/dialog_graphic_item_properties.cpp b/pcbnew/dialogs/dialog_graphic_item_properties.cpp index 73d667f862..469ef4bb22 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties.cpp @@ -130,12 +130,8 @@ void PCB_BASE_EDIT_FRAME::InstallGraphicItemPropertiesDialog( BOARD_ITEM* aItem { wxCHECK_RET( aItem != NULL, wxT( "InstallGraphicItemPropertiesDialog() error: NULL item" ) ); - m_canvas->SetIgnoreMouseEvents( true ); DIALOG_GRAPHIC_ITEM_PROPERTIES dlg( this, aItem ); dlg.ShowModal(); - m_canvas->MoveCursorToCrossHair(); - m_canvas->SetIgnoreMouseEvents( false ); - m_canvas->Refresh(); } diff --git a/pcbnew/dialogs/dialog_text_properties.cpp b/pcbnew/dialogs/dialog_text_properties.cpp index da255a4329..b2da98b898 100644 --- a/pcbnew/dialogs/dialog_text_properties.cpp +++ b/pcbnew/dialogs/dialog_text_properties.cpp @@ -188,14 +188,8 @@ DIALOG_TEXT_PROPERTIES::~DIALOG_TEXT_PROPERTIES() */ void PCB_BASE_EDIT_FRAME::InstallTextOptionsFrame( BOARD_ITEM* aText ) { - m_canvas->SetIgnoreMouseEvents( true ); - DIALOG_TEXT_PROPERTIES dlg( this, aText ); - dlg.ShowModal(); - m_canvas->MoveCursorToCrossHair(); - - m_canvas->SetIgnoreMouseEvents( false ); } diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index c2746a9b72..0078a011dc 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -200,8 +200,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) wxLogDebug( wxT( "PCB_EDIT_FRAME::Process_Special_Functions() unknown event id %d" ), id ); break; } - - m_canvas->SetIgnoreMouseEvents( false ); } diff --git a/pcbnew/edit_track_width.cpp b/pcbnew/edit_track_width.cpp index 86f5b3b894..20d2304de3 100644 --- a/pcbnew/edit_track_width.cpp +++ b/pcbnew/edit_track_width.cpp @@ -195,7 +195,6 @@ void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) break; case ID_POPUP_PCB_SELECT_AUTO_WIDTH: - m_canvas->MoveCursorToCrossHair(); GetDesignSettings().m_UseConnectedTrackWidth = true; break; @@ -215,7 +214,6 @@ void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) case ID_POPUP_PCB_SELECT_WIDTH14: case ID_POPUP_PCB_SELECT_WIDTH15: case ID_POPUP_PCB_SELECT_WIDTH16: - m_canvas->MoveCursorToCrossHair(); GetDesignSettings().m_UseConnectedTrackWidth = false; ii = id - ID_POPUP_PCB_SELECT_WIDTH1; GetDesignSettings().SetTrackWidthIndex( ii ); @@ -238,7 +236,6 @@ void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) case ID_POPUP_PCB_SELECT_VIASIZE15: case ID_POPUP_PCB_SELECT_VIASIZE16: // select the new current value for via size (via diameter) - m_canvas->MoveCursorToCrossHair(); ii = id - ID_POPUP_PCB_SELECT_VIASIZE1; GetDesignSettings().SetViaSizeIndex( ii ); break; diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 64a052bac9..a677706867 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -240,7 +240,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, // Create the manager and dispatcher & route draw panel events to the dispatcher setupTools(); - // ReCreateMenuBar(); // UseGalCanvas() will do this for us. + ReCreateMenuBar(); ReCreateHToolbar(); ReCreateVToolbar(); ReCreateOptToolbar(); @@ -279,7 +279,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, view->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); - UseGalCanvas(); + ActivateGalCanvas(); m_auimgr.Update(); updateTitle(); @@ -905,16 +905,14 @@ void FOOTPRINT_EDIT_FRAME::setupTools() } -void FOOTPRINT_EDIT_FRAME::UseGalCanvas() +void FOOTPRINT_EDIT_FRAME::ActivateGalCanvas() { - PCB_BASE_EDIT_FRAME::UseGalCanvas(); + PCB_BASE_EDIT_FRAME::ActivateGalCanvas(); // Be sure the axis are enabled: GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); updateView(); - ReCreateMenuBar(); - // Ensure the m_Layers settings are using the canvas type: UpdateUserInterface(); } diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index 7174524923..7e988f6ee9 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -315,7 +315,7 @@ public: void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) override; ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas() - void UseGalCanvas() override; + void ActivateGalCanvas() override; /** * Load a KiCad board (.kicad_pcb) from \a aFileName. diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index b9ac860c80..6a9b90eab1 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -576,13 +576,11 @@ void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem ) { case PCB_PAD_T: InstallPadOptionsFrame( static_cast( aItem ) ); - m_canvas->MoveCursorToCrossHair(); break; case PCB_MODULE_T: editFootprintProperties( (MODULE*) aItem ); - m_canvas->MoveCursorToCrossHair(); - m_canvas->Refresh(); + GetGalCanvas()->Refresh(); break; case PCB_MODULE_TEXT_T: diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 2ab4561fc6..a4e90d8100 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -238,7 +238,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent view->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); - UseGalCanvas(); + ActivateGalCanvas(); // Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.) GetGalCanvas()->GetView()->SetScale( m_lastZoom ); diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 7c9bdf43c3..28679f8b13 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -233,7 +233,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent view->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); - UseGalCanvas(); + ActivateGalCanvas(); updateView(); SetActiveLayer( F_Cu ); diff --git a/pcbnew/microwave.cpp b/pcbnew/microwave.cpp index 9413eab61f..ca63ddbe64 100644 --- a/pcbnew/microwave.cpp +++ b/pcbnew/microwave.cpp @@ -149,10 +149,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) WX_TEXT_ENTRY_DIALOG dlg( this, msg, _( "Create microwave module" ), value ); if( dlg.ShowModal() != wxID_OK ) - { - m_canvas->MoveCursorToCrossHair(); return NULL; // cancelled by user - } value = dlg.GetValue(); gap_size = ValueFromString( GetUserUnits(), value ); @@ -167,10 +164,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) _( "Create microwave module" ), msg ); if( angledlg.ShowModal() != wxID_OK ) - { - m_canvas->MoveCursorToCrossHair(); return NULL; // cancelled by user - } msg = angledlg.GetValue(); @@ -187,10 +181,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) } if( abort ) - { - m_canvas->MoveCursorToCrossHair(); return NULL; - } module = CreateMuWaveBaseFootprint( cmp_name, text_size, pad_count ); pad = module->PadsList(); @@ -465,8 +456,6 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() int ret = dlg.ShowModal(); - m_canvas->MoveCursorToCrossHair(); - if( ret != wxID_OK ) { PolyEdges.clear(); diff --git a/pcbnew/pcb_base_edit_frame.cpp b/pcbnew/pcb_base_edit_frame.cpp index c5d222f6c6..156c063477 100644 --- a/pcbnew/pcb_base_edit_frame.cpp +++ b/pcbnew/pcb_base_edit_frame.cpp @@ -62,9 +62,9 @@ void PCB_BASE_EDIT_FRAME::SetRotationAngle( int aRotationAngle ) } -void PCB_BASE_EDIT_FRAME::UseGalCanvas() +void PCB_BASE_EDIT_FRAME::ActivateGalCanvas() { - PCB_BASE_FRAME::UseGalCanvas(); + PCB_BASE_FRAME::ActivateGalCanvas(); static_cast( GetGalCanvas() )->SyncLayersVisibility( m_Pcb ); } diff --git a/pcbnew/pcb_base_edit_frame.h b/pcbnew/pcb_base_edit_frame.h index 0df9ede3c8..b63ea3bf20 100644 --- a/pcbnew/pcb_base_edit_frame.h +++ b/pcbnew/pcb_base_edit_frame.h @@ -173,7 +173,7 @@ public: void InstallGraphicItemPropertiesDialog( BOARD_ITEM* aItem ); ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas() - void UseGalCanvas() override; + void ActivateGalCanvas() override; ///> @copydoc PCB_BASE_FRAME::SetBoard() virtual void SetBoard( BOARD* aBoard ) override; diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 0e96c664f5..26c18d49d4 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -912,9 +912,9 @@ void PCB_BASE_FRAME::SetFastGrid2() } -void PCB_BASE_FRAME::UseGalCanvas() +void PCB_BASE_FRAME::ActivateGalCanvas() { - EDA_DRAW_FRAME::UseGalCanvas(); + EDA_DRAW_FRAME::ActivateGalCanvas(); EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas(); diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index dbacd12dce..1f01caf435 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -388,7 +388,7 @@ void PCB_DRAW_PANEL_GAL::OnShow() SwitchBackend( GAL_TYPE_CAIRO ); if( frame ) - frame->UseGalCanvas(); + frame->ActivateGalCanvas(); } if( frame ) diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index dcc30bcbf8..dce3629de9 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -403,7 +403,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : view->SetScale( GetZoomLevelCoeff() / m_canvas->GetScreen()->GetZoom() ); view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); - UseGalCanvas(); + ActivateGalCanvas(); // disable Export STEP item if kicad2step does not exist wxString strK2S = Pgm().GetExecutablePath(); @@ -618,9 +618,9 @@ void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event ) } -void PCB_EDIT_FRAME::UseGalCanvas() +void PCB_EDIT_FRAME::ActivateGalCanvas() { - PCB_BASE_EDIT_FRAME::UseGalCanvas(); + PCB_BASE_EDIT_FRAME::ActivateGalCanvas(); COLORS_DESIGN_SETTINGS& cds = Settings().Colors(); cds.SetLegacyMode( false ); @@ -628,9 +628,6 @@ void PCB_EDIT_FRAME::UseGalCanvas() auto view = GetGalCanvas()->GetView(); view->GetPainter()->GetSettings()->ImportLegacyColors( &cds ); GetGalCanvas()->Refresh(); - - // Re-create the layer manager to allow arbitrary colors when GAL is enabled - UpdateUserInterface(); } diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 6262151e35..30039915c7 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -572,7 +572,7 @@ public: void Show3D_Frame( wxCommandEvent& event ) override; ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas() - void UseGalCanvas() override; + void ActivateGalCanvas() override; /** * Function ShowBoardSetupDialog diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp index 0db55d5a0f..dd35edb2b1 100644 --- a/pcbnew/sel_layer.cpp +++ b/pcbnew/sel_layer.cpp @@ -274,8 +274,6 @@ void PCB_BASE_FRAME::SelectCopperLayerPair() if( screen->m_Route_Layer_TOP == screen->m_Route_Layer_BOTTOM ) DisplayInfoMessage( this, _( "Warning: top and bottom layers are same." ) ); } - - m_canvas->MoveCursorToCrossHair(); } diff --git a/pcbnew/swig/pcbnew_action_plugins.cpp b/pcbnew/swig/pcbnew_action_plugins.cpp index aab3df2c76..e705b10ff9 100644 --- a/pcbnew/swig/pcbnew_action_plugins.cpp +++ b/pcbnew/swig/pcbnew_action_plugins.cpp @@ -380,7 +380,7 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin ) GetScreen()->PushCommandToUndoList( oldBuffer ); - UseGalCanvas(); + ActivateGalCanvas(); } diff --git a/pcbnew/swig/pcbnew_scripting_helpers.cpp b/pcbnew/swig/pcbnew_scripting_helpers.cpp index 8af1b368f5..40f7fd5db0 100644 --- a/pcbnew/swig/pcbnew_scripting_helpers.cpp +++ b/pcbnew/swig/pcbnew_scripting_helpers.cpp @@ -158,7 +158,7 @@ void Refresh() auto gal_canvas = static_cast( s_PcbEditFrame->GetGalCanvas() ); // Reinit everything: this is the easy way to do that - s_PcbEditFrame->UseGalCanvas(); + s_PcbEditFrame->ActivateGalCanvas(); gal_canvas->Refresh(); } } diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index 5e285b32db..964c498c31 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -57,7 +57,6 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( ZONE_CONTAINER* aZone ) ZONE_SETTINGS zoneInfo = GetZoneSettings(); BOARD_COMMIT commit( this ); - m_canvas->SetIgnoreMouseEvents( true ); // Save initial zones configuration, for undo/redo, before adding new zone // note the net name and the layer can be changed, so we must save all zones @@ -83,9 +82,6 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( ZONE_CONTAINER* aZone ) dialogResult = InvokeNonCopperZonesEditor( this, &zoneInfo ); } - m_canvas->MoveCursorToCrossHair(); - m_canvas->SetIgnoreMouseEvents( false ); - if( dialogResult == wxID_CANCEL ) { s_AuxiliaryList.ClearListAndDeleteItems();