コード例 #1
0
    def activateFromCell(self, canvas):
        self.activeCanvas = canvas
        self.setColorsFromCanvas()

        self.controller = api.get_current_controller()
        self.version = self.controller.current_version
        self.pipeline = self.controller.vistrail.getPipeline(self.version)
        self.plots = CDMSPipelineHelper.find_plot_modules(self.pipeline)

        #set up plot combo box
        #        self.plotCb.clear()
        #        for i in range(len(self.plots)):
        #            found = False
        #            for func in self.plots[i].functions:
        #                if func.name == 'graphicsMethodName':
        #                    self.plotCb.addItem(self.plots[i].module_descriptor.module.plot_type \
        #                        + '_' + func.params[0].strValue, userData=i)
        #                    found = True
        #            if not found:
        #                self.plotCb.addItem(self.plots[i].module_descriptor.module.plot_type, userData=i)
        #        self.plotCb.setCurrentIndex(0)

        self.mapNameChanged = False
        self.cellsDirty = False
        self.show()
コード例 #2
0
    def activateFromCell(self,canvas):
        self.activeCanvas = canvas
        self.setColorsFromCanvas()
        
        self.controller = api.get_current_controller()
        self.version = self.controller.current_version
        self.pipeline = self.controller.vistrail.getPipeline(self.version)
        self.plots = CDMSPipelineHelper.find_plot_modules(self.pipeline)
        
        #set up plot combo box
#        self.plotCb.clear()
#        for i in range(len(self.plots)):
#            found = False
#            for func in self.plots[i].functions:
#                if func.name == 'graphicsMethodName':
#                    self.plotCb.addItem(self.plots[i].module_descriptor.module.plot_type \
#                        + '_' + func.params[0].strValue, userData=i)
#                    found = True                
#            if not found:
#                self.plotCb.addItem(self.plots[i].module_descriptor.module.plot_type, userData=i)                
#        self.plotCb.setCurrentIndex(0)
        
        self.mapNameChanged = False
        self.cellsDirty = False
        self.show()        
コード例 #3
0
    def activateFromCell(self, canvas):
        self.activeCanvas = canvas
        self.setColorsFromCanvas()

        self.controller = api.get_current_controller()
        self.version = self.controller.current_version
        self.pipeline = self.controller.vistrail.getPipeline(self.version)
        self.plots = CDMSPipelineHelper.find_plot_modules(self.pipeline)
        self.mapNameChanged = False
        self.cellsDirty = False
        self.show()
コード例 #4
0
    def build_python_script_from_pipeline(controller, version, plot=None):
        pipeline = controller.vistrail.getPipeline(version)
        plots = CDMSPipelineHelper.find_plot_modules(pipeline)
        text = "from PyQt4 import QtCore, QtGui\n"
        text += "import cdms2, cdutil, genutil\n"
        text += "import vcs\n\n"
        text += "if __name__ == '__main__':\n"
        text += "    import sys\n"
        text += "    app = QtGui.QApplication(sys.argv)\n"
        ident = '    '

        var_op_modules = CDMSPipelineHelper.find_topo_sort_modules_by_types(pipeline,
                                                                            [CDMSVariable,
                                                                             CDMSVariableOperation])
        for m in var_op_modules:
            desc = m.module_descriptor.module
            mobj = desc.from_module(m)
            text += mobj.to_python_script(ident=ident)

        text += ident + "canvas = vcs.init()\n"
        for mplot in plots:
            plot = mplot.module_descriptor.module.from_module(mplot)
            text += ident + "gm%s = canvas.get%s('%s')\n"%(plot.plot_type,
                                                 plot.plot_type.lower(),
                                                 plot.graphics_method_name)
            text += ident + "args = []\n"
            for varm in CDMSPipelineHelper.find_variables_connected_to_plot_module(controller, pipeline, mplot.id):
                text += ident + "args.append(%s)\n"%CDMSPipelineHelper.get_variable_name_from_module(varm)

            if plot.graphics_method_name != 'default':
                for k in plot.gm_attributes:
                    if hasattr(plot,k):
                        kval = getattr(plot,k)
                        if type(kval) == type("str") and k != 'legend':
                            text += ident + "gm%s.%s = '%s'\n"%(plot.plot_type,
                                                            k, kval)
                        else:
                            text += ident + "gm%s.%s = %s\n"%(plot.plot_type,
                                                      k,  kval)
            text += ident + "kwargs = %s\n"%plot.kwargs
            text += ident + "canvas.plot(gm%s,*args, **kwargs)\n"%(plot.plot_type)
        text += '    sys.exit(app.exec_())'
        return text