1#include "MosaicSceneWidget.h"
6#include <QGraphicsSceneContextMenuEvent>
27#include "GraphicsView.h"
32#include "MosaicAreaTool.h"
33#include "MosaicControlNetTool.h"
34#include "MosaicFindTool.h"
35#include "MosaicGraphicsScene.h"
36#include "MosaicGraphicsView.h"
37#include "MosaicGridTool.h"
38#include "MosaicPanTool.h"
39#include "MosaicSceneItem.h"
40#include "MosaicSelectTool.h"
41#include "MosaicTrackTool.h"
42#include "MosaicZoomTool.h"
43#include "MoveDownOneSceneWorkOrder.h"
44#include "MoveToBottomSceneWorkOrder.h"
45#include "MoveToTopSceneWorkOrder.h"
46#include "MoveUpOneSceneWorkOrder.h"
47#include "ProgressBar.h"
49#include "Projection.h"
50#include "ProjectionConfigDialog.h"
51#include "ProjectionFactory.h"
64 bool internalizeToolBarsAndProgress,
Directory *directory,
66 m_projectImageZOrders = NULL;
67 m_projectViewTransform = NULL;
68 m_directory = directory;
70 m_mosaicSceneItems =
new QList<MosaicSceneItem *>;
86 m_quickMapAction = NULL;
88 m_cubesSelectable =
true;
89 m_customRubberBandEnabled =
false;
90 m_customRubberBand = NULL;
91 m_rubberBandOrigin = NULL;
93 m_blockingSelectionChanged =
false;
94 m_queuedSelectionChanged =
false;
95 m_shouldRequeueSelectionChanged =
false;
97 m_userToolControl =
false;
98 m_ownProjection =
false;
101 m_progress->setVisible(
false);
103 QGridLayout * sceneLayout =
new QGridLayout;
104 sceneLayout->setContentsMargins(0, 0, 0, 0);
105 setLayout(sceneLayout);
108 if (!status && internalizeToolBarsAndProgress)
109 status =
new QStatusBar;
112 m_tools =
new QList<MosaicTool *>;
117 m_tools->append(cnetTool);
121 connect(cnetTool, SIGNAL(modifyControlPoint(
ControlPoint *)),
124 connect(cnetTool, SIGNAL(deleteControlPoint(
ControlPoint *)),
127 connect(cnetTool, SIGNAL(createControlPoint(
double,
double)),
128 this, SIGNAL(createControlPoint(
double,
double)));
131 connect(
this, SIGNAL(cnetModified()), cnetTool, SLOT(rebuildPointGraphics()));
139 m_tools->at(0)->activate(
true);
143 if (internalizeToolBarsAndProgress) {
158 QHBoxLayout *horizontalToolBarsLayout =
new QHBoxLayout;
160 m_permToolbar =
new QToolBar(
"Standard Tools");
161 m_permToolbar->setWhatsThis(
"This area contains options that are always present in the "
163 horizontalToolBarsLayout->addWidget(m_permToolbar);
165 m_activeToolbar =
new QToolBar(
"Active Tool",
this);
166 m_activeToolbar->setObjectName(
"Active Tool");
167 m_activeToolbar->setWhatsThis(
"The currently selected tool's options will "
168 "show up here. Not all tools have options.");
169 horizontalToolBarsLayout->addWidget(m_activeToolbar);
171 sceneLayout->addLayout(horizontalToolBarsLayout, 0, 0, 1, 2);
175 m_toolpad =
new ToolPad(
"Tool Pad",
this);
176 m_toolpad->setObjectName(
"Tool Pad");
177 m_toolpad->setOrientation(Qt::Vertical);
178 m_toolpad->setFloatable(
true);
179 sceneLayout->addWidget(m_toolpad, 1, 1, 1, 1);
181 QHBoxLayout *horizontalStatusLayout =
new QHBoxLayout;
182 horizontalStatusLayout->addWidget(m_progress);
183 horizontalStatusLayout->addStretch();
184 horizontalStatusLayout->addWidget(status);
186 sceneLayout->addLayout(horizontalStatusLayout, 2, 0, 1, 2);
188 addToPermanent(m_permToolbar);
189 m_permToolbar->addSeparator();
191 addTo(m_activeToolbar);
198 m_userToolControl =
true;
200 setWhatsThis(
"This is the mosaic scene. The opened cubes will be "
201 "shown here. You can fully interact with the files shown here.");
203 getView()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
204 getView()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
206 getView()->enableResizeZooming(
false);
208 connect(getView()->horizontalScrollBar(), SIGNAL(valueChanged(
int)),
209 this, SLOT(sendVisibleRectChanged()));
210 connect(getView()->verticalScrollBar() , SIGNAL(valueChanged(
int)),
211 this, SLOT(sendVisibleRectChanged()));
212 connect(getView()->horizontalScrollBar(), SIGNAL(rangeChanged(
int,
int)),
213 this, SLOT(sendVisibleRectChanged()));
214 connect(getView()->verticalScrollBar() , SIGNAL(rangeChanged(
int,
int)),
215 this, SLOT(sendVisibleRectChanged()));
221 getView()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
222 getView()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
224 setWhatsThis(
"This is the mosaic world view. The opened cubes will be "
225 "shown here, but you cannot zoom in. You can select cubes by dragging "
226 "a box over them, zoom to a particular cube by right clicking on it "
227 "and selecting 'Zoom Fit', and many other actions are available.");
232 m_currentMinimumFootprintZ = 0;
233 m_currentMaximumFootprintZ = 0;
235 connect(getScene(), SIGNAL(selectionChanged()),
236 this, SLOT(onSelectionChanged()));
239 connect(
this, SIGNAL(queueSelectionChanged()),
240 this, SLOT(onQueuedSelectionChanged()), Qt::QueuedConnection);
243 MosaicSceneWidget::~MosaicSceneWidget() {
244 m_outlineRect = NULL;
261 delete m_projectImageZOrders;
262 m_projectImageZOrders = NULL;
264 delete m_projectViewTransform;
265 m_projectViewTransform = NULL;
273 if (!mapping.hasKeyword(
"EquatorialRadius")) {
275 tmp.findGroup(
"Mapping") += radii[
"EquatorialRadius"];
276 tmp.findGroup(
"Mapping") += radii[
"PolarRadius"];
280 m_ownProjection =
true;
291 PvlKeyword projectionKeyword = mapping.findKeyword(
"ProjectionName");
292 QString projName = projectionKeyword[0];
293 m_mapButton->setText(tr(
"View/Edit %1 Projection").arg(projName));
302 if (old && m_ownProjection) {
307 m_ownProjection =
false;
312 void MosaicSceneWidget::setOutlineRect(QRectF outline) {
313 if (outline.united(getView()->sceneRect()) != getView()->sceneRect())
316 if (!m_outlineRect) {
317 m_outlineRect = getScene()->addRect(outline,
320 m_outlineRect->setZValue(DBL_MAX);
323 m_outlineRect->setRect(outline);
326 if (!m_userToolControl)
331 PvlGroup MosaicSceneWidget::createInitialProjection(
333 Projection *proj = NULL;
334 Cube *cube = image->cube();
335 Pvl *label = cube->label();
339 return proj->Mapping();
341 catch (IException &) {
342 Pvl mappingPvl(
"$ISISROOT/appdata/templates/maps/equirectangular.map");
343 PvlGroup &mappingGrp = mappingPvl.findGroup(
"Mapping");
344 mappingGrp += PvlKeyword(
"LatitudeType",
"Planetocentric");
345 mappingGrp += PvlKeyword(
"LongitudeDirection",
"PositiveEast");
346 mappingGrp += PvlKeyword(
"LongitudeDomain",
"360");
347 mappingGrp += PvlKeyword(
"CenterLatitude",
"0");
348 mappingGrp += PvlKeyword(
"CenterLongitude",
"180");
349 mappingGrp += PvlKeyword(
"MinimumLatitude",
"-90");
350 mappingGrp += PvlKeyword(
"MaximumLatitude",
"90");
351 mappingGrp += PvlKeyword(
"MinimumLongitude",
"0");
352 mappingGrp += PvlKeyword(
"MaximumLongitude",
"360");
355 Camera * cam = cube->camera();
359 mappingGrp += PvlKeyword(
"TargetName", cam->target()->name());
360 mappingGrp += PvlKeyword(
"EquatorialRadius",
toString(radii[0].meters()),
362 mappingGrp += PvlKeyword(
"PolarRadius",
toString(radii[2].meters()),
366 catch (IException &) {
376 void MosaicSceneWidget::addToPermanent(
QToolBar *perm) {
377 m_mapButton =
new QToolButton(
this);
378 connect(
this, SIGNAL(destroyed()), m_mapButton, SLOT(deleteLater()));
379 m_mapButton->setText(tr(
"View/Edit/Load Map File"));
380 m_mapButton->setToolTip(tr(
"View/Edit/Load Map File"));
381 m_mapButton->setIcon(QIcon(FileName(
"$ISISROOT/appdata/images/icons/ographic.png").expanded()));
382 m_mapButton->setWhatsThis(tr(
"This is the projection used by the mosaic "
383 "scene. Cubes can not be shown in the scene without a projection, so "
384 "if one is not selected, a default of Equirectangular will be used. "
385 "The selected file should be a map file, examples are available in "
386 "$ISISROOT/appdata/templates/maps."));
387 m_mapButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
391 PvlKeyword projectionKeyword =
393 QString projName = projectionKeyword[0];
394 m_mapButton->setText(projName);
397 m_quickMapAction =
new QAction(tr(
"Quick Load Map"),
this);
398 m_quickMapAction->setToolTip(tr(
"Quick Load Map"));
399 m_quickMapAction->setIcon(QIcon(FileName(
"$ISISROOT/appdata/images/icons/quickopen.png").expanded()));
400 m_quickMapAction->setWhatsThis(tr(
"This is the projection used by the mosaic "
401 "scene. Cubes can not be shown in the scene without a projection, so "
402 "if one is not selected, a default of Equirectangular will be used."));
403 connect(m_quickMapAction, SIGNAL(triggered()),
this, SLOT(quickConfigProjectionParameters()));
405 perm->addWidget(m_mapButton);
406 perm->addAction(m_quickMapAction);
410 void MosaicSceneWidget::addTo(
QToolBar *toolbar) {
412 foreach(tool, *m_tools) {
413 tool->addTo(toolbar);
418 void MosaicSceneWidget::addTo(
QMenu *menu) {
420 foreach(tool, *m_tools) {
426 void MosaicSceneWidget::addTo(ToolPad *toolPad) {
428 foreach(tool, *m_tools) {
429 tool->addTo(toolPad);
441 bool handled =
false;
442 QList<QGraphicsItem *> selectedGraphicsItems = getScene()->selectedItems();
443 QList<MosaicSceneItem *> selectedImageItems;
445 foreach (
QGraphicsItem *graphicsItem, selectedGraphicsItems) {
448 if (!sceneImageItem) {
449 sceneImageItem =
dynamic_cast<MosaicSceneItem *
>(graphicsItem->parentItem());
452 if (sceneImageItem && sceneImageItem->image()) {
453 selectedImageItems.append(sceneImageItem);
458 if (selectedImageItems.count()) {
462 title->setEnabled(
false);
470 displayActs.append(NULL);
475 foreach(displayAct, displayActs) {
476 if (displayAct == NULL) {
480 menu.addAction(displayAct);
485 menu.exec(event->screenPos());
493 void MosaicSceneWidget::enableRubberBand(
bool enable) {
494 m_customRubberBandEnabled = enable;
498 MosaicSceneItem *MosaicSceneWidget::cubeToMosaic(Image *image) {
500 QString msg = tr(
"Can not find a NULL image in the mosaic");
504 return cubeToMosaic(image->displayProperties());
508 bool MosaicSceneWidget::blockSelectionChange(
bool block) {
509 bool wasBlocking = m_blockingSelectionChanged;
511 m_blockingSelectionChanged = block;
522 PvlObject MosaicSceneWidget::toPvl()
const {
523 PvlObject output(
"MosaicScene");
529 dataBuffer.open(QIODevice::ReadWrite);
530 QDataStream transformStream(&dataBuffer);
531 transformStream << getView()->transform();
534 PvlObject mosaicScenePosition(
"SceneVisiblePosition");
535 mosaicScenePosition += PvlKeyword(
"ViewTransform",
536 QString(dataBuffer.data().toHex()));
537 PvlKeyword scrollPos(
"ScrollPosition");
538 scrollPos +=
toString(getView()->horizontalScrollBar()->value());
539 scrollPos +=
toString(getView()->verticalScrollBar()->value());
540 mosaicScenePosition += scrollPos;
542 output += mosaicScenePosition;
545 foreach(tool, *m_tools) {
546 if (tool->projectPvlObjectName() !=
"") {
547 PvlObject toolObj = tool->toPvl();
548 toolObj.setName(tool->projectPvlObjectName());
553 PvlObject zOrders(
"ZOrdering");
554 foreach(MosaicSceneItem * mosaicSceneItem, *m_mosaicSceneItems) {
555 PvlKeyword zValue(
"ZValue");
556 zValue += mosaicSceneItem->image()->id();
557 zValue +=
toString(mosaicSceneItem->zValue());
565 "Cannot save a scene without a projection to a project file",
583 foreach(tool, *m_tools) {
584 if (tool->projectPvlObjectName() !=
"") {
585 if (project.
hasObject(tool->projectPvlObjectName())) {
587 project.
findObject(tool->projectPvlObjectName()));
588 tool->fromPvl(toolSettings);
595 delete m_projectImageZOrders;
596 m_projectImageZOrders = NULL;
597 m_projectImageZOrders =
new QHash<QString, double>;
599 for (
int zOrderIndex = 0;
600 zOrderIndex < zOrders.keywords();
602 const PvlKeyword &zOrder = zOrders[zOrderIndex];
604 (*m_projectImageZOrders)[zOrder[0]] =
toDouble(zOrder[1]);
608 if (project.
hasObject(
"SceneVisiblePosition")) {
612 delete m_projectViewTransform;
613 m_projectViewTransform =
new PvlObject(positionInfo);
619 void MosaicSceneWidget::save(QXmlStreamWriter &stream,
Project *,
FileName )
const {
621 stream.writeStartElement(
"mosaicScene");
623 stream.writeStartElement(
"projection");
625 std::stringstream strStream;
626 strStream << mapping;
627 stream.writeCharacters(strStream.str().c_str());
628 stream.writeEndElement();
630 stream.writeStartElement(
"images");
632 stream.writeStartElement(
"image");
633 stream.writeAttribute(
"id", mosaicSceneItem->image()->id());
634 stream.writeAttribute(
"zValue",
toString(mosaicSceneItem->zValue()));
635 stream.writeEndElement();
637 stream.writeEndElement();
639 stream.writeStartElement(
"viewTransform");
640 stream.writeAttribute(
"scrollBarXValue",
toString(getView()->horizontalScrollBar()->value()));
641 stream.writeAttribute(
"scrollBarYValue",
toString(getView()->verticalScrollBar()->value()));
643 dataBuffer.open(QIODevice::ReadWrite);
644 QDataStream transformStream(&dataBuffer);
645 transformStream << getView()->transform();
647 stream.writeCharacters(dataBuffer.data().toHex());
648 stream.writeEndElement();
650 foreach(MosaicTool *tool, *m_tools) {
651 QString projectPvlObjectName = tool->projectPvlObjectName();
652 if (projectPvlObjectName !=
"") {
653 PvlObject toolObj = tool->toPvl();
654 toolObj.setName(projectPvlObjectName);
656 stream.writeStartElement(
"toolData");
657 stream.writeAttribute(
"objectName", projectPvlObjectName);
658 std::stringstream strStream;
659 strStream << toolObj;
660 stream.writeCharacters(strStream.str().c_str());
661 stream.writeEndElement();
665 stream.writeEndElement();
670 QRectF MosaicSceneWidget::cubesBoundingRect()
const {
673 MosaicSceneItem * mosaicItem;
674 foreach(mosaicItem, *m_mosaicSceneItems) {
675 if (boundingRect.isEmpty())
676 boundingRect = mosaicItem->boundingRect();
678 boundingRect = boundingRect.united(mosaicItem->boundingRect());
682 boundingRect = boundingRect.united(m_outlineRect->boundingRect());
688 MosaicSceneItem *MosaicSceneWidget::cubeToMosaic(DisplayProperties *props) {
690 QString msg = tr(
"Can not find a NULL Display Properties in the mosaic");
694 return m_displayPropsToMosaicSceneItemMap[props];
701 MosaicSceneItem *mosaicSceneItem;
702 foreach(mosaicSceneItem, *m_mosaicSceneItems) {
703 if (mosaicSceneItem->image())
704 cubes.append(mosaicSceneItem->image()->fileName());
711 Directory *MosaicSceneWidget::directory()
const {
716 ImageList MosaicSceneWidget::images() {
719 MosaicSceneItem *mosaicSceneItem;
720 foreach(mosaicSceneItem, *m_mosaicSceneItems) {
721 if (mosaicSceneItem->image())
722 images.
append(mosaicSceneItem->image());
736 QList<QGraphicsItem *> selectedGraphicsItems = getScene()->selectedItems();
737 QList<MosaicSceneItem *> selectedImageItems;
740 foreach (
QGraphicsItem *graphicsItem, selectedGraphicsItems) {
743 if (!sceneImageItem) {
744 sceneImageItem =
dynamic_cast<MosaicSceneItem *
>(graphicsItem->parentItem());
747 if (sceneImageItem && sceneImageItem->image()) {
748 selectedImageItems.append(sceneImageItem);
771 QList<QAction *> MosaicSceneWidget::getExportActions() {
772 QList<QAction *> exportActs;
779 saveList->setText(
"Save Entire Cube List (ordered by &view)...");
780 connect(saveList, SIGNAL(triggered()),
this, SLOT(saveList()));
783 exportActs.append(saveList);
789 QList<QAction *> MosaicSceneWidget::getViewActions() {
790 QList<QAction *> viewActs;
792 foreach(MosaicTool *tool, *m_tools) {
793 QList<QAction *> toolViewActs = tool->getViewActions();
794 viewActs.append(toolViewActs);
805 QList<QAction *> results;
806 bool allImagesInView = !images->isEmpty();
808 foreach (
Image *image, *images) {
809 allImagesInView = allImagesInView && (cubeToMosaic(image) != NULL);
812 if (allImagesInView) {
815 moveToTopAct->setData(images);
816 results.append(moveToTopAct);
820 moveUpOneAct->setData(images);
821 results.append(moveUpOneAct);
825 moveToBottomAct->setData(images);
826 results.append(moveToBottomAct);
830 moveDownOneAct->setData(images);
831 results.append(moveDownOneAct);
833 results.append(NULL);
836 zoomFitAct->setData(QVariant::fromValue(images));
837 connect(zoomFitAct, SIGNAL(triggered()),
this, SLOT(fitInView()));
838 results.append(zoomFitAct);
844 bool MosaicSceneWidget::isControlNetToolActive() {
849 if (cnTool->isActive())
return true;
856 QWidget * MosaicSceneWidget::getControlNetHelp(
QWidget *cnetToolContainer) {
857 QScrollArea *cnetHelpWidgetScrollArea =
new QScrollArea;
861 QVBoxLayout *cnetHelpLayout =
new QVBoxLayout;
862 cnetHelpWidget->setLayout(cnetHelpLayout);
864 QLabel *title =
new QLabel(
"<h2>Control Networks</h2>");
865 cnetHelpLayout->addWidget(title);
867 QPixmap previewPixmap;
869 if (cnetToolContainer) {
870 previewPixmap = cnetToolContainer->grab().scaled(
871 QSize(500, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation);
874 ToolPad tmpToolPad(
"Example Tool Pad", NULL);
875 MosaicControlNetTool tmpTool(NULL);
876 tmpTool.addTo(&tmpToolPad);
878 tmpToolPad.resize(QSize(32, 32));
880 previewPixmap = tmpToolPad.grab();
883 QLabel *previewWrapper =
new QLabel;
884 previewWrapper->setPixmap(previewPixmap);
885 cnetHelpLayout->addWidget(previewWrapper);
887 QLabel *overview =
new QLabel(
"The mosaic scene can display control points "
888 "in addition to the usual cube footprints. This feature is currently "
889 "offered as one of the Mosaic Scene's tools. To open a network, click "
890 "on the control network tool. It will immediately prompt you for a "
891 "control network file if one is not open. Only control points for "
892 "which the latitude and longitude can be established will be "
893 "displayed. Other control points will be ignored by qmos.<br><br>"
894 "<b>Warning: Opening large control networks is slow.</b>"
895 "<h3>Control Network Tool Options</h3>"
897 "<li>The control network tool opens control networks in two ways. "
898 "First, if you select the control network tool and no network is "
899 "open, then it will prompt you for one. Second, if there is an open "
900 "network, the buttons for the available options are displayed in the "
901 "active tool area.</li>"
902 "<li>The control network tool can toggle whether or not control "
903 "points are displayed on the screen using the 'Display' button. "
904 "Control points are always on top and colored based on their "
905 "ignored, locked and type values.</li>"
906 "<li>This tool can also change the color of your footprints based on "
907 "connectivity through control points. This is available through the "
908 "'Color Islands' button. When you press color islands, all of the "
909 "current cube coloring information is lost and re-done based on "
910 "how the control network connects the files. Each set of connected "
911 "cubes are colored differently; generally speaking, islands are not "
912 "a good thing to have in your control network.</li>"
913 "<li>This tool will color your footprints on a per-image basis if you "
914 "click color images, effectively reversing color islands.</li>"
915 "<li>The show movement option under 'Configure Movement Display' "
916 "only displays data when the control "
917 "network has adjusted values. This means that show movement only "
918 "works after you have done a jigsaw solution on the control network. "
919 "This displays arrows emanating from the apriori latitude/longitude "
920 "and pointing toward the adjusted latitude/longitude.</li>");
921 overview->setWordWrap(
true);
922 cnetHelpLayout->addWidget(overview);
924 cnetHelpWidgetScrollArea->setWidget(cnetHelpWidget);
926 return cnetHelpWidgetScrollArea;
930 QWidget * MosaicSceneWidget::getGridHelp(
QWidget *gridToolContainer) {
931 QScrollArea *gridHelpWidgetScrollArea =
new QScrollArea;
935 QVBoxLayout *gridHelpLayout =
new QVBoxLayout;
936 gridHelpWidget->setLayout(gridHelpLayout);
938 QLabel *title =
new QLabel(
"<h2>Map Grid Tool</h2>");
939 gridHelpLayout->addWidget(title);
941 QPixmap previewPixmap;
943 if (gridToolContainer) {
944 previewPixmap = gridToolContainer->grab().scaled(
945 QSize(500, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation);
948 ToolPad tmpToolPad(
"Example Tool Pad", NULL);
949 MosaicGridTool tmpTool(NULL);
950 tmpTool.addTo(&tmpToolPad);
952 tmpToolPad.resize(QSize(32, 32));
954 previewPixmap = tmpToolPad.grab();
957 QLabel *previewWrapper =
new QLabel;
958 previewWrapper->setPixmap(previewPixmap);
959 gridHelpLayout->addWidget(previewWrapper);
961 QLabel *overview =
new QLabel(
"Superimpose a map grid over the area of "
962 "displayed footprints in the 'mosaic scene.'"
965 "<li>The Map Grid Tool is activated by selecting the 'cross-hatch' "
966 "icon or typing 'g' at the keyboard."
968 "<li>The parameter options are displayed below the menubar. "
969 "Clicking the 'Grid Options' button will open the dialog. Checking "
970 "'Auto Grid' will draw a grid based on the open cubes. Hitting "
971 "'Show Grid' will display or hide the grid."
973 "<li>The map grid is defined by the loaded Map File (just as the "
974 "footprints and image data are), the opened cubes, or the grid "
977 "<li>If a Map File has not been selected, the default "
978 "Equirectangular projection will be used. The resulting grid "
979 "lines in the default 'Equi' map file will be drawn for the "
980 "full global range (latitude range = -90,90; longitude range = "
981 "0,360) at the default latitude and longitude increment values."
984 "If the grid lines are not immediately visible, try to "
985 "'zoom out' in the 'mosaic scene' window and modify the "
986 "Latitude and Longitude Increment parameters."
989 "<strong>Options:</strong>"
991 "<li>The 'Show Grid' option draws (checked) or clears (unchecked) the grid."
993 "<li>The 'Auto Grid' option draws a grid with extents and increments "
994 "computed from the set of images that are opened. The values displayed in the dialog "
995 "will reflect those used to draw the grid."
997 "<li>The expected units for each entry are displayed to the right of the "
1000 "<li>The 'Extent Type' combo boxes allow you to pick the source of the "
1001 "grid extents from the map file, from the open cubes <default>, or manually "
1004 "<li>The 'Auto Apply' checkbox, inside the 'Grid Options' dialog box, allows you to see "
1005 "real time updates in the grid when you change the parameters."
1007 "<li> Depending on the projection, the grid may not behave as expected. For instance, "
1008 "with a polarstereographic projection, the pole will not be included in the 'Auto "
1009 "Grid' if it is not in the cube region. In this case the 'Manual' option for latitude "
1010 "extents allows you to force the grid to the pole."
1013 overview->setWordWrap(
true);
1014 gridHelpLayout->addWidget(overview);
1016 gridHelpWidgetScrollArea->setWidget(gridHelpWidget);
1018 return gridHelpWidgetScrollArea;
1022 QWidget * MosaicSceneWidget::getLongHelp(
QWidget *sceneContainer) {
1023 QScrollArea *longHelpWidgetScrollArea =
new QScrollArea;
1027 QVBoxLayout *longHelpLayout =
new QVBoxLayout;
1028 longHelpWidget->setLayout(longHelpLayout);
1030 QLabel *title =
new QLabel(
"<h2>Mosaic Scene</h2>");
1031 longHelpLayout->addWidget(title);
1033 if (sceneContainer) {
1034 QPixmap previewPixmap = sceneContainer->grab().scaled(
1035 QSize(500, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation);
1037 QLabel *previewWrapper =
new QLabel;
1038 previewWrapper->setPixmap(previewPixmap);
1039 longHelpLayout->addWidget(previewWrapper);
1042 QLabel *overview =
new QLabel(
"The mosaic scene displays cube footprints "
1043 "to show where files are on a target and how they overlap. "
1044 "The scene always represents projected image space and cannot show raw "
1045 "or unprojected images; images will be projected on the fly."
1047 "<p>Interact with the mosaic scene in different ways using "
1048 "the tools. The tools are usually in a toolbar next to the scene. "
1049 "The tools define what is displayed and what happens when you "
1050 "click in the mosaic scene. The tools include</p>"
1051 "<ul><li>Select Tool</li>"
1052 "<li>Zoom Tool</li>"
1054 "<li>Control Network Tool</li>"
1055 "<li>Show Area Tool</li>"
1056 "<li>Find Tool</li>"
1057 "<li>Grid Tool</li></ul>"
1058 "<h3>Context Menus</h3>"
1059 "Right click on anything in the mosaic scene and a context menu will pop up showing "
1060 "a list of actions or information relevant to the item you clicked on. "
1061 "<p>Note: The context menu is not associated with any selection, only the item "
1063 overview->setWordWrap(
true);
1064 longHelpLayout->addWidget(overview);
1066 longHelpWidgetScrollArea->setWidget(longHelpWidget);
1068 return longHelpWidgetScrollArea;
1073 QScrollArea *mapHelpWidgetScrollArea =
new QScrollArea;
1077 QVBoxLayout *mapHelpLayout =
new QVBoxLayout;
1078 mapHelpWidget->setLayout(mapHelpLayout);
1080 QLabel *title =
new QLabel(tr(
"<h2>Map File</h2>"));
1081 mapHelpLayout->addWidget(title);
1084 QPixmap previewPixmap = mapContainer->grab().scaled(
1085 QSize(500, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation);
1087 QLabel *previewWrapper =
new QLabel;
1088 previewWrapper->setPixmap(previewPixmap);
1089 mapHelpLayout->addWidget(previewWrapper);
1092 QLabel *overviewMapIcon =
new QLabel;
1094 overviewMapIcon->setPixmap(
1095 QIcon(FileName(
"$ISISROOT/appdata/images/icons/ographic.png").expanded()).pixmap(32, 32));
1096 mapHelpLayout->addWidget(overviewMapIcon);
1098 QLabel *defaultMapFile =
new QLabel(tr(
1099 "<h3>Default Map File</h3>"
1100 "The mosaic scene's projection is defined by a \"Map File\" that consists of keywords "
1101 "that describe the map layout to be used. If a cube or a list of cubes are "
1102 "loaded before a map file is selected, the default map file defines the "
1103 "equirectangular projection, planetocentric latitude, positive longitude east, 360 "
1104 "longitude domain, latitude range=90S-90N, longitude range=0-360E. The radius will "
1105 "default to the IAU standards (ellipsoid or sphere) for the specific planetary body "
1106 "defined for the \"TargetName\" in the labels of the image cube(s)."));
1108 defaultMapFile->setWordWrap(
true);
1109 mapHelpLayout->addWidget(defaultMapFile);
1111 QLabel *userDefinedMapFileOverview =
new QLabel(tr(
1112 "<h3>User Defined Map File</h3>"
1113 "You can load an existing \"Map File\" before loading images into %1 by selecting the "
1114 "\"View/Edit/Load Map File\" option. You will be greeted with a dialog box that will "
1115 "enable you to select an existing map file by clicking on \"Load Map File.\" Once "
1116 "the map file is selected, the contents is displayed in the dialog box where "
1117 "modifications can be made as well. If the modified map file is to be used later, "
1118 "save the map file by clicking on \"Save Map File\" button.")
1119 .arg(QCoreApplication::applicationName()));
1121 userDefinedMapFileOverview->setWordWrap(
true);
1122 mapHelpLayout->addWidget(userDefinedMapFileOverview);
1124 QLabel *userDefinedMapFileQuickLoad =
new QLabel(tr(
1125 "The \"Quick Load Map\" option (lightning icon) allows you to efficiently select a "
1126 "prepared \"Map File\" without an immediate need to view or edit the contents."));
1128 userDefinedMapFileQuickLoad->setWordWrap(
true);
1129 mapHelpLayout->addWidget(userDefinedMapFileQuickLoad);
1131 QLabel *userDefinedMapFileAnyTime =
new QLabel(tr(
1132 "At any point, you have access to the \"View/Edit\" functionality to modify or load a "
1133 "different map file."));
1135 userDefinedMapFileAnyTime->setWordWrap(
true);
1136 mapHelpLayout->addWidget(userDefinedMapFileAnyTime);
1138 QString mapProjWorkshopUrl(
"https://github.com/USGS-Astrogeology/ISIS3/wiki/Learning_About_Map_Projections");
1139 QLabel *preparingMapFile =
new QLabel(tr(
1140 "<h3>Preparing a Map File</h3>"
1141 "Please refer to Isis applications such as 'maptemplate' or 'mosrange' for more details "
1142 "on creating a custom map file that defines the desired projection, latitude "
1143 "system, and longitude direction and domain. This program will use the latitude range "
1144 "and longitude range if they exist in the loaded file. A choice of map templates that can be used as "
1145 "a starting point for supported map projections can be found in $ISISROOT/appdata/templates/maps (refer "
1146 "to maptemplate or mosrange for more details and information on the required parameters "
1147 "for a projection). The website: "
1148 "<a href='%1'>%1</a> also provides useful information about map projections.")
1149 .arg(mapProjWorkshopUrl));
1151 preparingMapFile->setOpenExternalLinks(
true);
1152 preparingMapFile->setWordWrap(
true);
1153 mapHelpLayout->addWidget(preparingMapFile);
1155 QLabel *mapFileDisplayResults =
new QLabel(tr(
1156 "<h3>Display Results with the Map File</h3>"
1157 "The footprints and image data that are displayed in the mosaic scene are defined by the "
1158 "loaded \"Map File\" regardless of whether the opened cubes are Level1 (raw "
1159 "camera space) or Level2 (map projected). The associated footprint polygons for "
1160 "Level2 cubes will be re-mapped as needed based on the loaded map file."));
1162 mapFileDisplayResults->setWordWrap(
true);
1163 mapHelpLayout->addWidget(mapFileDisplayResults);
1165 QLabel *editingMapFileOverview =
new QLabel(tr(
1166 "<h3>Editing a Map File</h3>"
1167 "Editing a map file is possible through the dialog box displayed by clicking on the "
1168 "'View/Edit/Load Map File' icon/button. The edits are "
1169 "applied to the current session and will be included with a 'Saved Project' (refer to "
1170 "the help under File-Save Project or Save Project as)."));
1172 editingMapFileOverview->setWordWrap(
true);
1173 mapHelpLayout->addWidget(editingMapFileOverview);
1175 QLabel *saveMapFileToDiskBullet =
new QLabel(tr(
1178 "To save or write the changes to a map file on disk, choose 'Save Map File' button. "
1179 "Map files can be saved to an existing map file (overwrites) or to a new file. This "
1180 "program always saves <strong>exactly</strong> what you see, the text, in the dialog "
1185 saveMapFileToDiskBullet->setWordWrap(
true);
1186 mapHelpLayout->addWidget(saveMapFileToDiskBullet);
1188 QLabel *mapFileValidityBullet =
new QLabel(tr(
1191 "As you modify the contents of a loaded map file in the dialog box, the entry is "
1192 "verified as you type with a bold black indicator message displaying whether the "
1193 "text is valid or is not valid. If you want to see the actual error messages, "
1194 "select the 'Show Errors' box and the errors will be displayed in red font "
1195 "along with the black bolded message. The errors will update "
1200 mapFileValidityBullet->setWordWrap(
true);
1201 mapHelpLayout->addWidget(mapFileValidityBullet);
1203 QLabel *mapFileCommentsBullet =
new QLabel(tr(
1206 "Map files may contain 'commented-out' lines (text that starts with \"#\" at "
1207 "the beginning of the line). These are referred to as \"unnecessary\""
1208 "or \"unknown\" keywords, they are simply ignored. If these lines are to be saved to "
1209 "the output map file on disk, click 'Save Map File' BEFORE clicking 'Ok' or 'Apply.' "
1210 "The comments are removed from the dialog box when you hit 'Ok' or 'Apply,' if they "
1211 "are just above \"End_Group\" or follow \"End_Group\" or \"End\".<br/><br/>"
1213 "If you want these comments retained, make sure they are immediately above a valid "
1214 "keyword inside of \"Group = Mapping.\" Note that any lines (commented or not) will "
1215 "not be saved if they are placed outside of \"Group = Mapping\" and \"End_Group\"."
1219 mapFileCommentsBullet->setWordWrap(
true);
1220 mapHelpLayout->addWidget(mapFileCommentsBullet);
1222 mapHelpWidgetScrollArea->setWidget(mapHelpWidget);
1224 return mapHelpWidgetScrollArea;
1228 QWidget * MosaicSceneWidget::getPreviewHelp(
QWidget *worldViewContainer) {
1229 QScrollArea *previewHelpWidgetScrollArea =
new QScrollArea;
1233 QVBoxLayout *previewHelpLayout =
new QVBoxLayout;
1234 previewHelpWidget->setLayout(previewHelpLayout);
1236 QLabel *title =
new QLabel(
"<h2>Mosaic World View</h2>");
1237 previewHelpLayout->addWidget(title);
1239 if (worldViewContainer) {
1240 QPixmap previewPixmap = worldViewContainer->grab().scaled(
1241 QSize(500, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation);
1243 QLabel *previewWrapper =
new QLabel;
1244 previewWrapper->setPixmap(previewPixmap);
1245 previewHelpLayout->addWidget(previewWrapper);
1248 QLabel *overview =
new QLabel(
"The mosaic world view displays cube "
1249 "footprints to show you where your files are on a target and their "
1250 "general arrangement. The world view does not have tools like "
1251 "mosaic scenes, but otherwise they are very similar.");
1252 overview->setWordWrap(
true);
1253 previewHelpLayout->addWidget(overview);
1255 previewHelpWidgetScrollArea->setWidget(previewHelpWidget);
1257 return previewHelpWidgetScrollArea;
1261 MosaicSceneItem *MosaicSceneWidget::addImage(Image *image) {
1263 setProjection(createInitialProjection(image), *image->cube()->label());
1266 MosaicSceneItem *mosItem = NULL;
1269 if (!cubeToMosaic(image)) {
1270 mosItem =
new MosaicSceneItem(image,
this);
1272 connect(mosItem, SIGNAL(changed(
const QList<QRectF> &)),
1274 connect(mosItem, SIGNAL(mosaicCubeClosed(Image *)),
1275 this, SIGNAL(mosCubeClosed(Image *)));
1279 if (m_projectImageZOrders && m_projectImageZOrders->contains(image->id())) {
1280 double zOrder = m_projectImageZOrders->value(image->id());
1281 m_projectImageZOrders->remove(image->id());
1283 foreach (MosaicSceneItem *mosaicItem, *m_mosaicSceneItems) {
1284 if (mosaicItem->zValue() == zOrder) {
1285 mosaicItem->setZValue(maximumZ() + 1);
1286 m_currentMaximumFootprintZ = maximumZ() + 1;
1290 m_currentMaximumFootprintZ = qMax(zOrder, maximumZ());
1291 mosItem->setZValue(zOrder);
1294 mosItem->setZValue(maximumZ() + 1);
1295 m_currentMaximumFootprintZ = maximumZ() + 1;
1298 getScene()->addItem(mosItem);
1299 m_mosaicSceneItems->append(mosItem);
1300 m_displayPropsToMosaicSceneItemMap[image->displayProperties()] = mosItem;
1302 connect(mosItem, SIGNAL(destroyed(
QObject *)),
1303 this, SLOT(removeMosItem(
QObject *)));
1305 ImageDisplayProperties *prop = image->displayProperties();
1306 connect(prop, SIGNAL(moveDownOne()),
1307 this, SLOT(moveDownOne()));
1310 connect(prop, SIGNAL(moveUpOne()),
1311 this, SLOT(moveUpOne()));
1314 connect(prop, SIGNAL(zoomFit()),
1315 this, SLOT(fitInView()));
1322 double MosaicSceneWidget::maximumZ() {
1323 return m_currentMaximumFootprintZ;
1327 double MosaicSceneWidget::minimumZ() {
1328 return m_currentMinimumFootprintZ;
1331 void MosaicSceneWidget::recalcSceneRect() {
1333 double minX, minY, maxX, maxY;
1336 QRectF projRect(minX, -maxY, maxX - minX, maxY - minY);
1337 QRectF cubesBounding = cubesBoundingRect();
1339 QRectF bounding = projRect.united(cubesBounding);
1341 if (m_outlineRect && m_outlineRect->isVisible())
1342 bounding = bounding.united(m_outlineRect->boundingRect());
1344 getView()->setSceneRect(bounding);
1348 void MosaicSceneWidget::addImages(ImageList images) {
1349 if (m_userToolControl)
1350 m_progress->
setText(
"Loading primary scene");
1352 m_progress->
setText(
"Loading secondary scene");
1354 m_progress->setRange(0, images.size() - 1);
1355 m_progress->setValue(0);
1356 m_progress->setVisible(
true);
1358 foreach(Image *image, images) {
1362 catch (IException &e) {
1366 m_progress->setValue(m_progress->value() + 1);
1371 if (m_projectViewTransform) {
1372 PvlObject &positionInfo = *m_projectViewTransform;
1373 QByteArray hexValues(positionInfo[
"ViewTransform"][0].toLatin1());
1374 QDataStream transformStream(QByteArray::fromHex(hexValues));
1376 QTransform viewTransform;
1377 transformStream >> viewTransform;
1378 getView()->setTransform(viewTransform);
1380 QPoint projectScrollPos(
toInt(positionInfo[
"ScrollPosition"][0]),
1381 toInt(positionInfo[
"ScrollPosition"][1]));
1383 getView()->horizontalScrollBar()->setValue(projectScrollPos.x());
1384 getView()->verticalScrollBar()->setValue(projectScrollPos.y());
1390 if (!m_projectImageZOrders || m_projectImageZOrders->isEmpty()) {
1391 delete m_projectViewTransform;
1392 m_projectViewTransform = NULL;
1395 m_progress->setVisible(
false);
1396 emit cubesChanged();
1400 void MosaicSceneWidget::removeImages(ImageList images) {
1403 foreach(Image *image, images) {
1405 MosaicSceneItem *item = cubeToMosaic(image);
1406 item->deleteLater();
1407 removeMosItem(item);
1409 catch (IException &e) {
1421 QFileDialog::getSaveFileName((
QWidget *)parent(),
1422 "Choose output file",
1423 QDir::currentPath() +
"/untitled.png",
1424 QString(
"Images (*.png *.jpg *.tif)"));
1425 if (output.isEmpty())
return;
1428 if (QFileInfo(output).suffix().isEmpty()) {
1429 output = output +
".png";
1432 QString format = QFileInfo(output).suffix();
1433 QPixmap pm = getScene()->views().last()->grab();
1435 std::string formatString = format.toStdString();
1436 if (!pm.save(output, formatString.c_str())) {
1437 QMessageBox::information(
this,
"Error",
1438 "Unable to save [" + output +
"]");
1443 void MosaicSceneWidget::saveList() {
1445 QFileDialog::getSaveFileName((
QWidget *)parent(),
1446 "Choose output file",
1447 QDir::currentPath() +
"/files.lis",
1448 QString(
"List File (*.lis);;Text File (*.txt);;All Files (*.*)"));
1449 if (output.isEmpty())
return;
1451 TextFile file(output,
"overwrite");
1453 QList<MosaicSceneItem *> sorted = *m_mosaicSceneItems;
1454 std::sort(sorted.begin(), sorted.end(), zOrderGreaterThan);
1457 foreach(sceneItem, sorted) {
1458 file.PutLine( sceneItem->image()->fileName() );
1463 void MosaicSceneWidget::removeMosItem(
QObject *mosItem) {
1464 MosaicSceneItem *castedMosItem = (MosaicSceneItem *) mosItem;
1465 m_mosaicSceneItems->removeAll(castedMosItem);
1466 m_displayPropsToMosaicSceneItemMap.remove(
1467 m_displayPropsToMosaicSceneItemMap.key(castedMosItem));
1469 emit cubesChanged();
1478 QRectF sceneRect = cubesBoundingRect();
1480 if (sceneRect.isEmpty())
1483 double xPadding = sceneRect.width() * 0.10;
1484 double yPadding = sceneRect.height() * 0.10;
1486 sceneRect.adjust(-xPadding, -yPadding, xPadding, yPadding);
1487 getView()->fitInView(sceneRect, Qt::KeepAspectRatio);
1491 void MosaicSceneWidget::setCubesSelectable(
bool selectable) {
1492 if (m_cubesSelectable != selectable) {
1493 m_cubesSelectable = selectable;
1496 foreach(mosaicSceneItem, *m_mosaicSceneItems) {
1497 mosaicSceneItem->scenePropertiesChanged();
1509 configDialog.exec();
1513 void MosaicSceneWidget::quickConfigProjectionParameters() {
1515 configDialog.setQuickConfig(
true);
1516 configDialog.exec();
1520 void MosaicSceneWidget::sendVisibleRectChanged() {
1521 QPointF topLeft = getView()->mapToScene(0, 0);
1522 QPointF bottomRight = getView()->mapToScene(
1523 (
int)getView()->width(),
1524 (
int)getView()->height());
1526 QRectF visibleRect(topLeft, bottomRight);
1527 emit visibleRectChanged(visibleRect);
1531 bool MosaicSceneWidget::eventFilter(
QObject *obj, QEvent *event) {
1532 bool stopProcessingEvent =
true;
1534 switch(event->type()) {
1535 case QMouseEvent::GraphicsSceneMousePress: {
1536 if (m_customRubberBandEnabled) {
1538 if (!m_customRubberBand) {
1539 m_customRubberBand =
new QRubberBand(QRubberBand::Rectangle,
1543 if (!m_rubberBandOrigin) {
1544 m_rubberBandOrigin =
new QPoint;
1547 *m_rubberBandOrigin = getView()->mapFromScene(
1548 ((QGraphicsSceneMouseEvent *)event)->scenePos());
1549 m_customRubberBand->setGeometry(QRect(*m_rubberBandOrigin, QSize()));
1550 m_customRubberBand->show();
1553 emit mouseButtonPress(
1554 ((QGraphicsSceneMouseEvent *)event)->scenePos(),
1555 ((QGraphicsSceneMouseEvent *)event)->button());
1556 stopProcessingEvent =
false;
1560 case QMouseEvent::GraphicsSceneMouseRelease: {
1561 bool signalEmitted =
false;
1562 if (m_customRubberBandEnabled && m_rubberBandOrigin &&
1563 m_customRubberBand) {
1564 if (m_customRubberBand->geometry().width() +
1565 m_customRubberBand->geometry().height() > 10) {
1566 emit rubberBandComplete(
1567 getView()->mapToScene(
1568 m_customRubberBand->geometry()).boundingRect(),
1569 ((QGraphicsSceneMouseEvent *)event)->button());
1570 signalEmitted =
true;
1573 delete m_rubberBandOrigin;
1574 m_rubberBandOrigin = NULL;
1576 delete m_customRubberBand;
1577 m_customRubberBand = NULL;
1580 if (!signalEmitted) {
1581 stopProcessingEvent =
false;
1582 emit mouseButtonRelease(
1583 ((QGraphicsSceneMouseEvent *)event)->scenePos(),
1584 ((QGraphicsSceneMouseEvent *)event)->button());
1589 case QMouseEvent::GraphicsSceneMouseDoubleClick:
1590 emit mouseDoubleClick(
1591 ((QGraphicsSceneMouseEvent *)event)->scenePos());
1592 stopProcessingEvent =
false;
1595 case QMouseEvent::GraphicsSceneMouseMove:
1596 if (m_customRubberBandEnabled && m_rubberBandOrigin &&
1597 m_customRubberBand) {
1598 QPointF scenePos = ((QGraphicsSceneMouseEvent *)event)->scenePos();
1599 QPoint screenPos = getView()->mapFromScene(scenePos);
1601 QRect rubberBandRect =
1602 QRect(*m_rubberBandOrigin, screenPos).normalized();
1604 m_customRubberBand->setGeometry(rubberBandRect);
1607 stopProcessingEvent =
false;
1611 ((QGraphicsSceneMouseEvent *)event)->scenePos());
1614 case QEvent::GraphicsSceneWheel:
1616 ((QGraphicsSceneWheelEvent *)event)->scenePos(),
1617 ((QGraphicsSceneWheelEvent *)event)->delta());
1619 stopProcessingEvent =
true;
1622 case QMouseEvent::Enter:
1624 stopProcessingEvent =
false;
1627 case QMouseEvent::Leave:
1629 stopProcessingEvent =
false;
1632 case QEvent::GraphicsSceneHelp: {
1634 bool toolTipFound =
false;
1637 foreach(sceneItem, getScene()->items()) {
1638 if (!toolTipFound) {
1639 if (sceneItem->contains(
1640 ((QGraphicsSceneHelpEvent*)event)->scenePos()) &&
1641 sceneItem->toolTip().size() > 0) {
1642 setToolTip(sceneItem->toolTip());
1643 toolTipFound =
true;
1649 stopProcessingEvent =
true;
1651 ((QGraphicsSceneHelpEvent*)event)->screenPos(),
1658 stopProcessingEvent =
false;
1662 return stopProcessingEvent;
1673 if (m_mosaicSceneItems->size() == 0)
1676 if (m_userToolControl)
1677 m_progress->
setText(
"Reprojecting primary scene");
1679 m_progress->
setText(
"Reprojecting secondary scene");
1682 int reprojectsPerUpdate = qMax(1, m_mosaicSceneItems->size() / 20);
1684 m_progress->setRange(0,
1685 (m_mosaicSceneItems->size() - 1) / reprojectsPerUpdate + 1);
1686 m_progress->setValue(0);
1687 m_progress->setVisible(
true);
1691 int progressCountdown = reprojectsPerUpdate;
1692 foreach(mosaicSceneItem, *m_mosaicSceneItems) {
1697 QString msg =
"The file [";
1699 if (mosaicSceneItem->image())
1700 msg += mosaicSceneItem->image()->displayProperties()->displayName();
1702 msg +=
"] is being removed due to not being able to project onto the scene";
1706 mosaicSceneItem->image()->deleteLater();
1709 progressCountdown --;
1710 if (progressCountdown == 0) {
1711 m_progress->setValue(m_progress->value() + 1);
1712 progressCountdown = reprojectsPerUpdate;
1717 m_progress->setValue(m_progress->maximum());
1721 m_progress->setVisible(
false);
1725 void MosaicSceneWidget::moveDownOne() {
1729 moveDownOne(cubeToMosaic(props));
1736 double MosaicSceneWidget::moveDownOne(MosaicSceneItem *item) {
1737 MosaicSceneItem *nextDown =
getNextItem(item,
false);
1738 double originalZ = item->zValue();
1741 double newZValue = nextDown->zValue() - 1;
1742 moveZ(item, newZValue,
true);
1751 double MosaicSceneWidget::moveDownOne(Image *image) {
1752 return moveDownOne(cubeToMosaic(image));
1758 QList<double> MosaicSceneWidget::moveDownOne(ImageList *images) {
1759 QList<double> results;
1761 foreach (Image *image, *images) {
1762 results.append(moveDownOne(image));
1769 void MosaicSceneWidget::moveToBottom() {
1770 DisplayProperties *props = qobject_cast<DisplayProperties *>(sender());
1782 double originalZ = item->zValue();
1783 double minZ = minimumZ();
1785 if (originalZ != minZ) {
1787 int newZValue = qRound(minZ - 1);
1788 item->setZValue(newZValue);
1791 m_currentMinimumFootprintZ--;
1802 double MosaicSceneWidget::moveToBottom(
Image *image) {
1811 QList<double> MosaicSceneWidget::moveToBottom(
ImageList *images) {
1812 QList<double> results;
1814 foreach (
Image *image, *images) {
1822 void MosaicSceneWidget::moveUpOne() {
1826 moveUpOne(cubeToMosaic(props));
1833 double MosaicSceneWidget::moveUpOne(MosaicSceneItem *item) {
1834 MosaicSceneItem *nextUp =
getNextItem(item,
true);
1835 double originalZ = item->zValue();
1838 double newZValue = nextUp->zValue() + 1;
1839 moveZ(item, newZValue,
true);
1848 double MosaicSceneWidget::moveUpOne(Image *image) {
1849 return moveUpOne(cubeToMosaic(image));
1855 QList<double> MosaicSceneWidget::moveUpOne(ImageList *images) {
1856 QList<double> results;
1858 foreach (Image *image, *images) {
1859 results.append(moveUpOne(image));
1866 void MosaicSceneWidget::moveToTop() {
1867 DisplayProperties *props = qobject_cast<DisplayProperties *>(sender());
1880 double originalZ = item->zValue();
1881 double maxZ = maximumZ();
1883 if (originalZ != maxZ) {
1885 int newZValue = qRound(maxZ + 1);
1886 item->setZValue(newZValue);
1889 m_currentMaximumFootprintZ++;
1910 double MosaicSceneWidget::moveToTop(
Image *image) {
1919 QList<double> MosaicSceneWidget::moveToTop(
ImageList *images) {
1920 QList<double> results;
1922 foreach (
Image *image, *images) {
1948 bool newZValueMightExist) {
1949 double originalZ = sceneItem->zValue();
1951 if (newZValueMightExist) {
1953 m_currentMinimumFootprintZ = 0.0;
1954 m_currentMaximumFootprintZ = 0.0;
1957 double otherItemOrigZ = otherItem->zValue();
1958 double otherItemNewZ = otherItemOrigZ;
1961 if (originalZ > newZ && otherItemOrigZ >= newZ && otherItemOrigZ < originalZ) {
1962 otherItemNewZ = otherItemOrigZ + 1;
1965 else if (originalZ < newZ && otherItemOrigZ <= newZ && otherItemOrigZ > originalZ) {
1966 otherItemNewZ = otherItemOrigZ - 1;
1969 m_currentMinimumFootprintZ = qMin(m_currentMinimumFootprintZ, otherItemNewZ);
1970 m_currentMaximumFootprintZ = qMax(m_currentMaximumFootprintZ, otherItemNewZ);
1971 otherItem->setZValue(otherItemNewZ);
1975 sceneItem->setZValue(newZ);
1977 if (!newZValueMightExist) {
1979 if (originalZ == maximumZ() && newZ < originalZ) {
1980 m_currentMaximumFootprintZ--;
1982 else if (originalZ == minimumZ() && newZ > originalZ) {
1983 m_currentMinimumFootprintZ++;
1992 bool newZValueMightExist) {
1993 return moveZ(cubeToMosaic(image), newZ, newZValueMightExist);
1997 void MosaicSceneWidget::fitInView() {
1998 if (m_userToolControl) {
2001 DisplayProperties *props = qobject_cast<DisplayProperties *>(sender());
2004 MosaicSceneItem *item = cubeToMosaic(props);
2005 boundingBox = item->boundingRect();
2008 QAction *action = qobject_cast<QAction *>(sender());
2011 ImageList *images = action->data().value<ImageList *>();
2013 foreach (Image *image, *images) {
2014 boundingBox = boundingBox.united(cubeToMosaic(image)->boundingRect());
2019 if (!boundingBox.isNull()) {
2020 double xPadding = boundingBox.width() * 0.10;
2021 double yPadding = boundingBox.height() * 0.10;
2023 boundingBox.setLeft(boundingBox.left() - xPadding);
2024 boundingBox.setRight(boundingBox.right() + xPadding);
2026 boundingBox.setTop(boundingBox.top() - yPadding);
2027 boundingBox.setBottom(boundingBox.bottom() + yPadding);
2029 getView()->fitInView(boundingBox, Qt::KeepAspectRatio);
2030 getView()->centerOn(boundingBox.center());
2036 void MosaicSceneWidget::onSelectionChanged() {
2037 if (!m_blockingSelectionChanged) {
2038 if (!m_queuedSelectionChanged) {
2039 emit queueSelectionChanged();
2040 m_queuedSelectionChanged =
true;
2043 m_shouldRequeueSelectionChanged =
true;
2049 void MosaicSceneWidget::onQueuedSelectionChanged() {
2050 m_queuedSelectionChanged =
false;
2052 if (m_shouldRequeueSelectionChanged) {
2053 m_shouldRequeueSelectionChanged =
false;
2054 onSelectionChanged();
2057 foreach(MosaicSceneItem *mosaicSceneItem, *m_mosaicSceneItems) {
2058 mosaicSceneItem->updateSelection(
true);
2069 foreach(mosaicSceneItem, *m_mosaicSceneItems) {
2070 if (mosaicSceneItem != item &&
2071 mosaicSceneItem->boundingRect().intersects(item->boundingRect())) {
2073 if ( (up && mosaicSceneItem->zValue() > item->zValue()) ||
2074 (!up && mosaicSceneItem->zValue() < item->zValue())) {
2077 if (!nextZValueItem) {
2078 nextZValueItem = mosaicSceneItem;
2083 if ((up && mosaicSceneItem->zValue() < nextZValueItem->zValue()) ||
2084 (!up && mosaicSceneItem->zValue() > nextZValueItem->zValue())) {
2085 nextZValueItem = mosaicSceneItem;
2092 return nextZValueItem;
2098 return first->zValue() > second->zValue();
QList< QAction * > supportedActions(DataType data)
Returns a list of supported actions for a WorkOrder.
Project * project() const
Gets the Project for this directory.
File name manipulation and expansion.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
@ Programmer
This error is for when a programmer made an API call that was illegal.
This represents a cube in a project-based GUI interface.
Internalizes a list of images and allows for operations on the entire list.
void append(Image *const &value)
Appends an image to the image list.
QList< QAction * > supportedActions(Project *project=NULL)
Gets a list of pre-connected actions that have to do with display.
A graphics scene with improved user-interaction for use with the MosaicSceneWidget.
A graphics view that resizes in a more friendly way.
A single cube in the mosaic scene.
void reproject()
Called anytime the user reprojects the cube.
Move images, one by one, below the immediately-below intersecting image in a scene This workorder is ...
Move images below all other images in a mosaic scene This workorder is synchronous and undoable.
Move images on top of all other images in a mosaic scene This workorder is synchronous and undoable.
Move images, one by one, on top of the immediately-above intersecting image in a scene This workorder...
void setText(QString text)
Set custom text for this progress bar.
The main project for ipce.
This is the configuration dialog for the MosaicSceneWidget's projection parameters (map file).
static Isis::Projection * CreateFromCube(Isis::Cube &cube)
This method is a helper method.
static Isis::Projection * Create(Isis::Pvl &label, bool allowDefaults=false)
This method returns a pointer to a Projection object.
Base class for Map Projections.
Contains multiple PvlContainers.
A single keyword-value pair.
Contains Pvl Groups and Pvl Objects.
bool hasObject(const QString &name) const
Returns a boolean value based on whether the object exists in the current PvlObject or not.
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
@ Traverse
Search child objects.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
static PvlGroup radiiGroup(QString target)
Creates a Pvl Group with keywords TargetName, EquitorialRadius, and PolarRadius.
Provides access to sequential ASCII stream I/O.
This is free and unencumbered software released into the public domain.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
int toInt(const QString &string)
Global function to convert from a string to an integer.
double toDouble(const QString &string)
Global function to convert from a string to a double.