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.

113 lines
3.0 KiB

  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->IsModify() && confirm_deletion )
  32. {
  33. msg.Printf( _("Sheet %s (file %s) modified. Save it?"),
  34. FirstSheet->m_SheetName.GetData(),
  35. FirstSheet->m_FileName.GetData());
  36. if( IsOK(NULL, msg) )
  37. {
  38. frame->SaveEEFile(FirstSheet, FILE_SAVE_AS);
  39. }
  40. }
  41. /* free the sub hierarchy */
  42. EEDrawList = FirstSheet->EEDrawList;
  43. while (EEDrawList != NULL)
  44. {
  45. DrawStruct = EEDrawList;
  46. EEDrawList = EEDrawList->Pnext;
  47. if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE)
  48. {
  49. DeleteSubHierarchy((DrawSheetStruct *) DrawStruct, confirm_deletion);
  50. }
  51. }
  52. /* Effacement des elements de la feuille courante */
  53. FirstSheet->FreeDrawList();
  54. }
  55. /*********************************************************************/
  56. void ClearDrawList(EDA_BaseStruct *DrawList, bool confirm_deletion)
  57. /********************************************************************/
  58. /* free the draw list DrawList and the subhierarchies */
  59. {
  60. EDA_BaseStruct *DrawStruct;
  61. while (DrawList != NULL)
  62. {
  63. DrawStruct = DrawList;
  64. DrawList = DrawList->Pnext;
  65. if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE)
  66. {
  67. DeleteSubHierarchy((DrawSheetStruct*) DrawStruct, confirm_deletion);
  68. }
  69. delete DrawStruct;
  70. }
  71. }
  72. /********************************************************************/
  73. bool ClearProjectDrawList(SCH_SCREEN * screen, bool confirm_deletion)
  74. /********************************************************************/
  75. /* free the draw list screen->EEDrawList and the subhierarchies
  76. clear the screen datas (filenames ..)
  77. */
  78. {
  79. if ( screen == NULL ) return(TRUE);
  80. ClearDrawList(screen->EEDrawList, confirm_deletion);
  81. screen->EEDrawList = NULL;
  82. /* Clear the screen datas */
  83. screen->m_SheetNumber = screen->m_NumberOfSheet = 1;
  84. screen->m_Title.Empty();
  85. screen->m_Revision.Empty();
  86. screen->m_Company.Empty();
  87. screen->m_Commentaire1.Empty();
  88. screen->m_Commentaire2.Empty();
  89. screen->m_Commentaire3.Empty();
  90. screen->m_Commentaire4.Empty();
  91. screen->m_Date = GenDate();
  92. return TRUE;
  93. }