27 #include <QApplication>
28 #include <QDockWidget>
29 #include <QGridLayout>
34 #include <QStringList>
35 #include <QXmlStreamWriter>
38 #include <QMessageBox>
40 #include "ChipViewportsWidget.h"
43 #include "CnetEditorWidget.h"
46 #include "ControlList.h"
49 #include "ControlPointEditWidget.h"
52 #include "ExportControlNetWorkOrder.h"
53 #include "ExportImagesWorkOrder.h"
57 #include "HistoryTreeWidget.h"
64 #include "ImageFileListWidget.h"
66 #include "MatrixSceneWidget.h"
68 #include "MosaicSceneWidget.h"
80 #include "SensorInfoWidget.h"
83 #include "TargetInfoWidget.h"
85 #include "WarningTreeWidget.h"
88 #include "XmlStackedHandler.h"
89 #include "XmlStackedHandlerReader.h"
108 "Could not create directory because Project could not be created.",
129 createWorkOrder<SetActiveImageListWorkOrder>();
130 createWorkOrder<SetActiveControlWorkOrder>();
131 createWorkOrder<CnetEditorViewWorkOrder>();
132 createWorkOrder<CubeDnViewWorkOrder>();
133 createWorkOrder<Footprint2DViewWorkOrder>();
134 createWorkOrder<MatrixViewWorkOrder>();
135 createWorkOrder<SensorGetInfoWorkOrder>();
136 createWorkOrder<RemoveImagesWorkOrder>();
137 createWorkOrder<TargetGetInfoWorkOrder>();
138 createWorkOrder<ImageFileListViewWorkOrder>();
155 "Could not create directory because work orders are corrupt.",
265 QMenu *fileMenu =
new QMenu();
271 openProjectAction->setIcon(QIcon(
":open") );
272 fileMenu->addAction(openProjectAction);
276 QMenu *recentProjectsMenu = fileMenu->addMenu(
"&Recent Projects");
279 for (
int i = 0; i < nRecentProjects; i++) {
281 if (!projectFileName.fileExists() )
293 recentProjectsMenu->addAction(openRecentProjectAction);
296 fileMenu->addSeparator();
299 saveAction->setShortcut(Qt::Key_S | Qt::CTRL);
300 saveAction->setIcon( QIcon(
":save") );
301 connect(
project()->undoStack(), SIGNAL( cleanChanged(
bool) ),
302 saveAction, SLOT( setDisabled(
bool) ) );
303 fileMenu->addAction(saveAction);
307 saveAsAction->setIcon(QIcon(
":saveAs"));
308 fileMenu->addAction(saveAsAction);
311 fileMenu->addSeparator();
313 QMenu *importMenu = fileMenu->addMenu(
"&Import");
318 QMenu *exportMenu = fileMenu->addMenu(
"&Export");
322 fileMenu->addSeparator();
329 QMenu *projectMenu =
new QMenu();
347 QMenu *fileMenu = menuBar->findChild<QMenu *>(
"fileMenu");
353 openProjectAction->setIcon(QIcon(
":open") );
354 fileMenu->addAction(openProjectAction);
356 QMenu *recentProjectsMenu = fileMenu->addMenu(
"Recent P&rojects");
358 for (
int i = 0; i < nRecentProjects; i++) {
360 if (!projectFileName.fileExists() )
372 recentProjectsMenu->addAction(openRecentProjectAction);
375 fileMenu->addSeparator();
377 fileMenu->addSeparator();
382 saveAction->setShortcut(Qt::Key_S | Qt::CTRL);
383 saveAction->setIcon( QIcon(
":save") );
385 connect(
project()->undoStack(), SIGNAL( cleanChanged(
bool) ),
386 saveAction, SLOT( setDisabled(
bool) ) );
388 fileMenu->addAction(saveAction);
390 addAction->setIcon(QIcon(
":saveAs") );
391 fileMenu->addAction(addAction);
393 fileMenu->addSeparator();
397 QMenu *importMenu = fileMenu->addMenu(
"&Import");
402 QMenu *exportMenu = fileMenu->addMenu(
"&Export");
407 fileMenu->addSeparator();
411 fileMenu->addSeparator();
414 QMenu *projectMenu = menuBar->findChild<QMenu *>(
"projectMenu");
472 FileName configFile(
"$HOME/.Isis/" + QApplication::applicationName() +
"/" + title +
".config");
477 QGridLayout *resultLayout =
new QGridLayout;
478 result->setLayout(resultLayout);
482 QMenuBar *menuBar =
new QMenuBar;
483 resultLayout->addWidget(menuBar, row, 0, 1, 2);
488 resultLayout->addWidget(mainWidget, row, 0, 1, 2);
493 QMapIterator< QAction *, QList< QString > > actionMapIterator(actionMap);
497 while ( actionMapIterator.hasNext() ) {
498 actionMapIterator.next();
499 QAction *actionToAdd = actionMapIterator.key();
502 QMenu *menuToPutActionInto = NULL;
504 if ( location.count() ) {
505 QString topLevelMenuTitle = location.takeFirst();
506 if (!topLevelMenus[topLevelMenuTitle]) {
507 topLevelMenus[topLevelMenuTitle] = menuBar->addMenu(topLevelMenuTitle);
510 menuToPutActionInto = topLevelMenus[topLevelMenuTitle];
513 foreach (QString menuName, location) {
514 bool foundSubMenu =
false;
515 foreach (
QAction *possibleSubMenu, menuToPutActionInto->actions() ) {
517 possibleSubMenu->menu() && possibleSubMenu->menu()->title() == menuName) {
519 menuToPutActionInto = possibleSubMenu->menu();
524 menuToPutActionInto = menuToPutActionInto->addMenu(menuName);
528 menuToPutActionInto->addAction(actionToAdd);
531 QTabWidget *treeViews =
new QTabWidget;
532 treeViews->addTab( mainWidget->pointTreeView(), tr(
"Point View") );
533 treeViews->addTab( mainWidget->serialTreeView(), tr(
"Serial View") );
534 treeViews->addTab( mainWidget->connectionTreeView(), tr(
"Connection View") );
535 resultLayout->addWidget(treeViews, row, 0, 1, 1);
537 QTabWidget *filterViews =
new QTabWidget;
538 filterViews->addTab( mainWidget->pointFilterWidget(), tr(
"Filter Points and Measures") );
539 filterViews->addTab( mainWidget->serialFilterWidget(), tr(
"Filter Images and Points") );
540 filterViews->addTab( mainWidget->connectionFilterWidget(), tr(
"Filter Connections") );
541 resultLayout->addWidget(filterViews, row, 1, 1, 1);
544 connect( result, SIGNAL( destroyed(
QObject *) ),
549 result->setWindowTitle(title);
550 result->setObjectName(title);
552 emit newWidgetAvailable(result);
566 connect( result, SIGNAL( destroyed(
QObject *) ),
569 result->setWindowTitle(
"Cube DN View");
572 emit newWidgetAvailable(result);
577 connect(result, SIGNAL(modifyControlPoint(
ControlPoint *)),
580 connect(result, SIGNAL(deleteControlPoint(
ControlPoint *)),
583 connect(result, SIGNAL(createControlPoint(
double,
double,
Cube *,
bool)),
584 this, SLOT(createControlPoint(
double,
double,
Cube *,
bool)));
589 connect(
this, SIGNAL(controlPointAdded(QString)), result, SIGNAL(controlPointAdded(QString)));
610 connect( result, SIGNAL( destroyed(
QObject *) ),
613 emit newWidgetAvailable(result);
618 connect(result, SIGNAL(modifyControlPoint(
ControlPoint *)),
621 connect(result, SIGNAL(deleteControlPoint(
ControlPoint *)),
624 connect(result, SIGNAL(createControlPoint(
double,
double)),
625 this, SLOT(createControlPoint(
double,
double)));
630 connect(
this, SIGNAL(controlPointAdded(QString)), result, SIGNAL(controlPointAdded(QString)));
660 result->setWindowTitle(tr(
"Control Point Editor"));
661 result->setObjectName(result->windowTitle());
664 if (activeControl == NULL) {
666 QString message =
"No active control network chosen. Choose active control network on "
668 QMessageBox::critical(qobject_cast<QWidget *>(parent()),
"Error", message);
673 if (!
project()->activeImageList()->serialNumberList()) {
674 QString message =
"No active image list chosen. Choose an active image list on the project "
676 QMessageBox::critical(qobject_cast<QWidget *>(parent()),
"Error", message);
680 project()->activeImageList()->serialNumberList());
682 m_controlPointEditViewWidget = result;
684 connect(result, SIGNAL(destroyed(
QObject *)),
686 emit newWidgetAvailable(result);
691 m_chipViewports->setWindowTitle(tr(
"ChipViewport View"));
692 m_chipViewports->setObjectName(m_chipViewports->windowTitle());
693 m_chipViewports->setSerialNumberList(
project()->activeImageList()->serialNumberList());
694 m_chipViewports->setControlNet(activeControl->
controlNet(), activeControl->
fileName());
695 emit newWidgetAvailable(m_chipViewports);
703 this, SIGNAL(controlPointAdded(QString)));
716 connect(result, SIGNAL(destroyed(
QObject *)),
this, SLOT(cleanupchipViewportWidges()));
717 m_controlPointChipViews.append(result);
718 result->setWindowTitle(tr(
"ChipViewport View %1").arg(m_controlPointChipViews.count()));
719 result->setObjectName(result->windowTitle());
720 emit newWidgetAvailable(result);
734 connect( result, SIGNAL( destroyed(
QObject *) ),
740 result->setObjectName( result->windowTitle() );
742 emit newWidgetAvailable(result);
755 connect( result, SIGNAL( destroyed(
QObject *) ),
760 result->setWindowTitle( tr(
"%1").arg(target->displayProperties()->displayName() ) );
761 result->setObjectName( result->windowTitle() );
763 emit newWidgetAvailable(result);
776 connect( result, SIGNAL( destroyed(
QObject *) ),
781 result->setWindowTitle( tr(
"%1").arg(camera->displayProperties()->displayName() ) );
782 result->setObjectName( result->windowTitle() );
784 emit newWidgetAvailable(result);
798 connect( result, SIGNAL( destroyed(
QObject *) ),
804 result->setObjectName( result->windowTitle() );
806 emit newWidgetAvailable(result);
879 delete m_controlPointEditViewWidget;
880 m_controlPointEditViewWidget = NULL;
936 results.append(widget);
951 results.append(widget);
966 results.append(widget);
981 results.append(widget);
996 results.append(widget);
1011 results.append(view);
1026 results.append(widget);
1038 return m_controlPointEditViewWidget;
1044 return m_chipViewports;
1081 return project()->undoStack()->createRedoAction(
this);
1090 return project()->undoStack()->createUndoAction(
this);
1099 xmlReader->pushContentHandler(
new XmlHandler(
this) );
1113 stream.writeStartElement(
"directory");
1116 stream.writeStartElement(
"fileListWidgets");
1119 fileListWidget->
save(stream,
project(), newProjectRoot);
1122 stream.writeEndElement();
1127 stream.writeStartElement(
"footprintViews");
1130 footprint2DViewWidget->mosaicSceneWidget()->save(stream,
project(), newProjectRoot);
1133 stream.writeEndElement();
1138 stream.writeStartElement(
"cubeDnViews");
1141 cubeDnView->save(stream,
project(), newProjectRoot);
1144 stream.writeEndElement();
1147 stream.writeEndElement();
1183 const QString &qName,
const QXmlAttributes &atts) {
1184 bool result = XmlStackedHandler::startElement(namespaceURI, localName, qName, atts);
1187 if (localName ==
"footprint2DView") {
1188 m_directory->addFootprint2DView()->mosaicSceneWidget()->load(reader());
1190 else if (localName ==
"imageFileList") {
1191 m_directory->addImageFileListView()->load(reader());
1193 else if (localName ==
"cubeDnView") {
1194 m_directory->addCubeDnView()->load(reader(), m_directory->project());
1272 foreach (singleWidgetPairing, actionPairings) {
1273 QString widgetTitle = singleWidgetPairing.first;
1276 foreach (
QAction *widgetAction, widgetActions) {
1278 QString actionText = widgetAction->text();
1280 restructuredData[actionText].append( qMakePair(widgetTitle, widgetAction) );
1282 if ( !sortedActionTexts.contains(actionText) ) {
1283 sortedActionTexts.append(actionText);
1288 if ( !sortedActionTexts.isEmpty() && !sortedActionTexts.last().isEmpty() ) {
1289 sortedActionTexts.append(
"");
1295 if ( sortedActionTexts.count() && sortedActionTexts.last().isEmpty() ) {
1296 sortedActionTexts.removeLast();
1299 foreach (QString actionText, sortedActionTexts) {
1300 if ( actionText.isEmpty() ) {
1301 results.append(NULL);
1308 if (actions.count() == 1) {
1309 QAction *finalAct = actions.first().second;
1310 QString widgetTitle = actions.first().first;
1312 finalAct->setText( tr(
"%1 on %2").arg(actionText).arg(widgetTitle) );
1313 results.append(finalAct);
1318 QMenu *menu =
new QMenu;
1319 menuAct->setMenu(menu);
1324 foreach (widgetTitleAndAction, actions) {
1325 QString widgetTitle = widgetTitleAndAction.first;
1326 QAction *action = widgetTitleAndAction.second;
1328 action->setText(widgetTitle);
1329 actionsInsideMenu.append(action);
1336 foreach (
QAction *actionInMenu, actionsInsideMenu) {
1337 connect( allAct, SIGNAL( triggered() ),
1338 actionInMenu, SIGNAL( triggered() ) );
1339 menu->addAction(actionInMenu);
1342 menu->addSeparator();
1343 menu->addAction(allAct);
1345 results.append(menuAct);
1363 return lhs->text().localeAwareCompare( rhs->text() ) < 0;
1375 m_controlPointEdit, SLOT(loadControlPoint(
ControlPoint *)));
1376 connect(m_cnetEditor, SIGNAL(controlPointCreated(
ControlPoint *)),
1377 m_controlPointEditWidget, SLOT(setEditPoint(
ControlPoint *)));
1381 m_cnetEditor, SLOT( deleteControlPoint(QString) ) );
1383 connect( m_cnetEditor, SIGNAL( controlPointDeleted() ),
1389 connect(m_controlPointEditWidget, SIGNAL(controlPointChanged(QString)),
1391 connect(m_controlPointEditWidget, SIGNAL(controlPointAdded(QString)),
1398 void Directory::modifyControlPoint(
ControlPoint *controlPoint) {
1401 addControlPointEditView();
1407 void Directory::deleteControlPoint(
ControlPoint *controlPoint) {
1410 addControlPointEditView();
1416 void Directory::createControlPoint(
double latitude,
double longitude,
Cube *cube,
1417 bool isGroundSource) {
1420 addControlPointEditView();
1424 latitude, longitude, cube, isGroundSource);
This represents an ISIS control net in a project-based GUI interface.
~XmlHandler()
The Destructor for Directory::XmlHandler.
QList< QAction * > editMenuActions()
Get the list of actions that the Directory can provide for the edit menu.
QList< MatrixSceneWidget * > matrixViews()
Accessor for the list of MatrixSceneWidgets currently available.
QList< QAction * > projectMenuActions()
Get the list of actions that the Directory can provide for the project menu.
QList< QAction * > toolPadActions()
Get the list of actions that the Directory can provide for the Tool Pad.
QPointer< WorkOrder > m_saveProjectWorkOrder
The Save Project WorkOrder.
QList< QAction * > activeToolBarActions()
Get the list of actions that the Directory can provide for the active Tool Bar.
The main project for cnetsuite.
QList< QPointer< SensorInfoWidget > > m_sensorInfoWidgets
List of SensorInfoWidgets.
void save(QXmlStreamWriter &stream, FileName newProjectRoot) const
Save the directory to an XML file.
void cleanupTargetInfoWidgets()
Removes pointers to deleted TargetInfoWidget objects.
void cleanupFileListWidgets()
Reomoves pointers to deleted ImageFileListWidget objects.
File name manipulation and expansion.
QList< ImageFileListWidget * > imageFileListViews()
Accessor for the list of ImageFileListWidgets currently available.
QStringList recentProjectsList()
Public accessor for the list of recent projects.
~Directory()
The Destructor.
virtual void setModel(ProjectItemModel *model)
Sets the model used by the view.
CnetEditorWidget * addCnetEditorView(Control *network)
Add the widget for the cnet editor view to the window.
QPointer< WorkOrder > m_importControlNetWorkOrder
The import ControlNetwork WorkOrder.
TargetInfoWidget * addTargetInfoView(TargetBodyQsp target)
Add target body data view widget to the window.
QList< QAction * > m_settingsMenuActions
List of menu settings actions.
MatrixSceneWidget * addMatrixView()
Add the matrix view widget to the window.
QList< QAction * > m_helpMenuActions
List of help menu actions.
void cleanupCnetEditorViewWidgets()
Removes pointers to deleted CnetEditorWidget objects.
void showWarning(QString text)
Displays a Warning.
Directory * m_directory
Pointer to a Directory which is set by the XmlHandler class.
static bool actionTextLessThan(QAction *lhs, QAction *rhs)
This is for determining the ordering of the descriptive text of for the actions.
QPointer< WorkOrder > m_runJigsawWorkOrder
The Run Jigsaw WorkOrder.
QList< QAction * > viewMenuActions()
Get the list of actions that the Directory can provide for the view menu.
QList< QPointer< CubeDnView > > m_cubeDnViewWidgets
List of CubeDnCiew obs.
QPointer< ProjectItemModel > m_projectItemModel
Pointer to the ProjectItemModel.
History Widget for cnetsuite.
void populateMainMenu(QMenuBar *)
This method sets up the main menu at the top of the window (File, Settings, ...)
This is a child of class WorkOrder which is used for anything that performs an action in a Project...
ControlPointEditView * controlPointEditView()
Gets the ControlPointEditWidget associated with the Directory.
void cleanupMatrixViewWidgets()
Removes pointers to deleted MatrixSceneWidget objects.
This error is for when a programmer made an API call that was illegal.
void setRecentProjectsList(QStringList recentProjects)
Add recent projects to the recent projects list.
Control * activeControl()
Return the Active Control (control network)
QList< TargetInfoWidget * > targetInfoViews()
Accessor for the list of TargetInfoWidgets currently available.
CubeDnView * addCubeDnView()
Add the qview workspace to the window.
Project * project() const
Gets the Project for this directory.
void updateRecentProjects(Project *project)
Adds a new Project object to the list of recent projects if it has not already been added...
View for editing a single ControlPoint.
QList< QAction * > m_projectMenuActions
List of project menu actions.
QList< QAction * > permToolBarActions()
Get the list of actions that the Directory can provide for the permanent Tool Bar.
Provides access to data stored in a Project through Qt's model-view framework.
QAction * undoAction()
Creates an Action to undo the last action.
QPointer< WorkOrder > m_openProjectWorkOrder
The Open Project WorkOrder.
QList< QAction * > m_fileMenuActions
List of file menu actions.
void load(XmlStackedHandlerReader *xmlReader)
Loads the Directory from an XML file.
QList< Footprint2DView * > footprint2DViews()
Accessor for the list of Footprint2DViews currently available.
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
The XML reader invokes this method at the start of every element in the XML document.
QList< QAction * > settingsMenuActions()
Get the list of actions that the Directory can provide for the settings menu.
QPointer< WorkOrder > m_importShapesWorkOrder
The import shapes WorkOrder.
QList< QAction * > fileMenuActions()
Get the list of actions that the Directory can provide for the file menu.
Directory(QObject *parent=0)
The Constructor.
ProjectItemModel * model()
Gets the ProjectItemModel for this directory.
Parent class for anything that performs an action in Project.
ProjectItemTreeView * addProjectItemTreeView()
Adds a ProjectItemTreeView to the window.
QList< QAction * > m_editMenuActions
List of edit menu actions.
QList< SensorInfoWidget * > sensorInfoViews()
Accessor for the list of SensorInfoWidgets currently available.
QString displayName() const
Returns the display name.
QList< QPointer< Footprint2DView > > m_footprint2DViewWidgets
List of Footprint2DView objs.
QAction * redoAction()
Creates an Action to redo the last action.
ControlPointEditWidget * controlPointEditWidget() const
Returns the ControlPointEditWidget.
QSharedPointer< TargetBody > TargetBodyQsp
Defines A smart pointer to a TargetBody obj.
QList< QProgressBar * > progressBars()
Gets the ControlNetEditor associated with this the Directory.
#define _FILEINFO_
Macro for the filename and line number.
QPointer< WorkOrder > m_saveProjectAsWorkOrder
The Save Project As WorkOrder.
A ProjectItemTreeView displays items from a ProjectItemProxyModel in a tree structure.
void setWarningContainer(QDockWidget *warningContainer)
Set up the warning info in the warning dockable widget.
QList< CubeDnView * > cubeDnViews()
Accessor for the list of CubeDnViews currently available.
void setHistoryContainer(QDockWidget *historyContainer)
Set up the history info in the history dockable widget.
void cleanupCubeDnViewWidgets()
Removes pointers to deleted CubeDnView objects.
QString fileName() const
Access the name of the control network file associated with this Control.
QList< QPointer< CnetEditorWidget > > m_cnetEditorViewWidgets
List of CnetEditorWidgets.
ControlNet * controlNet()
Open and return a pointer to the ControlNet for this Control.
QPointer< WorkOrder > m_openRecentProjectWorkOrder
The Open Recent Project WorkOrder.
QPointer< Project > m_project
Pointer to the Project.
QList< QAction * > m_toolPadActions
List of ToolPad actions.
XmlHandler(Directory *directory)
This function sets the Directory pointer for the Directory::XmlHandler class.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
QWidget * warningWidget()
Returns a pointer to the warning widget.
ControlDisplayProperties * displayProperties()
Access a pointer to the display properties for the control network.
QPointer< HistoryTreeWidget > m_historyTreeWidget
Pointer to the HistoryTreeWidget.
QSharedPointer< GuiCamera > GuiCameraQsp
GuiCameraQsp Represents a smart pointer to a GuiCamera object.
QList< QAction * > m_permToolBarActions
List of perm ToolBar actions.
QPointer< WorkOrder > m_renameProjectWorkOrder
The Rename Project WorkOrder.
ImageFileListWidget * addImageFileListView()
Add an imageFileList widget to the window.
QList< QAction * > m_viewMenuActions
List of view menu actions.
View that displays cubes in a QView-like way.
QPointer< WarningTreeWidget > m_warningTreeWidget
Pointer to the WarningTreeWidget.
void updateControlNetEditConnections()
Updates the SIGNAL/SLOT connections for the cotrol net editor.
SensorInfoWidget * addSensorInfoView(GuiCameraQsp camera)
Add sensor data view widget to the window.
QList< QAction * > helpMenuActions()
Get the list of actions that the Directory can provide for the help menu.
Footprint2DView * addFootprint2DView()
Add the qmos view widget to the window.
QList< QPointer< MatrixSceneWidget > > m_matrixViewWidgets
List of MatrixSceneWidgets.
QPointer< WorkOrder > m_exportImagesWorkOrder
The export images WorkOrder.
QPointer< WorkOrder > m_exportControlNetWorkOrder
The export ControlNetwork WorkOrder.
QList< QPointer< TargetInfoWidget > > m_targetInfoWidgets
List of TargetInfoWidgets.
QPointer< WorkOrder > m_importImagesWorkOrder
The import images WorkOrder.
QList< QAction * > m_activeToolBarActions
List of active ToolBar actions.
void cleanupFootprint2DViewWidgets()
Removes pointers to deleted Footprint2DView objects.
void cleanupControlPointEditViewWidget()
Delete the ControlPointEditWidget and set it's pointer to NULL.
void cleanupSensorInfoWidgets()
Removes pointers to deleted SensorInfoWidget objects.
QStringList m_recentProjects
List of the names of recent projects.
QList< QPointer< WorkOrder > > m_workOrders
List of WorkOrders.
his enables stack-based XML parsing of XML files.
QString projectRoot() const
Get the top-level folder of the project.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
QList< QPointer< ImageFileListWidget > > m_fileListWidgets
List of ImageFileListWidgets.
void initializeActions()
Initializes the actions that the Directory can provide to a main window.
static QList< QAction * > restructureActions(QList< QPair< QString, QList< QAction * > > >)
Reformat actionPairings to be user friendly for use in menus.
QPointer< WorkOrder > m_closeProjectWorkOrder
The Close Project WorkOrder.
IO Handler for Isis Cubes.
QList< CnetEditorWidget * > cnetEditorViews()
Returns a list of all the control network views for this directory.