Slicer 5.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkSlicerScriptedFileReaderBridge Class Reference

Python bridge for vtkMRMLFileReader. More...

#include <Base/Logic/vtkSlicerScriptedFileReaderBridge.h>

Inheritance diagram for vtkSlicerScriptedFileReaderBridge:
Collaboration diagram for vtkSlicerScriptedFileReaderBridge:

Public Types

typedef vtkMRMLFileReader Superclass
 
- Public Types inherited from vtkMRMLFileReader
typedef vtkMRMLFileIOHandler Superclass
 
- Public Types inherited from vtkMRMLFileIOHandler
typedef vtkObject Superclass
 

Public Member Functions

bool CanLoadFile (const std::string &filePath) override
 
double CanLoadFileConfidence (const std::string &filePath) override
 
std::string ExamineFileList (std::vector< std::string > &fileList, vtkMRMLIOProperties *ioProperties) override
 The file list is passed to the Python method as a list, which the method must modify in place.
 
double ExamineFileListConfidence (std::vector< std::string > &fileList, vtkMRMLIOProperties *ioProperties) override
 The file list is passed to the Python method as a list, which the method must modify in place.
 
virtual const char * GetClassName ()
 
void GetOptionsDescription (vtkMRMLIOOptionsDescription *description) override
 
vtkWeakReference * GetWeakReference ()
 
virtual int IsA (const char *type)
 
bool Load (vtkMRMLIOProperties *properties) override
 
void PrintSelf (ostream &os, vtkIndent indent) override
 
- Public Member Functions inherited from vtkMRMLFileReader
void AddLoadedNodeID (const std::string &nodeID)
 
void ClearLoadedNodeIDs ()
 
virtual double GetConfidenceForMatchingExtension ()
 
const std::vector< std::string > & GetLoadedNodeIDs () const
 The nodes the last Load added, by node ID.
 
std::vector< std::string > GetSupportedNameFilters (const std::string &filePath)
 
std::vector< std::string > GetSupportedNameFilters (const std::string &filePath, int &longestExtensionMatch)
 
void PrintSelf (ostream &os, vtkIndent indent) override
 
virtual void SetConfidenceForMatchingExtension (double)
 
void SetLoadedNodeIDs (const std::vector< std::string > &nodeIDs)
 
- Public Member Functions inherited from vtkMRMLFileIOHandler
void FillOptionsDescription (vtkMRMLIOProperties *properties, vtkMRMLIOOptionsDescription *description)
 
virtual std::string GetDescription ()
 What to call this in a file dialog ("Volume", "Mimics project").
 
const std::vector< std::string > & GetExtensions () const
 
vtkMRMLFileIOManager * GetFileIOManager () const
 
virtual std::string GetFileType ()
 
virtual std::string GetMatchedExtension (const std::string &filePath) const
 The longest matching extension of filePath, or an empty string.
 
const std::vector< std::string > & GetNameFilters () const
 
vtkMRMLIOProperties * GetOptionDefaults ()
 
std::string GetOptionsDescriptionJSON (vtkMRMLIOProperties *properties)
 
void GetOptionValues (vtkMRMLIOProperties *properties, vtkMRMLIOProperties *values)
 
vtkMRMLScene * GetScene () const
 
vtkMRMLMessageCollection * GetUserMessages () const
 
virtual bool IsWriter () const
 Whether this writes rather than reads.
 
virtual bool MatchesExtension (const std::string &filePath) const
 
void PrintSelf (ostream &os, vtkIndent indent) override
 
virtual void SetDescription (std::string)
 
void SetFileIOManager (vtkMRMLFileIOManager *manager)
 
virtual void SetFileType (std::string)
 
void SetNameFilters (const std::vector< std::string > &filters)
 The name filters, as Slicer writes them: "Mimics project (*.mcs *.mcs.gz)".
 
virtual void SetScene (vtkMRMLScene *scene)
 Where the nodes go, and where messages for the user are collected.
 

Static Public Member Functions

static int IsTypeOf (const char *type)
 
static vtkSlicerScriptedFileReaderBridge * New ()
 
static vtkSlicerScriptedFileReaderBridge * SafeDownCast (vtkObject *o)
 
static PyObject * PropertiesToDict (vtkMRMLIOProperties *properties)
 
static void UpdatePropertiesFromDict (vtkMRMLIOProperties *properties, PyObject *dict)
 
