kicad/eeschema/eeredraw.cpp

308 lines
9.0 KiB
C++
Raw Normal View History

2007-05-06 16:03:28 +00:00
/*****************************************************************************
* Program to draw EE diagrams. *
* This module redraw/draw all structs. *
*****************************************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "class_drawpanel.h"
#include "class_drawpickedstruct.h"
#include "appl_wxstruct.h"
2007-05-06 16:03:28 +00:00
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
static EDA_BaseStruct* HighLightStruct = NULL;
2007-05-06 16:03:28 +00:00
void DrawDanglingSymbol( WinEDA_DrawPanel* panel, wxDC* DC,
2009-01-02 17:07:50 +00:00
const wxPoint& pos, int Color )
2007-05-06 16:03:28 +00:00
{
BASE_SCREEN* screen = panel->GetScreen();
if( !screen->m_IsPrinting ) /* Draw but do not print the Dangling Symbol */
{
GRRect( &panel->m_ClipBox, DC,
2009-01-02 17:07:50 +00:00
pos.x - DANGLING_SYMBOL_SIZE, pos.y - DANGLING_SYMBOL_SIZE,
pos.x + DANGLING_SYMBOL_SIZE, pos.y + DANGLING_SYMBOL_SIZE,
0, Color );
}
2007-05-06 16:03:28 +00:00
}
void SetHighLightStruct( EDA_BaseStruct* HighLight )
2007-05-06 16:03:28 +00:00
{
HighLightStruct = HighLight;
2007-05-06 16:03:28 +00:00
}
2007-05-06 16:03:28 +00:00
/*
2009-01-02 17:07:50 +00:00
* Redraws only the active window which is assumed to be whole visible.
*/
void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
2007-05-06 16:03:28 +00:00
{
wxString title;
if( GetScreen() == NULL )
return;
ActiveScreen = GetScreen();
/* Reinit draw and pen parameters */
GRResetPenAndBrush( DC );
DC->SetBackground( *wxBLACK_BRUSH );
DC->SetBackgroundMode( wxTRANSPARENT );
DrawPanel->CursorOff( DC ); // effacement curseur
2007-05-06 16:03:28 +00:00
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
}
if( EraseBg )
DrawPanel->EraseScreen( DC );
DrawPanel->DrawBackGround( DC );
RedrawStructList( DrawPanel, DC, GetScreen()->EEDrawList,
GR_DEFAULT_DRAWMODE );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness );
DrawPanel->CursorOn( DC ); // reaffichage curseur
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
}
UpdateStatusBar();
GetScreen()->ClrRefreshReq();
// Display the sheet filename, and the sheet path, for non root sheets
if( GetScreen()->m_FileName == m_DefaultSchematicFileName )
{
wxString msg = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
title.Printf( wxT( "%s [%s]" ), msg.GetData(),
GetScreen()->m_FileName.GetData() );
SetTitle( title );
}
else
{
title = wxT( "[" );
2009-01-02 17:07:50 +00:00
title << GetScreen()->m_FileName << wxT( "] " ) << _( "Sheet" );
title << wxT( " " ) << m_CurrentSheet->PathHumanReadable();
SetTitle( title );
}
2007-05-06 16:03:28 +00:00
}
/**
* PrintPage
* used to print a page.
* Print the page pointed by ActiveScreen, set by the calling print function
* @param DC = wxDC given by the calling print function
* @param Print_Sheet_Ref = true to print page references
* @param PrintMask = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
*/
void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref,
int PrintMask, bool aPrintMirrorMode )
2007-05-06 16:03:28 +00:00
{
wxBeginBusyCursor();
2007-05-06 16:03:28 +00:00
RedrawStructList( this, DC, ActiveScreen->EEDrawList, GR_COPY );
2007-05-06 16:03:28 +00:00
if( Print_Sheet_Ref )
m_Parent->TraceWorkSheet( DC, ActiveScreen, g_DrawDefaultLineThickness );
2007-05-06 16:03:28 +00:00
wxEndBusyCursor();
2007-05-06 16:03:28 +00:00
}
/*****************************************************************************
* Routine to redraw list of structs. *
* If the list is of DrawPickStruct types then the picked item are drawn. *
*****************************************************************************/
void RedrawStructList( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_ITEM* Structs, int DrawMode, int Color )
2007-05-06 16:03:28 +00:00
{
while( Structs )
{
if( Structs->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{
SCH_ITEM* item =
(SCH_ITEM*) ( (DrawPickedStruct*) Structs )->m_PickedStruct;
// uncomment line below when there is a virtual EDA_BaseStruct::GetBoundingBox()
2009-01-02 17:07:50 +00:00
// if( panel->m_ClipBox.Intersects( item->GetBoundingBox() ) )
{
RedrawOneStruct( panel, DC, item, DrawMode, Color );
}
}
else
{
if( !(Structs->m_Flags & IS_MOVED) )
{
// uncomment line below when there is a virtual EDA_BaseStruct::GetBoundingBox()
2009-01-02 17:07:50 +00:00
// if( panel->m_ClipBox.Intersects( Structs->GetBoundingBox() ) )
RedrawOneStruct( panel, DC, Structs, DrawMode, Color );
}
}
Structs = Structs->Next();
}
2007-05-06 16:03:28 +00:00
}
2007-05-06 16:03:28 +00:00
/*****************************************************************************
* Routine to redraw list of structs. *
*****************************************************************************/
void RedrawOneStruct( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_ITEM* Struct, int DrawMode, int Color )
2007-05-06 16:03:28 +00:00
{
if( Struct == NULL )
return;
2007-05-06 16:03:28 +00:00
if( HighLightStruct == Struct )
Color = HIGHLIGHT_COLOR;
2007-05-06 16:03:28 +00:00
Struct->Draw( panel, DC, wxPoint( 0, 0 ), DrawMode, Color );
2007-05-06 16:03:28 +00:00
}
2007-05-06 16:03:28 +00:00
/* Routine de redessin en mode fantome (Dessin simplifie en g_XorMode et
2009-01-02 17:07:50 +00:00
* g_GhostColor
* de structures.
* Utilisee dans les deplacements de blocs
*/
void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_ITEM* DrawStruct, int dx, int dy )
2007-05-06 16:03:28 +00:00
{
int DrawMode = g_XorMode;
int width = g_DrawDefaultLineThickness;
GRSetDrawMode( DC, DrawMode );
switch( DrawStruct->Type() )
{
case DRAW_POLYLINE_STRUCT_TYPE:
{
2009-01-02 17:07:50 +00:00
DrawPolylineStruct* Struct = (DrawPolylineStruct*) DrawStruct;
GRMoveTo( Struct->m_PolyPoints[0].x + dx,
Struct->m_PolyPoints[0].y + dy );
2009-01-02 17:07:50 +00:00
for( unsigned ii = 1; ii < Struct->GetCornerCount(); ii++ )
GRLineTo( &panel->m_ClipBox, DC, Struct->m_PolyPoints[ii].x + dx,
Struct->m_PolyPoints[ii].y + dy, width, g_GhostColor );
break;
}
case DRAW_SEGMENT_STRUCT_TYPE:
{
EDA_DrawLineStruct* Struct;
Struct = (EDA_DrawLineStruct*) DrawStruct;
if( (Struct->m_Flags & STARTPOINT) == 0 )
{
GRMoveTo( Struct->m_Start.x + dx, Struct->m_Start.y + dy );
}
else
{
GRMoveTo( Struct->m_Start.x, Struct->m_Start.y );
}
if( (Struct->m_Flags & ENDPOINT) == 0 )
{
GRLineTo( &panel->m_ClipBox, DC, Struct->m_End.x + dx,
Struct->m_End.y + dy, width, g_GhostColor );
}
else
{
GRLineTo( &panel->m_ClipBox, DC, Struct->m_End.x,
Struct->m_End.y, width, g_GhostColor );
}
break;
}
case DRAW_BUSENTRY_STRUCT_TYPE:
{
DrawBusEntryStruct* Struct = (DrawBusEntryStruct*) DrawStruct;
int xx = Struct->m_Pos.x + dx, yy = Struct->m_Pos.y + dy;
GRMoveTo( xx, yy );
GRLineTo( &panel->m_ClipBox, DC, Struct->m_Size.x + xx,
Struct->m_Size.y + yy, width, g_GhostColor );
break;
}
case DRAW_JUNCTION_STRUCT_TYPE:
{
DrawJunctionStruct* Struct;
Struct = (DrawJunctionStruct*) DrawStruct;
Struct->Draw( panel, DC, wxPoint(0,0), DrawMode, g_GhostColor );
break;
}
2008-03-20 01:50:21 +00:00
case TYPE_SCH_TEXT:
{
2008-03-20 01:50:21 +00:00
SCH_TEXT* Struct;
Struct = (SCH_TEXT*) DrawStruct;
Struct->Draw( panel, DC, wxPoint( dx, dy ), DrawMode, g_GhostColor );
break;
}
2008-03-20 01:50:21 +00:00
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
{
2008-03-20 01:50:21 +00:00
SCH_LABEL* Struct;
Struct = (SCH_LABEL*) DrawStruct;
Struct->Draw( panel, DC, wxPoint( dx, dy ), DrawMode, g_GhostColor );
break;
}
case DRAW_NOCONNECT_STRUCT_TYPE:
{
DrawNoConnectStruct* Struct;
Struct = (DrawNoConnectStruct*) DrawStruct;
Struct->Draw( panel, DC, wxPoint( dx, dy ), DrawMode, g_GhostColor );
break;
}
2008-03-20 01:50:21 +00:00
case TYPE_SCH_COMPONENT:
{
EDA_LibComponentStruct* LibEntry;
2009-01-02 17:07:50 +00:00
SCH_COMPONENT* Struct;
2008-03-20 01:50:21 +00:00
Struct = (SCH_COMPONENT*) DrawStruct;
LibEntry = FindLibPart( Struct->m_ChipName.GetData(), wxEmptyString,
FIND_ROOT );
if( LibEntry == NULL )
break;
DrawingLibInGhost( panel, DC, LibEntry, Struct, Struct->m_Pos.x + dx,
Struct->m_Pos.y + dy, Struct->m_Multi,
Struct->m_Convert, g_GhostColor, FALSE );
break;
}
case DRAW_SHEET_STRUCT_TYPE:
{
DrawSheetStruct* Struct = (DrawSheetStruct*) DrawStruct;
GRRect( &panel->m_ClipBox, DC, Struct->m_Pos.x + dx,
Struct->m_Pos.y + dy, Struct->m_Pos.x + Struct->m_Size.x + dx,
2009-01-02 17:07:50 +00:00
Struct->m_Pos.y + Struct->m_Size.y + dy, width, g_GhostColor );
break;
}
2008-04-15 19:38:19 +00:00
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE:
break;
default:
break;
}
2007-05-06 16:03:28 +00:00
}