"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/backend/worksheet/plots/cartesian/CartesianPlot.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.

CartesianPlot.cpp  (labplot-2.8.1):CartesianPlot.cpp  (labplot-2.8.2)
skipping to change at line 33 skipping to change at line 33
* * * *
* You should have received a copy of the GNU General Public License * * You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software * * along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA * * Boston, MA 02110-1301 USA *
* * * *
***************************************************************************/ ***************************************************************************/
#include "CartesianPlot.h" #include "CartesianPlot.h"
#include "CartesianPlotPrivate.h" #include "CartesianPlotPrivate.h"
#include "Axis.h"
#include "XYCurve.h" #include "XYCurve.h"
#include "Histogram.h" #include "Histogram.h"
#include "XYEquationCurve.h" #include "XYEquationCurve.h"
#include "XYDataReductionCurve.h" #include "XYDataReductionCurve.h"
#include "XYDifferentiationCurve.h" #include "XYDifferentiationCurve.h"
#include "XYIntegrationCurve.h" #include "XYIntegrationCurve.h"
#include "XYInterpolationCurve.h" #include "XYInterpolationCurve.h"
#include "XYSmoothCurve.h" #include "XYSmoothCurve.h"
#include "XYFitCurve.h" #include "XYFitCurve.h"
#include "XYFourierFilterCurve.h" #include "XYFourierFilterCurve.h"
skipping to change at line 191 skipping to change at line 190
d->type = type; d->type = type;
switch (type) { switch (type) {
case Type::FourAxes: { case Type::FourAxes: {
d->xMin = 0.0; d->xMin = 0.0;
d->xMax = 1.0; d->xMax = 1.0;
d->yMin = 0.0; d->yMin = 0.0;
d->yMax = 1.0; d->yMax = 1.0;
//Axes //Axes
Axis* axis = new Axis("x axis 1", Axis::Orientation::Hori zontal); Axis* axis = new Axis(QLatin1String("x"), Axis::Orientati on::Horizontal);
axis->setDefault(true); axis->setDefault(true);
axis->setSuppressRetransform(true); axis->setSuppressRetransform(true);
addChild(axis); addChild(axis);
axis->setPosition(Axis::Position::Bottom); axis->setPosition(Axis::Position::Bottom);
axis->setStart(0); axis->setStart(0);
axis->setEnd(1); axis->setEnd(1);
axis->setMajorTicksDirection(Axis::ticksIn); axis->setMajorTicksDirection(Axis::ticksIn);
axis->setMajorTicksNumber(6); axis->setMajorTicksNumber(6);
axis->setMinorTicksDirection(Axis::ticksIn); axis->setMinorTicksDirection(Axis::ticksIn);
axis->setMinorTicksNumber(1); axis->setMinorTicksNumber(1);
axis->setSuppressRetransform(false); axis->setSuppressRetransform(false);
axis = new Axis("x axis 2", Axis::Orientation::Horizontal ); axis = new Axis(QLatin1String("x2"), Axis::Orientation::H orizontal);
axis->setDefault(true); axis->setDefault(true);
axis->setSuppressRetransform(true); axis->setSuppressRetransform(true);
addChild(axis); addChild(axis);
axis->setPosition(Axis::Position::Top); axis->setPosition(Axis::Position::Top);
axis->setStart(0); axis->setStart(0);
axis->setEnd(1); axis->setEnd(1);
axis->setMajorTicksDirection(Axis::ticksIn); axis->setMajorTicksDirection(Axis::ticksIn);
axis->setMajorTicksNumber(6); axis->setMajorTicksNumber(6);
axis->setMinorTicksDirection(Axis::ticksIn); axis->setMinorTicksDirection(Axis::ticksIn);
axis->setMinorTicksNumber(1); axis->setMinorTicksNumber(1);
QPen pen = axis->minorGridPen(); QPen pen = axis->minorGridPen();
pen.setStyle(Qt::NoPen); pen.setStyle(Qt::NoPen);
axis->setMajorGridPen(pen); axis->setMajorGridPen(pen);
pen = axis->minorGridPen(); pen = axis->minorGridPen();
pen.setStyle(Qt::NoPen); pen.setStyle(Qt::NoPen);
axis->setMinorGridPen(pen); axis->setMinorGridPen(pen);
axis->setLabelsPosition(Axis::LabelsPosition::NoLabels); axis->setLabelsPosition(Axis::LabelsPosition::NoLabels);
axis->title()->setText(QString()); axis->title()->setText(QString());
axis->setSuppressRetransform(false); axis->setSuppressRetransform(false);
axis = new Axis("y axis 1", Axis::Orientation::Vertical); axis = new Axis(QLatin1String("y"), Axis::Orientation::Ve rtical);
axis->setDefault(true); axis->setDefault(true);
axis->setSuppressRetransform(true); axis->setSuppressRetransform(true);
addChild(axis); addChild(axis);
axis->setPosition(Axis::Position::Left); axis->setPosition(Axis::Position::Left);
axis->setStart(0); axis->setStart(0);
axis->setEnd(1); axis->setEnd(1);
axis->setMajorTicksDirection(Axis::ticksIn); axis->setMajorTicksDirection(Axis::ticksIn);
axis->setMajorTicksNumber(6); axis->setMajorTicksNumber(6);
axis->setMinorTicksDirection(Axis::ticksIn); axis->setMinorTicksDirection(Axis::ticksIn);
axis->setMinorTicksNumber(1); axis->setMinorTicksNumber(1);
axis->setSuppressRetransform(false); axis->setSuppressRetransform(false);
axis = new Axis("y axis 2", Axis::Orientation::Vertical); axis = new Axis(QLatin1String("y2"), Axis::Orientation::V ertical);
axis->setDefault(true); axis->setDefault(true);
axis->setSuppressRetransform(true); axis->setSuppressRetransform(true);
addChild(axis); addChild(axis);
axis->setPosition(Axis::Position::Right); axis->setPosition(Axis::Position::Right);
axis->setStart(0); axis->setStart(0);
axis->setEnd(1); axis->setEnd(1);
axis->setOffset(1); axis->setOffset(1);
axis->setMajorTicksDirection(Axis::ticksIn); axis->setMajorTicksDirection(Axis::ticksIn);
axis->setMajorTicksNumber(6); axis->setMajorTicksNumber(6);
axis->setMinorTicksDirection(Axis::ticksIn); axis->setMinorTicksDirection(Axis::ticksIn);
skipping to change at line 268 skipping to change at line 267
axis->setSuppressRetransform(false); axis->setSuppressRetransform(false);
break; break;
} }
case Type::TwoAxes: { case Type::TwoAxes: {
d->xMin = 0.0; d->xMin = 0.0;
d->xMax = 1.0; d->xMax = 1.0;
d->yMin = 0.0; d->yMin = 0.0;
d->yMax = 1.0; d->yMax = 1.0;
Axis* axis = new Axis("x axis 1", Axis::Orientation::Hori zontal); Axis* axis = new Axis(QLatin1String("x"), Axis::Orientati on::Horizontal);
axis->setDefault(true); axis->setDefault(true);
axis->setSuppressRetransform(true); axis->setSuppressRetransform(true);
addChild(axis); addChild(axis);
axis->setPosition(Axis::Position::Bottom); axis->setPosition(Axis::Position::Bottom);
axis->setStart(0); axis->setStart(0);
axis->setEnd(1); axis->setEnd(1);
axis->setMajorTicksDirection(Axis::ticksBoth); axis->setMajorTicksDirection(Axis::ticksBoth);
axis->setMajorTicksNumber(6); axis->setMajorTicksNumber(6);
axis->setMinorTicksDirection(Axis::ticksBoth); axis->setMinorTicksDirection(Axis::ticksBoth);
axis->setMinorTicksNumber(1); axis->setMinorTicksNumber(1);
axis->setArrowType(Axis::ArrowType::FilledSmall); axis->setArrowType(Axis::ArrowType::FilledSmall);
axis->setSuppressRetransform(false); axis->setSuppressRetransform(false);
axis = new Axis("y axis 1", Axis::Orientation::Vertical); axis = new Axis(QLatin1String("y"), Axis::Orientation::Ve rtical);
axis->setDefault(true); axis->setDefault(true);
axis->setSuppressRetransform(true); axis->setSuppressRetransform(true);
addChild(axis); addChild(axis);
axis->setPosition(Axis::Position::Left); axis->setPosition(Axis::Position::Left);
axis->setStart(0); axis->setStart(0);
axis->setEnd(1); axis->setEnd(1);
axis->setMajorTicksDirection(Axis::ticksBoth); axis->setMajorTicksDirection(Axis::ticksBoth);
axis->setMajorTicksNumber(6); axis->setMajorTicksNumber(6);
axis->setMinorTicksDirection(Axis::ticksBoth); axis->setMinorTicksDirection(Axis::ticksBoth);
axis->setMinorTicksNumber(1); axis->setMinorTicksNumber(1);
skipping to change at line 311 skipping to change at line 310
d->yMin = -0.5; d->yMin = -0.5;
d->yMax = 0.5; d->yMax = 0.5;
d->horizontalPadding = Worksheet::convertToSceneUnits(1.0 , Worksheet::Unit::Centimeter); d->horizontalPadding = Worksheet::convertToSceneUnits(1.0 , Worksheet::Unit::Centimeter);
d->verticalPadding = Worksheet::convertToSceneUnits(1.0, Worksheet::Unit::Centimeter); d->verticalPadding = Worksheet::convertToSceneUnits(1.0, Worksheet::Unit::Centimeter);
QPen pen = m_plotArea->borderPen(); QPen pen = m_plotArea->borderPen();
pen.setStyle(Qt::NoPen); pen.setStyle(Qt::NoPen);
m_plotArea->setBorderPen(pen); m_plotArea->setBorderPen(pen);
Axis* axis = new Axis("x axis 1", Axis::Orientation::Hori zontal); Axis* axis = new Axis(QLatin1String("x"), Axis::Orientati on::Horizontal);
axis->setDefault(true); axis->setDefault(true);
axis->setSuppressRetransform(true); axis->setSuppressRetransform(true);
addChild(axis); addChild(axis);
axis->setPosition(Axis::Position::Centered); axis->setPosition(Axis::Position::Centered);
axis->setStart(-0.5); axis->setStart(-0.5);
axis->setEnd(0.5); axis->setEnd(0.5);
axis->setMajorTicksDirection(Axis::ticksBoth); axis->setMajorTicksDirection(Axis::ticksBoth);
axis->setMajorTicksNumber(6); axis->setMajorTicksNumber(6);
axis->setMinorTicksDirection(Axis::ticksBoth); axis->setMinorTicksDirection(Axis::ticksBoth);
axis->setMinorTicksNumber(1); axis->setMinorTicksNumber(1);
axis->setArrowType(Axis::ArrowType::FilledSmall); axis->setArrowType(Axis::ArrowType::FilledSmall);
axis->title()->setText(QString()); axis->title()->setText(QString());
axis->setSuppressRetransform(false); axis->setSuppressRetransform(false);
axis = new Axis("y axis 1", Axis::Orientation::Vertical); axis = new Axis(QLatin1String("y"), Axis::Orientation::Ve rtical);
axis->setDefault(true); axis->setDefault(true);
axis->setSuppressRetransform(true); axis->setSuppressRetransform(true);
addChild(axis); addChild(axis);
axis->setPosition(Axis::Position::Centered); axis->setPosition(Axis::Position::Centered);
axis->setStart(-0.5); axis->setStart(-0.5);
axis->setEnd(0.5); axis->setEnd(0.5);
axis->setMajorTicksDirection(Axis::ticksBoth); axis->setMajorTicksDirection(Axis::ticksBoth);
axis->setMajorTicksNumber(6); axis->setMajorTicksNumber(6);
axis->setMinorTicksDirection(Axis::ticksBoth); axis->setMinorTicksDirection(Axis::ticksBoth);
axis->setMinorTicksNumber(1); axis->setMinorTicksNumber(1);
skipping to change at line 356 skipping to change at line 355
d->yMin = -0.5; d->yMin = -0.5;
d->yMax = 0.5; d->yMax = 0.5;
d->horizontalPadding = Worksheet::convertToSceneUnits(1.0 , Worksheet::Unit::Centimeter); d->horizontalPadding = Worksheet::convertToSceneUnits(1.0 , Worksheet::Unit::Centimeter);
d->verticalPadding = Worksheet::convertToSceneUnits(1.0, Worksheet::Unit::Centimeter); d->verticalPadding = Worksheet::convertToSceneUnits(1.0, Worksheet::Unit::Centimeter);
QPen pen = m_plotArea->borderPen(); QPen pen = m_plotArea->borderPen();
pen.setStyle(Qt::NoPen); pen.setStyle(Qt::NoPen);
m_plotArea->setBorderPen(pen); m_plotArea->setBorderPen(pen);
Axis* axis = new Axis("x axis 1", Axis::Orientation::Hori zontal); Axis* axis = new Axis(QLatin1String("x"), Axis::Orientati on::Horizontal);
axis->setDefault(true); axis->setDefault(true);
axis->setSuppressRetransform(true); axis->setSuppressRetransform(true);
addChild(axis); addChild(axis);
axis->setPosition(Axis::Position::Custom); axis->setPosition(Axis::Position::Custom);
axis->setOffset(0); axis->setOffset(0);
axis->setStart(-0.5); axis->setStart(-0.5);
axis->setEnd(0.5); axis->setEnd(0.5);
axis->setMajorTicksDirection(Axis::ticksBoth); axis->setMajorTicksDirection(Axis::ticksBoth);
axis->setMajorTicksNumber(6); axis->setMajorTicksNumber(6);
axis->setMinorTicksDirection(Axis::ticksBoth); axis->setMinorTicksDirection(Axis::ticksBoth);
axis->setMinorTicksNumber(1); axis->setMinorTicksNumber(1);
axis->setArrowType(Axis::ArrowType::FilledSmall); axis->setArrowType(Axis::ArrowType::FilledSmall);
axis->title()->setText(QString()); axis->title()->setText(QString());
axis->setSuppressRetransform(false); axis->setSuppressRetransform(false);
axis = new Axis("y axis 1", Axis::Orientation::Vertical); axis = new Axis(QLatin1String("y"), Axis::Orientation::Ve rtical);
axis->setDefault(true); axis->setDefault(true);
axis->setSuppressRetransform(true); axis->setSuppressRetransform(true);
addChild(axis); addChild(axis);
axis->setPosition(Axis::Position::Custom); axis->setPosition(Axis::Position::Custom);
axis->setOffset(0); axis->setOffset(0);
axis->setStart(-0.5); axis->setStart(-0.5);
axis->setEnd(0.5); axis->setEnd(0.5);
axis->setMajorTicksDirection(Axis::ticksBoth); axis->setMajorTicksDirection(Axis::ticksBoth);
axis->setMajorTicksNumber(6); axis->setMajorTicksNumber(6);
axis->setMinorTicksDirection(Axis::ticksBoth); axis->setMinorTicksDirection(Axis::ticksBoth);
skipping to change at line 1452 skipping to change at line 1451
double CartesianPlot::cursorPos(int cursorNumber) { double CartesianPlot::cursorPos(int cursorNumber) {
Q_D(CartesianPlot); Q_D(CartesianPlot);
if (cursorNumber == 0) if (cursorNumber == 0)
return d->cursor0Pos.x(); return d->cursor0Pos.x();
else else
return d->cursor1Pos.x(); return d->cursor1Pos.x();
} }
void CartesianPlot::childAdded(const AbstractAspect* child) { void CartesianPlot::childAdded(const AbstractAspect* child) {
Q_D(CartesianPlot); Q_D(CartesianPlot);
const bool firstCurve = (children<XYCurve>().size() + children<Histogram>
().size() == 1);
const auto* curve = qobject_cast<const XYCurve*>(child); const auto* curve = qobject_cast<const XYCurve*>(child);
if (curve) { if (curve) {
connect(curve, &XYCurve::dataChanged, this, &CartesianPlot::dataC hanged); connect(curve, &XYCurve::dataChanged, this, &CartesianPlot::dataC hanged);
connect(curve, &XYCurve::xColumnChanged, this, [this](const Abstr
actColumn* column) {
const bool firstCurve = (children<XYCurve>().size() + chi
ldren<Histogram>().size() == 1);
if (firstCurve)
checkAxisFormat(column, Axis::Orientation::Horizo
ntal);
});
connect(curve, &XYCurve::xDataChanged, this, &CartesianPlot::xDat aChanged); connect(curve, &XYCurve::xDataChanged, this, &CartesianPlot::xDat aChanged);
connect(curve, &XYCurve::xErrorTypeChanged, this, &CartesianPlot: :dataChanged); connect(curve, &XYCurve::xErrorTypeChanged, this, &CartesianPlot: :dataChanged);
connect(curve, &XYCurve::xErrorPlusColumnChanged, this, &Cartesia nPlot::dataChanged); connect(curve, &XYCurve::xErrorPlusColumnChanged, this, &Cartesia nPlot::dataChanged);
connect(curve, &XYCurve::xErrorMinusColumnChanged, this, &Cartesi anPlot::dataChanged); connect(curve, &XYCurve::xErrorMinusColumnChanged, this, &Cartesi anPlot::dataChanged);
connect(curve, &XYCurve::yDataChanged, this, &CartesianPlot::yDat aChanged); connect(curve, &XYCurve::yDataChanged, this, &CartesianPlot::yDat aChanged);
connect(curve, &XYCurve::yColumnChanged, this, [this](const Abstr
actColumn* column) {
const bool firstCurve = (children<XYCurve>().size() + chi
ldren<Histogram>().size() == 1);
if (firstCurve)
checkAxisFormat(column, Axis::Orientation::Vertic
al);
});
connect(curve, &XYCurve::yErrorTypeChanged, this, &CartesianPlot: :dataChanged); connect(curve, &XYCurve::yErrorTypeChanged, this, &CartesianPlot: :dataChanged);
connect(curve, &XYCurve::yErrorPlusColumnChanged, this, &Cartesia nPlot::dataChanged); connect(curve, &XYCurve::yErrorPlusColumnChanged, this, &Cartesia nPlot::dataChanged);
connect(curve, &XYCurve::yErrorMinusColumnChanged, this, &Cartesi anPlot::dataChanged); connect(curve, &XYCurve::yErrorMinusColumnChanged, this, &Cartesi anPlot::dataChanged);
connect(curve, static_cast<void (XYCurve::*)(bool)>(&XYCurve::vis ibilityChanged), connect(curve, QOverload<bool>::of(&XYCurve::visibilityChanged),
this, &CartesianPlot::curveVisibilityChanged); this, &CartesianPlot::curveVisibilityChanged);
//update the legend on changes of the name, line and symbol style s //update the legend on changes of the name, line and symbol style s
connect(curve, &XYCurve::aspectDescriptionChanged, this, &Cartesi anPlot::updateLegend); connect(curve, &XYCurve::aspectDescriptionChanged, this, &Cartesi anPlot::updateLegend);
connect(curve, &XYCurve::aspectDescriptionChanged, this, &Cartesi anPlot::curveNameChanged); connect(curve, &XYCurve::aspectDescriptionChanged, this, &Cartesi anPlot::curveNameChanged);
connect(curve, &XYCurve::lineTypeChanged, this, &CartesianPlot::u pdateLegend); connect(curve, &XYCurve::lineTypeChanged, this, &CartesianPlot::u pdateLegend);
connect(curve, &XYCurve::linePenChanged, this, &CartesianPlot::up dateLegend); connect(curve, &XYCurve::linePenChanged, this, &CartesianPlot::up dateLegend);
connect(curve, &XYCurve::linePenChanged, this, static_cast<void ( CartesianPlot::*)(QPen)>(&CartesianPlot::curveLinePenChanged)); connect(curve, &XYCurve::linePenChanged, this, static_cast<void ( CartesianPlot::*)(QPen)>(&CartesianPlot::curveLinePenChanged));
connect(curve, &XYCurve::lineOpacityChanged, this, &CartesianPlot ::updateLegend); connect(curve, &XYCurve::lineOpacityChanged, this, &CartesianPlot ::updateLegend);
connect(curve, &XYCurve::symbolsStyleChanged, this, &CartesianPlo t::updateLegend); connect(curve, &XYCurve::symbolsStyleChanged, this, &CartesianPlo t::updateLegend);
connect(curve, &XYCurve::symbolsSizeChanged, this, &CartesianPlot ::updateLegend); connect(curve, &XYCurve::symbolsSizeChanged, this, &CartesianPlot ::updateLegend);
connect(curve, &XYCurve::symbolsRotationAngleChanged, this, &Cart esianPlot::updateLegend); connect(curve, &XYCurve::symbolsRotationAngleChanged, this, &Cart esianPlot::updateLegend);
connect(curve, &XYCurve::symbolsOpacityChanged, this, &CartesianP lot::updateLegend); connect(curve, &XYCurve::symbolsOpacityChanged, this, &CartesianP lot::updateLegend);
connect(curve, &XYCurve::symbolsBrushChanged, this, &CartesianPlo t::updateLegend); connect(curve, &XYCurve::symbolsBrushChanged, this, &CartesianPlo t::updateLegend);
connect(curve, &XYCurve::symbolsPenChanged, this, &CartesianPlot: :updateLegend); connect(curve, &XYCurve::symbolsPenChanged, this, &CartesianPlot: :updateLegend);
connect(curve, &XYCurve::linePenChanged, this, QOverload<QPen>::o f(&CartesianPlot::curveLinePenChanged)); // forward to Worksheet to update Curso rDock
updateLegend(); updateLegend();
d->curvesXMinMaxIsDirty = true; d->curvesXMinMaxIsDirty = true;
d->curvesYMinMaxIsDirty = true; d->curvesYMinMaxIsDirty = true;
//in case the first curve is added, check whether we start plotti ng datetime data //in case the first curve is added, check whether we start plotti ng datetime data
if (children<XYCurve>().size() == 1) { if (firstCurve) {
const auto* col = dynamic_cast<const Column*>(curve->xCol checkAxisFormat(curve->xColumn(), Axis::Orientation::Hori
umn()); zontal);
if (col) { checkAxisFormat(curve->yColumn(), Axis::Orientation::Vert
if (col->columnMode() == AbstractColumn::ColumnMo ical);
de::DateTime) {
setUndoAware(false);
setXRangeFormat(RangeFormat::DateTime);
setUndoAware(true);
//set column's datetime format for all ho
rizontal axis
for (auto* axis : children<Axis>()) {
if (axis->orientation() == Axis::
Orientation::Horizontal) {
auto* filter = static_cas
t<DateTime2StringFilter*>(col->outputFilter());
d->xRangeDateTimeFormat =
filter->format();
axis->setUndoAware(false)
;
axis->setLabelsDateTimeFo
rmat(d->xRangeDateTimeFormat);
axis->setUndoAware(true);
}
}
}
}
col = dynamic_cast<const Column*>(curve->yColumn());
if (col) {
if (col->columnMode() == AbstractColumn::ColumnMo
de::DateTime) {
setUndoAware(false);
setYRangeFormat(RangeFormat::DateTime);
setUndoAware(true);
//set column's datetime format for all ve
rtical axis
for (auto* axis : children<Axis>()) {
if (axis->orientation() == Axis::
Orientation::Vertical) {
auto* filter = static_cas
t<DateTime2StringFilter*>(col->outputFilter());
d->yRangeDateTimeFormat =
filter->format();
axis->setUndoAware(false)
;
axis->setLabelsDateTimeFo
rmat(d->yRangeDateTimeFormat);
axis->setUndoAware(true);
}
}
}
}
} }
emit curveAdded(curve); emit curveAdded(curve);
} else { } else {
const auto* hist = qobject_cast<const Histogram*>(child); const auto* hist = qobject_cast<const Histogram*>(child);
if (hist) { if (hist) {
connect(hist, &Histogram::dataChanged, this, &CartesianPl ot::dataChanged); connect(hist, &Histogram::dataChanged, this, &CartesianPl ot::dataChanged);
connect(hist, &Histogram::visibilityChanged, this, &Carte sianPlot::curveVisibilityChanged); connect(hist, &Histogram::visibilityChanged, this, &Carte sianPlot::curveVisibilityChanged);
updateLegend(); updateLegend();
d->curvesXMinMaxIsDirty = true;
d->curvesYMinMaxIsDirty = true;
if (firstCurve)
checkAxisFormat(hist->dataColumn(), Axis::Orienta
tion::Horizontal);
} }
// if an element is hovered, the curves which are handled manuall y in this class // if an element is hovered, the curves which are handled manuall y in this class
// must be unhovered // must be unhovered
const auto* element = static_cast<const WorksheetElement*>(child) ; const auto* element = static_cast<const WorksheetElement*>(child) ;
connect(element, &WorksheetElement::hovered, this, &CartesianPlot ::childHovered); connect(element, &WorksheetElement::hovered, this, &CartesianPlot ::childHovered);
} }
if (!isLoading()) { if (!isLoading()) {
//if a theme was selected, apply the theme settings for newly add ed children, //if a theme was selected, apply the theme settings for newly add ed children,
//load default theme settings otherwise. //load default theme settings otherwise.
skipping to change at line 1558 skipping to change at line 1539
KConfig config(ThemeHandler::themeFilePath(d->the me), KConfig::SimpleConfig); KConfig config(ThemeHandler::themeFilePath(d->the me), KConfig::SimpleConfig);
const_cast<WorksheetElement*>(elem)->loadThemeCon fig(config); const_cast<WorksheetElement*>(elem)->loadThemeCon fig(config);
} else { } else {
KConfig config; KConfig config;
const_cast<WorksheetElement*>(elem)->loadThemeCon fig(config); const_cast<WorksheetElement*>(elem)->loadThemeCon fig(config);
} }
} }
} }
} }
void CartesianPlot::checkAxisFormat(const AbstractColumn* column, Axis::Orientat
ion orientation) {
const auto* col = dynamic_cast<const Column*>(column);
if (!col)
return;
if (col->columnMode() == AbstractColumn::ColumnMode::DateTime) {
setUndoAware(false);
if (orientation == Axis::Orientation::Horizontal)
setXRangeFormat(RangeFormat::DateTime);
else
setYRangeFormat(RangeFormat::DateTime);
setUndoAware(true);
//set column's datetime format for all horizontal axis
Q_D(CartesianPlot);
for (auto* axis : children<Axis>()) {
if (axis->orientation() == orientation) {
auto* filter = static_cast<DateTime2StringFilter*
>(col->outputFilter());
d->xRangeDateTimeFormat = filter->format();
axis->setUndoAware(false);
axis->setLabelsDateTimeFormat(d->xRangeDateTimeFo
rmat);
axis->setUndoAware(true);
}
}
} else {
setUndoAware(false);
if (orientation == Axis::Orientation::Horizontal)
setXRangeFormat(RangeFormat::Numeric);
else
setYRangeFormat(RangeFormat::Numeric);
setUndoAware(true);
}
}
void CartesianPlot::childRemoved(const AbstractAspect* parent, const AbstractAsp ect* before, const AbstractAspect* child) { void CartesianPlot::childRemoved(const AbstractAspect* parent, const AbstractAsp ect* before, const AbstractAspect* child) {
Q_UNUSED(parent); Q_UNUSED(parent);
Q_UNUSED(before); Q_UNUSED(before);
if (m_legend == child) { if (m_legend == child) {
if (m_menusInitialized) if (m_menusInitialized)
addLegendAction->setEnabled(true); addLegendAction->setEnabled(true);
m_legend = nullptr; m_legend = nullptr;
} else { } else {
const auto* curve = qobject_cast<const XYCurve*>(child); const auto* curve = qobject_cast<const XYCurve*>(child);
if (curve) { if (curve) {
skipping to change at line 1723 skipping to change at line 1738
if (hist) if (hist)
hist->retransform(); hist->retransform();
} }
} }
//in case there is only one curve and its column mode was changed, check whether we start plotting datetime data //in case there is only one curve and its column mode was changed, check whether we start plotting datetime data
if (children<XYCurve>().size() == 1) { if (children<XYCurve>().size() == 1) {
auto* curve = dynamic_cast<XYCurve*>(QObject::sender()); auto* curve = dynamic_cast<XYCurve*>(QObject::sender());
if (curve) { if (curve) {
const AbstractColumn* col = curve->yColumn(); const AbstractColumn* col = curve->yColumn();
if (col->columnMode() == AbstractColumn::ColumnMode::Date Time && d->xRangeFormat != RangeFormat::DateTime) { if (col->columnMode() == AbstractColumn::ColumnMode::Date Time && d->yRangeFormat != RangeFormat::DateTime) {
setUndoAware(false); setUndoAware(false);
setYRangeFormat(RangeFormat::DateTime); setYRangeFormat(RangeFormat::DateTime);
setUndoAware(true); setUndoAware(true);
} }
} }
} }
emit curveDataChanged(dynamic_cast<XYCurve*>(QObject::sender())); emit curveDataChanged(dynamic_cast<XYCurve*>(QObject::sender()));
} }
void CartesianPlot::curveVisibilityChanged() { void CartesianPlot::curveVisibilityChanged() {
skipping to change at line 2482 skipping to change at line 2497
} }
case Scale::Log2: case Scale::Log2:
case Scale::Log2Abs: { case Scale::Log2Abs: {
offset = (log2(max) - log2(min)) * factor; offset = (log2(max) - log2(min)) * factor;
min *= pow(2, offset); min *= pow(2, offset);
max *= pow(2, offset); max *= pow(2, offset);
break; break;
} }
case Scale::Ln: case Scale::Ln:
case Scale::LnAbs: { case Scale::LnAbs: {
offset = (log10(max) - log10(min)) * factor; offset = (log(max) - log(min)) * factor;
min *= exp(offset); min *= exp(offset);
max *= exp(offset); max *= exp(offset);
break; break;
} }
case Scale::Sqrt: case Scale::Sqrt:
case Scale::X2: case Scale::X2:
break; break;
} }
if (!std::isnan(min) && !std::isnan(max) && std::isfinite(min) && std::is finite(max)) { if (!std::isnan(min) && !std::isnan(max) && std::isfinite(min) && std::is finite(max)) {
skipping to change at line 3624 skipping to change at line 3639
writer->writeAttribute( "autoScaleX", QString::number(d->autoScaleX) ); writer->writeAttribute( "autoScaleX", QString::number(d->autoScaleX) );
writer->writeAttribute( "autoScaleY", QString::number(d->autoScaleY) ); writer->writeAttribute( "autoScaleY", QString::number(d->autoScaleY) );
writer->writeAttribute( "xMin", QString::number(d->xMin, 'g', 16)); writer->writeAttribute( "xMin", QString::number(d->xMin, 'g', 16));
writer->writeAttribute( "xMax", QString::number(d->xMax, 'g', 16) ); writer->writeAttribute( "xMax", QString::number(d->xMax, 'g', 16) );
writer->writeAttribute( "yMin", QString::number(d->yMin, 'g', 16) ); writer->writeAttribute( "yMin", QString::number(d->yMin, 'g', 16) );
writer->writeAttribute( "yMax", QString::number(d->yMax, 'g', 16) ); writer->writeAttribute( "yMax", QString::number(d->yMax, 'g', 16) );
writer->writeAttribute( "xScale", QString::number(static_cast<int>(d->xSc ale)) ); writer->writeAttribute( "xScale", QString::number(static_cast<int>(d->xSc ale)) );
writer->writeAttribute( "yScale", QString::number(static_cast<int>(d->ySc ale)) ); writer->writeAttribute( "yScale", QString::number(static_cast<int>(d->ySc ale)) );
writer->writeAttribute( "xRangeFormat", QString::number(static_cast<int>( d->xRangeFormat)) ); writer->writeAttribute( "xRangeFormat", QString::number(static_cast<int>( d->xRangeFormat)) );
writer->writeAttribute( "yRangeFormat", QString::number(static_cast<int>( d->yRangeFormat)) ); writer->writeAttribute( "yRangeFormat", QString::number(static_cast<int>( d->yRangeFormat)) );
writer->writeAttribute( "xRangeDateTimeFormat", d->xRangeDateTimeFormat )
;
writer->writeAttribute( "yRangeDateTimeFormat", d->yRangeDateTimeFormat )
;
writer->writeAttribute( "horizontalPadding", QString::number(d->horizonta lPadding) ); writer->writeAttribute( "horizontalPadding", QString::number(d->horizonta lPadding) );
writer->writeAttribute( "verticalPadding", QString::number(d->verticalPad ding) ); writer->writeAttribute( "verticalPadding", QString::number(d->verticalPad ding) );
writer->writeAttribute( "rightPadding", QString::number(d->rightPadding) ); writer->writeAttribute( "rightPadding", QString::number(d->rightPadding) );
writer->writeAttribute( "bottomPadding", QString::number(d->bottomPadding ) ); writer->writeAttribute( "bottomPadding", QString::number(d->bottomPadding ) );
writer->writeAttribute( "symmetricPadding", QString::number(d->symmetricP adding)); writer->writeAttribute( "symmetricPadding", QString::number(d->symmetricP adding));
writer->writeEndElement(); writer->writeEndElement();
//x-scale breaks //x-scale breaks
if (d->xRangeBreakingEnabled || !d->xRangeBreaks.list.isEmpty()) { if (d->xRangeBreakingEnabled || !d->xRangeBreaks.list.isEmpty()) {
writer->writeStartElement("xRangeBreaks"); writer->writeStartElement("xRangeBreaks");
skipping to change at line 3781 skipping to change at line 3798
d->yMax = str.toDouble(); d->yMax = str.toDouble();
d->yMaxPrev = d->yMax; d->yMaxPrev = d->yMax;
} }
READ_INT_VALUE("xScale", xScale, CartesianPlot::Scale); READ_INT_VALUE("xScale", xScale, CartesianPlot::Scale);
READ_INT_VALUE("yScale", yScale, CartesianPlot::Scale); READ_INT_VALUE("yScale", yScale, CartesianPlot::Scale);
READ_INT_VALUE("xRangeFormat", xRangeFormat, CartesianPlo t::RangeFormat); READ_INT_VALUE("xRangeFormat", xRangeFormat, CartesianPlo t::RangeFormat);
READ_INT_VALUE("yRangeFormat", yRangeFormat, CartesianPlo t::RangeFormat); READ_INT_VALUE("yRangeFormat", yRangeFormat, CartesianPlo t::RangeFormat);
str = attribs.value("xRangeDateTimeFormat").toString();
if (!str.isEmpty())
d->xRangeDateTimeFormat = str;
str = attribs.value("yRangeDateTimeFormat").toString();
if (!str.isEmpty())
d->yRangeDateTimeFormat = str;
READ_DOUBLE_VALUE("horizontalPadding", horizontalPadding) ; READ_DOUBLE_VALUE("horizontalPadding", horizontalPadding) ;
READ_DOUBLE_VALUE("verticalPadding", verticalPadding); READ_DOUBLE_VALUE("verticalPadding", verticalPadding);
READ_DOUBLE_VALUE("rightPadding", rightPadding); READ_DOUBLE_VALUE("rightPadding", rightPadding);
READ_DOUBLE_VALUE("bottomPadding", bottomPadding); READ_DOUBLE_VALUE("bottomPadding", bottomPadding);
READ_INT_VALUE("symmetricPadding", symmetricPadding, bool ); READ_INT_VALUE("symmetricPadding", symmetricPadding, bool );
} else if (!preview && reader->name() == "xRangeBreaks") { } else if (!preview && reader->name() == "xRangeBreaks") {
//delete default rang break //delete default rang break
d->xRangeBreaks.list.clear(); d->xRangeBreaks.list.clear();
attribs = reader->attributes(); attribs = reader->attributes();
 End of changes. 24 change blocks. 
69 lines changed or deleted 94 lines changed or added

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