Commit c5cd8502 authored by lifekidyeaa's avatar lifekidyeaa

2008-Feb-12 UPDATE Tim Hanson sideskate@gmail.com

================================================================================
+eeschema
        * commiting my changes to allow multiple instances of a given schematic file within 
a hierarchy:
        ** internally, m_currentScreen has been replaced with m_currentSheet,
                which is a list or 'path' of screens.  The path of screens is used to 
generate
                a series of timestamps, which is converted to flat component reference via 
a look-up
                table in the schematic files.
        ** this means that m_currentScreen is no longer used -- use GetScreen().
        ** GetScreen is virtual, as some of the dialogs keep around a WinEDA_BaseScreen 
pointer.
        ** all sub-sheets in a given schematic must have different names to generate a 
meaningful netlist.
parent 27bd742a
......@@ -11,6 +11,7 @@
#
# CMAKE_VERBOSE_MAKEFILE ON/OFF (OPTIONAL)
# Turns ON/OFF verbose build messages.
# you can also pass VERBOSE=1 to make for the same effect.
#
# CMAKE_INSTALL_PREFIX (OPTIONAL)
#
......
......@@ -6,6 +6,19 @@ Please add newer entries at the top, list the date and your name with
email address.
2008-Feb-12 UPDATE Tim Hanson sideskate@gmail.com
================================================================================
+eeschema
* commiting my changes to allow multiple instances of a given schematic file within a hierarchy:
** internally, m_currentScreen has been replaced with m_currentSheet,
which is a list or 'path' of screens. The path of screens is used to generate
a series of timestamps, which is converted to flat component reference via a look-up
table in the schematic files.
** this means that m_currentScreen is no longer used -- use GetScreen().
** GetScreen is virtual, as some of the dialogs keep around a WinEDA_BaseScreen pointer.
** all sub-sheets in a given schematic must have different names to generate a meaningful netlist.
=======
2008-Feb-12 UPDATE Igor Plyatov <plyatov@mail.ru>
================================================================================
+eeschema
......@@ -13,7 +26,6 @@ email address.
+all
Russian translation update.
2008-Feb-11 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew
......
......@@ -49,7 +49,7 @@ BASE_SCREEN::~BASE_SCREEN()
void BASE_SCREEN::InitDatas()
/*******************************/
{
m_SheetNumber = m_NumberOfSheet = 1; /* gestion hierarchie: Root: SheetNumber = 1 */
m_ScreenNumber = m_NumberOfScreen = 1; /* gestion hierarchie: Root: ScreenNumber = 1 */
m_Zoom = 32;
m_Grid = wxSize( 50, 50 ); /* pas de la grille */
m_UserGrid = g_UserGrid; /* pas de la grille "utilisateur" */
......@@ -63,18 +63,18 @@ void BASE_SCREEN::InitDatas()
{
case SCHEMATIC_FRAME:
m_Center = FALSE;
m_CurrentSheet = &g_Sheet_A4;
m_CurrentSheetDesc = &g_Sheet_A4;
break;
default:
case CVPCB_DISPLAY_FRAME:
case MODULE_EDITOR_FRAME:
case PCB_FRAME:
m_CurrentSheet = &g_Sheet_A4;
m_CurrentSheetDesc = &g_Sheet_A4;
break;
case GERBER_FRAME:
m_CurrentSheet = &g_Sheet_GERBER;
m_CurrentSheetDesc = &g_Sheet_GERBER;
break;
}
......@@ -158,15 +158,15 @@ wxSize BASE_SCREEN::ReturnPageSize()
{
default:
case SCHEMATIC_FRAME:
PageSize = m_CurrentSheet->m_Size;
PageSize = m_CurrentSheetDesc->m_Size;
break;
case GERBER_FRAME:
case CVPCB_DISPLAY_FRAME:
case MODULE_EDITOR_FRAME:
case PCB_FRAME:
PageSize.x = m_CurrentSheet->m_Size.x * (PCB_INTERNAL_UNIT / 1000);
PageSize.y = m_CurrentSheet->m_Size.y * (PCB_INTERNAL_UNIT / 1000);
PageSize.x = m_CurrentSheetDesc->m_Size.x * (PCB_INTERNAL_UNIT / 1000);
PageSize.y = m_CurrentSheetDesc->m_Size.y * (PCB_INTERNAL_UNIT / 1000);
break;
}
......
......@@ -186,7 +186,9 @@ std::ostream& operator<<( std::ostream& out, const wxPoint& pt )
void EDA_BaseStruct::Show( int nestLevel, std::ostream& os )
{
// for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
wxString s = GetClass();
s = s + wxT(" ");
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">\n";
/*
EDA_BaseStruct* kid = m_Son;
......@@ -195,9 +197,9 @@ void EDA_BaseStruct::Show( int nestLevel, std::ostream& os )
kid->Show( nestLevel+1, os );
}
*/
NestedSpace( nestLevel+1, os ) << "Need ::Show() override, shown class is using EDA_BaseStruct::Show()\n";
NestedSpace( nestLevel+1, os ) << "Need ::Show() override\n";
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n";
}
......
......@@ -122,6 +122,9 @@ void WinEDA_BasicFrame::PrintMsg(const wxString & text)
/******************************************************/
{
SetStatusText(text);
#ifdef DEBUG
printf("%s\n", (const char*)text.mb_str() );
#endif
}
/*************************************************************************/
......
......@@ -80,7 +80,7 @@ void PlotWorkSheet(int format_plot, BASE_SCREEN * screen)
*/
{
#define WSTEXTSIZE 50 // Text size in mils
Ki_PageDescr * Sheet = screen->m_CurrentSheet;
Ki_PageDescr * Sheet = screen->m_CurrentSheetDesc;
int ii, jj, xg , yg, ipas, gxpas, gypas;
wxSize PageSize;
wxPoint pos, ref;
......@@ -234,11 +234,11 @@ int UpperLimit = VARIABLE_BLOCK_START_POSITION;
break;
case WS_SIZESHEET:
msg += screen->m_CurrentSheet->m_Name;
msg += screen->m_CurrentSheetDesc->m_Name;
break;
case WS_IDENTSHEET:
msg << screen->m_SheetNumber << wxT("/") << screen->m_NumberOfSheet;
msg << screen->m_ScreenNumber << wxT("/") << screen->m_NumberOfScreen;
break;
case WS_COMPANY_NAME:
......
......@@ -40,7 +40,7 @@ void WinEDA_DrawFrame::CopyToClipboard(wxCommandEvent& event)
if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD )
{
if (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE)
if (GetScreen()->BlockLocate.m_Command != BLOCK_IDLE)
DrawPanel->SetCursor(wxCursor(DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor) );
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
......
......@@ -505,7 +505,7 @@ void SetRealLibraryPath( const wxString& shortlibname )
* Sinon g_UserLibDirBuffer = /usr/share/kicad/shortlibname/
*
* Remarque:
* Les \ sont remplacs par / (a la mode Unix)
* Les \ sont remplac�s par / (a la mode Unix)
*/
{
bool PathFound = FALSE;
......@@ -545,7 +545,7 @@ wxString ReturnKicadDatasPath()
* Sinon retourne /usr/share/kicad/
*
* Remarque:
* Les \ sont remplacs par / (a la mode Unix)
* Les \ sont remplac�s par / (a la mode Unix)
*/
{
bool PathFound = FALSE;
......
......@@ -21,7 +21,7 @@ void WinEDA_DrawFrame::TraceWorkSheet(wxDC * DC, BASE_SCREEN * screen, int line_
{
if ( ! m_Draw_Sheet_Ref ) return;
Ki_PageDescr * Sheet = screen->m_CurrentSheet;
Ki_PageDescr * Sheet = screen->m_CurrentSheetDesc;
int ii, jj, xg , yg, ipas, gxpas, gypas;
wxPoint pos;
int refx, refy,Color;
......@@ -179,10 +179,8 @@ int width = line_width;
case WS_IDENTSHEET:
if(WsItem->m_Legende) msg = WsItem->m_Legende;
msg << screen->m_SheetNumber << wxT("/") <<
screen->m_NumberOfSheet;
DrawGraphicText(DrawPanel, DC, pos, Color,
msg, TEXT_ORIENT_HORIZ, size,
GetScreenDesc(), TEXT_ORIENT_HORIZ, size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width);
break;
......@@ -273,3 +271,12 @@ int width = line_width;
}
}
}
/*********************************************************************/
wxString WinEDA_DrawFrame::GetScreenDesc()
/*********************************************************************/
{
wxString msg;
msg << GetScreen()->m_ScreenNumber << wxT("/") <<
GetScreen()->m_NumberOfScreen;
return msg;
}
......@@ -12,7 +12,7 @@ SET(EESCHEMA_SRCS
block_libedit.cpp
busentry.cpp
bus-wire-junction.cpp
class_hierarchy_sheet.cpp
class_drawsheet.cpp
class_screen.cpp
class_text-label.cpp
cleanup.cpp
......
......@@ -35,7 +35,7 @@ void EDA_SchComponentStruct::Display_Infos( WinEDA_DrawFrame* frame )
frame->MsgPanel->EraseMsgBox();
Affiche_1_Parametre( frame, 1, _( "Ref" ),
m_Field[REFERENCE].m_Text, DARKCYAN );
GetRef(((WinEDA_SchematicFrame*)frame)->GetSheet()), DARKCYAN );
if( Entry && Entry->m_Options == ENTRY_POWER )
msg = _( "Pwr Symb" );
......
This diff is collapsed.
......@@ -201,7 +201,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
* retourne :
* 0 si aucun composant selectionne
* 1 sinon
* -1 si commande termine et composants trouvs (block delete, block save)
* -1 si commande termin�e et composants trouv�s (block delete, block save)
*/
{
int ii = 0;
......@@ -232,18 +232,18 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
break;
case BLOCK_DRAG: /* Drag */
BreakSegmentOnJunction( GetScreen() );
BreakSegmentOnJunction( (SCH_SCREEN*)GetScreen() );
case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */
block->m_BlockDrawStruct =
PickStruct( GetScreen()->BlockLocate, GetScreen()->EEDrawList, SEARCHALL );
PickStruct( GetScreen()->BlockLocate, GetScreen(), SEARCHALL );
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
if( block->m_BlockDrawStruct != NULL )
{
ii = 1;
CollectStructsToDrag( GetScreen() );
CollectStructsToDrag( (SCH_SCREEN*)GetScreen() );
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
......@@ -260,7 +260,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DELETE: /* Delete */
block->m_BlockDrawStruct =
PickStruct( GetScreen()->BlockLocate,
GetScreen()->EEDrawList, SEARCHALL );
GetScreen(), SEARCHALL );
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
if( block->m_BlockDrawStruct != NULL )
{
......@@ -275,7 +275,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_SAVE: /* Save */
block->m_BlockDrawStruct =
PickStruct( GetScreen()->BlockLocate,
GetScreen()->EEDrawList, SEARCHALL );
GetScreen(), SEARCHALL );
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
if( block->m_BlockDrawStruct != NULL )
{
......@@ -379,14 +379,14 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
}
block->m_BlockDrawStruct = NULL;
}
BreakSegmentOnJunction( GetScreen() );
BreakSegmentOnJunction( (SCH_SCREEN*)GetScreen() );
block->m_BlockDrawStruct =
PickStruct( GetScreen()->BlockLocate,
GetScreen()->EEDrawList, SEARCHALL );
GetScreen(), SEARCHALL );
if( block->m_BlockDrawStruct != NULL )
{
ii = 1;
CollectStructsToDrag( GetScreen() );
CollectStructsToDrag( (SCH_SCREEN*)GetScreen() );
if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
block->m_State = STATE_BLOCK_MOVE;
......@@ -685,10 +685,10 @@ void MirrorOneStruct( EDA_BaseStruct* DrawStruct, wxPoint& Center )
DrawText->m_Pos.x = px.x;
break;
case DRAW_HIER_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
// Text is not really mirrored: Orientation is changed
DrawText = (DrawGlobalLabelStruct*) DrawStruct;
DrawText = (DrawLabelStruct*) DrawStruct;
if( DrawText->m_Orient == 0 ) /* horizontal text */
DrawText->m_Orient = 2;
else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/
......@@ -831,14 +831,14 @@ static EDA_BaseStruct* CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREE
case DRAW_SHEET_STRUCT_TYPE:
{
//DuplicateStruct calls GenCopy, which should handle
//m_s and m_sRefCount properly.
DrawSheetStruct* sheet = (DrawSheetStruct*) Struct;
sheet->m_TimeStamp = GetTimeStamp();
sheet->m_UndoList = NULL;
sheet->m_RedoList = NULL;
sheet->EEDrawList = NULL;
sheet->m_Son = NULL;
sheet->m_SheetName.Printf( wxT( "%8.8lX" ), sheet->m_TimeStamp );
sheet->m_FileName = sheet->m_SheetName + wxT( ".sch" );
//sheet->m_s->m_UndoList = NULL;
//sheet->m_s->m_RedoList = NULL;
//keep m_s pointer & associated.
//sheet->m_Son = NULL; m_son is involved in undo and redo.
break;
}
......@@ -871,6 +871,7 @@ static EDA_BaseStruct* CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREE
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_HIER_LABEL_STRUCT_TYPE:
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE:
......@@ -882,17 +883,12 @@ static EDA_BaseStruct* CopyStruct( WinEDA_DrawPanel* panel, wxDC* DC, BASE_SCREE
{
DrawSheetStruct* sheet = (DrawSheetStruct*) NewDrawStruct;
sheet->m_TimeStamp = GetTimeStamp();
sheet->m_UndoList = NULL;
sheet->m_RedoList = NULL;
sheet->EEDrawList = NULL;
sheet->m_Son = NULL;
sheet->m_SheetName.Printf( wxT( "%8.8lX" ), sheet->m_TimeStamp );
sheet->m_FileName = sheet->m_SheetName + wxT( ".sch" );
break;
}
case DRAW_LIB_ITEM_STRUCT_TYPE:
( (EDA_SchComponentStruct*) NewDrawStruct )->m_TimeStamp = GetTimeStamp();
( (EDA_SchComponentStruct*) NewDrawStruct )->m_TimeStamp = GetTimeStamp();
( (EDA_SchComponentStruct*) NewDrawStruct )->ClearAnnotation();
break;
}
......@@ -964,7 +960,12 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, EDA_BaseStruct* DrawStruct
RedrawOneStruct( panel, DC, DrawStruct, g_XorMode );
/* Unlink the structure */
DrawStruct->Pnext = DrawStruct->Pback = NULL; // Only one struct -> no link
frame->SaveCopyInUndoList( DrawStruct, IS_DELETED );
if(DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE){
SAFE_DELETE(DrawStruct);
//no undo/redo for this (for now), it is on both the EEDrawList and m_SubSheet arrays,
//hence the undo logic would have to be extended for this.
}else
frame->SaveCopyInUndoList( DrawStruct, IS_DELETED );
}
}
......@@ -1043,7 +1044,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC )
EDA_BaseStruct* Struct = PickedList->m_PickedStruct;
if( Struct->Type() == DRAW_LIB_ITEM_STRUCT_TYPE )
{
( (EDA_SchComponentStruct*) Struct )->m_TimeStamp = GetTimeStamp();
( (EDA_SchComponentStruct*) Struct )->m_TimeStamp = GetTimeStamp();
( (EDA_SchComponentStruct*) Struct )->ClearAnnotation();
SetStructFather( Struct, GetScreen() );
}
......@@ -1067,7 +1068,7 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC )
{
if( DrawStruct->Type() == DRAW_LIB_ITEM_STRUCT_TYPE )
{
( (EDA_SchComponentStruct*) DrawStruct )->m_TimeStamp = GetTimeStamp();
( (EDA_SchComponentStruct*) DrawStruct )->m_TimeStamp = GetTimeStamp();
( (EDA_SchComponentStruct*) DrawStruct )->ClearAnnotation();
}
SetStructFather( DrawStruct, GetScreen() );
......@@ -1117,6 +1118,7 @@ bool PlaceStruct( BASE_SCREEN* screen, EDA_BaseStruct* DrawStruct )
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_HIER_LABEL_STRUCT_TYPE:
case DRAW_LIB_ITEM_STRUCT_TYPE:
case DRAW_SHEET_STRUCT_TYPE:
case DRAW_SHEETLABEL_STRUCT_TYPE:
......@@ -1219,9 +1221,10 @@ void MoveOneStruct( EDA_BaseStruct* DrawStruct, const wxPoint& move_vector )
DrawLabel->m_Pos += move_vector;
break;
case DRAW_HIER_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
#define DrawGlobalLabel ( (DrawGlobalLabelStruct*) DrawStruct )
DrawGlobalLabel->m_Pos += move_vector;
#define DrawGHLabel ( (DrawLabelStruct*) DrawStruct )
DrawGHLabel->m_Pos += move_vector;
break;
case DRAW_LIB_ITEM_STRUCT_TYPE:
......@@ -1310,6 +1313,10 @@ EDA_BaseStruct* DuplicateStruct( EDA_BaseStruct* DrawStruct )
NewDrawStruct = ( (DrawLabelStruct*) DrawStruct )->GenCopy();
break;
case DRAW_HIER_LABEL_STRUCT_TYPE:
NewDrawStruct = ( (DrawHierLabelStruct*) DrawStruct )->GenCopy();
break;
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
NewDrawStruct = ( (DrawGlobalLabelStruct*) DrawStruct )->GenCopy();
break;
......@@ -1577,9 +1584,10 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
Struct->m_Flags |= SELECTED;
break;
case DRAW_HIER_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawGlobalLabelStruct*) Struct )
#define STRUCT ( (DrawLabelStruct*) Struct )
if( Struct->m_Flags & SELECTED )
break; /* Already in list */
if( STRUCT->m_Pos != position )
......
......@@ -140,8 +140,8 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
if( !newsegment ) /* first point : Create first wire ou bus */
{
s_ConnexionStartPoint = cursorpos;
s_OldWiresList = GetScreen()->ExtractWires( TRUE );
GetScreen()->SchematicCleanUp( NULL );
s_OldWiresList = ((SCH_SCREEN*)GetScreen())->ExtractWires( TRUE );
((SCH_SCREEN*)GetScreen())->SchematicCleanUp( NULL );
switch( type )
{
......@@ -191,8 +191,8 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
/* Creation du segment suivant ou fin de trac si point sur pin, jonction ...*/
if( IsTerminalPoint( GetScreen(), cursorpos, oldsegment->m_Layer ) )
/* Creation du segment suivant ou fin de trac si point sur pin, jonction ...*/
if( IsTerminalPoint( (SCH_SCREEN*)GetScreen(), cursorpos, oldsegment->m_Layer ) )
{
EndSegment( DC ); return;
}
......@@ -299,7 +299,7 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
alt_end_point = lastsegment->m_Start;
}
GetScreen()->SchematicCleanUp( NULL );
((SCH_SCREEN*)GetScreen())->SchematicCleanUp( NULL );
/* clear flags and find last segment entered, for repeat function */
segment = (EDA_DrawLineStruct*) GetScreen()->EEDrawList;
......@@ -519,7 +519,7 @@ void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC )
Segment_in_Ghost( DrawPanel, DC, FALSE ); /* Effacement du trace en cours */
}
EraseStruct( GetScreen()->GetCurItem(), GetScreen() );
EraseStruct( GetScreen()->GetCurItem(), (SCH_SCREEN*)GetScreen() );
DrawPanel->ManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
}
......@@ -662,6 +662,16 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
break;
case DRAW_HIER_LABEL_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawHierLabelStruct*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos;
/*** Increment du numero de label ***/
IncrementLabelMember( STRUCT->m_Text );
break;
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawGlobalLabelStruct*) g_ItemToRepeat )
......@@ -695,11 +705,11 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
// Create the duplicate component, position = mouse cursor
g_ItemToRepeat = STRUCT->GenCopy();
new_pos.x = m_CurrentScreen->m_Curseur.x - STRUCT->m_Pos.x;
new_pos.y = m_CurrentScreen->m_Curseur.y - STRUCT->m_Pos.y;
STRUCT->m_Pos = m_CurrentScreen->m_Curseur;
new_pos.x = GetScreen()->m_Curseur.x - STRUCT->m_Pos.x;
new_pos.y = GetScreen()->m_Curseur.y - STRUCT->m_Pos.y;
STRUCT->m_Pos = GetScreen()->m_Curseur;
STRUCT->m_Flags = IS_NEW;
STRUCT->m_TimeStamp = GetTimeStamp();
STRUCT->m_TimeStamp = GetTimeStamp();
for( int ii = 0; ii < NUMBER_OF_FIELDS; ii++ )
{
STRUCT->m_Field[ii].m_Pos += new_pos;
......@@ -770,10 +780,10 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
* - type WIRE, si il y a
* - une jonction
* - ou une pin
* - ou une extrmit unique de fil
* - ou une extr�mit� unique de fil
*
* - type BUS, si il y a
* - ou une extrmit unique de BUS
* - ou une extr�mit� unique de BUS
*/
{
EDA_BaseStruct* item;
......@@ -785,7 +795,7 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
switch( layer )
{
case LAYER_BUS:
item = PickStruct( pos, screen->EEDrawList, BUSITEM );
item = PickStruct( pos, screen, BUSITEM );
if( item )
return TRUE;
pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList );
......@@ -798,13 +808,13 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
break;
case LAYER_NOTES:
item = PickStruct( pos, screen->EEDrawList, DRAWITEM );
item = PickStruct( pos, screen, DRAWITEM );
if( item )
return TRUE;
break;
case LAYER_WIRE:
item = PickStruct( pos, screen->EEDrawList, RACCORDITEM | JUNCTIONITEM );
item = PickStruct( pos, screen, RACCORDITEM | JUNCTIONITEM );
if( item )
return TRUE;
......@@ -820,17 +830,17 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
return TRUE;
}
item = PickStruct( pos, screen->EEDrawList, WIREITEM );
item = PickStruct( pos, screen, WIREITEM );
if( item )
return TRUE;
item = PickStruct( pos, screen->EEDrawList, LABELITEM );
item = PickStruct( pos, screen, LABELITEM );
if( item && (item->Type() != DRAW_TEXT_STRUCT_TYPE)
&& ( ( (DrawGlobalLabelStruct*) item )->m_Pos.x == pos.x )
&& ( ( (DrawGlobalLabelStruct*) item )->m_Pos.y == pos.y ) )
return TRUE;
pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList );
pinsheet = LocateAnyPinSheet( pos, screen );
if( pinsheet && !IsBusLabel( pinsheet->m_Text ) )
{
itempos = pinsheet->m_Pos;
......@@ -861,14 +871,14 @@ bool IsJunctionNeeded( WinEDA_SchematicFrame* frame, wxPoint& pos )
* - a pin is on location pos
*/
{
if( PickStruct( pos, frame->GetScreen()->EEDrawList, JUNCTIONITEM ) )
if( PickStruct( pos, frame->GetScreen(), JUNCTIONITEM ) )
return FALSE;
if( PickStruct( pos, frame->GetScreen()->EEDrawList, WIREITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) )
if( PickStruct( pos, frame->GetScreen(), WIREITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) )
{
if( PickStruct( pos, frame->GetScreen()->EEDrawList, WIREITEM | WIRE_BUS_ENDPOINTS_ONLY ) )
if( PickStruct( pos, frame->GetScreen(), WIREITEM | WIRE_BUS_ENDPOINTS_ONLY ) )
return TRUE;
if( frame->LocatePinEnd( frame->GetScreen()->EEDrawList, pos ) )
if( frame->LocatePinEnd( frame->GetScreen(), pos ) )
return TRUE;
}
......
This diff is collapsed.
......@@ -83,11 +83,16 @@ extern int* TemplateShape[5][4];
/* Forward declarations */
class DrawSheetStruct;
extern DrawSheetStruct* g_RootSheet;
class SCH_SCREEN : public BASE_SCREEN
{
public:
int m_RefCount; //how many sheets reference this screen?
//delete when it goes to zero.
int m_ScreenNumber;
int m_NumberOfScreen;
SCH_SCREEN( int idtype, KICAD_T aType = SCREEN_STRUCT_TYPE );
~SCH_SCREEN();
......@@ -100,6 +105,8 @@ public:
void Place( WinEDA_DrawFrame* frame, wxDC* DC ) { };
void RemoveFromDrawList( EDA_BaseStruct* DrawStruct );/* remove DrawStruct from EEDrawList. */
bool CheckIfOnDrawList( EDA_BaseStruct* st );
void AddToDrawList( EDA_BaseStruct* DrawStruct );
void ClearUndoORRedoList( EDA_BaseStruct* List );
bool SchematicCleanUp( wxDC* DC = NULL );
......@@ -117,7 +124,7 @@ class DrawSheetLabelStruct : public EDA_BaseStruct, public EDA_TextStruct
public:
int m_Layer;
int m_Edge, m_Shape;
bool m_IsDangling; // TRUE si non connect
bool m_IsDangling; // TRUE si non connect
public:
DrawSheetLabelStruct( DrawSheetStruct* parent,
......@@ -140,20 +147,25 @@ public:
int draw_mode, int Color = -1 );
};
WX_DEFINE_ARRAY( DrawSheetStruct*, SheetGrowArray );
class DrawSheetStruct : public SCH_SCREEN /* Gestion de la hierarchie */
class DrawSheetStruct : public EDA_BaseStruct /*public SCH_SCREEN*/ /* Gestion de la hierarchie */
{
public:
wxString m_SheetName;
int m_SheetNameSize;
wxString m_SheetName; //this is equivalent to C101 for components:
// it is stored in F0 ... of the file.
wxString m_FileName; //also in SCH_SCREEN (redundant),
//but need it here for loading after
//reading the sheet description from file.
int m_SheetNameSize;
// wxString m_FileName; in SCH_SCREEN
int m_FileNameSize;
wxPoint m_Pos;
wxSize m_Size; /* Position and Size of sheet symbol */
int m_Layer;
DrawSheetLabelStruct* m_Label; /* Points de connection */
int m_NbLabel; /* Nombre de points de connexion */
int m_FileNameSize;
wxPoint m_Pos;
wxSize m_Size; /* Position and Size of sheet symbol */
int m_Layer;
DrawSheetLabelStruct* m_Label; /* Points de connection, linked list.*/
int m_NbLabel; /* Nombre de points de connexion */
SCH_SCREEN* m_s;
public:
DrawSheetStruct( const wxPoint& pos = wxPoint( 0, 0 ) );
......@@ -169,30 +181,95 @@ public:
void CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC );
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
void SwapData( DrawSheetStruct* copyitem );
void SwapData( DrawSheetStruct* copyitem );
void DeleteAnnotation( bool recurse );
int ComponentCount();
bool Load(WinEDA_SchematicFrame* frame);
bool SearchHierarchy(wxString filename, SCH_SCREEN **screen);
bool LocatePathOfScreen(SCH_SCREEN *screen, DrawSheetList* list);
int CountSheets();
//void RemoveSheet(DrawSheetStruct* sheet);
//to remove a sheet, just delete it
//-- the destructor should take care of everything else.
};
#define DSLSZ 32
class DrawSheetList
{
public:
int m_numSheets;
DrawSheetStruct* m_sheets[DSLSZ];
DrawSheetList();
~DrawSheetList(){};
void Clear(){m_numSheets = 0; }
int Cmp(DrawSheetList& d);
DrawSheetStruct* Last();
SCH_SCREEN* LastScreen();
EDA_BaseStruct* LastDrawList();
void Push(DrawSheetStruct* sheet);
DrawSheetStruct* Pop();
wxString Path();
wxString PathHumanReadable();
void UpdateAllScreenReferences();
bool operator= (const DrawSheetList& d1);
bool operator==(const DrawSheetList &d1);
bool operator!=(const DrawSheetList &d1);
};
/* Class to handle the list of *Sheets* in a hierarchy */
// sheets are not unique - can have many sheets with the same
// filename and the same SCH_SHEET reference.
class EDA_SheetList
{
private:
DrawSheetList* m_List;
int m_count;
int m_index;
DrawSheetList m_currList;
public:
EDA_SheetList( DrawSheetStruct* sheet ){
m_index = 0;
m_count = 0;
m_List = NULL;
if(sheet == NULL)
sheet = g_RootSheet;
BuildSheetList( sheet );
}
~EDA_SheetList() {if(m_List){free(m_List);} m_List = NULL;}
int GetCount() { return m_count; }
DrawSheetList* GetFirst();
DrawSheetList* GetNext();
DrawSheetList* GetSheet(int index );
private:
void BuildSheetList( DrawSheetStruct* sheet );
};
/* Class to handle the list of screens in a hierarchy */
/* Class to handle the list of *screens* in a hierarchy */
// screens are unique, and correspond to .sch files.
WX_DEFINE_ARRAY( SCH_SCREEN*, ScreenGrowArray );
class EDA_ScreenList
{
private:
int m_Count;
SCH_SCREEN** m_List;
int m_Index;
ScreenGrowArray m_List;
unsigned int m_Index;
public:
EDA_ScreenList( EDA_BaseStruct* DrawStruct );
~EDA_ScreenList();
int GetCount() { return m_Count; }
EDA_ScreenList(){
m_Index = 0;
BuildScreenList(g_RootSheet);
}
~EDA_ScreenList() {}
int GetCount() { return m_List.GetCount(); }
SCH_SCREEN* GetFirst();
SCH_SCREEN* GetNext();
SCH_SCREEN* GetScreen( int index );
void UpdateSheetNumberAndDate();
SCH_SCREEN* GetScreen( unsigned int index );
void UpdateScreenNumberAndDate();
private:
SCH_SCREEN** BuildScreenList( SCH_SCREEN** ScreenList,
EDA_BaseStruct* DrawStruct, int* Count );
void AddScreenToList( SCH_SCREEN* testscreen );
void BuildScreenList( EDA_BaseStruct* sheet );
};
#endif /* CLASS_SCREEN_H */
......@@ -18,6 +18,7 @@
/* class DrawTextStruct */
/* class DrawLabelStruct */
/* class DrawGlobalLabelStruct */
/* class DrawHierLabelStruct */
/************************/
/**************************************************************************/
......@@ -47,9 +48,13 @@ DrawTextStruct* DrawTextStruct::GenCopy()
break;
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
newitem = new DrawGlobalLabelStruct( m_Pos, m_Text );
newitem = new DrawGlobalLabelStruct(m_Pos, m_Text );
break;
case DRAW_HIER_LABEL_STRUCT_TYPE:
newitem = new DrawHierLabelStruct(m_Pos, m_Text );
break;
case DRAW_LABEL_STRUCT_TYPE:
newitem = new DrawLabelStruct( m_Pos, m_Text );
break;
......@@ -102,8 +107,7 @@ void DrawTextStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
/* restore new values */
SwapData( (DrawTextStruct*) g_ItemToUndoCopy );
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = NULL;
SAFE_DELETE( g_ItemToUndoCopy );
}
EDA_BaseStruct::Place( frame, DC );
......@@ -121,15 +125,24 @@ DrawLabelStruct::DrawLabelStruct( const wxPoint& pos, const wxString& text ) :
/***********************************************************************************/
DrawGlobalLabelStruct::DrawGlobalLabelStruct( const wxPoint& pos, const wxString& text ) :
DrawGlobalLabelStruct::DrawGlobalLabelStruct(const wxPoint& pos, const wxString& text) :
DrawTextStruct( pos, text, DRAW_GLOBAL_LABEL_STRUCT_TYPE )
/***********************************************************************************/
{
m_Layer = LAYER_GLOBLABEL;
m_Shape = NET_INPUT;
m_Layer = LAYER_GLOBLABEL;
m_Shape = NET_BIDI;
m_IsDangling = TRUE;
}
/***********************************************************************************/
DrawHierLabelStruct::DrawHierLabelStruct(const wxPoint& pos, const wxString& text) :
DrawTextStruct( pos, text, DRAW_HIER_LABEL_STRUCT_TYPE )
/***********************************************************************************/
{
m_Layer = LAYER_HIERLABEL;
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
}
/*******************************************************************************************/
void DrawTextStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
......@@ -201,10 +214,9 @@ void DrawLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& of
/*******************************************************************************************/
void DrawGlobalLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
void DrawHierLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int DrawMode, int Color )
/******************************************************************************************/
/* Texts type Global Label have 4 directions, and the Text origin is the graphic icon
*/
{
......@@ -214,46 +226,45 @@ void DrawGlobalLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoi
wxSize Size = m_Size;
int width = MAX( m_Width, g_DrawMinimunLineWidth );
if( Color >= 0 )
color = Color;
else
color = ReturnLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
HalfSize = Size.x / 2; ii = Size.x + TXTMARGE;
switch( m_Orient )
{
case 0: /* Orientation horiz normale */
DrawGraphicText( panel, DC,
wxPoint( m_Pos.x - ii + offset.x, m_Pos.y + offset.y ), color,
m_Text, TEXT_ORIENT_HORIZ, Size,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, width );
break;
case 1: /* Orientation vert UP */
DrawGraphicText( panel, DC,
wxPoint( m_Pos.x + offset.x, m_Pos.y + ii + offset.y ), color,
m_Text, TEXT_ORIENT_VERT, Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, width );
break;
case 2: /* Orientation horiz inverse */
DrawGraphicText( panel, DC,
wxPoint( m_Pos.x + ii + offset.x, m_Pos.y + offset.y ), color,
m_Text, TEXT_ORIENT_HORIZ, Size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width );
break;
case 3: /* Orientation vert BOTTOM */
DrawGraphicText( panel, DC,
wxPoint( m_Pos.x + offset.x, m_Pos.y - ii + offset.y ), color,
m_Text, TEXT_ORIENT_VERT, Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width );
break;
}
if( Color >= 0 )
color = Color;
else
color = ReturnLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
HalfSize = Size.x / 2; ii = Size.x + TXTMARGE;
switch( m_Orient )
{
case 0: /* Orientation horiz normale */
DrawGraphicText( panel, DC,
wxPoint( m_Pos.x - ii + offset.x, m_Pos.y + offset.y ), color,
m_Text, TEXT_ORIENT_HORIZ, Size,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, width );
break;
case 1: /* Orientation vert UP */
DrawGraphicText( panel, DC,
wxPoint( m_Pos.x + offset.x, m_Pos.y + ii + offset.y ), color,
m_Text, TEXT_ORIENT_VERT, Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, width );
break;
case 2: /* Orientation horiz inverse */
DrawGraphicText( panel, DC,
wxPoint( m_Pos.x + ii + offset.x, m_Pos.y + offset.y ), color,
m_Text, TEXT_ORIENT_HORIZ, Size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width );
break;
case 3: /* Orientation vert BOTTOM */
DrawGraphicText( panel, DC,
wxPoint( m_Pos.x + offset.x, m_Pos.y - ii + offset.y ), color,
m_Text, TEXT_ORIENT_VERT, Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width );
break;
}
Template = TemplateShape[m_Shape][m_Orient];
......@@ -271,3 +282,74 @@ void DrawGlobalLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoi
if( m_IsDangling )
DrawDanglingSymbol( panel, DC, m_Pos + offset, color );
}
/*******************************************************************************************/
void DrawGlobalLabelStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int DrawMode, int Color )
/******************************************************************************************/
/* Texts type Global Label have 4 directions, and the Text origin is the graphic icon
*/
//should reimplement this with a custom global shape??
//it is the same as Hierarchal sheet.
{
int* Template;
int Poly[20];
int ii, jj, imax, color, HalfSize;
wxSize Size = m_Size;
int width = MAX( m_Width, g_DrawMinimunLineWidth );
if( Color >= 0 )
color = Color;
else
color = ReturnLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
HalfSize = Size.x / 2; ii = Size.x + TXTMARGE;
switch( m_Orient )
{
case 0: /* Orientation horiz normale */
DrawGraphicText( panel, DC,
wxPoint( m_Pos.x - ii + offset.x, m_Pos.y + offset.y ), color,
m_Text, TEXT_ORIENT_HORIZ, Size,
GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, width );
break;
case 1: /* Orientation vert UP */
DrawGraphicText( panel, DC,
wxPoint( m_Pos.x + offset.x, m_Pos.y + ii + offset.y ), color,
m_Text, TEXT_ORIENT_VERT, Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, width );
break;
case 2: /* Orientation horiz inverse */
DrawGraphicText( panel, DC,
wxPoint( m_Pos.x + ii + offset.x, m_Pos.y + offset.y ), color,
m_Text, TEXT_ORIENT_HORIZ, Size,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width );
break;
case 3: /* Orientation vert BOTTOM */
DrawGraphicText( panel, DC,
wxPoint( m_Pos.x + offset.x, m_Pos.y - ii + offset.y ), color,
m_Text, TEXT_ORIENT_VERT, Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width );
break;
}
Template = TemplateShape[m_Shape][m_Orient];
imax = *Template; Template++;
for( ii = 0, jj = 0; ii < imax; ii++ )
{
Poly[jj] = ( HalfSize * (*Template) ) + m_Pos.x + offset.x;
jj++; Template++;
Poly[jj] = ( HalfSize * (*Template) ) + m_Pos.y + offset.y;
jj++; Template++;
}
GRPoly( &panel->m_ClipBox, DC, imax, Poly, 0, width, color, color );
if( m_IsDangling )
DrawDanglingSymbol( panel, DC, m_Pos + offset, color );
}
......@@ -106,6 +106,7 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen )
case DRAW_NOCONNECT_STRUCT_TYPE:
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_HIER_LABEL_STRUCT_TYPE:
case DRAW_LIB_ITEM_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE:
case DRAW_POLYLINE_STRUCT_TYPE:
......
......@@ -16,7 +16,8 @@
#include "macros.h"
#include <wx/arrimpl.cpp>
WX_DEFINE_OBJARRAY(ArrayOfSheetLists);
/***************************/
/* class DrawPartStruct */
/* class EDA_SchComponentStruct */
......@@ -88,7 +89,72 @@ const wxString& EDA_SchComponentStruct::ReturnFieldName( int aFieldNdx ) const
return m_Field[aFieldNdx].m_Name;
}
/************************************/
wxString EDA_SchComponentStruct::GetPath(DrawSheetList* sheet)
/************************************/
{
wxString str;
str.Printf(_("%8.8lX"), m_TimeStamp );
return sheet->Path() + str;
}
/************************************/
const wxString EDA_SchComponentStruct::GetRef( DrawSheetList* sheet )
/************************************/
{
wxString path = GetPath( sheet );
unsigned int i;
for(i=0; i<m_Paths.GetCount(); i++){
if( m_Paths[i].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];
}
}
return m_PrefixString;
}
/************************************/
void EDA_SchComponentStruct::SetRef( DrawSheetList* sheet, wxString ref )
/************************************/
{
//check to see if it is already there before inserting it
wxString path = GetPath( sheet );
printf("SetRef path: %s ref: %s\n",
CONV_TO_UTF8(path),
CONV_TO_UTF8(ref));
unsigned int i;
bool notInArray = true;
for(i=0; i<m_Paths.GetCount(); i++){
if(m_Paths[i].Cmp(path) == 0){
//just update the reference text, not the timestamp.
m_References.RemoveAt(i);
m_References.Insert(ref, i);
notInArray = false;
}
}
if(notInArray){
m_References.Add(ref);
m_Paths.Add(path);
}
if(m_Field[REFERENCE].m_Text.IsEmpty() ||
( abs(m_Field[REFERENCE].m_Pos.x - m_Pos.x) +
abs(m_Field[REFERENCE].m_Pos.y - m_Pos.y) > 1000)) {
//move it to a reasonable position..
m_Field[REFERENCE].m_Pos = m_Pos;
}
m_Field[REFERENCE].m_Text = ref; //for drawing.
}
/************************************/
void EDA_SchComponentStruct::ClearRefs()
/************************************/
{
m_Paths.Empty();
m_References.Empty();
}
const wxString& EDA_SchComponentStruct::GetFieldValue( int aFieldNdx ) const
{
// avoid unnecessarily copying wxStrings.
......@@ -109,8 +175,8 @@ EDA_SchComponentStruct::EDA_SchComponentStruct( const wxPoint& pos ) :
int ii;
m_Multi = 0; /* In multi unit chip - which unit to draw. */
m_RefIdNumber = 0;
m_FlagControlMulti = 0;
//m_FlagControlMulti = 0;
m_UsedOnSheets.Clear();
m_Convert = 0; /* Gestion des mutiples representations (conversion De Morgan) */
/* The rotation/mirror transformation matrix. pos normal*/
......@@ -132,6 +198,8 @@ EDA_SchComponentStruct::EDA_SchComponentStruct( const wxPoint& pos ) :
m_Field[REFERENCE].m_Layer = LAYER_REFERENCEPART;
m_PinIsDangling = NULL;
m_PrefixString = wxString(_("U"));
}
......@@ -183,8 +251,6 @@ EDA_Rect EDA_SchComponentStruct::GetBoundaryBox()
BoundaryBox.Offset( m_Pos );
return BoundaryBox;
}
/**************************************************************************/
void PartTextStruct::SwapData( PartTextStruct* copyitem )
/**************************************************************************/
......@@ -250,8 +316,7 @@ void EDA_SchComponentStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
/* restore new values */
SwapData( (EDA_SchComponentStruct*) g_ItemToUndoCopy );
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = NULL;
SAFE_DELETE( g_ItemToUndoCopy );
}
EDA_BaseStruct::Place( frame, DC );
......@@ -265,13 +330,13 @@ void EDA_SchComponentStruct::ClearAnnotation()
/* Suppress annotation ( i.i IC23 changed to IC? and part reset to 1)
*/
{
m_RefIdNumber = 0;
while( isdigit( m_Field[REFERENCE].m_Text.Last() ) )
m_Field[REFERENCE].m_Text.RemoveLast();
if( m_Field[REFERENCE].m_Text.Last() != '?' )
m_Field[REFERENCE].m_Text.Append( '?' );
wxString defRef = m_PrefixString;
defRef.Append( _("?") );
m_References.Empty();
unsigned int i;
for(i=0; i< m_Paths.GetCount(); i++){
m_References.Add(defRef);
}
EDA_LibComponentStruct* Entry;
Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
......@@ -291,7 +356,8 @@ EDA_SchComponentStruct* EDA_SchComponentStruct::GenCopy()
new_item->m_Multi = m_Multi;
new_item->m_ChipName = m_ChipName;
new_item->m_FlagControlMulti = m_FlagControlMulti;
//new_item->m_FlagControlMulti = m_FlagControlMulti;
new_item->m_UsedOnSheets = m_UsedOnSheets;
new_item->m_Convert = m_Convert;
new_item->m_Transform[0][0] = m_Transform[0][0];
new_item->m_Transform[0][1] = m_Transform[0][1];
......@@ -522,9 +588,9 @@ int EDA_SchComponentStruct::GetRotationMiroir()
wxPoint EDA_SchComponentStruct::GetScreenCoord( const wxPoint& coord )
/***********************************************************************/
/* Renvoie la coordonne du point coord, en fonction de l'orientation
/* Renvoie la coordonne du point coord, en fonction de l'orientation
* du composant (rotation, miroir).
* Les coord sont toujours relatives l'ancre (coord 0,0) du composant
* Les coord sont toujours relatives l'ancre (coord 0,0) du composant
*/
{
wxPoint screenpos;
......@@ -548,7 +614,7 @@ void EDA_SchComponentStruct::Show( int nestLevel, std::ostream& os )
{
// for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
" ref=\"" << GetReference().mb_str() << '"' <<
" ref=\"" << ReturnFieldName(0) << '"' <<
" chipName=\"" << m_ChipName.mb_str() << '"' <<
m_Pos <<
" layer=\"" << m_Layer << '"' <<
......
......@@ -11,10 +11,11 @@
#include "macros.h"
#include "base_struct.h"
#include <wx/arrstr.h>
#include "class_screen.h"
#include <wx/dynarray.h>
/* Definition de la representation du composant */
#define NUMBER_OF_FIELDS 12 /* Nombre de champs de texte affectes au composant */
enum NumFieldType {
REFERENCE = 0, /* Champ Reference of part, i.e. "IC21" */
VALUE, /* Champ Value of part, i.e. "3.3K" */
......@@ -27,7 +28,8 @@ enum NumFieldType {
FIELD5,
FIELD6,
FIELD7,
FIELD8
FIELD8,
NUMBER_OF_FIELDS /* Nombre de champs de texte affectes au composant */
};
......@@ -64,7 +66,7 @@ public:
/* the class DrawPartStruct describes a basic virtual component
* Not used directly:
* used classes are EDA_SchComponentStruct (the "classic" schematic component
* used classes are EDA_SchComponentStruct (the "classic" schematic component, below)
* and the Pseudo component DrawSheetStruct
*/
class DrawPartStruct : public EDA_BaseStruct
......@@ -83,27 +85,26 @@ public:
{
return wxT( "DrawPart" );
}
/**
* Function GetReference
* returns a reference to the Reference
*/
const wxString& GetReference() { return m_Field[REFERENCE].m_Text; }
};
WX_DECLARE_OBJARRAY(DrawSheetList, ArrayOfSheetLists);
/* the class EDA_SchComponentStruct describes a real component */
class EDA_SchComponentStruct : public DrawPartStruct
{
public:
int m_RefIdNumber; /* reference count: for U1, R2 .. it is the 1 or 2 value */
int m_Multi; /* In multi unit chip - which unit to draw. */
int m_FlagControlMulti;
int m_Convert; /* Gestion des mutiples representations (ex: conversion De Morgan) */
//int m_FlagControlMulti;
ArrayOfSheetLists m_UsedOnSheets;
int m_Convert; /* Gestion (management) des mutiples representations (ex: conversion De Morgan) */
int m_Transform[2][2]; /* The rotation/mirror transformation matrix. */
bool* m_PinIsDangling; // liste des indicateurs de pin non connectee
wxArrayString m_Paths; // /sheet1/C102, /sh2/sh1/U32 etc.
wxArrayString m_References; // C102, U32 etc.
wxString m_PrefixString; //C, R, U, Q etc - the first character which typically indicates what the component is.
//determined, upon placement, from the library component.
//determined, upon file load, by the first non-digits in the reference fields.
public:
EDA_SchComponentStruct( const wxPoint& pos = wxPoint( 0, 0 ) );
~EDA_SchComponentStruct( void ) { }
......@@ -142,7 +143,13 @@ public:
void SwapData( EDA_SchComponentStruct* copyitem );
virtual void Place( WinEDA_DrawFrame* frame, wxDC* DC );
//returns a unique ID, in the form of a path.
wxString GetPath( DrawSheetList* sheet);
const wxString GetRef( DrawSheetList* sheet );
void SetRef( DrawSheetList* sheet, wxString ref );
void ClearRefs();
#if defined(DEBUG)
/**
* Function Show
......
......@@ -60,7 +60,7 @@ SchematicGeneralLocateAndDisplay( bool IncludePin )
break;
case DRAW_LIB_ITEM_STRUCT_TYPE:
Pin = LocateAnyPin( m_CurrentScreen->EEDrawList, GetScreen()->m_Curseur, &LibItem );
Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, &LibItem );
if( Pin )
break; // Priority is probing a pin first
LibItem = (EDA_SchComponentStruct*) DrawStruct;
......@@ -68,7 +68,7 @@ SchematicGeneralLocateAndDisplay( bool IncludePin )
break;
default:
Pin = LocateAnyPin( m_CurrentScreen->EEDrawList, GetScreen()->m_Curseur, &LibItem );
Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, &LibItem );
break;
case COMPONENT_PIN_DRAW_TYPE:
......@@ -82,7 +82,7 @@ SchematicGeneralLocateAndDisplay( bool IncludePin )
Pin->Display_Infos( this );
if( LibItem )
Affiche_1_Parametre( this, 1,
LibItem->m_Field[REFERENCE].m_Text,
LibItem->GetRef(GetSheet()),
LibItem->m_Field[VALUE].m_Text,
CYAN );
......@@ -121,7 +121,7 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin )
wxString msg;
int ii;
DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, MARKERITEM );
DrawStruct = PickStruct( refpoint, GetScreen(), MARKERITEM );
if( DrawStruct )
{
DrawMarkerStruct* Marker = (DrawMarkerStruct*) DrawStruct;
......@@ -134,7 +134,7 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin )
return DrawStruct;
}
DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
DrawStruct = PickStruct( refpoint, GetScreen(),
NOCONNECTITEM );
if( DrawStruct )
{
......@@ -142,7 +142,7 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin )
return DrawStruct;
}
DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
DrawStruct = PickStruct( refpoint, GetScreen(),
JUNCTIONITEM );
if( DrawStruct )
{
......@@ -150,17 +150,17 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin )
return DrawStruct;
}
DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
DrawStruct = PickStruct( refpoint, GetScreen(),
WIREITEM | BUSITEM | RACCORDITEM );
if( DrawStruct ) // Search for a pin
{
Pin = LocateAnyPin( m_CurrentScreen->EEDrawList, refpoint, &LibItem );
Pin = LocateAnyPin( m_CurrentSheet->LastDrawList(), refpoint, &LibItem );
if( Pin )
{
Pin->Display_Infos( this );
if( LibItem )
Affiche_1_Parametre( this, 1,
LibItem->m_Field[REFERENCE].m_Text,
LibItem->GetRef(GetSheet()),
LibItem->m_Field[VALUE].m_Text,
CYAN );
}
......@@ -169,7 +169,7 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin )
return DrawStruct;
}
DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, FIELDCMPITEM );
DrawStruct = PickStruct( refpoint, GetScreen(), FIELDCMPITEM );
if( DrawStruct )
{
PartTextStruct* Field = (PartTextStruct*) DrawStruct;
......@@ -180,29 +180,29 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin )
}
/* search for a pin */
Pin = LocateAnyPin( m_CurrentScreen->EEDrawList, refpoint, &LibItem );
Pin = LocateAnyPin( m_CurrentSheet->LastDrawList(), refpoint, &LibItem );
if( Pin )
{
Pin->Display_Infos( this );
if( LibItem )
Affiche_1_Parametre( this, 1,
LibItem->m_Field[REFERENCE].m_Text,
LibItem->GetRef(GetSheet()),
LibItem->m_Field[VALUE].m_Text,
CYAN );
if( IncludePin == TRUE )
return LibItem;
}
DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList, LIBITEM );
DrawStruct = PickStruct( refpoint, GetScreen(), LIBITEM );
if( DrawStruct )
{
DrawStruct = LocateSmallestComponent( GetScreen() );
DrawStruct = LocateSmallestComponent( (SCH_SCREEN*)GetScreen() );
LibItem = (EDA_SchComponentStruct*) DrawStruct;
LibItem->Display_Infos( this );
return DrawStruct;
}
DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
DrawStruct = PickStruct( refpoint, GetScreen(),
SHEETITEM );
if( DrawStruct )
{
......@@ -211,7 +211,7 @@ SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, bool IncludePin )
}
// Recherche des autres elements
DrawStruct = PickStruct( refpoint, GetScreen()->EEDrawList,
DrawStruct = PickStruct( refpoint, GetScreen(),
SEARCHALL );
if( DrawStruct )
{
......@@ -228,17 +228,16 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels
/***********************************************************************/
{
wxSize delta;
int zoom = m_CurrentScreen->GetZoom();
SCH_SCREEN* screen = (SCH_SCREEN*)GetScreen();
int zoom = screen->GetZoom();
wxPoint curpos, oldpos;
int hotkey = 0;
ActiveScreen = (SCH_SCREEN*) m_CurrentScreen;
curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur;
curpos = m_CurrentScreen->m_MousePosition;
oldpos = m_CurrentScreen->m_Curseur;
delta.x = m_CurrentScreen->GetGrid().x / zoom;
delta.y = m_CurrentScreen->GetGrid().y / zoom;
delta.x = screen->GetGrid().x / zoom;
delta.y = screen->GetGrid().y / zoom;
if( delta.x <= 0 )
delta.x = 1;
......@@ -252,37 +251,37 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels
case EDA_PANNING_UP_KEY:
OnZoom( ID_ZOOM_PANNING_UP );
curpos = m_CurrentScreen->m_Curseur;
curpos = screen->m_Curseur;
break;
case EDA_PANNING_DOWN_KEY:
OnZoom( ID_ZOOM_PANNING_DOWN );
curpos = m_CurrentScreen->m_Curseur;
curpos = screen->m_Curseur;
break;
case EDA_PANNING_LEFT_KEY:
OnZoom( ID_ZOOM_PANNING_LEFT );
curpos = m_CurrentScreen->m_Curseur;
curpos = screen->m_Curseur;
break;
case EDA_PANNING_RIGHT_KEY:
OnZoom( ID_ZOOM_PANNING_RIGHT );
curpos = m_CurrentScreen->m_Curseur;
curpos = screen->m_Curseur;
break;
case EDA_ZOOM_IN_FROM_MOUSE:
OnZoom( ID_ZOOM_PLUS_KEY );
curpos = m_CurrentScreen->m_Curseur;
curpos = screen->m_Curseur;
break;
case EDA_ZOOM_OUT_FROM_MOUSE:
OnZoom( ID_ZOOM_MOINS_KEY );
curpos = m_CurrentScreen->m_Curseur;
curpos = screen->m_Curseur;
break;
case EDA_ZOOM_CENTER_FROM_MOUSE:
OnZoom( ID_ZOOM_CENTER_KEY );
curpos = m_CurrentScreen->m_Curseur;
curpos = screen->m_Curseur;
break;
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */
......@@ -315,22 +314,22 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels
}
/* Recalcul de la position du curseur schema */
m_CurrentScreen->m_Curseur = curpos;
screen->m_Curseur = curpos;
/* Placement sur la grille generale */
PutOnGrid( &m_CurrentScreen->m_Curseur );
PutOnGrid( &(screen->m_Curseur) );
if( m_CurrentScreen->IsRefreshReq() )
if( screen->IsRefreshReq() )
{
RedrawActiveWindow( DC, TRUE );
}
if( oldpos != m_CurrentScreen->m_Curseur )
if( oldpos != screen->m_Curseur )
{
curpos = m_CurrentScreen->m_Curseur;
m_CurrentScreen->m_Curseur = oldpos;
curpos = screen->m_Curseur;
screen->m_Curseur = oldpos;
DrawPanel->CursorOff( DC );
m_CurrentScreen->m_Curseur = curpos;
GetScreen()->m_Curseur = curpos;
DrawPanel->CursorOn( DC );
if( DrawPanel->ManageCurseur )
......@@ -341,9 +340,9 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels
if( hotkey )
{
if( m_CurrentScreen->GetCurItem()
&& m_CurrentScreen->GetCurItem()->m_Flags )
OnHotKey( DC, hotkey, m_CurrentScreen->GetCurItem() );
if( screen->GetCurItem()
&& screen->GetCurItem()->m_Flags )
OnHotKey( DC, hotkey, screen->GetCurItem() );
else
OnHotKey( DC, hotkey, NULL );
}
......
......@@ -98,7 +98,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( EDA_BaseStruct* DrawList, wxDC* DC
for( DanglingItem = ItemList; DanglingItem != NULL; DanglingItem = nextitem )
{
nextitem = DanglingItem->m_Pnext;
delete DanglingItem;
SAFE_DELETE( DanglingItem );
}
ItemList = RebuildEndList( DrawList );
......@@ -109,6 +109,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( EDA_BaseStruct* DrawList, wxDC* DC
switch( DrawItem->Type() )
{
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_HIER_LABEL_STRUCT_TYPE:
case DRAW_LABEL_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawLabelStruct*) DrawItem )
......@@ -146,7 +147,7 @@ LibDrawPin* WinEDA_SchematicFrame::LocatePinEnd( EDA_BaseStruct* DrawList,
const wxPoint& pos )
/********************************************************************/
/* Teste si le point de coordonnes pos est sur l'extrmit d'une PIN
/* Teste si le point de coordonn�es pos est sur l'extr�mit� d'une PIN
* retourne un pointeur sur la pin
* NULL sinon
*/
......@@ -280,7 +281,7 @@ wxPoint ReturnPinPhysicalPosition( LibDrawPin* Pin,
EDA_SchComponentStruct* DrawLibItem )
/****************************************************/
/* Retourne la position physique de la pin, qui dpend de l'orientation
/* Retourne la position physique de la pin, qui dpend de l'orientation
* du composant */
{
wxPoint PinPos = Pin->m_Pos;
......@@ -316,8 +317,9 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
break;
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_HIER_LABEL_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawGlobalLabelStruct*) DrawItem )
#define STRUCT ( (DrawLabelStruct*) DrawItem )
item = new DanglingEndHandle( LABEL_END );
item->m_Item = DrawItem;
......
......@@ -116,24 +116,28 @@ DrawPickedStruct * PickedItem, *PickedList = NULL;
for(DelStruct = GetScreen()->EEDrawList; DelStruct != NULL; DelStruct=DelStruct->Pnext)
DelStruct->m_Flags = 0;
BreakSegmentOnJunction( GetScreen() );
BreakSegmentOnJunction( (SCH_SCREEN*)GetScreen() );
DelStruct = GetScreen()->EEDrawList;
/* Locate all the wires, bus or junction under the mouse cursor, and put them in a list
of items to delete
*/
SCH_SCREEN* screen = (SCH_SCREEN*)GetScreen();
EDA_BaseStruct* savedEEDrawList = screen->EEDrawList;
while ( DelStruct &&
(DelStruct = PickStruct(GetScreen()->m_Curseur,
DelStruct, JUNCTIONITEM|WIREITEM|BUSITEM)) != NULL )
(DelStruct = PickStruct(screen->m_Curseur,
screen, JUNCTIONITEM|WIREITEM|BUSITEM)) != NULL )
{
DelStruct->m_Flags = SELECTEDNODE|STRUCT_DELETED;
/* Put this structure in the picked list: */
PickedItem = new DrawPickedStruct(DelStruct);
PickedItem->Pnext = PickedList;
PickedList = PickedItem;
DelStruct=DelStruct->Pnext;
screen->EEDrawList = DelStruct;
}
GetScreen()->EEDrawList = savedEEDrawList;
/* Mark all wires, junctions, .. connected to one of the item to delete
*/
if ( DeleteFullConnection )
......@@ -224,7 +228,7 @@ DrawPickedStruct * PickedItem, *PickedList = NULL;
if ( DelStruct->Type() != DRAW_LABEL_STRUCT_TYPE ) continue;
GetScreen()->m_Curseur = ((DrawTextStruct*)DelStruct)->m_Pos;
EDA_BaseStruct * TstStruct =
PickStruct(GetScreen()->m_Curseur, GetScreen()->EEDrawList,WIREITEM|BUSITEM);
PickStruct(GetScreen()->m_Curseur, GetScreen(),WIREITEM|BUSITEM);
if ( TstStruct && TstStruct->m_Flags & STRUCT_DELETED )
{
DelStruct->m_Flags |= STRUCT_DELETED;
......@@ -267,33 +271,33 @@ bool LocateAndDeleteItem(WinEDA_SchematicFrame * frame, wxDC * DC)
*/
{
EDA_BaseStruct * DelStruct;
SCH_SCREEN * screen = frame->GetScreen();
SCH_SCREEN * screen = (SCH_SCREEN*)(frame->GetScreen());
bool item_deleted = FALSE;
DelStruct = PickStruct(screen->m_Curseur,
screen->EEDrawList, MARKERITEM);
screen, MARKERITEM);
if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur,
screen->EEDrawList, JUNCTIONITEM);
screen, JUNCTIONITEM);
if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur,
screen->EEDrawList, NOCONNECTITEM);
screen, NOCONNECTITEM);
if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur,
screen->EEDrawList, RACCORDITEM);
screen, RACCORDITEM);
if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur,
screen->EEDrawList, WIREITEM|BUSITEM);
screen, WIREITEM|BUSITEM);
if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur,
screen->EEDrawList, DRAWITEM);
screen, DRAWITEM);
if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur,
screen->EEDrawList, TEXTITEM|LABELITEM);
screen, TEXTITEM|LABELITEM);
if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur,
screen->EEDrawList, LIBITEM);
screen, LIBITEM);
if( DelStruct == NULL ) DelStruct = PickStruct(screen->m_Curseur,
screen->EEDrawList, SHEETITEM);
screen, SHEETITEM);
if (DelStruct)
{
g_ItemToRepeat = NULL;
DeleteStruct(frame->DrawPanel, DC, DelStruct);
frame->TestDanglingEnds(frame->m_CurrentScreen->EEDrawList, DC);
frame->TestDanglingEnds(frame->GetScreen()->EEDrawList, DC);
frame->GetScreen()->SetModify();
item_deleted = TRUE;
}
......@@ -331,6 +335,7 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel;
if (DrawStruct->Type() == DRAW_SHEETLABEL_STRUCT_TYPE)
{ /* Cette stucture est rattachee a une feuille, et n'est pas
accessible par la liste globale directement */
//this structure has a sheet attached, which we must find.
DrawList = Screen->EEDrawList;
for ( ; DrawList != NULL; DrawList = DrawList->Pnext )
{
......@@ -342,7 +347,7 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel;
{
((DrawSheetStruct *) DrawList)->m_Label =
(DrawSheetLabelStruct *)SheetLabel->Pnext;
delete DrawStruct;
SAFE_DELETE( DrawStruct );
return;
}
else while( SheetLabel->Pnext )/* Examen de la liste dependante */
......@@ -351,7 +356,7 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel;
if( NextLabel == (DrawSheetLabelStruct*) DrawStruct )
{
SheetLabel->Pnext = (EDA_BaseStruct *)NextLabel->Pnext;
delete DrawStruct;
SAFE_DELETE( DrawStruct );
return;
}
SheetLabel = NextLabel;
......@@ -360,7 +365,6 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel;
return;
}
if (DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE)
{
PickedList = (DrawPickedStruct *) DrawStruct;
......@@ -369,7 +373,7 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel;
if (PickedList->m_PickedStruct == Screen->EEDrawList)
{
Screen->EEDrawList = Screen->EEDrawList->Pnext;
delete DrawStruct;
SAFE_DELETE( DrawStruct );
}
else
{
......@@ -379,7 +383,7 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel;
if (DrawList->Pnext == PickedList->m_PickedStruct)
{
DrawList->Pnext = DrawList->Pnext->Pnext;
delete DrawStruct;
SAFE_DELETE( DrawStruct );
return;
}
DrawList = DrawList->Pnext;
......@@ -393,7 +397,7 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel;
if (DrawStruct == Screen->EEDrawList)
{
Screen->EEDrawList = DrawStruct->Pnext;
delete DrawStruct;
SAFE_DELETE( DrawStruct );
}
else
{
......@@ -403,7 +407,7 @@ DrawSheetLabelStruct* SheetLabel, *NextLabel;
if (DrawList->Pnext == DrawStruct)
{
DrawList->Pnext = DrawStruct->Pnext;
delete DrawStruct;
SAFE_DELETE( DrawStruct );
return;
}
DrawList = DrawList->Pnext;
......@@ -423,7 +427,7 @@ SCH_SCREEN * screen;
EDA_BaseStruct * DrawStruct, * NextStruct;
DrawMarkerStruct * Marker;
EDA_ScreenList ScreenList(NULL);
EDA_ScreenList ScreenList;
for ( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
{
for ( DrawStruct = screen->EEDrawList; DrawStruct != NULL; DrawStruct = NextStruct)
......@@ -471,7 +475,7 @@ LibEDA_BaseStruct *PreviousDrawItem;
if( LibEntry->m_Drawings == DrawItem )
{
LibEntry->m_Drawings = DrawItem->Next();
delete DrawItem;
SAFE_DELETE( DrawItem );
}
else /* Cas des autres items */
......@@ -480,7 +484,7 @@ LibEDA_BaseStruct *PreviousDrawItem;
if(PreviousDrawItem->Pnext == DrawItem)
{
PreviousDrawItem->Pnext = DrawItem->Pnext;
delete DrawItem; break;
SAFE_DELETE( DrawItem ); break;
}
PreviousDrawItem = PreviousDrawItem->Next();
}
......@@ -488,7 +492,7 @@ LibEDA_BaseStruct *PreviousDrawItem;
else /* Structure non reliee a un composant */
{
delete DrawItem;
SAFE_DELETE( DrawItem );
}
}
......
......@@ -37,37 +37,40 @@ wxString msg;
}
/* effacement du sous schema correspondant */
if( FirstSheet->IsModify() && confirm_deletion )
if( FirstSheet->m_s->IsModify() && confirm_deletion )
{
msg.Printf( _("Sheet %s (file %s) modified. Save it?"),
FirstSheet->m_SheetName.GetData(),
FirstSheet->m_FileName.GetData());
if( IsOK(NULL, msg) )
{
frame->SaveEEFile(FirstSheet, FILE_SAVE_AS);
frame->SaveEEFile(FirstSheet->m_s, FILE_SAVE_AS);
}
}
/* free the sub hierarchy */
EEDrawList = FirstSheet->EEDrawList;
while (EEDrawList != NULL)
{
DrawStruct = EEDrawList;
EEDrawList = EEDrawList->Pnext;
if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE)
if(FirstSheet->m_s){
EEDrawList = FirstSheet->m_s->EEDrawList;
while (EEDrawList != NULL)
{
DeleteSubHierarchy((DrawSheetStruct *) DrawStruct, confirm_deletion);
DrawStruct = EEDrawList;
EEDrawList = EEDrawList->Pnext;
if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE)
{
DeleteSubHierarchy((DrawSheetStruct *) DrawStruct, confirm_deletion);
}
}
/* Effacement des elements de la feuille courante */
FirstSheet->m_s->FreeDrawList();
}
/* Effacement des elements de la feuille courante */
FirstSheet->FreeDrawList();
}
/*********************************************************************/
void ClearDrawList(EDA_BaseStruct *DrawList, bool confirm_deletion)
//void ClearDrawList(EDA_BaseStruct *DrawList, bool confirm_deletion)
/********************************************************************/
/* free the draw list DrawList and the subhierarchies */
//this is redundant -- use FreeDrawList, a member of SCH_SCREEN
/*
{
EDA_BaseStruct *DrawStruct;
......@@ -84,7 +87,7 @@ EDA_BaseStruct *DrawStruct;
delete DrawStruct;
}
}
*/
/********************************************************************/
bool ClearProjectDrawList(SCH_SCREEN * screen, bool confirm_deletion)
/********************************************************************/
......@@ -94,11 +97,10 @@ bool ClearProjectDrawList(SCH_SCREEN * screen, bool confirm_deletion)
{
if ( screen == NULL ) return(TRUE);
ClearDrawList(screen->EEDrawList, confirm_deletion);
screen->EEDrawList = NULL;
screen->FreeDrawList();
/* Clear the screen datas */
screen->m_SheetNumber = screen->m_NumberOfSheet = 1;
screen->m_ScreenNumber = screen->m_NumberOfScreen = 1;
screen->m_Title.Empty();
screen->m_Revision.Empty();
screen->m_Company.Empty();
......
This diff is collapsed.
......@@ -131,8 +131,8 @@ public:
////@end WinEDA_Build_BOM_Frame member function declarations
void GenereListeOfItems(const wxString & FullFileName);
void CreateExportList(const wxString & FullFileName);
int PrintListeCmpByRef( FILE * f, EDA_BaseStruct ** List, int NbItems, bool CompactForm = FALSE );
int PrintListeCmpByVal( FILE *f, EDA_BaseStruct **List, int NbItems);
int PrintListeCmpByRef( FILE * f, ListComponent * List, int NbItems, bool CompactForm = FALSE );
int PrintListeCmpByVal( FILE *f, ListComponent * List, int NbItems);
void PrintFieldData(FILE * f, EDA_SchComponentStruct * DrawLibItem, bool CompactForm = FALSE);
void SavePreferences();
......
......@@ -67,6 +67,10 @@ wxString msg;
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
SetTitle(_("Global Label properties"));
break;
case DRAW_HIER_LABEL_STRUCT_TYPE:
SetTitle(_("Hierarchal Label properties"));
break;
case DRAW_LABEL_STRUCT_TYPE:
SetTitle(_("Label properties"));
......@@ -155,7 +159,7 @@ void WinEDA_LabelPropertiesFrame::CreateControls()
m_TextShapeStrings.Add(_("Bidi"));
m_TextShapeStrings.Add(_("TriState"));
m_TextShapeStrings.Add(_("Passive"));
m_TextShape = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Glabel Shape:"), wxDefaultPosition, wxDefaultSize, m_TextShapeStrings, 1, wxRA_SPECIFY_COLS );
m_TextShape = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("label Shape:"), wxDefaultPosition, wxDefaultSize, m_TextShapeStrings, 1, wxRA_SPECIFY_COLS );
m_TextShape->SetSelection(0);
m_TextShape->Show(false);
itemBoxSizer6->Add(m_TextShape, 0, wxALIGN_TOP|wxALL, 5);
......@@ -185,7 +189,8 @@ void WinEDA_LabelPropertiesFrame::CreateControls()
m_TextShape->SetValidator( wxGenericValidator(& m_CurrentText->m_Shape) );
////@end WinEDA_LabelPropertiesFrame content construction
if (m_CurrentText->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE )
if (m_CurrentText->Type() == DRAW_GLOBAL_LABEL_STRUCT_TYPE ||
m_CurrentText->Type() == DRAW_HIER_LABEL_STRUCT_TYPE)
m_TextShape->Show(true);
}
......
......@@ -433,10 +433,10 @@ wxString msg;
break;
}
if ( m_Parent->m_CurrentScreen )
if ( m_Parent->GetScreen() )
{
if ( setgrid ) m_Parent->m_CurrentScreen->SetGrid(grid);
m_Parent->m_CurrentScreen->SetRefreshReq();
if ( setgrid ) m_Parent->GetScreen()->SetGrid(grid);
m_Parent->GetScreen()->SetRefreshReq();
}
}
......@@ -14,28 +14,6 @@
#include "protos.h"
/**********************************************************/
SCH_SCREEN * CreateNewScreen(WinEDA_DrawFrame * frame_source,
SCH_SCREEN * OldScreen, int TimeStamp)
/**********************************************************/
/* Routine de creation ( par allocation memoire ) d'un nouvel ecran
cet ecran est en chainage arriere avec OldScreen
la valeur TimeStamp est attribuee au parametre NewScreen->TimeStamp
*/
{
SCH_SCREEN * NewScreen;
NewScreen = new SCH_SCREEN(NULL, frame_source, SCHEMATIC_FRAME);
NewScreen->SetRefreshReq();
if(OldScreen) NewScreen->m_Company = OldScreen->m_Company;
NewScreen->m_TimeStamp = TimeStamp;
NewScreen->Pback = OldScreen;
return(NewScreen);
}
/**************************************/
void SetFlagModify(BASE_SCREEN * Window)
/**************************************/
......
......@@ -29,15 +29,15 @@ enum id_libedit {
/* Variables locales */
extern int CurrentUnit;
/* Classe de la frame des proprits d'un composant en librairie */
/* Classe de la frame des propri�t�s d'un composant en librairie */
/* Cette classe genere une fenetre type NoteBook, pour l'edition des proprits
/* Cette classe genere une fenetre type NoteBook, pour l'edition des propri�t�s
* d'un composant le librairie.
* On peut diter:
* On peut �diter:
* Texte dimensions et justification de tous les champs (Ref, Val, et autres champs)
* Documentation et mots clefs
* Nombre de part par boitier
* et autres proprirs gnrales
* et autres propri�r�s g�n�rales
*/
#include "dialog_edit_component_in_lib.cpp"
......@@ -653,7 +653,7 @@ void WinEDA_PartPropertiesFrame::PartPropertiesAccept( wxCommandEvent& event )
Close(); return;
}
m_Parent->m_CurrentScreen->SetModify();
m_Parent->GetScreen()->SetModify();
m_Parent->SaveCopyInUndoList( CurrentLibEntry );
CopyPanelFieldToData();
......@@ -761,7 +761,7 @@ void WinEDA_PartPropertiesFrame::PartPropertiesAccept( wxCommandEvent& event )
{
if( ii < FIELD1 || Field->m_Name.IsEmpty() )
{
delete Field;
SAFE_DELETE( Field );
if( previousField )
previousField->Pnext = NextField;
else
......@@ -1056,8 +1056,8 @@ bool WinEDA_PartPropertiesFrame::ChangeNbUnitsPerPackage( int MaxUnit )
bool WinEDA_PartPropertiesFrame::SetUnsetConvert()
/*****************************************************/
/* cre ou efface (selon option AsConvert) les lments
* de la reprsentation convertie d'un composant
/* cr�e ou efface (selon option AsConvert) les �l�ments
* de la repr�sentation convertie d'un composant
*/
{
int FlagDel = 0;
......@@ -1096,7 +1096,7 @@ bool WinEDA_PartPropertiesFrame::SetUnsetConvert()
}
else /* Representation convertie a supprimer */
{
/* Traitement des elements supprimer */
/* Traitement des elements � supprimer */
if( CurrentLibEntry )
DrawItem = CurrentLibEntry->m_Drawings;
for( ; DrawItem != NULL; DrawItem = NextDrawItem )
......
......@@ -88,7 +88,10 @@ void WinEDA_ComponentPropertiesFrame::InitBuffers()
for( ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ )
{
m_FieldName[ii] = m_Cmp->ReturnFieldName( ii );
m_FieldText[ii] = m_Cmp->m_Field[ii].m_Text;
if(ii == REFERENCE)
m_FieldText[ii] = m_Cmp->GetRef(m_Parent->GetSheet());
else
m_FieldText[ii] = m_Cmp->m_Field[ii].m_Text;
m_FieldSize[ii] = m_Cmp->m_Field[ii].m_Size.x;
m_FieldFlags[ii] =
(m_Cmp->m_Field[ii].m_Attributs & TEXT_NO_VISIBLE) ? 0 : 1;
......@@ -115,8 +118,9 @@ void WinEDA_ComponentPropertiesFrame::CopyDataToPanelField()
{
int fieldId = m_CurrentFieldId;
for( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ )
for( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ ){
m_FieldSelection->SetString( ii, m_FieldName[ii] );
}
if( fieldId == VALUE && m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER )
m_FieldTextCtrl->Enable( FALSE );
......@@ -343,7 +347,7 @@ void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept( wxCommandEvent&
(m_ConvertButt->GetValue() == TRUE) ?
m_Cmp->m_Convert = 2 : m_Cmp->m_Convert = 1;
//Mise a jour de la selection de l'lment dans le boitier
//Mise a jour de la selection de l'�l�ment dans le boitier
if( m_Cmp->m_Multi )
m_Cmp->m_Multi = m_SelectUnit->GetSelection() + 1;
......@@ -382,13 +386,13 @@ void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept( wxCommandEvent&
}
// Mise a jour des textes
// Mise a jour des textes (update the texts)
for( int ii = REFERENCE; ii < NUMBER_OF_FIELDS; ii++ )
{
if( ii == REFERENCE ) // la reference ne peut etre vide
{
if( !m_FieldText[ii].IsEmpty() )
m_Cmp->m_Field[ii].m_Text = m_FieldText[ii];
m_Cmp->SetRef(m_Parent->GetSheet(), m_FieldText[ii]);
}
else if( ii == VALUE ) // la valeur ne peut etre vide et ne peut etre change sur un POWER
{
......@@ -421,10 +425,10 @@ void WinEDA_ComponentPropertiesFrame::ComponentPropertiesAccept( wxCommandEvent&
m_Cmp->m_Field[ii].m_Pos.y += cmp_pos.y;
}
m_Parent->m_CurrentScreen->SetModify();
m_Parent->GetScreen()->SetModify();
RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE );
m_Parent->TestDanglingEnds( m_Parent->m_CurrentScreen->EEDrawList, &dc );
m_Parent->TestDanglingEnds( m_Parent->GetScreen()->EEDrawList, &dc );
EndModal( 0 );
}
......@@ -454,7 +458,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( PartTextStruct* Field, wxDC* DC )
int x1, y1;
EDA_SchComponentStruct* Cmp = (EDA_SchComponentStruct*) CurrentField->m_Parent;
delete g_ItemToUndoCopy;
SAFE_DELETE( g_ItemToUndoCopy );
g_ItemToUndoCopy = Cmp->GenCopy();
pos = Cmp->m_Pos;
......@@ -476,7 +480,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( PartTextStruct* Field, wxDC* DC )
newpos.y = pos.y + Cmp->m_Transform[0][1] * x1 + Cmp->m_Transform[1][1] * y1;
DrawPanel->CursorOff( DC );
m_CurrentScreen->m_Curseur = newpos;
GetScreen()->m_Curseur = newpos;
DrawPanel->MouseToCursorSchema();
OldPos = Field->m_Pos;
......@@ -561,6 +565,9 @@ void WinEDA_SchematicFrame::EditCmpFieldText( PartTextStruct* Field, wxDC* DC )
Field->m_Size.x = Field->m_Size.y = TextFieldSize;
}
Field->m_Text = newtext;
if( FieldNumber == REFERENCE ){
Cmp->SetRef(GetSheet(), newtext);
}
}
else /* Nouveau texte NULL */
{
......@@ -580,7 +587,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( PartTextStruct* Field, wxDC* DC )
DrawTextField( DrawPanel, DC, Field, flag, g_XorMode );
Cmp->Display_Infos( this );
m_CurrentScreen->SetModify();
GetScreen()->SetModify();
}
......@@ -633,7 +640,7 @@ static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC )
DrawTextField( Panel, DC, CurrentField, Multiflag, GR_DEFAULT_DRAWMODE );
}
CurrentField = NULL;
delete g_ItemToUndoCopy; g_ItemToUndoCopy = NULL;
SAFE_DELETE( g_ItemToUndoCopy );
}
......@@ -725,7 +732,6 @@ void WinEDA_SchematicFrame::EditComponentReference( EDA_SchComponentStruct* Cmp,
/**************************************************************************************************/
/* Edit the component text reference*/
{
wxString msg;
EDA_LibComponentStruct* Entry;
int flag = 0;
......@@ -739,19 +745,18 @@ void WinEDA_SchematicFrame::EditComponentReference( EDA_SchComponentStruct* Cmp,
if( Entry->m_UnitCount > 1 )
flag = 1;
PartTextStruct* TextField = &Cmp->m_Field[REFERENCE];
wxString ref = Cmp->GetRef(GetSheet());
Get_Message( _( "Reference" ), ref, this );
msg = TextField->m_Text;
Get_Message( _( "Reference" ), msg, this );
if( !msg.IsEmpty() ) // New text entered
if( !ref.IsEmpty() ) // New text entered
{
/* save old cmp in undo list if not already in edit, or moving ... */
if( Cmp->m_Flags == 0 )
SaveCopyInUndoList( Cmp, IS_CHANGED );
Cmp->SetRef(GetSheet(), ref);
DrawTextField( DrawPanel, DC, &Cmp->m_Field[REFERENCE], flag, g_XorMode );
TextField->m_Text = msg;
Cmp->SetRef(GetSheet(), ref );
DrawTextField( DrawPanel, DC, &Cmp->m_Field[REFERENCE], flag,
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
GetScreen()->SetModify();
......@@ -794,7 +799,7 @@ void WinEDA_SchematicFrame::EditComponentValue( EDA_SchComponentStruct* Cmp, wxD
TextField->m_Text = msg;
DrawTextField( DrawPanel, DC, &Cmp->m_Field[VALUE], flag,
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
m_CurrentScreen->SetModify();
GetScreen()->SetModify();
}
Cmp->Display_Infos( this );
......@@ -848,7 +853,7 @@ void WinEDA_SchematicFrame::EditComponentFootprint( EDA_SchComponentStruct* Cmp,
DrawTextField( DrawPanel, DC, &Cmp->m_Field[FOOTPRINT], flag,
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
m_CurrentScreen->SetModify();
GetScreen()->SetModify();
Cmp->Display_Infos( this );
}
......@@ -896,7 +901,7 @@ void WinEDA_ComponentPropertiesFrame::SetInitCmp( wxCommandEvent& event )
m_Cmp->SetRotationMiroir( CMP_NORMAL );
m_Parent->m_CurrentScreen->SetModify();
m_Parent->GetScreen()->SetModify();
RedrawOneStruct( m_Parent->DrawPanel, &dc, m_Cmp, GR_DEFAULT_DRAWMODE );
EndModal( 1 );
......
......@@ -87,6 +87,7 @@ void WinEDA_SchematicFrame::StartMoveTexte( DrawTextStruct* TextStruct, wxDC* DC
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_HIER_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
ItemInitialPosition = TextStruct->m_Pos;
OldSize = TextStruct->m_Size;
......@@ -98,7 +99,7 @@ void WinEDA_SchematicFrame::StartMoveTexte( DrawTextStruct* TextStruct, wxDC* DC
}
DrawPanel->CursorOff( DC );
m_CurrentScreen->m_Curseur = ItemInitialPosition;
GetScreen()->m_Curseur = ItemInitialPosition;
DrawPanel->MouseToCursorSchema();
GetScreen()->SetModify();
......@@ -142,7 +143,7 @@ void WinEDA_SchematicFrame::ChangeTextOrient( DrawTextStruct* TextStruct, wxDC*
{
if( TextStruct == NULL )
TextStruct = (DrawTextStruct*) PickStruct( GetScreen()->m_Curseur,
GetScreen()->EEDrawList, TEXTITEM | LABELITEM );
GetScreen(), TEXTITEM | LABELITEM );
if( TextStruct == NULL )
return;
......@@ -159,6 +160,7 @@ void WinEDA_SchematicFrame::ChangeTextOrient( DrawTextStruct* TextStruct, wxDC*
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_HIER_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
TextStruct->m_Orient++;
TextStruct->m_Orient &= 3;
......@@ -190,15 +192,21 @@ EDA_BaseStruct* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
switch( type )
{
case LAYER_NOTES:
NewText = new DrawTextStruct( m_CurrentScreen->m_Curseur );
NewText = new DrawTextStruct( GetScreen()->m_Curseur );
break;
case LAYER_LOCLABEL:
NewText = new DrawLabelStruct( m_CurrentScreen->m_Curseur );
NewText = new DrawLabelStruct( GetScreen()->m_Curseur );
break;
case LAYER_HIERLABEL:
NewText = new DrawHierLabelStruct(GetScreen()->m_Curseur );
NewText->m_Shape = s_DefaultShapeGLabel;
NewText->m_Orient = s_DefaultOrientGLabel;
break;
case LAYER_GLOBLABEL:
NewText = new DrawGlobalLabelStruct( m_CurrentScreen->m_Curseur );
NewText = new DrawGlobalLabelStruct(GetScreen()->m_Curseur );
NewText->m_Shape = s_DefaultShapeGLabel;
NewText->m_Orient = s_DefaultOrientGLabel;
break;
......@@ -216,11 +224,11 @@ EDA_BaseStruct* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
if( NewText->m_Text.IsEmpty() )
{
delete NewText;
SAFE_DELETE( NewText );
return NULL;
}
if( type == LAYER_GLOBLABEL )
if( type == LAYER_GLOBLABEL || type == LAYER_HIERLABEL)
{
s_DefaultShapeGLabel = NewText->m_Shape;
s_DefaultOrientGLabel = NewText->m_Orient;
......@@ -230,7 +238,7 @@ EDA_BaseStruct* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
DrawPanel->ManageCurseur = ShowWhileMoving;
DrawPanel->ForceCloseManageCurseur = ExitMoveTexte;
m_CurrentScreen->SetCurItem( NewText );
GetScreen()->SetCurItem( NewText );
return NewText;
}
......@@ -252,6 +260,7 @@ static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_HIER_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
( (DrawTextStruct*) TextStruct )->m_Pos = panel->GetScreen()->m_Curseur;
break;
......@@ -269,7 +278,7 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
/*************************************************************/
/* Abort function for the command move text */
{
SCH_SCREEN* screen = (SCH_SCREEN*) Panel->m_Parent->m_CurrentScreen;
SCH_SCREEN* screen = (SCH_SCREEN*) Panel->m_Parent->GetScreen();
EDA_BaseStruct* Struct = screen->GetCurItem();
g_ItemToRepeat = NULL;
......@@ -286,7 +295,7 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
if( Struct->m_Flags & IS_NEW )
{
delete Struct;
SAFE_DELETE( Struct );
screen->SetCurItem( NULL );
}
else /* this was a move command on an "old" text: restore its old settings. */
......@@ -295,6 +304,7 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
{
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_HIER_LABEL_STRUCT_TYPE:
case DRAW_TEXT_STRUCT_TYPE:
{
DrawTextStruct* Text = (DrawTextStruct*) Struct;
......@@ -336,9 +346,11 @@ void WinEDA_SchematicFrame::ConvertTextType( DrawTextStruct* Text,
break;
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
newtext = new DrawGlobalLabelStruct( Text->m_Pos, Text->m_Text );
newtext = new DrawGlobalLabelStruct(Text->m_Pos, Text->m_Text );
break;
case DRAW_HIER_LABEL_STRUCT_TYPE:
newtext = new DrawHierLabelStruct(Text->m_Pos, Text->m_Text );
break;
case DRAW_TEXT_STRUCT_TYPE:
newtext = new DrawTextStruct( Text->m_Pos, Text->m_Text );
break;
......@@ -381,13 +393,12 @@ void WinEDA_SchematicFrame::ConvertTextType( DrawTextStruct* Text,
{
Text->m_Flags = 0;
DeleteStruct( DrawPanel, DC, Text );
m_CurrentScreen->SetCurItem( NULL );
GetScreen()->SetCurItem( NULL );
g_ItemToRepeat = NULL;
}
GetScreen()->SetCurItem( newtext );
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = NULL;
SAFE_DELETE( g_ItemToUndoCopy );
DrawPanel->CursorOff( DC ); // Erase schematic cursor
......
......@@ -52,7 +52,7 @@ wxString FullFileName;
case ID_CONFIG_READ:
{
wxString mask( wxT("*") ); mask += g_Prj_Config_Filename_ext;
FullFileName = ScreenSch->m_FileName;
FullFileName = g_RootSheet->m_s->m_FileName;
ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext );
FullFileName = EDA_FileSelector(_("Read config file"),
......@@ -142,7 +142,7 @@ wxString FullFileName;
bool IsRead = TRUE;
wxArrayString liblist_tmp = g_LibName_List;
if ( CfgFileName.IsEmpty() ) FullFileName = ScreenSch->m_FileName;
if ( CfgFileName.IsEmpty() ) FullFileName = g_RootSheet->m_s->m_FileName;
else FullFileName = CfgFileName;
g_LibName_List.Clear();
......@@ -185,7 +185,7 @@ wxString FullFileName;
wxString mask( wxT("*") );
mask += g_Prj_Config_Filename_ext;
FullFileName = ScreenSch->m_FileName.AfterLast('/') /*ConfigFileName*/;
FullFileName = g_RootSheet->m_s->m_FileName.AfterLast('/') /*ConfigFileName*/;
ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext );
path = wxGetCwd();
......
......@@ -27,6 +27,7 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
/* Routine de Trace de segments ( WIRES, BUS ) pour lesquels chaque segment
* est une structure.
*/
// NOT USED!!!@!@!
{
DrawSegmentStruct* oldsegment, * newsegment;
wxPoint pos = GetScreen()->m_Curseur;
......@@ -84,7 +85,7 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
GetScreen()->ManageCurseur( DrawPanel, DC, FALSE );
oldsegment->m_EndIsDangling = FALSE;
/* Creation du segment suivant ou fin de trac si point sur pin, jonction ...*/
/* Creation du segment suivant ou fin de trac si point sur pin, jonction ...*/
if( IsTerminalPoint( GetScreen(), oldsegment->m_End, oldsegment->m_Layer ) )
{
EndSegment( DC ); return;
......@@ -385,6 +386,8 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_HIER_LABEL_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawLabelStruct*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
......@@ -396,19 +399,6 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
STRUCT->m_Text = Line;
break;
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawGlobalLabelStruct*) g_ItemToRepeat )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos.x += g_RepeatStep.x; ox = STRUCT->m_Pos.x;
STRUCT->m_Pos.y += g_RepeatStep.y; oy = STRUCT->m_Pos.y;
/*** Increment du numero de label ***/
strcpy( Line, STRUCT->GetText() );
IncrementLabelMember( Line );
STRUCT->m_Text = Line;
break;
case DRAW_SEGMENT_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawSegmentStruct*) g_ItemToRepeat )
......@@ -479,10 +469,10 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
* - type WIRE, si il y a
* - une jonction
* - ou une pin
* - ou une extrmit unique de fil
* - ou une extr�mit� unique de fil
*
* - type BUS, si il y a
* - ou une extrmit unique de BUS
* - ou une extr�mit� unique de BUS
*/
{
EDA_BaseStruct* item;
......
......@@ -193,7 +193,7 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC,
Field->m_HJustify, Field->m_VJustify, LineWidth );
}
// Trac de l'ancre
// Trac de l'ancre
int len = 3 * panel->GetZoom();
GRLine( &panel->m_ClipBox, DC, posX, posY - len, posX, posY + len, 0, color );
GRLine( &panel->m_ClipBox, DC, posX - len, posY, posX + len, posY, 0, color );
......@@ -212,7 +212,7 @@ void EDA_SchComponentStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
bool dummy = FALSE;
if( ( Entry = FindLibPart( m_ChipName.GetData(), wxEmptyString, FIND_ROOT ) ) == NULL )
{ /* composant non trouv, on affiche un composant "dummy" */
{ /* composant non trouv, on affiche un composant "dummy" */
dummy = TRUE;
if( DummyCmp == NULL )
CreateDummyCmp();
......@@ -587,8 +587,8 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
LibDrawPin* Pin = (LibDrawPin*) DEntry;
if( Pin->m_Attributs & PINNOTDRAW )
{
if( (ActiveScreen->m_Type == SCHEMATIC_FRAME)
&& !g_ShowAllPins )
if( /*(GetScreen()->m_Type == SCHEMATIC_FRAME )
&&*/ !g_ShowAllPins )
break;
}
......
......@@ -91,9 +91,9 @@ LibraryStruct* LoadLibraryName( WinEDA_DrawFrame* frame,
ChangeFileNameExt( FullFileName, DOC_EXT );
LoadDocLib( frame, FullFileName, NewLib->m_Name );
}
else
delete NewLib;
else{
SAFE_DELETE( NewLib );
}
fclose( f );
return NewLib;
}
......@@ -237,7 +237,7 @@ void FreeCmpLibrary( wxWindow* frame, const wxString& LibName )
TempLib->m_Pnext = TempLib->m_Pnext->m_Pnext;
}
delete Lib;
SAFE_DELETE( Lib );
/* The removed librairy can be the current library in libedit.
* If so, clear the current library in libedit */
......@@ -483,7 +483,7 @@ EDA_LibComponentStruct* Read_Component_Definition( WinEDA_DrawFrame* frame, char
Msg.Printf( wxT( " Error at line %d of library \n\"%s\",\nlibrary not loaded" ),
*LineNum, currentLibraryName.GetData() );
DisplayError( frame, Msg );
delete LibEntry;
SAFE_DELETE( LibEntry );
return NULL;
}
}
......@@ -604,7 +604,7 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
if( !Error )
{ /* Convert '~' to spaces. */
Text->m_Text = CONV_FROM_UTF8( Buffer );
Text->m_Text.Replace( wxT( "~" ), wxT( " " ) ); // Les espaces sont restitus
Text->m_Text.Replace( wxT( "~" ), wxT( " " ) ); // Les espaces sont restitus
}
}
break;
......@@ -780,7 +780,7 @@ static LibEDA_BaseStruct* GetDrawEntry( WinEDA_DrawFrame* frame, FILE* f, char*
MsgLine.Printf( wxT( "Error in %c DRAW command in line %d, aborted." ),
Line[0], *LineNum );
DisplayError( frame, MsgLine );
delete New;
SAFE_DELETE( New );
/* FLush till end of draw: */
do {
......@@ -1119,8 +1119,8 @@ static int SortItemsFct( const void* ref, const void* item );
void EDA_LibComponentStruct::SortDrawItems()
/*******************************************/
/* Trie les lments graphiques d'un composant lib pour amliorer
* le trac:
/* Trie les �l�ments graphiques d'un composant lib pour am�liorer
* le trac:
* items remplis en premier, pins en dernier
* En cas de superposition d'items, c'est plus lisible
*/
......
/****************************************/
/* Module to load/save EESchema files. */
/****************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "id.h"
static void LoadSubHierarchy( WinEDA_SchematicFrame* frame, EDA_BaseStruct* DrawList );
/* Variables locales */
/************************************************************************************/
int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNew )
/************************************************************************************/
/*
* Load an entire project ( shcematic root file and its subhierarchies, the configuration and the libs
* which are not already loaded)
*/
{
SCH_SCREEN* screen;
wxString FullFileName, msg;
bool LibCacheExist = FALSE;
EDA_ScreenList ScreenList( NULL );
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
{
if( screen->IsModify() )
break;
}
if( screen )
{
if( !IsOK( this, _( "Clear Schematic Hierarchy (modified!)?" ) ) )
return FALSE;
if( ScreenSch->m_FileName != g_DefaultSchematicFileName )
SetLastProject( ScreenSch->m_FileName );
}
screen = ScreenSch;
FullFileName = FileName;
if( ( FullFileName.IsEmpty() ) && !IsNew )
{
wxString mask = wxT( "*" ) + g_SchExtBuffer;
FullFileName = EDA_FileSelector( _( "Schematic files:" ),
wxEmptyString, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_SchExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
wxFD_OPEN,
TRUE
);
if( FullFileName.IsEmpty() )
return FALSE;
}
if( ClearProjectDrawList( screen, TRUE ) == FALSE )
return 1;
ActiveScreen = m_CurrentScreen = screen = ScreenSch;
ScreenSch->ClearUndoRedoList();
screen->SetCurItem( NULL );
wxSetWorkingDirectory( wxPathOnly( FullFileName ) );
m_CurrentScreen->m_FileName = FullFileName;
Affiche_Message( wxEmptyString );
MsgPanel->EraseMsgBox();
memset( &g_EESchemaVar, 0, sizeof(g_EESchemaVar) );
m_CurrentScreen->ClrModify();
m_CurrentScreen->Pnext = NULL;
if( IsNew )
{
screen->m_CurrentSheet = &g_Sheet_A4;
screen->SetZoom( 32 );
screen->m_SheetNumber = screen->m_NumberOfSheet = 1;
screen->m_Title = wxT( "noname.sch" );
m_CurrentScreen->m_FileName = screen->m_Title;
screen->m_Company.Empty();
screen->m_Commentaire1.Empty();
screen->m_Commentaire2.Empty();
screen->m_Commentaire3.Empty();
screen->m_Commentaire4.Empty();
Read_Config( wxEmptyString, TRUE );
Zoom_Automatique( TRUE );
ReDrawPanel();
return 1;
}
// Rechargement de la configuration:
msg = _( "Ready\nWorking dir: \n" ) + wxGetCwd();
PrintMsg( msg );
Read_Config( wxEmptyString, FALSE );
// Delete old caches.
LibraryStruct* nextlib, * lib = g_LibraryList;
for( ; lib != NULL; lib = nextlib )
{
nextlib = lib->m_Pnext;
if( lib->m_IsLibCache )
FreeCmpLibrary( this, lib->m_Name );
}
if( IsNew )
{
ReDrawPanel();
return 1;
}
// Loading the project library cache
wxString FullLibName;
wxString shortfilename;
wxSplitPath( ScreenSch->m_FileName, NULL, &shortfilename, NULL );
FullLibName << wxT( "." ) << STRING_DIR_SEP << shortfilename << wxT( ".cache" ) <<
g_LibExtBuffer;
if( wxFileExists( FullLibName ) )
{
wxString libname;
libname = FullLibName;
ChangeFileNameExt( libname, wxEmptyString );
msg = wxT( "Load " ) + FullLibName;
LibraryStruct* LibCache = LoadLibraryName( this, FullLibName, libname );
if( LibCache )
{
LibCache->m_IsLibCache = TRUE;
msg += wxT( " OK" );
}
else
msg += wxT( " ->Error" );
PrintMsg( msg );
LibCacheExist = TRUE;
}
if( !wxFileExists( ScreenSch->m_FileName ) && !LibCacheExist ) // Nouveau projet prpbablement
{
msg.Printf( _( "File %s not found (new project ?)" ),
ScreenSch->m_FileName.GetData() );
DisplayInfo( this, msg, 20 );
return -1;
}
if( LoadOneEEFile( ScreenSch, ScreenSch->m_FileName ) == FALSE )
return 0;
/* load all subhierarchies fond in current list and new loaded list */
LoadSubHierarchy( this, ScreenSch->EEDrawList );
/* Reaffichage ecran de base (ROOT) si necessaire */
ActiveScreen = ScreenSch;
Zoom_Automatique( FALSE );
return 1;
}
/*******************************************************************************/
void LoadSubHierarchy( WinEDA_SchematicFrame* frame, EDA_BaseStruct* DrawList )
/*******************************************************************************/
/* load subhierarcy when sheets are found in DrawList
* recursive function.
*/
{
EDA_BaseStruct* EEDrawList = DrawList;
while( EEDrawList )
{
if( EEDrawList->Type() == DRAW_SHEET_STRUCT_TYPE )
{
#undef STRUCT
#define STRUCT ( (DrawSheetStruct*) EEDrawList )
int timestamp = STRUCT->m_TimeStamp;
if( timestamp == 0 )
{
timestamp = GetTimeStamp();
STRUCT->m_TimeStamp = timestamp;
}
if( !STRUCT->m_FileName.IsEmpty() )
{
//problem -- must check for closed loops here, or we may never exit!
//search back up the linked list tree...
EDA_BaseStruct* strct = EEDrawList;
bool noRecurse = true;
while( strct->m_Parent ){
strct = strct->m_Parent;
if( ((DrawSheetStruct*)strct)->m_FileName ==
STRUCT->m_FileName ){
wxString msg;
msg += wxString::Format(_( "The sheet hierarchy has an infinite loop, halting recursive loads. file: "));
msg += STRUCT->m_FileName;
DisplayError( frame, msg );
noRecurse = false;
}
}
if( frame->LoadOneEEFile( STRUCT, STRUCT->m_FileName ) == TRUE && noRecurse)
{
LoadSubHierarchy( frame, STRUCT->EEDrawList );
}
}
else
DisplayError( frame, _( "No FileName in SubSheet" ) );
}
EEDrawList = EEDrawList->Pnext;
}
}
......@@ -35,7 +35,7 @@ char marq_bitmap[]=
char marqERC_bitmap[]=
{
8, 8, 0, 0, /* Dimensions x et y , offsets x et y du bitmap de marqueurs*/
-1, /* Color: -1 = couleur non prcise */
-1, /* Color: -1 = couleur non pr�cis�e */
1,1,1,1,1,0,0,0,
1,1,1,0,1,0,0,0,
1,1,1,1,0,0,0,0,
......@@ -129,18 +129,18 @@ wxString title;
void WinEDA_DrawPanel::PrintPage(wxDC * DC, bool Print_Sheet_Ref, int PrintMask)
/*******************************************************************************/
{
BASE_SCREEN * screen, * oldscreen = m_Parent->GetScreen();
BASE_SCREEN * screen; // * oldscreen = m_Parent->GetScreen();
wxBeginBusyCursor();
screen = m_Parent->m_CurrentScreen = ActiveScreen;
ActiveScreen = screen = m_Parent->GetScreen();
RedrawStructList(this,DC, screen->EEDrawList, GR_COPY);
if ( Print_Sheet_Ref )
m_Parent->TraceWorkSheet(DC, screen, g_DrawMinimunLineWidth );
m_Parent->m_CurrentScreen = oldscreen;
//m_Parent->m_CurrentSheet->m_s = oldscreen;
wxEndBusyCursor();
}
......@@ -223,7 +223,7 @@ void DrawMarkerStruct::Draw(WinEDA_DrawPanel * panel,wxDC * DC, const wxPoint &
int DrawMode, int Color)
/****************************************************************************************/
{
#define WAR 1 // utilis aussi dans erc.cpp
#define WAR 1 // utilis aussi dans erc.cpp
if( m_Type == MARQ_ERC )
{
......@@ -300,23 +300,23 @@ int width = MAX(m_Width, g_DrawMinimunLineWidth);
GRSetDrawMode(DC, DrawMode);
if( (m_Layer == LAYER_BUS) && (zoom <= 16) )
{
{
width *= 3;
}
}
GRMoveTo(m_Points[0], m_Points[1]);
if( m_Layer == LAYER_NOTES)
{
{
for (i = 1; i < m_NumOfPoints; i++)
GRDashedLineTo(&panel->m_ClipBox, DC, m_Points[i * 2] + offset.x,
m_Points[i * 2 + 1] + offset.y, width, color);
}
}
else
{
{
for (i = 1; i < m_NumOfPoints; i++)
GRLineTo(&panel->m_ClipBox, DC, m_Points[i * 2] + offset.x, m_Points[i * 2 + 1] + offset.y,
width, color);
}
}
}
/*****************************************************************************
......@@ -420,6 +420,8 @@ int width = g_DrawMinimunLineWidth;
}
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
case DRAW_HIER_LABEL_STRUCT_TYPE:
{
DrawLabelStruct * Struct;
Struct = (DrawLabelStruct * ) DrawStruct;
......@@ -429,16 +431,6 @@ int width = g_DrawMinimunLineWidth;
break;
}
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
{
DrawGlobalLabelStruct * Struct;
Struct = (DrawGlobalLabelStruct * ) DrawStruct;
Struct->m_Pos.x += dx; Struct->m_Pos.y += dy;
Struct->Draw(panel, DC, wxPoint(0,0),DrawMode,g_GhostColor);
Struct->m_Pos.x -= dx; Struct->m_Pos.y -= dy;
break;
}
case DRAW_NOCONNECT_STRUCT_TYPE:
{
DrawNoConnectStruct * Struct;
......
......@@ -24,10 +24,6 @@
#include "bitmaps.h"
#include "eda_dde.h"
/* Routines locales */
static void CreateScreens();
// Global variables
wxString g_Main_Title( wxT( "EESchema" ) );
......@@ -61,8 +57,6 @@ bool WinEDA_App::OnInit()
if( argc > 1 )
FFileName = argv[1];
CreateScreens();
/* init EESCHEMA */
GetSettings(); // read current setup
SeedLayers();
......@@ -106,25 +100,3 @@ bool WinEDA_App::OnInit()
return TRUE;
}
/******************************/
static void CreateScreens()
/******************************/
/*
* Fonction d'init des crans utiliss dans EESchema:
*/
{
/* creation des ecrans Sch , Lib */
if( ScreenSch == NULL )
ScreenSch = new SCH_SCREEN( SCHEMATIC_FRAME );
ScreenSch->m_FileName = g_DefaultSchematicFileName;
ScreenSch->m_Date = GenDate();
ActiveScreen = ScreenSch;
if( ScreenLib == NULL )
ScreenLib = new SCH_SCREEN( LIBEDITOR_FRAME );
ScreenLib->SetZoom( 4 );
ScreenLib->m_UndoRedoCountMax = 10;
}
......@@ -51,7 +51,7 @@ int WriteFichierERC = FALSE;
* PIN_OPENEMITTER, PIN_NC
*/
#define OK 0
#define WAR 1 // utilis aussi dans eeredraw
#define WAR 1 // utilis aussi dans eeredraw
#define ERR 2
#define UNC 3
......@@ -185,7 +185,7 @@ void WinEDA_ErcFrame::ReBuildMatrixPanel()
text_height = text->GetRect().GetHeight();
bitmap_size = MAX( bitmap_size, text_height );
delete text;
SAFE_DELETE( text );
// compute the Y pos interval:
BoxMatrixMinSize.y = ( bitmap_size * (PIN_NMAX + 1) ) + 5;
......@@ -313,7 +313,7 @@ void WinEDA_ErcFrame::TestErc( wxCommandEvent& event )
g_EESchemaVar.NbWarningErc = 0;
/* Cleanup the entire hierarchy */
EDA_ScreenList ScreenList( NULL );
EDA_ScreenList ScreenList;
for( SCH_SCREEN* Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() )
{
......@@ -358,10 +358,12 @@ void WinEDA_ErcFrame::TestErc( wxCommandEvent& event )
case NET_LABEL:
case NET_BUSLABELMEMBER:
case NET_PINLABEL:
case NET_GLOBLABEL: //not sure how to handle global labels -- they should be treated like other nets (just global!0
case NET_GLOBBUSLABELMEMBER:
break;
case NET_GLOBLABEL:
case NET_GLOBBUSLABELMEMBER:
case NET_HIERLABEL:
case NET_HIERBUSLABELMEMBER:
case NET_SHEETLABEL:
case NET_SHEETBUSLABELMEMBER:
TestLabel( m_Parent->DrawPanel, &dc, NetItemRef, StartNet );
......@@ -398,7 +400,7 @@ void WinEDA_ErcFrame::TestErc( wxCommandEvent& event )
if( WriteFichierERC == TRUE )
{
wxString ErcFullFileName;
ErcFullFileName = ScreenSch->m_FileName;
ErcFullFileName = g_RootSheet->m_s->m_FileName;
ChangeFileNameExt( ErcFullFileName, wxT( ".erc" ) );
ErcFullFileName = EDA_FileSelector( _( "ERC file:" ),
wxEmptyString, /* Chemin par defaut */
......@@ -542,7 +544,7 @@ static void Diagnose( WinEDA_DrawPanel* panel, wxDC* DC,
Marker->m_Type = MARQ_ERC;
Marker->m_MarkFlags = WAR;
screen = NetItemRef->m_Screen;
screen = NetItemRef->m_SheetList.LastScreen();
Marker->Pnext = screen->EEDrawList;
screen->EEDrawList = Marker;
g_EESchemaVar.NbErrorErc++;
......@@ -550,14 +552,14 @@ static void Diagnose( WinEDA_DrawPanel* panel, wxDC* DC,
if( MinConn < 0 ) // Traitement des erreurs sur labels
{
if( (NetItemRef->m_Type == NET_GLOBLABEL)
|| (NetItemRef->m_Type == NET_GLOBBUSLABELMEMBER) )
if( (NetItemRef->m_Type == NET_HIERLABEL)
|| (NetItemRef->m_Type == NET_HIERBUSLABELMEMBER) )
{
Marker->m_Comment.Printf( _( "Warning GLabel %s not connected to SheetLabel" ),
Marker->m_Comment.Printf( _( "Warning HLabel %s not connected to SheetLabel" ),
NetItemRef->m_Label->GetData() );
}
else
Marker->m_Comment.Printf( _( "Warning SheetLabel %s not connected to GLabel" ),
Marker->m_Comment.Printf( _( "Warning SheetLabel %s not connected to HLabel" ),
NetItemRef->m_Label->GetData() );
if( screen == panel->GetScreen() )
......@@ -656,7 +658,7 @@ static void TestOthersItems( WinEDA_DrawPanel* panel, wxDC* DC,
|| (NetItemRef->GetNet() != NetItemTst->GetNet()) ) // fin de net
{ /* Fin de netcode trouve: Tst connexion minimum */
if( (*MinConnexion < NET_NC )
&& (local_minconn < NET_NC ) ) /* pin non connecte ou non pilotee */
&& (local_minconn < NET_NC ) ) /* pin non connecte ou non pilotee */
{
Diagnose( panel, DC, NetItemRef, NULL, local_minconn, WAR );
*MinConnexion = DRV; // inhibition autres messages de ce type pour ce net
......@@ -670,11 +672,13 @@ static void TestOthersItems( WinEDA_DrawPanel* panel, wxDC* DC,
case NET_BUS:
case NET_JONCTION:
case NET_LABEL:
case NET_GLOBLABEL:
case NET_HIERLABEL:
case NET_BUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER:
case NET_HIERBUSLABELMEMBER:
case NET_SHEETBUSLABELMEMBER:
case NET_SHEETLABEL:
case NET_GLOBLABEL:
case NET_GLOBBUSLABELMEMBER:
case NET_PINLABEL:
break;
......@@ -719,7 +723,7 @@ static bool WriteDiagnosticERC( const wxString& FullFileName )
DrawMarkerStruct* Marker;
char Line[256];
static FILE* OutErc;
DrawSheetStruct* Sheet;
DrawSheetList* Sheet;
wxString msg;
if( ( OutErc = wxFopen( FullFileName, wxT( "wt" ) ) ) == NULL )
......@@ -730,19 +734,20 @@ static bool WriteDiagnosticERC( const wxString& FullFileName )
fprintf( OutErc, "%s (%s)\n", CONV_TO_UTF8( msg ), Line );
EDA_ScreenList ScreenList( NULL );
EDA_SheetList SheetList( NULL );
for( SCH_SCREEN* Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() )
for( Sheet = SheetList.GetFirst(); Sheet != NULL; Sheet = SheetList.GetNext() )
{
Sheet = (DrawSheetStruct*) Screen;
msg.Printf( _( "\n***** Sheet %d (%s)\n" ),
Sheet->m_SheetNumber,
Screen == ScreenSch ? _( "Root" ) : Sheet->m_SheetName.GetData() );
if(Sheet->Last() == g_RootSheet){
msg.Printf( _( "\n***** Sheet Root\n" ) );
}else{
wxString str = Sheet->Path();
msg.Printf( _("\n***** Sheet %s\n"), str.GetData() );
}
fprintf( OutErc, "%s", CONV_TO_UTF8( msg ) );
DrawStruct = Screen->EEDrawList;
DrawStruct = Sheet->LastDrawList();
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext )
{
if( DrawStruct->Type() != DRAW_MARKER_STRUCT_TYPE )
......@@ -770,7 +775,18 @@ static bool WriteDiagnosticERC( const wxString& FullFileName )
return TRUE;
}
bool TestLabel_( ObjetNetListStruct* a, ObjetNetListStruct* b )
{
int at = a->m_Type;
int bt = b->m_Type;
if( (at == NET_HIERLABEL || at == NET_HIERBUSLABELMEMBER)
&&(bt == NET_SHEETLABEL || bt == NET_SHEETBUSLABELMEMBER) ){
if( a->m_SheetList == b->m_SheetListInclude ){
return true; //connected!
}
}
return false; //these two are unconnected
}
/***********************************************************************/
void TestLabel( WinEDA_DrawPanel* panel, wxDC* DC,
ObjetNetListStruct* NetItemRef, ObjetNetListStruct* StartNet )
......@@ -799,66 +815,16 @@ void TestLabel( WinEDA_DrawPanel* panel, wxDC* DC,
|| ( NetItemRef->GetNet() != NetItemTst->GetNet() ) )
{
/* Fin de netcode trouve */
if( erc )
{
if( erc ){
/* GLabel ou SheetLabel orphelin */
Diagnose( panel, DC, NetItemRef, NULL, -1, WAR );
}
return;
}
if( (NetItemRef->m_Type == NET_GLOBLABEL)
|| (NetItemRef->m_Type == NET_GLOBBUSLABELMEMBER) )
{
switch( NetItemTst->m_Type )
{
case NET_SEGMENT:
case NET_BUS:
case NET_JONCTION:
case NET_LABEL:
case NET_GLOBLABEL:
case NET_BUSLABELMEMBER:
case NET_GLOBBUSLABELMEMBER:
case NET_PINLABEL:
case NET_NOCONNECT:
case NET_PIN:
break;
case NET_SHEETBUSLABELMEMBER:
case NET_SHEETLABEL:
/* Tst si le GLabel est bien dans la bonne sousfeuille */
if( NetItemRef->m_SheetNumber == NetItemTst->m_NumInclude )
{
erc = 0;
}
break;
}
}
else
{
switch( NetItemTst->m_Type )
{
case NET_SEGMENT:
case NET_BUS:
case NET_JONCTION:
case NET_LABEL:
case NET_BUSLABELMEMBER:
case NET_SHEETBUSLABELMEMBER:
case NET_SHEETLABEL:
case NET_PINLABEL:
case NET_NOCONNECT:
case NET_PIN:
break;
case NET_GLOBLABEL:
case NET_GLOBBUSLABELMEMBER:
/* Tst si le GLabel est bien dans la bonne sous-feuille */
if( NetItemTst->m_SheetNumber == NetItemRef->m_NumInclude )
{
erc = 0;
}
break;
}
}
if(TestLabel_(NetItemRef, NetItemTst))
erc = 0;
//same thing, different order.
if(TestLabel_(NetItemTst, NetItemRef))
erc = 0;
}
}
......@@ -20,7 +20,7 @@
void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event )
/****************************************************************/
/* Commands to save shepatic project or the current page.
/* Commands to save project or the current page.
*/
{
int id = event.GetId();
......@@ -28,7 +28,7 @@ void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event )
switch( id )
{
case ID_SAVE_PROJECT: /* Update Schematic File */
SaveProject( this );
SaveProject( );
break;
case ID_SAVE_ONE_SHEET: /* Update Schematic File */
......@@ -47,26 +47,25 @@ void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event )
/******************************************************************************************/
bool WinEDA_SchematicFrame::LoadOneSheet( SCH_SCREEN* screen, const wxString& filename )
//bool WinEDA_SchematicFrame::LoadOneSheet(DrawSheetStruct* sheet, const wxString& filename )
/******************************************************************************************/
{
//{
// return FALSE;
//when is this used? and why?
/*
//this must be called with a non-null pointer screen pointer, clearly.
//also note that this is for reading in a *root* file
wxString FullFileName = filename;
if( screen->EEDrawList != NULL )
{
if( !IsOK( this, _( "Clear SubHierarchy ?" ) ) )
return FALSE;
}
if( FullFileName.IsEmpty() )
{
wxString mask;
mask = wxT( "*" ) + g_SchExtBuffer;
FullFileName = EDA_FileSelector( _( "Schematic files:" ),
wxEmptyString, /* default path */
screen->m_FileName, /* default filename */
g_SchExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
wxEmptyString, //default path
sheet->m_s->m_FileName,// default filename
g_SchExtBuffer, // extension par defaut
mask, // Masque d'affichage
this,
wxFD_OPEN,
FALSE
......@@ -76,52 +75,212 @@ bool WinEDA_SchematicFrame::LoadOneSheet( SCH_SCREEN* screen, const wxString& fi
}
ClearProjectDrawList( screen, TRUE );
printf("in LoadOneScreen setting screen filename: %s \n", (const char*) FullFileName.mb_str() );
screen->m_FileName = FullFileName;
LoadOneEEFile( screen, FullFileName );
LoadDrawSheet( DrawSheetStruct * sheet, filename);
screen->SetModify();
if( GetScreen() == screen )
Refresh( TRUE );
return TRUE;
*/
//}
/************************************************************************************/
int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNew )
/************************************************************************************/
{
/*
* Load an entire project
* ( schematic root file and its subhierarchies, the configuration and the libs
* which are not already loaded)
*/
SCH_SCREEN* screen;
wxString FullFileName, msg;
bool LibCacheExist = FALSE;
EDA_ScreenList ScreenList;
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
{
if( screen->IsModify() )
break;
}
if( screen )
{
if( !IsOK( this, _( "Clear Schematic Hierarchy (modified!)?" ) ) )
return FALSE;
if( g_RootSheet->m_s->m_FileName != g_DefaultSchematicFileName )
SetLastProject( g_RootSheet->m_s->m_FileName );
}
FullFileName = FileName;
if( ( FullFileName.IsEmpty() ) && !IsNew )
{
wxString mask = wxT( "*" ) + g_SchExtBuffer;
FullFileName = EDA_FileSelector( _( "Schematic files:" ),
wxEmptyString, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_SchExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
wxFD_OPEN,
TRUE
);
if( FullFileName.IsEmpty() )
return FALSE;
}
if(g_RootSheet){
SAFE_DELETE(g_RootSheet);
}
CreateScreens();
screen = (SCH_SCREEN*)GetScreen();
wxSetWorkingDirectory( wxPathOnly( FullFileName ) );
GetScreen()->m_FileName = FullFileName;
g_RootSheet->m_FileName = FullFileName;
Affiche_Message( wxEmptyString );
MsgPanel->EraseMsgBox();
memset( &g_EESchemaVar, 0, sizeof(g_EESchemaVar) );
GetScreen()->ClrModify();
//m_CurrentSheet->m_s->Pnext = NULL; should be by default
if( IsNew )
{
screen->m_CurrentSheetDesc = &g_Sheet_A4;
screen->SetZoom( 32 );
screen->m_ScreenNumber = screen->m_NumberOfScreen = 1;
screen->m_Title = wxT( "noname.sch" );
GetScreen()->m_FileName = screen->m_Title;
screen->m_Company.Empty();
screen->m_Commentaire1.Empty();
screen->m_Commentaire2.Empty();
screen->m_Commentaire3.Empty();
screen->m_Commentaire4.Empty();
Read_Config( wxEmptyString, TRUE );
Zoom_Automatique( TRUE );
ReDrawPanel();
return 1;
}
// Rechargement de la configuration:
msg = _( "Ready\nWorking dir: \n" ) + wxGetCwd();
PrintMsg( msg );
Read_Config( wxEmptyString, FALSE );
// Delete old caches.
LibraryStruct* nextlib, * lib = g_LibraryList;
for( ; lib != NULL; lib = nextlib )
{
nextlib = lib->m_Pnext;
if( lib->m_IsLibCache )
FreeCmpLibrary( this, lib->m_Name );
}
if( IsNew )
{
ReDrawPanel();
return 1;
}
// Loading the project library cache
wxString FullLibName;
wxString shortfilename;
wxSplitPath( g_RootSheet->m_s->m_FileName, NULL, &shortfilename, NULL );
FullLibName << wxT( "." ) << STRING_DIR_SEP << shortfilename << wxT( ".cache" ) <<
g_LibExtBuffer;
if( wxFileExists( FullLibName ) )
{
wxString libname;
libname = FullLibName;
ChangeFileNameExt( libname, wxEmptyString );
msg = wxT( "Load " ) + FullLibName;
LibraryStruct* LibCache = LoadLibraryName( this, FullLibName, libname );
if( LibCache )
{
LibCache->m_IsLibCache = TRUE;
msg += wxT( " OK" );
}
else
msg += wxT( " ->Error" );
PrintMsg( msg );
LibCacheExist = TRUE;
}
if( !wxFileExists( g_RootSheet->m_s->m_FileName ) && !LibCacheExist ) // Nouveau projet prpbablement
{
msg.Printf( _( "File %s not found (new project ?)" ),
g_RootSheet->m_s->m_FileName.GetData() );
DisplayInfo( this, msg, 20 );
return -1;
}
//load the project.
SAFE_DELETE(g_RootSheet->m_s);
if(!g_RootSheet->Load(this))
return 0;
/* Reaffichage ecran de base (ROOT) si necessaire */
ActiveScreen = GetScreen();
Zoom_Automatique( FALSE );
DrawPanel->Refresh( TRUE );
return 1;
}
/**********************************************************/
SCH_SCREEN * WinEDA_SchematicFrame::CreateNewScreen(
SCH_SCREEN * OldScreen, int TimeStamp)
/**********************************************************/
/* Routine de creation ( par allocation memoire ) d'un nouvel ecran
cet ecran est en chainage arriere avec OldScreen
la valeur TimeStamp est attribuee au parametre NewScreen->TimeStamp
*/
{
SCH_SCREEN * NewScreen;
NewScreen = new SCH_SCREEN(SCHEMATIC_FRAME);
NewScreen->SetRefreshReq();
if(OldScreen) NewScreen->m_Company = OldScreen->m_Company;
NewScreen->m_TimeStamp = TimeStamp;
NewScreen->Pback = OldScreen;
return(NewScreen);
}
/****************************************************/
void SaveProject( WinEDA_SchematicFrame* frame )
void WinEDA_SchematicFrame::SaveProject( )
/****************************************************/
/* Sauvegarde toutes les feuilles du projet
* et cre une librairie archive des composants, de nom <root_name>.chche.lib
* et cre une librairie archive des composants, de nom <root_name>.chche.lib
*/
{
SCH_SCREEN* screen_tmp;
SCH_SCREEN* screen_tmp, *screen;
wxString LibArchiveFileName;
if( frame == NULL )
return;
screen_tmp = frame->GetScreen();
screen_tmp = (SCH_SCREEN*)GetScreen(); //save...
EDA_ScreenList ScreenList( NULL );
EDA_ScreenList ScreenList;
for( ActiveScreen = ScreenList.GetFirst();
ActiveScreen != NULL;
ActiveScreen = ScreenList.GetNext() )
for( screen = ScreenList.GetFirst(); screen != NULL;
screen = ScreenList.GetNext() )
{
frame->m_CurrentScreen = ActiveScreen;
frame->SaveEEFile( NULL, FILE_SAVE_AS );
printf("SaveEEFile, %s\n", (const char*)screen->m_FileName.mb_str() );
SaveEEFile( screen, FILE_SAVE_AS );
}
frame->m_CurrentScreen = ActiveScreen = screen_tmp;
/* Creation du fichier d'archivage composants en repertoire courant */
LibArchiveFileName = MakeFileName( wxEmptyString, ScreenSch->m_FileName, wxEmptyString );
LibArchiveFileName = MakeFileName( wxEmptyString, GetScreen()->m_FileName, wxEmptyString );
ChangeFileNameExt( LibArchiveFileName, wxEmptyString );
/* mise a jour extension */
LibArchiveFileName += wxT( ".cache" ) + g_LibExtBuffer;
LibArchive( frame, LibArchiveFileName );
LibArchive( this, LibArchiveFileName );
}
......@@ -132,10 +291,14 @@ int CountCmpNumber()
/* Routine retournant le nombre de composants dans le schema,
* powers non comprises */
{
return g_RootSheet->ComponentCount();
/*
BASE_SCREEN* Window;
EDA_BaseStruct* Phead;
int Nb = 0;
Window = ScreenSch;
while( Window )
{
......@@ -153,4 +316,5 @@ int CountCmpNumber()
}
return Nb;
*/
}
This diff is collapsed.
......@@ -72,6 +72,7 @@ typedef enum {
LAYER_JUNCTION,
LAYER_LOCLABEL,
LAYER_GLOBLABEL,
LAYER_HIERLABEL,
LAYER_PINFUN,
LAYER_PINNUM,
LAYER_PINNAM,
......@@ -147,7 +148,7 @@ extern int g_HVLines;
eda_global int g_PlotPSColorOpt; // True = plot postcript color (see plotps.cpp)
// Gestion de diverses variables, options... devant etre mmorises mais
// Gestion de diverses variables, options... devant etre m�moris�es mais
// Remises a 0 lors d'un rechargement de projetc
struct EESchemaVariables
{
......@@ -164,7 +165,7 @@ eda_global int g_PrintFillMask; /* pour les options "FILL",
eda_global wxString g_CurrentViewLibraryName; /* nom de la librairie en cours d'examen */
eda_global wxString g_CurrentViewComponentName; /* nom du le composant en cours d'examen */
eda_global int g_ViewConvert; /* Vue normal / convert */
eda_global int g_ViewUnit; /* unit a afficher (A, B ..) */
eda_global int g_ViewUnit; /* unit� a afficher (A, B ..) */
/* Variables globales pour Schematic Edit */
eda_global int g_DefaultTextLabelSize
......@@ -218,7 +219,8 @@ struct HPGL_Pen_Descr_Struct
eda_global HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr;
/* Ecrans usuels */
eda_global SCH_SCREEN * ScreenSch;
//eda_global SCH_SCREEN * ScreenSch;
eda_global DrawSheetStruct* g_RootSheet;
eda_global SCH_SCREEN * ScreenLib;
/*************************************/
......@@ -253,7 +255,7 @@ eda_global wxString g_NetListerCommandLine; // ligne de commande pour l'appel au
eda_global LayerStruct g_LayerDescr; /* couleurs des couches */
eda_global bool g_EditPinByPinIsOn /* bool: TRUE si edition des pins pin a pin au lieu */
#ifdef MAIN /* de l'edition simultane des pins de meme coordonnes */
#ifdef MAIN /* de l'edition simultan�e des pins de meme coordonn�es */
= FALSE
#endif
;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -27,15 +27,15 @@ static int TriListEntry(EDA_LibComponentStruct **Objet1,
bool LibArchive(wxWindow * frame, const wxString & ArchFullFileName)
/*******************************************************************/
/*
Creation du fichier librairie contenant tous les composants utiliss dans
Creation du fichier librairie contenant tous les composants utiliss dans
le projet en cours
retourne TRUE si fichier cr
retourne TRUE si fichier cr��
*/
{
wxString DocFileName, msg;
char Line[256];
FILE *ArchiveFile, *DocFile;
EDA_BaseStruct ** ListStruct;
ListComponent * List;
EDA_LibComponentStruct ** ListEntry, *Entry;
int ii, NbItems;
const wxChar * Text;
......@@ -45,12 +45,11 @@ const wxChar * Text;
NbItems = GenListeCmp(NULL ); // Comptage des composants
if ( NbItems == 0 ) return FALSE;
ListStruct = (EDA_BaseStruct **)
MyZMalloc( NbItems * sizeof(EDA_BaseStruct **) );
if (ListStruct == NULL ) return FALSE;
List = (ListComponent *) MyZMalloc( NbItems * sizeof( ListComponent ) );
if (List == NULL ) return FALSE;
/* Calcul de la liste des composants */
GenListeCmp(ListStruct);
GenListeCmp(List);
/* Calcul de la liste des Entrees de librairie
et Remplacement des alias par les composants "Root" */
......@@ -60,12 +59,12 @@ const wxChar * Text;
for ( ii = 0; ii < NbItems; ii++ )
{
Text = ( (EDA_SchComponentStruct*)ListStruct[ii])->m_ChipName.GetData();
Text = List[ii].m_Comp->m_ChipName.GetData();
Entry = FindLibPart(Text, wxEmptyString, FIND_ROOT);
ListEntry[ii] = Entry; // = NULL si Composant non trouv en librairie
ListEntry[ii] = Entry; // = NULL si Composant non trouv en librairie
}
MyFree(ListStruct);
MyFree(List);
qsort( ListEntry, NbItems, sizeof(EDA_LibComponentStruct *),
(int(*)(const void*, const void*))TriListEntry);
......@@ -95,7 +94,7 @@ const wxChar * Text;
/* Generation des elements */
for ( ii = 0; ii < NbItems; ii++ )
{
if ( ListEntry[ii] == NULL ) // Composant non trouv en librairie
if ( ListEntry[ii] == NULL ) // Composant non trouv en librairie
{
continue;
}
......
......@@ -41,7 +41,7 @@ void FreeLibraryEntry( LibCmpEntry* Entry )
/* Used by PQFreeFunc() to delete all entries
*/
{
delete Entry;
SAFE_DELETE( Entry );
}
......@@ -197,7 +197,7 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct()
while( field )
{
TempField = field; field = (LibDrawField*) field->Pnext;
delete TempField;
SAFE_DELETE( TempField );
}
/* suppression des elements dependants */
......@@ -205,7 +205,7 @@ EDA_LibComponentStruct::~EDA_LibComponentStruct()
while( DrawItem )
{
NextDrawItem = DrawItem->Next();
delete DrawItem;
SAFE_DELETE( DrawItem );
DrawItem = NextDrawItem;
}
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment