Пример #1
0
    def _onSelectedVariableChanged(self):
        self.otherEventsQueue.put(("cursorWait", None))
        currentText = self._variableListWidget.selectedItems()
        if currentText != None and len(currentText) > 0:
            firstItem = currentText[0]
            assert isinstance(firstItem, QtGui.QListWidgetItem)
            print "selected variable is ", firstItem.text()

            oldVariable = self._visDataContext.getCurrentVariable()
            newVariable = self._visDataContext.getVtuVariableFromDisplayName(
                firstItem.text())
            self._visDataContext.setCurrentVariable(newVariable)
            vcellProxy2 = vcellProxy.VCellProxyHandler()
            try:
                vcellProxy2.open()
                sim = self._visDataContext.getCurrentDataSet()
                timeIndex = self._visDataContext.getCurrentTimeIndex()
                bSameDomain = (
                    oldVariable.domainName == newVariable.domainName)
                newFilename = vcellProxy2.getClient(
                ).getDataSetFileOfVariableAtTimeIndex(sim, newVariable,
                                                      timeIndex)

                def successCallback(results):
                    self.otherEventsQueue.put(("cursorRestore", None))
                    self.minMaxExtents = results
                    print("_onSelectedVariableChanged: openOne() success " +
                          str(self.minMaxExtents))
                    if self._sliceControl.isChecked():
                        self._sliceControl.setTitle(
                            visGuiSliceControls.sliceControl.CONST_SLICE_TITLE
                            + " " + str(
                                self.getExtentAlongSliderAxis(
                                    self._sliceControl.getSliceSlider().value(
                                    ))))

                def errorCallback(errorMessage):
                    self.otherEventsQueue.put(("cursorRestore", None))
                    print("_onSelectedVariableChanged: openOne() error: " +
                          str(errorMessage))

                self._vis.openOne(newFilename, newVariable.variableVtuName,
                                  bSameDomain, successCallback, errorCallback)
            except Exception as exc:
                self.otherEventsQueue.put(("cursorRestore", None))
                print(exc.message)
                msgBox = QtGui.QMessageBox()
                msgBox.setText("Exception occurred: " + exc.message)
                msgBox.exec_()
                return
            finally:
                vcellProxy2.close()

        print('_onSelectedVariableChanged()')
Пример #2
0
    def _onTimeSliderChanged0(self):
        QtCore.QThread.msleep(250)

        print('_onTimeSliderChanged()')
        newIndex = self._timeSlider.sliderPosition()
        vcellProxy2 = vcellProxy.VCellProxyHandler()
        try:
            vcellProxy2.open()
            self._visDataContext.setCurrentTimeIndex(newIndex)
            self._visDataContext.setCurrentTimePoint(
                self._visDataContext.getCurrentDataSetTimePoints()[newIndex])
            sim = self._visDataContext.getCurrentDataSet()
            print(
                "New current Time Point should be: " +
                str(self._visDataContext.getCurrentDataSetTimePoints()
                    [newIndex]))
            print("new current Time Point is: " +
                  str(self._visDataContext.getCurrentTimePoint()))
            #self.timeGroup.setTitle("Time: "+str(self._visDataContext.getCurrentTimePoint()))
            dataFileName = vcellProxy2.getClient(
            ).getDataSetFileOfVariableAtTimeIndex(
                self._visDataContext.getCurrentDataSet(),
                self._visDataContext.getCurrentVariable(),
                self._visDataContext.getCurrentTimeIndex())
        except Exception as exc:
            print(exc.message)
            msgBox = QtGui.QMessageBox()
            msgBox.setText("Exception occurred: " + exc.message)
            msgBox.exec_()
            return
        finally:
            vcellProxy2.close()

        def successCallback(results):
            self.otherEventsQueue.put(("cursorRestore", None))
            print("_onTimeSliderChanged: openOne() success " + str(results))
            checkSlidePos = self.sliderQ(None, self.timeSliderQueue)
            if checkSlidePos[
                    VCellPysideApp.
                    CONST_POSITION] != self._visDataContext.getCurrentTimeIndex(
                    ):
                self._onTimeSliderChanged()

        def errorCallback(errorMessage):
            self.otherEventsQueue.put(("cursorRestore", None))
            print("_onTimeSliderChanged: openOne() error: " +
                  str(errorMessage))
            self.sliderQ(None, self.timeSliderQueue)  #clear queue

        self._vis.openOne(
            dataFileName,
            self._visDataContext.getCurrentVariable().variableVtuName, True,
            successCallback, errorCallback)
