Updates code to mark isGenerated
This commit is contained in:
parent
a1cc578bb9
commit
71b8ac94af
10 changed files with 29 additions and 18 deletions
|
@ -10,7 +10,7 @@ export default class Dot extends CodeShape<DotShape> {
|
|||
super({
|
||||
id: uuid(),
|
||||
type: ShapeType.Dot,
|
||||
isGenerated: false,
|
||||
isGenerated: true,
|
||||
name: "Dot",
|
||||
parentId: "page0",
|
||||
childIndex: 0,
|
||||
|
|
|
@ -10,7 +10,7 @@ export default class Ellipse extends CodeShape<EllipseShape> {
|
|||
super({
|
||||
id: uuid(),
|
||||
type: ShapeType.Ellipse,
|
||||
isGenerated: false,
|
||||
isGenerated: true,
|
||||
name: "Ellipse",
|
||||
parentId: "page0",
|
||||
childIndex: 0,
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import { Shape } from "types"
|
||||
import { getShapeUtils, ShapeUtility } from "lib/shape-utils"
|
||||
import shapeUtilityMap, {
|
||||
createShape,
|
||||
getShapeUtils,
|
||||
ShapeUtility,
|
||||
} from "lib/shape-utils"
|
||||
import * as vec from "utils/vec"
|
||||
import Vector from "./vector"
|
||||
import { vectorToPoint } from "utils/utils"
|
||||
|
@ -12,12 +16,11 @@ export const codeShapes = new Set<CodeShape<Shape>>([])
|
|||
*/
|
||||
export default class CodeShape<T extends Shape> {
|
||||
private _shape: T
|
||||
private utils: ShapeUtility<Shape>
|
||||
private utils: ShapeUtility<T>
|
||||
|
||||
constructor(props: T) {
|
||||
this._shape = props
|
||||
this.utils = getShapeUtils(this.shape)
|
||||
|
||||
this._shape = createShape<T>(props.type, props)
|
||||
this.utils = getShapeUtils<T>(this._shape)
|
||||
codeShapes.add(this)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ export default class Line extends CodeShape<LineShape> {
|
|||
super({
|
||||
id: uuid(),
|
||||
type: ShapeType.Line,
|
||||
isGenerated: false,
|
||||
isGenerated: true,
|
||||
name: "Line",
|
||||
parentId: "page0",
|
||||
childIndex: 0,
|
||||
|
|
|
@ -11,7 +11,7 @@ export default class Polyline extends CodeShape<PolylineShape> {
|
|||
super({
|
||||
id: uuid(),
|
||||
type: ShapeType.Polyline,
|
||||
isGenerated: false,
|
||||
isGenerated: true,
|
||||
name: "Polyline",
|
||||
parentId: "page0",
|
||||
childIndex: 0,
|
||||
|
|
|
@ -11,7 +11,7 @@ export default class Ray extends CodeShape<RayShape> {
|
|||
super({
|
||||
id: uuid(),
|
||||
type: ShapeType.Ray,
|
||||
isGenerated: false,
|
||||
isGenerated: true,
|
||||
name: "Ray",
|
||||
parentId: "page0",
|
||||
childIndex: 0,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { v4 as uuid } from "uuid"
|
||||
import * as vec from "utils/vec"
|
||||
import { CircleShape, ShapeType, Corner, Edge } from "types"
|
||||
import { registerShapeUtils } from "./index"
|
||||
import shapeUtilityMap, { registerShapeUtils } from "./index"
|
||||
import { boundsContained } from "utils/bounds"
|
||||
import { intersectCircleBounds } from "utils/intersections"
|
||||
import { pointInCircle } from "utils/hitTests"
|
||||
|
|
|
@ -134,11 +134,11 @@ export function registerShapeUtils<T extends Shape>(
|
|||
return Object.freeze(shape)
|
||||
}
|
||||
|
||||
export function createShape<T extends ShapeType>(
|
||||
type: T,
|
||||
props: Partial<ShapeByType<T>>
|
||||
export function createShape<T extends Shape>(
|
||||
type: T["type"],
|
||||
props: Partial<T>
|
||||
) {
|
||||
return shapeUtilityMap[type].create(props) as ShapeByType<T>
|
||||
return shapeUtilityMap[type].create(props) as T
|
||||
}
|
||||
|
||||
export default shapeUtilityMap
|
||||
|
|
|
@ -19,7 +19,7 @@ class MyDocument extends NextDocument {
|
|||
),
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e.message)
|
||||
console.error(e.message)
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,8 +72,16 @@ const state = createState({
|
|||
SELECTED_RECTANGLE_TOOL: { unless: "isReadOnly", to: "rectangle" },
|
||||
TOGGLED_CODE_PANEL_OPEN: "toggleCodePanel",
|
||||
RESET_CAMERA: "resetCamera",
|
||||
ZOOMED_TO_FIT: "zoomCameraToFit",
|
||||
ZOOMED_TO_SELECTION: { if: "hasSelection", do: "zoomCameraToSelection" },
|
||||
ZOOMED_TO_FIT: {
|
||||
if: "hasSelection",
|
||||
do: "zoomCameraToFit",
|
||||
else: "resetCamera",
|
||||
},
|
||||
ZOOMED_TO_SELECTION: {
|
||||
if: "hasSelection",
|
||||
do: "zoomCameraToSelection",
|
||||
else: "resetCamera",
|
||||
},
|
||||
ZOOMED_TO_ACTUAL: {
|
||||
if: "hasSelection",
|
||||
do: "zoomCameraToSelectionActual",
|
||||
|
|
Loading…
Reference in a new issue