Commit a9f0e4ea authored by Bruno Laurencich's avatar Bruno Laurencich

detect armature object

parent 1385ac8c
......@@ -43,8 +43,8 @@ class Chord_Properties(bpy.types.AddonPreferences):
state = props.EnumProperty(\
items=u.possible_states(),\
options={'SKIP_SAVE'}
)
options={'SKIP_SAVE'}
)
trans_method = props.EnumProperty(\
items= u.transmition_methods(),
......@@ -79,12 +79,22 @@ class Chord_Properties(bpy.types.AddonPreferences):
show_advanced = props.BoolProperty( name="Show advanced panel", default = False )
def target_update(self, context):
"""TODO: this function should block from selecting a non armature typed object """
pass
class Chord_Scene_Properties(bpy.types.PropertyGroup):
target = bpy.props.PointerProperty(name = "Source armature object",
description="The Armature to display the capture",
type=bpy.types.Object)#, update=target_update
# ====== End of GLOBAL PROPERTIES =======
def register():
# bpy.utils.register_class(Chord_Properties)
# WindowManager.chordata = \
# bpy.props.PointerProperty(type=Chord_Properties)
bpy.utils.register_class(Chord_Scene_Properties)
bpy.types.Scene.chordata = \
bpy.props.PointerProperty(type=Chord_Scene_Properties)
bpy.utils.register_module(__name__)
......
No preview for this file type
......@@ -88,10 +88,27 @@ class Chord_Get_Ip(bpy.types.Operator):
self.report({"DEBUG"}, "Query Thread terminating..")
return
# ----------- INVOKE -----------
def find_armature(self, context):
if not context.scene.chordata.target:
context.scene.chordata.target = u.get_chordata_armature()
if not context.scene.chordata.target:
self.report({"ERROR"},"No Chordata Armature in the scene")
return False
return True
# ----------- EXECUTE -----------
def execute(self, context):
self.chord_global = context.user_preferences.addons[__package__].preferences
if not self.find_armature(context):
return {"CANCELLED"}
self.chord_global.state = u.possible_states()[0][0]
self.chord_global.notochord_ip = ""
self.report({"INFO"},"ip query ongoing..")
......
......@@ -20,7 +20,7 @@ def get_conn_state_attr(context, attr = "name"):
#
class Chord_tools_panel(bpy.types.Panel):
"""Main panel for the chordata client addon"""
bl_label = "Chordata Panel"
bl_label = "Chordata"
bl_category = "Chordata"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
......@@ -50,7 +50,18 @@ class Chord_tools_panel(bpy.types.Panel):
self.check_connection()
if get_conn_state_attr(context, "value") > 2:
layout.enabled= False
layout.operator("chordata.get_ip", "Connect")
layout.label("Armature Object")
row = layout.row(align=True)
target = context.scene.chordata.target
if not target or target.type != "ARMATURE":
row.alert = True
row.prop(context.scene.chordata, "target", text="", icon="MOD_ARMATURE")
layout.separator()
row = layout.row()
row.scale_y = 2
row.operator("chordata.get_ip", "Connect")
layout.label(self.chord_global.state,\
icon= get_conn_state_attr(context, "icon"))
......@@ -95,7 +106,7 @@ class Chord_tools_panel(bpy.types.Panel):
class Chord_advanced_panel(bpy.types.Panel):
"""Main panel for the chordata client addon"""
"""Advanced options panel for the chordata client addon"""
bl_label = "Chordata Advanced"
bl_category = "Chordata"
bl_space_type = "VIEW_3D"
......@@ -120,4 +131,7 @@ class Chord_advanced_panel(bpy.types.Panel):
layout.label("Parameters")
layout.prop(self.chord_global, "notochord_parameters", text="")
layout.prop(self.chord_global, "notochord_hostname")
\ No newline at end of file
layout.label("Notochord hostname")
layout.prop(self.chord_global, "notochord_hostname", text="")
......@@ -21,8 +21,12 @@ def get_local_ip():
def get_chordata_armature():
for ob in bpy.data.objects:
if ob.name.lower() == "chordata":
if ob.type == "ARMATURE":
return ob
return None
def transmition_methods(as_tuples = True):
"""Transmision method to be used"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment