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>
|
2007-Aug-04 UPDATE Dick Hollenbeck <dick@softplc.com>
|
||||||
================================================================================
|
================================================================================
|
||||||
+ pcbnew
|
+ 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
|
I had to patch it and spent 2 days getting it configured. Patch not
|
||||||
sent upstream yet.
|
sent upstream yet.
|
||||||
Fixed a bug in "display local ratsnest pad or module": if you had a small
|
Fixed a bug in "display local ratsnest pad or module": if you had a small
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
/* methodes pour les structures de base: */
|
/* methodes pour les structures de base: */
|
||||||
/* EDA_BaseStruct (classe non utilisable seule) */
|
/* EDA_BaseStruct (classe non utilisable seule) */
|
||||||
/* EDA_TextStruct (classe non utilisable seule) */
|
/* EDA_TextStruct (classe non utilisable seule) */
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
|
|
||||||
/* Fichier base_struct.cpp */
|
/* Fichier base_struct.cpp */
|
||||||
|
|
||||||
#include "fctsys.h"
|
#include "fctsys.h"
|
||||||
#include "gr_basic.h"
|
#include "gr_basic.h"
|
||||||
|
@ -18,66 +18,64 @@
|
||||||
|
|
||||||
|
|
||||||
// DrawStructureType names for error messages only:
|
// DrawStructureType names for error messages only:
|
||||||
static wxString DrawStructureTypeName[MAX_STRUCT_TYPE_ID+1]
|
static wxString DrawStructureTypeName[MAX_STRUCT_TYPE_ID + 1]
|
||||||
= {
|
= {
|
||||||
wxT("Not init"),
|
wxT( "Not init" ),
|
||||||
|
|
||||||
wxT("Pcb"),
|
wxT( "Pcb" ),
|
||||||
wxT("Equipot"),
|
wxT( "Equipot" ),
|
||||||
wxT("Module"),
|
wxT( "Module" ),
|
||||||
wxT("Pad"),
|
wxT( "Pad" ),
|
||||||
wxT("DrawSegment"),
|
wxT( "DrawSegment" ),
|
||||||
wxT("Text (pcb)"),
|
wxT( "Text (pcb)" ),
|
||||||
wxT("Text module"),
|
wxT( "Text module" ),
|
||||||
wxT("edge module"),
|
wxT( "edge module" ),
|
||||||
wxT("track"),
|
wxT( "track" ),
|
||||||
wxT("zone"),
|
wxT( "zone" ),
|
||||||
wxT("via"),
|
wxT( "via" ),
|
||||||
wxT("marker"),
|
wxT( "marker" ),
|
||||||
wxT("cotation"),
|
wxT( "cotation" ),
|
||||||
wxT("mire"),
|
wxT( "mire" ),
|
||||||
wxT("screen"),
|
wxT( "screen" ),
|
||||||
wxT("block"),
|
wxT( "block" ),
|
||||||
wxT("edge zone"),
|
wxT( "edge zone" ),
|
||||||
|
|
||||||
wxT("Polyline"),
|
wxT( "Polyline" ),
|
||||||
wxT("Junction"),
|
wxT( "Junction" ),
|
||||||
wxT("Text"),
|
wxT( "Text" ),
|
||||||
wxT("Label"),
|
wxT( "Label" ),
|
||||||
wxT("Glob label"),
|
wxT( "Glob label" ),
|
||||||
wxT("Lib item"),
|
wxT( "Lib item" ),
|
||||||
wxT("Pick struct"),
|
wxT( "Pick struct" ),
|
||||||
wxT("Segment"),
|
wxT( "Segment" ),
|
||||||
wxT("Raccord"),
|
wxT( "Raccord" ),
|
||||||
wxT("Sheet"),
|
wxT( "Sheet" ),
|
||||||
wxT("Sheet label"),
|
wxT( "Sheet label" ),
|
||||||
wxT("Marker"),
|
wxT( "Marker" ),
|
||||||
wxT("No connect"),
|
wxT( "No connect" ),
|
||||||
wxT("Text (lib item)"),
|
wxT( "Text (lib item)" ),
|
||||||
wxT("Screen"),
|
wxT( "Screen" ),
|
||||||
wxT("Block locate"),
|
wxT( "Block locate" ),
|
||||||
wxT("Library component"),
|
wxT( "Library component" ),
|
||||||
wxT("lib cmp draw circle"),
|
wxT( "lib cmp draw circle" ),
|
||||||
wxT("lib cmp draw graphic text"),
|
wxT( "lib cmp draw graphic text" ),
|
||||||
wxT("lib cmp draw rect"),
|
wxT( "lib cmp draw rect" ),
|
||||||
wxT("lib cmp draw poly line"),
|
wxT( "lib cmp draw poly line" ),
|
||||||
wxT("lib cmp draw line"),
|
wxT( "lib cmp draw line" ),
|
||||||
wxT("lib cmp pin"),
|
wxT( "lib cmp pin" ),
|
||||||
wxT("lib cmp field"),
|
wxT( "lib cmp field" ),
|
||||||
wxT("unknown"),
|
wxT( "unknown" ),
|
||||||
wxT("unknown")
|
wxT( "unknown" )
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum textbox {
|
enum textbox {
|
||||||
ID_TEXTBOX_LIST = 8010
|
ID_TEXTBOX_LIST = 8010
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
EDA_BaseStruct::EDA_BaseStruct(EDA_BaseStruct * parent, int idType)
|
EDA_BaseStruct::EDA_BaseStruct( EDA_BaseStruct* parent, int idType )
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
{
|
{
|
||||||
InitVars();
|
InitVars();
|
||||||
|
@ -87,15 +85,16 @@ EDA_BaseStruct::EDA_BaseStruct(EDA_BaseStruct * parent, int idType)
|
||||||
|
|
||||||
|
|
||||||
/********************************************/
|
/********************************************/
|
||||||
EDA_BaseStruct::EDA_BaseStruct(int idType)
|
EDA_BaseStruct::EDA_BaseStruct( int idType )
|
||||||
/********************************************/
|
/********************************************/
|
||||||
{
|
{
|
||||||
InitVars();
|
InitVars();
|
||||||
m_StructType = idType;
|
m_StructType = idType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************************************/
|
/********************************************/
|
||||||
void EDA_BaseStruct::InitVars(void)
|
void EDA_BaseStruct::InitVars( void )
|
||||||
/********************************************/
|
/********************************************/
|
||||||
{
|
{
|
||||||
m_StructType = TYPE_NOT_INIT;
|
m_StructType = TYPE_NOT_INIT;
|
||||||
|
@ -112,24 +111,28 @@ void EDA_BaseStruct::InitVars(void)
|
||||||
|
|
||||||
|
|
||||||
/* Gestion de l'etat (status) de la structure (active, deleted..) */
|
/* Gestion de l'etat (status) de la structure (active, deleted..) */
|
||||||
int EDA_BaseStruct::GetState(int type)
|
int EDA_BaseStruct::GetState( int type )
|
||||||
{
|
{
|
||||||
return(m_Status & type);
|
return m_Status & type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EDA_BaseStruct::SetState(int type, int state )
|
|
||||||
|
void EDA_BaseStruct::SetState( int type, int state )
|
||||||
{
|
{
|
||||||
if( state ) m_Status |= type; /* state = ON ou OFF */
|
if( state )
|
||||||
else m_Status &= ~type;
|
m_Status |= type;/* state = ON ou OFF */
|
||||||
|
else
|
||||||
|
m_Status &= ~type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************/
|
/*********************************************************/
|
||||||
void EDA_BaseStruct::AddToChain(EDA_BaseStruct * laststruct)
|
void EDA_BaseStruct::AddToChain( EDA_BaseStruct* laststruct )
|
||||||
/*********************************************************/
|
/*********************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
addition d'une nouvelle struct a la liste chainée, apres la structure laststruct
|
* addition d'une nouvelle struct a la liste chain<EFBFBD>, apres la structure laststruct
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
Pnext = laststruct->Pnext;
|
Pnext = laststruct->Pnext;
|
||||||
Pback = laststruct;
|
Pback = laststruct;
|
||||||
|
@ -138,51 +141,59 @@ addition d'une nouvelle struct a la liste chain
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
void EDA_BaseStruct::Draw(WinEDA_DrawPanel * panel, wxDC * DC, const wxPoint & offset,
|
void EDA_BaseStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
|
||||||
int draw_mode, int Color)
|
int draw_mode, int Color )
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
||||||
/* Virtual
|
/* Virtual
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
wxString msg, name;
|
wxString msg, name;
|
||||||
msg.Printf( wxT("EDA_BaseStruct::Draw() error. Method for struct type %d used but not implemented ("),
|
|
||||||
m_StructType);
|
msg.Printf( wxT(
|
||||||
msg += ReturnClassName() + wxT(")\n");
|
"EDA_BaseStruct::Draw() error. Method for struct type %d used but not implemented (" ),
|
||||||
printf ( CONV_TO_UTF8(msg));
|
m_StructType );
|
||||||
|
msg += ReturnClassName() + wxT( ")\n" );
|
||||||
|
printf( CONV_TO_UTF8( msg ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
void EDA_BaseStruct::Place(WinEDA_DrawFrame * frame, wxDC * DC)
|
void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
|
|
||||||
/* fonction virtuelle de placement: non utilisee en pcbnew (utilisee eeschema)
|
/* fonction virtuelle de placement: non utilisee en pcbnew (utilisee eeschema)
|
||||||
---- A mieux utiliser (TODO...)
|
* ---- A mieux utiliser (TODO...)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
wxString EDA_BaseStruct::ReturnClassName(void)
|
wxString EDA_BaseStruct::ReturnClassName( void )
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
/* Used at run time for diags: return the class name of the item,
|
|
||||||
from its .m_StructType value.
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
int ii = m_StructType;
|
|
||||||
wxString classname;
|
|
||||||
|
|
||||||
if ( (ii < 0) || (ii > MAX_STRUCT_TYPE_ID) ) ii = MAX_STRUCT_TYPE_ID;
|
/* Used at run time for diags: return the class name of the item,
|
||||||
|
* from its .m_StructType value.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
int ii = m_StructType;
|
||||||
|
wxString classname;
|
||||||
|
|
||||||
|
if( (ii < 0) || (ii > MAX_STRUCT_TYPE_ID) )
|
||||||
|
ii = MAX_STRUCT_TYPE_ID;
|
||||||
classname = DrawStructureTypeName[ii];
|
classname = DrawStructureTypeName[ii];
|
||||||
|
|
||||||
return classname;
|
return classname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************************************/
|
/**********************************************************************************************/
|
||||||
EDA_BaseLineStruct::EDA_BaseLineStruct(EDA_BaseStruct * StructFather, DrawStructureType idtype):
|
EDA_BaseLineStruct::EDA_BaseLineStruct( EDA_BaseStruct* StructFather, DrawStructureType idtype ) :
|
||||||
EDA_BaseStruct(StructFather, idtype)
|
EDA_BaseStruct( StructFather, idtype )
|
||||||
/**********************************************************************************************/
|
/**********************************************************************************************/
|
||||||
{
|
{
|
||||||
m_Layer = 0;
|
m_Layer = 0;
|
||||||
|
@ -191,9 +202,9 @@ EDA_BaseLineStruct::EDA_BaseLineStruct(EDA_BaseStruct * StructFather, DrawStruct
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************/
|
/*********************************************************/
|
||||||
/* EDA_TextStruct (classe de base, non utilisée seule */
|
/* EDA_TextStruct (classe de base, non utilis<EFBFBD> seule */
|
||||||
/*********************************************************/
|
/*********************************************************/
|
||||||
EDA_TextStruct::EDA_TextStruct(const wxString & text)
|
EDA_TextStruct::EDA_TextStruct( const wxString& text )
|
||||||
{
|
{
|
||||||
m_Layer = 0;
|
m_Layer = 0;
|
||||||
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT; /* XY size of font */
|
m_Size.x = m_Size.y = DEFAULT_SIZE_TEXT; /* XY size of font */
|
||||||
|
@ -207,108 +218,124 @@ EDA_TextStruct::EDA_TextStruct(const wxString & text)
|
||||||
m_Text = text;
|
m_Text = text;
|
||||||
m_ZoomLevelDrawable = 0; /* Niveau de zoom acceptable pour affichage normal */
|
m_ZoomLevelDrawable = 0; /* Niveau de zoom acceptable pour affichage normal */
|
||||||
m_TextDrawings = NULL; /* Pointeur sur le dessin du caractere */
|
m_TextDrawings = NULL; /* Pointeur sur le dessin du caractere */
|
||||||
m_TextDrawingsSize = 0; /* taille du tableau pointé */
|
m_TextDrawingsSize = 0; /* taille du tableau point<6E>*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EDA_TextStruct::~EDA_TextStruct(void)
|
EDA_TextStruct::~EDA_TextStruct( void )
|
||||||
{
|
{
|
||||||
if( m_TextDrawings ) /* pointeur sur la liste des segments de dessin */
|
if( m_TextDrawings ) /* pointeur sur la liste des segments de dessin */
|
||||||
{
|
{
|
||||||
free(m_TextDrawings); m_TextDrawings = NULL;
|
free( m_TextDrawings ); m_TextDrawings = NULL;
|
||||||
}
|
}
|
||||||
m_TextDrawingsSize = 0; /* nombre de sommets a dessiner */
|
m_TextDrawingsSize = 0; /* nombre de sommets a dessiner */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************************/
|
/********************************/
|
||||||
int EDA_TextStruct::Len_Size(void)
|
int EDA_TextStruct::Len_Size( void )
|
||||||
/********************************/
|
/********************************/
|
||||||
|
|
||||||
// Return the text lenght in internal units
|
// Return the text lenght in internal units
|
||||||
{
|
{
|
||||||
int nbchar = m_Text.Len();
|
int nbchar = m_Text.Len();
|
||||||
int len;
|
int len;
|
||||||
if ( nbchar == 0 ) return 0;
|
|
||||||
|
|
||||||
len = ((10 * m_Size.x ) / 9) * nbchar;
|
if( nbchar == 0 )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
len = ( (10 * m_Size.x ) / 9 ) * nbchar;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************/
|
/*************************************************/
|
||||||
int EDA_TextStruct::Locate(const wxPoint & posref)
|
bool EDA_TextStruct::HitTest( const wxPoint& posref )
|
||||||
/*************************************************/
|
/*************************************************/
|
||||||
/* locate function
|
|
||||||
return:
|
|
||||||
1 if posref is inside the text area.
|
|
||||||
0 else.
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
int dx, dy;
|
|
||||||
int spot_cX, spot_cY;
|
|
||||||
|
|
||||||
dx = (Pitch() * GetLength()) / 2;
|
/* locate function
|
||||||
dy = m_Size.y /2 ;
|
* return:
|
||||||
|
* true if posref is inside the text area.
|
||||||
|
* false else.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
int dx, dy;
|
||||||
|
int spot_cX, spot_cY;
|
||||||
|
|
||||||
|
dx = ( Pitch() * GetLength() ) / 2;
|
||||||
|
dy = m_Size.y / 2;
|
||||||
|
|
||||||
/* Is the ref point inside the text area ? */
|
/* Is the ref point inside the text area ? */
|
||||||
spot_cX = posref.x - m_Pos.x ; spot_cY = posref.y - m_Pos.y ;
|
spot_cX = posref.x - m_Pos.x;
|
||||||
RotatePoint(&spot_cX, &spot_cY, - m_Orient);
|
spot_cY = posref.y - m_Pos.y;
|
||||||
if( (abs(spot_cX) <= abs(dx) ) && ( abs(spot_cY) <= abs(dy) ) ) return 1;
|
|
||||||
return 0;
|
RotatePoint( &spot_cX, &spot_cY, -m_Orient );
|
||||||
|
|
||||||
|
if( ( abs( spot_cX ) <= abs( dx ) ) && ( abs( spot_cY ) <= abs( dy ) ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************/
|
/*******************************/
|
||||||
int EDA_TextStruct::Pitch(void)
|
int EDA_TextStruct::Pitch( void )
|
||||||
/*******************************/
|
/*******************************/
|
||||||
|
|
||||||
/* retourne le pas entre 2 caracteres
|
/* retourne le pas entre 2 caracteres
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
return ((10 * m_Size.x ) / 9) + m_Width;
|
return ( (10 * m_Size.x ) / 9 ) + m_Width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
|
||||||
void EDA_TextStruct::Draw(WinEDA_DrawPanel * panel, wxDC * DC,
|
|
||||||
const wxPoint & offset, int color, int draw_mode,
|
|
||||||
int display_mode, int anchor_color)
|
|
||||||
/***************************************************************/
|
|
||||||
/*
|
|
||||||
Trace de 1 texte type EDA_TextStruct.
|
|
||||||
offset = Offset de trace (usuellement (0,0)
|
|
||||||
color = couleur du texte
|
|
||||||
draw_mode = GR_OR, GR_XOR.., -1 si mode courant.
|
|
||||||
display_mose = FILAIRE, FILLED ou SKETCH
|
|
||||||
anchor_color = couleur de l'ancre ( -1 si pas d'ancre ).
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
int zoom;
|
|
||||||
int coord[104];
|
|
||||||
int ii, jj, kk, ll, nbpoints;
|
|
||||||
int width;
|
|
||||||
|
|
||||||
if( m_TextDrawings == NULL) /* pointeur sur la liste des segments de dessin */
|
/***************************************************************/
|
||||||
|
void EDA_TextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
||||||
|
const wxPoint& offset, int color, int draw_mode,
|
||||||
|
int display_mode, int anchor_color )
|
||||||
|
/***************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Trace de 1 texte type EDA_TextStruct.
|
||||||
|
* offset = Offset de trace (usuellement (0,0)
|
||||||
|
* color = couleur du texte
|
||||||
|
* draw_mode = GR_OR, GR_XOR.., -1 si mode courant.
|
||||||
|
* display_mose = FILAIRE, FILLED ou SKETCH
|
||||||
|
* anchor_color = couleur de l'ancre ( -1 si pas d'ancre ).
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
int zoom;
|
||||||
|
int coord[104];
|
||||||
|
int ii, jj, kk, ll, nbpoints;
|
||||||
|
int width;
|
||||||
|
|
||||||
|
if( m_TextDrawings == NULL ) /* pointeur sur la liste des segments de dessin */
|
||||||
CreateDrawData();
|
CreateDrawData();
|
||||||
if( m_TextDrawings == NULL) return;
|
if( m_TextDrawings == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
zoom = panel->GetZoom();
|
zoom = panel->GetZoom();
|
||||||
width = m_Width / zoom;
|
width = m_Width / zoom;
|
||||||
if ( display_mode == FILAIRE ) width = 0;
|
if( display_mode == FILAIRE )
|
||||||
|
width = 0;
|
||||||
/* choix de la couleur du texte : */
|
/* choix de la couleur du texte : */
|
||||||
if ( draw_mode != -1 ) GRSetDrawMode(DC, draw_mode);
|
if( draw_mode != -1 )
|
||||||
|
GRSetDrawMode( DC, draw_mode );
|
||||||
|
|
||||||
/* trace du texte */
|
/* trace du texte */
|
||||||
if ( zoom > m_ZoomLevelDrawable)
|
if( zoom > m_ZoomLevelDrawable )
|
||||||
{
|
{
|
||||||
GRLine(&panel->m_ClipBox, DC,
|
GRLine( &panel->m_ClipBox, DC,
|
||||||
m_TextDrawings[1] + offset.x + m_Pos.x,
|
m_TextDrawings[1] + offset.x + m_Pos.x,
|
||||||
m_TextDrawings[2] + offset.y + m_Pos.y,
|
m_TextDrawings[2] + offset.y + m_Pos.y,
|
||||||
m_TextDrawings[3] + offset.x + m_Pos.x,
|
m_TextDrawings[3] + offset.x + m_Pos.x,
|
||||||
m_TextDrawings[4] + offset.y + m_Pos.y,
|
m_TextDrawings[4] + offset.y + m_Pos.y,
|
||||||
width, color);
|
width, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* trace ancre du texte ? */
|
/* trace ancre du texte ? */
|
||||||
if( anchor_color != -1)
|
if( anchor_color != -1 )
|
||||||
{
|
{
|
||||||
int anchor_size = 2 * zoom;
|
int anchor_size = 2 * zoom;
|
||||||
anchor_color &= MASKCOLOR;
|
anchor_color &= MASKCOLOR;
|
||||||
|
@ -316,93 +343,98 @@ int width;
|
||||||
int cX = m_Pos.x - offset.x;
|
int cX = m_Pos.x - offset.x;
|
||||||
int cY = m_Pos.y - offset.y;
|
int cY = m_Pos.y - offset.y;
|
||||||
/* trace ancre du texte */
|
/* trace ancre du texte */
|
||||||
GRLine(&panel->m_ClipBox, DC, cX - anchor_size, cY,
|
GRLine( &panel->m_ClipBox, DC, cX - anchor_size, cY,
|
||||||
cX + anchor_size, cY, 0, anchor_color);
|
cX + anchor_size, cY, 0, anchor_color );
|
||||||
GRLine(&panel->m_ClipBox, DC, cX, cY - anchor_size ,
|
GRLine( &panel->m_ClipBox, DC, cX, cY - anchor_size,
|
||||||
cX, cY + anchor_size , 0, anchor_color);
|
cX, cY + anchor_size, 0, anchor_color );
|
||||||
}
|
}
|
||||||
jj = 5; ii = jj+1;
|
jj = 5; ii = jj + 1;
|
||||||
while (ii < m_TextDrawingsSize)
|
while( ii < m_TextDrawingsSize )
|
||||||
{
|
{
|
||||||
nbpoints = m_TextDrawings[jj];
|
nbpoints = m_TextDrawings[jj];
|
||||||
if (nbpoints > 50 ) nbpoints = 50;
|
if( nbpoints > 50 )
|
||||||
for ( kk = 0, ll = 0; (kk < nbpoints) && (ii < m_TextDrawingsSize) ; kk++)
|
nbpoints = 50;
|
||||||
|
for( kk = 0, ll = 0; (kk < nbpoints) && (ii < m_TextDrawingsSize); kk++ )
|
||||||
{
|
{
|
||||||
coord[ll] = m_TextDrawings[ii] + offset.x + m_Pos.x;
|
coord[ll] = m_TextDrawings[ii] + offset.x + m_Pos.x;
|
||||||
ll++; ii++;
|
ll++; ii++;
|
||||||
coord[ll] = m_TextDrawings[ii] + offset.y + m_Pos.y;
|
coord[ll] = m_TextDrawings[ii] + offset.y + m_Pos.y;
|
||||||
ll++; ii++;
|
ll++; ii++;
|
||||||
}
|
}
|
||||||
|
|
||||||
jj = ii; ii++;
|
jj = ii; ii++;
|
||||||
|
|
||||||
if( width > 2)
|
if( width > 2 )
|
||||||
{
|
{
|
||||||
for ( kk = 0, ll = 0; kk < (nbpoints-1); kk ++, ll+= 2 )
|
for( kk = 0, ll = 0; kk < (nbpoints - 1); kk++, ll += 2 )
|
||||||
{
|
{
|
||||||
if( display_mode == SKETCH)
|
if( display_mode == SKETCH )
|
||||||
GRCSegm(&panel->m_ClipBox, DC,
|
GRCSegm( &panel->m_ClipBox, DC,
|
||||||
coord[ll],coord[ll+1],
|
coord[ll], coord[ll + 1],
|
||||||
coord[ll+2],coord[ll+3],
|
coord[ll + 2], coord[ll + 3],
|
||||||
m_Width, color) ;
|
m_Width, color );
|
||||||
|
|
||||||
else GRFillCSegm(&panel->m_ClipBox, DC,
|
else
|
||||||
coord[ll],coord[ll+1],
|
GRFillCSegm( &panel->m_ClipBox, DC,
|
||||||
coord[ll+2],coord[ll+3],
|
coord[ll], coord[ll + 1],
|
||||||
m_Width, color) ;
|
coord[ll + 2], coord[ll + 3],
|
||||||
|
m_Width, color );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
GRPoly(&panel->m_ClipBox, DC, nbpoints, coord, 0, 0, color, color);
|
GRPoly( &panel->m_ClipBox, DC, nbpoints, coord, 0, 0, color, color );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
void EDA_TextStruct::CreateDrawData(void)
|
void EDA_TextStruct::CreateDrawData( void )
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* Cree le tableau de données nécessaire au trace d'un texte (pcb, module..)
|
|
||||||
Met a jour:
|
/* Cree le tableau de donn<6E>s n<>essaire au trace d'un texte (pcb, module..)
|
||||||
m_ZoomLevelDrawable Niveau de zoom acceptable pour affichage normal
|
* Met a jour:
|
||||||
m_TextDrawings Pointeur sur le tableau de données
|
* m_ZoomLevelDrawable Niveau de zoom acceptable pour affichage normal
|
||||||
m_TextDrawingsSize taille (en int) du tableau
|
* m_TextDrawings Pointeur sur le tableau de donn<EFBFBD>s
|
||||||
Codage dans le tableau:
|
* m_TextDrawingsSize taille (en int) du tableau
|
||||||
Suite des coord des sommets des polygones a tracer précédé du nombre de sommets
|
* Codage dans le tableau:
|
||||||
nn xx1 yy1 xx2 yy2 .. xxn yyn mm xx1 yy1 xx2 yy2 .. xxm yym
|
* Suite des coord des sommets des polygones a tracer pr<EFBFBD><EFBFBD><EFBFBD>du nombre de sommets
|
||||||
les 2 premiers sommets sont le segment symbolisant le texte pour les
|
* nn xx1 yy1 xx2 yy2 .. xxn yyn mm xx1 yy1 xx2 yy2 .. xxm yym
|
||||||
affichages a trop petite echelle
|
* les 2 premiers sommets sont le segment symbolisant le texte pour les
|
||||||
*/
|
* affichages a trop petite echelle
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
int ii, jj, kk,nbchar, nbpoints, AsciiCode, endcar;
|
int ii, jj, kk, nbchar, nbpoints, AsciiCode, endcar;
|
||||||
int k1 , k2 , x0 , y0 ;
|
int k1, k2, x0, y0;
|
||||||
int size_h , size_v , espacement ;
|
int size_h, size_v, espacement;
|
||||||
char f_cod , plume = 'U';
|
char f_cod, plume = 'U';
|
||||||
const wxChar * ptr;
|
const wxChar* ptr;
|
||||||
const SH_CODE * ptcar;
|
const SH_CODE* ptcar;
|
||||||
int ux0, uy0, dx, dy; // Coord de trace des segments de texte & variables de calcul */
|
int ux0, uy0, dx, dy; // Coord de trace des segments de texte & variables de calcul */
|
||||||
int cX, cY; // Centre du texte
|
int cX, cY; // Centre du texte
|
||||||
int ox, oy; // coord de trace du caractere courant
|
int ox, oy; // coord de trace du caractere courant
|
||||||
int * coord; // liste des coord des segments a tracer
|
int* coord; // liste des coord des segments a tracer
|
||||||
int coord_count_max = 1000;
|
int coord_count_max = 1000;
|
||||||
|
|
||||||
if( m_TextDrawings ) /* pointeur sur la liste des segments de dessin */
|
if( m_TextDrawings ) /* pointeur sur la liste des segments de dessin */
|
||||||
{
|
{
|
||||||
free(m_TextDrawings); m_TextDrawings = 0;
|
free( m_TextDrawings ); m_TextDrawings = 0;
|
||||||
}
|
}
|
||||||
m_TextDrawingsSize = 0; /* nombre de segments a dessiner */
|
m_TextDrawingsSize = 0; /* nombre de segments a dessiner */
|
||||||
|
|
||||||
nbchar = m_Text.Length();
|
nbchar = m_Text.Length();
|
||||||
if ( nbchar == 0 ) return;
|
if( nbchar == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
size_h = m_Size.x;
|
size_h = m_Size.x;
|
||||||
size_v = m_Size.y;
|
size_v = m_Size.y;
|
||||||
espacement = Pitch();
|
espacement = Pitch();
|
||||||
if ( m_Miroir == 0 )
|
if( m_Miroir == 0 )
|
||||||
{
|
{
|
||||||
size_h = -size_h; espacement = - espacement;
|
size_h = -size_h; espacement = -espacement;
|
||||||
}
|
}
|
||||||
|
|
||||||
kk = 0; ptr = m_Text.GetData() ; /* ptr pointe 1er caractere du texte */
|
kk = 0; ptr = m_Text.GetData(); /* ptr pointe 1er caractere du texte */
|
||||||
|
|
||||||
/* calcul de la position du debut des textes: ox et oy */
|
/* calcul de la position du debut des textes: ox et oy */
|
||||||
ox = cX = 0; oy = cY = 0;
|
ox = cX = 0; oy = cY = 0;
|
||||||
|
@ -415,13 +447,13 @@ int coord_count_max = 1000;
|
||||||
|
|
||||||
if( (m_Orient == 0) || (m_Orient == 1800) ) /* Texte Horizontal */
|
if( (m_Orient == 0) || (m_Orient == 1800) ) /* Texte Horizontal */
|
||||||
{
|
{
|
||||||
switch(m_HJustify)
|
switch( m_HJustify )
|
||||||
{
|
{
|
||||||
case GR_TEXT_HJUSTIFY_CENTER:
|
case GR_TEXT_HJUSTIFY_CENTER:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GR_TEXT_HJUSTIFY_RIGHT:
|
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||||
ux0 = - dx;
|
ux0 = -dx;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GR_TEXT_HJUSTIFY_LEFT:
|
case GR_TEXT_HJUSTIFY_LEFT:
|
||||||
|
@ -429,7 +461,7 @@ int coord_count_max = 1000;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(m_VJustify)
|
switch( m_VJustify )
|
||||||
{
|
{
|
||||||
case GR_TEXT_VJUSTIFY_CENTER:
|
case GR_TEXT_VJUSTIFY_CENTER:
|
||||||
break;
|
break;
|
||||||
|
@ -443,16 +475,15 @@ int coord_count_max = 1000;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else /* Texte Vertical */
|
else /* Texte Vertical */
|
||||||
{
|
{
|
||||||
switch(m_HJustify)
|
switch( m_HJustify )
|
||||||
{
|
{
|
||||||
case GR_TEXT_HJUSTIFY_CENTER:
|
case GR_TEXT_HJUSTIFY_CENTER:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GR_TEXT_HJUSTIFY_RIGHT:
|
case GR_TEXT_HJUSTIFY_RIGHT:
|
||||||
ux0 = - dy;
|
ux0 = -dy;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GR_TEXT_HJUSTIFY_LEFT:
|
case GR_TEXT_HJUSTIFY_LEFT:
|
||||||
|
@ -460,7 +491,7 @@ int coord_count_max = 1000;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(m_VJustify)
|
switch( m_VJustify )
|
||||||
{
|
{
|
||||||
case GR_TEXT_VJUSTIFY_CENTER:
|
case GR_TEXT_VJUSTIFY_CENTER:
|
||||||
break;
|
break;
|
||||||
|
@ -475,47 +506,49 @@ int coord_count_max = 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cX += ux0; cY += uy0;
|
cX += ux0; cY += uy0;
|
||||||
ox = cX - dx; ; oy = cY + dy;
|
ox = cX - dx;; oy = cY + dy;
|
||||||
|
|
||||||
/* lorsque les chars sont trop petits pour etre dessines,
|
/* lorsque les chars sont trop petits pour etre dessines,
|
||||||
le texte est symbolise par une barre */
|
* le texte est symbolise par une barre */
|
||||||
m_ZoomLevelDrawable = m_Size.x / 3;
|
m_ZoomLevelDrawable = m_Size.x / 3;
|
||||||
dx = (espacement * nbchar) / 2;
|
dx = (espacement * nbchar) / 2;
|
||||||
dy = size_v / 2; /* Decalage du debut du texte / centre */
|
dy = size_v / 2; /* Decalage du debut du texte / centre */
|
||||||
ux0 = cX - dx; uy0 = cY;
|
ux0 = cX - dx; uy0 = cY;
|
||||||
dx += cX; dy = cY;
|
dx += cX; dy = cY;
|
||||||
RotatePoint(&ux0, &uy0, cX, cY, m_Orient);
|
RotatePoint( &ux0, &uy0, cX, cY, m_Orient );
|
||||||
RotatePoint(&dx, &dy, cX, cY, m_Orient);
|
RotatePoint( &dx, &dy, cX, cY, m_Orient );
|
||||||
|
|
||||||
coord = (int*) MyMalloc( (coord_count_max+2) * sizeof(int));
|
coord = (int*) MyMalloc( (coord_count_max + 2) * sizeof(int) );
|
||||||
coord[0] = 2;
|
coord[0] = 2;
|
||||||
coord[1] = ux0; coord[2] = uy0;
|
coord[1] = ux0; coord[2] = uy0;
|
||||||
coord[3] = dx; coord[4] = dy;
|
coord[3] = dx; coord[4] = dy;
|
||||||
|
|
||||||
jj = 5; ii = jj+1; nbpoints = 0;
|
jj = 5; ii = jj + 1; nbpoints = 0;
|
||||||
while(kk++ < nbchar)
|
while( kk++ < nbchar )
|
||||||
{
|
{
|
||||||
x0 = 0 ; y0 = 0 ;
|
x0 = 0; y0 = 0;
|
||||||
AsciiCode = (*ptr) & 255;
|
AsciiCode = (*ptr) & 255;
|
||||||
ptcar = graphic_fonte_shape[AsciiCode] ; /* ptcar pointe la description
|
ptcar = graphic_fonte_shape[AsciiCode]; /* ptcar pointe la description
|
||||||
du caractere a dessiner */
|
* du caractere a dessiner */
|
||||||
|
|
||||||
for(endcar = FALSE; ! endcar; ptcar++)
|
for( endcar = FALSE; !endcar; ptcar++ )
|
||||||
{
|
{
|
||||||
f_cod = *ptcar ; /* get code n de la forme selectionnee */
|
f_cod = *ptcar;
|
||||||
switch(f_cod)
|
|
||||||
|
/* get code n de la forme selectionnee */
|
||||||
|
switch( f_cod )
|
||||||
{
|
{
|
||||||
case 'X' :
|
case 'X':
|
||||||
endcar = TRUE;/* fin du caractere */
|
endcar = TRUE; /* fin du caractere */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'U' :
|
case 'U':
|
||||||
if(nbpoints && (plume == 'D' ) )
|
if( nbpoints && (plume == 'D' ) )
|
||||||
{
|
{
|
||||||
if ( jj >= coord_count_max )
|
if( jj >= coord_count_max )
|
||||||
{
|
{
|
||||||
coord_count_max *= 2;
|
coord_count_max *= 2;
|
||||||
coord = (int*)realloc( coord, coord_count_max * sizeof(int) );
|
coord = (int*) realloc( coord, coord_count_max * sizeof(int) );
|
||||||
}
|
}
|
||||||
coord[jj] = nbpoints;
|
coord[jj] = nbpoints;
|
||||||
jj = ii; ii++;
|
jj = ii; ii++;
|
||||||
|
@ -523,105 +556,113 @@ int coord_count_max = 1000;
|
||||||
plume = f_cod; nbpoints = 0;
|
plume = f_cod; nbpoints = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'D' :
|
case 'D':
|
||||||
plume = f_cod;
|
plume = f_cod;
|
||||||
nbpoints = 1; /* 1 point va suivre (origine du tracé) */
|
nbpoints = 1; /* 1 point va suivre (origine du trac<61> */
|
||||||
break ;
|
break;
|
||||||
|
|
||||||
default :
|
default:
|
||||||
{
|
{
|
||||||
k1 = f_cod; /* trace sur axe V */
|
k1 = f_cod; /* trace sur axe V */
|
||||||
k1 = - ((k1 * size_v) / 9) ;
|
k1 = -( (k1 * size_v) / 9 );
|
||||||
ptcar++ ;
|
ptcar++;
|
||||||
f_cod = *ptcar ;
|
f_cod = *ptcar;
|
||||||
k2 = f_cod; /* trace sur axe H */
|
k2 = f_cod; /* trace sur axe H */
|
||||||
k2 = (k2 * size_h) / 9 ;
|
k2 = (k2 * size_h) / 9;
|
||||||
dx = k2 + ox; dy = k1 + oy;
|
dx = k2 + ox; dy = k1 + oy;
|
||||||
RotatePoint(&dx, &dy, cX, cY, m_Orient);
|
RotatePoint( &dx, &dy, cX, cY, m_Orient );
|
||||||
if ( ii >= coord_count_max )
|
if( ii >= coord_count_max )
|
||||||
{
|
{
|
||||||
coord_count_max *= 2;
|
coord_count_max *= 2;
|
||||||
coord = (int*)realloc( coord, coord_count_max * sizeof(int) );
|
coord = (int*) realloc( coord, coord_count_max * sizeof(int) );
|
||||||
}
|
}
|
||||||
coord[ii] = dx; ii++; coord[ii] = dy; ii++;
|
coord[ii] = dx; ii++; coord[ii] = dy; ii++;
|
||||||
nbpoints++;
|
nbpoints++;
|
||||||
break ;
|
break;
|
||||||
}
|
}
|
||||||
} /* end switch */
|
}
|
||||||
} /* end boucle for = end trace de 1 caractere */
|
|
||||||
|
/* end switch */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end boucle for = end trace de 1 caractere */
|
||||||
|
|
||||||
ptr++; ox += espacement;
|
ptr++; ox += espacement;
|
||||||
} /* end trace du texte */
|
}
|
||||||
|
|
||||||
|
/* end trace du texte */
|
||||||
|
|
||||||
m_TextDrawings = (int*) realloc( coord, ii * sizeof(int) );
|
m_TextDrawings = (int*) realloc( coord, ii * sizeof(int) );
|
||||||
m_TextDrawingsSize = ii; //taille (en int) du tableau
|
m_TextDrawingsSize = ii; //taille (en int) du tableau
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************/
|
||||||
|
void EDA_Rect::Normalize( void )
|
||||||
|
/******************************/
|
||||||
|
|
||||||
/******************************/
|
|
||||||
void EDA_Rect::Normalize(void)
|
|
||||||
/******************************/
|
|
||||||
// Ensure the height ant width are >= 0
|
// Ensure the height ant width are >= 0
|
||||||
{
|
{
|
||||||
if ( m_Size.y < 0 )
|
if( m_Size.y < 0 )
|
||||||
{
|
{
|
||||||
m_Size.y = - m_Size.y;
|
m_Size.y = -m_Size.y;
|
||||||
m_Pos.y -= m_Size.y;
|
m_Pos.y -= m_Size.y;
|
||||||
}
|
}
|
||||||
if ( m_Size.x < 0 )
|
if( m_Size.x < 0 )
|
||||||
{
|
{
|
||||||
m_Size.x = - m_Size.x;
|
m_Size.x = -m_Size.x;
|
||||||
m_Pos.x -= m_Size.x;
|
m_Pos.x -= m_Size.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************************/
|
/*******************************************/
|
||||||
bool EDA_Rect::Inside(const wxPoint & point)
|
bool EDA_Rect::Inside( const wxPoint& point )
|
||||||
/*******************************************/
|
/*******************************************/
|
||||||
/* Return TRUE if point is in Rect
|
|
||||||
Accept rect size < 0
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
int rel_posx = point.x - m_Pos.x;
|
|
||||||
int rel_posy = point.y - m_Pos.y;
|
|
||||||
wxSize size = m_Size;
|
|
||||||
|
|
||||||
if ( size.x < 0 )
|
/* Return TRUE if point is in Rect
|
||||||
|
* Accept rect size < 0
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
int rel_posx = point.x - m_Pos.x;
|
||||||
|
int rel_posy = point.y - m_Pos.y;
|
||||||
|
wxSize size = m_Size;
|
||||||
|
|
||||||
|
if( size.x < 0 )
|
||||||
{
|
{
|
||||||
size.x = -size.x; rel_posx += size.x;
|
size.x = -size.x; rel_posx += size.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( size.y < 0 )
|
if( size.y < 0 )
|
||||||
{
|
{
|
||||||
size.y = -size.y; rel_posy += size.y;
|
size.y = -size.y; rel_posy += size.y;
|
||||||
}
|
}
|
||||||
return ( (rel_posx >= 0) && (rel_posy >= 0)
|
return (rel_posx >= 0) && (rel_posy >= 0)
|
||||||
&& ( rel_posy <= size.y)
|
&& ( rel_posy <= size.y)
|
||||||
&& ( rel_posx <= size.x)
|
&& ( rel_posx <= size.x)
|
||||||
);
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
EDA_Rect& EDA_Rect::Inflate(wxCoord dx, wxCoord dy)
|
EDA_Rect& EDA_Rect::Inflate( wxCoord dx, wxCoord dy )
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
{
|
{
|
||||||
if (-2*dx > m_Size.x)
|
if( -2 * dx > m_Size.x )
|
||||||
{
|
{
|
||||||
// Don't allow deflate to eat more width than we have,
|
// Don't allow deflate to eat more width than we have,
|
||||||
// a well-defined rectangle cannot have negative width.
|
// a well-defined rectangle cannot have negative width.
|
||||||
m_Pos.x += m_Size.x/2;
|
m_Pos.x += m_Size.x / 2;
|
||||||
m_Size.x = 0;
|
m_Size.x = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The inflate is valid.
|
// The inflate is valid.
|
||||||
m_Pos.x-=dx;
|
m_Pos.x -= dx;
|
||||||
m_Size.x += 2*dx;
|
m_Size.x += 2 * dx;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-2*dy > m_Size.y)
|
if( -2 * dy > m_Size.y )
|
||||||
{
|
{
|
||||||
// Don't allow deflate to eat more height than we have,
|
// Don't allow deflate to eat more height than we have,
|
||||||
// a well-defined rectangle cannot have negative height.
|
// a well-defined rectangle cannot have negative height.
|
||||||
|
@ -632,48 +673,49 @@ EDA_Rect& EDA_Rect::Inflate(wxCoord dx, wxCoord dy)
|
||||||
{
|
{
|
||||||
// The inflate is valid.
|
// The inflate is valid.
|
||||||
m_Pos.y -= dy;
|
m_Pos.y -= dy;
|
||||||
m_Size.y += 2*dy;
|
m_Size.y += 2 * dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************/
|
||||||
/**************************/
|
/* class DrawPickedStruct */
|
||||||
/* class DrawPickedStruct */
|
/**************************/
|
||||||
/**************************/
|
|
||||||
|
|
||||||
/* This class has only one useful member: .m_PickedStruct, used as a link.
|
/* This class has only one useful member: .m_PickedStruct, used as a link.
|
||||||
It does not describe really an item.
|
* It does not describe really an item.
|
||||||
It is used to create a linked list of selected items (in block selection).
|
* It is used to create a linked list of selected items (in block selection).
|
||||||
Each DrawPickedStruct item has is member: .m_PickedStruct pointing the
|
* Each DrawPickedStruct item has is member: .m_PickedStruct pointing the
|
||||||
real selected item
|
* real selected item
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
DrawPickedStruct::DrawPickedStruct(EDA_BaseStruct *pickedstruct ) :
|
DrawPickedStruct::DrawPickedStruct( EDA_BaseStruct* pickedstruct ) :
|
||||||
EDA_BaseStruct(DRAW_PICK_ITEM_STRUCT_TYPE)
|
EDA_BaseStruct( DRAW_PICK_ITEM_STRUCT_TYPE )
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
{
|
{
|
||||||
m_PickedStruct = pickedstruct;
|
m_PickedStruct = pickedstruct;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawPickedStruct::~DrawPickedStruct(void)
|
|
||||||
|
DrawPickedStruct::~DrawPickedStruct( void )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
void DrawPickedStruct::DeleteWrapperList(void)
|
void DrawPickedStruct::DeleteWrapperList( void )
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
/* Delete this item all the items of the linked list
|
|
||||||
Free the wrapper, but DOES NOT delete the picked items linked by .m_PickedStruct
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
DrawPickedStruct * wrapp_struct, * next_struct;
|
|
||||||
|
|
||||||
for ( wrapp_struct = Next(); wrapp_struct != NULL; wrapp_struct = next_struct)
|
/* Delete this item all the items of the linked list
|
||||||
|
* Free the wrapper, but DOES NOT delete the picked items linked by .m_PickedStruct
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
DrawPickedStruct* wrapp_struct, * next_struct;
|
||||||
|
|
||||||
|
for( wrapp_struct = Next(); wrapp_struct != NULL; wrapp_struct = next_struct )
|
||||||
{
|
{
|
||||||
next_struct = wrapp_struct->Next();
|
next_struct = wrapp_struct->Next();
|
||||||
delete wrapp_struct;
|
delete wrapp_struct;
|
||||||
|
|
203
common/trigo.cpp
203
common/trigo.cpp
|
@ -1,8 +1,8 @@
|
||||||
/************************/
|
/************************/
|
||||||
/* Routines de rotation */
|
/* Routines de rotation */
|
||||||
/************************/
|
/************************/
|
||||||
|
|
||||||
/* Fichier TRIGO.CPP */
|
/* Fichier TRIGO.CPP */
|
||||||
|
|
||||||
#include "fctsys.h"
|
#include "fctsys.h"
|
||||||
#define global extern
|
#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
|
/* Retourne l'arc tangente en 0.1 degres du vecteur de coord dx, dy
|
||||||
entre -1800 et 1800
|
* entre -1800 et 1800
|
||||||
Analogue a atan2 ( mais plus rapide pour les calculs si
|
* Analogue a atan2 ( mais plus rapide pour les calculs si
|
||||||
l'angle est souvent 0, -1800, ou +- 900
|
* l'angle est souvent 0, -1800, ou +- 900
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
double fangle;
|
double fangle;
|
||||||
|
|
||||||
if(dy == 0)
|
if( dy == 0 )
|
||||||
{
|
{
|
||||||
if(dx >= 0 ) return(0);
|
if( dx >= 0 )
|
||||||
else return(-1800);
|
return 0;
|
||||||
|
else
|
||||||
|
return -1800;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dx == 0)
|
if( dx == 0 )
|
||||||
{
|
{
|
||||||
if(dy >= 0 ) return(900);
|
if( dy >= 0 )
|
||||||
else return(-900);
|
return 900;
|
||||||
|
else
|
||||||
|
return -900;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dx == dy)
|
if( dx == dy )
|
||||||
{
|
{
|
||||||
if(dx >= 0) return(450);
|
if( dx >= 0 )
|
||||||
else return(-1800+450);
|
return 450;
|
||||||
|
else
|
||||||
|
return -1800 + 450;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dx == -dy)
|
if( dx == -dy )
|
||||||
{
|
{
|
||||||
if(dx >= 0) return(-450);
|
if( dx >= 0 )
|
||||||
else return(1800-450);
|
return -450;
|
||||||
|
else
|
||||||
|
return 1800 - 450;
|
||||||
}
|
}
|
||||||
|
|
||||||
fangle = atan2( (double)dy, (double)dx ) / M_PI * 1800;
|
fangle = atan2( (double) dy, (double) dx ) / M_PI * 1800;
|
||||||
return( (int) round(fangle) );
|
return (int) round( fangle );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
void RotatePoint(int *pX, int *pY, int angle)
|
void RotatePoint( int* pX, int* pY, int angle )
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Fonction surchargee!
|
* Fonction surchargee!
|
||||||
calcule les nouvelles coord du point de coord pX, pY,
|
* 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)
|
* pour une rotation de centre 0, 0, et d'angle angle ( en 1/10 degre)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
float fpx, fpy;
|
float fpx, fpy;
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
||||||
while (angle < 0) angle += 3600;
|
while( angle < 0 )
|
||||||
while (angle >= 3600) angle -= 3600;
|
angle += 3600;
|
||||||
|
|
||||||
if (angle == 0) return;
|
while( angle >= 3600 )
|
||||||
|
angle -= 3600;
|
||||||
|
|
||||||
|
if( angle == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
/* Calcul des coord :
|
/* Calcul des coord :
|
||||||
coord: xrot = y*sin + x*cos
|
* coord: xrot = y*sin + x*cos
|
||||||
yrot = y*cos - x*sin
|
* yrot = y*cos - x*sin
|
||||||
*/
|
*/
|
||||||
if( angle == 900 ) /* sin = 1, cos = 0 */
|
if( angle == 900 ) /* sin = 1, cos = 0 */
|
||||||
{
|
{
|
||||||
tmp = *pX;
|
tmp = *pX;
|
||||||
*pX = *pY;
|
*pX = *pY;
|
||||||
*pY = - tmp;
|
*pY = -tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( angle == 1800 ) /* sin = 0, cos = -1 */
|
else if( angle == 1800 ) /* sin = 0, cos = -1 */
|
||||||
{
|
{
|
||||||
*pX = - *pX;
|
*pX = -*pX;
|
||||||
*pY = - *pY;
|
*pY = -*pY;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( angle == 2700 ) /* sin = -1, cos = 0 */
|
else if( angle == 2700 ) /* sin = -1, cos = 0 */
|
||||||
{
|
{
|
||||||
tmp = *pX;
|
tmp = *pX;
|
||||||
*pX = - *pY;
|
*pX = -*pY;
|
||||||
*pY = tmp;
|
*pY = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]);
|
fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]);
|
||||||
fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[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);
|
* 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;
|
*pX = ox + cx;
|
||||||
*pY = oy + cy;
|
*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);
|
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->x = ox + centre.x;
|
||||||
point->y = oy + centre.y;
|
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 );
|
||||||
|
|
||||||
ox = *pX - cx; oy = *pY - cy;
|
|
||||||
RotatePoint(&ox, &oy, angle);
|
|
||||||
*pX = ox + cx;
|
*pX = ox + cx;
|
||||||
*pY = oy + cy;
|
*pY = oy + cy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************/
|
/*************************************************/
|
||||||
void RotatePoint(double *pX, double *pY, int angle)
|
void RotatePoint( double* pX, double* pY, int angle )
|
||||||
/*************************************************/
|
/*************************************************/
|
||||||
|
|
||||||
/* Calcul des coord :
|
/* Calcul des coord :
|
||||||
coord: xrot = y*sin + x*cos
|
* coord: xrot = y*sin + x*cos
|
||||||
yrot = y*cos - x*sin
|
* yrot = y*cos - x*sin
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
double tmp;
|
double tmp;
|
||||||
while (angle < 0) angle += 3600;
|
|
||||||
while (angle >= 3600) angle -= 3600;
|
while( angle < 0 )
|
||||||
if (angle == 0) return;
|
angle += 3600;
|
||||||
|
|
||||||
|
while( angle >= 3600 )
|
||||||
|
angle -= 3600;
|
||||||
|
|
||||||
|
if( angle == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
if( angle == 900 ) /* sin = 1, cos = 0 */
|
if( angle == 900 ) /* sin = 1, cos = 0 */
|
||||||
{
|
{
|
||||||
tmp = *pX;
|
tmp = *pX;
|
||||||
*pX = *pY;
|
*pX = *pY;
|
||||||
*pY = - tmp;
|
*pY = -tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( angle == 1800 ) /* sin = 0, cos = -1 */
|
else if( angle == 1800 ) /* sin = 0, cos = -1 */
|
||||||
{
|
{
|
||||||
*pX = - *pX;
|
*pX = -*pX;
|
||||||
*pY = - *pY;
|
*pY = -*pY;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( angle == 2700 ) /* sin = -1, cos = 0 */
|
else if( angle == 2700 ) /* sin = -1, cos = 0 */
|
||||||
{
|
{
|
||||||
tmp = *pX;
|
tmp = *pX;
|
||||||
*pX = - *pY;
|
*pX = -*pY;
|
||||||
*pY = tmp;
|
*pY = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]);
|
double fpx = (*pY * fsinus[angle]) + (*pX * fcosinus[angle]);
|
||||||
double fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[angle]);
|
double fpy = (*pY * fcosinus[angle]) - (*pX * fsinus[angle]);
|
||||||
*pX = fpx; *pY = fpy;
|
|
||||||
|
*pX = fpx;
|
||||||
|
*pY = fpy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,8 +179,14 @@ public:
|
||||||
const wxPoint& offset, int color,
|
const wxPoint& offset, int color,
|
||||||
int draw_mode, int display_mode = FILAIRE, int anchor_color = -1 );
|
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
|
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 "fctsys.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
@ -9,14 +9,13 @@
|
||||||
#include "bitmaps.h"
|
#include "bitmaps.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*****************/
|
||||||
/*****************/
|
/* Class BOARD: */
|
||||||
/* Class BOARD: */
|
/*****************/
|
||||||
/*****************/
|
|
||||||
|
|
||||||
/* Constructor */
|
/* Constructor */
|
||||||
BOARD::BOARD(EDA_BaseStruct * parent, WinEDA_BasePcbFrame * frame):
|
BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) :
|
||||||
EDA_BaseStruct(parent, TYPEPCB)
|
EDA_BaseStruct( parent, TYPEPCB )
|
||||||
{
|
{
|
||||||
m_PcbFrame = frame;
|
m_PcbFrame = frame;
|
||||||
m_Status_Pcb = 0; // Mot d'etat: Bit 1 = Chevelu calcule
|
m_Status_Pcb = 0; // Mot d'etat: Bit 1 = Chevelu calcule
|
||||||
|
@ -28,7 +27,7 @@ BOARD::BOARD(EDA_BaseStruct * parent, WinEDA_BasePcbFrame * frame):
|
||||||
// minimal de pistes a tracer
|
// minimal de pistes a tracer
|
||||||
m_NbSegmTrack = 0; // nombre d'elements de type segments de piste
|
m_NbSegmTrack = 0; // nombre d'elements de type segments de piste
|
||||||
m_NbSegmZone = 0; // nombre d'elements de type segments de zone
|
m_NbSegmZone = 0; // nombre d'elements de type segments de zone
|
||||||
m_NbNoconnect=0; // nombre de chevelus actifs
|
m_NbNoconnect = 0; // nombre de chevelus actifs
|
||||||
m_NbLoclinks = 0; // nb ratsnest local
|
m_NbLoclinks = 0; // nb ratsnest local
|
||||||
|
|
||||||
m_Drawings = NULL; // pointeur sur liste drawings
|
m_Drawings = NULL; // pointeur sur liste drawings
|
||||||
|
@ -43,10 +42,11 @@ BOARD::BOARD(EDA_BaseStruct * parent, WinEDA_BasePcbFrame * frame):
|
||||||
// de determination des contours de zone
|
// de determination des contours de zone
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************/
|
|
||||||
/* Destructeur */
|
/***************/
|
||||||
/***************/
|
/* Destructeur */
|
||||||
BOARD::~BOARD(void)
|
/***************/
|
||||||
|
BOARD::~BOARD( void )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,11 +56,10 @@ void BOARD::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" */
|
||||||
{
|
{
|
||||||
// Pback-> = Pnext;
|
// Pback-> = Pnext;
|
||||||
|
@ -68,159 +67,172 @@ void BOARD::UnLink( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modification du chainage avant */
|
/* Modification du chainage avant */
|
||||||
if( Pnext) Pnext->Pback = Pback;
|
if( Pnext )
|
||||||
|
Pnext->Pback = Pback;
|
||||||
|
|
||||||
Pnext = Pback = NULL;
|
Pnext = Pback = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Routines de calcul des nombres de segments pistes et zones */
|
/* Routines de calcul des nombres de segments pistes et zones */
|
||||||
int BOARD::GetNumSegmTrack(void)
|
int BOARD::GetNumSegmTrack( void )
|
||||||
{
|
{
|
||||||
TRACK * CurTrack = m_Track;
|
TRACK* CurTrack = m_Track;
|
||||||
int ii = 0;
|
int ii = 0;
|
||||||
|
|
||||||
|
for( ; CurTrack != NULL; CurTrack = (TRACK*) CurTrack->Pnext )
|
||||||
|
ii++;
|
||||||
|
|
||||||
for ( ;CurTrack != NULL; CurTrack = (TRACK*)CurTrack->Pnext ) ii++;
|
|
||||||
m_NbSegmTrack = ii;
|
m_NbSegmTrack = ii;
|
||||||
return(ii);
|
return ii;
|
||||||
}
|
}
|
||||||
int BOARD::GetNumSegmZone(void)
|
|
||||||
{
|
|
||||||
TRACK * CurTrack = m_Zone;
|
|
||||||
int ii = 0;
|
|
||||||
|
|
||||||
for ( ;CurTrack != NULL; CurTrack = (TRACK*)CurTrack->Pnext ) ii++;
|
|
||||||
|
int BOARD::GetNumSegmZone( void )
|
||||||
|
{
|
||||||
|
TRACK* CurTrack = m_Zone;
|
||||||
|
int ii = 0;
|
||||||
|
|
||||||
|
for( ; CurTrack != NULL; CurTrack = (TRACK*) CurTrack->Pnext )
|
||||||
|
ii++;
|
||||||
|
|
||||||
m_NbSegmZone = ii;
|
m_NbSegmZone = ii;
|
||||||
return(ii);
|
return ii;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// retourne le nombre de connexions manquantes
|
// retourne le nombre de connexions manquantes
|
||||||
int BOARD::GetNumNoconnect(void)
|
int BOARD::GetNumNoconnect( void )
|
||||||
{
|
{
|
||||||
return(m_NbNoconnect);
|
return m_NbNoconnect;
|
||||||
}
|
}
|
||||||
|
|
||||||
// retourne le nombre de chevelus
|
|
||||||
int BOARD::GetNumRatsnests(void)
|
// retourne le nombre de chevelus
|
||||||
|
int BOARD::GetNumRatsnests( void )
|
||||||
{
|
{
|
||||||
return(m_NbLinks);
|
return m_NbLinks;
|
||||||
}
|
}
|
||||||
|
|
||||||
// retourne le nombre de pads a netcode > 0
|
|
||||||
int BOARD::GetNumNodes(void)
|
// retourne le nombre de pads a netcode > 0
|
||||||
|
int BOARD::GetNumNodes( void )
|
||||||
{
|
{
|
||||||
return(m_NbNodes);
|
return m_NbNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************/
|
/***********************************/
|
||||||
bool BOARD::ComputeBoundaryBox(void)
|
bool BOARD::ComputeBoundaryBox( void )
|
||||||
/***********************************/
|
/***********************************/
|
||||||
|
|
||||||
/* Determine le rectangle d'encadrement du pcb
|
/* Determine le rectangle d'encadrement du pcb
|
||||||
Ce rectangle englobe les contours pcb, pads , vias et piste
|
* Ce rectangle englobe les contours pcb, pads , vias et piste
|
||||||
Sortie:
|
* Sortie:
|
||||||
m_PcbBox
|
* m_PcbBox
|
||||||
|
*
|
||||||
retourne:
|
* retourne:
|
||||||
0 si aucun element utile
|
* 0 si aucun element utile
|
||||||
1 sinon
|
* 1 sinon
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int rayon, cx, cy, d, xmin, ymin, xmax, ymax;
|
int rayon, cx, cy, d, xmin, ymin, xmax, ymax;
|
||||||
bool Has_Items = FALSE;
|
bool Has_Items = FALSE;
|
||||||
EDA_BaseStruct * PtStruct;
|
EDA_BaseStruct* PtStruct;
|
||||||
DRAWSEGMENT* ptr;
|
DRAWSEGMENT* ptr;
|
||||||
TRACK * Track;
|
TRACK* Track;
|
||||||
|
|
||||||
xmin = ymin = 0x7FFFFFFFl ;
|
xmin = ymin = 0x7FFFFFFFl;
|
||||||
xmax = ymax = -0x7FFFFFFFl ;
|
xmax = ymax = -0x7FFFFFFFl;
|
||||||
|
|
||||||
/* Analyse des Contours PCB */
|
/* Analyse des Contours PCB */
|
||||||
PtStruct = m_Drawings;
|
PtStruct = m_Drawings;
|
||||||
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
||||||
{
|
{
|
||||||
if( PtStruct->m_StructType != TYPEDRAWSEGMENT ) continue;
|
if( PtStruct->m_StructType != TYPEDRAWSEGMENT )
|
||||||
|
continue;
|
||||||
|
|
||||||
ptr = (DRAWSEGMENT*) PtStruct;
|
ptr = (DRAWSEGMENT*) PtStruct;
|
||||||
d = (ptr->m_Width /2) + 1;
|
d = (ptr->m_Width / 2) + 1;
|
||||||
if(ptr->m_Shape == S_CIRCLE)
|
|
||||||
|
if( ptr->m_Shape == S_CIRCLE )
|
||||||
{
|
{
|
||||||
cx = ptr->m_Start.x; cy = ptr->m_Start.y;
|
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 = (int) hypot( (double) (ptr->m_End.x - cx), (double) (ptr->m_End.y - cy) );
|
||||||
rayon += d;
|
rayon += d;
|
||||||
xmin = min(xmin,cx-rayon);
|
xmin = min( xmin, cx - rayon );
|
||||||
ymin = min(ymin,cy-rayon);
|
ymin = min( ymin, cy - rayon );
|
||||||
xmax = max(xmax,cx+rayon);
|
xmax = max( xmax, cx + rayon );
|
||||||
ymax = max(ymax,cy+rayon);
|
ymax = max( ymax, cy + rayon );
|
||||||
Has_Items = TRUE;
|
Has_Items = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cx = min(ptr->m_Start.x, ptr->m_End.x );
|
cx = min( ptr->m_Start.x, ptr->m_End.x );
|
||||||
cy = min(ptr->m_Start.y, ptr->m_End.y);
|
cy = min( ptr->m_Start.y, ptr->m_End.y );
|
||||||
xmin = min(xmin,cx - d);
|
xmin = min( xmin, cx - d );
|
||||||
ymin = min(ymin,cy - d);
|
ymin = min( ymin, cy - d );
|
||||||
cx = max(ptr->m_Start.x, ptr->m_End.x );
|
cx = max( ptr->m_Start.x, ptr->m_End.x );
|
||||||
cy = max(ptr->m_Start.y, ptr->m_End.y);
|
cy = max( ptr->m_Start.y, ptr->m_End.y );
|
||||||
xmax = max(xmax,cx + d);
|
xmax = max( xmax, cx + d );
|
||||||
ymax = max(ymax,cy + d);
|
ymax = max( ymax, cy + d );
|
||||||
Has_Items = TRUE;
|
Has_Items = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Analyse des Modules */
|
/* Analyse des Modules */
|
||||||
MODULE * module = m_Modules;
|
MODULE* module = m_Modules;
|
||||||
for( ; module != NULL; module = (MODULE *) module->Pnext )
|
for( ; module != NULL; module = (MODULE*) module->Pnext )
|
||||||
{
|
{
|
||||||
Has_Items = TRUE;
|
Has_Items = TRUE;
|
||||||
xmin = min(xmin,(module->m_Pos.x + module->m_BoundaryBox.GetX()));
|
xmin = min( xmin, ( module->m_Pos.x + module->m_BoundaryBox.GetX() ) );
|
||||||
ymin = min(ymin,(module->m_Pos.y + module->m_BoundaryBox.GetY()));
|
ymin = min( ymin, ( module->m_Pos.y + module->m_BoundaryBox.GetY() ) );
|
||||||
xmax = max(xmax,module->m_Pos.x + module->m_BoundaryBox.GetRight());
|
xmax = max( xmax, module->m_Pos.x + module->m_BoundaryBox.GetRight() );
|
||||||
ymax = max(ymax,module->m_Pos.y + module->m_BoundaryBox.GetBottom());
|
ymax = max( ymax, module->m_Pos.y + module->m_BoundaryBox.GetBottom() );
|
||||||
|
|
||||||
D_PAD * pt_pad = module->m_Pads;
|
D_PAD* 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 )
|
||||||
{
|
{
|
||||||
d = pt_pad->m_Rayon;
|
d = pt_pad->m_Rayon;
|
||||||
xmin = min(xmin,pt_pad->m_Pos.x - d);
|
xmin = min( xmin, pt_pad->m_Pos.x - d );
|
||||||
ymin = min(ymin,pt_pad->m_Pos.y - d);
|
ymin = min( ymin, pt_pad->m_Pos.y - d );
|
||||||
xmax = max(xmax,pt_pad->m_Pos.x + d);
|
xmax = max( xmax, pt_pad->m_Pos.x + d );
|
||||||
ymax = max(ymax,pt_pad->m_Pos.y + d);
|
ymax = max( ymax, pt_pad->m_Pos.y + d );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Analyse des segments de piste et zone*/
|
/* Analyse des segments de piste et zone*/
|
||||||
for( Track = m_Track; Track != NULL; Track = (TRACK*) Track->Pnext)
|
for( Track = m_Track; Track != NULL; Track = (TRACK*) Track->Pnext )
|
||||||
{
|
{
|
||||||
d = (Track->m_Width /2) + 1;
|
d = (Track->m_Width / 2) + 1;
|
||||||
cx = min(Track->m_Start.x, Track->m_End.x );
|
cx = min( Track->m_Start.x, Track->m_End.x );
|
||||||
cy = min(Track->m_Start.y, Track->m_End.y);
|
cy = min( Track->m_Start.y, Track->m_End.y );
|
||||||
xmin = min(xmin,cx - d);
|
xmin = min( xmin, cx - d );
|
||||||
ymin = min(ymin,cy - d);
|
ymin = min( ymin, cy - d );
|
||||||
cx = max(Track->m_Start.x, Track->m_End.x );
|
cx = max( Track->m_Start.x, Track->m_End.x );
|
||||||
cy = max(Track->m_Start.y, Track->m_End.y);
|
cy = max( Track->m_Start.y, Track->m_End.y );
|
||||||
xmax = max(xmax,cx + d);
|
xmax = max( xmax, cx + d );
|
||||||
ymax = max(ymax,cy + d);
|
ymax = max( ymax, cy + d );
|
||||||
Has_Items = TRUE;
|
Has_Items = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( Track = m_Zone; Track != NULL; Track = (TRACK*) Track->Pnext)
|
for( Track = m_Zone; Track != NULL; Track = (TRACK*) Track->Pnext )
|
||||||
{
|
{
|
||||||
d = (Track->m_Width /2) + 1;
|
d = (Track->m_Width / 2) + 1;
|
||||||
cx = min(Track->m_Start.x, Track->m_End.x );
|
cx = min( Track->m_Start.x, Track->m_End.x );
|
||||||
cy = min(Track->m_Start.y, Track->m_End.y);
|
cy = min( Track->m_Start.y, Track->m_End.y );
|
||||||
xmin = min(xmin,cx - d);
|
xmin = min( xmin, cx - d );
|
||||||
ymin = min(ymin,cy - d);
|
ymin = min( ymin, cy - d );
|
||||||
cx = max(Track->m_Start.x, Track->m_End.x );
|
cx = max( Track->m_Start.x, Track->m_End.x );
|
||||||
cy = max(Track->m_Start.y, Track->m_End.y);
|
cy = max( Track->m_Start.y, Track->m_End.y );
|
||||||
xmax = max(xmax,cx + d);
|
xmax = max( xmax, cx + d );
|
||||||
ymax = max(ymax,cy + d);
|
ymax = max( ymax, cy + d );
|
||||||
Has_Items = TRUE;
|
Has_Items = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! Has_Items && m_PcbFrame )
|
if( !Has_Items && m_PcbFrame )
|
||||||
{
|
{
|
||||||
if ( m_PcbFrame->m_Draw_Sheet_Ref )
|
if( m_PcbFrame->m_Draw_Sheet_Ref )
|
||||||
{
|
{
|
||||||
xmin = ymin = 0;
|
xmin = ymin = 0;
|
||||||
xmax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().x;
|
xmax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().x;
|
||||||
|
@ -228,18 +240,17 @@ TRACK * Track;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xmin = - m_PcbFrame->m_CurrentScreen->ReturnPageSize().x/2;
|
xmin = -m_PcbFrame->m_CurrentScreen->ReturnPageSize().x / 2;
|
||||||
ymin = - m_PcbFrame->m_CurrentScreen->ReturnPageSize().y/2;
|
ymin = -m_PcbFrame->m_CurrentScreen->ReturnPageSize().y / 2;
|
||||||
xmax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().x/2;
|
xmax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().x / 2;
|
||||||
ymax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().y/2;
|
ymax = m_PcbFrame->m_CurrentScreen->ReturnPageSize().y / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_BoundaryBox.SetX(xmin);
|
m_BoundaryBox.SetX( xmin );
|
||||||
m_BoundaryBox.SetY(ymin);
|
m_BoundaryBox.SetY( ymin );
|
||||||
m_BoundaryBox.SetWidth(xmax - xmin);
|
m_BoundaryBox.SetWidth( xmax - xmin );
|
||||||
m_BoundaryBox.SetHeight(ymax - ymin);
|
m_BoundaryBox.SetHeight( ymax - ymin );
|
||||||
|
|
||||||
return(Has_Items);
|
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 "fctsys.h"
|
||||||
#include "gr_basic.h"
|
#include "gr_basic.h"
|
||||||
|
@ -22,15 +22,15 @@
|
||||||
|
|
||||||
#include "protos.h"
|
#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 */
|
/* Constructeur de TEXTE_MODULE */
|
||||||
TEXTE_MODULE::TEXTE_MODULE(MODULE * parent, int text_type ):
|
TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) :
|
||||||
EDA_BaseStruct( parent, TYPETEXTEMODULE)
|
EDA_BaseStruct( parent, TYPETEXTEMODULE )
|
||||||
{
|
{
|
||||||
MODULE * Module = (MODULE*) m_Parent;
|
MODULE* Module = (MODULE*) m_Parent;
|
||||||
|
|
||||||
m_NoShow = 0; /* visible */
|
m_NoShow = 0; /* visible */
|
||||||
m_Type = text_type; /* Reference */
|
m_Type = text_type; /* Reference */
|
||||||
|
@ -46,22 +46,26 @@ MODULE * Module = (MODULE*) m_Parent;
|
||||||
{
|
{
|
||||||
m_Pos = Module->m_Pos;
|
m_Pos = Module->m_Pos;
|
||||||
m_Layer = Module->m_Layer;
|
m_Layer = Module->m_Layer;
|
||||||
if( Module->m_Layer == CUIVRE_N) m_Layer = SILKSCREEN_N_CU;
|
if( Module->m_Layer == CUIVRE_N )
|
||||||
if(Module->m_Layer == CMP_N) m_Layer = SILKSCREEN_N_CMP;
|
m_Layer = SILKSCREEN_N_CU;
|
||||||
if((Module->m_Layer == SILKSCREEN_N_CU) ||
|
if( Module->m_Layer == CMP_N )
|
||||||
(Module->m_Layer == ADHESIVE_N_CU) || (Module->m_Layer == CUIVRE_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_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_Pos = source->m_Pos;
|
||||||
m_Layer = source->m_Layer;
|
m_Layer = source->m_Layer;
|
||||||
|
@ -78,128 +82,141 @@ void TEXTE_MODULE::Copy(TEXTE_MODULE * source) // copy structure
|
||||||
m_Text = source->m_Text;
|
m_Text = source->m_Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* supprime du chainage la structure Struct
|
/* supprime du chainage la structure Struct
|
||||||
les structures arrieres et avant sont chainees directement
|
* les structures arrieres et avant sont chainees directement
|
||||||
*/
|
*/
|
||||||
void TEXTE_MODULE::UnLink( void )
|
void TEXTE_MODULE::UnLink( void )
|
||||||
{
|
{
|
||||||
/* Modification du chainage arriere */
|
/* Modification du chainage arriere */
|
||||||
if( Pback )
|
if( Pback )
|
||||||
{
|
{
|
||||||
if( Pback->m_StructType != TYPEMODULE)
|
if( Pback->m_StructType != TYPEMODULE )
|
||||||
{
|
{
|
||||||
Pback->Pnext = Pnext;
|
Pback->Pnext = Pnext;
|
||||||
}
|
}
|
||||||
|
|
||||||
else /* Le chainage arriere pointe sur la structure "Pere" */
|
else /* Le chainage arriere pointe sur la structure "Pere" */
|
||||||
{
|
{
|
||||||
((MODULE*)Pback)->m_Drawings = Pnext;
|
( (MODULE*) Pback )->m_Drawings = Pnext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modification du chainage avant */
|
/* Modification du chainage avant */
|
||||||
if( Pnext) Pnext->Pback = Pback;
|
if( Pnext )
|
||||||
|
Pnext->Pback = Pback;
|
||||||
|
|
||||||
Pnext = Pback = NULL;
|
Pnext = Pback = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************/
|
/******************************************/
|
||||||
int TEXTE_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;
|
int angle = Module->m_Orient;
|
||||||
NORMALIZE_ANGLE_POS(angle);
|
NORMALIZE_ANGLE_POS( angle );
|
||||||
|
|
||||||
RotatePoint( &m_Pos.x, &m_Pos.y, angle);
|
RotatePoint( &m_Pos.x, &m_Pos.y, angle );
|
||||||
m_Pos.x += Module->m_Pos.x;
|
m_Pos.x += Module->m_Pos.x;
|
||||||
m_Pos.y += Module->m_Pos.y;
|
m_Pos.y += Module->m_Pos.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mise a jour des coordonnées relatives au module
|
|
||||||
void TEXTE_MODULE:: SetLocalCoord(void)
|
|
||||||
{
|
|
||||||
MODULE * Module = (MODULE *) m_Parent;
|
|
||||||
|
|
||||||
if ( Module == NULL ) return;
|
// mise a jour des coordonn<6E>s relatives au module
|
||||||
|
void TEXTE_MODULE:: SetLocalCoord( void )
|
||||||
|
{
|
||||||
|
MODULE* Module = (MODULE*) m_Parent;
|
||||||
|
|
||||||
|
if( Module == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
m_Pos0.x = m_Pos.x - Module->m_Pos.x;
|
m_Pos0.x = m_Pos.x - Module->m_Pos.x;
|
||||||
m_Pos0.y = m_Pos.y - Module->m_Pos.y;
|
m_Pos0.y = m_Pos.y - Module->m_Pos.y;
|
||||||
|
|
||||||
int angle = Module->m_Orient;
|
int angle = Module->m_Orient;
|
||||||
NORMALIZE_ANGLE_POS(angle);
|
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;
|
int mX, mY, dx, dy;
|
||||||
MODULE * Module = (MODULE *) m_Parent;
|
MODULE* Module = (MODULE*) m_Parent;
|
||||||
int angle = m_Orient;
|
int angle = m_Orient;
|
||||||
|
|
||||||
if (Module) angle += Module->m_Orient;
|
if( Module )
|
||||||
|
angle += Module->m_Orient;
|
||||||
|
|
||||||
dx = (m_Size.x * GetLength()) /2;
|
dx = ( m_Size.x * GetLength() ) / 2;
|
||||||
dy = m_Size.y / 2 ;
|
dy = m_Size.y / 2;
|
||||||
dx = ((dx * 10) / 9) + m_Width; /* Facteur de forme des lettres : 10/9 */
|
dx = ( (dx * 10) / 9 ) + m_Width; /* Facteur de forme des lettres : 10/9 */
|
||||||
|
|
||||||
|
/* 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 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 */
|
/* le point de reference est-il dans ce rectangle */
|
||||||
if( ( abs(mX) <= abs(dx) ) && ( abs(mY) <= abs(dy)) )
|
if( ( abs( mX ) <= abs( dx ) ) && ( abs( mY ) <= abs( dy ) ) )
|
||||||
{
|
{
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
return 0;
|
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
|
/* trace 1 texte de module
|
||||||
Utilise la police definie dans grfonte.h
|
* Utilise la police definie dans grfonte.h
|
||||||
(Se reporter a ce fichier pour les explications complementaires)
|
* (Se reporter a ce fichier pour les explications complementaires)
|
||||||
offset = offset de trace ( reference au centre du texte)
|
* offset = offset de trace ( reference au centre du texte)
|
||||||
draw_mode = GR_OR, GR_XOR..
|
* draw_mode = GR_OR, GR_XOR..
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int zoom;
|
int zoom;
|
||||||
int width, color, orient, miroir;
|
int width, color, orient, miroir;
|
||||||
wxSize size;
|
wxSize size;
|
||||||
wxPoint pos; // Centre du texte
|
wxPoint pos; // Centre du texte
|
||||||
PCB_SCREEN * screen;
|
PCB_SCREEN* screen;
|
||||||
WinEDA_BasePcbFrame * frame;
|
WinEDA_BasePcbFrame* frame;
|
||||||
MODULE * Module = (MODULE *) m_Parent;
|
MODULE* Module = (MODULE*) m_Parent;
|
||||||
|
|
||||||
|
|
||||||
if ( panel == NULL ) return;
|
if( panel == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
screen = (PCB_SCREEN *) panel->GetScreen();
|
screen = (PCB_SCREEN*) panel->GetScreen();
|
||||||
frame = ( WinEDA_BasePcbFrame * ) panel->m_Parent;
|
frame = (WinEDA_BasePcbFrame*) panel->m_Parent;
|
||||||
zoom = screen->GetZoom();
|
zoom = screen->GetZoom();
|
||||||
|
|
||||||
pos.x = m_Pos.x - offset.x;
|
pos.x = m_Pos.x - offset.x;
|
||||||
|
@ -207,61 +224,73 @@ MODULE * Module = (MODULE *) m_Parent;
|
||||||
|
|
||||||
size = m_Size;
|
size = m_Size;
|
||||||
orient = GetDrawRotation();
|
orient = GetDrawRotation();
|
||||||
miroir = m_Miroir & 1 ; // = 0 si vu en miroir
|
miroir = m_Miroir & 1; // = 0 si vu en miroir
|
||||||
width = m_Width;
|
width = m_Width;
|
||||||
if( (frame->m_DisplayModText == FILAIRE) || ( (width/zoom) < L_MIN_DESSIN) )
|
if( (frame->m_DisplayModText == FILAIRE) || ( (width / zoom) < L_MIN_DESSIN ) )
|
||||||
width = 0;
|
width = 0;
|
||||||
else if ( frame->m_DisplayModText == SKETCH ) width = -width;
|
else if( frame->m_DisplayModText == SKETCH )
|
||||||
|
width = -width;
|
||||||
|
|
||||||
GRSetDrawMode(DC, draw_mode);
|
GRSetDrawMode( DC, draw_mode );
|
||||||
|
|
||||||
/* trace du centre du texte */
|
/* trace du centre du texte */
|
||||||
if((g_AnchorColor & ITEM_NOT_SHOW) == 0 )
|
if( (g_AnchorColor & ITEM_NOT_SHOW) == 0 )
|
||||||
{
|
{
|
||||||
int anchor_size = 2*zoom;
|
int anchor_size = 2 * zoom;
|
||||||
GRLine(&panel->m_ClipBox, DC,
|
GRLine( &panel->m_ClipBox, DC,
|
||||||
pos.x - anchor_size, pos.y,
|
pos.x - anchor_size, pos.y,
|
||||||
pos.x + anchor_size, pos.y, 0, g_AnchorColor);
|
pos.x + anchor_size, pos.y, 0, g_AnchorColor );
|
||||||
GRLine(&panel->m_ClipBox, DC,
|
GRLine( &panel->m_ClipBox, DC,
|
||||||
pos.x, pos.y - anchor_size,
|
pos.x, pos.y - anchor_size,
|
||||||
pos.x, pos.y + anchor_size, 0, g_AnchorColor);
|
pos.x, pos.y + anchor_size, 0, g_AnchorColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
color = g_DesignSettings.m_LayerColor[Module->m_Layer];
|
color = g_DesignSettings.m_LayerColor[Module->m_Layer];
|
||||||
|
|
||||||
if( Module && Module->m_Layer == CUIVRE_N) color = g_ModuleTextCUColor;
|
if( Module && Module->m_Layer == CUIVRE_N )
|
||||||
if( Module && Module->m_Layer == CMP_N) color = g_ModuleTextCMPColor;
|
color = g_ModuleTextCUColor;
|
||||||
|
if( Module && Module->m_Layer == CMP_N )
|
||||||
|
color = g_ModuleTextCMPColor;
|
||||||
|
|
||||||
if ( (color & ITEM_NOT_SHOW) != 0 ) return;
|
if( (color & ITEM_NOT_SHOW) != 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
if(m_NoShow) color = g_ModuleTextNOVColor;
|
if( m_NoShow )
|
||||||
if ( (color & ITEM_NOT_SHOW) != 0 ) return;
|
color = g_ModuleTextNOVColor;
|
||||||
|
if( (color & ITEM_NOT_SHOW) != 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
/* Si le texte doit etre mis en miroir: modif des parametres */
|
/* Si le texte doit etre mis en miroir: modif des parametres */
|
||||||
if( miroir == 0 ) size.x = - size.x;
|
if( miroir == 0 )
|
||||||
|
size.x = -size.x;
|
||||||
|
|
||||||
/* Trace du texte */
|
/* Trace du texte */
|
||||||
DrawGraphicText(panel, DC, pos , color, m_Text,
|
DrawGraphicText( panel, DC, pos, color, m_Text,
|
||||||
orient, size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width);
|
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
|
/* Return text rotation for drawings and plotting
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int rotation;
|
int rotation;
|
||||||
MODULE * Module = (MODULE *) m_Parent;
|
MODULE* Module = (MODULE*) m_Parent;
|
||||||
|
|
||||||
rotation = m_Orient;
|
rotation = m_Orient;
|
||||||
if ( Module ) rotation += Module->m_Orient;
|
if( Module )
|
||||||
|
rotation += Module->m_Orient;
|
||||||
|
|
||||||
|
NORMALIZE_ANGLE_POS( rotation );
|
||||||
|
|
||||||
NORMALIZE_ANGLE_POS(rotation);
|
|
||||||
// if( (rotation > 900 ) && (rotation < 2700 ) ) rotation -= 1800; // For angle = 0 .. 180 deg
|
// if( (rotation > 900 ) && (rotation < 2700 ) ) rotation -= 1800; // For angle = 0 .. 180 deg
|
||||||
while ( rotation > 900 ) rotation -= 1800; // For angle = -90 .. 90 deg
|
while( rotation > 900 )
|
||||||
|
rotation -= 1800;
|
||||||
|
|
||||||
|
// For angle = -90 .. 90 deg
|
||||||
|
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/***************************************************/
|
/***************************************************/
|
||||||
/* class_text_module.h : texts module description */
|
/* class_text_module.h : texts module description */
|
||||||
/***************************************************/
|
/***************************************************/
|
||||||
|
|
||||||
/* Description des Textes sur Modules : */
|
/* Description des Textes sur Modules : */
|
||||||
#define TEXT_is_REFERENCE 0
|
#define TEXT_is_REFERENCE 0
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
#define TEXT_is_DIVERS 2
|
#define TEXT_is_DIVERS 2
|
||||||
|
|
||||||
|
|
||||||
class TEXTE_MODULE: public EDA_BaseStruct
|
class TEXTE_MODULE : public EDA_BaseStruct
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int m_Layer; // layer number
|
int m_Layer; // layer number
|
||||||
|
@ -16,41 +16,46 @@ public:
|
||||||
wxPoint m_Pos; // Real coord
|
wxPoint m_Pos; // Real coord
|
||||||
wxPoint m_Pos0; // coord du debut du texte /ancre, orient 0
|
wxPoint m_Pos0; // coord du debut du texte /ancre, orient 0
|
||||||
char m_Unused; // unused (reserved for future extensions)
|
char m_Unused; // unused (reserved for future extensions)
|
||||||
char m_Miroir ; // vue normale / miroir
|
char m_Miroir; // vue normale / miroir
|
||||||
char m_NoShow; // 0: visible 1: invisible (bool)
|
char m_NoShow; // 0: visible 1: invisible (bool)
|
||||||
char m_Type; // 0: ref,1: val, autre = 2..255
|
char m_Type; // 0: ref,1: val, autre = 2..255
|
||||||
int m_Orient; // orientation en 1/10 degre
|
int m_Orient; // orientation en 1/10 degre
|
||||||
wxSize m_Size; // dimensions (en X et Y) du texte
|
wxSize m_Size; // dimensions (en X et Y) du texte
|
||||||
wxString m_Text;
|
wxString m_Text;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TEXTE_MODULE(MODULE * parent, int text_type = TEXT_is_DIVERS );
|
TEXTE_MODULE( MODULE* parent, int text_type = TEXT_is_DIVERS );
|
||||||
~TEXTE_MODULE(void);
|
~TEXTE_MODULE( void );
|
||||||
|
|
||||||
/* supprime du chainage la structure Struct */
|
/* supprime du chainage la structure Struct */
|
||||||
void UnLink( void );
|
void UnLink( void );
|
||||||
|
|
||||||
void Copy(TEXTE_MODULE * source); // copy structure
|
void Copy( TEXTE_MODULE* source ); // copy structure
|
||||||
|
|
||||||
/* Gestion du texte */
|
/* Gestion du texte */
|
||||||
void SetWidth(int new_width);
|
void SetWidth( int new_width );
|
||||||
int GetLength(void); /* text length */
|
int GetLength( void ); /* text length */
|
||||||
int Pitch(void); /* retourne le pas entre 2 caracteres */
|
int Pitch( void ); /* retourne le pas entre 2 caracteres */
|
||||||
int GetDrawRotation(void); // Return text rotation for drawings and plotting
|
int GetDrawRotation( void ); // Return text rotation for drawings and plotting
|
||||||
|
|
||||||
void SetDrawCoord(void); // mise a jour des coordonnées absolues de tracé
|
void SetDrawCoord( void ); // mise a jour des coordonn<6E>s absolues de trac<61>
|
||||||
// a partir des coord relatives
|
// a partir des coord relatives
|
||||||
void SetLocalCoord(void); // mise a jour des coordonnées relatives
|
|
||||||
// a partir des coord absolues de tracé
|
|
||||||
|
|
||||||
|
void SetLocalCoord( void ); // mise a jour des coordonn<6E>s relatives
|
||||||
|
|
||||||
|
// a partir des coord absolues de trac<61>
|
||||||
/* Reading and writing data on files */
|
/* Reading and writing data on files */
|
||||||
int WriteDescr( FILE * File );
|
int WriteDescr( FILE* File );
|
||||||
int ReadDescr( FILE * File, int * LineNum = NULL);
|
int ReadDescr( FILE* File, int* LineNum = NULL );
|
||||||
|
|
||||||
/* drawing functions */
|
/* drawing functions */
|
||||||
void Draw(WinEDA_DrawPanel * panel, wxDC * DC, wxPoint offset, int draw_mode);
|
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, wxPoint offset, int draw_mode );
|
||||||
|
|
||||||
/* 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 );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
|
||||||
{
|
{
|
||||||
bool PopupOn = GetScreen()->m_CurrentItem
|
bool PopupOn = GetScreen()->m_CurrentItem
|
||||||
&& GetScreen()->m_CurrentItem->m_Flags;
|
&& GetScreen()->m_CurrentItem->m_Flags;
|
||||||
|
|
||||||
bool ItemFree = (GetScreen()->m_CurrentItem == 0 )
|
bool ItemFree = (GetScreen()->m_CurrentItem == 0 )
|
||||||
|| (GetScreen()->m_CurrentItem->m_Flags == 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);
|
|| (GetScreen()->m_CurrentItem->m_Flags == 0);
|
||||||
if( ItemFree )
|
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();
|
DrawStruct = PcbGeneralLocateAndDisplay();
|
||||||
|
|
||||||
//don't let backspace delete modules!!
|
// don't let backspace delete modules!!
|
||||||
if( DrawStruct && (DrawStruct->m_StructType == TYPETRACK
|
if( DrawStruct && (DrawStruct->m_StructType == TYPETRACK
|
||||||
|| DrawStruct->m_StructType == TYPEVIA) )
|
|| DrawStruct->m_StructType == TYPEVIA) )
|
||||||
Delete_Segment( DC, (TRACK*) DrawStruct );
|
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 )
|
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 =
|
GetScreen()->m_CurrentItem =
|
||||||
Delete_Segment( DC, (TRACK*) GetScreen()->m_CurrentItem );
|
Delete_Segment( DC, (TRACK*) GetScreen()->m_CurrentItem );
|
||||||
GetScreen()->SetModify();
|
GetScreen()->SetModify();
|
||||||
|
@ -97,7 +98,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
|
||||||
|
|
||||||
case 'O' + GR_KB_CTRL:
|
case 'O' + GR_KB_CTRL:
|
||||||
{
|
{
|
||||||
//try not to duplicate save, load code etc.
|
// try not to duplicate save, load code etc.
|
||||||
wxCommandEvent evt;
|
wxCommandEvent evt;
|
||||||
evt.SetId( ID_LOAD_FILE );
|
evt.SetId( ID_LOAD_FILE );
|
||||||
Files_io( evt );
|
Files_io( evt );
|
||||||
|
@ -106,7 +107,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
|
||||||
|
|
||||||
case 'S' + GR_KB_CTRL:
|
case 'S' + GR_KB_CTRL:
|
||||||
{
|
{
|
||||||
//try not to duplicate save, load code etc.
|
// try not to duplicate save, load code etc.
|
||||||
wxCommandEvent evt;
|
wxCommandEvent evt;
|
||||||
evt.SetId( ID_SAVE_BOARD );
|
evt.SetId( ID_SAVE_BOARD );
|
||||||
Files_io( evt );
|
Files_io( evt );
|
||||||
|
@ -163,10 +164,18 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
|
||||||
if( module == NULL ) // no footprint found
|
if( module == NULL ) // no footprint found
|
||||||
{
|
{
|
||||||
module = Locate_Prefered_Module( m_Pcb, CURSEUR_OFF_GRILLE );
|
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() )
|
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;
|
module = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -426,7 +426,7 @@ 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->Locate( ref_pos ) )
|
if( pt_txt->HitTest( ref_pos ) )
|
||||||
return PtStruct;
|
return PtStruct;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -857,7 +857,7 @@ TEXTE_MODULE* LocateTexteModule( BOARD* Pcb, MODULE** PtModule, int typeloc )
|
||||||
|
|
||||||
// hit-test the reference text
|
// hit-test the reference text
|
||||||
pt_txt_mod = module->m_Reference;
|
pt_txt_mod = module->m_Reference;
|
||||||
if( pt_txt_mod->Locate( ref_pos ) )
|
if( pt_txt_mod->HitTest( ref_pos ) )
|
||||||
{
|
{
|
||||||
if( PtModule )
|
if( PtModule )
|
||||||
*PtModule = module;
|
*PtModule = module;
|
||||||
|
@ -866,7 +866,7 @@ TEXTE_MODULE* LocateTexteModule( BOARD* Pcb, MODULE** PtModule, int typeloc )
|
||||||
|
|
||||||
// hit-test the value text
|
// hit-test the value text
|
||||||
pt_txt_mod = module->m_Value;
|
pt_txt_mod = module->m_Value;
|
||||||
if( pt_txt_mod->Locate( ref_pos ) )
|
if( pt_txt_mod->HitTest( ref_pos ) )
|
||||||
{
|
{
|
||||||
if( PtModule )
|
if( PtModule )
|
||||||
*PtModule = module;
|
*PtModule = module;
|
||||||
|
@ -881,7 +881,7 @@ TEXTE_MODULE* LocateTexteModule( BOARD* Pcb, MODULE** PtModule, int typeloc )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pt_txt_mod = (TEXTE_MODULE*) PtStruct;
|
pt_txt_mod = (TEXTE_MODULE*) PtStruct;
|
||||||
if( pt_txt_mod->Locate( ref_pos ) )
|
if( pt_txt_mod->HitTest( ref_pos ) )
|
||||||
{
|
{
|
||||||
if( PtModule )
|
if( PtModule )
|
||||||
*PtModule = module;
|
*PtModule = module;
|
||||||
|
@ -1151,7 +1151,7 @@ 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->Locate( ref ) )
|
if( pt_txt_pcb->HitTest( ref ) )
|
||||||
{
|
{
|
||||||
if( pt_txt_pcb->m_Layer == LayerSearch )
|
if( pt_txt_pcb->m_Layer == LayerSearch )
|
||||||
return pt_txt_pcb;
|
return pt_txt_pcb;
|
||||||
|
|
Loading…
Reference in New Issue