2 changes: 1 addition & 1 deletion src/core/pal/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ namespace pal
bool showPartial;


typedef bool (*FnIsCancelled)(void* ctx);
typedef bool ( *FnIsCancelled )( void* ctx );
/** Callback that may be called from PAL to check whether the job has not been cancelled in meanwhile */
FnIsCancelled fnIsCancelled;
/** Application-specific context for the cancellation check function */
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsdiagramrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ void QgsDiagramRendererV2::setDiagram( QgsDiagram* d )
mDiagram = d;
}

QgsDiagramRendererV2::QgsDiagramRendererV2(const QgsDiagramRendererV2& other)
: mDiagram( other.mDiagram ? other.mDiagram->clone() : 0 )
QgsDiagramRendererV2::QgsDiagramRendererV2( const QgsDiagramRendererV2& other )
: mDiagram( other.mDiagram ? other.mDiagram->clone() : 0 )
{
}

Expand Down
38 changes: 19 additions & 19 deletions src/core/qgsfeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,25 @@ class CORE_EXPORT QgsAbstractFeatureIterator
template<typename T>
class QgsAbstractFeatureIteratorFromSource : public QgsAbstractFeatureIterator
{
public:
QgsAbstractFeatureIteratorFromSource( T* source, bool ownSource, const QgsFeatureRequest& request )
: QgsAbstractFeatureIterator( request ), mSource( source ), mOwnSource( ownSource )
{
mSource->iteratorOpened( this );
}

~QgsAbstractFeatureIteratorFromSource()
{
if ( mOwnSource )
delete mSource;
}

protected:
//! to be called by from subclass in close()
void iteratorClosed() { mSource->iteratorClosed( this ); }

T* mSource;
bool mOwnSource;
public:
QgsAbstractFeatureIteratorFromSource( T* source, bool ownSource, const QgsFeatureRequest& request )
: QgsAbstractFeatureIterator( request ), mSource( source ), mOwnSource( ownSource )
{
mSource->iteratorOpened( this );
}

~QgsAbstractFeatureIteratorFromSource()
{
if ( mOwnSource )
delete mSource;
}

protected:
//! to be called by from subclass in close()
void iteratorClosed() { mSource->iteratorClosed( this ); }

T* mSource;
bool mOwnSource;
};


Expand Down
16 changes: 8 additions & 8 deletions src/core/qgsfeaturerequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,18 @@ class QgsAbstractFeatureIterator;
*/
class CORE_EXPORT QgsAbstractFeatureSource
{
public:
virtual ~QgsAbstractFeatureSource();
public:
virtual ~QgsAbstractFeatureSource();

virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request ) = 0;
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request ) = 0;

protected:
void iteratorOpened( QgsAbstractFeatureIterator* it );
void iteratorClosed( QgsAbstractFeatureIterator* it );
protected:
void iteratorOpened( QgsAbstractFeatureIterator* it );
void iteratorClosed( QgsAbstractFeatureIterator* it );

QSet< QgsAbstractFeatureIterator* > mActiveIterators;
QSet< QgsAbstractFeatureIterator* > mActiveIterators;

template<typename> friend class QgsAbstractFeatureIteratorFromSource;
template<typename> friend class QgsAbstractFeatureIteratorFromSource;
};

#endif // QGSFEATUREREQUEST_H
24 changes: 12 additions & 12 deletions src/core/qgsmaplayerrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@
*/
class CORE_EXPORT QgsMapLayerRenderer
{
public:
QgsMapLayerRenderer( const QString& layerID ) : mLayerID( layerID ) {}
virtual ~QgsMapLayerRenderer() {}
public:
QgsMapLayerRenderer( const QString& layerID ) : mLayerID( layerID ) {}
virtual ~QgsMapLayerRenderer() {}

//! Do the rendering (based on data stored in the class)
virtual bool render() = 0;
//! Do the rendering (based on data stored in the class)
virtual bool render() = 0;

//! Return list of errors (problems) that happened during the rendering
QStringList errors() const { return mErrors; }
//! Return list of errors (problems) that happened during the rendering
QStringList errors() const { return mErrors; }

//! Get access to the ID of the layer rendered by this class
QString layerID() const { return mLayerID; }
//! Get access to the ID of the layer rendered by this class
QString layerID() const { return mLayerID; }

protected:
QStringList mErrors;
QString mLayerID;
protected:
QStringList mErrors;
QString mLayerID;
};

