233 lines
9.3 KiB
Dart
233 lines
9.3 KiB
Dart
import 'dart:math';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:scence_map/controllers/controller.dart';
|
|
import 'package:scence_map/controllers/plumController.dart';
|
|
|
|
import '../../../service/pile/device_type.dart';
|
|
import '../../../service/pile/input.dart';
|
|
import '../../../service/pile/public_widget.dart';
|
|
|
|
final ScenceMapController mapController = Get.find<ScenceMapController>();
|
|
|
|
class PileGenerate extends GetView<PlumDataController> {
|
|
const PileGenerate({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
double titleTextWidth = 90;
|
|
double inputLength = 120;
|
|
FocusNode xFocus = FocusNode();
|
|
FocusNode yFocus = FocusNode();
|
|
FocusNode directionFocus = FocusNode();
|
|
FocusNode pileSpaceFocus = FocusNode();
|
|
FocusNode pileWidthFocus = FocusNode();
|
|
DeviceType deviceType = getDeviceType(context);
|
|
double fontSize = 16;
|
|
if (deviceType == DeviceType.mobile) {
|
|
fontSize = 16;
|
|
} else {
|
|
fontSize = 20;
|
|
}
|
|
double centerPointX = controller.centerXY.value.dx;
|
|
double centerPointY = controller.centerXY.value.dy;
|
|
|
|
final size = MediaQuery.of(context).size;
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text("桩点生成"),
|
|
toolbarHeight: 30,
|
|
),
|
|
body: SizedBox(
|
|
height: size.height,
|
|
child: Stack(
|
|
children: [
|
|
SingleChildScrollView(
|
|
child: AlignWrapWidget(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
const Text('地图显示:'),
|
|
Obx(() => Switch(
|
|
value: controller.isMap.value,
|
|
onChanged: ((value) {
|
|
controller.isMap.value = !controller.isMap.value;
|
|
}))),
|
|
],
|
|
),
|
|
AlignWrapWidget(
|
|
children: [
|
|
ElevatedButton(
|
|
child: const Text("夯锤坐标"),
|
|
onPressed: () => {controller.isDirect.value = false},
|
|
),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
ElevatedButton(
|
|
child: const Text("桩点坐标"),
|
|
onPressed: () => {
|
|
controller.isGenerate.value = true,
|
|
controller.checkValue.value = "checkPile",
|
|
controller.isDirect.value = false,
|
|
// controller.checkValue.value = "checkDirection",
|
|
// controller.isDirect.value = true,
|
|
// controller.centerXY.value =
|
|
// Offset(centerPointX, centerPointY),
|
|
}),
|
|
const SizedBox(
|
|
width: 10,
|
|
),
|
|
ElevatedButton(
|
|
child: const Text("方向设置"),
|
|
onPressed: () => {
|
|
controller.isGenerate.value = true,
|
|
controller.checkValue.value = "checkDirection",
|
|
controller.isDirect.value = true,
|
|
controller.centerXY.value =
|
|
Offset(centerPointX, centerPointY),
|
|
Navigator.pop(context)
|
|
}),
|
|
],
|
|
),
|
|
Row(children: [
|
|
FixedWidthTextWidget(width: titleTextWidth, text: "X:"),
|
|
inputText(
|
|
inputLength: inputLength,
|
|
value: centerPointX.toString(),
|
|
fontsize: fontSize,
|
|
focusNode: yFocus,
|
|
onChanged: (value) => value.isNotEmpty
|
|
? centerPointY = double.parse(value)
|
|
: '')
|
|
]),
|
|
Row(children: [
|
|
FixedWidthTextWidget(width: titleTextWidth, text: "Y:"),
|
|
inputText(
|
|
inputLength: inputLength,
|
|
value: centerPointY.toString(),
|
|
fontsize: fontSize,
|
|
focusNode: xFocus,
|
|
onChanged: (value) => value.isNotEmpty
|
|
? centerPointX = double.parse(value)
|
|
: '')
|
|
]),
|
|
Row(children: [
|
|
FixedWidthTextWidget(width: titleTextWidth, text: "方向(°):"),
|
|
inputText(
|
|
inputLength: inputLength,
|
|
value: controller.direction.toString(),
|
|
fontsize: fontSize,
|
|
focusNode: directionFocus,
|
|
keyboardType: 0,
|
|
onChanged: (value) {
|
|
if (value.isNotEmpty) {
|
|
controller.direction.value = double.parse(value);
|
|
// bug 值修改后 绘制没有变化
|
|
controller.angle.value =
|
|
controller.direction.value * pi / 180;
|
|
}
|
|
})
|
|
]),
|
|
Row(children: [
|
|
FixedWidthTextWidget(
|
|
width: titleTextWidth + 10, text: "夯点间距(m):"),
|
|
inputText(
|
|
inputLength: inputLength - 10,
|
|
fontsize: fontSize,
|
|
value: controller.space.toString(),
|
|
focusNode: pileSpaceFocus,
|
|
onChanged: (value) => {
|
|
value.isNotEmpty
|
|
? controller.space.value = double.parse(value)
|
|
: '',
|
|
})
|
|
]),
|
|
Row(children: [
|
|
FixedWidthTextWidget(
|
|
width: titleTextWidth + 10, text: "宽度(m):"),
|
|
inputText(
|
|
inputLength: inputLength - 10,
|
|
fontsize: fontSize,
|
|
value: controller.pileWidth.toString(),
|
|
focusNode: pileWidthFocus,
|
|
onChanged: (value) => {
|
|
value.isNotEmpty
|
|
? controller.pileWidth.value =
|
|
double.parse(value)
|
|
: '',
|
|
})
|
|
]),
|
|
Row(children: [
|
|
const Icon(
|
|
Icons.tips_and_updates_outlined,
|
|
color: Colors.red,
|
|
),
|
|
Text(
|
|
controller.isPileId.value
|
|
? '选中桩点:${controller.checkName.value}'
|
|
: ' 未选中桩点',
|
|
style: TextStyle(
|
|
color: !controller.isPileId.value
|
|
? Colors.red
|
|
: Colors.black),
|
|
)
|
|
]),
|
|
],
|
|
)),
|
|
Positioned(
|
|
bottom: 10,
|
|
child: Row(
|
|
children: [
|
|
TextButton(
|
|
child: const Text('取消'),
|
|
onPressed: () {
|
|
controller.isGenerate.value = false;
|
|
controller.isDirect.value = false;
|
|
controller.isSave.value = false;
|
|
// 执行取消的逻辑
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
TextButton(
|
|
child: const Text('确定'),
|
|
onPressed: () {
|
|
// 执行确定的逻辑
|
|
var dx = (controller.canvasSize.width) / 2;
|
|
var dy = (controller.canvasSize.height) / 2;
|
|
var rotation = mapController.rotation.value;
|
|
for (int i = 0; i < controller.plumList.length; i++) {
|
|
Offset item = controller.plumList[i];
|
|
|
|
var dx1 = (item.dx - dx) * cos(rotation) +
|
|
(item.dy - dy) * sin(rotation);
|
|
var dy1 = -(item.dx - dx) * sin(rotation) +
|
|
(item.dy - dy) * cos(rotation);
|
|
Offset xy = mapController.ScreenCenter2xy(dx1, dy1);
|
|
PilePoint pilePoint = PilePoint(
|
|
x: xy.dx,
|
|
y: xy.dy,
|
|
state: 0,
|
|
id: i + 1,
|
|
radius: 0.3);
|
|
mapController.pilePoints.add(pilePoint);
|
|
}
|
|
controller.isGenerate.value = false;
|
|
controller.isDirect.value = false;
|
|
controller.isSave.value = true;
|
|
controller.centerXY.value =
|
|
Offset(centerPointX, centerPointY);
|
|
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
],
|
|
))
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|