Skip to content

Commit

Permalink
Fix for QMOS not updating lat/lon ranges correctly. (DOI-USGS#3714)
Browse files Browse the repository at this point in the history
* qqqqqqmoooooosssssss

* added doc string
  • Loading branch information
Kelvin Rodriguez authored and jessemapel committed Mar 4, 2020
1 parent 1a32f81 commit 5bc047a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
14 changes: 8 additions & 6 deletions isis/src/qisis/objs/MosaicSceneWidget/GridGraphicsItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ namespace Isis {
lonMin = lonMax;
lonMax = temp;
}

if (mappingGroup["LatitudeType"][0] == "Planetographic") {

Distance equaRad(tproj->EquatorialRadius(), Distance::Meters);
Expand Down Expand Up @@ -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)) {
Expand All @@ -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,
Expand All @@ -143,7 +143,7 @@ namespace Isis {
startLon = Longitude(
baseLon - Angle(floor((baseLon - minLon) / lonInc) * lonInc));
}

Longitude endLon =
(long)((maxLon - startLon) / lonInc) * lonInc + startLon;

Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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));
Expand Down
37 changes: 34 additions & 3 deletions isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}


Expand Down Expand Up @@ -445,6 +449,7 @@ namespace Isis {

case Cubes:
if (tproj->SetCoordinate(boundingRect.topLeft().x(), -boundingRect.topLeft().y())) {

topLeft = tproj->Longitude();
}
else {
Expand Down Expand Up @@ -796,6 +801,30 @@ 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();

// 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);
}


/**
Expand All @@ -813,27 +842,29 @@ 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 "
"will be calculated) or set the projection explicitly";
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);

}


Expand Down
3 changes: 2 additions & 1 deletion isis/src/qisis/objs/MosaicSceneWidget/MosaicGridTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ namespace Isis {
void drawGrid(bool draw);
void onCubesChanged();
void onToolOpen(bool check);

void onProjectionChanged();

protected:
QWidget *createToolBarWidget();
QAction *getPrimaryAction();
Expand Down

0 comments on commit 5bc047a

Please sign in to comment.