예제 #1
0
    def updateDataFile(self, data_file: DataFileExtended, new_database: bool) -> None:
        self.data_file = data_file
        self.config = data_file.getOptionAccess()

        self.undo = undo(self.data_file.db, ["mask"])
        self.undo.activate()
        self.undo.refresh = self.updateState
예제 #2
0
    def updateDataFile(self, data_file: DataFileExtended,
                       new_database: bool) -> None:
        self.data_file = data_file
        self.config = data_file.getOptionAccess()

        self.ToggleInterfaceEvent(hidden=self.config.contrast_interface_hidden)
        self.schedule_update = True
예제 #3
0
    def updateDataFile(self, data_file: DataFileExtended, new_database: bool) -> None:
        self.data_file = data_file
        self.config = data_file.getOptionAccess()

        self.mask_file = MaskFile(data_file)

        # if a new database is created take mask types from config
        if new_database:
            for type_id, type_def in enumerate(self.config.draw_types):
                if len(type_def) >= 3:
                    name = type_def[2]
                else:
                    name = "Color%d" % type_id
                self.mask_file.set_type(type_id, name, type_def[1], type_def[0])

        # update mask interface buttons
        self.maskTypeChooser.updateButtons(self.mask_file)

        # get config options
        self.changeOpacity(self.config.mask_opacity - self.mask_opacity)
        self.changeCursorSize(self.config.mask_brush_size - self.DrawCursorSize)
        self.ToggleInterfaceEvent(hidden=self.config.mask_interface_hidden)
        if self.config.selected_draw_type >= 0:
            self.maskTypeChooser.setActiveDrawType(self.config.selected_draw_type)

        # place tick marks for already present masks
        # but lets take care that there are masks ...
        try:
            frames = np.array(self.mask_file.get_mask_frames().tuples())[:, 0]
            BroadCastEvent(self.modules, "MarkerPointsAddedList", frames)
        except IndexError:
            pass
예제 #4
0
    def updateDataFile(self, data_file: DataFileExtended,
                       new_database: bool) -> None:
        self.data_file = data_file
        self.config = data_file.getOptionAccess()

        if self.config.info_hud_string != "":
            self.setVisible(True)
            self.hidden = False
            self.ToggleInterfaceEvent(self.hidden)
예제 #5
0
    def updateDataFile(self, data_file: DataFileExtended, new_database: bool) -> None:
        self.data_file = data_file
        self.config = data_file.getOptionAccess()
        self.scripts = self.loadScripts()

        for script in self.data_file.getOption("scripts"):
            self.activateScript(script, silent=True)

        self.updateScripts()
예제 #6
0
 def updateDataFile(self, data_file: DataFileExtended,
                    new_database: bool) -> None:
     self.data_file = data_file
     self.config = data_file.getOptionAccess()
예제 #7
0
    def __init__(self, window: "ClickPointsWindow", data_file: DataFileExtended, parent: "OptionEditor") -> None:
        QtWidgets.QWidget.__init__(self)
        self.window = window
        self.data_file = data_file
        self.parent = parent

        # Widget
        self.setMinimumWidth(450)
        self.setMinimumHeight(200)
        self.setWindowTitle("Options - ClickPoints")

        self.main_layout = QtWidgets.QVBoxLayout(self)
        self.version_widget = VersionDisplay(self, self.main_layout, window)

        self.list_layout = QtWidgets.QVBoxLayout()
        self.stackedLayout = QtWidgets.QStackedLayout()
        self.top_layout = QtWidgets.QHBoxLayout()
        self.top_layout.addLayout(self.list_layout)
        self.main_layout.addLayout(self.top_layout)

        layout = QtWidgets.QHBoxLayout()
        self.button_export = QtWidgets.QPushButton("&Export")
        self.button_export.clicked.connect(self.Export)
        layout.addWidget(self.button_export)
        self.button_import = QtWidgets.QPushButton("&Import")
        self.button_import.clicked.connect(self.Import)
        layout.addWidget(self.button_import)
        layout.addStretch()
        self.button_ok = QtWidgets.QPushButton("&Ok")
        self.button_ok.clicked.connect(self.Ok)
        layout.addWidget(self.button_ok)
        self.button_cancel = QtWidgets.QPushButton("&Cancel")
        self.button_cancel.clicked.connect(self.Cancel)
        layout.addWidget(self.button_cancel)
        self.button_apply = QtWidgets.QPushButton("&Apply")
        self.button_apply.clicked.connect(self.Apply)
        self.button_apply.setDisabled(True)
        layout.addWidget(self.button_apply)
        self.main_layout.addLayout(layout)

        self.list = QtWidgets.QListWidget()
        self.list_layout.addWidget(self.list)
        self.list.setMaximumWidth(80)

        self.list.currentRowChanged.connect(self.stackedLayout.setCurrentIndex)
        self.top_layout.addLayout(self.stackedLayout)

        self.setWindowIcon(qta.icon("fa.gears"))

        self.edits = []
        self.edits_by_name = {}

        options = data_file.getOptionAccess()

        for category in self.data_file._options:
            count = len([option for option in self.data_file._options[category] if not option.hidden])
            if count == 0:
                continue
            item = QtWidgets.QListWidgetItem(category, self.list)

            group = QtWidgets.QGroupBox(category)
            group.setFlat(True)
            self.layout = QtWidgets.QVBoxLayout()
            group.setLayout(self.layout)
            self.stackedLayout.addWidget(group)

            for option in self.data_file._options[category]:
                if option.hidden:
                    continue
                edit = getOptionInputWidget(option, self.layout)
                edit.valueChanged.connect(lambda value, edit=edit, option=option: self.Changed(edit, value, option))
                edit.current_value = None
                edit.option = option
                edit.error = None
                edit.has_error = False
                self.edits.append(edit)
                self.edits_by_name[option.key] = edit
            self.layout.addStretch()

        self.edits_by_name["buffer_size"].setDisabled(options.buffer_mode != 1)
        self.edits_by_name["buffer_memory"].setDisabled(options.buffer_mode != 2)
