Isis 3.0 Object Programmers' Reference
Home
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
ViewportBufferFill.cpp
1
2
#include "ViewportBufferFill.h"
3
4
#include <algorithm>
5
#include <iostream>
6
7
#include <QRect>
8
#include <QPoint>
9
10
using namespace
std;
11
12
namespace
Isis {
23
ViewportBufferFill::ViewportBufferFill(
const
QRect &rect,
24
const
int
&xCoef,
const
double
&xScale,
const
int
&yCoef,
25
const
double
&yScale,
const
QPoint &topLeftPixel)
26
:
ViewportBufferAction
() {
27
p_rect
= NULL;
28
p_topLeftPixel
= NULL;
29
30
p_rect
=
new
QRect(rect);
31
p_topLeftPixel
=
new
QPoint(topLeftPixel);
32
p_requestPosition
= rect.top();
33
p_readPosition
= rect.top();
34
p_xCoef
= xCoef;
35
p_xScale
= xScale;
36
p_yCoef
= yCoef;
37
p_yScale
= yScale;
38
}
39
43
ViewportBufferFill::~ViewportBufferFill
() {
44
if
(
p_rect
) {
45
delete
p_rect
;
46
p_rect
= NULL;
47
}
48
49
if
(
p_topLeftPixel
) {
50
delete
p_topLeftPixel
;
51
p_topLeftPixel
= NULL;
52
}
53
}
54
60
int
ViewportBufferFill::getTopmostPixelPosition
() {
61
return
p_topLeftPixel
->y();
62
}
63
64
70
int
ViewportBufferFill::getLeftmostPixelPosition
() {
71
return
p_topLeftPixel
->x();
72
}
73
74
80
bool
ViewportBufferFill::doneReading
() {
81
return
p_readPosition
>= (unsigned)(
p_rect
->top() +
p_rect
->height());
82
}
83
84
90
bool
ViewportBufferFill::shouldRequestMore
() {
91
return
p_requestPosition
< (unsigned)(
p_rect
->top() +
p_rect
->height());
92
}
93
94
98
void
ViewportBufferFill::stop
() {
99
p_rect
->setBottom(
p_requestPosition
);
100
}
101
102
111
bool
ViewportBufferFill::shouldPaint
(
int
&linesToPaint) {
112
if
(
p_rect
->height() <
STEPSIZE
)
113
linesToPaint =
p_rect
->height();
114
else
115
linesToPaint =
STEPSIZE
;
116
117
return
p_readPosition
%
STEPSIZE
== 0 ||
doneReading
();
118
}
119
}