Loading change_log.txt +9 −1 Original line number Diff line number Diff line Loading @@ -6,10 +6,18 @@ email address. 2007-Aug-05 UPDATE Dick Hollenbeck <dick@softplc.com> ================================================================================ + pcbnew & common Changed the function name of Locate( const wxPoint& ref_pos ) to bool HitTest(..) in both class_text_mod and base_struct. More beautification and commenting. 2007-Aug-04 UPDATE Dick Hollenbeck <dick@softplc.com> ================================================================================ + pcbnew Read-ability formatting, I am playing with a C++ beautifier called uncrustify. Read-ability formatting, I am playing with a C++ beautifier called "uncrustify". I had to patch it and spent 2 days getting it configured. Patch not sent upstream yet. Fixed a bug in "display local ratsnest pad or module": if you had a small Loading common/base_struct.cpp +560 −518 Original line number Diff line number Diff line Loading @@ -69,8 +69,6 @@ wxT("unknown") }; enum textbox { ID_TEXTBOX_LIST = 8010 }; Loading @@ -94,6 +92,7 @@ EDA_BaseStruct::EDA_BaseStruct(int idType) m_StructType = idType; } /********************************************/ void EDA_BaseStruct::InitVars( void ) /********************************************/ Loading @@ -114,21 +113,25 @@ void EDA_BaseStruct::InitVars(void) /* Gestion de l'etat (status) de la structure (active, deleted..) */ int EDA_BaseStruct::GetState( int type ) { return(m_Status & type); return m_Status & type; } void EDA_BaseStruct::SetState( int type, int state ) { if( state ) m_Status |= type; /* state = ON ou OFF */ else m_Status &= ~type; if( state ) m_Status |= type;/* state = ON ou OFF */ else m_Status &= ~type; } /*********************************************************/ void EDA_BaseStruct::AddToChain( EDA_BaseStruct* laststruct ) /*********************************************************/ /* addition d'une nouvelle struct a la liste chaine, apres la structure laststruct * addition d'une nouvelle struct a la liste chain�, apres la structure laststruct */ { Pnext = laststruct->Pnext; Loading @@ -141,45 +144,53 @@ addition d'une nouvelle struct a la liste chain void EDA_BaseStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, int Color ) /**************************************************************************************/ /* Virtual */ { wxString msg, name; msg.Printf( wxT("EDA_BaseStruct::Draw() error. Method for struct type %d used but not implemented ("), msg.Printf( wxT( "EDA_BaseStruct::Draw() error. Method for struct type %d used but not implemented (" ), m_StructType ); msg += ReturnClassName() + wxT( ")\n" ); printf( CONV_TO_UTF8( msg ) ); } #if 0 /**************************************************************/ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) /**************************************************************/ /* fonction virtuelle de placement: non utilisee en pcbnew (utilisee eeschema) ---- A mieux utiliser (TODO...) * ---- A mieux utiliser (TODO...) */ { } #endif /*********************************************/ wxString EDA_BaseStruct::ReturnClassName( void ) /*********************************************/ /* Used at run time for diags: return the class name of the item, from its .m_StructType value. * from its .m_StructType value. */ { int ii = m_StructType; wxString classname; if ( (ii < 0) || (ii > MAX_STRUCT_TYPE_ID) ) ii = MAX_STRUCT_TYPE_ID; if( (ii < 0) || (ii > MAX_STRUCT_TYPE_ID) ) ii = MAX_STRUCT_TYPE_ID; classname = DrawStructureTypeName[ii]; return classname; } /**********************************************************************************************/ EDA_BaseLineStruct::EDA_BaseLineStruct( EDA_BaseStruct* StructFather, DrawStructureType idtype ) : EDA_BaseStruct( StructFather, idtype ) Loading @@ -191,7 +202,7 @@ EDA_BaseLineStruct::EDA_BaseLineStruct(EDA_BaseStruct * StructFather, DrawStruct /*********************************************************/ /* EDA_TextStruct (classe de base, non utilise seule */ /* EDA_TextStruct (classe de base, non utilis� seule */ /*********************************************************/ EDA_TextStruct::EDA_TextStruct( const wxString& text ) { Loading @@ -207,7 +218,7 @@ EDA_TextStruct::EDA_TextStruct(const wxString & text) m_Text = text; m_ZoomLevelDrawable = 0; /* Niveau de zoom acceptable pour affichage normal */ m_TextDrawings = NULL; /* Pointeur sur le dessin du caractere */ m_TextDrawingsSize = 0; /* taille du tableau point */ m_TextDrawingsSize = 0; /* taille du tableau point�*/ } Loading @@ -220,14 +231,18 @@ EDA_TextStruct::~EDA_TextStruct(void) m_TextDrawingsSize = 0; /* nombre de sommets a dessiner */ } /********************************/ int EDA_TextStruct::Len_Size( void ) /********************************/ // Return the text lenght in internal units { int nbchar = m_Text.Len(); int len; if ( nbchar == 0 ) return 0; if( nbchar == 0 ) return 0; len = ( (10 * m_Size.x ) / 9 ) * nbchar; return len; Loading @@ -235,12 +250,13 @@ int len; /*************************************************/ int EDA_TextStruct::Locate(const wxPoint & posref) bool EDA_TextStruct::HitTest( const wxPoint& posref ) /*************************************************/ /* locate function return: 1 if posref is inside the text area. 0 else. * return: * true if posref is inside the text area. * false else. */ { int dx, dy; Loading @@ -250,33 +266,42 @@ int spot_cX, spot_cY; 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 ; spot_cX = posref.x - m_Pos.x; spot_cY = posref.y - m_Pos.y; RotatePoint( &spot_cX, &spot_cY, -m_Orient ); if( (abs(spot_cX) <= abs(dx) ) && ( abs(spot_cY) <= abs(dy) ) ) return 1; return 0; if( ( abs( spot_cX ) <= abs( dx ) ) && ( abs( spot_cY ) <= abs( dy ) ) ) return true; return false; } /*******************************/ int EDA_TextStruct::Pitch( void ) /*******************************/ /* retourne le pas entre 2 caracteres */ { return ( (10 * m_Size.x ) / 9 ) + m_Width; } /***************************************************************/ void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int color, int draw_mode, int display_mode, int anchor_color ) /***************************************************************/ /* Trace de 1 texte type EDA_TextStruct. offset = Offset de trace (usuellement (0,0) color = couleur du texte draw_mode = GR_OR, GR_XOR.., -1 si mode courant. display_mose = FILAIRE, FILLED ou SKETCH anchor_color = couleur de l'ancre ( -1 si pas d'ancre ). * Trace de 1 texte type EDA_TextStruct. * offset = Offset de trace (usuellement (0,0) * color = couleur du texte * draw_mode = GR_OR, GR_XOR.., -1 si mode courant. * display_mose = FILAIRE, FILLED ou SKETCH * anchor_color = couleur de l'ancre ( -1 si pas d'ancre ). */ { int zoom; Loading @@ -286,13 +311,16 @@ int width; if( m_TextDrawings == NULL ) /* pointeur sur la liste des segments de dessin */ CreateDrawData(); if( m_TextDrawings == NULL) return; if( m_TextDrawings == NULL ) return; zoom = panel->GetZoom(); width = m_Width / zoom; if ( display_mode == FILAIRE ) width = 0; if( display_mode == FILAIRE ) width = 0; /* choix de la couleur du texte : */ if ( draw_mode != -1 ) GRSetDrawMode(DC, draw_mode); if( draw_mode != -1 ) GRSetDrawMode( DC, draw_mode ); /* trace du texte */ if( zoom > m_ZoomLevelDrawable ) Loading @@ -304,7 +332,6 @@ int width; m_TextDrawings[4] + offset.y + m_Pos.y, width, color ); } else { /* trace ancre du texte ? */ Loading @@ -325,7 +352,8 @@ int width; while( ii < m_TextDrawingsSize ) { nbpoints = m_TextDrawings[jj]; if (nbpoints > 50 ) nbpoints = 50; if( nbpoints > 50 ) nbpoints = 50; for( kk = 0, ll = 0; (kk < nbpoints) && (ii < m_TextDrawingsSize); kk++ ) { coord[ll] = m_TextDrawings[ii] + offset.x + m_Pos.x; Loading @@ -333,6 +361,7 @@ int width; coord[ll] = m_TextDrawings[ii] + offset.y + m_Pos.y; ll++; ii++; } jj = ii; ii++; if( width > 2 ) Loading @@ -345,7 +374,8 @@ int width; coord[ll + 2], coord[ll + 3], m_Width, color ); else GRFillCSegm(&panel->m_ClipBox, DC, else GRFillCSegm( &panel->m_ClipBox, DC, coord[ll], coord[ll + 1], coord[ll + 2], coord[ll + 3], m_Width, color ); Loading @@ -353,24 +383,25 @@ int width; } else GRPoly( &panel->m_ClipBox, DC, nbpoints, coord, 0, 0, color, color ); } } } /****************************************/ void EDA_TextStruct::CreateDrawData( void ) /****************************************/ /* Cree le tableau de donnes ncessaire au trace d'un texte (pcb, module..) Met a jour: m_ZoomLevelDrawable Niveau de zoom acceptable pour affichage normal m_TextDrawings Pointeur sur le tableau de donnes m_TextDrawingsSize taille (en int) du tableau Codage dans le tableau: Suite des coord des sommets des polygones a tracer prcd du nombre de sommets nn xx1 yy1 xx2 yy2 .. xxn yyn mm xx1 yy1 xx2 yy2 .. xxm yym les 2 premiers sommets sont le segment symbolisant le texte pour les affichages a trop petite echelle /* Cree le tableau de donn�s n�essaire au trace d'un texte (pcb, module..) * Met a jour: * m_ZoomLevelDrawable Niveau de zoom acceptable pour affichage normal * m_TextDrawings Pointeur sur le tableau de donn�s * m_TextDrawingsSize taille (en int) du tableau * Codage dans le tableau: * Suite des coord des sommets des polygones a tracer pr���du nombre de sommets * nn xx1 yy1 xx2 yy2 .. xxn yyn mm xx1 yy1 xx2 yy2 .. xxm yym * les 2 premiers sommets sont le segment symbolisant le texte pour les * affichages a trop petite echelle */ { int ii, jj, kk, nbchar, nbpoints, AsciiCode, endcar; Loading @@ -392,7 +423,8 @@ int coord_count_max = 1000; m_TextDrawingsSize = 0; /* nombre de segments a dessiner */ nbchar = m_Text.Length(); if ( nbchar == 0 ) return; if( nbchar == 0 ) return; size_h = m_Size.x; size_v = m_Size.y; Loading Loading @@ -443,7 +475,6 @@ int coord_count_max = 1000; break; } } else /* Texte Vertical */ { switch( m_HJustify ) Loading Loading @@ -478,7 +509,7 @@ int coord_count_max = 1000; ox = cX - dx;; oy = cY + dy; /* lorsque les chars sont trop petits pour etre dessines, le texte est symbolise par une barre */ * le texte est symbolise par une barre */ m_ZoomLevelDrawable = m_Size.x / 3; dx = (espacement * nbchar) / 2; dy = size_v / 2; /* Decalage du debut du texte / centre */ Loading @@ -498,11 +529,13 @@ int coord_count_max = 1000; x0 = 0; y0 = 0; AsciiCode = (*ptr) & 255; ptcar = graphic_fonte_shape[AsciiCode]; /* ptcar pointe la description du caractere a dessiner */ * du caractere a dessiner */ for( endcar = FALSE; !endcar; ptcar++ ) { f_cod = *ptcar ; /* get code n de la forme selectionnee */ f_cod = *ptcar; /* get code n de la forme selectionnee */ switch( f_cod ) { case 'X': Loading @@ -525,7 +558,7 @@ int coord_count_max = 1000; case 'D': plume = f_cod; nbpoints = 1; /* 1 point va suivre (origine du trac) */ nbpoints = 1; /* 1 point va suivre (origine du trac� */ break; default: Loading @@ -547,21 +580,27 @@ int coord_count_max = 1000; nbpoints++; break; } } /* end switch */ } /* end boucle for = end trace de 1 caractere */ } /* end switch */ } /* end boucle for = end trace de 1 caractere */ ptr++; ox += espacement; } /* end trace du texte */ } /* end trace du texte */ m_TextDrawings = (int*) realloc( coord, ii * sizeof(int) ); m_TextDrawingsSize = ii; //taille (en int) du tableau } /******************************/ void EDA_Rect::Normalize( void ) /******************************/ // Ensure the height ant width are >= 0 { if( m_Size.y < 0 ) Loading @@ -580,8 +619,9 @@ void EDA_Rect::Normalize(void) /*******************************************/ bool EDA_Rect::Inside( const wxPoint& point ) /*******************************************/ /* Return TRUE if point is in Rect Accept rect size < 0 * Accept rect size < 0 */ { int rel_posx = point.x - m_Pos.x; Loading @@ -597,12 +637,13 @@ wxSize size = m_Size; { size.y = -size.y; rel_posy += size.y; } return ( (rel_posx >= 0) && (rel_posy >= 0) return (rel_posx >= 0) && (rel_posy >= 0) && ( rel_posy <= size.y) && ( rel_posx <= size.x) ); ; } /**************************************************/ EDA_Rect& EDA_Rect::Inflate( wxCoord dx, wxCoord dy ) /**************************************************/ Loading Loading @@ -639,16 +680,15 @@ EDA_Rect& EDA_Rect::Inflate(wxCoord dx, wxCoord dy) } /**************************/ /* class DrawPickedStruct */ /**************************/ /* This class has only one useful member: .m_PickedStruct, used as a link. It does not describe really an item. It is used to create a linked list of selected items (in block selection). Each DrawPickedStruct item has is member: .m_PickedStruct pointing the real selected item * It does not describe really an item. * It is used to create a linked list of selected items (in block selection). * Each DrawPickedStruct item has is member: .m_PickedStruct pointing the * real selected item */ /*******************************************************************/ Loading @@ -659,6 +699,7 @@ DrawPickedStruct::DrawPickedStruct(EDA_BaseStruct *pickedstruct ) : m_PickedStruct = pickedstruct; } DrawPickedStruct::~DrawPickedStruct( void ) { } Loading @@ -667,8 +708,9 @@ DrawPickedStruct::~DrawPickedStruct(void) /*********************************************/ void DrawPickedStruct::DeleteWrapperList( void ) /*********************************************/ /* Delete this item all the items of the linked list Free the wrapper, but DOES NOT delete the picked items linked by .m_PickedStruct * Free the wrapper, but DOES NOT delete the picked items linked by .m_PickedStruct */ { DrawPickedStruct* wrapp_struct, * next_struct; Loading common/trigo.cpp +173 −142 Original line number Diff line number Diff line Loading @@ -12,63 +12,77 @@ /***********************************/ int ArcTangente( int dy, int dx ) /***********************************/ /* Retourne l'arc tangente en 0.1 degres du vecteur de coord dx, dy entre -1800 et 1800 Analogue a atan2 ( mais plus rapide pour les calculs si l'angle est souvent 0, -1800, ou +- 900 * entre -1800 et 1800 * Analogue a atan2 ( mais plus rapide pour les calculs si * l'angle est souvent 0, -1800, ou +- 900 */ { double fangle; if( dy == 0 ) { if(dx >= 0 ) return(0); else return(-1800); if( dx >= 0 ) return 0; else return -1800; } if( dx == 0 ) { if(dy >= 0 ) return(900); else return(-900); if( dy >= 0 ) return 900; else return -900; } if( dx == dy ) { if(dx >= 0) return(450); else return(-1800+450); if( dx >= 0 ) return 450; else return -1800 + 450; } if( dx == -dy ) { if(dx >= 0) return(-450); else return(1800-450); if( dx >= 0 ) return -450; else return 1800 - 450; } fangle = atan2( (double) dy, (double) dx ) / M_PI * 1800; return( (int) round(fangle) ); return (int) round( fangle ); } /*********************************************/ void RotatePoint( int* pX, int* pY, int angle ) /*********************************************/ /* Fonction surchargee! calcule les nouvelles coord du point de coord pX, pY, pour une rotation de centre 0, 0, et d'angle angle ( en 1/10 degre) * Fonction surchargee! * calcule les nouvelles coord du point de coord pX, pY, * pour une rotation de centre 0, 0, et d'angle angle ( en 1/10 degre) */ { float fpx, fpy; int tmp; while (angle < 0) angle += 3600; while (angle >= 3600) angle -= 3600; while( angle < 0 ) angle += 3600; while( angle >= 3600 ) angle -= 3600; if (angle == 0) return; if( angle == 0 ) return; /* Calcul des coord : coord: xrot = y*sin + x*cos yrot = y*cos - x*sin * coord: xrot = y*sin + x*cos * yrot = y*cos - x*sin */ if( angle == 900 ) /* sin = 1, cos = 0 */ { Loading @@ -76,25 +90,24 @@ int tmp; *pX = *pY; *pY = -tmp; } else if( angle == 1800 ) /* sin = 0, cos = -1 */ { *pX = -*pX; *pY = -*pY; } else if( angle == 2700 ) /* sin = -1, cos = 0 */ { tmp = *pX; *pX = -*pY; *pY = tmp; } else { fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]); fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[angle]); *pX = (int)round(fpx); *pY = (int)round(fpy); *pX = (int) round( fpx ); *pY = (int) round( fpy ); } } Loading @@ -102,32 +115,40 @@ int tmp; /************************************************************/ void RotatePoint( int* pX, int* pY, int cx, int cy, int angle ) /*************************************************************/ /* Fonction surchargee! calcule les nouvelles coord du point de coord pX, pY, pour une rotation de centre cx, cy, et d'angle angle ( en 1/10 degre) * Fonction surchargee! * calcule les nouvelles coord du point de coord pX, pY, * pour une rotation de centre cx, cy, et d'angle angle ( en 1/10 degre) */ { int ox, oy; ox = *pX - cx; oy = *pY - cy; ox = *pX - cx; oy = *pY - cy; RotatePoint( &ox, &oy, angle ); *pX = ox + cx; *pY = oy + cy; } /*****************************************************************/ void RotatePoint( wxPoint* point, const wxPoint& centre, int angle ) /*****************************************************************/ /* Fonction surchargee! calcule les nouvelles coord du point point, pour une rotation de centre centre, et d'angle angle ( en 1/10 degre) * Fonction surchargee! * calcule les nouvelles coord du point point, * pour une rotation de centre centre, et d'angle angle ( en 1/10 degre) */ { int ox, oy; ox = point->x - centre.x; oy = point->y - centre.y; ox = point->x - centre.x; oy = point->y - centre.y; RotatePoint( &ox, &oy, angle ); point->x = ox + centre.x; point->y = oy + centre.y; Loading @@ -140,8 +161,11 @@ void RotatePoint(double *pX, double *pY, double cx, double cy, int angle) { double ox, oy; ox = *pX - cx; oy = *pY - cy; ox = *pX - cx; oy = *pY - cy; RotatePoint( &ox, &oy, angle ); *pX = ox + cx; *pY = oy + cy; } Loading @@ -150,39 +174,46 @@ double ox, oy; /*************************************************/ void RotatePoint( double* pX, double* pY, int angle ) /*************************************************/ /* Calcul des coord : coord: xrot = y*sin + x*cos yrot = y*cos - x*sin * coord: xrot = y*sin + x*cos * yrot = y*cos - x*sin */ { double tmp; while (angle < 0) angle += 3600; while (angle >= 3600) angle -= 3600; if (angle == 0) return; while( angle < 0 ) angle += 3600; while( angle >= 3600 ) angle -= 3600; if( angle == 0 ) return; if( angle == 900 ) /* sin = 1, cos = 0 */ { tmp = *pX; *pX = *pY; *pY = -tmp; } else if( angle == 1800 ) /* sin = 0, cos = -1 */ { *pX = -*pX; *pY = -*pY; } else if( angle == 2700 ) /* sin = -1, cos = 0 */ { tmp = *pX; *pX = -*pY; *pY = tmp; } else { double fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]); double fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[angle]); *pX = fpx; *pY = fpy; *pX = fpx; *pY = fpy; } } include/base_struct.h +8 −2 Original line number Diff line number Diff line Loading @@ -179,8 +179,14 @@ public: const wxPoint& offset, int color, int draw_mode, int display_mode = FILAIRE, int anchor_color = -1 ); /* locate functions */ int Locate( const wxPoint& posref ); /** * Function HitTest * tests if the given wxPoint is within the bounds of this object. * @param posref A wxPoint to test * @return bool - true if a hit, else false */ bool HitTest( const wxPoint& posref ); int Len_Size( void ); // Return the text lenght in internal units }; Loading pcbnew/class_board.cpp +207 −196 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ #include "bitmaps.h" /*****************/ /* Class BOARD: */ /*****************/ Loading Loading @@ -43,6 +42,7 @@ BOARD::BOARD(EDA_BaseStruct * parent, WinEDA_BasePcbFrame * frame): // de determination des contours de zone } /***************/ /* Destructeur */ /***************/ Loading @@ -60,7 +60,6 @@ void BOARD::UnLink( void ) { Pback->Pnext = Pnext; } else /* Le chainage arriere pointe sur la structure "Pere" */ { // Pback-> = Pnext; Loading @@ -68,48 +67,58 @@ void BOARD::UnLink( void ) } /* Modification du chainage avant */ if( Pnext) Pnext->Pback = Pback; if( Pnext ) Pnext->Pback = Pback; Pnext = Pback = NULL; } /* Routines de calcul des nombres de segments pistes et zones */ int BOARD::GetNumSegmTrack( void ) { TRACK* CurTrack = m_Track; int ii = 0; for ( ;CurTrack != NULL; CurTrack = (TRACK*)CurTrack->Pnext ) ii++; for( ; CurTrack != NULL; CurTrack = (TRACK*) CurTrack->Pnext ) ii++; m_NbSegmTrack = ii; return(ii); return ii; } int BOARD::GetNumSegmZone( void ) { TRACK* CurTrack = m_Zone; int ii = 0; for ( ;CurTrack != NULL; CurTrack = (TRACK*)CurTrack->Pnext ) ii++; for( ; CurTrack != NULL; CurTrack = (TRACK*) CurTrack->Pnext ) ii++; m_NbSegmZone = ii; return(ii); return ii; } // retourne le nombre de connexions manquantes int BOARD::GetNumNoconnect( void ) { return(m_NbNoconnect); return m_NbNoconnect; } // retourne le nombre de chevelus int BOARD::GetNumRatsnests( void ) { return(m_NbLinks); return m_NbLinks; } // retourne le nombre de pads a netcode > 0 int BOARD::GetNumNodes( void ) { return(m_NbNodes); return m_NbNodes; } Loading @@ -118,13 +127,13 @@ bool BOARD::ComputeBoundaryBox(void) /***********************************/ /* Determine le rectangle d'encadrement du pcb Ce rectangle englobe les contours pcb, pads , vias et piste Sortie: m_PcbBox retourne: 0 si aucun element utile 1 sinon * Ce rectangle englobe les contours pcb, pads , vias et piste * Sortie: * m_PcbBox * * retourne: * 0 si aucun element utile * 1 sinon */ { int rayon, cx, cy, d, xmin, ymin, xmax, ymax; Loading @@ -140,9 +149,12 @@ TRACK * Track; PtStruct = m_Drawings; for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) { if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; ptr = (DRAWSEGMENT*) PtStruct; d = (ptr->m_Width / 2) + 1; if( ptr->m_Shape == S_CIRCLE ) { cx = ptr->m_Start.x; cy = ptr->m_Start.y; Loading Loading @@ -240,6 +252,5 @@ TRACK * Track; m_BoundaryBox.SetWidth( xmax - xmin ); m_BoundaryBox.SetHeight( ymax - ymin ); return(Has_Items); return Has_Items; } Loading
change_log.txt +9 −1 Original line number Diff line number Diff line Loading @@ -6,10 +6,18 @@ email address. 2007-Aug-05 UPDATE Dick Hollenbeck <dick@softplc.com> ================================================================================ + pcbnew & common Changed the function name of Locate( const wxPoint& ref_pos ) to bool HitTest(..) in both class_text_mod and base_struct. More beautification and commenting. 2007-Aug-04 UPDATE Dick Hollenbeck <dick@softplc.com> ================================================================================ + pcbnew Read-ability formatting, I am playing with a C++ beautifier called uncrustify. Read-ability formatting, I am playing with a C++ beautifier called "uncrustify". I had to patch it and spent 2 days getting it configured. Patch not sent upstream yet. Fixed a bug in "display local ratsnest pad or module": if you had a small Loading
common/base_struct.cpp +560 −518 Original line number Diff line number Diff line Loading @@ -69,8 +69,6 @@ wxT("unknown") }; enum textbox { ID_TEXTBOX_LIST = 8010 }; Loading @@ -94,6 +92,7 @@ EDA_BaseStruct::EDA_BaseStruct(int idType) m_StructType = idType; } /********************************************/ void EDA_BaseStruct::InitVars( void ) /********************************************/ Loading @@ -114,21 +113,25 @@ void EDA_BaseStruct::InitVars(void) /* Gestion de l'etat (status) de la structure (active, deleted..) */ int EDA_BaseStruct::GetState( int type ) { return(m_Status & type); return m_Status & type; } void EDA_BaseStruct::SetState( int type, int state ) { if( state ) m_Status |= type; /* state = ON ou OFF */ else m_Status &= ~type; if( state ) m_Status |= type;/* state = ON ou OFF */ else m_Status &= ~type; } /*********************************************************/ void EDA_BaseStruct::AddToChain( EDA_BaseStruct* laststruct ) /*********************************************************/ /* addition d'une nouvelle struct a la liste chaine, apres la structure laststruct * addition d'une nouvelle struct a la liste chain�, apres la structure laststruct */ { Pnext = laststruct->Pnext; Loading @@ -141,45 +144,53 @@ addition d'une nouvelle struct a la liste chain void EDA_BaseStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, int Color ) /**************************************************************************************/ /* Virtual */ { wxString msg, name; msg.Printf( wxT("EDA_BaseStruct::Draw() error. Method for struct type %d used but not implemented ("), msg.Printf( wxT( "EDA_BaseStruct::Draw() error. Method for struct type %d used but not implemented (" ), m_StructType ); msg += ReturnClassName() + wxT( ")\n" ); printf( CONV_TO_UTF8( msg ) ); } #if 0 /**************************************************************/ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) /**************************************************************/ /* fonction virtuelle de placement: non utilisee en pcbnew (utilisee eeschema) ---- A mieux utiliser (TODO...) * ---- A mieux utiliser (TODO...) */ { } #endif /*********************************************/ wxString EDA_BaseStruct::ReturnClassName( void ) /*********************************************/ /* Used at run time for diags: return the class name of the item, from its .m_StructType value. * from its .m_StructType value. */ { int ii = m_StructType; wxString classname; if ( (ii < 0) || (ii > MAX_STRUCT_TYPE_ID) ) ii = MAX_STRUCT_TYPE_ID; if( (ii < 0) || (ii > MAX_STRUCT_TYPE_ID) ) ii = MAX_STRUCT_TYPE_ID; classname = DrawStructureTypeName[ii]; return classname; } /**********************************************************************************************/ EDA_BaseLineStruct::EDA_BaseLineStruct( EDA_BaseStruct* StructFather, DrawStructureType idtype ) : EDA_BaseStruct( StructFather, idtype ) Loading @@ -191,7 +202,7 @@ EDA_BaseLineStruct::EDA_BaseLineStruct(EDA_BaseStruct * StructFather, DrawStruct /*********************************************************/ /* EDA_TextStruct (classe de base, non utilise seule */ /* EDA_TextStruct (classe de base, non utilis� seule */ /*********************************************************/ EDA_TextStruct::EDA_TextStruct( const wxString& text ) { Loading @@ -207,7 +218,7 @@ EDA_TextStruct::EDA_TextStruct(const wxString & text) m_Text = text; m_ZoomLevelDrawable = 0; /* Niveau de zoom acceptable pour affichage normal */ m_TextDrawings = NULL; /* Pointeur sur le dessin du caractere */ m_TextDrawingsSize = 0; /* taille du tableau point */ m_TextDrawingsSize = 0; /* taille du tableau point�*/ } Loading @@ -220,14 +231,18 @@ EDA_TextStruct::~EDA_TextStruct(void) m_TextDrawingsSize = 0; /* nombre de sommets a dessiner */ } /********************************/ int EDA_TextStruct::Len_Size( void ) /********************************/ // Return the text lenght in internal units { int nbchar = m_Text.Len(); int len; if ( nbchar == 0 ) return 0; if( nbchar == 0 ) return 0; len = ( (10 * m_Size.x ) / 9 ) * nbchar; return len; Loading @@ -235,12 +250,13 @@ int len; /*************************************************/ int EDA_TextStruct::Locate(const wxPoint & posref) bool EDA_TextStruct::HitTest( const wxPoint& posref ) /*************************************************/ /* locate function return: 1 if posref is inside the text area. 0 else. * return: * true if posref is inside the text area. * false else. */ { int dx, dy; Loading @@ -250,33 +266,42 @@ int spot_cX, spot_cY; 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 ; spot_cX = posref.x - m_Pos.x; spot_cY = posref.y - m_Pos.y; RotatePoint( &spot_cX, &spot_cY, -m_Orient ); if( (abs(spot_cX) <= abs(dx) ) && ( abs(spot_cY) <= abs(dy) ) ) return 1; return 0; if( ( abs( spot_cX ) <= abs( dx ) ) && ( abs( spot_cY ) <= abs( dy ) ) ) return true; return false; } /*******************************/ int EDA_TextStruct::Pitch( void ) /*******************************/ /* retourne le pas entre 2 caracteres */ { return ( (10 * m_Size.x ) / 9 ) + m_Width; } /***************************************************************/ void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int color, int draw_mode, int display_mode, int anchor_color ) /***************************************************************/ /* Trace de 1 texte type EDA_TextStruct. offset = Offset de trace (usuellement (0,0) color = couleur du texte draw_mode = GR_OR, GR_XOR.., -1 si mode courant. display_mose = FILAIRE, FILLED ou SKETCH anchor_color = couleur de l'ancre ( -1 si pas d'ancre ). * Trace de 1 texte type EDA_TextStruct. * offset = Offset de trace (usuellement (0,0) * color = couleur du texte * draw_mode = GR_OR, GR_XOR.., -1 si mode courant. * display_mose = FILAIRE, FILLED ou SKETCH * anchor_color = couleur de l'ancre ( -1 si pas d'ancre ). */ { int zoom; Loading @@ -286,13 +311,16 @@ int width; if( m_TextDrawings == NULL ) /* pointeur sur la liste des segments de dessin */ CreateDrawData(); if( m_TextDrawings == NULL) return; if( m_TextDrawings == NULL ) return; zoom = panel->GetZoom(); width = m_Width / zoom; if ( display_mode == FILAIRE ) width = 0; if( display_mode == FILAIRE ) width = 0; /* choix de la couleur du texte : */ if ( draw_mode != -1 ) GRSetDrawMode(DC, draw_mode); if( draw_mode != -1 ) GRSetDrawMode( DC, draw_mode ); /* trace du texte */ if( zoom > m_ZoomLevelDrawable ) Loading @@ -304,7 +332,6 @@ int width; m_TextDrawings[4] + offset.y + m_Pos.y, width, color ); } else { /* trace ancre du texte ? */ Loading @@ -325,7 +352,8 @@ int width; while( ii < m_TextDrawingsSize ) { nbpoints = m_TextDrawings[jj]; if (nbpoints > 50 ) nbpoints = 50; if( nbpoints > 50 ) nbpoints = 50; for( kk = 0, ll = 0; (kk < nbpoints) && (ii < m_TextDrawingsSize); kk++ ) { coord[ll] = m_TextDrawings[ii] + offset.x + m_Pos.x; Loading @@ -333,6 +361,7 @@ int width; coord[ll] = m_TextDrawings[ii] + offset.y + m_Pos.y; ll++; ii++; } jj = ii; ii++; if( width > 2 ) Loading @@ -345,7 +374,8 @@ int width; coord[ll + 2], coord[ll + 3], m_Width, color ); else GRFillCSegm(&panel->m_ClipBox, DC, else GRFillCSegm( &panel->m_ClipBox, DC, coord[ll], coord[ll + 1], coord[ll + 2], coord[ll + 3], m_Width, color ); Loading @@ -353,24 +383,25 @@ int width; } else GRPoly( &panel->m_ClipBox, DC, nbpoints, coord, 0, 0, color, color ); } } } /****************************************/ void EDA_TextStruct::CreateDrawData( void ) /****************************************/ /* Cree le tableau de donnes ncessaire au trace d'un texte (pcb, module..) Met a jour: m_ZoomLevelDrawable Niveau de zoom acceptable pour affichage normal m_TextDrawings Pointeur sur le tableau de donnes m_TextDrawingsSize taille (en int) du tableau Codage dans le tableau: Suite des coord des sommets des polygones a tracer prcd du nombre de sommets nn xx1 yy1 xx2 yy2 .. xxn yyn mm xx1 yy1 xx2 yy2 .. xxm yym les 2 premiers sommets sont le segment symbolisant le texte pour les affichages a trop petite echelle /* Cree le tableau de donn�s n�essaire au trace d'un texte (pcb, module..) * Met a jour: * m_ZoomLevelDrawable Niveau de zoom acceptable pour affichage normal * m_TextDrawings Pointeur sur le tableau de donn�s * m_TextDrawingsSize taille (en int) du tableau * Codage dans le tableau: * Suite des coord des sommets des polygones a tracer pr���du nombre de sommets * nn xx1 yy1 xx2 yy2 .. xxn yyn mm xx1 yy1 xx2 yy2 .. xxm yym * les 2 premiers sommets sont le segment symbolisant le texte pour les * affichages a trop petite echelle */ { int ii, jj, kk, nbchar, nbpoints, AsciiCode, endcar; Loading @@ -392,7 +423,8 @@ int coord_count_max = 1000; m_TextDrawingsSize = 0; /* nombre de segments a dessiner */ nbchar = m_Text.Length(); if ( nbchar == 0 ) return; if( nbchar == 0 ) return; size_h = m_Size.x; size_v = m_Size.y; Loading Loading @@ -443,7 +475,6 @@ int coord_count_max = 1000; break; } } else /* Texte Vertical */ { switch( m_HJustify ) Loading Loading @@ -478,7 +509,7 @@ int coord_count_max = 1000; ox = cX - dx;; oy = cY + dy; /* lorsque les chars sont trop petits pour etre dessines, le texte est symbolise par une barre */ * le texte est symbolise par une barre */ m_ZoomLevelDrawable = m_Size.x / 3; dx = (espacement * nbchar) / 2; dy = size_v / 2; /* Decalage du debut du texte / centre */ Loading @@ -498,11 +529,13 @@ int coord_count_max = 1000; x0 = 0; y0 = 0; AsciiCode = (*ptr) & 255; ptcar = graphic_fonte_shape[AsciiCode]; /* ptcar pointe la description du caractere a dessiner */ * du caractere a dessiner */ for( endcar = FALSE; !endcar; ptcar++ ) { f_cod = *ptcar ; /* get code n de la forme selectionnee */ f_cod = *ptcar; /* get code n de la forme selectionnee */ switch( f_cod ) { case 'X': Loading @@ -525,7 +558,7 @@ int coord_count_max = 1000; case 'D': plume = f_cod; nbpoints = 1; /* 1 point va suivre (origine du trac) */ nbpoints = 1; /* 1 point va suivre (origine du trac� */ break; default: Loading @@ -547,21 +580,27 @@ int coord_count_max = 1000; nbpoints++; break; } } /* end switch */ } /* end boucle for = end trace de 1 caractere */ } /* end switch */ } /* end boucle for = end trace de 1 caractere */ ptr++; ox += espacement; } /* end trace du texte */ } /* end trace du texte */ m_TextDrawings = (int*) realloc( coord, ii * sizeof(int) ); m_TextDrawingsSize = ii; //taille (en int) du tableau } /******************************/ void EDA_Rect::Normalize( void ) /******************************/ // Ensure the height ant width are >= 0 { if( m_Size.y < 0 ) Loading @@ -580,8 +619,9 @@ void EDA_Rect::Normalize(void) /*******************************************/ bool EDA_Rect::Inside( const wxPoint& point ) /*******************************************/ /* Return TRUE if point is in Rect Accept rect size < 0 * Accept rect size < 0 */ { int rel_posx = point.x - m_Pos.x; Loading @@ -597,12 +637,13 @@ wxSize size = m_Size; { size.y = -size.y; rel_posy += size.y; } return ( (rel_posx >= 0) && (rel_posy >= 0) return (rel_posx >= 0) && (rel_posy >= 0) && ( rel_posy <= size.y) && ( rel_posx <= size.x) ); ; } /**************************************************/ EDA_Rect& EDA_Rect::Inflate( wxCoord dx, wxCoord dy ) /**************************************************/ Loading Loading @@ -639,16 +680,15 @@ EDA_Rect& EDA_Rect::Inflate(wxCoord dx, wxCoord dy) } /**************************/ /* class DrawPickedStruct */ /**************************/ /* This class has only one useful member: .m_PickedStruct, used as a link. It does not describe really an item. It is used to create a linked list of selected items (in block selection). Each DrawPickedStruct item has is member: .m_PickedStruct pointing the real selected item * It does not describe really an item. * It is used to create a linked list of selected items (in block selection). * Each DrawPickedStruct item has is member: .m_PickedStruct pointing the * real selected item */ /*******************************************************************/ Loading @@ -659,6 +699,7 @@ DrawPickedStruct::DrawPickedStruct(EDA_BaseStruct *pickedstruct ) : m_PickedStruct = pickedstruct; } DrawPickedStruct::~DrawPickedStruct( void ) { } Loading @@ -667,8 +708,9 @@ DrawPickedStruct::~DrawPickedStruct(void) /*********************************************/ void DrawPickedStruct::DeleteWrapperList( void ) /*********************************************/ /* Delete this item all the items of the linked list Free the wrapper, but DOES NOT delete the picked items linked by .m_PickedStruct * Free the wrapper, but DOES NOT delete the picked items linked by .m_PickedStruct */ { DrawPickedStruct* wrapp_struct, * next_struct; Loading
common/trigo.cpp +173 −142 Original line number Diff line number Diff line Loading @@ -12,63 +12,77 @@ /***********************************/ int ArcTangente( int dy, int dx ) /***********************************/ /* Retourne l'arc tangente en 0.1 degres du vecteur de coord dx, dy entre -1800 et 1800 Analogue a atan2 ( mais plus rapide pour les calculs si l'angle est souvent 0, -1800, ou +- 900 * entre -1800 et 1800 * Analogue a atan2 ( mais plus rapide pour les calculs si * l'angle est souvent 0, -1800, ou +- 900 */ { double fangle; if( dy == 0 ) { if(dx >= 0 ) return(0); else return(-1800); if( dx >= 0 ) return 0; else return -1800; } if( dx == 0 ) { if(dy >= 0 ) return(900); else return(-900); if( dy >= 0 ) return 900; else return -900; } if( dx == dy ) { if(dx >= 0) return(450); else return(-1800+450); if( dx >= 0 ) return 450; else return -1800 + 450; } if( dx == -dy ) { if(dx >= 0) return(-450); else return(1800-450); if( dx >= 0 ) return -450; else return 1800 - 450; } fangle = atan2( (double) dy, (double) dx ) / M_PI * 1800; return( (int) round(fangle) ); return (int) round( fangle ); } /*********************************************/ void RotatePoint( int* pX, int* pY, int angle ) /*********************************************/ /* Fonction surchargee! calcule les nouvelles coord du point de coord pX, pY, pour une rotation de centre 0, 0, et d'angle angle ( en 1/10 degre) * Fonction surchargee! * calcule les nouvelles coord du point de coord pX, pY, * pour une rotation de centre 0, 0, et d'angle angle ( en 1/10 degre) */ { float fpx, fpy; int tmp; while (angle < 0) angle += 3600; while (angle >= 3600) angle -= 3600; while( angle < 0 ) angle += 3600; while( angle >= 3600 ) angle -= 3600; if (angle == 0) return; if( angle == 0 ) return; /* Calcul des coord : coord: xrot = y*sin + x*cos yrot = y*cos - x*sin * coord: xrot = y*sin + x*cos * yrot = y*cos - x*sin */ if( angle == 900 ) /* sin = 1, cos = 0 */ { Loading @@ -76,25 +90,24 @@ int tmp; *pX = *pY; *pY = -tmp; } else if( angle == 1800 ) /* sin = 0, cos = -1 */ { *pX = -*pX; *pY = -*pY; } else if( angle == 2700 ) /* sin = -1, cos = 0 */ { tmp = *pX; *pX = -*pY; *pY = tmp; } else { fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]); fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[angle]); *pX = (int)round(fpx); *pY = (int)round(fpy); *pX = (int) round( fpx ); *pY = (int) round( fpy ); } } Loading @@ -102,32 +115,40 @@ int tmp; /************************************************************/ void RotatePoint( int* pX, int* pY, int cx, int cy, int angle ) /*************************************************************/ /* Fonction surchargee! calcule les nouvelles coord du point de coord pX, pY, pour une rotation de centre cx, cy, et d'angle angle ( en 1/10 degre) * Fonction surchargee! * calcule les nouvelles coord du point de coord pX, pY, * pour une rotation de centre cx, cy, et d'angle angle ( en 1/10 degre) */ { int ox, oy; ox = *pX - cx; oy = *pY - cy; ox = *pX - cx; oy = *pY - cy; RotatePoint( &ox, &oy, angle ); *pX = ox + cx; *pY = oy + cy; } /*****************************************************************/ void RotatePoint( wxPoint* point, const wxPoint& centre, int angle ) /*****************************************************************/ /* Fonction surchargee! calcule les nouvelles coord du point point, pour une rotation de centre centre, et d'angle angle ( en 1/10 degre) * Fonction surchargee! * calcule les nouvelles coord du point point, * pour une rotation de centre centre, et d'angle angle ( en 1/10 degre) */ { int ox, oy; ox = point->x - centre.x; oy = point->y - centre.y; ox = point->x - centre.x; oy = point->y - centre.y; RotatePoint( &ox, &oy, angle ); point->x = ox + centre.x; point->y = oy + centre.y; Loading @@ -140,8 +161,11 @@ void RotatePoint(double *pX, double *pY, double cx, double cy, int angle) { double ox, oy; ox = *pX - cx; oy = *pY - cy; ox = *pX - cx; oy = *pY - cy; RotatePoint( &ox, &oy, angle ); *pX = ox + cx; *pY = oy + cy; } Loading @@ -150,39 +174,46 @@ double ox, oy; /*************************************************/ void RotatePoint( double* pX, double* pY, int angle ) /*************************************************/ /* Calcul des coord : coord: xrot = y*sin + x*cos yrot = y*cos - x*sin * coord: xrot = y*sin + x*cos * yrot = y*cos - x*sin */ { double tmp; while (angle < 0) angle += 3600; while (angle >= 3600) angle -= 3600; if (angle == 0) return; while( angle < 0 ) angle += 3600; while( angle >= 3600 ) angle -= 3600; if( angle == 0 ) return; if( angle == 900 ) /* sin = 1, cos = 0 */ { tmp = *pX; *pX = *pY; *pY = -tmp; } else if( angle == 1800 ) /* sin = 0, cos = -1 */ { *pX = -*pX; *pY = -*pY; } else if( angle == 2700 ) /* sin = -1, cos = 0 */ { tmp = *pX; *pX = -*pY; *pY = tmp; } else { double fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]); double fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[angle]); *pX = fpx; *pY = fpy; *pX = fpx; *pY = fpy; } }
include/base_struct.h +8 −2 Original line number Diff line number Diff line Loading @@ -179,8 +179,14 @@ public: const wxPoint& offset, int color, int draw_mode, int display_mode = FILAIRE, int anchor_color = -1 ); /* locate functions */ int Locate( const wxPoint& posref ); /** * Function HitTest * tests if the given wxPoint is within the bounds of this object. * @param posref A wxPoint to test * @return bool - true if a hit, else false */ bool HitTest( const wxPoint& posref ); int Len_Size( void ); // Return the text lenght in internal units }; Loading
pcbnew/class_board.cpp +207 −196 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ #include "bitmaps.h" /*****************/ /* Class BOARD: */ /*****************/ Loading Loading @@ -43,6 +42,7 @@ BOARD::BOARD(EDA_BaseStruct * parent, WinEDA_BasePcbFrame * frame): // de determination des contours de zone } /***************/ /* Destructeur */ /***************/ Loading @@ -60,7 +60,6 @@ void BOARD::UnLink( void ) { Pback->Pnext = Pnext; } else /* Le chainage arriere pointe sur la structure "Pere" */ { // Pback-> = Pnext; Loading @@ -68,48 +67,58 @@ void BOARD::UnLink( void ) } /* Modification du chainage avant */ if( Pnext) Pnext->Pback = Pback; if( Pnext ) Pnext->Pback = Pback; Pnext = Pback = NULL; } /* Routines de calcul des nombres de segments pistes et zones */ int BOARD::GetNumSegmTrack( void ) { TRACK* CurTrack = m_Track; int ii = 0; for ( ;CurTrack != NULL; CurTrack = (TRACK*)CurTrack->Pnext ) ii++; for( ; CurTrack != NULL; CurTrack = (TRACK*) CurTrack->Pnext ) ii++; m_NbSegmTrack = ii; return(ii); return ii; } int BOARD::GetNumSegmZone( void ) { TRACK* CurTrack = m_Zone; int ii = 0; for ( ;CurTrack != NULL; CurTrack = (TRACK*)CurTrack->Pnext ) ii++; for( ; CurTrack != NULL; CurTrack = (TRACK*) CurTrack->Pnext ) ii++; m_NbSegmZone = ii; return(ii); return ii; } // retourne le nombre de connexions manquantes int BOARD::GetNumNoconnect( void ) { return(m_NbNoconnect); return m_NbNoconnect; } // retourne le nombre de chevelus int BOARD::GetNumRatsnests( void ) { return(m_NbLinks); return m_NbLinks; } // retourne le nombre de pads a netcode > 0 int BOARD::GetNumNodes( void ) { return(m_NbNodes); return m_NbNodes; } Loading @@ -118,13 +127,13 @@ bool BOARD::ComputeBoundaryBox(void) /***********************************/ /* Determine le rectangle d'encadrement du pcb Ce rectangle englobe les contours pcb, pads , vias et piste Sortie: m_PcbBox retourne: 0 si aucun element utile 1 sinon * Ce rectangle englobe les contours pcb, pads , vias et piste * Sortie: * m_PcbBox * * retourne: * 0 si aucun element utile * 1 sinon */ { int rayon, cx, cy, d, xmin, ymin, xmax, ymax; Loading @@ -140,9 +149,12 @@ TRACK * Track; PtStruct = m_Drawings; for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext ) { if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue; ptr = (DRAWSEGMENT*) PtStruct; d = (ptr->m_Width / 2) + 1; if( ptr->m_Shape == S_CIRCLE ) { cx = ptr->m_Start.x; cy = ptr->m_Start.y; Loading Loading @@ -240,6 +252,5 @@ TRACK * Track; m_BoundaryBox.SetWidth( xmax - xmin ); m_BoundaryBox.SetHeight( ymax - ymin ); return(Has_Items); return Has_Items; }