Beispiel #1
0
    def get_min_max_metadata(self, scene_metadata, field_name):
        """
        Returns dictionary with the following entries:
        1. MinRangeFixed
        2. MaxRangeFixed
        3. MinRange
        3. MaxRange

        :param scene_metadata:{dict} metadata dictionary
        :param field_name: {str} field name
        :return: {dict}
        """
        out_dict = {}
        if set(['MinRangeFixed', "MaxRangeFixed", 'MinRange',
                'MaxRange']).issubset(set(scene_metadata.keys())):

            min_range_fixed = scene_metadata['MinRangeFixed']
            max_range_fixed = scene_metadata['MaxRangeFixed']
            min_range = scene_metadata['MinRange']
            max_range = scene_metadata['MaxRange']
        else:
            min_range_fixed = Configuration.getSetting("MinRangeFixed",
                                                       field_name)
            max_range_fixed = Configuration.getSetting("MaxRangeFixed",
                                                       field_name)
            min_range = Configuration.getSetting("MinRange", field_name)
            max_range = Configuration.getSetting("MaxRange", field_name)

        out_dict['MinRangeFixed'] = min_range_fixed
        out_dict['MaxRangeFixed'] = max_range_fixed
        out_dict['MinRange'] = min_range
        out_dict['MaxRange'] = max_range

        return out_dict
    def set3DInvisibleTypes(self):
        '''
        Initializes a dictionary self.invisibleCellTypes of invisible cell types - reads settings "Types3DInvisible"
        :return:None
        '''
        self.colorMap = Configuration.getSetting("TypeColorMap")

        typesInvisibleStrTmp = str(Configuration.getSetting("Types3DInvisible"))
        # print "GOT ",typesInvisibleStrTmp
        if typesInvisibleStrTmp != self.typesInvisibleStr:
            self.typesInvisibleStr = str(Configuration.getSetting("Types3DInvisible"))

            typesInvisible = self.typesInvisibleStr.replace(" ", "")

            typesInvisible = typesInvisible.split(",")

            def cell_type_check(cell_type):
                try:
                    cell_type_int = int(cell_type)
                    if cell_type_int >= 0:

                        return True
                    else:
                        return False
                except:
                    False

            typesInvisible = [int(cell_type) for cell_type in typesInvisible if cell_type_check(cell_type)]
            # print "typesInvisibleVec=",typesInvisibleVec
            # turning list into a dictionary
            self.invisibleCellTypes.clear()
            for type in typesInvisible:
                self.invisibleCellTypes[int(type)] = 0
    def generate_cell_type_lookup_table(scene_metadata=None,
                                        actual_screenshot=False):
        """
        generates cell type color lookup table. Depending whether we got metadata for
        actual screenshot or not we will use cell type color lookup table based on
        settings or we will use colors defined int he screenshot description file
        :param scene_metadata: scene metadata dict
        :param actual_screenshot: flag that tells if we got metadata for actual screenshot
        :return:
        """
        if actual_screenshot:
            if scene_metadata is None:
                color_map = Configuration.getSetting("TypeColorMap")
            else:
                color_map = scene_metadata["TypeColorMap"]
        else:
            color_map = Configuration.getSetting("TypeColorMap")

        cell_type_color_lookup_table = vtk.vtkLookupTable()
        # You need to explicitly call Build() when constructing the LUT by hand
        cell_type_color_lookup_table.Build()
        cell_type_color_lookup_table.SetNumberOfTableValues(len(color_map))
        cell_type_color_lookup_table.SetNumberOfColors(len(color_map))

        for type_id, color_obj in list(color_map.items()):
            type_id = int(type_id)
            rgba = to_vtk_rgb(color_obj=color_obj)

            rgba.append(1.0)
            cell_type_color_lookup_table.SetTableValue(type_id, *rgba)

        return cell_type_color_lookup_table
    def store_gui_vis_config(self, scrData):
        """
        Stores visualization settings such as cell borders, on/or cell on/off etc...

        :param scrData: {instance of ScreenshotDescriptionData}
        :return: None
        """

        tvw = self.tabViewWidget()
        if tvw:
            tvw.update_active_window_vis_flags(self.screenshotGraphicsWidget)

        scrData.cell_borders_on = tvw.border_act.isChecked()
        scrData.cells_on = tvw.cells_act.isChecked()
        scrData.cluster_borders_on = tvw.cluster_border_act.isChecked()
        scrData.cell_glyphs_on = tvw.cell_glyphs_act.isChecked()
        scrData.fpp_links_on = tvw.fpp_links_act.isChecked()
        scrData.lattice_axes_on = Configuration.getSetting(
            'ShowHorizontalAxesLabels') or Configuration.getSetting(
                'ShowVerticalAxesLabels')
        scrData.lattice_axes_labels_on = Configuration.getSetting("ShowAxes")
        scrData.bounding_box_on = Configuration.getSetting("BoundingBoxOn")

        invisible_types = Configuration.getSetting("Types3DInvisible")
        invisible_types = invisible_types.strip()

        if invisible_types:
            scrData.invisible_types = list(
                [int(x) for x in invisible_types.split(',')])
        else:
            scrData.invisible_types = []
    def get_config_metadata(self, field_name, field_type):
        """
        Returns dictionary of auxiliary information needed to render borders

        :param field_name:{str} field_name
        :param field_type: {str} field type
        :return: {dict}
        """
        metadata_dict = {}
        metadata_dict['BorderColor'] = qcolor_to_rgba(Configuration.getSetting('BorderColor'))
        metadata_dict['ClusterBorderColor'] = qcolor_to_rgba(Configuration.getSetting('ClusterBorderColor'))
        metadata_dict['BoundingBoxColor'] = qcolor_to_rgba(Configuration.getSetting('BoundingBoxColor'))
        metadata_dict['AxesColor'] = qcolor_to_rgba(Configuration.getSetting('AxesColor'))
        metadata_dict['ContourColor'] = qcolor_to_rgba(Configuration.getSetting('ContourColor'))
        metadata_dict['WindowColor'] = qcolor_to_rgba(Configuration.getSetting('WindowColor'))
        # todo - fix color of fpp links
        metadata_dict['FPPLinksColor'] = qcolor_to_rgba(Configuration.getSetting('FPPLinksColor'))

        metadata_dict['ShowHorizontalAxesLabels'] = Configuration.getSetting('ShowHorizontalAxesLabels')
        metadata_dict['ShowVerticalAxesLabels'] = Configuration.getSetting('ShowVerticalAxesLabels')

        # type-color map
        type_color_map_dict = OrderedDict()
        config_type_color_map = Configuration.getSetting("TypeColorMap")
        for type_id, qt_color in list(config_type_color_map.items()):
            type_color_map_dict[type_id] = qcolor_to_rgba(qt_color)

        metadata_dict['TypeColorMap'] = type_color_map_dict

        return metadata_dict
