Isis Developer Reference
ViewportBuffer.h
Go to the documentation of this file.
1#ifndef ViewportBuffer_h
2#define ViewportBuffer_h
3
10/* SPDX-License-Identifier: CC0-1.0 */
11
12#include <vector>
13
14#include <QRect>
15
16#include "Cube.h"
17#include "Brick.h"
18
19// parent
20#include <QObject>
21
22template<class T > class QQueue;
23class QRect;
24
25namespace Isis {
26 class CubeDataThread;
27 class Brick;
28 class CubeViewport;
29 class ViewportBufferAction;
30 class ViewportBufferFill;
31 class ViewportBufferStretch;
32 class ViewportBufferTransform;
33
63 class ViewportBuffer : public QObject {
64 Q_OBJECT
65
66 public:
67 ViewportBuffer(CubeViewport *viewport, CubeDataThread *cubeData,
68 int cubeId);
69 virtual ~ViewportBuffer();
70
71 const std::vector<double> &getLine(int line);
72
73 void resizedViewport();
74 void pan(int deltaX, int deltaY);
75
76 void scaleChanged();
77
78 void fillBuffer(QRect rect);
79 void fillBuffer(QRect rect, const Brick *data);
80
81 void emptyBuffer(bool force = false);
82
83 QRect bufferXYRect();
84
85 void setBand(int band);
86
88 int getBand() {
89 return p_band;
90 }
91
92 void enable(bool enabled);
93
94 void addStretchAction();
95
96 double currentProgress();
97 double totalUnfilledArea();
98
105 bool enabled() {
106 return p_enabled;
107 }
108 bool working();
109
110 bool hasEntireCube();
111
112 public slots:
113 void DataReady(void *requester, int cubeId, const Isis::Brick *brick);
114
115 signals:
127 void ReadCube(int cubeId, int startSample, int startLine,
128 int endSample, int endLine, int band, void *caller);
129
131 void DoneWithData(int, const Isis::Brick *);
132
133 private:
134 QRect getXYBoundingRect();
135 QList<double> getSampLineBoundingRect();
136 void updateBoundingRects();
137 void doQueuedActions();
138 void doTransformAction(ViewportBufferTransform *action);
139 void doStretchAction(ViewportBufferStretch *action);
140 void startFillAction(ViewportBufferFill *action);
141
142 ViewportBufferFill *createViewportBufferFill(QRect, bool);
143
144 void requestCubeLine(ViewportBufferFill *fill);
145
146 void resizeBuffer(unsigned int width, unsigned int height);
147 void shiftBuffer(int deltaX, int deltaY);
148 void reinitialize();
149 bool actionsPreserveData();
150 bool reinitializeActionExists();
151 void enqueueAction(ViewportBufferAction *);
152
153 CubeViewport *p_viewport;
154 int p_cubeId;
155 CubeDataThread *p_dataThread;
156
157 int p_band;
158
159 bool p_enabled;
160 std::vector< std::vector<double> > p_buffer;
161 bool p_bufferInitialized;
162
167 QRect p_XYBoundingRect;
168 QRect p_oldXYBoundingRect;
169
176 QList< double > p_sampLineBoundingRect;
177 QList< double > p_oldSampLineBoundingRect;
178 int p_viewportHeight;
179 int p_oldViewportHeight;
180 int p_vertScrollBarPos;
181 int p_oldVertScrollBarPos;
182 bool p_initialStretchDone;
183 double p_requestedFillArea;
184
188 enum sampLineRectPosition {
189 rectLeft = 0,
190 rectTop,
191 rectRight,
192 rectBottom
193 };
194
200 QQueue< ViewportBufferAction * > * p_actions;
201
202 bool p_bricksOrdered;
203 };
204}
205
206#endif
Buffer for containing a three dimensional section of an image.
Definition Brick.h:45
Encapsulation of Cube I/O with Change Notifications.
Definition CubeDataThread.h:59
Widget to display Isis cubes for qt apps.
Definition CubeViewport.h:122
Definition ViewportBufferAction.h:18
Definition ViewportBufferFill.h:29
Reads and stores visible DN values.
Definition ViewportBuffer.h:63
void addStretchAction()
When all current operations finish the cube viewport will be asked to do a stretch if you call this.
Definition ViewportBuffer.cpp:1217
void DoneWithData(int, const Isis::Brick *)
Tell cube data thread we're done with a brick.
const std::vector< double > & getLine(int line)
Retrieves a line from the buffer.
Definition ViewportBuffer.cpp:339
void DataReady(void *requester, int cubeId, const Isis::Brick *brick)
This method is called when requested bricks become available.
Definition ViewportBuffer.cpp:205
double totalUnfilledArea()
This returns the amount of area in the queue that needs new cube data/will be filled by fill actions.
Definition ViewportBuffer.cpp:646
void setBand(int band)
Sets the band to read from, the buffer will be re-read if the band changes.
Definition ViewportBuffer.cpp:1316
double currentProgress()
Returns the viewport buffer's loading progress.
Definition ViewportBuffer.cpp:630
void ReadCube(int cubeId, int startSample, int startLine, int endSample, int endLine, int band, void *caller)
Ask the cube data thread for data.
virtual ~ViewportBuffer()
Updates total buffer size on destruction.
Definition ViewportBuffer.cpp:78
ViewportBuffer(CubeViewport *viewport, CubeDataThread *cubeData, int cubeId)
ViewportBuffer constructor.
Definition ViewportBuffer.cpp:42
void enable(bool enabled)
This turns on or off reading from the cube.
Definition ViewportBuffer.cpp:1299
QRect bufferXYRect()
Returns a rect, in screen pixels, of the area this buffer covers.
Definition ViewportBuffer.cpp:1254
void resizedViewport()
Call this when the viewport is resized (not zoomed).
Definition ViewportBuffer.cpp:898
bool enabled()
Returns whether the buffer is enabled (reading data) or not.
Definition ViewportBuffer.h:105
bool hasEntireCube()
Method to see if the entire cube is in the buffer.
Definition ViewportBuffer.cpp:420
void fillBuffer(QRect rect)
This method will convert the rect to sample/line positions and read from the cube into the buffer.
Definition ViewportBuffer.cpp:112
void emptyBuffer(bool force=false)
This is meant to clear up ram on non-active viewports.
Definition ViewportBuffer.cpp:1238
bool working()
This tests if queued actions exist in the viewport buffer.
Definition ViewportBuffer.cpp:756
int getBand()
Return the band associated with this viewport buffer.
Definition ViewportBuffer.h:88
void pan(int deltaX, int deltaY)
Call this when the viewport is panned.
Definition ViewportBuffer.cpp:1045
void scaleChanged()
Call this when zoomed, re-reads visible area.
Definition ViewportBuffer.cpp:1278
Definition ViewportBufferStretch.h:22
Definition ViewportBufferTransform.h:21
This is free and unencumbered software released into the public domain.
Definition BoxcarCachingAlgorithm.h:14
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16