mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-01 04:29:38 +00:00
New UI to show BCF comments in the BCF panel as a subpanel
This commit is contained in:
@@ -28,6 +28,7 @@ if bpy is not None:
|
|||||||
operator.NewBcfProject,
|
operator.NewBcfProject,
|
||||||
operator.LoadBcfProject,
|
operator.LoadBcfProject,
|
||||||
operator.LoadBcfTopics,
|
operator.LoadBcfTopics,
|
||||||
|
operator.LoadBcfComments,
|
||||||
operator.SaveBcfProject,
|
operator.SaveBcfProject,
|
||||||
operator.AddBcfTopic,
|
operator.AddBcfTopic,
|
||||||
operator.ViewBcfTopic,
|
operator.ViewBcfTopic,
|
||||||
@@ -260,6 +261,7 @@ if bpy is not None:
|
|||||||
prop.Sheet,
|
prop.Sheet,
|
||||||
prop.BcfBimSnippet,
|
prop.BcfBimSnippet,
|
||||||
prop.BcfDocumentReference,
|
prop.BcfDocumentReference,
|
||||||
|
prop.BcfComment,
|
||||||
prop.BcfTopic,
|
prop.BcfTopic,
|
||||||
prop.Subcontext,
|
prop.Subcontext,
|
||||||
prop.PresentationLayer,
|
prop.PresentationLayer,
|
||||||
@@ -295,6 +297,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_comments,
|
||||||
ui.BIM_PT_owner,
|
ui.BIM_PT_owner,
|
||||||
ui.BIM_PT_people,
|
ui.BIM_PT_people,
|
||||||
ui.BIM_PT_organisations,
|
ui.BIM_PT_organisations,
|
||||||
|
|||||||
@@ -550,8 +550,8 @@ class LoadBcfTopics(bpy.types.Operator):
|
|||||||
for topic in bcfxml.topics.values():
|
for topic in bcfxml.topics.values():
|
||||||
new = bpy.context.scene.BCFProperties.topics.add()
|
new = bpy.context.scene.BCFProperties.topics.add()
|
||||||
data_map = {
|
data_map = {
|
||||||
"name": topic.title,
|
"name": topic.guid,
|
||||||
"guid": topic.guid,
|
"title": topic.title,
|
||||||
"type": topic.topic_type,
|
"type": topic.topic_type,
|
||||||
"status": topic.topic_status,
|
"status": topic.topic_status,
|
||||||
"priority": topic.priority,
|
"priority": topic.priority,
|
||||||
@@ -597,6 +597,33 @@ class LoadBcfTopics(bpy.types.Operator):
|
|||||||
for related_topic in topic.related_topics:
|
for related_topic in topic.related_topics:
|
||||||
new2 = new.related_topics.add()
|
new2 = new.related_topics.add()
|
||||||
new2.name = related_topic.guid
|
new2.name = related_topic.guid
|
||||||
|
bpy.ops.bim.load_bcf_comments(topic_guid = topic.guid)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class LoadBcfComments(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.load_bcf_comments"
|
||||||
|
bl_label = "Load BCF Comments"
|
||||||
|
topic_guid: bpy.props.StringProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
bcfxml = bcfstore.BcfStore.get_bcfxml()
|
||||||
|
bcfxml.get_comments(self.topic_guid)
|
||||||
|
blender_topic = bpy.context.scene.BCFProperties.topics.get(self.topic_guid)
|
||||||
|
for comment in bcfxml.topics[self.topic_guid].comments.values():
|
||||||
|
new = blender_topic.comments.add()
|
||||||
|
data_map = {
|
||||||
|
"name": comment.guid,
|
||||||
|
"comment": comment.comment,
|
||||||
|
"viewpoint": comment.viewpoint.guid if comment.viewpoint else None,
|
||||||
|
"date": comment.date,
|
||||||
|
"author": comment.author,
|
||||||
|
"modified_date": comment.modified_date,
|
||||||
|
"modified_author": comment.modified_author,
|
||||||
|
}
|
||||||
|
for key, value in data_map.items():
|
||||||
|
if value is not None:
|
||||||
|
setattr(new, key, str(value))
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -917,7 +917,7 @@ def getBcfViewpoints(self, context):
|
|||||||
props = bpy.context.scene.BCFProperties
|
props = bpy.context.scene.BCFProperties
|
||||||
bcfxml = bcfstore.BcfStore.get_bcfxml()
|
bcfxml = bcfstore.BcfStore.get_bcfxml()
|
||||||
topic = props.topics[props.active_topic_index]
|
topic = props.topics[props.active_topic_index]
|
||||||
viewpoints = bcfxml.get_viewpoints(topic.guid)
|
viewpoints = bcfxml.get_viewpoints(topic.name)
|
||||||
bcfviewpoints_enum.extend([(v, f"Viewpoint {i+1}", "") for i, v in enumerate(viewpoints.keys())])
|
bcfviewpoints_enum.extend([(v, f"Viewpoint {i+1}", "") for i, v in enumerate(viewpoints.keys())])
|
||||||
return bcfviewpoints_enum
|
return bcfviewpoints_enum
|
||||||
|
|
||||||
@@ -936,9 +936,19 @@ class BcfDocumentReference(PropertyGroup):
|
|||||||
is_external: BoolProperty(name="Is External")
|
is_external: BoolProperty(name="Is External")
|
||||||
|
|
||||||
|
|
||||||
|
class BcfComment(PropertyGroup):
|
||||||
|
name: StringProperty(name="GUID")
|
||||||
|
date: StringProperty(name="Date")
|
||||||
|
author: StringProperty(name="Author")
|
||||||
|
comment: StringProperty(name="Comment")
|
||||||
|
viewpoint: StringProperty(name="Viewpoint")
|
||||||
|
modified_date: StringProperty(name="Modified Date")
|
||||||
|
modified_author: StringProperty(name="Modified Author")
|
||||||
|
|
||||||
|
|
||||||
class BcfTopic(PropertyGroup):
|
class BcfTopic(PropertyGroup):
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="GUID")
|
||||||
guid: StringProperty(default="", name="GUID")
|
title: StringProperty(default="", name="Title")
|
||||||
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")
|
||||||
@@ -957,6 +967,7 @@ class BcfTopic(PropertyGroup):
|
|||||||
bim_snippet: PointerProperty(type=BcfBimSnippet)
|
bim_snippet: PointerProperty(type=BcfBimSnippet)
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
def refreshBcfTopic(self, context):
|
def refreshBcfTopic(self, context):
|
||||||
@@ -966,7 +977,7 @@ def refreshBcfTopic(self, context):
|
|||||||
props = bpy.context.scene.BCFProperties
|
props = bpy.context.scene.BCFProperties
|
||||||
bcfxml = bcfstore.BcfStore.get_bcfxml()
|
bcfxml = bcfstore.BcfStore.get_bcfxml()
|
||||||
topic = props.topics[props.active_topic_index]
|
topic = props.topics[props.active_topic_index]
|
||||||
header = bcfxml.get_header(topic.guid)
|
header = bcfxml.get_header(topic.name)
|
||||||
getBcfViewpoints(self, context)
|
getBcfViewpoints(self, context)
|
||||||
|
|
||||||
|
|
||||||
@@ -1478,6 +1489,7 @@ class BIMProperties(PropertyGroup):
|
|||||||
class BCFProperties(PropertyGroup):
|
class BCFProperties(PropertyGroup):
|
||||||
is_editable: BoolProperty(name="Is Editable", default=False)
|
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)
|
||||||
name: StringProperty(default="", name="Project Name")
|
name: StringProperty(default="", name="Project Name")
|
||||||
author: StringProperty(default="john@doe.com", name="Author Email")
|
author: StringProperty(default="john@doe.com", name="Author Email")
|
||||||
topics: CollectionProperty(name="BCF Topics", type=BcfTopic)
|
topics: CollectionProperty(name="BCF Topics", type=BcfTopic)
|
||||||
|
|||||||
@@ -1708,7 +1708,7 @@ class BIM_PT_bcf(Panel):
|
|||||||
col.prop(topic, "modified_author")
|
col.prop(topic, "modified_author")
|
||||||
|
|
||||||
bcfxml = bcfstore.BcfStore.get_bcfxml()
|
bcfxml = bcfstore.BcfStore.get_bcfxml()
|
||||||
bcf_topic = bcfxml.topics[topic.guid]
|
bcf_topic = bcfxml.topics[topic.name]
|
||||||
|
|
||||||
if bcf_topic.header:
|
if bcf_topic.header:
|
||||||
layout.label(text="Header Files:")
|
layout.label(text="Header Files:")
|
||||||
@@ -1720,7 +1720,7 @@ class BIM_PT_bcf(Panel):
|
|||||||
row.operator("bim.open_uri", icon="URL", text="").uri = f.reference
|
row.operator("bim.open_uri", icon="URL", text="").uri = f.reference
|
||||||
else:
|
else:
|
||||||
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
|
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
|
||||||
op.uri = os.path.join(bcfxml.filepath, topic.guid, f.reference)
|
op.uri = os.path.join(bcfxml.filepath, topic.name, f.reference)
|
||||||
box.label(text=f.date)
|
box.label(text=f.date)
|
||||||
#box.label(text=f.ifc_project)
|
#box.label(text=f.ifc_project)
|
||||||
#box.label(text=f.ifc_spatial_structure_element)
|
#box.label(text=f.ifc_spatial_structure_element)
|
||||||
@@ -1751,7 +1751,7 @@ class BIM_PT_bcf(Panel):
|
|||||||
row.operator("bim.open_uri", icon="URL", text="").uri = topic.bim_snippet.reference
|
row.operator("bim.open_uri", icon="URL", text="").uri = topic.bim_snippet.reference
|
||||||
else:
|
else:
|
||||||
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
|
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
|
||||||
op.uri = os.path.join(bcfxml.filepath, topic.guid, topic.bim_snippet.reference)
|
op.uri = os.path.join(bcfxml.filepath, topic.name, topic.bim_snippet.reference)
|
||||||
|
|
||||||
if topic.document_references:
|
if topic.document_references:
|
||||||
layout.label(text="Document References:")
|
layout.label(text="Document References:")
|
||||||
@@ -1763,7 +1763,7 @@ class BIM_PT_bcf(Panel):
|
|||||||
row.operator("bim.open_uri", icon="URL", text="").uri = doc.reference
|
row.operator("bim.open_uri", icon="URL", text="").uri = doc.reference
|
||||||
else:
|
else:
|
||||||
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
|
op = row.operator("bim.open_uri", icon="FILE_FOLDER", text="")
|
||||||
op.uri = os.path.join(bcfxml.filepath, topic.guid, doc.reference)
|
op.uri = os.path.join(bcfxml.filepath, topic.name, doc.reference)
|
||||||
row = box.row(align=True)
|
row = box.row(align=True)
|
||||||
row.prop(doc, "description")
|
row.prop(doc, "description")
|
||||||
|
|
||||||
@@ -1774,6 +1774,51 @@ class BIM_PT_bcf(Panel):
|
|||||||
row.operator("bim.view_bcf_topic", text=related_topic.name).topic_guid = related_topic.name
|
row.operator("bim.view_bcf_topic", text=related_topic.name).topic_guid = related_topic.name
|
||||||
|
|
||||||
|
|
||||||
|
class BIM_PT_bcf_comments(Panel):
|
||||||
|
bl_label = "BCF Comments"
|
||||||
|
bl_idname = "BIM_PT_bcf_comments"
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(props, "comment_text_width")
|
||||||
|
|
||||||
|
topic = props.topics[props.active_topic_index]
|
||||||
|
for comment in topic.comments:
|
||||||
|
box = self.layout.box()
|
||||||
|
box.separator()
|
||||||
|
author_text = "{} ({})".format(comment.author, comment.date)
|
||||||
|
if comment.modified_author:
|
||||||
|
author_text = "*{} ({})".format(comment.modified_author, comment.modified_date)
|
||||||
|
box.label(text=author_text, icon="WORDWRAP_ON")
|
||||||
|
box.separator()
|
||||||
|
box.scale_y = 0.5
|
||||||
|
words = comment.comment.split()
|
||||||
|
while words:
|
||||||
|
total_line_chars = 0
|
||||||
|
line_words = []
|
||||||
|
while words and total_line_chars < props.comment_text_width:
|
||||||
|
word = words.pop(0)
|
||||||
|
line_words.append(word)
|
||||||
|
total_line_chars += len(word) + 1 # 1 is for the space
|
||||||
|
box.label(text=" ".join(line_words))
|
||||||
|
box.separator()
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_qa(Panel):
|
class BIM_PT_qa(Panel):
|
||||||
bl_label = "BIMTester Quality Auditing"
|
bl_label = "BIMTester Quality Auditing"
|
||||||
bl_idname = "BIM_PT_qa"
|
bl_idname = "BIM_PT_qa"
|
||||||
@@ -2105,7 +2150,7 @@ class BIM_UL_topics(bpy.types.UIList):
|
|||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
ob = data
|
ob = data
|
||||||
if item:
|
if item:
|
||||||
layout.prop(item, "name", text="", emboss=False)
|
layout.prop(item, "title", text="", emboss=False)
|
||||||
else:
|
else:
|
||||||
layout.label(text="", translate=False)
|
layout.label(text="", translate=False)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user