Commit f8f38438 authored by dickelbeck's avatar dickelbeck

search and debug infrastructure, beautification

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