Commit acf03b7d authored by CHARRAS's avatar CHARRAS
Browse files

Global labels problems fixed (see changelog)

parent 9086e68d
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -5,6 +5,13 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.

2008-Feb-20 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+eeschema
    Fixed bug in getpart.cpp:
    eeschema crashed when aborting a new component place command
	Global Symbols now have their shapes
	Bad global label shape fixed when reading a schematic file


2008-Feb-20 UPDATE   Dick Hollenbeck <dick@softplc.com>
+38 −0
Original line number Diff line number Diff line
/* XPM */
static const char *lang_chinese_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 16 16 1",
". c #E42814",
"X c #DC1A1C",
"& c #FCFE04",
"; c #EC6A14",
"% c #FCF20C",
"# c #EC5E14",
"$ c #F4B20C",
"+ c #DB031C",
"@ c #F4A60C",
"o c #DC0D1C",
"O c #E43E14",
"* c #F49A0C",
"- c #E45214",
"  c #DC1519",
"= c #EC7A0C",
": c #E44614",
/* pixels */
"       ..   .  X",
"X oO+ o@#+      ",
" ++$ ++o+@o  . X",
"X.%&&*o o=      ",
" +.&&+  + +  . X",
"Xo-+O  oo&      ",
"   o  o#.++.   X",
"  X    ;:    .  ",
" .  .  oo      X",
"X       .  .    ",
"   .  .      . X",
"X               ",
"   .  . . . .  X",
"XX           X X",
"X  X  X  X  X  X",
"XXXXXXXXXXXXXXXX"
};
+2 −1
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@
#include "Lang_Ko.xpm"
#include "Lang_Ru.xpm"
#include "Lang_Catalan.xpm"
#include "Lang_chinese.xpm"
#endif


@@ -572,7 +573,7 @@ wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu )

        item = new wxMenuItem( m_Language_Menu, ID_LANGUAGE_CHINESE_SIMPLIFIED,
                               _( "Chinese simplified" ), wxEmptyString, wxITEM_CHECK );
        //SETBITMAPS( lang_chinese_simplified_xpm );
        SETBITMAPS( lang_chinese_xpm );
        m_Language_Menu->Append( item );
    }

+0 −65
Original line number Diff line number Diff line
@@ -16,71 +16,6 @@
#define NB_MAX_SHEET 500


/* Type des labels sur sheet (Labels sur hierarchie) et forme des Global-Labels*/
typedef enum {
    NET_INPUT,
    NET_OUTPUT,
    NET_BIDI,
    NET_TRISTATE,
    NET_UNSPECIFIED,
    NET_TMAX        /* Derniere valeur: fin de tableau */
} TypeSheetLabel;

/* Messages correspondants aux types ou forme des labels */
#ifdef MAIN
const char*        SheetLabelType[] =
{
    "Input",
    "Output",
    "BiDi",
    "3State",
    "UnSpc",
    "?????"
};
#else
extern const char* SheetLabelType[];
#endif

/* Description du graphisme des icones associes aux types des Global_Labels */
#ifdef MAIN
int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 };
int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 };
int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 };
int TemplateIN_UP[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 };
    
int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 };
int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 };
int TemplateOUT_BOTTOM[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 };
int TemplateOUT_UP[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 };
    
int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 };
int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 };
int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 };
int TemplateUNSPC_UP[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 };
    
int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
int TemplateBIDI_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
    
