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 
22 template<class T > class QQueue;
23 class QRect;
24 
25 namespace 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 
201 
202  bool p_bricksOrdered;
203  };
204 }
205 
206 #endif
Isis::ViewportBuffer
Reads and stores visible DN values.
Definition: ViewportBuffer.h:63
Cube.h
Isis::Buffer::SampleDimension
int SampleDimension() const
Returns the number of samples in the shape buffer.
Definition: Buffer.h:70
Isis::ViewportBuffer::getLine
const std::vector< double > & getLine(int line)
Retrieves a line from the buffer.
Definition: ViewportBuffer.cpp:342
Isis::ViewportBuffer::resizedViewport
void resizedViewport()
Call this when the viewport is resized (not zoomed).
Definition: ViewportBuffer.cpp:901
Isis::ViewportBufferFill::doneReading
bool doneReading()
Returns true if read position is past the end of the fill.
Definition: ViewportBufferFill.cpp:87
QList< double >
Isis::ViewportBuffer::totalUnfilledArea
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:649
SpecialPixel.h
Isis::ViewportBufferAction::stop
virtual void stop()
Cancels the process, used if reinitialize requested for example.
Definition: ViewportBufferAction.h:53
Isis::ViewportBufferTransform::resizeFirst
bool resizeFirst()
Returns true if the resize should happen before the translation.
Definition: ViewportBufferTransform.h:77
Isis::Buffer::Index
int Index(const int i_samp, const int i_line, const int i_band) const
Given a sample, line, and band position, this returns the appropriate index in the shape buffer.
Definition: Buffer.cpp:197
Isis::ViewportBufferFill
Definition: ViewportBufferFill.h:29
CubeDataThread.h
Isis::ViewportBufferTransform::getYTranslation
int getYTranslation()
Gets the amount the buffer should be translated in Y.
Definition: ViewportBufferTransform.h:47
Isis::ViewportBuffer::setBand
void setBand(int band)
Sets the band to read from, the buffer will be re-read if the band changes.
Definition: ViewportBuffer.cpp:1319
Isis::ViewportBuffer::emptyBuffer
void emptyBuffer(bool force=false)
This is meant to clear up ram on non-active viewports.
Definition: ViewportBuffer.cpp:1241
Isis::ViewportBuffer::getBand
int getBand()
Return the band associated with this viewport buffer.
Definition: ViewportBuffer.h:88
Isis::ViewportBufferStretch
Definition: ViewportBufferStretch.h:22
Isis::Brick
Buffer for containing a three dimensional section of an image.
Definition: Brick.h:45
ViewportBufferFill.h
Isis::CubeDataThread
Encapsulation of Cube I/O with Change Notifications.
Definition: CubeDataThread.h:59
CubeViewport.h
ViewportBufferStretch.h
Isis::ViewportBufferTransform
Definition: ViewportBufferTransform.h:21
Isis::ViewportBufferFill::viewportToSample
double viewportToSample(int x)
Converts screen x position to cube sample position.
Definition: ViewportBufferFill.h:53
Isis::ViewportBuffer::ReadCube
void ReadCube(int cubeId, int startSample, int startLine, int endSample, int endLine, int band, void *caller)
Ask the cube data thread for data.
Isis::ViewportBuffer::enabled
bool enabled()
Returns whether the buffer is enabled (reading data) or not.
Definition: ViewportBuffer.h:105
Isis::ViewportBufferFill::viewportToLine
double viewportToLine(int y)
Converts screen y position to cube line position.
Definition: ViewportBufferFill.h:64
ViewportBufferTransform.h
Isis::ViewportBuffer::currentProgress
double currentProgress()
Returns the viewport buffer's loading progress.
Definition: ViewportBuffer.cpp:633
PixelType.h
Isis::ViewportBufferTransform::getBufferWidth
const int & getBufferWidth()
Returns the new buffer width.
Definition: ViewportBufferTransform.h:58
Isis::ViewportBufferFill::getReadPosition
int getReadPosition() const
Returns the current read position.
Definition: ViewportBufferFill.h:82
Isis::ViewportBufferFill::getTopmostPixelPosition
int getTopmostPixelPosition()
Returns the top of the X/Y bounding rect for this fill.
Definition: ViewportBufferFill.cpp:67
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::ViewportBufferAction
Definition: ViewportBufferAction.h:18
Isis::ViewportBufferFill::shouldRequestMore
bool shouldRequestMore()
Returns true if request position is past the end of the fill.
Definition: ViewportBufferFill.cpp:97
Isis::ViewportBufferFill::getRect
QRect * getRect()
Returns the rect that this action is filling in screen pixels.
Definition: ViewportBufferFill.h:101
Isis::Buffer::LineDimension
int LineDimension() const
Returns the number of lines in the shape buffer.
Definition: Buffer.h:79
Isis::Buffer::at
double at(const int index) const
Returns the value in the shape buffer at the given index.
Definition: Buffer.cpp:231
Isis::ViewportBufferTransform::setTranslation
void setTranslation(int x, int y)
Sets the translation amount in x and y.
Definition: ViewportBufferTransform.cpp:32
Isis::ViewportBufferFill::getLeftmostPixelPosition
int getLeftmostPixelPosition()
Returns the left of the X/Y bounding rect for this fill.
Definition: ViewportBufferFill.cpp:77
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::CubeViewport
Widget to display Isis cubes for qt apps.
Definition: CubeViewport.h:122
Isis::ViewportBuffer::bufferXYRect
QRect bufferXYRect()
Returns a rect, in screen pixels, of the area this buffer covers.
Definition: ViewportBuffer.cpp:1257
round
#define round(x)
This is free and unencumbered software released into the public domain.
Definition: ViewportBuffer.cpp:29
Isis::Null
const double Null
Value for an Isis Null pixel.
Definition: SpecialPixel.h:95
Isis::ViewportBufferFill::incRequestPosition
void incRequestPosition()
Increment request position.
Definition: ViewportBufferFill.h:92
Isis::ViewportBufferFill::getRequestPosition
int getRequestPosition() const
Returns the current request position (>= read position)
Definition: ViewportBufferFill.h:73
Brick.h
Isis::ViewportBufferAction::started
bool started()
Returns true if this is an action that takes time and has begun.
Definition: ViewportBufferAction.h:39
std
Namespace for the standard library.
Isis::ViewportBuffer::~ViewportBuffer
virtual ~ViewportBuffer()
Updates total buffer size on destruction.
Definition: ViewportBuffer.cpp:80
QQueue
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:14
Isis::ViewportBuffer::addStretchAction
void addStretchAction()
When all current operations finish the cube viewport will be asked to do a stretch if you call this.
Definition: ViewportBuffer.cpp:1220
Isis::ViewportBuffer::scaleChanged
void scaleChanged()
Call this when zoomed, re-reads visible area.
Definition: ViewportBuffer.cpp:1281
Isis::ViewportBufferTransform::setResize
void setResize(int width, int height)
Sets the size the buffer should be resized to.
Definition: ViewportBufferTransform.cpp:44
Isis::ViewportBufferAction::getActionType
virtual ActionType getActionType()
Returns the instantiated type.
Definition: ViewportBufferAction.h:34
ViewportBuffer.h
Isis::ViewportBuffer::enable
void enable(bool enabled)
This turns on or off reading from the cube.
Definition: ViewportBuffer.cpp:1302
Isis::ViewportBuffer::pan
void pan(int deltaX, int deltaY)
Call this when the viewport is panned.
Definition: ViewportBuffer.cpp:1048
Isis::Buffer::size
int size() const
Returns the total number of pixels in the shape buffer.
Definition: Buffer.h:97
Isis::ViewportBuffer::hasEntireCube
bool hasEntireCube()
Method to see if the entire cube is in the buffer.
Definition: ViewportBuffer.cpp:423
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
QObject
Isis::ViewportBufferFill::incReadPosition
void incReadPosition()
Increment read position.
Definition: ViewportBufferFill.h:87
ViewportBufferAction.h
Isis::Buffer::Sample
int Sample(const int index=0) const
Returns the sample position associated with a shape buffer index.
Definition: Buffer.cpp:127
Isis::ViewportBufferTransform::getBufferHeight
const int & getBufferHeight()
Returns the new buffer height.
Definition: ViewportBufferTransform.h:67
IsisDebug.h
Isis::ViewportBuffer::fillBuffer
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:114
Isis::Buffer::Line
int Line(const int index=0) const
Returns the line position associated with a shape buffer index.
Definition: Buffer.cpp:145
Isis::ViewportBufferTransform::getXTranslation
int getXTranslation()
Gets the amount the buffer should be translated in X.
Definition: ViewportBufferTransform.h:37
Isis::ViewportBuffer::DataReady
void DataReady(void *requester, int cubeId, const Isis::Brick *brick)
This method is called when requested bricks become available.
Definition: ViewportBuffer.cpp:208
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::ViewportBuffer::DoneWithData
void DoneWithData(int, const Isis::Brick *)
Tell cube data thread we're done with a brick.
Isis::ViewportBuffer::working
bool working()
This tests if queued actions exist in the viewport buffer.
Definition: ViewportBuffer.cpp:759
Isis::ViewportBuffer::ViewportBuffer
ViewportBuffer(CubeViewport *viewport, CubeDataThread *cubeData, int cubeId)
ViewportBuffer constructor.
Definition: ViewportBuffer.cpp:44