code cleanup, remove multiline text option in eeschema (multiline text is a work in progress) and minor enhancements

This commit is contained in:
charras 2009-05-05 17:32:07 +00:00
parent f28062acca
commit b49c2d2b9d
22 changed files with 429 additions and 470 deletions

View File

@ -15,9 +15,9 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
option(KICAD_MINIZIP "enable/disable building minizip (default ON)" ON)
# Russian GOST and CYRILLIC patch
option(KICAD_CYRILLIC "enable/disable building unicode (default OFF)")
option(KICAD_CYRILLIC "enable/disable building using cyrillic (needs unicode) (default OFF)")
option(wxUSE_UNICODE "enable/disable building unicode (default OFF)")
option(KICAD_GOST "enable/disable building unicode (default OFF)")
option(KICAD_GOST "enable/disable building using GOST notation for multiple gates per package (default OFF)")
# Comment this out if you don't want to build with Python support.
# OPTION(KICAD_PYTHON "enable/disable building with Python support (default OFF)")

View File

@ -8,7 +8,7 @@
#include "appl_wxstruct.h"
#define BUILD_VERSION wxT("(20090421-unstable)")
#define BUILD_VERSION wxT("(20090504-unstable)")
wxString g_BuildVersion

View File

@ -175,6 +175,7 @@ EDA_TextStruct::EDA_TextStruct( const wxString& text )
m_VJustify = GR_TEXT_VJUSTIFY_CENTER; /* Justifications Horiz et Vert du texte */
m_Width = 0; /* thickness */
m_Italic = false; /* true = italic shape */
m_MultilineAllowed = false; // Set to true only for texts that can use multiline.
m_Text = text;
}
@ -245,9 +246,9 @@ bool EDA_TextStruct::HitTest( EDA_Rect& refArea )
}
/*******************************/
/*********************************************/
int EDA_TextStruct::Pitch( int aMinTickness )
/*******************************/
/*********************************************/
/**
* Function Pitch
@ -277,6 +278,9 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
* @param EDA_Colors aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ).
*/
{
if ( m_MultilineAllowed )
{
wxPoint pos = m_Pos;
wxArrayString* list = wxStringSplit( m_Text, '\n' );
@ -287,7 +291,6 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
RotatePoint( &offset, m_Orient );
if( m_Mirror )
offset.x = -offset.x;
for( unsigned i = 0; i<list->Count(); i++ )
{
wxString txt = list->Item( i );
@ -306,6 +309,18 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
delete (list);
}
else
DrawOneLineOfText( aPanel,
aDC,
aOffset,
aColor,
aDrawMode,
aDisplayMode,
aAnchor_color,
m_Text,
m_Pos );
}
/** Function DrawOneLineOfText
* Draw a single text line.
@ -358,11 +373,10 @@ void EDA_TextStruct::DrawOneLineOfText( WinEDA_DrawPanel* aPanel, wxDC* aDC,
if( m_Mirror )
size.x = -size.x;
DrawGraphicText( aPanel, aDC,
aOffset + aPos, aColor, aText,
m_Orient, size,
m_HJustify, m_VJustify, width, m_Italic );
m_HJustify, m_VJustify, width, m_Italic, true );
}

View File

@ -189,21 +189,30 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
dx = (pitch * char_count) / 2;
dy = size_v / 2; /* dx, dy = draw offset between first letter and text center */
ux0 = uy0 = 0; /* Decalage du centre du texte / coord de ref */
ux0 = uy0 = 0; /* for ux0 = uy0 = 0, the text is centered */
wxPoint offset_org( dx, dy );
int irot = aOrient;
while( irot >= 1800 )
irot -= 1800;
while( irot < 0 )
irot += 1800;
if( irot != 0 )
EXCHG( offset_org.x, offset_org.y );
if( (aOrient == 0) || (aOrient == 1800) ) /* Horizontal Text */
{
switch( aH_justify )
{
case GR_TEXT_HJUSTIFY_CENTER:
break;
case GR_TEXT_HJUSTIFY_RIGHT:
ux0 = -dx;
ux0 = -offset_org.x;
break;
case GR_TEXT_HJUSTIFY_LEFT:
ux0 = dx;
ux0 = offset_org.x;
break;
}
@ -213,44 +222,14 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel,
break;
case GR_TEXT_VJUSTIFY_TOP:
uy0 = dy;
uy0 = offset_org.y;
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
uy0 = -dy;
break;
}
}
else /* Vertical Text */
{
switch( aH_justify )
{
case GR_TEXT_HJUSTIFY_CENTER:
break;
case GR_TEXT_HJUSTIFY_RIGHT:
ux0 = -dy;
break;
case GR_TEXT_HJUSTIFY_LEFT:
ux0 = dy;
uy0 = -offset_org.y;
break;
}
switch( aV_justify )
{
case GR_TEXT_VJUSTIFY_CENTER:
break;
case GR_TEXT_VJUSTIFY_TOP:
uy0 = dx;
break;
case GR_TEXT_VJUSTIFY_BOTTOM:
uy0 = -dx;
break;
}
}
cX += ux0;
cY += uy0;

