mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-08 21:37:34 +00:00
Prioritise editing rendering surface styles over shading surface styles
This commit is contained in:
@@ -36,43 +36,15 @@ def blender():
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def aggregator():
|
||||
prophet = Prophecy(blenderbim.core.tool.Aggregator)
|
||||
def aggregate():
|
||||
prophet = Prophecy(blenderbim.core.tool.Aggregate)
|
||||
yield prophet
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def person_editor():
|
||||
prophet = Prophecy(blenderbim.core.tool.PersonEditor)
|
||||
yield prophet
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def role_editor():
|
||||
prophet = Prophecy(blenderbim.core.tool.RoleEditor)
|
||||
yield prophet
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def address_editor():
|
||||
prophet = Prophecy(blenderbim.core.tool.AddressEditor)
|
||||
yield prophet
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def organisation_editor():
|
||||
prophet = Prophecy(blenderbim.core.tool.OrganisationEditor)
|
||||
yield prophet
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def context_editor():
|
||||
prophet = Prophecy(blenderbim.core.tool.ContextEditor)
|
||||
def context():
|
||||
prophet = Prophecy(blenderbim.core.tool.Context)
|
||||
yield prophet
|
||||
prophet.verify()
|
||||
|
||||
@@ -98,6 +70,13 @@ def selector():
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def style():
|
||||
prophet = Prophecy(blenderbim.core.tool.Style)
|
||||
yield prophet
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def surveyor():
|
||||
prophet = Prophecy(blenderbim.core.tool.Surveyor)
|
||||
|
||||
@@ -1,32 +1,50 @@
|
||||
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
# This file is part of BlenderBIM Add-on.
|
||||
#
|
||||
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# BlenderBIM Add-on is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import blenderbim.core.aggregate as subject
|
||||
from test.core.bootstrap import ifc, aggregator, collector
|
||||
from test.core.bootstrap import ifc, aggregate, collector
|
||||
|
||||
|
||||
class TestEnableEditingAggregate:
|
||||
def test_run(self, aggregator):
|
||||
aggregator.enable_editing("obj").should_be_called()
|
||||
subject.enable_editing_aggregate(aggregator, obj="obj")
|
||||
def test_run(self, aggregate):
|
||||
aggregate.enable_editing("obj").should_be_called()
|
||||
subject.enable_editing_aggregate(aggregate, obj="obj")
|
||||
|
||||
|
||||
class TestDisableEditingAggregate:
|
||||
def test_run(self, aggregator):
|
||||
aggregator.disable_editing("obj").should_be_called()
|
||||
subject.disable_editing_aggregate(aggregator, obj="obj")
|
||||
def test_run(self, aggregate):
|
||||
aggregate.disable_editing("obj").should_be_called()
|
||||
subject.disable_editing_aggregate(aggregate, obj="obj")
|
||||
|
||||
|
||||
class TestAssignObject:
|
||||
def test_run(self, ifc, aggregator, collector):
|
||||
aggregator.can_aggregate("relating_obj", "related_obj").should_be_called().will_return(True)
|
||||
def test_run(self, ifc, aggregate, collector):
|
||||
aggregate.can_aggregate("relating_obj", "related_obj").should_be_called().will_return(True)
|
||||
ifc.get_entity("relating_obj").should_be_called().will_return("relating_object")
|
||||
ifc.get_entity("related_obj").should_be_called().will_return("related_object")
|
||||
ifc.run(
|
||||
"aggregate.assign_object", product="related_object", relating_object="relating_object"
|
||||
).should_be_called().will_return("rel")
|
||||
aggregator.disable_editing("related_obj").should_be_called()
|
||||
aggregate.disable_editing("related_obj").should_be_called()
|
||||
collector.assign("relating_obj").should_be_called()
|
||||
collector.assign("related_obj").should_be_called()
|
||||
assert (
|
||||
subject.assign_object(ifc, aggregator, collector, relating_obj="relating_obj", related_obj="related_obj")
|
||||
subject.assign_object(ifc, aggregate, collector, relating_obj="relating_obj", related_obj="related_obj")
|
||||
== "rel"
|
||||
)
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import blenderbim.core.context as subject
|
||||
from test.core.bootstrap import ifc, context_editor
|
||||
from test.core.bootstrap import ifc, context
|
||||
|
||||
|
||||
class TestAddContext:
|
||||
@@ -53,22 +53,22 @@ class TestRemoveContext:
|
||||
|
||||
|
||||
class TestEnableEditingContext:
|
||||
def test_run(self, context_editor):
|
||||
context_editor.set_context("context").should_be_called()
|
||||
context_editor.import_attributes().should_be_called()
|
||||
subject.enable_editing_context(context_editor, context="context")
|
||||
def test_run(self, context):
|
||||
context.set_context("context").should_be_called()
|
||||
context.import_attributes().should_be_called()
|
||||
subject.enable_editing_context(context, context="context")
|
||||
|
||||
|
||||
class TestDisableEditingContext:
|
||||
def test_run(self, context_editor):
|
||||
context_editor.clear_context().should_be_called()
|
||||
subject.disable_editing_context(context_editor)
|
||||
def test_run(self, context):
|
||||
context.clear_context().should_be_called()
|
||||
subject.disable_editing_context(context)
|
||||
|
||||
|
||||
class TestEditContext:
|
||||
def test_run(self, ifc, context_editor):
|
||||
context_editor.get_context().should_be_called().will_return("context")
|
||||
context_editor.export_attributes().should_be_called().will_return("attributes")
|
||||
def test_run(self, ifc, context):
|
||||
context.get_context().should_be_called().will_return("context")
|
||||
context.export_attributes().should_be_called().will_return("attributes")
|
||||
ifc.run("context.edit_context", context="context", attributes="attributes").should_be_called()
|
||||
context_editor.clear_context().should_be_called()
|
||||
subject.edit_context(ifc, context_editor)
|
||||
context.clear_context().should_be_called()
|
||||
subject.edit_context(ifc, context)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
import blenderbim.core.owner as subject
|
||||
from test.core.bootstrap import ifc, blender, person_editor, role_editor, address_editor, organisation_editor, owner
|
||||
from test.core.bootstrap import ifc, owner
|
||||
|
||||
|
||||
class TestAddPerson:
|
||||
@@ -34,37 +34,37 @@ class TestRemovePerson:
|
||||
|
||||
|
||||
class TestEnableEditingPerson:
|
||||
def test_run(self, person_editor):
|
||||
person_editor.set_person("person").should_be_called()
|
||||
person_editor.import_attributes().should_be_called()
|
||||
subject.enable_editing_person(person_editor, person="person")
|
||||
def test_run(self, owner):
|
||||
owner.set_person("person").should_be_called()
|
||||
owner.import_person_attributes().should_be_called()
|
||||
subject.enable_editing_person(owner, person="person")
|
||||
|
||||
|
||||
class TestDisableEditingPerson:
|
||||
def test_run(self, person_editor):
|
||||
person_editor.clear_person().should_be_called()
|
||||
subject.disable_editing_person(person_editor)
|
||||
def test_run(self, owner):
|
||||
owner.clear_person().should_be_called()
|
||||
subject.disable_editing_person(owner)
|
||||
|
||||
|
||||
class TestEditPerson:
|
||||
def test_run(self, ifc, person_editor):
|
||||
person_editor.get_person().should_be_called().will_return("person")
|
||||
person_editor.export_attributes().should_be_called().will_return("attributes")
|
||||
def test_run(self, ifc, owner):
|
||||
owner.get_person().should_be_called().will_return("person")
|
||||
owner.export_person_attributes().should_be_called().will_return("attributes")
|
||||
ifc.run("owner.edit_person", person="person", attributes="attributes").should_be_called()
|
||||
person_editor.clear_person().should_be_called()
|
||||
subject.edit_person(ifc, person_editor)
|
||||
owner.clear_person().should_be_called()
|
||||
subject.edit_person(ifc, owner)
|
||||
|
||||
|
||||
class TestAddPersonAttribute:
|
||||
def test_run(self, person_editor):
|
||||
person_editor.add_attribute("name").should_be_called()
|
||||
subject.add_person_attribute(person_editor, name="name")
|
||||
def test_run(self, owner):
|
||||
owner.add_person_attribute("name").should_be_called()
|
||||
subject.add_person_attribute(owner, name="name")
|
||||
|
||||
|
||||
class TestRemovePersonAttribute:
|
||||
def test_run(self, person_editor):
|
||||
person_editor.remove_attribute("name", "id").should_be_called()
|
||||
subject.remove_person_attribute(person_editor, name="name", id="id")
|
||||
def test_run(self, owner):
|
||||
owner.remove_person_attribute("name", "id").should_be_called()
|
||||
subject.remove_person_attribute(owner, name="name", id="id")
|
||||
|
||||
|
||||
class TestAddRole:
|
||||
@@ -80,25 +80,25 @@ class TestRemoveRole:
|
||||
|
||||
|
||||
class TestEnableEditingRole:
|
||||
def test_run(self, role_editor):
|
||||
role_editor.set_role("role").should_be_called()
|
||||
role_editor.import_attributes().should_be_called()
|
||||
subject.enable_editing_role(role_editor, role="role")
|
||||
def test_run(self, owner):
|
||||
owner.set_role("role").should_be_called()
|
||||
owner.import_role_attributes().should_be_called()
|
||||
subject.enable_editing_role(owner, role="role")
|
||||
|
||||
|
||||
class TestDisableEditingRole:
|
||||
def test_run(self, role_editor):
|
||||
role_editor.clear_role().should_be_called()
|
||||
subject.disable_editing_role(role_editor)
|
||||
def test_run(self, owner):
|
||||
owner.clear_role().should_be_called()
|
||||
subject.disable_editing_role(owner)
|
||||
|
||||
|
||||
class TestEditRole:
|
||||
def test_run(self, ifc, role_editor):
|
||||
role_editor.export_attributes().should_be_called().will_return("attributes")
|
||||
role_editor.get_role().should_be_called().will_return("role")
|
||||
def test_run(self, ifc, owner):
|
||||
owner.export_role_attributes().should_be_called().will_return("attributes")
|
||||
owner.get_role().should_be_called().will_return("role")
|
||||
ifc.run("owner.edit_role", role="role", attributes="attributes").should_be_called()
|
||||
role_editor.clear_role().should_be_called()
|
||||
subject.edit_role(ifc, role_editor)
|
||||
owner.clear_role().should_be_called()
|
||||
subject.edit_role(ifc, owner)
|
||||
|
||||
|
||||
class TestAddAddress:
|
||||
@@ -116,37 +116,37 @@ class TestRemoveAddress:
|
||||
|
||||
|
||||
class TestEnableEditingAddress:
|
||||
def test_run(self, address_editor):
|
||||
address_editor.set_address("address").should_be_called()
|
||||
address_editor.import_attributes().should_be_called()
|
||||
subject.enable_editing_address(address_editor, address="address")
|
||||
def test_run(self, owner):
|
||||
owner.set_address("address").should_be_called()
|
||||
owner.import_address_attributes().should_be_called()
|
||||
subject.enable_editing_address(owner, address="address")
|
||||
|
||||
|
||||
class TestDisableEditingAddress:
|
||||
def test_run(self, address_editor):
|
||||
address_editor.clear_address().should_be_called()
|
||||
subject.disable_editing_address(address_editor)
|
||||
def test_run(self, owner):
|
||||
owner.clear_address().should_be_called()
|
||||
subject.disable_editing_address(owner)
|
||||
|
||||
|
||||
class TestEditAddress:
|
||||
def test_run(self, ifc, address_editor):
|
||||
address_editor.get_address().should_be_called().will_return("address")
|
||||
address_editor.export_attributes().should_be_called().will_return("attributes")
|
||||
def test_run(self, ifc, owner):
|
||||
owner.get_address().should_be_called().will_return("address")
|
||||
owner.export_address_attributes().should_be_called().will_return("attributes")
|
||||
ifc.run("owner.edit_address", address="address", attributes="attributes").should_be_called()
|
||||
address_editor.clear_address().should_be_called()
|
||||
subject.edit_address(ifc, address_editor)
|
||||
owner.clear_address().should_be_called()
|
||||
subject.edit_address(ifc, owner)
|
||||
|
||||
|
||||
class TestAddAddressAttribute:
|
||||
def test_run(self, address_editor):
|
||||
address_editor.add_attribute("name").should_be_called()
|
||||
subject.add_address_attribute(address_editor, name="name")
|
||||
def test_run(self, owner):
|
||||
owner.add_address_attribute("name").should_be_called()
|
||||
subject.add_address_attribute(owner, name="name")
|
||||
|
||||
|
||||
class TestRemoveAddressAttribute:
|
||||
def test_run(self, address_editor):
|
||||
address_editor.remove_attribute("name", "id").should_be_called()
|
||||
subject.remove_address_attribute(address_editor, name="name", id="id")
|
||||
def test_run(self, owner):
|
||||
owner.remove_address_attribute("name", "id").should_be_called()
|
||||
subject.remove_address_attribute(owner, name="name", id="id")
|
||||
|
||||
|
||||
class TestAddOrganisation:
|
||||
@@ -162,25 +162,25 @@ class TestRemoveOrganisation:
|
||||
|
||||
|
||||
class TestEnableEditingOrganisation:
|
||||
def test_run(self, organisation_editor):
|
||||
organisation_editor.set_organisation("organisation").should_be_called()
|
||||
organisation_editor.import_attributes().should_be_called()
|
||||
subject.enable_editing_organisation(organisation_editor, organisation="organisation")
|
||||
def test_run(self, owner):
|
||||
owner.set_organisation("organisation").should_be_called()
|
||||
owner.import_organisation_attributes().should_be_called()
|
||||
subject.enable_editing_organisation(owner, organisation="organisation")
|
||||
|
||||
|
||||
class TestDisableEditingOrganisation:
|
||||
def test_run(self, organisation_editor):
|
||||
organisation_editor.clear_organisation().should_be_called()
|
||||
subject.disable_editing_organisation(organisation_editor)
|
||||
def test_run(self, owner):
|
||||
owner.clear_organisation().should_be_called()
|
||||
subject.disable_editing_organisation(owner)
|
||||
|
||||
|
||||
class TestEditOrganisation:
|
||||
def test_run(self, ifc, organisation_editor):
|
||||
organisation_editor.get_organisation().should_be_called().will_return("organisation")
|
||||
organisation_editor.export_attributes().should_be_called().will_return("attributes")
|
||||
def test_run(self, ifc, owner):
|
||||
owner.get_organisation().should_be_called().will_return("organisation")
|
||||
owner.export_organisation_attributes().should_be_called().will_return("attributes")
|
||||
ifc.run("owner.edit_organisation", organisation="organisation", attributes="attributes").should_be_called()
|
||||
organisation_editor.clear_organisation().should_be_called()
|
||||
subject.edit_organisation(ifc, organisation_editor)
|
||||
owner.clear_organisation().should_be_called()
|
||||
subject.edit_organisation(ifc, owner)
|
||||
|
||||
|
||||
class TestAddPersonAndOrganisation:
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
# This file is part of BlenderBIM Add-on.
|
||||
#
|
||||
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# BlenderBIM Add-on is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import blenderbim.core.style as subject
|
||||
from test.core.bootstrap import ifc, style
|
||||
|
||||
|
||||
class TestAddStyle:
|
||||
def test_it_adds_a_style_with_rendering_attributes(self, ifc, style):
|
||||
style.get_name("obj").should_be_called().will_return("name")
|
||||
ifc.run("style.add_style", name="name").should_be_called().will_return("style")
|
||||
style.link("style", "obj").should_be_called()
|
||||
style.get_surface_rendering_attributes("obj").should_be_called().will_return("attributes")
|
||||
ifc.run(
|
||||
"style.add_surface_style", style="style", ifc_class="IfcSurfaceStyleRendering", attributes="attributes"
|
||||
).should_be_called()
|
||||
ifc.get_entity("obj").should_be_called().will_return(None)
|
||||
assert subject.add_style(ifc, style, obj="obj") == "style"
|
||||
|
||||
def test_adding_a_style_linked_to_a_material(self, ifc, style):
|
||||
style.get_name("obj").should_be_called().will_return("name")
|
||||
ifc.run("style.add_style", name="name").should_be_called().will_return("style")
|
||||
style.link("style", "obj").should_be_called()
|
||||
style.get_surface_rendering_attributes("obj").should_be_called().will_return("attributes")
|
||||
ifc.run(
|
||||
"style.add_surface_style", style="style", ifc_class="IfcSurfaceStyleRendering", attributes="attributes"
|
||||
).should_be_called()
|
||||
ifc.get_entity("obj").should_be_called().will_return("material")
|
||||
style.get_context("obj").should_be_called().will_return("context")
|
||||
ifc.run("style.assign_material_style", material="material", style="style", context="context").should_be_called()
|
||||
assert subject.add_style(ifc, style, obj="obj") == "style"
|
||||
|
||||
|
||||
class TestRemoveStyle:
|
||||
def test_run(self, ifc, style):
|
||||
style.get_style("obj").should_be_called().will_return("style")
|
||||
ifc.run("style.remove_style", style="style").should_be_called()
|
||||
style.unlink(obj="obj").should_be_called()
|
||||
subject.remove_style(ifc, style, obj="obj")
|
||||
|
||||
|
||||
class TestUpdateStyleColours:
|
||||
def test_updating_rendering_colours_if_available(self, ifc, style):
|
||||
style.get_surface_rendering_style("obj").should_be_called().will_return("style")
|
||||
style.get_surface_rendering_attributes("obj").should_be_called().will_return("attributes")
|
||||
ifc.run("style.edit_surface_style", style="style", attributes="attributes").should_be_called()
|
||||
subject.update_style_colours(ifc, style, obj="obj")
|
||||
|
||||
def test_updating_shading_colours_as_a_fallback_if_available(self, ifc, style):
|
||||
style.get_surface_rendering_style("obj").should_be_called().will_return(None)
|
||||
style.get_surface_shading_style("obj").should_be_called().will_return("style")
|
||||
style.get_surface_shading_attributes("obj").should_be_called().will_return("attributes")
|
||||
ifc.run("style.edit_surface_style", style="style", attributes="attributes").should_be_called()
|
||||
subject.update_style_colours(ifc, style, obj="obj")
|
||||
|
||||
|
||||
class TestUnlinkStyle:
|
||||
def test_run(self, style):
|
||||
style.unlink("obj").should_be_called()
|
||||
subject.unlink_style(style, obj="obj")
|
||||
|
||||
|
||||
class TestEnableEditingStyle:
|
||||
def test_run(self, style):
|
||||
style.enable_editing("obj").should_be_called()
|
||||
style.get_style("obj").should_be_called().will_return("style")
|
||||
style.import_surface_attributes("style", "obj").should_be_called()
|
||||
subject.enable_editing_style(style, obj="obj")
|
||||
|
||||
|
||||
class TestDisableEditingStyle:
|
||||
def test_run(self, style):
|
||||
style.disable_editing("obj").should_be_called()
|
||||
subject.disable_editing_style(style, obj="obj")
|
||||
|
||||
|
||||
class TestEditStyle:
|
||||
def test_run(self, ifc, style):
|
||||
style.get_style("obj").should_be_called().will_return("style")
|
||||
style.export_surface_attributes("obj").should_be_called().will_return("attributes")
|
||||
ifc.run("style.edit_presentation_style", style="style", attributes="attributes").should_be_called()
|
||||
style.disable_editing("obj").should_be_called()
|
||||
subject.edit_style(ifc, style, obj="obj")
|
||||
Reference in New Issue
Block a user