Beispiel #1
0
    def currentTabChanged(self):

        Configuration.setSetting("TabIndex", self.tabWidget.currentIndex())
        if self.tabWidget.currentIndex() == 2:

            if self.lastSelectedField >= 0:
                self.fieldComboBox.setCurrentIndex(self.lastSelectedField)
    def toggleModelEditor(self, flag):
        """
        Private slot to handle the toggle of the Model Editor window.
        """
        self.modelAct.setChecked(flag)

        Configuration.setSetting('DisplayModelEditor', flag)
        self.__toggleWindowFlag(self.modelEditorDock, flag)
    def closeEvent(self, event=None):

        Configuration.setSetting('ScreenGeometry',
                                 self.get_current_screen_geometry_settings())
        # this saves size and position of window when player is opened and closed without running simulation
        self.save_ui_geometry()

        self.viewmanager.closeEventSimpleTabView(event)
    def toggleLatticeData(self, flag):
        """
        Private slot to handle the toggle of the Plugins window.
        """

        self.latticeDataAct.setChecked(flag)

        Configuration.setSetting('DisplayLatticeData', flag)
        self.__toggleWindowFlag(self.latticeDataDock, flag)
Beispiel #5
0
    def updateColorButton(self, btn, name):
        '''
            updates button (btn) and changes corresponding color setting (name).Shows Choose color dialog 
        '''
        color = self.selectColor(btn, Configuration.getSetting(name))

        # which of the following is necessary at this point?
        Configuration.setSetting(name, color)
        self.paramCC3D[name] = color
    def toggle_cell_type_color_map_dock(self, flag):
        """

        :param flag:
        :return:
        """
        print('toggle_cell_type_color_map_dock')
        self.cell_type_color_map_act.setChecked(flag)
        self.__toggleWindowFlag(self.cell_type_color_map_dock, flag)
        Configuration.setSetting('DisplayCellTypeColorMap', flag)
Beispiel #7
0
 def changeButtonColor(self, _btn, _color, _settingName):
     '''
     assigns color (_color)  to button (_btn) and changes corresponding color setting (_settingName). Does not shows Choose color dialog 
     '''
     if _color.isValid():
         size = _btn.iconSize()
         pm = QPixmap(size.width(), size.height())
         pm.fill(_color)
         _btn.setIcon(QIcon(pm))
         Configuration.setSetting(_settingName, _color)
Beispiel #8
0
 def on_outputLocationButton_clicked(self):
     currentOutputDir = Configuration.getSetting('OutputLocation')
     dirName = QFileDialog.getExistingDirectory(
         self, "Specify CC3D Output Directory", currentOutputDir,
         QFileDialog.ShowDirsOnly)
     dirName = str(dirName)
     dirName.rstrip()
     print("dirName=", dirName)
     if dirName == "":
         return
     dirName = os.path.abspath(dirName)
     self.outputLocationLineEdit.setText(dirName)
     Configuration.setSetting('OutputLocation', dirName)
    def toggleConsole(self, flag):
        """
        Private slot to handle the toggle of the Log Viewer window.

        if self.layout == "DockWindows":
            self.__toggleWindow(self.logViewerDock)
        else:
            self.__toggleWindow(self.logViewer)
        """
        self.consoleAct.setChecked(flag)

        Configuration.setSetting('DisplayConsole', flag)
        # TODO
        self.__toggleWindowFlag(self.consoleDock, flag)
