This commit is contained in:
Holy 2024-09-10 08:41:48 +08:00
parent 27ce92e6ee
commit 261d77afa0
7 changed files with 211 additions and 130 deletions

85
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,85 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "cpnav",
"request": "launch",
"type": "dart"
},
{
"name": "cpnav (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "cpnav (release mode)",
"request": "launch",
"type": "dart",
"flutterMode": "release"
},
{
"name": "pass_track",
"cwd": "plugins\\pass_track",
"request": "launch",
"type": "dart"
},
{
"name": "pass_track (profile mode)",
"cwd": "plugins\\pass_track",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "pass_track (release mode)",
"cwd": "plugins\\pass_track",
"request": "launch",
"type": "dart",
"flutterMode": "release"
},
{
"name": "scence_map",
"cwd": "plugins\\scence_map",
"request": "launch",
"type": "dart"
},
{
"name": "scence_map (profile mode)",
"cwd": "plugins\\scence_map",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "scence_map (release mode)",
"cwd": "plugins\\scence_map",
"request": "launch",
"type": "dart",
"flutterMode": "release"
},
{
"name": "example",
"cwd": "plugins\\pass_track\\example",
"request": "launch",
"type": "dart"
},
{
"name": "example (profile mode)",
"cwd": "plugins\\pass_track\\example",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "example (release mode)",
"cwd": "plugins\\pass_track\\example",
"request": "launch",
"type": "dart",
"flutterMode": "release"
}
]
}

View File

