2024-08-18 22:42:37 +08:00
|
|
|
//字体
|
2024-11-06 17:23:29 +08:00
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
import 'package:cpnav/controllers/gnss_controller.dart';
|
2024-09-05 12:06:03 +08:00
|
|
|
import 'package:cpnav/main.dart';
|
2024-08-28 17:56:53 +08:00
|
|
|
import 'package:cpnav/pages/aim_point/aimpoint_page.dart';
|
2024-08-18 22:42:37 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:get/get.dart';
|
2024-11-15 17:42:52 +08:00
|
|
|
import 'package:intl/intl.dart';
|
2024-08-26 18:25:21 +08:00
|
|
|
import 'package:scence_map/controllers/controller.dart';
|
2024-08-28 17:56:53 +08:00
|
|
|
import 'package:scence_map/record_entity.dart';
|
2024-08-18 22:42:37 +08:00
|
|
|
import 'package:scence_map/scence_map.dart';
|
2024-11-21 10:01:14 +08:00
|
|
|
import '../../service/pile/device_type.dart';
|
2024-11-06 17:23:29 +08:00
|
|
|
import '../aim_point/aimpoint_controller.dart';
|
2024-11-20 19:42:10 +08:00
|
|
|
import '../dataAndDevice/real_data.dart';
|
|
|
|
import '../dataAndDevice/real_device.dart';
|
2024-11-06 17:23:29 +08:00
|
|
|
import '../real/real_data_card.dart';
|
2024-11-20 19:42:10 +08:00
|
|
|
|
2024-08-18 22:42:37 +08:00
|
|
|
import "controller.dart";
|
2024-08-27 18:08:05 +08:00
|
|
|
|
2024-08-19 18:31:59 +08:00
|
|
|
ScenceMapController mapcontroller = Get.put(ScenceMapController());
|
|
|
|
|
2024-11-20 19:42:10 +08:00
|
|
|
class PassTackAndDevice extends StatelessWidget {
|
|
|
|
final RecordEntity? currentPoint;
|
|
|
|
PassTackAndDevice({this.currentPoint});
|
2024-11-21 10:01:14 +08:00
|
|
|
final controller = Get.put(PassTrackController());
|
|
|
|
|
2024-11-20 19:42:10 +08:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-11-21 10:01:14 +08:00
|
|
|
if (controller.isDeviceShow.value) {
|
|
|
|
return Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
flex: 2,
|
|
|
|
child: RealDeviceView(),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
flex: 5,
|
|
|
|
child: PassTrack(currentPoint: currentPoint),
|
|
|
|
),
|
|
|
|
Expanded(flex: 2, child: RealDataContainer()),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
flex: 7,
|
|
|
|
child: PassTrack(currentPoint: currentPoint),
|
|
|
|
),
|
|
|
|
Expanded(flex: 2, child: RealDataContainer()),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2024-11-20 19:42:10 +08:00
|
|
|
}
|
|
|
|
}
|
2024-08-19 18:31:59 +08:00
|
|
|
|
2024-11-15 17:42:52 +08:00
|
|
|
// ignore: must_be_immutable
|
2024-10-29 17:55:04 +08:00
|
|
|
class PassTrack extends GetView<PassTrackController> {
|
2024-11-06 17:23:29 +08:00
|
|
|
// final GlobalKey<PopupMenuButtonState<int>> _popupMenuKey =
|
|
|
|
// GlobalKey<PopupMenuButtonState<int>>();
|
2024-11-15 17:42:52 +08:00
|
|
|
RecordEntity? currentPoint;
|
2024-11-06 17:23:29 +08:00
|
|
|
@override
|
2024-11-15 17:42:52 +08:00
|
|
|
final controller = Get.put(PassTrackController());
|
2024-11-21 10:01:14 +08:00
|
|
|
|
2024-11-06 17:23:29 +08:00
|
|
|
// String str = "播放";
|
|
|
|
// int sWidth = 0;
|
|
|
|
// int bits = -1;
|
|
|
|
// int speed = 50;
|
|
|
|
// List<int> speedList = [1, 2, 10, 20, 50, 100, 200, 500];
|
|
|
|
// int maxLength = 200;
|
|
|
|
// final _rangevalues = const SfRangeValues(0.0, 200.0);
|
|
|
|
|
2024-11-15 17:42:52 +08:00
|
|
|
PassTrack({super.key, this.currentPoint});
|
2024-08-18 22:42:37 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-11-15 17:42:52 +08:00
|
|
|
if (currentPoint == null) {
|
|
|
|
controller.date.value = DateFormat('yyyy-MM-dd').format(DateTime.now());
|
|
|
|
} else {
|
|
|
|
controller.date.value =
|
|
|
|
DateFormat('yyyy-MM-dd').format(currentPoint!.startTime);
|
|
|
|
}
|
|
|
|
controller.currentPoint = currentPoint;
|
|
|
|
controller.loadData();
|
|
|
|
|
|
|
|
return Obx(() {
|
|
|
|
controller.updateCount.value;
|
|
|
|
CustomPainter? forGroundPainter = appcontroller.currentIndex.value == 1
|
|
|
|
? BorderPainter(
|
|
|
|
controller,
|
|
|
|
)
|
|
|
|
: null;
|
2024-11-21 10:01:14 +08:00
|
|
|
|
2024-11-15 17:42:52 +08:00
|
|
|
return OrientationBuilder(builder: (context, orientation) {
|
2024-11-21 10:01:14 +08:00
|
|
|
final size = MediaQuery.of(context).size;
|
|
|
|
|
2024-11-15 17:42:52 +08:00
|
|
|
return Stack(
|
|
|
|
children: [
|
|
|
|
ScenceMapView(
|
|
|
|
onUpdate: (Offset center, double scale, double rotation) {
|
|
|
|
log("center:$center scale:$scale rotation:$rotation");
|
|
|
|
},
|
|
|
|
forGroundPainter: forGroundPainter,
|
|
|
|
onUpdatePilePoint: (RecordEntity? selectedPilePoint, double scale,
|
|
|
|
double rotation) {
|
|
|
|
log("selectedPilePoint:$selectedPilePoint scale:$scale rotation:$rotation");
|
|
|
|
controller.selectedPilePoint.value = selectedPilePoint;
|
|
|
|
aimcontroller.selectedPilePoint = selectedPilePoint;
|
|
|
|
controller.updateCount.value++;
|
|
|
|
},
|
|
|
|
children: const [],
|
|
|
|
),
|
2024-11-21 10:01:14 +08:00
|
|
|
SightGview(size: size),
|
2024-11-15 17:42:52 +08:00
|
|
|
const RealDataShow(),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
});
|
2024-08-20 17:44:39 +08:00
|
|
|
});
|
2024-08-18 22:42:37 +08:00
|
|
|
}
|
|
|
|
}
|
2024-08-28 17:56:53 +08:00
|
|
|
|
|
|
|
// 自定义的 BorderPainter
|
|
|
|
class BorderPainter extends CustomPainter {
|
|
|
|
final PassTrackController controller;
|
|
|
|
final GnssController gnsscontroller;
|
|
|
|
BorderPainter(this.controller)
|
|
|
|
: gnsscontroller = Get.find<GnssController>(),
|
|
|
|
super(repaint: controller);
|
|
|
|
|
|
|
|
@override
|
|
|
|
void paint(Canvas canvas, Size size) {
|
|
|
|
// 绘制边框
|
|
|
|
// canvas.scale(controller.dtScale);
|
|
|
|
|
|
|
|
final paint = Paint()
|
|
|
|
..color = Colors.red
|
|
|
|
..strokeWidth = 3.0;
|
2024-11-15 17:42:52 +08:00
|
|
|
RecordEntity? selectedPilePoint = controller.selectedPilePoint.value;
|
|
|
|
if (selectedPilePoint != null) {
|
|
|
|
var offset = Offset(selectedPilePoint.x, selectedPilePoint.y);
|
2024-08-28 17:56:53 +08:00
|
|
|
Offset screenPos = mapcontroller.xy2Screen0(offset);
|
|
|
|
|
|
|
|
// 计算圆的直径
|
|
|
|
double circleDiameter = 2 * 0.3 / mapcontroller.pixel2MeterRatio;
|
|
|
|
|
|
|
|
final rect = Rect.fromCenter(
|
|
|
|
center: screenPos,
|
|
|
|
width: circleDiameter + 4,
|
|
|
|
height: circleDiameter + 4);
|
|
|
|
// 定义角的长度
|
|
|
|
// double cornerLength = 10.0 ;
|
|
|
|
double cornerLength = 12;
|
|
|
|
|
|
|
|
// 确保 cornerLength 不小于最小值
|
|
|
|
if (mapcontroller.scale >= 2 && mapcontroller.scale < 5) {
|
|
|
|
cornerLength = 1.0;
|
|
|
|
} else if (mapcontroller.scale >= 5 && mapcontroller.scale < 10) {
|
|
|
|
cornerLength = 0.01;
|
|
|
|
} else if (mapcontroller.scale >= 10) {
|
|
|
|
cornerLength = 0;
|
|
|
|
}
|
2024-11-15 17:42:52 +08:00
|
|
|
paint.style = PaintingStyle.stroke;
|
|
|
|
canvas.drawRect(rect, paint);
|
2024-08-28 17:56:53 +08:00
|
|
|
|
2024-11-15 17:42:52 +08:00
|
|
|
Offset center =
|
|
|
|
Offset(gnsscontroller.device.x.value, gnsscontroller.device.y.value);
|
2024-08-28 17:56:53 +08:00
|
|
|
Offset pilerCenter = mapcontroller.xy2Screen0(center);
|
|
|
|
//绘制虚线
|
|
|
|
if (mapcontroller.deviceList.isNotEmpty) {
|
|
|
|
Paint dashedPaint = Paint()
|
|
|
|
..color = Colors.red
|
|
|
|
..strokeWidth = 3.5;
|
2024-11-15 17:42:52 +08:00
|
|
|
var offset = Offset(selectedPilePoint.x, selectedPilePoint.y);
|
2024-08-28 17:56:53 +08:00
|
|
|
Offset screenPos = mapcontroller.xy2Screen0(offset);
|
|
|
|
|
|
|
|
drawDashedLine(canvas, pilerCenter, screenPos, dashedPaint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void drawDashedLine(Canvas canvas, Offset start, Offset end, Paint paint) {
|
|
|
|
const double dashWidth = 10.0;
|
|
|
|
const double dashSpace = 5.0;
|
|
|
|
double distance = (end - start).distance;
|
|
|
|
double dashCount = distance / (dashWidth + dashSpace).floor();
|
|
|
|
if (dashCount < 5000) {
|
|
|
|
for (int i = 0; i < dashCount; ++i) {
|
|
|
|
double startX = start.dx +
|
|
|
|
(end.dx - start.dx) * (i * (dashWidth + dashSpace) / distance);
|
|
|
|
double startY = start.dy +
|
|
|
|
(end.dy - start.dy) * (i * (dashWidth + dashSpace) / distance);
|
|
|
|
double endX = start.dx +
|
|
|
|
(end.dx - start.dx) *
|
|
|
|
((i * (dashWidth + dashSpace) + dashWidth) / distance);
|
|
|
|
double endY = start.dy +
|
|
|
|
(end.dy - start.dy) *
|
|
|
|
((i * (dashWidth + dashSpace) + dashWidth) / distance);
|
|
|
|
canvas.drawLine(Offset(startX, startY), Offset(endX, endY), paint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool shouldRepaint(covariant CustomPainter oldDelegate) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|