mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
Implement support for editing BCF comments
This commit is contained in:
@@ -38,6 +38,7 @@ if bpy is not None:
|
|||||||
operator.ViewBcfTopic,
|
operator.ViewBcfTopic,
|
||||||
operator.RemoveBcfViewpoint,
|
operator.RemoveBcfViewpoint,
|
||||||
operator.RemoveBcfComment,
|
operator.RemoveBcfComment,
|
||||||
|
operator.EditBcfComment,
|
||||||
operator.AddBcfComment,
|
operator.AddBcfComment,
|
||||||
operator.ActivateBcfViewpoint,
|
operator.ActivateBcfViewpoint,
|
||||||
operator.OpenUri,
|
operator.OpenUri,
|
||||||
|
|||||||
@@ -771,6 +771,24 @@ class RemoveBcfComment(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class EditBcfComment(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.edit_bcf_comment"
|
||||||
|
bl_label = "Edit 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]
|
||||||
|
blender_comment = blender_topic.comments.get(self.comment_guid)
|
||||||
|
topic = bcfxml.topics[blender_topic.name]
|
||||||
|
comment = topic.comments[self.comment_guid]
|
||||||
|
comment.comment = blender_comment.comment
|
||||||
|
bcfxml.edit_comment(comment, topic)
|
||||||
|
bpy.ops.bim.load_bcf_comments(topic_guid = topic.guid)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class AddBcfComment(bpy.types.Operator):
|
class AddBcfComment(bpy.types.Operator):
|
||||||
bl_idname = "bim.add_bcf_comment"
|
bl_idname = "bim.add_bcf_comment"
|
||||||
bl_label = "Add BCF Comment"
|
bl_label = "Add BCF Comment"
|
||||||
|
|||||||
@@ -566,10 +566,14 @@ def updateBcfTopicName(self, context):
|
|||||||
|
|
||||||
def updateBcfTopicIsEditable(self, context):
|
def updateBcfTopicIsEditable(self, context):
|
||||||
if not self.is_editable:
|
if not self.is_editable:
|
||||||
print("EDITING!")
|
|
||||||
bpy.ops.bim.edit_bcf_topic()
|
bpy.ops.bim.edit_bcf_topic()
|
||||||
|
|
||||||
|
|
||||||
|
def updateBcfCommentIsEditable(self, context):
|
||||||
|
if not self.is_editable:
|
||||||
|
bpy.ops.bim.edit_bcf_comment(comment_guid = self.name)
|
||||||
|
|
||||||
|
|
||||||
def refreshBcfTopic(self, context):
|
def refreshBcfTopic(self, context):
|
||||||
global bcfviewpoints_enum
|
global bcfviewpoints_enum
|
||||||
bcfviewpoints_enum = None
|
bcfviewpoints_enum = None
|
||||||
@@ -985,6 +989,7 @@ class BcfComment(PropertyGroup):
|
|||||||
viewpoint: StringProperty(name="Viewpoint")
|
viewpoint: StringProperty(name="Viewpoint")
|
||||||
modified_date: StringProperty(name="Modified Date")
|
modified_date: StringProperty(name="Modified Date")
|
||||||
modified_author: StringProperty(name="Modified Author")
|
modified_author: StringProperty(name="Modified Author")
|
||||||
|
is_editable: BoolProperty(name="Is Editable", default=False, update=updateBcfCommentIsEditable)
|
||||||
|
|
||||||
|
|
||||||
class BcfTopic(PropertyGroup):
|
class BcfTopic(PropertyGroup):
|
||||||
|
|||||||
@@ -1843,19 +1843,24 @@ class BIM_PT_bcf_comments(Panel):
|
|||||||
author_text = "*{} ({})".format(comment.modified_author, comment.modified_date)
|
author_text = "*{} ({})".format(comment.modified_author, comment.modified_date)
|
||||||
row = box.row(align=True)
|
row = box.row(align=True)
|
||||||
row.label(text=author_text, icon="WORDWRAP_ON")
|
row.label(text=author_text, icon="WORDWRAP_ON")
|
||||||
|
row.prop(comment, "is_editable", icon="CHECKMARK" if comment.is_editable else "GREASEPENCIL", icon_only=True)
|
||||||
row.operator("bim.remove_bcf_comment", icon="X", text="").comment_guid = comment.name
|
row.operator("bim.remove_bcf_comment", icon="X", text="").comment_guid = comment.name
|
||||||
|
|
||||||
col = box.column(align=True)
|
if comment.is_editable:
|
||||||
col.scale_y = 0.8
|
row = box.row()
|
||||||
words = comment.comment.split()
|
row.prop(comment, "comment", text="")
|
||||||
while words:
|
else:
|
||||||
total_line_chars = 0
|
col = box.column(align=True)
|
||||||
line_words = []
|
col.scale_y = 0.8
|
||||||
while words and total_line_chars < props.comment_text_width:
|
words = comment.comment.split()
|
||||||
word = words.pop(0)
|
while words:
|
||||||
line_words.append(word)
|
total_line_chars = 0
|
||||||
total_line_chars += len(word) + 1 # 1 is for the space
|
line_words = []
|
||||||
col.label(text=" ".join(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
|
||||||
|
col.label(text=" ".join(line_words))
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(topic, "comment")
|
row.prop(topic, "comment")
|
||||||
|
|||||||
Reference in New Issue
Block a user