← Back to team overview

kicad-developers team mailing list archive

Re: Re: redraw on erase track segment



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?

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.


Follow ups