Beispiel #6
0
    def add_3d_screenshot(self, _plotName, _plotType, _camera, metadata=None):  # called from GraphicsFrameWidget
        if len(self.screenshotDataDict) > self.maxNumberOfScreenshots:
            print("MAX NUMBER OF SCREENSHOTS HAS BEEN REACHED")
        scrData = ScreenshotData()
        scrData.spaceDimension = "3D"
        scrData.plotData = (_plotName, _plotType)

        x_size = Configuration.getSetting("Screenshot_X")
        y_size = Configuration.getSetting("Screenshot_Y")

        (scrName, scrCoreName) = self.produce_screenshot_name(scrData)

        okToAddScreenshot = True
        for name in self.screenshotDataDict:
            scrDataFromDict = self.screenshotDataDict[name]
            if scrDataFromDict.screenshotCoreName == scrCoreName and scrDataFromDict.spaceDimension == "3D":
                if scrDataFromDict.compareCameras(_camera):
                    print("CAMERAS ARE THE SAME")
                    okToAddScreenshot = False
                    break
                else:
                    print("CAMERAS ARE DIFFERENT")

        if (not scrName in self.screenshotDataDict) and okToAddScreenshot:
            scrData.screenshotName = scrName
            scrData.screenshotCoreName = scrCoreName
            scrData.screenshotGraphicsWidget = self.screenshotGraphicsWidget

            scrData.win_width = x_size
            scrData.win_height = y_size

            if metadata is not None:
                scrData.metadata = metadata

            tvw = self.tabViewWidget()
            if tvw:
                tvw.update_active_window_vis_flags(self.screenshotGraphicsWidget)

            self.store_gui_vis_config(scrData=scrData)

            scrData.extractCameraInfo(_camera)

            # on linux there is a problem with X-server/Qt/QVTK implementation and calling resize right after additional QVTK
            # is created causes segfault so possible "solution" is to do resize right before taking screenshot.
            # It causes flicker but does not cause segfault
            # User should NOT close or minimize this "empty" window (on Linux anyway).
            if sys.platform == 'Linux' or sys.platform == 'linux' or sys.platform == 'linux2':
                self.screenshotDataDict[scrData.screenshotName] = scrData
                self.screenshotCounter3D += 1
            else:
                self.screenshotDataDict[scrData.screenshotName] = scrData
                self.screenshotCounter3D += 1
        else:
            print("Screenshot ", scrCoreName, " with current camera settings already exists. " \
                                              "You need to rotate camera i.e. rotate picture " \
                                              "using mouse to take additional screenshot")

        # serializing all screenshots
        self.serialize_screenshot_data()
Beispiel #7
0
    def __initActions(self):
        """
        Private method to define the user interface actions.
        """
        self.actions = []

        self.toolbarFileAct = QAction("&File", self)
        self.toolbarFileAct.setCheckable(True)
        self.toolbarFileAct.setChecked(True)
        self.actions.append(self.toolbarFileAct)

        self.toolbarViewAct = QAction("&View", self)
        self.toolbarViewAct.setCheckable(True)
        self.toolbarViewAct.setChecked(True)
        self.actions.append(self.toolbarViewAct)

        self.toolbarSimAct = QAction("&Simulation", self)
        self.toolbarSimAct.setCheckable(True)
        self.toolbarSimAct.setChecked(True)
        self.actions.append(self.toolbarSimAct)
        self.toolbarSimAct.setShortcut(Qt.CTRL + Qt.Key_M)

        self.modelAct = QAction("&Model Editor", self)
        self.modelAct.setCheckable(True)

        if Configuration.getSetting('DisplayModelEditor'):
            self.modelAct.setChecked(True)

        self.modelAct.triggered.connect(self.toggleModelEditor)

        self.actions.append(self.modelAct)

        self.pluginsAct = QAction("&Plugins", self)
        self.pluginsAct.setCheckable(True)
        self.pluginsAct.setChecked(True)
        self.pluginsAct.triggered.connect(self.__toggleCPlugins)

        self.actions.append(self.pluginsAct)

        self.latticeDataAct = QAction("&Lattice Data", self)
        self.latticeDataAct.setCheckable(True)
        if Configuration.getSetting('DisplayLatticeData'):
            self.latticeDataAct.setChecked(True)
        self.latticeDataAct.triggered.connect(self.toggleLatticeData)

        self.actions.append(self.latticeDataAct)

        self.consoleAct = QAction("&Console", self)
        self.consoleAct.setCheckable(True)

        self.toggleConsole(Configuration.getSetting('DisplayConsole'))

        if Configuration.getSetting('DisplayConsole'):
            self.consoleAct.setChecked(True)

        self.consoleAct.triggered.connect(self.toggleConsole)

        self.actions.append(self.consoleAct)
