Loading [MathJax]/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
Footprint2DView.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "IsisDebug.h"
10 
11 #include "Footprint2DView.h"
12 
13 #include <QAction>
14 #include <QDockWidget>
15 #include <QDragEnterEvent>
16 #include <QDragMoveEvent>
17 #include <QDropEvent>
18 #include <QItemSelectionModel>
19 #include <QList>
20 #include <QSize>
21 #include <QSizePolicy>
22 #include <QStatusBar>
23 #include <QToolBar>
24 #include <QBoxLayout>
25 #include <QHBoxLayout>
26 #include <QMainWindow>
27 #include <QVBoxLayout>
28 #include <QWidget>
29 #include <QWidgetAction>
30 #include <QXmlStreamWriter>
31 
32 #include "ControlNetTool.h"
33 #include "ControlPoint.h"
34 #include "Cube.h"
35 #include "Directory.h"
36 #include "Image.h"
37 #include "ImageFileListWidget.h"
38 #include "MosaicGraphicsView.h"
39 #include "MosaicSceneWidget.h"
40 #include "MosaicControlNetTool.h"
41 #include "Project.h"
42 #include "ProjectItem.h"
43 #include "ProjectItemModel.h"
44 #include "Shape.h"
45 #include "ToolPad.h"
46 #include "XmlStackedHandlerReader.h"
47 
48 namespace Isis {
55  AbstractProjectItemView(parent) {
56 
57  QStatusBar *statusBar = new QStatusBar(this);
58  m_sceneWidget = new MosaicSceneWidget(statusBar, true, false, directory, this);
59  m_sceneWidget->getScene()->installEventFilter(this);
60  m_sceneWidget->setAcceptDrops(false);
61  MosaicGraphicsView *graphicsView = m_sceneWidget->getView();
62  graphicsView->installEventFilter(this);
63  graphicsView->setAcceptDrops(false);
64 
65  connect( internalModel(), SIGNAL( itemAdded(ProjectItem *) ),
66  this, SLOT( onItemAdded(ProjectItem *) ) );
67  connect( internalModel(), SIGNAL( itemsAdded() ),
68  this, SLOT( onItemsAdded() ) );
69  connect( internalModel(), SIGNAL( itemRemoved(ProjectItem *) ),
70  this, SLOT( onItemRemoved(ProjectItem *) ) );
71 
72  connect(m_sceneWidget, SIGNAL(queueSelectionChanged()),
73  this, SLOT(onQueueSelectionChanged()), Qt::QueuedConnection);
74 
75  // Pass on Signals emitted from ControlNetTool, through the MosaicSceneWidget
76  // TODO 2016-09-09 TLS Design: Use a proxy model instead of signals?
77  connect(m_sceneWidget, SIGNAL(modifyControlPoint(ControlPoint *)),
78  this, SIGNAL(modifyControlPoint(ControlPoint *)));
79 
80  connect(m_sceneWidget, SIGNAL(deleteControlPoint(ControlPoint *)),
81  this, SIGNAL(deleteControlPoint(ControlPoint *)));
82 
83  connect(m_sceneWidget, SIGNAL(createControlPoint(double, double)),
84  this, SIGNAL(createControlPoint(double, double)));
85 
86  connect(m_sceneWidget, SIGNAL(mosCubeClosed(Image *)),
87  this, SLOT(onMosItemRemoved(Image *)));
88 
89  // Pass on redrawMeasure signal from Directory, so the control measures are redrawn on all
90  // the footprints. Connection made in Directory from directory's signal to this signal since
91  // Directory doesn't have access to the scene within the sceneWidget.
92  connect(this, SIGNAL(redrawMeasures()), m_sceneWidget->getScene(), SLOT(update()));
93 
94  setStatusBar(statusBar);
95 
96  m_fileListWidget = new ImageFileListWidget(directory);
97 
98  m_fileListWidget->setWindowTitle( tr("File List") );
99  m_fileListWidget->setObjectName( m_fileListWidget->windowTitle() );
100 
101  m_directory = directory;
102 
103  QDockWidget *imageFileListdock = new QDockWidget( m_fileListWidget->windowTitle() );
104  imageFileListdock->setObjectName(imageFileListdock->windowTitle());
105  imageFileListdock->setFeatures( QDockWidget::DockWidgetFloatable |
106  QDockWidget::DockWidgetMovable);
107 
108  imageFileListdock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
109 
110  imageFileListdock->setWidget(m_fileListWidget);
111 
112  addDockWidget(Qt::LeftDockWidgetArea, imageFileListdock, Qt::Vertical);
113  setCentralWidget(m_sceneWidget);
114 
115  m_permToolBar = addToolBar("Standard Tools");
116  m_permToolBar->setObjectName("permToolBar");
117  m_permToolBar->setIconSize(QSize(22, 22));
118 
119  m_activeToolBar = addToolBar("Active Tool");
120  m_activeToolBar->setObjectName("activeToolBar");
121  m_activeToolBar->setIconSize(QSize(22, 22));
122 
123  m_toolPad = new ToolPad("Tool Pad", 0);
124  m_toolPad->setObjectName("toolPad");
125  addToolBar(Qt::RightToolBarArea, m_toolPad);
126 
127  m_sceneWidget->addToPermanent(m_permToolBar);
129  m_sceneWidget->addTo(m_toolPad);
130 
131  // Store the actions for easy enable/disable.
132  foreach (QAction *action, findChildren<QAction *>()) {
133  addAction(action);
134  }
135  // On default, actions are disabled until the cursor enters the view.
136  disableActions();
137  }
138 
143  delete m_fileListWidget;
144  delete m_permToolBar;
145  delete m_activeToolBar;
146  delete m_toolPad;
147 
148  m_permToolBar = 0;
149  m_activeToolBar = 0;
150  m_toolPad = 0;
151  }
152 
153 
158  return m_sceneWidget;
159  }
160 
161 
166  return m_fileListWidget;
167  }
168 
169 
178  bool Footprint2DView::eventFilter(QObject *watched, QEvent *event) {
179  if (event->type() == QEvent::DragEnter) {
180  dragEnterEvent( static_cast<QDragEnterEvent *>(event) );
181  return true;
182  }
183  else if (event->type() == QEvent::DragMove) {
184  dragMoveEvent( static_cast<QDragMoveEvent *>(event) );
185  return true;
186  }
187  else if (event->type() == QEvent::Drop) {
188  dropEvent( static_cast<QDropEvent *>(event) );
189  return true;
190  }
191 
192  return AbstractProjectItemView::eventFilter(watched, event);
193  }
194 
195 
205  if (!item || (!item->isImage() && !item->isShape())) {
206  return;
207  }
208 
209  Image *image;
210  if (item->isShape()) {
211  image = new Image(item->shape()->cube(), item->shape()->footprint(), item->shape()->id());
212  }
213  else if (item->isImage()) {
214  image = item->image();
215  }
216 
217  m_images.append(image);
218 
219  if (!m_imageItemMap.value(image)) {
220  m_imageItemMap.insert(image, item);
221  }
222  }
223 
224 
232  // This is called once all selected images have been added to proxy model (internalModel())
233  // This is much faster than adding a single image at a time to the scene widget
234  m_sceneWidget->addImages(m_images);
235  m_fileListWidget->addImages(&m_images);
236  }
237 
238 
246  if (image) {
247  ImageList images;
248  images.append(image);
249 
250  m_sceneWidget->removeImages(images);
251  m_fileListWidget->removeImages(&(images));
252 
253  if ( m_imageItemMap.value( image ) ) {
254  m_imageItemMap.remove( image );
255  }
256  }
257  }
258 
259 
267 
268  if (!item) {
269  return;
270  }
271 
272  if (item->isImage()) {
273 
274  ImageList images;
275  images.append(item->image());
276 
277  m_sceneWidget->removeImages(images);
278  m_fileListWidget->removeImages(&(images));
279 
280  if ( m_imageItemMap.value( item->image() ) ) {
281  m_imageItemMap.remove( item->image());
282  }
283  }
284  }
285 
286 
292  ImageList selectedImages = m_sceneWidget->selectedImages();
293 
294  if (selectedImages.isEmpty() ) {
295  return;
296  }
297 
298  Image *currentImage = selectedImages.first();
299 
300  internalModel()->selectionModel()->clear();
301 
302  if ( ProjectItem *item = m_imageItemMap.value(currentImage) ) {
303  internalModel()->selectionModel()->setCurrentIndex(item->index(), QItemSelectionModel::Select);
304  }
305 
306  foreach (Image *image, selectedImages) {
307  if ( ProjectItem *item = m_imageItemMap.value(image) ) {
308  internalModel()->selectionModel()->select(item->index(), QItemSelectionModel::Select);
309  }
310  }
311  }
312 
313 
321  foreach (QAction *action, m_toolPad->actions()) {
322  if (action->toolTip() == "Control Net (c)") {
323  action->setEnabled(value);
324  if (value) {
325  MosaicControlNetTool *cnetTool = static_cast<MosaicControlNetTool *>(action->parent());
326  cnetTool->loadNetwork();
327  }
328  }
329  }
330  }
331 
332 
338  foreach (QAction *action, actions()) {
339  if (action->toolTip() == "Control Net (c)" && !m_directory->project()->activeControl()) {
340  continue;
341  }
342  action->setEnabled(true);
343  }
344  }
345 
346 
352  xmlReader->pushContentHandler( new XmlHandler(this) );
353  }
354 
355 
366  void Footprint2DView::save(QXmlStreamWriter &stream, Project *project,
367  FileName newProjectRoot) const {
368 
369  stream.writeStartElement("footprint2DView");
370  stream.writeAttribute("objectName", objectName());
371 
372  m_fileListWidget->save(stream, project, newProjectRoot);
373  m_sceneWidget->save(stream, project, newProjectRoot);
374 
375  stream.writeEndElement();
376  }
377 
378 
384 
385  m_footprintView = footprintView;
386  }
387 
388 
393  }
394 
395 
411  bool Footprint2DView::XmlHandler::startElement(const QString &namespaceURI, const QString &localName,
412  const QString &qName, const QXmlAttributes &atts) {
413  bool result = XmlStackedHandler::startElement(namespaceURI, localName, qName, atts);
414 
415  if (result) {
416  if (localName == "mosaicScene") {
417  m_footprintView->mosaicSceneWidget()->load(reader());
418  }
419  if (localName == "imageFileList") {
420  m_footprintView->m_fileListWidget->load(reader());
421  }
422  }
423  return result;
424  }
425 
426 
427  bool Footprint2DView::XmlHandler::endElement(const QString &namespaceURI,
428  const QString &localName, const QString &qName) {
429  bool result = XmlStackedHandler::endElement(namespaceURI, localName, qName);
430 
431  return result;
432  }
433 }
Isis::Footprint2DView::XmlHandler::startElement
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.
Definition: Footprint2DView.cpp:411
QWidget
Isis::Footprint2DView::onMosItemRemoved
void onMosItemRemoved(Image *image)
Slot at removes the mosaic item and corresponding image file list item when a cube is closed using th...
Definition: Footprint2DView.cpp:245
Isis::Directory
Definition: Directory.h:271
Isis::AbstractProjectItemView
AbstractProjectItemView is a base class for views of a ProjectItemModel in Qt's model-view framework.
Definition: AbstractProjectItemView.h:79
Isis::Footprint2DView
View for displaying footprints of images in a QMos like way.
Definition: Footprint2DView.h:102
Isis::Footprint2DView::onItemsAdded
void onItemsAdded()
Slot called once all selected images have been added to the proxy model.
Definition: Footprint2DView.cpp:231
Project.h
Isis::ImageFileListWidget::save
void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const
This method saves the FootprintColumns in the project and the settings associated with every column.
Definition: ImageFileListWidget.cpp:626
Isis::ProjectItem::image
Image * image() const
Returns the Image stored in the data of the item.
Definition: ProjectItem.cpp:476
Isis::AbstractProjectItemView::dropEvent
virtual void dropEvent(QDropEvent *event)
Drops the data into the internal model if it can accept the data.
Definition: AbstractProjectItemView.cpp:148
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::ImageFileListWidget::removeImages
void removeImages(ImageList *images)
Removes an imagelist from the FileListWidget.
Definition: ImageFileListWidget.cpp:446
Isis::XmlStackedHandlerReader::pushContentHandler
virtual void pushContentHandler(XmlStackedHandler *newHandler)
Push a contentHandler and maybe continue parsing...
Definition: XmlStackedHandlerReader.cpp:55
Isis::Footprint2DView::onItemAdded
void onItemAdded(ProjectItem *item)
Slot to connect to the itemAdded signal from the model.
Definition: Footprint2DView.cpp:204
Isis::ImageFileListWidget
A colored, grouped cube list.
Definition: ImageFileListWidget.h:64
Isis::ProjectItem::shape
Shape * shape() const
Returns the Shape stored in the data of the item.
Definition: ProjectItem.cpp:496
Isis::ImageFileListWidget::addImages
void addImages(ImageList *images)
This method adds the new images to the tree.
Definition: ImageFileListWidget.cpp:342
Isis::Footprint2DView::onQueueSelectionChanged
void onQueueSelectionChanged()
Slot to connect to the queueSelectionChanged signal from a MosiacSceneWidget.
Definition: Footprint2DView.cpp:291
Isis::ProjectItemModel::selectionModel
QItemSelectionModel * selectionModel()
Returns the internal selection model.
Definition: ProjectItemModel.cpp:93
Isis::MosaicControlNetTool::loadNetwork
void loadNetwork()
Load m_controlNetFile into memory - this will re-load the network if it's already open.
Definition: MosaicControlNetTool.cpp:610
Isis::ImageList::append
void append(Image *const &value)
Appends an image to the image list.
Definition: ImageList.cpp:153
Isis::Footprint2DView::XmlHandler
Definition: Footprint2DView.h:145
Isis::Footprint2DView::Footprint2DView
Footprint2DView(Directory *directory, QWidget *parent=0)
Constructor.
Definition: Footprint2DView.cpp:54
Isis::Shape::footprint
geos::geom::MultiPolygon * footprint()
Get the footprint of this shape (if available).
Definition: Shape.cpp:394
Isis::Footprint2DView::m_permToolBar
QToolBar * m_permToolBar
The permanent tool bar.
Definition: Footprint2DView.h:169
Isis::Footprint2DView::m_activeToolBar
QToolBar * m_activeToolBar
The active tool bar.
Definition: Footprint2DView.h:170
Isis::MosaicSceneWidget
This widget encompasses the entire mosaic scene.
Definition: MosaicSceneWidget.h:153
Isis::Project::activeControl
Control * activeControl()
Return the Active Control (control network)
Definition: Project.cpp:1903
Isis::Directory::project
Project * project() const
Gets the Project for this directory.
Definition: Directory.cpp:1311
Image.h
Isis::Shape::cube
Cube * cube()
Get the Cube * associated with this display property.
Definition: Shape.cpp:324
Isis::ProjectItem::isShape
bool isShape() const
Returns true if an Shape is stored in the data of the item.
Definition: ProjectItem.cpp:668
Isis::XmlStackedHandlerReader
Manage a stack of content handlers for reading XML files.
Definition: XmlStackedHandlerReader.h:30
Isis::Footprint2DView::m_directory
Directory * m_directory
The directory.
Definition: Footprint2DView.h:167
Isis::Project
The main project for ipce.
Definition: Project.h:289
Isis::Footprint2DView::XmlHandler::XmlHandler
XmlHandler(Footprint2DView *footprintView)
This function sets the Directory pointer for the Directory::XmlHandler class.
Definition: Footprint2DView.cpp:383
Isis::ImageList
Internalizes a list of images and allows for operations on the entire list.
Definition: ImageList.h:55
Isis::Footprint2DView::enableControlNetTool
void enableControlNetTool(bool value)
A slot function that is called when directory emits a siganl that an active control network is set.
Definition: Footprint2DView.cpp:320
Isis::ControlPoint
A single control point.
Definition: ControlPoint.h:354
Isis::Shape::id
QString id() const
Get a unique, identifying string associated with this shape.
Definition: Shape.cpp:459
Isis::Footprint2DView::save
void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const
Save the footprint view widgets (ImageFileListWidget and MosaicSceneWidget to an XML file.
Definition: Footprint2DView.cpp:366
Isis::AbstractProjectItemView::dragEnterEvent
virtual void dragEnterEvent(QDragEnterEvent *event)
Accepts the drag enter event if the internal model can accept the mime data.
Definition: AbstractProjectItemView.cpp:119
Isis::ProjectItem::isImage
bool isImage() const
Returns true if an Image is stored in the data of the item.
Definition: ProjectItem.cpp:646
Isis::Footprint2DView::XmlHandler::~XmlHandler
~XmlHandler()
The Destructor for Directory::XmlHandler.
Definition: Footprint2DView.cpp:392
Isis::AbstractProjectItemView::internalModel
virtual ProjectItemModel * internalModel()
Returns the internal model of the view.
Definition: AbstractProjectItemView.cpp:108
Isis::Footprint2DView::m_toolPad
ToolPad * m_toolPad
The tool pad.
Definition: Footprint2DView.h:171
Isis::Footprint2DView::XmlHandler::m_footprintView
Footprint2DView * m_footprintView
The Footprint2DView.
Definition: Footprint2DView.h:158
Isis::Footprint2DView::eventFilter
bool eventFilter(QObject *watched, QEvent *event)
Event filter to filter out drag and drop events.
Definition: Footprint2DView.cpp:178
Isis::Footprint2DView::m_fileListWidget
ImageFileListWidget * m_fileListWidget
The file list widget.
Definition: Footprint2DView.h:163
Isis::AbstractProjectItemView::dragMoveEvent
virtual void dragMoveEvent(QDragMoveEvent *event)
Accepts the drag event if the internal model can accept the mime data.
Definition: AbstractProjectItemView.cpp:134
Isis::Image
This represents a cube in a project-based GUI interface.
Definition: Image.h:107
Isis::MosaicSceneWidget::selectedImages
ImageList selectedImages()
Returns a list of all the cubes selected in the scene.
Definition: MosaicSceneWidget.cpp:742
Isis::ToolPad
Definition: ToolPad.h:14
Isis::Footprint2DView::mosaicSceneWidget
MosaicSceneWidget * mosaicSceneWidget()
Accessor for the MosaicSceneWidget.
Definition: Footprint2DView.cpp:157
Isis::Footprint2DView::enableActions
void enableActions()
Enables toolbars and toolpad actions.
Definition: Footprint2DView.cpp:337
Isis::MosaicControlNetTool
//TODO: Remove debug printout & comment // 2016-08-25 Tracie Sucharski - Checking Directory pointer f...
Definition: MosaicControlNetTool.h:74
Isis::Footprint2DView::m_imageItemMap
QMap< Image *, ProjectItem * > m_imageItemMap
Maps images to their items.
Definition: Footprint2DView.h:166
Isis::MosaicGraphicsView
A graphics view that resizes in a more friendly way.
Definition: MosaicGraphicsView.h:19
Isis::AbstractProjectItemView::disableActions
virtual void disableActions()
Disables toolbars and toolpad actions.
Definition: AbstractProjectItemView.cpp:196
Isis::Footprint2DView::~Footprint2DView
~Footprint2DView()
Destructor.
Definition: Footprint2DView.cpp:142
Isis::Footprint2DView::onItemRemoved
void onItemRemoved(ProjectItem *item)
Slot to connect to the itemRemoved signal from the model.
Definition: Footprint2DView.cpp:266
Isis::Footprint2DView::m_sceneWidget
MosaicSceneWidget * m_sceneWidget
The scene widget.
Definition: Footprint2DView.h:162
QObject
Isis::Footprint2DView::fileListWidget
ImageFileListWidget * fileListWidget()
Accessor for the FileListWidget.
Definition: Footprint2DView.cpp:165
Isis::Footprint2DView::load
void load(XmlStackedHandlerReader *xmlReader)
Loads the Footprint2DView from an XML file.
Definition: Footprint2DView.cpp:351
QAction
QDockWidget
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::ProjectItem
Represents an item of a ProjectItemModel in Qt's model-view framework.
Definition: ProjectItem.h:134

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:28