From 27849a09494da15940427d10de7c01c2486ff557 Mon Sep 17 00:00:00 2001 From: tommaso vinci Date: Thu, 6 Oct 2016 16:00:34 +0200 Subject: [PATCH 01/10] added rangelock --- src/axis/axis.cpp | 13 +++++++++++-- src/axis/axis.h | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/axis/axis.cpp b/src/axis/axis.cpp index 95c2f095..2419a3c4 100644 --- a/src/axis/axis.cpp +++ b/src/axis/axis.cpp @@ -429,6 +429,7 @@ QCPAxis::QCPAxis(QCPAxisRect *parent, AxisType type) : // scale and range: mRange(0, 5), mRangeReversed(false), + mRangeLocked(false), mScaleType(stLinear), // internal members: mGrid(new QCPGrid(this)), @@ -579,7 +580,7 @@ void QCPAxis::setScaleType(QCPAxis::ScaleType type) */ void QCPAxis::setRange(const QCPRange &range) { - if (range.lower == mRange.lower && range.upper == mRange.upper) + if (mRangeLocked || (range.lower == mRange.lower && range.upper == mRange.upper)) return; if (!QCPRange::validRange(range)) return; @@ -649,7 +650,7 @@ void QCPAxis::setSelectedParts(const SelectableParts &selected) */ void QCPAxis::setRange(double lower, double upper) { - if (lower == mRange.lower && upper == mRange.upper) + if (mRangeLocked || (lower == mRange.lower && upper == mRange.upper)) return; if (!QCPRange::validRange(lower, upper)) return; @@ -746,6 +747,14 @@ void QCPAxis::setRangeReversed(bool reversed) mRangeReversed = reversed; } +/*! + Sets whether the axis range (direction) is locked (i.e the setRange will not take place) +*/ +void QCPAxis::setRangeLocked(bool locked) +{ + mRangeLocked = locked; +} + /*! The axis ticker is responsible for generating the tick positions and tick labels. See the documentation of QCPAxisTicker for details on how to work with axis tickers. diff --git a/src/axis/axis.h b/src/axis/axis.h index a837e55d..72cd82e5 100644 --- a/src/axis/axis.h +++ b/src/axis/axis.h @@ -103,6 +103,7 @@ class QCP_LIB_DECL QCPAxis : public QCPLayerable Q_PROPERTY(ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY scaleTypeChanged) Q_PROPERTY(QCPRange range READ range WRITE setRange NOTIFY rangeChanged) Q_PROPERTY(bool rangeReversed READ rangeReversed WRITE setRangeReversed) + Q_PROPERTY(bool rangeLocked READ rangeLocked WRITE setRangeLocked) Q_PROPERTY(QSharedPointer ticker READ ticker WRITE setTicker) Q_PROPERTY(bool ticks READ ticks WRITE setTicks) Q_PROPERTY(bool tickLabels READ tickLabels WRITE setTickLabels) @@ -194,6 +195,7 @@ public: ScaleType scaleType() const { return mScaleType; } const QCPRange range() const { return mRange; } bool rangeReversed() const { return mRangeReversed; } + bool rangeLocked() const { return mRangeLocked; } QSharedPointer ticker() const { return mTicker; } bool ticks() const { return mTicks; } bool tickLabels() const { return mTickLabels; } @@ -241,6 +243,7 @@ public: void setRangeLower(double lower); void setRangeUpper(double upper); void setRangeReversed(bool reversed); + void setRangeLocked(bool locked); void setTicker(QSharedPointer ticker); void setTicks(bool show); void setTickLabels(bool show); @@ -343,6 +346,7 @@ protected: // scale and range: QCPRange mRange; bool mRangeReversed; + bool mRangeLocked; ScaleType mScaleType; // non-property members: -- GitLab From 023fb5016a22e67bca0861ae51325ea1089a5e40 Mon Sep 17 00:00:00 2001 From: tommaso vinci Date: Thu, 6 Oct 2016 16:17:02 +0200 Subject: [PATCH 02/10] more slots to check --- src/axis/axis.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/axis/axis.cpp b/src/axis/axis.cpp index 2419a3c4..b79d61ad 100644 --- a/src/axis/axis.cpp +++ b/src/axis/axis.cpp @@ -681,6 +681,7 @@ void QCPAxis::setRange(double lower, double upper) */ void QCPAxis::setRange(double position, double size, Qt::AlignmentFlag alignment) { + if(mRangeLocked) return; if (alignment == Qt::AlignLeft) setRange(position, position+size); else if (alignment == Qt::AlignRight) @@ -695,7 +696,7 @@ void QCPAxis::setRange(double position, double size, Qt::AlignmentFlag alignment */ void QCPAxis::setRangeLower(double lower) { - if (mRange.lower == lower) + if (mRangeLocked || mRange.lower == lower) return; QCPRange oldRange = mRange; @@ -717,7 +718,7 @@ void QCPAxis::setRangeLower(double lower) */ void QCPAxis::setRangeUpper(double upper) { - if (mRange.upper == upper) + if (mRangeLocked || mRange.upper == upper) return; QCPRange oldRange = mRange; -- GitLab From 87f6fa5fa440c5601f06da4184d262c8fb93494a Mon Sep 17 00:00:00 2001 From: tommaso vinci Date: Thu, 6 Oct 2016 19:29:07 +0200 Subject: [PATCH 03/10] again, more slots to check --- src/axis/axis.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/axis/axis.cpp b/src/axis/axis.cpp index b79d61ad..c6723b54 100644 --- a/src/axis/axis.cpp +++ b/src/axis/axis.cpp @@ -1349,6 +1349,7 @@ void QCPAxis::scaleRange(double factor) */ void QCPAxis::scaleRange(double factor, double center) { + if (mRangeLocked) return; QCPRange oldRange = mRange; if (mScaleType == stLinear) { -- GitLab From 297a9c785b22f674956ad65e91aba6e60f101b7a Mon Sep 17 00:00:00 2001 From: tommaso vinci Date: Mon, 17 Oct 2016 14:17:03 +0200 Subject: [PATCH 04/10] fix change progmatically lower/upper --- src/axis/axis.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/axis/axis.cpp b/src/axis/axis.cpp index c6723b54..df6d6e97 100644 --- a/src/axis/axis.cpp +++ b/src/axis/axis.cpp @@ -696,7 +696,7 @@ void QCPAxis::setRange(double position, double size, Qt::AlignmentFlag alignment */ void QCPAxis::setRangeLower(double lower) { - if (mRangeLocked || mRange.lower == lower) + if (mRange.lower == lower) return; QCPRange oldRange = mRange; @@ -718,7 +718,7 @@ void QCPAxis::setRangeLower(double lower) */ void QCPAxis::setRangeUpper(double upper) { - if (mRangeLocked || mRange.upper == upper) + if (mRange.upper == upper) return; QCPRange oldRange = mRange; -- GitLab From f9f4390f34bfb31af83798969fd36a83803438b3 Mon Sep 17 00:00:00 2001 From: tommaso vinci Date: Mon, 24 Oct 2016 16:30:58 +0200 Subject: [PATCH 05/10] adding amalgamate.py (2 changes in qcustomplot{cpp,h}.skeleton to correctly manage template files) --- amalgamate.py | 110 +++++++++++++++++++++++++++++++++++ src/qcustomplot.cpp.skeleton | 2 - src/qcustomplot.h.skeleton | 2 + 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 amalgamate.py diff --git a/amalgamate.py b/amalgamate.py new file mode 100644 index 00000000..ee07b5e9 --- /dev/null +++ b/amalgamate.py @@ -0,0 +1,110 @@ +import os +import re +import fileinput + + +class amalgamate(): + license_start=str('/'+'*'*75) + license_end=str('*'*76+'/') + fwd_decl=[] + gitcommit=os.popen('git log -n 1 --pretty=format:"%H %ai"').read() + + def __init__(self,file): + print "-->",file + self.filein=file + self.fileout=os.path.splitext(os.path.basename(file))[0] + self.fin=open(file,'r') + self.fout=open(self.fileout,'w') + for line in self.fin.readlines(): + if line.startswith("//amalgamation:"): + command=line.split()[1] + args=' '.join(line.split()[2:]) + if (command=="add"): + self.add_file(args) + elif (command=="place"): + if args == "implementation includes" : + self.add_implementation() + elif args == "header includes" : + self.add_header_includes() + elif args == "forward declarations" : + self.fout.write(line) + else: + print "unknown:",args + elif (command=="include"): + if args == "end" : + self.add_include_end() + + else: + self.fout.write(line) + + self.fin.close() + self.fout.close() + self.add_forward_decl() + + + def add_implementation(self): + '''''' + print "add_implementation ?" + + def add_include_end(self): + '''''' + print "add_include end ?" + + def add_header_includes(self): + '''''' + print "add_header_includes ?" + + def add_forward_decl(self): + '''''' + if len(self.fwd_decl)>0 : + for line in fileinput.FileInput(self.fileout,inplace=1): + if "//amalgamation: place forward declarations" in line: + line=''; + for cls in self.fwd_decl: + line+=cls + print line, + + + def add_file(self,fnamein): + '''''' + found=False + print "\t",fnamein + for root, dirs, files in os.walk(os.path.dirname(self.filein)): + for file in files: + fname=os.path.join(root, file) + if fname.endswith(fnamein): + found=True + fin=open(fname,'r') + license=False + self.fout.write("\n/* including file '"+fname+"'"+" "*(57-len(fname))+'*/\n') + self.fout.write("/* commit %s */\n"%self.gitcommit) + ifdef = os.path.basename(fname).upper().replace('.','_').replace('-','_') + for line in fin.readlines(): + if line.startswith('// amalgamation:'): + print "\t\tunknown", line[:-1] + elif line.startswith(self.license_start): + license=True + elif line.startswith(self.license_end): + license=False + elif re.match(r'class (\S+);',line): + if not line in self.fwd_decl: + self.fwd_decl.append(line) + elif not line.startswith('#include "'): + if not license: + if not ifdef in line: + self.fout.write(line) + self.fout.write("/* end of '%s' */\n\n"%fname) + if not found: + print "not found", fnamein + + + +script_dir=os.path.dirname(os.path.realpath(__file__)) +for root, dirs, files in os.walk(os.path.join(script_dir,'src')): + for file in files: + if file.endswith(".skeleton"): + amalgamate(os.path.join(root, file)) + + + + diff --git a/src/qcustomplot.cpp.skeleton b/src/qcustomplot.cpp.skeleton index d02d7514..88cbc3a3 100644 --- a/src/qcustomplot.cpp.skeleton +++ b/src/qcustomplot.cpp.skeleton @@ -44,11 +44,9 @@ //amalgamation: add axis/axistickerlog.cpp //amalgamation: add axis/axis.cpp //amalgamation: add scatterstyle.cpp -//amalgamation: add datacontainer.cpp //amalgamation: add plottable.cpp //amalgamation: add item.cpp //amalgamation: add core.cpp -//amalgamation: add plottable1d.cpp //amalgamation: add colorgradient.cpp //amalgamation: add selectiondecorator-bracket.cpp //amalgamation: add layoutelements/layoutelement-axisrect.cpp diff --git a/src/qcustomplot.h.skeleton b/src/qcustomplot.h.skeleton index c36e1579..8d3589cc 100644 --- a/src/qcustomplot.h.skeleton +++ b/src/qcustomplot.h.skeleton @@ -49,10 +49,12 @@ //amalgamation: add axis/axis.h //amalgamation: add scatterstyle.h //amalgamation: add datacontainer.h +//amalgamation: add datacontainer.cpp //amalgamation: add plottable.h //amalgamation: add item.h //amalgamation: add core.h //amalgamation: add plottable1d.h +//amalgamation: add plottable1d.cpp //amalgamation: add colorgradient.h //amalgamation: add selectiondecorator-bracket.h //amalgamation: add layoutelements/layoutelement-axisrect.h -- GitLab From ceb2a34555204b2ac922de99e3e34dc593a313d5 Mon Sep 17 00:00:00 2001 From: iltommi Date: Mon, 24 Oct 2016 15:09:09 +0000 Subject: [PATCH 06/10] Add license --- LICENSE | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..c404747b --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +/*************************************************************************** +** ** +** QCustomPlot, an easy to use, modern plotting widget for Qt ** +** Copyright (C) 2011-2016 Emanuel Eichhammer ** +** ** +** This program is free software: you can redistribute it and/or modify ** +** it under the terms of the GNU General Public License as published by ** +** the Free Software Foundation, either version 3 of the License, or ** +** (at your option) any later version. ** +** ** +** This program is distributed in the hope that it will be useful, ** +** but WITHOUT ANY WARRANTY; without even the implied warranty of ** +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** +** GNU General Public License for more details. ** +** ** +** You should have received a copy of the GNU General Public License ** +** along with this program. If not, see http://www.gnu.org/licenses/. ** +** ** +**************************************************************************** +** Author: Emanuel Eichhammer ** +** Website/Contact: http://www.qcustomplot.com/ ** +** Date: 13.09.16 ** +** Version: 2.0.0-beta ** +****************************************************************************/ \ No newline at end of file -- GitLab From c309b31eb1d49677f9ccf908d7f2b8d21985558a Mon Sep 17 00:00:00 2001 From: tommaso vinci Date: Wed, 23 Nov 2016 11:36:02 +0100 Subject: [PATCH 07/10] added ci --- .gitlab-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..dc4420b4 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,7 @@ +before_script: + - apt-get update -qq && apt-get install python + + +amalgamate: + script: + - python amalgamate.py -- GitLab From 372f7ec88124f27d6e720060c2a14ef8b1084ced Mon Sep 17 00:00:00 2001 From: tommaso vinci Date: Wed, 23 Nov 2016 12:24:42 +0100 Subject: [PATCH 08/10] ci 00 --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc4420b4..8f7c955a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,5 +3,5 @@ before_script: amalgamate: - script: - - python amalgamate.py + script: + - python amalgamate.py -- GitLab From d240c5e07d184dc41b9b407b3f2cffc4a57938ab Mon Sep 17 00:00:00 2001 From: tommaso vinci Date: Wed, 23 Nov 2016 12:30:45 +0100 Subject: [PATCH 09/10] ci 01 --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8f7c955a..57081c4a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,9 @@ before_script: - apt-get update -qq && apt-get install python + - echo "here1" amalgamate: script: + - echo "here2" - python amalgamate.py -- GitLab From ba5fd4d935f5a34f0d5fcba2da8992b917e6a2ed Mon Sep 17 00:00:00 2001 From: Tommaso Vinci Date: Mon, 4 Sep 2017 21:19:09 +0200 Subject: [PATCH 10/10] update amalgamate.py --- amalgamate.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/amalgamate.py b/amalgamate.py index ee07b5e9..4fce1b9e 100644 --- a/amalgamate.py +++ b/amalgamate.py @@ -1,3 +1,4 @@ + import os import re import fileinput @@ -76,7 +77,7 @@ class amalgamate(): found=True fin=open(fname,'r') license=False - self.fout.write("\n/* including file '"+fname+"'"+" "*(57-len(fname))+'*/\n') + self.fout.write("\n/* including file '"+file+"'"+" "*(57-len(fname))+'*/\n') self.fout.write("/* commit %s */\n"%self.gitcommit) ifdef = os.path.basename(fname).upper().replace('.','_').replace('-','_') for line in fin.readlines(): @@ -92,8 +93,12 @@ class amalgamate(): elif not line.startswith('#include "'): if not license: if not ifdef in line: - self.fout.write(line) - self.fout.write("/* end of '%s' */\n\n"%fname) + self.fout.write(line) + elif line.strip().endswith('.cpp"'): + new_found=line.split('"')[1] + self.add_file(new_found) + + self.fout.write("/* end of '%s' */"%file) if not found: print "not found", fnamein -- GitLab