Beispiel #8
0
    def add_2d_screenshot(self, _plotName, _plotType, _projection, _projectionPosition,
                          _camera, metadata=None):
        if len(self.screenshotDataDict) > self.maxNumberOfScreenshots:
            print("MAX NUMBER OF SCREENSHOTS HAS BEEN REACHED")

        scrData = ScreenshotData()
        scrData.spaceDimension = "2D"
        scrData.plotData = (_plotName, _plotType)

        x_size = Configuration.getSetting("Screenshot_X")
        y_size = Configuration.getSetting("Screenshot_Y")

        scrData.projection = _projection
        scrData.projectionPosition = int(_projectionPosition)

        #        import pdb; pdb.set_trace()

        (scrName, scrCoreName) = self.produce_screenshot_name(scrData)

        print("  add2DScreenshot():  THIS IS NEW SCRSHOT NAME", scrName)  # e.g. Cell_Field_CellField_2D_XY_150

        if not scrName in self.screenshotDataDict:
            scrData.screenshotName = scrName
            scrData.screenshotCoreName = scrCoreName
            scrData.screenshotGraphicsWidget = self.screenshotGraphicsWidget  # = GraphicsFrameWidget (rf. __init__)

            scrData.win_width = x_size
            scrData.win_height = y_size

            if metadata is not None:
                scrData.metadata = metadata

            tvw = self.tabViewWidget()
            if tvw:
                tvw.update_active_window_vis_flags(self.screenshotGraphicsWidget)

            self.store_gui_vis_config(scrData=scrData)
            scrData.extractCameraInfo(_camera)  # so "camera" icon (save images) remembers camera view

            # on linux there is a problem with X-server/Qt/QVTK implementation and calling resize right after additional QVTK
            # is created causes segfault so possible "solution" is to do resize right before taking screenshot.
            # It causes flicker but does not cause segfault.
            # User should NOT close or minimize this "empty" window (on Linux anyway).
            if sys.platform == 'Linux' or sys.platform == 'linux' or sys.platform == 'linux2':
                #                pass
                self.screenshotDataDict[scrData.screenshotName] = scrData
            else:
                self.screenshotDataDict[scrData.screenshotName] = scrData
        else:
            print("Screenshot ", scrName, " already exists")

        # serializing all screenshots
        self.serialize_screenshot_data()
    def get_vector_field_metadata(self, field_name, field_type):
        """
        Returns dictionary of auxiliary information needed to render a give scene
        :param field_name:{str} field_name
        :param field_type: {str} field type
        :return: {dict}
        """

        metadata_dict = self.get_con_field_metadata(field_name=field_name, field_type=field_type)
        metadata_dict['ArrowLength'] = Configuration.getSetting('ArrowLength', field_name)
        metadata_dict['FixedArrowColorOn'] = Configuration.getSetting('FixedArrowColorOn', field_name)
        metadata_dict['ArrowColor'] = qcolor_to_rgba(Configuration.getSetting('ArrowColor', field_name))
        metadata_dict['ScaleArrowsOn'] = Configuration.getSetting('ScaleArrowsOn', field_name)

        return metadata_dict
Beispiel #10
0
 def Render(self):
     color = Configuration.getSetting("WindowColor")
     self.ren.SetBackground(
         float(color.red()) / 255,
         float(color.green()) / 255,
         float(color.blue()) / 255)
     self.qvtkWidget.Render()
Beispiel #11
0
    def restore_plots_layout(self):
        ''' This function restores plot layout - it is called from CompuCellSetup.py inside mainLoopNewPlayer function
        :return: None
        '''

        windows_layout_dict = Configuration.getSetting('WindowsLayout')

        if not windows_layout_dict:
            return

        for winId, win in self.vm.win_inventory.getWindowsItems(PLOT_WINDOW_LABEL):
            plot_frame_widget = win.widget()

            plot_interface = plot_frame_widget.plotInterface()  # plot_frame_widget.plotInterface is a weakref

            if not plot_interface:  # if weakref to plot_interface is None we ignore such window
                continue

            if str(plot_interface.title) in list(windows_layout_dict.keys()):
                window_data_dict = windows_layout_dict[str(plot_interface.title)]



                gwd = GraphicsWindowData()
                gwd.fromDict(window_data_dict)

                if gwd.winType != 'plot':
                    return
                win.resize(gwd.winSize)
                win.move(gwd.winPosition)
                win.setWindowTitle(plot_interface.title)