int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 };
int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 };
int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 };
int Template3STATE_UP[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
    
int* TemplateShape[5][4] =
{
    { TemplateIN_HN,     TemplateIN_UP,     TemplateIN_HI,     TemplateIN_BOTTOM     },
    { TemplateOUT_HN,    TemplateOUT_UP,    TemplateOUT_HI,    TemplateOUT_BOTTOM    },
    { TemplateBIDI_HN,   TemplateBIDI_UP,   TemplateBIDI_HI,   TemplateBIDI_BOTTOM   },
    { Template3STATE_HN, Template3STATE_UP, Template3STATE_HI, Template3STATE_BOTTOM },
    { TemplateUNSPC_HN,  TemplateUNSPC_UP,  TemplateUNSPC_HI,  TemplateUNSPC_BOTTOM  }
};
#else
extern int* TemplateShape[5][4];
#endif


/* Forward declarations */
class DrawSheetStruct;
extern DrawSheetStruct* g_RootSheet; 
+245 −132
Original line number Diff line number Diff line
@@ -6,9 +6,11 @@
#include "gr_basic.h"

#include "common.h"
#include "trigo.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"

#include "id.h"

#include "protos.h"
@@ -120,6 +122,7 @@ DrawLabelStruct::DrawLabelStruct( const wxPoint& pos, const wxString& text ) :
/****************************************************************************/
{
    m_Layer      = LAYER_LOCLABEL;
    m_Shape      = NET_INPUT;
    m_IsDangling = TRUE;
}

@@ -134,6 +137,7 @@ DrawGlobalLabelStruct::DrawGlobalLabelStruct(const wxPoint& pos, const wxString&
    m_IsDangling = TRUE;
}


/***********************************************************************************/
DrawHierLabelStruct::DrawHierLabelStruct( const wxPoint& pos, const wxString& text ) :
    DrawTextStruct( pos, text, DRAW_HIER_LABEL_STRUCT_TYPE )
@@ -144,6 +148,7 @@ DrawHierLabelStruct::DrawHierLabelStruct(const wxPoint& pos, const wxString& tex
    m_IsDangling = TRUE;
}


/*******************************************************************************************/
void DrawTextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
                           int DrawMode, int Color )
@@ -217,13 +222,14 @@ void DrawLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& of
void DrawHierLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
                                int DrawMode, int Color )
/******************************************************************************************/

/* Texts type Global Label  have 4 directions, and the Text origin is the graphic icon
 */
{
    int*   Template;
    int    Poly[20];
    int    ii, jj, imax, color, HalfSize;
    wxSize Size  = m_Size;
    int     Poly[40];
    int     ii, color;
    wxPoint AnchorPos = m_Pos + offset;;

    int     width = MAX( m_Width, g_DrawMinimunLineWidth );

    if( Color >= 0 )
@@ -233,68 +239,84 @@ void DrawHierLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint

    GRSetDrawMode( DC, DrawMode );

	HalfSize = Size.x / 2; ii = Size.x + TXTMARGE;
    ii = m_Size.x + TXTMARGE;

    switch( m_Orient )
    {
    case 0:             /* Orientation horiz normale */
        DrawGraphicText( panel, DC,
							wxPoint( m_Pos.x - ii + offset.x, m_Pos.y + offset.y ), color,
							m_Text, TEXT_ORIENT_HORIZ, Size,
                         wxPoint( AnchorPos.x - ii, AnchorPos.y ), color,
                         m_Text, TEXT_ORIENT_HORIZ, m_Size,
                         GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, width );
        break;

    case 1:             /* Orientation vert UP */
        DrawGraphicText( panel, DC,
								 wxPoint( m_Pos.x + offset.x, m_Pos.y + ii + offset.y ), color,
										  m_Text, TEXT_ORIENT_VERT, Size,
                         wxPoint( AnchorPos.x, AnchorPos.y + ii ), color,
                         m_Text, TEXT_ORIENT_VERT, m_Size,
                         GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, width );
        break;

    case 2:             /* Orientation horiz inverse */
        DrawGraphicText( panel, DC,
							wxPoint( m_Pos.x + ii + offset.x, m_Pos.y + offset.y ), color,
							m_Text, TEXT_ORIENT_HORIZ, Size,
                         wxPoint( AnchorPos.x + ii, AnchorPos.y ), color,
                         m_Text, TEXT_ORIENT_HORIZ, m_Size,
                         GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width );
        break;

    case 3:             /* Orientation vert BOTTOM */
        DrawGraphicText( panel, DC,
							wxPoint( m_Pos.x + offset.x, m_Pos.y - ii + offset.y ), color,
							m_Text, TEXT_ORIENT_VERT, Size,
                         wxPoint( AnchorPos.x, AnchorPos.y - ii ), color,
                         m_Text, TEXT_ORIENT_VERT, m_Size,
                         GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width );
        break;
    }

    Template = TemplateShape[m_Shape][m_Orient];
    CreateGraphicShape( Poly, AnchorPos );
    GRPoly( &panel->m_ClipBox, DC, Poly[0], Poly + 1, 0, width, color, color );

    imax = *Template; Template++;
    for( ii = 0, jj = 0; ii < imax; ii++ )
    {
        Poly[jj] = ( HalfSize * (*Template) ) + m_Pos.x + offset.x;
        jj++; Template++;
        Poly[jj] = ( HalfSize * (*Template) ) + m_Pos.y + offset.y;
        jj++; Template++;
    if( m_IsDangling )
        DrawDanglingSymbol( panel, DC, m_Pos + offset, color );
}

    GRPoly( &panel->m_ClipBox, DC, imax, Poly, 0, width, color, color );

    if( m_IsDangling )
        DrawDanglingSymbol( panel, DC, m_Pos + offset, color );
/** function CreateGraphicShape
 * Calculates the graphic shape (a polygon) associated to the text
 * @param corner_list = coordinates list fill with polygon corners ooordinates (size > 20)
 * @param Pos = Postion of the shape
 * format list is
 * corner_count, x0, y0, ... xn, yn
 */
void DrawHierLabelStruct::CreateGraphicShape( int* corner_list, const wxPoint& Pos )
{
    int* Template = TemplateShape[m_Shape][m_Orient];
    int  HalfSize = m_Size.x / 2;

    int  imax = *Template; Template++;

    *corner_list = imax; corner_list++;
    for( int ii = 0; ii < imax; ii++ )
    {
        *corner_list = ( HalfSize * (*Template) ) + Pos.x;
        corner_list++; Template++;
        *corner_list = ( HalfSize * (*Template) ) + Pos.y;
        corner_list++; Template++;
    }
}


/*******************************************************************************************/
void DrawGlobalLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
void DrawGlobalLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& draw_offset,
                                  int DrawMode, int Color )
