1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-16 08:29:15 +01:00

GCS-Prevent the map from being dragged beyond the available imagery.

Previous way seemed broken, looked ugly and like a bug.
This commit is contained in:
PT_Dreamer 2012-08-11 19:58:14 +01:00
parent 74cd57e8a0
commit 619b4ffa8c
2 changed files with 18 additions and 2 deletions

View File

@ -251,6 +251,7 @@ namespace internals {
Matrix.Clear();
GoToCurrentPositionOnZoom();
UpdateBounds();
keepInBounds();
emit OnMapDrag();
emit OnMapZoomChanged();
emit OnNeedInvalidation();
@ -572,7 +573,7 @@ namespace internals {
{
renderOffset.SetX(pt.X() - dragPoint.X());
renderOffset.SetY(pt.Y() - dragPoint.Y());
keepInBounds();
UpdateCenterTileXYLocation();
if(centerTileXYLocation != centerTileXYLocationLast)
@ -692,4 +693,18 @@ namespace internals {
pxRes1000km = (int) (1000000.0 / rez); // 1000km
pxRes5000km = (int) (5000000.0 / rez); // 5000km
}
void Core::keepInBounds()
{
if(renderOffset.X()>0)
renderOffset.SetX(0);
if(renderOffset.Y()>0)
renderOffset.SetY(0);
int maxDragY=GetCurrentRegion().Height()-GettileRect().Height()*(maxOfTiles.Height()-minOfTiles.Height()+1);
int maxDragX=GetCurrentRegion().Width()-GettileRect().Width()*(maxOfTiles.Width()-minOfTiles.Width()+1);
if(maxDragY>renderOffset.Y())
renderOffset.SetY(maxDragY);
if(maxDragX>renderOffset.X())
renderOffset.SetX(maxDragX);
}
}

View File

@ -193,6 +193,7 @@ namespace internals {
bool isStarted(){return started;}
diagnostics GetDiagnostics();
signals:
void OnCurrentPositionChanged(internals::PointLatLng point);
void OnTileLoadComplete();
@ -206,7 +207,7 @@ namespace internals {
private:
void keepInBounds();
PointLatLng currentPosition;
core::Point currentPositionPixel;
core::Point renderOffset;