Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for loading TFS layers based on min/max levels available in the s… #2331

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/osgEarth/EarthManipulator
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ namespace osgEarth { namespace Util
void setZoomToMouse(bool value) { _zoomToMouse = value; }
bool getZoomToMouse() const { return _zoomToMouse; }

/** Allow multitouch drag events to be combined with pinch/twist in the same gesture */
void setAllowTouchDragCombos(bool value) { _allowTouchDragCombos = value; }
bool getAllowTouchDragCombos() const { return _allowTouchDragCombos; }

private:

friend class EarthManipulator;
Expand Down Expand Up @@ -561,6 +565,7 @@ namespace osgEarth { namespace Util
double _throwDecayRate;

bool _zoomToMouse;
bool _allowTouchDragCombos;
};

public:
Expand Down
25 changes: 19 additions & 6 deletions src/osgEarth/EarthManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ _terrainAvoidanceEnabled ( true ),
_terrainAvoidanceMinDistance ( 1.0 ),
_throwingEnabled ( false ),
_throwDecayRate ( 0.05 ),
_zoomToMouse ( false )
_zoomToMouse ( false ),
_allowTouchDragCombos ( false )
{
//NOP
}
Expand Down Expand Up @@ -329,7 +330,8 @@ _terrainAvoidanceEnabled( rhs._terrainAvoidanceEnabled ),
_terrainAvoidanceMinDistance( rhs._terrainAvoidanceMinDistance ),
_throwingEnabled( rhs._throwingEnabled ),
_throwDecayRate( rhs._throwDecayRate ),
_zoomToMouse( rhs._zoomToMouse )
_zoomToMouse( rhs._zoomToMouse ),
_allowTouchDragCombos( rhs._allowTouchDragCombos )
{
//NOP
}
Expand Down Expand Up @@ -2188,10 +2190,13 @@ EarthManipulator::parseTouchEvents( TouchEvents& output )

// Threshold in pixels for determining if a two finger drag happened.
float dragThres = 1.0f;
bool doMultiDrag = ( osg::equivalent(vec0.x(), vec1.x(), dragThres) &&
osg::equivalent(vec0.y(), vec1.y(), dragThres) ) ||
_settings->getAllowTouchDragCombos();

// now see if that corresponds to any touch events:
if (osg::equivalent(vec0.x(), vec1.x(), dragThres) &&
osg::equivalent(vec0.y(), vec1.y(), dragThres))
// First check if we should be doing the multidrag event, either because
// it was a pure drag, or because we allow it in combination with pinch/twise
if( doMultiDrag )
{
// two-finger drag.
output.push_back(TouchEvent());
Expand All @@ -2200,7 +2205,9 @@ EarthManipulator::parseTouchEvents( TouchEvents& output )
ev._dx = 0.5 * (dx[0] + dx[1]) * sens;
ev._dy = 0.5 * (dy[0] + dy[1]) * sens;
}
else

// If it wasn't a drag event, or if we allow drag combinations, do the pinch/twist
if( !doMultiDrag || _settings->getAllowTouchDragCombos() )
{
// otherwise it's a pinch and/or a zoom. You can do them together.
if (fabs(deltaDistance) > (1.0 * 0.0005 / sens))
Expand Down Expand Up @@ -2689,6 +2696,9 @@ EarthManipulator::zoom( double dx, double dy, osg::View* in_view )
if ( !camera )
return;

if ( !recalculateCenterFromLookVector() )
return;

// reset the "remembered start location" if we're just starting a continuous zoom
static osg::Vec3d zero(0,0,0);
if (_last_action._type != ACTION_ZOOM)
Expand Down Expand Up @@ -3371,6 +3381,9 @@ EarthManipulator::drag(double dx, double dy, osg::View* theView)
if ( !camera )
return;

if ( !recalculateCenterFromLookVector() )
return;

osg::Matrix viewMat = camera->getViewMatrix();
osg::Matrix viewMatInv = camera->getInverseViewMatrix();
if (!_ga_t1.valid())
Expand Down
24 changes: 24 additions & 0 deletions src/osgEarth/FeatureDisplayLayout
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,27 @@ namespace osgEarth
optional<float>& minRange() { return _minRange; }
const optional<float>& minRange() const { return _minRange; }

/**
* Whether features are loaded based on range. If not, pixels on screen
* is used. Default = range
*/
optional<bool>& useRange() { return _useRange; }
const optional<bool>& useRange() const { return _useRange; }

/**
* When using pixel size on screen instead of range, this specifies the maximum
* number of pixels at which to display the feature at a given LOD
*/
optional<float>& maxPixels() { return _maxPixels;}
const optional<float>& maxPixels() const { return _maxPixels;}

/**
* When using pixel size on screen instead of range, this specifies the minimum
* number of pixels at which to display the feature at a given LOD
*/
optional<float>& minPixels() { return _minPixels; }
const optional<float>& minPixels() const { return _minPixels; }

/**
* Whether to crop geometry to fit within the cell extents when chopping
* a feature level up into grid cells. By default, this is false, meaning
Expand Down Expand Up @@ -184,6 +205,9 @@ namespace osgEarth
optional<float> _tileSizeFactor;
optional<float> _minRange;
optional<float> _maxRange;
optional<float> _minPixels;
optional<float> _maxPixels;
optional<bool> _useRange;
optional<bool> _cropFeatures;
optional<float> _priorityOffset;
optional<float> _priorityScale;
Expand Down
9 changes: 9 additions & 0 deletions src/osgEarth/FeatureDisplayLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ FeatureDisplayLayout::FeatureDisplayLayout( const Config& conf ) :
_tileSizeFactor( 3.5f ),
_minRange ( 0.0f ),
_maxRange ( 0.0f ),
_minPixels ( 0.0f ),
_maxPixels ( 0.0f ),
_useRange ( true ),
_cropFeatures ( false ),
_priorityOffset( 0.0f ),
_priorityScale ( 1.0f ),
Expand All @@ -91,6 +94,9 @@ FeatureDisplayLayout::fromConfig( const Config& conf )
conf.get( "min_expiry_time", _minExpiryTime );
conf.get( "min_range", _minRange );
conf.get( "max_range", _maxRange );
conf.get( "min_pixels", _minPixels);
conf.get( "max_pixels", _maxPixels);
conf.get( "use_range", _useRange);
conf.get("paged", _paged);
ConfigSet children = conf.children( "level" );
for( ConfigSet::const_iterator i = children.begin(); i != children.end(); ++i )
Expand All @@ -109,6 +115,9 @@ FeatureDisplayLayout::getConfig() const
conf.set( "min_expiry_time", _minExpiryTime );
conf.set( "min_range", _minRange );
conf.set( "max_range", _maxRange );
conf.set( "min_pixels", _minPixels );
conf.set( "max_pixels", _maxPixels );
conf.set( "use_range", _useRange );
conf.set("paged", _paged);
for( Levels::const_iterator i = _levels.begin(); i != _levels.end(); ++i )
conf.add( i->second.getConfig() );
Expand Down
16 changes: 14 additions & 2 deletions src/osgEarth/FeatureModelGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,20 @@ namespace
p->setLoadFunction(func);
p->setCenter(bs.center());
p->setRadius(bs.radius());
p->setMinRange(minRange);
p->setMaxRange(maxRange);
if( layout.useRange().get() )
{
p->setMinRange(minRange);
p->setMaxRange(maxRange);
}
else
{
if( layout.minPixels().isSet() )
p->setMinPixels(layout.minPixels().get());

if( layout.maxPixels().isSet() )
p->setMaxPixels(layout.maxPixels().get());
}

p->setPriorityScale(layout.priorityScale().get());
p->setSceneGraphCallbacks(sgCallbacks);
return p;
Expand Down
Loading