Skip to content
Permalink
Browse files

Small code cleanups

  • Loading branch information
wonder-sk committed Sep 2, 2016
1 parent 8d832d8 commit 80f022878f4698efe694acff3f53c1a556afbe3a
@@ -9,7 +9,21 @@ class QgsRasterBlockFeedback : QgsFeedback
%TypeHeaderCode
#include <qgsrasterinterface.h>
%End
// TODO: extend with preview functionality??

public:
//! construct a new raster block feedback object
QgsRasterBlockFeedback( QObject* parent = nullptr );

//! whether the raster provider should return only data that are already available
//! without waiting for full result
bool preview_only;

//! whether our painter is drawing to a temporary image used just by this layer
bool render_partial_output;

//! may be emitted by raster data provider to indicate that some partial data are available
//! and a new preview image may be produced
virtual void onNewData();
};


@@ -37,6 +37,7 @@
class CORE_EXPORT QgsRasterBlockFeedback : public QgsFeedback
{
public:
//! construct a new raster block feedback object
QgsRasterBlockFeedback( QObject* parent = nullptr ) : QgsFeedback( parent ), preview_only( false ), render_partial_output( false ) {}

//! whether the raster provider should return only data that are already available
@@ -29,7 +29,7 @@ QgsRasterLayerRenderer::QgsRasterLayerRenderer( QgsRasterLayer* layer, QgsRender
, mRasterViewPort( nullptr )
, mPipe( nullptr )
, mContext( rendererContext )
, mFeedback( new MyFeedback( this ) )
, mFeedback( new Feedback( this ) )
{
mPainter = rendererContext.painter();
const QgsMapToPixel& theQgsMapToPixel = rendererContext.mapToPixel();
@@ -227,14 +227,14 @@ QgsFeedback* QgsRasterLayerRenderer::feedback() const
return mFeedback;
}

MyFeedback::MyFeedback( QgsRasterLayerRenderer *r )
QgsRasterLayerRenderer::Feedback::Feedback( QgsRasterLayerRenderer *r )
: mR( r )
, mMinimalPreviewInterval( 250 )
{
render_partial_output = r->mContext.testFlag( QgsRenderContext::RenderPartialOutput );
}

void MyFeedback::onNewData()
void QgsRasterLayerRenderer::Feedback::onNewData()
{
qDebug( "\nGOT NEW DATA!\n" );

@@ -31,18 +31,6 @@ class QgsRasterLayerRenderer;

#include "qgsrasterinterface.h"

class MyFeedback : public QgsRasterBlockFeedback
{
public:
explicit MyFeedback( QgsRasterLayerRenderer* r );

virtual void onNewData() override;
private:
QgsRasterLayerRenderer* mR;
int mMinimalPreviewInterval; //!< in miliseconds
QTime mLastPreview;
};


/** \ingroup core
* Implementation of threaded rendering for raster layers.
@@ -69,8 +57,22 @@ class QgsRasterLayerRenderer : public QgsMapLayerRenderer
QgsRasterPipe* mPipe;
QgsRenderContext& mContext;

MyFeedback* mFeedback;
friend class MyFeedback;
//! Specific feedback class to provide preview of raster layer rendering.
class Feedback : public QgsRasterBlockFeedback
{
public:
explicit Feedback( QgsRasterLayerRenderer* r );

//! when notified of new data in data provider it launches a preview draw of the raster
virtual void onNewData() override;
private:
QgsRasterLayerRenderer* mR; //!< parent renderer instance
int mMinimalPreviewInterval; //!< in miliseconds
QTime mLastPreview; //!< when last preview has been generated
};

//! feedback class for cancellation and preview generation
Feedback* mFeedback;
};


0 comments on commit 80f0228

Please sign in to comment.
You can’t perform that action at this time.