cgma
|
00001 //- Class: UndoCommands 00002 //- Description: Provides undo capability for Cubit system 00003 //- Owner: Ray J. Meyers 00004 //- Checked by: 00005 //- Version: $Id: 00006 00007 00008 #ifndef CUBITUNDO_HPP 00009 #define CUBITUNDO_HPP 00010 00011 #include <stack> 00012 #include "DLIList.hpp" 00013 00014 class UndoCommand; 00015 class CubitString; 00016 class RefEntity; 00017 class Body; 00018 class RefVolume; 00019 class RefFace; 00020 class RefEdge; 00021 class RefVertex; 00022 class MRefEntity; 00023 class MRefVolume; 00024 class MeshEntity; 00025 00026 class CUBIT_UTIL_EXPORT CubitUndo 00027 { 00028 // the one instance of the Cubit Undo object 00029 // creating a second instance will delete and replace the first instance. 00030 static CubitUndo* mInstance; 00031 00032 public: 00033 00034 CubitUndo(); 00035 virtual ~CubitUndo(); 00036 00037 static void start_undo_group(); 00038 static void end_undo_group(); 00039 static void set_undo_enabled(bool value); 00040 static bool get_undo_enabled(); 00041 static void clear_undo_groups(); 00042 static int execute_undo(); 00043 static void set_undo_by_restoring_state(); 00044 static void set_undo_by_command(CubitString command); 00045 00046 static void save_state_with_cubit_file( DLIList<Body*> &bodies_to_save, 00047 DLIList<RefEntity*> *free_ents_to_save = NULL ); 00048 static void save_state_with_cubit_file( DLIList<RefVolume*> &volumes_to_save ); 00049 static void save_state_with_cubit_file( DLIList<RefFace*> &faces_to_save ); 00050 static void save_state_with_cubit_file( RefFace* face_to_save ); 00051 static void save_state_with_cubit_file( RefVolume* volume_to_save ); 00052 static void save_state_with_cubit_file( DLIList<MRefVolume*> &volumes_to_save ); 00053 static void save_state_with_cubit_file( DLIList<RefEdge*> &edges_to_save ); 00054 static void save_state_with_cubit_file( DLIList<RefVertex*> &vertices_to_save, 00055 bool save_if_free = false ); 00056 00057 static void save_state(); 00058 static int number_undo_groups(); 00059 static void note_result_bodies( DLIList<Body*> &bodies_to_delete ); 00060 static void note_result_body( Body* body_to_delete ); 00061 static void note_result_entities( DLIList<RefEntity*> &entities_to_delete ); 00062 static void note_result_entities( DLIList<MRefVolume*> &vols_to_delete ); 00063 static void note_result_entity( RefEntity *entity_to_delete ); 00064 static void note_result_boundary_conditions( RefEntity *owner_entity ); 00065 00066 static void retain_mesh_on_result_bodies( DLIList<Body*> &bodies ); 00067 static void retain_mesh_on_result_curves( DLIList<RefEdge*> &curves ); 00068 static void retain_mesh_on_result_vertices( DLIList<RefVertex*> &vertices ); 00069 00070 static void remove_last_undo(); 00071 static void remove_last_undo_group(); 00072 static void create_dummy_undo_object(); 00073 static bool inside_undo_group(); 00074 00075 //meshing data 00076 static void save_mesh_size_data( MRefEntity *entity ); 00077 static void save_mesh_scheme_data( MRefEntity *entity ); 00078 static void save_smooth_scheme_data( MRefEntity *entity ); 00079 static void save_all_mesh_data( MRefEntity *entity ); 00080 00081 //merging 00082 static void save_merge_data( DLIList<RefEntity*> &ents, bool merging = true ); 00083 00084 //smoothing 00085 static void save_mesh_state_before_smoothing( MRefEntity *entity ); 00086 static void save_mesh_state_before_smoothing( DLIList<MRefEntity*> &ents ); 00087 static void save_mesh_state_before_smoothing( DLIList<MeshEntity*> &ents ); 00088 00089 protected: 00090 00091 virtual void p_start_undo_group() = 0; 00092 virtual void p_end_undo_group() = 0; 00093 00094 virtual void p_set_undo_enabled(bool value)=0; 00095 virtual bool p_get_undo_enabled()=0; 00096 virtual void p_clear_undo_groups()=0; 00097 virtual int p_execute_undo()=0; 00098 virtual void p_set_undo_by_restoring_state()=0; 00099 virtual void p_set_undo_by_command(CubitString command)=0; 00100 00101 virtual void p_save_state_with_cubit_file( DLIList<Body*> &bodies_to_save, 00102 DLIList<RefEntity*> *free_ref_ents = NULL )=0; 00103 virtual void p_save_state_with_cubit_file( DLIList<RefVolume*> &volumes_to_save )=0; 00104 virtual void p_save_state_with_cubit_file( DLIList<RefFace*> &faces_to_save )=0; 00105 virtual void p_save_state_with_cubit_file( RefFace *face_to_save )=0; 00106 virtual void p_save_state_with_cubit_file( RefVolume* volume_to_save )=0; 00107 virtual void p_save_state_with_cubit_file( DLIList<MRefVolume*> &volumes_to_save )=0; 00108 virtual void p_save_state_with_cubit_file( DLIList<RefEdge*> &edges_to_save )=0; 00109 virtual void p_save_state_with_cubit_file( DLIList<RefVertex*> &vertices_to_save, 00110 bool save_only_if_free = false )=0; 00111 00112 virtual void p_save_state()=0; 00113 virtual int p_number_undo_groups()=0; 00114 virtual void p_note_result_bodies( DLIList<Body*> &bodies_to_delete )=0; 00115 virtual void p_note_result_body( Body* body_to_delete )=0; 00116 virtual void p_note_result_entities( DLIList<RefEntity*> &entities_to_delete )=0; 00117 virtual void p_note_result_entities( DLIList<MRefVolume*> &vols_to_delete )=0; 00118 virtual void p_note_result_entity( RefEntity *entity_to_delete )=0; 00119 virtual void p_note_result_boundary_conditions( RefEntity *owner_entity )=0; 00120 virtual void p_remove_last_undo_group()=0; 00121 virtual void p_remove_last_undo()=0; 00122 virtual void p_create_dummy_undo_object()=0; 00123 virtual bool p_inside_undo_group()=0; 00124 00125 virtual void p_retain_mesh_on_result_bodies( DLIList<Body*> &bodies )=0; 00126 virtual void p_retain_mesh_on_result_curves( DLIList<RefEdge*> &curves )=0; 00127 virtual void p_retain_mesh_on_result_vertices( DLIList<RefVertex*> &vertices )=0; 00128 00129 //meshing data 00130 virtual void p_save_mesh_size_data( MRefEntity *entity )=0; 00131 virtual void p_save_mesh_scheme_data( MRefEntity *entity )=0; 00132 virtual void p_save_smooth_scheme_data( MRefEntity *entity )=0; 00133 virtual void p_save_all_mesh_data( MRefEntity *entity )=0; 00134 00135 //merging 00136 virtual void p_save_merge_data( DLIList<RefEntity*> &ents, bool merging = true)=0; 00137 00138 //smoothing 00139 virtual void p_save_mesh_state_before_smoothing( DLIList<MRefEntity*> &ents_to_smooth )=0; 00140 virtual void p_save_mesh_state_before_smoothing( DLIList<MeshEntity*> &ents_to_smooth )=0; 00141 00142 }; 00143 00144 #endif 00145 00146 00147 00148