Isis 3 Programmer Reference
ShapeReader.h
1 #ifndef ShapeReader_H
2 #define ShapeReader_H
3 
4 #include <QObject>
5 
6 #include <QPointer>
7 
8 // This is the parent of the inner class
9 #include <functional>
10 
11 #include "ShapeDisplayProperties.h"
12 #include "ShapeList.h"
13 #include "ProgressBar.h"
14 #include "PvlObject.h"
15 
16 template <typename A> class QFutureWatcher;
17 class QMutex;
18 class QProgressBar;
19 class QStringList;
20 class QVariant;
21 
22 namespace Isis {
23  class PvlObject;
24 
34  class ShapeReader : public QObject {
35  Q_OBJECT
36 
37  public:
38  ShapeReader(QMutex *cameraMutex, bool requireFootprints = false, QObject *parent = NULL);
39  virtual ~ShapeReader();
40 
41  QList<QAction *> actions(ShapeDisplayProperties::Property relevantDispProperties);
42  QProgressBar *progress();
43 
44  signals:
45  void shapesReady(ShapeList shapes);
46 
47  public slots:
48  void read(PvlObject shapesObj);
49  void read(QStringList shapeFileNames);
50  void setSafeFileOpen(bool safeFileOpen);
51 
52  private slots:
53  void shapesReady(int);
54  void mappedFinished();
55  //void setSmallNumberOfOpenShapes(bool useSmallNumber);
56 
57  private:
58  Q_DISABLE_COPY(ShapeReader)
59 
60  template <typename Iterator>
61  void read(Iterator begin, Iterator end) {
62  int numNewEntries = 0;
63  while (begin != end) {
64  m_backlog.append(qVariantFromValue(*begin));
65  numNewEntries++;
66  begin++;
67  }
68 
69  m_progress->setRange(0, m_progress->maximum() + numNewEntries);
70 
71  start();
72  }
73 
74  void initProgress();
75  void start();
76 
77  void readSettings();
78  void writeSettings();
79 
80  private:
85  QPointer<QAction> m_askAlphaAct;
86  QList<QVariant> m_backlog;
87  QMutex *m_cameraMutex;
88  QPointer<QAction> m_openFilledAct;
89  QPointer<ProgressBar> m_progress;
90  QPointer<QAction> m_safeFileOpenAct;
91  QFutureWatcher<Shape *> * m_watcher;
92 
93  bool m_safeFileOpen;
94  bool m_openFilled;
95  int m_defaultAlpha;
96  bool m_requireFootprints;
97 
98  bool m_mappedRunning;
99 
100  private:
109  class VariantToShapeFunctor : public std::unary_function<
110  const QVariant &, Shape *> {
111 
112  public:
113  VariantToShapeFunctor(QMutex *cameraMutex, bool requireFootprints, QThread *targetThread,
114  bool openFilled, int defaultAlpha);
115  Shape *operator()(const QVariant &);
116 
117  private:
118  QMutex *m_mutex;
119  QThread *m_targetThread;
120 
121  int m_defaultAlpha;
122  bool m_openFilled;
123  bool m_requireFootprints;
124  };
125  };
126 };
127 
128 #endif
129 
Internalizes a list of shapes and allows for operations on the entire list.
Definition: ShapeList.h:33
ShapeReader(QMutex *cameraMutex, bool requireFootprints=false, QObject *parent=NULL)
MosaicWidget constructor.
Definition: ShapeReader.cpp:35
virtual ~ShapeReader()
Free the allocated memory by this object.
Definition: ShapeReader.cpp:65
QPointer< QAction > m_askAlphaAct
Variant Internal Format: (QString|PvlObject).
Definition: ShapeReader.h:85
Converts from file name or project representation to Shape *.
Definition: ShapeReader.h:109
This represents a shape in a project-based GUI interface.
Definition: Shape.h:78
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Property
This is a list of properties and actions that are possible.
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74
VariantToShapeFunctor(QMutex *cameraMutex, bool requireFootprints, QThread *targetThread, bool openFilled, int defaultAlpha)
Create a functor for converting from QVariant to an Shape *.
Shape * operator()(const QVariant &)
Read the QString filename and make an Shape from it.