You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.1 KiB

18 years ago
18 years ago
18 years ago
18 years ago
  1. /*******************************************************/
  2. /* delsheet.cpp Routine d'effacement d'une hierarchie */
  3. /*******************************************************/
  4. #include "fctsys.h"
  5. #include "gr_basic.h"
  6. #include "common.h"
  7. #include "program.h"
  8. #include "libcmp.h"
  9. #include "general.h"
  10. #include "protos.h"
  11. /**************************************************************************/
  12. void DeleteSubHierarchy(DrawSheetStruct * FirstSheet, bool confirm_deletion)
  13. /**************************************************************************/
  14. /* Free (delete) all schematic data (include the sub hierarchy sheets )
  15. for the hierarchical sheet FirstSheet
  16. FirstSheet is not deleted.
  17. */
  18. {
  19. EDA_BaseStruct *DrawStruct;
  20. EDA_BaseStruct *EEDrawList;
  21. WinEDA_SchematicFrame * frame = g_EDA_Appl->m_SchematicFrame;
  22. wxString msg;
  23. if( FirstSheet == NULL ) return;
  24. if( FirstSheet->Type() != DRAW_SHEET_STRUCT_TYPE)
  25. {
  26. DisplayError(NULL,
  27. wxT("DeleteSubHierarchy error(): NOT a Sheet"));
  28. return;
  29. }
  30. /* effacement du sous schema correspondant */
  31. if( FirstSheet->m_AssociatedScreen->IsModify() && confirm_deletion )
  32. {
  33. msg.Printf( _("Sheet %s (file %s) modified. Save it?"),
  34. FirstSheet->m_SheetName.GetData(),
  35. FirstSheet->GetFileName().GetData());
  36. if( IsOK(NULL, msg) )
  37. {
  38. frame->SaveEEFile(FirstSheet->m_AssociatedScreen, FILE_SAVE_AS);
  39. }
  40. }
  41. /* free the sub hierarchy */
  42. if(FirstSheet->m_AssociatedScreen){
  43. EEDrawList = FirstSheet->m_AssociatedScreen->EEDrawList;
  44. while (EEDrawList != NULL)
  45. {
  46. DrawStruct = EEDrawList;
  47. EEDrawList = EEDrawList->Pnext;
  48. if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE)
  49. {
  50. DeleteSubHierarchy((DrawSheetStruct *) DrawStruct, confirm_deletion);
  51. }
  52. }
  53. /* Effacement des elements de la feuille courante */
  54. FirstSheet->m_AssociatedScreen->FreeDrawList();
  55. }
  56. }
  57. /*********************************************************************/
  58. //void ClearDrawList(EDA_BaseStruct *DrawList, bool confirm_deletion)
  59. /********************************************************************/
  60. /* free the draw list DrawList and the subhierarchies */
  61. //this is redundant -- use FreeDrawList, a member of SCH_SCREEN
  62. /*
  63. {
  64. EDA_BaseStruct *DrawStruct;
  65. while (DrawList != NULL)
  66. {
  67. DrawStruct = DrawList;
  68. DrawList = DrawList->Pnext;
  69. if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE)
  70. {
  71. DeleteSubHierarchy((DrawSheetStruct*) DrawStruct, confirm_deletion);
  72. }
  73. delete DrawStruct;
  74. }
  75. }
  76. */
  77. /********************************************************************/
  78. bool ClearProjectDrawList(SCH_SCREEN * screen, bool confirm_deletion)
  79. /********************************************************************/
  80. /* free the draw list screen->EEDrawList and the subhierarchies
  81. clear the screen datas (filenames ..)
  82. */
  83. {
  84. if ( screen == NULL ) return(TRUE);
  85. screen->FreeDrawList();
  86. /* Clear the screen datas */
  87. screen->m_ScreenNumber = screen->m_NumberOfScreen = 1;
  88. screen->m_Title.Empty();
  89. screen->m_Revision.Empty();
  90. screen->m_Company.Empty();
  91. screen->m_Commentaire1.Empty();
  92. screen->m_Commentaire2.Empty();
  93. screen->m_Commentaire3.Empty();
  94. screen->m_Commentaire4.Empty();
  95. screen->m_Date = GenDate();
  96. return TRUE;
  97. }