Beispiel #12
0
    def restoreSingleWindow(self, plotWindowInterface):
        '''
        Restores size and position of a single, just-added plot window
        :param plotWindowInterface: an insance of PlotWindowInterface - can be fetchet from PlotFrameWidget using PlotFrameWidgetInstance.plotInterface
        :return: None
        '''

        windows_layout_dict = Configuration.getSetting('WindowsLayout')
        # print 'windowsLayoutDict=', windowsLayoutDict

        if not windows_layout_dict:
            return

        if str(plotWindowInterface.title) in list(windows_layout_dict.keys()):
            window_data_dict = windows_layout_dict[str(plotWindowInterface.title)]

            gwd = GraphicsWindowData()
            gwd.fromDict(window_data_dict)

            if gwd.winType != 'plot':
                return

            plot_window = self.vm.lastActiveRealWindow
            plot_window.resize(gwd.winSize)
            plot_window.move(gwd.winPosition)
            plot_window.setWindowTitle(plotWindowInterface.title)
Beispiel #13
0
 def setScreenUpdateFrequency(self):
     import cc3d.player5.Configuration as Configuration
     try:
         self.screenUpdateFrequency = Configuration.getSetting(
             "ScreenUpdateFrequency")
     except:
         print('SIMTHREAD: Could not access configuration.')
Beispiel #14
0
    def initParams(self):
        '''
            this fcn stores current settings for all the keys of Configuration.Configuration.defaultConfigs as a self.paramCC3D dictionary
        '''

        for key in Configuration.getSettingNameList():
            self.paramCC3D[key] = Configuration.getSetting(key)
Beispiel #15
0
    def check_version(self, check_interval=-1, display_no_update_info=False):
        """
        This function checks if new CC3D version is available
        :return:None
        """

        # here we decide whether the information about no new updates is displayed or not. For automatic update checks
        # this information should not be displayed. For manual update checks we need to inform the user
        # that there are no updates

        self.display_no_update_info = display_no_update_info

        # determine if check is necessary - for now we check every week in order not to bother users with too many checks
        last_version_check_date = Configuration.getSetting(
            'LastVersionCheckDate')

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

        old_date = datetime.date(int(last_version_check_date[:4]),
                                 int(last_version_check_date[4:6]),
                                 int(last_version_check_date[6:]))
        t_delta = today - old_date

        if t_delta.days < check_interval:
            # check for CC3D recently
            return
        else:
            print('WILL DO THE CHECK')

        version_fetcher = WebFetcher(_parent=self)
        version_fetcher.gotWebContentSignal.connect(self.process_version_check)

        version_fetcher.fetch("http://www.compucell3d.org/current_version")
Beispiel #16
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 __init__(self, parent=None, originatingWidget=None):
        QtWidgets.QFrame.__init__(self, parent)
        self.is_screenshot_widget = False
        self.qvtkWidget = QVTKRenderWindowInteractor(self)  # a QWidget

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        # MDIFIX
        self.parentWidget = ref(originatingWidget)

        self.plane = None
        self.planePos = None

        self.lineEdit = QtWidgets.QLineEdit()

        self.init_cross_section_actions()
        self.cstb = self.initCrossSectionToolbar()

        layout = QtWidgets.QBoxLayout(QtWidgets.QBoxLayout.TopToBottom)
        layout.addWidget(self.cstb)
        layout.addWidget(self.qvtkWidget)
        self.setLayout(layout)
        self.setMinimumSize(100, 100)  # needs to be defined to resize smaller than 400x400
        self.resize(600, 600)

        self.qvtkWidget.Initialize()
        self.qvtkWidget.Start()

        # todo 5 - adding generic drawer

        self.gd = GenericDrawer()
        self.gd.set_interactive_camera_flag(True)
        self.gd.set_pixelized_cartesian_scene(Configuration.getSetting("PixelizedCartesianFields"))

        # placeholder for current screenshot data
        self.current_screenshot_data = None

        # placeholder for currently used basic simulation data
        self.current_bsd = None

        self.camera2D = self.gd.get_active_camera()
        self.camera3D = self.gd.get_renderer().MakeCamera()

        self.renWin = self.qvtkWidget.GetRenderWindow()
        self.renWin.AddRenderer(self.gd.get_renderer())

        self.metadata_fetcher_dict = {
            'CellField': self.get_cell_field_metadata,
            'ConField': self.get_con_field_metadata,
            'ScalarField': self.get_con_field_metadata,
            'ScalarFieldCellLevel': self.get_con_field_metadata,
            'VectorField': self.get_vector_field_metadata,
            'VectorFieldCellLevel': self.get_vector_field_metadata,
        }
    def __createViewManager(self):
        self.zitems = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2.0, 3.0, 4.0, 8.0]
        self.viewmanager = SimpleTabView(
            self)  # ViewManager.factory(self, self)

        self.viewmanager.set_recent_simulation_file(
            str(Configuration.getSetting("RecentFile")))

        self.viewmanager.setZoomItems(self.zitems)

        # self.viewmanager.setOrientation(Qt.Vertical)
        self.setCentralWidget(self.viewmanager)
    def populateLookupTable(
            self):  # rwh: why is this method in both View & Model?

        self.drawModel.populateLookupTable(
        )  # have to update colors in model objects
        colorMap = Configuration.getSetting("TypeColorMap")
        for key in list(colorMap.keys()):
            r = colorMap[key].red()
            g = colorMap[key].green()
            b = colorMap[key].blue()
            self.lut.SetTableValue(key, self.toVTKColor(r), self.toVTKColor(g),
                                   self.toVTKColor(b), 1.0)
