-
Notifications
You must be signed in to change notification settings - Fork 208
/
GenericElements.ts
269 lines (250 loc) · 10.3 KB
/
GenericElements.ts
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Elements
*/
import { Id64String } from "@itwin/core-bentley";
import {
CalloutProps, DefinitionElementProps, ElementProps, GeometricElement2dProps, GeometricElement3dProps, GeometricModel3dProps, IModel,
InformationPartitionElementProps, ModelProps, PhysicalElementProps, PhysicalTypeProps, TypeDefinitionElementProps, ViewAttachmentLabelProps,
} from "@itwin/core-common";
import {
Document, GraphicalElement2d, GraphicalElement3d, GraphicalPartition3d, GraphicalType2d, GroupInformationElement, GroupInformationPartition,
PhysicalElement, PhysicalType, SpatialLocationElement,
} from "../Element";
import { IModelDb } from "../IModelDb";
import { PhysicalMaterial } from "../Material";
import { GraphicalModel3d, GroupInformationModel } from "../Model";
import { SubjectOwnsPartitionElements } from "../NavigationRelationship";
/** A graphical detailing symbol that is placed on a [[Drawing]] or [[Sheet]].
* @public
*/
export abstract class DetailingSymbol extends GraphicalElement2d {
/** @internal */
public static override get className(): string { return "DetailingSymbol"; }
public constructor(props: GeometricElement2dProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** A graphical DetailingSymbol that contains title text.
* @public
*/
export class TitleText extends DetailingSymbol {
/** @internal */
public static override get className(): string { return "TitleText"; }
public constructor(props: GeometricElement2dProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** A graphical DetailingSymbol that contains a view attachment label.
* @public
*/
export class ViewAttachmentLabel extends DetailingSymbol {
/** @internal */
public static override get className(): string { return "ViewAttachmentLabel"; }
public constructor(props: ViewAttachmentLabelProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** A graphical DetailingSymbol that calls out a reference to another drawing.
* @public
*/
export abstract class Callout extends DetailingSymbol {
/** @internal */
public static override get className(): string { return "Callout"; }
public constructor(props: CalloutProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** A graphical Callout that references a section drawing.
* @public
*/
export class SectionCallout extends Callout {
/** @internal */
public static override get className(): string { return "SectionCallout"; }
public constructor(props: CalloutProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** A graphical Callout that references an elevation drawing.
* @public
*/
export class ElevationCallout extends Callout {
/** @internal */
public static override get className(): string { return "ElevationCallout"; }
public constructor(props: CalloutProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** A graphical Callout that references a plan drawing.
* @public
*/
export class PlanCallout extends Callout {
/** @internal */
public static override get className(): string { return "PlanCallout"; }
public constructor(props: CalloutProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** A graphical Callout that references a detail drawing.
* @public
*/
export class DetailCallout extends Callout {
/** @internal */
public static override get className(): string { return "DetailCallout"; }
public constructor(props: CalloutProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** A generic container for persisting BisCore:GraphicalElement3d instances.
* @public
*/
export class GenericGraphicalModel3d extends GraphicalModel3d {
/** @internal */
public static override get className(): string { return "GraphicalModel3d"; }
public constructor(props: GeometricModel3dProps, iModel: IModelDb) {
super(props, iModel);
}
/** Insert a BisCore:GraphicalPartition3d and a Generic:GraphicalModel3d that sub-models it.
* @param iModelDb Insert into this iModel
* @param parentSubjectId The GraphicalPartition3d will be inserted as a child of this Subject element.
* @param name The name of the GraphicalPartition3d that the new Generic:GraphicalModel3d will sub-model.
* @param isPlanProjection Optional value (default is false) that indicates if the contents of this model are expected to be in an XY plane.
* @returns The Id of the newly inserted GraphicalPartition3d and GraphicalModel3d (same value).
* @throws [[IModelError]] if there is an insert problem.
*/
public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String {
const partitionProps: InformationPartitionElementProps = {
classFullName: GraphicalPartition3d.classFullName,
model: IModel.repositoryModelId,
parent: new SubjectOwnsPartitionElements(parentSubjectId),
code: GraphicalPartition3d.createCode(iModelDb, parentSubjectId, name),
};
const partitionId = iModelDb.elements.insertElement(partitionProps);
const modelProps: GeometricModel3dProps = {
classFullName: this.classFullName,
modeledElement: { id: partitionId },
isPlanProjection,
};
return iModelDb.models.insertModel(modelProps);
}
}
/** The Generic:Graphic3d class is used when 3D graphics cannot be further classified.
* @note More-specific BisCore:GraphicalElement3d subclasses should be used wherever possible.
* @public
*/
export class Graphic3d extends GraphicalElement3d {
/** @internal */
public static override get className(): string { return "Graphic3d"; }
public constructor(props: GeometricElement3dProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** The Generic:PhysicalObject class is used when physical elements cannot be further classified.
* @note More-specific BisCore:PhysicalElement subclasses should be used wherever possible.
* @public
*/
export class PhysicalObject extends PhysicalElement {
/** @internal */
public static override get className(): string { return "PhysicalObject"; }
public constructor(props: PhysicalElementProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** The Generic:SpatialLocation class is used when spatial locations cannot be further classified.
* @note More-specific BisCore:SpatialLocationElement subclasses should be used wherever possible.
* @public
*/
export class SpatialLocation extends SpatialLocationElement {
/** @internal */
public static override get className(): string { return "SpatialLocation"; }
public constructor(props: GeometricElement3dProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** A generic container for BisCore:GroupInformationElement instances.
* @public
*/
export class GroupModel extends GroupInformationModel {
/** @internal */
public static override get className(): string { return "GroupModel"; }
public constructor(props: ModelProps, iModel: IModelDb) {
super(props, iModel);
}
/** Insert a GroupInformationPartition and a GroupModel that breaks it down.
* @param iModelDb Insert into this iModel
* @param parentSubjectId The GroupInformationPartition will be inserted as a child of this Subject element.
* @param name The name of the GroupInformationPartition that the new GroupModel will break down.
* @returns The Id of the newly inserted GroupModel.
* @throws [[IModelError]] if there is an insert problem.
*/
public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String {
const partitionProps: InformationPartitionElementProps = {
classFullName: GroupInformationPartition.classFullName,
model: IModel.repositoryModelId,
parent: new SubjectOwnsPartitionElements(parentSubjectId),
code: GroupInformationPartition.createCode(iModelDb, parentSubjectId, name),
};
const partitionId = iModelDb.elements.insertElement(partitionProps);
return iModelDb.models.insertModel({
classFullName: this.classFullName,
modeledElement: { id: partitionId },
});
}
}
/** The Generic:Group class is used when the group cannot be further classified.
* @public
*/
export class Group extends GroupInformationElement {
/** @internal */
public static override get className(): string { return "Group"; }
public constructor(props: ElementProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** The Generic:Document class is used when a document cannot be further classified.
* @note More-specific BisCore:Document subclasses should be used wherever possible.
* @public
*/
export class GenericDocument extends Document {
/** @internal */
public static override get className(): string { return "Document"; }
public constructor(props: ElementProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** The Generic:PhysicalMaterial class is used when the physical material cannot be further classified.
* @note More-specific BisCore:PhysicalMaterial subclasses should be used wherever possible.
* @public
*/
export class GenericPhysicalMaterial extends PhysicalMaterial {
/** @internal */
public static override get className(): string { return "PhysicalMaterial"; }
public constructor(props: DefinitionElementProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** The Generic:PhysicalType class is used when the physical type cannot be further classified.
* @note More-specific BisCore:PhysicalType subclasses should be used wherever possible.
* @public
*/
export class GenericPhysicalType extends PhysicalType {
/** @internal */
public static override get className(): string { return "PhysicalType"; }
public constructor(props: PhysicalTypeProps, iModel: IModelDb) {
super(props, iModel);
}
}
/** The Generic:GraphicalType2d class is used when graphical types cannot be further classified.
* @note More-specific BisCore:GraphicalType2d subclasses should be used wherever possible.
* @public
*/
export class GenericGraphicalType2d extends GraphicalType2d {
/** @internal */
public static override get className(): string { return "GraphicalType2d"; }
public constructor(props: TypeDefinitionElementProps, iModel: IModelDb) {
super(props, iModel);
}
}