#endif // QGSMAPLAYERRENDERER_H
6 changes: 3 additions & 3 deletions src/core/qgsmaprenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,9 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
if (( mRenderContext.useAdvancedEffects() ) && ( ml->type() == QgsMapLayer::VectorLayer ) )
{
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( ml );
if ( (( vl->blendMode() != QPainter::CompositionMode_SourceOver )
|| ( vl->featureBlendMode() != QPainter::CompositionMode_SourceOver )
|| ( vl->layerTransparency() != 0 ) ) )
if ((( vl->blendMode() != QPainter::CompositionMode_SourceOver )
|| ( vl->featureBlendMode() != QPainter::CompositionMode_SourceOver )
|| ( vl->layerTransparency() != 0 ) ) )
{
flattenedLayer = true;
mypFlattenedImage = new QImage( mRenderContext.painter()->device()->width(),
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsmaprenderercache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ bool QgsMapRendererCache::init( QgsRectangle extent, double scale )
QMutexLocker lock( &mMutex );

// check whether the params are the same
if (extent == mExtent &&
scale == mScale )
if ( extent == mExtent &&
scale == mScale )
return true;

// set new params
Expand Down Expand Up @@ -49,7 +49,7 @@ QImage QgsMapRendererCache::cacheImage( QString layerId )
void QgsMapRendererCache::layerDataChanged()
{
// TODO!
qDebug("nothing here yet");
qDebug( "nothing here yet" );
}


232 changes: 116 additions & 116 deletions src/core/qgsmaprendererjob.cpp

Large diffs are not rendered by default.

274 changes: 137 additions & 137 deletions src/core/qgsmaprendererjob.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,97 +36,97 @@ typedef QList<LayerRenderJob> LayerRenderJobs;
/** abstract base class renderer jobs that asynchronously start map rendering */
class CORE_EXPORT QgsMapRendererJob : public QObject
{
Q_OBJECT
public:
Q_OBJECT
public:

QgsMapRendererJob( const QgsMapSettings& settings );
QgsMapRendererJob( const QgsMapSettings& settings );

virtual ~QgsMapRendererJob() {}
virtual ~QgsMapRendererJob() {}

//! Start the rendering job and immediately return.
//! Does nothing if the rendering is already in progress.
virtual void start() = 0;
//! Start the rendering job and immediately return.
//! Does nothing if the rendering is already in progress.
virtual void start() = 0;

//! Stop the rendering job - does not return until the job has terminated.
//! Does nothing if the rendering is not active.
virtual void cancel() = 0;
//! Stop the rendering job - does not return until the job has terminated.
//! Does nothing if the rendering is not active.
virtual void cancel() = 0;

//! Block until the job has finished.
virtual void waitForFinished() = 0;
//! Block until the job has finished.
virtual void waitForFinished() = 0;

//! Tell whether the rendering job is currently running in background.
virtual bool isActive() const = 0;
//! Tell whether the rendering job is currently running in background.
virtual bool isActive() const = 0;

//! Get pointer to internal labeling engine (in order to get access to the results)
virtual QgsLabelingResults* takeLabelingResults() = 0;
//! Get pointer to internal labeling engine (in order to get access to the results)
virtual QgsLabelingResults* takeLabelingResults() = 0;

struct Error
{
Error( const QString& lid, const QString& msg ) : layerID( lid ), message( msg ) {}
struct Error
{
Error( const QString& lid, const QString& msg ) : layerID( lid ), message( msg ) {}

QString layerID;
QString message;
};
QString layerID;
QString message;
};

typedef QList<Error> Errors;
typedef QList<Error> Errors;

//! List of errors that happened during the rendering job - available when the rendering has been finished
Errors errors() const;
//! List of errors that happened during the rendering job - available when the rendering has been finished
Errors errors() const;


//! Assign a cache to be used for reading and storing rendered images of individual layers.
//! Does not take ownership of the object.
void setCache( QgsMapRendererCache* cache );
//! Assign a cache to be used for reading and storing rendered images of individual layers.
//! Does not take ownership of the object.
void setCache( QgsMapRendererCache* cache );

//! Set which vector layers should be cached while rendering
//! @note The way how geometries are cached is really suboptimal - this method may be removed in future releases
void setRequestedGeometryCacheForLayers( const QStringList& layerIds ) { mRequestedGeomCacheForLayers = layerIds; }
//! Set which vector layers should be cached while rendering
//! @note The way how geometries are cached is really suboptimal - this method may be removed in future releases
void setRequestedGeometryCacheForLayers( const QStringList& layerIds ) { mRequestedGeomCacheForLayers = layerIds; }

//! Find out how log it took to finish the job (in miliseconds)
int renderingTime() const { return mRenderingTime; }
//! Find out how log it took to finish the job (in miliseconds)
int renderingTime() const { return mRenderingTime; }

signals:
signals:

//! emitted when asynchronous rendering is finished (or canceled).
void finished();
//! emitted when asynchronous rendering is finished (or canceled).
void finished();

protected:
protected:

/** Convenience function to project an extent into the layer source
* CRS, but also split it into two extents if it crosses
* the +/- 180 degree line. Modifies the given extent to be in the
* source CRS coordinates, and if it was split, returns true, and
* also sets the contents of the r2 parameter
*/
static bool reprojectToLayerExtent(const QgsCoordinateTransform* ct, bool layerCrsGeographic, QgsRectangle& extent, QgsRectangle& r2 );
/** Convenience function to project an extent into the layer source
* CRS, but also split it into two extents if it crosses
* the +/- 180 degree line. Modifies the given extent to be in the
* source CRS coordinates, and if it was split, returns true, and
* also sets the contents of the r2 parameter
*/
static bool reprojectToLayerExtent( const QgsCoordinateTransform* ct, bool layerCrsGeographic, QgsRectangle& extent, QgsRectangle& r2 );

LayerRenderJobs prepareJobs( QPainter* painter, QgsPalLabeling* labelingEngine );
LayerRenderJobs prepareJobs( QPainter* painter, QgsPalLabeling* labelingEngine );

void cleanupJobs( LayerRenderJobs& jobs );
void cleanupJobs( LayerRenderJobs& jobs );

static QImage composeImage( const QgsMapSettings& settings, const LayerRenderJobs& jobs );
static QImage composeImage( const QgsMapSettings& settings, const LayerRenderJobs& jobs );

bool needTemporaryImage( QgsMapLayer* ml );
bool needTemporaryImage( QgsMapLayer* ml );

static void drawLabeling( const QgsMapSettings& settings, QgsRenderContext& renderContext, QgsPalLabeling* labelingEngine, QPainter* painter );
static void drawOldLabeling( const QgsMapSettings& settings, QgsRenderContext& renderContext );
static void drawNewLabeling( const QgsMapSettings& settings, QgsRenderContext& renderContext, QgsPalLabeling* labelingEngine );
static void drawLabeling( const QgsMapSettings& settings, QgsRenderContext& renderContext, QgsPalLabeling* labelingEngine, QPainter* painter );
static void drawOldLabeling( const QgsMapSettings& settings, QgsRenderContext& renderContext );
static void drawNewLabeling( const QgsMapSettings& settings, QgsRenderContext& renderContext, QgsPalLabeling* labelingEngine );

//! called when rendering has finished to update all layers' geometry caches
void updateLayerGeometryCaches();
//! called when rendering has finished to update all layers' geometry caches
void updateLayerGeometryCaches();

QgsMapSettings mSettings;
Errors mErrors;
QgsMapSettings mSettings;
Errors mErrors;

QgsMapRendererCache* mCache;
QgsMapRendererCache* mCache;

//! list of layer IDs for which the geometry cache should be updated
QStringList mRequestedGeomCacheForLayers;
//! map of geometry caches
QMap<QString, QgsGeometryCache> mGeometryCaches;
//! list of layer IDs for which the geometry cache should be updated
QStringList mRequestedGeomCacheForLayers;
//! map of geometry caches
QMap<QString, QgsGeometryCache> mGeometryCaches;

QTime mRenderingStart;
int mRenderingTime;
QTime mRenderingStart;
int mRenderingTime;
};


Expand All @@ -135,11 +135,11 @@ class CORE_EXPORT QgsMapRendererJob : public QObject
*/
class CORE_EXPORT QgsMapRendererQImageJob : public QgsMapRendererJob
{
public:
QgsMapRendererQImageJob( const QgsMapSettings& settings );
public:
QgsMapRendererQImageJob( const QgsMapSettings& settings );

//! Get a preview/resulting image
virtual QImage renderedImage() = 0;
//! Get a preview/resulting image
virtual QImage renderedImage() = 0;
};


Expand All @@ -149,31 +149,31 @@ class QgsMapRendererCustomPainterJob;
/** job implementation that renders everything sequentially in one thread */
class CORE_EXPORT QgsMapRendererSequentialJob : public QgsMapRendererQImageJob
{
Q_OBJECT
public:
QgsMapRendererSequentialJob( const QgsMapSettings& settings );
~QgsMapRendererSequentialJob();
Q_OBJECT
public:
QgsMapRendererSequentialJob( const QgsMapSettings& settings );
~QgsMapRendererSequentialJob();

virtual void start();
virtual void cancel();
virtual void waitForFinished();
virtual bool isActive() const;
virtual void start();
virtual void cancel();
virtual void waitForFinished();
virtual bool isActive() const;

virtual QgsLabelingResults* takeLabelingResults();
virtual QgsLabelingResults* takeLabelingResults();

// from QgsMapRendererJobWithPreview
virtual QImage renderedImage();
// from QgsMapRendererJobWithPreview
virtual QImage renderedImage();

public slots:
public slots:

void internalFinished();
void internalFinished();

protected:
protected:

QgsMapRendererCustomPainterJob* mInternalJob;
QImage mImage;
QPainter* mPainter;
QgsLabelingResults* mLabelingResults;
QgsMapRendererCustomPainterJob* mInternalJob;
QImage mImage;
QPainter* mPainter;
QgsLabelingResults* mLabelingResults;
};


Expand All @@ -182,47 +182,47 @@ public slots:
/** job implementation that renders all layers in parallel */
class CORE_EXPORT QgsMapRendererParallelJob : public QgsMapRendererQImageJob
{
Q_OBJECT
public:
QgsMapRendererParallelJob(const QgsMapSettings& settings);
~QgsMapRendererParallelJob();
Q_OBJECT
public:
QgsMapRendererParallelJob( const QgsMapSettings& settings );
~QgsMapRendererParallelJob();

virtual void start();
virtual void cancel();
virtual void waitForFinished();
virtual bool isActive() const;
virtual void start();
virtual void cancel();
virtual void waitForFinished();
virtual bool isActive() const;

virtual QgsLabelingResults* takeLabelingResults();
virtual QgsLabelingResults* takeLabelingResults();

// from QgsMapRendererJobWithPreview
virtual QImage renderedImage();
// from QgsMapRendererJobWithPreview
virtual QImage renderedImage();

protected slots:
//! layers are rendered, labeling is still pending
void renderLayersFinished();
//! all rendering is finished, including labeling
void renderingFinished();
protected slots:
//! layers are rendered, labeling is still pending
void renderLayersFinished();
//! all rendering is finished, including labeling
void renderingFinished();

protected:
protected:

static void renderLayerStatic(LayerRenderJob& job);
static void renderLabelsStatic( QgsMapRendererParallelJob* self );
static void renderLayerStatic( LayerRenderJob& job );
static void renderLabelsStatic( QgsMapRendererParallelJob* self );

protected:
protected:

QImage mFinalImage;
QImage mFinalImage;

enum { Idle, RenderingLayers, RenderingLabels } mStatus;
enum { Idle, RenderingLayers, RenderingLabels } mStatus;

QFuture<void> mFuture;
QFutureWatcher<void> mFutureWatcher;
QFuture<void> mFuture;
QFutureWatcher<void> mFutureWatcher;

LayerRenderJobs mLayerJobs;
LayerRenderJobs mLayerJobs;

QgsPalLabeling* mLabelingEngine;
QgsRenderContext mLabelingRenderContext;
QFuture<void> mLabelingFuture;
QFutureWatcher<void> mLabelingFutureWatcher;
QgsPalLabeling* mLabelingEngine;
QgsRenderContext mLabelingRenderContext;
QFuture<void> mLabelingFuture;
QFutureWatcher<void> mLabelingFutureWatcher;
};


Expand All @@ -232,37 +232,37 @@ protected slots:
*/
class CORE_EXPORT QgsMapRendererCustomPainterJob : public QgsMapRendererJob
{
Q_OBJECT
public:
QgsMapRendererCustomPainterJob(const QgsMapSettings& settings, QPainter* painter);
~QgsMapRendererCustomPainterJob();
Q_OBJECT
public:
QgsMapRendererCustomPainterJob( const QgsMapSettings& settings, QPainter* painter );
~QgsMapRendererCustomPainterJob();

virtual void start();
virtual void cancel();
virtual void waitForFinished();
virtual bool isActive() const;
virtual QgsLabelingResults* takeLabelingResults();
virtual void start();
virtual void cancel();
virtual void waitForFinished();
virtual bool isActive() const;
virtual QgsLabelingResults* takeLabelingResults();

const LayerRenderJobs& jobs() const { return mLayerJobs; }
const LayerRenderJobs& jobs() const { return mLayerJobs; }

protected slots:
void futureFinished();
protected slots:
void futureFinished();

protected:
static void staticRender(QgsMapRendererCustomPainterJob* self); // function to be used within the thread
protected:
static void staticRender( QgsMapRendererCustomPainterJob* self ); // function to be used within the thread

// these methods are called within worker thread
void doRender();
// these methods are called within worker thread
void doRender();

private:
QPainter* mPainter;
QFuture<void> mFuture;
QFutureWatcher<void> mFutureWatcher;
QgsRenderContext mLabelingRenderContext;
QgsPalLabeling* mLabelingEngine;
private:
QPainter* mPainter;
QFuture<void> mFuture;
QFutureWatcher<void> mFutureWatcher;
QgsRenderContext mLabelingRenderContext;
QgsPalLabeling* mLabelingEngine;

bool mActive;
LayerRenderJobs mLayerJobs;
bool mActive;
LayerRenderJobs mLayerJobs;
};


Expand Down
26 changes: 13 additions & 13 deletions src/core/qgsmapsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();


QgsMapSettings::QgsMapSettings()
: mDpi( qt_defaultDpiX() ) // DPI that will be used by default for QImage instances
, mSize( QSize( 0, 0 ) )
, mExtent()
, mProjectionsEnabled( false )
, mDestCRS( GEOCRS_ID, QgsCoordinateReferenceSystem::InternalCrsId ) // WGS 84
, mBackgroundColor( Qt::white )
, mSelectionColor( Qt::yellow )
, mFlags( Antialiasing | UseAdvancedEffects | DrawLabeling )
: mDpi( qt_defaultDpiX() ) // DPI that will be used by default for QImage instances
, mSize( QSize( 0, 0 ) )
, mExtent()
, mProjectionsEnabled( false )
, mDestCRS( GEOCRS_ID, QgsCoordinateReferenceSystem::InternalCrsId ) // WGS 84
, mBackgroundColor( Qt::white )
, mSelectionColor( Qt::yellow )
, mFlags( Antialiasing | UseAdvancedEffects | DrawLabeling )
{
updateDerived();

Expand All @@ -38,7 +38,7 @@ QgsRectangle QgsMapSettings::extent() const
return mExtent;
}

void QgsMapSettings::setExtent(const QgsRectangle& extent)
void QgsMapSettings::setExtent( const QgsRectangle& extent )
{
mExtent = extent;

Expand Down Expand Up @@ -104,7 +104,7 @@ void QgsMapSettings::updateDerived()

// calculate the actual extent of the mapCanvas
double dxmin = mExtent.xMinimum(), dxmax = mExtent.xMaximum(),
dymin = mExtent.yMinimum(), dymax = mExtent.yMaximum(), whitespace;
dymin = mExtent.yMinimum(), dymax = mExtent.yMaximum(), whitespace;

if ( mapUnitsPerPixelY > mapUnitsPerPixelX )
{
Expand Down Expand Up @@ -144,7 +144,7 @@ QSize QgsMapSettings::outputSize() const
return mSize;
}

void QgsMapSettings::setOutputSize(const QSize& size)
void QgsMapSettings::setOutputSize( const QSize& size )
{
mSize = size;

Expand All @@ -156,7 +156,7 @@ int QgsMapSettings::outputDpi() const
return mDpi;
}

void QgsMapSettings::setOutputDpi(int dpi)
void QgsMapSettings::setOutputDpi( int dpi )
{
mDpi = dpi;

Expand All @@ -169,7 +169,7 @@ QStringList QgsMapSettings::layers() const
return mLayers;
}

void QgsMapSettings::setLayers(const QStringList& layers)
void QgsMapSettings::setLayers( const QStringList& layers )
{
mLayers = layers;
}
Expand Down
212 changes: 106 additions & 106 deletions src/core/qgsmapsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,149 +20,149 @@ class QgsMapLayer;

class CORE_EXPORT QgsMapSettings
{
public:
QgsMapSettings();

QgsRectangle extent() const;
void setExtent(const QgsRectangle& rect);

QSize outputSize() const;
void setOutputSize(const QSize& size);

int outputDpi() const;
void setOutputDpi(int dpi);
public:
QgsMapSettings();

QgsRectangle extent() const;
void setExtent( const QgsRectangle& rect );

QSize outputSize() const;
void setOutputSize( const QSize& size );

int outputDpi() const;
void setOutputDpi( int dpi );

QStringList layers() const;
void setLayers(const QStringList& layers);
QStringList layers() const;
void setLayers( const QStringList& layers );

//! sets whether to use projections for this layer set
void setCrsTransformEnabled( bool enabled );
//! returns true if projections are enabled for this layer set
bool hasCrsTransformEnabled() const;
//! sets whether to use projections for this layer set
void setCrsTransformEnabled( bool enabled );
//! returns true if projections are enabled for this layer set
bool hasCrsTransformEnabled() const;

//! sets destination coordinate reference system
void setDestinationCrs( const QgsCoordinateReferenceSystem& crs );
//! returns CRS of destination coordinate reference system
const QgsCoordinateReferenceSystem& destinationCrs() const;
//! sets destination coordinate reference system
void setDestinationCrs( const QgsCoordinateReferenceSystem& crs );
//! returns CRS of destination coordinate reference system
const QgsCoordinateReferenceSystem& destinationCrs() const;

QGis::UnitType mapUnits() const;
void setMapUnits( QGis::UnitType u );
QGis::UnitType mapUnits() const;
void setMapUnits( QGis::UnitType u );

void setBackgroundColor( const QColor& color ) { mBackgroundColor = color; }
QColor backgroundColor() const { return mBackgroundColor; }
void setBackgroundColor( const QColor& color ) { mBackgroundColor = color; }
QColor backgroundColor() const { return mBackgroundColor; }

void setSelectionColor( const QColor& color ) { mSelectionColor = color; }
QColor selectionColor() const { return mSelectionColor; }
void setSelectionColor( const QColor& color ) { mSelectionColor = color; }
QColor selectionColor() const { return mSelectionColor; }

enum Flag
{
Antialiasing = 0x01,
DrawEditingInfo = 0x02,
ForceVectorOutput = 0x04,
UseAdvancedEffects = 0x08,
DrawLabeling = 0x10
// TODO: ignore scale-based visibiity (overview)
};
Q_DECLARE_FLAGS(Flags, Flag)
enum Flag
{
Antialiasing = 0x01,
DrawEditingInfo = 0x02,
ForceVectorOutput = 0x04,
UseAdvancedEffects = 0x08,
DrawLabeling = 0x10
// TODO: ignore scale-based visibiity (overview)
};
Q_DECLARE_FLAGS( Flags, Flag )

void setFlags( Flags flags );
void setFlag( Flag flag, bool on = true );
Flags flags() const;
bool testFlag( Flag flag ) const;
void setFlags( Flags flags );
void setFlag( Flag flag, bool on = true );
Flags flags() const;
bool testFlag( Flag flag ) const;

bool hasValidSettings() const;
QgsRectangle visibleExtent() const;
double mapUnitsPerPixel() const;
double scale() const;
bool hasValidSettings() const;
QgsRectangle visibleExtent() const;
double mapUnitsPerPixel() const;
double scale() const;


// -- utility functions --
// -- utility functions --

const QgsMapToPixel& mapToPixel() const { return mMapToPixel; }
const QgsMapToPixel& mapToPixel() const { return mMapToPixel; }

/**
* @brief transform bounding box from layer's CRS to output CRS
* @see layerToMapCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) if you want to transform a rectangle
* @return a bounding box (aligned rectangle) containing the transformed extent
*/
QgsRectangle layerExtentToOutputExtent( QgsMapLayer* theLayer, QgsRectangle extent ) const;
/**
* @brief transform bounding box from layer's CRS to output CRS
* @see layerToMapCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) if you want to transform a rectangle
* @return a bounding box (aligned rectangle) containing the transformed extent
*/
QgsRectangle layerExtentToOutputExtent( QgsMapLayer* theLayer, QgsRectangle extent ) const;

/**
* @brief transform bounding box from output CRS to layer's CRS
* @see mapToLayerCoordinates( QgsMapLayer* theLayer,QgsRectangle rect ) if you want to transform a rectangle
* @return a bounding box (aligned rectangle) containing the transformed extent
*/
QgsRectangle outputExtentToLayerExtent( QgsMapLayer* theLayer, QgsRectangle extent ) const;
/**
* @brief transform bounding box from output CRS to layer's CRS
* @see mapToLayerCoordinates( QgsMapLayer* theLayer,QgsRectangle rect ) if you want to transform a rectangle
* @return a bounding box (aligned rectangle) containing the transformed extent
*/
QgsRectangle outputExtentToLayerExtent( QgsMapLayer* theLayer, QgsRectangle extent ) const;

/**
* @brief transform point coordinates from layer's CRS to output CRS
* @return the transformed point
*/
QgsPoint layerToMapCoordinates( QgsMapLayer* theLayer, QgsPoint point ) const;
/**
* @brief transform point coordinates from layer's CRS to output CRS
* @return the transformed point
*/
QgsPoint layerToMapCoordinates( QgsMapLayer* theLayer, QgsPoint point ) const;

/**
* @brief transform rectangle from layer's CRS to output CRS
* @see layerExtentToOutputExtent() if you want to transform a bounding box
* @return the transformed rectangle
*/
QgsRectangle layerToMapCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) const;
/**
* @brief transform rectangle from layer's CRS to output CRS
* @see layerExtentToOutputExtent() if you want to transform a bounding box
* @return the transformed rectangle
*/
QgsRectangle layerToMapCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) const;

/**
* @brief transform point coordinates from output CRS to layer's CRS
* @return the transformed point
*/
QgsPoint mapToLayerCoordinates( QgsMapLayer* theLayer, QgsPoint point ) const;
/**
* @brief transform point coordinates from output CRS to layer's CRS
* @return the transformed point
*/
QgsPoint mapToLayerCoordinates( QgsMapLayer* theLayer, QgsPoint point ) const;

/**
* @brief transform rectangle from output CRS to layer's CRS
* @see outputExtentToLayerExtent() if you want to transform a bounding box
* @return the transformed rectangle
*/
QgsRectangle mapToLayerCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) const;
/**
* @brief transform rectangle from output CRS to layer's CRS
* @see outputExtentToLayerExtent() if you want to transform a bounding box
* @return the transformed rectangle
*/
QgsRectangle mapToLayerCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) const;


//! returns current extent of layer set
QgsRectangle fullExtent() const;
//! returns current extent of layer set
QgsRectangle fullExtent() const;

/* serialization */
/* serialization */

void readXML( QDomNode& theNode );
void readXML( QDomNode& theNode );

void writeXML( QDomNode& theNode, QDomDocument& theDoc );
void writeXML( QDomNode& theNode, QDomDocument& theDoc );

protected:
protected:

int mDpi;
int mDpi;

QSize mSize;
QSize mSize;

QgsRectangle mExtent;
QgsRectangle mExtent;

QStringList mLayers;
QStringList mLayers;

bool mProjectionsEnabled;
QgsCoordinateReferenceSystem mDestCRS;
bool mProjectionsEnabled;
QgsCoordinateReferenceSystem mDestCRS;

QColor mBackgroundColor;
QColor mSelectionColor;
QColor mBackgroundColor;
QColor mSelectionColor;

Flags mFlags;
Flags mFlags;

// derived properties
bool mValid; //!< whether the actual settings are valid (set in updateDerived())
QgsRectangle mVisibleExtent; //!< extent with some additional white space that matches the output aspect ratio
double mMapUnitsPerPixel;
double mScale;
// derived properties
bool mValid; //!< whether the actual settings are valid (set in updateDerived())
QgsRectangle mVisibleExtent; //!< extent with some additional white space that matches the output aspect ratio
double mMapUnitsPerPixel;
double mScale;


// utiity stuff
QgsScaleCalculator mScaleCalculator;
QgsMapToPixel mMapToPixel;
// utiity stuff
QgsScaleCalculator mScaleCalculator;
QgsMapToPixel mMapToPixel;


void updateDerived();
void updateDerived();

const QgsCoordinateTransform* coordTransform( QgsMapLayer *layer ) const;
const QgsCoordinateTransform* coordTransform( QgsMapLayer *layer ) const;
};

Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapSettings::Flags )
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgspallabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ static void _fixQPictureDPI( QPainter* p )
// Then when being drawn, it scales the painter. The following call
// negates the effect. There is no way of setting QPicture's DPI.
// See QTBUG-20361
p->scale( (double)qt_defaultDpiX() / p->device()->logicalDpiX(),
(double)qt_defaultDpiY() / p->device()->logicalDpiY() );
p->scale(( double )qt_defaultDpiX() / p->device()->logicalDpiX(),
( double )qt_defaultDpiY() / p->device()->logicalDpiY() );
}


