void EDA_DRAW_PANEL::DrawBackGround( wxDC* DC )
{
    GRSetDrawMode( DC, GR_COPY );

    if( GetParent()->IsGridVisible() )
        DrawGrid( DC );

    // Draw axis
    if( GetParent()->GetShowAxis() )
    {
        COLOR4D axis_color = COLOR4D( BLUE );
        wxSize  pageSize = GetParent()->GetPageSizeIU();

        // Draw the Y axis
        GRLine( &m_ClipBox, DC, 0, -pageSize.y, 0, pageSize.y, 0, axis_color );

        // Draw the X axis
        GRLine( &m_ClipBox, DC, -pageSize.x, 0, pageSize.x, 0, 0, axis_color );
    }

    if( GetParent()->GetShowOriginAxis() )
        DrawAuxiliaryAxis( DC, GR_COPY );

    if( GetParent()->GetShowGridAxis() )
        DrawGridAxis( DC, GR_COPY, GetParent()->GetGridOrigin() );
}
예제 #2
0
void BASE_SCREEN::Trace_Curseur(WinEDA_DrawPanel * panel, wxDC * DC)
/*******************************************************************/
/*
 Trace Le curseur sur la zone PCB , se deplacant sur la grille
*/
{
int color = WHITE;
	
	GRSetDrawMode(DC, GR_XOR);
	if( g_CursorShape == 1 )	/* Trace d'un reticule */
		{
		int dx = panel->m_ClipBox.GetWidth() * GetZoom();
		int dy = panel->m_ClipBox.GetHeight() * GetZoom();
		GRLine(&panel->m_ClipBox, DC, m_Curseur.x - dx, m_Curseur.y,
							m_Curseur.x + dx, m_Curseur.y, color); // axe Y
		GRLine(&panel->m_ClipBox, DC, m_Curseur.x, m_Curseur.y - dx,
				m_Curseur.x, m_Curseur.y + dy, color);  // axe X
		}

	else
		{
		int len = CURSOR_SIZE * GetZoom();
		GRLine(&panel->m_ClipBox, DC, m_Curseur.x - len, m_Curseur.y,
				m_Curseur.x + len, m_Curseur.y, color);
		GRLine(&panel->m_ClipBox, DC, m_Curseur.x, m_Curseur.y - len,
				m_Curseur.x, m_Curseur.y + len, color);
		}
}
void EDA_DRAW_PANEL::DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aGridOrigin )
{
    if( !GetParent()->GetShowGridAxis() || ( !aGridOrigin.x && !aGridOrigin.y ) )
        return;

    COLOR4D color = GetParent()->GetGridColor();

    GRSetDrawMode( aDC, aDrawMode );

#if DRAW_AXIS_AS_LINES
    wxSize      pageSize = GetParent()->GetPageSizeIU();
    // Draw the Y axis
    GRLine( &m_ClipBox, aDC, aGridOrigin.x, -pageSize.y,
            aGridOrigin.x, pageSize.y, 0, color );

    // Draw the X axis
    GRLine( &m_ClipBox, aDC, -pageSize.x, aGridOrigin.y,
            pageSize.x, aGridOrigin.y, 0, color );
#else
    int radius = aDC->DeviceToLogicalXRel( AXIS_SIZE_IN_PIXELS );
    int linewidth = aDC->DeviceToLogicalXRel( 1 );

    GRSetColorPen( aDC, GetParent()->GetGridColor(), linewidth );

    GRLine( &m_ClipBox, aDC, aGridOrigin.x-radius, aGridOrigin.y-radius,
            aGridOrigin.x+radius, aGridOrigin.y+radius, 0, color );

    // Draw the X shape
    GRLine( &m_ClipBox, aDC, aGridOrigin.x+radius, aGridOrigin.y-radius,
            aGridOrigin.x-radius, aGridOrigin.y+radius, 0, color );

    GRCircle( &m_ClipBox, aDC, aGridOrigin, radius, linewidth, color );
#endif
}
예제 #4
0
void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, EDA_COLOR_T aColor )
{
    if( m_cursorLevel != 0 || aDC == NULL || !m_showCrossHair )
        return;

    wxPoint cursor = GetParent()->GetCrossHairPosition();

    GRSetDrawMode( aDC, GR_XOR );

    if( GetParent()->m_cursorShape != 0 )    // Draws full screen crosshair.
    {
        wxSize  clientSize = GetClientSize();

        // Y axis
        wxPoint lineStart( cursor.x, aDC->DeviceToLogicalY( 0 ) );
        wxPoint lineEnd(   cursor.x, aDC->DeviceToLogicalY( clientSize.y ) );

        GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor );

        // X axis
        lineStart = wxPoint( aDC->DeviceToLogicalX( 0 ), cursor.y );
        lineEnd   = wxPoint( aDC->DeviceToLogicalX( clientSize.x ), cursor.y );

        GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor );
    }
    else
    {
        int len = aDC->DeviceToLogicalXRel( CURSOR_SIZE );

        GRLine( &m_ClipBox, aDC, cursor.x - len, cursor.y,
                cursor.x + len, cursor.y, 0, aColor );
        GRLine( &m_ClipBox, aDC, cursor.x, cursor.y - len,
                cursor.x, cursor.y + len, 0, aColor );
    }
}
예제 #5
0
/* Draw PCB_TARGET object: 2 segments + 1 circle
 * The circle radius is half the radius of the target
 * 2 lines have length the diameter of the target
 */
