Isis 3 Programmer Reference
Isis::ViewportBuffer Class Reference

Reads and stores visible DN values. More...

#include <ViewportBuffer.h>

Inheritance diagram for Isis::ViewportBuffer:
Inheritance graph
Collaboration diagram for Isis::ViewportBuffer:
Collaboration graph

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...
 
ViewportBufferFillcreateViewportBufferFill (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

CubeViewportp_viewport
 The CubeViewport which created this buffer. More...
 
int p_cubeId
 Id associated with the cube in this viewport buffer. More...
 
CubeDataThreadp_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
 

Detailed Description

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.

Author
2009-03-26 Steven Lambright and Noah Hilt
History:

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.

Member Enumeration Documentation

◆ sampLineRectPosition

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.

Constructor & Destructor Documentation

◆ ViewportBuffer()

Isis::ViewportBuffer::ViewportBuffer ( CubeViewport viewport,
CubeDataThread cubeData,
int  cubeId 
)

ViewportBuffer constructor.

Viewport and Cube can not be null. Band is not initialized

Parameters
viewportviewport that will use the buffer
cubeDatacube to read from
cubeIdThe identifier for the cube in the data thread

Definition at line 36 of file ViewportBuffer.cpp.

◆ ~ViewportBuffer()

Isis::ViewportBuffer::~ViewportBuffer ( )
virtual

Updates total buffer size on destruction.

Definition at line 72 of file ViewportBuffer.cpp.

Member Function Documentation

◆ actionsPreserveData()

bool Isis::ViewportBuffer::actionsPreserveData ( )
private

◆ addStretchAction()

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().

◆ bufferXYRect()

QRect Isis::ViewportBuffer::bufferXYRect ( )

Returns a rect, in screen pixels, of the area this buffer covers.

Author
slambright (4/30/2010)
Returns
QRect

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().

◆ createViewportBufferFill()

ViewportBufferFill * Isis::ViewportBuffer::createViewportBufferFill ( QRect  someRect,
bool  useOldY 
)
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.

Parameters
someRect
useOldY
Returns
ViewportBufferFill*

Definition at line 488 of file ViewportBuffer.cpp.

References _FILEINFO_.

◆ currentProgress()

double Isis::ViewportBuffer::currentProgress ( )

Returns the viewport buffer's loading progress.

Returns
0 to 1 where 1 is 100%

Definition at line 625 of file ViewportBuffer.cpp.

Referenced by Isis::CubeViewport::onProgressTimer().

◆ DataReady

◆ DoneWithData

void Isis::ViewportBuffer::DoneWithData ( int  ,
const Isis::Brick  
)
signal

Tell cube data thread we're done with a brick.

◆ doQueuedActions()

void Isis::ViewportBuffer::doQueuedActions ( )
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().

◆ doStretchAction()

void Isis::ViewportBuffer::doStretchAction ( ViewportBufferStretch action)
private

Tells the cube viewport to restretch.

Parameters
action

Definition at line 806 of file ViewportBuffer.cpp.

◆ doTransformAction()

void Isis::ViewportBuffer::doTransformAction ( ViewportBufferTransform action)
private

◆ emptyBuffer()

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.

Parameters
forceIf true, memory will be freed regardless of current total buffer size (b/w -> rgb for example).

Definition at line 1233 of file ViewportBuffer.cpp.

◆ enable()

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.

Parameters
enabled

Definition at line 1294 of file ViewportBuffer.cpp.

Referenced by Isis::CubeViewport::CubeViewport(), Isis::CubeViewport::setScale(), and Isis::CubeViewport::showEvent().

◆ enabled()

bool Isis::ViewportBuffer::enabled ( )
inline

Returns whether the buffer is enabled (reading data) or not.

Returns
bool

Definition at line 120 of file ViewportBuffer.h.

References p_enabled.

Referenced by Isis::CubeViewport::paintPixmap(), Isis::CubeViewport::setScale(), and Isis::CubeViewport::showEvent().

◆ enqueueAction()

void Isis::ViewportBuffer::enqueueAction ( ViewportBufferAction action)
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)"

Parameters
action

Definition at line 312 of file ViewportBuffer.cpp.

