fix: light zoom at back
This commit is contained in:
@@ -28,6 +28,7 @@ import 'widgets/grouping_stats.dart';
|
|||||||
|
|
||||||
class AnalysisScreen extends StatelessWidget {
|
class AnalysisScreen extends StatelessWidget {
|
||||||
final String imagePath;
|
final String imagePath;
|
||||||
|
final String? originalImagePath; // AJOUT : image source avant le crop à 85%
|
||||||
final TargetType targetType;
|
final TargetType targetType;
|
||||||
final double? initialCenterX;
|
final double? initialCenterX;
|
||||||
final double? initialCenterY;
|
final double? initialCenterY;
|
||||||
@@ -38,6 +39,7 @@ class AnalysisScreen extends StatelessWidget {
|
|||||||
const AnalysisScreen({
|
const AnalysisScreen({
|
||||||
super.key,
|
super.key,
|
||||||
required this.imagePath,
|
required this.imagePath,
|
||||||
|
this.originalImagePath, // AJOUT
|
||||||
required this.targetType,
|
required this.targetType,
|
||||||
this.initialCenterX,
|
this.initialCenterX,
|
||||||
this.initialCenterY,
|
this.initialCenterY,
|
||||||
@@ -75,6 +77,7 @@ class AnalysisScreen extends StatelessWidget {
|
|||||||
return p;
|
return p;
|
||||||
},
|
},
|
||||||
child: _AnalysisScreenContent(
|
child: _AnalysisScreenContent(
|
||||||
|
originalImagePath: originalImagePath, // AJOUT
|
||||||
cropScale: cropScale,
|
cropScale: cropScale,
|
||||||
cropOffset: cropOffset,
|
cropOffset: cropOffset,
|
||||||
cropRotation: cropRotation, // Envoyé à la structure d'affichage
|
cropRotation: cropRotation, // Envoyé à la structure d'affichage
|
||||||
@@ -84,11 +87,13 @@ class AnalysisScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _AnalysisScreenContent extends StatefulWidget {
|
class _AnalysisScreenContent extends StatefulWidget {
|
||||||
|
final String? originalImagePath; // AJOUT
|
||||||
final double? cropScale;
|
final double? cropScale;
|
||||||
final Offset? cropOffset;
|
final Offset? cropOffset;
|
||||||
final double? cropRotation;
|
final double? cropRotation;
|
||||||
|
|
||||||
const _AnalysisScreenContent({
|
const _AnalysisScreenContent({
|
||||||
|
this.originalImagePath, // AJOUT
|
||||||
this.cropScale,
|
this.cropScale,
|
||||||
this.cropOffset,
|
this.cropOffset,
|
||||||
this.cropRotation,
|
this.cropRotation,
|
||||||
@@ -155,15 +160,24 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
|||||||
///
|
///
|
||||||
/// Sans cette remise à zéro, le facteur de zoom accumulé en mode Plotting
|
/// Sans cette remise à zéro, le facteur de zoom accumulé en mode Plotting
|
||||||
/// persiste dans le TransformationController et se réapplique au retour,
|
/// persiste dans le TransformationController et se réapplique au retour,
|
||||||
/// ce qui faisait "zoomer" légèrement la photo à chaque aller-retour
|
/// ce qui faisait "zoomer" légèrement la photo. On repart donc toujours
|
||||||
/// Plotting <-> Centrage. On repart donc toujours d'une transformation
|
/// d'une transformation identité (zoom 1.0).
|
||||||
/// identité (zoom 1.0).
|
|
||||||
void _enterCalibration() {
|
void _enterCalibration() {
|
||||||
_transformationController.value = Matrix4.identity();
|
_transformationController.value = Matrix4.identity();
|
||||||
_currentZoomScale = 1.0;
|
_currentZoomScale = 1.0;
|
||||||
setState(() => _isCalibrating = true);
|
setState(() => _isCalibrating = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Chemin à utiliser pour repartir dans le CropScreen lors d'un retour arrière.
|
||||||
|
///
|
||||||
|
/// On privilégie TOUJOURS l'image source non rognée (originalImagePath).
|
||||||
|
/// Repartir de l'image déjà croppée à 85% provoquait un rognage cumulatif
|
||||||
|
/// (0.85 x 0.85 x ...) qui re-zoomait la photo à chaque aller-retour
|
||||||
|
/// entre la capture/crop et la calibration.
|
||||||
|
String _backCropImagePath(AnalysisProvider provider) {
|
||||||
|
return widget.originalImagePath ?? provider.imagePath!;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final provider = context.watch<AnalysisProvider>();
|
final provider = context.watch<AnalysisProvider>();
|
||||||
@@ -189,7 +203,9 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
|||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => CropScreen(
|
builder: (context) => CropScreen(
|
||||||
imagePath: provider.imagePath!,
|
// CORRECTION : on repart de l'image SOURCE (non rognée) pour
|
||||||
|
// éviter le rognage cumulatif à 85% qui re-zoomait à chaque retour.
|
||||||
|
imagePath: _backCropImagePath(provider),
|
||||||
targetType: provider.targetType!,
|
targetType: provider.targetType!,
|
||||||
initialScale: widget.cropScale,
|
initialScale: widget.cropScale,
|
||||||
initialOffset: widget.cropOffset,
|
initialOffset: widget.cropOffset,
|
||||||
@@ -722,7 +738,8 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
final path = provider.imagePath!;
|
// CORRECTION : on repart aussi de l'image SOURCE non rognée ici.
|
||||||
|
final path = _backCropImagePath(provider);
|
||||||
final type = provider.targetType!;
|
final type = provider.targetType!;
|
||||||
|
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
|
|||||||
@@ -419,6 +419,10 @@ class _CropScreenState extends State<CropScreen> {
|
|||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (_) => AnalysisScreen(
|
builder: (_) => AnalysisScreen(
|
||||||
imagePath: croppedImagePath,
|
imagePath: croppedImagePath,
|
||||||
|
// AJOUT : on conserve la SOURCE non rognée pour les retours arrière.
|
||||||
|
// Sans cela, revenir au crop repartait de l'image déjà rognée à 85%,
|
||||||
|
// provoquant un zoom cumulatif (0.85 x 0.85 x ...) à chaque aller-retour.
|
||||||
|
originalImagePath: widget.imagePath,
|
||||||
targetType: widget.targetType,
|
targetType: widget.targetType,
|
||||||
initialCenterX: targetCenterX,
|
initialCenterX: targetCenterX,
|
||||||
initialCenterY: targetCenterY,
|
initialCenterY: targetCenterY,
|
||||||
|
|||||||
Reference in New Issue
Block a user