void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color,
                       const wxPoint& offset )
{
    int radius, ox, oy, width;
    int dx1, dx2, dy1, dy2;

    ox = m_Pos.x + offset.x;
    oy = m_Pos.y + offset.y;

    BOARD * brd =  GetBoard( );

    if( brd->IsLayerVisible( m_Layer ) == false )
        return;

    auto frame = static_cast<PCB_EDIT_FRAME*> ( panel->GetParent() );
    auto gcolor = frame->Settings().Colors().GetLayerColor( m_Layer );

    GRSetDrawMode( DC, mode_color );
    auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() );
    bool filled = displ_opts ? displ_opts->m_DisplayDrawItemsFill : FILLED;
    width   = m_Width;

    radius = m_Size / 3;

    if( GetShape() )   // shape X
        radius = m_Size / 2;

    if( filled )
        GRCircle( panel->GetClipBox(), DC, ox, oy, radius, width, gcolor );
    else
    {
        GRCircle( panel->GetClipBox(), DC, ox, oy, radius + (width / 2), gcolor );
        GRCircle( panel->GetClipBox(), DC, ox, oy, radius - (width / 2), gcolor );
    }


    radius = m_Size / 2;
    dx1   = radius;
    dy1   = 0;
    dx2   = 0;
    dy2   = radius;

    if( GetShape() )   // shape X
    {
        dx1 = dy1 = radius;
        dx2 = dx1;
        dy2 = -dy1;
    }

    if( filled )
    {
        GRLine( panel->GetClipBox(), DC, ox - dx1, oy - dy1, ox + dx1, oy + dy1, width, gcolor );
        GRLine( panel->GetClipBox(), DC, ox - dx2, oy - dy2, ox + dx2, oy + dy2, width, gcolor );
    }
    else
    {
        GRCSegm( panel->GetClipBox(), DC, ox - dx1, oy - dy1, ox + dx1, oy + dy1, width, gcolor );
        GRCSegm( panel->GetClipBox(), DC, ox - dx2, oy - dy2, ox + dx2, oy + dy2, width, gcolor );
    }
}
예제 #6
0
void WinEDA_BasePcbFrame::trace_ratsnest_pad(wxDC * DC)
/*******************************************************/
/*
 affiche le "chevelu" d'un pad lors des trace de segments de piste
*/
{
int * pt_coord;
int ii;
int refX, refY;

	if((m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0) return;
	if( nb_local_chevelu == 0 ) return;
	if ( local_liste_chevelu == NULL ) return;

	pt_coord = (int*) local_liste_chevelu;
	refX = *pt_coord; pt_coord++;
	refY = *pt_coord; pt_coord++;

	GRSetDrawMode(DC, GR_XOR);
	for( ii = 0; ii < nb_local_chevelu; ii++)
		{
		if ( ii >= g_MaxLinksShowed ) break;
		GRLine(&DrawPanel->m_ClipBox, DC, refX, refY, *pt_coord, *(pt_coord+1), YELLOW);
		pt_coord += 2;
		}
}
예제 #7
0
void SCH_BUS_ENTRY_BASE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
                          GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
    COLOR4D color;
    EDA_RECT* clipbox = aPanel->GetClipBox();

    if( aColor != COLOR4D::UNSPECIFIED )
        color = aColor;
    else
        color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );

    GRSetDrawMode( aDC, aDrawMode );

    GRLine( clipbox, aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y,
            m_End().x + aOffset.x, m_End().y + aOffset.y, GetPenSize(), color );


    // Draw pin targets if part is being dragged
    bool dragging = aPanel->GetScreen()->GetCurItem() == this && aPanel->IsMouseCaptured();

    if( m_isDanglingStart || dragging )
    {
        GRCircle( clipbox, aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y,
                TARGET_BUSENTRY_RADIUS, 0, color );
    }

    if( m_isDanglingEnd || dragging )
    {
        GRCircle( clipbox, aDC, m_End().x + aOffset.x, m_End().y + aOffset.y,
                TARGET_BUSENTRY_RADIUS, 0, color );
    }
}
예제 #8
0
void SEGZONE::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
                    const wxPoint& aOffset )
{
    DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();

    if( displ_opts->m_DisplayZonesMode != 0 )
        return;

    BOARD * brd = GetBoard( );
    EDA_COLOR_T color = brd->GetLayerColor(m_Layer);

    if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
        return;

#ifdef USE_WX_OVERLAY
    // If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
    if( (m_Flags & IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC)))
      return;
#endif

    if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts->m_ContrastModeDisplay )
    {
        LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;

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

    if( aDrawMode & GR_HIGHLIGHT )
        ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );

    ColorApplyHighlightFlag( &color );

    SetAlpha( &color, 150 );

    GRSetDrawMode( aDC, aDrawMode );

    int l_trace = m_Width / 2;

    if( aDC->LogicalToDeviceXRel( l_trace ) <= MIN_DRAW_WIDTH )
    {
        GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, 0, color );
        return;
    }

    if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
    {
        GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
    }
    else
    {
        GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
                     m_Start.y + aOffset.y,
                     m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
    }

    // No clearance or netnames for zones
}
void SEGZONE::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
                    const wxPoint& aOffset )
{
    auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() );

    if( displ_opts->m_DisplayZonesMode != 0 )
        return;

    BOARD* brd = GetBoard();

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

    if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
        return;

#ifdef USE_WX_OVERLAY
    // If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
    if( (m_Flags & IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC)))
      return;