Expand Down Expand Up @@ -3355,7 +3355,7 @@ int QgsPalLabeling::addDiagramLayer( QgsVectorLayer* layer, QgsDiagramLayerSetti
s->xform = &mMapSettings->mapToPixel();
mActiveDiagramLayers.insert( layer->id(), *s );

mActiveDiagramLayers[ layer->id() ].renderer = layer->diagramRenderer()->clone();
mActiveDiagramLayers[ layer->id()].renderer = layer->diagramRenderer()->clone();

return 1;
}
Expand Down Expand Up @@ -3834,7 +3834,7 @@ void QgsPalLabeling::dataDefinedDropShadow( QgsPalLayerSettings& tmpLyr,
// helper function for checking for job cancellation within PAL
static bool _palIsCancelled( void* ctx )
{
return ( ( QgsRenderContext* ) ctx )->renderingStopped();
return (( QgsRenderContext* ) ctx )->renderingStopped();
}

void QgsPalLabeling::drawLabeling( QgsRenderContext& context )
Expand Down
22 changes: 11 additions & 11 deletions src/core/qgspallabeling.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,21 +664,21 @@ class CORE_EXPORT QgsLabelComponent
*/
class CORE_EXPORT QgsLabelingResults
{
public:
QgsLabelingResults();
~QgsLabelingResults();
public:
QgsLabelingResults();
~QgsLabelingResults();

//! return infos about labels at a given (map) position
QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) const;
//! return infos about labels within a given (map) rectangle
QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) const;
//! return infos about labels at a given (map) position
QList<QgsLabelPosition> labelsAtPosition( const QgsPoint& p ) const;
//! return infos about labels within a given (map) rectangle
QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle& r ) const;

private:
QgsLabelingResults( const QgsLabelingResults& ) {} // no copying allowed
private:
QgsLabelingResults( const QgsLabelingResults& ) {} // no copying allowed

QgsLabelSearchTree* mLabelSearchTree;
QgsLabelSearchTree* mLabelSearchTree;

friend class QgsPalLabeling;
friend class QgsPalLabeling;
};


Expand Down
30 changes: 15 additions & 15 deletions src/core/qgspluginlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ QgsLegendSymbologyList QgsPluginLayer::legendSymbologyItems( const QSize& iconSi
/** Fallback layer renderer implementation for layer that do not support map renderer yet. */
class QgsPluginLayerRenderer : public QgsMapLayerRenderer
{
public:
QgsPluginLayerRenderer( QgsPluginLayer* layer, QgsRenderContext& rendererContext )
: QgsMapLayerRenderer( layer->id() )
, mLayer( layer )
, mRendererContext( rendererContext )
{}

virtual bool render()
{
return mLayer->draw( mRendererContext );
}

protected:
QgsPluginLayer* mLayer;
QgsRenderContext& mRendererContext;
public:
QgsPluginLayerRenderer( QgsPluginLayer* layer, QgsRenderContext& rendererContext )
: QgsMapLayerRenderer( layer->id() )
, mLayer( layer )
, mRendererContext( rendererContext )
{}

virtual bool render()
{
return mLayer->draw( mRendererContext );
}

protected:
QgsPluginLayer* mLayer;
QgsRenderContext& mRendererContext;
};

QgsMapLayerRenderer* QgsPluginLayer::createMapRenderer( QgsRenderContext& rendererContext )
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgssnapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@


QgsSnapper::QgsSnapper( QgsMapRenderer* mapRenderer )
: mMapSettings( mapRenderer->mapSettings() )
: mMapSettings( mapRenderer->mapSettings() )
{

}

QgsSnapper::QgsSnapper( const QgsMapSettings& mapSettings )
: mMapSettings( mapSettings )
: mMapSettings( mapSettings )
{
}

Expand Down
122 changes: 61 additions & 61 deletions src/core/qgsspatialindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,80 +50,80 @@ class QgisVisitor : public SpatialIndex::IVisitor

class QgsSpatialIndexCopyVisitor : public SpatialIndex::IVisitor
{
public:
QgsSpatialIndexCopyVisitor( SpatialIndex::ISpatialIndex* newIndex )
: mNewIndex( newIndex ) {}
public:
QgsSpatialIndexCopyVisitor( SpatialIndex::ISpatialIndex* newIndex )
: mNewIndex( newIndex ) {}

void visitNode( const INode& n )
{ Q_UNUSED( n ); }
void visitNode( const INode& n )
{ Q_UNUSED( n ); }

void visitData( const IData& d )
{
SpatialIndex::IShape* shape;
d.getShape( &shape );
mNewIndex->insertData( 0, 0, *shape, d.getIdentifier() );
delete shape;
}
void visitData( const IData& d )
{
SpatialIndex::IShape* shape;
d.getShape( &shape );
mNewIndex->insertData( 0, 0, *shape, d.getIdentifier() );
delete shape;
}

void visitData( std::vector<const IData*>& v )
{ Q_UNUSED( v ); }
void visitData( std::vector<const IData*>& v )
{ Q_UNUSED( v ); }

private:
SpatialIndex::ISpatialIndex* mNewIndex;
private:
SpatialIndex::ISpatialIndex* mNewIndex;
};


/** Data of spatial index that may be implicitly shared */
class QgsSpatialIndexData : public QSharedData
{
public:
QgsSpatialIndexData()
{
initTree();
}
public:
QgsSpatialIndexData()
{
initTree();
}

QgsSpatialIndexData( const QgsSpatialIndexData& other )
: QSharedData( other )
{
initTree();

// copy R-tree data one by one (is there a faster way??)
double low[] = { DBL_MIN, DBL_MIN };
double high[] = { DBL_MAX, DBL_MAX };
SpatialIndex::Region query( low, high, 2 );
QgsSpatialIndexCopyVisitor visitor( mRTree );
other.mRTree->intersectsWithQuery( query, visitor );
}
QgsSpatialIndexData( const QgsSpatialIndexData& other )
: QSharedData( other )
{
initTree();

// copy R-tree data one by one (is there a faster way??)
double low[] = { DBL_MIN, DBL_MIN };
double high[] = { DBL_MAX, DBL_MAX };
SpatialIndex::Region query( low, high, 2 );
QgsSpatialIndexCopyVisitor visitor( mRTree );
other.mRTree->intersectsWithQuery( query, visitor );
}

~QgsSpatialIndexData()
{
delete mRTree;
delete mStorage;
}
~QgsSpatialIndexData()
{
delete mRTree;
delete mStorage;
}

void initTree()
{
// for now only memory manager
mStorage = StorageManager::createNewMemoryStorageManager();

// R-Tree parameters
double fillFactor = 0.7;
unsigned long indexCapacity = 10;
unsigned long leafCapacity = 10;
unsigned long dimension = 2;
RTree::RTreeVariant variant = RTree::RV_RSTAR;

// create R-tree
SpatialIndex::id_type indexId;
mRTree = RTree::createNewRTree( *mStorage, fillFactor, indexCapacity,
leafCapacity, dimension, variant, indexId );
}
void initTree()
{
// for now only memory manager
mStorage = StorageManager::createNewMemoryStorageManager();

// R-Tree parameters
double fillFactor = 0.7;
unsigned long indexCapacity = 10;
unsigned long leafCapacity = 10;
unsigned long dimension = 2;
RTree::RTreeVariant variant = RTree::RV_RSTAR;

// create R-tree
SpatialIndex::id_type indexId;
mRTree = RTree::createNewRTree( *mStorage, fillFactor, indexCapacity,
leafCapacity, dimension, variant, indexId );
}

/** storage manager */
SpatialIndex::IStorageManager* mStorage;
/** storage manager */
SpatialIndex::IStorageManager* mStorage;

/** R-tree containing spatial index */
SpatialIndex::ISpatialIndex* mRTree;
/** R-tree containing spatial index */
SpatialIndex::ISpatialIndex* mRTree;
};

// -------------------------------------------------------------------------
Expand All @@ -135,15 +135,15 @@ QgsSpatialIndex::QgsSpatialIndex()
}

QgsSpatialIndex::QgsSpatialIndex( const QgsSpatialIndex& other )
: d( other.d )
: d( other.d )
{
}

QgsSpatialIndex:: ~QgsSpatialIndex()
{
}

