[Marble-devel] [marble] src/lib: LatLonAltBox: returning it by value is a perfo hit. return by ref instead.

Torsten Rahn tackat at t-online.de
Wed Jul 18 13:54:11 UTC 2012


The small problem there would be that GeoDataLatLonAltBox inherits from 
GeoDataLatLonBox. So in that regard it's rather like 
GeoDataLineString/LinearRing/Polygon, since it means implicit sharing across 
inheritance hierarchies. So it's a bit more complex to implement IIRC and does 
a few uncommon things with C++ .... This isn't meant to oppose your idea but I 
just wanted to point it out.

BR,
Torsten  

On Mittwoch, 18. Juli 2012 13:58:31 Bernhard Beschow wrote:
> Hi Thibaut,
> 
> why not make GeoDataLatLon(Alt)Box implicitly shared, like e.g.
> GeoDataCoordinate? IMO, that would add for a more coherent API with less
> surprises.
> 
> Greetings,
> Bernhard
> 
> On Dienstag, 17. Juli 2012 22:20:44 Thibaut Gridel wrote:
> > Git commit ff6a02a7bbf47c1195d183da2233653260084c3e by Thibaut Gridel.
> > Committed on 17/07/2012 at 19:31.
> > Pushed by tgridel into branch 'master'.
> > 
> > LatLonAltBox: returning it by value is a perfo hit. return by ref
> > instead.
> > 
> > M  +1    -1    src/lib/ViewportParams.cpp
> > M  +1    -1    src/lib/ViewportParams.h
> > M  +2    -2    src/lib/geodata/data/GeoDataGeometry.cpp
> > M  +1    -1    src/lib/geodata/data/GeoDataGeometry.h
> > M  +3    -1    src/lib/geodata/data/GeoDataGeometry_p.h
> > M  +19   -0    src/lib/geodata/data/GeoDataLatLonAltBox.cpp
> > M  +6    -0    src/lib/geodata/data/GeoDataLatLonAltBox.h
> > M  +5    -0    src/lib/geodata/data/GeoDataLatLonBox.cpp
> > M  +5    -0    src/lib/geodata/data/GeoDataLatLonBox.h
> > M  +1    -1    src/lib/geodata/data/GeoDataLineString.cpp
> > M  +1    -1    src/lib/geodata/data/GeoDataLineString.h
> > M  +0    -1    src/lib/geodata/data/GeoDataLineString_p.h
> > M  +6    -6    src/lib/geodata/data/GeoDataMultiGeometry.cpp
> > M  +1    -1    src/lib/geodata/data/GeoDataMultiGeometry.h
> > M  +3    -5    src/lib/geodata/data/GeoDataPoint.cpp
> > M  +0    -2    src/lib/geodata/data/GeoDataPoint.h
> > M  +1    -1    src/lib/geodata/data/GeoDataPolygon.cpp
> > M  +1    -1    src/lib/geodata/data/GeoDataPolygon.h
> > M  +1    -1    src/lib/geodata/data/GeoDataTrack.cpp
> > M  +1    -1    src/lib/geodata/data/GeoDataTrack.h
> > M  +6    -11   src/lib/geodata/graphicsitem/GeoImageGraphicsItem.cpp
> > M  +1    -5    src/lib/geodata/graphicsitem/GeoImageGraphicsItem.h
> > M  +1    -1    src/lib/geodata/graphicsitem/GeoLineStringGraphicsItem.cpp
> > M  +1    -1    src/lib/geodata/graphicsitem/GeoLineStringGraphicsItem.h
> > M  +1    -1    src/lib/geodata/graphicsitem/GeoPhotoGraphicsItem.cpp
> > M  +1    -1    src/lib/geodata/graphicsitem/GeoPhotoGraphicsItem.h
> > M  +1    -1    src/lib/geodata/graphicsitem/GeoPointGraphicsItem.cpp
> > M  +1    -1    src/lib/geodata/graphicsitem/GeoPointGraphicsItem.h
> > M  +2    -2    src/lib/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp
> > M  +1    -1    src/lib/geodata/graphicsitem/GeoPolygonGraphicsItem.h
> > M  +1    -1    src/lib/graphicsview/GeoGraphicsItem.cpp
> > M  +1    -3    src/lib/graphicsview/GeoGraphicsItem.h
> > 
> > http://commits.kde.org/marble/ff6a02a7bbf47c1195d183da2233653260084c3e
> > 
> > diff --git a/src/lib/ViewportParams.cpp b/src/lib/ViewportParams.cpp
> > index c83d884..52b8b64 100644
> > --- a/src/lib/ViewportParams.cpp
> > +++ b/src/lib/ViewportParams.cpp
> > @@ -316,7 +316,7 @@ void ViewportParams::centerCoordinates( qreal
> > &centerLon, qreal &centerLat ) con
> > 
> >      centerLat = d->m_centerLatitude;
> >  
> >  }
> > 
> > -GeoDataLatLonAltBox ViewportParams::viewLatLonAltBox() const
> > +GeoDataLatLonAltBox& ViewportParams::viewLatLonAltBox() const
> > 
> >  {
> >  
> >      if (d->m_dirtyBox) {
> >      
> >          d->m_viewLatLonAltBox = d->m_currentProjection->latLonAltBox(
> >          QRect( QPoint( 0, 0 ),
> > 
> > diff --git a/src/lib/ViewportParams.h b/src/lib/ViewportParams.h
> > index 41d29cf..9cfadd1 100644
> > --- a/src/lib/ViewportParams.h
> > +++ b/src/lib/ViewportParams.h
> > @@ -54,7 +54,7 @@ class MARBLE_EXPORT ViewportParams
> > 
> >      int polarity() const;
> > 
> > -    GeoDataLatLonAltBox viewLatLonAltBox() const;
> > +    GeoDataLatLonAltBox& viewLatLonAltBox() const;
> > 
> >      GeoDataLatLonAltBox latLonAltBox( const QRect &screenRect ) const;
> > 
> > diff --git a/src/lib/geodata/data/GeoDataGeometry.cpp
> > b/src/lib/geodata/data/GeoDataGeometry.cpp index 724755d..845513a 100644
> > --- a/src/lib/geodata/data/GeoDataGeometry.cpp
> > +++ b/src/lib/geodata/data/GeoDataGeometry.cpp
> > @@ -115,9 +115,9 @@ void GeoDataGeometry::setAltitudeMode( const
> > AltitudeMode altitudeMode )
> > 
> >      d->m_altitudeMode = altitudeMode;
> >  
> >  }
> > 
> > -GeoDataLatLonAltBox GeoDataGeometry::latLonAltBox() const
> > +GeoDataLatLonAltBox& GeoDataGeometry::latLonAltBox() const
> > 
> >  {
> > 
> > -    return GeoDataLatLonAltBox();
> > +    return d->m_latLonAltBox;
> > 
> >  }
> >  
> >  void GeoDataGeometry::pack( QDataStream& stream ) const
> > 
> > diff --git a/src/lib/geodata/data/GeoDataGeometry.h
> > b/src/lib/geodata/data/GeoDataGeometry.h index b37c0a2..a389cdc 100644
> > --- a/src/lib/geodata/data/GeoDataGeometry.h
> > +++ b/src/lib/geodata/data/GeoDataGeometry.h
> > @@ -66,7 +66,7 @@ class GEODATA_EXPORT GeoDataGeometry : public
> > GeoDataObject
> > 
> >      AltitudeMode altitudeMode() const;
> >      void setAltitudeMode( const AltitudeMode altitudeMode );
> > 
> > -    virtual GeoDataLatLonAltBox latLonAltBox() const;
> > +    virtual GeoDataLatLonAltBox& latLonAltBox() const;
> > 
> >      /// Serialize the contents of the feature to @p stream.
> >      virtual void pack( QDataStream& stream ) const;
> > 
> > diff --git a/src/lib/geodata/data/GeoDataGeometry_p.h
> > b/src/lib/geodata/data/GeoDataGeometry_p.h index a5f981c..e333d87 100644
> > --- a/src/lib/geodata/data/GeoDataGeometry_p.h
> > +++ b/src/lib/geodata/data/GeoDataGeometry_p.h
> > @@ -16,6 +16,7 @@
> > 
> >  #include "GeoDataGeometry.h"
> > 
> > +#include "GeoDataLatLonAltBox.h"
> > 
> >  #include "GeoDataTypes.h"
> >  
> >  namespace Marble
> > 
> > @@ -67,7 +68,8 @@ class GeoDataGeometryPrivate
> > 
> >      bool         m_extrude;
> >      AltitudeMode m_altitudeMode;
> > 
> > -
> > +    GeoDataLatLonAltBox m_latLonAltBox;
> > +
> > 
> >      QAtomicInt  ref;
> >  
> >  };
> > 
> > diff --git a/src/lib/geodata/data/GeoDataLatLonAltBox.cpp
> > b/src/lib/geodata/data/GeoDataLatLonAltBox.cpp index 634286c..6007425
> > 100644
> > --- a/src/lib/geodata/data/GeoDataLatLonAltBox.cpp
> > +++ b/src/lib/geodata/data/GeoDataLatLonAltBox.cpp
> > @@ -62,6 +62,17 @@ GeoDataLatLonAltBox& GeoDataLatLonAltBox::operator=(
> > const GeoDataLatLonAltBox &
> > 
> >  }
> > 
> > +GeoDataLatLonAltBox& GeoDataLatLonAltBox::operator=( const
> > GeoDataCoordinates &other ) +{
> > +    setWest( other.longitude() );
> > +    setEast( other.longitude() );
> > +    setNorth( other.latitude() );
> > +    setSouth( other.latitude() );
> > +    setMinAltitude( other.altitude() );
> > +    setMaxAltitude( other.altitude() );
> > +    return *this;
> > +}
> > +
> > 
> >  GeoDataLatLonAltBox::GeoDataLatLonAltBox()
> >  
> >      : GeoDataLatLonBox(),
> >      : 
> >        d( new GeoDataLatLonAltBoxPrivate )
> > 
> > @@ -269,6 +280,14 @@ bool GeoDataLatLonAltBox::isNull() const
> > 
> >      return false;
> >  
> >  }
> > 
> > +void GeoDataLatLonAltBox::clear()
> > +{
> > +    GeoDataLatLonBox::clear();
> > +    d->m_minAltitude = 0;
> > +    d->m_maxAltitude = 0;
> > +    d->m_altitudeMode = ClampToGround;
> > +}
> > +
> > 
> >  void GeoDataLatLonAltBox::pack( QDataStream& stream ) const
> >  {
> >  
> >      GeoDataObject::pack( stream );
> > 
> > diff --git a/src/lib/geodata/data/GeoDataLatLonAltBox.h
> > b/src/lib/geodata/data/GeoDataLatLonAltBox.h index 15d2516..15f7d16
> > 100644
> > --- a/src/lib/geodata/data/GeoDataLatLonAltBox.h
> > +++ b/src/lib/geodata/data/GeoDataLatLonAltBox.h
> > @@ -64,6 +64,7 @@ class GEODATA_EXPORT GeoDataLatLonAltBox : public
> > GeoDataLatLonBox
> > 
> >      virtual ~GeoDataLatLonAltBox();
> >      
> >      GeoDataLatLonAltBox& operator=( const GeoDataLatLonAltBox& other );
> > 
> > +    GeoDataLatLonAltBox& operator=( const GeoDataCoordinates& other );
> > 
> >      /// Provides type information for downcasting a GeoData
> >      virtual const char* nodeType() const;
> > 
> > @@ -118,6 +119,11 @@ class GEODATA_EXPORT GeoDataLatLonAltBox : public
> > GeoDataLatLonBox
> > 
> >      bool isNull() const;
> >      
> >      /**
> > 
> > +     * @brief Resets the bounding box to its uninitialised state (and
> > thus contains nothing). +     */
> > +    virtual void clear();
> > +
> > +    /**
> > 
> >       * @brief returns the center of this box
> >       * @return a coordinate, body-center of the box
> >       */
> > 
> > diff --git a/src/lib/geodata/data/GeoDataLatLonBox.cpp
> > b/src/lib/geodata/data/GeoDataLatLonBox.cpp index 26fd76b..d810dab
> > 100644
> > --- a/src/lib/geodata/data/GeoDataLatLonBox.cpp
> > +++ b/src/lib/geodata/data/GeoDataLatLonBox.cpp
> > @@ -686,4 +686,9 @@ bool GeoDataLatLonBox::isEmpty() const
> > 
> >  {
> >  
> >      return *this == empty;
> >  
> >  }
> > 
> > +
> > +void GeoDataLatLonBox::clear()
> > +{
> > +    *this = empty;
> > +}
> > 
> >  }
> > 
> > diff --git a/src/lib/geodata/data/GeoDataLatLonBox.h
> > b/src/lib/geodata/data/GeoDataLatLonBox.h index 43662ef..8d0345a 100644
> > --- a/src/lib/geodata/data/GeoDataLatLonBox.h
> > +++ b/src/lib/geodata/data/GeoDataLatLonBox.h
> > @@ -166,6 +166,11 @@ class GEODATA_EXPORT GeoDataLatLonBox : public
> > GeoDataObject
> > 
> >       */
> >      
> >      virtual bool isEmpty() const;
> > 
> > +    /**
> > +     * @brief Resets the bounding box to its uninitialised state (and
> > thus contains nothing). +     */
> > +    virtual void clear();
> > +
> > 
> >      GeoDataLatLonBox operator|( const GeoDataLatLonBox& other ) const;
> >      
> >      /**
> > 
> > diff --git a/src/lib/geodata/data/GeoDataLineString.cpp
> > b/src/lib/geodata/data/GeoDataLineString.cpp index 04c8115..cc8ac79
> > 100644
> > --- a/src/lib/geodata/data/GeoDataLineString.cpp
> > +++ b/src/lib/geodata/data/GeoDataLineString.cpp
> > @@ -533,7 +533,7 @@ void GeoDataLineStringPrivate::toDateLineCorrected(
> > 
> >      lineStrings << dateLineCorrected;
> >  
> >  }
> > 
> > -GeoDataLatLonAltBox GeoDataLineString::latLonAltBox() const
> > +GeoDataLatLonAltBox& GeoDataLineString::latLonAltBox() const
> > 
> >  {
> >  
> >      // GeoDataLatLonAltBox::fromLineString is very expensive
> >      // that's why we recreate it only if the m_dirtyBox
> > 
> > diff --git a/src/lib/geodata/data/GeoDataLineString.h
> > b/src/lib/geodata/data/GeoDataLineString.h index 92715f3..2a627d1 100644
> > --- a/src/lib/geodata/data/GeoDataLineString.h
> > +++ b/src/lib/geodata/data/GeoDataLineString.h
> > @@ -144,7 +144,7 @@ class GEODATA_EXPORT GeoDataLineString : public
> > GeoDataGeometry
> > 
> >      \see GeoDataLatLonAltBox
> >  
> >  */
> > 
> > -   virtual GeoDataLatLonAltBox latLonAltBox() const;
> > +   virtual GeoDataLatLonAltBox& latLonAltBox() const;
> > 
> >  /**
> >  
> >    * @brief Returns the length of LineString across a sphere starting
> >    from a coordinate in LineString
> > 
> > diff --git a/src/lib/geodata/data/GeoDataLineString_p.h
> > b/src/lib/geodata/data/GeoDataLineString_p.h index 13884dd..8559e31
> > 100644
> > --- a/src/lib/geodata/data/GeoDataLineString_p.h
> > +++ b/src/lib/geodata/data/GeoDataLineString_p.h
> > @@ -92,7 +92,6 @@ class GeoDataLineStringPrivate : public
> > GeoDataGeometryPrivate
> > 
> >      QVector<GeoDataLineString*>  m_rangeCorrected;
> >      bool                        m_dirtyRange;
> > 
> > -    GeoDataLatLonAltBox         m_latLonAltBox;
> > 
> >      bool                        m_dirtyBox; // tells whether there have
> >      been changes to the
> >      
> >                                              // GeoDataPoints since the
> >                                              LatLonAltBox has // been
> >                                              calculated. Saves
> >                                              performance.
> > 
> > diff --git a/src/lib/geodata/data/GeoDataMultiGeometry.cpp
> > b/src/lib/geodata/data/GeoDataMultiGeometry.cpp index d65ef6c..6395212
> > 100644
> > --- a/src/lib/geodata/data/GeoDataMultiGeometry.cpp
> > +++ b/src/lib/geodata/data/GeoDataMultiGeometry.cpp
> > @@ -42,23 +42,23 @@ GeoDataMultiGeometryPrivate*
> > GeoDataMultiGeometry::p() const
> > 
> >      return static_cast<GeoDataMultiGeometryPrivate*>(d);
> >  
> >  }
> > 
> > -GeoDataLatLonAltBox GeoDataMultiGeometry::latLonAltBox() const
> > +GeoDataLatLonAltBox& GeoDataMultiGeometry::latLonAltBox() const
> > 
> >  {
> >  
> >      QVector<GeoDataGeometry*>::const_iterator it =
> >      p()->m_vector.constBegin();
> >      QVector<GeoDataGeometry*>::const_iterator end =
> >      p()->m_vector.constEnd();
> > 
> > -    GeoDataLatLonAltBox box;
> > +    p()->m_latLonAltBox.clear();
> > 
> >      for (; it != end; ++it) {
> >      
> >          if ( !(*it)->latLonAltBox().isEmpty() ) {
> > 
> > -            if ( box.isEmpty() ) {
> > -                box = (*it)->latLonAltBox();
> > +            if ( p()->m_latLonAltBox.isEmpty() ) {
> > +                p()->m_latLonAltBox = (*it)->latLonAltBox();
> > 
> >              }
> >              else {
> > 
> > -                box |= (*it)->latLonAltBox();
> > +                p()->m_latLonAltBox |= (*it)->latLonAltBox();
> > 
> >              }
> >          
> >          }
> >      
> >      }
> > 
> > -    return box;
> > +    return p()->m_latLonAltBox;
> > 
> >  }
> >  
> >  int GeoDataMultiGeometry::size() const
> > 
> > diff --git a/src/lib/geodata/data/GeoDataMultiGeometry.h
> > b/src/lib/geodata/data/GeoDataMultiGeometry.h index 9ef703b..fc9743c
> > 100644
> > --- a/src/lib/geodata/data/GeoDataMultiGeometry.h
> > +++ b/src/lib/geodata/data/GeoDataMultiGeometry.h
> > @@ -38,7 +38,7 @@ class GEODATA_EXPORT GeoDataMultiGeometry : public
> > GeoDataGeometry
> > 
> >      virtual ~GeoDataMultiGeometry();
> > 
> > -    virtual GeoDataLatLonAltBox latLonAltBox() const;
> > +    virtual GeoDataLatLonAltBox& latLonAltBox() const;
> > 
> >      int size() const;
> >      GeoDataGeometry& at( int pos );
> > 
> > diff --git a/src/lib/geodata/data/GeoDataPoint.cpp
> > b/src/lib/geodata/data/GeoDataPoint.cpp index 8e71eaa..5468806 100644
> > --- a/src/lib/geodata/data/GeoDataPoint.cpp
> > +++ b/src/lib/geodata/data/GeoDataPoint.cpp
> > @@ -35,6 +35,7 @@ GeoDataPoint::GeoDataPoint( qreal _lon, qreal _lat,
> > qreal _alt,
> > 
> >                          static_cast<GeoDataCoordinates::Unit>( unit ),
> >                          _detail ),
> >      
> >      GeoDataGeometry( new GeoDataPointPrivate )
> >  
> >  {
> > 
> > +    p()->m_latLonAltBox = *this;
> > 
> >  }
> >  
> >  GeoDataPoint::GeoDataPoint( const GeoDataPoint& other )
> > 
> > @@ -42,12 +43,14 @@ GeoDataPoint::GeoDataPoint( const GeoDataPoint& other
> > )
> > 
> >      GeoDataGeometry( other )
> >  
> >  {
> > 
> > +    p()->m_latLonAltBox = *this;
> > 
> >  }
> >  
> >  GeoDataPoint::GeoDataPoint( const GeoDataCoordinates& other )
> >  
> >    : GeoDataCoordinates( other ),
> >    
> >    GeoDataGeometry ( new GeoDataPointPrivate )
> >  
> >  {
> > 
> > +    p()->m_latLonAltBox = *this;
> > 
> >  }
> >  
> >  GeoDataPoint::GeoDataPoint( const GeoDataGeometry& other )
> > 
> > @@ -70,11 +73,6 @@ GeoDataPointPrivate* GeoDataPoint::p() const
> > 
> >      return static_cast<GeoDataPointPrivate*>(GeoDataGeometry::d);
> >  
> >  }
> > 
> > -GeoDataLatLonAltBox GeoDataPoint::latLonAltBox() const
> > -{
> > -    return GeoDataLatLonAltBox(*this);
> > -}
> > -
> > 
> >  const char* GeoDataPoint::nodeType() const
> >  {
> >  
> >      return GeoDataTypes::GeoDataPointType;
> > 
> > diff --git a/src/lib/geodata/data/GeoDataPoint.h
> > b/src/lib/geodata/data/GeoDataPoint.h index 15cea03..b63eec7 100644
> > --- a/src/lib/geodata/data/GeoDataPoint.h
> > +++ b/src/lib/geodata/data/GeoDataPoint.h
> > @@ -72,8 +72,6 @@ class GEODATA_EXPORT GeoDataPoint : public
> > GeoDataCoordinates,
> > 
> >      /// Provides type information for downcasting a GeoData
> >      virtual const char* nodeType() const;
> > 
> > -    virtual GeoDataLatLonAltBox latLonAltBox() const;
> > -
> > 
> >      // Type definitions
> >      typedef QVector<GeoDataPoint> Vector;
> > 
> > diff --git a/src/lib/geodata/data/GeoDataPolygon.cpp
> > b/src/lib/geodata/data/GeoDataPolygon.cpp index 6b65c0d..6896d2f 100644
> > --- a/src/lib/geodata/data/GeoDataPolygon.cpp
> > +++ b/src/lib/geodata/data/GeoDataPolygon.cpp
> > @@ -77,7 +77,7 @@ void GeoDataPolygon::setTessellationFlags(
> > TessellationFlags f )
> > 
> >      p()->m_tessellationFlags = f;
> >  
> >  }
> > 
> > -GeoDataLatLonAltBox GeoDataPolygon::latLonAltBox() const
> > +GeoDataLatLonAltBox& GeoDataPolygon::latLonAltBox() const
> > 
> >  {
> >  
> >      return p()->outer.latLonAltBox();
> >  
> >  }
> > 
> > diff --git a/src/lib/geodata/data/GeoDataPolygon.h
> > b/src/lib/geodata/data/GeoDataPolygon.h index 3552af0..87decdb 100644
> > --- a/src/lib/geodata/data/GeoDataPolygon.h
> > +++ b/src/lib/geodata/data/GeoDataPolygon.h
> > @@ -144,7 +144,7 @@ class GEODATA_EXPORT GeoDataPolygon : public
> > GeoDataGeometry
> > 
> >      \see GeoDataLatLonAltBox
> >  
> >  */
> > 
> > -    virtual GeoDataLatLonAltBox latLonAltBox() const;
> > +    virtual GeoDataLatLonAltBox& latLonAltBox() const;
> > 
> >  /*!
> >  
> >      \brief Returns the outer boundary that is represented as a
> >      LinearRing.
> > 
> > diff --git a/src/lib/geodata/data/GeoDataTrack.cpp
> > b/src/lib/geodata/data/GeoDataTrack.cpp index 312084a..53ca029 100644
> > --- a/src/lib/geodata/data/GeoDataTrack.cpp
> > +++ b/src/lib/geodata/data/GeoDataTrack.cpp
> > @@ -277,7 +277,7 @@ EnumGeometryId GeoDataTrack::geometryId() const
> > 
> >      return GeoDataTrackId;
> >  
> >  }
> > 
> > -GeoDataLatLonAltBox GeoDataTrack::latLonAltBox() const
> > +GeoDataLatLonAltBox& GeoDataTrack::latLonAltBox() const
> > 
> >  {
> >  
> >      return lineString()->latLonAltBox();
> >  
> >  }
> > 
> > diff --git a/src/lib/geodata/data/GeoDataTrack.h
> > b/src/lib/geodata/data/GeoDataTrack.h index f43cff6..a4ec403 100644
> > --- a/src/lib/geodata/data/GeoDataTrack.h
> > +++ b/src/lib/geodata/data/GeoDataTrack.h
> > 
> > @@ -175,7 +175,7 @@ public:
> >      virtual const char* nodeType() const;
> >      virtual EnumGeometryId geometryId() const;
> > 
> > -    virtual GeoDataLatLonAltBox latLonAltBox() const;
> > +    virtual GeoDataLatLonAltBox& latLonAltBox() const;
> > 
> >      virtual void pack( QDataStream& stream ) const;
> >      virtual void unpack( QDataStream& stream );
> > 
> > diff --git a/src/lib/geodata/graphicsitem/GeoImageGraphicsItem.cpp
> > b/src/lib/geodata/graphicsitem/GeoImageGraphicsItem.cpp index
> > 0766ad4..66d9334 100644
> > --- a/src/lib/geodata/graphicsitem/GeoImageGraphicsItem.cpp
> > +++ b/src/lib/geodata/graphicsitem/GeoImageGraphicsItem.cpp
> > @@ -10,6 +10,7 @@
> > 
> >  #include "GeoImageGraphicsItem.h"
> > 
> > +#include "GeoGraphicsItem_p.h"
> > 
> >  #include "GeoPainter.h"
> >  #include "ViewportParams.h"
> > 
> > @@ -18,12 +19,12 @@ namespace Marble
> > 
> >  void GeoImageGraphicsItem::setLatLonBox( const GeoDataLatLonBox &box )
> >  {
> > 
> > -    m_latLonBox = box;
> > +    p()->m_latLonAltBox = box;
> > 
> >  }
> > 
> > -GeoDataLatLonBox GeoImageGraphicsItem::latLonBox() const
> > +GeoDataLatLonBox& GeoImageGraphicsItem::latLonBox() const
> > 
> >  {
> > 
> > -    return m_latLonBox;
> > +    return p()->m_latLonAltBox;
> > 
> >  }
> >  
> >  void GeoImageGraphicsItem::setImage( const QImage &image )
> > 
> > @@ -55,8 +56,8 @@ void GeoImageGraphicsItem::paint( GeoPainter* painter,
> > ViewportParams* viewport,
> > 
> >      bool unloadImage = true;
> >      if ( viewport->projection() != Spherical ) {
> >      
> >          qreal x1(0.0), x2(0.0), y1( 0.0 ), y2( 0.0 );
> > 
> > -        viewport->screenCoordinates( m_latLonBox.west(),
> > m_latLonBox.north(), x1, y1 ); -        viewport->screenCoordinates(
> > m_latLonBox.east(), m_latLonBox.south(), x2, y2 ); +       
> > viewport->screenCoordinates( p()->m_latLonAltBox.west(),
> > p()->m_latLonAltBox.north(), x1, y1 ); +       
> > viewport->screenCoordinates( p()->m_latLonAltBox.east(),
> > p()->m_latLonAltBox.south(), x2, y2 );
> > 
> >          QRectF const screen( QPointF( 0, 0), viewport->size() );
> >          QRectF const position( x1, y1, x2-x1, y2-y1 );
> >          if ( !(screen & position).isEmpty() ) {
> > 
> > @@ -78,10 +79,4 @@ void GeoImageGraphicsItem::paint( GeoPainter* painter,
> > ViewportParams* viewport,
> > 
> >          m_image = QImage();
> >      
> >      }
> >  
> >  }
> > 
> > -
> > -GeoDataLatLonAltBox GeoImageGraphicsItem::latLonAltBox() const
> > -{
> > -    return m_latLonBox;
> > -}
> > -
> > 
> >  }
> > 
> > diff --git a/src/lib/geodata/graphicsitem/GeoImageGraphicsItem.h
> > b/src/lib/geodata/graphicsitem/GeoImageGraphicsItem.h index
> > f27f1a0..6d1c32a 100644
> > --- a/src/lib/geodata/graphicsitem/GeoImageGraphicsItem.h
> > +++ b/src/lib/geodata/graphicsitem/GeoImageGraphicsItem.h
> > @@ -25,7 +25,7 @@ class MARBLE_EXPORT GeoImageGraphicsItem : public
> > GeoGraphicsItem
> > 
> >  public:
> >      void setLatLonBox( const GeoDataLatLonBox& box );
> > 
> > -    GeoDataLatLonBox latLonBox() const;
> > +    GeoDataLatLonBox& latLonBox() const;
> > 
> >      void setImage( const QImage &image );
> > 
> > @@ -38,11 +38,7 @@ public:
> >      virtual void paint( GeoPainter* painter, ViewportParams *viewport,
> >      
> >                          const QString &renderPos, GeoSceneLayer *layer
> >                          );
> > 
> > -    virtual GeoDataLatLonAltBox latLonAltBox() const;
> > -
> > 
> >  protected:
> > -    GeoDataLatLonBox m_latLonBox;
> > -
> > 
> >      QImage m_image;
> >      
> >      QString m_imageFile;
> > 
> > diff --git a/src/lib/geodata/graphicsitem/GeoLineStringGraphicsItem.cpp
> > b/src/lib/geodata/graphicsitem/GeoLineStringGraphicsItem.cpp index
> > 529fd5f..23c2d19 100644
> > --- a/src/lib/geodata/graphicsitem/GeoLineStringGraphicsItem.cpp
> > +++ b/src/lib/geodata/graphicsitem/GeoLineStringGraphicsItem.cpp
> > @@ -43,7 +43,7 @@ void GeoLineStringGraphicsItem::coordinate( qreal
> > &longitude, qreal &latitude, q
> > 
> >      altitude = coords.altitude();
> >  
> >  }
> > 
> > -GeoDataLatLonAltBox GeoLineStringGraphicsItem::latLonAltBox() const
> > +GeoDataLatLonAltBox& GeoLineStringGraphicsItem::latLonAltBox() const
> > 
> >  {
> >  
> >      return m_lineString->latLonAltBox();
> >  
> >  }
> > 
> > diff --git a/src/lib/geodata/graphicsitem/GeoLineStringGraphicsItem.h
> > b/src/lib/geodata/graphicsitem/GeoLineStringGraphicsItem.h index
> > f50e2e5..4982857 100644
> > --- a/src/lib/geodata/graphicsitem/GeoLineStringGraphicsItem.h
> > +++ b/src/lib/geodata/graphicsitem/GeoLineStringGraphicsItem.h
> > 
> > @@ -30,7 +30,7 @@ public:
> >      virtual GeoDataCoordinates coordinate() const;
> >      virtual void coordinate( qreal &longitude, qreal &latitude, qreal
> >      &altitude ) const;
> > 
> > -    virtual GeoDataLatLonAltBox latLonAltBox() const;
> > +    virtual GeoDataLatLonAltBox& latLonAltBox() const;
> > 
> >      virtual void paint( GeoPainter* painter, ViewportParams *viewport,
> >      
> >                          const QString &renderPos, GeoSceneLayer *layer
> >                          );
> > 
> > diff --git a/src/lib/geodata/graphicsitem/GeoPhotoGraphicsItem.cpp
> > b/src/lib/geodata/graphicsitem/GeoPhotoGraphicsItem.cpp index
> > e17913d..16533a1 100644
> > --- a/src/lib/geodata/graphicsitem/GeoPhotoGraphicsItem.cpp
> > +++ b/src/lib/geodata/graphicsitem/GeoPhotoGraphicsItem.cpp
> > @@ -96,7 +96,7 @@ void GeoPhotoGraphicsItem::paint( GeoPainter* painter,
> > ViewportParams* viewport,
> > 
> >      }
> >  
> >  }
> > 
> > -GeoDataLatLonAltBox GeoPhotoGraphicsItem::latLonAltBox() const
> > +GeoDataLatLonAltBox& GeoPhotoGraphicsItem::latLonAltBox() const
> > 
> >  {
> >  
> >      return m_point.latLonAltBox();
> >  
> >  }
> > 
> > diff --git a/src/lib/geodata/graphicsitem/GeoPhotoGraphicsItem.h
> > b/src/lib/geodata/graphicsitem/GeoPhotoGraphicsItem.h index
> > ec382c9..6d824b6 100644
> > --- a/src/lib/geodata/graphicsitem/GeoPhotoGraphicsItem.h
> > +++ b/src/lib/geodata/graphicsitem/GeoPhotoGraphicsItem.h
> > 
> > @@ -38,7 +38,7 @@ public:
> >      virtual void paint( GeoPainter* painter, ViewportParams *viewport,
> >      
> >                          const QString &renderPos, GeoSceneLayer *layer
> >                          );
> > 
> > -    virtual GeoDataLatLonAltBox latLonAltBox() const;
> > +    virtual GeoDataLatLonAltBox& latLonAltBox() const;
> > 
> >  protected:
> >      GeoDataPoint m_point;
> > 
> > diff --git a/src/lib/geodata/graphicsitem/GeoPointGraphicsItem.cpp
> > b/src/lib/geodata/graphicsitem/GeoPointGraphicsItem.cpp index
> > 6abbc2b..f136a5c 100644
> > --- a/src/lib/geodata/graphicsitem/GeoPointGraphicsItem.cpp
> > +++ b/src/lib/geodata/graphicsitem/GeoPointGraphicsItem.cpp
> > @@ -39,7 +39,7 @@ void GeoPointGraphicsItem::paint( GeoPainter* painter,
> > ViewportParams* viewport,
> > 
> >      painter->drawPoint( m_point );
> >  
> >  }
> > 
> > -GeoDataLatLonAltBox GeoPointGraphicsItem::latLonAltBox() const
> > +GeoDataLatLonAltBox& GeoPointGraphicsItem::latLonAltBox() const
> > 
> >  {
> >  
> >      return m_point.latLonAltBox();
> >  
> >  }
> > 
> > diff --git a/src/lib/geodata/graphicsitem/GeoPointGraphicsItem.h
> > b/src/lib/geodata/graphicsitem/GeoPointGraphicsItem.h index
> > 0bf4547..3df2b57 100644
> > --- a/src/lib/geodata/graphicsitem/GeoPointGraphicsItem.h
> > +++ b/src/lib/geodata/graphicsitem/GeoPointGraphicsItem.h
> > 
> > @@ -30,7 +30,7 @@ public:
> >      virtual void paint( GeoPainter* painter, ViewportParams *viewport,
> >      
> >                          const QString &renderPos, GeoSceneLayer *layer
> >                          );
> > 
> > -    virtual GeoDataLatLonAltBox latLonAltBox() const;
> > +    virtual GeoDataLatLonAltBox& latLonAltBox() const;
> > 
> >  protected:
> >      GeoDataPoint    m_point;
> > 
> > diff --git a/src/lib/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp
> > b/src/lib/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp index
> > 67a0e06..3b93c32 100644
> > --- a/src/lib/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp
> > +++ b/src/lib/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp
> > @@ -73,14 +73,14 @@ void GeoPolygonGraphicsItem::coordinate( qreal
> > &longitude, qreal &latitude, qrea
> > 
> >      altitude = coords.altitude();
> >  
> >  }
> > 
> > -GeoDataLatLonAltBox GeoPolygonGraphicsItem::latLonAltBox() const
> > +GeoDataLatLonAltBox& GeoPolygonGraphicsItem::latLonAltBox() const
> > 
> >  {
> >  
> >      if( m_polygon ) {
> >      
> >          return m_polygon->latLonAltBox();
> >      
> >      } else if ( m_ring ) {
> >      
> >          return m_ring->latLonAltBox();
> >      
> >      } else {
> > 
> > -        return GeoDataLatLonAltBox::fromLineString( GeoDataLineString()
> > << GeoDataCoordinates() ); +        return
> > GeoGraphicsItem::latLonAltBox();
> > 
> >      }
> >  
> >  }
> > 
> > diff --git a/src/lib/geodata/graphicsitem/GeoPolygonGraphicsItem.h
> > b/src/lib/geodata/graphicsitem/GeoPolygonGraphicsItem.h index
> > 9345207..06609e5 100644
> > --- a/src/lib/geodata/graphicsitem/GeoPolygonGraphicsItem.h
> > +++ b/src/lib/geodata/graphicsitem/GeoPolygonGraphicsItem.h
> > 
> > @@ -32,7 +32,7 @@ public:
> >      virtual GeoDataCoordinates coordinate() const;
> >      virtual void coordinate( qreal &longitude, qreal &latitude, qreal
> >      &altitude ) const;
> > 
> > -    virtual GeoDataLatLonAltBox latLonAltBox() const;
> > +    virtual GeoDataLatLonAltBox& latLonAltBox() const;
> > 
> >      virtual void paint( GeoPainter* painter, ViewportParams *viewport,
> >      
> >                          const QString &renderPos, GeoSceneLayer *layer
> >                          );
> > 
> > diff --git a/src/lib/graphicsview/GeoGraphicsItem.cpp
> > b/src/lib/graphicsview/GeoGraphicsItem.cpp index 3d4d5c4..5e83bff 100644
> > --- a/src/lib/graphicsview/GeoGraphicsItem.cpp
> > +++ b/src/lib/graphicsview/GeoGraphicsItem.cpp
> > @@ -109,7 +109,7 @@ void GeoGraphicsItem::setMaxLodPixels( int pixels )
> > 
> >      p()->m_maxLodPixels = pixels;
> >  
> >  }
> > 
> > -GeoDataLatLonAltBox GeoGraphicsItem::latLonAltBox() const
> > +GeoDataLatLonAltBox& GeoGraphicsItem::latLonAltBox() const
> > 
> >  {
> >  
> >      return p()->m_latLonAltBox;
> >  
> >  }
> > 
> > diff --git a/src/lib/graphicsview/GeoGraphicsItem.h
> > b/src/lib/graphicsview/GeoGraphicsItem.h index f56e3c2..708715f 100644
> > --- a/src/lib/graphicsview/GeoGraphicsItem.h
> > +++ b/src/lib/graphicsview/GeoGraphicsItem.h
> > @@ -138,7 +138,7 @@ class MARBLE_EXPORT GeoGraphicsItem : public
> > MarbleGraphicsItem
> > 
> >      /**
> >      
> >       * Returns the box that is used to determine if an item is active or
> >       inactive. */
> > 
> > -    virtual GeoDataLatLonAltBox latLonAltBox() const;
> > +    virtual GeoDataLatLonAltBox& latLonAltBox() const;
> > 
> >      /**
> >      
> >       * Set the box used to determine if an item is active or inactive.
> >       If an empty box is passed
> > 
> > @@ -164,8 +164,6 @@ class MARBLE_EXPORT GeoGraphicsItem : public
> > MarbleGraphicsItem
> > 
> >   protected:
> >      explicit GeoGraphicsItem( GeoGraphicsItemPrivate *d_ptr );
> > 
> > -
> > 
> > - private:
> >      GeoGraphicsItemPrivate *p() const;
> >  
> >  };
> 
> _______________________________________________
> Marble-devel mailing list
> Marble-devel at kde.org
> https://mail.kde.org/mailman/listinfo/marble-devel


More information about the Marble-devel mailing list