Esempio n. 1
0
QDomDocument StyleNode::openStyleDoc(const QString& path)
{
    QDomDocument doc = QDomDocument(XML_DOM_TYPE);
    QFile file(path);
    if ( !file.open(QIODevice::ReadOnly) ) throw VisualizationException("Could not open style file " + file.fileName() + ".");

    if ( !doc.setContent(&file) || doc.isNull() )
    {
        file.close();
        throw VisualizationException("Reading of the XML structure of file " + file.fileName() + " failed.");
    }

    file.close();
    return doc;
}
Esempio n. 2
0
QString StyleNode::getProperty(QStringList path)
{
    QDomElement e = getElement(path);
    if (e.isNull())
        throw VisualizationException("Could not find the style property '"+ path.join("/") + "'.");
    return e.firstChild().nodeValue();
}
Esempio n. 3
0
void StyleLoader::load(const QString& propertyName, double& value)
{
	bool ok = true;

	value = getProperty(propertyName).toDouble(&ok);
	if ( !ok ) throw VisualizationException("Could not read double value property '" + propertyName + "'");
}
Esempio n. 4
0
void SvgShapeStyle::load(StyleLoader& sl)
{
	ShapeStyle::load(sl);
	sl.load("filename", filename_);
	sl.load("topContentMarginFraction", topContentMarginFraction_);
	sl.load("bottomContentMarginFraction", bottomContentMarginFraction_);
	sl.load("leftContentMarginFraction", leftContentMarginFraction_);
	sl.load("rightContentMarginFraction", rightContentMarginFraction_);

	if (filename_.isEmpty()) return;
	if (!renderer_.load(filename_)) throw VisualizationException("Could not read SVG shape: " + filename_);
}
Esempio n. 5
0
StyleNode::StyleNode(StyleNode* parent_, const QString& prototypeName, const QString& currentFolder) :
    parent(parent_)
{
    folder = currentFolder + "/" + prototypeName; // Try relative address
    if (!QFile::exists(folder)) folder = baseFolder + "/" + prototypeName; // Try absolute path (rooted at the styles folder)
    if (!QFile::exists(folder)) throw VisualizationException("Could not find the prototype style " + prototypeName);

    QString fileName = QFileInfo(folder).fileName();
    folder = QFileInfo(folder).path();
    doc = openStyleDoc(folder + "/" + fileName);
    elem = doc.documentElement();

    init();
}
Esempio n. 6
0
ShapeStyle* Shape::createNewShapeStyle(const QString& shapeName)
{
	if (shapeStyleConstructors.contains(shapeName)) return shapeStyleConstructors.value(shapeName)();
	else throw VisualizationException("Trying to create a new shape style for an unregistered shape type " + shapeName);
}
Esempio n. 7
0
Shape* Shape::createNewShape(const QString& shapeName, Item* parent)
{
	if (shapeConstructors.contains(shapeName)) return shapeConstructors.value(shapeName)(parent);
	else throw VisualizationException("Trying to create a new shape for an unregistered type " + shapeName);
}