Isis 3 Programmer Reference
|
Reads and stores visible DN values. More...
#include <ViewportBuffer.h>
Public Slots | |
void | DataReady (void *requester, int cubeId, const Isis::Brick *brick) |
This method is called when requested bricks become available. More... | |
Signals | |
void | ReadCube (int cubeId, int startSample, int startLine, int endSample, int endLine, int band, void *caller) |
Ask the cube data thread for data. More... | |
void | DoneWithData (int, const Isis::Brick *) |
Tell cube data thread we're done with a brick. More... | |
Public Member Functions | |
ViewportBuffer (CubeViewport *viewport, CubeDataThread *cubeData, int cubeId) | |
ViewportBuffer constructor. More... | |
virtual | ~ViewportBuffer () |
Updates total buffer size on destruction. More... | |
const std::vector< double > & | getLine (int line) |
Retrieves a line from the buffer. More... | |
void | resizedViewport () |
Call this when the viewport is resized (not zoomed). More... | |
void | pan (int deltaX, int deltaY) |
Call this when the viewport is panned. More... | |
void | scaleChanged () |
Call this when zoomed, re-reads visible area. More... | |
void | fillBuffer (QRect rect) |
This method will convert the rect to sample/line positions and read from the cube into the buffer. More... | |
void | fillBuffer (QRect rect, const Brick *data) |
This method will convert the rect to sample/line positions and read from the cube into the buffer. More... | |
void | emptyBuffer (bool force=false) |
This is meant to clear up ram on non-active viewports. More... | |
QRect | bufferXYRect () |
Returns a rect, in screen pixels, of the area this buffer covers. More... | |
void | setBand (int band) |
Sets the band to read from, the buffer will be re-read if the band changes. More... | |
int | getBand () |
Return the band associated with this viewport buffer. More... | |
void | enable (bool enabled) |
This turns on or off reading from the cube. More... | |
void | addStretchAction () |
When all current operations finish the cube viewport will be asked to do a stretch if you call this. More... | |
double | currentProgress () |
Returns the viewport buffer's loading progress. More... | |
double | totalUnfilledArea () |
This returns the amount of area in the queue that needs new cube data/will be filled by fill actions. More... | |
bool | enabled () |
Returns whether the buffer is enabled (reading data) or not. More... | |
bool | working () |
This tests if queued actions exist in the viewport buffer. More... | |
bool | hasEntireCube () |
Method to see if the entire cube is in the buffer. More... | |
Private Types | |
enum | sampLineRectPosition { rectLeft = 0, rectTop, rectRight, rectBottom } |
Enumeration for accessing sample/line bounding rectangles. More... | |
Private Member Functions | |
QRect | getXYBoundingRect () |
Retrieves the current bounding rect in viewport pixels of the visible cube area. More... | |
QList< double > | getSampLineBoundingRect () |
Retrieves the current bounding rect in sample/line coordinates of the visible cube area. More... | |
void | updateBoundingRects () |
Sets the old and new bounding rects. More... | |
void | doQueuedActions () |
This processes the next available action, or starts processing it, if possible. More... | |
void | doTransformAction (ViewportBufferTransform *action) |
Does a transformation on the internal viewport buffer. More... | |
void | doStretchAction (ViewportBufferStretch *action) |
Tells the cube viewport to restretch. More... | |
void | startFillAction (ViewportBufferFill *action) |
Initializes a fill action by requesting the initial cube data. More... | |
ViewportBufferFill * | createViewportBufferFill (QRect, bool) |
This method creates a fill action based on a rect and using new versus old Y values. More... | |
void | requestCubeLine (ViewportBufferFill *fill) |
This requests the next line in a fill action. More... | |
void | resizeBuffer (unsigned int width, unsigned int height) |
Enlarges or shrinks the buffer and fills with nulls if necessary. More... | |
void | shiftBuffer (int deltaX, int deltaY) |
Shifts the DN values in the buffer by deltaX and deltaY. More... | |
void | reinitialize () |
This resizes and fills entire buffer. More... | |
bool | actionsPreserveData () |
This returns true if any data currently in the buffer would be preserved if all of the queued actions are executed. More... | |
bool | reinitializeActionExists () |
This searches for actions that will reset the entire buffer's contents. More... | |
void | enqueueAction (ViewportBufferAction *) |
This enqueues the given action. More... | |
Private Attributes | |
CubeViewport * | p_viewport |
The CubeViewport which created this buffer. More... | |
int | p_cubeId |
Id associated with the cube in this viewport buffer. More... | |
CubeDataThread * | p_dataThread |
manages cube io More... | |
int | p_band |
The band to read from. More... | |
bool | p_enabled |
True if reading from cube (active) More... | |
std::vector< std::vector< double > > | p_buffer |
The buffer to hold cube dn values. More... | |
bool | p_bufferInitialized |
True if the buffer has been initialized. More... | |
QRect | p_XYBoundingRect |
This rect is in viewport pixels and represents the area that this viewport buffer defines in the viewport. More... | |
QRect | p_oldXYBoundingRect |
The previous bounding rect. More... | |
QList< double > | p_sampLineBoundingRect |
This rect is in cube pixels and represents the area that this viewport buffer defines in the viewport. More... | |
QList< double > | p_oldSampLineBoundingRect |
Previous bounding rect. More... | |
int | p_viewportHeight |
Current viewport height. More... | |
int | p_oldViewportHeight |
Previous viewport height. More... | |
int | p_vertScrollBarPos |
Current vertical scroll bar position. More... | |
int | p_oldVertScrollBarPos |
Previous vertical scroll bar position. More... | |
bool | p_initialStretchDone |
True if a stretch action has occurred. More... | |
double | p_requestedFillArea |
Sum of the requested area to be filled. More... | |
QQueue< ViewportBufferAction *> * | p_actions |
This is the set of actions we wish to perform on the buffer. More... | |
bool | p_bricksOrdered |
Reads and stores visible DN values.
This class manages visible pixels in a CubeViewport. This class is responsible for reading from the Cube only what is necessary and gives fast access to visible DNs.
2009-04-21 Steven Lambright - Fixed problem with only half of the side pixels being loaded in
2010-04-08 Steven Lambright and Eric Hyer - Added support for using CubeDataThread for reads.
2010-05-11 Eric Hyer - Fixed issue with invalid bounding rects in resizedViewport()
2010-05-24 Eric Hyer - Fixed bug in previous bug fix (checks were in wrong order)
2010-07-12 Jeannie Walldren - Added exceptiona to help track errors.
2011-03-30 Sharmila Prasad - Edited to remove black line on the left and on top
2011-04-25 Steven Lambright - Fixed bounding rect calculations and fill action creation
2011-06-20 Steven Lambright - Fixed panning issue where panning beyond a full screen was a problem.
Definition at line 78 of file ViewportBuffer.h.
|
private |
Enumeration for accessing sample/line bounding rectangles.
Enumerator | |
---|---|
rectLeft | QRect.left() |
rectTop | QRect.top() |
rectRight | QRect.right() |
rectBottom | QRect.bottom() |
Definition at line 203 of file ViewportBuffer.h.
Isis::ViewportBuffer::ViewportBuffer | ( | CubeViewport * | viewport, |
CubeDataThread * | cubeData, | ||
int | cubeId | ||
) |
ViewportBuffer constructor.
Viewport and Cube can not be null. Band is not initialized
viewport | viewport that will use the buffer |
cubeData | cube to read from |
cubeId | The identifier for the cube in the data thread |
Definition at line 36 of file ViewportBuffer.cpp.
|
virtual |
Updates total buffer size on destruction.
Definition at line 72 of file ViewportBuffer.cpp.
|
private |
This returns true if any data currently in the buffer would be preserved if all of the queued actions are executed.
Definition at line 666 of file ViewportBuffer.cpp.
References Isis::ViewportBufferAction::getActionType(), Isis::ViewportBufferTransform::getBufferHeight(), Isis::ViewportBufferTransform::getBufferWidth(), Isis::ViewportBufferTransform::getXTranslation(), Isis::ViewportBufferTransform::getYTranslation(), and Isis::ViewportBufferTransform::resizeFirst().
void Isis::ViewportBuffer::addStretchAction | ( | ) |
When all current operations finish the cube viewport will be asked to do a stretch if you call this.
Existing requests will be removed.
Definition at line 1212 of file ViewportBuffer.cpp.
Referenced by Isis::CubeViewport::showEvent(), Isis::CubeViewport::viewGray(), and Isis::CubeViewport::viewRGB().
QRect Isis::ViewportBuffer::bufferXYRect | ( | ) |
Returns a rect, in screen pixels, of the area this buffer covers.
Definition at line 1249 of file ViewportBuffer.cpp.
Referenced by Isis::StretchTool::histFromBuffer(), Isis::ScatterPlotWindow::paint(), Isis::CubeViewport::paintPixmap(), Isis::CubeViewport::scrollContentsBy(), Isis::StretchTool::statsFromBuffer(), and Isis::TrackTool::updateLabels().
|
private |
This method creates a fill action based on a rect and using new versus old Y values.
The use of old Y values is so we can think of X and Y independently in complicated transforms - do X first (with old Y values), then do Y. This does not enqueue the created action.
someRect | |
useOldY |
Definition at line 488 of file ViewportBuffer.cpp.
References _FILEINFO_.
double Isis::ViewportBuffer::currentProgress | ( | ) |
Returns the viewport buffer's loading progress.
Definition at line 625 of file ViewportBuffer.cpp.
Referenced by Isis::CubeViewport::onProgressTimer().
|
slot |
This method is called when requested bricks become available.
This processes the new cube data and requests more if necessary.
requester | |
cubeId | |
brick |
Definition at line 200 of file ViewportBuffer.cpp.
References _FILEINFO_, Isis::Buffer::at(), Isis::ViewportBufferFill::doneReading(), Isis::ViewportBufferAction::getActionType(), Isis::ViewportBufferFill::getLeftmostPixelPosition(), Isis::ViewportBufferFill::getReadPosition(), Isis::ViewportBufferFill::getRect(), Isis::ViewportBufferFill::getTopmostPixelPosition(), Isis::ViewportBufferFill::incReadPosition(), Isis::Buffer::Line(), Isis::Buffer::Sample(), Isis::ViewportBufferFill::shouldRequestMore(), Isis::Buffer::size(), Isis::ViewportBufferAction::started(), Isis::ViewportBufferFill::viewportToLine(), and Isis::ViewportBufferFill::viewportToSample().
|
signal |
Tell cube data thread we're done with a brick.
|
private |
This processes the next available action, or starts processing it, if possible.
This method keeps the buffer alive until the actions queue is empty.
Any time the actions queue is modified this method should be called, it doesn't hurt to call this too much. A side effect of not calling this is qview never completing a read/displaying new pixels.
Definition at line 571 of file ViewportBuffer.cpp.
References Isis::ViewportBufferAction::getActionType(), and Isis::ViewportBufferAction::started().
|
private |
Tells the cube viewport to restretch.
action |
Definition at line 806 of file ViewportBuffer.cpp.
|
private |
Does a transformation on the internal viewport buffer.
action |
Definition at line 761 of file ViewportBuffer.cpp.
References Isis::ViewportBufferTransform::getBufferHeight(), Isis::ViewportBufferTransform::getBufferWidth(), Isis::ViewportBufferTransform::getXTranslation(), Isis::ViewportBufferTransform::getYTranslation(), and Isis::ViewportBufferTransform::resizeFirst().
void Isis::ViewportBuffer::emptyBuffer | ( | bool | force = false | ) |
This is meant to clear up ram on non-active viewports.
cubeViewport is supposed to call this method on viewports buffers that are not related to the active viewport.
force | If true, memory will be freed regardless of current total buffer size (b/w -> rgb for example). |
Definition at line 1233 of file ViewportBuffer.cpp.
void Isis::ViewportBuffer::enable | ( | bool | enabled | ) |
This turns on or off reading from the cube.
If enabled is true the buffer will be re-read.
enabled |
Definition at line 1294 of file ViewportBuffer.cpp.
Referenced by Isis::CubeViewport::CubeViewport(), Isis::CubeViewport::setScale(), and Isis::CubeViewport::showEvent().
|
inline |
Returns whether the buffer is enabled (reading data) or not.
Definition at line 120 of file ViewportBuffer.h.
References p_enabled.
Referenced by Isis::CubeViewport::paintPixmap(), Isis::CubeViewport::setScale(), and Isis::CubeViewport::showEvent().
|
private |
This enqueues the given action.
Please use this and don't put actions directly into p_actions. Calling this method can be thought of as equivalent to calling "p_actions->push_back(action)"
action |
Definition at line 312 of file ViewportBuffer.cpp.
References Isis::ViewportBufferAction::getActionType().
void Isis::ViewportBuffer::fillBuffer | ( | QRect | rect | ) |
This method will convert the rect to sample/line positions and read from the cube into the buffer.
The rect is in viewport pixels.
rect |
Definition at line 106 of file ViewportBuffer.cpp.
References _FILEINFO_.
Referenced by Isis::CubeViewport::cubeContentsChanged(), and Isis::CubeViewport::cubeDataChanged().
void Isis::ViewportBuffer::fillBuffer | ( | QRect | rect, |
const Brick * | data | ||
) |
This method will convert the rect to sample/line positions and read from the cube into the buffer.
The rect is in viewport pixels.
rect | |
data |
Definition at line 125 of file ViewportBuffer.cpp.
References _FILEINFO_, Isis::Buffer::at(), Isis::ViewportBufferFill::getLeftmostPixelPosition(), Isis::ViewportBufferFill::getRequestPosition(), Isis::ViewportBufferFill::getTopmostPixelPosition(), Isis::ViewportBufferFill::incReadPosition(), Isis::ViewportBufferFill::incRequestPosition(), Isis::Buffer::Index(), Isis::Buffer::Line(), Isis::Buffer::LineDimension(), Isis::Buffer::Sample(), Isis::Buffer::SampleDimension(), Isis::ViewportBufferFill::shouldRequestMore(), Isis::Buffer::size(), Isis::ViewportBufferFill::viewportToLine(), and Isis::ViewportBufferFill::viewportToSample().
|
inline |
Return the band associated with this viewport buffer.
Definition at line 103 of file ViewportBuffer.h.
References p_band.
Referenced by Isis::CubeViewport::getAllWhatsThisInfo(), Isis::CubeViewport::updateWhatsThis(), Isis::CubeViewport::viewGray(), and Isis::CubeViewport::viewRGB().
const vector< double > & Isis::ViewportBuffer::getLine | ( | int | line | ) |
Retrieves a line from the buffer.
Line is relative to the top of the visible area of the cube in the viewport.
line |
Definition at line 334 of file ViewportBuffer.cpp.
References _FILEINFO_.
Referenced by Isis::StretchTool::histFromBuffer(), Isis::ScatterPlotWindow::paint(), Isis::CubeViewport::paintPixmap(), Isis::StretchTool::statsFromBuffer(), and Isis::TrackTool::updateLabels().
|
private |
Retrieves the current bounding rect in sample/line coordinates of the visible cube area.
Definition at line 439 of file ViewportBuffer.cpp.
|
private |
Retrieves the current bounding rect in viewport pixels of the visible cube area.
Definition at line 356 of file ViewportBuffer.cpp.
bool Isis::ViewportBuffer::hasEntireCube | ( | ) |
Method to see if the entire cube is in the buffer.
Definition at line 415 of file ViewportBuffer.cpp.
Referenced by Isis::StretchTool::stretchRequested().
void Isis::ViewportBuffer::pan | ( | int | deltaX, |
int | deltaY | ||
) |
Call this when the viewport is panned.
DeltaX and deltaY are relative to the direction the buffer needs to shift.
deltaX | |
deltaY |
Definition at line 1040 of file ViewportBuffer.cpp.
References Isis::ViewportBufferTransform::resizeFirst(), Isis::ViewportBufferTransform::setResize(), and Isis::ViewportBufferTransform::setTranslation().
Referenced by Isis::CubeViewport::center(), and Isis::CubeViewport::scrollContentsBy().
|
signal |
Ask the cube data thread for data.
cubeId | |
startSample | |
startLine | |
endSample | |
endLine | |
band | |
caller |
|
private |
This resizes and fills entire buffer.
iException | - "Unable to resize and fill buffer." |
Definition at line 1332 of file ViewportBuffer.cpp.
References _FILEINFO_, Isis::ViewportBufferAction::getActionType(), Isis::ViewportBufferFill::getRect(), Isis::ViewportBufferTransform::setResize(), Isis::ViewportBufferAction::started(), and Isis::ViewportBufferFill::stop().
|
private |
This searches for actions that will reset the entire buffer's contents.
Definition at line 722 of file ViewportBuffer.cpp.
References Isis::ViewportBufferAction::getActionType(), Isis::ViewportBufferTransform::getBufferHeight(), and Isis::ViewportBufferTransform::getBufferWidth().
|
private |
This requests the next line in a fill action.
fill |
Definition at line 533 of file ViewportBuffer.cpp.
References _FILEINFO_, Isis::ViewportBufferFill::getRect(), Isis::ViewportBufferFill::getRequestPosition(), Isis::ViewportBufferFill::incRequestPosition(), Isis::ViewportBufferFill::viewportToLine(), and Isis::ViewportBufferFill::viewportToSample().
|
private |
Enlarges or shrinks the buffer and fills with nulls if necessary.
width | |
height |
Definition at line 821 of file ViewportBuffer.cpp.
References Isis::Null.
void Isis::ViewportBuffer::resizedViewport | ( | ) |
Call this when the viewport is resized (not zoomed).
Definition at line 893 of file ViewportBuffer.cpp.
References Isis::ViewportBufferTransform::resizeFirst(), Isis::ViewportBufferTransform::setResize(), and Isis::ViewportBufferTransform::setTranslation().
Referenced by Isis::CubeViewport::resizeEvent().
void Isis::ViewportBuffer::scaleChanged | ( | ) |
Call this when zoomed, re-reads visible area.
iException | - "Unable to change scale" |
Definition at line 1273 of file ViewportBuffer.cpp.
References _FILEINFO_.
Referenced by Isis::CubeViewport::setScale().
void Isis::ViewportBuffer::setBand | ( | int | band | ) |
Sets the band to read from, the buffer will be re-read if the band changes.
band |
Definition at line 1311 of file ViewportBuffer.cpp.
Referenced by Isis::CubeViewport::CubeViewport(), Isis::CubeViewport::viewGray(), and Isis::CubeViewport::viewRGB().
|
private |
Shifts the DN values in the buffer by deltaX and deltaY.
Does not fill from outside the buffer.
deltaX | |
deltaY |
Definition at line 837 of file ViewportBuffer.cpp.
References Isis::Null.
|
private |
Initializes a fill action by requesting the initial cube data.
action |
Definition at line 787 of file ViewportBuffer.cpp.
References Isis::ViewportBufferFill::shouldRequestMore(), and Isis::ViewportBufferAction::started().
double Isis::ViewportBuffer::totalUnfilledArea | ( | ) |
This returns the amount of area in the queue that needs new cube data/will be filled by fill actions.
Definition at line 641 of file ViewportBuffer.cpp.
References Isis::ViewportBufferAction::getActionType(), Isis::ViewportBufferFill::getReadPosition(), and Isis::ViewportBufferFill::getRect().
|
private |
Sets the old and new bounding rects.
Definition at line 460 of file ViewportBuffer.cpp.
bool Isis::ViewportBuffer::working | ( | ) |
This tests if queued actions exist in the viewport buffer.
Definition at line 751 of file ViewportBuffer.cpp.
Referenced by Isis::CubeViewport::bufferUpdated(), Isis::CubeViewport::onProgressTimer(), Isis::ScatterPlotWindow::paint(), Isis::CubeViewport::paintPixmap(), Isis::CubeViewport::scrollContentsBy(), Isis::StretchTool::setCubeViewport(), Isis::StretchTool::statsFromBuffer(), Isis::StretchTool::updateAdvStretchDialogforAll(), Isis::StretchTool::updateHistograms(), and Isis::TrackTool::updateLabels().
|
private |
This is the set of actions we wish to perform on the buffer.
This is queued because we need to wait for other threads to give us cube data before we progress through the queue.
Definition at line 215 of file ViewportBuffer.h.
|
private |
|
private |
The buffer to hold cube dn values.
Definition at line 175 of file ViewportBuffer.h.
|
private |
True if the buffer has been initialized.
Definition at line 176 of file ViewportBuffer.h.
|
private |
Id associated with the cube in this viewport buffer.
Definition at line 169 of file ViewportBuffer.h.
|
private |
manages cube io
Definition at line 170 of file ViewportBuffer.h.
|
private |
True if reading from cube (active)
Definition at line 174 of file ViewportBuffer.h.
Referenced by enabled().
|
private |
True if a stretch action has occurred.
Definition at line 197 of file ViewportBuffer.h.
|
private |
Previous bounding rect.
Definition at line 192 of file ViewportBuffer.h.
|
private |
Previous vertical scroll bar position.
Definition at line 196 of file ViewportBuffer.h.
|
private |
Previous viewport height.
Definition at line 194 of file ViewportBuffer.h.
|
private |
The previous bounding rect.
Definition at line 183 of file ViewportBuffer.h.
|
private |
Sum of the requested area to be filled.
Definition at line 198 of file ViewportBuffer.h.
|
private |
This rect is in cube pixels and represents the area that this viewport buffer defines in the viewport.
To get a particular corner use the sampLineRectPosition enumeration as indices for a particular corner.
Definition at line 191 of file ViewportBuffer.h.
|
private |
Current vertical scroll bar position.
Definition at line 195 of file ViewportBuffer.h.
|
private |
The CubeViewport which created this buffer.
Definition at line 168 of file ViewportBuffer.h.
|
private |
Current viewport height.
Definition at line 193 of file ViewportBuffer.h.
|
private |
This rect is in viewport pixels and represents the area that this viewport buffer defines in the viewport.
Definition at line 182 of file ViewportBuffer.h.