2008-11-24 06:53:43 +00:00
|
|
|
/*******************************************************/
|
|
|
|
/* delsheet.cpp Routine d'effacement d'une hierarchie */
|
|
|
|
/*******************************************************/
|
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"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2008-11-24 06:53:43 +00:00
|
|
|
void DeleteSubHierarchy( DrawSheetStruct* FirstSheet, bool confirm_deletion )
|
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
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
EDA_BaseStruct* DrawStruct;
|
|
|
|
EDA_BaseStruct* EEDrawList;
|
2008-12-08 15:27:13 +00:00
|
|
|
wxString msg;
|
|
|
|
WinEDA_SchematicFrame* frame;
|
|
|
|
|
|
|
|
frame = (WinEDA_SchematicFrame*)wxGetApp().GetTopWindow();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
if( FirstSheet == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( FirstSheet->Type() != DRAW_SHEET_STRUCT_TYPE )
|
|
|
|
{
|
|
|
|
DisplayError( NULL,
|
2008-12-08 15:27:13 +00:00
|
|
|
wxT( "DeleteSubHierarchy error(): NOT a Sheet" ) );
|
2008-11-24 06:53:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* effacement du sous schema correspondant */
|
|
|
|
if( FirstSheet->m_AssociatedScreen->IsModify() && confirm_deletion )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Sheet %s (file %s) modified. Save it?" ),
|
2008-12-08 15:27:13 +00:00
|
|
|
FirstSheet->m_SheetName.GetData(),
|
|
|
|
FirstSheet->GetFileName().GetData() );
|
2008-11-24 06:53:43 +00:00
|
|
|
if( IsOK( NULL, msg ) )
|
|
|
|
{
|
|
|
|
frame->SaveEEFile( FirstSheet->m_AssociatedScreen, FILE_SAVE_AS );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free the sub hierarchy */
|
|
|
|
if( FirstSheet->m_AssociatedScreen )
|
|
|
|
{
|
|
|
|
EEDrawList = FirstSheet->m_AssociatedScreen->EEDrawList;
|
|
|
|
while( EEDrawList != NULL )
|
|
|
|
{
|
|
|
|
DrawStruct = EEDrawList;
|
|
|
|
EEDrawList = EEDrawList->Next();
|
|
|
|
if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE )
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
DeleteSubHierarchy( (DrawSheetStruct*) DrawStruct,
|
|
|
|
confirm_deletion );
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Effacement des elements de la feuille courante */
|
|
|
|
FirstSheet->m_AssociatedScreen->FreeDrawList();
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/********************************************************************/
|
2008-11-24 06:53:43 +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
|
|
|
|
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
|
|
|
*/
|
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
|
|
|
}
|