@@ -2362,11 +2362,19 @@ void MapWidget::simDataChanged(const atools::fs::sc::SimConnectData& simulatorDa
2362
2362
using atools::geo::angleAbsDiff;
2363
2363
2364
2364
const atools::fs::sc::SimConnectUserAircraft& aircraft = simulatorData.getUserAircraftConst ();
2365
+
2366
+ // Emit signal later once all values are updated - check for aircraft state changes
2367
+ bool userAircraftValidToggled = getScreenIndexConst ()->getUserAircraft ().isFullyValid () != aircraft.isFullyValid ();
2368
+
2365
2369
getScreenIndex ()->updateSimData (simulatorData);
2366
2370
2367
2371
if (databaseLoadStatus || !aircraft.isValid ())
2368
2372
{
2369
2373
getScreenIndex ()->updateLastSimData (atools::fs::sc::SimConnectData ());
2374
+
2375
+ // Update action states if needed
2376
+ if (userAircraftValidToggled)
2377
+ emit userAircraftValidChanged ();
2370
2378
return ;
2371
2379
}
2372
2380
@@ -2384,8 +2392,8 @@ void MapWidget::simDataChanged(const atools::fs::sc::SimConnectData& simulatorDa
2384
2392
QPoint aircraftPoint = conv.wToS (aircraft.getPosition (), CoordinateConverter::DEFAULT_WTOS_SIZE, &visible);
2385
2393
2386
2394
// Difference from last movement on map
2387
- const atools::fs::sc::SimConnectUserAircraft& last = getScreenIndexConst ()->getLastUserAircraft ();
2388
- QPoint aircraftPointDiff = aircraftPoint - conv.wToS (last .getPosition ());
2395
+ const atools::fs::sc::SimConnectUserAircraft& lastAircraft = getScreenIndexConst ()->getLastUserAircraft ();
2396
+ QPoint aircraftPointDiff = aircraftPoint - conv.wToS (lastAircraft .getPosition ());
2389
2397
const OptionData& od = OptionData::instance ();
2390
2398
2391
2399
// Zoom to aircraft and next waypoint - depends on various criteria
@@ -2488,18 +2496,18 @@ void MapWidget::simDataChanged(const atools::fs::sc::SimConnectData& simulatorDa
2488
2496
}
2489
2497
2490
2498
// Check if position has changed significantly
2491
- bool posHasChanged = !last .isValid () || // No previous position
2499
+ bool posHasChanged = !lastAircraft .isValid () || // No previous position
2492
2500
aircraftPointDiff.manhattanLength () >= deltas.manhattanLengthDelta ; // Screen position has changed
2493
2501
2494
2502
// Check if any data like heading has changed which requires a redraw
2495
2503
bool dataHasChanged = posHasChanged ||
2496
- last .isFlying () != aircraft.isFlying () ||
2497
- last .isOnGround () != aircraft.isOnGround () ||
2498
- angleAbsDiff (last .getHeadingDegMag (),
2504
+ lastAircraft .isFlying () != aircraft.isFlying () ||
2505
+ lastAircraft .isOnGround () != aircraft.isOnGround () ||
2506
+ angleAbsDiff (lastAircraft .getHeadingDegMag (),
2499
2507
aircraft.getHeadingDegMag ()) > deltas.headingDelta || // Heading has changed
2500
- almostNotEqual (last .getIndicatedSpeedKts (),
2508
+ almostNotEqual (lastAircraft .getIndicatedSpeedKts (),
2501
2509
aircraft.getIndicatedSpeedKts (), deltas.speedDelta ) || // Speed has changed
2502
- almostNotEqual (last .getPosition ().getAltitude (),
2510
+ almostNotEqual (lastAircraft .getPosition ().getAltitude (),
2503
2511
aircraft.getActualAltitudeFt (), deltas.altitudeDelta ); // Altitude has changed
2504
2512
2505
2513
// Force an update every five seconds to avoid hanging map view if aircraft does not move on map
@@ -2510,8 +2518,8 @@ void MapWidget::simDataChanged(const atools::fs::sc::SimConnectData& simulatorDa
2510
2518
lastSimUpdateMs = now;
2511
2519
2512
2520
// Check for takeoff, landing and fuel consumption changes ===========
2513
- simDataCalcTakeoffLanding (aircraft, last );
2514
- simDataCalcFuelOnOff (aircraft, last );
2521
+ simDataCalcTakeoffLanding (aircraft, lastAircraft );
2522
+ simDataCalcFuelOnOff (aircraft, lastAircraft );
2515
2523
2516
2524
if (dataHasChanged)
2517
2525
// Also changes local "last"
@@ -2756,6 +2764,10 @@ void MapWidget::simDataChanged(const atools::fs::sc::SimConnectData& simulatorDa
2756
2764
if (!updatesEnabled ())
2757
2765
setUpdatesEnabled (true );
2758
2766
} // if(now - lastSimUpdateMs > deltas.timeDeltaMs)
2767
+
2768
+ // Update action states if needed
2769
+ if (userAircraftValidToggled)
2770
+ emit userAircraftValidChanged ();
2759
2771
}
2760
2772
2761
2773
void MapWidget::mainWindowShown ()
0 commit comments