1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
/***/ "./src/gui/ViewerObjectContextMenu.js":
/*!********************************************!*\
!*** ./src/gui/ViewerObjectContextMenu.js ***!
\********************************************/
/*! exports provided: ViewerObjectContextMenu */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViewerObjectContextMenu", function() { return ViewerObjectContextMenu; });
/* harmony import */ var _ObjectContextMenu__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ObjectContextMenu */ "./src/gui/ObjectContextMenu.js");
/* harmony import */ var _logger_Logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../logger/Logger */ "./src/logger/Logger.js");
/**
* Constructs a ViewerObjectContextMenu object.
* @param {Viewer} viewer
* @constructor
*/
function ViewerObjectContextMenu(viewer) {
_ObjectContextMenu__WEBPACK_IMPORTED_MODULE_0__["ObjectContextMenu"].call(this, viewer);
}
ViewerObjectContextMenu.prototype = Object.create(_ObjectContextMenu__WEBPACK_IMPORTED_MODULE_0__["ObjectContextMenu"].prototype);
ViewerObjectContextMenu.prototype.constructor = ViewerObjectContextMenu;
/**
* Builds the context menu to be displayed.
* @override
* @param {Event} event - Browser event that requested the context menu
* @param {Object} status - Information about nodes: numSelected, hasSelected, hasVisible, hasHidden.
* @returns {?Array} An array of menu items.
*/
ViewerObjectContextMenu.prototype.buildMenu = function (event, status) {var _this = this;
// Context menu varies depending on whether we show 2D or 3D models. If we have neither 2d nor 3d, just don't create it.
if (!this.viewer.model) {
return;
}
var that = this,
menu = [],
nav = this.viewer.navigation,
is2d = this.viewer.model.is2d();
// the title strings here are added to the viewer.loc.json for localization
if (status.hasSelected) {
menu.push({
title: "Isolate",
target: function target() {
var selection = that.viewer.getAggregateSelection();
that.viewer.impl.visibilityManager.aggregateIsolate(selection);
that.viewer.clearSelection();
_logger_Logger__WEBPACK_IMPORTED_MODULE_1__["logger"].track({ name: 'isolate_count', aggregate: 'count' });
} });
if (status.hasVisible) {
menu.push({
title: "Hide Selected",
target: function target() {
var visMan = that.viewer.impl.visibilityManager;
that.viewer.getAggregateSelection(function (model, dbId) {
visMan.hide(dbId, model);
});
that.viewer.clearSelection();
} });
}
if (status.hasHidden) {
menu.push({
title: "Show Selected",
target: function target() {
// This is such a weird use case. Users can't select hidden nodes.
// For this to work, selection must have been done through code.
var selected = that.viewer.getSelection();
that.viewer.clearSelection();
that.viewer.show(selected);
} });
}
}
if (is2d) {
menu.push({
title: "Show All Layers",
target: function target() {
that.viewer.setLayerVisible(null, true);
} });
}
menu.push({
title: "Show All Objects",
target: function target() {
that.viewer.showAll();
_logger_Logger__WEBPACK_IMPORTED_MODULE_1__["logger"].track({ name: 'showall', aggregate: 'count' });
} });
// Fit-to-view only work with selections from one model.
var aggregateSelection = that.viewer.getAggregateSelection();
if (!is2d && aggregateSelection.length === 1 && nav.isActionEnabled('gotoview')) {
menu.push({
title: "Focus",
target: function target() {
aggregateSelection = that.viewer.getAggregateSelection(); // Get the aggregate selection again
if (aggregateSelection.length > 0) {
var singleRes = aggregateSelection[0];
that.viewer.fitToView(singleRes.selection, singleRes.model);
} else if (aggregateSelection.length === 0) {
that.viewer.fitToView(); // Fit to whole model, the first one loaded.
}
_logger_Logger__WEBPACK_IMPORTED_MODULE_1__["logger"].track({ name: 'fittoview', aggregate: 'count' });
} });
}
// Pivot point
if (!is2d) {
var rect = this.viewer.impl.getCanvasBoundingClientRect();
var canvasX = event.clientX - rect.left;
var canvasY = event.clientY - rect.top;
var res = this.viewer.clientToWorld(canvasX, canvasY, false);
if (res) {
menu.push({
title: "Pivot",
target: function target() {
_this.viewer.navigation.setPivotPoint(res.point);
} });
}
}
if (status.hasSelected) {
menu.push({
title: "Clear Selection",
target: function target() {
that.viewer.clearSelection();
_logger_Logger__WEBPACK_IMPORTED_MODULE_1__["logger"].track({ name: 'clearselection', aggregate: 'count' });
} });
}
return menu;
};
|