Slicer 5.11
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
191 static std::vector<std::string> FindTextFiles(const std::vector<std::string>& directories);
192
198 static std::string CreateUniqueFileName(const std::string& filename, const std::string& knownExtension = "");
199
202 {
203 RequestInvokeEvent = vtkCommand::UserEvent + 1,
204 PauseRenderEvent = vtkCommand::UserEvent + 101,
208 };
209
211 {
214 unsigned int Delay{ 100 };
216 vtkObject* Caller{ nullptr };
218 unsigned long EventID{ vtkCommand::ModifiedEvent };
220 void* CallData{ nullptr };
221 };
222
223 void InvokeEventWithDelay(unsigned int delayInMs, vtkObject* caller, unsigned long eventID = vtkCommand::ModifiedEvent, 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
305 void SetHomeDirectory(const std::string& path);
306 const std::string& GetHomeDirectory() const;
308
314 void SetShareDirectory(const std::string& path);
315 const std::string& GetShareDirectory() const;
317
321 std::string GetShareFilePath(const std::string& fileName) const;
322 std::string GetShareFilePath(const std::string& subfolderName, const std::string& fileName) const;
324
325protected:
328
329 void SetMRMLSceneInternal(vtkMRMLScene* newScene) override;
330
333
334 void ProcessMRMLNodesEvents(vtkObject* caller, unsigned long event, void* callData) override;
335
336 void FitSliceToContent(bool all, bool onlyIfPropagateVolumeSelectionAllowed = false, bool resetOrientation = true);
337
340 void OnMRMLSceneStartImport() override;
341 void OnMRMLSceneEndImport() override;
342 void OnMRMLSceneStartRestore() override;
343 void OnMRMLSceneEndRestore() override;
344
345private:
347 void operator=(const vtkMRMLApplicationLogic&) = delete;
348
349 class vtkInternal;
350 vtkInternal* Internal;
351};
352
353#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)
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.