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

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:24:02