卡片弹出
This commit is contained in:
parent
5d35f93de5
commit
569d7bb948
@ -1 +1 @@
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.10\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_linux","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"flutter_webrtc","dependencies":["path_provider"]},{"name":"libserialport","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2024-08-27 18:06:29.957598","version":"3.24.0","swift_package_manager_enabled":false}
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.10\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_linux","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"flutter_webrtc","dependencies":["path_provider"]},{"name":"libserialport","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2024-08-28 17:53:45.700498","version":"3.24.0","swift_package_manager_enabled":false}
|
@ -2,12 +2,14 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:scence_map/controllers/controller.dart';
|
||||
|
||||
import 'pages/aim_point/aimPointer.dart';
|
||||
|
||||
// import '../login_in/connect/bluetooth_page.dart';
|
||||
// import '../login_in/connect/connect_type.dart';
|
||||
// import '../login_in/getx/real_data.dart';
|
||||
// import 'main.dart';
|
||||
|
||||
final ScenceMapController mapcontroller = Get.find();
|
||||
final SightController sightcontroller = Get.find();
|
||||
|
||||
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final double appBarHeight;
|
||||
@ -88,13 +90,13 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
() => InkWell(
|
||||
onTap: () {
|
||||
// 点击图标时显示对点卡片
|
||||
mapcontroller.isCardVisible.value =
|
||||
!mapcontroller.isCardVisible.value; // 确保控制器已定义
|
||||
sightcontroller.isCardVisible.value =
|
||||
!sightcontroller.isCardVisible.value; // 确保控制器已定义
|
||||
},
|
||||
child: Icon(
|
||||
Icons.my_location_sharp,
|
||||
size: 35,
|
||||
color: mapcontroller.isCardVisible.value
|
||||
color: sightcontroller.isCardVisible.value
|
||||
? Colors.blue
|
||||
// : const Color.fromARGB(200, 29, 28, 28),
|
||||
: (isDarkMode.value
|
||||
|
@ -1,14 +1,19 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
import 'package:cpnav/pages/pass_track/controller.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:gnss/gnss.dart';
|
||||
import 'package:scence_map/controllers/controller.dart';
|
||||
|
||||
import '../models/pilePoint/coord_trans.dart';
|
||||
import '../pages/aim_point/aimPointer.dart';
|
||||
|
||||
class GnssController extends GetxController {
|
||||
late final Gnss gnss;
|
||||
late ScenceMapController mapController;
|
||||
late SightController sight;
|
||||
|
||||
LocationData? locationData;
|
||||
late Pos3D pilerCenter;
|
||||
late DeviceItem device;
|
||||
@ -20,11 +25,35 @@ class GnssController extends GetxController {
|
||||
var offsetangle = 0.0.obs; //主副连线与车身夹角
|
||||
late final CoordTrans coordTrans;
|
||||
Timer? timer;
|
||||
checkDistance() {
|
||||
Offset pilerCenterPoint = Offset(device.x, device.y);
|
||||
if (sight.selectedPilePoint == null) {
|
||||
return;
|
||||
}
|
||||
var offset = Offset(sight.selectedPilePoint!.x, sight.selectedPilePoint!.y);
|
||||
if (mapController.calculateDistance(pilerCenterPoint, offset) < 0.9) {
|
||||
if (!sight.isCardVisible.value) {
|
||||
print("距离小于1m");
|
||||
sight.isCardVisible.value = true;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!sight.isCardVisible.value) {
|
||||
print("距离大于1m");
|
||||
return null;
|
||||
} else {
|
||||
sight.isCardVisible.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
mapController = Get.find<ScenceMapController>();
|
||||
|
||||
sight = Get.find<SightController>();
|
||||
device = DeviceItem(
|
||||
name: 'GNSS',
|
||||
TID: 1001,
|
||||
@ -50,6 +79,7 @@ class GnssController extends GetxController {
|
||||
device.y += 0.2;
|
||||
device.rotation = device.rotation + pi / 180; // 确保旋转角度在0-360度之间
|
||||
device.update.value++;
|
||||
checkDistance();
|
||||
});
|
||||
|
||||
gnss = Gnss(port: "/dev/ttysWK2", baudrate: 115200);
|
||||
@ -64,7 +94,7 @@ class GnssController extends GetxController {
|
||||
// location.pitch, location.baseLength, offsetangle.value);
|
||||
// print(
|
||||
// 'X: ${pilerCenter.X}, Y: ${pilerCenter.Y}, Rotation: ${pilerCenter.rotation}');
|
||||
|
||||
// CheckDistance();
|
||||
locationUpdate.value++;
|
||||
});
|
||||
|
||||
|
@ -5,7 +5,7 @@ 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/pass_track/view.dart';
|
||||
import 'pages/pile/pileNav/view.dart';
|
||||
import 'pages/pile/rightDra/pileGenerate.dart';
|
||||
@ -15,6 +15,8 @@ void main() {
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); //设置全屏
|
||||
Get.put(ScenceMapController());
|
||||
Get.put(PlumDataController());
|
||||
|
||||
Get.put(SightController());
|
||||
Get.put(GnssController());
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
@ -1,56 +0,0 @@
|
||||
import 'package:cpnav/pages/pass_track/view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'aimPointer.dart';
|
||||
|
||||
final SightController controller = Get.put(SightController());
|
||||
|
||||
class SightGview extends GetView<SightController> {
|
||||
const SightGview({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Size size = MediaQuery.of(context).size;
|
||||
|
||||
return Obx(() => Positioned(
|
||||
left: controller.sightOffset.value.dx,
|
||||
top: controller.sightOffset.value.dy,
|
||||
width: size.width / 5 * 1.5,
|
||||
height: size.width / 5 * 1.5,
|
||||
child: GestureDetector(
|
||||
onScaleStart: (details) {
|
||||
// 正确计算初始偏移量:当前手指位置与卡片当前位置之间的差值
|
||||
controller.sightInit.value =
|
||||
details.localFocalPoint - controller.sightOffset.value;
|
||||
},
|
||||
onScaleUpdate: (details) {
|
||||
// 使用初始偏移量来更新卡片的位置
|
||||
controller.sightOffset.value =
|
||||
details.localFocalPoint - controller.sightInit.value;
|
||||
},
|
||||
child: Visibility(
|
||||
visible: mapcontroller.isCardVisible.value, // 控制可见性
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(color: Colors.transparent),
|
||||
child: Stack(children: [
|
||||
const Card(
|
||||
elevation: 5.0,
|
||||
child: SightView(),
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
top: 0,
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () {
|
||||
// 关闭按钮的回调函数
|
||||
mapcontroller.isCardVisible.value = false;
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
)))));
|
||||
}
|
||||
}
|
@ -2,22 +2,23 @@ import 'package:cpnav/pages/real_data/realController.dart';
|
||||
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 'package:scence_map/scence_map.dart';
|
||||
|
||||
import '../../service/pile/device_type.dart';
|
||||
|
||||
final RealController realcontroller = Get.put(RealController());
|
||||
final ScenceMapController mapcontroller = Get.put(ScenceMapController());
|
||||
|
||||
// 对点 瞄准器
|
||||
class SightController extends GetxController {
|
||||
final mapcontroller = Get.put(ScenceMapController());
|
||||
|
||||
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 lastSightOffset = const Offset(0, 0).obs; // 新增变量,用于存储上一次手指离开时的位置
|
||||
var isCardVisible = false.obs; // 控制卡片是否可见
|
||||
RecordEntity? selectedPilePoint;
|
||||
|
||||
var initDx = 0.0.obs;
|
||||
var isFirst = true.obs;
|
||||
@ -63,27 +64,25 @@ class SightView extends GetView<SightController> {
|
||||
|
||||
bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return Obx(() {
|
||||
return Stack(
|
||||
children: [
|
||||
CustomPaint(
|
||||
//绘制瞄准器
|
||||
size: Size(rectWidth, rectWidth),
|
||||
painter: DrawCicle(controller, realcontroller.centerX.value,
|
||||
realcontroller.centerX.value, isDarkMode),
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
return Stack(
|
||||
children: [
|
||||
CustomPaint(
|
||||
//绘制瞄准器
|
||||
size: Size(rectWidth, rectWidth),
|
||||
painter: DrawCicle(controller, 0, 0, isDarkMode),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DrawCicle extends CustomPainter {
|
||||
final SightController controller;
|
||||
final SightController sight;
|
||||
final double tiltX;
|
||||
final double tiltY;
|
||||
final bool isDarkMode;
|
||||
DrawCicle(this.controller, this.tiltX, this.tiltY, this.isDarkMode);
|
||||
|
||||
DrawCicle(this.sight, this.tiltX, this.tiltY, this.isDarkMode);
|
||||
final _paint = Paint(); //创建一个画笔并配置其属性
|
||||
Path path = Path();
|
||||
|
||||
@ -104,7 +103,7 @@ class DrawCicle extends CustomPainter {
|
||||
..color = const Color.fromARGB(255, 183, 183, 162);
|
||||
|
||||
double rectWidth = (size.height / 2 - 5).roundToDouble();
|
||||
if (!controller.isNomal.value) {
|
||||
if (!sight.isNomal.value) {
|
||||
} else {}
|
||||
|
||||
path.moveTo(0, rectWidth + 5);
|
||||
@ -113,7 +112,7 @@ class DrawCicle extends CustomPainter {
|
||||
path.lineTo(rectWidth + 5, size.height);
|
||||
canvas.drawPath(path, _paint);
|
||||
// 总长 2m
|
||||
double step = (rectWidth / controller.plot.value / 10).roundToDouble();
|
||||
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) {
|
||||
@ -145,22 +144,21 @@ class DrawCicle extends CustomPainter {
|
||||
canvas.translate(-(rectWidth + 5), -(rectWidth + 5));
|
||||
|
||||
canvas.translate(rectWidth + 5, rectWidth + 5);
|
||||
// if (controller.visualList.isNotEmpty) {
|
||||
drawPoint(canvas, step);
|
||||
// if (sight.selectedRecord.value != Offset(2, 2)) {
|
||||
// drawPoint(canvas);
|
||||
// }
|
||||
|
||||
// 绘制水平仪
|
||||
double x = realcontroller.tiltX.value; //
|
||||
double y = realcontroller.tiltY.value; //
|
||||
print(
|
||||
"----${realcontroller.centerX.value},${realcontroller.centerY.value}");
|
||||
if (realcontroller.tiltX.value == 0 || realcontroller.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));
|
||||
// // 绘制水平仪
|
||||
// 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]) {
|
||||
@ -176,38 +174,65 @@ class DrawCicle extends CustomPainter {
|
||||
textPainter.paint(canvas, offset);
|
||||
}
|
||||
|
||||
// drawPoint(Canvas canvas, double step) {
|
||||
// // bug 绘制前应该旋转一定的角度
|
||||
|
||||
// // 设置当前施工点为中心,显示可视范围的点
|
||||
// for (int i = 0; i < plumDataController.plumList.length; i++) {
|
||||
// Offset item = plumDataController.plumList[i];
|
||||
// double x = item.dx - realController.centerX.value;
|
||||
// double y = item.dy - realController.centerY.value;
|
||||
// // 纵向方向是相反
|
||||
|
||||
// Offset pos = Offset(x, y) * step * 10;
|
||||
// canvas.drawCircle(pos, 20, Paint()..color = Colors.grey);
|
||||
// drawText(canvas, pos - const Offset(20, 10), i, false);
|
||||
// }
|
||||
// }
|
||||
|
||||
drawPoint(Canvas canvas, double step) {
|
||||
// bug 绘制前应该旋转一定的角度
|
||||
|
||||
// 设置当前施工点为中心,显示可视范围的点
|
||||
for (int i = 0; i < plumDataController.plumList.length; i++) {
|
||||
Offset item = plumDataController.plumList[i];
|
||||
double x = item.dx - realcontroller.centerX.value;
|
||||
double y = item.dy - realcontroller.centerY.value;
|
||||
// 纵向方向是相反
|
||||
|
||||
Offset pos = Offset(x, y) * step * 10;
|
||||
canvas.drawCircle(pos, 20, Paint()..color = Colors.grey);
|
||||
drawText(canvas, pos - const Offset(20, 10), i, false);
|
||||
}
|
||||
drawPoint(Canvas canvas) {
|
||||
canvas.drawCircle(Offset.zero, 20, Paint()..color = Colors.grey);
|
||||
// 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}")],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
225
lib/pages/aim_point/aimpoint_page.dart
Normal file
225
lib/pages/aim_point/aimpoint_page.dart
Normal file
@ -0,0 +1,225 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:cpnav/appbar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:scence_map/scence_map.dart';
|
||||
|
||||
import '../../service/pile/device_type.dart';
|
||||
import 'aimPointer.dart';
|
||||
|
||||
final SightController sight = Get.put(SightController());
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
String gradienter = "0"; //水平仪
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Size size = MediaQuery.of(context).size;
|
||||
MediaQueryData mediaQueryData =
|
||||
MediaQueryData.fromView(WidgetsBinding.instance.window); //获取当前屏幕信息
|
||||
final orientation = mediaQueryData.orientation; //获得设备方向
|
||||
bool isPortrait = Orientation.portrait == orientation ? true : false;
|
||||
double rectWidth = size.width;
|
||||
final deviceType = getDeviceType(context);
|
||||
|
||||
// var dx = item.x - targetPoint.dx;
|
||||
// var dy = item.y - targetPoint.dy;
|
||||
// var left = dx * cos(maprotation) + dy * sin(maprotation);
|
||||
// var top = -dx * sin(maprotation) + dy * cos(maprotation);
|
||||
if (orientation == Orientation.landscape) {
|
||||
rectWidth = size.width / 2 - 60;
|
||||
if (deviceType == DeviceType.mobile) {
|
||||
rectWidth = size.height - 130;
|
||||
}
|
||||
} else {
|
||||
rectWidth = size.height / 2;
|
||||
if (deviceType == DeviceType.mobile) {
|
||||
rectWidth = size.width - 5;
|
||||
}
|
||||
}
|
||||
bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
||||
List<Widget> children = [
|
||||
SizedBox(
|
||||
width: rectWidth,
|
||||
height: rectWidth,
|
||||
child: Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(color: Colors.transparent, width: 0),
|
||||
borderRadius: BorderRadius.circular(4.0), // 可以根据需要调整圆角半径
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
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: 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;
|
||||
},
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
// left: rectWidth / 2 + left / mapcontroller.pixel2MeterRatio,
|
||||
// top: rectWidth / 2 - top / mapcontroller.pixel2MeterRatio,
|
||||
left: 70,
|
||||
top: 70,
|
||||
// child: Obx(() {
|
||||
// return Transform(
|
||||
// // transform: Matrix4.identity()..rotateZ(item.rotation.value),
|
||||
// transform: Matrix4.identity()..rotateZ(0),
|
||||
// alignment: FractionalOffset.center,
|
||||
// child: DevicePointer(item),
|
||||
// );
|
||||
// }),
|
||||
|
||||
child: DevicePointer(),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 5,
|
||||
height: 5,
|
||||
),
|
||||
const Expanded(
|
||||
child: Text(""),
|
||||
),
|
||||
];
|
||||
if (isPortrait) {
|
||||
return Column(
|
||||
children: children,
|
||||
);
|
||||
} else {
|
||||
return Row(
|
||||
children: children,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 瞄准器卡片
|
||||
class SightGview extends StatelessWidget {
|
||||
const SightGview();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Size size = MediaQuery.of(context).size;
|
||||
MediaQueryData mediaQueryData =
|
||||
MediaQueryData.fromView(WidgetsBinding.instance.window); //获取当前屏幕信息
|
||||
final orientation = mediaQueryData.orientation; //获得设备方向
|
||||
double rectWidth = size.width;
|
||||
final deviceType = getDeviceType(context);
|
||||
if (orientation == Orientation.landscape) {
|
||||
rectWidth = size.width / 2 - 60;
|
||||
if (deviceType == DeviceType.mobile) {
|
||||
rectWidth = size.height - 130;
|
||||
}
|
||||
} else {
|
||||
rectWidth = size.height / 2;
|
||||
if (deviceType == DeviceType.mobile) {
|
||||
rectWidth = size.width - 5;
|
||||
}
|
||||
}
|
||||
|
||||
return Obx(() => Visibility(
|
||||
visible: sight.isCardVisible.value,
|
||||
child: Positioned(
|
||||
left: sight.sightOffset.value.dx,
|
||||
top: sight.sightOffset.value.dy,
|
||||
width: rectWidth + 15,
|
||||
height: rectWidth + 15,
|
||||
child: GestureDetector(
|
||||
onScaleStart: (details) {
|
||||
// 正确计算初始偏移量:当前手指位置与卡片当前位置之间的差值
|
||||
sight.sightInit.value =
|
||||
details.localFocalPoint - sight.sightOffset.value;
|
||||
//
|
||||
//
|
||||
//
|
||||
print('sight.isCardVisible: ${sight.isCardVisible.value}');
|
||||
},
|
||||
onScaleUpdate: (details) {
|
||||
// 使用初始偏移量来更新卡片的位置
|
||||
sight.sightOffset.value =
|
||||
details.localFocalPoint - sight.sightInit.value;
|
||||
},
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(color: Colors.transparent),
|
||||
child: const Stack(children: [
|
||||
Card(
|
||||
color: Colors.transparent,
|
||||
elevation: 5.0,
|
||||
child: AimPointer(),
|
||||
),
|
||||
]))))));
|
||||
}
|
||||
}
|
@ -4,14 +4,13 @@ import 'package:cpnav/service/base.dart';
|
||||
import 'package:scence_map/controllers/controller.dart';
|
||||
import 'package:scence_map/record_entity.dart';
|
||||
|
||||
|
||||
class PassTrackController extends GetxController {
|
||||
final mapController = Get.put(ScenceMapController());
|
||||
|
||||
String projCode;
|
||||
String projType;
|
||||
late final GetServices service;
|
||||
|
||||
RecordEntity? selectedPilePoint;
|
||||
PassTrackController(this.projCode, this.projType);
|
||||
|
||||
@override
|
||||
|
@ -1,16 +1,18 @@
|
||||
//字体
|
||||
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';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:scence_map/controllers/controller.dart';
|
||||
import 'package:scence_map/record_entity.dart';
|
||||
import 'package:scence_map/scence_map.dart';
|
||||
|
||||
import 'package:syncfusion_flutter_sliders/sliders.dart';
|
||||
import '../../controllers/gnss_Controller.dart';
|
||||
import '../aim_point/aimCard.dart';
|
||||
|
||||
import 'iconContainer.dart';
|
||||
import "controller.dart";
|
||||
|
||||
@ -24,7 +26,6 @@ import "controller.dart";
|
||||
// import '../setting/xy_change.dart';
|
||||
|
||||
ScenceMapController mapcontroller = Get.put(ScenceMapController());
|
||||
GnssController gnsscontroller = Get.find<GnssController>();
|
||||
|
||||
class PassTrack extends StatefulWidget {
|
||||
final String date;
|
||||
@ -40,6 +41,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>();
|
||||
String str = "播放";
|
||||
int sWidth = 0;
|
||||
int bits = -1;
|
||||
@ -113,6 +115,14 @@ class _PasstrackState extends State<PassTrack> {
|
||||
onUpdate: (Offset center, double scale, double rotation) {
|
||||
print("center:$center scale:$scale rotation:$rotation");
|
||||
},
|
||||
forGroundPainter: BorderPainter(controller),
|
||||
onUpdatePilePoint: (RecordEntity? selectedPilePoint, double scale,
|
||||
double rotation) {
|
||||
print(
|
||||
"selectedPilePoint:$selectedPilePoint scale:$scale rotation:$rotation");
|
||||
controller.selectedPilePoint = selectedPilePoint;
|
||||
sightcontroller.selectedPilePoint = selectedPilePoint;
|
||||
},
|
||||
),
|
||||
Positioned(
|
||||
width: isPortrait ? size.width * .63 : size.width * .41,
|
||||
@ -254,9 +264,141 @@ class _PasstrackState extends State<PassTrack> {
|
||||
),
|
||||
),
|
||||
IconContainer(),
|
||||
SightGview()
|
||||
SightGview(),
|
||||
// CustomPaint(
|
||||
// painter: BorderPainter(controller),
|
||||
// ),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 自定义的 BorderPainter
|
||||
class BorderPainter extends CustomPainter {
|
||||
final PassTrackController controller;
|
||||
final GnssController gnsscontroller;
|
||||
// final SightController sight;
|
||||
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;
|
||||
if (controller.selectedPilePoint != null) {
|
||||
var offset = Offset(
|
||||
controller.selectedPilePoint!.x, controller.selectedPilePoint!.y);
|
||||
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;
|
||||
}
|
||||
|
||||
// 左上角
|
||||
canvas.drawLine(
|
||||
rect.topLeft, rect.topLeft + Offset(cornerLength, 0), paint);
|
||||
canvas.drawLine(
|
||||
rect.topLeft, rect.topLeft + Offset(0, cornerLength), paint);
|
||||
|
||||
// 右上角
|
||||
canvas.drawLine(
|
||||
rect.topRight, rect.topRight + Offset(-cornerLength, 0), paint);
|
||||
canvas.drawLine(
|
||||
rect.topRight, rect.topRight + Offset(0, cornerLength), paint);
|
||||
|
||||
// 左下角
|
||||
canvas.drawLine(
|
||||
rect.bottomLeft, rect.bottomLeft + Offset(cornerLength, 0), paint);
|
||||
canvas.drawLine(
|
||||
rect.bottomLeft, rect.bottomLeft + Offset(0, -cornerLength), paint);
|
||||
|
||||
// 右下角
|
||||
canvas.drawLine(
|
||||
rect.bottomRight, rect.bottomRight + Offset(-cornerLength, 0), paint);
|
||||
canvas.drawLine(
|
||||
rect.bottomRight, rect.bottomRight + Offset(0, -cornerLength), paint);
|
||||
|
||||
Offset center = Offset(gnsscontroller.device.x, gnsscontroller.device.y);
|
||||
Offset pilerCenter = mapcontroller.xy2Screen0(center);
|
||||
//绘制虚线
|
||||
if (mapcontroller.deviceList.isNotEmpty) {
|
||||
Paint dashedPaint = Paint()
|
||||
..color = Colors.red
|
||||
..strokeWidth = 3.5;
|
||||
var offset = Offset(
|
||||
controller.selectedPilePoint!.x, controller.selectedPilePoint!.y);
|
||||
Offset screenPos = mapcontroller.xy2Screen0(offset);
|
||||
|
||||
drawDashedLine(canvas, pilerCenter, screenPos, dashedPaint);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
// if (!controller.isCardVisible.value) {
|
||||
// if (controller.calculateDistance(pilerCenterPoint, offset) < 0.9) {
|
||||
// print("距离小于1m");
|
||||
// controller.isCardVisible.value = !controller.isCardVisible.value;
|
||||
// } else {
|
||||
// print("距离大于1m");
|
||||
// }
|
||||
// } else {
|
||||
// if (controller.calculateDistance(pilerCenterPoint, offset) > 1.1) {
|
||||
// print("距离大于1m");
|
||||
// controller.isCardVisible.value = controller.isCardVisible.value;
|
||||
// } else {
|
||||
// print("距禽小于1m");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user