设备移动

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

View File

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

View File

@ -7,9 +7,8 @@ import 'package:get/get.dart';
import 'package:scence_map/controllers/controller.dart';
import 'package:scence_map/controllers/plumController.dart';
import 'appbar.dart';
import 'pages/aim_point/aimPointer.dart';
import 'pages/aim_point/aimpointController.dart';
import 'pages/history/history_record.dart';
import 'pages/pass_track/view.dart';
import 'pages/pile/pileNav/view.dart';
import 'pages/pile/rightDra/pileGenerate.dart';
import 'pages/real/index.dart';
@ -24,7 +23,7 @@ void main() async {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); //
Get.put(ScenceMapController());
Get.put(PlumDataController());
Get.put(SightController());
Get.put(AimPointerController());
Get.put(GnssController());
Get.put(AntennaController());
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:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:get/get.dart';
import 'package:scence_map/controllers/controller.dart';
import '../../controllers/gnss_Controller.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 GnssController gnsscontroller = Get.put(GnssController());
class AimPointer extends StatefulWidget {
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();
}
class AimPointer extends GetView<AimPointerController> {
String gradienter = "0"; //
@override
Widget build(BuildContext context) {
@ -45,17 +23,9 @@ class _AimPointerState extends State<AimPointer> {
final orientation = mediaQueryData.orientation; //
bool isPortrait = Orientation.portrait == orientation ? true : false;
double rectWidth = size.width;
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) {
rectWidth = size.width / 2 - 60;
if (deviceType == DeviceType.mobile) {
@ -73,8 +43,10 @@ class _AimPointerState extends State<AimPointer> {
width: rectWidth,
height: rectWidth,
child: Card(
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
side: BorderSide(color: Colors.transparent, width: 0),
borderRadius: BorderRadius.circular(4.0), //
),
child: Stack(
@ -82,78 +54,141 @@ class _AimPointerState extends State<AimPointer> {
Container(
width: rectWidth,
height: rectWidth,
clipBehavior: Clip.hardEdge, //
decoration: BoxDecoration(
border: Border.all(
color: isDarkMode ? Colors.white : Colors.black),
borderRadius:
BorderRadius.all(Radius.circular(rectWidth / 2)),
),
child: Obx(() {
return Transform(
transform: Matrix4.identity()
..rotateZ(mapcontroller.rotation.value),
alignment: FractionalOffset.center,
child: const SightView(),
);
})),
Positioned(
top: 0,
left: 10,
child: Obx(() {
return TextButton(
child: Text(
"${sight.plot.value}m",
style: const TextStyle(fontSize: 20),
),
onPressed: () {
if (sight.plot.value == 1) {
sight.plot.value = 2;
} else {
sight.plot.value = 1;
}
sight.update();
},
);
})),
Positioned(
top: 25,
right: 10,
child: TextButton(
child: Text(
"垂直度:$gradienter°",
style: const TextStyle(fontSize: 20),
),
onPressed: () {},
)),
Positioned(
right: 0,
top: 0,
child: IconButton(
icon: const Icon(Icons.close),
onPressed: () {
//
sight.isCardVisible.value = false;
sight.lastCloseTapTime =
DateTime.now().millisecondsSinceEpoch;
},
),
),
if (sight.selectedPilePoint != null)
Positioned(
left: rectWidth / 2 + left / mapcontroller.pixel2MeterRatio,
top: rectWidth / 2 - top / mapcontroller.pixel2MeterRatio,
// left: 70,
// top: 70,
child: Transform(
transform: Matrix4.identity()
..rotateZ(gnsscontroller.device.rotation + pi / 2),
alignment: FractionalOffset.center,
child: DevicePointer(),
)
child: Stack(
children: [
CustomPaint(
//
size: Size(rectWidth, rectWidth),
painter: DrawAxis(aimcontroller, 0, 0, isDarkMode),
child: Stack(
children: [
Positioned(
top: 20,
left: 20,
child: Obx(() {
return TextButton(
child: Text(
"${aimcontroller.plot.value}m",
style: const TextStyle(fontSize: 20),
),
onPressed: () {
if (aimcontroller.plot.value == 1) {
aimcontroller.plot.value = 2;
} else {
aimcontroller.plot.value = 1;
}
aimcontroller.update();
},
);
})),
Positioned(
top: 25,
right: 10,
child: TextButton(
child: Text(
"垂直度:$gradienter°",
style: const TextStyle(fontSize: 20),
),
onPressed: () {},
)),
Positioned(
right: 0,
top: 0,
child: IconButton(
icon: const Icon(Icons.close),
onPressed: () {
//
aimcontroller.isCardVisible.value = false;
aimcontroller.lastCloseTapTime =
DateTime.now().millisecondsSinceEpoch;
},
),
),
Obx(() {
var pixel2MeterRatio =
aimcontroller.plot.value * 2 / rectWidth;
if (aimcontroller.selectedPilePoint != null)
gnsscontroller.device.update.value;
if (aimcontroller.selectedPilePoint != null) {
var dx = (gnsscontroller.device.x -
aimcontroller.selectedPilePoint!.x);
var dy = (gnsscontroller.device.y -
aimcontroller.selectedPilePoint!.y);
// 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 {
const SightGview();
@ -203,30 +356,31 @@ class SightGview extends StatelessWidget {
}
return Obx(() => Visibility(
visible: sight.isCardVisible.value,
visible: aimcontroller.isCardVisible.value,
child: Positioned(
left: sight.sightOffset.value.dx,
top: sight.sightOffset.value.dy,
left: aimcontroller.sightOffset.value.dx,
top: aimcontroller.sightOffset.value.dy,
width: rectWidth + 15,
height: rectWidth + 15,
child: GestureDetector(
onScaleStart: (details) {
//
sight.sightInit.value =
details.localFocalPoint - sight.sightOffset.value;
aimcontroller.sightInit.value =
details.localFocalPoint - aimcontroller.sightOffset.value;
//
//
//
print('sight.isCardVisible: ${sight.isCardVisible.value}');
print(
'aimcontroller.isCardVisible: ${aimcontroller.isCardVisible.value}');
},
onScaleUpdate: (details) {
// 使
sight.sightOffset.value =
details.localFocalPoint - sight.sightInit.value;
aimcontroller.sightOffset.value =
details.localFocalPoint - aimcontroller.sightInit.value;
},
child: Container(
decoration: const BoxDecoration(color: Colors.transparent),
child: const Stack(children: [
child: Stack(children: [
Card(
color: Colors.transparent,
elevation: 5.0,

View File

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