mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
Move Brick namespace from data to BrickStore
This commit is contained in:
@@ -42,7 +42,6 @@ class BrickschemaData:
|
|||||||
cls.data = {
|
cls.data = {
|
||||||
"is_loaded": cls.get_is_loaded(),
|
"is_loaded": cls.get_is_loaded(),
|
||||||
"attributes": cls.attributes(),
|
"attributes": cls.attributes(),
|
||||||
"namespaces": cls.namespaces(),
|
|
||||||
"brick_equipment_classes": cls.brick_equipment_classes(),
|
"brick_equipment_classes": cls.brick_equipment_classes(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,17 +103,6 @@ class BrickschemaData:
|
|||||||
)
|
)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def namespaces(cls):
|
|
||||||
if BrickStore.graph is None:
|
|
||||||
return []
|
|
||||||
results = []
|
|
||||||
filter = ["brick", "owl", "w3", "xml"]
|
|
||||||
for alias, uri in BrickStore.graph.namespaces():
|
|
||||||
if alias not in filter:
|
|
||||||
results.append((uri, f"{alias}: {uri}", ""))
|
|
||||||
return results
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def brick_equipment_classes(cls):
|
def brick_equipment_classes(cls):
|
||||||
if BrickStore.graph is None:
|
if BrickStore.graph is None:
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ from bpy.props import (
|
|||||||
FloatVectorProperty,
|
FloatVectorProperty,
|
||||||
CollectionProperty,
|
CollectionProperty,
|
||||||
)
|
)
|
||||||
|
from blenderbim.tool.brick import BrickStore
|
||||||
|
|
||||||
def update_active_brick_index(self, context):
|
def update_active_brick_index(self, context):
|
||||||
BrickschemaData.is_loaded = False
|
BrickschemaData.is_loaded = False
|
||||||
@@ -43,9 +43,7 @@ def get_libraries(self, context):
|
|||||||
|
|
||||||
|
|
||||||
def get_namespaces(self, context):
|
def get_namespaces(self, context):
|
||||||
if not BrickschemaData.is_loaded:
|
return BrickStore.namespaces
|
||||||
BrickschemaData.load()
|
|
||||||
return BrickschemaData.data["namespaces"]
|
|
||||||
|
|
||||||
|
|
||||||
def get_brick_equipment_classes(self, context):
|
def get_brick_equipment_classes(self, context):
|
||||||
|
|||||||
@@ -268,6 +268,7 @@ class Brick(blenderbim.core.tool.Brick):
|
|||||||
with BrickStore.graph.new_changeset("PROJECT") as cs:
|
with BrickStore.graph.new_changeset("PROJECT") as cs:
|
||||||
cs.load_file(filepath)
|
cs.load_file(filepath)
|
||||||
BrickStore.path = filepath
|
BrickStore.path = filepath
|
||||||
|
BrickStore.load_namespaces()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new_brick_file(cls):
|
def new_brick_file(cls):
|
||||||
@@ -278,6 +279,7 @@ class Brick(blenderbim.core.tool.Brick):
|
|||||||
with BrickStore.graph.new_changeset("SCHEMA") as cs:
|
with BrickStore.graph.new_changeset("SCHEMA") as cs:
|
||||||
cs.load_file(BrickStore.schema)
|
cs.load_file(BrickStore.schema)
|
||||||
BrickStore.graph.bind("digitaltwin", Namespace("https://example.org/digitaltwin#"))
|
BrickStore.graph.bind("digitaltwin", Namespace("https://example.org/digitaltwin#"))
|
||||||
|
BrickStore.load_namespaces()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def pop_brick_breadcrumb(cls):
|
def pop_brick_breadcrumb(cls):
|
||||||
@@ -325,13 +327,12 @@ class Brick(blenderbim.core.tool.Brick):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def add_namespace(cls, alias, uri):
|
def add_namespace(cls, alias, uri):
|
||||||
BrickStore.graph.bind(alias, Namespace(uri))
|
BrickStore.graph.bind(alias, Namespace(uri))
|
||||||
# need some way to reload namespace enum view
|
BrickStore.load_namespaces()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def clear_breadcrumbs(cls):
|
def clear_breadcrumbs(cls):
|
||||||
bpy.context.scene.BIMBrickProperties.brick_breadcrumbs.clear()
|
bpy.context.scene.BIMBrickProperties.brick_breadcrumbs.clear()
|
||||||
|
|
||||||
|
|
||||||
class BrickStore:
|
class BrickStore:
|
||||||
schema = None # this is now a os path
|
schema = None # this is now a os path
|
||||||
path = None # file path if the project was loaded in
|
path = None # file path if the project was loaded in
|
||||||
@@ -341,17 +342,32 @@ class BrickStore:
|
|||||||
future = []
|
future = []
|
||||||
current_changesets = 0
|
current_changesets = 0
|
||||||
history_size = 64
|
history_size = 64
|
||||||
|
namespaces = []
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def purge():
|
def purge():
|
||||||
BrickStore.schema = None
|
BrickStore.schema = None
|
||||||
BrickStore.graph = None
|
BrickStore.graph = None
|
||||||
BrickStore.path = None
|
BrickStore.path = None
|
||||||
|
BrickStore.namespaces = []
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_project(cls):
|
def get_project(cls):
|
||||||
return BrickStore.graph.graph_at(graph="PROJECT")
|
return BrickStore.graph.graph_at(graph="PROJECT")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load_namespaces(cls):
|
||||||
|
BrickStore.namespaces = []
|
||||||
|
keyword_filter = ["brickschema.org", "schema.org", "w3.org", "purl.org", "rdfs.org", "qudt.org", "ashrae.org"]
|
||||||
|
for alias, uri in BrickStore.graph.namespaces():
|
||||||
|
ignore_namespace = False
|
||||||
|
for keyword in keyword_filter:
|
||||||
|
if keyword in str(uri):
|
||||||
|
ignore_namespace = True
|
||||||
|
break
|
||||||
|
if not ignore_namespace:
|
||||||
|
BrickStore.namespaces.append((uri, f"{alias}: {uri}", ""))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_history_size(cls, size):
|
def set_history_size(cls, size):
|
||||||
cls.history_size = size
|
cls.history_size = size
|
||||||
|
|||||||
Reference in New Issue
Block a user