2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************************/
|
|
|
|
/* Methodes de base de gestion des classes des elements de schematique */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2008-02-20 19:37:17 +00:00
|
|
|
#include "trigo.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "id.h"
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "drawtxt.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
/************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
/* class SCH_TEXT */
|
|
|
|
/* class SCH_LABEL */
|
|
|
|
/* class SCH_GLOBALLABEL */
|
|
|
|
/* class SCH_HIERLABEL */
|
2007-09-01 12:00:30 +00:00
|
|
|
/************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/* Messages correspondants aux types ou forme des labels */
|
|
|
|
const char* SheetLabelType[] =
|
|
|
|
{
|
|
|
|
"Input",
|
|
|
|
"Output",
|
|
|
|
"BiDi",
|
|
|
|
"3State",
|
|
|
|
"UnSpc",
|
|
|
|
"?????"
|
|
|
|
};
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
/* Coding polygons for global symbol graphic shapes.
|
|
|
|
* the first parml is the number of corners
|
|
|
|
* others are the corners coordinates in reduced units
|
|
|
|
* the real coordinate is the reduced coordinate * text half size
|
|
|
|
*/
|
2009-05-12 12:12:34 +00:00
|
|
|
static int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 };
|
|
|
|
static int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 };
|
|
|
|
static int TemplateIN_UP[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 };
|
|
|
|
static int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 };
|
|
|
|
|
|
|
|
static int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 };
|
|
|
|
static int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 };
|
|
|
|
static int TemplateOUT_UP[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 };
|
|
|
|
static int TemplateOUT_BOTTOM[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 };
|
|
|
|
|
|
|
|
static int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 };
|
|
|
|
static int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 };
|
|
|
|
static int TemplateUNSPC_UP[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 };
|
|
|
|
static int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 };
|
|
|
|
|
|
|
|
static int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
|
|
|
|
static int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
|
|
|
|
static int TemplateBIDI_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
|
|
|
|
static int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
|
|
|
|
|
|
|
|
static int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
|
|
|
|
static int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
|
|
|
|
static int Template3STATE_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
|
|
|
|
static int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
|
|
|
|
|
|
|
|
static int* TemplateShape[5][4] =
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
{ TemplateIN_HN, TemplateIN_UP, TemplateIN_HI, TemplateIN_BOTTOM },
|
|
|
|
{ TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI, TemplateOUT_BOTTOM },
|
|
|
|
{ TemplateBIDI_HN, TemplateBIDI_UP, TemplateBIDI_HI, TemplateBIDI_BOTTOM },
|
|
|
|
{ Template3STATE_HN, Template3STATE_UP, Template3STATE_HI, Template3STATE_BOTTOM },
|
|
|
|
{ TemplateUNSPC_HN, TemplateUNSPC_UP, TemplateUNSPC_HI, TemplateUNSPC_BOTTOM }
|
2009-04-05 20:49:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
|
2009-05-05 17:32:07 +00:00
|
|
|
SCH_ITEM( NULL, aType ),
|
|
|
|
EDA_TextStruct( text )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
m_Layer = LAYER_NOTES;
|
|
|
|
m_Pos = pos;
|
|
|
|
m_Shape = 0;
|
2007-09-01 12:00:30 +00:00
|
|
|
m_IsDangling = FALSE;
|
2009-05-12 12:12:34 +00:00
|
|
|
m_MultilineAllowed = true;
|
|
|
|
m_SchematicOrientation = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2009-01-31 18:08:47 +00:00
|
|
|
/** Function HitTest
|
|
|
|
* @return true if the point aPosRef is within item area
|
|
|
|
* @param aPosRef = a wxPoint to test
|
|
|
|
*/
|
|
|
|
bool SCH_TEXT::HitTest( const wxPoint& aPosRef )
|
|
|
|
{
|
2009-06-11 14:26:17 +00:00
|
|
|
return TextHitTest( aPosRef );
|
2009-01-31 18:08:47 +00:00
|
|
|
}
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_TEXT* SCH_TEXT::GenCopy()
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************/
|
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_TEXT* newitem;
|
2008-01-21 16:21:41 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( Type() )
|
|
|
|
{
|
2007-09-13 11:28:58 +00:00
|
|
|
default:
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_TEXT:
|
|
|
|
newitem = new SCH_TEXT( m_Pos, m_Text );
|
2007-09-01 12:00:30 +00:00
|
|
|
break;
|
2008-01-21 16:21:41 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
|
|
|
newitem = new SCH_GLOBALLABEL( m_Pos, m_Text );
|
2007-09-01 12:00:30 +00:00
|
|
|
break;
|
2008-01-21 16:21:41 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_HIERLABEL:
|
|
|
|
newitem = new SCH_HIERLABEL( m_Pos, m_Text );
|
2008-02-20 19:37:17 +00:00
|
|
|
break;
|
2008-02-12 21:12:46 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
newitem = new SCH_LABEL( m_Pos, m_Text );
|
2007-09-01 12:00:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
newitem->m_Layer = m_Layer;
|
|
|
|
newitem->m_Shape = m_Shape;
|
|
|
|
newitem->m_Orient = m_Orient;
|
|
|
|
newitem->m_Size = m_Size;
|
|
|
|
newitem->m_Width = m_Width;
|
|
|
|
newitem->m_HJustify = m_HJustify;
|
|
|
|
newitem->m_VJustify = m_VJustify;
|
|
|
|
newitem->m_IsDangling = m_IsDangling;
|
2009-04-09 09:00:23 +00:00
|
|
|
newitem->m_Italic = m_Italic;
|
2009-05-28 17:39:40 +00:00
|
|
|
newitem->m_Bold = m_Bold;
|
2009-05-12 12:12:34 +00:00
|
|
|
newitem->m_SchematicOrientation = m_SchematicOrientation;
|
2007-09-01 12:00:30 +00:00
|
|
|
|
|
|
|
return newitem;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
/** function GetSchematicTextOffset (virtual)
|
|
|
|
* @return the offset between the SCH_TEXT position and the text itself position
|
|
|
|
* This offset depend on orientation, and the type of text
|
|
|
|
* (room to draw an associated graphic symbol, or put the text above a wire)
|
|
|
|
*/
|
|
|
|
wxPoint SCH_TEXT::GetSchematicTextOffset()
|
|
|
|
{
|
|
|
|
wxPoint text_offset;
|
|
|
|
|
|
|
|
// add a small offset (TXTMARGE) to x ( or y) position to allow a text to be on a wire or a line and be readable
|
|
|
|
switch( m_SchematicOrientation )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0: /* Horiz Normal Orientation (left justified) */
|
|
|
|
text_offset.y = -TXTMARGE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* Vert Orientation UP */
|
|
|
|
text_offset.x = -TXTMARGE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* Horiz Orientation - Right justified */
|
|
|
|
text_offset.y = -TXTMARGE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* Vert Orientation BOTTOM */
|
|
|
|
text_offset.x = -TXTMARGE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return text_offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** function GetSchematicTextOffset (virtual)
|
|
|
|
* @return the offset between the SCH_TEXT position and the text itself position
|
|
|
|
* This offset depend on orientation, and the type of text
|
|
|
|
* (room to draw an associated graphic symbol, or put the text above a wire)
|
|
|
|
*/
|
|
|
|
wxPoint SCH_LABEL::GetSchematicTextOffset()
|
|
|
|
{
|
|
|
|
return SCH_TEXT::GetSchematicTextOffset();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
/** virtual function Mirror_Y
|
|
|
|
* mirror item relative to an Y axis
|
|
|
|
* @param aYaxis_position = the y axis position
|
|
|
|
*/
|
|
|
|
void SCH_TEXT::Mirror_Y(int aYaxis_position)
|
|
|
|
{
|
|
|
|
// Text is NOT really mirrored; it is moved to a suitable position
|
|
|
|
// which is the closest position for a true mirrored text
|
|
|
|
// The center position is mirrored and the text is moved for half horizontal len
|
|
|
|
int px = m_Pos.x;
|
|
|
|
int dx;
|
|
|
|
if( m_Orient == 0 ) /* horizontal text */
|
|
|
|
dx = LenSize( m_Text ) / 2;
|
|
|
|
else if( m_Orient == 2 ) /* invert horizontal text*/
|
|
|
|
dx = -LenSize( m_Text ) / 2;
|
|
|
|
else
|
|
|
|
dx = 0;
|
|
|
|
px += dx;
|
|
|
|
px -= aYaxis_position;
|
|
|
|
NEGATE(px);
|
|
|
|
px += aYaxis_position;
|
|
|
|
px -= dx;
|
|
|
|
m_Pos.x = px;
|
|
|
|
}
|
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
/** function GetSchematicTextOffset (virtual)
|
|
|
|
* @return the offset between the SCH_TEXT position and the text itself position
|
|
|
|
* This offset depend on orientation, and the type of text
|
|
|
|
* (room to draw an associated graphic symbol, or put the text above a wire)
|
|
|
|
*/
|
|
|
|
wxPoint SCH_HIERLABEL::GetSchematicTextOffset()
|
|
|
|
{
|
|
|
|
wxPoint text_offset;
|
|
|
|
|
2009-06-02 07:26:49 +00:00
|
|
|
int width = MAX( m_Width, g_DrawDefaultLineThickness );
|
2009-05-12 12:12:34 +00:00
|
|
|
|
|
|
|
int ii = m_Size.x + TXTMARGE + width;
|
|
|
|
|
|
|
|
switch( m_SchematicOrientation )
|
|
|
|
{
|
|
|
|
case 0: /* Orientation horiz normale */
|
|
|
|
text_offset.x = -ii;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* Orientation vert UP */
|
|
|
|
text_offset.y = -ii;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* Orientation horiz inverse */
|
|
|
|
text_offset.x = ii;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* Orientation vert BOTTOM */
|
|
|
|
text_offset.y = ii;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return text_offset;
|
|
|
|
}
|
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
/** virtual function Mirror_Y
|
|
|
|
* mirror item relative to an Y axis
|
|
|
|
* @param aYaxis_position = the y axis position
|
|
|
|
*/
|
|
|
|
void SCH_HIERLABEL::Mirror_Y(int aYaxis_position)
|
|
|
|
{
|
|
|
|
// Text is NOT really mirrored; it is moved to a suitable position
|
|
|
|
// which is the closest position for a true mirrored text
|
|
|
|
// The center position is mirrored and the text is moved for half horizontal len
|
|
|
|
if( m_Orient == 0 ) /* horizontal text */
|
|
|
|
m_Orient = 2;
|
|
|
|
else if( m_Orient == 2 ) /* invert horizontal text*/
|
|
|
|
m_Orient = 0;
|
|
|
|
m_Pos.x -= aYaxis_position;
|
|
|
|
NEGATE(m_Pos.x);
|
|
|
|
m_Pos.x += aYaxis_position;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** virtual function Mirror_Y
|
|
|
|
* mirror item relative to an Y axis
|
|
|
|
* @param aYaxis_position = the y axis position
|
|
|
|
*/
|
|
|
|
void SCH_GLOBALLABEL::Mirror_Y(int aYaxis_position)
|
|
|
|
{
|
|
|
|
// Text is NOT really mirrored; it is moved to a suitable position
|
|
|
|
// which is the closest position for a true mirrored text
|
|
|
|
// The center position is mirrored and the text is moved for half horizontal len
|
|
|
|
if( m_Orient == 0 ) /* horizontal text */
|
|
|
|
m_Orient = 2;
|
|
|
|
else if( m_Orient == 2 ) /* invert horizontal text*/
|
|
|
|
m_Orient = 0;
|
|
|
|
m_Pos.x -= aYaxis_position;
|
|
|
|
NEGATE(m_Pos.x);
|
|
|
|
m_Pos.x += aYaxis_position;
|
|
|
|
}
|
2009-05-12 12:12:34 +00:00
|
|
|
|
|
|
|
/** function GetSchematicTextOffset (virtual)
|
|
|
|
* @return the offset between the SCH_TEXT position and the text itself position
|
|
|
|
* This offset depend on orientation, and the type of text
|
|
|
|
* (room to draw an associated graphic symbol, or put the text above a wire)
|
|
|
|
*/
|
|
|
|
wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset()
|
|
|
|
{
|
|
|
|
wxPoint text_offset;
|
2009-06-02 07:26:49 +00:00
|
|
|
int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
|
|
|
|
|
|
|
|
width = Clamp_Text_PenSize( width, m_Size, m_Bold );
|
2009-05-12 12:12:34 +00:00
|
|
|
int HalfSize = m_Size.x / 2;
|
|
|
|
int offset = width;
|
|
|
|
|
|
|
|
switch( m_Shape )
|
|
|
|
{
|
|
|
|
case NET_INPUT:
|
|
|
|
case NET_BIDI:
|
|
|
|
case NET_TRISTATE:
|
|
|
|
offset += HalfSize;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_OUTPUT:
|
2009-05-28 17:39:40 +00:00
|
|
|
case NET_UNSPECIFIED:
|
2009-05-12 12:12:34 +00:00
|
|
|
offset += TXTMARGE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( m_SchematicOrientation )
|
|
|
|
{
|
|
|
|
case 0: /* Orientation horiz normale */
|
|
|
|
text_offset.x -= offset;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* Orientation vert UP */
|
|
|
|
text_offset.y -= offset;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* Orientation horiz inverse */
|
|
|
|
text_offset.x += offset;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* Orientation vert BOTTOM */
|
|
|
|
text_offset.y += offset;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return text_offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** function SetTextOrientAndJustifyParmeters (virtual)
|
|
|
|
* Set m_SchematicOrientation, and initialize
|
|
|
|
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation
|
|
|
|
* must be called after changing m_SchematicOrientation
|
|
|
|
* @param aSchematicOrientation =
|
|
|
|
* 0 = normal (horizontal, left justified).
|
|
|
|
* 1 = up (vertical)
|
|
|
|
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
|
|
|
|
* 3 = bottom . This can be seen as the mirrored position of up
|
|
|
|
*/
|
|
|
|
void SCH_TEXT::SetSchematicTextOrientation( int aSchematicOrientation )
|
|
|
|
{
|
|
|
|
m_SchematicOrientation = aSchematicOrientation;
|
|
|
|
|
|
|
|
switch( m_SchematicOrientation )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0: /* Horiz Normal Orientation (left justified) */
|
|
|
|
m_Orient = TEXT_ORIENT_HORIZ;
|
|
|
|
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
|
|
|
|
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* Vert Orientation UP */
|
|
|
|
m_Orient = TEXT_ORIENT_VERT;
|
|
|
|
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
|
|
|
|
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* Horiz Orientation - Right justified */
|
|
|
|
m_Orient = TEXT_ORIENT_HORIZ;
|
|
|
|
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
|
|
|
|
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* Vert Orientation BOTTOM */
|
|
|
|
m_Orient = TEXT_ORIENT_VERT;
|
|
|
|
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
|
|
|
|
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** function SetTextOrientAndJustifyParmeters
|
|
|
|
* Set m_SchematicOrientation, and initialize
|
|
|
|
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation (for a label)
|
|
|
|
* must be called after changing m_SchematicOrientation
|
|
|
|
* @param aSchematicOrientation =
|
|
|
|
* 0 = normal (horizontal, left justified).
|
|
|
|
* 1 = up (vertical)
|
|
|
|
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
|
|
|
|
* 3 = bottom . This can be seen as the mirrored position of up
|
|
|
|
*/
|
|
|
|
void SCH_LABEL::SetSchematicTextOrientation( int aSchematicOrientation )
|
|
|
|
{
|
|
|
|
SCH_TEXT::SetSchematicTextOrientation( aSchematicOrientation );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** function SetTextOrientAndJustifyParmeters
|
|
|
|
* Set m_SchematicOrientation, and initialize
|
|
|
|
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation
|
|
|
|
* must be called after changing m_SchematicOrientation
|
|
|
|
* @param aSchematicOrientation =
|
|
|
|
* 0 = normal (horizontal, left justified).
|
|
|
|
* 1 = up (vertical)
|
|
|
|
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
|
|
|
|
* 3 = bottom . This can be seen as the mirrored position of up
|
|
|
|
*/
|
|
|
|
void SCH_GLOBALLABEL::SetSchematicTextOrientation( int aSchematicOrientation )
|
|
|
|
{
|
|
|
|
m_SchematicOrientation = aSchematicOrientation;
|
|
|
|
|
|
|
|
switch( m_SchematicOrientation )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0: /* Horiz Normal Orientation */
|
|
|
|
m_Orient = TEXT_ORIENT_HORIZ;
|
|
|
|
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
|
|
|
|
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* Vert Orientation UP */
|
|
|
|
m_Orient = TEXT_ORIENT_VERT;
|
|
|
|
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
|
|
|
|
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* Horiz Orientation */
|
|
|
|
m_Orient = TEXT_ORIENT_HORIZ;
|
|
|
|
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
|
|
|
|
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* Vert Orientation BOTTOM */
|
|
|
|
m_Orient = TEXT_ORIENT_VERT;
|
|
|
|
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
|
|
|
|
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** function SetTextOrientAndJustifyParmeters
|
|
|
|
* Set m_SchematicOrientation, and initialize
|
|
|
|
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation
|
|
|
|
* must be called after changing m_SchematicOrientation
|
|
|
|
* @param aSchematicOrientation =
|
|
|
|
* 0 = normal (horizontal, left justified).
|
|
|
|
* 1 = up (vertical)
|
|
|
|
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
|
|
|
|
* 3 = bottom . This can be seen as the mirrored position of up
|
|
|
|
*/
|
|
|
|
void SCH_HIERLABEL::SetSchematicTextOrientation( int aSchematicOrientation )
|
|
|
|
{
|
|
|
|
m_SchematicOrientation = aSchematicOrientation;
|
|
|
|
|
|
|
|
switch( m_SchematicOrientation )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0: /* Horiz Normal Orientation */
|
|
|
|
m_Orient = TEXT_ORIENT_HORIZ;
|
|
|
|
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
|
|
|
|
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* Vert Orientation UP */
|
|
|
|
m_Orient = TEXT_ORIENT_VERT;
|
|
|
|
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
|
|
|
|
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* Horiz Orientation */
|
|
|
|
m_Orient = TEXT_ORIENT_HORIZ;
|
|
|
|
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
|
|
|
|
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* Vert Orientation BOTTOM */
|
|
|
|
m_Orient = TEXT_ORIENT_VERT;
|
|
|
|
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
|
|
|
|
m_VJustify = GR_TEXT_VJUSTIFY_CENTER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
void SCH_TEXT::SwapData( SCH_TEXT* copyitem )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
EXCHG( m_Text, copyitem->m_Text );
|
|
|
|
EXCHG( m_Pos, copyitem->m_Pos );
|
|
|
|
EXCHG( m_Size, copyitem->m_Size );
|
|
|
|
EXCHG( m_Width, copyitem->m_Width );
|
|
|
|
EXCHG( m_Shape, copyitem->m_Shape );
|
|
|
|
EXCHG( m_Orient, copyitem->m_Orient );
|
|
|
|
|
|
|
|
EXCHG( m_Layer, copyitem->m_Layer );
|
|
|
|
EXCHG( m_HJustify, copyitem->m_HJustify );
|
|
|
|
EXCHG( m_VJustify, copyitem->m_VJustify );
|
|
|
|
EXCHG( m_IsDangling, copyitem->m_IsDangling );
|
2009-05-12 12:12:34 +00:00
|
|
|
EXCHG( m_SchematicOrientation, copyitem->m_SchematicOrientation );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************************/
|
2008-04-17 16:25:29 +00:00
|
|
|
void SCH_TEXT::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************************/
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
/* save old text in undo list */
|
|
|
|
if( g_ItemToUndoCopy && ( (m_Flags & IS_NEW) == 0 ) )
|
|
|
|
{
|
|
|
|
/* restore old values and save new ones */
|
2008-03-20 01:50:21 +00:00
|
|
|
SwapData( (SCH_TEXT*) g_ItemToUndoCopy );
|
2008-01-21 16:21:41 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
/* save in undo list */
|
2009-07-26 17:16:42 +00:00
|
|
|
frame->SaveCopyInUndoList( this, UR_CHANGED );
|
2008-01-21 16:21:41 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
/* restore new values */
|
2008-03-20 01:50:21 +00:00
|
|
|
SwapData( (SCH_TEXT*) g_ItemToUndoCopy );
|
2008-01-21 16:21:41 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
SAFE_DELETE( g_ItemToUndoCopy );
|
2007-09-01 12:00:30 +00:00
|
|
|
}
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
SCH_ITEM::Place( frame, DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2009-06-30 17:57:27 +00:00
|
|
|
/** Function GetPenSize
|
|
|
|
* @return the size of the "pen" that be used to draw or plot this item
|
|
|
|
*/
|
|
|
|
int SCH_TEXT::GetPenSize( )
|
|
|
|
{
|
|
|
|
int pensize = m_Width;
|
|
|
|
|
|
|
|
if( pensize == 0 ) // Use default values for pen size
|
|
|
|
{
|
|
|
|
if( m_Bold )
|
|
|
|
pensize = GetPenSizeForBold( m_Size.x );
|
|
|
|
else
|
|
|
|
pensize = g_DrawDefaultLineThickness;
|
|
|
|
}
|
|
|
|
// Clip pen size for small texts:
|
|
|
|
pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold );
|
|
|
|
return pensize;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/*******************************************************************************************/
|
2009-05-05 17:32:07 +00:00
|
|
|
void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset,
|
|
|
|
int DrawMode, int Color )
|
2007-05-28 18:09:49 +00:00
|
|
|
/*******************************************************************************************/
|
2008-01-21 16:21:41 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/* Texts type Comment (text on layer "NOTE") have 4 directions, and the Text origin is the first letter
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-14 19:45:05 +00:00
|
|
|
EDA_Colors color;
|
2009-06-02 07:26:49 +00:00
|
|
|
int linewidth = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
|
|
|
|
|
|
|
|
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
|
2007-09-01 12:00:30 +00:00
|
|
|
|
|
|
|
if( Color >= 0 )
|
2009-05-05 17:32:07 +00:00
|
|
|
color = (EDA_Colors) Color;
|
2007-09-01 12:00:30 +00:00
|
|
|
else
|
|
|
|
color = ReturnLayerColor( m_Layer );
|
|
|
|
GRSetDrawMode( DC, DrawMode );
|
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
wxPoint text_offset = aOffset + GetSchematicTextOffset();
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2009-06-02 07:26:49 +00:00
|
|
|
EXCHG( linewidth, m_Width ); // Set the minimum width
|
2009-05-05 17:32:07 +00:00
|
|
|
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
|
2009-06-02 07:26:49 +00:00
|
|
|
EXCHG( linewidth, m_Width ); // set initial value
|
2007-09-01 12:00:30 +00:00
|
|
|
if( m_IsDangling )
|
2009-05-05 17:32:07 +00:00
|
|
|
DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
/**
|
|
|
|
* Function Save
|
|
|
|
* writes the data structures for this object out to a FILE in "*.brd" format.
|
|
|
|
* @param aFile The FILE to write to.
|
|
|
|
* @return bool - true if success writing else false.
|
|
|
|
*/
|
|
|
|
bool SCH_TEXT::Save( FILE* aFile ) const
|
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
bool success = true;
|
|
|
|
const char* shape = "~";
|
|
|
|
|
|
|
|
if( m_Italic )
|
2008-12-19 20:40:08 +00:00
|
|
|
shape = "Italic";
|
2009-05-12 12:12:34 +00:00
|
|
|
|
|
|
|
wxString text = m_Text;
|
|
|
|
|
|
|
|
for( ; ; )
|
2009-05-09 21:54:33 +00:00
|
|
|
{
|
2009-05-12 12:12:34 +00:00
|
|
|
int i = text.find( '\n' );
|
|
|
|
if( i==wxNOT_FOUND )
|
|
|
|
break;
|
|
|
|
|
|
|
|
text.erase( i, 1 );
|
2009-05-16 05:38:38 +00:00
|
|
|
text.insert( i, wxT( "\\n" ) );
|
2009-05-09 21:54:33 +00:00
|
|
|
}
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2008-12-19 20:40:08 +00:00
|
|
|
if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n",
|
2009-05-12 12:12:34 +00:00
|
|
|
m_Pos.x, m_Pos.y,
|
|
|
|
m_SchematicOrientation, m_Size.x,
|
2009-05-30 16:06:01 +00:00
|
|
|
shape, m_Width,
|
2009-05-12 12:12:34 +00:00
|
|
|
CONV_TO_UTF8( text ) ) == EOF )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
|
|
|
success = false;
|
|
|
|
}
|
2009-05-12 12:12:34 +00:00
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-22 16:38:23 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
|
|
|
|
void SCH_TEXT::Show( int nestLevel, std::ostream& os )
|
|
|
|
{
|
|
|
|
// XML output:
|
|
|
|
wxString s = GetClass();
|
|
|
|
|
|
|
|
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
|
2009-05-05 17:32:07 +00:00
|
|
|
<< " layer=\"" << m_Layer << '"'
|
|
|
|
<< " shape=\"" << m_Shape << '"'
|
|
|
|
<< " dangling=\"" << m_IsDangling << '"'
|
|
|
|
<< '>'
|
|
|
|
<< CONV_TO_UTF8( m_Text )
|
|
|
|
<< "</" << s.Lower().mb_str() << ">\n";
|
2008-04-22 16:38:23 +00:00
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2008-04-22 16:38:23 +00:00
|
|
|
#endif
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
/****************************************************************************/
|
|
|
|
SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
|
|
|
|
SCH_TEXT( pos, text, TYPE_SCH_LABEL )
|
|
|
|
/****************************************************************************/
|
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
m_Layer = LAYER_LOCLABEL;
|
|
|
|
m_Shape = NET_INPUT;
|
2008-04-15 19:38:19 +00:00
|
|
|
m_IsDangling = TRUE;
|
2009-05-12 12:12:34 +00:00
|
|
|
m_MultilineAllowed = false;
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Save
|
|
|
|
* writes the data structures for this object out to a FILE in "*.brd" format.
|
|
|
|
* @param aFile The FILE to write to.
|
|
|
|
* @return bool - true if success writing else false.
|
|
|
|
*/
|
|
|
|
bool SCH_LABEL::Save( FILE* aFile ) const
|
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
bool success = true;
|
|
|
|
const char* shape = "~";
|
|
|
|
|
|
|
|
if( m_Italic )
|
2008-12-19 20:40:08 +00:00
|
|
|
shape = "Italic";
|
|
|
|
|
|
|
|
if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %s %d\n%s\n",
|
2009-05-05 17:32:07 +00:00
|
|
|
m_Pos.x, m_Pos.y,
|
2009-05-30 16:06:01 +00:00
|
|
|
m_SchematicOrientation, m_Size.x, shape, m_Width,
|
2009-05-05 17:32:07 +00:00
|
|
|
CONV_TO_UTF8( m_Text ) ) == EOF )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************************/
|
|
|
|
SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
|
|
|
|
SCH_TEXT( pos, text, TYPE_SCH_GLOBALLABEL )
|
|
|
|
/***********************************************************************************/
|
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
m_Layer = LAYER_GLOBLABEL;
|
|
|
|
m_Shape = NET_BIDI;
|
2008-04-15 19:38:19 +00:00
|
|
|
m_IsDangling = TRUE;
|
2009-05-12 12:12:34 +00:00
|
|
|
m_MultilineAllowed = false;
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Save
|
|
|
|
* writes the data structures for this object out to a FILE in "*.brd" format.
|
|
|
|
* @param aFile The FILE to write to.
|
|
|
|
* @return bool - true if success writing else false.
|
|
|
|
*/
|
|
|
|
bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
|
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
bool success = true;
|
|
|
|
const char* shape = "~";
|
|
|
|
|
|
|
|
if( m_Italic )
|
2008-12-19 20:40:08 +00:00
|
|
|
shape = "Italic";
|
|
|
|
if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
|
2009-05-05 17:32:07 +00:00
|
|
|
m_Pos.x, m_Pos.y,
|
2009-05-12 12:12:34 +00:00
|
|
|
m_SchematicOrientation, m_Size.x,
|
2009-05-05 17:32:07 +00:00
|
|
|
SheetLabelType[m_Shape],
|
2009-05-30 16:06:01 +00:00
|
|
|
shape, m_Width,
|
2009-05-05 17:32:07 +00:00
|
|
|
CONV_TO_UTF8( m_Text ) ) == EOF )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2009-01-31 18:08:47 +00:00
|
|
|
/************************************************/
|
|
|
|
bool SCH_GLOBALLABEL::HitTest( const wxPoint& aPosRef )
|
|
|
|
/************************************************/
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2009-01-31 18:08:47 +00:00
|
|
|
/** Function HitTest
|
|
|
|
* @return true if the point aPosRef is within item area
|
|
|
|
* @param aPosRef = a wxPoint to test
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
EDA_Rect rect = GetBoundingBox();
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2009-01-31 18:08:47 +00:00
|
|
|
return rect.Inside( aPosRef );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
/***********************************************************************************/
|
|
|
|
SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) :
|
|
|
|
SCH_TEXT( pos, text, TYPE_SCH_HIERLABEL )
|
|
|
|
/***********************************************************************************/
|
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
m_Layer = LAYER_HIERLABEL;
|
|
|
|
m_Shape = NET_INPUT;
|
2008-04-15 19:38:19 +00:00
|
|
|
m_IsDangling = TRUE;
|
2009-05-12 12:12:34 +00:00
|
|
|
m_MultilineAllowed = false;
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Save
|
|
|
|
* writes the data structures for this object out to a FILE in "*.brd" format.
|
|
|
|
* @param aFile The FILE to write to.
|
|
|
|
* @return bool - true if success writing else false.
|
|
|
|
*/
|
|
|
|
bool SCH_HIERLABEL::Save( FILE* aFile ) const
|
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
bool success = true;
|
|
|
|
const char* shape = "~";
|
|
|
|
|
|
|
|
if( m_Italic )
|
2008-12-19 20:40:08 +00:00
|
|
|
shape = "Italic";
|
|
|
|
if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
|
2009-05-05 17:32:07 +00:00
|
|
|
m_Pos.x, m_Pos.y,
|
2009-05-12 12:12:34 +00:00
|
|
|
m_SchematicOrientation, m_Size.x,
|
2009-05-05 17:32:07 +00:00
|
|
|
SheetLabelType[m_Shape],
|
2009-05-30 16:06:01 +00:00
|
|
|
shape, m_Width,
|
2009-05-05 17:32:07 +00:00
|
|
|
CONV_TO_UTF8( m_Text ) ) == EOF )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2009-01-31 18:08:47 +00:00
|
|
|
/************************************************/
|
|
|
|
bool SCH_HIERLABEL::HitTest( const wxPoint& aPosRef )
|
|
|
|
/************************************************/
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2009-01-31 18:08:47 +00:00
|
|
|
/** Function HitTest
|
|
|
|
* @return true if the point aPosRef is within item area
|
|
|
|
* @param aPosRef = a wxPoint to test
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
EDA_Rect rect = GetBoundingBox();
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2009-01-31 18:08:47 +00:00
|
|
|
return rect.Inside( aPosRef );
|
|
|
|
}
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/*********************************************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
void SCH_LABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
|
2009-05-05 17:32:07 +00:00
|
|
|
int DrawMode, int Color )
|
2007-09-13 11:28:58 +00:00
|
|
|
/*********************************************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_TEXT::Draw( panel, DC, offset, DrawMode, Color );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
/*******************************************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
|
2009-05-05 17:32:07 +00:00
|
|
|
int DrawMode, int Color )
|
2007-09-13 11:28:58 +00:00
|
|
|
/******************************************************************************************/
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/* Texts type Global Label have 4 directions, and the Text origin is the graphic icon
|
2007-09-01 12:00:30 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
static std::vector <wxPoint> Poly;
|
2008-12-14 19:45:05 +00:00
|
|
|
EDA_Colors color;
|
2009-06-02 07:26:49 +00:00
|
|
|
int linewidth = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
|
|
|
|
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
|
2008-02-20 19:37:17 +00:00
|
|
|
|
|
|
|
if( Color >= 0 )
|
2009-05-05 17:32:07 +00:00
|
|
|
color = (EDA_Colors) Color;
|
2008-02-20 19:37:17 +00:00
|
|
|
else
|
|
|
|
color = ReturnLayerColor( m_Layer );
|
|
|
|
|
|
|
|
GRSetDrawMode( DC, DrawMode );
|
|
|
|
|
2009-06-02 07:26:49 +00:00
|
|
|
EXCHG( linewidth, m_Width ); // Set the minimum width
|
|
|
|
wxPoint text_offset = offset + GetSchematicTextOffset();
|
2009-05-12 12:12:34 +00:00
|
|
|
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
|
2009-06-02 07:26:49 +00:00
|
|
|
EXCHG( linewidth, m_Width ); // set initial value
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
CreateGraphicShape( Poly, m_Pos + offset );
|
2009-06-02 07:26:49 +00:00
|
|
|
GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
if( m_IsDangling )
|
|
|
|
DrawDanglingSymbol( panel, DC, m_Pos + offset, color );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2008-02-20 19:37:17 +00:00
|
|
|
|
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
/** Function CreateGraphicShape
|
2008-12-29 18:02:54 +00:00
|
|
|
* calculates the graphic shape (a polygon) associated to the text
|
2009-05-12 12:12:34 +00:00
|
|
|
* @param aCorner_list = a buffer to fill with polygon corners coordinates
|
2008-02-20 19:37:17 +00:00
|
|
|
* @param Pos = Postion of the shape
|
|
|
|
*/
|
2009-05-05 17:32:07 +00:00
|
|
|
void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos )
|
2008-02-20 19:37:17 +00:00
|
|
|
{
|
2009-05-12 12:12:34 +00:00
|
|
|
int* Template = TemplateShape[m_Shape][m_SchematicOrientation];
|
2008-02-20 19:37:17 +00:00
|
|
|
int HalfSize = m_Size.x / 2;
|
|
|
|
|
|
|
|
int imax = *Template; Template++;
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
aCorner_list.clear();
|
2008-02-20 19:37:17 +00:00
|
|
|
for( int ii = 0; ii < imax; ii++ )
|
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
wxPoint corner;
|
|
|
|
corner.x = ( HalfSize * (*Template) ) + Pos.x;
|
2008-12-29 18:02:54 +00:00
|
|
|
Template++;
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
corner.y = ( HalfSize * (*Template) ) + Pos.y;
|
2008-12-29 18:02:54 +00:00
|
|
|
Template++;
|
2009-05-05 17:32:07 +00:00
|
|
|
|
|
|
|
aCorner_list.push_back( corner );
|
2008-02-20 19:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2009-01-31 18:08:47 +00:00
|
|
|
/****************************************/
|
2008-03-30 09:27:53 +00:00
|
|
|
EDA_Rect SCH_HIERLABEL::GetBoundingBox()
|
2009-01-31 18:08:47 +00:00
|
|
|
/****************************************/
|
2008-03-30 09:27:53 +00:00
|
|
|
{
|
2008-03-30 10:47:03 +00:00
|
|
|
int x, y, dx, dy, length, height;
|
2008-03-30 09:27:53 +00:00
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
x = m_Pos.x;
|
|
|
|
y = m_Pos.y;
|
2008-03-30 11:48:18 +00:00
|
|
|
dx = dy = 0;
|
2008-03-30 09:27:53 +00:00
|
|
|
|
2009-06-02 07:26:49 +00:00
|
|
|
int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
|
2009-05-29 15:45:13 +00:00
|
|
|
height = m_Size.y + width + 2 * TXTMARGE;
|
2009-05-28 17:39:40 +00:00
|
|
|
length = LenSize( m_Text )
|
2009-05-12 12:12:34 +00:00
|
|
|
+ height // add height for triangular shapes
|
|
|
|
+ 2 * DANGLING_SYMBOL_SIZE;
|
2008-03-30 09:27:53 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
switch( m_SchematicOrientation ) // respect orientation
|
2008-03-30 09:27:53 +00:00
|
|
|
{
|
2009-05-12 12:12:34 +00:00
|
|
|
case 0: /* Horiz Normal Orientation (left justified) */
|
2009-05-05 17:32:07 +00:00
|
|
|
dx = -length;
|
|
|
|
dy = height;
|
|
|
|
x += DANGLING_SYMBOL_SIZE;
|
|
|
|
y -= height / 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* Vert Orientation UP */
|
|
|
|
dx = height;
|
2009-05-12 12:12:34 +00:00
|
|
|
dy = -length;
|
2009-05-05 17:32:07 +00:00
|
|
|
x -= height / 2;
|
2009-05-12 12:12:34 +00:00
|
|
|
y += DANGLING_SYMBOL_SIZE;
|
2009-05-05 17:32:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* Horiz Orientation - Right justified */
|
|
|
|
dx = length;
|
|
|
|
dy = height;
|
|
|
|
x -= DANGLING_SYMBOL_SIZE;
|
|
|
|
y -= height / 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* Vert Orientation BOTTOM */
|
|
|
|
dx = height;
|
2009-05-12 12:12:34 +00:00
|
|
|
dy = length;
|
2009-05-05 17:32:07 +00:00
|
|
|
x -= height / 2;
|
2009-05-12 12:12:34 +00:00
|
|
|
y -= DANGLING_SYMBOL_SIZE;
|
2009-05-05 17:32:07 +00:00
|
|
|
break;
|
2008-03-30 09:27:53 +00:00
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
EDA_Rect box( wxPoint( x, y ), wxSize( dx, dy ) );
|
2008-03-30 09:27:53 +00:00
|
|
|
box.Normalize();
|
|
|
|
return box;
|
|
|
|
}
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/*******************************************************************************************/
|
2009-05-12 12:12:34 +00:00
|
|
|
void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset,
|
2009-05-05 17:32:07 +00:00
|
|
|
int DrawMode, int Color )
|
2008-02-12 21:12:46 +00:00
|
|
|
/******************************************************************************************/
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
/* Texts type Global Label have 4 directions, and the Text origin is the graphic icon
|
|
|
|
*/
|
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
static std::vector <wxPoint> Poly;
|
2008-12-14 19:45:05 +00:00
|
|
|
EDA_Colors color;
|
2009-05-12 12:12:34 +00:00
|
|
|
wxPoint text_offset = aOffset + GetSchematicTextOffset();
|
2008-02-20 19:37:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
if( Color >= 0 )
|
2009-05-05 17:32:07 +00:00
|
|
|
color = (EDA_Colors) Color;
|
2008-02-20 19:37:17 +00:00
|
|
|
else
|
|
|
|
color = ReturnLayerColor( m_Layer );
|
|
|
|
|
|
|
|
GRSetDrawMode( DC, DrawMode );
|
|
|
|
|
2009-06-02 07:26:49 +00:00
|
|
|
int linewidth = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
|
|
|
|
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
|
|
|
|
EXCHG( linewidth, m_Width ); // Set the minimum width
|
2009-05-12 12:12:34 +00:00
|
|
|
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
|
2009-06-02 07:26:49 +00:00
|
|
|
EXCHG( linewidth, m_Width ); // set initial value
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
CreateGraphicShape( Poly, m_Pos + aOffset );
|
2009-06-02 07:26:49 +00:00
|
|
|
GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
|
2008-02-20 19:37:17 +00:00
|
|
|
|
|
|
|
if( m_IsDangling )
|
2009-05-12 12:12:34 +00:00
|
|
|
DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
|
2008-02-20 19:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** function CreateGraphicShape
|
|
|
|
* Calculates the graphic shape (a polygon) associated to the text
|
2009-05-12 12:12:34 +00:00
|
|
|
* @param aCorner_list = a buffer to fill with polygon corners coordinates
|
2009-05-05 17:32:07 +00:00
|
|
|
* @param Pos = Position of the shape
|
2008-02-20 19:37:17 +00:00
|
|
|
*/
|
2009-05-05 17:32:07 +00:00
|
|
|
void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos )
|
2008-02-20 19:37:17 +00:00
|
|
|
{
|
2009-06-02 07:26:49 +00:00
|
|
|
int HalfSize = m_Size.y / 2;
|
|
|
|
int linewidth = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
|
|
|
|
|
|
|
|
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
|
2009-05-05 17:32:07 +00:00
|
|
|
|
|
|
|
aCorner_list.clear();
|
2008-02-20 19:37:17 +00:00
|
|
|
|
2009-05-28 17:39:40 +00:00
|
|
|
int symb_len = LenSize( m_Text ) + (TXTMARGE * 2);
|
2008-02-20 19:37:17 +00:00
|
|
|
|
|
|
|
// Create outline shape : 6 points
|
2009-06-02 07:26:49 +00:00
|
|
|
int x = symb_len + linewidth + 3;
|
|
|
|
int y = wxRound( (double) HalfSize * 1.5 + (double) linewidth + 3.0 ); // 50% more for negation bar
|
|
|
|
aCorner_list.push_back( wxPoint( 0, 0 ) ); // Starting point (anchor)
|
|
|
|
aCorner_list.push_back( wxPoint( 0, -y ) ); // Up
|
|
|
|
aCorner_list.push_back( wxPoint( -x, -y ) ); // left Up
|
|
|
|
aCorner_list.push_back( wxPoint( -x, 0 ) ); // left
|
|
|
|
aCorner_list.push_back( wxPoint( -x, y ) ); // left down
|
|
|
|
aCorner_list.push_back( wxPoint( 0, y ) ); // down
|
2008-02-20 19:37:17 +00:00
|
|
|
|
|
|
|
int x_offset = 0;
|
|
|
|
|
|
|
|
switch( m_Shape )
|
|
|
|
{
|
|
|
|
case NET_INPUT:
|
|
|
|
x_offset = -HalfSize;
|
2009-05-05 17:32:07 +00:00
|
|
|
aCorner_list[0].x += HalfSize;
|
2008-02-20 19:37:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_OUTPUT:
|
2009-05-05 17:32:07 +00:00
|
|
|
aCorner_list[3].x -= HalfSize;
|
2008-02-20 19:37:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_BIDI:
|
|
|
|
case NET_TRISTATE:
|
|
|
|
x_offset = -HalfSize;
|
2009-05-05 17:32:07 +00:00
|
|
|
aCorner_list[0].x += HalfSize;
|
|
|
|
aCorner_list[3].x -= HalfSize;
|
2008-02-20 19:37:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_UNSPECIFIED:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
int angle = 0;
|
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
switch( m_SchematicOrientation )
|
2008-02-20 19:37:17 +00:00
|
|
|
{
|
|
|
|
case 0: /* Orientation horiz normale */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* Orientation vert UP */
|
2009-05-12 12:12:34 +00:00
|
|
|
angle = -900;
|
2008-02-20 19:37:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* Orientation horiz inverse */
|
|
|
|
angle = 1800;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* Orientation vert BOTTOM */
|
2009-05-12 12:12:34 +00:00
|
|
|
angle = 900;
|
2008-02-20 19:37:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
// Rotate outlines and move corners in real position
|
2009-05-12 12:12:34 +00:00
|
|
|
for( unsigned ii = 0; ii < aCorner_list.size(); ii++ )
|
2008-02-20 19:37:17 +00:00
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
aCorner_list[ii].x += x_offset;
|
2008-02-20 19:37:17 +00:00
|
|
|
if( angle )
|
2009-05-05 17:32:07 +00:00
|
|
|
RotatePoint( &aCorner_list[ii], angle );
|
|
|
|
aCorner_list[ii] += Pos;
|
2008-02-20 19:37:17 +00:00
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
aCorner_list.push_back( aCorner_list[0] ); // closing
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2008-03-27 21:24:50 +00:00
|
|
|
|
|
|
|
|
2009-01-31 18:08:47 +00:00
|
|
|
/******************************************/
|
2008-03-30 09:27:53 +00:00
|
|
|
EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
|
2009-01-31 18:08:47 +00:00
|
|
|
/******************************************/
|
2008-03-30 09:27:53 +00:00
|
|
|
{
|
2008-03-30 10:47:03 +00:00
|
|
|
int x, y, dx, dy, length, height;
|
2008-03-30 09:27:53 +00:00
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
x = m_Pos.x;
|
|
|
|
y = m_Pos.y;
|
2008-03-30 11:48:18 +00:00
|
|
|
dx = dy = 0;
|
2008-03-30 09:27:53 +00:00
|
|
|
|
2009-06-02 07:26:49 +00:00
|
|
|
int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
|
2009-05-12 12:12:34 +00:00
|
|
|
height = ( (m_Size.y * 15) / 10 ) + width + 2 * TXTMARGE;
|
2009-05-05 17:32:07 +00:00
|
|
|
length =
|
2009-06-02 07:26:49 +00:00
|
|
|
LenSize( m_Text ) // text X size
|
2009-05-12 12:12:34 +00:00
|
|
|
+ height // add height for triangular shapes (bidirectional)
|
|
|
|
+ DANGLING_SYMBOL_SIZE;
|
2008-03-30 09:27:53 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
switch( m_SchematicOrientation ) // respect orientation
|
2008-03-30 09:27:53 +00:00
|
|
|
{
|
2009-05-12 12:12:34 +00:00
|
|
|
case 0: /* Horiz Normal Orientation (left justified) */
|
2009-05-05 17:32:07 +00:00
|
|
|
dx = -length;
|
|
|
|
dy = height;
|
|
|
|
x += DANGLING_SYMBOL_SIZE;
|
|
|
|
y -= height / 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* Vert Orientation UP */
|
|
|
|
dx = height;
|
2009-05-12 12:12:34 +00:00
|
|
|
dy = -length;
|
2009-05-05 17:32:07 +00:00
|
|
|
x -= height / 2;
|
2009-05-12 12:12:34 +00:00
|
|
|
y += DANGLING_SYMBOL_SIZE;
|
2009-05-05 17:32:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* Horiz Orientation - Right justified */
|
|
|
|
dx = length;
|
|
|
|
dy = height;
|
|
|
|
x -= DANGLING_SYMBOL_SIZE;
|
|
|
|
y -= height / 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* Vert Orientation BOTTOM */
|
|
|
|
dx = height;
|
2009-05-12 12:12:34 +00:00
|
|
|
dy = length;
|
2009-05-05 17:32:07 +00:00
|
|
|
x -= height / 2;
|
2009-05-12 12:12:34 +00:00
|
|
|
y -= DANGLING_SYMBOL_SIZE;
|
2009-05-05 17:32:07 +00:00
|
|
|
break;
|
2008-03-30 09:27:53 +00:00
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
EDA_Rect box( wxPoint( x, y ), wxSize( dx, dy ) );
|
2008-03-30 09:27:53 +00:00
|
|
|
box.Normalize();
|
|
|
|
return box;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-31 18:08:47 +00:00
|
|
|
/***********************************/
|
2008-03-27 21:24:50 +00:00
|
|
|
EDA_Rect SCH_TEXT::GetBoundingBox()
|
2009-01-31 18:08:47 +00:00
|
|
|
/***********************************/
|
2008-03-27 21:24:50 +00:00
|
|
|
{
|
2008-03-30 10:47:03 +00:00
|
|
|
int x, y, dx, dy, length, height;
|
2008-03-27 21:24:50 +00:00
|
|
|
|
|
|
|
x = m_Pos.x;
|
|
|
|
y = m_Pos.y;
|
2009-06-02 07:26:49 +00:00
|
|
|
int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
|
2009-05-28 17:39:40 +00:00
|
|
|
length = LenSize( m_Text );
|
2009-05-29 15:45:13 +00:00
|
|
|
height = m_Size.y + width;
|
2009-05-05 17:32:07 +00:00
|
|
|
dx = dy = 0;
|
2008-03-27 21:24:50 +00:00
|
|
|
|
2009-05-12 12:12:34 +00:00
|
|
|
switch( m_SchematicOrientation )
|
2008-03-27 21:24:50 +00:00
|
|
|
{
|
2009-05-05 17:32:07 +00:00
|
|
|
case 0: /* Horiz Normal Orientation (left justified) */
|
|
|
|
dx = 2 * DANGLING_SYMBOL_SIZE + length;
|
|
|
|
dy = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE;
|
|
|
|
x -= DANGLING_SYMBOL_SIZE;
|
|
|
|
y += DANGLING_SYMBOL_SIZE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* Vert Orientation UP */
|
|
|
|
dx = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE;
|
|
|
|
dy = -2 * DANGLING_SYMBOL_SIZE - length;
|
|
|
|
x += DANGLING_SYMBOL_SIZE;
|
|
|
|
y += DANGLING_SYMBOL_SIZE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* Horiz Orientation - Right justified */
|
|
|
|
dx = -2 * DANGLING_SYMBOL_SIZE - length;
|
|
|
|
dy = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE;
|
|
|
|
x += DANGLING_SYMBOL_SIZE;
|
|
|
|
y += DANGLING_SYMBOL_SIZE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* Vert Orientation BOTTOM */
|
|
|
|
dx = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE;
|
|
|
|
dy = 2 * DANGLING_SYMBOL_SIZE + length;
|
|
|
|
x += DANGLING_SYMBOL_SIZE;
|
|
|
|
y -= DANGLING_SYMBOL_SIZE;
|
|
|
|
break;
|
2008-03-27 21:24:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-05 17:32:07 +00:00
|
|
|
EDA_Rect box( wxPoint( x, y ), wxSize( dx, dy ) );
|
2008-03-27 21:24:50 +00:00
|
|
|
box.Normalize();
|
|
|
|
return box;
|
|
|
|
}
|