Beispiel #10
0
    def process_version_check(self, version_str, url_str):
        """
        This function extracts current version and revision numbers from the http://www.compucell3d.org/current_version
        It informs users that new version is available and allows easy redirection to the download site
        :param version_str: content of the web page with the current version information
        :param url_str: url of the webpage with the current version information
        :return: None
        """
        if str(version_str) == '':
            print(
                'Could not fetch "http://www.compucell3d.org/current_version webpage'
            )
            return

        current_version = ''
        current_revision = ''
        whats_new_list = []

        current_version_regex = re.compile("(current version)([0-9\. ]*)")

        # (.*?)(<) ensures non-greedy match i.e. all the characters will be matched until first occurrence of '<'
        whats_new_regex = re.compile("(>[\S]*what is new:)(.*?)(<)")

        for line in str(version_str).split("\n"):

            search_obj = re.search(current_version_regex, line)
            search_obj_whats_new = re.search(whats_new_regex, line)

            if search_obj:
                # print 'search_obj=', search_obj
                # print search_obj.groups()
                try:
                    version_info = search_obj.groups()[1]
                    version_info = version_info.strip()
                    current_version, current_revision = version_info.split(' ')
                except:
                    pass

            if search_obj_whats_new:
                # print search_obj_whats_new.groups()
                try:
                    whats_new = search_obj_whats_new.groups()[1]
                    whats_new = whats_new.strip()
                    whats_new_list = whats_new.split(', ')
                except:
                    pass

        instance_version = cc3d.__version__
        instance_revision = cc3d.__revision__
        try:
            current_version_number = int(current_version.replace('.', ''))
        except:
            # this can happen when the page gets "decorated" by e.g. your hotel network
            # will have to come up with a better way of dealing with it
            return
        current_revision_number = int(current_revision)
        instance_version_number = int(instance_version.replace('.', ''))
        instance_revision_number = int(instance_revision)

        display_new_version_info = False

        if current_version_number > instance_version_number:
            display_new_version_info = True

        elif current_version_number == instance_version_number and current_revision_number > instance_revision_number:
            display_new_version_info = True

        today = datetime.date.today()
        today_date_str = today.strftime('%Y%m%d')

        last_version_check_date = Configuration.setSetting(
            'LastVersionCheckDate', today_date_str)

        message = 'New version of CompuCell3D is available - %s rev. %s. Would you like to upgrade?' % (
            current_version, current_revision)

        if len(whats_new_list):
            message += '<p><b>New Features:</b></p>'
            for whats_new_item in whats_new_list:
                message += '<p> * ' + whats_new_item + '</p>'

        if display_new_version_info:

            ret = QMessageBox.information(self, 'New Version Available',
                                          message,
                                          QMessageBox.Yes | QMessageBox.No)
            if ret == QMessageBox.Yes:
                QDesktopServices.openUrl(
                    QUrl('http://sourceforge.net/projects/cc3d/files/' +
                         current_version))

        elif self.display_no_update_info == True:
            ret = QMessageBox.information(
                self, 'Software update check',
                'You are running latest version of CC3D.', QMessageBox.Ok)
