Reimplement basic BCF metadata editing and further improve BCF UI

This commit is contained in:
Dion Moult
2020-12-19 21:48:23 +11:00
parent 03d8537a2d
commit 05d835410d
4 changed files with 199 additions and 83 deletions
@@ -29,6 +29,10 @@ if bpy is not None:
operator.LoadBcfProject, operator.LoadBcfProject,
operator.LoadBcfTopics, operator.LoadBcfTopics,
operator.LoadBcfComments, operator.LoadBcfComments,
operator.EditBcfProjectName,
operator.EditBcfAuthor,
operator.EditBcfTopicName,
operator.EditBcfTopic,
operator.SaveBcfProject, operator.SaveBcfProject,
operator.AddBcfTopic, operator.AddBcfTopic,
operator.ViewBcfTopic, operator.ViewBcfTopic,
@@ -297,6 +301,7 @@ if bpy is not None:
ui.BIM_PT_ifccsv, ui.BIM_PT_ifccsv,
ui.BIM_PT_ifcclash, ui.BIM_PT_ifcclash,
ui.BIM_PT_bcf, ui.BIM_PT_bcf,
ui.BIM_PT_bcf_metadata,
ui.BIM_PT_bcf_comments, ui.BIM_PT_bcf_comments,
ui.BIM_PT_owner, ui.BIM_PT_owner,
ui.BIM_PT_people, ui.BIM_PT_people,
@@ -527,7 +527,6 @@ class LoadBcfProject(bpy.types.Operator):
bcfxml = bcfstore.BcfStore.get_bcfxml() bcfxml = bcfstore.BcfStore.get_bcfxml()
if self.filepath: if self.filepath:
bcfxml.get_project(self.filepath) bcfxml.get_project(self.filepath)
bpy.context.scene.BCFProperties.is_editable = False
bpy.context.scene.BCFProperties.name = bcfxml.project.name bpy.context.scene.BCFProperties.name = bcfxml.project.name
bpy.ops.bim.load_bcf_topics() bpy.ops.bim.load_bcf_topics()
bpy.context.scene.BCFProperties.is_loaded = True bpy.context.scene.BCFProperties.is_loaded = True
@@ -627,6 +626,64 @@ class LoadBcfComments(bpy.types.Operator):
return {"FINISHED"} return {"FINISHED"}
class EditBcfProjectName(bpy.types.Operator):
bl_idname = "bim.edit_bcf_project_name"
bl_label = "Edit BCF Project Name"
def execute(self, context):
bcfxml = bcfstore.BcfStore.get_bcfxml()
bcfxml.project.name = bpy.context.scene.BCFProperties.name
bcfxml.edit_project()
return {"FINISHED"}
class EditBcfAuthor(bpy.types.Operator):
bl_idname = "bim.edit_bcf_author"
bl_label = "Edit BCF Author"
def execute(self, context):
bcfxml = bcfstore.BcfStore.get_bcfxml()
bcfxml.author = bpy.context.scene.BCFProperties.author
return {"FINISHED"}
class EditBcfTopicName(bpy.types.Operator):
bl_idname = "bim.edit_bcf_topic_name"
bl_label = "Edit BCF Topic Name"
def execute(self, context):
props = bpy.context.scene.BCFProperties
blender_topic = props.topics[props.active_topic_index]
bcfxml = bcfstore.BcfStore.get_bcfxml()
topic = bcfxml.topics[blender_topic.name]
topic.title = blender_topic.title
bcfxml.edit_topic(topic)
return {"FINISHED"}
class EditBcfTopic(bpy.types.Operator):
bl_idname = "bim.edit_bcf_topic"
bl_label = "Edit BCF Topic"
def execute(self, context):
props = bpy.context.scene.BCFProperties
blender_topic = props.topics[props.active_topic_index]
bcfxml = bcfstore.BcfStore.get_bcfxml()
topic = bcfxml.topics[blender_topic.name]
topic.title = blender_topic.title or None
topic.priority = blender_topic.priority or None
topic.due_date = blender_topic.due_date or None
topic.assigned_to = blender_topic.assigned_to or None
topic.stage = blender_topic.stage or None
topic.description = blender_topic.description or None
topic.topic_status = blender_topic.status or None
topic.topic_type = blender_topic.type or None
bcfxml.edit_topic(topic)
return {"FINISHED"}
class SaveBcfProject(bpy.types.Operator): class SaveBcfProject(bpy.types.Operator):
bl_idname = "bim.save_bcf_project" bl_idname = "bim.save_bcf_project"
bl_label = "Save BCF Project" bl_label = "Save BCF Project"
+33 -15
View File
@@ -540,6 +540,35 @@ def refreshFontSize(self, context):
annotation.Annotator.resize_text(context.active_object) annotation.Annotator.resize_text(context.active_object)
def updateBcfProjectName(self, context):
bpy.ops.bim.edit_bcf_project_name()
def updateBcfAuthor(self, context):
bpy.ops.bim.edit_bcf_author()
def updateBcfTopicName(self, context):
bpy.ops.bim.edit_bcf_topic_name()
def updateBcfTopicIsEditable(self, context):
if not self.is_editable:
print("EDITING!")
bpy.ops.bim.edit_bcf_topic()
def refreshBcfTopic(self, context):
global bcfviewpoints_enum
bcfviewpoints_enum = None
props = bpy.context.scene.BCFProperties
bcfxml = bcfstore.BcfStore.get_bcfxml()
topic = props.topics[props.active_topic_index]
header = bcfxml.get_header(topic.name)
getBcfViewpoints(self, context)
class StrProperty(PropertyGroup): class StrProperty(PropertyGroup):
pass pass
@@ -948,7 +977,7 @@ class BcfComment(PropertyGroup):
class BcfTopic(PropertyGroup): class BcfTopic(PropertyGroup):
name: StringProperty(name="GUID") name: StringProperty(name="GUID")
title: StringProperty(default="", name="Title") title: StringProperty(default="", name="Title", update=updateBcfTopicName)
type: StringProperty(default="", name="Type") type: StringProperty(default="", name="Type")
status: StringProperty(default="", name="Status") status: StringProperty(default="", name="Status")
priority: StringProperty(default="", name="Priority") priority: StringProperty(default="", name="Priority")
@@ -968,17 +997,7 @@ class BcfTopic(PropertyGroup):
document_references: CollectionProperty(name="Document References", type=BcfDocumentReference) document_references: CollectionProperty(name="Document References", type=BcfDocumentReference)
related_topics: CollectionProperty(name="Related Topics", type=StrProperty) related_topics: CollectionProperty(name="Related Topics", type=StrProperty)
comments: CollectionProperty(name="Comments", type=BcfComment) comments: CollectionProperty(name="Comments", type=BcfComment)
is_editable: BoolProperty(name="Is Editable", default=False, update=updateBcfTopicIsEditable)
def refreshBcfTopic(self, context):
global bcfviewpoints_enum
bcfviewpoints_enum = None
props = bpy.context.scene.BCFProperties
bcfxml = bcfstore.BcfStore.get_bcfxml()
topic = props.topics[props.active_topic_index]
header = bcfxml.get_header(topic.name)
getBcfViewpoints(self, context)
class PropertySetTemplate(PropertyGroup): class PropertySetTemplate(PropertyGroup):
@@ -1487,11 +1506,10 @@ class BIMProperties(PropertyGroup):
class BCFProperties(PropertyGroup): class BCFProperties(PropertyGroup):
is_editable: BoolProperty(name="Is Editable", default=False)
is_loaded: BoolProperty(name="Is Loaded", default=False) is_loaded: BoolProperty(name="Is Loaded", default=False)
comment_text_width: IntProperty(name="Comment Text Width", default=40) comment_text_width: IntProperty(name="Comment Text Width", default=40)
name: StringProperty(default="", name="Project Name") name: StringProperty(default="", name="Project Name", update=updateBcfProjectName)
author: StringProperty(default="john@doe.com", name="Author Email") author: StringProperty(default="john@doe.com", name="Author Email", update=updateBcfAuthor)
topics: CollectionProperty(name="BCF Topics", type=BcfTopic) topics: CollectionProperty(name="BCF Topics", type=BcfTopic)
active_topic_index: IntProperty(name="Active BCF Topic Index", update=refreshBcfTopic) active_topic_index: IntProperty(name="Active BCF Topic Index", update=refreshBcfTopic)
+47 -11
View File
@@ -1658,6 +1658,7 @@ class BIM_PT_bcf(Panel):
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
layout.use_property_split = True layout.use_property_split = True
layout.use_property_decorate = False
scene = context.scene scene = context.scene
props = bpy.context.scene.BCFProperties props = bpy.context.scene.BCFProperties
@@ -1682,10 +1683,14 @@ class BIM_PT_bcf(Panel):
row.template_list("BIM_UL_topics", "", props, "topics", props, "active_topic_index") row.template_list("BIM_UL_topics", "", props, "topics", props, "active_topic_index")
col = row.column(align=True) col = row.column(align=True)
col.operator("bim.add_bcf_topic", icon="ADD", text="") col.operator("bim.add_bcf_topic", icon="ADD", text="")
if props.active_topic_index < len(props.topics):
topic = props.topics[props.active_topic_index]
col.prop(topic, "is_editable", icon="CHECKMARK" if topic.is_editable else "GREASEPENCIL", icon_only=True)
if props.active_topic_index < len(props.topics): if props.active_topic_index < len(props.topics):
topic = props.topics[props.active_topic_index] topic = props.topics[props.active_topic_index]
row = layout.row() row = layout.row()
row.enabled = topic.is_editable
row.prop(topic, "description", text="") row.prop(topic, "description", text="")
row = layout.row() row = layout.row()
@@ -1693,20 +1698,50 @@ class BIM_PT_bcf(Panel):
row.operator("bim.activate_bcf_viewpoint", icon="SCENE", text="") row.operator("bim.activate_bcf_viewpoint", icon="SCENE", text="")
col = layout.column(align=True) col = layout.column(align=True)
col.prop(topic, "type") if topic.type:
col.prop(topic, "status") col.prop(topic, "type", emboss=topic.is_editable)
col.prop(topic, "priority") if topic.status:
col.prop(topic, "stage") col.prop(topic, "status", emboss=topic.is_editable)
col.prop(topic, "assigned_to") if topic.priority:
col.prop(topic, "due_date") col.prop(topic, "priority", emboss=topic.is_editable)
if topic.stage:
col.prop(topic, "stage", emboss=topic.is_editable)
if topic.assigned_to:
col.prop(topic, "assigned_to", emboss=topic.is_editable)
if topic.due_date:
col.prop(topic, "due_date", emboss=topic.is_editable)
col = layout.column(align=True) col = layout.column(align=True)
col.enabled = False if topic.modified_date:
col.prop(topic, "creation_date") col.prop(topic, "modified_date", emboss=False)
col.prop(topic, "creation_author") col.prop(topic, "modified_author", emboss=False)
col.prop(topic, "modified_date") else:
col.prop(topic, "modified_author") col.prop(topic, "creation_date", emboss=False)
col.prop(topic, "creation_author", emboss=False)
class BIM_PT_bcf_metadata(Panel):
bl_label = "BCF Metadata"
bl_idname = "BIM_PT_bcf_metadata"
bl_options = {"DEFAULT_CLOSED"}
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "scene"
bl_parent_id = "BIM_PT_bcf"
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
scene = context.scene
props = bpy.context.scene.BCFProperties
if props.active_topic_index >= len(props.topics):
layout.label(text="No BCF project is loaded")
return
topic = props.topics[props.active_topic_index]
bcfxml = bcfstore.BcfStore.get_bcfxml() bcfxml = bcfstore.BcfStore.get_bcfxml()
bcf_topic = bcfxml.topics[topic.name] bcf_topic = bcfxml.topics[topic.name]
@@ -1786,6 +1821,7 @@ class BIM_PT_bcf_comments(Panel):
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
layout.use_property_split = True layout.use_property_split = True
layout.use_property_decorate = False
scene = context.scene scene = context.scene
props = bpy.context.scene.BCFProperties props = bpy.context.scene.BCFProperties