Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

Isis 3 Programmer Reference
MosaicMainWindow.cpp
1#include "MosaicMainWindow.h"
2
3#include <QApplication>
4#include <QDockWidget>
5#include <QHBoxLayout>
6#include <QLabel>
7#include <QMenu>
8#include <QMenuBar>
9#include <QMessageBox>
10#include <QProgressBar>
11#include <QPushButton>
12#include <QRegExp>
13#include <QSettings>
14#include <QScrollArea>
15#include <QStatusBar>
16#include <QVBoxLayout>
17#include <QWhatsThis>
18
19#include "Camera.h"
20#include "FileDialog.h"
21#include "MosaicController.h"
22#include "ImageFileListWidget.h"
23#include "ImageTreeWidgetItem.h"
24#include "IString.h"
25#include "MosaicSceneWidget.h"
26#include "Projection.h"
27#include "ProjectionFactory.h"
28#include "TextFile.h"
29#include "ToolPad.h"
30
31
32namespace Isis {
33 MosaicMainWindow::MosaicMainWindow(QString title, QWidget *parent) :
34 MainWindow(title, parent),
35 m_settings(FileName("$HOME/.Isis/qmos/qmos.config").expanded(),
36 QSettings::NativeFormat) {
37 m_filename = "";
38 m_fileMenu = NULL;
39 m_settingsMenu = NULL;
40 m_viewMenu = NULL;
41
42 setObjectName("MosaicMainWindow");
43
44 m_controllerVisible = false;
45
46 setWindowTitle(title);
47
48 m_permToolbar = new QToolBar("Standard Tools", this);
49 m_permToolbar->setObjectName("Standard Tools");
50 m_permToolbar->setWhatsThis("This area contains options that are always "
51 "present in qmos, regardless of whether or not a project is open. "
52 "These options are also found in the File menu.");
53 addToolBar(m_permToolbar);
54
55 m_activeToolbar = new QToolBar("Active Tool", this);
56 m_activeToolbar->setObjectName("Active Tool");
57 m_activeToolbar->setWhatsThis("The currently selected tool's options will "
58 "show up here. Not all tools have options.");
59 addToolBar(m_activeToolbar);
60
61 statusBar()->showMessage("Ready");
62
63 m_toolpad = new ToolPad("Tool Pad", this);
64 m_toolpad->setObjectName("Tool Pad");
65 // default to the right hand side for qview-like behavior... we might
66 // want to do something different here
67 addToolBar(Qt::RightToolBarArea, m_toolpad);
68
69 setupMenus();
70
71 m_fileListDock = new QDockWidget("File List", this, Qt::SubWindow);
72 m_fileListDock->setObjectName("FileListDock");
73 m_fileListDock->setFeatures(QDockWidget::DockWidgetFloatable |
74 QDockWidget::DockWidgetMovable |
75 QDockWidget::DockWidgetClosable);
76 m_fileListDock->setWhatsThis("This contains the mosaic file list.");
77
78 m_mosaicPreviewDock = new QDockWidget("Mosaic World View",
79 this, Qt::SubWindow);
80 m_mosaicPreviewDock->setObjectName("MosaicPreviewDock");
81 m_mosaicPreviewDock->setFeatures(QDockWidget::DockWidgetFloatable |
82 QDockWidget::DockWidgetMovable |
83 QDockWidget::DockWidgetClosable);
84 m_mosaicPreviewDock->setWhatsThis("This contains a zoomed out view of the "
85 "mosaic.");
86
87 addDockWidget(Qt::LeftDockWidgetArea, m_fileListDock);
88 addDockWidget(Qt::LeftDockWidgetArea, m_mosaicPreviewDock);
89
90 readSettings();
91
92 setCentralWidget(new QWidget());
93 centralWidget()->setLayout(new QHBoxLayout());
94
95 m_mosaicController = NULL;
96 createController();
97 displayController();
98 installEventFilter(this);
99
100 QStringList args = QApplication::arguments();
101 args.removeFirst();
102
103 QStringList filesToOpen;
104 bool projectLoaded = false;
105
106 foreach (QString argument, args) {
107 QRegExp cubeName(".*\\.cub$", Qt::CaseInsensitive);
108 QRegExp cubeListName(".*\\.(lis|txt)$", Qt::CaseInsensitive);
109 QRegExp projectName(".*\\.mos$", Qt::CaseInsensitive);
110
111 try {
112 if (cubeName.exactMatch(argument)) {
113 filesToOpen.append(argument);
114 }
115 else if (cubeListName.exactMatch(argument)) {
116 TextFile fileList(argument);
117 QString line;
118
119 while(fileList.GetLine(line)) {
120 filesToOpen.append(line);
121 }
122 }
123 else if (projectName.exactMatch(argument)) {
124 if (!projectLoaded) {
125 loadProject(argument);
126 projectLoaded = true;
127 }
128 else {
129 QMessageBox::warning(this, "Multiple Projects Specified",
130 "qmos can only open one project at a time. The first project "
131 "specified is the one that will be used.");
132 }
133 }
134 }
135 catch (IException &e) {
136 QMessageBox::warning(this, "Problem Loading File", e.what());
137 }
138 }
139
140 m_lastOpenedFile = QFileInfo(".");
141
142 if (!filesToOpen.isEmpty())
143 openFiles(filesToOpen);
144 }
145
146
155 switch(e->type()) {
156 case QEvent::Close:
157 closeMosaic();
158
159 default:
160 return false;
161 }
162 }
163
164
174 // Create the file menu
175 m_fileMenu = menuBar()->addMenu("&File");
176
177 IString iconDir = FileName("$ISISROOT/appdata/images/icons").expanded();
178
179 QAction *open = new QAction(this);
180 open->setText("Open Cube...");
181 open->setIcon(QPixmap(QString::fromStdString(iconDir.c_str()) + "/fileopen.png"));
182 connect(open, SIGNAL(triggered()), this, SLOT(open()));
183
184 QAction *openList = new QAction(this);
185 openList->setText("Open Cube List...");
186 openList->setIcon(QPixmap(QString::fromStdString(iconDir.c_str()) + "/mActionHelpContents.png"));
187 connect(openList, SIGNAL(triggered()), this, SLOT(openList()));
188
189 QAction *saveProject = new QAction(this);
190 saveProject->setText("Save Project");
191 saveProject->setShortcut(Qt::CTRL + Qt::Key_S);
192 saveProject->setIcon(QPixmap(QString::fromStdString(iconDir.c_str()) + "/mActionFileSave.png"));
193 m_actionsRequiringOpen.append(saveProject);
194 connect(saveProject, SIGNAL(triggered()), this, SLOT(saveProject()));
195
196 QAction *saveProjectAs = new QAction(this);
197 saveProjectAs->setText("Save Project As...");
198 saveProjectAs->setIcon(QPixmap(QString::fromStdString(iconDir.c_str()) + "/mActionFileSaveAs.png"));
199 m_actionsRequiringOpen.append(saveProjectAs);
200 connect(saveProjectAs, SIGNAL(triggered()), this, SLOT(saveProjectAs()));
201
202 QAction *loadProject = new QAction(this);
203 loadProject->setText("Load Project...");
204 loadProject->setIcon(QPixmap(QString::fromStdString(iconDir.c_str()) + "/mActionExportMapServer.png"));
205 connect(loadProject, SIGNAL(triggered()), this, SLOT(loadProject()));
206
207 QAction *closeProject = new QAction(this);
208 closeProject->setText("Close Project");
209 m_actionsRequiringOpen.append(closeProject);
210 connect(closeProject, SIGNAL(triggered()), this, SLOT(closeMosaic()));
211
212 QAction *exit = new QAction(this);
213 exit->setText("Exit");
214 exit->setIcon(QIcon::fromTheme("window-close"));
215 connect(exit, SIGNAL(triggered()), this, SLOT(close()));
216
217 QAction *actionRequiringOpen = NULL;
218 foreach(actionRequiringOpen, m_actionsRequiringOpen) {
219 actionRequiringOpen->setEnabled(false);
220 }
221
222 QAction *actionRequiringClosed = NULL;
223 foreach(actionRequiringClosed, m_actionsRequiringClosed) {
224 actionRequiringClosed->setEnabled(true);
225 }
226
227 m_fileMenu->addAction(open);
228 m_fileMenu->addAction(openList);
229 m_fileMenu->addSeparator();
230 m_fileMenu->addAction(loadProject);
231 m_fileMenu->addAction(saveProject);
232 m_fileMenu->addAction(saveProjectAs);
233 m_fileMenu->addAction(closeProject);
234 m_fileMenu->addSeparator();
235 m_exportMenu = m_fileMenu->addMenu("&Export");
236 m_fileMenu->addAction(exit);
237
238 permanentToolBar()->addAction(loadProject);
239 permanentToolBar()->addAction(saveProject);
240 permanentToolBar()->addAction(saveProjectAs);
241 permanentToolBar()->addSeparator();
242 permanentToolBar()->addAction(open);
243 permanentToolBar()->addAction(openList);
244 permanentToolBar()->addSeparator();
245
246 m_viewMenu = menuBar()->addMenu("&View");
247 m_settingsMenu = menuBar()->addMenu("&Settings");
248 QMenu *helpMenu = menuBar()->addMenu("&Help");
249
250 QAction *activateWhatsThisAct = new QAction("&What's This", this);
251 activateWhatsThisAct->setShortcut(Qt::SHIFT | Qt::Key_F1);
252 activateWhatsThisAct->setIcon(
253 QPixmap(FileName("$ISISROOT/appdata/images/icons/contexthelp.png").expanded()));
254 activateWhatsThisAct->setToolTip("Activate What's This and click on parts "
255 "this program to see more information about them");
256 connect(activateWhatsThisAct, SIGNAL(triggered()),
257 this, SLOT(enterWhatsThisMode()));
258
259 QAction *showHelpAct = new QAction("qmos &Help", this);
260 showHelpAct->setIcon(QIcon::fromTheme("help-contents"));
261 connect(showHelpAct, SIGNAL(triggered()),
262 this, SLOT(showHelp()));
263
264 helpMenu->addAction(activateWhatsThisAct);
265 helpMenu->addAction(showHelpAct);
266
267 updateMenuVisibility();
268 }
269
270
277 QStringList filterList;
278 filterList.append("Isis cubes (*.cub)");
279 filterList.append("All Files (*)");
280
281 QDir directory = m_lastOpenedFile.dir();
282 QStringList selected = QFileDialog::getOpenFileNames(this, "Open Cubes",
283 directory.path(), filterList.join(";;"));
284
285 if (!selected.empty()) {
286 m_lastOpenedFile = QFileInfo(selected.last());
287 openFiles(selected);
288 }
289 }
290
291
292 void MosaicMainWindow::enterWhatsThisMode() {
293 QWhatsThis::enterWhatsThisMode();
294 }
295
296
297 void MosaicMainWindow::showHelp() {
298 QDialog *helpDialog = new QDialog(this);
299
300 QVBoxLayout *mainLayout = new QVBoxLayout;
301 helpDialog->setLayout(mainLayout);
302
303 // Let's add some text
304 QLabel *qmosTitle = new QLabel("<h1>qmos</h1>");
305// qmosTitle->setMinimumSize(QSize(800, qmosTitle->minimumSize().height()));
306 mainLayout->addWidget(qmosTitle);
307
308 QLabel *qmosSubtitle = new QLabel("A tool for visualizing image "
309 "footprints for a mosaic.");
310 mainLayout->addWidget(qmosSubtitle);
311
312 QTabWidget *tabArea = new QTabWidget;
313 mainLayout->addWidget(tabArea);
314
315 QScrollArea *overviewTab = new QScrollArea;
316
317 QWidget *overviewContainer = new QWidget;
318
319 QVBoxLayout *overviewLayout = new QVBoxLayout;
320 overviewContainer->setLayout(overviewLayout);
321
322 QLabel *purposeTitle = new QLabel("<h2>Purpose</h2>");
323 overviewLayout->addWidget(purposeTitle);
324
325 QLabel *purposeText = new QLabel("<p>qmos is designed "
326 "specifically for visualizing large amounts of images, how images "
327 "overlap, where control points lie on the images, and how jigsaw has "
328 "moved control points.");
329 purposeText->setWordWrap(true);
330 overviewLayout->addWidget(purposeText);
331
332 QLabel *shortcomingsTitle = new QLabel("<h2>Known Issues</h2>");
333 overviewLayout->addWidget(shortcomingsTitle);
334
335 QLabel *shortcomingsText = new QLabel("<p>The known shortcomings of qmos "
336 "include:<ul>"
337 "<li>All input files are read-only, you cannot edit your input "
338 "data</li>"
339 "<li>Large control networks are slow and memory intensive to load</li>"
340 "<li>Show cube DN data is extremely slow</li>"
341 "<li>Warnings are not displayed graphically</li>"
342 "<li>Zooming in too far causes you to pan off of your data</li></ul>");
343 shortcomingsText->setWordWrap(true);
344 overviewLayout->addWidget(shortcomingsText);
345
346 overviewTab->setWidget(overviewContainer);
347
348 QScrollArea *preparationsTab = new QScrollArea;
349
350 QWidget *preparationsContainer = new QWidget;
351 QVBoxLayout *preparationsLayout = new QVBoxLayout;
352 preparationsContainer->setLayout(preparationsLayout);
353
354 QLabel *preparationTitle = new QLabel("<h2>Before Using qmos</h2>");
355 preparationsLayout->addWidget(preparationTitle);
356
357 QLabel *preparationText = new QLabel("<p>qmos only supports files which "
358 "have latitude and longitude information associated with them. Global "
359 "projections are also not supported. If your files meet these "
360 "requirements, it is beneficial to run a couple of Isis programs on "
361 "your files before loading them into qmos. The programs you should run "
362 "are:<ul>"
363 "<li><i>camstats from=future_input_to_qmos.cub attach=true "
364 "sinc=... linc=...</i></li>"
365 " <br>This enables qmos to give you the emission angle, incidence "
366 "angle, phase angle, and resolution in the <b>File List</b>"
367 "<li><i>footprintinit from=future_input_to_qmos.cub "
368 "sinc=... linc=...</i></li>"
369 " <br>Running <i>footprintinit</i> beforehand will significantly speed up loading images "
370 "into qmos.<br/><br/>"
371 "The footprint is created by \"walking\" around the valid image data, and qmos reprojects "
372 "the footprint according to the loaded map file.<br/><br/>"
373 "Qmos displays the footprints, and optionally the image data and map grid to the default "
374 "IAU radius, unless the radius is specified within the loaded map file.<br/><br/>"
375 "For Level1 (raw camera space) images, when calculating the "
376 "footprint polygons, footprintinit refers to the image labels "
377 "and uses the SPICE kernels and the shape model (DEM if one "
378 "exists and is specified, otherwise, the IAU sphere or "
379 "ellipsoid is used). Refer to spiceinit for more information "
380 "on loading SPICE onto Level0 and Level1 images. This enables "
381 "qmos to use the given footprints instead of trying to "
382 "calculate its own. The 'linc' and 'sinc' parameters can have a "
383 "significant effect on your image's footprint. Also, images "
384 "without footprints cannot be opened more than one at a time. "
385 "Running footprintinit will significantly speed up loading "
386 "images into qmos.<br>"
387 "For Level2 images, do not run footprintinit. The footprint "
388 "polygon is created by 'walking' around the valid image data. "
389 "qmos 'reprojects' the footprint polygons according to the "
390 "loaded Map File.<br>"
391 "</ul>");
392 preparationText->setWordWrap(true);
393 preparationsLayout->addWidget(preparationText);
394
395 preparationsTab->setWidget(preparationsContainer);
396
397 QScrollArea *projectsTab = new QScrollArea;
398
399 QWidget *projectsContainer = new QWidget;
400 QVBoxLayout *projectsLayout = new QVBoxLayout;
401 projectsContainer->setLayout(projectsLayout);
402
403 QLabel *projectsTitle = new QLabel("<h2>Projects</h2>");
404 projectsLayout->addWidget(projectsTitle);
405
406 QLabel *projectsText = new QLabel("<p>The contents of qmos can be saved as a project file, "
407 "which allows the user to restore back to the previous state at any given time. The stored "
408 "files or qmos project files must have a \".mos\" extension.<br/><br/>"
409 "These project files store the input file location information and their qmos properties "
410 "(color, group information, and other attributes).<br/><br/>"
411 "When you initially open qmos you start with a blank project. "
412 "To load a project, you can specify the project "
413 "file's name on the command line (qmos myProject.mos) or go to "
414 "File -> Load Project after qmos is started. When "
415 "loading a project, all current data in the qmos window is lost (your cubes are closed)."
416 "These project files are relatively small files. You can "
417 "save your current project any time by going to File -> Save Project. ");
418 projectsText->setWordWrap(true);
419 projectsLayout->addWidget(projectsText);
420
421 projectsTab->setWidget(projectsContainer);
422
423 if (m_controllerVisible) {
424 tabArea->addTab(overviewTab, "&Overview");
425 tabArea->addTab(preparationsTab, "Preparing &Input Cubes");
426
427 tabArea->addTab(ImageFileListWidget::getLongHelp(m_fileListDock),
428 "File &List");
429 tabArea->addTab(MosaicSceneWidget::getLongHelp(centralWidget()),
430 "Mosaic &Scene");
431 tabArea->addTab(MosaicSceneWidget::getPreviewHelp(m_mosaicPreviewDock),
432 "Mosaic &World View");
433
434 tabArea->addTab(MosaicSceneWidget::getMapHelp(),
435 "&Map File");
436 tabArea->addTab(projectsTab, "&Project Files");
437
438 tabArea->addTab(MosaicSceneWidget::getControlNetHelp(),
439 "&Control Networks");
440 tabArea->addTab(MosaicSceneWidget::getGridHelp(),
441 "Mosaic &Grid");
442 }
443 else {
444 tabArea->addTab(overviewTab, "&Overview");
445 tabArea->addTab(preparationsTab, "Preparing &Input Cubes");
446
447 tabArea->addTab(ImageFileListWidget::getLongHelp(),
448 "File &List");
449 tabArea->addTab(MosaicSceneWidget::getLongHelp(),
450 "Mosaic &Scene");
451 tabArea->addTab(MosaicSceneWidget::getPreviewHelp(),
452 "Mosaic &World View");
453
454 tabArea->addTab(MosaicSceneWidget::getMapHelp(),
455 "&Map File");
456 tabArea->addTab(projectsTab, "&Project Files");
457
458 tabArea->addTab(MosaicSceneWidget::getControlNetHelp(),
459 "&Control Networks");
460 tabArea->addTab(MosaicSceneWidget::getGridHelp(),
461 "Mosaic &Grid");
462 }
463
464 // Now add close option
465 QWidget *buttonsArea = new QWidget;
466 mainLayout->addWidget(buttonsArea);
467
468 QHBoxLayout *buttonsLayout = new QHBoxLayout;
469 buttonsArea->setLayout(buttonsLayout);
470
471 // Flush the buttons to the right
472 buttonsLayout->addStretch();
473
474 QPushButton *closeButton = new QPushButton(QIcon::fromTheme("window-close"),
475 "&Close");
476 closeButton->setDefault(true);
477 connect(closeButton, SIGNAL(clicked()),
478 helpDialog, SLOT(close()));
479 buttonsLayout->addWidget(closeButton);
480
481 helpDialog->show();
482 }
483
484
485 void MosaicMainWindow::updateMenuVisibility() {
486 QMenuBar *rootMenu = menuBar();
487
488 QAction *rootAction = NULL;
489 foreach(rootAction, rootMenu->actions()) {
490 QMenu *rootMenu = rootAction->menu();
491
492 if (rootMenu) {
493 rootAction->setVisible(updateMenuVisibility(rootAction->menu()));
494 }
495 }
496 }
497
498
499 void MosaicMainWindow::createController() {
500 if (m_mosaicController == NULL) {
501 m_mosaicController = new MosaicController(statusBar(), m_settings);
502
503 QList<QAction *> settingsActs = m_mosaicController->getSettingsActions();
504
505 QAction *settingsAct;
506 foreach(settingsAct, settingsActs) {
507 connect(settingsAct, SIGNAL(destroyed(QObject *)),
508 this, SLOT(updateMenuVisibility()));
509
510 m_settingsMenu->addAction(settingsAct);
511 }
512
513 updateMenuVisibility();
514 }
515 }
516
517
518 void MosaicMainWindow::displayController() {
519 if (m_mosaicController && !m_controllerVisible) {
520 m_controllerVisible = true;
521 m_mosaicController->addExportActions(*m_exportMenu);
522
523 m_fileListDock->setWidget(m_mosaicController->getImageFileList());
524 m_mosaicPreviewDock->setWidget(m_mosaicController->getMosaicWorldScene());
525
526 centralWidget()->layout()->addWidget(
527 m_mosaicController->getMosaicScene());
528
529 QAction *actionRequiringOpen = NULL;
530 foreach(actionRequiringOpen, m_actionsRequiringOpen) {
531 actionRequiringOpen->setEnabled(true);
532 }
533
534 QAction *actionRequiringClosed = NULL;
535 foreach(actionRequiringClosed, m_actionsRequiringClosed) {
536 actionRequiringClosed->setEnabled(false);
537 }
538
539 m_mosaicController->getMosaicScene()->addTo(m_toolpad);
540 m_mosaicController->getMosaicScene()->addToPermanent(m_permToolbar);
541 m_mosaicController->getMosaicScene()->addTo(m_activeToolbar);
542
543 statusBar()->addWidget(m_mosaicController->getProgress());
544 statusBar()->addWidget(
545 m_mosaicController->getMosaicScene()->getProgress());
546 statusBar()->addWidget(
547 m_mosaicController->getMosaicWorldScene()->getProgress());
548 statusBar()->addWidget(
549 m_mosaicController->getImageFileList()->getProgress());
550
551 QList<QAction *> sceneViewActs =
552 m_mosaicController->getMosaicScene()->getViewActions();
553
554 foreach(QAction *viewAct, sceneViewActs) {
555 connect(viewAct, SIGNAL(destroyed(QObject *)),
556 this, SLOT(updateMenuVisibility()));
557
558 m_viewMenu->addAction(viewAct);
559 }
560
561 m_viewMenu->addSeparator();
562
563
564 QList<QAction *> fileListViewActs =
565 m_mosaicController->getImageFileList()->getViewActions();
566
567 foreach(QAction *viewAct, fileListViewActs) {
568 connect(viewAct, SIGNAL(destroyed(QObject *)),
569 this, SLOT(updateMenuVisibility()));
570
571 m_viewMenu->addAction(viewAct);
572 }
573
574 updateMenuVisibility();
575 }
576 }
577
578
579 bool MosaicMainWindow::updateMenuVisibility(QMenu *menu) {
580 bool anythingVisible = false;
581
582 if (menu) {
583 QList<QAction *> actions = menu->actions();
584
585 // Recursively search the menu for other menus to show or hide and handle
586 // every internal being invisible
587 QAction *menuAction = NULL;
588 foreach(menuAction, menu->actions()) {
589 bool thisVisible = true;
590
591 if (menuAction->menu() != NULL) {
592 thisVisible = updateMenuVisibility(menuAction->menu());
593 }
594 else {
595 thisVisible = menuAction->isVisible();
596 }
597
598 if (thisVisible)
599 anythingVisible = true;
600 }
601
602 menu->menuAction()->setVisible(anythingVisible);
603 }
604
605 return anythingVisible;
606 }
607
608
614 // Set up the list of filters that are default with this dialog.
615 QStringList filterList;
616 filterList.append("List Files (*.lis)");
617 filterList.append("Text Files (*.txt)");
618 filterList.append("All files (*)");
619
620 QDir directory = m_lastOpenedFile.dir();
621
622 QString selected = QFileDialog::getOpenFileName(this, "Open Cube List",
623 directory.path(), filterList.join(";;"));
624
625 if (selected != "") {
626 m_lastOpenedFile = QFileInfo(selected);
627 TextFile fileList((QString) selected);
628
629 QStringList filesInList;
630 QString line;
631
632 while(fileList.GetLine(line)) {
633 filesInList.append(line);
634 }
635
636 if (filesInList.empty()) {
637 IString msg = "No files were found inside the file list";
638 throw IException(IException::Unknown, msg, _FILEINFO_);
639 }
640
641 openFiles(filesInList);
642 }
643 }
644
645
652 void MosaicMainWindow::readSettings(QSize defaultSize) {
653 MainWindow::readSettings(defaultSize);
654 }
655
656
657 void MosaicMainWindow::openFiles(QStringList cubeNames) {
658 // Create a mosaic widget if we don't have one
659 if (!cubeNames.empty()) {
660 displayController();
661 }
662
663 if (m_mosaicController)
664 m_mosaicController->openImages(cubeNames);
665 }
666
667
677
678
683 if (m_mosaicController) {
684 QString fn = QFileDialog::getSaveFileName(this, "Save Project",
685 QDir::currentPath() + "/untitled.mos",
686 "Mosaic (*.mos)");
687 if (fn.isEmpty()) return;
688
689 m_mosaicController->saveProject(fn);
690 m_filename = fn;
691 }
692 }
693
694
700 if (m_filename == "") {
702 }
703 else {
704 m_mosaicController->saveProject(m_filename);
705 }
706 }
707
708
714 void MosaicMainWindow::loadProject() {
715 QString fn = QFileDialog::getOpenFileName(this, "Load Project",
716 QDir::currentPath(),
717 "Mosaic (*.mos)");
718
719 if (!fn.isEmpty()) {
720 closeMosaic();
721
722 m_lastOpenedFile = QFileInfo(fn);
723 loadProject(fn);
724 }
725 }
726
727
728 void MosaicMainWindow::loadProject(QString fn) {
729 if (!fn.isEmpty()) {
730 createController();
731 displayController();
732
733 if (m_mosaicController)
734 m_mosaicController->readProject(fn);
735
736 m_filename = fn;
737 }
738 }
739
740
741 void MosaicMainWindow::closeMosaic() {
742 if (m_mosaicController) {
743 QAction *actionRequiringOpen = NULL;
744 foreach(actionRequiringOpen, m_actionsRequiringOpen) {
745 actionRequiringOpen->setEnabled(false);
746 }
747
748 QAction *actionRequiringClosed = NULL;
749 foreach(actionRequiringClosed, m_actionsRequiringClosed) {
750 actionRequiringClosed->setEnabled(true);
751 }
752
753 m_mosaicController->saveSettings(m_settings);
754 delete m_mosaicController;
755 m_mosaicController = NULL;
756
757 m_filename = "";
758 m_controllerVisible = false;
759 }
760
761 createController();
762 displayController();
763 }
764}
Base class for the Qisis main windows.
Definition MainWindow.h:24
virtual void readSettings(QSize defaultSize=QSize())
This method ensure that the settings get written even if the Main window was only hidden,...
void openList()
Opens a list of cube files instead of one at a time.
void setupMenus()
Sets up the menus on the menu bar for the qmos window.
void saveProjectAs()
Allows the user to save a project file.
void open()
Calles MosaicWidget's open method which opens a cube file and displays the footprint in the graphics ...
void readSettings(QSize defaultSize=QSize(800, 600))
This overriden method is called from the constructor so that when the Mosaicmainwindow is created,...
bool eventFilter(QObject *o, QEvent *e)
This event filter is installed in the constructor.
void saveSettings2()
This overriden method is called when the MosaicMainWindow is closed or hidden to write the size and l...
void saveProject()
Called from the file menu to save a project file.
Provides access to sequential ASCII stream I/O.
Definition TextFile.h:38
bool GetLine(QString &line, const bool skipComments=true)
Gets next line from file.
Definition TextFile.cpp:411
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16