QgsSpatialIndex& QgsSpatialIndex::operator=( const QgsSpatialIndex& other )
QgsSpatialIndex& QgsSpatialIndex::operator=( const QgsSpatialIndex & other )
{
if ( this != &other )
d = other.d;
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgstolerance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ double QgsTolerance::toleranceInMapUnits( double tolerance, QgsMapLayer* layer,
return toleranceInMapUnits( tolerance, layer, renderer->mapSettings(), units );
}

double QgsTolerance::vertexSearchRadius(QgsMapLayer *layer, const QgsMapSettings &mapSettings)
double QgsTolerance::vertexSearchRadius( QgsMapLayer *layer, const QgsMapSettings &mapSettings )
{
QSettings settings;
double tolerance = settings.value( "/qgis/digitizing/search_radius_vertex_edit", 10 ).toDouble();
Expand Down Expand Up @@ -61,7 +61,7 @@ double QgsTolerance::defaultTolerance( QgsMapLayer* layer, QgsMapRenderer* rende
}


double QgsTolerance::computeMapUnitPerPixel(QgsMapLayer* layer, const QgsMapSettings& mapSettings )
double QgsTolerance::computeMapUnitPerPixel( QgsMapLayer* layer, const QgsMapSettings& mapSettings )
{
if ( ! mapSettings.hasCrsTransformEnabled() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgstolerance.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class CORE_EXPORT QgsTolerance

private:
static double computeMapUnitPerPixel( QgsMapLayer* layer, const QgsMapSettings& mapSettings );
static QgsPoint toLayerCoordinates(QgsMapLayer* layer, const QgsMapSettings& mapSettings, const QPoint& point );
static QgsPoint toLayerCoordinates( QgsMapLayer* layer, const QgsMapSettings& mapSettings, const QPoint& point );

};

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectordataprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
* @note added in 2.4
* @return new instance of QgsAbstractFeatureSource (caller is responsible for deleting it)
*/
virtual QgsAbstractFeatureSource* featureSource() const { Q_ASSERT(0 && "All providers must support featureSource()"); return 0; }
virtual QgsAbstractFeatureSource* featureSource() const { Q_ASSERT( 0 && "All providers must support featureSource()" ); return 0; }

/**
* Returns the permanent storage type for this layer as a friendly name.
Expand Down Expand Up @@ -366,7 +366,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider

static QVariant convertValue( QVariant::Type type, QString value );

protected:
protected:
void clearMinMaxCache();
void fillMinMaxCache();

Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,

// Default simplify drawing settings
QSettings settings;
mSimplifyMethod.setSimplifyHints( ( QgsVectorSimplifyMethod::SimplifyHints ) settings.value( "/qgis/simplifyDrawingHints", ( int ) mSimplifyMethod.simplifyHints() ).toInt() );
mSimplifyMethod.setSimplifyHints(( QgsVectorSimplifyMethod::SimplifyHints ) settings.value( "/qgis/simplifyDrawingHints", ( int ) mSimplifyMethod.simplifyHints() ).toInt() );
mSimplifyMethod.setThreshold( settings.value( "/qgis/simplifyDrawingTol", mSimplifyMethod.threshold() ).toFloat() );
mSimplifyMethod.setForceLocalOptimization( settings.value( "/qgis/simplifyLocal", mSimplifyMethod.forceLocalOptimization() ).toBool() );
mSimplifyMethod.setMaximumScale( settings.value( "/qgis/simplifyMaxScale", mSimplifyMethod.maximumScale() ).toFloat() );
Expand Down Expand Up @@ -837,7 +837,7 @@ QgsRectangle QgsVectorLayer::extent()
mLazyExtent = false;
}

if( mValidExtent )
if ( mValidExtent )
return QgsMapLayer::extent();

if ( !mDataProvider )
Expand Down Expand Up @@ -1541,7 +1541,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
}

// get the simplification drawing settings
mSimplifyMethod.setSimplifyHints( ( QgsVectorSimplifyMethod::SimplifyHints ) e.attribute( "simplifyDrawingHints", "1" ).toInt() );
mSimplifyMethod.setSimplifyHints(( QgsVectorSimplifyMethod::SimplifyHints ) e.attribute( "simplifyDrawingHints", "1" ).toInt() );
mSimplifyMethod.setThreshold( e.attribute( "simplifyDrawingTol", "1" ).toFloat() );
mSimplifyMethod.setForceLocalOptimization( e.attribute( "simplifyLocal", "1" ).toInt() );
mSimplifyMethod.setMaximumScale( e.attribute( "simplifyMaxScale", "1" ).toFloat() );
Expand Down
40 changes: 20 additions & 20 deletions src/core/qgsvectorlayerfeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,35 @@ class QgsVectorLayerFeatureIterator;
/** Partial snapshot of vector layer's state (only the members necessary for access to features) */
class QgsVectorLayerFeatureSource : public QgsAbstractFeatureSource
{
public:
QgsVectorLayerFeatureSource( QgsVectorLayer* layer );
~QgsVectorLayerFeatureSource();
public:
QgsVectorLayerFeatureSource( QgsVectorLayer* layer );
~QgsVectorLayerFeatureSource();

virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );

friend class QgsVectorLayerFeatureIterator;
friend class QgsVectorLayerFeatureIterator;

protected:
protected:

QgsAbstractFeatureSource* mProviderFeatureSource;
QgsAbstractFeatureSource* mProviderFeatureSource;

QgsVectorLayerJoinBuffer* mJoinBuffer;
QgsVectorLayerJoinBuffer* mJoinBuffer;

QgsFields mFields;
QgsFields mFields;

bool mHasEditBuffer;
bool mHasEditBuffer;

bool mCanBeSimplified;
bool mCanBeSimplified;

// A deep-copy is only performed, if the original maps change
// see here https://github.com/qgis/Quantum-GIS/pull/673
// for explanation
QgsFeatureMap mAddedFeatures;
QgsGeometryMap mChangedGeometries;
QgsFeatureIds mDeletedFeatureIds;
QList<QgsField> mAddedAttributes;
QgsChangedAttributesMap mChangedAttributeValues;
QgsAttributeList mDeletedAttributeIds;
// A deep-copy is only performed, if the original maps change
// see here https://github.com/qgis/Quantum-GIS/pull/673
// for explanation
QgsFeatureMap mAddedFeatures;
QgsGeometryMap mChangedGeometries;
QgsFeatureIds mDeletedFeatureIds;
QList<QgsField> mAddedAttributes;
QgsChangedAttributesMap mChangedAttributeValues;
QgsAttributeList mDeletedAttributeIds;
};


Expand Down
26 changes: 13 additions & 13 deletions src/core/qgsvectorlayerrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@


QgsVectorLayerRenderer::QgsVectorLayerRenderer( QgsVectorLayer* layer, QgsRenderContext& context )
: QgsMapLayerRenderer( layer->id() )
, mContext( context )
, mFields( layer->pendingFields() )
, mRendererV2( 0 )
, mCache( 0 )
, mLabeling( false )
, mDiagrams( false )
, mLayerTransparency( 0 )
: QgsMapLayerRenderer( layer->id() )
, mContext( context )
, mFields( layer->pendingFields() )
, mRendererV2( 0 )
, mCache( 0 )
, mLabeling( false )
, mDiagrams( false )
, mLayerTransparency( 0 )
{
mSource = new QgsVectorLayerFeatureSource( layer );

Expand Down Expand Up @@ -114,8 +114,8 @@ bool QgsVectorLayerRenderer::render()
mRendererV2->startRender( mContext, mFields );

QgsFeatureRequest featureRequest = QgsFeatureRequest()
.setFilterRect( mContext.extent() )
.setSubsetOfAttributes( mAttrNames, mFields );
.setFilterRect( mContext.extent() )
.setSubsetOfAttributes( mAttrNames, mFields );

// enable the simplification of the geometries (Using the current map2pixel context) before send it to renderer engine.
if ( mSimplifyGeometry )
Expand Down Expand Up @@ -189,7 +189,7 @@ bool QgsVectorLayerRenderer::render()
// use destination in composition mode to merge source's alpha with destination
mContext.painter()->setCompositionMode( QPainter::CompositionMode_DestinationIn );
mContext.painter()->fillRect( 0, 0, mContext.painter()->device()->width(),
mContext.painter()->device()->height(), transparentFillColor );
mContext.painter()->device()->height(), transparentFillColor );
}

return true;
Expand Down Expand Up @@ -220,7 +220,7 @@ void QgsVectorLayerRenderer::drawRendererV2( QgsFeatureIterator& fit )

if ( mContext.renderingStopped() )
{
qDebug("breaking!");
qDebug( "breaking!" );
break;
}

Expand Down Expand Up @@ -283,7 +283,7 @@ void QgsVectorLayerRenderer::drawRendererV2Levels( QgsFeatureIterator& fit )

if ( mContext.renderingStopped() )
{
qDebug("rendering stop!");
qDebug( "rendering stop!" );
stopRendererV2( selRenderer );
return;
}
Expand Down
80 changes: 40 additions & 40 deletions src/core/qgsvectorlayerrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,67 +29,67 @@ typedef QList<int> QgsAttributeList;

class QgsVectorLayerRenderer : public QgsMapLayerRenderer
{
public:
QgsVectorLayerRenderer( QgsVectorLayer* layer, QgsRenderContext& context );
~QgsVectorLayerRenderer();
public:
QgsVectorLayerRenderer( QgsVectorLayer* layer, QgsRenderContext& context );
~QgsVectorLayerRenderer();

virtual bool render();
virtual bool render();

//! where to save the cached geometries
//! @note The way how geometries are cached is really suboptimal - this method may be removed in future releases
void setGeometryCachePointer( QgsGeometryCache* cache );
//! where to save the cached geometries
//! @note The way how geometries are cached is really suboptimal - this method may be removed in future releases
void setGeometryCachePointer( QgsGeometryCache* cache );

private:
private:

/**Registers label and diagram layer
@param attributes attributes needed for labeling and diagrams will be added to the list
*/
void prepareLabeling( QgsVectorLayer* layer, QStringList& attributeNames );
void prepareDiagrams( QgsVectorLayer* layer, QStringList& attributeNames );
/**Registers label and diagram layer
@param attributes attributes needed for labeling and diagrams will be added to the list
*/
void prepareLabeling( QgsVectorLayer* layer, QStringList& attributeNames );
void prepareDiagrams( QgsVectorLayer* layer, QStringList& attributeNames );

/** Draw layer with renderer V2. QgsFeatureRenderer::startRender() needs to be called before using this method
*/
void drawRendererV2( QgsFeatureIterator& fit );
/** Draw layer with renderer V2. QgsFeatureRenderer::startRender() needs to be called before using this method
*/
void drawRendererV2( QgsFeatureIterator& fit );

/** Draw layer with renderer V2 using symbol levels. QgsFeatureRenderer::startRender() needs to be called before using this method
*/
void drawRendererV2Levels( QgsFeatureIterator& fit );
/** Draw layer with renderer V2 using symbol levels. QgsFeatureRenderer::startRender() needs to be called before using this method
*/
void drawRendererV2Levels( QgsFeatureIterator& fit );

/** Stop version 2 renderer and selected renderer (if required) */
void stopRendererV2( QgsSingleSymbolRendererV2* selRenderer );
/** Stop version 2 renderer and selected renderer (if required) */
void stopRendererV2( QgsSingleSymbolRendererV2* selRenderer );


protected:
protected:

QgsRenderContext& mContext;
QgsRenderContext& mContext;

QgsFields mFields; // TODO: use fields from mSource
QgsFields mFields; // TODO: use fields from mSource

QgsFeatureIds mSelectedFeatureIds;
QgsFeatureIds mSelectedFeatureIds;

QgsVectorLayerFeatureSource* mSource;
QgsVectorLayerFeatureSource* mSource;

QgsFeatureRendererV2 *mRendererV2;
QgsFeatureRendererV2 *mRendererV2;

bool mCacheFeatures;
QgsGeometryCache* mCache;
bool mCacheFeatures;
QgsGeometryCache* mCache;

bool mDrawVertexMarkers;
bool mVertexMarkerOnlyForSelection;
int mVertexMarkerStyle, mVertexMarkerSize;
bool mDrawVertexMarkers;
bool mVertexMarkerOnlyForSelection;
int mVertexMarkerStyle, mVertexMarkerSize;

QGis::GeometryType mGeometryType;
QGis::GeometryType mGeometryType;

QStringList mAttrNames;
QStringList mAttrNames;

bool mLabeling;
bool mDiagrams;
bool mLabeling;
bool mDiagrams;

int mLayerTransparency;
QPainter::CompositionMode mFeatureBlendMode;
int mLayerTransparency;
QPainter::CompositionMode mFeatureBlendMode;

QgsVectorSimplifyMethod mSimplifyMethod;
bool mSimplifyGeometry;
QgsVectorSimplifyMethod mSimplifyMethod;
bool mSimplifyGeometry;
};


Expand Down
14 changes: 7 additions & 7 deletions src/core/qgsxmlutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ class QgsRectangle;
*/
class CORE_EXPORT QgsXmlUtils
{
public:
public:

/* reading */
/* reading */

static QGis::UnitType readMapUnits( const QDomElement& element );
static QgsRectangle readRectangle( const QDomElement& element );
static QGis::UnitType readMapUnits( const QDomElement& element );
static QgsRectangle readRectangle( const QDomElement& element );

/* writing */
/* writing */

static QDomElement writeMapUnits( QGis::UnitType units, QDomDocument& doc );
static QDomElement writeRectangle( const QgsRectangle& rect, QDomDocument& doc );
static QDomElement writeMapUnits( QGis::UnitType units, QDomDocument& doc );
static QDomElement writeRectangle( const QgsRectangle& rect, QDomDocument& doc );
};


Expand Down
10 changes: 5 additions & 5 deletions src/core/raster/qgsrasterdataprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast
bool setInput( QgsRasterInterface* input ) { Q_UNUSED( input ); return false; }

/** \brief Renders the layer as an image
\note When render caching (/qgis/enable_render_caching) is on the wms
provider doesn't wait for the reply of the getmap request or all
tiles replies and can return incomplete images.
Temporarily disable render caching if you require the complete
wms image in the first call.
\note When render caching (/qgis/enable_render_caching) is on the wms
provider doesn't wait for the reply of the getmap request or all
tiles replies and can return incomplete images.
Temporarily disable render caching if you require the complete
wms image in the first call.
*/
virtual QImage* draw( const QgsRectangle & viewExtent, int pixelWidth, int pixelHeight ) = 0;

Expand Down
6 changes: 3 additions & 3 deletions src/core/raster/qgsrasterlayerrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@


QgsRasterLayerRenderer::QgsRasterLayerRenderer( QgsRasterLayer* layer, QgsRenderContext& rendererContext )
: QgsMapLayerRenderer( layer->id() )
, mRasterViewPort( 0 )
, mPipe( 0 )
: QgsMapLayerRenderer( layer->id() )
, mRasterViewPort( 0 )
, mPipe( 0 )
{

mPainter = rendererContext.painter();
Expand Down
18 changes: 9 additions & 9 deletions src/core/raster/qgsrasterlayerrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ class QgsRenderContext;

class QgsRasterLayerRenderer : public QgsMapLayerRenderer
{
public:
QgsRasterLayerRenderer( QgsRasterLayer* layer, QgsRenderContext& rendererContext );
~QgsRasterLayerRenderer();
public:
QgsRasterLayerRenderer( QgsRasterLayer* layer, QgsRenderContext& rendererContext );
~QgsRasterLayerRenderer();

virtual bool render();
virtual bool render();

protected:
protected:

QPainter* mPainter;
const QgsMapToPixel* mMapToPixel;
QgsRasterViewPort* mRasterViewPort;
QPainter* mPainter;
const QgsMapToPixel* mMapToPixel;
QgsRasterViewPort* mRasterViewPort;

QgsRasterPipe* mPipe;
QgsRasterPipe* mPipe;
};

#endif // QGSRASTERLAYERRENDERER_H
70 changes: 35 additions & 35 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,23 @@ class QgsMapCanvas::CanvasProperties


QgsMapCanvasRendererSync::QgsMapCanvasRendererSync( QgsMapCanvas* canvas, QgsMapRenderer* renderer )
: QObject( canvas )
, mCanvas( canvas )
, mRenderer( renderer )
: QObject( canvas )
, mCanvas( canvas )
, mRenderer( renderer )
{
connect( mCanvas, SIGNAL(extentsChanged()), this, SLOT(onExtentC2R()) );
connect( mRenderer, SIGNAL(extentsChanged()), this, SLOT(onExtentR2C()) );
connect( mCanvas, SIGNAL( extentsChanged() ), this, SLOT( onExtentC2R() ) );
connect( mRenderer, SIGNAL( extentsChanged() ), this, SLOT( onExtentR2C() ) );

connect( mCanvas, SIGNAL(mapUnitsChanged()), this, SLOT(onMapUnitsC2R()) );
connect( mRenderer, SIGNAL(mapUnitsChanged()), this, SLOT(onMapUnitsR2C()) );
connect( mCanvas, SIGNAL( mapUnitsChanged() ), this, SLOT( onMapUnitsC2R() ) );
connect( mRenderer, SIGNAL( mapUnitsChanged() ), this, SLOT( onMapUnitsR2C() ) );

connect( mCanvas, SIGNAL(hasCrsTransformEnabledChanged(bool)), this, SLOT(onCrsTransformC2R()) );
connect( mRenderer, SIGNAL(hasCrsTransformEnabled(bool)), this, SLOT(onCrsTransformR2C()) );
connect( mCanvas, SIGNAL( hasCrsTransformEnabledChanged( bool ) ), this, SLOT( onCrsTransformC2R() ) );
connect( mRenderer, SIGNAL( hasCrsTransformEnabled( bool ) ), this, SLOT( onCrsTransformR2C() ) );

connect( mCanvas, SIGNAL(destinationCrsChanged()), this, SLOT(onDestCrsC2R()) );
connect( mRenderer, SIGNAL(destinationSrsChanged()), this, SLOT(onDestCrsR2C()) );
connect( mCanvas, SIGNAL( destinationCrsChanged() ), this, SLOT( onDestCrsC2R() ) );
connect( mRenderer, SIGNAL( destinationSrsChanged() ), this, SLOT( onDestCrsR2C() ) );

connect( mCanvas, SIGNAL(layersChanged()), this, SLOT(onLayersC2R()) );
connect( mCanvas, SIGNAL( layersChanged() ), this, SLOT( onLayersC2R() ) );
// TODO: layers R2C ? (should not happen!)

}
Expand Down Expand Up @@ -217,7 +217,7 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )

moveCanvasContents( true );

connect(&mMapUpdateTimer, SIGNAL( timeout() ), SLOT( mapUpdateTimeout() ) );
connect( &mMapUpdateTimer, SIGNAL( timeout() ), SLOT( mapUpdateTimeout() ) );
mMapUpdateTimer.setInterval( 250 );

#ifdef Q_OS_WIN
Expand Down Expand Up @@ -281,7 +281,7 @@ void QgsMapCanvas::enableAntiAliasing( bool theFlag )

void QgsMapCanvas::useImageToRender( bool theFlag )
{
Q_UNUSED(theFlag);
Q_UNUSED( theFlag );
}

QgsMapCanvasMap* QgsMapCanvas::map()
Expand Down Expand Up @@ -453,7 +453,7 @@ const QgsMapSettings &QgsMapCanvas::mapSettings() const
return mSettings;
}

void QgsMapCanvas::setCrsTransformEnabled(bool enabled)
void QgsMapCanvas::setCrsTransformEnabled( bool enabled )
{
if ( mSettings.hasCrsTransformEnabled() == enabled )
return;
Expand All @@ -465,7 +465,7 @@ void QgsMapCanvas::setCrsTransformEnabled(bool enabled)
emit hasCrsTransformEnabledChanged( enabled );
}

void QgsMapCanvas::setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
void QgsMapCanvas::setDestinationCrs( const QgsCoordinateReferenceSystem &crs )
{
if ( mSettings.destinationCrs() == crs )
return;
Expand Down Expand Up @@ -566,28 +566,28 @@ void QgsMapCanvas::refresh()
{
if ( !mSettings.hasValidSettings() )
{
qDebug("CANVAS refresh - invalid settings -> nothing to do");
qDebug( "CANVAS refresh - invalid settings -> nothing to do" );
return;
}

if ( !mRenderFlag || mFrozen ) // do we really need two flags controlling rendering?
{
qDebug("CANVAS render flag off");
qDebug( "CANVAS render flag off" );
return;
}

if ( mRefreshScheduled )
{
qDebug("CANVAS refresh already scheduled");
qDebug( "CANVAS refresh already scheduled" );
return;
}

mRefreshScheduled = true;

qDebug("CANVAS refresh scheduling");
qDebug( "CANVAS refresh scheduling" );

// schedule a refresh
QTimer::singleShot( 1, this, SLOT(refreshMap()));
QTimer::singleShot( 1, this, SLOT( refreshMap() ) );

/*
// we can't draw again if already drawing...
Expand Down Expand Up @@ -648,7 +648,7 @@ void QgsMapCanvas::refreshMap()
{
Q_ASSERT( mRefreshScheduled );

qDebug("CANVAS refresh!");
qDebug( "CANVAS refresh!" );

stopRendering(); // if any...

Expand All @@ -662,7 +662,7 @@ void QgsMapCanvas::refreshMap()
mJob = new QgsMapRendererParallelJob( mSettings );
else
mJob = new QgsMapRendererSequentialJob( mSettings );
connect(mJob, SIGNAL( finished() ), SLOT( rendererJobFinished() ) );
connect( mJob, SIGNAL( finished() ), SLOT( rendererJobFinished() ) );
mJob->setCache( mCache );

QStringList layersForGeometryCache;
Expand Down Expand Up @@ -696,7 +696,7 @@ void QgsMapCanvas::layerRequestedRepaint()

void QgsMapCanvas::rendererJobFinished()
{
qDebug("CANVAS finish! %d", !mJobCancelled );
qDebug( "CANVAS finish! %d", !mJobCancelled );

mMapUpdateTimer.stop();

Expand All @@ -720,13 +720,13 @@ void QgsMapCanvas::rendererJobFinished()
QFont fnt = p.font();
fnt.setBold( true );
p.setFont( fnt );
int lh = p.fontMetrics().height()*2;
int lh = p.fontMetrics().height() * 2;
QRect r( 0, h - lh, w, lh );
p.setPen( Qt::NoPen );
p.setBrush( QColor( 0, 0, 0, 110 ) );
p.drawRect( r );
p.setPen( Qt::white );
QString msg = QString("%1 :: %2 ms").arg( mUseParallelRendering ? "PARALLEL" : "SEQUENTIAL" ).arg( mJob->renderingTime() );
QString msg = QString( "%1 :: %2 ms" ).arg( mUseParallelRendering ? "PARALLEL" : "SEQUENTIAL" ).arg( mJob->renderingTime() );
p.drawText( r, msg, QTextOption( Qt::AlignCenter ) );
}

Expand All @@ -746,7 +746,7 @@ void QgsMapCanvas::rendererJobFinished()

void QgsMapCanvas::mapUpdateTimeout()
{
qDebug("CANVAS update timer!");
qDebug( "CANVAS update timer!" );

mMap->setContent( mJob->renderedImage(), mSettings.visibleExtent() );
}
Expand All @@ -756,7 +756,7 @@ void QgsMapCanvas::stopRendering()
{
if ( mJob )
{
qDebug("CANVAS stop rendering!");
qDebug( "CANVAS stop rendering!" );
mJobCancelled = true;
mJob->cancel();
Q_ASSERT( mJob == 0 ); // no need to delete here: already deleted in finished()
Expand Down Expand Up @@ -1112,7 +1112,7 @@ void QgsMapCanvas::keyPressEvent( QKeyEvent * e )
refresh();
break;

case Qt::Key_S:
case Qt::Key_S:
mDrawRenderingStats = !mDrawRenderingStats;
refresh();
break;
Expand Down Expand Up @@ -1245,7 +1245,7 @@ void QgsMapCanvas::mouseReleaseEvent( QMouseEvent * e )

void QgsMapCanvas::resizeEvent( QResizeEvent * e )
{
QGraphicsView::resizeEvent(e);
QGraphicsView::resizeEvent( e );
mResizeTimer->start( 500 );

QSize lastSize = size();
Expand Down Expand Up @@ -1592,17 +1592,17 @@ void QgsMapCanvas::panActionEnd( QPoint releasePoint )
QgsPoint start = getCoordinateTransform()->toMapCoordinates( mCanvasProperties->rubberStartPoint );
QgsPoint end = getCoordinateTransform()->toMapCoordinates( releasePoint );

qDebug("start %f,%f", start.x(), start.y());
qDebug("end %f,%f", end.x(), end.y());
qDebug( "start %f,%f", start.x(), start.y() );
qDebug( "end %f,%f", end.x(), end.y() );

double dx = qAbs( end.x() - start.x() );
double dy = qAbs( end.y() - start.y() );

// modify the extent
QgsRectangle r = mapSettings().visibleExtent();

qDebug(" -------------XXX diff: %f,%f", dx, dy);
qDebug(" ------------oldR: %f,%f", r.xMinimum(), r.yMinimum());
qDebug( " -------------XXX diff: %f,%f", dx, dy );
qDebug( " ------------oldR: %f,%f", r.xMinimum(), r.yMinimum() );

if ( end.x() < start.x() )
{
Expand Down Expand Up @@ -1631,7 +1631,7 @@ void QgsMapCanvas::panActionEnd( QPoint releasePoint )
setExtent( r );

r = mapSettings().visibleExtent();
qDebug(" ------------newR: %f,%f", r.xMinimum(), r.yMinimum());
qDebug( " ------------newR: %f,%f", r.xMinimum(), r.yMinimum() );

refresh();
}
Expand Down
32 changes: 16 additions & 16 deletions src/gui/qgsmapcanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,28 +602,28 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
*/
class QgsMapCanvasRendererSync : public QObject
{
Q_OBJECT
public:
QgsMapCanvasRendererSync( QgsMapCanvas* canvas, QgsMapRenderer* renderer );
Q_OBJECT
public:
QgsMapCanvasRendererSync( QgsMapCanvas* canvas, QgsMapRenderer* renderer );

protected slots:
void onExtentC2R();
void onExtentR2C();
protected slots:
void onExtentC2R();
void onExtentR2C();

void onMapUnitsC2R();
void onMapUnitsR2C();
void onMapUnitsC2R();
void onMapUnitsR2C();

void onCrsTransformC2R();
void onCrsTransformR2C();
void onCrsTransformC2R();
void onCrsTransformR2C();

void onDestCrsC2R();
void onDestCrsR2C();
void onDestCrsC2R();
void onDestCrsR2C();

void onLayersC2R();
void onLayersC2R();

protected:
QgsMapCanvas* mCanvas;
QgsMapRenderer* mRenderer;
protected:
QgsMapCanvas* mCanvas;
QgsMapRenderer* mRenderer;
};


Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsmapcanvasitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ bool QgsMapCanvasItem::setRenderContextVariables( QPainter* p, QgsRenderContext&
context.setScaleFactor( ms.outputDpi() / 25.4 );
context.setRasterScaleFactor( 1.0 );

context.setForceVectorOutput( true );
context.setForceVectorOutput( true );
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgsmapcanvasmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ void QgsMapCanvasMap::setContent( const QImage& image, const QgsRectangle& rect

void QgsMapCanvasMap::paint( QPainter* painter )
{
int w = qRound(boundingRect().width()) - 2, h = qRound(boundingRect().height()) - 2; // setRect() makes the size +2 :-(
if (mImage.size() != QSize(w,h))
qDebug("map paint DIFFERENT SIZE: img %d,%d item %d,%d", mImage.width(), mImage.height(), w, h);
painter->drawImage( QRect(0, 0, w, h), mImage );
int w = qRound( boundingRect().width() ) - 2, h = qRound( boundingRect().height() ) - 2; // setRect() makes the size +2 :-(
if ( mImage.size() != QSize( w, h ) )
qDebug( "map paint DIFFERENT SIZE: img %d,%d item %d,%d", mImage.width(), mImage.height(), w, h );
painter->drawImage( QRect( 0, 0, w, h ), mImage );
}

QPaintDevice& QgsMapCanvasMap::paintDevice()
Expand Down
14 changes: 7 additions & 7 deletions src/gui/qgsmapoverviewcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,19 @@ void QgsMapOverviewCanvas::refresh()
if ( !mSettings.hasValidSettings() )
return; // makes no sense to render anything

if (mJob)
if ( mJob )
{
qDebug("oveview - cancelling old");
qDebug( "oveview - cancelling old" );
mJob->cancel();
qDebug("oveview - deleting old");
qDebug( "oveview - deleting old" );
delete mJob; // get rid of previous job (if any)
}

qDebug("oveview - starting new");
qDebug( "oveview - starting new" );

// TODO: setup overview mode
mJob = new QgsMapRendererSequentialJob(mSettings);
connect(mJob, SIGNAL(finished()), this, SLOT(mapRenderingFinished()));
mJob = new QgsMapRendererSequentialJob( mSettings );
connect( mJob, SIGNAL( finished() ), this, SLOT( mapRenderingFinished() ) );
mJob->start();

// schedule repaint
Expand All @@ -284,7 +284,7 @@ void QgsMapOverviewCanvas::refresh()

void QgsMapOverviewCanvas::mapRenderingFinished()
{
qDebug("overview - finished");
qDebug( "overview - finished" );
mPixmap = QPixmap::fromImage( mJob->renderedImage() );

delete mJob;
Expand Down
20 changes: 10 additions & 10 deletions src/plugins/georeferencer/qgsgcpcanvasitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,20 @@ double QgsGCPCanvasItem::residualToScreenFactor() const
double mapUnitsPerScreenPixel = mMapCanvas->mapUnitsPerPixel();
double mapUnitsPerRasterPixel = 1.0;

QStringList canvasLayers = mMapCanvas->mapSettings().layers();
if ( canvasLayers.size() > 0 )
QStringList canvasLayers = mMapCanvas->mapSettings().layers();
if ( canvasLayers.size() > 0 )
{
QString layerId = canvasLayers.at( 0 );
QgsMapLayer* mapLayer = QgsMapLayerRegistry::instance()->mapLayer( layerId );
if ( mapLayer )
{
QString layerId = canvasLayers.at( 0 );
QgsMapLayer* mapLayer = QgsMapLayerRegistry::instance()->mapLayer( layerId );
if ( mapLayer )
QgsRasterLayer* rasterLayer = dynamic_cast<QgsRasterLayer*>( mapLayer );
if ( rasterLayer )
{
QgsRasterLayer* rasterLayer = dynamic_cast<QgsRasterLayer*>( mapLayer );
if ( rasterLayer )
{
mapUnitsPerRasterPixel = rasterLayer->rasterUnitsPerPixelX();
}
mapUnitsPerRasterPixel = rasterLayer->rasterUnitsPerPixelX();
}
}
}

return 1.0 / ( mapUnitsPerScreenPixel * mapUnitsPerRasterPixel );
}
Expand Down
38 changes: 19 additions & 19 deletions src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,25 +445,25 @@ void QgsDelimitedTextFeatureIterator::fetchAttribute( QgsFeature& feature, int f
// ------------

QgsDelimitedTextFeatureSource::QgsDelimitedTextFeatureSource( const QgsDelimitedTextProvider* p )
: mGeomRep( p->mGeomRep )
, mSubsetExpression( p->mSubsetExpression )
, mExtent( p->mExtent )
, mUseSpatialIndex( p->mUseSpatialIndex )
, mSpatialIndex( p->mSpatialIndex ? new QgsSpatialIndex( *p->mSpatialIndex ) : 0 )
, mUseSubsetIndex( p->mUseSubsetIndex )
, mSubsetIndex( p->mSubsetIndex )
, mFile( 0 )
, mFields( p->attributeFields )
, mFieldCount( p->mFieldCount )
, mXFieldIndex( p->mXFieldIndex )
, mYFieldIndex( p->mYFieldIndex )
, mWktFieldIndex( p->mWktFieldIndex )
, mWktHasZM( p->mWktHasZM )
, mWktHasPrefix( p->mWktHasPrefix )
, mGeometryType( p->mGeometryType )
, mDecimalPoint( p->mDecimalPoint )
, mXyDms( p->mXyDms )
, attributeColumns( p->attributeColumns )
: mGeomRep( p->mGeomRep )
, mSubsetExpression( p->mSubsetExpression )
, mExtent( p->mExtent )
, mUseSpatialIndex( p->mUseSpatialIndex )
, mSpatialIndex( p->mSpatialIndex ? new QgsSpatialIndex( *p->mSpatialIndex ) : 0 )
, mUseSubsetIndex( p->mUseSubsetIndex )
, mSubsetIndex( p->mSubsetIndex )
, mFile( 0 )
, mFields( p->attributeFields )
, mFieldCount( p->mFieldCount )
, mXFieldIndex( p->mXFieldIndex )
, mYFieldIndex( p->mYFieldIndex )
, mWktFieldIndex( p->mWktFieldIndex )
, mWktHasZM( p->mWktHasZM )
, mWktHasPrefix( p->mWktHasPrefix )
, mGeometryType( p->mGeometryType )
, mDecimalPoint( p->mDecimalPoint )
, mXyDms( p->mXyDms )
, attributeColumns( p->attributeColumns )
{
mFile = new QgsDelimitedTextFile();
mFile->setFromUrl( p->mFile->url() );
Expand Down
56 changes: 28 additions & 28 deletions src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,34 @@

class QgsDelimitedTextFeatureSource : public QgsAbstractFeatureSource
{
public:
QgsDelimitedTextFeatureSource( const QgsDelimitedTextProvider* p );
~QgsDelimitedTextFeatureSource();

virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );

protected:
QgsDelimitedTextProvider::GeomRepresentationType mGeomRep;
QgsExpression *mSubsetExpression;
QgsRectangle mExtent;
bool mUseSpatialIndex;
QgsSpatialIndex *mSpatialIndex;
bool mUseSubsetIndex;
QList<quintptr> mSubsetIndex;
QgsDelimitedTextFile *mFile;
QgsFields mFields;
int mFieldCount; // Note: this includes field count for wkt field
int mXFieldIndex;
int mYFieldIndex;
int mWktFieldIndex;
bool mWktHasZM;
bool mWktHasPrefix;
QGis::GeometryType mGeometryType;
QString mDecimalPoint;
bool mXyDms;
QList<int> attributeColumns;

friend class QgsDelimitedTextFeatureIterator;
public:
QgsDelimitedTextFeatureSource( const QgsDelimitedTextProvider* p );
~QgsDelimitedTextFeatureSource();

virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );

protected:
QgsDelimitedTextProvider::GeomRepresentationType mGeomRep;
QgsExpression *mSubsetExpression;
QgsRectangle mExtent;
bool mUseSpatialIndex;
QgsSpatialIndex *mSpatialIndex;
bool mUseSubsetIndex;
QList<quintptr> mSubsetIndex;
QgsDelimitedTextFile *mFile;
QgsFields mFields;
int mFieldCount; // Note: this includes field count for wkt field
int mXFieldIndex;
int mYFieldIndex;
int mWktFieldIndex;
bool mWktHasZM;
bool mWktHasPrefix;
QGis::GeometryType mGeometryType;
QString mDecimalPoint;
bool mXyDms;
QList<int> attributeColumns;

friend class QgsDelimitedTextFeatureIterator;
};


Expand Down
8 changes: 4 additions & 4 deletions src/providers/gpx/qgsgpxfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ QgsGeometry* QgsGPXFeatureIterator::readTrackGeometry( const QgsTrack& trk )
// ------------

QgsGPXFeatureSource::QgsGPXFeatureSource( const QgsGPXProvider* p )
: mFileName( p->mFileName )
, mFeatureType( p->mFeatureType )
, indexToAttr( p->indexToAttr )
, mFields( p->attributeFields )
: mFileName( p->mFileName )
, mFeatureType( p->mFeatureType )
, indexToAttr( p->indexToAttr )
, mFields( p->attributeFields )
{
data = QgsGPSData::getData( mFileName );
}
Expand Down
22 changes: 11 additions & 11 deletions src/providers/gpx/qgsgpxfeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ class QgsGPXProvider;

class QgsGPXFeatureSource : public QgsAbstractFeatureSource
{
public:
QgsGPXFeatureSource( const QgsGPXProvider* p );
~QgsGPXFeatureSource();
public:
QgsGPXFeatureSource( const QgsGPXProvider* p );
~QgsGPXFeatureSource();

virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );

protected:
QString mFileName;
QgsGPXProvider::DataType mFeatureType;
QgsGPSData* data;
QVector<int> indexToAttr;
QgsFields mFields;
protected:
QString mFileName;
QgsGPXProvider::DataType mFeatureType;
QgsGPSData* data;
QVector<int> indexToAttr;
QgsFields mFields;

friend class QgsGPXFeatureIterator;
friend class QgsGPXFeatureIterator;
};


Expand Down
2 changes: 1 addition & 1 deletion src/providers/gpx/qgsgpxprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class QgsGPXProvider : public QgsVectorDataProvider
CmtAttr, DscAttr, SrcAttr, URLAttr, URLNameAttr
};

private:
private:

QgsGPSData* data;

Expand Down
18 changes: 9 additions & 9 deletions src/providers/grass/qgsgrassfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,15 +565,15 @@ void QgsGrassFeatureIterator::setFeatureAttributes( int cat, QgsFeature *feature


QgsGrassFeatureSource::QgsGrassFeatureSource( const QgsGrassProvider* p )
: mMap( p->mMap )
, mLayerType( p->mLayerType )
, mGrassType( p->mGrassType )
, mLayerId( p->mLayerId )
, mQgisType( p->mQgisType )
, mCidxFieldIndex( p->mCidxFieldIndex )
, mCidxFieldNumCats( p->mCidxFieldNumCats )
, mFields( p->fields() )
, mEncoding( p->mEncoding )
: mMap( p->mMap )
, mLayerType( p->mLayerType )
, mGrassType( p->mGrassType )
, mLayerId( p->mLayerId )
, mQgisType( p->mQgisType )
, mCidxFieldIndex( p->mCidxFieldIndex )
, mCidxFieldNumCats( p->mCidxFieldNumCats )
, mFields( p->fields() )
, mEncoding( p->mEncoding )
{
int layerId = QgsGrassProvider::openLayer( p->mGisdbase, p->mLocation, p->mMapset, p->mMapName, p->mLayerField );

Expand Down
30 changes: 15 additions & 15 deletions src/providers/grass/qgsgrassfeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ class QgsGrassProvider;

class QgsGrassFeatureSource : public QgsAbstractFeatureSource
{
public:
QgsGrassFeatureSource( const QgsGrassProvider* provider );
~QgsGrassFeatureSource();
public:
QgsGrassFeatureSource( const QgsGrassProvider* provider );
~QgsGrassFeatureSource();

virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );

protected:
struct Map_info* mMap;
int mLayerType; // layer type POINT, LINE, ...
int mGrassType; // grass feature type: GV_POINT, GV_LINE | GV_BOUNDARY, GV_AREA,
int mLayerId; // ID used in layers
QGis::WkbType mQgisType;// WKBPoint, WKBLineString, ...
protected:
struct Map_info* mMap;
int mLayerType; // layer type POINT, LINE, ...
int mGrassType; // grass feature type: GV_POINT, GV_LINE | GV_BOUNDARY, GV_AREA,
int mLayerId; // ID used in layers
QGis::WkbType mQgisType;// WKBPoint, WKBLineString, ...

int mCidxFieldIndex; // !UPDATE! Index for layerField in category index or -1 if no such field
int mCidxFieldNumCats; // !UPDATE! Number of records in field index
int mCidxFieldIndex; // !UPDATE! Index for layerField in category index or -1 if no such field
int mCidxFieldNumCats; // !UPDATE! Number of records in field index

QgsFields mFields;
QTextCodec* mEncoding;
QgsFields mFields;
QTextCodec* mEncoding;

friend class QgsGrassFeatureIterator;
friend class QgsGrassFeatureIterator;
};


Expand Down
2 changes: 1 addition & 1 deletion src/providers/grass/qgsgrassprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ class GRASS_LIB_EXPORT QgsGrassProvider : public QgsVectorDataProvider
TOPO_NODE // topology nodes
};

private:
private:
QString mGisdbase; // map gisdabase
QString mLocation; // map location name (not path!)
QString mMapset; // map mapset
Expand Down
8 changes: 4 additions & 4 deletions src/providers/memory/qgsmemoryfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ bool QgsMemoryFeatureIterator::nextFeatureUsingList( QgsFeature& feature )
if ( mRequest.filterType() == QgsFeatureRequest::FilterRect && mRequest.flags() & QgsFeatureRequest::ExactIntersect )
{
// do exact check in case we're doing intersection
if ( mSource->mFeatures[*mFeatureIdListIterator].geometry() && mSource->mFeatures[*mFeatureIdListIterator].geometry()->intersects( mSelectRectGeom ) )
if ( mSource->mFeatures[*mFeatureIdListIterator].geometry() && mSource->mFeatures[*mFeatureIdListIterator].geometry()->intersects( mSelectRectGeom ) )
hasFeature = true;
}
else
Expand Down Expand Up @@ -191,9 +191,9 @@ bool QgsMemoryFeatureIterator::close()
// -------------------------

QgsMemoryFeatureSource::QgsMemoryFeatureSource( const QgsMemoryProvider* p )
: mFields( p->mFields )
, mFeatures( p->mFeatures )
, mSpatialIndex( p->mSpatialIndex ? new QgsSpatialIndex( *p->mSpatialIndex ) : 0 ) // just shallow copy
: mFields( p->mFields )
, mFeatures( p->mFeatures )
, mSpatialIndex( p->mSpatialIndex ? new QgsSpatialIndex( *p->mSpatialIndex ) : 0 ) // just shallow copy
{
}

Expand Down
18 changes: 9 additions & 9 deletions src/providers/memory/qgsmemoryfeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ class QgsSpatialIndex;

class QgsMemoryFeatureSource : public QgsAbstractFeatureSource
{
public:
QgsMemoryFeatureSource( const QgsMemoryProvider* p );
~QgsMemoryFeatureSource();
public:
QgsMemoryFeatureSource( const QgsMemoryProvider* p );
~QgsMemoryFeatureSource();

virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );

protected:
QgsFields mFields;
QgsFeatureMap mFeatures;
QgsSpatialIndex* mSpatialIndex;
protected:
QgsFields mFields;
QgsFeatureMap mFeatures;
QgsSpatialIndex* mSpatialIndex;

friend class QgsMemoryFeatureIterator;
friend class QgsMemoryFeatureIterator;
};


Expand Down
26 changes: 13 additions & 13 deletions src/providers/ogr/qgsogrfeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ class QgsOgrAbstractGeometrySimplifier;

class QgsOgrFeatureSource : public QgsAbstractFeatureSource
{
public:
QgsOgrFeatureSource( const QgsOgrProvider* p );

virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );
public:
QgsOgrFeatureSource( const QgsOgrProvider* p );

protected:
QString mFilePath;
QString mLayerName;
int mLayerIndex;
QString mSubsetString;
QTextCodec* mEncoding;
QgsFields mFields;
OGRwkbGeometryType mOgrGeometryTypeFilter;
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );

friend class QgsOgrFeatureIterator;
protected:
QString mFilePath;
QString mLayerName;
int mLayerIndex;
QString mSubsetString;
QTextCodec* mEncoding;
QgsFields mFields;
OGRwkbGeometryType mOgrGeometryTypeFilter;

friend class QgsOgrFeatureIterator;
};

class QgsOgrFeatureIterator : public QgsAbstractFeatureIteratorFromSource<QgsOgrFeatureSource>
Expand Down
8 changes: 4 additions & 4 deletions src/providers/ogr/qgsogrprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ class QgsOgrProvider : public QgsVectorDataProvider

class QgsOgrUtils
{
public:
static void setRelevantFields( OGRLayerH ogrLayer, int fieldCount, bool fetchGeometry, const QgsAttributeList &fetchAttributes );
static OGRLayerH setSubsetString( OGRLayerH layer, OGRDataSourceH ds, QTextCodec* encoding, const QString& subsetString );
static QByteArray quotedIdentifier( QByteArray field, const QString& ogrDriverName );
public:
static void setRelevantFields( OGRLayerH ogrLayer, int fieldCount, bool fetchGeometry, const QgsAttributeList &fetchAttributes );
static OGRLayerH setSubsetString( OGRLayerH layer, OGRDataSourceH ds, QTextCodec* encoding, const QString& subsetString );
static QByteArray quotedIdentifier( QByteArray field, const QString& ogrDriverName );
};
24 changes: 12 additions & 12 deletions src/providers/oracle/qgsoraclefeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,18 @@ bool QgsOracleFeatureIterator::openQuery( QString whereClause )
// -----------

