diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 11a4790b36..0ee1d024ab 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,6 +5,15 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. +2008-Dec-14 UPDATE Jean-Pierre Charras +================================================================================ +++All + Cleaning code to draw/plot texts (work in progress): + Now only one function is used to draw and plot texts + (easier to maintain and ensure textes have the same size in ploting and drawing) + In eeschema, italic and bold texts allowed (in pcbenew, texts thicness is already adjustable) + + 2008-Dec-18 UPDATE Wayne Stambaugh ================================================================================ ++all diff --git a/common/base_struct.cpp b/common/base_struct.cpp index a10d487235..b5b0f96c1b 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -192,7 +192,7 @@ int EDA_TextStruct::Len_Size() if( nbchar == 0 ) return 0; - len = ( (10 * m_Size.x ) / 9 ) * nbchar; + len = (( (10 * m_Size.x ) / 9 ) + m_Width) * nbchar; return len; } @@ -210,7 +210,7 @@ bool EDA_TextStruct::HitTest( const wxPoint& posref ) int dx, dy; int spot_cX, spot_cY; - dx = ( Pitch() * GetLength() ) / 2; + dx = (int) (( Pitch() * GetLength() ) / 2); dy = m_Size.y / 2; /* Is the ref point inside the text area ? */ @@ -243,13 +243,15 @@ bool EDA_TextStruct::HitTest( EDA_Rect& refArea ) /*******************************/ -int EDA_TextStruct::Pitch() +int EDA_TextStruct::Pitch(int aMinTickness) /*******************************/ - -/* retourne le pas entre 2 caracteres +/** + * Function Pitch + * @return distance between 2 characters + * @param aMinTickness = min segments tickness */ { - return ( (10 * m_Size.x ) / 9 ) + m_Width; + return ((m_Size.x * 10)/9) + MAX( m_Width, aMinTickness); } diff --git a/common/common_plot_functions.cpp b/common/common_plot_functions.cpp index 80f28a5143..2d5e22943d 100644 --- a/common/common_plot_functions.cpp +++ b/common/common_plot_functions.cpp @@ -100,6 +100,8 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ) wxSize text_size; void (*FctPlume)( wxPoint pos, int state ); int UpperLimit = VARIABLE_BLOCK_START_POSITION; + bool italic = false; + bool thickness = 0; //@todo : use current pen switch( format_plot ) { @@ -176,7 +178,8 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ) if(WsItem->m_Legende) msg = WsItem->m_Legende; PlotGraphicText(format_plot, pos, color, msg, TEXT_ORIENT_VERT, text_size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM); + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, + thickness, italic ); break; case WS_SEGMENT_LU: @@ -221,7 +224,8 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ) pos.y = (ref.y + GRID_REF_W / 2) * conv_unit; PlotGraphicText( format_plot, pos, color, msg, TEXT_ORIENT_HORIZ, text_size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER ); + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + thickness, italic ); if( ii < xg - PAS_REF / 2 ) { @@ -234,7 +238,8 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ) pos.y = (yg - GRID_REF_W / 2) * conv_unit; PlotGraphicText( format_plot, pos, color, msg, TEXT_ORIENT_HORIZ, text_size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER ); + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + thickness, italic ); } /* Trace des reperes selon l'axe Y */ @@ -254,7 +259,8 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ) pos.y = (ii - gypas / 2) * conv_unit; PlotGraphicText( format_plot, pos, color, msg, TEXT_ORIENT_HORIZ, text_size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER ); + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + thickness, italic ); if( ii < yg - PAS_REF / 2 ) { @@ -266,7 +272,8 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ) pos.x = (xg - GRID_REF_W / 2) * conv_unit; pos.y = (ii - gypas / 2) * conv_unit; PlotGraphicText( format_plot, pos, color, msg, TEXT_ORIENT_HORIZ, text_size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER ); + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + thickness, italic ); } #endif @@ -294,7 +301,8 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ) case WS_PODPIS: if(WsItem->m_Legende) msg = WsItem->m_Legende; PlotGraphicText(format_plot, pos, color, msg, TEXT_ORIENT_HORIZ,text_size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, + thickness, italic ); break; case WS_SIZESHEET: break; @@ -302,13 +310,15 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ) if(WsItem->m_Legende) msg = WsItem->m_Legende; msg << screen->m_ScreenNumber; PlotGraphicText(format_plot, pos, color, msg, TEXT_ORIENT_HORIZ,text_size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, + thickness, italic ); break; case WS_SHEETS: if(WsItem->m_Legende) msg = WsItem->m_Legende; msg << screen->m_NumberOfScreen; PlotGraphicText(format_plot, pos, color, msg, TEXT_ORIENT_HORIZ,text_size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, + thickness, italic ); break; case WS_COMPANY_NAME: break; @@ -345,13 +355,15 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ) case WS_PODPIS_D: if(WsItem->m_Legende) msg = WsItem->m_Legende; PlotGraphicText(format_plot, pos, color, msg, TEXT_ORIENT_HORIZ,text_size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, + thickness, italic ); break; case WS_IDENTSHEET_D: if(WsItem->m_Legende) msg = WsItem->m_Legende; msg << screen->m_ScreenNumber; PlotGraphicText(format_plot, pos, color, msg, TEXT_ORIENT_HORIZ,text_size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER); + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, + thickness, italic ); break; case WS_LEFT_SEGMENT_D: case WS_SEGMENT_D: @@ -470,7 +482,8 @@ void PlotWorkSheet( int format_plot, BASE_SCREEN* screen ) { PlotGraphicText( format_plot, pos, color, msg.GetData(), TEXT_ORIENT_HORIZ, text_size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER ); + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, + thickness, italic ); } } #endif diff --git a/common/drawtxt.cpp b/common/drawtxt.cpp index 43943ef7c5..6896773496 100644 --- a/common/drawtxt.cpp +++ b/common/drawtxt.cpp @@ -52,7 +52,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, wxDC* DC, int ii, kk, char_count, AsciiCode, endcar; int x0, y0; int zoom; - int size_h, size_v, espacement; + int size_h, size_v, pitch; SH_CODE f_cod, plume = 'U'; const SH_CODE* ptcar; int ptr; @@ -83,11 +83,11 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, wxDC* DC, if( char_count == 0 ) return; - espacement = (10 * size_h ) / 9; // this is the pitch between chars - if ( espacement > 0 ) - espacement += ABS(aWidth); + pitch = (10 * size_h ) / 9; // this is the pitch between chars + if ( pitch > 0 ) + pitch += ABS(aWidth); else - espacement -= ABS(aWidth); + pitch -= ABS(aWidth); ox = cX = aPos.x; oy = cY = aPos.y; @@ -96,7 +96,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, wxDC* DC, if( aPanel ) { int xm, ym, ll, xc, yc; - int textsize = ABS( espacement ); + int textsize = ABS( pitch ); ll = (textsize * char_count) / zoom; xc = GRMapX( cX ); @@ -119,7 +119,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, wxDC* DC, /* Compute the position ux0, uy0 of the first letter , next */ - dx = (espacement * char_count) / 2; + 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 */ @@ -196,7 +196,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, wxDC* DC, if( ABS( (aSize.x / zoom) ) < 3 ) /* chars trop petits pour etre dessines */ { /* le texte est symbolise par une barre */ - dx = (espacement * char_count) / 2; + dx = (pitch * char_count) / 2; dy = size_v / 2; /* Decalage du debut du texte / centre */ ux0 = cX - dx; @@ -303,18 +303,54 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, wxDC* DC, /* end draw 1 char */ - ptr++; ox += espacement; + ptr++; ox += pitch; } } + +/* functions used to plot texts, using DrawGraphicText() with a call back function */ +static void (*MovePenFct)( wxPoint pos, int state ); // a pointer to actual plot function (HPGL, PS, ..) +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 wxPoint PenLastPos; + wxPoint pstart; + pstart.x = x0; + pstart.y = y0; + wxPoint pend; + pend.x = xf; + pend.y = yf; + if ( s_Plotbegin ) // First segment to plot + { + MovePenFct( pstart, 'U' ); + MovePenFct( pend, 'D' ); + s_Plotbegin = false; + } + + else + { + if ( PenLastPos == pstart ) // this is a next segment in a polyline + { + MovePenFct( pend, 'D' ); + } + else // New segment to plot + { + MovePenFct( pstart, 'U' ); + MovePenFct( pend, 'D' ); + } + } + + PenLastPos = pend; +} /******************************************************************************************/ void PlotGraphicText( int aFormat_plot, const wxPoint& aPos, enum EDA_Colors aColor, const wxString& aText, int aOrient, const wxSize& aSize, enum GRTextHorizJustifyType aH_justify, enum GRTextVertJustifyType aV_justify, - bool aItalic ) + int aWidth, bool aItalic ) /******************************************************************************************/ /** Function PlotGraphicText @@ -327,27 +363,21 @@ void PlotGraphicText( int aFormat_plot, const wxPoint& aPos, enum EDA_Colors aCo * @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) + * if width < 0 : draw segments in sketch mode, width = abs(width) + * @param aItalic = true to simulate an italic font */ { - int kk, char_count, end, AsciiCode; - int k1, k2, x0, y0, ox, oy; - int size_h, size_v, espacement; - SH_CODE f_cod, plume = 'U'; - const SH_CODE* ptcar; - int ptr; - int ux0, uy0, dx, dy; // Coord de trace des segments de texte & variables de calcul */ - int cX, cY; // Centre du texte - - void (*FctPlume)( wxPoint pos, int state ); + // Initialise the actual function used to plot lines: switch( aFormat_plot ) { case PLOT_FORMAT_POST: - FctPlume = LineTo_PS; + MovePenFct = LineTo_PS; break; case PLOT_FORMAT_HPGL: - FctPlume = Move_Plume_HPGL; + MovePenFct = Move_Plume_HPGL; break; case PLOT_FORMAT_GERBER: @@ -358,158 +388,13 @@ void PlotGraphicText( int aFormat_plot, const wxPoint& aPos, enum EDA_Colors aCo if( aColor >= 0 && IsPostScript( aFormat_plot ) ) SetColorMapPS( aColor ); - size_h = aSize.x; - size_v = aSize.y; - if( size_h == 0 ) - size_h = DEFAULT_SIZE_TEXT; - if( size_v == 0 ) - size_v = DEFAULT_SIZE_TEXT; + s_Plotbegin = true; + DrawGraphicText( NULL, NULL, aPos, aColor, aText, + aOrient, aSize, + aH_justify, aV_justify, + aWidth, aItalic, + s_Callback_plot); - kk = 0; - ptr = 0; /* ptr = text index */ - - /* calcul de la position du debut des textes: ox et oy */ - char_count = aText.Len(); - - espacement = (10 * size_h ) / 9; - ox = cX = aPos.x; - oy = cY = aPos.y; - - /* Calcul du cadrage du texte */ - dx = (espacement * char_count) / 2; - dy = size_v / 2; /* Decalage du debut du texte / centre */ - - ux0 = uy0 = 0; /* Decalage du centre du texte / ccord de ref */ - - if( (aOrient == 0) || (aOrient == 1800) ) /* Texte Horizontal */ - { - switch( aH_justify ) - { - case GR_TEXT_HJUSTIFY_CENTER: - break; - - case GR_TEXT_HJUSTIFY_RIGHT: - ux0 = -dx; - 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; - } - } - else /* Texte Vertical */ - { - switch( aH_justify ) - { - case GR_TEXT_HJUSTIFY_CENTER: - break; - - case GR_TEXT_HJUSTIFY_RIGHT: - ux0 = -dy; - 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; - } - } - - cX += ux0; - cY += uy0; /* cX, cY = coord du centre du texte */ - - ox = -dx; - oy = +dy; /* ox, oy = coord debut texte, relativement au centre */ - - FctPlume( wxPoint( 0, 0 ), 'Z' ); - - while( kk++ < char_count ) - { -#if defined(wxUSE_UNICODE) && defined(KICAD_CYRILLIC) - AsciiCode = aText.GetChar(ptr) & 0x7FF; - if ( AsciiCode > 0x40F && AsciiCode < 0x450 ) // big small Cyr - AsciiCode = utf8_to_ascii[AsciiCode - 0x410] & 0xFF; - else - AsciiCode = AsciiCode & 0xFF; -#else - AsciiCode = aText.GetChar( ptr ) & 0xFF; -#endif - ptcar = graphic_fonte_shape[AsciiCode]; /* ptcar pointe la description - * du caractere a dessiner */ - - for( end = 0; end == 0; ptcar++ ) - { - f_cod = *ptcar; - - /* get code n de la forme selectionnee */ - switch( f_cod ) - { - case 'X': - end = 1; /* fin du caractere */ - - case 'U': - case 'D': - plume = f_cod; break; - - default: - k1 = f_cod; /* trace sur axe V */ - k1 = -(k1 * size_v) / 9; - ptcar++; - f_cod = *ptcar; - - k2 = f_cod; /* trace sur axe H */ - k2 = (k2 * size_h) / 9; - // To simulate an italic font, add a x offset depending on the y offset - if ( aItalic ) - k2 -= k1/8; - - dx = k2 + ox; - dy = k1 + oy; - - RotatePoint( &dx, &dy, aOrient ); - FctPlume( wxPoint( cX + dx, cY + dy ), plume ); - - x0 = k2; - y0 = k1; - break; - } - - /* end switch */ - } - - /* end boucle for = end trace de 1 caractere */ - - FctPlume( wxPoint( 0, 0 ), 'Z' ); - ptr++; ox += espacement; - } - - /* end trace du texte */ - FctPlume( wxPoint( 0, 0 ), 'Z' ); + /* end text : pen UP ,no move */ + MovePenFct( wxPoint( 0, 0 ), 'Z' ); } diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index b0d467c65e..b9dccfcf8e 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -38,7 +38,8 @@ set(EESCHEMA_SRCS # dialog_edit_component_in_lib.cpp dialog_edit_component_in_schematic_fbp.cpp dialog_edit_component_in_schematic.cpp -# dialog_edit_label.cpp + dialog_edit_label.cpp + dialog_edit_label_base.cpp dialog_eeschema_config.cpp dialog_erc.cpp # dialog_find.cpp @@ -82,6 +83,7 @@ set(EESCHEMA_SRCS plothpgl.cpp plotps.cpp priorque.cpp + read_from_file_schematic_items_descriptions.cpp savelib.cpp save_schemas.cpp schedit.cpp diff --git a/eeschema/class_pin.cpp b/eeschema/class_pin.cpp index 9e1fc43d22..36eec7e3bf 100644 --- a/eeschema/class_pin.cpp +++ b/eeschema/class_pin.cpp @@ -281,7 +281,7 @@ void LibDrawPin::DrawPinTexts( WinEDA_DrawPanel* panel, } const wxChar* textsrc = m_PinName.GetData(); - float fPinTextPitch = PinNameSize.x * 1.1; + float fPinTextPitch = (PinNameSize.x * 1.1) + LineWidth; /* Do we need to invert the string? Is this string has only "~"? */ PinTextBarCount = 0; PinTxtLen = 0; ii = 0; @@ -555,7 +555,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, int orient, int TextInside, bool DrawPinNum, - bool DrawPinName ) + bool DrawPinName, + int aWidth, bool aItalic ) { int dx, len, start; int ii, x, y, x1, y1, cte; @@ -594,7 +595,7 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, } const wxChar* textsrc = m_PinName.GetData(); - float fPinTextPitch = PinNameSize.x * 1.1; + float fPinTextPitch = (PinNameSize.x * 1.1) + aWidth; /* Do we need to invert the string? Is this string has only "~"? */ PinTextBarCount = 0; PinTxtLen = 0; ii = 0; @@ -635,7 +636,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, TEXT_ORIENT_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_LEFT, - GR_TEXT_VJUSTIFY_CENTER ); + GR_TEXT_VJUSTIFY_CENTER, + aWidth, aItalic ); for( ii = 0; ii < PinTextBarCount; ) { @@ -654,7 +656,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, NameColor, PinText, TEXT_ORIENT_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, - GR_TEXT_VJUSTIFY_CENTER ); + GR_TEXT_VJUSTIFY_CENTER, + aWidth, aItalic ); for( ii = 0; ii < PinTextBarCount; ) { @@ -675,7 +678,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, NumColor, StringPinNum, TEXT_ORIENT_HORIZ, PinNumSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM ); + GR_TEXT_VJUSTIFY_BOTTOM, + aWidth, aItalic ); } } else /* Its a vertical line. */ @@ -691,7 +695,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, PinText, TEXT_ORIENT_VERT, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_TOP ); + GR_TEXT_VJUSTIFY_TOP, + aWidth, aItalic); for( ii = 0; ii < PinTextBarCount; ) { @@ -711,7 +716,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, PinText, TEXT_ORIENT_VERT, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM ); + GR_TEXT_VJUSTIFY_BOTTOM, + aWidth, aItalic); for( ii = 0; ii < PinTextBarCount; ) { @@ -732,7 +738,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, NumColor, StringPinNum, TEXT_ORIENT_VERT, PinNumSize, GR_TEXT_HJUSTIFY_RIGHT, - GR_TEXT_VJUSTIFY_CENTER ); + GR_TEXT_VJUSTIFY_CENTER, + aWidth, aItalic); } } } @@ -749,7 +756,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, NameColor, PinText, TEXT_ORIENT_HORIZ, PinNameSize, GR_TEXT_HJUSTIFY_CENTER, - GR_TEXT_VJUSTIFY_BOTTOM ); + GR_TEXT_VJUSTIFY_BOTTOM, + aWidth, aItalic); for( ii = 0; ii < PinTextBarCount; ) { @@ -767,7 +775,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, PlotGraphicText( g_PlotFormat, wxPoint( x, y1 + TXTMARGE ), NumColor, StringPinNum, TEXT_ORIENT_HORIZ, PinNumSize, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP ); + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, + aWidth, aItalic); } } else /* Its a vertical line. */ @@ -780,7 +789,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, NameColor, PinText, TEXT_ORIENT_VERT, PinNameSize, GR_TEXT_HJUSTIFY_RIGHT, - GR_TEXT_VJUSTIFY_CENTER ); + GR_TEXT_VJUSTIFY_CENTER, + aWidth, aItalic); for( ii = 0; ii < PinTextBarCount; ) { @@ -801,7 +811,8 @@ void LibDrawPin::PlotPinTexts( wxPoint& pin_pos, NumColor, StringPinNum, TEXT_ORIENT_VERT, PinNumSize, GR_TEXT_HJUSTIFY_LEFT, - GR_TEXT_VJUSTIFY_CENTER ); + GR_TEXT_VJUSTIFY_CENTER, + aWidth, aItalic); } } } diff --git a/eeschema/class_text-label.cpp b/eeschema/class_text-label.cpp index a4fb90fe8f..9061fbe59d 100644 --- a/eeschema/class_text-label.cpp +++ b/eeschema/class_text-label.cpp @@ -139,7 +139,7 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, wxPoint( m_Pos.x + offset.x, m_Pos.y - TXTMARGE + offset.y ), color, m_Text, TEXT_ORIENT_HORIZ, m_Size, GR_TEXT_HJUSTIFY_LEFT, - GR_TEXT_VJUSTIFY_BOTTOM, width ); + GR_TEXT_VJUSTIFY_BOTTOM, width, m_Italic ); break; case 1: /* Vert Orientation UP */ @@ -148,7 +148,7 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, m_Pos.y + offset.y ), color, m_Text, TEXT_ORIENT_VERT, m_Size, GR_TEXT_HJUSTIFY_RIGHT, - GR_TEXT_VJUSTIFY_BOTTOM, width ); + GR_TEXT_VJUSTIFY_BOTTOM, width, m_Italic ); break; case 2: /* Horiz Orientation - Right justified */ @@ -157,7 +157,7 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, TXTMARGE + offset.y ), color, m_Text, TEXT_ORIENT_HORIZ, m_Size, GR_TEXT_HJUSTIFY_RIGHT, - GR_TEXT_VJUSTIFY_BOTTOM, width ); + GR_TEXT_VJUSTIFY_BOTTOM, width, m_Italic ); break; case 3: /* Vert Orientation BOTTOM */ @@ -166,7 +166,7 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, m_Pos.y + offset.y ), color, m_Text, TEXT_ORIENT_VERT, m_Size, GR_TEXT_HJUSTIFY_RIGHT, - GR_TEXT_VJUSTIFY_TOP, width ); + GR_TEXT_VJUSTIFY_TOP, width, m_Italic ); break; } @@ -184,9 +184,13 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, bool SCH_TEXT::Save( FILE* aFile ) const { bool success = true; - if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d ~\n%s\n", + 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 ) { success = false; @@ -234,10 +238,13 @@ SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) : bool SCH_LABEL::Save( FILE* aFile ) const { bool success = true; - char shape = '~'; - if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %c\n%s\n", + 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_Orient, m_Size.x, shape, m_Width, CONV_TO_UTF8( m_Text ) ) == EOF ) { success = false; @@ -267,10 +274,14 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : bool SCH_GLOBALLABEL::Save( FILE* aFile ) const { bool success = true; - if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s\n%s\n", + 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 ) { success = false; @@ -300,10 +311,14 @@ SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) : bool SCH_HIERLABEL::Save( FILE* aFile ) const { bool success = true; - if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s\n%s\n", + 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 ) { success = false; @@ -352,28 +367,28 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs DrawGraphicText( panel, DC, wxPoint( AnchorPos.x - ii, AnchorPos.y ), color, m_Text, TEXT_ORIENT_HORIZ, m_Size, - GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, width ); + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, width, m_Italic ); break; case 1: /* Orientation vert UP */ DrawGraphicText( panel, DC, wxPoint( AnchorPos.x, AnchorPos.y + ii ), color, m_Text, TEXT_ORIENT_VERT, m_Size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, width ); + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, width, m_Italic ); break; case 2: /* Orientation horiz inverse */ DrawGraphicText( panel, DC, wxPoint( AnchorPos.x + ii, AnchorPos.y ), color, m_Text, TEXT_ORIENT_HORIZ, m_Size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, m_Italic ); break; case 3: /* Orientation vert BOTTOM */ DrawGraphicText( panel, DC, wxPoint( AnchorPos.x, AnchorPos.y - ii ), color, m_Text, TEXT_ORIENT_VERT, m_Size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width ); + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width, m_Italic ); break; } @@ -417,8 +432,9 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox() y = m_Pos.y; dx = dy = 0; + int width = MAX( m_Width, g_DrawMinimunLineWidth ); height = m_Size.y + 2*TXTMARGE; - length = ( Pitch() * GetLength() ) + height + 2*DANGLING_SYMBOL_SIZE; // add height for triangular shapes + length = ( Pitch(width) * GetLength() ) + height + 2*DANGLING_SYMBOL_SIZE; // add height for triangular shapes switch( m_Orient ) // respect orientation { @@ -504,28 +520,28 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& dr DrawGraphicText( panel, DC, wxPoint( AnchorPos.x - offset, AnchorPos.y ), color, m_Text, TEXT_ORIENT_HORIZ, m_Size, - GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, width ); + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, width, m_Italic ); break; case 1: /* Orientation vert UP */ DrawGraphicText( panel, DC, wxPoint( AnchorPos.x, AnchorPos.y + offset ), color, m_Text, TEXT_ORIENT_VERT, m_Size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, width ); + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, width, m_Italic ); break; case 2: /* Orientation horiz inverse */ DrawGraphicText( panel, DC, wxPoint( AnchorPos.x + offset, AnchorPos.y ), color, m_Text, TEXT_ORIENT_HORIZ, m_Size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width ); + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, m_Italic ); break; case 3: /* Orientation vert BOTTOM */ DrawGraphicText( panel, DC, wxPoint( AnchorPos.x, AnchorPos.y - offset ), color, m_Text, TEXT_ORIENT_VERT, m_Size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width ); + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width, m_Italic ); break; } @@ -629,8 +645,9 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() y = m_Pos.y; dx = dy = 0; + int width = MAX( m_Width, g_DrawMinimunLineWidth ); height = m_Size.y + 2*TXTMARGE; - length = ( Pitch() * GetLength() ) + 2* height + 2*DANGLING_SYMBOL_SIZE; // add 2*height for triangular shapes (bidirectional) + length = ( Pitch(width) * GetLength() ) + 2* height + 2*DANGLING_SYMBOL_SIZE; // add 2*height for triangular shapes (bidirectional) switch( m_Orient ) // respect orientation { @@ -675,7 +692,8 @@ EDA_Rect SCH_TEXT::GetBoundingBox() x = m_Pos.x; y = m_Pos.y; - length = ( Pitch() * GetLength() ); + int width = MAX( m_Width, g_DrawMinimunLineWidth ); + length = ( Pitch(width) * GetLength() ); height = m_Size.y; dx = dy = 0; @@ -714,3 +732,4 @@ EDA_Rect SCH_TEXT::GetBoundingBox() box.Normalize(); return box; } + diff --git a/eeschema/classes_body_items.h b/eeschema/classes_body_items.h index ef5a78ab1c..0ca6c82343 100644 --- a/eeschema/classes_body_items.h +++ b/eeschema/classes_body_items.h @@ -232,7 +232,7 @@ public: int TextInside, bool DrawPinNum, bool DrawPinName, int Color, int DrawMode ); void PlotPinTexts( wxPoint& pin_pos, int orient, - int TextInside, bool DrawPinNum, bool DrawPinName ); + int TextInside, bool DrawPinNum, bool DrawPinNameint, int aWidth, bool aItalic ); }; diff --git a/eeschema/dialog_edit_label.cpp b/eeschema/dialog_edit_label.cpp index c2f4e7a26c..ee50cdcbc6 100644 --- a/eeschema/dialog_edit_label.cpp +++ b/eeschema/dialog_edit_label.cpp @@ -1,67 +1,38 @@ ///////////////////////////////////////////////////////////////////////////// // Name: dialog_edit_label.cpp -// Purpose: // Author: jean-pierre Charras // Modified by: -// Created: 19/02/2006 15:46:26 -// RCS-ID: -// Copyright: License GNU -// Licence: +// Created: 18/12/2008 15:46:26 +// Licence: GPL ///////////////////////////////////////////////////////////////////////////// -// Generated by DialogBlocks (unregistered), 19/02/2006 15:46:26 - -/* This is the dialog box for labels, glob. labels and graphic texts edition */ - -////@begin includes -////@end includes +#include "fctsys.h" +#include "wx/valgen.h" +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" #include "dialog_edit_label.h" -////@begin XPM images -////@end XPM images - -/*! - * WinEDA_LabelPropertiesFrame type definition - */ - -IMPLEMENT_DYNAMIC_CLASS( WinEDA_LabelPropertiesFrame, wxDialog ) - -/*! - * WinEDA_LabelPropertiesFrame event table definition - */ - -BEGIN_EVENT_TABLE( WinEDA_LabelPropertiesFrame, wxDialog ) - -////@begin WinEDA_LabelPropertiesFrame event table entries - EVT_BUTTON( wxID_OK, WinEDA_LabelPropertiesFrame::OnOkClick ) - - EVT_BUTTON( wxID_CANCEL, WinEDA_LabelPropertiesFrame::OnCancelClick ) - -////@end WinEDA_LabelPropertiesFrame event table entries - -END_EVENT_TABLE() - -/*! - * WinEDA_LabelPropertiesFrame constructors - */ - -WinEDA_LabelPropertiesFrame::WinEDA_LabelPropertiesFrame( ) +DialogLabelEditor::DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText) + : DialogLabelEditor_Base ( parent ) { + m_Parent = parent; + m_CurrentText= CurrentText; } -WinEDA_LabelPropertiesFrame::WinEDA_LabelPropertiesFrame( WinEDA_SchematicFrame* parent, - SCH_TEXT * CurrentText, - const wxPoint& pos, - wxWindowID id, const wxString& caption, const wxSize& size, long style ) +void DialogLabelEditor::OnInitDialog( wxInitDialogEvent& event ) { wxString msg; - m_Parent = parent; - m_CurrentText = CurrentText; - Create(parent, id, caption, pos, size, style); m_TextLabel->SetValue(m_CurrentText->m_Text); m_TextLabel->SetFocus(); + + // Set validators + m_TextOrient->SetSelection( m_CurrentText->m_Orient ); + m_TextShape->SetSelection( m_CurrentText->m_Shape ); + switch( m_CurrentText->Type() ) { case TYPE_SCH_GLOBALLABEL: @@ -81,163 +52,37 @@ wxString msg; break; } + int style = 0; + if ( m_CurrentText->m_Italic ) + style = 1; + if ( m_CurrentText->m_Width > 1 ) + style += 2; + m_TextStyle->SetSelection(style); msg = m_SizeTitle->GetLabel() + ReturnUnitSymbol(); m_SizeTitle->SetLabel(msg); msg = ReturnStringFromValue(g_UnitMetric, m_CurrentText->m_Size.x, m_Parent->m_InternalUnits); m_TextSize->SetValue(msg); -} + + SetFocus(); + + if (m_CurrentText->Type() != TYPE_SCH_GLOBALLABEL && + m_CurrentText->Type() != TYPE_SCH_HIERLABEL) + m_TextShape->Show(false); -/*! - * WinEDA_LabelPropertiesFrame creator - */ - -bool WinEDA_LabelPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) -{ -////@begin WinEDA_LabelPropertiesFrame member initialisation - m_TextLabel = NULL; - m_TextOrient = NULL; - m_TextShape = NULL; - m_SizeTitle = NULL; - m_TextSize = NULL; - m_btClose = NULL; -////@end WinEDA_LabelPropertiesFrame member initialisation - -////@begin WinEDA_LabelPropertiesFrame creation - SetExtraStyle(wxWS_EX_BLOCK_EVENTS); - wxDialog::Create( parent, id, caption, pos, size, style ); - - CreateControls(); if (GetSizer()) { GetSizer()->SetSizeHints(this); } - Centre(); -////@end WinEDA_LabelPropertiesFrame creation - return true; } -/*! - * Control creation for WinEDA_LabelPropertiesFrame - */ -void WinEDA_LabelPropertiesFrame::CreateControls() -{ - SetFont(*g_DialogFont); -////@begin WinEDA_LabelPropertiesFrame content construction - // Generated by DialogBlocks, 29/04/2008 21:03:43 (unregistered) - - WinEDA_LabelPropertiesFrame* itemDialog1 = this; - - wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); - itemDialog1->SetSizer(itemBoxSizer2); - - wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); - - wxStaticText* itemStaticText4 = new wxStaticText( itemDialog1, wxID_STATIC, _("Text "), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); - - m_TextLabel = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(250, -1), 0 ); - itemBoxSizer3->Add(m_TextLabel, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); - - wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL); - itemBoxSizer3->Add(itemBoxSizer6, 0, wxGROW|wxALL, 5); - - wxArrayString m_TextOrientStrings; - m_TextOrientStrings.Add(_("Right")); - m_TextOrientStrings.Add(_("Up")); - m_TextOrientStrings.Add(_("Left")); - m_TextOrientStrings.Add(_("Down")); - m_TextOrient = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Text Orient:"), wxDefaultPosition, wxDefaultSize, m_TextOrientStrings, 1, wxRA_SPECIFY_COLS ); - m_TextOrient->SetSelection(0); - itemBoxSizer6->Add(m_TextOrient, 0, wxALIGN_TOP|wxALL, 5); - - itemBoxSizer6->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - - wxArrayString m_TextShapeStrings; - m_TextShapeStrings.Add(_("Input")); - m_TextShapeStrings.Add(_("Output")); - m_TextShapeStrings.Add(_("Bidi")); - m_TextShapeStrings.Add(_("TriState")); - m_TextShapeStrings.Add(_("Passive")); - m_TextShape = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Glabel Shape:"), wxDefaultPosition, wxDefaultSize, m_TextShapeStrings, 1, wxRA_SPECIFY_COLS ); - m_TextShape->SetSelection(0); - m_TextShape->Show(false); - itemBoxSizer6->Add(m_TextShape, 0, wxALIGN_TOP|wxALL, 5); - - wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer2->Add(itemBoxSizer10, 0, wxGROW|wxALL, 5); - - m_SizeTitle = new wxStaticText( itemDialog1, wxID_STATIC, _("Size "), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer10->Add(m_SizeTitle, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); - - m_TextSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer10->Add(m_TextSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); - - itemBoxSizer10->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); - - wxButton* itemButton14 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton14->SetDefault(); - itemButton14->SetForegroundColour(wxColour(204, 0, 0)); - itemBoxSizer10->Add(itemButton14, 0, wxGROW|wxALL, 5); - - m_btClose = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - m_btClose->SetForegroundColour(wxColour(0, 0, 255)); - itemBoxSizer10->Add(m_btClose, 0, wxGROW|wxALL, 5); - - // Set validators - m_TextOrient->SetValidator( wxGenericValidator(& m_CurrentText->m_Orient) ); - m_TextShape->SetValidator( wxGenericValidator(& m_CurrentText->m_Shape) ); -////@end WinEDA_LabelPropertiesFrame content construction - - m_btClose->SetFocus(); - - if (m_CurrentText->Type() == TYPE_SCH_GLOBALLABEL || - m_CurrentText->Type() == TYPE_SCH_HIERLABEL) - m_TextShape->Show(true); -} - -/*! - * Should we show tooltips? - */ - -bool WinEDA_LabelPropertiesFrame::ShowToolTips() -{ - return true; -} - -/*! - * Get bitmap resources - */ - -wxBitmap WinEDA_LabelPropertiesFrame::GetBitmapResource( const wxString& name ) -{ - // Bitmap retrieval -////@begin WinEDA_LabelPropertiesFrame bitmap retrieval - wxUnusedVar(name); - return wxNullBitmap; -////@end WinEDA_LabelPropertiesFrame bitmap retrieval -} - -/*! - * Get icon resources - */ - -wxIcon WinEDA_LabelPropertiesFrame::GetIconResource( const wxString& name ) -{ - // Icon retrieval -////@begin WinEDA_LabelPropertiesFrame icon retrieval - wxUnusedVar(name); - return wxNullIcon; -////@end WinEDA_LabelPropertiesFrame icon retrieval -} /*! * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK */ -void WinEDA_LabelPropertiesFrame::OnOkClick( wxCommandEvent& event ) +void DialogLabelEditor::OnButtonOKClick( wxCommandEvent& event ) { TextPropertiesAccept(event); } @@ -246,7 +91,7 @@ void WinEDA_LabelPropertiesFrame::OnOkClick( wxCommandEvent& event ) * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL */ -void WinEDA_LabelPropertiesFrame::OnCancelClick( wxCommandEvent& event ) +void DialogLabelEditor::OnButtonCANCEL_Click( wxCommandEvent& event ) { m_Parent->DrawPanel->MouseToCursorSchema(); EndModal( -1 ); diff --git a/eeschema/dialog_edit_label.h b/eeschema/dialog_edit_label.h index 9863d0da78..d82f3cfb07 100644 --- a/eeschema/dialog_edit_label.h +++ b/eeschema/dialog_edit_label.h @@ -1,119 +1,30 @@ ///////////////////////////////////////////////////////////////////////////// // Name: dialog_edit_label.h -// Purpose: // Author: jean-pierre Charras // Modified by: -// Created: 19/02/2006 15:46:26 -// RCS-ID: -// Copyright: License GNU -// Licence: +// Licence: GPL ///////////////////////////////////////////////////////////////////////////// -// Generated by DialogBlocks (unregistered), 19/02/2006 15:46:26 - #ifndef _DIALOG_EDIT_LABEL_H_ #define _DIALOG_EDIT_LABEL_H_ +#include "dialog_edit_label_base.h" -/*! - * Includes - */ - -////@begin includes -#include "wx/valgen.h" -////@end includes - -/*! - * Forward declarations - */ - -////@begin forward declarations -////@end forward declarations - -/*! - * Control identifiers - */ - -////@begin control identifiers -#define ID_DIALOG 10000 -#define ID_TEXTCTRL 10001 -#define ID_RADIOBOX 10003 -#define ID_RADIOBOX1 10004 -#define ID_TEXTCTRL1 10002 -#define SYMBOL_WINEDA_LABELPROPERTIESFRAME_STYLE wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER -#define SYMBOL_WINEDA_LABELPROPERTIESFRAME_TITLE _("Text Editor") -#define SYMBOL_WINEDA_LABELPROPERTIESFRAME_IDNAME ID_DIALOG -#define SYMBOL_WINEDA_LABELPROPERTIESFRAME_SIZE wxSize(400, 300) -#define SYMBOL_WINEDA_LABELPROPERTIESFRAME_POSITION wxDefaultPosition -////@end control identifiers - -/*! - * Compatibility - */ - -#ifndef wxCLOSE_BOX -#define wxCLOSE_BOX 0x1000 -#endif - -/*! - * WinEDA_LabelPropertiesFrame class declaration - */ - -class WinEDA_LabelPropertiesFrame: public wxDialog +class DialogLabelEditor : public DialogLabelEditor_Base { - DECLARE_DYNAMIC_CLASS( WinEDA_LabelPropertiesFrame ) - DECLARE_EVENT_TABLE() - -public: - /// Constructors - WinEDA_LabelPropertiesFrame( ); - WinEDA_LabelPropertiesFrame( WinEDA_SchematicFrame* parent, - SCH_TEXT * CurrentText, - const wxPoint& pos = SYMBOL_WINEDA_LABELPROPERTIESFRAME_POSITION, - wxWindowID id = SYMBOL_WINEDA_LABELPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_LABELPROPERTIESFRAME_TITLE, const wxSize& size = SYMBOL_WINEDA_LABELPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_LABELPROPERTIESFRAME_STYLE ); - - /// Creation - bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_LABELPROPERTIESFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_LABELPROPERTIESFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_LABELPROPERTIESFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_LABELPROPERTIESFRAME_SIZE, long style = SYMBOL_WINEDA_LABELPROPERTIESFRAME_STYLE ); - - /// Creates the controls and sizers - void CreateControls(); - -////@begin WinEDA_LabelPropertiesFrame event handler declarations - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK - void OnOkClick( wxCommandEvent& event ); - - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL - void OnCancelClick( wxCommandEvent& event ); - -////@end WinEDA_LabelPropertiesFrame event handler declarations - -////@begin WinEDA_LabelPropertiesFrame member function declarations - - /// Retrieves bitmap resources - wxBitmap GetBitmapResource( const wxString& name ); - - /// Retrieves icon resources - wxIcon GetIconResource( const wxString& name ); -////@end WinEDA_LabelPropertiesFrame member function declarations - - /// Should we show tooltips? - static bool ShowToolTips(); - void TextPropertiesAccept(wxCommandEvent& event); - -////@begin WinEDA_LabelPropertiesFrame member variables - wxTextCtrl* m_TextLabel; - wxRadioBox* m_TextOrient; - wxRadioBox* m_TextShape; - wxStaticText* m_SizeTitle; - wxTextCtrl* m_TextSize; - wxButton* m_btClose; -////@end WinEDA_LabelPropertiesFrame member variables - - WinEDA_SchematicFrame * m_Parent; +private: + WinEDA_SchematicFrame * m_Parent; SCH_TEXT * m_CurrentText; +public: + DialogLabelEditor( WinEDA_SchematicFrame* parent, SCH_TEXT * CurrentText); + ~DialogLabelEditor(){}; +private: + void OnInitDialog( wxInitDialogEvent& event ); + void OnButtonOKClick( wxCommandEvent& event ); + void OnButtonCANCEL_Click( wxCommandEvent& event ); + void TextPropertiesAccept( wxCommandEvent& event ); }; -#endif - // _DIALOG_EDIT_LABEL_H_ + +#endif // _DIALOG_EDIT_LABEL_H_ diff --git a/eeschema/dialog_edit_label.pjd b/eeschema/dialog_edit_label.pjd deleted file mode 100644 index ea9c6a3094..0000000000 --- a/eeschema/dialog_edit_label.pjd +++ /dev/null @@ -1,1034 +0,0 @@ - - -
- 0 - "" - "" - "" - "" - "" - 0 - 0 - 0 - 1 - 1 - 1 - 1 - 0 - "jean-pierre Charras" - "License GNU" - "" - 0 - 0 - "<All platforms>" - "<Any>" - "///////////////////////////////////////////////////////////////////////////// -// Name: %HEADER-FILENAME% -// Purpose: -// Author: %AUTHOR% -// Modified by: -// Created: %DATE% -// RCS-ID: -// Copyright: %COPYRIGHT% -// Licence: -///////////////////////////////////////////////////////////////////////////// - -" - "///////////////////////////////////////////////////////////////////////////// -// Name: %SOURCE-FILENAME% -// Purpose: -// Author: %AUTHOR% -// Modified by: -// Created: %DATE% -// RCS-ID: -// Copyright: %COPYRIGHT% -// Licence: -///////////////////////////////////////////////////////////////////////////// - -" - "///////////////////////////////////////////////////////////////////////////// -// Name: %SYMBOLS-FILENAME% -// Purpose: Symbols file -// Author: %AUTHOR% -// Modified by: -// Created: %DATE% -// RCS-ID: -// Copyright: %COPYRIGHT% -// Licence: -///////////////////////////////////////////////////////////////////////////// - -" - "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma interface "%HEADER-FILENAME%" -#endif - -" - "#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "%HEADER-FILENAME%" -#endif - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/wx.h" -#endif - -" - " /// %BODY% -" - " -/*! - * %BODY% - */ - -" - "app_resources.h" - "app_resources.cpp" - "AppResources" - "app.h" - "app.cpp" - "Application" - 0 - "" - "<None>" - "<System>" - "utf-8" - "<System>" - "" - 0 - 0 - 4 - " " - "" - 0 - 0 - 1 - 0 - 1 - 1 - 0 - 1 - 0 -
- - - "" - "data-document" - "" - "" - 0 - 1 - 0 - 0 - - "Configurations" - "config-data-document" - "" - "" - 0 - 1 - 0 - 0 - "" - 1 - 0 - "" - "Debug" - "ANSI" - "Static" - "Modular" - "GUI" - "wxMSW" - "Dynamic" - "Yes" - "No" - "No" - "%WXVERSION%" - "%EXECUTABLE%" - "" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - "%AUTO%" - 0 - 1 - - - - - - - "Projects" - "root-document" - "" - "project" - 1 - 1 - 0 - 1 - - "Windows" - "html-document" - "" - "dialogsfolder" - 1 - 1 - 0 - 1 - - "Text editor" - "dialog-document" - "" - "dialog" - 0 - 1 - 0 - 0 - "19/3/2006" - "wbDialogProxy" - 10000 - 0 - "" - 0 - "" - 0 - 0 - "ID_DIALOG" - 10000 - "WinEDA_LabelPropertiesFrame" - "wxDialog" - "wxDialog" - "dialog_edit_label.cpp" - "dialog_edit_label.h" - "" - "Text Editor" - 1 - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "Tiled" - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 1 - 0 - "MAYBE_RESIZE_BORDER" - 0 - 1 - -1 - -1 - 400 - 300 - 0 - "" - - "wxBoxSizer H" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "wbBoxSizerProxy" - "Horizontal" - "" - 0 - 0 - 0 - "<Any platform>" - - "wxBoxSizer V" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "19/2/2006" - "wbBoxSizerProxy" - "Vertical" - "" - "Centre" - "Expand" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "19/2/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "" - "wxStaticText" - "wxStaticText" - 1 - 0 - "" - "" - "" - "Text " - -1 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - "" - "" - - - "wxTextCtrl: ID_TEXTCTRL" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "19/2/2006" - "wbTextCtrlProxy" - "ID_TEXTCTRL" - 10001 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_TextLabel" - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - 250 - -1 - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 0 - 1 - 0 - 0 - 0 - "" - "" - - - "wxBoxSizer H" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "19/2/2006" - "wbBoxSizerProxy" - "Horizontal" - "" - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - "wxRadioBox: ID_RADIOBOX" - "dialog-control-document" - "" - "radiobox" - 0 - 1 - 0 - 0 - "19/2/2006" - "wbRadioBoxProxy" - "ID_RADIOBOX" - 10003 - "" - "wxRadioBox" - "wxRadioBox" - 1 - 0 - "" - "" - "m_TextOrient" - "Text Orient:" - 1 - "Right|Up|Left|Down" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "m_CurrentText->m_Orient" - "wxGenericValidator(& %VARIABLE%)" - "" - "" - "" - "" - "" - 0 - 1 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Centre" - "Top" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - - - "Spacer" - "dialog-control-document" - "" - "spacer" - 0 - 1 - 0 - 0 - "19/2/2006" - "wbSpacerProxy" - 5 - 5 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - - "wxRadioBox: ID_RADIOBOX1" - "dialog-control-document" - "" - "radiobox" - 0 - 1 - 0 - 0 - "19/2/2006" - "wbRadioBoxProxy" - "ID_RADIOBOX1" - 10004 - "" - "wxRadioBox" - "wxRadioBox" - 1 - 0 - "" - "" - "m_TextShape" - "Glabel Shape:" - 1 - "Input|Output|Bidi|TriState|Passive" - 0 - "" - "" - "" - "" - "" - 1 - 1 - "<Any platform>" - "m_CurrentText->m_Shape" - "wxGenericValidator(& %VARIABLE%)" - "" - "" - "" - "" - "" - 0 - 1 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Centre" - "Top" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - - - - - "wxBoxSizer V" - "dialog-control-document" - "" - "sizer" - 0 - 1 - 0 - 0 - "19/2/2006" - "wbBoxSizerProxy" - "Vertical" - "" - "Centre" - "Expand" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - "wxStaticText: wxID_STATIC" - "dialog-control-document" - "" - "statictext" - 0 - 1 - 0 - 0 - "19/2/2006" - "wbStaticTextProxy" - "wxID_STATIC" - 5105 - "" - "wxStaticText" - "wxStaticText" - 1 - 0 - "" - "" - "m_SizeTitle" - "Size " - -1 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 1 - 0 - 0 - 1 - 0 - "" - "" - - - "wxTextCtrl: ID_TEXTCTRL1" - "dialog-control-document" - "" - "textctrl" - 0 - 1 - 0 - 0 - "19/2/2006" - "wbTextCtrlProxy" - "ID_TEXTCTRL1" - 10002 - "" - "wxTextCtrl" - "wxTextCtrl" - 1 - 0 - "" - "" - "m_TextSize" - "" - 0 - "" - "" - "" - "" - "" - 0 - 1 - "<Any platform>" - "" - "" - "" - "" - "" - "" - "" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Left" - "Centre" - 0 - 5 - 1 - 1 - 0 - 1 - 0 - 0 - 0 - "" - "" - - - "Spacer" - "dialog-control-document" - "" - "spacer" - 0 - 1 - 0 - 0 - "19/2/2006" - "wbSpacerProxy" - 5 - 5 - "Centre" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "<Any platform>" - - - "wxButton: wxID_OK" - "dialog-control-document" - "" - "dialogcontrol" - 0 - 1 - 0 - 0 - "19/2/2006" - "wbButtonProxy" - "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" - "wxID_OK" - 5100 - "" - "wxButton" - "wxButton" - 1 - 0 - "" - "" - "" - "&OK" - 1 - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "CC0000" - "" - 0 - 1 - "<Any platform>" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - - - "wxButton: wxID_CANCEL" - "dialog-control-document" - "" - "dialogcontrol" - 0 - 1 - 0 - 0 - "19/2/2006" - "wbButtonProxy" - "wxEVT_COMMAND_BUTTON_CLICKED|OnCancelClick|||WinEDA_LabelPropertiesFrame" - "wxID_CANCEL" - 5101 - "" - "wxButton" - "wxButton" - 1 - 0 - "" - "" - "m_btClose" - "&Cancel" - 0 - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "0000FF" - "" - 0 - 1 - "<Any platform>" - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - "" - -1 - -1 - -1 - -1 - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - - - - - - - "Sources" - "html-document" - "" - "sourcesfolder" - 1 - 1 - 0 - 1 - - "dialog_edit_label.rc" - "source-editor-document" - "dialog_edit_label.rc" - "source-editor" - 0 - 0 - 1 - 0 - "19/3/2006" - "" - - - - "Images" - "html-document" - "" - "bitmapsfolder" - 1 - 1 - 0 - 1 - - - - -
diff --git a/eeschema/dialog_edit_label.rc b/eeschema/dialog_edit_label.rc deleted file mode 100644 index b86c4e2265..0000000000 --- a/eeschema/dialog_edit_label.rc +++ /dev/null @@ -1 +0,0 @@ -#include "wx/msw/wx.rc" diff --git a/eeschema/dialog_edit_label_base.cpp b/eeschema/dialog_edit_label_base.cpp new file mode 100644 index 0000000000..f8003da79a --- /dev/null +++ b/eeschema/dialog_edit_label_base.cpp @@ -0,0 +1,94 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 16 2008) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_edit_label_base.h" + +/////////////////////////////////////////////////////////////////////////// + +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 ); + + 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_TextLabel = new wxTextCtrl( this, wxID_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer2->Add( m_TextLabel, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + wxBoxSizer* m_OptionsSizer; + m_OptionsSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxString m_TextOrientChoices[] = { _("Right"), _("Up"), _("Left"), _("Down") }; + int m_TextOrientNChoices = sizeof( m_TextOrientChoices ) / sizeof( wxString ); + m_TextOrient = new wxRadioBox( this, wxID_ANY, _("wxRadioBox"), wxDefaultPosition, wxDefaultSize, m_TextOrientNChoices, m_TextOrientChoices, 1, wxRA_SPECIFY_COLS ); + m_TextOrient->SetSelection( 0 ); + m_OptionsSizer->Add( m_TextOrient, 0, wxALL, 5 ); + + wxString m_TextStyleChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") }; + int m_TextStyleNChoices = sizeof( m_TextStyleChoices ) / sizeof( wxString ); + m_TextStyle = new wxRadioBox( this, wxID_ANY, _("Style"), wxDefaultPosition, wxDefaultSize, m_TextStyleNChoices, m_TextStyleChoices, 1, wxRA_SPECIFY_COLS ); + m_TextStyle->SetSelection( 0 ); + m_OptionsSizer->Add( m_TextStyle, 0, wxALL, 5 ); + + wxString m_TextShapeChoices[] = { _("Input"), _("Output"), _("Bidi"), _("TriState"), _("Passive") }; + int m_TextShapeNChoices = sizeof( m_TextShapeChoices ) / sizeof( wxString ); + m_TextShape = new wxRadioBox( this, wxID_ANY, _("Glabel Shape:"), wxDefaultPosition, wxDefaultSize, m_TextShapeNChoices, m_TextShapeChoices, 1, wxRA_SPECIFY_COLS ); + m_TextShape->SetSelection( 2 ); + m_OptionsSizer->Add( m_TextShape, 0, wxALL, 5 ); + + bSizer2->Add( m_OptionsSizer, 1, wxEXPAND, 5 ); + + bMainSizer->Add( bSizer2, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxVERTICAL ); + + m_SizeTitle = new wxStaticText( this, wxID_ANY, _("Size"), wxDefaultPosition, wxDefaultSize, 0 ); + m_SizeTitle->Wrap( -1 ); + bSizer4->Add( m_SizeTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_TextSize = new wxTextCtrl( this, wxID_SIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer4->Add( m_TextSize, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + + bSizer4->Add( 8, 8, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonOK->SetForegroundColour( wxColour( 234, 0, 0 ) ); + + bSizer4->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_buttonCANCEL = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonCANCEL->SetForegroundColour( wxColour( 0, 0, 187 ) ); + + bSizer4->Add( m_buttonCANCEL, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + bMainSizer->Add( bSizer4, 0, wxEXPAND, 5 ); + + this->SetSizer( bMainSizer ); + this->Layout(); + + // Connect Events + this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DialogLabelEditor_Base::OnInitDialog ) ); + m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnButtonOKClick ), NULL, this ); + m_buttonCANCEL->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnButtonCANCEL_Click ), NULL, this ); +} + +DialogLabelEditor_Base::~DialogLabelEditor_Base() +{ + // Disconnect Events + this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DialogLabelEditor_Base::OnInitDialog ) ); + m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnButtonOKClick ), NULL, this ); + m_buttonCANCEL->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLabelEditor_Base::OnButtonCANCEL_Click ), NULL, this ); +} diff --git a/eeschema/dialog_edit_label_base.fbp b/eeschema/dialog_edit_label_base.fbp new file mode 100644 index 0000000000..5bf082c5d8 --- /dev/null +++ b/eeschema/dialog_edit_label_base.fbp @@ -0,0 +1,602 @@ + + + + + + C++ + 1 + UTF-8 + connect + dialog_edit_label_base + 1000 + none + 1 + dialog_edit_label_base + + . + + 1 + 1 + 0 + + + + + 1 + + + + 0 + wxID_ANY + + + DialogLabelEditor_Base + + 401,222 + wxDEFAULT_DIALOG_STYLE + + Text Editor + + + + + + + + + + + + + + OnInitDialog + + + + + + + + + + + + + + + + + + + + + + + bMainSizer + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + bSizer2 + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + Text + + + m_staticText1 + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_VALUE + + 0 + + m_TextLabel + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + m_OptionsSizer + wxHORIZONTAL + none + + 5 + wxALL + 0 + + + "Right" "Up" "Left" "Down" + + 1 + + + 0 + wxID_ANY + wxRadioBox + 1 + + + m_TextOrient + protected + + 0 + + wxRA_SPECIFY_COLS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + "Normal" "Italic" "Bold" "Bold Italic" + + 1 + + + 0 + wxID_ANY + Style + 1 + + + m_TextStyle + protected + + 0 + + wxRA_SPECIFY_COLS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + "Input" "Output" "Bidi" "TriState" "Passive" + + 1 + + + 0 + wxID_ANY + Glabel Shape: + 1 + + + m_TextShape + protected + + 2 + + wxRA_SPECIFY_COLS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + bSizer4 + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + + + 0 + wxID_ANY + Size + + + m_SizeTitle + protected + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_SIZE + + 0 + + m_TextSize + protected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALIGN_CENTER_HORIZONTAL + 0 + + 8 + protected + 8 + + + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + + + 0 + 1 + 234,0,0 + + 0 + wxID_OK + OK + + + m_buttonOK + protected + + + + + + + + + OnButtonOKClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + + + 0 + 1 + 0,0,187 + + 0 + wxID_CANCEL + Cancel + + + m_buttonCANCEL + protected + + + + + + + + + OnButtonCANCEL_Click + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eeschema/dialog_edit_label_base.h b/eeschema/dialog_edit_label_base.h new file mode 100644 index 0000000000..a041dacf92 --- /dev/null +++ b/eeschema/dialog_edit_label_base.h @@ -0,0 +1,64 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 16 2008) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __dialog_edit_label_base__ +#define __dialog_edit_label_base__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class DialogLabelEditor_Base +/////////////////////////////////////////////////////////////////////////////// +class DialogLabelEditor_Base : public wxDialog +{ + private: + + protected: + enum + { + wxID_VALUE = 1000, + wxID_SIZE, + }; + + wxStaticText* m_staticText1; + wxTextCtrl* m_TextLabel; + wxRadioBox* m_TextOrient; + wxRadioBox* m_TextStyle; + wxRadioBox* m_TextShape; + wxStaticText* m_SizeTitle; + wxTextCtrl* m_TextSize; + + wxButton* m_buttonOK; + wxButton* m_buttonCANCEL; + + // Virtual event handlers, overide them in your derived class + virtual void OnInitDialog( wxInitDialogEvent& event ){ event.Skip(); } + virtual void OnButtonOKClick( wxCommandEvent& event ){ event.Skip(); } + virtual void OnButtonCANCEL_Click( wxCommandEvent& event ){ event.Skip(); } + + + public: + DialogLabelEditor_Base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 401,222 ), long style = wxDEFAULT_DIALOG_STYLE ); + ~DialogLabelEditor_Base(); + +}; + +#endif //__dialog_edit_label_base__ diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 785006b700..7b1d008f54 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -10,6 +10,7 @@ #include "program.h" #include "libcmp.h" #include "general.h" +#include "dialog_edit_label.h" #include "protos.h" @@ -24,15 +25,11 @@ static wxSize OldSize; static int s_DefaultShapeGLabel = (int) NET_INPUT; static int s_DefaultOrientGLabel = 0; -/************************************/ -/* class WinEDA_LabelPropertiesFrame */ -/************************************/ -#include "dialog_edit_label.cpp" /****************************************************************************/ -void WinEDA_LabelPropertiesFrame::TextPropertiesAccept( wxCommandEvent& event ) +void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event ) /****************************************************************************/ { wxString text; @@ -55,6 +52,17 @@ void WinEDA_LabelPropertiesFrame::TextPropertiesAccept( wxCommandEvent& event ) if( m_TextShape ) m_CurrentText->m_Shape = m_TextShape->GetSelection(); + int style = m_TextStyle->GetSelection(); + if ( ( style & 1 ) ) + m_CurrentText->m_Italic = 1; + else + m_CurrentText->m_Italic = 0; + + if ( ( style & 2 ) ) + m_CurrentText->m_Width = m_CurrentText->m_Size.x / 5; + else + m_CurrentText->m_Width = 0; + m_Parent->GetScreen()->SetModify(); /* Make the text size as new default size if it is a new text */ @@ -127,10 +135,8 @@ void WinEDA_SchematicFrame::EditSchematicText( SCH_TEXT* TextStruct, DrawPanel->CursorOff( DC ); RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode ); - WinEDA_LabelPropertiesFrame* frame = new WinEDA_LabelPropertiesFrame( this, - TextStruct, - wxPoint( 30, 30 ) ); - frame->ShowModal(); frame->Destroy(); + DialogLabelEditor* dialog = new DialogLabelEditor( this, TextStruct ); + dialog->ShowModal(); dialog->Destroy(); RedrawOneStruct( DrawPanel, DC, TextStruct, GR_DEFAULT_DRAWMODE ); DrawPanel->CursorOn( DC ); diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index bcbef6fc4d..138c6bbf31 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -13,72 +13,44 @@ #include "protos.h" -#include "id.h" +/* in read_from_file_schematic_items_description.cpp */ +SCH_ITEM* ReadTextDescr( FILE* aFile, wxString& aMsgDiag, char* aLine, + int aBufsize, int* aLineNum, int aSchematicFileVersion ); +int ReadSheetDescr( wxWindow* frame, + char* Line, + FILE* f, + wxString& aMsgDiag, + int* aLineNum, + BASE_SCREEN* Window ); +int ReadSchemaDescr( wxWindow* frame, + char* Line, + FILE* f, + wxString& aMsgDiag, + int* aLineNum, + BASE_SCREEN* Window ); -/* Format des fichiers: - * - entete: - * EESchema Schematic File Version n - * - liste des librairies utilisees - * LIBS:lib1,lib2,... - * - * - description des elements: - * - ici Dimensions du schema, cartouche..: - * $Descr A3 xx yy (format A3 (A..A0 / A..E / "user") xx yy = dims internes ) - * $EndDescr - * - * - ici: polyline - * P L 0 3 - * 2208 1008 - * 2208 1136 - * 2128 1136 - * - * - ici: Segment (wire, bus) ( 1; W = segment type Wire, 2: W = Wire B = Bus - * 3: L ou B = epaisseur ( L = ligne, B = bus) - * W W L (W B B si bus) - * 1856 1008 1856 1136 (debut X,Y fin X,Y) - * - * - ici: Raccord (wire, bus) - * R W L - * 1856 1008 1856 1136 (debut X,Y fin X,Y) - * - * - ici: Sheet ( Sous-feuille de hierarchie) - * $Sheet - * S 1856 1008 1856 1136 (debut X,Y fin X,Y) - * F0 "texte" X X posx posy ; sheetname - * F1 "texte" X X posx posy ; filename - * Fn "label" type side posx posy size ; n lignes de label - * $EndSheet - * - * - ici: composant - * $Comp - * L CAPACITOR C1 H H -30863 -14794 1968 1184 nom, ref, dir et pos - * 1 2016 1136 1904 1024 2128 1248 multi, posx,y, rect encadrement - * 1 0 0 -1 matrice de rotation/miroir - * $EndComp - */ +int ReadPartDescr( wxWindow* frame, + char* Line, + FILE* f, + wxString& aMsgDiag, + int* aLineNum, + BASE_SCREEN* Window ); /* Fonctions locales */ -static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window ); -static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window ); -static int ReadSchemaDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window ); static void LoadLayers( FILE* f, int* linecnt ); -/* Variables locales */ -static int LineCount; /* Decompte de num de ligne lue dans eeload() */ -static wxString MsgDiag; /* Error and log messages */ - /************************************************************************************************/ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& FullFileName ) /************************************************************************************************/ /* Routine to load an EESchema file. - * Returns TRUE if file has been loaded (at least partially.) + * Returns true if file has been loaded (at least partially.) */ { char Line[1024], * SLine; char Name1[256], Name2[256]; - int ii, layer, orient, size; + int ii, layer; wxPoint pos; bool Failed = FALSE; SCH_ITEM* Phead, * Pnext; @@ -88,6 +60,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F DrawBusEntryStruct* RaccordStruct; DrawMarkerStruct* MarkerStruct; DrawNoConnectStruct* NoConnectStruct; + int LineCount; /* Decompte de num de ligne lue dans eeload() */ + wxString MsgDiag; /* Error and log messages */ FILE* f; @@ -122,16 +96,17 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F //get the file version here. TODO: Support version numbers > 9 char version = Line[9 + sizeof(SCHEMATIC_HEAD_STRING)]; - int ver = version - '0'; + int ver = version - '0'; if( ver > EESCHEMA_VERSION ) { MsgDiag = FullFileName + _( " was created by a more recent version of EESchema and may not load correctly. Please consider updating!" ); DisplayInfo( this, MsgDiag ); } + #if 0 - // Compile it if the new versiopn is unreadable by previous eeschema versions + // Compile it if the new version is unreadable by previous eeschema versions else if( ver < EESCHEMA_VERSION ) { MsgDiag = FullFileName + _( @@ -161,21 +136,18 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F { case '$': /* identification de bloc */ if( Line[1] == 'C' ) - { - Failed = ReadPartDescr( this, Line, f, screen ); - } + Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, screen ); + else if( Line[1] == 'S' ) - { - Failed = ReadSheetDescr( this, Line, f, screen ); - } + Failed = ReadSheetDescr( this, Line, f, MsgDiag, &LineCount, screen ); + else if( Line[1] == 'D' ) - { - Failed = ReadSchemaDescr( this, Line, f, screen ); - } + Failed = ReadSchemaDescr( this, Line, f, MsgDiag, &LineCount, screen ); + break; case 'L': /* Its a library item. */ - Failed = ReadPartDescr( this, Line, f, screen ); + Failed = ReadPartDescr( this, Line, f, MsgDiag, &LineCount, screen ); break; /* Fin lecture 1 composant */ @@ -185,7 +157,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F MsgDiag.Printf( wxT( "EESchema file Segment struct error at line %d, aborted" ), LineCount ); - Failed = TRUE; + MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); + Failed = true; break; } layer = LAYER_NOTES; @@ -205,7 +178,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F MsgDiag.Printf( wxT( "EESchema file Segment struct error at line %d, aborted" ), LineCount ); - Failed = TRUE; + MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); + Failed = true; SAFE_DELETE( SegmentStruct ); break; } @@ -213,7 +187,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F if( !Failed ) { SegmentStruct->SetNext( screen->EEDrawList ); - screen->EEDrawList = SegmentStruct; + screen->EEDrawList = SegmentStruct; } break; @@ -224,7 +198,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F MsgDiag.Printf( wxT( "EESchema file record struct error at line %d, aborted" ), LineCount ); - Failed = TRUE; + MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); + Failed = true; break; } @@ -240,9 +215,10 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F &RaccordStruct->m_Size.x, &RaccordStruct->m_Size.y ) != 4 ) { MsgDiag.Printf( - wxT( "EESchema file Raccord struct error at line %d, aborted" ), + wxT( "EESchema file Bus Entry struct error at line %d, aborted" ), LineCount ); - Failed = TRUE; + MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); + Failed = true; SAFE_DELETE( RaccordStruct ); break; } @@ -252,7 +228,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F RaccordStruct->m_Size.x -= RaccordStruct->m_Pos.x; RaccordStruct->m_Size.y -= RaccordStruct->m_Pos.y; RaccordStruct->SetNext( screen->EEDrawList ); - screen->EEDrawList = RaccordStruct; + screen->EEDrawList = RaccordStruct; } break; @@ -262,7 +238,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F MsgDiag.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ), LineCount ); - Failed = TRUE; + MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); + Failed = true; break; } layer = LAYER_NOTES; @@ -286,7 +263,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F MsgDiag.Printf( wxT( "EESchema file polyline struct error at line %d, aborted" ), LineCount ); - Failed = TRUE; + MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); + Failed = true; SAFE_DELETE( PolylineStruct ); break; } @@ -295,11 +273,11 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F if( !Failed ) { PolylineStruct->SetNext( screen->EEDrawList ); - screen->EEDrawList = PolylineStruct; + screen->EEDrawList = PolylineStruct; } break; - case 'C': /* Its a connection item. */ + case 'C': /* It is a connection item. */ ConnectionStruct = new DrawJunctionStruct( wxPoint( 0, 0 ) ); if( sscanf( SLine, "%s %d %d", Name1, @@ -309,7 +287,8 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F MsgDiag.Printf( wxT( "EESchema file connection struct error at line %d, aborted" ), LineCount ); - Failed = TRUE; + MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); + Failed = true; SAFE_DELETE( ConnectionStruct ); } else @@ -319,13 +298,14 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F } break; - case 'N': /* Its a NoConnect item. */ + case 'N': /* It is a NoConnect item. */ if( sscanf( SLine, "%s %d %d", Name1, &pos.x, &pos.y ) != 3 ) { MsgDiag.Printf( wxT( "EESchema file NoConnect struct error at line %d, aborted" ), LineCount ); - Failed = TRUE; + MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); + Failed = true; } else { @@ -336,13 +316,14 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F } break; - case 'K': /* Its a MarKer item. */ + case 'K': /* It is a Marker item. */ if( sscanf( SLine, "%s %d %d", Name1, &pos.x, &pos.y ) != 3 ) { MsgDiag.Printf( wxT( "EESchema file marker struct error line %d, aborted" ), LineCount ); - Failed = TRUE; + MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); + Failed = true; } else { @@ -363,107 +344,30 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F MarkerStruct->m_MarkFlags = ii; } MarkerStruct->SetNext( screen->EEDrawList ); - screen->EEDrawList = MarkerStruct; + screen->EEDrawList = MarkerStruct; } break; - case 'T': /* Its a text item. */ + case 'T': /* It is a text item. */ { - SCH_ITEM* Struct = NULL; - *Name1 = *Name2 = 0; - ii = sscanf( SLine, "%s %d %d %d %d %s", - Name1, &pos.x, &pos.y, &orient, &size, Name2 ); - - if( ii < 4 ) + SCH_ITEM* Struct; + Struct = ReadTextDescr( f, MsgDiag, Line, sizeof(Line), &LineCount, version); + if( Struct ) { - MsgDiag.Printf( - wxT( "EESchema file text struct error line %d, aborted" ), - LineCount ); - Failed = TRUE; - } - else if( fgets( Line, 256 - 1, f ) == NULL ) - { - LineCount++; - MsgDiag.Printf( - wxT( "EESchema file text struct error line %d (No text), aborted" ), - LineCount ); - Failed = TRUE; + Struct->SetNext( screen->EEDrawList ); + screen->EEDrawList = Struct; } else - { - LineCount++; - if( size == 0 ) - size = DEFAULT_SIZE_TEXT; - char* text = strtok( Line, "\n\r" ); - if( text == NULL ) - break; - - if( Name1[0] == 'L' ) - { - SCH_LABEL* TextStruct = - new SCH_LABEL( pos, CONV_FROM_UTF8 ( text ) ); - - TextStruct->m_Size.x = TextStruct->m_Size.y = size; - TextStruct->m_Orient = orient; - Struct = TextStruct; - } - else if( Name1[0] == 'G' && version > '1' ) - { - SCH_GLOBALLABEL* TextStruct = new SCH_GLOBALLABEL( pos, CONV_FROM_UTF8 ( text ) ); - - Struct = TextStruct; - TextStruct->m_Size.x = TextStruct->m_Size.y = size; - TextStruct->m_Orient = orient; - TextStruct->m_Shape = NET_INPUT; - if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 ) - TextStruct->m_Shape = NET_OUTPUT; - if( stricmp( Name2, SheetLabelType[NET_BIDI] ) == 0 ) - TextStruct->m_Shape = NET_BIDI; - if( stricmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 ) - TextStruct->m_Shape = NET_TRISTATE; - if( stricmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 ) - TextStruct->m_Shape = NET_UNSPECIFIED; - } - else if( (Name1[0] == 'H') || (Name1[0] == 'G' && version == '1') ) - { //in schematic file version 1, glabels were actually hierarchal labels. - SCH_HIERLABEL* TextStruct = new SCH_HIERLABEL( pos, CONV_FROM_UTF8 ( text ) ); - - Struct = TextStruct; - TextStruct->m_Size.x = TextStruct->m_Size.y = size; - TextStruct->m_Orient = orient; - TextStruct->m_Shape = NET_INPUT; - if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 ) - TextStruct->m_Shape = NET_OUTPUT; - if( stricmp( Name2, SheetLabelType[NET_BIDI] ) == 0 ) - TextStruct->m_Shape = NET_BIDI; - if( stricmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 ) - TextStruct->m_Shape = NET_TRISTATE; - if( stricmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 ) - TextStruct->m_Shape = NET_UNSPECIFIED; - } - else - { - SCH_TEXT* TextStruct = - new SCH_TEXT( pos, CONV_FROM_UTF8 ( text ) ); - - TextStruct->m_Size.x = TextStruct->m_Size.y = size; - TextStruct->m_Orient = orient; - Struct = TextStruct; - } - if( Struct ) - { - Struct->SetNext( screen->EEDrawList ); - screen->EEDrawList = Struct; - } - } + Failed = true; break; } default: - Failed = FALSE; + Failed = true; MsgDiag.Printf( wxT( "EESchema file undef structdef at line %d, aborted" ), LineCount ); + MsgDiag << wxT( "\n" ) << CONV_FROM_UTF8( Line ); break; } @@ -497,648 +401,7 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F MsgDiag = _( "Done Loading " ) + screen->m_FileName; PrintMsg( MsgDiag ); - return TRUE; /* Although it may be that file is only partially loaded. */ -} - - -/*************************************************************/ -static int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, - BASE_SCREEN* Window ) -/*************************************************************/ - -/* Fonction utilisee par LoadEEFile(). - * Lit les lignes relatives a la description d'un composant en schema - */ -{ - int ii; - char Name1[256], Name2[256], - Char1[256], Char2[256], Char3[256]; - SCH_COMPONENT* component; - int Failed = 0, newfmt = 0; - char* ptcar; - wxString fieldName; - - - component = new SCH_COMPONENT(); - - component->m_Convert = 1; - - if( Line[0] == '$' ) - { - newfmt = 1; - LineCount++; - if( fgets( Line, 256 - 1, f ) == 0 ) - return TRUE; - } - - /* Traitement de la 1ere ligne de description */ - if( sscanf( &Line[1], "%s %s", Name1, Name2 ) != 2 ) - { - MsgDiag.Printf( - wxT( "EESchema Component descr error at line %d, aborted" ), - LineCount ); - Failed = TRUE; - return Failed; - } - - if( strcmp( Name1, NULL_STRING ) != 0 ) - { - for( ii = 0; ii < (int) strlen( Name1 ); ii++ ) - if( Name1[ii] == '~' ) - Name1[ii] = ' '; - - component->m_ChipName = CONV_FROM_UTF8( Name1 ); - if( !newfmt ) - component->GetField( VALUE )->m_Text = CONV_FROM_UTF8( Name1 ); - } - else - { - component->m_ChipName.Empty(); - component->GetField( VALUE )->m_Text.Empty(); - component->GetField( VALUE )->m_Orient = TEXT_ORIENT_HORIZ; - component->GetField( VALUE )->m_Attributs = TEXT_NO_VISIBLE; - } - - if( strcmp( Name2, NULL_STRING ) != 0 ) - { - bool isDigit = false; - for( ii = 0; ii < (int) strlen( Name2 ); ii++ ) - { - if( Name2[ii] == '~' ) - Name2[ii] = ' '; - - // get RefBase from this, too. store in Name1. - if( Name2[ii] >= '0' && Name2[ii] <= '9' ) - { - isDigit = true; - Name1[ii] = 0; //null-terminate. - } - if( !isDigit ) - { - Name1[ii] = Name2[ii]; - } - } - - Name1[ii] = 0; //just in case - int jj; - for( jj = 0; jjm_PrefixString = wxT( "U" ); - } - else - { - component->m_PrefixString = CONV_FROM_UTF8( &Name1[jj] ); - - //printf("prefix: %s\n", CONV_TO_UTF8(component->m_PrefixString)); - } - if( !newfmt ) - component->GetField( REFERENCE )->m_Text = CONV_FROM_UTF8( Name2 ); - } - else - { - component->GetField( REFERENCE )->m_Attributs = TEXT_NO_VISIBLE; - } - - /* Traitement des autres lignes de description */ - - /* Ces lignes commencent par: - * "P " = position - * "U " = Num Unit, et Conversion - * "Fn" = Champs ( n = 0.. = numero de champ ) - * "Ar" = AlternateReference, in the case of multiple sheets - * referring to one schematic file. - */ - - /* Lecture des champs */ - for( ; ; ) - { - LineCount++; - if( fgets( Line, 256 - 1, f ) == NULL ) - return TRUE; - - if( Line[0] == 'U' ) /* Lecture num multi, conversion et time stamp */ - { - sscanf( Line + 1, "%d %d %lX", - &component->m_Multi, &component->m_Convert, - &component->m_TimeStamp ); - } - - else if( Line[0] == 'P' ) - { - sscanf( Line + 1, "%d %d", - &component->m_Pos.x, &component->m_Pos.y ); - } - - else if( Line[0] == 'A' && Line[1] == 'R' ) - { - /* format: - * AR Path="/9086AF6E/67452AA0" Ref="C99" Part="1" - * where 9086AF6E is the unique timestamp of the containing sheet - * and 67452AA0 is the timestamp of this component. - * C99 is the reference given this path. - */ - int ii; - ptcar = Line + 2; - - //copy the path. - ii = ReadDelimitedText( Name1, ptcar, 255 ); - ptcar += ii + 1; - wxString path = CONV_FROM_UTF8( Name1 ); - - // copy the reference - ii = ReadDelimitedText( Name1, ptcar, 255 ); - ptcar += ii + 1; - wxString ref = CONV_FROM_UTF8( Name1 ); - - // copy the multi, if exists - ii = ReadDelimitedText( Name1, ptcar, 255 ); - if( Name1[0] == 0 ) // Nothing read, put a default value - sprintf( Name1, "%d", component->m_Multi ); - int multi = atoi( Name1 ); - if( multi < 0 || multi > 25 ) - multi = 1; - component->AddHierarchicalReference( path, ref, multi ); - component->GetField( REFERENCE )->m_Text = ref; - } - - else if( Line[0] == 'F' ) - { - int fieldNdx; - - char FieldUserName[1024]; - GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER; - GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER; - - FieldUserName[0] = 0; - - /* Lecture du champ */ - ptcar = Line; - - while( *ptcar && (*ptcar != '"') ) - ptcar++; - - if( *ptcar != '"' ) - { - MsgDiag.Printf( - wxT( "EESchema file lib field F at line %d, aborted" ), - LineCount ); - return TRUE; - } - - for( ptcar++, ii = 0; ; ii++, ptcar++ ) - { - Name1[ii] = *ptcar; - if( *ptcar == 0 ) - { - MsgDiag.Printf( - wxT( "Component field F at line %d, aborted" ), - LineCount ); - return TRUE; - } - - if( *ptcar == '"' ) - { - Name1[ii] = 0; - ptcar++; - break; - } - } - - fieldNdx = atoi( Line+2 ); - - ReadDelimitedText( FieldUserName, ptcar, sizeof(FieldUserName) ); - - if( !FieldUserName[0] ) - fieldName = ReturnDefaultFieldName( fieldNdx ); - else - fieldName = CONV_FROM_UTF8( FieldUserName ); - - if( fieldNdx >= component->GetFieldCount() ) - { - // add as many fields as needed so the m_FieldId's are contiguous, no gaps. - while( fieldNdx >= component->GetFieldCount() ) - { - int newNdx = component->GetFieldCount(); - - SCH_CMP_FIELD f( wxPoint(0,0), newNdx, component, fieldName ); - component->AddField( f ); - } - } - else - { - component->GetField( fieldNdx )->m_Name = fieldName; - } - - component->GetField( fieldNdx )->m_Text = CONV_FROM_UTF8( Name1 ); - - if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", Char1, - &component->GetField( fieldNdx )->m_Pos.x, - &component->GetField( fieldNdx )->m_Pos.y, - &component->GetField( fieldNdx )->m_Size.x, - &component->GetField( fieldNdx )->m_Attributs, - Char2, Char3 ) ) < 4 ) - { - MsgDiag.Printf( - wxT( "Component Field error line %d, aborted" ), - LineCount ); - DisplayError( frame, MsgDiag ); - continue; - } - - if( (component->GetField( fieldNdx )->m_Size.x == 0 ) || (ii == 4) ) - component->GetField( fieldNdx )->m_Size.x = DEFAULT_SIZE_TEXT; - - component->GetField( fieldNdx )->m_Orient = TEXT_ORIENT_HORIZ; - component->GetField( fieldNdx )->m_Size.y = component->GetField( fieldNdx )->m_Size.x; - - if( Char1[0] == 'V' ) - component->GetField( fieldNdx )->m_Orient = TEXT_ORIENT_VERT; - - if( ii >= 7 ) - { - if( *Char2 == 'L' ) - hjustify = GR_TEXT_HJUSTIFY_LEFT; - else if( *Char2 == 'R' ) - hjustify = GR_TEXT_HJUSTIFY_RIGHT; - if( *Char3 == 'B' ) - vjustify = GR_TEXT_VJUSTIFY_BOTTOM; - else if( *Char3 == 'T' ) - vjustify = GR_TEXT_VJUSTIFY_TOP; - - component->GetField( fieldNdx )->m_HJustify = hjustify; - component->GetField( fieldNdx )->m_VJustify = vjustify; - } - - if( fieldNdx == REFERENCE ) - if( component->GetField( fieldNdx )->m_Text[0] == '#' ) - component->GetField( fieldNdx )->m_Attributs |= TEXT_NO_VISIBLE; - } - else - break; - } - - /* Lecture multi et position du composant */ - if( sscanf( Line, "%d %d %d", - &component->m_Multi, - &component->m_Pos.x, &component->m_Pos.y ) != 3 ) - { - MsgDiag.Printf( - wxT( "Component unit & pos error at line %d, aborted" ), - LineCount ); - Failed = TRUE; - return Failed; - } - - /* Lecture de la matrice de miroir / rotation */ - LineCount++; - if( (fgets( Line, 256 - 1, f ) == NULL) - || (sscanf( Line, "%d %d %d %d", - &component->m_Transform[0][0], - &component->m_Transform[0][1], - &component->m_Transform[1][0], - &component->m_Transform[1][1] ) != 4) ) - { - MsgDiag.Printf( - wxT( "Component orient error at line %d, aborted" ), - LineCount ); - Failed = TRUE; - return Failed; - } - - if( newfmt ) - { - LineCount++; - if( fgets( Line, 256 - 1, f ) == NULL ) - return TRUE; - if( strnicmp( "$End", Line, 4 ) != 0 ) - { - MsgDiag.Printf( - wxT( "Component End expected at line %d, aborted" ), - LineCount ); - Failed = TRUE; - } - } - - if( !Failed ) - { - component->SetNext( Window->EEDrawList ); - Window->EEDrawList = component; - component->SetParent( Window ); - } - - return Failed; /* Fin lecture 1 composant */ -} - - -/*************************************************************************************/ -static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window ) -/*************************************************************************************/ - -/* Fonction utilisee par LoadEEFile(). - * Lit les lignes relatives a la description d'une feuille de hierarchie - */ -{ - int ii, fieldNdx, size; - char Name1[256], Char1[256], Char2[256]; - DrawSheetStruct* SheetStruct; - Hierarchical_PIN_Sheet_Struct* SheetLabelStruct, * OldSheetLabel = NULL; - int Failed = FALSE; - char* ptcar; - - SheetStruct = new DrawSheetStruct(); - - SheetStruct->m_TimeStamp = GetTimeStamp(); - - //sheets are added to the EEDrawList like other schematic components. - //however, in order to preserve the heirarchy (through m_Parent pointers), - //a duplicate of the sheet is added to m_SubSheet array. - //must be a duplicate, references just work for a two-layer structure. - //this is accomplished through the Sync() function. - - if( Line[0] == '$' ) /* Ligne doit etre "$Sheet" */ - { - LineCount++; - if( fgets( Line, 256 - 1, f ) == 0 ) - { - MsgDiag.Printf( wxT( "Read File Errror" ) ); return TRUE; - } - } - - /* Next line: must be "S xx yy nn mm" with xx, yy = sheet position - * ( upper left corner ) et nn,mm = sheet size */ - if( (sscanf( &Line[1], "%d %d %d %d", - &SheetStruct->m_Pos.x, &SheetStruct->m_Pos.y, - &SheetStruct->m_Size.x, &SheetStruct->m_Size.y ) != 4) - || (Line[0] != 'S' ) ) - { - MsgDiag.Printf( - wxT( " ** EESchema file sheet struct error at line %d, aborted" ), - LineCount ); - Failed = TRUE; - return Failed; - } - - /* Lecture des champs */ - for( ; ; ) /* Analyse des lignes "Fn "texte" .." */ - { - LineCount++; - if( fgets( Line, 256 - 1, f ) == NULL ) - return TRUE; - if( Line[0] == 'U' ) - { - sscanf( Line + 1, "%lX", &(SheetStruct->m_TimeStamp) ); - if( SheetStruct->m_TimeStamp == 0 ) //zero is not unique! - SheetStruct->m_TimeStamp = GetTimeStamp(); - continue; - } - if( Line[0] != 'F' ) - break; - sscanf( Line + 1, "%d", &fieldNdx ); - - /* Lecture du champ : - * si fieldNdx >= 2 : Fn "texte" t s posx posy - * sinon F0 "texte" pour sheetname - * et F1 "texte" pour filename */ - - ptcar = Line; while( *ptcar && (*ptcar != '"') ) - ptcar++; - - if( *ptcar != '"' ) - { - MsgDiag.Printf( - wxT( " ** EESchema file sheet label F%d at line %d, aborted" ), - fieldNdx, LineCount ); - return TRUE; - } - - for( ptcar++, ii = 0; ; ii++, ptcar++ ) - { - Name1[ii] = *ptcar; - if( *ptcar == 0 ) - { - MsgDiag.Printf( - wxT( " ** EESchema file sheet field F at line %d, aborted" ), LineCount ); - return TRUE; - } - if( *ptcar == '"' ) - { - Name1[ii] = 0; ptcar++; - break; - } - } - - if( ( fieldNdx == 0 ) || ( fieldNdx == 1 ) ) - { - if( sscanf( ptcar, "%d", &size ) != 1 ) - { - MsgDiag.Printf( - wxT( - " ** EESchema file sheet Label Caract error line %d, aborted" ), LineCount ); - DisplayError( frame, MsgDiag ); - } - if( size == 0 ) - size = DEFAULT_SIZE_TEXT; - if( fieldNdx == 0 ) - { - SheetStruct->m_SheetName = CONV_FROM_UTF8( Name1 ); - SheetStruct->m_SheetNameSize = size; - } - else - { - SheetStruct->SetFileName( CONV_FROM_UTF8( Name1 ) ); - - //printf("in ReadSheetDescr : SheetStruct->m_FileName = %s \n", Name1); - SheetStruct->m_FileNameSize = size; - } - } - - if( fieldNdx > 1 ) - { - SheetLabelStruct = new Hierarchical_PIN_Sheet_Struct( SheetStruct, - wxPoint( 0, - 0 ), CONV_FROM_UTF8 ( Name1 ) ); - - if( SheetStruct->m_Label == NULL ) - OldSheetLabel = SheetStruct->m_Label = SheetLabelStruct; - else - OldSheetLabel->SetNext( (EDA_BaseStruct*) SheetLabelStruct ); - OldSheetLabel = SheetLabelStruct; - - /* Lecture des coordonnees */ - if( sscanf( ptcar, "%s %s %d %d %d", Char1, Char2, - &SheetLabelStruct->m_Pos.x, &SheetLabelStruct->m_Pos.y, - &size ) != 5 ) - { - MsgDiag.Printf( - wxT( - " ** EESchema file Sheet Label Caract error line %d, aborted" ), LineCount ); - DisplayError( frame, MsgDiag ); - continue; - } - - if( size == 0 ) - size = DEFAULT_SIZE_TEXT; - SheetLabelStruct->m_Size.x = SheetLabelStruct->m_Size.y = size; - - /* Mise a jour des cadrage et type */ - switch( Char1[0] ) - { - case 'I': - SheetLabelStruct->m_Shape = NET_INPUT; break; - - case 'O': - SheetLabelStruct->m_Shape = NET_OUTPUT; break; - - case 'B': - SheetLabelStruct->m_Shape = NET_BIDI; break; - - case 'T': - SheetLabelStruct->m_Shape = NET_TRISTATE; break; - - case 'U': - SheetLabelStruct->m_Shape = NET_UNSPECIFIED; break; - } - - if( Char2[0] == 'R' ) - SheetLabelStruct->m_Edge = 1; - } - } - - if( strnicmp( "$End", Line, 4 ) != 0 ) - { - MsgDiag.Printf( - wxT( " **EESchema file end_sheet struct error at line %d, aborted" ), - LineCount ); - Failed = TRUE; - } - if( !Failed ) - { - SheetStruct->SetNext( Window->EEDrawList ); - Window->EEDrawList = SheetStruct; - SheetStruct->SetParent( Window ); - } - return Failed; /* Fin lecture 1 composant */ -} - - -/******************************************************************/ -static int ReadSchemaDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Window ) -/******************************************************************/ - -/* Analyse de l'entete du schema ( dims feuille, cartouche..) - */ -{ - char Text[256], buf[1024]; - int ii; - Ki_PageDescr* wsheet = &g_Sheet_A4; - static Ki_PageDescr* SheetFormatList[] = { - &g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0, - &g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E, - &g_Sheet_user, NULL - }; - wxSize PageSize; - - sscanf( Line, "%s %s %d %d", Text, Text, &PageSize.x, &PageSize.y ); - /* Recherche de la descr correspondante: */ - wxString pagename = CONV_FROM_UTF8( Text ); - for( ii = 0; SheetFormatList[ii] != NULL; ii++ ) - { - wsheet = SheetFormatList[ii]; - if( wsheet->m_Name.CmpNoCase( pagename ) == 0 ) - { /* Descr found ! */ - if( wsheet == &g_Sheet_user ) // Get the user page size and make it the default - { - g_Sheet_user.m_Size = PageSize; - } - break; - } - } - - if( SheetFormatList[ii] == NULL ) - { - /* Erreur ici: descr non trouvee */ - MsgDiag.Printf( - wxT( "EESchema file Dims Caract error line %d, aborted" ), LineCount ); - DisplayError( frame, MsgDiag ); - } - - /* Ajuste ecran */ - Window->m_CurrentSheetDesc = wsheet; - - /* Recheche suite et fin de descr */ - for( ; ; ) - { - if( GetLine( f, Line, &LineCount, 1024 ) == NULL ) - return TRUE; - if( strnicmp( Line, "$End", 4 ) == 0 ) - break; - - if( strnicmp( Line, "Sheet", 2 ) == 0 ) - sscanf( Line + 5, " %d %d", - &Window->m_ScreenNumber, &Window->m_NumberOfScreen ); - - if( strnicmp( Line, "Title", 2 ) == 0 ) - { - ReadDelimitedText( buf, Line, 256 ); - Window->m_Title = CONV_FROM_UTF8( buf ); - continue; - } - - if( strnicmp( Line, "Date", 2 ) == 0 ) - { - ReadDelimitedText( buf, Line, 256 ); - Window->m_Date = CONV_FROM_UTF8( buf ); - continue; - } - - if( strnicmp( Line, "Rev", 2 ) == 0 ) - { - ReadDelimitedText( buf, Line, 256 ); - Window->m_Revision = CONV_FROM_UTF8( buf ); - continue; - } - - if( strnicmp( Line, "Comp", 4 ) == 0 ) - { - ReadDelimitedText( buf, Line, 256 ); - Window->m_Company = CONV_FROM_UTF8( buf ); - continue; - } - - if( strnicmp( Line, "Comment1", 8 ) == 0 ) - { - ReadDelimitedText( buf, Line, 256 ); - Window->m_Commentaire1 = CONV_FROM_UTF8( buf ); - continue; - } - - if( strnicmp( Line, "Comment2", 8 ) == 0 ) - { - ReadDelimitedText( buf, Line, 256 ); - Window->m_Commentaire2 = CONV_FROM_UTF8( buf ); - continue; - } - - if( strnicmp( Line, "Comment3", 8 ) == 0 ) - { - ReadDelimitedText( buf, Line, 256 ); - Window->m_Commentaire3 = CONV_FROM_UTF8( buf ); - continue; - } - - if( strnicmp( Line, "Comment4", 8 ) == 0 ) - { - ReadDelimitedText( buf, Line, 256 ); - Window->m_Commentaire4 = CONV_FROM_UTF8( buf ); - continue; - } - } - - return FALSE; + return true; /* Although it may be that file is only partially loaded. */ } diff --git a/eeschema/makefile.include b/eeschema/makefile.include index 9a6c36e4af..80050d7eab 100644 --- a/eeschema/makefile.include +++ b/eeschema/makefile.include @@ -53,11 +53,14 @@ OBJECTS = eeschema.o\ netlist.o\ netlist_control.o\ edit_label.o\ + dialog_edit_label.o\ + dialog_edit_label_base.o\ edit_component_in_schematic.o\ dialog_edit_component_in_schematic_fbp.o \ dialog_edit_component_in_schematic.o \ locate.o \ save_schemas.o sheet.o \ + read_from_file_schematic_items_descriptions.o\ viewlibs.o \ libedit.o \ libframe.o \ @@ -97,13 +100,18 @@ OBJECTS = eeschema.o\ eeschema.o: eeschema.cpp program.h general.h $(DEPEND) +read_from_file_schematic_items_descriptions.o: read_from_file_schematic_items_descriptions.cpp + + #edit_component_in_lib.o: edit_component_in_lib.cpp\ # dialog_edit_component_in_lib.cpp dialog_edit_component_in_lib.h $(DEPEND) edit_component_in_schematic.o: edit_component_in_schematic.cpp\ dialog_edit_component_in_schematic.cpp dialog_edit_component_in_schematic.h $(DEPEND) -edit_label.o: edit_label.cpp dialog_edit_label.cpp dialog_edit_label.h $(DEPEND) +edit_label.o: edit_label.cpp dialog_edit_label.h dialog_edit_label_base.h $(DEPEND) + +dialog_edit_label.o: dialog_edit_label.cpp dialog_edit_label.h dialog_edit_label_base.h $(DEPEND) dialog_create_component.o: dialog_create_component.cpp dialog_create_component.h $(DEPEND) diff --git a/eeschema/plot.cpp b/eeschema/plot.cpp index 433aa51bac..60444c8d9f 100644 --- a/eeschema/plot.cpp +++ b/eeschema/plot.cpp @@ -252,11 +252,13 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem ) t1 = (TransMat[0][0] != 0) ^ (Text->m_Horiz != 0); pos = TransformCoordinate( TransMat, Text->m_Pos ) + DrawLibItem->m_Pos; SetCurrentLineWidth( -1 ); + int thickness = Text->m_Width; // @todo: calcultae the pen tickness PlotGraphicText( g_PlotFormat, pos, CharColor, Text->m_Text, t1 ? TEXT_ORIENT_HORIZ : TEXT_ORIENT_VERT, Text->m_Size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER ); + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, + thickness); } break; @@ -282,7 +284,6 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem ) LibDrawPin* Pin = (LibDrawPin*) DEntry; if( Pin->m_Attributs & PINNOTDRAW ) { -// if( ActiveScreen->m_Type == SCHEMATIC_FRAME ) break; } @@ -294,9 +295,11 @@ void PlotLibPart( SCH_COMPONENT* DrawLibItem ) /* Dessin de la pin et du symbole special associe */ SetCurrentLineWidth( -1 ); PlotPinSymbol( pos, Pin->m_PinLen, orient, Pin->m_PinShape ); + int thickness = 0; // @todo: calcultae the pen tickness Pin->PlotPinTexts( pos, orient, Entry->m_TextInside, - Entry->m_DrawPinNum, Entry->m_DrawPinName ); + Entry->m_DrawPinNum, Entry->m_DrawPinName, + thickness, false); } break; @@ -463,14 +466,16 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem, } SetCurrentLineWidth( -1 ); + int thickness = field->m_Width; // @todo: calculate the pen tickness - //not sure what to do here in terms of plotting components that may have multiple REFERENCE entries. + //@todo not sure what to do here in terms of plotting components that may have multiple REFERENCE entries. if( !IsMulti || (FieldNumber != REFERENCE) ) { PlotGraphicText( g_PlotFormat, textpos, color, field->m_Text, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, field->m_Size, - hjustify, vjustify ); + hjustify, vjustify, + thickness, field->m_Italic); } else /* We plt the reference, for a multiple parts per package */ { @@ -485,7 +490,8 @@ static void PlotTextField( SCH_COMPONENT* DrawLibItem, #endif PlotGraphicText( g_PlotFormat, textpos, color, Text, orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, - field->m_Size, hjustify, vjustify ); + field->m_Size, hjustify, vjustify, + thickness, field->m_Italic ); } } @@ -613,6 +619,9 @@ void PlotTextStruct( EDA_BaseStruct* Struct ) wxString Text; EDA_Colors color = UNSPECIFIED_COLOR; + bool italic = false; + int thickness = 0; + switch( Struct->Type() ) { case TYPE_SCH_GLOBALLABEL: @@ -621,6 +630,8 @@ void PlotTextStruct( EDA_BaseStruct* Struct ) case TYPE_SCH_TEXT: Text = ( (SCH_TEXT*) Struct )->m_Text; Size = ( (SCH_TEXT*) Struct )->m_Size; + thickness = ( (SCH_TEXT*) Struct )->m_Width; + italic = ( (SCH_TEXT*) Struct )->m_Italic; Orient = ( (SCH_TEXT*) Struct )->m_Orient; Shape = ( (SCH_TEXT*) Struct )->m_Shape; pX = ( (SCH_TEXT*) Struct )->m_Pos.x; @@ -641,7 +652,6 @@ void PlotTextStruct( EDA_BaseStruct* Struct ) Size = wxSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT ); SetCurrentLineWidth( -1 ); - if ( Struct->Type() == TYPE_SCH_GLOBALLABEL ) { offset = ( (SCH_GLOBALLABEL*) Struct )->m_Width; @@ -669,44 +679,52 @@ void PlotTextStruct( EDA_BaseStruct* Struct ) if( Struct->Type() == TYPE_SCH_GLOBALLABEL || Struct->Type() == TYPE_SCH_HIERLABEL ) PlotGraphicText( g_PlotFormat, wxPoint( pX - offset, pY ), color, Text, TEXT_ORIENT_HORIZ, Size, - GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER ); + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, + thickness, italic ); else PlotGraphicText( g_PlotFormat, wxPoint( pX, pY - offset ), color, Text, TEXT_ORIENT_HORIZ, Size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM ); + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, + thickness, italic ); break; case 1: /* Orientation vert UP */ if( Struct->Type() == TYPE_SCH_GLOBALLABEL || Struct->Type() == TYPE_SCH_HIERLABEL ) PlotGraphicText( g_PlotFormat, wxPoint( pX, pY + offset ), color, Text, TEXT_ORIENT_VERT, Size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP ); + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, + thickness, italic ); else PlotGraphicText( g_PlotFormat, wxPoint( pX - offset, pY ), color, Text, TEXT_ORIENT_VERT, Size, - GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM ); + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, + thickness, italic ); break; case 2: /* Horiz Orientation - Right justified */ if( Struct->Type() == TYPE_SCH_GLOBALLABEL || Struct->Type() == TYPE_SCH_HIERLABEL ) PlotGraphicText( g_PlotFormat, wxPoint( pX + offset, pY ), color, Text, TEXT_ORIENT_HORIZ, Size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER ); + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, + thickness, italic ); else PlotGraphicText( g_PlotFormat, wxPoint( pX, pY + offset ), color, Text, TEXT_ORIENT_HORIZ, Size, - GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM ); + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, + thickness, italic ); break; case 3: /* Orientation vert BOTTOM */ if( Struct->Type() == TYPE_SCH_GLOBALLABEL || Struct->Type() == TYPE_SCH_HIERLABEL ) PlotGraphicText( g_PlotFormat, wxPoint( pX, pY - offset ), color, Text, TEXT_ORIENT_VERT, Size, - GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM ); + GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, + thickness, italic ); else PlotGraphicText( g_PlotFormat, wxPoint( pX + offset, pY ), color, Text, TEXT_ORIENT_VERT, Size, - GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_TOP ); + GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_TOP, + thickness, italic ); break; } @@ -748,9 +766,12 @@ static void PlotSheetLabelStruct( Hierarchical_PIN_Sheet_Struct* Struct ) tposx = posx + size + (size / 8); side = GR_TEXT_HJUSTIFY_LEFT; } + int thickness = Struct->m_Width; + bool italic = Struct->m_Italic; PlotGraphicText( g_PlotFormat, wxPoint( tposx, posy ), txtcolor, Struct->m_Text, TEXT_ORIENT_HORIZ, wxSize( size, size ), - side, GR_TEXT_VJUSTIFY_CENTER ); + side, GR_TEXT_VJUSTIFY_CENTER, + thickness, italic ); /* dessin du symbole de connexion */ if( Struct->m_Edge ) @@ -837,9 +858,12 @@ void PlotSheetStruct( DrawSheetStruct* Struct ) if( (g_PlotFormat == PLOT_FORMAT_POST) && g_PlotPSColorOpt ) SetColorMapPS( ReturnLayerColor( LAYER_SHEETNAME ) ); + int thickness = 0; //@todo use current pen width + bool italic = false; PlotGraphicText( g_PlotFormat, pos, txtcolor, Text, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM ); + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, + thickness, italic ); /* Trace des textes : FileName */ Text = Struct->GetFileName(); @@ -852,7 +876,8 @@ void PlotSheetStruct( DrawSheetStruct* Struct ) wxPoint( Struct->m_Pos.x, Struct->m_Pos.y + Struct->m_Size.y + 4 ), txtcolor, Text, TEXT_ORIENT_HORIZ, size, - GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP ); + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, + thickness, italic ); /* Trace des textes : SheetLabel */ SheetLabelStruct = Struct->m_Label; diff --git a/eeschema/read_from_file_schematic_items_descriptions.cpp b/eeschema/read_from_file_schematic_items_descriptions.cpp new file mode 100644 index 0000000000..d382022bd2 --- /dev/null +++ b/eeschema/read_from_file_schematic_items_descriptions.cpp @@ -0,0 +1,798 @@ +/* read_from_file_schematic_items_descriptions.cpp */ + +/*functions to read schematic items descriptions from file + */ +#include "fctsys.h" + +#include "common.h" +#include "program.h" +#include "libcmp.h" +#include "general.h" + +#include "protos.h" + + +SCH_ITEM* ReadTextDescr( FILE * aFile, + wxString & aMsgDiag, + char* aLine, + int aBufsize, + int* aLineNum, + int aSchematicFileVersion) +{ +/** + * Function ReadTextDescr + * Reads the data structures for a Text (Comment, label, Hlabel and Hlabel + * from a FILE in "*.brd" format. + * @param aFile The FILE to read. + * @param aLine The buffer used to read the first line of description. + * @param aBufsize The size of aLine. + * @param aLineNum a pointer to the line count. + * @return a poiner to the new created obect if success reading else NULL. + */ + SCH_ITEM* Struct = NULL; + char Name1[256]; + char Name2[256]; + char Name3[256]; + int width = 0, size = 0, orient = 0; + wxPoint pos; + + char* SLine = aLine; + + while( (*SLine != ' ' ) && *SLine ) + SLine++; + + // SLine points the start of parameters + + Name1[0] = 0; Name2[0] = 0; Name3[0] = 0; + int ii = sscanf( SLine, "%s %d %d %d %d %s %s %d", + Name1, &pos.x, &pos.y, &orient, &size, Name2, Name3, &width ); + + if( ii < 4 ) + { + aMsgDiag.Printf( + wxT( "EESchema file text struct error line %d, aborted" ), + *aLineNum ); + return NULL; + } + + if( feof( aFile ) || GetLine( aFile, aLine, aLineNum, aBufsize) == NULL ) + { + aMsgDiag.Printf( + wxT( "EESchema file text struct error line %d (No text), aborted" ), + *aLineNum ); + return NULL; + } + if( size == 0 ) + size = DEFAULT_SIZE_TEXT; + char* text = strtok( aLine, "\n\r" ); + if( text == NULL ) + return NULL; + + if( Name1[0] == 'L' ) + { + SCH_LABEL* TextStruct = + new SCH_LABEL( pos, CONV_FROM_UTF8( text ) ); + + TextStruct->m_Size.x = TextStruct->m_Size.y = size; + TextStruct->m_Orient = orient; + TextStruct->m_Width = width; + Struct = TextStruct; + if( stricmp( Name2, "Italic" ) == 0 ) + TextStruct->m_Italic = 1; + } + else if( Name1[0] == 'G' && aSchematicFileVersion > '1' ) + { + SCH_GLOBALLABEL* TextStruct = new SCH_GLOBALLABEL( pos, CONV_FROM_UTF8( text ) ); + + Struct = TextStruct; + TextStruct->m_Size.x = TextStruct->m_Size.y = size; + TextStruct->m_Orient = orient; + TextStruct->m_Shape = NET_INPUT; + TextStruct->m_Width = width; + + if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 ) + TextStruct->m_Shape = NET_OUTPUT; + if( stricmp( Name2, SheetLabelType[NET_BIDI] ) == 0 ) + TextStruct->m_Shape = NET_BIDI; + if( stricmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 ) + TextStruct->m_Shape = NET_TRISTATE; + if( stricmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 ) + TextStruct->m_Shape = NET_UNSPECIFIED; + if( stricmp( Name3, "Italic" ) == 0 ) + TextStruct->m_Italic = 1; + } + else if( (Name1[0] == 'H') || (Name1[0] == 'G' && aSchematicFileVersion == '1') ) + { //in schematic file version 1, glabels were actually hierarchal labels. + SCH_HIERLABEL* TextStruct = new SCH_HIERLABEL( pos, CONV_FROM_UTF8( text ) ); + + Struct = TextStruct; + TextStruct->m_Size.x = TextStruct->m_Size.y = size; + TextStruct->m_Orient = orient; + TextStruct->m_Shape = NET_INPUT; + TextStruct->m_Width = width; + + if( stricmp( Name2, SheetLabelType[NET_OUTPUT] ) == 0 ) + TextStruct->m_Shape = NET_OUTPUT; + if( stricmp( Name2, SheetLabelType[NET_BIDI] ) == 0 ) + TextStruct->m_Shape = NET_BIDI; + if( stricmp( Name2, SheetLabelType[NET_TRISTATE] ) == 0 ) + TextStruct->m_Shape = NET_TRISTATE; + if( stricmp( Name2, SheetLabelType[NET_UNSPECIFIED] ) == 0 ) + TextStruct->m_Shape = NET_UNSPECIFIED; + if( stricmp( Name3, "Italic" ) == 0 ) + TextStruct->m_Italic = 1; + } + else + { + SCH_TEXT* TextStruct = + new SCH_TEXT( pos, CONV_FROM_UTF8( text ) ); + + TextStruct->m_Size.x = TextStruct->m_Size.y = size; + TextStruct->m_Orient = orient; + TextStruct->m_Width = width; + + if( strnicmp( Name2, "Italic", 6 ) == 0 ) + TextStruct->m_Italic = 1; + Struct = TextStruct; + } + + return Struct; +} + + +/*************************************************************************************/ +int ReadSheetDescr( wxWindow* frame, + char* Line, + FILE* f, + wxString& aMsgDiag, int* aLineNum, + BASE_SCREEN* Window ) +/*************************************************************************************/ + +/* Fonction utilisee par LoadEEFile(). + * Lit les lignes relatives a la description d'une feuille de hierarchie + */ +{ + int ii, fieldNdx, size; + char Name1[256], Char1[256], Char2[256]; + DrawSheetStruct* SheetStruct; + Hierarchical_PIN_Sheet_Struct* SheetLabelStruct, * OldSheetLabel = NULL; + int Failed = FALSE; + char* ptcar; + + SheetStruct = new DrawSheetStruct(); + + SheetStruct->m_TimeStamp = GetTimeStamp(); + + //sheets are added to the EEDrawList like other schematic components. + //however, in order to preserve the hierarchy (through m_Parent pointers), + //a duplicate of the sheet is added to m_SubSheet array. + //must be a duplicate, references just work for a two-layer structure. + //this is accomplished through the Sync() function. + + if( Line[0] == '$' ) /* Ligne doit etre "$Sheet" */ + { + *aLineNum++; + if( fgets( Line, 256 - 1, f ) == 0 ) + { + aMsgDiag.Printf( wxT( "Read File Errror" ) ); + return TRUE; + } + } + + /* Next line: must be "S xx yy nn mm" with xx, yy = sheet position + * ( upper left corner ) et nn,mm = sheet size */ + if( (sscanf( &Line[1], "%d %d %d %d", + &SheetStruct->m_Pos.x, &SheetStruct->m_Pos.y, + &SheetStruct->m_Size.x, &SheetStruct->m_Size.y ) != 4) + || (Line[0] != 'S' ) ) + { + aMsgDiag.Printf( + wxT( " ** EESchema file sheet struct error at line %d, aborted\n" ), + *aLineNum ); + aMsgDiag << CONV_FROM_UTF8(Line); + Failed = TRUE; + return Failed; + } + + /* Read fields */ + for( ; ; ) /* Analyse des lignes "Fn "texte" .." */ + { + *aLineNum++; + if( fgets( Line, 256 - 1, f ) == NULL ) + return TRUE; + if( Line[0] == 'U' ) + { + sscanf( Line + 1, "%lX", &(SheetStruct->m_TimeStamp) ); + if( SheetStruct->m_TimeStamp == 0 ) //zero is not unique! + SheetStruct->m_TimeStamp = GetTimeStamp(); + continue; + } + if( Line[0] != 'F' ) + break; + sscanf( Line + 1, "%d", &fieldNdx ); + + /* Lecture du champ : + * si fieldNdx >= 2 : Fn "texte" t s posx posy + * sinon F0 "texte" pour sheetname + * et F1 "texte" pour filename */ + + ptcar = Line; while( *ptcar && (*ptcar != '"') ) + ptcar++; + + if( *ptcar != '"' ) + { + aMsgDiag.Printf( + wxT( "EESchema file sheet label F%d at line %d, aborted\n" ), + fieldNdx, *aLineNum ); + aMsgDiag << CONV_FROM_UTF8(Line); + return TRUE; + } + + for( ptcar++, ii = 0; ; ii++, ptcar++ ) + { + Name1[ii] = *ptcar; + if( *ptcar == 0 ) + { + aMsgDiag.Printf( + wxT( "EESchema file sheet field F at line %d, aborted\n" ), *aLineNum ); + aMsgDiag << CONV_FROM_UTF8(Line); + return TRUE; + } + if( *ptcar == '"' ) + { + Name1[ii] = 0; ptcar++; + break; + } + } + + if( ( fieldNdx == 0 ) || ( fieldNdx == 1 ) ) + { + if( sscanf( ptcar, "%d", &size ) != 1 ) + { + aMsgDiag.Printf( + wxT( + "EESchema file sheet Label Caract error line %d, aborted\n" ), *aLineNum ); + aMsgDiag << CONV_FROM_UTF8(Line); + DisplayError( frame, aMsgDiag ); + } + if( size == 0 ) + size = DEFAULT_SIZE_TEXT; + if( fieldNdx == 0 ) + { + SheetStruct->m_SheetName = CONV_FROM_UTF8( Name1 ); + SheetStruct->m_SheetNameSize = size; + } + else + { + SheetStruct->SetFileName( CONV_FROM_UTF8( Name1 ) ); + + //printf("in ReadSheetDescr : SheetStruct->m_FileName = %s \n", Name1); + SheetStruct->m_FileNameSize = size; + } + } + + if( fieldNdx > 1 ) + { + SheetLabelStruct = new Hierarchical_PIN_Sheet_Struct( SheetStruct, + wxPoint( 0, + 0 ), + CONV_FROM_UTF8( Name1 ) ); + + if( SheetStruct->m_Label == NULL ) + OldSheetLabel = SheetStruct->m_Label = SheetLabelStruct; + else + OldSheetLabel->SetNext( (EDA_BaseStruct*) SheetLabelStruct ); + OldSheetLabel = SheetLabelStruct; + + /* Lecture des coordonnees */ + if( sscanf( ptcar, "%s %s %d %d %d", Char1, Char2, + &SheetLabelStruct->m_Pos.x, &SheetLabelStruct->m_Pos.y, + &size ) != 5 ) + { + aMsgDiag.Printf( + wxT( + "EESchema file Sheet Label Caract error line %d, aborted\n" ), *aLineNum ); + aMsgDiag << CONV_FROM_UTF8(Line); + DisplayError( frame, aMsgDiag ); + continue; + } + + if( size == 0 ) + size = DEFAULT_SIZE_TEXT; + SheetLabelStruct->m_Size.x = SheetLabelStruct->m_Size.y = size; + + /* Mise a jour des cadrage et type */ + switch( Char1[0] ) + { + case 'I': + SheetLabelStruct->m_Shape = NET_INPUT; break; + + case 'O': + SheetLabelStruct->m_Shape = NET_OUTPUT; break; + + case 'B': + SheetLabelStruct->m_Shape = NET_BIDI; break; + + case 'T': + SheetLabelStruct->m_Shape = NET_TRISTATE; break; + + case 'U': + SheetLabelStruct->m_Shape = NET_UNSPECIFIED; break; + } + + if( Char2[0] == 'R' ) + SheetLabelStruct->m_Edge = 1; + } + } + + if( strnicmp( "$End", Line, 4 ) != 0 ) + { + aMsgDiag.Printf( + wxT( " **EESchema file end_sheet struct error at line %d, aborted\n" ), + *aLineNum ); + aMsgDiag << CONV_FROM_UTF8(Line); + Failed = TRUE; + } + if( !Failed ) + { + SheetStruct->SetNext( Window->EEDrawList ); + Window->EEDrawList = SheetStruct; + SheetStruct->SetParent( Window ); + } + return Failed; /* Fin lecture 1 composant */ +} + + +/******************************************************************/ +bool ReadSchemaDescr( wxWindow* frame, + char* Line, + FILE* f, + wxString& aMsgDiag, int* aLineNum, + BASE_SCREEN* Window ) +/******************************************************************/ + +/* Analyse de l'entete du schema ( dims feuille, cartouche..) + */ +{ + char Text[256], buf[1024]; + int ii; + Ki_PageDescr* wsheet = &g_Sheet_A4; + static Ki_PageDescr* SheetFormatList[] = { + &g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2, &g_Sheet_A1, &g_Sheet_A0, + &g_Sheet_A, &g_Sheet_B, &g_Sheet_C, &g_Sheet_D, &g_Sheet_E, + &g_Sheet_user, NULL + }; + wxSize PageSize; + + sscanf( Line, "%s %s %d %d", Text, Text, &PageSize.x, &PageSize.y ); + /* Recherche de la descr correspondante: */ + wxString pagename = CONV_FROM_UTF8( Text ); + for( ii = 0; SheetFormatList[ii] != NULL; ii++ ) + { + wsheet = SheetFormatList[ii]; + if( wsheet->m_Name.CmpNoCase( pagename ) == 0 ) + { /* Descr found ! */ + if( wsheet == &g_Sheet_user ) // Get the user page size and make it the default + { + g_Sheet_user.m_Size = PageSize; + } + break; + } + } + + if( SheetFormatList[ii] == NULL ) + { + /* Erreur ici: descr non trouvee */ + aMsgDiag.Printf( + wxT( "EESchema file Dims Caract error line %d, aborted\n" ), *aLineNum ); + aMsgDiag << CONV_FROM_UTF8(Line); + DisplayError( frame, aMsgDiag ); + } + + /* Ajuste ecran */ + Window->m_CurrentSheetDesc = wsheet; + + /* Recheche suite et fin de descr */ + for( ; ; ) + { + if( GetLine( f, Line, aLineNum, 1024 ) == NULL ) + return TRUE; + if( strnicmp( Line, "$End", 4 ) == 0 ) + break; + + if( strnicmp( Line, "Sheet", 2 ) == 0 ) + sscanf( Line + 5, " %d %d", + &Window->m_ScreenNumber, &Window->m_NumberOfScreen ); + + if( strnicmp( Line, "Title", 2 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Title = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( Line, "Date", 2 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Date = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( Line, "Rev", 2 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Revision = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( Line, "Comp", 4 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Company = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( Line, "Comment1", 8 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Commentaire1 = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( Line, "Comment2", 8 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Commentaire2 = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( Line, "Comment3", 8 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Commentaire3 = CONV_FROM_UTF8( buf ); + continue; + } + + if( strnicmp( Line, "Comment4", 8 ) == 0 ) + { + ReadDelimitedText( buf, Line, 256 ); + Window->m_Commentaire4 = CONV_FROM_UTF8( buf ); + continue; + } + } + + return false; +} + + +/*************************************************************/ +int ReadPartDescr( wxWindow* frame, char* Line, FILE* f, + wxString& aMsgDiag, int* aLineNum, + BASE_SCREEN* Window ) +/*************************************************************/ + +/* Fonction utilisee par LoadEEFile(). + * Lit les lignes relatives a la description d'un composant en schema + */ +{ + int ii; + char Name1[256], Name2[256], + Char1[256], Char2[256], Char3[256]; + SCH_COMPONENT* component; + int Failed = 0, newfmt = 0; + char* ptcar; + wxString fieldName; + + + component = new SCH_COMPONENT(); + + component->m_Convert = 1; + + if( Line[0] == '$' ) + { + newfmt = 1; + *aLineNum++; + if( fgets( Line, 256 - 1, f ) == 0 ) + return TRUE; + } + + /* Traitement de la 1ere ligne de description */ + if( sscanf( &Line[1], "%s %s", Name1, Name2 ) != 2 ) + { + aMsgDiag.Printf( + wxT( "EESchema Component descr error at line %d, aborted" ), + *aLineNum ); + aMsgDiag << wxT("\n") << CONV_FROM_UTF8(Line); + Failed = TRUE; + return Failed; + } + + if( strcmp( Name1, NULL_STRING ) != 0 ) + { + for( ii = 0; ii < (int) strlen( Name1 ); ii++ ) + if( Name1[ii] == '~' ) + Name1[ii] = ' '; + + component->m_ChipName = CONV_FROM_UTF8( Name1 ); + if( !newfmt ) + component->GetField( VALUE )->m_Text = CONV_FROM_UTF8( Name1 ); + } + else + { + component->m_ChipName.Empty(); + component->GetField( VALUE )->m_Text.Empty(); + component->GetField( VALUE )->m_Orient = TEXT_ORIENT_HORIZ; + component->GetField( VALUE )->m_Attributs = TEXT_NO_VISIBLE; + } + + if( strcmp( Name2, NULL_STRING ) != 0 ) + { + bool isDigit = false; + for( ii = 0; ii < (int) strlen( Name2 ); ii++ ) + { + if( Name2[ii] == '~' ) + Name2[ii] = ' '; + + // get RefBase from this, too. store in Name1. + if( Name2[ii] >= '0' && Name2[ii] <= '9' ) + { + isDigit = true; + Name1[ii] = 0; //null-terminate. + } + if( !isDigit ) + { + Name1[ii] = Name2[ii]; + } + } + + Name1[ii] = 0; //just in case + int jj; + for( jj = 0; jjm_PrefixString = wxT( "U" ); + } + else + { + component->m_PrefixString = CONV_FROM_UTF8( &Name1[jj] ); + + //printf("prefix: %s\n", CONV_TO_UTF8(component->m_PrefixString)); + } + if( !newfmt ) + component->GetField( REFERENCE )->m_Text = CONV_FROM_UTF8( Name2 ); + } + else + { + component->GetField( REFERENCE )->m_Attributs = TEXT_NO_VISIBLE; + } + + /* Traitement des autres lignes de description */ + + /* Ces lignes commencent par: + * "P " = position + * "U " = Num Unit, et Conversion + * "Fn" = Champs ( n = 0.. = numero de champ ) + * "Ar" = AlternateReference, in the case of multiple sheets + * referring to one schematic file. + */ + + /* Lecture des champs */ + for( ; ; ) + { + *aLineNum++; + if( fgets( Line, 256 - 1, f ) == NULL ) + return TRUE; + + if( Line[0] == 'U' ) /* Lecture num multi, conversion et time stamp */ + { + sscanf( Line + 1, "%d %d %lX", + &component->m_Multi, &component->m_Convert, + &component->m_TimeStamp ); + } + else if( Line[0] == 'P' ) + { + sscanf( Line + 1, "%d %d", + &component->m_Pos.x, &component->m_Pos.y ); + } + else if( Line[0] == 'A' && Line[1] == 'R' ) + { + /* format: + * AR Path="/9086AF6E/67452AA0" Ref="C99" Part="1" + * where 9086AF6E is the unique timestamp of the containing sheet + * and 67452AA0 is the timestamp of this component. + * C99 is the reference given this path. + */ + int ii; + ptcar = Line + 2; + + //copy the path. + ii = ReadDelimitedText( Name1, ptcar, 255 ); + ptcar += ii + 1; + wxString path = CONV_FROM_UTF8( Name1 ); + + // copy the reference + ii = ReadDelimitedText( Name1, ptcar, 255 ); + ptcar += ii + 1; + wxString ref = CONV_FROM_UTF8( Name1 ); + + // copy the multi, if exists + ii = ReadDelimitedText( Name1, ptcar, 255 ); + if( Name1[0] == 0 ) // Nothing read, put a default value + sprintf( Name1, "%d", component->m_Multi ); + int multi = atoi( Name1 ); + if( multi < 0 || multi > 25 ) + multi = 1; + component->AddHierarchicalReference( path, ref, multi ); + component->GetField( REFERENCE )->m_Text = ref; + } + else if( Line[0] == 'F' ) + { + int fieldNdx; + + char FieldUserName[1024]; + GRTextHorizJustifyType hjustify = GR_TEXT_HJUSTIFY_CENTER; + GRTextVertJustifyType vjustify = GR_TEXT_VJUSTIFY_CENTER; + + FieldUserName[0] = 0; + + /* Lecture du champ */ + ptcar = Line; + + while( *ptcar && (*ptcar != '"') ) + ptcar++; + + if( *ptcar != '"' ) + { + aMsgDiag.Printf( + wxT( "EESchema file lib field F at line %d, aborted" ), + *aLineNum ); + return TRUE; + } + + for( ptcar++, ii = 0; ; ii++, ptcar++ ) + { + Name1[ii] = *ptcar; + if( *ptcar == 0 ) + { + aMsgDiag.Printf( + wxT( "Component field F at line %d, aborted" ), + *aLineNum ); + return TRUE; + } + + if( *ptcar == '"' ) + { + Name1[ii] = 0; + ptcar++; + break; + } + } + + fieldNdx = atoi( Line + 2 ); + + ReadDelimitedText( FieldUserName, ptcar, sizeof(FieldUserName) ); + + if( !FieldUserName[0] ) + fieldName = ReturnDefaultFieldName( fieldNdx ); + else + fieldName = CONV_FROM_UTF8( FieldUserName ); + + if( fieldNdx >= component->GetFieldCount() ) + { + // add as many fields as needed so the m_FieldId's are contiguous, no gaps. + while( fieldNdx >= component->GetFieldCount() ) + { + int newNdx = component->GetFieldCount(); + + SCH_CMP_FIELD f( wxPoint( 0, 0 ), newNdx, component, fieldName ); + component->AddField( f ); + } + } + else + { + component->GetField( fieldNdx )->m_Name = fieldName; + } + + component->GetField( fieldNdx )->m_Text = CONV_FROM_UTF8( Name1 ); + + if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", Char1, + &component->GetField( fieldNdx )->m_Pos.x, + &component->GetField( fieldNdx )->m_Pos.y, + &component->GetField( fieldNdx )->m_Size.x, + &component->GetField( fieldNdx )->m_Attributs, + Char2, Char3 ) ) < 4 ) + { + aMsgDiag.Printf( + wxT( "Component Field error line %d, aborted" ), + *aLineNum ); + DisplayError( frame, aMsgDiag ); + continue; + } + + if( (component->GetField( fieldNdx )->m_Size.x == 0 ) || (ii == 4) ) + component->GetField( fieldNdx )->m_Size.x = DEFAULT_SIZE_TEXT; + + component->GetField( fieldNdx )->m_Orient = TEXT_ORIENT_HORIZ; + component->GetField( fieldNdx )->m_Size.y = component->GetField( fieldNdx )->m_Size.x; + + if( Char1[0] == 'V' ) + component->GetField( fieldNdx )->m_Orient = TEXT_ORIENT_VERT; + + if( ii >= 7 ) + { + if( *Char2 == 'L' ) + hjustify = GR_TEXT_HJUSTIFY_LEFT; + else if( *Char2 == 'R' ) + hjustify = GR_TEXT_HJUSTIFY_RIGHT; + if( *Char3 == 'B' ) + vjustify = GR_TEXT_VJUSTIFY_BOTTOM; + else if( *Char3 == 'T' ) + vjustify = GR_TEXT_VJUSTIFY_TOP; + + component->GetField( fieldNdx )->m_HJustify = hjustify; + component->GetField( fieldNdx )->m_VJustify = vjustify; + } + + if( fieldNdx == REFERENCE ) + if( component->GetField( fieldNdx )->m_Text[0] == '#' ) + component->GetField( fieldNdx )->m_Attributs |= TEXT_NO_VISIBLE; + } + else + break; + } + + /* Lecture multi et position du composant */ + if( sscanf( Line, "%d %d %d", + &component->m_Multi, + &component->m_Pos.x, &component->m_Pos.y ) != 3 ) + { + aMsgDiag.Printf( + wxT( "Component unit & pos error at line %d, aborted" ), + *aLineNum ); + Failed = TRUE; + return Failed; + } + + /* Lecture de la matrice de miroir / rotation */ + *aLineNum++; + if( (fgets( Line, 256 - 1, f ) == NULL) + || (sscanf( Line, "%d %d %d %d", + &component->m_Transform[0][0], + &component->m_Transform[0][1], + &component->m_Transform[1][0], + &component->m_Transform[1][1] ) != 4) ) + { + aMsgDiag.Printf( + wxT( "Component orient error at line %d, aborted" ), + *aLineNum ); + Failed = TRUE; + return Failed; + } + + if( newfmt ) + { + *aLineNum++; + if( fgets( Line, 256 - 1, f ) == NULL ) + return TRUE; + if( strnicmp( "$End", Line, 4 ) != 0 ) + { + aMsgDiag.Printf( + wxT( "Component End expected at line %d, aborted" ), + *aLineNum ); + Failed = TRUE; + } + } + + if( !Failed ) + { + component->SetNext( Window->EEDrawList ); + Window->EEDrawList = component; + component->SetParent( Window ); + } + + return Failed; /* Fin lecture 1 composant */ +} + diff --git a/include/base_struct.h b/include/base_struct.h index ea6f8e2fce..7b80ef957c 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -509,8 +509,9 @@ public: /** * Function Pitch * @return distance between 2 characters + * @param aMinTickness = min segments tickness */ - int Pitch(); + int Pitch(int aMinTickness = 0); /** Function Draw * @param aPanel = the current DrawPanel diff --git a/include/common.h b/include/common.h index 7cac361363..c15c9875a8 100644 --- a/include/common.h +++ b/include/common.h @@ -461,6 +461,8 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, wxDC* aDC, * @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) + * if width < 0 : draw segments in sketch mode, width = abs(width) * @param aItalic = true to simulate an italic font */ void PlotGraphicText( int aFormat_plot, const wxPoint& aPos, enum EDA_Colors aColor, @@ -468,7 +470,7 @@ void PlotGraphicText( int aFormat_plot, const wxPoint& aPos, enum EDA_Colors aCo int aOrient, const wxSize& aSize, enum GRTextHorizJustifyType aH_justify, enum GRTextVertJustifyType aV_justify, - bool aItalic = false ); + int aWidth, bool aItalic = false ); /***************/ /* CONFIRM.CPP */ diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 9e6d19697c..54a9a211b8 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -1,6 +1,7 @@ -/*******************************************************************/ -/* Functions relatives to tracks, vias and zones(see class_track.h */ -/*******************************************************************/ +/***********************************************************************/ +/* Functions relatives to tracks, vias and segments used to fill zones */ +/* (see class_track.h ) */ +/***********************************************************************/ #include "fctsys.h" #include "gr_basic.h" @@ -636,11 +637,13 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin m_Width + (g_DesignSettings.m_TrackClearence * 2), color ); } - /* Display the short netname: + /* Display the short netname for tracks, not for zone segments. * we must filter tracks, to avoid a lot of texts. * - only horizontal or vertical tracks are eligible * - only tracks with a length > 10 * thickness are eligible */ + if( Type() == TYPE_ZONE ) + return; #define THRESHOLD 10 if( (m_End.x - m_Start.x) != 0 && (m_End.y - m_Start.y) != 0 ) @@ -651,6 +654,9 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin if( len < THRESHOLD * m_Width ) return; + if( ( m_Width / zoom) < 6 ) // no room to display a text inside track + return; + if( GetNet() == 0 ) return; EQUIPOT* net = ( (BOARD*) GetParent() )->FindNet( GetNet() );