11import 'dart:math' ;
22import 'dart:typed_data' ;
3+ import 'dart:ui' ;
34
45import 'package:flutter/gestures.dart' ;
56import 'package:flutter/material.dart' ;
@@ -616,46 +617,45 @@ class FieldWidget extends NTWidget {
616617 Offset fittedCenter = fittedSizes.destination.toOffset / 2 ;
617618 Offset fieldCenter = model.field.center;
618619 return Stack (
620+
619621 children: [
622+ //line going towards robot when off-screen
620623 IgnorePointer (
621- ignoring: true ,
622- child: InteractiveViewer (
623- transformationController: controller,
624- clipBehavior: Clip .none,
625- child: ListenableBuilder (
626- listenable: Listenable .merge (listeners),
627- builder: (context, child) => Transform .scale (
628- scale: rotatedScaleReduction / scaleReduction,
629- child: Transform .rotate (
630- angle: radians (model.fieldRotation),
631- child: Stack (
632- children: [
633- CustomPaint (
634- size: fittedSizes.destination,
635- painter: RobotLinePainter (
636- fittedCenter: fittedSizes.destination,
637- size: size,
638- color: model.robotColor.withAlpha (150 ),
639- robotPosition: _getTrajectoryPointOffset (
640- model,
641- x: _robotX,
642- y: _robotY,
643- fieldCenter: fieldCenter,
644- scaleReduction: scaleReduction,
645- ),
646- strokeWidth:
647- model.trajectoryPointSize *
648- model.field.pixelsPerMeterHorizontal *
649- scaleReduction,
624+ child: ListenableBuilder (
625+ listenable: Listenable .merge (listeners),
626+ builder: (context, child) => Transform .scale (
627+ scale: rotatedScaleReduction / scaleReduction,
628+ child: Transform .rotate (
629+ angle: radians (model.fieldRotation),
630+ child: Stack (
631+ children: [
632+ CustomPaint (
633+ size: fittedSizes.destination,
634+ painter: RobotLinePainter (
635+ fittedCenter: fittedSizes.destination,
636+ size: size,
637+ color: model.robotColor.withAlpha (150 ),
638+ transform: controller.value,
639+ robotPosition: _getTrajectoryPointOffset (
640+ model,
641+ x: _robotX,
642+ y: _robotY,
643+ fieldCenter: fieldCenter,
644+ scaleReduction: scaleReduction,
650645 ),
646+ strokeWidth:
647+ model.trajectoryPointSize *
648+ model.field.pixelsPerMeterHorizontal *
649+ scaleReduction,
651650 ),
652- ] ,
653- ) ,
651+ ) ,
652+ ] ,
654653 ),
655654 ),
656655 ),
657656 ),
658657 ),
658+ //pannable field widget
659659 InteractiveViewer (
660660 transformationController: controller,
661661 constrained: true ,
@@ -685,6 +685,7 @@ class FieldWidget extends NTWidget {
685685 ),
686686 ),
687687 ),
688+ //robot, trajectories overlay
688689 IgnorePointer (
689690 ignoring: true ,
690691 child: InteractiveViewer (
@@ -956,6 +957,7 @@ class FieldWidget extends NTWidget {
956957 ),
957958 ),
958959 ),
960+
959961 ],
960962 );
961963 },
@@ -1043,6 +1045,7 @@ class RobotLinePainter extends CustomPainter {
10431045 final Color color;
10441046 final Size fittedCenter;
10451047 final Size size;
1048+ final Matrix4 transform;
10461049 Offset robotPosition;
10471050
10481051 RobotLinePainter ({
@@ -1051,6 +1054,7 @@ class RobotLinePainter extends CustomPainter {
10511054 required this .color,
10521055 required this .fittedCenter,
10531056 required this .size,
1057+ required this .transform
10541058 });
10551059
10561060 @override
@@ -1065,13 +1069,17 @@ class RobotLinePainter extends CustomPainter {
10651069 robotPosition.dx + (size.width / 2 ),
10661070 robotPosition.dy + (size.height / 2 ),
10671071 );
1072+ Offset start = Offset (
1073+ size.width / 2 ,
1074+ size.height / 2
1075+ );
10681076
10691077 drawDashedLine (
10701078 canvas: canvas,
1071- p1: size.toOffset / 2 ,
1072- p2: robotPos,
1073- dashWidth: 10 ,
1074- dashSpace: 15 ,
1079+ p1: start ,
1080+ p2: MatrixUtils . transformPoint (transform, robotPos) ,
1081+ dashWidth: 5 ,
1082+ dashSpace: 10 ,
10751083 paint: linePaint,
10761084 );
10771085 }
0 commit comments