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.
================================================================================
++All:
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>
================================================================================
......
......@@ -110,9 +110,11 @@ InitKiCadAbout( wxAboutDialogInfo& info )
/* Add developers */
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( "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( "Rok Markovic <rok@kanardia.eu>" ) ) );
info.AddDeveloper( SetMsg( wxT( "Vesa Solonen <vesa.solonen@hut.fi>" ) ) );
info.AddDeveloper( SetMsg( wxT( "Wayne Stambaugh <stambaughw@verizon.net>" ) ) );
......
......@@ -209,18 +209,17 @@ bool EDA_TextStruct::HitTest( const wxPoint& posref )
*/
{
int dx, dy;
int spot_cX, spot_cY;
wxPoint location;
dx = (int) (( Pitch() * GetLength() ) / 2);
dy = m_Size.y / 2;
/* Is the ref point inside the text area ? */
spot_cX = posref.x - m_Pos.x;
spot_cY = posref.y - m_Pos.y;
location = posref - m_Pos;
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 false;
......
......@@ -374,6 +374,18 @@ EDA_Rect DrawSheetStruct::GetBoundingBox()
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()
......
......@@ -129,10 +129,17 @@ public:
void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
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
* @return an EDA_Rect giving the bouding box of the sheet
*/
EDA_Rect GetBoundingBox();
void SwapData( DrawSheetStruct* copyitem );
/** Function ComponentCount
......
......@@ -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 */
NEGATE(ymax); NEGATE(ymin); // Y is not is screen axis sense
// Ensure H > 0 (wxRect assume it)
NEGATE(ymax); NEGATE(ymin); // y coordinates are screen oriented
// Ensure H > 0
if( ymax < ymin )
EXCHG( ymax, ymin );
BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin );
......
......@@ -40,9 +40,9 @@ DrawBusEntryStruct::DrawBusEntryStruct( const wxPoint& pos, int shape, int id )
}
/*************************************/
/****************************************/
wxPoint DrawBusEntryStruct::m_End() const
/*************************************/
/****************************************/
// retourne la coord de fin du raccord
{
......@@ -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 */
/***************************/
......@@ -143,6 +158,7 @@ bool DrawJunctionStruct::Save( FILE* aFile ) const
EDA_Rect DrawJunctionStruct::GetBoundingBox()
// return a bounding box
{
int width = DRAWJUNCTION_SIZE * 2;
int xmin = m_Pos.x - DRAWJUNCTION_SIZE;
......@@ -153,6 +169,21 @@ EDA_Rect DrawJunctionStruct::GetBoundingBox()
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)
void DrawJunctionStruct::Show( int nestLevel, std::ostream& os )
......@@ -188,6 +219,35 @@ DrawNoConnectStruct* DrawNoConnectStruct::GenCopy()
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
......
......@@ -162,6 +162,12 @@ public:
*/
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();
};
......@@ -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();
DrawJunctionStruct* GenCopy();
......
......@@ -35,6 +35,16 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
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()
......@@ -290,6 +300,19 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
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 ) :
......@@ -327,6 +350,18 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const
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,
......@@ -426,7 +461,9 @@ void SCH_HIERLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos )
}
}
/****************************************/
EDA_Rect SCH_HIERLABEL::GetBoundingBox()
/****************************************/
{
int x, y, dx, dy, length, height;
......@@ -639,7 +676,9 @@ void SCH_GLOBALLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos )
}
/******************************************/
EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
/******************************************/
{
int x, y, dx, dy, length, height;
......@@ -688,7 +727,9 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
}
/***********************************/
EDA_Rect SCH_TEXT::GetBoundingBox()
/***********************************/
{
int x, y, dx, dy, length, height;
......
......@@ -102,6 +102,13 @@ public:
void SwapData( SCH_TEXT* copyitem );
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();
/**
......@@ -175,6 +182,12 @@ public:
*/
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();
};
......@@ -212,6 +225,12 @@ public:
*/
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();
};
......
......@@ -557,10 +557,10 @@ bool LibDrawPolyline::HitTest( wxPoint aPosRef, int aThreshold, const int aTrans
{
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] );
end = TransformCoordinate( aTransMat, m_PolyPoints[1] );
start = TransformCoordinate( aTransMat, m_PolyPoints[ii-1] );
end = TransformCoordinate( aTransMat, m_PolyPoints[ii] );
ref = aPosRef - start;
end -= start;
......@@ -584,14 +584,15 @@ EDA_Rect LibDrawPolyline::GetBoundaryBox()
ymin = ymax = m_PolyPoints[0].y;
for( unsigned ii = 1; ii < GetCornerCount(); ii++ )
{
xmin = MIN( xmin, m_PolyPoints[0].x );
xmax = MAX( xmax, m_PolyPoints[0].x );
ymin = MIN( ymin, m_PolyPoints[0].y );
ymax = MAX( ymax, m_PolyPoints[0].y );
xmin = MIN( xmin, m_PolyPoints[ii-1].x );
xmax = MAX( xmax, m_PolyPoints[ii-1].x );
ymin = MIN( ymin, m_PolyPoints[ii].y );
ymax = MAX( ymax, m_PolyPoints[ii].y );
}
BoundaryBox.SetX( xmin ); BoundaryBox.SetWidth( xmax - xmin );
BoundaryBox.SetY( ymin ); BoundaryBox.SetHeight( ymax - ymin );
BoundaryBox.Inflate(m_Width, m_Width);
return BoundaryBox;
}
......@@ -353,7 +353,7 @@ EDA_Rect SCH_COMPONENT::GetBoundaryBox() const
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 )
EXCHG( x2, x1 );
if( y2 < y1 )
......
......@@ -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,
int DrawMode, int Color )
......@@ -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. *
......@@ -411,7 +391,6 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
* Utilisee dans les deplacements de blocs
*/
{
int Width;
int DrawMode = g_XorMode;
int width = g_DrawMinimunLineWidth;
......@@ -477,15 +456,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
{
DrawJunctionStruct* Struct;
Struct = (DrawJunctionStruct*) DrawStruct;
Width = DRAWJUNCTION_SIZE;
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 );
Struct->Draw( panel, DC, wxPoint(0,0), DrawMode, g_GhostColor );
break;
}
......
This diff is collapsed.
......@@ -324,11 +324,12 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
void WinEDA_SchematicFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
/***************************************************************************/
/* Appel� sur un double click:
* pour un �l�ment editable (textes, composant):
* appel de l'editeur correspondant.
* pour une connexion en cours:
* termine la connexion
/** Function OnLeftDClick
* called on a double click event from the drawpanel mouse handler
* if an editable item is found (text, component)
* Call the suitable dialog editor.
* Id a creat command is in progress:
* validate and finish the command
*/
{
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