2007-05-06 16:03:28 +00:00
|
|
|
/*******************************************************/
|
|
|
|
/* delsheet.cpp Routine d'effacement d'une hierarchie */
|
|
|
|
/*******************************************************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
void DeleteSubHierarchy(DrawSheetStruct * FirstSheet, bool confirm_deletion)
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
/* Free (delete) all schematic data (include the sub hierarchy sheets )
|
|
|
|
for the hierarchical sheet FirstSheet
|
|
|
|
FirstSheet is not deleted.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
EDA_BaseStruct *DrawStruct;
|
|
|
|
EDA_BaseStruct *EEDrawList;
|
2007-10-26 06:08:19 +00:00
|
|
|
WinEDA_SchematicFrame * frame = g_EDA_Appl->m_SchematicFrame;
|
2007-05-06 16:03:28 +00:00
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( FirstSheet == NULL ) return;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
if( FirstSheet->Type() != DRAW_SHEET_STRUCT_TYPE)
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
DisplayError(NULL,
|
|
|
|
wxT("DeleteSubHierarchy error(): NOT a Sheet"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* effacement du sous schema correspondant */
|
2008-02-26 19:19:54 +00:00
|
|
|
if( FirstSheet->m_AssociatedScreen->IsModify() && confirm_deletion )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
msg.Printf( _("Sheet %s (file %s) modified. Save it?"),
|
|
|
|
FirstSheet->m_SheetName.GetData(),
|
2008-02-28 19:27:25 +00:00
|
|
|
FirstSheet->GetFileName().GetData());
|
2007-05-06 16:03:28 +00:00
|
|
|
if( IsOK(NULL, msg) )
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
frame->SaveEEFile(FirstSheet->m_AssociatedScreen, FILE_SAVE_AS);
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free the sub hierarchy */
|
2008-02-26 19:19:54 +00:00
|
|
|
if(FirstSheet->m_AssociatedScreen){
|
|
|
|
EEDrawList = FirstSheet->m_AssociatedScreen->EEDrawList;
|
2008-02-12 21:12:46 +00:00
|
|
|
while (EEDrawList != NULL)
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawStruct = EEDrawList;
|
|
|
|
EEDrawList = EEDrawList->Pnext;
|
|
|
|
if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE)
|
|
|
|
{
|
|
|
|
DeleteSubHierarchy((DrawSheetStruct *) DrawStruct, confirm_deletion);
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2008-02-12 21:12:46 +00:00
|
|
|
/* Effacement des elements de la feuille courante */
|
2008-02-26 19:19:54 +00:00
|
|
|
FirstSheet->m_AssociatedScreen->FreeDrawList();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************/
|
2008-02-12 21:12:46 +00:00
|
|
|
//void ClearDrawList(EDA_BaseStruct *DrawList, bool confirm_deletion)
|
2007-05-06 16:03:28 +00:00
|
|
|
/********************************************************************/
|
|
|
|
/* free the draw list DrawList and the subhierarchies */
|
2008-02-12 21:12:46 +00:00
|
|
|
//this is redundant -- use FreeDrawList, a member of SCH_SCREEN
|
|
|
|
/*
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
EDA_BaseStruct *DrawStruct;
|
|
|
|
|
|
|
|
while (DrawList != NULL)
|
|
|
|
{
|
|
|
|
DrawStruct = DrawList;
|
|
|
|
DrawList = DrawList->Pnext;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE)
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
DeleteSubHierarchy((DrawSheetStruct*) DrawStruct, confirm_deletion);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete DrawStruct;
|
|
|
|
}
|
|
|
|
}
|
2008-02-12 21:12:46 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
/********************************************************************/
|
|
|
|
bool ClearProjectDrawList(SCH_SCREEN * screen, bool confirm_deletion)
|
|
|
|
/********************************************************************/
|
|
|
|
/* free the draw list screen->EEDrawList and the subhierarchies
|
|
|
|
clear the screen datas (filenames ..)
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
if ( screen == NULL ) return(TRUE);
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
screen->FreeDrawList();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
/* Clear the screen datas */
|
2008-02-12 21:12:46 +00:00
|
|
|
screen->m_ScreenNumber = screen->m_NumberOfScreen = 1;
|
2007-05-06 16:03:28 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|