Commit ce9db78c authored by charras's avatar charras

Cleaned and optimized code about new hershey fonts and bold texts handling (see changelog)

parent b4c639a6
......@@ -4,6 +4,16 @@ KiCad ChangeLog 2009
Please add newer entries at the top, list the date and your name with
email address.
2009-may-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++All:
Cleaned and optimized code about new hershey fonts and bold texts handling.
Bold texts use now the same font as normal texts.
Only the pen size used to draw them is bigger.
- The max pen size allowed depending on texts sizes is now tested
when loading boards and modules, and clamped if too large.
2009-may-28 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
......
......@@ -19,13 +19,56 @@
#define EDA_DRAWBASE
#include "hershey_fonts.h"
/* factor used to calculate actual size of shapes from hershey fonts (could be adjusted depending on the font name)
* Its value is choosen in order to have letters like M, P .. vertical size equal to the vertical char size parameter
* Of course some shapes can be bigger or smaller than the vertical char size parameter
*/
#define HERSHEY_SCALE_FACTOR 1/21.0
*/
#define HERSHEY_SCALE_FACTOR 1 / 21.0
double s_HerscheyScaleFactor = HERSHEY_SCALE_FACTOR;
/** Function GetPensizeForBold
* @return the "best" value for a pen size to draw/plot a bold text
* @param aTextSize = the char size (height or width)
*/
int GetPenSizeForBold( int aTextSize )
{
return wxRound( aTextSize / 5.0 );
}
/** Function Clamp_Text_PenSize
*As a rule, pen width should not be >1/4em, otherwise the character
* will be cluttered up in its own fatness
* so pen width max is aSize/4 for bold text, and aSize/6 for normal text
* The "best" pen width is aSize/5 for bold texts,
* so the clamp is consistant with bold option.
* @param aPenSize = the pen size to clamp
* @param aSize the char size (height or width)
* @param aBold = true if text accept bold pen size
* @return the max pen size allowed
*/
int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold )
{
int penSize = aPenSize;
double scale = aBold ? 4.0 : 6.0;
int maxWidth = wxRound( ABS( aSize ) / scale );
if( penSize > maxWidth )
penSize = maxWidth;
return penSize;
}
int Clamp_Text_PenSize( int aPenSize, wxSize aSize, bool aBold )
{
int size = MIN( ABS( aSize.x ), ABS( aSize.y ) );
return Clamp_Text_PenSize(aPenSize, size, aBold);;
}
/* Functions to draw / plot a string.
* texts have only one line.
* They can be in italic.
......@@ -53,9 +96,15 @@ int NegableTextLength( const wxString& aText )
}
static const char* get_hershey_recipe( int AsciiCode, bool bold )
{
/* Function GetHersheyShapeDescription()
* return a pointer to the shape corresponding to unicode value AsciiCode
* Note we use the same font for Bold and Normal texts
* because kicad handles a variable pen size to do that
* that gives better results in XOR draw mode.
*/
static const char* GetHersheyShapeDescription( int AsciiCode )
{
#if defined(KICAD_CYRILLIC)
AsciiCode &= 0x7FF;
if( AsciiCode > 0x40F && AsciiCode < 0x450 ) // big small Cyr
......@@ -77,18 +126,11 @@ static const char* get_hershey_recipe( int AsciiCode, bool bold )
AsciiCode = 32; /* Clamp control chars */
AsciiCode -= 32;
if( bold )
{
return hershey_duplex[AsciiCode];
}
else
{
return hershey_simplex[AsciiCode];
}
return hershey_simplex[AsciiCode];
}
int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool italic, bool bold )
int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool aItalic, bool aWidth )
{
int tally = 0;
int char_count = aText.length();
......@@ -102,7 +144,7 @@ int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool italic, bool
continue;
}
const char* ptcar = get_hershey_recipe( AsciiCode, bold );
const char* ptcar = GetHersheyShapeDescription( AsciiCode );
/* Get metrics */
int xsta = *ptcar++ - 'R';
int xsto = *ptcar++ - 'R';
......@@ -110,7 +152,7 @@ int ReturnGraphicTextWidth( const wxString& aText, int aXSize, bool italic, bool
}
/* Italic correction, 1/8em */
if( italic )
if( aItalic )
{
tally += wxRound( aXSize * 0.125 );
}
......@@ -149,35 +191,11 @@ static void DrawGraphicTextPline(
}
/* Helper function for texts with over bar
*/
static int overbar_position( int size_v, int thickness )
{
return wxRound( ((double) size_v * 26 * s_HerscheyScaleFactor ) + ((double) thickness * 1.5) );
}
static int clamp_text_pen_size( int width, int size_h, bool bold )
{
/* As a rule, pen width should not be >1/8em, otherwise the character
* will be cluttered up in its own fatness */
/* XXX @todo: Should be handled in the UI and gerber plotter too */
int maxWidth = wxRound( ABS( size_h ) / 8.0 );
if( width > maxWidth )
{
width = maxWidth;
}
/* Special rule for bold text: the width should be at least 1.42 times the
* quantum unit, otherwise the line pairs will be visible! */
if( bold )
{
int minWidth = wxRound( ABS( size_h ) * 1.42 * s_HerscheyScaleFactor + 0.5 );
if( width < minWidth )
{
width = minWidth;
}
}
return width;
return wxRound( ( (double) size_v * 26 * s_HerscheyScaleFactor ) + ( (double) thickness * 1.5 ) );
}
......@@ -192,10 +210,11 @@ static int clamp_text_pen_size( int width, int size_h, bool bold )
* @param aSize = text size (size.x or size.y can be < 0 for mirrored texts)
* @param aH_justify = horizontal justification (Left, center, right)
* @param aV_justify = vertical justification (bottom, center, top)
* @param aWidth = line width (pen width) (default = 0)
* @param aWidth = line width (pen width) (use default width if aWidth = 0)
* if width < 0 : draw segments in sketch mode, width = abs(width)
* Use a value min(aSize.x, aSize.y) / 5 for a bold text
* @param aItalic = true to simulate an italic font
* @param aBold = true to use a bold font
* @param aBold = true to use a bold font. Useful only with default width value (aWidth = 0)
* @param aCallback() = function called (if non null) to draw each segment.
* used to draw 3D texts or for plotting, NULL for normal drawings
*/
......@@ -233,6 +252,9 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
size_h = aSize.x; /* PLEASE NOTE: H is for HORIZONTAL not for HEIGHT */
size_v = aSize.y;
if( aWidth == 0 && aBold ) // Use default values if aWidth == 0
aWidth = GetPenSizeForBold( MIN( aSize.x, aSize.y ) );
if( aWidth < 0 )
{
aWidth = -aWidth;
......@@ -241,15 +263,13 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
if( size_h < 0 ) // text is mirrored using size.x < 0 (mirror / Y axis)
italic_reverse = true;
aWidth = clamp_text_pen_size( aWidth, size_h, aBold );
char_count = NegableTextLength( aText );
if( char_count == 0 )
return;
current_char_pos = aPos;
dx = ReturnGraphicTextWidth( aText, size_h, aItalic, aBold );
dx = ReturnGraphicTextWidth( aText, size_h, aItalic, aWidth );
dy = size_v;
/* Do not draw the text if out of draw area! */
......@@ -381,7 +401,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
AsciiCode = aText.GetChar( ptr + overbars );
const char* ptcar = get_hershey_recipe( AsciiCode, aBold );
const char* ptcar = GetHersheyShapeDescription( AsciiCode );
/* Get metrics */
int xsta = *ptcar++ - 'R';
int xsto = *ptcar++ - 'R';
......@@ -468,7 +488,7 @@ static bool s_Plotbegin; // Flag to init plot
* The call back function
*/
/****************************************************************/
static void s_Callback_plot( int x0, int y0, int xf, int yf )
static void s_Callback_plot( int x0, int y0, int xf, int yf )
/****************************************************************/
{
static wxPoint PenLastPos;
......@@ -514,8 +534,9 @@ static void s_Callback_plot( int x0, int y0, int xf, int yf )
* @param aV_justify = vertical justification (bottom, center, top)
* @param aWidth = line width (pen width) (default = 0)
* if width < 0 : draw segments in sketch mode, width = abs(width)
* Use a value min(aSize.x, aSize.y) / 5 for a bold text
* @param aItalic = true to simulate an italic font
* @param aBold = true to use a bold font
* @param aBold = true to use a bold font Useful only with default width value (aWidth = 0)
*/
/******************************************************************************************/
void PlotGraphicText( int aFormat_plot,
......@@ -531,14 +552,8 @@ void PlotGraphicText( int aFormat_plot,
bool aBold )
/******************************************************************************************/
{
if( aWidth > 0 )
{
aWidth = clamp_text_pen_size( aWidth, aSize.x, aBold );
}
else
{
aWidth = -clamp_text_pen_size( -aWidth, aSize.x, aBold );
}
if( aWidth == 0 && aBold ) // Use default values if aWidth == 0
aWidth = GetPenSizeForBold( MIN( aSize.x, aSize.y ) );
// Initialise the actual function used to plot lines:
switch( aFormat_plot )
......@@ -568,7 +583,8 @@ void PlotGraphicText( int aFormat_plot,
DrawGraphicText( NULL, NULL, aPos, aColor, aText,
aOrient, aSize,
aH_justify, aV_justify,
aWidth, aItalic, aBold,
aWidth, aItalic,
aBold,
s_Callback_plot );
/* end text : pen UP ,no move */
......
......@@ -325,11 +325,7 @@ void GRSetBrush( wxDC* DC, int Color, int fill )
if( ForceBlackPen )
Color = BLACK;
wxBrush DrawBrush;
DrawBrush.SetColour(
ColorRefs[Color].m_Red,
ColorRefs[Color].m_Green,
ColorRefs[Color].m_Blue
);
DrawBrush.SetColour( MakeColour( Color ) );
if( fill )
DrawBrush.SetStyle( wxSOLID );
......
This diff is collapsed.
......@@ -520,7 +520,7 @@ bool SCH_TEXT::Save( FILE* aFile ) const
if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n",
m_Pos.x, m_Pos.y,
m_SchematicOrientation, m_Size.x,
shape, (m_Bold?1:0),
shape, m_Width,
CONV_TO_UTF8( text ) ) == EOF )
{
success = false;
......@@ -577,7 +577,7 @@ bool SCH_LABEL::Save( FILE* aFile ) const
if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %s %d\n%s\n",
m_Pos.x, m_Pos.y,
m_SchematicOrientation, m_Size.x, shape, (m_Bold?1:0),
m_SchematicOrientation, m_Size.x, shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF )
{
success = false;
......@@ -616,7 +616,7 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
m_Pos.x, m_Pos.y,
m_SchematicOrientation, m_Size.x,
SheetLabelType[m_Shape],
shape, (m_Bold?1:0),
shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF )
{
success = false;
......@@ -670,7 +670,7 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const
m_Pos.x, m_Pos.y,
m_SchematicOrientation, m_Size.x,
SheetLabelType[m_Shape],
shape, (m_Bold?1:0),
shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF )
{
success = false;
......
......@@ -6,6 +6,8 @@
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "base_struct.h"
#include "drawtxt.h"
#include "class_drawpanel.h"
#include "confirm.h"
......@@ -61,9 +63,15 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
m_CurrentText->m_Italic = 0;
if ( ( style & 2 ) )
{
m_CurrentText->m_Bold = true;
m_CurrentText->m_Width = GetPenSizeForBold( m_CurrentText->m_Size.x );
}
else
{
m_CurrentText->m_Bold = false;
m_CurrentText->m_Width = 0;
}
m_Parent->GetScreen()->SetModify();
......
......@@ -9,6 +9,7 @@
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "drawtxt.h"
#include "protos.h"
......@@ -69,7 +70,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
if( text == NULL )
return NULL;
if( Name1[0] == 'L' )
if( Name1[0] == 'L' ) // Reading a simple label (SCH_LABEL item)
{
SCH_LABEL* TextStruct =
new SCH_LABEL( pos, CONV_FROM_UTF8( text ) );
......@@ -80,12 +81,13 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
{
thickness = atol( Name3 );
TextStruct->m_Bold = (thickness != 0);
TextStruct->m_Width = TextStruct->m_Bold ? GetPenSizeForBold( size ) : 0;
}
Struct = TextStruct;
if( stricmp( Name2, "Italic" ) == 0 )
TextStruct->m_Italic = 1;
}
else if( Name1[0] == 'G' && aSchematicFileVersion > '1' )
else if( Name1[0] == 'G' && aSchematicFileVersion > '1' ) // Reading a global label (SCH_GLOBALLABEL item)
{
SCH_GLOBALLABEL* TextStruct =
new SCH_GLOBALLABEL( pos, CONV_FROM_UTF8( text ) );
......@@ -94,7 +96,8 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->SetSchematicTextOrientation( orient );
TextStruct->m_Shape = NET_INPUT;
TextStruct->m_Bold = (thickness != 0);
TextStruct->m_Bold = (thickness != 0);
TextStruct->m_Width = TextStruct->m_Bold ? GetPenSizeForBold( size ) : 0;
if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 )
TextStruct->m_Shape = NET_OUTPUT;
......@@ -107,7 +110,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
if( stricmp( Name3, "Italic" ) == 0 )
TextStruct->m_Italic = 1;
}
else if( (Name1[0] == 'H')
else if( (Name1[0] == 'H') // Reading a hierarchical label (SCH_HIERLABEL item)
|| (Name1[0] == 'G' && aSchematicFileVersion == '1') ) //in schematic file version 1, glabels were actually hierarchal labels.
{
SCH_HIERLABEL* TextStruct =
......@@ -117,7 +120,8 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
TextStruct->m_Size.x = TextStruct->m_Size.y = size;
TextStruct->SetSchematicTextOrientation( orient );
TextStruct->m_Shape = NET_INPUT;
TextStruct->m_Bold = (thickness != 0);
TextStruct->m_Bold = (thickness != 0);
TextStruct->m_Width = TextStruct->m_Bold ? GetPenSizeForBold( size ) : 0;
if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 )
TextStruct->m_Shape = NET_OUTPUT;
......@@ -130,7 +134,7 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
if( stricmp( Name3, "Italic" ) == 0 )
TextStruct->m_Italic = 1;
}
else
else // reading a graphic text (comment)
{
wxString val = CONV_FROM_UTF8( text );
......@@ -152,7 +156,8 @@ SCH_ITEM* ReadTextDescr( FILE* aFile,
if( isdigit( Name3[0] ) )
{
thickness = atol( Name3 );
TextStruct->m_Bold = (thickness != 0);
TextStruct->m_Bold = (thickness != 0);
TextStruct->m_Width = TextStruct->m_Bold ? GetPenSizeForBold( size ) : 0;
}
if( strnicmp( Name2, "Italic", 6 ) == 0 )
......
/* Hershey Cyrillic definition
* First shape has unicode value 0x410
*/
const static char* hershey_cyrillic[] =
{
"H\\RFK[ RRFY[ RRIX[ RMUVU RI[O[ RU[[[",
"G]LFL[ RMFM[ RIFYFYLXF RMPUPXQYRZTZWYYXZU[I[ RUPWQXRYTYWXYWZU[",
"G]LFL[ RMFM[ RIFUFXGYHZJZLYNXOUP RUFWGXHYJYLXNWOUP RMPUPXQYRZTZWYYXZU[I[ RUPWQXRYTYWXYWZU[",
"I[NF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TPT", /* ю */
"G\\VMV[ RWMW[ RZMOMLNKPKQLSOTVT ROMMNLPLQMSOT RTTQUPVNZM[ RTTRUQVOZN[L[KZJX RS[Z[" /* я */
};
/* Hershey Simplex Roman (sans) definition
* First shape has unicode (or ascii) value 0x20 (space)
*/
const static char* hershey_simplex[] =
{
"JZ",
"MWRFRT RRYQZR[SZRY",
"JZNFNM RVFVM",
"H]SBLb RYBRb RLOZO RKUYU",
"H\\PBP_ RTBT_ RYIWGTFPFMGKIKKLMMNOOUQWRXSYUYXWZT[P[MZKX",
"F^[FI[ RNFPHPJOLMMKMIKIIJGLFNFPGSHVHYG[F RWTUUTWTYV[X[ZZ[X[VYTWT",
"E_\\O\\N[MZMYNXPVUTXRZP[L[JZIYHWHUISJRQNRMSKSIRGPFNGMIMKNNPQUXWZY[[[\\Z\\Y",
"MWRHQGRFSGSIRKQL",
"KYVBTDRGPKOPOTPYR]T`Vb",
"KYNBPDRGTKUPUTTYR]P`Nb",
"JZRFRR RMIWO RWIMO",
"E_RIR[ RIR[R",
"MWSZR[QZRYSZS\\R^Q_",
"E_IR[R",
"MWRYQZR[SZRY",
"G][BIb",
"H\\QFNGLJKOKRLWNZQ[S[VZXWYRYOXJVGSFQF",
"H\\NJPISFS[",
"H\\LKLJMHNGPFTFVGWHXJXLWNUQK[Y[",
"H\\MFXFRNUNWOXPYSYUXXVZS[P[MZLYKW",
"H\\UFKTZT RUFU[",
"H\\WFMFLOMNPMSMVNXPYSYUXXVZS[P[MZLYKW",
"H\\XIWGTFRFOGMJLOLTMXOZR[S[VZXXYUYTXQVOSNRNOOMQLT",
"H\\YFO[ RKFYF",
"H\\PFMGLILKMMONSOVPXRYTYWXYWZT[P[MZLYKWKTLRNPQOUNWMXKXIWGTFPF",
"H\\XMWPURRSQSNRLPKMKLLINGQFRFUGWIXMXRWWUZR[P[MZLX",
"MWRMQNROSNRM RRYQZR[SZRY",
"MWRMQNROSNRM RSZR[QZRYSZS\\R^Q_",
"F^ZIJRZ[",
"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14 +491,14 @@ public:
wxString m_Text; /* text! */
wxPoint m_Pos; /* XY position of anchor text. */
wxSize m_Size; /* XY size of text */
int m_Width; /* text width */
int m_Width; /* pen size used to draw this text */
int m_Orient; /* Orient in 0.1 degrees */
bool m_Mirror; // Display Normal / mirror
bool m_Mirror; /* Display Normal / mirror */
int m_Attributs; /* flags (visible...) */
bool m_Italic; /* true to simulate an italic font... */
bool m_Bold; /* true to use a bold font... */
GRTextHorizJustifyType m_HJustify; /* Horiz Justify */
GRTextVertJustifyType m_VJustify; /* Vertical and Vert Justify */
bool m_Italic; /* true to simulate (or use if exists) an italic font... */
bool m_Bold; /* true to simulate a bold font ... */
GRTextHorizJustifyType m_HJustify; /* Horiz justification */
GRTextVertJustifyType m_VJustify; /* Vertical justification */
bool m_MultilineAllowed; /* true to use multiline option, false to use only single line text
* Single line is faster in calculations than multiline */
......@@ -576,7 +576,7 @@ public:
* If aLine == -1, the full area (considering all lines) is returned
*/
EDA_Rect GetTextBox( int aLine = -1);
/** Function GetInterline
* return the distance between 2 text lines
* has meaning only for multiline texts
......
......@@ -9,6 +9,26 @@
class WinEDA_DrawPanel;
/** Function Clamp_Text_PenSize
*As a rule, pen width should not be >1/4em, otherwise the character
* will be cluttered up in its own fatness
* The pen width max is aSize/4 for bold texts, and aSize/6 for normal texts
* The "best" pen width is aSize/5 for bold texts,
* so the clamp is consistant with bold option.
* @param aPenSize = the pen size to clamp
* @param aSize the char size (height or width, od its wxSize)
* @param aBold = true if text accept bold pen size
* @return the max pen size allowed
*/
int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold = true);
int Clamp_Text_PenSize( int aPenSize, wxSize aSize, bool aBold = true);
/** Function GetPensizeForBold
* @return the "best" value for a pen size to draw/plot a bold text
* @param aTextSize = the char size (height or width)
*/
int GetPenSizeForBold( int aTextSize );
/** Function ReturnGraphicTextWidth
* @return the X size of the graphic text
* the full X size is ReturnGraphicTextWidth + the thickness of graphic lines
......@@ -32,9 +52,9 @@ int NegableTextLength( const wxString& aText );
* @param aV_justify = vertical justification (bottom, center, top)
* @param aWidth = line width (pen width) (default = 0)
* if width < 0 : draw segments in sketch mode, width = abs(width)
* Use a value min(aSize.x, aSize.y) / 5 for a bold text
* @param aItalic = true to simulate an italic font
* @param aBold = true to use a bold font
* @param aNegable = true to enable the ~ char for overbarring
* @param aCallback() = function called (if non null) to draw each segment.
* used to draw 3D texts or for plotting, NULL for normal drawings
*/
......@@ -49,7 +69,7 @@ void DrawGraphicText( WinEDA_DrawPanel * aPanel,
enum GRTextVertJustifyType aV_justify,
int aWidth,
bool aItalic,
bool aBold,
bool aBold,
void (*aCallback)( int x0, int y0, int xf, int yf ) = NULL );
/** Function PlotGraphicText
......
This diff is collapsed.
......@@ -11,32 +11,32 @@
#ifndef __WORKSHEET_H__
#define __WORKSHEET_H__
#define GRID_REF_W 70 /* hauteur de la bande de reference grille */
#define SIZETEXT 60 /* Dimension des textes du cartouche */
#define SIZETEXT_REF 50 /* Dimension des lettres du marquage des reperes */
#define PAS_REF 2000 /* pas des marquages de reference des reperes */
#define TEXT_VTAB_HEIGHT SIZETEXT*2
#define GRID_REF_W 70 /* hauteur de la bande de reference grille */
#define SIZETEXT 60 /* Dimension des textes du cartouche */
#define SIZETEXT_REF 50 /* Dimension des lettres du marquage des reperes */
#define PAS_REF 2000 /* pas des marquages de reference des reperes */
#define TEXT_VTAB_HEIGHT SIZETEXT * 2
#if defined(KICAD_GOST)
/* Shtamp */
#define STAMP_OX 185 * 10000 / 254
#define STAMP_OY 55 * 10000 / 254
#define STAMP_OX 185 * 10000 / 254
#define STAMP_OY 55 * 10000 / 254
#define STAMP_Y_0 0
#define STAMP_Y_5 5 * 10000 / 254
#define STAMP_Y_8 8 * 10000 / 254
#define STAMP_Y_7 7 * 10000 / 254
#define STAMP_Y_10 10 * 10000 / 254
#define STAMP_Y_14 14 * 10000 / 254
#define STAMP_Y_15 15 * 10000 / 254
#define STAMP_Y_20 20 * 10000 / 254
#define STAMP_Y_25 25 * 10000 / 254
#define STAMP_Y_30 30 * 10000 / 254
#define STAMP_Y_35 35 * 10000 / 254
#define STAMP_Y_40 40 * 10000 / 254
#define STAMP_Y_45 45 * 10000 / 254
#define STAMP_Y_50 50 * 10000 / 254
#define STAMP_Y_55 55 * 10000 / 254
#define STAMP_Y_0 0
#define STAMP_Y_5 5 * 10000 / 254
#define STAMP_Y_8 8 * 10000 / 254
#define STAMP_Y_7 7 * 10000 / 254
#define STAMP_Y_10 10 * 10000 / 254
#define STAMP_Y_14 14 * 10000 / 254
#define STAMP_Y_15 15 * 10000 / 254
#define STAMP_Y_20 20 * 10000 / 254
#define STAMP_Y_25 25 * 10000 / 254
#define STAMP_Y_30 30 * 10000 / 254
#define STAMP_Y_35 35 * 10000 / 254
#define STAMP_Y_40 40 * 10000 / 254
#define STAMP_Y_45 45 * 10000 / 254
#define STAMP_Y_50 50 * 10000 / 254
#define STAMP_Y_55 55 * 10000 / 254
#define STAMP_X_0 0
#define STAMP_X_10 10 * 10000 / 254
......@@ -58,59 +58,58 @@
#define STAMP_X_178 178 * 10000 / 254
#define STAMP_X_185 185 * 10000 / 254
#define STAMP_5 5 * 10000 / 254
#define STAMP_7 7 * 10000 / 254
#define STAMP_12 12 * 10000 / 254
#define STAMP_5 5 * 10000 / 254
#define STAMP_7 7 * 10000 / 254
#define STAMP_12 12 * 10000 / 254
#define STAMP_145 145 * 10000 / 254
#define STAMP_110 110 * 10000 / 254
#define STAMP_85 85 * 10000 / 254
#define STAMP_60 60 * 10000 / 254
#define STAMP_25 25 * 10000 / 254
#define STAMP_145 145 * 10000 / 254
#define STAMP_110 110 * 10000 / 254
#define STAMP_85 85 * 10000 / 254
#define STAMP_60 60 * 10000 / 254
#define STAMP_25 25 * 10000 / 254
#endif
/* Les coord ci dessous sont relatives au coin bas - droit de la feuille, et
seront soustraires de cette origine
*/
#define BLOCK_OX 4200
#define BLOCK_KICAD_VERSION_X BLOCK_OX - SIZETEXT
#define BLOCK_KICAD_VERSION_Y SIZETEXT
#define BLOCK_REV_X 820
#define BLOCK_REV_Y (SIZETEXT*3)
#define BLOCK_DATE_X BLOCK_OX - (SIZETEXT*15)
#define BLOCK_DATE_Y (SIZETEXT*3)
#define BLOCK_ID_SHEET_X 820
#define BLOCK_ID_SHEET_Y SIZETEXT
#define BLOCK_SIZE_SHEET_X BLOCK_OX - SIZETEXT
#define BLOCK_SIZE_SHEET_Y (SIZETEXT*3)
#define BLOCK_TITLE_X BLOCK_OX - SIZETEXT
#define BLOCK_TITLE_Y (SIZETEXT*5)
#define BLOCK_FULLSHEETNAME_X BLOCK_OX - SIZETEXT
#define BLOCK_FULLSHEETNAME_Y (SIZETEXT * 7)
#define BLOCK_FILENAME_X BLOCK_OX - SIZETEXT
#define BLOCK_FILENAME_Y (SIZETEXT * 9)
#define BLOCK_COMMENT_X BLOCK_OX - SIZETEXT
* seront soustraires de cette origine
*/
#define BLOCK_OX 4200
#define BLOCK_KICAD_VERSION_X BLOCK_OX - SIZETEXT
#define BLOCK_KICAD_VERSION_Y SIZETEXT
#define BLOCK_REV_X 820
#define BLOCK_REV_Y (SIZETEXT * 3)
#define BLOCK_DATE_X BLOCK_OX - (SIZETEXT * 15)
#define BLOCK_DATE_Y (SIZETEXT * 3)
#define BLOCK_ID_SHEET_X 820
#define BLOCK_ID_SHEET_Y SIZETEXT
#define BLOCK_SIZE_SHEET_X BLOCK_OX - SIZETEXT
#define BLOCK_SIZE_SHEET_Y (SIZETEXT * 3)
#define BLOCK_TITLE_X BLOCK_OX - SIZETEXT
#define BLOCK_TITLE_Y (SIZETEXT * 5)
#define BLOCK_FULLSHEETNAME_X BLOCK_OX - SIZETEXT
#define BLOCK_FULLSHEETNAME_Y (SIZETEXT * 7)
#define BLOCK_FILENAME_X BLOCK_OX - SIZETEXT
#define BLOCK_FILENAME_Y (SIZETEXT * 9)
#define BLOCK_COMMENT_X BLOCK_OX - SIZETEXT
#define VARIABLE_BLOCK_START_POSITION (SIZETEXT * 10)
#define BLOCK_COMPANY_Y (SIZETEXT*11)
#define BLOCK_COMMENT1_Y (SIZETEXT*13)
#define BLOCK_COMMENT2_Y (SIZETEXT*15)
#define BLOCK_COMMENT3_Y (SIZETEXT*17)
#define BLOCK_COMMENT4_Y (SIZETEXT*19)
#define BLOCK_COMPANY_Y (SIZETEXT * 11)
#define BLOCK_COMMENT1_Y (SIZETEXT * 13)
#define BLOCK_COMMENT2_Y (SIZETEXT * 15)
#define BLOCK_COMMENT3_Y (SIZETEXT * 17)
#define BLOCK_COMMENT4_Y (SIZETEXT * 19)
struct Ki_WorkSheetData
{
public:
int m_Type; /* nombre permettant de reconnaitre la description */
Ki_WorkSheetData * Pnext;
int m_Posx, m_Posy; /* position de l'element ou point de depart du segment */
int m_Endx, m_Endy; /* extremite d'un element type segment ou cadre */
const wxChar * m_Legende; /* Pour m_Textes: texte a afficher avant le texte lui meme */
const wxChar * m_Text; /* Pour m_Textes:pointeur sur le texte a afficher */
int m_Type; /* nombre permettant de reconnaitre la description */
Ki_WorkSheetData* Pnext;
int m_Posx, m_Posy; /* position de l'element ou point de depart du segment */
int m_Endx, m_Endy; /* extremite d'un element type segment ou cadre */
const wxChar* m_Legende; /* Pour m_Textes: texte a afficher avant le texte lui meme */
const wxChar* m_Text; /* Pour m_Textes:pointeur sur le texte a afficher */
};
/* Type des descriptions Ki_WorkSheetData */
enum TypeKi_WorkSheetData
{
enum TypeKi_WorkSheetData {
WS_DATE,
WS_REV,
WS_KICAD_VERSION,
......
No preview for this file type
This diff is collapsed.
......@@ -205,6 +205,8 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
if( ( m_Masque_Layer & ALL_CU_LAYERS ) == 0 )
DisplayIsol = FALSE;
SetAlpha(&color, 170);
switch( GetShape() )
{
case PAD_CIRCLE:
......
......@@ -5,7 +5,9 @@
#include "fctsys.h"
#include "wxstruct.h"
#include "gr_basic.h"
#include "base_struct.h"
#include "common.h"
#include "drawtxt.h"
#include "kicad_string.h"
#include "pcbnew.h"
......@@ -42,6 +44,7 @@ void TEXTE_PCB::Copy( TEXTE_PCB* source )
m_Width = source->m_Width;
m_Attributs = source->m_Attributs;
m_Italic = source->m_Italic;
m_Bold = source->m_Bold;
m_HJustify = source->m_HJustify;
m_VJustify = source->m_VJustify;
m_MultilineAllowed = m_MultilineAllowed;
......@@ -131,6 +134,11 @@ int TEXTE_PCB::ReadTextePcbDescr( FILE* File, int* LineNum )
}
}
// Set a reasonnable width:
if( m_Width < 1 )
m_Width = 1;
m_Width = Clamp_Text_PenSize( m_Width, m_Size );
return 1;
}
......@@ -194,7 +202,7 @@ void TEXTE_PCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
GRFillMode fillmode = FILLED;
if ( DisplayOpt.DisplayDrawItems == SKETCH)
fillmode = SKETCH;
EDA_TextStruct::Draw(
panel, DC,
offset,
......
......@@ -166,19 +166,18 @@ int TEXTE_MODULE::ReadDescr( char* aLine, FILE* aFile, int* aLineNum )
ReadDelimitedText( BufLine, aLine, sizeof(BufLine) );
m_Text = CONV_FROM_UTF8( BufLine );
// Test for a reasonnable width:
if( m_Width <= 1 )
m_Width = 1;
if( m_Width > TEXTS_MAX_WIDTH )
m_Width = TEXTS_MAX_WIDTH;
// Test for a reasonnable size:
if( m_Size.x < TEXTS_MIN_SIZE )
m_Size.x = TEXTS_MIN_SIZE;
if( m_Size.y < TEXTS_MIN_SIZE )
m_Size.y = TEXTS_MIN_SIZE;
return success;
// Set a reasonnable width:
if( m_Width < 1 )
m_Width = 1;
m_Width = Clamp_Text_PenSize( m_Width, m_Size );
return success;
}
......@@ -203,6 +202,8 @@ void TEXTE_MODULE::Copy( TEXTE_MODULE* source )
m_Size = source->m_Size;
m_Width = source->m_Width;
m_Italic = source->m_Italic;
m_Bold = source->m_Bold;
m_Text = source->m_Text;
}
......
......@@ -10,6 +10,8 @@
#include "common.h"
#include "class_drawpanel.h"
#include "pcbnew.h"
#include "drawtxt.h"
#include "confirm.h"
#include "dialog_edit_module_text_base.h"
......@@ -178,9 +180,12 @@ void DialogEditModuleText::OnOkClick( wxCommandEvent& event )
// Test for a reasonnable width:
if( width <= 1 )
width = 1;
int minthickness = min(m_CurrentTextMod->m_Size.x, m_CurrentTextMod->m_Size.y) / 4;
if( width > minthickness )
width = minthickness;
int maxthickness = Clamp_Text_PenSize(width, m_CurrentTextMod->m_Size );
if( width > maxthickness )
{
DisplayError(this, _("The text thickness is too large for the text size. It will be clamped"));
width = maxthickness;
}
m_CurrentTextMod->SetWidth( width );
m_CurrentTextMod->m_NoShow = (m_Show->GetSelection() == 0) ? 0 : 1;
......
......@@ -7,6 +7,8 @@
#include "common.h"
#include "class_drawpanel.h"
#include "pcbnew.h"
#include "drawtxt.h"
#include "confirm.h"
enum id_TextPCB_properties {
ID_TEXTPCB_SELECT_LAYER = 1900
......@@ -221,10 +223,12 @@ void WinEDA_TextPCBPropertiesFrame::OnOkClick( wxCommandEvent& event )
CurrentTextPCB->m_Width = m_TxtWidthCtlr->GetValue();
// test for acceptable values for parameters:
int max_tickness = min( CurrentTextPCB->m_Size.x, CurrentTextPCB->m_Size.y );
max_tickness /= 4;
if( CurrentTextPCB->m_Width > max_tickness )
CurrentTextPCB->m_Width = max_tickness;
int maxthickness = Clamp_Text_PenSize( CurrentTextPCB->m_Width, CurrentTextPCB->m_Size );
if( CurrentTextPCB->m_Width > maxthickness )
{
DisplayError(this, _("The text thickness is too large for the text size. It will be clamped"));
CurrentTextPCB->m_Width = maxthickness;
}
CurrentTextPCB->m_Mirror = (m_Mirror->GetSelection() == 1) ? true : false;
CurrentTextPCB->m_Orient = m_Orient->GetSelection() * 900;
......
......@@ -11,6 +11,7 @@
#include "class_drawpanel.h"
#include "pcbnew.h"
#include "drawtxt.h"
#include "trigo.h"
#include "protos.h"
......@@ -44,6 +45,8 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC )
Text->m_Text = wxT( "text" );
ModuleTextWidth = Clamp_Text_PenSize( ModuleTextWidth,
MIN(ModuleTextSize.x, ModuleTextSize.y), true );
Text->m_Size = ModuleTextSize;
Text->m_Width = ModuleTextWidth;
Text->m_Pos = GetScreen()->m_Curseur;
......
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