Slicer  4.8
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;
36 class vtkMRMLStorageNode;
38 
39 // VTK includes
40 class vtkCollection;
41 class vtkImageData;
42 
43 // STD includes
44 #include <vector>
45 
46 class VTK_MRML_LOGIC_EXPORT vtkMRMLApplicationLogic
47  : public vtkMRMLAbstractLogic
48 {
49 public:
50 
51  static vtkMRMLApplicationLogic *New();
52  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
54 
56  vtkMRMLSelectionNode * GetSelectionNode()const;
57 
59  vtkMRMLInteractionNode * GetInteractionNode()const;
60 
62  void SetSliceLogics(vtkCollection* sliceLogics);
63  vtkCollection* GetSliceLogics()const;
64  vtkMRMLSliceLogic* GetSliceLogic(vtkMRMLSliceNode* sliceNode) const;
65  vtkMRMLSliceLogic* GetSliceLogicByLayoutName(const char* layoutName) const;
67  vtkMRMLSliceLogic* GetSliceLogicByModelDisplayNode(vtkMRMLModelDisplayNode* displayNode) const;
68 
70  vtkMRMLModelHierarchyLogic* GetModelHierarchyLogic() const;
71 
76  void SetColorLogic(vtkMRMLColorLogic* newColorLogic);
77  vtkMRMLColorLogic* GetColorLogic()const;
78 
87  void PropagateVolumeSelection(int fit = 1);
88 
94  void PropagateBackgroundVolumeSelection(int fit = 1);
95 
101  void PropagateForegroundVolumeSelection(int fit = 1);
102 
108  void PropagateLabelVolumeSelection(int fit = 1);
109 
110  enum Layers
111  {
112  LabelLayer = 0x1,
113  ForegroundLayer = 0x2,
114  BackgroundLayer = 0x4,
115  AllLayers = LabelLayer | ForegroundLayer | BackgroundLayer
116  };
117 
121  void PropagateVolumeSelection(int layer, int fit);
122 
126  void FitSliceToAll(bool onlyIfPropagateVolumeSelectionAllowed=false);
127 
129  void PropagateTableSelection();
130 
132  void PropagatePlotChartSelection();
133 
136  bool Zip(const char *zipFileName, const char *directoryToZip);
137 
140  bool Unzip(const char *zipFileName, const char *destinationDirectory);
141 
151  std::string PercentEncode(std::string s);
152 
158  bool SaveSceneToSlicerDataBundleDirectory(const char *sdbDir, vtkImageData *screenShot = NULL);
159 
163  bool OpenSlicerDataBundle(const char *sdbFilePath, const char *temporaryDirectory);
164 
168  std::string UnpackSlicerDataBundle(const char *sdbFilePath, const char *temporaryDirectory);
169 
172  static int LoadDefaultParameterSets(vtkMRMLScene * scene,
173  const std::vector<std::string>& directories);
174 
176  static std::string CreateUniqueFileName(std::string &filename);
177 
179  enum Events{
180  RequestInvokeEvent = vtkCommand::UserEvent + 1
181  };
184  InvokeRequest();
186  unsigned int Delay;
188  vtkObject* Caller;
190  unsigned long EventID;
192  void* CallData;
193  };
195  void InvokeEventWithDelay(unsigned int delayInMs,
196  vtkObject* caller,
197  unsigned long eventID = vtkCommand::ModifiedEvent,
198  void* callData = 0);
199 
201  const char* GetTemporaryPath();
202 
204  void SetTemporaryPath(const char* path);
205 
206 protected:
207 
209  virtual ~vtkMRMLApplicationLogic();
210 
211  virtual void SetMRMLSceneInternal(vtkMRMLScene *newScene) VTK_OVERRIDE;
212 
213  void SetSelectionNode(vtkMRMLSelectionNode* );
214  void SetInteractionNode(vtkMRMLInteractionNode* );
215 
216  void SaveStorableNodeToSlicerDataBundleDirectory(vtkMRMLStorableNode *storableNode,
217  std::string &dataDir);
218 
219 
220 
221 private:
222 
223  std::map<vtkMRMLStorageNode*, std::string> OriginalStorageNodeDirs;
227  std::map<vtkMRMLStorageNode*, std::vector<std::string> > OriginalStorageNodeFileNames;
228 
230  void operator=(const vtkMRMLApplicationLogic&);
231 
232  class vtkInternal;
233  vtkInternal* Internal;
234 
235 };
236 
237 
238 #endif
239 
unsigned long EventID
The event id of InvokeEvent. ModifiedEvent by default.
Superclass for MRML logic classes.
vtkObject * Caller
the caller to call InvokeEvent() on.
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.
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
Events
List of custom events fired by the class.
void * CallData
Optional call data. 0 by default.
MRML node to represent a 3D surface model.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
Structure passed as calldata pointer in the RequestEvent invoked event.
A supercalss for other storage nodes.
Slicer logic class for volumes manipulation.
static vtkMRMLAbstractLogic * New()
MRML node for storing information about the active nodes in the scene.
Slicer logic class for slice manipulation.