@ccpc/core 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/index.js +2080 -0
  2. package/package.json +4 -23
  3. package/types/display/dirty_prop.d.ts +3 -0
  4. package/types/display/state_object.d.ts +30 -0
  5. package/types/document/doc_saver.d.ts +13 -0
  6. package/types/document/document.d.ts +37 -0
  7. package/types/document/element_mgr.d.ts +28 -0
  8. package/types/document/i_document.d.ts +60 -0
  9. package/{dist → types}/document/id_pool.d.ts +3 -1
  10. package/types/element/db.d.ts +49 -0
  11. package/types/element/element.d.ts +55 -0
  12. package/{dist → types}/element/element_decorator.d.ts +0 -1
  13. package/{dist → types}/element/element_id.d.ts +1 -2
  14. package/types/element/i_element.d.ts +64 -0
  15. package/types/element/tmp_element/tmp_element.d.ts +6 -0
  16. package/types/element/tmp_element/tmp_element_painter.d.ts +27 -0
  17. package/types/grep/display/display_object.d.ts +37 -0
  18. package/types/grep/display/display_object_mgr.d.ts +23 -0
  19. package/types/grep/display/grep_display.d.ts +16 -0
  20. package/types/grep/gcurve2d.d.ts +15 -0
  21. package/types/grep/ggroup.d.ts +29 -0
  22. package/types/grep/gnode.d.ts +110 -0
  23. package/types/grep/gnode2d.d.ts +9 -0
  24. package/types/grep/gnode_type.d.ts +10 -0
  25. package/types/grep/gpoint2d.d.ts +14 -0
  26. package/types/grep/gpolycurve.d.ts +13 -0
  27. package/types/grep/gpolygon.d.ts +14 -0
  28. package/types/grep/grep.d.ts +15 -0
  29. package/types/grep/gtext2d.d.ts +14 -0
  30. package/types/grep/i_style.d.ts +42 -0
  31. package/types/grep/style_utils.d.ts +22 -0
  32. package/types/index.d.ts +41 -0
  33. package/types/model_view/i_high_light.d.ts +6 -0
  34. package/types/model_view/i_selection.d.ts +6 -0
  35. package/types/model_view/model_changed_cache.d.ts +35 -0
  36. package/types/model_view/model_view.d.ts +45 -0
  37. package/types/render/i_render.d.ts +24 -0
  38. package/types/render/null_render.d.ts +10 -0
  39. package/types/render/render_node.d.ts +68 -0
  40. package/types/render/render_node_util.d.ts +4 -0
  41. package/types/request/buildin_request/redo_request.d.ts +5 -0
  42. package/types/request/buildin_request/undo_request.d.ts +5 -0
  43. package/{dist → types}/request/i_request.d.ts +0 -1
  44. package/{dist → types}/request/request.d.ts +0 -1
  45. package/{dist → types}/request/request_decorator.d.ts +0 -1
  46. package/{dist → types}/request/request_mgr.d.ts +0 -1
  47. package/{dist → types}/toolkit/class_manager.d.ts +0 -1
  48. package/types/toolkit/cmath_util.d.ts +4 -0
  49. package/{dist → types}/toolkit/debug_util.d.ts +0 -1
  50. package/{dist → types}/transaction/i_transaction.d.ts +0 -1
  51. package/{dist → types}/transaction/i_transaction_base.d.ts +0 -1
  52. package/{dist → types}/transaction/i_transaction_group.d.ts +0 -1
  53. package/{dist → types}/transaction/transaction.d.ts +0 -1
  54. package/{dist → types}/transaction/transaction_base.d.ts +0 -1
  55. package/{dist → types}/transaction/transaction_group.d.ts +0 -1
  56. package/{dist → types}/transaction/transaction_mgr.d.ts +0 -1
  57. package/{dist → types}/transaction/undo_redo_entity.d.ts +0 -1
  58. package/types/types/type_define.d.ts +31 -0
  59. package/{dist → types}/types/type_guard.d.ts +1 -1
  60. package/README.md +0 -11
  61. package/dist/document/document.d.ts +0 -21
  62. package/dist/document/document.d.ts.map +0 -1
  63. package/dist/document/document.js +0 -53
  64. package/dist/document/element_mgr.d.ts +0 -11
  65. package/dist/document/element_mgr.d.ts.map +0 -1
  66. package/dist/document/element_mgr.js +0 -27
  67. package/dist/document/i_document.d.ts +0 -19
  68. package/dist/document/i_document.d.ts.map +0 -1
  69. package/dist/document/i_document.js +0 -1
  70. package/dist/document/id_pool.d.ts.map +0 -1
  71. package/dist/document/id_pool.js +0 -67
  72. package/dist/element/c_element.d.ts +0 -6
  73. package/dist/element/c_element.d.ts.map +0 -1
  74. package/dist/element/c_element.js +0 -6
  75. package/dist/element/element.d.ts +0 -42
  76. package/dist/element/element.d.ts.map +0 -1
  77. package/dist/element/element.js +0 -72
  78. package/dist/element/element_decorator.d.ts.map +0 -1
  79. package/dist/element/element_decorator.js +0 -40
  80. package/dist/element/element_id.d.ts.map +0 -1
  81. package/dist/element/element_id.js +0 -30
  82. package/dist/element/i_element.d.ts +0 -30
  83. package/dist/element/i_element.d.ts.map +0 -1
  84. package/dist/element/i_element.js +0 -1
  85. package/dist/index.d.ts +0 -12
  86. package/dist/index.d.ts.map +0 -1
  87. package/dist/index.js +0 -8
  88. package/dist/request/i_request.d.ts.map +0 -1
  89. package/dist/request/i_request.js +0 -1
  90. package/dist/request/request.d.ts.map +0 -1
  91. package/dist/request/request.js +0 -11
  92. package/dist/request/request_decorator.d.ts.map +0 -1
  93. package/dist/request/request_decorator.js +0 -10
  94. package/dist/request/request_mgr.d.ts.map +0 -1
  95. package/dist/request/request_mgr.js +0 -77
  96. package/dist/toolkit/class_manager.d.ts.map +0 -1
  97. package/dist/toolkit/class_manager.js +0 -54
  98. package/dist/toolkit/debug_util.d.ts.map +0 -1
  99. package/dist/toolkit/debug_util.js +0 -15
  100. package/dist/transaction/i_transaction.d.ts.map +0 -1
  101. package/dist/transaction/i_transaction.js +0 -1
  102. package/dist/transaction/i_transaction_base.d.ts.map +0 -1
  103. package/dist/transaction/i_transaction_base.js +0 -11
  104. package/dist/transaction/i_transaction_group.d.ts.map +0 -1
  105. package/dist/transaction/i_transaction_group.js +0 -1
  106. package/dist/transaction/transaction.d.ts.map +0 -1
  107. package/dist/transaction/transaction.js +0 -41
  108. package/dist/transaction/transaction_base.d.ts.map +0 -1
  109. package/dist/transaction/transaction_base.js +0 -32
  110. package/dist/transaction/transaction_group.d.ts.map +0 -1
  111. package/dist/transaction/transaction_group.js +0 -242
  112. package/dist/transaction/transaction_mgr.d.ts.map +0 -1
  113. package/dist/transaction/transaction_mgr.js +0 -84
  114. package/dist/transaction/undo_redo_entity.d.ts.map +0 -1
  115. package/dist/transaction/undo_redo_entity.js +0 -261
  116. package/dist/types/dump_type.d.ts +0 -4
  117. package/dist/types/dump_type.d.ts.map +0 -1
  118. package/dist/types/dump_type.js +0 -1
  119. package/dist/types/type_guard.d.ts.map +0 -1
  120. package/dist/types/type_guard.js +0 -1
