Collection Manager: Refactor and cleanup. Task: T69577
Change how addon wide variables are imported.
This commit is contained in:
parent
5614916cf6
commit
5a1e3d5023
Notes:
blender-bot
2023-02-14 18:06:58 +01:00
Referenced by commit 1bab44a7: Collection Manager: Fix regression. Task: T69577
Referenced by commit 1bab44a7
, Collection Manager: Fix regression. Task: T69577
|
@ -106,10 +106,6 @@ swap_buffer = {
|
|||
}
|
||||
|
||||
|
||||
def get_max_lvl():
|
||||
return max_lvl
|
||||
|
||||
|
||||
class QCDSlots():
|
||||
_slots = {}
|
||||
overrides = set()
|
||||
|
|
|
@ -19,14 +19,11 @@
|
|||
# Copyright 2011, Ryan Inch
|
||||
import bpy
|
||||
|
||||
# For VARS
|
||||
from . import internals
|
||||
|
||||
# For FUNCTIONS
|
||||
from .internals import (
|
||||
layer_collections,
|
||||
qcd_slots,
|
||||
expanded,
|
||||
expand_history,
|
||||
rto_history,
|
||||
copy_buffer,
|
||||
swap_buffer,
|
||||
update_property_group,
|
||||
get_move_selection,
|
||||
)
|
||||
|
@ -157,22 +154,22 @@ def isolate_rto(cls, self, view_layer, rto, *, children=False):
|
|||
off = set_off_on[rto]["off"]
|
||||
on = set_off_on[rto]["on"]
|
||||
|
||||
laycol_ptr = layer_collections[self.name]["ptr"]
|
||||
target = rto_history[rto][view_layer]["target"]
|
||||
history = rto_history[rto][view_layer]["history"]
|
||||
laycol_ptr = internals.layer_collections[self.name]["ptr"]
|
||||
target = internals.rto_history[rto][view_layer]["target"]
|
||||
history = internals.rto_history[rto][view_layer]["history"]
|
||||
|
||||
# get active collections
|
||||
active_layer_collections = [x["ptr"] for x in layer_collections.values()
|
||||
active_layer_collections = [x["ptr"] for x in internals.layer_collections.values()
|
||||
if get_rto(x["ptr"], rto) == on]
|
||||
|
||||
# check if previous state should be restored
|
||||
if cls.isolated and self.name == target:
|
||||
# restore previous state
|
||||
for x, item in enumerate(layer_collections.values()):
|
||||
for x, item in enumerate(internals.layer_collections.values()):
|
||||
set_rto(item["ptr"], rto, history[x])
|
||||
|
||||
# reset target and history
|
||||
del rto_history[rto][view_layer]
|
||||
del internals.rto_history[rto][view_layer]
|
||||
|
||||
cls.isolated = False
|
||||
|
||||
|
@ -180,24 +177,24 @@ def isolate_rto(cls, self, view_layer, rto, *, children=False):
|
|||
elif (len(active_layer_collections) == 1 and
|
||||
active_layer_collections[0].name == self.name):
|
||||
# activate all collections
|
||||
for item in layer_collections.values():
|
||||
for item in internals.layer_collections.values():
|
||||
set_rto(item["ptr"], rto, on)
|
||||
|
||||
# reset target and history
|
||||
del rto_history[rto][view_layer]
|
||||
del internals.rto_history[rto][view_layer]
|
||||
|
||||
cls.isolated = False
|
||||
|
||||
else:
|
||||
# isolate collection
|
||||
|
||||
rto_history[rto][view_layer]["target"] = self.name
|
||||
internals.rto_history[rto][view_layer]["target"] = self.name
|
||||
|
||||
# reset history
|
||||
history.clear()
|
||||
|
||||
# save state
|
||||
for item in layer_collections.values():
|
||||
for item in internals.layer_collections.values():
|
||||
history.append(get_rto(item["ptr"], rto))
|
||||
|
||||
child_states = {}
|
||||
|
@ -209,7 +206,7 @@ def isolate_rto(cls, self, view_layer, rto, *, children=False):
|
|||
apply_to_children(laycol_ptr, get_child_states)
|
||||
|
||||
# isolate collection
|
||||
for item in layer_collections.values():
|
||||
for item in internals.layer_collections.values():
|
||||
if item["name"] != laycol_ptr.name:
|
||||
set_rto(item["ptr"], rto, off)
|
||||
|
||||
|
@ -217,7 +214,7 @@ def isolate_rto(cls, self, view_layer, rto, *, children=False):
|
|||
|
||||
if rto not in ["exclude", "holdout", "indirect"]:
|
||||
# activate all parents
|
||||
laycol = layer_collections[self.name]
|
||||
laycol = internals.layer_collections[self.name]
|
||||
while laycol["id"] != 0:
|
||||
set_rto(laycol["ptr"], rto, on)
|
||||
laycol = laycol["parent"]
|
||||
|
@ -248,10 +245,10 @@ def isolate_rto(cls, self, view_layer, rto, *, children=False):
|
|||
|
||||
|
||||
def toggle_children(self, view_layer, rto):
|
||||
laycol_ptr = layer_collections[self.name]["ptr"]
|
||||
laycol_ptr = internals.layer_collections[self.name]["ptr"]
|
||||
# clear rto history
|
||||
del rto_history[rto][view_layer]
|
||||
rto_history[rto+"_all"].pop(view_layer, None)
|
||||
del internals.rto_history[rto][view_layer]
|
||||
internals.rto_history[rto+"_all"].pop(view_layer, None)
|
||||
|
||||
# toggle rto state
|
||||
state = not get_rto(laycol_ptr, rto)
|
||||
|
@ -267,13 +264,13 @@ def activate_all_rtos(view_layer, rto):
|
|||
off = set_off_on[rto]["off"]
|
||||
on = set_off_on[rto]["on"]
|
||||
|
||||
history = rto_history[rto+"_all"][view_layer]
|
||||
history = internals.rto_history[rto+"_all"][view_layer]
|
||||
|
||||
# if not activated, activate all
|
||||
if len(history) == 0:
|
||||
keep_history = False
|
||||
|
||||
for item in reversed(list(layer_collections.values())):
|
||||
for item in reversed(list(internals.layer_collections.values())):
|
||||
if get_rto(item["ptr"], rto) == off:
|
||||
keep_history = True
|
||||
|
||||
|
@ -287,37 +284,37 @@ def activate_all_rtos(view_layer, rto):
|
|||
history.reverse()
|
||||
|
||||
else:
|
||||
for x, item in enumerate(layer_collections.values()):
|
||||
for x, item in enumerate(internals.layer_collections.values()):
|
||||
set_rto(item["ptr"], rto, history[x])
|
||||
|
||||
# clear rto history
|
||||
del rto_history[rto+"_all"][view_layer]
|
||||
del internals.rto_history[rto+"_all"][view_layer]
|
||||
|
||||
|
||||
def invert_rtos(view_layer, rto):
|
||||
if rto == "exclude":
|
||||
orig_values = []
|
||||
|
||||
for item in layer_collections.values():
|
||||
for item in internals.layer_collections.values():
|
||||
orig_values.append(get_rto(item["ptr"], rto))
|
||||
|
||||
for x, item in enumerate(layer_collections.values()):
|
||||
for x, item in enumerate(internals.layer_collections.values()):
|
||||
set_rto(item["ptr"], rto, not orig_values[x])
|
||||
|
||||
else:
|
||||
for item in layer_collections.values():
|
||||
for item in internals.layer_collections.values():
|
||||
set_rto(item["ptr"], rto, not get_rto(item["ptr"], rto))
|
||||
|
||||
# clear rto history
|
||||
rto_history[rto].pop(view_layer, None)
|
||||
internals.rto_history[rto].pop(view_layer, None)
|
||||
|
||||
|
||||
def copy_rtos(view_layer, rto):
|
||||
if not copy_buffer["RTO"]:
|
||||
if not internals.copy_buffer["RTO"]:
|
||||
# copy
|
||||
copy_buffer["RTO"] = rto
|
||||
for laycol in layer_collections.values():
|
||||
copy_buffer["values"].append(get_off_on[
|
||||
internals.copy_buffer["RTO"] = rto
|
||||
for laycol in internals.layer_collections.values():
|
||||
internals.copy_buffer["values"].append(get_off_on[
|
||||
get_rto(laycol["ptr"], rto)
|
||||
][
|
||||
rto
|
||||
|
@ -326,29 +323,29 @@ def copy_rtos(view_layer, rto):
|
|||
|
||||
else:
|
||||
# paste
|
||||
for x, laycol in enumerate(layer_collections.values()):
|
||||
for x, laycol in enumerate(internals.layer_collections.values()):
|
||||
set_rto(laycol["ptr"],
|
||||
rto,
|
||||
set_off_on[rto][
|
||||
copy_buffer["values"][x]
|
||||
internals.copy_buffer["values"][x]
|
||||
]
|
||||
)
|
||||
|
||||
# clear rto history
|
||||
rto_history[rto].pop(view_layer, None)
|
||||
del rto_history[rto+"_all"][view_layer]
|
||||
internals.rto_history[rto].pop(view_layer, None)
|
||||
del internals.rto_history[rto+"_all"][view_layer]
|
||||
|
||||
# clear copy buffer
|
||||
copy_buffer["RTO"] = ""
|
||||
copy_buffer["values"].clear()
|
||||
internals.copy_buffer["RTO"] = ""
|
||||
internals.copy_buffer["values"].clear()
|
||||
|
||||
|
||||
def swap_rtos(view_layer, rto):
|
||||
if not swap_buffer["A"]["values"]:
|
||||
if not internals.swap_buffer["A"]["values"]:
|
||||
# get A
|
||||
swap_buffer["A"]["RTO"] = rto
|
||||
for laycol in layer_collections.values():
|
||||
swap_buffer["A"]["values"].append(get_off_on[
|
||||
internals.swap_buffer["A"]["RTO"] = rto
|
||||
for laycol in internals.layer_collections.values():
|
||||
internals.swap_buffer["A"]["values"].append(get_off_on[
|
||||
get_rto(laycol["ptr"], rto)
|
||||
][
|
||||
rto
|
||||
|
@ -357,9 +354,9 @@ def swap_rtos(view_layer, rto):
|
|||
|
||||
else:
|
||||
# get B
|
||||
swap_buffer["B"]["RTO"] = rto
|
||||
for laycol in layer_collections.values():
|
||||
swap_buffer["B"]["values"].append(get_off_on[
|
||||
internals.swap_buffer["B"]["RTO"] = rto
|
||||
for laycol in internals.layer_collections.values():
|
||||
internals.swap_buffer["B"]["values"].append(get_off_on[
|
||||
get_rto(laycol["ptr"], rto)
|
||||
][
|
||||
rto
|
||||
|
@ -367,52 +364,52 @@ def swap_rtos(view_layer, rto):
|
|||
)
|
||||
|
||||
# swap A with B
|
||||
for x, laycol in enumerate(layer_collections.values()):
|
||||
set_rto(laycol["ptr"], swap_buffer["A"]["RTO"],
|
||||
for x, laycol in enumerate(internals.layer_collections.values()):
|
||||
set_rto(laycol["ptr"], internals.swap_buffer["A"]["RTO"],
|
||||
set_off_on[
|
||||
swap_buffer["A"]["RTO"]
|
||||
internals.swap_buffer["A"]["RTO"]
|
||||
][
|
||||
swap_buffer["B"]["values"][x]
|
||||
internals.swap_buffer["B"]["values"][x]
|
||||
]
|
||||
)
|
||||
|
||||
set_rto(laycol["ptr"], swap_buffer["B"]["RTO"],
|
||||
set_rto(laycol["ptr"], internals.swap_buffer["B"]["RTO"],
|
||||
set_off_on[
|
||||
swap_buffer["B"]["RTO"]
|
||||
internals.swap_buffer["B"]["RTO"]
|
||||
][
|
||||
swap_buffer["A"]["values"][x]
|
||||
internals.swap_buffer["A"]["values"][x]
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
# clear rto history
|
||||
swap_a = swap_buffer["A"]["RTO"]
|
||||
swap_b = swap_buffer["B"]["RTO"]
|
||||
swap_a = internals.swap_buffer["A"]["RTO"]
|
||||
swap_b = internals.swap_buffer["B"]["RTO"]
|
||||
|
||||
rto_history[swap_a].pop(view_layer, None)
|
||||
rto_history[swap_a+"_all"].pop(view_layer, None)
|
||||
rto_history[swap_b].pop(view_layer, None)
|
||||
rto_history[swap_b+"_all"].pop(view_layer, None)
|
||||
internals.rto_history[swap_a].pop(view_layer, None)
|
||||
internals.rto_history[swap_a+"_all"].pop(view_layer, None)
|
||||
internals.rto_history[swap_b].pop(view_layer, None)
|
||||
internals.rto_history[swap_b+"_all"].pop(view_layer, None)
|
||||
|
||||
# clear swap buffer
|
||||
swap_buffer["A"]["RTO"] = ""
|
||||
swap_buffer["A"]["values"].clear()
|
||||
swap_buffer["B"]["RTO"] = ""
|
||||
swap_buffer["B"]["values"].clear()
|
||||
internals.swap_buffer["A"]["RTO"] = ""
|
||||
internals.swap_buffer["A"]["values"].clear()
|
||||
internals.swap_buffer["B"]["RTO"] = ""
|
||||
internals.swap_buffer["B"]["values"].clear()
|
||||
|
||||
|
||||
def clear_copy(rto):
|
||||
if copy_buffer["RTO"] == rto:
|
||||
copy_buffer["RTO"] = ""
|
||||
copy_buffer["values"].clear()
|
||||
if internals.copy_buffer["RTO"] == rto:
|
||||
internals.copy_buffer["RTO"] = ""
|
||||
internals.copy_buffer["values"].clear()
|
||||
|
||||
|
||||
def clear_swap(rto):
|
||||
if swap_buffer["A"]["RTO"] == rto:
|
||||
swap_buffer["A"]["RTO"] = ""
|
||||
swap_buffer["A"]["values"].clear()
|
||||
swap_buffer["B"]["RTO"] = ""
|
||||
swap_buffer["B"]["values"].clear()
|
||||
if internals.swap_buffer["A"]["RTO"] == rto:
|
||||
internals.swap_buffer["A"]["RTO"] = ""
|
||||
internals.swap_buffer["A"]["values"].clear()
|
||||
internals.swap_buffer["B"]["RTO"] = ""
|
||||
internals.swap_buffer["B"]["values"].clear()
|
||||
|
||||
|
||||
def link_child_collections_to_parent(laycol, collection, parent_collection):
|
||||
|
@ -454,29 +451,29 @@ def remove_collection(laycol, collection, context):
|
|||
bpy.data.collections.remove(collection)
|
||||
|
||||
# update references
|
||||
expanded.discard(laycol["name"])
|
||||
internals.expanded.discard(laycol["name"])
|
||||
|
||||
if expand_history["target"] == laycol["name"]:
|
||||
expand_history["target"] = ""
|
||||
if internals.expand_history["target"] == laycol["name"]:
|
||||
internals.expand_history["target"] = ""
|
||||
|
||||
if laycol["name"] in expand_history["history"]:
|
||||
expand_history["history"].remove(laycol["name"])
|
||||
if laycol["name"] in internals.expand_history["history"]:
|
||||
internals.expand_history["history"].remove(laycol["name"])
|
||||
|
||||
if qcd_slots.contains(name=laycol["name"]):
|
||||
qcd_slots.del_slot(name=laycol["name"])
|
||||
if internals.qcd_slots.contains(name=laycol["name"]):
|
||||
internals.qcd_slots.del_slot(name=laycol["name"])
|
||||
|
||||
if laycol["name"] in qcd_slots.overrides:
|
||||
qcd_slots.overrides.remove(laycol["name"])
|
||||
if laycol["name"] in internals.qcd_slots.overrides:
|
||||
internals.qcd_slots.overrides.remove(laycol["name"])
|
||||
|
||||
# reset history
|
||||
for rto in rto_history.values():
|
||||
for rto in internals.rto_history.values():
|
||||
rto.clear()
|
||||
|
||||
# update tree view
|
||||
update_property_group(context)
|
||||
|
||||
# update selected row
|
||||
laycol = layer_collections.get(selected_row_name, None)
|
||||
laycol = internals.layer_collections.get(selected_row_name, None)
|
||||
if laycol:
|
||||
cm.cm_list_index = laycol["row_index"]
|
||||
|
||||
|
@ -485,7 +482,7 @@ def remove_collection(laycol, collection, context):
|
|||
|
||||
if cm.cm_list_index > -1:
|
||||
name = cm.cm_list_collection[cm.cm_list_index].name
|
||||
laycol = layer_collections[name]
|
||||
laycol = internals.layer_collections[name]
|
||||
while not laycol["visible"]:
|
||||
laycol = laycol["parent"]
|
||||
|
||||
|
@ -497,7 +494,7 @@ def select_collection_objects(is_master_collection, collection_name, replace, ne
|
|||
target_collection = bpy.context.view_layer.layer_collection.collection
|
||||
|
||||
else:
|
||||
laycol = layer_collections[collection_name]
|
||||
laycol = internals.layer_collections[collection_name]
|
||||
target_collection = laycol["ptr"].collection
|
||||
|
||||
if replace:
|
||||
|
|
|
@ -32,17 +32,11 @@ from bpy.props import (
|
|||
IntProperty
|
||||
)
|
||||
|
||||
# For VARS
|
||||
from . import internals
|
||||
|
||||
# For FUNCTIONS
|
||||
from .internals import (
|
||||
expanded,
|
||||
layer_collections,
|
||||
qcd_slots,
|
||||
rto_history,
|
||||
expand_history,
|
||||
phantom_history,
|
||||
copy_buffer,
|
||||
swap_buffer,
|
||||
update_property_group,
|
||||
get_modifiers,
|
||||
get_move_selection,
|
||||
|
@ -52,8 +46,6 @@ from .internals import (
|
|||
)
|
||||
|
||||
from .operator_utils import (
|
||||
get_rto,
|
||||
set_rto,
|
||||
apply_to_children,
|
||||
isolate_rto,
|
||||
toggle_children,
|
||||
|
@ -85,7 +77,7 @@ class SetActiveCollection(Operator):
|
|||
layer_collection = context.view_layer.layer_collection
|
||||
|
||||
else:
|
||||
laycol = layer_collections[self.collection_name]
|
||||
laycol = internals.layer_collections[self.collection_name]
|
||||
layer_collection = laycol["ptr"]
|
||||
|
||||
# set selection to this row
|
||||
|
@ -106,19 +98,17 @@ class ExpandAllOperator(Operator):
|
|||
bl_idname = "view3d.expand_all_items"
|
||||
|
||||
def execute(self, context):
|
||||
global expand_history
|
||||
|
||||
if len(expanded) > 0:
|
||||
expanded.clear()
|
||||
if len(internals.expanded) > 0:
|
||||
internals.expanded.clear()
|
||||
context.scene.collection_manager.cm_list_index = 0
|
||||
else:
|
||||
for laycol in layer_collections.values():
|
||||
for laycol in internals.layer_collections.values():
|
||||
if laycol["ptr"].children:
|
||||
expanded.add(laycol["name"])
|
||||
internals.expanded.add(laycol["name"])
|
||||
|
||||
# clear expand history
|
||||
expand_history["target"] = ""
|
||||
expand_history["history"].clear()
|
||||
internals.expand_history["target"] = ""
|
||||
internals.expand_history["history"].clear()
|
||||
|
||||
# update tree view
|
||||
update_property_group(context)
|
||||
|
@ -140,74 +130,74 @@ class ExpandSublevelOperator(Operator):
|
|||
index: IntProperty()
|
||||
|
||||
def invoke(self, context, event):
|
||||
global expand_history
|
||||
cls = ExpandSublevelOperator
|
||||
|
||||
modifiers = get_modifiers(event)
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
expand_history["target"] = ""
|
||||
expand_history["history"].clear()
|
||||
internals.expand_history["target"] = ""
|
||||
internals.expand_history["history"].clear()
|
||||
|
||||
elif modifiers == {"ctrl"}:
|
||||
# expand/collapse all subcollections
|
||||
expand = None
|
||||
|
||||
# check whether to expand or collapse
|
||||
if self.name in expanded:
|
||||
expanded.remove(self.name)
|
||||
if self.name in internals.expanded:
|
||||
internals.expanded.remove(self.name)
|
||||
expand = False
|
||||
else:
|
||||
expanded.add(self.name)
|
||||
internals.expanded.add(self.name)
|
||||
expand = True
|
||||
|
||||
# do expanding/collapsing
|
||||
def set_expanded(layer_collection):
|
||||
if expand:
|
||||
expanded.add(layer_collection.name)
|
||||
internals.expanded.add(layer_collection.name)
|
||||
else:
|
||||
expanded.discard(layer_collection.name)
|
||||
internals.expanded.discard(layer_collection.name)
|
||||
|
||||
apply_to_children(layer_collections[self.name]["ptr"], set_expanded)
|
||||
apply_to_children(internals.layer_collections[self.name]["ptr"], set_expanded)
|
||||
|
||||
expand_history["target"] = ""
|
||||
expand_history["history"].clear()
|
||||
internals.expand_history["target"] = ""
|
||||
internals.expand_history["history"].clear()
|
||||
|
||||
elif modifiers == {"shift"}:
|
||||
def isolate_tree(current_laycol):
|
||||
parent = current_laycol["parent"]
|
||||
|
||||
for laycol in parent["children"]:
|
||||
if laycol["name"] != current_laycol["name"] and laycol["name"] in expanded:
|
||||
expanded.remove(laycol["name"])
|
||||
expand_history["history"].append(laycol["name"])
|
||||
if (laycol["name"] != current_laycol["name"]
|
||||
and laycol["name"] in internals.expanded):
|
||||
internals.expanded.remove(laycol["name"])
|
||||
internals.expand_history["history"].append(laycol["name"])
|
||||
|
||||
if parent["parent"]:
|
||||
isolate_tree(parent)
|
||||
|
||||
if self.name == expand_history["target"]:
|
||||
for item in expand_history["history"]:
|
||||
expanded.add(item)
|
||||
if self.name == internals.expand_history["target"]:
|
||||
for item in internals.expand_history["history"]:
|
||||
internals.expanded.add(item)
|
||||
|
||||
expand_history["target"] = ""
|
||||
expand_history["history"].clear()
|
||||
internals.expand_history["target"] = ""
|
||||
internals.expand_history["history"].clear()
|
||||
|
||||
else:
|
||||
expand_history["target"] = ""
|
||||
expand_history["history"].clear()
|
||||
internals.expand_history["target"] = ""
|
||||
internals.expand_history["history"].clear()
|
||||
|
||||
isolate_tree(layer_collections[self.name])
|
||||
expand_history["target"] = self.name
|
||||
isolate_tree(internals.layer_collections[self.name])
|
||||
internals.expand_history["target"] = self.name
|
||||
|
||||
else:
|
||||
# expand/collapse collection
|
||||
if self.expand:
|
||||
expanded.add(self.name)
|
||||
internals.expanded.add(self.name)
|
||||
else:
|
||||
expanded.remove(self.name)
|
||||
internals.expanded.remove(self.name)
|
||||
|
||||
expand_history["target"] = ""
|
||||
expand_history["history"].clear()
|
||||
internals.expand_history["target"] = ""
|
||||
internals.expand_history["history"].clear()
|
||||
|
||||
# set the selected row to the collection you're expanding/collapsing to
|
||||
# preserve the tree view's scrolling
|
||||
|
@ -288,7 +278,7 @@ class CMSetCollectionOperator(Operator):
|
|||
target_collection = context.view_layer.layer_collection.collection
|
||||
|
||||
else:
|
||||
laycol = layer_collections[self.collection_name]
|
||||
laycol = internals.layer_collections[self.collection_name]
|
||||
target_collection = laycol["ptr"].collection
|
||||
|
||||
selected_objects = get_move_selection()
|
||||
|
@ -395,20 +385,19 @@ class CMExcludeOperator(Operator):
|
|||
isolated = False
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
cls = CMExcludeOperator
|
||||
|
||||
modifiers = get_modifiers(event)
|
||||
view_layer = context.view_layer.name
|
||||
orig_active_collection = context.view_layer.active_layer_collection
|
||||
orig_active_object = context.view_layer.objects.active
|
||||
laycol_ptr = layer_collections[self.name]["ptr"]
|
||||
laycol_ptr = internals.layer_collections[self.name]["ptr"]
|
||||
|
||||
if not view_layer in rto_history["exclude"]:
|
||||
rto_history["exclude"][view_layer] = {"target": "", "history": []}
|
||||
if not view_layer in internals.rto_history["exclude"]:
|
||||
internals.rto_history["exclude"][view_layer] = {"target": "", "history": []}
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
del rto_history["exclude"][view_layer]
|
||||
del internals.rto_history["exclude"][view_layer]
|
||||
cls.isolated = False
|
||||
|
||||
elif modifiers == {"shift"}:
|
||||
|
@ -426,7 +415,7 @@ class CMExcludeOperator(Operator):
|
|||
# toggle exclusion
|
||||
|
||||
# reset exclude history
|
||||
del rto_history["exclude"][view_layer]
|
||||
del internals.rto_history["exclude"][view_layer]
|
||||
|
||||
set_exclude_state(laycol_ptr, not laycol_ptr.exclude)
|
||||
|
||||
|
@ -441,8 +430,8 @@ class CMExcludeOperator(Operator):
|
|||
context.view_layer.objects.active = orig_active_object
|
||||
|
||||
# reset exclude all history
|
||||
if view_layer in rto_history["exclude_all"]:
|
||||
del rto_history["exclude_all"][view_layer]
|
||||
if view_layer in internals.rto_history["exclude_all"]:
|
||||
del internals.rto_history["exclude_all"][view_layer]
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
@ -460,19 +449,17 @@ class CMUnExcludeAllOperator(Operator):
|
|||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
|
||||
orig_active_collection = context.view_layer.active_layer_collection
|
||||
orig_active_object = context.view_layer.objects.active
|
||||
view_layer = context.view_layer.name
|
||||
modifiers = get_modifiers(event)
|
||||
|
||||
if not view_layer in rto_history["exclude_all"]:
|
||||
rto_history["exclude_all"][view_layer] = []
|
||||
if not view_layer in internals.rto_history["exclude_all"]:
|
||||
internals.rto_history["exclude_all"][view_layer] = []
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
# clear all states
|
||||
del rto_history["exclude_all"][view_layer]
|
||||
del internals.rto_history["exclude_all"][view_layer]
|
||||
clear_copy("exclude")
|
||||
clear_swap("exclude")
|
||||
|
||||
|
@ -516,18 +503,17 @@ class CMRestrictSelectOperator(Operator):
|
|||
isolated = False
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
cls = CMRestrictSelectOperator
|
||||
|
||||
modifiers = get_modifiers(event)
|
||||
view_layer = context.view_layer.name
|
||||
laycol_ptr = layer_collections[self.name]["ptr"]
|
||||
laycol_ptr = internals.layer_collections[self.name]["ptr"]
|
||||
|
||||
if not view_layer in rto_history["select"]:
|
||||
rto_history["select"][view_layer] = {"target": "", "history": []}
|
||||
if not view_layer in internals.rto_history["select"]:
|
||||
internals.rto_history["select"][view_layer] = {"target": "", "history": []}
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
del rto_history["select"][view_layer]
|
||||
del internals.rto_history["select"][view_layer]
|
||||
cls.isolated = False
|
||||
|
||||
elif modifiers == {"shift"}:
|
||||
|
@ -545,7 +531,7 @@ class CMRestrictSelectOperator(Operator):
|
|||
# toggle selectable
|
||||
|
||||
# reset select history
|
||||
del rto_history["select"][view_layer]
|
||||
del internals.rto_history["select"][view_layer]
|
||||
|
||||
# toggle selectability of collection
|
||||
laycol_ptr.collection.hide_select = not laycol_ptr.collection.hide_select
|
||||
|
@ -553,8 +539,8 @@ class CMRestrictSelectOperator(Operator):
|
|||
cls.isolated = False
|
||||
|
||||
# reset select all history
|
||||
if view_layer in rto_history["select_all"]:
|
||||
del rto_history["select_all"][view_layer]
|
||||
if view_layer in internals.rto_history["select_all"]:
|
||||
del internals.rto_history["select_all"][view_layer]
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
@ -572,17 +558,15 @@ class CMUnRestrictSelectAllOperator(Operator):
|
|||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
|
||||
view_layer = context.view_layer.name
|
||||
modifiers = get_modifiers(event)
|
||||
|
||||
if not view_layer in rto_history["select_all"]:
|
||||
rto_history["select_all"][view_layer] = []
|
||||
if not view_layer in internals.rto_history["select_all"]:
|
||||
internals.rto_history["select_all"][view_layer] = []
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
# clear all states
|
||||
del rto_history["select_all"][view_layer]
|
||||
del internals.rto_history["select_all"][view_layer]
|
||||
clear_copy("select")
|
||||
clear_swap("select")
|
||||
|
||||
|
@ -618,18 +602,17 @@ class CMHideOperator(Operator):
|
|||
isolated = False
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
cls = CMHideOperator
|
||||
|
||||
modifiers = get_modifiers(event)
|
||||
view_layer = context.view_layer.name
|
||||
laycol_ptr = layer_collections[self.name]["ptr"]
|
||||
laycol_ptr = internals.layer_collections[self.name]["ptr"]
|
||||
|
||||
if not view_layer in rto_history["hide"]:
|
||||
rto_history["hide"][view_layer] = {"target": "", "history": []}
|
||||
if not view_layer in internals.rto_history["hide"]:
|
||||
internals.rto_history["hide"][view_layer] = {"target": "", "history": []}
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
del rto_history["hide"][view_layer]
|
||||
del internals.rto_history["hide"][view_layer]
|
||||
cls.isolated = False
|
||||
|
||||
elif modifiers == {"shift"}:
|
||||
|
@ -647,7 +630,7 @@ class CMHideOperator(Operator):
|
|||
# toggle visible
|
||||
|
||||
# reset hide history
|
||||
del rto_history["hide"][view_layer]
|
||||
del internals.rto_history["hide"][view_layer]
|
||||
|
||||
# toggle view of collection
|
||||
laycol_ptr.hide_viewport = not laycol_ptr.hide_viewport
|
||||
|
@ -655,8 +638,8 @@ class CMHideOperator(Operator):
|
|||
cls.isolated = False
|
||||
|
||||
# reset hide all history
|
||||
if view_layer in rto_history["hide_all"]:
|
||||
del rto_history["hide_all"][view_layer]
|
||||
if view_layer in internals.rto_history["hide_all"]:
|
||||
del internals.rto_history["hide_all"][view_layer]
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
@ -674,17 +657,15 @@ class CMUnHideAllOperator(Operator):
|
|||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
|
||||
view_layer = context.view_layer.name
|
||||
modifiers = get_modifiers(event)
|
||||
|
||||
if not view_layer in rto_history["hide_all"]:
|
||||
rto_history["hide_all"][view_layer] = []
|
||||
if not view_layer in internals.rto_history["hide_all"]:
|
||||
internals.rto_history["hide_all"][view_layer] = []
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
# clear all states
|
||||
del rto_history["hide_all"][view_layer]
|
||||
del internals.rto_history["hide_all"][view_layer]
|
||||
clear_copy("hide")
|
||||
clear_swap("hide")
|
||||
|
||||
|
@ -720,18 +701,17 @@ class CMDisableViewportOperator(Operator):
|
|||
isolated = False
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
cls = CMDisableViewportOperator
|
||||
|
||||
modifiers = get_modifiers(event)
|
||||
view_layer = context.view_layer.name
|
||||
laycol_ptr = layer_collections[self.name]["ptr"]
|
||||
laycol_ptr = internals.layer_collections[self.name]["ptr"]
|
||||
|
||||
if not view_layer in rto_history["disable"]:
|
||||
rto_history["disable"][view_layer] = {"target": "", "history": []}
|
||||
if not view_layer in internals.rto_history["disable"]:
|
||||
internals.rto_history["disable"][view_layer] = {"target": "", "history": []}
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
del rto_history["disable"][view_layer]
|
||||
del internals.rto_history["disable"][view_layer]
|
||||
cls.isolated = False
|
||||
|
||||
elif modifiers == {"shift"}:
|
||||
|
@ -749,7 +729,7 @@ class CMDisableViewportOperator(Operator):
|
|||
# toggle disable
|
||||
|
||||
# reset disable history
|
||||
del rto_history["disable"][view_layer]
|
||||
del internals.rto_history["disable"][view_layer]
|
||||
|
||||
# toggle disable of collection in viewport
|
||||
laycol_ptr.collection.hide_viewport = not laycol_ptr.collection.hide_viewport
|
||||
|
@ -757,8 +737,8 @@ class CMDisableViewportOperator(Operator):
|
|||
cls.isolated = False
|
||||
|
||||
# reset disable all history
|
||||
if view_layer in rto_history["disable_all"]:
|
||||
del rto_history["disable_all"][view_layer]
|
||||
if view_layer in internals.rto_history["disable_all"]:
|
||||
del internals.rto_history["disable_all"][view_layer]
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
@ -776,17 +756,15 @@ class CMUnDisableViewportAllOperator(Operator):
|
|||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
|
||||
view_layer = context.view_layer.name
|
||||
modifiers = get_modifiers(event)
|
||||
|
||||
if not view_layer in rto_history["disable_all"]:
|
||||
rto_history["disable_all"][view_layer] = []
|
||||
if not view_layer in internals.rto_history["disable_all"]:
|
||||
internals.rto_history["disable_all"][view_layer] = []
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
# clear all states
|
||||
del rto_history["disable_all"][view_layer]
|
||||
del internals.rto_history["disable_all"][view_layer]
|
||||
clear_copy("disable")
|
||||
clear_swap("disable")
|
||||
|
||||
|
@ -822,19 +800,18 @@ class CMDisableRenderOperator(Operator):
|
|||
isolated = False
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
cls = CMDisableRenderOperator
|
||||
|
||||
modifiers = get_modifiers(event)
|
||||
view_layer = context.view_layer.name
|
||||
laycol_ptr = layer_collections[self.name]["ptr"]
|
||||
laycol_ptr = internals.layer_collections[self.name]["ptr"]
|
||||
|
||||
if not view_layer in rto_history["render"]:
|
||||
rto_history["render"][view_layer] = {"target": "", "history": []}
|
||||
if not view_layer in internals.rto_history["render"]:
|
||||
internals.rto_history["render"][view_layer] = {"target": "", "history": []}
|
||||
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
del rto_history["render"][view_layer]
|
||||
del internals.rto_history["render"][view_layer]
|
||||
cls.isolated = False
|
||||
|
||||
elif modifiers == {"shift"}:
|
||||
|
@ -852,7 +829,7 @@ class CMDisableRenderOperator(Operator):
|
|||
# toggle renderable
|
||||
|
||||
# reset render history
|
||||
del rto_history["render"][view_layer]
|
||||
del internals.rto_history["render"][view_layer]
|
||||
|
||||
# toggle renderability of collection
|
||||
laycol_ptr.collection.hide_render = not laycol_ptr.collection.hide_render
|
||||
|
@ -860,8 +837,8 @@ class CMDisableRenderOperator(Operator):
|
|||
cls.isolated = False
|
||||
|
||||
# reset render all history
|
||||
if view_layer in rto_history["render_all"]:
|
||||
del rto_history["render_all"][view_layer]
|
||||
if view_layer in internals.rto_history["render_all"]:
|
||||
del internals.rto_history["render_all"][view_layer]
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
@ -879,17 +856,15 @@ class CMUnDisableRenderAllOperator(Operator):
|
|||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
|
||||
view_layer = context.view_layer.name
|
||||
modifiers = get_modifiers(event)
|
||||
|
||||
if not view_layer in rto_history["render_all"]:
|
||||
rto_history["render_all"][view_layer] = []
|
||||
if not view_layer in internals.rto_history["render_all"]:
|
||||
internals.rto_history["render_all"][view_layer] = []
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
# clear all states
|
||||
del rto_history["render_all"][view_layer]
|
||||
del internals.rto_history["render_all"][view_layer]
|
||||
clear_copy("render")
|
||||
clear_swap("render")
|
||||
|
||||
|
@ -925,18 +900,17 @@ class CMHoldoutOperator(Operator):
|
|||
isolated = False
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
cls = CMHoldoutOperator
|
||||
|
||||
modifiers = get_modifiers(event)
|
||||
view_layer = context.view_layer.name
|
||||
laycol_ptr = layer_collections[self.name]["ptr"]
|
||||
laycol_ptr = internals.layer_collections[self.name]["ptr"]
|
||||
|
||||
if not view_layer in rto_history["holdout"]:
|
||||
rto_history["holdout"][view_layer] = {"target": "", "history": []}
|
||||
if not view_layer in internals.rto_history["holdout"]:
|
||||
internals.rto_history["holdout"][view_layer] = {"target": "", "history": []}
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
del rto_history["holdout"][view_layer]
|
||||
del internals.rto_history["holdout"][view_layer]
|
||||
cls.isolated = False
|
||||
|
||||
elif modifiers == {"shift"}:
|
||||
|
@ -954,7 +928,7 @@ class CMHoldoutOperator(Operator):
|
|||
# toggle holdout
|
||||
|
||||
# reset holdout history
|
||||
del rto_history["holdout"][view_layer]
|
||||
del internals.rto_history["holdout"][view_layer]
|
||||
|
||||
# toggle holdout of collection in viewport
|
||||
laycol_ptr.holdout = not laycol_ptr.holdout
|
||||
|
@ -962,8 +936,8 @@ class CMHoldoutOperator(Operator):
|
|||
cls.isolated = False
|
||||
|
||||
# reset holdout all history
|
||||
if view_layer in rto_history["holdout_all"]:
|
||||
del rto_history["holdout_all"][view_layer]
|
||||
if view_layer in internals.rto_history["holdout_all"]:
|
||||
del internals.rto_history["holdout_all"][view_layer]
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
@ -981,17 +955,15 @@ class CMUnHoldoutAllOperator(Operator):
|
|||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
|
||||
view_layer = context.view_layer.name
|
||||
modifiers = get_modifiers(event)
|
||||
|
||||
if not view_layer in rto_history["holdout_all"]:
|
||||
rto_history["holdout_all"][view_layer] = []
|
||||
if not view_layer in internals.rto_history["holdout_all"]:
|
||||
internals.rto_history["holdout_all"][view_layer] = []
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
# clear all states
|
||||
del rto_history["holdout_all"][view_layer]
|
||||
del internals.rto_history["holdout_all"][view_layer]
|
||||
clear_copy("holdout")
|
||||
clear_swap("holdout")
|
||||
|
||||
|
@ -1027,19 +999,18 @@ class CMIndirectOnlyOperator(Operator):
|
|||
isolated = False
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
cls = CMIndirectOnlyOperator
|
||||
|
||||
modifiers = get_modifiers(event)
|
||||
view_layer = context.view_layer.name
|
||||
laycol_ptr = layer_collections[self.name]["ptr"]
|
||||
laycol_ptr = internals.layer_collections[self.name]["ptr"]
|
||||
|
||||
if not view_layer in rto_history["indirect"]:
|
||||
rto_history["indirect"][view_layer] = {"target": "", "history": []}
|
||||
if not view_layer in internals.rto_history["indirect"]:
|
||||
internals.rto_history["indirect"][view_layer] = {"target": "", "history": []}
|
||||
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
del rto_history["indirect"][view_layer]
|
||||
del internals.rto_history["indirect"][view_layer]
|
||||
cls.isolated = False
|
||||
|
||||
elif modifiers == {"shift"}:
|
||||
|
@ -1057,7 +1028,7 @@ class CMIndirectOnlyOperator(Operator):
|
|||
# toggle indirect only
|
||||
|
||||
# reset indirect history
|
||||
del rto_history["indirect"][view_layer]
|
||||
del internals.rto_history["indirect"][view_layer]
|
||||
|
||||
# toggle indirect only of collection
|
||||
laycol_ptr.indirect_only = not laycol_ptr.indirect_only
|
||||
|
@ -1065,8 +1036,8 @@ class CMIndirectOnlyOperator(Operator):
|
|||
cls.isolated = False
|
||||
|
||||
# reset indirect all history
|
||||
if view_layer in rto_history["indirect_all"]:
|
||||
del rto_history["indirect_all"][view_layer]
|
||||
if view_layer in internals.rto_history["indirect_all"]:
|
||||
del internals.rto_history["indirect_all"][view_layer]
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
@ -1084,17 +1055,15 @@ class CMUnIndirectOnlyAllOperator(Operator):
|
|||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
global rto_history
|
||||
|
||||
view_layer = context.view_layer.name
|
||||
modifiers = get_modifiers(event)
|
||||
|
||||
if not view_layer in rto_history["indirect_all"]:
|
||||
rto_history["indirect_all"][view_layer] = []
|
||||
if not view_layer in internals.rto_history["indirect_all"]:
|
||||
internals.rto_history["indirect_all"][view_layer] = []
|
||||
|
||||
if modifiers == {"alt"}:
|
||||
# clear all states
|
||||
del rto_history["indirect_all"][view_layer]
|
||||
del internals.rto_history["indirect_all"][view_layer]
|
||||
clear_copy("indirect")
|
||||
clear_swap("indirect")
|
||||
|
||||
|
@ -1122,11 +1091,7 @@ class CMRemoveCollectionOperator(Operator):
|
|||
collection_name: StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
global rto_history
|
||||
global expand_history
|
||||
global qcd_slots
|
||||
|
||||
laycol = layer_collections[self.collection_name]
|
||||
laycol = internals.layer_collections[self.collection_name]
|
||||
collection = laycol["ptr"].collection
|
||||
parent_collection = laycol["parent"]["ptr"].collection
|
||||
|
||||
|
@ -1171,22 +1136,18 @@ class CMRemoveEmptyCollectionsOperator(Operator):
|
|||
return tooltip
|
||||
|
||||
def execute(self, context):
|
||||
global rto_history
|
||||
global expand_history
|
||||
global qcd_slots
|
||||
|
||||
if self.without_objects:
|
||||
empty_collections = [laycol["name"]
|
||||
for laycol in layer_collections.values()
|
||||
for laycol in internals.layer_collections.values()
|
||||
if not laycol["ptr"].collection.objects]
|
||||
else:
|
||||
empty_collections = [laycol["name"]
|
||||
for laycol in layer_collections.values()
|
||||
for laycol in internals.layer_collections.values()
|
||||
if not laycol["children"] and
|
||||
not laycol["ptr"].collection.objects]
|
||||
|
||||
for name in empty_collections:
|
||||
laycol = layer_collections[name]
|
||||
laycol = internals.layer_collections[name]
|
||||
collection = laycol["ptr"].collection
|
||||
parent_collection = laycol["parent"]["ptr"].collection
|
||||
|
||||
|
@ -1227,8 +1188,6 @@ class CMNewCollectionOperator(Operator):
|
|||
return tooltip
|
||||
|
||||
def execute(self, context):
|
||||
global rto_history
|
||||
|
||||
new_collection = bpy.data.collections.new("New Collection")
|
||||
cm = context.scene.collection_manager
|
||||
|
||||
|
@ -1251,17 +1210,17 @@ class CMNewCollectionOperator(Operator):
|
|||
if len(cm.cm_list_collection) > 0:
|
||||
if not cm.cm_list_index == -1:
|
||||
# get selected collection
|
||||
laycol = layer_collections[cm.cm_list_collection[cm.cm_list_index].name]
|
||||
laycol = internals.layer_collections[cm.cm_list_collection[cm.cm_list_index].name]
|
||||
|
||||
# add new collection
|
||||
if self.child:
|
||||
laycol["ptr"].collection.children.link(new_collection)
|
||||
expanded.add(laycol["name"])
|
||||
internals.expanded.add(laycol["name"])
|
||||
|
||||
# update tree view property
|
||||
update_property_group(context)
|
||||
|
||||
cm.cm_list_index = layer_collections[new_collection.name]["row_index"]
|
||||
cm.cm_list_index = internals.layer_collections[new_collection.name]["row_index"]
|
||||
|
||||
else:
|
||||
laycol["parent"]["ptr"].collection.children.link(new_collection)
|
||||
|
@ -1269,7 +1228,7 @@ class CMNewCollectionOperator(Operator):
|
|||
# update tree view property
|
||||
update_property_group(context)
|
||||
|
||||
cm.cm_list_index = layer_collections[new_collection.name]["row_index"]
|
||||
cm.cm_list_index = internals.layer_collections[new_collection.name]["row_index"]
|
||||
|
||||
else:
|
||||
context.scene.collection.children.link(new_collection)
|
||||
|
@ -1277,7 +1236,7 @@ class CMNewCollectionOperator(Operator):
|
|||
# update tree view property
|
||||
update_property_group(context)
|
||||
|
||||
cm.cm_list_index = layer_collections[new_collection.name]["row_index"]
|
||||
cm.cm_list_index = internals.layer_collections[new_collection.name]["row_index"]
|
||||
|
||||
# if no collections add top level collection and select it
|
||||
else:
|
||||
|
@ -1290,7 +1249,7 @@ class CMNewCollectionOperator(Operator):
|
|||
|
||||
|
||||
# set new collection to active
|
||||
layer_collection = layer_collections[new_collection.name]["ptr"]
|
||||
layer_collection = internals.layer_collections[new_collection.name]["ptr"]
|
||||
context.view_layer.active_layer_collection = layer_collection
|
||||
|
||||
# show the new collection when collections are filtered.
|
||||
|
@ -1300,7 +1259,7 @@ class CMNewCollectionOperator(Operator):
|
|||
rename[0] = True
|
||||
|
||||
# reset history
|
||||
for rto in rto_history.values():
|
||||
for rto in internals.rto_history.values():
|
||||
rto.clear()
|
||||
|
||||
return {'FINISHED'}
|
||||
|
@ -1312,9 +1271,6 @@ class CMPhantomModeOperator(Operator):
|
|||
bl_idname = "view3d.toggle_phantom_mode"
|
||||
|
||||
def execute(self, context):
|
||||
global phantom_history
|
||||
global rto_history
|
||||
|
||||
cm = context.scene.collection_manager
|
||||
view_layer = context.view_layer
|
||||
|
||||
|
@ -1324,10 +1280,10 @@ class CMPhantomModeOperator(Operator):
|
|||
cm.in_phantom_mode = True
|
||||
|
||||
# save current visibility state
|
||||
phantom_history["view_layer"] = view_layer.name
|
||||
internals.phantom_history["view_layer"] = view_layer.name
|
||||
|
||||
def save_visibility_state(layer_collection):
|
||||
phantom_history["initial_state"][layer_collection.name] = {
|
||||
internals.phantom_history["initial_state"][layer_collection.name] = {
|
||||
"exclude": layer_collection.exclude,
|
||||
"select": layer_collection.collection.hide_select,
|
||||
"hide": layer_collection.hide_viewport,
|
||||
|
@ -1340,15 +1296,15 @@ class CMPhantomModeOperator(Operator):
|
|||
apply_to_children(view_layer.layer_collection, save_visibility_state)
|
||||
|
||||
# save current rto history
|
||||
for rto, history, in rto_history.items():
|
||||
for rto, history, in internals.rto_history.items():
|
||||
if history.get(view_layer.name, None):
|
||||
phantom_history[rto+"_history"] = deepcopy(history[view_layer.name])
|
||||
internals.phantom_history[rto+"_history"] = deepcopy(history[view_layer.name])
|
||||
|
||||
|
||||
|
||||
else: # return to normal mode
|
||||
def restore_visibility_state(layer_collection):
|
||||
phantom_laycol = phantom_history["initial_state"][layer_collection.name]
|
||||
phantom_laycol = internals.phantom_history["initial_state"][layer_collection.name]
|
||||
|
||||
layer_collection.exclude = phantom_laycol["exclude"]
|
||||
layer_collection.collection.hide_select = phantom_laycol["select"]
|
||||
|
@ -1362,14 +1318,14 @@ class CMPhantomModeOperator(Operator):
|
|||
|
||||
|
||||
# restore previous rto history
|
||||
for rto, history, in rto_history.items():
|
||||
for rto, history, in internals.rto_history.items():
|
||||
if view_layer.name in history:
|
||||
del history[view_layer.name]
|
||||
|
||||
if phantom_history[rto+"_history"]:
|
||||
history[view_layer.name] = deepcopy(phantom_history[rto+"_history"])
|
||||
if internals.phantom_history[rto+"_history"]:
|
||||
history[view_layer.name] = deepcopy(internals.phantom_history[rto+"_history"])
|
||||
|
||||
phantom_history[rto+"_history"].clear()
|
||||
internals.phantom_history[rto+"_history"].clear()
|
||||
|
||||
cm.in_phantom_mode = False
|
||||
|
||||
|
|
|
@ -28,12 +28,12 @@ from gpu_extras.batch import batch_for_shader
|
|||
|
||||
from bpy.types import Operator
|
||||
|
||||
from .internals import (
|
||||
layer_collections,
|
||||
qcd_slots,
|
||||
)
|
||||
from . import internals
|
||||
|
||||
from . import qcd_operators
|
||||
from .qcd_operators import (
|
||||
get_move_selection,
|
||||
get_move_active,
|
||||
)
|
||||
|
||||
def spacer():
|
||||
spacer = 10
|
||||
|
@ -655,8 +655,8 @@ def allocate_main_ui(self, context):
|
|||
self.areas["Button Row 2 B"] = button_row_2_b
|
||||
|
||||
|
||||
selected_objects = qcd_operators.get_move_selection()
|
||||
active_object = qcd_operators.get_move_active()
|
||||
selected_objects = get_move_selection()
|
||||
active_object = get_move_active()
|
||||
|
||||
|
||||
# BUTTONS
|
||||
|
@ -666,10 +666,10 @@ def allocate_main_ui(self, context):
|
|||
for num in range(button_group):
|
||||
slot_num = row_num + num
|
||||
|
||||
qcd_slot_name = qcd_slots.get_name(f"{slot_num}")
|
||||
qcd_slot_name = internals.qcd_slots.get_name(f"{slot_num}")
|
||||
|
||||
if qcd_slot_name:
|
||||
qcd_laycol = layer_collections[qcd_slot_name]["ptr"]
|
||||
qcd_laycol = internals.layer_collections[qcd_slot_name]["ptr"]
|
||||
collection_objects = qcd_laycol.collection.objects
|
||||
|
||||
# BUTTON
|
||||
|
@ -789,12 +789,12 @@ def draw_callback_px(self, context):
|
|||
|
||||
for num in range(20):
|
||||
slot_num = num + 1
|
||||
qcd_slot_name = qcd_slots.get_name(f"{slot_num}")
|
||||
qcd_slot_name = internals.qcd_slots.get_name(f"{slot_num}")
|
||||
if qcd_slot_name:
|
||||
qcd_laycol = layer_collections[qcd_slot_name]["ptr"]
|
||||
qcd_laycol = internals.layer_collections[qcd_slot_name]["ptr"]
|
||||
collection_objects = qcd_laycol.collection.objects
|
||||
selected_objects = qcd_operators.get_move_selection()
|
||||
active_object = qcd_operators.get_move_active()
|
||||
selected_objects = get_move_selection()
|
||||
active_object = get_move_active()
|
||||
button_area = self.areas[f"Button {slot_num}"]
|
||||
|
||||
# colors
|
||||
|
@ -826,16 +826,16 @@ def draw_callback_px(self, context):
|
|||
rounding = 5
|
||||
|
||||
if num < 10:
|
||||
if not qcd_slots.contains(idx=f"{num+2}"):
|
||||
if not internals.qcd_slots.contains(idx=f"{num+2}"):
|
||||
tr = rounding
|
||||
|
||||
if not qcd_slots.contains(idx=f"{num}"):
|
||||
if not internals.qcd_slots.contains(idx=f"{num}"):
|
||||
tl = rounding
|
||||
else:
|
||||
if not qcd_slots.contains(idx=f"{num+2}"):
|
||||
if not internals.qcd_slots.contains(idx=f"{num+2}"):
|
||||
br = rounding
|
||||
|
||||
if not qcd_slots.contains(idx=f"{num}"):
|
||||
if not internals.qcd_slots.contains(idx=f"{num}"):
|
||||
bl = rounding
|
||||
|
||||
if num in [0,5]:
|
||||
|
@ -921,7 +921,7 @@ def draw_callback_px(self, context):
|
|||
|
||||
if in_tooltip_area:
|
||||
if self.draw_tooltip:
|
||||
slot_name = qcd_slots.get_name(f"{tooltip_slot_idx}")
|
||||
slot_name = internals.qcd_slots.get_name(f"{tooltip_slot_idx}")
|
||||
slot_string = f"QCD Slot {tooltip_slot_idx}: \"{slot_name}\"\n"
|
||||
hotkey_string = " * Shift+LMB - Toggle objects\' slot."
|
||||
|
||||
|
|
|
@ -30,15 +30,11 @@ from bpy.props import (
|
|||
IntProperty
|
||||
)
|
||||
|
||||
# For VARS
|
||||
from . import internals
|
||||
|
||||
# For FUNCTIONS
|
||||
from .internals import (
|
||||
layer_collections,
|
||||
rto_history,
|
||||
qcd_history,
|
||||
qcd_slots,
|
||||
qcd_collection_state,
|
||||
update_collection_tree,
|
||||
update_property_group,
|
||||
generate_state,
|
||||
get_modifiers,
|
||||
|
@ -97,20 +93,20 @@ class QCDAllBase():
|
|||
cls.view_layer = context.view_layer.name
|
||||
cls.orig_active_object = context.view_layer.objects.active
|
||||
|
||||
if not cls.view_layer in qcd_history:
|
||||
qcd_history[cls.view_layer] = []
|
||||
if not cls.view_layer in internals.qcd_history:
|
||||
internals.qcd_history[cls.view_layer] = []
|
||||
|
||||
cls.history = qcd_history[cls.view_layer]
|
||||
cls.history = internals.qcd_history[cls.view_layer]
|
||||
|
||||
cls.locked = get_locked_objs(context)
|
||||
|
||||
@classmethod
|
||||
def apply_history(cls):
|
||||
for x, item in enumerate(layer_collections.values()):
|
||||
for x, item in enumerate(internals.layer_collections.values()):
|
||||
item["ptr"].exclude = cls.history[x]
|
||||
|
||||
# clear rto history
|
||||
del qcd_history[cls.view_layer]
|
||||
del internals.qcd_history[cls.view_layer]
|
||||
|
||||
internals.qcd_collection_state.clear()
|
||||
cls.history = None
|
||||
|
@ -133,7 +129,6 @@ class QCDAllBase():
|
|||
|
||||
@classmethod
|
||||
def clear(cls):
|
||||
|
||||
cls.context = None
|
||||
cls.view_layer = ""
|
||||
cls.history = None
|
||||
|
@ -153,8 +148,6 @@ class EnableAllQCDSlotsMeta(Operator):
|
|||
bl_idname = "view3d.enable_all_qcd_slots_meta"
|
||||
|
||||
def invoke(self, context, event):
|
||||
global qcd_slots
|
||||
global layer_collections
|
||||
qab = QCDAllBase
|
||||
|
||||
modifiers = get_modifiers(event)
|
||||
|
@ -192,12 +185,10 @@ class EnableAllQCDSlots(Operator):
|
|||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def execute(self, context):
|
||||
global qcd_slots
|
||||
global layer_collections
|
||||
qab = QCDAllBase
|
||||
|
||||
# validate qcd slots
|
||||
if not dict(qcd_slots):
|
||||
if not dict(internals.qcd_slots):
|
||||
if qab.meta_op:
|
||||
qab.meta_report = "No QCD slots."
|
||||
else:
|
||||
|
@ -210,8 +201,8 @@ class EnableAllQCDSlots(Operator):
|
|||
if not qab.history:
|
||||
keep_history = False
|
||||
|
||||
for laycol in layer_collections.values():
|
||||
is_qcd_slot = qcd_slots.contains(name=laycol["name"])
|
||||
for laycol in internals.layer_collections.values():
|
||||
is_qcd_slot = internals.qcd_slots.contains(name=laycol["name"])
|
||||
|
||||
qab.history.append(laycol["ptr"].exclude)
|
||||
|
||||
|
@ -222,7 +213,7 @@ class EnableAllQCDSlots(Operator):
|
|||
|
||||
if not keep_history:
|
||||
# clear rto history
|
||||
del qcd_history[qab.view_layer]
|
||||
del internals.qcd_history[qab.view_layer]
|
||||
qab.clear()
|
||||
|
||||
if qab.meta_op:
|
||||
|
@ -243,6 +234,7 @@ class EnableAllQCDSlots(Operator):
|
|||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class EnableAllQCDSlotsIsolated(Operator):
|
||||
'''Toggles between the current state and all enabled (non-QCD collections disabled)'''
|
||||
bl_label = "Enable All QCD Slots Isolated"
|
||||
|
@ -250,21 +242,19 @@ class EnableAllQCDSlotsIsolated(Operator):
|
|||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def execute(self, context):
|
||||
global qcd_slots
|
||||
global layer_collections
|
||||
qab = QCDAllBase
|
||||
|
||||
# validate qcd slots
|
||||
if not dict(qcd_slots):
|
||||
if not dict(internals.qcd_slots):
|
||||
self.report({"INFO"}, "No QCD slots.")
|
||||
|
||||
return {'CANCELLED'}
|
||||
|
||||
qab.init(context)
|
||||
|
||||
if qab.locked.objs and not qcd_slots.object_in_slots(qab.orig_active_object):
|
||||
if qab.locked.objs and not internals.qcd_slots.object_in_slots(qab.orig_active_object):
|
||||
# clear rto history
|
||||
del qcd_history[qab.view_layer]
|
||||
del internals.qcd_history[qab.view_layer]
|
||||
qab.clear()
|
||||
|
||||
self.report({"WARNING"}, "Cannot execute. The active object would be lost.")
|
||||
|
@ -274,8 +264,8 @@ class EnableAllQCDSlotsIsolated(Operator):
|
|||
if not qab.history:
|
||||
keep_history = False
|
||||
|
||||
for laycol in layer_collections.values():
|
||||
is_qcd_slot = qcd_slots.contains(name=laycol["name"])
|
||||
for laycol in internals.layer_collections.values():
|
||||
is_qcd_slot = internals.qcd_slots.contains(name=laycol["name"])
|
||||
|
||||
qab.history.append(laycol["ptr"].exclude)
|
||||
|
||||
|
@ -290,7 +280,7 @@ class EnableAllQCDSlotsIsolated(Operator):
|
|||
|
||||
if not keep_history:
|
||||
# clear rto history
|
||||
del qcd_history[qab.view_layer]
|
||||
del internals.qcd_history[qab.view_layer]
|
||||
qab.clear()
|
||||
|
||||
self.report({"INFO"}, "All QCD slots are already enabled and isolated.")
|
||||
|
@ -314,21 +304,19 @@ class DisableAllNonQCDSlots(Operator):
|
|||
|
||||
|
||||
def execute(self, context):
|
||||
global qcd_slots
|
||||
global layer_collections
|
||||
qab = QCDAllBase
|
||||
|
||||
# validate qcd slots
|
||||
if not dict(qcd_slots):
|
||||
if not dict(internals.qcd_slots):
|
||||
self.report({"INFO"}, "No QCD slots.")
|
||||
|
||||
return {'CANCELLED'}
|
||||
|
||||
qab.init(context)
|
||||
|
||||
if qab.locked.objs and not qcd_slots.object_in_slots(qab.orig_active_object):
|
||||
if qab.locked.objs and not internals.qcd_slots.object_in_slots(qab.orig_active_object):
|
||||
# clear rto history
|
||||
del qcd_history[qab.view_layer]
|
||||
del internals.qcd_history[qab.view_layer]
|
||||
qab.clear()
|
||||
|
||||
self.report({"WARNING"}, "Cannot execute. The active object would be lost.")
|
||||
|
@ -338,8 +326,8 @@ class DisableAllNonQCDSlots(Operator):
|
|||
if not qab.history:
|
||||
keep_history = False
|
||||
|
||||
for laycol in layer_collections.values():
|
||||
is_qcd_slot = qcd_slots.contains(name=laycol["name"])
|
||||
for laycol in internals.layer_collections.values():
|
||||
is_qcd_slot = internals.qcd_slots.contains(name=laycol["name"])
|
||||
|
||||
qab.history.append(laycol["ptr"].exclude)
|
||||
|
||||
|
@ -349,7 +337,7 @@ class DisableAllNonQCDSlots(Operator):
|
|||
|
||||
if not keep_history:
|
||||
# clear rto history
|
||||
del qcd_history[qab.view_layer]
|
||||
del internals.qcd_history[qab.view_layer]
|
||||
qab.clear()
|
||||
|
||||
self.report({"INFO"}, "All non QCD slots are already disabled.")
|
||||
|
@ -374,15 +362,13 @@ class DisableAllCollections(Operator):
|
|||
|
||||
|
||||
def execute(self, context):
|
||||
global qcd_slots
|
||||
global layer_collections
|
||||
qab = QCDAllBase
|
||||
|
||||
qab.init(context)
|
||||
|
||||
if qab.locked.objs:
|
||||
# clear rto history
|
||||
del qcd_history[qab.view_layer]
|
||||
del internals.qcd_history[qab.view_layer]
|
||||
qab.clear()
|
||||
|
||||
self.report({"WARNING"}, "Cannot execute. The active object would be lost.")
|
||||
|
@ -390,19 +376,19 @@ class DisableAllCollections(Operator):
|
|||
return {'CANCELLED'}
|
||||
|
||||
if not qab.history:
|
||||
for laycol in layer_collections.values():
|
||||
for laycol in internals.layer_collections.values():
|
||||
|
||||
qab.history.append(laycol["ptr"].exclude)
|
||||
|
||||
if all(qab.history): # no collections are enabled
|
||||
# clear rto history
|
||||
del qcd_history[qab.view_layer]
|
||||
del internals.qcd_history[qab.view_layer]
|
||||
qab.clear()
|
||||
|
||||
self.report({"INFO"}, "All collections are already disabled.")
|
||||
return {'CANCELLED'}
|
||||
|
||||
for laycol in layer_collections.values():
|
||||
for laycol in internals.layer_collections.values():
|
||||
laycol["ptr"].exclude = True
|
||||
|
||||
internals.qcd_collection_state.clear()
|
||||
|
@ -424,8 +410,6 @@ class SelectAllQCDObjects(Operator):
|
|||
|
||||
|
||||
def execute(self, context):
|
||||
global qcd_slots
|
||||
global layer_collections
|
||||
qab = QCDAllBase
|
||||
|
||||
if context.mode != 'OBJECT':
|
||||
|
@ -444,7 +428,7 @@ class SelectAllQCDObjects(Operator):
|
|||
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
|
||||
for slot, collection_name in qcd_slots:
|
||||
for slot, collection_name in internals.qcd_slots:
|
||||
select_collection_objects(
|
||||
is_master_collection=False,
|
||||
collection_name=collection_name,
|
||||
|
@ -454,7 +438,7 @@ class SelectAllQCDObjects(Operator):
|
|||
)
|
||||
|
||||
if context.selected_objects == orig_selected_objects:
|
||||
for slot, collection_name in qcd_slots:
|
||||
for slot, collection_name in internals.qcd_slots:
|
||||
select_collection_objects(
|
||||
is_master_collection=False,
|
||||
collection_name=collection_name,
|
||||
|
@ -473,14 +457,12 @@ class DiscardQCDHistory(Operator):
|
|||
bl_idname = "view3d.discard_qcd_history"
|
||||
|
||||
def execute(self, context):
|
||||
global qcd_slots
|
||||
global layer_collections
|
||||
qab = QCDAllBase
|
||||
|
||||
view_layer = context.view_layer.name
|
||||
|
||||
if view_layer in qcd_history:
|
||||
del qcd_history[view_layer]
|
||||
if view_layer in internals.qcd_history:
|
||||
del internals.qcd_history[view_layer]
|
||||
qab.clear()
|
||||
|
||||
return {'FINISHED'}
|
||||
|
@ -496,18 +478,16 @@ class MoveToQCDSlot(Operator):
|
|||
toggle: BoolProperty()
|
||||
|
||||
def execute(self, context):
|
||||
global qcd_slots
|
||||
global layer_collections
|
||||
|
||||
selected_objects = get_move_selection()
|
||||
active_object = get_move_active()
|
||||
internals.move_triggered = True
|
||||
|
||||
qcd_laycol = None
|
||||
slot_name = qcd_slots.get_name(self.slot)
|
||||
slot_name = internals.qcd_slots.get_name(self.slot)
|
||||
|
||||
if slot_name:
|
||||
qcd_laycol = layer_collections[slot_name]["ptr"]
|
||||
qcd_laycol = internals.layer_collections[slot_name]["ptr"]
|
||||
|
||||
else:
|
||||
return {'CANCELLED'}
|
||||
|
@ -543,7 +523,7 @@ class MoveToQCDSlot(Operator):
|
|||
qcd_laycol.collection.objects.link(obj)
|
||||
|
||||
for collection in obj.users_collection:
|
||||
qcd_idx = qcd_slots.get_idx(collection.name)
|
||||
qcd_idx = internals.qcd_slots.get_idx(collection.name)
|
||||
if qcd_idx != self.slot:
|
||||
collection.objects.unlink(obj)
|
||||
|
||||
|
@ -571,12 +551,8 @@ class ViewMoveQCDSlot(Operator):
|
|||
|
||||
@classmethod
|
||||
def description(cls, context, properties):
|
||||
global qcd_slots
|
||||
|
||||
slot_name = qcd_slots.get_name(properties.slot)
|
||||
|
||||
slot_string = f"QCD Slot {properties.slot}: \"{slot_name}\"\n"
|
||||
|
||||
hotkey_string = (
|
||||
" * LMB - Isolate slot.\n"
|
||||
" * Shift+LMB - Toggle slot.\n"
|
||||
|
@ -589,9 +565,6 @@ class ViewMoveQCDSlot(Operator):
|
|||
return f"{slot_string}{hotkey_string}"
|
||||
|
||||
def invoke(self, context, event):
|
||||
global layer_collections
|
||||
global qcd_history
|
||||
|
||||
modifiers = get_modifiers(event)
|
||||
|
||||
if modifiers == {"shift"}:
|
||||
|
@ -606,7 +579,7 @@ class ViewMoveQCDSlot(Operator):
|
|||
elif modifiers == {"alt"}:
|
||||
select_collection_objects(
|
||||
is_master_collection=False,
|
||||
collection_name=qcd_slots.get_name(self.slot),
|
||||
collection_name=internals.qcd_slots.get_name(self.slot),
|
||||
replace=True,
|
||||
nested=False
|
||||
)
|
||||
|
@ -614,7 +587,7 @@ class ViewMoveQCDSlot(Operator):
|
|||
elif modifiers == {"alt", "shift"}:
|
||||
select_collection_objects(
|
||||
is_master_collection=False,
|
||||
collection_name=qcd_slots.get_name(self.slot),
|
||||
collection_name=internals.qcd_slots.get_name(self.slot),
|
||||
replace=False,
|
||||
nested=False
|
||||
)
|
||||
|
@ -634,15 +607,11 @@ class ViewQCDSlot(Operator):
|
|||
toggle: BoolProperty()
|
||||
|
||||
def execute(self, context):
|
||||
global qcd_slots
|
||||
global layer_collections
|
||||
global rto_history
|
||||
|
||||
qcd_laycol = None
|
||||
slot_name = qcd_slots.get_name(self.slot)
|
||||
slot_name = internals.qcd_slots.get_name(self.slot)
|
||||
|
||||
if slot_name:
|
||||
qcd_laycol = layer_collections[slot_name]["ptr"]
|
||||
qcd_laycol = internals.layer_collections[slot_name]["ptr"]
|
||||
|
||||
else:
|
||||
return {'CANCELLED'}
|
||||
|
@ -663,7 +632,7 @@ class ViewQCDSlot(Operator):
|
|||
|
||||
else:
|
||||
# exclude all collections
|
||||
for laycol in layer_collections.values():
|
||||
for laycol in internals.layer_collections.values():
|
||||
if laycol["name"] != qcd_laycol.name:
|
||||
# prevent exclusion if locked objects in this collection
|
||||
if set(locked.objs).isdisjoint(laycol["ptr"].collection.objects):
|
||||
|
@ -702,10 +671,10 @@ class ViewQCDSlot(Operator):
|
|||
update_qcd_header()
|
||||
|
||||
view_layer = context.view_layer.name
|
||||
if view_layer in rto_history["exclude"]:
|
||||
del rto_history["exclude"][view_layer]
|
||||
if view_layer in rto_history["exclude_all"]:
|
||||
del rto_history["exclude_all"][view_layer]
|
||||
if view_layer in internals.rto_history["exclude"]:
|
||||
del internals.rto_history["exclude"][view_layer]
|
||||
if view_layer in internals.rto_history["exclude_all"]:
|
||||
del internals.rto_history["exclude_all"][view_layer]
|
||||
|
||||
|
||||
return {'FINISHED'}
|
||||
|
@ -724,8 +693,6 @@ class RenumerateQCDSlots(Operator):
|
|||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
global qcd_slots
|
||||
|
||||
modifiers = get_modifiers(event)
|
||||
|
||||
beginning = False
|
||||
|
@ -741,7 +708,7 @@ class RenumerateQCDSlots(Operator):
|
|||
if 'shift' in modifiers:
|
||||
constrain=True
|
||||
|
||||
qcd_slots.renumerate(beginning=beginning,
|
||||
internals.qcd_slots.renumerate(beginning=beginning,
|
||||
depth_first=depth_first,
|
||||
constrain=constrain)
|
||||
|
||||
|
|
|
@ -32,20 +32,11 @@ from bpy.props import (
|
|||
StringProperty,
|
||||
)
|
||||
|
||||
# For VARS
|
||||
from . import internals
|
||||
|
||||
# For FUNCTIONS
|
||||
from .internals import (
|
||||
collection_tree,
|
||||
collection_state,
|
||||
qcd_collection_state,
|
||||
expanded,
|
||||
get_max_lvl,
|
||||
layer_collections,
|
||||
rto_history,
|
||||
qcd_history,
|
||||
expand_history,
|
||||
phantom_history,
|
||||
copy_buffer,
|
||||
swap_buffer,
|
||||
qcd_slots,
|
||||
update_collection_tree,
|
||||
update_property_group,
|
||||
generate_state,
|
||||
|
@ -128,14 +119,14 @@ class CollectionManager(Operator):
|
|||
collapse_sec.alignment = 'LEFT'
|
||||
collapse_sec.enabled = False
|
||||
|
||||
if len(expanded) > 0:
|
||||
if len(internals.expanded) > 0:
|
||||
text = "Collapse All Items"
|
||||
else:
|
||||
text = "Expand All Items"
|
||||
|
||||
collapse_sec.operator("view3d.expand_all_items", text=text)
|
||||
|
||||
for laycol in collection_tree:
|
||||
for laycol in internals.collection_tree:
|
||||
if laycol["has_children"]:
|
||||
collapse_sec.enabled = True
|
||||
break
|
||||
|
@ -214,16 +205,16 @@ class CollectionManager(Operator):
|
|||
copy_swap_icon = 'SELECT_INTERSECT'
|
||||
|
||||
if cm.show_exclude:
|
||||
exclude_all_history = rto_history["exclude_all"].get(view_layer.name, [])
|
||||
exclude_all_history = internals.rto_history["exclude_all"].get(view_layer.name, [])
|
||||
depress = True if len(exclude_all_history) else False
|
||||
icon = 'CHECKBOX_HLT'
|
||||
buffers = [False, False]
|
||||
|
||||
if copy_buffer["RTO"] == "exclude":
|
||||
if internals.copy_buffer["RTO"] == "exclude":
|
||||
icon = copy_icon
|
||||
buffers[0] = True
|
||||
|
||||
if swap_buffer["A"]["RTO"] == "exclude":
|
||||
if internals.swap_buffer["A"]["RTO"] == "exclude":
|
||||
icon = swap_icon
|
||||
buffers[1] = True
|
||||
|
||||
|
@ -233,16 +224,16 @@ class CollectionManager(Operator):
|
|||
global_rto_row.operator("view3d.un_exclude_all_collections", text="", icon=icon, depress=depress)
|
||||
|
||||
if cm.show_selectable:
|
||||
select_all_history = rto_history["select_all"].get(view_layer.name, [])
|
||||
select_all_history = internals.rto_history["select_all"].get(view_layer.name, [])
|
||||
depress = True if len(select_all_history) else False
|
||||
icon = 'RESTRICT_SELECT_OFF'
|
||||
buffers = [False, False]
|
||||
|
||||
if copy_buffer["RTO"] == "select":
|
||||
if internals.copy_buffer["RTO"] == "select":
|
||||
icon = copy_icon
|
||||
buffers[0] = True
|
||||
|
||||
if swap_buffer["A"]["RTO"] == "select":
|
||||
if internals.swap_buffer["A"]["RTO"] == "select":
|
||||
icon = swap_icon
|
||||
buffers[1] = True
|
||||
|
||||
|
@ -252,16 +243,16 @@ class CollectionManager(Operator):
|
|||
global_rto_row.operator("view3d.un_restrict_select_all_collections", text="", icon=icon, depress=depress)
|
||||
|
||||
if cm.show_hide_viewport:
|
||||
hide_all_history = rto_history["hide_all"].get(view_layer.name, [])
|
||||
hide_all_history = internals.rto_history["hide_all"].get(view_layer.name, [])
|
||||
depress = True if len(hide_all_history) else False
|
||||
icon = 'HIDE_OFF'
|
||||
buffers = [False, False]
|
||||
|
||||
if copy_buffer["RTO"] == "hide":
|
||||
if internals.copy_buffer["RTO"] == "hide":
|
||||
icon = copy_icon
|
||||
buffers[0] = True
|
||||
|
||||
if swap_buffer["A"]["RTO"] == "hide":
|
||||
if internals.swap_buffer["A"]["RTO"] == "hide":
|
||||
icon = swap_icon
|
||||
buffers[1] = True
|
||||
|
||||
|
@ -271,16 +262,16 @@ class CollectionManager(Operator):
|
|||
global_rto_row.operator("view3d.un_hide_all_collections", text="", icon=icon, depress=depress)
|
||||
|
||||
if cm.show_disable_viewport:
|
||||
disable_all_history = rto_history["disable_all"].get(view_layer.name, [])
|
||||
disable_all_history = internals.rto_history["disable_all"].get(view_layer.name, [])
|
||||
depress = True if len(disable_all_history) else False
|
||||
icon = 'RESTRICT_VIEW_OFF'
|
||||
buffers = [False, False]
|
||||
|
||||
if copy_buffer["RTO"] == "disable":
|
||||
if internals.copy_buffer["RTO"] == "disable":
|
||||
icon = copy_icon
|
||||
buffers[0] = True
|
||||
|
||||
if swap_buffer["A"]["RTO"] == "disable":
|
||||
if internals.swap_buffer["A"]["RTO"] == "disable":
|
||||
icon = swap_icon
|
||||
buffers[1] = True
|
||||
|
||||
|
@ -290,16 +281,16 @@ class CollectionManager(Operator):
|
|||
global_rto_row.operator("view3d.un_disable_viewport_all_collections", text="", icon=icon, depress=depress)
|
||||
|
||||
if cm.show_render:
|
||||
render_all_history = rto_history["render_all"].get(view_layer.name, [])
|
||||
render_all_history = internals.rto_history["render_all"].get(view_layer.name, [])
|
||||
depress = True if len(render_all_history) else False
|
||||
icon = 'RESTRICT_RENDER_OFF'
|
||||
buffers = [False, False]
|
||||
|
||||
if copy_buffer["RTO"] == "render":
|
||||
if internals.copy_buffer["RTO"] == "render":
|
||||
icon = copy_icon
|
||||
buffers[0] = True
|
||||
|
||||
if swap_buffer["A"]["RTO"] == "render":
|
||||
if internals.swap_buffer["A"]["RTO"] == "render":
|
||||
icon = swap_icon
|
||||
buffers[1] = True
|
||||
|
||||
|
@ -309,16 +300,16 @@ class CollectionManager(Operator):
|
|||
global_rto_row.operator("view3d.un_disable_render_all_collections", text="", icon=icon, depress=depress)
|
||||
|
||||
if cm.show_holdout:
|
||||
holdout_all_history = rto_history["holdout_all"].get(view_layer.name, [])
|
||||
holdout_all_history = internals.rto_history["holdout_all"].get(view_layer.name, [])
|
||||
depress = True if len(holdout_all_history) else False
|
||||
icon = 'HOLDOUT_ON'
|
||||
buffers = [False, False]
|
||||
|
||||
if copy_buffer["RTO"] == "holdout":
|
||||
if internals.copy_buffer["RTO"] == "holdout":
|
||||
icon = copy_icon
|
||||
buffers[0] = True
|
||||
|
||||
if swap_buffer["A"]["RTO"] == "holdout":
|
||||
if internals.swap_buffer["A"]["RTO"] == "holdout":
|
||||
icon = swap_icon
|
||||
buffers[1] = True
|
||||
|
||||
|
@ -328,16 +319,16 @@ class CollectionManager(Operator):
|
|||
global_rto_row.operator("view3d.un_holdout_all_collections", text="", icon=icon, depress=depress)
|
||||
|
||||
if cm.show_indirect_only:
|
||||
indirect_all_history = rto_history["indirect_all"].get(view_layer.name, [])
|
||||
indirect_all_history = internals.rto_history["indirect_all"].get(view_layer.name, [])
|
||||
depress = True if len(indirect_all_history) else False
|
||||
icon = 'INDIRECT_ONLY_ON'
|
||||
buffers = [False, False]
|
||||
|
||||
if copy_buffer["RTO"] == "indirect":
|
||||
if internals.copy_buffer["RTO"] == "indirect":
|
||||
icon = copy_icon
|
||||
buffers[0] = True
|
||||
|
||||
if swap_buffer["A"]["RTO"] == "indirect":
|
||||
if internals.swap_buffer["A"]["RTO"] == "indirect":
|
||||
icon = swap_icon
|
||||
buffers[1] = True
|
||||
|
||||
|
@ -397,57 +388,57 @@ class CollectionManager(Operator):
|
|||
cm.cm_list_index = -1
|
||||
|
||||
# check if expanded & history/buffer state still correct
|
||||
if collection_state:
|
||||
if internals.collection_state:
|
||||
new_state = generate_state()
|
||||
|
||||
if new_state["name"] != collection_state["name"]:
|
||||
copy_buffer["RTO"] = ""
|
||||
copy_buffer["values"].clear()
|
||||
if new_state["name"] != internals.collection_state["name"]:
|
||||
internals.copy_buffer["RTO"] = ""
|
||||
internals.copy_buffer["values"].clear()
|
||||
|
||||
swap_buffer["A"]["RTO"] = ""
|
||||
swap_buffer["A"]["values"].clear()
|
||||
swap_buffer["B"]["RTO"] = ""
|
||||
swap_buffer["B"]["values"].clear()
|
||||
internals.swap_buffer["A"]["RTO"] = ""
|
||||
internals.swap_buffer["A"]["values"].clear()
|
||||
internals.swap_buffer["B"]["RTO"] = ""
|
||||
internals.swap_buffer["B"]["values"].clear()
|
||||
|
||||
for name in list(expanded):
|
||||
laycol = layer_collections.get(name)
|
||||
for name in list(internals.expanded):
|
||||
laycol = internals.layer_collections.get(name)
|
||||
if not laycol or not laycol["has_children"]:
|
||||
expanded.remove(name)
|
||||
internals.expanded.remove(name)
|
||||
|
||||
for name in list(expand_history["history"]):
|
||||
laycol = layer_collections.get(name)
|
||||
for name in list(internals.expand_history["history"]):
|
||||
laycol = internals.layer_collections.get(name)
|
||||
if not laycol or not laycol["has_children"]:
|
||||
expand_history["history"].remove(name)
|
||||
internals.expand_history["history"].remove(name)
|
||||
|
||||
for rto, history in rto_history.items():
|
||||
for rto, history in internals.rto_history.items():
|
||||
if view_layer.name in history:
|
||||
del history[view_layer.name]
|
||||
|
||||
|
||||
else:
|
||||
for rto in ["exclude", "select", "hide", "disable", "render", "holdout", "indirect"]:
|
||||
if new_state[rto] != collection_state[rto]:
|
||||
if view_layer.name in rto_history[rto]:
|
||||
del rto_history[rto][view_layer.name]
|
||||
if new_state[rto] != internals.collection_state[rto]:
|
||||
if view_layer.name in internals.rto_history[rto]:
|
||||
del internals.rto_history[rto][view_layer.name]
|
||||
|
||||
if view_layer.name in rto_history[rto+"_all"]:
|
||||
del rto_history[rto+"_all"][view_layer.name]
|
||||
if view_layer.name in internals.rto_history[rto+"_all"]:
|
||||
del internals.rto_history[rto+"_all"][view_layer.name]
|
||||
|
||||
# check if in phantom mode and if it's still viable
|
||||
if cm.in_phantom_mode:
|
||||
if layer_collections.keys() != phantom_history["initial_state"].keys():
|
||||
if internals.layer_collections.keys() != internals.phantom_history["initial_state"].keys():
|
||||
cm.in_phantom_mode = False
|
||||
|
||||
if view_layer.name != phantom_history["view_layer"]:
|
||||
if view_layer.name != internals.phantom_history["view_layer"]:
|
||||
cm.in_phantom_mode = False
|
||||
|
||||
if not cm.in_phantom_mode:
|
||||
for key, value in phantom_history.items():
|
||||
for key, value in internals.phantom_history.items():
|
||||
try:
|
||||
value.clear()
|
||||
except AttributeError:
|
||||
if key == "view_layer":
|
||||
phantom_history["view_layer"] = ""
|
||||
internals.phantom_history["view_layer"] = ""
|
||||
|
||||
# handle window sizing
|
||||
max_width = 960
|
||||
|
@ -456,14 +447,13 @@ class CollectionManager(Operator):
|
|||
width_step = 21
|
||||
qcd_width = 30
|
||||
scrollbar_width = 21
|
||||
lvl = get_max_lvl()
|
||||
|
||||
width = min_width + row_indent_width + (width_step * lvl)
|
||||
width = min_width + row_indent_width + (width_step * internals.max_lvl)
|
||||
|
||||
if bpy.context.preferences.addons[__package__].preferences.enable_qcd:
|
||||
width += qcd_width
|
||||
|
||||
if len(layer_collections) > 14:
|
||||
if len(internals.layer_collections) > 14:
|
||||
width += scrollbar_width
|
||||
|
||||
if width > max_width:
|
||||
|
@ -472,14 +462,12 @@ class CollectionManager(Operator):
|
|||
return wm.invoke_popup(self, width=width)
|
||||
|
||||
def __del__(self):
|
||||
global collection_state
|
||||
|
||||
if not self.window_open:
|
||||
# prevent destructor execution when changing templates
|
||||
return
|
||||
|
||||
collection_state.clear()
|
||||
collection_state.update(generate_state())
|
||||
internals.collection_state.clear()
|
||||
internals.collection_state.update(generate_state())
|
||||
|
||||
|
||||
class CM_UL_items(UIList):
|
||||
|
@ -527,7 +515,7 @@ class CM_UL_items(UIList):
|
|||
cm = context.scene.collection_manager
|
||||
prefs = context.preferences.addons[__package__].preferences
|
||||
view_layer = context.view_layer
|
||||
laycol = layer_collections[item.name]
|
||||
laycol = internals.layer_collections[item.name]
|
||||
collection = laycol["ptr"].collection
|
||||
selected_objects = CM_UL_items.selected_objects
|
||||
active_object = CM_UL_items.active_object
|
||||
|
@ -555,7 +543,7 @@ class CM_UL_items(UIList):
|
|||
# add expander if collection has children to make UIList act like tree view
|
||||
if laycol["has_children"]:
|
||||
if laycol["expanded"]:
|
||||
highlight = True if expand_history["target"] == item.name else False
|
||||
highlight = True if internals.expand_history["target"] == item.name else False
|
||||
|
||||
prop = row.operator("view3d.expand_sublevel", text="",
|
||||
icon='DISCLOSURE_TRI_DOWN',
|
||||
|
@ -565,7 +553,7 @@ class CM_UL_items(UIList):
|
|||
prop.index = index
|
||||
|
||||
else:
|
||||
highlight = True if expand_history["target"] == item.name else False
|
||||
highlight = True if internals.expand_history["target"] == item.name else False
|
||||
|
||||
prop = row.operator("view3d.expand_sublevel", text="",
|
||||
icon='DISCLOSURE_TRI_RIGHT',
|
||||
|
@ -632,7 +620,7 @@ class CM_UL_items(UIList):
|
|||
|
||||
|
||||
if cm.show_exclude:
|
||||
exclude_history_base = rto_history["exclude"].get(view_layer.name, {})
|
||||
exclude_history_base = internals.rto_history["exclude"].get(view_layer.name, {})
|
||||
exclude_target = exclude_history_base.get("target", "")
|
||||
exclude_history = exclude_history_base.get("history", [])
|
||||
|
||||
|
@ -644,7 +632,7 @@ class CM_UL_items(UIList):
|
|||
prop.name = item.name
|
||||
|
||||
if cm.show_selectable:
|
||||
select_history_base = rto_history["select"].get(view_layer.name, {})
|
||||
select_history_base = internals.rto_history["select"].get(view_layer.name, {})
|
||||
select_target = select_history_base.get("target", "")
|
||||
select_history = select_history_base.get("history", [])
|
||||
|
||||
|
@ -657,7 +645,7 @@ class CM_UL_items(UIList):
|
|||
prop.name = item.name
|
||||
|
||||
if cm.show_hide_viewport:
|
||||
hide_history_base = rto_history["hide"].get(view_layer.name, {})
|
||||
hide_history_base = internals.rto_history["hide"].get(view_layer.name, {})
|
||||
hide_target = hide_history_base.get("target", "")
|
||||
hide_history = hide_history_base.get("history", [])
|
||||
|
||||
|
@ -669,7 +657,7 @@ class CM_UL_items(UIList):
|
|||
prop.name = item.name
|
||||
|
||||
if cm.show_disable_viewport:
|
||||
disable_history_base = rto_history["disable"].get(view_layer.name, {})
|
||||
disable_history_base = internals.rto_history["disable"].get(view_layer.name, {})
|
||||
disable_target = disable_history_base.get("target", "")
|
||||
disable_history = disable_history_base.get("history", [])
|
||||
|
||||
|
@ -682,7 +670,7 @@ class CM_UL_items(UIList):
|
|||
prop.name = item.name
|
||||
|
||||
if cm.show_render:
|
||||
render_history_base = rto_history["render"].get(view_layer.name, {})
|
||||
render_history_base = internals.rto_history["render"].get(view_layer.name, {})
|
||||
render_target = render_history_base.get("target", "")
|
||||
render_history = render_history_base.get("history", [])
|
||||
|
||||
|
@ -695,7 +683,7 @@ class CM_UL_items(UIList):
|
|||
prop.name = item.name
|
||||
|
||||
if cm.show_holdout:
|
||||
holdout_history_base = rto_history["holdout"].get(view_layer.name, {})
|
||||
holdout_history_base = internals.rto_history["holdout"].get(view_layer.name, {})
|
||||
holdout_target = holdout_history_base.get("target", "")
|
||||
holdout_history = holdout_history_base.get("history", [])
|
||||
|
||||
|
@ -708,7 +696,7 @@ class CM_UL_items(UIList):
|
|||
prop.name = item.name
|
||||
|
||||
if cm.show_indirect_only:
|
||||
indirect_history_base = rto_history["indirect"].get(view_layer.name, {})
|
||||
indirect_history_base = internals.rto_history["indirect"].get(view_layer.name, {})
|
||||
indirect_target = indirect_history_base.get("target", "")
|
||||
indirect_history = indirect_history_base.get("history", [])
|
||||
|
||||
|
@ -792,7 +780,7 @@ class CM_UL_items(UIList):
|
|||
new_flt_flags = [0] * len(list_items)
|
||||
|
||||
for idx, item in enumerate(list_items):
|
||||
collection = layer_collections[item.name]["ptr"].collection
|
||||
collection = internals.layer_collections[item.name]["ptr"].collection
|
||||
|
||||
# check if any of the selected objects are in the collection
|
||||
if not set(context.selected_objects).isdisjoint(collection.objects):
|
||||
|
@ -825,7 +813,7 @@ class CM_UL_items(UIList):
|
|||
flt_flags = [0] * len(list_items)
|
||||
|
||||
for idx, item in enumerate(list_items):
|
||||
if layer_collections[item.name]["visible"]:
|
||||
if internals.layer_collections[item.name]["visible"]:
|
||||
flt_flags[idx] = self.bitflag_filter_item
|
||||
|
||||
|
||||
|
@ -930,32 +918,27 @@ class EnableAllQCDSlotsMenu(Menu):
|
|||
|
||||
|
||||
def view3d_header_qcd_slots(self, context):
|
||||
global qcd_collection_state
|
||||
|
||||
update_collection_tree(context)
|
||||
|
||||
view_layer = context.view_layer
|
||||
|
||||
layout = self.layout
|
||||
|
||||
idx = 1
|
||||
|
||||
if qcd_collection_state:
|
||||
if internals.qcd_collection_state:
|
||||
view_layer = context.view_layer
|
||||
new_state = generate_state(qcd=True)
|
||||
|
||||
if (new_state["name"] != qcd_collection_state["name"]
|
||||
or new_state["exclude"] != qcd_collection_state["exclude"]
|
||||
or new_state["exclude"] != qcd_collection_state["exclude"]
|
||||
or new_state["qcd"] != qcd_collection_state["qcd"]):
|
||||
if view_layer.name in qcd_history:
|
||||
del qcd_history[view_layer.name]
|
||||
qcd_collection_state.clear()
|
||||
if (new_state["name"] != internals.qcd_collection_state["name"]
|
||||
or new_state["exclude"] != internals.qcd_collection_state["exclude"]
|
||||
or new_state["qcd"] != internals.qcd_collection_state["qcd"]):
|
||||
if view_layer.name in internals.qcd_history:
|
||||
del internals.qcd_history[view_layer.name]
|
||||
internals.qcd_collection_state.clear()
|
||||
QCDAllBase.clear()
|
||||
|
||||
|
||||
main_row = layout.row(align=True)
|
||||
current_qcd_history = qcd_history.get(context.view_layer.name, [])
|
||||
current_qcd_history = internals.qcd_history.get(context.view_layer.name, [])
|
||||
|
||||
main_row.operator_menu_hold("view3d.enable_all_qcd_slots_meta",
|
||||
text="",
|
||||
|
@ -973,10 +956,10 @@ def view3d_header_qcd_slots(self, context):
|
|||
active_object = get_move_active()
|
||||
|
||||
for x in range(20):
|
||||
qcd_slot_name = qcd_slots.get_name(str(x+1))
|
||||
qcd_slot_name = internals.qcd_slots.get_name(str(x+1))
|
||||
|
||||
if qcd_slot_name:
|
||||
qcd_laycol = layer_collections[qcd_slot_name]["ptr"]
|
||||
qcd_laycol = internals.layer_collections[qcd_slot_name]["ptr"]
|
||||
collection_objects = qcd_laycol.collection.objects
|
||||
|
||||
icon_value = 0
|
||||
|
|
Loading…
Reference in New Issue