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

release/4.0.20 #38

Merged
merged 46 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a9ddd75
init branch
Dec 5, 2024
b46d1f4
to continue
Dec 10, 2024
80fa4cf
update tree view
Dec 10, 2024
fc2b1a2
update DropMimeData
Dec 12, 2024
5c81dad
Update file_widgets.py
Dec 17, 2024
0289e30
update files_widget.py
Dec 19, 2024
968d6ce
Update ItemWidget Visibiliy logic
Dec 19, 2024
d1352bb
clean code
Dec 20, 2024
60da9f0
Update file_widget.py
Jan 9, 2025
7b1c7d6
Add the possibility to drop file on existing item
Jan 9, 2025
24d666a
Update FilesWidget logic
Jan 15, 2025
389f941
Update FilesWidget logic
Jan 20, 2025
4c8edfc
Adjuts files_widget logic
Jan 21, 2025
48f9ddf
Collect Simple instances
Jan 21, 2025
022e52b
Can publish multiple reviews
Jan 22, 2025
3900b62
Clean code
Jan 22, 2025
202d416
Clean code
Jan 22, 2025
e685313
Add the BG application on single frame publish
hfarre Jan 22, 2025
ce5984b
Bump version to 4.0.20
BenSouchet Jan 22, 2025
98df6e5
Clean print log
hfarre Jan 22, 2025
1976201
Add allow_reviews in settings
Jan 22, 2025
e2a5bf8
Disable Review Button if not allowed
Jan 22, 2025
51fb285
clean code
Jan 22, 2025
626578e
Add an option to disable the BG in tvpaint, and create an image with …
hfarre Jan 22, 2025
23632d5
Rewrite to simplify
hfarre Jan 22, 2025
2abd604
clean code
Jan 23, 2025
c6e944a
Change to an enum option and rewrite logic
hfarre Jan 23, 2025
4f47882
Merge branch 'main' into feature/updateFilesViewLogic
BenSouchet Jan 23, 2025
39473dc
Merge branch 'feature/updateFilesViewLogic' of https://github.com/qua…
BenSouchet Jan 23, 2025
746ebe1
Fix extension layout
Jan 23, 2025
154fae5
Fix Review Visual Issue
Jan 23, 2025
f99e4ba
Adjust Color Code
Jan 23, 2025
374cdcf
set review to on by default
Jan 23, 2025
80dff54
fix lot of stuff
Jan 24, 2025
d83fa69
Use Pathlib to get extentsion
hfarre Jan 24, 2025
052bc9c
fix lot of stuff
Jan 24, 2025
35ca85d
Fix colore code
Jan 24, 2025
d2fa211
Retake on instrucctions
Jan 24, 2025
229fac1
Simplfy using self.apply_bg_back_command
hfarre Jan 24, 2025
97d08b4
Fix review detection
Jan 24, 2025
6629344
Merge pull request #25 from quadproduction/feature/updateFilesViewLogic
ccaillot Jan 24, 2025
c767eab
Remove unused variable
BenSouchet Jan 27, 2025
46758cf
Merge pull request #41 from quadproduction/enhancement/40-add-the-pos…
BenSouchet Jan 27, 2025
50454aa
Move import to the correct place
BenSouchet Jan 27, 2025
22d24bc
Merge pull request #39 from quadproduction/bugfix/37-no-bg-in-single-…
BenSouchet Jan 27, 2025
661a2b6
Improve Kitsu sync, hnadle exclusion list
BenSouchet Jan 27, 2025
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
11 changes: 2 additions & 9 deletions src/quadpype/hosts/traypublisher/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,7 @@ def get_pre_create_attr_defs(self):
allow_sequences=self.allow_sequences,
single_item=not self.allow_multiple_items,
label="Representations",
),
FileDef(
"reviewable",
folders=False,
extensions=REVIEW_EXTENSIONS,
allow_sequences=True,
single_item=True,
label="Reviewable representations",
extensions_label="Single reviewable item"
allow_reviews=self.allow_reviews
)
]

Expand All @@ -325,6 +317,7 @@ def from_settings(cls, item_data):
"detailed_description": item_data["detailed_description"],
"extensions": item_data["extensions"],
"allow_sequences": item_data["allow_sequences"],
"allow_reviews": item_data.get("allow_reviews", True),
"allow_multiple_items": item_data["allow_multiple_items"],
"allow_version_control": item_data.get(
"allow_version_control", False),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ def get_pre_create_attr_defs(self):
extensions=self.extensions,
allow_sequences=False,
label="Filepath"
),
BoolDef(
"add_review_family",
default=True,
label="Review"
)
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ def get_pre_create_attr_defs(self):
allow_sequences=True,
single_item=True,
label="Representation",
),
BoolDef(
"add_review_family",
default=True,
label="Review"
)
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,58 +172,74 @@ def _create_review_representation(
return

creator_attributes = instance.data["creator_attributes"]
review_file_item = creator_attributes["reviewable"]
filenames = review_file_item.get("filenames")
if not filenames:
representation_files = creator_attributes["representation_files"]

if isinstance(representation_files, dict):
review_items = representation_files.get("reviewable", [])
elif isinstance(representation_files, list):
review_items = []
for representation in representation_files:
review_items.extend(representation.get("reviewable", []))
else:
review_items = []

if not review_items or not isinstance(review_items, list):
self.log.debug((
"Filepath for review is not defined."
"No valid reviewable items found."
" Skipping review representation creation."
))
return

item_dir = review_file_item["directory"]
first_filepath = os.path.join(item_dir, filenames[0])

filepaths = {
os.path.join(item_dir, filename)
for filename in filenames
}
source_filepaths.extend(filepaths)
# First try to find out representation with same filepaths
# so it's not needed to create new representation just for review
review_representation = None
# Review path (only for logging)
review_path = None
for item in representation_files_mapping:
_filepaths, representation, repre_path = item
if _filepaths == filepaths:
review_representation = representation
review_path = repre_path
break

if review_representation is None:
self.log.debug("Creating new review representation")
review_path = self._calculate_source(filepaths)
review_representation = self._create_representation_data(
review_file_item, repre_names_counter, repre_names
)
instance.data["representations"].append(review_representation)

if "review" not in instance.data["families"]:
instance.data["families"].append("review")

if not instance.data.get("thumbnailSource"):
instance.data["thumbnailSource"] = first_filepath

review_representation["tags"].append("review")
for review_file_item in review_items:
filenames = review_file_item.get("filenames")
if not filenames:
self.log.debug((
"Filepath for review is not defined."
" Skipping review representation creation for item."
))
continue

# Adding "review" to representation name since it can clash with main
# representation if they share the same extension.
review_representation["outputName"] = "review"
item_dir = review_file_item["directory"]
first_filepath = os.path.join(item_dir, filenames[0])

self.log.debug("Representation {} was marked for review. {}".format(
review_representation["name"], review_path
))
filepaths = {
os.path.join(item_dir, filename)
for filename in filenames
}
source_filepaths.extend(filepaths)
# First try to find out representation with same filepaths
# so it's not needed to create new representation just for review
review_representation = None
# Review path (only for logging)
review_path = None

for item in representation_files_mapping:
_filepaths, representation, repre_path = item
if _filepaths == filepaths:
review_representation = representation
review_path = repre_path
break

if review_representation is None:
self.log.debug("Creating new review representation")
review_path = self._calculate_source(filepaths)
review_representation = self._create_representation_data(
review_file_item, repre_names_counter, repre_names
)
instance.data["representations"].append(review_representation)

if "review" not in instance.data["families"]:
instance.data["families"].append("review")

if not instance.data.get("thumbnailSource"):
instance.data["thumbnailSource"] = first_filepath

review_representation["tags"].append("review")
review_representation["outputName"] = "review"

self.log.debug("Representation {} was marked for review. {}".format(
review_representation["name"], review_path
))

def _create_representation_data(
self, filepath_item, repre_names_counter, repre_names
Expand Down
9 changes: 5 additions & 4 deletions src/quadpype/hosts/tvpaint/plugins/create/create_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,9 +1049,9 @@ def apply_settings(self, project_settings):
self.default_pass_name = plugin_settings["default_pass_name"]
self.extract_psd = plugin_settings.get("extract_psd", True)

self.apply_background = False
self.keep_frame_index = False
self.exports_types = ['scene', 'camera']
self.apply_background = ['No Operation', 'Color From Settings', 'Transparent']
self.review_types = [el.name for el in TVPaintReviewType]

# A global value to ignore transparency for the subsets exists, this option here adds the ability
Expand Down Expand Up @@ -1205,10 +1205,11 @@ def get_instance_attr_defs(self):
label="All Layers are Full Opaque",
default=self.ignore_layers_transparency
),
BoolDef(
EnumDef(
"apply_background",
label="Apply BG Color (as defined in settings)",
default=self.apply_background
self.apply_background,
label="Apply BG",
default=self.apply_background[0]
),
TextDef("export_frames_selection",
label="Frames to Export",
Expand Down
65 changes: 40 additions & 25 deletions src/quadpype/hosts/tvpaint/plugins/publish/extract_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ def process(self, instance):
# Handles are not stored per instance but on Context
handle_start = instance.context.data["handleStart"]

scene_bg_color = instance.context.data["sceneBgColor"]

# Prepare output frames
output_frame_start = frame_start - handle_start

Expand Down Expand Up @@ -148,16 +146,28 @@ def process(self, instance):

make_playblast = instance.data["creator_attributes"].get("make_playblast", False)
export_type = instance.data["creator_attributes"].get("export_type", "scene")
apply_background = instance.data["creator_attributes"].get("apply_background", True)
is_review = instance.data["family"] == "review"

# Prepare scene BG changes
apply_background = instance.data["creator_attributes"].get("apply_background", "No Operation")

self.apply_bg_command = "tv_background \"none\""
self.apply_bg_back_command = False

if apply_background != 'No Operation':
self.apply_bg_back_command = self._get_bg_rollback_command(instance.context.data["sceneBgColor"])

if apply_background == 'Color From Settings':
settings_bg_color = self._get_settings_bg_color(review=True)
self.apply_bg_command = "tv_background \"color\" {} {} {}".format(*settings_bg_color)


if is_review or make_playblast:
result = self.render_review(
output_dir,
export_type,
mark_in,
mark_out,
scene_bg_color if apply_background else None,
ignore_layers_transparency,
layers,
export_frames_without_offset,
Expand All @@ -172,7 +182,6 @@ def process(self, instance):
mark_out,
filtered_layers,
ignore_layers_transparency,
apply_background,
resolution,
export_frames_without_offset
)
Expand Down Expand Up @@ -276,7 +285,7 @@ def _rename_output_files(
return repre_filenames

def render_review(
self, output_dir, export_type, mark_in, mark_out, scene_bg_color,
self, output_dir, export_type, mark_in, mark_out,
ignore_layers_transparency, layers, export_frames_without_offset, origin_mark_in, origin_mark_out
):
""" Export images from TVPaint using `tv_savesequence` command.
Expand All @@ -285,8 +294,6 @@ def render_review(
output_dir (str): Directory where files will be stored.
mark_in (int): Starting frame index from which export will begin.
mark_out (int): On which frame index export will end.
scene_bg_color (list): Bg color set in scene. Result of george
script command `tv_background`.
ignore_layers_transparency (bool): Layer's opacity will be ignored.
layers (list): List of layers to be exported.
export_frames_without_offset (list): List of frame indexes to process, if any is given
Expand Down Expand Up @@ -337,22 +344,12 @@ def render_review(
tv_export
])

if scene_bg_color:
bg_color = self._get_settings_bg_color(review=True)

if self.apply_bg_back_command:
# Change bg color to color from settings
george_script_lines.insert(0, "tv_background \"color\" {} {} {}".format(*bg_color)),
george_script_lines.insert(0, self.apply_bg_command)

# Change bg color back to previous scene bg color
_scene_bg_color = copy.deepcopy(scene_bg_color)
bg_type = _scene_bg_color.pop(0)
orig_color_command = [
"tv_background",
"\"{}\"".format(bg_type)
]
orig_color_command.extend(_scene_bg_color)

george_script_lines.append(" ".join(orig_color_command))
george_script_lines.append(self.apply_bg_back_command)

# Put back the origin opacity on each layer
if ignore_layers_transparency:
Expand Down Expand Up @@ -428,7 +425,7 @@ def render_review(
return output_filepaths_by_frame_index, thumbnail_filepath

def render(
self, output_dir, mark_in, mark_out, layers, ignore_layers_transparency, apply_background, resolution, export_frames
self, output_dir, mark_in, mark_out, layers, ignore_layers_transparency, resolution, export_frames
):
""" Export images from TVPaint.

Expand All @@ -438,7 +435,6 @@ def render(
mark_out (int): On which frame index export will end.
layers (list): List of layers to be exported.
ignore_layers_transparency (bool): Layer's opacity will be ignored.
apply_background (bool): Apply a bg color to the render set in settings of OP.
resolution (tuple): Resolution of the tvpaint project (Width, Height).
export_frames (list)

Expand Down Expand Up @@ -499,8 +495,8 @@ def render(
# filter the layers to compose to remove those who didn't have a render
filtered_layers = [layer for layer in layers if layer['layer_id'] in output_used_layers_id]

# Prepare bg image if apply_background enabled
if apply_background:
# Prepare bg image if apply_bg_back_command
if self.apply_bg_back_command:
# Create and add to Layers
bg_layer = {}
layer_positions = []
Expand Down Expand Up @@ -736,3 +732,22 @@ def _convert_opacity_range(value):
Int: New value between 0-255
"""
return max(0, min(int(round(value * 2.55)), 255))

@staticmethod
def _get_bg_rollback_command(scene_bg_color):
"""Will produce a tvpaint command that correspond to the current BG mode in opened scene
Args:
scene_bg_color (list): Information from current BG settings.

Returns:
str: A george script command to apply current BG settings.
"""
_scene_bg_color = copy.deepcopy(scene_bg_color)
bg_type = _scene_bg_color.pop(0)

if bg_type == "check":
return "tv_background \"{}\" {} {} {} {} {} {} ".format(bg_type, *_scene_bg_color)
elif bg_type == "color" and _scene_bg_color:
return "tv_background \"{}\" {} {} {}".format(bg_type, *_scene_bg_color)
else:
return "tv_background \"{}\"".format(bg_type)
Loading