Пример #1
0
void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
                     EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode,
                     EDA_DRAW_MODE_T aFillMode, EDA_COLOR_T aAnchor_color )
{
    if( m_MultilineAllowed )
    {
        std::vector<wxPoint> positions;
        wxArrayString  strings;
        wxStringSplit( GetShownText(), strings, '\n' );
        positions.reserve( strings.Count() );

        GetPositionsOfLinesOfMultilineText(positions, strings.Count() );

        for( unsigned ii = 0; ii < strings.Count(); ii++ )
        {
            wxString& txt = strings.Item( ii );
            drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
                               aDrawMode, aFillMode, txt, positions[ii] );
        }
    }
    else
        drawOneLineOfText( aClipBox, aDC, aOffset, aColor,
                           aDrawMode, aFillMode, GetShownText(), m_Pos );

    // Draw text anchor, if requested
    if( aAnchor_color != UNSPECIFIED_COLOR )
    {
        GRDrawAnchor( aClipBox, aDC,
                      m_Pos.x + aOffset.x, m_Pos.y + aOffset.y,
                      DIM_ANCRE_TEXTE, aAnchor_color );
    }
}
Пример #2
0
void MODULE::DrawAncre( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
                        int dim_ancre, GR_DRAWMODE draw_mode )
{
    GRSetDrawMode( DC, draw_mode );

    if( GetBoard()->IsElementVisible( ANCHOR_VISIBLE ) )
    {
        GRDrawAnchor( panel->GetClipBox(), DC, m_Pos.x, m_Pos.y,
                      dim_ancre,
                      g_ColorsSettings.GetItemColor( ANCHOR_VISIBLE ) );
    }
}
/**
 * Function Draw
 * Draw the text according to the footprint pos and orient
 * @param panel = draw panel, Used to know the clip box
 * @param DC = Current Device Context
 * @param offset = draw offset (usually wxPoint(0,0)
 * @param draw_mode = GR_OR, GR_XOR..
 */
void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
                         const wxPoint& offset )
{
    MODULE* module = (MODULE*) m_Parent;

    /* parent must *not* be NULL (a module text without a footprint
       parent has no sense) */
    wxASSERT( module );

    if( panel == NULL )
        return;

    BOARD* brd = GetBoard( );
    EDA_COLOR_T color;
    // Determine the element color or suppress it element if hidden
    switch( module->GetLayer() )
    {
    case LAYER_N_BACK:
        if( !brd->IsElementVisible( MOD_TEXT_BK_VISIBLE ) )
            return;
        color = brd->GetVisibleElementColor( MOD_TEXT_BK_VISIBLE );
        break;

    case LAYER_N_FRONT:
        if( !brd->IsElementVisible( MOD_TEXT_FR_VISIBLE ) )
            return;
        color = brd->GetVisibleElementColor( MOD_TEXT_FR_VISIBLE );
        break;

    default:
        color = brd->GetLayerColor( module->GetLayer() );
    }

    // 'Ghost' the element if forced show
    if( m_NoShow )
    {
        if( !brd->IsElementVisible( MOD_TEXT_INVISIBLE ) )
            return;
        color = brd->GetVisibleElementColor( MOD_TEXT_INVISIBLE );
    }

    // Draw mode compensation for the width
    PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
    int width = m_Thickness;
    if( ( frame->m_DisplayModText == LINE )
        || ( DC->LogicalToDeviceXRel( width ) <= MIN_DRAW_WIDTH ) )
        width = 0;
    else if( frame->m_DisplayModText == SKETCH )
        width = -width;

    GRSetDrawMode( DC, draw_mode );
    wxPoint pos( m_Pos.x - offset.x,
                 m_Pos.y - offset.y);

    // Draw the text anchor point
    if( brd->IsElementVisible( ANCHOR_VISIBLE ) )
    {
        EDA_COLOR_T anchor_color = brd->GetVisibleElementColor(ANCHOR_VISIBLE);
        GRDrawAnchor( panel->GetClipBox(), DC, pos.x, pos.y,
                      DIM_ANCRE_TEXTE, anchor_color );
    }

    // Draw the text proper, with the right attributes
    wxSize size   = m_Size;
    double orient = GetDrawRotation();

    // If the text is mirrored : negate size.x (mirror / Y axis)
    if( m_Mirror )
        size.x = -size.x;

    EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
    DrawGraphicText( clipbox, DC, pos, color, m_Text, orient,
                     size, m_HJustify, m_VJustify, width, m_Italic, m_Bold );

    // Enable these line to draw the bounding box (debug tests purposes only)
#if 0
    {
        EDA_RECT BoundaryBox = GetBoundingBox();
        GRRect( clipbox, DC, BoundaryBox, 0, BROWN );
    }
#endif
}
void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
                         const wxPoint& aOffset )
{
    if( aPanel == NULL )
        return;

    /* parent must *not* be NULL (a footprint text without a footprint
       parent has no sense) */
    wxASSERT( m_Parent );

    BOARD* brd = GetBoard( );

    auto frame = static_cast<PCB_BASE_FRAME*> ( aPanel->GetParent() );
    auto color = frame->Settings().Colors().GetLayerColor( GetLayer() );

    PCB_LAYER_ID text_layer = GetLayer();

    if( !brd->IsLayerVisible( m_Layer )
      || ( IsFrontLayer( text_layer ) && !brd->IsElementVisible( LAYER_MOD_TEXT_FR ) )
      || ( IsBackLayer( text_layer ) && !brd->IsElementVisible( LAYER_MOD_TEXT_BK ) ) )
        return;

    if( !brd->IsElementVisible( LAYER_MOD_REFERENCES ) && GetText() == wxT( "%R" ) )
        return;

    if( !brd->IsElementVisible( LAYER_MOD_VALUES ) && GetText() == wxT( "%V" ) )
        return;

    // Invisible texts are still drawn (not plotted) in LAYER_MOD_TEXT_INVISIBLE
    // Just because we must have to edit them (at least to make them visible)
    if( !IsVisible() )
    {
        if( !brd->IsElementVisible( LAYER_MOD_TEXT_INVISIBLE ) )
            return;

        color = frame->Settings().Colors().GetItemColor( LAYER_MOD_TEXT_INVISIBLE );
    }

    auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aPanel->GetDisplayOptions() );

    // shade text if high contrast mode is active
    if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay )
    {
        PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) aPanel->GetScreen() )->m_Active_Layer;

        if( !IsOnLayer( curr_layer ) )
            color = COLOR4D( DARKDARKGRAY );
    }

    // Draw mode compensation for the width
    int width = GetThickness();

    if( displ_opts && displ_opts->m_DisplayModTextFill == SKETCH )
        width = -width;

    GRSetDrawMode( aDC, aDrawMode );
    wxPoint pos = GetTextPos() - aOffset;

    // Draw the text anchor point
    if( brd->IsElementVisible( LAYER_ANCHOR ) )
    {
        COLOR4D anchor_color = frame->Settings().Colors().GetItemColor( LAYER_ANCHOR );
        GRDrawAnchor( aPanel->GetClipBox(), aDC, pos.x, pos.y, DIM_ANCRE_TEXTE, anchor_color );
    }

    // Draw the text proper, with the right attributes
    wxSize size   = GetTextSize();
    double orient = GetDrawRotation();

    // If the text is mirrored : negate size.x (mirror / Y axis)
    if( IsMirrored() )
        size.x = -size.x;

    DrawGraphicText( aPanel->GetClipBox(), aDC, pos, color, GetShownText(), orient,
                     size, GetHorizJustify(), GetVertJustify(),
                     width, IsItalic(), IsBold() );

    // Enable these line to draw the bounding box (debug test purpose only)
