Gnash  0.8.11dev
Classes | Public Types | Public Member Functions | Friends | List of all members
gnash::geometry::SnappingRanges2d< T > Class Template Reference

#include <snappingrange.h>

Classes

class  AddTo
 
class  ContainsPoint
 
class  ContainsRange
 
struct  ExpandToIfSnap
 Merge two ranges based on snaptest. More...
 
class  GrowBy
 
class  IntersectsRange
 
class  Scale
 

Public Types

typedef geometry::Range2d< T > RangeType
 
typedef std::vector< RangeTypeRangeList
 
typedef RangeList::size_type size_type
 

Public Member Functions

 SnappingRanges2d ()
 
template<typename U >
 SnappingRanges2d (const SnappingRanges2d< U > &from)
 Templated copy constructor, for casting between range types. More...
 
void setSnapFactor (const float factor)
 
float getSnapFactor () const
 
void setSingleMode (const bool mode)
 if mode==true, then the snapping ranges will act like a normal Range2d More...
 
bool getSingleMode () const
 
void setRangeCountLimit (const size_type limit)
 
size_type getRangeCountLimit () const
 
void inheritConfig (const SnappingRanges2d< T > &from)
 
void add (const RangeType &range)
 Add a Range to the set, merging when possible and appropriate. More...
 
void add (const SnappingRanges2d< T > &other)
 combines two snapping ranges More...
 
void growBy (const T amount)
 Grows all ranges by the specified amount. More...
 
void scale (const float factor)
 Scale all ranges by the specified factor. More...
 
void setNull ()
 Resets to NULL range. More...
 
void setWorld ()
 Resets to one range with world flags. More...
 
bool isWorld () const
 Returns true, when the ranges equal world range. More...
 
bool isNull () const
 Returns true, when there is no range. More...
 
size_type size () const
 Returns the number of ranges in the list. More...
 
const RangeTypegetRange (size_type index) const
 Returns the range at the specified index. More...
 
RangeType getFullArea () const
 
bool intersects (const RangeType &r) const
 Returns true if any of the ranges intersect the given range. More...
 
bool contains (T x, T y) const
 Returns true if any of the ranges contains the point. More...
 
bool contains (const RangeType &r) const
 Returns true if any of the ranges contains the range. More...
 
bool contains (const SnappingRanges2d< T > &o) const
 Returns true if all ranges in the given SnappingRanges2d are contained in at least one of the ranges composing this one. More...
 
void intersect (const SnappingRanges2d< T > &o)
 
void intersect (const RangeType &r)
 
void combineRanges () const
 
template<class V >
bool visit (V &visitor) const
 Visit the current Ranges set. More...
 
template<class V >
void visitAll (V &visitor) const
 Visit the current Ranges set. More...
 

Friends

template<typename U >
std::ostream & operator<< (std::ostream &os, const SnappingRanges2d< U > &r)
 

Member Typedef Documentation

§ RangeList

template<typename T>
typedef std::vector<RangeType> gnash::geometry::SnappingRanges2d< T >::RangeList

§ RangeType

template<typename T>
typedef geometry::Range2d<T> gnash::geometry::SnappingRanges2d< T >::RangeType

§ size_type

template<typename T>
typedef RangeList::size_type gnash::geometry::SnappingRanges2d< T >::size_type

Constructor & Destructor Documentation

§ SnappingRanges2d() [1/2]

template<typename T>
gnash::geometry::SnappingRanges2d< T >::SnappingRanges2d ( )
inline

§ SnappingRanges2d() [2/2]

template<typename T>
template<typename U >
gnash::geometry::SnappingRanges2d< T >::SnappingRanges2d ( const SnappingRanges2d< U > &  from)
inline

Templated copy constructor, for casting between range types.

Member Function Documentation

§ add() [1/2]

template<typename T>
void gnash::geometry::SnappingRanges2d< T >::add ( const RangeType range)
inline

§ add() [2/2]

template<typename T>
void gnash::geometry::SnappingRanges2d< T >::add ( const SnappingRanges2d< T > &  other)
inline

combines two snapping ranges

§ combineRanges()

template<typename T>
void gnash::geometry::SnappingRanges2d< T >::combineRanges ( ) const
inline

Combines known ranges. Previously merged ranges may have come close to other ranges. Algorithm could be optimized.

Referenced by gnash::Gui::notify_key_event(), and gnash::geometry::SnappingRanges2d< std::int32_t >::visitAll().

§ contains() [1/3]

template<typename T>
bool gnash::geometry::SnappingRanges2d< T >::contains ( x,
y 
) const
inline

Returns true if any of the ranges contains the point.

Referenced by gnash::geometry::SnappingRanges2d< std::int32_t >::contains().

§ contains() [2/3]

template<typename T>
bool gnash::geometry::SnappingRanges2d< T >::contains ( const RangeType r) const
inline

Returns true if any of the ranges contains the range.

Note that a NULL range is not contained in any range and a WORLD range is onluy contained in another WORLD range.

§ contains() [3/3]

template<typename T>
bool gnash::geometry::SnappingRanges2d< T >::contains ( const SnappingRanges2d< T > &  o) const
inline

