Class providing funcionality to a Control panel inside the TaskView. More...
Public Member Functions | |
def | __init__ (self, control_proxy, form) |
Initialization method for ControlPanel. More... | |
def | playClicked (self) |
Feedback method called when play button was clicked. More... | |
def | pauseClicked (self) |
Feedback method called when pause button was clicked. More... | |
def | rewindClicked (self) |
Feedback method called when rewind button was clicked. More... | |
def | recordClicked (self) |
Feedback method called when record button was clicked. More... | |
def | exportClicked (self) |
Feedback method called when export button was clicked. More... | |
def | sliderChanged (self) |
Feedback method called when slider position is changed. More... | |
def | setInvalidButtons (self) |
Method to enable/disable buttons according to a last clicked button. More... | |
def | reject (self) |
Feedback method called when Control panel is closing. More... | |
def | getStandardButtons (self, *args) |
Method to set just one button (close) to close the dialog. More... | |
def | isAllowedAlterSelection (self) |
Method to tell FreeCAD if dialog is allowed to alter a selection. More... | |
def | isAllowedAlterView (self) |
Method to tell FreeCAD if dialog is allowed to alter a view. More... | |
def | isAllowedAlterDocument (self) |
Method to tell FreeCAD if dialog is allowed to alter a document. More... | |
def | play (self, t) |
Method to show an animation frame at an animation time t during playing. More... | |
def | rewind (self, t) |
Method to show an animation frame at an animation time t during rewind. More... | |
def | record (self, t) |
Method to show and save an animation frame at an animation time t . More... | |
def | distributeTime (self, t) |
Method to distribute a time t to children Trajectories. More... | |
def | updateCollisions (self) |
Method to update collisions from CollisionDetector children. More... | |
def | resetCollisions (self) |
Method to reset collisions from CollisionDetector children. More... | |
def | showChanges (self) |
Method to show changes made to objects, collisions. More... | |
def | saveImage (self) |
Method to save current view as a PNG image. More... | |
def | findSequences (self, files) |
Method to find sequences between files. More... | |
def | showSequences (self, sequences) |
Method to show sequences to export on a dialog panel. More... | |
def | exportConfirmed (self) |
Feedback method called when confirm button was clicked. More... | |
def | exportAborted (self) |
Feedback method called when abort button was clicked. More... | |
def | closeExportSubform (self) |
Method used to close the part of the dialog panel used for video exporting. More... | |
def | installPyPNGNotice (self) |
Method telling user that pyPNG library ought to be installed into FreeCAD. More... | |
def | writeFramerateChunk (self, framerate, image_path) |
Method to write a framerate into a PNG image as one of its chunks. More... | |
def | readFramerateChunk (self, image_path) |
Method to read a framerate inserted as one of a PNG image's chunks. More... | |
Public Attributes | |
control_proxy | |
A proxy to an associated Control class. More... | |
form | |
A QDialog instance show in the TaskView. More... | |
timer | |
A QTimer for timing animations. More... | |
last_clicked | |
A str showing which button was pressed last. More... | |
record_prefix | |
A str prefix for an image file name. More... | |
image_number | |
An int number of a next recorded image. More... | |
trv_sequences | |
A QTreeView showing list of recorded sequences. More... | |
lyt_export | |
A QHBoxLayout with a confirm and abort buttons. More... | |
btn_confirm | |
A QPushButton to confirm sequence to export. More... | |
btn_abort | |
A QPushButton to abort exporting a sequence. More... | |
Class providing funcionality to a Control panel inside the TaskView.
This class enables user to play, pause, rewind, record, export and seek through an animation.
To create an instance of this class do:
Definition at line 83 of file Control.py.
def Control.ControlPanel.__init__ | ( | self, | |
control_proxy, | |||
form | |||
) |
Initialization method for ControlPanel.
A class instance is created. A proxy for an associated Control
is added and the control properties are set to read-only as not to change when control panel is opened. A form and timer are assigned. Pause
button is disabled as no animation is playing.
control_proxy | A proxy to a Control so properties can be set read-only. |
form | A Qt dialog loaded from a file. |
Definition at line 127 of file Control.py.
def Control.ControlPanel.closeExportSubform | ( | self | ) |
Method used to close the part of the dialog panel used for video exporting.
The QTreeView with sequence names and their numbers of frames are closed. Then ‘'Confirm’and
'Abort'` buttons are removed and the rest of buttons is returned to the default state (the same as if pause button was pressed).
Definition at line 912 of file Control.py.
def Control.ControlPanel.distributeTime | ( | self, | |
t | |||
) |
Method to distribute a time t
to children Trajectories.
List of children is loaded. If a child is Trajectory
, the time is set to it and its children are added to the list.
t | A time to distribute to all child Trajectories . |
Definition at line 575 of file Control.py.
def Control.ControlPanel.exportAborted | ( | self | ) |
Feedback method called when abort button was clicked.
The part of the dialog panel used for video exporting is closed.
Definition at line 901 of file Control.py.
def Control.ControlPanel.exportClicked | ( | self | ) |
Feedback method called when export button was clicked.
Invalid buttons are disabled. An Export Path
is checked for files. The files are checked for sequences. Sequences are shown with buttons to confirm or cancel the selection.
Definition at line 277 of file Control.py.
def Control.ControlPanel.exportConfirmed | ( | self | ) |
Feedback method called when confirm button was clicked.
Buttons are disabled, framerate is loaded from the first image chunks, selected sequence name is used to create an image name
template and a video name
which can be used in a FFMPEG command. Such a command is executed to convert the video, if FFMPEG is installed. Otherwise warnings are shown.
Definition at line 841 of file Control.py.
def Control.ControlPanel.findSequences | ( | self, | |
files | |||
) |
Method to find sequences between files.
Files are scanned for sequences, the valid sequences are recognized and number of frames is counted.
files | A list of string file names. |
Definition at line 677 of file Control.py.
def Control.ControlPanel.getStandardButtons | ( | self, | |
* | args | ||
) |
Method to set just one button (close) to close the dialog.
*args: A tuple of unused arguments from Qt.
Definition at line 381 of file Control.py.
def Control.ControlPanel.installPyPNGNotice | ( | self | ) |
Method telling user that pyPNG library ought to be installed into FreeCAD.
The pyPNG library is not part of FreeCAD and so we need to add it using pip. This method tells user to do so.
Definition at line 930 of file Control.py.
def Control.ControlPanel.isAllowedAlterDocument | ( | self | ) |
Method to tell FreeCAD if dialog is allowed to alter a document.
Definition at line 408 of file Control.py.
def Control.ControlPanel.isAllowedAlterSelection | ( | self | ) |
Method to tell FreeCAD if dialog is allowed to alter a selection.
Definition at line 390 of file Control.py.
def Control.ControlPanel.isAllowedAlterView | ( | self | ) |
Method to tell FreeCAD if dialog is allowed to alter a view.
Definition at line 399 of file Control.py.
def Control.ControlPanel.pauseClicked | ( | self | ) |
Feedback method called when pause button was clicked.
Invalid buttons are disabled in this method and that's it.
Definition at line 189 of file Control.py.
def Control.ControlPanel.play | ( | self, | |
t | |||
) |
Method to show an animation frame at an animation time t
during playing.
Current clock time is loaded. If the pause button was clicked, an animation is stopped. Otherwise the animation time t
is distributed to appropriate children. If the animation time t
exceeded Stop Time
, the animation is stopped. Lastly next frame time is computed as well as pause time (to stick with real time if computation did not exceeded Step Time
). Finally the timer is set to show the next animation frame after precomputed pause.
t | An animation time to generate an animation frame at. |
Definition at line 425 of file Control.py.
def Control.ControlPanel.playClicked | ( | self | ) |
Feedback method called when play button was clicked.
Invalid buttons are disabled. Active View's animation is disabled (Necessary). Slider position is checked for invalid position (at the end) and if position is plausible, all collisions are reset, current time is extrapolated from the slider and an animation is played.
Definition at line 162 of file Control.py.
def Control.ControlPanel.readFramerateChunk | ( | self, | |
image_path | |||
) |
Method to read a framerate inserted as one of a PNG image's chunks.
This method tries to import pyPNG first. Then it tries to install it and import again. If either import is successful, all chunks currently in the PNG image at an image_path
are extracted. The framerate chunk ought to be stored as the second chunk, right behind IHDR. If the chunk's code type matches, its value is returned.
image_path | A str containing a path to an image with the framerate chunk. |
Definition at line 1014 of file Control.py.
def Control.ControlPanel.record | ( | self, | |
t | |||
) |
Method to show and save an animation frame at an animation time t
.
Current clock time is loaded. If the pause button was clicked, an animation is stopped. Otherwise the animation time t
is distributed to appropriate children. If the animation time t
exceeded Stop Time
, the animation is stopped. Lastly next frame time is computed. Finally the timer is set to show the next animation frame after precomputed pause.
t | An animation time to generate an animation frame at. |
Definition at line 532 of file Control.py.
def Control.ControlPanel.recordClicked | ( | self | ) |
Feedback method called when record button was clicked.
Invalid buttons are disabled. A record prefix is generated. An Image number is set to 0. Active View's animation is disabled (Necessary). Slider position is checked for invalid position (at the end) and if position is plausible, all collisions are reset, current time is extrapolated from the slider and an animation is played/recorded.
Definition at line 233 of file Control.py.
def Control.ControlPanel.reject | ( | self | ) |
Feedback method called when Control panel is closing.
Animation is stopped. Controls properties are set to be editable. Dialog is closed.
Definition at line 360 of file Control.py.
def Control.ControlPanel.resetCollisions | ( | self | ) |
Method to reset collisions from CollisionDetector children.
List of children is loaded. If a child is CollisionDetector
, it's reset.
Definition at line 612 of file Control.py.
def Control.ControlPanel.rewind | ( | self, | |
t | |||
) |
Method to show an animation frame at an animation time t
during rewind.
Current clock time is loaded. If the pause button was clicked, an animation is stopped. Otherwise the animation time t
is distributed to appropriate children. If the animation time t
exceeded Stop Time
, the animation is stopped. Lastly next frame time is computed as well as pause time (to stick with real time if computation did not exceeded Step Time
). Finally the timer is set to show the next animation frame after precomputed pause.
t | An animation time to generate an animation frame at. |
Definition at line 479 of file Control.py.
def Control.ControlPanel.rewindClicked | ( | self | ) |
Feedback method called when rewind button was clicked.
Invalid buttons are disabled. Active View's animation is disabled (Necessary). Slider position is checked for invalid position (at the end) and if position is plausible, all collisions are reset, current time is extrapolated from the slider and an animation is played.
Definition at line 202 of file Control.py.
def Control.ControlPanel.saveImage | ( | self | ) |
Method to save current view as a PNG image.
An image name is pieced together from record prefix
and image number
. Then an image path is constructed. Animation is disabled(obligatory) and current view is saved as an image. Afterwards, if saving the first image(image number 0), a chunk with a framerate corresponding to a step size is added. Finally the image number is incremented.
Definition at line 641 of file Control.py.
def Control.ControlPanel.setInvalidButtons | ( | self | ) |
Method to enable/disable buttons according to a last clicked
button.
If pause
button was pressed, all others buttons are disabled. If any other button was pressed, only pause
button is left enabled.
Definition at line 337 of file Control.py.
def Control.ControlPanel.showChanges | ( | self | ) |
Method to show changes made to objects, collisions.
This method is necessary to call after distributeTime
, updateCollisions
and resetCollisions
.
Definition at line 628 of file Control.py.
def Control.ControlPanel.showSequences | ( | self, | |
sequences | |||
) |
Method to show sequences to export on a dialog panel.
Sequences and frame numbers are shown in a QTreeView, and buttons ‘'Confirm’ and
'Abort'` are attached under it. All of this is put under the Export button on the dialog panel.
sequences | A dict with sequence names and numbers of frames. |
Definition at line 721 of file Control.py.
def Control.ControlPanel.sliderChanged | ( | self | ) |
Feedback method called when slider position is changed.
If slider is enabled (not used to show animation time) and slider position is changed, time is extrapolated from slider position and animation in that time is shown.
Definition at line 318 of file Control.py.
def Control.ControlPanel.updateCollisions | ( | self | ) |
Method to update collisions from CollisionDetector children.
List of children is loaded. If a child is CollisionDetector
, it's touched so that it's recomputed.
Definition at line 597 of file Control.py.
def Control.ControlPanel.writeFramerateChunk | ( | self, | |
framerate, | |||
image_path | |||
) |
Method to write a framerate into a PNG image as one of its chunks.
This method tries to import pyPNG first. Then it tries to install it and import again. If either import is successful, all chunks currently in the PNG image at an image_path
are extracted. The framerate chunk is added as the second chunk, right behind IHDR. Finally the image is rewritten with new list of chunks.
framerate | A float specifying the framerate to be written into the image. |
image_path | A str containing a path to an image about to be augmented. |
Definition at line 976 of file Control.py.
Control.ControlPanel.btn_abort |
A QPushButton to abort exporting a sequence.
Definition at line 797 of file Control.py.
Control.ControlPanel.btn_confirm |
A QPushButton to confirm sequence to export.
Definition at line 778 of file Control.py.
Control.ControlPanel.control_proxy |
A proxy to an associated Control
class.
Definition at line 129 of file Control.py.
Control.ControlPanel.form |
A QDialog instance show in the TaskView.
Definition at line 136 of file Control.py.
Control.ControlPanel.image_number |
An int number of a next recorded image.
Definition at line 241 of file Control.py.
Control.ControlPanel.last_clicked |
A str showing which button was pressed last.
Definition at line 151 of file Control.py.
Control.ControlPanel.lyt_export |
A QHBoxLayout with a confirm
and abort
buttons.
Definition at line 773 of file Control.py.
Control.ControlPanel.record_prefix |
A str prefix for an image file name.
Definition at line 239 of file Control.py.
Control.ControlPanel.timer |
A QTimer for timing animations.
Definition at line 147 of file Control.py.
Control.ControlPanel.trv_sequences |
A QTreeView showing list of recorded sequences.
Definition at line 726 of file Control.py.