diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index 2824c665fa..90932bff04 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -469,3 +469,22 @@ void EDA_DRAW_PANEL_GAL::onShowTimer( wxTimerEvent& aEvent ) OnShow(); } } +void EDA_DRAW_PANEL_GAL::SetCurrentCursor( int aCursor ) +{ + if ( aCursor > wxCURSOR_NONE && aCursor < wxCURSOR_MAX ) + { + m_currentCursor = aCursor; + } + else + { + m_currentCursor = wxCURSOR_ARROW; + } + + SetCursor( (wxStockCursor) m_currentCursor ); +} + +void EDA_DRAW_PANEL_GAL::SetDefaultCursor() +{ + SetCurrentCursor( m_defaultCursor ); +} + \ No newline at end of file diff --git a/common/legacy_gal/block.cpp b/common/legacy_gal/block.cpp index 1968ef23ea..f94989d43a 100644 --- a/common/legacy_gal/block.cpp +++ b/common/legacy_gal/block.cpp @@ -201,5 +201,7 @@ void AbortBlockCurrentCommand( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) screen->m_BlockLocate.SetCommand( BLOCK_IDLE ); aPanel->GetParent()->DisplayToolMsg( wxEmptyString ); - aPanel->SetDefaultCursor(); + + // ugly, but temporary + reinterpret_cast( aPanel )->SetDefaultCursor(); } diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp index b79d4faafc..c4a442ae9e 100644 --- a/common/legacy_gal/eda_draw_frame.cpp +++ b/common/legacy_gal/eda_draw_frame.cpp @@ -625,10 +625,6 @@ void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg ) // Keep default cursor in toolbars SetCursor( wxNullCursor ); - // Change m_canvas cursor if requested. - if( m_canvas && aCursor >= 0 ) - m_canvas->SetCurrentCursor( aCursor ); - // Change GAL canvas cursor if requested. if( IsGalCanvasActive() && aCursor >= 0 ) GetGalCanvas()->SetCurrentCursor( aCursor ); @@ -654,9 +650,7 @@ void EDA_DRAW_FRAME::SetNoToolSelected() // Change GAL canvas cursor if requested. if( IsGalCanvasActive() ) defaultCursor = GetGalCanvas()->GetDefaultCursor(); - else if( m_canvas ) - defaultCursor = m_canvas->GetDefaultCursor(); - + SetToolID( ID_NO_TOOL_SELECTED, defaultCursor, wxEmptyString ); } @@ -1107,13 +1101,11 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const { - printf("GetCrossHairPos\n"); // subject to change, borrow from old BASE_SCREEN for now. if( IsGalCanvasActive() ) { VECTOR2I cursor = GetGalCanvas()->GetViewControls()->GetCursorPosition(); - printf("gal %d %d\n", cursor.x, cursor.y ); return wxPoint( cursor.x, aInvertY ? -cursor.y : cursor.y ); } diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 4309acdc5b..961fd59ed0 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -132,7 +132,7 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) if( block->GetMoveVector() == wxPoint( 0, 0 ) ) { // This calls the block-abort command routine on cleanup - m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor() ); + m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor() ); return; } @@ -179,7 +179,7 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) block->ClearItemsList(); } - m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false ); + m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString, false ); GetCanvas()->GetView()->ClearPreview(); GetCanvas()->GetView()->ClearHiddenFlags(); @@ -395,7 +395,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) block->SetState( STATE_NO_BLOCK ); block->SetCommand( BLOCK_IDLE ); GetScreen()->SetCurItem( NULL ); - m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, + m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString, false ); } diff --git a/eeschema/libedit/block_libedit.cpp b/eeschema/libedit/block_libedit.cpp index ed69b605af..bd56ef855a 100644 --- a/eeschema/libedit/block_libedit.cpp +++ b/eeschema/libedit/block_libedit.cpp @@ -414,7 +414,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) block->SetState( STATE_NO_BLOCK ); block->SetCommand( BLOCK_IDLE ); GetScreen()->SetCurItem( NULL ); - m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, + m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString, false ); m_canvas->Refresh( true ); } @@ -525,7 +525,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) block->SetState( STATE_NO_BLOCK ); block->SetCommand( BLOCK_IDLE ); GetScreen()->SetCurItem( NULL ); - m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false ); + m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString, false ); GetCanvas()->GetView()->ClearPreview(); GetCanvas()->GetView()->ClearHiddenFlags(); diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index 6a87aa983c..3a2bb01027 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -612,7 +612,7 @@ void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event ) void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event ) { - m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); + m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); if( event.GetId() == ID_DE_MORGAN_NORMAL_BUTT ) m_convert = 1; @@ -663,7 +663,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( m_canvas->IsMouseCaptured() ) m_canvas->EndMouseCapture(); else - m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); + m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); break; case ID_POPUP_LIBEDIT_DELETE_ITEM: @@ -671,14 +671,11 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; default: - m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), + m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor(), wxEmptyString ); break; } - //fixme-gal - //INSTALL_UNBUFFERED_DC( dc, m_canvas ); - switch( id ) { case ID_POPUP_LIBEDIT_CANCEL_EDITING: @@ -1026,7 +1023,7 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event ) bool partLocked = GetCurPart()->UnitsLocked(); wxString oldName = GetCurPart()->GetName(); - m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); + m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); if( GetDrawItem() && GetDrawItem()->Type() == LIB_FIELD_T ) SetDrawItem( nullptr ); // selected LIB_FIELD might be deleted @@ -1074,14 +1071,14 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) m_lastDrawItem = NULL; // Stop the current command and deselect the current tool. - m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); + m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); LIB_PART* part = GetCurPart(); switch( id ) { case ID_NO_TOOL_SELECTED: - SetToolID( id, m_canvas->GetDefaultCursor(), wxEmptyString ); + SetToolID( id, GetGalCanvas()->GetDefaultCursor(), wxEmptyString ); break; case ID_MENU_ZOOM_SELECTION: @@ -1135,13 +1132,13 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) break; case ID_LIBEDIT_IMPORT_BODY_BUTT: - SetToolID( id, m_canvas->GetDefaultCursor(), _( "Import" ) ); + SetToolID( id, GetGalCanvas()->GetDefaultCursor(), _( "Import" ) ); LoadOneSymbol(); SetNoToolSelected(); break; case ID_LIBEDIT_EXPORT_BODY_BUTT: - SetToolID( id, m_canvas->GetDefaultCursor(), _( "Export" ) ); + SetToolID( id, GetGalCanvas()->GetDefaultCursor(), _( "Export" ) ); SaveOneSymbol(); SetNoToolSelected(); break; diff --git a/eeschema/libedit/libedit.cpp b/eeschema/libedit/libedit.cpp index c5074ffbb9..0533e57741 100644 --- a/eeschema/libedit/libedit.cpp +++ b/eeschema/libedit/libedit.cpp @@ -255,7 +255,7 @@ void LIB_EDIT_FRAME::OnSaveAll( wxCommandEvent& event ) void LIB_EDIT_FRAME::OnCreateNewPart( wxCommandEvent& event ) { - m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); + m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); SetDrawItem( NULL ); wxString lib = getTargetLib(); @@ -647,7 +647,7 @@ bool LIB_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile ) wxString msg; PROJECT& prj = Prj(); - m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); + m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); if( !aNewFile && ( aLibrary.empty() || !prj.SchSymbolLibTable()->HasLibrary( aLibrary ) ) ) { diff --git a/eeschema/libedit/symbdraw.cpp b/eeschema/libedit/symbdraw.cpp index ec3b832f47..8e81ac7f41 100644 --- a/eeschema/libedit/symbdraw.cpp +++ b/eeschema/libedit/symbdraw.cpp @@ -351,7 +351,7 @@ void LIB_EDIT_FRAME::EndDrawGraphicItem( wxDC* DC ) if( GetToolId() != ID_NO_TOOL_SELECTED ) SetCursor( wxCURSOR_PENCIL ); else - SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ); + SetCursor( (wxStockCursor) GetGalCanvas()->GetDefaultCursor() ); if( GetTempCopyComponent() ) // used when editing an existing item SaveCopyInUndoList( GetTempCopyComponent() ); diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index a0a67ed59c..4f4f78dbe4 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -58,11 +58,12 @@ m_parent( aParentWindow ) m_view = new KIGFX::SCH_VIEW( true ); m_view->SetGAL( m_gal ); + m_gal->SetWorldUnitLength( 0.01 ); // 1 unit = 0.01 inch m_painter.reset( new KIGFX::SCH_PAINTER( m_gal ) ); m_view->SetPainter( m_painter.get() ); - m_view->SetScaleLimits( 2000000.0, 30000.0 ); + m_view->SetScaleLimits( 2000000.0, 0.002 ); m_view->SetMirror( false, false ); setDefaultLayerOrder(); @@ -337,16 +338,14 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) m_PanStartCenter = GetParent()->GetScrollCenterPosition(); m_PanStartEventPosition = event.GetPosition(); -// INSTALL_UNBUFFERED_DC( dc, this ); CrossHairOff( ); SetCurrentCursor( wxCURSOR_SIZING ); } if( event.ButtonUp( wxMOUSE_BTN_MIDDLE ) ) { -// INSTALL_UNBUFFERED_DC( dc, this ); CrossHairOn(); - SetCursor( (wxStockCursor) m_defaultCursor ); + SetDefaultCursor(); } if( event.MiddleIsDown() ) @@ -644,22 +643,6 @@ void SCH_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event ) event.Skip(); } -void SCH_DRAW_PANEL::SetCurrentCursor( int aCursor ) -{ - m_currentCursor = aCursor; - SetCursor( (wxStockCursor) m_currentCursor ); -} - -void SCH_DRAW_PANEL::SetCurrentCursor( const wxCursor& aCursor ) -{ - SetCursor( aCursor ); -} - -void SCH_DRAW_PANEL::SetDefaultCursor() -{ - SetCursor( (wxStockCursor) m_defaultCursor ); -} - void SCH_DRAW_PANEL::onPaint( wxPaintEvent& aEvent ) { if( m_painter ) diff --git a/eeschema/sch_draw_panel.h b/eeschema/sch_draw_panel.h index 01d18b1fc5..8d063794a0 100644 --- a/eeschema/sch_draw_panel.h +++ b/eeschema/sch_draw_panel.h @@ -78,24 +78,6 @@ public: /// @copydoc wxWindow::Refresh() void Refresh( bool aEraseBackground = true, const wxRect* aRect = NULL ) override; - virtual void SetCurrentCursor( int aCursor ) override; - virtual void SetCurrentCursor( const wxCursor& aCursor ) override; - virtual void SetDefaultCursor() override; - - virtual int GetDefaultCursor() const override - { - return EDA_DRAW_PANEL_GAL::GetDefaultCursor(); - } - - /** - * Function GetCurrentCursor - * @return the current cursor shape, depending on the current selected tool - */ - virtual int GetCurrentCursor() const override - { - return EDA_DRAW_PANEL_GAL::GetCurrentCursor(); - } - protected: diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index e1eeb8d9cf..50ee787b16 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -161,7 +161,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( m_canvas->IsMouseCaptured() ) { m_canvas->EndMouseCapture(); - SetToolID( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString ); + SetToolID( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString ); } else { @@ -463,7 +463,7 @@ void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent ) if( screen->IsBlockActive() ) { -// m_canvas->SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ); +// m_canvas->SetCursor( (wxStockCursor) GetGalCanvas()->GetDefaultCursor() ); screen->ClearBlockCommand(); // Stop the current command (if any) but keep the current tool @@ -474,7 +474,7 @@ void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent ) if( m_canvas->IsMouseCaptured() ) // Stop the current command but keep the current tool m_canvas->EndMouseCapture(); else // Deselect current tool - m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); + m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); } GetCanvas()->GetView()->ClearHiddenFlags(); @@ -489,7 +489,7 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) int lastToolID = GetToolId(); // Stop the current command and deselect the current tool. - m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); + m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); switch( id ) { diff --git a/include/class_draw_panel_gal.h b/include/class_draw_panel_gal.h index a70144f815..2626c4bc78 100644 --- a/include/class_draw_panel_gal.h +++ b/include/class_draw_panel_gal.h @@ -204,16 +204,13 @@ public: return m_stealsFocus; } + virtual void SetDefaultCursor(); /** * Function SetCurrentCursor * Set the current cursor shape for this panel */ - void SetCurrentCursor( int aCursor ) - { - m_currentCursor = aCursor; - SetCursor( (wxStockCursor) m_currentCursor ); - } - + virtual void SetCurrentCursor( int aCursor ); + /** * Function GetDefaultCursor * @return the default cursor shape diff --git a/include/legacy_gal/class_drawpanel.h b/include/legacy_gal/class_drawpanel.h index 667cebda63..a4c6f1a7e6 100644 --- a/include/legacy_gal/class_drawpanel.h +++ b/include/legacy_gal/class_drawpanel.h @@ -359,28 +359,6 @@ public: */ virtual void CallEndMouseCapture( wxDC* aDC ) { printf("Unimplemented\n"); assert(false); };; - /** - * Function SetCurrentCursor - * Set the current cursor shape for drawpanel - */ - virtual void SetCurrentCursor( int aCursor ) {}; - virtual void SetCurrentCursor( const wxCursor& aCursor ) {}; - - /** - * Function GetDefaultCursor - * @return the default cursor shape - */ - //fixme-gal - virtual int GetDefaultCursor() const = 0; - - virtual void SetDefaultCursor() {}; - - /** - * Function GetCurrentCursor - * @return the current cursor shape, depending on the current selected tool - */ - virtual int GetCurrentCursor() const = 0; - virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL ) {} virtual wxWindow* GetWindow() = 0;