View File

@ -440,14 +440,6 @@ bool WinEDA_App::SetBinDir()
while( m_BinDir.Last() != '/' && !m_BinDir.IsEmpty() )
m_BinDir.RemoveLast();
wxFileName pfn( wxT( "/posix/path/specification" ), wxT( "filename" ) );
wxFileName wfn( wxT( "\\windows\\path\\specification" ), wxT( "filename" ) );
wxLogDebug( wxT( "Posix path: " ) + pfn.GetFullPath() );
wxLogDebug( wxT( "Windows path: " ) + wfn.GetFullPath() );
wxLogDebug( wxT( "Executable path the Kicad way: " ) + m_BinDir );
wxLogDebug( wxT( "Executable path the wxWidgets way: " ) +
GetTraits()->GetStandardPaths().GetExecutablePath() );
return TRUE;
}

View File

@ -704,7 +704,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
if( !CompactForm )
{
msg = _( "#End Cmp\n" );
fprintf( f, CONV_TO_UTF8( msg ) );
fputs( CONV_TO_UTF8( msg ), f );
}
return 0;
}
@ -731,7 +731,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal(
if( aIncludeSubComponents )
msg << _( " (with SubCmp)" );
msg << wxT( "\n" );
fprintf( f, CONV_TO_UTF8( msg ) );
fputs( CONV_TO_UTF8( msg ), f );
for( unsigned ii = 0; ii < aList.size(); ii++ )
{
@ -781,11 +781,11 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal(
PrintFieldData( f, DrawLibItem );
fprintf( f, "\n" );
fputs( "\n", f );
}
msg = _( "#End Cmp\n" );
fprintf( f, CONV_TO_UTF8( msg ) );
fputs( CONV_TO_UTF8( msg ), f );
return 0;
}
@ -821,7 +821,7 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
(float) DrawTextItem->m_Pos.x / 1000,
(float) DrawTextItem->m_Pos.y / 1000 );
fprintf( f, CONV_TO_UTF8( msg ) );
fputs( CONV_TO_UTF8( msg ), f );
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
@ -840,7 +840,7 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
aList[ii].m_SheetPath.PathHumanReadable().GetData(),
(float) DrawSheetLabel->m_Pos.x / 1000,
(float) DrawSheetLabel->m_Pos.y / 1000 );
fprintf( f, CONV_TO_UTF8( msg ) );
fputs( CONV_TO_UTF8( msg ), f );
}
break;
@ -850,7 +850,7 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
}
msg = _( "#End labels\n" );
fprintf( f, CONV_TO_UTF8( msg ) );
fputs( CONV_TO_UTF8( msg ), f );
return 0;
}

View File

@ -231,10 +231,6 @@ void EDA_ScreenList::AddScreenToList( SCH_SCREEN* testscreen )
}
m_List.Add( testscreen );
#ifdef DEBUG
printf( "EDA_ScreenList::AddScreenToList adding %s\n",
(const char*) testscreen->m_FileName.mb_str() );
#endif
}

View File

