Commit 920ea810 authored by dickelbeck's avatar dickelbeck

dirty stuff

parent 32a693f5
...@@ -5,19 +5,36 @@ Started 2007-June-11 ...@@ -5,19 +5,36 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2008-Mar-10 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Mar-10 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
+pcbnew +pcbnew
Pcbnew can import footprints in gpcb format in Nelib format only * Improved some comments on new functions.
Pcbnew automatically recognizes pcbnew or gpcb format when importing a footprint. * Changed
Due to differences between pcbnew and gpcb, void ConvertPcbUnitsToPixelsUnits( EDA_Rect& aRect ); to
only gpcb newlib files containing only one footprint (one element) are useables. void ConvertPcbUnitsToPixelsUnits( EDA_Rect* aRect );
Dirty rectangle calculation debugged. which I prefer because it is clearer to the human reader of the calling
WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( EDA_Rect& aRect ) can be used to convert a bouding box to a clip box context that the passed argument is to be modified. References as function
(see example in deltrack.cpp) arguments are fine, but if they are to be modified, passing by pointer
gives human reader a clearer picture when looking at the calling context.
* TRACK::GetBoundingBox() now (1) rounds up the radius, and (2) returns a bounding
box which is [pos,dim) in nature, [inclusive, exclusive).
* Changed from "new wxDCClip()" to use an automatic wxDCClip() variable in
drawpanel.cpp
* Removed a printf() from "release" build of drawpanel.cpp
2008-Mar-10 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew
Pcbnew can import footprints in gpcb format in Nelib format only
Pcbnew automatically recognizes pcbnew or gpcb format when importing a footprint.
Due to differences between pcbnew and gpcb,
only gpcb newlib files containing only one footprint (one element) are useables.
Dirty rectangle calculation debugged.
WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( EDA_Rect& aRect ) can be used to convert a bouding box to a clip box
(see example in deltrack.cpp)
+eeschema: +eeschema:
restored: missing lines in schedit.cpp (problems in a lot of commands) restored: missing lines in schedit.cpp (problems in a lot of commands)
2008-Mar-06 UPDATE Igor Plyatov <plyatov@mail.ru> 2008-Mar-06 UPDATE Igor Plyatov <plyatov@mail.ru>
......
...@@ -96,20 +96,23 @@ public: ...@@ -96,20 +96,23 @@ public:
wxPoint CursorRealPosition( const wxPoint& ScreenPos ); wxPoint CursorRealPosition( const wxPoint& ScreenPos );
wxPoint CursorScreenPosition(); wxPoint CursorScreenPosition();
/** Function ConvertPcbUnitsToPixelsUnits /**
* Convert pos and size of the given EDA_Rect to pos and size in pixels, * Function ConvertPcbUnitsToPixelsUnits
* relative to the current draw area (origin 0,0 is the left top visible corner draw area) * converts pos and size of the given EDA_Rect to pos and size in pixels,
* according to the current scrool and zoom * relative to the current draw area (origin 0,0 is the left top visible
* @param aRect = the given rect * corner of draw area) according to the current scroll and zoom.
*/ * @param aRect = the rectangle to convert
void ConvertPcbUnitsToPixelsUnits( EDA_Rect & aRect); */
/** Function ConvertPcbUnitsToPixelsUnits void ConvertPcbUnitsToPixelsUnits( EDA_Rect* aRect );
* Convert a given wxPoint position (in internal units) to the pos in pixels,
* relative to the current draw area (origin 0,0 is the left top visible corner draw area) /**
* according to the current scrool and zoom * Function ConvertPcbUnitsToPixelsUnits
* @param aPosition = the given position * converts a given wxPoint position (in internal units) to units of pixels,
*/ * relative to the current draw area (origin 0,0 is the left top visible
void ConvertPcbUnitsToPixelsUnits( wxPoint & aPosition); * corner of draw area) according to the current scroll and zoom.
* @param aPosition = the position to convert
*/
void ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition );
wxPoint GetScreenCenterRealPosition( void ); wxPoint GetScreenCenterRealPosition( void );
void MouseToCursorSchema(); void MouseToCursorSchema();
...@@ -120,7 +123,7 @@ public: ...@@ -120,7 +123,7 @@ public:
void CursorOff( wxDC* DC ); // remove the grid cursor from the display void CursorOff( wxDC* DC ); // remove the grid cursor from the display
void CursorOn( wxDC* DC ); // display the grid cursor void CursorOn( wxDC* DC ); // display the grid cursor
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
/**************************/ /**************************/
...@@ -195,7 +198,7 @@ public: ...@@ -195,7 +198,7 @@ public:
wxSize m_ScrollbarNumber; /* Valeur effective des Nombres de Scrool wxSize m_ScrollbarNumber; /* Valeur effective des Nombres de Scrool
* c.a.d taille en unites de scroll de la surface totale affichable */ * c.a.d taille en unites de scroll de la surface totale affichable */
wxPoint m_StartVisu; // Coord absolues du 1er pixel visualis�a l'ecran (en nombre de pixels) wxPoint m_StartVisu; // Coord absolues du 1er pixel visualis�a l'ecran (en nombre de pixels)
wxSize m_SizeVisu; /* taille en pixels de l'ecran (fenetre de visu wxSize m_SizeVisu; /* taille en pixels de l'ecran (fenetre de visu
* Utile pour recadrer les affichages lors de la * Utile pour recadrer les affichages lors de la
* navigation dans la hierarchie */ * navigation dans la hierarchie */
...@@ -271,16 +274,16 @@ public: ...@@ -271,16 +274,16 @@ public:
int IsRefreshReq() { return m_FlagRefreshReq & 1; } int IsRefreshReq() { return m_FlagRefreshReq & 1; }
int IsSave() { return m_FlagSave & 1; } int IsSave() { return m_FlagSave & 1; }
/** /**
* Function SetCurItem * Function SetCurItem
* sets the currently selected object, m_CurrentItem. * sets the currently selected object, m_CurrentItem.
* @param current Any object derived from EDA_BaseStruct * @param current Any object derived from EDA_BaseStruct
*/ */
void SetCurItem( EDA_BaseStruct* current ) { m_CurrentItem = current; } void SetCurItem( EDA_BaseStruct* current ) { m_CurrentItem = current; }
EDA_BaseStruct* GetCurItem() const { return m_CurrentItem; } EDA_BaseStruct* GetCurItem() const { return m_CurrentItem; }
/* fonctions relatives au zoom */ /* fonctions relatives au zoom */
int GetZoom(); /* retourne le coeff de zoom */ int GetZoom(); /* retourne le coeff de zoom */
void SetZoom( int coeff ); /* ajuste le coeff de zoom a coeff */ void SetZoom( int coeff ); /* ajuste le coeff de zoom a coeff */
...@@ -299,20 +302,20 @@ public: ...@@ -299,20 +302,20 @@ public:
void SetFirstGrid(); /* ajuste la grille au mini*/ void SetFirstGrid(); /* ajuste la grille au mini*/
void SetLastGrid(); /* ajuste la grille au max */ void SetLastGrid(); /* ajuste la grille au max */
/** /**
* Function RefPos * Function RefPos
* returns the reference position, coming from either the mouse position or the * returns the reference position, coming from either the mouse position or the
* the cursor position. * the cursor position.
* @param useMouse If true, return mouse position, else cursor's. * @param useMouse If true, return mouse position, else cursor's.
* @return wxPoint - The reference point, either the mouse position or * @return wxPoint - The reference point, either the mouse position or
* the cursor position. * the cursor position.
*/ */
wxPoint RefPos( bool useMouse ) wxPoint RefPos( bool useMouse )
{ {
return useMouse ? m_MousePosition : m_Curseur; return useMouse ? m_MousePosition : m_Curseur;
} }
/** /**
* Function GetClass * Function GetClass
...@@ -323,18 +326,18 @@ public: ...@@ -323,18 +326,18 @@ public:
{ {
return wxT( "BASE_SCREEN" ); return wxT( "BASE_SCREEN" );
} }
#if defined(DEBUG) #if defined(DEBUG)
/** /**
* Function Show * Function Show
* is used to output the object tree, currently for debugging only. * is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level * @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree. * of nesting of this object within the overall tree.
* @param os The ostream& to output to. * @param os The ostream& to output to.
*/ */
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
}; };
......
...@@ -207,7 +207,8 @@ int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) ...@@ -207,7 +207,8 @@ int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
EDA_Rect TRACK::GetBoundingBox() const EDA_Rect TRACK::GetBoundingBox() const
{ {
int radius = m_Width/2; // end of track is round, this is its radius // end of track is round, this is its radius, rounded up
int radius = ( m_Width+1 )/2;
int ymax = MAX( m_Start.y, m_End.y ); int ymax = MAX( m_Start.y, m_End.y );
int xmax = MAX( m_Start.x, m_End.x ); int xmax = MAX( m_Start.x, m_End.x );
...@@ -221,7 +222,8 @@ EDA_Rect TRACK::GetBoundingBox() const ...@@ -221,7 +222,8 @@ EDA_Rect TRACK::GetBoundingBox() const
ymin -= radius; ymin -= radius;
xmin -= radius; xmin -= radius;
return EDA_Rect( wxPoint( xmin, ymin ), wxSize( xmax-xmin, ymax-ymin ) ); // return a rectangle which is [pos,dim) in nature. therefore the +1
return EDA_Rect( wxPoint( xmin, ymin ), wxSize( xmax-xmin+1, ymax-ymin+1 ) );
} }
......
...@@ -375,13 +375,13 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, ...@@ -375,13 +375,13 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
if( !doCheckNet || !currTrack || currTrack->GetNet() == via->GetNet() ) if( !doCheckNet || !currTrack || currTrack->GetNet() == via->GetNet() )
{ {
*curpos = via->m_Start; *curpos = via->m_Start;
D(printf("via hit\n");) // D(printf("via hit\n");)
return true; return true;
} }
} }
else else
{ {
D( printf( "skipping self\n" ); ) // D( printf( "skipping self\n" ); )
} }
} }
...@@ -393,7 +393,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, ...@@ -393,7 +393,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
if( !track || track->Type() != TYPETRACK ) if( !track || track->Type() != TYPETRACK )
return false; return false;
D( printf( "Project\n" ); ) // D( printf( "Project\n" ); )
return Project( curpos, on_grid, track ); return Project( curpos, on_grid, track );
} }
...@@ -431,7 +431,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, ...@@ -431,7 +431,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
if( Join( curpos, track->m_Start, track->m_End, currTrack->m_Start, currTrack->m_End ) ) if( Join( curpos, track->m_Start, track->m_End, currTrack->m_Start, currTrack->m_End ) )
{ {
D(printf( "join currTrack->Type()=%d\n", currTrack->Type() );) // D(printf( "join currTrack->Type()=%d\n", currTrack->Type() );)
return true; return true;
} }
...@@ -453,14 +453,14 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, ...@@ -453,14 +453,14 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
{ {
if( distStart <= currTrack->m_Width/2 ) if( distStart <= currTrack->m_Width/2 )
{ {
D(printf("nearest end is start\n");) // D(printf("nearest end is start\n");)
*curpos = track->m_Start; *curpos = track->m_Start;
return true; return true;
} }
if( distEnd <= currTrack->m_Width/2 ) if( distEnd <= currTrack->m_Width/2 )
{ {
D(printf("nearest end is end\n");) // D(printf("nearest end is end\n");)
*curpos = track->m_End; *curpos = track->m_End;
return true; return true;
} }
......
...@@ -130,15 +130,16 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track ) ...@@ -130,15 +130,16 @@ TRACK* WinEDA_PcbFrame::Delete_Segment( wxDC* DC, TRACK* Track )
EDA_Rect dirty = Track->GetBoundingBox(); EDA_Rect dirty = Track->GetBoundingBox();
// Convert the rect coordinates and size in pixels (make a draw clip box): // Convert the rect coordinates and size in pixels (make a draw clip box):
DrawPanel->ConvertPcbUnitsToPixelsUnits( dirty ); DrawPanel->ConvertPcbUnitsToPixelsUnits( &dirty );
/* now that TRACK::GetBoundingBox() returns a [,) type of rectangle, and
rounds up the track radius, let's see if this is really needed.
// Ensure the last line and column are in the dirty rectangle after truncatures // Ensure the last line and column are in the dirty rectangle after truncatures
dirty.m_Size.x += 1; dirty.m_Size.y += 1; dirty.m_Size.x += 1; dirty.m_Size.y += 1;
*/
// pass wxRect() via EDA_Rect::operator wxRect() overload // pass wxRect() via EDA_Rect::operator wxRect() overload
wxRect dirtyR = dirty; DrawPanel->RefreshRect( dirty, TRUE );
DrawPanel->RefreshRect( dirtyR, TRUE );
#endif #endif
......
...@@ -267,52 +267,50 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos ) ...@@ -267,52 +267,50 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
/************************************************************************/ /************************************************************************/
void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( EDA_Rect& aRect ) void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( EDA_Rect* aRect )
/************************************************************************/ /************************************************************************/
/** Function ConvertPcbUnitsToPixelsUnits
* Convert pos and size off the given EDA_Rect to pos and size in pixels,
* relative to the current draw area (origin 0,0 is the left top visible corner draw area)
* according to the current scrool and zoom
* @param aRect = the given rect
*/
{ {
// Calculate the draw area origin in internal units: // Calculate the draw area origin in internal units:
wxPoint pos = aRect.GetPosition(); wxPoint pos = aRect->GetPosition();
ConvertPcbUnitsToPixelsUnits( &pos );
aRect->SetOrigin( pos ); // rect origin in pixel units
ConvertPcbUnitsToPixelsUnits( pos ); aRect->m_Size.x /= GetZoom();
aRect.SetOrigin( pos ); // rect origin in pixel units aRect->m_Size.y /= GetZoom(); // size in pixel units
aRect.m_Size.x /= GetZoom();
aRect.m_Size.y /= GetZoom(); // size in pixel units
} }
/***************************************************************************/ /***************************************************************************/
void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint& aPosition ) void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition )
/***************************************************************************/ /***************************************************************************/
/** Function ConvertPcbUnitsToPixelsUnits
* Convert a given wxPoint position (in internal units) to the pos in pixels,
* relative to the current draw area (origin 0,0 is the left top visible corner draw area)
* according to the current scrool and zoom
* @param aPosition = the given position
*/
{ {
// Calculate the draw area origin in internal units: // Calculate the draw area origin in internal units:
wxPoint drwOrig; wxPoint drwOrig;
int x_axis_scale, y_axis_scale; int x_axis_scale, y_axis_scale;
GetViewStart( &drwOrig.x, &drwOrig.y ); // Origin in scrool units; // Origin in scroll units;
GetViewStart( &drwOrig.x, &drwOrig.y );
GetScrollPixelsPerUnit( &x_axis_scale, &y_axis_scale ); GetScrollPixelsPerUnit( &x_axis_scale, &y_axis_scale );
drwOrig.x *= x_axis_scale; drwOrig.y *= y_axis_scale; // Origin in pixels units;
drwOrig.x *= GetZoom(); drwOrig.y *= GetZoom(); // Origin in internal units;
drwOrig += GetScreen()->m_DrawOrg; // Real origin, according to the "plot" origin // Origin in pixels units
drwOrig.x *= x_axis_scale;
drwOrig.y *= y_axis_scale;
// Origin in internal units
drwOrig.x *= GetZoom();
drwOrig.y *= GetZoom();
// Real origin, according to the "plot" origin
drwOrig += GetScreen()->m_DrawOrg;
aPosition -= drwOrig; // position in internal units, relative to the visible draw area origin // position in internal units, relative to the visible draw area origin
*aPosition -= drwOrig;
aPosition.x /= GetZoom(); // position in pixels, relative to the visible draw area origin
aPosition.y /= GetZoom(); // position in pixels, relative to the visible draw area origin aPosition->x /= GetZoom();
aPosition->y /= GetZoom();
} }
...@@ -546,17 +544,13 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) ...@@ -546,17 +544,13 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
org = m_ClipBox.GetOrigin(); org = m_ClipBox.GetOrigin();
static int counter;
wxRegion upd = GetUpdateRegion(); // get the update rect list wxRegion upd = GetUpdateRegion(); // get the update rect list
++counter; // get the union of all rectangles in the update region, 'upd'
PaintClipBox = upd.GetBox(); PaintClipBox = upd.GetBox();
#if 1 && defined (DEBUG) #if 0 && defined (DEBUG)
printf( "PaintClipBox[%d]=(%d, %d, %d, %d) org=(%d, %d) m_ClipBox=(%d, %d, %d, %d)\n", printf( "PaintClipBox=(%d, %d, %d, %d) org=(%d, %d) m_ClipBox=(%d, %d, %d, %d)\n",
counter,
PaintClipBox.x, PaintClipBox.x,
PaintClipBox.y, PaintClipBox.y,
PaintClipBox.width, PaintClipBox.width,
...@@ -583,9 +577,8 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) ...@@ -583,9 +577,8 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
#endif #endif
#if 1 // && defined(DEBUG) #if 0 && defined(DEBUG)
printf( "PaintClipBox[%d]=(%d, %d, %d, %d) org=(%d, %d) m_ClipBox=(%d, %d, %d, %d)\n", printf( "PaintClipBox=(%d, %d, %d, %d) org=(%d, %d) m_ClipBox=(%d, %d, %d, %d)\n",
counter,
PaintClipBox.x, PaintClipBox.x,
PaintClipBox.y, PaintClipBox.y,
PaintClipBox.width, PaintClipBox.width,
...@@ -599,9 +592,12 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event ) ...@@ -599,9 +592,12 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
PaintClipBox = m_ClipBox; PaintClipBox = m_ClipBox;
wxDCClipper* dcclip = new wxDCClipper( paintDC, PaintClipBox ); // call ~wxDCClipper() before ~wxPaintDC()
ReDraw( &paintDC, TRUE ); {
delete dcclip; wxDCClipper dcclip( paintDC, PaintClipBox );
ReDraw( &paintDC, TRUE );
}
m_ClipBox = tmp; m_ClipBox = tmp;
event.Skip(); event.Skip();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment