Loading [MathJax]/jax/output/NativeMML/config.js
 |
Isis 3 Programmer Reference
|
Go to the documentation of this file.
24 #include "ImageList.h"
25 #include "IException.h"
28 #include <QColorDialog>
33 #include <QInputDialog>
35 #include <QProgressDialog>
36 #include <QtConcurrentMap>
37 #include <QXmlStreamWriter>
41 #include "IException.h"
44 #include "XmlStackedHandlerReader.h"
111 foreach (QString fileName, fileNames) {
139 for (
int i = 0; i < count(); i++) {
140 result->
add((*
this)[i]->fileName());
155 emit countChanged(count());
168 emit countChanged(count());
178 bool countChanging = count();
181 emit countChanged(count());
197 emit countChanged(count());
216 emit countChanged(count());
232 emit countChanged(count());
248 emit countChanged(count());
262 emit countChanged(count());
276 emit countChanged(count());
290 emit countChanged(count());
307 emit countChanged(count());
323 emit countChanged(count());
334 emit countChanged(count());
345 emit countChanged(count());
362 emit countChanged(count());
379 if (count() != other.count()) {
380 emit countChanged(count());
396 emit countChanged(count());
410 emit countChanged(count());
424 emit countChanged(count());
443 emit countChanged(count());
462 emit countChanged(count());
481 emit countChanged(count());
500 emit countChanged(count());
515 bool countChanging = (rhs.count() != count());
519 emit countChanged(count());
534 bool countChanging = (rhs.count() != count());
541 emit countChanged(count());
575 connect(alphaAction, SIGNAL(triggered()),
578 actions.append(alphaAction);
582 connect(colorAction, SIGNAL(triggered()),
585 actions.append(colorAction);
589 connect(ranColorAction, SIGNAL(triggered()),
592 actions.append(ranColorAction);
599 connect(labelVisibleAction, SIGNAL(triggered()),
602 actions.append(labelVisibleAction);
608 connect(fillAction, SIGNAL(triggered()),
611 actions.append(fillAction);
618 connect(cubeDataAction, SIGNAL(triggered()),
621 actions.append(cubeDataAction);
628 connect(outlineAction, SIGNAL(triggered()),
631 actions.append(outlineAction);
634 actions.append(NULL);
643 foreach (
Image *image, *
this) {
644 connect(moveToTopAct, SIGNAL(triggered()),
647 connect(moveUpAct, SIGNAL(triggered()),
650 connect(moveToBottomAct, SIGNAL(triggered()),
653 connect(moveDownAct, SIGNAL(triggered()),
657 actions.append(moveToTopAct);
658 actions.append(moveUpAct);
659 actions.append(moveToBottomAct);
660 actions.append(moveDownAct);
663 actions.append(NULL);
667 connect(zoomFit, SIGNAL(triggered()),
668 first()->displayProperties(), SIGNAL(zoomFit()));
669 actions.append(zoomFit);
688 foreach (
Image *image, *
this) {
748 foreach (
Image *image, *
this) {
787 stream.writeStartElement(
"imageList");
788 stream.writeAttribute(
"name",
m_name);
789 stream.writeAttribute(
"path",
m_path);
795 if (dataRoot.startsWith(
"/")) {
796 dataRoot.remove(0,1);
798 stream.writeAttribute(
"dataRoot", dataRoot);
801 "/" +
m_path +
"/images.xml");
803 if (!settingsFileName.
dir().mkpath(settingsFileName.
path())) {
805 QString(
"Failed to create directory [%1]")
806 .arg(settingsFileName.
path()),
809 QFile imageListContentsFile(settingsFileName.
toString());
811 if (!imageListContentsFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
813 QString(
"Unable to save image information for [%1] because [%2] could not be opened for "
819 QXmlStreamWriter imageDetailsWriter(&imageListContentsFile);
820 imageDetailsWriter.setAutoFormatting(
true);
821 imageDetailsWriter.writeStartDocument();
823 imageDetailsWriter.writeStartElement(
"images");
827 int countWidth = QString(
"%1L").arg(count()).size() - 1;
828 QChar paddingChar(
'0');
830 QLabel *progressLabel =
new QLabel;
832 QProgressDialog progressDialog;
833 progressDialog.setLabel(progressLabel);
834 progressDialog.setRange(-1, count());
835 progressDialog.setValue(-1);
838 QFuture<void *> future = QtConcurrent::mapped(*
this,
841 for (
int i = 0; i < count(); i++) {
842 int newProgressValue = progressDialog.value() + 1;
843 progressLabel->setText(
844 tr(
"Saving Image Information for [%1] - %L2/%L3 done")
846 .arg(newProgressValue, countWidth, 10, paddingChar)
848 progressDialog.setValue(newProgressValue);
852 catch(std::exception &e) {
853 QString msg(
"Could not save ImageList: "+this->
name() );
858 progressLabel->setText(tr(
"Finalizing..."));
859 progressDialog.setRange(0, 0);
860 progressDialog.setValue(0);
863 foreach (
Image *image, *
this) {
864 image->
save(imageDetailsWriter, project, newProjectRoot);
867 imageDetailsWriter.writeEndElement();
869 imageDetailsWriter.writeEndDocument();
871 stream.writeEndElement();
951 if (count() == alphaValues.count()) {
952 for (
int i = 0; i < count(); i++) {
955 color.setAlpha(alphaValues[i].
toInt());
972 if (count() == colorValues.count()) {
973 for (
int i = 0; i < count(); i++) {
974 QString colorData = colorValues[i].split(
" ")[column];
992 if (count() == showLabelValues.count()) {
993 for (
int i = 0; i < count(); i++) {
1012 if (count() == showFillValues.count()) {
1013 for (
int i = 0; i < count(); i++) {
1015 dispProps->
setShowFill(showFillValues[i] ==
"shown");
1031 if (count() == showDNsValues.count()) {
1032 for (
int i = 0; i < count(); i++) {
1034 dispProps->
setShowDNs(showDNsValues[i] ==
"shown");
1050 if (count() == showOutlineValues.count()) {
1051 for (
int i = 0; i < count(); i++) {
1073 bool result =
false;
1077 *alphaResult = QInputDialog::getInt(NULL,
"Transparency Value",
1078 "Set the cube's transparency\nValues are 0 (invisible) to 255 (solid)",
1080 0, 255, 1, &result);
1101 *colorResult = QColor();
1105 *colorResult = QColorDialog::getColor(
1107 "Cube Display Color",
1108 QColorDialog::ShowAlphaChannel);
1111 return colorResult->isValid();
1125 foreach (
Image *image, *
this) {
1128 QColor displayColor = displayProperties->
getValue(
1131 results.append(QString::number(displayColor.alpha()));
1133 displayColor.setAlpha(newAlpha);
1134 displayProperties->
setColor(displayColor);
1153 if (newColor.isValid()) {
1154 foreach (
Image *image, *
this) {
1157 QColor displayColor = displayProperties->
getValue(
1162 displayProperties->
setColor(newColor);
1180 foreach (
Image *image, *
this) {
1185 QColor displayColor = displayProperties->
getValue(
1189 ranColor.setAlpha(displayColor.alpha());
1196 displayProperties->
setColor(ranColor);
1232 foreach (
Image *image, *
this) {
1252 foreach (
Image *image, *
this) {
1256 results.append(value?
"shown" :
"hidden");
1280 foreach (
Image *image, *
this) {
1284 results.append(value?
"shown" :
"hidden");
1308 foreach (
Image *image, *
this) {
1312 results.append(value?
"shown" :
"hidden");
1336 foreach (
Image *image, *
this) {
1340 results.append(value?
"shown" :
"hidden");
1359 m_imageList = imageList;
1360 m_project = project;
1361 m_imageDataRoot = dataRoot;
1372 const QString &qName,
const QXmlAttributes &atts) {
1373 if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
1374 if (localName ==
"imageList") {
1375 QString
name = atts.value(
"name");
1376 QString
path = atts.value(
"path");
1377 m_imageDataRoot = atts.value(
"dataRoot");
1379 if (!
name.isEmpty()) {
1380 m_imageList->setName(
name);
1383 if (!
path.isEmpty()) {
1384 m_imageList->setPath(
path);
1387 else if (localName ==
"image") {
1388 m_imageList->append(
new Image(
1389 m_project->projectRoot() +
"/" + m_imageDataRoot +
"/" + m_imageList->path(), reader()));
1407 const QString &qName) {
1408 if (localName ==
"imageList") {
1409 XmlHandler handler(m_imageList, m_project, m_imageDataRoot);
1413 reader.setErrorHandler(&handler);
1415 QDir projectPath = QDir(m_project->projectRoot()).dirName();
1416 QString imageListXmlPath = m_project->projectRoot() +
"/" + m_imageDataRoot +
"/" +
1417 m_imageList->path() +
"/images.xml";
1418 imageListXmlPath = QDir::cleanPath(imageListXmlPath);
1420 QFile file(imageListXmlPath);
1422 if (!file.open(QFile::ReadOnly)) {
1424 QString(
"Unable to open [%1] with read access")
1425 .arg(imageListXmlPath),
1429 QXmlInputSource xmlInputSource(&file);
1430 if (!reader.parse(xmlInputSource))
1432 tr(
"Failed to open image list XML [%1]").arg(imageListXmlPath),
1436 return XmlStackedHandler::endElement(namespaceURI, localName, qName);
void removeFirst()
Removes the image at the front of the image list.
void insert(int i, Image *const &value)
Inserts an image into the image list at an index.
@ ToggleShowLabel
Show or hide each image's display name.
ImageList & operator+=(const QList< Image * > &other)
Appends a list of images to the end of the image list.
@ ShowOutline
True if the cube should be outlined (bool)
ImageList(QString name, QString path, QObject *parent=NULL)
Creates an image list from an image list name and path (does not read Images).
QString path() const
Get the path to the images in the image list (relative to project root).
@ Io
A type of error that occurred when performing an actual I/O operation.
@ Zooming
Data ignored. Tells if the cube supports the zoomFit action.
@ MoveUpOne
Move the image forward.
This functor is used for copying the images between two projects quickly.
@ MoveToTop
Move the image to the front.
ImageList & operator=(const QList< Image * > &rhs)
Assigns another list of images to the image list.
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Convert this image list into XML format for saving/restoring capabilities.
static QColor randomColor()
Creates and returns a random color for the intial color of the footprint polygon.
@ ToggleShowFilled
Show or hide each image's fill area.
void setColor(QColor newColor)
Change the color associated with this cube.
QString m_name
This stores the image list's name.
QStringList saveAndApplyAlpha(int newAlpha)
Sets the alpha value of every image in the image list to a specificed value.
QStringList saveAndApplyColor(QColor newColor)
Sets the color values of every image to a specificed set of values.
File name manipulation and expansion.
CopyImageDataFunctor & operator=(const CopyImageDataFunctor &rhs)
Assignment operator for CopyImageDataFunctor.
virtual void pushContentHandler(XmlStackedHandler *newHandler)
Push a contentHandler and maybe continue parsing...
void applyShowOutline(QStringList showOutlineValues)
Sets the visibility of the outlines of the images in the image list based on a list of values.
static QString toRGBAString(QColor)
Convert a QColor to its QString.
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
Handle an XML end element.
void askAndUpdateAlpha()
Prompt the user for a new alpha value.
bool allSupport(ImageDisplayProperties::Property prop)
Check if all images in the image list support a display property.
bool askNewColor(QColor *colorResult) const
Prompts the user for color values.
void append(Image *const &value)
Appends an image to the image list.
void applyShowFill(QStringList showFillValues)
Sets the visibility of the fill areas of the images in the image list based on a list of values.
QStringList saveAndToggleShowOutline()
Changes the visibility of the outline of the first image in the image list and synchronizes the visib...
@ MoveDownOne
Move the image backward.
void deleteFromDisk(Project *project)
Delete all of the contained Images from disk.
Property
This is a list of properties and actions that are possible.
static QColor fromRGBAString(QString)
Converts a QString to its QColor.
@ ShowLabel
True if the cube should show its display name (bool)
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Handle an XML start element.
void prepend(Image *const &value)
Inserts an image at the beginning of the image list.
QString imageDataRoot() const
Accessor for the root directory of the image data.
Serial Number list generator.
Manage a stack of content handlers for reading XML files.
@ ChangeTransparency
Change the alpha values of the image list.
bool askAlpha(int *alphaResult) const
Prompts the user for an alpha value.
SerialNumberList * serialNumberList()
Creates a SerialNumberList from the image list.
The main project for ipce.
@ ZOrdering
Data ignored. Tells if the cube supports the "move*" actions.
Internalizes a list of images and allows for operations on the entire list.
void push_back(Image *const &value)
Appends an image to the end of the image list.
QAction * createWorkOrder(Project *project, ImageListActionWorkOrder::Action action)
Creates an ImageListActionWorkOrder and sets the image list as the data for the work order.
~CopyImageDataFunctor()
Destructor for CopyImageDataFunctor.
void setName(QString newName)
Set the human-readable name of this image list.
void push_front(Image *const &value)
Prepends an image to the beginning of the image list.
void setShowDNs(bool)
Change the visibility of DNs associated with this cube.
bool supports(int property)
Support may come later, please make sure you are connected to the supportAdded signal.
QList< QAction * > supportedActions(Project *project=NULL)
Gets a list of pre-connected actions that have to do with display.
void deleteFromDisk()
Delete the image data from disk.
@ RandomizeColor
Set each image in the list to a random color.
QStringList saveAndApplyRandomColor()
Sets the color values of every image to a random color.
QDir dir() const
Returns the path of the file's parent directory as a QDir object.
@ Color
The color of the cube, default randomized (QColor)
int toInt(const QString &string)
Global function to convert from a string to an integer.
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Write the Image properties out to an XML file.
void clear()
Clears the image list.
void removeAt(int i)
Removes the image at an index.
void add(const QString &filename, bool def2filename=false)
Adds a new filename / serial number pair to the SerialNumberList.
void applyShowDNs(QStringList showDNsValues)
Sets the visibility of the DNs of the images in the image list based on a list of values.
void closeCube()
Cleans up the Cube pointer.
QString newProjectRoot() const
Get the top-level folder of the new project.
QString displayName() const
Returns the display name.
QString name() const
Get the human-readable name of this image list.
void copyToNewProjectRoot(const Project *project, FileName newProjectRoot)
Copy the cub/ecub files associated with this image into the new project.
This represents a cube in a project-based GUI interface.
FileName m_newProjectRoot
This stores the path to the root of the project that is going to be copied to.
QString toString() const
Returns a QString of the full file name including the file path, excluding the attributes with any Is...
QString projectRoot() const
Get the top-level folder of the project.
Image * takeAt(int i)
Removes the image at an index and returns it.
@ ToggleShowCubeData
Show or hide each image's DNs.
ImageDisplayProperties * displayProperties()
Get the display (GUI) properties (information) associated with this image.
@ ShowDNs
True if the cube should show DN values if possible (bool)
@ ChangeColor
Change the color values of the image list.
@ ZoomFit
Zoom in on the image so that it fits the screen.
void setShowFill(bool)
Change the visibility of the fill area associated with this cube.
const Project * m_project
This stores the name of the project that is going to be copied to.
QStringList saveAndToggleShowFill()
Changes the visibility of the fill area of the first image in the image list and synchronizes the vis...
void * operator()(Image *const &imageToCopy)
Copies the cub/ecub files for an image into m_project.
bool removeOne(Image *const &value)
Removes the first occurance of an image.
void setPath(QString newPath)
Set the relative path (from the project root) to this image list's folder.
@ ToggleShowOutline
Show or hide each image's outline.
@ MoveToBottom
Move the image to the back.
@ ShowFill
True if the cube should show a fill area if possible (bool)
ImageList & operator<<(const QList< Image * > &other)
Appends a list of images to the end of the image list.
Image * takeFirst()
Removes and returns the first image.
This class is used to read an images.xml file into an image list.
Image * takeLast()
Removes and returns the last image.
CopyImageDataFunctor(const Project *project, FileName newProjectRoot)
Constructor for CopyImageDataFunctor.
QStringList saveAndToggleShowDNs()
Changes the visibility of the DNs of the first image in the image list and synchronizes the visibilit...
void applyColors(QStringList colorValues, int column=0)
Sets the colors values of the images based on a list of values.
XmlHandler(ImageList *imageList, Project *project, QString dataRoot="")
Create an XML Handler (reader) that can populate the Image list class data.
void setShowOutline(bool)
Change the visibility of the outline associated with this cube.
Adds specific functionality to C++ strings.
void setShowLabel(bool)
Change the visibility of the display name associated with this cube.
QString original() const
Returns the full file name including the file path.
void applyShowLabel(QStringList showLabelValues)
Sets the visibility of the display names of the images in the image list based on a list of values.
iterator erase(iterator pos)
Erases a single image from the image list.
QVariant getValue(int property) const
Get a property's associated data.
void removeLast()
Removes the image at the end of the image list.
static QString imageDataRoot(QString projectRoot)
Appends the root directory name 'images' to the project .
int removeAll(Image *const &value)
Removes all occurances of an image.
QString m_path
This stores the directory name that contains the images in this image list.
void showRandomColor()
This applies a new semi-random color to every image's display property for every image in this image ...
void swap(QList< Image * > &other)
Swaps the image list with another list of images.
void applyAlphas(QStringList alphaValues)
Sets the alpha values of the images based on a list of values.
QString path() const
Returns the path of the file name.
This is free and unencumbered software released into the public domain.
QStringList saveAndToggleShowLabel()
Changes the visibility of the display name of the first image in the image list and synchronizes the ...
void askAndUpdateColor()
Prompt the user for a new color.
This is the GUI communication mechanism for cubes.