7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-11 00:30:01 +00:00

see changelog

This commit is contained in:
charras 2008-04-15 19:38:19 +00:00
parent 7f453831d5
commit 8123d3a5eb
45 changed files with 1377 additions and 864 deletions

View File

@ -5,6 +5,17 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2008-Apr-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+eeschema
More code cleaning and Files cleaning and reorganization.
change DrawSheetLabelStruct class name to a better name: Hierarchical_PIN_Sheet_Struct
For simple Hierarchies, files are now compatables with old eescheam versions
In complex hierarchies, multiples parts per packages have still problems,
but i hope to solve that soon
(in fact all the last changes were made for that)
2008-Apr-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+eeschema

View File

@ -569,7 +569,7 @@ EDA_BaseStruct* BASE_SCREEN::GetItemFromRedoList()
*/
void BASE_SCREEN::Show( int nestLevel, std::ostream& os )
{
EDA_BaseStruct* item = EEDrawList;
EDA_BaseStruct* item = (EDA_BaseStruct*) EEDrawList; // @todo : use SCH_ITEM as type for item
// for now, make it look like XML, expand on this later.
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<

View File

@ -6,6 +6,22 @@
#include "common.h"
#include "sch_item_struct.h"
/* Constructor and destructor for SCH_ITEM */
/* They are not inline because this creates problems with gcc at linking time
* in debug mode
*/
SCH_ITEM::SCH_ITEM( EDA_BaseStruct* aParent, KICAD_T aType ) :
EDA_BaseStruct( aParent, aType )
{
m_Layer = 0;
}
SCH_ITEM::~SCH_ITEM()
{
}
/**************************/
/* class DrawPickedStruct */
/**************************/

View File

@ -13,10 +13,11 @@ set(EESCHEMA_SRCS
busentry.cpp
bus-wire-junction.cpp
class_drawsheet.cpp
class_hierarchical_PIN_sheet.cpp
class_screen.cpp
class_text-label.cpp
class_schematic_items.cpp
cleanup.cpp
cmpclass.cpp
component_class.cpp
controle.cpp
cross-probing.cpp
@ -34,7 +35,6 @@ set(EESCHEMA_SRCS
dialog_erc.cpp
# dialog_find.cpp
dialog_options.cpp
# divers.cpp
edit_component_in_lib.cpp
edit_component_in_schematic.cpp
edit_label.cpp
@ -43,7 +43,6 @@ set(EESCHEMA_SRCS
eelayer.cpp
eelibs_draw_components.cpp
eelibs_read_libraryfiles.cpp
eeload.cpp
eeredraw.cpp
eeschema.cpp
eestring.cpp

View File

@ -607,7 +607,7 @@ void MirrorOneStruct( SCH_ITEM * DrawStruct, wxPoint& Center )
DrawBusEntryStruct* DrawRaccord;
SCH_COMPONENT* DrawLibItem;
DrawSheetStruct* DrawSheet;
DrawSheetLabelStruct* DrawSheetLabel;
Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
DrawMarkerStruct* DrawMarker;
DrawNoConnectStruct* DrawNoConnect;
SCH_TEXT* DrawText;
@ -728,13 +728,13 @@ void MirrorOneStruct( SCH_ITEM * DrawStruct, wxPoint& Center )
{
MirrorYPoint( DrawSheetLabel->m_Pos, Center );
DrawSheetLabel->m_Edge = DrawSheetLabel->m_Edge ? 0 : 1;
DrawSheetLabel = (DrawSheetLabelStruct*) DrawSheetLabel->Pnext;
DrawSheetLabel = (Hierarchical_PIN_Sheet_Struct*) DrawSheetLabel->Pnext;
}
break;
case DRAW_SHEETLABEL_STRUCT_TYPE:
DrawSheetLabel = (DrawSheetLabelStruct*) DrawStruct;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
DrawSheetLabel = (Hierarchical_PIN_Sheet_Struct*) DrawStruct;
MirrorYPoint( DrawSheetLabel->m_Pos, Center );
break;
@ -876,7 +876,7 @@ static SCH_ITEM * CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREEN* sc
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE:
case DRAW_NOCONNECT_STRUCT_TYPE:
@ -929,12 +929,12 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM * DrawStruct )
if( !DrawStruct )
return;
if( DrawStruct->Type() == DRAW_SHEETLABEL_STRUCT_TYPE )
if( DrawStruct->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
{
/* Cette stucture est rattachee a une feuille, et n'est pas
* accessible par la liste globale directement */
frame->SaveCopyInUndoList( (SCH_ITEM*) ( (DrawSheetLabelStruct*) DrawStruct )->m_Parent, IS_CHANGED );
frame->DeleteSheetLabel( DC, (DrawSheetLabelStruct*) DrawStruct );
frame->SaveCopyInUndoList( (SCH_ITEM*) ( (Hierarchical_PIN_Sheet_Struct*) DrawStruct )->m_Parent, IS_CHANGED );
frame->DeleteSheetLabel( DC, (Hierarchical_PIN_Sheet_Struct*) DrawStruct );
return;
}
@ -1127,7 +1127,7 @@ bool PlaceStruct( BASE_SCREEN* screen, SCH_ITEM * DrawStruct )
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_COMPONENT:
case DRAW_SHEET_STRUCT_TYPE:
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE:
case DRAW_NOCONNECT_STRUCT_TYPE:
MoveOneStruct( DrawStruct, move_vector );
@ -1162,7 +1162,7 @@ void MoveOneStruct( SCH_ITEM * DrawStruct, const wxPoint& move_vector )
DrawBusEntryStruct* DrawRaccord;
SCH_COMPONENT* DrawLibItem;
DrawSheetStruct* DrawSheet;
DrawSheetLabelStruct* DrawSheetLabel;
Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
DrawMarkerStruct* DrawMarker;
DrawNoConnectStruct* DrawNoConnect;
@ -1255,8 +1255,8 @@ void MoveOneStruct( SCH_ITEM * DrawStruct, const wxPoint& move_vector )
break;
case DRAW_SHEETLABEL_STRUCT_TYPE:
DrawSheetLabel = (DrawSheetLabelStruct*) DrawStruct;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
DrawSheetLabel = (Hierarchical_PIN_Sheet_Struct*) DrawStruct;
DrawSheetLabel->m_Pos += move_vector;
break;
@ -1356,7 +1356,7 @@ SCH_ITEM * DuplicateStruct( SCH_ITEM * DrawStruct )
break;
}
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_PART_TEXT_STRUCT_TYPE:
case SCREEN_STRUCT_TYPE:
default:
@ -1467,12 +1467,12 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
if( Struct->Type() == DRAW_SHEET_STRUCT_TYPE )
{
DrawSheetLabelStruct* SLabel = ( (DrawSheetStruct*) Struct )->m_Label;
Hierarchical_PIN_Sheet_Struct* SLabel = ( (DrawSheetStruct*) Struct )->m_Label;
while( SLabel )
{
if( SLabel->Type() == DRAW_SHEETLABEL_STRUCT_TYPE )
if( SLabel->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
AddPickedItem( screen, SLabel->m_Pos );
SLabel = (DrawSheetLabelStruct*) SLabel->Pnext;
SLabel = (Hierarchical_PIN_Sheet_Struct*) SLabel->Pnext;
}
}
@ -1611,7 +1611,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
case DRAW_SHEET_STRUCT_TYPE:
break;
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
break;
case DRAW_PICK_ITEM_STRUCT_TYPE:

View File

@ -789,7 +789,7 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
EDA_BaseStruct* item;
LibDrawPin* pin;
SCH_COMPONENT* LibItem = NULL;
DrawSheetLabelStruct* pinsheet;
Hierarchical_PIN_Sheet_Struct* pinsheet;
wxPoint itempos;
switch( layer )

View File

@ -1,14 +1,14 @@
/////////////////////////////////////////////////////////////////////////////
// Name: DrawSheet.cpp
// Purpose: member functions for DrawSheetStruct and DrawSheetLabelStruct
// header = class_screen.h
// Name: class_drawsheet.cpp
// Purpose: member functions for DrawSheetStruct
// header = class_drawsheet.h
// Author: jean-pierre Charras
// Modified by:
// Created: 08/02/2006 18:37:02
// RCS-ID:
// Copyright: License GNU
// Licence:
// Copyright:
// Licence: License GNU
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx/wx.h".
@ -56,11 +56,11 @@ DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) :
DrawSheetStruct::~DrawSheetStruct()
/**************************************/
{
DrawSheetLabelStruct* label = m_Label, * next_label;
Hierarchical_PIN_Sheet_Struct* label = m_Label, * next_label;
while( label )
{
next_label = (DrawSheetLabelStruct*) label->Pnext;
next_label = label->Next();
delete label;
label = next_label;
}
@ -76,82 +76,66 @@ DrawSheetStruct::~DrawSheetStruct()
}
/**********************************************/
bool DrawSheetStruct::Save( FILE *f )
bool DrawSheetStruct::Save( FILE* f ) const
/***********************************************/
/* Routine utilisee dans la routine precedente.
Assure la sauvegarde de la structure LibItemStruct
*/
* Assure la sauvegarde de la structure LibItemStruct
*/
{
int ii;
bool Failed = FALSE;
DrawSheetLabelStruct * SheetLabel;
bool Success = true;
Hierarchical_PIN_Sheet_Struct* SheetLabel;
fprintf(f, "$Sheet\n");
fprintf( f, "$Sheet\n" );
if (fprintf(f, "S %-4d %-4d %-4d %-4d\n",
m_Pos.x,m_Pos.y,
m_Size.x,m_Size.y) == EOF){
Failed = TRUE; return(Failed);
if( fprintf( f, "S %-4d %-4d %-4d %-4d\n",
m_Pos.x, m_Pos.y,
m_Size.x, m_Size.y ) == EOF )
{
Success = false;
return Success;
}
//save the unique timestamp, like other shematic parts.
if( fprintf(f, "U %8.8lX\n", m_TimeStamp) == EOF ){
Failed = TRUE; return(Failed);
if( fprintf( f, "U %8.8lX\n", m_TimeStamp ) == EOF )
{
Success = false; return Success;
}
/* Generation de la liste des 2 textes (sheetname et filename) */
if ( ! m_SheetName.IsEmpty())
if( !m_SheetName.IsEmpty() )
{
if(fprintf(f,"F0 \"%s\" %d\n", CONV_TO_UTF8(m_SheetName), m_SheetNameSize) == EOF)
if( fprintf( f, "F0 \"%s\" %d\n", CONV_TO_UTF8( m_SheetName ), m_SheetNameSize ) == EOF )
{
Failed = TRUE; return(Failed);
Success = false; return Success;
}
}
if( ! GetFileName().IsEmpty())
if( !m_FileName.IsEmpty() )
{
if(fprintf(f,"F1 \"%s\" %d\n", CONV_TO_UTF8(GetFileName()), m_FileNameSize) == EOF)
if( fprintf( f, "F1 \"%s\" %d\n", CONV_TO_UTF8( m_FileName ), m_FileNameSize ) == EOF )
{
Failed = TRUE; return(Failed);
Success = false; return Success;
}
}
/* Generation de la liste des labels (entrees) de la sous feuille */
ii = 2;
SheetLabel = m_Label;
int l_id = 2;
while( SheetLabel != NULL )
{
int type = 'U', side = 'L';
if( SheetLabel->m_Text.IsEmpty() ) continue;
if( SheetLabel->m_Edge ) side = 'R';
switch(SheetLabel->m_Shape)
{
case NET_INPUT: type = 'I'; break;
case NET_OUTPUT: type = 'O'; break;
case NET_BIDI: type = 'B'; break;
case NET_TRISTATE: type = 'T'; break;
case NET_UNSPECIFIED: type = 'U'; break;
}
if(fprintf(f,"F%d \"%s\" %c %c %-3d %-3d %-3d\n", ii,
CONV_TO_UTF8(SheetLabel->m_Text), type, side,
SheetLabel->m_Pos.x, SheetLabel->m_Pos.y,
SheetLabel->m_Size.x) == EOF)
{
Failed = TRUE; break;
}
ii++;
SheetLabel = (DrawSheetLabelStruct*)SheetLabel->Pnext;
SheetLabel->m_Number = l_id;
SheetLabel->Save( f );
l_id++;
SheetLabel = SheetLabel->Next();
}
fprintf(f, "$EndSheet\n");
return(Failed);
fprintf( f, "$EndSheet\n" );
return Success;
}
/***********************************************/
DrawSheetStruct* DrawSheetStruct::GenCopy()
/***********************************************/
@ -174,7 +158,7 @@ DrawSheetStruct* DrawSheetStruct::GenCopy()
newitem->m_Label = NULL;
DrawSheetLabelStruct* Slabel = NULL, * label = m_Label;
Hierarchical_PIN_Sheet_Struct* Slabel = NULL, * label = m_Label;
if( label )
{
@ -186,7 +170,7 @@ DrawSheetStruct* DrawSheetStruct::GenCopy()
while( label )
{
Slabel->Pnext = label->GenCopy();
Slabel = (DrawSheetLabelStruct*) Slabel->Pnext;
Slabel = (Hierarchical_PIN_Sheet_Struct*) Slabel->Pnext;
Slabel->m_Parent = newitem;
label = label->Next();
}
@ -217,19 +201,19 @@ void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem )
EXCHG( m_NbLabel, copyitem->m_NbLabel );
// Ensure sheet labels have their .m_Parent member poiuntin really on their parent, after swapping.
DrawSheetLabelStruct * label = m_Label;
Hierarchical_PIN_Sheet_Struct* label = m_Label;
while( label )
{
label->m_Parent = this;
label = label->Next();
}
label = copyitem->m_Label;
while( label )
{
label->m_Parent = copyitem;
label = label->Next();
}
}
@ -263,7 +247,7 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC )
* if DC != NULL, redraw Sheet
*/
{
DrawSheetLabelStruct* Pinsheet, * NextPinsheet;
Hierarchical_PIN_Sheet_Struct* Pinsheet, * NextPinsheet;
if( !IsOK( frame, _( "Ok to cleanup this sheet" ) ) )
return;
@ -273,8 +257,8 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC )
{
/* Search Hlabel corresponding to this Pinsheet */
EDA_BaseStruct* DrawStruct = m_AssociatedScreen->EEDrawList;
SCH_HIERLABEL* HLabel = NULL;
EDA_BaseStruct* DrawStruct = m_AssociatedScreen->EEDrawList;
SCH_HIERLABEL* HLabel = NULL;
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext )
{
if( DrawStruct->Type() != TYPE_SCH_HIERLABEL )
@ -285,7 +269,7 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC )
HLabel = NULL;
}
NextPinsheet = (DrawSheetLabelStruct*) Pinsheet->Pnext;
NextPinsheet = Pinsheet->Next();
if( HLabel == NULL ) // Hlabel not found: delete pinsheet
{
frame->GetScreen()->SetModify();
@ -302,7 +286,7 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& of
/**************************************************************************************/
/* Draw the hierarchical sheet shape */
{
DrawSheetLabelStruct* SheetLabelStruct;
Hierarchical_PIN_Sheet_Struct* SheetLabelStruct;
int txtcolor;
wxString Text;
int color;
@ -316,7 +300,7 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& of
GRSetDrawMode( DC, DrawMode );
GRRect( &panel->m_ClipBox, DC, pos.x, pos.y,
pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color );
pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color );
/* Draw text : SheetName */
if( Color > 0 )
@ -326,9 +310,9 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& of
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 );
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 )
@ -337,37 +321,44 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& of
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 );
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 )
{
if ( !(SheetLabelStruct->m_Flags & IS_MOVED) )
if( !(SheetLabelStruct->m_Flags & IS_MOVED) )
SheetLabelStruct->Draw( panel, DC, offset, DrawMode, Color );
SheetLabelStruct = (DrawSheetLabelStruct*) (SheetLabelStruct->Pnext);
SheetLabelStruct = SheetLabelStruct->Next();
}
}
EDA_Rect DrawSheetStruct::GetBoundingBox(){
int dx, dy;
// Determine length of texts
wxString Text1 = wxT( "Sheet: " ) + m_SheetName;
wxString Text2 = wxT( "File: " ) + m_FileName;
int textlen1 = 10 * Text1.Len() * m_SheetNameSize / 9;
int textlen2 = 10 * Text2.Len() * m_FileNameSize / 9;
textlen1 = MAX(textlen1, textlen2);
dx = MAX(m_Size.x, textlen1 );
dy = m_Size.y+m_SheetNameSize+m_FileNameSize+16;
EDA_Rect box(wxPoint(m_Pos.x,m_Pos.y-m_SheetNameSize-8), wxSize(dx,dy) );
/*****************************************/
EDA_Rect DrawSheetStruct::GetBoundingBox()
/*****************************************/
{
int dx, dy;
// Determine length of texts
wxString Text1 = wxT( "Sheet: " ) + m_SheetName;
wxString Text2 = wxT( "File: " ) + m_FileName;
int textlen1 = 10 * Text1.Len() * m_SheetNameSize / 9;
int textlen2 = 10 * Text2.Len() * m_FileNameSize / 9;
textlen1 = MAX( textlen1, textlen2 );
dx = MAX( m_Size.x, textlen1 );
dy = m_Size.y + m_SheetNameSize + m_FileNameSize + 16;
EDA_Rect box( wxPoint( m_Pos.x, m_Pos.y - m_SheetNameSize - 8 ), wxSize( dx, dy ) );
return box;
}
/**************************************************************************************/
void DrawSheetStruct::DeleteAnnotation( bool recurse )
/**************************************************************************************/
@ -440,8 +431,8 @@ bool DrawSheetStruct::SearchHierarchy( wxString filename, SCH_SCREEN** screen )
if( strct->Type() == DRAW_SHEET_STRUCT_TYPE )
{
DrawSheetStruct* ss = (DrawSheetStruct*) strct;
if( ss->m_AssociatedScreen &&
ss->m_AssociatedScreen->m_FileName.CmpNoCase( filename ) == 0 )
if( ss->m_AssociatedScreen
&& ss->m_AssociatedScreen->m_FileName.CmpNoCase( filename ) == 0 )
{
*screen = ss->m_AssociatedScreen;
return true;
@ -575,36 +566,35 @@ void DrawSheetStruct::SetFileName( const wxString& aFilename )
* - if new filename is already used (a complex hierarchy) : reference the sheet.
*/
bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame * aFrame, const wxString& aFileName )
bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame, const wxString& aFileName )
{
if( (GetFileName() == aFileName) && m_AssociatedScreen )
return true;
SCH_SCREEN* Screen_to_use = NULL;
wxString msg;
bool LoadFromFile = false;
wxString msg;
bool LoadFromFile = false;
if( g_RootSheet->SearchHierarchy( aFileName, &Screen_to_use ) ) //do we reload the data from the existing hierarchy
{
if(m_AssociatedScreen) //upon initial load, this will be null.
{
msg.Printf( _(
"A Sub Hierarchy named %s exists, Use it (The data in this sheet will be replaced)?" ),
aFileName.GetData() );
if( ! IsOK( NULL, msg ) )
{
DisplayInfo(NULL, _("Sheet Filename Renaming Aborted"));
return false;
}
}
if( m_AssociatedScreen ) //upon initial load, this will be null.
{
msg.Printf( _(
"A Sub Hierarchy named %s exists, Use it (The data in this sheet will be replaced)?" ),
aFileName.GetData() );
if( !IsOK( NULL, msg ) )
{
DisplayInfo( NULL, _( "Sheet Filename Renaming Aborted" ) );
return false;
}
}
}
else if( wxFileExists( aFileName ) ) //do we reload the data from an existing file
{
msg.Printf( _(
"A file named %s exists, load it (otherwise keep current sheet data if possible)?" ),
aFileName.GetData() );
"A file named %s exists, load it (otherwise keep current sheet data if possible)?" ),
aFileName.GetData() );
if( IsOK( NULL, msg ) )
{
LoadFromFile = true;
@ -616,11 +606,12 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame * aFrame, const wxSt
}
// if an associated screen exists, shared between this sheet and others sheets, what we do ?
if( m_AssociatedScreen && ( m_AssociatedScreen->m_RefCount > 1 ))
if( m_AssociatedScreen && ( m_AssociatedScreen->m_RefCount > 1 ) )
{
msg = _("This sheet uses shared data in a complex hierarchy" ) ;
msg << wxT("\n");
msg << _("Do we convert it in a simple hierarchical sheet (otherwise delete current sheet data)");
msg = _( "This sheet uses shared data in a complex hierarchy" );
msg << wxT( "\n" );
msg << _(
"Do we convert it in a simple hierarchical sheet (otherwise delete current sheet data)" );
if( IsOK( NULL, msg ) )
{
LoadFromFile = true;
@ -629,8 +620,8 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame * aFrame, const wxSt
aFrame->SaveEEFile( m_AssociatedScreen, FILE_SAVE_AS );
m_AssociatedScreen->m_FileName = oldfilename;
}
m_AssociatedScreen->m_RefCount--; //be careful with these
m_AssociatedScreen = NULL; //will be created later
m_AssociatedScreen->m_RefCount--; //be careful with these
m_AssociatedScreen = NULL; //will be created later
}
@ -645,9 +636,9 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame * aFrame, const wxSt
m_AssociatedScreen = NULL; //so that we reload..
}
if ( LoadFromFile )
if( LoadFromFile )
Load( aFrame );
else if ( Screen_to_use )
else if( Screen_to_use )
{
m_AssociatedScreen = Screen_to_use;
m_AssociatedScreen->m_RefCount++;
@ -666,129 +657,6 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame * aFrame, const wxSt
}
/************************/
/* DrawSheetLabelStruct */
/************************/
/*******************************************************************/
DrawSheetLabelStruct::DrawSheetLabelStruct( DrawSheetStruct* parent,
const wxPoint& pos, const wxString& text ) :
SCH_ITEM( NULL, DRAW_SHEETLABEL_STRUCT_TYPE )
, EDA_TextStruct( text )
/*******************************************************************/
{
m_Layer = LAYER_SHEETLABEL;
m_Pos = pos;
m_Edge = 0;
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
}
/***********************************************************/
DrawSheetLabelStruct* DrawSheetLabelStruct::GenCopy()
/***********************************************************/
{
DrawSheetLabelStruct* newitem =
new DrawSheetLabelStruct( (DrawSheetStruct*) m_Parent, m_Pos, m_Text );
newitem->m_Edge = m_Edge;
newitem->m_Shape = m_Shape;
return newitem;
}
/********************************************************************************************/
void DrawSheetLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int DrawMode, int Color )
/********************************************************************************************/
/* Routine de dessin des Labels type hierarchie */
{
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 */
}
/**********************************************/
/* class to handle a series of sheets *********/