- Static Public Member Functions inherited from vtkMRMLFileReader
static int IsTypeOf (const char *type)
 
static vtkMRMLFileReader * New ()
 
static vtkMRMLFileReader * SafeDownCast (vtkObject *o)
 
- Static Public Member Functions inherited from vtkMRMLFileIOHandler
static std::vector< std::string > ExtensionsFromNameFilter (const std::string &nameFilter)
 The extensions named by a filter such as "Mimics project (*.mcs *.mcs.gz)".
 
static std::vector< std::string > GetMatchingNameFilters (const std::string &filePath, const std::vector< std::string > &nameFilters, bool requireReadableFile, int *longestExtensionMatch=nullptr)
 
static int IsTypeOf (const char *type)
 
static std::string LongestMatchingExtension (const std::string &filePath, const std::vector< std::string > &extensions)
 
static std::vector< std::string > NameFilterToWildcards (const std::string &nameFilter)
 
static vtkMRMLFileIOHandler * New ()
 
static vtkMRMLFileIOHandler * SafeDownCast (vtkObject *o)
 
static bool WildcardMatch (const std::string &pattern, const std::string &text)
 Case-insensitive wildcard matching of the whole text. Supported wildcards: '*', '?', and character sets ("[abc]", "[!abc]").
 

Protected Member Functions

void UnRegisterInternal (vtkObjectBase *o, vtkTypeBool check) override
 
 vtkSlicerScriptedFileReaderBridge ()
 
 ~vtkSlicerScriptedFileReaderBridge () override
 
- Protected Member Functions inherited from vtkMRMLFileReader
 vtkMRMLFileReader ()
 
 ~vtkMRMLFileReader () override
 
- Protected Member Functions inherited from vtkMRMLFileIOHandler
 vtkMRMLFileIOHandler ()
 
 ~vtkMRMLFileIOHandler () override
 

Additional Inherited Members

- Static Protected Member Functions inherited from vtkMRMLFileReader
static bool EndsWithNoCase (const std::string &text, const std::string &suffix)
 Returns true if the string ends with the suffix (case-insensitive).
 
static std::string ReadFileHeader (const std::string &filePath, size_t maxLength)
 
- Protected Attributes inherited from vtkMRMLFileReader
double ConfidenceForMatchingExtension { 0.5 }
 
std::vector< std::string > LoadedNodeIDs
 
- Protected Attributes inherited from vtkMRMLFileIOHandler
std::string Description
 
std::vector< std::string > Extensions
 
vtkWeakPointer< vtkMRMLFileIOManager > FileIOManager
 
std::string FileType
 
std::vector< std::string > NameFilters
 
vtkNew< vtkMRMLIOProperties > OptionDefaults
 
vtkWeakPointer< vtkMRMLScene > Scene
 
vtkNew< vtkMRMLMessageCollection > UserMessages
 

Detailed Description

Python bridge for vtkMRMLFileReader.

File readers are implemented in Python by subclassing slicer.vtkSlicerScriptedFileReader (defined in slicer.ScriptedFileIO), which is a Python subclass of this class. This class calls the methods that are overridden in Python and uses the vtkMRMLFileReader implementation of the other methods.

See https://slicer.readthedocs.io/en/latest/developer_guide/mrml_overview.html#readers-and-writers-implemented-in-python

See also
vtkSlicerScriptedFileWriterBridge

Definition at line 47 of file vtkSlicerScriptedFileReaderBridge.h.

Member Typedef Documentation

◆ Superclass

Constructor & Destructor Documentation

◆ vtkSlicerScriptedFileReaderBridge()

vtkSlicerScriptedFileReaderBridge::vtkSlicerScriptedFileReaderBridge ( )
protected

◆ ~vtkSlicerScriptedFileReaderBridge()

vtkSlicerScriptedFileReaderBridge::~vtkSlicerScriptedFileReaderBridge ( )
overrideprotected

Member Function Documentation

◆ CanLoadFile()

bool vtkSlicerScriptedFileReaderBridge::CanLoadFile ( const std::string & filePath)
overridevirtual

Returns true if the reader can load this file. Default implementation is a simple and fast, it just checks if file extension matches any of the name filters.

Reimplemented from vtkMRMLFileReader.

◆ CanLoadFileConfidence()

double vtkSlicerScriptedFileReaderBridge::CanLoadFileConfidence ( const std::string & filePath)
overridevirtual

