Skip to content

Commit

Permalink
Merge pull request #25 from aardschok/0020
Browse files Browse the repository at this point in the history
Major Fix from branches [0008, 0014, 0018, 0019, 0020]
  • Loading branch information
BigRoy authored May 3, 2017
2 parents f1309e9 + bbc6c43 commit 9ee00f3
Show file tree
Hide file tree
Showing 9 changed files with 252 additions and 15 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ capture_gui.main()

### Advanced

#### Callbacks
Register a pre-view callback to allow a custom conversion or overlays on the
resulting footage in your pipeline (e.g. through FFMPEG)

Expand Down Expand Up @@ -71,6 +72,22 @@ app.viewer_start.connect(callback, QtCore.Qt.DirectConnection)
app.show()
```

#### Register preset paths

Register a preset path that will be used by the capture gui to load default presets from.

```python
import capture_gui.presets
import capture_gui

path = "path/to/directory"
capture_gui.presets.register_path(path)

# After registering capture gui will automatically load
# the presets found in all registered preset paths
capture_gui.main()
```


### Known issues

Expand Down
19 changes: 19 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Maya Capture GUI RELEASES

## 03 / 05 / 2017 - v1.3.0
- Changed mode name in Time Plugin, old presets incompatible with current version
- Removed unused keyword argument

## 03 / 05 / 2017 - v1.2.0
- Extended README with example of adding presets before launching the
tool
- Solved issue 0008
+ Playback of images, frame padding ( #### ) solved
+ View when finished works regardless of Save being checked
- Solved issue 0019
+ Non-chronological time range is not possible anymore
- Solved issue 0020
+ Added custom frame range, similar to print pages in Word

## 02 / 05 / 2017 - v1.1.0
- Solved issue 0014
- Added plugin validation function
- Added app validation function to validate listed plugins

## 24 / 04 / 2017 - v1.0.2
Fixed issue with storing presets and recent playblasts
Expand Down
39 changes: 38 additions & 1 deletion capture_gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ class PreviewWidget(QtWidgets.QWidget):
preview_width = 320
preview_height = 180

def __init__(self, options_getter, parent=None):
def __init__(self, options_getter, validator, parent=None):
QtWidgets.QWidget.__init__(self, parent=parent)

# Add attributes
self.initialized = False
self.options_getter = options_getter
self.validator = validator
self.preview = ClickLabel()
self.preview.setFixedWidth(self.preview_width)
self.preview.setFixedHeight(self.preview_height)
Expand All @@ -69,6 +70,11 @@ def refresh(self):
# time into the undo queue to enforce correct undoing.
cmds.currentTime(frame, update=True)

# check if plugin outputs are correct
valid = self.validator()
if not valid:
return

with lib.no_undo():
options = self.options_getter()

Expand Down Expand Up @@ -333,6 +339,7 @@ def __init__(self, title, parent=None):
# Add separate widgets
self.widgetlibrary.addItem("Preview",
PreviewWidget(self.get_outputs,
self.validate,
parent=self),
collapsed=True)

Expand Down Expand Up @@ -362,7 +369,13 @@ def __init__(self, title, parent=None):
def apply(self):
"""Run capture action with current settings"""

valid = self.validate()
if not valid:
return

options = self.get_outputs()
if options["frame"] is not None:
options["raw_frame_numbers"] = True
filename = options.get("filename", None)

self.playblast_start.emit(options)
Expand Down Expand Up @@ -412,6 +425,7 @@ def add_plugin(self, plugin):
return

widget = plugin(parent=self)
widget.initialize()
widget.options_changed.connect(self.on_widget_settings_changed)
self.playblast_finished.connect(widget.on_playblast_finished)

Expand All @@ -433,6 +447,29 @@ def add_plugin(self, plugin):
group_layout.addWidget(widget)
layout.addWidget(group_widget)

def validate(self):
"""
Check if the outputs of the widgets are good
:return:
"""

errors = list()
for widget in self._get_plugin_widgets():
widget_errors = widget.validate()
if widget_errors:
errors.extend(widget_errors)

if errors:
message_title = "%s Validation Error(s)" % len(errors)
message = "\n".join(errors)
QtWidgets.QMessageBox.critical(self,
message_title,
message,
QtWidgets.QMessageBox.Ok)
return False

return True

def get_outputs(self):
"""Return the settings for a capture as currently set in the
Application.
Expand Down
13 changes: 12 additions & 1 deletion capture_gui/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,18 @@ def _fix_playblast_output_path(filepath):
# Fix: playblast not returning correct filename (with extension)
# Lets assume the most recently modified file is the correct one.
if not os.path.exists(filepath):
files = glob.glob("{}.*".format(filepath))
directory = os.path.dirname(filepath)
filename = os.path.basename(filepath)
# check if the filepath is has frame based filename
# example : capture.####.png
parts = filename.split(".")
if len(parts) == 3:
query = os.path.join(directory, "{}.*.{}".format(parts[0],
parts[-1]))
files = glob.glob(query)
else:
files = glob.glob("{}.*".format(filepath))

if not files:
raise RuntimeError("Couldn't find playblast from: "
"{0}".format(filepath))
Expand Down
11 changes: 11 additions & 0 deletions capture_gui/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,21 @@ class Plugin(QtWidgets.QWidget):
options_changed = QtCore.Signal()
label_changed = QtCore.Signal(str)
order = 0
highlight = "border: 1px solid red;"
validate_state = True

def on_playblast_finished(self, options):
pass

def validate(self):
"""
Ensure outputs of the widget are possible, when errors are raised it
will return a message with what has caused the error
:return:
"""
errors = []
return errors

def get_outputs(self):
"""Return the options as set in this plug-in widget.
Expand Down
14 changes: 14 additions & 0 deletions capture_gui/plugins/cameraplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self, parent=None):

self.cameras.currentIndexChanged.connect(self.options_changed)
self.options_changed.connect(self.on_update_label)
self.options_changed.connect(self.validate)

# Force update of the label
self.set_active_cam()
Expand All @@ -64,6 +65,19 @@ def select_camera(self, cam):
self.cameras.setCurrentIndex(i)
return

def validate(self):

errors = []
camera = self.cameras.currentText()
if not cmds.objExists(camera):
errors.append("{} : Selected camera '{}' "
"does not exist!".format(self.id, camera))
self.cameras.setStyleSheet(self.highlight)
else:
self.cameras.setStyleSheet("")

return errors

def get_outputs(self):
"""Return currently selected camera from combobox."""

Expand Down
7 changes: 4 additions & 3 deletions capture_gui/plugins/ioplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,14 @@ def get_outputs(self):
:rtype: dict
"""

output = {"filename": None}
output = {"filename": None,
"viewer": self.open_viewer.isChecked()}

use_default = self.use_default.isChecked()
save = self.save_file.isChecked()
# run playblast, don't copy to dir
if not save:
return
return output

# run playblast, copy file to given directory
# get directory from inputs
Expand All @@ -198,7 +200,6 @@ def get_outputs(self):
path = lib.default_output()

output["filename"] = path
output["viewer"] = self.open_viewer.isChecked()

return output

Expand Down
Loading

0 comments on commit 9ee00f3

Please sign in to comment.