@ -34,6 +34,11 @@ const char* SheetLabelType[] =
"?????"
};
/* 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
*/
int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 };
int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 };
int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 };
@ -71,8 +76,8 @@ int* TemplateShape[5][4] =
/**************************************************************************/
SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
SCH_ITEM( NULL, aType )
, EDA_TextStruct( text )
SCH_ITEM( NULL, aType ),
EDA_TextStruct( text )
/**************************************************************************/
{
m_Layer = LAYER_NOTES;
@ -81,6 +86,7 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
m_IsDangling = FALSE;
}
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
@ -88,6 +94,7 @@ SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
bool SCH_TEXT::HitTest( const wxPoint& aPosRef )
{
EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef );
}
@ -172,8 +179,9 @@ void SCH_TEXT::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
SCH_ITEM::Place( frame, DC );
}
/*******************************************************************************************/
void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset,
int DrawMode, int Color )
/*******************************************************************************************/
@ -189,69 +197,50 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
color = ReturnLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
wxArrayString* list = wxStringSplit(m_Text, '\n');
wxPoint pos;
int orientation;
GRTextHorizJustifyType Hjustify;
GRTextVertJustifyType Vjustify;
pos = m_Pos + offset;
wxPoint text_offset = aOffset;
switch( m_Orient )
{
default:
case 0: /* Horiz Normal Orientation (left justified) */
orientation = TEXT_ORIENT_HORIZ;
Hjustify = GR_TEXT_HJUSTIFY_LEFT;
Vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
pos.y-=TXTMARGE;
m_HJustify = GR_TEXT_HJUSTIFY_LEFT;
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
text_offset.y -= TXTMARGE;
break;
case 1: /* Vert Orientation UP */
orientation = TEXT_ORIENT_VERT;
Hjustify = GR_TEXT_HJUSTIFY_RIGHT;
Vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
pos.x-=TXTMARGE;
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
text_offset.x -= TXTMARGE;
break;
case 2: /* Horiz Orientation - Right justified */
orientation = TEXT_ORIENT_HORIZ;
Hjustify = GR_TEXT_HJUSTIFY_RIGHT;
Vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
pos.y-=TXTMARGE;
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
text_offset.y -= TXTMARGE;
break;
case 3: /* Vert Orientation BOTTOM */
orientation = TEXT_ORIENT_VERT;
Hjustify = GR_TEXT_HJUSTIFY_RIGHT;
Vjustify = GR_TEXT_VJUSTIFY_TOP;
pos.x-=TXTMARGE;
m_HJustify = GR_TEXT_HJUSTIFY_RIGHT;
m_VJustify = GR_TEXT_VJUSTIFY_TOP;
text_offset.x -= TXTMARGE;
break;
}
for( unsigned i=0;i<list->Count();i++)
{
wxString txt = list->Item(i);
DrawGraphicText( panel, DC,
pos,
color, txt, orientation, m_Size,
Hjustify,
Vjustify, width, m_Italic, true );
if (orientation == TEXT_ORIENT_HORIZ)
pos.y+= 1.5*(m_Size.y);
else
pos.x+= 1.5*(m_Size.x);
}
delete (list);
// Due to eeschema history; texts orientations are in 0.1 deg, and m_Orient is 0,1,2,3 for label
// Set m_Orient to is value in deg, and after call EDA_TextStruct::Draw retrieve its previous value
EXCHG( orientation, m_Orient );
EXCHG( width, m_Width ); // Set the minimum width
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
EXCHG( orientation, m_Orient ); // set initial value
EXCHG( width, m_Width ); // set initial value
if( m_IsDangling )
DrawDanglingSymbol( panel, DC, m_Pos + offset, color );
DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
}
@ -265,6 +254,7 @@ bool SCH_TEXT::Save( FILE* aFile ) const
{
bool success = true;
const char* shape = "~";
if( m_Italic )
shape = "Italic";
if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n",
@ -296,6 +286,7 @@ void SCH_TEXT::Show( int nestLevel, std::ostream& os )
<< "</" << s.Lower().mb_str() << ">\n";
}
#endif
/****************************************************************************/
@ -319,6 +310,7 @@ bool SCH_LABEL::Save( FILE* aFile ) const
{
bool success = true;
const char* shape = "~";
if( m_Italic )
shape = "Italic";
@ -355,6 +347,7 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
{
bool success = true;
const char* shape = "~";
if( m_Italic )
shape = "Italic";
if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
@ -370,20 +363,22 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
return success;
}
/************************************************/
bool SCH_GLOBALLABEL::HitTest( const wxPoint& aPosRef )
/************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef );
}
/***********************************************************************************/
SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_HIERLABEL )
@ -405,6 +400,7 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const
{
bool success = true;
const char* shape = "~";
if( m_Italic )
shape = "Italic";
if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
@ -420,15 +416,18 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const
return success;
}
/************************************************/
bool SCH_HIERLABEL::HitTest( const wxPoint& aPosRef )
/************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef );
}
@ -450,10 +449,10 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
/* Texts type Global Label have 4 directions, and the Text origin is the graphic icon
*/
{
int Poly[40];
static std::vector <wxPoint> Poly;
int ii;
EDA_Colors color;
wxPoint AnchorPos = m_Pos + offset;;
wxPoint AnchorPos = m_Pos + offset;
int width = MAX( m_Width, g_DrawMinimunLineWidth );
@ -498,7 +497,7 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
}
CreateGraphicShape( Poly, AnchorPos );
GRPoly( &panel->m_ClipBox, DC, Poly[0], (wxPoint*)(Poly + 1), 0, width, color, color );
GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, width, color, color );
if( m_IsDangling )
DrawDanglingSymbol( panel, DC, m_Pos + offset, color );
@ -508,29 +507,33 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
/**
* Function CreateGraphicShape
* calculates the graphic shape (a polygon) associated to the text
* @param corner_list = coordinates list fill with polygon corners ooordinates (size > 20)
* @param aCorner_list = coordinates list fill with polygon corners ooordinates (size > 20)
* @param Pos = Postion of the shape
* format list is
* corner_count, x0, y0, ... xn, yn
*/
void SCH_HIERLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos )
void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos )
{
int* Template = TemplateShape[m_Shape][m_Orient];
int HalfSize = m_Size.x / 2;
int imax = *Template; Template++;
*corner_list++ = imax;
aCorner_list.clear();
for( int ii = 0; ii < imax; ii++ )
{
*corner_list++ = ( HalfSize * (*Template) ) + Pos.x;
wxPoint corner;
corner.x = ( HalfSize * (*Template) ) + Pos.x;
Template++;
*corner_list++ = ( HalfSize * (*Template) ) + Pos.y;
corner.y = ( HalfSize * (*Template) ) + Pos.y;
Template++;
aCorner_list.push_back( corner );
}
}
/****************************************/
EDA_Rect SCH_HIERLABEL::GetBoundingBox()
/****************************************/
@ -581,6 +584,7 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox()
return box;
}
/*******************************************************************************************/
void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& draw_offset,
int DrawMode, int Color )
@ -589,7 +593,7 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& dr
/* Texts type Global Label have 4 directions, and the Text origin is the graphic icon
*/
{
int Poly[20];
static std::vector <wxPoint> Poly;
int offset;
EDA_Colors color;
int HalfSize;
@ -655,7 +659,7 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& dr
}
CreateGraphicShape( Poly, AnchorPos );
GRPoly( &panel->m_ClipBox, DC, Poly[0], (wxPoint*) (Poly + 1), 0, width, color, color );
GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, width, color, color );
if( m_IsDangling )
DrawDanglingSymbol( panel, DC, AnchorPos, color );
@ -664,28 +668,27 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& dr
/** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text
* @param corner_list = oordinates list fill with polygon corners ooordinates (size >= 14)
* @param Pos = Postion of the shape
* format list is
* <corner_count>, x0, y0, ... xn, yn
* @param aCorner_list = list to fill with polygon corners coordinates
* @param Pos = Position of the shape
*/
void SCH_GLOBALLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos )
void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos )
{
int HalfSize = m_Size.y / 2;
int width = MAX( m_Width, g_DrawMinimunLineWidth );
*corner_list = 7; corner_list++; // 7 corners in list
aCorner_list.clear();
int symb_len = ( Pitch( width ) * NegableTextLength( m_Text ) ) + (TXTMARGE * 2);
// Create outline shape : 6 points
int x = symb_len + width + 3;
int y = HalfSize*1.5 + width + 3; /* 50% more for negation bar */
corner_list[0] = 0; corner_list[1] = 0; // Starting point (anchor)
corner_list[2] = 0; corner_list[3] = -y; // Up
corner_list[4] = -x; corner_list[5] = -y; // left Up
corner_list[6] = -x; corner_list[7] = 0; // left
corner_list[8] = -x; corner_list[9] = y; // left down
corner_list[10] = 0; corner_list[11] = y; // down
int y = HalfSize * 1.5 + width + 3; // 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
int x_offset = 0;
@ -693,18 +696,18 @@ void SCH_GLOBALLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos )
{
case NET_INPUT:
x_offset = -HalfSize;
corner_list[0] += HalfSize;
aCorner_list[0].x += HalfSize;
break;
case NET_OUTPUT:
corner_list[6] -= HalfSize;
aCorner_list[3].x -= HalfSize;
break;
case NET_BIDI:
case NET_TRISTATE:
x_offset = -HalfSize;
corner_list[0] += HalfSize;
corner_list[6] -= HalfSize;
aCorner_list[0].x += HalfSize;
aCorner_list[3].x -= HalfSize;
break;
case NET_UNSPECIFIED:
@ -732,17 +735,16 @@ void SCH_GLOBALLABEL::CreateGraphicShape( int* corner_list, const wxPoint& Pos )
break;
}
// Rotate outlines and move in real position
for( int ii = 0; ii < 12; ii += 2 )
// Rotate outlines and move corners in real position
for( unsigned ii = 0; ii < aCorner_list.size(); ii ++ )
{
corner_list[ii] += x_offset;
aCorner_list[ii].x += x_offset;
if( angle )
RotatePoint( &corner_list[ii], &corner_list[ii + 1], angle );
corner_list[ii] += Pos.x;
corner_list[ii + 1] += Pos.y;
RotatePoint( &aCorner_list[ii], angle );
aCorner_list[ii] += Pos;
}
corner_list[12] = corner_list[0]; corner_list[13] = corner_list[1]; // closing
aCorner_list.push_back( aCorner_list[0] ); // closing
}
@ -758,7 +760,8 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
int width = MAX( m_Width, g_DrawMinimunLineWidth );
height = m_Size.y + 2 * TXTMARGE;
length = ( Pitch(width) * NegableTextLength(m_Text) ) + 2* height + 2*DANGLING_SYMBOL_SIZE; // add 2*height for triangular shapes (bidirectional)
length =
( Pitch( width ) * NegableTextLength( m_Text ) ) + 2 * height + 2 * DANGLING_SYMBOL_SIZE; // add 2*height for triangular shapes (bidirectional)
switch( m_Orient ) // respect orientation
{
@ -845,4 +848,3 @@ EDA_Rect SCH_TEXT::GetBoundingBox()
box.Normalize();
return box;
}

