def __interpolate_btn_event(self): 
     #store a temporary path for interpolation visualization
     if len(self._sel_pts) >= 2:
         mode = None if self._interpolation_mode.value=='Auto' else self._interpolation_mode.value        #store a temporary path for interpolation visualization
         self.interpolate_range( self._sel_pts[0], self._sel_pts[-1], interpolation_mode=mode)
         self.mainwindow._player.refresh()
     else:
         QMessageBox.about(self, "Error", "You need to select 2 frames.")
	def __derivate_data(self):
		for i in range(1, len(self)):
			a = self[i-1]
			b = self[i]
			if a is not None and b is not None:
				self._values[i-1] = b-a
			else:
				self._values[i-1] = 0
		QMessageBox.about(self, "Info", "Operation complete.")
Пример #3
0
 def cleanLine(self, track_index=None):
     if track_index is not None or self._selected is not None:
         track_index = track_index if track_index is not None else self._selected.track
         if len(self._tracks) > track_index:
             self._tracks[track_index].clear()
         self._selected = None
         self.repaint()
     else:
         QMessageBox.about(self, "Error", "You must select a timebar first")
         return
 def __del_path_btn_event(self): #store a temporary path for interpolation visualization
     if len(self._sel_pts) == 2:
         reply = QMessageBox.question(self, 'Confirmation',
                                            "Are you sure you want to delete this path?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
         if reply == QMessageBox.Yes: #store a temporary path for interpolation visualization
             start, end = self._sel_pts[0], self._sel_pts[1]
             self.delete_range(start, end)
             self.calculate_tmp_interpolation()
             self.mainwindow._player.refresh()
     else:
         QMessageBox.about(self, "Error", "You need to select 2 frames.")
    def __apply_btn_event(self):

        if self._apply.checked:

            if len(self._properties) == 0:
                QMessageBox.about(
                    self, "Error",
                    "You need to select at least one value to export.")
                self._apply.checked = False
                return

            if self._outfile.value is None or len(
                    self._outfile.value.strip()) == 0:
                QMessageBox.about(
                    self, "Error",
                    "You need to select the name of the output file.")
                self._apply.checked = False
                return

            if self._outdir.value is None or len(self._outdir.value) == 0:
                QMessageBox.about(
                    self, "Error",
                    "You need to select the name of the output directory.")
                self._apply.checked = False
                return

            self.__update_outfile_name_event()

            self._export_list.enabled = False
            self._tree.enabled = False
            self._add.enabled = False
            self._remove.enabled = False
            self._outdir.enabled = False
            self._outfile.enabled = False
            self._apply.label = 'Cancel'

            ### calculate the video cuts #############################
            timeline = self.parent().timeline

            selected_events = self._splitevents.value
            videocuts = []
            if len(selected_events):
                # use the events to cut the video
                totalframes = 0
                for row in timeline.rows:
                    for event in row.events:
                        if event.title not in selected_events: continue
                        b = event.begin
                        e = event.end
                        totalframes += e - b
                        videocuts.append((int(b), int(e), event.title))
                videocuts = sorted(videocuts, key=lambda x: x[0])
            else:
                # no events were selected
                end = max([size for size, func in self._properties])
                totalframes = end
                videocuts = [(0, int(end), None)]
            ##########################################################

            self._progress.min = 0
            self._progress.max = totalframes
            self._progress.show()

            for b, e, eventname in videocuts:

                filename = self._outfile.value
                filename = filename.format(event=eventname, start=b, end=e)
                filename = os.path.join(self._outdir.value, filename)

                with open(filename, 'w') as out:

                    ## write the csv columns headers
                    out.write('frame;')
                    for values in self._export_list.value:
                        out.write(('{0};'.format(values[0])))
                    out.write('\n')

                    ## write the values
                    for index in range(b, e):
                        out.write('{0};'.format(index))
                        for _, func in self._properties:
                            out.write('{0};'.format(func(index)))
                        out.write('\n')
                        self._progress += 1

            self._export_list.enabled = True
            self._tree.enabled = True
            self._add.enabled = True
            self._remove.enabled = True
            self._outdir.enabled = True
            self._outfile.enabled = True
            self._apply.label = 'Apply'
            self._apply.checked = False
            self._progress.hide()