View File

@ -14,33 +14,43 @@
extern DrawSheetStruct* g_RootSheet;
class DrawSheetLabelStruct : public SCH_ITEM,
class Hierarchical_PIN_Sheet_Struct : public SCH_ITEM,
public EDA_TextStruct
{
public:
int m_Edge, m_Shape;
bool m_IsDangling; // TRUE non connected
int m_Number; // used to numbered labels when writing data on file . m_Number >= 2
// value 0 is for sheet name and 1 for sheet filename
public:
DrawSheetLabelStruct( DrawSheetStruct* parent,
Hierarchical_PIN_Sheet_Struct( DrawSheetStruct* parent,
const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
~DrawSheetLabelStruct() { }
~Hierarchical_PIN_Sheet_Struct() { }
virtual wxString GetClass() const
{
return wxT( "DrawSheetLabelStruct" );
return wxT( "Hierarchical_PIN_Sheet_Struct" );
}
DrawSheetLabelStruct* GenCopy();
Hierarchical_PIN_Sheet_Struct* GenCopy();
DrawSheetLabelStruct* Next()
{ return (DrawSheetLabelStruct*) Pnext; }
Hierarchical_PIN_Sheet_Struct* Next()
{ return (Hierarchical_PIN_Sheet_Struct*) Pnext; }
void Place( WinEDA_DrawFrame* frame, wxDC* DC );
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
};
@ -65,7 +75,7 @@ public:
wxPoint m_Pos;
wxSize m_Size; /* Position and Size of sheet symbol */
int m_Layer;
DrawSheetLabelStruct* m_Label; /* Points de connection, linked list.*/
Hierarchical_PIN_Sheet_Struct* m_Label; /* Points de connection, linked list.*/
int m_NbLabel; /* Nombre de points de connexion */
SCH_SCREEN* m_AssociatedScreen; /* Associated Screen which handle the physical data
* In complex hierarchies we can have many DrawSheetStruct using the same data
@ -81,12 +91,13 @@ public:
return wxT( "DrawSheetStruct" );
}
/** Function Save
* Write on file a DrawSheetStruct description
* @param f = output file
* return an error: false if ok, true if error
*/
bool Save( FILE *f );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
void Place( WinEDA_DrawFrame* frame, wxDC* DC );
DrawSheetStruct* GenCopy();

View File

@ -0,0 +1,201 @@
/////////////////////////////////////////////////////////////////////////////
// Name: class_hierarchical_PIN_sheet.cpp
// Purpose: member functions Hierarchical_PIN_Sheet_Struct
// header = class_drawsheet.h
// Author: jean-pierre Charras
// Modified by:
// Created: 08/02/2006 18:37:02
// RCS-ID:
// Copyright: License GNU
// Licence:
/////////////////////////////////////////////////////////////////////////////
// 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"
#include "protos.h"
/*******************************************************************/
Hierarchical_PIN_Sheet_Struct::Hierarchical_PIN_Sheet_Struct( DrawSheetStruct* parent,
const wxPoint& pos, const wxString& text ) :
SCH_ITEM( NULL, DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ),
EDA_TextStruct( text )
/*******************************************************************/
{
m_Layer = LAYER_SHEETLABEL;
m_Pos = pos;
m_Edge = 0;
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
m_Number = 2;
}
/***********************************************************/
Hierarchical_PIN_Sheet_Struct* Hierarchical_PIN_Sheet_Struct::GenCopy()
/***********************************************************/
{
Hierarchical_PIN_Sheet_Struct* newitem =
new Hierarchical_PIN_Sheet_Struct( (DrawSheetStruct*) m_Parent, m_Pos, m_Text );
newitem->m_Edge = m_Edge;
newitem->m_Shape = m_Shape;
newitem->m_Number = m_Number;
return newitem;
}
/********************************************************************************************/
void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int DrawMode, int Color )
/********************************************************************************************/
/* Routine de dessin des Labels type hierarchie */
{
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 */
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Hierarchical_PIN_Sheet_Struct::Save( FILE* aFile ) const
{
int type = 'U', side = 'L';
if( m_Text.IsEmpty() )
return true;
if( m_Edge )
side = 'R';
switch( m_Shape )
{
case NET_INPUT:
type = 'I'; break;
case NET_OUTPUT:
type = 'O'; break;
case NET_BIDI:
type = 'B'; break;
case NET_TRISTATE:
type = 'T'; break;
case NET_UNSPECIFIED:
type = 'U'; break;
}
if( fprintf( aFile, "F%d \"%s\" %c %c %-3d %-3d %-3d\n", m_Number,
CONV_TO_UTF8( m_Text ), type, side,
m_Pos.x, m_Pos.y,
m_Size.x ) == EOF )
{
return false;
}
return true;
}

View File

@ -13,6 +13,10 @@
#include "protos.h"
/****************************/
/* class DrawBusEntryStruct */
/***************************/
/*******************************************************************/
DrawBusEntryStruct::DrawBusEntryStruct( const wxPoint& pos, int shape, int id ) :
@ -37,7 +41,7 @@ DrawBusEntryStruct::DrawBusEntryStruct( const wxPoint& pos, int shape, int id )
/*************************************/
wxPoint DrawBusEntryStruct::m_End()
wxPoint DrawBusEntryStruct::m_End() const
/*************************************/
// retourne la coord de fin du raccord
@ -61,6 +65,39 @@ DrawBusEntryStruct* DrawBusEntryStruct::GenCopy()
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool DrawBusEntryStruct::Save( FILE* aFile ) const
{
bool success = true;
const char* layer = "Wire";
const char* width = "Line";
if( GetLayer() == LAYER_BUS )
{
layer = "Bus"; width = "Bus";
}
if( fprintf( aFile, "Entry %s %s\n", layer, width ) == EOF )
{
success = false;
}
if( fprintf( aFile, "\t%-4d %-4d %-4d %-4d\n",
m_Pos.x, m_Pos.y,
m_End().x, m_End().y ) == EOF )
{
success = false;
}
return success;
}
/****************************/
/* class DrawJunctionStruct */
/***************************/
@ -86,6 +123,37 @@ DrawJunctionStruct* DrawJunctionStruct::GenCopy()
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool DrawJunctionStruct::Save( FILE* aFile ) const
{
bool success = true;
if( fprintf( aFile, "Connection ~ %-4d %-4d\n", m_Pos.x, m_Pos.y ) == EOF )
{
success = false;
}
return success;
}
EDA_Rect DrawJunctionStruct::GetBoundingBox()
{
int width = DRAWJUNCTION_SIZE * 2;
int xmin = m_Pos.x - DRAWJUNCTION_SIZE;
int ymin = m_Pos.y - DRAWJUNCTION_SIZE;
EDA_Rect ret( wxPoint( xmin, ymin ), wxSize( width, width ) );
return ret;
};
/*****************************/
/* class DrawNoConnectStruct */
/*****************************/
@ -107,6 +175,25 @@ DrawNoConnectStruct* DrawNoConnectStruct::GenCopy()
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool DrawNoConnectStruct::Save( FILE* aFile ) const
{
bool success = true;
if( fprintf( aFile, "NoConn ~ %-4d %-4d\n", m_Pos.x, m_Pos.y ) == EOF )
{
success = false;
}
return success;
}
/**************************/
/* class DrawMarkerStruct */
/**************************/
@ -143,7 +230,8 @@ wxString DrawMarkerStruct::GetComment()
}
#if defined(DEBUG)
#if defined (DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
@ -154,11 +242,36 @@ wxString DrawMarkerStruct::GetComment()
void DrawMarkerStruct::Show( int nestLevel, std::ostream& os )
{
// for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << m_Pos
<< "/>\n";
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << m_Pos
<< "/>\n";
}
#endif
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool DrawMarkerStruct::Save( FILE* aFile ) const
{
bool success = true;
wxString msg;
if( fprintf( aFile, "Kmarq %c %-4d %-4d \"%s\" F=%X\n",
m_Type + 'A',
m_Pos.x, m_Pos.y,
CONV_TO_UTF8( m_Comment ), m_MarkFlags ) == EOF )
{
success = false;
}
return success;
}
/***************************/
/* Class EDA_DrawLineStruct */
@ -218,7 +331,8 @@ bool EDA_DrawLineStruct::IsOneEndPointAt( const wxPoint& pos )
}
#if defined(DEBUG)
#if defined (DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
@ -229,65 +343,70 @@ bool EDA_DrawLineStruct::IsOneEndPointAt( const wxPoint& pos )
void EDA_DrawLineStruct::Show( int nestLevel, std::ostream& os )
{
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
" layer=\"" << m_Layer << '"' <<
" width=\"" << m_Width << '"' <<
" startIsDangling=\"" << m_StartIsDangling << '"' <<
" endIsDangling=\"" << m_EndIsDangling << '"' << ">" <<
" <start" << m_Start << "/>" <<
" <end" << m_End << "/>" <<
"</" << GetClass().Lower().mb_str() << ">\n";
" layer=\"" << m_Layer << '"' <<
" width=\"" << m_Width << '"' <<
" startIsDangling=\"" << m_StartIsDangling << '"' <<
" endIsDangling=\"" << m_EndIsDangling << '"' << ">" <<
" <start" << m_Start << "/>" <<
" <end" << m_End << "/>" <<
"</" << GetClass().Lower().mb_str() << ">\n";
}
#endif
#endif
EDA_Rect EDA_DrawLineStruct::GetBoundingBox()
{
int width = 25;
int width = 25;
int xmin = MIN( m_Start.x, m_End.x ) - width;
int ymin = MIN( m_Start.y, m_End.y ) - width;
int xmin = MIN( m_Start.x, m_End.x ) - width;
int ymin = MIN( m_Start.y, m_End.y ) - width;
int xmax = MAX( m_Start.x, m_End.x ) + width;
int ymax = MAX( m_Start.y, m_End.y ) + width;
int xmax = MAX( m_Start.x, m_End.x ) + width;
int ymax = MAX( m_Start.y, m_End.y ) + width;
// return a rectangle which is [pos,dim) in nature. therefore the +1
EDA_Rect ret( wxPoint( xmin, ymin ), wxSize( xmax-xmin+1, ymax-ymin+1 ) );
EDA_Rect ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
return ret;
}
EDA_Rect DrawJunctionStruct::GetBoundingBox()
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool EDA_DrawLineStruct::Save( FILE* aFile ) const
{
int width = DRAWJUNCTION_SIZE * 2;
int xmin = m_Pos.x - DRAWJUNCTION_SIZE ;
int ymin = m_Pos.y - DRAWJUNCTION_SIZE;
bool success = true;
EDA_Rect ret( wxPoint( xmin, ymin ), wxSize( width, width ) );
const char* layer = "Notes";
const char* width = "Line";
return ret;
};
EDA_Rect SCH_COMPONENT::GetBoundingBox()
{
const int PADDING = 40;
// This gives a reasonable approximation (but some things are missing so...
EDA_Rect ret = GetBoundaryBox();
// Include BoundingBoxes of fields
for( int i = REFERENCE; i < NUMBER_OF_FIELDS; i++ )
if( GetLayer() == LAYER_WIRE )
layer = "Wire";
if( GetLayer() == LAYER_BUS )
layer = "Bus";
if( m_Width != GR_NORM_WIDTH )
layer = "Bus";
if( fprintf( aFile, "Wire %s %s\n", layer, width ) == EOF )
{
ret.Merge( m_Field[i].GetBoundaryBox() );
success = false;
}
if (fprintf( aFile, "\t%-4d %-4d %-4d %-4d\n",
m_Start.x,m_Start.y,
m_End.x,m_End.y) == EOF)
{
success = false;
}
// ... add padding
ret.Inflate(PADDING, PADDING);
return ret;
return success;
}
/****************************/
/* Class DrawPolylineStruct */
/****************************/
@ -345,3 +464,43 @@ DrawPolylineStruct* DrawPolylineStruct::GenCopy()
return newitem;
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool DrawPolylineStruct::Save( FILE* aFile ) const
{
bool success = true;
const char* layer = "Notes";
const char* width = "Line";
if( GetLayer() == LAYER_WIRE )
layer = "Wire";
if( GetLayer() == LAYER_BUS )
layer = "Bus";
if( m_Width != GR_NORM_WIDTH )
width = "Bus";
if( fprintf( aFile, "Poly %s %s %d\n",
width, layer, m_NumOfPoints ) == EOF )
{
success = false;
return success;
}
for( int ii = 0; ii < m_NumOfPoints; ii++ )
{
if( fprintf( aFile, "\t%-4d %-4d\n",
m_Points[ii * 2],
m_Points[ii * 2 + 1] ) == EOF )
{
success = false;
break;
}
}
return success;
}