Beispiel #20
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 get_con_field_metadata(self, field_name, field_type):
        """
        Returns dictionary of auxiliary information needed to render a give scene
        :param field_name:{str} field_name
        :param field_type: {str} field type
        :return: {dict}
        """

        # metadata_dict = {}
        metadata_dict = self.get_config_metadata(field_name=field_name, field_type=field_type)
        con_field_name = field_name
        metadata_dict['MinRangeFixed'] = Configuration.getSetting("MinRangeFixed", con_field_name)
        metadata_dict['MaxRangeFixed'] = Configuration.getSetting("MaxRangeFixed", con_field_name)
        metadata_dict['MinRange'] = Configuration.getSetting("MinRange", con_field_name)
        metadata_dict['MaxRange'] = Configuration.getSetting("MaxRange", con_field_name)
        metadata_dict['ContoursOn'] = Configuration.getSetting("ContoursOn", con_field_name)
        metadata_dict['NumberOfContourLines'] = Configuration.getSetting("NumberOfContourLines", field_name)
        metadata_dict['ScalarIsoValues'] = cs_string_to_typed_list(
            Configuration.getSetting("ScalarIsoValues", field_name))
        metadata_dict['LegendEnable'] = Configuration.getSetting("LegendEnable", field_name)
        metadata_dict['DisplayMinMaxInfo'] = Configuration.getSetting("DisplayMinMaxInfo")

        return metadata_dict
Beispiel #22
0
 def populateLookupTable(self):
     #        print MODULENAME,' populateLookupTable()'
     colorMap = Configuration.getSetting("TypeColorMap")
     #        print MODULENAME,' populateLookupTable():  len(colorMap)=',len(colorMap)
     self.celltypeLUT.SetNumberOfTableValues(len(colorMap))
     self.celltypeLUT.SetNumberOfColors(len(colorMap))
     #        lutGlyph.SetTableValue(5, 1,0,0, 1.0)     # SetTableValue (vtkIdType indx, double r, double g, double b, double a=1.0)
     #        lutGlyph.SetTableValue(8, 0,1,1, 1.0)     # SetTableValue (vtkIdType indx, double r, double g, double b, double a=1.0)
     for key in list(colorMap.keys()):
         r = colorMap[key].red()
         g = colorMap[key].green()
         b = colorMap[key].blue()
         self.celltypeLUT.SetTableValue(key, self.toVTKColor(r), self.toVTKColor(g), self.toVTKColor(b), 1.0)
     #            print "       type=",key," red=",r," green=",g," blue=",b
     #            print "       type=",key," (VTK) red=",self.toVTKColor(r)," green=",self.toVTKColor(g)," blue=",self.toVTKColor(b)
     # self.qvtkWidget.repaint()
     self.celltypeLUT.Build()
     self.celltypeLUTMax = self.celltypeLUT.GetNumberOfTableValues() - 1  # cell types = [0,max]
     self.celltypeLUT.SetTableRange(0, self.celltypeLUTMax)
Beispiel #23
0
    def check_version(self, check_interval=-1, display_no_update_info=False):
        """
        This function checks if new CC3D version is available
        :return:None
        """

        # checking if cc3d is running in nanohub. if it is do not check for updates (it'll be blocked by their firewall)
        if 'NANOHUB_SIM' in environ:
            return

        # here we decide whether the information about no new updates is displayed or not. For automatic update checks
        # this information should not be displayed. For manual update checks we need to inform the user
        # that there are no updates

        self.display_no_update_info = display_no_update_info

        # determine if check is necessary - for now we check every week in order
        # not to bother users with too many checks
        last_version_check_date = Configuration.getSetting(
            'LastVersionCheckDate')

        today = datetime.date.today()

        old_date = datetime.date(int(last_version_check_date[:4]),
                                 int(last_version_check_date[4:6]),
                                 int(last_version_check_date[6:]))
        t_delta = today - old_date

        if t_delta.days < check_interval:
            # check for CC3D recently
            return
        else:
            print('WILL DO THE CHECK')

        if requests_web_fetcher_available:
            self.version_fetcher = WebFetcherRequests(_parent=self)
        else:
            self.version_fetcher = WebFetcher(_parent=self)

        self.version_fetcher.gotWebContentSignal.connect(
            self.process_version_check)
        self.version_fetcher.fetch(self.cc3d_updates_url)
    def read_cell_type_color_data(self):
        """

        :return:
        """
        self.item_data = OrderedDict()

        type_color_map = Configuration.getSetting('TypeColorMap')
        names_ids = CompuCellSetup.simulation_utils.extract_type_names_and_ids()
        for type_id, type_name in names_ids.items():

            try:
                color = type_color_map[type_id]
            except KeyError:
                color = QColor('black')

            self.item_data[type_id] = [type_name, color]


        self.update(item_data=self.item_data)
