Commit 5759f734 authored by charras's avatar charras

Rework on TEXTE_PCB, SCH_TEXT and EDA_TextStruct classes.

Code seriously cleaned, obscure and duplicated code removed, and some oddities removed.
Better support of multiline texts.
parent 804e5397
...@@ -4,6 +4,17 @@ KiCad ChangeLog 2009 ...@@ -4,6 +4,17 @@ KiCad ChangeLog 2009
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2009-may-12 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++All:
Rework on TEXTE_PCB, SCH_TEXT and EDA_TextStruct classes.
Code seriously cleaned, obscure and duplicated code removed,
and some oddities removed ( like different .m_Orient values in eeschema and
pcbnew, for the same text orientation )
Multiline texts (in comments and Pcb texts) are now supported.
In pcbnew text justifications could work (but not yet used and tested)
2009-may-01 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> 2009-may-01 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================ ================================================================================
++pcbnew: ++pcbnew:
......
...@@ -254,8 +254,8 @@ EDA_Rect EDA_TextStruct::GetTextBox( int aLine ) ...@@ -254,8 +254,8 @@ EDA_Rect EDA_TextStruct::GetTextBox( int aLine )
rect.SetSize( textsize ); rect.SetSize( textsize );
/* Now, calculate the rect origin, according to text justification /* Now, calculate the rect origin, according to text justification
* At this point the area origin is the text origin. * At this point the area origin is the text origin (m_Pos).
* This is true only for left and top text justified. * This is true only for left and top text justified texts.
* and must be recalculated for others justifications * and must be recalculated for others justifications
* also, note the V justification is relative to the first line * also, note the V justification is relative to the first line
*/ */
...@@ -284,7 +284,7 @@ EDA_Rect EDA_TextStruct::GetTextBox( int aLine ) ...@@ -284,7 +284,7 @@ EDA_Rect EDA_TextStruct::GetTextBox( int aLine )
break; break;
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_VJUSTIFY_BOTTOM:
rect.SetY( rect.GetY() + (dy / 2) ); rect.SetY( rect.GetY() - dy );
break; break;
} }
......
...@@ -20,6 +20,14 @@ ...@@ -20,6 +20,14 @@
#define EDA_DRAWBASE #define EDA_DRAWBASE
#include "grfonte.h" #include "grfonte.h"
/* Functions to draw / plot a string.
* texts have only one line.
* They can be in italic.
* Horizontal and Vertical justification are handled.
* Texts can be rotated
* substrings between ~ markers can be "negated" (i.e. with an over bar
*/
/** Function NegableTextLength /** Function NegableTextLength
* Return the text length of a negable string, excluding the ~ markers */ * Return the text length of a negable string, excluding the ~ markers */
int NegableTextLength( const wxString& aText ) int NegableTextLength( const wxString& aText )
...@@ -48,7 +56,7 @@ static void DrawGraphicTextPline( ...@@ -48,7 +56,7 @@ static void DrawGraphicTextPline(
bool sketch_mode, bool sketch_mode,
int point_count, int point_count,
wxPoint* coord, wxPoint* coord,
void (* aCallback)(int x0, int y0, int xf, int yf) ) void (*aCallback)( int x0, int y0, int xf, int yf ) )
{ {
if( aCallback ) if( aCallback )
{ {
...@@ -107,7 +115,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -107,7 +115,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
int aWidth, int aWidth,
bool aItalic, bool aItalic,
bool aNegable, bool aNegable,
void (* aCallback)(int x0, int y0, int xf, int yf) ) void (*aCallback)( int x0, int y0, int xf, int yf ) )
/****************************************************************************************************/ /****************************************************************************************************/
{ {
int char_count, AsciiCode; int char_count, AsciiCode;
...@@ -116,10 +124,9 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -116,10 +124,9 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
SH_CODE f_cod, plume = 'U'; SH_CODE f_cod, plume = 'U';
const SH_CODE* ptcar; const SH_CODE* ptcar;
int ptr; int ptr;
int ux0, uy0, dx, dy; // Draw coordinate for segments to draw. also used in some other calculation int dx, dy; // Draw coordinate for segments to draw. also used in some other calculation
int cX, cY; // Texte center wxPoint current_char_pos; // Draw coordinates for the current char
int ox, oy; // Draw coordinates for the current char wxPoint overbar_pos; // Start point for the current overbar
int overbar_x, overbar_y; // Start point for the current overbar
int overbars; // Number of ~ seen int overbars; // Number of ~ seen
#define BUF_SIZE 100 #define BUF_SIZE 100
...@@ -156,8 +163,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -156,8 +163,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
else else
pitch -= thickness; pitch -= thickness;
ox = cX = aPos.x; current_char_pos = aPos;
oy = cY = aPos.y;
/* Do not draw the text if out of draw area! */ /* Do not draw the text if out of draw area! */
if( aPanel ) if( aPanel )
...@@ -166,8 +172,8 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -166,8 +172,8 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
int textsize = ABS( pitch ); int textsize = ABS( pitch );
ll = aPanel->GetScreen()->Scale( textsize * char_count ); ll = aPanel->GetScreen()->Scale( textsize * char_count );
xc = GRMapX( cX ); xc = GRMapX( current_char_pos.x );
yc = GRMapY( cY ); yc = GRMapY( current_char_pos.y );
x0 = aPanel->m_ClipBox.GetX() - ll; x0 = aPanel->m_ClipBox.GetX() - ll;
y0 = aPanel->m_ClipBox.GetY() - ll; y0 = aPanel->m_ClipBox.GetY() - ll;
...@@ -185,81 +191,60 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -185,81 +191,60 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
} }
/* Compute the position ux0, uy0 of the first letter , next */ /* Compute the position of the first letter of the text
dx = (pitch * char_count) / 2; * this position is the position of the left bottom point of the letter
dy = size_v / 2; /* dx, dy = draw offset between first letter and text center */ * this is the same as the text position only for a left and bottom justified text
* In others cases, this position must be calculated from the text position ans size
ux0 = uy0 = 0; /* for ux0 = uy0 = 0, the text is centered */ */
dx = pitch * char_count;
wxPoint offset_org( dx, dy ); dy = size_v; /* dx, dy = draw offset between first letter and text center */
int irot = aOrient;
while( irot >= 1800 )
irot -= 1800;
while( irot < 0 )
irot += 1800;
if( irot != 0 )
EXCHG( offset_org.x, offset_org.y );
switch( aH_justify ) switch( aH_justify )
{ {
case GR_TEXT_HJUSTIFY_CENTER: case GR_TEXT_HJUSTIFY_CENTER:
current_char_pos.x -= dx / 2;
break; break;
case GR_TEXT_HJUSTIFY_RIGHT: case GR_TEXT_HJUSTIFY_RIGHT:
ux0 = -offset_org.x; current_char_pos.x -= dx;
break; break;
case GR_TEXT_HJUSTIFY_LEFT: case GR_TEXT_HJUSTIFY_LEFT:
ux0 = offset_org.x;
break; break;
} }
switch( aV_justify ) switch( aV_justify )
{ {
case GR_TEXT_VJUSTIFY_CENTER: case GR_TEXT_VJUSTIFY_CENTER:
current_char_pos.y += dy/2;
break; break;
case GR_TEXT_VJUSTIFY_TOP: case GR_TEXT_VJUSTIFY_TOP:
uy0 = offset_org.y; current_char_pos.y += dy;
break; break;
case GR_TEXT_VJUSTIFY_BOTTOM: case GR_TEXT_VJUSTIFY_BOTTOM:
uy0 = -offset_org.y;
break; break;
} }
cX += ux0;
cY += uy0;
ox = cX - dx;
oy = cY + dy;
// Note: if aPanel == NULL, we are using a GL Canvas that handle scaling // Note: if aPanel == NULL, we are using a GL Canvas that handle scaling
if( aPanel && aPanel->GetScreen()->Scale( aSize.x ) == 0 ) if( aPanel && aPanel->GetScreen()->Scale( aSize.x ) == 0 )
return; return;
if( aPanel && ABS( ( aPanel->GetScreen()->Scale( aSize.x ) ) ) < 3 ) /* shapes are too small: connot be drawn */ /* if a text size is too small, the text cannot be drawn, and it is drawn as a single graphic line */
if( aPanel && ABS( ( aPanel->GetScreen()->Scale( aSize.x ) ) ) < 3 )
{ {
/* insteed the text is drawn as a line */ /* draw the text as a line always vertically centered */
dx = (pitch * char_count) / 2; wxPoint end( current_char_pos.x + dx, current_char_pos.y);
dy = size_v / 2; /* line is always centered */
ux0 = cX - dx;
uy0 = cY;
dx += cX;
dy = cY;
RotatePoint( &ux0, &uy0, cX, cY, aOrient ); RotatePoint( &current_char_pos, aPos, aOrient );
RotatePoint( &dx, &dy, cX, cY, aOrient ); RotatePoint( &end, aPos, aOrient );
if( aCallback ) if( aCallback )
aCallback( ux0, uy0, dx, dy ); aCallback( current_char_pos.x, current_char_pos.y, end.x, end.y );
else else
GRLine( &aPanel->m_ClipBox, aDC, ux0, uy0, dx, dy, aWidth, aColor ); GRLine( &aPanel->m_ClipBox, aDC,
current_char_pos.x, current_char_pos.y, end.x, end.y , aWidth, aColor );
return; return;
} }
...@@ -278,20 +263,18 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -278,20 +263,18 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
if( overbars % 2 ) if( overbars % 2 )
{ {
/* Starting the overbar */ /* Starting the overbar */
overbar_x = ox; overbar_pos = current_char_pos;
overbar_y = oy - overbar_position( size_v, thickness ); overbar_pos.y -= overbar_position( size_v, thickness );
RotatePoint( &overbar_x, &overbar_y, cX, cY, aOrient ); RotatePoint( &overbar_pos, aPos, aOrient );
} }
else else
{ {
/* Ending the overbar */ /* Ending the overbar */
coord[0].x = overbar_x; coord[0] = overbar_pos;
coord[0].y = overbar_y; overbar_pos = current_char_pos;
overbar_x = ox; overbar_pos.y -= overbar_position( size_v, thickness );
overbar_y = oy - overbar_position( size_v, thickness ); RotatePoint( &overbar_pos, aPos, aOrient );
RotatePoint( &overbar_x, &overbar_y, cX, cY, aOrient ); coord[1] = overbar_pos;
coord[1].x = overbar_x;
coord[1].y = overbar_y;
/* Plot the overbar segment */ /* Plot the overbar segment */
DrawGraphicTextPline( aPanel, aDC, aColor, aWidth, DrawGraphicTextPline( aPanel, aDC, aColor, aWidth,
sketch_mode, 2, coord, aCallback ); sketch_mode, 2, coord, aCallback );
...@@ -345,6 +328,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -345,6 +328,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
default: default:
{ {
int y, k1, k2; int y, k1, k2;
wxPoint currpoint;
y = k1 = f_cod; /* trace sur axe V */ y = k1 = f_cod; /* trace sur axe V */
k1 = -( (k1 * size_v) / 9 ); k1 = -( (k1 * size_v) / 9 );
...@@ -357,11 +341,11 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -357,11 +341,11 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
// To simulate an italic font, add a x offset depending on the y offset // To simulate an italic font, add a x offset depending on the y offset
if( aItalic ) if( aItalic )
k2 -= italic_reverse ? -k1 / 8 : k1 / 8; k2 -= italic_reverse ? -k1 / 8 : k1 / 8;
dx = k2 + ox; dy = k1 + oy; currpoint.x = k2 + current_char_pos.x;
currpoint.y = k1 + current_char_pos.y;
RotatePoint( &dx, &dy, cX, cY, aOrient ); RotatePoint( &currpoint, aPos, aOrient );
coord[point_count].x = dx; coord[point_count] = currpoint;
coord[point_count].y = dy;
if( point_count < BUF_SIZE - 1 ) if( point_count < BUF_SIZE - 1 )
point_count++; point_count++;
break; break;
...@@ -373,19 +357,18 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, ...@@ -373,19 +357,18 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
/* end draw 1 char */ /* end draw 1 char */
ptr++; ox += pitch; ptr++;
current_char_pos.x += pitch; // current_char_pos is now the next position
} }
if( overbars % 2 ) if( overbars % 2 )
{ {
/* Close the last overbar */ /* Close the last overbar */
coord[0].x = overbar_x; coord[0] = overbar_pos;
coord[0].y = overbar_y; overbar_pos = current_char_pos;
overbar_x = ox; overbar_pos.y -= overbar_position( size_v, thickness );
overbar_y = oy - overbar_position( size_v, thickness ); RotatePoint( &overbar_pos, aPos, aOrient );
RotatePoint( &overbar_x, &overbar_y, cX, cY, aOrient ); coord[1] = overbar_pos;
coord[1].x = overbar_x;
coord[1].y = overbar_y;
/* Plot the overbar segment */ /* Plot the overbar segment */
DrawGraphicTextPline( aPanel, aDC, aColor, aWidth, DrawGraphicTextPline( aPanel, aDC, aColor, aWidth,
sketch_mode, 2, coord, aCallback ); sketch_mode, 2, coord, aCallback );
......
This diff is collapsed.
This diff is collapsed.
...@@ -8,28 +8,37 @@ ...@@ -8,28 +8,37 @@
#include "macros.h" #include "macros.h"
#include "base_struct.h" #include "base_struct.h"
/* Type des labels sur sheet (Labels sur hierarchie) et forme des Global-Labels*/ /* Type of SCH_HIERLABEL and SCH_GLOBALLABEL
* mainly used to handle the graphic associated shape
*/
typedef enum { typedef enum {
NET_INPUT, NET_INPUT,
NET_OUTPUT, NET_OUTPUT,
NET_BIDI, NET_BIDI,
NET_TRISTATE, NET_TRISTATE,
NET_UNSPECIFIED, NET_UNSPECIFIED,
NET_TMAX /* Derniere valeur: fin de tableau */ NET_TMAX /* Last value */
} TypeSheetLabel; } TypeSheetLabel;
/* Messages correspondants aux types ou forme des labels */
extern const char* SheetLabelType[];
extern int* TemplateShape[5][4];
class SCH_TEXT : public SCH_ITEM extern const char* SheetLabelType[]; /* names of types of labels */
, public EDA_TextStruct
{
class SCH_TEXT : public SCH_ITEM,
public EDA_TextStruct
{
public: public:
int m_Layer; int m_Layer;
int m_Shape; int m_Shape;
bool m_IsDangling; // TRUE if not connected bool m_IsDangling; // true if not connected (used to draw the "not connected" symbol
protected:
int m_SchematicOrientation; /* orientation of texts (comments) and labels in schematic
* 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
* this is perhaps a duplicate of m_Orient and m_HJustified or m_VJustified,
* but is more easy to handle that 3 parmeters in editions, Reading and Saving file
*/
public: public:
...@@ -43,6 +52,27 @@ public: ...@@ -43,6 +52,27 @@ public:
} }
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation (for a text )
* 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
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
int GetSchematicTextOrientation() { return m_SchematicOrientation;}
/** 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)
*/
virtual wxPoint GetSchematicTextOffset( );
SCH_TEXT* GenCopy(); SCH_TEXT* GenCopy();
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 ); int Color = -1 );
...@@ -71,9 +101,6 @@ public: ...@@ -71,9 +101,6 @@ public:
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
}; };
...@@ -90,6 +117,26 @@ public: ...@@ -90,6 +117,26 @@ public:
return wxT( "SCH_LABEL" ); return wxT( "SCH_LABEL" );
} }
/** 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
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
/** 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)
*/
virtual wxPoint GetSchematicTextOffset( );
/** /**
* Function Save * Function Save
* writes the data structures for this object out to a FILE in "*.brd" format. * writes the data structures for this object out to a FILE in "*.brd" format.
...@@ -115,6 +162,25 @@ public: ...@@ -115,6 +162,25 @@ public:
} }
/** 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
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
/** 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)
*/
virtual wxPoint GetSchematicTextOffset( );
/** /**
* Function Save * Function Save
* writes the data structures for this object out to a FILE in "*.brd" format. * writes the data structures for this object out to a FILE in "*.brd" format.
...@@ -133,17 +199,13 @@ public: ...@@ -133,17 +199,13 @@ public:
/** function CreateGraphicShape /** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text * Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = coordinates list fill with polygon corners ooordinates * @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Postion of the shape * @param Pos = Position of the shape
* format list is
* <corner_count>, x0, y0, ... xn, yn
*/ */
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint & Pos ); void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos );
}; };
class SCH_HIERLABEL : public SCH_TEXT class SCH_HIERLABEL : public SCH_TEXT
{ {
public: public:
...@@ -159,14 +221,31 @@ public: ...@@ -159,14 +221,31 @@ public:
} }
/** 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
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
/** 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)
*/
virtual wxPoint GetSchematicTextOffset( );
/** function CreateGraphicShape /** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text * Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = coordinates list fill with polygon corners ooordinates * @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Postion of the shape * @param Pos = Postion of the shape
* format list is
* <corner_count>, x0, y0, ... xn, yn
*/ */
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint & Pos ); void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos );
/** /**
* Function Save * Function Save
......
...@@ -21,20 +21,7 @@ ...@@ -21,20 +21,7 @@
int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText ) int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText )
{ {
int ret; int ret;
bool multiline; bool multiline = CurrentText->m_MultilineAllowed;
switch( CurrentText->Type() )
{
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_LABEL:
multiline = false;
break;
default:
multiline = true;
break;
}
DialogLabelEditor* dialog = new DialogLabelEditor( parent, CurrentText, multiline ); DialogLabelEditor* dialog = new DialogLabelEditor( parent, CurrentText, multiline );
...@@ -97,7 +84,7 @@ void DialogLabelEditor::init() ...@@ -97,7 +84,7 @@ void DialogLabelEditor::init()
EnsureTextCtrlWidth( m_TextLabel ); EnsureTextCtrlWidth( m_TextLabel );
// Set validators // Set validators
m_TextOrient->SetSelection( m_CurrentText->m_Orient ); m_TextOrient->SetSelection( m_CurrentText->GetSchematicTextOrientation() );
m_TextShape->SetSelection( m_CurrentText->m_Shape ); m_TextShape->SetSelection( m_CurrentText->m_Shape );
int style = 0; int style = 0;
......
...@@ -525,6 +525,13 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel() ...@@ -525,6 +525,13 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
else else
m_FieldHJustifyCtrl->SetSelection(1); m_FieldHJustifyCtrl->SetSelection(1);
if( field.m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
m_FieldVJustifyCtrl->SetSelection(0);
else if( field.m_VJustify == GR_TEXT_VJUSTIFY_TOP )
m_FieldVJustifyCtrl->SetSelection(2);
else
m_FieldVJustifyCtrl->SetSelection(1);
fieldNameTextCtrl->SetValue( field.m_Name ); fieldNameTextCtrl->SetValue( field.m_Name );
// if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable filed name editing // if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable filed name editing
...@@ -605,16 +612,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField() ...@@ -605,16 +612,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
field.m_HJustify = hjustify[m_FieldHJustifyCtrl->GetSelection()]; field.m_HJustify = hjustify[m_FieldHJustifyCtrl->GetSelection()];
field.m_VJustify = vjustify[m_FieldVJustifyCtrl->GetSelection()]; field.m_VJustify = vjustify[m_FieldVJustifyCtrl->GetSelection()];
if( field.m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) /* Void fields texts for REFERENCE and VALUE (value is the name of the component in lib ! ) are not allowed
m_FieldVJustifyCtrl->SetSelection(0);
else if( field.m_VJustify == GR_TEXT_VJUSTIFY_TOP )
m_FieldVJustifyCtrl->SetSelection(2);
else
m_FieldVJustifyCtrl->SetSelection(1);
rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT );
/* Void fields texts for REFERENCE and VALUE (value is the name of the compinent in lib ! ) are not allowed
* change them only for a new non void value * change them only for a new non void value
*/ */
if( !fieldValueTextCtrl->GetValue().IsEmpty() || fieldNdx > VALUE ) if( !fieldValueTextCtrl->GetValue().IsEmpty() || fieldNdx > VALUE )
......
...@@ -47,7 +47,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event ) ...@@ -47,7 +47,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
else if( (m_CurrentText->m_Flags & IS_NEW) == 0 ) else if( (m_CurrentText->m_Flags & IS_NEW) == 0 )
DisplayError( this, _( "Empty Text!" ) ); DisplayError( this, _( "Empty Text!" ) );
m_CurrentText->m_Orient = m_TextOrient->GetSelection(); m_CurrentText->SetSchematicTextOrientation( m_TextOrient->GetSelection() );
text = m_TextSize->GetValue(); text = m_TextSize->GetValue();
value = ReturnValueFromString( g_UnitMetric, text, m_Parent->m_InternalUnits ); value = ReturnValueFromString( g_UnitMetric, text, m_Parent->m_InternalUnits );
m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value; m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;
...@@ -101,7 +101,7 @@ void WinEDA_SchematicFrame::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC ) ...@@ -101,7 +101,7 @@ void WinEDA_SchematicFrame::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC )
case TYPE_SCH_TEXT: case TYPE_SCH_TEXT:
ItemInitialPosition = TextStruct->m_Pos; ItemInitialPosition = TextStruct->m_Pos;
OldSize = TextStruct->m_Size; OldSize = TextStruct->m_Size;
OldOrient = TextStruct->m_Orient; OldOrient = TextStruct->GetSchematicTextOrientation();
break; break;
default: default:
...@@ -163,14 +163,16 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC ) ...@@ -163,14 +163,16 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode ); RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode );
/* Rotation du texte */ /* Rotation du texte */
int orient;
switch( TextStruct->Type() ) switch( TextStruct->Type() )
{ {
case TYPE_SCH_LABEL: case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL: case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
case TYPE_SCH_TEXT: case TYPE_SCH_TEXT:
TextStruct->m_Orient++; orient = TextStruct->GetSchematicTextOrientation() + 1;
TextStruct->m_Orient &= 3; orient &= 3;
TextStruct->SetSchematicTextOrientation( orient );
break; break;
default: default:
...@@ -209,13 +211,13 @@ SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type ) ...@@ -209,13 +211,13 @@ SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
case LAYER_HIERLABEL: case LAYER_HIERLABEL:
NewText = new SCH_HIERLABEL( GetScreen()->m_Curseur ); NewText = new SCH_HIERLABEL( GetScreen()->m_Curseur );
NewText->m_Shape = s_DefaultShapeGLabel; NewText->m_Shape = s_DefaultShapeGLabel;
NewText->m_Orient = s_DefaultOrientGLabel; NewText->SetSchematicTextOrientation( s_DefaultOrientGLabel );
break; break;
case LAYER_GLOBLABEL: case LAYER_GLOBLABEL:
NewText = new SCH_GLOBALLABEL( GetScreen()->m_Curseur ); NewText = new SCH_GLOBALLABEL( GetScreen()->m_Curseur );
NewText->m_Shape = s_DefaultShapeGLabel; NewText->m_Shape = s_DefaultShapeGLabel;
NewText->m_Orient = s_DefaultOrientGLabel; NewText->SetSchematicTextOrientation( s_DefaultOrientGLabel );
break; break;
default: default:
...@@ -238,7 +240,7 @@ SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type ) ...@@ -238,7 +240,7 @@ SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
if( type == LAYER_GLOBLABEL || type == LAYER_HIERLABEL ) if( type == LAYER_GLOBLABEL || type == LAYER_HIERLABEL )
{ {
s_DefaultShapeGLabel = NewText->m_Shape; s_DefaultShapeGLabel = NewText->m_Shape;
s_DefaultOrientGLabel = NewText->m_Orient; s_DefaultOrientGLabel = NewText->GetSchematicTextOrientation();
} }
RedrawOneStruct( DrawPanel, DC, NewText, GR_DEFAULT_DRAWMODE ); RedrawOneStruct( DrawPanel, DC, NewText, GR_DEFAULT_DRAWMODE );
...@@ -317,7 +319,7 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -317,7 +319,7 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
SCH_TEXT* Text = (SCH_TEXT*) Struct; SCH_TEXT* Text = (SCH_TEXT*) Struct;
Text->m_Pos = ItemInitialPosition; Text->m_Pos = ItemInitialPosition;
Text->m_Size = OldSize; Text->m_Size = OldSize;
Text->m_Orient = OldOrient; Text->SetSchematicTextOrientation( OldOrient );
} }
break; break;
...@@ -372,11 +374,9 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text, ...@@ -372,11 +374,9 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text,
/* copy the old text settings */ /* copy the old text settings */
newtext->m_Shape = Text->m_Shape; newtext->m_Shape = Text->m_Shape;
newtext->m_Orient = Text->m_Orient; newtext->SetSchematicTextOrientation( Text->GetSchematicTextOrientation() );
newtext->m_Size = Text->m_Size; newtext->m_Size = Text->m_Size;
newtext->m_Width = Text->m_Width; newtext->m_Width = Text->m_Width;
newtext->m_HJustify = Text->m_HJustify;
newtext->m_VJustify = Text->m_VJustify;
newtext->m_IsDangling = Text->m_IsDangling; newtext->m_IsDangling = Text->m_IsDangling;
// save current text flag: // save current text flag:
......
...@@ -311,11 +311,10 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, ...@@ -311,11 +311,10 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
break; break;
} }
case TYPE_SCH_LABEL:
case TYPE_SCH_TEXT: case TYPE_SCH_TEXT:
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_TEXT*) DrawList ) #define STRUCT ( (SCH_TEXT*) DrawList )
if( !( SearchMask & (TEXTITEM | LABELITEM) ) ) if( !( SearchMask & TEXTITEM) )
break; break;
if( STRUCT->HitTest( aPosRef ) ) if( STRUCT->HitTest( aPosRef ) )
{ {
...@@ -325,21 +324,11 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, ...@@ -325,21 +324,11 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
break; break;
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL: case TYPE_SCH_GLOBALLABEL:
#undef STRUCT
#define STRUCT ( (SCH_GLOBALLABEL*) DrawList )
if( !(SearchMask & LABELITEM) )
break;
if( STRUCT->HitTest( aPosRef ) )
{
LastSnappedStruct = DrawList;
return TRUE;
}
break;
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_HIERLABEL*) DrawList ) #define STRUCT ( (SCH_TEXT*) DrawList ) // SCH_TEXT is the base class of these labels
if( !(SearchMask & LABELITEM) ) if( !(SearchMask & LABELITEM) )
break; break;
if( STRUCT->HitTest( aPosRef ) ) if( STRUCT->HitTest( aPosRef ) )
......
This diff is collapsed.
...@@ -75,7 +75,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile, ...@@ -75,7 +75,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
new SCH_LABEL( pos, CONV_FROM_UTF8( text ) ); new SCH_LABEL( pos, CONV_FROM_UTF8( text ) );
TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient; TextStruct->SetSchematicTextOrientation( orient );
if( isdigit( Name3[0] ) ) if( isdigit( Name3[0] ) )
{ {
thickness = atol( Name3 ); thickness = atol( Name3 );
...@@ -92,7 +92,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile, ...@@ -92,7 +92,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
Struct = TextStruct; Struct = TextStruct;
TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient; TextStruct->SetSchematicTextOrientation( orient );
TextStruct->m_Shape = NET_INPUT; TextStruct->m_Shape = NET_INPUT;
TextStruct->m_Width = thickness; TextStruct->m_Width = thickness;
...@@ -115,7 +115,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile, ...@@ -115,7 +115,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
Struct = TextStruct; Struct = TextStruct;
TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient; TextStruct->SetSchematicTextOrientation( orient );
TextStruct->m_Shape = NET_INPUT; TextStruct->m_Shape = NET_INPUT;
TextStruct->m_Width = thickness; TextStruct->m_Width = thickness;
...@@ -145,7 +145,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile, ...@@ -145,7 +145,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
SCH_TEXT* TextStruct = new SCH_TEXT( pos, val ); SCH_TEXT* TextStruct = new SCH_TEXT( pos, val );
TextStruct->m_Size.x = TextStruct->m_Size.y = size; TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->m_Orient = orient; TextStruct->SetSchematicTextOrientation( orient );
if( isdigit( Name3[0] ) ) if( isdigit( Name3[0] ) )
{ {
thickness = atol( Name3 ); thickness = atol( Name3 );
......
...@@ -353,7 +353,7 @@ static void PlotTextModule( TEXTE_MODULE* pt_texte, int format_plot ) ...@@ -353,7 +353,7 @@ static void PlotTextModule( TEXTE_MODULE* pt_texte, int format_plot )
pt_texte->m_Text, pt_texte->m_Text,
orient, size, orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify, pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic ); thickness, pt_texte->m_Italic, true );
} }
...@@ -620,11 +620,34 @@ void PlotTextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer ) ...@@ -620,11 +620,34 @@ void PlotTextePcb( TEXTE_PCB* pt_texte, int format_plot, int masque_layer )
break; break;
} }
if( pt_texte->m_MultilineAllowed )
{
wxArrayString* list = wxStringSplit( pt_texte->m_Text, '\n' );
wxPoint offset;
offset.y = pt_texte->GetInterline();
RotatePoint( &offset, orient );
for( unsigned i = 0; i<list->Count(); i++ )
{
wxString txt = list->Item( i );
PlotGraphicText( format_plot, pos, BLACK,
txt,
orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic, true );
pos += offset;
}
delete (list);
}
else
PlotGraphicText( format_plot, pos, BLACK, PlotGraphicText( format_plot, pos, BLACK,
pt_texte->m_Text, pt_texte->m_Text,
orient, size, orient, size,
pt_texte->m_HJustify, pt_texte->m_VJustify, pt_texte->m_HJustify, pt_texte->m_VJustify,
thickness, pt_texte->m_Italic ); thickness, pt_texte->m_Italic, true );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment