import { CanvasElementModel } from "../../models-canvas/CanvasElementModel" ; import * as _ from "lodash" ; import { Rectangle } from "../../geometry/Rectangle" ; import { DeserializeEvent } from "../../base-models/BaseModel" ; export class SelectionElementModel extends CanvasElementModel { models : CanvasElementModel [ ] ; constructor ( ) { super ( "selection" ) ; this . models = [ ] ; } setModels ( models ) { this . models = models ; } getModels ( ) { return this . models ; } getDimensions ( ) { return Rectangle . boundingBoxFromPolygons ( _ . map ( this . models , model => { return model . getDimensions ( ) ; } ) ) ; } setDimensions ( dimensions ) { } deSerialize ( event ) { super . deSerialize ( event ) ; this . models = _ . map ( event . data [ "models" ] , modelID => { return event . cache [ modelID ] ; } ) as any ; } serialize ( ) { return { ... super . serialize ( ) , models : _ . map ( this . models , model => { return model . getID ( ) ; } ) } ; } }