Slicer  4.10
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 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) VTK_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 
78  vtkMRMLModelHierarchyLogic* GetModelHierarchyLogic() const;
79 
84  void SetColorLogic(vtkMRMLColorLogic* newColorLogic);
85  vtkMRMLColorLogic* GetColorLogic()const;
86 
95  void PropagateVolumeSelection(int fit = 1);
96 
102  void PropagateBackgroundVolumeSelection(int fit = 1);
103 
109  void PropagateForegroundVolumeSelection(int fit = 1);
110 
116  void PropagateLabelVolumeSelection(int fit = 1);
117 
118  enum Layers
119  {
120  LabelLayer = 0x1,
121  ForegroundLayer = 0x2,
122  BackgroundLayer = 0x4,
123  AllLayers = LabelLayer | ForegroundLayer | BackgroundLayer
124  };
125 
129  void PropagateVolumeSelection(int layer, int fit);
130 
134  void FitSliceToAll(bool onlyIfPropagateVolumeSelectionAllowed=false);
135 
137  void PropagateTableSelection();
138 
140  void PropagatePlotChartSelection();
141 
144  bool Zip(const char* zipFileName, const char* directoryToZip);
145 
148  bool Unzip(const char* zipFileName, const char* destinationDirectory);
149 
159  static std::string PercentEncode(std::string s);
160 
166  bool SaveSceneToSlicerDataBundleDirectory(const char* sdbDir, vtkImageData* screenShot = NULL);
167 
171  bool OpenSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory);
172 
176  std::string UnpackSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory);
177 
180  static int LoadDefaultParameterSets(vtkMRMLScene* scene,
181  const std::vector<std::string>& directories);
182 
188  static std::string CreateUniqueFileName(const std::string &filename, const std::string& knownExtension="");
189 
191  enum Events{
192  RequestInvokeEvent = vtkCommand::UserEvent + 1
193  };
196  InvokeRequest();
198  unsigned int Delay;
200  vtkObject* Caller;
202  unsigned long EventID;
204  void* CallData;
205  };
207  void InvokeEventWithDelay(unsigned int delayInMs,
208  vtkObject* caller,
209  unsigned long eventID = vtkCommand::ModifiedEvent,
210  void* callData = 0);
211 
213  const char* GetTemporaryPath();
214 
216  void SetTemporaryPath(const char* path);
217 
220  void SaveSceneScreenshot(vtkImageData* screenshot);
221 
222 protected:
223 
225  virtual ~vtkMRMLApplicationLogic();
226 
227  virtual void SetMRMLSceneInternal(vtkMRMLScene *newScene) VTK_OVERRIDE;
228 
229  void SetSelectionNode(vtkMRMLSelectionNode* );
230  void SetInteractionNode(vtkMRMLInteractionNode* );
231 
232  void SaveStorableNodeToSlicerDataBundleDirectory(vtkMRMLStorableNode* storableNode,
233  std::string &dataDir);
234 
235 private:
236 
240  std::map<vtkMRMLStorageNode*, std::vector<std::string> > OriginalStorageNodeFileNames;
241 
243  void operator=(const vtkMRMLApplicationLogic&);
244 
245  class vtkInternal;
246  vtkInternal* Internal;
247 
248 };
249 
250 
251 #endif
252 
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.
virtual void SetMRMLSceneInternal(vtkMRMLScene *newScene)
A superclass for other storage nodes.
Slicer logic class for view manipulation.
MRML node to represent a 3D view.
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.