15#include <QRegularExpression>
18#include <QXmlStreamWriter>
20#include "ControlDisplayProperties.h"
21#include "ControlNet.h"
23#include "IException.h"
47 catch (IException &e) {
48 throw IException(e, IException::Programmer,
"Error opening control net.", _FILEINFO_);
54 m_id =
new QUuid(QUuid::createUuid());
76 m_id =
new QUuid(QUuid::createUuid());
100 m_id =
new QUuid(QUuid::createUuid());
156 catch (IException &e) {
157 throw IException(e, IException::Programmer,
"Error opening control net.", _FILEINFO_);
181 catch (IException &e) {
182 throw IException(e, IException::Programmer,
"Cannot write control net.", _FILEINFO_);
224 m_modified = modified;
264 return m_id->toString().remove(QRegularExpression(
"[{}]"));
279 QString newNetworkPath = project->
cnetRoot(newProjectRoot.toString()) +
"/" +
291 if (!QFile::copy(oldNetworkPath,newNetworkPath) ) {
292 throw IException(IException::Io,
"Error saving control net.", _FILEINFO_);
318 throw IException(IException::Io,
319 tr(
"Could not remove file [%1]").arg(
m_fileName),
340 FileName newName(project->
cnetRoot() +
"/" +
341 original.dir().dirName() +
"/" + original.name());
355 FileName newProjectRoot)
const {
356 stream.writeStartElement(
"controlNet");
357 stream.writeAttribute(
"id",
m_id->toString());
359 stream.writeAttribute(
"fileName", FileName(
m_fileName).name());
363 stream.writeEndElement();
This is the GUI communication mechanism for cubes.
QString id() const
Access the unique ID associated with this Control.
ControlNet * controlNet()
Open and return a pointer to the ControlNet for this Control.
ControlDisplayProperties * displayProperties()
Access a pointer to the display properties for the control network.
QString m_fileName
Project associated with this control.
void deleteFromDisk()
Delete the control net from disk.
Control(QString cnetFileName, QObject *parent=0)
Create a Control from control net located on disk.
bool write()
@description Write control net to disk.
void copyToNewProjectRoot(const Project *project, FileName newProjectRoot)
Copies the files of the given Project to the given location.
void setModified(bool modified=true)
@description Sets the modification state of this control.
ControlNet * m_controlNet
A pointer to the ControlNet object associated with this Control object.
bool isModified()
@description Has this control been modified?
~Control()
Destroys Control object.
void updateFileName(Project *)
Change the on-disk file name for this control to be where the control ought to be in the given projec...
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Method to write this Control object's member data to an XML stream.
void openControlNet()
Sets the ControlNet from the control net file name provided in the constructor.
QString fileName() const
Access the name of the control network file associated with this Control.
ControlDisplayProperties * m_displayProperties
Contains the display properties for this Control object.
QUuid * m_id
A unique ID for this Control.
void closeControlNet()
Cleans up the ControlNet pointer.
void Write(const QString &filename, bool pvl=false)
Writes out the control network.
The main project for ipce.
static QString cnetRoot(QString projectRoot)
Appends the root directory name 'cnets' to the project.
QString projectRoot() const
Get the top-level folder of the project.
This is free and unencumbered software released into the public domain.
QString toString(const LinearAlgebra::Vector &vector, int precision)
A global function to format LinearAlgebra::Vector as a QString with the given precision.