Beispiel #11
0
    def process_version_check(
            self,
            version_str,
            url_str="http://www.compucell3d.org/current_version"):
        """
        This function extracts current version and revision numbers from the http://www.compucell3d.org/current_version
        It informs users that new version is available and allows easy redirection to the download site
        :param version_str: content of the web page with the current version information
        :param url_str: url of the webpage with the current version information
        :return: None
        """
        # print('got the following string:', version_str)
        if str(version_str) == '':
            print(f'Could not fetch {url_str} webpage')
            return

        current_version, current_revision = self.extract_current_version(
            version_html_str=version_str)

        whats_new_list = self.extract_whats_new_list(
            version_html_str=version_str)

        encourage_update = False
        display_new_version_info = False
        running_latest_version = self.check_if_running_latest_version(
            latest_version=current_version, latest_revision=current_revision)

        if self.display_no_update_info:
            display_new_version_info = True
            if not running_latest_version:
                encourage_update = True
        else:
            if not running_latest_version:
                display_new_version_info = True
                encourage_update = True

        today = datetime.date.today()
        today_date_str = today.strftime('%Y%m%d')

        Configuration.setSetting('LastVersionCheckDate', today_date_str)

        if encourage_update:
            message = f'New version of CompuCell3D is available - {current_version} rev. {current_revision}. ' \
                      f'Would you like to upgrade?'
            title = "New Version Available"
        else:
            message = f'You have latest version - {current_version} rev. {current_revision}. ' \
                      'Here is the list of recent features:'
            title = "You have latest version. No need to upgrade"

        if len(whats_new_list):
            message += '<p><b>New Features:</b></p>'
            for whats_new_item in whats_new_list:
                message += '<p> * ' + whats_new_item + '</p>'

        if display_new_version_info:
            if encourage_update:
                buttons = QMessageBox.Yes | QMessageBox.No
            else:
                buttons = QMessageBox.Ok

            ret = QMessageBox.information(self, title, message, buttons)

            if ret == QMessageBox.Yes:
                QDesktopServices.openUrl(
                    QUrl('http://sourceforge.net/projects/cc3d/files/' +
                         current_version))

        elif self.display_no_update_info:
            ret = QMessageBox.information(
                self, 'Software update check',
                'You are running latest version of CC3D.', QMessageBox.Ok)
    def closeEvent(self, event=None):
        print("CALLING CLOSE EVENT FROM  SIMTAB")
        # TODO check the rest of the function

        if self.viewmanager.MDI_ON:
            Configuration.setSetting("PlayerSizes", self.saveState())
            Configuration.setSetting("MainWindowSize", self.size())
            Configuration.setSetting("MainWindowPosition", self.pos())

        else:
            Configuration.setSetting("PlayerSizesFloating", self.saveState())
            Configuration.setSetting("MainWindowSizeFloating", self.size())
            Configuration.setSetting("MainWindowPositionFloating", self.pos())

        self.viewmanager.closeEventSimpleTabView(event)
    def save_ui_geometry(self):
        """
        Stores ui geometry settings . Called after user presses stop button
        :return:
        """
        if self.viewmanager.MDI_ON:
            Configuration.setSetting("PlayerSizes", self.saveState())
            Configuration.setSetting("MainWindowSize", self.size())
            Configuration.setSetting("MainWindowPosition", self.pos())

        else:
            Configuration.setSetting("PlayerSizesFloating", self.saveState())
            Configuration.setSetting("MainWindowSizeFloating", self.size())
            Configuration.setSetting("MainWindowPositionFloating", self.pos())