References Isis::ViewportBufferAction::getActionType().

◆ fillBuffer() [1/2]

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.

Parameters
rect

Definition at line 106 of file ViewportBuffer.cpp.

References _FILEINFO_.

Referenced by Isis::CubeViewport::cubeContentsChanged(), and Isis::CubeViewport::cubeDataChanged().

◆ fillBuffer() [2/2]

◆ getBand()

int Isis::ViewportBuffer::getBand ( )
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().

◆ getLine()

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.

Parameters
line
Returns
const vector<double> &

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().

◆ getSampLineBoundingRect()

QList< double > Isis::ViewportBuffer::getSampLineBoundingRect ( )
private

Retrieves the current bounding rect in sample/line coordinates of the visible cube area.

Returns
QList<double>

Definition at line 439 of file ViewportBuffer.cpp.

◆ getXYBoundingRect()

QRect Isis::ViewportBuffer::getXYBoundingRect ( )
private

Retrieves the current bounding rect in viewport pixels of the visible cube area.

Returns
QRect

Definition at line 356 of file ViewportBuffer.cpp.

◆ hasEntireCube()

bool Isis::ViewportBuffer::hasEntireCube ( )

Method to see if the entire cube is in the buffer.

Returns
bool

Definition at line 415 of file ViewportBuffer.cpp.

Referenced by Isis::StretchTool::stretchRequested().

◆ pan()

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.

Parameters
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().

◆ ReadCube

void Isis::ViewportBuffer::ReadCube ( int  cubeId,
int  startSample,
int  startLine,
int  endSample,
int  endLine,
int  band,
void *  caller 
)
signal

Ask the cube data thread for data.

Parameters
cubeId
startSample
startLine
endSample
endLine
band
caller

◆ reinitialize()

void Isis::ViewportBuffer::reinitialize ( )
private

This resizes and fills entire buffer.

Exceptions
iException- "Unable to resize and fill buffer."
History:
2010-07-12 Jeannie Walldren - Added exception to help track errors.

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().

◆ reinitializeActionExists()

bool Isis::ViewportBuffer::reinitializeActionExists ( )
private

This searches for actions that will reset the entire buffer's contents.

Returns
bool True if a transform to size 0,0 exists

Definition at line 722 of file ViewportBuffer.cpp.

References Isis::ViewportBufferAction::getActionType(), Isis::ViewportBufferTransform::getBufferHeight(), and Isis::ViewportBufferTransform::getBufferWidth().

◆ requestCubeLine()

void Isis::ViewportBuffer::requestCubeLine ( ViewportBufferFill fill)
private

◆ resizeBuffer()

void Isis::ViewportBuffer::resizeBuffer ( unsigned int  width,
unsigned int  height 
)
private

Enlarges or shrinks the buffer and fills with nulls if necessary.

Parameters
width
height

Definition at line 821 of file ViewportBuffer.cpp.

References Isis::Null.

◆ resizedViewport()

void Isis::ViewportBuffer::resizedViewport ( )

◆ scaleChanged()

void Isis::ViewportBuffer::scaleChanged ( )

Call this when zoomed, re-reads visible area.

Exceptions
iException- "Unable to change scale"
History:
2010-07-12 Jeannie Walldren - Added exception to help track errors.

Definition at line 1273 of file ViewportBuffer.cpp.

References _FILEINFO_.

Referenced by Isis::CubeViewport::setScale().

◆ setBand()

void Isis::ViewportBuffer::setBand ( int  band)

Sets the band to read from, the buffer will be re-read if the band changes.

Parameters
band

Definition at line 1311 of file ViewportBuffer.cpp.

Referenced by Isis::CubeViewport::CubeViewport(), Isis::CubeViewport::viewGray(), and Isis::CubeViewport::viewRGB().

◆ shiftBuffer()

void Isis::ViewportBuffer::shiftBuffer ( int  deltaX,
int  deltaY 
)
private

Shifts the DN values in the buffer by deltaX and deltaY.

Does not fill from outside the buffer.

Parameters
deltaX
deltaY

Definition at line 837 of file ViewportBuffer.cpp.

References Isis::Null.

◆ startFillAction()

