1 #include "MosaicGridTool.h" 3 #include <QApplication> 6 #include <QDoubleValidator> 7 #include <QGraphicsScene> 12 #include <QMessageBox> 14 #include <QPushButton> 20 #include "GridGraphicsItem.h" 24 #include "MosaicGraphicsView.h" 25 #include "MosaicGridToolConfigDialog.h" 28 #include "MosaicSceneWidget.h" 142 if (getWidget()->getProjection()) {
161 if (getWidget()->getProjection()) {
304 Projection *proj = getWidget()->getProjection();
313 QRectF boundingRect = getWidget()->cubesBoundingRect();
315 double topLeft = 100;
316 double topRight = 100;
317 double bottomLeft = 100;
318 double bottomRight = 100;
319 bool cubeRectWorked =
true;
329 if (tproj->
SetCoordinate(boundingRect.topLeft().x(), -boundingRect.topLeft().y())) {
333 cubeRectWorked =
false;
335 if (tproj->
SetCoordinate(boundingRect.topRight().x(), -boundingRect.topRight().y())) {
339 cubeRectWorked =
false;
341 if (tproj->
SetCoordinate(boundingRect.bottomLeft().x(), -boundingRect.bottomLeft().y())) {
345 cubeRectWorked =
false;
348 -boundingRect.bottomRight().y())) {
352 cubeRectWorked =
false;
355 if (cubeRectWorked) {
357 std::min(bottomLeft, bottomRight)), mappingGroup,
360 std::max(bottomLeft, bottomRight)), mappingGroup,
364 boundingRect.contains(QPointF(tproj->
XCoord(), -tproj->
YCoord()))) {
369 boundingRect.contains(QPointF(tproj->
XCoord(), -tproj->
YCoord()))) {
378 static Projection *lastProjWithThisError = NULL;
380 if (proj != lastProjWithThisError) {
381 lastProjWithThisError = proj;
382 QMessageBox::warning(NULL, tr(
"Latitude Extent Failure"),
383 tr(
"<p/>Could not extract latitude extents from the cubes.<br/>" 384 "<br/>The option <strong>\"Compute From Images\"</strong> " 385 "will default to using the <strong>Manual</strong> option " 386 "for latitude extents with a range of -90 to 90."));
428 Projection *proj = getWidget()->getProjection();
431 QRectF boundingRect = getWidget()->cubesBoundingRect();
435 double bottomLeft = 0;
436 double bottomRight = 0;
437 bool cubeRectWorked =
true;
447 if (tproj->
SetCoordinate(boundingRect.topLeft().x(), -boundingRect.topLeft().y())) {
451 cubeRectWorked =
false;
453 if (tproj->
SetCoordinate(boundingRect.topRight().x(), -boundingRect.topRight().y())) {
457 cubeRectWorked =
false;
459 if (tproj->
SetCoordinate(boundingRect.bottomLeft().x(), -boundingRect.bottomLeft().y())) {
463 cubeRectWorked =
false;
466 -boundingRect.bottomRight().y())) {
470 cubeRectWorked =
false;
473 if (cubeRectWorked) {
475 std::min(bottomLeft, bottomRight)),
478 std::max(bottomLeft, bottomRight)),
498 static Projection *lastProjWithThisError = NULL;
500 if (proj != lastProjWithThisError) {
501 lastProjWithThisError = proj;
502 QMessageBox::warning(NULL, tr(
"Longitude Extent Failure"),
503 tr(
"<p/>Could not extract longitude extents from the cubes.<br/>" 504 "<br/>The option <strong>\"Compute From Images\"</strong> " 505 "will default to using the <strong>Manual</strong> option " 506 "for longitude extents with a range of 0 to 360."));
556 Projection *proj = getWidget()->getProjection();
565 if (obj[
"BaseLatitude"][0] !=
"Null")
569 if (obj[
"BaseLongitude"][0] !=
"Null")
572 if (obj[
"LatitudeIncrement"][0] !=
"Null")
575 if (obj[
"LongitudeIncrement"][0] !=
"Null")
579 if (obj[
"LatitudeExtentType"][0] !=
"Null")
584 if (obj[
"MinimumLatitude"][0] !=
"Null")
590 if (obj[
"MaximumLatitude"][0] !=
"Null")
596 if (obj[
"LongitudeExtentType"][0] !=
"Null")
601 if (obj[
"MinimumLongitude"][0] !=
"Null")
606 if (obj[
"MaximumLongitude"][0] !=
"Null")
610 if (obj[
"Density"][0] !=
"Null")
615 if (obj[
"CheckTheBoxes"][0] !=
"Null") {
620 if(
toBool(obj[
"Visible"][0])) {
633 return "MosaicGridTool";
668 Longitude MosaicGridTool::domainMinLon() {
671 if (getWidget() && getWidget()->getProjection()) {
686 Longitude MosaicGridTool::domainMaxLon() {
689 if (getWidget() && getWidget()->getProjection()) {
691 TProjection *tproj = (TProjection *) getWidget()->getProjection();
692 if (tproj->Has360Domain()) {
713 FileName(QString(
"$HOME/.Isis/%1/mosaicSceneGridTool.config")
714 .arg(QApplication::applicationName())).expanded(),
715 QSettings::NativeFormat);
716 settings.setValue(
"autoGrid", draw);
718 Projection *proj = getWidget()->getProjection();
721 QRectF boundingRect = getWidget()->cubesBoundingRect();
723 if (!boundingRect.isNull()) {
730 if (tproj->
Mapping()[
"LatitudeType"][0] ==
"Planetographic") {
753 double latOffsetMultiplier = pow(10, qFloor(log10(latRange) - 1));
754 double lonOffsetMultiplier = pow(10, qFloor(log10(lonRange) - 1));
756 double idealLatInc = latRange / 10.0;
757 double idealLonInc = lonRange / 10.0;
759 double roundedLatInc = qRound(idealLatInc / latOffsetMultiplier) * latOffsetMultiplier ;
760 double roundedLonInc = qRound(idealLonInc / lonOffsetMultiplier) * lonOffsetMultiplier ;
777 if(m_gridItem != NULL) {
778 disconnect(getWidget(), SIGNAL(projectionChanged(
Projection *)),
781 getWidget()->getScene()->removeItem(m_gridItem);
795 qobject_cast<QWidget *>(parent()));
796 configDialog->setAttribute(Qt::WA_DeleteOnClose);
797 configDialog->show();
807 if(m_gridItem != NULL) {
817 if (!getWidget()->getProjection()) {
818 QString msg =
"Please set the mosaic scene's projection before trying to " 819 "draw a grid. This means either open a cube (a projection " 820 "will be calculated) or set the projection explicitly";
821 QMessageBox::warning(NULL, tr(
"Grid Tool Requires Projection"), msg);
829 connect(getWidget(), SIGNAL(projectionChanged(
Projection *)),
830 this, SLOT(
drawGrid()), Qt::UniqueConnection);
832 connect(getWidget(), SIGNAL(cubesChanged()),
835 if (m_gridItem != NULL)
836 getWidget()->getScene()->addItem(m_gridItem);
868 emit boundingRectChanged();
872 getWidget()->getView()->update();
873 QApplication::processEvents();
887 FileName(QString(
"$HOME/.Isis/%1/mosaicSceneGridTool.config")
888 .arg(QApplication::applicationName())).expanded(),
889 QSettings::NativeFormat);
891 bool drawAuto = settings.value(
"autoGrid",
true).toBool();
931 m_action->setIcon(
getIcon(
"grid.png"));
932 m_action->setToolTip(
"Grid (g)");
933 m_action->setShortcut(Qt::Key_G);
935 "<b>Function:</b> Superimpose a map grid over the area of displayed " 936 "footprints in the 'mosaic scene.'<br><br>" 937 "This tool allows you to overlay a ground grid onto the mosaic scene. " 938 "The inputs are standard ground grid parameters and a grid density." 939 "<p><b>Shortcut:</b> g</p> ";
940 m_action->setWhatsThis(text);
954 QHBoxLayout *actionLayout =
new QHBoxLayout();
956 QString autoGridWhatsThis =
957 "Draws a grid based on the current lat/lon extents (from the cubes, map, or user).";
967 QPushButton *optionsButton =
new QPushButton(
"Grid Options");
968 optionsButton->setWhatsThis(
"Opens a dialog box that has the options to change the base" 969 " latitude, base longitude, latitude increment, longitude" 970 " increment, and grid density.");
971 connect(optionsButton, SIGNAL(clicked()),
this, SLOT(
configure()));
972 actionLayout->addWidget(optionsButton);
974 QString drawGridWhatsThis =
975 "Draws a grid based on the current lat/lon extents (from the cubes, map, or user).";
976 QLabel *drawGridLabel =
new QLabel(
"Show Grid");
977 drawGridLabel->setWhatsThis(drawGridWhatsThis);
981 actionLayout->addWidget(drawGridLabel);
984 connect(
this, SIGNAL(activated(
bool)),
this, SLOT(
onToolOpen(
bool)));
986 actionLayout->addStretch(1);
987 actionLayout->setMargin(0);
990 toolBarWidget->setLayout(actionLayout);
992 return toolBarWidget;
double EquatorialRadius() const
This returns the equatorial radius of the target.
double MaximumLongitude() const
This returns the maximum longitude of the area of interest.
double planetographic(Angle::Units units=Angle::Radians) const
Get the latitude in the planetographic coordinate system.
bool SetUniversalGround(const double lat, const double lon)
This method is used to set the latitude/longitude which must be Planetocentric (latitude) and Positiv...
File name manipulation and expansion.
ProjectionType projectionType() const
Returns an enum value for the projection type.
Base class for Map TProjections.
QString LatitudeTypeString() const
This method returns the latitude type as a string.
int toInt(const QString &string)
Global function to convert from a string to an integer.
This class is designed to encapsulate the concept of a Latitude.
double XCoord() const
This returns the projection X provided SetGround, SetCoordinate, SetUniversalGround, or SetWorld returned with success.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
double toDouble(const QString &string)
Global function to convert from a string to a double.
Distance measurement, usually in meters.
double degrees() const
Get the angle in units of Degrees.
double MinimumLongitude() const
This returns the minimum longitude of the area of interest.
bool hasKeyword(const QString &kname, FindOptions opts) const
See if a keyword is in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within ...
This is the universal (and default) latitude coordinate system.
This class is designed to encapsulate the concept of a Longitude.
Base class for Map Projections.
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
The visual display of the find point.
double Longitude() const
This returns a longitude with correct longitude direction and domain as specified in the label object...
Contains multiple PvlContainers.
A single keyword-value pair.
double YCoord() const
This returns the projection Y provided SetGround, SetCoordinate, SetUniversalGround, or SetWorld returned with success.
bool Has360Domain() const
This indicates if the longitude domain is 0 to 360 (as opposed to -180 to 180).
double MinimumLatitude() const
This returns the minimum latitude of the area of interest.
virtual PvlGroup Mapping()
This function returns the keywords that this projection uses.
Defines an angle and provides unit conversions.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
virtual bool SetCoordinate(const double x, const double y)
This method is used to set the projection x/y.
double PolarRadius() const
This returns the polar radius of the target.
bool toBool(const QString &string)
Global function to convert from a string to a boolean.
double Latitude() const
This returns a latitude with correct latitude type as specified in the label object.
Namespace for ISIS/Bullet specific routines.
The distance is being specified in meters.
QString LongitudeDomainString() const
This method returns the longitude domain as a string.
Contains Pvl Groups and Pvl Objects.
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.
double MaximumLatitude() const
This returns the maximum latitude of the area of interest.