Beispiel #25
0
    def populate_cell_type_lookup_table(self, scene_metadata=None):
        """
        Populates lookup table
        :param scene_metadata:
        :return:
        """
        if scene_metadata is None:
            color_map = Configuration.getSetting("TypeColorMap")
        else:
            color_map = scene_metadata["TypeColorMap"]

        self.celltypeLUT = vtk.vtkLookupTable()
        # You need to explicitly call Build() when constructing the LUT by hand
        self.celltypeLUT.Build()
        self.celltypeLUT.SetNumberOfTableValues(len(color_map))
        self.celltypeLUT.SetNumberOfColors(len(color_map))

        for type_id, qt_color in list(color_map.items()):
            rgba = to_vtk_rgb(qcolor_to_rgba(qt_color))
            rgba.append(1.0)
            self.celltypeLUT.SetTableValue(type_id, *rgba)
    def __init__(self):
        QMainWindow.__init__(self)
        self.argv = None

        QApplication.setWindowIcon(QIcon(gip("cc3d_64x64_logo.png")))
        self.setWindowIcon(QIcon(gip("cc3d_64x64_logo.png")))
        self.setWindowTitle("CompuCell3D Player")

        self.origStdout = sys.stdout
        self.origStderr = sys.stderr

        self.__toolbars = {}

        # Setting self.viewmanager and dock windows
        self.__createViewManager()
        self.__createLayout()

        # # Generate the redirection helpers
        self.stdout = sys.stdout
        self.stderr = sys.stderr

        # Now setup the connections
        if Configuration.getSetting("UseInternalConsole"):
            self.stdout = Redirector(False)
            self.stderr = Redirector(True)

            self.stdout.appendStdout.connect(self.appendToStdout)
            self.stderr.appendStderr.connect(self.appendToStderr)
            self.appendStdoutSignal.connect(self.console.appendToStdout)
            self.appendStderrSignal.connect(self.console.appendToStderr)

        # I don't know why I need this
        cc3dApp().registerObject("UserInterface", self)
        cc3dApp().registerObject("ViewManager", self.viewmanager)

        # Setup actions
        self.__initActions()
        # Setup menus
        self.__initMenus()

        # Setup toolbars
        self.__initToolbars()

        # Setup status bar
        self.__initStatusbar()

        # now redirect stdout and stderr
        if Configuration.getSetting("CC3DOutputOn"):

            if Configuration.getSetting("UseInternalConsole"):
                # redirecting Python output to internal console
                self.use_internal_console_for_python_output(True)
            else:
                # Python output goes to system console
                self.enable_python_output(True)
        else:
            # silencing output from Python
            self.enable_python_output(False)

        self.initialize_gui_geometry()

        floating_flag = Configuration.getSetting('FloatingWindows')

        floating_non_graphics_flag = False
        # we allow non-graphics windows to be docked. This improves
        # layout when we request floating grahics windows
        self.modelEditorDock.setFloating(floating_non_graphics_flag)
        self.consoleDock.setFloating(floating_non_graphics_flag)
        self.latticeDataDock.setFloating(floating_non_graphics_flag)

        if floating_flag:
            # in order to have all dock widgets expand (i.e. fill all available space)
            # we hide central widget when graphics windows are floating
            self.centralWidget().hide()
    def initialize_gui_geometry(self, allow_main_window_move: bool = True):
        """
        Initializes GUI geometry based on saved settings and based on current screen configuration
        :param allow_main_window_move: flag that specifies whether we may move main window according to settings or not
        We typically allow to moving of the main window at the GUI startup but not after loading simulation
        :return:
        """

        current_screen_geometry_settings = self.get_current_screen_geometry_settings(
        )
        saved_screen_geometry_settings = Configuration.getSetting(
            "ScreenGeometry")

        main_window_size = Configuration.getSetting("MainWindowSizeDefault")
        main_window_position = Configuration.getSetting(
            "MainWindowPositionDefault")
        if self.viewmanager.MDI_ON:
            player_sizes = Configuration.getSetting("PlayerSizesDefault")
        else:
            player_sizes = Configuration.getSetting(
                "PlayerSizesFloatingDefault")

        if current_screen_geometry_settings == saved_screen_geometry_settings:
            # this indicates that saved screen geometry is the same as current screen geometry and we will use
            # saved settings because we are working with same screen configuration so it is safe to restore
            if self.viewmanager.MDI_ON:
                # configuration of MDI
                main_window_size = Configuration.getSetting("MainWindowSize")
                main_window_position = Configuration.getSetting(
                    "MainWindowPosition")
                player_sizes = Configuration.getSetting("PlayerSizes")
            else:
                main_window_size = Configuration.getSetting(
                    "MainWindowSizeFloating")

                main_window_position = Configuration.getSetting(
                    "MainWindowPositionFloating")
                player_sizes = Configuration.getSetting("PlayerSizesFloating")

        self.resize(main_window_size)
        # we want main window to move only during initial opening of the GUI but not upon loading new simulation
        if allow_main_window_move:
            self.move(main_window_position)

        if player_sizes and player_sizes.size() > 0:
            self.restoreState(player_sizes)
    def __initActions(self):
        """
        Private method to define the user interface actions.
        """
        self.actions = []
        # self.zoomInAct = QAction(QIcon(gip("zoomIn.png")), "&Zoom In", self)
        # self.actions.append(self.zoomInAct) # Replaced "viewActions" by "actions":self.viewActions.append(self.zoomInAct)
        # #
        # self.zoomOutAct = QAction(QIcon(gip("zoomOut.png")), "&Zoom Out", self)
        # self.actions.append(self.zoomOutAct)

        # # Why do I need self.zoomFixedAct?
        # #self.zoomFixedAct = QAction(self)
        # self.zoomFixed  = QComboBox()
        # self.zoomFixed.setToolTip("Zoom Fixed")
        # self.zoomFixed.addItems(self.__zoomItems())
        # self.zoomFixed.setCurrentIndex(3)
        # self.zoomFixed.addAction(self.zoomFixedAct)
        # self.actions.append(self.zoomFixedAct)

        # self.screenshotAct = QAction(QIcon("player5/icons/screenshot.png"), "&Take Screenshot", self)
        # self.actions.append(self.screenshotAct)

        self.toolbarFileAct = QAction("&File", self)
        self.toolbarFileAct.setCheckable(True)
        self.toolbarFileAct.setChecked(True)
        self.actions.append(self.toolbarFileAct)

        self.toolbarViewAct = QAction("&View", self)
        self.toolbarViewAct.setCheckable(True)
        self.toolbarViewAct.setChecked(True)
        self.actions.append(self.toolbarViewAct)

        self.toolbarSimAct = QAction("&Simulation", self)
        self.toolbarSimAct.setCheckable(True)
        self.toolbarSimAct.setChecked(True)
        self.actions.append(self.toolbarSimAct)
        self.toolbarSimAct.setShortcut(Qt.CTRL + Qt.Key_M)

        self.modelAct = QAction("&Model Editor", self)
        self.modelAct.setCheckable(True)
        # self.modelAct.setChecked(True) #not self.projectBrowserDock.isHidden()
        if Configuration.getSetting('DisplayModelEditor'):
            self.modelAct.setChecked(True)
        # self.connect(self.modelAct, SIGNAL("triggered(bool)"), self.toggleModelEditor)
        self.modelAct.triggered.connect(self.toggleModelEditor)
        # self.connect(self.modelAct, SIGNAL("triggered(bool)"), self.toggleModelEditor)

        self.actions.append(self.modelAct)

        self.pluginsAct = QAction("&Plugins", self)
        self.pluginsAct.setCheckable(True)
        self.pluginsAct.setChecked(True)
        # self.connect(self.pluginsAct, SIGNAL("triggered()"), self.__toggleCPlugins)
        self.pluginsAct.triggered.connect(self.__toggleCPlugins)

        self.actions.append(self.pluginsAct)

        self.latticeDataAct = QAction("&Lattice Data", self)
        self.latticeDataAct.setCheckable(True)
        if Configuration.getSetting('DisplayLatticeData'):
            self.latticeDataAct.setChecked(True)
        # self.latticeDataAct.setChecked(False)
        # self.connect(self.latticeDataAct, SIGNAL("triggered(bool)"), self.toggleLatticeData)
        self.latticeDataAct.triggered.connect(self.toggleLatticeData)

        self.actions.append(self.latticeDataAct)

        # self.connect(self.zoomInAct, SIGNAL('triggered()'), self.viewmanager.zoomIn)
        # self.connect(self.zoomOutAct, SIGNAL('triggered()'), self.viewmanager.zoomOut)
        # self.connect(self.zoomFixed, SIGNAL('activated(int)'), self.viewmanager.zoomFixed)
        # self.connect(self.screenshotAct, SIGNAL('triggered()'), self.viewmanager.takeShot)

        # self.connect(self.newGraphicsWindowAct, SIGNAL('triggered()'), self.viewmanager.addVTKWindowToWorkspace)

        # Keep this code. There won't be plotting in 3.4.0 version
        """
        self.plotAct = QAction("&Plot", self)
        self.plotAct.setCheckable(True)
        self.plotAct.setChecked(True)
        self.actions.append(self.plotAct)
        """

        self.consoleAct = QAction("&Console", self)
        self.consoleAct.setCheckable(True)

        self.toggleConsole(Configuration.getSetting('DisplayConsole'))

        if Configuration.getSetting('DisplayConsole'):
            self.consoleAct.setChecked(True)

        # self.connect(self.consoleAct, SIGNAL("triggered(bool)"), self.toggleConsole)
        self.consoleAct.triggered.connect(self.toggleConsole)

        self.actions.append(self.consoleAct)
    def __init__(self):
        QMainWindow.__init__(self)
        self.argv = None
        # self.resize(QSize(900, 650))

        QApplication.setWindowIcon(QIcon(gip("cc3d_64x64_logo.png")))
        self.setWindowIcon(QIcon(gip("cc3d_64x64_logo.png")))
        self.setWindowTitle("CompuCell3D Player")

        self.origStdout = sys.stdout
        self.origStderr = sys.stderr
        # Setting self.viewmanager and dock windows
        # TODO
        self.__createViewManager()
        self.__createLayout()

        # # Generate the redirection helpers
        self.stdout = Redirector(False)
        self.stderr = Redirector(True)
        # #TODO
        self.stderr.setStdErrConsole(self.console.getStdErrConsole())

        # Now setup the connections
        if Configuration.getSetting("UseInternalConsole"):
            self.stdout.appendStdout.connect(self.appendToStdout)
            self.stderr.appendStderr.connect(self.appendToStderr)
            self.appendStdoutSignal.connect(self.console.appendToStdout)
            self.appendStderrSignal.connect(self.console.appendToStderr)

            # self.connect(self.stdout, SIGNAL('appendStdout'), self.appendToStdout)
            # self.connect(self.stderr, SIGNAL('appendStderr'), self.appendToStderr)
            #
            # self.connect(self, SIGNAL('appendStdout'), self.console.appendToStdout)
            # self.connect(self, SIGNAL('appendStderr'), self.console.appendToStderr)

        # I don't know why I need this
        cc3dApp().registerObject("UserInterface", self)
        cc3dApp().registerObject("ViewManager", self.viewmanager)

        self.__initActions()  # Setup actions
        self.__initMenus()  # Setup menus

        # self.__createViewManager()
        self.__initToolbars()  # Setup toolbars
        self.__initStatusbar()  # Setup status bar

        # self.tabWidget=QTabWidget(self)
        # self.tabWidget=SimpleTabView(self)
        # self.setCentralWidget(self.tabWidget)

        # now redirect stdout and stderr
        if Configuration.getSetting("CC3DOutputOn"):

            if Configuration.getSetting("UseInternalConsole"):
                # redirecting Python output to internal console
                self.useInternalConsoleForPythonOutput(True)
            else:
                # Python output goes to system console
                self.enablePythonOutput(True)
        else:
            # silencing output from Python
            self.enablePythonOutput(False)
        # TODO
        if self.viewmanager.MDI_ON:  # configuration of MDI
            playerSizes = Configuration.getSetting("PlayerSizes")
            if playerSizes and playerSizes.size() > 0:
                self.resize(Configuration.getSetting("MainWindowSize"))
                self.move(Configuration.getSetting("MainWindowPosition"))
                self.restoreState(playerSizes)
            else:
                self.resize(Configuration.getSetting("MainWindowSize"))
                self.move(Configuration.getSetting("MainWindowPosition"))
        else:  # configuration of floating windows
            playerSizes = Configuration.getSetting("PlayerSizesFloating")

            if playerSizes and playerSizes.size() > 0:
                self.resize(Configuration.getSetting("MainWindowSizeFloating"))
                self.resize(
                    self.size().width(), 20
                )  # resizing vertical dimension to be minimal - for PyQt5 we cannot use 0
                self.move(
                    Configuration.getSetting("MainWindowPositionFloating"))
                self.restoreState(playerSizes)
            else:
                self.resize(Configuration.getSetting("MainWindowSizeFloating"))
                self.resize(
                    self.size().width(), 20
                )  # resizing vertical dimension to be minimal - for PyQt5 we cannot use 0
                self.move(
                    Configuration.getSetting("MainWindowPositionFloating"))

        # if playerSizes and playerSizes.size()>0:
        #     self.resize(Configuration.getSetting("MainWindowSize"))
        #     self.move(Configuration.getSetting("MainWindowPosition"))
        #     self.restoreState(playerSizes)
        # else:
        #     self.resize(Configuration.getSetting("MainWindowSize"))
        #     self.move(Configuration.getSetting("MainWindowPosition"))

        # MDIFIX
        floatingFlag = Configuration.getSetting('FloatingWindows')
        self.modelEditorDock.setFloating(floatingFlag)
        self.consoleDock.setFloating(floatingFlag)
        self.latticeDataDock.setFloating(floatingFlag)