Пример #3
0
    def _onShowPostProcessingDataButtonPressed(self):
        print("in _onShowPostProcessingDataButtonPressed")
        sim = self._visDataContext.getCurrentDataSet()
        if (sim == None):
            return
        print(str(sim))

        vcellProxy2 = vcellProxy.VCellProxyHandler()
        try:
            vcellProxy2.open()
            vcellProxy2.getClient().displayPostProcessingDataInVCell(sim)
        except Exception as exc:
            print(exc.message)
            msgBox = QtGui.QMessageBox()
            msgBox.setText("Exception occurred: " + exc.message)
            msgBox.exec_()
            return
        finally:
            vcellProxy2.close()
    def initUI(self, vis):
        self._vis = vis

        assert isinstance(self._vis, visContextAbstract)
        self.setObjectName("queryControlWidget")
        selfSizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                                           QtGui.QSizePolicy.Minimum)
        selfSizePolicy.setHorizontalStretch(0)
        selfSizePolicy.setVerticalStretch(0)
        selfSizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(selfSizePolicy)
        self.setMinimumSize(300, 200)
        gridLayout = QtGui.QGridLayout(self)
        gridLayout.setObjectName("gridLayout")

        self._simTable = QtGui.QTableWidget(self)
        self._simTable.setSelectionMode(
            QtGui.QAbstractItemView.SingleSelection)
        self._simTable.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
        self._simTable.setColumnCount(4)
        self._simTable.setHorizontalHeaderLabels(
            ("Model", "Application", "Simulation", "jobIndex"))
        #        self._domainChoiceComboBox = QtGui.QComboBox(self)
        #        self._dataSetComboBox.activated.connect(self._changeSimulationSelectionAction)

        gridLayout.addWidget(
            self._simTable,
            0,
            0,
        )
        #       gridLayout.addWidget(self._domainChoiceComboBox,1,0)
        openButton = QtGui.QPushButton("Open", self)
        cancelButton = QtGui.QPushButton("Cancel", self)
        buttonLayout = QtGui.QHBoxLayout()
        buttonLayout.addWidget(openButton)
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(cancelButton)
        openButton.pressed.connect(self._openButtonPressedAction)
        cancelButton.pressed.connect(self._cancelButtonPressedAction)
        gridLayout.addLayout(buttonLayout, 2, 0)

        # Get available simulation dataset of open models from the VCell client
        self.simList = None
        vcellProxy2 = vcellProxy.VCellProxyHandler()
        try:
            print("calling vcellProxy2.getSimsFromOpenModels()")
            vcellProxy2.open()
            self.simList = vcellProxy2.getClient().getSimsFromOpenModels()
            # Progressively sort
            self.simList.sort(key=attrgetter('jobIndex'))
            self.simList.sort(key=attrgetter('simName'))
            #self.simList.sort(key=lambda sim: '(math)' if sim.isMathModel else sim.simulationContextName)
            self.simList.sort(key=attrgetter('simulationContextName'))
            self.simList.sort(key=attrgetter('modelName'))
        except Exception as simFromModelException:
            self.simList = simFromModelException
            print("Exception looking for open model datasets " +
                  repr(simFromModelException))
        finally:
            vcellProxy2.close()
        print(self.simList)
        if (isinstance(self.simList, Exception) or self.simList == None
                or len(self.simList) == 0):
            msgBox = QtGui.QMessageBox()
            if (isinstance(self.simList, Exception)):
                msgBox.setText(
                    "VCell communication error:\nCheck VCell is started and has at least 1 open model with spatial simulation data"
                )
            else:
                msgBox.setText(
                    "no completed 2D or 3D spatial simulations found in open VCell models"
                )
            msgBox.exec_()
            raise Exception("No simulations found")
            #return

        # populate the QTableWidget if we found datasets
        self._simTable.setRowCount(len(self.simList))
        for i, sim in enumerate(self.simList):
            self._simTable.setItem(i, 0, QtGui.QTableWidgetItem(sim.modelName))
            self._simTable.setItem(
                i, 1,
                QtGui.QTableWidgetItem("(math)" if sim.simulationContextName ==
                                       None else sim.simulationContextName))
            self._simTable.setItem(i, 2, QtGui.QTableWidgetItem(sim.simName))
            self._simTable.setItem(i, 3,
                                   QtGui.QTableWidgetItem(str(sim.jobIndex)))
            #self._dataSetComboBox.addItem(sim.simName,sim)
            #self._changeSimulationSelectionAction()

        self._simTable.resizeColumnsToContents()

        vwidth = self._simTable.verticalHeader().width()
        hwidth = self._simTable.horizontalHeader().length()
        swidth = self._simTable.style().pixelMetric(
            QtGui.QStyle.PM_ScrollBarExtent)
        fwidth = self._simTable.frameWidth() * 2
        self.resize(vwidth + hwidth + swidth + fwidth, self.size().height())
import sys

import vtk

sys.path.append('./')
import vcellProxy

