Commit 99408024 authored by charras's avatar charras

Code cleaning. Some bugs fixed. Added contributors to list in About Kicad.

parent 5813a12e
...@@ -9,7 +9,10 @@ email address. ...@@ -9,7 +9,10 @@ email address.
================================================================================ ================================================================================
++All: ++All:
Print functions and display zoom level modified to use the new zoom implementation Print functions and display zoom level modified to use the new zoom implementation
Comments adde in some functions. Comments added in some functions.
Code cleaning
some bugs fixed.
Added contributors to list in about Kicad.
2009-Jan-29 UPDATE Wayne Stambaugh <stambaughw@verizon.net> 2009-Jan-29 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================ ================================================================================
......
...@@ -110,9 +110,11 @@ InitKiCadAbout( wxAboutDialogInfo& info ) ...@@ -110,9 +110,11 @@ InitKiCadAbout( wxAboutDialogInfo& info )
/* Add developers */ /* Add developers */
info.AddDeveloper( wxT( "Jean-Pierre Charras <jean-pierre.charras@inpg.fr>" ) ); info.AddDeveloper( wxT( "Jean-Pierre Charras <jean-pierre.charras@inpg.fr>" ) );
info.AddDeveloper( SetMsg( wxT( "Jerry Jacobs <jerkejacobs@gmail.com>" ) ) );
info.AddDeveloper( SetMsg( wxT( "Dick Hollenbeck <dick@softplc.com>" ) ) ); info.AddDeveloper( SetMsg( wxT( "Dick Hollenbeck <dick@softplc.com>" ) ) );
info.AddDeveloper( SetMsg( wxT( "Jerry Jacobs <jerkejacobs@gmail.com>" ) ) );
info.AddDeveloper( SetMsg( wxT( "Jonas Diemer <diemer@gmx.de>" ) ) );
info.AddDeveloper( SetMsg( wxT( "KBool Library <http://boolean.klaasholwerda.nl/bool.html>" ) ) ); info.AddDeveloper( SetMsg( wxT( "KBool Library <http://boolean.klaasholwerda.nl/bool.html>" ) ) );
info.AddDeveloper( SetMsg( wxT( "Rok Markovic <rok@kanardia.eu>" ) ) );
info.AddDeveloper( SetMsg( wxT( "Vesa Solonen <vesa.solonen@hut.fi>" ) ) ); info.AddDeveloper( SetMsg( wxT( "Vesa Solonen <vesa.solonen@hut.fi>" ) ) );
info.AddDeveloper( SetMsg( wxT( "Wayne Stambaugh <stambaughw@verizon.net>" ) ) ); info.AddDeveloper( SetMsg( wxT( "Wayne Stambaugh <stambaughw@verizon.net>" ) ) );
......
...@@ -209,18 +209,17 @@ bool EDA_TextStruct::HitTest( const wxPoint& posref ) ...@@ -209,18 +209,17 @@ bool EDA_TextStruct::HitTest( const wxPoint& posref )
*/ */
{ {
int dx, dy; int dx, dy;
int spot_cX, spot_cY; wxPoint location;
dx = (int) (( Pitch() * GetLength() ) / 2); dx = (int) (( Pitch() * GetLength() ) / 2);
dy = m_Size.y / 2; dy = m_Size.y / 2;
/* Is the ref point inside the text area ? */ /* Is the ref point inside the text area ? */
spot_cX = posref.x - m_Pos.x; location = posref - m_Pos;
spot_cY = posref.y - m_Pos.y;
RotatePoint( &spot_cX, &spot_cY, -m_Orient ); RotatePoint( &location, -m_Orient );
if( ( abs( spot_cX ) <= abs( dx ) ) && ( abs( spot_cY ) <= abs( dy ) ) ) if( ( abs( location.x ) <= abs( dx ) ) && ( abs( location.y ) <= abs( dy ) ) )
return true; return true;
return false; return false;
......
...@@ -374,6 +374,18 @@ EDA_Rect DrawSheetStruct::GetBoundingBox() ...@@ -374,6 +374,18 @@ EDA_Rect DrawSheetStruct::GetBoundingBox()
return box; return box;
} }
/************************************************/
bool DrawSheetStruct::HitTest( const wxPoint& aPosRef )
/************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef );
}
/************************************/ /************************************/
int DrawSheetStruct::ComponentCount() int DrawSheetStruct::ComponentCount()
......
...@@ -129,10 +129,17 @@ public: ...@@ -129,10 +129,17 @@ public:
void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset, void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor = -1 ); int aDrawMode, int aColor = -1 );
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
/** Function GetBoundingBox /** Function GetBoundingBox
* @return an EDA_Rect giving the bouding box of the sheet * @return an EDA_Rect giving the bouding box of the sheet
*/ */
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
void SwapData( DrawSheetStruct* copyitem ); void SwapData( DrawSheetStruct* copyitem );
/** Function ComponentCount /** Function ComponentCount
......
...@@ -249,8 +249,8 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert ) ...@@ -249,8 +249,8 @@ EDA_Rect EDA_LibComponentStruct::GetBoundaryBox( int Unit, int Convert )
} }
// Update the BoundaryBox. Remember the fact the screen Y axis is the reverse */ // Update the BoundaryBox. Remember the fact the screen Y axis is the reverse */
NEGATE(ymax); NEGATE(ymin); // Y is not is screen axis sense NEGATE(ymax); NEGATE(ymin); // y coordinates are screen oriented
// Ensure H > 0 (wxRect assume it) // Ensure H > 0
if( ymax < ymin ) if( ymax < ymin )
EXCHG( ymax, ymin ); EXCHG( ymax, ymin );
BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin ); BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin );
......
...@@ -40,9 +40,9 @@ DrawBusEntryStruct::DrawBusEntryStruct( const wxPoint& pos, int shape, int id ) ...@@ -40,9 +40,9 @@ DrawBusEntryStruct::DrawBusEntryStruct( const wxPoint& pos, int shape, int id )
} }
/*************************************/ /****************************************/
wxPoint DrawBusEntryStruct::m_End() const wxPoint DrawBusEntryStruct::m_End() const
/*************************************/ /****************************************/
// retourne la coord de fin du raccord // retourne la coord de fin du raccord
{ {
...@@ -98,6 +98,21 @@ bool DrawBusEntryStruct::Save( FILE* aFile ) const ...@@ -98,6 +98,21 @@ bool DrawBusEntryStruct::Save( FILE* aFile ) const
} }
/*********************************************/
EDA_Rect DrawBusEntryStruct::GetBoundingBox()
/*********************************************/
{
int dx = m_Pos.x - m_End().x;
int dy = m_Pos.y - m_End().y;
EDA_Rect box( wxPoint( m_Pos.x, m_Pos.y ), wxSize( dx, dy ) );
box.Normalize();
int width = MAX( m_Width, g_DrawMinimunLineWidth );
box.Inflate(width/2, width/2);
return box;
}
/****************************/ /****************************/
/* class DrawJunctionStruct */ /* class DrawJunctionStruct */
/***************************/ /***************************/
...@@ -143,6 +158,7 @@ bool DrawJunctionStruct::Save( FILE* aFile ) const ...@@ -143,6 +158,7 @@ bool DrawJunctionStruct::Save( FILE* aFile ) const
EDA_Rect DrawJunctionStruct::GetBoundingBox() EDA_Rect DrawJunctionStruct::GetBoundingBox()
// return a bounding box
{ {
int width = DRAWJUNCTION_SIZE * 2; int width = DRAWJUNCTION_SIZE * 2;
int xmin = m_Pos.x - DRAWJUNCTION_SIZE; int xmin = m_Pos.x - DRAWJUNCTION_SIZE;
...@@ -153,6 +169,21 @@ EDA_Rect DrawJunctionStruct::GetBoundingBox() ...@@ -153,6 +169,21 @@ EDA_Rect DrawJunctionStruct::GetBoundingBox()
return ret; return ret;
}; };
/*********************************************************/
bool DrawJunctionStruct::HitTest( const wxPoint& aPosRef )
/*********************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
wxPoint dist = aPosRef - m_Pos;
if( sqrt( ((double) dist.x * dist.x) + ((double) dist.y * dist.y) ) < DRAWJUNCTION_SIZE )
return true;
return false;
}
#if defined(DEBUG) #if defined(DEBUG)
void DrawJunctionStruct::Show( int nestLevel, std::ostream& os ) void DrawJunctionStruct::Show( int nestLevel, std::ostream& os )
...@@ -188,6 +219,35 @@ DrawNoConnectStruct* DrawNoConnectStruct::GenCopy() ...@@ -188,6 +219,35 @@ DrawNoConnectStruct* DrawNoConnectStruct::GenCopy()
return newitem; return newitem;
} }
/*********************************************/
EDA_Rect DrawNoConnectStruct::GetBoundingBox()
/*********************************************/
{
const int DELTA = DRAWNOCONNECT_SIZE / 2;
EDA_Rect box( wxPoint( m_Pos.x - DELTA, m_Pos.y - DELTA ), wxSize( 2 * DELTA, 2 * DELTA ) );
box.Normalize();
return box;
}
/*********************************************************/
bool DrawNoConnectStruct::HitTest( const wxPoint& aPosRef )
/*********************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
int width = g_DrawMinimunLineWidth;
int delta = ( DRAWNOCONNECT_SIZE + width) / 2;
wxPoint dist = aPosRef - m_Pos;
if( (ABS(dist.x) <= delta) && (ABS(dist.y) <= delta) )
return true;
return false;
}
/** /**
* Function Save * Function Save
......
...@@ -162,6 +162,12 @@ public: ...@@ -162,6 +162,12 @@ public:
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
}; };
...@@ -261,6 +267,12 @@ public: ...@@ -261,6 +267,12 @@ public:
} }
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
DrawJunctionStruct* GenCopy(); DrawJunctionStruct* GenCopy();
......
...@@ -35,6 +35,16 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) : ...@@ -35,6 +35,16 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
m_IsDangling = FALSE; m_IsDangling = FALSE;
} }
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool SCH_TEXT::HitTest( const wxPoint& aPosRef )
{
EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef );
}
/*********************************************/ /*********************************************/
SCH_TEXT* SCH_TEXT::GenCopy() SCH_TEXT* SCH_TEXT::GenCopy()
...@@ -290,6 +300,19 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const ...@@ -290,6 +300,19 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
return success; return success;
} }
/************************************************/
bool SCH_GLOBALLABEL::HitTest( const wxPoint& aPosRef )
/************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef );
}
/***********************************************************************************/ /***********************************************************************************/
SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) : SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) :
...@@ -327,6 +350,18 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const ...@@ -327,6 +350,18 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const
return success; return success;
} }
/************************************************/
bool SCH_HIERLABEL::HitTest( const wxPoint& aPosRef )
/************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef );
}
/*********************************************************************************************/ /*********************************************************************************************/
void SCH_LABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, void SCH_LABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
...@@ -426,7 +461,9 @@ void SCH_HIERLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos ) ...@@ -426,7 +461,9 @@ void SCH_HIERLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos )
} }
} }
/****************************************/
EDA_Rect SCH_HIERLABEL::GetBoundingBox() EDA_Rect SCH_HIERLABEL::GetBoundingBox()
/****************************************/
{ {
int x, y, dx, dy, length, height; int x, y, dx, dy, length, height;
...@@ -639,7 +676,9 @@ void SCH_GLOBALLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos ) ...@@ -639,7 +676,9 @@ void SCH_GLOBALLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos )
} }
/******************************************/
EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
/******************************************/
{ {
int x, y, dx, dy, length, height; int x, y, dx, dy, length, height;
...@@ -688,7 +727,9 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() ...@@ -688,7 +727,9 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
} }
/***********************************/
EDA_Rect SCH_TEXT::GetBoundingBox() EDA_Rect SCH_TEXT::GetBoundingBox()
/***********************************/
{ {
int x, y, dx, dy, length, height; int x, y, dx, dy, length, height;
......
...@@ -102,6 +102,13 @@ public: ...@@ -102,6 +102,13 @@ public:
void SwapData( SCH_TEXT* copyitem ); void SwapData( SCH_TEXT* copyitem );
void Place( WinEDA_SchematicFrame* frame, wxDC* DC ); void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
/** /**
...@@ -175,6 +182,12 @@ public: ...@@ -175,6 +182,12 @@ public:
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
}; };
...@@ -212,6 +225,12 @@ public: ...@@ -212,6 +225,12 @@ public:
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
}; };
......
...@@ -557,10 +557,10 @@ bool LibDrawPolyline::HitTest( wxPoint aPosRef, int aThreshold, const int aTrans ...@@ -557,10 +557,10 @@ bool LibDrawPolyline::HitTest( wxPoint aPosRef, int aThreshold, const int aTrans
{ {
wxPoint ref, start, end; wxPoint ref, start, end;
for( unsigned ii = 0; ii < m_PolyPoints.size() - 1; ii++ ) for( unsigned ii = 1; ii < GetCornerCount(); ii++ )
{ {
start = TransformCoordinate( aTransMat, m_PolyPoints[0] ); start = TransformCoordinate( aTransMat, m_PolyPoints[ii-1] );
end = TransformCoordinate( aTransMat, m_PolyPoints[1] ); end = TransformCoordinate( aTransMat, m_PolyPoints[ii] );
ref = aPosRef - start; ref = aPosRef - start;
end -= start; end -= start;
...@@ -584,14 +584,15 @@ EDA_Rect LibDrawPolyline::GetBoundaryBox() ...@@ -584,14 +584,15 @@ EDA_Rect LibDrawPolyline::GetBoundaryBox()
ymin = ymax = m_PolyPoints[0].y; ymin = ymax = m_PolyPoints[0].y;
for( unsigned ii = 1; ii < GetCornerCount(); ii++ ) for( unsigned ii = 1; ii < GetCornerCount(); ii++ )
{ {
xmin = MIN( xmin, m_PolyPoints[0].x ); xmin = MIN( xmin, m_PolyPoints[ii-1].x );
xmax = MAX( xmax, m_PolyPoints[0].x ); xmax = MAX( xmax, m_PolyPoints[ii-1].x );
ymin = MIN( ymin, m_PolyPoints[0].y ); ymin = MIN( ymin, m_PolyPoints[ii].y );
ymax = MAX( ymax, m_PolyPoints[0].y ); ymax = MAX( ymax, m_PolyPoints[ii].y );
} }
BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin ); BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin );
BoundaryBox.SetY( ymin ); BoundaryBox.SetHeight( ymax - ymin ); BoundaryBox.SetY( ymin ); BoundaryBox.SetHeight( ymax - ymin );
BoundaryBox.Inflate(m_Width, m_Width);
return BoundaryBox; return BoundaryBox;
} }
...@@ -353,7 +353,7 @@ EDA_Rect SCH_COMPONENT::GetBoundaryBox() const ...@@ -353,7 +353,7 @@ EDA_Rect SCH_COMPONENT::GetBoundaryBox() const
int y2 = m_Transform[1][0] * xm + m_Transform[1][1] * ym; int y2 = m_Transform[1][0] * xm + m_Transform[1][1] * ym;
// H and W must be > 0 for wxRect: // H and W must be > 0:
if( x2 < x1 ) if( x2 < x1 )
EXCHG( x2, x1 ); EXCHG( x2, x1 );
if( y2 < y1 ) if( y2 < y1 )
......
...@@ -294,16 +294,6 @@ void DrawNoConnectStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint ...@@ -294,16 +294,6 @@ void DrawNoConnectStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint
} }
EDA_Rect DrawNoConnectStruct::GetBoundingBox()
{
const int DELTA = (DRAWNOCONNECT_SIZE / 2);
EDA_Rect box( wxPoint( m_Pos.x - DELTA, m_Pos.y - DELTA ), wxSize( 2 * DELTA, 2 * DELTA ) );
box.Normalize();
return box;
}
/**************************************************************/ /**************************************************************/
void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int DrawMode, int Color ) int DrawMode, int Color )
...@@ -329,16 +319,6 @@ void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& ...@@ -329,16 +319,6 @@ void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint&
} }
EDA_Rect DrawBusEntryStruct::GetBoundingBox()
{
int dx = m_Pos.x - m_End().x;
int dy = m_Pos.y - m_End().y;
EDA_Rect box( wxPoint( m_Pos.x, m_Pos.y ), wxSize( dx, dy ) );
box.Normalize();
return box;
}
/***************************************************************************** /*****************************************************************************
* Routine to redraw polyline struct. * * Routine to redraw polyline struct. *
...@@ -411,7 +391,6 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -411,7 +391,6 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
* Utilisee dans les deplacements de blocs * Utilisee dans les deplacements de blocs
*/ */
{ {
int Width;
int DrawMode = g_XorMode; int DrawMode = g_XorMode;
int width = g_DrawMinimunLineWidth; int width = g_DrawMinimunLineWidth;
...@@ -477,15 +456,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -477,15 +456,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
{ {
DrawJunctionStruct* Struct; DrawJunctionStruct* Struct;
Struct = (DrawJunctionStruct*) DrawStruct; Struct = (DrawJunctionStruct*) DrawStruct;
Width = DRAWJUNCTION_SIZE; Struct->Draw( panel, DC, wxPoint(0,0), DrawMode, g_GhostColor );
GRFilledRect( &panel->m_ClipBox,
DC,
Struct->m_Pos.x - Width + dx,
Struct->m_Pos.y - Width + dy,
Struct->m_Pos.x + Width + dx,
Struct->m_Pos.y + Width + dy,
g_GhostColor,
g_GhostColor );
break; break;
} }
......
This diff is collapsed.
...@@ -324,11 +324,12 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -324,11 +324,12 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
void WinEDA_SchematicFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) void WinEDA_SchematicFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
/***************************************************************************/ /***************************************************************************/
/* Appel� sur un double click: /** Function OnLeftDClick
* pour un �l�ment editable (textes, composant): * called on a double click event from the drawpanel mouse handler
* appel de l'editeur correspondant. * if an editable item is found (text, component)
* pour une connexion en cours: * Call the suitable dialog editor.
* termine la connexion * Id a creat command is in progress:
* validate and finish the command
*/ */
{ {
EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem();
......
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