diff --git a/CHANGELOG.md b/CHANGELOG.md index 56573dff836027e3e7f75df657deab5b358cf454..4f7eccafde6b87eec5bfb4e128d352af8a6c5630 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ release. ### Changed ### Added +- Added LatLonGrid Tool to Qview to view latitude and longitude lines if camera model information is present. ### Deprecated diff --git a/isis/src/qisis/apps/qview/main.cpp b/isis/src/qisis/apps/qview/main.cpp index d5ae89c77fef10121c7374896d876e81a8b5b49b..69f06fe013e070d47fb29fee2c50d51db97fd28f 100644 --- a/isis/src/qisis/apps/qview/main.cpp +++ b/isis/src/qisis/apps/qview/main.cpp @@ -23,6 +23,7 @@ find files of those names at the top level of this repository. **/ #include "BandTool.h" #include "BlinkTool.h" #include "EditTool.h" +#include "LatLonGridTool.h" #include "FeatureNomenclatureTool.h" #include "FileName.h" #include "FileTool.h" @@ -173,6 +174,8 @@ int main(int argc, char *argv[]) { Tool *editTool = createTool(vw, &tools); + Tool *latLonGridTool = createTool(vw, &tools); + Tool *windowTool = createTool(vw, &tools); Tool *measureTool = createTool(vw, &tools); @@ -274,6 +277,7 @@ int main(int argc, char *argv[]) { delete statsTool; delete helpTool; delete matchTool; + delete latLonGridTool; delete stereoTool; delete histTool; delete spatialPlotTool; diff --git a/isis/src/qisis/apps/qview/qview.xml b/isis/src/qisis/apps/qview/qview.xml index 13c151f9e35c373730c9d5c60e9ce570802c7a9d..623f89940daadcdd30eb0223c25196f9cff63681 100644 --- a/isis/src/qisis/apps/qview/qview.xml +++ b/isis/src/qisis/apps/qview/qview.xml @@ -266,5 +266,8 @@ Included documentation for Spatial Plot Tool in this .xml. References #5281. + + Added latitude and longtitude grid display. + diff --git a/isis/src/qisis/objs/LatLonGridTool/LatLonGridTool.cpp b/isis/src/qisis/objs/LatLonGridTool/LatLonGridTool.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5219a2addefd23dd404cbc419f3c978ae9d4e495 --- /dev/null +++ b/isis/src/qisis/objs/LatLonGridTool/LatLonGridTool.cpp @@ -0,0 +1,152 @@ +/** This is free and unencumbered software released into the public domain. + +The authors of ISIS do not claim copyright on the contents of this file. +For more details about the LICENSE terms and the AUTHORS, you will +find files of those names at the top level of this repository. **/ + +/* SPDX-License-Identifier: CC0-1.0 */ + +#include "LatLonGridTool.h" + +#include +#include +#include +#include +#include +#include + +#include "MdiCubeViewport.h" +#include "ToolPad.h" +#include "Camera.h" + + +namespace Isis { + /** + * Constructs an LatLonGridTool object. + * + * @param parent Parent widget + */ + LatLonGridTool::LatLonGridTool(QWidget *parent) : Tool(parent) { + } + + /** + * Adds the LatLonGridTool to the tool pad. + * + * @param pad input - The tool pad that LatLonGridTool is to be added to + * + * @return QAction* + */ + QAction *LatLonGridTool::toolPadAction(ToolPad *pad) { + QAction *action = new QAction(pad); + action->setIcon(QPixmap(toolIconDir() + "/grid.png")); + action->setToolTip("Lat Lon Grid Tool (G)"); + action->setShortcut(Qt::Key_G); + + QString text = + "Function: View lat lon grid \ +

Shortcut: G

