parent
805dd4f319
commit
12ba867ee1
@ -7,30 +7,23 @@ from .. import presence
|
|||||||
from .bl_datablock import BlDatablock
|
from .bl_datablock import BlDatablock
|
||||||
from ..libs.replication.replication.constants import UP
|
from ..libs.replication.replication.constants import UP
|
||||||
|
|
||||||
|
|
||||||
class BlUser(BlDatablock):
|
class BlUser(BlDatablock):
|
||||||
def construct(self, name):
|
def construct(self, name):
|
||||||
return presence.User()
|
return presence.User()
|
||||||
|
|
||||||
def load(self, data, target):
|
|
||||||
target.name = data['name']
|
|
||||||
target.location = data['location']
|
|
||||||
target.selected_objects = data['selected_objects']
|
|
||||||
|
|
||||||
utils.dump_anything.load(target, data)
|
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
|
for obj in bpy.data.objects:
|
||||||
if self.pointer:
|
if obj.hide_select and obj.uuid not in self.data['selected_objects']:
|
||||||
self.load(data=self.data, target=self.pointer)
|
obj.hide_select = False
|
||||||
|
elif not obj.hide_select and obj.uuid in self.data['selected_objects']:
|
||||||
|
obj.hide_select = True
|
||||||
|
|
||||||
presence.refresh_3d_view()
|
presence.refresh_3d_view()
|
||||||
|
|
||||||
self.state = UP
|
self.state = UP
|
||||||
|
|
||||||
|
def dump(self, pointer=None):
|
||||||
|
|
||||||
|
|
||||||
def dump(self,pointer=None):
|
|
||||||
data = utils.dump_anything.dump(pointer)
|
data = utils.dump_anything.dump(pointer)
|
||||||
data['location'] = pointer.location
|
data['location'] = pointer.location
|
||||||
data['color'] = pointer.color
|
data['color'] = pointer.color
|
||||||
@ -38,28 +31,18 @@ class BlUser(BlDatablock):
|
|||||||
data['view_matrix'] = pointer.view_matrix
|
data['view_matrix'] = pointer.view_matrix
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.pointer.is_dirty = True
|
self.pointer.is_dirty = True
|
||||||
|
|
||||||
# def diff(self):
|
|
||||||
# if not self.pointer:
|
|
||||||
# return False
|
|
||||||
# if self.pointer.is_dirty:
|
|
||||||
# self.pointer.is_dirty = False
|
|
||||||
# return True
|
|
||||||
|
|
||||||
# for i,coord in enumerate(self.pointer.location):
|
|
||||||
# if coord != self.data['location'][i]:
|
|
||||||
# return True
|
|
||||||
# return False
|
|
||||||
|
|
||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
bl_id = "users"
|
bl_id = "users"
|
||||||
bl_class = presence.User
|
bl_class = presence.User
|
||||||
bl_rep_class = BlUser
|
bl_rep_class = BlUser
|
||||||
bl_delay_refresh = .1
|
bl_delay_refresh = .1
|
||||||
bl_delay_apply = .1
|
bl_delay_apply = .1
|
||||||
bl_automatic_push = True
|
bl_automatic_push = True
|
||||||
bl_icon = 'CON_ARMATURE'
|
bl_icon = 'CON_ARMATURE'
|
||||||
|
@ -74,74 +74,91 @@ class ApplyTimer(Timer):
|
|||||||
try:
|
try:
|
||||||
operators.client.apply(node)
|
operators.client.apply(node)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("fail to apply {}: {}".format(node_ref.uuid,e))
|
logger.error(
|
||||||
|
"fail to apply {}: {}".format(node_ref.uuid, e))
|
||||||
|
|
||||||
|
|
||||||
class DynamicRightSelectTimer(Timer):
|
class DynamicRightSelectTimer(Timer):
|
||||||
def __init__(self, timout=.1):
|
def __init__(self, timout=.1):
|
||||||
super().__init__(timout)
|
super().__init__(timout)
|
||||||
self.last_selection = []
|
self._last_selection = []
|
||||||
|
self._user = None
|
||||||
|
self._user_node = None
|
||||||
|
self._right_strategy = RP_COMMON
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
if operators.client:
|
repo = operators.client
|
||||||
users = operators.client.list(filter=BlUser)
|
if repo:
|
||||||
|
settings = bpy.context.window_manager.session
|
||||||
|
|
||||||
for user in users:
|
# Find user
|
||||||
user_ref = operators.client.get(uuid=user)
|
if self._user is None:
|
||||||
settings = bpy.context.window_manager.session
|
users = repo.list(filter=BlUser)
|
||||||
|
|
||||||
# Local user
|
for user in users:
|
||||||
if user_ref.pointer:
|
user_node = repo.get(uuid=user)
|
||||||
current_selection = utils.get_selected_objects(
|
if user_node.pointer:
|
||||||
bpy.context.scene)
|
self._user = user_node.pointer
|
||||||
if current_selection != self.last_selection:
|
self._user_node = user_node
|
||||||
right_strategy = operators.client.get_config()[
|
|
||||||
'right_strategy']
|
|
||||||
if right_strategy == RP_COMMON:
|
|
||||||
obj_common = [
|
|
||||||
o for o in self.last_selection if o not in current_selection]
|
|
||||||
obj_ours = [
|
|
||||||
o for o in current_selection if o not in self.last_selection]
|
|
||||||
|
|
||||||
# change new selection to our
|
if self._right_strategy is None:
|
||||||
for obj in obj_ours:
|
self._right_strategy = repo.get_config()[
|
||||||
node = operators.client.get(uuid=obj)
|
'right_strategy']
|
||||||
|
|
||||||
if node and node.owner == RP_COMMON:
|
|
||||||
recursive = True
|
|
||||||
if node.data and 'instance_type' in node.data.keys():
|
|
||||||
recursive = node.data['instance_type'] != 'COLLECTION'
|
|
||||||
|
|
||||||
operators.client.change_owner(
|
|
||||||
node.uuid,
|
|
||||||
settings.username,
|
|
||||||
recursive=recursive)
|
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
|
||||||
self.last_selection = current_selection
|
if self._user:
|
||||||
user_ref.pointer.update_selected_objects(
|
current_selection = utils.get_selected_objects(
|
||||||
bpy.context)
|
bpy.context.scene)
|
||||||
user_ref.update()
|
if current_selection != self._last_selection:
|
||||||
|
if self._right_strategy == RP_COMMON:
|
||||||
|
obj_common = [
|
||||||
|
o for o in self._last_selection if o not in current_selection]
|
||||||
|
obj_ours = [
|
||||||
|
o for o in current_selection if o not in self._last_selection]
|
||||||
|
|
||||||
# change old selection right to common
|
# change old selection right to common
|
||||||
for obj in obj_common:
|
for obj in obj_common:
|
||||||
node = operators.client.get(uuid=obj)
|
node = repo.get(uuid=obj)
|
||||||
|
|
||||||
if node and (node.owner == settings.username or node.owner == RP_COMMON):
|
if node and (node.owner == settings.username or node.owner == RP_COMMON):
|
||||||
recursive = True
|
recursive = True
|
||||||
if node.data and 'instance_type' in node.data.keys():
|
if node.data and 'instance_type' in node.data.keys():
|
||||||
recursive = node.data['instance_type'] != 'COLLECTION'
|
recursive = node.data['instance_type'] != 'COLLECTION'
|
||||||
operators.client.change_owner(
|
repo.change_owner(
|
||||||
node.uuid,
|
node.uuid,
|
||||||
RP_COMMON,
|
RP_COMMON,
|
||||||
recursive=recursive)
|
recursive=recursive)
|
||||||
else:
|
|
||||||
for obj in bpy.data.objects:
|
# change new selection to our
|
||||||
if obj.hide_select and obj.uuid not in user_ref.data['selected_objects']:
|
for obj in obj_ours:
|
||||||
obj.hide_select = False
|
node = repo.get(uuid=obj)
|
||||||
elif not obj.hide_select and obj.uuid in user_ref.data['selected_objects']:
|
|
||||||
obj.hide_select = True
|
if node and node.owner == RP_COMMON:
|
||||||
|
recursive = True
|
||||||
|
if node.data and 'instance_type' in node.data.keys():
|
||||||
|
recursive = node.data['instance_type'] != 'COLLECTION'
|
||||||
|
|
||||||
|
repo.change_owner(
|
||||||
|
node.uuid,
|
||||||
|
settings.username,
|
||||||
|
recursive=recursive)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
self._last_selection = current_selection
|
||||||
|
self._user.update_selected_objects(
|
||||||
|
bpy.context)
|
||||||
|
repo.push(self._user_node.uuid)
|
||||||
|
|
||||||
|
# Fix deselection until right managment refactoring (with Roles concepts)
|
||||||
|
if len(current_selection) == 0 and self._right_strategy == RP_COMMON:
|
||||||
|
owned_keys = repo.list(filter_owner=settings.username)
|
||||||
|
for key in owned_keys:
|
||||||
|
node = repo.get(uuid=key)
|
||||||
|
if not isinstance(node, BlUser):
|
||||||
|
repo.change_owner(
|
||||||
|
key,
|
||||||
|
RP_COMMON,
|
||||||
|
recursive=recursive)
|
||||||
|
|
||||||
|
|
||||||
class Draw(Delayable):
|
class Draw(Delayable):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user