fix(analysis): normaliser les coordonnées de la cible pour annuler l'effet du zoom initial
This commit is contained in:
@@ -162,8 +162,10 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
return;
|
||||
}
|
||||
|
||||
// CORRECTION PARALLÈLE : Changement de la méthode pour l'Isolate asynchrone
|
||||
final result = await _detectionService.detectTargetAsync(imagePath, targetType);
|
||||
final result = await _detectionService.detectTargetAsync(
|
||||
imagePath,
|
||||
targetType,
|
||||
);
|
||||
|
||||
if (!result.success) {
|
||||
_state = AnalysisState.error;
|
||||
@@ -512,11 +514,14 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
double radius, {
|
||||
int? ringCount,
|
||||
List<double>? ringRadii,
|
||||
double zoomScale = 1.0,
|
||||
Offset offset = Offset.zero,
|
||||
}) {
|
||||
_targetCenterX = centerX;
|
||||
_targetCenterY = centerY;
|
||||
_targetInnerRadius = innerRadius;
|
||||
_targetRadius = radius;
|
||||
_targetCenterX = (centerX - offset.dx) / zoomScale;
|
||||
_targetCenterY = (centerY - offset.dy) / zoomScale;
|
||||
_targetRadius = radius / zoomScale;
|
||||
_targetInnerRadius = innerRadius / zoomScale;
|
||||
|
||||
if (ringCount != null) {
|
||||
_ringCount = ringCount;
|
||||
}
|
||||
@@ -720,14 +725,14 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
return success;
|
||||
}
|
||||
|
||||
/// Save the session (Refactorisé pour appliquer le paramètre de date personnalisé)
|
||||
/// Save the session
|
||||
Future<TargetAnalysis> saveSession({
|
||||
String? notes,
|
||||
String? sessionId,
|
||||
String? weaponName,
|
||||
String? weaponId,
|
||||
int? distance,
|
||||
DateTime? date, // <-- REÇOIT PROPREMENT LA DATE DE DEBUT DE SESSION
|
||||
DateTime? date,
|
||||
}) async {
|
||||
if (_imagePath == null || _targetType == null) {
|
||||
throw Exception('Cannot save: missing image or target type');
|
||||
@@ -751,7 +756,10 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
if (sessionId != null && sessionId != 'standalone') {
|
||||
final existingSession = await _sessionRepository.getSession(sessionId);
|
||||
if (existingSession != null) {
|
||||
await _sessionRepository.addAnalysisToSession(sessionId, targetAnalysis);
|
||||
await _sessionRepository.addAnalysisToSession(
|
||||
sessionId,
|
||||
targetAnalysis,
|
||||
);
|
||||
} else {
|
||||
// CORRECTION : Utilise la date injectée plutôt que DateTime.now()
|
||||
await _sessionRepository.createSession(
|
||||
@@ -788,7 +796,7 @@ class AnalysisProvider extends ChangeNotifier {
|
||||
_errorMessage = null;
|
||||
_imagePath = null;
|
||||
_targetType = null;
|
||||
_cropRotation = 0.0; // Reset de la rotation
|
||||
_cropRotation = 0.0;
|
||||
_targetCenterX = 0.5;
|
||||
_targetCenterY = 0.5;
|
||||
_targetRadius = 0.4;
|
||||
|
||||
Reference in New Issue
Block a user