Isis Developer Reference
ImageList.h
Go to the documentation of this file.
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"
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 
55  class ImageList : public QObject, public QList<Image *> {
56  Q_OBJECT
57 
58  public:
60 
61  ImageList(QString name, QString path, QObject *parent = NULL);
62  explicit ImageList(QObject *parent = NULL);
63  explicit ImageList(QList<Image *>, QObject *parent = NULL);
64  explicit ImageList(Project *project,
65  XmlStackedHandlerReader *xmlReader, QObject *parent = NULL);
66  explicit ImageList(QStringList &);
67  ImageList(const ImageList &);
68  ~ImageList();
69 
70 // QSharedPointer<SerialNumberList> serialNumberList();
72 
73  // These are overridden (-ish) in order to add notifications to the list changing
74  void append(Image * const & value);
75  void append(const QList<Image *> &value);
76 
77  void clear();
78 
79  iterator erase(iterator pos);
80  iterator erase(iterator begin, iterator end);
81 
82  void insert(int i, Image * const & value);
83  iterator insert(iterator before, Image * const & value);
84 
85  void prepend(Image * const & value);
86  void push_back(Image * const & value);
87  void push_front(Image * const & value);
88  int removeAll(Image * const & value);
89  void removeAt(int i);
90  void removeFirst();
91  void removeLast();
92  bool removeOne(Image * const & value);
93  void swap(QList<Image *> &other);
94  Image *takeAt(int i);
95  Image *takeFirst();
96  Image *takeLast();
97 
98  ImageList &operator+=(const QList<Image *> &other);
99  ImageList &operator+=(Image * const &other);
100  ImageList &operator<<(const QList<Image *> &other);
101  ImageList &operator<<(Image * const &other);
102  ImageList &operator=(const QList<Image *> &rhs);
103 
104  // This is our own assignment, but it needs to notify just like the operator=(QList)
105  ImageList &operator=(const ImageList &rhs);
106 
107  // Done overriding (-ish)
108 
109 
110  QList<QAction *> supportedActions(Project *project = NULL);
112 
113  void setName(QString newName);
114  void setPath(QString newPath);
115 
116  QString name() const;
117  QString path() const;
118 
119  void deleteFromDisk(Project *project);
120  void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const;
121 
122  signals:
123  void countChanged(int newCount);
124 
125  private:
133  class XmlHandler : public XmlStackedHandler {
134  public:
135  XmlHandler(ImageList *imageList, Project *project, QString dataRoot="");
136 
137  virtual bool startElement(const QString &namespaceURI, const QString &localName,
138  const QString &qName, const QXmlAttributes &atts);
139  virtual bool endElement(const QString &namespaceURI, const QString &localName,
140  const QString &qName);
141 
142  private:
143  Q_DISABLE_COPY(XmlHandler);
144 
148  ImageList *m_imageList;
152  Project *m_project;
157  QString m_imageDataRoot;
158  };
159 
160 
170  class CopyImageDataFunctor : public std::unary_function<Image * const &, void *> {
171  public:
172  CopyImageDataFunctor(const Project *project, FileName newProjectRoot);
173  CopyImageDataFunctor(const CopyImageDataFunctor &other);
174  ~CopyImageDataFunctor();
175 
176  void *operator()(Image * const &imageToCopy);
177 
178  CopyImageDataFunctor &operator=(const CopyImageDataFunctor &rhs);
179 
180  private:
184  const Project *m_project;
188  FileName m_newProjectRoot;
189  };
190 
191  private:
200  QAction *createWorkOrder(Project *project, ImageListActionWorkOrder::Action action) {
201  QAction *result = NULL;
202 
203  if (project) {
204  result = new ImageListActionWorkOrder(action, project);
205  ((ImageListActionWorkOrder *)result)->setData(this);
206  }
207  else {
208  result = new QAction(
210  this),
211  this);
212  }
213 
214  return result;
215  }
216 
217  void applyAlphas(QStringList alphaValues);
218  void applyColors(QStringList colorValues, int column = 0);
219  void applyShowLabel(QStringList showLabelValues);
220  void applyShowFill(QStringList showFillValues);
221  void applyShowDNs(QStringList showDNsValues);
222  void applyShowOutline(QStringList showOutlineValues);
223  bool askAlpha(int *alphaResult) const;
224  bool askNewColor(QColor *colorResult) const;
225  QStringList saveAndApplyAlpha(int newAlpha);
226  QStringList saveAndApplyColor(QColor newColor);
227  QStringList saveAndApplyRandomColor();
228 
229  private slots:
230  void askAndUpdateAlpha();
231  void askAndUpdateColor();
232  void showRandomColor();
233  QStringList saveAndToggleShowDNs();
234  QStringList saveAndToggleShowFill();
235  QStringList saveAndToggleShowLabel();
236  QStringList saveAndToggleShowOutline();
237 
238  private:
242  QString m_name;
243 
254  QString m_path;
255  };
256 
257 }
258 
260 
261 #endif
Isis::ImageList::removeFirst
void removeFirst()
Removes the image at the front of the image list.
Definition: ImageList.cpp:332
Isis::ImageList::insert
void insert(int i, Image *const &value)
Inserts an image into the image list at an index.
Definition: ImageList.cpp:229
operator<<
QDebug operator<<(QDebug dbg, const Isis::Angle &angleToPrint)
Display an Angle for a debugging statement.
Definition: Angle.cpp:368
Isis::ImageListActionWorkOrder::ToggleShowLabel
@ ToggleShowLabel
Show or hide each image's display name.
Definition: ImageListActionWorkOrder.h:73
FileName.h
Isis::ImageList::operator+=
ImageList & operator+=(const QList< Image * > &other)
Appends a list of images to the end of the image list.
Definition: ImageList.cpp:439
Isis::ImageDisplayProperties::ShowOutline
@ ShowOutline
True if the cube should be outlined (bool)
Definition: ImageDisplayProperties.h:105
Isis::ImageList::ImageList
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:54
Isis::ImageList::path
QString path() const
Get the path to the images in the image list (relative to project root).
Definition: ImageList.cpp:735
Isis::IException::Io
@ Io
A type of error that occurred when performing an actual I/O operation.
Definition: IException.h:155
Isis::ImageDisplayProperties::Zooming
@ Zooming
Data ignored. Tells if the cube supports the zoomFit action.
Definition: ImageDisplayProperties.h:107
Isis::ImageListActionWorkOrder::MoveUpOne
@ MoveUpOne
Move the image forward.
Definition: ImageListActionWorkOrder.h:78
Isis::ImageListActionWorkOrder::MoveToTop
@ MoveToTop
Move the image to the front.
Definition: ImageListActionWorkOrder.h:77
Isis::ImageList::operator=
ImageList & operator=(const QList< Image * > &rhs)
Assigns another list of images to the image list.
Definition: ImageList.cpp:514
QList< Image * >
Project.h
Isis::ImageList::save
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Convert this image list into XML format for saving/restoring capabilities.
Definition: ImageList.cpp:785
Isis::ImageDisplayProperties::randomColor
static QColor randomColor()
Creates and returns a random color for the intial color of the footprint polygon.
Definition: ImageDisplayProperties.cpp:54
Isis::ImageListActionWorkOrder::ToggleShowFilled
@ ToggleShowFilled
Show or hide each image's fill area.
Definition: ImageListActionWorkOrder.h:74
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::XmlStackedHandlerReader::pushContentHandler
virtual void pushContentHandler(XmlStackedHandler *newHandler)
Push a contentHandler and maybe continue parsing...
Definition: XmlStackedHandlerReader.cpp:55
Isis::ImageList::~ImageList
~ImageList()
Destructor.
Definition: ImageList.cpp:126
Isis::Color::toRGBAString
static QString toRGBAString(QColor)
Convert a QColor to its QString.
Definition: Color.cpp:38
Isis::ImageList::allSupport
bool allSupport(ImageDisplayProperties::Property prop)
Check if all images in the image list support a display property.
Definition: ImageList.cpp:684
ImageDisplayProperties.h
Isis::ImageList::append
void append(Image *const &value)
Appends an image to the image list.
Definition: ImageList.cpp:153
Isis::XmlStackedHandler::startElement
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Definition: XmlStackedHandler.cpp:44
Isis::ImageList::countChanged
void countChanged(int newCount)
Image.h
Isis::ImageListActionWorkOrder::MoveDownOne
@ MoveDownOne
Move the image backward.
Definition: ImageListActionWorkOrder.h:80
Isis::ImageList::deleteFromDisk
void deleteFromDisk(Project *project)
Delete all of the contained Images from disk.
Definition: ImageList.cpp:747
Isis::ImageDisplayProperties::Property
Property
This is a list of properties and actions that are possible.
Definition: ImageDisplayProperties.h:91
Isis::Color::fromRGBAString
static QColor fromRGBAString(QString)
Converts a QString to its QColor.
Definition: Color.cpp:21
Color.h
Isis::ImageDisplayProperties::ShowLabel
@ ShowLabel
True if the cube should show its display name (bool)
Definition: ImageDisplayProperties.h:103
Isis::ImageList::prepend
void prepend(Image *const &value)
Inserts an image at the beginning of the image list.
Definition: ImageList.cpp:260
QStringList
Isis::Project::imageDataRoot
QString imageDataRoot() const
Accessor for the root directory of the image data.
Definition: Project.cpp:2077
Isis::SerialNumberList
Serial Number list generator.
Definition: SerialNumberList.h:64
Isis::XmlStackedHandlerReader
Manage a stack of content handlers for reading XML files.
Definition: XmlStackedHandlerReader.h:30
Isis::ImageListActionWorkOrder::ChangeTransparency
@ ChangeTransparency
Change the alpha values of the image list.
Definition: ImageListActionWorkOrder.h:70
IString.h
Isis::ImageListActionWorkOrder
Work orders that can be performed on an image list that modifies internal state.
Definition: ImageListActionWorkOrder.h:61
Isis::ImageList::serialNumberList
SerialNumberList * serialNumberList()
Creates a SerialNumberList from the image list.
Definition: ImageList.cpp:135
Isis::Project
The main project for ipce.
Definition: Project.h:289
Isis::ImageDisplayProperties::ZOrdering
@ ZOrdering
Data ignored. Tells if the cube supports the "move*" actions.
Definition: ImageDisplayProperties.h:109
Isis::ImageList
Internalizes a list of images and allows for operations on the entire list.
Definition: ImageList.h:55
Isis::ImageList::ImageListActionWorkOrder
friend class ImageListActionWorkOrder
Definition: ImageList.h:59
Isis::ImageList::push_back
void push_back(Image *const &value)
Appends an image to the end of the image list.
Definition: ImageList.cpp:274
Isis::ImageList::setName
void setName(QString newName)
Set the human-readable name of this image list.
Definition: ImageList.cpp:703
WorkOrder.h
Isis::ImageList::push_front
void push_front(Image *const &value)
Prepends an image to the beginning of the image list.
Definition: ImageList.cpp:288
Isis::DisplayProperties::supports
bool supports(int property)
Support may come later, please make sure you are connected to the supportAdded signal.
Definition: DisplayProperties.cpp:122
Isis::ImageList::supportedActions
QList< QAction * > supportedActions(Project *project=NULL)
Gets a list of pre-connected actions that have to do with display.
Definition: ImageList.cpp:565
Isis::Image::deleteFromDisk
void deleteFromDisk()
Delete the image data from disk.
Definition: Image.cpp:586
Isis::ReadWrite
const int ReadWrite
Definition: Process.h:24
Isis::ImageListActionWorkOrder::RandomizeColor
@ RandomizeColor
Set each image in the list to a random color.
Definition: ImageListActionWorkOrder.h:72
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::FileName::dir
QDir dir() const
Returns the path of the file's parent directory as a QDir object.
Definition: FileName.cpp:465
Isis::ImageListActionWorkOrder::qualifyString
static QString qualifyString(QString unqualifiedString, ImageList *)
Determine whether a toggle action should show or hide.
Definition: ImageListActionWorkOrder.cpp:361
Isis::ImageDisplayProperties::Color
@ Color
The color of the cube, default randomized (QColor)
Definition: ImageDisplayProperties.h:95
Isis::toInt
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:93
Isis::Image::save
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Write the Image properties out to an XML file.
Definition: Image.cpp:626
SerialNumberList.h
Isis::ImageList::clear
void clear()
Clears the image list.
Definition: ImageList.cpp:177
Isis::ImageList::removeAt
void removeAt(int i)
Removes the image at an index.
Definition: ImageList.cpp:321
Isis::SerialNumberList::add
void add(const QString &filename, bool def2filename=false)
Adds a new filename / serial number pair to the SerialNumberList.
Definition: SerialNumberList.cpp:121
Isis::Image::closeCube
void closeCube()
Cleans up the Cube pointer.
Definition: Image.cpp:307
Isis::Project::newProjectRoot
QString newProjectRoot() const
Get the top-level folder of the new project.
Definition: Project.cpp:1675
Isis::ImageList::name
QString name() const
Get the human-readable name of this image list.
Definition: ImageList.cpp:724
ImageList.h
Isis::XmlStackedHandler::endElement
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
Definition: XmlStackedHandler.cpp:55
Isis::Image
This represents a cube in a project-based GUI interface.
Definition: Image.h:107
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::FileName::toString
QString toString() const
Returns a QString of the full file name including the file path, excluding the attributes with any Is...
Definition: FileName.cpp:515
Isis::Project::projectRoot
QString projectRoot() const
Get the top-level folder of the project.
Definition: Project.cpp:1666
Isis::ImageList::takeAt
Image * takeAt(int i)
Removes the image at an index and returns it.
Definition: ImageList.cpp:394
Isis::ImageListActionWorkOrder::ToggleShowCubeData
@ ToggleShowCubeData
Show or hide each image's DNs.
Definition: ImageListActionWorkOrder.h:75
Isis::Image::displayProperties
ImageDisplayProperties * displayProperties()
Get the display (GUI) properties (information) associated with this image.
Definition: Image.cpp:320
Isis::ImageDisplayProperties::ShowDNs
@ ShowDNs
True if the cube should show DN values if possible (bool)
Definition: ImageDisplayProperties.h:99
Isis::ImageListActionWorkOrder::ChangeColor
@ ChangeColor
Change the color values of the image list.
Definition: ImageListActionWorkOrder.h:71
Isis::ImageListActionWorkOrder::toString
static QString toString(Action)
Convert an action to a string.
Definition: ImageListActionWorkOrder.cpp:417
Isis::ImageListActionWorkOrder::ZoomFit
@ ZoomFit
Zoom in on the image so that it fits the screen.
Definition: ImageListActionWorkOrder.h:81
IException.h
Isis::ImageList::removeOne
bool removeOne(Image *const &value)
Removes the first occurance of an image.
Definition: ImageList.cpp:358
Isis::ImageList::setPath
void setPath(QString newPath)
Set the relative path (from the project root) to this image list's folder.
Definition: ImageList.cpp:714
Isis::ImageListActionWorkOrder::ToggleShowOutline
@ ToggleShowOutline
Show or hide each image's outline.
Definition: ImageListActionWorkOrder.h:76
Isis::ImageListActionWorkOrder::MoveToBottom
@ MoveToBottom
Move the image to the back.
Definition: ImageListActionWorkOrder.h:79
Isis::ImageDisplayProperties::ShowFill
@ ShowFill
True if the cube should show a fill area if possible (bool)
Definition: ImageDisplayProperties.h:101
Isis::ImageList::operator<<
ImageList & operator<<(const QList< Image * > &other)
Appends a list of images to the end of the image list.
Definition: ImageList.cpp:477
Isis::XmlStackedHandler
XML Handler that parses XMLs in a stack-oriented way.
Definition: XmlStackedHandler.h:118
Isis::ImageList::takeFirst
Image * takeFirst()
Removes and returns the first image.
Definition: ImageList.cpp:408
Isis::ImageList::takeLast
Image * takeLast()
Removes and returns the last image.
Definition: ImageList.cpp:422
QObject
Isis::FileName::original
QString original() const
Returns the full file name including the file path.
Definition: FileName.cpp:212
Isis::ImageList::erase
iterator erase(iterator pos)
Erases a single image from the image list.
Definition: ImageList.cpp:195
Isis::ImageList::removeLast
void removeLast()
Removes the image at the end of the image list.
Definition: ImageList.cpp:343
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(Isis::ImageList *)
QAction
XmlStackedHandlerReader.h
Isis::Project::imageDataRoot
static QString imageDataRoot(QString projectRoot)
Appends the root directory name 'images' to the project .
Definition: Project.cpp:2067
Isis::ImageList::removeAll
int removeAll(Image *const &value)
Removes all occurances of an image.
Definition: ImageList.cpp:303
XmlStackedHandler.h
ImageListActionWorkOrder.h
Isis::ImageListActionWorkOrder::Action
Action
Type of action to be performed by the work order.
Definition: ImageListActionWorkOrder.h:68
Isis::ImageList::swap
void swap(QList< Image * > &other)
Swaps the image list with another list of images.
Definition: ImageList.cpp:376
Isis::FileName::path
QString path() const
Returns the path of the file name.
Definition: FileName.cpp:103
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16