From f8f384384a914b063c7174b8a15f0b564948af8e Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Tue, 7 Aug 2007 06:21:19 +0000 Subject: [PATCH] search and debug infrastructure, beautification --- common/base_struct.cpp | 10 +- include/base_struct.h | 25 +- include/drawpanel_wxstruct.h | 423 +++++----- include/pcbstruct.h | 12 + pcbnew/class_board.cpp | 6 +- pcbnew/class_edge_mod.cpp | 2 +- pcbnew/class_edge_mod.h | 11 + pcbnew/class_module.cpp | 32 +- pcbnew/class_module.h | 28 +- pcbnew/class_pad.cpp | 1438 +++++++++++++++++++--------------- pcbnew/class_pad.h | 26 +- pcbnew/class_pcb_text.cpp | 204 +++-- pcbnew/class_pcb_text.h | 22 + pcbnew/class_text_mod.cpp | 4 +- pcbnew/class_text_mod.h | 11 +- pcbnew/locate.cpp | 9 +- 16 files changed, 1294 insertions(+), 969 deletions(-) diff --git a/common/base_struct.cpp b/common/base_struct.cpp index 1dee27f22e..4cb3698664 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -171,7 +171,7 @@ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC ) /*********************************************/ -wxString EDA_BaseStruct::ReturnClassName( void ) +wxString EDA_BaseStruct::ReturnClassName() const /*********************************************/ /* Used at run time for diags: return the class name of the item, @@ -202,7 +202,7 @@ wxString EDA_BaseStruct::ReturnClassName( void ) void EDA_BaseStruct::Show( int nestLevel, std::ostream& os ) { // for now, make it look like XML: - NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << ">\n"; + NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n"; EDA_BaseStruct* kid = m_Son; for( ; kid; kid = kid->Pnext ) @@ -210,7 +210,7 @@ void EDA_BaseStruct::Show( int nestLevel, std::ostream& os ) kid->Show( nestLevel+1, os ); } - NestedSpace( nestLevel, os ) << "\n"; + NestedSpace( nestLevel, os ) << "\n"; } @@ -236,7 +236,7 @@ SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart, EDA_BaseStruct* p = listStart; for( ; p; p = p->Pnext ) { - if( SEARCH_QUIT == p->Traverse( inspector, testData, scanTypes ) ) + if( SEARCH_QUIT == p->Visit( inspector, testData, scanTypes ) ) return SEARCH_QUIT; } @@ -245,7 +245,7 @@ SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart, // see base_struct.h -SEARCH_RESULT EDA_BaseStruct::Traverse( INSPECTOR* inspector, const void* testData, +SEARCH_RESULT EDA_BaseStruct::Visit( INSPECTOR* inspector, const void* testData, const KICAD_T scanTypes[] ) { KICAD_T stype; diff --git a/include/base_struct.h b/include/base_struct.h index b12392448e..e211a4ae1c 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -164,7 +164,7 @@ public: m_Status = new_status; } - wxString ReturnClassName( void ); + wxString ReturnClassName() const; /* addition d'une nouvelle struct a la liste chain� */ void AddToChain( EDA_BaseStruct* laststruct ); @@ -179,6 +179,23 @@ public: int Color = -1 ); #if defined(DEBUG) + + /** + * Function GetClass + * returns the class name. + * @return wxString + */ + virtual wxString GetClass() const + { + // ReturnClassName() is too hard to maintain, coordinating the array + // with the enum. It would be nice to migrate to virtual GetClass() + // away from ReturnClassName(). Over time, derived classes should + // simply return a wxString from their virtual GetClass() function. + // Some classes do that now. + return ReturnClassName(); + } + + /** * Function Show * is used to output the object tree, currently for debugging only. @@ -221,7 +238,7 @@ public: /** - * Function Traverse + * Function Visit * should be re-implemented for each derived class in order to handle * all the types given by its member data. Implementations should call * inspector->Inspect() on types in scanTypes[], and may use IterateForward() @@ -231,9 +248,9 @@ public: * @param scanTypes Which KICAD_T types are of interest and the order * is significant too, terminated by EOT. * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, - * else SCAN_CONTINUE; + * else SCAN_CONTINUE, and determined by the inspector. */ - virtual SEARCH_RESULT Traverse( INSPECTOR* inspector, const void* testData, + virtual SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData, const KICAD_T scanTypes[] ); diff --git a/include/drawpanel_wxstruct.h b/include/drawpanel_wxstruct.h index 583978f005..a70f6147b0 100644 --- a/include/drawpanel_wxstruct.h +++ b/include/drawpanel_wxstruct.h @@ -1,11 +1,11 @@ - /****************************************************/ - /* drawpanel_wxstruct.h: */ - /* descriptions des principales classes utilisees: */ - /* ici classe: "WinEDA_DrawPanel", "BASE_SCREEN" */ - /*****************************************************/ +/****************************************************/ +/* drawpanel_wxstruct.h: */ +/* descriptions des principales classes utilisees: */ +/* ici classe: "WinEDA_DrawPanel", "BASE_SCREEN" */ +/*****************************************************/ /* Doit etre inclus dans "wxstruch.h" -*/ + */ #ifndef PANEL_WXSTRUCT_H #define PANEL_WXSTRUCT_H @@ -17,258 +17,277 @@ #include "colors.h" - /****************************************************/ - /* classe representant un ecran graphique de dessin */ - /****************************************************/ +/****************************************************/ +/* classe representant un ecran graphique de dessin */ +/****************************************************/ -class WinEDA_DrawPanel: public EDA_DRAW_PANEL +class WinEDA_DrawPanel : public EDA_DRAW_PANEL { public: - int m_Ident; - WinEDA_DrawFrame * m_Parent; - EDA_Rect m_ClipBox; /* position et taille de la fenetre de trace - pour les "RePaint" d'ecran */ - wxPoint m_CursorStartPos; // utile dans controles du mouvement curseur - int m_Scroll_unit; // Valeur de l'unite de scroll en pixels pour les barres de scroll - int m_ScrollButt_unit; // Valeur de l'unite de scroll en pixels pour les boutons de scroll + int m_Ident; + WinEDA_DrawFrame* m_Parent; + EDA_Rect m_ClipBox; /* position et taille de la fenetre de trace + * pour les "RePaint" d'ecran */ + wxPoint m_CursorStartPos; // utile dans controles du mouvement curseur + int m_Scroll_unit; // Valeur de l'unite de scroll en pixels pour les barres de scroll + int m_ScrollButt_unit; // Valeur de l'unite de scroll en pixels pour les boutons de scroll - bool m_AbortRequest; // Flag d'arret de commandes longues - bool m_AbortEnable; // TRUE si menu ou bouton Abort doit etre affiche + bool m_AbortRequest; // Flag d'arret de commandes longues + bool m_AbortEnable; // TRUE si menu ou bouton Abort doit etre affiche - bool m_AutoPAN_Enable; // TRUE pour autoriser auto pan (autorisation générale) - bool m_AutoPAN_Request; // TRUE pour auto pan (lorsque auto pan nécessaire) + bool m_AutoPAN_Enable; // TRUE pour autoriser auto pan (autorisation g��ale) + bool m_AutoPAN_Request; // TRUE pour auto pan (lorsque auto pan n�essaire) - bool m_IgnoreMouseEvents; // TRUE pour ne par traiter les evenements souris + bool m_IgnoreMouseEvents; // TRUE pour ne par traiter les evenements souris - bool m_Block_Enable; // TRUE pour autoriser Bloc Commandes (autorisation générale) - int m_CanStartBlock; // >= 0 (ou >= n) si un bloc peut demarrer - // (filtrage des commandes de debut de bloc ) - int m_PanelDefaultCursor; // Current mouse cursor default shape id for this window - int m_PanelCursor; // Current mouse cursor shape id for this window - int m_CursorLevel; // Index for cursor redraw in XOR mode + bool m_Block_Enable; // TRUE pour autoriser Bloc Commandes (autorisation g��ale) + int m_CanStartBlock; // >= 0 (ou >= n) si un bloc peut demarrer + // (filtrage des commandes de debut de bloc ) + int m_PanelDefaultCursor; // Current mouse cursor default shape id for this window + int m_PanelCursor; // Current mouse cursor shape id for this window + int m_CursorLevel; // Index for cursor redraw in XOR mode - /* Cursor management (used in editing functions) */ - void (*ManageCurseur)(WinEDA_DrawPanel * panel, wxDC * DC, bool erase); /* Fonction d'affichage sur deplacement souris - si erase : effacement ancien affichage */ - void (*ForceCloseManageCurseur)(WinEDA_DrawPanel * panel, wxDC * DC); /* Fonction de fermeture forcée - de la fonction ManageCurseur */ + /* Cursor management (used in editing functions) */ + void (*ManageCurseur)(WinEDA_DrawPanel * panel, wxDC * DC, bool erase);/* Fonction d'affichage sur deplacement souris + * si erase : effacement ancien affichage */ + void (*ForceCloseManageCurseur)(WinEDA_DrawPanel * panel, wxDC * DC);/* Fonction de fermeture forc� + * de la fonction ManageCurseur */ public: - // Constructor and destructor - WinEDA_DrawPanel(WinEDA_DrawFrame *parent, int id, const wxPoint& pos, const wxSize& size); - ~WinEDA_DrawPanel(void){} - /****************************/ - BASE_SCREEN * GetScreen(void) { return m_Parent->m_CurrentScreen; } - void PrepareGraphicContext(wxDC * DC); - wxPoint CalcAbsolutePosition(const wxPoint & rel_pos); - bool IsPointOnDisplay(wxPoint ref_pos); - void OnPaint(wxPaintEvent & event); - void OnSize(wxSizeEvent & event); - void SetBoundaryBox(void); - void ReDraw(wxDC * DC, bool erasebg = TRUE); - void PrintPage(wxDC * DC, bool Print_Sheet_Ref, int PrintMask); - void DrawBackGround(wxDC * DC); - void m_Draw_Auxiliary_Axis(wxDC * DC, int drawmode); - void OnEraseBackground(wxEraseEvent& event); - void OnActivate(wxActivateEvent& event); + // Constructor and destructor + WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id, const wxPoint& pos, const wxSize& size ); + ~WinEDA_DrawPanel( void ) { } + /****************************/ + BASE_SCREEN* GetScreen( void ) { return m_Parent->m_CurrentScreen; } - /* Mouse and keys events */ - void OnMouseEvent(wxMouseEvent& event); - void OnMouseLeaving(wxMouseEvent& event); - void OnKeyEvent(wxKeyEvent& event); - /*************************/ + void PrepareGraphicContext( wxDC* DC ); + wxPoint CalcAbsolutePosition( const wxPoint& rel_pos ); + bool IsPointOnDisplay( wxPoint ref_pos ); + void OnPaint( wxPaintEvent& event ); + void OnSize( wxSizeEvent& event ); + void SetBoundaryBox( void ); + void ReDraw( wxDC* DC, bool erasebg = TRUE ); + void PrintPage( wxDC* DC, bool Print_Sheet_Ref, int PrintMask ); + void DrawBackGround( wxDC* DC ); + void m_Draw_Auxiliary_Axis( wxDC* DC, int drawmode ); + void OnEraseBackground( wxEraseEvent& event ); + void OnActivate( wxActivateEvent& event ); - void EraseScreen(wxDC * DC); - void OnScrollWin( wxCommandEvent &event ); - void OnScroll( wxScrollWinEvent &event ); + /* Mouse and keys events */ + void OnMouseEvent( wxMouseEvent& event ); + void OnMouseLeaving( wxMouseEvent& event ); + void OnKeyEvent( wxKeyEvent& event ); - void SetZoom(int mode); - int GetZoom(void); - void SetGrid(const wxSize & size); - wxSize GetGrid(void); + /*************************/ - void AddMenuZoom( wxMenu * MasterMenu ); - void OnRightClick(wxMouseEvent& event); - void Process_Popup_Zoom( wxCommandEvent &event ); - void Process_Special_Functions(wxCommandEvent& event); - wxPoint CursorRealPosition(const wxPoint & ScreenPos); - wxPoint CursorScreenPosition(void); - wxPoint GetScreenCenterRealPosition(void); - void MouseToCursorSchema(void); - void MouseTo(const wxPoint & Mouse); + void EraseScreen( wxDC* DC ); + void OnScrollWin( wxCommandEvent& event ); + void OnScroll( wxScrollWinEvent& event ); - /* Cursor functions */ - void Trace_Curseur(wxDC * DC, int color = WHITE); // Draw the user cursor (grid cursor) - void CursorOff(wxDC * DC); // remove the grid cursor from the display - void CursorOn(wxDC * DC); // display the grid cursor + void SetZoom( int mode ); + int GetZoom( void ); + void SetGrid( const wxSize& size ); + wxSize GetGrid( void ); - DECLARE_EVENT_TABLE() + void AddMenuZoom( wxMenu* MasterMenu ); + void OnRightClick( wxMouseEvent& event ); + void Process_Popup_Zoom( wxCommandEvent& event ); + void Process_Special_Functions( wxCommandEvent& event ); + wxPoint CursorRealPosition( const wxPoint& ScreenPos ); + wxPoint CursorScreenPosition( void ); + wxPoint GetScreenCenterRealPosition( void ); + void MouseToCursorSchema( void ); + void MouseTo( const wxPoint& Mouse ); + + /* Cursor functions */ + void Trace_Curseur( wxDC* DC, int color = WHITE ); // Draw the user cursor (grid cursor) + void CursorOff( wxDC* DC ); // remove the grid cursor from the display + void CursorOn( wxDC* DC ); // display the grid cursor + + DECLARE_EVENT_TABLE() }; /**************************/ /* class DrawBlockStruct */ /**************************/ /* Definition d'un block pour les fonctions sur block (block move, ..) */ -typedef enum { /* definition de l'etat du block */ - STATE_NO_BLOCK, /* Block non initialise */ - STATE_BLOCK_INIT, /* Block initialise: 1er point defini */ - STATE_BLOCK_END, /* Block initialise: 2eme point defini */ - STATE_BLOCK_MOVE, /* Block en deplacement */ - STATE_BLOCK_STOP /* Block fixe (fin de deplacement) */ - } BlockState; +typedef enum { /* definition de l'etat du block */ + STATE_NO_BLOCK, /* Block non initialise */ + STATE_BLOCK_INIT, /* Block initialise: 1er point defini */ + STATE_BLOCK_END, /* Block initialise: 2eme point defini */ + STATE_BLOCK_MOVE, /* Block en deplacement */ + STATE_BLOCK_STOP /* Block fixe (fin de deplacement) */ + +} BlockState; /* codes des differentes commandes sur block: */ typedef enum { - BLOCK_IDLE, - BLOCK_MOVE, - BLOCK_COPY, - BLOCK_SAVE, - BLOCK_DELETE, - BLOCK_PASTE, - BLOCK_DRAG, - BLOCK_ROTATE, - BLOCK_INVERT, - BLOCK_ZOOM, - BLOCK_ABORT, - BLOCK_PRESELECT_MOVE, - BLOCK_SELECT_ITEMS_ONLY, - BLOCK_MIRROR_X, - BLOCK_MIRROR_Y + BLOCK_IDLE, + BLOCK_MOVE, + BLOCK_COPY, + BLOCK_SAVE, + BLOCK_DELETE, + BLOCK_PASTE, + BLOCK_DRAG, + BLOCK_ROTATE, + BLOCK_INVERT, + BLOCK_ZOOM, + BLOCK_ABORT, + BLOCK_PRESELECT_MOVE, + BLOCK_SELECT_ITEMS_ONLY, + BLOCK_MIRROR_X, + BLOCK_MIRROR_Y + } CmdBlockType; -class DrawBlockStruct: public EDA_BaseStruct, public EDA_Rect +class DrawBlockStruct : public EDA_BaseStruct + , public EDA_Rect { public: - BlockState m_State; /* Etat (enum BlockState) du block */ - CmdBlockType m_Command; /* Type (enum CmdBlockType) d'operation */ - EDA_BaseStruct *m_BlockDrawStruct; /* pointeur sur la structure - selectionnee dans le bloc */ - int m_Color; /* Block Color */ - wxPoint m_MoveVector; /* Move distance in move, drag, copy ... command */ - wxPoint m_BlockLastCursorPosition; /* Last Mouse position in block command - = last cursor position in move commands - = 0,0 in block paste */ + BlockState m_State; /* Etat (enum BlockState) du block */ + CmdBlockType m_Command; /* Type (enum CmdBlockType) d'operation */ + EDA_BaseStruct* m_BlockDrawStruct; /* pointeur sur la structure + * selectionnee dans le bloc */ + int m_Color; /* Block Color */ + wxPoint m_MoveVector; /* Move distance in move, drag, copy ... command */ + wxPoint m_BlockLastCursorPosition;/* Last Mouse position in block command + * = last cursor position in move commands + * = 0,0 in block paste */ public: - DrawBlockStruct(void); - ~DrawBlockStruct(void); - void SetMessageBlock(WinEDA_DrawFrame * frame); - void Draw(WinEDA_DrawPanel * panel, wxDC * DC); + DrawBlockStruct( void ); + ~DrawBlockStruct( void ); + void SetMessageBlock( WinEDA_DrawFrame* frame ); + void Draw( WinEDA_DrawPanel* panel, wxDC* DC ); }; /*******************************************************************/ /* Class to handle how to draw a screen (a board, a schematic ...) */ /*******************************************************************/ -class BASE_SCREEN: public EDA_BaseStruct +class BASE_SCREEN : public EDA_BaseStruct { public: - int m_Type; /* indicateur: type d'ecran */ - wxPoint m_DrawOrg; /* offsets pour tracer le circuit sur l'ecran */ - wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */ - wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */ - wxPoint m_MousePositionInPixels; /* Mouse cursor coordinate (off grid) in pixels. */ - wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) in user units. - (coordinates from last reset position)*/ - wxPoint m_ScrollbarPos; // Position effective des Curseurs de scroll - wxSize m_ScrollbarNumber; /* Valeur effective des Nombres de Scrool - c.a.d taille en unites de scroll de la surface totale affichable */ - wxPoint m_StartVisu; // Coord absolues du 1er pixel visualisé a l'ecran (en nombre de pixels) - wxSize m_SizeVisu; /* taille en pixels de l'ecran (fenetre de visu - Utile pour recadrer les affichages lors de la - navigation dans la hierarchie */ - bool m_Center; // TRUE: coord algebriques, FALSE: coord >= 0 - bool m_FirstRedraw; + int m_Type; /* indicateur: type d'ecran */ + wxPoint m_DrawOrg; /* offsets pour tracer le circuit sur l'ecran */ + wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */ + wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */ + wxPoint m_MousePositionInPixels; /* Mouse cursor coordinate (off grid) in pixels. */ + wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) in user units. + * (coordinates from last reset position)*/ + wxPoint m_ScrollbarPos; // Position effective des Curseurs de scroll + wxSize m_ScrollbarNumber;/* Valeur effective des Nombres de Scrool + * c.a.d taille en unites de scroll de la surface totale affichable */ + wxPoint m_StartVisu; // Coord absolues du 1er pixel visualis�a l'ecran (en nombre de pixels) + wxSize m_SizeVisu; /* taille en pixels de l'ecran (fenetre de visu + * Utile pour recadrer les affichages lors de la + * navigation dans la hierarchie */ + bool m_Center; // TRUE: coord algebriques, FALSE: coord >= 0 + bool m_FirstRedraw; - /* Gestion des editions */ - EDA_BaseStruct *EEDrawList; /* Object list (main data) for schematic */ - EDA_BaseStruct * m_UndoList; /* Object list for the undo command (old data) */ - EDA_BaseStruct * m_RedoList; /* Object list for the redo command (old data) */ - int m_UndoRedoCountMax; /* undo/Redo command Max depth */ - EDA_BaseStruct * m_CurrentItem; /* Current selected object */ + /* Gestion des editions */ + EDA_BaseStruct* EEDrawList; /* Object list (main data) for schematic */ + EDA_BaseStruct* m_UndoList; /* Object list for the undo command (old data) */ + EDA_BaseStruct* m_RedoList; /* Object list for the redo command (old data) */ + int m_UndoRedoCountMax; /* undo/Redo command Max depth */ + EDA_BaseStruct* m_CurrentItem; /* Current selected object */ - /* block control */ - DrawBlockStruct BlockLocate; /* Bock description for block commands */ + /* block control */ + DrawBlockStruct BlockLocate; /* Bock description for block commands */ - /* Page description */ - Ki_PageDescr * m_CurrentSheet; - int m_SheetNumber, m_NumberOfSheet; /* gestion hierarchie: numero de sousfeuille - et nombre de feuilles. Root: SheetNumber = 1 */ - wxString m_FileName; - wxString m_Title; /* titre de la feuille */ - wxString m_Date; /* date de mise a jour */ - wxString m_Revision; /* code de revision */ - wxString m_Company; /* nom du proprietaire */ - wxString m_Commentaire1; - wxString m_Commentaire2; - wxString m_Commentaire3; - wxString m_Commentaire4; + /* Page description */ + Ki_PageDescr* m_CurrentSheet; + int m_SheetNumber, m_NumberOfSheet;/* gestion hierarchie: numero de sousfeuille + * et nombre de feuilles. Root: SheetNumber = 1 */ + wxString m_FileName; + wxString m_Title; /* titre de la feuille */ + wxString m_Date; /* date de mise a jour */ + wxString m_Revision; /* code de revision */ + wxString m_Company; /* nom du proprietaire */ + wxString m_Commentaire1; + wxString m_Commentaire2; + wxString m_Commentaire3; + wxString m_Commentaire4; private: - /* indicateurs divers */ - char m_FlagRefreshReq; /* indique que l'ecran doit redessine */ - char m_FlagModified; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde - char m_FlagSave; // indique sauvegarde auto faite + /* indicateurs divers */ + char m_FlagRefreshReq; /* indique que l'ecran doit redessine */ + char m_FlagModified; // indique modif du PCB,utilise pour eviter une sortie sans sauvegarde + char m_FlagSave; // indique sauvegarde auto faite - /* Valeurs du pas de grille et du zoom */ + /* Valeurs du pas de grille et du zoom */ public: - wxSize m_Grid ; /* pas de la grille (peut differer en X et Y) */ - wxSize * m_GridList; /* Liste des valeurs standard de grille */ - wxRealPoint m_UserGrid; /* pas de la grille utilisateur */ - int m_UserGridUnit; /* unité grille utilisateur (0 = inch, 1 = mm */ - int m_Diviseur_Grille ; - bool m_UserGridIsON; - int * m_ZoomList; /* Liste des coefficients standard de zoom */ - int m_Zoom ; /* coeff de ZOOM */ + wxSize m_Grid; /* pas de la grille (peut differer en X et Y) */ + wxSize* m_GridList; /* Liste des valeurs standard de grille */ + wxRealPoint m_UserGrid; /* pas de la grille utilisateur */ + int m_UserGridUnit; /* unit�grille utilisateur (0 = inch, 1 = mm */ + int m_Diviseur_Grille; + bool m_UserGridIsON; + int* m_ZoomList; /* Liste des coefficients standard de zoom */ + int m_Zoom; /* coeff de ZOOM */ public: - BASE_SCREEN(int idscreen); - ~BASE_SCREEN(void); + BASE_SCREEN( int idscreen ); + ~BASE_SCREEN( void ); - void InitDatas(void); /* Inits completes des variables */ - wxSize ReturnPageSize(void); - int GetInternalUnits(void); + void InitDatas( void );/* Inits completes des variables */ + wxSize ReturnPageSize( void ); + int GetInternalUnits( void ); - wxPoint CursorRealPosition(const wxPoint & ScreenPos); + wxPoint CursorRealPosition( const wxPoint& ScreenPos ); - /* general Undo/Redo command control */ - virtual void ClearUndoRedoList(void); - virtual void AddItemToUndoList(EDA_BaseStruct * item); - virtual void AddItemToRedoList(EDA_BaseStruct * item); - virtual EDA_BaseStruct * GetItemFromUndoList(void); - virtual EDA_BaseStruct * GetItemFromRedoList(void); + /* general Undo/Redo command control */ + virtual void ClearUndoRedoList( void ); + virtual void AddItemToUndoList( EDA_BaseStruct* item ); + virtual void AddItemToRedoList( EDA_BaseStruct* item ); + virtual EDA_BaseStruct* GetItemFromUndoList( void ); + virtual EDA_BaseStruct* GetItemFromRedoList( void ); - /* Manipulation des flags */ - void SetRefreshReq(void) { m_FlagRefreshReq = 1; } - void ClrRefreshReq(void) { m_FlagRefreshReq = 0; } - void SetModify(void) { m_FlagModified = 1; m_FlagSave = 0; } - void ClrModify(void) { m_FlagModified = 0; m_FlagSave = 1; } - void SetSave(void) { m_FlagSave = 1; } - void ClrSave(void) { m_FlagSave = 0; } - int IsModify(void) { return (m_FlagModified & 1); } - int IsRefreshReq(void) { return (m_FlagRefreshReq & 1); } - int IsSave(void) { return (m_FlagSave & 1); } + /* Manipulation des flags */ + void SetRefreshReq( void ) { m_FlagRefreshReq = 1; } + void ClrRefreshReq( void ) { m_FlagRefreshReq = 0; } + void SetModify( void ) { m_FlagModified = 1; m_FlagSave = 0; } + void ClrModify( void ) { m_FlagModified = 0; m_FlagSave = 1; } + void SetSave( void ) { m_FlagSave = 1; } + void ClrSave( void ) { m_FlagSave = 0; } + int IsModify( void ) { return m_FlagModified & 1; } + int IsRefreshReq( void ) { return m_FlagRefreshReq & 1; } + int IsSave( void ) { return m_FlagSave & 1; } - /* fonctions relatives au zoom */ - int GetZoom(void); /* retourne le coeff de zoom */ - void SetZoom(int coeff) ; /* ajuste le coeff de zoom a coeff */ - void SetZoomList(int * zoomlist); /* init liste des zoom (NULL terminated) */ - void SetNextZoom(void); /* ajuste le prochain coeff de zoom */ - void SetPreviousZoom(void); /* ajuste le precedent coeff de zoom */ - void SetFirstZoom(void); /* ajuste le coeff de zoom a 1*/ - void SetLastZoom(void); /* ajuste le coeff de zoom au max */ + /* fonctions relatives au zoom */ + int GetZoom( void ); /* retourne le coeff de zoom */ + void SetZoom( int coeff ); /* ajuste le coeff de zoom a coeff */ + void SetZoomList( int* zoomlist ); /* init liste des zoom (NULL terminated) */ + void SetNextZoom( void ); /* ajuste le prochain coeff de zoom */ + void SetPreviousZoom( void ); /* ajuste le precedent coeff de zoom */ + void SetFirstZoom( void ); /* ajuste le coeff de zoom a 1*/ + void SetLastZoom( void ); /* ajuste le coeff de zoom au max */ - /* fonctions relatives a la grille */ - wxSize GetGrid(void); /* retourne la grille */ - void SetGrid(const wxSize & size); - void SetGridList(wxSize * sizelist); /* init liste des grilles (NULL terminated) */ - void SetNextGrid(void); /* ajuste le prochain coeff de grille */ - void SetPreviousGrid(void); /* ajuste le precedent coeff de grille */ - void SetFirstGrid(void); /* ajuste la grille au mini*/ - void SetLastGrid(void); /* ajuste la grille au max */ + /* fonctions relatives a la grille */ + wxSize GetGrid( void ); /* retourne la grille */ + void SetGrid( const wxSize& size ); + void SetGridList( wxSize* sizelist ); /* init liste des grilles (NULL terminated) */ + void SetNextGrid( void ); /* ajuste le prochain coeff de grille */ + void SetPreviousGrid( void ); /* ajuste le precedent coeff de grille */ + void SetFirstGrid( void ); /* ajuste la grille au mini*/ + void SetLastGrid( void ); /* ajuste la grille au max */ + + +#if defined (DEBUG) + + /** + * Function GetClass + * returns the class name. + * @return wxString + */ + virtual wxString GetClass() const + { + return wxT( "BASE_SCREEN" ); + } + +#endif }; #endif /* PANEL_WXSTRUCT_H */ - diff --git a/include/pcbstruct.h b/include/pcbstruct.h index 140679b088..abdd75b6bb 100644 --- a/include/pcbstruct.h +++ b/include/pcbstruct.h @@ -234,6 +234,18 @@ public: #if defined(DEBUG) + + /** + * Function GetClass + * returns the class name. + * @return wxString + */ + virtual wxString GetClass() const + { + return wxT( "BOARD" ); + } + + /** * Function Show * is used to output the object tree, currently for debugging only. diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 5f1d39ee16..006e172ef7 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -257,6 +257,7 @@ bool BOARD::ComputeBoundaryBox( void ) #if defined(DEBUG) + /** * Function Show * is used to output the object tree, currently for debugging only. @@ -267,7 +268,7 @@ bool BOARD::ComputeBoundaryBox( void ) void BOARD::Show( int nestLevel, std::ostream& os ) { // for now, make it look like XML: - NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << ">\n"; + NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n"; // specialization of the output: EDA_BaseStruct* p = m_Modules; @@ -284,11 +285,10 @@ void BOARD::Show( int nestLevel, std::ostream& os ) kid->Show( nestLevel+1, os ); } - NestedSpace( nestLevel, os ) << "\n"; + NestedSpace( nestLevel, os ) << "\n"; } - class ModuleOrPad : public INSPECTOR { public: diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 24488f8315..78670b5e4f 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -446,7 +446,7 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File, void EDGE_MODULE::Show( int nestLevel, std::ostream& os ) { // for now, make it look like XML: - NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << "/>\n"; + NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << "/>\n"; } #endif diff --git a/pcbnew/class_edge_mod.h b/pcbnew/class_edge_mod.h index 29588760d4..037adbf135 100644 --- a/pcbnew/class_edge_mod.h +++ b/pcbnew/class_edge_mod.h @@ -43,6 +43,17 @@ public: void Draw3D( Pcb3D_GLCanvas* glcanvas ); #if defined(DEBUG) + /** + * Function GetClass + * returns the class name. + * @return wxString + */ + virtual wxString GetClass() const + { + return wxT( "POLYLINE" ); + // return wxT( "EDGE" ); ? + } + /** * Function Show * is used to output the object tree, currently for debugging only. diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 7efc0f18ee..4fd7633017 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -1158,7 +1158,7 @@ void MODULE::Show( int nestLevel, std::ostream& os ) { // for now, make it look like XML, expand on this later. - NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << + NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << // " ref=\"" << m_Reference->m_Text.mb_str() << // "\" value=\"" << m_Value->m_Text.mb_str() << '"' << ">\n"; @@ -1172,23 +1172,27 @@ void MODULE::Show( int nestLevel, std::ostream& os ) p = m_Value; for( ; p; p = p->Pnext ) p->Show( nestLevel+1, os ); + + p = m_Pads; + for( ; p; p = p->Pnext ) + p->Show( nestLevel+1, os ); p = m_Drawings; for( ; p; p = p->Pnext ) p->Show( nestLevel+1, os ); - + p = m_Son; for( ; p; p = p->Pnext ) { p->Show( nestLevel+1, os ); } - NestedSpace( nestLevel, os ) << "\n"; + NestedSpace( nestLevel, os ) << "\n"; } // see class_module.h -SEARCH_RESULT MODULE::Traverse( INSPECTOR* inspector, const void* testData, +SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, const KICAD_T scanTypes[] ) { KICAD_T stype; @@ -1201,13 +1205,6 @@ SEARCH_RESULT MODULE::Traverse( INSPECTOR* inspector, const void* testData, if( SEARCH_QUIT == inspector->Inspect( this, testData ) ) return SEARCH_QUIT; } - else if( stype == TYPEEDGEMODULE ) - { - // iterate over m_Drawings - if( SEARCH_QUIT == IterateForward( m_Drawings, inspector, - testData, scanTypes ) ) - return SEARCH_QUIT; - } else if( stype == TYPETEXTEMODULE ) { // iterate over m_Reference @@ -1220,6 +1217,19 @@ SEARCH_RESULT MODULE::Traverse( INSPECTOR* inspector, const void* testData, testData, scanTypes ) ) return SEARCH_QUIT; } + else if( stype == TYPEPAD ) + { + if( SEARCH_QUIT == IterateForward( m_Pads, inspector, + testData, scanTypes ) ) + return SEARCH_QUIT; + } + else if( stype == TYPEEDGEMODULE ) + { + // iterate over m_Drawings + if( SEARCH_QUIT == IterateForward( m_Drawings, inspector, + testData, scanTypes ) ) + return SEARCH_QUIT; + } } return SEARCH_CONTINUE; diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 57c7604870..1ced83f1dc 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -27,9 +27,9 @@ enum Mod_Attribut /* Attributs d'un module */ * fichiers de placement automatique (principalement modules CMS */ MOD_VIRTUAL = 2 /* Module virtuel constitue par un dessin sur circuit * (connecteur, trou de percage..) */ - }; + /* flags for autoplace and autoroute (.m_ModuleStatus member) */ #define MODULE_is_LOCKED 0x01 /* module LOCKED: no autoplace allowed */ #define MODULE_is_PLACED 0x02 /* In autoplace: module automatically placed */ @@ -55,7 +55,8 @@ public: EDA_Rect m_RealBoundaryBox; /* position/taille du module (coord relles) */ int m_PadNum; // Nombre total de pads int m_AltPadNum; // en placement auto Nombre de pads actifs pour - // les calculs + // les calculs + int m_CntRot90; // Placement auto: cout ( 0..10 ) de la rotation 90 degre int m_CntRot180; // Placement auto: cout ( 0..10 ) de la rotation 180 degre wxSize m_Ext; // marges de "garde": utilise en placement auto. @@ -77,11 +78,10 @@ public: MODULE* Next( void ) { return (MODULE*) Pnext; } void Set_Rectangle_Encadrement( void );/* mise a jour du rect d'encadrement - * en coord locales (orient 0 et origine = pos module) */ + * en coord locales (orient 0 et origine = pos module) */ void SetRectangleExinscrit( void );/* mise a jour du rect d'encadrement - * et de la surface en coord reelles */ - + * et de la surface en coord reelles */ // deplacements void SetPosition( const wxPoint& newpos ); @@ -134,6 +134,18 @@ public: void Display_Infos( WinEDA_BasePcbFrame* frame ); #if defined(DEBUG) + + /** + * Function GetClass + * returns the class name. + * @return wxString + */ + virtual wxString GetClass() const + { + return wxT( "MODULE" ); + } + + /** * Function Show * is used to output the object tree, currently for debugging only. @@ -145,8 +157,8 @@ public: /** - * Function Traverse - * should be re-implemented for each derrived class in order to handle + * Function Visit + * should be re-implemented for each derived class in order to handle * all the types given by its member data. Implementations should call * inspector->Inspect() on types in scanTypes[], and may use IterateForward() * to do so on lists of such data. @@ -157,7 +169,7 @@ public: * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, * else SCAN_CONTINUE; */ - virtual SEARCH_RESULT Traverse( INSPECTOR* inspector, const void* testData, + virtual SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData, const KICAD_T scanTypes[] ); #endif diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index b6873fd47c..335b6cb6b5 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -1,6 +1,6 @@ - /************************************************/ - /* class_pad.cpp : fonctions de la classe D_PAD */ - /************************************************/ +/************************************************/ +/* class_pad.cpp : fonctions de la classe D_PAD */ +/************************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -21,72 +21,76 @@ #include "protos.h" - /*******************************/ - /* classe D_PAD : constructeur */ - /*******************************/ +/*******************************/ +/* classe D_PAD : constructeur */ +/*******************************/ -D_PAD::D_PAD(MODULE * parent): EDA_BaseStruct( parent, TYPEPAD) +D_PAD::D_PAD( MODULE* parent ) : EDA_BaseStruct( parent, TYPEPAD ) { - m_NumPadName = 0; - m_Masque_Layer = CUIVRE_LAYER; - m_NetCode = 0; /* Numero de net pour comparaisons rapides */ - m_DrillShape = CIRCLE; // Drill shape = circle - m_Size.x = m_Size.y = 500; - if (m_Parent && (m_Parent->m_StructType == TYPEMODULE) ) - { - m_Pos = ((MODULE*)m_Parent)->m_Pos; - } + m_NumPadName = 0; + m_Masque_Layer = CUIVRE_LAYER; + m_NetCode = 0; /* Numero de net pour comparaisons rapides */ + m_DrillShape = CIRCLE; // Drill shape = circle + m_Size.x = m_Size.y = 500; + if( m_Parent && (m_Parent->m_StructType == TYPEMODULE) ) + { + m_Pos = ( (MODULE*) m_Parent )->m_Pos; + } - m_PadShape = CIRCLE; // forme CERCLE, RECT OVALE TRAPEZE ou libre - m_Attribut = STANDARD; // NORMAL, SMD, CONN, Bit 7 = STACK - m_Orient = 0; // en 1/10 degres + m_PadShape = CIRCLE; // forme CERCLE, RECT OVALE TRAPEZE ou libre + m_Attribut = STANDARD; // NORMAL, SMD, CONN, Bit 7 = STACK + m_Orient = 0; // en 1/10 degres - m_logical_connexion = 0; - m_physical_connexion = 0; // variables utilisee lors du calcul du chevelu - ComputeRayon(); + m_logical_connexion = 0; + m_physical_connexion = 0; // variables utilisee lors du calcul du chevelu + ComputeRayon(); } -D_PAD::~D_PAD(void) +D_PAD::~D_PAD( void ) { } + /****************************/ -void D_PAD::ComputeRayon(void) +void D_PAD::ComputeRayon( void ) /****************************/ + /* met a jour m_Rayon, rayon du cercle exinscrit -*/ + */ { - switch (m_PadShape & 0x7F) - { - case CIRCLE : - m_Rayon = m_Size.x/2; - break; + switch( m_PadShape & 0x7F ) + { + case CIRCLE: + m_Rayon = m_Size.x / 2; + break; - case OVALE : - m_Rayon = MAX(m_Size.x, m_Size.y) / 2; - break; - - case RECT : - case SPECIAL_PAD: - case TRAPEZE: - m_Rayon = (int)(sqrt((float)m_Size.y * m_Size.y - + (float)m_Size.x * m_Size.x) / 2); - break; - } + case OVALE: + m_Rayon = MAX( m_Size.x, m_Size.y ) / 2; + break; + case RECT: + case SPECIAL_PAD: + case TRAPEZE: + m_Rayon = (int) (sqrt( (float) m_Size.y * m_Size.y + + (float) m_Size.x * m_Size.x ) / 2); + break; + } } + /*********************************************/ -const wxPoint D_PAD::ReturnShapePos(void) +const wxPoint D_PAD::ReturnShapePos( void ) /*********************************************/ + // retourne la position de la forme (pastilles excentrees) { - if ( (m_Offset.x == 0) && (m_Offset.y == 0) ) return m_Pos; -wxPoint shape_pos; -int dX, dY; + if( (m_Offset.x == 0) && (m_Offset.y == 0) ) + return m_Pos; + wxPoint shape_pos; + int dX, dY; dX = m_Offset.x; dY = m_Offset.y; - RotatePoint(&dX, &dY, m_Orient ); + RotatePoint( &dX, &dY, m_Orient ); shape_pos.x = m_Pos.x + dX; shape_pos.y = m_Pos.y + dY; return shape_pos; @@ -94,727 +98,879 @@ int dX, dY; /****************************************/ -wxString D_PAD::ReturnStringPadName(void) +wxString D_PAD::ReturnStringPadName( void ) /****************************************/ + /* Return pad name as string in a wxString -*/ + */ { -wxString name; + wxString name; - ReturnStringPadName(name); - return name; + ReturnStringPadName( name ); + return name; } + /********************************************/ -void D_PAD::ReturnStringPadName(wxString & text) +void D_PAD::ReturnStringPadName( wxString& text ) /********************************************/ + /* Return pad name as string in a buffer -*/ + */ { -int ii; - - text.Empty(); - for ( ii = 0; ii < 4; ii++ ) - { - if ( m_Padname[ii] == 0 ) break; - text.Append(m_Padname[ii]); - } + int ii; + + text.Empty(); + for( ii = 0; ii < 4; ii++ ) + { + if( m_Padname[ii] == 0 ) + break; + text.Append( m_Padname[ii] ); + } } /********************************************/ -void D_PAD::SetPadName(const wxString & name) +void D_PAD::SetPadName( const wxString& name ) /********************************************/ + // Change pad name { -int ii, len; - len = name.Length(); - if ( len > 4 ) len = 4; - for (ii = 0; ii < len; ii ++ ) m_Padname[ii] = name.GetChar(ii); - for (ii = len; ii < 4; ii ++ ) m_Padname[ii] = 0; + int ii, len; + + len = name.Length(); + if( len > 4 ) + len = 4; + for( ii = 0; ii < len; ii++ ) + m_Padname[ii] = name.GetChar( ii ); + + for( ii = len; ii < 4; ii++ ) + m_Padname[ii] = 0; } /********************************/ -void D_PAD::Copy(D_PAD * source) +void D_PAD::Copy( D_PAD* source ) /********************************/ { - if (source == NULL) return; + if( source == NULL ) + return; - m_Pos = source->m_Pos; - m_Masque_Layer = source->m_Masque_Layer; + m_Pos = source->m_Pos; + m_Masque_Layer = source->m_Masque_Layer; - memcpy(m_Padname,source->m_Padname, sizeof(m_Padname));/* nom de la pastille */ - m_NetCode = source->m_NetCode; /* Numero de net pour comparaisons rapides */ - m_Drill = source->m_Drill; // Diametre de percage - m_DrillShape = source->m_DrillShape; - m_Offset = source->m_Offset; // Offset de la forme - m_Size = source->m_Size; // Dimension ( pour orient 0 ) - m_DeltaSize = source->m_DeltaSize; // delta sur formes rectangle -> trapezes - m_Pos0 = source->m_Pos0; // Coord relatives a l'ancre du pad en - // orientation 0 - m_Rayon = source->m_Rayon; // rayon du cercle exinscrit du pad - m_PadShape = source->m_PadShape; // forme CERCLE, RECT OVALE TRAPEZE ou libre - m_Attribut = source->m_Attribut; // NORMAL, SMD, CONN, Bit 7 = STACK - m_Orient = source->m_Orient; // en 1/10 degres + memcpy( m_Padname, source->m_Padname, sizeof(m_Padname) ); /* nom de la pastille */ + m_NetCode = source->m_NetCode; /* Numero de net pour comparaisons rapides */ + m_Drill = source->m_Drill; // Diametre de percage + m_DrillShape = source->m_DrillShape; + m_Offset = source->m_Offset; // Offset de la forme + m_Size = source->m_Size; // Dimension ( pour orient 0 ) + m_DeltaSize = source->m_DeltaSize; // delta sur formes rectangle -> trapezes + m_Pos0 = source->m_Pos0; // Coord relatives a l'ancre du pad en + // orientation 0 + m_Rayon = source->m_Rayon; // rayon du cercle exinscrit du pad + m_PadShape = source->m_PadShape; // forme CERCLE, RECT OVALE TRAPEZE ou libre + m_Attribut = source->m_Attribut; // NORMAL, SMD, CONN, Bit 7 = STACK + m_Orient = source->m_Orient; // en 1/10 degres - m_logical_connexion = 0; // variable utilisee lors du calcul du chevelu - m_physical_connexion = 0; // variable utilisee lors du calcul de la connexité - - m_Netname = source->m_Netname; + m_logical_connexion = 0; // variable utilisee lors du calcul du chevelu + m_physical_connexion = 0; // variable utilisee lors du calcul de la connexit� + m_Netname = source->m_Netname; } + /**************************/ void D_PAD::UnLink( void ) /**************************/ + /* supprime du chainage la structure Struct - les structures arrieres et avant sont chainees directement + * les structures arrieres et avant sont chainees directement */ { - /* Modification du chainage arriere */ - if( Pback ) - { - if( Pback->m_StructType != TYPEMODULE) - { - Pback->Pnext = Pnext; - } + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType != TYPEMODULE ) + { + Pback->Pnext = Pnext; + } + else /* Le chainage arriere pointe sur la structure "Pere" */ + { + ( (MODULE*) Pback )->m_Pads = (D_PAD*) Pnext; + } + } - else /* Le chainage arriere pointe sur la structure "Pere" */ - { - ((MODULE*)Pback)->m_Pads = (D_PAD *) Pnext; - } - } + /* Modification du chainage avant */ + if( Pnext ) + Pnext->Pback = Pback; - /* Modification du chainage avant */ - if( Pnext) Pnext->Pback = Pback; - - Pnext = Pback = NULL; + Pnext = Pback = NULL; } /*******************************************************************************************/ -void D_PAD::Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset, int draw_mode) +void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode ) /*******************************************************************************************/ -/* Tracé a l'écran d'un pad: - Entree : - ptr_pad = pointeur sur le pad du module - offset = offset de trace - draw_mode = mode de trace ( GR_OR, GR_XOR, GR_AND) -*/ + +/* Trac�a l'�ran d'un pad: + * Entree : + * ptr_pad = pointeur sur le pad du module + * offset = offset de trace + * draw_mode = mode de trace ( GR_OR, GR_XOR, GR_AND) + */ { -int ii; -int color = 0; -int ux0,uy0, - dx,dx0,dy,dy0, - rotdx, - delta_cx, delta_cy, - xc, yc; -int angle; -wxPoint coord[4]; -int zoom; -int fillpad = 0; -PCB_SCREEN * screen; -WinEDA_BasePcbFrame * frame; -wxPoint shape_pos; + int ii; + int color = 0; + int ux0, uy0, + dx, dx0, dy, dy0, + rotdx, + delta_cx, delta_cy, + xc, yc; + int angle; + wxPoint coord[4]; + int zoom; + int fillpad = 0; + PCB_SCREEN* screen; + WinEDA_BasePcbFrame* frame; + wxPoint shape_pos; - screen = panel ? (PCB_SCREEN *) panel->m_Parent->m_CurrentScreen : (PCB_SCREEN *) ActiveScreen; - frame = ( WinEDA_BasePcbFrame * ) panel->m_Parent; + screen = panel ? (PCB_SCREEN*) panel->m_Parent->m_CurrentScreen : (PCB_SCREEN*) ActiveScreen; + frame = (WinEDA_BasePcbFrame*) panel->m_Parent; - /* Calcul de l'aspect du pad */ - if( frame->m_DisplayPadFill == FILLED) fillpad = 1; + /* Calcul de l'aspect du pad */ + if( frame->m_DisplayPadFill == FILLED ) + fillpad = 1; - zoom = screen->GetZoom(); + zoom = screen->GetZoom(); #ifdef PCBNEW - if( m_Flags & IS_MOVED) fillpad = 0; + if( m_Flags & IS_MOVED ) + fillpad = 0; #endif - if ( m_Masque_Layer & CMP_LAYER ) color = g_PadCMPColor ; - if ( m_Masque_Layer & CUIVRE_LAYER ) color |= g_PadCUColor ; + if( m_Masque_Layer & CMP_LAYER ) + color = g_PadCMPColor; + if( m_Masque_Layer & CUIVRE_LAYER ) + color |= g_PadCUColor; - if( color == 0) /* Not on copper layer */ - { - switch ( m_Masque_Layer & ~ALL_CU_LAYERS ) - { - case ADHESIVE_LAYER_CU: - color = g_DesignSettings.m_LayerColor[ADHESIVE_N_CU]; - break; - case ADHESIVE_LAYER_CMP: - color = g_DesignSettings.m_LayerColor[ADHESIVE_N_CMP]; - break; - case SOLDERPASTE_LAYER_CU: - color = g_DesignSettings.m_LayerColor[SOLDERPASTE_N_CU]; - break; - case SOLDERPASTE_LAYER_CMP: - color = g_DesignSettings.m_LayerColor[SOLDERPASTE_N_CMP]; - break; - case SILKSCREEN_LAYER_CU: - color = g_DesignSettings.m_LayerColor[SILKSCREEN_N_CU]; - break; - case SILKSCREEN_LAYER_CMP: - color = g_DesignSettings.m_LayerColor[SILKSCREEN_N_CMP]; - break; - case SOLDERMASK_LAYER_CU: - color = g_DesignSettings.m_LayerColor[SOLDERMASK_N_CU]; - break; - case SOLDERMASK_LAYER_CMP: - color = g_DesignSettings.m_LayerColor[SOLDERMASK_N_CMP]; - break; - case DRAW_LAYER : - color = g_DesignSettings.m_LayerColor[DRAW_N]; - break; - case COMMENT_LAYER: - color = g_DesignSettings.m_LayerColor[COMMENT_N]; - break; - case ECO1_LAYER: - color = g_DesignSettings.m_LayerColor[ECO1_N]; - break; - case ECO2_LAYER : - color = g_DesignSettings.m_LayerColor[ECO2_N]; - break; - case EDGE_LAYER: - color = g_DesignSettings.m_LayerColor[EDGE_N]; - break; - - default: - color = DARKGRAY; - break; - } - } + if( color == 0 ) /* Not on copper layer */ + { + switch( m_Masque_Layer & ~ALL_CU_LAYERS ) + { + case ADHESIVE_LAYER_CU: + color = g_DesignSettings.m_LayerColor[ADHESIVE_N_CU]; + break; - if ( draw_mode & GR_SURBRILL ) - { - if(draw_mode & GR_AND) color &= ~HIGHT_LIGHT_FLAG; - else color |= HIGHT_LIGHT_FLAG; - } - if ( color & HIGHT_LIGHT_FLAG) - color = ColorRefs[color & MASKCOLOR].m_LightColor; + case ADHESIVE_LAYER_CMP: + color = g_DesignSettings.m_LayerColor[ADHESIVE_N_CMP]; + break; - GRSetDrawMode(DC, draw_mode); /* mode de trace */ + case SOLDERPASTE_LAYER_CU: + color = g_DesignSettings.m_LayerColor[SOLDERPASTE_N_CU]; + break; - /* calcul du centre des pads en coordonnees Ecran : */ + case SOLDERPASTE_LAYER_CMP: + color = g_DesignSettings.m_LayerColor[SOLDERPASTE_N_CMP]; + break; + + case SILKSCREEN_LAYER_CU: + color = g_DesignSettings.m_LayerColor[SILKSCREEN_N_CU]; + break; + + case SILKSCREEN_LAYER_CMP: + color = g_DesignSettings.m_LayerColor[SILKSCREEN_N_CMP]; + break; + + case SOLDERMASK_LAYER_CU: + color = g_DesignSettings.m_LayerColor[SOLDERMASK_N_CU]; + break; + + case SOLDERMASK_LAYER_CMP: + color = g_DesignSettings.m_LayerColor[SOLDERMASK_N_CMP]; + break; + + case DRAW_LAYER: + color = g_DesignSettings.m_LayerColor[DRAW_N]; + break; + + case COMMENT_LAYER: + color = g_DesignSettings.m_LayerColor[COMMENT_N]; + break; + + case ECO1_LAYER: + color = g_DesignSettings.m_LayerColor[ECO1_N]; + break; + + case ECO2_LAYER: + color = g_DesignSettings.m_LayerColor[ECO2_N]; + break; + + case EDGE_LAYER: + color = g_DesignSettings.m_LayerColor[EDGE_N]; + break; + + default: + color = DARKGRAY; + break; + } + } + + if( draw_mode & GR_SURBRILL ) + { + if( draw_mode & GR_AND ) + color &= ~HIGHT_LIGHT_FLAG; + else + color |= HIGHT_LIGHT_FLAG; + } + if( color & HIGHT_LIGHT_FLAG ) + color = ColorRefs[color & MASKCOLOR].m_LightColor; + + GRSetDrawMode( DC, draw_mode ); /* mode de trace */ + + /* calcul du centre des pads en coordonnees Ecran : */ shape_pos = ReturnShapePos(); - ux0 = shape_pos.x - offset.x; - uy0 = shape_pos.y - offset.y; - xc = ux0; - yc = uy0; + ux0 = shape_pos.x - offset.x; + uy0 = shape_pos.y - offset.y; + xc = ux0; + yc = uy0; - /* le trace depend de la rotation de l'empreinte */ + /* le trace depend de la rotation de l'empreinte */ - dx = dx0 = m_Size.x >> 1 ; - dy = dy0 = m_Size.y >> 1 ; /* demi dim dx et dy */ + dx = dx0 = m_Size.x >> 1; + dy = dy0 = m_Size.y >> 1; /* demi dim dx et dy */ - angle = m_Orient; - bool DisplayIsol = DisplayOpt.DisplayPadIsol; - if ( ( m_Masque_Layer & ALL_CU_LAYERS ) == 0 ) DisplayIsol = FALSE; - - switch (m_PadShape & 0x7F) - { - case CIRCLE : - if ( fillpad) - GRFilledCircle(&panel->m_ClipBox, DC, xc, yc, dx, 0, color, color); - else GRCircle(&panel->m_ClipBox, DC, xc, yc, dx, 0, color); + angle = m_Orient; + bool DisplayIsol = DisplayOpt.DisplayPadIsol; + if( ( m_Masque_Layer & ALL_CU_LAYERS ) == 0 ) + DisplayIsol = FALSE; - if(DisplayIsol) - { - GRCircle(&panel->m_ClipBox, DC, xc, yc, dx + g_DesignSettings.m_TrackClearence, 0, color ); - } - break; + switch( m_PadShape & 0x7F ) + { + case CIRCLE: + if( fillpad ) + GRFilledCircle( &panel->m_ClipBox, DC, xc, yc, dx, 0, color, color ); + else + GRCircle( &panel->m_ClipBox, DC, xc, yc, dx, 0, color ); - case OVALE : - /* calcul de l'entraxe de l'ellipse */ - if( dx > dy ) /* ellipse horizontale */ - { - delta_cx = dx - dy; delta_cy = 0; - rotdx = m_Size.y; - } - else /* ellipse verticale */ - { - delta_cx = 0; delta_cy = dy - dx; - rotdx = m_Size.x; - } - RotatePoint(&delta_cx, &delta_cy, angle); + if( DisplayIsol ) + { + GRCircle( &panel->m_ClipBox, + DC, + xc, + yc, + dx + g_DesignSettings.m_TrackClearence, + 0, + color ); + } + break; - if (fillpad) - { - GRFillCSegm(&panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, - ux0 - delta_cx, uy0 - delta_cy, - rotdx, color); - } + case OVALE: + /* calcul de l'entraxe de l'ellipse */ + if( dx > dy ) /* ellipse horizontale */ + { + delta_cx = dx - dy; delta_cy = 0; + rotdx = m_Size.y; + } + else /* ellipse verticale */ + { + delta_cx = 0; delta_cy = dy - dx; + rotdx = m_Size.x; + } + RotatePoint( &delta_cx, &delta_cy, angle ); - else - { - GRCSegm(&panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, - ux0 - delta_cx, uy0 - delta_cy, - rotdx, color); - } + if( fillpad ) + { + GRFillCSegm( &panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, + ux0 - delta_cx, uy0 - delta_cy, + rotdx, color ); + } + else + { + GRCSegm( &panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, + ux0 - delta_cx, uy0 - delta_cy, + rotdx, color ); + } - /* Trace de la marge d'isolement */ - if(DisplayIsol) - { - rotdx = rotdx + g_DesignSettings.m_TrackClearence + g_DesignSettings.m_TrackClearence; - GRCSegm(&panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, - ux0 - delta_cx, uy0 - delta_cy, - rotdx, color); - } - break; + /* Trace de la marge d'isolement */ + if( DisplayIsol ) + { + rotdx = rotdx + g_DesignSettings.m_TrackClearence + g_DesignSettings.m_TrackClearence; + GRCSegm( &panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, + ux0 - delta_cx, uy0 - delta_cy, + rotdx, color ); + } + break; - case RECT : - case SPECIAL_PAD: - case TRAPEZE: - { - int ddx, ddy ; - ddx = m_DeltaSize.x >> 1 ; - ddy = m_DeltaSize.y >> 1 ; /* demi dim dx et dy */ + case RECT: + case SPECIAL_PAD: + case TRAPEZE: + { + int ddx, ddy; + ddx = m_DeltaSize.x >> 1; + ddy = m_DeltaSize.y >> 1; /* demi dim dx et dy */ - coord[0].x = - dx - ddy; - coord[0].y = + dy + ddx; + coord[0].x = -dx - ddy; + coord[0].y = +dy + ddx; - coord[1].x = - dx + ddy; - coord[1].y = - dy - ddx; + coord[1].x = -dx + ddy; + coord[1].y = -dy - ddx; - coord[2].x = + dx - ddy; - coord[2].y = - dy + ddx; + coord[2].x = +dx - ddy; + coord[2].y = -dy + ddx; - coord[3].x = + dx + ddy; - coord[3].y = + dy - ddx; + coord[3].x = +dx + ddy; + coord[3].y = +dy - ddx; - for (ii = 0; ii < 4; ii++) - { - RotatePoint(&coord[ii].x,&coord[ii].y, angle); - coord[ii].x = coord[ii].x + ux0; - coord[ii].y = coord[ii].y + uy0; - } + for( ii = 0; ii < 4; ii++ ) + { + RotatePoint( &coord[ii].x, &coord[ii].y, angle ); + coord[ii].x = coord[ii].x + ux0; + coord[ii].y = coord[ii].y + uy0; + } - GRClosedPoly(&panel->m_ClipBox, DC, 4, (int*) coord, fillpad, color, color); + GRClosedPoly( &panel->m_ClipBox, DC, 4, (int*) coord, fillpad, color, color ); - if(DisplayIsol) - { - dx += g_DesignSettings.m_TrackClearence; dy += g_DesignSettings.m_TrackClearence; - coord[0].x = -dx - ddy; - coord[0].y = dy + ddx; + if( DisplayIsol ) + { + dx += g_DesignSettings.m_TrackClearence; dy += g_DesignSettings.m_TrackClearence; + coord[0].x = -dx - ddy; + coord[0].y = dy + ddx; - coord[1].x = -dx + ddy; - coord[1].y = -dy - ddx; + coord[1].x = -dx + ddy; + coord[1].y = -dy - ddx; - coord[2].x = dx - ddy; - coord[2].y = -dy + ddx; + coord[2].x = dx - ddy; + coord[2].y = -dy + ddx; - coord[3].x = dx + ddy; - coord[3].y = dy - ddx; + coord[3].x = dx + ddy; + coord[3].y = dy - ddx; - for (ii = 0; ii < 4; ii++) - { - RotatePoint(&coord[ii].x,&coord[ii].y, angle); - coord[ii].x = coord[ii].x + ux0; - coord[ii].y = coord[ii].y + uy0; - } + for( ii = 0; ii < 4; ii++ ) + { + RotatePoint( &coord[ii].x, &coord[ii].y, angle ); + coord[ii].x = coord[ii].x + ux0; + coord[ii].y = coord[ii].y + uy0; + } - GRClosedPoly(&panel->m_ClipBox, DC, 4, (int*)coord, 0, color, color); - } - break; + GRClosedPoly( &panel->m_ClipBox, DC, 4, (int*) coord, 0, color, color ); + } + break; - default: - break; - } - } + default: + break; + } + } - /* Draw the pad hole */ - int cx0 = m_Pos.x - offset.x; - int cy0 = m_Pos.y - offset.y; - int hole = m_Drill.x >> 1 ; + /* Draw the pad hole */ + int cx0 = m_Pos.x - offset.x; + int cy0 = m_Pos.y - offset.y; + int hole = m_Drill.x >> 1; - if( fillpad && hole ) - { - color = g_IsPrinting ? WHITE : BLACK; // ou DARKGRAY; - if(draw_mode != GR_XOR) GRSetDrawMode(DC, GR_COPY); - else GRSetDrawMode(DC, GR_XOR); - switch ( m_DrillShape ) - { - case CIRCLE: - if( (hole/zoom) > 1 ) /* draw hole if its size is enought */ - GRFilledCircle(&panel->m_ClipBox, DC, cx0, cy0, hole, 0, color, color); - break; - - case OVALE: - dx = m_Drill.x >> 1 ; - dy = m_Drill.y >> 1 ; /* demi dim dx et dy */ - /* calcul de l'entraxe de l'ellipse */ - if( m_Drill.x > m_Drill.y ) /* ellipse horizontale */ - { - delta_cx = dx - dy; delta_cy = 0; - rotdx = m_Drill.y; - } - else /* ellipse verticale */ - { - delta_cx = 0; delta_cy = dy - dx; - rotdx = m_Drill.x; - } - RotatePoint(&delta_cx, &delta_cy, angle); - - GRFillCSegm(&panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, - ux0 - delta_cx, uy0 - delta_cy, - rotdx, color); - break; - - default: - break; - } - } + if( fillpad && hole ) + { + color = g_IsPrinting ? WHITE : BLACK; // ou DARKGRAY; + if( draw_mode != GR_XOR ) + GRSetDrawMode( DC, GR_COPY ); + else + GRSetDrawMode( DC, GR_XOR ); - GRSetDrawMode(DC, draw_mode); - /* Trace du symbole "No connect" ( / ou \ ou croix en X) si necessaire : */ - if( m_Netname.IsEmpty() && DisplayOpt.DisplayPadNoConn ) - { - dx0 = min(dx0,dy0); - int nc_color = BLUE; - if(m_Masque_Layer & CMP_LAYER) /* Trace forme \ */ - GRLine(&panel->m_ClipBox, DC, cx0 - dx0, cy0 - dx0, - cx0 + dx0, cy0 + dx0, 0, nc_color ); + switch( m_DrillShape ) + { + case CIRCLE: + if( (hole / zoom) > 1 ) /* draw hole if its size is enought */ + GRFilledCircle( &panel->m_ClipBox, DC, cx0, cy0, hole, 0, color, color ); + break; - if(m_Masque_Layer & CUIVRE_LAYER) /* Trace forme / */ - GRLine(&panel->m_ClipBox, DC, cx0 + dx0, cy0 - dx0, - cx0 - dx0, cy0 + dx0, 0, nc_color ); - } - /* Trace de la reference */ - if( ! frame->m_DisplayPadNum) return; - dx = min(m_Size.x, m_Size.y); /* dx = text size */ - if( (dx / zoom) > 12 ) /* size must be enought to draw 2 chars */ - { - wxString buffer; - ReturnStringPadName(buffer); - dy = buffer.Len(); - /* Draw text with an angle between -90 deg and + 90 deg */ - NORMALIZE_ANGLE_90(angle); - if ( dy < 2 ) dy = 2; /* text min size is 2 char */ - dx = (dx * 9 ) / (dy * 13 ); /* Text size ajusted to pad size */ - DrawGraphicText(panel, DC, wxPoint(ux0, uy0), - WHITE, buffer, angle, wxSize(dx, dx), - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); - } + case OVALE: + dx = m_Drill.x >> 1; + dy = m_Drill.y >> 1; /* demi dim dx et dy */ + /* calcul de l'entraxe de l'ellipse */ + if( m_Drill.x > m_Drill.y ) /* ellipse horizontale */ + { + delta_cx = dx - dy; delta_cy = 0; + rotdx = m_Drill.y; + } + else /* ellipse verticale */ + { + delta_cx = 0; delta_cy = dy - dx; + rotdx = m_Drill.x; + } + RotatePoint( &delta_cx, &delta_cy, angle ); + + GRFillCSegm( &panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, + ux0 - delta_cx, uy0 - delta_cy, + rotdx, color ); + break; + + default: + break; + } + } + + GRSetDrawMode( DC, draw_mode ); + /* Trace du symbole "No connect" ( / ou \ ou croix en X) si necessaire : */ + if( m_Netname.IsEmpty() && DisplayOpt.DisplayPadNoConn ) + { + dx0 = min( dx0, dy0 ); + int nc_color = BLUE; + if( m_Masque_Layer & CMP_LAYER ) /* Trace forme \ */ + GRLine( &panel->m_ClipBox, DC, cx0 - dx0, cy0 - dx0, + cx0 + dx0, cy0 + dx0, 0, nc_color ); + + if( m_Masque_Layer & CUIVRE_LAYER ) /* Trace forme / */ + GRLine( &panel->m_ClipBox, DC, cx0 + dx0, cy0 - dx0, + cx0 - dx0, cy0 + dx0, 0, nc_color ); + } + /* Trace de la reference */ + if( !frame->m_DisplayPadNum ) + return; + dx = min( m_Size.x, m_Size.y ); /* dx = text size */ + if( (dx / zoom) > 12 ) /* size must be enought to draw 2 chars */ + { + wxString buffer; + ReturnStringPadName( buffer ); + dy = buffer.Len(); + /* Draw text with an angle between -90 deg and + 90 deg */ + NORMALIZE_ANGLE_90( angle ); + if( dy < 2 ) + dy = 2; /* text min size is 2 char */ + dx = (dx * 9 ) / (dy * 13 ); /* Text size ajusted to pad size */ + DrawGraphicText( panel, DC, wxPoint( ux0, uy0 ), + WHITE, buffer, angle, wxSize( dx, dx ), + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER ); + } } + /*************************************************/ -int D_PAD::ReadDescr( FILE * File, int * LineNum) +int D_PAD::ReadDescr( FILE* File, int* LineNum ) /*************************************************/ + /* Routine de lecture de descr de pads - la 1ere ligne de descr ($PAD) est supposee etre deja lue -syntaxe: -$PAD -Sh "N1" C 550 550 0 0 1800 -Dr 310 0 0 -At STD N 00C0FFFF -Ne 3 "netname" -Po 6000 -6000 -$EndPAD -*/ + * la 1ere ligne de descr ($PAD) est supposee etre deja lue + * syntaxe: + * $PAD + * Sh "N1" C 550 550 0 0 1800 + * Dr 310 0 0 + * At STD N 00C0FFFF + * Ne 3 "netname" + * Po 6000 -6000 + * $EndPAD + */ { -char Line[1024], BufLine[1024], BufCar[256]; -char * PtLine; -int nn, ll, dx, dy; + char Line[1024], BufLine[1024], BufCar[256]; + char* PtLine; + int nn, ll, dx, dy; - while( GetLine(File, Line, LineNum ) != NULL ) - { - if( Line[0] == '$' ) return( 0 ); + while( GetLine( File, Line, LineNum ) != NULL ) + { + if( Line[0] == '$' ) + return 0; - PtLine = Line + 3; /* Pointe 1er code utile de la ligne */ - switch( Line[0] ) - { - case 'S': /* Ligne de description de forme et dims*/ - /* Lecture du nom pad */ - nn = 0; - while( (*PtLine != '"') && *PtLine ) PtLine++; - if ( *PtLine ) PtLine++; - memset(m_Padname,0 ,sizeof(m_Padname) ); - while( (*PtLine != '"') && *PtLine ) - { - if(nn < (int) sizeof(m_Padname)) - { - if( * PtLine > ' ' ) - { - m_Padname[nn] = *PtLine; nn++; - } - } - PtLine++; - } + PtLine = Line + 3; - if ( *PtLine == '"' ) PtLine++; + /* Pointe 1er code utile de la ligne */ + switch( Line[0] ) + { + case 'S': /* Ligne de description de forme et dims*/ + /* Lecture du nom pad */ + nn = 0; + while( (*PtLine != '"') && *PtLine ) + PtLine++; - nn = sscanf(PtLine," %s %d %d %d %d %d", - BufCar, &m_Size.x, &m_Size.y, - &m_DeltaSize.x, &m_DeltaSize.y, - &m_Orient); + if( *PtLine ) + PtLine++; + memset( m_Padname, 0, sizeof(m_Padname) ); + while( (*PtLine != '"') && *PtLine ) + { + if( nn < (int) sizeof(m_Padname) ) + { + if( *PtLine > ' ' ) + { + m_Padname[nn] = *PtLine; nn++; + } + } + PtLine++; + } - ll = 0xFF & BufCar[0]; + if( *PtLine == '"' ) + PtLine++; - /* Mise a jour de la forme */ - m_PadShape = CIRCLE; - switch(ll) - { - case 'C': m_PadShape = CIRCLE; break; - case 'R': m_PadShape = RECT; break; - case 'O': m_PadShape = OVALE; break; - case 'T': m_PadShape = TRAPEZE; break; - } - ComputeRayon(); - break; + nn = sscanf( PtLine, " %s %d %d %d %d %d", + BufCar, &m_Size.x, &m_Size.y, + &m_DeltaSize.x, &m_DeltaSize.y, + &m_Orient ); - case 'D': - BufCar[0] = 0; - nn = sscanf(PtLine,"%d %d %d %s %d %d", &m_Drill.x, - &m_Offset.x, &m_Offset.y, BufCar, &dx, &dy ); - m_Drill.y = m_Drill.x; - m_DrillShape = CIRCLE; - if (nn >= 6 ) // Drill shape = OVAL ? - { - if (BufCar[0] == 'O' ) - { - m_Drill.x = dx; m_Drill.y = dy; - m_DrillShape = OVALE; - } - } - break; + ll = 0xFF & BufCar[0]; - case 'A': - nn = sscanf(PtLine,"%s %s %X", BufLine, BufCar, - &m_Masque_Layer); - /* Contenu de BufCar non encore utilise ( reserve pour evolutions - ulterieures */ - /* Mise a jour de l'attribut */ - m_Attribut = STANDARD; - if( strncmp(BufLine,"SMD",3) == 0 ) m_Attribut = SMD; - if( strncmp(BufLine,"CONN",4) == 0 ) m_Attribut = CONN; - if( strncmp(BufLine,"HOLE",4) == 0 ) m_Attribut = P_HOLE; - if( strncmp(BufLine,"MECA",4) == 0 ) m_Attribut = MECA; - break; + /* Mise a jour de la forme */ + m_PadShape = CIRCLE; - case 'N': /* Lecture du netname */ - nn = sscanf(PtLine,"%d", &m_NetCode); - /* Lecture du netname */ - ReadDelimitedText(BufLine, PtLine, sizeof(BufLine)); - m_Netname = CONV_FROM_UTF8(StrPurge(BufLine)); - break; + switch( ll ) + { + case 'C': + m_PadShape = CIRCLE; break; - case 'P': - nn = sscanf(PtLine,"%d %d", &m_Pos0.x, &m_Pos0.y ); - m_Pos = m_Pos0; - break; + case 'R': + m_PadShape = RECT; break; - default: - DisplayError(NULL, wxT("Err Pad: Id inconnu")); - return(1); - } - } - return(2); /* error : EOF */ + case 'O': + m_PadShape = OVALE; break; + + case 'T': + m_PadShape = TRAPEZE; break; + } + + ComputeRayon(); + break; + + case 'D': + BufCar[0] = 0; + nn = sscanf( PtLine, "%d %d %d %s %d %d", &m_Drill.x, + &m_Offset.x, &m_Offset.y, BufCar, &dx, &dy ); + m_Drill.y = m_Drill.x; + m_DrillShape = CIRCLE; + if( nn >= 6 ) // Drill shape = OVAL ? + { + if( BufCar[0] == 'O' ) + { + m_Drill.x = dx; m_Drill.y = dy; + m_DrillShape = OVALE; + } + } + break; + + case 'A': + nn = sscanf( PtLine, "%s %s %X", BufLine, BufCar, + &m_Masque_Layer ); + + /* Contenu de BufCar non encore utilise ( reserve pour evolutions + * ulterieures */ + /* Mise a jour de l'attribut */ + m_Attribut = STANDARD; + if( strncmp( BufLine, "SMD", 3 ) == 0 ) + m_Attribut = SMD; + if( strncmp( BufLine, "CONN", 4 ) == 0 ) + m_Attribut = CONN; + if( strncmp( BufLine, "HOLE", 4 ) == 0 ) + m_Attribut = P_HOLE; + if( strncmp( BufLine, "MECA", 4 ) == 0 ) + m_Attribut = MECA; + break; + + case 'N': /* Lecture du netname */ + nn = sscanf( PtLine, "%d", &m_NetCode ); + /* Lecture du netname */ + ReadDelimitedText( BufLine, PtLine, sizeof(BufLine) ); + m_Netname = CONV_FROM_UTF8( StrPurge( BufLine ) ); + break; + + case 'P': + nn = sscanf( PtLine, "%d %d", &m_Pos0.x, &m_Pos0.y ); + m_Pos = m_Pos0; + break; + + default: + DisplayError( NULL, wxT( "Err Pad: Id inconnu" ) ); + return 1; + } + } + + return 2; /* error : EOF */ } + /***********************************/ -int D_PAD::WriteDescr( FILE * File ) +int D_PAD::WriteDescr( FILE* File ) /***********************************/ + /* Sauvegarde de la description d'un PAD -*/ + */ { -int cshape, NbLigne = 0;; -char * texttype; + int cshape, NbLigne = 0;; - if( GetState(DELETED) ) return(NbLigne); + char* texttype; - /* Generation du fichier pad: */ - fprintf( File,"$PAD\n"); NbLigne++; - switch(m_PadShape) - { - case CIRCLE: cshape = 'C'; break; - case RECT: cshape = 'R'; break; - case OVALE: cshape = 'O'; break; - case TRAPEZE: cshape = 'T'; break; - default: cshape = 'C'; - DisplayError(NULL, _("Unknown Pad shape")); - break; - } - fprintf(File,"Sh \"%.4s\" %c %d %d %d %d %d\n", - m_Padname, cshape, m_Size.x, m_Size.y, - m_DeltaSize.x, m_DeltaSize.y,m_Orient); - NbLigne++; - fprintf(File,"Dr %d %d %d", m_Drill.x, m_Offset.x, m_Offset.y ); - if ( m_DrillShape == OVALE ) - { - fprintf(File," %c %d %d", 'O', m_Drill.x, m_Drill.y ); - } - fprintf(File,"\n"); - - NbLigne++; - switch(m_Attribut) - { - case STANDARD: texttype = "STD"; break; - case SMD: texttype = "SMD"; break; - case CONN: texttype = "CONN"; break; - case P_HOLE: texttype = "HOLE"; break; - case MECA: texttype = "MECA"; break; - default: - texttype = "STD"; - DisplayError(NULL, wxT("attribut Pad inconnu")); - break; - } - fprintf(File,"At %s N %8.8X\n", texttype, m_Masque_Layer); - NbLigne++; + if( GetState( DELETED ) ) + return NbLigne; - fprintf(File,"Ne %d \"%s\"\n", m_NetCode,CONV_TO_UTF8(m_Netname)); - NbLigne++; + /* Generation du fichier pad: */ + fprintf( File, "$PAD\n" ); NbLigne++; - fprintf(File,"Po %d %d\n", m_Pos0.x, m_Pos0.y ); - NbLigne++; + switch( m_PadShape ) + { + case CIRCLE: + cshape = 'C'; break; - fprintf( File,"$EndPAD\n"); - NbLigne++; - return(NbLigne); + case RECT: + cshape = 'R'; break; + + case OVALE: + cshape = 'O'; break; + + case TRAPEZE: + cshape = 'T'; break; + + default: + cshape = 'C'; + DisplayError( NULL, _( "Unknown Pad shape" ) ); + break; + } + + fprintf( File, "Sh \"%.4s\" %c %d %d %d %d %d\n", + m_Padname, cshape, m_Size.x, m_Size.y, + m_DeltaSize.x, m_DeltaSize.y, m_Orient ); + NbLigne++; + fprintf( File, "Dr %d %d %d", m_Drill.x, m_Offset.x, m_Offset.y ); + if( m_DrillShape == OVALE ) + { + fprintf( File, " %c %d %d", 'O', m_Drill.x, m_Drill.y ); + } + fprintf( File, "\n" ); + + NbLigne++; + + switch( m_Attribut ) + { + case STANDARD: + texttype = "STD"; break; + + case SMD: + texttype = "SMD"; break; + + case CONN: + texttype = "CONN"; break; + + case P_HOLE: + texttype = "HOLE"; break; + + case MECA: + texttype = "MECA"; break; + + default: + texttype = "STD"; + DisplayError( NULL, wxT( "attribut Pad inconnu" ) ); + break; + } + + fprintf( File, "At %s N %8.8X\n", texttype, m_Masque_Layer ); + NbLigne++; + + fprintf( File, "Ne %d \"%s\"\n", m_NetCode, CONV_TO_UTF8( m_Netname ) ); + NbLigne++; + + fprintf( File, "Po %d %d\n", m_Pos0.x, m_Pos0.y ); + NbLigne++; + + fprintf( File, "$EndPAD\n" ); + NbLigne++; + return NbLigne; } + /******************************************************/ -void D_PAD::Display_Infos(WinEDA_BasePcbFrame * frame) +void D_PAD::Display_Infos( WinEDA_BasePcbFrame* frame ) /******************************************************/ /* Affiche en bas d'ecran les caract de la pastille demandee */ { -int ii; -MODULE* Module; -wxString Line; -int pos = 1; -/* Pad messages */ -wxString Msg_Pad_Shape[6] = - { wxT("??? "), wxT("Circ"), wxT("Rect"), wxT("Oval"), wxT("trap"), wxT("spec") } ; + int ii; + MODULE* Module; + wxString Line; + int pos = 1; + + /* Pad messages */ + static const wxString Msg_Pad_Shape[6] = + { wxT( "??? " ), wxT( "Circ" ), wxT( "Rect" ), wxT( "Oval" ), wxT( "trap" ), wxT( "spec" ) }; -wxString Msg_Pad_Layer[9] = - { wxT("??? "), wxT("cmp "), wxT("cu "), wxT("cmp+cu "), wxT("int "), - wxT("cmp+int "), wxT("cu+int "), wxT("all "), wxT("No copp") } ; -wxString Msg_Pad_Attribut[5] = - { wxT("norm"), wxT("smd "), wxT("conn"), wxT("hole"), wxT("????")} ; + static const wxString Msg_Pad_Layer[9] = + { + wxT( "??? " ), wxT( "cmp " ), wxT( "cu " ), wxT( "cmp+cu " ), wxT( "int " ), + wxT( "cmp+int " ), wxT( "cu+int " ), wxT( "all " ), wxT( "No copp" ) + }; + + static const wxString Msg_Pad_Attribut[5] = + { wxT( "norm" ), wxT( "smd " ), wxT( "conn" ), wxT( "hole" ), wxT( "????" ) }; - frame->MsgPanel->EraseMsgBox(); + frame->MsgPanel->EraseMsgBox(); - /* Recherche du module correspondant */ - Module = (MODULE *) m_Parent; - if(Module) - { - wxString msg = Module->m_Reference->m_Text; - Affiche_1_Parametre(frame, pos,_("Module"), msg, DARKCYAN) ; - ReturnStringPadName(Line); - pos += 8; - Affiche_1_Parametre(frame, pos,_("RefP"),Line,BROWN) ; - } - pos += 4; - Affiche_1_Parametre(frame, pos,_("Net"),m_Netname, DARKCYAN); + /* Recherche du module correspondant */ + Module = (MODULE*) m_Parent; + if( Module ) + { + wxString msg = Module->m_Reference->m_Text; + Affiche_1_Parametre( frame, pos, _( "Module" ), msg, DARKCYAN ); + ReturnStringPadName( Line ); + pos += 8; + Affiche_1_Parametre( frame, pos, _( "RefP" ), Line, BROWN ); + } + pos += 4; + Affiche_1_Parametre( frame, pos, _( "Net" ), m_Netname, DARKCYAN ); - /* pour mise au point (peut etre supprimé) : Affichage du numero de Net et sous net */ - pos += 10; + /* pour mise au point (peut etre supprim� : Affichage du numero de Net et sous net */ + pos += 10; #if 0 - Line.Printf( wxT("%d.%d "),m_logical_connexion, m_physical_connexion); - Affiche_1_Parametre(frame, pos,"L.P",Line,WHITE); + Line.Printf( wxT( "%d.%d " ), m_logical_connexion, m_physical_connexion ); + Affiche_1_Parametre( frame, pos, "L.P", Line, WHITE ); #endif - wxString LayerInfo; - ii = 0; - if(m_Masque_Layer & CUIVRE_LAYER) ii = 2; - if(m_Masque_Layer & CMP_LAYER) ii += 1; - if((m_Masque_Layer & ALL_CU_LAYERS) == ALL_CU_LAYERS) ii = 7; - - LayerInfo = Msg_Pad_Layer[ii]; - if((m_Masque_Layer & ALL_CU_LAYERS) == 0) - { - if(m_Masque_Layer) LayerInfo = Msg_Pad_Layer[8]; - switch ( m_Masque_Layer & ~ALL_CU_LAYERS ) - { - case ADHESIVE_LAYER_CU: - LayerInfo = ReturnPcbLayerName(ADHESIVE_N_CU); - break; - case ADHESIVE_LAYER_CMP: - LayerInfo = ReturnPcbLayerName(ADHESIVE_N_CMP); - break; - case SOLDERPASTE_LAYER_CU: - LayerInfo = ReturnPcbLayerName(SOLDERPASTE_N_CU); - break; - case SOLDERPASTE_LAYER_CMP: - LayerInfo = ReturnPcbLayerName(SOLDERPASTE_N_CMP); - break; - case SILKSCREEN_LAYER_CU: - LayerInfo = ReturnPcbLayerName(SILKSCREEN_N_CU); - break; - case SILKSCREEN_LAYER_CMP: - LayerInfo = ReturnPcbLayerName(SILKSCREEN_N_CMP); - break; - case SOLDERMASK_LAYER_CU: - LayerInfo = ReturnPcbLayerName(SOLDERMASK_N_CU); - break; - case SOLDERMASK_LAYER_CMP: - LayerInfo = ReturnPcbLayerName(SOLDERMASK_N_CMP); - break; - case DRAW_LAYER : - LayerInfo = ReturnPcbLayerName(DRAW_N); - break; - case COMMENT_LAYER: - LayerInfo = ReturnPcbLayerName(COMMENT_N); - break; - case ECO1_LAYER: - LayerInfo = ReturnPcbLayerName(ECO1_N); - break; - case ECO2_LAYER : - LayerInfo = ReturnPcbLayerName(ECO2_N); - break; - case EDGE_LAYER: - LayerInfo = ReturnPcbLayerName(EDGE_N); - break; - - default: - break; - } - } - pos += 3; - Affiche_1_Parametre(frame, pos,_("Layer"),LayerInfo, DARKGREEN) ; + wxString LayerInfo; + ii = 0; + if( m_Masque_Layer & CUIVRE_LAYER ) + ii = 2; + if( m_Masque_Layer & CMP_LAYER ) + ii += 1; + if( (m_Masque_Layer & ALL_CU_LAYERS) == ALL_CU_LAYERS ) + ii = 7; - pos += 6; - Affiche_1_Parametre(frame, pos,Msg_Pad_Shape[m_PadShape],wxEmptyString, DARKGREEN); - /* Affichage en couleur diff si pad stack ou non */ + LayerInfo = Msg_Pad_Layer[ii]; + if( (m_Masque_Layer & ALL_CU_LAYERS) == 0 ) + { + if( m_Masque_Layer ) + LayerInfo = Msg_Pad_Layer[8]; - if (m_Attribut & PAD_STACK) - Affiche_1_Parametre(frame, -1,wxEmptyString,Msg_Pad_Attribut[m_Attribut&15],RED); - else Affiche_1_Parametre(frame, -1,wxEmptyString,Msg_Pad_Attribut[m_Attribut&15], DARKGREEN); + switch( m_Masque_Layer & ~ALL_CU_LAYERS ) + { + case ADHESIVE_LAYER_CU: + LayerInfo = ReturnPcbLayerName( ADHESIVE_N_CU ); + break; - valeur_param(m_Size.x,Line) ; - pos += 6; - Affiche_1_Parametre(frame, pos,_("H Size"),Line,RED) ; + case ADHESIVE_LAYER_CMP: + LayerInfo = ReturnPcbLayerName( ADHESIVE_N_CMP ); + break; - valeur_param(m_Size.y,Line) ; - pos += 7; - Affiche_1_Parametre(frame, pos,_("V Size"),Line,RED) ; + case SOLDERPASTE_LAYER_CU: + LayerInfo = ReturnPcbLayerName( SOLDERPASTE_N_CU ); + break; - pos += 7; - valeur_param((unsigned)m_Drill.x,Line) ; - if ( m_DrillShape == CIRCLE ) - { - Affiche_1_Parametre(frame, pos,_("Drill"),Line,RED); - } - else - { - valeur_param((unsigned)m_Drill.x,Line); - wxString msg; - valeur_param((unsigned)m_Drill.x,msg); - Line += wxT(" ") + msg; - Affiche_1_Parametre(frame, pos,_("Drill X / Y"),Line,RED); - } - - - int module_orient = Module ? Module->m_Orient : 0; - if( module_orient ) - Line.Printf( wxT("%3.1f(+%3.1f)"), - (float)(m_Orient - module_orient) /10, (float)module_orient /10); - else - Line.Printf( wxT("%3.1f"), (float) m_Orient /10); - pos += 8; - Affiche_1_Parametre(frame, pos,_("Orient"),Line,BLUE); + case SOLDERPASTE_LAYER_CMP: + LayerInfo = ReturnPcbLayerName( SOLDERPASTE_N_CMP ); + break; - valeur_param(m_Pos.x,Line); - pos += 8; - Affiche_1_Parametre(frame, pos,_("X Pos"),Line,BLUE) ; + case SILKSCREEN_LAYER_CU: + LayerInfo = ReturnPcbLayerName( SILKSCREEN_N_CU ); + break; - valeur_param(m_Pos.y,Line); - pos += 6; - Affiche_1_Parametre(frame, pos,_("Y pos"),Line,BLUE) ; + case SILKSCREEN_LAYER_CMP: + LayerInfo = ReturnPcbLayerName( SILKSCREEN_N_CMP ); + break; + + case SOLDERMASK_LAYER_CU: + LayerInfo = ReturnPcbLayerName( SOLDERMASK_N_CU ); + break; + + case SOLDERMASK_LAYER_CMP: + LayerInfo = ReturnPcbLayerName( SOLDERMASK_N_CMP ); + break; + + case DRAW_LAYER: + LayerInfo = ReturnPcbLayerName( DRAW_N ); + break; + + case COMMENT_LAYER: + LayerInfo = ReturnPcbLayerName( COMMENT_N ); + break; + + case ECO1_LAYER: + LayerInfo = ReturnPcbLayerName( ECO1_N ); + break; + + case ECO2_LAYER: + LayerInfo = ReturnPcbLayerName( ECO2_N ); + break; + + case EDGE_LAYER: + LayerInfo = ReturnPcbLayerName( EDGE_N ); + break; + + default: + break; + } + } + pos += 3; + Affiche_1_Parametre( frame, pos, _( "Layer" ), LayerInfo, DARKGREEN ); + + pos += 6; + Affiche_1_Parametre( frame, pos, Msg_Pad_Shape[m_PadShape], wxEmptyString, DARKGREEN ); + /* Affichage en couleur diff si pad stack ou non */ + + if( m_Attribut & PAD_STACK ) + Affiche_1_Parametre( frame, -1, wxEmptyString, Msg_Pad_Attribut[m_Attribut & 15], RED ); + else + Affiche_1_Parametre( frame, + -1, + wxEmptyString, + Msg_Pad_Attribut[m_Attribut & 15], + DARKGREEN ); + + valeur_param( m_Size.x, Line ); + pos += 6; + Affiche_1_Parametre( frame, pos, _( "H Size" ), Line, RED ); + + valeur_param( m_Size.y, Line ); + pos += 7; + Affiche_1_Parametre( frame, pos, _( "V Size" ), Line, RED ); + + pos += 7; + valeur_param( (unsigned) m_Drill.x, Line ); + if( m_DrillShape == CIRCLE ) + { + Affiche_1_Parametre( frame, pos, _( "Drill" ), Line, RED ); + } + else + { + valeur_param( (unsigned) m_Drill.x, Line ); + wxString msg; + valeur_param( (unsigned) m_Drill.x, msg ); + Line += wxT( " " ) + msg; + Affiche_1_Parametre( frame, pos, _( "Drill X / Y" ), Line, RED ); + } + + + int module_orient = Module ? Module->m_Orient : 0; + if( module_orient ) + Line.Printf( wxT( "%3.1f(+%3.1f)" ), + (float) (m_Orient - module_orient) / 10, (float) module_orient / 10 ); + else + Line.Printf( wxT( "%3.1f" ), (float) m_Orient / 10 ); + pos += 8; + Affiche_1_Parametre( frame, pos, _( "Orient" ), Line, BLUE ); + + valeur_param( m_Pos.x, Line ); + pos += 8; + Affiche_1_Parametre( frame, pos, _( "X Pos" ), Line, BLUE ); + + valeur_param( m_Pos.y, Line ); + pos += 6; + Affiche_1_Parametre( frame, pos, _( "Y pos" ), Line, BLUE ); } + +#if defined(DEBUG) +/** + * Function Show + * is used to output the object tree, currently for debugging only. + * @param nestLevel An aid to prettier tree indenting, and is the level + * of nesting of this object within the overall tree. + * @param os The ostream& to output to. + */ +void D_PAD::Show( int nestLevel, std::ostream& os ) +{ + char padname[5] = { m_Padname[0], m_Padname[1], m_Padname[2], m_Padname[3], 0 }; + + char layerMask[16]; + + sprintf( layerMask, "%08X", m_Masque_Layer ); + + // for now, make it look like XML: + NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << + " num=\"" << padname << '"' << + " net=\"" << m_Netname.mb_str() << '"' << + " layerMask=\"" << layerMask << '"' << + " pos=\"(" << m_Pos.x << ',' << m_Pos.y << ")\"" << + "/>\n"; + +// NestedSpace( nestLevel+1, os ) << m_Text.mb_str() << '\n'; + +// NestedSpace( nestLevel, os ) << "\n"; +} + +#endif diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 48b9f410dc..3e6ab7ccd3 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -74,7 +74,7 @@ public: /* supprime du chainage la structure Struct */ void UnLink( void ); - /* Readind and writing data on files */ + /* Reading and writing data on files */ int ReadDescr( FILE* File, int* LineNum = NULL ); int WriteDescr( FILE* File ); @@ -83,7 +83,7 @@ public: void Draw3D( Pcb3D_GLCanvas* glcanvas ); // autres - void SetPadName( const wxString& name ); // Change pade name + void SetPadName( const wxString& name ); // Change pad name wxString ReturnStringPadName( void ); // Return pad name as string in a wxString void ReturnStringPadName( wxString& text ); // Return pad name as string in a buffer void ComputeRayon( void ); // met a jour m_Rayon, rayon du cercle exinscrit @@ -91,6 +91,28 @@ public: // de la forme (pastilles excentrees) void Display_Infos( WinEDA_BasePcbFrame* frame ); + +#if defined(DEBUG) + /** + * Function GetClass + * returns the class name. + * @return wxString + */ + virtual wxString GetClass() const + { + return wxT( "PAD" ); + } + + /** + * Function Show + * is used to output the object tree, currently for debugging only. + * @param nestLevel An aid to prettier tree indenting, and is the level + * of nesting of this object within the overall tree. + * @param os The ostream& to output to. + */ + virtual void Show( int nestLevel, std::ostream& os ); +#endif + }; typedef class D_PAD * LISTE_PAD; diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index 4298c8f4cd..76aa0af1c5 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -11,130 +11,162 @@ #include "pcbnew.h" - /*******************/ - /* class TEXTE_PCB */ - /*******************/ +/*******************/ +/* class TEXTE_PCB */ +/*******************/ -TEXTE_PCB::TEXTE_PCB(EDA_BaseStruct * parent): - EDA_BaseStruct(parent, TYPETEXTE), EDA_TextStruct() +TEXTE_PCB::TEXTE_PCB( EDA_BaseStruct* parent ) : + EDA_BaseStruct( parent, TYPETEXTE ), + EDA_TextStruct() { } + /* Destructeur */ -TEXTE_PCB:: ~TEXTE_PCB(void) +TEXTE_PCB:: ~TEXTE_PCB( void ) { } + /* copie de stucture */ -void TEXTE_PCB::Copy(TEXTE_PCB * source) +void TEXTE_PCB::Copy( TEXTE_PCB* source ) { - m_Parent = source->m_Parent; - Pback = Pnext = NULL; - m_Miroir = source->m_Miroir; - m_Size = source->m_Size; - m_Orient = source->m_Orient; - m_Pos = source->m_Pos; - m_Layer = source->m_Layer; - m_Width = source->m_Width; - m_Attributs = source->m_Attributs; - m_CharType = source->m_CharType; - m_HJustify = source->m_HJustify; - m_VJustify = source->m_VJustify; + m_Parent = source->m_Parent; + Pback = Pnext = NULL; + m_Miroir = source->m_Miroir; + m_Size = source->m_Size; + m_Orient = source->m_Orient; + m_Pos = source->m_Pos; + m_Layer = source->m_Layer; + m_Width = source->m_Width; + m_Attributs = source->m_Attributs; + m_CharType = source->m_CharType; + m_HJustify = source->m_HJustify; + m_VJustify = source->m_VJustify; - m_Text = source->m_Text; + m_Text = source->m_Text; } + void TEXTE_PCB::UnLink( void ) { - /* Modification du chainage arriere */ - if( Pback ) - { - if( Pback->m_StructType != TYPEPCB) - { - Pback->Pnext = Pnext; - } + /* Modification du chainage arriere */ + if( Pback ) + { + if( Pback->m_StructType != TYPEPCB ) + { + Pback->Pnext = Pnext; + } + else /* Le chainage arriere pointe sur la structure "Pere" */ + { + ( (BOARD*) Pback )->m_Drawings = Pnext; + } + } - else /* Le chainage arriere pointe sur la structure "Pere" */ - { - ((BOARD*)Pback)->m_Drawings = Pnext; - } - } + /* Modification du chainage avant */ + if( Pnext ) + Pnext->Pback = Pback; - /* Modification du chainage avant */ - if( Pnext) Pnext->Pback = Pback; - - Pnext = Pback = NULL; + Pnext = Pback = NULL; } + /****************************************************************/ -int TEXTE_PCB::ReadTextePcbDescr(FILE * File, int * LineNum) +int TEXTE_PCB::ReadTextePcbDescr( FILE* File, int* LineNum ) /****************************************************************/ { -char text[1024], Line[1024]; -int dummy; + char text[1024], Line[1024]; + int dummy; - while( GetLine(File, Line, LineNum ) != NULL ) - { - if(strnicmp(Line,"$EndTEXTPCB",11) == 0) return 0; - if( strncmp(Line,"Te", 2) == 0 ) /* Texte */ - { - ReadDelimitedText(text, Line+2, sizeof(text) ); - m_Text = CONV_FROM_UTF8(text); - continue; - } - if( strncmp(Line,"Po", 2) == 0 ) - { - sscanf( Line+2," %d %d %d %d %d %d", - &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Size.y, - &m_Width, &m_Orient); - continue; - } - if( strncmp(Line,"De", 2) == 0 ) - { - sscanf( Line+2," %d %d %lX %d\n",&m_Layer, &m_Miroir, - &m_TimeStamp, &dummy); - if ( m_Layer < LAYER_CUIVRE_N ) - m_Layer = LAYER_CUIVRE_N; - if ( m_Layer > LAST_NO_COPPER_LAYER ) - m_Layer = LAST_NO_COPPER_LAYER; + while( GetLine( File, Line, LineNum ) != NULL ) + { + if( strnicmp( Line, "$EndTEXTPCB", 11 ) == 0 ) + return 0; + if( strncmp( Line, "Te", 2 ) == 0 ) /* Texte */ + { + ReadDelimitedText( text, Line + 2, sizeof(text) ); + m_Text = CONV_FROM_UTF8( text ); + continue; + } + if( strncmp( Line, "Po", 2 ) == 0 ) + { + sscanf( Line + 2, " %d %d %d %d %d %d", + &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Size.y, + &m_Width, &m_Orient ); + continue; + } + if( strncmp( Line, "De", 2 ) == 0 ) + { + sscanf( Line + 2, " %d %d %lX %d\n", &m_Layer, &m_Miroir, + &m_TimeStamp, &dummy ); + if( m_Layer < LAYER_CUIVRE_N ) + m_Layer = LAYER_CUIVRE_N; + if( m_Layer > LAST_NO_COPPER_LAYER ) + m_Layer = LAST_NO_COPPER_LAYER; - continue; - } - } - return(1); + continue; + } + } + + return 1; } /**************************************************/ -int TEXTE_PCB::WriteTextePcbDescr(FILE * File) +int TEXTE_PCB::WriteTextePcbDescr( FILE* File ) /**************************************************/ { - if( GetState(DELETED) ) return(0); + if( GetState( DELETED ) ) + return 0; - if(m_Text.IsEmpty() ) return(0); - fprintf( File,"$TEXTPCB\n"); - fprintf( File,"Te \"%s\"\n",CONV_TO_UTF8(m_Text)); - fprintf( File,"Po %d %d %d %d %d %d\n", - m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Width, m_Orient ); - fprintf( File,"De %d %d %lX %d\n", m_Layer, m_Miroir, m_TimeStamp, 0); - fprintf( File,"$EndTEXTPCB\n"); - return(1); + if( m_Text.IsEmpty() ) + return 0; + fprintf( File, "$TEXTPCB\n" ); + fprintf( File, "Te \"%s\"\n", CONV_TO_UTF8( m_Text ) ); + fprintf( File, "Po %d %d %d %d %d %d\n", + m_Pos.x, m_Pos.y, m_Size.x, m_Size.y, m_Width, m_Orient ); + fprintf( File, "De %d %d %lX %d\n", m_Layer, m_Miroir, m_TimeStamp, 0 ); + fprintf( File, "$EndTEXTPCB\n" ); + return 1; } + /**********************************************************************/ -void TEXTE_PCB::Draw(WinEDA_DrawPanel * panel, wxDC * DC, - const wxPoint & offset, int DrawMode) +void TEXTE_PCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC, + const wxPoint& offset, int DrawMode ) /**********************************************************************/ + /* - DrawMode = GR_OR, GR_XOR.., -1 si mode courant. -*/ + * DrawMode = GR_OR, GR_XOR.., -1 si mode courant. + */ { -int color = g_DesignSettings.m_LayerColor[m_Layer]; - if(color & ITEM_NOT_SHOW ) return ; + int color = g_DesignSettings.m_LayerColor[m_Layer]; - EDA_TextStruct::Draw(panel, DC, offset, color, - DrawMode, DisplayOpt.DisplayDrawItems, - (g_AnchorColor & ITEM_NOT_SHOW) ? -1 : (g_AnchorColor & MASKCOLOR)); + if( color & ITEM_NOT_SHOW ) + return; + EDA_TextStruct::Draw( panel, DC, offset, color, + DrawMode, DisplayOpt.DisplayDrawItems, + (g_AnchorColor & ITEM_NOT_SHOW) ? -1 : (g_AnchorColor & MASKCOLOR) ); } +#if defined(DEBUG) + +/** + * Function Show + * is used to output the object tree, currently for debugging only. + * @param nestLevel An aid to prettier tree indenting, and is the level + * of nesting of this object within the overall tree. + * @param os The ostream& to output to. + */ +void TEXTE_PCB::Show( int nestLevel, std::ostream& os ) +{ + // for now, make it look like XML: + NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n"; + + NestedSpace( nestLevel+1, os ) << m_Text.mb_str() << '\n'; + + NestedSpace( nestLevel, os ) << "\n"; +} + +#endif diff --git a/pcbnew/class_pcb_text.h b/pcbnew/class_pcb_text.h index e40c0ac9ac..8ca4e8ded7 100644 --- a/pcbnew/class_pcb_text.h +++ b/pcbnew/class_pcb_text.h @@ -25,6 +25,28 @@ public: // File Operations: int ReadTextePcbDescr(FILE * File, int * LineNum); int WriteTextePcbDescr(FILE * File); + +#if defined(DEBUG) + /** + * Function GetClass + * returns the class name. + * @return wxString + */ + virtual wxString GetClass() const + { + return wxT("PTEXT"); + } + + /** + * Function Show + * is used to output the object tree, currently for debugging only. + * @param nestLevel An aid to prettier tree indenting, and is the level + * of nesting of this object within the overall tree. + * @param os The ostream& to output to. + */ + virtual void Show( int nestLevel, std::ostream& os ); +#endif + }; #endif // #define CLASS_PCB_TEXT_H diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 712a7a6718..822bcaa413 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -307,10 +307,10 @@ void TEXTE_MODULE::Show( int nestLevel, std::ostream& os ) { // for now, make it look like XML, expand on this later. - NestedSpace( nestLevel, os ) << '<' << ReturnClassName().mb_str() << ">\n"; + NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n"; NestedSpace( nestLevel+1, os ) << m_Text.mb_str() << '\n'; - NestedSpace( nestLevel, os ) << "\n"; + NestedSpace( nestLevel, os ) << "\n"; } #endif diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index 91a3dafc15..c08dd8dc95 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -58,9 +58,18 @@ public: * @return bool - true if a hit, else false */ bool HitTest( const wxPoint& posref ); - #if defined(DEBUG) + /** + * Function GetClass + * returns the class name. + * @return wxString + */ + virtual wxString GetClass() const + { + return wxT( "MTEXT" ); + } + /** * Function Show * is used to output the object tree, currently for debugging only. diff --git a/pcbnew/locate.cpp b/pcbnew/locate.cpp index 3ab3b94d14..c5000f4430 100644 --- a/pcbnew/locate.cpp +++ b/pcbnew/locate.cpp @@ -675,14 +675,17 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer ) for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext ) { shape_pos = pt_pad->ReturnShapePos(); - ux0 = shape_pos.x; uy0 = shape_pos.y; /* pos x,y du centre du pad */ - deltaX = ref_pos.x - ux0; deltaY = ref_pos.y - uy0; + ux0 = shape_pos.x; + uy0 = shape_pos.y; /* pos x,y du centre du pad */ + + deltaX = ref_pos.x - ux0; + deltaY = ref_pos.y - uy0; /* Test rapide: le point a tester doit etre a l'interieur du cercle * exinscrit ... */ if( (abs( deltaX ) > pt_pad->m_Rayon ) - || (abs( deltaY ) > pt_pad->m_Rayon) ) + || (abs( deltaY ) > pt_pad->m_Rayon) ) continue; /* ... et sur la bonne couche */