예제 #1
0
//! Load from XML
bool DatapickerImage::load(XmlStreamReader* reader) {
	if(!reader->isStartElement() || reader->name() != "datapickerImage") {
		reader->raiseError(i18n("no image element found"));
		return false;
	}

	if (!readBasicAttributes(reader))
		return false;

	QString attributeWarning = i18n("Attribute '%1' missing or empty, default value is used");
	QXmlStreamAttributes attribs;
	QString str;

	while (!reader->atEnd()) {
		reader->readNext();
		if (reader->isEndElement() && reader->name() == "datapickerImage")
			break;

		if (!reader->isStartElement())
			continue;

		if (reader->name() == "comment") {
			if (!readCommentElement(reader)) return false;
		} else if (reader->name() == "general") {
			attribs = reader->attributes();

			str = attribs.value("fileName").toString();
			d->fileName = str;

			str = attribs.value("plotPointsType").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("plotPointsType"));
			else
				d->plotPointsType = DatapickerImage::PointsType(str.toInt());

		} else if (reader->name() == "axisPoint") {
			attribs = reader->attributes();

			str = attribs.value("graphType").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("graphType"));
			else
				d->axisPoints.type = DatapickerImage::GraphType(str.toInt());

			str = attribs.value("ternaryScale").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("ternaryScale"));
			else
				d->axisPoints.ternaryScale = str.toDouble();

			str = attribs.value("axisPointLogicalX1").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointLogicalX1"));
			else
				d->axisPoints.logicalPos[0].setX(str.toDouble());

			str = attribs.value("axisPointLogicalY1").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointLogicalY1"));
			else
				d->axisPoints.logicalPos[0].setY(str.toDouble());

			str = attribs.value("axisPointLogicalZ1").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointLogicalZ1"));
			else
				d->axisPoints.logicalPos[0].setZ(str.toDouble());

			str = attribs.value("axisPointLogicalX2").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointLogicalX2"));
			else
				d->axisPoints.logicalPos[1].setX(str.toDouble());

			str = attribs.value("axisPointLogicalY2").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointLogicalY2"));
			else
				d->axisPoints.logicalPos[1].setY(str.toDouble());

			str = attribs.value("axisPointLogicalZ2").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointLogicalZ2"));
			else
				d->axisPoints.logicalPos[1].setZ(str.toDouble());

			str = attribs.value("axisPointLogicalX3").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointLogicalX3"));
			else
				d->axisPoints.logicalPos[2].setX(str.toDouble());

			str = attribs.value("axisPointLogicalY3").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointLogicalY3"));
			else
				d->axisPoints.logicalPos[2].setY(str.toDouble());

			str = attribs.value("axisPointLogicalZ3").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointLogicalZ3"));
			else
				d->axisPoints.logicalPos[2].setZ(str.toDouble());

			str = attribs.value("axisPointSceneX1").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointSceneX1"));
			else
				d->axisPoints.scenePos[0].setX(str.toDouble());

			str = attribs.value("axisPointSceneY1").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointSceneY1"));
			else
				d->axisPoints.scenePos[0].setY(str.toDouble());

			str = attribs.value("axisPointSceneX2").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointSceneX2"));
			else
				d->axisPoints.scenePos[1].setX(str.toDouble());

			str = attribs.value("axisPointSceneY2").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointSceneY2"));
			else
				d->axisPoints.scenePos[1].setY(str.toDouble());

			str = attribs.value("axisPointSceneX3").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointSceneX3"));
			else
				d->axisPoints.scenePos[2].setX(str.toDouble());

			str = attribs.value("axisPointSceneY3").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("axisPointSceneY3"));
			else
				d->axisPoints.scenePos[2].setY(str.toDouble());

		} else if (reader->name() == "editorSettings") {
			attribs = reader->attributes();

			str = attribs.value("plotImageType").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("plotImageType"));
			else
				d->plotImageType = DatapickerImage::PlotImageType(str.toInt());

			str = attribs.value("rotationAngle").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("rotationAngle"));
			else
				d->rotationAngle = str.toFloat();

			str = attribs.value("minSegmentLength").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("minSegmentLength"));
			else
				d->minSegmentLength = str.toInt();

			str = attribs.value("pointSeparation").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("pointSeparation"));
			else
				d->pointSeparation = str.toInt();

			str = attribs.value("foregroundThresholdHigh").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("foregroundThresholdHigh"));
			else
				d->settings.foregroundThresholdHigh = str.toInt();

			str = attribs.value("foregroundThresholdLow").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("foregroundThresholdLow"));
			else
				d->settings.foregroundThresholdLow = str.toInt();

			str = attribs.value("hueThresholdHigh").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("hueThresholdHigh"));
			else
				d->settings.hueThresholdHigh = str.toInt();

			str = attribs.value("hueThresholdLow").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("hueThresholdLow"));
			else
				d->settings.hueThresholdLow = str.toInt();

			str = attribs.value("intensityThresholdHigh").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("intensityThresholdHigh"));
			else
				d->settings.intensityThresholdHigh = str.toInt();

			str = attribs.value("intensityThresholdLow").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("intensityThresholdLow"));
			else
				d->settings.intensityThresholdLow = str.toInt();

			str = attribs.value("saturationThresholdHigh").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("saturationThresholdHigh"));
			else
				d->settings.saturationThresholdHigh = str.toInt();

			str = attribs.value("saturationThresholdLow").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("saturationThresholdLow"));
			else
				d->settings.saturationThresholdLow = str.toInt();

			str = attribs.value("valueThresholdHigh").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("valueThresholdHigh"));
			else
				d->settings.valueThresholdHigh = str.toInt();

			str = attribs.value("valueThresholdLow").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("valueThresholdLow"));
			else
				d->settings.valueThresholdLow = str.toInt();

		} else if(reader->name() == "symbolProperties") {
			attribs = reader->attributes();

			str = attribs.value("pointRotationAngle").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("pointRotationAngle"));
			else
				d->pointRotationAngle = str.toFloat();

			str = attribs.value("pointOpacity").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("pointOpacity"));
			else
				d->pointOpacity = str.toFloat();

			str = attribs.value("pointSize").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("pointSize"));
			else
				d->pointSize = str.toFloat();

			str = attribs.value("pointStyle").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("pointStyle"));
			else
				d->pointStyle = (Symbol::Style)str.toInt();

			str = attribs.value("pointVisibility").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("pointVisibility"));
			else
				d->pointVisibility = (bool)str.toInt();

			READ_QBRUSH(d->pointBrush);
			READ_QPEN(d->pointPen);
		} else if(reader->name() == "datapickerPoint") {
			DatapickerPoint* datapickerPoint = new DatapickerPoint("");
			datapickerPoint->setHidden(true);
			if (!datapickerPoint->load(reader)) {
				delete datapickerPoint;
				return false;
			} else {
				addChild(datapickerPoint);
			}
		} else { // unknown element
			reader->raiseWarning(i18n("unknown element '%1'", reader->name().toString()));
			if (!reader->skipToEndElement()) return false;
		}
	}

	d->uploadImage(d->fileName);
	d->retransform();
	return true;
}
예제 #2
0
//! Load from XML
bool DatapickerCurve::load(XmlStreamReader* reader) {
	Q_D(DatapickerCurve);

	if(!reader->isStartElement() || reader->name() != "datapickerCurve") {
		reader->raiseError(i18n("no dataPicker curve element found"));
		return false;
	}

	if (!readBasicAttributes(reader))
		return false;

	QString attributeWarning = i18n("Attribute '%1' missing or empty, default value is used");
	QXmlStreamAttributes attribs;
	QString str;

	while (!reader->atEnd()) {
		reader->readNext();
		if (reader->isEndElement() && reader->name() == "datapickerCurve")
			break;

		if (!reader->isStartElement())
			continue;

		if (reader->name() == "comment") {
			if (!readCommentElement(reader)) return false;
		} else if (reader->name() == "general") {
			attribs = reader->attributes();

			str = attribs.value("curveErrorType_X").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("curveErrorType_X"));
			else
				d->curveErrorTypes.x = ErrorType(str.toInt());

			str = attribs.value("curveErrorType_Y").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("curveErrorType_Y"));
			else
				d->curveErrorTypes.y = ErrorType(str.toInt());

			READ_COLUMN(posXColumn);
			READ_COLUMN(posYColumn);
			READ_COLUMN(posZColumn);
			READ_COLUMN(plusDeltaXColumn);
			READ_COLUMN(minusDeltaXColumn);
			READ_COLUMN(plusDeltaYColumn);
			READ_COLUMN(minusDeltaYColumn);

		} else if(reader->name() == "symbolProperties") {
			attribs = reader->attributes();

			str = attribs.value("pointRotationAngle").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("pointRotationAngle"));
			else
				d->pointRotationAngle = str.toFloat();

			str = attribs.value("pointOpacity").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("pointOpacity"));
			else
				d->pointOpacity = str.toFloat();

			str = attribs.value("pointSize").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("pointSize"));
			else
				d->pointSize = str.toFloat();

			str = attribs.value("pointStyle").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("pointStyle"));
			else
				d->pointStyle = (Symbol::Style)str.toInt();

			str = attribs.value("pointVisibility").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("pointVisibility"));
			else
				d->pointVisibility = (bool)str.toInt();

			READ_QBRUSH(d->pointBrush);
			READ_QPEN(d->pointPen);
		} else if(reader->name() == "errorBarProperties") {
			attribs = reader->attributes();

			str = attribs.value("pointErrorBarSize").toString();
			if(str.isEmpty())
				reader->raiseWarning(attributeWarning.arg("pointErrorBarSize"));
			else
				d->pointErrorBarSize = str.toFloat();

			READ_QBRUSH(d->pointErrorBarBrush);
			READ_QPEN(d->pointErrorBarPen);
		} else if (reader->name() == "datapickerPoint") {
			DatapickerPoint* curvePoint = new DatapickerPoint("");
			curvePoint->setHidden(true);
			if (!curvePoint->load(reader)) {
				delete curvePoint;
				return false;
			} else {
				addChild(curvePoint);
				curvePoint->initErrorBar(curveErrorTypes());
			}
		} else if (reader->name() == "spreadsheet") {
			Spreadsheet* datasheet = new Spreadsheet(0, "spreadsheet", true);
			if (!datasheet->load(reader)) {
				delete datasheet;
				return false;
			} else {
				addChild(datasheet);
				m_datasheet = datasheet;
			}
		} else { // unknown element
			reader->raiseWarning(i18n("unknown element '%1'", reader->name().toString()));
			if (!reader->skipToEndElement()) return false;
		}
	}

	d->retransform();
	return true;
}
예제 #3
0
//! Load from XML
bool CartesianPlotLegend::load(XmlStreamReader* reader) {
	Q_D(CartesianPlotLegend);

    if(!reader->isStartElement() || reader->name() != "cartesianPlotLegend"){
        reader->raiseError(i18n("no cartesian plot legend element found"));
        return false;
    }

    if (!readBasicAttributes(reader))
        return false;

    QString attributeWarning = i18n("Attribute '%1' missing or empty, default value is used");
    QXmlStreamAttributes attribs;
    QString str;

    while (!reader->atEnd()){
        reader->readNext();
        if (reader->isEndElement() && reader->name() == "cartesianPlotLegend")
            break;

        if (!reader->isStartElement())
            continue;

        if (reader->name() == "comment"){
            if (!readCommentElement(reader)) return false;
		}else if (reader->name() == "general"){
			attribs = reader->attributes();

			READ_QCOLOR(d->labelColor);
			READ_QFONT(d->labelFont);

			str = attribs.value("columnMajor").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("'columnMajor'"));
            else
                d->labelColumnMajor = str.toInt();

			str = attribs.value("lineSymbolWidth").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("'lineSymbolWidth'"));
            else
                d->lineSymbolWidth = str.toDouble();

			str = attribs.value("visible").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("'visible'"));
            else
                d->setVisible(str.toInt());
		}else if (reader->name() == "geometry"){
            attribs = reader->attributes();

            str = attribs.value("x").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("'x'"));
            else
                d->position.point.setX(str.toDouble());

            str = attribs.value("y").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("'y'"));
            else
                d->position.point.setY(str.toDouble());

            str = attribs.value("horizontalPosition").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("'horizontalPosition'"));
            else
                d->position.horizontalPosition = (CartesianPlotLegend::HorizontalPosition)str.toInt();

            str = attribs.value("verticalPosition").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("'verticalPosition'"));
            else
                d->position.verticalPosition = (CartesianPlotLegend::VerticalPosition)str.toInt();
        }else if(reader->name() == "textLabel"){
            if (!d->title->load(reader)){
                delete d->title;
				d->title=0;
                return false;
            }
		}else if (reader->name() == "background"){
            attribs = reader->attributes();

            str = attribs.value("type").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("type"));
            else
                d->backgroundType = PlotArea::BackgroundType(str.toInt());

            str = attribs.value("colorStyle").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("colorStyle"));
            else
                d->backgroundColorStyle = PlotArea::BackgroundColorStyle(str.toInt());

            str = attribs.value("imageStyle").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("imageStyle"));
            else
                d->backgroundImageStyle = PlotArea::BackgroundImageStyle(str.toInt());

            str = attribs.value("brushStyle").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("brushStyle"));
            else
                d->backgroundBrushStyle = Qt::BrushStyle(str.toInt());

            str = attribs.value("firstColor_r").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("firstColor_r"));
            else
                d->backgroundFirstColor.setRed(str.toInt());

            str = attribs.value("firstColor_g").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("firstColor_g"));
            else
                d->backgroundFirstColor.setGreen(str.toInt());

            str = attribs.value("firstColor_b").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("firstColor_b"));
            else
                d->backgroundFirstColor.setBlue(str.toInt());

            str = attribs.value("secondColor_r").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("secondColor_r"));
            else
                d->backgroundSecondColor.setRed(str.toInt());

            str = attribs.value("secondColor_g").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("secondColor_g"));
            else
                d->backgroundSecondColor.setGreen(str.toInt());

            str = attribs.value("secondColor_b").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("secondColor_b"));
            else
                d->backgroundSecondColor.setBlue(str.toInt());

            str = attribs.value("fileName").toString();
            d->backgroundFileName = str;

            str = attribs.value("opacity").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("opacity"));
            else
                d->backgroundOpacity = str.toDouble();
		}else if (reader->name() == "border"){
			attribs = reader->attributes();

			READ_QPEN(d->borderPen);

            str = attribs.value("borderOpacity").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("borderOpacity"));
            else
                d->borderOpacity = str.toDouble();
        }else if (reader->name() == "layout"){
            attribs = reader->attributes();

            str = attribs.value("topMargin").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("topMargin"));
            else
                d->layoutTopMargin = str.toDouble();

            str = attribs.value("bottomMargin").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("bottomMargin"));
            else
                d->layoutBottomMargin = str.toDouble();

            str = attribs.value("leftMargin").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("leftMargin"));
            else
                d->layoutLeftMargin = str.toDouble();

            str = attribs.value("rightMargin").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("rightMargin"));
            else
                d->layoutRightMargin = str.toDouble();

            str = attribs.value("verticalSpacing").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("verticalSpacing"));
            else
                d->layoutVerticalSpacing = str.toDouble();

            str = attribs.value("horizontalSpacing").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("horizontalSpacing"));
            else
                d->layoutHorizontalSpacing = str.toDouble();

            str = attribs.value("columnCount").toString();
            if(str.isEmpty())
                reader->raiseWarning(attributeWarning.arg("columnCount"));
            else
                d->layoutColumnCount = str.toInt();
		}
	}

	return true;
}