Slicer 5.13
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
41class vtkMRMLViewNode;
42class vtkTextProperty;
43
44// VTK includes
45class vtkCollection;
46class vtkImageData;
47
48// STD includes
49#include <vector>
50
51class VTK_MRML_LOGIC_EXPORT vtkMRMLApplicationLogic : public vtkMRMLAbstractLogic
52{
53public:
55 void PrintSelf(ostream& os, vtkIndent indent) override;
57
60
63
65 void SetSliceLogics(vtkCollection* sliceLogics);
66 vtkCollection* GetSliceLogics() const;
68 vtkMRMLSliceLogic* GetSliceLogicByLayoutName(const char* layoutName) const;
71
73 void SetViewLogics(vtkCollection* viewLogics);
74 vtkCollection* GetViewLogics() const;
76 vtkMRMLViewLogic* GetViewLogicByLayoutName(const char* layoutName) const;
77
82 void SetColorLogic(vtkMRMLColorLogic* newColorLogic);
84
89
98 void PropagateVolumeSelection(int fit = 1);
99
106
113
120
128
132 void PropagateVolumeSelection(int layer, int fit);
133
138 void FitSliceToAll(bool onlyIfPropagateVolumeSelectionAllowed = false, bool resetOrientation = true);
139
147 void FitSliceToBackground(bool onlyIfPropagateVolumeSelectionAllowed = false, bool resetOrientation = true);
148
151
155
158
161 bool Zip(const char* zipFileName, const char* directoryToZip);
162
165 bool Unzip(const char* zipFileName, const char* destinationDirectory);
166
176 static std::string PercentEncode(std::string s);
177
183 bool SaveSceneToSlicerDataBundleDirectory(const char* sdbDir, vtkImageData* screenShot = nullptr, vtkMRMLMessageCollection* userMessages = nullptr);
184
188 bool OpenSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory, vtkMRMLMessageCollection* userMessages = nullptr);
189
193 std::string UnpackSlicerDataBundle(const char* sdbFilePath, const char* temporaryDirectory);
194
197 static int LoadDefaultParameterSets(vtkMRMLScene* scene, const std::vector<std::string>& directories);
198
201 static std::vector<std::string> FindTextFiles(const std::vector<std::string>& directories);
202
208 static std::string CreateUniqueFileName(const std::string& filename, const std::string& knownExtension = "");
209
222
224 {
227 unsigned int Delay{ 100 };
229 vtkObject* Caller{ nullptr };
231 unsigned long EventID{ vtkCommand::ModifiedEvent };
233 void* CallData{ nullptr };
234 };
235
236 void InvokeEventWithDelay(unsigned int delayInMs, vtkObject* caller, unsigned long eventID = vtkCommand::ModifiedEvent, void* callData = nullptr);
237
239 const char* GetTemporaryPath();
240
242 void SetTemporaryPath(const char* path);
243
246 void SaveSceneScreenshot(vtkImageData* screenshot);
247
255 virtual void PauseRender();
256
260 virtual void ResumeRender();
261
263 virtual void EditNode(vtkMRMLNode* node);
264
273 void SetModuleLogic(const char* moduleName, vtkMRMLAbstractLogic* moduleLogic);
274
279 vtkMRMLAbstractLogic* GetModuleLogic(const char* moduleName) const;
280
289
292
295
298
303 void SetFontFileName(int fontFamily, const std::string& fontFileName);
304 std::string GetFontFileName(int fontFamily);
306
308 std::string GetFontFilePath(const std::string& fontFileName);
309
311 std::string GetFontsDirectory();
312
316 void UseCustomFontFile(vtkTextProperty* textProperty);
317
321 void SetHomeDirectory(const std::string& path);
322 const std::string& GetHomeDirectory() const;
324
330 void SetShareDirectory(const std::string& path);
331 const std::string& GetShareDirectory() const;
333
337 std::string GetShareFilePath(const std::string& fileName) const;
338 std::string GetShareFilePath(const std::string& subfolderName, const std::string& fileName) const;
340
341protected:
344
345 void SetMRMLSceneInternal(vtkMRMLScene* newScene) override;
346
349
350 void ProcessMRMLNodesEvents(vtkObject* caller, unsigned long event, void* callData) override;
351
352 void FitSliceToContent(bool all, bool onlyIfPropagateVolumeSelectionAllowed = false, bool resetOrientation = true);
353
356 void OnMRMLSceneStartImport() override;
357 void OnMRMLSceneEndImport() override;
358 void OnMRMLSceneStartRestore() override;
359 void OnMRMLSceneEndRestore() override;
360
361private:
363 void operator=(const vtkMRMLApplicationLogic&) = delete;
364
365 class vtkInternal;
366 vtkInternal* Internal;
367};
368
369#endif
std::string GetShareFilePath(const std::string &fileName) const
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 SetHomeDirectory(const std::string &path)
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.
const std::string & GetHomeDirectory() const
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)
std::string GetShareFilePath(const std::string &subfolderName, const std::string &fileName) const
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)
vtkMRMLFileIOManager * GetFileIOManager() const
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
static std::vector< std::string > FindTextFiles(const std::vector< std::string > &directories)
void OnMRMLSceneStartRestore() override
void SetShareDirectory(const std::string &path)
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)
const std::string & GetShareDirectory() const
~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.