2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************************************************
|
2009-10-16 17:18:23 +00:00
|
|
|
* Program to draw EE diagrams. *
|
|
|
|
* This module redraw/draw all structs. *
|
2007-05-06 16:03:28 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
2009-04-05 20:49:15 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_library.h"
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-13 06:36:53 +00:00
|
|
|
static EDA_BaseStruct* HighLightStruct = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-03-27 21:02:42 +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
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
BASE_SCREEN* screen = panel->GetScreen();
|
|
|
|
|
|
|
|
if( !screen->m_IsPrinting ) /* Draw but do not print the Dangling Symbol */
|
2008-03-13 06:36:53 +00:00
|
|
|
{
|
|
|
|
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 );
|
2008-03-13 06:36:53 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-13 06:36:53 +00:00
|
|
|
void SetHighLightStruct( EDA_BaseStruct* HighLight )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-13 06:36:53 +00:00
|
|
|
HighLightStruct = HighLight;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-13 06:36:53 +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.
|
2008-03-13 06:36:53 +00:00
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-13 06:36:53 +00:00
|
|
|
wxString title;
|
|
|
|
|
|
|
|
if( GetScreen() == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
ActiveScreen = GetScreen();
|
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
/* Reinit draw and pen parameters */
|
2008-03-13 06:36:53 +00:00
|
|
|
GRResetPenAndBrush( DC );
|
|
|
|
DC->SetBackground( *wxBLACK_BRUSH );
|
|
|
|
DC->SetBackgroundMode( wxTRANSPARENT );
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
DrawPanel->CursorOff( DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-13 06:36:53 +00:00
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
{
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( EraseBg )
|
|
|
|
DrawPanel->EraseScreen( DC );
|
|
|
|
|
|
|
|
DrawPanel->DrawBackGround( DC );
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
RedrawStructList( DrawPanel, DC, GetScreen()->EEDrawList,
|
|
|
|
GR_DEFAULT_DRAWMODE );
|
2008-03-13 06:36:53 +00:00
|
|
|
|
2009-06-02 07:26:49 +00:00
|
|
|
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness );
|
2008-03-13 06:36:53 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
DrawPanel->CursorOn( DC );
|
2008-03-13 06:36:53 +00:00
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
{
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
GetScreen()->ClrRefreshReq();
|
2008-04-16 08:40:31 +00:00
|
|
|
|
|
|
|
// Display the sheet filename, and the sheet path, for non root sheets
|
2009-04-29 17:09:00 +00:00
|
|
|
if( GetScreen()->m_FileName == m_DefaultSchematicFileName )
|
2008-03-13 06:36:53 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString msg = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
|
|
|
|
title.Printf( wxT( "%s [%s]" ), msg.GetData(),
|
2009-11-03 13:26:31 +00:00
|
|
|
GetScreen()->m_FileName.GetData() );
|
2008-03-13 06:36:53 +00:00
|
|
|
SetTitle( title );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-16 08:40:31 +00:00
|
|
|
title = wxT( "[" );
|
2009-01-02 17:07:50 +00:00
|
|
|
title << GetScreen()->m_FileName << wxT( "] " ) << _( "Sheet" );
|
2008-04-16 08:40:31 +00:00
|
|
|
title << wxT( " " ) << m_CurrentSheet->PathHumanReadable();
|
2008-03-13 06:36:53 +00:00
|
|
|
SetTitle( title );
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-13 06:36:53 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/**
|
|
|
|
* PrintPage
|
2008-07-31 15:30:57 +00:00
|
|
|
* 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
|
2008-11-02 19:52:57 +00:00
|
|
|
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
|
2008-07-31 15:30:57 +00:00
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref,
|
2009-11-03 13:26:31 +00:00
|
|
|
int PrintMask, bool aPrintMirrorMode )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-13 06:36:53 +00:00
|
|
|
wxBeginBusyCursor();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-07-31 15:30:57 +00:00
|
|
|
RedrawStructList( this, DC, ActiveScreen->EEDrawList, GR_COPY );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-13 06:36:53 +00:00
|
|
|
if( Print_Sheet_Ref )
|
2009-06-02 07:26:49 +00:00
|
|
|
m_Parent->TraceWorkSheet( DC, ActiveScreen, g_DrawDefaultLineThickness );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-13 06:36:53 +00:00
|
|
|
wxEndBusyCursor();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2009-10-16 17:18:23 +00:00
|
|
|
* Routine to redraw list of structs. *
|
|
|
|
* If the list is of DrawPickStruct types then the picked item are drawn. *
|
2007-05-06 16:03:28 +00:00
|
|
|
*****************************************************************************/
|
2008-03-13 06:36:53 +00:00
|
|
|
void RedrawStructList( WinEDA_DrawPanel* panel, wxDC* DC,
|
2009-07-25 07:31:07 +00:00
|
|
|
SCH_ITEM* Structlist, int DrawMode, int Color )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-07-25 07:31:07 +00:00
|
|
|
while( Structlist )
|
2008-03-13 06:36:53 +00:00
|
|
|
{
|
2009-07-25 07:31:07 +00:00
|
|
|
if( !(Structlist->m_Flags & IS_MOVED) )
|
2008-03-13 06:36:53 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
// uncomment line below when there is a virtual
|
|
|
|
// EDA_BaseStruct::GetBoundingBox()
|
|
|
|
// if( panel->m_ClipBox.Intersects( Structs->GetBoundingBox()
|
|
|
|
// ) )
|
2009-07-25 07:31:07 +00:00
|
|
|
RedrawOneStruct( panel, DC, Structlist, DrawMode, Color );
|
2008-03-13 06:36:53 +00:00
|
|
|
}
|
|
|
|
|
2009-07-25 07:31:07 +00:00
|
|
|
Structlist = Structlist->Next();
|
2008-03-13 06:36:53 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-13 06:36:53 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************************************************
|
2009-10-16 17:18:23 +00:00
|
|
|
* Routine to redraw list of structs. *
|
2007-05-06 16:03:28 +00:00
|
|
|
*****************************************************************************/
|
2008-03-13 06:36:53 +00:00
|
|
|
void RedrawOneStruct( WinEDA_DrawPanel* panel, wxDC* DC,
|
2008-04-14 19:22:48 +00:00
|
|
|
SCH_ITEM* Struct, int DrawMode, int Color )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-13 06:36:53 +00:00
|
|
|
if( Struct == NULL )
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-13 06:36:53 +00:00
|
|
|
if( HighLightStruct == Struct )
|
|
|
|
Color = HIGHLIGHT_COLOR;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-13 06:36:53 +00:00
|
|
|
Struct->Draw( panel, DC, wxPoint( 0, 0 ), DrawMode, Color );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Routine for repainting item in ghost mode. Used in the block moves. */
|
|
|
|
void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
|
|
|
|
wxDC* aDC,
|
|
|
|
SCH_ITEM* aItem,
|
|
|
|
const wxPoint& aOffset )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-13 06:36:53 +00:00
|
|
|
int DrawMode = g_XorMode;
|
2009-06-02 07:26:49 +00:00
|
|
|
int width = g_DrawDefaultLineThickness;
|
2008-03-13 06:36:53 +00:00
|
|
|
|
2009-07-26 17:16:42 +00:00
|
|
|
GRSetDrawMode( aDC, DrawMode );
|
2008-03-13 06:36:53 +00:00
|
|
|
|
2009-07-26 17:16:42 +00:00
|
|
|
switch( aItem->Type() )
|
2008-03-13 06:36:53 +00:00
|
|
|
{
|
|
|
|
case DRAW_POLYLINE_STRUCT_TYPE:
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_POLYLINE* Struct = (SCH_POLYLINE*) aItem;
|
2009-07-26 17:16:42 +00:00
|
|
|
GRMoveTo( Struct->m_PolyPoints[0].x + aOffset.x,
|
|
|
|
Struct->m_PolyPoints[0].y + aOffset.y );
|
2009-01-02 17:07:50 +00:00
|
|
|
for( unsigned ii = 1; ii < Struct->GetCornerCount(); ii++ )
|
2009-11-03 13:26:31 +00:00
|
|
|
GRLineTo( &aPanel->m_ClipBox,
|
|
|
|
aDC,
|
|
|
|
Struct->m_PolyPoints[ii].x + aOffset.x,
|
|
|
|
Struct->m_PolyPoints[ii].y + aOffset.y,
|
|
|
|
width,
|
|
|
|
g_GhostColor );
|
2008-03-13 06:36:53 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_LINE* Struct;
|
|
|
|
Struct = (SCH_LINE*) aItem;
|
2008-03-13 06:36:53 +00:00
|
|
|
if( (Struct->m_Flags & STARTPOINT) == 0 )
|
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
GRMoveTo( Struct->m_Start.x + aOffset.x,
|
|
|
|
Struct->m_Start.y + aOffset.y );
|
2008-03-13 06:36:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GRMoveTo( Struct->m_Start.x, Struct->m_Start.y );
|
|
|
|
}
|
|
|
|
if( (Struct->m_Flags & ENDPOINT) == 0 )
|
|
|
|
{
|
2009-07-26 17:16:42 +00:00
|
|
|
GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_End.x + aOffset.x,
|
|
|
|
Struct->m_End.y + aOffset.y, width, g_GhostColor );
|
2008-03-13 06:36:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-26 17:16:42 +00:00
|
|
|
GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_End.x,
|
2009-04-05 20:49:15 +00:00
|
|
|
Struct->m_End.y, width, g_GhostColor );
|
2008-03-13 06:36:53 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DRAW_BUSENTRY_STRUCT_TYPE:
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_BUS_ENTRY* Struct = (SCH_BUS_ENTRY*) aItem;
|
|
|
|
wxPoint start = Struct->m_Pos + aOffset;
|
2009-07-26 17:16:42 +00:00
|
|
|
GRMoveTo( start.x, start.y );
|
|
|
|
GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_Size.x + start.x,
|
|
|
|
Struct->m_Size.y + start.y, width, g_GhostColor );
|
2008-03-13 06:36:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DRAW_JUNCTION_STRUCT_TYPE:
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_JUNCTION* Struct;
|
|
|
|
Struct = (SCH_JUNCTION*) aItem;
|
2009-07-26 17:16:42 +00:00
|
|
|
Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
|
2008-03-13 06:36:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_TEXT:
|
2008-03-13 06:36:53 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_TEXT* Struct;
|
2009-07-26 17:16:42 +00:00
|
|
|
Struct = (SCH_TEXT*) aItem;
|
|
|
|
Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
|
2008-03-13 06:36:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
|
|
|
case TYPE_SCH_HIERLABEL:
|
2008-03-13 06:36:53 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_LABEL* Struct;
|
2009-07-26 17:16:42 +00:00
|
|
|
Struct = (SCH_LABEL*) aItem;
|
|
|
|
Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
|
2008-03-13 06:36:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DRAW_NOCONNECT_STRUCT_TYPE:
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_NO_CONNECT* Struct;
|
|
|
|
Struct = (SCH_NO_CONNECT*) aItem;
|
2009-07-26 17:16:42 +00:00
|
|
|
Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
|
2008-03-13 06:36:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_COMPONENT:
|
2008-03-13 06:36:53 +00:00
|
|
|
{
|
2009-10-16 17:18:23 +00:00
|
|
|
SCH_COMPONENT* Component = (SCH_COMPONENT*) aItem;
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
if( Component == NULL )
|
2008-03-13 06:36:53 +00:00
|
|
|
break;
|
2009-10-16 17:18:23 +00:00
|
|
|
|
|
|
|
Component->Draw( aPanel, aDC, aOffset, g_XorMode, g_GhostColor, false );
|
2008-03-13 06:36:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DRAW_SHEET_STRUCT_TYPE:
|
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET* Struct = (SCH_SHEET*) aItem;
|
2009-11-03 13:26:31 +00:00
|
|
|
GRRect( &aPanel->m_ClipBox,
|
|
|
|
aDC,
|
|
|
|
Struct->m_Pos.x + aOffset.x,
|
|
|
|
Struct->m_Pos.y + aOffset.y,
|
|
|
|
Struct->m_Pos.x + Struct->m_Size.x + aOffset.x,
|
|
|
|
Struct->m_Pos.y + Struct->m_Size.y + aOffset.y,
|
|
|
|
width,
|
|
|
|
g_GhostColor );
|
2008-03-13 06:36:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
|
2009-12-02 21:44:03 +00:00
|
|
|
case TYPE_SCH_MARKER:
|
2008-03-13 06:36:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|