Isis 3 Programmer Reference
ViewportBufferFill.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "ViewportBufferFill.h"
10 
11 #include <algorithm>
12 #include <iostream>
13 
14 #include <QRect>
15 #include <QPoint>
16 
17 using namespace std;
18 
19 namespace Isis {
30  ViewportBufferFill::ViewportBufferFill(const QRect &rect,
31  const int &xCoef, const double &xScale, const int &yCoef,
32  const double &yScale, const QPoint &topLeftPixel)
34  p_rect = NULL;
35  p_topLeftPixel = NULL;
36 
37  p_rect = new QRect(rect);
38  p_topLeftPixel = new QPoint(topLeftPixel);
39  p_requestPosition = rect.top();
40  p_readPosition = rect.top();
41  p_xCoef = xCoef;
42  p_xScale = xScale;
43  p_yCoef = yCoef;
44  p_yScale = yScale;
45  }
46 
51  if(p_rect) {
52  delete p_rect;
53  p_rect = NULL;
54  }
55 
56  if(p_topLeftPixel) {
57  delete p_topLeftPixel;
58  p_topLeftPixel = NULL;
59  }
60  }
61 
68  return p_topLeftPixel->y();
69  }
70 
71 
78  return p_topLeftPixel->x();
79  }
80 
81 
88  return p_readPosition >= (unsigned)(p_rect->top() + p_rect->height());
89  }
90 
91 
98  return p_requestPosition < (unsigned)(p_rect->top() + p_rect->height());
99  }
100 
101 
106  p_rect->setBottom(p_requestPosition - 1);
107  }
108 
109 
118  bool ViewportBufferFill::shouldPaint(int &linesToPaint) {
119  if(p_rect->height() < STEPSIZE)
120  linesToPaint = p_rect->height();
121  else
122  linesToPaint = STEPSIZE;
123 
124  return p_readPosition % STEPSIZE == 0 || doneReading();
125  }
126 }
Isis::ViewportBufferFill::doneReading
bool doneReading()
Returns true if read position is past the end of the fill.
Definition: ViewportBufferFill.cpp:87
Isis::ViewportBufferFill::p_rect
QRect * p_rect
Rect this fill represents.
Definition: ViewportBufferFill.h:121
Isis::ViewportBufferFill::p_yCoef
int p_yCoef
viewport to sample/line y coef
Definition: ViewportBufferFill.h:129
Isis::ViewportBufferFill::STEPSIZE
static const int STEPSIZE
how many cube lines per paint if painting inbetween gets re-enabled
Definition: ViewportBufferFill.h:134
Isis::ViewportBufferFill::shouldPaint
bool shouldPaint(int &linesToPaint)
Returns true if it is recommended to paint the fill area so far.
Definition: ViewportBufferFill.cpp:118
Isis::ViewportBufferFill::getTopmostPixelPosition
int getTopmostPixelPosition()
Returns the top of the X/Y bounding rect for this fill.
Definition: ViewportBufferFill.cpp:67
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::p_xCoef
int p_xCoef
viewport to sample/line x coef
Definition: ViewportBufferFill.h:125
Isis::ViewportBufferFill::getLeftmostPixelPosition
int getLeftmostPixelPosition()
Returns the left of the X/Y bounding rect for this fill.
Definition: ViewportBufferFill.cpp:77
Isis::ViewportBufferFill::p_xScale
double p_xScale
viewport to sample/line x scalar
Definition: ViewportBufferFill.h:127
Isis::ViewportBufferFill::p_requestPosition
unsigned int p_requestPosition
Position of the cube requests.
Definition: ViewportBufferFill.h:119
std
Namespace for the standard library.
Isis::ViewportBufferFill::p_readPosition
unsigned int p_readPosition
Position of the cube reads.
Definition: ViewportBufferFill.h:117
Isis::ViewportBufferFill::stop
void stop()
Cancels the current operation.
Definition: ViewportBufferFill.cpp:105
Isis::ViewportBufferFill::p_topLeftPixel
QPoint * p_topLeftPixel
Top left of the viewport for this fill.
Definition: ViewportBufferFill.h:123
Isis::ViewportBufferFill::p_yScale
double p_yScale
viewport to sample/line y scalar
Definition: ViewportBufferFill.h:131
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::ViewportBufferFill::~ViewportBufferFill
~ViewportBufferFill()
Destructor.
Definition: ViewportBufferFill.cpp:50