gnssview/lib/sky/skyPlotView.dart

414 lines
13 KiB
Dart
Raw Permalink Normal View History

2024-12-02 10:57:26 +08:00
// import 'dart:convert';
// import 'package:flutter/material.dart';
// import 'package:flutter/services.dart';
// import 'package:get/get.dart';
// import 'package:gnss/gnss.dart';
// import 'package:mc_nav/main.dart';
// import '../../models/config/model.dart';
// import '../../service/pile/public_widget.dart';
// import 'chart_page.dart';
// import 'sky_plot_page.dart';
// // import 'chart_page.dart';
// // import 'sky_plot_page.dart';
// final SkyController skycontroller = Get.put(SkyController());
// class SkyPlotView extends StatefulWidget {
// const SkyPlotView({super.key});
// @override
// State<SkyPlotView> createState() => _SkyPlotViewState();
// }
// class _SkyPlotViewState extends State<SkyPlotView>
// with SingleTickerProviderStateMixin {
// late TabController _tabController;
// @override
// void initState() {
// super.initState();
// _tabController = TabController(length: 2, vsync: this);
// // appcontroller.gnss.signalStream.listen((event) {
// // var a = skycontroller.updateSky(event);
// // print(a);
// // });
// }
// @override
// Widget build(BuildContext context) {
// final size = MediaQuery.of(context).size;
// return GetBuilder<SkyController>(
// init: SkyController(), // 确保每次进入页面时初始化控制器
// builder: (controller) {
// final orientation = MediaQuery.of(context).orientation;
// bool isPortrait = Orientation.portrait == orientation ? true : false;
// List<Widget> children = [
// Container(
// alignment: Alignment.centerLeft,
// decoration: const BoxDecoration(color: Colors.blue),
// height: 40,
// child: Row(
// children: [
// IconButton(
// onPressed: () {
// Navigator.pop(context);
// },
// icon: const Icon(Icons.arrow_back_rounded)),
// const Text("GPS信号",
// style: TextStyle(
// color: Colors.white,
// fontSize: 16,
// fontWeight: FontWeight.bold))
// ],
// ),
// ),
// TabBar(
// labelColor: Colors.black, // 设置选中标签的字体颜色为黑色
// unselectedLabelColor: Colors.grey, // 设置未选中标签的字体颜色为灰色
// labelStyle:
// const TextStyle(color: Colors.black), // 设置选中标签的字体颜色为黑色
// unselectedLabelStyle:
// const TextStyle(color: Colors.grey), // 设置未选中标签的字体颜色为灰色
// controller: _tabController,
// tabs: const [
// Tab(text: '天空图', icon: Icon(Icons.blur_circular_sharp)),
// Tab(text: '信号质量', icon: Icon(Icons.bar_chart_rounded)),
// ],
// ),
// //
// const SkyTnfo(),
// ];
// Widget body = const Text("");
// if (isPortrait) {
// body = Column(
// children: [
// ...children,
// Expanded(
// child: TabBarView(
// physics: const NeverScrollableScrollPhysics(), // 禁用滑动切换
// controller: _tabController,
// children: [
// SkyPlotPage(controller: controller),
// ChartPage(controller: controller)
// ],
// ),
// ),
// ],
// );
// } else {
// body = Row(children: [
// Expanded(
// flex: 1,
// child: Column(
// children: children,
// ),
// ),
// Expanded(
// flex: 1,
// child: TabBarView(
// controller: _tabController,
// children: [
// SkyPlotPage(controller: controller),
// ChartPage(controller: controller)
// ],
// ),
// ),
// ]);
// }
// return Scaffold(
// appBar: AppBar(
// title: const Text("天空图"),
// toolbarHeight: 0,
// ),
// body: Container(
// decoration: const BoxDecoration(color: Colors.white),
// child: Stack(
// children: [
// Positioned(child: body),
// Obx(() {
// List<Widget> legendWideget = [];
// controller.legend.forEach((key, value) {
// LegendItem item = value;
// legendWideget.add(TextButton(
// onPressed: () {
// item.show = !item.show;
// item.color = item.show
// ? item.color.withOpacity(1)
// : item.color.withOpacity(0.3);
// controller.updateLegend(key, item);
// },
// child: Row(
// children: [
// Text(item.text,
// style: TextStyle(
// backgroundColor: item.color,
// color: Colors.white,
// fontSize: 20,
// ))
// ],
// )));
// });
// return !isPortrait
// ? Positioned(
// top: 150,
// left: size.width / 3,
// child: Column(
// children: legendWideget,
// ),
// )
// : Positioned(
// bottom: 20,
// right: 50,
// child: Row(
// children: legendWideget,
// ),
// );
// })
// ],
// ),
// ),
// );
// });
// }
// }
// List<String> statusList = [
// '初始化',
// '单点定位',
// '码差分',
// '无效PPS',
// '固定解',
// '浮点解',
// '正在估算',
// '人工输入',
// '模拟模式',
// 'WAAS差分',
// '单点定位'
// ];
// class SkyTnfo extends GetView<SkyController> {
// const SkyTnfo({super.key});
// @override
// Widget build(BuildContext context) {
// final isPortrait =
// MediaQuery.of(context).orientation == Orientation.portrait;
// return Theme(
// data: ThemeData(
// textTheme: const TextTheme(
// titleLarge: TextStyle(
// fontSize: 30,
// fontWeight: FontWeight.normal,
// ),
// )),
// child: Container(
// margin: const EdgeInsets.only(left: 5),
// alignment: Alignment.centerLeft,
// child: Obx(() {
// Widget rowItem(String title, String text) => Row(
// children: [
// FixedWidthTextWidget(
// width: 95,
// text: title,
// style: Theme.of(context).textTheme.titleLarge,
// ),
// Text(
// text,
// style: Theme.of(context).textTheme.titleLarge,
// )
// ],
// );
// List<Widget> children = [
// controller.lat.value > 0.0
// ? rowItem("北纬", '${controller.lat.value.toStringAsFixed(4)}N ')
// : rowItem(
// "南纬:", '${controller.lat.value.toStringAsFixed(4)}S '),
// controller.lon > 0.0
// ? rowItem("东经:", '${controller.lon.value.toStringAsFixed(4)}E ')
// : rowItem(
// "西经:", '${controller.lon.value.toStringAsFixed(4)}W '),
// rowItem("高程:", ' '),
// rowItem("水平:", '${controller.hdop.value}米 '),
// rowItem("GNSS误差", ''),
// rowItem("定位状态:", statusList[controller.status.value]),
// rowItem("可见:", '${controller.view.value}'),
// rowItem("使用:", '${controller.use.value}')
// ];
// return isPortrait
// ? Wrap(
// children: children,
// )
// : Column(children: children);
// }),
// ),
// );
// }
// }
// class SkyController extends GetxController {
// var use = 0.obs;
// var view = 0.obs;
// var status = 0.obs;
// var hdop = 0.0.obs;
// var lat = 0.0.obs;
// var lon = 0.0.obs;
// var alt = 0.0.obs;
// var bsv = [].obs;
// var esv = [].obs;
// var rsv = [].obs;
// var gsv = [].obs;
// var legend = {}.obs;
// // GpsSignal? chartData;
// SignalData? signalData;
// var signalUpdate = 0.obs;
// Map<String, bool> selectedSignal = {
// "GPS": true,
// "GLO": true,
// "GAL": true,
// "BDS": true,
// "QZS": true,
// }.obs;
// @override
// void onInit() {
// super.onInit();
// // rootBundle.loadString('images/gps.json').then((value) {
// // var originCharData = jsonDecode(value);
// // chartData = GpsSignal.fromJson(originCharData);
// // if (chartData != null) {
// // updateSV(chartData!);
// // }
// // updateSky(originCharData);
// // });
// appcontroller.gnss.signalStream.listen((singnal) {
// var key = singnal.keys.first;
// var signalGNSS = singnal[key];
// updateSky(signalGNSS);
// });
// }
// void dispose() {
// appcontroller.gnss.dispose();
// super.dispose();
// }
// updateSky(data) {
// var sky = data.toString();
// update();
// }
// List<Color> colors = const [
// Color.fromRGBO(0, 0, 160, 1),
// Color.fromRGBO(0, 112, 0, 1),
// Color.fromRGBO(128, 0, 0, 1),
// Color.fromRGBO(128, 96, 0, 1),
// Color.fromRGBO(0, 96, 96, 1),
// Color.fromRGBO(128, 0, 128, 1),
// Color.fromRGBO(68, 68, 204, 1),
// Color.fromRGBO(128, 64, 64, 1),
// Color.fromRGBO(64, 64, 128, 1),
// Color.fromRGBO(128, 128, 128, 1),
// ];
// List<String> sVTypes = [
// 'GPS',
// 'SBAS',
// 'GLONASS',
// 'GALILEO',
// 'QZSS',
// 'BEIDOU',
// 'OMNI',
// 'XPS',
// 'IRNSS'
// ];
// List<String> sVLabels = [
// 'GPS',
// 'SBAS',
// 'GLN',
// 'GAL',
// 'QZSS',
// 'BDS',
// 'OMNI',
// 'XPS',
// 'IRNSS'
// ];
// Map svMap = {
// "BDS": "BSV",
// "GLN": "ESV",
// "GPS": "GSV",
// "GAL": "RSV",
// };
// var svData = [].obs;
// updateSV(GpsSignal chartData) {
// if ((chartData.bsv).isNotEmpty) {
// for (int i = 0; i < chartData.bsv.length; i++) {
// SvItem data = chartData.bsv[i];
// data.name = 'BEIDOU';
// svData.add(data);
// }
// }
// if ((chartData.esv).isNotEmpty) {
// for (int i = 0; i < chartData.esv.length; i++) {
// SvItem data = chartData.esv[i];
// data.name = 'GLONASS';
// svData.add(data);
// }
// }
// if ((chartData.gsv).isNotEmpty) {
// for (int i = 0; i < chartData.gsv.length; i++) {
// SvItem data = chartData.gsv[i];
// data.name = 'GPS';
// svData.add(data);
// }
// }
// if ((chartData.rsv).isNotEmpty) {
// for (int i = 0; i < chartData.rsv.length; i++) {
// SvItem data = chartData.rsv[i];
// data.name = 'GALILEO';
// svData.add(data);
// }
// }
// for (var i = 0; i < svData.length; i++) {
// SvItem item = svData[i];
// String sys = item.name;
// int index = sVTypes.indexWhere((item) => item == sys);
// legend[sys] =
// LegendItem(text: sVLabels[index], color: colors[index], show: true);
// // {
// // 'text': sVLabels[index],
// // 'color': colors[index],
// // "show": true
// // };
// }
// }
// updateLegend(String key, LegendItem data) {
// legend[key] = data;
// startIndex.value = 0;
// update();
// }
// final startIndex = 0.obs;
// updateSlider(double value) {
// startIndex.value = value.ceil();
// update();
// }
// }
// class LegendItem {
// String text;
// Color color;
// bool show;
// LegendItem({required this.text, required this.color, this.show = true});
// }