/** * @brief Sets provided value as current zoom * * @param value zoom ratio to set */ void MapWindow::Zoom::EventSetZoom(double value) { double _lastRequestedScale = *_requestedScale; *_requestedScale = LimitMapScale(value); if(*_requestedScale != _lastRequestedScale) { RefreshMap(); } }
/** * @brief Modifies current zoom ratio * * @param vswitch Modifier value: */ void MapWindow::Zoom::EventScaleZoom(int vswitch) { if (IsMultiMapNoMain() && !INPAN) { if (vswitch>0) LKevent=LKEVENT_UP; else LKevent=LKEVENT_DOWN; return; } // disable AutoZoom if possible if(_autoZoom && mode.Special() == Mode::MODE_SPECIAL_NONE && !(_circleZoom && mode.Is(Mode::MODE_CIRCLING))) { // Disable Auto Zoom only if not in Special or Circling Zoom DoStatusMessage(gettext(TEXT("_@M857_"))); // AutoZoom OFF _autoZoom = false; } // For best results, zooms should be multiples or roots of 2 double value = *_requestedScale; if(ScaleListCount > 0) { value = FindMapScale(*_requestedScale); value = StepMapScale(-vswitch); } else { if (abs(vswitch)>=4) { if (vswitch==4) vswitch = 1; if (vswitch==-4) vswitch = -1; } if (vswitch==1) { // zoom in a little value /= 1.414; } if (vswitch== -1) { // zoom out a little value *= 1.414; } if (vswitch==2) { // zoom in a lot value /= 2.0; } if (vswitch== -2) { // zoom out a lot value *= 2.0; } } double _lastRequestedScale = *_requestedScale; *_requestedScale = LimitMapScale(value); if(*_requestedScale != _lastRequestedScale) { RefreshMap(); } }
/** * @brief Assigns proper zoom ratio for new Display Mode */ void MapWindow::Zoom::SwitchMode() { if(!_inited) return; if((mode._mode & Mode::MODE_TARGET_PAN) && !(mode._lastMode & Mode::MODE_TARGET_PAN)) { // TARGET_PAN enabled _requestedScale = &_modeScale[SCALE_TARGET_PAN]; CalculateTargetPanZoom(); zoom._bigZoom = true; } else if(mode._mode & Mode::MODE_TARGET_PAN) { // do not change zoom for other mode changes while in TARGET_PAN mode return; } else if(mode._mode & Mode::MODE_PAN) { if(!(mode._lastMode & Mode::MODE_PAN)) // PAN enabled - use current map scale if PAN enabled _modeScale[SCALE_PAN] = *_requestedScale; _requestedScale = &_modeScale[SCALE_PAN]; // do not change zoom for other mode changes while in PAN mode return; } else if((mode._mode & Mode::MODE_PANORAMA) && !(mode._lastMode & Mode::MODE_PANORAMA)) { // PANORAMA enabled _requestedScale = &_modeScale[SCALE_PANORAMA]; zoom._bigZoom = true; } else if(mode._mode & Mode::MODE_PANORAMA) { // do not change zoom for mode changes while in PANORAMA mode return; } else { if((mode._mode & Mode::MODE_CIRCLING) && _circleZoom) { _requestedScale = &_modeScale[SCALE_CIRCLING]; } else { _requestedScale = &_modeScale[SCALE_CRUISE]; if(_autoZoom) CalculateAutoZoom(); } _bigZoom = true; } *_requestedScale = LimitMapScale(*_requestedScale); RefreshMap(); }
/** * @brief Recalculates zoom parameters */ void MapWindow::Zoom::ModifyMapScale() { if(_scale == *_requestedScale) return; // limit zoomed in so doesn't reach silly levels *_requestedScale = LimitMapScale(*_requestedScale); // FIX VENTA remove limit _scaleOverDistanceModify = *_requestedScale / DISTANCEMODIFY; _resScaleOverDistanceModify = GetMapResolutionFactor() / _scaleOverDistanceModify; _drawScale = _scaleOverDistanceModify; _drawScale = _drawScale / 111194; _drawScale = GetMapResolutionFactor() / _drawScale; _invDrawScale = 1.0 / _drawScale; _scale = *_requestedScale; }
void MapWindow::Zoom::ModifyMapScale() { // limit zoomed in so doesn't reach silly levels if(_bMapScale) *_requestedScale = LimitMapScale(*_requestedScale); // FIX VENTA remove limit _scaleOverDistanceModify = *_requestedScale / DISTANCEMODIFY; LKASSERT(_scaleOverDistanceModify!=0); _resScaleOverDistanceModify = GetMapResolutionFactor() / _scaleOverDistanceModify; _drawScale = _scaleOverDistanceModify; _drawScale = _drawScale / 111194; LKASSERT(_drawScale!=0); _drawScale = GetMapResolutionFactor() / _drawScale; _invDrawScale = 1.0 / _drawScale; _scale = *_requestedScale; _realscale = *_requestedScale/DISTANCEMODIFY/1000; }
/** * @brief Sets requested zoom scale for AUTO_ZOOM mode */ void MapWindow::Zoom::CalculateAutoZoom() { static int autoMapScaleWaypointIndex = -1; double wpd = DerivedDrawInfo.ZoomDistance; if(wpd > 0) { double AutoZoomFactor; if( (DisplayOrientation == NORTHTRACK && !mode.Is(Mode::MODE_CIRCLING)) || DisplayOrientation == NORTHUP || DisplayOrientation == NORTHSMART || ((DisplayOrientation == NORTHCIRCLE || DisplayOrientation == TRACKCIRCLE) && mode.Is(Mode::MODE_CIRCLING)) ) AutoZoomFactor = 2.5; else AutoZoomFactor = 4; if(wpd < AutoZoomFactor * _scaleOverDistanceModify) { // waypoint is too close, so zoom in _modeScale[SCALE_CRUISE] = LimitMapScale(wpd * DISTANCEMODIFY / AutoZoomFactor); } } LockTaskData(); // protect from external task changes #ifdef HAVEEXCEPTIONS __try{ #endif // if we aren't looking at a waypoint, see if we are now if(autoMapScaleWaypointIndex == -1) { if(ValidTaskPoint(ActiveWayPoint)) autoMapScaleWaypointIndex = Task[ActiveWayPoint].Index; } if(ValidTaskPoint(ActiveWayPoint)) { // if the current zoom focused waypoint has changed... if(autoMapScaleWaypointIndex != Task[ActiveWayPoint].Index) { autoMapScaleWaypointIndex = Task[ActiveWayPoint].Index; // zoom back out to where we were before _modeScale[SCALE_CRUISE] = _modeScale[SCALE_AUTO_ZOOM]; } } #ifdef HAVEEXCEPTIONS }__finally #endif { UnlockTaskData(); } }
/** * @brief Sets requested zoom scale for AUTO_ZOOM mode */ void MapWindow::Zoom::CalculateAutoZoom() { static int autoMapScaleWaypointIndex = -1; static int wait_for_new_wpt_distance = 0; double wpd = DerivedDrawInfo.ZoomDistance; if (wait_for_new_wpt_distance>0) wait_for_new_wpt_distance--; //This counter is needed to get new valid waypoint distance after wp changes if ( (wpd > 0) && (wait_for_new_wpt_distance==0) ) { double AutoZoomFactor; if( (DisplayOrientation == NORTHTRACK && !mode.Is(Mode::MODE_CIRCLING)) || DisplayOrientation == NORTHUP || DisplayOrientation == NORTHSMART || ((DisplayOrientation == NORTHCIRCLE || DisplayOrientation == TRACKCIRCLE) && mode.Is(Mode::MODE_CIRCLING)) ) AutoZoomFactor = 2.5; else AutoZoomFactor = 4; if ( ( !ISPARAGLIDER && (wpd < AutoZoomFactor * _scaleOverDistanceModify) ) || ( ISPARAGLIDER && (wpd < PGAutoZoomThreshold)) ) { // waypoint is too close, so zoom in LKASSERT(AutoZoomFactor!=0); _modeScale[SCALE_CRUISE] = LimitMapScale(wpd * DISTANCEMODIFY / AutoZoomFactor); } } LockTaskData(); // protect from external task changes // if we aren't looking at a waypoint, see if we are now if(autoMapScaleWaypointIndex == -1) { if(ValidTaskPoint(ActiveWayPoint)) autoMapScaleWaypointIndex = Task[ActiveWayPoint].Index; } if(ValidTaskPoint(ActiveWayPoint)) { // if the current zoom focused waypoint has changed... if(autoMapScaleWaypointIndex != Task[ActiveWayPoint].Index) { autoMapScaleWaypointIndex = Task[ActiveWayPoint].Index; wait_for_new_wpt_distance = 3; // zoom back out to where we were before _modeScale[SCALE_CRUISE] = _modeScale[SCALE_AUTO_ZOOM]; } } { UnlockTaskData(); } }
/** * @brief Sets requested zoom scale for TARGET_PAN mode */ void MapWindow::Zoom::CalculateTargetPanZoom() { // set scale exactly so that waypoint distance is the zoom factor across the screen *_requestedScale = LimitMapScale(TargetZoomDistance * DISTANCEMODIFY / 6.0); }
double RequestMapScale(double x, const SETTINGS_MAP &settings_map) { _RequestedMapScale = LimitMapScale(x, settings_map); return _RequestedMapScale; }
fixed RequestMapScale(fixed x, const SETTINGS_MAP &settings_map) { _RequestedMapScale = LimitMapScale(x, settings_map); return _RequestedMapScale; }
void MapWindowProjection::SetMapScale(const fixed x) { SetScale(fixed(GetMapResolutionFactor()) / LimitMapScale(x)); }