← Back to team overview

kicad-developers team mailing list archive

Re: Re: redraw on erase track segment

 

Dick Hollenbeck a écrit :
Jean-Pierre,

I have the track's bounding box now. How do I scale it to a dirty rectangle?

Here is what I have now:


// redraw the area where the track was
EDA_Rect dirty = Track->GetBoundingBox();

/* saw this going in the opposite direction from what I think I need:
curpos.x = ScreenPos.x * GetZoom();
curpos.y = ScreenPos.y * GetZoom();

curpos.x += m_DrawOrg.x;
curpos.y += m_DrawOrg.y;
*/

// here is the reverse:
int zoom = GetZoom();

wxPoint drwOrig = GetScreen()->m_DrawOrg;

dirty.m_Pos.x = (dirty.m_Pos.x - drwOrig.x) / zoom;
dirty.m_Pos.y = (dirty.m_Pos.y - drwOrig.y) / zoom;

dirty.m_Size.x = (dirty.m_Size.x - drwOrig.x) / zoom;
dirty.m_Size.y = (dirty.m_Size.y - drwOrig.y) / zoom;

// pass wxRect() via EDA_Rect::operator wxRect() overload
// convert from EDA_Rect to wxRect, no problem here
wxRect dirtyR = dirty;

DrawPanel->Refresh( TRUE, &dirtyR );



Does this look right?


For me, it looks right ( but i wrote the graphic code some years ago...)



I also believe ReDraw() must be called only once.



Yes, I'm having a look at this too. I put a debug counter in there to learn some interesting things.


Dick






--

Jean-Pierre CHARRAS

Maître de conférences
Directeur d'études 2ieme année.
Génie Electrique et Informatique Industrielle 2
Institut Universitaire de Technologie 1 de Grenoble
BP 67, 38402 St Martin d'Heres Cedex

Recherche :
GIPSA-LIS - INPG
46, Avenue Félix Viallet
38031 Grenoble cedex








Follow ups

References