USGS

Isis 3.0 Object Programmers' Reference

Home

ViewportBufferFill.cpp

00001 
00002 #include "ViewportBufferFill.h"
00003 
00004 #include <algorithm>
00005 #include <iostream>
00006 
00007 #include <QRect>
00008 #include <QPoint>
00009 
00010 using namespace std;
00011 
00012 namespace Isis {
00023   ViewportBufferFill::ViewportBufferFill(const QRect &rect,
00024       const int &xCoef, const double &xScale, const int &yCoef,
00025       const double &yScale, const QPoint &topLeftPixel)
00026       : ViewportBufferAction() {
00027     p_rect = NULL;
00028     p_topLeftPixel = NULL;
00029 
00030     p_rect = new QRect(rect);
00031     p_topLeftPixel = new QPoint(topLeftPixel);
00032     p_requestPosition = rect.top();
00033     p_readPosition = rect.top();
00034     p_xCoef = xCoef;
00035     p_xScale = xScale;
00036     p_yCoef = yCoef;
00037     p_yScale = yScale;
00038   }
00039 
00043   ViewportBufferFill::~ViewportBufferFill() {
00044     if(p_rect) {
00045       delete p_rect;
00046       p_rect = NULL;
00047     }
00048 
00049     if(p_topLeftPixel) {
00050       delete p_topLeftPixel;
00051       p_topLeftPixel = NULL;
00052     }
00053   }
00054 
00060   int ViewportBufferFill::getTopmostPixelPosition() {
00061     return p_topLeftPixel->y();
00062   }
00063 
00064 
00070   int ViewportBufferFill::getLeftmostPixelPosition() {
00071     return p_topLeftPixel->x();
00072   }
00073 
00074 
00080   bool ViewportBufferFill::doneReading() {
00081     return p_readPosition >= (unsigned)(p_rect->top() + p_rect->height());
00082   }
00083 
00084 
00090   bool ViewportBufferFill::shouldRequestMore() {
00091     return p_requestPosition < (unsigned)(p_rect->top() + p_rect->height());
00092   }
00093 
00094 
00098   void ViewportBufferFill::stop() {
00099     p_rect->setBottom(p_requestPosition);
00100   }
00101 
00102 
00111   bool ViewportBufferFill::shouldPaint(int &linesToPaint) {
00112     if(p_rect->height() < STEPSIZE)
00113       linesToPaint = p_rect->height();
00114     else
00115       linesToPaint = STEPSIZE;
00116 
00117     return p_readPosition % STEPSIZE == 0 || doneReading();
00118   }
00119 }