Beispiel #14
0
    def updatePreferences(self):
        '''called when user presses Apply or OK button on the Prefs dialog'''

        # rwh: check if the PreferencesFile is different; if so, update it
        # # # Configuration.mySettings = QSettings(QSettings.IniFormat, QSettings.UserScope, "Biocomplexity", self.prefsFileLineEdit.text())

        # update flags in menus:  CC3DOutputOn, etc. (rf. ViewManager/SimpleViewManager)

        # Output
        Configuration.setSetting("ScreenUpdateFrequency",
                                 self.updateScreenSpinBox.value())
        Configuration.setSetting("ImageOutputOn",
                                 self.outputImagesCheckBox.isChecked())
        Configuration.setSetting("SaveImageFrequency",
                                 self.saveImageSpinBox.value())
        Configuration.setSetting("Screenshot_X", self.screenshot_X_SB.value())
        Configuration.setSetting("Screenshot_Y", self.screenshot_Y_SB.value())
        Configuration.setSetting("LatticeOutputOn",
                                 self.outputLatticeDataCheckBox.isChecked())
        Configuration.setSetting("SaveLatticeFrequency",
                                 self.saveLatticeSpinBox.value())
        Configuration.setSetting("DebugOutputPlayer",
                                 self.debugOutputPlayerCB.isChecked())
        Configuration.setSetting("UseInternalConsole",
                                 self.useInternalConsoleCheckBox.isChecked())
        Configuration.setSetting("ClosePlayerAfterSimulationDone",
                                 self.closePlayerCheckBox.isChecked())
        Configuration.setSetting("ProjectLocation",
                                 self.projectLocationLineEdit.text())
        Configuration.setSetting("OutputLocation",
                                 self.outputLocationLineEdit.text())

        if str(self.outputLocationLineEdit.text()).rstrip() == '':
            Configuration.setSetting(
                "OutputLocation",
                os.path.join(os.path.expanduser('~'), 'CC3DWorkspace'))

        Configuration.setSetting("OutputToProjectOn",
                                 self.outputToProjectCheckBox.isChecked())
        # # # Configuration.setSetting("PreferencesFile", self.prefsFileLineEdit.text())
        Configuration.setSetting("NumberOfRecentSimulations",
                                 self.numberOfRecentSimulationsSB.value())
        Configuration.setSetting("NumberOfStepOutputs",
                                 self.numberOfStepOutputsSB.value())
        Configuration.setSetting("FloatingWindows",
                                 self.floatingWindowsCB.isChecked())

        Configuration.setSetting("WindowColorSameAsMedium",
                                 self.windowColorSameAsMediumCB.isChecked())

        # Cell Type/Colors
        Configuration.setSetting("TypeColorMap",
                                 self.paramCC3D["TypeColorMap"])  # rwh

        Configuration.setSetting(
            "CellGlyphScaleByVolumeOn",
            self.cellGlyphScaleByVolumeCheckBox.isChecked())
        Configuration.setSetting("CellGlyphScale",
                                 float(self.cellGlyphScale.text()))
        Configuration.setSetting("CellGlyphThetaRes",
                                 self.cellGlyphThetaRes.value())  # spinbox
        Configuration.setSetting("CellGlyphPhiRes",
                                 self.cellGlyphPhiRes.value())  # spinbox

        fp = Configuration.getSetting("FieldParams")

        # get Field name from combobox in the Field tab and save the current settings for that field
        fname = self.fieldComboBox.currentText()

        # Configuration.updateSimFieldsParams(fname)
        # print '\n\n\n updating field fname = ',fname

        # TODO change
        self.updateFieldParams(fname)

        # fpafter = Configuration.getSetting("FieldParams")
        # print 'CONF POPUP AFTER self.updateFieldParams \n\n\n FIELD PARAMS keys  = ',fpafter.keys()

        Configuration.setSetting("PixelizedCartesianFields",
                                 self.pixelizedScalarFieldCB.isChecked())

        Configuration.setSetting("MinRange", float(self.fieldMinRange.text()))
        Configuration.setSetting("MinRangeFixed",
                                 self.fieldMinRangeFixedCheckBox.isChecked())
        Configuration.setSetting("MaxRange", float(self.fieldMaxRange.text()))
        Configuration.setSetting("MaxRangeFixed",
                                 self.fieldMaxRangeFixedCheckBox.isChecked())

        Configuration.setSetting("NumberOfLegendBoxes",
                                 self.fieldLegendNumLabels.value())  # spinbox
        Configuration.setSetting("NumberAccuracy",
                                 self.fieldLegendAccuracy.value())  # spinbox
        Configuration.setSetting("LegendEnable",
                                 self.fieldShowLegendCheckBox.isChecked())

        Configuration.setSetting("ScalarIsoValues", self.isovalList.text())
        Configuration.setSetting("NumberOfContourLines",
                                 self.numberOfContoursLinesSpinBox.value())
        Configuration.setSetting("ShowPlotAxes",
                                 self.showPlotAxesCB.isChecked())

        Configuration.setSetting("DisplayMinMaxInfo",
                                 self.min_max_display_CB.isChecked())

        # Vectors

        Configuration.setSetting("ArrowLength",
                                 self.vectorsArrowLength.value())
        Configuration.setSetting("ScaleArrowsOn",
                                 self.vectorsScaleArrowCheckBox.isChecked())
        Configuration.setSetting("FixedArrowColorOn",
                                 self.vectorsArrowColorCheckBox.isChecked())

        # 3D section

        # cellTypesInvisibleList = self.cellTypesInvisibleList.text()

        Configuration.setSetting("Types3DInvisible",
                                 self.cellTypesInvisibleList.text())
        Configuration.setSetting("BoundingBoxOn",
                                 self.boundingBoxCheckBox.isChecked())
        Configuration.setSetting("ShowAxes", self.showAxesCB.isChecked())
        Configuration.setSetting("ShowHorizontalAxesLabels",
                                 self.showHorizontalAxesLabelsCB.isChecked())
        Configuration.setSetting("ShowVerticalAxesLabels",
                                 self.showVerticalAxesLabelsCB.isChecked())
        # Configuration.setSetting("Show3DAxes", self.show3DAxesCB.isChecked())

        # restart section
        Configuration.setSetting("RestartOutputEnable",
                                 self.restart_CB.isChecked())
        Configuration.setSetting("RestartOutputFrequency",
                                 self.restart_freq_SB.value())
        Configuration.setSetting(
            "RestartAllowMultipleSnapshots",
            self.multiple_restart_snapshots_CB.isChecked())
