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 : public vtkMRMLAbstractLogic
51{
52public:
54 void PrintSelf(ostream& os, vtkIndent indent) override;
56
59
62
64 void SetSliceLogics(vtkCollection* sliceLogics);
65 vtkCollection* GetSliceLogics() const;
67 vtkMRMLSliceLogic* GetSliceLogicByLayoutName(const char* layoutName) const;
70
72 void SetViewLogics(vtkCollection* viewLogics);
73 vtkCollection* GetViewLogics() const;
75 vtkMRMLViewLogic* GetViewLogicByLayoutName(const char* layoutName) const;
76
81 void SetColorLogic(vtkMRMLColorLogic* newColorLogic);
83
92 void PropagateVolumeSelection(int fit = 1);
93
100
107
114
122
126 void PropagateVolumeSelection(int layer, int fit);
127
132 void FitSliceToAll(bool onlyIfPropagateVolumeSelectionAllowed = false, bool resetOrientation = true);
133
141 void FitSliceToBackground(bool onlyIfPropagateVolumeSelectionAllowed = false, bool resetOrientation = true);
142
145
148
151 bool Zip(const char* zipFileName, const char* directoryToZip);
152
155 bool Unzip(const char* zipFileName, const char* destinationDirectory);
156
166 static std::string PercentEncode(std::string s);
167
173 bool SaveSceneToSlicerDataBundleDirectory(const char* sdbDir, vtkImageData* screenShot = nullptr, vtkMRMLMessageCollection* userMessages = nullptr);
174
178 bool OpenSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory, vtkMRMLMessageCollection* userMessages = nullptr);
179
183 std::string UnpackSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory);
184
187 static int LoadDefaultParameterSets(vtkMRMLScene* scene, const std::vector<std::string>& directories);
188
194 static std::string CreateUniqueFileName(const std::string& filename, const std::string& knownExtension = "");
195
198 {
199 RequestInvokeEvent = vtkCommand::UserEvent + 1,
200 PauseRenderEvent = vtkCommand::UserEvent + 101,
204 };
205
207 {
210 unsigned int Delay{ 100 };
212 vtkObject* Caller{ nullptr };
214 unsigned long EventID{ vtkCommand::ModifiedEvent };
216 void* CallData{ nullptr };
217 };
218
219 void InvokeEventWithDelay(unsigned int delayInMs, vtkObject* caller, unsigned long eventID = vtkCommand::ModifiedEvent, void* callData = nullptr);
220
222 const char* GetTemporaryPath();
223
225 void SetTemporaryPath(const char* path);
226
229 void SaveSceneScreenshot(vtkImageData* screenshot);
230
238 virtual void PauseRender();
239
243 virtual void ResumeRender();
244
246 virtual void EditNode(vtkMRMLNode* node);
247
253 void SetModuleLogic(const char* moduleName, vtkMRMLAbstractLogic* moduleLogic);
254
259 vtkMRMLAbstractLogic* GetModuleLogic(const char* moduleName) const;
260
269
272
275
278
283 void SetFontFileName(int fontFamily, const std::string& fontFileName);
284 std::string GetFontFileName(int fontFamily);
286
288 std::string GetFontFilePath(const std::string& fontFileName);
289
291 std::string GetFontsDirectory();
292
296 void UseCustomFontFile(vtkTextProperty* textProperty);
297
298protected:
301
302 void SetMRMLSceneInternal(vtkMRMLScene* newScene) override;
303
306
307 void ProcessMRMLNodesEvents(vtkObject* caller, unsigned long event, void* callData) override;
308
309 void FitSliceToContent(bool all, bool onlyIfPropagateVolumeSelectionAllowed = false, bool resetOrientation = true);
310
313 void OnMRMLSceneStartImport() override;
314 void OnMRMLSceneEndImport() override;
315 void OnMRMLSceneStartRestore() override;
316 void OnMRMLSceneEndRestore() override;
317
318private:
320 void operator=(const vtkMRMLApplicationLogic&) = delete;
321
322 class vtkInternal;
323 vtkInternal* Internal;
324};
325
326#endif
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.
void * CallData
Optional call data. 0 by default.
vtkObject * Caller
the caller to call InvokeEvent() on.
unsigned long EventID
The event id of InvokeEvent. ModifiedEvent by default.