vcellProxy2 = vcellProxy.VCellProxyHandler()
try:
    vcellProxy2.open()

    # transport = TSocket.TSocket('localhost', 9090)
    # transport = TTransport.TBufferedTransport(transport)
    # protocol = TBinaryProtocol.TBinaryProtocol(transport)
    # client = VCellProxy.Client(protocol)
    # transport.open()

    simList = vcellProxy2.getClient().getSimsFromOpenModels()
    print('\n')
    print(simList)
    sim = simList[0]
    variables = vcellProxy2.getClient().getVariableList(sim)
    timePoints = vcellProxy2.getClient().getTimePoints(sim)
    print(variables)
    print(timePoints)
    var = variables[0]
    timeIndex = len(timePoints) - 1
    dataFileName = vcellProxy2.getClient().getDataSetFileOfVariableAtTimeIndex(
        sim, var, timeIndex)
    reader = vtk.vtkXMLUnstructuredGridReader()
    reader.SetFileName(dataFileName)
Пример #6
0
    def _onSimulationSelected0(self, sim):

        vcellProxy2 = vcellProxy.VCellProxyHandler()
        try:
            vcellProxy2.open()
            variables = vcellProxy2.getClient().getVariableList(sim)
            all(isinstance(n, pyvcell.ttypes.VariableInfo) for n in variables)
            if (len(variables) < 1):
                print "no variables, ignoring dataset ... new"
                return

            currVar = variables[0]
            assert isinstance(currVar, pyvcell.ttypes.VariableInfo)

            dataFileName = vcellProxy2.getClient(
            ).getDataSetFileOfVariableAtTimeIndex(sim, currVar, 0)
            self._visDataContext.setVariableInfos(variables)
            self._visDataContext.setCurrentVariable(currVar)
            self._visDataContext.setCurrentDataSet(sim)
            self._visDataContext.setCurrentDataSetTimePoints(
                vcellProxy2.getClient().getTimePoints(sim))
            self._visDataContext.setCurrentTimeIndex(0)

            print("List of variable names from VCellProxy is:")
            varDisplayNames = [
                varInfo.variableDisplayName for varInfo in variables
            ]
            print("var display names: " + str(varDisplayNames))
            varVtuNames = [varInfo.variableVtuName for varInfo in variables]
            print("var mesh names: " + str(varVtuNames))
            print("\nThe list of variable names from the MDServer is:")
            #print(self._vis.getMDVariableNames())

            assert isinstance(self._variableListWidget, QtGui.QListWidget)
            self._variableListWidget.clear()

            self._variableListWidget.addItems(varDisplayNames)
            #if visQt.isPyside():
            #    #self._variableListWidget.setCurrentItem(QtGui.QListWidgetItem(str(0)))
            #    self._variableListWidget.item(0).setSelected(True)
            #elif visQt.isPyQt4:
            #    self._variableListWidget.setItemSelected(QtGui.QListWidgetItem(str(0)),True)

            times = self._visDataContext.getCurrentDataSetTimePoints()
            self._timeSlider.blockSignals(True)
            if times == None or len(times) == 0:
                self._timeSlider.setMinimum(0)
                self._timeSlider.setMaximum(0)
                self.timeGroup.setTitle("Time: 0.0")
            else:
                self._timeSlider.setMinimum(0)
                self._timeSlider.setMaximum(len(times) - 1)
                self.timeGroup.setTitle("Time: 0.0")
                self._timemaxlabel.setText(str(times[len(times) - 1]))

            self._timeSlider.setValue(0)
            self._timeSlider.blockSignals(False)

            def successCallback(results):
                self.minMaxExtents = results
                print("_onSimulationSelected: openOne() success " +
                      str(self.minMaxExtents))
                self._variableListWidget.setCurrentRow(0)
                self._variableListWidget.item(0).setSelected(True)
                self._variableListWidget.setFocus()
                self.modalProgress(None)
                print(str(sim))
                newTtitle = "VCell Visit View " + (
                    "(Math)" if sim.isMathModel else
                    "(Bio) ") + '\'' + sim.modelName + '\'->' + (
                        ('\'' + sim.simulationContextName +
                         "\'->") if sim.simulationContextName != None else
                        '') + '\'' + sim.simName + '\''
                self.setWindowTitle(newTtitle)

            def errorCallback(errorMessage):
                print("_onSimulationSelected: openOne() error: " +
                      str(errorMessage))
                self.modalProgress(None)

            self._vis.openOne(
                dataFileName,
                self._visDataContext.getCurrentVariable().variableVtuName,
                False, successCallback, errorCallback)

            #vcellProxy2.getClient().displayPostProcessingDataInVCell(sim)

        except Exception as exc:
            print(exc.message)
            self.otherEventsQueue.put(
                "Exception occurred while retrieving data\n" + exc.message)
            return
        finally:
            vcellProxy2.close()