"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/backend/worksheet/plots/cartesian/XYCurve.cpp" between
labplot-2.8.1.tar.gz and labplot-2.8.2.tar.gz

About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.

XYCurve.cpp  (labplot-2.8.1):XYCurve.cpp  (labplot-2.8.2)
skipping to change at line 801 skipping to change at line 801
pen = d->linePen; pen = d->linePen;
pen.setWidthF(pen.widthF() * (horizontalRatio + verticalRatio) / 2.); pen.setWidthF(pen.widthF() * (horizontalRatio + verticalRatio) / 2.);
setLinePen(pen); setLinePen(pen);
//setValuesDistance(d->distance*); //setValuesDistance(d->distance*);
QFont font = d->valuesFont; QFont font = d->valuesFont;
font.setPointSizeF(font.pointSizeF()*horizontalRatio); font.setPointSizeF(font.pointSizeF()*horizontalRatio);
setValuesFont(font); setValuesFont(font);
} }
/*!
* returns \c true if the aspect being removed \c removedAspect is equal to \c c
olumn
* or to one of its parents. returns \c false otherwise.
*/
bool XYCurve::columnRemoved(const AbstractColumn* column, const AbstractAspect*
removedAspect) const {
// TODO: BAD HACK.
// In macrosXYCurve.h every parent of the column is connected to the func
tion aspectAboutToBeRemoved().
// When a column is removed, the function aspectAboutToBeRemoved is calle
d and the column pointer is set to nullptr.
// However, when a child of the parent is removed, the parent calls the a
spectAboutToBeRemoved() again, but
// the column was already disconnected.
// Better solution would be to emit aspectAboutToBeRemoved() for every co
lumn when their parents are removed.
// At the moment this signal is only emitted when the column is deleted d
irectly and not when its parent is deleted.
// Once this is done, the connection of all parents to the aspectAboutToB
eRemoved() signal can be removed.
if (!column)
return false;
bool removed = (removedAspect == column);
if (!removed) {
auto* parent = column->parentAspect();
while (parent) {
if (parent == removedAspect) {
removed = true;
break;
}
parent = parent->parentAspect();
}
}
return removed;
}
void XYCurve::xColumnAboutToBeRemoved(const AbstractAspect* aspect) { void XYCurve::xColumnAboutToBeRemoved(const AbstractAspect* aspect) {
Q_D(XYCurve); Q_D(XYCurve);
if (columnRemoved(d->xColumn, aspect)) { if (aspect == d->xColumn) {
disconnect(aspect, nullptr, this, nullptr); disconnect(aspect, nullptr, this, nullptr);
d->xColumn = nullptr; d->xColumn = nullptr;
d->retransform(); d->retransform();
} }
} }
void XYCurve::yColumnAboutToBeRemoved(const AbstractAspect* aspect) { void XYCurve::yColumnAboutToBeRemoved(const AbstractAspect* aspect) {
Q_D(XYCurve); Q_D(XYCurve);
if (columnRemoved(d->yColumn, aspect)) { if (aspect == d->yColumn) {
disconnect(aspect, nullptr, this, nullptr); disconnect(aspect, nullptr, this, nullptr);
d->yColumn = nullptr; d->yColumn = nullptr;
d->retransform(); d->retransform();
} }
} }
void XYCurve::valuesColumnAboutToBeRemoved(const AbstractAspect* aspect) { void XYCurve::valuesColumnAboutToBeRemoved(const AbstractAspect* aspect) {
Q_D(XYCurve); Q_D(XYCurve);
if (columnRemoved(d->valuesColumn, aspect)) { if (aspect == d->valuesColumn) {
disconnect(aspect, nullptr, this, nullptr); disconnect(aspect, nullptr, this, nullptr);
d->valuesColumn = nullptr; d->valuesColumn = nullptr;
d->updateValues(); d->updateValues();
} }
} }
void XYCurve::xErrorPlusColumnAboutToBeRemoved(const AbstractAspect* aspect) { void XYCurve::xErrorPlusColumnAboutToBeRemoved(const AbstractAspect* aspect) {
Q_D(XYCurve); Q_D(XYCurve);
if (columnRemoved(d->xErrorPlusColumn, aspect)) { if (aspect == d->xErrorPlusColumn) {
disconnect(aspect, nullptr, this, nullptr); disconnect(aspect, nullptr, this, nullptr);
d->xErrorPlusColumn = nullptr; d->xErrorPlusColumn = nullptr;
d->updateErrorBars(); d->updateErrorBars();
} }
} }
void XYCurve::xErrorMinusColumnAboutToBeRemoved(const AbstractAspect* aspect) { void XYCurve::xErrorMinusColumnAboutToBeRemoved(const AbstractAspect* aspect) {
Q_D(XYCurve); Q_D(XYCurve);
if (columnRemoved(d->xErrorMinusColumn, aspect)) { if (aspect == d->xErrorMinusColumn) {
disconnect(aspect, nullptr, this, nullptr); disconnect(aspect, nullptr, this, nullptr);
d->xErrorMinusColumn = nullptr; d->xErrorMinusColumn = nullptr;
d->updateErrorBars(); d->updateErrorBars();
} }
} }
void XYCurve::yErrorPlusColumnAboutToBeRemoved(const AbstractAspect* aspect) { void XYCurve::yErrorPlusColumnAboutToBeRemoved(const AbstractAspect* aspect) {
Q_D(XYCurve); Q_D(XYCurve);
if (columnRemoved(d->yErrorPlusColumn, aspect)) { if (aspect == d->yErrorPlusColumn) {
disconnect(aspect, nullptr, this, nullptr); disconnect(aspect, nullptr, this, nullptr);
d->yErrorPlusColumn = nullptr; d->yErrorPlusColumn = nullptr;
d->updateErrorBars(); d->updateErrorBars();
} }
} }
void XYCurve::yErrorMinusColumnAboutToBeRemoved(const AbstractAspect* aspect) { void XYCurve::yErrorMinusColumnAboutToBeRemoved(const AbstractAspect* aspect) {
Q_D(XYCurve); Q_D(XYCurve);
if (columnRemoved(d->yErrorMinusColumn, aspect)) { if (aspect == d->yErrorMinusColumn) {
disconnect(aspect, nullptr, this, nullptr); disconnect(aspect, nullptr, this, nullptr);
d->yErrorMinusColumn = nullptr; d->yErrorMinusColumn = nullptr;
d->updateErrorBars(); d->updateErrorBars();
} }
} }
void XYCurve::xColumnNameChanged() { void XYCurve::xColumnNameChanged() {
Q_D(XYCurve); Q_D(XYCurve);
setXColumnPath(d->xColumn->path()); setXColumnPath(d->xColumn->path());
} }
skipping to change at line 1501 skipping to change at line 1471
continue; continue;
} }
addLine(p0, p1, lastPoint, pixelDiff, num berOfPixelX); addLine(p0, p1, lastPoint, pixelDiff, num berOfPixelX);
skip++; skip++;
} else { } else {
skip = 0; skip = 0;
if (!isnan(lastPoint.x())) { if (!isnan(lastPoint.x())) {
lastPoint.setX(NAN); lastPoint.setX(NAN);
m_lines.append(QLineF(lastPoint, p1)); m_lines.append(QLineF(lastPoint, p1));
} }
if (!isnan(lastPoint.x())) // last l
ine
m_lines.append(QLineF(m_logicalPo
ints[endIndex-1], m_logicalPoints[endIndex]));
break;
} }
} }
if (!isnan(lastPoint.x())) // last line if (!isnan(lastPoint.x())) // last line
m_lines.append(QLineF(m_logicalPoints.at(endIndex - 1), m_logicalPoints.at(endIndex))); m_lines.append(QLineF(m_logicalPoints.at(endIndex - 1), m_logicalPoints.at(endIndex)));
break; break;
} }
case XYCurve::LineType::SplineCubicNatural: case XYCurve::LineType::SplineCubicNatural:
case XYCurve::LineType::SplineCubicPeriodic: case XYCurve::LineType::SplineCubicPeriodic:
case XYCurve::LineType::SplineAkimaNatural: case XYCurve::LineType::SplineAkimaNatural:
skipping to change at line 1627 skipping to change at line 1601
#ifdef PERFTRACE_CURVES #ifdef PERFTRACE_CURVES
PERFTRACE(name().toLatin1() + ", XYCurvePrivate::updateLines(), m ap lines to scene coordinates"); PERFTRACE(name().toLatin1() + ", XYCurvePrivate::updateLines(), m ap lines to scene coordinates");
#endif #endif
m_lines = cSystem->mapLogicalToScene(m_lines); m_lines = cSystem->mapLogicalToScene(m_lines);
} }
{ {
#ifdef PERFTRACE_CURVES #ifdef PERFTRACE_CURVES
PERFTRACE(name().toLatin1() + ", XYCurvePrivate::updateLines(), calculate new line path"); PERFTRACE(name().toLatin1() + ", XYCurvePrivate::updateLines(), calculate new line path");
#endif #endif
//new line path //new line path
for (const auto& line : qAsConst(m_lines)) { for (const auto& line : qAsConst(m_lines)) {
linePath.moveTo(line.p1()); linePath.moveTo(line.p1());
linePath.lineTo(line.p2()); linePath.lineTo(line.p2());
} }
} }
updateFilling(); updateFilling();
recalcShapeAndBoundingRect(); recalcShapeAndBoundingRect();
} }
/*! /*!
recalculates the painter path for the drop lines. recalculates the painter path for the drop lines.
Called each time when the type of the drop lines is changed. Called each time when the type of the drop lines is changed.
*/ */
skipping to change at line 1654 skipping to change at line 1628
if (dropLineType == XYCurve::DropLineType::NoDropLine) { if (dropLineType == XYCurve::DropLineType::NoDropLine) {
recalcShapeAndBoundingRect(); recalcShapeAndBoundingRect();
return; return;
} }
//calculate drop lines //calculate drop lines
QVector<QLineF> dlines; QVector<QLineF> dlines;
const double xMin = plot->xMin(); const double xMin = plot->xMin();
const double yMin = plot->yMin(); const double yMin = plot->yMin();
int i{0}; //don't skip the invisible points, we still need to calculate
//the drop lines falling into the plot region
switch (dropLineType) { switch (dropLineType) {
case XYCurve::DropLineType::NoDropLine: case XYCurve::DropLineType::NoDropLine:
break; break;
case XYCurve::DropLineType::X: case XYCurve::DropLineType::X:
for (const auto& point: qAsConst(m_logicalPoints)) { for (const auto& point: qAsConst(m_logicalPoints)) {
if (!m_pointVisible.at(i++)) continue;
dlines.append(QLineF(point, QPointF(point.x(), yMin))); dlines.append(QLineF(point, QPointF(point.x(), yMin)));
} }
break; break;
case XYCurve::DropLineType::Y: case XYCurve::DropLineType::Y:
for (const auto& point: qAsConst(m_logicalPoints)) { for (const auto& point: qAsConst(m_logicalPoints)) {
if (!m_pointVisible.at(i++)) continue;
dlines.append(QLineF(point, QPointF(xMin, point.y()))); dlines.append(QLineF(point, QPointF(xMin, point.y())));
} }
break; break;
case XYCurve::DropLineType::XY: case XYCurve::DropLineType::XY:
for (const auto& point: qAsConst(m_logicalPoints)) { for (const auto& point: qAsConst(m_logicalPoints)) {
if (!m_pointVisible.at(i++)) continue;
dlines.append(QLineF(point, QPointF(point.x(), yMin))); dlines.append(QLineF(point, QPointF(point.x(), yMin)));
dlines.append(QLineF(point, QPointF(xMin, point.y()))); dlines.append(QLineF(point, QPointF(xMin, point.y())));
} }
break; break;
case XYCurve::DropLineType::XZeroBaseline: case XYCurve::DropLineType::XZeroBaseline:
for (const auto& point: qAsConst(m_logicalPoints)) { for (const auto& point: qAsConst(m_logicalPoints)) {
if (!m_pointVisible.at(i++)) continue;
dlines.append(QLineF(point, QPointF(point.x(), 0))); dlines.append(QLineF(point, QPointF(point.x(), 0)));
} }
break; break;
case XYCurve::DropLineType::XMinBaseline: case XYCurve::DropLineType::XMinBaseline:
for (const auto& point: qAsConst(m_logicalPoints)) { for (const auto& point: qAsConst(m_logicalPoints)) {
if (!m_pointVisible.at(i++)) continue;
dlines.append(QLineF(point, QPointF(point.x(), yColumn->m inimum()))); dlines.append(QLineF(point, QPointF(point.x(), yColumn->m inimum())));
} }
break; break;
case XYCurve::DropLineType::XMaxBaseline: case XYCurve::DropLineType::XMaxBaseline:
for (const auto& point: qAsConst(m_logicalPoints)) { for (const auto& point: qAsConst(m_logicalPoints)) {
if (!m_pointVisible.at(i++)) continue;
dlines.append(QLineF(point, QPointF(point.x(), yColumn->m aximum()))); dlines.append(QLineF(point, QPointF(point.x(), yColumn->m aximum())));
} }
break; break;
} }
//map the drop lines to scene coordinates //map the drop lines to scene coordinates
dlines = cSystem->mapLogicalToScene(dlines); dlines = cSystem->mapLogicalToScene(dlines);
//new painter path for the drop lines //new painter path for the drop lines
for (const auto& line : qAsConst(dlines)) { for (const auto& line : qAsConst(dlines)) {
skipping to change at line 2727 skipping to change at line 2696
if (symbolsStyle != Symbol::Style::NoSymbols) { if (symbolsStyle != Symbol::Style::NoSymbols) {
painter->setOpacity(symbolsOpacity); painter->setOpacity(symbolsOpacity);
painter->setPen(symbolsPen); painter->setPen(symbolsPen);
painter->setBrush(symbolsBrush); painter->setBrush(symbolsBrush);
drawSymbols(painter); drawSymbols(painter);
} }
//draw values //draw values
if (valuesType != XYCurve::ValuesType::NoValues) { if (valuesType != XYCurve::ValuesType::NoValues) {
painter->setOpacity(valuesOpacity); painter->setOpacity(valuesOpacity);
//don't use any painter pen, since this will force QPainter to re painter->setPen(QPen(valuesColor));
nder the text outline which is expensive painter->setFont(valuesFont);
painter->setPen(Qt::NoPen);
painter->setBrush(valuesColor);
drawValues(painter); drawValues(painter);
} }
} }
void XYCurvePrivate::updatePixmap() { void XYCurvePrivate::updatePixmap() {
DEBUG(Q_FUNC_INFO << ", m_suppressRecalc = " << m_suppressRecalc); DEBUG(Q_FUNC_INFO << ", m_suppressRecalc = " << m_suppressRecalc);
if (m_suppressRecalc) if (m_suppressRecalc)
return; return;
WAIT_CURSOR; WAIT_CURSOR;
skipping to change at line 2822 skipping to change at line 2790
} }
/*! /*!
Drawing of symbolsPath is very slow, so we draw every symbol in the loop which is much faster (factor 10) Drawing of symbolsPath is very slow, so we draw every symbol in the loop which is much faster (factor 10)
*/ */
void XYCurvePrivate::drawSymbols(QPainter* painter) { void XYCurvePrivate::drawSymbols(QPainter* painter) {
QPainterPath path = Symbol::pathFromStyle(symbolsStyle); QPainterPath path = Symbol::pathFromStyle(symbolsStyle);
QTransform trafo; QTransform trafo;
trafo.scale(symbolsSize, symbolsSize); trafo.scale(symbolsSize, symbolsSize);
path = trafo.map(path);
trafo.reset(); if (symbolsRotationAngle != 0)
if (symbolsRotationAngle != 0) {
trafo.rotate(-symbolsRotationAngle); trafo.rotate(-symbolsRotationAngle);
path = trafo.map(path);
} path = trafo.map(path);
for (const auto& point : qAsConst(m_scenePoints)) { for (const auto& point : qAsConst(m_scenePoints)) {
trafo.reset(); trafo.reset();
trafo.translate(point.x(), point.y()); trafo.translate(point.x(), point.y());
painter->drawPath(trafo.map(path)); painter->drawPath(trafo.map(path));
} }
} }
void XYCurvePrivate::drawValues(QPainter* painter) { void XYCurvePrivate::drawValues(QPainter* painter) {
QTransform trafo;
QPainterPath path;
int i = 0; int i = 0;
for (const auto& point : qAsConst(m_valuePoints)) { for (const auto& point : qAsConst(m_valuePoints)) {
path = QPainterPath(); painter->translate(point);
path.addText(QPoint(0, 0), valuesFont, m_valueStrings.at(i++));
trafo.reset();
trafo.translate(point.x(), point.y());
if (valuesRotationAngle != 0) if (valuesRotationAngle != 0)
trafo.rotate(-valuesRotationAngle); painter->rotate(-valuesRotationAngle);
painter->drawPath(trafo.map(path)); painter->drawText(QPoint(0, 0), m_valueStrings.at(i++));
if (valuesRotationAngle != 0)
painter->rotate(valuesRotationAngle);
painter->translate(-point);
} }
} }
void XYCurvePrivate::drawFilling(QPainter* painter) { void XYCurvePrivate::drawFilling(QPainter* painter) {
for (const auto& pol : qAsConst(m_fillPolygons)) { for (const auto& pol : qAsConst(m_fillPolygons)) {
QRectF rect = pol.boundingRect(); QRectF rect = pol.boundingRect();
if (fillingType == PlotArea::BackgroundType::Color) { if (fillingType == PlotArea::BackgroundType::Color) {
switch (fillingColorStyle) { switch (fillingColorStyle) {
case PlotArea::BackgroundColorStyle::SingleColor: { case PlotArea::BackgroundColorStyle::SingleColor: {
painter->setBrush(QBrush(fillingFirstColo r)); painter->setBrush(QBrush(fillingFirstColo r));
skipping to change at line 3038 skipping to change at line 3003
writer->writeEndElement(); writer->writeEndElement();
//Values //Values
writer->writeStartElement( "values" ); writer->writeStartElement( "values" );
writer->writeAttribute( "type", QString::number(static_cast<int>(d->value sType)) ); writer->writeAttribute( "type", QString::number(static_cast<int>(d->value sType)) );
WRITE_COLUMN(d->valuesColumn, valuesColumn); WRITE_COLUMN(d->valuesColumn, valuesColumn);
writer->writeAttribute( "position", QString::number(static_cast<int>(d->v aluesPosition)) ); writer->writeAttribute( "position", QString::number(static_cast<int>(d->v aluesPosition)) );
writer->writeAttribute( "distance", QString::number(d->valuesDistance) ); writer->writeAttribute( "distance", QString::number(d->valuesDistance) );
writer->writeAttribute( "rotation", QString::number(d->valuesRotationAngl e) ); writer->writeAttribute( "rotation", QString::number(d->valuesRotationAngl e) );
writer->writeAttribute( "opacity", QString::number(d->valuesOpacity) ); writer->writeAttribute( "opacity", QString::number(d->valuesOpacity) );
//TODO values format and precision writer->writeAttribute("numericFormat", QString(d->valuesNumericFormat));
writer->writeAttribute("dateTimeFormat", d->valuesDateTimeFormat);
writer->writeAttribute( "precision", QString::number(d->valuesPrecision)
);
writer->writeAttribute( "prefix", d->valuesPrefix ); writer->writeAttribute( "prefix", d->valuesPrefix );
writer->writeAttribute( "suffix", d->valuesSuffix ); writer->writeAttribute( "suffix", d->valuesSuffix );
WRITE_QCOLOR(d->valuesColor); WRITE_QCOLOR(d->valuesColor);
WRITE_QFONT(d->valuesFont); WRITE_QFONT(d->valuesFont);
writer->writeEndElement(); writer->writeEndElement();
//Filling //Filling
writer->writeStartElement( "filling" ); writer->writeStartElement( "filling" );
writer->writeAttribute( "position", QString::number(static_cast<int>(d->f illingPosition)) ); writer->writeAttribute( "position", QString::number(static_cast<int>(d->f illingPosition)) );
writer->writeAttribute( "type", QString::number(static_cast<int>(d->filli ngType)) ); writer->writeAttribute( "type", QString::number(static_cast<int>(d->filli ngType)) );
skipping to change at line 3147 skipping to change at line 3114
attribs = reader->attributes(); attribs = reader->attributes();
READ_INT_VALUE("type", valuesType, ValuesType); READ_INT_VALUE("type", valuesType, ValuesType);
READ_COLUMN(valuesColumn); READ_COLUMN(valuesColumn);
READ_INT_VALUE("position", valuesPosition, ValuesPosition ); READ_INT_VALUE("position", valuesPosition, ValuesPosition );
READ_DOUBLE_VALUE("distance", valuesDistance); READ_DOUBLE_VALUE("distance", valuesDistance);
READ_DOUBLE_VALUE("rotation", valuesRotationAngle); READ_DOUBLE_VALUE("rotation", valuesRotationAngle);
READ_DOUBLE_VALUE("opacity", valuesOpacity); READ_DOUBLE_VALUE("opacity", valuesOpacity);
str = attribs.value("numericFormat").toString();
if (str.isEmpty())
reader->raiseWarning(attributeWarning.subs("numer
icFormat").toString());
else
d->valuesNumericFormat = *(str.toLatin1().data())
;
READ_STRING_VALUE("dateTimeFormat", valuesDateTimeFormat)
;
READ_INT_VALUE("precision", valuesPrecision, int);
//don't produce any warning if no prefix or suffix is set (empty string is allowed here in xml) //don't produce any warning if no prefix or suffix is set (empty string is allowed here in xml)
d->valuesPrefix = attribs.value("prefix").toString(); d->valuesPrefix = attribs.value("prefix").toString();
d->valuesSuffix = attribs.value("suffix").toString(); d->valuesSuffix = attribs.value("suffix").toString();
READ_QCOLOR(d->valuesColor); READ_QCOLOR(d->valuesColor);
READ_QFONT(d->valuesFont); READ_QFONT(d->valuesFont);
} else if (!preview && reader->name() == "filling") { } else if (!preview && reader->name() == "filling") {
attribs = reader->attributes(); attribs = reader->attributes();
READ_INT_VALUE("position", fillingPosition, FillingPositi on); READ_INT_VALUE("position", fillingPosition, FillingPositi on);
 End of changes. 26 change blocks. 
77 lines changed or deleted 50 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)