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;
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;
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;
288 PvlGroup mapping(proj->Mapping());
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 &) {
368 label->findGroup(
"Instrument", Pvl::Traverse)[
"TargetName"];
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;
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);
465 Project *project = m_directory ? m_directory->project() : NULL;
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");
501 throw IException(IException::Programmer, msg, _FILEINFO_);
504 return cubeToMosaic(image->displayProperties());
508 bool MosaicSceneWidget::blockSelectionChange(
bool block) {
509 bool wasBlocking = m_blockingSelectionChanged;
511 m_blockingSelectionChanged = block;
517 QProgressBar *MosaicSceneWidget::getProgress() {
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());
564 throw IException(IException::User,
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())) {
586 const PvlObject &toolSettings(
587 project.findObject(tool->projectPvlObjectName()));
588 tool->fromPvl(toolSettings);
592 if (project.hasObject(
"ZOrdering")) {
593 const PvlObject &zOrders = project.findObject(
"ZOrdering");
595 delete m_projectImageZOrders;
596 m_projectImageZOrders = NULL;
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")) {
609 const PvlObject &positionInfo =
610 project.findObject(
"SceneVisiblePosition");
612 delete m_projectViewTransform;
613 m_projectViewTransform =
new PvlObject(positionInfo);
614 m_projectViewTransform->addKeyword(project.findKeyword(
"QtVersion"));
620 void MosaicSceneWidget::save(QXmlStreamWriter &stream,
Project *, FileName )
const {
622 stream.writeStartElement(
"mosaicScene");
624 stream.writeStartElement(
"projection");
626 std::stringstream strStream;
627 strStream << mapping;
628 stream.writeCharacters(strStream.str().c_str());
629 stream.writeEndElement();
631 stream.writeStartElement(
"images");
633 stream.writeStartElement(
"image");
634 stream.writeAttribute(
"id", mosaicSceneItem->image()->
id());
635 stream.writeAttribute(
"zValue",
toString(mosaicSceneItem->zValue()));
636 stream.writeEndElement();
638 stream.writeEndElement();
640 stream.writeStartElement(
"viewTransform");
641 stream.writeAttribute(
"scrollBarXValue",
toString(getView()->horizontalScrollBar()->value()));
642 stream.writeAttribute(
"scrollBarYValue",
toString(getView()->verticalScrollBar()->value()));
644 dataBuffer.open(QIODevice::ReadWrite);
645 QDataStream transformStream(&dataBuffer);
646 transformStream << getView()->transform();
648 stream.writeCharacters(dataBuffer.data().toHex());
649 stream.writeEndElement();
651 foreach(MosaicTool *tool, *m_tools) {
652 QString projectPvlObjectName = tool->projectPvlObjectName();
653 if (projectPvlObjectName !=
"") {
654 PvlObject toolObj = tool->toPvl();
655 toolObj.setName(projectPvlObjectName);
657 stream.writeStartElement(
"toolData");
658 stream.writeAttribute(
"objectName", projectPvlObjectName);
659 std::stringstream strStream;
660 strStream << toolObj;
661 stream.writeCharacters(strStream.str().c_str());
662 stream.writeEndElement();
666 stream.writeEndElement();
671 QRectF MosaicSceneWidget::cubesBoundingRect()
const {
674 MosaicSceneItem * mosaicItem;
675 foreach(mosaicItem, *m_mosaicSceneItems) {
676 if (boundingRect.isEmpty())
677 boundingRect = mosaicItem->boundingRect();
679 boundingRect = boundingRect.united(mosaicItem->boundingRect());
683 boundingRect = boundingRect.united(m_outlineRect->boundingRect());
691 QString msg = tr(
"Can not find a NULL Display Properties in the mosaic");
692 throw IException(IException::Programmer, msg, _FILEINFO_);
695 return m_displayPropsToMosaicSceneItemMap[props];
699 QStringList MosaicSceneWidget::cubeFileNames() {
702 MosaicSceneItem *mosaicSceneItem;
703 foreach(mosaicSceneItem, *m_mosaicSceneItems) {
704 if (mosaicSceneItem->image())
705 cubes.append(mosaicSceneItem->image()->fileName());
712 Directory *MosaicSceneWidget::directory()
const {
720 MosaicSceneItem *mosaicSceneItem;
721 foreach(mosaicSceneItem, *m_mosaicSceneItems) {
722 if (mosaicSceneItem->image())
723 images.append(mosaicSceneItem->image());
741 foreach (
QGraphicsItem *graphicsItem, selectedGraphicsItems) {
744 if (!sceneImageItem) {
745 sceneImageItem =
dynamic_cast<MosaicSceneItem *
>(graphicsItem->parentItem());
748 if (sceneImageItem && sceneImageItem->image()) {
749 selectedImageItems.append(sceneImageItem);
780 saveList->setText(
"Save Entire Cube List (ordered by &view)...");
781 connect(saveList, SIGNAL(triggered()),
this, SLOT(saveList()));
784 exportActs.append(saveList);
793 foreach(MosaicTool *tool, *m_tools) {
795 viewActs.append(toolViewActs);
807 bool allImagesInView = !images->isEmpty();
809 foreach (
Image *image, *images) {
810 allImagesInView = allImagesInView && (cubeToMosaic(image) != NULL);
813 if (allImagesInView) {
817 results.append(moveToTopAct);
822 results.append(moveUpOneAct);
826 moveToBottomAct->
setData(images);
827 results.append(moveToBottomAct);
831 moveDownOneAct->
setData(images);
832 results.append(moveDownOneAct);
834 results.append(NULL);
837 zoomFitAct->setData(QVariant::fromValue(images));
838 connect(zoomFitAct, SIGNAL(triggered()),
this, SLOT(fitInView()));
839 results.append(zoomFitAct);
845 bool MosaicSceneWidget::isControlNetToolActive() {
850 if (cnTool->
isActive())
return true;
857 QWidget * MosaicSceneWidget::getControlNetHelp(QWidget *cnetToolContainer) {
858 QScrollArea *cnetHelpWidgetScrollArea =
new QScrollArea;
860 QWidget *cnetHelpWidget =
new QWidget;
862 QVBoxLayout *cnetHelpLayout =
new QVBoxLayout;
863 cnetHelpWidget->setLayout(cnetHelpLayout);
865 QLabel *title =
new QLabel(
"<h2>Control Networks</h2>");
866 cnetHelpLayout->addWidget(title);
868 QPixmap previewPixmap;
870 if (cnetToolContainer) {
871 previewPixmap = cnetToolContainer->grab().scaled(
872 QSize(500, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation);
875 ToolPad tmpToolPad(
"Example Tool Pad", NULL);
876 MosaicControlNetTool tmpTool(NULL);
877 tmpTool.addTo(&tmpToolPad);
879 tmpToolPad.resize(QSize(32, 32));
881 previewPixmap = tmpToolPad.grab();
884 QLabel *previewWrapper =
new QLabel;
885 previewWrapper->setPixmap(previewPixmap);
886 cnetHelpLayout->addWidget(previewWrapper);
888 QLabel *overview =
new QLabel(
"The mosaic scene can display control points "
889 "in addition to the usual cube footprints. This feature is currently "
890 "offered as one of the Mosaic Scene's tools. To open a network, click "
891 "on the control network tool. It will immediately prompt you for a "
892 "control network file if one is not open. Only control points for "
893 "which the latitude and longitude can be established will be "
894 "displayed. Other control points will be ignored by qmos.<br><br>"
895 "<b>Warning: Opening large control networks is slow.</b>"
896 "<h3>Control Network Tool Options</h3>"
898 "<li>The control network tool opens control networks in two ways. "
899 "First, if you select the control network tool and no network is "
900 "open, then it will prompt you for one. Second, if there is an open "
901 "network, the buttons for the available options are displayed in the "
902 "active tool area.</li>"
903 "<li>The control network tool can toggle whether or not control "
904 "points are displayed on the screen using the 'Display' button. "
905 "Control points are always on top and colored based on their "
906 "ignored, locked and type values.</li>"
907 "<li>This tool can also change the color of your footprints based on "
908 "connectivity through control points. This is available through the "
909 "'Color Islands' button. When you press color islands, all of the "
910 "current cube coloring information is lost and re-done based on "
911 "how the control network connects the files. Each set of connected "
912 "cubes are colored differently; generally speaking, islands are not "
913 "a good thing to have in your control network.</li>"
914 "<li>This tool will color your footprints on a per-image basis if you "
915 "click color images, effectively reversing color islands.</li>"
916 "<li>The show movement option under 'Configure Movement Display' "
917 "only displays data when the control "
918 "network has adjusted values. This means that show movement only "
919 "works after you have done a jigsaw solution on the control network. "
920 "This displays arrows emanating from the apriori latitude/longitude "
921 "and pointing toward the adjusted latitude/longitude.</li>");
922 overview->setWordWrap(
true);
923 cnetHelpLayout->addWidget(overview);
925 cnetHelpWidgetScrollArea->setWidget(cnetHelpWidget);
927 return cnetHelpWidgetScrollArea;
931 QWidget * MosaicSceneWidget::getGridHelp(QWidget *gridToolContainer) {
932 QScrollArea *gridHelpWidgetScrollArea =
new QScrollArea;
934 QWidget *gridHelpWidget =
new QWidget;
936 QVBoxLayout *gridHelpLayout =
new QVBoxLayout;
937 gridHelpWidget->setLayout(gridHelpLayout);
939 QLabel *title =
new QLabel(
"<h2>Map Grid Tool</h2>");
940 gridHelpLayout->addWidget(title);
942 QPixmap previewPixmap;
944 if (gridToolContainer) {
945 previewPixmap = gridToolContainer->grab().scaled(
946 QSize(500, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation);
949 ToolPad tmpToolPad(
"Example Tool Pad", NULL);
950 MosaicGridTool tmpTool(NULL);
951 tmpTool.addTo(&tmpToolPad);
953 tmpToolPad.resize(QSize(32, 32));
955 previewPixmap = tmpToolPad.grab();
958 QLabel *previewWrapper =
new QLabel;
959 previewWrapper->setPixmap(previewPixmap);
960 gridHelpLayout->addWidget(previewWrapper);
962 QLabel *overview =
new QLabel(
"Superimpose a map grid over the area of "
963 "displayed footprints in the 'mosaic scene.'"
966 "<li>The Map Grid Tool is activated by selecting the 'cross-hatch' "
967 "icon or typing 'g' at the keyboard."
969 "<li>The parameter options are displayed below the menubar. "
970 "Clicking the 'Grid Options' button will open the dialog. Checking "
971 "'Auto Grid' will draw a grid based on the open cubes. Hitting "
972 "'Show Grid' will display or hide the grid."
974 "<li>The map grid is defined by the loaded Map File (just as the "
975 "footprints and image data are), the opened cubes, or the grid "
978 "<li>If a Map File has not been selected, the default "
979 "Equirectangular projection will be used. The resulting grid "
980 "lines in the default 'Equi' map file will be drawn for the "
981 "full global range (latitude range = -90,90; longitude range = "
982 "0,360) at the default latitude and longitude increment values."
985 "If the grid lines are not immediately visible, try to "
986 "'zoom out' in the 'mosaic scene' window and modify the "
987 "Latitude and Longitude Increment parameters."
990 "<strong>Options:</strong>"
992 "<li>The 'Show Grid' option draws (checked) or clears (unchecked) the grid."
994 "<li>The 'Auto Grid' option draws a grid with extents and increments "
995 "computed from the set of images that are opened. The values displayed in the dialog "
996 "will reflect those used to draw the grid."
998 "<li>The expected units for each entry are displayed to the right of the "
1001 "<li>The 'Extent Type' combo boxes allow you to pick the source of the "
1002 "grid extents from the map file, from the open cubes <default>, or manually "
1005 "<li>The 'Auto Apply' checkbox, inside the 'Grid Options' dialog box, allows you to see "
1006 "real time updates in the grid when you change the parameters."
1008 "<li> Depending on the projection, the grid may not behave as expected. For instance, "
1009 "with a polarstereographic projection, the pole will not be included in the 'Auto "
1010 "Grid' if it is not in the cube region. In this case the 'Manual' option for latitude "
1011 "extents allows you to force the grid to the pole."
1014 overview->setWordWrap(
true);
1015 gridHelpLayout->addWidget(overview);
1017 gridHelpWidgetScrollArea->setWidget(gridHelpWidget);
1019 return gridHelpWidgetScrollArea;
1023 QWidget * MosaicSceneWidget::getLongHelp(QWidget *sceneContainer) {
1024 QScrollArea *longHelpWidgetScrollArea =
new QScrollArea;
1026 QWidget *longHelpWidget =
new QWidget;
1028 QVBoxLayout *longHelpLayout =
new QVBoxLayout;
1029 longHelpWidget->setLayout(longHelpLayout);
1031 QLabel *title =
new QLabel(
"<h2>Mosaic Scene</h2>");
1032 longHelpLayout->addWidget(title);
1034 if (sceneContainer) {
1035 QPixmap previewPixmap = sceneContainer->grab().scaled(
1036 QSize(500, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation);
1038 QLabel *previewWrapper =
new QLabel;
1039 previewWrapper->setPixmap(previewPixmap);
1040 longHelpLayout->addWidget(previewWrapper);
1043 QLabel *overview =
new QLabel(
"The mosaic scene displays cube footprints "
1044 "to show where files are on a target and how they overlap. "
1045 "The scene always represents projected image space and cannot show raw "
1046 "or unprojected images; images will be projected on the fly."
1048 "<p>Interact with the mosaic scene in different ways using "
1049 "the tools. The tools are usually in a toolbar next to the scene. "
1050 "The tools define what is displayed and what happens when you "
1051 "click in the mosaic scene. The tools include</p>"
1052 "<ul><li>Select Tool</li>"
1053 "<li>Zoom Tool</li>"
1055 "<li>Control Network Tool</li>"
1056 "<li>Show Area Tool</li>"
1057 "<li>Find Tool</li>"
1058 "<li>Grid Tool</li></ul>"
1059 "<h3>Context Menus</h3>"
1060 "Right click on anything in the mosaic scene and a context menu will pop up showing "
1061 "a list of actions or information relevant to the item you clicked on. "
1062 "<p>Note: The context menu is not associated with any selection, only the item "
1064 overview->setWordWrap(
true);
1065 longHelpLayout->addWidget(overview);
1067 longHelpWidgetScrollArea->setWidget(longHelpWidget);
1069 return longHelpWidgetScrollArea;
1073 QWidget * MosaicSceneWidget::getMapHelp(QWidget *mapContainer) {
1074 QScrollArea *mapHelpWidgetScrollArea =
new QScrollArea;
1076 QWidget *mapHelpWidget =
new QWidget;
1078 QVBoxLayout *mapHelpLayout =
new QVBoxLayout;
1079 mapHelpWidget->setLayout(mapHelpLayout);
1081 QLabel *title =
new QLabel(tr(
"<h2>Map File</h2>"));
1082 mapHelpLayout->addWidget(title);
1085 QPixmap previewPixmap = mapContainer->grab().scaled(
1086 QSize(500, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation);
1088 QLabel *previewWrapper =
new QLabel;
1089 previewWrapper->setPixmap(previewPixmap);
1090 mapHelpLayout->addWidget(previewWrapper);
1093 QLabel *overviewMapIcon =
new QLabel;
1095 overviewMapIcon->setPixmap(
1096 QIcon(FileName(
"$ISISROOT/appdata/images/icons/ographic.png").expanded()).pixmap(32, 32));
1097 mapHelpLayout->addWidget(overviewMapIcon);
1099 QLabel *defaultMapFile =
new QLabel(tr(
1100 "<h3>Default Map File</h3>"
1101 "The mosaic scene's projection is defined by a \"Map File\" that consists of keywords "
1102 "that describe the map layout to be used. If a cube or a list of cubes are "
1103 "loaded before a map file is selected, the default map file defines the "
1104 "equirectangular projection, planetocentric latitude, positive longitude east, 360 "
1105 "longitude domain, latitude range=90S-90N, longitude range=0-360E. The radius will "
1106 "default to the IAU standards (ellipsoid or sphere) for the specific planetary body "
1107 "defined for the \"TargetName\" in the labels of the image cube(s)."));
1109 defaultMapFile->setWordWrap(
true);
1110 mapHelpLayout->addWidget(defaultMapFile);
1112 QLabel *userDefinedMapFileOverview =
new QLabel(tr(
1113 "<h3>User Defined Map File</h3>"
1114 "You can load an existing \"Map File\" before loading images into %1 by selecting the "
1115 "\"View/Edit/Load Map File\" option. You will be greeted with a dialog box that will "
1116 "enable you to select an existing map file by clicking on \"Load Map File.\" Once "
1117 "the map file is selected, the contents is displayed in the dialog box where "
1118 "modifications can be made as well. If the modified map file is to be used later, "
1119 "save the map file by clicking on \"Save Map File\" button.")
1120 .arg(QCoreApplication::applicationName()));
1122 userDefinedMapFileOverview->setWordWrap(
true);
1123 mapHelpLayout->addWidget(userDefinedMapFileOverview);
1125 QLabel *userDefinedMapFileQuickLoad =
new QLabel(tr(
1126 "The \"Quick Load Map\" option (lightning icon) allows you to efficiently select a "
1127 "prepared \"Map File\" without an immediate need to view or edit the contents."));
1129 userDefinedMapFileQuickLoad->setWordWrap(
true);
1130 mapHelpLayout->addWidget(userDefinedMapFileQuickLoad);
1132 QLabel *userDefinedMapFileAnyTime =
new QLabel(tr(
1133 "At any point, you have access to the \"View/Edit\" functionality to modify or load a "
1134 "different map file."));
1136 userDefinedMapFileAnyTime->setWordWrap(
true);
1137 mapHelpLayout->addWidget(userDefinedMapFileAnyTime);
1139 QString mapProjWorkshopUrl(
"https://github.com/USGS-Astrogeology/ISIS3/wiki/Learning_About_Map_Projections");
1140 QLabel *preparingMapFile =
new QLabel(tr(
1141 "<h3>Preparing a Map File</h3>"
1142 "Please refer to Isis applications such as 'maptemplate' or 'mosrange' for more details "
1143 "on creating a custom map file that defines the desired projection, latitude "
1144 "system, and longitude direction and domain. This program will use the latitude range "
1145 "and longitude range if they exist in the loaded file. A choice of map templates that can be used as "
1146 "a starting point for supported map projections can be found in $ISISROOT/appdata/templates/maps (refer "
1147 "to maptemplate or mosrange for more details and information on the required parameters "
1148 "for a projection). The website: "
1149 "<a href='%1'>%1</a> also provides useful information about map projections.")
1150 .arg(mapProjWorkshopUrl));
1152 preparingMapFile->setOpenExternalLinks(
true);
1153 preparingMapFile->setWordWrap(
true);
1154 mapHelpLayout->addWidget(preparingMapFile);
1156 QLabel *mapFileDisplayResults =
new QLabel(tr(
1157 "<h3>Display Results with the Map File</h3>"
1158 "The footprints and image data that are displayed in the mosaic scene are defined by the "
1159 "loaded \"Map File\" regardless of whether the opened cubes are Level1 (raw "
1160 "camera space) or Level2 (map projected). The associated footprint polygons for "
1161 "Level2 cubes will be re-mapped as needed based on the loaded map file."));
1163 mapFileDisplayResults->setWordWrap(
true);
1164 mapHelpLayout->addWidget(mapFileDisplayResults);
1166 QLabel *editingMapFileOverview =
new QLabel(tr(
1167 "<h3>Editing a Map File</h3>"
1168 "Editing a map file is possible through the dialog box displayed by clicking on the "
1169 "'View/Edit/Load Map File' icon/button. The edits are "
1170 "applied to the current session and will be included with a 'Saved Project' (refer to "
1171 "the help under File-Save Project or Save Project as)."));
1173 editingMapFileOverview->setWordWrap(
true);
1174 mapHelpLayout->addWidget(editingMapFileOverview);
1176 QLabel *saveMapFileToDiskBullet =
new QLabel(tr(
1179 "To save or write the changes to a map file on disk, choose 'Save Map File' button. "
1180 "Map files can be saved to an existing map file (overwrites) or to a new file. This "
1181 "program always saves <strong>exactly</strong> what you see, the text, in the dialog "
1186 saveMapFileToDiskBullet->setWordWrap(
true);
1187 mapHelpLayout->addWidget(saveMapFileToDiskBullet);
1189 QLabel *mapFileValidityBullet =
new QLabel(tr(
1192 "As you modify the contents of a loaded map file in the dialog box, the entry is "
1193 "verified as you type with a bold black indicator message displaying whether the "
1194 "text is valid or is not valid. If you want to see the actual error messages, "
1195 "select the 'Show Errors' box and the errors will be displayed in red font "
1196 "along with the black bolded message. The errors will update "
1201 mapFileValidityBullet->setWordWrap(
true);
1202 mapHelpLayout->addWidget(mapFileValidityBullet);
1204 QLabel *mapFileCommentsBullet =
new QLabel(tr(
1207 "Map files may contain 'commented-out' lines (text that starts with \"#\" at "
1208 "the beginning of the line). These are referred to as \"unnecessary\""
1209 "or \"unknown\" keywords, they are simply ignored. If these lines are to be saved to "
1210 "the output map file on disk, click 'Save Map File' BEFORE clicking 'Ok' or 'Apply.' "
1211 "The comments are removed from the dialog box when you hit 'Ok' or 'Apply,' if they "
1212 "are just above \"End_Group\" or follow \"End_Group\" or \"End\".<br/><br/>"
1214 "If you want these comments retained, make sure they are immediately above a valid "
1215 "keyword inside of \"Group = Mapping.\" Note that any lines (commented or not) will "
1216 "not be saved if they are placed outside of \"Group = Mapping\" and \"End_Group\"."
1220 mapFileCommentsBullet->setWordWrap(
true);
1221 mapHelpLayout->addWidget(mapFileCommentsBullet);
1223 mapHelpWidgetScrollArea->setWidget(mapHelpWidget);
1225 return mapHelpWidgetScrollArea;
1229 QWidget * MosaicSceneWidget::getPreviewHelp(QWidget *worldViewContainer) {
1230 QScrollArea *previewHelpWidgetScrollArea =
new QScrollArea;
1232 QWidget *previewHelpWidget =
new QWidget;
1234 QVBoxLayout *previewHelpLayout =
new QVBoxLayout;
1235 previewHelpWidget->setLayout(previewHelpLayout);
1237 QLabel *title =
new QLabel(
"<h2>Mosaic World View</h2>");
1238 previewHelpLayout->addWidget(title);
1240 if (worldViewContainer) {
1241 QPixmap previewPixmap = worldViewContainer->grab().scaled(
1242 QSize(500, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation);
1244 QLabel *previewWrapper =
new QLabel;
1245 previewWrapper->setPixmap(previewPixmap);
1246 previewHelpLayout->addWidget(previewWrapper);
1249 QLabel *overview =
new QLabel(
"The mosaic world view displays cube "
1250 "footprints to show you where your files are on a target and their "
1251 "general arrangement. The world view does not have tools like "
1252 "mosaic scenes, but otherwise they are very similar.");
1253 overview->setWordWrap(
true);
1254 previewHelpLayout->addWidget(overview);
1256 previewHelpWidgetScrollArea->setWidget(previewHelpWidget);
1258 return previewHelpWidgetScrollArea;
1264 setProjection(createInitialProjection(image), *image->cube()->label());
1267 MosaicSceneItem *mosItem = NULL;
1270 if (!cubeToMosaic(image)) {
1271 mosItem =
new MosaicSceneItem(image,
this);
1273 connect(mosItem, SIGNAL(changed(
const QList<QRectF> &)),
1275 connect(mosItem, SIGNAL(mosaicCubeClosed(Image *)),
1276 this, SIGNAL(mosCubeClosed(Image *)));
1280 if (m_projectImageZOrders && m_projectImageZOrders->contains(image->id())) {
1281 double zOrder = m_projectImageZOrders->value(image->id());
1282 m_projectImageZOrders->remove(image->id());
1284 foreach (MosaicSceneItem *mosaicItem, *m_mosaicSceneItems) {
1285 if (mosaicItem->zValue() == zOrder) {
1286 mosaicItem->setZValue(maximumZ() + 1);
1287 m_currentMaximumFootprintZ = maximumZ() + 1;
1291 m_currentMaximumFootprintZ = qMax(zOrder, maximumZ());
1292 mosItem->setZValue(zOrder);
1295 mosItem->setZValue(maximumZ() + 1);
1296 m_currentMaximumFootprintZ = maximumZ() + 1;
1299 getScene()->addItem(mosItem);
1300 m_mosaicSceneItems->append(mosItem);
1301 m_displayPropsToMosaicSceneItemMap[image->displayProperties()] = mosItem;
1303 connect(mosItem, SIGNAL(destroyed(QObject *)),
1304 this, SLOT(removeMosItem(QObject *)));
1306 ImageDisplayProperties *prop = image->displayProperties();
1307 connect(prop, SIGNAL(moveDownOne()),
1308 this, SLOT(moveDownOne()));
1311 connect(prop, SIGNAL(moveUpOne()),
1312 this, SLOT(moveUpOne()));
1315 connect(prop, SIGNAL(zoomFit()),
1316 this, SLOT(fitInView()));
1323 double MosaicSceneWidget::maximumZ() {
1324 return m_currentMaximumFootprintZ;
1328 double MosaicSceneWidget::minimumZ() {
1329 return m_currentMinimumFootprintZ;
1332 void MosaicSceneWidget::recalcSceneRect() {
1334 double minX, minY, maxX, maxY;
1337 QRectF projRect(minX, -maxY, maxX - minX, maxY - minY);
1338 QRectF cubesBounding = cubesBoundingRect();
1340 QRectF bounding = projRect.united(cubesBounding);
1342 if (m_outlineRect && m_outlineRect->isVisible())
1343 bounding = bounding.united(m_outlineRect->boundingRect());
1345 getView()->setSceneRect(bounding);
1349 void MosaicSceneWidget::addImages(
ImageList images) {
1350 if (m_userToolControl)
1351 m_progress->setText(
"Loading primary scene");
1353 m_progress->setText(
"Loading secondary scene");
1355 m_progress->setRange(0, images.size() - 1);
1356 m_progress->setValue(0);
1357 m_progress->setVisible(
true);
1359 foreach(Image *image, images) {
1363 catch (IException &e) {
1367 m_progress->setValue(m_progress->value() + 1);
1372 if (m_projectViewTransform) {
1373 PvlObject &positionInfo = *m_projectViewTransform;
1374 QByteArray hexValues(positionInfo[
"ViewTransform"][0].toLatin1());
1375 QDataStream transformStream(QByteArray::fromHex(hexValues));
1376 transformStream.setVersion(
int(positionInfo[
"QtVersion"]));
1378 QTransform viewTransform;
1379 transformStream >> viewTransform;
1380 getView()->setTransform(viewTransform);
1382 QPoint projectScrollPos(toInt(positionInfo[
"ScrollPosition"][0]),
1383 toInt(positionInfo[
"ScrollPosition"][1]));
1385 getView()->horizontalScrollBar()->setValue(projectScrollPos.x());
1386 getView()->verticalScrollBar()->setValue(projectScrollPos.y());
1392 if (!m_projectImageZOrders || m_projectImageZOrders->isEmpty()) {
1393 delete m_projectViewTransform;
1394 m_projectViewTransform = NULL;
1397 m_progress->setVisible(
false);
1398 emit cubesChanged();
1402 void MosaicSceneWidget::removeImages(
ImageList images) {
1405 foreach(Image *image, images) {
1407 MosaicSceneItem *item = cubeToMosaic(image);
1408 item->deleteLater();
1409 removeMosItem(item);
1411 catch (IException &e) {
1423 QFileDialog::getSaveFileName((
QWidget *)parent(),
1424 "Choose output file",
1425 QDir::currentPath() +
"/untitled.png",
1426 QString(
"Images (*.png *.jpg *.tif)"));
1427 if (output.isEmpty())
return;
1430 if (QFileInfo(output).suffix().isEmpty()) {
1431 output = output +
".png";
1434 QString format = QFileInfo(output).suffix();
1435 QPixmap pm = getScene()->views().last()->grab();
1437 std::string formatString = format.toStdString();
1438 if (!pm.save(output, formatString.c_str())) {
1439 QMessageBox::information(
this,
"Error",
1440 "Unable to save [" + output +
"]");
1445 void MosaicSceneWidget::saveList() {
1447 QFileDialog::getSaveFileName((
QWidget *)parent(),
1448 "Choose output file",
1449 QDir::currentPath() +
"/files.lis",
1450 QString(
"List File (*.lis);;Text File (*.txt);;All Files (*.*)"));
1451 if (output.isEmpty())
return;
1453 TextFile file(output,
"overwrite");
1456 std::sort(sorted.begin(), sorted.end(), zOrderGreaterThan);
1459 foreach(sceneItem, sorted) {
1460 file.PutLine( sceneItem->image()->
fileName() );
1465 void MosaicSceneWidget::removeMosItem(QObject *mosItem) {
1466 MosaicSceneItem *castedMosItem = (MosaicSceneItem *) mosItem;
1467 m_mosaicSceneItems->removeAll(castedMosItem);
1468 m_displayPropsToMosaicSceneItemMap.remove(
1469 m_displayPropsToMosaicSceneItemMap.key(castedMosItem));
1471 emit cubesChanged();
1480 QRectF sceneRect = cubesBoundingRect();
1482 if (sceneRect.isEmpty())
1485 double xPadding = sceneRect.width() * 0.10;
1486 double yPadding = sceneRect.height() * 0.10;
1488 sceneRect.adjust(-xPadding, -yPadding, xPadding, yPadding);
1489 getView()->fitInView(sceneRect, Qt::KeepAspectRatio);
1493 void MosaicSceneWidget::setCubesSelectable(
bool selectable) {
1494 if (m_cubesSelectable != selectable) {
1495 m_cubesSelectable = selectable;
1498 foreach(mosaicSceneItem, *m_mosaicSceneItems) {
1499 mosaicSceneItem->scenePropertiesChanged();
1511 configDialog.exec();
1515 void MosaicSceneWidget::quickConfigProjectionParameters() {
1517 configDialog.setQuickConfig(
true);
1518 configDialog.exec();
1522 void MosaicSceneWidget::sendVisibleRectChanged() {
1523 QPointF topLeft = getView()->mapToScene(0, 0);
1524 QPointF bottomRight = getView()->mapToScene(
1525 (
int)getView()->width(),
1526 (
int)getView()->height());
1528 QRectF visibleRect(topLeft, bottomRight);
1529 emit visibleRectChanged(visibleRect);
1533 bool MosaicSceneWidget::eventFilter(QObject *obj, QEvent *event) {
1534 bool stopProcessingEvent =
true;
1536 switch(event->type()) {
1537 case QMouseEvent::GraphicsSceneMousePress: {
1538 if (m_customRubberBandEnabled) {
1540 if (!m_customRubberBand) {
1541 m_customRubberBand =
new QRubberBand(QRubberBand::Rectangle,
1545 if (!m_rubberBandOrigin) {
1546 m_rubberBandOrigin =
new QPoint;
1549 *m_rubberBandOrigin = getView()->mapFromScene(
1550 ((QGraphicsSceneMouseEvent *)event)->scenePos());
1551 m_customRubberBand->setGeometry(QRect(*m_rubberBandOrigin, QSize()));
1552 m_customRubberBand->show();
1555 emit mouseButtonPress(
1556 ((QGraphicsSceneMouseEvent *)event)->scenePos(),
1557 ((QGraphicsSceneMouseEvent *)event)->button());
1558 stopProcessingEvent =
false;
1562 case QMouseEvent::GraphicsSceneMouseRelease: {
1563 bool signalEmitted =
false;
1564 if (m_customRubberBandEnabled && m_rubberBandOrigin &&
1565 m_customRubberBand) {
1566 if (m_customRubberBand->geometry().width() +
1567 m_customRubberBand->geometry().height() > 10) {
1568 emit rubberBandComplete(
1569 getView()->mapToScene(
1570 m_customRubberBand->geometry()).boundingRect(),
1571 ((QGraphicsSceneMouseEvent *)event)->button());
1572 signalEmitted =
true;
1575 delete m_rubberBandOrigin;
1576 m_rubberBandOrigin = NULL;
1578 delete m_customRubberBand;
1579 m_customRubberBand = NULL;
1582 if (!signalEmitted) {
1583 stopProcessingEvent =
false;
1584 emit mouseButtonRelease(
1585 ((QGraphicsSceneMouseEvent *)event)->scenePos(),
1586 ((QGraphicsSceneMouseEvent *)event)->button());
1591 case QMouseEvent::GraphicsSceneMouseDoubleClick:
1592 emit mouseDoubleClick(
1593 ((QGraphicsSceneMouseEvent *)event)->scenePos());
1594 stopProcessingEvent =
false;
1597 case QMouseEvent::GraphicsSceneMouseMove:
1598 if (m_customRubberBandEnabled && m_rubberBandOrigin &&
1599 m_customRubberBand) {
1600 QPointF scenePos = ((QGraphicsSceneMouseEvent *)event)->scenePos();
1601 QPoint screenPos = getView()->mapFromScene(scenePos);
1603 QRect rubberBandRect =
1604 QRect(*m_rubberBandOrigin, screenPos).normalized();
1606 m_customRubberBand->setGeometry(rubberBandRect);
1609 stopProcessingEvent =
false;
1613 ((QGraphicsSceneMouseEvent *)event)->scenePos());
1616 case QEvent::GraphicsSceneWheel:
1618 ((QGraphicsSceneWheelEvent *)event)->scenePos(),
1619 ((QGraphicsSceneWheelEvent *)event)->delta());
1621 stopProcessingEvent =
true;
1624 case QMouseEvent::Enter:
1626 stopProcessingEvent =
false;
1629 case QMouseEvent::Leave:
1631 stopProcessingEvent =
false;
1634 case QEvent::GraphicsSceneHelp: {
1636 bool toolTipFound =
false;
1638 QGraphicsItem *sceneItem;
1639 foreach(sceneItem, getScene()->items()) {
1640 if (!toolTipFound) {
1641 if (sceneItem->contains(
1642 ((QGraphicsSceneHelpEvent*)event)->scenePos()) &&
1643 sceneItem->toolTip().size() > 0) {
1644 setToolTip(sceneItem->toolTip());
1645 toolTipFound =
true;
1651 stopProcessingEvent =
true;
1653 ((QGraphicsSceneHelpEvent*)event)->screenPos(),
1660 stopProcessingEvent =
false;
1664 return stopProcessingEvent;
1675 if (m_mosaicSceneItems->size() == 0)
1678 if (m_userToolControl)
1679 m_progress->setText(
"Reprojecting primary scene");
1681 m_progress->setText(
"Reprojecting secondary scene");
1684 int reprojectsPerUpdate = qMax(1, m_mosaicSceneItems->size() / 20);
1686 m_progress->setRange(0,
1687 (m_mosaicSceneItems->size() - 1) / reprojectsPerUpdate + 1);
1688 m_progress->setValue(0);
1689 m_progress->setVisible(
true);
1693 int progressCountdown = reprojectsPerUpdate;
1694 foreach(mosaicSceneItem, *m_mosaicSceneItems) {
1698 catch (IException &e) {
1699 QString msg =
"The file [";
1701 if (mosaicSceneItem->image())
1704 msg +=
"] is being removed due to not being able to project onto the scene";
1706 IException tmp(e, IException::Programmer, msg, _FILEINFO_);
1708 mosaicSceneItem->image()->deleteLater();
1711 progressCountdown --;
1712 if (progressCountdown == 0) {
1713 m_progress->setValue(m_progress->value() + 1);
1714 progressCountdown = reprojectsPerUpdate;
1719 m_progress->setValue(m_progress->maximum());
1723 m_progress->setVisible(
false);
1727 void MosaicSceneWidget::moveDownOne() {
1731 moveDownOne(cubeToMosaic(props));
1739 MosaicSceneItem *nextDown =
getNextItem(item,
false);
1740 double originalZ = item->zValue();
1743 double newZValue = nextDown->zValue() - 1;
1744 moveZ(item, newZValue,
true);
1753 double MosaicSceneWidget::moveDownOne(
Image *image) {
1754 return moveDownOne(cubeToMosaic(image));
1760 QList<double> MosaicSceneWidget::moveDownOne(
ImageList *images) {
1761 QList<double> results;
1763 foreach (Image *image, *images) {
1764 results.append(moveDownOne(image));
1772 DisplayProperties *props = qobject_cast<DisplayProperties *>(sender());
1784 double originalZ = item->zValue();
1785 double minZ = minimumZ();
1787 if (originalZ != minZ) {
1789 int newZValue = qRound(minZ - 1);
1790 item->setZValue(newZValue);
1793 m_currentMinimumFootprintZ--;
1816 foreach (
Image *image, *images) {
1824 void MosaicSceneWidget::moveUpOne() {
1828 moveUpOne(cubeToMosaic(props));
1836 MosaicSceneItem *nextUp =
getNextItem(item,
true);
1837 double originalZ = item->zValue();
1840 double newZValue = nextUp->zValue() + 1;
1841 moveZ(item, newZValue,
true);
1850 double MosaicSceneWidget::moveUpOne(
Image *image) {
1851 return moveUpOne(cubeToMosaic(image));
1857 QList<double> MosaicSceneWidget::moveUpOne(
ImageList *images) {
1858 QList<double> results;
1860 foreach (Image *image, *images) {
1861 results.append(moveUpOne(image));
1869 DisplayProperties *props = qobject_cast<DisplayProperties *>(sender());
1882 double originalZ = item->zValue();
1883 double maxZ = maximumZ();
1885 if (originalZ != maxZ) {
1887 int newZValue = qRound(maxZ + 1);
1888 item->setZValue(newZValue);
1891 m_currentMaximumFootprintZ++;
1924 foreach (
Image *image, *images) {
1950 bool newZValueMightExist) {
1951 double originalZ = sceneItem->zValue();
1953 if (newZValueMightExist) {
1955 m_currentMinimumFootprintZ = 0.0;
1956 m_currentMaximumFootprintZ = 0.0;
1959 double otherItemOrigZ = otherItem->zValue();
1960 double otherItemNewZ = otherItemOrigZ;
1963 if (originalZ > newZ && otherItemOrigZ >= newZ && otherItemOrigZ < originalZ) {
1964 otherItemNewZ = otherItemOrigZ + 1;
1967 else if (originalZ < newZ && otherItemOrigZ <= newZ && otherItemOrigZ > originalZ) {
1968 otherItemNewZ = otherItemOrigZ - 1;
1971 m_currentMinimumFootprintZ = qMin(m_currentMinimumFootprintZ, otherItemNewZ);
1972 m_currentMaximumFootprintZ = qMax(m_currentMaximumFootprintZ, otherItemNewZ);
1973 otherItem->setZValue(otherItemNewZ);
1977 sceneItem->setZValue(newZ);
1979 if (!newZValueMightExist) {
1981 if (originalZ == maximumZ() && newZ < originalZ) {
1982 m_currentMaximumFootprintZ--;
1984 else if (originalZ == minimumZ() && newZ > originalZ) {
1985 m_currentMinimumFootprintZ++;
1994 bool newZValueMightExist) {
1995 return moveZ(cubeToMosaic(image), newZ, newZValueMightExist);
1999 void MosaicSceneWidget::fitInView() {
2000 if (m_userToolControl) {
2003 DisplayProperties *props = qobject_cast<DisplayProperties *>(sender());
2006 MosaicSceneItem *item = cubeToMosaic(props);
2007 boundingBox = item->boundingRect();
2010 QAction *action = qobject_cast<QAction *>(sender());
2013 ImageList *images = action->data().value<ImageList *>();
2015 foreach (Image *image, *images) {
2016 boundingBox = boundingBox.united(cubeToMosaic(image)->boundingRect());
2021 if (!boundingBox.isNull()) {
2022 double xPadding = boundingBox.width() * 0.10;
2023 double yPadding = boundingBox.height() * 0.10;
2025 boundingBox.setLeft(boundingBox.left() - xPadding);
2026 boundingBox.setRight(boundingBox.right() + xPadding);
2028 boundingBox.setTop(boundingBox.top() - yPadding);
2029 boundingBox.setBottom(boundingBox.bottom() + yPadding);
2031 getView()->fitInView(boundingBox, Qt::KeepAspectRatio);
2032 getView()->centerOn(boundingBox.center());
2038 void MosaicSceneWidget::onSelectionChanged() {
2039 if (!m_blockingSelectionChanged) {
2040 if (!m_queuedSelectionChanged) {
2041 emit queueSelectionChanged();
2042 m_queuedSelectionChanged =
true;
2045 m_shouldRequeueSelectionChanged =
true;
2051 void MosaicSceneWidget::onQueuedSelectionChanged() {
2052 m_queuedSelectionChanged =
false;
2054 if (m_shouldRequeueSelectionChanged) {
2055 m_shouldRequeueSelectionChanged =
false;
2056 onSelectionChanged();
2059 foreach(MosaicSceneItem *mosaicSceneItem, *m_mosaicSceneItems) {
2060 mosaicSceneItem->updateSelection(
true);
2071 foreach(mosaicSceneItem, *m_mosaicSceneItems) {
2072 if (mosaicSceneItem != item &&
2073 mosaicSceneItem->boundingRect().intersects(item->boundingRect())) {
2075 if ( (up && mosaicSceneItem->zValue() > item->zValue()) ||
2076 (!up && mosaicSceneItem->zValue() < item->zValue())) {
2079 if (!nextZValueItem) {
2080 nextZValueItem = mosaicSceneItem;
2085 if ((up && mosaicSceneItem->zValue() < nextZValueItem->zValue()) ||
2086 (!up && mosaicSceneItem->zValue() > nextZValueItem->zValue())) {
2087 nextZValueItem = mosaicSceneItem;
2094 return nextZValueItem;
2100 return first->zValue() > second->zValue();
QString displayName() const
Returns the display name.
This represents a cube in a project-based GUI interface.
ImageDisplayProperties * displayProperties()
Get the display (GUI) properties (information) associated with this image.
QString fileName() const
Get the file name of the cube that this image represents.
QString id() const
Get a unique, identifying string associated with this image.
Internalizes a list of images and allows for operations on the entire list.
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...
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.
static PvlGroup radiiGroup(QString target)
Creates a Pvl Group with keywords TargetName, EquitorialRadius, and PolarRadius.
Provides access to sequential ASCII stream I/O.
virtual void setData(Context)
Sets the context data for this WorkOrder.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
QString toString(const LinearAlgebra::Vector &vector, int precision)
A global function to format LinearAlgebra::Vector as a QString with the given precision.