#endif

    if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts->m_ContrastModeDisplay )
    {
        PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;

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

    if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
        color.SetToLegacyHighlightColor();

    color.a = 0.588;

    GRSetDrawMode( aDC, aDrawMode );

    // Draw track as line if width <= 1pixel:
    if( aDC->LogicalToDeviceXRel( m_Width ) <= 1 )
    {
        GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
        return;
    }

    if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
    {
        GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
    }
    else
    {
        GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
                     m_Start.y + aOffset.y,
                     m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
    }

    // No clearance or netnames for zones
}
void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, COLOR4D aColor )
{
    if( m_cursorLevel != 0 || aDC == NULL || !m_showCrossHair )
        return;

    wxPoint cursor = GetParent()->GetCrossHairPosition();

#ifdef USE_WX_GRAPHICS_CONTEXT
    // Normally cursor color is set to white, so when it is xored with white
    // background, it is painted black effectively. wxGraphicsContext does not have
    // xor operation, so we need to invert the color manually.
    aColor.Invert();
#else
    GRSetDrawMode( aDC, GR_XOR );
#endif

    if( GetParent()->GetGalDisplayOptions().m_fullscreenCursor )
    {
        wxSize  clientSize = GetClientSize();

        // Y axis
        wxPoint lineStart( cursor.x, aDC->DeviceToLogicalY( 0 ) );
        wxPoint lineEnd(   cursor.x, aDC->DeviceToLogicalY( clientSize.y ) );

        GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor );

        // X axis
        lineStart = wxPoint( aDC->DeviceToLogicalX( 0 ), cursor.y );
        lineEnd   = wxPoint( aDC->DeviceToLogicalX( clientSize.x ), cursor.y );

        GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor );
    }
    else
    {
        int len = aDC->DeviceToLogicalXRel( CURSOR_SIZE );

        GRLine( &m_ClipBox, aDC, cursor.x - len, cursor.y,
                cursor.x + len, cursor.y, 0, aColor );
        GRLine( &m_ClipBox, aDC, cursor.x, cursor.y - len,
                cursor.x, cursor.y + len, 0, aColor );
    }
}
예제 #11
0
void DrawBlockStruct::Draw(WinEDA_DrawPanel * panel, wxDC * DC)
/**************************************************************/
{
    int w = GetWidth()/panel->GetZoom();
    int h = GetHeight()/panel->GetZoom();
    if (  w == 0 || h == 0 )
        GRLine(&panel->m_ClipBox, DC, GetX(), GetY(),
               GetRight(), GetBottom(), m_Color);
    else
        GRRect(&panel->m_ClipBox, DC,  GetX(), GetY(),
               GetRight(), GetBottom(), m_Color);
}
예제 #12
0
void WinEDA_BasePcbFrame::trace_ratsnest_module(wxDC * DC)
/**********************************************************/
/*
 affiche le chevelu d'un module calcule en mode rapide.
	retourne: rien
*/
{
CHEVELU* local_chevelu;
int ii;

	if((m_Pcb->m_Status_Pcb & CHEVELU_LOCAL_OK) == 0) return ;

	local_chevelu = local_liste_chevelu;
	ii = nb_local_chevelu;

	GRSetDrawMode(DC, GR_XOR);

	while( ii-- > 0 )
		{
		if(local_chevelu->status & LOCAL_CHEVELU)
			{
			GRLine(&DrawPanel->m_ClipBox, DC,
				local_chevelu->pad_start->m_Pos.x - g_Offset_Module.x,
				local_chevelu->pad_start->m_Pos.y - g_Offset_Module.y,
				local_chevelu->pad_end->m_Pos.x - g_Offset_Module.x,
				local_chevelu->pad_end->m_Pos.y - g_Offset_Module.y,
				YELLOW);
			}
		else
			{
			GRLine(&DrawPanel->m_ClipBox, DC,
				local_chevelu->pad_start->m_Pos.x - g_Offset_Module.x,
				local_chevelu->pad_start->m_Pos.y - g_Offset_Module.y,
				local_chevelu->pad_end->m_Pos.x,
				local_chevelu->pad_end->m_Pos.y,
				g_DesignSettings.m_RatsnestColor);
			}
		local_chevelu++;
		}
}
예제 #13
0
void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
                           int aDrawMode, int aColor )
{
    int pX, pY, color;
    int delta = m_size.x / 2;
    int width = g_DrawDefaultLineThickness;

    pX = m_pos.x + aOffset.x;
    pY = m_pos.y + aOffset.y;

    if( aColor >= 0 )
        color = aColor;
    else
        color = ReturnLayerColor( LAYER_NOCONNECT );

    GRSetDrawMode( aDC, aDrawMode );

    GRLine( aPanel->GetClipBox(), aDC, pX - delta, pY - delta, pX + delta, pY + delta,
            width, color );
    GRLine( aPanel->GetClipBox(), aDC, pX + delta, pY - delta, pX - delta, pY + delta,
            width, color );
}
/**
 * Function Draw
 * Draws a line (a ratsnest) from the starting pad to the ending pad
 */