"; + action->setWhatsThis(text); + + return action; + } + + /** + * Creates the toolbar containing the lat-lon grid tool widgets + * + * @param active input The widget that will contain the lat-lon grid tool + * specific widgets + * + * @return QWidget* + */ + QWidget *LatLonGridTool::createToolBarWidget(QStackedWidget *active) { + QWidget *container = new QWidget(active); + container->setObjectName("LatLonGridToolActiveToolBarWidget"); + + m_gridCheckBox = new QCheckBox; + m_gridCheckBox->setText("Show Grid"); + + QHBoxLayout *layout = new QHBoxLayout; + layout->setMargin(0); + layout->addWidget(m_gridCheckBox); + layout->addStretch(1); + container->setLayout(layout); + + m_container = container; + return container; + } + + /** + * Draws grid onto cube viewport + * This is overiding the parents paintViewport member. + * + * @param vp Pointer to Viewport to be painted + * @param painter + */ + void LatLonGridTool::paintViewport(MdiCubeViewport *mvp, QPainter *painter) { + int x1, x2, y1, y2; + double lat, lon; + + QFont font; + QBrush brush(Qt::gray); + QPen pen(brush, 1); + + // Only draws if "Show Grid" checkbox is checked + if (m_gridCheckBox->isChecked()) { + painter->setPen(pen); + font.setPixelSize(8); + painter->setFont(font); + + // Draws Longitude Lines + for (int i = mvp->cubeSamples(); i > 0; i -= mvp->cubeSamples() / 12) { + if (mvp->camera() != NULL) { + mvp->camera()->SetImage(i, 0); + lon = mvp->camera()->UniversalLongitude(); + + lon = ceil(lon * 100.0) / 100.0; + + mvp->cubeToViewport(i, 0, x1, y1); + mvp->cubeToViewport(0, mvp->cubeLines(), x2, y2); + painter->drawLine(x1, y1, x1, y2); + + painter->drawText(x1, y2 + 10, toString(lon)); + } + } + + // Draws Latitude Lines + for (int i = mvp->cubeLines(); i > 0; i -= mvp->cubeLines() / 12) { + if (mvp->camera() != NULL) { + mvp->camera()->SetImage(0, i); + lat = mvp->camera()->UniversalLatitude(); + + lat = ceil(lat * 100.0) / 100.0; + + mvp->cubeToViewport(0, i, x1, y1); + mvp->cubeToViewport(mvp->cubeSamples(), 0, x2, y2); + painter->drawLine(x1, y1, x2, y1); + + painter->drawText(x2 + 5, y1, toString(lat)); + } + } + } + // remove grid by updating viewport to original cubeViewport + else { + mvp = cubeViewport(); + } + } + + /** + * Enables/Disable grid option tool based on camera model + */ + void LatLonGridTool::updateTool() { + MdiCubeViewport *vp = cubeViewport(); + + if (vp != NULL) { + if (vp->camera() == NULL) { + m_gridCheckBox->setEnabled(false); + } + else { + m_gridCheckBox->setEnabled(true); + } + } + } +} diff --git a/isis/src/qisis/objs/LatLonGridTool/LatLonGridTool.h b/isis/src/qisis/objs/LatLonGridTool/LatLonGridTool.h new file mode 100644 index 0000000000000000000000000000000000000000..ad1cbefe035af71438c29dcbf83f96ff1533cf0b --- /dev/null +++ b/isis/src/qisis/objs/LatLonGridTool/LatLonGridTool.h @@ -0,0 +1,56 @@ +#ifndef LatLonGridTool_h +#define LatLonGridTool_h + +/** This is free and unencumbered software released into the public domain. + +The authors of ISIS do not claim copyright on the contents of this file. +For more details about the LICENSE terms and the AUTHORS, you will +find files of those names at the top level of this repository. **/ + +/* SPDX-License-Identifier: CC0-1.0 */ + +#include "Tool.h" + + +#include +#include +#include + + +class QToolButton; +class QPainter; +class QCheckBox; + +namespace Isis { + class MdiCubeViewport; + + + /** + * @brief Lat Lon Grid View Tool + * + * This tool is part of the Qisis namespace and allows visualizes latitude and + * longitude lines on cube. + * + * @ingroup Visualization Tools + * + * @author 2022-08-08 Amy Stamile + */ + class LatLonGridTool : public Tool { + Q_OBJECT + + public: + LatLonGridTool(QWidget *parent); + void paintViewport(MdiCubeViewport *mvp, QPainter *painter); + + protected: + QAction *toolPadAction(ToolPad *pad); + QWidget *createToolBarWidget(QStackedWidget *active); + void updateTool(); + + private: + QWidget *m_container; + QPointer m_gridCheckBox; + }; +}; + +#endif diff --git a/isis/src/qisis/objs/LatLonGridTool/Makefile b/isis/src/qisis/objs/LatLonGridTool/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..f122bc88227c5c7ebd108dea5d339d1d2e074d82 --- /dev/null +++ b/isis/src/qisis/objs/LatLonGridTool/Makefile @@ -0,0 +1,7 @@ +ifeq ($(ISISROOT), $(BLANK)) +.SILENT: +error: + echo "Please set ISISROOT"; +else + include $(ISISROOT)/make/isismake.objs +endif \ No newline at end of file