182 if (!qFuzzyIsNull(vLengthSqr))
184 double mu = v.
dot(*
this-start)/vLengthSqr;
186 return (*
this-start).lengthSquared();
188 return (*
this-end).lengthSquared();
190 return ((start + mu*v)-*
this).lengthSquared();
192 return (*
this-start).lengthSquared();
288 mIsAntialiasing(false)
305 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // before Qt5, default pens used to be cosmetic if NonCosmeticDefaultPen flag isn't set. So we set it to get consistency across Qt versions. 307 setRenderHint(QPainter::NonCosmeticDefaultPen);
319 QPainter::setPen(pen);
333 QPainter::setPen(color);
347 QPainter::setPen(penStyle);
363 QPainter::drawLine(line);
365 QPainter::drawLine(line.toLine());
376 setRenderHint(QPainter::Antialiasing, enabled);
385 translate(-0.5, -0.5);
412 bool result = QPainter::begin(device);
413 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // before Qt5, default pens used to be cosmetic if NonCosmeticDefaultPen flag isn't set. So we set it to get consistency across Qt versions. 415 setRenderHint(QPainter::NonCosmeticDefaultPen);
427 if (!enabled &&
mModes.testFlag(mode))
429 else if (enabled && !
mModes.testFlag(mode))
460 qDebug() << Q_FUNC_INFO <<
"Unbalanced save/restore";
470 if (qFuzzyIsNull(pen().widthF()))
572 mDevicePixelRatio(devicePixelRatio),
631 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 635 qDebug() << Q_FUNC_INFO <<
"Device pixel ratios not supported for Qt versions before 5.4";
670 result->setRenderHint(QPainter::HighQualityAntialiasing);
677 if (painter && painter->isActive())
678 painter->drawPixmap(0, 0,
mBuffer);
680 qDebug() << Q_FUNC_INFO <<
"invalid or inactive painter passed";
695 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 697 mBuffer.setDevicePixelRatio(mDevicePixelRatio);
699 qDebug() << Q_FUNC_INFO <<
"Device pixel ratios not supported for Qt versions before 5.4";
700 mDevicePixelRatio = 1.0;
710 #ifdef QCP_OPENGL_PBUFFER 734 QCPPaintBufferGlPbuffer::QCPPaintBufferGlPbuffer(
const QSize &
size,
double devicePixelRatio,
int multisamples) :
737 mMultisamples(qMax(0, multisamples))
739 QCPPaintBufferGlPbuffer::reallocateBuffer();
742 QCPPaintBufferGlPbuffer::~QCPPaintBufferGlPbuffer()
749 QCPPainter *QCPPaintBufferGlPbuffer::startPainting()
751 if (!mGlPBuffer->isValid())
753 qDebug() << Q_FUNC_INFO <<
"OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
758 result->setRenderHint(QPainter::HighQualityAntialiasing);
763 void QCPPaintBufferGlPbuffer::draw(
QCPPainter *painter)
const 765 if (!painter || !painter->isActive())
767 qDebug() << Q_FUNC_INFO <<
"invalid or inactive painter passed";
770 if (!mGlPBuffer->isValid())
772 qDebug() << Q_FUNC_INFO <<
"OpenGL pbuffer isn't valid, reallocateBuffer was not called?";
775 painter->drawImage(0, 0, mGlPBuffer->toImage());
779 void QCPPaintBufferGlPbuffer::clear(
const QColor &color)
781 if (mGlPBuffer->isValid())
783 mGlPBuffer->makeCurrent();
784 glClearColor(color.redF(), color.greenF(), color.blueF(), color.alphaF());
785 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
786 mGlPBuffer->doneCurrent();
788 qDebug() << Q_FUNC_INFO <<
"OpenGL pbuffer invalid or context not current";
792 void QCPPaintBufferGlPbuffer::reallocateBuffer()
798 format.setAlpha(
true);
799 format.setSamples(mMultisamples);
800 mGlPBuffer =
new QGLPixelBuffer(
mSize, format);
802 #endif // QCP_OPENGL_PBUFFER 805 #ifdef QCP_OPENGL_FBO 830 QCPPaintBufferGlFbo::QCPPaintBufferGlFbo(
const QSize &
size,
double devicePixelRatio, QWeakPointer<QOpenGLContext> glContext, QWeakPointer<QOpenGLPaintDevice> glPaintDevice) :
832 mGlContext(glContext),
833 mGlPaintDevice(glPaintDevice),
836 QCPPaintBufferGlFbo::reallocateBuffer();
839 QCPPaintBufferGlFbo::~QCPPaintBufferGlFbo()
842 delete mGlFrameBuffer;
846 QCPPainter *QCPPaintBufferGlFbo::startPainting()
848 if (mGlPaintDevice.isNull())
850 qDebug() << Q_FUNC_INFO <<
"OpenGL paint device doesn't exist";
855 qDebug() << Q_FUNC_INFO <<
"OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
859 if (QOpenGLContext::currentContext() != mGlContext.data())
860 mGlContext.data()->makeCurrent(mGlContext.data()->surface());
861 mGlFrameBuffer->bind();
863 result->setRenderHint(QPainter::HighQualityAntialiasing);
868 void QCPPaintBufferGlFbo::donePainting()
870 if (mGlFrameBuffer && mGlFrameBuffer->isBound())
871 mGlFrameBuffer->release();
873 qDebug() << Q_FUNC_INFO <<
"Either OpenGL frame buffer not valid or was not bound";
877 void QCPPaintBufferGlFbo::draw(
QCPPainter *painter)
const 879 if (!painter || !painter->isActive())
881 qDebug() << Q_FUNC_INFO <<
"invalid or inactive painter passed";
886 qDebug() << Q_FUNC_INFO <<
"OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
889 painter->drawImage(0, 0, mGlFrameBuffer->toImage());
893 void QCPPaintBufferGlFbo::clear(
const QColor &color)
895 if (mGlContext.isNull())
897 qDebug() << Q_FUNC_INFO <<
"OpenGL context doesn't exist";
902 qDebug() << Q_FUNC_INFO <<
"OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
906 if (QOpenGLContext::currentContext() != mGlContext.data())
907 mGlContext.data()->makeCurrent(mGlContext.data()->surface());
908 mGlFrameBuffer->bind();
909 glClearColor(color.redF(), color.greenF(), color.blueF(), color.alphaF());
910 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
911 mGlFrameBuffer->release();
915 void QCPPaintBufferGlFbo::reallocateBuffer()
920 if (mGlFrameBuffer->isBound())
921 mGlFrameBuffer->release();
922 delete mGlFrameBuffer;
926 if (mGlContext.isNull())
928 qDebug() << Q_FUNC_INFO <<
"OpenGL context doesn't exist";
931 if (mGlPaintDevice.isNull())
933 qDebug() << Q_FUNC_INFO <<
"OpenGL paint device doesn't exist";
938 mGlContext.data()->makeCurrent(mGlContext.data()->surface());
939 QOpenGLFramebufferObjectFormat frameBufferFormat;
940 frameBufferFormat.setSamples(mGlContext.data()->format().samples());
941 frameBufferFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
944 mGlPaintDevice.data()->setSize(
mSize*mDevicePixelRatio);
945 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 946 mGlPaintDevice.data()->setDevicePixelRatio(mDevicePixelRatio);
949 #endif // QCP_OPENGL_FBO 1043 QObject(parentPlot),
1044 mParentPlot(parentPlot),
1065 qDebug() << Q_FUNC_INFO <<
"The parent plot's mCurrentLayer will be a dangling pointer. Should have been set to a valid layer or 0 beforehand.";
1125 painter->setClipRect(child->
clipRect().translated(0, -1));
1127 child->
draw(painter);
1147 if (painter->isActive())
1150 qDebug() << Q_FUNC_INFO <<
"paint buffer returned inactive painter";
1154 qDebug() << Q_FUNC_INFO <<
"paint buffer returned zero painter";
1156 qDebug() << Q_FUNC_INFO <<
"no valid paint buffer associated with this layer";
1183 qDebug() << Q_FUNC_INFO <<
"no valid paint buffer associated with this layer";
1209 qDebug() << Q_FUNC_INFO <<
"layerable is already child of this layer" <<
reinterpret_cast<quintptr
>(layerable);
1228 qDebug() << Q_FUNC_INFO <<
"layerable is not child of this layer" <<
reinterpret_cast<quintptr
>(layerable);
1343 mParentLayerable(parentLayerable),
1349 if (targetLayer.isEmpty())
1352 qDebug() << Q_FUNC_INFO <<
"setting QCPlayerable initial layer to" << targetLayer <<
"failed.";
1398 qDebug() << Q_FUNC_INFO <<
"no parent QCustomPlot set";
1406 qDebug() << Q_FUNC_INFO <<
"there is no layer with name" << layerName;
1474 Q_UNUSED(onlySelectable)
1500 qDebug() << Q_FUNC_INFO <<
"called with mParentPlot already initialized";
1505 qDebug() << Q_FUNC_INFO <<
"called with parentPlot zero";
1539 qDebug() << Q_FUNC_INFO <<
"no parent QCustomPlot set";
1544 qDebug() << Q_FUNC_INFO <<
"layer" << layer->
name() <<
"is not in same QCustomPlot as this layerable";
1594 Q_UNUSED(parentPlot)
1663 Q_UNUSED(selectionStateChanged)
1680 Q_UNUSED(selectionStateChanged)
1950 lower = includeCoord;
1952 upper = includeCoord;
1969 result.
expand(otherRange);
1986 result.
expand(includeCoord);
2000 if (lowerBound > upperBound)
2001 qSwap(lowerBound, upperBound);
2004 if (result.
lower < lowerBound)
2006 result.
lower = lowerBound;
2008 if (result.
upper > upperBound || qFuzzyCompare(
size(), upperBound-lowerBound))
2009 result.
upper = upperBound;
2010 }
else if (result.
upper > upperBound)
2012 result.
upper = upperBound;
2014 if (result.
lower < lowerBound || qFuzzyCompare(
size(), upperBound-lowerBound))
2015 result.
lower = lowerBound;
2035 double rangeFac = 1e-3;
2040 if (sanitizedRange.
lower == 0.0 && sanitizedRange.
upper != 0.0)
2043 if (rangeFac < sanitizedRange.
upper*rangeFac)
2044 sanitizedRange.
lower = rangeFac;
2046 sanitizedRange.
lower = sanitizedRange.
upper*rangeFac;
2048 else if (sanitizedRange.
lower != 0.0 && sanitizedRange.
upper == 0.0)
2051 if (-rangeFac > sanitizedRange.
lower*rangeFac)
2052 sanitizedRange.
upper = -rangeFac;
2054 sanitizedRange.
upper = sanitizedRange.
lower*rangeFac;
2055 }
else if (sanitizedRange.
lower < 0 && sanitizedRange.
upper > 0)
2058 if (-sanitizedRange.
lower > sanitizedRange.
upper)
2061 if (-rangeFac > sanitizedRange.
lower*rangeFac)
2062 sanitizedRange.
upper = -rangeFac;
2064 sanitizedRange.
upper = sanitizedRange.
lower*rangeFac;
2068 if (rangeFac < sanitizedRange.
upper*rangeFac)
2069 sanitizedRange.
lower = rangeFac;
2071 sanitizedRange.
lower = sanitizedRange.
upper*rangeFac;
2075 return sanitizedRange;
2086 return sanitizedRange;
2103 !(lower > 0 && qIsInf(upper/lower)) &&
2104 !(upper < 0 && qIsInf(lower/upper)));
2256 if (mEnd <= other.mBegin)
2269 return QCPDataRange(qMin(mBegin, other.mBegin), qMax(mEnd, other.mEnd));
2284 QCPDataRange result(qMax(mBegin, other.mBegin), qMin(mEnd, other.mEnd));
2298 return !( (mBegin > other.mBegin && mBegin >= other.mEnd) ||
2299 (mEnd <= other.mBegin && mEnd < other.mEnd) );
2309 return mBegin <= other.mBegin && mEnd >= other.mEnd;
2392 mDataRanges.append(range);
2404 if (mDataRanges.size() != other.mDataRanges.size())
2406 for (
int i=0; i<mDataRanges.size(); ++i)
2408 if (mDataRanges.at(i) != other.mDataRanges.at(i))
2420 mDataRanges << other.mDataRanges;
2431 addDataRange(other);
2456 while (i < mDataRanges.size())
2458 const int thisBegin = mDataRanges.at(i).begin();
2459 const int thisEnd = mDataRanges.at(i).end();
2460 if (thisBegin >= other.
end())
2463 if (thisEnd > other.
begin())
2465 if (thisBegin >= other.
begin())
2467 if (thisEnd <= other.
end())
2469 mDataRanges.removeAt(i);
2472 mDataRanges[i].setBegin(other.
end());
2475 if (thisEnd <= other.
end())
2477 mDataRanges[i].setEnd(other.
begin());
2480 mDataRanges[i].setEnd(other.
begin());
2499 for (
int i=0; i<mDataRanges.size(); ++i)
2500 result += mDataRanges.at(i).length();
2514 if (index >= 0 && index < mDataRanges.size())
2516 return mDataRanges.at(index);
2519 qDebug() << Q_FUNC_INFO <<
"index out of range:" << index;
2533 return QCPDataRange(mDataRanges.first().begin(), mDataRanges.last().end());
2544 mDataRanges.append(dataRange);
2556 mDataRanges.clear();
2571 for (
int i=mDataRanges.size()-1; i>=0; --i)
2573 if (mDataRanges.at(i).isEmpty())
2574 mDataRanges.removeAt(i);
2576 if (mDataRanges.isEmpty())
2580 std::sort(mDataRanges.begin(), mDataRanges.end(), lessThanDataRangeBegin);
2584 while (i < mDataRanges.size())
2586 if (mDataRanges.at(i-1).end() >= mDataRanges.at(i).begin())
2588 mDataRanges[i-1].setEnd(qMax(mDataRanges.at(i-1).end(), mDataRanges.at(i).end()));
2589 mDataRanges.removeAt(i);
2612 mDataRanges.clear();
2623 if (!mDataRanges.isEmpty())
2625 if (mDataRanges.size() > 1)
2626 mDataRanges = QList<QCPDataRange>() << mDataRanges.first();
2627 if (mDataRanges.first().length() > 1)
2628 mDataRanges.first().setEnd(mDataRanges.first().begin()+1);
2634 mDataRanges = QList<QCPDataRange>() << span();
2653 if (other.
isEmpty())
return false;
2657 while (thisIndex < mDataRanges.size() && otherIndex < other.mDataRanges.size())
2659 if (mDataRanges.at(thisIndex).contains(other.mDataRanges.at(otherIndex)))
2664 return thisIndex < mDataRanges.size();
2678 for (
int i=0; i<mDataRanges.size(); ++i)
2679 result.
addDataRange(mDataRanges.at(i).intersection(other),
false);
2714 if (mDataRanges.first().begin() != fullRange.
begin())
2717 for (
int i=1; i<mDataRanges.size(); ++i)
2720 if (mDataRanges.last().end() != fullRange.
end())
2815 mPen(QBrush(Qt::gray), 0, Qt::DashLine),
2816 mBrush(Qt::NoBrush),
2840 qDebug() << Q_FUNC_INFO <<
"called with axis zero";
2888 mRect = QRect(event->pos(),
event->pos());
2900 mRect.setBottomRight(event->pos());
2913 mRect.setBottomRight(event->pos());
2926 if (event->key() == Qt::Key_Escape &&
mActive)
2950 painter->setBrush(
mBrush);
2951 painter->drawRect(
mRect);
3009 QObject(parentPlot),
3029 QHashIterator<QCP::MarginSide, QList<QCPLayoutElement*> > it(
mChildren);
3030 while (it.hasNext())
3033 if (!it.value().isEmpty())
3046 QHashIterator<QCP::MarginSide, QList<QCPLayoutElement*> > it(
mChildren);
3047 while (it.hasNext())
3050 const QList<QCPLayoutElement*>
elements = it.value();
3051 for (
int i=elements.size()-1; i>=0; --i)
3052 elements.at(i)->setMarginGroup(it.key(), 0);
3071 for (
int i=0; i<elements.size(); ++i)
3073 if (!elements.at(i)->autoMargins().testFlag(side))
3075 int m = qMax(elements.at(i)->calculateAutoMargin(side),
QCP::getMarginValue(elements.at(i)->minimumMargins(), side));
3093 qDebug() << Q_FUNC_INFO <<
"element is already child of this margin group side" <<
reinterpret_cast<quintptr
>(element);
3104 if (!
mChildren[side].removeOne(element))
3105 qDebug() << Q_FUNC_INFO <<
"element is not child of this margin group side" <<
reinterpret_cast<quintptr
>(element);
3168 mMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX),
3170 mOuterRect(0, 0, 0, 0),
3171 mMargins(0, 0, 0, 0),
3172 mMinimumMargins(0, 0, 0, 0),
3323 QVector<QCP::MarginSide> sideVector;
3329 for (
int i=0; i<sideVector.size(); ++i)
3423 return QList<QCPLayoutElement*>();
3450 qDebug() << Q_FUNC_INFO <<
"parent plot not defined";
3598 const int elCount = elementCount();
3599 for (
int i=0; i<elCount; ++i)
3609 const int c = elementCount();
3610 QList<QCPLayoutElement*> result;
3611 #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) 3614 for (
int i=0; i<c; ++i)
3615 result.append(elementAt(i));
3618 for (
int i=0; i<c; ++i)
3621 result << result.at(i)->elements(recursive);
3688 for (
int i=elementCount()-1; i>=0; --i)
3706 if (QWidget *w = qobject_cast<QWidget*>(parent()))
3707 w->updateGeometry();
3708 else if (
QCPLayout *l = qobject_cast<QCPLayout*>(parent()))
3709 l->sizeConstraintsChanged();
3747 el->setParent(
this);
3752 qDebug() << Q_FUNC_INFO <<
"Null element passed";
3774 qDebug() << Q_FUNC_INFO <<
"Null element passed";
3808 if (maxSizes.size() != minSizes.size() || minSizes.size() != stretchFactors.size())
3810 qDebug() << Q_FUNC_INFO <<
"Passed vector sizes aren't equal:" << maxSizes << minSizes << stretchFactors;
3811 return QVector<int>();
3813 if (stretchFactors.isEmpty())
3814 return QVector<int>();
3815 int sectionCount = stretchFactors.size();
3816 QVector<double> sectionSizes(sectionCount);
3819 for (
int i=0; i<sectionCount; ++i)
3820 minSizeSum += minSizes.at(i);
3821 if (totalSize < minSizeSum)
3824 for (
int i=0; i<sectionCount; ++i)
3826 stretchFactors[i] = minSizes.at(i);
3831 QList<int> minimumLockedSections;
3832 QList<int> unfinishedSections;
3833 for (
int i=0; i<sectionCount; ++i)
3834 unfinishedSections.append(i);
3835 double freeSize = totalSize;
3837 int outerIterations = 0;
3838 while (!unfinishedSections.isEmpty() && outerIterations < sectionCount*2)
3841 int innerIterations = 0;
3842 while (!unfinishedSections.isEmpty() && innerIterations < sectionCount*2)
3847 double nextMax = 1e12;
3848 for (
int i=0; i<unfinishedSections.size(); ++i)
3850 int secId = unfinishedSections.at(i);
3851 double hitsMaxAt = (maxSizes.at(secId)-sectionSizes.at(secId))/stretchFactors.at(secId);
3852 if (hitsMaxAt < nextMax)
3854 nextMax = hitsMaxAt;
3860 double stretchFactorSum = 0;
3861 for (
int i=0; i<unfinishedSections.size(); ++i)
3862 stretchFactorSum += stretchFactors.at(unfinishedSections.at(i));
3863 double nextMaxLimit = freeSize/stretchFactorSum;
3864 if (nextMax < nextMaxLimit)
3866 for (
int i=0; i<unfinishedSections.size(); ++i)
3868 sectionSizes[unfinishedSections.at(i)] += nextMax*stretchFactors.at(unfinishedSections.at(i));
3869 freeSize -= nextMax*stretchFactors.at(unfinishedSections.at(i));
3871 unfinishedSections.removeOne(nextId);
3874 for (
int i=0; i<unfinishedSections.size(); ++i)
3875 sectionSizes[unfinishedSections.at(i)] += nextMaxLimit*stretchFactors.at(unfinishedSections.at(i));
3876 unfinishedSections.clear();
3879 if (innerIterations == sectionCount*2)
3880 qDebug() << Q_FUNC_INFO <<
"Exceeded maximum expected inner iteration count, layouting aborted. Input was:" << maxSizes << minSizes << stretchFactors << totalSize;
3883 bool foundMinimumViolation =
false;
3884 for (
int i=0; i<sectionSizes.size(); ++i)
3886 if (minimumLockedSections.contains(i))
3888 if (sectionSizes.at(i) < minSizes.at(i))
3890 sectionSizes[i] = minSizes.at(i);
3891 foundMinimumViolation =
true;
3892 minimumLockedSections.append(i);
3895 if (foundMinimumViolation)
3897 freeSize = totalSize;
3898 for (
int i=0; i<sectionCount; ++i)
3900 if (!minimumLockedSections.contains(i))
3901 unfinishedSections.append(i);
3903 freeSize -= sectionSizes.at(i);
3906 for (
int i=0; i<unfinishedSections.size(); ++i)
3907 sectionSizes[unfinishedSections.at(i)] = 0;
3910 if (outerIterations == sectionCount*2)
3911 qDebug() << Q_FUNC_INFO <<
"Exceeded maximum expected outer iteration count, layouting aborted. Input was:" << maxSizes << minSizes << stretchFactors << totalSize;
3913 QVector<int> result(sectionCount);
3914 for (
int i=0; i<sectionCount; ++i)
3915 result[i] = qRound(sectionSizes.at(i));
3969 mFillOrder(foRowsFirst)
3992 if (column >= 0 && column <
mElements.first().size())
3997 qDebug() << Q_FUNC_INFO <<
"Requested cell is empty. Row:" << row <<
"Column:" << column;
3999 qDebug() << Q_FUNC_INFO <<
"Invalid column. Row:" << row <<
"Column:" << column;
4001 qDebug() << Q_FUNC_INFO <<
"Invalid row. Row:" << row <<
"Column:" << column;
4024 if (element && element->
layout())
4032 qDebug() << Q_FUNC_INFO <<
"There is already an element in the specified row/column:" << row << column;
4073 return addElement(rowIndex, colIndex, element);
4108 qDebug() << Q_FUNC_INFO <<
"Invalid stretch factor, must be positive:" << factor;
4110 qDebug() << Q_FUNC_INFO <<
"Invalid column:" << column;
4133 qDebug() << Q_FUNC_INFO <<
"Invalid stretch factor, must be positive:" <<
mColumnStretchFactors.at(i);
4138 qDebug() << Q_FUNC_INFO <<
"Column count not equal to passed stretch factor count:" << factors;
4159 qDebug() << Q_FUNC_INFO <<
"Invalid stretch factor, must be positive:" << factor;
4161 qDebug() << Q_FUNC_INFO <<
"Invalid row:" << row;
4184 qDebug() << Q_FUNC_INFO <<
"Invalid stretch factor, must be positive:" <<
mRowStretchFactors.at(i);
4189 qDebug() << Q_FUNC_INFO <<
"Row count not equal to passed stretch factor count:" << factors;
4231 mWrap = qMax(0, count);
4262 QVector<QCPLayoutElement*> tempElements;
4265 tempElements.reserve(elCount);
4266 for (
int i=0; i<elCount; ++i)
4269 tempElements.append(
takeAt(i));
4278 for (
int i=0; i<tempElements.size(); ++i)
4302 mElements.append(QList<QCPLayoutElement*>());
4306 int newColCount = qMax(
columnCount(), newColumnCount);
4309 while (
mElements.at(i).size() < newColCount)
4336 QList<QCPLayoutElement*> newRow;
4362 for (
int row=0; row<
rowCount(); ++row)
4391 qDebug() << Q_FUNC_INFO <<
"row index out of bounds:" << row;
4393 qDebug() << Q_FUNC_INFO <<
"column index out of bounds:" << column;
4420 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
4444 QVector<int> minColWidths, minRowHeights, maxColWidths, maxRowHeights;
4454 int yOffset =
mRect.top();
4455 for (
int row=0; row<
rowCount(); ++row)
4459 int xOffset =
mRect.left();
4465 mElements.at(row).at(col)->setOuterRect(QRect(xOffset, yOffset, colWidths.at(col), rowHeights.at(row)));
4508 qDebug() << Q_FUNC_INFO <<
"Attempt to take invalid index:" << index;
4526 qDebug() << Q_FUNC_INFO <<
"Element not in this layout, couldn't take";
4528 qDebug() << Q_FUNC_INFO <<
"Can't take null element";
4535 QList<QCPLayoutElement*> result;
4537 #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) 4538 result.reserve(elCount);
4540 for (
int i=0; i<elCount; ++i)
4544 for (
int i=0; i<elCount; ++i)
4547 result << result.at(i)->elements(recursive);
4559 for (
int row=
rowCount()-1; row>=0; --row)
4561 bool hasElements =
false;
4582 bool hasElements =
false;
4583 for (
int row=0; row<
rowCount(); ++row)
4594 for (
int row=0; row<
rowCount(); ++row)
4603 QVector<int> minColWidths, minRowHeights;
4606 for (
int i=0; i<minColWidths.size(); ++i)
4607 result.rwidth() += minColWidths.at(i);
4608 for (
int i=0; i<minRowHeights.size(); ++i)
4609 result.rheight() += minRowHeights.at(i);
4618 QVector<int> maxColWidths, maxRowHeights;
4622 for (
int i=0; i<maxColWidths.size(); ++i)
4623 result.setWidth(qMin(result.width()+maxColWidths.at(i), QWIDGETSIZE_MAX));
4624 for (
int i=0; i<maxRowHeights.size(); ++i)
4625 result.setHeight(qMin(result.height()+maxRowHeights.at(i), QWIDGETSIZE_MAX));
4646 *minRowHeights = QVector<int>(
rowCount(), 0);
4647 for (
int row=0; row<
rowCount(); ++row)
4653 QSize minHint =
mElements.at(row).at(col)->minimumSizeHint();
4654 QSize min =
mElements.at(row).at(col)->minimumSize();
4655 QSize
final(min.width() > 0 ? min.width() : minHint.width(), min.height() > 0 ? min.height() : minHint.height());
4656 if (minColWidths->at(col) <
final.width())
4657 (*minColWidths)[col] =
final.width();
4658 if (minRowHeights->at(row) <
final.height())
4659 (*minRowHeights)[row] =
final.height();
4679 *maxColWidths = QVector<int>(
columnCount(), QWIDGETSIZE_MAX);
4680 *maxRowHeights = QVector<int>(
rowCount(), QWIDGETSIZE_MAX);
4681 for (
int row=0; row<
rowCount(); ++row)
4687 QSize maxHint =
mElements.at(row).at(col)->maximumSizeHint();
4688 QSize max =
mElements.at(row).at(col)->maximumSize();
4689 QSize
final(max.width() < QWIDGETSIZE_MAX ? max.width() : maxHint.width(), max.height() < QWIDGETSIZE_MAX ? max.height() : maxHint.height());
4690 if (maxColWidths->at(col) >
final.width())
4691 (*maxColWidths)[col] =
final.width();
4692 if (maxRowHeights->at(row) >
final.height())
4693 (*maxRowHeights)[row] =
final.height();
4751 return mInsetPlacement.at(index);
4754 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4766 return mInsetAlignment.at(index);
4769 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4781 return mInsetRect.at(index);
4784 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4797 mInsetPlacement[index] = placement;
4799 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4813 mInsetAlignment[index] = alignment;
4815 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4832 mInsetRect[index] =
rect;
4834 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4843 QSize finalMinSize, finalMaxSize;
4844 QSize minSizeHint =
mElements.at(i)->minimumSizeHint();
4845 QSize maxSizeHint =
mElements.at(i)->maximumSizeHint();
4846 finalMinSize.setWidth(
mElements.at(i)->minimumSize().width() > 0 ?
mElements.at(i)->minimumSize().width() : minSizeHint.width());
4847 finalMinSize.setHeight(
mElements.at(i)->minimumSize().height() > 0 ?
mElements.at(i)->minimumSize().height() : minSizeHint.height());
4848 finalMaxSize.setWidth(
mElements.at(i)->maximumSize().width() < QWIDGETSIZE_MAX ?
mElements.at(i)->maximumSize().width() : maxSizeHint.width());
4849 finalMaxSize.setHeight(
mElements.at(i)->maximumSize().height() < QWIDGETSIZE_MAX ?
mElements.at(i)->maximumSize().height() : maxSizeHint.height());
4850 if (mInsetPlacement.at(i) == ipFree)
4852 insetRect = QRect(
rect().x()+
rect().width()*mInsetRect.at(i).x(),
4853 rect().y()+
rect().height()*mInsetRect.at(i).y(),
4854 rect().width()*mInsetRect.at(i).width(),
4855 rect().height()*mInsetRect.at(i).height());
4856 if (insetRect.size().width() < finalMinSize.width())
4857 insetRect.setWidth(finalMinSize.width());
4858 if (insetRect.size().height() < finalMinSize.height())
4859 insetRect.setHeight(finalMinSize.height());
4860 if (insetRect.size().width() > finalMaxSize.width())
4861 insetRect.setWidth(finalMaxSize.width());
4862 if (insetRect.size().height() > finalMaxSize.height())
4863 insetRect.setHeight(finalMaxSize.height());
4864 }
else if (mInsetPlacement.at(i) == ipBorderAligned)
4866 insetRect.setSize(finalMinSize);
4867 Qt::Alignment al = mInsetAlignment.at(i);
4868 if (al.testFlag(Qt::AlignLeft)) insetRect.moveLeft(
rect().x());
4869 else if (al.testFlag(Qt::AlignRight)) insetRect.moveRight(
rect().x()+
rect().width());
4870 else insetRect.moveLeft(
rect().x()+
rect().width()*0.5-finalMinSize.width()*0.5);
4871 if (al.testFlag(Qt::AlignTop)) insetRect.moveTop(
rect().y());
4872 else if (al.testFlag(Qt::AlignBottom)) insetRect.moveBottom(
rect().y()+
rect().height());
4873 else insetRect.moveTop(
rect().y()+
rect().height()*0.5-finalMinSize.height()*0.5);
4875 mElements.at(i)->setOuterRect(insetRect);
4888 if (index >= 0 && index <
mElements.size())
4901 mInsetPlacement.removeAt(index);
4902 mInsetAlignment.removeAt(index);
4903 mInsetRect.removeAt(index);
4907 qDebug() << Q_FUNC_INFO <<
"Attempt to take invalid index:" << index;
4925 qDebug() << Q_FUNC_INFO <<
"Element not in this layout, couldn't take";
4927 qDebug() << Q_FUNC_INFO <<
"Can't take null element";
4950 if (
mElements.at(i)->realVisibility() &&
mElements.at(i)->selectTest(pos, onlySelectable) >= 0)
4974 mInsetPlacement.append(ipBorderAligned);
4975 mInsetAlignment.append(alignment);
4976 mInsetRect.append(QRectF(0.6, 0.6, 0.4, 0.4));
4979 qDebug() << Q_FUNC_INFO <<
"Can't add null element";
5000 mInsetPlacement.append(ipFree);
5001 mInsetAlignment.append(Qt::AlignRight|Qt::AlignTop);
5002 mInsetRect.append(rect);
5005 qDebug() << Q_FUNC_INFO <<
"Can't add null element";
5186 QPen penBackup = painter->pen();
5187 QBrush brushBackup = painter->brush();
5188 QPen miterPen = penBackup;
5189 miterPen.setJoinStyle(Qt::MiterJoin);
5190 QBrush brush(painter->pen().color(), Qt::SolidPattern);
5196 QPointF points[3] = {pos.
toPointF(),
5197 (pos-lengthVec+widthVec).toPointF(),
5198 (pos-lengthVec-widthVec).toPointF()
5200 painter->
setPen(miterPen);
5201 painter->setBrush(brush);
5202 painter->drawConvexPolygon(points, 3);
5203 painter->setBrush(brushBackup);
5204 painter->
setPen(penBackup);
5209 QPointF points[4] = {pos.
toPointF(),
5210 (pos-lengthVec+widthVec).toPointF(),
5211 (pos-lengthVec*0.8).toPointF(),
5212 (pos-lengthVec-widthVec).toPointF()
5214 painter->
setPen(miterPen);
5215 painter->setBrush(brush);
5216 painter->drawConvexPolygon(points, 4);
5217 painter->setBrush(brushBackup);
5218 painter->
setPen(penBackup);
5223 QPointF points[3] = {(pos-lengthVec+widthVec).toPointF(),
5225 (pos-lengthVec-widthVec).toPointF()
5227 painter->
setPen(miterPen);
5228 painter->drawPolyline(points, 3);
5229 painter->
setPen(penBackup);
5234 painter->setBrush(brush);
5236 painter->setBrush(brushBackup);
5242 QPointF points[4] = {(pos-widthVecPerp+widthVec).toPointF(),
5243 (pos-widthVecPerp-widthVec).toPointF(),
5244 (pos+widthVecPerp-widthVec).toPointF(),
5245 (pos+widthVecPerp+widthVec).toPointF()
5247 painter->
setPen(miterPen);
5248 painter->setBrush(brush);
5249 painter->drawConvexPolygon(points, 4);
5250 painter->setBrush(brushBackup);
5251 painter->
setPen(penBackup);
5257 QPointF points[4] = {(pos-widthVecPerp).toPointF(),
5258 (pos-widthVec).toPointF(),
5259 (pos+widthVecPerp).toPointF(),
5260 (pos+widthVec).toPointF()
5262 painter->
setPen(miterPen);
5263 painter->setBrush(brush);
5264 painter->drawConvexPolygon(points, 4);
5265 painter->setBrush(brushBackup);
5266 painter->
setPen(penBackup);
5271 painter->
drawLine((pos+widthVec).toPointF(), (pos-widthVec).toPointF());
5285 (pos-widthVec-lengthVec*0.2*(
mInverted?-1:1)).toPointF());
5289 painter->
drawLine((pos+widthVec+lengthVec*0.2*(
mInverted?-1:1)+dir.
normalized()*qMax(1.0f, (
float)painter->pen().widthF())*0.5f).toPointF(),
5290 (pos-widthVec-lengthVec*0.2*(
mInverted?-1:1)+dir.
normalized()*qMax(1.0f, (
float)painter->pen().widthF())*0.5f).toPointF());
5373 mTickStepStrategy(tssReadability),
5406 qDebug() << Q_FUNC_INFO <<
"tick count must be greater than zero:" << count;
5435 void QCPAxisTicker::generate(
const QCPRange &range,
const QLocale &locale, QChar formatChar,
int precision, QVector<double> &ticks, QVector<double> *subTicks, QVector<QString> *tickLabels)
5445 if (ticks.size() > 0)
5450 *subTicks = QVector<double>();
5488 double epsilon = 0.01;
5491 double fracPart = modf(
getMantissa(tickStep), &intPartf);
5495 if (fracPart < epsilon || 1.0-fracPart < epsilon)
5497 if (1.0-fracPart < epsilon)
5501 case 1: result = 4;
break;
5502 case 2: result = 3;
break;
5503 case 3: result = 2;
break;
5504 case 4: result = 3;
break;
5505 case 5: result = 4;
break;
5506 case 6: result = 2;
break;
5507 case 7: result = 6;
break;
5508 case 8: result = 3;
break;
5509 case 9: result = 2;
break;
5514 if (qAbs(fracPart-0.5) < epsilon)
5518 case 1: result = 2;
break;
5519 case 2: result = 4;
break;
5520 case 3: result = 4;
break;
5521 case 4: result = 2;
break;
5522 case 5: result = 4;
break;
5523 case 6: result = 4;
break;
5524 case 7: result = 2;
break;
5525 case 8: result = 4;
break;
5526 case 9: result = 4;
break;
5548 return locale.toString(tick, formatChar.toLatin1(), precision);
5562 QVector<double> result;
5563 if (subTickCount <= 0 || ticks.size() < 2)
5566 result.reserve((ticks.size()-1)*subTickCount);
5567 for (
int i=1; i<ticks.size(); ++i)
5569 double subTickStep = (ticks.at(i)-ticks.at(i-1))/(
double)(subTickCount+1);
5570 for (
int k=1; k<=subTickCount; ++k)
5571 result.append(ticks.at(i-1) + k*subTickStep);
5593 QVector<double> result;
5597 int tickcount = lastStep-firstStep+1;
5598 if (tickcount < 0) tickcount = 0;
5599 result.resize(tickcount);
5600 for (
int i=0; i<tickcount; ++i)
5616 QVector<QString> result;
5617 result.reserve(ticks.size());
5618 for (
int i=0; i<ticks.size(); ++i)
5619 result.append(
getTickLabel(ticks.at(i), locale, formatChar, precision));
5632 bool lowFound =
false;
5633 bool highFound =
false;
5637 for (
int i=0; i < ticks.size(); ++i)
5639 if (ticks.at(i) >= range.
lower)
5646 for (
int i=ticks.size()-1; i >= 0; --i)
5648 if (ticks.at(i) <= range.
upper)
5656 if (highFound && lowFound)
5658 int trimFront = qMax(0, lowIndex-(keepOneOutlier ? 1 : 0));
5659 int trimBack = qMax(0, ticks.size()-(keepOneOutlier ? 2 : 1)-highIndex);
5660 if (trimFront > 0 || trimBack > 0)
5661 ticks = ticks.mid(trimFront, ticks.size()-trimFront-trimBack);
5674 if (candidates.size() == 1)
5675 return candidates.first();
5676 QVector<double>::const_iterator it = std::lower_bound(candidates.constBegin(), candidates.constEnd(), target);
5677 if (it == candidates.constEnd())
5679 else if (it == candidates.constBegin())
5682 return target-*(it-1) < *it-target ? *(it-1) : *it;
5694 const double mag = qPow(10.0, qFloor(qLn(input)/qLn(10.0)));
5695 if (magnitude) *magnitude = mag;
5708 const double mantissa =
getMantissa(input, &magnitude);
5713 return pickClosest(mantissa, QVector<double>() << 1.0 << 2.0 << 2.5 << 5.0 << 10.0)*magnitude;
5718 if (mantissa <= 5.0)
5719 return (
int)(mantissa*2)/2.0*magnitude;
5721 return (
int)(mantissa/2.0)*2.0*magnitude;
5776 mDateTimeFormat(QLatin1String(
"hh:mm:ss\ndd.MM.yy")),
5777 mDateTimeSpec(Qt::LocalTime),
5778 mDateStrategy(dsNone)
5858 }
else if (result < 86400*30.4375*12)
5861 << 1 << 2.5 << 5 << 10 << 15 << 30 << 60 << 2.5*60 << 5*60 << 10*60 << 15*60 << 30*60 << 60*60
5862 << 3600*2 << 3600*3 << 3600*6 << 3600*12 << 3600*24
5863 << 86400*2 << 86400*5 << 86400*7 << 86400*14 << 86400*30.4375 << 86400*30.4375*2 << 86400*30.4375*3 << 86400*30.4375*6 << 86400*30.4375*12);
5864 if (result > 86400*30.4375-1)
5866 else if (result > 3600*24-1)
5870 const double secondsPerYear = 86400*30.4375*12;
5871 result =
cleanMantissa(result/secondsPerYear)*secondsPerYear;
5887 switch (qRound(tickStep))
5889 case 5*60: result = 4;
break;
5890 case 10*60: result = 1;
break;
5891 case 15*60: result = 2;
break;
5892 case 30*60: result = 1;
break;
5893 case 60*60: result = 3;
break;
5894 case 3600*2: result = 3;
break;
5895 case 3600*3: result = 2;
break;
5896 case 3600*6: result = 1;
break;
5897 case 3600*12: result = 3;
break;
5898 case 3600*24: result = 3;
break;
5899 case 86400*2: result = 1;
break;
5900 case 86400*5: result = 4;
break;
5901 case 86400*7: result = 6;
break;
5902 case 86400*14: result = 1;
break;
5903 case (
int)(86400*30.4375+0.5): result = 3;
break;
5904 case (
int)(86400*30.4375*2+0.5): result = 1;
break;
5905 case (
int)(86400*30.4375*3+0.5): result = 2;
break;
5906 case (
int)(86400*30.4375*6+0.5): result = 5;
break;
5907 case (
int)(86400*30.4375*12+0.5): result = 3;
break;
5922 Q_UNUSED(formatChar)
5936 if (!result.isEmpty())
5941 QDateTime tickDateTime;
5942 for (
int i=0; i<result.size(); ++i)
5945 tickDateTime.setTime(uniformDateTime.time());
5951 QDateTime tickDateTime;
5952 for (
int i=0; i<result.size(); ++i)
5955 tickDateTime.setTime(uniformDateTime.time());
5956 int thisUniformDay = uniformDateTime.date().day() <= tickDateTime.date().daysInMonth() ? uniformDateTime.date().day() : tickDateTime.date().daysInMonth();
5957 if (thisUniformDay-tickDateTime.date().day() < -15)
5958 tickDateTime = tickDateTime.addMonths(1);
5959 else if (thisUniformDay-tickDateTime.date().day() > 15)
5960 tickDateTime = tickDateTime.addMonths(-1);
5961 tickDateTime.setDate(QDate(tickDateTime.date().year(), tickDateTime.date().month(), thisUniformDay));
5980 # if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) 5981 return QDateTime::fromTime_t(key).addMSecs((key-(qint64)key)*1000);
5983 return QDateTime::fromMSecsSinceEpoch(key*1000.0);
6000 # if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) 6001 return dateTime.toTime_t()+dateTime.time().msec()/1000.0;
6003 return dateTime.toMSecsSinceEpoch()/1000.0;
6017 # if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) 6018 return QDateTime(date).toTime_t();
6020 return QDateTime(date).toMSecsSinceEpoch()/1000.0;
6073 mTimeFormat(QLatin1String(
"%h:%m:%s")),
6074 mSmallestUnit(tuSeconds),
6075 mBiggestUnit(tuHours)
6117 bool hasSmallest =
false;
6164 }
else if (result < 3600*24)
6167 QVector<double> availableSteps;
6170 availableSteps << 1;
6172 availableSteps << 2.5;
6174 availableSteps << 2;
6176 availableSteps << 5 << 10 << 15 << 30;
6179 availableSteps << 1*60;
6181 availableSteps << 2.5*60;
6183 availableSteps << 2*60;
6185 availableSteps << 5*60 << 10*60 << 15*60 << 30*60;
6188 availableSteps << 1*3600 << 2*3600 << 3*3600 << 6*3600 << 12*3600 << 24*3600;
6193 const double secondsPerDay = 3600*24;
6208 switch (qRound(tickStep))
6210 case 5*60: result = 4;
break;
6211 case 10*60: result = 1;
break;
6212 case 15*60: result = 2;
break;
6213 case 30*60: result = 1;
break;
6214 case 60*60: result = 3;
break;
6215 case 3600*2: result = 3;
break;
6216 case 3600*3: result = 2;
break;
6217 case 3600*6: result = 1;
break;
6218 case 3600*12: result = 3;
break;
6219 case 3600*24: result = 3;
break;
6234 Q_UNUSED(formatChar)
6236 bool negative = tick < 0;
6237 if (negative) tick *= -1;
6239 double restValues[
tuDays+1];
6244 values[
tuMinutes] = modf(restValues[tuMinutes]/60, &restValues[
tuHours])*60;
6245 values[
tuHours] = modf(restValues[tuHours]/24, &restValues[
tuDays])*24;
6255 result.prepend(QLatin1Char(
'-'));
6266 QString valueStr = QString::number(value);
6268 valueStr.prepend(QLatin1Char(
'0'));
6307 mScaleStrategy(ssNone)
6325 qDebug() << Q_FUNC_INFO <<
"tick step must be greater than zero:" << step;
6464 qDebug() << Q_FUNC_INFO <<
"sub tick count can't be negative:" << subTicks;
6488 mTicks.insert(position, label);
6519 if (positions.size() != labels.size())
6520 qDebug() << Q_FUNC_INFO <<
"passed unequal length vectors for positions and labels:" << positions.size() << labels.size();
6521 int n = qMin(positions.size(), labels.size());
6522 for (
int i=0; i<n; ++i)
6523 mTicks.insert(positions.at(i), labels.at(i));
6558 Q_UNUSED(formatChar)
6560 return mTicks.value(tick);
6573 QVector<double> result;
6577 QMap<double, QString>::const_iterator start =
mTicks.lowerBound(range.
lower);
6578 QMap<double, QString>::const_iterator end =
mTicks.upperBound(range.
upper);
6580 if (start !=
mTicks.constBegin()) --start;
6581 if (end !=
mTicks.constEnd()) ++end;
6582 for (QMap<double, QString>::const_iterator it = start; it != end; ++it)
6583 result.append(it.key());
6617 mPiSymbol(QLatin1String(
" ")+QChar(0x03C0)),
6620 mFractionStyle(fsUnicodeFractions),
6716 int denominator = 1000;
6717 int numerator = qRound(tickInPis*denominator);
6719 if (qAbs(numerator) == 1 && denominator == 1)
6720 return (numerator < 0 ? QLatin1String(
"-") : QLatin1String(
"")) +
mPiSymbol.trimmed();
6721 else if (numerator == 0)
6722 return QLatin1String(
"0");
6727 if (qFuzzyIsNull(tickInPis))
6728 return QLatin1String(
"0");
6729 else if (qFuzzyCompare(qAbs(tickInPis), 1.0))
6730 return (tickInPis < 0 ? QLatin1String(
"-") : QLatin1String(
"")) +
mPiSymbol.trimmed();
6744 if (numerator == 0 || denominator == 0)
6747 int num = numerator;
6748 int denom = denominator;
6751 int oldDenom = denom;
6752 denom = num % denom;
6771 if (denominator == 0)
6773 qDebug() << Q_FUNC_INFO <<
"called with zero denominator";
6778 qDebug() << Q_FUNC_INFO <<
"shouldn't be called with fraction style fsDecimal";
6779 return QString::number(numerator/(
double)denominator);
6781 int sign = numerator*denominator < 0 ? -1 : 1;
6782 numerator = qAbs(numerator);
6783 denominator = qAbs(denominator);
6785 if (denominator == 1)
6787 return QString::number(sign*numerator);
6790 int integerPart = numerator/denominator;
6791 int remainder = numerator%denominator;
6794 return QString::number(sign*integerPart);
6799 return QString(QLatin1String(
"%1%2%3/%4"))
6800 .arg(sign == -1 ? QLatin1String(
"-") : QLatin1String(
""))
6801 .arg(integerPart > 0 ? QString::number(integerPart)+QLatin1String(
" ") : QLatin1String(
""))
6806 return QString(QLatin1String(
"%1%2%3"))
6807 .arg(sign == -1 ? QLatin1String(
"-") : QLatin1String(
""))
6808 .arg(integerPart > 0 ? QString::number(integerPart) : QLatin1String(
""))
6838 return QString(QChar(0x2070));
6843 const int digit = number%10;
6846 case 1: { result.prepend(QChar(0x00B9));
break; }
6847 case 2: { result.prepend(QChar(0x00B2));
break; }
6848 case 3: { result.prepend(QChar(0x00B3));
break; }
6849 default: { result.prepend(QChar(0x2070+digit));
break; }
6864 return QString(QChar(0x2080));
6869 result.prepend(QChar(0x2080+number%10));
6910 mLogBaseLnInv(1.0/qLn(mLogBase))
6925 qDebug() << Q_FUNC_INFO <<
"log base has to be greater than zero:" << base;
6943 qDebug() << Q_FUNC_INFO <<
"sub tick count can't be negative:" << subTicks;
6985 QVector<double> result;
6990 double currentTick = qPow(newLogBase, qFloor(qLn(range.
lower)/qLn(newLogBase)));
6991 result.append(currentTick);
6992 while (currentTick < range.upper && currentTick > 0)
6994 currentTick *= newLogBase;
6995 result.append(currentTick);
6997 }
else if (range.
lower < 0 && range.
upper < 0)
7001 double currentTick = -qPow(newLogBase, qCeil(qLn(-range.
lower)/qLn(newLogBase)));
7002 result.append(currentTick);
7003 while (currentTick < range.
upper && currentTick < 0)
7005 currentTick /= newLogBase;
7006 result.append(currentTick);
7010 qDebug() << Q_FUNC_INFO <<
"Invalid range for logarithmic plot: " << range.
lower <<
".." << range.
upper;
7045 QCPLayerable(parentAxis->parentPlot(), QString(), parentAxis),
7046 mParentAxis(parentAxis)
7049 setParent(parentAxis);
7050 setPen(QPen(QColor(200,200,200), 0, Qt::DotLine));
7137 if (!
mParentAxis) { qDebug() << Q_FUNC_INFO <<
"invalid parent axis";
return; }
7152 if (!
mParentAxis) { qDebug() << Q_FUNC_INFO <<
"invalid parent axis";
return; }
7159 int zeroLineIndex = -1;
7165 for (
int i=0; i<tickCount; ++i)
7179 for (
int i=0; i<tickCount; ++i)
7181 if (i == zeroLineIndex)
continue;
7188 int zeroLineIndex = -1;
7194 for (
int i=0; i<tickCount; ++i)
7208 for (
int i=0; i<tickCount; ++i)
7210 if (i == zeroLineIndex)
continue;
7225 if (!
mParentAxis) { qDebug() << Q_FUNC_INFO <<
"invalid parent axis";
return; }
7388 mOrientation(orientation(type)),
7389 mSelectableParts(spAxis | spTickLabels | spAxisLabel),
7390 mSelectedParts(spNone),
7391 mBasePen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
7392 mSelectedBasePen(QPen(Qt::blue, 2)),
7396 mSelectedLabelFont(QFont(mLabelFont.family(), mLabelFont.pointSize(), QFont::Bold)),
7397 mLabelColor(Qt::black),
7398 mSelectedLabelColor(Qt::blue),
7402 mSelectedTickLabelFont(QFont(mTickLabelFont.family(), mTickLabelFont.pointSize(), QFont::Bold)),
7403 mTickLabelColor(Qt::black),
7404 mSelectedTickLabelColor(Qt::blue),
7405 mNumberPrecision(6),
7406 mNumberFormatChar(
'g'),
7407 mNumberBeautifulPowers(true),
7411 mTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
7412 mSelectedTickPen(QPen(Qt::blue, 2)),
7413 mSubTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
7414 mSelectedSubTickPen(QPen(Qt::blue, 2)),
7417 mRangeReversed(false),
7418 mScaleType(stLinear),
7423 mCachedMarginValid(false),
7443 }
else if (type ==
atLeft)
7481 result.append(QLatin1Char(
'b'));
7483 result.append(QLatin1Char(
'c'));
7669 if (alignment == Qt::AlignLeft)
7671 else if (alignment == Qt::AlignRight)
7674 setRange(position-size/2.0, position+size/2.0);
7753 qDebug() << Q_FUNC_INFO <<
"can not set 0 as axis ticker";
7888 if (formatCode.isEmpty())
7890 qDebug() << Q_FUNC_INFO <<
"Passed formatCode is empty";
7896 QString allowedFormatChars(QLatin1String(
"eEfgG"));
7897 if (allowedFormatChars.contains(formatCode.at(0)))
7902 qDebug() << Q_FUNC_INFO <<
"Invalid number format code (first char not in 'eEfgG'):" << formatCode;
7905 if (formatCode.length() < 2)
7918 qDebug() << Q_FUNC_INFO <<
"Invalid number format code (second char not 'b' or first char neither 'e' nor 'g'):" << formatCode;
7921 if (formatCode.length() < 3)
7928 if (formatCode.at(2) == QLatin1Char(
'c'))
7931 }
else if (formatCode.at(2) == QLatin1Char(
'd'))
7936 qDebug() << Q_FUNC_INFO <<
"Invalid number format code (third char neither 'c' nor 'd'):" << formatCode;
8346 qDebug() << Q_FUNC_INFO <<
"Center of scaling operation doesn't lie in same logarithmic sign domain as range:" << center;
8367 int otherPixelSize, ownPixelSize;
8379 double newRangeSize = ratio*otherAxis->
range().
size()*ownPixelSize/(double)otherPixelSize;
8391 QList<QCPAbstractPlottable*> p =
plottables();
8393 bool haveRange =
false;
8394 for (
int i=0; i<p.size(); ++i)
8396 if (!p.at(i)->realVisibility() && onlyVisiblePlottables)
8399 bool currentFoundRange;
8403 if (p.at(i)->keyAxis() ==
this)
8404 plottableRange = p.at(i)->getKeyRange(currentFoundRange, signDomain);
8406 plottableRange = p.at(i)->getValueRange(currentFoundRange, signDomain);
8407 if (currentFoundRange)
8410 newRange = plottableRange;
8412 newRange.
expand(plottableRange);
8420 double center = (newRange.
lower+newRange.
upper)*0.5;
8490 else if (value <= 0 && mRange.upper > 0)
8512 else if (value <= 0 && mRange.upper > 0)
8558 details->setValue(part);
8571 QList<QCPAbstractPlottable*> result;
8589 QList<QCPGraph*> result;
8608 QList<QCPAbstractItem*> result;
8613 QList<QCPItemPosition*> positions =
mParentPlot->
mItems.at(itemId)->positions();
8614 for (
int posId=0; posId<positions.size(); ++posId)
8616 if (positions.at(posId)->keyAxis() ==
this || positions.at(posId)->valueAxis() ==
this)
8640 qDebug() << Q_FUNC_INFO <<
"Invalid margin side passed:" << (
int)side;
8655 default: qDebug() << Q_FUNC_INFO <<
"invalid axis type";
return atLeft;
break;
8668 if (selectionStateChanged)
8678 if (selectionStateChanged)
8710 QVector<double> subTickPositions;
8711 QVector<double> tickPositions;
8729 for (
int i=0; i<subTickCount; ++i)
8869 QVector<double> tickPositions;
8930 basePen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
8937 substituteExponent(true),
8938 numberMultiplyCross(false),
8943 tickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
8944 subTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
8946 abbreviateDecimalPowers(false),
8947 reversedEndings(false),
8982 double xCor = 0, yCor = 0;
8994 baseLine.setPoints(origin+QPointF(xCor, yCor), origin+QPointF(
axisRect.width()+xCor, yCor));
8996 baseLine.setPoints(origin+QPointF(xCor, yCor), origin+QPointF(xCor, -
axisRect.height()+yCor));
8998 baseLine = QLineF(baseLine.p2(), baseLine.p1());
9038 painter->setBrush(QBrush(
basePen.color()));
9039 QCPVector2D baseLineVector(baseLine.dx(), baseLine.dy());
9050 oldClipRect = painter->clipRegion().boundingRect();
9053 QSize tickLabelsSize(0, 0);
9061 int distanceToAxis = margin;
9064 for (
int i=0; i<maxLabelIndex; ++i)
9070 painter->setClipRect(oldClipRect);
9074 if (!
label.isEmpty())
9079 labelBounds = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip,
label);
9082 QTransform oldTransform = painter->transform();
9083 painter->translate((origin.x()-margin-labelBounds.height()), origin.y());
9084 painter->rotate(-90);
9085 painter->drawText(0, 0,
axisRect.height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter,
label);
9086 painter->setTransform(oldTransform);
9090 QTransform oldTransform = painter->transform();
9091 painter->translate((origin.x()+margin+labelBounds.height()), origin.y()-
axisRect.height());
9092 painter->rotate(90);
9093 painter->drawText(0, 0,
axisRect.height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter,
label);
9094 painter->setTransform(oldTransform);
9097 painter->drawText(origin.x(), origin.y()-margin-labelBounds.height(),
axisRect.width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter,
label);
9099 painter->drawText(origin.x(), origin.y()+margin,
axisRect.width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter,
label);
9103 int selectionTolerance = 0;
9107 qDebug() << Q_FUNC_INFO <<
"mParentPlot is null";
9109 int selAxisInSize = selectionTolerance;
9110 int selTickLabelSize;
9111 int selTickLabelOffset;
9114 selTickLabelSize = (
QCPAxis::orientation(
type) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width());
9118 selTickLabelSize = -(
QCPAxis::orientation(
type) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width());
9121 int selLabelSize = labelBounds.height();
9168 QSize tickLabelsSize(0, 0);
9179 if (!
label.isEmpty())
9183 bounds = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter | Qt::AlignVCenter,
label);
9243 if (text.isEmpty())
return;
9245 QPointF labelAnchor;
9264 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 9270 cachedLabel->
pixmap.fill(Qt::transparent);
9272 cachePainter.
setPen(painter->pen());
9276 bool labelClippedByBorder =
false;
9284 if (!labelClippedByBorder)
9286 painter->drawPixmap(labelAnchor+cachedLabel->
offset, cachedLabel->
pixmap);
9295 bool labelClippedByBorder =
false;
9303 if (!labelClippedByBorder)
9305 drawTickLabel(painter, finalPosition.x(), finalPosition.y(), labelData);
9311 if (finalSize.width() > tickLabelsSize->width())
9312 tickLabelsSize->setWidth(finalSize.width());
9313 if (finalSize.height() > tickLabelsSize->height())
9314 tickLabelsSize->setHeight(finalSize.height());
9329 QTransform oldTransform = painter->transform();
9330 QFont oldFont = painter->font();
9333 painter->translate(x, y);
9338 if (!labelData.
expPart.isEmpty())
9340 painter->setFont(labelData.
baseFont);
9341 painter->drawText(0, 0, 0, 0, Qt::TextDontClip, labelData.
basePart);
9344 painter->setFont(labelData.
expFont);
9348 painter->setFont(labelData.
baseFont);
9353 painter->setTransform(oldTransform);
9354 painter->setFont(oldFont);
9370 bool useBeautifulPowers =
false;
9375 ePos = text.indexOf(QLatin1Char(
'e'));
9376 if (ePos > 0 && text.at(ePos-1).isDigit())
9379 while (eLast+1 < text.size() && (text.at(eLast+1) == QLatin1Char(
'+') || text.at(eLast+1) == QLatin1Char(
'-') || text.at(eLast+1).isDigit()))
9382 useBeautifulPowers =
true;
9388 if (result.
baseFont.pointSizeF() > 0)
9390 if (useBeautifulPowers)
9397 result.
basePart = QLatin1String(
"10");
9400 result.
expPart = text.mid(ePos+1, eLast-ePos);
9402 while (result.
expPart.length() > 2 && result.
expPart.at(1) == QLatin1Char(
'0'))
9404 if (!result.
expPart.isEmpty() && result.
expPart.at(0) == QLatin1Char(
'+'))
9408 if (result.
expFont.pointSize() > 0)
9421 result.
totalBounds = QFontMetrics(result.
baseFont).boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter, result.
basePart);
9429 QTransform transform;
9487 x = +qSin(radians)*labelData.
totalBounds.height();
9509 x = -qSin(-radians)*labelData.
totalBounds.height()/2.0;
9510 y = -qCos(-radians)*labelData.
totalBounds.height();
9523 x = +qSin(radians)*labelData.
totalBounds.height()/2.0;
9528 y = +qSin(-radians)*labelData.
totalBounds.width();
9537 return QPointF(x, y);
9562 if (finalSize.width() > tickLabelsSize->width())
9563 tickLabelsSize->setWidth(finalSize.width());
9564 if (finalSize.height() > tickLabelsSize->height())
9565 tickLabelsSize->setHeight(finalSize.height());
9662 mBrush(Qt::NoBrush),
9771 if (properties.testFlag(
spPen))
9777 if (properties.testFlag(
spBrush))
9779 if (properties.testFlag(
spSize))
9781 if (properties.testFlag(
spShape))
9887 painter->setBrush(
mBrush);
9908 double w =
mSize/2.0;
9914 painter->
drawLine(QPointF(x, y), QPointF(x+0.0001, y));
9919 painter->
drawLine(QLineF(x-w, y-w, x+w, y+w));
9920 painter->
drawLine(QLineF(x-w, y+w, x+w, y-w));
9925 painter->
drawLine(QLineF(x-w, y, x+w, y));
9926 painter->
drawLine(QLineF( x, y+w, x, y-w));
9931 painter->drawEllipse(QPointF(x , y), w, w);
9936 QBrush b = painter->brush();
9937 painter->setBrush(painter->pen().color());
9938 painter->drawEllipse(QPointF(x , y), w, w);
9939 painter->setBrush(b);
9944 painter->drawRect(QRectF(x-w, y-w,
mSize,
mSize));
9949 painter->
drawLine(QLineF(x-w, y, x, y-w));
9950 painter->
drawLine(QLineF( x, y-w, x+w, y));
9951 painter->
drawLine(QLineF(x+w, y, x, y+w));
9952 painter->
drawLine(QLineF( x, y+w, x-w, y));
9957 painter->
drawLine(QLineF(x-w, y, x+w, y));
9958 painter->
drawLine(QLineF( x, y+w, x, y-w));
9959 painter->
drawLine(QLineF(x-w*0.707, y-w*0.707, x+w*0.707, y+w*0.707));
9960 painter->
drawLine(QLineF(x-w*0.707, y+w*0.707, x+w*0.707, y-w*0.707));
9965 painter->
drawLine(QLineF(x-w, y+0.755*w, x+w, y+0.755*w));
9966 painter->
drawLine(QLineF(x+w, y+0.755*w, x, y-0.977*w));
9967 painter->
drawLine(QLineF( x, y-0.977*w, x-w, y+0.755*w));
9972 painter->
drawLine(QLineF(x-w, y-0.755*w, x+w, y-0.755*w));
9973 painter->
drawLine(QLineF(x+w, y-0.755*w, x, y+0.977*w));
9974 painter->
drawLine(QLineF( x, y+0.977*w, x-w, y-0.755*w));
9979 painter->
drawLine(QLineF(x-w, y-w, x+w*0.95, y+w*0.95));
9980 painter->
drawLine(QLineF(x-w, y+w*0.95, x+w*0.95, y-w));
9981 painter->drawRect(QRectF(x-w, y-w,
mSize,
mSize));
9986 painter->
drawLine(QLineF(x-w, y, x+w*0.95, y));
9987 painter->
drawLine(QLineF( x, y+w, x, y-w));
9988 painter->drawRect(QRectF(x-w, y-w,
mSize,
mSize));
9993 painter->
drawLine(QLineF(x-w*0.707, y-w*0.707, x+w*0.670, y+w*0.670));
9994 painter->
drawLine(QLineF(x-w*0.707, y+w*0.670, x+w*0.670, y-w*0.707));
9995 painter->drawEllipse(QPointF(x, y), w, w);
10000 painter->
drawLine(QLineF(x-w, y, x+w, y));
10001 painter->
drawLine(QLineF( x, y+w, x, y-w));
10002 painter->drawEllipse(QPointF(x, y), w, w);
10007 painter->
drawLine(QLineF(x, y-w, x, y+w));
10008 painter->
drawLine(QLineF(x, y, x-w*0.707, y+w*0.707));
10009 painter->
drawLine(QLineF(x, y, x+w*0.707, y+w*0.707));
10010 painter->drawEllipse(QPointF(x, y), w, w);
10015 const double widthHalf =
mPixmap.width()*0.5;
10016 const double heightHalf =
mPixmap.height()*0.5;
10017 #if QT_VERSION < QT_VERSION_CHECK(4, 8, 0) 10018 const QRectF clipRect = painter->clipRegion().boundingRect().adjusted(-widthHalf, -heightHalf, widthHalf, heightHalf);
10020 const QRectF clipRect = painter->clipBoundingRect().adjusted(-widthHalf, -heightHalf, widthHalf, heightHalf);
10022 if (clipRect.contains(x, y))
10023 painter->drawPixmap(x-widthHalf, y-heightHalf,
mPixmap);
10028 QTransform oldTransform = painter->transform();
10029 painter->translate(x, y);
10032 painter->setTransform(oldTransform);
10078 mPen(QColor(80, 80, 255), 2.5),
10146 painter->setBrush(
mBrush);
10193 Q_UNUSED(selection)
10213 qDebug() << Q_FUNC_INFO <<
"This selection decorator is already registered with plottable:" <<
reinterpret_cast<quintptr
>(
mPlottable);
10435 QCPLayerable(keyAxis->parentPlot(), QString(), keyAxis->axisRect()),
10437 mAntialiasedFill(true),
10438 mAntialiasedScatters(true),
10442 mValueAxis(valueAxis),
10444 mSelectionDecorator(0)
10447 qDebug() << Q_FUNC_INFO <<
"Parent plot of keyAxis is not the same as that of valueAxis.";
10449 qDebug() << Q_FUNC_INFO <<
"keyAxis and valueAxis must be orthogonal to each other.";
10650 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
10671 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPointF(); }
10692 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
10741 if (!keyAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key axis";
return; }
10755 double center = (newRange.
lower+newRange.
upper)*0.5;
10784 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
10798 double center = (newRange.
lower+newRange.
upper)*0.5;
10831 qDebug() << Q_FUNC_INFO <<
"passed legend is null";
10836 qDebug() << Q_FUNC_INFO <<
"passed legend isn't in the same QCustomPlot as this plottable";
10876 qDebug() << Q_FUNC_INFO <<
"passed legend is null";
10993 if (selectionStateChanged)
10994 *selectionStateChanged =
mSelection != selectionBefore;
11005 if (selectionStateChanged)
11006 *selectionStateChanged =
mSelection != selectionBefore;
11062 mParentItem(parentItem),
11063 mAnchorId(anchorId)
11097 qDebug() << Q_FUNC_INFO <<
"no valid anchor id set:" <<
mAnchorId;
11102 qDebug() << Q_FUNC_INFO <<
"no parent item set";
11120 qDebug() << Q_FUNC_INFO <<
"provided pos is child already" <<
reinterpret_cast<quintptr
>(pos);
11132 qDebug() << Q_FUNC_INFO <<
"provided pos isn't child" <<
reinterpret_cast<quintptr
>(pos);
11148 qDebug() << Q_FUNC_INFO <<
"provided pos is child already" <<
reinterpret_cast<quintptr
>(pos);
11160 qDebug() << Q_FUNC_INFO <<
"provided pos isn't child" <<
reinterpret_cast<quintptr
>(pos);
11234 mPositionTypeX(ptAbsolute),
11235 mPositionTypeY(ptAbsolute),
11315 bool retainPixelPosition =
true;
11317 retainPixelPosition =
false;
11319 retainPixelPosition =
false;
11322 if (retainPixelPosition)
11327 if (retainPixelPosition)
11345 bool retainPixelPosition =
true;
11347 retainPixelPosition =
false;
11349 retainPixelPosition =
false;
11352 if (retainPixelPosition)
11357 if (retainPixelPosition)
11384 return successX && successY;
11397 if (parentAnchor ==
this)
11399 qDebug() << Q_FUNC_INFO <<
"can't set self as parent anchor" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11404 while (currentParent)
11409 if (currentParentPos ==
this)
11411 qDebug() << Q_FUNC_INFO <<
"can't create recursive parent-child-relationship" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11414 currentParent = currentParentPos->parentAnchorX();
11422 qDebug() << Q_FUNC_INFO <<
"can't set parent to be an anchor which itself depends on this position" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11435 if (keepPixelPosition)
11445 if (keepPixelPosition)
11462 if (parentAnchor ==
this)
11464 qDebug() << Q_FUNC_INFO <<
"can't set self as parent anchor" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11469 while (currentParent)
11474 if (currentParentPos ==
this)
11476 qDebug() << Q_FUNC_INFO <<
"can't create recursive parent-child-relationship" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11479 currentParent = currentParentPos->parentAnchorY();
11487 qDebug() << Q_FUNC_INFO <<
"can't set parent to be an anchor which itself depends on this position" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11500 if (keepPixelPosition)
11510 if (keepPixelPosition)
11565 result.rx() =
mKey;
11587 result.rx() +=
mAxisRect.data()->left();
11589 qDebug() << Q_FUNC_INFO <<
"Item position type x is ptAxisRectRatio, but no axis rect was defined";
11599 qDebug() << Q_FUNC_INFO <<
"Item position type x is ptPlotCoords, but no axes were defined";
11631 result.ry() +=
mAxisRect.data()->top();
11633 qDebug() << Q_FUNC_INFO <<
"Item position type y is ptAxisRectRatio, but no axis rect was defined";
11643 qDebug() << Q_FUNC_INFO <<
"Item position type y is ptPlotCoords, but no axes were defined";
11684 double x = pixelPosition.x();
11685 double y = pixelPosition.y();
11712 x /= (double)
mAxisRect.data()->width();
11714 qDebug() << Q_FUNC_INFO <<
"Item position type x is ptAxisRectRatio, but no axis rect was defined";
11720 x =
mKeyAxis.data()->pixelToCoord(x);
11724 qDebug() << Q_FUNC_INFO <<
"Item position type x is ptPlotCoords, but no axes were defined";
11754 y /= (double)
mAxisRect.data()->height();
11756 qDebug() << Q_FUNC_INFO <<
"Item position type y is ptAxisRectRatio, but no axis rect was defined";
11762 x =
mKeyAxis.data()->pixelToCoord(y);
11766 qDebug() << Q_FUNC_INFO <<
"Item position type y is ptPlotCoords, but no axes were defined";
11949 mClipToAxisRect(false),
11955 QList<QCPAxisRect*> rects = parentPlot->
axisRects();
11956 if (rects.size() > 0)
12059 qDebug() << Q_FUNC_INFO <<
"position with name not found:" << name;
12075 for (
int i=0; i<
mAnchors.size(); ++i)
12077 if (
mAnchors.at(i)->name() == name)
12080 qDebug() << Q_FUNC_INFO <<
"anchor with name not found:" << name;
12094 for (
int i=0; i<
mAnchors.size(); ++i)
12096 if (
mAnchors.at(i)->name() == name)
12152 double result = -1;
12155 QList<QLineF> lines;
12156 lines << QLineF(rect.topLeft(), rect.topRight()) << QLineF(rect.bottomLeft(), rect.bottomRight())
12157 << QLineF(rect.topLeft(), rect.bottomLeft()) << QLineF(rect.topRight(), rect.bottomRight());
12158 double minDistSqr = std::numeric_limits<double>::max();
12159 for (
int i=0; i<lines.size(); ++i)
12162 if (distSqr < minDistSqr)
12163 minDistSqr = distSqr;
12165 result = qSqrt(minDistSqr);
12170 if (rect.contains(pos))
12188 qDebug() << Q_FUNC_INFO <<
"called on item which shouldn't have any anchors (this method not reimplemented). anchorId" << anchorId;
12209 qDebug() << Q_FUNC_INFO <<
"anchor/position with name exists already:" << name;
12218 return newPosition;
12243 qDebug() << Q_FUNC_INFO <<
"anchor/position with name exists already:" << name;
12258 if (selectionStateChanged)
12259 *selectionStateChanged =
mSelected != selBefore;
12270 if (selectionStateChanged)
12271 *selectionStateChanged =
mSelected != selBefore;
12599 mBufferDevicePixelRatio(1.0),
12601 mAutoAddPlottableToLegend(true),
12605 mSelectionTolerance(8),
12606 mNoAntialiasingOnDrag(false),
12607 mBackgroundBrush(Qt::white, Qt::SolidPattern),
12608 mBackgroundScaled(true),
12609 mBackgroundScaledMode(Qt::KeepAspectRatioByExpanding),
12612 mMultiSelectModifier(Qt::ControlModifier),
12616 mMouseHasMoved(false),
12617 mMouseEventLayerable(0),
12618 mReplotting(false),
12619 mReplotQueued(false),
12620 mOpenGlMultisamples(16),
12621 mOpenGlAntialiasedElementsBackup(
QCP::
aeNone),
12622 mOpenGlCacheLabelsBackup(true)
12624 setAttribute(Qt::WA_NoMousePropagation);
12625 setAttribute(Qt::WA_OpaquePaintEvent);
12626 setFocusPolicy(Qt::ClickFocus);
12627 setMouseTracking(
true);
12628 QLocale currentLocale = locale();
12629 currentLocale.setNumberOptions(QLocale::OmitGroupSeparator);
12630 setLocale(currentLocale);
12631 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 12664 defaultAxisRect->
setLayer(QLatin1String(
"background"));
13055 #ifdef QCUSTOMPLOT_USE_OPENGL 13069 qDebug() << Q_FUNC_INFO <<
"Failed to enable OpenGL, continuing plotting without hardware acceleration.";
13086 qDebug() << Q_FUNC_INFO <<
"QCustomPlot can't use OpenGL because QCUSTOMPLOT_USE_OPENGL was not defined during compilation (add 'DEFINES += QCUSTOMPLOT_USE_OPENGL' to your qmake .pro file)";
13128 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 13134 qDebug() << Q_FUNC_INFO <<
"Device pixel ratios not supported for Qt versions before 5.4";
13235 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13268 qDebug() << Q_FUNC_INFO <<
"plottable not in list:" <<
reinterpret_cast<quintptr
>(
plottable);
13293 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13309 for (
int i=c-1; i >= 0; --i)
13333 QList<QCPAbstractPlottable*> result;
13337 result.append(plottable);
13361 if (onlySelectable && !plottable->
selectable())
13365 double currentDistance = plottable->
selectTest(pos,
false);
13366 if (currentDistance >= 0 && currentDistance < resultDistance)
13369 resultDistance = currentDistance;
13374 return resultPlottable;
13395 if (index >= 0 && index <
mGraphs.size())
13400 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13435 if (!keyAxis) keyAxis =
xAxis;
13436 if (!valueAxis) valueAxis =
yAxis;
13437 if (!keyAxis || !valueAxis)
13439 qDebug() << Q_FUNC_INFO <<
"can't use default QCustomPlot xAxis or yAxis, because at least one is invalid (has been deleted)";
13444 qDebug() << Q_FUNC_INFO <<
"passed keyAxis or valueAxis doesn't have this QCustomPlot as parent";
13449 newGraph->
setName(QLatin1String(
"Graph ")+QString::number(
mGraphs.size()));
13474 if (index >= 0 && index <
mGraphs.size())
13491 for (
int i=c-1; i >= 0; --i)
13516 QList<QCPGraph*> result;
13520 result.append(graph);
13535 if (index >= 0 && index <
mItems.size())
13537 return mItems.at(index);
13540 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13570 if (
mItems.contains(item))
13577 qDebug() << Q_FUNC_INFO <<
"item not in list:" <<
reinterpret_cast<quintptr
>(
item);
13588 if (index >= 0 && index <
mItems.size())
13592 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13607 for (
int i=c-1; i >= 0; --i)
13629 QList<QCPAbstractItem*> result;
13633 result.append(item);
13662 double currentDistance = item->
selectTest(pos,
false);
13663 if (currentDistance >= 0 && currentDistance < resultDistance)
13666 resultDistance = currentDistance;
13681 return mItems.contains(item);
13696 if (layer->
name() == name)
13710 if (index >= 0 && index <
mLayers.size())
13715 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13745 qDebug() << Q_FUNC_INFO <<
"layer with name doesn't exist:" << name;
13760 if (!
mLayers.contains(layer))
13762 qDebug() << Q_FUNC_INFO <<
"layer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
layer);
13797 if (!
mLayers.contains(otherLayer))
13799 qDebug() << Q_FUNC_INFO <<
"otherLayer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(otherLayer);
13804 qDebug() << Q_FUNC_INFO <<
"A layer exists already with the name" << name;
13831 if (!
mLayers.contains(layer))
13833 qDebug() << Q_FUNC_INFO <<
"layer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
layer);
13838 qDebug() << Q_FUNC_INFO <<
"can't remove last layer";
13843 int removedIndex = layer->
index();
13844 bool isFirstLayer = removedIndex==0;
13846 QList<QCPLayerable*> children = layer->
children();
13849 for (
int i=children.size()-1; i>=0; --i)
13850 children.at(i)->moveToLayer(targetLayer,
true);
13853 for (
int i=0; i<children.size(); ++i)
13854 children.at(i)->moveToLayer(targetLayer,
false);
13880 if (!
mLayers.contains(layer))
13882 qDebug() << Q_FUNC_INFO <<
"layer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
layer);
13885 if (!
mLayers.contains(otherLayer))
13887 qDebug() << Q_FUNC_INFO <<
"otherLayer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(otherLayer);
13893 else if (layer->
index() < otherLayer->
index())
13900 otherLayer->
mPaintBuffer.toStrongRef()->setInvalidated();
13931 const QList<QCPAxisRect*> rectList =
axisRects();
13932 if (index >= 0 && index < rectList.size())
13934 return rectList.at(index);
13937 qDebug() << Q_FUNC_INFO <<
"invalid axis rect index" << index;
13949 QList<QCPAxisRect*> result;
13950 QStack<QCPLayoutElement*> elementStack;
13954 while (!elementStack.isEmpty())
13960 elementStack.push(element);
13961 if (
QCPAxisRect *ar = qobject_cast<QCPAxisRect*>(element))
13982 bool searchSubElements =
true;
13983 while (searchSubElements && currentElement)
13985 searchSubElements =
false;
13990 currentElement = subElement;
13991 searchSubElements =
true;
13996 return currentElement;
14013 bool searchSubElements =
true;
14014 while (searchSubElements && currentElement)
14016 searchSubElements =
false;
14021 currentElement = subElement;
14022 searchSubElements =
true;
14023 if (
QCPAxisRect *ar = qobject_cast<QCPAxisRect*>(currentElement))
14041 QList<QCPAxis*> result, allAxes;
14043 allAxes << rect->
axes();
14045 foreach (
QCPAxis *axis, allAxes)
14048 result.append(axis);
14063 QList<QCPLegend*> result;
14065 QStack<QCPLayoutElement*> elementStack;
14069 while (!elementStack.isEmpty())
14075 elementStack.push(subElement);
14076 if (
QCPLegend *leg = qobject_cast<QCPLegend*>(subElement))
14079 result.append(leg);
14138 QTimer::singleShot(0,
this, SLOT(
replot()));
14176 QList<QCPAxis*> allAxes;
14178 allAxes << rect->
axes();
14180 foreach (
QCPAxis *axis, allAxes)
14181 axis->
rescale(onlyVisiblePlottables);
14223 bool success =
false;
14224 #ifdef QT_NO_PRINTER 14226 Q_UNUSED(exportPen)
14229 Q_UNUSED(pdfCreator)
14231 qDebug() << Q_FUNC_INFO <<
"Qt was built without printer support (QT_NO_PRINTER). PDF not created.";
14233 int newWidth, newHeight;
14234 if (width == 0 || height == 0)
14236 newWidth = this->width();
14237 newHeight = this->height();
14241 newHeight = height;
14244 QPrinter printer(QPrinter::ScreenResolution);
14245 printer.setOutputFileName(fileName);
14246 printer.setOutputFormat(QPrinter::PdfFormat);
14247 printer.setColorMode(QPrinter::Color);
14248 printer.printEngine()->setProperty(QPrintEngine::PPK_Creator, pdfCreator);
14249 printer.printEngine()->setProperty(QPrintEngine::PPK_DocumentName, pdfTitle);
14252 #if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) 14253 printer.setFullPage(
true);
14254 printer.setPaperSize(
viewport().
size(), QPrinter::DevicePixel);
14256 QPageLayout pageLayout;
14257 pageLayout.setMode(QPageLayout::FullPageMode);
14258 pageLayout.setOrientation(QPageLayout::Portrait);
14259 pageLayout.setMargins(QMarginsF(0, 0, 0, 0));
14260 pageLayout.setPageSize(QPageSize(
viewport().
size(), QPageSize::Point, QString(), QPageSize::ExactMatch));
14261 printer.setPageLayout(pageLayout);
14264 if (printpainter.
begin(&printer))
14275 draw(&printpainter);
14276 printpainter.end();
14280 #endif // QT_NO_PRINTER 14331 return saveRastered(fileName, width, height, scale,
"PNG", quality, resolution, resolutionUnit);
14378 return saveRastered(fileName, width, height, scale,
"JPG", quality, resolution, resolutionUnit);
14422 return saveRastered(fileName, width, height, scale,
"BMP", -1, resolution, resolutionUnit);
14457 if (painter.isActive())
14459 painter.setRenderHint(QPainter::HighQualityAntialiasing);
14463 for (
int bufferIndex = 0; bufferIndex <
mPaintBuffers.size(); ++bufferIndex)
14497 QList<QVariant> details;
14499 for (
int i=0; i<candidates.size(); ++i)
14502 candidates.at(i)->mouseDoubleClickEvent(event, details.at(i));
14503 if (event->isAccepted())
14512 if (!candidates.isEmpty())
14518 dataIndex = details.first().value<
QCPDataSelection>().dataRange().begin();
14520 }
else if (
QCPAxis *ax = qobject_cast<QCPAxis*>(candidates.first()))
14522 else if (
QCPAbstractItem *ai = qobject_cast<QCPAbstractItem*>(candidates.first()))
14524 else if (
QCPLegend *lg = qobject_cast<QCPLegend*>(candidates.first()))
14556 QList<QVariant> details;
14558 for (
int i=0; i<candidates.size(); ++i)
14561 candidates.at(i)->mousePressEvent(event, details.at(i));
14562 if (event->isAccepted())
14623 if (event->button() == Qt::LeftButton)
14672 QList<QCPLayerable*> candidates =
layerableListAt(event->pos(),
false);
14673 for (
int i=0; i<candidates.size(); ++i)
14676 candidates.at(i)->wheelEvent(event);
14677 if (event->isAccepted())
14702 layer->
draw(painter);
14792 int bufferIndex = 0;
14796 for (
int layerIndex = 0; layerIndex <
mLayers.size(); ++layerIndex)
14840 #if defined(QCP_OPENGL_FBO) 14842 #elif defined(QCP_OPENGL_PBUFFER) 14845 qDebug() << Q_FUNC_INFO <<
"OpenGL enabled even though no support for it compiled in, this shouldn't have happened. Falling back to pixmap paint buffer.";
14888 #ifdef QCP_OPENGL_FBO 14890 QSurfaceFormat proposedSurfaceFormat;
14892 #ifdef QCP_OPENGL_OFFSCREENSURFACE 14893 QOffscreenSurface *surface =
new QOffscreenSurface;
14895 QWindow *surface =
new QWindow;
14896 surface->setSurfaceType(QSurface::OpenGLSurface);
14898 surface->setFormat(proposedSurfaceFormat);
14900 mGlSurface = QSharedPointer<QSurface>(surface);
14901 mGlContext = QSharedPointer<QOpenGLContext>(
new QOpenGLContext);
14902 mGlContext->setFormat(mGlSurface->format());
14903 if (!mGlContext->create())
14905 qDebug() << Q_FUNC_INFO <<
"Failed to create OpenGL context";
14906 mGlContext.clear();
14907 mGlSurface.clear();
14910 if (!mGlContext->makeCurrent(mGlSurface.data()))
14912 qDebug() << Q_FUNC_INFO <<
"Failed to make opengl context current";
14913 mGlContext.clear();
14914 mGlSurface.clear();
14917 if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
14919 qDebug() << Q_FUNC_INFO <<
"OpenGL of this system doesn't support frame buffer objects";
14920 mGlContext.clear();
14921 mGlSurface.clear();
14924 mGlPaintDevice = QSharedPointer<QOpenGLPaintDevice>(
new QOpenGLPaintDevice);
14926 #elif defined(QCP_OPENGL_PBUFFER) 14927 return QGLFormat::hasOpenGL();
14946 #ifdef QCP_OPENGL_FBO 14947 mGlPaintDevice.clear();
14948 mGlContext.clear();
14949 mGlSurface.clear();
14979 if (this->legend == legend)
15002 bool selectionStateChanged =
false;
15006 QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> > potentialSelections;
15007 QRectF rectF(rect.normalized());
15015 QCPDataSelection dataSel = plottableInterface->selectTestRect(rectF,
true);
15017 potentialSelections.insertMulti(dataSel.
dataPointCount(), QPair<QCPAbstractPlottable*, QCPDataSelection>(
plottable, dataSel));
15024 if (!potentialSelections.isEmpty())
15026 QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> >::iterator it = potentialSelections.begin();
15027 while (it != potentialSelections.end()-1)
15028 it = potentialSelections.erase(it);
15041 if ((potentialSelections.isEmpty() || potentialSelections.constBegin()->first != layerable) &&
mInteractions.testFlag(layerable->
selectionCategory()))
15043 bool selChanged =
false;
15045 selectionStateChanged |= selChanged;
15052 QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> >::const_iterator it = potentialSelections.constEnd();
15053 while (it != potentialSelections.constBegin())
15056 if (
mInteractions.testFlag(it.value().first->selectionCategory()))
15058 bool selChanged =
false;
15059 it.value().first->selectEvent(event, additive, QVariant::fromValue(it.value().second), &selChanged);
15060 selectionStateChanged |= selChanged;
15066 if (selectionStateChanged)
15091 affectedAxes.removeAll(static_cast<QCPAxis*>(0));
15118 bool selectionStateChanged =
false;
15129 bool selChanged =
false;
15131 selectionStateChanged |= selChanged;
15139 bool selChanged =
false;
15140 clickedLayerable->
selectEvent(event, additive, details, &selChanged);
15141 selectionStateChanged |= selChanged;
15143 if (selectionStateChanged)
15165 qDebug() << Q_FUNC_INFO <<
"plottable already added to this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
plottable);
15170 qDebug() << Q_FUNC_INFO <<
"plottable not created with this QCustomPlot as parent:" <<
reinterpret_cast<quintptr
>(
plottable);
15178 if (!plottable->
layer())
15196 qDebug() << Q_FUNC_INFO <<
"passed graph is zero";
15201 qDebug() << Q_FUNC_INFO <<
"graph already registered with this QCustomPlot";
15221 if (
mItems.contains(item))
15223 qDebug() << Q_FUNC_INFO <<
"item already added to this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
item);
15228 qDebug() << Q_FUNC_INFO <<
"item not created with this QCustomPlot as parent:" <<
reinterpret_cast<quintptr
>(
item);
15233 if (!item->
layer())
15246 for (
int i=0; i<
mLayers.size(); ++i)
15267 QList<QVariant> details;
15268 QList<QCPLayerable*> candidates =
layerableListAt(pos, onlySelectable, selectionDetails ? &details : 0);
15269 if (selectionDetails && !details.isEmpty())
15270 *selectionDetails = details.first();
15271 if (!candidates.isEmpty())
15272 return candidates.first();
15297 QList<QCPLayerable*> result;
15298 for (
int layerIndex=
mLayers.size()-1; layerIndex>=0; --layerIndex)
15300 const QList<QCPLayerable*> layerables =
mLayers.at(layerIndex)->children();
15301 for (
int i=layerables.size()-1; i>=0; --i)
15303 if (!layerables.at(i)->realVisibility())
15306 double dist = layerables.at(i)->selectTest(pos, onlySelectable, selectionDetails ? &details : 0);
15309 result.append(layerables.at(i));
15310 if (selectionDetails)
15311 selectionDetails->append(details);
15338 QImage buffer =
toPixmap(width, height, scale).toImage();
15340 int dotsPerMeter = 0;
15341 switch (resolutionUnit)
15347 buffer.setDotsPerMeterX(dotsPerMeter);
15348 buffer.setDotsPerMeterY(dotsPerMeter);
15349 if (!buffer.isNull())
15350 return buffer.save(fileName, format, quality);
15366 int newWidth, newHeight;
15367 if (width == 0 || height == 0)
15369 newWidth = this->width();
15370 newHeight = this->height();
15374 newHeight = height;
15376 int scaledWidth = qRound(scale*newWidth);
15377 int scaledHeight = qRound(scale*newHeight);
15379 QPixmap result(scaledWidth, scaledHeight);
15382 painter.
begin(&result);
15383 if (painter.isActive())
15388 if (!qFuzzyCompare(scale, 1.0))
15392 painter.scale(scale, scale);
15401 qDebug() << Q_FUNC_INFO <<
"Couldn't activate painter on pixmap";
15422 int newWidth, newHeight;
15423 if (width == 0 || height == 0)
15425 newWidth = this->width();
15426 newHeight = this->height();
15430 newHeight = height;
15433 if (painter->isActive())
15443 qDebug() << Q_FUNC_INFO <<
"Passed painter is not active";
15493 mColorInterpolation(ciRGB),
15495 mColorBufferInvalidated(true)
15519 return ((other.
mLevelCount == this->mLevelCount) &&
15521 (other.
mPeriodic == this->mPeriodic) &&
15535 qDebug() << Q_FUNC_INFO <<
"n must be greater or equal 2 but was" << n;
15633 qDebug() << Q_FUNC_INFO <<
"null pointer given as data";
15638 qDebug() << Q_FUNC_INFO <<
"null pointer given as scanLine";
15649 for (
int i=0; i<n; ++i)
15658 for (
int i=0; i<n; ++i)
15660 int index = (data[dataIndexFactor*i]-range.
lower)*posToIndexFactor;
15672 for (
int i=0; i<n; ++i)
15681 for (
int i=0; i<n; ++i)
15707 qDebug() << Q_FUNC_INFO <<
"null pointer given as data";
15712 qDebug() << Q_FUNC_INFO <<
"null pointer given as alpha";
15717 qDebug() << Q_FUNC_INFO <<
"null pointer given as scanLine";
15728 for (
int i=0; i<n; ++i)
15733 if (alpha[dataIndexFactor*i] == 255)
15739 const float alphaF = alpha[dataIndexFactor*i]/255.0f;
15740 scanLine[i] = qRgba(qRed(rgb)*alphaF, qGreen(rgb)*alphaF, qBlue(rgb)*alphaF, qAlpha(rgb)*alphaF);
15745 for (
int i=0; i<n; ++i)
15747 int index = (data[dataIndexFactor*i]-range.
lower)*posToIndexFactor;
15752 if (alpha[dataIndexFactor*i] == 255)
15758 const float alphaF = alpha[dataIndexFactor*i]/255.0f;
15759 scanLine[i] = qRgba(qRed(rgb)*alphaF, qGreen(rgb)*alphaF, qBlue(rgb)*alphaF, qAlpha(rgb)*alphaF);
15767 for (
int i=0; i<n; ++i)
15772 if (alpha[dataIndexFactor*i] == 255)
15778 const float alphaF = alpha[dataIndexFactor*i]/255.0f;
15779 scanLine[i] = qRgba(qRed(rgb)*alphaF, qGreen(rgb)*alphaF, qBlue(rgb)*alphaF, qAlpha(rgb)*alphaF);
15784 for (
int i=0; i<n; ++i)
15791 if (alpha[dataIndexFactor*i] == 255)
15797 const float alphaF = alpha[dataIndexFactor*i]/255.0f;
15798 scanLine[i] = qRgba(qRed(rgb)*alphaF, qGreen(rgb)*alphaF, qBlue(rgb)*alphaF, qAlpha(rgb)*alphaF);
15974 for (QMap<double, QColor>::const_iterator it=
mColorStops.constBegin(); it!=
mColorStops.constEnd(); ++it)
15986 for (QMap<double, QColor>::const_iterator it=
mColorStops.constBegin(); it!=
mColorStops.constEnd(); ++it)
15988 if (it.value().alpha() < 255)
16005 double indexToPosFactor = 1.0/(double)(
mLevelCount-1);
16009 double position = i*indexToPosFactor;
16010 QMap<double, QColor>::const_iterator it =
mColorStops.lowerBound(position);
16019 QMap<double, QColor>::const_iterator high = it;
16020 QMap<double, QColor>::const_iterator low = it-1;
16021 double t = (position-low.key())/(high.key()-low.key());
16028 const int alpha = (1-t)*low.value().alpha() + t*high.value().alpha();
16029 const float alphaPremultiplier = alpha/255.0f;
16030 mColorBuffer[i] = qRgba(((1-t)*low.value().red() + t*high.value().red())*alphaPremultiplier,
16031 ((1-t)*low.value().green() + t*high.value().green())*alphaPremultiplier,
16032 ((1-t)*low.value().blue() + t*high.value().blue())*alphaPremultiplier,
16036 mColorBuffer[i] = qRgb(((1-t)*low.value().red() + t*high.value().red()),
16037 ((1-t)*low.value().green() + t*high.value().green()),
16038 ((1-t)*low.value().blue() + t*high.value().blue()));
16044 QColor lowHsv = low.value().toHsv();
16045 QColor highHsv = high.value().toHsv();
16047 double hueDiff = highHsv.hueF()-lowHsv.hueF();
16049 hue = lowHsv.hueF() - t*(1.0-hueDiff);
16050 else if (hueDiff < -0.5)
16051 hue = lowHsv.hueF() + t*(1.0+hueDiff);
16053 hue = lowHsv.hueF() + t*hueDiff;
16054 if (hue < 0) hue += 1.0;
16055 else if (hue >= 1.0) hue -= 1.0;
16058 const QRgb rgb = QColor::fromHsvF(hue,
16059 (1-t)*lowHsv.saturationF() + t*highHsv.saturationF(),
16060 (1-t)*lowHsv.valueF() + t*highHsv.valueF()).rgb();
16061 const float alpha = (1-t)*lowHsv.alphaF() + t*highHsv.alphaF();
16062 mColorBuffer[i] = qRgba(qRed(rgb)*alpha, qGreen(rgb)*alpha, qBlue(rgb)*alpha, 255*alpha);
16067 (1-t)*lowHsv.saturationF() + t*highHsv.saturationF(),
16068 (1-t)*lowHsv.valueF() + t*highHsv.valueF()).rgb();
16077 const QRgb rgb =
mColorStops.constBegin().value().rgb();
16078 const float alpha =
mColorStops.constBegin().value().alphaF();
16079 mColorBuffer.fill(qRgba(qRed(rgb)*alpha, qGreen(rgb)*alpha, qBlue(rgb)*alpha, 255*alpha));
16116 mBracketPen(QPen(Qt::black)),
16117 mBracketBrush(Qt::NoBrush),
16119 mBracketHeight(50),
16120 mBracketStyle(bsSquareBracket),
16121 mTangentToData(false),
16248 qDebug() << Q_FUNC_INFO <<
"unknown/custom bracket style can't be handeld by default implementation:" <<
static_cast<int>(
mBracketStyle);
16272 int closeBracketDir = -openBracketDir;
16275 double openBracketAngle = 0;
16276 double closeBracketAngle = 0;
16280 closeBracketAngle =
getTangentAngle(interface1d, dataRange.
end()-1, closeBracketDir);
16283 QTransform oldTransform = painter->transform();
16286 painter->translate(openBracketPos);
16287 painter->rotate(openBracketAngle/M_PI*180.0);
16289 painter->setTransform(oldTransform);
16293 painter->translate(closeBracketPos);
16294 painter->rotate(closeBracketAngle/M_PI*180.0);
16296 painter->setTransform(oldTransform);
16316 if (!interface1d || dataIndex < 0 || dataIndex >= interface1d->
dataCount())
16318 direction = direction < 0 ? -1 : 1;
16326 qDebug() << averageCount;
16328 QVector<QPointF> points(averageCount);
16329 QPointF pointsAverage;
16330 int currentIndex = dataIndex;
16331 for (
int i=0; i<averageCount; ++i)
16334 pointsAverage += points[i];
16335 currentIndex += direction;
16337 pointsAverage /= (double)averageCount;
16341 double denomSum = 0;
16342 for (
int i=0; i<averageCount; ++i)
16344 const double dx = points.at(i).x()-pointsAverage.x();
16345 const double dy = points.at(i).y()-pointsAverage.y();
16349 if (!qFuzzyIsNull(denomSum) && !qFuzzyIsNull(numSum))
16351 return qAtan2(numSum, denomSum);
16365 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPointF(0, 0); }
16510 mBackgroundBrush(Qt::NoBrush),
16511 mBackgroundScaled(true),
16512 mBackgroundScaledMode(Qt::KeepAspectRatioByExpanding),
16514 mRangeDrag(Qt::Horizontal|Qt::Vertical),
16515 mRangeZoom(Qt::Horizontal|Qt::Vertical),
16516 mRangeZoomFactorHorz(0.85),
16517 mRangeZoomFactorVert(0.85),
16531 if (setupDefaultAxes)
16557 QList<QCPAxis*> axesList =
axes();
16558 for (
int i=0; i<axesList.size(); ++i)
16569 return mAxes.value(type).size();
16579 QList<QCPAxis*> ax(
mAxes.value(type));
16580 if (index >= 0 && index < ax.size())
16582 return ax.at(index);
16585 qDebug() << Q_FUNC_INFO <<
"Axis index out of bounds:" << index;
16600 QList<QCPAxis*> result;
16618 QList<QCPAxis*> result;
16619 QHashIterator<QCPAxis::AxisType, QList<QCPAxis*> > it(
mAxes);
16620 while (it.hasNext())
16623 result << it.value();
16653 newAxis =
new QCPAxis(
this, type);
16658 qDebug() << Q_FUNC_INFO <<
"passed axis has different axis type than specified in type parameter";
16663 qDebug() << Q_FUNC_INFO <<
"passed axis doesn't have this axis rect as parent axis rect";
16666 if (
axes().contains(newAxis))
16668 qDebug() << Q_FUNC_INFO <<
"passed axis is already owned by this axis rect";
16678 mAxes[type].append(newAxis);
16705 QList<QCPAxis*> result;
16727 QHashIterator<QCPAxis::AxisType, QList<QCPAxis*> > it(
mAxes);
16728 while (it.hasNext())
16731 if (it.value().contains(axis))
16733 mAxes[it.key()].removeOne(axis);
16734 if (qobject_cast<QCustomPlot*>(
parentPlot()))
16740 qDebug() << Q_FUNC_INFO <<
"Axis isn't in axis rect:" <<
reinterpret_cast<quintptr
>(
axis);
16771 qDebug() << Q_FUNC_INFO <<
"a passed axis was zero";
16776 pixelRange =
QCPRange(pixelRect.left(), pixelRect.right());
16778 pixelRange =
QCPRange(pixelRect.top(), pixelRect.bottom());
16804 QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2;
16838 xAxis2->
ticker()->setTickCount(xAxis->
ticker()->tickCount());
16839 xAxis2->
ticker()->setTickOrigin(xAxis->
ticker()->tickOrigin());
16847 yAxis2->
ticker()->setTickCount(yAxis->
ticker()->tickCount());
16848 yAxis2->
ticker()->setTickOrigin(yAxis->
ticker()->tickOrigin());
16852 connect(xAxis, SIGNAL(rangeChanged(
QCPRange)), xAxis2, SLOT(setRange(
QCPRange)));
16853 connect(yAxis, SIGNAL(rangeChanged(
QCPRange)), yAxis2, SLOT(setRange(
QCPRange)));
16868 QList<QCPAbstractPlottable*> result;
16888 QList<QCPGraph*> result;
16911 QList<QCPAbstractItem*> result;
16919 QList<QCPItemPosition*> positions =
mParentPlot->
mItems.at(itemId)->positions();
16920 for (
int posId=0; posId<positions.size(); ++posId)
16922 if (positions.at(posId)->axisRect() ==
this ||
16923 positions.at(posId)->keyAxis()->axisRect() ==
this ||
16924 positions.at(posId)->valueAxis()->axisRect() ==
this)
16952 QList<QCPAxis*> allAxes =
axes();
16953 for (
int i=0; i<allAxes.size(); ++i)
16954 allAxes.at(i)->setupTickVectors();
16972 QList<QCPLayoutElement*> result;
16977 result << mInsetLayout->
elements(recursive);
17081 if (orientation == Qt::Horizontal)
17095 if (orientation == Qt::Horizontal)
17108 QList<QCPAxis*> result;
17109 if (orientation == Qt::Horizontal)
17134 QList<QCPAxis*> result;
17135 if (orientation == Qt::Horizontal)
17216 QList<QCPAxis*> horz, vert;
17218 horz.append(horizontal);
17220 vert.append(vertical);
17235 QList<QCPAxis*> horz, vert;
17255 foreach (
QCPAxis *ax, horizontal)
17257 QPointer<QCPAxis> axPointer(ax);
17258 if (!axPointer.isNull())
17261 qDebug() << Q_FUNC_INFO <<
"invalid axis passed in horizontal list:" <<
reinterpret_cast<quintptr
>(ax);
17264 foreach (
QCPAxis *ax, vertical)
17266 QPointer<QCPAxis> axPointer(ax);
17267 if (!axPointer.isNull())
17270 qDebug() << Q_FUNC_INFO <<
"invalid axis passed in vertical list:" <<
reinterpret_cast<quintptr
>(ax);
17288 QList<QCPAxis*> horz, vert;
17290 horz.append(horizontal);
17292 vert.append(vertical);
17307 QList<QCPAxis*> horz, vert;
17327 foreach (
QCPAxis *ax, horizontal)
17329 QPointer<QCPAxis> axPointer(ax);
17330 if (!axPointer.isNull())
17333 qDebug() << Q_FUNC_INFO <<
"invalid axis passed in horizontal list:" <<
reinterpret_cast<quintptr
>(ax);
17336 foreach (
QCPAxis *ax, vertical)
17338 QPointer<QCPAxis> axPointer(ax);
17339 if (!axPointer.isNull())
17342 qDebug() << Q_FUNC_INFO <<
"invalid axis passed in vertical list:" <<
reinterpret_cast<quintptr
>(ax);
17426 const QList<QCPAxis*> axesList =
mAxes.value(type);
17427 if (axesList.isEmpty())
17430 bool isFirstVisible = !axesList.first()->visible();
17431 for (
int i=1; i<axesList.size(); ++i)
17433 int offset = axesList.at(i-1)->offset() + axesList.at(i-1)->calculateMargin();
17434 if (axesList.at(i)->visible())
17436 if (!isFirstVisible)
17437 offset += axesList.at(i)->tickLengthIn();
17438 isFirstVisible =
false;
17440 axesList.at(i)->setOffset(offset);
17448 qDebug() << Q_FUNC_INFO <<
"Called with side that isn't specified as auto margin";
17454 if (axesList.size() > 0)
17455 return axesList.last()->offset() + axesList.last()->calculateMargin();
17500 if (event->buttons() & Qt::LeftButton)
17623 double wheelSteps =
event->delta()/120.0;
17696 mParentLegend(parent),
17697 mFont(parent->font()),
17698 mTextColor(parent->textColor()),
17699 mSelectedFont(parent->selectedFont()),
17700 mSelectedTextColor(parent->selectedTextColor()),
17704 setLayer(QLatin1String(
"legend"));
17789 if (
mRect.contains(pos.toPoint()))
17816 if (selectionStateChanged)
17817 *selectionStateChanged =
mSelected != selBefore;
17828 if (selectionStateChanged)
17829 *selectionStateChanged =
mSelected != selBefore;
17872 mPlottable(plottable)
17919 QRectF textRect = painter->fontMetrics().boundingRect(0, 0, 0, iconSize.height(), Qt::TextDontClip,
mPlottable->
name());
17920 QRectF iconRect(
mRect.topLeft(), iconSize);
17921 int textHeight = qMax(textRect.height(), iconSize.height());
17925 painter->setClipRect(iconRect, Qt::IntersectClip);
17932 painter->setBrush(Qt::NoBrush);
17933 int halfPen = qCeil(painter->pen().widthF()*0.5)+1;
17934 painter->setClipRect(
mOuterRect.adjusted(-halfPen, -halfPen, halfPen, halfPen));
17935 painter->drawRect(iconRect);
17949 QSize result(0, 0);
17951 QFontMetrics fontMetrics(
getFont());
17953 textRect = fontMetrics.boundingRect(0, 0, 0, iconSize.height(), Qt::TextDontClip,
mPlottable->
name());
17955 result.setHeight(qMax(textRect.height(), iconSize.height()) +
mMargins.top() +
mMargins.bottom());
18017 setColumnSpacing(8);
18020 setIconSize(32, 18);
18022 setIconTextPadding(7);
18024 setSelectableParts(spLegendBox | spItems);
18025 setSelectedParts(spNone);
18027 setBorderPen(QPen(Qt::black, 0));
18028 setSelectedBorderPen(QPen(Qt::blue, 2));
18029 setIconBorderPen(Qt::NoPen);
18030 setSelectedIconBorderPen(QPen(Qt::blue, 2));
18031 setBrush(Qt::white);
18032 setSelectedBrush(Qt::white);
18048 bool hasSelectedItems =
false;
18049 for (
int i=0; i<itemCount(); ++i)
18051 if (item(i) && item(i)->selected())
18053 hasSelectedItems =
true;
18057 if (hasSelectedItems)
18058 return mSelectedParts | spItems;
18060 return mSelectedParts & ~spItems;
18091 for (
int i=0; i<itemCount(); ++i)
18094 item(i)->setFont(
mFont);
18110 for (
int i=0; i<itemCount(); ++i)
18113 item(i)->setTextColor(color);
18130 mIconSize.setWidth(width);
18131 mIconSize.setHeight(height);
18141 mIconTextPadding = padding;
18152 mIconBorderPen = pen;
18167 if (mSelectableParts != selectable)
18197 SelectableParts newSelected =
selected;
18198 mSelectedParts = this->selectedParts();
18200 if (mSelectedParts != newSelected)
18202 if (!mSelectedParts.testFlag(spItems) && newSelected.testFlag(spItems))
18204 qDebug() << Q_FUNC_INFO <<
"spItems flag can not be set, it can only be unset with this function";
18205 newSelected &= ~spItems;
18207 if (mSelectedParts.testFlag(spItems) && !newSelected.testFlag(spItems))
18209 for (
int i=0; i<itemCount(); ++i)
18212 item(i)->setSelected(
false);
18215 mSelectedParts = newSelected;
18228 mSelectedBorderPen = pen;
18238 mSelectedIconBorderPen = pen;
18249 mSelectedBrush = brush;
18262 for (
int i=0; i<itemCount(); ++i)
18265 item(i)->setSelectedFont(font);
18279 for (
int i=0; i<itemCount(); ++i)
18282 item(i)->setSelectedTextColor(color);
18306 for (
int i=0; i<itemCount(); ++i)
18327 return elementCount();
18337 for (
int i=0; i<itemCount(); ++i)
18339 if (item == this->item(i))
18353 return itemWithPlottable(plottable);
18368 return addElement(item);
18388 bool success =
remove(ali);
18390 setFillOrder(fillOrder(),
true);
18410 bool success =
remove(item);
18412 setFillOrder(fillOrder(),
true);
18421 for (
int i=itemCount()-1; i>=0; --i)
18433 QList<QCPAbstractLegendItem*> result;
18434 for (
int i=0; i<itemCount(); ++i)
18438 if (ali->selected())
18439 result.append(ali);
18472 return mSelectedParts.testFlag(spLegendBox) ? mSelectedBorderPen : mBorderPen;
18482 return mSelectedParts.testFlag(spLegendBox) ? mSelectedBrush : mBrush;
18493 painter->setBrush(getBrush());
18494 painter->
setPen(getBorderPen());
18502 if (onlySelectable && !mSelectableParts.testFlag(spLegendBox))
18507 if (details) details->setValue(spLegendBox);
18517 mSelectedParts = selectedParts();
18518 if (details.value<
SelectablePart>() == spLegendBox && mSelectableParts.testFlag(spLegendBox))
18520 SelectableParts selBefore = mSelectedParts;
18521 setSelectedParts(additive ? mSelectedParts^spLegendBox : mSelectedParts|spLegendBox);
18522 if (selectionStateChanged)
18523 *selectionStateChanged = mSelectedParts != selBefore;
18530 mSelectedParts = selectedParts();
18531 if (mSelectableParts.testFlag(spLegendBox))
18533 SelectableParts selBefore = mSelectedParts;
18534 setSelectedParts(selectedParts() & ~spLegendBox);
18535 if (selectionStateChanged)
18536 *selectionStateChanged = mSelectedParts != selBefore;
18555 if (parentPlot && !parentPlot->
legend)
18556 parentPlot->
legend =
this;
18612 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
18613 mFont(QFont(QLatin1String(
"sans serif"), 12)),
18622 mFont = parentPlot->font();
18637 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
18638 mFont(QFont(QLatin1String(
"sans serif"), 12)),
18647 mFont = parentPlot->font();
18662 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
18663 mFont(QFont(QLatin1String(
"sans serif"), pointSize)),
18665 mSelectedFont(QFont(QLatin1String(
"sans serif"), pointSize)),
18672 mFont = parentPlot->font();
18673 mFont.setPointSizeF(pointSize);
18689 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
18690 mFont(QFont(fontFamily, pointSize)),
18709 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
18843 QFontMetrics metrics(
mFont);
18844 QSize result = metrics.boundingRect(0, 0, 0, 0, Qt::AlignCenter,
mText).size();
18853 QFontMetrics metrics(
mFont);
18854 QSize result = metrics.boundingRect(0, 0, 0, 0, Qt::AlignCenter,
mText).size();
18856 result.setWidth(QWIDGETSIZE_MAX);
18869 if (selectionStateChanged)
18870 *selectionStateChanged =
mSelected != selBefore;
18881 if (selectionStateChanged)
18882 *selectionStateChanged =
mSelected != selBefore;
18928 if ((QPointF(event->pos())-startPos).manhattanLength() <= 3)
19058 mDataScaleType(
QCPAxis::stLinear),
19077 qDebug() << Q_FUNC_INFO <<
"internal color axis undefined";
19089 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19103 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19123 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19130 QString labelTransfer;
19131 QSharedPointer<QCPAxisTicker> tickerTransfer;
19138 tickerTransfer =
mColorAxis.data()->ticker();
19156 mColorAxis.data()->setTicker(tickerTransfer);
19220 mAxisRect.data()->mGradientImageInvalidated =
true;
19233 qDebug() << Q_FUNC_INFO <<
"internal color axis undefined";
19259 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19279 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19294 QList<QCPColorMap*> result;
19298 if (cm->colorScale() ==
this)
19312 QList<QCPColorMap*> maps =
colorMaps();
19314 bool haveRange =
false;
19318 for (
int i=0; i<maps.size(); ++i)
19320 if (!maps.at(i)->realVisibility() && onlyVisibleMaps)
19323 if (maps.at(i)->colorScale() ==
this)
19325 bool currentFoundRange =
true;
19326 mapRange = maps.at(i)->data()->dataBounds();
19329 if (mapRange.
lower <= 0 && mapRange.
upper > 0)
19331 else if (mapRange.
lower <= 0 && mapRange.
upper <= 0)
19332 currentFoundRange =
false;
19335 if (mapRange.
upper >= 0 && mapRange.
lower < 0)
19337 else if (mapRange.
upper >= 0 && mapRange.
lower >= 0)
19338 currentFoundRange =
false;
19340 if (currentFoundRange)
19343 newRange = mapRange;
19345 newRange.
expand(mapRange);
19354 double center = (newRange.
lower+newRange.
upper)*0.5;
19375 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19416 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19419 mAxisRect.data()->mousePressEvent(event, details);
19427 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19430 mAxisRect.data()->mouseMoveEvent(event, startPos);
19438 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19441 mAxisRect.data()->mouseReleaseEvent(event, startPos);
19449 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19475 mParentColorScale(parentColorScale),
19476 mGradientImageInvalidated(true)
19486 connect(
axis(type), SIGNAL(selectionChanged(QCPAxis::SelectableParts)),
this, SLOT(
axisSelectionChanged(QCPAxis::SelectableParts)));
19487 connect(
axis(type), SIGNAL(selectableChanged(QCPAxis::SelectableParts)),
this, SLOT(
axisSelectableChanged(QCPAxis::SelectableParts)));
19518 bool mirrorHorz =
false;
19519 bool mirrorVert =
false;
19526 painter->drawImage(
rect().adjusted(0, -1, 0, -1),
mGradientImage.mirrored(mirrorHorz, mirrorVert));
19537 if (
rect().isEmpty())
19540 const QImage::Format format = QImage::Format_ARGB32_Premultiplied;
19543 QVector<double> data(n);
19544 for (
int i=0; i<n; ++i)
19549 h =
rect().height();
19551 QVector<QRgb*> pixels;
19552 for (
int y=0; y<h; ++y)
19553 pixels.append(reinterpret_cast<QRgb*>(
mGradientImage.scanLine(y)));
19555 for (
int y=1; y<h; ++y)
19556 memcpy(pixels.at(y), pixels.first(), n*
sizeof(QRgb));
19559 w =
rect().width();
19562 for (
int y=0; y<h; ++y)
19564 QRgb *pixels =
reinterpret_cast<QRgb*
>(
mGradientImage.scanLine(y));
19566 for (
int x=0; x<w; ++x)
19567 pixels[x] = lineColor;
19584 if (
QCPAxis *senderAxis = qobject_cast<QCPAxis*>(sender()))
19585 if (senderAxis->axisType() == type)
19609 if (
QCPAxis *senderAxis = qobject_cast<QCPAxis*>(sender()))
19610 if (senderAxis->axisType() == type)
19789 setPen(QPen(Qt::blue, 0));
19836 addData(keys, values, alreadySorted);
19889 if (targetGraph ==
this)
19891 qDebug() << Q_FUNC_INFO <<
"targetGraph is this graph itself";
19898 qDebug() << Q_FUNC_INFO <<
"targetGraph not in same plot";
19956 if (keys.size() != values.size())
19957 qDebug() << Q_FUNC_INFO <<
"keys and values have different sizes:" << keys.size() << values.size();
19958 const int n = qMin(keys.size(), values.size());
19959 QVector<QCPGraphData> tempData(n);
19960 QVector<QCPGraphData>::iterator it = tempData.begin();
19961 const QVector<QCPGraphData>::iterator itEnd = tempData.end();
19963 while (it != itEnd)
19966 it->value = values[i];
19993 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
20016 return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange);
20022 if (!
mKeyAxis || !
mValueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
20026 QVector<QPointF> lines, scatters;
20029 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
20031 allSegments << unselectedSegments << selectedSegments;
20032 for (
int i=0; i<allSegments.size(); ++i)
20034 bool isSelectedSegment = i >= unselectedSegments.size();
20036 QCPDataRange lineDataRange = isSelectedSegment ? allSegments.at(i) : allSegments.at(i).
adjusted(-1, 1);
20040 #ifdef QCUSTOMPLOT_CHECK_DATA 20045 qDebug() << Q_FUNC_INFO <<
"Data point at" << it->key <<
"invalid." <<
"Plottable name:" <<
name();
20053 painter->setBrush(
mBrush);
20054 painter->
setPen(Qt::NoPen);
20064 painter->setBrush(Qt::NoBrush);
20075 if (!finalScatterStyle.
isNone())
20091 if (
mBrush.style() != Qt::NoBrush)
20094 painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0),
mBrush);
20101 painter->
drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0));
20111 scaledStyle.
setPixmap(scaledStyle.
pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
20113 scaledStyle.
drawShape(painter, QRectF(rect).center());
20144 if (!lines)
return;
20153 QVector<QCPGraphData> lineData;
20159 case lsNone: lines->clear();
break;
20182 if (!scatters)
return;
20185 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis"; scatters->clear();
return; }
20195 QVector<QCPGraphData>
data;
20197 scatters->resize(data.size());
20200 for (
int i=0; i<data.size(); ++i)
20202 if (!qIsNaN(data.at(i).value))
20204 (*scatters)[i].setX(valueAxis->
coordToPixel(data.at(i).value));
20205 (*scatters)[i].setY(keyAxis->
coordToPixel(data.at(i).key));
20210 for (
int i=0; i<data.size(); ++i)
20212 if (!qIsNaN(data.at(i).value))
20214 (*scatters)[i].setX(keyAxis->
coordToPixel(data.at(i).key));
20215 (*scatters)[i].setY(valueAxis->
coordToPixel(data.at(i).value));
20233 QVector<QPointF> result;
20236 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20238 result.reserve(data.size()+2);
20239 result.resize(data.size());
20244 for (
int i=0; i<data.size(); ++i)
20246 result[i].setX(valueAxis->
coordToPixel(data.at(i).value));
20247 result[i].setY(keyAxis->
coordToPixel(data.at(i).key));
20251 for (
int i=0; i<data.size(); ++i)
20253 result[i].setX(keyAxis->
coordToPixel(data.at(i).key));
20254 result[i].setY(valueAxis->
coordToPixel(data.at(i).value));
20272 QVector<QPointF> result;
20275 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20277 result.reserve(data.size()*2+2);
20278 result.resize(data.size()*2);
20283 double lastValue = valueAxis->
coordToPixel(data.first().value);
20284 for (
int i=0; i<data.size(); ++i)
20286 const double key = keyAxis->
coordToPixel(data.at(i).key);
20287 result[i*2+0].setX(lastValue);
20288 result[i*2+0].setY(key);
20289 lastValue = valueAxis->
coordToPixel(data.at(i).value);
20290 result[i*2+1].setX(lastValue);
20291 result[i*2+1].setY(key);
20295 double lastValue = valueAxis->
coordToPixel(data.first().value);
20296 for (
int i=0; i<data.size(); ++i)
20298 const double key = keyAxis->
coordToPixel(data.at(i).key);
20299 result[i*2+0].setX(key);
20300 result[i*2+0].setY(lastValue);
20301 lastValue = valueAxis->
coordToPixel(data.at(i).value);
20302 result[i*2+1].setX(key);
20303 result[i*2+1].setY(lastValue);
20321 QVector<QPointF> result;
20324 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20326 result.reserve(data.size()*2+2);
20327 result.resize(data.size()*2);
20332 double lastKey = keyAxis->
coordToPixel(data.first().key);
20333 for (
int i=0; i<data.size(); ++i)
20335 const double value = valueAxis->
coordToPixel(data.at(i).value);
20336 result[i*2+0].setX(value);
20337 result[i*2+0].setY(lastKey);
20339 result[i*2+1].setX(value);
20340 result[i*2+1].setY(lastKey);
20344 double lastKey = keyAxis->
coordToPixel(data.first().key);
20345 for (
int i=0; i<data.size(); ++i)
20347 const double value = valueAxis->
coordToPixel(data.at(i).value);
20348 result[i*2+0].setX(lastKey);
20349 result[i*2+0].setY(value);
20351 result[i*2+1].setX(lastKey);
20352 result[i*2+1].setY(value);
20370 QVector<QPointF> result;
20373 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20375 result.reserve(data.size()*2+2);
20376 result.resize(data.size()*2);
20381 double lastKey = keyAxis->
coordToPixel(data.first().key);
20382 double lastValue = valueAxis->
coordToPixel(data.first().value);
20383 result[0].setX(lastValue);
20384 result[0].setY(lastKey);
20385 for (
int i=1; i<data.size(); ++i)
20387 const double key = (keyAxis->
coordToPixel(data.at(i).key)+lastKey)*0.5;
20388 result[i*2-1].setX(lastValue);
20389 result[i*2-1].setY(key);
20390 lastValue = valueAxis->
coordToPixel(data.at(i).value);
20392 result[i*2+0].setX(lastValue);
20393 result[i*2+0].setY(key);
20395 result[data.size()*2-1].setX(lastValue);
20396 result[data.size()*2-1].setY(lastKey);
20399 double lastKey = keyAxis->
coordToPixel(data.first().key);
20400 double lastValue = valueAxis->
coordToPixel(data.first().value);
20401 result[0].setX(lastKey);
20402 result[0].setY(lastValue);
20403 for (
int i=1; i<data.size(); ++i)
20405 const double key = (keyAxis->
coordToPixel(data.at(i).key)+lastKey)*0.5;
20406 result[i*2-1].setX(key);
20407 result[i*2-1].setY(lastValue);
20408 lastValue = valueAxis->
coordToPixel(data.at(i).value);
20410 result[i*2+0].setX(key);
20411 result[i*2+0].setY(lastValue);
20413 result[data.size()*2-1].setX(lastKey);
20414 result[data.size()*2-1].setY(lastValue);
20431 QVector<QPointF> result;
20434 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20436 result.resize(data.size()*2);
20441 for (
int i=0; i<data.size(); ++i)
20443 const double key = keyAxis->
coordToPixel(data.at(i).key);
20445 result[i*2+0].setY(key);
20446 result[i*2+1].setX(valueAxis->
coordToPixel(data.at(i).value));
20447 result[i*2+1].setY(key);
20451 for (
int i=0; i<data.size(); ++i)
20453 const double key = keyAxis->
coordToPixel(data.at(i).key);
20454 result[i*2+0].setX(key);
20456 result[i*2+1].setX(key);
20457 result[i*2+1].setY(valueAxis->
coordToPixel(data.at(i).value));
20482 if (painter->brush().style() == Qt::NoBrush || painter->brush().color().alpha() == 0)
return;
20489 painter->drawPolygon(QPolygonF(*lines));
20509 for (
int i=0; i<scatters.size(); ++i)
20510 style.
drawShape(painter, scatters.at(i).x(), scatters.at(i).y());
20521 if (painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0)
20538 if (painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0)
20541 QPen oldPen = painter->pen();
20542 QPen newPen = painter->pen();
20543 newPen.setCapStyle(Qt::FlatCap);
20544 painter->
setPen(newPen);
20545 painter->drawLines(lines);
20546 painter->
setPen(oldPen);
20564 if (!lineData)
return;
20567 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
20568 if (begin == end)
return;
20571 int maxCount = std::numeric_limits<int>::max();
20575 if (2*keyPixelSpan+2 < (
double)std::numeric_limits<int>::max())
20576 maxCount = 2*keyPixelSpan+2;
20582 double minValue = it->value;
20583 double maxValue = it->value;
20586 int reversedRound = reversedFactor==-1 ? 1 : 0;
20588 double lastIntervalEndKey = currentIntervalStartKey;
20589 double keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->
pixelToCoord(keyAxis->
coordToPixel(currentIntervalStartKey)+1.0*reversedFactor));
20591 int intervalDataCount = 1;
20595 if (it->key < currentIntervalStartKey+keyEpsilon)
20597 if (it->value < minValue)
20598 minValue = it->value;
20599 else if (it->value > maxValue)
20600 maxValue = it->value;
20601 ++intervalDataCount;
20604 if (intervalDataCount >= 2)
20606 if (lastIntervalEndKey < currentIntervalStartKey-keyEpsilon)
20607 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.2, currentIntervalFirstPoint->value));
20608 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.25, minValue));
20609 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.75, maxValue));
20610 if (it->key > currentIntervalStartKey+keyEpsilon*2)
20611 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.8, (it-1)->value));
20613 lineData->append(
QCPGraphData(currentIntervalFirstPoint->key, currentIntervalFirstPoint->value));
20614 lastIntervalEndKey = (it-1)->key;
20615 minValue = it->value;
20616 maxValue = it->value;
20617 currentIntervalFirstPoint = it;
20619 if (keyEpsilonVariable)
20620 keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->
pixelToCoord(keyAxis->
coordToPixel(currentIntervalStartKey)+1.0*reversedFactor));
20621 intervalDataCount = 1;
20626 if (intervalDataCount >= 2)
20628 if (lastIntervalEndKey < currentIntervalStartKey-keyEpsilon)
20629 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.2, currentIntervalFirstPoint->value));
20630 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.25, minValue));
20631 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.75, maxValue));
20633 lineData->append(
QCPGraphData(currentIntervalFirstPoint->key, currentIntervalFirstPoint->value));
20638 lineData->reserve(dataCount+2);
20641 lineData->append(*it);
20661 if (!scatterData)
return;
20664 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
20670 while (doScatterSkip && begin != end && beginIndex % scatterModulo != 0)
20675 if (begin == end)
return;
20677 int maxCount = std::numeric_limits<int>::max();
20681 maxCount = 2*keyPixelSpan+2;
20686 double valueMaxRange = valueAxis->
range().
upper;
20687 double valueMinRange = valueAxis->
range().
lower;
20689 int itIndex = beginIndex;
20690 double minValue = it->value;
20691 double maxValue = it->value;
20696 int reversedRound = reversedFactor==-1 ? 1 : 0;
20698 double keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->
pixelToCoord(keyAxis->
coordToPixel(currentIntervalStartKey)+1.0*reversedFactor));
20700 int intervalDataCount = 1;
20702 if (!doScatterSkip)
20706 itIndex += scatterModulo;
20707 if (itIndex < endIndex)
20708 it += scatterModulo;
20712 itIndex = endIndex;
20718 if (it->key < currentIntervalStartKey+keyEpsilon)
20720 if (it->value < minValue && it->value > valueMinRange && it->value < valueMaxRange)
20722 minValue = it->value;
20724 }
else if (it->value > maxValue && it->value > valueMinRange && it->value < valueMaxRange)
20726 maxValue = it->value;
20729 ++intervalDataCount;
20732 if (intervalDataCount >= 2)
20736 int dataModulo = qMax(1, qRound(intervalDataCount/(valuePixelSpan/4.0)));
20739 while (intervalIt != it)
20741 if ((c % dataModulo == 0 || intervalIt == minValueIt || intervalIt == maxValueIt) && intervalIt->value > valueMinRange && intervalIt->value < valueMaxRange)
20742 scatterData->append(*intervalIt);
20744 if (!doScatterSkip)
20747 intervalIt += scatterModulo;
20749 }
else if (currentIntervalStart->value > valueMinRange && currentIntervalStart->value < valueMaxRange)
20750 scatterData->append(*currentIntervalStart);
20751 minValue = it->value;
20752 maxValue = it->value;
20753 currentIntervalStart = it;
20755 if (keyEpsilonVariable)
20756 keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->
pixelToCoord(keyAxis->
coordToPixel(currentIntervalStartKey)+1.0*reversedFactor));
20757 intervalDataCount = 1;
20760 if (!doScatterSkip)
20764 itIndex += scatterModulo;
20765 if (itIndex < endIndex)
20766 it += scatterModulo;
20770 itIndex = endIndex;
20775 if (intervalDataCount >= 2)
20779 int dataModulo = qMax(1, qRound(intervalDataCount/(valuePixelSpan/4.0)));
20783 while (intervalIt != it)
20785 if ((c % dataModulo == 0 || intervalIt == minValueIt || intervalIt == maxValueIt) && intervalIt->value > valueMinRange && intervalIt->value < valueMaxRange)
20786 scatterData->append(*intervalIt);
20788 if (!doScatterSkip)
20792 intervalItIndex += scatterModulo;
20793 if (intervalItIndex < itIndex)
20794 intervalIt += scatterModulo;
20798 intervalItIndex = itIndex;
20802 }
else if (currentIntervalStart->value > valueMinRange && currentIntervalStart->value < valueMaxRange)
20803 scatterData->append(*currentIntervalStart);
20808 int itIndex = beginIndex;
20809 scatterData->reserve(dataCount);
20812 scatterData->append(*it);
20814 if (!doScatterSkip)
20818 itIndex += scatterModulo;
20819 if (itIndex < endIndex)
20820 it += scatterModulo;
20824 itIndex = endIndex;
20842 if (rangeRestriction.
isEmpty())
20850 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
20855 mDataContainer->limitIteratorsToDataRange(begin, end, rangeRestriction);
20876 if (!
mKeyAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key axis";
return; }
20877 if (!lines) { qDebug() << Q_FUNC_INFO <<
"passed null as lineData";
return; }
20878 if (lines->isEmpty())
return;
20881 if (
mKeyAxis.data()->orientation() == Qt::Vertical)
20900 if (!lines) { qDebug() << Q_FUNC_INFO <<
"passed null as lineData";
return; }
20901 if (lines->isEmpty())
return;
20903 lines->remove(lines->size()-2, 2);
20924 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPointF(); }
20932 point.setY(lowerKey);
20936 point.setY(lowerKey);
20939 point.setX(lowerKey);
20943 point.setX(lowerKey);
20957 point.setY(lowerKey);
20960 point.setX(lowerKey);
20989 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPointF(); }
20997 point.setY(upperKey);
21001 point.setY(upperKey);
21004 point.setX(upperKey);
21008 point.setX(upperKey);
21022 point.setY(upperKey);
21025 point.setX(upperKey);
21051 return QPolygonF();
21055 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPolygonF(); }
21056 if (!
mChannelFillGraph.data()->mKeyAxis) { qDebug() << Q_FUNC_INFO <<
"channel fill target key axis invalid";
return QPolygonF(); }
21059 return QPolygonF();
21061 if (lines->isEmpty())
return QPolygonF();
21062 QVector<QPointF> otherData;
21064 if (otherData.isEmpty())
return QPolygonF();
21065 QVector<QPointF> thisData;
21066 thisData.reserve(lines->size()+otherData.size());
21067 for (
int i=0; i<lines->size(); ++i)
21068 thisData << lines->at(i);
21071 QVector<QPointF> *staticData = &thisData;
21072 QVector<QPointF> *croppedData = &otherData;
21079 if (staticData->first().x() > staticData->last().x())
21081 int size = staticData->size();
21082 for (
int i=0; i<size/2; ++i)
21083 qSwap((*staticData)[i], (*staticData)[size-1-i]);
21085 if (croppedData->first().x() > croppedData->last().x())
21087 int size = croppedData->size();
21088 for (
int i=0; i<size/2; ++i)
21089 qSwap((*croppedData)[i], (*croppedData)[size-1-i]);
21092 if (staticData->first().x() < croppedData->first().x())
21093 qSwap(staticData, croppedData);
21094 int lowBound =
findIndexBelowX(croppedData, staticData->first().x());
21095 if (lowBound == -1)
return QPolygonF();
21096 croppedData->remove(0, lowBound);
21099 if (croppedData->size() < 2)
return QPolygonF();
21101 if (croppedData->at(1).x()-croppedData->at(0).x() != 0)
21102 slope = (croppedData->at(1).y()-croppedData->at(0).y())/(croppedData->at(1).x()-croppedData->at(0).x());
21105 (*croppedData)[0].setY(croppedData->at(0).y()+slope*(staticData->first().x()-croppedData->at(0).x()));
21106 (*croppedData)[0].setX(staticData->first().x());
21109 if (staticData->last().x() > croppedData->last().x())
21110 qSwap(staticData, croppedData);
21111 int highBound =
findIndexAboveX(croppedData, staticData->last().x());
21112 if (highBound == -1)
return QPolygonF();
21113 croppedData->remove(highBound+1, croppedData->size()-(highBound+1));
21116 if (croppedData->size() < 2)
return QPolygonF();
21117 int li = croppedData->size()-1;
21118 if (croppedData->at(li).x()-croppedData->at(li-1).x() != 0)
21119 slope = (croppedData->at(li).y()-croppedData->at(li-1).y())/(croppedData->at(li).x()-croppedData->at(li-1).x());
21122 (*croppedData)[li].setY(croppedData->at(li-1).y()+slope*(staticData->last().x()-croppedData->at(li-1).x()));
21123 (*croppedData)[li].setX(staticData->last().x());
21130 if (staticData->first().y() < staticData->last().y())
21132 int size = staticData->size();
21133 for (
int i=0; i<size/2; ++i)
21134 qSwap((*staticData)[i], (*staticData)[size-1-i]);
21136 if (croppedData->first().y() < croppedData->last().y())
21138 int size = croppedData->size();
21139 for (
int i=0; i<size/2; ++i)
21140 qSwap((*croppedData)[i], (*croppedData)[size-1-i]);
21143 if (staticData->first().y() > croppedData->first().y())
21144 qSwap(staticData, croppedData);
21145 int lowBound =
findIndexAboveY(croppedData, staticData->first().y());
21146 if (lowBound == -1)
return QPolygonF();
21147 croppedData->remove(0, lowBound);
21150 if (croppedData->size() < 2)
return QPolygonF();
21152 if (croppedData->at(1).y()-croppedData->at(0).y() != 0)
21153 slope = (croppedData->at(1).x()-croppedData->at(0).x())/(croppedData->at(1).y()-croppedData->at(0).y());
21156 (*croppedData)[0].setX(croppedData->at(0).x()+slope*(staticData->first().y()-croppedData->at(0).y()));
21157 (*croppedData)[0].setY(staticData->first().y());
21160 if (staticData->last().y() < croppedData->last().y())
21161 qSwap(staticData, croppedData);
21162 int highBound =
findIndexBelowY(croppedData, staticData->last().y());
21163 if (highBound == -1)
return QPolygonF();
21164 croppedData->remove(highBound+1, croppedData->size()-(highBound+1));
21167 if (croppedData->size() < 2)
return QPolygonF();
21168 int li = croppedData->size()-1;
21169 if (croppedData->at(li).y()-croppedData->at(li-1).y() != 0)
21170 slope = (croppedData->at(li).x()-croppedData->at(li-1).x())/(croppedData->at(li).y()-croppedData->at(li-1).y());
21173 (*croppedData)[li].setX(croppedData->at(li-1).x()+slope*(staticData->last().y()-croppedData->at(li-1).y()));
21174 (*croppedData)[li].setY(staticData->last().y());
21178 for (
int i=otherData.size()-1; i>=0; --i)
21179 thisData << otherData.at(i);
21180 return QPolygonF(thisData);
21192 for (
int i=data->size()-1; i>=0; --i)
21194 if (data->at(i).x() < x)
21196 if (i<data->
size()-1)
21199 return data->size()-1;
21214 for (
int i=0; i<data->size(); ++i)
21216 if (data->at(i).x() > x)
21236 for (
int i=0; i<data->size(); ++i)
21238 if (data->at(i).y() < y)
21269 double minDistSqr = std::numeric_limits<double>::max();
21271 double posKeyMin, posKeyMax, dummy;
21274 if (posKeyMin > posKeyMax)
21275 qSwap(posKeyMin, posKeyMax);
21282 if (currentDistSqr < minDistSqr)
21284 minDistSqr = currentDistSqr;
21293 QVector<QPointF> lineData;
21297 for (
int i=0; i<lineData.size()-1; i+=step)
21300 if (currentDistSqr < minDistSqr)
21301 minDistSqr = currentDistSqr;
21305 return qSqrt(minDistSqr);
21318 for (
int i=data->size()-1; i>=0; --i)
21320 if (data->at(i).y() > y)
21322 if (i<data->
size()-1)
21325 return data->size()-1;
21495 setPen(QPen(Qt::blue, 0));
21537 void QCPCurve::setData(
const QVector<double> &t,
const QVector<double> &keys,
const QVector<double> &values,
bool alreadySorted)
21540 addData(t, keys, values, alreadySorted);
21613 void QCPCurve::addData(
const QVector<double> &t,
const QVector<double> &keys,
const QVector<double> &values,
bool alreadySorted)
21615 if (t.size() != keys.size() || t.size() != values.size())
21616 qDebug() << Q_FUNC_INFO <<
"ts, keys and values have different sizes:" << t.size() << keys.size() << values.size();
21617 const int n = qMin(qMin(t.size(), keys.size()), values.size());
21618 QVector<QCPCurveData> tempData(n);
21619 QVector<QCPCurveData>::iterator it = tempData.begin();
21620 const QVector<QCPCurveData>::iterator itEnd = tempData.end();
21622 while (it != itEnd)
21626 it->value = values[i];
21647 if (keys.size() != values.size())
21648 qDebug() << Q_FUNC_INFO <<
"keys and values have different sizes:" << keys.size() << values.size();
21649 const int n = qMin(keys.size(), values.size());
21655 QVector<QCPCurveData> tempData(n);
21656 QVector<QCPCurveData>::iterator it = tempData.begin();
21657 const QVector<QCPCurveData>::iterator itEnd = tempData.end();
21659 while (it != itEnd)
21661 it->t = tStart + i;
21663 it->value = values[i];
21707 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
21730 return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange);
21739 QVector<QPointF> lines, scatters;
21742 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
21744 allSegments << unselectedSegments << selectedSegments;
21745 for (
int i=0; i<allSegments.size(); ++i)
21747 bool isSelectedSegment = i >= unselectedSegments.size();
21750 QPen finalCurvePen =
mPen;
21754 QCPDataRange lineDataRange = isSelectedSegment ? allSegments.at(i) : allSegments.at(i).
adjusted(-1, 1);
21755 getCurveLines(&lines, lineDataRange, finalCurvePen.widthF());
21758 #ifdef QCUSTOMPLOT_CHECK_DATA 21763 qDebug() << Q_FUNC_INFO <<
"Data point at" << it->key <<
"invalid." <<
"Plottable name:" <<
name();
21772 painter->setBrush(
mBrush);
21773 painter->
setPen(Qt::NoPen);
21774 if (painter->brush().style() != Qt::NoBrush && painter->brush().color().alpha() != 0)
21775 painter->drawPolygon(QPolygonF(lines));
21780 painter->
setPen(finalCurvePen);
21781 painter->setBrush(Qt::NoBrush);
21789 if (!finalScatterStyle.
isNone())
21805 if (
mBrush.style() != Qt::NoBrush)
21808 painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0),
mBrush);
21815 painter->
drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0));
21825 scaledStyle.
setPixmap(scaledStyle.
pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
21827 scaledStyle.
drawShape(painter, QRectF(rect).center());
21844 if (painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0)
21863 for (
int i=0; i<points.size(); ++i)
21864 if (!qIsNaN(points.at(i).x()) && !qIsNaN(points.at(i).y()))
21865 style.
drawShape(painter, points.at(i));
21898 if (!lines)
return;
21902 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
21905 const double strokeMargin = qMax(qreal(1.0), qreal(penWidth*0.75));
21912 mDataContainer->limitIteratorsToDataRange(itBegin, itEnd, dataRange);
21913 if (itBegin == itEnd)
21917 int prevRegion =
getRegion(prevIt->key, prevIt->value, keyMin, valueMax, keyMax, valueMin);
21918 QVector<QPointF> trailingPoints;
21919 while (it != itEnd)
21921 const int currentRegion =
getRegion(it->key, it->value, keyMin, valueMax, keyMax, valueMin);
21922 if (currentRegion != prevRegion)
21924 if (currentRegion != 5)
21926 QPointF crossA, crossB;
21927 if (prevRegion == 5)
21929 lines->append(
getOptimizedPoint(currentRegion, it->key, it->value, prevIt->key, prevIt->value, keyMin, valueMax, keyMax, valueMin));
21931 *lines <<
getOptimizedCornerPoints(prevRegion, currentRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin);
21932 }
else if (
mayTraverse(prevRegion, currentRegion) &&
21933 getTraverse(prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin, crossA, crossB))
21936 QVector<QPointF> beforeTraverseCornerPoints, afterTraverseCornerPoints;
21937 getTraverseCornerPoints(prevRegion, currentRegion, keyMin, valueMax, keyMax, valueMin, beforeTraverseCornerPoints, afterTraverseCornerPoints);
21940 *lines << beforeTraverseCornerPoints;
21941 lines->append(crossA);
21942 lines->append(crossB);
21943 *lines << afterTraverseCornerPoints;
21946 lines->append(crossB);
21947 *lines << afterTraverseCornerPoints;
21948 trailingPoints << beforeTraverseCornerPoints << crossA ;
21952 *lines <<
getOptimizedCornerPoints(prevRegion, currentRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin);
21957 trailingPoints <<
getOptimizedPoint(prevRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin);
21959 lines->append(
getOptimizedPoint(prevRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin));
21964 if (currentRegion == 5)
21973 prevRegion = currentRegion;
21976 *lines << trailingPoints;
22001 if (!scatters)
return;
22005 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
22009 mDataContainer->limitIteratorsToDataRange(begin, end, dataRange);
22026 while (doScatterSkip && it != end && itIndex % scatterModulo != 0)
22035 if (!qIsNaN(it->value) && keyRange.
contains(it->key) && valueRange.
contains(it->value))
22039 if (!doScatterSkip)
22043 itIndex += scatterModulo;
22044 if (itIndex < endIndex)
22045 it += scatterModulo;
22049 itIndex = endIndex;
22057 if (!qIsNaN(it->value) && keyRange.
contains(it->key) && valueRange.
contains(it->value))
22061 if (!doScatterSkip)
22065 itIndex += scatterModulo;
22066 if (itIndex < endIndex)
22067 it += scatterModulo;
22071 itIndex = endIndex;
22097 int QCPCurve::getRegion(
double key,
double value,
double keyMin,
double valueMax,
double keyMax,
double valueMin)
const 22101 if (value > valueMax)
22103 else if (value < valueMin)
22107 }
else if (key > keyMax)
22109 if (value > valueMax)
22111 else if (value < valueMin)
22117 if (value > valueMax)
22119 else if (value < valueMin)
22141 QPointF
QCPCurve::getOptimizedPoint(
int otherRegion,
double otherKey,
double otherValue,
double key,
double value,
double keyMin,
double valueMax,
double keyMax,
double valueMin)
const 22143 double intersectKey = keyMin;
22144 double intersectValue = valueMax;
22145 switch (otherRegion)
22149 intersectValue = valueMax;
22150 intersectKey = otherKey + (key-otherKey)/(value-otherValue)*(intersectValue-otherValue);
22151 if (intersectKey < keyMin || intersectKey > keyMax)
22153 intersectKey = keyMin;
22154 intersectValue = otherValue + (value-otherValue)/(key-otherKey)*(intersectKey-otherKey);
22160 intersectKey = keyMin;
22161 intersectValue = otherValue + (value-otherValue)/(key-otherKey)*(intersectKey-otherKey);
22166 intersectValue = valueMin;
22167 intersectKey = otherKey + (key-otherKey)/(value-otherValue)*(intersectValue-otherValue);
22168 if (intersectKey < keyMin || intersectKey > keyMax)
22170 intersectKey = keyMin;
22171 intersectValue = otherValue + (value-otherValue)/(key-otherKey)*(intersectKey-otherKey);
22177 intersectValue = valueMax;
22178 intersectKey = otherKey + (key-otherKey)/(value-otherValue)*(intersectValue-otherValue);
22187 intersectValue = valueMin;
22188 intersectKey = otherKey + (key-otherKey)/(value-otherValue)*(intersectValue-otherValue);
22193 intersectValue = valueMax;
22194 intersectKey = otherKey + (key-otherKey)/(value-otherValue)*(intersectValue-otherValue);
22195 if (intersectKey < keyMin || intersectKey > keyMax)
22197 intersectKey = keyMax;
22198 intersectValue = otherValue + (value-otherValue)/(key-otherKey)*(intersectKey-otherKey);
22204 intersectKey = keyMax;
22205 intersectValue = otherValue + (value-otherValue)/(key-otherKey)*(intersectKey-otherKey);
22210 intersectValue = valueMin;
22211 intersectKey = otherKey + (key-otherKey)/(value-otherValue)*(intersectValue-otherValue);
22212 if (intersectKey < keyMin || intersectKey > keyMax)
22214 intersectKey = keyMax;
22215 intersectValue = otherValue + (value-otherValue)/(key-otherKey)*(intersectKey-otherKey);
22241 QVector<QPointF>
QCPCurve::getOptimizedCornerPoints(
int prevRegion,
int currentRegion,
double prevKey,
double prevValue,
double key,
double value,
double keyMin,
double valueMax,
double keyMax,
double valueMin)
const 22243 QVector<QPointF> result;
22244 switch (prevRegion)
22248 switch (currentRegion)
22257 if ((value-prevValue)/(key-prevKey)*(keyMin-key)+value < valueMin)
22268 switch (currentRegion)
22272 case 4: { result <<
coordsToPixels(keyMin, valueMax); result.append(result.last());
break; }
22273 case 6: { result <<
coordsToPixels(keyMin, valueMin); result.append(result.last());
break; }
22274 case 7: { result <<
coordsToPixels(keyMin, valueMax); result.append(result.last()); result <<
coordsToPixels(keyMax, valueMax);
break; }
22275 case 9: { result <<
coordsToPixels(keyMin, valueMin); result.append(result.last()); result <<
coordsToPixels(keyMax, valueMin);
break; }
22281 switch (currentRegion)
22290 if ((value-prevValue)/(key-prevKey)*(keyMax-key)+value < valueMin)
22301 switch (currentRegion)
22305 case 2: { result <<
coordsToPixels(keyMin, valueMax); result.append(result.last());
break; }
22306 case 8: { result <<
coordsToPixels(keyMax, valueMax); result.append(result.last());
break; }
22307 case 3: { result <<
coordsToPixels(keyMin, valueMax); result.append(result.last()); result <<
coordsToPixels(keyMin, valueMin);
break; }
22308 case 9: { result <<
coordsToPixels(keyMax, valueMax); result.append(result.last()); result <<
coordsToPixels(keyMax, valueMin);
break; }
22314 switch (currentRegion)
22325 switch (currentRegion)
22329 case 2: { result <<
coordsToPixels(keyMin, valueMin); result.append(result.last());
break; }
22330 case 8: { result <<
coordsToPixels(keyMax, valueMin); result.append(result.last());
break; }
22331 case 1: { result <<
coordsToPixels(keyMin, valueMin); result.append(result.last()); result <<
coordsToPixels(keyMin, valueMax);
break; }
22332 case 7: { result <<
coordsToPixels(keyMax, valueMin); result.append(result.last()); result <<
coordsToPixels(keyMax, valueMax);
break; }
22338 switch (currentRegion)
22347 if ((value-prevValue)/(key-prevKey)*(keyMax-key)+value < valueMin)
22358 switch (currentRegion)
22362 case 4: { result <<
coordsToPixels(keyMax, valueMax); result.append(result.last());
break; }
22363 case 6: { result <<
coordsToPixels(keyMax, valueMin); result.append(result.last());
break; }
22364 case 1: { result <<
coordsToPixels(keyMax, valueMax); result.append(result.last()); result <<
coordsToPixels(keyMin, valueMax);
break; }
22365 case 3: { result <<
coordsToPixels(keyMax, valueMin); result.append(result.last()); result <<
coordsToPixels(keyMin, valueMin);
break; }
22371 switch (currentRegion)
22380 if ((value-prevValue)/(key-prevKey)*(keyMin-key)+value < valueMin)
22407 switch (prevRegion)
22411 switch (currentRegion)
22416 case 3:
return false;
22417 default:
return true;
22422 switch (currentRegion)
22425 case 3:
return false;
22426 default:
return true;
22431 switch (currentRegion)
22436 case 9:
return false;
22437 default:
return true;
22442 switch (currentRegion)
22445 case 7:
return false;
22446 default:
return true;
22449 case 5:
return false;
22452 switch (currentRegion)
22455 case 9:
return false;
22456 default:
return true;
22461 switch (currentRegion)
22466 case 9:
return false;
22467 default:
return true;
22472 switch (currentRegion)
22475 case 9:
return false;
22476 default:
return true;
22481 switch (currentRegion)
22486 case 7:
return false;
22487 default:
return true;
22490 default:
return true;
22508 bool QCPCurve::getTraverse(
double prevKey,
double prevValue,
double key,
double value,
double keyMin,
double valueMax,
double keyMax,
double valueMin, QPointF &crossA, QPointF &crossB)
const 22510 QList<QPointF> intersections;
22511 if (qFuzzyIsNull(key-prevKey))
22514 intersections.append(QPointF(key, valueMin));
22515 intersections.append(QPointF(key, valueMax));
22516 }
else if (qFuzzyIsNull(value-prevValue))
22519 intersections.append(QPointF(keyMin, value));
22520 intersections.append(QPointF(keyMax, value));
22524 double keyPerValue = (key-prevKey)/(value-prevValue);
22526 gamma = prevKey + (valueMax-prevValue)*keyPerValue;
22527 if (gamma >= keyMin && gamma <= keyMax)
22528 intersections.append(QPointF(gamma, valueMax));
22530 gamma = prevKey + (valueMin-prevValue)*keyPerValue;
22531 if (gamma >= keyMin && gamma <= keyMax)
22532 intersections.append(QPointF(gamma, valueMin));
22533 double valuePerKey = 1.0/keyPerValue;
22535 gamma = prevValue + (keyMin-prevKey)*valuePerKey;
22536 if (gamma >= valueMin && gamma <= valueMax)
22537 intersections.append(QPointF(keyMin, gamma));
22539 gamma = prevValue + (keyMax-prevKey)*valuePerKey;
22540 if (gamma >= valueMin && gamma <= valueMax)
22541 intersections.append(QPointF(keyMax, gamma));
22545 if (intersections.size() > 2)
22548 double distSqrMax = 0;
22550 for (
int i=0; i<intersections.size()-1; ++i)
22552 for (
int k=i+1; k<intersections.size(); ++k)
22554 QPointF distPoint = intersections.at(i)-intersections.at(k);
22555 double distSqr = distPoint.x()*distPoint.x()+distPoint.y()+distPoint.y();
22556 if (distSqr > distSqrMax)
22558 pv1 = intersections.at(i);
22559 pv2 = intersections.at(k);
22560 distSqrMax = distSqr;
22564 intersections = QList<QPointF>() << pv1 << pv2;
22565 }
else if (intersections.size() != 2)
22572 if ((key-prevKey)*(intersections.at(1).x()-intersections.at(0).x()) + (value-prevValue)*(intersections.at(1).y()-intersections.at(0).y()) < 0)
22573 intersections.move(0, 1);
22574 crossA =
coordsToPixels(intersections.at(0).x(), intersections.at(0).y());
22575 crossB =
coordsToPixels(intersections.at(1).x(), intersections.at(1).y());
22604 void QCPCurve::getTraverseCornerPoints(
int prevRegion,
int currentRegion,
double keyMin,
double valueMax,
double keyMax,
double valueMin, QVector<QPointF> &beforeTraverse, QVector<QPointF> &afterTraverse)
const 22606 switch (prevRegion)
22610 switch (currentRegion)
22612 case 6: { beforeTraverse <<
coordsToPixels(keyMin, valueMax);
break; }
22614 case 8: { beforeTraverse <<
coordsToPixels(keyMin, valueMax);
break; }
22620 switch (currentRegion)
22622 case 7: { afterTraverse <<
coordsToPixels(keyMax, valueMax);
break; }
22623 case 9: { afterTraverse <<
coordsToPixels(keyMax, valueMin);
break; }
22629 switch (currentRegion)
22631 case 4: { beforeTraverse <<
coordsToPixels(keyMin, valueMin);
break; }
22633 case 8: { beforeTraverse <<
coordsToPixels(keyMin, valueMin);
break; }
22639 switch (currentRegion)
22641 case 3: { afterTraverse <<
coordsToPixels(keyMin, valueMin);
break; }
22642 case 9: { afterTraverse <<
coordsToPixels(keyMax, valueMin);
break; }
22649 switch (currentRegion)
22651 case 1: { afterTraverse <<
coordsToPixels(keyMin, valueMax);
break; }
22652 case 7: { afterTraverse <<
coordsToPixels(keyMax, valueMax);
break; }
22658 switch (currentRegion)
22660 case 2: { beforeTraverse <<
coordsToPixels(keyMax, valueMax);
break; }
22662 case 6: { beforeTraverse <<
coordsToPixels(keyMax, valueMax);
break; }
22668 switch (currentRegion)
22670 case 1: { afterTraverse <<
coordsToPixels(keyMin, valueMax);
break; }
22671 case 3: { afterTraverse <<
coordsToPixels(keyMin, valueMin);
break; }
22677 switch (currentRegion)
22679 case 2: { beforeTraverse <<
coordsToPixels(keyMax, valueMin);
break; }
22681 case 4: { beforeTraverse <<
coordsToPixels(keyMax, valueMin);
break; }
22716 double minDistSqr = std::numeric_limits<double>::max();
22723 if (currentDistSqr < minDistSqr)
22725 minDistSqr = currentDistSqr;
22733 QVector<QPointF> lines;
22735 for (
int i=0; i<lines.size()-1; ++i)
22738 if (currentDistSqr < minDistSqr)
22739 minDistSqr = currentDistSqr;
22743 return qSqrt(minDistSqr);
22824 QObject(parentPlot),
22826 mSpacingType(stAbsolute),
22867 if (index >= 0 && index <
mBars.size())
22869 return mBars.at(index);
22872 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
22898 qDebug() << Q_FUNC_INFO <<
"bars is 0";
22902 if (!
mBars.contains(bars))
22905 qDebug() << Q_FUNC_INFO <<
"bars plottable is already in this bars group:" <<
reinterpret_cast<quintptr
>(
bars);
22921 qDebug() << Q_FUNC_INFO <<
"bars is 0";
22926 if (!
mBars.contains(bars))
22941 qDebug() << Q_FUNC_INFO <<
"bars is 0";
22945 if (
mBars.contains(bars))
22948 qDebug() << Q_FUNC_INFO <<
"bars plottable is not in this bars group:" <<
reinterpret_cast<quintptr
>(
bars);
22960 if (!
mBars.contains(bars))
22961 mBars.append(bars);
22973 mBars.removeOne(bars);
22985 QList<const QCPBars*> baseBars;
22990 if (!baseBars.contains(b))
22991 baseBars.append(b);
23000 int index = baseBars.indexOf(thisBase);
23003 if (baseBars.size() % 2 == 1 && index == (baseBars.size()-1)/2)
23008 double lowerPixelWidth, upperPixelWidth;
23010 int dir = (index <= (baseBars.size()-1)/2) ? -1 : 1;
23011 if (baseBars.size() % 2 == 0)
23013 startIndex = baseBars.size()/2 + (dir < 0 ? -1 : 0);
23017 startIndex = (baseBars.size()-1)/2+dir;
23018 baseBars.at((baseBars.size()-1)/2)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth);
23019 result += qAbs(upperPixelWidth-lowerPixelWidth)*0.5;
23020 result +=
getPixelSpacing(baseBars.at((baseBars.size()-1)/2), keyCoord);
23022 for (
int i = startIndex; i != index; i += dir)
23024 baseBars.at(i)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth);
23025 result += qAbs(upperPixelWidth-lowerPixelWidth);
23029 baseBars.at(index)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth);
23030 result += qAbs(upperPixelWidth-lowerPixelWidth)*0.5;
23240 mWidthType(wtPlotCoords),
23246 mPen.setColor(Qt::blue);
23247 mPen.setStyle(Qt::SolidLine);
23248 mBrush.setColor(QColor(40, 50, 255, 30));
23249 mBrush.setStyle(Qt::SolidPattern);
23291 void QCPBars::setData(
const QVector<double> &keys,
const QVector<double> &values,
bool alreadySorted)
23294 addData(keys, values, alreadySorted);
23377 void QCPBars::addData(
const QVector<double> &keys,
const QVector<double> &values,
bool alreadySorted)
23379 if (keys.size() != values.size())
23380 qDebug() << Q_FUNC_INFO <<
"keys and values have different sizes:" << keys.size() << values.size();
23381 const int n = qMin(keys.size(), values.size());
23382 QVector<QCPBarsData> tempData(n);
23383 QVector<QCPBarsData>::iterator it = tempData.begin();
23384 const QVector<QCPBarsData>::iterator itEnd = tempData.end();
23386 while (it != itEnd)
23389 it->value = values[i];
23423 if (bars ==
this)
return;
23426 qDebug() << Q_FUNC_INFO <<
"passed QCPBars* doesn't have same key and value axis as this QCPBars";
23456 if (bars ==
this)
return;
23459 qDebug() << Q_FUNC_INFO <<
"passed QCPBars* doesn't have same key and value axis as this QCPBars";
23489 if (rect.intersects(
getBarRect(it->key, it->value)))
23505 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
23512 if (
getBarRect(it->key, it->value).contains(pos))
23544 double lowerPixelWidth, upperPixelWidth, keyPixel;
23547 keyPixel =
mKeyAxis.data()->coordToPixel(range.
lower) + lowerPixelWidth;
23550 const double lowerCorrected =
mKeyAxis.data()->pixelToCoord(keyPixel);
23551 if (!qIsNaN(lowerCorrected) && qIsFinite(lowerCorrected) && range.
lower > lowerCorrected)
23552 range.
lower = lowerCorrected;
23555 keyPixel =
mKeyAxis.data()->coordToPixel(range.
upper) + upperPixelWidth;
23558 const double upperCorrected =
mKeyAxis.data()->pixelToCoord(keyPixel);
23559 if (!qIsNaN(upperCorrected) && qIsFinite(upperCorrected) && range.
upper < upperCorrected)
23560 range.
upper = upperCorrected;
23573 bool haveLower =
true;
23574 bool haveUpper =
true;
23585 if (qIsNaN(current))
continue;
23588 if (current < range.
lower || !haveLower)
23590 range.
lower = current;
23593 if (current > range.
upper || !haveUpper)
23595 range.
upper = current;
23608 if (index >= 0 && index < mDataContainer->
size())
23612 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPointF(); }
23618 return QPointF(keyPixel, valuePixel);
23620 return QPointF(valuePixel, keyPixel);
23623 qDebug() << Q_FUNC_INFO <<
"Index out of bounds" << index;
23631 if (!
mKeyAxis || !
mValueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
23638 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
23640 allSegments << unselectedSegments << selectedSegments;
23641 for (
int i=0; i<allSegments.size(); ++i)
23643 bool isSelectedSegment = i >= unselectedSegments.size();
23646 mDataContainer->limitIteratorsToDataRange(begin, end, allSegments.at(i));
23653 #ifdef QCUSTOMPLOT_CHECK_DATA 23655 qDebug() << Q_FUNC_INFO <<
"Data point at" << it->key <<
"of drawn range invalid." <<
"Plottable name:" <<
name();
23664 painter->setBrush(
mBrush);
23668 painter->drawPolygon(
getBarRect(it->key, it->value));
23682 painter->setBrush(
mBrush);
23684 QRectF r = QRectF(0, 0, rect.width()*0.67, rect.height()*0.67);
23685 r.moveCenter(rect.center());
23686 painter->drawRect(r);
23707 qDebug() << Q_FUNC_INFO <<
"invalid key axis";
23722 double lowerPixelBound =
mKeyAxis.data()->coordToPixel(
mKeyAxis.data()->range().lower);
23723 double upperPixelBound =
mKeyAxis.data()->coordToPixel(
mKeyAxis.data()->range().upper);
23724 bool isVisible =
false;
23730 const QRectF barRect =
getBarRect(it->key, it->value);
23731 if (
mKeyAxis.data()->orientation() == Qt::Horizontal)
23732 isVisible = ((!
mKeyAxis.data()->rangeReversed() && barRect.right() >= lowerPixelBound) || (
mKeyAxis.data()->rangeReversed() && barRect.left() <= lowerPixelBound));
23734 isVisible = ((!
mKeyAxis.data()->rangeReversed() && barRect.top() <= lowerPixelBound) || (
mKeyAxis.data()->rangeReversed() && barRect.bottom() >= lowerPixelBound));
23744 const QRectF barRect =
getBarRect(it->key, it->value);
23745 if (
mKeyAxis.data()->orientation() == Qt::Horizontal)
23746 isVisible = ((!
mKeyAxis.data()->rangeReversed() && barRect.left() <= upperPixelBound) || (
mKeyAxis.data()->rangeReversed() && barRect.right() >= upperPixelBound));
23748 isVisible = ((!
mKeyAxis.data()->rangeReversed() && barRect.bottom() >= upperPixelBound) || (
mKeyAxis.data()->rangeReversed() && barRect.top() <= upperPixelBound));
23767 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QRectF(); }
23769 double lowerPixelWidth, upperPixelWidth;
23773 double valuePixel = valueAxis->
coordToPixel(base+value);
23777 double bottomOffset = (
mBarBelow &&
mPen != Qt::NoPen ? 1 : 0)*(
mPen.isCosmetic() ? 1 :
mPen.widthF());
23780 if (qAbs(valuePixel-basePixel) <= qAbs(bottomOffset))
23781 bottomOffset = valuePixel-basePixel;
23784 return QRectF(QPointF(keyPixel+lowerPixelWidth, valuePixel), QPointF(keyPixel+upperPixelWidth, basePixel+bottomOffset)).normalized();
23787 return QRectF(QPointF(basePixel+bottomOffset, keyPixel+lowerPixelWidth), QPointF(valuePixel, keyPixel+upperPixelWidth)).normalized();
23816 if (
mKeyAxis.data()->orientation() == Qt::Horizontal)
23822 qDebug() << Q_FUNC_INFO <<
"No key axis or axis rect defined";
23829 double keyPixel =
mKeyAxis.data()->coordToPixel(key);
23835 qDebug() << Q_FUNC_INFO <<
"No key axis defined";
23856 double epsilon = qAbs(key)*(
sizeof(key)==4 ? 1e-6 : 1e-14);
23858 epsilon = (
sizeof(key)==4 ? 1e-6 : 1e-14);
23861 while (it != itEnd)
23863 if (it->key > key-epsilon && it->key < key+epsilon)
23865 if ((positive && it->value > max) ||
23866 (!positive && it->value < max))
23872 return max +
mBarBelow.data()->getStackedBaseValue(key, positive);
23887 if (!lower && !upper)
return;
23893 upper->
mBarBelow.data()->mBarAbove = 0;
23899 lower->
mBarAbove.data()->mBarBelow = 0;
23905 lower->
mBarAbove.data()->mBarBelow = 0;
23908 upper->
mBarBelow.data()->mBarAbove = 0;
24032 lowerQuartile(lowerQuartile),
24034 upperQuartile(upperQuartile),
24117 mWhiskerWidth(0.2),
24118 mWhiskerPen(Qt::black, 0, Qt::DashLine, Qt::FlatCap),
24119 mWhiskerBarPen(Qt::black),
24120 mWhiskerAntialiased(false),
24121 mMedianPen(Qt::black, 3, Qt::SolidLine, Qt::FlatCap),
24124 setPen(QPen(Qt::black));
24159 void QCPStatisticalBox::setData(
const QVector<double> &keys,
const QVector<double> &minimum,
const QVector<double> &lowerQuartile,
const QVector<double> &median,
const QVector<double> &upperQuartile,
const QVector<double> &maximum,
bool alreadySorted)
24162 addData(keys, minimum, lowerQuartile, median, upperQuartile, maximum, alreadySorted);
24260 void QCPStatisticalBox::addData(
const QVector<double> &keys,
const QVector<double> &minimum,
const QVector<double> &lowerQuartile,
const QVector<double> &median,
const QVector<double> &upperQuartile,
const QVector<double> &maximum,
bool alreadySorted)
24262 if (keys.size() != minimum.size() || minimum.size() != lowerQuartile.size() || lowerQuartile.size() != median.size() ||
24263 median.size() != upperQuartile.size() || upperQuartile.size() != maximum.size() || maximum.size() != keys.size())
24264 qDebug() << Q_FUNC_INFO <<
"keys, minimum, lowerQuartile, median, upperQuartile, maximum have different sizes:" 24265 << keys.size() << minimum.size() << lowerQuartile.size() << median.size() << upperQuartile.size() << maximum.size();
24266 const int n = qMin(keys.size(), qMin(minimum.size(), qMin(lowerQuartile.size(), qMin(median.size(), qMin(upperQuartile.size(), maximum.size())))));
24267 QVector<QCPStatisticalBoxData> tempData(n);
24268 QVector<QCPStatisticalBoxData>::iterator it = tempData.begin();
24269 const QVector<QCPStatisticalBoxData>::iterator itEnd = tempData.end();
24271 while (it != itEnd)
24274 it->minimum = minimum[i];
24275 it->lowerQuartile = lowerQuartile[i];
24276 it->median = median[i];
24277 it->upperQuartile = upperQuartile[i];
24278 it->maximum = maximum[i];
24293 void QCPStatisticalBox::addData(
double key,
double minimum,
double lowerQuartile,
double median,
double upperQuartile,
double maximum,
const QVector<double> &outliers)
24330 if (
mKeyAxis->axisRect()->rect().contains(pos.toPoint()))
24336 double minDistSqr = std::numeric_limits<double>::max();
24342 if (currentDistSqr < minDistSqr)
24344 minDistSqr = currentDistSqr;
24345 closestDataPoint = it;
24350 for (
int i=0; i<whiskerBackbones.size(); ++i)
24353 if (currentDistSqr < minDistSqr)
24355 minDistSqr = currentDistSqr;
24356 closestDataPoint = it;
24366 return qSqrt(minDistSqr);
24389 return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange);
24398 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
24404 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
24406 allSegments << unselectedSegments << selectedSegments;
24407 for (
int i=0; i<allSegments.size(); ++i)
24409 bool isSelectedSegment = i >= unselectedSegments.size();
24412 mDataContainer->limitIteratorsToDataRange(begin, end, allSegments.at(i));
24419 # ifdef QCUSTOMPLOT_CHECK_DATA 24423 qDebug() << Q_FUNC_INFO <<
"Data point at" << it->key <<
"of drawn range has invalid data." <<
"Plottable name:" <<
name();
24424 for (
int i=0; i<it->outliers.size(); ++i)
24426 qDebug() << Q_FUNC_INFO <<
"Data point outlier at" << it->key <<
"of drawn range invalid." <<
"Plottable name:" <<
name();
24436 painter->setBrush(
mBrush);
24456 painter->setBrush(
mBrush);
24457 QRectF r = QRectF(0, 0, rect.width()*0.67, rect.height()*0.67);
24458 r.moveCenter(rect.center());
24459 painter->drawRect(r);
24475 painter->drawRect(quartileBox);
24478 painter->setClipRect(quartileBox, Qt::IntersectClip);
24491 for (
int i=0; i<it->outliers.size(); ++i)
24513 qDebug() << Q_FUNC_INFO <<
"invalid key axis";
24547 QVector<QLineF> result(2);
24562 QVector<QLineF> result(2);
24630 mKeyRange(keyRange),
24631 mValueRange(valueRange),
24635 mDataModified(true)
24669 if (&other !=
this)
24696 if (keyCell >= 0 && keyCell < mKeySize && valueCell >= 0 && valueCell <
mValueSize)
24705 if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex <
mValueSize)
24721 if (
mAlpha && keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex <
mValueSize)
24750 #ifdef __EXCEPTIONS 24754 #ifdef __EXCEPTIONS 24755 }
catch (...) {
mData = 0; }
24760 qDebug() << Q_FUNC_INFO <<
"out of memory for data dimensions "<<
mKeySize <<
"*" <<
mValueSize;
24863 if (keyCell >= 0 && keyCell < mKeySize && valueCell >= 0 && valueCell <
mValueSize)
24887 if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex <
mValueSize)
24896 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << keyIndex << valueIndex;
24916 if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex <
mValueSize)
24924 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << keyIndex << valueIndex;
24944 double minHeight =
mData[0];
24945 double maxHeight =
mData[0];
24947 for (
int i=0; i<dataCount; ++i)
24949 if (
mData[i] > maxHeight)
24950 maxHeight =
mData[i];
24951 if (
mData[i] < minHeight)
24952 minHeight =
mData[i];
24988 for (
int i=0; i<dataCount; ++i)
25008 for (
int i=0; i<dataCount; ++i)
25081 #ifdef __EXCEPTIONS 25085 #ifdef __EXCEPTIONS 25086 }
catch (...) {
mAlpha = 0; }
25090 if (initializeOpaque)
25095 qDebug() << Q_FUNC_INFO <<
"out of memory for data dimensions "<<
mKeySize <<
"*" <<
mValueSize;
25226 mDataScaleType(
QCPAxis::stLinear),
25228 mInterpolate(true),
25229 mTightBoundary(false),
25230 mMapImageInvalidated(true)
25250 qDebug() << Q_FUNC_INFO <<
"The data pointer is already in (and owned by) this plottable" <<
reinterpret_cast<quintptr
>(
data);
25414 if (recalculateDataBounds)
25442 mLegendIcon = QPixmap::fromImage(
mMapImage.mirrored(mirrorX, mirrorY)).scaled(thumbSize, Qt::KeepAspectRatio, transformMode);
25455 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
25457 double posKey, posValue;
25479 else if (result.
lower <= 0 && result.
upper <= 0)
25480 foundRange =
false;
25485 else if (result.
upper >= 0 && result.
lower >= 0)
25486 foundRange =
false;
25498 foundRange =
false;
25510 else if (result.
lower <= 0 && result.
upper <= 0)
25511 foundRange =
false;
25516 else if (result.
upper >= 0 && result.
lower >= 0)
25517 foundRange =
false;
25539 if (!keyAxis)
return;
25542 const QImage::Format format = QImage::Format_ARGB32_Premultiplied;
25545 int keyOversamplingFactor =
mInterpolate ? 1 : (
int)(1.0+100.0/(
double)keySize);
25546 int valueOversamplingFactor =
mInterpolate ? 1 : (
int)(1.0+100.0/(
double)valueSize);
25549 if (keyAxis->
orientation() == Qt::Horizontal && (
mMapImage.width() != keySize*keyOversamplingFactor ||
mMapImage.height() != valueSize*valueOversamplingFactor))
25550 mMapImage = QImage(QSize(keySize*keyOversamplingFactor, valueSize*valueOversamplingFactor), format);
25551 else if (keyAxis->
orientation() == Qt::Vertical && (
mMapImage.width() != valueSize*valueOversamplingFactor ||
mMapImage.height() != keySize*keyOversamplingFactor))
25552 mMapImage = QImage(QSize(valueSize*valueOversamplingFactor, keySize*keyOversamplingFactor), format);
25555 if (keyOversamplingFactor > 1 || valueOversamplingFactor > 1)
25570 const int lineCount = valueSize;
25571 const int rowCount = keySize;
25572 for (
int line=0; line<lineCount; ++line)
25574 QRgb* pixels =
reinterpret_cast<QRgb*
>(localMapImage->scanLine(lineCount-1-line));
25582 const int lineCount = keySize;
25583 const int rowCount = valueSize;
25584 for (
int line=0; line<lineCount; ++line)
25586 QRgb* pixels =
reinterpret_cast<QRgb*
>(localMapImage->scanLine(lineCount-1-line));
25594 if (keyOversamplingFactor > 1 || valueOversamplingFactor > 1)
25597 mMapImage =
mUndersampledMapImage.scaled(keySize*keyOversamplingFactor, valueSize*valueOversamplingFactor, Qt::IgnoreAspectRatio, Qt::FastTransformation);
25599 mMapImage =
mUndersampledMapImage.scaled(valueSize*valueOversamplingFactor, keySize*keyOversamplingFactor, Qt::IgnoreAspectRatio, Qt::FastTransformation);
25618 QRectF mapBufferTarget;
25622 const double mapBufferPixelRatio = 3;
25623 mapBufferTarget = painter->clipRegion().boundingRect();
25624 mapBuffer = QPixmap((mapBufferTarget.size()*mapBufferPixelRatio).toSize());
25625 mapBuffer.fill(Qt::transparent);
25627 localPainter->scale(mapBufferPixelRatio, mapBufferPixelRatio);
25628 localPainter->translate(-mapBufferTarget.topLeft());
25634 double halfCellWidth = 0;
25635 double halfCellHeight = 0;
25636 if (
keyAxis()->orientation() == Qt::Horizontal)
25639 halfCellWidth = 0.5*imageRect.width()/(double)(
mMapData->
keySize()-1);
25645 halfCellHeight = 0.5*imageRect.height()/(double)(
mMapData->
keySize()-1);
25649 imageRect.adjust(-halfCellWidth, -halfCellHeight, halfCellWidth, halfCellHeight);
25652 const bool smoothBackup = localPainter->renderHints().testFlag(QPainter::SmoothPixmapTransform);
25653 localPainter->setRenderHint(QPainter::SmoothPixmapTransform,
mInterpolate);
25654 QRegion clipBackup;
25657 clipBackup = localPainter->clipRegion();
25660 localPainter->setClipRect(tightClipRect, Qt::IntersectClip);
25662 localPainter->drawImage(imageRect,
mMapImage.mirrored(mirrorX, mirrorY));
25664 localPainter->setClipRegion(clipBackup);
25665 localPainter->setRenderHint(QPainter::SmoothPixmapTransform, smoothBackup);
25669 delete localPainter;
25670 painter->drawPixmap(mapBufferTarget.toRect(), mapBuffer);
25681 QPixmap scaledIcon =
mLegendIcon.scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::FastTransformation);
25682 QRectF iconRect = QRectF(0, 0, scaledIcon.width(), scaledIcon.height());
25683 iconRect.moveCenter(rect.center());
25684 painter->drawPixmap(iconRect.topLeft(), scaledIcon);
25874 mChartStyle(csCandlestick),
25876 mWidthType(wtPlotCoords),
25878 mBrushPositive(QBrush(QColor(50, 160, 0))),
25879 mBrushNegative(QBrush(QColor(180, 0, 15))),
25880 mPenPositive(QPen(QColor(40, 150, 0))),
25881 mPenNegative(QPen(QColor(170, 5, 5)))
25921 void QCPFinancial::setData(
const QVector<double> &keys,
const QVector<double> &open,
const QVector<double> &high,
const QVector<double> &low,
const QVector<double> &close,
bool alreadySorted)
25924 addData(keys, open, high, low, close, alreadySorted);
26042 void QCPFinancial::addData(
const QVector<double> &keys,
const QVector<double> &open,
const QVector<double> &high,
const QVector<double> &low,
const QVector<double> &close,
bool alreadySorted)
26044 if (keys.size() != open.size() || open.size() != high.size() || high.size() != low.size() || low.size() != close.size() || close.size() != keys.size())
26045 qDebug() << Q_FUNC_INFO <<
"keys, open, high, low, close have different sizes:" << keys.size() << open.size() << high.size() << low.size() << close.size();
26046 const int n = qMin(keys.size(), qMin(open.size(), qMin(high.size(), qMin(low.size(), close.size()))));
26047 QVector<QCPFinancialData> tempData(n);
26048 QVector<QCPFinancialData>::iterator it = tempData.begin();
26049 const QVector<QCPFinancialData>::iterator itEnd = tempData.end();
26051 while (it != itEnd)
26054 it->open = open[i];
26055 it->high = high[i];
26057 it->close = close[i];
26111 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
26118 double result = -1;
26122 result =
ohlcSelectTest(pos, visibleBegin, visibleEnd, closestDataPoint);
break;
26155 return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange);
26175 int count = qMin(time.size(), value.size());
26179 QCPFinancialData currentBinData(0, value.first(), value.first(), value.first(), value.first());
26180 int currentBinIndex = qFloor((time.first()-timeBinOffset)/timeBinSize+0.5);
26181 for (
int i=0; i<count; ++i)
26183 int index = qFloor((time.at(i)-timeBinOffset)/timeBinSize+0.5);
26184 if (currentBinIndex == index)
26186 if (value.at(i) < currentBinData.low) currentBinData.low = value.at(i);
26187 if (value.at(i) > currentBinData.high) currentBinData.high = value.at(i);
26190 currentBinData.close = value.at(i);
26191 currentBinData.key = timeBinOffset+(index)*timeBinSize;
26192 data.
add(currentBinData);
26197 currentBinData.close = value.at(i-1);
26198 currentBinData.key = timeBinOffset+(index-1)*timeBinSize;
26199 data.
add(currentBinData);
26201 currentBinIndex = index;
26202 currentBinData.open = value.at(i);
26203 currentBinData.high = value.at(i);
26204 currentBinData.low = value.at(i);
26219 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
26221 allSegments << unselectedSegments << selectedSegments;
26222 for (
int i=0; i<allSegments.size(); ++i)
26224 bool isSelectedSegment = i >= unselectedSegments.size();
26227 mDataContainer->limitIteratorsToDataRange(begin, end, allSegments.at(i));
26235 drawOhlcPlot(painter, begin, end, isSelectedSegment);
break;
26257 painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.topLeft().toPoint()));
26258 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26259 painter->
drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft()));
26260 painter->
drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft()));
26264 painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.bottomRight().toPoint()));
26265 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26266 painter->
drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft()));
26267 painter->
drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft()));
26270 painter->setBrush(
mBrush);
26272 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26273 painter->
drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft()));
26274 painter->
drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft()));
26283 painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.topLeft().toPoint()));
26284 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft()));
26285 painter->
drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26286 painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft()));
26290 painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.bottomRight().toPoint()));
26291 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft()));
26292 painter->
drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26293 painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft()));
26296 painter->setBrush(
mBrush);
26298 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft()));
26299 painter->
drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26300 painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft()));
26315 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
26329 double closePixel = valueAxis->
coordToPixel(it->close);
26334 painter->
drawLine(QPointF(keyPixel-pixelWidth, openPixel), QPointF(keyPixel, openPixel));
26336 painter->
drawLine(QPointF(keyPixel, closePixel), QPointF(keyPixel+pixelWidth, closePixel));
26350 double closePixel = valueAxis->
coordToPixel(it->close);
26355 painter->
drawLine(QPointF(openPixel, keyPixel-pixelWidth), QPointF(openPixel, keyPixel));
26357 painter->
drawLine(QPointF(closePixel, keyPixel), QPointF(closePixel, keyPixel+pixelWidth));
26372 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
26389 painter->setBrush(
mBrush);
26393 double closePixel = valueAxis->
coordToPixel(it->close);
26400 painter->drawRect(QRectF(QPointF(keyPixel-pixelWidth, closePixel), QPointF(keyPixel+pixelWidth, openPixel)));
26417 painter->setBrush(
mBrush);
26421 double closePixel = valueAxis->
coordToPixel(it->close);
26428 painter->drawRect(QRectF(QPointF(closePixel, keyPixel-pixelWidth), QPointF(openPixel, keyPixel+pixelWidth)));
26460 if (
mKeyAxis.data()->orientation() == Qt::Horizontal)
26465 qDebug() << Q_FUNC_INFO <<
"No key axis or axis rect defined";
26471 result =
mKeyAxis.data()->coordToPixel(key+
mWidth*0.5)-keyPixel;
26473 qDebug() << Q_FUNC_INFO <<
"No key axis defined";
26493 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return -1; }
26495 double minDistSqr = std::numeric_limits<double>::max();
26503 if (currentDistSqr < minDistSqr)
26505 minDistSqr = currentDistSqr;
26506 closestDataPoint = it;
26516 if (currentDistSqr < minDistSqr)
26518 minDistSqr = currentDistSqr;
26519 closestDataPoint = it;
26523 return qSqrt(minDistSqr);
26540 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return -1; }
26542 double minDistSqr = std::numeric_limits<double>::max();
26547 double currentDistSqr;
26550 QCPRange boxValueRange(it->close, it->open);
26551 double posKey, posValue;
26562 currentDistSqr = qMin(highLineDistSqr, lowLineDistSqr);
26564 if (currentDistSqr < minDistSqr)
26566 minDistSqr = currentDistSqr;
26567 closestDataPoint = it;
26574 double currentDistSqr;
26577 QCPRange boxValueRange(it->close, it->open);
26578 double posKey, posValue;
26589 currentDistSqr = qMin(highLineDistSqr, lowLineDistSqr);
26591 if (currentDistSqr < minDistSqr)
26593 minDistSqr = currentDistSqr;
26594 closestDataPoint = it;
26598 return qSqrt(minDistSqr);
26619 qDebug() << Q_FUNC_INFO <<
"invalid key axis";
26637 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QRectF(); }
26644 return QRectF(keyPixel-keyWidthPixels, highPixel, keyWidthPixels*2, lowPixel-highPixel).normalized();
26646 return QRectF(highPixel, keyPixel-keyWidthPixels, lowPixel-highPixel, keyWidthPixels*2).normalized();
26696 errorMinus(errorMinus),
26697 errorPlus(errorPlus)
26762 mErrorType(etValueError),
26766 setPen(QPen(Qt::black, 0));
26825 addData(errorMinus, errorPlus);
26844 if (plottable && qobject_cast<QCPErrorBars*>(plottable))
26847 qDebug() << Q_FUNC_INFO <<
"can't set another QCPErrorBars instance as data plottable";
26853 qDebug() << Q_FUNC_INFO <<
"passed plottable doesn't implement 1d interface, can't associate with QCPErrorBars";
26914 if (errorMinus.size() != errorPlus.size())
26915 qDebug() << Q_FUNC_INFO <<
"minus and plus error vectors have different sizes:" << errorMinus.size() << errorPlus.size();
26916 const int n = qMin(errorMinus.size(), errorPlus.size());
26918 for (
int i=0; i<n; ++i)
26963 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
26973 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
26983 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
26992 const double value =
mDataPlottable->interface1D()->dataMainValue(index);
26999 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27010 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27022 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27040 QCPErrorBarsDataContainer::const_iterator visibleBegin, visibleEnd;
27043 QVector<QLineF> backbones, whiskers;
27044 for (QCPErrorBarsDataContainer::const_iterator it=visibleBegin; it!=visibleEnd; ++it)
27049 for (
int i=0; i<backbones.size(); ++i)
27069 int beginIndex =
mDataPlottable->interface1D()->findBegin(sortKey, expandedRange);
27074 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27085 int endIndex =
mDataPlottable->interface1D()->findEnd(sortKey, expandedRange);
27090 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27104 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
27106 QCPErrorBarsDataContainer::const_iterator closestDataPoint =
mDataContainer->constEnd();
27122 if (!
mKeyAxis || !
mValueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
27127 bool checkPointVisibility = !
mDataPlottable->interface1D()->sortKeyIsMainKey();
27130 #ifdef QCUSTOMPLOT_CHECK_DATA 27131 QCPErrorBarsDataContainer::const_iterator it;
27135 qDebug() << Q_FUNC_INFO <<
"Data point at index" << it-
mDataContainer->constBegin() <<
"invalid." <<
"Plottable name:" <<
name();
27140 painter->setBrush(Qt::NoBrush);
27142 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
27144 allSegments << unselectedSegments << selectedSegments;
27145 QVector<QLineF> backbones, whiskers;
27146 for (
int i=0; i<allSegments.size(); ++i)
27148 QCPErrorBarsDataContainer::const_iterator begin, end;
27153 bool isSelectedSegment = i >= unselectedSegments.size();
27158 if (painter->pen().capStyle() == Qt::SquareCap)
27160 QPen capFixPen(painter->pen());
27161 capFixPen.setCapStyle(Qt::FlatCap);
27162 painter->
setPen(capFixPen);
27166 for (QCPErrorBarsDataContainer::const_iterator it=begin; it!=end; ++it)
27171 painter->drawLines(backbones);
27172 painter->drawLines(whiskers);
27187 painter->
drawLine(QLineF(rect.center().x(), rect.top()+2, rect.center().x(), rect.bottom()-1));
27188 painter->
drawLine(QLineF(rect.center().x()-4, rect.top()+2, rect.center().x()+4, rect.top()+2));
27189 painter->
drawLine(QLineF(rect.center().x()-4, rect.bottom()-1, rect.center().x()+4, rect.bottom()-1));
27192 painter->
drawLine(QLineF(rect.left()+2, rect.center().y(), rect.right()-2, rect.center().y()));
27193 painter->
drawLine(QLineF(rect.left()+2, rect.center().y()-4, rect.left()+2, rect.center().y()+4));
27194 painter->
drawLine(QLineF(rect.right()-2, rect.center().y()-4, rect.right()-2, rect.center().y()+4));
27203 foundRange =
false;
27208 bool haveLower =
false;
27209 bool haveUpper =
false;
27210 QCPErrorBarsDataContainer::const_iterator it;
27217 if (qIsNaN(current))
continue;
27220 if (current < range.
lower || !haveLower)
27222 range.
lower = current;
27225 if (current > range.
upper || !haveUpper)
27227 range.
upper = current;
27234 if (qIsNaN(dataKey))
continue;
27236 double current = dataKey + (qIsNaN(it->errorPlus) ? 0 : it->errorPlus);
27239 if (current > range.
upper || !haveUpper)
27241 range.
upper = current;
27246 current = dataKey - (qIsNaN(it->errorMinus) ? 0 : it->errorMinus);
27249 if (current < range.
lower || !haveLower)
27251 range.
lower = current;
27258 if (haveUpper && !haveLower)
27262 }
else if (haveLower && !haveUpper)
27268 foundRange = haveLower && haveUpper;
27277 foundRange =
false;
27282 const bool restrictKeyRange = inKeyRange !=
QCPRange();
27283 bool haveLower =
false;
27284 bool haveUpper =
false;
27285 QCPErrorBarsDataContainer::const_iterator itBegin =
mDataContainer->constBegin();
27286 QCPErrorBarsDataContainer::const_iterator itEnd =
mDataContainer->constEnd();
27287 if (
mDataPlottable->interface1D()->sortKeyIsMainKey() && restrictKeyRange)
27292 for (QCPErrorBarsDataContainer::const_iterator it = itBegin; it != itEnd; ++it)
27294 if (restrictKeyRange)
27297 if (dataKey < inKeyRange.lower || dataKey > inKeyRange.
upper)
27303 if (qIsNaN(dataValue))
continue;
27305 double current = dataValue + (qIsNaN(it->errorPlus) ? 0 : it->errorPlus);
27308 if (current > range.
upper || !haveUpper)
27310 range.
upper = current;
27315 current = dataValue - (qIsNaN(it->errorMinus) ? 0 : it->errorMinus);
27318 if (current < range.
lower || !haveLower)
27320 range.
lower = current;
27328 if (qIsNaN(current))
continue;
27331 if (current < range.
lower || !haveLower)
27333 range.
lower = current;
27336 if (current > range.
upper || !haveUpper)
27338 range.
upper = current;
27345 if (haveUpper && !haveLower)
27349 }
else if (haveLower && !haveUpper)
27355 foundRange = haveLower && haveUpper;
27375 QPointF centerPixel =
mDataPlottable->interface1D()->dataPixelPosition(index);
27376 if (qIsNaN(centerPixel.x()) || qIsNaN(centerPixel.y()))
27380 const double centerErrorAxisPixel = errorAxis->
orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
27381 const double centerOrthoAxisPixel = orthoAxis->
orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
27382 const double centerErrorAxisCoord = errorAxis->
pixelToCoord(centerErrorAxisPixel);
27385 double errorStart, errorEnd;
27386 if (!qIsNaN(it->errorPlus))
27388 errorStart = centerErrorAxisPixel+
symbolGap;
27389 errorEnd = errorAxis->
coordToPixel(centerErrorAxisCoord+it->errorPlus);
27393 backbones.append(QLineF(centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd));
27394 whiskers.append(QLineF(centerOrthoAxisPixel-
mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+
mWhiskerWidth*0.5, errorEnd));
27398 backbones.append(QLineF(errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel));
27399 whiskers.append(QLineF(errorEnd, centerOrthoAxisPixel-
mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+
mWhiskerWidth*0.5));
27403 if (!qIsNaN(it->errorMinus))
27405 errorStart = centerErrorAxisPixel-
symbolGap;
27406 errorEnd = errorAxis->
coordToPixel(centerErrorAxisCoord-it->errorMinus);
27410 backbones.append(QLineF(centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd));
27411 whiskers.append(QLineF(centerOrthoAxisPixel-
mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+
mWhiskerWidth*0.5, errorEnd));
27415 backbones.append(QLineF(errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel));
27416 whiskers.append(QLineF(errorEnd, centerOrthoAxisPixel-
mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+
mWhiskerWidth*0.5));
27443 if (!keyAxis || !valueAxis)
27445 qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
27462 dataRange = dataRange.
bounded(rangeRestriction);
27472 int i = beginIndex;
27473 while (i > 0 && i < n && i > rangeRestriction.
begin())
27480 while (i >= 0 && i < n && i < rangeRestriction.
end())
27504 QCPErrorBarsDataContainer::const_iterator begin, end;
27508 double minDistSqr = std::numeric_limits<double>::max();
27509 QVector<QLineF> backbones, whiskers;
27510 for (QCPErrorBarsDataContainer::const_iterator it=begin; it!=end; ++it)
27513 for (
int i=0; i<backbones.size(); ++i)
27516 if (currentDistSqr < minDistSqr)
27518 minDistSqr = currentDistSqr;
27523 return qSqrt(minDistSqr);
27535 selectedSegments.clear();
27536 unselectedSegments.clear();
27542 unselectedSegments << QCPDataRange(0,
dataCount());
27563 QPointF centerPixel =
mDataPlottable->interface1D()->dataPixelPosition(index);
27564 const double centerKeyPixel =
mKeyAxis->orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
27565 if (qIsNaN(centerKeyPixel))
27568 double keyMin, keyMax;
27571 const double centerKey =
mKeyAxis->pixelToCoord(centerKeyPixel);
27574 keyMax = centerKey+(qIsNaN(errorPlus) ? 0 : errorPlus);
27575 keyMin = centerKey-(qIsNaN(errorMinus) ? 0 : errorMinus);
27581 return ((keyMax >
mKeyAxis->range().lower) && (keyMin < mKeyAxis->range().upper));
27593 if (pixelRect.left() > line.x1() && pixelRect.left() > line.x2())
27595 else if (pixelRect.right() < line.x1() && pixelRect.right() < line.x2())
27597 else if (pixelRect.top() > line.y1() && pixelRect.top() > line.y2())
27599 else if (pixelRect.bottom() < line.y1() && pixelRect.bottom() < line.y2())
27630 point1(createPosition(QLatin1String(
"point1"))),
27631 point2(createPosition(QLatin1String(
"point2")))
27636 setPen(QPen(Qt::black));
27680 double clipPad =
mainPen().widthF();
27683 if (!line.isNull())
27702 if (vec.
x() == 0 && vec.
y() == 0)
27704 if (qFuzzyIsNull(vec.
x()))
27709 gamma = base.
x()-bx + (by-base.
y())*vec.
x()/vec.
y();
27710 if (gamma >= 0 && gamma <= rect.width())
27711 result.setLine(bx+gamma, rect.top(), bx+gamma, rect.bottom());
27712 }
else if (qFuzzyIsNull(vec.
y()))
27717 gamma = base.
y()-by + (bx-base.
x())*vec.
y()/vec.
x();
27718 if (gamma >= 0 && gamma <= rect.height())
27719 result.setLine(rect.left(), by+gamma, rect.right(), by+gamma);
27722 QList<QCPVector2D> pointVectors;
27726 gamma = base.
x()-bx + (by-base.
y())*vec.
x()/vec.
y();
27727 if (gamma >= 0 && gamma <= rect.width())
27731 by = rect.bottom();
27732 gamma = base.
x()-bx + (by-base.
y())*vec.
x()/vec.
y();
27733 if (gamma >= 0 && gamma <= rect.width())
27738 gamma = base.
y()-by + (bx-base.
x())*vec.
y()/vec.
x();
27739 if (gamma >= 0 && gamma <= rect.height())
27744 gamma = base.
y()-by + (bx-base.
x())*vec.
y()/vec.
x();
27745 if (gamma >= 0 && gamma <= rect.height())
27749 if (pointVectors.size() == 2)
27751 result.setPoints(pointVectors.at(0).toPointF(), pointVectors.at(1).toPointF());
27752 }
else if (pointVectors.size() > 2)
27755 double distSqrMax = 0;
27757 for (
int i=0; i<pointVectors.size()-1; ++i)
27759 for (
int k=i+1; k<pointVectors.size(); ++k)
27761 double distSqr = (pointVectors.at(i)-pointVectors.at(k)).lengthSquared();
27762 if (distSqr > distSqrMax)
27764 pv1 = pointVectors.at(i);
27765 pv2 = pointVectors.at(k);
27766 distSqrMax = distSqr;
27819 setPen(QPen(Qt::black));
27888 if (qFuzzyIsNull((startVec-endVec).lengthSquared()))
27892 clipPad = qMax(clipPad, (
double)
mainPen().widthF());
27895 if (!line.isNull())
27899 painter->setBrush(Qt::SolidPattern);
27901 mTail.
draw(painter, startVec, startVec-endVec);
27903 mHead.
draw(painter, endVec, endVec-startVec);
27916 bool containsStart = rect.contains(start.
x(), start.
y());
27917 bool containsEnd = rect.contains(end.
x(), end.
y());
27918 if (containsStart && containsEnd)
27926 QList<QCPVector2D> pointVectors;
27928 if (!qFuzzyIsNull(vec.
y()))
27933 mu = (by-base.y())/vec.
y();
27934 if (mu >= 0 && mu <= 1)
27936 gamma = base.x()-bx + mu*vec.
x();
27937 if (gamma >= 0 && gamma <= rect.width())
27942 by = rect.bottom();
27943 mu = (by-base.y())/vec.
y();
27944 if (mu >= 0 && mu <= 1)
27946 gamma = base.x()-bx + mu*vec.
x();
27947 if (gamma >= 0 && gamma <= rect.width())
27951 if (!qFuzzyIsNull(vec.
x()))
27956 mu = (bx-base.x())/vec.
x();
27957 if (mu >= 0 && mu <= 1)
27959 gamma = base.y()-by + mu*vec.
y();
27960 if (gamma >= 0 && gamma <= rect.height())
27966 mu = (bx-base.x())/vec.
x();
27967 if (mu >= 0 && mu <= 1)
27969 gamma = base.y()-by + mu*vec.
y();
27970 if (gamma >= 0 && gamma <= rect.height())
27976 pointVectors.append(start);
27978 pointVectors.append(end);
27981 if (pointVectors.size() == 2)
27983 result.setPoints(pointVectors.at(0).toPointF(), pointVectors.at(1).toPointF());
27984 }
else if (pointVectors.size() > 2)
27987 double distSqrMax = 0;
27989 for (
int i=0; i<pointVectors.size()-1; ++i)
27991 for (
int k=i+1; k<pointVectors.size(); ++k)
27993 double distSqr = (pointVectors.at(i)-pointVectors.at(k)).lengthSquared();
27994 if (distSqr > distSqrMax)
27996 pv1 = pointVectors.at(i);
27997 pv2 = pointVectors.at(k);
27998 distSqrMax = distSqr;
28061 setPen(QPen(Qt::black));
28127 QPainterPath cubicPath(startVec);
28128 cubicPath.cubicTo(startDirVec, endDirVec, endVec);
28130 QPolygonF polygon = cubicPath.toSubpathPolygons().first();
28132 double minDistSqr = std::numeric_limits<double>::max();
28133 for (
int i=1; i<polygon.size(); ++i)
28136 if (distSqr < minDistSqr)
28137 minDistSqr = distSqr;
28139 return qSqrt(minDistSqr);
28149 if ((endVec-startVec).length() > 1e10)
28152 QPainterPath cubicPath(startVec.toPointF());
28153 cubicPath.cubicTo(startDirVec.toPointF(), endDirVec.toPointF(), endVec.toPointF());
28157 QRect cubicRect = cubicPath.controlPointRect().toRect();
28158 if (cubicRect.isEmpty())
28159 cubicRect.adjust(0, 0, 1, 1);
28160 if (clip.intersects(cubicRect))
28163 painter->drawPath(cubicPath);
28164 painter->setBrush(Qt::SolidPattern);
28166 mTail.
draw(painter, startVec, M_PI-cubicPath.angleAtPercent(0)/180.0*M_PI);
28168 mHead.
draw(painter, endVec, -cubicPath.angleAtPercent(1)/180.0*M_PI);
28210 topRight(
createAnchor(QLatin1String(
"topRight"), aiTopRight)),
28212 bottom(
createAnchor(QLatin1String(
"bottom"), aiBottom)),
28213 bottomLeft(
createAnchor(QLatin1String(
"bottomLeft"), aiBottomLeft)),
28219 setPen(QPen(Qt::black));
28279 bool filledRect =
mBrush.style() != Qt::NoBrush &&
mBrush.color().alpha() != 0;
28288 if (p1.toPoint() == p2.toPoint())
28290 QRectF rect = QRectF(p1, p2).normalized();
28291 double clipPad =
mainPen().widthF();
28292 QRectF boundingRect = rect.adjusted(-clipPad, -clipPad, clipPad, clipPad);
28293 if (boundingRect.intersects(
clipRect()))
28297 painter->drawRect(rect);
28307 case aiTop:
return (rect.topLeft()+rect.topRight())*0.5;
28309 case aiRight:
return (rect.topRight()+rect.bottomRight())*0.5;
28310 case aiBottom:
return (rect.bottomLeft()+rect.bottomRight())*0.5;
28312 case aiLeft:
return (rect.topLeft()+rect.bottomLeft())*0.5;
28315 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
28379 mText(QLatin1String(
"text")),
28380 mPositionAlignment(Qt::AlignCenter),
28381 mTextAlignment(Qt::AlignTop|Qt::AlignHCenter),
28542 QTransform inputTransform;
28543 inputTransform.translate(positionPixels.x(), positionPixels.y());
28545 inputTransform.translate(-positionPixels.x(), -positionPixels.y());
28546 QPointF rotatedPos = inputTransform.map(pos);
28547 QFontMetrics fontMetrics(
mFont);
28548 QRect textRect = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip|
mTextAlignment,
mText);
28551 textBoxRect.moveTopLeft(textPos.toPoint());
28560 QTransform transform = painter->transform();
28561 transform.translate(pos.x(), pos.y());
28565 QRect textRect = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip|
mTextAlignment,
mText);
28568 textRect.moveTopLeft(textPos.toPoint()+QPoint(
mPadding.left(),
mPadding.top()));
28569 textBoxRect.moveTopLeft(textPos.toPoint());
28570 double clipPad =
mainPen().widthF();
28571 QRect boundingRect = textBoxRect.adjusted(-clipPad, -clipPad, clipPad, clipPad);
28572 if (transform.mapRect(boundingRect).intersects(painter->transform().mapRect(
clipRect())))
28574 painter->setTransform(transform);
28580 painter->drawRect(textBoxRect);
28582 painter->setBrush(Qt::NoBrush);
28593 QTransform transform;
28594 transform.translate(pos.x(), pos.y());
28597 QFontMetrics fontMetrics(
mainFont());
28598 QRect textRect = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip|
mTextAlignment,
mText);
28601 textBoxRect.moveTopLeft(textPos.toPoint());
28602 QPolygonF rectPoly = transform.map(QPolygonF(textBoxRect));
28607 case aiTop:
return (rectPoly.at(0)+rectPoly.at(1))*0.5;
28609 case aiRight:
return (rectPoly.at(1)+rectPoly.at(2))*0.5;
28611 case aiBottom:
return (rectPoly.at(2)+rectPoly.at(3))*0.5;
28613 case aiLeft:
return (rectPoly.at(3)+rectPoly.at(0))*0.5;
28616 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
28632 if (positionAlignment == 0 || positionAlignment == (Qt::AlignLeft|Qt::AlignTop))
28635 QPointF result = pos;
28636 if (positionAlignment.testFlag(Qt::AlignHCenter))
28637 result.rx() -= rect.width()/2.0;
28638 else if (positionAlignment.testFlag(Qt::AlignRight))
28639 result.rx() -= rect.width();
28640 if (positionAlignment.testFlag(Qt::AlignVCenter))
28641 result.ry() -= rect.height()/2.0;
28642 else if (positionAlignment.testFlag(Qt::AlignBottom))
28643 result.ry() -= rect.height();
28714 topLeftRim(
createAnchor(QLatin1String(
"topLeftRim"), aiTopLeftRim)),
28716 topRightRim(
createAnchor(QLatin1String(
"topRightRim"), aiTopRightRim)),
28718 bottomRightRim(
createAnchor(QLatin1String(
"bottomRightRim"), aiBottomRightRim)),
28720 bottomLeftRim(
createAnchor(QLatin1String(
"bottomLeftRim"), aiBottomLeftRim)),
28722 center(
createAnchor(QLatin1String(
"center"), aiCenter))
28727 setPen(QPen(Qt::black));
28788 QPointF
center((p1+p2)/2.0);
28789 double a = qAbs(p1.x()-p2.x())/2.0;
28790 double b = qAbs(p1.y()-p2.y())/2.0;
28791 double x = pos.x()-center.x();
28792 double y = pos.y()-center.y();
28795 double c = 1.0/qSqrt(x*x/(a*a)+y*y/(b*b));
28796 double result = qAbs(c-1)*qSqrt(x*x+y*y);
28800 if (x*x/(a*a) + y*y/(b*b) <= 1)
28811 if (p1.toPoint() == p2.toPoint())
28813 QRectF ellipseRect = QRectF(p1, p2).normalized();
28815 if (ellipseRect.intersects(clip))
28819 #ifdef __EXCEPTIONS 28823 painter->drawEllipse(ellipseRect);
28824 #ifdef __EXCEPTIONS 28827 qDebug() << Q_FUNC_INFO <<
"Item too large for memory, setting invisible";
28840 case aiTopLeftRim:
return rect.center()+(rect.topLeft()-rect.center())*1/qSqrt(2);
28841 case aiTop:
return (rect.topLeft()+rect.topRight())*0.5;
28842 case aiTopRightRim:
return rect.center()+(rect.topRight()-rect.center())*1/qSqrt(2);
28843 case aiRight:
return (rect.topRight()+rect.bottomRight())*0.5;
28844 case aiBottomRightRim:
return rect.center()+(rect.bottomRight()-rect.center())*1/qSqrt(2);
28845 case aiBottom:
return (rect.bottomLeft()+rect.bottomRight())*0.5;
28846 case aiBottomLeftRim:
return rect.center()+(rect.bottomLeft()-rect.center())*1/qSqrt(2);
28847 case aiLeft:
return (rect.topLeft()+rect.bottomLeft())*0.5;
28848 case aiCenter:
return (rect.topLeft()+rect.bottomRight())*0.5;
28851 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
28909 topRight(
createAnchor(QLatin1String(
"topRight"), aiTopRight)),
28912 bottomLeft(
createAnchor(QLatin1String(
"bottomLeft"), aiBottomLeft)),
28915 mScaledPixmapInvalidated(true),
28916 mAspectRatioMode(Qt::KeepAspectRatio),
28917 mTransformationMode(Qt::SmoothTransformation)
28938 qDebug() << Q_FUNC_INFO <<
"pixmap is null";
28986 bool flipHorz =
false;
28987 bool flipVert =
false;
28989 double clipPad =
mainPen().style() == Qt::NoPen ? 0 :
mainPen().widthF();
28990 QRect boundingRect = rect.adjusted(-clipPad, -clipPad, clipPad, clipPad);
28991 if (boundingRect.intersects(
clipRect()))
28996 if (pen.style() != Qt::NoPen)
28999 painter->setBrush(Qt::NoBrush);
29000 painter->drawRect(rect);
29014 rect.adjust(rect.width(), 0, -rect.width(), 0);
29016 rect.adjust(0, rect.height(), 0, -rect.height());
29020 case aiTop:
return (rect.topLeft()+rect.topRight())*0.5;
29022 case aiRight:
return (rect.topRight()+rect.bottomRight())*0.5;
29023 case aiBottom:
return (rect.bottomLeft()+rect.bottomRight())*0.5;
29025 case aiLeft:
return (rect.topLeft()+rect.bottomLeft())*0.5;;
29028 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
29052 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 29053 double devicePixelRatio =
mPixmap.devicePixelRatio();
29055 double devicePixelRatio = 1.0;
29057 if (finalRect.isNull())
29062 if (flipHorz || flipVert)
29064 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 29090 bool flipHorz =
false;
29091 bool flipVert =
false;
29095 return QRect(p1, QSize(0, 0));
29098 QSize newSize = QSize(p2.x()-p1.x(), p2.y()-p1.y());
29100 if (newSize.width() < 0)
29103 newSize.rwidth() *= -1;
29104 topLeft.setX(p2.x());
29106 if (newSize.height() < 0)
29109 newSize.rheight() *= -1;
29110 topLeft.setY(p2.y());
29112 QSize scaledSize =
mPixmap.size();
29113 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 29114 scaledSize /=
mPixmap.devicePixelRatio();
29119 result = QRect(topLeft, scaledSize);
29122 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 29125 result = QRect(p1,
mPixmap.size());
29129 *flippedHorz = flipHorz;
29131 *flippedVert = flipVert;
29194 mStyle(tsCrosshair),
29197 mInterpolating(false)
29203 setPen(QPen(Qt::black));
29292 qDebug() << Q_FUNC_INFO <<
"graph isn't in same QCustomPlot instance as this item";
29337 double w =
mSize/2.0;
29344 if (
clipRect().intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29345 return qSqrt(qMin(
QCPVector2D(pos).distanceSquaredToLine(center+QPointF(-w, 0), center+QPointF(w, 0)),
29346 QCPVector2D(pos).distanceSquaredToLine(center+QPointF(0, -w), center+QPointF(0, w))));
29356 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29360 double circleLine = w;
29361 double result = qAbs(centerDist-circleLine);
29365 if (centerDist <= circleLine)
29374 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29376 QRectF rect = QRectF(center-QPointF(w, w), center+QPointF(w, w));
29377 bool filledRect =
mBrush.style() != Qt::NoBrush &&
mBrush.color().alpha() != 0;
29396 double w =
mSize/2.0;
29403 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29405 painter->
drawLine(QLineF(center+QPointF(-w, 0), center+QPointF(w, 0)));
29406 painter->
drawLine(QLineF(center+QPointF(0, -w), center+QPointF(0, w)));
29412 if (center.y() > clip.top() && center.y() < clip.bottom())
29413 painter->
drawLine(QLineF(clip.left(), center.y(), clip.right(), center.y()));
29414 if (center.x() > clip.left() && center.x() < clip.right())
29415 painter->
drawLine(QLineF(center.x(), clip.top(), center.x(), clip.bottom()));
29420 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29421 painter->drawEllipse(center, w, w);
29426 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29427 painter->drawRect(QRectF(center-QPointF(w, w), center+QPointF(w, w)));
29455 if (mGraphKey <= first->key)
29470 if (!qFuzzyCompare((
double)it->key, (
double)prevIt->key))
29471 slope = (it->value-prevIt->value)/(it->key-prevIt->key);
29476 if (
mGraphKey < (prevIt->key+it->key)*0.5)
29489 qDebug() << Q_FUNC_INFO <<
"graph has no data";
29491 qDebug() << Q_FUNC_INFO <<
"graph not contained in QCustomPlot instance (anymore)";
29554 center(
createAnchor(QLatin1String(
"center"), aiCenter)),
29561 setPen(QPen(Qt::black));
29626 if (leftVec.toPoint() == rightVec.toPoint())
29631 QCPVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec;
29641 return qSqrt(qMin(qMin(a, b), c));
29646 double a = p.
distanceSquaredToLine(centerVec-widthVec*0.75+lengthVec*0.15, centerVec+lengthVec*0.3);
29647 double b = p.
distanceSquaredToLine(centerVec-widthVec+lengthVec*0.7, centerVec-widthVec*0.75+lengthVec*0.15);
29648 double c = p.
distanceSquaredToLine(centerVec+widthVec*0.75+lengthVec*0.15, centerVec+lengthVec*0.3);
29649 double d = p.
distanceSquaredToLine(centerVec+widthVec+lengthVec*0.7, centerVec+widthVec*0.75+lengthVec*0.15);
29650 return qSqrt(qMin(qMin(a, b), qMin(c, d)));
29661 if (leftVec.toPoint() == rightVec.toPoint())
29666 QCPVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec;
29668 QPolygon boundingPoly;
29669 boundingPoly << leftVec.
toPoint() << rightVec.toPoint()
29670 << (rightVec-lengthVec).toPoint() << (leftVec-lengthVec).toPoint();
29672 if (clip.intersects(boundingPoly.boundingRect()))
29679 painter->
drawLine((centerVec+widthVec).toPointF(), (centerVec-widthVec).toPointF());
29680 painter->
drawLine((centerVec+widthVec).toPointF(), (centerVec+widthVec+lengthVec).toPointF());
29681 painter->
drawLine((centerVec-widthVec).toPointF(), (centerVec-widthVec+lengthVec).toPointF());
29686 painter->setBrush(Qt::NoBrush);
29688 path.moveTo((centerVec+widthVec+lengthVec).toPointF());
29689 path.cubicTo((centerVec+widthVec).toPointF(), (centerVec+widthVec).toPointF(), centerVec.
toPointF());
29690 path.cubicTo((centerVec-widthVec).toPointF(), (centerVec-widthVec).toPointF(), (centerVec-widthVec+lengthVec).toPointF());
29691 painter->drawPath(path);
29696 painter->setBrush(Qt::NoBrush);
29698 path.moveTo((centerVec+widthVec+lengthVec).toPointF());
29699 path.cubicTo((centerVec+widthVec-lengthVec*0.8).toPointF(), (centerVec+0.4*widthVec+lengthVec).toPointF(), centerVec.
toPointF());
29700 path.cubicTo((centerVec-0.4*widthVec+lengthVec).toPointF(), (centerVec-widthVec-lengthVec*0.8).toPointF(), (centerVec-widthVec+lengthVec).toPointF());
29701 painter->drawPath(path);
29706 painter->
setPen(Qt::NoPen);
29707 painter->setBrush(QBrush(
mainPen().color()));
29709 path.moveTo((centerVec+widthVec+lengthVec).toPointF());
29711 path.cubicTo((centerVec+widthVec-lengthVec*0.8).toPointF(), (centerVec+0.4*widthVec+0.8*lengthVec).toPointF(), centerVec.
toPointF());
29712 path.cubicTo((centerVec-0.4*widthVec+0.8*lengthVec).toPointF(), (centerVec-widthVec-lengthVec*0.8).toPointF(), (centerVec-widthVec+lengthVec).toPointF());
29714 path.cubicTo((centerVec-widthVec-lengthVec*0.5).toPointF(), (centerVec-0.2*widthVec+1.2*lengthVec).toPointF(), (centerVec+lengthVec*0.2).toPointF());
29715 path.cubicTo((centerVec+0.2*widthVec+1.2*lengthVec).toPointF(), (centerVec+widthVec-lengthVec*0.5).toPointF(), (centerVec+widthVec+lengthVec).toPointF());
29717 painter->drawPath(path);
29729 if (leftVec.toPoint() == rightVec.toPoint())
29734 QCPVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec;
29741 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
double devicePixelRatio() const
double pointDistance(const QPointF &pixelPoint, QCPGraphDataContainer::const_iterator &closestData) const
QList< QList< QCPLayoutElement * > > mElements
QSharedPointer< QCPCurveDataContainer > data() const
QCP::AntialiasedElements mNotAADragBackup
double cleanMantissa(double input) const
void setType(PositionType type)
QCPLayoutElement(QCustomPlot *parentPlot=0)
QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale)
void itemClick(QCPAbstractItem *item, QMouseEvent *event)
void drawSubGridLines(QCPPainter *painter) const
Q_SLOT void setSelection(QCPDataSelection selection)
QList< QSharedPointer< QCPAbstractPaintBuffer > > mPaintBuffers
void addElement(QCPLayoutElement *element, Qt::Alignment alignment)
QCPItemPosition * position(const QString &name) const
void insertRow(int newIndex)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QVector< QPointF > dataToStepLeftLines(const QVector< QCPGraphData > &data) const
A margin group allows synchronization of margin sides if working with multiple layout elements...
One individual data point can be selected at a time.
QList< QCPGraph * > mGraphs
QCPGraph * addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0)
virtual ~QCPAxisPainterPrivate()
Holds the data of one single error bar for QCPErrorBars.
QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis)
void setSubTickLengthIn(int inside)
void setMargins(const QMargins &margins)
0x04 Turns pen widths 0 to 1, i.e. disables cosmetic pens. (A cosmetic pen is always drawn with width...
void setBracketBrush(const QBrush &brush)
QCPDataRange intersection(const QCPDataRange &other) const
bool stopsUseAlpha() const
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QList< QCPLayoutElement * > elements(QCP::MarginSide side) const
void setWhiskerBarPen(const QPen &pen)
double bufferDevicePixelRatio() const
bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
void setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, bool enabled=true)
Qt::Orientations mRangeDrag
A plus shaped crosshair which spans the complete axis rect.
virtual void updateLayout()
static const double maxRange
void setPeriodic(bool enabled)
void setLevelCount(int n)
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
QRgb color(double position, const QCPRange &range, bool logarithmic=false)
void setBracketWidth(int width)
void setTimeFormat(const QString &format)
void setInsetPlacement(int index, InsetPlacement placement)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Q_SLOT void axisSelectableChanged(QCPAxis::SelectableParts selectableParts)
bool isInvalidData(double value)
virtual QVector< double > createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE
virtual void updateMapImage()
QSharedPointer< QCPDataContainer< QCPGraphData > > mDataContainer
virtual int elementCount() const Q_DECL_OVERRIDE
void setTickOrigin(double origin)
void setScatterStyle(const QCPScatterStyle &scatterStyle, QCPScatterStyle::ScatterProperties usedProperties=QCPScatterStyle::spPen)
QCPColorGradient gradient() const
QCPAxis * rangeZoomAxis(Qt::Orientation orientation)
void setLowerEnding(const QCPLineEnding &ending)
Open-High-Low-Close bar representation.
An ellipse is drawn. The size of the ellipse is given by the bracket width/height properties...
bool clipToAxisRect() const
bool registerGraph(QCPGraph *graph)
QCPAxisRect * axisRectAt(const QPointF &pos) const
void setBackgroundScaledMode(Qt::AspectRatioMode mode)
QCPItemPosition *const end
Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpRefreshHint)
void plottableDoubleClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event)
void updateAxesOffset(QCPAxis::AxisType type)
QCPVector2D & operator+=(const QCPVector2D &vector)
QCPColorMapData * mMapData
QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlottable *plottable)
virtual void draw(QCPPainter *painter)
int plottableCount() const
QCPLayout * mParentLayout
virtual int calculateAutoMargin(QCP::MarginSide side) Q_DECL_OVERRIDE
double cell(int keyIndex, int valueIndex)
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
void dataRangeChanged(const QCPRange &newRange)
void setMinimumMargins(const QMargins &margins)
virtual void drawDecoration(QCPPainter *painter, QCPDataSelection selection)
The base class tick generator used by QCPAxis to create tick positions and tick labels.
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
QCPAxis(QCPAxisRect *parent, AxisType type)
void setScaleRatio(const QCPAxis *otherAxis, double ratio=1.0)
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE
PainterModes modes() const
QCPRange dataRange() const
void setBrush(const QBrush &brush)
void applyPen(QCPPainter *painter) const
Fractions are written using sub- and superscript UTF-8 digits and the fraction symbol.
virtual void reallocateBuffer()=0
void setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, bool enabled=true)
void setTickOrigin(double origin)
void setKeySize(int keySize)
The abstract base class for paint buffers, which define the rendering backend.
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
virtual QCPLayoutElement * elementAt(int index) const Q_DECL_OVERRIDE
void remove(QCPBars *bars)
QCP::AntialiasedElements antialiasedElements() const
QCPDataSelection selection() const
void setMaximumSize(const QSize &size)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Color channels hue, saturation and value are linearly interpolated (The hue is interpolated over the ...
void setDevicePixelRatio(double ratio)
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Holds the data of one single data point for QCPCurve.
void mouseMove(QMouseEvent *event)
QCPRange keyRange() const
No line is drawn between data points (e.g. only scatters)
QCustomPlot(QWidget *parent=0)
QList< QCPDataRange > dataRanges() const
void setParentLayerable(QCPLayerable *parentLayerable)
QCPItemBracket(QCustomPlot *parentPlot)
QCPLineEnding tail() const
void rescaleKeyAxis(bool onlyEnlarge=false) const
void addData(const QVector< double > &keys, const QVector< double > &values, bool alreadySorted=false)
bool mNumberBeautifulPowers
QCPItemAnchor *const center
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE
A legend item representing a plottable with an icon and the plottable name.
QHash< QCP::MarginSide, QCPMarginGroup * > mMarginGroups
Bar spacing is given by a fraction of the axis rect size.
bool antialiasing() const
virtual double dataMainValue(int index) const =0
void setType(QCPAxis::AxisType type)
void setIconTextPadding(int padding)
each data point is represented by a line parallel to the value axis, which reaches from the data poin...
QCPItemPosition *const start
void selectionChanged(bool selected)
int numberPrecision() const
virtual bool sortKeyIsMainKey() const
virtual QList< QCPLayoutElement * > elements(bool recursive) const
void expandTo(int newRowCount, int newColumnCount)
SelectableParts selectedParts() const
virtual void reallocateBuffer() Q_DECL_OVERRIDE
virtual void drawFill(QCPPainter *painter, QVector< QPointF > *lines) const
QByteArray mLabelParameterHash
0x01 Mode for vectorized painting (e.g. PDF export). For example, this prevents some antialiasing fix...
void applyBrush(QCPPainter *painter) const
void setMedianPen(const QPen &pen)
QCPRange bounded(double lowerBound, double upperBound) const
QList< QCPAbstractPlottable * > selectedPlottables() const
void selectionChanged(bool selected)
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
Q_SLOT bool setLayer(QCPLayer *layer)
QList< QCPGraph * > graphs() const
QCPAbstractPlottable * plottable()
bool contains(double value) const
bool registerPlottable(QCPAbstractPlottable *plottable)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
The axis backbone and tick marks.
void setTickStepStrategy(TickStepStrategy strategy)
Fractions are displayed as regular decimal floating point numbers, e.g. "0.25" or "0...
double realLength() const
QCPLineEnding lowerEnding
static double dateTimeToKey(const QDateTime dateTime)
The errors are for the key dimension (bars appear parallel to the key axis)
EndingStyle style() const
Bar spacing is in key coordinates and thus scales with the key axis range.
QCPItemAnchor * anchor(const QString &name) const
void drawGridLines(QCPPainter *painter) const
void setSpacingType(SpacingType spacingType)
void setSelectedTickLabelFont(const QFont &font)
void setOffset(int offset)
QColor mSelectedTickLabelColor
virtual void wheelEvent(QWheelEvent *event)
void setBasePen(const QPen &pen)
bool hasPlottable(QCPAbstractPlottable *plottable) const
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
void addData(const QVector< double > &t, const QVector< double > &keys, const QVector< double > &values, bool alreadySorted=false)
void setVisible(bool visible)
The tracer is not visible.
Controls how a plottable's data selection is drawn.
void simplifyFraction(int &numerator, int &denominator) const
void setSelectedBorderPen(const QPen &pen)
void zoom(const QRectF &pixelRect)
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
void setErrorType(ErrorType type)
virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE
void setPixmap(const QPixmap &pixmap)
QColor getTickLabelColor() const
virtual void updateLayout() Q_DECL_OVERRIDE
QCPItemPosition *const topLeft
SelectableParts mSelectedParts
QList< QCPLayerable * > layerableListAt(const QPointF &pos, bool onlySelectable, QList< QVariant > *selectionDetails=0) const
custom painter operations are performed per scatter (As QPainterPath, see setCustomPath) ...
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
The abstract base class for all entries in a QCPLegend.
0x08 The shape property, see setShape
void getVisibleDataBounds(QCPErrorBarsDataContainer::const_iterator &begin, QCPErrorBarsDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const
bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const
QFont mSelectedTickLabelFont
void setHead(const QCPLineEnding &head)
double ohlcSelectTest(const QPointF &pos, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, QCPFinancialDataContainer::const_iterator &closestDataPoint) const
bool remove(QCPLayoutElement *element)
{ssPeace.png} a circle, with one vertical and two downward diagonal lines
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Queues the entire replot for the next event loop iteration. This way multiple redundant replots can b...
Tick labels (numbers) of this axis (as a whole, not individually)
bool mAntialiasedZeroLine
void setStyle(BracketStyle style)
virtual void draw(QCPPainter *painter)
void setSubTickCount(int subTicks)
void itemDoubleClick(QCPAbstractItem *item, QMouseEvent *event)
QString fractionToString(int numerator, int denominator) const
An integer multiple of the specified tick step is allowed. The used factor follows the base class pro...
QColor getTextColor() const
void getVisibleDataBounds(QCPBarsDataContainer::const_iterator &begin, QCPBarsDataContainer::const_iterator &end) const
QColor mSelectedTextColor
double dot(const QCPVector2D &vec) const
void addChild(QCPLayerable *layerable, bool prepend)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setPenPositive(const QPen &pen)
static AxisType marginSideToAxisType(QCP::MarginSide side)
0x0001 Axis base line and tick marks
QCPItemAnchor * createAnchor(const QString &name, int anchorId)
Q_SLOT void setDataRange(const QCPRange &dataRange)
void setScatterSkip(int skip)
void setName(const QString &name)
QPainterPath customPath() const
void setRowStretchFactors(const QList< double > &factors)
void setRangeReversed(bool reversed)
QPointF getOptimizedPoint(int prevRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const
QCP::SelectionType selectable() const
QPointF upperFillBasePoint(double upperKey) const
void setStackingGap(double pixels)
void setSelectedBasePen(const QPen &pen)
double getTangentAngle(const QCPPlottableInterface1D *interface1d, int dataIndex, int direction) const
Responsible for drawing the grid of a QCPAxis.
Qt::Alignment positionAlignment() const
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
0x001 Axis ranges are draggable (see QCPAxisRect::setRangeDrag, QCPAxisRect::setRangeDragAxes) ...
QCPItemAnchor * parentAnchor() const
void setTangentToData(bool enabled)
QVector< QString > tickLabels
void getTraverseCornerPoints(int prevRegion, int currentRegion, double keyMin, double valueMax, double keyMax, double valueMin, QVector< QPointF > &beforeTraverse, QVector< QPointF > &afterTraverse) const
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
void setWhiskerWidth(double width)
void setPen(const QPen &pen)
void changed(const QRect &rect, QMouseEvent *event)
void setTextAlignment(Qt::Alignment alignment)
void gradientChanged(const QCPColorGradient &newGradient)
const QCPRange range() const
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
void dataRangeChanged(const QCPRange &newRange)
width is in key coordinates and thus scales with the key axis range
QCPColorGradient mGradient
void setTicker(QSharedPointer< QCPAxisTicker > ticker)
QList< QCPGraph * > graphs() const
Defines an abstract interface for one-dimensional plottables.
void setSelectedSubTickPen(const QPen &pen)
void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
int dataPointCount() const
QSharedPointer< QCPStatisticalBoxDataContainer > data() const
The selection rect is disabled, and all mouse events are forwarded to the underlying objects...
QCPColorMapData * data() const
bool noAntialiasingOnDrag() const
QRect axisSelectionBox() const
Provides rect/rubber-band data selection and range zoom interaction.
void setCustomPath(const QPainterPath &customPath)
void getCurveLines(QVector< QPointF > *lines, const QCPDataRange &dataRange, double penWidth) const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Fractions are written as rationals using ASCII characters only, e.g. "1/4" or "1/8".
double rectDistance(const QRectF &rect, const QPointF &pos, bool filledRect) const
QList< QCPItemPosition * > mPositions
virtual void drawBracket(QCPPainter *painter, int direction) const
void setShape(ScatterShape shape)
QCP::PlottingHints plottingHints() const
QCustomPlot * mParentPlot
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setBackgroundScaled(bool scaled)
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
Colors suitable for thermal imaging, ranging from dark blue over purple to orange, yellow and white.
void drawOhlcPlot(QCPPainter *painter, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, bool isSelected)
void setTickLabels(bool show)
An anchor of an item to which positions can be attached to.
A square bracket is drawn.
bool addToLegend(QCPLegend *legend)
ScaleStrategy mScaleStrategy
void setSelectedPen(const QPen &pen)
Qt::Orientations mRangeZoom
void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
void enforceType(QCP::SelectionType type)
void setBrush(const QBrush &brush)
void setData(QSharedPointer< QCPErrorBarsDataContainer > data)
void getVisibleDataBounds(QCPGraphDataContainer::const_iterator &begin, QCPGraphDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const
QCPScatterStyle mScatterStyle
virtual QList< QCPLayoutElement * > elements(bool recursive) const Q_DECL_OVERRIDE
void axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
QCPAxis * keyAxis() const
Phase in which the margins are calculated and set.
Q_SLOT void setSelectableParts(const QCPAxis::SelectableParts &selectableParts)
void setSelectedIconBorderPen(const QPen &pen)
Static positioning in pixels, starting from the top left corner of the viewport/widget.
void setAntialiasedScatters(bool enabled)
void setRangeZoom(Qt::Orientations orientations)
virtual QRect clipRect() const Q_DECL_OVERRIDE
QCPItemRect(QCustomPlot *parentPlot)
QCPItemAnchor * mParentAnchorX
void indexToRowCol(int index, int &row, int &column) const
QCache< QString, CachedLabel > mLabelCache
void mouseRelease(QMouseEvent *event)
A brace with angled edges.
void setSelectedPen(const QPen &pen)
QCPItemPosition *const right
void setWhiskerPen(const QPen &pen)
void setAdaptiveSampling(bool enabled)
int findIndexAboveY(const QVector< QPointF > *data, double y) const
void getScatters(QVector< QPointF > *scatters, const QCPDataRange &dataRange, double scatterWidth) const
QVector< double > subTickPositions
void rangeChanged(const QCPRange &newRange)
void setSelectionDecorator(QCPSelectionDecorator *decorator)
virtual QList< QCPLayoutElement * > elements(bool recursive) const Q_DECL_OVERRIDE
A plus shaped crosshair with limited size.
void rescaleDataRange(bool onlyVisibleMaps)
void mouseDoubleClick(QMouseEvent *event)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const
void setupFullAxesBox(bool connectRanges=false)
void setText(const QString &text)
QCPItemLine(QCustomPlot *parentPlot)
void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical)
Q_SLOT void setSelectableParts(const SelectableParts &selectableParts)
QCPAxis * addAxis(QCPAxis::AxisType type, QCPAxis *axis=0)
double tickLabelRotation() const
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
QCPLineEnding head() const
void setFromOther(const QCPScatterStyle &other, ScatterProperties properties)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
static bool validRange(double lower, double upper)
Base class for all drawable objects.
QPixmap mBackgroundPixmap
void setInterpolating(bool enabled)
virtual int findBegin(double sortKey, bool expandedRange=true) const
void setValueAxis(QCPAxis *axis)
QSharedPointer< QCPAxisTicker > ticker() const
double distanceSquaredToLine(const QCPVector2D &start, const QCPVector2D &end) const
bool mGradientImageInvalidated
void setBackground(const QPixmap &pm)
double getPixelSpacing(const QCPBars *bars, double keyCoord)
void setPadding(int padding)
bool removeFromLegend(QCPLegend *legend) const
virtual Q_SLOT void processRectSelection(QRect rect, QMouseEvent *event)
A plottable representing a bar chart in a plot.
const QCP::Interactions interactions() const
virtual QCPPlottableInterface1D * interface1D()
bool removeGraph(QCPGraph *graph)
QVector< double > mTickVector
void setRange(const QCPRange &keyRange, const QCPRange &valueRange)
void setBrush(const QBrush &brush)
0x080 All other objects are selectable (e.g. your own derived layerables, other layout elements...
QList< QCPAbstractPlottable * > plottables() const
virtual void layoutChanged() Q_DECL_OVERRIDE
void setCoords(double key, double value)
void addChild(QCP::MarginSide side, QCPLayoutElement *element)
void colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false)
0x0080 Scatter symbols of plottables (excluding scatter symbols of type ssPixmap) ...
friend class QCPItemAnchor
Q_SLOT void setSelectable(bool selectable)
void setWidth(double width)
void loadPreset(GradientPreset preset)
void moveAbove(QCPBars *bars)
void addFillBasePoints(QVector< QPointF > *lines) const
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setSize(int keySize, int valueSize)
void moveBelow(QCPBars *bars)
QSharedPointer< QCPFinancialDataContainer > data() const
void setScatterStyle(const QCPScatterStyle &style)
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
void setInteraction(const QCP::Interaction &interaction, bool enabled=true)
virtual void simplify() Q_DECL_OVERRIDE
void setRangeUpper(double upper)
virtual ~QCPMarginGroup()
void setModes(PainterModes modes)
virtual QPointF pixelPosition() const
void setData(QSharedPointer< QCPBarsDataContainer > data)
QCPItemTracer(QCustomPlot *parentPlot)
virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos)
void recalculateDataBounds()
double getPixelWidth(double key, double keyPixel) const
bool contains(const QCPDataSelection &other) const
QColor mSelectedTextColor
virtual QRect clipRect() const
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
bool mScaledPixmapInvalidated
virtual QCP::Interaction selectionCategory() const
void trimTicks(const QCPRange &range, QVector< double > &ticks, bool keepOneOutlier) const
void layerChanged(QCPLayer *newLayer)
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
bool addElement(int row, int column, QCPLayoutElement *element)
void setStyle(EndingStyle style)
QPointer< QCPBars > mBarBelow
void setValueSize(int valueSize)
void addData(const QVector< double > &keys, const QVector< double > &minimum, const QVector< double > &lowerQuartile, const QVector< double > &median, const QVector< double > &upperQuartile, const QVector< double > &maximum, bool alreadySorted=false)
virtual ~QCPLayoutElement()
QList< QCPRange > mDragStartHorzRange
QList< QCPLayerable * > children() const
void setTickLabelRotation(double degrees)
QCPScatterStyle mScatterStyle
void setTypeX(PositionType type)
0x02 Mode for all sorts of exports (e.g. PNG, PDF,...). For example, this prevents using cached pixma...
QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis)
A layout that arranges child elements in a grid.
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
QCPVector2D & operator-=(const QCPVector2D &vector)
void setPen(const QPen &pen)
int pixelOrientation() const
void setFont(const QFont &font)
void setColor(const QColor &color)
bool registerItem(QCPAbstractItem *item)
virtual int findEnd(double sortKey, bool expandedRange=true) const
void selectionChangedByUser()
virtual bool take(QCPLayoutElement *element) Q_DECL_OVERRIDE
0x08 Axis is horizontal and on the bottom side of the axis rect
QPointer< QCPAbstractPlottable > mDataPlottable
double mBufferDevicePixelRatio
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
QPointer< QCPBars > mBarAbove
QCPScatterStyle mOutlierStyle
void setUpperEnding(const QCPLineEnding &ending)
void setPixmap(const QPixmap &pixmap)
void setWidth(double width)
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
Multiple contiguous data points (a data range) can be selected.
QCPItemText(QCustomPlot *parentPlot)
virtual bool registerWithPlottable(QCPAbstractPlottable *plottable)
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
void setUsedScatterProperties(const QCPScatterStyle::ScatterProperties &properties)
QList< QCPLayer * > mLayers
virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE
void setRangeDrag(Qt::Orientations orientations)
void setTangentAverage(int pointCount)
QCP::AntialiasedElements mNotAntialiasedElements
virtual void generate(const QCPRange &range, const QLocale &locale, QChar formatChar, int precision, QVector< double > &ticks, QVector< double > *subTicks, QVector< QString > *tickLabels)
virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE
QCPItemAnchor *const bottom
void setSize(const QSize &size)
QCPDataRange expanded(const QCPDataRange &other) const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
0x0040 Main lines of items
void removeChild(QCPLayerable *layerable)
QCPAxisRect * axisRect() const
QImage mUndersampledMapImage
Represents two doubles as a mathematical 2D vector.
QCPVector2D perpendicular() const
Holds the data of one single data point for QCPGraph.
QCPDataSelection & operator-=(const QCPDataSelection &other)
no scatter symbols are drawn (e.g. in QCPGraph, data only represented with lines) ...
bool begin(QPaintDevice *device)
void setSelectedTextColor(const QColor &color)
virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE
virtual void drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const
virtual void placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize)
void updateScaledPixmap(QRect finalRect=QRect(), bool flipHorz=false, bool flipVert=false)
double getMantissa(double input, double *magnitude=0) const
QCPLineEnding upperEnding() const
The abstract base class for all data representing objects in a plot.
QCP::MarginSides mAutoMargins
FractionStyle mFractionStyle
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void selectionChanged(bool selected)
void setColorScale(QCPColorScale *colorScale)
bool saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
QCPScatterStyle outlierStyle() const
QCPColorGradient inverted() const
Hue variation similar to a spectrum, often used in numerical visualization (creates banding illusion ...
QRectF insetRect(int index) const
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void getScatters(QVector< QPointF > *scatters, const QCPDataRange &dataRange) const
QCPRange sanitizedForLogScale() const
void setSelectedBrush(const QBrush &brush)
void setBackground(const QPixmap &pm)
virtual QByteArray generateLabelParameterHash() const
void releaseElement(QCPLayoutElement *el)
void removeChildX(QCPItemPosition *pos)
virtual int dataCount() const
QCPItemAnchor *const left
QPointer< QCPAxis > mValueAxis
void setSubTickLengthOut(int outside)
virtual QSize sizeHint() const Q_DECL_OVERRIDE
void setAxes(QCPAxis *keyAxis, QCPAxis *valueAxis)
void setDateTimeFormat(const QString &format)
QList< QCPBars * > bars() const
QCPDataRange adjusted(int changeBegin, int changeEnd) const
QList< QPointer< QCPAxis > > mRangeDragVertAxis
virtual void drawImpulsePlot(QCPPainter *painter, const QVector< QPointF > &lines) const
void setTwoColored(bool twoColored)
QPointF lowerFillBasePoint(double lowerKey) const
QVector< QPointF > dataToStepRightLines(const QVector< QCPGraphData > &data) const
virtual void parentPlotInitialized(QCustomPlot *parentPlot) Q_DECL_OVERRIDE
bool moveToLayer(QCPLayer *layer, bool prepend)
QPointer< QCPAxis > mColorAxis
0x008 Plottables are selectable (e.g. graphs, curves, bars,... see QCPAbstractPlottable) ...
bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
void setSubGridPen(const QPen &pen)
virtual QSize minimumSizeHint() const
QList< QCPAbstractLegendItem * > selectedItems() const
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE
void setAntialiasedSubGrid(bool enabled)
Q_SLOT void setSelectable(QCP::SelectionType selectable)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const =0
virtual ~QCPItemStraightLine()
Tick labels will be displayed outside the axis rect.
QCPItemAnchor * parentAnchorY() const
Continuous lightness from black over icey colors to white (suited for non-biased data representation)...
void scaleRange(double factor)
line is drawn as steps where the step height is the value of the left data point
void selectionChanged(const QCPAxis::SelectableParts &parts)
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE
void plottableClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event)
virtual TickLabelData getTickLabelData(const QFont &font, const QString &text) const
QCPItemPosition *const endDir
Columns are filled first, and a new element is wrapped to the next row if the column count would exce...
QCPVector2D normalized() const
0x02 Axis is vertical and on the right side of the axis rect
An approximation of the visible light spectrum (creates banding illusion but allows more precise magn...
void setBackgroundScaled(bool scaled)
void setTickLabelFont(const QFont &font)
QCPItemPosition *const bottomRight
QList< QPointer< QCPAxis > > mRangeDragHorzAxis
QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange)
void setFieldWidth(TimeUnit unit, int width)
int subTickLengthIn() const
QCPColorGradient mGradient
void setTextColor(const QColor &color)
virtual ~QCPItemEllipse()
QList< QPointer< QCPAxis > > mRangeZoomVertAxis
Bar width is in absolute pixels.
int tickLengthOut() const
Qt::AspectRatioMode aspectRatioMode() const
void setSelectionRectMode(QCP::SelectionRectMode mode)
QList< QCPAxis * > axes() const
QCustomPlot * mParentPlot
bool removeLayer(QCPLayer *layer)
void setSelectedLabelFont(const QFont &font)
bool getTraverse(double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin, QPointF &crossA, QPointF &crossB) const
void setPiValue(double pi)
void getPixelWidth(double key, double &lower, double &upper) const
QCPColorScale * colorScale() const
A plottable representing a graph in a plot.
QCPAbstractPlottable * mPlottable
void applyFillAntialiasingHint(QCPPainter *painter) const
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
QCPItemPosition *const start
int iconTextPadding() const
The abstract base class for all items in a plot.
QCPAbstractLegendItem(QCPLegend *parent)
QCPLayoutInset * mInsetLayout
void setData(double key, double value, double z)
virtual QCPLayoutElement * takeAt(int index) Q_DECL_OVERRIDE
QVector< QPointF > dataToStepCenterLines(const QVector< QCPGraphData > &data) const
Q_SLOT void setSelectable(bool selectable)
void dataScaleTypeChanged(QCPAxis::ScaleType scaleType)
Q_SLOT void setGradient(const QCPColorGradient &gradient)
0x004 axis (tick) labels will be cached as pixmaps, increasing replot performance.
QRect tickLabelsSelectionBox() const
void setPadding(const QMargins &padding)
Logarithmic scaling with correspondingly transformed axis coordinates (possibly also setTicker to a Q...
Modifications are not allowed, the specified tick step is absolutely fixed. This might cause a high t...
QCPLegend * mParentLegend
QPointer< QCPAxis > mKeyAxis
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const =0
QVector< int > getSectionSizes(QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
virtual QSize maximumSizeHint() const
QRect mTickLabelsSelectionBox
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
void setRangeLower(double lower)
void setBrush(const QBrush &brush)
QCPItemCurve(QCustomPlot *parentPlot)
void setTickCount(int count)
QCPColorScale(QCustomPlot *parentPlot)
virtual void moveSelection(QMouseEvent *event)
QCPItemAnchor *const right
bool mNoAntialiasingOnDrag
QCPAbstractPaintBuffer * createPaintBuffer()
The central class of the library. This is the QWidget which displays the plot and interacts with the ...
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
virtual ~QCPPaintBufferPixmap()
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE
void setAntialiasing(bool enabled)
void setPen(const QPen &pen)
0x040 Items are selectable (Rectangles, Arrows, Textitems, etc. see QCPAbstractItem) ...
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Candlestick representation.
void setWidth(double width)
bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
int rowColToIndex(int row, int column) const
void getMinimumRowColSizes(QVector< int > *minColWidths, QVector< int > *minRowHeights) const
void setBrushNegative(const QBrush &brush)
TickStepStrategy mTickStepStrategy
Manages a single axis inside a QCustomPlot.
QCPLineEnding tail() const
QCPAxis::AxisType type() const
QCPBarsGroup * barsGroup() const
virtual void mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
bool isPenDefined() const
void drawLine(const QLineF &line)
QList< QCPAbstractItem * > selectedItems() const
double candlestickSelectTest(const QPointF &pos, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, QCPFinancialDataContainer::const_iterator &closestDataPoint) const
Half hue spectrum from black over purple to blue and finally green (creates banding illusion but allo...
void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical)
virtual int commonMargin(QCP::MarginSide side) const
void setTickPen(const QPen &pen)
Replots immediately, but queues the widget repaint, by calling QWidget::update() after the replot...
void applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
QHash< TimeUnit, QString > mFormatPattern
QCPColorScale * mParentColorScale
void setPen(const QPen &pen)
void setColorStops(const QMap< double, QColor > &colorStops)
QCPLayer * layer(const QString &name) const
A filled arrow head with a straight/flat back (a triangle)
PositionType type() const
virtual bool take(QCPLayoutElement *element) Q_DECL_OVERRIDE
int findIndexAboveX(const QVector< QPointF > *data, double x) const
Represents the visual appearance of scatter points.
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const
void setOutlierStyle(const QCPScatterStyle &style)
Manages a legend inside a QCustomPlot.
Layer is used only for rendering order, and shares paint buffer with all other adjacent logical layer...
QList< QCPLayerable * > mChildren
QSet< QCPItemPosition * > mChildrenY
void insert(int i, QCPBars *bars)
void setSelectionRect(QCPSelectionRect *selectionRect)
QCPLineEnding lowerEnding() const
QSharedPointer< QCPGraphDataContainer > data() const
void setCell(int keyIndex, int valueIndex, double z)
virtual void getOptimizedLineData(QVector< QCPGraphData > *lineData, const QCPGraphDataContainer::const_iterator &begin, const QCPGraphDataContainer::const_iterator &end) const
PositionType mPositionTypeY
QCPLayerable * parentLayerable() const
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
QPointer< QCPColorScaleAxisRectPrivate > mAxisRect
void setInsetRect(int index, const QRectF &rect)
QCPSelectionRect * mSelectionRect
line is drawn as steps where the step is in between two data points
Cosmetic pens are converted to pens with pixel width 1 when exporting.
virtual bool take(QCPLayoutElement *element)=0
void setTextColor(const QColor &color)
void setData(QSharedPointer< QCPStatisticalBoxDataContainer > data)
virtual void keyPressEvent(QKeyEvent *event)
void selectableChanged(bool selectable)
Qt::AspectRatioMode mBackgroundScaledMode
When dragging the mouse, a selection rect becomes active. Upon releasing, the axes that are currently...
void setBrush(const QBrush &brush)
void setSelectedFont(const QFont &font)
0x0100 Borders of fills (e.g. under or between graphs)
bool abbreviateDecimalPowers
0x004 The user can select multiple objects by holding the modifier set by QCustomPlot::setMultiSelect...
void addTick(double position, QString label)
virtual QPointF pixelPosition() const
QCPAbstractPlottable * plottable()
virtual QSize maximumSizeHint() const Q_DECL_OVERRIDE
QCPItemAnchor *const bottomRight
virtual QVector< double > createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE
void setBackgroundScaledMode(Qt::AspectRatioMode mode)
void setTicks(const QMap< double, QString > &ticks)
virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE
virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE
void setSpacing(double spacing)
QPointer< QCPAxis > mValueAxis
Bar width is in key coordinates and thus scales with the key axis range.
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setRowSpacing(int pixels)
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const =0
The plottable is not selectable.
QCPRange valueRange() const
QCPItemPosition * createPosition(const QString &name)
void setMinimumSize(const QSize &size)
QVector< double > mSubTickVector
void setWidthType(WidthType widthType)
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
QPen getSubTickPen() const
QCPDataRange dataRange(int index=0) const
virtual ~QCPAbstractPaintBuffer()
QCPDataRange span() const
void setKeyAxis(QCPAxis *axis)
bool hasInvalidatedPaintBuffers()
QPointer< QCPLayerable > mMouseEventLayerable
virtual ~QCPSelectionRect()
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
void fillAlpha(unsigned char alpha)
int dataRangeCount() const
A layer that may contain objects, to control the rendering order.
Qt::Orientation orientation() const
Continuous lightness from black over firey colors to white (suited for non-biased data representation...
void setScaleStrategy(ScaleStrategy strategy)
void setPen(const QPen &pen)
QCPItemPosition *const position
void rescaleDataRange(bool recalculateDataBounds=false)
void setInverted(bool inverted)
LabelSide tickLabelSide() const
void setAutoMargins(QCP::MarginSides sides)
void getErrorBarLines(QCPErrorBarsDataContainer::const_iterator it, QVector< QLineF > &backbones, QVector< QLineF > &whiskers) const
virtual void axisRemoved(QCPAxis *axis)
0x00 Default mode for painting on screen devices
Selection behaves like stMultipleDataRanges, but if there are any data points selected, the entire plottable is drawn as selected.
Replots immediately and repaints the widget immediately by calling QWidget::repaint() after the replo...
QFont getLabelFont() const
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision)
SpacingType spacingType() const
The abstract base class for all objects that form the layout system.
virtual void drawScatterPlot(QCPPainter *painter, const QVector< QPointF > &points, const QCPScatterStyle &style) const
bool savePdf(const QString &fileName, int width=0, int height=0, QCP::ExportPen exportPen=QCP::epAllowCosmetic, const QString &pdfCreator=QString(), const QString &pdfTitle=QString())
QCPBarsGroup(QCustomPlot *parentPlot)
int getRegion(double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const
QColor getLabelColor() const
void setGraph(QCPGraph *graph)
void mousePress(QMouseEvent *event)
Continuous lightness from black to white (suited for non-biased data representation) ...
void draw(QCPPainter *painter)
QCPTextElement(QCustomPlot *parentPlot)
void setFont(const QFont &font)
static QDateTime keyToDateTime(double key)
int findIndexBelowX(const QVector< QPointF > *data, double x) const
void getDataSegments(QList< QCPDataRange > &selectedSegments, QList< QCPDataRange > &unselectedSegments) const
double pointDistance(const QPointF &pixelPoint, QCPCurveDataContainer::const_iterator &closestData) const
QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis)
QCPRange expanded(const QCPRange &otherRange) const
QCPPaintBufferPixmap(const QSize &size, double devicePixelRatio)
virtual QRect clipRect() const Q_DECL_OVERRIDE
Q_SLOT void setGradient(const QCPColorGradient &gradient)
void applyScattersAntialiasingHint(QCPPainter *painter) const
void getVisibleDataBounds(QCPStatisticalBoxDataContainer::const_iterator &begin, QCPStatisticalBoxDataContainer::const_iterator &end) const
QCPAxis * keyAxis() const
void setOuterRect(const QRect &rect)
void setPen(const QPen &pen)
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
bool mayTraverse(int prevRegion, int currentRegion) const
QCPLayer(QCustomPlot *parentPlot, const QString &layerName)
void setLineStyle(LineStyle ls)
QCPColorGradient gradient() const
void setPen(const QPen &pen)
void updateLayerIndices() const
QCPLineEnding upperEnding
void selectableChanged(bool selectable)
QMap< double, QString > & ticks()
void setTextColor(const QColor &color)
Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts &selectedParts)
void getMaximumRowColSizes(QVector< int > *maxColWidths, QVector< int > *maxRowHeights) const
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
void insertColumn(int newIndex)
void setColumnSpacing(int pixels)
virtual double dataSortKey(int index) const
QRect getFinalRect(bool *flippedHorz=0, bool *flippedVert=0) const
void removeFillBasePoints(QVector< QPointF > *lines) const
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE
Qt::AspectRatioMode mAspectRatioMode
QCPItemStraightLine(QCustomPlot *parentPlot)
Q_SLOT void rescaleAxes(bool onlyVisiblePlottables=false)
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
An integer power of the specified tick step is allowed.
QPen selectedIconBorderPen() const
virtual void draw(QCPPainter *painter)=0
Describes a data set by holding multiple QCPDataRange instances.
QCPItemAnchor * parentAnchorX() const
int findIndexBelowY(const QVector< QPointF > *data, double y) const
virtual ~QCPAbstractItem()
void setPen(const QPen &pen)
bool removeFromLegend() const
QCPBarsGroup * mBarsGroup
void dataScaleTypeChanged(QCPAxis::ScaleType scaleType)
QVector< QPointF > getOptimizedCornerPoints(int prevRegion, int currentRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const
virtual int dataCount() const =0
QCPItemAnchor *const left
double getStackedBaseValue(double key, bool positive) const
virtual void updateLayout()
void setTightBoundary(bool enabled)
bool operator==(const QCPColorGradient &other) const
QList< QCPAxis * > addAxes(QCPAxis::AxisTypes types)
virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE
void setWidthType(WidthType widthType)
void setPeriodicity(int multiplesOfPi)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
A brace with round edges.
A layout that places child elements aligned to the border or arbitrarily positioned.
void setData(QCPColorMapData *data, bool copy=false)
QPen getIconBorderPen() const
void setData(QSharedPointer< QCPGraphDataContainer > data)
void setViewport(const QRect &rect)
QCPAbstractPaintBuffer(const QSize &size, double devicePixelRatio)
0x020 Legends are selectable (or their child items, see QCPLegend::setSelectableParts) ...
void setStyle(TracerStyle style)
void setNoAntialiasingOnDrag(bool enabled)
Handles the different ending decorations for line-like items.
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE=0
A color scale for use with color coding data such as QCPColorMap.
virtual void update(UpdatePhase phase)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
Q_SLOT void setSelectable(bool selectable)
QCP::PlottingHints mPlottingHints
virtual QCPPainter * startPainting() Q_DECL_OVERRIDE
QCPAxis * valueAxis() const
void setDateTimeSpec(Qt::TimeSpec spec)
QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const
Rows are filled first, and a new element is wrapped to the next column if the row count would exceed ...
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
virtual QCPItemPosition * toQCPItemPosition()
QPointer< QCPAxisRect > mClipAxisRect
bool mAntialiasedScatters
QVector< QString > mTickVectorLabels
int getMarginValue(const QMargins &margins, QCP::MarginSide side)
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const =0
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
void draw(QCPPainter *painter, const QCPVector2D &pos, const QCPVector2D &dir) const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Both sign domains, including zero, i.e. all numbers.
virtual QList< QCPLayoutElement * > elements(bool recursive) const Q_DECL_OVERRIDE
bool setParentAnchorX(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false)
QList< QCPAbstractPlottable * > mPlottables
QCustomPlot * parentPlot() const
void applyTo(QCPPainter *painter, const QPen &defaultPen) const
QPainter subclass used internally.
void append(QCPBars *bars)
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
Qt::TransformationMode transformationMode() const
void setTickLength(int inside, int outside=0)
Q_SLOT void setSelected(bool selected)
QMap< double, QString > mTicks
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
QSet< QCPItemPosition * > mChildrenX
WidthType widthType() const
void canceled(const QRect &rect, QInputEvent *event)
virtual QVector< double > createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE
bool operator==(const QCPDataSelection &other) const
QCPItemEllipse(QCustomPlot *parentPlot)
{ssCrossCircle.png} a circle with a cross inside
void setPlottingHints(const QCP::PlottingHints &hints)
void setMode(LayerMode mode)
void coordsToPixels(double key, double value, double &x, double &y) const
void addData(const QVector< double > &keys, const QVector< double > &values, bool alreadySorted=false)
void drawBackground(QCPPainter *painter)
double data(double key, double value)
Holds the data of one single data point (one bar) for QCPBars.
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
double boundingDistance() const
QCPItemAnchor *const bottom
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
virtual double getTickStep(const QCPRange &range)
QCPSelectionDecorator * mSelectionDecorator
QCPGrid(QCPAxis *parentAxis)
QCPScatterStyle::ScatterProperties usedScatterProperties() const
void setColorInterpolation(ColorInterpolation interpolation)
QCPLineEnding head() const
{ssDot.png} a single pixel (use ssDisc or ssCircle if you want a round shape with a certain radius) ...
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
virtual void drawDecoration(QCPPainter *painter, QCPDataSelection selection)
virtual QCPLayoutElement * elementAt(int index) const Q_DECL_OVERRIDE
Layer has its own paint buffer and may be replotted individually (see replot).
void setChartStyle(ChartStyle style)
void setBarsGroup(QCPBarsGroup *barsGroup)
void setPiSymbol(QString symbol)
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
virtual QVector< double > createTickVector(double tickStep, const QCPRange &range)
QColor mainTextColor() const
QVector< QRgb > mColorBuffer
void registerBars(QCPBars *bars)
QCPAxisRect * axisRect() const
QCPAbstractItem * mParentItem
{ssPlusSquare.png} a square with a plus inside
A filled diamond (45 degrees rotated square)
QSharedPointer< QCPErrorBarsDataContainer > data() const
void setIconBorderPen(const QPen &pen)
double lengthSquared() const
QCP::SelectionRectMode mSelectionRectMode
QPointF getPixelCoordinates(const QCPPlottableInterface1D *interface1d, int dataIndex) const
void removeChildY(QCPItemPosition *pos)
Colors suitable to represent different elevations on geographical maps.
int selectionTolerance() const
void setSelectedFont(const QFont &font)
Qt::TimeSpec mDateTimeSpec
QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name, int anchorId=-1)
QCPVector2D & operator/=(double divisor)
0x01 The pen property, see setPen
void setNumberPrecision(int precision)
QVector< QLineF > getWhiskerBarLines(QCPStatisticalBoxDataContainer::const_iterator it) const
bool errorBarVisible(int index) const
QRect labelSelectionBox() const
static const double minRange
QList< QCPAbstractItem * > items() const
void setSelectedPen(const QPen &pen)
QCPLayer * currentLayer() const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType)
void setOpenGl(bool enabled, int multisampling=16)
virtual void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE
void setKeyRange(const QCPRange &keyRange)
{ssTriangle.png} an equilateral triangle, standing on baseline
{ssDisc.png} a circle which is filled with the pen's color (not the brush as with ssCircle) ...
Q_SLOT void setSelected(bool selected)
void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
void rescaleAxes(bool onlyEnlarge=false) const
0x0020 Main lines of plottables
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const =0
virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
static void connectBars(QCPBars *lower, QCPBars *upper)
virtual void drawLinePlot(QCPPainter *painter, const QVector< QPointF > &lines) const
QVector< DataType >::const_iterator const_iterator
bool createAlpha(bool initializeOpaque=true)
QCPBars * barBelow() const
bool rangeReversed() const
void setBrush(const QBrush &brush)
A bar perpendicular to the line.
Q_SLOT void setSelectedParts(const SelectableParts &selectedParts)
void setRangeDrag(bool enabled)
virtual ~QCPSelectionDecorator()
data points are connected by a straight line
Final phase in which the layout system places the rects of the elements.
0x01 Axis is vertical and on the left side of the axis rect
void setLabelColor(const QColor &color)
void setAntialiasedFill(bool enabled)
QCP::AntialiasedElements mAntialiasedElements
QCPItemPosition *const topLeft
void setHead(const QCPLineEnding &head)
void setNotAntialiasedElements(const QCP::AntialiasedElements ¬AntialiasedElements)
QCPItemAnchor *const bottom
bool mAutoAddPlottableToLegend
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setAntialiased(bool enabled)
void setSelectedBrush(const QBrush &brush)
QSharedPointer< QCPBarsDataContainer > data() const
QCustomPlot * parentPlot() const
static QCPFinancialDataContainer timeSeriesToOhlc(const QVector< double > &time, const QVector< double > &value, double timeBinSize, double timeBinOffset=0)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QCPItemPixmap(QCustomPlot *parentPlot)
QCPLayout * layout() const
QCPAxis * rangeDragAxis(Qt::Orientation orientation)
QCPAxisRect * axisRect(int index=0) const
void setFractionStyle(FractionStyle style)
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
bool contains(const QCPDataRange &other) const
void setFont(const QFont &font)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setRowStretchFactor(int row, double factor)
QCPAbstractPlottable * plottableAt(const QPointF &pos, bool onlySelectable=false) const
void setBarWidth(int width)
QList< double > mColumnStretchFactors
bool mMapImageInvalidated
BracketStyle style() const
QList< QCPGraph * > selectedGraphs() const
bool removeItem(QCPAbstractItem *item)
void drawBackground(QCPPainter *painter)
Bar width is given by a fraction of the axis rect size.
void setInterpolate(bool enabled)
SelectableParts selectedParts() const
void setPen(const QPen &pen)
Q_SLOT void deselectAll()
QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis)
QRectF getQuartileBox(QCPStatisticalBoxDataContainer::const_iterator it) const
QPointer< QCPColorScale > mColorScale
void setBufferDevicePixelRatio(double ratio)
QCPScatterStyle scatterStyle() const
virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
void setTickLabelSide(LabelSide side)
QCPLayoutInset * insetLayout() const
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
virtual ~QCPItemBracket()
void removeChild(QCP::MarginSide side, QCPLayoutElement *element)
void setBrush(const QBrush &brush)
void setPixelPosition(const QPointF &pixelPosition)
void setSelectionTolerance(int pixels)
void setSelectedPen(const QPen &pen)
void clear(const QColor &color) Q_DECL_OVERRIDE
void setPen(const QPen &pen)
static AxisType opposite(AxisType type)
void setSymbolGap(double pixels)
Less readable tick steps are allowed which in turn facilitates getting closer to the requested tick c...
void gradientChanged(const QCPColorGradient &newGradient)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
virtual void draw(QCPPainter *painter)
double pixelToCoord(double value) const
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
enum QCPAxisTickerDateTime::DateStrategy mDateStrategy
void setWhiskerAntialiased(bool enabled)
QMap< double, QColor > mColorStops
{ssStar.png} a star with eight arms, i.e. a combination of cross and plus
void addTicks(const QMap< double, QString > &ticks)
QStack< bool > mAntialiasingStack
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
void cellToCoord(int keyIndex, int valueIndex, double *key, double *value) const
Phase used for any type of preparation that needs to be done before margin calculation and layout...
QList< QPointer< QCPAxis > > mRangeZoomHorzAxis
virtual void layoutChanged()
bool moveLayer(QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove)
void selectableChanged(bool selectable)
void drawCandlestickPlot(QCPPainter *painter, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, bool isSelected)
double mRangeZoomFactorHorz
Q_SLOT void setDataRange(const QCPRange &dataRange)
virtual int calculateAutoMargin(QCP::MarginSide side)
void setSelectedTextColor(const QColor &color)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setTickLengthOut(int outside)
double rangeZoomFactor(Qt::Orientation orientation)
QCPItemPosition *const point1
void setMultiSelectModifier(Qt::KeyboardModifier modifier)
virtual QVector< QString > createLabelVector(const QVector< double > &ticks, const QLocale &locale, QChar formatChar, int precision)
QPen getBorderPen() const
QList< QCPColorMap * > colorMaps() const
bool hasItem(QCPAbstractLegendItem *item) const
virtual void legendRemoved(QCPLegend *legend)
void unregisterBars(QCPBars *bars)
void setSelectedTickPen(const QPen &pen)
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
QCPAxis::ScaleType mDataScaleType
void setSelectedFont(const QFont &font)
Describes a data range given by begin and end index.
QCPSelectionDecoratorBracket()
void moveRange(double diff)
void setLabelFont(const QFont &font)
QCP::SelectionType mSelectable
A bar perpendicular to the line, pointing out to only one side (to which side can be changed with set...
0x002 Legend items individually (see selectedItems)
virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
QCPAxis::ScaleType mDataScaleType
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
QList< QCPLegend * > selectedLegends() const
QCPAbstractItem * item() const
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
void addChildY(QCPItemPosition *pos)
QWeakPointer< QCPAbstractPaintBuffer > mPaintBuffer
{ssPlusCircle.png} a circle with a plus inside
QSharedPointer< QCPErrorBarsDataContainer > mDataContainer
void setRotation(double degrees)
QRectF getBarRect(double key, double value) const
void setSubTickPen(const QPen &pen)
{ssCrossSquare.png} a square with a cross inside
QHash< QCPAxis::AxisType, QList< QCPAxis * > > mAxes
QCPItemAnchor *const right
void setLength(double length)
void setBracketHeight(int height)
virtual ~QCPAbstractPlottable()
virtual void getOptimizedScatterData(QVector< QCPGraphData > *scatterData, QCPGraphDataContainer::const_iterator begin, QCPGraphDataContainer::const_iterator end) const
Data points are connected with a straight line.
Dynamic positioning at a plot coordinate defined by two axes (see setAxes).
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
virtual int getSubTickCount(double tickStep)
QCPDataSelection mSelection
void setNumberFormat(const QString &formatCode)
SelectableParts mSelectableParts
virtual double dataMainValue(int index) const
QCPItemPosition *const startDir
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name)
virtual QRect clipRect() const Q_DECL_OVERRIDE
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
QCPRange sanitizedForLinScale() const
void setLineStyle(LineStyle style)
QCPSelectionRect * selectionRect() const
virtual void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE
Colors suitable to emphasize polarity around the center, with blue for negative, black in the middle ...
void scaleTypeChanged(QCPAxis::ScaleType scaleType)
void replaceUnit(QString &text, TimeUnit unit, int value) const
QCPLayoutElement * element(int row, int column) const
The generic data container for one-dimensional plottables.
void setLogBase(double base)
QCPAxisPainterPrivate(QCustomPlot *parentPlot)
Qt::Alignment insetAlignment(int index) const
void add(const QCPDataContainer< DataType > &data)
double pickClosest(double target, const QVector< double > &candidates) const
SelectablePart getPartAt(const QPointF &pos) const
bool intersects(const QCPDataRange &other) const
void accepted(const QRect &rect, QMouseEvent *event)
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos)
void setTail(const QCPLineEnding &tail)
Holds the two-dimensional data of a QCPColorMap plottable.
bool setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false)
virtual QPointF dataPixelPosition(int index) const
void setSelectedFont(const QFont &font)
QList< QCPAbstractItem * > mItems
bool rectIntersectsLine(const QRectF &pixelRect, const QLineF &line) const
0x002 Axis ranges are zoomable with the mouse wheel (see QCPAxisRect::setRangeZoom, QCPAxisRect::setRangeZoomAxes)
QCPAbstractLegendItem * item(int index) const
virtual void startSelection(QMouseEvent *event)
void getVisibleDataBounds(QCPFinancialDataContainer::const_iterator &begin, QCPFinancialDataContainer::const_iterator &end) const
virtual QVector< double > createSubTickVector(int subTickCount, const QVector< double > &ticks)
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
void addDataRange(const QCPDataRange &dataRange, bool simplify=true)
QString numberFormat() const
width is given by a fraction of the axis rect size
void setTickLengthIn(int inside)
virtual void endSelection(QMouseEvent *event)
double mRangeZoomFactorVert
void setSelectedColor(const QColor &color)
void setSelectedPen(const QPen &pen)
void setRangeZoomFactor(double horizontalFactor, double verticalFactor)
void addData(const QVector< double > &keys, const QVector< double > &open, const QVector< double > &high, const QVector< double > &low, const QVector< double > &close, bool alreadySorted=false)
void setSelectedBrush(const QBrush &brush)
virtual void copyFrom(const QCPSelectionDecorator *other)
Q_SLOT void setScaleType(QCPAxis::ScaleType type)
void setClipToAxisRect(bool clip)
TracerStyle style() const
a custom pixmap specified by setPixmap, centered on the data point coordinates
void setColumnStretchFactors(const QList< double > &factors)
void mouseWheel(QWheelEvent *event)
bool addItem(QCPAbstractLegendItem *item)
Continuous lightness from black over weak blueish colors to white (suited for non-biased data represe...
void setMarginValue(QMargins &margins, QCP::MarginSide side, int value)
void setPen(const QPen &pen)
void drawPolyline(QCPPainter *painter, const QVector< QPointF > &lineData) const
QFont getTickLabelFont() const
QCPAxisPainterPrivate * mAxisPainter
void setWhiskerWidth(double pixels)
virtual QPointF anchorPixelPosition(int anchorId) const
void setMode(PainterMode mode, bool enabled=true)
The abstract base class for layouts.
void setSubGridVisible(bool visible)
QString unicodeSubscript(int number) const
Holds the data of one single data point for QCPFinancial.
void setTickLabelPadding(int padding)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
QLineF getRectClippedStraightLine(const QCPVector2D &point1, const QCPVector2D &vec, const QRect &rect) const
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setSelectedLabelColor(const QColor &color)
QCPItemPosition *const bottomRight
None of the selectable parts.
void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group)
QCPLayoutElement * layoutElementAt(const QPointF &pos) const
void setInteractions(const QCP::Interactions &interactions)
Any combination of data points/ranges can be selected.
void setBrush(const QBrush &brush)
0x04 Axis is horizontal and on the top side of the axis rect
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
Resolution is given in dots per centimeter (dpcm)
bool mOpenGlCacheLabelsBackup
virtual int elementCount() const Q_DECL_OVERRIDE
bool realVisibility() const
QCPItemAnchor *const left
QCPAbstractPlottable * mPlottable
QCPAbstractPlottable * plottable(int index)
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
ColorInterpolation mColorInterpolation
QCPPlottableLegendItem * itemWithPlottable(const QCPAbstractPlottable *plottable) const
QString unicodeSuperscript(int number) const
QCPItemAnchor *const bottomLeft
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
QCPAxis * axis(QCPAxis::AxisType type, int index=0) const
{ssTriangleInverted.png} an equilateral triangle, standing on corner
void setLength(double length)
void setAlpha(int keyIndex, int valueIndex, unsigned char alpha)
A plottable representing a two-dimensional color map in a plot.
Layer is inserted above other layer.
void rescale(bool onlyVisiblePlottables=false)
QHash< QCP::MarginSide, QList< QCPLayoutElement * > > mChildren
void setPlottingHint(QCP::PlottingHint hint, bool enabled=true)
void setTextFlags(int flags)
QCPAxis * valueAxis() const
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
QPointer< QCPAxis > mKeyAxis
InsetPlacement insetPlacement(int index) const
void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio, Qt::TransformationMode transformationMode=Qt::SmoothTransformation)
void setColumnStretchFactor(int column, double factor)
void setSelectedPen(const QPen &pen)
void setBracketStyle(BracketStyle style)
QCPDataSelection & operator+=(const QCPDataSelection &other)
virtual QSize maximumSizeHint() const Q_DECL_OVERRIDE
double distanceToStraightLine(const QCPVector2D &base, const QCPVector2D &direction) const
bool setCurrentLayer(const QString &name)
QCPItemPosition *const position
void setAxisRect(QCPAxisRect *axisRect)
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details)
int tickLabelPadding() const
void addChildX(QCPItemPosition *pos)
The positive sign domain, i.e. numbers greater than zero.
QCPAxis::LabelSide tickLabelSide
QPointer< QCPLayerable > mParentLayerable
QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis)
int subTickLengthOut() const
QList< QCPAbstractPlottable * > plottables() const
QCPItemAnchor *const topLeft
Color channels red, green and blue are linearly interpolated.
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
QCPItemAnchor *const right
WidthType widthType() const
Tick labels will be displayed inside the axis rect and clipped to the inner axis rect.
void doubleClicked(QMouseEvent *event)
QList< double > mRowStretchFactors
void setInsetAlignment(int index, Qt::Alignment alignment)
void setData(QSharedPointer< QCPFinancialDataContainer > data)
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
void setPen(const QPen &pen)
QPixmap mScaledBackgroundPixmap
When dragging the mouse, a selection rect becomes active. Upon releasing, plottable data points that ...
QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis)
bool removeAxis(QCPAxis *axis)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
The negative sign domain, i.e. numbers smaller than zero.
void setRangeZoom(bool enabled)
virtual void mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details)
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE
void setAutoAddPlottableToLegend(bool on)
QPointer< QCPAxisRect > mAxisRect
void setClipAxisRect(QCPAxisRect *rect)
Qt::TransformationMode mTransformationMode
virtual Q_SLOT void processPointSelection(QMouseEvent *event)
virtual int calculateMargin()
void setText(const QString &text)
void setPen(const QPen &pen)
QVector< double > tickPositions
QCPDataSelection intersection(const QCPDataRange &other) const
QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes=true)
width is in absolute pixels
void selectionChanged(bool selected)
QHash< TimeUnit, int > mFieldWidth
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setSelectedTextColor(const QColor &color)
virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const
QCPDataSelection inverse(const QCPDataRange &outerRange) const
void expand(const QCPRange &otherRange)
QCPAbstractItem * itemAt(const QPointF &pos, bool onlySelectable=false) const
QCPRange dataBounds() const
QCPLayerable * layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=0) const
Holds the data of one single data point for QCPStatisticalBox.
A non-filled arrow head with open back.
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
0x04 The size property, see setSize
virtual void updateLayout() Q_DECL_OVERRIDE
A paint buffer based on QPixmap, using software raster rendering.
void setSelectedPen(const QPen &pen)
void setBorderPen(const QPen &pen)
A nicely readable tick step is prioritized over matching the requested number of ticks (see setTickCo...
SelectableParts selectableParts() const
void setZeroLinePen(const QPen &pen)
QCPItemPosition *const point2
bool hasAnchor(const QString &name) const
virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE
virtual QCPLayoutElement * takeAt(int index) Q_DECL_OVERRIDE
QVariant mMouseEventLayerableDetails
Bar spacing is in absolute pixels.
void setFillOrder(FillOrder order, bool rearrange=true)
void selectableChanged(const QCPAxis::SelectableParts &parts)
void setIconSize(const QSize &size)
void setBracketPen(const QPen &pen)
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
void setBaseValue(double baseValue)
QCPItemAnchor * mParentAnchorY
0x0200 Zero-lines, see QCPGrid::setZeroLinePen
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
bool addLayer(const QString &name, QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove)
void setSelectedPen(const QPen &pen)
double coordToPixel(double value) const
virtual void draw(QCPPainter *painter) const Q_DECL_OVERRIDE
void setScatterStyle(const QCPScatterStyle &style)
QList< QCPAxis * > axes(QCPAxis::AxisTypes types) const
void getLines(QVector< QPointF > *lines, const QCPDataRange &dataRange) const
virtual ~QCPItemPosition()
Manages the position of an item.
unsigned char alpha(int keyIndex, int valueIndex)
void adoptElement(QCPLayoutElement *el)
void setValueRange(const QCPRange &valueRange)
QList< QCPRange > mDragStartVertRange
bool hasItem(QCPAbstractItem *item) const
void setDataPlottable(QCPAbstractPlottable *plottable)
virtual void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE
A half ellipse is drawn. The size of the ellipse is given by the bracket width/height properties...
void setSubTickCount(int subTicks)
QPen iconBorderPen() const
QCPItemPosition *const end
BracketStyle mBracketStyle
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
A curly brace with varying stroke width giving a calligraphic impression.
QList< QCPAbstractItem * > items() const
void setSize(double size)
0x02 The brush property, see setBrush
void getDataSegments(QList< QCPDataRange > &selectedSegments, QList< QCPDataRange > &unselectedSegments) const
QCPDataContainer< QCPFinancialData > QCPFinancialDataContainer
QPixmap mBackgroundPixmap
void setGraphKey(double key)
Defines a color gradient for use with e.g. QCPColorMap.
QCPMarginGroup(QCustomPlot *parentPlot)
QCPErrorBars(QCPAxis *keyAxis, QCPAxis *valueAxis)
void setTypeY(PositionType type)
QRectF selectionHitBox(QCPFinancialDataContainer::const_iterator it) const
virtual void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE
Resolution is given in dots per inch (DPI/PPI)
const QPolygonF getChannelFillPolygon(const QVector< QPointF > *lines) const
QCPMarginGroup * marginGroup(QCP::MarginSide side) const
QLineF getRectClippedLine(const QCPVector2D &start, const QCPVector2D &end, const QRect &rect) const
Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType)
QPixmap mScaledBackgroundPixmap
virtual Q_SLOT void processRectZoom(QRect rect, QMouseEvent *event)
QCPAbstractItem(QCustomPlot *parentPlot)
void setSubTickLength(int inside, int outside=0)
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
void setBrushPositive(const QBrush &brush)
QMap< double, QColor > colorStops() const
virtual void drawStatisticalBox(QCPPainter *painter, QCPStatisticalBoxDataContainer::const_iterator it, const QCPScatterStyle &outlierStyle) const
A bar that is skewed (skew controllable via setLength)
virtual void parentPlotInitialized(QCustomPlot *parentPlot)
Represents the range an axis is encompassing.
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
0x8000 Other elements that don't fit into any of the existing categories
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
void addData(const QVector< double > &error)
QCPRange dataRange() const
QCPLayoutGrid * mPlotLayout
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setAntialiasedZeroLine(bool enabled)
QVector< QLineF > getWhiskerBackboneLines(QCPStatisticalBoxDataContainer::const_iterator it) const
void setPositionAlignment(Qt::Alignment alignment)
QList< QCPItemAnchor * > mAnchors
QCPScatterStyle mScatterStyle
QList< QCPAxis * > rangeZoomAxes(Qt::Orientation orientation)
void started(QMouseEvent *event)
QString unicodeFraction(int numerator, int denominator) const
Groups multiple QCPBars together so they appear side by side.
0x010 Axes are selectable (or parts of them, see QCPAxis::setSelectableParts)
void initializeParentPlot(QCustomPlot *parentPlot)
QCPScatterStyle getFinalScatterStyle(const QCPScatterStyle &unselectedStyle) const
void setSelectedBrush(const QBrush &brush)
void setScatterSkip(int skip)
void setSelectedTickLabelColor(const QColor &color)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const
void setTickStep(double step)
bool removePlottable(QCPAbstractPlottable *plottable)
void setTail(const QCPLineEnding &tail)
virtual int dataCount() const
QList< QCPAxis * > rangeDragAxes(Qt::Orientation orientation)
void setTickLabelColor(const QColor &color)
A template base class for plottables with one-dimensional data.
void setSize(double size)
void setBrush(const QBrush &brush)
ScaleType scaleType() const
Resolution is given in dots per meter (dpm)
Full hue cycle, with highest and lowest color red (suitable for periodic data, such as angles and pha...
void pixelsToCoords(double x, double y, double &key, double &value) const
void setSelectedPen(const QPen &pen)
QCPItemPosition *const topLeft
bool removeItem(int index)
SelectableParts selectableParts() const
friend class QCPPlottableLegendItem
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
PositionType mPositionTypeX
Qt::Alignment mPositionAlignment
QList< QCPAxisRect * > axisRects() const
Holds multiple axes and arranges them in a rectangular shape.
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
QCPDataRange bounded(const QCPDataRange &other) const
void setPen(const QPen &pen)
Whether to use immediate or queued refresh depends on whether the plotting hint QCP::phImmediateRefre...
void clicked(QMouseEvent *event)
virtual ~QCPLayoutInset()
virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE
virtual void parentPlotInitialized(QCustomPlot *parentPlot) Q_DECL_OVERRIDE
{ssDiamond.png} a diamond
QCPAxisRect * clipAxisRect() const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void rescaleValueAxis(bool onlyEnlarge=false, bool inKeyRange=false) const
virtual double dataMainKey(int index) const =0
virtual QCPRange dataValueRange(int index) const
QCP::AntialiasedElements mAADragBackup
QCPColorMapData & operator=(const QCPColorMapData &other)
bool setParentAnchorY(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false)
void toPainter(QCPPainter *painter, int width=0, int height=0)
QPixmap toPixmap(int width=0, int height=0, double scale=1.0)
QCPScatterStyle::ScatterProperties mUsedScatterProperties
Qt::KeyboardModifier mMultiSelectModifier
QCPRange range(const QCPAxis *axis) const
virtual void drawScatterPlot(QCPPainter *painter, const QVector< QPointF > &scatters, const QCPScatterStyle &style) const
void setPenNegative(const QPen &pen)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setLabel(const QString &str)
QVector< QPointF > dataToImpulseLines(const QVector< QCPGraphData > &data) const
QCP::AntialiasedElements notAntialiasedElements() const
void setAntialiasedElements(const QCP::AntialiasedElements &antialiasedElements)
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
QCPSelectionRect(QCustomPlot *parentPlot)
Q_SLOT void updateLegendIcon(Qt::TransformationMode transformMode=Qt::SmoothTransformation, const QSize &thumbSize=QSize(32, 18))
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
Q_SLOT void axisSelectionChanged(QCPAxis::SelectableParts selectedParts)
void sizeConstraintsChanged() const
Q_SLOT void setRange(const QCPRange &range)
QVector< double > outliers
QList< QCPAxis * > selectedAxes() const
A filled arrow head with an indented back.
line is drawn as steps where the step height is the value of the right data point ...
virtual void deselectEvent(bool *selectionStateChanged)
QCP::Interactions mInteractions
QCPItemAnchor *const topRight
Qt::Alignment mTextAlignment
void setLabel(const QString &str)
QLatin1Char mNumberFormatChar
void setData(QSharedPointer< QCPCurveDataContainer > data)
The errors are for the value dimension (bars appear parallel to the value axis)
int axisCount(QCPAxis::AxisType type) const
QCP::AntialiasedElements mOpenGlAntialiasedElementsBackup
QCPItemPosition *const left
bool mColorBufferInvalidated
int axisRectCount() const
QCustomPlot * mParentPlot
void setSubTicks(bool show)
QSharedPointer< QCPAxisTicker > mTicker
QPointer< QCPGraph > mChannelFillGraph
void setInvalidated(bool invalidated=true)
QVector< QPointF > dataToLines(const QVector< QCPGraphData > &data) const
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
void updateGradientImage()
virtual double dataMainKey(int index) const
AxisType axisType() const
void setChannelFillGraph(QCPGraph *targetGraph)
void selectableChanged(QCP::SelectionType selectable)
void setWidth(double width)
double keyPixelOffset(const QCPBars *bars, double keyCoord)
bool hasElement(int row, int column)
QCustomPlot * mParentPlot
ScatterShape shape() const
void setSelectedBrush(const QBrush &brush)
void coordToCell(double key, double value, int *keyIndex, int *valueIndex) const
void drawShape(QCPPainter *painter, const QPointF &pos) const
void setPen(const QPen &pen)
QCPItemPosition *const bottomRight
Qt::AspectRatioMode mBackgroundScaledMode
virtual void drawCurveLine(QCPPainter *painter, const QVector< QPointF > &lines) const
Q_SLOT void setSelected(bool selected)
QCPLayerable(QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0)
double pointDistance(const QPointF &pixelPoint, QCPErrorBarsDataContainer::const_iterator &closestData) const
virtual ~QCPSelectionDecoratorBracket()
virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
virtual void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE
QCPFinancial(QCPAxis *keyAxis, QCPAxis *valueAxis)
QColor mSelectedLabelColor
void setFont(const QFont &font)
void setColorStopAt(double position, const QColor &color)
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
QCPVector2D & operator*=(double factor)
void setLabelPadding(int padding)