Beispiel #15
0
    def updateFieldParams(self, fieldName):
        # we do not allow fields with empty name
        if str(fieldName) == '':
            return

        fieldDict = {}

        key = "ShowPlotAxes"
        val = self.showPlotAxesCB.isChecked()
        fieldDict[key] = val
        Configuration.setSetting(key, val)

        key = "MinRange"
        val = self.fieldMinRange.text()

        fieldDict[key] = float(val)

        Configuration.setSetting(key, val)
        key = "MinRangeFixed"
        val = self.fieldMinRangeFixedCheckBox.isChecked()
        fieldDict[key] = val
        Configuration.setSetting(key, val)
        key = "MaxRange"
        val = self.fieldMaxRange.text()

        fieldDict[key] = float(val)
        Configuration.setSetting(key, val)
        key = "MaxRangeFixed"
        val = self.fieldMaxRangeFixedCheckBox.isChecked()
        fieldDict[key] = val
        Configuration.setSetting(key, val)

        key = "NumberOfLegendBoxes"
        val = self.fieldLegendNumLabels.value()  # spinbox
        fieldDict[key] = val
        Configuration.setSetting(key, val)
        key = "NumberAccuracy"
        val = self.fieldLegendAccuracy.value()  # spinbox
        fieldDict[key] = val
        Configuration.setSetting(key, val)
        key = "LegendEnable"
        val = self.fieldShowLegendCheckBox.isChecked()
        fieldDict[key] = val
        Configuration.setSetting(key, val)

        key = "OverlayVectorsOn"
        val = self.vectorsOverlayCheckBox.isChecked()
        fieldDict[key] = val
        Configuration.setSetting(key, val)

        key = "ContoursOn"
        val = self.contoursShowCB.isChecked()
        fieldDict[key] = val
        Configuration.setSetting(key, val)

        key = "ScalarIsoValues"
        val = self.isovalList.text()
        fieldDict[key] = val
        #        print MODULENAME,' updateFieldParams():  fieldDict (after adding ScalarIsoValues)=',fieldDict
        Configuration.setSetting(key, val)
        key = "NumberOfContourLines"
        val = self.numberOfContoursLinesSpinBox.value()
        fieldDict[key] = val
        Configuration.setSetting(key, val)

        key = "ArrowLength"
        val = self.vectorsArrowLength.value()
        fieldDict[key] = val
        Configuration.setSetting(key, val)
        key = "ScaleArrowsOn"
        val = self.vectorsScaleArrowCheckBox.isChecked()
        fieldDict[key] = val
        Configuration.setSetting(key, val)
        key = "FixedArrowColorOn"
        val = self.vectorsArrowColorCheckBox.isChecked()
        fieldDict[key] = val
        Configuration.setSetting(key, val)
        color = Configuration.getSetting("ArrowColor")

        fieldDict["ArrowColor"] = color

        Configuration.updateFieldsParams(fieldName, fieldDict)