void Isis::ViewportBuffer::startFillAction ( ViewportBufferFill action)
private

Initializes a fill action by requesting the initial cube data.

Parameters
action

Definition at line 787 of file ViewportBuffer.cpp.

References Isis::ViewportBufferFill::shouldRequestMore(), and Isis::ViewportBufferAction::started().

◆ totalUnfilledArea()

double Isis::ViewportBuffer::totalUnfilledArea ( )

This returns the amount of area in the queue that needs new cube data/will be filled by fill actions.

Returns
double

Definition at line 641 of file ViewportBuffer.cpp.

References Isis::ViewportBufferAction::getActionType(), Isis::ViewportBufferFill::getReadPosition(), and Isis::ViewportBufferFill::getRect().

◆ updateBoundingRects()

void Isis::ViewportBuffer::updateBoundingRects ( )
private

Sets the old and new bounding rects.

Definition at line 460 of file ViewportBuffer.cpp.

◆ working()

Member Data Documentation

◆ p_actions

QQueue< ViewportBufferAction * >* Isis::ViewportBuffer::p_actions
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.

◆ p_band

int Isis::ViewportBuffer::p_band
private

The band to read from.

Definition at line 172 of file ViewportBuffer.h.

Referenced by getBand().

◆ p_buffer

std::vector< std::vector<double> > Isis::ViewportBuffer::p_buffer
private

The buffer to hold cube dn values.

Definition at line 175 of file ViewportBuffer.h.

◆ p_bufferInitialized

bool Isis::ViewportBuffer::p_bufferInitialized
private

True if the buffer has been initialized.

Definition at line 176 of file ViewportBuffer.h.

◆ p_cubeId

int Isis::ViewportBuffer::p_cubeId
private

Id associated with the cube in this viewport buffer.

Definition at line 169 of file ViewportBuffer.h.

◆ p_dataThread

CubeDataThread* Isis::ViewportBuffer::p_dataThread
private

manages cube io

Definition at line 170 of file ViewportBuffer.h.

◆ p_enabled

bool Isis::ViewportBuffer::p_enabled
private

True if reading from cube (active)

Definition at line 174 of file ViewportBuffer.h.

Referenced by enabled().

◆ p_initialStretchDone

bool Isis::ViewportBuffer::p_initialStretchDone
private

True if a stretch action has occurred.

Definition at line 197 of file ViewportBuffer.h.

◆ p_oldSampLineBoundingRect

QList< double > Isis::ViewportBuffer::p_oldSampLineBoundingRect
private

Previous bounding rect.

Definition at line 192 of file ViewportBuffer.h.

◆ p_oldVertScrollBarPos

int Isis::ViewportBuffer::p_oldVertScrollBarPos
private

Previous vertical scroll bar position.

Definition at line 196 of file ViewportBuffer.h.

◆ p_oldViewportHeight

int Isis::ViewportBuffer::p_oldViewportHeight
private

Previous viewport height.

Definition at line 194 of file ViewportBuffer.h.

◆ p_oldXYBoundingRect

QRect Isis::ViewportBuffer::p_oldXYBoundingRect
private

The previous bounding rect.

Definition at line 183 of file ViewportBuffer.h.

◆ p_requestedFillArea

double Isis::ViewportBuffer::p_requestedFillArea
private

Sum of the requested area to be filled.

Definition at line 198 of file ViewportBuffer.h.

◆ p_sampLineBoundingRect

QList< double > Isis::ViewportBuffer::p_sampLineBoundingRect
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.

◆ p_vertScrollBarPos

int Isis::ViewportBuffer::p_vertScrollBarPos
private

Current vertical scroll bar position.

Definition at line 195 of file ViewportBuffer.h.

◆ p_viewport

CubeViewport* Isis::ViewportBuffer::p_viewport
private

The CubeViewport which created this buffer.

Definition at line 168 of file ViewportBuffer.h.

◆ p_viewportHeight

int Isis::ViewportBuffer::p_viewportHeight
private

Current viewport height.

Definition at line 193 of file ViewportBuffer.h.

◆ p_XYBoundingRect

QRect Isis::ViewportBuffer::p_XYBoundingRect
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.


The documentation for this class was generated from the following files: