Isis 3 Programmer Reference
Isis::ShapeList Class Reference

Internalizes a list of shapes and allows for operations on the entire list. More...

#include <ShapeList.h>

Inheritance diagram for Isis::ShapeList:
Inheritance graph
Collaboration diagram for Isis::ShapeList:
Collaboration graph

Classes

class  CopyShapeDataFunctor
 This functor is used for copying the shapes between two projects quickly. More...
 
class  XmlHandler
 This class is used to read an shapes.xml file into an shape list. More...
 

Signals

void countChanged (int newCount)
 

Public Member Functions

 ShapeList (QString name, QString path, QObject *parent=NULL)
 Creates an shape list from an shape list name and path (does not read Shapes).
 
 ShapeList (QObject *parent=NULL)
 Creates a blank shape list.
 
 ShapeList (QList< Shape * >, QObject *parent=NULL)
 Creates an shape list from a list of shapes.
 
 ShapeList (Project *project, XmlStackedHandlerReader *xmlReader, QObject *parent=NULL)
 Creates an shape list from XML.
 
 ShapeList (QStringList &)
 Creates an shape list from a list of cube file names.
 
 ShapeList (const ShapeList &)
 Copy constructor.
 
 ~ShapeList ()
 Destructor.
 
SerialNumberList serialNumberList ()
 Creates a SerialNumberList from the shape list.
 
void append (Shape *const &value)
 Appends an shape to the shape list.
 
void append (const QList< Shape * > &value)
 Appends a list of shapes to the shape list.
 
void clear ()
 Clears the shape list.
 
iterator erase (iterator pos)
 Erases a single shape from the shape list.
 
iterator erase (iterator begin, iterator end)
 Erases a range of shapes from the shape list.
 
void insert (int i, Shape *const &value)
 Inserts an shape into the shape list at an index.
 
iterator insert (iterator before, Shape *const &value)
 Inserts an shape into the shape list after an iterator.
 
void prepend (Shape *const &value)
 Inserts an shape at the beginning of the shape list.
 
void push_back (Shape *const &value)
 Appends an shape to the end of the shape list.
 
void push_front (Shape *const &value)
 Prepends an shape to the beginning of the shape list.
 
int removeAll (Shape *const &value)
 Removes all occurances of an shape.
 
void removeAt (int i)
 Removes the shape at an index.
 
void removeFirst ()
 Removes the shape at the front of the shape list.
 
void removeLast ()
 Removes the shape at the end of the shape list.
 
bool removeOne (Shape *const &value)
 Removes the first occurance of an shape.
 
void swap (QList< Shape * > &other)
 Swaps the shape list with another list of shapes.
 
ShapetakeAt (int i)
 Removes the shape at an index and returns it.
 
ShapetakeFirst ()
 Removes and returns the first shape.
 
ShapetakeLast ()
 Removes and returns the last shape.
 
ShapeListoperator+= (const QList< Shape * > &other)
 Appends a list of shapes to the end of the shape list.
 
ShapeListoperator+= (Shape *const &other)
 Appends a single shape to the end of the shape list.
 
ShapeListoperator<< (const QList< Shape * > &other)
 Appends a list of shapes to the end of the shape list.
 
ShapeListoperator<< (Shape *const &other)
 Appends a single shape to the end of the shape list.
 
ShapeListoperator= (const QList< Shape * > &rhs)
 Assigns another list of shapes to the shape list.
 
ShapeListoperator= (const ShapeList &rhs)
 Assignment operator.
 
void setName (QString newName)
 Set the human-readable name of this shape list.
 
void setPath (QString newPath)
 Set the relative path (from the project root) to this shape list's folder.
 
QString name () const
 Get the human-readable name of this shape list.
 
QString path () const
 Get the path to the shapes in the shape list (relative to project root).
 
void deleteFromDisk (Project *project)
 Delete all of the contained Shapes from disk.
 