Returns true if all ranges in the given SnappingRanges2d are contained in at least one of the ranges composing this one.

Note that a NULL range is not contained in any range and a WORLD range is onluy contained in another WORLD range.

TODO: use a visitor !

§ getFullArea()

template<typename T>
RangeType gnash::geometry::SnappingRanges2d< T >::getFullArea ( ) const
inline

Return a range that surrounds all added ranges. This is used mainly for compatibilty issues.

Referenced by gnash::geometry::SnappingRanges2d< std::int32_t >::combineRanges(), and gnash::Gui::setInvalidatedRegions().

§ getRange()

template<typename T>
const RangeType& gnash::geometry::SnappingRanges2d< T >::getRange ( size_type  index) const
inline

§ getRangeCountLimit()

template<typename T>
size_type gnash::geometry::SnappingRanges2d< T >::getRangeCountLimit ( ) const
inline

§ getSingleMode()

template<typename T>
bool gnash::geometry::SnappingRanges2d< T >::getSingleMode ( ) const
inline

§ getSnapFactor()

template<typename T>
float gnash::geometry::SnappingRanges2d< T >::getSnapFactor ( ) const
inline

§ growBy()

template<typename T>
void gnash::geometry::SnappingRanges2d< T >::growBy ( const T  amount)
inline

Grows all ranges by the specified amount.

Referenced by gnash::Gui::notify_key_event().

§ inheritConfig()

template<typename T>
void gnash::geometry::SnappingRanges2d< T >::inheritConfig ( const SnappingRanges2d< T > &  from)
inline

Copy the snapping settings from another ranges list, without copying the ranges itself

Referenced by gnash::DisplayList::add_invalidated_bounds().

§ intersect() [1/2]

template<typename T>
void gnash::geometry::SnappingRanges2d< T >::intersect ( const SnappingRanges2d< T > &  o)
inline

Intersect this ranges list with the given ranges list, updating the current ranges list. Note this is currently a relatively expensive operation for complex lists.

Referenced by gnash::DisplayList::add_invalidated_bounds().

§ intersect() [2/2]

template<typename T>
void gnash::geometry::SnappingRanges2d< T >::intersect ( const RangeType r)
inline

Intersects this ranges list with the given single range, updating the current ranges list.

§ intersects()

template<typename T>
bool gnash::geometry::SnappingRanges2d< T >::intersects ( const RangeType r) const
inline

Returns true if any of the ranges intersect the given range.

Note that a NULL range doesn't intersect anything and a WORLD range intersects everything except a NULL Range.

§ isNull()

template<typename T>
bool gnash::geometry::SnappingRanges2d< T >::isNull ( ) const
inline

§ isWorld()

template<typename T>
bool gnash::geometry::SnappingRanges2d< T >::isWorld ( ) const
inline

§ scale()

template<typename T>
void gnash::geometry::SnappingRanges2d< T >::scale ( const float  factor)
inline

Scale all ranges by the specified factor.

§ setNull()

template<typename T>
void gnash::geometry::SnappingRanges2d< T >::setNull ( )
inline

§ setRangeCountLimit()

template<typename T>
void gnash::geometry::SnappingRanges2d< T >::setRangeCountLimit ( const size_type  limit)
inline

Sets the maximum number of ranges allowed (to avoid lots of small ranges)

§ setSingleMode()

template<typename T>
void gnash::geometry::SnappingRanges2d< T >::setSingleMode ( const bool  mode)
inline

if mode==true, then the snapping ranges will act like a normal Range2d

Referenced by gnash::Gui::notify_key_event().

§ setSnapFactor()

template<typename T>
void gnash::geometry::SnappingRanges2d< T >::setSnapFactor ( const float  factor)
inline

Sets the snapping factor (which must be > 1.0). Higher factors make the ranges more attractive for snapping. A good value is usually 1.3.

Referenced by gnash::Gui::notify_key_event().

§ setWorld()

template<typename T>
void gnash::geometry::SnappingRanges2d< T >::setWorld ( )
inline

§ size()

template<typename T>
size_type gnash::geometry::SnappingRanges2d< T >::size ( ) const
inline

§ visit()

template<typename T>
template<class V >
bool gnash::geometry::SnappingRanges2d< T >::visit ( V &  visitor) const
inline

Visit the current Ranges set.

Visitor functor will be invoked for each RangeType in the current set.

The visitor functor will receive a RangeType reference; must return true if it wants next item or true to exit the loop.

Returns
false if the visitor reached the end.

Referenced by gnash::geometry::SnappingRanges2d< std::int32_t >::add().

§ visitAll()

template<typename T>
template<class V >
void gnash::geometry::SnappingRanges2d< T >::visitAll ( V &  visitor) const
inline

Visit the current Ranges set.

Visitor functor will be invoked inconditionally for each RangeType in the current set.

The visitor functor will receive a RangeType reference.

Friends And Related Function Documentation

§ operator<<

template<typename T>
template<typename U >
std::ostream& operator<< ( std::ostream &  os,
const SnappingRanges2d< U > &  r 
)
friend

The documentation for this class was generated from the following file: