2009-11-03 13:26:31 +00:00
|
|
|
/****************/
|
|
|
|
/* delsheet.cpp */
|
|
|
|
/****************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "class_sch_screen.h"
|
|
|
|
#include "wxEeschemaStruct.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_sheet.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Free (delete) all schematic data (include the sub hierarchy sheets )
|
2008-12-08 15:27:13 +00:00
|
|
|
* for the hierarchical sheet FirstSheet
|
|
|
|
* FirstSheet is not deleted.
|
2008-11-24 06:53:43 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
void DeleteSubHierarchy( SCH_SHEET* FirstSheet, bool confirm_deletion )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* DrawStruct;
|
|
|
|
EDA_ITEM* EEDrawList;
|
|
|
|
wxString msg;
|
|
|
|
SCH_EDIT_FRAME* frame;
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
frame = (SCH_EDIT_FRAME*)wxGetApp().GetTopWindow();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
if( FirstSheet == NULL )
|
|
|
|
return;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( FirstSheet->Type() != SCH_SHEET_T )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
DisplayError( NULL, wxT( "DeleteSubHierarchy error(): NOT a Sheet" ) );
|
2008-11-24 06:53:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
if( FirstSheet->GetScreen()->IsModify() && confirm_deletion )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
|
|
|
msg.Printf( _( "Sheet %s (file %s) modified. Save it?" ),
|
2008-12-08 15:27:13 +00:00
|
|
|
FirstSheet->m_SheetName.GetData(),
|
|
|
|
FirstSheet->GetFileName().GetData() );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
if( IsOK( NULL, msg ) )
|
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
frame->SaveEEFile( FirstSheet->GetScreen(), FILE_SAVE_AS );
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free the sub hierarchy */
|
2011-01-20 16:34:57 +00:00
|
|
|
if( FirstSheet->GetScreen() )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
EEDrawList = FirstSheet->GetScreen()->GetDrawItems();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
while( EEDrawList != NULL )
|
|
|
|
{
|
|
|
|
DrawStruct = EEDrawList;
|
|
|
|
EEDrawList = EEDrawList->Next();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( DrawStruct->Type() == SCH_SHEET_T )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
DeleteSubHierarchy( (SCH_SHEET*) DrawStruct, confirm_deletion );
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-20 16:34:57 +00:00
|
|
|
FirstSheet->GetScreen()->FreeDrawList();
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* free the draw list screen->EEDrawList and the subhierarchies
|
2008-12-08 15:27:13 +00:00
|
|
|
* clear the screen datas (filenames ..)
|
2008-11-24 06:53:43 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
bool ClearProjectDrawList( SCH_SCREEN* screen, bool confirm_deletion )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
if( screen == NULL )
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
screen->FreeDrawList();
|
|
|
|
|
|
|
|
/* Clear the screen datas */
|
|
|
|
screen->m_ScreenNumber = screen->m_NumberOfScreen = 1;
|
|
|
|
screen->m_Title.Empty();
|
|
|
|
screen->m_Revision.Empty();
|
|
|
|
screen->m_Company.Empty();
|
|
|
|
screen->m_Commentaire1.Empty();
|
|
|
|
screen->m_Commentaire2.Empty();
|
|
|
|
screen->m_Commentaire3.Empty();
|
|
|
|
screen->m_Commentaire4.Empty();
|
|
|
|
screen->m_Date = GenDate();
|
|
|
|
|
|
|
|
return TRUE;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|