Isis 3.0 Programmer Reference
Back | Home
Footprint2DView.cpp
Go to the documentation of this file.
1 
23 #include "IsisDebug.h"
24 
25 #include "Footprint2DView.h"
26 
27 #include <QAction>
28 #include <QDragEnterEvent>
29 #include <QDragMoveEvent>
30 #include <QDropEvent>
31 #include <QItemSelectionModel>
32 #include <QList>
33 #include <QSize>
34 #include <QSizePolicy>
35 #include <QToolBar>
36 #include <QVBoxLayout>
37 #include <QWidget>
38 #include <QWidgetAction>
39 
40 #include "ControlPoint.h"
41 #include "Cube.h"
42 #include "Image.h"
43 #include "MosaicGraphicsView.h"
44 #include "MosaicSceneWidget.h"
45 #include "ProjectItem.h"
46 #include "ProjectItemModel.h"
47 #include "Shape.h"
48 #include "ToolPad.h"
49 
50 namespace Isis {
57  AbstractProjectItemView(parent) {
58  m_sceneWidget = new MosaicSceneWidget(NULL, 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 // qDebug()<<"Footprint2DView::Footprint2DView internalModel() = "<<internalModel();
65  connect( internalModel(), SIGNAL( itemAdded(ProjectItem *) ),
66  this, SLOT( onItemAdded(ProjectItem *) ) );
67  connect( internalModel(), SIGNAL( itemRemoved(ProjectItem *) ),
68  this, SLOT( onItemRemoved(ProjectItem *) ) );
69 
70  connect(m_sceneWidget, SIGNAL(queueSelectionChanged() ),
71  this, SLOT(onQueueSelectionChanged() ) );
72 
73  // Pass on Signals emitted from ControlNetTool, through the MosaicSceneWidget
74  // TODO 2016-09-09 TLS Design: Use a proxy model instead of signals?
75  connect(m_sceneWidget, SIGNAL(modifyControlPoint(ControlPoint *)),
76  this, SIGNAL(modifyControlPoint(ControlPoint *)));
77 
78  connect(m_sceneWidget, SIGNAL(deleteControlPoint(ControlPoint *)),
79  this, SIGNAL(deleteControlPoint(ControlPoint *)));
80 
81  connect(m_sceneWidget, SIGNAL(createControlPoint(double, double)),
82  this, SIGNAL(createControlPoint(double, double)));
83 
84  // Pass on signals emitted from Directory (by way of ControlPointEditWidget)
85  // This is done to redraw the control points on the cube viewports
86  connect(this, SIGNAL(controlPointAdded(QString)),
87  m_sceneWidget, SIGNAL(controlPointAdded(QString)));
88 
89  QVBoxLayout *layout = new QVBoxLayout;
90  setLayout(layout);
91 
92  layout->addWidget(m_sceneWidget);
93 
94  m_permToolBar = new QToolBar("Standard Tools", 0);
95  m_permToolBar->setObjectName("permToolBar");
96  m_permToolBar->setIconSize(QSize(22, 22));
97  //toolBarLayout->addWidget(m_permToolBar);
98 
99  m_activeToolBar = new QToolBar("Active Tool", 0);
100  m_activeToolBar->setObjectName("activeToolBar");
101  m_activeToolBar->setIconSize(QSize(22, 22));
102  //toolBarLayout->addWidget(m_activeToolBar);
103 
104  m_toolPad = new ToolPad("Tool Pad", 0);
105  m_toolPad->setObjectName("toolPad");
106  //toolBarLayout->addWidget(m_toolPad);
107 
108 
109  m_sceneWidget->addToPermanent(m_permToolBar);
111  m_sceneWidget->addTo(m_toolPad);
112 
113  m_activeToolBarAction = new QWidgetAction(this);
114  m_activeToolBarAction->setDefaultWidget(m_activeToolBar);
115 
116  setAcceptDrops(true);
117 
118  QSizePolicy policy = sizePolicy();
119  policy.setHorizontalPolicy(QSizePolicy::Expanding);
120  policy.setVerticalPolicy(QSizePolicy::Expanding);
121  setSizePolicy(policy);
122 
123  }
124 
125 
130  delete m_permToolBar;
131  delete m_activeToolBar;
132  delete m_toolPad;
133 
134  m_permToolBar = 0;
135  m_activeToolBar = 0;
136  m_toolPad = 0;
137  }
138 
139 
146  return QSize(800, 600);
147  }
148 
149 
150  MosaicSceneWidget *Footprint2DView::mosaicSceneWidget() {
151  return m_sceneWidget;
152  }
153 
154 
163  bool Footprint2DView::eventFilter(QObject *watched, QEvent *event) {
164  if (event->type() == QEvent::DragEnter) {
165  dragEnterEvent( static_cast<QDragEnterEvent *>(event) );
166  return true;
167  }
168  else if (event->type() == QEvent::DragMove) {
169  dragMoveEvent( static_cast<QDragMoveEvent *>(event) );
170  return true;
171  }
172  else if (event->type() == QEvent::Drop) {
173  dropEvent( static_cast<QDropEvent *>(event) );
174  return true;
175  }
176 
177  return AbstractProjectItemView::eventFilter(watched, event);
178  }
179 
180 
188  qDebug()<<"Footprint2DView::onItemAdded";
189  if (!item || (!item->isImage() && !item->isShape())) {
190  return;
191  }
192  //TODO 2016-09-09 TLS Handle Shapes-Create image from shape since qmos only handles images?
193  // Still don't know if shape should inherit from image or contain an image?
194  //
195  Image *image;
196  ImageList images;
197  if (item->isShape()) {
198  //TEMPORARY UNTIL SHAPE IS FIXED TO HOLD IMAGE, once Shape holds image go back to old code
199  // previous to 10-21-16
200  image = new Image(item->shape()->cube());
201  }
202  else if (item->isImage()) {
203  image = item->image();
204  }
205  images.append(image);
206  m_sceneWidget->addImages(images);
207 
208  if (!m_imageItemMap.value(image)) {
209  m_imageItemMap.insert(image, item);
210  }
211  }
212 
213 
221 // qDebug()<<"Footprint2DView::onItemRemoved item= "<<item;
222 // qDebug()<<" source model: "<<internalModel()->sourceModel()<<" rows = "<<internalModel()->sourceModel()->rowCount();
223 // qDebug()<<" proxy model: "<<internalModel()<<" rows = "<<internalModel()->rowCount();
224  if (!item) {
225  return;
226  }
227 
228  if (item->isImage()) {
229 
230  ImageList images;
231  images.append(item->image());
232 // qDebug()<<" image count = "<<images.size();
233 
234  m_sceneWidget->removeImages(images);
235 
236  if ( m_imageItemMap.value( item->image() ) ) {
237  m_imageItemMap.remove( item->image());
238  }
239  }
240  }
241 
242 
248  ImageList selectedImages = m_sceneWidget->selectedImages();
249 
250  if (selectedImages.isEmpty() ) {
251  return;
252  }
253 
254  Image *currentImage = selectedImages.first();
255 
256  internalModel()->selectionModel()->clear();
257 
258  if ( ProjectItem *item = m_imageItemMap.value(currentImage) ) {
259  internalModel()->selectionModel()->setCurrentIndex(item->index(), QItemSelectionModel::Select);
260  }
261 
262 
263  foreach (Image *image, selectedImages) {
264  if ( ProjectItem *item = m_imageItemMap.value(image) ) {
265  internalModel()->selectionModel()->select(item->index(), QItemSelectionModel::Select);
266  }
267  }
268  }
269 
270 
277  return m_permToolBar->actions();
278  }
279 
280 
287  QList<QAction *> actions;
288  actions.append(m_activeToolBarAction);
289  return actions;
290  }
291 
292 
299  return m_toolPad->actions();
300  }
301 
302 
303 }
Footprint2DView(Directory *directory, QWidget *parent=0)
Constructor.
$Date$ $Revision$
Internalizes a list of images and allows for operations on the entire list.
Definition: ImageList.h:44
A graphics view that resizes in a more friendly way.
virtual void dropEvent(QDropEvent *event)
Drops the data into the internal model if it can accept the data.
bool isShape() const
Returns true if an Shape is stored in the data of the item.
This widget encompasses the entire mosaic scene.
virtual QList< QAction * > permToolBarActions()
Returns a list of actions for the permanent tool bar.
bool isImage() const
Returns true if an Image is stored in the data of the item.
Shape * shape() const
Returns the Shape stored in the data of the item.
$Date$ $Revision$
virtual QList< QAction * > activeToolBarActions()
Returns a list of actions for the active tool bar.
QMap< Image *, ProjectItem * > m_imageItemMap
Maps images to their items.
AbstractProjectItemView is a base class for views of a ProjectItemModel in Qt&#39;s model-view framework...
virtual ProjectItemModel * internalModel()
Returns the internal model of the view.
void onItemRemoved(ProjectItem *item)
Slot to connect to the itemRemoved signal from the model.
Image * image() const
Returns the Image stored in the data of the item.
bool eventFilter(QObject *watched, QEvent *event)
Event filter to filter out drag and drop events.
ToolPad * m_toolPad
The tool pad.
QItemSelectionModel * selectionModel()
Returns the internal selection model.
Cube * cube()
Get the Cube * associated with this display property.
Definition: Shape.cpp:282
QToolBar * m_activeToolBar
The active tool bar.
void onQueueSelectionChanged()
Slot to connect to the queueSelectionChanged signal from a MosiacSceneWidget.
~Footprint2DView()
Destructor.
ImageList selectedImages()
Returns a list of all the cubes selected in the scene.
virtual void dragMoveEvent(QDragMoveEvent *event)
Accepts the drag event if the internal model can accept the mime data.
A single control point.
Definition: ControlPoint.h:339
This represents a cube in a project-based GUI interface.
Definition: Image.h:91
void append(Image *const &value)
Appends an image to the image list.
Definition: ImageList.cpp:150
virtual void dragEnterEvent(QDragEnterEvent *event)
Accepts the drag enter event if the internal model can accept the mime data.
$Date$ $Revision$
Represents an item of a ProjectItemModel in Qt&#39;s model-view framework.
Definition: ProjectItem.h:113
QSize sizeHint() const
Returns the suggested size for the widget.
QWidgetAction * m_activeToolBarAction
Stores the active tool bar.
MosaicSceneWidget * m_sceneWidget
The scene widget.
void onItemAdded(ProjectItem *item)
Slot to connect to the itemAdded signal from the model.
QToolBar * m_permToolBar
The permanent tool bar.
virtual QList< QAction * > toolPadActions()
Returns a list of actions for the tool pad.

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:18:19