2007-05-06 16:03:28 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
// Name: sheet.cpp
|
2007-08-23 04:28:46 +00:00
|
|
|
// Purpose:
|
2007-05-06 16:03:28 +00:00
|
|
|
// Author: jean-pierre Charras
|
2007-08-23 04:28:46 +00:00
|
|
|
// Modified by:
|
2007-05-06 16:03:28 +00:00
|
|
|
// Created: 08/02/2006 18:37:02
|
2007-08-23 04:28:46 +00:00
|
|
|
// RCS-ID:
|
2007-05-06 16:03:28 +00:00
|
|
|
// Copyright: License GNU
|
2007-08-23 04:28:46 +00:00
|
|
|
// Licence:
|
2007-05-06 16:03:28 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
#include "protos.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************/
|
2007-08-23 04:28:46 +00:00
|
|
|
DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) :
|
2007-09-02 15:49:11 +00:00
|
|
|
SCH_SCREEN( SCHEMATIC_FRAME, DRAW_SHEET_STRUCT_TYPE )
|
2007-05-06 16:03:28 +00:00
|
|
|
/***********************************************************/
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
m_Label = NULL;
|
|
|
|
m_NbLabel = 0;
|
|
|
|
m_Layer = LAYER_SHEET;
|
|
|
|
m_Pos = pos;
|
|
|
|
m_SheetNameSize = m_FileNameSize = 60;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************/
|
2007-08-23 04:28:46 +00:00
|
|
|
DrawSheetStruct::~DrawSheetStruct()
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************/
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
DrawSheetLabelStruct* label = m_Label, * next_label;
|
|
|
|
|
|
|
|
while( label )
|
|
|
|
{
|
|
|
|
next_label = (DrawSheetLabelStruct*) label->Pnext;
|
|
|
|
delete label;
|
|
|
|
label = next_label;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
DrawSheetStruct* DrawSheetStruct::GenCopy()
|
2007-05-06 16:03:28 +00:00
|
|
|
/***********************************************/
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* creates a copy of a sheet
|
2007-08-23 04:28:46 +00:00
|
|
|
* The linked data itself (EEDrawList) is not duplicated
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
DrawSheetStruct* newitem = new DrawSheetStruct( m_Pos );
|
|
|
|
|
|
|
|
DrawSheetLabelStruct* Slabel = NULL, * label = m_Label;
|
|
|
|
|
|
|
|
newitem->m_Size = m_Size;
|
|
|
|
newitem->m_Parent = m_Parent;
|
|
|
|
newitem->m_TimeStamp = GetTimeStamp();
|
|
|
|
|
|
|
|
newitem->m_FileName = m_FileName;
|
|
|
|
newitem->m_FileNameSize = m_FileNameSize;
|
|
|
|
newitem->m_SheetName = m_SheetName;
|
|
|
|
newitem->m_SheetNameSize = m_SheetNameSize;
|
|
|
|
|
|
|
|
if( label )
|
|
|
|
{
|
|
|
|
Slabel = newitem->m_Label = label->GenCopy();
|
|
|
|
Slabel->m_Parent = newitem;
|
|
|
|
label = (DrawSheetLabelStruct*) label->Pnext;
|
|
|
|
}
|
|
|
|
|
|
|
|
while( label )
|
|
|
|
{
|
|
|
|
Slabel->Pnext = label->GenCopy();
|
|
|
|
Slabel = (DrawSheetLabelStruct*) Slabel->Pnext;
|
|
|
|
Slabel->m_Parent = newitem;
|
|
|
|
label = (DrawSheetLabelStruct*) label->Pnext;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy screen data */
|
|
|
|
newitem->m_DrawOrg = m_DrawOrg;
|
|
|
|
newitem->m_Curseur = m_Curseur;
|
|
|
|
newitem->m_MousePosition = m_MousePosition;
|
|
|
|
newitem->m_MousePositionInPixels = m_MousePositionInPixels;
|
|
|
|
newitem->m_O_Curseur = m_O_Curseur;
|
|
|
|
newitem->m_ScrollbarPos = m_ScrollbarPos;
|
|
|
|
newitem->m_ScrollbarNumber = m_ScrollbarNumber;
|
|
|
|
newitem->m_StartVisu = m_StartVisu;
|
|
|
|
newitem->m_FirstRedraw = m_FirstRedraw;
|
|
|
|
|
|
|
|
newitem->EEDrawList = EEDrawList; /* Object list (main data) for schematic */
|
|
|
|
newitem->m_UndoList = m_UndoList; /* Object list for the undo command (old data) */
|
|
|
|
newitem->m_RedoList = m_RedoList; /* Object list for the redo command (old data) */
|
|
|
|
|
|
|
|
newitem->m_CurrentSheet = m_CurrentSheet;
|
|
|
|
newitem->m_SheetNumber = m_SheetNumber;
|
|
|
|
newitem->m_NumberOfSheet = m_NumberOfSheet;
|
|
|
|
newitem->m_FileName = m_FileName;
|
|
|
|
newitem->m_Title = m_Title;
|
|
|
|
newitem->m_Date = m_Date;
|
|
|
|
newitem->m_Revision = m_Revision;
|
|
|
|
newitem->m_Company = m_Company;
|
|
|
|
newitem->m_Commentaire1 = m_Commentaire1;
|
|
|
|
newitem->m_Commentaire2 = m_Commentaire2;
|
|
|
|
newitem->m_Commentaire3 = m_Commentaire3;
|
|
|
|
newitem->m_Commentaire4 = m_Commentaire4;
|
|
|
|
|
|
|
|
return newitem;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/**********************************************************/
|
2007-08-23 04:28:46 +00:00
|
|
|
void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**********************************************************/
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Used if undo / redo command:
|
2007-08-23 04:28:46 +00:00
|
|
|
* swap data between this and copyitem
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
EXCHG( m_Pos, copyitem->m_Pos );
|
|
|
|
EXCHG( m_Size, copyitem->m_Size );
|
|
|
|
EXCHG( m_SheetName, copyitem->m_SheetName );
|
|
|
|
EXCHG( m_SheetNameSize, copyitem->m_SheetNameSize );
|
|
|
|
EXCHG( m_FileNameSize, copyitem->m_FileNameSize );
|
|
|
|
EXCHG( m_Label, copyitem->m_Label );
|
|
|
|
EXCHG( m_NbLabel, copyitem->m_NbLabel );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/**************************************************************************************/
|
2007-08-23 04:28:46 +00:00
|
|
|
void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
|
|
|
|
int DrawMode, int Color )
|
2007-05-28 18:09:49 +00:00
|
|
|
/**************************************************************************************/
|
|
|
|
/* Draw the hierarchical sheet shape */
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
DrawSheetLabelStruct* SheetLabelStruct;
|
|
|
|
int txtcolor;
|
|
|
|
wxString Text;
|
|
|
|
int color;
|
|
|
|
wxPoint pos = m_Pos + offset;
|
|
|
|
int LineWidth = g_DrawMinimunLineWidth;
|
|
|
|
|
|
|
|
if( Color >= 0 )
|
|
|
|
color = Color;
|
|
|
|
else
|
|
|
|
color = ReturnLayerColor( m_Layer );
|
|
|
|
GRSetDrawMode( DC, DrawMode );
|
|
|
|
|
|
|
|
GRRect( &panel->m_ClipBox, DC, pos.x, pos.y,
|
|
|
|
pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color );
|
|
|
|
|
|
|
|
/* Draw text : SheetName */
|
|
|
|
if( Color > 0 )
|
|
|
|
txtcolor = Color;
|
|
|
|
else
|
|
|
|
txtcolor = ReturnLayerColor( LAYER_SHEETNAME );
|
|
|
|
|
|
|
|
Text = wxT( "Sheet: " ) + m_SheetName;
|
|
|
|
DrawGraphicText( panel, DC,
|
|
|
|
wxPoint( pos.x, pos.y - 8 ), txtcolor,
|
|
|
|
Text, TEXT_ORIENT_HORIZ, wxSize( m_SheetNameSize, m_SheetNameSize ),
|
|
|
|
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth );
|
|
|
|
|
|
|
|
/* Draw text : FileName */
|
|
|
|
if( Color >= 0 )
|
|
|
|
txtcolor = Color;
|
|
|
|
else
|
|
|
|
txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME );
|
|
|
|
Text = wxT( "File: " ) + m_FileName;
|
|
|
|
DrawGraphicText( panel, DC,
|
|
|
|
wxPoint( pos.x, pos.y + m_Size.y + 4 ),
|
|
|
|
txtcolor,
|
|
|
|
Text, TEXT_ORIENT_HORIZ, wxSize( m_FileNameSize, m_FileNameSize ),
|
|
|
|
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth );
|
|
|
|
|
|
|
|
|
|
|
|
/* Draw text : SheetLabel */
|
|
|
|
SheetLabelStruct = m_Label;
|
|
|
|
while( SheetLabelStruct != NULL )
|
|
|
|
{
|
|
|
|
SheetLabelStruct->Draw( panel, DC, offset, DrawMode, Color );
|
|
|
|
SheetLabelStruct = (DrawSheetLabelStruct*) (SheetLabelStruct->Pnext);
|
|
|
|
}
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
/************************/
|
|
|
|
/* DrawSheetLabelStruct */
|
|
|
|
/************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/*******************************************************************/
|
2007-08-23 04:28:46 +00:00
|
|
|
DrawSheetLabelStruct::DrawSheetLabelStruct( DrawSheetStruct* parent,
|
|
|
|
const wxPoint& pos, const wxString& text ) :
|
|
|
|
EDA_BaseStruct( DRAW_SHEETLABEL_STRUCT_TYPE ),
|
|
|
|
EDA_TextStruct( text )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*******************************************************************/
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
m_Layer = LAYER_SHEETLABEL;
|
|
|
|
m_Parent = parent;
|
|
|
|
m_Pos = pos;
|
|
|
|
m_Edge = 0;
|
|
|
|
m_Shape = NET_INPUT;
|
|
|
|
m_IsDangling = TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
DrawSheetLabelStruct* DrawSheetLabelStruct::GenCopy()
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************/
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
DrawSheetLabelStruct* newitem =
|
|
|
|
new DrawSheetLabelStruct( (DrawSheetStruct*) m_Parent, m_Pos, m_Text );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
newitem->m_Edge = m_Edge;
|
|
|
|
newitem->m_Shape = m_Shape;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
return newitem;
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************************************************/
|
2007-08-23 04:28:46 +00:00
|
|
|
void DrawSheetLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
|
|
|
|
int DrawMode, int Color )
|
2007-05-28 18:09:49 +00:00
|
|
|
/********************************************************************************************/
|
|
|
|
/* Routine de dessin des Labels type hierarchie */
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
int side, txtcolor;
|
|
|
|
int posx, tposx, posy, size2;
|
|
|
|
wxSize size;
|
|
|
|
int NbSegm, coord[20];
|
|
|
|
int LineWidth = g_DrawMinimunLineWidth;
|
|
|
|
|
|
|
|
if( Color >= 0 )
|
|
|
|
txtcolor = Color;
|
|
|
|
else
|
|
|
|
txtcolor = ReturnLayerColor( m_Layer );
|
|
|
|
GRSetDrawMode( DC, DrawMode );
|
|
|
|
|
|
|
|
posx = m_Pos.x + offset.x; posy = m_Pos.y + offset.y; size = m_Size;
|
|
|
|
if( !m_Text.IsEmpty() )
|
|
|
|
{
|
|
|
|
if( m_Edge )
|
|
|
|
{
|
|
|
|
tposx = posx - size.x;
|
|
|
|
side = GR_TEXT_HJUSTIFY_RIGHT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tposx = posx + size.x + (size.x / 8);
|
|
|
|
side = GR_TEXT_HJUSTIFY_LEFT;
|
|
|
|
}
|
|
|
|
DrawGraphicText( panel, DC, wxPoint( tposx, posy ), txtcolor,
|
|
|
|
m_Text, TEXT_ORIENT_HORIZ, size,
|
|
|
|
side, GR_TEXT_VJUSTIFY_CENTER, LineWidth );
|
|
|
|
}
|
|
|
|
/* dessin du symbole de connexion */
|
|
|
|
|
|
|
|
if( m_Edge )
|
|
|
|
{
|
|
|
|
size.x = -size.x;
|
|
|
|
size.y = -size.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
coord[0] = posx; coord[1] = posy; size2 = size.x / 2;
|
|
|
|
NbSegm = 0;
|
|
|
|
|
|
|
|
switch( m_Shape )
|
|
|
|
{
|
|
|
|
case 0: /* input |> */
|
|
|
|
coord[2] = posx; coord[3] = posy - size2;
|
|
|
|
coord[4] = posx + size2; coord[5] = posy - size2;
|
|
|
|
coord[6] = posx + size.x; coord[7] = posy;
|
|
|
|
coord[8] = posx + size2; coord[9] = posy + size2;
|
|
|
|
coord[10] = posx; coord[11] = posy + size2;
|
|
|
|
coord[12] = coord[0]; coord[13] = coord[1];
|
|
|
|
NbSegm = 7;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* output <| */
|
|
|
|
coord[2] = posx + size2; coord[3] = posy - size2;
|
|
|
|
coord[4] = posx + size.x; coord[5] = posy - size2;
|
|
|
|
coord[6] = posx + size.x; coord[7] = posy + size2;
|
|
|
|
coord[8] = posx + size2; coord[9] = posy + size2;
|
|
|
|
coord[10] = coord[0]; coord[11] = coord[1];
|
|
|
|
NbSegm = 6;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* bidi <> */
|
|
|
|
case 3: /* TriSt <> */
|
|
|
|
coord[2] = posx + size2; coord[3] = posy - size2;
|
|
|
|
coord[4] = posx + size.x; coord[5] = posy;
|
|
|
|
coord[6] = posx + size2; coord[7] = posy + size2;
|
|
|
|
coord[8] = coord[0]; coord[9] = coord[1];
|
|
|
|
NbSegm = 5;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* unsp []*/
|
|
|
|
coord[2] = posx; coord[3] = posy - size2;
|
|
|
|
coord[4] = posx + size.x; coord[5] = posy - size2;
|
|
|
|
coord[6] = posx + size.x; coord[7] = posy + size2;
|
|
|
|
coord[8] = posx; coord[9] = posy + size2;
|
|
|
|
coord[10] = coord[0]; coord[11] = coord[1];
|
|
|
|
NbSegm = 6;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
int FillShape = FALSE;
|
|
|
|
GRPoly( &panel->m_ClipBox, DC, NbSegm, coord, FillShape, LineWidth, txtcolor, txtcolor ); /* Poly Non rempli */
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|