View File

@ -112,15 +112,6 @@ public:
}
/** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text
* @param corner_list = coordinates list fill with polygon corners ooordinates (size > 20)
* @param Pos = Postion of the shape
* format list is
* <corner_count>, x0, y0, ... xn, yn
*/
void CreateGraphicShape( int* corner_list, const wxPoint & Pos );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
@ -136,6 +127,16 @@ public:
bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox();
/** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = coordinates list fill with polygon corners ooordinates
* @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 );
};
@ -157,12 +158,12 @@ public:
/** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text
* @param corner_list = coordinates list fill with polygon corners ooordinates (size >= 14)
* @param aCorner_list = coordinates list fill with polygon corners ooordinates
* @param Pos = Postion of the shape
* format list is
* <corner_count>, x0, y0, ... xn, yn
*/
void CreateGraphicShape( int* corner_list, const wxPoint & Pos );
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint & Pos );
/**
* Function Save

View File

@ -21,22 +21,7 @@
int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText )
{
int ret;
bool multiline;
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 );
// doing any post construction resizing is better done here than in
// OnInitDialog() since it tends to flash/redraw the dialog less.
@ -49,8 +34,8 @@ int DialogLabelEditor::ShowModally( WinEDA_SchematicFrame* parent, SCH_TEXT * C
DialogLabelEditor::DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT* CurrentText,bool multiline ) :
DialogLabelEditor_Base( parent,wxID_ANY,multiline )
DialogLabelEditor::DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT* CurrentText ) :
DialogLabelEditor_Base( parent )
{
m_Parent = parent;
m_CurrentText = CurrentText;

View File

@ -18,7 +18,7 @@ private:
protected:
// these are protected so that the static ShowModally() gets used.
DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText, bool multiline);
DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText);
~DialogLabelEditor(){};

View File

@ -9,31 +9,23 @@
///////////////////////////////////////////////////////////////////////////
DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id, bool multiline, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxVERTICAL );
bSizerTextCtrl = new wxBoxSizer( wxVERTICAL );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("Text"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
bSizer2->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
bSizerTextCtrl->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
if (multiline)
{
m_TextLabel = new wxTextCtrl( this, wxID_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER | wxTE_MULTILINE );
}
else
{
m_TextLabel = new wxTextCtrl( this, wxID_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
}
m_TextLabel->SetToolTip( _("Enter the text to be used within the schematic") );
bSizer2->Add( m_TextLabel, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bSizerTextCtrl->Add( m_TextLabel, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
wxBoxSizer* m_OptionsSizer;
m_OptionsSizer = new wxBoxSizer( wxHORIZONTAL );
@ -56,9 +48,9 @@ DialogLabelEditor_Base::DialogLabelEditor_Base( wxWindow* parent, wxWindowID id,
m_TextShape->SetSelection( 0 );
m_OptionsSizer->Add( m_TextShape, 1, wxALL, 5 );
bSizer2->Add( m_OptionsSizer, 1, wxEXPAND, 5 );
bSizerTextCtrl->Add( m_OptionsSizer, 1, wxEXPAND, 5 );
bMainSizer->Add( bSizer2, 5, wxEXPAND, 5 );
bMainSizer->Add( bSizerTextCtrl, 5, wxEXPAND, 5 );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxVERTICAL );

View File

@ -32,7 +32,7 @@
<property name="minimum_size"></property>
<property name="name">DialogLabelEditor_Base</property>
<property name="pos"></property>
<property name="size">600,300</property>
<property name="size">600,216</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property>
<property name="title">Text Editor</property>
@ -81,9 +81,9 @@
<property name="proportion">5</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer2</property>
<property name="name">bSizerTextCtrl</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>

View File

@ -38,6 +38,7 @@ class DialogLabelEditor_Base : public wxDialog
wxID_SIZE,
};
wxBoxSizer* bSizerTextCtrl;
wxStaticText* m_staticText1;
wxTextCtrl* m_TextLabel;
wxRadioBox* m_TextOrient;
@ -56,7 +57,7 @@ class DialogLabelEditor_Base : public wxDialog
public:
DialogLabelEditor_Base( wxWindow* parent, wxWindowID id = wxID_ANY, bool multiline = false, const wxString& title = _("Text Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 600,300 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DialogLabelEditor_Base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 600,216 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DialogLabelEditor_Base();
};

View File

@ -15,6 +15,7 @@
#include "general.h"
#include <wx/dcps.h>
#include "dialog_print_using_printer_base.h"
@ -275,7 +276,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
wxString title = _("Preview");
EDA_Printout printout( this, m_Parent, title, print_ref );
#ifndef __WINDOWS__
#if !defined(__WINDOWS__) && !wxCHECK_VERSION(2,9,0)
wxDC* dc = printout.GetDC();
( (wxPostScriptDC*) dc )->SetResolution( 600 ); // Postscript DC resolution is 600 ppi
#endif

View File

@ -311,7 +311,7 @@ void Write_GENERIC_NetList( WinEDA_SchematicFrame* frame,
fprintf( tmpfile, "Footprint=%s\n", CONV_TO_UTF8( FootprintName ) );
Line = wxT( "Reference=" ) + Component->GetRef( sheet ) + wxT( "\n" );
Line.Replace( wxT( " " ), wxT( "_" ) );
fprintf( tmpfile, CONV_TO_UTF8( Line ) );
fputs( CONV_TO_UTF8( Line ), tmpfile );
Line = Component->GetField( VALUE )->m_Text;
Line.Replace( wxT( " " ), wxT( "_" ) );

View File

@ -613,23 +613,20 @@ void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame )
if( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE )
ADD_MENUITEM( PopMenu, ID_POPUP_ZOOM_BLOCK,
_( "Zoom Block" ), zoom_selected_xpm );
_( "Window Zoom" ), zoom_selected_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), apply_xpm );
if( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE )
{
wxMenu* menu_other_block_commands = new wxMenu;
ADD_MENUITEM_WITH_SUBMENU( PopMenu, menu_other_block_commands,
-1, _( "Other Block Commands" ), right_xpm );
ADD_MENUITEM( menu_other_block_commands, wxID_COPY, _( "Save Block" ), copy_button );
ADD_MENUITEM( menu_other_block_commands, ID_POPUP_COPY_BLOCK,
{ // After a block move (that is also a block selection) one can reselect a block function:
ADD_MENUITEM( PopMenu, wxID_COPY, _( "Save Block" ), copy_button );
ADD_MENUITEM( PopMenu, ID_POPUP_COPY_BLOCK,
_( "Copy Block" ), copyblock_xpm );
ADD_MENUITEM( menu_other_block_commands, ID_POPUP_DRAG_BLOCK,
ADD_MENUITEM( PopMenu, ID_POPUP_DRAG_BLOCK,
_( "Drag Block" ), move_xpm );
ADD_MENUITEM( menu_other_block_commands, ID_POPUP_DELETE_BLOCK,
ADD_MENUITEM( PopMenu, ID_POPUP_DELETE_BLOCK,
_( "Delete Block" ), delete_xpm );
ADD_MENUITEM( menu_other_block_commands, ID_POPUP_MIRROR_Y_BLOCK, _(
ADD_MENUITEM( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, _(
"Mirror Block ||" ), mirror_H_xpm );
#if 0
#ifdef __WINDOWS__

View File

@ -616,7 +616,7 @@ void PlotTextStruct( EDA_BaseStruct* Struct )
* Les textes peuvent avoir 4 directions.
*/
{
int Poly[50];
static std::vector <wxPoint> Poly;
int pX, pY, Shape = 0, Orient = 0, offset;
wxSize Size;
wxString Text;
@ -737,12 +737,12 @@ void PlotTextStruct( EDA_BaseStruct* Struct )
if( Struct->Type() == TYPE_SCH_GLOBALLABEL )
{
( (SCH_GLOBALLABEL*) Struct )->CreateGraphicShape( Poly, wxPoint(pX, pY) );
PlotPoly( Poly[0], Poly + 1, NOFILL );
PlotPoly( Poly.size(), &Poly[0].x, NOFILL );
}
if( Struct->Type() == TYPE_SCH_HIERLABEL )
{
( (SCH_HIERLABEL*) Struct )->CreateGraphicShape( Poly, wxPoint(pX, pY) );
PlotPoly( Poly[0], Poly + 1, NOFILL );
PlotPoly( Poly.size(), &Poly[0].x, NOFILL );
}
}

