From 7f0191f6fcbe3967bb87e5e2d325fe675bbdaf6a Mon Sep 17 00:00:00 2001 From: tanlinxing Date: Mon, 2 Dec 2024 10:57:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E5=8A=A0=E6=95=B0=E6=8D=AE=E7=9A=84?= =?UTF-8?q?=E5=A4=A9=E7=A9=BA=E5=9B=BE=E6=9F=B1=E7=8A=B6=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Controller/gnss_controller.dart | 2 +- lib/sky/chart_page.dart | 252 +++++++++++++++++ lib/sky/draw_sky_plot.dart | 141 ++++++++++ lib/sky/skyPlotView.dart | 413 ++++++++++++++++++++++++++++ lib/sky/sky_plot_page.dart | 43 +++ 5 files changed, 850 insertions(+), 1 deletion(-) create mode 100644 lib/sky/chart_page.dart create mode 100644 lib/sky/draw_sky_plot.dart create mode 100644 lib/sky/skyPlotView.dart create mode 100644 lib/sky/sky_plot_page.dart diff --git a/lib/Controller/gnss_controller.dart b/lib/Controller/gnss_controller.dart index 02ac917..9668a51 100644 --- a/lib/Controller/gnss_controller.dart +++ b/lib/Controller/gnss_controller.dart @@ -40,7 +40,7 @@ class GnssController extends GetxController { @override void onInit() async { super.onInit(); - gnss = Gnss(port: "/dev/ttysWK2", baudrate: 115200); + gnss = Gnss(port: "/dev/ttyS5", baudrate: 115200); // gnss = Gnss(port: "COM1", baudrate: 115200); gnss.start(); gnss.locationStream.listen((location) { diff --git a/lib/sky/chart_page.dart b/lib/sky/chart_page.dart new file mode 100644 index 0000000..c421733 --- /dev/null +++ b/lib/sky/chart_page.dart @@ -0,0 +1,252 @@ +// import 'dart:math'; + +// import 'package:fl_chart/fl_chart.dart'; +// import 'package:flutter/material.dart'; +// import 'package:get/get.dart'; + +// import '../../models/config/model.dart'; +// import 'skyPlotView.dart'; + +// class ChartPage extends StatelessWidget { +// ChartPage({super.key, required this.controller}); +// final SkyController controller; +// List checkSVData = []; +// int lastValue = -10; +// double maxY = 0; +// int maxX = 10; +// double xLength = 0; +// @override +// Widget build(BuildContext context) { +// checkSVData.length = 0; +// xLength = 0; +// List svData = List.from(controller.svData) +// ..sort((a, b) => a.sn.compareTo(b.sn)); + +// for (int i = 0; i < svData.length; i++) { +// SvItem item = svData[i]; +// String sys = item.name; +// // int index = controller.sVTypes.indexWhere((item) => item == sys); + +// LegendItem legendItem = controller.legend[sys]; +// if (legendItem.show) { +// maxY = max(maxY, item.l1.toDouble()); +// maxY = max(maxY, item.l2.toDouble()); +// maxX = max(maxX, item.sn); +// checkSVData.add(makeGroupData( +// item.sn, item.l1.toDouble(), item.l2.toDouble(), legendItem.color)); +// xLength++; +// } +// } +// if (checkSVData.isNotEmpty) { +// if (controller.startIndex.value < checkSVData.length - 15) { +// checkSVData = checkSVData.sublist( +// controller.startIndex.value, controller.startIndex.value + 15); +// } else { +// checkSVData = checkSVData.sublist( +// controller.startIndex.value, checkSVData.length - 1); +// } +// } + +// final size = MediaQuery.of(context).size; +// final orientation = +// MediaQuery.of(context).orientation == Orientation.portrait; +// return Container( +// width: size.width, +// decoration: const BoxDecoration(color: Colors.white), +// child: AspectRatio( +// aspectRatio: 1, +// child: Padding( +// padding: const EdgeInsets.all(10), +// child: Stack( +// children: [ +// Column( +// crossAxisAlignment: CrossAxisAlignment.stretch, +// children: [ +// Expanded( +// child: BarChart( +// BarChartData( +// maxY: maxY, // 提示需要+ 20 因为 提示是根据柱状图位置进行计算的 +// barTouchData: BarTouchData( +// touchTooltipData: BarTouchTooltipData( +// // tooltipBgColor: Colors.blueGrey, +// getTooltipItem: ( +// BarChartGroupData group, +// int groupIndex, +// BarChartRodData rod, +// int rodIndex, +// ) { +// return BarTooltipItem( +// 'L1:${group.barRods[0].toY}\nL2:${group.barRods[1].toY}', +// const TextStyle( +// fontWeight: FontWeight.bold, +// decoration: TextDecoration.none, +// color: Colors.black, +// fontSize: 18, +// shadows: [ +// Shadow( +// color: Colors.black26, +// blurRadius: 12, +// ) +// ], +// ), +// ); +// }, +// ), +// touchCallback: (event, response) { +// if (event.isInterestedForInteractions && +// response != null && +// response.spot != null) { +// // setState(() { +// // touchedGroupIndex = +// // response.spot!.touchedBarGroupIndex; +// // }); +// } else { +// // setState(() { +// // touchedGroupIndex = -100; +// // }); +// } +// }, +// ), +// titlesData: FlTitlesData( +// show: true, +// rightTitles: AxisTitles( +// sideTitles: SideTitles(showTitles: false), +// ), +// topTitles: AxisTitles( +// sideTitles: SideTitles(showTitles: false), +// ), +// bottomTitles: AxisTitles( +// sideTitles: SideTitles( +// showTitles: true, +// getTitlesWidget: bottomTitles, +// reservedSize: 42, +// ), +// ), +// leftTitles: AxisTitles( +// sideTitles: SideTitles( +// showTitles: true, +// reservedSize: 28, +// interval: 1, +// getTitlesWidget: leftTitles, +// ), +// ), +// ), +// borderData: FlBorderData( +// show: false, +// ), +// barGroups: checkSVData, +// gridData: FlGridData(show: false), +// ), +// ), +// ), +// if (orientation) +// const SizedBox( +// height: 50, +// ), +// ], +// ), +// Positioned( +// bottom: 0, +// left: 0, +// right: 0, +// height: size.height, +// child: Opacity( +// opacity: 0, // 设置 Slider 组件的透明度为 0,使其不可见 +// child: Slider( +// value: controller.startIndex.toDouble(), +// onChanged: (newvalue) => controller.updateSlider(newvalue), +// min: 0, +// max: xLength <= 5 ? 0 : xLength - 5, +// ), +// ), +// ), +// ], +// ), +// ), +// ), +// ); +// } + +// Widget leftTitles(double value, TitleMeta meta) { +// const style = TextStyle( +// color: Color(0xff7589a2), +// fontWeight: FontWeight.bold, +// fontSize: 14, +// decoration: TextDecoration.none); +// String text; +// int intValue = (value).ceil(); +// if (intValue % 10 == 0 && intValue <= maxY) { +// text = intValue.toString(); +// } else { +// return Container(); +// } +// return SideTitleWidget( +// axisSide: meta.axisSide, +// space: 0, +// child: Text(text, style: style), +// ); +// } + +// Widget bottomTitles(double value, TitleMeta meta) { +// // if (lastValue == value) { +// // return SideTitleWidget( +// // axisSide: meta.axisSide, +// // space: 16, //margin top +// // child: const Text(''), +// // ); +// // } +// String text = ""; +// int intValue = (value).ceil(); + +// if (intValue != lastValue) { +// text = intValue.toString(); +// } + +// lastValue = intValue; +// return SideTitleWidget( +// axisSide: meta.axisSide, +// space: 16, //margin top +// child: Text( +// text.toString(), +// style: const TextStyle( +// color: Color(0xff7589a2), +// fontWeight: FontWeight.bold, +// decoration: TextDecoration.none, +// fontSize: 14, +// ), +// ), +// ); +// } + +// final double width = 20; +// final Color leftBarColor = const Color.fromARGB(95, 101, 98, 98); +// final Color rightBarColor = const Color.fromRGBO(33, 150, 243, 1); + +// BarChartGroupData makeGroupData(int x, double y1, double y2, +// [Color color = const Color.fromRGBO(33, 150, 243, 1)]) { +// return BarChartGroupData( +// barsSpace: -width, +// x: x, +// showingTooltipIndicators: [], +// barRods: [ +// BarChartRodData( +// toY: y1, +// color: Colors.white, +// borderSide: BorderSide(color: leftBarColor, width: 1), +// borderRadius: const BorderRadius.all( +// Radius.circular(2), +// ), +// width: width, +// ), +// BarChartRodData( +// toY: y2, +// color: color, +// borderRadius: const BorderRadius.all( +// Radius.circular(2), +// ), +// width: width, +// ), +// ], +// ); +// } +// } diff --git a/lib/sky/draw_sky_plot.dart b/lib/sky/draw_sky_plot.dart new file mode 100644 index 0000000..16702c9 --- /dev/null +++ b/lib/sky/draw_sky_plot.dart @@ -0,0 +1,141 @@ +// import 'dart:math'; + +// import 'package:flutter/material.dart'; +// import '../../models/config/model.dart'; +// import 'skyPlotView.dart'; + +// class DrawSkyPlot { +// double width = 500; +// double height = 500; +// late Canvas ctx; +// Map legend = {}; +// final Paint _paint = Paint(); +// Path path = Path(); +// bool isPortrait = false; +// SkyController controller; +// DrawSkyPlot(op, this.controller) { +// ctx = op['ctx']; // canvas dom 对象 +// height = op['height']; // 画布高 +// width = op['width']; // 画布宽 +// _paint +// ..color = Colors.black +// ..strokeWidth = 3 +// ..style = PaintingStyle.stroke; +// MediaQueryData mediaQueryData = +// MediaQueryData.fromView(WidgetsBinding.instance.window); +// final orientation = mediaQueryData.orientation; +// // 横屏竖屏宽高重新设置 +// if (orientation == Orientation.portrait) { +// height = op['width']; +// isPortrait = true; +// } else { +// width = op['height']; +// isPortrait = false; +// } +// } + +// //外圈 +// drawSkyPlotCircle() { +// double x = width / 2; +// double y = height / 2; +// double r = height / 2.5; +// ctx.drawCircle(Offset(x, y), r, _paint); +// ctx.drawCircle(Offset(x, y), r * 2 / 3, _paint); +// ctx.drawCircle(Offset(x, y), r / 3, _paint); +// path.moveTo(x - r, y); +// path.lineTo(x + r, y); +// path.moveTo(x, y - r); +// path.lineTo(x, y + r); +// path.moveTo(x + cos(30 * (pi / 180)) * r, y + sin(30 * (pi / 180)) * r); +// path.lineTo(x - cos(30 * (pi / 180)) * r, y - sin(30 * (pi / 180)) * r); +// path.moveTo(x + cos(60 * (pi / 180)) * r, y + sin(60 * (pi / 180)) * r); +// path.lineTo(x - cos(60 * (pi / 180)) * r, y - sin(60 * (pi / 180)) * r); +// path.moveTo(x + cos(60 * (pi / 180)) * r, y - sin(60 * (pi / 180)) * r); +// path.lineTo(x - cos(60 * (pi / 180)) * r, y + sin(60 * (pi / 180)) * r); +// path.moveTo(x - cos(60 * (pi / 180)) * r, y + sin(60 * (pi / 180)) * r); +// path.lineTo(x + cos(60 * (pi / 180)) * r, y - sin(60 * (pi / 180)) * r); +// path.moveTo(x + cos(30 * (pi / 180)) * r, y - sin(30 * (pi / 180)) * r); +// path.lineTo(x - cos(30 * (pi / 180)) * r, y + sin(30 * (pi / 180)) * r); +// path.moveTo(x - cos(30 * (pi / 180)) * r, y + sin(30 * (pi / 180)) * r); +// path.lineTo(x + cos(30 * (pi / 180)) * r, y - sin(30 * (pi / 180)) * r); +// ctx.drawPath(path, _paint); + +// Map textList = { +// '0': Offset(x, y - r - 25), +// '30': Offset( +// x + cos(60 * (pi / 180)) * r, y - sin(60 * (pi / 180)) * r - 25), +// '60': Offset( +// x + cos(30 * (pi / 180)) * r + 10, y - sin(30 * (pi / 180)) * r - 10), +// '90': Offset(x + r + 10, y - 5), +// '120': Offset( +// x + cos(30 * (pi / 180)) * r, y + sin(30 * (pi / 180)) * r + 5), +// '150': Offset( +// x + cos(60 * (pi / 180)) * r, y + sin(60 * (pi / 180)) * r + 5), +// '180': Offset(x - 10, y + r), +// '210': Offset( +// x - cos(60 * (pi / 180)) * r - 20, y + sin(60 * (pi / 180)) * r + 10), +// '240': Offset( +// x - cos(30 * (pi / 180)) * r - 30, y + sin(30 * (pi / 180)) * r + 5), +// '270': Offset(x - r - 35, y - 5), +// '300': Offset( +// x - cos(30 * (pi / 180)) * r - 37, y - sin(30 * (pi / 180)) * r - 20), +// '330': Offset( +// x - cos(60 * (pi / 180)) * r - 30, y - sin(60 * (pi / 180)) * r - 25) +// }; +// textList.forEach((key, offset) { +// TextPainter( +// text: TextSpan( +// text: key, +// style: const TextStyle(color: Colors.black, fontSize: 20)), +// textDirection: TextDirection.ltr, +// ) +// ..layout() +// ..paint(ctx, offset); +// }); +// } + +// getCircles(GpsSignal chartData) { +// legend = {}; +// double x = width / 3; +// double y = height / 2; +// double maxr = height / 4.2; +// double r = 12; +// List svData = controller.svData; +// for (int i = 0; i < svData.length; i++) { +// SvItem item = svData[i]; +// int elev = item.ea; + +// if (elev == -45) continue; +// double azi = item.aa * pi / 180; +// // console.log(elev,azi); +// double cx = (x + sin(azi) * (-elev) * (180 / 90) * maxr / 180); +// double cy = (y - (cos(azi) * (-elev) * (180 / 90) * maxr / 180)); +// int prn = item.sn; +// String sys = item.name; +// int index = controller.sVTypes.indexWhere((item) => item == sys); + +// LegendItem legendItem = controller.legend[sys]; +// if (legendItem.show) { +// _paint.color = controller.colors[index]; +// _paint.style = PaintingStyle.fill; +// // this.ctx.fillStyle = colors[index]; + +// ctx.drawCircle(Offset(cx, cy), r, _paint); + +// TextPainter( +// text: TextSpan( +// text: prn.toString(), +// style: const TextStyle( +// color: Colors.white, +// fontSize: 16, +// )), +// textDirection: TextDirection.ltr, +// ) +// ..layout() +// ..paint(ctx, Offset(cx - 10, cy - 7)); +// } + +// // } +// } +// } +// } diff --git a/lib/sky/skyPlotView.dart b/lib/sky/skyPlotView.dart new file mode 100644 index 0000000..eb97e19 --- /dev/null +++ b/lib/sky/skyPlotView.dart @@ -0,0 +1,413 @@ +// 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 createState() => _SkyPlotViewState(); +// } + +// class _SkyPlotViewState extends State +// 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( +// init: SkyController(), // 确保每次进入页面时初始化控制器 +// builder: (controller) { +// final orientation = MediaQuery.of(context).orientation; +// bool isPortrait = Orientation.portrait == orientation ? true : false; +// List 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 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 statusList = [ +// '初始化', +// '单点定位', +// '码差分', +// '无效PPS', +// '固定解', +// '浮点解', +// '正在估算', +// '人工输入', +// '模拟模式', +// 'WAAS差分', +// '单点定位' +// ]; + +// class SkyTnfo extends GetView { +// 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 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 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 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 sVTypes = [ +// 'GPS', +// 'SBAS', +// 'GLONASS', +// 'GALILEO', +// 'QZSS', +// 'BEIDOU', +// 'OMNI', +// 'XPS', +// 'IRNSS' +// ]; +// List 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}); +// } diff --git a/lib/sky/sky_plot_page.dart b/lib/sky/sky_plot_page.dart new file mode 100644 index 0000000..3e4959b --- /dev/null +++ b/lib/sky/sky_plot_page.dart @@ -0,0 +1,43 @@ +// import 'package:flutter/material.dart'; +// import 'draw_sky_plot.dart'; +// import 'skyPlotView.dart'; + + +// class SkyPlotPage extends StatelessWidget { +// final SkyController controller; +// const SkyPlotPage({super.key, required this.controller}); + +// @override +// Widget build(BuildContext context) { +// return Container( +// decoration: const BoxDecoration(color: Colors.white), +// child: CustomPaint( +// painter: DrawSky(controller, context), +// ), +// ); +// } +// } + +// class DrawSky extends CustomPainter { +// final BuildContext context; +// final SkyController controller; +// DrawSky( +// this.controller, +// this.context, +// ); +// @override +// void paint(Canvas canvas, Size size) { +// // bool isPortrait = MediaQuery.of(context).orientation == Orientation.portrait; +// canvas.translate(0, -15); +// DrawSkyPlot skyPlot = DrawSkyPlot( +// {'ctx': canvas, 'width': size.width, 'height': size.height}, +// controller); +// skyPlot.drawSkyPlotCircle(); +// if (controller.chartData != null) { +// skyPlot.getCircles(controller.chartData!); +// } +// } + +// @override +// bool shouldRepaint(covariant CustomPainter oldDelegate) => true; +// }