Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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
26
27#include "vtkMRMLLogicExport.h"
29
40class vtkMRMLViewNode;
41class vtkTextProperty;
42
43// VTK includes
44class vtkCollection;
45class vtkImageData;
46
47// STD includes
48#include <vector>
49
50class VTK_MRML_LOGIC_EXPORT vtkMRMLApplicationLogic
52{
53public:
54
56 void PrintSelf(ostream& os, vtkIndent indent) override;
58
61
64
66 void SetSliceLogics(vtkCollection* sliceLogics);
67 vtkCollection* GetSliceLogics()const;
69 vtkMRMLSliceLogic* GetSliceLogicByLayoutName(const char* layoutName) const;
72
74 void SetViewLogics(vtkCollection* viewLogics);
75 vtkCollection* GetViewLogics()const;
77 vtkMRMLViewLogic* GetViewLogicByLayoutName(const char* layoutName) const;
78
83 void SetColorLogic(vtkMRMLColorLogic* newColorLogic);
85
94 void PropagateVolumeSelection(int fit = 1);
95
102
109
116
118 {
119 LabelLayer = 0x1,
120 ForegroundLayer = 0x2,
121 BackgroundLayer = 0x4,
122 AllLayers = LabelLayer | ForegroundLayer | BackgroundLayer
123 };
124
128 void PropagateVolumeSelection(int layer, int fit);
129
134 void FitSliceToAll(bool onlyIfPropagateVolumeSelectionAllowed=false, bool resetOrientation=true);
135
143 void FitSliceToBackground(bool onlyIfPropagateVolumeSelectionAllowed=false, bool resetOrientation=true);
144
147
150
153 bool Zip(const char* zipFileName, const char* directoryToZip);
154
157 bool Unzip(const char* zipFileName, const char* destinationDirectory);
158
168 static std::string PercentEncode(std::string s);
169
175 bool SaveSceneToSlicerDataBundleDirectory(const char* sdbDir, vtkImageData* screenShot = nullptr, vtkMRMLMessageCollection* userMessages=nullptr);
176
180 bool OpenSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory, vtkMRMLMessageCollection* userMessages=nullptr);
181
185 std::string UnpackSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory);
186
190 const std::vector<std::string>& directories);
191
197 static std::string CreateUniqueFileName(const std::string &filename, const std::string& knownExtension="");
198
200 enum Events{
201 RequestInvokeEvent = vtkCommand::UserEvent + 1,
202 PauseRenderEvent = vtkCommand::UserEvent + 101,
206 };
211 unsigned int Delay{100};
213 vtkObject* Caller{nullptr};
215 unsigned long EventID{vtkCommand::ModifiedEvent};
217 void* CallData{nullptr};
218 };
220 void InvokeEventWithDelay(unsigned int delayInMs,
221 vtkObject* caller,
222 unsigned long eventID = vtkCommand::ModifiedEvent,
223 void* callData = nullptr);
224
226 const char* GetTemporaryPath();
227
229 void SetTemporaryPath(const char* path);
230
233 void SaveSceneScreenshot(vtkImageData* screenshot);
234
242 virtual void PauseRender();
243
247 virtual void ResumeRender();
248
250 virtual void EditNode(vtkMRMLNode* node);
251
257 void SetModuleLogic(const char* moduleName, vtkMRMLAbstractLogic* moduleLogic);
258
263 vtkMRMLAbstractLogic* GetModuleLogic(const char* moduleName) const;
264
273
276
279
282
287 void SetFontFileName(int fontFamily, const std::string& fontFileName);
288 std::string GetFontFileName(int fontFamily);
290
292 std::string GetFontFilePath(const std::string& fontFileName);
293
295 std::string GetFontsDirectory();
296
300 void UseCustomFontFile(vtkTextProperty* textProperty);
301
302protected:
303
306
307 void SetMRMLSceneInternal(vtkMRMLScene *newScene) override;
308
311
312 void ProcessMRMLNodesEvents(vtkObject* caller, unsigned long event, void* callData) override;
313
314 void FitSliceToContent(bool all, bool onlyIfPropagateVolumeSelectionAllowed=false, bool resetOrientation=true);
315
318 void OnMRMLSceneStartImport() override;
319 void OnMRMLSceneEndImport() override;
320 void OnMRMLSceneStartRestore() override;
321 void OnMRMLSceneEndRestore() override;
322
323private:
324
326 void operator=(const vtkMRMLApplicationLogic&) = delete;
327
328 class vtkInternal;
329 vtkInternal* Internal;
330
331};
332
333
334#endif
Superclass for MRML logic classes.
static std::string PercentEncode(std::string s)
void FitSliceToContent(bool all, bool onlyIfPropagateVolumeSelectionAllowed=false, bool resetOrientation=true)
void SetIntersectingSlicesLineThicknessMode(int mode)
void PropagateBackgroundVolumeSelection(int fit=1)
void OnMRMLSceneStartBatchProcess() override
void ProcessMRMLNodesEvents(vtkObject *caller, unsigned long event, void *callData) override
vtkMRMLSliceLogic * GetSliceLogic(vtkMRMLSliceNode *sliceNode) const
Events
List of custom events fired by the class.
vtkMRMLViewLogic * GetViewLogic(vtkMRMLViewNode *viewNode) const
void OnMRMLSceneEndRestore() override
void SetIntersectingSlicesIntersectionMode(int mode)
void SetModuleLogic(const char *moduleName, vtkMRMLAbstractLogic *moduleLogic)
vtkMRMLColorLogic * GetColorLogic() const
bool Unzip(const char *zipFileName, const char *destinationDirectory)
bool OpenSlicerDataBundle(const char *sdbFilePath, const char *temporaryDirectory, vtkMRMLMessageCollection *userMessages=nullptr)
vtkCollection * GetSliceLogics() const
vtkMRMLSliceLogic * GetSliceLogicByLayoutName(const char *layoutName) const
void UseCustomFontFile(vtkTextProperty *textProperty)
void SetInteractionNode(vtkMRMLInteractionNode *)
void SetViewLogics(vtkCollection *viewLogics)
All the view logics in the application.
bool Zip(const char *zipFileName, const char *directoryToZip)
virtual void ResumeRender()
std::string GetFontFileName(int fontFamily)
void OnMRMLSceneEndImport() override
std::string GetFontsDirectory()
Get folder where font files are stored ("Fonts" subfolder in application share folder).
void SetSelectionNode(vtkMRMLSelectionNode *)
void SaveSceneScreenshot(vtkImageData *screenshot)
void PropagateTableSelection()
Propagate selected table in the SelectionNode to table view nodes.
bool GetIntersectingSlicesEnabled(IntersectingSlicesOperation operation)
vtkCollection * GetViewLogics() const
void InvokeEventWithDelay(unsigned int delayInMs, vtkObject *caller, unsigned long eventID=vtkCommand::ModifiedEvent, void *callData=nullptr)
Conveniently calls an InvokeEvent on an object with a delay.
void PropagateVolumeSelection(int layer, int fit)
virtual void PauseRender()
void PropagateVolumeSelection(int fit=1)
virtual void EditNode(vtkMRMLNode *node)
Requests the application to show user interface for editing a node.
void SetSliceLogics(vtkCollection *sliceLogics)
All the slice logics in the application.
bool SaveSceneToSlicerDataBundleDirectory(const char *sdbDir, vtkImageData *screenShot=nullptr, vtkMRMLMessageCollection *userMessages=nullptr)
void PropagateLabelVolumeSelection(int fit=1)
static std::string CreateUniqueFileName(const std::string &filename, const std::string &knownExtension="")
void SetTemporaryPath(const char *path)
Set the temporary path the logics can use. The path should be set by the application.
void PropagatePlotChartSelection()
Propagate selected PlotChart in the SelectionNode to Plot view nodes.
void SetColorLogic(vtkMRMLColorLogic *newColorLogic)
std::string GetFontFilePath(const std::string &fontFileName)
Get full path to custom font file for rendering views from font file name.
void OnMRMLSceneEndBatchProcess() override
void PropagateForegroundVolumeSelection(int fit=1)
void FitSliceToBackground(bool onlyIfPropagateVolumeSelectionAllowed=false, bool resetOrientation=true)
vtkMRMLViewLogic * GetViewLogicByLayoutName(const char *layoutName) const
void PrintSelf(ostream &os, vtkIndent indent) override
void OnMRMLSceneStartRestore() override
void OnMRMLSceneStartImport() override
const char * GetTemporaryPath()
Return the temporary path that was set by the application.
vtkMRMLInteractionNode * GetInteractionNode() const
Get default Interaction node.
void SetFontFileName(int fontFamily, const std::string &fontFileName)
vtkMRMLSliceLogic * GetSliceLogicByModelDisplayNode(vtkMRMLModelDisplayNode *displayNode) const
Get slice logic from slice model display node.
std::string UnpackSlicerDataBundle(const char *sdbFilePath, const char *temporaryDirectory)
int GetIntersectingSlicesLineThicknessMode()
vtkMRMLAbstractLogic * GetModuleLogic(const char *moduleName) const
void FitSliceToAll(bool onlyIfPropagateVolumeSelectionAllowed=false, bool resetOrientation=true)
void SetMRMLSceneInternal(vtkMRMLScene *newScene) override
static int LoadDefaultParameterSets(vtkMRMLScene *scene, const std::vector< std::string > &directories)
int GetIntersectingSlicesIntersectionMode()
void SetIntersectingSlicesEnabled(IntersectingSlicesOperation operation, bool enabled)
~vtkMRMLApplicationLogic() override
static vtkMRMLApplicationLogic * New()
vtkMRMLSelectionNode * GetSelectionNode() const
Get default Selection node.
MRML logic class for color manipulation.
MRML node to represent a display property of 3D surface model.
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
MRML node for storing information about the active nodes in the scene.
Slicer logic class for slice manipulation.
MRML node for storing a slice through RAS space.
MRML node to represent a 3D surface model.
A superclass for other storage nodes.
Slicer logic class for view manipulation.
MRML node to represent a 3D view.
Structure passed as calldata pointer in the RequestEvent invoked event.