View File

@ -114,7 +114,8 @@ void WinEDA_LibeditFrame::ReCreateHToolbar()
SetToolBar( m_HToolBar );
// Set up toolbar
m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_LIB, wxEmptyString, wxBitmap( save_library_xpm ),
m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_LIB, wxEmptyString,
wxBitmap( save_library_xpm ),
_( "Save current loaded library on disk (file update)" ) );
m_HToolBar->AddTool( ID_LIBEDIT_SELECT_CURRENT_LIB, wxEmptyString, wxBitmap( library_xpm ),
@ -127,7 +128,8 @@ void WinEDA_LibeditFrame::ReCreateHToolbar()
m_HToolBar->AddTool( ID_LIBEDIT_NEW_PART, wxEmptyString, wxBitmap( new_component_xpm ),
_( "New component" ) );
m_HToolBar->AddTool( ID_LIBEDIT_SELECT_PART, wxBitmap( add_component_xpm ),
m_HToolBar->AddTool( ID_LIBEDIT_SELECT_PART, wxEmptyString,
wxBitmap( add_component_xpm ),
_( "Select component to edit" ) );
m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_PART, wxEmptyString,
@ -151,23 +153,17 @@ void WinEDA_LibeditFrame::ReCreateHToolbar()
m_HToolBar->AddTool( ID_LIBEDIT_REDO, wxEmptyString, wxBitmap( redo_xpm ), msg );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_PART, wxBitmap( part_properties_xpm ),
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
m_HToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_PART, wxEmptyString,
wxBitmap( part_properties_xpm ),
_( "Edit component properties" ) );
m_HToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, wxBitmap( add_text_xpm ),
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
m_HToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, wxEmptyString,
wxBitmap( add_text_xpm ),
_( "Add, remove fields and edit fields properties" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxBitmap( erc_xpm ),
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
m_HToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxEmptyString,
wxBitmap( erc_xpm ),
_( "Test duplicate pins" ) );
m_HToolBar->AddSeparator();
@ -201,10 +197,8 @@ void WinEDA_LibeditFrame::ReCreateHToolbar()
(CurrentConvert >= 2) ? TRUE : FALSE );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_LIBEDIT_VIEW_DOC, wxBitmap( datasheet_xpm ),
wxNullBitmap,
FALSE,
-1, -1, (wxObject*) NULL,
m_HToolBar->AddTool( ID_LIBEDIT_VIEW_DOC, wxEmptyString,
wxBitmap( datasheet_xpm ),
_( "Documents" ) );
m_HToolBar->EnableTool( ID_LIBEDIT_VIEW_DOC, FALSE );
@ -218,10 +212,8 @@ void WinEDA_LibeditFrame::ReCreateHToolbar()
m_HToolBar->AddControl( m_SelAliasBox );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, wxBitmap( pin2pin_xpm ),
wxNullBitmap,
TRUE,
-1, -1, (wxObject*) NULL,
m_HToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, wxEmptyString,
wxBitmap( pin2pin_xpm ),
_( "Edit pins part per part (Carefully use!)" ) );
m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn );

