Implement delete BCF comment

This commit is contained in:
Dion Moult
2020-12-22 18:23:43 +11:00
parent ee42703f9f
commit 6a5d255c2f
5 changed files with 35 additions and 9 deletions
+6 -2
View File
@@ -438,9 +438,11 @@ class BcfXml:
return return
for bitmap in viewpoint.bitmaps: for bitmap in viewpoint.bitmaps:
bitmap_el = self._create_element(parent, "Bitmap") bitmap_el = self._create_element(parent, "Bitmap")
text_map = {"Bitmap": bitmap.bitmap_type, "Reference": bitmap.reference, "Height": bitmap.height}
text_map = {"Bitmap": bitmap.bitmap_type, "Reference": bitmap.reference}
for key, value in text_map.items(): for key, value in text_map.items():
self._create_element(bitmap_el, key, text=value) self._create_element(bitmap_el, key, text=value)
location_el = self._create_element(bitmap_el, "Location") location_el = self._create_element(bitmap_el, "Location")
self.write_vector(location_el, bitmap.location) self.write_vector(location_el, bitmap.location)
normal_el = self._create_element(bitmap_el, "Normal") normal_el = self._create_element(bitmap_el, "Normal")
@@ -448,6 +450,8 @@ class BcfXml:
up_el = self._create_element(bitmap_el, "Up") up_el = self._create_element(bitmap_el, "Up")
self.write_vector(up_el, bitmap.up) self.write_vector(up_el, bitmap.up)
self._create_element(bitmap_el, "Height", text=bitmap.height)
def write_vector(self, parent, from_obj): def write_vector(self, parent, from_obj):
self._create_element(parent, "X", text=from_obj.x) self._create_element(parent, "X", text=from_obj.x)
self._create_element(parent, "Y", text=from_obj.y) self._create_element(parent, "Y", text=from_obj.y)
@@ -631,7 +635,7 @@ class BcfXml:
for item in visinfo["Bitmap"]: for item in visinfo["Bitmap"]:
bitmap = bcf.data.Bitmap() bitmap = bcf.data.Bitmap()
bitmap.reference = item["Reference"] bitmap.reference = item["Reference"]
bitmap.bitmap_type = item["Bitmap"].lower() bitmap.bitmap_type = item["Bitmap"].upper()
self.set_vector(bitmap.location, item["Location"]) self.set_vector(bitmap.location, item["Location"])
self.set_vector(bitmap.normal, item["Normal"]) self.set_vector(bitmap.normal, item["Normal"])
self.set_vector(bitmap.up, item["Up"]) self.set_vector(bitmap.up, item["Up"])
+1 -1
View File
@@ -156,7 +156,7 @@ class Bitmap:
def __init__(self): def __init__(self):
self.reference = "" # Only in BCF-XML self.reference = "" # Only in BCF-XML
self.bitmap_data = None # Only in BCF-API self.bitmap_data = None # Only in BCF-API
self.bitmap_type = "png" # Enum of png or jpg self.bitmap_type = "PNG" # Enum of png or jpg
self.location = Point() self.location = Point()
self.normal = Direction() self.normal = Direction()
self.up = Direction() self.up = Direction()
@@ -37,6 +37,7 @@ if bpy is not None:
operator.AddBcfTopic, operator.AddBcfTopic,
operator.ViewBcfTopic, operator.ViewBcfTopic,
operator.RemoveBcfViewpoint, operator.RemoveBcfViewpoint,
operator.RemoveBcfComment,
operator.ActivateBcfViewpoint, operator.ActivateBcfViewpoint,
operator.OpenUri, operator.OpenUri,
operator.OpenBcfReferenceLink, operator.OpenBcfReferenceLink,
@@ -622,6 +622,8 @@ class LoadBcfComments(bpy.types.Operator):
bcfxml = bcfstore.BcfStore.get_bcfxml() bcfxml = bcfstore.BcfStore.get_bcfxml()
bcfxml.get_comments(self.topic_guid) bcfxml.get_comments(self.topic_guid)
blender_topic = bpy.context.scene.BCFProperties.topics.get(self.topic_guid) blender_topic = bpy.context.scene.BCFProperties.topics.get(self.topic_guid)
while len(blender_topic.comments) > 0:
blender_topic.comments.remove(0)
for comment in bcfxml.topics[self.topic_guid].comments.values(): for comment in bcfxml.topics[self.topic_guid].comments.values():
new = blender_topic.comments.add() new = blender_topic.comments.add()
data_map = { data_map = {
@@ -694,6 +696,7 @@ class EditBcfTopic(bpy.types.Operator):
topic.topic_type = blender_topic.type or None topic.topic_type = blender_topic.type or None
bcfxml.edit_topic(topic) bcfxml.edit_topic(topic)
props.active_topic_index = props.active_topic_index # Refreshes the BCF Topic
return {"FINISHED"} return {"FINISHED"}
@@ -749,6 +752,22 @@ class RemoveBcfViewpoint(bpy.types.Operator):
topic = bcfxml.topics[blender_topic.name] topic = bcfxml.topics[blender_topic.name]
bcfxml.delete_viewpoint(viewpoint_guid, topic) bcfxml.delete_viewpoint(viewpoint_guid, topic)
props.active_topic_index = props.active_topic_index # Refreshes the BCF Topic props.active_topic_index = props.active_topic_index # Refreshes the BCF Topic
return {"FINISHED"}
class RemoveBcfComment(bpy.types.Operator):
bl_idname = "bim.remove_bcf_comment"
bl_label = "Remove BCF Comment"
comment_guid: bpy.props.StringProperty()
def execute(self, context):
bcfxml = bcfstore.BcfStore.get_bcfxml()
props = bpy.context.scene.BCFProperties
blender_topic = props.topics[props.active_topic_index]
topic = bcfxml.topics[blender_topic.name]
bcfxml.delete_comment(self.comment_guid, topic)
props.active_topic_index = props.active_topic_index # Refreshes the BCF Topic
bpy.ops.bim.load_bcf_comments(topic_guid = topic.guid)
print(bcfxml.filepath) print(bcfxml.filepath)
return {"FINISHED"} return {"FINISHED"}
+8 -6
View File
@@ -1837,13 +1837,16 @@ class BIM_PT_bcf_comments(Panel):
topic = props.topics[props.active_topic_index] topic = props.topics[props.active_topic_index]
for comment in topic.comments: for comment in topic.comments:
box = self.layout.box() box = self.layout.box()
box.separator()
author_text = "{} ({})".format(comment.author, comment.date) author_text = "{} ({})".format(comment.author, comment.date)
if comment.modified_author: if comment.modified_author:
author_text = "*{} ({})".format(comment.modified_author, comment.modified_date) author_text = "*{} ({})".format(comment.modified_author, comment.modified_date)
box.label(text=author_text, icon="WORDWRAP_ON") row = box.row(align=True)
box.separator() row.label(text=author_text, icon="WORDWRAP_ON")
box.scale_y = 0.5 row.operator("bim.remove_bcf_comment", icon="X", text="").comment_guid = comment.name
col = box.column(align=True)
col.scale_y = 0.8
words = comment.comment.split() words = comment.comment.split()
while words: while words:
total_line_chars = 0 total_line_chars = 0
@@ -1852,8 +1855,7 @@ class BIM_PT_bcf_comments(Panel):
word = words.pop(0) word = words.pop(0)
line_words.append(word) line_words.append(word)
total_line_chars += len(word) + 1 # 1 is for the space total_line_chars += len(word) + 1 # 1 is for the space
box.label(text=" ".join(line_words)) col.label(text=" ".join(line_words))
box.separator()
class BIM_PT_qa(Panel): class BIM_PT_qa(Panel):