Slicer 5.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLFileIOHandler.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==============================================================================*/
17
18#ifndef __vtkMRMLFileIOHandler_h
19#define __vtkMRMLFileIOHandler_h
20
21#include "vtkMRMLIOProperties.h"
22#include "vtkMRMLLogicExport.h"
23
25
26#include <vtkNew.h>
27#include <vtkObject.h>
28#include <vtkWeakPointer.h>
29
30#include <string>
31#include <vector>
32
33class vtkMRMLScene;
36
41class VTK_MRML_LOGIC_EXPORT vtkMRMLFileIOHandler : public vtkObject
42{
43public:
45 vtkTypeMacro(vtkMRMLFileIOHandler, vtkObject);
46 void PrintSelf(ostream& os, vtkIndent indent) override;
47
50 vtkGetMacro(FileType, std::string);
51 vtkSetMacro(FileType, std::string);
52
54 vtkGetMacro(Description, std::string);
55 vtkSetMacro(Description, std::string);
56
58 void SetNameFilters(const std::vector<std::string>& filters);
59 const std::vector<std::string>& GetNameFilters() const { return this->NameFilters; }
60
63 const std::vector<std::string>& GetExtensions() const { return this->Extensions; }
64
67 virtual bool MatchesExtension(const std::string& filePath) const;
69 virtual std::string GetMatchedExtension(const std::string& filePath) const;
70
72 virtual void SetScene(vtkMRMLScene* scene);
74
78
80 virtual bool IsWriter() const { return false; }
81
86
88
90
94
98
102
106
111
119 static std::vector<std::string> GetMatchingNameFilters(const std::string& filePath,
120 const std::vector<std::string>& nameFilters,
121 bool requireReadableFile,
122 int* longestExtensionMatch = nullptr);
123
126 static std::vector<std::string> NameFilterToWildcards(const std::string& nameFilter);
127
129 static bool WildcardMatch(const std::string& pattern, const std::string& text);
130
133 static std::string LongestMatchingExtension(const std::string& filePath, const std::vector<std::string>& extensions);
135 static std::vector<std::string> ExtensionsFromNameFilter(const std::string& nameFilter);
136
137protected:
140
141 std::string FileType;
142 std::string Description;
143 std::vector<std::string> NameFilters;
144 std::vector<std::string> Extensions;
145 vtkWeakPointer<vtkMRMLScene> Scene;
146 vtkWeakPointer<vtkMRMLFileIOManager> FileIOManager;
147 vtkNew<vtkMRMLIOProperties> OptionDefaults;
148 vtkNew<vtkMRMLMessageCollection> UserMessages;
149
150private:
152 void operator=(const vtkMRMLFileIOHandler&) = delete;
153};
154
155#endif
vtkMRMLMessageCollection * GetUserMessages() const
std::string GetOptionsDescriptionJSON(vtkMRMLIOProperties *properties)
void SetNameFilters(const std::vector< std::string > &filters)
The name filters, as Slicer writes them: "Mimics project (*.mcs *.mcs.gz)".
virtual void GetOptionsDescription(vtkMRMLIOOptionsDescription *description)
static std::string LongestMatchingExtension(const std::string &filePath, const std::vector< std::string > &extensions)
void GetOptionValues(vtkMRMLIOProperties *properties, vtkMRMLIOProperties *values)
vtkMRMLFileIOManager * GetFileIOManager() const
static std::vector< std::string > GetMatchingNameFilters(const std::string &filePath, const std::vector< std::string > &nameFilters, bool requireReadableFile, int *longestExtensionMatch=nullptr)
std::vector< std::string > NameFilters
virtual bool IsWriter() const
Whether this writes rather than reads.
vtkMRMLScene * GetScene() const
vtkNew< vtkMRMLIOProperties > OptionDefaults
static vtkMRMLFileIOHandler * New()
const std::vector< std::string > & GetNameFilters() const
std::vector< std::string > Extensions
virtual std::string GetMatchedExtension(const std::string &filePath) const
The longest matching extension of filePath, or an empty string.
vtkNew< vtkMRMLMessageCollection > UserMessages
virtual void SetScene(vtkMRMLScene *scene)
Where the nodes go, and where messages for the user are collected.
static bool WildcardMatch(const std::string &pattern, const std::string &text)
Case-insensitive wildcard matching of the whole text. Supported wildcards: '*', '?...
virtual bool MatchesExtension(const std::string &filePath) const
void SetFileIOManager(vtkMRMLFileIOManager *manager)
vtkMRMLIOProperties * GetOptionDefaults()
static std::vector< std::string > NameFilterToWildcards(const std::string &nameFilter)
void PrintSelf(ostream &os, vtkIndent indent) override
vtkWeakPointer< vtkMRMLFileIOManager > FileIOManager
const std::vector< std::string > & GetExtensions() const
vtkWeakPointer< vtkMRMLScene > Scene
void FillOptionsDescription(vtkMRMLIOProperties *properties, vtkMRMLIOOptionsDescription *description)
~vtkMRMLFileIOHandler() override
static std::vector< std::string > ExtensionsFromNameFilter(const std::string &nameFilter)
The extensions named by a filter such as "Mimics project (*.mcs *.mcs.gz)".
A set of MRML Nodes that supports serialization and undo/redo.