コード例 #1
0
ファイル: mgui.py プロジェクト: physicalist/moose
    def connectBioModel(self):
        connecttoBioModel = BioModelsClientWidget()
        if connecttoBioModel.exec_():
            pass
        filepath = connecttoBioModel.filePath
        if filepath:
            head, fileName = os.path.split(filepath)
            modelName = os.path.splitext(fileName)[0]
            pwe = moose.getCwe()
            ret = loadFile(str(filepath), '/model/%s' % (modelName), merge=False)
            self.objectEditSlot('/',False)
            pluginLookup = '%s/%s' % (ret['modeltype'], ret['subtype'])
            try:
                pluginName = subtype_plugin_map['%s/%s' % (ret['modeltype'], ret['subtype'])]
            except KeyError:
                pluginName = 'default'
            print 'Loaded model', ret['model'].path,subtype
            self._loadedModels.append([ret['model'].path,pluginName])
            if len(self._loadedModels)>5:
                self._loadedModels.pop(0)

            if not moose.exists(ret['model'].path+'/info'):
                    moose.Annotator(ret['model'].path+'/info')

            modelAnno = moose.Annotator(ret['model'].path+'/info')
            if ret['subtype']:
                modelAnno.modeltype = ret['subtype']
            else:
                modelAnno.modeltype = ret['modeltype']
            modelAnno.dirpath = str(dialog.directory().absolutePath())
            self.loadedModelsAction(ret['model'].path,pluginName)
            self.setPlugin(pluginName, ret['model'].path)
コード例 #2
0
ファイル: mgui.py プロジェクト: physicalist/moose
    def loadModelDialogSlot(self):
        """Start a file dialog to choose a model file.

        Once the dialog succeeds, we should hand-over the duty of
        actual model loading to something else. Then refresh the
        views. Things to check from the user:

        1) The file type

        2) Target element

        3) Whether we should update the current window or start a new
        window.

        4) Plugin to use for displaying this model (can be automated
        by looking into the model file for a regular expression)

        """
        self.popup.close()
        activeWindow = None # This to be used later to refresh the current widget with newly loaded model
        dialog = LoaderDialog(self,
                              self.tr('Load model from file'))

        if dialog.exec_():
            fileNames = dialog.selectedFiles()
            for fileName in fileNames:
                modelName = dialog.getTargetPath()
                if '/' in modelName:
                    raise mexception.ElementNameError('Model name cannot contain `/`')
                ret = loadFile(str(fileName),'%s' %(modelName),merge=False)
                #ret = loadFile(str(fileName), '/model/%s' % (modelName), merge=False)
		        #Harsha: This will clear out object editor's objectpath and make it invisible
                self.objectEditSlot('/',False)

                # Harsha: if subtype is None, in case of cspace then pluginLookup = /cspace/None
                #     which will not call kkit plugin so cleaning to /cspace
                pluginLookup = '%s/%s' % (ret['modeltype'], ret['subtype'])
                try:
                    pluginName = subtype_plugin_map['%s/%s' % (ret['modeltype'], ret['subtype'])]
                except KeyError:
                    pluginName = 'default'
                print 'Loaded model', ret['model'].path
                if not moose.exists(ret['model'].path+'/info'):
                    moose.Annotator(ret['model'].path+'/info')

                modelAnno = moose.Annotator(ret['model'].path+'/info')
                if ret['subtype']:
                    modelAnno.modeltype = ret['subtype']
                else:
                    modelAnno.modeltype = ret['modeltype']
                modelAnno.dirpath = str(dialog.directory().absolutePath())
                self.loadedModelsAction(ret['model'].path,pluginName)
                self.setPlugin(pluginName, ret['model'].path)
                if pluginName == 'kkit':
                    QtCore.QCoreApplication.sendEvent(self.plugin.getEditorView().getCentralWidget().view, QtGui.QKeyEvent(QtCore.QEvent.KeyPress, Qt.Qt.Key_A, Qt.Qt.NoModifier))
コード例 #3
0
ファイル: mgui.py プロジェクト: csiki/moose-csiki
 def connectBioModel(self):
     connecttoBioModel = BioModelsClientWidget()
     if connecttoBioModel.exec_():
         pass
     filepath = connecttoBioModel.filePath
     if filepath:
         head, fileName = os.path.split(filepath)
         modelName = os.path.splitext(fileName)[0]
         pwe = moose.getCwe()
         ret = loadFile(str(filepath), '/model/%s' % (modelName), merge=False)
         self.objectEditSlot('/',False)
         pluginLookup = '%s/%s' % (ret['modeltype'], ret['subtype'])
         try:
             pluginName = subtype_plugin_map['%s/%s' % (ret['modeltype'], ret['subtype'])]
         except KeyError:
             pluginName = 'default'
         
         print 'Loaded model', ret['model'].path
         self.setPlugin(pluginName, ret['model'].path)
コード例 #4
0
ファイル: mgui.py プロジェクト: Vivek-sagar/moose-1
    def loadModelDialogSlot(self):
        """Start a file dialog to choose a model file.

        Once the dialog succeeds, we should hand-over the duty of
        actual model loading to something else. Then refresh the
        views. Things to check from the user:

        1) The file type

        2) Target element

        3) Whether we should update the current window or start a new
        window.

        4) Plugin to use for displaying this model (can be automated
        by looking into the model file for a regular expression)

        """
        activeWindow = None # This to be used later to refresh the current widget with newly loaded model
        dialog = LoaderDialog(self, 
                              self.tr('Load model from file'))
        
        if dialog.exec_():
            fileNames = dialog.selectedFiles()
            for fileName in fileNames:
                # print 'Current plugin', self.plugin
                modelName = dialog.getTargetPath()
                if '/' in modelName:
                    raise mexception.ElementNameError('Model name cannot contain `/`')
                ret = loadFile(str(fileName), '/model/%s' % (modelName), merge=False)
                #print '11111'
                # Harsha: if subtype is None, in case of cspace then pluginLookup = /cspace/None 
                #     which will not call kkit plugin so cleaning to /cspace 
                pluginLookup = '%s/%s' % (ret['modeltype'], ret['subtype'])
                try:
                    pluginName = subtype_plugin_map['%s/%s' % (ret['modeltype'], ret['subtype'])]
                except KeyError:
                    pluginName = 'default'
                print 'Loaded model', ret['model'].path
                self.setPlugin(pluginName, ret['model'].path)
                #Harsha: This will clear out object editor's objectpath and make it invisible
                self.objectEditSlot('/',False)