Loading [MathJax]/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
CnetEditorView.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "IsisDebug.h"
10 
11 #include "CnetEditorView.h"
12 
13 #include <QAction>
14 #include <QGridLayout>
15 #include <QList>
16 #include <QMap>
17 #include <QMapIterator>
18 #include <QMenu>
19 #include <QMenuBar>
20 #include <QSize>
21 #include <QSizePolicy>
22 #include <QString>
23 #include <QTabWidget>
24 #include <QToolBar>
25 #include <QtXml>
26 
27 #include "Control.h"
28 #include "ControlNet.h"
29 #include "CnetEditorWidget.h"
30 #include "Directory.h"
31 #include "FileName.h"
32 #include "Project.h"
33 #include "XmlStackedHandlerReader.h"
34 #include "ProjectItemViewMenu.h"
35 
36 namespace Isis {
40  CnetEditorView::CnetEditorView(Directory *directory, Control *control, FileName configFile,
41  QWidget *parent) : AbstractProjectItemView(parent) {
42 
43  // TODO: This layout should be inside of the cnet editor widget, but I put it here to not
44  // conflict with current work in the cnet editor widget code.
45  //QWidget *result = new QWidget;
46 
47  QWidget *centralWidget = new QWidget;
48  setCentralWidget(centralWidget);
49  QGridLayout *resultLayout = new QGridLayout;
50  centralWidget->setLayout(resultLayout);
51 
52  m_cnetEditorWidget = new CnetEditorWidget(control, configFile.expanded());
53  m_control = control;
54 
55  resultLayout->addWidget(m_cnetEditorWidget, 0, 0, 1, 2);
56 
57  QTabWidget *treeViews = new QTabWidget;
58  treeViews->addTab( m_cnetEditorWidget->pointTreeView(), tr("Point View") );
59  treeViews->addTab( m_cnetEditorWidget->serialTreeView(), tr("Serial View") );
60  treeViews->addTab( m_cnetEditorWidget->connectionTreeView(), tr("Connection View") );
61  resultLayout->addWidget(treeViews, 1, 0, 1, 1);
62 
63  QTabWidget *filterViews = new QTabWidget;
64  filterViews->addTab( m_cnetEditorWidget->pointFilterWidget(), tr("Filter Points and Measures") );
65  filterViews->addTab( m_cnetEditorWidget->serialFilterWidget(), tr("Filter Images and Points") );
66  filterViews->addTab( m_cnetEditorWidget->connectionFilterWidget(), tr("Filter Connections") );
67  resultLayout->addWidget(filterViews, 1, 1, 1, 1);
68 
69  createMenus();
71 
72  // Store the actions for easy enable/disable.
73  foreach (QAction *action, m_permToolBar->actions()) {
74  addAction(action);
75  }
76  // On default, actions are disabled until the cursor enters the view.
78  }
79 
84 
85  delete m_cnetEditorWidget;
86  delete m_permToolBar;
87  delete m_tablesMenu;
88 
89  m_tablesMenu = 0;
90  m_permToolBar = 0;
91  }
92 
98  QMap< QAction *, QList< QString > > actionMap = m_cnetEditorWidget->menuActions();
99  QMapIterator< QAction *, QList< QString > > actionMapIter(actionMap);
100 
101  m_tablesMenu = new ProjectItemViewMenu("&Tables");
102  connect(m_tablesMenu, SIGNAL(menuClosed()), this, SLOT(disableActions()));
103  menuBar()->addMenu(m_tablesMenu);
104 
105  while ( actionMapIter.hasNext() ) {
106  actionMapIter.next();
107  QAction *actionToAdd = actionMapIter.key();
108 
109  // Skip the "What's This?" action because it is in the main help menu of IPCE
110  if (actionToAdd->text() == "What's This?") {
111  continue;
112  }
113  m_tablesMenu->addAction(actionToAdd);
114  }
115  }
116 
117 
124  m_permToolBar = addToolBar("Standard Tools");
125  m_permToolBar->setObjectName("permToolBar");
126  m_permToolBar->setIconSize(QSize(22, 22));
127 
129  actionMap = m_cnetEditorWidget->toolBarActions();
130  QMapIterator< QString, QList< QAction * > > actionIter(actionMap);
131 
132  while (actionIter.hasNext()) {
133  actionIter.next();
134  QString objName = actionIter.key();
135  QList< QAction * > actionList = actionIter.value();
136  foreach (QAction *action, actionList) {
137  m_permToolBar->addAction(action);
138  }
139  }
140  }
141 
142 
150  void CnetEditorView::leaveEvent(QEvent *event) {
151  if (!m_tablesMenu->isVisible()) {
152  disableActions();
153  }
154  }
155 
156 
164  return m_cnetEditorWidget;
165  }
166 
167 
174  return m_control;
175  }
176 
177 
184  xmlReader->pushContentHandler(new XmlHandler(this));
185  }
186 
187 
195  void CnetEditorView::save(QXmlStreamWriter &stream, Project *, FileName) const {
196 
197  stream.writeStartElement("cnetEditorView");
198  stream.writeAttribute("objectName", objectName());
199  stream.writeAttribute("id", m_control->id());
200  stream.writeEndElement();
201  }
202 
203 
210  m_cnetEditorView = cnetEditorView;
211  }
212 
213 
218  delete m_cnetEditorView;
219  m_cnetEditorView = NULL;
220  }
221 
222 
234  bool CnetEditorView::XmlHandler::startElement(const QString &namespaceURI,
235  const QString &localName, const QString &qName, const QXmlAttributes &atts) {
236 
237  bool result = XmlStackedHandler::startElement(namespaceURI, localName, qName, atts);
238  return result;
239  }
240 
241 
252  bool CnetEditorView::XmlHandler::endElement(const QString &namespaceURI,
253  const QString &localName, const QString &qName) {
254 
255  bool result = XmlStackedHandler::endElement(namespaceURI, localName, qName);
256  return result;
257  }
258 }
QWidget
Isis::CnetEditorView::createMenus
void createMenus()
Uses the actions created by CnetEditorWidget, creates the tables menu, and puts the actions into the ...
Definition: CnetEditorView.cpp:97
Isis::Directory
Definition: Directory.h:271
Isis::CnetEditorView::createToolBars
void createToolBars()
Uses and adds the actions created by CnetEditorWidget to the view's toolbars Right now,...
Definition: CnetEditorView.cpp:123
Isis::AbstractProjectItemView
AbstractProjectItemView is a base class for views of a ProjectItemModel in Qt's model-view framework.
Definition: AbstractProjectItemView.h:79
QList< QAction * >
Project.h
Isis::CnetEditorView::XmlHandler::m_cnetEditorView
CnetEditorView * m_cnetEditorView
The view we are working with.
Definition: CnetEditorView.h:105
Isis::CnetEditorView::XmlHandler::startElement
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Placeholder for later serialization of CnetEditorViews.
Definition: CnetEditorView.cpp:234
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::XmlStackedHandlerReader::pushContentHandler
virtual void pushContentHandler(XmlStackedHandler *newHandler)
Push a contentHandler and maybe continue parsing...
Definition: XmlStackedHandlerReader.cpp:55
Isis::CnetEditorView::cnetEditorWidget
CnetEditorWidget * cnetEditorWidget()
Returns the cnetEditorWidget.
Definition: CnetEditorView.cpp:163
Isis::Control
This represents an ISIS control net in a project-based GUI interface.
Definition: Control.h:66
Isis::CnetEditorWidget
This widget provides full editing, filtering and viewing capabilities for the raw data in a control n...
Definition: CnetEditorWidget.h:96
Isis::XmlStackedHandlerReader
Manage a stack of content handlers for reading XML files.
Definition: XmlStackedHandlerReader.h:30
Isis::Project
The main project for ipce.
Definition: Project.h:289
Isis::CnetEditorView::m_permToolBar
QToolBar * m_permToolBar
The permanent tool bar.
Definition: CnetEditorView.h:112
Isis::FileName::expanded
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:196
Isis::CnetEditorView::load
void load(XmlStackedHandlerReader *xmlReader)
This method pushes a new XmlHandler into the parser stack.
Definition: CnetEditorView.cpp:183
Isis::CnetEditorView::m_tablesMenu
ProjectItemViewMenu * m_tablesMenu
View menu for storing actions.
Definition: CnetEditorView.h:113
Isis::CnetEditorView::~CnetEditorView
~CnetEditorView()
Destructor.
Definition: CnetEditorView.cpp:83
Isis::CnetEditorView::control
Control * control()
@description Returns the Control displayed in the CnetEditorWidget
Definition: CnetEditorView.cpp:173
Isis::CnetEditorView::XmlHandler::~XmlHandler
~XmlHandler()
Destructor.
Definition: CnetEditorView.cpp:217
Isis::CnetEditorView
Ipce view containing the CnetEditorWidget.
Definition: CnetEditorView.h:65
Isis::CnetEditorView::save
void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const
This method saves the Controls object ids to the stream.
Definition: CnetEditorView.cpp:195
Isis::ProjectItemViewMenu
QMenu subclass that overrides the closeEvent.
Definition: ProjectItemViewMenu.h:26
Isis::CnetEditorView::leaveEvent
void leaveEvent(QEvent *event)
Disables actions when cursor leaves the view.
Definition: CnetEditorView.cpp:150
Isis::CnetEditorView::XmlHandler
Definition: CnetEditorView.h:92
Isis::AbstractProjectItemView::disableActions
virtual void disableActions()
Disables toolbars and toolpad actions.
Definition: AbstractProjectItemView.cpp:196
QMap
This is free and unencumbered software released into the public domain.
Definition: CubeIoHandler.h:22
Isis::CnetEditorView::XmlHandler::endElement
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
This method calls XmlStackedHandler's endElement() and dereferences pointers according to the value o...
Definition: CnetEditorView.cpp:252
QAction
Isis::CnetEditorView::CnetEditorView
CnetEditorView(Directory *directory, Control *control, FileName configFile, QWidget *parent=0)
Constructor.
Definition: CnetEditorView.cpp:40
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::CnetEditorView::XmlHandler::XmlHandler
XmlHandler(CnetEditorView *cnetEditorView)
Creates an XmlHandler for cnetEditor.
Definition: CnetEditorView.cpp:209

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 USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:16:16