Isis 3 Programmer Reference
ViewportBuffer.h
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();
141
143
145
146 void resizeBuffer(unsigned int width, unsigned int height);
147 void shiftBuffer(int deltaX, int deltaY);
148 void reinitialize();
149 bool actionsPreserveData();
152
156
157 int p_band;
158
160 std::vector< std::vector<double> > p_buffer;
162
169
184
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.
Widget to display Isis cubes for qt apps.
Reads and stores visible DN values.
QList< double > p_sampLineBoundingRect
This rect is in cube pixels and represents the area that this viewport buffer defines in the viewport...
void enqueueAction(ViewportBufferAction *)
This enqueues the given action.
void addStretchAction()
When all current operations finish the cube viewport will be asked to do a stretch if you call this.
bool actionsPreserveData()
This returns true if any data currently in the buffer would be preserved if all of the queued actions...
void startFillAction(ViewportBufferFill *action)
Initializes a fill action by requesting the initial cube data.
void DoneWithData(int, const Isis::Brick *)
Tell cube data thread we're done with a brick.
int p_vertScrollBarPos
Current vertical scroll bar position.
CubeViewport * p_viewport
The CubeViewport which created this buffer.
const std::vector< double > & getLine(int line)
Retrieves a line from the buffer.
QRect p_oldXYBoundingRect
The previous bounding rect.
QRect getXYBoundingRect()
Retrieves the current bounding rect in viewport pixels of the visible cube area.
int p_band
The band to read from.
void reinitialize()
This resizes and fills entire buffer.
void DataReady(void *requester, int cubeId, const Isis::Brick *brick)
This method is called when requested bricks become available.
double totalUnfilledArea()
This returns the amount of area in the queue that needs new cube data/will be filled by fill actions.
void resizeBuffer(unsigned int width, unsigned int height)
Enlarges or shrinks the buffer and fills with nulls if necessary.
void setBand(int band)
Sets the band to read from, the buffer will be re-read if the band changes.
double currentProgress()
Returns the viewport buffer's loading progress.
void shiftBuffer(int deltaX, int deltaY)
Shifts the DN values in the buffer by deltaX and deltaY.
void ReadCube(int cubeId, int startSample, int startLine, int endSample, int endLine, int band, void *caller)
Ask the cube data thread for data.
void doQueuedActions()
This processes the next available action, or starts processing it, if possible.
void updateBoundingRects()
Sets the old and new bounding rects.
double p_requestedFillArea
Sum of the requested area to be filled.
virtual ~ViewportBuffer()
Updates total buffer size on destruction.
QQueue< ViewportBufferAction * > * p_actions
This is the set of actions we wish to perform on the buffer.
sampLineRectPosition
Enumeration for accessing sample/line bounding rectangles.
@ rectBottom
QRect.bottom()
@ rectRight
QRect.right()
ViewportBufferFill * createViewportBufferFill(QRect, bool)
This method creates a fill action based on a rect and using new versus old Y values.
int p_oldViewportHeight
Previous viewport height.
bool p_initialStretchDone
True if a stretch action has occurred.
ViewportBuffer(CubeViewport *viewport, CubeDataThread *cubeData, int cubeId)
ViewportBuffer constructor.
void enable(bool enabled)
This turns on or off reading from the cube.
void doStretchAction(ViewportBufferStretch *action)
Tells the cube viewport to restretch.
QList< double > p_oldSampLineBoundingRect
Previous bounding rect.
QList< double > getSampLineBoundingRect()
Retrieves the current bounding rect in sample/line coordinates of the visible cube area.
QRect bufferXYRect()
Returns a rect, in screen pixels, of the area this buffer covers.
bool p_bufferInitialized
True if the buffer has been initialized.
void resizedViewport()
Call this when the viewport is resized (not zoomed).
bool enabled()
Returns whether the buffer is enabled (reading data) or not.
CubeDataThread * p_dataThread
manages cube io
int p_cubeId
Id associated with the cube in this viewport buffer.
int p_oldVertScrollBarPos
Previous vertical scroll bar position.
bool hasEntireCube()
Method to see if the entire cube is in the buffer.
QRect p_XYBoundingRect
This rect is in viewport pixels and represents the area that this viewport buffer defines in the view...
void fillBuffer(QRect rect)
This method will convert the rect to sample/line positions and read from the cube into the buffer.
void emptyBuffer(bool force=false)
This is meant to clear up ram on non-active viewports.
void doTransformAction(ViewportBufferTransform *action)
Does a transformation on the internal viewport buffer.
bool working()
This tests if queued actions exist in the viewport buffer.
int getBand()
Return the band associated with this viewport buffer.
bool p_enabled
True if reading from cube (active)
void pan(int deltaX, int deltaY)
Call this when the viewport is panned.
std::vector< std::vector< double > > p_buffer
The buffer to hold cube dn values.
void scaleChanged()
Call this when zoomed, re-reads visible area.
void requestCubeLine(ViewportBufferFill *fill)
This requests the next line in a fill action.
int p_viewportHeight
Current viewport height.
bool reinitializeActionExists()
This searches for actions that will reset the entire buffer's contents.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16