/******************************************************************************************/

/* Texts type Global Label  have 4 directions, and the Text origin is the graphic icon
 */
	//should reimplement this with a custom global shape??
	//it is the same as Hierarchal sheet. 
{
	int*   Template;
    int     Poly[20];
	int    ii, jj, imax, color, HalfSize;
	wxSize Size  = m_Size;
    int     offset, color, HalfSize;
    wxPoint AnchorPos = m_Pos + draw_offset;;

    int     width = MAX( m_Width, g_DrawMinimunLineWidth );

    if( Color >= 0 )
@@ -304,52 +326,143 @@ void DrawGlobalLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoi

    GRSetDrawMode( DC, DrawMode );

	HalfSize = Size.x / 2; ii = Size.x + TXTMARGE;
    HalfSize = m_Size.x / 2;
    offset = width;

    switch( m_Shape )
    {
    case NET_INPUT:
    case NET_BIDI:
    case NET_TRISTATE:
        offset += HalfSize;
        break;

	case NET_OUTPUT:
		offset += TXTMARGE;
		break;

    default:
        break;
    }

    switch( m_Orient )
    {
    case 0:             /* Orientation horiz normale */
        DrawGraphicText( panel, DC,
							wxPoint( m_Pos.x - ii + offset.x, m_Pos.y + offset.y ), color,
							m_Text, TEXT_ORIENT_HORIZ, Size,
                         wxPoint( AnchorPos.x - offset, AnchorPos.y ), color,
                         m_Text, TEXT_ORIENT_HORIZ, m_Size,
                         GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, width );
        break;

    case 1:             /* Orientation vert UP */
        DrawGraphicText( panel, DC,
								 wxPoint( m_Pos.x + offset.x, m_Pos.y + ii + offset.y ), color,
										  m_Text, TEXT_ORIENT_VERT, Size,
                         wxPoint( AnchorPos.x, AnchorPos.y + offset ), color,
                         m_Text, TEXT_ORIENT_VERT, m_Size,
                         GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, width );
        break;

    case 2:             /* Orientation horiz inverse */
        DrawGraphicText( panel, DC,
							wxPoint( m_Pos.x + ii + offset.x, m_Pos.y + offset.y ), color,
							m_Text, TEXT_ORIENT_HORIZ, Size,
                         wxPoint( AnchorPos.x + offset, AnchorPos.y ), color,
                         m_Text, TEXT_ORIENT_HORIZ, m_Size,
                         GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width );
        break;

    case 3:             /* Orientation vert BOTTOM */
        DrawGraphicText( panel, DC,
							wxPoint( m_Pos.x + offset.x, m_Pos.y - ii + offset.y ), color,
							m_Text, TEXT_ORIENT_VERT, Size,
                         wxPoint( AnchorPos.x, AnchorPos.y - offset ), color,
                         m_Text, TEXT_ORIENT_VERT, m_Size,
                         GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width );
        break;
    }

	Template = TemplateShape[m_Shape][m_Orient];
    CreateGraphicShape( Poly, AnchorPos );
    GRPoly( &panel->m_ClipBox, DC, Poly[0], Poly + 1, 0, width, color, color );

    if( m_IsDangling )
        DrawDanglingSymbol( panel, DC, AnchorPos, color );
}


