设备移动

This commit is contained in:
tanlinxing 2024-08-31 17:57:19 +08:00
parent b53abd5705
commit 84c403ae26
8 changed files with 350 additions and 406 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,14 +1,11 @@
import 'dart:async'; import 'package:cpnav/pages/aim_point/aimpoint_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:scence_map/controllers/controller.dart';
import 'main.dart'; import 'main.dart';
import 'pages/aim_point/aimPointer.dart'; import 'pages/aim_point/aimpointController.dart';
import 'pages/real/realController.dart'; import 'pages/real/realController.dart';
final SightController sightcontroller = Get.find(); final AimPointerController aimcontroller = Get.find();
final RealController realcontroller = Get.find(); final RealController realcontroller = Get.find();
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
@ -96,17 +93,16 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
() => InkWell( () => InkWell(
onTap: () { onTap: () {
// //
sightcontroller.isCardVisible.value = aimcontroller.isCardVisible.value =
!sightcontroller.isCardVisible.value; // !aimcontroller.isCardVisible.value; //
sightcontroller.lastManualTapTime = aimcontroller.lastManualTapTime =
DateTime.now().millisecondsSinceEpoch; DateTime.now().millisecondsSinceEpoch;
}, },
child: Icon( child: Icon(
Icons.my_location_sharp, Icons.my_location_sharp,
size: 35, size: 35,
color: sightcontroller.isCardVisible.value color: aimcontroller.isCardVisible.value
? Colors.blue ? Colors.blue
// : const Color.fromARGB(200, 29, 28, 28), // : const Color.fromARGB(200, 29, 28, 28),
: (appcontroller.isDarkMode.value : (appcontroller.isDarkMode.value

View File

@ -1,19 +1,19 @@
import 'dart:async'; import 'dart:async';
import 'dart:math'; import 'dart:math';
import 'dart:ui'; import 'dart:ui';
import 'package:cpnav/pages/pass_track/controller.dart'; import 'package:cpnav/pages/aim_point/aimpoint_page.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:gnss/gnss.dart'; import 'package:gnss/gnss.dart';
import 'package:scence_map/controllers/controller.dart'; import 'package:scence_map/controllers/controller.dart';
import 'package:scence_map/record_entity.dart'; import 'package:scence_map/record_entity.dart';
import '../models/pilePoint/coord_trans.dart'; import '../models/pilePoint/coord_trans.dart';
import '../pages/aim_point/aimPointer.dart'; import '../pages/aim_point/aimpointController.dart';
class GnssController extends GetxController { class GnssController extends GetxController {
late final Gnss gnss; late final Gnss gnss;
late ScenceMapController mapController; late ScenceMapController mapController;
late SightController sight; late AimPointerController aimcontroller;
LocationData? locationData; LocationData? locationData;
late Pos3D pilerCenter; late Pos3D pilerCenter;
@ -30,31 +30,31 @@ class GnssController extends GetxController {
var _dy = 0.0; var _dy = 0.0;
Timer? timer; Timer? timer;
checkDistance() { checkDistance() {
if (DateTime.now().millisecondsSinceEpoch - sight.lastManualTapTime < if (DateTime.now().millisecondsSinceEpoch - aimcontroller.lastManualTapTime <
10000 || 30000 ||
DateTime.now().millisecondsSinceEpoch - sight.lastCloseTapTime < DateTime.now().millisecondsSinceEpoch - aimcontroller.lastCloseTapTime <
10000) { 30000) {
return; return;
} }
Offset pilerCenterPoint = Offset(device.x, device.y); Offset pilerCenterPoint = Offset(device.x, device.y);
if (sight.selectedPilePoint == null) { if (aimcontroller.selectedPilePoint == null) {
return; return;
} }
var offset = Offset(sight.selectedPilePoint!.x, sight.selectedPilePoint!.y); var offset = Offset(aimcontroller.selectedPilePoint!.x, aimcontroller.selectedPilePoint!.y);
if (mapController.calculateDistance(pilerCenterPoint, offset) < 0.9) { if (mapController.calculateDistance(pilerCenterPoint, offset) < 1.9) {
if (!sight.isCardVisible.value) { if (!aimcontroller.isCardVisible.value) {
print("距离小于1m"); print("距离小于1m");
sight.isCardVisible.value = true; aimcontroller.isCardVisible.value = true;
} else { } else {
return null; return null;
} }
} else { } else {
if (!sight.isCardVisible.value) { if (!aimcontroller.isCardVisible.value) {
print("距离大于1m"); print("距离大于1m");
return null; return null;
} else { } else {
sight.isCardVisible.value = false; aimcontroller.isCardVisible.value = false;
} }
} }
} }
@ -64,15 +64,15 @@ class GnssController extends GetxController {
super.onInit(); super.onInit();
mapController = Get.find<ScenceMapController>(); mapController = Get.find<ScenceMapController>();
sight = Get.find<SightController>(); aimcontroller = Get.find<AimPointerController>();
device = DeviceItem( device = DeviceItem(
name: 'GNSS', name: 'GNSS',
TID: 1001, TID: 1001,
type: 2, type: 2,
height: 3.0, height: 3.0,
width: 3.0, width: 3.0,
lat: 3790616.710, lat: 3790621.123,
lon: 577046.048, lon: 577052.547,
image: ['assets/images/pilerCar.png']); image: ['assets/images/pilerCar.png']);
mapController.addDevice(device); mapController.addDevice(device);
// pilerCenterPoint = PilerPointCalculate( // pilerCenterPoint = PilerPointCalculate(
@ -86,26 +86,26 @@ class GnssController extends GetxController {
// //
timer = Timer.periodic(Duration(seconds: 1), (Timer timer) { timer = Timer.periodic(Duration(seconds: 1), (Timer timer) {
// if (lastPilePoint != sight.selectedPilePoint) { if (lastPilePoint != aimcontroller.selectedPilePoint) {
// lastPilePoint = sight.selectedPilePoint; lastPilePoint = aimcontroller.selectedPilePoint;
// if (sight.selectedPilePoint != null) { if (aimcontroller.selectedPilePoint != null) {
// var dx = device.x - sight.selectedPilePoint!.x; var dx = device.x - aimcontroller.selectedPilePoint!.x;
// var dy = device.y - sight.selectedPilePoint!.y; var dy = device.y - aimcontroller.selectedPilePoint!.y;
// var distance = sqrt(dx * dx + dy * dy); var distance = sqrt(dx * dx + dy * dy);
// if (distance > 20) { if (distance > 20) {
// dx = (sight.selectedPilePoint!.x - device.x) / (distance / 20); dx = (aimcontroller.selectedPilePoint!.x - device.x) / (distance / 20);
// dy = (sight.selectedPilePoint!.y - device.y) / (distance / 20); dy = (aimcontroller.selectedPilePoint!.y - device.y) / (distance / 20);
// device.x = sight.selectedPilePoint!.x + dx; device.x = aimcontroller.selectedPilePoint!.x + dx;
// device.y = sight.selectedPilePoint!.y + dy; device.y = aimcontroller.selectedPilePoint!.y + dy;
// } }
// _dx = -dx / 50; _dx = -dx / 50;
// _dy = -dy / 50; _dy = -dy / 50;
// } }
// } }
// device.x += _dx; device.x += _dx;
// device.y += _dy; device.y += _dy;
device.x += 0.2; // device.x += 0.05;
device.y += 0.2; // device.y += 0.05;
device.rotation = device.rotation + pi / 180; // 0-360 device.rotation = device.rotation + pi / 180; // 0-360
device.update.value++; device.update.value++;
checkDistance(); checkDistance();

View File

@ -7,9 +7,8 @@ import 'package:get/get.dart';
import 'package:scence_map/controllers/controller.dart'; import 'package:scence_map/controllers/controller.dart';
import 'package:scence_map/controllers/plumController.dart'; import 'package:scence_map/controllers/plumController.dart';
import 'appbar.dart'; import 'appbar.dart';
import 'pages/aim_point/aimPointer.dart'; import 'pages/aim_point/aimpointController.dart';
import 'pages/history/history_record.dart'; import 'pages/history/history_record.dart';
import 'pages/pass_track/view.dart';
import 'pages/pile/pileNav/view.dart'; import 'pages/pile/pileNav/view.dart';
import 'pages/pile/rightDra/pileGenerate.dart'; import 'pages/pile/rightDra/pileGenerate.dart';
import 'pages/real/index.dart'; import 'pages/real/index.dart';
@ -24,7 +23,7 @@ void main() async {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); // SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); //
Get.put(ScenceMapController()); Get.put(ScenceMapController());
Get.put(PlumDataController()); Get.put(PlumDataController());
Get.put(SightController()); Get.put(AimPointerController());
Get.put(GnssController()); Get.put(GnssController());
Get.put(AntennaController()); Get.put(AntennaController());
LoginPrefs loginPrefs = LoginPrefs(); LoginPrefs loginPrefs = LoginPrefs();

View File

@ -1,239 +0,0 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:scence_map/controllers/controller.dart';
import 'package:scence_map/record_entity.dart';
import '../../service/pile/device_type.dart';
final ScenceMapController mapcontroller = Get.put(ScenceMapController());
//
class SightController extends GetxController {
var isNomal = true.obs;
//
var sightOffset = const Offset(3, 3).obs;
var sightOffsetInit = const Offset(0, 0).obs;
var sightInit = const Offset(0, 0).obs;
// var lastSightOffset = const Offset(0, 0).obs; //
var isCardVisible = false.obs; //
RecordEntity? selectedPilePoint;
var initDx = 0.0.obs;
var isFirst = true.obs;
var visualList = [].obs;
var plot = 2.0.obs;
var scale = 0.75.obs;
int lastManualTapTime = 0;
int lastCloseTapTime = 0;
reset() {
sightOffset.value = const Offset(3, 3);
sightOffsetInit.value = const Offset(0, 0);
sightInit.value = const Offset(0, 0);
initDx.value = 0.0;
update();
}
}
class SightView extends GetView<SightController> {
const SightView({super.key});
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
MediaQueryData mediaQueryData =
MediaQueryData.fromView(WidgetsBinding.instance.window); //
final orientation = mediaQueryData.orientation; //
final deviceType = getDeviceType(context);
double rectWidth = size.height / 2;
if (!controller.isNomal.value) {
rectWidth = size.width;
} else {
if (orientation == Orientation.landscape) {
rectWidth = size.width / 2;
if (deviceType == DeviceType.mobile) {
rectWidth = size.height - 5;
}
} else {
rectWidth = size.height / 2;
if (deviceType == DeviceType.mobile) {
rectWidth = size.width - 5;
}
}
}
bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
return Stack(
children: [
CustomPaint(
//
size: Size(rectWidth, rectWidth),
painter: DrawCicle(controller, 0, 0, isDarkMode),
)
],
);
}
}
class DrawCicle extends CustomPainter {
final SightController sight;
final double tiltX;
final double tiltY;
final bool isDarkMode;
DrawCicle(this.sight, this.tiltX, this.tiltY, this.isDarkMode);
final _paint = Paint(); //
Path path = Path();
List<IconData> icons = [
Icons.arrow_drop_up,
Icons.arrow_drop_down,
Icons.arrow_left,
Icons.arrow_right
];
List<Offset> iconOffset = [];
List<String> text = ["", "", "", ""]; //['前移', '后移', '左移', '右移'];
@override
void paint(Canvas canvas, size) {
_paint
..strokeWidth = 2
..style = PaintingStyle.stroke
..color = const Color.fromARGB(255, 183, 183, 162);
double rectWidth = (size.height / 2 - 5).roundToDouble();
if (!sight.isNomal.value) {
} else {}
path.moveTo(0, rectWidth + 5);
path.lineTo(size.height, rectWidth + 5);
path.moveTo(rectWidth + 5, 0);
path.lineTo(rectWidth + 5, size.height);
canvas.drawPath(path, _paint);
// 2m
double step = (rectWidth / sight.plot.value / 10).roundToDouble();
canvas.translate(rectWidth + 5, rectWidth + 5);
for (var i = 0; i < 21; i++) {
if (i % 10 == 0) {
double line = 7;
canvas.drawLine(Offset(0, i * step), Offset(line, i * step), _paint);
canvas.drawLine(Offset(i * step, 0), Offset(i * step, line), _paint);
canvas.drawLine(Offset(0, -i * step), Offset(line, -i * step), _paint);
canvas.drawLine(Offset(-i * step, 0), Offset(-i * step, line), _paint);
drawText(canvas, Offset(line, i * step), i ~/ 10);
drawText(canvas, Offset(line, -i * step), (-i ~/ 10));
if (i ~/ 10 != 0) {
drawText(canvas, Offset(i * step, line), i ~/ 10);
drawText(canvas, Offset(-i * step, line), (-i ~/ 10));
}
} else if (i % 5 == 0) {
double line = 5;
canvas.drawLine(Offset(0, i * step), Offset(line, i * step), _paint);
canvas.drawLine(Offset(i * step, 0), Offset(i * step, line), _paint);
canvas.drawLine(Offset(0, -i * step), Offset(line, -i * step), _paint);
canvas.drawLine(Offset(-i * step, 0), Offset(-i * step, line), _paint);
} else {
double line = 3;
canvas.drawLine(Offset(0, i * step), Offset(line, i * step), _paint);
canvas.drawLine(Offset(i * step, 0), Offset(i * step, line), _paint);
canvas.drawLine(Offset(0, -i * step), Offset(line, -i * step), _paint);
canvas.drawLine(Offset(-i * step, 0), Offset(-i * step, line), _paint);
}
}
canvas.translate(-(rectWidth + 5), -(rectWidth + 5));
canvas.translate(rectWidth + 5, rectWidth + 5);
if (sight.selectedPilePoint != null) {
drawPoint(canvas);
}
// //
// double x = real.tiltX.value; //
// double y = real.tiltY.value; //
// print("----${real.centerX.value},${real.centerY.value}");
// if (real.tiltX.value == 0 || real.tiltY.value == 0) {
// x = 0;
// y = 0;
// }
// _paint.color = Colors.red;
// canvas.drawCircle(Offset(x * step * 10, y * step * 10), 10, _paint);
// canvas.translate(-(rectWidth + 5), -(rectWidth + 5));
}
drawText(Canvas canvas, Offset offset, int i, [bool isShow = true]) {
TextPainter textPainter = TextPainter(
text: TextSpan(
text: isShow ? "$i m" : "$i",
style: TextStyle(
fontSize: 12, color: isDarkMode ? Colors.white : Colors.black)),
textDirection: TextDirection.ltr,
textAlign: TextAlign.left);
textPainter.layout();
textPainter.paint(canvas, offset);
}
drawPoint(Canvas canvas) {
canvas.drawCircle(Offset.zero, 20,
Paint()..color = const Color.fromARGB(255, 139, 33, 33));
// drawText(canvas, pos - const Offset(20, 10), i, false);
}
// drawRect(Canvas canvas, double rectWidth) {
// double x = item.dx - real.centerX.value;
// double y = item.dy - real.centerY.value;
// Offset center = Offset(x, y);
// canvas.drawRect(
// Rect.fromCenter(center: center, width: rectWidth, height: rectWidth),
// _paint);
// }
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}
class DevicePointer extends StatelessWidget {
// final DeviceItemController item;
// DevicePointer(this.item);
DevicePointer();
@override
Widget build(BuildContext context) {
// double carWidth = item.width / controller.pixel2MeterRatio;
// double carHeight = item.height / controller.pixel2MeterRatio;
return Stack(
alignment: Alignment.center,
children: [
SizedBox(
width: 60.0, //
height: 60.0, //
child: Image.asset(
"images/navi_pointer.png",
errorBuilder: (context, error, stackTrace) {
return Text('无法加载图片');
},
),
),
// Obx(() {
// Offset offset = controller.xy2Screen(
// gnsscontroller.pilerCenter.X, gnsscontroller.pilerCenter.Y);
// return Positioned(
// left: offset.dx,
// top: offset.dy,
// child: Transform(
// transform: Matrix4.identity()
// ..rotateZ(-controller.rotation.value),
// child: Column(
// children: [Text("设备:${item.name}")],
// ),
// ),
// );
// }),
],
);
}
}

View File

@ -0,0 +1,35 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:scence_map/record_entity.dart';
class AimPointerController extends GetxController {
var isNomal = true.obs;
//
var sightOffset = const Offset(3, 3).obs;
var sightOffsetInit = const Offset(0, 0).obs;
var sightInit = const Offset(0, 0).obs;
// var lastSightOffset = const Offset(0, 0).obs; //
var isCardVisible = false.obs; //
RecordEntity? selectedPilePoint;
var initDx = 0.0.obs;
var isFirst = true.obs;
var visualList = [].obs;
var plot = 2.0.obs;
var scale = 0.75.obs;
var cardWidth = 0.0.obs;
var left = 0.0.obs;
var top = 0.0.obs;
var positionUpdate = 0.obs;
int lastManualTapTime = 0;
int lastCloseTapTime = 0;
reset() {
sightOffset.value = const Offset(3, 3);
sightOffsetInit.value = const Offset(0, 0);
sightInit.value = const Offset(0, 0);
initDx.value = 0.0;
update();
}
}

View File

@ -2,40 +2,18 @@ import 'dart:async';
import 'dart:math'; import 'dart:math';
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:scence_map/controllers/controller.dart'; import 'package:scence_map/controllers/controller.dart';
import '../../controllers/gnss_Controller.dart'; import '../../controllers/gnss_Controller.dart';
import '../../service/pile/device_type.dart'; import '../../service/pile/device_type.dart';
import 'aimPointer.dart'; import 'aimpointController.dart';
final SightController sight = Get.put(SightController()); final AimPointerController aimcontroller = Get.put(AimPointerController());
final ScenceMapController mapcontroller = Get.put(ScenceMapController()); final ScenceMapController mapcontroller = Get.put(ScenceMapController());
final GnssController gnsscontroller = Get.put(GnssController()); final GnssController gnsscontroller = Get.put(GnssController());
class AimPointer extends StatefulWidget { class AimPointer extends GetView<AimPointerController> {
const AimPointer({super.key});
@override
State<AimPointer> createState() => _AimPointerState();
}
//CounterPointer StatefulWidget
// createState State
//createState _CounterPointerState() _CounterPointerState
// CounterPointer
class _AimPointerState extends State<AimPointer> {
// late final DeviceItemController item;
// late final double maprotation;
// late final Offset targetPoint;
@override
void initState() {
super.initState();
// map.disableMove.value = true;
// map.update();
}
String gradienter = "0"; // String gradienter = "0"; //
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -45,17 +23,9 @@ class _AimPointerState extends State<AimPointer> {
final orientation = mediaQueryData.orientation; // final orientation = mediaQueryData.orientation; //
bool isPortrait = Orientation.portrait == orientation ? true : false; bool isPortrait = Orientation.portrait == orientation ? true : false;
double rectWidth = size.width; double rectWidth = size.width;
final deviceType = getDeviceType(context); final deviceType = getDeviceType(context);
double left = 0.0;
double top = 0.0;
if (sight.selectedPilePoint != null) {
var dx = gnsscontroller.device.x - sight.selectedPilePoint!.x;
var dy = gnsscontroller.device.y - sight.selectedPilePoint!.y;
left = dx * cos(mapcontroller.rotation.value) +
dy * sin(mapcontroller.rotation.value);
top = -dx * sin(mapcontroller.rotation.value) +
dy * cos(mapcontroller.rotation.value);
}
if (orientation == Orientation.landscape) { if (orientation == Orientation.landscape) {
rectWidth = size.width / 2 - 60; rectWidth = size.width / 2 - 60;
if (deviceType == DeviceType.mobile) { if (deviceType == DeviceType.mobile) {
@ -73,8 +43,10 @@ class _AimPointerState extends State<AimPointer> {
width: rectWidth, width: rectWidth,
height: rectWidth, height: rectWidth,
child: Card( child: Card(
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
side: BorderSide(color: Colors.transparent, width: 0), side: BorderSide(color: Colors.transparent, width: 0),
borderRadius: BorderRadius.circular(4.0), // borderRadius: BorderRadius.circular(4.0), //
), ),
child: Stack( child: Stack(
@ -82,78 +54,141 @@ class _AimPointerState extends State<AimPointer> {
Container( Container(
width: rectWidth, width: rectWidth,
height: rectWidth, height: rectWidth,
clipBehavior: Clip.hardEdge, //
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(
color: isDarkMode ? Colors.white : Colors.black), color: isDarkMode ? Colors.white : Colors.black),
borderRadius: borderRadius:
BorderRadius.all(Radius.circular(rectWidth / 2)), BorderRadius.all(Radius.circular(rectWidth / 2)),
), ),
child: Obx(() { child: Stack(
return Transform( children: [
transform: Matrix4.identity() CustomPaint(
..rotateZ(mapcontroller.rotation.value), //
alignment: FractionalOffset.center, size: Size(rectWidth, rectWidth),
child: const SightView(), painter: DrawAxis(aimcontroller, 0, 0, isDarkMode),
); child: Stack(
})), children: [
Positioned( Positioned(
top: 0, top: 20,
left: 10, left: 20,
child: Obx(() { child: Obx(() {
return TextButton( return TextButton(
child: Text( child: Text(
"${sight.plot.value}m", "${aimcontroller.plot.value}m",
style: const TextStyle(fontSize: 20), style: const TextStyle(fontSize: 20),
), ),
onPressed: () { onPressed: () {
if (sight.plot.value == 1) { if (aimcontroller.plot.value == 1) {
sight.plot.value = 2; aimcontroller.plot.value = 2;
} else { } else {
sight.plot.value = 1; aimcontroller.plot.value = 1;
} }
sight.update(); aimcontroller.update();
}, },
); );
})), })),
Positioned( Positioned(
top: 25, top: 25,
right: 10, right: 10,
child: TextButton( child: TextButton(
child: Text( child: Text(
"垂直度:$gradienter°", "垂直度:$gradienter°",
style: const TextStyle(fontSize: 20), style: const TextStyle(fontSize: 20),
), ),
onPressed: () {}, onPressed: () {},
)), )),
Positioned( Positioned(
right: 0, right: 0,
top: 0, top: 0,
child: IconButton( child: IconButton(
icon: const Icon(Icons.close), icon: const Icon(Icons.close),
onPressed: () { onPressed: () {
// //
sight.isCardVisible.value = false; aimcontroller.isCardVisible.value = false;
sight.lastCloseTapTime = aimcontroller.lastCloseTapTime =
DateTime.now().millisecondsSinceEpoch; DateTime.now().millisecondsSinceEpoch;
}, },
), ),
), ),
if (sight.selectedPilePoint != null) Obx(() {
Positioned( var pixel2MeterRatio =
left: rectWidth / 2 + left / mapcontroller.pixel2MeterRatio, aimcontroller.plot.value * 2 / rectWidth;
top: rectWidth / 2 - top / mapcontroller.pixel2MeterRatio, if (aimcontroller.selectedPilePoint != null)
// left: 70, gnsscontroller.device.update.value;
// top: 70, if (aimcontroller.selectedPilePoint != null) {
child: Transform( var dx = (gnsscontroller.device.x -
transform: Matrix4.identity() aimcontroller.selectedPilePoint!.x);
..rotateZ(gnsscontroller.device.rotation + pi / 2), var dy = (gnsscontroller.device.y -
alignment: FractionalOffset.center, aimcontroller.selectedPilePoint!.y);
child: DevicePointer(),
)
// child: DevicePointer(), aimcontroller.top.value = dx *
) cos(mapcontroller.rotation.value) +
dy * sin(mapcontroller.rotation.value);
aimcontroller.left.value = -dx *
sin(mapcontroller.rotation.value) +
dy * cos(mapcontroller.rotation.value);
// aimcontroller.positionUpdate.value++;
print("dx:$dx,dy:$dy");
print(
"left:${aimcontroller.left.value},top:${aimcontroller.top.value}");
}
return Positioned(
left: rectWidth / 2 -
30 +
aimcontroller.left.value /
pixel2MeterRatio,
top: rectWidth / 2 -
30 -
aimcontroller.top.value /
pixel2MeterRatio,
// left: 70,
// top: 70,
child: Transform(
transform: Matrix4.identity()
..rotateZ(
gnsscontroller.device.rotation +
pi / 2 +
mapcontroller.rotation.value),
alignment: FractionalOffset.center,
child: Stack(
alignment: Alignment.center,
children: [
SizedBox(
width: 60.0, //
height: 60.0, //
child: Image.asset(
"images/navi_pointer.png",
errorBuilder: (context, error,
stackTrace) {
return Text('无法加载图片');
},
),
),
// Obx(() {
// Offset offset = controller.xy2Screen(
// gnsscontroller.pilerCenter.X, gnsscontroller.pilerCenter.Y);
// return Positioned(
// left: offset.dx,
// top: offset.dy,
// child: Transform(
// transform: Matrix4.identity()
// ..rotateZ(-controller.rotation.value),
// child: Column(
// children: [Text("设备:${item.name}")],
// ),
// ),
// );
// }),
],
)));
})
],
))
],
)),
], ],
), ),
), ),
@ -178,6 +213,124 @@ class _AimPointerState extends State<AimPointer> {
} }
} }
class DrawAxis extends CustomPainter {
final AimPointerController aimcontroller;
final double tiltX;
final double tiltY;
final bool isDarkMode;
DrawAxis(this.aimcontroller, this.tiltX, this.tiltY, this.isDarkMode);
final _paint = Paint(); //
Path path = Path();
List<IconData> icons = [
Icons.arrow_drop_up,
Icons.arrow_drop_down,
Icons.arrow_left,
Icons.arrow_right
];
List<Offset> iconOffset = [];
List<String> text = ["", "", "", ""]; //['前移', '后移', '左移', '右移'];
@override
void paint(Canvas canvas, size) {
_paint
..strokeWidth = 2
..style = PaintingStyle.stroke
..color = const Color.fromARGB(255, 183, 183, 162);
double rectWidth = (size.height / 2 - 5).roundToDouble();
aimcontroller.cardWidth.value = rectWidth;
if (!aimcontroller.isNomal.value) {
} else {}
path.moveTo(0, rectWidth + 5);
path.lineTo(size.height, rectWidth + 5);
path.moveTo(rectWidth + 5, 0);
path.lineTo(rectWidth + 5, size.height);
canvas.drawPath(path, _paint);
// 2m
double step = (rectWidth / aimcontroller.plot.value / 10).roundToDouble();
canvas.translate(rectWidth + 5, rectWidth + 5);
for (var i = 0; i < 21; i++) {
if (i % 10 == 0) {
double line = 7;
canvas.drawLine(Offset(0, i * step), Offset(line, i * step), _paint);
canvas.drawLine(Offset(i * step, 0), Offset(i * step, line), _paint);
canvas.drawLine(Offset(0, -i * step), Offset(line, -i * step), _paint);
canvas.drawLine(Offset(-i * step, 0), Offset(-i * step, line), _paint);
drawText(canvas, Offset(line, i * step), -i ~/ 10);
drawText(canvas, Offset(line, -i * step), (i ~/ 10));
if (i ~/ 10 != 0) {
drawText(canvas, Offset(i * step, line), i ~/ 10);
drawText(canvas, Offset(-i * step, line), (-i ~/ 10));
}
} else if (i % 5 == 0) {
double line = 5;
canvas.drawLine(Offset(0, i * step), Offset(line, i * step), _paint);
canvas.drawLine(Offset(i * step, 0), Offset(i * step, line), _paint);
canvas.drawLine(Offset(0, -i * step), Offset(line, -i * step), _paint);
canvas.drawLine(Offset(-i * step, 0), Offset(-i * step, line), _paint);
} else {
double line = 3;
canvas.drawLine(Offset(0, i * step), Offset(line, i * step), _paint);
canvas.drawLine(Offset(i * step, 0), Offset(i * step, line), _paint);
canvas.drawLine(Offset(0, -i * step), Offset(line, -i * step), _paint);
canvas.drawLine(Offset(-i * step, 0), Offset(-i * step, line), _paint);
}
}
canvas.translate(-(rectWidth + 5), -(rectWidth + 5));
canvas.translate(rectWidth + 5, rectWidth + 5);
if (aimcontroller.selectedPilePoint != null) {
drawPoint(canvas);
}
// //
// double x = real.tiltX.value; //
// double y = real.tiltY.value; //
// print("----${real.centerX.value},${real.centerY.value}");
// if (real.tiltX.value == 0 || real.tiltY.value == 0) {
// x = 0;
// y = 0;
// }
// _paint.color = Colors.red;
// canvas.drawCircle(Offset(x * step * 10, y * step * 10), 10, _paint);
// canvas.translate(-(rectWidth + 5), -(rectWidth + 5));
}
drawText(Canvas canvas, Offset offset, int i, [bool isShow = true]) {
TextPainter textPainter = TextPainter(
text: TextSpan(
text: isShow ? "$i m" : "$i",
style: TextStyle(
fontSize: 12, color: isDarkMode ? Colors.white : Colors.black)),
textDirection: TextDirection.ltr,
textAlign: TextAlign.left);
textPainter.layout();
textPainter.paint(canvas, offset);
}
drawPoint(Canvas canvas) {
canvas.drawCircle(Offset.zero, 20,
Paint()..color = const Color.fromARGB(255, 139, 33, 33));
// drawText(canvas, pos - const Offset(20, 10), i, false);
}
// drawRect(Canvas canvas, double rectWidth) {
// double x = item.dx - real.centerX.value;
// double y = item.dy - real.centerY.value;
// Offset center = Offset(x, y);
// canvas.drawRect(
// Rect.fromCenter(center: center, width: rectWidth, height: rectWidth),
// _paint);
// }
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}
// //
class SightGview extends StatelessWidget { class SightGview extends StatelessWidget {
const SightGview(); const SightGview();
@ -203,30 +356,31 @@ class SightGview extends StatelessWidget {
} }
return Obx(() => Visibility( return Obx(() => Visibility(
visible: sight.isCardVisible.value, visible: aimcontroller.isCardVisible.value,
child: Positioned( child: Positioned(
left: sight.sightOffset.value.dx, left: aimcontroller.sightOffset.value.dx,
top: sight.sightOffset.value.dy, top: aimcontroller.sightOffset.value.dy,
width: rectWidth + 15, width: rectWidth + 15,
height: rectWidth + 15, height: rectWidth + 15,
child: GestureDetector( child: GestureDetector(
onScaleStart: (details) { onScaleStart: (details) {
// //
sight.sightInit.value = aimcontroller.sightInit.value =
details.localFocalPoint - sight.sightOffset.value; details.localFocalPoint - aimcontroller.sightOffset.value;
// //
// //
// //
print('sight.isCardVisible: ${sight.isCardVisible.value}'); print(
'aimcontroller.isCardVisible: ${aimcontroller.isCardVisible.value}');
}, },
onScaleUpdate: (details) { onScaleUpdate: (details) {
// 使 // 使
sight.sightOffset.value = aimcontroller.sightOffset.value =
details.localFocalPoint - sight.sightInit.value; details.localFocalPoint - aimcontroller.sightInit.value;
}, },
child: Container( child: Container(
decoration: const BoxDecoration(color: Colors.transparent), decoration: const BoxDecoration(color: Colors.transparent),
child: const Stack(children: [ child: Stack(children: [
Card( Card(
color: Colors.transparent, color: Colors.transparent,
elevation: 5.0, elevation: 5.0,

View File

@ -1,7 +1,6 @@
// //
import 'package:bottom_picker/resources/arrays.dart'; import 'package:bottom_picker/resources/arrays.dart';
import 'package:cpnav/controllers/gnss_Controller.dart'; import 'package:cpnav/controllers/gnss_Controller.dart';
import 'package:cpnav/pages/aim_point/aimPointer.dart';
import 'package:cpnav/pages/aim_point/aimpoint_page.dart'; import 'package:cpnav/pages/aim_point/aimpoint_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
@ -13,6 +12,7 @@ import 'package:scence_map/record_entity.dart';
import 'package:scence_map/scence_map.dart'; import 'package:scence_map/scence_map.dart';
import 'package:syncfusion_flutter_sliders/sliders.dart'; import 'package:syncfusion_flutter_sliders/sliders.dart';
import '../aim_point/aimpointController.dart';
import '../real/realDataCard.dart'; import '../real/realDataCard.dart';
import 'iconContainer.dart'; import 'iconContainer.dart';
import "controller.dart"; import "controller.dart";
@ -42,7 +42,7 @@ class _PasstrackState extends State<PassTrack> {
final GlobalKey<PopupMenuButtonState<int>> _popupMenuKey = final GlobalKey<PopupMenuButtonState<int>> _popupMenuKey =
GlobalKey<PopupMenuButtonState<int>>(); GlobalKey<PopupMenuButtonState<int>>();
final controller = Get.put(PassTrackController("TEST", "pile_cm")); final controller = Get.put(PassTrackController("TEST", "pile_cm"));
final sightcontroller = Get.find<SightController>(); final aimcontroller = Get.find<AimPointerController>();
String str = "播放"; String str = "播放";
int sWidth = 0; int sWidth = 0;
int bits = -1; int bits = -1;
@ -122,7 +122,7 @@ class _PasstrackState extends State<PassTrack> {
print( print(
"selectedPilePoint:$selectedPilePoint scale:$scale rotation:$rotation"); "selectedPilePoint:$selectedPilePoint scale:$scale rotation:$rotation");
controller.selectedPilePoint = selectedPilePoint; controller.selectedPilePoint = selectedPilePoint;
sightcontroller.selectedPilePoint = selectedPilePoint; aimcontroller.selectedPilePoint = selectedPilePoint;
}, },
), ),
Positioned( Positioned(
@ -280,7 +280,6 @@ class _PasstrackState extends State<PassTrack> {
class BorderPainter extends CustomPainter { class BorderPainter extends CustomPainter {
final PassTrackController controller; final PassTrackController controller;
final GnssController gnsscontroller; final GnssController gnsscontroller;
// final SightController sight;
BorderPainter(this.controller) BorderPainter(this.controller)
: gnsscontroller = Get.find<GnssController>(), : gnsscontroller = Get.find<GnssController>(),
super(repaint: controller); super(repaint: controller);