Isis 3 Programmer Reference
ViewportBuffer.h
Go to the documentation of this file.
1 #ifndef ViewportBuffer_h
2 #define ViewportBuffer_h
3 
27 #include <vector>
28 
29 #include <QRect>
30 
31 #include "Cube.h"
32 #include "Brick.h"
33 
34 // parent
35 #include <QObject>
36 
37 template<class T > class QQueue;
38 class QRect;
39 
40 namespace Isis {
41  class CubeDataThread;
42  class Brick;
43  class CubeViewport;
44  class ViewportBufferAction;
45  class ViewportBufferFill;
46  class ViewportBufferStretch;
47  class ViewportBufferTransform;
48 
78  class ViewportBuffer : public QObject {
79  Q_OBJECT
80 
81  public:
82  ViewportBuffer(CubeViewport *viewport, CubeDataThread *cubeData,
83  int cubeId);
84  virtual ~ViewportBuffer();
85 
86  const std::vector<double> &getLine(int line);
87 
88  void resizedViewport();
89  void pan(int deltaX, int deltaY);
90 
91  void scaleChanged();
92 
93  void fillBuffer(QRect rect);
94  void fillBuffer(QRect rect, const Brick *data);
95 
96  void emptyBuffer(bool force = false);
97 
98  QRect bufferXYRect();
99 
100  void setBand(int band);
101 
103  int getBand() {
104  return p_band;
105  }
106 
107  void enable(bool enabled);
108 
109  void addStretchAction();
110 
111  double currentProgress();
112  double totalUnfilledArea();
113 
120  bool enabled() {
121  return p_enabled;
122  }
123  bool working();
124 
125  bool hasEntireCube();
126 
127  public slots:
128  void DataReady(void *requester, int cubeId, const Isis::Brick *brick);
129 
130  signals:
142  void ReadCube(int cubeId, int startSample, int startLine,
143  int endSample, int endLine, int band, void *caller);
144 
146  void DoneWithData(int, const Isis::Brick *);
147 
148  private:
149  QRect getXYBoundingRect();
151  void updateBoundingRects();
152  void doQueuedActions();
155  void startFillAction(ViewportBufferFill *action);
156 
158 
160 
161  void resizeBuffer(unsigned int width, unsigned int height);
162  void shiftBuffer(int deltaX, int deltaY);
163  void reinitialize();
164  bool actionsPreserveData();
167 
169  int p_cubeId;
171 
172  int p_band;
173 
174  bool p_enabled;
175  std::vector< std::vector<double> > p_buffer;
177 
184 
199 
204  rectLeft = 0,
208  };
209 
216 
217  bool p_bricksOrdered;
218  };
219 }
220 
221 #endif
Reads and stores visible DN values.
bool actionsPreserveData()
This returns true if any data currently in the buffer would be preserved if all of the queued actions...
bool p_bufferInitialized
True if the buffer has been initialized.
void updateBoundingRects()
Sets the old and new bounding rects.
double p_requestedFillArea
Sum of the requested area to be filled.
std::vector< std::vector< double > > p_buffer
The buffer to hold cube dn values.
const std::vector< double > & getLine(int line)
Retrieves a line from the buffer.
void ReadCube(int cubeId, int startSample, int startLine, int endSample, int endLine, int band, void *caller)
Ask the cube data thread for data.
void DoneWithData(int, const Isis::Brick *)
Tell cube data thread we&#39;re done with a brick.
Buffer for containing a three dimensional section of an image.
Definition: Brick.h:61
int p_oldVertScrollBarPos
Previous vertical scroll bar position.
double currentProgress()
Returns the viewport buffer&#39;s loading progress.
void emptyBuffer(bool force=false)
This is meant to clear up ram on non-active viewports.
int p_band
The band to read from.
QQueue< ViewportBufferAction *> * p_actions
This is the set of actions we wish to perform on the buffer.
void startFillAction(ViewportBufferFill *action)
Initializes a fill action by requesting the initial cube data.
bool p_enabled
True if reading from cube (active)
int getBand()
Return the band associated with this viewport buffer.
void resizeBuffer(unsigned int width, unsigned int height)
Enlarges or shrinks the buffer and fills with nulls if necessary.
Widget to display Isis cubes for qt apps.
Definition: CubeViewport.h:132
QList< double > p_oldSampLineBoundingRect
Previous bounding rect.
double totalUnfilledArea()
This returns the amount of area in the queue that needs new cube data/will be filled by fill actions...
QRect bufferXYRect()
Returns a rect, in screen pixels, of the area this buffer covers.
void resizedViewport()
Call this when the viewport is resized (not zoomed).
void doStretchAction(ViewportBufferStretch *action)
Tells the cube viewport to restretch.
bool enabled()
Returns whether the buffer is enabled (reading data) or not.
ViewportBuffer(CubeViewport *viewport, CubeDataThread *cubeData, int cubeId)
ViewportBuffer constructor.
void enable(bool enabled)
This turns on or off reading from the cube.
QRect p_oldXYBoundingRect
The previous bounding rect.
QList< double > getSampLineBoundingRect()
Retrieves the current bounding rect in sample/line coordinates of the visible cube area...
CubeViewport * p_viewport
The CubeViewport which created this buffer.
int p_oldViewportHeight
Previous viewport height.
void shiftBuffer(int deltaX, int deltaY)
Shifts the DN values in the buffer by deltaX and deltaY.
QRect getXYBoundingRect()
Retrieves the current bounding rect in viewport pixels of the visible cube area.
bool p_initialStretchDone
True if a stretch action has occurred.
void scaleChanged()
Call this when zoomed, re-reads visible area.
int p_cubeId
Id associated with the cube in this viewport buffer.
QList< double > p_sampLineBoundingRect
This rect is in cube pixels and represents the area that this viewport buffer defines in the viewport...
Encapsulation of Cube I/O with Change Notifications.
CubeDataThread * p_dataThread
manages cube io
bool working()
This tests if queued actions exist in the viewport buffer.
void doQueuedActions()
This processes the next available action, or starts processing it, if possible.
void fillBuffer(QRect rect)
This method will convert the rect to sample/line positions and read from the cube into the buffer...
void reinitialize()
This resizes and fills entire buffer.
void enqueueAction(ViewportBufferAction *)
This enqueues the given action.
QRect p_XYBoundingRect
This rect is in viewport pixels and represents the area that this viewport buffer defines in the view...
void DataReady(void *requester, int cubeId, const Isis::Brick *brick)
This method is called when requested bricks become available.
void setBand(int band)
Sets the band to read from, the buffer will be re-read if the band changes.
bool reinitializeActionExists()
This searches for actions that will reset the entire buffer&#39;s contents.
virtual ~ViewportBuffer()
Updates total buffer size on destruction.
int p_viewportHeight
Current viewport height.
void doTransformAction(ViewportBufferTransform *action)
Does a transformation on the internal viewport buffer.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
sampLineRectPosition
Enumeration for accessing sample/line bounding rectangles.
int p_vertScrollBarPos
Current vertical scroll bar position.
bool hasEntireCube()
Method to see if the entire cube is in the buffer.
void pan(int deltaX, int deltaY)
Call this when the viewport is panned.
void addStretchAction()
When all current operations finish the cube viewport will be asked to do a stretch if you call this...
ViewportBufferFill * createViewportBufferFill(QRect, bool)
This method creates a fill action based on a rect and using new versus old Y values.
void requestCubeLine(ViewportBufferFill *fill)
This requests the next line in a fill action.