Beispiel #30
0
    def __init__(self, ui):
        QObject.__init__(self)
        self.visual = {
            "CellsOn":
            Configuration.getSetting("CellsOn"),
            "CellBordersOn":
            Configuration.getSetting("CellBordersOn"),
            "ClusterBordersOn":
            Configuration.getSetting("ClusterBordersOn"),
            "CellGlyphsOn":
            Configuration.getSetting("CellGlyphsOn"),
            "FPPLinksOn":
            Configuration.getSetting("FPPLinksOn"),
            "CC3DOutputOn":
            Configuration.getSetting("CC3DOutputOn"),
            "ConcentrationLimitsOn":
            Configuration.getSetting("ConcentrationLimitsOn"),
            "ZoomFactor":
            Configuration.getSetting("ZoomFactor"),
        }

        # file actions
        self.open_act = None
        self.open_lds_act = None
        self.exit_act = None
        self.twedit_act = None

        # Simulation actions
        self.run_act = None
        self.step_act = None
        self.pause_act = None
        self.stop_act = None
        self.restore_default_settings_act = None

        # visualization actions
        self.cells_act = None
        self.border_act = None
        self.cluster_border_act = None
        self.cell_glyphs_act = None
        self.fpp_links_act = None
        self.limits_act = None
        self.cc3d_output_on_act = None
        self.reset_camera_act = None
        self.zoom_in_act = None
        self.zoom_out_act = None

        # tools Actions
        self.config_act = None
        self.pif_from_vtk_act = None
        self.pif_from_simulation_act = None
        self.restart_snapshot_from_simulation_act = None

        # windows actions
        self.python_steering_panel_act = None
        self.new_graphics_window_act = None
        self.tile_act = None
        self.cascade_act = None
        self.minimize_all_graphics_windows_act = None
        self.restore_all_graphics_windows_act = None
        self.close_active_window_act = None

        # help actions
        self.quick_act = None
        self.tutor_act = None
        self.ref_man_act = None
        self.about_act = None
        self.mail_subscribe_act = None
        self.mail_unsubscribe_act = None
        self.mail_subscribe_unsubscribe_web_act = None
        self.check_update_act = None
        self.whats_this_act = None

        self.display_no_update_info = False

        self.init_actions()
        self.ui = ui