Slicer  5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLApplicationLogic.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Kitware Inc.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
17  and was partially funded by NIH grant 3P41RR013218-12S1
18 
19 ==============================================================================*/
20 
21 #ifndef __vtkMRMLApplicationLogic_h
22 #define __vtkMRMLApplicationLogic_h
23 
24 // MRMLLogic includes
25 #include "vtkMRMLAbstractLogic.h"
26 
27 #include "vtkMRMLLogicExport.h"
29 
30 class vtkMRMLColorLogic;
32 class vtkMRMLSliceNode;
33 class vtkMRMLSliceLogic;
36 class vtkMRMLStorageNode;
38 class vtkMRMLViewLogic;
39 class vtkMRMLViewNode;
40 
41 // VTK includes
42 class vtkCollection;
43 class vtkImageData;
44 
45 // STD includes
46 #include <vector>
47 
48 class VTK_MRML_LOGIC_EXPORT vtkMRMLApplicationLogic
49  : public vtkMRMLAbstractLogic
50 {
51 public:
52 
53  static vtkMRMLApplicationLogic *New();
54  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
58  vtkMRMLSelectionNode* GetSelectionNode()const;
59 
61  vtkMRMLInteractionNode* GetInteractionNode()const;
62 
64  void SetSliceLogics(vtkCollection* sliceLogics);
65  vtkCollection* GetSliceLogics()const;
66  vtkMRMLSliceLogic* GetSliceLogic(vtkMRMLSliceNode* sliceNode) const;
67  vtkMRMLSliceLogic* GetSliceLogicByLayoutName(const char* layoutName) const;
69  vtkMRMLSliceLogic* GetSliceLogicByModelDisplayNode(vtkMRMLModelDisplayNode* displayNode) const;
70 
72  void SetViewLogics(vtkCollection* viewLogics);
73  vtkCollection* GetViewLogics()const;
74  vtkMRMLViewLogic* GetViewLogic(vtkMRMLViewNode* viewNode) const;
75  vtkMRMLViewLogic* GetViewLogicByLayoutName(const char* layoutName) const;
76 
81  void SetColorLogic(vtkMRMLColorLogic* newColorLogic);
82  vtkMRMLColorLogic* GetColorLogic()const;
83 
92  void PropagateVolumeSelection(int fit = 1);
93 
99  void PropagateBackgroundVolumeSelection(int fit = 1);
100 
106  void PropagateForegroundVolumeSelection(int fit = 1);
107 
113  void PropagateLabelVolumeSelection(int fit = 1);
114 
115  enum Layers
116  {
117  LabelLayer = 0x1,
118  ForegroundLayer = 0x2,
119  BackgroundLayer = 0x4,
120  AllLayers = LabelLayer | ForegroundLayer | BackgroundLayer
121  };
122 
126  void PropagateVolumeSelection(int layer, int fit);
127 
132  void FitSliceToAll(bool onlyIfPropagateVolumeSelectionAllowed=false, bool resetOrientation=true);
133 
135  void PropagateTableSelection();
136 
138  void PropagatePlotChartSelection();
139 
142  bool Zip(const char* zipFileName, const char* directoryToZip);
143 
146  bool Unzip(const char* zipFileName, const char* destinationDirectory);
147 
157  static std::string PercentEncode(std::string s);
158 
164  bool SaveSceneToSlicerDataBundleDirectory(const char* sdbDir, vtkImageData* screenShot = nullptr);
165 
169  bool OpenSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory);
170 
174  std::string UnpackSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory);
175 
178  static int LoadDefaultParameterSets(vtkMRMLScene* scene,
179  const std::vector<std::string>& directories);
180 
186  static std::string CreateUniqueFileName(const std::string &filename, const std::string& knownExtension="");
187 
189  enum Events{
190  RequestInvokeEvent = vtkCommand::UserEvent + 1,
191  PauseRenderEvent = vtkCommand::UserEvent + 101,
195  };
198  InvokeRequest();
200  unsigned int Delay{100};
202  vtkObject* Caller{nullptr};
204  unsigned long EventID{vtkCommand::ModifiedEvent};
206  void* CallData{nullptr};
207  };
209  void InvokeEventWithDelay(unsigned int delayInMs,
210  vtkObject* caller,
211  unsigned long eventID = vtkCommand::ModifiedEvent,
212  void* callData = nullptr);
213 
215  const char* GetTemporaryPath();
216 
218  void SetTemporaryPath(const char* path);
219 
222  void SaveSceneScreenshot(vtkImageData* screenshot);
223 
231  virtual void PauseRender();
232 
236  virtual void ResumeRender();
237 
239  virtual void EditNode(vtkMRMLNode* node);
240 
246  void SetModuleLogic(const char* moduleName, vtkMRMLAbstractLogic* moduleLogic);
247 
252  vtkMRMLAbstractLogic* GetModuleLogic(const char* moduleName) const;
253 
255  {
260  };
261 
262  void SetIntersectingSlicesEnabled(IntersectingSlicesOperation operation, bool enabled);
263  bool GetIntersectingSlicesEnabled(IntersectingSlicesOperation operation);
264 
265  void SetIntersectingSlicesIntersectionMode(int mode);
266  int GetIntersectingSlicesIntersectionMode();
267 
268  void SetIntersectingSlicesLineThicknessMode(int mode);
269  int GetIntersectingSlicesLineThicknessMode();
270 
271 protected:
272 
274  ~vtkMRMLApplicationLogic() override;
275 
276  void SetMRMLSceneInternal(vtkMRMLScene *newScene) override;
277 
278  void SetSelectionNode(vtkMRMLSelectionNode* );
279  void SetInteractionNode(vtkMRMLInteractionNode* );
280 
281  void ProcessMRMLNodesEvents(vtkObject* caller, unsigned long event, void* callData) override;
282 
283  void OnMRMLSceneStartBatchProcess() override;
284  void OnMRMLSceneEndBatchProcess() override;
285  void OnMRMLSceneStartImport() override;
286  void OnMRMLSceneEndImport() override;
287  void OnMRMLSceneStartRestore() override;
288  void OnMRMLSceneEndRestore() override;
289 
290 private:
291 
293  void operator=(const vtkMRMLApplicationLogic&) = delete;
294 
295  class vtkInternal;
296  vtkInternal* Internal;
297 
298 };
299 
300 
301 #endif
302 
Superclass for MRML logic classes.
void PrintSelf(ostream &os, vtkIndent indent) override
virtual void OnMRMLSceneEndImport()
MRML node to represent a display property of 3D surface model.
MRML node for storing a slice through RAS space.
virtual void OnMRMLSceneStartImport()
MRML logic class for color manipulation.
virtual void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData)
virtual void OnMRMLSceneStartBatchProcess()
Events
List of custom events fired by the class.
MRML node to represent a 3D surface model.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:57
virtual void OnMRMLSceneEndBatchProcess()
Structure passed as calldata pointer in the RequestEvent invoked event.
virtual void SetMRMLSceneInternal(vtkMRMLScene *newScene)
A superclass for other storage nodes.
Slicer logic class for view manipulation.
virtual void OnMRMLSceneEndRestore()
MRML node to represent a 3D view.
virtual void OnMRMLSceneStartRestore()
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
static vtkMRMLAbstractLogic * New()
MRML node for storing information about the active nodes in the scene.
Slicer logic class for slice manipulation.