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 
19 namespace 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 
85  clearLabels();
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) {
117  MdiCubeViewport *cvp = cubeViewport();
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) {
143  MdiCubeViewport *cvp = cubeViewport();
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
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
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  double lat = cvp->camera()->UniversalLatitude();
214  double lon = cvp->camera()->UniversalLongitude();
215  p_latLabel->setText(QString("Lat %1").arg(lat));
216  p_lonLabel->setText(QString("Lon %1").arg(lon));
217  }
218  else {
219  double rad = cvp->camera()->LocalRadius().meters();
220  double lon = cvp->camera()->UniversalLongitude();
221  //??? p_latLabel->setToolTip("Radius Position");
222  p_latLabel->setText(QString("Rad %1").arg(rad));
223  p_lonLabel->setText(QString("Lon %1").arg(lon));
224  }
225  }
226  else {
227  p_latLabel->setText("Lat N/A");
228  p_lonLabel->setText("Lon N/A");
229  }
230  }
231 
232  else {
233  p_latLabel->hide();
234  p_lonLabel->hide();
235  }
236 
237  if(cvp->isGray()) {
238  p_grayLabel->show();
239  p_redLabel->hide();
240  p_grnLabel->hide();
241  p_bluLabel->hide();
242 
243  ViewportBuffer *grayBuf = cvp->grayBuffer();
244 
245  if(grayBuf->working()) {
246  p_grayLabel->setText("BUSY");
247  }
248  else {
249  const QRect rect(grayBuf->bufferXYRect());
250 
251  if(p.x() >= rect.left() && p.x() <= rect.right() &&
252  p.y() >= rect.top() && p.y() <= rect.bottom()) {
253  const int bufX = p.x() - rect.left();
254  const int bufY = p.y() - rect.top();
255  QString pixelString = IString(PixelToString(
256  grayBuf->getLine(bufY)[bufX])).ToQt();
257  p_grayLabel->setText(pixelString);
258  }
259  }
260  }
261  else {
262  p_grayLabel->hide();
263  p_redLabel->show();
264  p_grnLabel->show();
265  p_bluLabel->show();
266 
267  ViewportBuffer *redBuf = cvp->redBuffer();
268 
269  if(redBuf->working()) {
270  p_grayLabel->setText("BUSY");
271  }
272  else {
273  const QRect rRect = redBuf->bufferXYRect();
274 
275  if(p.x() >= rRect.left() && p.x() < rRect.right() &&
276  p.y() >= rRect.top() && p.y() < rRect.bottom()) {
277  const int rBufX = p.x() - rRect.left();
278  const int rBufY = p.y() - rRect.top();
279  QString rLab = "R ";
280  rLab += IString(PixelToString(
281  redBuf->getLine(rBufY)[rBufX])).ToQt();
282  p_redLabel->setText(rLab);
283  }
284  }
285 
286  ViewportBuffer *greenBuf = cvp->greenBuffer();
287 
288  if(greenBuf->working()) {
289  p_grayLabel->setText("BUSY");
290  }
291  else {
292  const QRect gRect = greenBuf->bufferXYRect();
293 
294  if(p.x() >= gRect.left() && p.x() < gRect.right() &&
295  p.y() >= gRect.top() && p.y() < gRect.bottom()) {
296  const int gBufX = p.x() - gRect.left();
297  const int gBufY = p.y() - gRect.top();
298  QString gLab = "G ";
299  gLab += IString(PixelToString(
300  greenBuf->getLine(gBufY)[gBufX])).ToQt();
301  p_grnLabel->setText(gLab);
302  }
303  }
304 
305  ViewportBuffer *blueBuf = cvp->blueBuffer();
306 
307  if(blueBuf->working()) {
308  p_grayLabel->setText("BUSY");
309  }
310  else {
311  const QRect bRect = blueBuf->bufferXYRect();
312 
313  if(p.x() >= bRect.left() && p.x() < bRect.right() &&
314  p.y() >= bRect.top() && p.y() < bRect.bottom()) {
315  const int bBufX = p.x() - bRect.left();
316  const int bBufY = p.y() - bRect.top();
317  QString bLab = "B ";
318  bLab += IString(PixelToString(
319  blueBuf->getLine(bBufY)[bBufX])).ToQt();
320  p_bluLabel->setText(bLab);
321  }
322  }
323  }
324  }
325 
326 
332  p_sampLabel->setText("S N/A");
333  p_lineLabel->setText("L N/A");
334  p_latLabel->setText("Lat N/A");
335  p_lonLabel->setText("Lon N/A");
336  p_grayLabel->setText("N/A");
337  p_redLabel->setText("R N/A");
338  p_grnLabel->setText("G N/A");
339  p_bluLabel->setText("B N/A");
340  }
341 
342 
348  if(cubeViewport() == NULL) return;
349  QPoint p = cubeViewport()->viewport()->mapFromGlobal(QCursor::pos());
350  if(p.x() < 0) return;
351  if(p.y() < 0) return;
352  if(p.x() >= cubeViewport()->viewport()->width()) return;
353  if(p.y() >= cubeViewport()->viewport()->height()) return;
354  updateLabels(p);
355  }
356 
357 
365  connect(cubeViewport(), SIGNAL(viewportUpdated()),
366  this, SLOT(locateCursor()));
367  }
368 
369 
377  disconnect(cubeViewport(), SIGNAL(viewportUpdated()),
378  this, SLOT(locateCursor()));
379  }
380 
381 
382  QStatusBar *TrackTool::getStatusBar(void) {
383  return p_sbar;
384  }
385 }
386 
Isis::CubeViewport::cubeLines
int cubeLines() const
Return the number of lines in the cube.
Definition: CubeViewport.cpp:439
Isis::PixelToString
QString PixelToString(double d)
Takes a double pixel value and returns the name of the pixel type as a string.
Definition: SpecialPixel.h:371
Isis::ViewportBuffer
Reads and stores visible DN values.
Definition: ViewportBuffer.h:63
Isis::MdiCubeViewport
Cube display widget for certain Isis MDI applications.
Definition: MdiCubeViewport.h:39
Isis::CubeViewport::redBuffer
ViewportBuffer * redBuffer()
Returns the red viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:421
Isis::Target::shape
ShapeModel * shape() const
Return the shape.
Definition: Target.cpp:655
Isis::TrackTool::removeConnections
void removeConnections(MdiCubeViewport *cvp)
Removes the connections from the given viewport.
Definition: TrackTool.cpp:376
Isis::ViewportBuffer::getLine
const std::vector< double > & getLine(int line)
Retrieves a line from the buffer.
Definition: ViewportBuffer.cpp:342
Isis::TrackTool::p_grayLabel
QLabel * p_grayLabel
Gray label.
Definition: TrackTool.h:71
Isis::TrackTool::displayWarning
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
Isis::TrackTool::clearLabels
void clearLabels()
Clears the labels.
Definition: TrackTool.cpp:331
Isis::Camera::SetImage
virtual bool SetImage(const double sample, const double line)
Sets the sample/line values of the image to get the lat/lon values.
Definition: Camera.cpp:154
Isis::Tool
Base class for the Qisis tools.
Definition: Tool.h:67
Isis::CubeViewport::isGray
bool isGray() const
Definition: CubeViewport.h:189
Isis::RingPlaneProjection::RingLongitude
double RingLongitude() const
This returns a ring longitude with correct ring longitude direction and domain as specified in the la...
Definition: RingPlaneProjection.cpp:530
Isis::TProjection::Longitude
virtual double Longitude() const
This returns a longitude with correct longitude direction and domain as specified in the label object...
Definition: TProjection.cpp:823
Isis::ShapeModel::name
QString name() const
Gets the shape name.
Definition: ShapeModel.cpp:543
Isis::Projection::projectionType
ProjectionType projectionType() const
Returns an enum value for the projection type.
Definition: Projection.cpp:198
Isis::TrackTool::p_sampLabel
QLabel * p_sampLabel
Sample label.
Definition: TrackTool.h:67
Isis::TrackTool::mWarningWidget
WarningWidget * mWarningWidget
Warning Widget.
Definition: TrackTool.h:75
Isis::TrackTool::p_lineLabel
QLabel * p_lineLabel
Line label.
Definition: TrackTool.h:68
Isis::TrackTool::p_latLabel
QLabel * p_latLabel
Lat label.
Definition: TrackTool.h:69
Isis::CubeViewport::camera
Camera * camera() const
Definition: CubeViewport.h:348
Isis::TrackTool::p_lonLabel
QLabel * p_lonLabel
Lon label.
Definition: TrackTool.h:70
Isis::Spice::target
virtual Target * target() const
Returns a pointer to the target object.
Definition: Spice.cpp:1368
Isis::TrackTool::mouseLeave
virtual void mouseLeave()
Clears the labels if the mouse leaves the application.
Definition: TrackTool.cpp:131
Isis::TrackTool::p_sbar
QStatusBar * p_sbar
Status bar.
Definition: TrackTool.h:66
Isis::RingPlaneProjection
Base class for Map Projections of plane shapes.
Definition: RingPlaneProjection.h:147
Isis::TrackTool::mouseMove
virtual void mouseMove(QPoint p)
Updates the labels anytime the mouse moves.
Definition: TrackTool.cpp:116
Isis::Sensor::UniversalLongitude
virtual double UniversalLongitude() const
Returns the positive east, 0-360 domain longitude, in degrees, at the surface intersection point in t...
Definition: Sensor.cpp:233
Isis::TProjection::Latitude
virtual double Latitude() const
This returns a latitude with correct latitude type as specified in the label object.
Definition: TProjection.cpp:811
Isis::TrackTool::p_bluLabel
QLabel * p_bluLabel
Blue label.
Definition: TrackTool.h:74
Isis::RingPlaneProjection::RingRadius
double RingRadius() const
This returns a radius.
Definition: RingPlaneProjection.cpp:506
Isis::TProjection
Base class for Map TProjections.
Definition: TProjection.h:166
Isis::TrackTool::p_grnLabel
QLabel * p_grnLabel
Green label.
Definition: TrackTool.h:73
Isis::TrackTool::locateCursor
void locateCursor()
Finds the cursor position.
Definition: TrackTool.cpp:347
Isis::CubeViewport::cubeSamples
int cubeSamples() const
Return the number of samples in the cube.
Definition: CubeViewport.cpp:433
Isis::Projection::SetWorld
virtual bool SetWorld(const double x, const double y)
This method is used to set a world coordinate.
Definition: Projection.cpp:497
Isis::ViewportBuffer::bufferXYRect
QRect bufferXYRect()
Returns a rect, in screen pixels, of the area this buffer covers.
Definition: ViewportBuffer.cpp:1257
Isis::TrackTool::p_redLabel
QLabel * p_redLabel
Red label.
Definition: TrackTool.h:72
Isis::TrackTool::resetStatusWarning
void resetStatusWarning(void)
Resets the warning status on the status bar to default.
Definition: TrackTool.cpp:104
Isis::CubeViewport::blueBuffer
ViewportBuffer * blueBuffer()
Returns the blue viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:441
Isis::TrackTool::updateLabels
void updateLabels(QPoint p)
Updates the tracking labels.
Definition: TrackTool.cpp:142
Isis::TrackTool::addConnections
void addConnections(MdiCubeViewport *cvp)
Adds the connections to the given viewport.
Definition: TrackTool.cpp:364
Isis::WarningWidget
Displays the NoWarning icon as default and the Warning icon in case of exception and also pops up a a...
Definition: WarningWidget.h:38
Isis::Tool::activate
void activate(bool)
Activates the tool.
Definition: Tool.cpp:131
Isis::Distance::meters
double meters() const
Get the distance in meters.
Definition: Distance.cpp:85
Isis::Projection::Triaxial
@ Triaxial
These projections are used to map triaxial and irregular-shaped bodies.
Definition: Projection.h:166
Isis::CubeViewport::viewportToCube
void viewportToCube(int x, int y, double &sample, double &line) const
Turns a viewport into a cube.
Definition: CubeViewport.cpp:815
Isis::Projection::IsSky
bool IsSky() const
Returns true if projection is sky and false if it is land.
Definition: Projection.cpp:208
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
Isis::TrackTool::TrackTool
TrackTool(QStatusBar *parent)
TrackTool constructor.
Definition: TrackTool.cpp:26
Isis::CubeViewport::grayBuffer
ViewportBuffer * grayBuffer()
Returns the gray viewport buffer (Will be NULL if in RGB mode.)
Definition: CubeViewport.h:411
Isis::Projection::ProjectionType
ProjectionType
This enum defines the subclasses of Projection supported in Isis.
Definition: Projection.h:166
Isis::WarningWidget::resetWarning
void resetWarning(void)
When the dialog "OK" button is clicked or when the mouse is released on some other area or tool the W...
Definition: WarningWidget.cpp:118
Isis::Tool::cubeViewport
MdiCubeViewport * cubeViewport() const
Return the current cubeviewport.
Definition: Tool.h:197
Isis::CubeViewport::greenBuffer
ViewportBuffer * greenBuffer()
Returns the green viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:431
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::IString::ToQt
QString ToQt() const
Retuns the object string as a QString.
Definition: IString.cpp:869
Isis::Sensor::LocalRadius
Distance LocalRadius() const
Returns the local radius at the intersection point.
Definition: Sensor.cpp:267
Isis::CubeViewport::projection
Projection * projection() const
Definition: CubeViewport.h:343
Isis::WarningWidget::viewWarningWidgetIcon
void viewWarningWidgetIcon(std::string &pStr, const std::string &pExStr)
View Warning icon when there is an exception.
Definition: WarningWidget.cpp:149
Isis::Sensor::UniversalLatitude
virtual double UniversalLatitude() const
Returns the planetocentric latitude, in degrees, at the surface intersection point in the body fixed ...
Definition: Sensor.cpp:210
Isis::ViewportBuffer::working
bool working()
This tests if queued actions exist in the viewport buffer.
Definition: ViewportBuffer.cpp:759