Isis 3.0 Programmer Reference
Back | Home
ProjectItem.cpp
Go to the documentation of this file.
1 
24 #include "ProjectItem.h"
25 
26 #include <QIcon>
27 #include <QStandardItem>
28 #include <QVariant>
29 
30 #include "BundleResults.h"
31 #include "BundleSettings.h"
32 #include "BundleSolutionInfo.h"
33 #include "Control.h"
34 #include "ControlList.h"
35 #include "CorrelationMatrix.h"
36 #include "Image.h"
37 #include "ImageList.h"
38 #include "Project.h"
39 #include "ProjectItemModel.h"
40 #include "Shape.h"
41 #include "ShapeList.h"
42 
43 namespace Isis {
48 
49 
58  setProjectItem(item);
59  for (int i=0; i < item->rowCount(); i++) {
60  appendRow(new ProjectItem( item->child(i) ) );
61  }
62  }
63 
64 
72  setBundleResults(bundleResults);
73  appendRow( new ProjectItem( bundleResults.correlationMatrix() ) );
74  }
75 
76 
84  setBundleSettings(bundleSettings);
85  }
86 
87 
95  setBundleSolutionInfo(bundleSolutionInfo);
96 
97  QString cNetFileName = bundleSolutionInfo->controlNetworkFileName();
98  Control *control = new Control(cNetFileName);
99  appendRow( new ProjectItem(control) );
100 
101  appendRow( new ProjectItem( bundleSolutionInfo->bundleSettings() ) );
102  appendRow( new ProjectItem( bundleSolutionInfo->bundleResults() ) );
103  }
104 
105 
112  setControl(control);
113  }
114 
115 
122  setControlList(controlList);
123  foreach (Control *control, *controlList) {
124  appendRow( new ProjectItem(control) );
125  }
126  }
127 
128 
135  setControls();
136  foreach (ControlList *controlList, controls) {
137  appendRow( new ProjectItem(controlList) );
138  }
139  }
140 
141 
149  setCorrelationMatrix(correlationMatrix);
150  }
151 
152 
159  setImage(image);
160  }
161 
162 
169  setImageList(imageList);
170  foreach (Image *image, *imageList) {
171  appendRow( new ProjectItem(image) );
172  }
173  }
174 
175 
182  setImages();
183  foreach (ImageList *imageList, images) {
184  appendRow( new ProjectItem(imageList) );
185  }
186  }
187 
188 
195  setShape(shape);
196  }
197 
198 
205  setShapeList(shapeList);
206  foreach (Shape *shape, *shapeList) {
207  appendRow(new ProjectItem(shape));
208  }
209  }
210 
211 
218  setShapes();
219  foreach (ShapeList *shapeList, shapes) {
220  appendRow( new ProjectItem(shapeList) );
221  }
222  }
223 
224 
231  setGuiCamera(guiCamera);
232  }
233 
234 
243  foreach (GuiCameraQsp guiCamera, *guiCameraList) {
244  appendRow( new ProjectItem(guiCamera) );
245  }
246  }
247 
248 
255  setProject(project);
256 // qDebug()<<"ProjectItem::ProjectItem(Project *project) rowCount() = "<<rowCount();
257  appendRow( new ProjectItem( project->controls() ) );
258 // qDebug()<<" rowCount() afterControls = "<<rowCount();
259  appendRow( new ProjectItem( project->images() ) );
260 // qDebug()<<" rowCount() afterImages = "<<rowCount();
261  appendRow( new ProjectItem( project->shapes() ) );
262 
263  ProjectItem *targetBodyListItem = new ProjectItem();
264  targetBodyListItem->setTargetBodyList();
265  appendRow(targetBodyListItem);
266 
267  ProjectItem *guiCameraListItem = new ProjectItem();
268  guiCameraListItem->setGuiCameraList();
269  appendRow(guiCameraListItem);
270 
271  ProjectItem *spaceCraftItem = new ProjectItem();
272  spaceCraftItem->setSpacecraft();
273  appendRow(spaceCraftItem);
274 
275  appendRow( new ProjectItem( project->bundleSolutionInfo() ) );
276  }
277 
278 
286  setResults();
287  foreach (BundleSolutionInfo *bundleSolutionInfo, results) {
288  appendRow( new ProjectItem( bundleSolutionInfo) );
289  }
290  }
291 
292 
299  setTargetBody(targetBody);
300  }
301 
302 
310  foreach (TargetBodyQsp targetBody, *targetBodyList) {
311  appendRow( new ProjectItem(targetBody) );
312  }
313  }
314 
315 
320 
321 
328  return data().value<BundleResults>();
329  }
330 
331 
338  return data().value<BundleSettingsQsp>();
339  }
340 
341 
348  return data().value<BundleSolutionInfo *>();
349  }
350 
351 
358  return data().value<Image *>();
359  }
360 
361 
368  return data().value<ImageList *>();
369  }
370 
371 
378  return data().value<Shape *>();
379  }
380 
381 
388  return data().value<ShapeList *>();
389  }
390 
391 
398  return data().value<Control *>();
399  }
400 
401 
408  return data().value<ControlList *>();
409  }
410 
411 
418  return data().value<CorrelationMatrix>();
419  }
420 
421 
428  return data().value<Project *>();
429  }
430 
431 
438  return data().value<GuiCameraQsp>();
439 
440  }
441 
442 
449  return data().value<TargetBodyQsp>();
450  }
451 
452 
460  return data().canConvert<BundleResults>();
461  }
462 
463 
471  return data().canConvert<BundleSettingsQsp>();
472  }
473 
474 
482  return data().canConvert<BundleSolutionInfo *>();
483  }
484 
485 
492  bool ProjectItem::isImage() const {
493  return data().canConvert<Image *>();
494  }
495 
496 
504  return data().canConvert<ImageList *>();
505  }
506 
507 
514  bool ProjectItem::isShape() const {
515  return data().canConvert<Shape *>();
516  }
517 
518 
526  return data().canConvert<ShapeList *>();
527  }
528 
529 
536  bool ProjectItem::isControl() const {
537  return data().canConvert<Control *>();
538  }
539 
540 
549  return data().canConvert<ControlList *>();
550  }
551 
552 
560  return data().canConvert<CorrelationMatrix>();
561  }
562 
563 
570  bool ProjectItem::isProject() const {
571  return data().canConvert<Project *>();
572  }
573 
574 
581  bool ProjectItem::isGuiCamera() const {
582  return data().canConvert<GuiCameraQsp>();
583  }
584 
585 
593  return data().canConvert<TargetBodyQsp>();
594  }
595 
596 
603  setText( item->text() );
604  setIcon( item->icon() );
605  setData( item->data() );
606  }
607 
608 
615  setText("Results");
616  setIcon( QIcon(":results") );
617  setData( QVariant::fromValue<BundleResults>(bundleResults) );
618  }
619 
620 
627  setText("Settings");
628  setIcon( QIcon(":settings") );
629  setData( QVariant::fromValue<BundleSettingsQsp>(bundleSettings) );
630  }
631 
632 
639  setText( bundleSolutionInfo->runTime() );
640  setIcon( QIcon(":results") );
641  setData( QVariant::fromValue<BundleSolutionInfo *>(bundleSolutionInfo) );
642  }
643 
644 
651  setText( QFileInfo( image->fileName() ).fileName() );
652  setIcon( QIcon(":pictures") );
653  setData( QVariant::fromValue<Image *>(image) );
654  }
655 
656 
663  setText( imageList->name() );
664  setIcon( QIcon(":pictures") );
665  setData( QVariant::fromValue<ImageList *>(imageList) );
666  }
667 
668 
673  setText("Images");
674  setIcon( QIcon(":pictures") );
675  setData( QVariant() );
676  }
677 
678 
685  setText( QFileInfo( shape->fileName() ).fileName() );
686  setIcon( QIcon(":dem") );
687  setData( QVariant::fromValue<Shape *>(shape) );
688  }
689 
690 
697  setText( shapeList->name() );
698  setIcon( QIcon(":dem") );
699  setData( QVariant::fromValue<ShapeList *>(shapeList) );
700  }
701 
702 
707  setText("Shapes");
708  setIcon( QIcon(":dem") );
709  setData( QVariant() );
710  }
711 
712 
719  setText( QFileInfo( control->fileName() ).fileName() );
720  setIcon( QIcon(":pointReg") );
721  setData( QVariant::fromValue<Control *>(control) );
722  }
723 
724 
731  setText( controlList->name() );
732  setIcon( QIcon(":folder") );
733  setData( QVariant::fromValue<ControlList *>(controlList) );
734  }
735 
736 
741  setText("Control Networks");
742  setIcon( QIcon(":layers") );
743  setData( QVariant() );
744  }
745 
746 
753  setText("Correlation Matrix");
754  setIcon( QIcon(":pointReg") );
755  setData( QVariant::fromValue<CorrelationMatrix>(correlationMatrix) );
756  }
757 
758 
770  setText( project->name() );
771  setIcon( QIcon(":data-management") );
772  setData( QVariant::fromValue<Project *>(project) );
773  }
774 
775 
780  setText("Results");
781  setIcon( QIcon(":results") );
782  setData( QVariant() );
783  }
784 
785 
792  setText( guiCamera->displayProperties()->displayName() );
793  setIcon( QIcon(":camera") );
794  setData( QVariant::fromValue<GuiCameraQsp>(guiCamera) );
795  }
796 
797 
802  setText("Sensors");
803  setIcon( QIcon(":camera") );
804  setData( QVariant() );
805  }
806 
807 
812  setText("Spacecraft");
813  setIcon( QIcon(":spacecraft") );
814  setData( QVariant() );
815  }
816 
817 
824  setText( targetBody->displayProperties()->displayName() );
825  if (targetBody->displayProperties()->displayName() == "MOON")
826  setIcon( QIcon(":moon") );
827  else if (targetBody->displayProperties()->displayName() == "Enceladus")
828  setIcon( QIcon(":enceladus") );
829  else if (targetBody->displayProperties()->displayName() == "Mars")
830  setIcon( QIcon(":mars") );
831  else if (targetBody->displayProperties()->displayName() == "Titan")
832  setIcon( QIcon(":titan") );
833  else
834  setIcon( QIcon(":moonPhase") );
835  setData( QVariant::fromValue<TargetBodyQsp>(targetBody) );
836  }
837 
838 
843  setText("Target Body");
844  setIcon( QIcon(":moonPhase") );
845  setData( QVariant() );
846  }
847 
848 
858  ProjectItem *ProjectItem::findItemData(const QVariant &value, int role) {
859 // qDebug()<<"ProjectItem::findItemData incoming value = "<<value;
860 // qDebug()<<"ProjectItem::findItemData ProjectItem::data(role) = "<<data(role);
861  if ( data(role) == value ) {
862  return this;
863  }
864 
865  for (int i=0; i<rowCount(); i++) {
866 // qDebug()<<"ProjectItem::findItemData BEFORE call: child(i)->findItemData...";
867  ProjectItem *item = child(i)->findItemData(value, role);
868 // qDebug()<<"ProjectItem::findItemData AFTER call: child(i)->findItemData...";
869  if (item) {
870  return item;
871  }
872  }
873 
874  return 0;
875  }
876 
877 
884  QStandardItem::appendRow(item);
885  }
886 
887 
895  ProjectItem *ProjectItem::child(int row) const {
896  return static_cast<ProjectItem *>( QStandardItem::child(row) );
897  }
898 
899 
906  void ProjectItem::insertRow(int row, ProjectItem *item) {
907  QStandardItem::insertRow(row, item);
908  }
909 
910 
917  return static_cast<ProjectItemModel *>( QStandardItem::model() );
918  }
919 
920 
927  return static_cast<ProjectItem *>( QStandardItem::parent() );
928  }
929 
930 
937  void ProjectItem::setChild(int row, ProjectItem *item) {
938  QStandardItem::setChild(row, item);
939  }
940 
941 
950  QList<QStandardItem *> items = QStandardItem::takeRow(row);
951 
952  if ( items.isEmpty() ) {
953  return 0;
954  }
955 
956  return static_cast<ProjectItem *>( items.first() );
957  }
958 
959 }
This represents an ISIS control net in a project-based GUI interface.
Definition: Control.h:57
QString name() const
Get the human-readable name of this shape list.
Definition: ShapeList.cpp:569
Internalizes a list of shapes and allows for operations on the entire list.
Definition: ShapeList.h:33
bool isBundleSettings() const
Returns true if BundleSettings are stored in the data of the item.
$Date$ $Revision$
Internalizes a list of images and allows for operations on the entire list.
Definition: ImageList.h:44
QSharedPointer< BundleSettings > BundleSettingsQsp
Definition for a BundleSettingsQsp, a shared pointer to a BundleSettings object.
The main project for cnetsuite.
Definition: Project.h:105
void appendRow(ProjectItem *item)
Appends an item to the children of this item.
This is a container for the correlation matrix that comes from a bundle adjust.
QString name() const
Get the project&#39;s GUI name.
Definition: Project.cpp:1050
void setTargetBody(TargetBodyQsp targetBody)
Sets the text, icon, and data corresponding to a TargetBodyQsp.
TargetBodyQsp targetBody() const
Returns the TargetBodyQsp stored in the data of the item.
bool isShape() const
Returns true if an Shape is stored in the data of the item.
Container class for BundleAdjustment results.
void setProject(Project *project)
Sets the text, icon, and data corresponding to a Project.
BundleSettingsQsp bundleSettings()
Returns the bundle settings.
void setControlList(ControlList *controlList)
Sets the text, icon, and data corresponding to a ControlList.
QString fileName() const
Get the file name of the cube that this image represents.
Definition: Image.cpp:305
Maintains a list of Controls so that control nets can easily be copied from one Project to another...
Definition: ControlList.h:34
bool isControl() const
Returns true if a Control is stored in the data of the item.
void setChild(int row, ProjectItem *item)
Sets the child at the given row to an item.
void setControls()
Sets the text, icon, and data corresponding to a list of ControlList.
QString name() const
Get the human-readable name of this image list.
Definition: ImageList.cpp:719
bool isImageList() const
Returns true if an ImageList is stored in the data of the item.
ImageList * imageList() const
Returns the ImageList stored in the data of the item.
CorrelationMatrix correlationMatrix() const
Returns the Correlation Matrix.
void setBundleSettings(BundleSettingsQsp bundleSettings)
Sets the text, icon, and data corresponding to BundleSettings.
void setSpacecraft()
Sets the text, icon, and data corresponding to SpaceCraft.
bool isImage() const
Returns true if an Image is stored in the data of the item.
CorrelationMatrix correlationMatrix() const
Returns the CorrelationMatrix stored the item.
Shape * shape() const
Returns the Shape stored in the data of the item.
void setImage(Image *image)
Sets the text, icon, and data corresponding to an Image.
void setShapes()
Sets the text, icon, and data corresponding to a list of ShapeList.
QString runTime() const
Returns the run time.
BundleResults bundleResults() const
Returns the BundleResults stored in the data of the item.
void setControl(Control *control)
Sets the text, icon, and data corresponding to a Control.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
List for holding TargetBodies.
void setGuiCamera(GuiCameraQsp guiCamera)
Sets the text, icon, and data corresponding to a GuiCameraQsp.
bool isBundleSolutionInfo() const
Returns true if a BundleSolutionInfo is stored in the data of the item.
ProjectItem * findItemData(const QVariant &value, int role=Qt::UserRole+1)
Finds and returns the first item in the model that contains the data in the role. ...
ProjectItem * parent() const
Returns the parent item of this item.
void setShape(Shape *shape)
Sets the text, icon, and data corresponding to an Shape.
void insertRow(int row, ProjectItem *item)
Inserts an item to the children of this item at the row.
void setTargetBodyList()
Sets the text, icon, and data corresponding to a TargetBodyList.
void setImageList(ImageList *imageList)
Sets the text, icon, and data corresponding to an ImageList.
Provides access to data stored in a Project through Qt&#39;s model-view framework.
static QStringList images(QStringList)
Verify that the input fileNames are image files.
Definition: Project.cpp:561
void setBundleResults(BundleResults bundleResults)
Sets the text, icon, and data corresponding to BundleResults.
Project * project() const
Returns the Project stored in the data of the item.
bool isTargetBody() const
Returns true if a TargetBodyQsp is stored in the data of the item.
ProjectItem * takeChild(int row)
Removes the child item at the given row and returns the removed item.
void setProjectItem(ProjectItem *item)
Sets the text, icon, and data to those of another item.
Image * image() const
Returns the Image stored in the data of the item.
ControlList * controlList() const
Returns the ControlList stored in the data of the item.
ProjectItemModel * model() const
Returns the ProjectItemModel associated with this item.
QSharedPointer< TargetBody > TargetBodyQsp
Defines A smart pointer to a TargetBody obj.
Definition: TargetBody.h:224
bool isCorrelationMatrix() const
Returns true if a CorrelationMatrix is stored in the data of the item.
GuiCameraQsp guiCamera() const
Returns the GuiCameraQsp stored in the data of the item.
Control * control() const
Returns the Control stored in the data of the item.
QString name() const
Get the human-readable name of this control list.
bool isGuiCamera() const
Returns true if a GuiCameraQsp is stored in the data of the item.
This represents a cube in a project-based GUI interface.
Definition: Image.h:91
QString fileName() const
Access the name of the control network file associated with this Control.
Definition: Control.cpp:171
void setCorrelationMatrix(CorrelationMatrix correlationMatrix)
Sets the text, icon, and data corresponding to a CorrelationMatrix.
bool isShapeList() const
Returns true if an ShapeList is stored in the data of the item.
void setImages()
Sets the text, icon, and data corresponding to a list of ImageList.
void setResults()
Sets the text, icon, and data corresponding to a list of Results.
void setGuiCameraList()
Sets the text, icon, and data corresponding to a GuiCameraQsp.
List of GuiCameras saved as QSharedPointers.
Definition: GuiCameraList.h:35
QString controlNetworkFileName() const
Returns the name of the control network.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
void setBundleSolutionInfo(BundleSolutionInfo *bundleSolutionInfo)
Sets the text, icon, and data corresponding to a BundleSolutionInfo.
QSharedPointer< GuiCamera > GuiCameraQsp
GuiCameraQsp Represents a smart pointer to a GuiCamera object.
Definition: GuiCamera.h:188
$Date$ $Revision$
This represents a shape in a project-based GUI interface.
Definition: Shape.h:70
ShapeList * shapeList() const
Returns the ShapeList stored in the data of the item.
ProjectItem()
Constructs an item without children, a parent, or a model.
Definition: ProjectItem.cpp:47
bool isControlList() const
Returns true if a ControlList is stored in the data of the item.
~ProjectItem()
Destructs a ProjectItem.
Represents an item of a ProjectItemModel in Qt&#39;s model-view framework.
Definition: ProjectItem.h:113
BundleResults bundleResults()
Returns the bundle results.
A container class for statistical results from a BundleAdjust solution.
Definition: BundleResults.h:90
void setShapeList(ShapeList *shapeList)
Sets the text, icon, and data corresponding to an ShapeList.
BundleSettingsQsp bundleSettings() const
Returns the BundleSettings stored in the data of the item.
BundleSolutionInfo * bundleSolutionInfo() const
Returns the BundleSolutionInfo stored in the data of the item.
ProjectItem * child(int row) const
Returns the child item at a given row.
bool isBundleResults() const
Returns true if BundleResults are stored in the data of the item.
QString fileName() const
Get the file name of the cube that this shape represents.
Definition: Shape.cpp:334
bool isProject() const
Returns true if a Project is stored in the data of the item.

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:26:44