254 lines
8.9 KiB
Dart
254 lines
8.9 KiB
Dart
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter/scheduler.dart';
|
||
|
import 'package:get/get.dart';
|
||
|
|
||
|
import '../login_in/connect/blue_tooth.dart';
|
||
|
import '../login_in/connect/index.dart';
|
||
|
import '../login_in/getx/blue_tooth.dart';
|
||
|
import '../login_in/service/coor_trans.dart';
|
||
|
import '../login_in/service/service.dart';
|
||
|
import '../map_pointer/modules/common/device_type.dart';
|
||
|
|
||
|
|
||
|
final BlueToothController blueToothController = Get.put(BlueToothController());
|
||
|
BlueSetting blueSetting = BlueSetting();
|
||
|
|
||
|
class XyChangeView extends StatefulWidget {
|
||
|
const XyChangeView({super.key});
|
||
|
|
||
|
@override
|
||
|
State<XyChangeView> createState() => _XyChangeViewState();
|
||
|
}
|
||
|
|
||
|
class _XyChangeViewState extends State<XyChangeView> {
|
||
|
List<Widget> list = [];
|
||
|
CoorTransModel coorTrans = CoorTransModel(
|
||
|
name: "",
|
||
|
L0: 0,
|
||
|
belt: "",
|
||
|
dstEllipsoid: "",
|
||
|
dx: 0,
|
||
|
dy: 0,
|
||
|
dz: 0,
|
||
|
id: 0,
|
||
|
wx: 0,
|
||
|
wy: 0,
|
||
|
wz: 0,
|
||
|
k: 0,
|
||
|
elevation: 0,
|
||
|
isMain: 0,
|
||
|
rota: 0,
|
||
|
srcEllipsoid: "");
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
SchedulerBinding.instance.addPostFrameCallback((_) async {
|
||
|
List coordTransmap = await GetServices().getCoordTrans();
|
||
|
if (coordTransmap.isNotEmpty) {
|
||
|
var mianBelt =
|
||
|
coordTransmap.firstWhere((element) => element['belt'] == 'main');
|
||
|
coorTrans = CoorTransModel.fromJson(mianBelt);
|
||
|
setState(() {});
|
||
|
} else {
|
||
|
print("当前项目没有设置中央子午线");
|
||
|
return;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
final deviceType = getDeviceType(context);
|
||
|
final size = MediaQuery.of(context).size;
|
||
|
|
||
|
return Scaffold(
|
||
|
appBar: AppBar(
|
||
|
title: const Text("坐标转换"),
|
||
|
toolbarHeight: 40,
|
||
|
),
|
||
|
body: Container(
|
||
|
margin: const EdgeInsets.all(5),
|
||
|
child: ListView.builder(
|
||
|
itemCount: 1,
|
||
|
itemBuilder: (BuildContext context, int index) {
|
||
|
TextEditingController l0Controller =
|
||
|
TextEditingController(text: coorTrans.L0.toString());
|
||
|
TextEditingController elevationController =
|
||
|
TextEditingController(text: coorTrans.elevation.toString());
|
||
|
TextEditingController dxController =
|
||
|
TextEditingController(text: coorTrans.dx.toString());
|
||
|
TextEditingController dyController =
|
||
|
TextEditingController(text: coorTrans.dy.toString());
|
||
|
TextEditingController dzController =
|
||
|
TextEditingController(text: coorTrans.dz.toString());
|
||
|
TextEditingController wxController =
|
||
|
TextEditingController(text: coorTrans.wx.toString());
|
||
|
TextEditingController wyController =
|
||
|
TextEditingController(text: coorTrans.wy.toString());
|
||
|
TextEditingController wzController =
|
||
|
TextEditingController(text: coorTrans.wz.toString());
|
||
|
TextEditingController kController =
|
||
|
TextEditingController(text: coorTrans.k.toString());
|
||
|
List<Widget> list1 = [
|
||
|
Flexible(
|
||
|
child: TextFormField(
|
||
|
keyboardType: TextInputType.number,
|
||
|
controller: l0Controller,
|
||
|
decoration: const InputDecoration(
|
||
|
prefixText: '中央子午线:',
|
||
|
border: InputBorder.none,
|
||
|
),
|
||
|
onChanged: (String value) {
|
||
|
// coorTrans.L0 =(value);
|
||
|
},
|
||
|
)),
|
||
|
const Divider(),
|
||
|
Flexible(
|
||
|
child: TextFormField(
|
||
|
keyboardType: TextInputType.number,
|
||
|
controller: elevationController,
|
||
|
decoration: const InputDecoration(
|
||
|
border: InputBorder.none,
|
||
|
prefixText: '投影高程:',
|
||
|
),
|
||
|
onChanged: (String value) {
|
||
|
// coorTrans.L0 =(value);
|
||
|
},
|
||
|
)),
|
||
|
];
|
||
|
List<Widget> list2 = [
|
||
|
Flexible(
|
||
|
child: TextFormField(
|
||
|
keyboardType: TextInputType.number,
|
||
|
controller: dxController,
|
||
|
decoration: const InputDecoration(
|
||
|
border: InputBorder.none,
|
||
|
prefixText: 'x平移(m):',
|
||
|
),
|
||
|
onChanged: (String value) {
|
||
|
// coorTrans.L0 =(value);
|
||
|
},
|
||
|
)),
|
||
|
const Divider(),
|
||
|
Flexible(
|
||
|
child: TextFormField(
|
||
|
keyboardType: TextInputType.number,
|
||
|
controller: dyController,
|
||
|
decoration: const InputDecoration(
|
||
|
prefixText: 'Y平移(米):',
|
||
|
border: InputBorder.none,
|
||
|
),
|
||
|
onChanged: (String value) {
|
||
|
// coorTrans.L0 =(value);
|
||
|
},
|
||
|
)),
|
||
|
const Divider(),
|
||
|
Flexible(
|
||
|
child: TextFormField(
|
||
|
keyboardType: TextInputType.number,
|
||
|
controller: dzController,
|
||
|
decoration: const InputDecoration(
|
||
|
prefixText: 'Z平移(米):',
|
||
|
border: InputBorder.none,
|
||
|
),
|
||
|
onChanged: (String value) {
|
||
|
// coorTrans.L0 =(value);
|
||
|
},
|
||
|
)),
|
||
|
const Divider(),
|
||
|
];
|
||
|
List<Widget> list3 = [
|
||
|
Flexible(
|
||
|
child: TextFormField(
|
||
|
keyboardType: TextInputType.number,
|
||
|
controller: wxController,
|
||
|
decoration: const InputDecoration(
|
||
|
border: InputBorder.none,
|
||
|
prefixText: 'X轴旋转(秒):',
|
||
|
),
|
||
|
onChanged: (String value) {
|
||
|
// coorTrans.L0 =(value);
|
||
|
},
|
||
|
)),
|
||
|
const Divider(),
|
||
|
Flexible(
|
||
|
child: TextFormField(
|
||
|
keyboardType: TextInputType.number,
|
||
|
controller: wyController,
|
||
|
decoration: const InputDecoration(
|
||
|
border: InputBorder.none,
|
||
|
prefixText: 'Y轴旋转(秒):',
|
||
|
),
|
||
|
onChanged: (String value) {
|
||
|
// coorTrans.L0 =(value);
|
||
|
},
|
||
|
)),
|
||
|
const Divider(),
|
||
|
Flexible(
|
||
|
child: TextFormField(
|
||
|
keyboardType: TextInputType.number,
|
||
|
controller: wzController,
|
||
|
decoration: const InputDecoration(
|
||
|
border: InputBorder.none,
|
||
|
prefixText: 'Z轴旋转(秒):',
|
||
|
),
|
||
|
onChanged: (String value) {
|
||
|
// coorTrans.L0 =(value);
|
||
|
},
|
||
|
)),
|
||
|
const Divider(),
|
||
|
];
|
||
|
|
||
|
return Column(
|
||
|
children: <Widget>[
|
||
|
deviceType == DeviceType.mobile && size.width < 350
|
||
|
? Column(
|
||
|
children: list1,
|
||
|
)
|
||
|
: Row(
|
||
|
children: list1,
|
||
|
),
|
||
|
const Divider(),
|
||
|
deviceType == DeviceType.mobile && size.width < 350
|
||
|
? Column(
|
||
|
children: list2,
|
||
|
)
|
||
|
: Row(children: list2),
|
||
|
const Divider(),
|
||
|
deviceType == DeviceType.mobile && size.width < 350
|
||
|
? Column(
|
||
|
children: list3,
|
||
|
)
|
||
|
: Row(
|
||
|
children: list3,
|
||
|
),
|
||
|
const Divider(),
|
||
|
SizedBox(
|
||
|
child: TextFormField(
|
||
|
keyboardType: TextInputType.number,
|
||
|
controller: kController,
|
||
|
decoration: const InputDecoration(
|
||
|
border: InputBorder.none,
|
||
|
prefixText: '尺度:',
|
||
|
),
|
||
|
onChanged: (String value) {
|
||
|
// coorTrans.L0 =(value);
|
||
|
},
|
||
|
)),
|
||
|
const Divider(),
|
||
|
TextButton(
|
||
|
onPressed: () {
|
||
|
Connect().writeCoorTransValue(
|
||
|
blueToothController.connectedDeviceID.value,
|
||
|
coorTrans);
|
||
|
},
|
||
|
child: const Text("更新设置"))
|
||
|
],
|
||
|
);
|
||
|
},
|
||
|
),
|
||
|
));
|
||
|
}
|
||
|
}
|