Slicer 5.6
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
138
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 = nullptr, vtkMRMLMessageCollection* userMessages=nullptr);
167
171 bool OpenSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory, vtkMRMLMessageCollection* userMessages=nullptr);
172
176 std::string UnpackSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory);
177
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 PauseRenderEvent = vtkCommand::UserEvent + 101,
197 };
202 unsigned int Delay{100};
204 vtkObject* Caller{nullptr};
206 unsigned long EventID{vtkCommand::ModifiedEvent};
208 void* CallData{nullptr};
209 };
211 void InvokeEventWithDelay(unsigned int delayInMs,
212 vtkObject* caller,
213 unsigned long eventID = vtkCommand::ModifiedEvent,
214 void* callData = nullptr);
215
217 const char* GetTemporaryPath();
218
220 void SetTemporaryPath(const char* path);
221
224 void SaveSceneScreenshot(vtkImageData* screenshot);
225
233 virtual void PauseRender();
234
238 virtual void ResumeRender();
239
241 virtual void EditNode(vtkMRMLNode* node);
242
248 void SetModuleLogic(const char* moduleName, vtkMRMLAbstractLogic* moduleLogic);
249
254 vtkMRMLAbstractLogic* GetModuleLogic(const char* moduleName) const;
255
264
267
270
273
278 void SetFontFileName(int fontFamily, const std::string& fontFileName);
279 std::string GetFontFileName(int fontFamily);
281
283 std::string GetFontFilePath(const std::string& fontFileName);
284
286 std::string GetFontsDirectory();
287
291 void UseCustomFontFile(vtkTextProperty* textProperty);
292
293protected:
294
297
298 void SetMRMLSceneInternal(vtkMRMLScene *newScene) override;
299
302
303 void ProcessMRMLNodesEvents(vtkObject* caller, unsigned long event, void* callData) override;
304
307 void OnMRMLSceneStartImport() override;
308 void OnMRMLSceneEndImport() override;
309 void OnMRMLSceneStartRestore() override;
310 void OnMRMLSceneEndRestore() override;
311
312private:
313
315 void operator=(const vtkMRMLApplicationLogic&) = delete;
316
317 class vtkInternal;
318 vtkInternal* Internal;
319
320};
321
322
323#endif
324
Superclass for MRML logic classes.
static std::string PercentEncode(std::string s)
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)
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.