void save (QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
 Convert this shape list into XML format for saving/restoring capabilities.
 

Private Attributes

QString m_name
 This stores the shape list's name.
 
QString m_path
 This stores the directory name that contains the shapes in this shape list.
 

Detailed Description

Internalizes a list of shapes and allows for operations on the entire list.

This class reads a list of shapes from an shapes.xml file and internalizes them as aQList of shapes. It also allows for modifications to the entire list of shapes and storing the shape list as an shapes.xml file.

Author
2016-07-25 Tracie Sucharski

Definition at line 33 of file ShapeList.h.

Constructor & Destructor Documentation

◆ ShapeList() [1/6]

Isis::ShapeList::ShapeList ( QString name,
QString path,
QObject * parent = NULL )

Creates an shape list from an shape list name and path (does not read Shapes).

Parameters
nameThe ShapeList's name (i.e. import1, import2, ...).
pathThe ShapeList's folder name (i.e. import1, import2, ...).
parentThe Qt-relationship parent.

Definition at line 35 of file ShapeList.cpp.

References m_name, m_path, name(), and path().

◆ ShapeList() [2/6]

Isis::ShapeList::ShapeList ( QObject * parent = NULL)
explicit

Creates a blank shape list.

Parameters
parentThe Qt-relationship parent.

Definition at line 46 of file ShapeList.cpp.

◆ ShapeList() [3/6]

Isis::ShapeList::ShapeList ( QList< Shape * > shapes,
QObject * parent = NULL )
explicit

Creates an shape list from a list of shapes.

Parameters
shapesThe list of shapes.
parentThe Qt-relationship parent.

Definition at line 56 of file ShapeList.cpp.

References append().

◆ ShapeList() [4/6]

Isis::ShapeList::ShapeList ( Project * project,
XmlStackedHandlerReader * xmlReader,
QObject * parent = NULL )
explicit

Creates an shape list from XML.

Parameters
projectThe project with the shape list.
xmlReaderThe XML reader currently at an <shapeList > tag.
parentThe Qt-relationship parent.

Definition at line 68 of file ShapeList.cpp.

◆ ShapeList() [5/6]

Isis::ShapeList::ShapeList ( QStringList & fileNames)
explicit

Creates an shape list from a list of cube file names.

This is slow (serial) and not recommended.

Parameters
fileNamesThe list of cube fileNames.

Definition at line 91 of file ShapeList.cpp.

References append().

◆ ShapeList() [6/6]

Isis::ShapeList::ShapeList ( const ShapeList & other)

Copy constructor.

Parameters
otherThe shape list to copy.

Definition at line 79 of file ShapeList.cpp.

References m_name, and m_path.

◆ ~ShapeList()

Isis::ShapeList::~ShapeList ( )

Destructor.

This does not free the Shapes from memory.

Definition at line 106 of file ShapeList.cpp.

Member Function Documentation

◆ append() [1/2]

void Isis::ShapeList::append ( const QList< Shape * > & value)

Appends a list of shapes to the shape list.

Parameters
valuethe list of shapes to be appened.
See also
QList<Shape *>::append().

Definition at line 146 of file ShapeList.cpp.

◆ append() [2/2]

void Isis::ShapeList::append ( Shape *const & value)

Appends an shape to the shape list.

Parameters
valueThe shape to be appended.
See also
QList<Shape *>::append().

Definition at line 133 of file ShapeList.cpp.

Referenced by Isis::ImportShapesWorkOrder::importConfirmedShapes(), Isis::WorkOrder::isExecutable(), Isis::WorkOrder::setData(), ShapeList(), and ShapeList().

◆ clear()

void Isis::ShapeList::clear ( )

Clears the shape list.

See also
QList<Shape *>::clear().

Definition at line 157 of file ShapeList.cpp.

◆ deleteFromDisk()

void Isis::ShapeList::deleteFromDisk ( Project * project)

Delete all of the contained Shapes from disk.

Parameters
projectThe project the shapes in the shape list belong to.
See also
Shape::deleteFromDisk()

Definition at line 578 of file ShapeList.cpp.

References Isis::Shape::deleteFromDisk(), m_path, and Isis::Project::shapeDataRoot().

Referenced by Isis::ImportShapesWorkOrder::undoExecution().

◆ erase() [1/2]

QList< Shape * >::iterator Isis::ShapeList::erase ( iterator begin,
iterator end )

Erases a range of shapes from the shape list.

Erases all shapes from begin up to (but not including) end.

Parameters
beginAn iterator pointing to the first shape to be erased.
endAn iterator pointing to the shape just after the last shape to be erased. Will be invalid after the call.
Returns
QList::iterator An iterator pointing to the shape end refered to before the call.
See also
QList<Shape *>::erase()

Definition at line 194 of file ShapeList.cpp.

◆ erase() [2/2]

QList< Shape * >::iterator Isis::ShapeList::erase ( iterator pos)

Erases a single shape from the shape list.

Parameters
posAn iterator pointing to the shape to be erased.
Returns
QList::iterator An iterator pointing to the shape after the shape that was removed.
See also
QList<Shape *>::erase()

Definition at line 175 of file ShapeList.cpp.

◆ insert() [1/2]

void Isis::ShapeList::insert ( int i,
Shape *const & value )

Inserts an shape into the shape list at an index.

Parameters
iThe index at which to insert the shape.
valuethe shape to be inserted.
See also
QList<Shape *>::insert()

Definition at line 209 of file ShapeList.cpp.

◆ insert() [2/2]

QList< Shape * >::iterator Isis::ShapeList::insert ( iterator before,
Shape *const & value )

Inserts an shape into the shape list after an iterator.

Parameters
beforeAn iterator pointing to the shape that value will be inserted after
valueThe shape to be inserted.
Returns
QList::iterator An iterator pointing to the inserted shape.
See also
QList<Shape *>::insert()

Definition at line 226 of file ShapeList.cpp.

◆ name()

QString Isis::ShapeList::name ( ) const

Get the human-readable name of this shape list.

Returns
Qstring The name of the shape list (or an empty string if anonymous).

Definition at line 555 of file ShapeList.cpp.

References m_name.

Referenced by Isis::ProjectItemModel::onShapesAdded(), Isis::ProjectItem::setShapeList(), Isis::Project::shapeList(), ShapeList(), and Isis::ShapeList::XmlHandler::startElement().

◆ operator+=() [1/2]

ShapeList & Isis::ShapeList::operator+= ( const QList< Shape * > & other)

Appends a list of shapes to the end of the shape list.

Parameters
otherThe list of shapes to be appended.
Returns
ShapeList & A reference to the shapeList.
See also
append()
QList<Shape *>::operator+=()

Definition at line 419 of file ShapeList.cpp.

◆ operator+=() [2/2]

ShapeList & Isis::ShapeList::operator+= ( Shape *const & other)

Appends a single shape to the end of the shape list.

Parameters
otherThe shape to be appended.
Returns
ShapeList & A reference to the shapeList.
See also
append()
QList<Shape *>::operator+=()

Definition at line 440 of file ShapeList.cpp.

◆ operator<<() [1/2]

ShapeList & Isis::ShapeList::operator<< ( const QList< Shape * > & other)

Appends a list of shapes to the end of the shape list.

Parameters
otherThe list of shapes to be appended.
Returns
ShapeList & A reference to the shapeList.
See also
append()
QList<Shape *>::operator<<()

Definition at line 457 of file ShapeList.cpp.

◆ operator<<() [2/2]

ShapeList & Isis::ShapeList::operator<< ( Shape *const & other)

Appends a single shape to the end of the shape list.

Parameters
otherThe shape to be appended.
Returns
ShapeList & A reference to the shapeList.
See also
append()
QList<Shape *>::operator<<()

Definition at line 478 of file ShapeList.cpp.

◆ operator=() [1/2]

ShapeList & Isis::ShapeList::operator= ( const QList< Shape * > & rhs)

Assigns another list of shapes to the shape list.

Parameters
rhsThe list of shapes that shapeList will become a copy of.
Returns
ShapeList & A reference to the shapeList.
See also
QList<Shape *>::operator=()

Definition at line 494 of file ShapeList.cpp.

◆ operator=() [2/2]

ShapeList & Isis::ShapeList::operator= ( const ShapeList & rhs)

Assignment operator.

Parameters
rhsThe right hand side of the '=' operator
Returns
ShapeList & This shape list.

Definition at line 513 of file ShapeList.cpp.

References m_name, and m_path.

◆ path()

QString Isis::ShapeList::path ( ) const

Get the path to the shapes in the shape list (relative to project root).

This only applies to an shape list from the project.

Returns
QString The path to the shapes in the shape list (or an empty string if unknown).

Definition at line 566 of file ShapeList.cpp.

References m_path.

Referenced by Isis::ProjectItem::setShapeList(), ShapeList(), and Isis::ShapeList::XmlHandler::startElement().

◆ prepend()

void Isis::ShapeList::prepend ( Shape *const & value)

Inserts an shape at the beginning of the shape list.

Parameters
valueThe shape to be inserted.
See also
QList<Shape *>::prepend()

Definition at line 240 of file ShapeList.cpp.

◆ push_back()

void Isis::ShapeList::push_back ( Shape *const & value)

Appends an shape to the end of the shape list.

Equivalent to append().

Parameters
valueThe shape to be appended.
See also
QList<Shape *>::push_back()

Definition at line 254 of file ShapeList.cpp.

◆ push_front()

void Isis::ShapeList::push_front ( Shape *const & value)

Prepends an shape to the beginning of the shape list.

Equivalent to prepend().

Parameters
valueThe shape to be appended.
See also
QList<Shape *>::push_front()

Definition at line 268 of file ShapeList.cpp.

◆ removeAll()

int Isis::ShapeList::removeAll ( Shape *const & value)

Removes all occurances of an shape.

Parameters
valueThe shape to be removed.
Returns
int The number of occurances of the shape.
See also
QList<Shape *>::removeAll()

Definition at line 283 of file ShapeList.cpp.

◆ removeAt()

void Isis::ShapeList::removeAt ( int i)

Removes the shape at an index.

Parameters
iThe index of the shape to be removed.
See also
QList<Shape *>::removeAt()

Definition at line 301 of file ShapeList.cpp.

Referenced by Isis::Project::shapeClosed().

◆ removeFirst()

void Isis::ShapeList::removeFirst ( )

Removes the shape at the front of the shape list.

See also
QList<Shape *>::removeFirst()

Definition at line 312 of file ShapeList.cpp.

◆ removeLast()

void Isis::ShapeList::removeLast ( )

Removes the shape at the end of the shape list.

See also
QList<Shape *>::removeLast()

Definition at line 323 of file ShapeList.cpp.

◆ removeOne()

bool Isis::ShapeList::removeOne ( Shape *const & value)

Removes the first occurance of an shape.

Parameters
valueThe shape to be removed.
Returns
bool True if successful, otherwise false.
See also
QList<Shape *>::removeOne()

Definition at line 338 of file ShapeList.cpp.

◆ save()

void Isis::ShapeList::save ( QXmlStreamWriter & stream,
const Project * project,
FileName newProjectRoot ) const

Convert this shape list into XML format for saving/restoring capabilities.

This writes:

  <shapeList name="..." path="...">

to the given xml stream, and creates an 'shapes.xml' inside the folder with the shapes. Inside the shapes.xml, this writes:

  <shapes>
    ...
  </shapes>
Parameters
streamXmlStream to write out the document.
projectThe project the shape list will be saved to.
newProjectRootThe path to the root directory for the new project.
Exceptions
iException::Io"Failed to create directory"
iException::Io"Unable to save shape information because new file could not be opened for writing"

Definition at line 615 of file ShapeList.cpp.

References Isis::FileName::dir(), Isis::IException::Io, m_name, m_path, Isis::FileName::original(), Isis::FileName::path(), Isis::Shape::save(), Isis::Project::shapeDataRoot(), and Isis::FileName::toString().

◆ serialNumberList()

SerialNumberList Isis::ShapeList::serialNumberList ( )

Creates a SerialNumberList from the shape list.

Returns
SerialNumberList The list of serial numbers for the cubes in the ShapeList.

Definition at line 115 of file ShapeList.cpp.

References Isis::SerialNumberList::add().

◆ setName()

void Isis::ShapeList::setName ( QString newName)

Set the human-readable name of this shape list.

This is really only useful for project shape lists (not anonymous temporary ones).

Parameters
newNameThe name to give this shape list

Definition at line 534 of file ShapeList.cpp.

References m_name.

Referenced by Isis::ProjectItemModel::setData().

◆ setPath()

void Isis::ShapeList::setPath ( QString newPath)

Set the relative path (from the project root) to this shape list's folder.

This is really only useful for project shape lists (not anonymous temporary ones).

Parameters
newPathThe path to the shapes in this shape list

Definition at line 545 of file ShapeList.cpp.

References m_path.

◆ swap()

void Isis::ShapeList::swap ( QList< Shape * > & other)

Swaps the shape list with another list of shapes.

Parameters
otherThe list of shapes to swapped with.
See also
QList<Shape *>::swap()

Definition at line 356 of file ShapeList.cpp.

◆ takeAt()

Shape * Isis::ShapeList::takeAt ( int i)

Removes the shape at an index and returns it.

Parameters
iThe index of the shape to be removed and returned.
Returns
Shape * The removed shape.
See also
QList<Shape *>::takeAt()

Definition at line 374 of file ShapeList.cpp.

◆ takeFirst()

Shape * Isis::ShapeList::takeFirst ( )

Removes and returns the first shape.

Returns
Shape * The first shape.
See also
QList<Shape *>::takeFirst()

Definition at line 388 of file ShapeList.cpp.

◆ takeLast()

Shape * Isis::ShapeList::takeLast ( )

Removes and returns the last shape.

Returns
Shape * The last shape.
See also
QList<Shape *>::takeLast()

Definition at line 402 of file ShapeList.cpp.

Member Data Documentation

◆ m_name

QString Isis::ShapeList::m_name
private

This stores the shape list's name.

Definition at line 164 of file ShapeList.h.

Referenced by name(), operator=(), save(), setName(), ShapeList(), and ShapeList().

◆ m_path

QString Isis::ShapeList::m_path
private

This stores the directory name that contains the shapes in this shape list.

For example: import1 or import2

This path is relative to Project::shapeDataRoot()

Definition at line 176 of file ShapeList.h.

Referenced by deleteFromDisk(), operator=(), path(), save(), setPath(), ShapeList(), and ShapeList().


The documentation for this class was generated from the following files: