[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [labplot] src/backend/worksheet/plots: Removed some obsolete code in CartesianCoordinateSystem.
From: Alexander Semke <alexander.semke () web ! de>
Date: 2016-09-11 8:10:26
Message-ID: E1bizqM-0008WM-Tw () code ! kde ! org
[Download RAW message or body]
Git commit 27d2a6c716ad780afb8f0b2606f68d580cbfa45b by Alexander Semke.
Committed on 11/09/2016 at 08:03.
Pushed by asemke into branch 'master'.
Removed some obsolete code in CartesianCoordinateSystem.
M +0 -2 src/backend/worksheet/plots/AbstractCoordinateSystem.h
M +0 -6 src/backend/worksheet/plots/AbstractPlot.cpp
M +0 -3 src/backend/worksheet/plots/AbstractPlot.h
M +12 -79 src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.cpp
M +8 -19 src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.h
M +8 -16 src/backend/worksheet/plots/cartesian/CartesianPlot.cpp
M +2 -2 src/backend/worksheet/plots/cartesian/CartesianPlotPrivate.h
http://commits.kde.org/labplot/27d2a6c716ad780afb8f0b2606f68d580cbfa45b
diff --git a/src/backend/worksheet/plots/AbstractCoordinateSystem.h \
b/src/backend/worksheet/plots/AbstractCoordinateSystem.h index 78fdeb6..eb8988d \
100644
--- a/src/backend/worksheet/plots/AbstractCoordinateSystem.h
+++ b/src/backend/worksheet/plots/AbstractCoordinateSystem.h
@@ -54,8 +54,6 @@ class AbstractCoordinateSystem {
virtual QList<QPointF> mapSceneToLogical(const QList<QPointF>&, const MappingFlags \
&flags = DefaultMapping) const = 0; virtual QPointF mapSceneToLogical(const \
QPointF&, const MappingFlags &flags = DefaultMapping) const = 0;
- virtual void handlePageResize(double horizontalRatio, double verticalRatio) = 0;
-
class LineClipResult {
public:
LineClipResult() {
diff --git a/src/backend/worksheet/plots/AbstractPlot.cpp \
b/src/backend/worksheet/plots/AbstractPlot.cpp index 0f3c8df..d136ac4 100644
--- a/src/backend/worksheet/plots/AbstractPlot.cpp
+++ b/src/backend/worksheet/plots/AbstractPlot.cpp
@@ -75,12 +75,6 @@ TextLabel* AbstractPlot::title(){
return m_title;
}
-void AbstractPlot::handlePageResize(double horizontalRatio, double verticalRatio){
- m_coordinateSystem->handlePageResize(horizontalRatio, verticalRatio);
- m_plotArea->handlePageResize(horizontalRatio, verticalRatio);
- WorksheetElementContainer::handlePageResize(horizontalRatio, verticalRatio);
-}
-
BASIC_SHARED_D_READER_IMPL(AbstractPlot, float, horizontalPadding, \
horizontalPadding) BASIC_SHARED_D_READER_IMPL(AbstractPlot, float, verticalPadding, \
verticalPadding)
diff --git a/src/backend/worksheet/plots/AbstractPlot.h \
b/src/backend/worksheet/plots/AbstractPlot.h index 8b55ea5..b8c61dc 100644
--- a/src/backend/worksheet/plots/AbstractPlot.h
+++ b/src/backend/worksheet/plots/AbstractPlot.h
@@ -55,9 +55,6 @@ class AbstractPlot:public WorksheetElementContainer{
typedef AbstractPlot BaseClass;
typedef AbstractPlotPrivate Private;
- public slots:
- virtual void handlePageResize(double horizontalRatio, double verticalRatio);
-
protected:
AbstractPlot(const QString &name, AbstractPlotPrivate *dd);
AbstractCoordinateSystem* m_coordinateSystem;
diff --git a/src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.cpp \
b/src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.cpp index \
c02b3d8..1e54ca4 100644
--- a/src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.cpp
+++ b/src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.cpp
@@ -4,8 +4,7 @@
Project : LabPlot
Description : Cartesian coordinate system for plots.
--------------------------------------------------------------------
- Copyright : (C) 2009 Tilman Benkert (thzs@gmx.net)
- Copyright : (C) 2012-2015 by Alexander Semke (alexander.semke@web.de)
+ Copyright : (C) 2012-2016 by Alexander Semke (alexander.semke@web.de)
***************************************************************************/
@@ -30,27 +29,20 @@
#include "backend/worksheet/plots/cartesian/CartesianCoordinateSystem.h"
#include "backend/worksheet/plots/cartesian/CartesianPlot.h"
+
#include <cmath>
-#include <QUndoCommand>
#include <KLocale>
-/**
- * \class CartesianCoordinateSystem
- * \brief Cartesian coordinate system for plots.
- *
- *
- */
+/* ============================================================================ */
+/* =================================== scales ================================= */
+/* ============================================================================ */
/**
* \class CartesianCoordinateSystem::Scale
* \brief Base class for cartesian coordinate system scales.
*
*
*/
-
-/* ============================================================================ */
-/* =================================== scales ================================= */
-/* ============================================================================ */
CartesianCoordinateSystem::Scale::Scale(ScaleType type, const Interval<double> \
&interval, double a, double b, double c) : m_type(type), m_interval(interval), \
m_a(a), m_b(b), m_c(c) { }
@@ -71,38 +63,6 @@ void CartesianCoordinateSystem::Scale::getProperties(ScaleType \
*type, Interval<d
*c = m_c;
}
-class CartesianCoordinateSystemSetScalePropertiesCmd : public QUndoCommand {
- public:
- CartesianCoordinateSystemSetScalePropertiesCmd(CartesianCoordinateSystem::Scale \
*target,
- const Interval<double> &interval, double a, double b, double c)
- : m_target(target), m_interval(interval), m_a(a), m_b(b), m_c(c) {
- // use in macro only
- }
-
- template <typename T> void swap(T *a, T *b) {
- T temp = *a;
- *a = *b;
- *b = temp;
- }
-
- virtual void redo() {
- swap< Interval<double> >(&m_interval, &m_target->m_interval);
- swap< double >(&m_a, &m_target->m_a);
- swap< double >(&m_b, &m_target->m_b);
- swap< double >(&m_c, &m_target->m_c);
- }
-
- virtual void undo() { redo(); }
-
- private:
- CartesianCoordinateSystem::Scale *m_target;
- Interval<double> m_interval;
- double m_a;
- double m_b;
- double m_c;
-};
-
-
class LinearScale: public CartesianCoordinateSystem::Scale {
public:
virtual ~LinearScale() {}
@@ -171,11 +131,9 @@ class LogScale: public CartesianCoordinateSystem::Scale {
*a = m_a * ratio;
*b = m_b * ratio;
*c = m_c;
-
}
};
-
CartesianCoordinateSystem::Scale \
*CartesianCoordinateSystem::Scale::createScale(ScaleType type, const Interval<double> \
&interval, double a, double b, double c) { switch (type) {
case ScaleLinear:
@@ -223,7 +181,9 @@ CartesianCoordinateSystem::Scale \
*CartesianCoordinateSystem::Scale::createLogSca /* \
============================================================================ */ /* \
========================= coordinate system ================================ */ /* \
============================================================================ \
*/
-class CartesianCoordinateSystemPrivate{
+
+
+class CartesianCoordinateSystemPrivate {
public:
CartesianCoordinateSystemPrivate(CartesianCoordinateSystem *owner);
~CartesianCoordinateSystemPrivate();
@@ -234,13 +194,16 @@ public:
QList<CartesianCoordinateSystem::Scale*> yScales;
};
+/**
+ * \class CartesianCoordinateSystem
+ * \brief Cartesian coordinate system for plots.
+ */
CartesianCoordinateSystem::CartesianCoordinateSystem(CartesianPlot* plot)
: AbstractCoordinateSystem(plot), d(new CartesianCoordinateSystemPrivate(this)) {
d->plot=plot;
// TODO: set some standard scales
}
-
CartesianCoordinateSystem::~CartesianCoordinateSystem() {
delete d;
}
@@ -684,24 +647,6 @@ QList<CartesianCoordinateSystem::Scale *> \
CartesianCoordinateSystem::yScales() c return d->yScales; // TODO: should rather \
return a copy of the scales here }
-void CartesianCoordinateSystem::handlePageResize(double horizontalRatio, double \
verticalRatio) {
- Scale::ScaleType type;
- Interval<double> interval;
- double a, b, c;
-
- d->plot->beginMacro(i18n("adjust to page size"));
- foreach (Scale *xScale, d->xScales) {
- xScale->getPropertiesOnResize(horizontalRatio, &type, &interval, &a, &b, &c);
- d->plot->exec(new CartesianCoordinateSystemSetScalePropertiesCmd(xScale, interval, \
a, b, c));
- }
-
- foreach (Scale *yScale, d->yScales) {
- yScale->getPropertiesOnResize(verticalRatio, &type, &interval, &a, &b, &c);
- d->plot->exec(new CartesianCoordinateSystemSetScalePropertiesCmd(yScale, interval, \
a, b, c));
- }
- d->plot->endMacro();
-}
-
/*!
* Adjusted the function QRectF::contains(QPointF) from Qt 4.8.4 to handle the
* comparison of float numbers correctly.
@@ -753,15 +698,3 @@ \
CartesianCoordinateSystemPrivate::~CartesianCoordinateSystemPrivate() { while \
(!yScales.isEmpty()) delete yScales.takeFirst();
}
-
-//##############################################################################
-//################## Serialization/Deserialization ###########################
-//##############################################################################
-void CartesianCoordinateSystem::save(QXmlStreamWriter* writer) const{
- Q_UNUSED(writer);
-}
-
-bool CartesianCoordinateSystem::load(XmlStreamReader* reader) {
- Q_UNUSED(reader);
- return true;
-}
diff --git a/src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.h \
b/src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.h index \
6418d90..acd4688 100644
--- a/src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.h
+++ b/src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.h
@@ -3,8 +3,7 @@
Project : LabPlot
Description : Cartesian coordinate system for plots.
--------------------------------------------------------------------
- Copyright : (C) 2009 Tilman Benkert (thzs@gmx.net)
- Copyright : (C) 2012 by Alexander Semke (alexander.semke@web.de)
+ Copyright : (C) 2012-2016 by Alexander Semke (alexander.semke@web.de)
***************************************************************************/
@@ -31,7 +30,6 @@
#define CARTESIANCOORDINATESYSTEM_H
#include "backend/worksheet/plots/AbstractCoordinateSystem.h"
-#include "backend/lib/macros.h"
#include "backend/lib/Interval.h"
#include <vector>
@@ -39,6 +37,7 @@
class CartesianPlot;
class CartesianCoordinateSystemPrivate;
class CartesianCoordinateSystemSetScalePropertiesCmd;
+
class CartesianCoordinateSystem: public AbstractCoordinateSystem {
public:
@@ -51,12 +50,9 @@ class CartesianCoordinateSystem: public AbstractCoordinateSystem {
static constexpr double LIMIT_MAX = 1e15;
static constexpr double LIMIT_MIN = -1e15;
#endif
-
virtual ~Scale();
- enum ScaleType {
- ScaleLinear,
- ScaleLog,
- };
+
+ enum ScaleType {ScaleLinear, ScaleLog};
static Scale *createScale(ScaleType type, const Interval<double> &interval, \
double a, double b, double c);
static Scale *createLinearScale(const Interval<double> &interval, double \
sceneStart, double sceneEnd, @@ -73,8 +69,6 @@ class CartesianCoordinateSystem: \
public AbstractCoordinateSystem { virtual void getPropertiesOnResize(double ratio,
ScaleType *type, Interval<double> *interval, double *a, double *b, double *c) \
const = 0;
- // changing properties is done via this command:
- friend class CartesianCoordinateSystemSetScalePropertiesCmd;
protected:
Scale(ScaleType type, const Interval<double> &interval, double a, double b, \
double c); ScaleType m_type;
@@ -94,17 +88,12 @@ class CartesianCoordinateSystem: public AbstractCoordinateSystem \
{ virtual QPointF mapSceneToLogical(const QPointF&, const MappingFlags &flags = \
DefaultMapping) const; virtual QList<QLineF> mapLogicalToScene(const QList<QLineF>&, \
const MappingFlags &flags = DefaultMapping) const;
- virtual void handlePageResize(double horizontalRatio, double verticalRatio);
-
int xDirection() const;
int yDirection() const;
- bool setXScales(const QList<Scale *> &scales);
- QList<Scale *> xScales() const;
- bool setYScales(const QList<Scale *> &scales);
- QList<Scale *> yScales() const;
-
- virtual void save(QXmlStreamWriter *) const;
- virtual bool load(XmlStreamReader *);
+ bool setXScales(const QList<Scale*>& scales);
+ QList<Scale*> xScales() const;
+ bool setYScales(const QList<Scale*>& scales);
+ QList<Scale*> yScales() const;
private:
void init();
diff --git a/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp \
b/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp index 9f198bf..67fd091 \
100644
--- a/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp
+++ b/src/backend/worksheet/plots/cartesian/CartesianPlot.cpp
@@ -1324,8 +1324,7 @@ void CartesianPlotPrivate::retransformScales() {
//TODO: how should we handle the case sceneStart=sceneEnd
//(to reproduce, create plots and adjust the spacing/pading to get zero size for \
the plots) if (sceneStart!=sceneEnd) {
- Interval<double> interval(SCALE_MIN, SCALE_MAX);
- scales << this->createScale(xScale, interval, sceneStart, sceneEnd, logicalStart, \
logicalEnd); + scales << this->createScale(xScale, sceneStart, sceneEnd, \
logicalStart, logicalEnd); }
} else {
foreach(const CartesianPlot::RangeBreak& b, xRangeBreaks.list) {
@@ -1334,16 +1333,13 @@ void CartesianPlotPrivate::retransformScales() {
sceneEnd = sceneStart+(sceneEnd-sceneStart)*b.position;
logicalStart = xMin;
logicalEnd = b.start;
-
- Interval<double> interval(SCALE_MIN, SCALE_MAX);
- scales << this->createScale(xScale, interval, sceneStart, sceneEnd, logicalStart, \
logicalEnd); + scales << this->createScale(xScale, sceneStart, sceneEnd, \
logicalStart, logicalEnd);
sceneStart = sceneEnd+50;
sceneEnd = itemRect.x()+itemRect.width()-horizontalPadding;
logicalStart = b.end;
logicalEnd = xMax;
- Interval<double> interval2(SCALE_MIN, SCALE_MAX);
- scales << this->createScale(xScale, interval2, sceneStart, sceneEnd, \
logicalStart, logicalEnd); + scales << this->createScale(xScale, sceneStart, \
sceneEnd, logicalStart, logicalEnd); }
}
@@ -1367,8 +1363,7 @@ void CartesianPlotPrivate::retransformScales() {
sceneEnd = itemRect.y()+verticalPadding;
logicalStart = yMin;
logicalEnd = yMax;
- Interval<double> interval (SCALE_MIN, SCALE_MAX);
- scales << this->createScale(yScale, interval, sceneStart, sceneEnd, logicalStart, \
logicalEnd); + scales << this->createScale(yScale, sceneStart, sceneEnd, \
logicalStart, logicalEnd); } else {
foreach(const CartesianPlot::RangeBreak& b, yRangeBreaks.list) {
sceneStart = itemRect.y()+itemRect.height()-verticalPadding;
@@ -1376,16 +1371,13 @@ void CartesianPlotPrivate::retransformScales() {
sceneEnd = sceneStart+(sceneEnd-sceneStart)*b.position;
logicalStart = yMin;
logicalEnd = b.start;
-
- Interval<double> interval(SCALE_MIN, SCALE_MAX);
- scales << this->createScale(yScale, interval, sceneStart, sceneEnd, logicalStart, \
logicalEnd); + scales << this->createScale(yScale, sceneStart, sceneEnd, \
logicalStart, logicalEnd);
sceneStart = sceneEnd+50;
sceneEnd = itemRect.y()+verticalPadding;
logicalStart = b.end;
logicalEnd = yMax;
- Interval<double> interval2(SCALE_MIN, SCALE_MAX);
- scales << this->createScale(yScale, interval2, sceneStart, sceneEnd, \
logicalStart, logicalEnd); + scales << this->createScale(yScale, sceneStart, \
sceneEnd, logicalStart, logicalEnd); }
}
@@ -1496,8 +1488,8 @@ void CartesianPlotPrivate::checkYRange() {
}
}
-CartesianCoordinateSystem::Scale* \
CartesianPlotPrivate::createScale(CartesianPlot::Scale type, Interval<double>& \
interval,
- double sceneStart, double sceneEnd,double logicalStart, double logicalEnd) {
+CartesianCoordinateSystem::Scale* \
CartesianPlotPrivate::createScale(CartesianPlot::Scale type, double sceneStart, \
double sceneEnd, double logicalStart, double logicalEnd) { + Interval<double> \
interval (SCALE_MIN, SCALE_MAX); if (type == CartesianPlot::ScaleLinear) {
return CartesianCoordinateSystem::Scale::createLinearScale(interval, sceneStart, \
sceneEnd, logicalStart, logicalEnd); } else {
diff --git a/src/backend/worksheet/plots/cartesian/CartesianPlotPrivate.h \
b/src/backend/worksheet/plots/cartesian/CartesianPlotPrivate.h index 9076a56..55fe5b0 \
100644
--- a/src/backend/worksheet/plots/cartesian/CartesianPlotPrivate.h
+++ b/src/backend/worksheet/plots/cartesian/CartesianPlotPrivate.h
@@ -3,7 +3,7 @@
Project : LabPlot
Description : Private members of CartesianPlot.
--------------------------------------------------------------------
- Copyright : (C) 2014 Alexander Semke (alexander.semke@web.de)
+ Copyright : (C) 2014-2016 Alexander Semke (alexander.semke@web.de)
***************************************************************************/
@@ -52,7 +52,7 @@ class CartesianPlotPrivate:public AbstractPlotPrivate{
void retransformScales();
void checkXRange();
void checkYRange();
- CartesianCoordinateSystem::Scale* createScale(CartesianPlot::Scale type, \
Interval<double>& interval, + CartesianCoordinateSystem::Scale* \
createScale(CartesianPlot::Scale type, double sceneStart, double sceneEnd,
double logicalStart, double logicalEnd);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic