qgis_threaded_render.v1.diff

first draft of patch - makes maplayers qthread children - Tim Sutton, 2009-10-27 04:05 PM

Download (4.55 KB)

View differences:

src/core/qgsvectorlayer.cpp (working copy)
646 646
  return ptr;
647 647
}
648 648

  
649
void QgsVectorLayer::run( )
650
{
651
    draw( mRenderContext );
652
}
653

  
649 654
bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
650 655
{
651 656
  //set update threshold before each draw to make sure the current setting is picked up
src/core/raster/qgsrasterlayer.cpp (working copy)
1343 1343
  return mDataProvider;
1344 1344
}
1345 1345

  
1346
void QgsRasterLayer::run( )
1347
{
1348
    draw( mRenderContext );
1349
}
1350

  
1346 1351
bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
1347 1352
{
1348 1353
  QgsDebugMsg( "entered. (renderContext)" );
src/core/raster/qgsrasterlayer.h (working copy)
455 455
    /** Returns the data provider in a const-correct manner */
456 456
    const QgsRasterDataProvider* dataProvider() const;
457 457

  
458
    /** Render the layer in a thread.
459
     * @note Added in QGIS 1.4
460
     */
461
    void run();
462

  
458 463
    /** \brief This is called when the view on the raster layer needs to be redrawn */
459 464
    bool draw( QgsRenderContext& rendererContext );
460 465

  
src/core/qgsmaplayer.cpp (working copy)
133 133
  return mLayerExtent;
134 134
}
135 135

  
136
void  QgsMapLayer::setRenderContext( QgsRenderContext theContext )
137
{
138
  mRenderContext = theContext;
139
}
140

  
141
void QgsMapLayer::run( )
142
{
143
  return ;
144
}
145

  
136 146
bool QgsMapLayer::draw( QgsRenderContext& rendererContext )
137 147
{
138 148
  return false;
src/core/qgsvectorlayer.h (working copy)
363 363
                         QgsSnappingResult > & snappingResults,
364 364
                         QgsSnapper::SnappingType snap_to );
365 365

  
366
    /** Draw the layer in its own thread 
367
     * @note - added in QGIS 1.4
368
     */
369
    void run();
366 370
    /** Draws the layer
367 371
     *  @return FALSE if an error occurred during drawing
368 372
     */
src/core/qgsmaplayer.h (working copy)
25 25
#include <QObject>
26 26
#include <QUndoStack>
27 27
#include <QImage>
28
#include <QThread>
28 29

  
29 30
#include "qgsrectangle.h"
30 31

  
31
class QgsRenderContext;
32 32
class QgsCoordinateReferenceSystem;
33 33

  
34 34
class QDomNode;
......
36 36
class QKeyEvent;
37 37
class QPainter;
38 38

  
39
#include "qgsrendercontext.h"
40

  
39 41
/** \ingroup core
40 42
 * Base class for all map layer types.
41 43
 * This is the base class for all map layer types (vector, raster).
42 44
 */
43
class CORE_EXPORT QgsMapLayer : public QObject
45
class CORE_EXPORT QgsMapLayer : public QThread
44 46
{
45
    Q_OBJECT
47
    Q_OBJECT;
46 48

  
47 49
  public:
48 50
    /** Layers enum defining the types of layers that can be added to a map */
......
79 81
     */
80 82
    QString const & name() const;
81 83

  
84
    /** Render this layer onto the paint device 
85
     * specified in mRenderContext in a separate thread.
86
     *
87
     * @note Added in QGIS 1.4
88
     */
89
    virtual void run();
90

  
91
    /** Set the render context onto which the layer will
92
     * be drawn when the thread is started.
93
     * @see run()
94
     * @note Added in QGIS 1.4
95
     */
96
    void setRenderContext( QgsRenderContext theContext );
97

  
82 98
    /** This is the method that does the actual work of 
83 99
     * drawing the layer onto a paint device.
84 100
     * @param QgsRenderContext - describes the extents, 
85 101
     * resolution etc. that should be used when rendering the 
86 102
     * layer.
103
     * @note From QGIS 1.4 onwards for threaded drawing you should rather 
104
     * use setRenderContext and then call run() rather than call this
105
     * method which may be deprecated in the future.
87 106
     */
88 107
    virtual bool draw( QgsRenderContext& rendererContext );
89 108

  
......
381 400
     * @note This property was added in QGIS 1.4 **/
382 401
    QImage * mpCacheImage;
383 402

  
403
  protected:
404
    /** Render context defining the scale etc and paint device
405
     * onto which the layer should be rendered when run is called. */
406
    QgsRenderContext mRenderContext;
384 407
};
385 408

  
386 409
#endif