View File

@ -31,7 +31,7 @@ void SetStructFather( EDA_BaseStruct* Struct, BASE_SCREEN* Screen )
Struct->m_Parent = Screen;
break;
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;

View File

@ -47,6 +47,13 @@ public:
virtual void ClearUndoRedoList();
virtual void AddItemToUndoList( EDA_BaseStruct* item );
virtual void AddItemToRedoList( EDA_BaseStruct* item );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
};

View File

@ -115,40 +115,6 @@ void SCH_TEXT::Place( WinEDA_DrawFrame* frame, wxDC* DC )
SCH_ITEM::Place( frame, DC );
}
/****************************************************************************/
SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_LABEL )
/****************************************************************************/
{
m_Layer = LAYER_LOCLABEL;
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
}
/***********************************************************************************/
SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_GLOBALLABEL )
/***********************************************************************************/
{
m_Layer = LAYER_GLOBLABEL;
m_Shape = NET_BIDI;
m_IsDangling = TRUE;
}
/***********************************************************************************/
SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_HIERLABEL )
/***********************************************************************************/
{
m_Layer = LAYER_HIERLABEL;
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
}
/*******************************************************************************************/
void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int DrawMode, int Color )
@ -209,6 +175,126 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool SCH_TEXT::Save( FILE* aFile ) const
{
bool success = true;
if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d ~\n%s\n",
m_Pos.x, m_Pos.y,
m_Orient, m_Size.x,
CONV_TO_UTF8( m_Text ) ) == EOF )
{
success = false;
}
return success;
}
/****************************************************************************/
SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_LABEL )
/****************************************************************************/
{
m_Layer = LAYER_LOCLABEL;
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool SCH_LABEL::Save( FILE* aFile ) const
{
bool success = true;
char shape = '~';
if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %c\n%s\n",
m_Pos.x, m_Pos.y,
m_Orient, m_Size.x, shape,
CONV_TO_UTF8( m_Text ) ) == EOF )
{
success = false;
}
return success;
}
/***********************************************************************************/
SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_GLOBALLABEL )
/***********************************************************************************/
{
m_Layer = LAYER_GLOBLABEL;
m_Shape = NET_BIDI;
m_IsDangling = TRUE;
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
{
bool success = true;
if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s\n%s\n",
m_Pos.x, m_Pos.y,
m_Orient, m_Size.x,
SheetLabelType[m_Shape],
CONV_TO_UTF8( m_Text ) ) == EOF )
{
success = false;
}
return success;
}
/***********************************************************************************/
SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_HIERLABEL )
/***********************************************************************************/
{
m_Layer = LAYER_HIERLABEL;
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool SCH_HIERLABEL::Save( FILE* aFile ) const
{
bool success = true;
if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s\n%s\n",
m_Pos.x, m_Pos.y,
m_Orient, m_Size.x,
SheetLabelType[m_Shape],
CONV_TO_UTF8( m_Text ) ) == EOF )
{
success = false;
}
return success;
}
/*********************************************************************************************/
void SCH_LABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int DrawMode, int Color )