void RATSNEST_ITEM::Draw( EDA_DRAW_PANEL* panel,
                          wxDC*           DC,
                          GR_DRAWMODE     aDrawMode,
                          const wxPoint&  aOffset )
{
    GRSetDrawMode( DC, aDrawMode );

    EDA_COLOR_T color = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE);

    GRLine( panel->GetClipBox(), DC,
            m_PadStart->GetPosition() - aOffset,
            m_PadEnd->GetPosition() - aOffset, 0, color );
}
예제 #15
0
void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color,
                      const wxPoint& offset )
{
    EDA_COLOR_T gcolor;
    BOARD*      brd = GetBoard();

    if( brd->IsLayerVisible( m_Layer ) == false )
        return;

    m_Text.Draw( panel, DC, mode_color, offset );

    gcolor = brd->GetLayerColor( m_Layer );

    GRSetDrawMode( DC, mode_color );
    DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();
    bool filled = displ_opts ? displ_opts->m_DisplayDrawItemsFill : FILLED;
    int width   = m_Width;

    if( filled )
    {
        GRLine( panel->GetClipBox(), DC, m_crossBarO + offset,
                m_crossBarF + offset, width, gcolor );
        GRLine( panel->GetClipBox(), DC, m_featureLineGO + offset,
                m_featureLineGF + offset, width, gcolor );
        GRLine( panel->GetClipBox(), DC, m_featureLineDO + offset,
                m_featureLineDF + offset, width, gcolor );
        GRLine( panel->GetClipBox(), DC, m_crossBarF + offset,
                m_arrowD1F + offset, width, gcolor );
        GRLine( panel->GetClipBox(), DC, m_crossBarF + offset,
                m_arrowD2F + offset, width, gcolor );
        GRLine( panel->GetClipBox(), DC, m_crossBarO + offset,
                m_arrowG1F + offset, width, gcolor );
        GRLine( panel->GetClipBox(), DC, m_crossBarO + offset,
                m_arrowG2F + offset, width, gcolor );
    }
    else
    {
        GRCSegm( panel->GetClipBox(), DC, m_crossBarO + offset,
                 m_crossBarF + offset, width, gcolor );
        GRCSegm( panel->GetClipBox(), DC, m_featureLineGO + offset,
                 m_featureLineGF + offset, width, gcolor );
        GRCSegm( panel->GetClipBox(), DC, m_featureLineDO + offset,
                 m_featureLineDF + offset, width, gcolor );
        GRCSegm( panel->GetClipBox(), DC, m_crossBarF + offset,
                 m_arrowD1F + offset, width, gcolor );
        GRCSegm( panel->GetClipBox(), DC, m_crossBarF + offset,
                 m_arrowD2F + offset, width, gcolor );
        GRCSegm( panel->GetClipBox(), DC, m_crossBarO + offset,
                 m_arrowG1F + offset, width, gcolor );
        GRCSegm( panel->GetClipBox(), DC, m_crossBarO + offset,
                 m_arrowG2F + offset, width, gcolor );
    }
}
예제 #16
0
void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
                           GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
    int pX, pY;
    int delta = m_size.x / 2;
    int width = GetDefaultLineThickness();

    pX = m_pos.x + aOffset.x;
    pY = m_pos.y + aOffset.y;

    COLOR4D color;

    if( aColor != COLOR4D::UNSPECIFIED )
        color = aColor;
    else
        color = GetLayerColor( LAYER_NOCONNECT );

    GRSetDrawMode( aDC, aDrawMode );

    GRLine( aPanel->GetClipBox(), aDC, pX - delta, pY - delta, pX + delta, pY + delta,
            width, color );
    GRLine( aPanel->GetClipBox(), aDC, pX + delta, pY - delta, pX - delta, pY + delta,
            width, color );
}
예제 #17
0
/* Draws a line from the TEXTE_MODULE origin to parent MODULE origin.
*/
void TEXTE_MODULE::DrawUmbilical( EDA_DRAW_PANEL* aPanel,
                                  wxDC*           aDC,
                                  GR_DRAWMODE     aDrawMode,
                                  const wxPoint&  aOffset )
{
    MODULE* parent = (MODULE*) GetParent();

    if( !parent )
        return;

    GRSetDrawMode( aDC, GR_XOR );
    GRLine( aPanel->GetClipBox(), aDC,
            parent->GetPosition(), GetTextPosition() + aOffset,
            0, UMBILICAL_COLOR);
}
void EDA_DRAW_PANEL::DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode )
{
    wxPoint origin = GetParent()->GetAuxOrigin();

    if( origin == wxPoint( 0, 0 ) )
        return;

    COLOR4D color = COLOR4D( RED );

    GRSetDrawMode( aDC, aDrawMode );

#if DRAW_AXIS_AS_LINES
    wxSize  pageSize = GetParent()->GetPageSizeIU();
    // Draw the Y axis
    GRLine( &m_ClipBox, aDC, origin.x, -pageSize.y,
            origin.x, pageSize.y, 0, color );

    // Draw the X axis
    GRLine( &m_ClipBox, aDC, -pageSize.x, origin.y,
            pageSize.x, origin.y, 0, color );
#else
    int radius = aDC->DeviceToLogicalXRel( AXIS_SIZE_IN_PIXELS );
    int linewidth = aDC->DeviceToLogicalXRel( 1 );

    GRSetColorPen( aDC, color, linewidth );

    GRLine( &m_ClipBox, aDC, origin.x, origin.y-radius,
            origin.x, origin.y+radius, 0, color );

    // Draw the + shape
    GRLine( &m_ClipBox, aDC, origin.x-radius, origin.y,
            origin.x+radius, origin.y, 0, color );

    GRCircle( &m_ClipBox, aDC, origin, radius, linewidth, color );
#endif
}
예제 #19
0
void SCH_BUS_ENTRY::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
                          GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
{
    EDA_COLOR_T color;

    if( aColor >= 0 )
        color = aColor;
    else
        color = ReturnLayerColor( m_Layer );

    GRSetDrawMode( aDC, aDrawMode );

    GRLine( aPanel->GetClipBox(), aDC, m_pos.x + aOffset.x, m_pos.y + aOffset.y,
            m_End().x + aOffset.x, m_End().y + aOffset.y, GetPenSize(), color );
}
예제 #20
0
void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
                           GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
{

    int w = GetWidth();
    int h = GetHeight();

    GRSetDrawMode( aDC, aDrawMode );

    if(  w == 0 || h == 0 )
        GRLine( aPanel->GetClipBox(), aDC, GetX() + aOffset.x, GetY() + aOffset.y,
                GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor );
    else
        GRRect( aPanel->GetClipBox(), aDC, GetX() + aOffset.x, GetY() + aOffset.y,
                GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor );
}
예제 #21
0
void LIB_ARC::drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, int aColor )
{
    // The edit indicators only get drawn when a new arc is being drawn.
    if( !IsNew() )
        return;

    // Use the last edit state so when the drawing switches from the end mode to the center
    // point mode, the last line between the center points gets erased.
    if( m_lastEditState == 1 )
    {
        GRLine( aClipBox, aDC, m_ArcStart.x, -m_ArcStart.y, m_ArcEnd.x, -m_ArcEnd.y, 0, aColor );
    }
    else
    {
        GRDashedLine( aClipBox, aDC, m_ArcStart.x, -m_ArcStart.y, m_Pos.x, -m_Pos.y, 0, aColor );
        GRDashedLine( aClipBox, aDC, m_ArcEnd.x, -m_ArcEnd.y, m_Pos.x, -m_Pos.y, 0, aColor );
    }
}
예제 #22
0
파일: ratsnest.cpp 프로젝트: jerkey/kicad
void PCB_BASE_FRAME::TraceAirWiresToTargets( wxDC* aDC )
{
    if( aDC == NULL )
        return;

    if( s_TargetsLocations.size() == 0 )
        return;

    GRSetDrawMode( aDC, GR_XOR );

    for( int ii = 0; ii < (int) s_TargetsLocations.size(); ii++ )
    {
        if( ii >= g_MaxLinksShowed )
            break;

        GRLine( m_canvas->GetClipBox(), aDC, s_CursorPos, s_TargetsLocations[ii], 0, YELLOW );
    }
}
예제 #23
0
void WinEDA_BasePcbFrame::DrawGeneralRatsnest(wxDC * DC, int net_code)
{
int ii;
CHEVELU * Chevelu;

	if( (m_Pcb->m_Status_Pcb & LISTE_CHEVELU_OK) == 0 ) return;

	Chevelu = m_Pcb->m_Ratsnest;
	if( Chevelu == NULL ) return;

	GRSetDrawMode(DC, GR_XOR);
	for( ii = m_Pcb->GetNumRatsnests() ;ii > 0; Chevelu++, ii--)
		{
		if( (Chevelu->status & (CH_VISIBLE|CH_ACTIF)) != (CH_VISIBLE|CH_ACTIF) )
			continue;
		if( (net_code <= 0) || (net_code == Chevelu->m_NetCode) )
			{
			GRLine(&DrawPanel->m_ClipBox, DC,
						Chevelu->pad_start->m_Pos.x, Chevelu->pad_start->m_Pos.y,
						Chevelu->pad_end->m_Pos.x, Chevelu->pad_end->m_Pos.y,
						g_DesignSettings.m_RatsnestColor);
			}
		}
}
void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
{
    wxPaintDC    dc( m_panelShowPad );
    PAD_DRAWINFO drawInfo;

    EDA_COLOR_T color = BLACK;

    if( m_dummyPad->GetLayerSet()[F_Cu] )
    {
        color = m_board->GetVisibleElementColor( PAD_FR_VISIBLE );
    }

    if( m_dummyPad->GetLayerSet()[B_Cu] )
    {
        color = ColorMix( color, m_board->GetVisibleElementColor( PAD_BK_VISIBLE ) );
    }

    // What could happen: the pad color is *actually* black, or no
    // copper was selected
    if( color == BLACK )
        color = LIGHTGRAY;

    drawInfo.m_Color     = color;
    drawInfo.m_HoleColor = DARKGRAY;
    drawInfo.m_Offset    = m_dummyPad->GetPosition();
    drawInfo.m_Display_padnum  = true;
    drawInfo.m_Display_netname = true;

    if( m_dummyPad->GetAttribute() == PAD_HOLE_NOT_PLATED )
        drawInfo.m_ShowNotPlatedHole = true;

    // Shows the local pad clearance
    drawInfo.m_PadClearance = m_dummyPad->GetLocalClearance();

    wxSize dc_size = dc.GetSize();
    dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );

    // Calculate a suitable scale to fit the available draw area
    int dim = m_dummyPad->GetSize().x + std::abs( m_dummyPad->GetDelta().y);

    if( m_dummyPad->GetLocalClearance() > 0 )
        dim += m_dummyPad->GetLocalClearance() * 2;

    double scale = (double) dc_size.x / dim;

    dim = m_dummyPad->GetSize().y + std::abs( m_dummyPad->GetDelta().x);
    if( m_dummyPad->GetLocalClearance() > 0 )
        dim += m_dummyPad->GetLocalClearance() * 2;

    double altscale = (double) dc_size.y / dim;
    scale = std::min( scale, altscale );

    // Give a margin
    scale *= 0.7;
    dc.SetUserScale( scale, scale );

    GRResetPenAndBrush( &dc );
    m_dummyPad->DrawShape( NULL, &dc, drawInfo );

    // Draw X and Y axis.
    // this is particularly useful to show the reference position of pads
    // with offset and no hole
    GRLine( NULL, &dc, -dim, 0, dim, 0, 0, BLUE );   // X axis
    GRLine( NULL, &dc, 0, -dim, 0, dim, 0, BLUE );   // Y axis

    event.Skip();
}
예제 #25
0
void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
                      const wxPoint& offset, GR_DRAWMODE DrawMode, EDA_COLOR_T Color )
{
    int            orient;
    EDA_COLOR_T    color;
    wxPoint        textpos;
    SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent;
    int            LineWidth = m_Thickness;

    if( LineWidth == 0 )   // Use default values for pen size
    {
        if( m_Bold  )
            LineWidth = GetPenSizeForBold( m_Size.x );
        else
            LineWidth = GetDefaultLineThickness();
    }


    // Clip pen size for small texts:
    LineWidth = Clamp_Text_PenSize( LineWidth, m_Size, m_Bold );

    if( ((m_Attributs & TEXT_NO_VISIBLE) && !m_forceVisible) || IsVoid() )
        return;

    GRSetDrawMode( DC, DrawMode );

    // Calculate the text orientation according to the component orientation.
    orient = m_Orient;

    if( parentComponent->GetTransform().y1 )  // Rotate component 90 degrees.
    {
        if( orient == TEXT_ORIENT_HORIZ )
            orient = TEXT_ORIENT_VERT;
        else
            orient = TEXT_ORIENT_HORIZ;
    }

    /* Calculate the text justification, according to the component
     * orientation/mirror this is a bit complicated due to cumulative
     * calculations:
     * - numerous cases (mirrored or not, rotation)
     * - the DrawGraphicText function recalculate also H and H justifications
     *      according to the text orientation.
     * - When a component is mirrored, the text is not mirrored and
     *   justifications are complicated to calculate
     * so the more easily way is to use no justifications ( Centered text )
     * and use GetBoundaryBox to know the text coordinate considered as centered
     */
    EDA_RECT boundaryBox = GetBoundingBox();
    textpos = boundaryBox.Centre();

    if( m_forceVisible )
    {
        color = DARKGRAY;
    }
    else
    {
        if( m_id == REFERENCE )
            color = ReturnLayerColor( LAYER_REFERENCEPART );
        else if( m_id == VALUE )
            color = ReturnLayerColor( LAYER_VALUEPART );
        else
            color = ReturnLayerColor( LAYER_FIELDS );
    }

    DrawGraphicText( panel, DC, textpos, color, GetText(), orient, m_Size,
                     GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
                     LineWidth, m_Italic, m_Bold );

    /* Enable this to draw the bounding box around the text field to validate
     * the bounding box calculations.
     */
#if 0

    // Draw boundary box:
    GRRect( panel->GetClipBox(), DC, boundaryBox, 0, BROWN );

    // Draw the text anchor point

    /* Calculate the text position, according to the component
     * orientation/mirror */
    textpos  = m_Pos - parentComponent->GetPosition();
    textpos  = parentComponent->GetScreenCoord( textpos );
    textpos += parentComponent->GetPosition();
    const int len = 10;
    GRLine( panel->GetClipBox(), DC,
            textpos.x - len, textpos.y, textpos.x + len, textpos.y, 0, BLUE );
    GRLine( panel->GetClipBox(), DC,
            textpos.x, textpos.y - len, textpos.x, textpos.y + len, 0, BLUE );
#endif
}
예제 #26
0
static void SymbolDisplayDraw(WinEDA_DrawPanel * panel, wxDC * DC, bool erase)
{
int DrawMode = g_XorMode;
int * ptpoly;
int dx, dy;
BASE_SCREEN * Screen = panel->m_Parent->m_CurrentScreen;
int mx = Screen->m_Curseur.x,
	my = Screen->m_Curseur.y;

	GRSetDrawMode(DC, DrawMode);

	if( erase )
		{ 
		if( StateDrawArc == 1 )
			{
			int Color = ReturnLayerColor(LAYER_DEVICE);
			GRLine(&panel->m_ClipBox, DC, ArcStartX, - ArcStartY, ArcEndX, - ArcEndY, Color);
			}
		else
			{
			DrawLibraryDrawStruct(panel, DC, CurrentLibEntry, 0 , 0,
						CurrentDrawItem, CurrentUnit, DrawMode);
			if(CurrentDrawItem->m_StructType == COMPONENT_ARC_DRAW_TYPE)
				{
				int Color = ReturnLayerColor(LAYER_DEVICE);
				GRDashedLine(&panel->m_ClipBox, DC, ArcStartX, - ArcStartY,
						((LibDrawArc*)CurrentDrawItem)->m_Pos.x,
						- ((LibDrawArc*)CurrentDrawItem)->m_Pos.y,
						Color);
				GRDashedLine(&panel->m_ClipBox, DC, ArcEndX, - ArcEndY,
						((LibDrawArc*)CurrentDrawItem)->m_Pos.x,
						- ((LibDrawArc*)CurrentDrawItem)->m_Pos.y,
						Color);
				}
			}
		}

	switch ( CurrentDrawItem->m_StructType )
		{
		case COMPONENT_ARC_DRAW_TYPE:
			if( StateDrawArc == 1)
				{
				ArcEndX = mx; ArcEndY = - my;
				}

			if( StateDrawArc == 2)
				{
				ComputeArc((LibDrawArc*)CurrentDrawItem, Screen->m_Curseur);
				}
			((LibDrawArc*)CurrentDrawItem)->m_Fill = FlSymbol_Fill;
			break;

		case COMPONENT_CIRCLE_DRAW_TYPE:
			dx = ((LibDrawCircle*)CurrentDrawItem)->m_Pos.x - mx;
			dy = ((LibDrawCircle*)CurrentDrawItem)->m_Pos.y + my;
			((LibDrawCircle*)CurrentDrawItem)->m_Rayon = (int)sqrt( (dx*dx) + (dy*dy) );
			((LibDrawCircle*)CurrentDrawItem)->m_Fill = FlSymbol_Fill;
			break;

		case COMPONENT_RECT_DRAW_TYPE:
			((LibDrawSquare*)CurrentDrawItem)->m_End.x = mx;
			((LibDrawSquare*)CurrentDrawItem)->m_End.y = - my;
			((LibDrawSquare*)CurrentDrawItem)->m_Fill = FlSymbol_Fill;
			break;

		case COMPONENT_POLYLINE_DRAW_TYPE:
			ptpoly = ((LibDrawPolyline*)CurrentDrawItem)->PolyList;
			ptpoly += 2 * (((LibDrawPolyline*)CurrentDrawItem)->n - 1);
			ptpoly[0] = mx;
			ptpoly[1] = - my;
			((LibDrawPolyline*)CurrentDrawItem)->m_Fill = FlSymbol_Fill;
			break;

		case COMPONENT_LINE_DRAW_TYPE:
			((LibDrawSegment*)CurrentDrawItem)->m_End.x = mx;
			((LibDrawSegment*)CurrentDrawItem)->m_End.y = - my;
			break;

		case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:	/* Traite par des routines specifiques */
			break;
		}

	if( StateDrawArc == 1 )
		{
		int Color = ReturnLayerColor(LAYER_DEVICE);
		GRLine(&panel->m_ClipBox, DC, ArcStartX, - ArcStartY, ArcEndX, - ArcEndY, Color);
		}
	else
		{
		DrawLibraryDrawStruct(panel, DC, CurrentLibEntry, 0 , 0,
						CurrentDrawItem, CurrentUnit, DrawMode);
		if(CurrentDrawItem->m_StructType == COMPONENT_ARC_DRAW_TYPE)
			{
			int Color = ReturnLayerColor(LAYER_DEVICE);
			GRDashedLine(&panel->m_ClipBox, DC, ArcStartX, - ArcStartY,
					((LibDrawArc*)CurrentDrawItem)->m_Pos.x,
					- ((LibDrawArc*)CurrentDrawItem)->m_Pos.y,
					Color);
			GRDashedLine(&panel->m_ClipBox, DC, ArcEndX, - ArcEndY,
					((LibDrawArc*)CurrentDrawItem)->m_Pos.x,
					- ((LibDrawArc*)CurrentDrawItem)->m_Pos.y,
					Color);
			}
		}
}
예제 #27
0
void EDGE_MODULE::Draw(WinEDA_DrawPanel * panel, wxDC * DC,
						const wxPoint & offset, int draw_mode)
