~mapclient.devs/mapclient/stable

« back to all changes in this revision

Viewing changes to plugins/mapclientplugins/pointcloudserializerstep/step.py

  • Committer: musculoskeletal
  • Date: 2014-06-25 05:38:05 UTC
  • mfrom: (1.6.35 testing)
  • Revision ID: musculoskeletal@bioeng1033-20140625053805-jkqhi5oq74vmlntl
Merging testing into stable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from PySide import QtGui, QtCore
23
23
 
24
 
from mountpoints.workflowstep import WorkflowStepMountPoint
 
24
from mapclient.mountpoints.workflowstep import WorkflowStepMountPoint
25
25
 
26
 
from pointcloudserializerstep.widgets.configuredialog import ConfigureDialog, ConfigureDialogState
 
26
from mapclientplugins.pointcloudserializerstep.widgets.configuredialog import ConfigureDialog, ConfigureDialogState
27
27
 
28
28
def getConfigFilename(identifier):
29
29
    return identifier + '.conf'
45
45
        self._icon = QtGui.QImage(':/pointcloudserializer/images/pointcloudserializer.png')
46
46
        self.addPort(('http://physiomeproject.org/workflow/1.0/rdf-schema#port', 'http://physiomeproject.org/workflow/1.0/rdf-schema#uses', 'http://physiomeproject.org/workflow/1.0/rdf-schema#pointcloud'))
47
47
        self._state = ConfigureDialogState()
 
48
        self._dataIn = None
48
49
 
49
50
    def configure(self):
50
51
        d = ConfigureDialog(self._state)
66
67
        if not os.path.exists(self.getOutputDirectory()):
67
68
            os.mkdir(self.getOutputDirectory())
68
69
 
69
 
        configuration_file = os.path.join(location,getConfigFilename(self._state.identifier()))
 
70
        configuration_file = os.path.join(location, getConfigFilename(self._state.identifier()))
70
71
        s = QtCore.QSettings(configuration_file, QtCore.QSettings.IniFormat)
71
72
        self._state.save(s)
72
73
 
73
74
    def deserialize(self, location):
74
 
        configuration_file = os.path.join(location,getConfigFilename(self._state.identifier()))
 
75
        configuration_file = os.path.join(location, getConfigFilename(self._state.identifier()))
75
76
        s = QtCore.QSettings(configuration_file, QtCore.QSettings.IniFormat)
76
77
        self._state.load(s)
77
78
        d = ConfigureDialog(self._state)
80
81
    def getOutputDirectory(self):
81
82
        return os.path.join(self._location, self._state.identifier())
82
83
 
83
 
    def execute(self, dataIn):
84
 
        f = open(os.path.join(self.getOutputDirectory(), 'pointcloud.txt'), 'w')
85
 
        for i, pt in enumerate(dataIn):
86
 
            f.write(str(i + 1) + '\t' + str(pt[0]) + '\t' + str(pt[1]) + '\t' + str(pt[2]) + '\n')
87
 
        f.close()
 
84
    def setPortData(self, portId, dataIn):
 
85
        self._dataIn = dataIn
 
86
 
 
87
    def execute(self):
 
88
        if self._dataIn:
 
89
            f = open(os.path.join(self.getOutputDirectory(), 'pointcloud.txt'), 'w')
 
90
            for i, pt in enumerate(self._dataIn):
 
91
                f.write(str(i + 1) + '\t' + str(pt[0]) + '\t' + str(pt[1]) + '\t' + str(pt[2]) + '\n')
 
92
            f.close()
88
93
        self._doneExecution()
89
94