Slicer  5.3
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 class vtkTextProperty;
41 
42 // VTK includes
43 class vtkCollection;
44 class vtkImageData;
45 
46 // STD includes
47 #include <vector>
48 
49 class VTK_MRML_LOGIC_EXPORT vtkMRMLApplicationLogic
50  : public vtkMRMLAbstractLogic
51 {
52 public:
53 
54  static vtkMRMLApplicationLogic *New();
55  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
59  vtkMRMLSelectionNode* GetSelectionNode()const;
60 
62  vtkMRMLInteractionNode* GetInteractionNode()const;
63 
65  void SetSliceLogics(vtkCollection* sliceLogics);
66  vtkCollection* GetSliceLogics()const;
67  vtkMRMLSliceLogic* GetSliceLogic(vtkMRMLSliceNode* sliceNode) const;
68  vtkMRMLSliceLogic* GetSliceLogicByLayoutName(const char* layoutName) const;
70  vtkMRMLSliceLogic* GetSliceLogicByModelDisplayNode(vtkMRMLModelDisplayNode* displayNode) const;
71 
73  void SetViewLogics(vtkCollection* viewLogics);
74  vtkCollection* GetViewLogics()const;
75  vtkMRMLViewLogic* GetViewLogic(vtkMRMLViewNode* viewNode) const;
76  vtkMRMLViewLogic* GetViewLogicByLayoutName(const char* layoutName) const;
77 
82  void SetColorLogic(vtkMRMLColorLogic* newColorLogic);
83  vtkMRMLColorLogic* GetColorLogic()const;
84 
93  void PropagateVolumeSelection(int fit = 1);
94 
100  void PropagateBackgroundVolumeSelection(int fit = 1);
101 
107  void PropagateForegroundVolumeSelection(int fit = 1);
108 
114  void PropagateLabelVolumeSelection(int fit = 1);
115 
116  enum Layers
117  {
118  LabelLayer = 0x1,
119  ForegroundLayer = 0x2,
120  BackgroundLayer = 0x4,
121  AllLayers = LabelLayer | ForegroundLayer | BackgroundLayer
122  };
123 
127  void PropagateVolumeSelection(int layer, int fit);
128 
133  void FitSliceToAll(bool onlyIfPropagateVolumeSelectionAllowed=false, bool resetOrientation=true);
134 
136  void PropagateTableSelection();
137 
139  void PropagatePlotChartSelection();
140 
143  bool Zip(const char* zipFileName, const char* directoryToZip);
144 
147  bool Unzip(const char* zipFileName, const char* destinationDirectory);
148 
158  static std::string PercentEncode(std::string s);
159 
165  bool SaveSceneToSlicerDataBundleDirectory(const char* sdbDir, vtkImageData* screenShot = nullptr);
166 
170  bool OpenSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory);
171 
175  std::string UnpackSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory);
176 
179  static int LoadDefaultParameterSets(vtkMRMLScene* scene,
180  const std::vector<std::string>& directories);
181 
187  static std::string CreateUniqueFileName(const std::string &filename, const std::string& knownExtension="");
188 
190  enum Events{
191  RequestInvokeEvent = vtkCommand::UserEvent + 1,
192  PauseRenderEvent = vtkCommand::UserEvent + 101,
196  };
199  InvokeRequest();
201  unsigned int Delay{100};
203  vtkObject* Caller{nullptr};
205  unsigned long EventID{vtkCommand::ModifiedEvent};
207  void* CallData{nullptr};
208  };
210  void InvokeEventWithDelay(unsigned int delayInMs,
211  vtkObject* caller,
212  unsigned long eventID = vtkCommand::ModifiedEvent,
213  void* callData = nullptr);
214 
216  const char* GetTemporaryPath();
217 
219  void SetTemporaryPath(const char* path);
220 
223  void SaveSceneScreenshot(vtkImageData* screenshot);
224 
232  virtual void PauseRender();
233 
237  virtual void ResumeRender();
238 
240  virtual void EditNode(vtkMRMLNode* node);
241 
247  void SetModuleLogic(const char* moduleName, vtkMRMLAbstractLogic* moduleLogic);
248 
253  vtkMRMLAbstractLogic* GetModuleLogic(const char* moduleName) const;
254 
256  {
261  };
262 
263  void SetIntersectingSlicesEnabled(IntersectingSlicesOperation operation, bool enabled);
264  bool GetIntersectingSlicesEnabled(IntersectingSlicesOperation operation);
265 
266  void SetIntersectingSlicesIntersectionMode(int mode);
267  int GetIntersectingSlicesIntersectionMode();
268 
269  void SetIntersectingSlicesLineThicknessMode(int mode);
270  int GetIntersectingSlicesLineThicknessMode();
271 
276  void SetFontFileName(int fontFamily, const std::string& fontFileName);
277  std::string GetFontFileName(int fontFamily);
279 
281  std::string GetFontFilePath(const std::string& fontFileName);
282 
284  std::string GetFontsDirectory();
285 
289  void UseCustomFontFile(vtkTextProperty* textProperty);
290 
291 protected:
292 
294  ~vtkMRMLApplicationLogic() override;
295 
296  void SetMRMLSceneInternal(vtkMRMLScene *newScene) override;
297 
298  void SetSelectionNode(vtkMRMLSelectionNode* );
299  void SetInteractionNode(vtkMRMLInteractionNode* );
300 
301  void ProcessMRMLNodesEvents(vtkObject* caller, unsigned long event, void* callData) override;
302 
303  void OnMRMLSceneStartBatchProcess() override;
304  void OnMRMLSceneEndBatchProcess() override;
305  void OnMRMLSceneStartImport() override;
306  void OnMRMLSceneEndImport() override;
307  void OnMRMLSceneStartRestore() override;
308  void OnMRMLSceneEndRestore() override;
309 
310 private:
311 
313  void operator=(const vtkMRMLApplicationLogic&) = delete;
314 
315  class vtkInternal;
316  vtkInternal* Internal;
317 
318 };
319 
320 
321 #endif
322 
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.