Isis 3 Programmer Reference
ShapeList.h
1 #ifndef ShapeList_H
2 #define ShapeList_H
3 
4 #include <QDebug>
5 #include <QObject>
6 #include <QList>
7 #include <QMetaType>
8 
9 #include "Shape.h"
10 #include "ShapeDisplayProperties.h"
11 #include "SerialNumberList.h"
12 #include "WorkOrder.h"
13 #include "XmlStackedHandler.h"
14 
15 class QStringList;
16 class QXmlStreamWriter;
17 
18 namespace Isis {
19  class FileName;
20  class XmlStackedHandlerReader;
21 
33  class ShapeList : public QObject, public QList<Shape *> {
34  Q_OBJECT
35 
36  public:
37  ShapeList(QString name, QString path, QObject *parent = NULL);
38  explicit ShapeList(QObject *parent = NULL);
39  explicit ShapeList(QList<Shape *>, QObject *parent = NULL);
40  explicit ShapeList(Project *project,
41  XmlStackedHandlerReader *xmlReader, QObject *parent = NULL);
42  explicit ShapeList(QStringList &);
43  ShapeList(const ShapeList &);
44  ~ShapeList();
45 
47 
48  // These are overridden (-ish) in order to add notifications to the list changing
49  void append(Shape * const & value);
50  void append(const QList<Shape *> &value);
51 
52  void clear();
53 
54  iterator erase(iterator pos);
55  iterator erase(iterator begin, iterator end);
56 
57  void insert(int i, Shape * const & value);
58  iterator insert(iterator before, Shape * const & value);
59 
60  void prepend(Shape * const & value);
61  void push_back(Shape * const & value);
62  void push_front(Shape * const & value);
63  int removeAll(Shape * const & value);
64  void removeAt(int i);
65  void removeFirst();
66  void removeLast();
67  bool removeOne(Shape * const & value);
68  void swap(QList<Shape *> &other);
69  Shape *takeAt(int i);
70  Shape *takeFirst();
71  Shape *takeLast();
72 
73  ShapeList &operator+=(const QList<Shape *> &other);
74  ShapeList &operator+=(Shape * const &other);
75  ShapeList &operator<<(const QList<Shape *> &other);
76  ShapeList &operator<<(Shape * const &other);
77  ShapeList &operator=(const QList<Shape *> &rhs);
78 
79  // This is our own assignment, but it needs to notify just like the operator=(QList)
80  ShapeList &operator=(const ShapeList &rhs);
81 
82  // Done overriding (-ish)
83 
84  void setName(QString newName);
85  void setPath(QString newPath);
86 
87  QString name() const;
88  QString path() const;
89 
90  void deleteFromDisk(Project *project);
91  void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const;
92 
93 
94  signals:
95  void countChanged(int newCount);
96 
97  private:
105  class XmlHandler : public XmlStackedHandler {
106  public:
107  XmlHandler(ShapeList *shapeList, Project *project);
108 
109  virtual bool startElement(const QString &namespaceURI, const QString &localName,
110  const QString &qName, const QXmlAttributes &atts);
111  virtual bool endElement(const QString &namespaceURI, const QString &localName,
112  const QString &qName);
113 
114  private:
115  Q_DISABLE_COPY(XmlHandler);
116 
125  };
126 
127 
137  class CopyShapeDataFunctor : public std::unary_function<Shape * const &, void *> {
138  public:
139  CopyShapeDataFunctor(const Project *project, FileName newProjectRoot);
142 
143  void *operator()(Shape * const &shapeToCopy);
144 
146 
147  private:
156  };
157 
158  private slots:
159 
160  private:
164  QString m_name;
165 
176  QString m_path;
177  };
178 
179 }
180 
182 
183 #endif
Isis::ShapeList::insert
void insert(int i, Shape *const &value)
Inserts an shape into the shape list at an index.
Definition: ShapeList.cpp:209
Isis::ShapeList::takeLast
Shape * takeLast()
Removes and returns the last shape.
Definition: ShapeList.cpp:402
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis::ShapeList::operator<<
ShapeList & operator<<(const QList< Shape * > &other)
Appends a list of shapes to the end of the shape list.
Definition: ShapeList.cpp:457
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::ShapeList::CopyShapeDataFunctor::CopyShapeDataFunctor
CopyShapeDataFunctor(const Project *project, FileName newProjectRoot)
Constructor for CopyShapeDataFunctor.
Definition: ShapeList.cpp:693
Isis::ShapeList::CopyShapeDataFunctor::~CopyShapeDataFunctor
~CopyShapeDataFunctor()
Destructor for CopyShapeDataFunctor.
Definition: ShapeList.cpp:714
Isis::ShapeList::takeFirst
Shape * takeFirst()
Removes and returns the first shape.
Definition: ShapeList.cpp:388
Isis::ShapeList::setName
void setName(QString newName)
Set the human-readable name of this shape list.
Definition: ShapeList.cpp:534
Isis::ShapeList::CopyShapeDataFunctor::operator()
void * operator()(Shape *const &shapeToCopy)
Copies the cub/ecub files for an shape into m_project.
Definition: ShapeList.cpp:726
Isis::ShapeList::~ShapeList
~ShapeList()
Destructor.
Definition: ShapeList.cpp:106
Isis::ShapeList::clear
void clear()
Clears the shape list.
Definition: ShapeList.cpp:157
Isis::ShapeList::XmlHandler::m_shapeList
ShapeList * m_shapeList
This stores a pointer to the shape list that will be read into.
Definition: ShapeList.h:120
Isis::ShapeList::push_front
void push_front(Shape *const &value)
Prepends an shape to the beginning of the shape list.
Definition: ShapeList.cpp:268
Isis::ShapeList::operator+=
ShapeList & operator+=(const QList< Shape * > &other)
Appends a list of shapes to the end of the shape list.
Definition: ShapeList.cpp:419
Isis::ShapeList::erase
iterator erase(iterator pos)
Erases a single shape from the shape list.
Definition: ShapeList.cpp:175
QStringList
Isis::ShapeList::XmlHandler
This class is used to read an shapes.xml file into an shape list.
Definition: ShapeList.h:105
Isis::ShapeList::CopyShapeDataFunctor::m_newProjectRoot
FileName m_newProjectRoot
This stores the path to the root of the project that is going to be copied to.
Definition: ShapeList.h:155
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::ShapeList::operator=
ShapeList & operator=(const QList< Shape * > &rhs)
Assigns another list of shapes to the shape list.
Definition: ShapeList.cpp:494
Isis::ShapeList::setPath
void setPath(QString newPath)
Set the relative path (from the project root) to this shape list's folder.
Definition: ShapeList.cpp:545
Isis::ShapeList::takeAt
Shape * takeAt(int i)
Removes the shape at an index and returns it.
Definition: ShapeList.cpp:374
Isis::ShapeList::deleteFromDisk
void deleteFromDisk(Project *project)
Delete all of the contained Shapes from disk.
Definition: ShapeList.cpp:578
Isis::Project
The main project for ipce.
Definition: Project.h:289
Isis::ShapeList::m_path
QString m_path
This stores the directory name that contains the shapes in this shape list.
Definition: ShapeList.h:176
Isis::ShapeList::CopyShapeDataFunctor::operator=
CopyShapeDataFunctor & operator=(const CopyShapeDataFunctor &rhs)
Assignment operator for CopyShapeDataFunctor.
Definition: ShapeList.cpp:739
Isis::ShapeList::removeOne
bool removeOne(Shape *const &value)
Removes the first occurance of an shape.
Definition: ShapeList.cpp:338
Isis::ShapeList::serialNumberList
SerialNumberList serialNumberList()
Creates a SerialNumberList from the shape list.
Definition: ShapeList.cpp:115
Isis::ShapeList::removeFirst
void removeFirst()
Removes the shape at the front of the shape list.
Definition: ShapeList.cpp:312
Isis::ShapeList::XmlHandler::XmlHandler
XmlHandler(ShapeList *shapeList, Project *project)
Create an XML Handler (reader) that can populate the Shape list class data.
Definition: ShapeList.cpp:755
Isis::Shape
This represents a shape in a project-based GUI interface.
Definition: Shape.h:68
Isis::ShapeList::swap
void swap(QList< Shape * > &other)
Swaps the shape list with another list of shapes.
Definition: ShapeList.cpp:356
Isis::ShapeList::push_back
void push_back(Shape *const &value)
Appends an shape to the end of the shape list.
Definition: ShapeList.cpp:254
Isis::ShapeList
Internalizes a list of shapes and allows for operations on the entire list.
Definition: ShapeList.h:33
Isis::ShapeList::removeAt
void removeAt(int i)
Removes the shape at an index.
Definition: ShapeList.cpp:301
Isis::ShapeList::prepend
void prepend(Shape *const &value)
Inserts an shape at the beginning of the shape list.
Definition: ShapeList.cpp:240
Isis::ShapeList::save
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Convert this shape list into XML format for saving/restoring capabilities.
Definition: ShapeList.cpp:615
Isis::ShapeList::CopyShapeDataFunctor
This functor is used for copying the shapes between two projects quickly.
Definition: ShapeList.h:137
Isis::ShapeList::name
QString name() const
Get the human-readable name of this shape list.
Definition: ShapeList.cpp:555
Isis::ShapeList::XmlHandler::startElement
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Handle an XML start element.
Definition: ShapeList.cpp:767
Isis::ShapeList::ShapeList
ShapeList(QString name, QString path, QObject *parent=NULL)
Creates an shape list from an shape list name and path (does not read Shapes).
Definition: ShapeList.cpp:35
Isis::XmlStackedHandler
XML Handler that parses XMLs in a stack-oriented way.
Definition: XmlStackedHandler.h:118
Isis::ShapeList::append
void append(Shape *const &value)
Appends an shape to the shape list.
Definition: ShapeList.cpp:133
Isis::ShapeList::m_name
QString m_name
This stores the shape list's name.
Definition: ShapeList.h:164
Isis::ShapeList::XmlHandler::endElement
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
Handle an XML end element.
Definition: ShapeList.cpp:801
QObject
Isis::ShapeList::removeAll
int removeAll(Shape *const &value)
Removes all occurances of an shape.
Definition: ShapeList.cpp:283
Isis::ShapeList::XmlHandler::m_project
Project * m_project
This stores a pointer to the project that the shapes in the shape list will be a part of.
Definition: ShapeList.h:124
Isis::ShapeList::CopyShapeDataFunctor::m_project
const Project * m_project
This stores the name of the project that is going to be copied to.
Definition: ShapeList.h:151
Isis::ShapeList::removeLast
void removeLast()
Removes the shape at the end of the shape list.
Definition: ShapeList.cpp:323
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(Isis::PlotWindow *)
We have plot windows as QVariant data types, so here it's enabled.
Isis::ShapeList::path
QString path() const
Get the path to the shapes in the shape list (relative to project root).
Definition: ShapeList.cpp:566