Commit f43d1aaa authored by charras's avatar charras
Browse files

Added text justification for graphic texts in libedit and more(see changelog)

parent a56c02e9
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -4,6 +4,15 @@ KiCad ChangeLog 2009
Please add newer entries at the top, list the date and your name with
email address.


2009-june-11 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++Eeschema:
    Added text justification for graphic texts in libedit
    Minor bug 2803506 fixed (error when mirroring bus entries)
    Some code cleaning.
    Better locating algo for arcs in libedit

2009-may-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++Eeschema:
+10 −9
Original line number Diff line number Diff line
@@ -250,8 +250,8 @@ EDA_Rect EDA_TextStruct::GetTextBox( int aLine )
    rect.SetSize( textsize );

    /* Now, calculate the rect origin, according to text justification
     * At this point the area origin is the text origin (m_Pos).
     * This is true only for left and top text justified texts.
     * At this point the rectangle origin is the text origin (m_Pos).
     * This is true only for left and top text justified texts (using top to bottom Y axis orientation).
     * and must be recalculated for others justifications
     * also, note the V justification is relative to the first line
     */
@@ -290,13 +290,14 @@ EDA_Rect EDA_TextStruct::GetTextBox( int aLine )


/*************************************************/
bool EDA_TextStruct::HitTest( const wxPoint& posref )
bool EDA_TextStruct::TextHitTest( const wxPoint& posref )
/*************************************************/

/* locate function
 *  return:
 *      true  if posref is inside the text area.
 *      false else.
/**
 * Function TextHitTest (overlayed)
 * tests if the given point is inside this object.
 * @param posref point to test
 * @return bool - true if a hit, else false
 */
{
    EDA_Rect rect = GetTextBox( -1 );   // Get the full text area.
@@ -310,13 +311,13 @@ bool EDA_TextStruct::HitTest( const wxPoint& posref )


/**
 * Function HitTest (overlayed)
 * Function TextHitTest (overlayed)
 * tests if the given EDA_Rect intersect this object.
 * @param refArea the given EDA_Rect to test
 * @return bool - true if a hit, else false
 */
/*********************************************************/
bool EDA_TextStruct::HitTest( EDA_Rect& refArea )
bool EDA_TextStruct::TextHitTest( EDA_Rect& refArea )
/*********************************************************/
{
    if( refArea.Inside( m_Pos ) )
+2 −1
Original line number Diff line number Diff line
@@ -620,7 +620,7 @@ bool MoveStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
static void MirrorYPoint( wxPoint& point, wxPoint& Center )
{
    point.x -= Center.x;
    point.x  = -point.x;
    NEGATE(point.x);
    point.x += Center.x;
}

@@ -683,6 +683,7 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )
    case DRAW_BUSENTRY_STRUCT_TYPE:
        DrawRaccord = (DrawBusEntryStruct*) DrawStruct;
        MirrorYPoint( DrawRaccord->m_Pos, Center );
        NEGATE(DrawRaccord->m_Size.x);
        break;

    case DRAW_JUNCTION_STRUCT_TYPE:
+15 −35
Original line number Diff line number Diff line
@@ -254,44 +254,24 @@ void LibDrawField::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
 */
bool LibDrawField::HitTest( const wxPoint& refPos )
{
    EDA_Rect bbox;             // bounding box for the text
    int      dx;               // X size for the full text

    bbox.SetOrigin( m_Pos );

    dx = m_Size.x * m_Text.Len();

    // Reference designator text has one additional character (displays U?)
    if( m_FieldId == REFERENCE )
        dx += m_Size.x;

    // spacing between characters is 0.1 the character size
    dx = (int) ( (double) dx * 10.0 / 9 );
    int dy = m_Size.y;

    if( m_Orient )
        EXCHG( dx, dy );            // Swap X and Y size for a vertical text

    // adjust position of the left bottom corner according to the justification
    // pos is at this point correct for a left and top justified text
    // Horizontal justification
    if( m_HJustify == GR_TEXT_HJUSTIFY_CENTER )
        bbox.Offset( -dx / 2, 0 );
    else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT )
        bbox.Offset( -dx, 0 );

    // Vertical justification
    if( m_VJustify == GR_TEXT_VJUSTIFY_CENTER )
        bbox.Offset( 0, -dy / 2 );
    else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
        bbox.Offset( 0, -dy );
        m_Text.Append('?');
    // if using TextHitTest() remember this function uses top to bottom y axis convention
    // and for lib items we are using bottom to top convention
    // so for non center Y justification we use a trick.
    GRTextVertJustifyType vJustify = m_VJustify;
    if ( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
        m_VJustify = GR_TEXT_VJUSTIFY_BOTTOM;
    else if  ( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
        m_VJustify = GR_TEXT_VJUSTIFY_TOP;

    bbox.SetSize( dx, dy );
    bool hit = TextHitTest(refPos);
    m_VJustify = vJustify;

    if( bbox.Inside( refPos ) )
        return true;

    return false;
    if( m_FieldId == REFERENCE )
        m_Text.RemoveLast( );
    return hit;
}


+11 −2
Original line number Diff line number Diff line
@@ -59,7 +59,16 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
    SCH_COMPONENT* DrawLibItem = (SCH_COMPONENT*) m_Parent;
    GRTextHorizJustifyType hjustify;
    GRTextVertJustifyType vjustify;
    int            LineWidth = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
    int            LineWidth = m_Width;
    
    if (LineWidth == 0)   // Use default values for pen size
    {
        if ( m_Bold  )
            LineWidth = GetPenSizeForBold( m_Size.x );
        else
            LineWidth = g_DrawDefaultLineThickness;
    }


    // Clip pen size for small texts:
    LineWidth = Clamp_Text_PenSize( LineWidth, m_Size, m_Bold );
@@ -153,7 +162,7 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
    {
        DrawGraphicText( panel, DC, pos, color, m_Text,
                         orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
                         m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold, false );
                         m_Size, hjustify, vjustify, LineWidth, m_Italic, m_Bold );
    }
    else
    {
Loading