Isis 3.0 Programmer Reference
Back | Home
ImageList.h
1 #ifndef ImageList_H
2 #define ImageList_H
3 
4 #include <QDebug>
5 #include <QObject>
6 #include <QList>
7 #include <QMetaType>
8 #include <QSharedPointer>
9 
10 #include "Image.h"
11 #include "ImageDisplayProperties.h"
12 #include "ImageListActionWorkOrder.h"
13 #include "SerialNumberList.h"
14 #include "WorkOrder.h"
15 #include "XmlStackedHandler.h"
16 
17 class QStringList;
18 class QXmlStreamWriter;
19 
20 namespace Isis {
21  class FileName;
22  class XmlStackedHandlerReader;
23 
44  class ImageList : public QObject, public QList<Image *> {
45  Q_OBJECT
46 
47  public:
48  friend class ImageListActionWorkOrder;
49 
50  ImageList(QString name, QString path, QObject *parent = NULL);
51  explicit ImageList(QObject *parent = NULL);
52  explicit ImageList(QList<Image *>, QObject *parent = NULL);
53  explicit ImageList(Project *project,
54  XmlStackedHandlerReader *xmlReader, QObject *parent = NULL);
55  explicit ImageList(QStringList &);
56  ImageList(const ImageList &);
57  ~ImageList();
58 
59 // QSharedPointer<SerialNumberList> serialNumberList();
61 
62  // These are overridden (-ish) in order to add notifications to the list changing
63  void append(Image * const & value);
64  void append(const QList<Image *> &value);
65 
66  void clear();
67 
68  iterator erase(iterator pos);
69  iterator erase(iterator begin, iterator end);
70 
71  void insert(int i, Image * const & value);
72  iterator insert(iterator before, Image * const & value);
73 
74  void prepend(Image * const & value);
75  void push_back(Image * const & value);
76  void push_front(Image * const & value);
77  int removeAll(Image * const & value);
78  void removeAt(int i);
79  void removeFirst();
80  void removeLast();
81  bool removeOne(Image * const & value);
82  void swap(QList<Image *> &other);
83  Image *takeAt(int i);
84  Image *takeFirst();
85  Image *takeLast();
86 
87  ImageList &operator+=(const QList<Image *> &other);
88  ImageList &operator+=(Image * const &other);
89  ImageList &operator<<(const QList<Image *> &other);
90  ImageList &operator<<(Image * const &other);
91  ImageList &operator=(const QList<Image *> &rhs);
92 
93  // This is our own assignment, but it needs to notify just like the operator=(QList)
94  ImageList &operator=(const ImageList &rhs);
95 
96  // Done overriding (-ish)
97 
98 
99  QList<QAction *> supportedActions(Project *project = NULL);
101 
102  void setName(QString newName);
103  void setPath(QString newPath);
104 
105  QString name() const;
106  QString path() const;
107 
108  void deleteFromDisk(Project *project);
109  void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const;
110 
111 
112  signals:
113  void countChanged(int newCount);
114 
115  private:
123  class XmlHandler : public XmlStackedHandler {
124  public:
125  XmlHandler(ImageList *imageList, Project *project);
126 
127  virtual bool startElement(const QString &namespaceURI, const QString &localName,
128  const QString &qName, const QXmlAttributes &atts);
129  virtual bool endElement(const QString &namespaceURI, const QString &localName,
130  const QString &qName);
131 
132  private:
133  Q_DISABLE_COPY(XmlHandler);
134 
143  };
144 
145 
155  class CopyImageDataFunctor : public std::unary_function<Image * const &, void *> {
156  public:
157  CopyImageDataFunctor(const Project *project, FileName newProjectRoot);
160 
161  void *operator()(Image * const &imageToCopy);
162 
164 
165  private:
174  };
175 
176  private:
186  QAction *result = NULL;
187 
188  if (project) {
189  result = new ImageListActionWorkOrder(action, project);
190  ((ImageListActionWorkOrder *)result)->setData(this);
191  }
192  else {
193  result = new QAction(
195  this),
196  this);
197  }
198 
199  return result;
200  }
201 
202  void applyAlphas(QStringList alphaValues);
203  void applyColors(QStringList colorValues, int column = 0);
204  void applyShowLabel(QStringList showLabelValues);
205  void applyShowFill(QStringList showFillValues);
206  void applyShowDNs(QStringList showDNsValues);
207  void applyShowOutline(QStringList showOutlineValues);
208  bool askAlpha(int *alphaResult) const;
209  bool askNewColor(QColor *colorResult) const;
210  QStringList saveAndApplyAlpha(int newAlpha);
211  QStringList saveAndApplyColor(QColor newColor);
213 
214  private slots:
215  void askAndUpdateAlpha();
216  void askAndUpdateColor();
217  void showRandomColor();
222 
223  private:
227  QString m_name;
228 
239  QString m_path;
240  };
241  // TODO: add QDataStream >> and << ???
242 }
243 
245 
246 #endif
Image * takeLast()
Removes and returns the last image.
Definition: ImageList.cpp:419
QString path() const
Get the path to the images in the image list (relative to project root).
Definition: ImageList.cpp:730
QStringList saveAndToggleShowDNs()
Changes the visibility of the DNs of the first image in the image list and synchronizes the visibilit...
Definition: ImageList.cpp:1214
void push_back(Image *const &value)
Appends an image to the end of the image list.
Definition: ImageList.cpp:271
CopyImageDataFunctor(const Project *project, FileName newProjectRoot)
Constructor for CopyImageDataFunctor.
Definition: ImageList.cpp:857
Internalizes a list of images and allows for operations on the entire list.
Definition: ImageList.h:44
ImageList & operator<<(const QList< Image * > &other)
Appends a list of images to the end of the image list.
Definition: ImageList.cpp:474
The main project for cnetsuite.
Definition: Project.h:105
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
Handle an XML end element.
Definition: ImageList.cpp:1373
int removeAll(Image *const &value)
Removes all occurances of an image.
Definition: ImageList.cpp:300
QStringList saveAndApplyRandomColor()
Sets the color values of every image to a random color.
Definition: ImageList.cpp:1146
void showRandomColor()
This applies a new semi-random color to every image&#39;s display property for every image in this image ...
Definition: ImageList.cpp:1200
This functor is used for copying the images between two projects quickly.
Definition: ImageList.h:155
File name manipulation and expansion.
Definition: FileName.h:111
Work orders that can be performed on an image list that modifies internal state.
void deleteFromDisk(Project *project)
Delete all of the contained Images from disk.
Definition: ImageList.cpp:742
Action
Type of action to be performed by the work order.
void applyShowLabel(QStringList showLabelValues)
Sets the visibility of the display names of the images in the image list based on a list of values...
Definition: ImageList.cpp:960
QString name() const
Get the human-readable name of this image list.
Definition: ImageList.cpp:719
QStringList saveAndToggleShowOutline()
Changes the visibility of the outline of the first image in the image list and synchronizes the visib...
Definition: ImageList.cpp:1298
void applyColors(QStringList colorValues, int column=0)
Sets the colors values of the images based on a list of values.
Definition: ImageList.cpp:940
SerialNumberList * serialNumberList()
Creates a SerialNumberList from the image list.
Definition: ImageList.cpp:132
ImageList * m_imageList
This stores a pointer to the image list that will be read into.
Definition: ImageList.h:138
~CopyImageDataFunctor()
Destructor for CopyImageDataFunctor.
Definition: ImageList.cpp:878
Q_DECLARE_METATYPE(Isis::Cube *)
This allows Cube *&#39;s to be stored in a QVariant.
bool removeOne(Image *const &value)
Removes the first occurance of an image.
Definition: ImageList.cpp:355
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Handle an XML start element.
Definition: ImageList.cpp:1339
void removeAt(int i)
Removes the image at an index.
Definition: ImageList.cpp:318
QString m_path
This stores the directory name that contains the images in this image list.
Definition: ImageList.h:239
QAction * createWorkOrder(Project *project, ImageListActionWorkOrder::Action action)
Creates an ImageListActionWorkOrder and sets the image list as the data for the work order...
Definition: ImageList.h:185
QString m_name
This stores the image list&#39;s name.
Definition: ImageList.h:227
CopyImageDataFunctor & operator=(const CopyImageDataFunctor &rhs)
Assignment operator for CopyImageDataFunctor.
Definition: ImageList.cpp:903
~ImageList()
Destructor.
Definition: ImageList.cpp:123
bool askAlpha(int *alphaResult) const
Prompts the user for an alpha value.
Definition: ImageList.cpp:1041
void prepend(Image *const &value)
Inserts an image at the beginning of the image list.
Definition: ImageList.cpp:257
static QString qualifyString(QString unqualifiedString, ImageList *)
Determine whether a toggle action should show or hide.
QList< QAction * > supportedActions(Project *project=NULL)
Gets a list of pre-connected actions that have to do with display.
Definition: ImageList.cpp:557
ImageList & operator+=(const QList< Image * > &other)
Appends a list of images to the end of the image list.
Definition: ImageList.cpp:436
void push_front(Image *const &value)
Prepends an image to the beginning of the image list.
Definition: ImageList.cpp:285
const Project * m_project
This stores the name of the project that is going to be copied to.
Definition: ImageList.h:169
void swap(QList< Image * > &other)
Swaps the image list with another list of images.
Definition: ImageList.cpp:373
void applyShowFill(QStringList showFillValues)
Sets the visibility of the fill areas of the images in the image list based on a list of values...
Definition: ImageList.cpp:980
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Convert this image list into XML format for saving/restoring capabilities.
Definition: ImageList.cpp:779
XML Handler that parses XMLs in a stack-oriented way.
void clear()
Clears the image list.
Definition: ImageList.cpp:174
This represents a cube in a project-based GUI interface.
Definition: Image.h:91
void removeFirst()
Removes the image at the front of the image list.
Definition: ImageList.cpp:329
void applyShowOutline(QStringList showOutlineValues)
Sets the visibility of the outlines of the images in the image list based on a list of values...
Definition: ImageList.cpp:1018
void setPath(QString newPath)
Set the relative path (from the project root) to this image list&#39;s folder.
Definition: ImageList.cpp:709
QStringList saveAndApplyAlpha(int newAlpha)
Sets the alpha value of every image in the image list to a specificed value.
Definition: ImageList.cpp:1092
Image * takeAt(int i)
Removes the image at an index and returns it.
Definition: ImageList.cpp:391
void applyAlphas(QStringList alphaValues)
Sets the alpha values of the images based on a list of values.
Definition: ImageList.cpp:919
void append(Image *const &value)
Appends an image to the image list.
Definition: ImageList.cpp:150
Property
This is a list of properties and actions that are possible.
void askAndUpdateColor()
Prompt the user for a new color.
Definition: ImageList.cpp:1189
void insert(int i, Image *const &value)
Inserts an image into the image list at an index.
Definition: ImageList.cpp:226
bool askNewColor(QColor *colorResult) const
Prompts the user for color values.
Definition: ImageList.cpp:1069
Image * takeFirst()
Removes and returns the first image.
Definition: ImageList.cpp:405
XmlHandler(ImageList *imageList, Project *project)
Create an XML Handler (reader) that can populate the Image list class data.
Definition: ImageList.cpp:1327
void applyShowDNs(QStringList showDNsValues)
Sets the visibility of the DNs of the images in the image list based on a list of values...
Definition: ImageList.cpp:999
iterator erase(iterator pos)
Erases a single image from the image list.
Definition: ImageList.cpp:192
This class is used to read an images.xml file into an image list.
Definition: ImageList.h:123
QStringList saveAndToggleShowLabel()
Changes the visibility of the display name of the first image in the image list and synchronizes the ...
Definition: ImageList.cpp:1270
static QString toString(Action)
Convert an action to a string.
FileName m_newProjectRoot
This stores the path to the root of the project that is going to be copied to.
Definition: ImageList.h:173
bool allSupport(ImageDisplayProperties::Property prop)
Check if all images in the image list support a display property.
Definition: ImageList.cpp:679
void askAndUpdateAlpha()
Prompt the user for a new alpha value.
Definition: ImageList.cpp:1176
void removeLast()
Removes the image at the end of the image list.
Definition: ImageList.cpp:340
ImageList(QString name, QString path, QObject *parent=NULL)
Creates an image list from an image list name and path (does not read Images).
Definition: ImageList.cpp:52
Serial Number list generator.
ImageList & operator=(const QList< Image * > &rhs)
Assigns another list of images to the image list.
Definition: ImageList.cpp:511
void setName(QString newName)
Set the human-readable name of this image list.
Definition: ImageList.cpp:698
his enables stack-based XML parsing of XML files.
QStringList saveAndToggleShowFill()
Changes the visibility of the fill area of the first image in the image list and synchronizes the vis...
Definition: ImageList.cpp:1242
Project * m_project
This stores a pointer to the project that the images in the image list will be a part of...
Definition: ImageList.h:142
void * operator()(Image *const &imageToCopy)
Copies the cub/ecub files for an image into m_project.
Definition: ImageList.cpp:890
QStringList saveAndApplyColor(QColor newColor)
Sets the color values of every image to a specificed set of values.
Definition: ImageList.cpp:1119

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:20:11