add new field to app type, to distinguish between modes (one mode for normal insertion/deleteion, another mode for saving, etc.)

This commit is contained in:
2024-09-24 21:54:19 +01:00
parent 7dfc427663
commit c17c573638
4 changed files with 48 additions and 21 deletions

BIN
dotscape

Binary file not shown.

View File

@@ -20,7 +20,8 @@ struct
val xClickPoints = ClickPoints.generate (wStart, wFinish, numClickPoints) val xClickPoints = ClickPoints.generate (wStart, wFinish, numClickPoints)
val yClickPoints = ClickPoints.generate (hStart, hFinish, numClickPoints) val yClickPoints = ClickPoints.generate (hStart, hFinish, numClickPoints)
in in
{ triangles = [] { mode = AppType.NORMAL_MODE
, triangles = []
, triangleStage = NO_TRIANGLE , triangleStage = NO_TRIANGLE
, windowWidth = windowWidth , windowWidth = windowWidth
, windowHeight = windowHeight , windowHeight = windowHeight

View File

@@ -1,5 +1,7 @@
signature APP_TYPE = signature APP_TYPE =
sig sig
datatype app_mode = NORMAL_MODE | SAVE_MODE
datatype triangle_stage = datatype triangle_stage =
NO_TRIANGLE NO_TRIANGLE
| FIRST of {x1: Real32.real, y1: Real32.real} | FIRST of {x1: Real32.real, y1: Real32.real}
@@ -16,7 +18,8 @@ sig
} }
type app_type = type app_type =
{ triangles: triangle list { mode: app_mode
, triangles: triangle list
, triangleStage: triangle_stage , triangleStage: triangle_stage
, windowWidth: int , windowWidth: int
, windowHeight: int , windowHeight: int
@@ -35,6 +38,8 @@ end
structure AppType :> APP_TYPE = structure AppType :> APP_TYPE =
struct struct
datatype app_mode = NORMAL_MODE | SAVE_MODE
type triangle = type triangle =
{ x1: Real32.real { x1: Real32.real
, y1: Real32.real , y1: Real32.real
@@ -59,7 +64,8 @@ struct
{x1: Real32.real, y1: Real32.real, x2: Real32.real, y2: Real32.real} {x1: Real32.real, y1: Real32.real, x2: Real32.real, y2: Real32.real}
type app_type = type app_type =
{ triangles: triangle list { mode: app_mode
, triangles: triangle list
, triangleStage: triangle_stage , triangleStage: triangle_stage
, windowWidth: int , windowWidth: int
, windowHeight: int , windowHeight: int

View File

@@ -64,6 +64,7 @@ struct
let let
val val
{ triangleStage = _ { triangleStage = _
, mode
, triangles , triangles
, numClickPoints , numClickPoints
, xClickPoints , xClickPoints
@@ -84,6 +85,7 @@ struct
{ triangleStage = newTriangleStage { triangleStage = newTriangleStage
, undo = newUndo , undo = newUndo
, redo = [] , redo = []
, mode = mode
, triangles = triangles , triangles = triangles
, numClickPoints = numClickPoints , numClickPoints = numClickPoints
, xClickPoints = xClickPoints , xClickPoints = xClickPoints
@@ -103,7 +105,8 @@ struct
app_type = app_type =
let let
val val
{ triangles { mode
, triangles
, triangleStage = _ , triangleStage = _
, numClickPoints , numClickPoints
, xClickPoints , xClickPoints
@@ -123,7 +126,8 @@ struct
val newTriangles = newTriangle :: triangles val newTriangles = newTriangle :: triangles
val newUndo = newUndoHd :: undo val newUndo = newUndoHd :: undo
in in
{ triangleStage = NO_TRIANGLE { mode = mode
, triangleStage = NO_TRIANGLE
, triangles = newTriangles , triangles = newTriangles
, undo = newUndo , undo = newUndo
, redo = [] , redo = []
@@ -143,7 +147,8 @@ struct
fun arrowX (app: app_type, arrowX) = fun arrowX (app: app_type, arrowX) =
let let
val val
{ xClickPoints { mode
, xClickPoints
, yClickPoints , yClickPoints
, numClickPoints , numClickPoints
, windowWidth , windowWidth
@@ -159,7 +164,8 @@ struct
, arrowY , arrowY
} = app } = app
in in
{ xClickPoints = xClickPoints { mode = mode
, xClickPoints = xClickPoints
, yClickPoints = yClickPoints , yClickPoints = yClickPoints
, numClickPoints = numClickPoints , numClickPoints = numClickPoints
, triangles = triangles , triangles = triangles
@@ -179,7 +185,8 @@ struct
fun arrowY (app: app_type, arrowY) = fun arrowY (app: app_type, arrowY) =
let let
val val
{ xClickPoints { mode
, xClickPoints
, yClickPoints , yClickPoints
, numClickPoints , numClickPoints
, windowWidth , windowWidth
@@ -195,7 +202,8 @@ struct
, arrowY = _ , arrowY = _
} = app } = app
in in
{ xClickPoints = xClickPoints { mode = mode
, xClickPoints = xClickPoints
, yClickPoints = yClickPoints , yClickPoints = yClickPoints
, numClickPoints = numClickPoints , numClickPoints = numClickPoints
, triangles = triangles , triangles = triangles
@@ -217,7 +225,8 @@ struct
app_type = app_type =
let let
val val
{ xClickPoints = _ { mode
, xClickPoints = _
, yClickPoints = _ , yClickPoints = _
, numClickPoints , numClickPoints
, windowWidth = _ , windowWidth = _
@@ -236,7 +245,8 @@ struct
val xClickPoints = ClickPoints.generate (wStart, wFinish, numClickPoints) val xClickPoints = ClickPoints.generate (wStart, wFinish, numClickPoints)
val yClickPoints = ClickPoints.generate (hStart, hFinish, numClickPoints) val yClickPoints = ClickPoints.generate (hStart, hFinish, numClickPoints)
in in
{ xClickPoints = xClickPoints { mode = mode
, xClickPoints = xClickPoints
, yClickPoints = yClickPoints , yClickPoints = yClickPoints
, numClickPoints = numClickPoints , numClickPoints = numClickPoints
, triangles = triangles , triangles = triangles
@@ -279,7 +289,8 @@ struct
fun mousePosition (app: app_type, mouseX, mouseY) = fun mousePosition (app: app_type, mouseX, mouseY) =
let let
val val
{ mouseX = _ { mode
, mouseX = _
, mouseY = _ , mouseY = _
, triangles , triangles
, triangleStage , triangleStage
@@ -295,7 +306,8 @@ struct
, arrowY , arrowY
} = app } = app
in in
{ mouseX = mouseX { mode = mode
, mouseX = mouseX
, mouseY = mouseY , mouseY = mouseY
, triangles = triangles , triangles = triangles
, triangleStage = triangleStage , triangleStage = triangleStage
@@ -316,7 +328,8 @@ struct
fun undo (app: app_type, newTriangleStage, newTriangles, newRedoHd) = fun undo (app: app_type, newTriangleStage, newTriangles, newRedoHd) =
let let
val val
{ triangleStage = _ { mode
, triangleStage = _
, triangles = _ , triangles = _
, numClickPoints , numClickPoints
, xClickPoints , xClickPoints
@@ -339,7 +352,8 @@ struct
val newRedo = newRedoHd :: redo val newRedo = newRedoHd :: redo
in in
{ triangleStage = newTriangleStage { mode = mode
, triangleStage = newTriangleStage
, triangles = newTriangles , triangles = newTriangles
, undo = newUndo , undo = newUndo
, redo = newRedo , redo = newRedo
@@ -360,7 +374,8 @@ struct
fun redo (app: app_type, newTriangleStage, newTriangles, newUndoHd) = fun redo (app: app_type, newTriangleStage, newTriangles, newUndoHd) =
let let
val val
{ triangleStage = _ { mode
, triangleStage = _
, triangles = _ , triangles = _
, numClickPoints , numClickPoints
, xClickPoints , xClickPoints
@@ -382,7 +397,8 @@ struct
hd :: tl => tl hd :: tl => tl
| empty => empty | empty => empty
in in
{ triangleStage = newTriangleStage { mode = mode
, triangleStage = newTriangleStage
, triangles = newTriangles , triangles = newTriangles
, undo = newUndo , undo = newUndo
, redo = newRedo , redo = newRedo
@@ -402,7 +418,8 @@ struct
fun graphVisibility (app: app_type, shouldShowGraph) = fun graphVisibility (app: app_type, shouldShowGraph) =
let let
val val
{ triangleStage { mode
, triangleStage
, triangles , triangles
, numClickPoints , numClickPoints
, xClickPoints , xClickPoints
@@ -418,7 +435,8 @@ struct
, showGraph = _ , showGraph = _
} = app } = app
in in
{ showGraph = shouldShowGraph { mode = mode
, showGraph = shouldShowGraph
, triangleStage = triangleStage , triangleStage = triangleStage
, triangles = triangles , triangles = triangles
, undo = undo , undo = undo
@@ -438,7 +456,8 @@ struct
fun useTriangles (app: app_type, triangles) = fun useTriangles (app: app_type, triangles) =
let let
val val
{ xClickPoints { mode
, xClickPoints
, yClickPoints , yClickPoints
, numClickPoints , numClickPoints
, windowWidth , windowWidth
@@ -456,7 +475,8 @@ struct
val triangleStage = NO_TRIANGLE val triangleStage = NO_TRIANGLE
in in
{ triangleStage = triangleStage { mode = mode
, triangleStage = triangleStage
, triangles = triangles , triangles = triangles
, undo = [] , undo = []
, redo = [] , redo = []