package/package.json CHANGED
@@ -1,30 +1,11 @@
1
1
  {
2
2
  "name": "@ccpc/core",
3
- "version": "0.1.0",
4
- "private": false,
3
+ "version": "0.1.2",
5
4
  "description": "Core data model layer for editor",
6
5
  "license": "MIT",
7
6
  "type": "module",
8
- "main": "./dist/index.js",
9
- "types": "./dist/index.d.ts",
10
- "exports": {
11
- ".": {
12
- "types": "./dist/index.d.ts",
13
- "import": "./dist/index.js"
14
- }
15
- },
16
- "files": [
17
- "dist",
18
- "README.md",
19
- "LICENSE"
20
- ],
21
- "publishConfig": {
22
- "access": "public"
23
- },
24
- "scripts": {
25
- "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput",
26
- "build": "tsc -p tsconfig.json",
27
- "lint": "eslint . --ext .ts",
28
- "lint:fix": "eslint . --ext .ts --fix"
7
+ "main": "./index.cjs",
8
+ "peerDependencies": {
9
+ "@ccpc/math": "^0.1.4"
29
10
  }
30
11
  }
@@ -0,0 +1,3 @@
1
+ import { IPrototype } from '../types/type_guard';
2
+ import type { StateObject } from './state_object';
3
+ export declare function dirtyProp<T extends StateObject>(equals?: (o: unknown, n: unknown) => boolean): (target: IPrototype<T>, fieldName: string) => void;
@@ -0,0 +1,30 @@
1
+ export declare abstract class StateObject {
2
+ /** 脏标识 */
3
+ private _dirty;
4
+ /** 注销状态 */
5
+ private _disposed;
6
+ /** 脏属性池 */
7
+ protected _dirtyPropsPool: Map<string, unknown>;
8
+ /**
9
+ * 脏处理
10
+ */
11
+ dirty(): void;
12
+ /**
13
+ * 清理脏
14
+ */
15
+ unDirty(): void;
16
+ /**
17
+ * 是否脏
18
+ * @returns boolean
19
+ */
20
+ isDirty(): boolean;
21
+ /**
22
+ * 注销
23
+ */
24
+ dispose(): void;
25
+ /**
26
+ * 是否注销
27
+ * @returns
28
+ */
29
+ isDisposed(): boolean;
30
+ }
@@ -0,0 +1,13 @@
1
+ import { IDocFile, IDocument } from './i_document';
2
+ export declare class DocSaver {
3
+ private _doc;
4
+ constructor(doc: IDocument);
5
+ dump(): IDocFile;
6
+ private _dumpDoc;
7
+ /**
8
+ * 同步加载
9
+ */
10
+ syncLoad(file: IDocFile): boolean;
11
+ private _clearDocument;
12
+ private _fillDocument;
13
+ }
@@ -0,0 +1,37 @@
1
+ import type { IElement } from '../element/i_element';
2
+ import type { IDocFile, IDocument } from './i_document';
3
+ import { IDPool } from './id_pool';
4
+ import { ElementId } from '../element/element_id';
5
+ import { TransactionMgr } from '../transaction/transaction_mgr';
6
+ import { IConstructor } from '../types/type_guard';
7
+ import { EN_ModelViewChanged } from '../types/type_define';
8
+ import { ModelView } from '../model_view/model_view';
9
+ export declare class Document implements IDocument {
10
+ isMainDoc: boolean;
11
+ /**
12
+ * 文档唯一标识
13
+ */
14
+ private _id;
15
+ /**是否可以创建对象*/
16
+ static canCreate: boolean;
17
+ readonly idPool: IDPool;
18
+ readonly elementMgr: import("./element_mgr").ElementMgr;
19
+ readonly transactionMgr: TransactionMgr;
20
+ readonly requestMgr: import("..").RequestMgr;
21
+ readonly modelView: ModelView;
22
+ constructor();
23
+ get id(): string;
24
+ set id(val: string);
25
+ create<T extends IElement>(ctor: IConstructor<T>): T;
26
+ deleteElementsById(...eIds: Array<number | ElementId>): boolean;
27
+ getElementById<T extends IElement>(id: ElementId | number): T | undefined;
28
+ getElementByIdEnsure<T extends IElement>(eleId: ElementId | number): T;
29
+ getElementsByIds(eleIds: Array<ElementId | number>): IElement[];
30
+ filterElements(filter?: (ele: IElement) => boolean): IElement[];
31
+ checkIfCanModifyDoc(): void;
32
+ cacheForViewElementChanged(evtType: EN_ModelViewChanged, elements: Array<IElement>): void;
33
+ updateView(rebuild?: boolean): boolean;
34
+ dump(): IDocFile;
35
+ load(file: IDocFile): this;
36
+ destroy(): void;
37
+ }
@@ -0,0 +1,28 @@
1
+ import type { IElement, IElementCtor } from '../element/i_element';
2
+ export declare class ElementMgr {
3
+ private static _instance?;
4
+ /**
5
+ * 当前文档中的所有对象
6
+ */
7
+ private readonly _elements;
8
+ /**
9
+ * 对象类管理器
10
+ */
11
+ private readonly _eleClsMgr;
12
+ static instance(): ElementMgr;
13
+ /**
14
+ * 注册Element
15
+ */
16
+ registerElement(ctor: string, eleCtor: IElementCtor): void;
17
+ /**
18
+ * 根据序列化id获取Element构造函数
19
+ */
20
+ getElementClsByCtor(ctor: string): IElementCtor | undefined;
21
+ getElementById<T extends IElement>(id: number): T;
22
+ getAllElements(): IElement[];
23
+ getAllElementIds(): number[];
24
+ add(element: IElement, force?: boolean): boolean;
25
+ delete(id: number): boolean;
26
+ clear(): void;
27
+ }
28
+ export declare const elementMgr: ElementMgr;
@@ -0,0 +1,60 @@
1
+ import { ElementId } from '../element/element_id';
2
+ import type { IElement } from '../element/i_element';
3
+ import { ModelView } from '../model_view/model_view';
4
+ import { RequestMgr } from '../request/request_mgr';
5
+ import { TransactionMgr } from '../transaction/transaction_mgr';
6
+ import { EN_ModelViewChanged } from '../types/type_define';
7
+ import { IConstructor } from '../types/type_guard';
8
+ import type { ElementMgr } from './element_mgr';
9
+ import { IDPool } from './id_pool';
10
+ export type IElementFile = {
11
+ ctor: string;
12
+ [key: string]: unknown;
13
+ };
14
+ /**
15
+ * 文档JSON类型
16
+ */
17
+ export type IDocFile = {
18
+ id: string;
19
+ doc?: Array<IElementFile>;
20
+ };
21
+ export interface IDocument {
22
+ /**是否为主文档*/
23
+ isMainDoc: boolean;
24
+ /**文档唯一标识*/
25
+ id: string;
26
+ readonly idPool: IDPool;
27
+ /**对象管理器*/
28
+ readonly elementMgr: ElementMgr;
29
+ /**事务管理器*/
30
+ readonly transactionMgr: TransactionMgr;
31
+ readonly requestMgr: RequestMgr;
32
+ readonly modelView: ModelView;
33
+ create<T extends IElement>(ctor: IConstructor<T>): T;
34
+ deleteElementsById(...ids: Array<number | ElementId>): boolean;
35
+ getElementById<T extends IElement>(id: ElementId | number): T | undefined;
36
+ /**根据id获取对象*/
37
+ getElementByIdEnsure<T extends IElement>(eleId: ElementId | number): T;
38
+ getElementsByIds(eleIds: Array<ElementId | number>): IElement[];
39
+ /**
40
+ * 根据序列化id获取Element的类
41
+ */
42
+ /**
43
+ * 返回文档中满足filter条件的Element
44
+ * filter为空返回所有Element
45
+ */
46
+ filterElements(filter?: (ele: IElement) => boolean): IElement[];
47
+ /**
48
+ * 检测是否允许修改文档
49
+ * 包括增加、删除和修改
50
+ */
51
+ checkIfCanModifyDoc(): void;
52
+ /**
53
+ * 缓存模型层视图变化
54
+ */
55
+ cacheForViewElementChanged(evtType: EN_ModelViewChanged, elements: Array<IElement>): void;
56
+ updateView(rebuild?: boolean): boolean;
57
+ destroy(): void;
58
+ dump(): IDocFile;
59
+ load(file: IDocFile): this;
60
+ }
@@ -14,7 +14,9 @@ export declare class IDPool {
14
14
  genTmpId(): ElementId | undefined;
15
15
  genUnstableId(): ElementId | undefined;
16
16
  genStableId(): ElementId;
17
+ /**
18
+ * 重置稳定ID的起始计数
19
+ */
17
20
  clearStableId(startIdx: number): void;
18
21
  isStableId(id: number): boolean;
19
22
  }
20
- //# sourceMappingURL=id_pool.d.ts.map
@@ -0,0 +1,49 @@
1
+ import { IJSON } from '../types/type_define';
2
+ import { IDB, IModifiedProps } from './i_element';
3
+ export declare class DB implements IDB {
4
+ private _db;
5
+ private _cache;
6
+ get db(): IJSON;
7
+ get cache(): IJSON;
8
+ /**
9
+ * 获取修改的数据
10
+ */
11
+ getModified(): IModifiedProps[];
12
+ /**
13
+ * 数据入库
14
+ */
15
+ commit(): void;
16
+ /**
17
+ * 数据回滚
18
+ */
19
+ rollBack(): void;
20
+ /**
21
+ * 清空缓存
22
+ */
23
+ private _clearCache;
24
+ ownKeys(): string[];
25
+ dump(): IJSON;
26
+ load(json: IJSON): void;
27
+ private _dumpData;
28
+ private _dumpArr;
29
+ /**
30
+ * 加载数组
31
+ * @param arr JSON中的数组
32
+ * @param first 参考数组中的第一个值
33
+ * 数组中元素当前只支持dump、load对象和基础类型
34
+ */
35
+ private _loadArr;
36
+ private _dumpMap;
37
+ /**
38
+ * Map中的元素支持dump、load对象和基础元素类型
39
+ */
40
+ private _loadMap;
41
+ private _dumpSet;
42
+ /**
43
+ * 当前Set只支持里面所有元素为同一类型
44
+ */
45
+ private _loadSet;
46
+ private _dumpAProperty;
47
+ private _isDumpLoad;
48
+ private _isBasicType;
49
+ }
@@ -0,0 +1,55 @@
1
+ import { ElementId } from './element_id';
2
+ import { type IElement, type T_SerializedId } from './i_element';
3
+ import type { IDocument } from '../document/i_document';
4
+ import { GRep } from '../grep/grep';
5
+ import { DB } from './db';
6
+ export declare class Element extends DB implements IElement {
7
+ /**
8
+ * 保存到文档中的序列化Id
9
+ */
10
+ static serializedId: T_SerializedId;
11
+ id: ElementId;
12
+ name: string;
13
+ private _doc;
14
+ visible: boolean;
15
+ C_GRep: GRep;
16
+ constructor();
17
+ getDoc(): IDocument;
18
+ setDoc(doc: IDocument): void;
19
+ /**
20
+ * 空构造+初始化
21
+ */
22
+ init(..._params: unknown[]): this;
23
+ /**
24
+ * 获取序列化的id
25
+ */
26
+ getSerialId(): string;
27
+ /**
28
+ * 重置缓存的 GRep,强制后续重新生成图形表示。
29
+ */
30
+ markGRepDirty(): void;
31
+ /**
32
+ * 获取GRep显示对象
33
+ */
34
+ getGRep(): GRep;
35
+ getGRepWhenSelected(): GRep;
36
+ getGRepWhenActive(): GRep;
37
+ /**
38
+ * 设置GRep显示对象
39
+ */
40
+ setGRep(grep: GRep): boolean;
41
+ isElementVisible(): boolean;
42
+ /**
43
+ * 是否为临时对象
44
+ * 临时对象不受事务监管
45
+ */
46
+ isTemporary(): boolean;
47
+ dontSave(): boolean;
48
+ dontShowView(): boolean;
49
+ /**
50
+ * 属性变化是否应该缓存到视图
51
+ */
52
+ propShouldCacheToView(propName: string): boolean;
53
+ clone(): this;
54
+ onLoad(): void;
55
+ }
@@ -1,3 +1,2 @@
1
1
  import { IElement, IElementCtor } from './i_element';
2
2
  export declare const RegisterElement: (ctorStr: string) => <T extends IElement>(Ctor: IElementCtor<T>) => void;
3
- //# sourceMappingURL=element_decorator.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { IDBEleId } from '../types/dump_type';
1
+ import { IDBEleId } from '../types/type_define';
2
2
  declare class ElementId {
3
3
  static get INVALID(): ElementId;
4
4
  protected _id: number;
@@ -11,4 +11,3 @@ declare class ElementId {
11
11
  load(json: IDBEleId): void;
12
12
  }
13
13
  export { ElementId };
14
- //# sourceMappingURL=element_id.d.ts.map
@@ -0,0 +1,64 @@
1
+ import { IDocument } from '../document/i_document';
2
+ import { GRep } from '../grep/grep';
3
+ import { IJSON } from '../types/type_define';
4
+ import { ElementId } from './element_id';
5
+ export type IModifiedProps = {
6
+ propertyName: string;
7
+ oldValue: unknown;
8
+ newValue: unknown;
9
+ };
10
+ export interface IDB {
11
+ readonly db: Record<string, unknown>;
12
+ readonly cache: Record<string, unknown>;
13
+ getModified(): IModifiedProps[];
14
+ commit(): void;
15
+ rollBack(): void;
16
+ dump(): IJSON;
17
+ load(val: IJSON): void;
18
+ }
19
+ export interface IElement extends IDB {
20
+ id: ElementId;
21
+ name: string;
22
+ getDoc(): IDocument;
23
+ setDoc(doc: IDocument): void;
24
+ init(...params: unknown[]): this;
25
+ getSerialId(): string;
26
+ getGRep(): GRep;
27
+ /**
28
+ * 获取选中GRep
29
+ */
30
+ getGRepWhenSelected(): GRep;
31
+ /**
32
+ * 获取高亮GRep
33
+ */
34
+ getGRepWhenActive(): GRep;
35
+ setGRep(grep: GRep): boolean;
36
+ isElementVisible(): boolean;
37
+ isTemporary(): boolean;
38
+ dontSave(): boolean;
39
+ dontShowView(): boolean;
40
+ propShouldCacheToView(propName: string): boolean;
41
+ clone(): this;
42
+ onLoad(): void;
43
+ }
44
+ export type T_SerializedId = {
45
+ /**类序列化的唯一标识*/
46
+ ctor: string;
47
+ };
48
+ export type IElementCtor<T extends IElement = IElement> = {
49
+ new (): T;
50
+ serializedId: T_SerializedId;
51
+ };
52
+ export declare const EN_VIEW_CACHE_PROPS: {
53
+ readonly C_GREP: "C_GRep";
54
+ readonly VISIBLE: "visible";
55
+ };
56
+ export type IDumpLoad = {
57
+ dump(): unknown;
58
+ load(val: unknown): void;
59
+ };
60
+ export declare const MathSymbol: unique symbol;
61
+ export declare const DBGenerator: {
62
+ newGeoArray: <T>() => T[];
63
+ newGeoObject: <T>() => T;
64
+ };
@@ -0,0 +1,6 @@
1
+ import { Element } from '../element';
2
+ export declare class TmpElement extends Element {
3
+ init(): this;
4
+ dontSave(): boolean;
5
+ isTemporary(): boolean;
6
+ }
@@ -0,0 +1,27 @@
1
+ import { IDocument } from '../../document/i_document';
2
+ import { GRep } from '../../grep/grep';
3
+ /**
4
+ * 临时元素绘制器
5
+ */
6
+ export declare class TmpElementPainter {
7
+ /**
8
+ * 临时元素id
9
+ */
10
+ private _tmpElementId;
11
+ private _tmpGRepRemoved;
12
+ private _doc;
13
+ constructor(doc: IDocument);
14
+ get tmpElement(): import("../i_element").IElement;
15
+ /**
16
+ * 绘制临时元素
17
+ */
18
+ drawTmpGRep(grep: GRep): void;
19
+ /**
20
+ * 清除临时元素
21
+ */
22
+ clearTmp(): void;
23
+ /**
24
+ * 销毁
25
+ */
26
+ destroy(): void;
27
+ }
@@ -0,0 +1,37 @@
1
+ import type { GRep } from '../grep';
2
+ import { StateObject } from '../../display/state_object';
3
+ export interface IDisplayRenderData {
4
+ gRep?: GRep;
5
+ }
6
+ export interface IMgrDisplayRenderData extends IDisplayRenderData {
7
+ id: number;
8
+ }
9
+ /**
10
+ * 最小单类显示对象。
11
+ * 当前只保留跑通 GRep 渲染链路需要的公共能力。
12
+ */
13
+ export declare abstract class DisplayObject extends StateObject {
14
+ private static _dID;
15
+ /**
16
+ * 统一显示对象 id,后续可作为渲染层主键。
17
+ */
18
+ readonly id: number;
19
+ /**
20
+ * 在render层创建出group后,设置visible属性。
21
+ * display 直接改,modelview里 updateElementVisible。
22
+ * 控制整棵树显隐,grep中的visible控制图元是否参与渲染。
23
+ */
24
+ visible?: boolean;
25
+ constructor();
26
+ /**
27
+ * 统一判断当前对象是否应该显示。
28
+ */
29
+ testVisible(): boolean;
30
+ /**
31
+ * 给子类补充额外显示条件。
32
+ */
33
+ visibleCheck(): boolean;
34
+ onBeforeRender(rebuild?: boolean): IDisplayRenderData | null;
35
+ onRender(): IDisplayRenderData | null;
36
+ dispose(): void;
37
+ }
@@ -0,0 +1,23 @@
1
+ import type { IMgrDisplayRenderData } from './display_object';
2
+ import { DisplayObject } from './display_object';
3
+ export declare class DisplayObjectMgr {
4
+ /** 显示对象集合。 */
5
+ private _displayMap;
6
+ /** 本轮被移除的显示对象 id。 */
7
+ private _removedSet;
8
+ /** 单例实例。 */
9
+ private static _instance;
10
+ constructor();
11
+ addDisplay(display: DisplayObject): void;
12
+ getDisplay<T extends DisplayObject>(id: number): T | undefined;
13
+ removeDisplayById(id: number): boolean;
14
+ /**
15
+ * 渲染前准备
16
+ */
17
+ onBeforeRender(rebuild?: boolean): {
18
+ update: IMgrDisplayRenderData[];
19
+ remove: number[];
20
+ };
21
+ clearDisplay(): void;
22
+ static instance(): DisplayObjectMgr;
23
+ }
@@ -0,0 +1,16 @@
1
+ import type { GRep } from '../grep';
2
+ import type { IDisplayRenderData } from './display_object';
3
+ import { DisplayObject } from './display_object';
4
+ export declare class GrepDisplay extends DisplayObject {
5
+ /**
6
+ * 当前显示对象对应的 GRep。
7
+ */
8
+ gRep: GRep;
9
+ /**
10
+ * 关联的 elementId。
11
+ * 先保留,便于继续兼容当前 ModelView 链路。
12
+ */
13
+ eId: number;
14
+ getGRep(): GRep;
15
+ onRender(): IDisplayRenderData | null;
16
+ }
@@ -0,0 +1,15 @@
1
+ import { Curve2, DiscreteParam, Plane } from '@ccpc/math';
2
+ import type { types } from '@ccpc/math';
3
+ import { GNode2d } from './gnode2d';
4
+ import { RenderNode } from '../render/render_node';
5
+ import { GNODE_TYPE } from './gnode_type';
6
+ import { IStyle } from './i_style';
7
+ export declare class GCurve2d extends GNode2d {
8
+ geo: Curve2;
9
+ constructor(plane: Plane, geo: Curve2);
10
+ setStyle(style: IStyle): this;
11
+ getType(): GNODE_TYPE;
12
+ protected _toRenderNodeWithoutMatrix(discreteParams?: DiscreteParam): RenderNode;
13
+ discrete(params?: DiscreteParam): types.IXYZ[];
14
+ clone(cloneGeo?: boolean): GCurve2d;
15
+ }
@@ -0,0 +1,29 @@
1
+ import { DiscreteParam } from '@ccpc/math';
2
+ import { RenderNode } from '../render/render_node';
3
+ import { GNode } from './gnode';
4
+ import { GNODE_TYPE } from './gnode_type';
5
+ export declare class GGroup extends GNode {
6
+ /**
7
+ * 子节点
8
+ */
9
+ protected _children: Array<GNode>;
10
+ get children(): GNode[];
11
+ isEmpty(): boolean;
12
+ /**
13
+ * 添加子节点
14
+ */
15
+ addNode(node: GNode, index?: number): GNode;
16
+ /**
17
+ * 移除子节点
18
+ */
19
+ removeNode(node: GNode): boolean;
20
+ /**
21
+ * 批量添加子节点
22
+ */
23
+ addNodes(...nodes: Array<GNode | GNode[]>): void;
24
+ getTraverseChildren(): GNode[];
25
+ getType(): GNODE_TYPE;
26
+ protected _toRenderNodeWithoutMatrix(discreteParams?: DiscreteParam): RenderNode;
27
+ clone(cloneGeo?: boolean): GGroup;
28
+ protected _copyFrom(another: GGroup, cloneGeo?: boolean): this;
29
+ }
@@ -0,0 +1,110 @@
1
+ import { DiscreteParam, Matrix4 } from '@ccpc/math';
2
+ import { RenderNode } from '../render/render_node';
3
+ import { ElementId } from '../element/element_id';
4
+ import { GNODE_TYPE } from './gnode_type';
5
+ import { IStyle } from './i_style';
6
+ /**
7
+ * 表示图形的基本单元, 包括几何数据和显示样式
8
+ */
9
+ export declare abstract class GNode {
10
+ static gId: number;
11
+ /**
12
+ * dynamic global incremental
13
+ */
14
+ readonly globalID: number;
15
+ parent?: GNode;
16
+ /**
17
+ * 相对父节点局部矩阵
18
+ */
19
+ protected _localMatrix?: Matrix4;
20
+ /**
21
+ * 根节点累计到当前的世界矩阵
22
+ */
23
+ protected _globalMatrix?: Matrix4;
24
+ /**
25
+ * 对应的渲染节点
26
+ * 一旦创建出来, 会复用并在需要时同步矩阵
27
+ */
28
+ protected _renderNode?: RenderNode;
29
+ /**
30
+ * 渲染节点样式
31
+ */
32
+ protected _style: IStyle;
33
+ protected _canPick: boolean;
34
+ protected _canSnap: boolean;
35
+ get elementId(): ElementId;
36
+ get localMatrix(): Matrix4 | undefined;
37
+ set localMatrix(value: Matrix4);
38
+ get globalMatrix(): Matrix4 | undefined;
39
+ constructor();
40
+ /**
41
+ * set local style only (without mixing with parent style)
42
+ */
43
+ setStyle(style: IStyle): this;
44
+ /**
45
+ * get final style mixing child and parent
46
+ */
47
+ getStyle(): Partial<{
48
+ point: import("./i_style").IPointStyle;
49
+ line: import("./i_style").ILineStyle;
50
+ face: import("./i_style").IFaceStyle;
51
+ text: import("./i_style").ITextStyle;
52
+ }>;
53
+ get canPick(): boolean;
54
+ set canPick(canPick: boolean);
55
+ get canSnap(): boolean;
56
+ set canSnap(canSnap: boolean);
57
+ /**
58
+ * GNode->RenderNode入口
59
+ */
60
+ toRenderNode(discreteParams?: DiscreteParam): RenderNode;
61
+ /**
62
+ * 更新GNode对应的RenderNode
63
+ */
64
+ updateRenderNode(discreteParams?: DiscreteParam): void;
65
+ /**
66
+ * 设置局部坐标变换
67
+ */
68
+ setLocalMatrix(mat?: Matrix4): void;
69
+ /**
70
+ * 从当前节点的树根计算整棵子树的世界矩阵
71
+ */
72
+ updateGlobalMatrix(): void;
73
+ /**
74
+ * 递归计算当前节点及子节点的世界矩阵
75
+ */
76
+ protected _updateMatrix(parentGlobalMatrix?: Matrix4): void;
77
+ /**
78
+ * 查整根树的根节点
79
+ */
80
+ getRoot(): GNode;
81
+ traverse(callback: (gnode: GNode) => void): void;
82
+ /**
83
+ * 返回当前节点的可遍历子节点
84
+ */
85
+ getTraverseChildren(): Array<GNode>;
86
+ getType(): GNODE_TYPE;
87
+ /**
88
+ * 通过离散等方式生成对应的RenderNode
89
+ */
90
+ protected abstract _toRenderNodeWithoutMatrix(discreteParams?: DiscreteParam): RenderNode;
91
+ /**
92
+ * 清除_renderNode
93
+ * @param clearChildren 是否清除子节点renderNode
94
+ * @param clearParent 是否清除父节点renderNode
95
+ */
96
+ clearRenderNode(clearChildren?: boolean, clearParent?: boolean): void;
97
+ /**
98
+ * 从父节点移除
99
+ */
100
+ removeFromParent(): boolean;
101
+ /**
102
+ * 克隆
103
+ * @param cloneGeo 是否深拷贝底层几何对象
104
+ */
105
+ abstract clone(cloneGeo?: boolean): GNode;
106
+ /**
107
+ * 从其它实例复制状态
108
+ */
109
+ protected _copyFrom(another: GNode): this;
110
+ }