@ -68,7 +68,7 @@ class _MyHomePageState extends State<MyHomePage> {
final _currentIndex = 0.obs;
final List<Widget> _pages = [
PassTrackWidget(
PassTrackView(
date: '',
),
Container(

View File

@ -1,13 +1,11 @@
import 'dart:ui';
import 'package:get/get.dart';
import 'package:scence_map/controller.dart';
import 'package:cpnav/service/base.dart';
import 'package:pass_track/pass_track.dart';
import 'sevice/file_handle.dart';
FileHandle fileHandle = FileHandle();
class PassTrackController extends GetxController {
@ -16,6 +14,7 @@ class PassTrackController extends GetxController {
String projCode;
String projType;
var speed = 1.obs;
late final GetServices service;
// final PassTrack _passTrackPlugin;
PassTrackController(this.projCode, this.projType);

View File

@ -62,7 +62,7 @@ class _IconContainerState extends State<IconContainer> {
decoration: BoxDecoration(
color: Colors.transparent,
border: Border.all(
color: Color.fromARGB(255, 54, 52, 52),
color: const Color.fromARGB(255, 54, 52, 52),
width: 1.0,
),
borderRadius: BorderRadius.circular(5.0),
@ -134,7 +134,7 @@ class _IconContainerState extends State<IconContainer> {
decoration: BoxDecoration(
color: Colors.transparent,
border: Border.all(
color: Color.fromARGB(255, 54, 52, 52),
color: const Color.fromARGB(255, 54, 52, 52),
width: 1.0,
),
borderRadius: BorderRadius.circular(5.0),
@ -206,7 +206,7 @@ class _IconContainerState extends State<IconContainer> {
return Container(
width: 33,
height: 33,
margin: EdgeInsets.symmetric(vertical: 2.0),
margin: const EdgeInsets.symmetric(vertical: 2.0),
decoration: BoxDecoration(
color: _iconColors[icon],
border: Border.all(
@ -229,7 +229,7 @@ class _IconContainerState extends State<IconContainer> {
return Container(
width: 33,
height: 33,
margin: EdgeInsets.symmetric(vertical: 2.0),
margin: const EdgeInsets.symmetric(vertical: 2.0),
decoration: BoxDecoration(
color: _iconColors[icon],
border: Border.all(

View File

@ -15,6 +15,7 @@ import "package:pass_track/pass_track.dart";
import "package:pass_track/pass_track_platform_interface.dart";
import "controller.dart";
import "dart:ffi" as ffi;
// import '../login_in/connect/bluetooth_page.dart';
// import '../login_in/connect/config.dart';
// import '../login_in/connect/connect_type.dart';
@ -26,131 +27,126 @@ import "dart:ffi" as ffi;
ScenceMapController mapcontroller = Get.put(ScenceMapController());
class PassTrackWidget extends StatefulWidget {
final String date;
final controller;
const PassTrackWidget({super.key, required this.date, this.controller});
@override
State<PassTrackWidget> createState() => _PasstrackState();
}
class _PasstrackState extends State<PassTrackWidget> {
class PassTrackView extends GetView<PassTrackController> {
final GlobalKey<PopupMenuButtonState<int>> _popupMenuKey =
GlobalKey<PopupMenuButtonState<int>>();
final controller = Get.put(PassTrackController("WXLMB", "cp_road"));
String str = "播放";
int sWidth = 800;
int sHeight = 800;
int bits = -1;
int speed = 50;
List<int> speedList = [1, 2, 10, 20, 50, 100, 200, 500];
// final controller = Get.put(PassTrackController("WXLMB", "cp_road"));
final String str = "播放";
// int sWidth = 800;
// int sHeight = 800;
// int bits = -1;
// int speed = 50;
// int maxLength = 200;
late SfRangeValues _rangevalues;
// late SfRangeValues _rangevalues;
final PassTrack _passTrackPlugin = PassTrack();
@override
initState() {
super.initState();
var maxLen =
controller.allLen > 0 ? controller.allLen : 1.0; // maxLen 0
_rangevalues = SfRangeValues(0.0, maxLen);
SchedulerBinding.instance.addPostFrameCallback((_) async {
// sWidth = sqrt(screen.width * screen.width + screen.height * screen.height)
// .ceil();
PassTrackView({Key? key}) : super(key: key);
// // scenceMapController.scale = passTrackPlugin.passTrack_getScale() * 1.0;
// fileHandle.date = widget.date;
// await fileHandle.init();
// //
// // await initPlatformState();
// if (fileHandle.pointData.isNotEmpty) {
// DecodeDataObj obj = fileHandle.pointData[0].obj!;
// scenceMapController.centerXY = Offset(obj.y / 20, obj.x / 20);
// }
// @override
// initState() {
// super.initState();
// var maxLen =
// controller.allLen > 0 ? controller.allLen : 1.0; // maxLen 0
// _rangevalues = SfRangeValues(0.0, maxLen);
// SchedulerBinding.instance.addPostFrameCallback((_) async {
// sWidth = sqrt(screen.width * screen.width + screen.height * screen.height)
// .ceil();
// for (var item in fileHandle.deviceList) {
// if (item["point"] != null) {
// bits = item["bits"];
// break;
// }
// }
// // passTrackPlugin.map_setCenterDevice(bits);
// setState(() {
// if (fileHandle.pointData.isNotEmpty) {
// maxLength = fileHandle.pointData.length;
// // _value = maxLength;
// _rangevalues = SfRangeValues(0.0, maxLength.toDouble());
// }
// });
});
var f = initPlatformState();
var future = controller.getHisFileList(_passTrackPlugin);
f.then((void _) {
_passTrackPlugin.setGridColor(const Color.fromARGB(255, 0, 0, 0).value);
_passTrackPlugin.drawGrid();
// // scenceMapController.scale = passTrackPlugin.passTrack_getScale() * 1.0;
// fileHandle.date = widget.date;
// await fileHandle.init();
// //
// // await initPlatformState();
// if (fileHandle.pointData.isNotEmpty) {
// DecodeDataObj obj = fileHandle.pointData[0].obj!;
// scenceMapController.centerXY = Offset(obj.y / 20, obj.x / 20);
// }
future.then((value) {
_passTrackPlugin.setScale(1);
for (var TID in controller.deviceMap.keys) {
_passTrackPlugin.addDevice(int.parse(TID), 0);
}
for (var item in controller.coorTransMap.entries) {
print("tid:${item.key} value:${item.value}");
}
//
var start = DateTime.now().millisecondsSinceEpoch;
// _passTrackPlugin.generateTile(0, value);
_passTrackPlugin.waitForTile(() {
var start = DateTime.now().millisecondsSinceEpoch;
print("len: ${_passTrackPlugin.allTileCnt()}");
_rangevalues = SfRangeValues(0, _passTrackPlugin.allTileCnt());
_passTrackPlugin.playTrack(0, _passTrackPlugin.allTileCnt(), true, 0, ffi.nullptr);
var end = DateTime.now().millisecondsSinceEpoch;
print("play: ${end - start}");
});
// _passTrackPlugin.drawGrid();
//
});
});
}
// for (var item in fileHandle.deviceList) {
// if (item["point"] != null) {
// bits = item["bits"];
// break;
// }
// }
// // passTrackPlugin.map_setCenterDevice(bits);
// setState(() {
// if (fileHandle.pointData.isNotEmpty) {
// maxLength = fileHandle.pointData.length;
// // _value = maxLength;
// _rangevalues = SfRangeValues(0.0, maxLength.toDouble());
// }
// });
// });
// var f = initPlatformState();
// var future = controller.getHisFileList(_passTrackPlugin);
// f.then((void _) {
// _passTrackPlugin.setGridColor(const Color.fromARGB(255, 0, 0, 0).value);
// _passTrackPlugin.drawGrid();
Future<void> initPlatformState() async {
String platformVersion;
try {
platformVersion = await _passTrackPlugin.getPlatformVersion() ??
'Unknown platform version';
} on Exception {
platformVersion = 'Failed to get platform version.';
}
await _passTrackPlugin.create(sWidth, sWidth);
fileHandle.textureId = await _passTrackPlugin.getTextureId() ?? -1;
print("textureId: ${fileHandle.textureId}");
// future.then((value) {
// _passTrackPlugin.setScale(1);
// for (var TID in controller.deviceMap.keys) {
// _passTrackPlugin.addDevice(int.parse(TID), 0);
// }
// for (var item in controller.coorTransMap.entries) {
// print("tid:${item.key} value:${item.value}");
// }
// //
// var start = DateTime.now().millisecondsSinceEpoch;
// // _passTrackPlugin.generateTile(0, value);
// _passTrackPlugin.waitForTile(() {
// var start = DateTime.now().millisecondsSinceEpoch;
// print("len: ${_passTrackPlugin.allTileCnt()}");
// _rangevalues = SfRangeValues(0, _passTrackPlugin.allTileCnt());
// _passTrackPlugin.playTrack(
// 0, _passTrackPlugin.allTileCnt(), true, 0, ffi.nullptr);
// var end = DateTime.now().millisecondsSinceEpoch;
// print("play: ${end - start}");
// });
// // _passTrackPlugin.drawGrid();
// //
// });
// });
// }
if (!mounted) Exception('Failed to get textureId.');
// Future<void> initPlatformState() async {
// String platformVersion;
// try {
// platformVersion = await _passTrackPlugin.getPlatformVersion() ??
// 'Unknown platform version';
// } on Exception {
// platformVersion = 'Failed to get platform version.';
// }
// await _passTrackPlugin.create(
// mapcontroller.height.toInt(), mapcontroller.width.toInt());
// fileHandle.textureId = await _passTrackPlugin.getTextureId() ?? -1;
// print("textureId: ${fileHandle.textureId}");
setState(() {
platformVersion = platformVersion;
});
return;
}
// if (!mounted) Exception('Failed to get textureId.');
// setState(() {
// platformVersion = platformVersion;
// });
// return;
// }
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
var isPortrait = MediaQuery.of(context).orientation == Orientation.portrait;
var controller = this.controller;
return OrientationBuilder(builder: (context, orientation) {
return Stack(
children: [
ScenceMapView(
children: [
Positioned(
top: 0,
left: 0,
top: mapcontroller.top,
left: mapcontroller.left,
child: SizedBox(
width: sWidth * 1.0,
height: sWidth * 1.0,
width: mapcontroller.width,
height: mapcontroller.height,
// child: Text('Running on: $_platformVersion\n'),
child: Texture(textureId: fileHandle.textureId))),
],
@ -177,10 +173,10 @@ class _PasstrackState extends State<PassTrackWidget> {
minorTicksPerInterval: 1,
stepSize: 1,
onChanged: (SfRangeValues values) {
setState(() {
_rangevalues = SfRangeValues(values.start.roundToDouble(),
values.end.roundToDouble());
});
// setState(() {
// _rangevalues = SfRangeValues(values.start.roundToDouble(),
// values.end.roundToDouble());
// });
},
),
),
@ -195,20 +191,20 @@ class _PasstrackState extends State<PassTrackWidget> {
width: 74,
child: ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color?>(
backgroundColor: WidgetStateProperty.all<Color?>(
str == "播放" ? Colors.blue : Colors.red,
),
),
onPressed: () {
if (str == "播放") {
_passTrackPlugin.playTrack(0, 10000, true, 50, ffi.nullptr);
_passTrackPlugin.playTrack(
0, 10000, true, 50, ffi.nullptr);
} else {
_passTrackPlugin.playPause();
}
setState(() {
str = str == "播放" ? "暂停" : "播放";
});
// setState(() {
// str = str == "播放" ? "暂停" : "播放";
// });
},
child: Text(
str,
@ -234,12 +230,14 @@ class _PasstrackState extends State<PassTrackWidget> {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"$speed X",
style: const TextStyle(
fontSize: 11, color: Colors.black),
Obx(
() => Text(
"${controller.speed.value} X",
style: const TextStyle(
fontSize: 11, color: Colors.black),
),
),
Container(
SizedBox(
width: 25,
child: PopupMenuButton<int>(
key: _popupMenuKey,
@ -247,9 +245,7 @@ class _PasstrackState extends State<PassTrackWidget> {
icon: const Icon(Icons.arrow_drop_up,
color: Color.fromARGB(255, 47, 48, 47)),
onSelected: (int value) {
setState(() {
speed = value;
});
controller.speed.value = value;
},
// style: ButtonStyle(
// minimumSize: MaterialStateProperty.all<Size>(
@ -262,7 +258,8 @@ class _PasstrackState extends State<PassTrackWidget> {
return PopupMenuItem<int>(
height: 30,
value: speed,
child: Text("$speed X速度"),
child: Obx(() =>
Text("${controller.speed.value} X速度")),
);
}).toList();
},

@ -1 +1 @@
Subproject commit 1318d54e5901967be53f6ceba0825df45df9d167
Subproject commit 65de63acc0c565de548b02b15be6554b24ebad11

@ -1 +1 @@
Subproject commit 2eaf69b52fb3965a920202f878a8416a164d6e15
Subproject commit ac2179219ba52d0c91dfd51470fd1d7ebaae69be