Skip to content

Commit

Permalink
Merge pull request #9783 from opf/bug/39144-fix-get-viewpoint-endpoin…
Browse files Browse the repository at this point in the history
…t-in-bcf-api

[#39144] Get viewpoint returns too much data
  • Loading branch information
oliverguenther committed Nov 1, 2021
2 parents 1a57cf8 + 2f3f1b5 commit 7efc094
Show file tree
Hide file tree
Showing 26 changed files with 598 additions and 162 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Expand Up @@ -443,8 +443,8 @@ ij_typescript_keep_blank_lines_in_code = 2
ij_typescript_keep_first_column_comment = true
ij_typescript_keep_indents_on_empty_lines = false
ij_typescript_keep_line_breaks = true
ij_typescript_keep_simple_blocks_in_one_line = false
ij_typescript_keep_simple_methods_in_one_line = false
ij_typescript_keep_simple_blocks_in_one_line = true
ij_typescript_keep_simple_methods_in_one_line = true
ij_typescript_line_comment_add_space = true
ij_typescript_line_comment_at_first_column = false
ij_typescript_method_brace_style = end_of_line
Expand Down
30 changes: 29 additions & 1 deletion frontend/src/app/features/bim/bcf/api/bcf-api-request.service.ts
@@ -1,3 +1,31 @@
// -- copyright
// OpenProject is an open source project management software.
// Copyright (C) 2012-2021 the OpenProject GmbH
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program 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 2
// of the License, or (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See COPYRIGHT and LICENSE files for more details.
//++

import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http';
import { Injector } from '@angular/core';
import { TypedJSON } from 'typedjson';
Expand Down Expand Up @@ -51,7 +79,7 @@ export class BcfApiRequestService<T> {
* @param method request method
* @param path API path to request
* @param data Request payload (URL params for get, JSON payload otherwise)
* @param data Request payload (URL params for get, JSON payload otherwise)
* @param headers Request headers
*/
public request(method:HTTPSupportedMethods, path:string, data:HTTPClientParamMap = {}, headers:HTTPClientHeaders = {}):Observable<T> {
// HttpClient requires us to create HttpParams instead of passing data for get
Expand Down
103 changes: 103 additions & 0 deletions frontend/src/app/features/bim/bcf/api/bcf-api.model.ts
@@ -0,0 +1,103 @@
// -- copyright
// OpenProject is an open source project management software.
// Copyright (C) 2012-2021 the OpenProject GmbH
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program 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 2
// of the License, or (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See COPYRIGHT and LICENSE files for more details.
//++

export type BcfViewpointData = BcfViewpoint&{
components:BcfViewpointVisibility&BcfViewpointSelection
};

export type CreateBcfViewpointData = BcfViewpointData&{
snapshot:{ snapshot_type:string, snapshot_data:string }
};

export interface BcfViewpoint {
index:number|null
guid:string
orthogonal_camera:BcfOrthogonalCamera|null
perspective_camera:BcfPerspectiveCamera|null
lines:BcfLine[]|null
clipping_planes:BcfClippingPlane[]|null
bitmaps:BcfBitmap[]|null
snapshot:{ snapshot_type:string }
}

export interface BcfViewpointVisibility {
visibility:{
default_visibility:boolean
exceptions:BcfComponent[]
view_setup_hints:BcfViewSetupHints|null
}
}

export interface BcfViewpointSelection {
selection:BcfComponent[]
}

export interface BcfComponent {
ifc_guid:string|null
originating_system:string|null
authoring_tool_id:string|null
}

export interface BcfViewSetupHints {
spaces_visible:boolean
space_boundaries_visible:boolean
openings_visible:boolean
}

export interface BcfOrthogonalCamera {
camera_view_point:{ x:number, y:number, z:number }
camera_direction:{ x:number, y:number, z:number }
camera_up_vector:{ x:number, y:number, z:number }
view_to_world_scale:number
}

export interface BcfPerspectiveCamera {
camera_view_point:{ x:number, y:number, z:number }
camera_direction:{ x:number, y:number, z:number }
camera_up_vector:{ x:number, y:number, z:number }
field_of_view:number
}

export interface BcfBitmap {
guid:string
bitmap_type:string
location:{ x:number, y:number, z:number }
normal:{ x:number, y:number, z:number }
up:{ x:number, y:number, z:number }
height:number
}

export interface BcfClippingPlane {
location:{ x:number, y:number, z:number }
direction:{ x:number, y:number, z:number }
}

export interface BcfLine {
start_point:{ x:number, y:number, z:number }
end_point:{ x:number, y:number, z:number }
}
31 changes: 30 additions & 1 deletion frontend/src/app/features/bim/bcf/api/topics/bcf-topic.paths.ts
@@ -1,9 +1,38 @@
// -- copyright
// OpenProject is an open source project management software.
// Copyright (C) 2012-2021 the OpenProject GmbH
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program 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 2
// of the License, or (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See COPYRIGHT and LICENSE files for more details.
//++

import { BcfResourceCollectionPath, BcfResourcePath } from 'core-app/features/bim/bcf/api/bcf-path-resources';
import { BcfTopicResource } from 'core-app/features/bim/bcf/api/topics/bcf-topic.resource';
import { BcfApiRequestService } from 'core-app/features/bim/bcf/api/bcf-api-request.service';
import { BcfViewpointPaths } from 'core-app/features/bim/bcf/api/viewpoints/bcf-viewpoint.paths';
import { BcfViewpointCollectionPath } from 'core-app/features/bim/bcf/api/viewpoints/bcf-viewpoint-collection.paths';
import { HTTPClientHeaders, HTTPClientParamMap } from 'core-app/features/hal/http/http.interfaces';
import { Observable } from 'rxjs';

export class BcfTopicPaths extends BcfResourcePath {
readonly bcfTopicService = new BcfApiRequestService(this.injector, BcfTopicResource);
Expand All @@ -14,7 +43,7 @@ export class BcfTopicPaths extends BcfResourcePath {
/** /viewpoints */
public readonly viewpoints = new BcfViewpointCollectionPath(this.injector, this.path, 'viewpoints', BcfViewpointPaths);

get(params:HTTPClientParamMap = {}, headers:HTTPClientHeaders = {}) {
get(params:HTTPClientParamMap = {}, headers:HTTPClientHeaders = {}):Observable<BcfTopicResource> {
return this.bcfTopicService.get(this.toPath(), params, headers);
}
}
28 changes: 28 additions & 0 deletions frontend/src/app/features/bim/bcf/api/topics/bcf-topic.resource.ts
@@ -1,3 +1,31 @@
// -- copyright
// OpenProject is an open source project management software.
// Copyright (C) 2012-2021 the OpenProject GmbH
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program 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 2
// of the License, or (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See COPYRIGHT and LICENSE files for more details.
//++

import { jsonArrayMember, jsonMember, jsonObject } from 'typedjson';
import * as moment from 'moment';
import { Moment } from 'moment';
Expand Down
@@ -1,20 +1,43 @@
// -- copyright
// OpenProject is an open source project management software.
// Copyright (C) 2012-2021 the OpenProject GmbH
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program 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 2
// of the License, or (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See COPYRIGHT and LICENSE files for more details.
//++

import { BcfResourceCollectionPath } from 'core-app/features/bim/bcf/api/bcf-path-resources';
import { BcfApiRequestService } from 'core-app/features/bim/bcf/api/bcf-api-request.service';
import { BcfViewpointInterface } from 'core-app/features/bim/bcf/api/viewpoints/bcf-viewpoint.interface';
import { HTTPClientHeaders, HTTPClientParamMap } from 'core-app/features/hal/http/http.interfaces';
import { Observable } from 'rxjs';
import { BcfViewpointPaths } from 'core-app/features/bim/bcf/api/viewpoints/bcf-viewpoint.paths';
import { CreateBcfViewpointData } from 'core-app/features/bim/bcf/api/bcf-api.model';

export class BcfViewpointCollectionPath extends BcfResourceCollectionPath<BcfViewpointPaths> {
readonly bcfTopicService = new BcfApiRequestService<BcfViewpointInterface>(this.injector);

get(params:HTTPClientParamMap = {}, headers:HTTPClientHeaders = {}) {
throw new Error('Not implemented');
}
readonly bcfViewpointService = new BcfApiRequestService<CreateBcfViewpointData>(this.injector);

post(viewpoint:BcfViewpointInterface):Observable<BcfViewpointInterface> {
post(viewpoint:CreateBcfViewpointData):Observable<CreateBcfViewpointData> {
return this
.bcfTopicService
.bcfViewpointService
.request(
'post',
this.toPath(),
Expand Down
@@ -1,10 +1,38 @@
import { BcfViewpointInterface } from 'core-app/features/bim/bcf/api/viewpoints/bcf-viewpoint.interface';
// -- copyright
// OpenProject is an open source project management software.
// Copyright (C) 2012-2021 the OpenProject GmbH
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program 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 2
// of the License, or (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See COPYRIGHT and LICENSE files for more details.
//++

import { CreateBcfViewpointData } from 'core-app/features/bim/bcf/api/bcf-api.model';

export interface BcfViewpointItem {
/** The URL of the viewpoint, if persisted */
href?:string|null;
/** URL (persisted or data) to the snapshot */
snapshotURL:string;
/** The loaded snapshot, if exists */
viewpoint?:BcfViewpointInterface;
viewpoint?:CreateBcfViewpointData;
}
@@ -0,0 +1,41 @@
// -- copyright
// OpenProject is an open source project management software.
// Copyright (C) 2012-2021 the OpenProject GmbH
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program 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 2
// of the License, or (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See COPYRIGHT and LICENSE files for more details.
//++

import { BcfResourcePath } from 'core-app/features/bim/bcf/api/bcf-path-resources';
import { BcfApiRequestService } from 'core-app/features/bim/bcf/api/bcf-api-request.service';
import { HTTPClientHeaders, HTTPClientParamMap } from 'core-app/features/hal/http/http.interfaces';
import { Observable } from 'rxjs';
import { BcfViewpointSelection } from 'core-app/features/bim/bcf/api/bcf-api.model';

export class BcfViewpointSelectionPath extends BcfResourcePath {
readonly bcfViewpointsService = new BcfApiRequestService<BcfViewpointSelection>(this.injector);

get(params:HTTPClientParamMap = {}, headers:HTTPClientHeaders = {}):Observable<BcfViewpointSelection> {
return this.bcfViewpointsService.get(this.toPath(), params, headers);
}
}

0 comments on commit 7efc094

Please sign in to comment.