diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..57081c4aa8ccf332792429c26469a325c6b7bc08 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,9 @@ +before_script: + - apt-get update -qq && apt-get install python + - echo "here1" + + +amalgamate: + script: + - echo "here2" + - python amalgamate.py diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..c404747b1d68216404e5401b6beb273a901f0aac --- /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 diff --git a/amalgamate.py b/amalgamate.py new file mode 100644 index 0000000000000000000000000000000000000000..4fce1b9ed9ccf95ace30f65d9594db4081905316 --- /dev/null +++ b/amalgamate.py @@ -0,0 +1,115 @@ + +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 '"+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(): + 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) + 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 + + + +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/axis/axis.cpp b/src/axis/axis.cpp index c0525d82c41f46d376cc7cf17faa6fdfea919978..4fe150c607d933ec78e2e5d474e8b43fe69200b3 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; @@ -680,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) @@ -746,6 +748,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. @@ -1339,6 +1349,7 @@ void QCPAxis::scaleRange(double factor) */ void QCPAxis::scaleRange(double factor, double center) { + if (mRangeLocked) return; QCPRange oldRange = mRange; if (mScaleType == stLinear) { diff --git a/src/axis/axis.h b/src/axis/axis.h index 38e35737fc7d26dae3e217dfe075d8da2719ebd1..f37171a11815eccbd1b35b0b9e2011682d2292fc 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: diff --git a/src/qcustomplot.cpp.skeleton b/src/qcustomplot.cpp.skeleton index c5f906907175b0565e7b5c4999ec983ee6c45858..072df98f6f7f45b404334843373182eb96ef1670 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 3da9d3208650a6da6a069cdc37d28bb482a36530..3696c2be8c44ae1c4e651ab18e2f3d9eccc4bdd5 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