Beispiel #16
0
    def fieldComboBoxClicked(self):
        fname = self.fieldComboBox.currentText()

        fieldIndex = self.fieldComboBox.currentIndex()
        Configuration.setSetting("FieldIndex", fieldIndex)
        self.lastSelectedField = fieldIndex

        # allFieldsDict = Configuration.getSimFieldsParams()
        allFieldsDict = Configuration.getSetting('FieldParams')

        key1 = list(allFieldsDict.keys())[0]

        if isinstance(key1, str):
            fieldParams = allFieldsDict[str(fname)]
        else:
            fieldParams = allFieldsDict[fname]

        if not isinstance(fieldParams, dict):

            fieldParamsDict = fieldParams.toMap()
        else:

            fieldParamsDict = fieldParams

        try:  # in case ShowPlotAxes is not defined in a dictinary for this plot
            val = fieldParamsDict["ShowPlotAxes"]
        except:
            val = Configuration.getSetting('ShowPlotAxes')

        self.showPlotAxesCB.setChecked(val)

        val = fieldParamsDict["MinRange"]

        self.fieldMinRange.setText(str(val))
        val = fieldParamsDict["MinRangeFixed"]

        self.fieldMinRangeFixedCheckBox.setChecked(val)
        self.fieldMinRangeClicked()  # enable/disable

        val = fieldParamsDict["MaxRange"]

        self.fieldMaxRange.setText(str(val))
        val = fieldParamsDict["MaxRangeFixed"]
        self.fieldMaxRangeFixedCheckBox.setChecked(val)
        self.fieldMaxRangeClicked()  # enable/disable

        val = fieldParamsDict["NumberOfLegendBoxes"]
        #        print MODULENAME, 'fieldComboBoxClicked(): NumberOfLegendBoxes      type(val)= ',type(val)
        self.fieldLegendNumLabels.setValue(val)

        val = fieldParamsDict["NumberAccuracy"]
        #        print MODULENAME, 'fieldComboBoxClicked(): NumberAccuracy      type(val)= ',type(val)
        self.fieldLegendAccuracy.setValue(val)

        val = fieldParamsDict["LegendEnable"]
        self.fieldShowLegendCheckBox.setChecked(val)

        try:
            val = fieldParamsDict["OverlayVectorsOn"]
            self.vectorsOverlayCheckBox.setChecked(val)

        except KeyError:
            print(
                MODULENAME,
                '  WARNING fieldParamsDict key "OverlayVectorsOn" not defined')
            print(MODULENAME, '  fieldParamsDict=', fieldParamsDict)
            print('\n')

        try:
            val = fieldParamsDict["ScalarIsoValues"]

            if type(val) == QVariant:
                self.isovalList.setText(val.toString())
            elif type(val) == str:
                self.isovalList.setText(val)
            else:
                self.isovalList.setText(str(val))

            print('ScalarIsoValues=', val)
        except KeyError:
            print('-----------------\n')
            print(
                MODULENAME,
                '  WARNING fieldParamsDict key "ScalarIsoValues" not defined')
            print(MODULENAME, '  fieldParamsDict=', fieldParamsDict)
            print('\n')
        # sys.exit()
        val = fieldParamsDict["NumberOfContourLines"]

        self.numberOfContoursLinesSpinBox.setValue(val)

        val = fieldParamsDict["ArrowLength"]
        self.vectorsArrowLength.setValue(val)
        val = fieldParamsDict["ScaleArrowsOn"]
        self.vectorsScaleArrowCheckBox.setChecked(val)
        val = fieldParamsDict["FixedArrowColorOn"]
        self.vectorsArrowColorCheckBox.setChecked(val)
        self.vectorsArrowColorClicked()  # enable/disable

        contoursOn = fieldParamsDict["ContoursOn"]
        self.contoursShowCB.setChecked(contoursOn)