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,17 +17,17 @@ ...@@ -17,17 +17,17 @@
#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
...@@ -35,12 +35,12 @@ public: ...@@ -35,12 +35,12 @@ public:
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
...@@ -48,60 +48,62 @@ public: ...@@ -48,60 +48,62 @@ public:
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 // Constructor and destructor
WinEDA_DrawPanel(WinEDA_DrawFrame *parent, int id, const wxPoint& pos, const wxSize& size); WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id, const wxPoint& pos, const wxSize& size );
~WinEDA_DrawPanel(void){} ~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); void PrepareGraphicContext( wxDC* DC );
wxPoint CalcAbsolutePosition(const wxPoint & rel_pos); wxPoint CalcAbsolutePosition( const wxPoint& rel_pos );
bool IsPointOnDisplay(wxPoint ref_pos); bool IsPointOnDisplay( wxPoint ref_pos );
void OnPaint(wxPaintEvent & event); void OnPaint( wxPaintEvent& event );
void OnSize(wxSizeEvent & event); void OnSize( wxSizeEvent& event );
void SetBoundaryBox(void); void SetBoundaryBox( void );
void ReDraw(wxDC * DC, bool erasebg = TRUE); void ReDraw( wxDC* DC, bool erasebg = TRUE );
void PrintPage(wxDC * DC, bool Print_Sheet_Ref, int PrintMask); void PrintPage( wxDC* DC, bool Print_Sheet_Ref, int PrintMask );
void DrawBackGround(wxDC * DC); void DrawBackGround( wxDC* DC );
void m_Draw_Auxiliary_Axis(wxDC * DC, int drawmode); void m_Draw_Auxiliary_Axis( wxDC* DC, int drawmode );
void OnEraseBackground(wxEraseEvent& event); void OnEraseBackground( wxEraseEvent& event );
void OnActivate(wxActivateEvent& event); void OnActivate( wxActivateEvent& event );
/* Mouse and keys events */ /* Mouse and keys events */
void OnMouseEvent(wxMouseEvent& event); void OnMouseEvent( wxMouseEvent& event );
void OnMouseLeaving(wxMouseEvent& event); void OnMouseLeaving( wxMouseEvent& event );
void OnKeyEvent(wxKeyEvent& event); void OnKeyEvent( wxKeyEvent& event );
/*************************/ /*************************/
void EraseScreen(wxDC * DC); void EraseScreen( wxDC* DC );
void OnScrollWin( wxCommandEvent &event ); void OnScrollWin( wxCommandEvent& event );
void OnScroll( wxScrollWinEvent &event ); void OnScroll( wxScrollWinEvent& event );
void SetZoom(int mode); void SetZoom( int mode );
int GetZoom(void); int GetZoom( void );
void SetGrid(const wxSize & size); void SetGrid( const wxSize& size );
wxSize GetGrid(void); wxSize GetGrid( void );
void AddMenuZoom( wxMenu * MasterMenu ); void AddMenuZoom( wxMenu* MasterMenu );
void OnRightClick(wxMouseEvent& event); void OnRightClick( wxMouseEvent& event );
void Process_Popup_Zoom( wxCommandEvent &event ); void Process_Popup_Zoom( wxCommandEvent& event );
void Process_Special_Functions(wxCommandEvent& event); void Process_Special_Functions( wxCommandEvent& event );
wxPoint CursorRealPosition(const wxPoint & ScreenPos); wxPoint CursorRealPosition( const wxPoint& ScreenPos );
wxPoint CursorScreenPosition(void); wxPoint CursorScreenPosition( void );
wxPoint GetScreenCenterRealPosition(void); wxPoint GetScreenCenterRealPosition( void );
void MouseToCursorSchema(void); void MouseToCursorSchema( void );
void MouseTo(const wxPoint & Mouse); void MouseTo( const wxPoint& Mouse );
/* Cursor functions */ /* Cursor functions */
void Trace_Curseur(wxDC * DC, int color = WHITE); // Draw the user cursor (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 void CursorOff( wxDC* DC ); // remove the grid cursor from the display
void CursorOn(wxDC * DC); // display the grid cursor void CursorOn( wxDC* DC ); // display the grid cursor
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
...@@ -116,7 +118,8 @@ typedef enum { /* definition de l'etat du block */ ...@@ -116,7 +118,8 @@ typedef enum { /* definition de l'etat du block */
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 {
...@@ -135,33 +138,35 @@ typedef enum { ...@@ -135,33 +138,35 @@ typedef enum {
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 */
...@@ -170,31 +175,31 @@ public: ...@@ -170,31 +175,31 @@ public:
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 */
...@@ -213,62 +218,76 @@ private: ...@@ -213,62 +218,76 @@ private:
/* 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";
...@@ -1173,6 +1173,10 @@ void MODULE::Show( int nestLevel, std::ostream& os ) ...@@ -1173,6 +1173,10 @@ void MODULE::Show( int nestLevel, std::ostream& os )
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 );
...@@ -1183,12 +1187,12 @@ void MODULE::Show( int nestLevel, std::ostream& os ) ...@@ -1183,12 +1187,12 @@ void MODULE::Show( int nestLevel, std::ostream& os )
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 */
...@@ -56,6 +56,7 @@ public: ...@@ -56,6 +56,7 @@ public:
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.
...@@ -82,7 +83,6 @@ public: ...@@ -82,7 +83,6 @@ public:
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 );
void SetOrientation( int newangle ); void SetOrientation( int newangle );
...@@ -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,20 +21,20 @@ ...@@ -21,20 +21,20 @@
#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
...@@ -47,46 +47,50 @@ D_PAD::D_PAD(MODULE * parent): EDA_BaseStruct( parent, TYPEPAD) ...@@ -47,46 +47,50 @@ D_PAD::D_PAD(MODULE * parent): EDA_BaseStruct( parent, TYPEPAD)
} }
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,57 +98,68 @@ int dX, dY; ...@@ -94,57 +98,68 @@ 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(); len = name.Length();
if ( len > 4 ) len = 4; if( len > 4 )
for (ii = 0; ii < len; ii ++ ) m_Padname[ii] = name.GetChar(ii); len = 4;
for (ii = len; ii < 4; ii ++ ) m_Padname[ii] = 0; 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_Pos = source->m_Pos;
m_Masque_Layer = source->m_Masque_Layer; m_Masque_Layer = source->m_Masque_Layer;
memcpy(m_Padname,source->m_Padname, sizeof(m_Padname));/* nom de la pastille */ 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_NetCode = source->m_NetCode; /* Numero de net pour comparaisons rapides */
m_Drill = source->m_Drill; // Diametre de percage m_Drill = source->m_Drill; // Diametre de percage
m_DrillShape = source->m_DrillShape; m_DrillShape = source->m_DrillShape;
...@@ -159,118 +174,136 @@ void D_PAD::Copy(D_PAD * source) ...@@ -159,118 +174,136 @@ void D_PAD::Copy(D_PAD * source)
m_Orient = source->m_Orient; // en 1/10 degres m_Orient = source->m_Orient; // en 1/10 degres
m_logical_connexion = 0; // variable utilisee lors du calcul du chevelu m_logical_connexion = 0; // variable utilisee lors du calcul du chevelu
m_physical_connexion = 0; // variable utilisee lors du calcul de la connexit 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) Pnext->Pback = Pback; 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 : /* 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 )
color |= g_PadCUColor;
if( color == 0) /* Not on copper layer */ if( color == 0 ) /* Not on copper layer */
{ {
switch ( m_Masque_Layer & ~ALL_CU_LAYERS ) switch( m_Masque_Layer & ~ALL_CU_LAYERS )
{ {
case ADHESIVE_LAYER_CU: case ADHESIVE_LAYER_CU:
color = g_DesignSettings.m_LayerColor[ADHESIVE_N_CU]; color = g_DesignSettings.m_LayerColor[ADHESIVE_N_CU];
break; break;
case ADHESIVE_LAYER_CMP: case ADHESIVE_LAYER_CMP:
color = g_DesignSettings.m_LayerColor[ADHESIVE_N_CMP]; color = g_DesignSettings.m_LayerColor[ADHESIVE_N_CMP];
break; break;
case SOLDERPASTE_LAYER_CU: case SOLDERPASTE_LAYER_CU:
color = g_DesignSettings.m_LayerColor[SOLDERPASTE_N_CU]; color = g_DesignSettings.m_LayerColor[SOLDERPASTE_N_CU];
break; break;
case SOLDERPASTE_LAYER_CMP: case SOLDERPASTE_LAYER_CMP:
color = g_DesignSettings.m_LayerColor[SOLDERPASTE_N_CMP]; color = g_DesignSettings.m_LayerColor[SOLDERPASTE_N_CMP];
break; break;
case SILKSCREEN_LAYER_CU: case SILKSCREEN_LAYER_CU:
color = g_DesignSettings.m_LayerColor[SILKSCREEN_N_CU]; color = g_DesignSettings.m_LayerColor[SILKSCREEN_N_CU];
break; break;
case SILKSCREEN_LAYER_CMP: case SILKSCREEN_LAYER_CMP:
color = g_DesignSettings.m_LayerColor[SILKSCREEN_N_CMP]; color = g_DesignSettings.m_LayerColor[SILKSCREEN_N_CMP];
break; break;
case SOLDERMASK_LAYER_CU: case SOLDERMASK_LAYER_CU:
color = g_DesignSettings.m_LayerColor[SOLDERMASK_N_CU]; color = g_DesignSettings.m_LayerColor[SOLDERMASK_N_CU];
break; break;
case SOLDERMASK_LAYER_CMP: case SOLDERMASK_LAYER_CMP:
color = g_DesignSettings.m_LayerColor[SOLDERMASK_N_CMP]; color = g_DesignSettings.m_LayerColor[SOLDERMASK_N_CMP];
break; break;
case DRAW_LAYER :
case DRAW_LAYER:
color = g_DesignSettings.m_LayerColor[DRAW_N]; color = g_DesignSettings.m_LayerColor[DRAW_N];
break; break;
case COMMENT_LAYER: case COMMENT_LAYER:
color = g_DesignSettings.m_LayerColor[COMMENT_N]; color = g_DesignSettings.m_LayerColor[COMMENT_N];
break; break;
case ECO1_LAYER: case ECO1_LAYER:
color = g_DesignSettings.m_LayerColor[ECO1_N]; color = g_DesignSettings.m_LayerColor[ECO1_N];
break; break;
case ECO2_LAYER :
case ECO2_LAYER:
color = g_DesignSettings.m_LayerColor[ECO2_N]; color = g_DesignSettings.m_LayerColor[ECO2_N];
break; break;
case EDGE_LAYER: case EDGE_LAYER:
color = g_DesignSettings.m_LayerColor[EDGE_N]; color = g_DesignSettings.m_LayerColor[EDGE_N];
break; break;
...@@ -281,15 +314,17 @@ wxPoint shape_pos; ...@@ -281,15 +314,17 @@ wxPoint shape_pos;
} }
} }
if ( draw_mode & GR_SURBRILL ) if( draw_mode & GR_SURBRILL )
{ {
if(draw_mode & GR_AND) color &= ~HIGHT_LIGHT_FLAG; if( draw_mode & GR_AND )
else color |= HIGHT_LIGHT_FLAG; color &= ~HIGHT_LIGHT_FLAG;
else
color |= HIGHT_LIGHT_FLAG;
} }
if ( color & HIGHT_LIGHT_FLAG) if( color & HIGHT_LIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor; color = ColorRefs[color & MASKCOLOR].m_LightColor;
GRSetDrawMode(DC, draw_mode); /* mode de trace */ GRSetDrawMode( DC, draw_mode ); /* mode de trace */
/* calcul du centre des pads en coordonnees Ecran : */ /* calcul du centre des pads en coordonnees Ecran : */
shape_pos = ReturnShapePos(); shape_pos = ReturnShapePos();
...@@ -300,27 +335,35 @@ wxPoint shape_pos; ...@@ -300,27 +335,35 @@ wxPoint shape_pos;
/* 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 : case CIRCLE:
if ( fillpad) if( fillpad )
GRFilledCircle(&panel->m_ClipBox, DC, xc, yc, dx, 0, color, color); GRFilledCircle( &panel->m_ClipBox, DC, xc, yc, dx, 0, color, color );
else GRCircle(&panel->m_ClipBox, DC, xc, yc, dx, 0, color); else
GRCircle( &panel->m_ClipBox, DC, xc, yc, dx, 0, color );
if(DisplayIsol) if( DisplayIsol )
{ {
GRCircle(&panel->m_ClipBox, DC, xc, yc, dx + g_DesignSettings.m_TrackClearence, 0, color ); GRCircle( &panel->m_ClipBox,
DC,
xc,
yc,
dx + g_DesignSettings.m_TrackClearence,
0,
color );
} }
break; break;
case OVALE : case OVALE:
/* calcul de l'entraxe de l'ellipse */ /* calcul de l'entraxe de l'ellipse */
if( dx > dy ) /* ellipse horizontale */ if( dx > dy ) /* ellipse horizontale */
{ {
...@@ -332,62 +375,61 @@ wxPoint shape_pos; ...@@ -332,62 +375,61 @@ wxPoint shape_pos;
delta_cx = 0; delta_cy = dy - dx; delta_cx = 0; delta_cy = dy - dx;
rotdx = m_Size.x; rotdx = m_Size.x;
} }
RotatePoint(&delta_cx, &delta_cy, angle); RotatePoint( &delta_cx, &delta_cy, angle );
if (fillpad) if( fillpad )
{ {
GRFillCSegm(&panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, GRFillCSegm( &panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy,
ux0 - delta_cx, uy0 - delta_cy, ux0 - delta_cx, uy0 - delta_cy,
rotdx, color); rotdx, color );
} }
else else
{ {
GRCSegm(&panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, GRCSegm( &panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy,
ux0 - delta_cx, uy0 - delta_cy, ux0 - delta_cx, uy0 - delta_cy,
rotdx, color); rotdx, color );
} }
/* Trace de la marge d'isolement */ /* Trace de la marge d'isolement */
if(DisplayIsol) if( DisplayIsol )
{ {
rotdx = rotdx + g_DesignSettings.m_TrackClearence + g_DesignSettings.m_TrackClearence; rotdx = rotdx + g_DesignSettings.m_TrackClearence + g_DesignSettings.m_TrackClearence;
GRCSegm(&panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, GRCSegm( &panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy,
ux0 - delta_cx, uy0 - delta_cy, ux0 - delta_cx, uy0 - delta_cy,
rotdx, color); rotdx, color );
} }
break; break;
case RECT : case RECT:
case SPECIAL_PAD: case SPECIAL_PAD:
case TRAPEZE: case TRAPEZE:
{ {
int ddx, ddy ; int ddx, ddy;
ddx = m_DeltaSize.x >> 1 ; ddx = m_DeltaSize.x >> 1;
ddy = m_DeltaSize.y >> 1 ; /* demi dim dx et dy */ ddy = m_DeltaSize.y >> 1; /* demi dim dx et dy */
coord[0].x = - dx - ddy; coord[0].x = -dx - ddy;
coord[0].y = + dy + ddx; coord[0].y = +dy + ddx;
coord[1].x = - dx + ddy; coord[1].x = -dx + ddy;
coord[1].y = - dy - ddx; coord[1].y = -dy - ddx;
coord[2].x = + dx - ddy; coord[2].x = +dx - ddy;
coord[2].y = - dy + ddx; coord[2].y = -dy + ddx;
coord[3].x = + dx + ddy; coord[3].x = +dx + ddy;
coord[3].y = + dy - ddx; coord[3].y = +dy - ddx;
for (ii = 0; ii < 4; ii++) for( ii = 0; ii < 4; ii++ )
{ {
RotatePoint(&coord[ii].x,&coord[ii].y, angle); RotatePoint( &coord[ii].x, &coord[ii].y, angle );
coord[ii].x = coord[ii].x + ux0; coord[ii].x = coord[ii].x + ux0;
coord[ii].y = coord[ii].y + uy0; 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) if( DisplayIsol )
{ {
dx += g_DesignSettings.m_TrackClearence; dy += g_DesignSettings.m_TrackClearence; dx += g_DesignSettings.m_TrackClearence; dy += g_DesignSettings.m_TrackClearence;
coord[0].x = -dx - ddy; coord[0].x = -dx - ddy;
...@@ -402,14 +444,14 @@ wxPoint shape_pos; ...@@ -402,14 +444,14 @@ wxPoint shape_pos;
coord[3].x = dx + ddy; coord[3].x = dx + ddy;
coord[3].y = dy - ddx; coord[3].y = dy - ddx;
for (ii = 0; ii < 4; ii++) for( ii = 0; ii < 4; ii++ )
{ {
RotatePoint(&coord[ii].x,&coord[ii].y, angle); RotatePoint( &coord[ii].x, &coord[ii].y, angle );
coord[ii].x = coord[ii].x + ux0; coord[ii].x = coord[ii].x + ux0;
coord[ii].y = coord[ii].y + uy0; coord[ii].y = coord[ii].y + uy0;
} }
GRClosedPoly(&panel->m_ClipBox, DC, 4, (int*)coord, 0, color, color); GRClosedPoly( &panel->m_ClipBox, DC, 4, (int*) coord, 0, color, color );
} }
break; break;
...@@ -421,23 +463,26 @@ wxPoint shape_pos; ...@@ -421,23 +463,26 @@ wxPoint shape_pos;
/* Draw the pad hole */ /* Draw the pad hole */
int cx0 = m_Pos.x - offset.x; int cx0 = m_Pos.x - offset.x;
int cy0 = m_Pos.y - offset.y; int cy0 = m_Pos.y - offset.y;
int hole = m_Drill.x >> 1 ; int hole = m_Drill.x >> 1;
if( fillpad && hole ) if( fillpad && hole )
{ {
color = g_IsPrinting ? WHITE : BLACK; // ou DARKGRAY; color = g_IsPrinting ? WHITE : BLACK; // ou DARKGRAY;
if(draw_mode != GR_XOR) GRSetDrawMode(DC, GR_COPY); if( draw_mode != GR_XOR )
else GRSetDrawMode(DC, GR_XOR); GRSetDrawMode( DC, GR_COPY );
switch ( m_DrillShape ) else
GRSetDrawMode( DC, GR_XOR );
switch( m_DrillShape )
{ {
case CIRCLE: case CIRCLE:
if( (hole/zoom) > 1 ) /* draw hole if its size is enought */ if( (hole / zoom) > 1 ) /* draw hole if its size is enought */
GRFilledCircle(&panel->m_ClipBox, DC, cx0, cy0, hole, 0, color, color); GRFilledCircle( &panel->m_ClipBox, DC, cx0, cy0, hole, 0, color, color );
break; break;
case OVALE: case OVALE:
dx = m_Drill.x >> 1 ; dx = m_Drill.x >> 1;
dy = m_Drill.y >> 1 ; /* demi dim dx et dy */ dy = m_Drill.y >> 1; /* demi dim dx et dy */
/* calcul de l'entraxe de l'ellipse */ /* calcul de l'entraxe de l'ellipse */
if( m_Drill.x > m_Drill.y ) /* ellipse horizontale */ if( m_Drill.x > m_Drill.y ) /* ellipse horizontale */
{ {
...@@ -449,11 +494,11 @@ wxPoint shape_pos; ...@@ -449,11 +494,11 @@ wxPoint shape_pos;
delta_cx = 0; delta_cy = dy - dx; delta_cx = 0; delta_cy = dy - dx;
rotdx = m_Drill.x; rotdx = m_Drill.x;
} }
RotatePoint(&delta_cx, &delta_cy, angle); RotatePoint( &delta_cx, &delta_cy, angle );
GRFillCSegm(&panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy, GRFillCSegm( &panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy,
ux0 - delta_cx, uy0 - delta_cy, ux0 - delta_cx, uy0 - delta_cy,
rotdx, color); rotdx, color );
break; break;
default: default:
...@@ -461,75 +506,85 @@ wxPoint shape_pos; ...@@ -461,75 +506,85 @@ wxPoint shape_pos;
} }
} }
GRSetDrawMode(DC, draw_mode); GRSetDrawMode( DC, draw_mode );
/* Trace du symbole "No connect" ( / ou \ ou croix en X) si necessaire : */ /* Trace du symbole "No connect" ( / ou \ ou croix en X) si necessaire : */
if( m_Netname.IsEmpty() && DisplayOpt.DisplayPadNoConn ) if( m_Netname.IsEmpty() && DisplayOpt.DisplayPadNoConn )
{ {
dx0 = min(dx0,dy0); dx0 = min( dx0, dy0 );
int nc_color = BLUE; int nc_color = BLUE;
if(m_Masque_Layer & CMP_LAYER) /* Trace forme \ */ if( m_Masque_Layer & CMP_LAYER ) /* Trace forme \ */
GRLine(&panel->m_ClipBox, DC, cx0 - dx0, cy0 - dx0, GRLine( &panel->m_ClipBox, DC, cx0 - dx0, cy0 - dx0,
cx0 + dx0, cy0 + dx0, 0, nc_color ); cx0 + dx0, cy0 + dx0, 0, nc_color );
if(m_Masque_Layer & CUIVRE_LAYER) /* Trace forme / */ if( m_Masque_Layer & CUIVRE_LAYER ) /* Trace forme / */
GRLine(&panel->m_ClipBox, DC, cx0 + dx0, cy0 - dx0, GRLine( &panel->m_ClipBox, DC, cx0 + dx0, cy0 - dx0,
cx0 - dx0, cy0 + dx0, 0, nc_color ); cx0 - dx0, cy0 + dx0, 0, nc_color );
} }
/* Trace de la reference */ /* Trace de la reference */
if( ! frame->m_DisplayPadNum) return; if( !frame->m_DisplayPadNum )
dx = min(m_Size.x, m_Size.y); /* dx = text size */ return;
dx = min( m_Size.x, m_Size.y ); /* dx = text size */
if( (dx / zoom) > 12 ) /* size must be enought to draw 2 chars */ if( (dx / zoom) > 12 ) /* size must be enought to draw 2 chars */
{ {
wxString buffer; wxString buffer;
ReturnStringPadName(buffer); ReturnStringPadName( buffer );
dy = buffer.Len(); dy = buffer.Len();
/* Draw text with an angle between -90 deg and + 90 deg */ /* Draw text with an angle between -90 deg and + 90 deg */
NORMALIZE_ANGLE_90(angle); NORMALIZE_ANGLE_90( angle );
if ( dy < 2 ) dy = 2; /* text min size is 2 char */ if( dy < 2 )
dy = 2; /* text min size is 2 char */
dx = (dx * 9 ) / (dy * 13 ); /* Text size ajusted to pad size */ dx = (dx * 9 ) / (dy * 13 ); /* Text size ajusted to pad size */
DrawGraphicText(panel, DC, wxPoint(ux0, uy0), DrawGraphicText( panel, DC, wxPoint( ux0, uy0 ),
WHITE, buffer, angle, wxSize(dx, dx), WHITE, buffer, angle, wxSize( dx, dx ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER); 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 */ PtLine = Line + 3;
/* Pointe 1er code utile de la ligne */
switch( Line[0] ) switch( Line[0] )
{ {
case 'S': /* Ligne de description de forme et dims*/ case 'S': /* Ligne de description de forme et dims*/
/* Lecture du nom pad */ /* Lecture du nom pad */
nn = 0; nn = 0;
while( (*PtLine != '"') && *PtLine ) PtLine++; while( (*PtLine != '"') && *PtLine )
if ( *PtLine ) PtLine++; PtLine++;
memset(m_Padname,0 ,sizeof(m_Padname) );
if( *PtLine )
PtLine++;
memset( m_Padname, 0, sizeof(m_Padname) );
while( (*PtLine != '"') && *PtLine ) while( (*PtLine != '"') && *PtLine )
{ {
if(nn < (int) sizeof(m_Padname)) if( nn < (int) sizeof(m_Padname) )
{ {
if( * PtLine > ' ' ) if( *PtLine > ' ' )
{ {
m_Padname[nn] = *PtLine; nn++; m_Padname[nn] = *PtLine; nn++;
} }
...@@ -537,36 +592,46 @@ int nn, ll, dx, dy; ...@@ -537,36 +592,46 @@ int nn, ll, dx, dy;
PtLine++; PtLine++;
} }
if ( *PtLine == '"' ) PtLine++; if( *PtLine == '"' )
PtLine++;
nn = sscanf(PtLine," %s %d %d %d %d %d", nn = sscanf( PtLine, " %s %d %d %d %d %d",
BufCar, &m_Size.x, &m_Size.y, BufCar, &m_Size.x, &m_Size.y,
&m_DeltaSize.x, &m_DeltaSize.y, &m_DeltaSize.x, &m_DeltaSize.y,
&m_Orient); &m_Orient );
ll = 0xFF & BufCar[0]; ll = 0xFF & BufCar[0];
/* Mise a jour de la forme */ /* Mise a jour de la forme */
m_PadShape = CIRCLE; m_PadShape = CIRCLE;
switch(ll)
switch( ll )
{ {
case 'C': m_PadShape = CIRCLE; break; case 'C':
case 'R': m_PadShape = RECT; break; m_PadShape = CIRCLE; break;
case 'O': m_PadShape = OVALE; break;
case 'T': m_PadShape = TRAPEZE; break; case 'R':
m_PadShape = RECT; break;
case 'O':
m_PadShape = OVALE; break;
case 'T':
m_PadShape = TRAPEZE; break;
} }
ComputeRayon(); ComputeRayon();
break; break;
case 'D': case 'D':
BufCar[0] = 0; BufCar[0] = 0;
nn = sscanf(PtLine,"%d %d %d %s %d %d", &m_Drill.x, nn = sscanf( PtLine, "%d %d %d %s %d %d", &m_Drill.x,
&m_Offset.x, &m_Offset.y, BufCar, &dx, &dy ); &m_Offset.x, &m_Offset.y, BufCar, &dx, &dy );
m_Drill.y = m_Drill.x; m_Drill.y = m_Drill.x;
m_DrillShape = CIRCLE; m_DrillShape = CIRCLE;
if (nn >= 6 ) // Drill shape = OVAL ? if( nn >= 6 ) // Drill shape = OVAL ?
{ {
if (BufCar[0] == 'O' ) if( BufCar[0] == 'O' )
{ {
m_Drill.x = dx; m_Drill.y = dy; m_Drill.x = dx; m_Drill.y = dy;
m_DrillShape = OVALE; m_DrillShape = OVALE;
...@@ -575,191 +640,246 @@ int nn, ll, dx, dy; ...@@ -575,191 +640,246 @@ int nn, ll, dx, dy;
break; break;
case 'A': case 'A':
nn = sscanf(PtLine,"%s %s %X", BufLine, BufCar, nn = sscanf( PtLine, "%s %s %X", BufLine, BufCar,
&m_Masque_Layer); &m_Masque_Layer );
/* Contenu de BufCar non encore utilise ( reserve pour evolutions /* Contenu de BufCar non encore utilise ( reserve pour evolutions
ulterieures */ * ulterieures */
/* Mise a jour de l'attribut */ /* Mise a jour de l'attribut */
m_Attribut = STANDARD; m_Attribut = STANDARD;
if( strncmp(BufLine,"SMD",3) == 0 ) m_Attribut = SMD; if( strncmp( BufLine, "SMD", 3 ) == 0 )
if( strncmp(BufLine,"CONN",4) == 0 ) m_Attribut = CONN; m_Attribut = SMD;
if( strncmp(BufLine,"HOLE",4) == 0 ) m_Attribut = P_HOLE; if( strncmp( BufLine, "CONN", 4 ) == 0 )
if( strncmp(BufLine,"MECA",4) == 0 ) m_Attribut = MECA; m_Attribut = CONN;
if( strncmp( BufLine, "HOLE", 4 ) == 0 )
m_Attribut = P_HOLE;
if( strncmp( BufLine, "MECA", 4 ) == 0 )
m_Attribut = MECA;
break; break;
case 'N': /* Lecture du netname */ case 'N': /* Lecture du netname */
nn = sscanf(PtLine,"%d", &m_NetCode); nn = sscanf( PtLine, "%d", &m_NetCode );
/* Lecture du netname */ /* Lecture du netname */
ReadDelimitedText(BufLine, PtLine, sizeof(BufLine)); ReadDelimitedText( BufLine, PtLine, sizeof(BufLine) );
m_Netname = CONV_FROM_UTF8(StrPurge(BufLine)); m_Netname = CONV_FROM_UTF8( StrPurge( BufLine ) );
break; break;
case 'P': case 'P':
nn = sscanf(PtLine,"%d %d", &m_Pos0.x, &m_Pos0.y ); nn = sscanf( PtLine, "%d %d", &m_Pos0.x, &m_Pos0.y );
m_Pos = m_Pos0; m_Pos = m_Pos0;
break; break;
default: default:
DisplayError(NULL, wxT("Err Pad: Id inconnu")); DisplayError( NULL, wxT( "Err Pad: Id inconnu" ) );
return(1); return 1;
} }
} }
return(2); /* error : EOF */
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;
if( GetState(DELETED) ) return(NbLigne); char* texttype;
if( GetState( DELETED ) )
return NbLigne;
/* Generation du fichier pad: */ /* Generation du fichier pad: */
fprintf( File,"$PAD\n"); NbLigne++; fprintf( File, "$PAD\n" ); NbLigne++;
switch(m_PadShape)
switch( m_PadShape )
{ {
case CIRCLE: cshape = 'C'; break; case CIRCLE:
case RECT: cshape = 'R'; break; cshape = 'C'; break;
case OVALE: cshape = 'O'; break;
case TRAPEZE: cshape = 'T'; break; case RECT:
default: cshape = 'C'; cshape = 'R'; break;
DisplayError(NULL, _("Unknown Pad shape"));
case OVALE:
cshape = 'O'; break;
case TRAPEZE:
cshape = 'T'; break;
default:
cshape = 'C';
DisplayError( NULL, _( "Unknown Pad shape" ) );
break; break;
} }
fprintf(File,"Sh \"%.4s\" %c %d %d %d %d %d\n",
fprintf( File, "Sh \"%.4s\" %c %d %d %d %d %d\n",
m_Padname, cshape, m_Size.x, m_Size.y, m_Padname, cshape, m_Size.x, m_Size.y,
m_DeltaSize.x, m_DeltaSize.y,m_Orient); m_DeltaSize.x, m_DeltaSize.y, m_Orient );
NbLigne++; NbLigne++;
fprintf(File,"Dr %d %d %d", m_Drill.x, m_Offset.x, m_Offset.y ); fprintf( File, "Dr %d %d %d", m_Drill.x, m_Offset.x, m_Offset.y );
if ( m_DrillShape == OVALE ) if( m_DrillShape == OVALE )
{ {
fprintf(File," %c %d %d", 'O', m_Drill.x, m_Drill.y ); fprintf( File, " %c %d %d", 'O', m_Drill.x, m_Drill.y );
} }
fprintf(File,"\n"); fprintf( File, "\n" );
NbLigne++; NbLigne++;
switch(m_Attribut)
switch( m_Attribut )
{ {
case STANDARD: texttype = "STD"; break; case STANDARD:
case SMD: texttype = "SMD"; break; texttype = "STD"; break;
case CONN: texttype = "CONN"; break;
case P_HOLE: texttype = "HOLE"; break; case SMD:
case MECA: texttype = "MECA"; break; texttype = "SMD"; break;
case CONN:
texttype = "CONN"; break;
case P_HOLE:
texttype = "HOLE"; break;
case MECA:
texttype = "MECA"; break;
default: default:
texttype = "STD"; texttype = "STD";
DisplayError(NULL, wxT("attribut Pad inconnu")); DisplayError( NULL, wxT( "attribut Pad inconnu" ) );
break; break;
} }
fprintf(File,"At %s N %8.8X\n", texttype, m_Masque_Layer);
fprintf( File, "At %s N %8.8X\n", texttype, m_Masque_Layer );
NbLigne++; NbLigne++;
fprintf(File,"Ne %d \"%s\"\n", m_NetCode,CONV_TO_UTF8(m_Netname)); fprintf( File, "Ne %d \"%s\"\n", m_NetCode, CONV_TO_UTF8( m_Netname ) );
NbLigne++; NbLigne++;
fprintf(File,"Po %d %d\n", m_Pos0.x, m_Pos0.y ); fprintf( File, "Po %d %d\n", m_Pos0.x, m_Pos0.y );
NbLigne++; NbLigne++;
fprintf( File,"$EndPAD\n"); fprintf( File, "$EndPAD\n" );
NbLigne++; NbLigne++;
return(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] =
{ wxT("??? "), wxT("Circ"), wxT("Rect"), wxT("Oval"), wxT("trap"), wxT("spec") } ;
wxString Msg_Pad_Layer[9] = /* Pad messages */
{ wxT("??? "), wxT("cmp "), wxT("cu "), wxT("cmp+cu "), wxT("int "), static const wxString Msg_Pad_Shape[6] =
wxT("cmp+int "), wxT("cu+int "), wxT("all "), wxT("No copp") } ; { wxT( "??? " ), wxT( "Circ" ), wxT( "Rect" ), wxT( "Oval" ), wxT( "trap" ), wxT( "spec" ) };
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 */ /* Recherche du module correspondant */
Module = (MODULE *) m_Parent; Module = (MODULE*) m_Parent;
if(Module) if( Module )
{ {
wxString msg = Module->m_Reference->m_Text; wxString msg = Module->m_Reference->m_Text;
Affiche_1_Parametre(frame, pos,_("Module"), msg, DARKCYAN) ; Affiche_1_Parametre( frame, pos, _( "Module" ), msg, DARKCYAN );
ReturnStringPadName(Line); ReturnStringPadName( Line );
pos += 8; pos += 8;
Affiche_1_Parametre(frame, pos,_("RefP"),Line,BROWN) ; Affiche_1_Parametre( frame, pos, _( "RefP" ), Line, BROWN );
} }
pos += 4; pos += 4;
Affiche_1_Parametre(frame, pos,_("Net"),m_Netname, DARKCYAN); Affiche_1_Parametre( frame, pos, _( "Net" ), m_Netname, DARKCYAN );
/* pour mise au point (peut etre supprim) : Affichage du numero de Net et sous net */ /* pour mise au point (peut etre supprim� : Affichage du numero de Net et sous net */
pos += 10; 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;
if( (m_Masque_Layer & ALL_CU_LAYERS) == ALL_CU_LAYERS )
ii = 7;
LayerInfo = Msg_Pad_Layer[ii]; LayerInfo = Msg_Pad_Layer[ii];
if((m_Masque_Layer & ALL_CU_LAYERS) == 0) if( (m_Masque_Layer & ALL_CU_LAYERS) == 0 )
{ {
if(m_Masque_Layer) LayerInfo = Msg_Pad_Layer[8]; if( m_Masque_Layer )
switch ( m_Masque_Layer & ~ALL_CU_LAYERS ) LayerInfo = Msg_Pad_Layer[8];
switch( m_Masque_Layer & ~ALL_CU_LAYERS )
{ {
case ADHESIVE_LAYER_CU: case ADHESIVE_LAYER_CU:
LayerInfo = ReturnPcbLayerName(ADHESIVE_N_CU); LayerInfo = ReturnPcbLayerName( ADHESIVE_N_CU );
break; break;
case ADHESIVE_LAYER_CMP: case ADHESIVE_LAYER_CMP:
LayerInfo = ReturnPcbLayerName(ADHESIVE_N_CMP); LayerInfo = ReturnPcbLayerName( ADHESIVE_N_CMP );
break; break;
case SOLDERPASTE_LAYER_CU: case SOLDERPASTE_LAYER_CU:
LayerInfo = ReturnPcbLayerName(SOLDERPASTE_N_CU); LayerInfo = ReturnPcbLayerName( SOLDERPASTE_N_CU );
break; break;
case SOLDERPASTE_LAYER_CMP: case SOLDERPASTE_LAYER_CMP:
LayerInfo = ReturnPcbLayerName(SOLDERPASTE_N_CMP); LayerInfo = ReturnPcbLayerName( SOLDERPASTE_N_CMP );
break; break;
case SILKSCREEN_LAYER_CU: case SILKSCREEN_LAYER_CU:
LayerInfo = ReturnPcbLayerName(SILKSCREEN_N_CU); LayerInfo = ReturnPcbLayerName( SILKSCREEN_N_CU );
break; break;
case SILKSCREEN_LAYER_CMP: case SILKSCREEN_LAYER_CMP:
LayerInfo = ReturnPcbLayerName(SILKSCREEN_N_CMP); LayerInfo = ReturnPcbLayerName( SILKSCREEN_N_CMP );
break; break;
case SOLDERMASK_LAYER_CU: case SOLDERMASK_LAYER_CU:
LayerInfo = ReturnPcbLayerName(SOLDERMASK_N_CU); LayerInfo = ReturnPcbLayerName( SOLDERMASK_N_CU );
break; break;
case SOLDERMASK_LAYER_CMP: case SOLDERMASK_LAYER_CMP:
LayerInfo = ReturnPcbLayerName(SOLDERMASK_N_CMP); LayerInfo = ReturnPcbLayerName( SOLDERMASK_N_CMP );
break; break;
case DRAW_LAYER :
LayerInfo = ReturnPcbLayerName(DRAW_N); case DRAW_LAYER:
LayerInfo = ReturnPcbLayerName( DRAW_N );
break; break;
case COMMENT_LAYER: case COMMENT_LAYER:
LayerInfo = ReturnPcbLayerName(COMMENT_N); LayerInfo = ReturnPcbLayerName( COMMENT_N );
break; break;
case ECO1_LAYER: case ECO1_LAYER:
LayerInfo = ReturnPcbLayerName(ECO1_N); LayerInfo = ReturnPcbLayerName( ECO1_N );
break; break;
case ECO2_LAYER :
LayerInfo = ReturnPcbLayerName(ECO2_N); case ECO2_LAYER:
LayerInfo = ReturnPcbLayerName( ECO2_N );
break; break;
case EDGE_LAYER: case EDGE_LAYER:
LayerInfo = ReturnPcbLayerName(EDGE_N); LayerInfo = ReturnPcbLayerName( EDGE_N );
break; break;
default: default:
...@@ -767,54 +887,90 @@ wxString Msg_Pad_Attribut[5] = ...@@ -767,54 +887,90 @@ wxString Msg_Pad_Attribut[5] =
} }
} }
pos += 3; pos += 3;
Affiche_1_Parametre(frame, pos,_("Layer"),LayerInfo, DARKGREEN) ; Affiche_1_Parametre( frame, pos, _( "Layer" ), LayerInfo, DARKGREEN );
pos += 6; pos += 6;
Affiche_1_Parametre(frame, pos,Msg_Pad_Shape[m_PadShape],wxEmptyString, DARKGREEN); Affiche_1_Parametre( frame, pos, Msg_Pad_Shape[m_PadShape], wxEmptyString, DARKGREEN );
/* Affichage en couleur diff si pad stack ou non */ /* Affichage en couleur diff si pad stack ou non */
if (m_Attribut & PAD_STACK) if( m_Attribut & PAD_STACK )
Affiche_1_Parametre(frame, -1,wxEmptyString,Msg_Pad_Attribut[m_Attribut&15],RED); 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); else
Affiche_1_Parametre( frame,
-1,
wxEmptyString,
Msg_Pad_Attribut[m_Attribut & 15],
DARKGREEN );
valeur_param(m_Size.x,Line) ; valeur_param( m_Size.x, Line );
pos += 6; pos += 6;
Affiche_1_Parametre(frame, pos,_("H Size"),Line,RED) ; Affiche_1_Parametre( frame, pos, _( "H Size" ), Line, RED );
valeur_param(m_Size.y,Line) ; valeur_param( m_Size.y, Line );
pos += 7; pos += 7;
Affiche_1_Parametre(frame, pos,_("V Size"),Line,RED) ; Affiche_1_Parametre( frame, pos, _( "V Size" ), Line, RED );
pos += 7; pos += 7;
valeur_param((unsigned)m_Drill.x,Line) ; valeur_param( (unsigned) m_Drill.x, Line );
if ( m_DrillShape == CIRCLE ) if( m_DrillShape == CIRCLE )
{ {
Affiche_1_Parametre(frame, pos,_("Drill"),Line,RED); Affiche_1_Parametre( frame, pos, _( "Drill" ), Line, RED );
} }
else else
{ {
valeur_param((unsigned)m_Drill.x,Line); valeur_param( (unsigned) m_Drill.x, Line );
wxString msg; wxString msg;
valeur_param((unsigned)m_Drill.x,msg); valeur_param( (unsigned) m_Drill.x, msg );
Line += wxT(" ") + msg; Line += wxT( " " ) + msg;
Affiche_1_Parametre(frame, pos,_("Drill X / Y"),Line,RED); Affiche_1_Parametre( frame, pos, _( "Drill X / Y" ), Line, RED );
} }
int module_orient = Module ? Module->m_Orient : 0; int module_orient = Module ? Module->m_Orient : 0;
if( module_orient ) if( module_orient )
Line.Printf( wxT("%3.1f(+%3.1f)"), Line.Printf( wxT( "%3.1f(+%3.1f)" ),
(float)(m_Orient - module_orient) /10, (float)module_orient /10); (float) (m_Orient - module_orient) / 10, (float) module_orient / 10 );
else else
Line.Printf( wxT("%3.1f"), (float) m_Orient /10); Line.Printf( wxT( "%3.1f" ), (float) m_Orient / 10 );
pos += 8; pos += 8;
Affiche_1_Parametre(frame, pos,_("Orient"),Line,BLUE); Affiche_1_Parametre( frame, pos, _( "Orient" ), Line, BLUE );
valeur_param(m_Pos.x,Line); valeur_param( m_Pos.x, Line );
pos += 8; pos += 8;
Affiche_1_Parametre(frame, pos,_("X Pos"),Line,BLUE) ; Affiche_1_Parametre( frame, pos, _( "X Pos" ), Line, BLUE );
valeur_param(m_Pos.y,Line); valeur_param( m_Pos.y, Line );
pos += 6; pos += 6;
Affiche_1_Parametre(frame, pos,_("Y pos"),Line,BLUE) ; 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,22 +11,25 @@ ...@@ -11,22 +11,25 @@
#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;
...@@ -44,97 +47,126 @@ void TEXTE_PCB::Copy(TEXTE_PCB * source) ...@@ -44,97 +47,126 @@ void TEXTE_PCB::Copy(TEXTE_PCB * source)
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) Pnext->Pback = Pback; 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]; 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) ); ReadDelimitedText( text, Line + 2, sizeof(text) );
m_Text = CONV_FROM_UTF8(text); m_Text = CONV_FROM_UTF8( text );
continue; continue;
} }
if( strncmp(Line,"Po", 2) == 0 ) if( strncmp( Line, "Po", 2 ) == 0 )
{ {
sscanf( Line+2," %d %d %d %d %d %d", sscanf( Line + 2, " %d %d %d %d %d %d",
&m_Pos.x, &m_Pos.y, &m_Size.x, &m_Size.y, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Size.y,
&m_Width, &m_Orient); &m_Width, &m_Orient );
continue; 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, sscanf( Line + 2, " %d %d %lX %d\n", &m_Layer, &m_Miroir,
&m_TimeStamp, &dummy); &m_TimeStamp, &dummy );
if ( m_Layer < LAYER_CUIVRE_N ) if( m_Layer < LAYER_CUIVRE_N )
m_Layer = LAYER_CUIVRE_N; m_Layer = LAYER_CUIVRE_N;
if ( m_Layer > LAST_NO_COPPER_LAYER ) if( m_Layer > LAST_NO_COPPER_LAYER )
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" );
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 ); 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, "De %d %d %lX %d\n", m_Layer, m_Miroir, m_TimeStamp, 0 );
fprintf( File,"$EndTEXTPCB\n"); fprintf( File, "$EndTEXTPCB\n" );
return(1); 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 ;
if( color & ITEM_NOT_SHOW )
return;
EDA_TextStruct::Draw(panel, DC, offset, color, EDA_TextStruct::Draw( panel, DC, offset, color,
DrawMode, DisplayOpt.DisplayDrawItems, DrawMode, DisplayOpt.DisplayDrawItems,
(g_AnchorColor & ITEM_NOT_SHOW) ? -1 : (g_AnchorColor & MASKCOLOR)); (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
...@@ -59,8 +59,17 @@ public: ...@@ -59,8 +59,17 @@ public:
*/ */
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,9 +675,12 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer ) ...@@ -675,9 +675,12 @@ 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 ... */
......
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