Isis 3 Programmer Reference
TrackTool.cpp
1#include "TrackTool.h"
2
3#include <QStatusBar>
4#include <QLabel>
5#include <QCursor>
6
7#include "Camera.h"
8#include "Distance.h"
9#include "MdiCubeViewport.h"
10#include "Projection.h"
11#include "RingPlaneProjection.h"
12#include "SpecialPixel.h"
13#include "Target.h"
14#include "TProjection.h"
15#include "ViewportBuffer.h"
16#include "WarningWidget.h"
17
18
19namespace Isis {
26 TrackTool::TrackTool(QStatusBar *parent) : Tool(parent) {
27 p_sbar = parent;
28
29 p_sampLabel = new QLabel(p_sbar);
30 p_sampLabel->setText("W 999999");
31 p_sampLabel->setMinimumSize(p_sampLabel->sizeHint());
32 p_sampLabel->setToolTip("Sample Position");
33 p_sbar->addPermanentWidget(p_sampLabel);
34
35 p_lineLabel = new QLabel(p_sbar);
36 p_lineLabel->setText("W 999999");
37 p_lineLabel->setMinimumSize(p_lineLabel->sizeHint());
38 p_lineLabel->setToolTip("Line Position");
39 p_sbar->addPermanentWidget(p_lineLabel);
40
41 p_latLabel = new QLabel(p_sbar);
42 p_latLabel->setText("9.999999E-99");
43 p_latLabel->setMinimumSize(p_latLabel->sizeHint());
44 p_latLabel->hide();
45 p_latLabel->setToolTip("Latitude Position");
46 p_sbar->addPermanentWidget(p_latLabel);
47
48 p_lonLabel = new QLabel(p_sbar);
49 p_lonLabel->setText("9.999999E-99");
50 p_lonLabel->setMinimumSize(p_lonLabel->sizeHint());
51 p_lonLabel->hide();
52 p_lonLabel->setToolTip("Longitude Position");
53 p_sbar->addPermanentWidget(p_lonLabel);
54
55 p_grayLabel = new QLabel(p_sbar);
56 p_grayLabel->setText("9.999999E-99");
57 p_grayLabel->setMinimumSize(p_grayLabel->sizeHint());
58 p_grayLabel->setToolTip("Gray Pixel Value");
59 p_sbar->addPermanentWidget(p_grayLabel);
60
61 p_redLabel = new QLabel(p_sbar);
62 p_redLabel->setText("W 9.999999E-99");
63 p_redLabel->setMinimumSize(p_redLabel->sizeHint());
64 p_redLabel->hide();
65 p_redLabel->setToolTip("Red Pixel Value");
66 p_sbar->addPermanentWidget(p_redLabel);
67
68 p_grnLabel = new QLabel(p_sbar);
69 p_grnLabel->setText("W 9.999999E-99");
70 p_grnLabel->setMinimumSize(p_grnLabel->sizeHint());
71 p_grnLabel->hide();
72 p_grnLabel->setToolTip("Green Pixel Value");
73 p_sbar->addPermanentWidget(p_grnLabel);
74
75 p_bluLabel = new QLabel(p_sbar);
76 p_bluLabel->setText("W 9.999999E-99");
77 p_bluLabel->setMinimumSize(p_bluLabel->sizeHint());
78 p_bluLabel->hide();
79 p_bluLabel->setToolTip("Blue Pixel Value");
80 p_sbar->addPermanentWidget(p_bluLabel);
81
83 connect(p_sbar, SIGNAL(messageChanged(const QString &)), mWarningWidget, SLOT(checkMessage()));
84
86
87 activate(true);
88 }
89
97 void TrackTool::displayWarning(std::string &pStr, const std::string &pExStr) {
99 }
100
105 if(mWarningWidget != NULL) {
107 }
108 }
109
116 void TrackTool::mouseMove(QPoint p) {
118 if(cvp == NULL) return;
119
120 if(p.x() >= 0 && p.x() < cvp->width() &&
121 p.y() >= 0 && p.y() < cvp->height()) {
122 updateLabels(p);
123 }
124 }
125
126
132 clearLabels();
133 }
134
135
142 void TrackTool::updateLabels(QPoint p) {
144
145 clearLabels();
146
147 if(cvp == NULL) {
148 return;
149 }
150
151 double sample, line;
152 cvp->viewportToCube(p.x(), p.y(), sample, line);
153 if((sample < 0.5) || (line < 0.5) ||
154 (sample > cvp->cubeSamples() + 0.5) ||
155 (line > cvp->cubeLines() + 0.5)) {
156 return;
157 }
158
159 int isamp = (int)(sample + 0.5);
160 QString text;
161 text.setNum(isamp);
162 text = "S " + text;
163 p_sampLabel->setText(text);
164
165 int iline = (int)(line + 0.5);
166 text.setNum(iline);
167 text = "L " + text;
168 p_lineLabel->setText(text);
169
170
171 // Do we have a projection?
172 if(cvp->projection() != NULL) {
173 // Set up for projection types
174 Projection::ProjectionType projType = cvp->projection()->projectionType();
175 p_latLabel->show();
176 p_lonLabel->show();
177
178 if(cvp->projection()->SetWorld(sample, line)) {
179 if (projType == Projection::Triaxial) {
180 TProjection *tproj = (TProjection *) cvp->projection();
181 double lat = tproj->Latitude();
182 double lon = tproj->Longitude();
183 if (cvp->projection()->IsSky()) {
184 p_latLabel->setText(QString("DEC %1").arg(lat));
185 p_lonLabel->setText(QString("RA %1").arg(lon));
186 }
187 else {
188 p_latLabel->setText(QString("Lat %1").arg(lat));
189 p_lonLabel->setText(QString("Lon %1").arg(lon));
190 }
191 }
192 else { // RingPlane TODO write out radius azimuth instead of lat/lon
193 RingPlaneProjection *rproj = (RingPlaneProjection *) cvp->projection();
194 double rad = rproj->RingRadius();
195 double lon = rproj->RingLongitude();
196 //??? p_latLabel->setToolTip("Radius Position");
197 p_latLabel->setText(QString("Rad %1").arg(rad));
198 p_lonLabel->setText(QString("Lon %1").arg(lon));
199 }
200 }
201 else {
202 p_latLabel->setText("Lat N/A");
203 p_lonLabel->setText("Lon N/A");
204 }
205 }
206 // Do we have a camera model?
207 else if(cvp->camera() != NULL) {
208 p_latLabel->show();
209 p_lonLabel->show();
210
211 if(cvp->camera()->SetImage(sample, line)) {
212 if (cvp->camera()->target()->shape()->name() != "Plane") {
213 if (cvp->camera()->target()->isSky()) {
214 double dec = cvp->camera()->Declination();
215 double ra = cvp->camera()->RightAscension();
216 p_latLabel->setText(QString("DEC %1").arg(dec));
217 p_lonLabel->setText(QString("RA %1").arg(ra));
218 }
219 else {
220 double lat = cvp->camera()->UniversalLatitude();
221 double lon = cvp->camera()->UniversalLongitude();
222 p_latLabel->setText(QString("Lat %1").arg(lat));
223 p_lonLabel->setText(QString("Lon %1").arg(lon));
224 }
225 }
226 else {
227 double rad = cvp->camera()->LocalRadius().meters();
228 double lon = cvp->camera()->UniversalLongitude();
229 //??? p_latLabel->setToolTip("Radius Position");
230 p_latLabel->setText(QString("Rad %1").arg(rad));
231 p_lonLabel->setText(QString("Lon %1").arg(lon));
232 }
233 }
234 else {
235 p_latLabel->setText("Lat N/A");
236 p_lonLabel->setText("Lon N/A");
237 }
238 }
239
240 else {
241 p_latLabel->hide();
242 p_lonLabel->hide();
243 }
244
245 if(cvp->isGray()) {
246 p_grayLabel->show();
247 p_redLabel->hide();
248 p_grnLabel->hide();
249 p_bluLabel->hide();
250
251 ViewportBuffer *buf = cvp->grayBuffer();
252
253 QString pixelString = updateColorLabel(p, buf, p_grayLabel);
254
255 p_grayLabel->setText(pixelString);
256 }
257 else {
258 p_grayLabel->hide();
259 p_redLabel->show();
260 p_grnLabel->show();
261 p_bluLabel->show();
262
263 ViewportBuffer *redBuf = cvp->redBuffer();
264 QString pixelString = updateColorLabel(p, redBuf, p_redLabel);
265 QString rLab = "R ";
266 rLab += IString(pixelString).ToQt();
267 p_redLabel->setText(rLab);
268
269 ViewportBuffer *greenBuf = cvp->greenBuffer();
270 pixelString = updateColorLabel(p, greenBuf, p_grnLabel);
271 QString gLab = "G ";
272 gLab += IString(pixelString).ToQt();
273 p_grnLabel->setText(gLab);
274
275 ViewportBuffer *blueBuf = cvp->blueBuffer();
276 pixelString = updateColorLabel(p, blueBuf, p_bluLabel);
277 QString bLab = "B ";
278 bLab += IString(pixelString).ToQt();
279 p_bluLabel->setText(bLab);
280 }
281 }
282
283 QString TrackTool::updateColorLabel(QPoint p, ViewportBuffer *buf, QLabel *label) {
284 if(!buf->working()) {
285 const QRect rRect = buf->bufferXYRect();
286
287 if(p.x() >= rRect.left() && p.x() < rRect.right() &&
288 p.y() >= rRect.top() && p.y() < rRect.bottom()) {
289 const int rBufX = p.x() - rRect.left();
290 const int rBufY = p.y() - rRect.top();
291 return PixelToString(buf->getLine(rBufY)[rBufX], 12);
292 }
293 }
294 return "BUSY";
295 }
296
297
303 p_sampLabel->setText("S N/A");
304 p_lineLabel->setText("L N/A");
305 p_latLabel->setText("Lat N/A");
306 p_lonLabel->setText("Lon N/A");
307 p_grayLabel->setText("N/A");
308 p_redLabel->setText("R N/A");
309 p_grnLabel->setText("G N/A");
310 p_bluLabel->setText("B N/A");
311 }
312
313
319 if(cubeViewport() == NULL) return;
320 QPoint p = cubeViewport()->viewport()->mapFromGlobal(QCursor::pos());
321 if(p.x() < 0) return;
322 if(p.y() < 0) return;
323 if(p.x() >= cubeViewport()->viewport()->width()) return;
324 if(p.y() >= cubeViewport()->viewport()->height()) return;
325 updateLabels(p);
326 }
327
328
336 connect(cubeViewport(), SIGNAL(viewportUpdated()),
337 this, SLOT(locateCursor()));
338 }
339
340
348 disconnect(cubeViewport(), SIGNAL(viewportUpdated()),
349 this, SLOT(locateCursor()));
350 }
351
352
353 QStatusBar *TrackTool::getStatusBar(void) {
354 return p_sbar;
355 }
356}
Adds specific functionality to C++ strings.
Definition IString.h:165
QString ToQt() const
Retuns the object string as a QString.
Definition IString.cpp:869
Cube display widget for certain Isis MDI applications.
ProjectionType
This enum defines the subclasses of Projection supported in Isis.
Definition Projection.h:166
@ Triaxial
These projections are used to map triaxial and irregular-shaped bodies.
Definition Projection.h:166
Base class for Map Projections of plane shapes.
double RingRadius() const
This returns a radius.
Base class for Map TProjections.
virtual double Latitude() const
This returns a latitude with correct latitude type as specified in the label object.
Base class for the Qisis tools.
Definition Tool.h:67
void activate(bool)
Activates the tool.
Definition Tool.cpp:131
MdiCubeViewport * cubeViewport() const
Return the current cubeviewport.
Definition Tool.h:197
QLabel * p_lonLabel
Lon label.
Definition TrackTool.h:72
QLabel * p_grayLabel
Gray label.
Definition TrackTool.h:73
void resetStatusWarning(void)
Resets the warning status on the status bar to default.
void updateLabels(QPoint p)
Updates the tracking labels.
void locateCursor()
Finds the cursor position.
QLabel * p_grnLabel
Green label.
Definition TrackTool.h:75
QLabel * p_bluLabel
Blue label.
Definition TrackTool.h:76
void addConnections(MdiCubeViewport *cvp)
Adds the connections to the given viewport.
QLabel * p_sampLabel
Sample label.
Definition TrackTool.h:69
void removeConnections(MdiCubeViewport *cvp)
Removes the connections from the given viewport.
virtual void mouseMove(QPoint p)
Updates the labels anytime the mouse moves.
void clearLabels()
Clears the labels.
WarningWidget * mWarningWidget
Warning Widget.
Definition TrackTool.h:77
void displayWarning(std::string &pStr, const std::string &pExStr)
Display the Warning icon in case of an exception, sent from the tool where the exception occured.
Definition TrackTool.cpp:97
TrackTool(QStatusBar *parent)
TrackTool constructor.
Definition TrackTool.cpp:26
QStatusBar * p_sbar
Status bar.
Definition TrackTool.h:68
QLabel * p_latLabel
Lat label.
Definition TrackTool.h:71
QLabel * p_redLabel
Red label.
Definition TrackTool.h:74
QLabel * p_lineLabel
Line label.
Definition TrackTool.h:70
virtual void mouseLeave()
Clears the labels if the mouse leaves the application.
Reads and stores visible DN values.
Displays the NoWarning icon as default and the Warning icon in case of exception and also pops up a a...
void viewWarningWidgetIcon(std::string &pStr, const std::string &pExStr)
View Warning icon when there is an exception.
void resetWarning(void)
When the dialog "OK" button is clicked or when the mouse is released on some other area or tool the W...
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString PixelToString(double d, double precision=8)
Takes a double pixel value and returns the name of the pixel type as a string.