QgsOracleFeatureSource::QgsOracleFeatureSource( const QgsOracleProvider* p )
: mUri( p->mUri )
, mFields( p->mAttributeFields )
, mGeometryColumn( p->mGeometryColumn )
, mSrid( p->mSrid )
, mSpatialIndex( p->mSpatialIndex )
, mDetectedGeomType( p->mDetectedGeomType )
, mRequestedGeomType( p->mRequestedGeomType )
, mSqlWhereClause( p->mSqlWhereClause )
, mPrimaryKeyType( p->mPrimaryKeyType )
, mPrimaryKeyAttrs( p->mPrimaryKeyAttrs )
, mQuery( p->mQuery )
, mShared( p->mShared )
: mUri( p->mUri )
, mFields( p->mAttributeFields )
, mGeometryColumn( p->mGeometryColumn )
, mSrid( p->mSrid )
, mSpatialIndex( p->mSpatialIndex )
, mDetectedGeomType( p->mDetectedGeomType )
, mRequestedGeomType( p->mRequestedGeomType )
, mSqlWhereClause( p->mSqlWhereClause )
, mPrimaryKeyType( p->mPrimaryKeyType )
, mPrimaryKeyAttrs( p->mPrimaryKeyAttrs )
, mQuery( p->mQuery )
, mShared( p->mShared )
{
}

Expand Down
40 changes: 20 additions & 20 deletions src/providers/oracle/qgsoraclefeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@ class QgsOracleProvider;

class QgsOracleFeatureSource : public QgsAbstractFeatureSource
{
public:
QgsOracleFeatureSource( const QgsOracleProvider* p );

virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );

protected:
QgsDataSourceURI mUri;
QgsFields mFields;

QString mGeometryColumn; //! name of the geometry column
int mSrid; //! srid of column
QString mSpatialIndex; //! name of spatial index of geometry column
QGis::WkbType mDetectedGeomType; //! geometry type detected in the database
QGis::WkbType mRequestedGeomType; //! geometry type requested in the uri
QString mSqlWhereClause;
QgsOraclePrimaryKeyType mPrimaryKeyType;
QList<int> mPrimaryKeyAttrs;
QString mQuery;
public:
QgsOracleFeatureSource( const QgsOracleProvider* p );

QSharedPointer<QgsOracleSharedData> mShared;
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );

friend class QgsOracleFeatureIterator;
protected:
QgsDataSourceURI mUri;
QgsFields mFields;

QString mGeometryColumn; //! name of the geometry column
int mSrid; //! srid of column
QString mSpatialIndex; //! name of spatial index of geometry column
QGis::WkbType mDetectedGeomType; //! geometry type detected in the database
QGis::WkbType mRequestedGeomType; //! geometry type requested in the uri
QString mSqlWhereClause;
QgsOraclePrimaryKeyType mPrimaryKeyType;
QList<int> mPrimaryKeyAttrs;
QString mQuery;

QSharedPointer<QgsOracleSharedData> mShared;

friend class QgsOracleFeatureIterator;
};


Expand Down
2 changes: 1 addition & 1 deletion src/providers/oracle/qgsoracleprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2966,7 +2966,7 @@ QGISEXTERN bool deleteLayer( const QString& uri, QString& errCause )


QgsOracleSharedData::QgsOracleSharedData()
: mFidCounter( 0 )
: mFidCounter( 0 )
{
}

Expand Down
48 changes: 24 additions & 24 deletions src/providers/oracle/qgsoracleprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,18 +410,18 @@ class QgsOracleProvider : public QgsVectorDataProvider
/** Assorted Oracle utility functions */
class QgsOracleUtils
{
public:
static QString whereClause( QgsFeatureId featureId,
const QgsFields& fields,
QgsOraclePrimaryKeyType primaryKeyType,
const QList<int>& primaryKeyAttrs,
QSharedPointer<QgsOracleSharedData> sharedData );

static QString whereClause( QgsFeatureIds featureIds,
const QgsFields& fields,
QgsOraclePrimaryKeyType primaryKeyType,
const QList<int>& primaryKeyAttrs,
QSharedPointer<QgsOracleSharedData> sharedData );
public:
static QString whereClause( QgsFeatureId featureId,
const QgsFields& fields,
QgsOraclePrimaryKeyType primaryKeyType,
const QList<int>& primaryKeyAttrs,
QSharedPointer<QgsOracleSharedData> sharedData );

static QString whereClause( QgsFeatureIds featureIds,
const QgsFields& fields,
QgsOraclePrimaryKeyType primaryKeyType,
const QList<int>& primaryKeyAttrs,
QSharedPointer<QgsOracleSharedData> sharedData );
};


Expand All @@ -430,21 +430,21 @@ class QgsOracleUtils
* from different threads and therefore locking has to be involved. */
class QgsOracleSharedData
{
public:
QgsOracleSharedData();
public:
QgsOracleSharedData();

// FID lookups
QgsFeatureId lookupFid( const QVariant &v ); // lookup existing mapping or add a new one
QVariant removeFid( QgsFeatureId fid );
void insertFid( QgsFeatureId fid, const QVariant& k );
QVariant lookupKey( QgsFeatureId featureId );
// FID lookups
QgsFeatureId lookupFid( const QVariant &v ); // lookup existing mapping or add a new one
QVariant removeFid( QgsFeatureId fid );
void insertFid( QgsFeatureId fid, const QVariant& k );
QVariant lookupKey( QgsFeatureId featureId );

protected:
QMutex mMutex; //!< Access to all data members is guarded by the mutex
protected:
QMutex mMutex; //!< Access to all data members is guarded by the mutex

QgsFeatureId mFidCounter; // next feature id if map is used
QMap<QVariant, QgsFeatureId> mKeyToFid; // map key values to feature id
QMap<QgsFeatureId, QVariant> mFidToKey; // map feature back to fea
QgsFeatureId mFidCounter; // next feature id if map is used
QMap<QVariant, QgsFeatureId> mKeyToFid; // map key values to feature id
QMap<QgsFeatureId, QVariant> mFidToKey; // map feature back to fea
};


Expand Down
6 changes: 3 additions & 3 deletions src/providers/postgres/qgspostgresconnpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@


QgsPostgresConnPoolGroup::QgsPostgresConnPoolGroup( const QString& ci )
: connInfo( ci )
, sem( POSTGRES_MAX_CONCURRENT_CONNS )
, expirationTimer( this )
: connInfo( ci )
, sem( POSTGRES_MAX_CONCURRENT_CONNS )
, expirationTimer( this )
{
// just to make sure the object belongs to main thread and thus will get events
moveToThread( qApp->thread() );
Expand Down
64 changes: 32 additions & 32 deletions src/providers/postgres/qgspostgresconnpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,35 @@ class QgsPostgresConn;
//! stores data related to one server
class QgsPostgresConnPoolGroup : public QObject
{
Q_OBJECT
public:
Q_OBJECT
public:

static const int maxConcurrentConnections;
static const int maxConcurrentConnections;

struct Item
{
QgsPostgresConn* c;
QTime lastUsedTime;
};
struct Item
{
QgsPostgresConn* c;
QTime lastUsedTime;
};

QgsPostgresConnPoolGroup( const QString& ci );
~QgsPostgresConnPoolGroup();
QgsPostgresConnPoolGroup( const QString& ci );
~QgsPostgresConnPoolGroup();

QgsPostgresConn* acquire();
QgsPostgresConn* acquire();

void release( QgsPostgresConn* conn );
void release( QgsPostgresConn* conn );

protected slots:
void handleConnectionExpired();
protected slots:
void handleConnectionExpired();

protected:
Q_DISABLE_COPY(QgsPostgresConnPoolGroup)
protected:
Q_DISABLE_COPY( QgsPostgresConnPoolGroup )

QString connInfo;
QStack<Item> conns;
QMutex connMutex;
QSemaphore sem;
QTimer expirationTimer;
QString connInfo;
QStack<Item> conns;
QMutex connMutex;
QSemaphore sem;
QTimer expirationTimer;
};

typedef QMap<QString, QgsPostgresConnPoolGroup*> QgsPostgresConnPoolGroups;
Expand All @@ -81,22 +81,22 @@ typedef QMap<QString, QgsPostgresConnPoolGroup*> QgsPostgresConnPoolGroups;
*/
class QgsPostgresConnPool
{
public:
public:

static QgsPostgresConnPool* instance();
static QgsPostgresConnPool* instance();

//! Try to acquire a connection: if no connections are available, the thread will get blocked.
//! @return initialized connection or null on error
QgsPostgresConn* acquireConnection( const QString& connInfo );
//! Try to acquire a connection: if no connections are available, the thread will get blocked.
//! @return initialized connection or null on error
QgsPostgresConn* acquireConnection( const QString& connInfo );

//! Release an existing connection so it will get back into the pool and can be reused
void releaseConnection( QgsPostgresConn* conn );
//! Release an existing connection so it will get back into the pool and can be reused
void releaseConnection( QgsPostgresConn* conn );

protected:
QgsPostgresConnPoolGroups mGroups;
QMutex mMutex;
protected:
QgsPostgresConnPoolGroups mGroups;
QMutex mMutex;

static QgsPostgresConnPool* mInstance;
static QgsPostgresConnPool* mInstance;
};

#endif // QGSPOSTGRESCONNPOOL_H
376 changes: 188 additions & 188 deletions src/providers/postgres/qgspostgresfeatureiterator.cpp

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions src/providers/postgres/qgspostgresfeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,31 @@ class QgsPostgresResult;

class QgsPostgresFeatureSource : public QgsAbstractFeatureSource
{
public:
QgsPostgresFeatureSource( const QgsPostgresProvider* p );
public:
QgsPostgresFeatureSource( const QgsPostgresProvider* p );

virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );

protected:
protected:

QString mConnInfo;
QString mConnInfo;

QString mGeometryColumn;
QString mSqlWhereClause;
QgsFields mFields;
QgsPostgresGeometryColumnType mSpatialColType;
QString mRequestedSrid;
QString mDetectedSrid;
QGis::WkbType mRequestedGeomType; //! geometry type requested in the uri
QGis::WkbType mDetectedGeomType; //! geometry type detected in the database
QgsPostgresPrimaryKeyType mPrimaryKeyType;
QList<int> mPrimaryKeyAttrs;
QString mQuery;
// TODO: loadFields()
QString mGeometryColumn;
QString mSqlWhereClause;
QgsFields mFields;
QgsPostgresGeometryColumnType mSpatialColType;
QString mRequestedSrid;
QString mDetectedSrid;
QGis::WkbType mRequestedGeomType; //! geometry type requested in the uri
QGis::WkbType mDetectedGeomType; //! geometry type detected in the database
QgsPostgresPrimaryKeyType mPrimaryKeyType;
QList<int> mPrimaryKeyAttrs;
QString mQuery;
// TODO: loadFields()

QSharedPointer<QgsPostgresSharedData> mShared;
QSharedPointer<QgsPostgresSharedData> mShared;

friend class QgsPostgresFeatureIterator;
friend class QgsPostgresFeatureIterator;
};


