OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add bitmaps to the reader
Oliver Günther71eb1c2b4131
diff --git a/modules/bcf/lib/open_project/bcf/bcf_json/viewpoint_mapper.rb b/modules/bcf/lib/open_project/bcf/bcf_json/viewpoint_mapper.rbindex d7198f62269..0c809c7bd29 100644--- a/modules/bcf/lib/open_project/bcf/bcf_json/viewpoint_mapper.rb+++ b/modules/bcf/lib/open_project/bcf/bcf_json/viewpoint_mapper.rb@@ -46,6 +46,7 @@ module OpenProject::Bcftransform_orthogonal_cameratransform_linestransform_clipping_planes+ transform_bitmapstransform_selectionstransform_coloringtransform_visibility@@ -106,6 +107,31 @@ module OpenProject::Bcfendend+ def transform_bitmaps(hash)+ return unless hash.key?('bitmaps')++ # Bitmaps can be multiple items within the root bitmaps node+ # this is different from the other entries+ # https://github.com/buildingSMART/BCF-XML/pull/44/files+ bitmaps = Array.wrap(hash['bitmaps'])++ hash['bitmaps'] = bitmaps.map! do |bitmap|+ bitmap['bitmap_type'] = bitmap.delete('bitmap').downcase+ bitmap['bitmap_data'] = bitmap.delete('reference')+ bitmap['height'] = bitmap['height'].to_f++ %w[location normal up].each do |key|+ next unless bitmap.key?(key)++ # Transform all coordinates to floats+ bitmap[key].transform_values!(&:to_f)+ end++ bitmap+ end+ end++### Move selections up the tree from the nested XML nodedef transform_selections(hash)diff --git a/modules/bcf/spec/fixtures/viewpoints/full_viewpoint.bcfv.json b/modules/bcf/spec/fixtures/viewpoints/full_viewpoint.bcfv.jsonindex e0b79fd217a..226d1104215 100644--- a/modules/bcf/spec/fixtures/viewpoints/full_viewpoint.bcfv.json+++ b/modules/bcf/spec/fixtures/viewpoints/full_viewpoint.bcfv.json@@ -144,5 +144,47 @@"z": 0.0}}+ ],+ "bitmaps": [+ {+ "bitmap_type": "png",+ "bitmap_data": "3f6ac03e-de8e-4c5e-b3f0-c7bf5f87fe51/bitmaps-d1514fd3-290b-4830-b1fa-5bb780ce9e94-0.png",+ "location": {+ "x": 10.064999999983305,+ "y": -10.40177106506878,+ "z": 7.011243681990698+ },+ "normal": {+ "x": -0.9999999999999999,+ "y": 1.253656364893038E-16,+ "z": 0.0+ },+ "up": {+ "x": -5.43903050550883E-34,+ "y": -4.338533794284917E-18,+ "z": 1.0+ },+ "height": 1666.1814563907683+ },+ {+ "bitmap_type": "jpg",+ "bitmap_data": "3f6ac03e-de8e-4c5e-b3f0-c7bf5f87fe51/bitmaps-e6f5a36a-c60b-4fcc-815f-a1dd939ebc87.jpg",+ "location": {+ "x": 1.0,+ "y": 2.0,+ "z": 3.0+ },+ "normal": {+ "x": -3.0,+ "y": 1.253656364893038E-16,+ "z": 0.0+ },+ "up": {+ "x": 30.1234,+ "y": -9000.0,+ "z": 1.0+ },+ "height": 10.0+ }]}diff --git a/modules/bcf/spec/fixtures/viewpoints/full_viewpoint.bcfv.xml b/modules/bcf/spec/fixtures/viewpoints/full_viewpoint.bcfv.xmlindex aa3ace55b23..af60fd30ae3 100644--- a/modules/bcf/spec/fixtures/viewpoints/full_viewpoint.bcfv.xml+++ b/modules/bcf/spec/fixtures/viewpoints/full_viewpoint.bcfv.xml@@ -110,4 +110,44 @@</Direction></ClippingPlane></ClippingPlanes>+ <Bitmaps>+ <Bitmap>PNG</Bitmap>+ <Reference>3f6ac03e-de8e-4c5e-b3f0-c7bf5f87fe51/bitmaps-d1514fd3-290b-4830-b1fa-5bb780ce9e94-0.png</Reference>+ <Location>+ <X>10.064999999983305</X>+ <Y>-10.40177106506878</Y>+ <Z>7.011243681990698</Z>+ </Location>+ <Normal>+ <X>-0.9999999999999999</X>+ <Y>1.253656364893038E-16</Y>+ <Z>0.0</Z>+ </Normal>+ <Up>+ <X>-5.43903050550883E-34</X>+ <Y>-4.338533794284917E-18</Y>+ <Z>1.0</Z>+ </Up>+ <Height>1666.1814563907683</Height>+ </Bitmaps>+ <Bitmaps>+ <Bitmap>JPG</Bitmap>+ <Reference>3f6ac03e-de8e-4c5e-b3f0-c7bf5f87fe51/bitmaps-e6f5a36a-c60b-4fcc-815f-a1dd939ebc87.jpg</Reference>+ <Location>+ <X>1</X>+ <Y>2</Y>+ <Z>3</Z>+ </Location>+ <Normal>+ <X>-3</X>+ <Y>1.253656364893038E-16</Y>+ <Z>0.0</Z>+ </Normal>+ <Up>+ <X>30.1234</X>+ <Y>-9000</Y>+ <Z>1.0</Z>+ </Up>+ <Height>10</Height>+ </Bitmaps></VisualizationInfo>\ No newline at end of filediff --git a/modules/bcf/spec/lib/open_project/bcf/bcf_json/viewpoint_mapper_shared_examples.rb b/modules/bcf/spec/lib/open_project/bcf/bcf_json/viewpoint_mapper_shared_examples.rbindex 1620b69c3fc..3839468655c 100644--- a/modules/bcf/spec/lib/open_project/bcf/bcf_json/viewpoint_mapper_shared_examples.rb+++ b/modules/bcf/spec/lib/open_project/bcf/bcf_json/viewpoint_mapper_shared_examples.rb@@ -29,7 +29,7 @@require 'spec_helper'shared_examples 'viewpoint keys' do- let(:expected) { %w[guid components orthogonal_camera perspective_camera lines clipping_planes] }+ let(:expected) { %w[guid components orthogonal_camera perspective_camera lines clipping_planes bitmaps] }it 'has only allowed keys' doexpect(subject.keys - expected).to be_empty@@ -94,6 +94,25 @@ shared_examples 'has clipping planes' doendend+shared_examples 'has bitmaps' do+ it 'has a bitmaps entry' do+ bitmaps = subject['bitmaps']+ expect(bitmaps).to be_kind_of(Array)++ bitmaps.each do |bitmap|+ expect(bitmap).to be_kind_of(Hash)+ expect(bitmap.keys).to contain_exactly 'bitmap_type', 'bitmap_data', 'location', 'normal', 'up', 'height'+ expect(bitmap['location'].keys).to contain_exactly 'x', 'y', 'z'+ expect(bitmap['location'].values).to all(be_kind_of(Float))+ expect(bitmap['normal'].keys).to contain_exactly 'x', 'y', 'z'+ expect(bitmap['normal'].values).to all(be_kind_of(Float))+ expect(bitmap['up'].keys).to contain_exactly 'x', 'y', 'z'+ expect(bitmap['up'].values).to all(be_kind_of(Float))+ expect(bitmap['height']).to be_kind_of(Float)+ end+ end+end+shared_examples 'has components selection' doit 'has components selections' doselection = subject.dig('components', 'selection')diff --git a/modules/bcf/spec/lib/open_project/bcf/bcf_json/viewpoint_mapper_spec.rb b/modules/bcf/spec/lib/open_project/bcf/bcf_json/viewpoint_mapper_spec.rbindex efc9290f510..60fa0e2725f 100644--- a/modules/bcf/spec/lib/open_project/bcf/bcf_json/viewpoint_mapper_spec.rb+++ b/modules/bcf/spec/lib/open_project/bcf/bcf_json/viewpoint_mapper_spec.rb@@ -53,6 +53,7 @@ describe OpenProject::Bcf::BcfJson::ViewpointMapper doit_behaves_like 'has camera', 'perspective_camera'it_behaves_like 'has lines'it_behaves_like 'has clipping planes'+ it_behaves_like 'has bitmaps'it_behaves_like 'has components selection'it_behaves_like 'has components coloring'it_behaves_like 'has components visibility'