|
@@ -206,7 +206,7 @@ class WorkViewModel : ViewModel() {
|
|
mapData.value = map
|
|
mapData.value = map
|
|
}
|
|
}
|
|
|
|
|
|
- fun transformPoints() {
|
|
|
|
|
|
+ fun useDefaultPaths() {
|
|
val sizeValid = canvasSize.width * canvasSize.height > 1
|
|
val sizeValid = canvasSize.width * canvasSize.height > 1
|
|
val hasData = processedData.value.bitmap != null
|
|
val hasData = processedData.value.bitmap != null
|
|
Log.i(TAG, "size valid:$sizeValid, has data: $hasData")
|
|
Log.i(TAG, "size valid:$sizeValid, has data: $hasData")
|
|
@@ -306,6 +306,11 @@ class WorkViewModel : ViewModel() {
|
|
updateVisibleArea()
|
|
updateVisibleArea()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ fun exitEditing() {
|
|
|
|
+ imageState.value = imageState.value.copy(editMode = false)
|
|
|
|
+ useDefaultPaths()
|
|
|
|
+ }
|
|
|
|
+
|
|
fun onDrag(position: Offset) {
|
|
fun onDrag(position: Offset) {
|
|
// 开始拖动
|
|
// 开始拖动
|
|
if (dragStartPos == null) {
|
|
if (dragStartPos == null) {
|
|
@@ -334,18 +339,25 @@ class WorkViewModel : ViewModel() {
|
|
(position - offset.value - canvasSize.center) / scale
|
|
(position - offset.value - canvasSize.center) / scale
|
|
.value + canvasSize.center
|
|
.value + canvasSize.center
|
|
|
|
|
|
- if (editingPath == 0) {
|
|
|
|
- val newPath = contourPath.value.toMutableList()
|
|
|
|
- newPath[editingPoint] = newVertex
|
|
|
|
- contourPath.value = newPath
|
|
|
|
- } else if (editingPath == 1) {
|
|
|
|
- val newPath = lengthPath.value.toMutableList()
|
|
|
|
- newPath[editingPoint] = newVertex
|
|
|
|
- lengthPath.value = newPath
|
|
|
|
- } else if (editingPath == 2) {
|
|
|
|
- val newPath = widthPath.value.toMutableList()
|
|
|
|
- newPath[editingPoint] = newVertex
|
|
|
|
- widthPath.value = newPath
|
|
|
|
|
|
+
|
|
|
|
+ when (editingPath) {
|
|
|
|
+ 0 -> {
|
|
|
|
+ val newPath = contourPath.value.toMutableList()
|
|
|
|
+ newPath[editingPoint] = newVertex
|
|
|
|
+ contourPath.value = newPath
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 1 -> {
|
|
|
|
+ val newPath = lengthPath.value.toMutableList()
|
|
|
|
+ newPath[editingPoint] = newVertex
|
|
|
|
+ lengthPath.value = newPath
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 2 -> {
|
|
|
|
+ val newPath = widthPath.value.toMutableList()
|
|
|
|
+ newPath[editingPoint] = newVertex
|
|
|
|
+ widthPath.value = newPath
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
// 拖动图像
|
|
// 拖动图像
|