Returns a positive number (>0) if the reader can load this file. The higher the returned value is the more confident the reader it is the most suitable class to load the file. By default, the method calls CanLoadFile and if it returns true then the returned confidence value is ConfidenceForMatchingExtension (0.5 by default)

  • 0.01 * matchedFileExtensionLength. The additional confidence for longer matched file extensions allow prioritization of more specific readers. For example, "*.seg.nrrd" is more specific than "*.nrrd"; "*.nrrd" is more specific than "*.*".

Reimplemented from vtkMRMLFileReader.

◆ ExamineFileList()

std::string vtkSlicerScriptedFileReaderBridge::ExamineFileList ( std::vector< std::string > & fileList,
vtkMRMLIOProperties * ioProperties )
overridevirtual

The file list is passed to the Python method as a list, which the method must modify in place.

Reimplemented from vtkMRMLFileReader.

◆ ExamineFileListConfidence()

double vtkSlicerScriptedFileReaderBridge::ExamineFileListConfidence ( std::vector< std::string > & fileList,
vtkMRMLIOProperties * ioProperties )
overridevirtual

The file list is passed to the Python method as a list, which the method must modify in place.

Reimplemented from vtkMRMLFileReader.

◆ GetClassName()

virtual const char * vtkSlicerScriptedFileReaderBridge::GetClassName ( )
virtual

Reimplemented from vtkMRMLFileReader.

◆ GetOptionsDescription()

void vtkSlicerScriptedFileReaderBridge::GetOptionsDescription ( vtkMRMLIOOptionsDescription * description)
overridevirtual

Options of the reader or writer (properties that the user may set). See https://slicer.readthedocs.io/en/latest/developer_guide/mrml_overview.html#reader-and-writer-options Describe the options. The default implementation describes no options. Properties (context and current values) and defaults are already set in the description.

Reimplemented from vtkMRMLFileIOHandler.

◆ GetWeakReference()

vtkWeakReference * vtkSlicerScriptedFileReaderBridge::GetWeakReference ( )

Weak reference to this object. It is cleared when the object starts to be deleted (before DeleteEvent observers are called), therefore it can be used for referring to this object from Python without preventing the deletion of the object, even in DeleteEvent observers.

◆ IsA()

virtual int vtkSlicerScriptedFileReaderBridge::IsA ( const char * type)
virtual

Reimplemented from vtkMRMLFileReader.

◆ IsTypeOf()

static int vtkSlicerScriptedFileReaderBridge::IsTypeOf ( const char * type)
static

◆ Load()

bool vtkSlicerScriptedFileReaderBridge::Load ( vtkMRMLIOProperties * properties)
overridevirtual

Read the file specified by the "fileName" property into the scene. Loaded nodes are reported by AddLoadedNodeID(). Returns true on success. The base class reads nothing and returns false.

Reimplemented from vtkMRMLFileReader.

◆ New()

static vtkSlicerScriptedFileReaderBridge * vtkSlicerScriptedFileReaderBridge::New ( )
static

◆ PrintSelf()

void vtkSlicerScriptedFileReaderBridge::PrintSelf ( ostream & os,
vtkIndent indent )
override

◆ PropertiesToDict()

static PyObject * vtkSlicerScriptedFileReaderBridge::PropertiesToDict ( vtkMRMLIOProperties * properties)
static

Convert IO properties to a Python dictionary and update IO properties from a Python dictionary. Used by readers and writers that use dictionaries for properties (legacy scripted readers and writers).

◆ SafeDownCast()

static vtkSlicerScriptedFileReaderBridge * vtkSlicerScriptedFileReaderBridge::SafeDownCast ( vtkObject * o)
static

◆ UnRegisterInternal()

void vtkSlicerScriptedFileReaderBridge::UnRegisterInternal ( vtkObjectBase * o,
vtkTypeBool check )
overrideprotected

Clear the weak reference (see GetWeakReference) when the last reference is released, before DeleteEvent observers are invoked. If the weak reference was used in a DeleteEvent observer then a new Python wrapper would be created for the object that is being deleted, which would lead to infinite recursion.

◆ UpdatePropertiesFromDict()

static void vtkSlicerScriptedFileReaderBridge::UpdatePropertiesFromDict ( vtkMRMLIOProperties * properties,
PyObject * dict )
static

The documentation for this class was generated from the following file: