From b49c2d2b9df0613ecf6b4cfbf9f9394a617e50ab Mon Sep 17 00:00:00 2001 From: charras Date: Tue, 5 May 2009 17:32:07 +0000 Subject: [PATCH] code cleanup, remove multiline text option in eeschema (multiline text is a work in progress) and minor enhancements --- CMakeLists.txt | 4 +- common/about_kicad.cpp | 2 +- common/base_struct.cpp | 56 ++- common/drawtxt.cpp | 85 ++-- common/edaappl.cpp | 8 - eeschema/build_BOM.cpp | 14 +- eeschema/class_screen.cpp | 4 - eeschema/class_text-label.cpp | 528 ++++++++++++------------ eeschema/class_text-label.h | 23 +- eeschema/dialog_edit_label.cpp | 21 +- eeschema/dialog_edit_label.h | 2 +- eeschema/dialog_edit_label_base.cpp | 26 +- eeschema/dialog_edit_label_base.fbp | 6 +- eeschema/dialog_edit_label_base.h | 3 +- eeschema/dialog_print_using_printer.cpp | 3 +- eeschema/netform.cpp | 2 +- eeschema/onrightclick.cpp | 17 +- eeschema/plot.cpp | 6 +- eeschema/tool_lib.cpp | 80 ++-- gerbview/files.cpp | 5 +- include/base_struct.h | 2 + pcbnew/class_pcb_text.cpp | 2 + 22 files changed, 429 insertions(+), 470 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 677444486e..448f0baa27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)") diff --git a/common/about_kicad.cpp b/common/about_kicad.cpp index 0351269630..22e502f6c7 100644 --- a/common/about_kicad.cpp +++ b/common/about_kicad.cpp @@ -8,7 +8,7 @@ #include "appl_wxstruct.h" -#define BUILD_VERSION wxT("(20090421-unstable)") +#define BUILD_VERSION wxT("(20090504-unstable)") wxString g_BuildVersion diff --git a/common/base_struct.cpp b/common/base_struct.cpp index 6f471ff8be..4c3a349650 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -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 @@ -278,19 +279,37 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, */ { - wxPoint pos = m_Pos; - wxArrayString* list = wxStringSplit( m_Text, '\n' ); - wxPoint offset; - offset.y = (int) (m_Size.y * 1.5 ); - - RotatePoint( &offset, m_Orient ); - if( m_Mirror ) - offset.x = -offset.x; - - for( unsigned i = 0; iCount(); i++ ) + if ( m_MultilineAllowed ) { - wxString txt = list->Item( i ); + wxPoint pos = m_Pos; + wxArrayString* list = wxStringSplit( m_Text, '\n' ); + wxPoint offset; + + offset.y = (int) (m_Size.y * 1.5 ); + + RotatePoint( &offset, m_Orient ); + if( m_Mirror ) + offset.x = -offset.x; + for( unsigned i = 0; iCount(); i++ ) + { + wxString txt = list->Item( i ); + DrawOneLineOfText( aPanel, + aDC, + aOffset, + aColor, + aDrawMode, + aDisplayMode, + aAnchor_color, + txt, + pos ); + pos += offset; + } + + delete (list); + } + + else DrawOneLineOfText( aPanel, aDC, aOffset, @@ -298,12 +317,8 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, aDrawMode, aDisplayMode, aAnchor_color, - txt, - pos ); - pos += offset; - } - - delete (list); + m_Text, + m_Pos ); } @@ -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 ); } diff --git a/common/drawtxt.cpp b/common/drawtxt.cpp index f854279952..21006da419 100644 --- a/common/drawtxt.cpp +++ b/common/drawtxt.cpp @@ -189,69 +189,48 @@ 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 */ - if( (aOrient == 0) || (aOrient == 1800) ) /* Horizontal Text */ + 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 ); + + switch( aH_justify ) { - switch( aH_justify ) - { - case GR_TEXT_HJUSTIFY_CENTER: - break; + case GR_TEXT_HJUSTIFY_CENTER: + break; - case GR_TEXT_HJUSTIFY_RIGHT: - ux0 = -dx; - break; + case GR_TEXT_HJUSTIFY_RIGHT: + ux0 = -offset_org.x; + break; - case GR_TEXT_HJUSTIFY_LEFT: - ux0 = dx; - break; - } - - switch( aV_justify ) - { - case GR_TEXT_VJUSTIFY_CENTER: - break; - - case GR_TEXT_VJUSTIFY_TOP: - uy0 = dy; - break; - - case GR_TEXT_VJUSTIFY_BOTTOM: - uy0 = -dy; - break; - } + case GR_TEXT_HJUSTIFY_LEFT: + ux0 = offset_org.x; + break; } - else /* Vertical Text */ + + switch( aV_justify ) { - switch( aH_justify ) - { - case GR_TEXT_HJUSTIFY_CENTER: - break; + case GR_TEXT_VJUSTIFY_CENTER: + break; - case GR_TEXT_HJUSTIFY_RIGHT: - ux0 = -dy; - break; + case GR_TEXT_VJUSTIFY_TOP: + uy0 = offset_org.y; + break; - case GR_TEXT_HJUSTIFY_LEFT: - ux0 = dy; - 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; - } + case GR_TEXT_VJUSTIFY_BOTTOM: + uy0 = -offset_org.y; + break; } + cX += ux0; cY += uy0; diff --git a/common/edaappl.cpp b/common/edaappl.cpp index 91409c6bf7..ce1f8c34b4 100644 --- a/common/edaappl.cpp +++ b/common/edaappl.cpp @@ -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; } diff --git a/eeschema/build_BOM.cpp b/eeschema/build_BOM.cpp index b18e54f2eb..d79613a622 100644 --- a/eeschema/build_BOM.cpp +++ b/eeschema/build_BOM.cpp @@ -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 & 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 & 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 & aList ) } msg = _( "#End labels\n" ); - fprintf( f, CONV_TO_UTF8( msg ) ); + fputs( CONV_TO_UTF8( msg ), f ); return 0; } diff --git a/eeschema/class_screen.cpp b/eeschema/class_screen.cpp index 7de56ae282..f64df3d9a5 100644 --- a/eeschema/class_screen.cpp +++ b/eeschema/class_screen.cpp @@ -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 } diff --git a/eeschema/class_text-label.cpp b/eeschema/class_text-label.cpp index 4af657256e..1c3e3150ca 100644 --- a/eeschema/class_text-label.cpp +++ b/eeschema/class_text-label.cpp @@ -34,53 +34,59 @@ const char* SheetLabelType[] = "?????" }; -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 }; -int TemplateIN_UP[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 }; +/* 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 }; +int TemplateIN_UP[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 }; -int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 }; -int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 }; -int TemplateOUT_BOTTOM[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 }; -int TemplateOUT_UP[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 }; +int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 }; +int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 }; +int TemplateOUT_BOTTOM[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 }; +int TemplateOUT_UP[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 }; -int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 }; -int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 }; -int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 }; -int TemplateUNSPC_UP[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 }; +int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 }; +int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 }; +int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 }; +int TemplateUNSPC_UP[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 }; -int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 }; -int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 }; -int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 }; -int TemplateBIDI_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }; +int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 }; +int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 }; +int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 }; +int TemplateBIDI_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }; -int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 }; -int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 }; -int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 }; -int Template3STATE_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }; +int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 }; +int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 }; +int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 }; +int Template3STATE_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }; int* TemplateShape[5][4] = { - { TemplateIN_HN, TemplateIN_UP, TemplateIN_HI, TemplateIN_BOTTOM }, - { TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI, TemplateOUT_BOTTOM }, - { TemplateBIDI_HN, TemplateBIDI_UP, TemplateBIDI_HI, TemplateBIDI_BOTTOM }, - { Template3STATE_HN, Template3STATE_UP, Template3STATE_HI, Template3STATE_BOTTOM }, - { TemplateUNSPC_HN, TemplateUNSPC_UP, TemplateUNSPC_HI, TemplateUNSPC_BOTTOM } + { TemplateIN_HN, TemplateIN_UP, TemplateIN_HI, TemplateIN_BOTTOM }, + { TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI, TemplateOUT_BOTTOM }, + { TemplateBIDI_HN, TemplateBIDI_UP, TemplateBIDI_HI, TemplateBIDI_BOTTOM }, + { Template3STATE_HN, Template3STATE_UP, Template3STATE_HI, Template3STATE_BOTTOM }, + { TemplateUNSPC_HN, TemplateUNSPC_UP, TemplateUNSPC_HI, TemplateUNSPC_BOTTOM } }; /**************************************************************************/ 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; - m_Pos = pos; - m_Shape = 0; + m_Layer = LAYER_NOTES; + m_Pos = pos; + m_Shape = 0; 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,86 +179,68 @@ 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, - int DrawMode, int Color ) +void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset, + int DrawMode, int Color ) /*******************************************************************************************/ /* Texts type Comment (text on layer "NOTE") have 4 directions, and the Text origin is the first letter */ { EDA_Colors color; - int width = MAX( m_Width, g_DrawMinimunLineWidth ); + int width = MAX( m_Width, g_DrawMinimunLineWidth ); if( Color >= 0 ) - color = (EDA_Colors)Color; + color = (EDA_Colors) Color; else 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; - + int orientation; + 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; + orientation = TEXT_ORIENT_HORIZ; + 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; + orientation = TEXT_ORIENT_VERT; + 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; + orientation = TEXT_ORIENT_HORIZ; + 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; + orientation = TEXT_ORIENT_VERT; + m_HJustify = GR_TEXT_HJUSTIFY_RIGHT; + m_VJustify = GR_TEXT_VJUSTIFY_TOP; + text_offset.x -= TXTMARGE; break; } - for( unsigned i=0;iCount();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 ); } @@ -263,15 +252,16 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, */ bool SCH_TEXT::Save( FILE* aFile ) const { - bool success = true; - const char * shape = "~"; - if (m_Italic ) + 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", - m_Pos.x, m_Pos.y, - m_Orient, m_Size.x, - shape, m_Width, - CONV_TO_UTF8( m_Text ) ) == EOF ) + m_Pos.x, m_Pos.y, + m_Orient, m_Size.x, + shape, m_Width, + CONV_TO_UTF8( m_Text ) ) == EOF ) { success = false; } @@ -288,14 +278,15 @@ void SCH_TEXT::Show( int nestLevel, std::ostream& os ) wxString s = GetClass(); NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() - << " layer=\"" << m_Layer << '"' - << " shape=\"" << m_Shape << '"' - << " dangling=\"" << m_IsDangling << '"' - << '>' - << CONV_TO_UTF8( m_Text ) - << "\n"; + << " layer=\"" << m_Layer << '"' + << " shape=\"" << m_Shape << '"' + << " dangling=\"" << m_IsDangling << '"' + << '>' + << CONV_TO_UTF8( m_Text ) + << "\n"; } + #endif /****************************************************************************/ @@ -303,8 +294,8 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) : SCH_TEXT( pos, text, TYPE_SCH_LABEL ) /****************************************************************************/ { - m_Layer = LAYER_LOCLABEL; - m_Shape = NET_INPUT; + m_Layer = LAYER_LOCLABEL; + m_Shape = NET_INPUT; m_IsDangling = TRUE; } @@ -317,15 +308,16 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) : */ bool SCH_LABEL::Save( FILE* aFile ) const { - bool success = true; - const char * shape = "~"; - if (m_Italic ) + bool success = true; + const char* shape = "~"; + + if( m_Italic ) shape = "Italic"; if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %s %d\n%s\n", - m_Pos.x, m_Pos.y, - m_Orient, m_Size.x, shape, m_Width, - CONV_TO_UTF8( m_Text ) ) == EOF ) + m_Pos.x, m_Pos.y, + m_Orient, m_Size.x, shape, m_Width, + CONV_TO_UTF8( m_Text ) ) == EOF ) { success = false; } @@ -339,8 +331,8 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : SCH_TEXT( pos, text, TYPE_SCH_GLOBALLABEL ) /***********************************************************************************/ { - m_Layer = LAYER_GLOBLABEL; - m_Shape = NET_BIDI; + m_Layer = LAYER_GLOBLABEL; + m_Shape = NET_BIDI; m_IsDangling = TRUE; } @@ -353,16 +345,17 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : */ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const { - bool success = true; - const char * shape = "~"; - if (m_Italic ) + 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", - m_Pos.x, m_Pos.y, - m_Orient, m_Size.x, - SheetLabelType[m_Shape], - shape, m_Width, - CONV_TO_UTF8( m_Text ) ) == EOF ) + m_Pos.x, m_Pos.y, + m_Orient, m_Size.x, + SheetLabelType[m_Shape], + shape, m_Width, + CONV_TO_UTF8( m_Text ) ) == EOF ) { success = false; } @@ -370,27 +363,29 @@ 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 ) /***********************************************************************************/ { - m_Layer = LAYER_HIERLABEL; - m_Shape = NET_INPUT; + m_Layer = LAYER_HIERLABEL; + m_Shape = NET_INPUT; m_IsDangling = TRUE; } @@ -403,16 +398,17 @@ SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) : */ bool SCH_HIERLABEL::Save( FILE* aFile ) const { - bool success = true; - const char * shape = "~"; - if (m_Italic ) + 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", - m_Pos.x, m_Pos.y, - m_Orient, m_Size.x, - SheetLabelType[m_Shape], - shape, m_Width, - CONV_TO_UTF8( m_Text ) ) == EOF ) + m_Pos.x, m_Pos.y, + m_Orient, m_Size.x, + SheetLabelType[m_Shape], + shape, m_Width, + CONV_TO_UTF8( m_Text ) ) == EOF ) { success = false; } @@ -420,22 +416,25 @@ 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 ); } /*********************************************************************************************/ void SCH_LABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int DrawMode, int Color ) + int DrawMode, int Color ) /*********************************************************************************************/ { SCH_TEXT::Draw( panel, DC, offset, DrawMode, Color ); @@ -444,21 +443,21 @@ void SCH_LABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, /*******************************************************************************************/ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, - int DrawMode, int Color ) + int DrawMode, int Color ) /******************************************************************************************/ /* Texts type Global Label have 4 directions, and the Text origin is the graphic icon */ { - int Poly[40]; - int ii; + static std::vector Poly; + int ii; EDA_Colors color; - wxPoint AnchorPos = m_Pos + offset;; + wxPoint AnchorPos = m_Pos + offset; - int width = MAX( m_Width, g_DrawMinimunLineWidth ); + int width = MAX( m_Width, g_DrawMinimunLineWidth ); if( Color >= 0 ) - color = (EDA_Colors)Color; + color = (EDA_Colors) Color; else color = ReturnLayerColor( m_Layer ); @@ -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,104 +507,109 @@ 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 & 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() /****************************************/ { int x, y, dx, dy, length, height; - x = m_Pos.x; - y = m_Pos.y; + x = m_Pos.x; + y = m_Pos.y; dx = dy = 0; - int width = MAX( m_Width, g_DrawMinimunLineWidth ); - height = m_Size.y + 2*TXTMARGE; - length = ( Pitch(width) * NegableTextLength(m_Text) ) + height + 2*DANGLING_SYMBOL_SIZE; // add height for triangular shapes + int width = MAX( m_Width, g_DrawMinimunLineWidth ); + height = m_Size.y + 2 * TXTMARGE; + length = ( Pitch( width ) * NegableTextLength( m_Text ) ) + height + 2 * DANGLING_SYMBOL_SIZE; // add height for triangular shapes - switch( m_Orient ) // respect orientation + switch( m_Orient ) // respect orientation { - case 0: /* Horiz Normal Orientation (left justified) */ - dx = -length; - dy = height; - x += DANGLING_SYMBOL_SIZE; - y -= height/2; - break; + case 0: /* Horiz Normal Orientation (left justified) */ + dx = -length; + dy = height; + x += DANGLING_SYMBOL_SIZE; + y -= height / 2; + break; - case 1: /* Vert Orientation UP */ - dx = height; - dy = length; - x -= height/2; - y -= DANGLING_SYMBOL_SIZE; - break; + case 1: /* Vert Orientation UP */ + dx = height; + dy = length; + x -= height / 2; + y -= DANGLING_SYMBOL_SIZE; + break; - case 2: /* Horiz Orientation - Right justified */ - dx = length; - dy = height; - x -= DANGLING_SYMBOL_SIZE; - y -= height/2; - break; + case 2: /* Horiz Orientation - Right justified */ + dx = length; + dy = height; + x -= DANGLING_SYMBOL_SIZE; + y -= height / 2; + break; - case 3: /* Vert Orientation BOTTOM */ - dx = height; - dy = -length; - x -= height/2; - y += DANGLING_SYMBOL_SIZE; - break; + case 3: /* Vert Orientation BOTTOM */ + dx = height; + dy = -length; + x -= height / 2; + y += DANGLING_SYMBOL_SIZE; + break; } - EDA_Rect box(wxPoint(x,y), wxSize(dx,dy) ); + EDA_Rect box( wxPoint( x, y ), wxSize( dx, dy ) ); box.Normalize(); return box; } + /*******************************************************************************************/ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& draw_offset, - int DrawMode, int Color ) + int DrawMode, int Color ) /******************************************************************************************/ /* Texts type Global Label have 4 directions, and the Text origin is the graphic icon */ { - int Poly[20]; - int offset; + static std::vector Poly; + int offset; EDA_Colors color; - int HalfSize; - wxPoint AnchorPos = m_Pos + draw_offset;; + int HalfSize; + wxPoint AnchorPos = m_Pos + draw_offset;; - int width = MAX( m_Width, g_DrawMinimunLineWidth ); + int width = MAX( m_Width, g_DrawMinimunLineWidth ); if( Color >= 0 ) - color = (EDA_Colors)Color; + color = (EDA_Colors) Color; else color = ReturnLayerColor( m_Layer ); GRSetDrawMode( DC, DrawMode ); HalfSize = m_Size.x / 2; - offset = width; + offset = width; switch( m_Shape ) { @@ -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 - * , 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 & aCorner_list, const wxPoint& Pos ) { int HalfSize = m_Size.y / 2; - int width = MAX( m_Width, g_DrawMinimunLineWidth ); + 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); - 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 } @@ -752,46 +754,47 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() { int x, y, dx, dy, length, height; - x = m_Pos.x; - y = m_Pos.y; + x = m_Pos.x; + y = m_Pos.y; dx = dy = 0; - 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) + 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) - switch( m_Orient ) // respect orientation + switch( m_Orient ) // respect orientation { - case 0: /* Horiz Normal Orientation (left justified) */ - dx = -length; - dy = height; - x += DANGLING_SYMBOL_SIZE; - y -= height/2; - break; + case 0: /* Horiz Normal Orientation (left justified) */ + dx = -length; + dy = height; + x += DANGLING_SYMBOL_SIZE; + y -= height / 2; + break; - case 1: /* Vert Orientation UP */ - dx = height; - dy = length; - x -= height/2; - y -= DANGLING_SYMBOL_SIZE; - break; + case 1: /* Vert Orientation UP */ + dx = height; + dy = length; + x -= height / 2; + y -= DANGLING_SYMBOL_SIZE; + break; - case 2: /* Horiz Orientation - Right justified */ - dx = length; - dy = height; - x -= DANGLING_SYMBOL_SIZE; - y -= height/2; - break; + case 2: /* Horiz Orientation - Right justified */ + dx = length; + dy = height; + x -= DANGLING_SYMBOL_SIZE; + y -= height / 2; + break; - case 3: /* Vert Orientation BOTTOM */ - dx = height; - dy = -length; - x -= height/2; - y += DANGLING_SYMBOL_SIZE; - break; + case 3: /* Vert Orientation BOTTOM */ + dx = height; + dy = -length; + x -= height / 2; + y += DANGLING_SYMBOL_SIZE; + break; } - EDA_Rect box(wxPoint(x,y), wxSize(dx,dy) ); + EDA_Rect box( wxPoint( x, y ), wxSize( dx, dy ) ); box.Normalize(); return box; } @@ -805,44 +808,43 @@ EDA_Rect SCH_TEXT::GetBoundingBox() x = m_Pos.x; y = m_Pos.y; - int width = MAX( m_Width, g_DrawMinimunLineWidth ); - length = ( Pitch(width) * NegableTextLength(m_Text) ); - height = m_Size.y; - dx = dy = 0; + int width = MAX( m_Width, g_DrawMinimunLineWidth ); + length = ( Pitch( width ) * NegableTextLength( m_Text ) ); + height = m_Size.y; + dx = dy = 0; - switch( m_Orient ) // respect orientation + switch( m_Orient ) // respect orientation { - case 0: /* Horiz Normal Orientation (left justified) */ - dx = 2*DANGLING_SYMBOL_SIZE + length; - dy = -2*DANGLING_SYMBOL_SIZE - height - TXTMARGE; - x -= DANGLING_SYMBOL_SIZE; - y += DANGLING_SYMBOL_SIZE; - break; + case 0: /* Horiz Normal Orientation (left justified) */ + dx = 2 * DANGLING_SYMBOL_SIZE + length; + dy = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; + x -= DANGLING_SYMBOL_SIZE; + y += DANGLING_SYMBOL_SIZE; + break; - case 1: /* Vert Orientation UP */ - dx = -2*DANGLING_SYMBOL_SIZE - height - TXTMARGE; - dy = -2*DANGLING_SYMBOL_SIZE - length; - x += DANGLING_SYMBOL_SIZE; - y += DANGLING_SYMBOL_SIZE; - break; + case 1: /* Vert Orientation UP */ + dx = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; + dy = -2 * DANGLING_SYMBOL_SIZE - length; + x += DANGLING_SYMBOL_SIZE; + y += DANGLING_SYMBOL_SIZE; + break; - case 2: /* Horiz Orientation - Right justified */ - dx = -2*DANGLING_SYMBOL_SIZE - length; - dy = -2*DANGLING_SYMBOL_SIZE - height - TXTMARGE; - x += DANGLING_SYMBOL_SIZE; - y += DANGLING_SYMBOL_SIZE; - break; + case 2: /* Horiz Orientation - Right justified */ + dx = -2 * DANGLING_SYMBOL_SIZE - length; + dy = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; + x += DANGLING_SYMBOL_SIZE; + y += DANGLING_SYMBOL_SIZE; + break; - case 3: /* Vert Orientation BOTTOM */ - dx = -2*DANGLING_SYMBOL_SIZE - height - TXTMARGE; - dy = 2*DANGLING_SYMBOL_SIZE + length; - x += DANGLING_SYMBOL_SIZE; - y -= DANGLING_SYMBOL_SIZE; - break; + case 3: /* Vert Orientation BOTTOM */ + dx = -2 * DANGLING_SYMBOL_SIZE - height - TXTMARGE; + dy = 2 * DANGLING_SYMBOL_SIZE + length; + x += DANGLING_SYMBOL_SIZE; + y -= DANGLING_SYMBOL_SIZE; + break; } - EDA_Rect box(wxPoint(x,y), wxSize(dx,dy) ); + EDA_Rect box( wxPoint( x, y ), wxSize( dx, dy ) ); box.Normalize(); return box; } - diff --git a/eeschema/class_text-label.h b/eeschema/class_text-label.h index 062102581c..d5e81b9a1f 100644 --- a/eeschema/class_text-label.h +++ b/eeschema/class_text-label.h @@ -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 - * , 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 + * , x0, y0, ... xn, yn + */ + void CreateGraphicShape( std::vector & 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 * , x0, y0, ... xn, yn */ - void CreateGraphicShape( int* corner_list, const wxPoint & Pos ); + void CreateGraphicShape( std::vector & aCorner_list, const wxPoint & Pos ); /** * Function Save diff --git a/eeschema/dialog_edit_label.cpp b/eeschema/dialog_edit_label.cpp index e2259db1cb..23ecc2dc79 100644 --- a/eeschema/dialog_edit_label.cpp +++ b/eeschema/dialog_edit_label.cpp @@ -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; diff --git a/eeschema/dialog_edit_label.h b/eeschema/dialog_edit_label.h index 6346a9cd71..b6c2d16a2e 100644 --- a/eeschema/dialog_edit_label.h +++ b/eeschema/dialog_edit_label.h @@ -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(){}; diff --git a/eeschema/dialog_edit_label_base.cpp b/eeschema/dialog_edit_label_base.cpp index c20fb9cbad..cc4c884917 100644 --- a/eeschema/dialog_edit_label_base.cpp +++ b/eeschema/dialog_edit_label_base.cpp @@ -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 ); + m_staticText1 = new wxStaticText( this, wxID_ANY, _("Text"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText1->Wrap( -1 ); + 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 = 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 ); diff --git a/eeschema/dialog_edit_label_base.fbp b/eeschema/dialog_edit_label_base.fbp index 3877254ff8..45c0f51c16 100644 --- a/eeschema/dialog_edit_label_base.fbp +++ b/eeschema/dialog_edit_label_base.fbp @@ -32,7 +32,7 @@ DialogLabelEditor_Base - 600,300 + 600,216 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER Text Editor @@ -81,9 +81,9 @@ 5 - bSizer2 + bSizerTextCtrl wxVERTICAL - none + protected 5 wxTOP|wxRIGHT|wxLEFT diff --git a/eeschema/dialog_edit_label_base.h b/eeschema/dialog_edit_label_base.h index 8730323dac..fa3b1b2c52 100644 --- a/eeschema/dialog_edit_label_base.h +++ b/eeschema/dialog_edit_label_base.h @@ -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(); }; diff --git a/eeschema/dialog_print_using_printer.cpp b/eeschema/dialog_print_using_printer.cpp index 92916d9f13..49ab38a3f5 100644 --- a/eeschema/dialog_print_using_printer.cpp +++ b/eeschema/dialog_print_using_printer.cpp @@ -15,6 +15,7 @@ #include "general.h" #include + #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 diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 9496afb72e..2b91a5441b 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -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( "_" ) ); diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index c4d34e9eb5..26ca369257 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -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__ diff --git a/eeschema/plot.cpp b/eeschema/plot.cpp index 6ff26a86da..52b5fbe975 100644 --- a/eeschema/plot.cpp +++ b/eeschema/plot.cpp @@ -616,7 +616,7 @@ void PlotTextStruct( EDA_BaseStruct* Struct ) * Les textes peuvent avoir 4 directions. */ { - int Poly[50]; + static std::vector 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 ); } } diff --git a/eeschema/tool_lib.cpp b/eeschema/tool_lib.cpp index 0de962b37e..b08761813c 100644 --- a/eeschema/tool_lib.cpp +++ b/eeschema/tool_lib.cpp @@ -114,61 +114,57 @@ void WinEDA_LibeditFrame::ReCreateHToolbar() SetToolBar( m_HToolBar ); // Set up toolbar - 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_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 ), - _( "Select working library" ) ); + _( "Select working library" ) ); m_HToolBar->AddTool( ID_LIBEDIT_DELETE_PART, wxEmptyString, wxBitmap( delete_xpm ), - _( "Delete component in current library" ) ); + _( "Delete component in current library" ) ); m_HToolBar->AddSeparator(); m_HToolBar->AddTool( ID_LIBEDIT_NEW_PART, wxEmptyString, wxBitmap( new_component_xpm ), - _( "New component" ) ); + _( "New component" ) ); - m_HToolBar->AddTool( ID_LIBEDIT_SELECT_PART, wxBitmap( add_component_xpm ), - _( "Select component to edit" ) ); + 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, - wxBitmap( save_part_in_mem_xpm ), - _( "Save current component into current loaded library (in memory)" ) ); + wxBitmap( save_part_in_mem_xpm ), + _( "Save current component into current loaded library (in memory)" ) ); m_HToolBar->AddTool( ImportPartId, wxEmptyString, wxBitmap( import_xpm ), - _( "import component" ) ); + _( "import component" ) ); m_HToolBar->AddTool( ExportPartId, wxEmptyString, wxBitmap( export_xpm ), - _( "export component" ) ); + _( "export component" ) ); m_HToolBar->AddTool( CreateNewLibAndSavePartId, wxEmptyString, - wxBitmap( new_library_xpm ), - _( "Create a new library an save current component into" ) ); + wxBitmap( new_library_xpm ), + _( "Create a new library an save current component into" ) ); m_HToolBar->AddSeparator(); - msg = AddHotkeyName( _( "Undo last edition" ), s_Schematic_Hokeys_Descr, HK_UNDO ); + msg = AddHotkeyName( _( "Undo last edition" ), s_Schematic_Hokeys_Descr, HK_UNDO ); m_HToolBar->AddTool( ID_LIBEDIT_UNDO, wxEmptyString, wxBitmap( undo_xpm ), msg ); - msg = AddHotkeyName( _( "Redo the last undo command" ), s_Schematic_Hokeys_Descr, HK_REDO ); + msg = AddHotkeyName( _( "Redo the last undo command" ), s_Schematic_Hokeys_Descr, HK_REDO ); 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, - _( "Edit component properties" ) ); + 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, - _( "Add, remove fields and edit fields properties" ) ); + 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, - _( "Test duplicate pins" ) ); + m_HToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxEmptyString, + wxBitmap( erc_xpm ), + _( "Test duplicate pins" ) ); m_HToolBar->AddSeparator(); msg = AddHotkeyName( _( "Zoom in" ), s_Libedit_Hokeys_Descr, HK_ZOOM_IN ); @@ -184,8 +180,8 @@ void WinEDA_LibeditFrame::ReCreateHToolbar() msg ); m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, - wxBitmap( zoom_auto_xpm ), - _( "Zoom auto" ) ); + wxBitmap( zoom_auto_xpm ), + _( "Zoom auto" ) ); m_HToolBar->AddSeparator(); m_HToolBar->AddTool( ID_DE_MORGAN_NORMAL_BUTT, wxEmptyString, @@ -201,28 +197,24 @@ 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, - _( "Documents" ) ); + m_HToolBar->AddTool( ID_LIBEDIT_VIEW_DOC, wxEmptyString, + wxBitmap( datasheet_xpm ), + _( "Documents" ) ); m_HToolBar->EnableTool( ID_LIBEDIT_VIEW_DOC, FALSE ); m_HToolBar->AddSeparator(); m_SelpartBox = new WinEDAChoiceBox( m_HToolBar, ID_LIBEDIT_SELECT_PART_NUMBER, - wxDefaultPosition, wxSize( LISTBOX_WIDTH, -1 ) ); + wxDefaultPosition, wxSize( LISTBOX_WIDTH, -1 ) ); m_HToolBar->AddControl( m_SelpartBox ); m_SelAliasBox = new WinEDAChoiceBox( m_HToolBar, ID_LIBEDIT_SELECT_ALIAS, - wxDefaultPosition, wxSize( LISTBOX_WIDTH, -1 ) ); + wxDefaultPosition, wxSize( LISTBOX_WIDTH, -1 ) ); 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, - _( "Edit pins part per part (Carefully use!)" ) ); + 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 ); // after adding the buttons to the toolbar, must call Realize() to reflect the changes diff --git a/gerbview/files.cpp b/gerbview/files.cpp index fcf59469e7..035ee0c212 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -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 ); diff --git a/include/base_struct.h b/include/base_struct.h index 63c2ce382a..a44451f1f3 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -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 ); diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index 84e3675c1d..dee5cadef5 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -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; }