From 8447a83bf9134a0594e7b78715a9505e6eaa4a3d Mon Sep 17 00:00:00 2001 From: Kelvin Date: Wed, 26 Feb 2020 14:50:11 -0700 Subject: [PATCH 1/2] qqqqqqmoooooosssssss --- .../MosaicSceneWidget/GridGraphicsItem.cpp | 14 ++++---- .../objs/MosaicSceneWidget/MosaicGridTool.cpp | 32 +++++++++++++++++-- .../objs/MosaicSceneWidget/MosaicGridTool.h | 3 +- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/isis/src/qisis/objs/MosaicSceneWidget/GridGraphicsItem.cpp b/isis/src/qisis/objs/MosaicSceneWidget/GridGraphicsItem.cpp index ee898c733b..8c94d0493e 100644 --- a/isis/src/qisis/objs/MosaicSceneWidget/GridGraphicsItem.cpp +++ b/isis/src/qisis/objs/MosaicSceneWidget/GridGraphicsItem.cpp @@ -53,7 +53,6 @@ namespace Isis { lonMin = lonMax; lonMax = temp; } - if (mappingGroup["LatitudeType"][0] == "Planetographic") { Distance equaRad(tproj->EquatorialRadius(), Distance::Meters); @@ -115,6 +114,7 @@ namespace Isis { Angle::Degrees); maxLat = Latitude(latMax.degrees(), mappingGroup, Angle::Degrees); + // Make sure our lat increment is non-zero if (!qFuzzyCompare(latInc.radians(), 0.0)) { @@ -131,7 +131,7 @@ namespace Isis { if (qFuzzyCompare(endLat.degrees(), 90.0)) endLat = Latitude(90.0, mappingGroup, Angle::Degrees); } - + Longitude minLon(lonMin.degrees(), mappingGroup, Angle::Degrees); Longitude maxLon(lonMax.degrees(), mappingGroup, @@ -143,7 +143,7 @@ namespace Isis { startLon = Longitude( baseLon - Angle(floor((baseLon - minLon) / lonInc) * lonInc)); } - + Longitude endLon = (long)((maxLon - startLon) / lonInc) * lonInc + startLon; @@ -199,7 +199,7 @@ namespace Isis { double y = 0; bool valid; - + // Set ground according to lon direction to get correct X,Y values // when drawing lines. if (tproj->IsPositiveWest()) { @@ -276,7 +276,7 @@ namespace Isis { firstIteration = true; atMaxLat = false; atMaxLon = false; - + // Create the longitude grid lines for (Longitude lon = minLon; lon != maxLon + lonInc; lon += lonInc) { if (lon > endLon && lon < maxLon) { @@ -300,8 +300,10 @@ namespace Isis { // Set ground according to lon direction to get correct X,Y values // when drawing lines. bool valid; + if (tproj->IsPositiveWest()) { - valid = tproj->SetGround(lat.degrees(), lon.positiveWest(Angle::Degrees)); + double glon = tproj->Has180Domain() ? -1*lon.positiveEast(Angle::Degrees): lon.positiveWest(Angle::Degrees); + valid = tproj->SetGround(lat.degrees(), glon); } else { valid = tproj->SetGround(lat.degrees(), lon.positiveEast(Angle::Degrees)); diff --git a/isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.cpp b/isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.cpp index d93c880946..dc973afaa8 100644 --- a/isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.cpp +++ b/isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.cpp @@ -58,6 +58,10 @@ namespace Isis { m_minLon = domainMinLon(); m_maxLon = domainMaxLon(); m_density = 10000; + + connect(getWidget(), SIGNAL(projectionChanged(Projection *)), + this, SLOT(onProjectionChanged()), Qt::UniqueConnection); + } @@ -445,6 +449,7 @@ namespace Isis { case Cubes: if (tproj->SetCoordinate(boundingRect.topLeft().x(), -boundingRect.topLeft().y())) { + topLeft = tproj->Longitude(); } else { @@ -797,6 +802,25 @@ namespace Isis { configDialog->show(); } + void MosaicGridTool::onProjectionChanged() { + TProjection * tproj = (TProjection *)getWidget()->getProjection(); + + // If Projection changed from a file, force extents to come from + // the new map file + m_latExtents = Map; + m_lonExtents = Map; + + Latitude minLat = Latitude(tproj->MinimumLatitude(), Angle::Degrees); + Latitude maxLat = Latitude(tproj->MaximumLatitude(), Angle::Degrees); + + setLatExtents(m_latExtents, minLat, maxLat); + + Longitude minLon = Longitude(tproj->MinimumLongitude(), Angle::Degrees); + Longitude maxLon = Longitude(tproj->MaximumLongitude(), Angle::Degrees); + + setLonExtents(m_lonExtents, minLon, maxLon); + } + /** * Creates the GridGraphicsItem that will draw the grid. If there is no grid item the grid @@ -813,7 +837,7 @@ namespace Isis { m_drawGridCheckBox->blockSignals(true); m_drawGridCheckBox->setChecked(true); m_drawGridCheckBox->blockSignals(false); - + if (!getWidget()->getProjection()) { QString msg = "Please set the mosaic scene's projection before trying to " "draw a grid. This means either open a cube (a projection " @@ -821,19 +845,21 @@ namespace Isis { QMessageBox::warning(NULL, tr("Grid Tool Requires Projection"), msg); } + if (m_minLon.degrees() < m_maxLon.degrees() && m_minLat.degrees() < m_maxLat.degrees()) { m_gridItem = new GridGraphicsItem(m_baseLat, m_baseLon, m_latInc, m_lonInc, getWidget(), m_density, m_minLat, m_maxLat, m_minLon, m_maxLon); } - + connect(getWidget(), SIGNAL(projectionChanged(Projection *)), this, SLOT(drawGrid()), Qt::UniqueConnection); connect(getWidget(), SIGNAL(cubesChanged()), this, SLOT(onCubesChanged())); - + if (m_gridItem != NULL) getWidget()->getScene()->addItem(m_gridItem); + } diff --git a/isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.h b/isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.h index 73fbd78461..a7712caf60 100644 --- a/isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.h +++ b/isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.h @@ -122,7 +122,8 @@ namespace Isis { void drawGrid(bool draw); void onCubesChanged(); void onToolOpen(bool check); - + void onProjectionChanged(); + protected: QWidget *createToolBarWidget(); QAction *getPrimaryAction(); From cd0ddd9f78eaf3a4ede2f58a8e2c9c15d2ee48af Mon Sep 17 00:00:00 2001 From: Kelvin Date: Thu, 27 Feb 2020 09:56:41 -0700 Subject: [PATCH 2/2] added doc string --- isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.cpp b/isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.cpp index dc973afaa8..d189a5cf03 100644 --- a/isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.cpp +++ b/isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.cpp @@ -801,7 +801,12 @@ namespace Isis { configDialog->setAttribute(Qt::WA_DeleteOnClose); configDialog->show(); } - + + /* + * Updates lat/lon ranges when a new projection file is loaded. Also + * forces the lat/lon extent source to Map resetting user options in the grid tool dialog. + * + */ void MosaicGridTool::onProjectionChanged() { TProjection * tproj = (TProjection *)getWidget()->getProjection();