Expand Down
4 changes: 2 additions & 2 deletions src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3554,8 +3554,8 @@ QGISEXTERN QString getStyleById( const QString& uri, QString styleId, QString& e
// ----------

QgsPostgresSharedData::QgsPostgresSharedData()
: mFeaturesCounted( -1 )
, mFidCounter( 0 )
: mFeaturesCounted( -1 )
, mFidCounter( 0 )
{
}

Expand Down
62 changes: 31 additions & 31 deletions src/providers/postgres/qgspostgresprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,49 +482,49 @@ class QgsPostgresProvider : public QgsVectorDataProvider
/** Assorted Postgres utility functions */
class QgsPostgresUtils
{
public:
static QString whereClause( QgsFeatureId featureId,
const QgsFields& fields,
QgsPostgresConn* conn,
QgsPostgresPrimaryKeyType pkType,
const QList<int>& pkAttrs,
QSharedPointer<QgsPostgresSharedData> sharedData );

static QString whereClause( QgsFeatureIds featureIds,
const QgsFields& fields,
QgsPostgresConn* conn,
QgsPostgresPrimaryKeyType pkType,
const QList<int>& pkAttrs,
QSharedPointer<QgsPostgresSharedData> sharedData );
public:
static QString whereClause( QgsFeatureId featureId,
const QgsFields& fields,
QgsPostgresConn* conn,
QgsPostgresPrimaryKeyType pkType,
const QList<int>& pkAttrs,
QSharedPointer<QgsPostgresSharedData> sharedData );

static QString whereClause( QgsFeatureIds featureIds,
const QgsFields& fields,
QgsPostgresConn* conn,
QgsPostgresPrimaryKeyType pkType,
const QList<int>& pkAttrs,
QSharedPointer<QgsPostgresSharedData> sharedData );
};

/** Data shared between provider class and its feature sources. Ideally there should
* be as few members as possible because there could be simultaneous reads/writes
* from different threads and therefore locking has to be involved. */
class QgsPostgresSharedData
{
public:
QgsPostgresSharedData();
public:
QgsPostgresSharedData();

long featuresCounted();
void setFeaturesCounted( long count );
void addFeaturesCounted( long diff );
void ensureFeaturesCountedAtLeast( long fetched );
long featuresCounted();
void setFeaturesCounted( long count );
void addFeaturesCounted( long diff );
void ensureFeaturesCountedAtLeast( long fetched );

// FID lookups
QgsFeatureId lookupFid( const QVariant &v ); // lookup existing mapping or add a new one
QVariant removeFid( QgsFeatureId fid );
void insertFid( QgsFeatureId fid, const QVariant& k );
QVariant lookupKey( QgsFeatureId featureId );
// FID lookups
QgsFeatureId lookupFid( const QVariant &v ); // lookup existing mapping or add a new one
QVariant removeFid( QgsFeatureId fid );
void insertFid( QgsFeatureId fid, const QVariant& k );
QVariant lookupKey( QgsFeatureId featureId );

protected:
QMutex mMutex; //!< Access to all data members is guarded by the mutex
protected:
QMutex mMutex; //!< Access to all data members is guarded by the mutex

long mFeaturesCounted; //! Number of features in the layer
long mFeaturesCounted; //! Number of features in the layer

QgsFeatureId mFidCounter; // next feature id if map is used
QMap<QVariant, QgsFeatureId> mKeyToFid; // map key values to feature id
QMap<QgsFeatureId, QVariant> mFidToKey; // map feature back to fea
QgsFeatureId mFidCounter; // next feature id if map is used
QMap<QVariant, QgsFeatureId> mKeyToFid; // map key values to feature id
QMap<QgsFeatureId, QVariant> mFidToKey; // map feature back to fea
};

#endif
28 changes: 14 additions & 14 deletions src/providers/spatialite/qgsspatialitefeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ void QgsSpatiaLiteFeatureIterator::getFeatureGeometry( sqlite3_stmt* stmt, int i
const void *blob = sqlite3_column_blob( stmt, ic );
size_t blob_size = sqlite3_column_bytes( stmt, ic );
QgsSpatiaLiteProvider::convertToGeosWKB(( const unsigned char * )blob, blob_size,
&featureGeom, &geom_size );
&featureGeom, &geom_size );
if ( featureGeom )
feature.setGeometryAndOwnership( featureGeom, geom_size );
else
Expand All @@ -391,19 +391,19 @@ void QgsSpatiaLiteFeatureIterator::getFeatureGeometry( sqlite3_stmt* stmt, int i


QgsSpatiaLiteFeatureSource::QgsSpatiaLiteFeatureSource( const QgsSpatiaLiteProvider* p )
: mGeometryColumn( p->mGeometryColumn )
, mSubsetString( p->mSubsetString )
, mFields( p->attributeFields )
, mQuery( p->mQuery )
, isQuery( p->isQuery )
, mVShapeBased( p->mVShapeBased )
, mIndexTable( p->mIndexTable )
, mIndexGeometry( p->mIndexGeometry )
, mPrimaryKey( p->mPrimaryKey )
, spatialIndexRTree( p->spatialIndexRTree )
, spatialIndexMbrCache( p->spatialIndexMbrCache )
, handle( QgsSpatiaLiteProvider::SqliteHandles::openDb( p->mSqlitePath ) )
, sqliteHandle( handle->handle() )
: mGeometryColumn( p->mGeometryColumn )
, mSubsetString( p->mSubsetString )
, mFields( p->attributeFields )
, mQuery( p->mQuery )
, isQuery( p->isQuery )
, mVShapeBased( p->mVShapeBased )
, mIndexTable( p->mIndexTable )
, mIndexGeometry( p->mIndexGeometry )
, mPrimaryKey( p->mPrimaryKey )
, spatialIndexRTree( p->spatialIndexRTree )
, spatialIndexMbrCache( p->spatialIndexMbrCache )
, handle( QgsSpatiaLiteProvider::SqliteHandles::openDb( p->mSqlitePath ) )
, sqliteHandle( handle->handle() )
{
}

Expand Down
46 changes: 23 additions & 23 deletions src/providers/spatialite/qgsspatialitefeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,29 @@ class QgsSpatiaLiteProvider;

class QgsSpatiaLiteFeatureSource : public QgsAbstractFeatureSource
{
public:
QgsSpatiaLiteFeatureSource( const QgsSpatiaLiteProvider* p );
~QgsSpatiaLiteFeatureSource();

virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );

protected:
QString mGeometryColumn;
QString mSubsetString;
QgsFields mFields;
QString mQuery;
bool isQuery;
bool mVShapeBased;
QString mIndexTable;
QString mIndexGeometry;
QString mPrimaryKey;
bool spatialIndexRTree;
bool spatialIndexMbrCache;

QgsSpatiaLiteProvider::SqliteHandles* handle;
sqlite3 *sqliteHandle;

friend class QgsSpatiaLiteFeatureIterator;
public:
QgsSpatiaLiteFeatureSource( const QgsSpatiaLiteProvider* p );
~QgsSpatiaLiteFeatureSource();

virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );

protected:
QString mGeometryColumn;
QString mSubsetString;
QgsFields mFields;
QString mQuery;
bool isQuery;
bool mVShapeBased;
QString mIndexTable;
QString mIndexGeometry;
QString mPrimaryKey;
bool spatialIndexRTree;
bool spatialIndexMbrCache;

QgsSpatiaLiteProvider::SqliteHandles* handle;
sqlite3 *sqliteHandle;

friend class QgsSpatiaLiteFeatureIterator;
};

class QgsSpatiaLiteFeatureIterator : public QgsAbstractFeatureIteratorFromSource<QgsSpatiaLiteFeatureSource>
Expand Down
8 changes: 4 additions & 4 deletions src/providers/spatialite/qgsspatialiteprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,14 +414,14 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
bool getFeature( sqlite3_stmt *stmt, bool fetchGeometry,
QgsFeature &feature,
const QgsAttributeList &fetchAttributes );
public:
public:
// static functions

static void convertToGeosWKB( const unsigned char *blob, size_t blob_size,
unsigned char **wkb, size_t *geom_size );
unsigned char **wkb, size_t *geom_size );
static int computeMultiWKB3Dsize( const unsigned char *p_in, int little_endian,
int endian_arch );
private:
int endian_arch );
private:
int computeSizeFromMultiWKB2D( const unsigned char *p_in, int nDims,
int little_endian,
int endian_arch );
Expand Down
32 changes: 16 additions & 16 deletions src/providers/wcs/qgswcsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,13 +780,13 @@ void QgsWcsProvider::getCache( int bandNo, QgsRectangle const & viewExtent, int
}

#if 0
QFile myFile( "/tmp/qgiswcscache.dat" );
if ( myFile.open( QIODevice::WriteOnly ) )
{
QDataStream myStream( &myFile );
myStream.writeRawData( mCachedData.data(), mCachedData.size() );
myFile.close();
}
QFile myFile( "/tmp/qgiswcscache.dat" );
if ( myFile.open( QIODevice::WriteOnly ) )
{
QDataStream myStream( &myFile );
myStream.writeRawData( mCachedData.data(), mCachedData.size() );
myFile.close();
}
#endif

mCachedMemFile = VSIFileFromMemBuffer( TO8F( mCachedMemFilename ),
Expand Down Expand Up @@ -932,10 +932,10 @@ bool QgsWcsProvider::parseServiceExceptionReportDom( QByteArray const & xml, con
{
errorTitle = tr( "Dom Exception" );
errorText = tr( "Could not get WCS Service Exception at %1 at line %2 column %3\n\nResponse was:\n\n%4" )
.arg( errorMsg )
.arg( errorLine )
.arg( errorColumn )
.arg( QString( xml ) );
.arg( errorMsg )
.arg( errorLine )
.arg( errorColumn )
.arg( QString( xml ) );

QgsLogger::debug( "Dom Exception: " + errorText );

Expand Down Expand Up @@ -1657,11 +1657,11 @@ QGISEXTERN bool isProvider()
int QgsWcsDownloadHandler::sErrors = 0;

QgsWcsDownloadHandler::QgsWcsDownloadHandler( const QUrl& url, QgsWcsAuthorization& auth, QNetworkRequest::CacheLoadControl cacheLoadControl, QByteArray& cachedData, const QString& wcsVersion, QgsError& cachedError )
: mNAM( new QgsNetworkAccessManager )
, mEventLoop( new QEventLoop )
, mCachedData( cachedData )
, mWcsVersion( wcsVersion )
, mCachedError( cachedError )
: mNAM( new QgsNetworkAccessManager )
, mEventLoop( new QEventLoop )
, mCachedData( cachedData )
, mWcsVersion( wcsVersion )
, mCachedError( cachedError )
{
mNAM->setupDefaultProxyAndCache();

Expand Down
34 changes: 17 additions & 17 deletions src/providers/wcs/qgswcsprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,30 +407,30 @@ class QgsWcsProvider : public QgsRasterDataProvider, QgsGdalProviderBase
/** Handler for downloading of coverage data - output is written to mCachedData */
class QgsWcsDownloadHandler : public QObject
{
Q_OBJECT
public:
QgsWcsDownloadHandler( const QUrl& url, QgsWcsAuthorization& auth, QNetworkRequest::CacheLoadControl cacheLoadControl, QByteArray& cachedData, const QString& wcsVersion, QgsError& cachedError );
~QgsWcsDownloadHandler();
Q_OBJECT
public:
QgsWcsDownloadHandler( const QUrl& url, QgsWcsAuthorization& auth, QNetworkRequest::CacheLoadControl cacheLoadControl, QByteArray& cachedData, const QString& wcsVersion, QgsError& cachedError );
~QgsWcsDownloadHandler();

void blockingDownload();
void blockingDownload();

protected slots:
void cacheReplyFinished();
void cacheReplyProgress( qint64, qint64 );
protected slots:
void cacheReplyFinished();
void cacheReplyProgress( qint64, qint64 );

protected:
void finish() { QMetaObject::invokeMethod( mEventLoop, "quit", Qt::QueuedConnection ); }
protected:
void finish() { QMetaObject::invokeMethod( mEventLoop, "quit", Qt::QueuedConnection ); }

QgsNetworkAccessManager* mNAM;
QEventLoop* mEventLoop;
QgsNetworkAccessManager* mNAM;
QEventLoop* mEventLoop;

QNetworkReply* mCacheReply;
QNetworkReply* mCacheReply;

QByteArray& mCachedData;
QString mWcsVersion;
QgsError& mCachedError;
QByteArray& mCachedData;
QString mWcsVersion;
QgsError& mCachedError;

static int sErrors; // this should be ideally per-provider...?
static int sErrors; // this should be ideally per-provider...?
};


Expand Down
6 changes: 3 additions & 3 deletions src/providers/wfs/qgswfsfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ void QgsWFSFeatureIterator::copyFeature( const QgsFeature* f, QgsFeature& featur
// -------------------------

QgsWFSFeatureSource::QgsWFSFeatureSource( const QgsWFSProvider* p )
: mFields( p->mFields )
, mFeatures( p->mFeatures )
, mSpatialIndex( p->mSpatialIndex ? new QgsSpatialIndex( *p->mSpatialIndex ) : 0 ) // just shallow copy
: mFields( p->mFields )
, mFeatures( p->mFeatures )
, mSpatialIndex( p->mSpatialIndex ? new QgsSpatialIndex( *p->mSpatialIndex ) : 0 ) // just shallow copy
{
}

Expand Down
18 changes: 9 additions & 9 deletions src/providers/wfs/qgswfsfeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ typedef QMap<QgsFeatureId, QgsFeature*> QgsFeaturePtrMap;

class QgsWFSFeatureSource : public QgsAbstractFeatureSource
{
public:
QgsWFSFeatureSource( const QgsWFSProvider* p );
~QgsWFSFeatureSource();
public:
QgsWFSFeatureSource( const QgsWFSProvider* p );
~QgsWFSFeatureSource();

QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );
QgsFeatureIterator getFeatures( const QgsFeatureRequest& request );

protected:
protected:

QgsFields mFields;
QgsFeaturePtrMap mFeatures;
QgsSpatialIndex* mSpatialIndex;
QgsFields mFields;
QgsFeaturePtrMap mFeatures;
QgsSpatialIndex* mSpatialIndex;

friend class QgsWFSFeatureIterator;
friend class QgsWFSFeatureIterator;
};

class QgsWFSFeatureIterator : public QgsAbstractFeatureIteratorFromSource<QgsWFSFeatureSource>
Expand Down
Loading