Loading common/common.cpp +123 −119 Original line number Diff line number Diff line Loading @@ -119,18 +119,16 @@ StructColors ColorRefs[NBCOLOR] = }; /* /** Function GetBuildVersion() * Return the build date */ /****************/ wxString GetBuildVersion() /****************/ { return g_BuildVersion; } /* /** Function GetAboutBuildVersion() * Return custom build date for about dialog */ wxString GetAboutBuildVersion() Loading Loading @@ -179,6 +177,7 @@ bool EnsureTextCtrlWidth(wxTextCtrl* aCtrl, /********************************************************************/ { wxWindow* window = aCtrl->GetParent(); if( !window ) window = aCtrl; Loading Loading @@ -371,6 +370,7 @@ int ReturnValueFromString( int Units, const wxString& TextValue, return Value; } /** * Function wxStringSplit * Split a String to a String List when founding 'splitter' Loading @@ -383,6 +383,7 @@ wxArrayString* wxStringSplit(wxString txt, wxChar splitter) /**********************************************************/ { wxArrayString* list = new wxArrayString(); while( 1 ) { int index = txt.Find( splitter ); Loading @@ -407,6 +408,7 @@ wxArrayString* wxStringSplit(wxString txt, wxChar splitter) /******************************************************************/ double To_User_Unit( bool is_metric, int val, int internal_unit_value ) /******************************************************************/ /** * Function To_User_Unit * Convert in inch or mm the variable "val" (double)given in internal units Loading @@ -426,11 +428,13 @@ double To_User_Unit( bool is_metric, int val, int internal_unit_value ) return value; } /******************************************************************/ double To_User_Unit( bool is_metric, double val, int internal_unit_value ) /******************************************************************/ /** * Function To_User_Unit * Convert in inch or mm the variable "val" (double)given in internal units Loading @@ -451,7 +455,6 @@ double To_User_Unit( bool is_metric, } /* * Return in internal units the value "val" given in inch or mm */ Loading Loading @@ -580,7 +583,8 @@ wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding ) // These are only default layer names. For PCBNEW, the copper names // may be over-ridden in the BOARD file *.brd. static const wxString layer_name_list[] = { static const wxString layer_name_list[] = { _( "Copper " ), _( "Inner L1 " ), _( "Inner L2 " ), _( "Inner L3 " ), _( "Inner L4 " ), _( "Inner L5 " ), _( "Inner L6 " ), _( "Inner L7 " ), _( "Inner L8 " ), _( "Inner L9 " ), _( "Inner L10" ), _( "Inner L11" ), Loading common/trigo.cpp +1467 −1453 Original line number Diff line number Diff line Loading @@ -7,28 +7,40 @@ #include "fctsys.h" #include "trigo.h" /** Function TestSegmentHit * test for hit on line segment * i.e. cursor within a given distance from segment * @param aRefPoint = cursor (point to test) coords * @param aStart is the first end-point of the line segment * @param aEnd is the second end-point of the line segment * @param aDist = maximum distance for hit */ bool TestSegmentHit( wxPoint aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist ) { // make coordinates relatives to aStart: aEnd -= aStart; aRefPoint -= aStart; return DistanceTest( aDist, aEnd.x, aEnd.y, aRefPoint.x, aRefPoint.y ); } /************************************************************************/ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY ) /************************************************************************/ /* /** Function DistanceTest * Calcul de la distance du curseur souris a un segment de droite : * ( piste, edge, contour module .. * retourne: * false si distance > seuil * true si distance <= seuil * Variables utilisees ( doivent etre initialisees avant appel , et * sont ramenees au repere centre sur l'origine du segment) * dx, dy = coord de l'extremite segment. * spot_cX,spot_cY = coord du curseur souris * la recherche se fait selon 4 cas: * segment horizontal * segment vertical * segment 45 * segment quelconque */ { /* We can have 4 cases:: * horizontal segment * vertical segment * 45 degrees segment * other slopes */ int cXrot, cYrot, /* coord du point (souris) dans le repere tourne */ segX, segY; /* coord extremite segment tj >= 0 */ int pointX, pointY; /* coord point a tester dans repere modifie dans lequel Loading Loading @@ -66,7 +78,8 @@ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY ) } if( (pointX > segX) && ( pointX <= (segX + seuil) ) ) { if( ( ( (pointX - segX) * (pointX - segX) ) + (pointY * pointY) ) <= (seuil * seuil) ) if( ( ( (pointX - segX) * (pointX - segX) ) + (pointY * pointY) ) <= (seuil * seuil) ) return true; } } Loading @@ -84,7 +97,8 @@ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY ) } if( (pointY > segY) && ( pointY <= (segY + seuil) ) ) { if( ( ( (pointY - segY) * (pointY - segY) ) + (pointX * pointX) ) <= (seuil * seuil) ) if( ( ( (pointY - segY) * (pointY - segY) ) + (pointX * pointX) ) <= (seuil * seuil) ) return true; } } Loading @@ -97,7 +111,7 @@ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY ) * et le segment de piste est alors horizontal. * recalcul des coord de la souris ( sin45 = cos45 = .707 = 7/10 * remarque : sin ou cos45 = .707, et lors du recalcul des coord * dx45 et dy45, lec coeff .707 est neglige, dx et dy sont en fait .707 fois * dx45 et dy45, lec coeff .707 est neglige, dx et dy sont en fait 0.707 fois * trop grands. (c.a.d trop petits) * spot_cX,Y doit etre * par .707 * .707 = 0.5 */ Loading Loading @@ -136,7 +150,7 @@ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY ) * de piste soit horizontal dans le nouveau repere */ int angle; angle = (int) ( atan2( (double) segY, (double) segX ) * 1800 / M_PI ); angle = wxRound( ( atan2( (double) segY, (double) segX ) * 1800.0 / M_PI ) ); cXrot = pointX; cYrot = pointY; Loading eeschema/CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ set(EESCHEMA_SRCS build_BOM.cpp busentry.cpp bus-wire-junction.cpp class_BodyItem_Text.cpp class_drawsheet.cpp class_drawsheetpath.cpp class_hierarchical_PIN_sheet.cpp Loading eeschema/class_libentry_fields.cpp +40 −14 Original line number Diff line number Diff line Loading @@ -254,27 +254,53 @@ void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, */ bool LibDrawField::HitTest( const wxPoint& refPos ) { // Reference designator text has one additional character (displays U?) return HitTest( refPos, 0, DefaultTransformMatrix ); } /** Function HitTest * @return true if the point aPosRef is near this object * @param aPosRef = a wxPoint to test * @param aThreshold = unused here (TextHitTest calculates its threshold ) * @param aTransMat = the transform matrix */ bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ) { int extraCharCount = 0; // Reference designator text has one or 2 additional character (displays U? or U?A) if( m_FieldId == REFERENCE ) { extraCharCount++; m_Text.Append('?'); // if using TextHitTest() remember this function uses top to bottom y axis convention // and for lib items we are using bottom to top convention // so for non center Y justification we use a trick. GRTextVertJustifyType vJustify = m_VJustify; if ( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; else if ( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) m_VJustify = GR_TEXT_VJUSTIFY_TOP; EDA_LibComponentStruct* parent = (EDA_LibComponentStruct*)m_Parent; if ( parent && ( parent->m_UnitCount > 1 ) ) { m_Text.Append('A'); extraCharCount++; } } bool hit = TextHitTest(refPos); m_VJustify = vJustify; wxPoint physicalpos = TransformCoordinate( aTransMat, m_Pos ); wxPoint tmp = m_Pos; m_Pos = physicalpos; /* The text orientation may need to be flipped if the * transformation matrix causes xy axes to be flipped. * this simple algo works only for schematic matrix (rot 90 or/and mirror) */ int t1 = ( aTransMat[0][0] != 0 ) ^ ( m_Orient != 0 ); int orient = t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT; EXCHG( m_Orient, orient ); if( m_FieldId == REFERENCE ) bool hit = TextHitTest(aPosRef); EXCHG( m_Orient, orient ); m_Pos = tmp; while( extraCharCount-- ) m_Text.RemoveLast( ); return hit; } // Creation et Duplication d'un field LibDrawField* LibDrawField::GenCopy() { Loading eeschema/class_libentry_fields.h +8 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,14 @@ public: */ bool HitTest( const wxPoint& refPos ); /** Function HitTest * @return true if the point aPosRef is near this object * @param aPosRef = a wxPoint to test * @param aThreshold = max distance to this object (usually the half thickness of a line) * @param aTransMat = the transform matrix */ virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ); void operator=( const LibDrawField& field ) { m_FieldId = field.m_FieldId; Loading Loading
common/common.cpp +123 −119 Original line number Diff line number Diff line Loading @@ -119,18 +119,16 @@ StructColors ColorRefs[NBCOLOR] = }; /* /** Function GetBuildVersion() * Return the build date */ /****************/ wxString GetBuildVersion() /****************/ { return g_BuildVersion; } /* /** Function GetAboutBuildVersion() * Return custom build date for about dialog */ wxString GetAboutBuildVersion() Loading Loading @@ -179,6 +177,7 @@ bool EnsureTextCtrlWidth(wxTextCtrl* aCtrl, /********************************************************************/ { wxWindow* window = aCtrl->GetParent(); if( !window ) window = aCtrl; Loading Loading @@ -371,6 +370,7 @@ int ReturnValueFromString( int Units, const wxString& TextValue, return Value; } /** * Function wxStringSplit * Split a String to a String List when founding 'splitter' Loading @@ -383,6 +383,7 @@ wxArrayString* wxStringSplit(wxString txt, wxChar splitter) /**********************************************************/ { wxArrayString* list = new wxArrayString(); while( 1 ) { int index = txt.Find( splitter ); Loading @@ -407,6 +408,7 @@ wxArrayString* wxStringSplit(wxString txt, wxChar splitter) /******************************************************************/ double To_User_Unit( bool is_metric, int val, int internal_unit_value ) /******************************************************************/ /** * Function To_User_Unit * Convert in inch or mm the variable "val" (double)given in internal units Loading @@ -426,11 +428,13 @@ double To_User_Unit( bool is_metric, int val, int internal_unit_value ) return value; } /******************************************************************/ double To_User_Unit( bool is_metric, double val, int internal_unit_value ) /******************************************************************/ /** * Function To_User_Unit * Convert in inch or mm the variable "val" (double)given in internal units Loading @@ -451,7 +455,6 @@ double To_User_Unit( bool is_metric, } /* * Return in internal units the value "val" given in inch or mm */ Loading Loading @@ -580,7 +583,8 @@ wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding ) // These are only default layer names. For PCBNEW, the copper names // may be over-ridden in the BOARD file *.brd. static const wxString layer_name_list[] = { static const wxString layer_name_list[] = { _( "Copper " ), _( "Inner L1 " ), _( "Inner L2 " ), _( "Inner L3 " ), _( "Inner L4 " ), _( "Inner L5 " ), _( "Inner L6 " ), _( "Inner L7 " ), _( "Inner L8 " ), _( "Inner L9 " ), _( "Inner L10" ), _( "Inner L11" ), Loading
common/trigo.cpp +1467 −1453 Original line number Diff line number Diff line Loading @@ -7,28 +7,40 @@ #include "fctsys.h" #include "trigo.h" /** Function TestSegmentHit * test for hit on line segment * i.e. cursor within a given distance from segment * @param aRefPoint = cursor (point to test) coords * @param aStart is the first end-point of the line segment * @param aEnd is the second end-point of the line segment * @param aDist = maximum distance for hit */ bool TestSegmentHit( wxPoint aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist ) { // make coordinates relatives to aStart: aEnd -= aStart; aRefPoint -= aStart; return DistanceTest( aDist, aEnd.x, aEnd.y, aRefPoint.x, aRefPoint.y ); } /************************************************************************/ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY ) /************************************************************************/ /* /** Function DistanceTest * Calcul de la distance du curseur souris a un segment de droite : * ( piste, edge, contour module .. * retourne: * false si distance > seuil * true si distance <= seuil * Variables utilisees ( doivent etre initialisees avant appel , et * sont ramenees au repere centre sur l'origine du segment) * dx, dy = coord de l'extremite segment. * spot_cX,spot_cY = coord du curseur souris * la recherche se fait selon 4 cas: * segment horizontal * segment vertical * segment 45 * segment quelconque */ { /* We can have 4 cases:: * horizontal segment * vertical segment * 45 degrees segment * other slopes */ int cXrot, cYrot, /* coord du point (souris) dans le repere tourne */ segX, segY; /* coord extremite segment tj >= 0 */ int pointX, pointY; /* coord point a tester dans repere modifie dans lequel Loading Loading @@ -66,7 +78,8 @@ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY ) } if( (pointX > segX) && ( pointX <= (segX + seuil) ) ) { if( ( ( (pointX - segX) * (pointX - segX) ) + (pointY * pointY) ) <= (seuil * seuil) ) if( ( ( (pointX - segX) * (pointX - segX) ) + (pointY * pointY) ) <= (seuil * seuil) ) return true; } } Loading @@ -84,7 +97,8 @@ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY ) } if( (pointY > segY) && ( pointY <= (segY + seuil) ) ) { if( ( ( (pointY - segY) * (pointY - segY) ) + (pointX * pointX) ) <= (seuil * seuil) ) if( ( ( (pointY - segY) * (pointY - segY) ) + (pointX * pointX) ) <= (seuil * seuil) ) return true; } } Loading @@ -97,7 +111,7 @@ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY ) * et le segment de piste est alors horizontal. * recalcul des coord de la souris ( sin45 = cos45 = .707 = 7/10 * remarque : sin ou cos45 = .707, et lors du recalcul des coord * dx45 et dy45, lec coeff .707 est neglige, dx et dy sont en fait .707 fois * dx45 et dy45, lec coeff .707 est neglige, dx et dy sont en fait 0.707 fois * trop grands. (c.a.d trop petits) * spot_cX,Y doit etre * par .707 * .707 = 0.5 */ Loading Loading @@ -136,7 +150,7 @@ bool DistanceTest( int seuil, int dx, int dy, int spot_cX, int spot_cY ) * de piste soit horizontal dans le nouveau repere */ int angle; angle = (int) ( atan2( (double) segY, (double) segX ) * 1800 / M_PI ); angle = wxRound( ( atan2( (double) segY, (double) segX ) * 1800.0 / M_PI ) ); cXrot = pointX; cYrot = pointY; Loading
eeschema/CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ set(EESCHEMA_SRCS build_BOM.cpp busentry.cpp bus-wire-junction.cpp class_BodyItem_Text.cpp class_drawsheet.cpp class_drawsheetpath.cpp class_hierarchical_PIN_sheet.cpp Loading
eeschema/class_libentry_fields.cpp +40 −14 Original line number Diff line number Diff line Loading @@ -254,27 +254,53 @@ void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, */ bool LibDrawField::HitTest( const wxPoint& refPos ) { // Reference designator text has one additional character (displays U?) return HitTest( refPos, 0, DefaultTransformMatrix ); } /** Function HitTest * @return true if the point aPosRef is near this object * @param aPosRef = a wxPoint to test * @param aThreshold = unused here (TextHitTest calculates its threshold ) * @param aTransMat = the transform matrix */ bool LibDrawField::HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ) { int extraCharCount = 0; // Reference designator text has one or 2 additional character (displays U? or U?A) if( m_FieldId == REFERENCE ) { extraCharCount++; m_Text.Append('?'); // if using TextHitTest() remember this function uses top to bottom y axis convention // and for lib items we are using bottom to top convention // so for non center Y justification we use a trick. GRTextVertJustifyType vJustify = m_VJustify; if ( m_VJustify == GR_TEXT_VJUSTIFY_TOP ) m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM; else if ( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) m_VJustify = GR_TEXT_VJUSTIFY_TOP; EDA_LibComponentStruct* parent = (EDA_LibComponentStruct*)m_Parent; if ( parent && ( parent->m_UnitCount > 1 ) ) { m_Text.Append('A'); extraCharCount++; } } bool hit = TextHitTest(refPos); m_VJustify = vJustify; wxPoint physicalpos = TransformCoordinate( aTransMat, m_Pos ); wxPoint tmp = m_Pos; m_Pos = physicalpos; /* The text orientation may need to be flipped if the * transformation matrix causes xy axes to be flipped. * this simple algo works only for schematic matrix (rot 90 or/and mirror) */ int t1 = ( aTransMat[0][0] != 0 ) ^ ( m_Orient != 0 ); int orient = t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT; EXCHG( m_Orient, orient ); if( m_FieldId == REFERENCE ) bool hit = TextHitTest(aPosRef); EXCHG( m_Orient, orient ); m_Pos = tmp; while( extraCharCount-- ) m_Text.RemoveLast( ); return hit; } // Creation et Duplication d'un field LibDrawField* LibDrawField::GenCopy() { Loading
eeschema/class_libentry_fields.h +8 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,14 @@ public: */ bool HitTest( const wxPoint& refPos ); /** Function HitTest * @return true if the point aPosRef is near this object * @param aPosRef = a wxPoint to test * @param aThreshold = max distance to this object (usually the half thickness of a line) * @param aTransMat = the transform matrix */ virtual bool HitTest( wxPoint aPosRef, int aThreshold, const int aTransMat[2][2] ); void operator=( const LibDrawField& field ) { m_FieldId = field.m_FieldId; Loading