USGS

Isis 3.0 Object Programmers' Reference

Home

ViewportBuffer.h

Go to the documentation of this file.
00001 #ifndef ViewportBuffer_h
00002 #define ViewportBuffer_h
00003 
00027 #include <vector>
00028 
00029 #include <QRect>
00030 
00031 #include "Cube.h"
00032 #include "Brick.h"
00033 
00034 // parent
00035 #include <QObject>
00036 
00037 template<class T > class QQueue;
00038 class QRect;
00039 
00040 namespace Isis {
00041   class CubeDataThread;
00042   class Brick;
00043   class CubeViewport;
00044   class ViewportBufferAction;
00045   class ViewportBufferFill;
00046   class ViewportBufferStretch;
00047   class ViewportBufferTransform;
00048 
00078   class ViewportBuffer : public QObject {
00079       Q_OBJECT
00080 
00081     public:
00082       ViewportBuffer(CubeViewport *viewport, CubeDataThread *cubeData,
00083                      int cubeId);
00084       virtual ~ViewportBuffer();
00085 
00086       const std::vector<double> &getLine(int line);
00087 
00088       void resizedViewport();
00089       void pan(int deltaX, int deltaY);
00090 
00091       void scaleChanged();
00092 
00093       void fillBuffer(QRect rect);
00094       void fillBuffer(QRect rect, const Brick *data);
00095 
00096       void emptyBuffer(bool force = false);
00097 
00098       QRect bufferXYRect();
00099 
00100       void setBand(int band);
00101 
00103       int getBand() {
00104         return p_band;
00105       }
00106 
00107       void enable(bool enabled);
00108 
00109       void addStretchAction();
00110 
00111       double currentProgress();
00112       double totalUnfilledArea();
00113 
00120       bool enabled() {
00121         return p_enabled;
00122       }
00123       bool working();
00124 
00125       bool hasEntireCube();
00126 
00127     public slots:
00128       void DataReady(void *requester, int cubeId, const Isis::Brick *brick);
00129 
00130     signals:
00142       void ReadCube(int cubeId, int startSample, int startLine,
00143                     int endSample, int endLine, int band, void *caller);
00144 
00146       void DoneWithData(int, const Isis::Brick *);
00147 
00148     private:
00149       QRect getXYBoundingRect();
00150       QList<double> getSampLineBoundingRect();
00151       void updateBoundingRects();
00152       void doQueuedActions();
00153       void doTransformAction(ViewportBufferTransform *action);
00154       void doStretchAction(ViewportBufferStretch *action);
00155       void startFillAction(ViewportBufferFill *action);
00156 
00157       ViewportBufferFill *createViewportBufferFill(QRect, bool);
00158 
00159       void requestCubeLine(ViewportBufferFill *fill);
00160 
00161       void resizeBuffer(unsigned int width, unsigned int height);
00162       void shiftBuffer(int deltaX, int deltaY);
00163       void reinitialize();
00164       bool actionsPreserveData();
00165       bool reinitializeActionExists();
00166       void enqueueAction(ViewportBufferAction *);
00167 
00168       CubeViewport *p_viewport;  
00169       int p_cubeId; 
00170       CubeDataThread *p_dataThread;  
00171 
00172       int p_band; 
00173 
00174       bool p_enabled; 
00175       std::vector< std::vector<double> > p_buffer; 
00176       bool p_bufferInitialized; 
00177 
00182       QRect p_XYBoundingRect;
00183       QRect p_oldXYBoundingRect; 
00184 
00191       QList< double > p_sampLineBoundingRect;
00192       QList< double > p_oldSampLineBoundingRect; 
00193       int p_viewportHeight; 
00194       int p_oldViewportHeight; 
00195       int p_vertScrollBarPos; 
00196       int p_oldVertScrollBarPos; 
00197       bool p_initialStretchDone; 
00198       double p_requestedFillArea; 
00199 
00203       enum sampLineRectPosition {
00204         rectLeft = 0, 
00205         rectTop,  
00206         rectRight, 
00207         rectBottom 
00208       };
00209 
00215       QQueue< ViewportBufferAction * > * p_actions;
00216       
00217       bool p_bricksOrdered;
00218   };
00219 }
00220 
00221 #endif