refactor(tactical-app): modernize state management with GetX controllers, bindings, and clean MVP architecture
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import 'package:get/get.dart';
|
||||
import '../models/landmark.dart';
|
||||
import '../services/resection_calculator.dart';
|
||||
|
||||
/// ============================================================================
|
||||
/// [ResectionController] - وحدة التحكم بالتقاطع البصري العكسي (GPS-Denied Fix)
|
||||
/// ============================================================================
|
||||
/// English:
|
||||
/// GetX Controller managing camera-based optical resection observations,
|
||||
/// magnetic azimuth readings, and inverse triangulation coordinate resolution.
|
||||
///
|
||||
/// العربية:
|
||||
/// متحكم GetX لإدارة عملية التقاطع البصري العكسي عبر الكاميرا والبوصلة المغناطيسية،
|
||||
/// واستخراج إحداثيات الموقع بدقة عند انقطاع الـ GPS أو التشويش الإلكتروني.
|
||||
/// ============================================================================
|
||||
class ResectionController extends GetxController {
|
||||
// ── Observables / الحالات التفاعلية ──────────────────────────────────────
|
||||
final RxList<ResectionObservation> observations = <ResectionObservation>[].obs;
|
||||
final Rx<ResectionResult?> resectionResult = Rx<ResectionResult?>(null);
|
||||
final RxDouble currentHeadingDeg = 0.0.obs;
|
||||
|
||||
/// Add Observation / إضافة رصد اتجاهي لمعلم جغرافي
|
||||
void addObservation(ResectionObservation obs) {
|
||||
observations.removeWhere((o) => o.landmark.id == obs.landmark.id);
|
||||
observations.add(obs);
|
||||
}
|
||||
|
||||
/// Remove Observation / إزالة رصد معلم معين
|
||||
void removeObservation(String landmarkId) {
|
||||
observations.removeWhere((o) => o.landmark.id == landmarkId);
|
||||
}
|
||||
|
||||
/// Compute Position from Observations / استخراج الإحداثيات بالتقاطع العكسي
|
||||
ResectionResult? computePosition() {
|
||||
if (observations.length < 2) return null;
|
||||
final res = ResectionCalculator.calculatePosition(observations);
|
||||
resectionResult.value = res;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Reset all observations / تصفير وإعادة ضبط الرصد
|
||||
void reset() {
|
||||
observations.clear();
|
||||
resectionResult.value = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user