This commit is contained in:
tanlinxing 2024-09-10 14:15:52 +08:00
parent 7f6e0bd0c7
commit 90bb63a532
4 changed files with 130 additions and 34 deletions

View File

@ -1,4 +1,5 @@
import 'package:cpnav/appbar.dart';
import 'package:cpnav/pages/pass_track/controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
@ -8,7 +9,7 @@ import 'pages/pass_track/view.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); //
Get.put(PassTrackController('WXLMB', 'cp_road'));
runApp(const MyApp());
}
@ -69,7 +70,7 @@ class _MyHomePageState extends State<MyHomePage> {
final _currentIndex = 0.obs;
final List<Widget> _pages = [
PassTrackView(
date: '',
// date: '',
),
Container(
color: Colors.green,

View File

@ -1,5 +1,5 @@
import 'dart:ui';
import "dart:ffi" as ffi;
import 'package:get/get.dart';
import 'package:scence_map/controller.dart';
import 'package:cpnav/service/base.dart';
@ -7,19 +7,24 @@ import 'package:pass_track/pass_track.dart';
import 'sevice/file_handle.dart';
FileHandle fileHandle = FileHandle();
ScenceMapController mapcontroller = Get.put(ScenceMapController());
class PassTrackController extends GetxController {
int allLen = 0;
var tileCount = 0.obs;
var tileFirst = 0.obs;
var tileLast = 0.obs;
final mapController = Get.put(ScenceMapController());
String projCode;
String projType;
var speed = 1.obs;
late final GetServices service;
// final PassTrack _passTrackPlugin;
PassTrackController(this.projCode, this.projType);
Map<String, int> deviceMap = {};
Map<String, int> coorTransMap = {};
// final PassTrack _passTrackPlugin;
final PassTrack _passTrackPlugin = PassTrack();
@override
void onInit() {
super.onInit();
@ -28,6 +33,72 @@ class PassTrackController extends GetxController {
// loadSideLine();
loadBindDevice();
// getHisFileList();
var future = getHisFileList(_passTrackPlugin);
// 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();
// // 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);
// }
// 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();
f.then((void _) {
_passTrackPlugin.setGridColor(const Color.fromARGB(255, 0, 0, 0).value);
_passTrackPlugin.drawGrid();
future.then((value) {
_passTrackPlugin.setScale(1);
for (var TID in deviceMap.keys) {
_passTrackPlugin.addDevice(int.parse(TID), 0);
}
for (var item in 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()}");
tileCount.value = _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();
//
});
});
}
loadBindDevice() async {
@ -89,12 +160,34 @@ class PassTrackController extends GetxController {
var jsData = await GetServices().getHisFil1(file);
print("have message");
int len = fileHandle.resolveJson(jsData, passTrackPlugin);
allLen += len;
if (allLen >= 20000) {
tileCount.value += len;
if (tileCount.value >= 20000) {
break;
}
}
coorTransMap = fileHandle.pointsMap;
return allLen;
return tileCount.value;
}
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(600, 600);
// mapcontroller.height.toInt(), mapcontroller.width.toInt());
fileHandle.textureId = await _passTrackPlugin.getTextureId() ?? -1;
print("textureId: ${fileHandle.textureId}");
print("${mapcontroller.height.toInt()}");
// if (!mounted) Exception('Failed to get textureId.');
// setState(() {
// platformVersion = platformVersion;
// });
return;
}
}

View File

@ -141,6 +141,12 @@ class PassTrackView extends GetView<PassTrackController> {
children: [
ScenceMapView(
children: [
],
onUpdate: (Offset center, double scale, double rotation) {
print("center:$center scale:$scale rotation:$rotation");
},
),
Positioned(
top: mapcontroller.top,
left: mapcontroller.left,
@ -149,38 +155,34 @@ class PassTrackView extends GetView<PassTrackController> {
height: mapcontroller.height,
// child: Text('Running on: $_platformVersion\n'),
child: Texture(textureId: fileHandle.textureId))),
],
onUpdate: (Offset center, double scale, double rotation) {
print("center:$center scale:$scale rotation:$rotation");
},
),
Positioned(
width: isPortrait ? size.width * .63 : size.width * .41,
left: isPortrait ? 190 : 200,
bottom: 30,
child: Container(
padding: const EdgeInsets.only(bottom: 5),
child: SfRangeSlider(
child: Obx(
() => SfRangeSlider(
min: 0.0,
// max: maxLength,
max: controller.allLen > 0
? controller.allLen
max: controller.tileCount.value > 0
? controller.tileCount.value
: 1.0, // max 0
values: _rangevalues,
values: SfRangeValues(
controller.tileFirst.value, controller.tileLast.value),
showTicks: false,
showLabels: false,
enableTooltip: true,
minorTicksPerInterval: 1,
stepSize: 1,
onChanged: (SfRangeValues values) {
// setState(() {
// _rangevalues = SfRangeValues(values.start.roundToDouble(),
// values.end.roundToDouble());
// });
controller.tileFirst.value = values.start.toInt();
controller.tileLast.value = values.end.toInt();
},
),
),
),
),
Positioned(
left: isPortrait ? 190 : 200,
bottom: 0,

@ -1 +1 @@
Subproject commit 65de63acc0c565de548b02b15be6554b24ebad11
Subproject commit ad96316e993e3bbb2ca2b5b360b2fb5b6a50f0d2