예제 #8
0
    def __init__(self, parent: "VideoExporter", window: "ClickPointsWindow", data_file: DataFileExtended,
                 config: OptionAccess, modules: List[Any]) -> None:
        QtWidgets.QWidget.__init__(self)
        # default settings and parameters
        self.window = window
        self.data_file = data_file
        self.config = config
        self.modules = modules
        options = data_file.getOptionAccess()
        self.options = options

        # widget layout and elements
        self.setMinimumWidth(700)
        self.setMinimumHeight(300)
        self.setWindowIcon(qta.icon('fa.film'))
        self.setWindowTitle('Video Export - ClickPoints')
        self.layout = QtWidgets.QVBoxLayout(self)
        self.parent = parent

        # add combo box to choose export mode
        Hlayout = QtWidgets.QHBoxLayout()
        self.cbType = QtWidgets.QComboBox(self)
        self.cbType.insertItem(0, "Video")
        self.cbType.insertItem(1, "Images")
        self.cbType.insertItem(2, "Gif")
        self.cbType.insertItem(3, "Single Image")
        Hlayout.addWidget(self.cbType)
        self.layout.addLayout(Hlayout)

        # add stacked widget to store export mode parameter
        self.StackedWidget = QtWidgets.QStackedWidget(self)
        self.layout.addWidget(self.StackedWidget)

        self.cbType.currentIndexChanged.connect(self.StackedWidget.setCurrentIndex)

        """ Video """
        videoWidget = QtWidgets.QGroupBox("Video Settings")
        self.StackedWidget.addWidget(videoWidget)
        Vlayout = QtWidgets.QVBoxLayout(videoWidget)

        self.leAName = QtShortCuts.QInputFilename(Vlayout, 'Filename:', os.path.abspath(options.export_video_filename),
                                                  "Choose Video - ClickPoints", "Videos (*.mp4 *.mpeg *.avi)",
                                                  lambda name: self.checkExtension(name, ".mp4"))
        self.leCodec = QtShortCuts.QInputString(Vlayout, "Codec:", options.video_codec, stretch=True)
        self.sbQuality = QtShortCuts.QInputNumber(Vlayout, 'Quality (0 lowest, 10 highest):', options.video_quality,
                                                  min=0, max=10, float=False, stretch=True)

        Vlayout.addStretch()

        """ Image """
        imageWidget = QtWidgets.QGroupBox("Image Settings")
        self.StackedWidget.addWidget(imageWidget)
        Vlayout = QtWidgets.QVBoxLayout(imageWidget)

        self.leANameI = QtShortCuts.QInputFilename(Vlayout, 'Filename:', os.path.abspath(options.export_image_filename),
                                                   "Choose Image - ClickPoints", "Images (*.jpg *.png *.tif, *.svg)",
                                                   self.CheckImageFilename)
        QtShortCuts.QInput(Vlayout, 'Image names have to contain %d as a placeholder for the image number.')

        Vlayout.addStretch()

        """ Gif """
        gifWidget = QtWidgets.QGroupBox("Animated Gif Settings")
        self.StackedWidget.addWidget(gifWidget)
        Vlayout = QtWidgets.QVBoxLayout(gifWidget)

        self.leANameG = QtShortCuts.QInputFilename(Vlayout, 'Filename:', os.path.abspath(options.export_gif_filename),
                                                   "Choose Gif - ClickPoints", "Animated Gifs (*.gif)",
                                                   lambda name: self.checkExtension(name, ".gif"))

        Vlayout.addStretch()

        """ Single Image """
        imageWidget = QtWidgets.QGroupBox("Single Image Settings")
        self.StackedWidget.addWidget(imageWidget)
        Vlayout = QtWidgets.QVBoxLayout(imageWidget)

        self.leANameIS = QtShortCuts.QInputFilename(Vlayout, 'Filename:',
                                                    os.path.abspath(options.export_single_image_filename),
                                                    "Choose Image - ClickPoints", "Images (*.jpg *.png *.tif *.svg)",
                                                    lambda name: self.checkExtension(name, ".jpg"))
        QtShortCuts.QInput(Vlayout,
                           'Single Image will only export the current frame. Optionally, a %d placeholder will be filled with the frame number')

        Vlayout.addStretch()

        """ Time """
        timeWidget = QtWidgets.QGroupBox("Time")
        self.layout.addWidget(timeWidget)
        Hlayout = QtWidgets.QHBoxLayout(timeWidget)
        Vlayout = QtWidgets.QVBoxLayout()
        Hlayout.addLayout(Vlayout)

        self.cbTime = QtShortCuts.QInputBool(Vlayout, 'Display time:', options.export_display_time, stretch=True)
        self.cbTimeZero = QtShortCuts.QInputBool(Vlayout, 'Start from zero:', options.export_time_from_zero,
                                                 stretch=True)
        self.cbTimeFontSize = QtShortCuts.QInputNumber(Vlayout, 'Font size:', options.export_time_font_size,
                                                       float=False, stretch=True)
        self.cbTimeColor = QtShortCuts.QInputColor(Vlayout, "Color:", options.export_time_font_color, stretch=True)
        self.cbTimeFormat = QtShortCuts.QInputString(Vlayout, "Format:", options.export_time_format, stretch=True)
        self.cbTimeDeltaFormat = QtShortCuts.QInputString(Vlayout, "Format:", options.export_timedelta_format,
                                                          stretch=True)

        def updateTimeFormat(self):
            if self.cbTimeZero.value():
                self.cbTimeDeltaFormat.show()
                self.cbTimeFormat.hide()
            else:
                self.cbTimeDeltaFormat.hide()
                self.cbTimeFormat.show()

        self.cbTimeZero.checkbox.stateChanged.connect(lambda x, self=self: updateTimeFormat(self))
        updateTimeFormat(self)

        Vlayout = QtWidgets.QVBoxLayout()
        Hlayout.addLayout(Vlayout)

        self.cbCustomTime = QtShortCuts.QInputBool(Vlayout, 'Custom time:', options.export_custom_time)
        self.cbCustomTimeDelta = QtShortCuts.QInputNumber(Vlayout, 'Time between two frames (s):',
                                                          options.export_custom_time_delta, decimals=3)

        Vlayout.addStretch()

        """ Scale """
        scaleWidget = QtWidgets.QGroupBox("Scale")
        self.layout.addWidget(scaleWidget)
        Vlayout = QtWidgets.QVBoxLayout(scaleWidget)

        self.cbImageScaleSize = QtShortCuts.QInputNumber(Vlayout, 'Image scale:', options.export_image_scale,
                                                         float=True, stretch=True)
        self.cbMarkerScaleSize = QtShortCuts.QInputNumber(Vlayout, 'Marker scale:', options.export_marker_scale,
                                                          float=True, stretch=True)

        Vlayout.addStretch()

        self.cbType.setCurrentIndex(options.export_type)

        """ Progress bar """

        Hlayout = QtWidgets.QHBoxLayout()
        self.progressbar = QtWidgets.QProgressBar()
        Hlayout.addWidget(self.progressbar)
        self.button_start = QtWidgets.QPushButton("Start")
        self.button_start.pressed.connect(self.SaveImage)
        Hlayout.addWidget(self.button_start)
        self.button_stop = QtWidgets.QPushButton("Stop")
        self.button_stop.pressed.connect(self.StopSaving)
        self.button_stop.setHidden(True)
        Hlayout.addWidget(self.button_stop)
        self.layout.addLayout(Hlayout)