View File

@ -135,7 +135,10 @@ bool WinEDA_GerberFrame::LoadOneGerberFile( const wxString& FullFileName,
g_PenFilenameExt.c_str(), g_PenFilenameExt.c_str());
wildcard += AllFilesWildcard;
wxFileDialog dlg( this, _( "Open Gerber File" ), fn.GetPath(),
wxString currpath = fn.GetPath();
if ( currpath.IsEmpty() )
currpath = wxGetCwd();
wxFileDialog dlg( this, _( "Open Gerber File" ), currpath,
fn.GetFullName(), wildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST );

View File

@ -499,6 +499,8 @@ public:
bool m_Italic; /* true to simulate an italic font... */
GRTextHorizJustifyType m_HJustify; /* Horiz Justify */
GRTextVertJustifyType m_VJustify; /* Vertical and Vert Justify */
bool m_MultilineAllowed; /* true to use multiline option, false to use only single line text
* Single line is faster in calculations than multiline */
public:
EDA_TextStruct( const wxString& text = wxEmptyString );

View File

@ -19,6 +19,7 @@ TEXTE_PCB::TEXTE_PCB( BOARD_ITEM* parent ) :
BOARD_ITEM( parent, TYPE_TEXTE ),
EDA_TextStruct()
{
m_MultilineAllowed = true;
}
@ -43,6 +44,7 @@ void TEXTE_PCB::Copy( TEXTE_PCB* source )
m_Italic = source->m_Italic;
m_HJustify = source->m_HJustify;
m_VJustify = source->m_VJustify;
m_MultilineAllowed = m_MultilineAllowed;
m_Text = source->m_Text;
}