From 0ebbc62a061e2989559a8d98b2286692a4bf0192 Mon Sep 17 00:00:00 2001 From: Gorgious56 Date: Fri, 28 Oct 2022 11:54:07 +0200 Subject: [PATCH] Add popup window when clicking Ifc description in right click context menu --- src/blenderbim/blenderbim/bim/operator.py | 18 +++++++++++++++++- src/blenderbim/blenderbim/bim/prop.py | 13 +++++++------ src/blenderbim/blenderbim/bim/ui.py | 5 ++--- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/operator.py b/src/blenderbim/blenderbim/bim/operator.py index e1ac1f7308..7d7df28172 100644 --- a/src/blenderbim/blenderbim/bim/operator.py +++ b/src/blenderbim/blenderbim/bim/operator.py @@ -19,6 +19,7 @@ import os import bpy import json +import textwrap import time import logging import webbrowser @@ -28,7 +29,7 @@ import blenderbim.tool as tool from . import schema from blenderbim.bim import import_ifc from blenderbim.bim.ifc import IfcStore -from blenderbim.bim.prop import StrProperty +from blenderbim.bim.prop import StrProperty, get_ifc_entity_doc_url from blenderbim.bim.ui import IFCFileSelector from blenderbim.bim.helper import get_enum_items from mathutils import Vector, Matrix, Euler @@ -688,11 +689,26 @@ class EditBlenderCollection(bpy.types.Operator): class BIM_OT_show_description(bpy.types.Operator): bl_idname = "bim.show_description" bl_label = "Description" + ifc_class: bpy.props.StringProperty() description: bpy.props.StringProperty() + def invoke(self, context, event): + wm = context.window_manager + return wm.invoke_props_dialog(self, width=450) + def execute(self, context): return {"FINISHED"} + def draw(self, context): + layout = self.layout + wrapper = textwrap.TextWrapper(width=80) + for line in wrapper.wrap(self.description): + layout.label(text=line) + url = get_ifc_entity_doc_url(self.ifc_class) + if url: + url_op = layout.operator("bim.open_webbrowser", icon="URL", text="Online IFC Documentation") + url_op.url = url + @classmethod def description(cls, context, properties): return properties.description diff --git a/src/blenderbim/blenderbim/bim/prop.py b/src/blenderbim/blenderbim/bim/prop.py index 9a4e34c598..40135598ee 100644 --- a/src/blenderbim/blenderbim/bim/prop.py +++ b/src/blenderbim/blenderbim/bim/prop.py @@ -129,12 +129,13 @@ def get_predefined_type_description(entity, predefined_type): HARDCODED_ATTRIBUTE_DESCRIPTIONS = { - "GlobalId": "Unique Entity Identifier", - "Name": "TODO", - "Description": "TODO", - "PredefinedType": "TODO", - "ObjectType": "TODO", - "Tag": "TODO", + "GlobalId": "Assignment of a globally unique identifier within the entire software world.", + "OwnerHistory": "Assignment of the information about the current ownership of that object, including owning actor, application, local identification and information captured about the recent changes of the object, NOTE only the last modification in stored - either as addition, deletion or modification.", + "Name": "Optional name for use by the participating software systems or users. For some subtypes of IfcRoot the insertion of the Name attribute may be required. This would be enforced by a where rule. ", + "Description": "Optional description, provided for exchanging informative comments.", + "PredefinedType": "Predefined generic type for a window that is specified in an enumeration. There may be a property set given specificly for the predefined types. NOTE The PredefinedType shall only be used, if no IfcWindowType is assigned, providing its own IfcWindowType.PredefinedType.", + "ObjectType": "The type denotes a particular type that indicates the object further. The use has to be established at the level of instantiable subtypes. In particular it holds the user defined type, if the enumeration of the attribute PredefinedType is set to USERDEFINED.", + "Tag": "The tag (or label) identifier at the particular instance of a product, e.g. the serial number, or the position number. It is the identifier at the occurrence level.", } diff --git a/src/blenderbim/blenderbim/bim/ui.py b/src/blenderbim/blenderbim/bim/ui.py index 6574eb6469..10f5bba4e6 100644 --- a/src/blenderbim/blenderbim/bim/ui.py +++ b/src/blenderbim/blenderbim/bim/ui.py @@ -404,7 +404,6 @@ def draw_custom_context_menu(self, context): url_op = layout.operator("bim.open_webbrowser", icon="URL", text="Online IFC Documentation") url_op.url = url if description: - op_description = layout.operator( - "bim.show_description", text="Hover for Description", icon="INFO", emboss=False - ) + op_description = layout.operator("bim.show_description", text="IFC Description", icon="INFO") op_description.description = description + op_description.ifc_class = getattr(context.button_pointer, "ifc_class", "")