#if 0
    {
        EDA_RECT BoundaryBox = GetBoundingBox();
        GRRect( aPanel->GetClipBox(), aDC, BoundaryBox, 0, BROWN );
    }
#endif
}
Пример #5
0
void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
                         const wxPoint& aOffset )
{
    if( aPanel == NULL )
        return;

    /* parent must *not* be NULL (a footprint text without a footprint
       parent has no sense) */
    wxASSERT( m_Parent );

    BOARD* brd = GetBoard( );
    EDA_COLOR_T color = brd->GetLayerColor( GetLayer() );
    LAYER_ID text_layer = GetLayer();

    if( !brd->IsLayerVisible( m_Layer )
      || (IsFrontLayer( text_layer ) && !brd->IsElementVisible( MOD_TEXT_FR_VISIBLE ))
      || (IsBackLayer( text_layer ) && !brd->IsElementVisible( MOD_TEXT_BK_VISIBLE )) )
        return;

    // Invisible texts are still drawn (not plotted) in MOD_TEXT_INVISIBLE
    // Just because we must have to edit them (at least to make them visible)
    if( m_NoShow )
    {
        if( !brd->IsElementVisible( MOD_TEXT_INVISIBLE ) )
            return;

        color = brd->GetVisibleElementColor( MOD_TEXT_INVISIBLE );
    }

    DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)aPanel->GetDisplayOptions();

    // shade text if high contrast mode is active
    if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay )
    {
        LAYER_ID curr_layer = ( (PCB_SCREEN*) aPanel->GetScreen() )->m_Active_Layer;

        if( !IsOnLayer( curr_layer ) )
            ColorTurnToDarkDarkGray( &color );
    }

    // Draw mode compensation for the width
    int width = m_Thickness;

    if( displ_opts && displ_opts->m_DisplayModTextFill == SKETCH )
        width = -width;

    GRSetDrawMode( aDC, aDrawMode );
    wxPoint pos = m_Pos - aOffset;

    // Draw the text anchor point
    if( brd->IsElementVisible( ANCHOR_VISIBLE ) )
    {
        EDA_COLOR_T anchor_color = brd->GetVisibleElementColor(ANCHOR_VISIBLE);
        GRDrawAnchor( aPanel->GetClipBox(), aDC, pos.x, pos.y, DIM_ANCRE_TEXTE, anchor_color );
    }

    // Draw the text proper, with the right attributes
    wxSize size   = m_Size;
    double orient = GetDrawRotation();

    // If the text is mirrored : negate size.x (mirror / Y axis)
    if( m_Mirror )
        size.x = -size.x;

    DrawGraphicText( aPanel->GetClipBox(), aDC, pos, color, GetShownText(), orient,
                     size, m_HJustify, m_VJustify, width, m_Italic, m_Bold );

    // Enable these line to draw the bounding box (debug test purpose only)
#if 0
    {
        EDA_RECT BoundaryBox = GetBoundingBox();
        GRRect( aPanel->GetClipBox(), aDC, BoundaryBox, 0, BROWN );
    }
#endif
}