View File

@ -103,6 +103,15 @@ public:
virtual void Place( WinEDA_DrawFrame* frame, wxDC* DC );
EDA_Rect GetBoundingBox();
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
};
@ -118,6 +127,14 @@ public:
{
return wxT( "SCH_LABEL" );
}
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
};
@ -145,6 +162,14 @@ public:
*/
void CreateGraphicShape( int* corner_list, const wxPoint & Pos );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
EDA_Rect GetBoundingBox();
};
@ -174,6 +199,14 @@ public:
*/
void CreateGraphicShape( int* corner_list, const wxPoint & Pos );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
EDA_Rect GetBoundingBox();
};

View File

@ -113,7 +113,7 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen )
case DRAW_MARKER_STRUCT_TYPE:
case TYPE_SCH_TEXT:
case DRAW_SHEET_STRUCT_TYPE:
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
break;
default:

View File

@ -1,5 +1,5 @@
/***********************************************************************/
/* Methodes de base de gestion des classes des elements de schematique */
/* component_class.cpp : handle the class SCH_COMPONENT */
/***********************************************************************/
#include "fctsys.h"
@ -17,6 +17,7 @@
#include "macros.h"
#include <wx/arrimpl.cpp>
#include <wx/tokenzr.h>
WX_DEFINE_OBJARRAY( ArrayOfSheetLists );
@ -31,8 +32,27 @@ WX_DEFINE_OBJARRAY( ArrayOfSheetLists );
*/
void SCH_COMPONENT::AddHierarchicalReference( const wxString& path, const wxString& ref )
{
m_Paths.Add( path );
m_References.Add( ref );
wxString h_path, h_ref;
wxStringTokenizer tokenizer;
wxString separators( wxT( " " ) );
// Search for an existing path and remove it if found (should not occur)
for( unsigned ii = 0; ii<m_PathsAndReferences.GetCount(); ii++ )
{
tokenizer.SetString( m_PathsAndReferences[ii], separators );
h_path = tokenizer.GetNextToken();
if( h_path.Cmp( path ) == 0 )
{
m_PathsAndReferences.RemoveAt(ii);
ii --;
}
}
h_ref = path + wxT( " " ) + ref;
h_ref << wxT( " " ) << m_Multi;
m_PathsAndReferences.Add( h_ref );
}
@ -100,17 +120,21 @@ wxString SCH_COMPONENT::GetPath( DrawSheetPath* sheet )
const wxString SCH_COMPONENT::GetRef( DrawSheetPath* sheet )
/********************************************************************/
{
wxString path = GetPath( sheet );
unsigned int i;
wxString path = GetPath( sheet );
wxString h_path, h_ref;
wxStringTokenizer tokenizer;
wxString separators( wxT( " " ) );
for( i = 0; i<m_Paths.GetCount(); i++ )
for( unsigned ii = 0; ii<m_PathsAndReferences.GetCount(); ii++ )
{
if( m_Paths[i].Cmp( path ) == 0 )
tokenizer.SetString( m_PathsAndReferences[ii], separators );
h_path = tokenizer.GetNextToken();
if( h_path.Cmp( path ) == 0 )
{
/*printf("GetRef path: %s ref: %s\n",
* CONV_TO_UTF8(m_Paths[i]),
* CONV_TO_UTF8(m_References[i])); */
return m_References[i];
h_ref = tokenizer.GetNextToken();
//printf("GetRef hpath: %s\n",CONV_TO_UTF8(m_PathsAndReferences[ii]));
return h_ref;
}
}
@ -133,25 +157,34 @@ void SCH_COMPONENT::SetRef( DrawSheetPath* sheet, const wxString& ref )
/***********************************************************************/
{
//check to see if it is already there before inserting it
wxString path = GetPath( sheet );
wxString path = GetPath( sheet );
// printf( "SetRef path: %s ref: %s\n", CONV_TO_UTF8( path ), CONV_TO_UTF8( ref ) ); // Debug
unsigned int i;
bool notInArray = true;
bool notInArray = true;
for( i = 0; i<m_Paths.GetCount(); i++ )
wxString h_path, h_ref;
wxStringTokenizer tokenizer;
wxString separators( wxT( " " ) );
for( unsigned ii = 0; ii<m_PathsAndReferences.GetCount(); ii++ )
{
if( m_Paths[i].Cmp( path ) == 0 )
tokenizer.SetString( m_PathsAndReferences[ii], separators );
h_path = tokenizer.GetNextToken();
if( h_path.Cmp( path ) == 0 )
{
//just update the reference text, not the timestamp.
m_References.RemoveAt( i );
m_References.Insert( ref, i );
h_ref = h_path + wxT( " " ) + ref;
h_ref += wxT( " " );
tokenizer.GetNextToken(); // Skip old reference
h_ref += tokenizer.GetNextToken(); // Add part selection
// Ann the part selection
m_PathsAndReferences[ii] = h_ref;
notInArray = false;
}
}
if( notInArray )
AddHierarchicalReference(path, ref);
AddHierarchicalReference( path, ref );
if( m_Field[REFERENCE].m_Text.IsEmpty()
|| ( abs( m_Field[REFERENCE].m_Pos.x - m_Pos.x ) +
@ -204,14 +237,14 @@ SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos ) :
/* initialisation des Fields */
for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ )
{
m_Field[ii].m_Pos = m_Pos;
m_Field[ii].SetLayer(LAYER_FIELDS);
m_Field[ii].m_Pos = m_Pos;
m_Field[ii].SetLayer( LAYER_FIELDS );
m_Field[ii].m_FieldId = REFERENCE + ii;
m_Field[ii].m_Parent = this;
}
m_Field[VALUE].SetLayer(LAYER_VALUEPART);
m_Field[REFERENCE].SetLayer(LAYER_REFERENCEPART);
m_Field[VALUE].SetLayer( LAYER_VALUEPART );
m_Field[REFERENCE].SetLayer( LAYER_REFERENCEPART );
m_PrefixString = wxString( _( "U" ) );
}
@ -347,27 +380,35 @@ void SCH_COMPONENT::ClearAnnotation()
/* Suppress annotation ( i.i IC23 changed to IC? and part reset to 1)
*/
{
wxString defRef = m_PrefixString;
wxString defRef = m_PrefixString;
bool KeepMulti = false;
EDA_LibComponentStruct* Entry;
Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
if( Entry && Entry->m_UnitSelectionLocked )
KeepMulti = true;
while( defRef.Last() == '?' )
defRef.RemoveLast();
defRef.Append( wxT( "?" ) );
m_References.Empty();
unsigned int i;
for( i = 0; i< m_Paths.GetCount(); i++ )
wxString multi = wxT( "1" );
wxString NewHref;
for( unsigned int ii = 0; ii< m_PathsAndReferences.GetCount(); ii++ )
{
m_References.Add( defRef );
if( KeepMulti ) // Get and keep part selection
multi = m_PathsAndReferences[ii].AfterLast( wxChar( ' ' ) );
NewHref = m_PathsAndReferences[ii].BeforeFirst( wxChar( ' ' ) );
NewHref << wxT( " " ) << defRef << wxT( " " ) << multi;
m_PathsAndReferences[ii] = NewHref;
}
m_Field[REFERENCE].m_Text = defRef; //for drawing.
EDA_LibComponentStruct* Entry;
Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
if( !Entry || !Entry->m_UnitSelectionLocked )
{
if( !KeepMulti )
m_Multi = 1;
}
}
@ -618,7 +659,7 @@ wxPoint SCH_COMPONENT::GetScreenCoord( const wxPoint& coord )
/* Renvoie la coordonn<6E>e du point coord, en fonction de l'orientation
* du composant (rotation, miroir).
* Les coord sont toujours relatives <EFBFBD> l'ancre (coord 0,0) du composant
* Les coord sont toujours relatives a l'ancre (coord 0,0) du composant
*/
{
wxPoint screenpos;
@ -674,8 +715,8 @@ PartTextStruct::PartTextStruct( const wxPoint& pos, const wxString& text ) :
EDA_TextStruct( text )
/***************************************************************************/
{
m_Pos = pos;
m_FieldId = 0;
m_Pos = pos;
m_FieldId = 0;
m_AddExtraText = false;
}
@ -829,24 +870,82 @@ EDA_Rect PartTextStruct::GetBoundaryBox() const
}
/**********************************/
bool SCH_COMPONENT::Save( FILE* f )
/**********************************/
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool PartTextStruct::Save( FILE* aFile ) const
{
char hjustify = 'C';
/** Function Save
* Write on file a SCH_COMPONENT decscription
* @param f = output file
* return an error: false if ok, true if error
if( m_HJustify == GR_TEXT_HJUSTIFY_LEFT )
hjustify = 'L';
else if( m_HJustify == GR_TEXT_HJUSTIFY_RIGHT )
hjustify = 'R';
char vjustify = 'C';
if( m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
vjustify = 'B';
else if( m_VJustify == GR_TEXT_VJUSTIFY_TOP )
vjustify = 'T';
if( fprintf( aFile, "F %d \"%s\" %c %-3d %-3d %-3d %4.4X %c %c", m_FieldId,
CONV_TO_UTF8( m_Text ),
m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V',
m_Pos.x, m_Pos.y,
m_Size.x,
m_Attributs,
hjustify, vjustify ) == EOF )
{
return false;
}
// Save field name, if necessary
if( m_FieldId >= FIELD1 && !m_Name.IsEmpty() )
{
wxString fieldname = ReturnDefaultFieldName( m_FieldId );
if( fieldname != m_Name )
{
if( fprintf( aFile, " \"%s\"", CONV_TO_UTF8( m_Name ) ) == EOF )
{
return false;
}
}
}
if( fprintf( aFile, "\n" ) == EOF )
{
return false;
}
return true;
}
/****************************************/
bool SCH_COMPONENT::Save( FILE* f ) const
/****************************************/
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
{
int ii, Failed = FALSE;
char Name1[256], Name2[256];
int hjustify, vjustify;
int ii, Success = true;
char Name1[256], Name2[256];
wxArrayString reference_fields;
static wxString delimiters( wxT( " " ) );
//this is redundant with the AR entries below, but it makes the
//files backwards-compatible.
if( m_References.GetCount() > 0 )
strncpy( Name1, CONV_TO_UTF8( m_References[0] ), sizeof(Name1) );
if( m_PathsAndReferences.GetCount() > 0 )
{
reference_fields = wxStringTokenize( m_PathsAndReferences[0], delimiters );
strncpy( Name1, CONV_TO_UTF8( reference_fields[1] ), sizeof(Name1) );
}
else
{
if( m_Field[REFERENCE].m_Text.IsEmpty() )
@ -874,88 +973,73 @@ bool SCH_COMPONENT::Save( FILE* f )
if( fprintf( f, "L %s %s\n", Name2, Name1 ) == EOF )
{
Failed = TRUE;
return Failed;
Success = false;
return Success;
}
/* Generation de numero d'unit, convert et Time Stamp*/
if( fprintf( f, "U %d %d %8.8lX\n", m_Multi, m_Convert, m_TimeStamp ) == EOF )
{
Failed = TRUE; return Failed;
Success = false;
return Success;
}
/* Sortie de la position */
/* Save the position */
if( fprintf( f, "P %d %d\n", m_Pos.x, m_Pos.y ) == EOF )
{
Failed = TRUE; return Failed;
Success = false;
return Success;
}
unsigned int i;
for( i = 0; i< m_References.GetCount(); i++ )
/* If this is a complex hierarchy; save hierarchical references.
* but for simple hierarchies it is not necessary.
* the reference inf is already saved
* this is usefull for old eeschema version compatibility
*/
if( m_PathsAndReferences.GetCount() > 1 )
{
/*format:
* AR Path="/140/2" Ref="C99"
* where 140 is the uid of the contianing sheet
* and 2 is the timestamp of this component.
* (timestamps are actually 8 hex chars)
* Ref is the conventional component reference for this 'path'
*/
if( fprintf( f, "AR Path=\"%s\" Ref=\"%s\" \n",
CONV_TO_UTF8( m_Paths[i] ),
CONV_TO_UTF8( m_References[i] ) ) == EOF )
for( unsigned int ii = 0; ii< m_PathsAndReferences.GetCount(); ii++ )
{
Failed = TRUE; break;
/*format:
* AR Path="/140/2" Ref="C99" Part="1"
* where 140 is the uid of the containing sheet
* and 2 is the timestamp of this component.
* (timestamps are actually 8 hex chars)
* Ref is the conventional component reference for this 'path'
* Part is the conventional component part selection for this 'path'
*/
reference_fields = wxStringTokenize( m_PathsAndReferences[ii], delimiters );
if( fprintf( f, "AR Path=\"%s\" Ref=\"%s\" Part=\"%s\" \n",
CONV_TO_UTF8( reference_fields[0] ),
CONV_TO_UTF8( reference_fields[1] ),
CONV_TO_UTF8( reference_fields[2] )
) == EOF )
{
Success = false;
return Success;
}
}
}
for( ii = 0; ii < NUMBER_OF_FIELDS; ii++ )
{
PartTextStruct* field = &m_Field[ii];
const PartTextStruct* field = &m_Field[ii];
if( field->m_Text.IsEmpty() )
continue;
hjustify = 'C';
if( field->m_HJustify == GR_TEXT_HJUSTIFY_LEFT )
hjustify = 'L';
else if( field->m_HJustify == GR_TEXT_HJUSTIFY_RIGHT )
hjustify = 'R';
vjustify = 'C';
if( field->m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM )
vjustify = 'B';
else if( field->m_VJustify == GR_TEXT_VJUSTIFY_TOP )
vjustify = 'T';
if( fprintf( f, "F %d \"%s\" %c %-3d %-3d %-3d %4.4X %c %c", ii,
CONV_TO_UTF8( field->m_Text ),
field->m_Orient == TEXT_ORIENT_HORIZ ? 'H' : 'V',
field->m_Pos.x, field->m_Pos.y,
field->m_Size.x,
field->m_Attributs,
hjustify, vjustify ) == EOF )
if( !field->Save( f ) )
{
Failed = TRUE; break;
}
// Save field name, if necessary
if( ii >= FIELD1 && !field->m_Name.IsEmpty() )
{
wxString fieldname = ReturnDefaultFieldName( ii );
if( fieldname != field->m_Name )
if( fprintf( f, " \"%s\"", CONV_TO_UTF8( field->m_Name ) ) == EOF )
{
Failed = TRUE; break;
}
}
if( fprintf( f, "\n" ) == EOF )
{
Failed = TRUE; break;
Success = false; break;
}
}
if( Failed )
return Failed;
if( !Success )
return Success;
/* Generation du num unit, position, box ( ancienne norme )*/
if( fprintf( f, "\t%-4d %-4d %-4d\n", m_Multi, m_Pos.x, m_Pos.y ) == EOF )
{
Failed = TRUE; return Failed;
Success = false;
return Success;
}
if( fprintf( f, "\t%-4d %-4d %-4d %-4d\n",
@ -964,9 +1048,30 @@ bool SCH_COMPONENT::Save( FILE* f )
m_Transform[1][0],
m_Transform[1][1] ) == EOF )
{
Failed = TRUE; return Failed;
Success = false;
return Success;
}
fprintf( f, "$EndComp\n" );
return Failed;
return Success;
}
EDA_Rect SCH_COMPONENT::GetBoundingBox()
{
const int PADDING = 40;
// This gives a reasonable approximation (but some things are missing so...
EDA_Rect ret = GetBoundaryBox();
// Include BoundingBoxes of fields
for( int i = REFERENCE; i < NUMBER_OF_FIELDS; i++ )
{
ret.Merge( m_Field[i].GetBoundaryBox() );
}
// ... add padding
ret.Inflate( PADDING, PADDING );
return ret;
}

View File

@ -41,10 +41,10 @@ class PartTextStruct : public SCH_ITEM,
public EDA_TextStruct
{
public:
int m_FieldId; // Field indicator type (REFERENCE, VALUE or other id)
int m_FieldId; // Field indicator type (REFERENCE, VALUE or other id)
wxString m_Name; /* Field name (ref, value,pcb, sheet, filed 1..
* and for fields 1 to 8 the name is editable */
bool m_AddExtraText; // Mainly for REFERENCE, add extar info (for REFERENCE: add part selection text
bool m_AddExtraText; // Mainly for REFERENCE, add extar info (for REFERENCE: add part selection text
public:
PartTextStruct( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString );
@ -62,14 +62,22 @@ public:
EDA_Rect GetBoundaryBox() const;
bool IsVoid();
void SwapData( PartTextStruct* copyitem );
/**
* Function Draw
*/
void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
*/
void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
};
@ -98,8 +106,16 @@ public:
int m_Transform[2][2]; /* The rotation/mirror transformation matrix. */
private:
wxArrayString m_Paths; // /sheet1/C102, /sh2/sh1/U32 etc.
wxArrayString m_References; // C102, U32 etc.
/* Hierarchical references.
* format is
* path reference multi
* with:
* path = /<timestamp1>/<timestamp2> (subsheet path, = / for the root scheet)
* reference = reference for this path (C23, R5, U78 ... )
* multi = part selection in multi parts per package (0 or 1 for àne part per package)
*/
wxArrayString m_PathsAndReferences;
public:
SCH_COMPONENT( const wxPoint& pos = wxPoint( 0, 0 ) );
@ -110,12 +126,14 @@ public:
return wxT( "SCH_COMPONENT" );
}
/** Function Save
* Write on file a SCH_COMPONENT decscription
* @param f = output file
* return an error: false if ok, true if error
*/
bool Save( FILE *f );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
SCH_COMPONENT* GenCopy();
void SetRotationMiroir( int type );
@ -152,8 +170,8 @@ public:
//returns a unique ID, in the form of a path.
wxString GetPath( DrawSheetPath* sheet );
const wxString GetRef( DrawSheetPath* sheet );
void SetRef( DrawSheetPath* sheet, const wxString & ref );
void AddHierarchicalReference(const wxString & path, const wxString & ref);
void SetRef( DrawSheetPath* sheet, const wxString& ref );
void AddHierarchicalReference( const wxString& path, const wxString& ref );
int GetUnitSelection( DrawSheetPath* aSheet );
void SetUnitSelection( DrawSheetPath* aSheet, int aUnitSelection );

View File

@ -435,7 +435,7 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
{
#undef STRUCT
#define STRUCT ( (DrawSheetStruct*) DrawItem )
DrawSheetLabelStruct* pinsheet = STRUCT->m_Label;
Hierarchical_PIN_Sheet_Struct* pinsheet = STRUCT->m_Label;
while( pinsheet )
{
item = new DanglingEndHandle( SHEET_LABEL_END );
@ -447,7 +447,7 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
else
StartList = item;
lastitem = item;
pinsheet = (DrawSheetLabelStruct*) pinsheet->Pnext;
pinsheet = (Hierarchical_PIN_Sheet_Struct*) pinsheet->Pnext;
}
break;

View File

@ -382,7 +382,7 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
{
EDA_BaseStruct* DrawList;
DrawPickedStruct* PickedList = NULL;
DrawSheetLabelStruct* SheetLabel, * NextLabel;
Hierarchical_PIN_Sheet_Struct* SheetLabel, * NextLabel;
if( DrawStruct == NULL )
return;
@ -392,7 +392,7 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
Screen->SetModify();
if( DrawStruct->Type() == DRAW_SHEETLABEL_STRUCT_TYPE )
if( DrawStruct->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
{
/* Cette stucture est rattachee a une feuille, et n'est pas
* accessible par la liste globale directement */
@ -408,10 +408,10 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
if( SheetLabel == NULL )
continue;
if( SheetLabel == (DrawSheetLabelStruct*) DrawStruct )
if( SheetLabel == (Hierarchical_PIN_Sheet_Struct*) DrawStruct )
{
( (DrawSheetStruct*) DrawList )->m_Label =
(DrawSheetLabelStruct*) SheetLabel->Pnext;
(Hierarchical_PIN_Sheet_Struct*) SheetLabel->Pnext;
SAFE_DELETE( DrawStruct );
return;
@ -420,8 +420,8 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
{
while( SheetLabel->Pnext ) /* Examen de la liste dependante */
{
NextLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext;
if( NextLabel == (DrawSheetLabelStruct*) DrawStruct )
NextLabel = (Hierarchical_PIN_Sheet_Struct*) SheetLabel->Pnext;
if( NextLabel == (Hierarchical_PIN_Sheet_Struct*) DrawStruct )
{
SheetLabel->Pnext = (EDA_BaseStruct*) NextLabel->Pnext;
SAFE_DELETE( DrawStruct );

View File

@ -896,7 +896,7 @@ static int GenListeGLabels( ListLabel* List )
{
int ItemCount = 0;
EDA_BaseStruct* DrawList;
DrawSheetLabelStruct* SheetLabel;
Hierarchical_PIN_Sheet_Struct* SheetLabel;
DrawSheetPath* sheet;
/* Build the screen list */
@ -931,14 +931,14 @@ static int GenListeGLabels( ListLabel* List )
{
if( List )
{
List->m_LabelType = DRAW_SHEETLABEL_STRUCT_TYPE;
List->m_LabelType = DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE;
snprintf( List->m_SheetPath, sizeof(List->m_SheetPath),
"%s", CONV_TO_UTF8( path ) );
List->m_Label = SheetLabel;
List++;
}
ItemCount++;
SheetLabel = (DrawSheetLabelStruct*) (SheetLabel->Pnext);
SheetLabel = (Hierarchical_PIN_Sheet_Struct*) (SheetLabel->Pnext);
}
}
break;
@ -1060,13 +1060,13 @@ static int ListTriGLabelByVal( ListLabel* Objet1, ListLabel* Objet2 )
int ii;
const wxString* Text1, * Text2;
if( Objet1->m_LabelType == DRAW_SHEETLABEL_STRUCT_TYPE )
Text1 = &( (DrawSheetLabelStruct*) Objet1->m_Label )->m_Text;
if( Objet1->m_LabelType == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
Text1 = &( (Hierarchical_PIN_Sheet_Struct*) Objet1->m_Label )->m_Text;
else
Text1 = &( (SCH_TEXT*) Objet1->m_Label )->m_Text;
if( Objet2->m_LabelType == DRAW_SHEETLABEL_STRUCT_TYPE )
Text2 = &( (DrawSheetLabelStruct*) Objet2->m_Label )->m_Text;
if( Objet2->m_LabelType == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
Text2 = &( (Hierarchical_PIN_Sheet_Struct*) Objet2->m_Label )->m_Text;
else
Text2 = &( (SCH_TEXT*) Objet2->m_Label )->m_Text;
@ -1099,13 +1099,13 @@ static int ListTriGLabelBySheet( ListLabel* Objet1, ListLabel* Objet2 )
if( ii == 0 )
{
if( Objet1->m_LabelType == DRAW_SHEETLABEL_STRUCT_TYPE )
Text1 = &( (DrawSheetLabelStruct*) Objet1->m_Label )->m_Text;
if( Objet1->m_LabelType == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
Text1 = &( (Hierarchical_PIN_Sheet_Struct*) Objet1->m_Label )->m_Text;
else
Text1 = &( (SCH_TEXT*) Objet1->m_Label )->m_Text;
if( Objet2->m_LabelType == DRAW_SHEETLABEL_STRUCT_TYPE )
Text2 = &( (DrawSheetLabelStruct*) Objet2->m_Label )->m_Text;
if( Objet2->m_LabelType == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
Text2 = &( (Hierarchical_PIN_Sheet_Struct*) Objet2->m_Label )->m_Text;
else
Text2 = &( (SCH_TEXT*) Objet2->m_Label )->m_Text;
@ -1378,7 +1378,7 @@ static int PrintListeGLabel( FILE* f, ListLabel* List, int NbItems )
{
int ii, jj;
SCH_LABEL* DrawTextItem;
DrawSheetLabelStruct* DrawSheetLabel;
Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
ListLabel* LabelItem;
wxString msg, sheetpath;
wxString labeltype;
@ -1408,9 +1408,9 @@ static int PrintListeGLabel( FILE* f, ListLabel* List, int NbItems )
fprintf( f, CONV_TO_UTF8( msg ) );
break;
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
{
DrawSheetLabel = (DrawSheetLabelStruct*) LabelItem->m_Label;
DrawSheetLabel = (Hierarchical_PIN_Sheet_Struct*) LabelItem->m_Label;
jj = DrawSheetLabel->m_Shape;
if( jj < 0 )
jj = NET_TMAX;

View File

@ -1,30 +0,0 @@
/************************************************/
/* Routines diverses */
/************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
/**************************************/
void SetFlagModify(BASE_SCREEN * Window)
/**************************************/
/* Mise a 1 du flag modified de l'ecran Window, et de la date de la feuille
*/
{
if( Window == NULL ) return;
Window->SetModify();
/* Mise a jour des dates */
Window->m_Date = GenDate();
}

View File

@ -477,7 +477,7 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
EDA_BaseStruct* item;
LibDrawPin* pin;
DrawLibItemStruct* LibItem = NULL;
DrawSheetLabelStruct* pinsheet;
Hierarchical_PIN_Sheet_Struct* pinsheet;
wxPoint itempos;
switch( layer )

View File

View File

@ -524,7 +524,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
break;
}
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE:
break;

View File

@ -126,11 +126,14 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
MsgDiag = FullFileName + _( " was created by a more recent version of EESchema and may not load correctly. Please consider updating!");
DisplayInfo( this, MsgDiag);
}
#if 0
// Compile it if the new versiopn is unreadable by previous eeschema versions
else if ( ver < EESCHEMA_VERSION )
{
MsgDiag = FullFileName + _( " was created by an older version of EESchema. It will be stored in the new file format when you save this file again.");
DisplayInfo( this, MsgDiag);
}
#endif
LineCount++;
if( fgets( Line, 1024 - 1, f ) == NULL || strncmp( Line, "LIBS:", 5 ) != 0 )
@ -792,7 +795,7 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi
int ii, fieldref, size;
char Name1[256], Char1[256], Char2[256];
DrawSheetStruct* SheetStruct;
DrawSheetLabelStruct* SheetLabelStruct, * OldSheetLabel = NULL;
Hierarchical_PIN_Sheet_Struct* SheetLabelStruct, * OldSheetLabel = NULL;
int Failed = FALSE;
char* ptcar;
@ -901,7 +904,7 @@ static int ReadSheetDescr( wxWindow* frame, char* Line, FILE* f, BASE_SCREEN* Wi
if( fieldref > 1 )
{
SheetLabelStruct = new DrawSheetLabelStruct( SheetStruct,
SheetLabelStruct = new Hierarchical_PIN_Sheet_Struct( SheetStruct,
wxPoint( 0, 0 ), CONV_FROM_UTF8( Name1 ) );
if( SheetStruct->m_Label == NULL )
OldSheetLabel = SheetStruct->m_Label = SheetLabelStruct;

Some files were not shown because too many files have changed in this diff Show More