beautification, commenting, and renaming
This commit is contained in:
parent
caa42eafca
commit
2e4c17a8b0
|
@ -6,10 +6,18 @@ email address.
|
|||
|
||||
|
||||
|
||||
2007-Aug-05 UPDATE Dick Hollenbeck <dick@softplc.com>
|
||||
================================================================================
|
||||
+ pcbnew & common
|
||||
Changed the function name of Locate( const wxPoint& ref_pos ) to bool HitTest(..)
|
||||
in both class_text_mod and base_struct.
|
||||
More beautification and commenting.
|
||||
|
||||
|
||||
2007-Aug-04 UPDATE Dick Hollenbeck <dick@softplc.com>
|
||||
================================================================================
|
||||
+ pcbnew
|
||||
Read-ability formatting, I am playing with a C++ beautifier called uncrustify.
|
||||
Read-ability formatting, I am playing with a C++ beautifier called "uncrustify".
|
||||
I had to patch it and spent 2 days getting it configured. Patch not
|
||||
sent upstream yet.
|
||||
Fixed a bug in "display local ratsnest pad or module": if you had a small
|
||||
|
|
File diff suppressed because it is too large
Load Diff
299
common/trigo.cpp
299
common/trigo.cpp
|
@ -1,8 +1,8 @@
|
|||
/************************/
|
||||
/* Routines de rotation */
|
||||
/************************/
|
||||
/************************/
|
||||
/* Routines de rotation */
|
||||
/************************/
|
||||
|
||||
/* Fichier TRIGO.CPP */
|
||||
/* Fichier TRIGO.CPP */
|
||||
|
||||
#include "fctsys.h"
|
||||
#define global extern
|
||||
|
@ -10,179 +10,210 @@
|
|||
|
||||
|
||||
/***********************************/
|
||||
int ArcTangente(int dy, int dx)
|
||||
int ArcTangente( int dy, int dx )
|
||||
/***********************************/
|
||||
|
||||
/* Retourne l'arc tangente en 0.1 degres du vecteur de coord dx, dy
|
||||
entre -1800 et 1800
|
||||
Analogue a atan2 ( mais plus rapide pour les calculs si
|
||||
l'angle est souvent 0, -1800, ou +- 900
|
||||
*/
|
||||
* entre -1800 et 1800
|
||||
* Analogue a atan2 ( mais plus rapide pour les calculs si
|
||||
* l'angle est souvent 0, -1800, ou +- 900
|
||||
*/
|
||||
{
|
||||
double fangle;
|
||||
|
||||
if(dy == 0)
|
||||
{
|
||||
if(dx >= 0 ) return(0);
|
||||
else return(-1800);
|
||||
}
|
||||
double fangle;
|
||||
|
||||
if(dx == 0)
|
||||
{
|
||||
if(dy >= 0 ) return(900);
|
||||
else return(-900);
|
||||
}
|
||||
if( dy == 0 )
|
||||
{
|
||||
if( dx >= 0 )
|
||||
return 0;
|
||||
else
|
||||
return -1800;
|
||||
}
|
||||
|
||||
if(dx == dy)
|
||||
{
|
||||
if(dx >= 0) return(450);
|
||||
else return(-1800+450);
|
||||
}
|
||||
if( dx == 0 )
|
||||
{
|
||||
if( dy >= 0 )
|
||||
return 900;
|
||||
else
|
||||
return -900;
|
||||
}
|
||||
|
||||
if(dx == -dy)
|
||||
{
|
||||
if(dx >= 0) return(-450);
|
||||
else return(1800-450);
|
||||
}
|
||||
if( dx == dy )
|
||||
{
|
||||
if( dx >= 0 )
|
||||
return 450;
|
||||
else
|
||||
return -1800 + 450;
|
||||
}
|
||||
|
||||
fangle = atan2( (double)dy, (double)dx ) / M_PI * 1800;
|
||||
return( (int) round(fangle) );
|
||||
if( dx == -dy )
|
||||
{
|
||||
if( dx >= 0 )
|
||||
return -450;
|
||||
else
|
||||
return 1800 - 450;
|
||||
}
|
||||
|
||||
fangle = atan2( (double) dy, (double) dx ) / M_PI * 1800;
|
||||
return (int) round( fangle );
|
||||
}
|
||||
|
||||
|
||||
/*********************************************/
|
||||
void RotatePoint(int *pX, int *pY, int angle)
|
||||
void RotatePoint( int* pX, int* pY, int angle )
|
||||
/*********************************************/
|
||||
|
||||
/*
|
||||
Fonction surchargee!
|
||||
calcule les nouvelles coord du point de coord pX, pY,
|
||||
pour une rotation de centre 0, 0, et d'angle angle ( en 1/10 degre)
|
||||
*/
|
||||
* Fonction surchargee!
|
||||
* calcule les nouvelles coord du point de coord pX, pY,
|
||||
* pour une rotation de centre 0, 0, et d'angle angle ( en 1/10 degre)
|
||||
*/
|
||||
{
|
||||
float fpx, fpy;
|
||||
int tmp;
|
||||
float fpx, fpy;
|
||||
int tmp;
|
||||
|
||||
while (angle < 0) angle += 3600;
|
||||
while (angle >= 3600) angle -= 3600;
|
||||
while( angle < 0 )
|
||||
angle += 3600;
|
||||
|
||||
if (angle == 0) return;
|
||||
while( angle >= 3600 )
|
||||
angle -= 3600;
|
||||
|
||||
/* Calcul des coord :
|
||||
coord: xrot = y*sin + x*cos
|
||||
yrot = y*cos - x*sin
|
||||
*/
|
||||
if( angle == 900 ) /* sin = 1, cos = 0 */
|
||||
{
|
||||
tmp = *pX;
|
||||
*pX = *pY;
|
||||
*pY = - tmp;
|
||||
}
|
||||
if( angle == 0 )
|
||||
return;
|
||||
|
||||
else if( angle == 1800 ) /* sin = 0, cos = -1 */
|
||||
{
|
||||
*pX = - *pX;
|
||||
*pY = - *pY;
|
||||
}
|
||||
/* Calcul des coord :
|
||||
* coord: xrot = y*sin + x*cos
|
||||
* yrot = y*cos - x*sin
|
||||
*/
|
||||
if( angle == 900 ) /* sin = 1, cos = 0 */
|
||||
{
|
||||
tmp = *pX;
|
||||
*pX = *pY;
|
||||
*pY = -tmp;
|
||||
}
|
||||
else if( angle == 1800 ) /* sin = 0, cos = -1 */
|
||||
{
|
||||
*pX = -*pX;
|
||||
*pY = -*pY;
|
||||
}
|
||||
else if( angle == 2700 ) /* sin = -1, cos = 0 */
|
||||
{
|
||||
tmp = *pX;
|
||||
*pX = -*pY;
|
||||
*pY = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]);
|
||||
fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[angle]);
|
||||
|
||||
else if( angle == 2700 ) /* sin = -1, cos = 0 */
|
||||
{
|
||||
tmp = *pX;
|
||||
*pX = - *pY;
|
||||
*pY = tmp;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]);
|
||||
fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[angle]);
|
||||
*pX = (int)round(fpx); *pY = (int)round(fpy);
|
||||
}
|
||||
*pX = (int) round( fpx );
|
||||
*pY = (int) round( fpy );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************************************************************/
|
||||
void RotatePoint(int *pX, int *pY, int cx, int cy, int angle)
|
||||
void RotatePoint( int* pX, int* pY, int cx, int cy, int angle )
|
||||
/*************************************************************/
|
||||
/*
|
||||
Fonction surchargee!
|
||||
calcule les nouvelles coord du point de coord pX, pY,
|
||||
pour une rotation de centre cx, cy, et d'angle angle ( en 1/10 degre)
|
||||
*/
|
||||
{
|
||||
int ox, oy;
|
||||
|
||||
ox = *pX - cx; oy = *pY - cy;
|
||||
RotatePoint(&ox, &oy, angle);
|
||||
*pX = ox + cx;
|
||||
*pY = oy + cy;
|
||||
/*
|
||||
* Fonction surchargee!
|
||||
* calcule les nouvelles coord du point de coord pX, pY,
|
||||
* pour une rotation de centre cx, cy, et d'angle angle ( en 1/10 degre)
|
||||
*/
|
||||
{
|
||||
int ox, oy;
|
||||
|
||||
ox = *pX - cx;
|
||||
oy = *pY - cy;
|
||||
|
||||
RotatePoint( &ox, &oy, angle );
|
||||
|
||||
*pX = ox + cx;
|
||||
*pY = oy + cy;
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
void RotatePoint(wxPoint *point, const wxPoint & centre, int angle)
|
||||
/*****************************************************************/
|
||||
/*
|
||||
Fonction surchargee!
|
||||
calcule les nouvelles coord du point point,
|
||||
pour une rotation de centre centre, et d'angle angle ( en 1/10 degre)
|
||||
*/
|
||||
{
|
||||
int ox, oy;
|
||||
|
||||
ox = point->x - centre.x; oy = point->y - centre.y;
|
||||
RotatePoint(&ox, &oy, angle);
|
||||
point->x = ox + centre.x;
|
||||
point->y = oy + centre.y;
|
||||
/*****************************************************************/
|
||||
void RotatePoint( wxPoint* point, const wxPoint& centre, int angle )
|
||||
/*****************************************************************/
|
||||
|
||||
/*
|
||||
* Fonction surchargee!
|
||||
* calcule les nouvelles coord du point point,
|
||||
* pour une rotation de centre centre, et d'angle angle ( en 1/10 degre)
|
||||
*/
|
||||
{
|
||||
int ox, oy;
|
||||
|
||||
ox = point->x - centre.x;
|
||||
oy = point->y - centre.y;
|
||||
|
||||
RotatePoint( &ox, &oy, angle );
|
||||
point->x = ox + centre.x;
|
||||
point->y = oy + centre.y;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
void RotatePoint(double *pX, double *pY, double cx, double cy, int angle)
|
||||
void RotatePoint( double* pX, double* pY, double cx, double cy, int angle )
|
||||
/*************************************************************************/
|
||||
{
|
||||
double ox, oy;
|
||||
double ox, oy;
|
||||
|
||||
ox = *pX - cx; oy = *pY - cy;
|
||||
RotatePoint(&ox, &oy, angle);
|
||||
*pX = ox + cx;
|
||||
*pY = oy + cy;
|
||||
ox = *pX - cx;
|
||||
oy = *pY - cy;
|
||||
|
||||
RotatePoint( &ox, &oy, angle );
|
||||
|
||||
*pX = ox + cx;
|
||||
*pY = oy + cy;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************/
|
||||
void RotatePoint(double *pX, double *pY, int angle)
|
||||
void RotatePoint( double* pX, double* pY, int angle )
|
||||
/*************************************************/
|
||||
|
||||
/* Calcul des coord :
|
||||
coord: xrot = y*sin + x*cos
|
||||
yrot = y*cos - x*sin
|
||||
*/
|
||||
* coord: xrot = y*sin + x*cos
|
||||
* yrot = y*cos - x*sin
|
||||
*/
|
||||
{
|
||||
double tmp;
|
||||
while (angle < 0) angle += 3600;
|
||||
while (angle >= 3600) angle -= 3600;
|
||||
if (angle == 0) return;
|
||||
if( angle == 900 ) /* sin = 1, cos = 0 */
|
||||
{
|
||||
tmp = *pX;
|
||||
*pX = *pY;
|
||||
*pY = - tmp;
|
||||
}
|
||||
double tmp;
|
||||
|
||||
else if( angle == 1800 ) /* sin = 0, cos = -1 */
|
||||
{
|
||||
*pX = - *pX;
|
||||
*pY = - *pY;
|
||||
}
|
||||
while( angle < 0 )
|
||||
angle += 3600;
|
||||
|
||||
else if( angle == 2700 ) /* sin = -1, cos = 0 */
|
||||
{
|
||||
tmp = *pX;
|
||||
*pX = - *pY;
|
||||
*pY = tmp;
|
||||
}
|
||||
while( angle >= 3600 )
|
||||
angle -= 3600;
|
||||
|
||||
else
|
||||
{
|
||||
double fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]);
|
||||
double fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[angle]);
|
||||
*pX = fpx; *pY = fpy;
|
||||
}
|
||||
if( angle == 0 )
|
||||
return;
|
||||
|
||||
if( angle == 900 ) /* sin = 1, cos = 0 */
|
||||
{
|
||||
tmp = *pX;
|
||||
*pX = *pY;
|
||||
*pY = -tmp;
|
||||
}
|
||||
else if( angle == 1800 ) /* sin = 0, cos = -1 */
|
||||
{
|
||||
*pX = -*pX;
|
||||
*pY = -*pY;
|
||||
}
|
||||
else if( angle == 2700 ) /* sin = -1, cos = 0 */
|
||||
{
|
||||
tmp = *pX;
|
||||
*pX = -*pY;
|
||||
*pY = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
double fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]);
|
||||
double fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[angle]);
|
||||
|
||||
*pX = fpx;
|
||||
*pY = fpy;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,8 +179,14 @@ public:
|
|||
const wxPoint& offset, int color,
|
||||
int draw_mode, int display_mode = FILAIRE, int anchor_color = -1 );
|
||||
|
||||
/* locate functions */
|
||||
int Locate( const wxPoint& posref );
|
||||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param posref A wxPoint to test
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool HitTest( const wxPoint& posref );
|
||||
|
||||
int Len_Size( void ); // Return the text lenght in internal units
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*******************************************/
|
||||
/* class_board.cpp - BOARD class functions */
|
||||
/*******************************************/
|
||||
/*******************************************/
|
||||
/* class_board.cpp - BOARD class functions */
|
||||
/*******************************************/
|
||||
#include "fctsys.h"
|
||||
#include "common.h"
|
||||
|
||||
|
@ -9,237 +9,248 @@
|
|||
#include "bitmaps.h"
|
||||
|
||||
|
||||
|
||||
/*****************/
|
||||
/* Class BOARD: */
|
||||
/*****************/
|
||||
/*****************/
|
||||
/* Class BOARD: */
|
||||
/*****************/
|
||||
|
||||
/* Constructor */
|
||||
BOARD::BOARD(EDA_BaseStruct * parent, WinEDA_BasePcbFrame * frame):
|
||||
EDA_BaseStruct(parent, TYPEPCB)
|
||||
BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) :
|
||||
EDA_BaseStruct( parent, TYPEPCB )
|
||||
{
|
||||
m_PcbFrame = frame;
|
||||
m_Status_Pcb = 0; // Mot d'etat: Bit 1 = Chevelu calcule
|
||||
m_NbNets = 0; // Nombre de nets (equipotentielles)
|
||||
m_BoardSettings = &g_DesignSettings;
|
||||
m_NbPads = 0; // nombre total de pads
|
||||
m_NbNodes = 0; // nombre de pads connectes
|
||||
m_NbLinks = 0; // nombre de chevelus (donc aussi nombre
|
||||
// minimal de pistes a tracer
|
||||
m_NbSegmTrack = 0; // nombre d'elements de type segments de piste
|
||||
m_NbSegmZone = 0; // nombre d'elements de type segments de zone
|
||||
m_NbNoconnect=0; // nombre de chevelus actifs
|
||||
m_NbLoclinks = 0; // nb ratsnest local
|
||||
m_PcbFrame = frame;
|
||||
m_Status_Pcb = 0; // Mot d'etat: Bit 1 = Chevelu calcule
|
||||
m_NbNets = 0; // Nombre de nets (equipotentielles)
|
||||
m_BoardSettings = &g_DesignSettings;
|
||||
m_NbPads = 0; // nombre total de pads
|
||||
m_NbNodes = 0; // nombre de pads connectes
|
||||
m_NbLinks = 0; // nombre de chevelus (donc aussi nombre
|
||||
// minimal de pistes a tracer
|
||||
m_NbSegmTrack = 0; // nombre d'elements de type segments de piste
|
||||
m_NbSegmZone = 0; // nombre d'elements de type segments de zone
|
||||
m_NbNoconnect = 0; // nombre de chevelus actifs
|
||||
m_NbLoclinks = 0; // nb ratsnest local
|
||||
|
||||
m_Drawings = NULL; // pointeur sur liste drawings
|
||||
m_Modules = NULL; // pointeur sur liste zone modules
|
||||
m_Equipots = NULL; // pointeur liste zone equipot
|
||||
m_Track = NULL; // pointeur relatif zone piste
|
||||
m_Zone = NULL; // pointeur tableau zone zones de cuivre
|
||||
m_Pads = NULL; // pointeur liste d'acces aux pads
|
||||
m_Ratsnest = NULL; // pointeur liste rats
|
||||
m_LocalRatsnest = NULL; // pointeur liste rats local
|
||||
m_CurrentLimitZone = NULL; // pointeur liste des EDEGE_ZONES
|
||||
// de determination des contours de zone
|
||||
m_Drawings = NULL; // pointeur sur liste drawings
|
||||
m_Modules = NULL; // pointeur sur liste zone modules
|
||||
m_Equipots = NULL; // pointeur liste zone equipot
|
||||
m_Track = NULL; // pointeur relatif zone piste
|
||||
m_Zone = NULL; // pointeur tableau zone zones de cuivre
|
||||
m_Pads = NULL; // pointeur liste d'acces aux pads
|
||||
m_Ratsnest = NULL; // pointeur liste rats
|
||||
m_LocalRatsnest = NULL; // pointeur liste rats local
|
||||
m_CurrentLimitZone = NULL; // pointeur liste des EDEGE_ZONES
|
||||
// de determination des contours de zone
|
||||
}
|
||||
|
||||
/***************/
|
||||
/* Destructeur */
|
||||
/***************/
|
||||
BOARD::~BOARD(void)
|
||||
|
||||
/***************/
|
||||
/* Destructeur */
|
||||
/***************/
|
||||
BOARD::~BOARD( void )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BOARD::UnLink( void )
|
||||
{
|
||||
/* Modification du chainage arriere */
|
||||
if( Pback )
|
||||
{
|
||||
if( Pback->m_StructType == TYPEPCB)
|
||||
{
|
||||
Pback->Pnext = Pnext;
|
||||
}
|
||||
|
||||
else /* Le chainage arriere pointe sur la structure "Pere" */
|
||||
{
|
||||
/* Modification du chainage arriere */
|
||||
if( Pback )
|
||||
{
|
||||
if( Pback->m_StructType == TYPEPCB )
|
||||
{
|
||||
Pback->Pnext = Pnext;
|
||||
}
|
||||
else /* Le chainage arriere pointe sur la structure "Pere" */
|
||||
{
|
||||
// Pback-> = Pnext;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Modification du chainage avant */
|
||||
if( Pnext) Pnext->Pback = Pback;
|
||||
/* Modification du chainage avant */
|
||||
if( Pnext )
|
||||
Pnext->Pback = Pback;
|
||||
|
||||
Pnext = Pback = NULL;
|
||||
Pnext = Pback = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Routines de calcul des nombres de segments pistes et zones */
|
||||
int BOARD::GetNumSegmTrack(void)
|
||||
int BOARD::GetNumSegmTrack( void )
|
||||
{
|
||||
TRACK * CurTrack = m_Track;
|
||||
int ii = 0;
|
||||
TRACK* CurTrack = m_Track;
|
||||
int ii = 0;
|
||||
|
||||
for ( ;CurTrack != NULL; CurTrack = (TRACK*)CurTrack->Pnext ) ii++;
|
||||
m_NbSegmTrack = ii;
|
||||
return(ii);
|
||||
}
|
||||
int BOARD::GetNumSegmZone(void)
|
||||
{
|
||||
TRACK * CurTrack = m_Zone;
|
||||
int ii = 0;
|
||||
for( ; CurTrack != NULL; CurTrack = (TRACK*) CurTrack->Pnext )
|
||||
ii++;
|
||||
|
||||
for ( ;CurTrack != NULL; CurTrack = (TRACK*)CurTrack->Pnext ) ii++;
|
||||
m_NbSegmZone = ii;
|
||||
return(ii);
|
||||
m_NbSegmTrack = ii;
|
||||
return ii;
|
||||
}
|
||||
|
||||
|
||||
// retourne le nombre de connexions manquantes
|
||||
int BOARD::GetNumNoconnect(void)
|
||||
int BOARD::GetNumSegmZone( void )
|
||||
{
|
||||
return(m_NbNoconnect);
|
||||
TRACK* CurTrack = m_Zone;
|
||||
int ii = 0;
|
||||
|
||||
for( ; CurTrack != NULL; CurTrack = (TRACK*) CurTrack->Pnext )
|
||||
ii++;
|
||||
|
||||
m_NbSegmZone = ii;
|
||||
return ii;
|
||||
}
|
||||
|
||||
// retourne le nombre de chevelus
|
||||
int BOARD::GetNumRatsnests(void)
|
||||
|
||||
// retourne le nombre de connexions manquantes
|
||||
int BOARD::GetNumNoconnect( void )
|
||||
{
|
||||
return(m_NbLinks);
|
||||
return m_NbNoconnect;
|
||||
}
|
||||
|
||||
// retourne le nombre de pads a netcode > 0
|
||||
int BOARD::GetNumNodes(void)
|
||||
|
||||
// retourne le nombre de chevelus
|
||||
int BOARD::GetNumRatsnests( void )
|
||||
{
|
||||
return(m_NbNodes);
|
||||
return m_NbLinks;
|
||||
}
|
||||
|
||||
|
||||
// retourne le nombre de pads a netcode > 0
|
||||
int BOARD::GetNumNodes( void )
|
||||
{
|
||||
return m_NbNodes;
|
||||
}
|
||||
|
||||
|
||||
/***********************************/
|
||||
bool BOARD::ComputeBoundaryBox(void)
|
||||
bool BOARD::ComputeBoundaryBox( void )
|
||||
/***********************************/
|
||||
|
||||
/* Determine le rectangle d'encadrement du pcb
|
||||
Ce rectangle englobe les contours pcb, pads , vias et piste
|
||||
Sortie:
|
||||
m_PcbBox
|
||||
|
||||
retourne:
|
||||
0 si aucun element utile
|
||||
1 sinon
|
||||
*/
|
||||
* Ce rectangle englobe les contours pcb, pads , vias et piste
|
||||
* Sortie:
|
||||
* m_PcbBox
|
||||
*
|
||||
* retourne:
|
||||
* 0 si aucun element utile
|
||||
* 1 sinon
|
||||
*/
|
||||
{
|
||||
int rayon, cx, cy, d, xmin, ymin, xmax, ymax;
|
||||
bool Has_Items = FALSE;
|
||||
EDA_BaseStruct * PtStruct;
|
||||
DRAWSEGMENT* ptr;
|
||||
TRACK * Track;
|
||||
int rayon, cx, cy, d, xmin, ymin, xmax, ymax;
|
||||
bool Has_Items = FALSE;
|
||||
EDA_BaseStruct* PtStruct;
|
||||
DRAWSEGMENT* ptr;
|
||||
TRACK* Track;
|
||||
|
||||
xmin = ymin = 0x7FFFFFFFl ;
|
||||
xmax = ymax = -0x7FFFFFFFl ;
|
||||
xmin = ymin = 0x7FFFFFFFl;
|
||||
xmax = ymax = -0x7FFFFFFFl;
|
||||
|
||||
/* Analyse des Contours PCB */
|
||||
PtStruct = m_Drawings;
|
||||
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
||||
{
|
||||
if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue;
|
||||
ptr = (DRAWSEGMENT*) PtStruct;
|
||||
d = (ptr->m_Width /2) + 1;
|
||||
if(ptr->m_Shape == S_CIRCLE)
|
||||
{
|
||||
cx = ptr->m_Start.x; cy = ptr->m_Start.y;
|
||||
rayon = (int)hypot((double)(ptr->m_End.x-cx),(double)(ptr->m_End.y-cy) );
|
||||
rayon += d;
|
||||
xmin = min(xmin,cx-rayon);
|
||||
ymin = min(ymin,cy-rayon);
|
||||
xmax = max(xmax,cx+rayon);
|
||||
ymax = max(ymax,cy+rayon);
|
||||
Has_Items = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cx = min(ptr->m_Start.x, ptr->m_End.x );
|
||||
cy = min(ptr->m_Start.y, ptr->m_End.y);
|
||||
xmin = min(xmin,cx - d);
|
||||
ymin = min(ymin,cy - d);
|
||||
cx = max(ptr->m_Start.x, ptr->m_End.x );
|
||||
cy = max(ptr->m_Start.y, ptr->m_End.y);
|
||||
xmax = max(xmax,cx + d);
|
||||
ymax = max(ymax,cy + d);
|
||||
Has_Items = TRUE;
|
||||
}
|
||||
}
|
||||
/* Analyse des Contours PCB */
|
||||
PtStruct = m_Drawings;
|
||||
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
||||
{
|
||||
if( PtStruct->m_StructType != TYPEDRAWSEGMENT )
|
||||
continue;
|
||||
|
||||
/* Analyse des Modules */
|
||||
MODULE * module = m_Modules;
|
||||
for( ; module != NULL; module = (MODULE *) module->Pnext )
|
||||
{
|
||||
Has_Items = TRUE;
|
||||
xmin = min(xmin,(module->m_Pos.x + module->m_BoundaryBox.GetX()));
|
||||
ymin = min(ymin,(module->m_Pos.y + module->m_BoundaryBox.GetY()));
|
||||
xmax = max(xmax,module->m_Pos.x + module->m_BoundaryBox.GetRight());
|
||||
ymax = max(ymax,module->m_Pos.y + module->m_BoundaryBox.GetBottom());
|
||||
ptr = (DRAWSEGMENT*) PtStruct;
|
||||
d = (ptr->m_Width / 2) + 1;
|
||||
|
||||
if( ptr->m_Shape == S_CIRCLE )
|
||||
{
|
||||
cx = ptr->m_Start.x; cy = ptr->m_Start.y;
|
||||
rayon = (int) hypot( (double) (ptr->m_End.x - cx), (double) (ptr->m_End.y - cy) );
|
||||
rayon += d;
|
||||
xmin = min( xmin, cx - rayon );
|
||||
ymin = min( ymin, cy - rayon );
|
||||
xmax = max( xmax, cx + rayon );
|
||||
ymax = max( ymax, cy + rayon );
|
||||
Has_Items = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cx = min( ptr->m_Start.x, ptr->m_End.x );
|
||||
cy = min( ptr->m_Start.y, ptr->m_End.y );
|
||||
xmin = min( xmin, cx - d );
|
||||
ymin = min( ymin, cy - d );
|
||||
cx = max( ptr->m_Start.x, ptr->m_End.x );
|
||||
cy = max( ptr->m_Start.y, ptr->m_End.y );
|
||||
xmax = max( xmax, cx + d );
|
||||
ymax = max( ymax, cy + d );
|
||||
Has_Items = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
D_PAD * pt_pad = module->m_Pads;
|
||||
for ( ;pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
|
||||
{
|
||||
d = pt_pad->m_Rayon;
|
||||
xmin = min(xmin,pt_pad->m_Pos.x - d);
|
||||
ymin = min(ymin,pt_pad->m_Pos.y - d);
|
||||
xmax = max(xmax,pt_pad->m_Pos.x + d);
|
||||
ymax = max(ymax,pt_pad->m_Pos.y + d);
|
||||
}
|
||||
}
|
||||
/* Analyse des Modules */
|
||||
MODULE* module = m_Modules;
|
||||
for( ; module != NULL; module = (MODULE*) module->Pnext )
|
||||
{
|
||||
Has_Items = TRUE;
|
||||
xmin = min( xmin, ( module->m_Pos.x + module->m_BoundaryBox.GetX() ) );
|
||||
ymin = min( ymin, ( module->m_Pos.y + module->m_BoundaryBox.GetY() ) );
|
||||
xmax = max( xmax, module->m_Pos.x + module->m_BoundaryBox.GetRight() );
|
||||
ymax = max( ymax, module->m_Pos.y + module->m_BoundaryBox.GetBottom() );
|
||||
|
||||
/* Analyse des segments de piste et zone*/
|
||||
for( Track = m_Track; Track != NULL; Track = (TRACK*) Track->Pnext)
|
||||
{
|
||||
d = (Track->m_Width /2) + 1;
|
||||
cx = min(Track->m_Start.x, Track->m_End.x );
|
||||
cy = min(Track->m_Start.y, Track->m_End.y);
|
||||
xmin = min(xmin,cx - d);
|
||||
ymin = min(ymin,cy - d);
|
||||
cx = max(Track->m_Start.x, Track->m_End.x );
|
||||
cy = max(Track->m_Start.y, Track->m_End.y);
|
||||
xmax = max(xmax,cx + d);
|
||||
ymax = max(ymax,cy + d);
|
||||
Has_Items = TRUE;
|
||||
}
|
||||
D_PAD* pt_pad = module->m_Pads;
|
||||
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
|
||||
{
|
||||
d = pt_pad->m_Rayon;
|
||||
xmin = min( xmin, pt_pad->m_Pos.x - d );
|
||||
ymin = min( ymin, pt_pad->m_Pos.y - d );
|
||||
xmax = max( xmax, pt_pad->m_Pos.x + d );
|
||||
ymax = max( ymax, pt_pad->m_Pos.y + d );
|
||||
}
|
||||
}
|
||||
|
||||
for( Track = m_Zone; Track != NULL; Track = (TRACK*) Track->Pnext)
|
||||
{
|
||||
d = (Track->m_Width /2) + 1;
|
||||
cx = min(Track->m_Start.x, Track->m_End.x );
|
||||
cy = min(Track->m_Start.y, Track->m_End.y);
|
||||
xmin = min(xmin,cx - d);
|
||||
ymin = min(ymin,cy - d);
|
||||
cx = max(Track->m_Start.x, Track->m_End.x );
|
||||
cy = max(Track->m_Start.y, Track->m_End.y);
|
||||
xmax = max(xmax,cx + d);
|
||||
ymax = max(ymax,cy + d);
|
||||
Has_Items = TRUE;
|
||||
}
|
||||
/* Analyse des segments de piste et zone*/
|
||||
for( Track = m_Track; Track != NULL; Track = (TRACK*) Track->Pnext )
|
||||
{
|
||||
d = (Track->m_Width / 2) + 1;
|
||||
cx = min( Track->m_Start.x, Track->m_End.x );
|
||||
cy = min( Track->m_Start.y, Track->m_End.y );
|
||||
xmin = min( xmin, cx - d );
|
||||
ymin = min( ymin, cy - d );
|
||||
cx = max( Track->m_Start.x, Track->m_End.x );
|
||||
cy = max( Track->m_Start.y, Track->m_End.y );
|
||||
xmax = max( xmax, cx + d );
|
||||
ymax = max( ymax, cy + d );
|
||||
Has_Items = TRUE;
|
||||
}
|
||||
|
||||
if ( ! Has_Items && m_PcbFrame )
|
||||
{
|
||||
if ( m_PcbFrame->m_Draw_Sheet_Ref )
|
||||
{
|
||||
xmin = ymin = 0;
|
||||
xmax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().x;
|
||||
ymax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().y;
|
||||
}
|
||||
else
|
||||
{
|
||||
xmin = - m_PcbFrame->m_CurrentScreen->ReturnPageSize().x/2;
|
||||
ymin = - m_PcbFrame->m_CurrentScreen->ReturnPageSize().y/2;
|
||||
xmax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().x/2;
|
||||
ymax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().y/2;
|
||||
}
|
||||
}
|
||||
for( Track = m_Zone; Track != NULL; Track = (TRACK*) Track->Pnext )
|
||||
{
|
||||
d = (Track->m_Width / 2) + 1;
|
||||
cx = min( Track->m_Start.x, Track->m_End.x );
|
||||
cy = min( Track->m_Start.y, Track->m_End.y );
|
||||
xmin = min( xmin, cx - d );
|
||||
ymin = min( ymin, cy - d );
|
||||
cx = max( Track->m_Start.x, Track->m_End.x );
|
||||
cy = max( Track->m_Start.y, Track->m_End.y );
|
||||
xmax = max( xmax, cx + d );
|
||||
ymax = max( ymax, cy + d );
|
||||
Has_Items = TRUE;
|
||||
}
|
||||
|
||||
m_BoundaryBox.SetX(xmin);
|
||||
m_BoundaryBox.SetY(ymin);
|
||||
m_BoundaryBox.SetWidth(xmax - xmin);
|
||||
m_BoundaryBox.SetHeight(ymax - ymin);
|
||||
if( !Has_Items && m_PcbFrame )
|
||||
{
|
||||
if( m_PcbFrame->m_Draw_Sheet_Ref )
|
||||
{
|
||||
xmin = ymin = 0;
|
||||
xmax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().x;
|
||||
ymax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().y;
|
||||
}
|
||||
else
|
||||
{
|
||||
xmin = -m_PcbFrame->m_CurrentScreen->ReturnPageSize().x / 2;
|
||||
ymin = -m_PcbFrame->m_CurrentScreen->ReturnPageSize().y / 2;
|
||||
xmax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().x / 2;
|
||||
ymax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().y / 2;
|
||||
}
|
||||
}
|
||||
|
||||
return(Has_Items);
|
||||
m_BoundaryBox.SetX( xmin );
|
||||
m_BoundaryBox.SetY( ymin );
|
||||
m_BoundaryBox.SetWidth( xmax - xmin );
|
||||
m_BoundaryBox.SetHeight( ymax - ymin );
|
||||
|
||||
return Has_Items;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************/
|
||||
/* class_module.cpp : fonctions de la classe MODULE */
|
||||
/****************************************************/
|
||||
/****************************************************/
|
||||
/* class_module.cpp : fonctions de la classe MODULE */
|
||||
/****************************************************/
|
||||
|
||||
#include "fctsys.h"
|
||||
#include "gr_basic.h"
|
||||
|
@ -22,246 +22,275 @@
|
|||
|
||||
#include "protos.h"
|
||||
|
||||
/************************************************************************/
|
||||
/* Class TEXTE_MODULE classe de base des elements type Texte sur module */
|
||||
/************************************************************************/
|
||||
/************************************************************************/
|
||||
/* Class TEXTE_MODULE classe de base des elements type Texte sur module */
|
||||
/************************************************************************/
|
||||
|
||||
/* Constructeur de TEXTE_MODULE */
|
||||
TEXTE_MODULE::TEXTE_MODULE(MODULE * parent, int text_type ):
|
||||
EDA_BaseStruct( parent, TYPETEXTEMODULE)
|
||||
TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) :
|
||||
EDA_BaseStruct( parent, TYPETEXTEMODULE )
|
||||
{
|
||||
MODULE * Module = (MODULE*) m_Parent;
|
||||
MODULE* Module = (MODULE*) m_Parent;
|
||||
|
||||
m_NoShow = 0; /* visible */
|
||||
m_Type = text_type; /* Reference */
|
||||
if( (m_Type != TEXT_is_REFERENCE) && (m_Type != TEXT_is_VALUE) )
|
||||
m_Type = TEXT_is_DIVERS;
|
||||
m_NoShow = 0; /* visible */
|
||||
m_Type = text_type; /* Reference */
|
||||
if( (m_Type != TEXT_is_REFERENCE) && (m_Type != TEXT_is_VALUE) )
|
||||
m_Type = TEXT_is_DIVERS;
|
||||
|
||||
m_Size.x = m_Size.y = 400; m_Width = 120; /* dimensions raisonnables par defaut */
|
||||
m_Orient = 0; /* en 1/10 degre */
|
||||
m_Miroir = 1; // Mode normal (pas de miroir)
|
||||
m_Unused = 0;
|
||||
m_Layer = SILKSCREEN_N_CMP;
|
||||
if( Module && (Module->m_StructType == TYPEMODULE) )
|
||||
{
|
||||
m_Pos = Module->m_Pos;
|
||||
m_Layer = Module->m_Layer;
|
||||
if( Module->m_Layer == CUIVRE_N) m_Layer = SILKSCREEN_N_CU;
|
||||
if(Module->m_Layer == CMP_N) m_Layer = SILKSCREEN_N_CMP;
|
||||
if((Module->m_Layer == SILKSCREEN_N_CU) ||
|
||||
(Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N))
|
||||
m_Miroir = 0;
|
||||
}
|
||||
m_Size.x = m_Size.y = 400; m_Width = 120; /* dimensions raisonnables par defaut */
|
||||
m_Orient = 0; /* en 1/10 degre */
|
||||
m_Miroir = 1; // Mode normal (pas de miroir)
|
||||
m_Unused = 0;
|
||||
m_Layer = SILKSCREEN_N_CMP;
|
||||
if( Module && (Module->m_StructType == TYPEMODULE) )
|
||||
{
|
||||
m_Pos = Module->m_Pos;
|
||||
m_Layer = Module->m_Layer;
|
||||
if( Module->m_Layer == CUIVRE_N )
|
||||
m_Layer = SILKSCREEN_N_CU;
|
||||
if( Module->m_Layer == CMP_N )
|
||||
m_Layer = SILKSCREEN_N_CMP;
|
||||
if( (Module->m_Layer == SILKSCREEN_N_CU)
|
||||
|| (Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_N) )
|
||||
m_Miroir = 0;
|
||||
}
|
||||
}
|
||||
|
||||
TEXTE_MODULE:: ~TEXTE_MODULE(void)
|
||||
|
||||
TEXTE_MODULE::~TEXTE_MODULE( void )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TEXTE_MODULE::Copy(TEXTE_MODULE * source) // copy structure
|
||||
void TEXTE_MODULE::Copy( TEXTE_MODULE* source ) // copy structure
|
||||
{
|
||||
if (source == NULL) return;
|
||||
if( source == NULL )
|
||||
return;
|
||||
|
||||
m_Pos = source->m_Pos;
|
||||
m_Layer = source->m_Layer;
|
||||
m_Pos = source->m_Pos;
|
||||
m_Layer = source->m_Layer;
|
||||
|
||||
m_Miroir = source->m_Miroir; // vue normale / miroir
|
||||
m_NoShow = source->m_NoShow; // 0: visible 1: invisible
|
||||
m_Type = source->m_Type; // 0: ref,1: val, autre = 2..255
|
||||
m_Orient = source->m_Orient; // orientation en 1/10 degre
|
||||
m_Pos0 = source->m_Pos0; // coord du debut du texte /ancre, orient 0
|
||||
m_Miroir = source->m_Miroir; // vue normale / miroir
|
||||
m_NoShow = source->m_NoShow; // 0: visible 1: invisible
|
||||
m_Type = source->m_Type; // 0: ref,1: val, autre = 2..255
|
||||
m_Orient = source->m_Orient; // orientation en 1/10 degre
|
||||
m_Pos0 = source->m_Pos0; // coord du debut du texte /ancre, orient 0
|
||||
|
||||
m_Size = source->m_Size;
|
||||
m_Width = source->m_Width;
|
||||
m_Size = source->m_Size;
|
||||
m_Width = source->m_Width;
|
||||
|
||||
m_Text = source->m_Text;
|
||||
m_Text = source->m_Text;
|
||||
}
|
||||
|
||||
|
||||
/* supprime du chainage la structure Struct
|
||||
les structures arrieres et avant sont chainees directement
|
||||
* les structures arrieres et avant sont chainees directement
|
||||
*/
|
||||
void TEXTE_MODULE::UnLink( void )
|
||||
{
|
||||
/* Modification du chainage arriere */
|
||||
if( Pback )
|
||||
{
|
||||
if( Pback->m_StructType != TYPEMODULE)
|
||||
{
|
||||
Pback->Pnext = Pnext;
|
||||
}
|
||||
/* Modification du chainage arriere */
|
||||
if( Pback )
|
||||
{
|
||||
if( Pback->m_StructType != TYPEMODULE )
|
||||
{
|
||||
Pback->Pnext = Pnext;
|
||||
}
|
||||
else /* Le chainage arriere pointe sur la structure "Pere" */
|
||||
{
|
||||
( (MODULE*) Pback )->m_Drawings = Pnext;
|
||||
}
|
||||
}
|
||||
|
||||
else /* Le chainage arriere pointe sur la structure "Pere" */
|
||||
{
|
||||
((MODULE*)Pback)->m_Drawings = Pnext;
|
||||
}
|
||||
}
|
||||
/* Modification du chainage avant */
|
||||
if( Pnext )
|
||||
Pnext->Pback = Pback;
|
||||
|
||||
/* Modification du chainage avant */
|
||||
if( Pnext) Pnext->Pback = Pback;
|
||||
|
||||
Pnext = Pback = NULL;
|
||||
Pnext = Pback = NULL;
|
||||
}
|
||||
|
||||
|
||||
/******************************************/
|
||||
int TEXTE_MODULE:: GetLength(void)
|
||||
int TEXTE_MODULE:: GetLength( void )
|
||||
/******************************************/
|
||||
{
|
||||
return m_Text.Len();
|
||||
return m_Text.Len();
|
||||
}
|
||||
|
||||
|
||||
/******************************************/
|
||||
void TEXTE_MODULE:: SetWidth(int new_width)
|
||||
void TEXTE_MODULE:: SetWidth( int new_width )
|
||||
/******************************************/
|
||||
{
|
||||
m_Width = new_width;
|
||||
m_Width = new_width;
|
||||
}
|
||||
|
||||
// mise a jour des coordonnées absolues pour affichage
|
||||
void TEXTE_MODULE:: SetDrawCoord(void)
|
||||
|
||||
// mise a jour des coordonn<6E>s absolues pour affichage
|
||||
void TEXTE_MODULE:: SetDrawCoord( void )
|
||||
{
|
||||
MODULE * Module = (MODULE *) m_Parent;
|
||||
MODULE* Module = (MODULE*) m_Parent;
|
||||
|
||||
m_Pos = m_Pos0;
|
||||
m_Pos = m_Pos0;
|
||||
|
||||
if ( Module == NULL ) return;
|
||||
if( Module == NULL )
|
||||
return;
|
||||
|
||||
int angle = Module->m_Orient;
|
||||
NORMALIZE_ANGLE_POS(angle);
|
||||
int angle = Module->m_Orient;
|
||||
NORMALIZE_ANGLE_POS( angle );
|
||||
|
||||
RotatePoint( &m_Pos.x, &m_Pos.y, angle);
|
||||
m_Pos.x += Module->m_Pos.x;
|
||||
m_Pos.y += Module->m_Pos.y;
|
||||
RotatePoint( &m_Pos.x, &m_Pos.y, angle );
|
||||
m_Pos.x += Module->m_Pos.x;
|
||||
m_Pos.y += Module->m_Pos.y;
|
||||
}
|
||||
|
||||
// mise a jour des coordonnées relatives au module
|
||||
void TEXTE_MODULE:: SetLocalCoord(void)
|
||||
|
||||
// mise a jour des coordonn<6E>s relatives au module
|
||||
void TEXTE_MODULE:: SetLocalCoord( void )
|
||||
{
|
||||
MODULE * Module = (MODULE *) m_Parent;
|
||||
MODULE* Module = (MODULE*) m_Parent;
|
||||
|
||||
if ( Module == NULL ) return;
|
||||
if( Module == NULL )
|
||||
return;
|
||||
|
||||
m_Pos0.x = m_Pos.x - Module->m_Pos.x;
|
||||
m_Pos0.y = m_Pos.y - Module->m_Pos.y;
|
||||
m_Pos0.x = m_Pos.x - Module->m_Pos.x;
|
||||
m_Pos0.y = m_Pos.y - Module->m_Pos.y;
|
||||
|
||||
int angle = Module->m_Orient;
|
||||
NORMALIZE_ANGLE_POS(angle);
|
||||
int angle = Module->m_Orient;
|
||||
NORMALIZE_ANGLE_POS( angle );
|
||||
|
||||
RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle);
|
||||
RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle );
|
||||
}
|
||||
|
||||
/* locate functions */
|
||||
int TEXTE_MODULE:: Locate(const wxPoint & posref)
|
||||
|
||||
/* locate functions */
|
||||
bool TEXTE_MODULE::HitTest( const wxPoint& posref )
|
||||
{
|
||||
int mX, mY, dx, dy;
|
||||
MODULE * Module = (MODULE *) m_Parent;
|
||||
int angle = m_Orient;
|
||||
int mX, mY, dx, dy;
|
||||
MODULE* Module = (MODULE*) m_Parent;
|
||||
int angle = m_Orient;
|
||||
|
||||
if (Module) angle += Module->m_Orient;
|
||||
if( Module )
|
||||
angle += Module->m_Orient;
|
||||
|
||||
dx = (m_Size.x * GetLength()) /2;
|
||||
dy = m_Size.y / 2 ;
|
||||
dx = ((dx * 10) / 9) + m_Width; /* Facteur de forme des lettres : 10/9 */
|
||||
dx = ( m_Size.x * GetLength() ) / 2;
|
||||
dy = m_Size.y / 2;
|
||||
dx = ( (dx * 10) / 9 ) + m_Width; /* Facteur de forme des lettres : 10/9 */
|
||||
|
||||
/* le point de reference est tourné de - angle
|
||||
pour se ramener a un rectangle de reference horizontal */
|
||||
mX = posref.x - m_Pos.x; mY = posref.y - m_Pos.y;
|
||||
RotatePoint(&mX, &mY, - angle);
|
||||
/* le point de reference est-il dans ce rectangle */
|
||||
if( ( abs(mX) <= abs(dx) ) && ( abs(mY) <= abs(dy)) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
/* le point de reference est tourn<72>de - angle
|
||||
* pour se ramener a un rectangle de reference horizontal */
|
||||
mX = posref.x - m_Pos.x;
|
||||
mY = posref.y - m_Pos.y;
|
||||
|
||||
RotatePoint( &mX, &mY, -angle );
|
||||
|
||||
/* le point de reference est-il dans ce rectangle */
|
||||
if( ( abs( mX ) <= abs( dx ) ) && ( abs( mY ) <= abs( dy ) ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************************/
|
||||
void TEXTE_MODULE::Draw(WinEDA_DrawPanel * panel, wxDC * DC, wxPoint offset, int draw_mode)
|
||||
void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, wxPoint offset, int draw_mode )
|
||||
/******************************************************************************************/
|
||||
|
||||
/* trace 1 texte de module
|
||||
Utilise la police definie dans grfonte.h
|
||||
(Se reporter a ce fichier pour les explications complementaires)
|
||||
offset = offset de trace ( reference au centre du texte)
|
||||
draw_mode = GR_OR, GR_XOR..
|
||||
*/
|
||||
* Utilise la police definie dans grfonte.h
|
||||
* (Se reporter a ce fichier pour les explications complementaires)
|
||||
* offset = offset de trace ( reference au centre du texte)
|
||||
* draw_mode = GR_OR, GR_XOR..
|
||||
*/
|
||||
{
|
||||
int zoom;
|
||||
int width, color, orient, miroir;
|
||||
wxSize size;
|
||||
wxPoint pos; // Centre du texte
|
||||
PCB_SCREEN * screen;
|
||||
WinEDA_BasePcbFrame * frame;
|
||||
MODULE * Module = (MODULE *) m_Parent;
|
||||
int zoom;
|
||||
int width, color, orient, miroir;
|
||||
wxSize size;
|
||||
wxPoint pos; // Centre du texte
|
||||
PCB_SCREEN* screen;
|
||||
WinEDA_BasePcbFrame* frame;
|
||||
MODULE* Module = (MODULE*) m_Parent;
|
||||
|
||||
|
||||
if ( panel == NULL ) return;
|
||||
|
||||
screen = (PCB_SCREEN *) panel->GetScreen();
|
||||
frame = ( WinEDA_BasePcbFrame * ) panel->m_Parent;
|
||||
zoom = screen->GetZoom();
|
||||
if( panel == NULL )
|
||||
return;
|
||||
|
||||
pos.x = m_Pos.x - offset.x;
|
||||
pos.y = m_Pos.y - offset.y;
|
||||
screen = (PCB_SCREEN*) panel->GetScreen();
|
||||
frame = (WinEDA_BasePcbFrame*) panel->m_Parent;
|
||||
zoom = screen->GetZoom();
|
||||
|
||||
size = m_Size;
|
||||
orient = GetDrawRotation();
|
||||
miroir = m_Miroir & 1 ; // = 0 si vu en miroir
|
||||
width = m_Width;
|
||||
if( (frame->m_DisplayModText == FILAIRE) || ( (width/zoom) < L_MIN_DESSIN) )
|
||||
width = 0;
|
||||
else if ( frame->m_DisplayModText == SKETCH ) width = -width;
|
||||
pos.x = m_Pos.x - offset.x;
|
||||
pos.y = m_Pos.y - offset.y;
|
||||
|
||||
GRSetDrawMode(DC, draw_mode);
|
||||
size = m_Size;
|
||||
orient = GetDrawRotation();
|
||||
miroir = m_Miroir & 1; // = 0 si vu en miroir
|
||||
width = m_Width;
|
||||
if( (frame->m_DisplayModText == FILAIRE) || ( (width / zoom) < L_MIN_DESSIN ) )
|
||||
width = 0;
|
||||
else if( frame->m_DisplayModText == SKETCH )
|
||||
width = -width;
|
||||
|
||||
/* trace du centre du texte */
|
||||
if((g_AnchorColor & ITEM_NOT_SHOW) == 0 )
|
||||
{
|
||||
int anchor_size = 2*zoom;
|
||||
GRLine(&panel->m_ClipBox, DC,
|
||||
pos.x - anchor_size, pos.y,
|
||||
pos.x + anchor_size, pos.y, 0, g_AnchorColor);
|
||||
GRLine(&panel->m_ClipBox, DC,
|
||||
pos.x, pos.y - anchor_size,
|
||||
pos.x, pos.y + anchor_size, 0, g_AnchorColor);
|
||||
}
|
||||
GRSetDrawMode( DC, draw_mode );
|
||||
|
||||
color = g_DesignSettings.m_LayerColor[Module->m_Layer];
|
||||
/* trace du centre du texte */
|
||||
if( (g_AnchorColor & ITEM_NOT_SHOW) == 0 )
|
||||
{
|
||||
int anchor_size = 2 * zoom;
|
||||
GRLine( &panel->m_ClipBox, DC,
|
||||
pos.x - anchor_size, pos.y,
|
||||
pos.x + anchor_size, pos.y, 0, g_AnchorColor );
|
||||
GRLine( &panel->m_ClipBox, DC,
|
||||
pos.x, pos.y - anchor_size,
|
||||
pos.x, pos.y + anchor_size, 0, g_AnchorColor );
|
||||
}
|
||||
|
||||
if( Module && Module->m_Layer == CUIVRE_N) color = g_ModuleTextCUColor;
|
||||
if( Module && Module->m_Layer == CMP_N) color = g_ModuleTextCMPColor;
|
||||
|
||||
if ( (color & ITEM_NOT_SHOW) != 0 ) return;
|
||||
color = g_DesignSettings.m_LayerColor[Module->m_Layer];
|
||||
|
||||
if(m_NoShow) color = g_ModuleTextNOVColor;
|
||||
if ( (color & ITEM_NOT_SHOW) != 0 ) return;
|
||||
if( Module && Module->m_Layer == CUIVRE_N )
|
||||
color = g_ModuleTextCUColor;
|
||||
if( Module && Module->m_Layer == CMP_N )
|
||||
color = g_ModuleTextCMPColor;
|
||||
|
||||
/* Si le texte doit etre mis en miroir: modif des parametres */
|
||||
if( miroir == 0 ) size.x = - size.x;
|
||||
if( (color & ITEM_NOT_SHOW) != 0 )
|
||||
return;
|
||||
|
||||
/* Trace du texte */
|
||||
DrawGraphicText(panel, DC, pos , color, m_Text,
|
||||
orient, size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width);
|
||||
if( m_NoShow )
|
||||
color = g_ModuleTextNOVColor;
|
||||
if( (color & ITEM_NOT_SHOW) != 0 )
|
||||
return;
|
||||
|
||||
/* Si le texte doit etre mis en miroir: modif des parametres */
|
||||
if( miroir == 0 )
|
||||
size.x = -size.x;
|
||||
|
||||
/* Trace du texte */
|
||||
DrawGraphicText( panel, DC, pos, color, m_Text,
|
||||
orient, size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width );
|
||||
}
|
||||
|
||||
|
||||
/******************************************/
|
||||
int TEXTE_MODULE::GetDrawRotation(void)
|
||||
int TEXTE_MODULE::GetDrawRotation( void )
|
||||
/******************************************/
|
||||
|
||||
/* Return text rotation for drawings and plotting
|
||||
*/
|
||||
*/
|
||||
{
|
||||
int rotation;
|
||||
MODULE * Module = (MODULE *) m_Parent;
|
||||
int rotation;
|
||||
MODULE* Module = (MODULE*) m_Parent;
|
||||
|
||||
rotation = m_Orient;
|
||||
if( Module )
|
||||
rotation += Module->m_Orient;
|
||||
|
||||
NORMALIZE_ANGLE_POS( rotation );
|
||||
|
||||
rotation = m_Orient;
|
||||
if ( Module ) rotation += Module->m_Orient;
|
||||
|
||||
NORMALIZE_ANGLE_POS(rotation);
|
||||
// if( (rotation > 900 ) && (rotation < 2700 ) ) rotation -= 1800; // For angle = 0 .. 180 deg
|
||||
while ( rotation > 900 ) rotation -= 1800; // For angle = -90 .. 90 deg
|
||||
|
||||
return rotation;
|
||||
}
|
||||
while( rotation > 900 )
|
||||
rotation -= 1800;
|
||||
|
||||
// For angle = -90 .. 90 deg
|
||||
|
||||
return rotation;
|
||||
}
|
||||
|
|
|
@ -1,56 +1,61 @@
|
|||
/***************************************************/
|
||||
/* class_text_module.h : texts module description */
|
||||
/***************************************************/
|
||||
/***************************************************/
|
||||
/* class_text_module.h : texts module description */
|
||||
/***************************************************/
|
||||
|
||||
/* Description des Textes sur Modules : */
|
||||
#define TEXT_is_REFERENCE 0
|
||||
#define TEXT_is_VALUE 1
|
||||
#define TEXT_is_DIVERS 2
|
||||
#define TEXT_is_VALUE 1
|
||||
#define TEXT_is_DIVERS 2
|
||||
|
||||
|
||||
class TEXTE_MODULE: public EDA_BaseStruct
|
||||
class TEXTE_MODULE : public EDA_BaseStruct
|
||||
{
|
||||
public:
|
||||
int m_Layer; // layer number
|
||||
int m_Width;
|
||||
wxPoint m_Pos; // Real coord
|
||||
wxPoint m_Pos0; // coord du debut du texte /ancre, orient 0
|
||||
char m_Unused; // unused (reserved for future extensions)
|
||||
char m_Miroir ; // vue normale / miroir
|
||||
char m_NoShow; // 0: visible 1: invisible (bool)
|
||||
char m_Type; // 0: ref,1: val, autre = 2..255
|
||||
int m_Orient; // orientation en 1/10 degre
|
||||
wxSize m_Size; // dimensions (en X et Y) du texte
|
||||
wxString m_Text;
|
||||
int m_Layer; // layer number
|
||||
int m_Width;
|
||||
wxPoint m_Pos; // Real coord
|
||||
wxPoint m_Pos0; // coord du debut du texte /ancre, orient 0
|
||||
char m_Unused; // unused (reserved for future extensions)
|
||||
char m_Miroir; // vue normale / miroir
|
||||
char m_NoShow; // 0: visible 1: invisible (bool)
|
||||
char m_Type; // 0: ref,1: val, autre = 2..255
|
||||
int m_Orient; // orientation en 1/10 degre
|
||||
wxSize m_Size; // dimensions (en X et Y) du texte
|
||||
wxString m_Text;
|
||||
|
||||
public:
|
||||
TEXTE_MODULE(MODULE * parent, int text_type = TEXT_is_DIVERS );
|
||||
~TEXTE_MODULE(void);
|
||||
public:
|
||||
TEXTE_MODULE( MODULE* parent, int text_type = TEXT_is_DIVERS );
|
||||
~TEXTE_MODULE( void );
|
||||
|
||||
/* supprime du chainage la structure Struct */
|
||||
void UnLink( void );
|
||||
/* supprime du chainage la structure Struct */
|
||||
void UnLink( void );
|
||||
|
||||
void Copy(TEXTE_MODULE * source); // copy structure
|
||||
|
||||
/* Gestion du texte */
|
||||
void SetWidth(int new_width);
|
||||
int GetLength(void); /* text length */
|
||||
int Pitch(void); /* retourne le pas entre 2 caracteres */
|
||||
int GetDrawRotation(void); // Return text rotation for drawings and plotting
|
||||
void Copy( TEXTE_MODULE* source ); // copy structure
|
||||
|
||||
void SetDrawCoord(void); // mise a jour des coordonnées absolues de tracé
|
||||
// a partir des coord relatives
|
||||
void SetLocalCoord(void); // mise a jour des coordonnées relatives
|
||||
// a partir des coord absolues de tracé
|
||||
/* Gestion du texte */
|
||||
void SetWidth( int new_width );
|
||||
int GetLength( void ); /* text length */
|
||||
int Pitch( void ); /* retourne le pas entre 2 caracteres */
|
||||
int GetDrawRotation( void ); // Return text rotation for drawings and plotting
|
||||
|
||||
/* Reading and writing data on files */
|
||||
int WriteDescr( FILE * File );
|
||||
int ReadDescr( FILE * File, int * LineNum = NULL);
|
||||
void SetDrawCoord( void ); // mise a jour des coordonn<6E>s absolues de trac<61>
|
||||
// a partir des coord relatives
|
||||
|
||||
/* drawing functions */
|
||||
void Draw(WinEDA_DrawPanel * panel, wxDC * DC, wxPoint offset, int draw_mode);
|
||||
void SetLocalCoord( void ); // mise a jour des coordonn<6E>s relatives
|
||||
|
||||
/* locate functions */
|
||||
int Locate(const wxPoint & posref);
|
||||
// a partir des coord absolues de trac<61>
|
||||
/* Reading and writing data on files */
|
||||
int WriteDescr( FILE* File );
|
||||
int ReadDescr( FILE* File, int* LineNum = NULL );
|
||||
|
||||
/* drawing functions */
|
||||
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, wxPoint offset, int draw_mode );
|
||||
|
||||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param posref A wxPoint to test
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool HitTest( const wxPoint& posref );
|
||||
};
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
|
|||
{
|
||||
bool PopupOn = GetScreen()->m_CurrentItem
|
||||
&& GetScreen()->m_CurrentItem->m_Flags;
|
||||
|
||||
bool ItemFree = (GetScreen()->m_CurrentItem == 0 )
|
||||
|| (GetScreen()->m_CurrentItem->m_Flags == 0);
|
||||
|
||||
|
@ -63,10 +64,10 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
|
|||
|| (GetScreen()->m_CurrentItem->m_Flags == 0);
|
||||
if( ItemFree )
|
||||
{
|
||||
//no track is currently being edited - select a segment and remove it.
|
||||
// no track is currently being edited - select a segment and remove it.
|
||||
DrawStruct = PcbGeneralLocateAndDisplay();
|
||||
|
||||
//don't let backspace delete modules!!
|
||||
// don't let backspace delete modules!!
|
||||
if( DrawStruct && (DrawStruct->m_StructType == TYPETRACK
|
||||
|| DrawStruct->m_StructType == TYPEVIA) )
|
||||
Delete_Segment( DC, (TRACK*) DrawStruct );
|
||||
|
@ -74,7 +75,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
|
|||
}
|
||||
else if( GetScreen()->m_CurrentItem->m_StructType == TYPETRACK )
|
||||
{
|
||||
//then an element is being edited - remove the last segment.
|
||||
// then an element is being edited - remove the last segment.
|
||||
GetScreen()->m_CurrentItem =
|
||||
Delete_Segment( DC, (TRACK*) GetScreen()->m_CurrentItem );
|
||||
GetScreen()->SetModify();
|
||||
|
@ -97,7 +98,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
|
|||
|
||||
case 'O' + GR_KB_CTRL:
|
||||
{
|
||||
//try not to duplicate save, load code etc.
|
||||
// try not to duplicate save, load code etc.
|
||||
wxCommandEvent evt;
|
||||
evt.SetId( ID_LOAD_FILE );
|
||||
Files_io( evt );
|
||||
|
@ -106,7 +107,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
|
|||
|
||||
case 'S' + GR_KB_CTRL:
|
||||
{
|
||||
//try not to duplicate save, load code etc.
|
||||
// try not to duplicate save, load code etc.
|
||||
wxCommandEvent evt;
|
||||
evt.SetId( ID_SAVE_BOARD );
|
||||
Files_io( evt );
|
||||
|
@ -163,10 +164,18 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
|
|||
if( module == NULL ) // no footprint found
|
||||
{
|
||||
module = Locate_Prefered_Module( m_Pcb, CURSEUR_OFF_GRILLE );
|
||||
if( module ) // a footprint is found, but locked or on an other layer
|
||||
if( module )
|
||||
{
|
||||
// a footprint is found, but locked or on an other layer
|
||||
if( module->IsLocked() )
|
||||
DisplayInfo( this, _( "Footprint found, but locked" ) );
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
msg.Printf( _("Footprint %s found, but locked"),
|
||||
module->m_Reference->m_Text.GetData() );
|
||||
|
||||
DisplayInfo( this, msg );
|
||||
}
|
||||
module = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -426,7 +426,7 @@ EDA_BaseStruct* Locate_Cotation( BOARD* Pcb, int LayerSearch, int typeloc )
|
|||
pt_txt = Cotation->m_Text;
|
||||
if( pt_txt )
|
||||
{
|
||||
if( pt_txt->Locate( ref_pos ) )
|
||||
if( pt_txt->HitTest( ref_pos ) )
|
||||
return PtStruct;
|
||||
}
|
||||
|
||||
|
@ -857,7 +857,7 @@ TEXTE_MODULE* LocateTexteModule( BOARD* Pcb, MODULE** PtModule, int typeloc )
|
|||
|
||||
// hit-test the reference text
|
||||
pt_txt_mod = module->m_Reference;
|
||||
if( pt_txt_mod->Locate( ref_pos ) )
|
||||
if( pt_txt_mod->HitTest( ref_pos ) )
|
||||
{
|
||||
if( PtModule )
|
||||
*PtModule = module;
|
||||
|
@ -866,7 +866,7 @@ TEXTE_MODULE* LocateTexteModule( BOARD* Pcb, MODULE** PtModule, int typeloc )
|
|||
|
||||
// hit-test the value text
|
||||
pt_txt_mod = module->m_Value;
|
||||
if( pt_txt_mod->Locate( ref_pos ) )
|
||||
if( pt_txt_mod->HitTest( ref_pos ) )
|
||||
{
|
||||
if( PtModule )
|
||||
*PtModule = module;
|
||||
|
@ -881,7 +881,7 @@ TEXTE_MODULE* LocateTexteModule( BOARD* Pcb, MODULE** PtModule, int typeloc )
|
|||
continue;
|
||||
|
||||
pt_txt_mod = (TEXTE_MODULE*) PtStruct;
|
||||
if( pt_txt_mod->Locate( ref_pos ) )
|
||||
if( pt_txt_mod->HitTest( ref_pos ) )
|
||||
{
|
||||
if( PtModule )
|
||||
*PtModule = module;
|
||||
|
@ -1151,7 +1151,7 @@ TEXTE_PCB* Locate_Texte_Pcb( EDA_BaseStruct* PtStruct, int LayerSearch, int type
|
|||
if( PtStruct->m_StructType != TYPETEXTE )
|
||||
continue;
|
||||
TEXTE_PCB* pt_txt_pcb = (TEXTE_PCB*) PtStruct;
|
||||
if( pt_txt_pcb->Locate( ref ) )
|
||||
if( pt_txt_pcb->HitTest( ref ) )
|
||||
{
|
||||
if( pt_txt_pcb->m_Layer == LayerSearch )
|
||||
return pt_txt_pcb;
|
||||
|
|
Loading…
Reference in New Issue