/********************************************************************************/

/* Affichage d'un segment contour de module :
	Entree : ox, oy = offset de trace
	draw_mode = mode de trace ( GR_OR, GR_XOR, GR_AND)
		Les contours sont de differents type:
		- Segment
		- Cercles
		- Arcs
*/
{
int ux0, uy0, dx, dy,rayon, StAngle, EndAngle;
int color , type_trace;
int zoom;
int typeaff;
PCB_SCREEN * screen;
WinEDA_BasePcbFrame * frame;
MODULE * Module = NULL;

	if ( m_Parent && (m_Parent->m_StructType == TYPEMODULE) )
		Module = (MODULE*) m_Parent;

	GRSetDrawMode(DC, draw_mode);
	color = g_DesignSettings.m_LayerColor[m_Layer];

	if ( panel ) screen = (PCB_SCREEN *) panel->m_Parent->m_CurrentScreen;
	else screen = ActiveScreen;

	frame = screen->GetParentPcbFrame();

	zoom = screen->GetZoom();

	type_trace = m_Shape;
	ux0 = m_Start.x - offset.x; uy0 = m_Start.y - offset.y;
	dx = m_End.x - offset.x ;
	dy = m_End.y - offset.y ;

	typeaff = frame->m_DisplayModEdge;
	if( m_Layer <= CMP_N )
		typeaff = frame->m_DisplayPcbTrackFill;
	if( (m_Width /zoom) < L_MIN_DESSIN ) typeaff = FILAIRE;

	switch (type_trace )
	{
		case S_SEGMENT:
			if( typeaff == FILAIRE)
				GRLine(&panel->m_ClipBox, DC,  ux0, uy0, dx, dy, color);
			else Affiche_1_Segment(panel, DC, ux0,uy0,dx,dy,m_Width,
									typeaff,color);
			break ;

		case S_CIRCLE:
			rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) );
			if( typeaff == FILAIRE)
			{
				GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon, color) ;
			}
			else
			{
				if(typeaff == FILLED )
				{
					GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon, m_Width, color);
				}
				else
				{
					GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon + (m_Width/2), color) ;
					GRCircle(&panel->m_ClipBox, DC, ux0, uy0, rayon - (m_Width/2), color) ;
				}
			}
			break;

		case S_ARC:
			rayon = (int)hypot((double)(dx-ux0),(double)(dy-uy0) );
			StAngle = (int)ArcTangente( dy-uy0, dx-ux0 );
			EndAngle = StAngle + m_Angle;
			if ( StAngle > EndAngle) EXCHG (StAngle, EndAngle);
			if( typeaff == FILAIRE)
			{
				GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, color) ;
			}
			else if(typeaff == FILLED )
				{
					GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon,
								m_Width, color);
				}
			else
			{
				GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
						rayon + (m_Width/2), color) ;
				GRArc(&panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
						rayon - (m_Width/2), color) ;
			}
			break;

		case S_POLYGON:
		{
			// We must compute true coordinates from m_PolyList
			// which are relative to module position, orientation 0
			int ii, * source, * ptr, * ptr_base;
			ptr = ptr_base = (int*) MyMalloc( 2 * m_PolyCount * sizeof(int) );
			source = m_PolyList;
			for (ii = 0; ii < m_PolyCount; ii++ )
			{
				int x, y;
				x = *source; source++; y = *source; source++;
				if ( Module )
				{
					RotatePoint (&x, &y, Module->m_Orient);
					x += Module->m_Pos.x;
					y += Module->m_Pos.y;
				}
				x +=  m_Start0.x - offset.x;
				y +=  m_Start0.y - offset.y;
				*ptr = x; ptr++; *ptr = y; ptr++;
			}
			GRPoly(&panel->m_ClipBox, DC, m_PolyCount, ptr_base,
				TRUE, color, color);
			free ( ptr_base);
			break;
		}
	}
}
void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
{
    wxPaintDC    dc( m_panelShowPad );
    PAD_DRAWINFO drawInfo;

    EDA_COLOR_T color = BLACK;

    if( m_dummyPad->GetLayerSet()[F_Cu] )
    {
        color = m_board->GetVisibleElementColor( PAD_FR_VISIBLE );
    }

    if( m_dummyPad->GetLayerSet()[B_Cu] )
    {
        color = ColorMix( color, m_board->GetVisibleElementColor( PAD_BK_VISIBLE ) );
    }

    // What could happen: the pad color is *actually* black, or no
    // copper was selected
    if( color == BLACK )
        color = LIGHTGRAY;

    drawInfo.m_Color     = color;
    drawInfo.m_HoleColor = DARKGRAY;
    drawInfo.m_Offset    = m_dummyPad->GetPosition();
    drawInfo.m_Display_padnum  = true;
    drawInfo.m_Display_netname = true;

    if( m_dummyPad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
        drawInfo.m_ShowNotPlatedHole = true;

    // Shows the local pad clearance
    drawInfo.m_PadClearance = m_dummyPad->GetLocalClearance();

    wxSize dc_size = dc.GetSize();
    dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );

    // Calculate a suitable scale to fit the available draw area
    int dim = m_dummyPad->GetBoundingRadius() *2;

    // Invalid x size. User could enter zero, or have deleted all text prior to
    // entering a new value; this is also treated as zero. If dim is left at
    // zero, the drawing scale is zero and we get a crash.
    if( dim == 0 )
    {
        // If drill size has been set, use that. Otherwise default to 1mm.
        dim = m_dummyPad->GetDrillSize().x;
        if( dim == 0 )
            dim = Millimeter2iu( 1.0 );
    }

    if( m_dummyPad->GetLocalClearance() > 0 )
        dim += m_dummyPad->GetLocalClearance() * 2;

    double scale = (double) dc_size.x / dim;

    // If the pad is a circle, use the x size here instead.
    int ysize;
    if( m_dummyPad->GetShape() == PAD_SHAPE_CIRCLE )
        ysize = m_dummyPad->GetSize().x;
    else
        ysize = m_dummyPad->GetSize().y;

    dim = ysize + std::abs( m_dummyPad->GetDelta().x );

    // Invalid y size. See note about x size above.
    if( dim == 0 )
    {
        dim = m_dummyPad->GetDrillSize().y;
        if( dim == 0 )
            dim = Millimeter2iu( 0.1 );
    }

    if( m_dummyPad->GetLocalClearance() > 0 )
        dim += m_dummyPad->GetLocalClearance() * 2;

    double altscale = (double) dc_size.y / dim;
    scale = std::min( scale, altscale );

    // Give a margin
    scale *= 0.7;
    dc.SetUserScale( scale, scale );

    GRResetPenAndBrush( &dc );
    m_dummyPad->DrawShape( NULL, &dc, drawInfo );

    // Draw X and Y axis. Hhis is particularly useful to show the
    // reference position of pads with offset and no hole, or custom pad shapes
    const int linethickness = 0;
    GRLine( NULL, &dc, -int( dc_size.x/scale ), 0, int( dc_size.x/scale ), 0,
            linethickness, LIGHTBLUE );   // X axis
    GRLine( NULL, &dc, 0, -int( dc_size.y/scale ), 0, int( dc_size.y/scale ),
            linethickness, LIGHTBLUE );   // Y axis

    event.Skip();
}
예제 #29
0
void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC,
                                             GR_DRAWMODE draw_mode )
{
    GR_DRAWMODE current_gr_mode  = draw_mode;
    bool    is_close_segment = false;
    wxPoint seg_start, seg_end;

    if( DC == NULL )
        return;

    LAYER_NUM curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
    BOARD* brd   = GetBoard();
    EDA_COLOR_T color = brd->GetLayerColor( m_Layer );

    if( DisplayOpt.ContrastModeDisplay )
    {
        if( !IsOnLayer( curr_layer ) )
            ColorTurnToDarkDarkGray( &color );
    }

    // draw the lines
    wxPoint start_contour_pos = GetCornerPosition( 0 );
    int     icmax = GetNumCorners() - 1;

    for( int ic = 0; ic <= icmax; ic++ )
    {
        int xi = GetCornerPosition( ic ).x;
        int yi = GetCornerPosition( ic ).y;
        int xf, yf;

        if( !m_Poly->m_CornersList.IsEndContour( ic ) && ic < icmax )
        {
            is_close_segment = false;
            xf = GetCornerPosition( ic + 1 ).x;
            yf = GetCornerPosition( ic + 1 ).y;

            if( m_Poly->m_CornersList.IsEndContour( ic + 1 ) || (ic == icmax - 1) )
                current_gr_mode = GR_XOR;
            else
                current_gr_mode = draw_mode;
        }
        else    // Draw the line from last corner to the first corner of the current contour
        {
            is_close_segment = true;
            current_gr_mode  = GR_XOR;
            xf = start_contour_pos.x;
            yf = start_contour_pos.y;

            // Prepare the next contour for drawing, if exists
            if( ic < icmax )
                start_contour_pos = GetCornerPosition( ic + 1 );
        }

        GRSetDrawMode( DC, current_gr_mode );

        if( is_close_segment )
            GRLine( panel->GetClipBox(), DC, xi, yi, xf, yf, 0, WHITE );
        else
            GRLine( panel->GetClipBox(), DC, xi, yi, xf, yf, 0, color );
    }
}
void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
                             const wxPoint& aOffset, GBR_DISPLAY_OPTIONS* aDrawOptions )
{
    // used when a D_CODE is not found. default D_CODE to draw a flashed item
    static D_CODE dummyD_CODE( 0 );
    bool          isFilled;
    int           radius;
    int           halfPenWidth;
    static bool   show_err;
    D_CODE*       d_codeDescr = GetDcodeDescr();

    if( d_codeDescr == NULL )
        d_codeDescr = &dummyD_CODE;

    COLOR4D color = m_GerberImageFile->GetPositiveDrawColor();

    if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
        color.SetToLegacyHighlightColor();

    /* isDark is true if flash is positive and should use a drawing
     *   color other than the background color, else use the background color
     *   when drawing so that an erasure happens.
     */
    bool isDark = !(m_LayerNegative ^ m_GerberImageFile->m_ImageNegative);

    if( !isDark )
    {
        // draw in background color ("negative" color)
        color = aDrawOptions->m_NegativeDrawColor;
    }

    GRSetDrawMode( aDC, aDrawMode );

    isFilled = aDrawOptions->m_DisplayLinesFill;

    switch( m_Shape )
    {
    case GBR_POLYGON:
        isFilled = aDrawOptions->m_DisplayPolygonsFill;

        if( !isDark )
            isFilled = true;

        DrawGbrPoly( aPanel->GetClipBox(), aDC, color, aOffset, isFilled );
        break;

    case GBR_CIRCLE:
        radius = KiROUND( GetLineLength( m_Start, m_End ) );

        halfPenWidth = m_Size.x >> 1;

        if( !isFilled )
        {
            // draw the border of the pen's path using two circles, each as narrow as possible
            GRCircle( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ),
                      radius - halfPenWidth, 0, color );
            GRCircle( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ),
                      radius + halfPenWidth, 0, color );
        }
        else    // Filled mode
        {
            GRCircle( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ),
                      radius, m_Size.x, color );
        }
        break;

    case GBR_ARC:
        // Currently, arcs plotted with a rectangular aperture are not supported.
        // a round pen only is expected.

