Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 4a011e9

Browse files
committed
more wip
1 parent e7bdd57 commit 4a011e9

File tree

6 files changed

+57
-16
lines changed

6 files changed

+57
-16
lines changed

README.md

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,43 @@ A brand new foundation for storm-react-diagrams
66

77
## Features
88

9-
* Virtual and real co-ordinate system
10-
* Built in primitives (square, grid, circle)
11-
* Grouped selections
12-
* canvas panning and zooming
13-
* Forward constraints and inferred constraints (dimension tracking)
14-
* pluggable state machine for interactive modes
15-
* pluggable and modular everything
16-
* multiple layers
17-
* ordered canvas elements per layer
18-
* grouped resizing via 8 anchor points
19-
* Fit to width
20-
* Serialization and deserialization
21-
* History (redo and undo)
9+
#### Core
10+
* virtual co-ordinate system
11+
* real co-ordinate system
12+
* matrix transformation, precomputed and optimized
13+
* forward dimensions and inferred dimensions
14+
* history push and pop (wip)
15+
* SVG and standard DOM support
16+
* pluggable event bus
17+
* pluggable state machine
18+
* model driven with serialization layers (imperative and declarative styles)
19+
* serialization and deserialization
20+
21+
#### Canvas
22+
* translate / panning
23+
* zoom
24+
* de-select elements
25+
* fit to width
26+
* multiple ordered layers
27+
* ordered elements on layers
28+
29+
#### Primitives
30+
* multiple infinite grids
31+
* point based vectors (wip)
32+
* ellipse
33+
* rectangles
34+
* pages
35+
36+
### Groups
37+
* group selection
38+
* group translate
39+
* group scaling from any anchor point
40+
* group rotation from origin (or any arbitrary point)
41+
* group transform with mirror modifiers (wip)
42+
2243

2344
| | |
2445
|---|---|
25-
| ![](./images/1.gif)| ![](./images/2.gif) |
46+
| ![](./images/1.gif) | ![](./images/2.gif) |
2647
| ![](./images/3.gif) | ![](./images/4.gif) |
48+
| ![](./images/5.gif) | ![](./images/6.gif) |

images/5.gif

371 KB
Loading

images/6.gif

173 KB
Loading

src/CanvasEngine.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ export class CanvasEngine<T extends CanvasModel = CanvasModel> extends BaseObjec
256256

257257
setCanvasWidget(widget: CanvasWidget) {
258258
this.canvasWidget = widget;
259-
this.historyBank.pushState(this.model.serialize());
259+
if (widget) {
260+
this.historyBank.pushState(this.model.serialize());
261+
}
260262
}
261263

262264
getFactory(type: string): AbstractElementFactory {

src/base-models/GraphModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class GraphModel<
8484

8585
deSerialize(event: DeserializeEvent): void {
8686
super.deSerialize(event);
87-
let entities = event.subset("children");
87+
let entities = event.subset("entities");
8888
this.children = _.mapValues(entities.data, (entity: any, index) => {
8989
let entityOb = event.engine.generateEntityFor(entity._type);
9090
entityOb.deSerialize(entities.subset(index));

src/primitives/selection/SelectionElementModel.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { CanvasElementModel } from "../../models-canvas/CanvasElementModel";
22
import * as _ from "lodash";
33
import { Rectangle } from "../../geometry/Rectangle";
4+
import { DeserializeEvent } from "../../base-models/BaseModel";
45

56
export class SelectionElementModel extends CanvasElementModel {
67
models: CanvasElementModel[];
@@ -27,4 +28,20 @@ export class SelectionElementModel extends CanvasElementModel {
2728
}
2829

2930
setDimensions(dimensions: Rectangle) {}
31+
32+
deSerialize(event: DeserializeEvent): void {
33+
super.deSerialize(event);
34+
this.models = _.map(event.data["models"], modelID => {
35+
return event.cache[modelID];
36+
}) as any;
37+
}
38+
39+
serialize() {
40+
return {
41+
...super.serialize(),
42+
models: _.map(this.models, model => {
43+
return model.getID();
44+
})
45+
};
46+
}
3047
}

0 commit comments

Comments
 (0)