Skip to content

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

Resolve merge conflict

Wieland Lindenthal211f0fdf32bf
diff --git a/frontend/src/app/modules/bcf/bcf-buttons/bcf-add-viewpoint-button.component.ts b/frontend/src/app/modules/bcf/bcf-buttons/bcf-add-viewpoint-button.component.ts
new file mode 100644
index 00000000000..a82637bcf13
--- /dev/null
+++ b/frontend/src/app/modules/bcf/bcf-buttons/bcf-add-viewpoint-button.component.ts
@@ -0,0 +1,84 @@
+// -- copyright
+// OpenProject is a project management system.
+// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
+//
+// 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 doc/COPYRIGHT.rdoc for more details.
+// ++
+
+import {Component, OnDestroy, OnInit} from '@angular/core';
+import {I18nService} from 'core-app/modules/common/i18n/i18n.service';
+import {CurrentProjectService} from "core-components/projects/current-project.service";
+import {BcfPathHelperService} from "core-app/modules/bcf/helper/bcf-path-helper.service";
+import {RevitBridgeService} from "core-app/modules/bcf/services/revit-bridge.service";
+import {distinctUntilChanged, filter} from "rxjs/operators";
+import {untilComponentDestroyed} from "ng2-rx-componentdestroyed";
+
+@Component({
+ template: `
+ <a [title]="text.add_viewpoint" class="button import-bcf-button" (click)="handleClick()">
+ <op-icon icon-classes="button--icon icon-add"></op-icon>
+ <span class="button--text"> {{text.viewpoint}} </span>
+ </a>
+ `,
+ selector: 'bcf-add-viewpoint-button',
+})
+export class BcfAddViewpointButtonComponent implements OnInit, OnDestroy {
+ public text = {
+ viewpoint: this.I18n.t('js.bcf.viewpoint'),
+ add_viewpoint: this.I18n.t('js.bcf.add_viewpoint'),
+ };
+
+ constructor(readonly I18n:I18nService,
+ readonly currentProject:CurrentProjectService,
+ readonly bcfPathHelper:BcfPathHelperService,
+ readonly revitBridgeService:RevitBridgeService) {
+ }
+
+ public handleClick() {
+ console.log("handleClick");
+ const trackingId = this.revitBridgeService.newTrackingId();
+
+ this.revitBridgeService.sendMessageToRevit('createViewpoint', trackingId, '');
+
+ this.revitBridgeService.revitMessageReceived$
+ .pipe(
+ distinctUntilChanged(),
+ filter(message => message.messageType === 'viewpointCreated' && message.trackingId === trackingId),
+ untilComponentDestroyed(this)
+ )
+ .subscribe(message => this.saveViewpoint(message));
+ }
+
+ private saveViewpoint(message:any):void {
+ console.log('save viewpoint with', message);
+ }
+
+ public ngOnInit():void {
+ console.log("init add viewpoint button component");
+ }
+
+ public ngOnDestroy():void {
+ // nop
+ }
+}
diff --git a/frontend/src/app/modules/bcf/bcf-wp-single-view/bcf-wp-single-view.component.html b/frontend/src/app/modules/bcf/bcf-wp-single-view/bcf-wp-single-view.component.html
index 679250417c0..b59b3d1cbd4 100644
--- a/frontend/src/app/modules/bcf/bcf-wp-single-view/bcf-wp-single-view.component.html
+++ b/frontend/src/app/modules/bcf/bcf-wp-single-view/bcf-wp-single-view.component.html
@@ -6,3 +6,5 @@
(previewClose)="galleryPreviewClose()">
</ngx-gallery>
</div>
+
+<bcf-add-viewpoint-button></bcf-add-viewpoint-button>
\ No newline at end of file
diff --git a/frontend/src/app/modules/bcf/openproject-bcf.module.ts b/frontend/src/app/modules/bcf/openproject-bcf.module.ts
index d38c5fcc6fa..18f02630d2b 100644
--- a/frontend/src/app/modules/bcf/openproject-bcf.module.ts
+++ b/frontend/src/app/modules/bcf/openproject-bcf.module.ts
@@ -36,7 +36,8 @@ import {BcfImportButtonComponent} from "core-app/modules/bcf/bcf-buttons/bcf-imp
import {BcfDetectorService} from "core-app/modules/bcf/helper/bcf-detector.service";
import {BcfPathHelperService} from "core-app/modules/bcf/helper/bcf-path-helper.service";
import {BcfExportButtonComponent} from "core-app/modules/bcf/bcf-buttons/bcf-export-button.component";
-
+import {BcfAddViewpointButtonComponent} from "core-app/modules/bcf/bcf-buttons/bcf-add-viewpoint-button.component";
+import {RevitBridgeService} from "core-app/modules/bcf/services/revit-bridge.service";
@NgModule({
imports: [
@@ -46,17 +47,20 @@ import {BcfExportButtonComponent} from "core-app/modules/bcf/bcf-buttons/bcf-exp
providers: [
{ provide: APP_INITIALIZER, useFactory: initializeBcfDisplayFields, deps: [DisplayFieldService], multi: true },
BcfDetectorService,
- BcfPathHelperService
+ BcfPathHelperService,
+ RevitBridgeService
],
declarations: [
BcfWpSingleViewComponent,
BcfImportButtonComponent,
- BcfExportButtonComponent
+ BcfExportButtonComponent,
+ BcfAddViewpointButtonComponent
],
exports: [
BcfWpSingleViewComponent,
BcfImportButtonComponent,
- BcfExportButtonComponent
+ BcfExportButtonComponent,
+ BcfAddViewpointButtonComponent
],
entryComponents: [
]
diff --git a/frontend/src/app/modules/bcf/services/revit-bridge.service.ts b/frontend/src/app/modules/bcf/services/revit-bridge.service.ts
new file mode 100644
index 00000000000..491fe5cb7c6
--- /dev/null
+++ b/frontend/src/app/modules/bcf/services/revit-bridge.service.ts
@@ -0,0 +1,61 @@
+declare global {
+ interface Window { bcfierBridge:any; }
+}
+
+import {HostListener, Injectable} from '@angular/core';
+import {Subject} from "rxjs";
+
+@Injectable()
+export class RevitBridgeService {
+ private revitMessageReceivedSource = new Subject<{ messageType:string, trackingId:string, messagePayload:string }>();
+ public revitMessageReceived$ = this.revitMessageReceivedSource.asObservable();
+ private _trackingIdNumber = 0;
+ private _ready = false;
+
+ public get ready() {
+ return this._ready;
+ }
+
+ @HostListener('window:revit.client.loaded')
+ onRevitClientLoaded() {
+ console.log('EVENT onRevitClientLoaded');
+ this.hookUpRevitListener();
+ }
+
+ constructor() {
+ if (window.bcfierBridge) {
+ this.hookUpRevitListener();
+ }
+ }
+
+ public sendMessageToRevit(messageType:string, trackingId:string, messagePayload?:any) {
+ if (!this.ready) {
+ console.log('The BCFier Revit Bridge is not ready yet.');
+ return;
+ }
+
+ const jsonPayload = messagePayload != null ? JSON.stringify(messagePayload) : null;
+ window.bcfierBridge.sendMessageToBcfier(messageType, trackingId, jsonPayload);
+ }
+
+ private hookUpRevitListener() {
+ window.bcfierBridge.sendMessageToOpenProject = (messageString:string) => {
+ const message = JSON.parse(messageString);
+ const messageType = message.messageType;
+ const trackingId = message.trackingId;
+ const messagePayload = JSON.parse(message.messagePayload);
+
+ this.revitMessageReceivedSource.next({
+ messageType: messageType,
+ trackingId: trackingId,
+ messagePayload: messagePayload
+ });
+ };
+ this._ready = true;
+ }
+
+ public newTrackingId():string {
+ this._trackingIdNumber = this._trackingIdNumber + 1;
+ return String(this._trackingIdNumber);
+ }
+}
diff --git a/modules/bim/config/locales/js-en.yml b/modules/bim/config/locales/js-en.yml
index fd19702f026..55c0210228b 100644
--- a/modules/bim/config/locales/js-en.yml
+++ b/modules/bim/config/locales/js-en.yml
@@ -4,6 +4,8 @@ en:
bcf:
import: 'Import'
export: 'Export'
+ viewpoint: 'Viewpoint'
+ add_viewpoint: 'Add viewpoint'
ifc_models:
models:
default: 'Default IFC models'