Isis 3 Programmer Reference
MosaicTrackTool.cpp
1 #include "MosaicTrackTool.h"
2 
3 #include <QLabel>
4 #include <QStatusBar>
5 
6 #include "MosaicSceneWidget.h"
7 #include "Projection.h"
8 #include "TProjection.h"
9 
10 namespace Isis {
18  QStatusBar *status) : MosaicTool(scene) {
19  p_sbar = status;
20 
21  p_latLabel = new QLabel(getWidget());
22  p_latLabel->setText("");
23  p_latLabel->setMinimumSize(p_latLabel->sizeHint());
24  p_latLabel->setToolTip("Latitude");
25  p_sbar->addPermanentWidget(p_latLabel);
26  connect(p_latLabel, SIGNAL(destroyed(QObject *)),
27  this, SLOT(labelDestroyed(QObject *)));
28 
29  p_lonLabel = new QLabel(getWidget());
30  p_lonLabel->setText("");
31  p_lonLabel->setMinimumSize(p_lonLabel->sizeHint());
32  p_lonLabel->setToolTip("Longitude");
33  p_sbar->addPermanentWidget(p_lonLabel);
34  connect(p_lonLabel, SIGNAL(destroyed(QObject *)),
35  this, SLOT(labelDestroyed(QObject *)));
36 
37  p_xLabel = new QLabel(getWidget());
38  p_xLabel->setText("X");
39  p_xLabel->setMinimumSize(p_lonLabel->sizeHint());
40  p_xLabel->setToolTip("Longitude");
41  p_sbar->addPermanentWidget(p_xLabel);
42  connect(p_xLabel, SIGNAL(destroyed(QObject *)),
43  this, SLOT(labelDestroyed(QObject *)));
44 
45  p_yLabel = new QLabel(getWidget());
46  p_yLabel->setText("Y");
47  p_yLabel->setMinimumSize(p_lonLabel->sizeHint());
48  p_yLabel->setToolTip("Longitude");
49  p_sbar->addPermanentWidget(p_yLabel);
50  connect(p_yLabel, SIGNAL(destroyed(QObject *)),
51  this, SLOT(labelDestroyed(QObject *)));
52 
53  clearLabels();
54  }
55 
56 
57  MosaicTrackTool::~MosaicTrackTool() {
58  if(p_latLabel) {
59  p_latLabel->deleteLater();
60  }
61 
62  if(p_lonLabel) {
63  p_lonLabel->deleteLater();
64  }
65 
66  if(p_xLabel) {
67  p_xLabel->deleteLater();
68  }
69 
70  if(p_yLabel) {
71  p_yLabel->deleteLater();
72  }
73  }
74 
75 
76  void MosaicTrackTool::mouseMove(QPointF p) {
77  updateLabels(p);
78  }
79 
80 
82  return NULL;
83  }
84 
85 
91  clearLabels();
92  }
93 
94 
95  void MosaicTrackTool::labelDestroyed(QObject *obj) {
96  if(p_latLabel == obj) {
97  p_latLabel = NULL;
98  }
99 
100  if(p_lonLabel == obj) {
101  p_lonLabel = NULL;
102  }
103 
104  if(p_xLabel == obj) {
105  p_xLabel = NULL;
106  }
107 
108  if(p_yLabel == obj) {
109  p_yLabel = NULL;
110  }
111  }
112 
113 
123  //----------------------------------------------------------------------
124  // we need to find out if the point given is over an item, if not, call
125  // clearLables() if so, then we need to get the item and figure out the
126  // lat/lon that corresponds with the given point.
127  //----------------------------------------------------------------------
128  Projection *proj = getWidget()->getProjection();
129  TProjection *tproj = (TProjection *) proj;
130 
131  if (!proj || proj->projectionType() != Projection::Triaxial) {
132  clearLabels();
133  return;
134  }
135 
136  proj->SetCoordinate(p.x(), -1 * p.y());
137 
138  if(p_lonLabel) {
139  p_lonLabel->setVisible(true);
140  p_lonLabel->setText("LON " + QString::number(tproj->Longitude()));
141  }
142 
143  if(p_latLabel) {
144  p_latLabel->setVisible(true);
145  p_latLabel->setText("LAT " + QString::number(tproj->Latitude()));
146  }
147 
148  if(p_xLabel) {
149  p_xLabel->setVisible(true);
150  p_xLabel->setText("X " + QString::number(p.x()));
151  }
152 
153  if(p_yLabel) {
154  p_yLabel->setVisible(true);
155  p_yLabel->setText("Y " + QString::number(-1 * p.y()));
156  }
157  }
158 
159 
165  if(p_lonLabel)
166  p_lonLabel->setVisible(false);
167 
168  if(p_latLabel)
169  p_latLabel->setVisible(false);
170 
171  if(p_xLabel)
172  p_xLabel->setVisible(false);
173 
174  if(p_yLabel)
175  p_yLabel->setVisible(false);
176  }
177 
178 }
179 
Isis::MosaicTrackTool::getPrimaryAction
virtual QAction * getPrimaryAction()
This method returns an action that is used to activate this tool.
Definition: MosaicTrackTool.cpp:81
Isis::MosaicTrackTool::mouseLeave
virtual void mouseLeave()
Clears the labels if the mouse leaves the application.
Definition: MosaicTrackTool.cpp:90
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::Projection::projectionType
ProjectionType projectionType() const
Returns an enum value for the projection type.
Definition: Projection.cpp:198
Isis::MosaicSceneWidget
This widget encompasses the entire mosaic scene.
Definition: MosaicSceneWidget.h:153
Isis::MosaicTrackTool::clearLabels
void clearLabels()
Clears the labels.
Definition: MosaicTrackTool.cpp:164
Isis::MosaicTool
Base class for the MosaicTools.
Definition: MosaicTool.h:37
Isis::MosaicTrackTool::p_sbar
QStatusBar * p_sbar
Status bar.
Definition: MosaicTrackTool.h:37
Isis::MosaicTrackTool::p_lonLabel
QLabel * p_lonLabel
Longitude label.
Definition: MosaicTrackTool.h:39
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::MosaicTrackTool::p_yLabel
QLabel * p_yLabel
Longitude label.
Definition: MosaicTrackTool.h:41
Isis::MosaicTrackTool::updateLabels
void updateLabels(QPointF p)
Updates the tracking labels.
Definition: MosaicTrackTool.cpp:122
Isis::TProjection
Base class for Map TProjections.
Definition: TProjection.h:166
Isis::MosaicTrackTool::p_latLabel
QLabel * p_latLabel
Latitude label.
Definition: MosaicTrackTool.h:38
Isis::MosaicTrackTool::p_xLabel
QLabel * p_xLabel
Latitude label.
Definition: MosaicTrackTool.h:40
Isis::Projection::Triaxial
@ Triaxial
These projections are used to map triaxial and irregular-shaped bodies.
Definition: Projection.h:166
QObject
Isis::Projection
Base class for Map Projections.
Definition: Projection.h:155
QAction
Isis::MosaicTrackTool::MosaicTrackTool
MosaicTrackTool(MosaicSceneWidget *, QStatusBar *)
MosaicTrackTool constructor.
Definition: MosaicTrackTool.cpp:17
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16