Slicer: 2145-support-for-installing-extension-from-file a26497c3

Author Committer Branch Timestamp Parent
jcfr jcfr 2145-support-for-installing-extension-from-file 2013-08-26 23:29:57 2145-support-for-installing-extension-from-file b0302280
Changeset

ENH: Add qSlicerScriptedFileWriter interface

User can now register python based file writer.

For example:

File MyCustomSceneExporter.py

import json
import os
import zipfile
import contextlib
import datetime
import vtk, slicer

class MyCustomSceneExporter:
def init(self, parent):
parent.title = "[...]"
parent.categories = ["..."]
parent.dependencies = []
parent.contributors = ["..."]
parent.helpText = """[...]"""
parent.acknowledgementText = """[...]"""
self.parent = parent

class MyCustomSceneExporterFileWriter:
def init(self, parent):
self.parent = parent

def description(self):
    return 'Custom Scene File'

def fileType(self):
    return 'SceneFile'

def canWriteObject(self, obj):
    return isinstance(obj, slicer.vtkMRMLScene)

def extensions(self, obj):
    return ['CustomScene File (*.customscene.zip)']

def write(self, properties):
    self.exportModels(properties['fileName'])
    return True

[...]

git-svn-id: http://svn.slicer.org/Slicer4/trunk@22338 3bd1e089-480b-0410-8dfb-8563597acbee

mod - Base/QTCore/CMakeLists.txt Diff File
add - Base/QTCore/qSlicerScriptedFileWriter.cxx Diff File
add - Base/QTCore/qSlicerScriptedFileWriter.h Diff File
mod - Base/QTGUI/qSlicerScriptedLoadableModule.cxx Diff File
mod - Base/QTGUI/qSlicerScriptedLoadableModule.h Diff File