diff --git a/common/base_screen.cpp b/common/base_screen.cpp index 62fadfa0ff..7dcb277c6d 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -37,8 +37,10 @@ BASE_SCREEN::~BASE_SCREEN() { if( m_ZoomList ) free( m_ZoomList ); + if( m_GridList ) free( m_GridList ); + ClearUndoRedoList(); } @@ -110,9 +112,8 @@ wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos ) { wxPoint curpos; - curpos.x = ScreenPos.x* GetZoom(); - - curpos.y = ScreenPos.y* GetZoom(); + curpos.x = ScreenPos.x * GetZoom(); + curpos.y = ScreenPos.y * GetZoom(); curpos.x += m_DrawOrg.x; curpos.y += m_DrawOrg.y; diff --git a/pcbnew/classpcb.cpp b/pcbnew/classpcb.cpp index f2610e86a1..932ce33434 100644 --- a/pcbnew/classpcb.cpp +++ b/pcbnew/classpcb.cpp @@ -319,14 +319,20 @@ void MARQUEUR::Display_Infos( WinEDA_DrawFrame* frame ) bool MARQUEUR::HitTest( const wxPoint& refPos ) { - // currently the MARKER is about 14 pixels by 14 pixels - int xCenter = m_Pos.x + 7; - int yCenter = m_Pos.y + 7; + // the MARKER is 12 pixels by 12 pixels, but is not resized with zoom, so + // as zoom changes, the effective real size of the MARKER changes. + + // @todo: compensate for the zoom. right now it is difficult to select marker when zoomed out. + + const int halfSize = 6; + + int xCenter = m_Pos.x + halfSize; + int yCenter = m_Pos.y + halfSize; int dx = refPos.x - xCenter; int dy = refPos.y - yCenter; - if( ABS(dx) <= 7 && ABS(dy) <= 7 ) + if( ABS(dx) <= halfSize && ABS(dy) <= halfSize ) return true; else return false; diff --git a/share/drawpanel.cpp b/share/drawpanel.cpp index 43a08762a1..fcccc4cc17 100644 --- a/share/drawpanel.cpp +++ b/share/drawpanel.cpp @@ -195,9 +195,13 @@ wxPoint WinEDA_DrawPanel::CalcAbsolutePosition( const wxPoint& rel_pos ) CalcUnscrolledPosition( rel_pos.x, rel_pos.y, &pos.x, &pos.y ); #else int ii, jj; + GetViewStart( &pos.x, &pos.y ); GetScrollPixelsPerUnit( &ii, &jj ); - pos.x *= ii; pos.y *= jj; + + pos.x *= ii; + pos.y *= jj; + pos.x += rel_pos.x; pos.y += rel_pos.y; #endif @@ -243,11 +247,16 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos ) // Conversion en coord physiques pos = CalcAbsolutePosition( display_rect.GetPosition() ); + pos.x *= GetZoom(); pos.y *= GetZoom(); + pos.x += GetScreen()->m_DrawOrg.x; pos.y += GetScreen()->m_DrawOrg.y; - display_rect.SetX( pos.x ); display_rect.SetY( pos.y ); + + display_rect.SetX( pos.x ); + display_rect.SetY( pos.y ); + display_rect.SetWidth( display_rect.GetWidth() * GetZoom() ); display_rect.SetHeight( display_rect.GetHeight() * GetZoom() ); @@ -283,11 +292,15 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition() wxPoint realpos; size = GetClientSize(); - size.x /= 2; size.y /= 2; + + size.x /= 2; + size.y /= 2; realpos = CalcAbsolutePosition( wxPoint( size.x, size.y ) ); + realpos.x *= GetZoom(); realpos.y *= GetZoom(); + realpos.x += GetScreen()->m_DrawOrg.x; realpos.y += GetScreen()->m_DrawOrg.y; @@ -576,7 +589,8 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC ) ii = pas_grille_affichee.x / zoom; if( ii < 5 ) { - pas_grille_affichee.x *= 2; ii *= 2; + pas_grille_affichee.x *= 2; + ii *= 2; } if( ii < 5 ) drawgrid = FALSE; // grille trop petite @@ -584,14 +598,18 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC ) ii = pas_grille_affichee.y / zoom; if( ii < 5 ) { - pas_grille_affichee.y *= 2; ii *= 2; + pas_grille_affichee.y *= 2; + ii *= 2; } if( ii < 5 ) drawgrid = FALSE; // grille trop petite GetViewStart( &org.x, &org.y ); GetScrollPixelsPerUnit( &ii, &jj ); - org.x *= ii; org.y *= jj; + + org.x *= ii; + org.y *= jj; + screen->m_StartVisu = org; org.x *= zoom; @@ -850,12 +868,14 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) m_Parent->OnLeftDClick( &DC, screen->m_MousePositionInPixels ); IgnoreNextLeftButtonRelease = true; } - - else if( event.LeftUp() && screen->BlockLocate.m_State==STATE_NO_BLOCK ) - if ( ! IgnoreNextLeftButtonRelease ) - m_Parent->OnLeftClick( &DC, screen->m_MousePositionInPixels ); - if( event.LeftUp() ) IgnoreNextLeftButtonRelease = false; + else if( event.LeftUp() ) + { + if( screen->BlockLocate.m_State==STATE_NO_BLOCK && !IgnoreNextLeftButtonRelease ) + m_Parent->OnLeftClick( &DC, screen->m_MousePositionInPixels ); + + IgnoreNextLeftButtonRelease = false; + } if( event.ButtonUp( 2 ) && (screen->BlockLocate.m_State == STATE_NO_BLOCK) ) { diff --git a/todo.txt b/todo.txt index 51581f6286..8dd281e454 100644 --- a/todo.txt +++ b/todo.txt @@ -56,3 +56,9 @@ when Undo/Redo stack is empty/filled. can now identify a marker. To see where the user gets a menu to delete a marker: void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) + +*** fix MARQUEUR::HitTest(): +the MARKER is 12 pixels by 12 pixels, but is not resized with zoom, so +as zoom changes, the effective real size of the MARKER changes. +@todo: compensate for the zoom. right now it is difficult to select marker when zoomed out. +