/** function CreateGraphicShape
 * Calculates the graphic shape (a polygon) associated to the text
 * @param corner_list = oordinates list fill with polygon corners ooordinates (size >= 14)
 * @param Pos = Postion of the shape
 * format list is
 * <corner_count>, x0, y0, ... xn, yn
 */
void DrawGlobalLabelStruct::CreateGraphicShape( int* corner_list, const wxPoint& Pos )
{
    int HalfSize = m_Size.x / 2;
    int     width = MAX( m_Width, g_DrawMinimunLineWidth );

    *corner_list = 7; corner_list++;	// 7 corners in list

    int symb_len = Len_Size() + (TXTMARGE * 2);   // Real text len + text margin
    // Create outline shape : 6 points
    int x = symb_len + width + 3;
    int y = HalfSize + width + 3;
    corner_list[0]  = 0; corner_list[1] = 0;        // Starting point (anchor)
    corner_list[2]  = 0; corner_list[3] = -y;       // Up
    corner_list[4]  = -x; corner_list[5] = -y;      // left Up
    corner_list[6]  = -x; corner_list[7] = 0;       // left
    corner_list[8]  = -x; corner_list[9] = y;       // left down
    corner_list[10] = 0; corner_list[11] = y;       // down

    int x_offset = 0;

    switch( m_Shape )
    {
    case NET_INPUT:
        x_offset = -HalfSize;
        corner_list[0] += HalfSize;
        break;

    case NET_OUTPUT:
        corner_list[6] -= HalfSize;
        break;

    case NET_BIDI:
    case NET_TRISTATE:
        x_offset = -HalfSize;
        corner_list[0] += HalfSize;
        corner_list[6] -= HalfSize;
        break;

    case NET_UNSPECIFIED:
    default:
        break;
    }

    int angle = 0;

	imax = *Template; Template++;
	for( ii = 0, jj = 0; ii < imax; ii++ )
    switch( m_Orient )
    {
		Poly[jj] = ( HalfSize * (*Template) ) + m_Pos.x + offset.x;
		jj++; Template++;
		Poly[jj] = ( HalfSize * (*Template) ) + m_Pos.y + offset.y;
		jj++; Template++;
    case 0:             /* Orientation horiz normale */
        break;

    case 1:             /* Orientation vert UP */
        angle = 900;
        break;

    case 2:             /* Orientation horiz inverse */
        angle = 1800;
        break;

    case 3:             /* Orientation vert BOTTOM */
        angle = -900;
        break;
    }

	GRPoly( &panel->m_ClipBox, DC, imax, Poly, 0, width, color, color );
    // Rotate outlines and move in real position
    for( int ii = 0; ii < 12; ii += 2 )
    {
        corner_list[ii] += x_offset;
        if( angle )
            RotatePoint( &corner_list[ii], &corner_list[ii + 1], angle );
        corner_list[ii]     += Pos.x;
        corner_list[ii + 1] += Pos.y;
    }

	if( m_IsDangling )
		DrawDanglingSymbol( panel, DC, m_Pos + offset, color );
    corner_list[12] = corner_list[0]; corner_list[13] = corner_list[1]; // closing
}
Loading