refactor: pep8 compliant
This commit is contained in:
@ -10,14 +10,15 @@ bl_info = {
|
|||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import random
|
import random
|
||||||
import sys
|
import sys
|
||||||
import os
|
|
||||||
import bpy
|
import bpy
|
||||||
from . import environment
|
|
||||||
from . import utils
|
|
||||||
from bpy.app.handlers import persistent
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
|
from . import environment, utils
|
||||||
|
|
||||||
DEPENDENCIES = {
|
DEPENDENCIES = {
|
||||||
"zmq",
|
"zmq",
|
||||||
"umsgpack",
|
"umsgpack",
|
||||||
|
21
delayable.py
21
delayable.py
@ -1,12 +1,15 @@
|
|||||||
import bpy
|
import bpy
|
||||||
from .libs.replication.constants import *
|
|
||||||
from .libs import debug
|
|
||||||
from . import operators, utils
|
from . import operators, utils
|
||||||
from .bl_types.bl_user import BlUser
|
from .bl_types.bl_user import BlUser
|
||||||
|
from .libs import debug
|
||||||
|
from .libs.replication.constants import FETCHED
|
||||||
|
|
||||||
|
|
||||||
class Delayable():
|
class Delayable():
|
||||||
"""Delayable task interface
|
"""Delayable task interface
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def register(self):
|
def register(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@ -16,11 +19,13 @@ class Delayable():
|
|||||||
def unregister(self):
|
def unregister(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
class Timer(Delayable):
|
class Timer(Delayable):
|
||||||
"""Timer binder interface for blender
|
"""Timer binder interface for blender
|
||||||
|
|
||||||
Run a bpy.app.Timer in the background looping at the given rate
|
Run a bpy.app.Timer in the background looping at the given rate
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, duration=1):
|
def __init__(self, duration=1):
|
||||||
self._timeout = duration
|
self._timeout = duration
|
||||||
|
|
||||||
@ -42,8 +47,9 @@ class Timer(Delayable):
|
|||||||
except:
|
except:
|
||||||
print("timer already unregistered")
|
print("timer already unregistered")
|
||||||
|
|
||||||
|
|
||||||
class ApplyTimer(Timer):
|
class ApplyTimer(Timer):
|
||||||
def __init__(self, timout=1,target_type=None):
|
def __init__(self, timout=1, target_type=None):
|
||||||
self._type = target_type
|
self._type = target_type
|
||||||
super().__init__(timout)
|
super().__init__(timout)
|
||||||
|
|
||||||
@ -59,13 +65,14 @@ class ApplyTimer(Timer):
|
|||||||
|
|
||||||
return self._timeout
|
return self._timeout
|
||||||
|
|
||||||
|
|
||||||
class Draw(Delayable):
|
class Draw(Delayable):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._handler = None
|
self._handler = None
|
||||||
|
|
||||||
def register(self):
|
def register(self):
|
||||||
self._handler = bpy.types.SpaceView3D.draw_handler_add(
|
self._handler = bpy.types.SpaceView3D.draw_handler_add(
|
||||||
self.execute,(), 'WINDOW', 'POST_VIEW')
|
self.execute, (), 'WINDOW', 'POST_VIEW')
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
@ -73,10 +80,11 @@ class Draw(Delayable):
|
|||||||
def unregister(self):
|
def unregister(self):
|
||||||
try:
|
try:
|
||||||
bpy.types.SpaceView3D.draw_handler_remove(
|
bpy.types.SpaceView3D.draw_handler_remove(
|
||||||
self._handler, "WINDOW")
|
self._handler, "WINDOW")
|
||||||
except:
|
except:
|
||||||
print("draw already unregistered")
|
print("draw already unregistered")
|
||||||
|
|
||||||
|
|
||||||
class ClientUpdate(Draw):
|
class ClientUpdate(Draw):
|
||||||
def __init__(self, client_uuid=None):
|
def __init__(self, client_uuid=None):
|
||||||
assert(client_uuid)
|
assert(client_uuid)
|
||||||
@ -84,9 +92,8 @@ class ClientUpdate(Draw):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
if hasattr(operators,"client") and self._client_uuid:
|
if hasattr(operators, "client") and self._client_uuid:
|
||||||
client = operators.client.get(self._client_uuid)
|
client = operators.client.get(self._client_uuid)
|
||||||
|
|
||||||
if client:
|
if client:
|
||||||
client.pointer.update_location()
|
client.pointer.update_location()
|
||||||
|
|
||||||
|
@ -39,27 +39,28 @@ DEFAULT_CONFIG = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ORDERED_TYPES = [
|
ORDERED_TYPES = [
|
||||||
'Image',
|
'Image',
|
||||||
'Texture',
|
'Texture',
|
||||||
'Curve',
|
'Curve',
|
||||||
'Material',
|
'Material',
|
||||||
'Light',
|
'Light',
|
||||||
'SunLight',
|
'SunLight',
|
||||||
'SpotLight',
|
'SpotLight',
|
||||||
'AreaLight',
|
'AreaLight',
|
||||||
'PointLight',
|
'PointLight',
|
||||||
'Camera',
|
'Camera',
|
||||||
'Mesh',
|
'Mesh',
|
||||||
'Armature',
|
'Armature',
|
||||||
'GreasePencil',
|
'GreasePencil',
|
||||||
'Object',
|
'Object',
|
||||||
'Action',
|
'Action',
|
||||||
'Collection',
|
'Collection',
|
||||||
'Scene',
|
'Scene',
|
||||||
]
|
]
|
||||||
|
|
||||||
rtypes = []
|
rtypes = []
|
||||||
|
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
@ -71,6 +72,7 @@ def load_config():
|
|||||||
|
|
||||||
return DEFAULT_CONFIG
|
return DEFAULT_CONFIG
|
||||||
|
|
||||||
|
|
||||||
def get_replicated_types():
|
def get_replicated_types():
|
||||||
config = load_config()
|
config = load_config()
|
||||||
rtpyes = config["replicated_types"]
|
rtpyes = config["replicated_types"]
|
||||||
@ -82,6 +84,7 @@ def get_replicated_types():
|
|||||||
|
|
||||||
return tlist
|
return tlist
|
||||||
|
|
||||||
|
|
||||||
def genererate_replicated_types():
|
def genererate_replicated_types():
|
||||||
rtypes.clear()
|
rtypes.clear()
|
||||||
|
|
||||||
@ -133,7 +136,6 @@ def setup(dependencies, python_path):
|
|||||||
PYTHON_PATH = Path(python_path)
|
PYTHON_PATH = Path(python_path)
|
||||||
SUBPROCESS_DIR = PYTHON_PATH.parent
|
SUBPROCESS_DIR = PYTHON_PATH.parent
|
||||||
|
|
||||||
|
|
||||||
if not module_can_be_imported("pip"):
|
if not module_can_be_imported("pip"):
|
||||||
install_pip()
|
install_pip()
|
||||||
|
|
||||||
|
37
operators.py
37
operators.py
@ -26,6 +26,7 @@ client = None
|
|||||||
delayables = []
|
delayables = []
|
||||||
ui_context = None
|
ui_context = None
|
||||||
|
|
||||||
|
|
||||||
def add_datablock(datablock):
|
def add_datablock(datablock):
|
||||||
global client
|
global client
|
||||||
child = []
|
child = []
|
||||||
@ -35,16 +36,19 @@ def add_datablock(datablock):
|
|||||||
if hasattr(datablock, "materials"):
|
if hasattr(datablock, "materials"):
|
||||||
for mat in datablock.materials:
|
for mat in datablock.materials:
|
||||||
child.append(add_datablock(mat))
|
child.append(add_datablock(mat))
|
||||||
if hasattr(datablock, "collection") and hasattr(datablock.collection, "children"):
|
if hasattr(datablock, "collection") \
|
||||||
for coll in datablock.collection.children:
|
and hasattr(datablock.collection, "children"):
|
||||||
child.append(add_datablock(coll))
|
for coll in datablock.collection.children:
|
||||||
|
child.append(add_datablock(coll))
|
||||||
if hasattr(datablock, "children"):
|
if hasattr(datablock, "children"):
|
||||||
for coll in datablock.children:
|
for coll in datablock.children:
|
||||||
child.append(add_datablock(coll))
|
child.append(add_datablock(coll))
|
||||||
if hasattr(datablock, "objects"):
|
if hasattr(datablock, "objects"):
|
||||||
for obj in datablock.objects:
|
for obj in datablock.objects:
|
||||||
child.append(add_datablock(obj))
|
child.append(add_datablock(obj))
|
||||||
if hasattr(datablock,'uuid') and datablock.uuid and client.exist(datablock.uuid):
|
if hasattr(datablock, 'uuid') \
|
||||||
|
and datablock.uuid \
|
||||||
|
and client.exist(datablock.uuid):
|
||||||
return datablock.uuid
|
return datablock.uuid
|
||||||
else:
|
else:
|
||||||
new_uuid = client.add(datablock, childs=child)
|
new_uuid = client.add(datablock, childs=child)
|
||||||
@ -62,7 +66,6 @@ def init_supported_datablocks(supported_types_id):
|
|||||||
add_datablock(item)
|
add_datablock(item)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# OPERATORS
|
# OPERATORS
|
||||||
class SessionStartOperator(bpy.types.Operator):
|
class SessionStartOperator(bpy.types.Operator):
|
||||||
bl_idname = "session.start"
|
bl_idname = "session.start"
|
||||||
@ -94,10 +97,16 @@ class SessionStartOperator(bpy.types.Operator):
|
|||||||
_type = getattr(bl_types, type)
|
_type = getattr(bl_types, type)
|
||||||
supported_bl_types.append(_type.bl_id)
|
supported_bl_types.append(_type.bl_id)
|
||||||
|
|
||||||
bpy_factory.register_type(_type.bl_class, _type.bl_rep_class, timer=_type.bl_delay_refresh,automatic=True)
|
bpy_factory.register_type(
|
||||||
|
_type.bl_class,
|
||||||
|
_type.bl_rep_class,
|
||||||
|
timer=_type.bl_delay_refresh,
|
||||||
|
automatic=True)
|
||||||
|
|
||||||
if _type.bl_delay_apply > 0:
|
if _type.bl_delay_apply > 0:
|
||||||
delayables.append(delayable.ApplyTimer(timout=_type.bl_delay_apply,target_type=_type.bl_rep_class))
|
delayables.append(delayable.ApplyTimer(
|
||||||
|
timout=_type.bl_delay_apply,
|
||||||
|
target_type=_type.bl_rep_class))
|
||||||
|
|
||||||
client = Client(factory=bpy_factory)
|
client = Client(factory=bpy_factory)
|
||||||
|
|
||||||
@ -120,13 +129,14 @@ class SessionStartOperator(bpy.types.Operator):
|
|||||||
usr = presence.User(
|
usr = presence.User(
|
||||||
username=settings.username,
|
username=settings.username,
|
||||||
color=(settings.client_color.r,
|
color=(settings.client_color.r,
|
||||||
settings.client_color.g,
|
settings.client_color.g,
|
||||||
settings.client_color.b,
|
settings.client_color.b,
|
||||||
1),
|
1),
|
||||||
)
|
)
|
||||||
|
|
||||||
settings.user_uuid = client.add(usr)
|
settings.user_uuid = client.add(usr)
|
||||||
delayables.append(delayable.ClientUpdate(client_uuid=settings.user_uuid))
|
delayables.append(delayable.ClientUpdate(
|
||||||
|
client_uuid=settings.user_uuid))
|
||||||
|
|
||||||
# Push all added values
|
# Push all added values
|
||||||
client.push()
|
client.push()
|
||||||
@ -216,8 +226,7 @@ class SessionPropertyRightOperator(bpy.types.Operator):
|
|||||||
global client
|
global client
|
||||||
|
|
||||||
if client:
|
if client:
|
||||||
client.right(self.key,settings.clients)
|
client.right(self.key, settings.clients)
|
||||||
|
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
@ -247,8 +256,6 @@ class SessionSnapUserOperator(bpy.types.Operator):
|
|||||||
|
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class SessionApply(bpy.types.Operator):
|
class SessionApply(bpy.types.Operator):
|
||||||
bl_idname = "session.apply"
|
bl_idname = "session.apply"
|
||||||
|
43
presence.py
43
presence.py
@ -17,6 +17,7 @@ from gpu_extras.batch import batch_for_shader
|
|||||||
|
|
||||||
global renderer
|
global renderer
|
||||||
|
|
||||||
|
|
||||||
def view3d_find():
|
def view3d_find():
|
||||||
for area in bpy.data.window_managers[0].windows[0].screen.areas:
|
for area in bpy.data.window_managers[0].windows[0].screen.areas:
|
||||||
if area.type == 'VIEW_3D':
|
if area.type == 'VIEW_3D':
|
||||||
@ -74,7 +75,7 @@ def get_client_cam_points():
|
|||||||
v6 = list(rv3d.view_location)
|
v6 = list(rv3d.view_location)
|
||||||
v7 = get_target_far(region, rv3d, (width/2, height/2), -.8)
|
v7 = get_target_far(region, rv3d, (width/2, height/2), -.8)
|
||||||
|
|
||||||
coords = [v1,v2,v3,v4,v5,v6,v7]
|
coords = [v1, v2, v3, v4, v5, v6, v7]
|
||||||
|
|
||||||
return coords
|
return coords
|
||||||
|
|
||||||
@ -86,11 +87,12 @@ def get_client_2d(coords):
|
|||||||
else:
|
else:
|
||||||
return (0, 0)
|
return (0, 0)
|
||||||
|
|
||||||
|
|
||||||
class User():
|
class User():
|
||||||
def __init__(self, username=None, color=(0,0,0,1)):
|
def __init__(self, username=None, color=(0, 0, 0, 1)):
|
||||||
self.name = username
|
self.name = username
|
||||||
self.color = color
|
self.color = color
|
||||||
self.location = [[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
|
self.location = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
|
||||||
self.active_object = ""
|
self.active_object = ""
|
||||||
|
|
||||||
def update_location(self):
|
def update_location(self):
|
||||||
@ -101,9 +103,7 @@ class User():
|
|||||||
if current_coords:
|
if current_coords:
|
||||||
self.location = list(current_coords)
|
self.location = list(current_coords)
|
||||||
|
|
||||||
|
def update_client_selected_object(self, context):
|
||||||
|
|
||||||
def update_client_selected_object(self,context):
|
|
||||||
session = bpy.context.window_manager.session
|
session = bpy.context.window_manager.session
|
||||||
username = bpy.context.window_manager.session.username
|
username = bpy.context.window_manager.session.username
|
||||||
# client_data = client.get(client_key)
|
# client_data = client.get(client_key)
|
||||||
@ -123,8 +123,6 @@ class User():
|
|||||||
client.set(client_key, client_data[0][1])
|
client.set(client_key, client_data[0][1])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DrawFactory(object):
|
class DrawFactory(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -136,12 +134,12 @@ class DrawFactory(object):
|
|||||||
self.coords = None
|
self.coords = None
|
||||||
self.active_object = None
|
self.active_object = None
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.register_handlers()
|
self.register_handlers()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.unregister_handlers()
|
self.unregister_handlers()
|
||||||
|
|
||||||
def register_handlers(self):
|
def register_handlers(self):
|
||||||
self.draw3d_handle = bpy.types.SpaceView3D.draw_handler_add(
|
self.draw3d_handle = bpy.types.SpaceView3D.draw_handler_add(
|
||||||
self.draw3d_callback, (), 'WINDOW', 'POST_VIEW')
|
self.draw3d_callback, (), 'WINDOW', 'POST_VIEW')
|
||||||
@ -184,43 +182,39 @@ class DrawFactory(object):
|
|||||||
(0, 4), (1, 5), (2, 6), (3, 7)
|
(0, 4), (1, 5), (2, 6), (3, 7)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if select_ob in bpy.data.objects.keys():
|
if select_ob in bpy.data.objects.keys():
|
||||||
ob = bpy.data.objects[select_ob]
|
ob = bpy.data.objects[select_ob]
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
bbox_corners = [ob.matrix_world @ mathutils.Vector(corner) for corner in ob.bound_box]
|
bbox_corners = [ob.matrix_world @ mathutils.Vector(
|
||||||
|
corner) for corner in ob.bound_box]
|
||||||
|
|
||||||
coords = [(point.x, point.y, point.z)
|
coords = [(point.x, point.y, point.z)
|
||||||
for point in bbox_corners]
|
for point in bbox_corners]
|
||||||
|
|
||||||
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
||||||
|
|
||||||
color = client['color']
|
color = client['color']
|
||||||
|
|
||||||
batch = batch_for_shader(
|
batch = batch_for_shader(
|
||||||
shader, 'LINES', {"pos": coords}, indices=indices)
|
shader, 'LINES', {"pos": coords}, indices=indices)
|
||||||
|
drawable_key = "{}/{}".format(client['id'], select_ob)
|
||||||
|
|
||||||
self.d3d_items["{}/{}".format(client['id'],
|
self.d3d_items[drawable_key] = (shader, batch, color)
|
||||||
select_ob)] = (shader, batch, color)
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def draw_client_camera(self,client_uuid, client_location, client_color):
|
def draw_client_camera(self, client_uuid, client_location, client_color):
|
||||||
if client_location:
|
if client_location:
|
||||||
local_username = bpy.context.window_manager.session.username
|
local_username = bpy.context.window_manager.session.username
|
||||||
|
|
||||||
try:
|
try:
|
||||||
indices = (
|
indices = (
|
||||||
(1, 3), (2, 1), (3, 0), (2, 0),(4,5),(1, 6), (2, 6), (3, 6), (0, 6)
|
(1, 3), (2, 1), (3, 0),
|
||||||
|
(2, 0), (4, 5), (1, 6),
|
||||||
|
(2, 6), (3, 6), (0, 6)
|
||||||
)
|
)
|
||||||
|
|
||||||
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
||||||
position = [tuple(coord) for coord in client_location]
|
position = [tuple(coord) for coord in client_location]
|
||||||
color = client_color
|
color = client_color
|
||||||
|
|
||||||
|
|
||||||
batch = batch_for_shader(
|
batch = batch_for_shader(
|
||||||
shader, 'LINES', {"pos": position}, indices=indices)
|
shader, 'LINES', {"pos": position}, indices=indices)
|
||||||
|
|
||||||
@ -237,7 +231,7 @@ class DrawFactory(object):
|
|||||||
shader.bind()
|
shader.bind()
|
||||||
shader.uniform_float("color", color)
|
shader.uniform_float("color", color)
|
||||||
batch.draw(shader)
|
batch.draw(shader)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print("3D Exception")
|
print("3D Exception")
|
||||||
|
|
||||||
def draw2d_callback(self):
|
def draw2d_callback(self):
|
||||||
@ -251,9 +245,10 @@ class DrawFactory(object):
|
|||||||
blf.color(0, color[0], color[1], color[2], color[3])
|
blf.color(0, color[0], color[1], color[2], color[3])
|
||||||
blf.draw(0, font)
|
blf.draw(0, font)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print("2D EXCEPTION")
|
print("2D EXCEPTION")
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
global renderer
|
global renderer
|
||||||
renderer = DrawFactory()
|
renderer = DrawFactory()
|
||||||
|
88
ui.py
88
ui.py
@ -1,15 +1,16 @@
|
|||||||
import bpy
|
import bpy
|
||||||
from . import operators
|
from . import operators
|
||||||
from .libs.replication.constants import *
|
from .libs.replication.constants import FETCHED, ERROR
|
||||||
from .bl_types.bl_user import BlUser
|
from .bl_types.bl_user import BlUser
|
||||||
|
|
||||||
|
|
||||||
PROP_STATES = [ 'KEYTYPE_BREAKDOWN_VEC',
|
PROP_STATES = ['KEYTYPE_BREAKDOWN_VEC',
|
||||||
'KEYTYPE_BREAKDOWN_VEC',
|
'KEYTYPE_BREAKDOWN_VEC',
|
||||||
'KEYTYPE_KEYFRAME_VEC',
|
'KEYTYPE_KEYFRAME_VEC',
|
||||||
'KEYTYPE_KEYFRAME_VEC',
|
'KEYTYPE_KEYFRAME_VEC',
|
||||||
'KEYTYPE_JITTER_VEC',
|
'KEYTYPE_JITTER_VEC',
|
||||||
'KEYTYPE_KEYFRAME_VEC']
|
'KEYTYPE_KEYFRAME_VEC']
|
||||||
|
|
||||||
|
|
||||||
class SESSION_PT_settings(bpy.types.Panel):
|
class SESSION_PT_settings(bpy.types.Panel):
|
||||||
"""Settings panel"""
|
"""Settings panel"""
|
||||||
@ -22,18 +23,15 @@ class SESSION_PT_settings(bpy.types.Panel):
|
|||||||
def draw_header(self, context):
|
def draw_header(self, context):
|
||||||
self.layout.label(text="", icon='TOOL_SETTINGS')
|
self.layout.label(text="", icon='TOOL_SETTINGS')
|
||||||
|
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
layout.use_property_split = True
|
layout.use_property_split = True
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
if hasattr(context.window_manager, 'session'):
|
|
||||||
settings = context.window_manager.session
|
|
||||||
window_manager = context.window_manager
|
|
||||||
|
|
||||||
|
if hasattr(context.window_manager, 'session'):
|
||||||
# STATE INITIAL
|
# STATE INITIAL
|
||||||
if not operators.client or (operators.client and operators.client.state == 0):
|
if not operators.client \
|
||||||
|
or (operators.client and operators.client.state == 0):
|
||||||
pass
|
pass
|
||||||
# REPLICATION SETTINGS
|
# REPLICATION SETTINGS
|
||||||
# row = layout.row()
|
# row = layout.row()
|
||||||
@ -47,8 +45,8 @@ class SESSION_PT_settings(bpy.types.Panel):
|
|||||||
# row.prop(item, "is_replicated", text="")
|
# row.prop(item, "is_replicated", text="")
|
||||||
# row = box.row()
|
# row = box.row()
|
||||||
else:
|
else:
|
||||||
# STATE ACTIVE
|
# STATE ACTIVE
|
||||||
if operators.client.state == 2:
|
if operators.client.state == 2:
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.operator("session.stop", icon='QUIT', text="Exit")
|
row.operator("session.stop", icon='QUIT', text="Exit")
|
||||||
@ -69,15 +67,17 @@ class SESSION_PT_settings_network(bpy.types.Panel):
|
|||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_category = "Multiuser"
|
bl_category = "Multiuser"
|
||||||
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return not operators.client or (operators.client and operators.client.state == 0)
|
return not operators.client \
|
||||||
|
or (operators.client and operators.client.state == 0)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
settings = context.window_manager.session
|
settings = context.window_manager.session
|
||||||
scene = context.window_manager
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
# USER SETTINGS
|
# USER SETTINGS
|
||||||
row.label(text="draw overlay:")
|
row.label(text="draw overlay:")
|
||||||
@ -107,7 +107,6 @@ class SESSION_PT_settings_network(bpy.types.Panel):
|
|||||||
row.prop(settings, "port", text="")
|
row.prop(settings, "port", text="")
|
||||||
row = box.row()
|
row = box.row()
|
||||||
|
|
||||||
|
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.operator("session.start", text="CONNECT").host = False
|
row.operator("session.start", text="CONNECT").host = False
|
||||||
|
|
||||||
@ -119,15 +118,17 @@ class SESSION_PT_settings_user(bpy.types.Panel):
|
|||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_category = "Multiuser"
|
bl_category = "Multiuser"
|
||||||
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return not operators.client or (operators.client and operators.client.state == 0)
|
return not operators.client \
|
||||||
|
or (operators.client and operators.client.state == 0)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
settings = context.window_manager.session
|
settings = context.window_manager.session
|
||||||
scene = context.window_manager
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
# USER SETTINGS
|
# USER SETTINGS
|
||||||
row.prop(settings, "username", text="id")
|
row.prop(settings, "username", text="id")
|
||||||
@ -144,34 +145,33 @@ class SESSION_PT_user(bpy.types.Panel):
|
|||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_category = "Multiuser"
|
bl_category = "Multiuser"
|
||||||
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return operators.client and operators.client.state == 2
|
return operators.client and operators.client.state == 2
|
||||||
|
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
settings = context.window_manager.session
|
settings = context.window_manager.session
|
||||||
scene = context.window_manager
|
|
||||||
# Create a simple row.
|
# Create a simple row.
|
||||||
col = layout.column(align=True)
|
col = layout.column(align=True)
|
||||||
|
|
||||||
client_keys = operators.client.list(filter=BlUser)
|
client_keys = operators.client.list(filter=BlUser)
|
||||||
if client_keys and len(client_keys) > 0:
|
if client_keys and len(client_keys) > 0:
|
||||||
for key in client_keys:
|
for key in client_keys:
|
||||||
area_msg = col.row(align = True)
|
area_msg = col.row(align=True)
|
||||||
item_box = area_msg.box()
|
item_box = area_msg.box()
|
||||||
client = operators.client.get(key).buffer
|
client = operators.client.get(key).buffer
|
||||||
pointer = operators.client.get(key).pointer
|
|
||||||
info = ""
|
info = ""
|
||||||
|
|
||||||
detail_item_row = item_box.row(align = True)
|
detail_item_row = item_box.row(align=True)
|
||||||
|
|
||||||
username = client['name']
|
username = client['name']
|
||||||
|
|
||||||
|
is_local_user = username == settings.username
|
||||||
is_local_user = username == settings.username
|
|
||||||
|
|
||||||
if is_local_user:
|
if is_local_user:
|
||||||
info = "(self)"
|
info = "(self)"
|
||||||
@ -181,7 +181,9 @@ class SESSION_PT_user(bpy.types.Panel):
|
|||||||
|
|
||||||
if not is_local_user:
|
if not is_local_user:
|
||||||
detail_item_row.operator(
|
detail_item_row.operator(
|
||||||
"session.snapview", text="", icon='VIEW_CAMERA').target_client = key
|
"session.snapview",
|
||||||
|
text="",
|
||||||
|
icon='VIEW_CAMERA').target_client = key
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
else:
|
else:
|
||||||
row.label(text="Empty")
|
row.label(text="Empty")
|
||||||
@ -189,14 +191,14 @@ class SESSION_PT_user(bpy.types.Panel):
|
|||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|
||||||
|
|
||||||
def draw_property(context,parent,property_uuid, level=0):
|
def draw_property(context, parent, property_uuid, level=0):
|
||||||
settings = context.window_manager.session
|
settings = context.window_manager.session
|
||||||
item = operators.client.get(property_uuid)
|
item = operators.client.get(property_uuid)
|
||||||
|
|
||||||
if item.str_type == 'BlUser' or item.state == ERROR:
|
if item.str_type == 'BlUser' or item.state == ERROR:
|
||||||
return
|
return
|
||||||
|
|
||||||
area_msg = parent.row(align = True)
|
area_msg = parent.row(align=True)
|
||||||
if level > 0:
|
if level > 0:
|
||||||
for i in range(level):
|
for i in range(level):
|
||||||
area_msg.label(text="")
|
area_msg.label(text="")
|
||||||
@ -204,21 +206,25 @@ def draw_property(context,parent,property_uuid, level=0):
|
|||||||
|
|
||||||
name = item.buffer['name']
|
name = item.buffer['name']
|
||||||
|
|
||||||
detail_item_box = line.row(align = True)
|
detail_item_box = line.row(align=True)
|
||||||
|
|
||||||
if item.state == FETCHED:
|
if item.state == FETCHED:
|
||||||
detail_item_box.operator("session.apply",text="", icon=PROP_STATES[item.state]).target = item.uuid
|
detail_item_box.operator(
|
||||||
|
"session.apply",
|
||||||
|
text="",
|
||||||
|
icon=PROP_STATES[item.state]).target = item.uuid
|
||||||
else:
|
else:
|
||||||
detail_item_box.label(text="", icon=PROP_STATES[item.state])
|
detail_item_box.label(text="", icon=PROP_STATES[item.state])
|
||||||
|
|
||||||
detail_item_box.label(text="",icon=item.icon)
|
detail_item_box.label(text="", icon=item.icon)
|
||||||
detail_item_box.label(text="{} ".format(name))
|
detail_item_box.label(text="{} ".format(name))
|
||||||
|
|
||||||
right_icon = "DECORATE_UNLOCKED"
|
right_icon = "DECORATE_UNLOCKED"
|
||||||
if item.owner != settings.username:
|
if item.owner != settings.username:
|
||||||
right_icon="DECORATE_LOCKED"
|
right_icon = "DECORATE_LOCKED"
|
||||||
|
|
||||||
ro = detail_item_box.operator("session.right", text="", icon=right_icon, emboss=settings.is_admin)
|
ro = detail_item_box.operator(
|
||||||
|
"session.right", text="", icon=right_icon, emboss=settings.is_admin)
|
||||||
ro.key = property_uuid
|
ro.key = property_uuid
|
||||||
|
|
||||||
detail_item_box.operator(
|
detail_item_box.operator(
|
||||||
@ -234,7 +240,7 @@ class SESSION_PT_outliner(bpy.types.Panel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return operators.client and operators.client.state == 2
|
return operators.client and operators.client.state == 2
|
||||||
|
|
||||||
def draw_header(self, context):
|
def draw_header(self, context):
|
||||||
self.layout.label(text="", icon='OUTLINER_OB_GROUP_INSTANCE')
|
self.layout.label(text="", icon='OUTLINER_OB_GROUP_INSTANCE')
|
||||||
@ -242,13 +248,11 @@ class SESSION_PT_outliner(bpy.types.Panel):
|
|||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
|
if hasattr(context.window_manager, 'session'):
|
||||||
if hasattr(context.window_manager,'session'):
|
|
||||||
settings = context.window_manager.session
|
settings = context.window_manager.session
|
||||||
scene = context.window_manager
|
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(settings,'outliner_filter', text="")
|
row.prop(settings, 'outliner_filter', text="")
|
||||||
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
# Property area
|
# Property area
|
||||||
@ -258,7 +262,7 @@ class SESSION_PT_outliner(bpy.types.Panel):
|
|||||||
if client_keys and len(client_keys) > 0:
|
if client_keys and len(client_keys) > 0:
|
||||||
col = layout.column(align=True)
|
col = layout.column(align=True)
|
||||||
for key in client_keys:
|
for key in client_keys:
|
||||||
draw_property(context,col,key)
|
draw_property(context, col, key)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
col.label(text="Empty")
|
col.label(text="Empty")
|
||||||
|
Reference in New Issue
Block a user