#if 0   // for arc debug only
        GRLine( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ),
                GetABPosition( m_ArcCentre ), 0, color );
        GRLine( aPanel->GetClipBox(), aDC, GetABPosition( m_End ),
                GetABPosition( m_ArcCentre ), 0, color );
#endif

        if( !isFilled )
        {
            GRArc1( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ),
                    GetABPosition( m_End ), GetABPosition( m_ArcCentre ),
                    0, color );
        }
        else
        {
            GRArc1( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ),
                    GetABPosition( m_End ), GetABPosition( m_ArcCentre ),
                    m_Size.x, color );
        }

        break;

    case GBR_SPOT_CIRCLE:
    case GBR_SPOT_RECT:
    case GBR_SPOT_OVAL:
    case GBR_SPOT_POLY:
    case GBR_SPOT_MACRO:
        isFilled = aDrawOptions->m_DisplayFlashedItemsFill;
        d_codeDescr->DrawFlashedShape( this, aPanel->GetClipBox(), aDC, color,
                                       m_Start, isFilled );
        break;

    case GBR_SEGMENT:
        /* Plot a line from m_Start to m_End.
         * Usually, a round pen is used, but some gerber files use a rectangular pen
         * In fact, any aperture can be used to plot a line.
         * currently: only a square pen is handled (I believe using a polygon gives a strange plot).
         */
        if( d_codeDescr->m_Shape == APT_RECT )
        {
            if( m_Polygon.OutlineCount() == 0 )
                ConvertSegmentToPolygon();

            DrawGbrPoly( aPanel->GetClipBox(), aDC, color, aOffset, isFilled );
        }
        else
        {
            if( !isFilled )
            {
                    GRCSegm( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ),
                             GetABPosition( m_End ), m_Size.x, color );
            }
            else
            {
                GRFilledSegment( aPanel->GetClipBox(), aDC, GetABPosition( m_Start ),
                                 GetABPosition( m_End ), m_Size.x, color );
            }
        }

        break;

    default:
        if( !show_err )
        {
            wxMessageBox( wxT( "Trace_Segment() type error" ) );
            show_err = true;
        }

        break;
    }
}