-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathImage_Tile.hh
262 lines (207 loc) · 7.79 KB
/
Image_Tile.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/* Image_Tile
HiROC CVS ID: $Id: Image_Tile.hh,v 1.19 2012/06/17 00:34:08 castalia Exp $
Copyright (C) 2010-2011 Arizona Board of Regents on behalf of the
Planetary Image Research Laboratory, Lunar and Planetary Laboratory at
the University of Arizona.
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License, version 2.1,
as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*******************************************************************************/
#ifndef HiView_Image_Tile_hh
#define HiView_Image_Tile_hh
#include <QMetaType>
#include <QPoint>
#include <QRect>
#include <QString>
#include <iosfwd>
namespace UA
{
namespace HiRISE
{
// Forward reference.
class Plastic_Image;
/** An <i>Image_Tile</i> encapsulates a Plastic_Image and the
characteristics associated with rendering the image.
@author Bradford Castaia, UA/HiROC
@version $Revision: 1.19 $
*/
class Image_Tile
{
public:
/*==============================================================================
Constants
*/
//! Class identification name with source code version and date.
static const char* const
ID;
/** The {@link status() status of an Image_Tile.
The LOW_PRIORITY status refers to a tile that contains a null tile
coordinate. Such a tile is expected to be located beyond the bounds
of the display viewport.
The HIGH_PRIORITY status refers to a tile that contains a positive
tile coordinate. Such a tile is expected to intersect the display
viewport. The Image_Renderer will place a high priority tile before
low priority tiles in the Image_Rendering Queue of Image_Tiles.
<b>N.B.</b>: Corresponding Image_Renderer status values depend on
these values.
*/
enum
{
LOW_PRIORITY = 1,
HIGH_PRIORITY = 2
};
/* >>> CAUTION <<< These values must be 1 and 2 because they are
used by the Image_Renderer which relies on them.
*/
/*==============================================================================
Constructors
*/
/** Construct an empty Image_Tile.
*/
Image_Tile ();
/** Construct an Image_Tile with a Plastic_Image and optional
rendering characteristics.
@param image A pointer to a Plastic_Image. This should not be
null, but it is not an error if it is.
@param tile_coordinate A QPoint specifying the location of the
tile image in the display tile grid. The tile coordinate
determines the {@link status() tile status}: A tile with a
null coordinate is deemed low priority; otherwise the tile
is high priority.
@param tile_region A QRect specifying the region of the tile image,
in tile-relative coordinates, that is visible in the display
viewport.
@param cancelable If true rendering of the tile image may be
canceled; otherwise the tile should be considered persistent in
the rendering queue when rendering is cancelled.
@param delete_when_done If true the tile's Plastic_Image is to
be deleted when the tile is destroyed.
*/
Image_Tile (Plastic_Image* image,
const QPoint& tile_coordinate = QPoint (),
const QRect& tile_region = QRect (),
bool cancelable = true, bool delete_when_done = false);
/** Construct an Image_Tile with a Plastic_Image and
rendering characteristics.
The tile will have a null Tile_Region which make it low priority.
@param image A pointer to a Plastic_Image. This should not be
null, but it is not an error if it is.
@param tile_coordinate A QPoint specifying the location of the
tile image in the display tile grid. The tile coordinate
determines the {@link status() tile status}: A tile with a
null coordinate is deemed low priority; otherwise the tile
is high priority.
@param cancelable If true rendering of the tile image may be
canceled; otherwise the tile should be considered persistent in
the rendering queue when rendering is cancelled.
@param delete_when_done If true the tile's Plastic_Image is to
be deleted when the tile is destroyed.
*/
Image_Tile (Plastic_Image* image,
const QPoint& tile_coordinate,
bool cancelable = true, bool delete_when_done = false);
/** Construct an Image_Tile from a copy of another Image_Tile.
The Image pointer and all rendering characteristics are copied.
@param image_tile A reference to the Image_Tile to be copied.
*/
Image_Tile (const Image_Tile& image_tile);
/** Assign the content of another Image_Tile to this Image_Tile.
The Image pointer and all rendering characteristics are copied.
The previous Image is never deleted.
@param image_tile A reference to the Image_Tile to be assigned.
*/
Image_Tile& operator= (const Image_Tile& image_tile);
/** Delete the Image_Tile.
If Delete_Image_When_Done is true the Plastic_Image pointed to by
Image is deleted.
*/
~Image_Tile ();
/*==============================================================================
Accessors
*/
/** Get the priority status of the tile.
@return LOW_PRIORITY if the tile {@link is_low_priority() is low
priority}; HIGH_PRIORITY otherwise.
*/
inline int status () const
{return (is_low_priority () ? LOW_PRIORITY : HIGH_PRIORITY);}
/** Test if tile has low priority status.
@return true if the Tile_Coordinate x value is zero; false otherwise.
@see status()
*/
inline bool is_low_priority () const
{return Tile_Coordinate.x () == 0;}
/** Test if tile has high priority status.
@return true if the Tile_Coordinate x value greater than zero;
false otherwise.
@see status()
*/
inline bool is_high_priority () const
{return Tile_Coordinate.x () > 0;}
/** Get the area of the tile visible in the display viewport.
@return The area of the tile visible in the display viewport; i.e.
the Tile_Region width times height. Note that a {@link
is_low_priority() low priority} tile will always have a zero
area.
*/
inline unsigned long long area () const
{return (unsigned long long)Tile_Region.width () * Tile_Region.height ();}
/*==============================================================================
Tile Accounting
*/
/* Print a list of extant Image_Tiles.
<b>N.B.</b>: This method is a no-op unless the Image_Tile class has
been compiled with DEBUG defined.
When an Image_Tile is constructed it is appended to the list of
extant Image_Tiles and when it is destroyed it is removed from
the list.
*/
static void tile_accounting ();
/*==============================================================================
Data Members
*/
// The image that renders this tile.
Plastic_Image*
Image;
// The coordinate of the tile in the tile grid.
QPoint
Tile_Coordinate;
// The tile region (tile-relative) that is visible in the display viewport.
QRect
Tile_Region;
// Flag to indicate if the Renderer can cancel rendering the tile image.
bool
Cancelable;
// Flag to indicate if the Image is to be deleted when the tile is destroyed.
bool
Delete_Image_When_Done;
};
/*==============================================================================
Utility Functions
*/
/** Image_Tile output operator.
The description printed to the output stream is contained on a single
line of the form:
Image_Tile @ <tile address>
Image @ <Image address>
at <Tile_Coordinate>
displays <Tile_Region>
is [not] <Cancelable> [; <Delete_Image_When_Done>]
@param stream A std::ostream reference.
@param image_tile An Image_Tile reference.
@return The stream reference.
*/
std::ostream& operator<< (std::ostream& stream,
const Image_Tile& image_tile);
} // namespace HiRISE
} // namespace UA
//! Qt meta-type declaration.
Q_DECLARE_METATYPE(UA::HiRISE::Image_Tile);
#endif