Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major Fix from branches [0008, 0014, 0018, 0019, 0020] #25

Merged
merged 14 commits into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 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,25 @@ app.viewer_start.connect(callback, QtCore.Qt.DirectConnection)
app.show()
```

#### Register presets

```python
import capture_gui.presets as presets

# create a list of directories where the presets might be stored
# Not the files! Always the directory
directories = ["root/directory/folder",
"root/directory/other_folder"]

# register the directories to check in the presets.discover function
for directory in directories:
presets.registers_path(directory)

# launch the capture gui with the registered paths
import capture_gui
capture_gui.main()
```


### Known issues

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


## 03 / 05 / 2017 - v1.1.1
- 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

## 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
Fixed issue with changing presets in selection box
Expand Down
38 changes: 37 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 @@ -433,6 +446,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