Commit 6719900e authored by dickelbeck's avatar dickelbeck

searching and beautification

parent f8f38438
...@@ -5,6 +5,18 @@ Please add newer entries at the top, list the date and your name with ...@@ -5,6 +5,18 @@ Please add newer entries at the top, list the date and your name with
email address. email address.
2007-Aug-07 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+ pcbnew & common
* More searching work. Made HitTest() virtual. Factored out a HitTest()
function for both class_module and class_pad from existing code.
* Embellished the Show() function for several of the classes. Could be the
basis of a possible future XML export, but with the native format being
ascii already, this is of questionable value as an export.
* Discovered a long time existing bug in class_module hit-testing.
Still need to understand it. It could just be an improperly formatted module.
2007-Aug-06 UPDATE Dick Hollenbeck <dick@softplc.com> 2007-Aug-06 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
+ pcbnew & common + pcbnew & common
......
...@@ -191,6 +191,20 @@ wxString EDA_BaseStruct::ReturnClassName() const ...@@ -191,6 +191,20 @@ wxString EDA_BaseStruct::ReturnClassName() const
#if defined(DEBUG) #if defined(DEBUG)
// A function that should have been in wxWidgets
std::ostream& operator<<( std::ostream& out, wxSize& size )
{
out << " width=\"" << size.GetWidth() << "\" height=\"" << size.GetHeight() << "\"";
return out;
}
// A function that should have been in wxWidgets
std::ostream& operator<<( std::ostream& out, wxPoint& pt )
{
out << " x=\"" << pt.x << "\" y=\"" << pt.y << "\"";
return out;
}
/** /**
* Function Show * Function Show
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#if defined(DEBUG) #if defined(DEBUG)
#include <iostream> // needed for Show() #include <iostream> // needed for Show()
extern std::ostream& operator<<( std::ostream& out, wxSize& size );
extern std::ostream& operator<<( std::ostream& out, wxPoint& pt );
#endif #endif
...@@ -177,6 +179,18 @@ public: ...@@ -177,6 +179,18 @@ public:
const wxPoint& offset, const wxPoint& offset,
int draw_mode, int draw_mode,
int Color = -1 ); int Color = -1 );
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param refPos A wxPoint to test
* @return bool - true if a hit, else false
*/
virtual bool HitTest( const wxPoint& refPos )
{
return false; // derived classes should override this function
}
#if defined(DEBUG) #if defined(DEBUG)
...@@ -330,10 +344,10 @@ public: ...@@ -330,10 +344,10 @@ public:
/** /**
* Function HitTest * Function HitTest
* tests if the given wxPoint is within the bounds of this object. * tests if the given wxPoint is within the bounds of this object.
* @param posref A wxPoint to test * @param ref_pos A wxPoint to test
* @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& ref_pos );
int Len_Size( void ); // Return the text lenght in internal units int Len_Size( void ); // Return the text lenght in internal units
}; };
...@@ -381,9 +395,11 @@ public: ...@@ -381,9 +395,11 @@ public:
}; };
/* class to handle component boundary box. /**
* This class is similar to wxRect, but some wxRect functions are very curious, * Class EDA_Rect
* so I prefer this suitable class * handles the component boundary box.
* This class is similar to wxRect, but some wxRect functions are very curious,
* so I prefer this suitable class
*/ */
class EDA_Rect class EDA_Rect
{ {
......
...@@ -174,16 +174,17 @@ public: ...@@ -174,16 +174,17 @@ public:
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
* Utile pour recadrer les affichages lors de la wxSize m_SizeVisu; /* taille en pixels de l'ecran (fenetre de visu
* navigation dans la hierarchie */ * Utile pour recadrer les affichages lors de la
bool m_Center; // TRUE: coord algebriques, FALSE: coord >= 0 * navigation dans la hierarchie */
bool m_Center; // TRUE: coord algebriques, FALSE: coord >= 0
bool m_FirstRedraw; bool m_FirstRedraw;
/* Gestion des editions */ /* Gestion des editions */
...@@ -273,9 +274,22 @@ public: ...@@ -273,9 +274,22 @@ public:
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 */
/**
* Function RefPos
* returns the reference position, coming from either the mouse position or the
* the cursor position.
* @param useMouse If true, return mouse posistion, else cursor's.
* @return wxPoint - The reference point, either the mouse position or
* the cursor position.
*/
wxPoint RefPos( bool useMouse )
{
return useMouse ? m_MousePosition : m_Curseur;
}
#if defined (DEBUG) #if defined (DEBUG)
/** /**
* Function GetClass * Function GetClass
* returns the class name. * returns the class name.
...@@ -285,7 +299,6 @@ public: ...@@ -285,7 +299,6 @@ public:
{ {
return wxT( "BASE_SCREEN" ); return wxT( "BASE_SCREEN" );
} }
#endif #endif
}; };
......
...@@ -66,16 +66,15 @@ ...@@ -66,16 +66,15 @@
#define ECO1_LAYER 0x04000000 #define ECO1_LAYER 0x04000000
#define ECO2_LAYER 0x08000000 #define ECO2_LAYER 0x08000000
#define EDGE_LAYER 0x10000000 #define EDGE_LAYER 0x10000000
#define intS_LAYER 0xE0000000 /* 4 bits MSB = autres flags */ // extra bits 0xE0000000
/* masques generaux : */ /* masques generaux : */
#define ALL_LAYERS 0x1FFFFFFF #define ALL_LAYERS 0x1FFFFFFF
#define ALL_NO_CU_LAYERS 0x1FFF0000 #define ALL_NO_CU_LAYERS 0x1FFF0000
#define ALL_CU_LAYERS 0x0000FFFF #define ALL_CU_LAYERS 0x0000FFFF
#define INTERNAL_LAYERS 0x00007FFE /* Bits layers internes */ #define INTERNAL_LAYERS 0x00007FFE /* Bits layers internes */
#define EXTERNAL_LAYERS 0x00008001 #define EXTERNAL_LAYERS 0x00008001
/* Flags pour les couches cuivres */
#define LAYER_is_PLAN 0x80000000
/* Flags pour les couches cuivres */
/* numero des couches particulieres */ /* numero des couches particulieres */
#define LAYER_CUIVRE_N 0 #define LAYER_CUIVRE_N 0
#define CUIVRE_N 0 #define CUIVRE_N 0
...@@ -96,6 +95,7 @@ ...@@ -96,6 +95,7 @@
#define LAYER_CMP_N 15 #define LAYER_CMP_N 15
#define CMP_N 15 #define CMP_N 15
#define NB_COPPER_LAYERS (CMP_N + 1) #define NB_COPPER_LAYERS (CMP_N + 1)
#define FIRST_NO_COPPER_LAYER 16 #define FIRST_NO_COPPER_LAYER 16
#define ADHESIVE_N_CU 16 #define ADHESIVE_N_CU 16
#define ADHESIVE_N_CMP 17 #define ADHESIVE_N_CMP 17
...@@ -112,6 +112,7 @@ ...@@ -112,6 +112,7 @@
#define EDGE_N 28 #define EDGE_N 28
#define LAST_NO_COPPER_LAYER 28 #define LAST_NO_COPPER_LAYER 28
#define NB_LAYERS (EDGE_N + 1) #define NB_LAYERS (EDGE_N + 1)
#define LAYER_COUNT 32 #define LAYER_COUNT 32
/* Forme des segments (pistes, contours ..) ( parametre .shape ) */ /* Forme des segments (pistes, contours ..) ( parametre .shape ) */
...@@ -257,12 +258,13 @@ public: ...@@ -257,12 +258,13 @@ public:
/** /**
* Function FindModuleOrPad * Function FindPadOrModule
* searches for either a module or a pad, giving precedence to pads. * searches for either a pad or module, giving precedence to pads.
* @param refPos The wxPoint to hit-test. * @param refPos The wxPoint to hit-test.
* @param typeloc
* @return EDA_BaseStruct* - if a direct hit, else NULL. * @return EDA_BaseStruct* - if a direct hit, else NULL.
*/ */
EDA_BaseStruct* FindModuleOrPad( const wxPoint& refPos ); EDA_BaseStruct* FindPadOrModule( const wxPoint& refPos, int layer, int typeloc );
#endif #endif
}; };
...@@ -375,9 +377,10 @@ public: ...@@ -375,9 +377,10 @@ public:
int DisplayModText; int DisplayModText;
bool DisplayPcbTrackFill; /* FALSE = sketch , TRUE = filled */ bool DisplayPcbTrackFill; /* FALSE = sketch , TRUE = filled */
bool DisplayTrackIsol; bool DisplayTrackIsol;
int m_DisplayViaMode; /* 0 do not show via hole, int m_DisplayViaMode; /* 0 do not show via hole,
* 1 show via hole for non default value * 1 show via hole for non default value
* 2 show all via hole */ * 2 show all via hole */
bool DisplayPolarCood; bool DisplayPolarCood;
bool DisplayZones; bool DisplayZones;
......
MAKEGTK = $(MAKE) -f makefile.gtk MAKEGTK = $(MAKE) -f makefile.gtk
KICAD_SUBDIRS = common 3d-viewer eeschema eeschema/plugins pcbnew cvpcb kicad gerbview KICAD_SUBDIRS = common 3d-viewer pcbnew eeschema eeschema/plugins cvpcb kicad gerbview
KICAD_SUBDIRS_BIN = eeschema eeschema/plugins pcbnew cvpcb kicad gerbview KICAD_SUBDIRS_BIN = eeschema eeschema/plugins pcbnew cvpcb kicad gerbview
KICAD_SUBDIRS_RES = internat modules template library KICAD_SUBDIRS_RES = internat modules template library
KICAD_SUBDIRS_HELP = help KICAD_SUBDIRS_HELP = help
......
...@@ -289,58 +289,75 @@ void BOARD::Show( int nestLevel, std::ostream& os ) ...@@ -289,58 +289,75 @@ void BOARD::Show( int nestLevel, std::ostream& os )
} }
class ModuleOrPad : public INSPECTOR // see pcbstruct.h
EDA_BaseStruct* BOARD::FindPadOrModule( const wxPoint& refPos, int layer, int typeloc )
{ {
public: class PadOrModule : public INSPECTOR
EDA_BaseStruct* found;
ModuleOrPad() :
found(0)
{
}
SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData )
{ {
const wxPoint* refPos = (const wxPoint*) testData; public:
EDA_BaseStruct* found;
if( testItem->m_StructType == TYPEMODULE ) int layer;
int typeloc;
PadOrModule( int alayer, int atypeloc ) :
found(0),
layer(alayer),
typeloc(atypeloc) {}
SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData )
{ {
/* not finished const wxPoint* refPos = (const wxPoint*) testData;
if( testItem->HitTest( &refPos ) )
if( testItem->m_StructType == TYPEMODULE )
{ {
found = testItem; int mlayer = ((MODULE*)testItem)->m_Layer;
return SEARCH_QUIT;
if( typeloc & MATCH_LAYER )
{
if( layer != mlayer )
return SEARCH_CONTINUE;
}
if( typeloc & VISIBLE_ONLY )
{
if( !IsModuleLayerVisible(mlayer) )
return SEARCH_CONTINUE;
}
if( testItem->HitTest( *refPos ) )
{
found = testItem;
return SEARCH_QUIT;
}
} }
*/ else if( testItem->m_StructType == TYPEPAD )
}
else if( testItem->m_StructType == TYPEPAD )
{
/* not finished
if( testItem->HitTest( &refPos ) )
{ {
found = testItem; if( testItem->HitTest( *refPos ) )
return SEARCH_QUIT; {
found = testItem;
return SEARCH_QUIT;
}
} }
*/ else { int debug=1; /* this should not happen, because of scanTypes */ }
return SEARCH_CONTINUE;
} }
return SEARCH_CONTINUE; };
}
};
// see pcbstruct.h PadOrModule inspector1( layer, MATCH_LAYER );
EDA_BaseStruct* BOARD::FindModuleOrPad( const wxPoint& refPos ) PadOrModule inspector2( layer, VISIBLE_ONLY );
{
ModuleOrPad inspector;
static const KICAD_T scanTypes[] = { TYPEPAD, TYPEMODULE, EOT }; static const KICAD_T scanTypes[] = { TYPEPAD, TYPEMODULE, EOT };
if( SEARCH_QUIT == IterateForward( m_Modules, &inspector, &refPos, scanTypes ) )
return inspector.found;
// search the current layer first
if( SEARCH_QUIT == IterateForward( m_Modules, &inspector1, &refPos, scanTypes ) )
return inspector1.found;
// if not found, set layer to don't care and search again
if( SEARCH_QUIT == IterateForward( m_Modules, &inspector2, &refPos, scanTypes ) )
return inspector2.found;
return NULL; return NULL;
} }
......
...@@ -163,7 +163,10 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -163,7 +163,10 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
zoom = screen->GetZoom(); zoom = screen->GetZoom();
type_trace = m_Shape; type_trace = m_Shape;
ux0 = m_Start.x - offset.x; uy0 = m_Start.y - offset.y;
ux0 = m_Start.x - offset.x;
uy0 = m_Start.y - offset.y;
dx = m_End.x - offset.x; dx = m_End.x - offset.x;
dy = m_End.y - offset.y; dy = m_End.y - offset.y;
...@@ -445,8 +448,29 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File, ...@@ -445,8 +448,29 @@ 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 )
{ {
const char* cp = "???";
switch( m_Shape )
{
case S_SEGMENT: cp = "line"; break;
case S_RECT: cp = "rect"; break;
case S_ARC: cp = "arc"; break;
case S_CIRCLE: cp = "circle"; break;
case S_ARC_RECT: cp = "arc_rect"; break;
case S_SPOT_OVALE: cp = "spot_oval"; break;
case S_SPOT_CIRCLE: cp = "spot_circle"; break;
case S_SPOT_RECT: cp = "spot_rect"; break;
case S_POLYGON: cp = "polygon"; break;
}
// for now, make it look like XML: // for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << "/>\n"; NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
" type=\"" << cp << "\">\n";
NestedSpace( nestLevel+1, os ) << "<start" << m_Start0 << "/>\n";
NestedSpace( nestLevel+1, os ) << "<end" << m_End0 << "/>\n";
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
} }
#endif #endif
...@@ -16,7 +16,7 @@ public: ...@@ -16,7 +16,7 @@ public:
int m_Angle; // pour les arcs de cercle: longueur de l'arc en 0,1 degres int m_Angle; // pour les arcs de cercle: longueur de l'arc en 0,1 degres
int m_PolyCount; // For polygons : number of points (> 2) int m_PolyCount; // For polygons: number of points (> 2)
int* m_PolyList; // For polygons: coord list (1 point = 2 coord) int* m_PolyList; // For polygons: coord list (1 point = 2 coord)
// Coord are relative to Origin, orient 0 // Coord are relative to Origin, orient 0
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
*/ */
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
return wxT( "POLYLINE" ); return wxT( "GRAPHIC" );
// return wxT( "EDGE" ); ? // return wxT( "EDGE" ); ?
} }
......
/*****************************************************************/ /*****************************************************************/
/* fonctions membres de la classe EQUIPOT et fonctions associes */ /* fonctions membres de la classe EQUIPOT et fonctions associs */
/*****************************************************************/ /*****************************************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -17,125 +17,132 @@ ...@@ -17,125 +17,132 @@
#include "protos.h" #include "protos.h"
/*********************************************************/ /*********************************************************/
/* classe EQUIPOT: gestion des listes d'equipotentielles */ /* classe EQUIPOT: gestion des listes d'equipotentielles */
/*********************************************************/ /*********************************************************/
/* Constructeur de la classe EQUIPOT */ /* Constructeur de la classe EQUIPOT */
EQUIPOT::EQUIPOT(EDA_BaseStruct * StructFather): EQUIPOT::EQUIPOT( EDA_BaseStruct* StructFather ) :
EDA_BaseStruct( StructFather, PCB_EQUIPOT_STRUCT_TYPE) EDA_BaseStruct( StructFather, PCB_EQUIPOT_STRUCT_TYPE )
{ {
m_NetCode = 0; m_NetCode = 0;
m_NbNodes = m_NbLink = m_NbNoconn = 0; m_NbNodes = m_NbLink = m_NbNoconn = 0;
m_Masque_Layer = 0; m_Masque_Layer = 0;
m_Masque_Plan = 0; m_Masque_Plan = 0;
m_ForceWidth = 0; m_ForceWidth = 0;
m_PadzoneStart = NULL;// pointeur sur debut de liste pads du net m_PadzoneStart = NULL; // pointeur sur debut de liste pads du net
m_PadzoneEnd = NULL; // pointeur sur fin de liste pads du net m_PadzoneEnd = NULL; // pointeur sur fin de liste pads du net
m_RatsnestStart = NULL; // pointeur sur debut de liste ratsnests du net m_RatsnestStart = NULL; // pointeur sur debut de liste ratsnests du net
m_RatsnestEnd = NULL; // pointeur sur fin de liste ratsnests du net m_RatsnestEnd = NULL; // pointeur sur fin de liste ratsnests du net
} }
/* destructeut */
EQUIPOT::~EQUIPOT(void) /* destructeut */
EQUIPOT::~EQUIPOT( void )
{ {
} }
void EQUIPOT::UnLink( void ) void EQUIPOT::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_Equipots = (EQUIPOT*) Pnext;
((BOARD*)Pback)->m_Equipots = (EQUIPOT*)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;
} }
/*************************************************/ /*************************************************/
EQUIPOT * GetEquipot(BOARD * pcb, int netcode) EQUIPOT* GetEquipot( BOARD* pcb, int netcode )
/**************************************************/ /**************************************************/
/* /*
retourne un pointeur sur la structure EQUIPOT de numero netcode * retourne un pointeur sur la structure EQUIPOT de numero netcode
*/ */
{ {
EQUIPOT * Equipot ; EQUIPOT* Equipot;
if( netcode <= 0 ) return NULL; if( netcode <= 0 )
return NULL;
Equipot = (EQUIPOT*)pcb->m_Equipots;
while ( Equipot ) Equipot = (EQUIPOT*) pcb->m_Equipots;
{ while( Equipot )
if(Equipot->m_NetCode == netcode ) break; {
Equipot = (EQUIPOT*) Equipot->Pnext; if( Equipot->m_NetCode == netcode )
} break;
Equipot = (EQUIPOT*) Equipot->Pnext;
return(Equipot); }
return Equipot;
} }
/*********************************************************/ /*********************************************************/
int EQUIPOT:: ReadEquipotDescr(FILE * File, int * LineNum) int EQUIPOT:: ReadEquipotDescr( FILE* File, int* LineNum )
/*********************************************************/ /*********************************************************/
/* Routine de lecture de 1 descr Equipotentielle. /* Routine de lecture de 1 descr Equipotentielle.
retourne 0 si OK * retourne 0 si OK
1 si lecture incomplete * 1 si lecture incomplete
*/ */
{ {
char Line[1024], Ltmp[1024]; char Line[1024], Ltmp[1024];
int tmp; int tmp;
while( GetLine(File, Line, LineNum ) ) while( GetLine( File, Line, LineNum ) )
{ {
if( strnicmp(Line,"$End",4) == 0 )return 0; if( strnicmp( Line, "$End", 4 ) == 0 )
return 0;
if( strncmp(Line,"Na", 2) == 0 ) /* Texte */
{ if( strncmp( Line, "Na", 2 ) == 0 ) /* Texte */
sscanf(Line+2," %d", &tmp); {
m_NetCode = tmp; sscanf( Line + 2, " %d", &tmp );
m_NetCode = tmp;
ReadDelimitedText(Ltmp, Line + 2, sizeof(Ltmp) );
m_Netname = CONV_FROM_UTF8(Ltmp); ReadDelimitedText( Ltmp, Line + 2, sizeof(Ltmp) );
continue; m_Netname = CONV_FROM_UTF8( Ltmp );
} continue;
}
if( strncmp(Line,"Lw", 2) == 0 ) /* Texte */
{ if( strncmp( Line, "Lw", 2 ) == 0 ) /* Texte */
sscanf(Line+2," %d", &tmp); {
m_ForceWidth = tmp; sscanf( Line + 2, " %d", &tmp );
continue; m_ForceWidth = tmp;
} continue;
} }
return 1; }
return 1;
} }
/********************************************/ /********************************************/
int EQUIPOT:: WriteEquipotDescr(FILE * File) int EQUIPOT:: WriteEquipotDescr( FILE* File )
/********************************************/ /********************************************/
{ {
if( GetState(DELETED) ) return(0); if( GetState( DELETED ) )
return 0;
fprintf( File,"$EQUIPOT\n");
fprintf( File,"Na %d \"%.16s\"\n", m_NetCode, CONV_TO_UTF8(m_Netname) ); fprintf( File, "$EQUIPOT\n" );
fprintf( File,"St %s\n","~"); fprintf( File, "Na %d \"%.16s\"\n", m_NetCode, CONV_TO_UTF8( m_Netname ) );
if( m_ForceWidth) fprintf( File,"Lw %d\n",m_ForceWidth ); fprintf( File, "St %s\n", "~" );
fprintf( File,"$EndEQUIPOT\n"); if( m_ForceWidth )
return(1); fprintf( File, "Lw %d\n", m_ForceWidth );
fprintf( File, "$EndEQUIPOT\n" );
return 1;
} }
...@@ -1146,6 +1146,29 @@ void MODULE::Display_Infos( WinEDA_BasePcbFrame* frame ) ...@@ -1146,6 +1146,29 @@ void MODULE::Display_Infos( WinEDA_BasePcbFrame* frame )
} }
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param refPos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool MODULE::HitTest( const wxPoint& refPos )
{
/* Calcul des coord souris dans le repere module */
int spot_cX = refPos.x - m_Pos.x;
int spot_cY = refPos.y - m_Pos.y;
RotatePoint( &spot_cX, &spot_cY, -m_Orient );
/* la souris est-elle dans ce rectangle : */
if( m_BoundaryBox.Inside( spot_cX, spot_cY ) )
return true;
return false;
}
#if defined(DEBUG) #if defined(DEBUG)
/** /**
* Function Show * Function Show
...@@ -1157,29 +1180,29 @@ void MODULE::Display_Infos( WinEDA_BasePcbFrame* frame ) ...@@ -1157,29 +1180,29 @@ void MODULE::Display_Infos( WinEDA_BasePcbFrame* frame )
void MODULE::Show( int nestLevel, std::ostream& os ) 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 ) << '<' << GetClass().Lower().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";
EDA_BaseStruct* p;
p = m_Reference; NestedSpace( nestLevel+1, os ) <<
for( ; p; p = p->Pnext ) "<boundingBox" << m_BoundaryBox.m_Pos << m_BoundaryBox.m_Size << "/>\n";
p->Show( nestLevel+1, os );
p = m_Value; NestedSpace( nestLevel+1, os ) << "<orientation tenths=\"" << m_Orient << "\"/>\n";
for( ; p; p = p->Pnext )
p->Show( nestLevel+1, os ); EDA_BaseStruct* p;
NestedSpace( nestLevel+1, os ) << "<pads>\n";
p = m_Pads; p = m_Pads;
for( ; p; p = p->Pnext ) for( ; p; p = p->Pnext )
p->Show( nestLevel+1, os ); p->Show( nestLevel+2, os );
NestedSpace( nestLevel+1, os ) << "</pads>\n";
NestedSpace( nestLevel+1, os ) << "<drawings>\n";
p = m_Drawings; p = m_Drawings;
for( ; p; p = p->Pnext ) for( ; p; p = p->Pnext )
p->Show( nestLevel+1, os ); p->Show( nestLevel+2, os );
NestedSpace( nestLevel+1, os ) << "</drawings>\n";
p = m_Son; p = m_Son;
for( ; p; p = p->Pnext ) for( ; p; p = p->Pnext )
...@@ -1207,13 +1230,14 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, ...@@ -1207,13 +1230,14 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
} }
else if( stype == TYPETEXTEMODULE ) else if( stype == TYPETEXTEMODULE )
{ {
// iterate over m_Reference if( SEARCH_QUIT == inspector->Inspect( m_Reference, testData ) )
if( SEARCH_QUIT == IterateForward( m_Reference, inspector,
testData, scanTypes ) )
return SEARCH_QUIT; return SEARCH_QUIT;
// iterate over m_Value if( SEARCH_QUIT == inspector->Inspect( m_Value, testData ) )
if( SEARCH_QUIT == IterateForward( m_Value, inspector, return SEARCH_QUIT;
// m_Drawings can hold TYPETEXTMODULE also?
if( SEARCH_QUIT == IterateForward( m_Drawings, inspector,
testData, scanTypes ) ) testData, scanTypes ) )
return SEARCH_QUIT; return SEARCH_QUIT;
} }
......
...@@ -133,6 +133,16 @@ public: ...@@ -133,6 +133,16 @@ public:
/* miscellaneous */ /* miscellaneous */
void Display_Infos( WinEDA_BasePcbFrame* frame ); void Display_Infos( WinEDA_BasePcbFrame* frame );
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param refPos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool HitTest( const wxPoint& refPos );
#if defined(DEBUG) #if defined(DEBUG)
/** /**
......
...@@ -87,11 +87,16 @@ const wxPoint D_PAD::ReturnShapePos( void ) ...@@ -87,11 +87,16 @@ const wxPoint D_PAD::ReturnShapePos( void )
{ {
if( (m_Offset.x == 0) && (m_Offset.y == 0) ) if( (m_Offset.x == 0) && (m_Offset.y == 0) )
return m_Pos; return m_Pos;
wxPoint shape_pos; wxPoint shape_pos;
int dX, dY; 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;
} }
...@@ -507,6 +512,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int ...@@ -507,6 +512,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int
} }
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 )
{ {
...@@ -520,20 +526,26 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int ...@@ -520,20 +526,26 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int
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 ) if( !frame->m_DisplayPadNum )
return; return;
dx = min( m_Size.x, m_Size.y ); /* dx = text size */ 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 ) if( dy < 2 )
dy = 2; /* text min size is 2 char */ 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 );
...@@ -579,6 +591,7 @@ int D_PAD::ReadDescr( FILE* File, int* LineNum ) ...@@ -579,6 +591,7 @@ int D_PAD::ReadDescr( FILE* File, int* LineNum )
if( *PtLine ) if( *PtLine )
PtLine++; PtLine++;
memset( m_Padname, 0, sizeof(m_Padname) ); memset( m_Padname, 0, sizeof(m_Padname) );
while( (*PtLine != '"') && *PtLine ) while( (*PtLine != '"') && *PtLine )
{ {
...@@ -629,6 +642,7 @@ int D_PAD::ReadDescr( FILE* File, int* LineNum ) ...@@ -629,6 +642,7 @@ int D_PAD::ReadDescr( FILE* File, int* LineNum )
&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' )
...@@ -944,6 +958,54 @@ void D_PAD::Display_Infos( WinEDA_BasePcbFrame* frame ) ...@@ -944,6 +958,54 @@ void D_PAD::Display_Infos( WinEDA_BasePcbFrame* frame )
Affiche_1_Parametre( frame, pos, _( "Y pos" ), Line, BLUE ); Affiche_1_Parametre( frame, pos, _( "Y pos" ), Line, BLUE );
} }
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param ref_pos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool D_PAD::HitTest( const wxPoint& ref_pos )
{
int deltaX, deltaY;
int dx, dy;
double dist;
wxPoint shape_pos = ReturnShapePos();
deltaX = ref_pos.x - shape_pos.x;
deltaY = ref_pos.y - shape_pos.y;
/* Test rapide: le point a tester doit etre a l'interieur du cercle exinscrit ... */
if( (abs( deltaX ) > m_Rayon )
|| (abs( deltaY ) > m_Rayon) )
return false;
/* calcul des demi dim dx et dy */
dx = m_Size.x >> 1; // dx also is the radius for rounded pads
dy = m_Size.y >> 1;
/* localisation ? */
switch( m_PadShape & 0x7F )
{
case CIRCLE:
dist = hypot( deltaX, deltaY );
if( (int) ( round( dist ) ) <= dx )
return true;
break;
default:
/* calcul des coord du point test dans le repere du Pad */
RotatePoint( &deltaX, &deltaY, -m_Orient );
if( (abs( deltaX ) <= dx ) && (abs( deltaY ) <= dy) )
return true;
break;
}
return false;
}
#if defined(DEBUG) #if defined(DEBUG)
/** /**
* Function Show * Function Show
......
...@@ -29,11 +29,11 @@ public: ...@@ -29,11 +29,11 @@ public:
char m_Padname[4]; /* nom (numero) de la pastille (assimilable a un long)*/ char m_Padname[4]; /* nom (numero) de la pastille (assimilable a un long)*/
}; };
wxString m_Netname; /* Net Name */ wxString m_Netname; /* Net Name */
int m_Masque_Layer; // (Bit a Bit :1= cuivre, 15= cmp, int m_Masque_Layer; // (Bit a Bit :1= cuivre, 15= cmp,
// 2..14 = interne // 2..14 = interne
// 16 .. 31 = couches non cuivre // 16 .. 31 = couches non cuivre
int m_PadShape; // forme CERCLE, RECT, OVALE, TRAPEZE ou libre int m_PadShape; // forme CERCLE, RECT, OVALE, TRAPEZE ou libre
int m_DrillShape; // forme CERCLE, OVAL int m_DrillShape; // forme CERCLE, OVAL
...@@ -91,7 +91,15 @@ public: ...@@ -91,7 +91,15 @@ public:
// de la forme (pastilles excentrees) // de la forme (pastilles excentrees)
void Display_Infos( WinEDA_BasePcbFrame* frame ); void Display_Infos( WinEDA_BasePcbFrame* frame );
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param refPos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool HitTest( const wxPoint& refPos );
#if defined(DEBUG) #if defined(DEBUG)
/** /**
* Function GetClass * Function GetClass
......
...@@ -162,11 +162,10 @@ void TEXTE_PCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -162,11 +162,10 @@ void TEXTE_PCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
void TEXTE_PCB::Show( int nestLevel, std::ostream& os ) void TEXTE_PCB::Show( int nestLevel, std::ostream& os )
{ {
// for now, make it look like XML: // for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n"; NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
" string=\"" << m_Text.mb_str() << "\"/>\n";
NestedSpace( nestLevel+1, os ) << m_Text.mb_str() << '\n';
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n"; // NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
} }
#endif #endif
...@@ -305,12 +305,10 @@ int TEXTE_MODULE::GetDrawRotation( void ) ...@@ -305,12 +305,10 @@ int TEXTE_MODULE::GetDrawRotation( void )
*/ */
void TEXTE_MODULE::Show( int nestLevel, std::ostream& os ) 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:
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
" string=\"" << m_Text.mb_str() << "\"/>\n";
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n"; // 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 #endif
...@@ -125,7 +125,14 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -125,7 +125,14 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case ID_PCB_SHOW_1_RATSNEST_BUTT: case ID_PCB_SHOW_1_RATSNEST_BUTT:
#if defined(DEBUG)
DrawStruct = m_Pcb->FindPadOrModule(
GetScreen()->RefPos(true),
GetScreen()->m_Active_Layer,
VISIBLE_ONLY );
#else
DrawStruct = PcbGeneralLocateAndDisplay(); DrawStruct = PcbGeneralLocateAndDisplay();
#endif
Show_1_Ratsnest( DrawStruct, DC ); Show_1_Ratsnest( DrawStruct, DC );
break; break;
...@@ -454,11 +461,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -454,11 +461,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_OPEN_MODULE_EDITOR: case ID_OPEN_MODULE_EDITOR:
if( m_Parent->m_ModuleEditFrame == NULL ) if( m_Parent->m_ModuleEditFrame == NULL )
{ {
m_Parent->m_ModuleEditFrame = new WinEDA_ModuleEditFrame( this, m_Parent->m_ModuleEditFrame =
m_Parent, _( "Module Editor" ), new WinEDA_ModuleEditFrame( this,
wxPoint( -1, m_Parent, _( "Module Editor" ),
-1 ), wxPoint( -1,
wxSize( 600, 400 ) ); -1 ),
wxSize( 600, 400 ) );
m_Parent->m_ModuleEditFrame->Show( TRUE ); m_Parent->m_ModuleEditFrame->Show( TRUE );
m_Parent->m_ModuleEditFrame->Zoom_Automatique( TRUE ); m_Parent->m_ModuleEditFrame->Zoom_Automatique( TRUE );
} }
...@@ -601,8 +609,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -601,8 +609,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_END_LINE: case ID_POPUP_END_LINE:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
// EndSegment(&dc);
// EndSegment(&dc);
break; break;
case ID_POPUP_PCB_EDIT_TRACK: case ID_POPUP_PCB_EDIT_TRACK:
......
...@@ -341,7 +341,8 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC ) ...@@ -341,7 +341,8 @@ void WinEDA_PcbFrame::Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC )
{ {
if( item->m_StructType == TYPETEXTEMODULE ) if( item->m_StructType == TYPETEXTEMODULE )
{ {
Module = (MODULE*) item->m_Parent; if( item->m_Parent && (item->m_Parent->m_StructType == TYPEMODULE) )
Module = (MODULE*) item->m_Parent;
} }
else if( item->m_StructType == TYPEMODULE ) else if( item->m_StructType == TYPEMODULE )
......
...@@ -32,30 +32,7 @@ EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch, int t ...@@ -32,30 +32,7 @@ EDA_BaseStruct* Locate_MirePcb( EDA_BaseStruct* PtStruct, int LayerSearch, int t
*/ */
wxPoint inline RefPos( int typeloc ) wxPoint inline RefPos( int typeloc )
{ {
if( typeloc & CURSEUR_OFF_GRILLE ) return ActiveScreen->RefPos( (typeloc & CURSEUR_OFF_GRILLE) != 0 );
return ActiveScreen->m_MousePosition;
else
return ActiveScreen->m_Curseur;
}
/**
* Function IsModuleLayerVisible
* expects either of the two layers on which a module can reside, and returns
* whether that layer is visible.
* @param layer One of the two allowed layers for modules: CMP_N or CUIVRE_N
* @return bool - true if the layer is visible, else false.
*/
bool inline IsModuleLayerVisible( int layer )
{
if( layer==CMP_N )
return DisplayOpt.Show_Modules_Cmp;
else if( layer==CUIVRE_N )
return DisplayOpt.Show_Modules_Cu;
else
return true;
} }
...@@ -344,6 +321,7 @@ EDGE_MODULE* Locate_Edge_Module( MODULE* module, int typeloc ) ...@@ -344,6 +321,7 @@ EDGE_MODULE* Locate_Edge_Module( MODULE* module, int typeloc )
{ {
if( PtStruct->m_StructType != TYPEEDGEMODULE ) if( PtStruct->m_StructType != TYPEEDGEMODULE )
continue; continue;
edge_mod = (EDGE_MODULE*) PtStruct; edge_mod = (EDGE_MODULE*) PtStruct;
type_trace = edge_mod->m_Shape; type_trace = edge_mod->m_Shape;
ux0 = edge_mod->m_Start.x; uy0 = edge_mod->m_Start.y; ux0 = edge_mod->m_Start.x; uy0 = edge_mod->m_Start.y;
...@@ -418,6 +396,7 @@ EDA_BaseStruct* Locate_Cotation( BOARD* Pcb, int LayerSearch, int typeloc ) ...@@ -418,6 +396,7 @@ EDA_BaseStruct* Locate_Cotation( BOARD* Pcb, int LayerSearch, int typeloc )
{ {
if( PtStruct->m_StructType != TYPECOTATION ) if( PtStruct->m_StructType != TYPECOTATION )
continue; continue;
Cotation = (COTATION*) PtStruct; Cotation = (COTATION*) PtStruct;
if( (Cotation->m_Layer != LayerSearch) && (LayerSearch != -1) ) if( (Cotation->m_Layer != LayerSearch) && (LayerSearch != -1) )
continue; continue;
...@@ -426,7 +405,10 @@ EDA_BaseStruct* Locate_Cotation( BOARD* Pcb, int LayerSearch, int typeloc ) ...@@ -426,7 +405,10 @@ EDA_BaseStruct* Locate_Cotation( BOARD* Pcb, int LayerSearch, int typeloc )
pt_txt = Cotation->m_Text; pt_txt = Cotation->m_Text;
if( pt_txt ) if( pt_txt )
{ {
if( pt_txt->HitTest( ref_pos ) ) // because HitTest() is present in both base classes of TEXTE_PCB
// use a dis-ambiguating cast to tell compiler which HitTest()
// to call.
if( static_cast<EDA_TextStruct*>(pt_txt)->HitTest( ref_pos ) )
return PtStruct; return PtStruct;
} }
...@@ -666,52 +648,23 @@ D_PAD* Locate_Pads( MODULE* module, int masque_layer, int typeloc ) ...@@ -666,52 +648,23 @@ D_PAD* Locate_Pads( MODULE* module, int masque_layer, int typeloc )
D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer ) D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer )
{ {
D_PAD* pt_pad; D_PAD* pt_pad = module->m_Pads;
int deltaX, deltaY;
wxPoint shape_pos;
double dist;
pt_pad = module->m_Pads;
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(); /*
wxPoint shape_pos = ReturnShapePos();
why the global ux0?
ux0 = shape_pos.x; ux0 = shape_pos.x;
uy0 = shape_pos.y; /* pos x,y du centre du pad */ uy0 = shape_pos.y; // pos x,y du centre du pad
*/
deltaX = ref_pos.x - ux0;
deltaY = ref_pos.y - uy0;
/* Test rapide: le point a tester doit etre a l'interieur du cercle
* exinscrit ... */
if( (abs( deltaX ) > pt_pad->m_Rayon )
|| (abs( deltaY ) > pt_pad->m_Rayon) )
continue;
/* ... et sur la bonne couche */ /* ... et sur la bonne couche */
if( (pt_pad->m_Masque_Layer & masque_layer) == 0 ) if( (pt_pad->m_Masque_Layer & masque_layer) == 0 )
continue; continue;
/* calcul des demi dim dx et dy */ if( pt_pad->HitTest( ref_pos ) )
dx = pt_pad->m_Size.x >> 1; // dx also is the radius for rounded pads return pt_pad;
dy = pt_pad->m_Size.y >> 1;
/* localisation ? */
switch( pt_pad->m_PadShape & 0x7F )
{
case CIRCLE:
dist = hypot( deltaX, deltaY );
if( (int) ( round( dist ) ) <= dx )
return pt_pad;
break;
default:
/* calcul des coord du point test dans le repere du Pad */
RotatePoint( &deltaX, &deltaY, -pt_pad->m_Orient );
if( (abs( deltaX ) <= dx ) && (abs( deltaY ) <= dy) )
return pt_pad;
break;
}
} }
return NULL; return NULL;
...@@ -743,17 +696,8 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc ) ...@@ -743,17 +696,8 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
pt_module = Pcb->m_Modules; pt_module = Pcb->m_Modules;
for( ; pt_module; pt_module = (MODULE*) pt_module->Pnext ) for( ; pt_module; pt_module = (MODULE*) pt_module->Pnext )
{ {
/* calcul des dimensions du cadre :*/ // is the ref point within the module's bounds?
lx = pt_module->m_BoundaryBox.GetWidth(); if( !pt_module->HitTest( ref_pos ) )
ly = pt_module->m_BoundaryBox.GetHeight();
/* Calcul des coord souris dans le repere module */
spot_cX = ref_pos.x - pt_module->m_Pos.x;
spot_cY = ref_pos.y - pt_module->m_Pos.y;
RotatePoint( &spot_cX, &spot_cY, -pt_module->m_Orient );
/* la souris est-elle dans ce rectangle : */
if( !pt_module->m_BoundaryBox.Inside( spot_cX, spot_cY ) )
continue; continue;
// if caller wants to ignore locked modules, and this one is locked, skip it. // if caller wants to ignore locked modules, and this one is locked, skip it.
...@@ -773,13 +717,18 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc ) ...@@ -773,13 +717,18 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
else if( layer==ADHESIVE_N_CMP || layer==SILKSCREEN_N_CMP ) else if( layer==ADHESIVE_N_CMP || layer==SILKSCREEN_N_CMP )
layer = CMP_N; layer = CMP_N;
/* calcul des dimensions du cadre :*/
lx = pt_module->m_BoundaryBox.GetWidth();
ly = pt_module->m_BoundaryBox.GetHeight();
if( ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer == layer ) if( ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer == layer )
{ {
if( min( lx, ly ) <= min_dim ) if( min( lx, ly ) <= min_dim )
{ {
/* meilleure empreinte localisee sur couche active */ /* meilleure empreinte localisee sur couche active */
module = pt_module; min_dim = min( lx, ly ); module = pt_module;
min_dim = min( lx, ly );
} }
} }
else if( !(typeloc & MATCH_LAYER) else if( !(typeloc & MATCH_LAYER)
...@@ -1155,11 +1104,18 @@ TEXTE_PCB* Locate_Texte_Pcb( EDA_BaseStruct* PtStruct, int LayerSearch, int type ...@@ -1155,11 +1104,18 @@ TEXTE_PCB* Locate_Texte_Pcb( EDA_BaseStruct* PtStruct, int LayerSearch, int type
{ {
if( PtStruct->m_StructType != TYPETEXTE ) if( PtStruct->m_StructType != TYPETEXTE )
continue; continue;
TEXTE_PCB* pt_txt_pcb = (TEXTE_PCB*) PtStruct; TEXTE_PCB* pt_txt_pcb = (TEXTE_PCB*) PtStruct;
if( pt_txt_pcb->HitTest( ref ) )
if( pt_txt_pcb->m_Layer == LayerSearch )
{ {
if( pt_txt_pcb->m_Layer == LayerSearch ) // because HitTest() is present in both base classes of TEXTE_PCB
// use a dis-ambiguating cast to tell compiler which HitTest()
// to call.
if( static_cast<EDA_TextStruct*>(pt_txt_pcb)->HitTest( ref ) )
{
return pt_txt_pcb; return pt_txt_pcb;
}
} }
} }
......
/****************************************************/ /****************************************************/
/* Gestion des composants specifiques aux microndes */ /* Gestion des composants specifiques aux microndes */
/****************************************************/ /****************************************************/
/* Fichier MUONDE.CPP */ /* Fichier MUONDE.CPP */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -20,688 +20,717 @@ ...@@ -20,688 +20,717 @@
/* fonctions importees */ /* fonctions importees */
/* Fonctions locales */ /* Fonctions locales */
//static void Exit_Muonde(WinEDA_DrawFrame * frame, wxDC *DC); //static void Exit_Muonde(WinEDA_DrawFrame * frame, wxDC *DC);
/* Variables locales : */ /* Variables locales : */
#define COEFF_COUNT 6 #define COEFF_COUNT 6
double * PolyEdges; double* PolyEdges;
int PolyEdgesCount; int PolyEdgesCount;
double ShapeScaleX, ShapeScaleY; double ShapeScaleX, ShapeScaleY;
wxSize ShapeSize; wxSize ShapeSize;
int PolyShapeType; int PolyShapeType;
#include "gen_self.h" #include "gen_self.h"
/***************************************************************************/ /***************************************************************************/
MODULE * WinEDA_PcbFrame::Create_MuWaveBasicShape(wxDC * DC, MODULE* WinEDA_PcbFrame::Create_MuWaveBasicShape( wxDC* DC,
const wxString & name, int pad_count) const wxString& name, int pad_count )
/***************************************************************************/ /***************************************************************************/
/* Create a footprint with pad_count pads for micro wave applications /* Create a footprint with pad_count pads for micro wave applications
This footprint has pad_count pads: * This footprint has pad_count pads:
SMD, rectangular, H size = V size = current track width. * SMD, rectangular, H size = V size = current track width.
*/ */
{ {
MODULE * Module; MODULE* Module;
int pad_num = 1; int pad_num = 1;
wxString Line; wxString Line;
Module = Create_1_Module(DC, name); Module = Create_1_Module( DC, name );
if ( Module == NULL ) return NULL; if( Module == NULL )
return NULL;
Module->m_TimeStamp = GetTimeStamp();
Module->m_Value->m_Size = wxSize(30,30); Module->m_TimeStamp = GetTimeStamp();
Module->m_Value->m_Pos0.y = -30; Module->m_Value->m_Size = wxSize( 30, 30 );
Module->m_Value->m_Pos.y += Module->m_Value->m_Pos0.y; Module->m_Value->m_Pos0.y = -30;
Module->m_Reference->m_Size = wxSize(30,30); Module->m_Value->m_Pos.y += Module->m_Value->m_Pos0.y;
Module->m_Reference->m_Pos0.y = 30; Module->m_Reference->m_Size = wxSize( 30, 30 );
Module->m_Reference->m_Pos.y += Module->m_Reference->m_Pos0.y; Module->m_Reference->m_Pos0.y = 30;
Module->m_Reference->m_Pos.y += Module->m_Reference->m_Pos0.y;
/* Creation des pastilles formant le gap */
while ( pad_count -- ) /* Creation des pastilles formant le gap */
{ while( pad_count-- )
D_PAD* pad; {
pad = new D_PAD(Module); D_PAD* pad;
pad->Pback = Module; pad = new D_PAD( Module );
if ( Module->m_Pads == NULL ) pad->Pback = Module;
{ if( Module->m_Pads == NULL )
Module->m_Pads = pad; {
} Module->m_Pads = pad;
else }
{ else
Module->m_Pads->Pback = pad; {
pad->Pnext = Module->m_Pads; Module->m_Pads->Pback = pad;
Module->m_Pads = pad; pad->Pnext = Module->m_Pads;
} Module->m_Pads = pad;
pad->m_Size.x = pad->m_Size.y = g_DesignSettings.m_CurrentTrackWidth; }
pad->m_Pos = Module->m_Pos; pad->m_Size.x = pad->m_Size.y = g_DesignSettings.m_CurrentTrackWidth;
pad->m_PadShape = RECT; pad->m_Pos = Module->m_Pos;
pad->m_Attribut = SMD; pad->m_PadShape = RECT;
pad->m_Masque_Layer = CMP_LAYER; pad->m_Attribut = SMD;
Line.Printf( wxT("%d"), pad_num); pad->m_Masque_Layer = CMP_LAYER;
pad->SetPadName(Line); Line.Printf( wxT( "%d" ), pad_num );
pad_num++; pad->SetPadName( Line );
} pad_num++;
}
if (DC) Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ;
return Module; if( DC )
Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
return Module;
} }
#if 0 #if 0
/**********************************************************/ /**********************************************************/
static void Exit_Muonde(WinEDA_DrawFrame * frame, wxDC *DC ) static void Exit_Muonde( WinEDA_DrawFrame* frame, wxDC* DC )
/**********************************************************/ /**********************************************************/
{ {
MODULE * Module = (MODULE*) frame->m_CurrentScreen->m_CurrentItem; MODULE* Module = (MODULE*) frame->m_CurrentScreen->m_CurrentItem;
if( Module ) if( Module )
{ {
if ( Module->m_Flags & IS_NEW) if( Module->m_Flags & IS_NEW )
{ {
Module->Draw(frame->DrawPanel, DC, wxPoint(0,0), GR_XOR) ; Module->Draw( frame->DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
DeleteStructure( Module); DeleteStructure( Module );
} }
else else
{ {
Module->Draw(frame->DrawPanel, DC, wxPoint(0,0), GR_XOR) ; Module->Draw( frame->DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
} }
} }
frame->DrawPanel->ManageCurseur = NULL; frame->DrawPanel->ManageCurseur = NULL;
frame->DrawPanel->ForceCloseManageCurseur = NULL; frame->DrawPanel->ForceCloseManageCurseur = NULL;
frame->m_CurrentScreen->m_CurrentItem = NULL; frame->m_CurrentScreen->m_CurrentItem = NULL;
} }
#endif #endif
/***************************************************************************/ /***************************************************************************/
MODULE * WinEDA_PcbFrame::Create_MuWaveComponent(wxDC * DC, int shape_type) MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( wxDC* DC, int shape_type )
/***************************************************************************/ /***************************************************************************/
/* Create a module "GAP" or "STUB" /* Create a module "GAP" or "STUB"
This a "gap" or "stub" used in micro wave designs * This a "gap" or "stub" used in micro wave designs
This modue has 2 pads: * This modue has 2 pads:
SMD, rectangular, H size = V size = current track width. * SMD, rectangular, H size = V size = current track width.
the "gap" is isolation created between this 2 pads * the "gap" is isolation created between this 2 pads
*/ */
{ {
int gap_size, oX, ii; int gap_size, oX, ii;
float fcoeff; float fcoeff;
D_PAD* pt_pad; D_PAD* pt_pad;
MODULE * Module; MODULE* Module;
wxString msg, cmp_name; wxString msg, cmp_name;
int pad_count = 2; int pad_count = 2;
int angle = 0; int angle = 0;
bool abort; bool abort;
/* Entree de la longueur desiree du gap*/ /* Entree de la longueur desiree du gap*/
gap_size = g_DesignSettings.m_CurrentTrackWidth; // Valeur raisonnable gap_size = g_DesignSettings.m_CurrentTrackWidth; // Valeur raisonnable
switch ( shape_type ) switch( shape_type )
{ {
case 0: case 0:
msg = _("Gap"); msg = _( "Gap" );
cmp_name = wxT("GAP"); cmp_name = wxT( "GAP" );
break; break;
case 1: case 1:
msg = _("Stub"); msg = _( "Stub" );
cmp_name = wxT("STUB"); cmp_name = wxT( "STUB" );
pad_count = 2; pad_count = 2;
break; break;
case 2: case 2:
msg = _("Arc Stub"); msg = _( "Arc Stub" );
cmp_name = wxT("ASTUB"); cmp_name = wxT( "ASTUB" );
pad_count = 1; pad_count = 1;
break; break;
default: default:
msg = wxT("???"); msg = wxT( "???" );
break; break;
} }
wxString value; wxString value;
if( g_UnitMetric) if( g_UnitMetric )
{ {
fcoeff = 10000.0/25.4 ; fcoeff = 10000.0 / 25.4;
value.Printf( wxT("%2.4f"),gap_size / fcoeff); value.Printf( wxT( "%2.4f" ), gap_size / fcoeff );
msg += _(" (mm):"); msg += _( " (mm):" );
abort = Get_Message(msg,value, this); abort = Get_Message( msg, value, this );
} }
else else
{ {
fcoeff = 10000.0 ; fcoeff = 10000.0;
value.Printf( wxT("%2.3f"),gap_size / fcoeff); value.Printf( wxT( "%2.3f" ), gap_size / fcoeff );
msg += _(" (inch):"); msg += _( " (inch):" );
abort = Get_Message(msg, value, this); abort = Get_Message( msg, value, this );
} }
double fval; double fval;
if ( ! value.ToDouble(&fval) ) if( !value.ToDouble( &fval ) )
{ {
DisplayError(this, _("Incorrect number, abort")); DisplayError( this, _( "Incorrect number, abort" ) );
abort = TRUE; abort = TRUE;
} }
gap_size = ABS( (int) round( fval * fcoeff )); gap_size = ABS( (int) round( fval * fcoeff ) );
if ( ! abort && (shape_type == 2) ) if( !abort && (shape_type == 2) )
{ {
fcoeff = 10.0 ; fcoeff = 10.0;
value.Printf( wxT("%3.1f"),angle / fcoeff); value.Printf( wxT( "%3.1f" ), angle / fcoeff );
msg = _("Angle (0.1deg):"); msg = _( "Angle (0.1deg):" );
abort = Get_Message(msg, value, this); abort = Get_Message( msg, value, this );
if ( ! value.ToDouble(&fval) ) if( !value.ToDouble( &fval ) )
{ {
DisplayError(this, _("Incorrect number, abort")); DisplayError( this, _( "Incorrect number, abort" ) );
abort = TRUE; abort = TRUE;
} }
angle = ABS( (int) round( fval * fcoeff )); angle = ABS( (int) round( fval * fcoeff ) );
if ( angle > 1800 ) angle = 1800; if( angle > 1800 )
} angle = 1800;
}
if (abort)
{ if( abort )
DrawPanel->MouseToCursorSchema(); {
return NULL; DrawPanel->MouseToCursorSchema();
} return NULL;
}
Module = Create_MuWaveBasicShape(NULL, cmp_name, pad_count);
pt_pad = Module->m_Pads; Module = Create_MuWaveBasicShape( NULL, cmp_name, pad_count );
pt_pad = Module->m_Pads;
switch ( shape_type )
{ switch( shape_type )
case 0: //Gap : {
oX = pt_pad->m_Pos0.x = - (gap_size + pt_pad->m_Size.x) / 2; case 0: //Gap :
pt_pad->m_Pos.x += pt_pad->m_Pos0.x; oX = pt_pad->m_Pos0.x = -(gap_size + pt_pad->m_Size.x) / 2;
pt_pad->m_Pos.x += pt_pad->m_Pos0.x;
pt_pad = (D_PAD *) pt_pad->Pnext;
pt_pad->m_Pos0.x = oX + gap_size + pt_pad->m_Size.x; pt_pad = (D_PAD*) pt_pad->Pnext;
pt_pad->m_Pos.x += pt_pad->m_Pos0.x; pt_pad->m_Pos0.x = oX + gap_size + pt_pad->m_Size.x;
break; pt_pad->m_Pos.x += pt_pad->m_Pos0.x;
break;
case 1: //Stub :
pt_pad->SetPadName( wxT("1")); case 1: //Stub :
pt_pad = (D_PAD *) pt_pad->Pnext; pt_pad->SetPadName( wxT( "1" ) );
pt_pad->m_Pos0.y = -(gap_size + pt_pad->m_Size.y) /2; pt_pad = (D_PAD*) pt_pad->Pnext;
pt_pad->m_Size.y = gap_size; pt_pad->m_Pos0.y = -(gap_size + pt_pad->m_Size.y) / 2;
pt_pad->m_Pos.y += pt_pad->m_Pos0.y; pt_pad->m_Size.y = gap_size;
break; pt_pad->m_Pos.y += pt_pad->m_Pos0.y;
break;
case 2: //Arc Stub :
{ case 2: //Arc Stub :
EDGE_MODULE * edge; int * ptr, theta; {
ii = angle / 50; EDGE_MODULE* edge; int* ptr, theta;
edge = new EDGE_MODULE(Module); ii = angle / 50;
Module->m_Drawings = edge; edge = new EDGE_MODULE( Module );
edge->Pback = Module; Module->m_Drawings = edge;
edge->m_Shape = S_POLYGON; edge->Pback = Module;
edge->m_Layer = LAYER_CMP_N; edge->m_Shape = S_POLYGON;
edge->m_PolyCount = ii + 3; edge->m_Layer = LAYER_CMP_N;
edge->m_PolyList = (int*) MyMalloc( edge->m_PolyCount * 2 * sizeof(int) ); edge->m_PolyCount = ii + 3;
ptr = edge->m_PolyList; edge->m_PolyList = (int*) MyMalloc( edge->m_PolyCount * 2 * sizeof(int) );
edge->m_Start0.y = - pt_pad->m_Size.y / 2; ptr = edge->m_PolyList;
edge->m_Start0.y = -pt_pad->m_Size.y / 2;
* ptr = 0; ptr++;
* ptr = 0; ptr++; *ptr = 0; ptr++;
theta = - angle/2; *ptr = 0; ptr++;
for ( ii = 1; ii < edge->m_PolyCount - 1; ii ++) theta = -angle / 2;
{ for( ii = 1; ii < edge->m_PolyCount - 1; ii++ )
int x, y; {
x = 0; y = - gap_size; int x, y;
RotatePoint(&x, &y, theta); x = 0; y = -gap_size;
* ptr = x; ptr++; *ptr = y; ptr++; RotatePoint( &x, &y, theta );
theta += 50; *ptr = x; ptr++; *ptr = y; ptr++;
if ( theta > angle/2) theta = angle/2; theta += 50;
} if( theta > angle / 2 )
*ptr = edge->m_PolyList[0]; ptr++; theta = angle / 2;
*ptr = edge->m_PolyList[1]; }
break;
} *ptr = edge->m_PolyList[0]; ptr++;
*ptr = edge->m_PolyList[1];
default: break;
break; }
}
default:
Module->Set_Rectangle_Encadrement(); break;
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; }
DrawPanel->MouseToCursorSchema();
m_Pcb->m_Status_Pcb = 0 ; Module->Set_Rectangle_Encadrement();
m_CurrentScreen->SetModify(); Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
return Module; DrawPanel->MouseToCursorSchema();
m_Pcb->m_Status_Pcb = 0;
m_CurrentScreen->SetModify();
return Module;
} }
/**************** Polygon Shapes ***********************/ /**************** Polygon Shapes ***********************/
enum id_mw_cmd enum id_mw_cmd {
{ ID_ACCEPT_OPT = 1000,
ID_ACCEPT_OPT = 1000, ID_CANCEL_OPT,
ID_CANCEL_OPT, ID_READ_SHAPE_FILE
ID_READ_SHAPE_FILE
}; };
/*************************************************/ /*************************************************/
class WinEDA_SetParamShapeFrame: public wxDialog class WinEDA_SetParamShapeFrame : public wxDialog
/*************************************************/ /*************************************************/
/* Reglages des parametres des forme polynomiales /* Reglages des parametres des forme polynomiales
*/ */
{ {
private: private:
WinEDA_PcbFrame * m_Parent; WinEDA_PcbFrame* m_Parent;
wxRadioBox * m_ShapeOptionCtrl; wxRadioBox* m_ShapeOptionCtrl;
WinEDA_SizeCtrl * m_SizeCtrl; WinEDA_SizeCtrl* m_SizeCtrl;
public: public:
// Constructor and destructor
WinEDA_SetParamShapeFrame(WinEDA_PcbFrame *parent,const wxPoint& pos);
~WinEDA_SetParamShapeFrame(void) {};
private: // Constructor and destructor
void OnCloseWindow(wxCloseEvent & event); WinEDA_SetParamShapeFrame( WinEDA_PcbFrame* parent, const wxPoint& pos );
void OnCancel(wxCommandEvent& event); ~WinEDA_SetParamShapeFrame( void ) { };
void ReadDataShapeDescr(wxCommandEvent& event);
void AcceptOptions(wxCommandEvent& event);
DECLARE_EVENT_TABLE() private:
void OnCloseWindow( wxCloseEvent& event );
void OnCancel( wxCommandEvent& event );
void ReadDataShapeDescr( wxCommandEvent& event );
void AcceptOptions( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
}; };
/* Construction de la table des evenements pour WinEDA_SetParamShapeFrame */ /* Construction de la table des evenements pour WinEDA_SetParamShapeFrame */
BEGIN_EVENT_TABLE(WinEDA_SetParamShapeFrame, wxDialog) BEGIN_EVENT_TABLE( WinEDA_SetParamShapeFrame, wxDialog )
EVT_BUTTON(ID_ACCEPT_OPT, WinEDA_SetParamShapeFrame::AcceptOptions) EVT_BUTTON( ID_ACCEPT_OPT, WinEDA_SetParamShapeFrame::AcceptOptions )
EVT_BUTTON(ID_CANCEL_OPT, WinEDA_SetParamShapeFrame::OnCancel) EVT_BUTTON( ID_CANCEL_OPT, WinEDA_SetParamShapeFrame::OnCancel )
EVT_BUTTON(ID_READ_SHAPE_FILE, WinEDA_SetParamShapeFrame::ReadDataShapeDescr) EVT_BUTTON( ID_READ_SHAPE_FILE, WinEDA_SetParamShapeFrame::ReadDataShapeDescr )
END_EVENT_TABLE() END_EVENT_TABLE()
/*************************************************/
/* Constructeur de WinEDA_SetParamShapeFrame */
/************************************************/
/*************************************************/ WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( WinEDA_PcbFrame* parent,
/* Constructeur de WinEDA_SetParamShapeFrame */ const wxPoint& framepos ) :
/************************************************/ wxDialog( parent, -1, _( "Complex shape" ), framepos, wxSize( 350, 280 ),
DIALOG_STYLE )
WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame(WinEDA_PcbFrame *parent,
const wxPoint& framepos):
wxDialog(parent, -1, _("Complex shape"), framepos, wxSize(350, 280),
DIALOG_STYLE )
{ {
m_Parent = parent; m_Parent = parent;
SetFont(*g_DialogFont); SetFont( *g_DialogFont );
if ( PolyEdges ) free(PolyEdges); if( PolyEdges )
PolyEdges = NULL; free( PolyEdges );
PolyEdgesCount = 0; PolyEdges = NULL;
PolyEdgesCount = 0;
wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL);
SetSizer(MainBoxSizer); wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); SetSizer( MainBoxSizer );
wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxButton * Button = new wxButton(this, ID_ACCEPT_OPT, _("Ok"));
Button->SetForegroundColour(*wxRED); wxButton* Button = new wxButton( this, ID_ACCEPT_OPT, _( "Ok" ) );
RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); Button->SetForegroundColour( *wxRED );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton(this, ID_CANCEL_OPT, _("Cancel"));
Button->SetForegroundColour(*wxBLUE); Button = new wxButton( this, ID_CANCEL_OPT, _( "Cancel" ) );
RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); Button->SetForegroundColour( *wxBLUE );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton(this, ID_READ_SHAPE_FILE, _("Read Shape Descr File"));
Button->SetForegroundColour(wxColor(0,100,0) ); Button = new wxButton( this, ID_READ_SHAPE_FILE, _( "Read Shape Descr File" ) );
RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); Button->SetForegroundColour( wxColor( 0, 100, 0 ) );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
wxString shapelist[3] = { _("Normal"), _("Symmetrical"), _("mirrored") };
m_ShapeOptionCtrl = new wxRadioBox(this, -1, _("ShapeOption"), wxString shapelist[3] = { _( "Normal" ), _( "Symmetrical" ), _( "mirrored" ) };
wxDefaultPosition, wxDefaultSize, 3, shapelist, 1, wxRA_SPECIFY_COLS); m_ShapeOptionCtrl = new wxRadioBox( this, -1, _(
LeftBoxSizer->Add(m_ShapeOptionCtrl, 0, wxGROW|wxALL, 5); "ShapeOption" ),
wxDefaultPosition, wxDefaultSize, 3, shapelist, 1,
m_SizeCtrl = new WinEDA_SizeCtrl(this, _("Size"), wxRA_SPECIFY_COLS );
ShapeSize, LeftBoxSizer->Add( m_ShapeOptionCtrl, 0, wxGROW | wxALL, 5 );
g_UnitMetric, LeftBoxSizer, PCB_INTERNAL_UNIT) ;
m_SizeCtrl = new WinEDA_SizeCtrl( this, _( "Size" ),
ShapeSize,
GetSizer()->Fit(this); g_UnitMetric, LeftBoxSizer, PCB_INTERNAL_UNIT );
GetSizer()->SetSizeHints(this);
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
} }
/**********************************************************************/ /**********************************************************************/
void WinEDA_SetParamShapeFrame::OnCancel(wxCommandEvent& WXUNUSED(event)) void WinEDA_SetParamShapeFrame::OnCancel( wxCommandEvent& WXUNUSED (event) )
/**********************************************************************/ /**********************************************************************/
{ {
if ( PolyEdges ) free(PolyEdges); if( PolyEdges )
PolyEdges = NULL; free( PolyEdges );
PolyEdgesCount = 0; PolyEdges = NULL;
EndModal(0); PolyEdgesCount = 0;
EndModal( 0 );
} }
/*******************************************************************/ /*******************************************************************/
void WinEDA_SetParamShapeFrame::AcceptOptions(wxCommandEvent& event) void WinEDA_SetParamShapeFrame::AcceptOptions( wxCommandEvent& event )
/*******************************************************************/ /*******************************************************************/
{ {
ShapeSize = m_SizeCtrl->GetValue(); ShapeSize = m_SizeCtrl->GetValue();
PolyShapeType = m_ShapeOptionCtrl->GetSelection(); PolyShapeType = m_ShapeOptionCtrl->GetSelection();
EndModal(1); EndModal( 1 );
} }
/************************************************************************/ /************************************************************************/
void WinEDA_SetParamShapeFrame::ReadDataShapeDescr(wxCommandEvent& event) void WinEDA_SetParamShapeFrame::ReadDataShapeDescr( wxCommandEvent& event )
/************************************************************************/ /************************************************************************/
/* Read a description shape file /* Read a description shape file
File format is * File format is
Unit=MM * Unit=MM
XScale=271.501 * XScale=271.501
YScale=1.00133 * YScale=1.00133
*
$COORD * $COORD
0 0.6112600148417837 * 0 0.6112600148417837
0.001851851851851852 0.6104800531118608 * 0.001851851851851852 0.6104800531118608
.... * ....
$ENDCOORD * $ENDCOORD
*
Each line is the X Y coord (normalised units from 0 to 1) * Each line is the X Y coord (normalised units from 0 to 1)
*/ */
{ {
wxString FullFileName; wxString FullFileName;
wxString ext, mask; wxString ext, mask;
FILE * File; FILE* File;
char Line[1024]; char Line[1024];
double unitconv = 10000; double unitconv = 10000;
char * param1, *param2; char* param1, * param2;
int bufsize; int bufsize;
double * ptbuf; double* ptbuf;
ext = wxT(".txt"); ext = wxT( ".txt" );
mask = wxT("*") + ext; mask = wxT( "*" ) + ext;
FullFileName = EDA_FileSelector(_("Read descr shape file"), FullFileName = EDA_FileSelector( _( "Read descr shape file" ),
wxEmptyString, /* Chemin par defaut */ wxEmptyString, /* Chemin par defaut */
FullFileName, /* nom fichier par defaut */ FullFileName, /* nom fichier par defaut */
ext, /* extension par defaut */ ext, /* extension par defaut */
mask, /* Masque d'affichage */ mask, /* Masque d'affichage */
this, this,
wxFD_OPEN, wxFD_OPEN,
TRUE /* ne change pas de repertoire courant */ TRUE /* ne change pas de repertoire courant */
); );
if ( FullFileName.IsEmpty()) return; if( FullFileName.IsEmpty() )
return;
File = wxFopen(FullFileName, wxT("rt"));
File = wxFopen( FullFileName, wxT( "rt" ) );
if ( File == NULL )
{ if( File == NULL )
DisplayError(this, _("File not found") ); {
return; DisplayError( this, _( "File not found" ) );
} return;
}
bufsize = 100;
ptbuf = PolyEdges = (double*) MyZMalloc( bufsize * 2 * sizeof(double)); bufsize = 100;
ptbuf = PolyEdges = (double*) MyZMalloc( bufsize * 2 * sizeof(double) );
setlocale(LC_NUMERIC, "C");
int LineNum = 0; setlocale( LC_NUMERIC, "C" );
while( GetLine(File, Line, &LineNum , sizeof(Line) -1) != NULL ) int LineNum = 0;
{ while( GetLine( File, Line, &LineNum, sizeof(Line) - 1 ) != NULL )
param1 = strtok(Line," =\n\r"); {
param2 = strtok(NULL," \t\n\r"); param1 = strtok( Line, " =\n\r" );
param2 = strtok( NULL, " \t\n\r" );
if ( strnicmp(param1, "Unit", 4) == 0)
{ if( strnicmp( param1, "Unit", 4 ) == 0 )
if ( strnicmp(param2, "inch", 4) == 0) unitconv = 10000; {
if ( strnicmp(param2, "mm", 2) == 0) unitconv = 10000/25.4; if( strnicmp( param2, "inch", 4 ) == 0 )
} unitconv = 10000;
if ( strnicmp(param1, "$ENDCOORD", 8) == 0) break; if( strnicmp( param2, "mm", 2 ) == 0 )
if ( strnicmp(param1, "$COORD", 6) == 0) unitconv = 10000 / 25.4;
{ }
while( GetLine(File, Line, &LineNum , sizeof(Line) -1) != NULL ) if( strnicmp( param1, "$ENDCOORD", 8 ) == 0 )
{ break;
param1 = strtok(Line," \t\n\r"); if( strnicmp( param1, "$COORD", 6 ) == 0 )
param2 = strtok(NULL," \t\n\r"); {
if ( strnicmp(param1, "$ENDCOORD", 8) == 0) break; while( GetLine( File, Line, &LineNum, sizeof(Line) - 1 ) != NULL )
if ( bufsize <= PolyEdgesCount ) {
{ param1 = strtok( Line, " \t\n\r" );
int index = ptbuf - PolyEdges; param2 = strtok( NULL, " \t\n\r" );
bufsize *= 2; if( strnicmp( param1, "$ENDCOORD", 8 ) == 0 )
ptbuf = PolyEdges = (double*) realloc( PolyEdges, bufsize * 2 * sizeof(double)); break;
ptbuf += index; if( bufsize <= PolyEdgesCount )
} {
* ptbuf = atof(param1); int index = ptbuf - PolyEdges;
ptbuf++; bufsize *= 2;
* ptbuf = atof(param2); ptbuf = PolyEdges = (double*) realloc( PolyEdges, bufsize * 2 *
ptbuf++; sizeof(double) );
PolyEdgesCount++; ptbuf += index;
} }
} *ptbuf = atof( param1 );
if ( strnicmp(Line, "XScale", 6) == 0) ptbuf++;
{ *ptbuf = atof( param2 );
ShapeScaleX = atof(param2); ptbuf++;
} PolyEdgesCount++;
if ( strnicmp(Line, "YScale", 6) == 0) }
{ }
ShapeScaleY = atof(param2); if( strnicmp( Line, "XScale", 6 ) == 0 )
} {
} ShapeScaleX = atof( param2 );
}
if ( PolyEdgesCount == 0 ) if( strnicmp( Line, "YScale", 6 ) == 0 )
{ {
free(PolyEdges); ShapeScaleY = atof( param2 );
PolyEdges = NULL; }
} }
fclose( File);
setlocale(LC_NUMERIC, ""); // revert to the current locale if( PolyEdgesCount == 0 )
{
ShapeScaleX *= unitconv; free( PolyEdges );
ShapeScaleY *= unitconv; PolyEdges = NULL;
}
m_SizeCtrl->SetValue( (int) ShapeScaleX, (int) ShapeScaleY); fclose( File );
setlocale( LC_NUMERIC, "" ); // revert to the current locale
ShapeScaleX *= unitconv;
ShapeScaleY *= unitconv;
m_SizeCtrl->SetValue( (int) ShapeScaleX, (int) ShapeScaleY );
} }
/*************************************************************/ /*************************************************************/
MODULE * WinEDA_PcbFrame::Create_MuWavePolygonShape(wxDC * DC) MODULE* WinEDA_PcbFrame::Create_MuWavePolygonShape( wxDC* DC )
/*************************************************************/ /*************************************************************/
{ {
D_PAD * pad1, *pad2; D_PAD* pad1, * pad2;
MODULE * Module; MODULE* Module;
wxString cmp_name; wxString cmp_name;
int pad_count = 2; int pad_count = 2;
EDGE_MODULE * edge; int * ptr; EDGE_MODULE* edge; int* ptr;
int ii, npoints; int ii, npoints;
WinEDA_SetParamShapeFrame * frame = new WinEDA_SetParamShapeFrame(this, wxPoint(-1,-1)); WinEDA_SetParamShapeFrame* frame = new WinEDA_SetParamShapeFrame( this, wxPoint( -1, -1 ) );
int ok = frame->ShowModal(); frame->Destroy(); int ok = frame->ShowModal(); frame->Destroy();
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if ( ok != 1 ) if( ok != 1 )
{ {
if ( PolyEdges ) free(PolyEdges); if( PolyEdges )
PolyEdges = NULL; free( PolyEdges );
PolyEdgesCount = 0; PolyEdges = NULL;
return NULL; PolyEdgesCount = 0;
} return NULL;
}
if ( PolyShapeType == 2 ) // mirrored
ShapeScaleY = - ShapeScaleY; if( PolyShapeType == 2 ) // mirrored
ShapeSize.x = (int) round( ShapeScaleX); ShapeScaleY = -ShapeScaleY;
ShapeSize.y = (int) round( ShapeScaleY); ShapeSize.x = (int) round( ShapeScaleX );
ShapeSize.y = (int) round( ShapeScaleY );
if ( (ShapeSize.x) == 0 || (ShapeSize.y == 0) )
{ if( (ShapeSize.x) == 0 || (ShapeSize.y == 0) )
DisplayError(this, _("Shape has a null size!") ); {
return NULL; DisplayError( this, _( "Shape has a null size!" ) );
} return NULL;
if (PolyEdgesCount == 0) }
{ if( PolyEdgesCount == 0 )
DisplayError(this, _("Shape has no points!") ); {
return NULL; DisplayError( this, _( "Shape has no points!" ) );
} return NULL;
}
cmp_name = wxT("POLY");
cmp_name = wxT( "POLY" );
Module = Create_MuWaveBasicShape(NULL, cmp_name, pad_count);
pad1 = Module->m_Pads; Module = Create_MuWaveBasicShape( NULL, cmp_name, pad_count );
pad1 = Module->m_Pads;
pad1->m_Pos0.x = - ShapeSize.x / 2;
pad1->m_Pos.x += pad1->m_Pos0.x; pad1->m_Pos0.x = -ShapeSize.x / 2;
pad1->m_Pos.x += pad1->m_Pos0.x;
pad2 = (D_PAD *) pad1->Pnext;
pad2->m_Pos0.x = pad1->m_Pos0.x + ShapeSize.x; pad2 = (D_PAD*) pad1->Pnext;
pad2->m_Pos.x += pad2->m_Pos0.x; pad2->m_Pos0.x = pad1->m_Pos0.x + ShapeSize.x;
pad2->m_Pos.x += pad2->m_Pos0.x;
edge = new EDGE_MODULE(Module);
Module->m_Drawings = edge; edge = new EDGE_MODULE( Module );
edge->Pback = Module; Module->m_Drawings = edge;
edge->m_Shape = S_POLYGON; edge->Pback = Module;
edge->m_Layer = LAYER_CMP_N; edge->m_Shape = S_POLYGON;
npoints = PolyEdgesCount; edge->m_Layer = LAYER_CMP_N;
switch (PolyShapeType) npoints = PolyEdgesCount;
{
case 0: // Single switch( PolyShapeType )
case 2: // Single, mirrored {
edge->m_PolyCount = PolyEdgesCount + 2; case 0: // Single
break; case 2: // Single, mirrored
edge->m_PolyCount = PolyEdgesCount + 2;
case 1: // Symetric break;
edge->m_PolyCount = (2 * PolyEdgesCount) + 2;
break; case 1: // Symetric
} edge->m_PolyCount = (2 * PolyEdgesCount) + 2;
break;
edge->m_PolyList = (int*) MyMalloc( edge->m_PolyCount * 2 * sizeof(int) ); }
ptr = edge->m_PolyList; edge->m_PolyList = (int*) MyMalloc( edge->m_PolyCount * 2 * sizeof(int) );
// Init start point coord:
* ptr = pad1->m_Pos0.x; ptr++; ptr = edge->m_PolyList;
* ptr = 0; ptr++;
// Init start point coord:
double * dptr = PolyEdges; *ptr = pad1->m_Pos0.x; ptr++;
wxPoint first_cordinate, last_cordinate; *ptr = 0; ptr++;
for ( ii = 0; ii < npoints; ii ++) // Copy points
{ double* dptr = PolyEdges;
last_cordinate.x = * ptr = (int)round(*dptr * ShapeScaleX) + pad1->m_Pos0.x; wxPoint first_cordinate, last_cordinate;
dptr++; ptr++; for( ii = 0; ii < npoints; ii++ ) // Copy points
last_cordinate.y = *ptr = - (int) round( *dptr * ShapeScaleY); {
dptr++; ptr++; last_cordinate.x = *ptr = (int) round( *dptr * ShapeScaleX ) + pad1->m_Pos0.x;
} dptr++; ptr++;
first_cordinate.y = edge->m_PolyList[3]; last_cordinate.y = *ptr = -(int) round( *dptr * ShapeScaleY );
dptr++; ptr++;
switch (PolyShapeType) }
{
int * ptr1; first_cordinate.y = edge->m_PolyList[3];
case 0: // Single
case 2: // Single mirrored switch( PolyShapeType )
// Init end point coord: {
* ptr = pad2->m_Pos0.x = last_cordinate.x; ptr++; int* ptr1;
* ptr = 0;
pad1->m_Size.x = pad1->m_Size.y = ABS(first_cordinate.y); case 0: // Single
pad2->m_Size.x = pad2->m_Size.y = ABS(last_cordinate.y); case 2: // Single mirrored
pad1->m_Pos0.y = first_cordinate.y/2; // Init end point coord:
pad2->m_Pos0.y = last_cordinate.y/2; *ptr = pad2->m_Pos0.x = last_cordinate.x; ptr++;
pad1->m_Pos.y = pad1->m_Pos0.y + Module->m_Pos.y; *ptr = 0;
pad2->m_Pos.y = pad2->m_Pos0.y + Module->m_Pos.y; pad1->m_Size.x = pad1->m_Size.y = ABS( first_cordinate.y );
break; pad2->m_Size.x = pad2->m_Size.y = ABS( last_cordinate.y );
pad1->m_Pos0.y = first_cordinate.y / 2;
case 1: // Symetric pad2->m_Pos0.y = last_cordinate.y / 2;
ptr1 = ptr-2; pad1->m_Pos.y = pad1->m_Pos0.y + Module->m_Pos.y;
for ( ii = 0; ii <= npoints; ii ++) pad2->m_Pos.y = pad2->m_Pos0.y + Module->m_Pos.y;
{ break;
* ptr = * ptr1; // Copy X coord
ptr++; case 1: // Symetric
*ptr = - *(ptr1+1); // Copy Y coord, mirror X axis ptr1 = ptr - 2;
ptr1 -= 2; ptr++; for( ii = 0; ii <= npoints; ii++ )
} {
pad1->m_Size.x = pad1->m_Size.y = 2 * ABS(first_cordinate.y); *ptr = *ptr1; // Copy X coord
pad2->m_Size.x = pad2->m_Size.y = 2 * ABS(last_cordinate.y); ptr++;
break; *ptr = -*(ptr1 + 1); // Copy Y coord, mirror X axis
} ptr1 -= 2; ptr++;
}
free(PolyEdges);
PolyEdgesCount = 0; pad1->m_Size.x = pad1->m_Size.y = 2* ABS( first_cordinate.y );
PolyEdges = NULL;
pad2->m_Size.x = pad2->m_Size.y = 2* ABS( last_cordinate.y );
Module->Set_Rectangle_Encadrement();
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; break;
m_Pcb->m_Status_Pcb = 0 ; }
m_CurrentScreen->SetModify();
return Module; free( PolyEdges );
PolyEdgesCount = 0;
PolyEdges = NULL;
Module->Set_Rectangle_Encadrement();
Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
m_Pcb->m_Status_Pcb = 0;
m_CurrentScreen->SetModify();
return Module;
} }
/***************************************************************/ /***************************************************************/
void WinEDA_PcbFrame::Edit_Gap(wxDC * DC, MODULE * Module) void WinEDA_PcbFrame::Edit_Gap( wxDC* DC, MODULE* Module )
/***************************************************************/ /***************************************************************/
/* /*
Edit le module GAP, c'est a dire modifie la position et la taille * Edit le module GAP, c'est a dire modifie la position et la taille
des pastilles formant le gap pour obtenir une nouvelle valeur du gap * des pastilles formant le gap pour obtenir une nouvelle valeur du gap
*/ */
{ {
int gap_size, oX; int gap_size, oX;
float fcoeff; float fcoeff;
D_PAD* pad, * next_pad; D_PAD* pad, * next_pad;
wxString msg; wxString msg;
if( Module == NULL) return; /* Module non trouve */ if( Module == NULL )
return; /* Module non trouve */
/* Test si module = gap ( nom commence par GAP, et 2 pastilles) */
msg = Module->m_Reference->m_Text.Left(3); /* Test si module = gap ( nom commence par GAP, et 2 pastilles) */
if( msg != wxT("GAP") ) return; msg = Module->m_Reference->m_Text.Left( 3 );
if( msg != wxT( "GAP" ) )
pad = Module->m_Pads; return;
if(pad == NULL )
{ pad = Module->m_Pads;
DisplayError(this, _("No pad for this module")); return; if( pad == NULL )
} {
next_pad = (D_PAD*)pad->Pnext; DisplayError( this, _( "No pad for this module" ) ); return;
if(next_pad == NULL ) }
{ next_pad = (D_PAD*) pad->Pnext;
DisplayError(this, _("Only one pad for this module")); return; if( next_pad == NULL )
} {
DisplayError( this, _( "Only one pad for this module" ) ); return;
/* Effacement du module: */ }
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_XOR) ;
/* Effacement du module: */
/* Calcul de la dimension actuelle */ Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
gap_size = next_pad->m_Pos0.x - pad->m_Pos0.x - pad->m_Size.x;
/* Calcul de la dimension actuelle */
/* Entree de la longueur desiree du gap*/ gap_size = next_pad->m_Pos0.x - pad->m_Pos0.x - pad->m_Size.x;
if( g_UnitMetric)
{ /* Entree de la longueur desiree du gap*/
fcoeff = 10000.0/25.4 ; if( g_UnitMetric )
msg.Printf( wxT("%2.3f"),gap_size / fcoeff); {
Get_Message( _("Gap (mm):"),msg, this); fcoeff = 10000.0 / 25.4;
} msg.Printf( wxT( "%2.3f" ), gap_size / fcoeff );
else Get_Message( _( "Gap (mm):" ), msg, this );
{ }
fcoeff = 10000.0 ; else
msg.Printf( wxT("%2.4f"),gap_size / fcoeff); {
Get_Message( _("Gap (inch):"),msg, this); fcoeff = 10000.0;
} msg.Printf( wxT( "%2.4f" ), gap_size / fcoeff );
Get_Message( _( "Gap (inch):" ), msg, this );
if ( ! msg.IsEmpty() ) }
{
double fval; if( !msg.IsEmpty() )
if ( msg.ToDouble(&fval) ) {
gap_size = (int)( fval * fcoeff ); double fval;
} if( msg.ToDouble( &fval ) )
gap_size = (int) ( fval * fcoeff );
/* Mise a jour des tailles des pastilles formant le gap */ }
pad->m_Size.x = pad->m_Size.y = g_DesignSettings.m_CurrentTrackWidth;
pad->m_Pos0.y = 0; /* Mise a jour des tailles des pastilles formant le gap */
oX = pad->m_Pos0.x =- ((gap_size + pad->m_Size.x) /2); pad->m_Size.x = pad->m_Size.y = g_DesignSettings.m_CurrentTrackWidth;
pad->m_Pos.x = pad->m_Pos0.x + Module->m_Pos.x; pad->m_Pos0.y = 0;
pad->m_Pos.y = pad->m_Pos0.y + Module->m_Pos.y; oX = pad->m_Pos0.x = -( (gap_size + pad->m_Size.x) / 2 );
RotatePoint(&(pad->m_Pos.x),&(pad->m_Pos.y), pad->m_Pos.x = pad->m_Pos0.x + Module->m_Pos.x;
Module->m_Pos.x,Module->m_Pos.y,Module->m_Orient); pad->m_Pos.y = pad->m_Pos0.y + Module->m_Pos.y;
RotatePoint( &(pad->m_Pos.x), &(pad->m_Pos.y),
next_pad->m_Size.x = next_pad->m_Size.y = g_DesignSettings.m_CurrentTrackWidth; Module->m_Pos.x, Module->m_Pos.y, Module->m_Orient );
next_pad->m_Pos0.y = 0;
next_pad->m_Pos0.x = oX + gap_size + next_pad->m_Size.x; next_pad->m_Size.x = next_pad->m_Size.y = g_DesignSettings.m_CurrentTrackWidth;
next_pad->m_Pos.x = next_pad->m_Pos0.x + Module->m_Pos.x; next_pad->m_Pos0.y = 0;
next_pad->m_Pos.y = next_pad->m_Pos0.y + Module->m_Pos.y; next_pad->m_Pos0.x = oX + gap_size + next_pad->m_Size.x;
RotatePoint(&(next_pad->m_Pos.x), &(next_pad->m_Pos.y), next_pad->m_Pos.x = next_pad->m_Pos0.x + Module->m_Pos.x;
Module->m_Pos.x,Module->m_Pos.y, Module->m_Orient); next_pad->m_Pos.y = next_pad->m_Pos0.y + Module->m_Pos.y;
RotatePoint( &(next_pad->m_Pos.x), &(next_pad->m_Pos.y),
Module->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR) ; Module->m_Pos.x, Module->m_Pos.y, Module->m_Orient );
Module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
} }
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#define U_PCB (PCB_INTERNAL_UNIT / EESCHEMA_INTERNAL_UNIT) #define U_PCB (PCB_INTERNAL_UNIT / EESCHEMA_INTERNAL_UNIT)
/* valeur de flag indicant si le pointeur de reference pour une localisation /* valeur de flag indicant si le pointeur de reference pour une localisation
* est le curseur sur grille ou le curseur a deplacement fin hors grille */ * est le curseur sur grille ou le curseur a deplacement fin hors grille */
#define CURSEUR_ON_GRILLE (0 << 0) #define CURSEUR_ON_GRILLE (0 << 0)
#define CURSEUR_OFF_GRILLE (1 << 0) #define CURSEUR_OFF_GRILLE (1 << 0)
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
eda_global wxArrayString g_LibName_List; // library list to load eda_global wxArrayString g_LibName_List; // library list to load
eda_global wxSize g_GridList[] eda_global wxSize g_GridList[]
#ifdef MAIN #ifdef MAIN
= { = {
wxSize( 1000, 1000 ), wxSize( 500, 500 ), wxSize( 250, 250 ), wxSize( 200, 200 ), wxSize( 1000, 1000 ), wxSize( 500, 500 ), wxSize( 250, 250 ), wxSize( 200, 200 ),
...@@ -71,7 +71,7 @@ eda_global wxSize g_GridList[] ...@@ -71,7 +71,7 @@ eda_global wxSize g_GridList[]
; ;
#define UNDELETE_STACK_SIZE 10 #define UNDELETE_STACK_SIZE 10
eda_global EDA_BaseStruct* g_UnDeleteStack[UNDELETE_STACK_SIZE]; //Liste des elements supprimes eda_global EDA_BaseStruct* g_UnDeleteStack[UNDELETE_STACK_SIZE]; // Liste des elements supprimes
eda_global int g_UnDeleteStackPtr; eda_global int g_UnDeleteStackPtr;
eda_global bool g_ShowGrid eda_global bool g_ShowGrid
...@@ -146,6 +146,26 @@ eda_global bool g_ShowIsolDuringCreateTrack; /* .State controle l'affichage ...@@ -146,6 +146,26 @@ eda_global bool g_ShowIsolDuringCreateTrack; /* .State controle l'affichage
eda_global DISPLAY_OPTIONS DisplayOpt; eda_global DISPLAY_OPTIONS DisplayOpt;
/**
* Function IsModuleLayerVisible
* expects either of the two layers on which a module can reside, and returns
* whether that layer is visible.
* @param layer One of the two allowed layers for modules: CMP_N or CUIVRE_N
* @return bool - true if the layer is visible, else false.
*/
bool inline IsModuleLayerVisible( int layer )
{
if( layer==CMP_N )
return DisplayOpt.Show_Modules_Cmp;
else if( layer==CUIVRE_N )
return DisplayOpt.Show_Modules_Cu;
else
return true;
}
eda_global bool Track_45_Only; /* Flag pour limiter l'inclinaison eda_global bool Track_45_Only; /* Flag pour limiter l'inclinaison
* pistes a 45 degres seulement */ * pistes a 45 degres seulement */
eda_global bool Segments_45_Only;/* Flag pour limiter l'inclinaison eda_global bool Segments_45_Only;/* Flag pour limiter l'inclinaison
......
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