2 #include "MeasureTool.h" 4 #include <QApplication> 11 #include <QMessageBox> 12 #include <QStackedWidget> 14 #include <QTableWidget> 15 #include <QToolButton> 17 #include <geos/geom/Geometry.h> 18 #include <geos/geom/Point.h> 56 "Start\nLatitude:Start\nLongitude:End\nLatitude:End\nLongitude",
57 "Ground Range", -1, Qt::Horizontal,
"Start Latitude/Longitude to End Latitude/Longitude");
59 "Pixel Range", -1, Qt::Horizontal,
"Start Sample/Line to End Sample/Line");
68 m_tableWin->
addToTable(
false,
"Segments Sum\nkm",
"Segments Sum", -1, Qt::Horizontal,
"Sum of Segment lengths in kilometers");
69 m_tableWin->
addToTable(
false,
"Segment Number",
"Segment Number", -1, Qt::Horizontal,
"Segment number of a segmented line");
90 action->setIcon(QPixmap(
toolIconDir() +
"/measure.png"));
91 action->setToolTip(
"Measure (M)");
92 action->setShortcut(Qt::Key_M);
95 "<b>Function:</b> Measure features in active viewport \ 96 <p><b>Shortcut:</b> M</p> ";
97 action->setWhatsThis(text);
113 QToolButton *measureButton =
new QToolButton(hbox);
114 measureButton->setText(
"Table");
115 measureButton->setToolTip(
"Record Measurement Data in Table");
117 "<b>Function:</b> This button will bring up a table that will record the \ 118 starting and ending points of the line, along with the distance between \ 119 the two points on the image. To measure the distance between two points, \ 120 click on the first point and releasing the mouse at the second point. \ 121 <p><b>Shortcut:</b> CTRL+M</p>";
122 measureButton->setWhatsThis(text);
123 measureButton->setShortcut(Qt::CTRL + Qt::Key_M);
124 connect(measureButton, SIGNAL(clicked()),
m_tableWin, SLOT(showTable()));
125 connect(measureButton, SIGNAL(clicked()),
m_tableWin, SLOT(syncColumns()));
126 connect(measureButton, SIGNAL(clicked()),
m_tableWin, SLOT(
raise()));
127 measureButton->setEnabled(
true);
145 QString text2 =
"<b>Function: </b> Shows the length of the line drawn on \ 150 m_showAllSegments =
new QCheckBox(hbox);
151 m_showAllSegments->setText(
"Show All Segments");
160 connect(rubberBandTool(), SIGNAL(modeChanged()),
this, SLOT(
updateUnitsCombo()));
162 QHBoxLayout *layout =
new QHBoxLayout(hbox);
163 layout->setMargin(0);
167 layout->addWidget(measureButton);
168 layout->addWidget(m_showAllSegments);
169 layout->addStretch(1);
170 hbox->setLayout(layout);
181 if (miComboUnit >= 0) {
186 m_showAllSegments->setEnabled(
false);
188 if (rubberBandTool()->currentMode() == RubberBandTool::LineMode ||
189 rubberBandTool()->currentMode() == RubberBandTool::SegmentedLineMode) {
191 if (rubberBandTool()->currentMode() == RubberBandTool::SegmentedLineMode) {
192 m_showAllSegments->setEnabled(
true);
198 if (miComboUnit < 0 || miComboUnit > 2) {
202 else if (rubberBandTool()->currentMode() == RubberBandTool::AngleMode) {
205 if (miComboUnit > 1 || miComboUnit < 0) {
213 if (miComboUnit < 0 || miComboUnit > 2) {
281 if (rubberBandTool()->currentMode() != RubberBandTool::AngleMode &&
m_unitsComboBox->currentIndex() != 2) {
283 QMessageBox::information((
QWidget *)parent(),
"Error",
284 "File must have a Camera Model or Projection to measure in km or m");
330 ASSERT(row < m_tableWin->table()->rowCount());
428 int requiredRows = m_distanceSegments.size() + row;
433 for (
int r = 0; r < rowDiff; r++) {
438 if (rubberBandTool()->currentMode() == RubberBandTool::SegmentedLineMode &&
439 m_distanceSegments.size() > 0) {
440 double distanceSum = 0;
441 for (
int i = 0; i < m_distanceSegments.size(); i++) {
443 if (m_startLatSegments[i] !=
Null && m_startLonSegments[i] !=
Null) {
452 if (m_endLatSegments[i] !=
Null && m_endLonSegments[i] !=
Null) {
461 if (m_startSampSegments[i] !=
Null && m_startLineSegments[i] !=
Null) {
470 if (m_endSampSegments[i] !=
Null && m_endLineSegments[i] !=
Null) {
479 if (m_pixDistSegments[i] !=
Null) {
486 if (m_distanceSegments[i] !=
Null) {
501 if (distanceSum !=
Null) {
539 void MeasureTool::addRow() {
543 QTableWidgetItem *item =
new QTableWidgetItem(
"");
547 QAbstractItemView::PositionAtBottom);
577 if (rubberBandTool()->currentMode() == RubberBandTool::LineMode ||
578 rubberBandTool()->currentMode() == RubberBandTool::SegmentedLineMode) {
579 m_distanceSegments.clear();
580 m_pixDistSegments.clear();
581 m_startSampSegments.clear();
582 m_endSampSegments.clear();
583 m_startLineSegments.clear();
584 m_endLineSegments.clear();
585 m_startLatSegments.clear();
586 m_endLatSegments.clear();
587 m_startLonSegments.clear();
588 m_endLonSegments.clear();
590 for (
int startIndex = 0; startIndex < rubberBandTool()->
vertices().size() - 1; startIndex++) {
591 QPoint start = rubberBandTool()->
vertices()[startIndex];
592 QPoint end = rubberBandTool()->
vertices()[startIndex + 1];
594 setDistances(cvp, start, end);
596 if (rubberBandTool()->currentMode() == RubberBandTool::SegmentedLineMode) {
597 if (m_distanceSegments.size() < 75) {
598 m_distanceSegments.append(
m_kmDist);
612 if (rubberBandTool()->currentMode() == RubberBandTool::SegmentedLineMode &&
613 m_pixDistSegments.size()) {
618 for (
int i = 1; i < m_pixDistSegments.size(); i++) {
624 thisDistance).kilometers();
626 thisDistance).meters();
630 else if (rubberBandTool()->currentMode() == RubberBandTool::AngleMode) {
635 geos::geom::Geometry *polygon = rubberBandTool()->
geometry();
636 if (polygon != NULL) {
639 geos::geom::Point *center = polygon->getCentroid();
641 cvp->
viewportToCube((
int)center->getX(), (int)center->getY(), sample, line);
643 if (cvp->
camera() != NULL) {
660 if (rubberBandTool()->currentMode() == RubberBandTool::RectangleMode) {
661 setDistances(cvp, rubberBandTool()->vertices()[0],
662 rubberBandTool()->vertices()[2]);
668 if (m_showAllSegments->isChecked() &&
669 rubberBandTool()->currentMode() == RubberBandTool::SegmentedLineMode) {
686 double radius =
Null;
697 (m_startSamp <= cvp->cubeSamples() + 0.5) &&
698 (m_endSamp <= cvp->cubeSamples() + 0.5) &&
699 (m_startLine <= cvp->cubeLines() + 0.5) &&
700 (m_endLine <= cvp->cubeLines() + 0.5)) {
717 rproj = (RingPlaneProjection *) cvp->
projection();
748 else if (cvp->
camera() != NULL &&
767 double pixDist = sqrt(lineDif * lineDif + sampDif * sampDif);
776 SurfacePoint startPoint;
777 SurfacePoint endPoint;
779 if (startLat.isValid() && startLon.isValid() &&
780 endLat.isValid() && endLon.isValid() && radiusDist.isValid()) {
781 startPoint = SurfacePoint(startLat, startLon, radiusDist);
782 endPoint = SurfacePoint(endLat, endLon, radiusDist);
785 Distance distance = startPoint.GetDistanceToPoint(endPoint, radiusDist);
794 if (rubberBandTool()->currentMode() == RubberBandTool::LineMode ||
795 rubberBandTool()->currentMode() == RubberBandTool::SegmentedLineMode) {
816 else if (rubberBandTool()->currentMode() == RubberBandTool::AngleMode) {
Cube display widget for certain Isis MDI applications.
void reset()
Resets the selection.
QString path() const
Returns the path of the file name.
double meters() const
Get the distance in meters.
const double Null
Value for an Isis Null pixel.
void setStatusMessage(QString message)
sets the status message in the lower lefthand corner of the window.
File name manipulation and expansion.
ProjectionType projectionType() const
Returns an enum value for the projection type.
double UniversalLatitude() const
Returns the planetocentric latitude, in degrees, at the surface intersection point in the body fixed ...
double radians() const
Convert an angle to a double.
Base class for Map TProjections.
void clearRow(int row)
This method clears the text of the given row.
Combo box for choosing a rubber band type.
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
double UniversalLongitude()
This returns a universal longitude (positive east in 0 to 360 domain).
The distance is being specified in kilometers.
double Resolution() const
This method returns the resolution for mapping world coordinates into projection coordinates.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Distance measurement, usually in meters.
double degrees() const
Get the angle in units of Degrees.
Distance LocalRadius() const
Returns the local radius at the intersection point.
void setTrackListItems(bool track=false)
If this property is true, the class will keep track of the checked/unchecked items in the dock area w...
bool SetImage(const double sample, const double line)
Sets the sample/line values of the image to get the lat/lon values.
These projections are used to map ring planes.
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
int currentRow() const
Returns the current row.
bool IsSky() const
Returns true if projection is sky and false if it is land.
double UniversalRingRadius()
This returns a universal radius, which is just the radius in meters.
double LocalRadius(double lat) const
This method returns the local radius in meters at the specified latitude position.
bool isLinked() const
Is the viewport linked with other viewports.
double UniversalLongitude() const
Returns the positive east, 0-360 domain longitude, in degrees, at the surface intersection point in t...
void setCurrentRow(int row)
Sets the current row to row.
double UniversalLatitude()
This returns a universal latitude (planetocentric).
a subclass of the qisis mainwindow, tablemainwindow handles all of the table tasks.
double RingRadius() const
This returns a radius.
bool SetWorld(const double x, const double y)
This method is used to set a world coordinate.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
QTableWidget * table() const
Returns the table.
Base class for Map Projections of plane shapes.
virtual QString fileName() const
Returns the opened cube's filename.
double PixelResolution()
Returns the pixel resolution at the current position in meters/pixel.
Namespace for ISIS/Bullet specific routines.
Projection * projection() const
The distance is being specified in meters.
void addToTable(bool setOn, const QString &heading, const QString &menuText="", int insertAt=-1, Qt::Orientation o=Qt::Horizontal, QString toolTip="")
Adds a new column to the table when a new curve is added to the plot.
void viewportToCube(int x, int y, double &sample, double &line) const
Turns a viewport into a cube.
The distance is being specified in pixels.
ProjectionType
This enum defines the subclasses of Projection supported in Isis.
double UniversalRingLongitude()
This returns a universal ring longitude (clockwise in 0 to 360 domain).
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
These projections are used to map triaxial and irregular-shaped bodies.