Slicer  4.11
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"
28 
29 class vtkMRMLColorLogic;
31 class vtkMRMLSliceNode;
32 class vtkMRMLSliceLogic;
35 class vtkMRMLStorageNode;
37 class vtkMRMLViewLogic;
38 class vtkMRMLViewNode;
39 
40 // VTK includes
41 class vtkCollection;
42 class vtkImageData;
43 
44 // STD includes
45 #include <vector>
46 
47 class VTK_MRML_LOGIC_EXPORT vtkMRMLApplicationLogic
48  : public vtkMRMLAbstractLogic
49 {
50 public:
51 
52  static vtkMRMLApplicationLogic *New();
53  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
57  vtkMRMLSelectionNode* GetSelectionNode()const;
58 
60  vtkMRMLInteractionNode* GetInteractionNode()const;
61 
63  void SetSliceLogics(vtkCollection* sliceLogics);
64  vtkCollection* GetSliceLogics()const;
65  vtkMRMLSliceLogic* GetSliceLogic(vtkMRMLSliceNode* sliceNode) const;
66  vtkMRMLSliceLogic* GetSliceLogicByLayoutName(const char* layoutName) const;
68  vtkMRMLSliceLogic* GetSliceLogicByModelDisplayNode(vtkMRMLModelDisplayNode* displayNode) const;
69 
71  void SetViewLogics(vtkCollection* viewLogics);
72  vtkCollection* GetViewLogics()const;
73  vtkMRMLViewLogic* GetViewLogic(vtkMRMLViewNode* viewNode) const;
74  vtkMRMLViewLogic* GetViewLogicByLayoutName(const char* layoutName) const;
75 
80  void SetColorLogic(vtkMRMLColorLogic* newColorLogic);
81  vtkMRMLColorLogic* GetColorLogic()const;
82 
91  void PropagateVolumeSelection(int fit = 1);
92 
98  void PropagateBackgroundVolumeSelection(int fit = 1);
99 
105  void PropagateForegroundVolumeSelection(int fit = 1);
106 
112  void PropagateLabelVolumeSelection(int fit = 1);
113 
114  enum Layers
115  {
116  LabelLayer = 0x1,
117  ForegroundLayer = 0x2,
118  BackgroundLayer = 0x4,
119  AllLayers = LabelLayer | ForegroundLayer | BackgroundLayer
120  };
121 
125  void PropagateVolumeSelection(int layer, int fit);
126 
130  void FitSliceToAll(bool onlyIfPropagateVolumeSelectionAllowed=false);
131 
133  void PropagateTableSelection();
134 
136  void PropagatePlotChartSelection();
137 
140  bool Zip(const char* zipFileName, const char* directoryToZip);
141 
144  bool Unzip(const char* zipFileName, const char* destinationDirectory);
145 
155  static std::string PercentEncode(std::string s);
156 
162  bool SaveSceneToSlicerDataBundleDirectory(const char* sdbDir, vtkImageData* screenShot = nullptr);
163 
167  bool OpenSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory);
168 
172  std::string UnpackSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory);
173 
176  static int LoadDefaultParameterSets(vtkMRMLScene* scene,
177  const std::vector<std::string>& directories);
178 
184  static std::string CreateUniqueFileName(const std::string &filename, const std::string& knownExtension="");
185 
187  enum Events{
188  RequestInvokeEvent = vtkCommand::UserEvent + 1,
189  PauseRenderEvent = vtkCommand::UserEvent + 101,
191  EditNodeEvent
192  };
195  InvokeRequest();
197  unsigned int Delay{100};
199  vtkObject* Caller{nullptr};
201  unsigned long EventID{vtkCommand::ModifiedEvent};
203  void* CallData{nullptr};
204  };
206  void InvokeEventWithDelay(unsigned int delayInMs,
207  vtkObject* caller,
208  unsigned long eventID = vtkCommand::ModifiedEvent,
209  void* callData = nullptr);
210 
212  const char* GetTemporaryPath();
213 
215  void SetTemporaryPath(const char* path);
216 
219  void SaveSceneScreenshot(vtkImageData* screenshot);
220 
228  virtual void PauseRender();
229 
233  virtual void ResumeRender();
234 
236  virtual void EditNode(vtkMRMLNode* node);
237 
238 protected:
239 
241  ~vtkMRMLApplicationLogic() override;
242 
243  void SetMRMLSceneInternal(vtkMRMLScene *newScene) override;
244 
245  void SetSelectionNode(vtkMRMLSelectionNode* );
246  void SetInteractionNode(vtkMRMLInteractionNode* );
247 
248  void ProcessMRMLNodesEvents(vtkObject* caller, unsigned long event, void* callData) override;
249 
250 private:
251 
253  void operator=(const vtkMRMLApplicationLogic&) = delete;
254 
255  class vtkInternal;
256  vtkInternal* Internal;
257 
258 };
259 
260 
261 #endif
262 
Superclass for MRML logic classes.
void PrintSelf(ostream &os, vtkIndent indent) override
MRML node to represent a display property of 3D surface model.
MRML node for storing a slice through RAS space.
MRML logic class for color manipulation.
virtual void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData)
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:60
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.
MRML node to represent a 3D view.
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.