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;
1478 Q_UNUSED(onlySelectable)
1504 qDebug() << Q_FUNC_INFO <<
"called with mParentPlot already initialized";
1509 qDebug() << Q_FUNC_INFO <<
"called with parentPlot zero";
1543 qDebug() << Q_FUNC_INFO <<
"no parent QCustomPlot set";
1548 qDebug() << Q_FUNC_INFO <<
"layer" << layer->
name() <<
"is not in same QCustomPlot as this layerable";
1598 Q_UNUSED(parentPlot)
1667 Q_UNUSED(selectionStateChanged)
1684 Q_UNUSED(selectionStateChanged)
1954 lower = includeCoord;
1956 upper = includeCoord;
1973 result.
expand(otherRange);
1990 result.
expand(includeCoord);
2004 if (lowerBound > upperBound)
2005 qSwap(lowerBound, upperBound);
2008 if (result.
lower < lowerBound)
2010 result.
lower = lowerBound;
2012 if (result.
upper > upperBound || qFuzzyCompare(
size(), upperBound-lowerBound))
2013 result.
upper = upperBound;
2014 }
else if (result.
upper > upperBound)
2016 result.
upper = upperBound;
2018 if (result.
lower < lowerBound || qFuzzyCompare(
size(), upperBound-lowerBound))
2019 result.
lower = lowerBound;
2039 double rangeFac = 1e-3;
2044 if (sanitizedRange.
lower == 0.0 && sanitizedRange.
upper != 0.0)
2047 if (rangeFac < sanitizedRange.
upper*rangeFac)
2048 sanitizedRange.
lower = rangeFac;
2050 sanitizedRange.
lower = sanitizedRange.
upper*rangeFac;
2052 else if (sanitizedRange.
lower != 0.0 && sanitizedRange.
upper == 0.0)
2055 if (-rangeFac > sanitizedRange.
lower*rangeFac)
2056 sanitizedRange.
upper = -rangeFac;
2058 sanitizedRange.
upper = sanitizedRange.
lower*rangeFac;
2059 }
else if (sanitizedRange.
lower < 0 && sanitizedRange.
upper > 0)
2062 if (-sanitizedRange.
lower > sanitizedRange.
upper)
2065 if (-rangeFac > sanitizedRange.
lower*rangeFac)
2066 sanitizedRange.
upper = -rangeFac;
2068 sanitizedRange.
upper = sanitizedRange.
lower*rangeFac;
2072 if (rangeFac < sanitizedRange.
upper*rangeFac)
2073 sanitizedRange.
lower = rangeFac;
2075 sanitizedRange.
lower = sanitizedRange.
upper*rangeFac;
2079 return sanitizedRange;
2090 return sanitizedRange;
2107 !(lower > 0 && qIsInf(upper/lower)) &&
2108 !(upper < 0 && qIsInf(lower/upper)));
2397 mDataRanges.append(range);
2409 if (mDataRanges.size() != other.
mDataRanges.size())
2411 for (
int i=0; i<mDataRanges.size(); ++i)
2436 addDataRange(other);
2461 while (i < mDataRanges.size())
2463 const int thisBegin = mDataRanges.at(i).begin();
2464 const int thisEnd = mDataRanges.at(i).end();
2465 if (thisBegin >= other.
end())
2468 if (thisEnd > other.
begin())
2470 if (thisBegin >= other.
begin())
2472 if (thisEnd <= other.
end())
2474 mDataRanges.removeAt(i);
2477 mDataRanges[i].setBegin(other.
end());
2480 if (thisEnd <= other.
end())
2482 mDataRanges[i].setEnd(other.
begin());
2485 mDataRanges[i].setEnd(other.
begin());
2504 for (
int i=0; i<mDataRanges.size(); ++i)
2505 result += mDataRanges.at(i).length();
2519 if (index >= 0 && index < mDataRanges.size())
2521 return mDataRanges.at(index);
2524 qDebug() << Q_FUNC_INFO <<
"index out of range:" << index;
2538 return QCPDataRange(mDataRanges.first().begin(), mDataRanges.last().end());
2549 mDataRanges.append(dataRange);
2561 mDataRanges.clear();
2576 for (
int i=mDataRanges.size()-1; i>=0; --i)
2578 if (mDataRanges.at(i).isEmpty())
2579 mDataRanges.removeAt(i);
2581 if (mDataRanges.isEmpty())
2585 std::sort(mDataRanges.begin(), mDataRanges.end(), lessThanDataRangeBegin);
2589 while (i < mDataRanges.size())
2591 if (mDataRanges.at(i-1).end() >= mDataRanges.at(i).begin())
2593 mDataRanges[i-1].setEnd(qMax(mDataRanges.at(i-1).end(), mDataRanges.at(i).end()));
2594 mDataRanges.removeAt(i);
2617 mDataRanges.clear();
2628 if (!mDataRanges.isEmpty())
2630 if (mDataRanges.size() > 1)
2631 mDataRanges = QList<QCPDataRange>() << mDataRanges.first();
2632 if (mDataRanges.first().length() > 1)
2633 mDataRanges.first().setEnd(mDataRanges.first().begin()+1);
2640 mDataRanges = QList<QCPDataRange>() << span();
2659 if (other.
isEmpty())
return false;
2663 while (thisIndex < mDataRanges.size() && otherIndex < other.
mDataRanges.size())
2665 if (mDataRanges.at(thisIndex).contains(other.
mDataRanges.at(otherIndex)))
2670 return thisIndex < mDataRanges.size();
2684 for (
int i=0; i<mDataRanges.size(); ++i)
2685 result.
addDataRange(mDataRanges.at(i).intersection(other),
false);
2720 if (mDataRanges.first().begin() != fullRange.
begin())
2723 for (
int i=1; i<mDataRanges.size(); ++i)
2726 if (mDataRanges.last().end() != fullRange.
end())
2821 mPen(QBrush(Qt::gray), 0, Qt::DashLine),
2822 mBrush(Qt::NoBrush),
2846 qDebug() << Q_FUNC_INFO <<
"called with axis zero";
2894 mRect = QRect(event->pos(),
event->pos());
2906 mRect.setBottomRight(event->pos());
2919 mRect.setBottomRight(event->pos());
2932 if (event->key() == Qt::Key_Escape &&
mActive)
2956 painter->setBrush(
mBrush);
2957 painter->drawRect(
mRect);
3015 QObject(parentPlot),
3035 QHashIterator<QCP::MarginSide, QList<QCPLayoutElement*> > it(
mChildren);
3036 while (it.hasNext())
3039 if (!it.value().isEmpty())
3052 QHashIterator<QCP::MarginSide, QList<QCPLayoutElement*> > it(
mChildren);
3053 while (it.hasNext())
3056 const QList<QCPLayoutElement*>
elements = it.value();
3057 for (
int i=elements.size()-1; i>=0; --i)
3058 elements.at(i)->setMarginGroup(it.key(), 0);
3077 for (
int i=0; i<elements.size(); ++i)
3079 if (!elements.at(i)->autoMargins().testFlag(side))
3081 int m = qMax(elements.at(i)->calculateAutoMargin(side),
QCP::getMarginValue(elements.at(i)->minimumMargins(), side));
3099 qDebug() << Q_FUNC_INFO <<
"element is already child of this margin group side" <<
reinterpret_cast<quintptr
>(element);
3110 if (!
mChildren[side].removeOne(element))
3111 qDebug() << Q_FUNC_INFO <<
"element is not child of this margin group side" <<
reinterpret_cast<quintptr
>(element);
3185 mMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX),
3186 mSizeConstraintRect(scrInnerRect),
3188 mOuterRect(0, 0, 0, 0),
3189 mMargins(0, 0, 0, 0),
3190 mMinimumMargins(0, 0, 0, 0),
3372 QVector<QCP::MarginSide> sideVector;
3378 for (
int i=0; i<sideVector.size(); ++i)
3473 return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
3486 return QList<QCPLayoutElement*>();
3513 qDebug() << Q_FUNC_INFO <<
"parent plot not defined";
3662 const int elCount = elementCount();
3663 for (
int i=0; i<elCount; ++i)
3673 const int c = elementCount();
3674 QList<QCPLayoutElement*> result;
3675 #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) 3678 for (
int i=0; i<c; ++i)
3679 result.append(elementAt(i));
3682 for (
int i=0; i<c; ++i)
3685 result << result.at(i)->elements(recursive);
3752 for (
int i=elementCount()-1; i>=0; --i)
3770 if (QWidget *w = qobject_cast<QWidget*>(parent()))
3771 w->updateGeometry();
3772 else if (
QCPLayout *l = qobject_cast<QCPLayout*>(parent()))
3773 l->sizeConstraintsChanged();
3811 el->setParent(
this);
3816 qDebug() << Q_FUNC_INFO <<
"Null element passed";
3838 qDebug() << Q_FUNC_INFO <<
"Null element passed";
3872 if (maxSizes.size() != minSizes.size() || minSizes.size() != stretchFactors.size())
3874 qDebug() << Q_FUNC_INFO <<
"Passed vector sizes aren't equal:" << maxSizes << minSizes << stretchFactors;
3875 return QVector<int>();
3877 if (stretchFactors.isEmpty())
3878 return QVector<int>();
3879 int sectionCount = stretchFactors.size();
3880 QVector<double> sectionSizes(sectionCount);
3883 for (
int i=0; i<sectionCount; ++i)
3884 minSizeSum += minSizes.at(i);
3885 if (totalSize < minSizeSum)
3888 for (
int i=0; i<sectionCount; ++i)
3890 stretchFactors[i] = minSizes.at(i);
3895 QList<int> minimumLockedSections;
3896 QList<int> unfinishedSections;
3897 for (
int i=0; i<sectionCount; ++i)
3898 unfinishedSections.append(i);
3899 double freeSize = totalSize;
3901 int outerIterations = 0;
3902 while (!unfinishedSections.isEmpty() && outerIterations < sectionCount*2)
3905 int innerIterations = 0;
3906 while (!unfinishedSections.isEmpty() && innerIterations < sectionCount*2)
3911 double nextMax = 1e12;
3912 for (
int i=0; i<unfinishedSections.size(); ++i)
3914 int secId = unfinishedSections.at(i);
3915 double hitsMaxAt = (maxSizes.at(secId)-sectionSizes.at(secId))/stretchFactors.at(secId);
3916 if (hitsMaxAt < nextMax)
3918 nextMax = hitsMaxAt;
3924 double stretchFactorSum = 0;
3925 for (
int i=0; i<unfinishedSections.size(); ++i)
3926 stretchFactorSum += stretchFactors.at(unfinishedSections.at(i));
3927 double nextMaxLimit = freeSize/stretchFactorSum;
3928 if (nextMax < nextMaxLimit)
3930 for (
int i=0; i<unfinishedSections.size(); ++i)
3932 sectionSizes[unfinishedSections.at(i)] += nextMax*stretchFactors.at(unfinishedSections.at(i));
3933 freeSize -= nextMax*stretchFactors.at(unfinishedSections.at(i));
3935 unfinishedSections.removeOne(nextId);
3938 for (
int i=0; i<unfinishedSections.size(); ++i)
3939 sectionSizes[unfinishedSections.at(i)] += nextMaxLimit*stretchFactors.at(unfinishedSections.at(i));
3940 unfinishedSections.clear();
3943 if (innerIterations == sectionCount*2)
3944 qDebug() << Q_FUNC_INFO <<
"Exceeded maximum expected inner iteration count, layouting aborted. Input was:" << maxSizes << minSizes << stretchFactors << totalSize;
3947 bool foundMinimumViolation =
false;
3948 for (
int i=0; i<sectionSizes.size(); ++i)
3950 if (minimumLockedSections.contains(i))
3952 if (sectionSizes.at(i) < minSizes.at(i))
3954 sectionSizes[i] = minSizes.at(i);
3955 foundMinimumViolation =
true;
3956 minimumLockedSections.append(i);
3959 if (foundMinimumViolation)
3961 freeSize = totalSize;
3962 for (
int i=0; i<sectionCount; ++i)
3964 if (!minimumLockedSections.contains(i))
3965 unfinishedSections.append(i);
3967 freeSize -= sectionSizes.at(i);
3970 for (
int i=0; i<unfinishedSections.size(); ++i)
3971 sectionSizes[unfinishedSections.at(i)] = 0;
3974 if (outerIterations == sectionCount*2)
3975 qDebug() << Q_FUNC_INFO <<
"Exceeded maximum expected outer iteration count, layouting aborted. Input was:" << maxSizes << minSizes << stretchFactors << totalSize;
3977 QVector<int> result(sectionCount);
3978 for (
int i=0; i<sectionCount; ++i)
3979 result[i] = qRound(sectionSizes.at(i));
4000 minOuter.rwidth() += el->
margins().left() + el->
margins().right();
4002 minOuter.rheight() += el->
margins().top() + el->
margins().bottom();
4004 return QSize(minOuter.width() > 0 ? minOuter.width() : minOuterHint.width(),
4005 minOuter.height() > 0 ? minOuter.height() : minOuterHint.height());;
4025 maxOuter.rwidth() += el->
margins().left() + el->
margins().right();
4027 maxOuter.rheight() += el->
margins().top() + el->
margins().bottom();
4029 return QSize(maxOuter.width() < QWIDGETSIZE_MAX ? maxOuter.width() : maxOuterHint.width(),
4030 maxOuter.height() < QWIDGETSIZE_MAX ? maxOuter.height() : maxOuterHint.height());
4083 mFillOrder(foColumnsFirst)
4106 if (column >= 0 && column <
mElements.first().size())
4111 qDebug() << Q_FUNC_INFO <<
"Requested cell is empty. Row:" << row <<
"Column:" << column;
4113 qDebug() << Q_FUNC_INFO <<
"Invalid column. Row:" << row <<
"Column:" << column;
4115 qDebug() << Q_FUNC_INFO <<
"Invalid row. Row:" << row <<
"Column:" << column;
4138 if (element && element->
layout())
4146 qDebug() << Q_FUNC_INFO <<
"There is already an element in the specified row/column:" << row << column;
4187 return addElement(rowIndex, colIndex, element);
4223 qDebug() << Q_FUNC_INFO <<
"Invalid stretch factor, must be positive:" << factor;
4225 qDebug() << Q_FUNC_INFO <<
"Invalid column:" << column;
4249 qDebug() << Q_FUNC_INFO <<
"Invalid stretch factor, must be positive:" <<
mColumnStretchFactors.at(i);
4254 qDebug() << Q_FUNC_INFO <<
"Column count not equal to passed stretch factor count:" << factors;
4276 qDebug() << Q_FUNC_INFO <<
"Invalid stretch factor, must be positive:" << factor;
4278 qDebug() << Q_FUNC_INFO <<
"Invalid row:" << row;
4302 qDebug() << Q_FUNC_INFO <<
"Invalid stretch factor, must be positive:" <<
mRowStretchFactors.at(i);
4307 qDebug() << Q_FUNC_INFO <<
"Row count not equal to passed stretch factor count:" << factors;
4349 mWrap = qMax(0, count);
4381 QVector<QCPLayoutElement*> tempElements;
4384 tempElements.reserve(elCount);
4385 for (
int i=0; i<elCount; ++i)
4388 tempElements.append(
takeAt(i));
4397 for (
int i=0; i<tempElements.size(); ++i)
4421 mElements.append(QList<QCPLayoutElement*>());
4425 int newColCount = qMax(
columnCount(), newColumnCount);
4428 while (
mElements.at(i).size() < newColCount)
4455 QList<QCPLayoutElement*> newRow;
4482 for (
int row=0; row<
rowCount(); ++row)
4511 qDebug() << Q_FUNC_INFO <<
"row index out of bounds:" << row;
4513 qDebug() << Q_FUNC_INFO <<
"column index out of bounds:" << column;
4538 if (nCols == 0 || nRows == 0)
4542 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
4550 column = index / nRows;
4551 row = index % nRows;
4556 row = index / nCols;
4557 column = index % nCols;
4566 QVector<int> minColWidths, minRowHeights, maxColWidths, maxRowHeights;
4576 int yOffset =
mRect.top();
4577 for (
int row=0; row<
rowCount(); ++row)
4581 int xOffset =
mRect.left();
4587 mElements.at(row).at(col)->setOuterRect(QRect(xOffset, yOffset, colWidths.at(col), rowHeights.at(row)));
4630 qDebug() << Q_FUNC_INFO <<
"Attempt to take invalid index:" << index;
4648 qDebug() << Q_FUNC_INFO <<
"Element not in this layout, couldn't take";
4650 qDebug() << Q_FUNC_INFO <<
"Can't take null element";
4657 QList<QCPLayoutElement*> result;
4659 #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) 4660 result.reserve(elCount);
4662 for (
int i=0; i<elCount; ++i)
4666 for (
int i=0; i<elCount; ++i)
4669 result << result.at(i)->elements(recursive);
4681 for (
int row=
rowCount()-1; row>=0; --row)
4683 bool hasElements =
false;
4704 bool hasElements =
false;
4705 for (
int row=0; row<
rowCount(); ++row)
4716 for (
int row=0; row<
rowCount(); ++row)
4725 QVector<int> minColWidths, minRowHeights;
4728 for (
int i=0; i<minColWidths.size(); ++i)
4729 result.rwidth() += minColWidths.at(i);
4730 for (
int i=0; i<minRowHeights.size(); ++i)
4731 result.rheight() += minRowHeights.at(i);
4742 QVector<int> maxColWidths, maxRowHeights;
4746 for (
int i=0; i<maxColWidths.size(); ++i)
4747 result.setWidth(qMin(result.width()+maxColWidths.at(i), QWIDGETSIZE_MAX));
4748 for (
int i=0; i<maxRowHeights.size(); ++i)
4749 result.setHeight(qMin(result.height()+maxRowHeights.at(i), QWIDGETSIZE_MAX));
4754 if (result.height() > QWIDGETSIZE_MAX)
4755 result.setHeight(QWIDGETSIZE_MAX);
4756 if (result.width() > QWIDGETSIZE_MAX)
4757 result.setWidth(QWIDGETSIZE_MAX);
4777 *minRowHeights = QVector<int>(
rowCount(), 0);
4778 for (
int row=0; row<
rowCount(); ++row)
4785 if (minColWidths->at(col) < minSize.width())
4786 (*minColWidths)[col] = minSize.width();
4787 if (minRowHeights->at(row) < minSize.height())
4788 (*minRowHeights)[row] = minSize.height();
4809 *maxColWidths = QVector<int>(
columnCount(), QWIDGETSIZE_MAX);
4810 *maxRowHeights = QVector<int>(
rowCount(), QWIDGETSIZE_MAX);
4811 for (
int row=0; row<
rowCount(); ++row)
4818 if (maxColWidths->at(col) > maxSize.width())
4819 (*maxColWidths)[col] = maxSize.width();
4820 if (maxRowHeights->at(row) > maxSize.height())
4821 (*maxRowHeights)[row] = maxSize.height();
4879 return mInsetPlacement.at(index);
4882 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4894 return mInsetAlignment.at(index);
4897 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4909 return mInsetRect.at(index);
4912 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4925 mInsetPlacement[index] = placement;
4927 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4941 mInsetAlignment[index] = alignment;
4943 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4960 mInsetRect[index] =
rect;
4962 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4974 if (mInsetPlacement.at(i) == ipFree)
4976 insetRect = QRect(
rect().x()+
rect().width()*mInsetRect.at(i).x(),
4977 rect().y()+
rect().height()*mInsetRect.at(i).y(),
4978 rect().width()*mInsetRect.at(i).width(),
4979 rect().height()*mInsetRect.at(i).height());
4980 if (insetRect.size().width() < finalMinSize.width())
4981 insetRect.setWidth(finalMinSize.width());
4982 if (insetRect.size().height() < finalMinSize.height())
4983 insetRect.setHeight(finalMinSize.height());
4984 if (insetRect.size().width() > finalMaxSize.width())
4985 insetRect.setWidth(finalMaxSize.width());
4986 if (insetRect.size().height() > finalMaxSize.height())
4987 insetRect.setHeight(finalMaxSize.height());
4988 }
else if (mInsetPlacement.at(i) == ipBorderAligned)
4990 insetRect.setSize(finalMinSize);
4991 Qt::Alignment al = mInsetAlignment.at(i);
4992 if (al.testFlag(Qt::AlignLeft)) insetRect.moveLeft(
rect().x());
4993 else if (al.testFlag(Qt::AlignRight)) insetRect.moveRight(
rect().x()+
rect().width());
4994 else insetRect.moveLeft(
rect().x()+
rect().width()*0.5-finalMinSize.width()*0.5);
4995 if (al.testFlag(Qt::AlignTop)) insetRect.moveTop(
rect().y());
4996 else if (al.testFlag(Qt::AlignBottom)) insetRect.moveBottom(
rect().y()+
rect().height());
4997 else insetRect.moveTop(
rect().y()+
rect().height()*0.5-finalMinSize.height()*0.5);
4999 mElements.at(i)->setOuterRect(insetRect);
5012 if (index >= 0 && index <
mElements.size())
5025 mInsetPlacement.removeAt(index);
5026 mInsetAlignment.removeAt(index);
5027 mInsetRect.removeAt(index);
5031 qDebug() << Q_FUNC_INFO <<
"Attempt to take invalid index:" << index;
5049 qDebug() << Q_FUNC_INFO <<
"Element not in this layout, couldn't take";
5051 qDebug() << Q_FUNC_INFO <<
"Can't take null element";
5074 if (
mElements.at(i)->realVisibility() &&
mElements.at(i)->selectTest(pos, onlySelectable) >= 0)
5098 mInsetPlacement.append(ipBorderAligned);
5099 mInsetAlignment.append(alignment);
5100 mInsetRect.append(QRectF(0.6, 0.6, 0.4, 0.4));
5103 qDebug() << Q_FUNC_INFO <<
"Can't add null element";
5124 mInsetPlacement.append(ipFree);
5125 mInsetAlignment.append(Qt::AlignRight|Qt::AlignTop);
5126 mInsetRect.append(rect);
5129 qDebug() << Q_FUNC_INFO <<
"Can't add null element";
5310 QPen penBackup = painter->pen();
5311 QBrush brushBackup = painter->brush();
5312 QPen miterPen = penBackup;
5313 miterPen.setJoinStyle(Qt::MiterJoin);
5314 QBrush brush(painter->pen().color(), Qt::SolidPattern);
5320 QPointF points[3] = {pos.
toPointF(),
5321 (pos-lengthVec+widthVec).toPointF(),
5322 (pos-lengthVec-widthVec).toPointF()
5324 painter->
setPen(miterPen);
5325 painter->setBrush(brush);
5326 painter->drawConvexPolygon(points, 3);
5327 painter->setBrush(brushBackup);
5328 painter->
setPen(penBackup);
5333 QPointF points[4] = {pos.
toPointF(),
5334 (pos-lengthVec+widthVec).toPointF(),
5335 (pos-lengthVec*0.8).toPointF(),
5336 (pos-lengthVec-widthVec).toPointF()
5338 painter->
setPen(miterPen);
5339 painter->setBrush(brush);
5340 painter->drawConvexPolygon(points, 4);
5341 painter->setBrush(brushBackup);
5342 painter->
setPen(penBackup);
5347 QPointF points[3] = {(pos-lengthVec+widthVec).toPointF(),
5349 (pos-lengthVec-widthVec).toPointF()
5351 painter->
setPen(miterPen);
5352 painter->drawPolyline(points, 3);
5353 painter->
setPen(penBackup);
5358 painter->setBrush(brush);
5360 painter->setBrush(brushBackup);
5366 QPointF points[4] = {(pos-widthVecPerp+widthVec).toPointF(),
5367 (pos-widthVecPerp-widthVec).toPointF(),
5368 (pos+widthVecPerp-widthVec).toPointF(),
5369 (pos+widthVecPerp+widthVec).toPointF()
5371 painter->
setPen(miterPen);
5372 painter->setBrush(brush);
5373 painter->drawConvexPolygon(points, 4);
5374 painter->setBrush(brushBackup);
5375 painter->
setPen(penBackup);
5381 QPointF points[4] = {(pos-widthVecPerp).toPointF(),
5382 (pos-widthVec).toPointF(),
5383 (pos+widthVecPerp).toPointF(),
5384 (pos+widthVec).toPointF()
5386 painter->
setPen(miterPen);
5387 painter->setBrush(brush);
5388 painter->drawConvexPolygon(points, 4);
5389 painter->setBrush(brushBackup);
5390 painter->
setPen(penBackup);
5395 painter->
drawLine((pos+widthVec).toPointF(), (pos-widthVec).toPointF());
5409 (pos-widthVec-lengthVec*0.2*(
mInverted?-1:1)).toPointF());
5413 painter->
drawLine((pos+widthVec+lengthVec*0.2*(
mInverted?-1:1)+dir.
normalized()*qMax(1.0
f, (
float)painter->pen().widthF())*0.5
f).toPointF(),
5414 (pos-widthVec-lengthVec*0.2*(
mInverted?-1:1)+dir.
normalized()*qMax(1.0
f, (
float)painter->pen().widthF())*0.5
f).toPointF());
5497 mTickStepStrategy(tssReadability),
5530 qDebug() << Q_FUNC_INFO <<
"tick count must be greater than zero:" << count;
5559 void QCPAxisTicker::generate(
const QCPRange &range,
const QLocale &locale, QChar formatChar,
int precision, QVector<double> &ticks, QVector<double> *subTicks, QVector<QString> *tickLabels)
5569 if (ticks.size() > 0)
5574 *subTicks = QVector<double>();
5615 double fracPart = modf(
getMantissa(tickStep), &intPartf);
5619 if (fracPart < epsilon || 1.0-fracPart < epsilon)
5621 if (1.0-fracPart < epsilon)
5625 case 1: result = 4;
break;
5626 case 2: result = 3;
break;
5627 case 3: result = 2;
break;
5628 case 4: result = 3;
break;
5629 case 5: result = 4;
break;
5630 case 6: result = 2;
break;
5631 case 7: result = 6;
break;
5632 case 8: result = 3;
break;
5633 case 9: result = 2;
break;
5638 if (qAbs(fracPart-0.5) < epsilon)
5642 case 1: result = 2;
break;
5643 case 2: result = 4;
break;
5644 case 3: result = 4;
break;
5645 case 4: result = 2;
break;
5646 case 5: result = 4;
break;
5647 case 6: result = 4;
break;
5648 case 7: result = 2;
break;
5649 case 8: result = 4;
break;
5650 case 9: result = 4;
break;
5672 return locale.toString(tick, formatChar.toLatin1(), precision);
5686 QVector<double> result;
5687 if (subTickCount <= 0 || ticks.size() < 2)
5690 result.reserve((ticks.size()-1)*subTickCount);
5691 for (
int i=1; i<ticks.size(); ++i)
5693 double subTickStep = (ticks.at(i)-ticks.at(i-1))/(
double)(subTickCount+1);
5694 for (
int k=1; k<=subTickCount; ++k)
5695 result.append(ticks.at(i-1) + k*subTickStep);
5717 QVector<double> result;
5721 int tickcount = lastStep-firstStep+1;
5722 if (tickcount < 0) tickcount = 0;
5723 result.resize(tickcount);
5724 for (
int i=0; i<tickcount; ++i)
5740 QVector<QString> result;
5741 result.reserve(ticks.size());
5742 for (
int i=0; i<ticks.size(); ++i)
5743 result.append(
getTickLabel(ticks.at(i), locale, formatChar, precision));
5756 bool lowFound =
false;
5757 bool highFound =
false;
5761 for (
int i=0; i < ticks.size(); ++i)
5763 if (ticks.at(i) >= range.
lower)
5770 for (
int i=ticks.size()-1; i >= 0; --i)
5772 if (ticks.at(i) <= range.
upper)
5780 if (highFound && lowFound)
5782 int trimFront = qMax(0, lowIndex-(keepOneOutlier ? 1 : 0));
5783 int trimBack = qMax(0, ticks.size()-(keepOneOutlier ? 2 : 1)-highIndex);
5784 if (trimFront > 0 || trimBack > 0)
5785 ticks = ticks.mid(trimFront, ticks.size()-trimFront-trimBack);
5798 if (candidates.size() == 1)
5799 return candidates.first();
5800 QVector<double>::const_iterator it = std::lower_bound(candidates.constBegin(), candidates.constEnd(), target);
5801 if (it == candidates.constEnd())
5803 else if (it == candidates.constBegin())
5806 return target-*(it-1) < *it-target ? *(it-1) : *it;
5818 const double mag = qPow(10.0, qFloor(qLn(input)/qLn(10.0)));
5819 if (magnitude) *magnitude = mag;
5832 const double mantissa =
getMantissa(input, &magnitude);
5837 return pickClosest(mantissa, QVector<double>() << 1.0 << 2.0 << 2.5 << 5.0 << 10.0)*magnitude;
5842 if (mantissa <= 5.0)
5843 return (
int)(mantissa*2)/2.0*magnitude;
5845 return (
int)(mantissa/2.0)*2.0*magnitude;
5900 mDateTimeFormat(QLatin1String(
"hh:mm:ss\ndd.MM.yy")),
5901 mDateTimeSpec(Qt::LocalTime),
5902 mDateStrategy(dsNone)
5982 }
else if (result < 86400*30.4375*12)
5985 << 1 << 2.5 << 5 << 10 << 15 << 30 << 60 << 2.5*60 << 5*60 << 10*60 << 15*60 << 30*60 << 60*60
5986 << 3600*2 << 3600*3 << 3600*6 << 3600*12 << 3600*24
5987 << 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);
5988 if (result > 86400*30.4375-1)
5990 else if (result > 3600*24-1)
5994 const double secondsPerYear = 86400*30.4375*12;
5995 result =
cleanMantissa(result/secondsPerYear)*secondsPerYear;
6011 switch (qRound(tickStep))
6013 case 5*60: result = 4;
break;
6014 case 10*60: result = 1;
break;
6015 case 15*60: result = 2;
break;
6016 case 30*60: result = 1;
break;
6017 case 60*60: result = 3;
break;
6018 case 3600*2: result = 3;
break;
6019 case 3600*3: result = 2;
break;
6020 case 3600*6: result = 1;
break;
6021 case 3600*12: result = 3;
break;
6022 case 3600*24: result = 3;
break;
6023 case 86400*2: result = 1;
break;
6024 case 86400*5: result = 4;
break;
6025 case 86400*7: result = 6;
break;
6026 case 86400*14: result = 1;
break;
6027 case (
int)(86400*30.4375+0.5): result = 3;
break;
6028 case (
int)(86400*30.4375*2+0.5): result = 1;
break;
6029 case (
int)(86400*30.4375*3+0.5): result = 2;
break;
6030 case (
int)(86400*30.4375*6+0.5): result = 5;
break;
6031 case (
int)(86400*30.4375*12+0.5): result = 3;
break;
6046 Q_UNUSED(formatChar)
6060 if (!result.isEmpty())
6065 QDateTime tickDateTime;
6066 for (
int i=0; i<result.size(); ++i)
6069 tickDateTime.setTime(uniformDateTime.time());
6075 QDateTime tickDateTime;
6076 for (
int i=0; i<result.size(); ++i)
6079 tickDateTime.setTime(uniformDateTime.time());
6080 int thisUniformDay = uniformDateTime.date().day() <= tickDateTime.date().daysInMonth() ? uniformDateTime.date().day() : tickDateTime.date().daysInMonth();
6081 if (thisUniformDay-tickDateTime.date().day() < -15)
6082 tickDateTime = tickDateTime.addMonths(1);
6083 else if (thisUniformDay-tickDateTime.date().day() > 15)
6084 tickDateTime = tickDateTime.addMonths(-1);
6085 tickDateTime.setDate(QDate(tickDateTime.date().year(), tickDateTime.date().month(), thisUniformDay));
6104 # if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) 6105 return QDateTime::fromTime_t(key).addMSecs((key-(qint64)key)*1000);
6107 return QDateTime::fromMSecsSinceEpoch(key*1000.0);
6124 # if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) 6125 return dateTime.toTime_t()+dateTime.time().msec()/1000.0;
6127 return dateTime.toMSecsSinceEpoch()/1000.0;
6141 # if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) 6142 return QDateTime(date).toTime_t();
6144 return QDateTime(date).toMSecsSinceEpoch()/1000.0;
6197 mTimeFormat(QLatin1String(
"%h:%m:%s")),
6198 mSmallestUnit(tuSeconds),
6199 mBiggestUnit(tuHours)
6241 bool hasSmallest =
false;
6288 }
else if (result < 3600*24)
6291 QVector<double> availableSteps;
6294 availableSteps << 1;
6296 availableSteps << 2.5;
6298 availableSteps << 2;
6300 availableSteps << 5 << 10 << 15 << 30;
6303 availableSteps << 1*60;
6305 availableSteps << 2.5*60;
6307 availableSteps << 2*60;
6309 availableSteps << 5*60 << 10*60 << 15*60 << 30*60;
6312 availableSteps << 1*3600 << 2*3600 << 3*3600 << 6*3600 << 12*3600 << 24*3600;
6317 const double secondsPerDay = 3600*24;
6332 switch (qRound(tickStep))
6334 case 5*60: result = 4;
break;
6335 case 10*60: result = 1;
break;
6336 case 15*60: result = 2;
break;
6337 case 30*60: result = 1;
break;
6338 case 60*60: result = 3;
break;
6339 case 3600*2: result = 3;
break;
6340 case 3600*3: result = 2;
break;
6341 case 3600*6: result = 1;
break;
6342 case 3600*12: result = 3;
break;
6343 case 3600*24: result = 3;
break;
6358 Q_UNUSED(formatChar)
6360 bool negative = tick < 0;
6361 if (negative) tick *= -1;
6363 double restValues[
tuDays+1];
6368 values[
tuMinutes] = modf(restValues[tuMinutes]/60, &restValues[
tuHours])*60;
6369 values[
tuHours] = modf(restValues[tuHours]/24, &restValues[
tuDays])*24;
6379 result.prepend(QLatin1Char(
'-'));
6390 QString valueStr = QString::number(value);
6392 valueStr.prepend(QLatin1Char(
'0'));
6431 mScaleStrategy(ssNone)
6449 qDebug() << Q_FUNC_INFO <<
"tick step must be greater than zero:" << step;
6588 qDebug() << Q_FUNC_INFO <<
"sub tick count can't be negative:" << subTicks;
6612 mTicks.insert(position, label);
6643 if (positions.size() != labels.size())
6644 qDebug() << Q_FUNC_INFO <<
"passed unequal length vectors for positions and labels:" << positions.size() << labels.size();
6645 int n = qMin(positions.size(), labels.size());
6646 for (
int i=0; i<n; ++i)
6647 mTicks.insert(positions.at(i), labels.at(i));
6682 Q_UNUSED(formatChar)
6684 return mTicks.value(tick);
6697 QVector<double> result;
6701 QMap<double, QString>::const_iterator
start =
mTicks.lowerBound(range.
lower);
6702 QMap<double, QString>::const_iterator end =
mTicks.upperBound(range.
upper);
6704 if (start !=
mTicks.constBegin()) --start;
6705 if (end !=
mTicks.constEnd()) ++end;
6706 for (QMap<double, QString>::const_iterator it = start; it != end; ++it)
6707 result.append(it.key());
6741 mPiSymbol(QLatin1String(
" ")+QChar(0x03C0)),
6744 mFractionStyle(fsUnicodeFractions),
6840 int denominator = 1000;
6841 int numerator = qRound(tickInPis*denominator);
6843 if (qAbs(numerator) == 1 && denominator == 1)
6844 return (numerator < 0 ? QLatin1String(
"-") : QLatin1String(
"")) +
mPiSymbol.trimmed();
6845 else if (numerator == 0)
6846 return QLatin1String(
"0");
6851 if (qFuzzyIsNull(tickInPis))
6852 return QLatin1String(
"0");
6853 else if (qFuzzyCompare(qAbs(tickInPis), 1.0))
6854 return (tickInPis < 0 ? QLatin1String(
"-") : QLatin1String(
"")) +
mPiSymbol.trimmed();
6868 if (numerator == 0 || denominator == 0)
6871 int num = numerator;
6872 int denom = denominator;
6875 int oldDenom = denom;
6876 denom = num % denom;
6895 if (denominator == 0)
6897 qDebug() << Q_FUNC_INFO <<
"called with zero denominator";
6902 qDebug() << Q_FUNC_INFO <<
"shouldn't be called with fraction style fsDecimal";
6903 return QString::number(numerator/(
double)denominator);
6905 int sign = numerator*denominator < 0 ? -1 : 1;
6906 numerator = qAbs(numerator);
6907 denominator = qAbs(denominator);
6909 if (denominator == 1)
6911 return QString::number(sign*numerator);
6914 int integerPart = numerator/denominator;
6915 int remainder = numerator%denominator;
6918 return QString::number(sign*integerPart);
6923 return QString(QLatin1String(
"%1%2%3/%4"))
6924 .arg(sign == -1 ? QLatin1String(
"-") : QLatin1String(
""))
6925 .arg(integerPart > 0 ? QString::number(integerPart)+QLatin1String(
" ") : QLatin1String(
""))
6930 return QString(QLatin1String(
"%1%2%3"))
6931 .arg(sign == -1 ? QLatin1String(
"-") : QLatin1String(
""))
6932 .arg(integerPart > 0 ? QString::number(integerPart) : QLatin1String(
""))
6962 return QString(QChar(0x2070));
6967 const int digit = number%10;
6970 case 1: { result.prepend(QChar(0x00B9));
break; }
6971 case 2: { result.prepend(QChar(0x00B2));
break; }
6972 case 3: { result.prepend(QChar(0x00B3));
break; }
6973 default: { result.prepend(QChar(0x2070+digit));
break; }
6988 return QString(QChar(0x2080));
6993 result.prepend(QChar(0x2080+number%10));
7034 mLogBaseLnInv(1.0/qLn(mLogBase))
7049 qDebug() << Q_FUNC_INFO <<
"log base has to be greater than zero:" << base;
7067 qDebug() << Q_FUNC_INFO <<
"sub tick count can't be negative:" << subTicks;
7109 QVector<double> result;
7114 double currentTick = qPow(newLogBase, qFloor(qLn(range.
lower)/qLn(newLogBase)));
7115 result.append(currentTick);
7116 while (currentTick < range.upper && currentTick > 0)
7118 currentTick *= newLogBase;
7119 result.append(currentTick);
7121 }
else if (range.
lower < 0 && range.
upper < 0)
7125 double currentTick = -qPow(newLogBase, qCeil(qLn(-range.
lower)/qLn(newLogBase)));
7126 result.append(currentTick);
7127 while (currentTick < range.
upper && currentTick < 0)
7129 currentTick /= newLogBase;
7130 result.append(currentTick);
7134 qDebug() << Q_FUNC_INFO <<
"Invalid range for logarithmic plot: " << range.
lower <<
".." << range.
upper;
7169 QCPLayerable(parentAxis->parentPlot(), QString(), parentAxis),
7170 mParentAxis(parentAxis)
7173 setParent(parentAxis);
7174 setPen(QPen(QColor(200,200,200), 0, Qt::DotLine));
7261 if (!
mParentAxis) { qDebug() << Q_FUNC_INFO <<
"invalid parent axis";
return; }
7276 if (!
mParentAxis) { qDebug() << Q_FUNC_INFO <<
"invalid parent axis";
return; }
7283 int zeroLineIndex = -1;
7289 for (
int i=0; i<tickCount; ++i)
7303 for (
int i=0; i<tickCount; ++i)
7305 if (i == zeroLineIndex)
continue;
7312 int zeroLineIndex = -1;
7318 for (
int i=0; i<tickCount; ++i)
7332 for (
int i=0; i<tickCount; ++i)
7334 if (i == zeroLineIndex)
continue;
7349 if (!
mParentAxis) { qDebug() << Q_FUNC_INFO <<
"invalid parent axis";
return; }
7512 mOrientation(orientation(type)),
7513 mSelectableParts(spAxis | spTickLabels | spAxisLabel),
7514 mSelectedParts(spNone),
7515 mBasePen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
7516 mSelectedBasePen(QPen(Qt::blue, 2)),
7520 mSelectedLabelFont(QFont(mLabelFont.family(), mLabelFont.pointSize(), QFont::Bold)),
7521 mLabelColor(Qt::black),
7522 mSelectedLabelColor(Qt::blue),
7526 mSelectedTickLabelFont(QFont(mTickLabelFont.family(), mTickLabelFont.pointSize(), QFont::Bold)),
7527 mTickLabelColor(Qt::black),
7528 mSelectedTickLabelColor(Qt::blue),
7529 mNumberPrecision(6),
7530 mNumberFormatChar(
'g'),
7531 mNumberBeautifulPowers(true),
7535 mTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
7536 mSelectedTickPen(QPen(Qt::blue, 2)),
7537 mSubTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
7538 mSelectedSubTickPen(QPen(Qt::blue, 2)),
7541 mRangeReversed(false),
7542 mScaleType(stLinear),
7547 mCachedMarginValid(false),
7567 }
else if (type ==
atLeft)
7605 result.append(QLatin1Char(
'b'));
7607 result.append(QLatin1Char(
'c'));
7797 if (alignment == Qt::AlignLeft)
7799 else if (alignment == Qt::AlignRight)
7802 setRange(position-size/2.0, position+size/2.0);
7881 qDebug() << Q_FUNC_INFO <<
"can not set 0 as axis ticker";
8016 if (formatCode.isEmpty())
8018 qDebug() << Q_FUNC_INFO <<
"Passed formatCode is empty";
8024 QString allowedFormatChars(QLatin1String(
"eEfgG"));
8025 if (allowedFormatChars.contains(formatCode.at(0)))
8030 qDebug() << Q_FUNC_INFO <<
"Invalid number format code (first char not in 'eEfgG'):" << formatCode;
8033 if (formatCode.length() < 2)
8046 qDebug() << Q_FUNC_INFO <<
"Invalid number format code (second char not 'b' or first char neither 'e' nor 'g'):" << formatCode;
8049 if (formatCode.length() < 3)
8056 if (formatCode.at(2) == QLatin1Char(
'c'))
8059 }
else if (formatCode.at(2) == QLatin1Char(
'd'))
8064 qDebug() << Q_FUNC_INFO <<
"Invalid number format code (third char neither 'c' nor 'd'):" << formatCode;
8474 qDebug() << Q_FUNC_INFO <<
"Center of scaling operation doesn't lie in same logarithmic sign domain as range:" << center;
8495 int otherPixelSize, ownPixelSize;
8507 double newRangeSize = ratio*otherAxis->
range().
size()*ownPixelSize/(double)otherPixelSize;
8519 QList<QCPAbstractPlottable*> p =
plottables();
8521 bool haveRange =
false;
8522 for (
int i=0; i<p.size(); ++i)
8524 if (!p.at(i)->realVisibility() && onlyVisiblePlottables)
8527 bool currentFoundRange;
8531 if (p.at(i)->keyAxis() ==
this)
8532 plottableRange = p.at(i)->getKeyRange(currentFoundRange, signDomain);
8534 plottableRange = p.at(i)->getValueRange(currentFoundRange, signDomain);
8535 if (currentFoundRange)
8538 newRange = plottableRange;
8540 newRange.
expand(plottableRange);
8548 double center = (newRange.
lower+newRange.
upper)*0.5;
8618 else if (value <= 0.0 && mRange.upper >= 0.0)
8640 else if (value <= 0.0 && mRange.upper >= 0.0)
8686 details->setValue(part);
8699 QList<QCPAbstractPlottable*> result;
8717 QList<QCPGraph*> result;
8736 QList<QCPAbstractItem*> result;
8741 QList<QCPItemPosition*> positions =
mParentPlot->
mItems.at(itemId)->positions();
8742 for (
int posId=0; posId<positions.size(); ++posId)
8744 if (positions.at(posId)->keyAxis() ==
this || positions.at(posId)->valueAxis() ==
this)
8768 qDebug() << Q_FUNC_INFO <<
"Invalid margin side passed:" << (int)side;
8783 default: qDebug() << Q_FUNC_INFO <<
"invalid axis type";
return atLeft;
break;
8796 if (selectionStateChanged)
8806 if (selectionStateChanged)
8836 if (event->buttons() & Qt::LeftButton)
8867 const double startPixel =
orientation() == Qt::Horizontal ? startPos.x() : startPos.y();
8868 const double currentPixel =
orientation() == Qt::Horizontal ?
event->pos().x() :
event->pos().y();
8935 const double wheelSteps =
event->delta()/120.0;
8969 QVector<double> subTickPositions;
8970 QVector<double> tickPositions;
8988 for (
int i=0; i<subTickCount; ++i)
9128 QVector<double> tickPositions;
9189 basePen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
9196 substituteExponent(true),
9197 numberMultiplyCross(false),
9202 tickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
9203 subTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
9205 abbreviateDecimalPowers(false),
9206 reversedEndings(false),
9241 double xCor = 0, yCor = 0;
9253 baseLine.setPoints(origin+QPointF(xCor, yCor), origin+QPointF(
axisRect.width()+xCor, yCor));
9255 baseLine.setPoints(origin+QPointF(xCor, yCor), origin+QPointF(xCor, -
axisRect.height()+yCor));
9257 baseLine = QLineF(baseLine.p2(), baseLine.p1());
9297 painter->setBrush(QBrush(
basePen.color()));
9298 QCPVector2D baseLineVector(baseLine.dx(), baseLine.dy());
9309 oldClipRect = painter->clipRegion().boundingRect();
9312 QSize tickLabelsSize(0, 0);
9320 int distanceToAxis = margin;
9323 for (
int i=0; i<maxLabelIndex; ++i)
9329 painter->setClipRect(oldClipRect);
9333 if (!
label.isEmpty())
9338 labelBounds = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip,
label);
9341 QTransform oldTransform = painter->transform();
9342 painter->translate((origin.x()-margin-labelBounds.height()), origin.y());
9343 painter->rotate(-90);
9344 painter->drawText(0, 0,
axisRect.height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter,
label);
9345 painter->setTransform(oldTransform);
9349 QTransform oldTransform = painter->transform();
9350 painter->translate((origin.x()+margin+labelBounds.height()), origin.y()-
axisRect.height());
9351 painter->rotate(90);
9352 painter->drawText(0, 0,
axisRect.height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter,
label);
9353 painter->setTransform(oldTransform);
9356 painter->drawText(origin.x(), origin.y()-margin-labelBounds.height(),
axisRect.width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter,
label);
9358 painter->drawText(origin.x(), origin.y()+margin,
axisRect.width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter,
label);
9362 int selectionTolerance = 0;
9366 qDebug() << Q_FUNC_INFO <<
"mParentPlot is null";
9368 int selAxisInSize = selectionTolerance;
9369 int selTickLabelSize;
9370 int selTickLabelOffset;
9373 selTickLabelSize = (
QCPAxis::orientation(
type) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width());
9377 selTickLabelSize = -(
QCPAxis::orientation(
type) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width());
9380 int selLabelSize = labelBounds.height();
9427 QSize tickLabelsSize(0, 0);
9438 if (!
label.isEmpty())
9442 bounds = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter | Qt::AlignVCenter,
label);
9502 if (text.isEmpty())
return;
9504 QPointF labelAnchor;
9523 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 9524 # ifdef QCP_DEVICEPIXELRATIO_FLOAT 9532 cachedLabel->
pixmap.fill(Qt::transparent);
9534 cachePainter.
setPen(painter->pen());
9538 bool labelClippedByBorder =
false;
9546 if (!labelClippedByBorder)
9548 painter->drawPixmap(labelAnchor+cachedLabel->
offset, cachedLabel->
pixmap);
9557 bool labelClippedByBorder =
false;
9565 if (!labelClippedByBorder)
9567 drawTickLabel(painter, finalPosition.x(), finalPosition.y(), labelData);
9573 if (finalSize.width() > tickLabelsSize->width())
9574 tickLabelsSize->setWidth(finalSize.width());
9575 if (finalSize.height() > tickLabelsSize->height())
9576 tickLabelsSize->setHeight(finalSize.height());
9591 QTransform oldTransform = painter->transform();
9592 QFont oldFont = painter->font();
9595 painter->translate(x, y);
9600 if (!labelData.
expPart.isEmpty())
9602 painter->setFont(labelData.
baseFont);
9603 painter->drawText(0, 0, 0, 0, Qt::TextDontClip, labelData.
basePart);
9606 painter->setFont(labelData.
expFont);
9610 painter->setFont(labelData.
baseFont);
9615 painter->setTransform(oldTransform);
9616 painter->setFont(oldFont);
9632 bool useBeautifulPowers =
false;
9637 ePos = text.indexOf(QLatin1Char(
'e'));
9638 if (ePos > 0 && text.at(ePos-1).isDigit())
9641 while (eLast+1 < text.size() && (text.at(eLast+1) == QLatin1Char(
'+') || text.at(eLast+1) == QLatin1Char(
'-') || text.at(eLast+1).isDigit()))
9644 useBeautifulPowers =
true;
9650 if (result.
baseFont.pointSizeF() > 0)
9652 if (useBeautifulPowers)
9659 result.
basePart = QLatin1String(
"10");
9662 result.
expPart = text.mid(ePos+1, eLast-ePos);
9664 while (result.
expPart.length() > 2 && result.
expPart.at(1) == QLatin1Char(
'0'))
9666 if (!result.
expPart.isEmpty() && result.
expPart.at(0) == QLatin1Char(
'+'))
9670 if (result.
expFont.pointSize() > 0)
9683 result.
totalBounds = QFontMetrics(result.
baseFont).boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter, result.
basePart);
9691 QTransform transform;
9749 x = +qSin(radians)*labelData.
totalBounds.height();
9771 x = -qSin(-radians)*labelData.
totalBounds.height()/2.0;
9772 y = -qCos(-radians)*labelData.
totalBounds.height();
9785 x = +qSin(radians)*labelData.
totalBounds.height()/2.0;
9790 y = +qSin(-radians)*labelData.
totalBounds.width();
9799 return QPointF(x, y);
9824 if (finalSize.width() > tickLabelsSize->width())
9825 tickLabelsSize->setWidth(finalSize.width());
9826 if (finalSize.height() > tickLabelsSize->height())
9827 tickLabelsSize->setHeight(finalSize.height());
9924 mBrush(Qt::NoBrush),
10033 if (properties.testFlag(
spPen))
10039 if (properties.testFlag(
spBrush))
10041 if (properties.testFlag(
spSize))
10043 if (properties.testFlag(
spShape))
10149 painter->setBrush(
mBrush);
10170 double w =
mSize/2.0;
10176 painter->
drawLine(QPointF(x, y), QPointF(x+0.0001, y));
10181 painter->
drawLine(QLineF(x-w, y-w, x+w, y+w));
10182 painter->
drawLine(QLineF(x-w, y+w, x+w, y-w));
10187 painter->
drawLine(QLineF(x-w, y, x+w, y));
10188 painter->
drawLine(QLineF( x, y+w, x, y-w));
10193 painter->drawEllipse(QPointF(x , y), w, w);
10198 QBrush b = painter->brush();
10199 painter->setBrush(painter->pen().color());
10200 painter->drawEllipse(QPointF(x , y), w, w);
10201 painter->setBrush(b);
10206 painter->drawRect(QRectF(x-w, y-w,
mSize,
mSize));
10211 QPointF lineArray[4] = {QPointF(x-w, y),
10215 painter->drawPolygon(lineArray, 4);
10220 painter->
drawLine(QLineF(x-w, y, x+w, y));
10221 painter->
drawLine(QLineF( x, y+w, x, y-w));
10222 painter->
drawLine(QLineF(x-w*0.707, y-w*0.707, x+w*0.707, y+w*0.707));
10223 painter->
drawLine(QLineF(x-w*0.707, y+w*0.707, x+w*0.707, y-w*0.707));
10228 QPointF lineArray[3] = {QPointF(x-w, y+0.755*w),
10229 QPointF(x+w, y+0.755*w),
10230 QPointF( x, y-0.977*w)};
10231 painter->drawPolygon(lineArray, 3);
10236 QPointF lineArray[3] = {QPointF(x-w, y-0.755*w),
10237 QPointF(x+w, y-0.755*w),
10238 QPointF( x, y+0.977*w)};
10239 painter->drawPolygon(lineArray, 3);
10244 painter->drawRect(QRectF(x-w, y-w,
mSize,
mSize));
10245 painter->
drawLine(QLineF(x-w, y-w, x+w*0.95, y+w*0.95));
10246 painter->
drawLine(QLineF(x-w, y+w*0.95, x+w*0.95, y-w));
10251 painter->drawRect(QRectF(x-w, y-w,
mSize,
mSize));
10252 painter->
drawLine(QLineF(x-w, y, x+w*0.95, y));
10253 painter->
drawLine(QLineF( x, y+w, x, y-w));
10258 painter->drawEllipse(QPointF(x, y), w, w);
10259 painter->
drawLine(QLineF(x-w*0.707, y-w*0.707, x+w*0.670, y+w*0.670));
10260 painter->
drawLine(QLineF(x-w*0.707, y+w*0.670, x+w*0.670, y-w*0.707));
10265 painter->drawEllipse(QPointF(x, y), w, w);
10266 painter->
drawLine(QLineF(x-w, y, x+w, y));
10267 painter->
drawLine(QLineF( x, y+w, x, y-w));
10272 painter->drawEllipse(QPointF(x, y), w, w);
10273 painter->
drawLine(QLineF(x, y-w, x, y+w));
10274 painter->
drawLine(QLineF(x, y, x-w*0.707, y+w*0.707));
10275 painter->
drawLine(QLineF(x, y, x+w*0.707, y+w*0.707));
10280 const double widthHalf =
mPixmap.width()*0.5;
10281 const double heightHalf =
mPixmap.height()*0.5;
10282 #if QT_VERSION < QT_VERSION_CHECK(4, 8, 0) 10283 const QRectF clipRect = painter->clipRegion().boundingRect().adjusted(-widthHalf, -heightHalf, widthHalf, heightHalf);
10285 const QRectF clipRect = painter->clipBoundingRect().adjusted(-widthHalf, -heightHalf, widthHalf, heightHalf);
10287 if (clipRect.contains(x, y))
10288 painter->drawPixmap(x-widthHalf, y-heightHalf,
mPixmap);
10293 QTransform oldTransform = painter->transform();
10294 painter->translate(x, y);
10297 painter->setTransform(oldTransform);
10343 mPen(QColor(80, 80, 255), 2.5),
10413 painter->setBrush(
mBrush);
10460 Q_UNUSED(selection)
10480 qDebug() << Q_FUNC_INFO <<
"This selection decorator is already registered with plottable:" <<
reinterpret_cast<quintptr
>(
mPlottable);
10702 QCPLayerable(keyAxis->parentPlot(), QString(), keyAxis->axisRect()),
10704 mAntialiasedFill(true),
10705 mAntialiasedScatters(true),
10709 mValueAxis(valueAxis),
10711 mSelectionDecorator(0)
10714 qDebug() << Q_FUNC_INFO <<
"Parent plot of keyAxis is not the same as that of valueAxis.";
10716 qDebug() << Q_FUNC_INFO <<
"keyAxis and valueAxis must be orthogonal to each other.";
10917 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
10938 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPointF(); }
10959 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
11008 if (!keyAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key axis";
return; }
11022 double center = (newRange.
lower+newRange.
upper)*0.5;
11051 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
11065 double center = (newRange.
lower+newRange.
upper)*0.5;
11098 qDebug() << Q_FUNC_INFO <<
"passed legend is null";
11103 qDebug() << Q_FUNC_INFO <<
"passed legend isn't in the same QCustomPlot as this plottable";
11143 qDebug() << Q_FUNC_INFO <<
"passed legend is null";
11260 if (selectionStateChanged)
11261 *selectionStateChanged =
mSelection != selectionBefore;
11272 if (selectionStateChanged)
11273 *selectionStateChanged =
mSelection != selectionBefore;
11329 mParentItem(parentItem),
11330 mAnchorId(anchorId)
11364 qDebug() << Q_FUNC_INFO <<
"no valid anchor id set:" <<
mAnchorId;
11369 qDebug() << Q_FUNC_INFO <<
"no parent item set";
11387 qDebug() << Q_FUNC_INFO <<
"provided pos is child already" <<
reinterpret_cast<quintptr
>(pos);
11399 qDebug() << Q_FUNC_INFO <<
"provided pos isn't child" <<
reinterpret_cast<quintptr
>(pos);
11415 qDebug() << Q_FUNC_INFO <<
"provided pos is child already" <<
reinterpret_cast<quintptr
>(pos);
11427 qDebug() << Q_FUNC_INFO <<
"provided pos isn't child" <<
reinterpret_cast<quintptr
>(pos);
11501 mPositionTypeX(ptAbsolute),
11502 mPositionTypeY(ptAbsolute),
11582 bool retainPixelPosition =
true;
11584 retainPixelPosition =
false;
11586 retainPixelPosition =
false;
11589 if (retainPixelPosition)
11594 if (retainPixelPosition)
11612 bool retainPixelPosition =
true;
11614 retainPixelPosition =
false;
11616 retainPixelPosition =
false;
11619 if (retainPixelPosition)
11624 if (retainPixelPosition)
11651 return successX && successY;
11664 if (parentAnchor ==
this)
11666 qDebug() << Q_FUNC_INFO <<
"can't set self as parent anchor" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11671 while (currentParent)
11676 if (currentParentPos ==
this)
11678 qDebug() << Q_FUNC_INFO <<
"can't create recursive parent-child-relationship" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11681 currentParent = currentParentPos->parentAnchorX();
11689 qDebug() << Q_FUNC_INFO <<
"can't set parent to be an anchor which itself depends on this position" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11702 if (keepPixelPosition)
11712 if (keepPixelPosition)
11729 if (parentAnchor ==
this)
11731 qDebug() << Q_FUNC_INFO <<
"can't set self as parent anchor" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11736 while (currentParent)
11741 if (currentParentPos ==
this)
11743 qDebug() << Q_FUNC_INFO <<
"can't create recursive parent-child-relationship" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11746 currentParent = currentParentPos->parentAnchorY();
11754 qDebug() << Q_FUNC_INFO <<
"can't set parent to be an anchor which itself depends on this position" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11767 if (keepPixelPosition)
11777 if (keepPixelPosition)
11832 result.rx() =
mKey;
11854 result.rx() +=
mAxisRect.data()->left();
11856 qDebug() << Q_FUNC_INFO <<
"Item position type x is ptAxisRectRatio, but no axis rect was defined";
11866 qDebug() << Q_FUNC_INFO <<
"Item position type x is ptPlotCoords, but no axes were defined";
11898 result.ry() +=
mAxisRect.data()->top();
11900 qDebug() << Q_FUNC_INFO <<
"Item position type y is ptAxisRectRatio, but no axis rect was defined";
11910 qDebug() << Q_FUNC_INFO <<
"Item position type y is ptPlotCoords, but no axes were defined";
11951 double x = pixelPosition.x();
11952 double y = pixelPosition.y();
11979 x /= (double)
mAxisRect.data()->width();
11981 qDebug() << Q_FUNC_INFO <<
"Item position type x is ptAxisRectRatio, but no axis rect was defined";
11987 x =
mKeyAxis.data()->pixelToCoord(x);
11991 qDebug() << Q_FUNC_INFO <<
"Item position type x is ptPlotCoords, but no axes were defined";
12021 y /= (double)
mAxisRect.data()->height();
12023 qDebug() << Q_FUNC_INFO <<
"Item position type y is ptAxisRectRatio, but no axis rect was defined";
12029 x =
mKeyAxis.data()->pixelToCoord(y);
12033 qDebug() << Q_FUNC_INFO <<
"Item position type y is ptPlotCoords, but no axes were defined";
12216 mClipToAxisRect(false),
12222 QList<QCPAxisRect*> rects = parentPlot->
axisRects();
12223 if (rects.size() > 0)
12326 qDebug() << Q_FUNC_INFO <<
"position with name not found:" << name;
12342 for (
int i=0; i<
mAnchors.size(); ++i)
12344 if (
mAnchors.at(i)->name() == name)
12347 qDebug() << Q_FUNC_INFO <<
"anchor with name not found:" << name;
12361 for (
int i=0; i<
mAnchors.size(); ++i)
12363 if (
mAnchors.at(i)->name() == name)
12419 double result = -1;
12422 QList<QLineF> lines;
12423 lines << QLineF(rect.topLeft(), rect.topRight()) << QLineF(rect.bottomLeft(), rect.bottomRight())
12424 << QLineF(rect.topLeft(), rect.bottomLeft()) << QLineF(rect.topRight(), rect.bottomRight());
12425 double minDistSqr = (std::numeric_limits<double>::max)();
12426 for (
int i=0; i<lines.size(); ++i)
12429 if (distSqr < minDistSqr)
12430 minDistSqr = distSqr;
12432 result = qSqrt(minDistSqr);
12437 if (rect.contains(pos))
12455 qDebug() << Q_FUNC_INFO <<
"called on item which shouldn't have any anchors (this method not reimplemented). anchorId" << anchorId;
12476 qDebug() << Q_FUNC_INFO <<
"anchor/position with name exists already:" << name;
12485 return newPosition;
12510 qDebug() << Q_FUNC_INFO <<
"anchor/position with name exists already:" << name;
12525 if (selectionStateChanged)
12526 *selectionStateChanged =
mSelected != selBefore;
12537 if (selectionStateChanged)
12538 *selectionStateChanged =
mSelected != selBefore;
12866 mBufferDevicePixelRatio(1.0),
12868 mAutoAddPlottableToLegend(true),
12872 mSelectionTolerance(8),
12873 mNoAntialiasingOnDrag(false),
12874 mBackgroundBrush(Qt::white, Qt::SolidPattern),
12875 mBackgroundScaled(true),
12876 mBackgroundScaledMode(Qt::KeepAspectRatioByExpanding),
12879 mMultiSelectModifier(Qt::ControlModifier),
12883 mMouseHasMoved(false),
12884 mMouseEventLayerable(0),
12885 mMouseSignalLayerable(0),
12886 mReplotting(false),
12887 mReplotQueued(false),
12888 mOpenGlMultisamples(16),
12889 mOpenGlAntialiasedElementsBackup(
QCP::
aeNone),
12890 mOpenGlCacheLabelsBackup(true)
12892 setAttribute(Qt::WA_NoMousePropagation);
12893 setAttribute(Qt::WA_OpaquePaintEvent);
12894 setFocusPolicy(Qt::ClickFocus);
12895 setMouseTracking(
true);
12896 QLocale currentLocale = locale();
12897 currentLocale.setNumberOptions(QLocale::OmitGroupSeparator);
12898 setLocale(currentLocale);
12899 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 12900 # ifdef QCP_DEVICEPIXELRATIO_FLOAT 12936 defaultAxisRect->
setLayer(QLatin1String(
"background"));
13331 #ifdef QCUSTOMPLOT_USE_OPENGL 13345 qDebug() << Q_FUNC_INFO <<
"Failed to enable OpenGL, continuing plotting without hardware acceleration.";
13362 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)";
13404 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 13410 qDebug() << Q_FUNC_INFO <<
"Device pixel ratios not supported for Qt versions before 5.4";
13511 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13544 qDebug() << Q_FUNC_INFO <<
"plottable not in list:" <<
reinterpret_cast<quintptr
>(
plottable);
13569 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13585 for (
int i=c-1; i >= 0; --i)
13609 QList<QCPAbstractPlottable*> result;
13613 result.append(plottable);
13637 if (onlySelectable && !plottable->
selectable())
13641 double currentDistance = plottable->
selectTest(pos,
false);
13642 if (currentDistance >= 0 && currentDistance < resultDistance)
13645 resultDistance = currentDistance;
13650 return resultPlottable;
13671 if (index >= 0 && index <
mGraphs.size())
13676 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13711 if (!keyAxis) keyAxis =
xAxis;
13712 if (!valueAxis) valueAxis =
yAxis;
13713 if (!keyAxis || !valueAxis)
13715 qDebug() << Q_FUNC_INFO <<
"can't use default QCustomPlot xAxis or yAxis, because at least one is invalid (has been deleted)";
13720 qDebug() << Q_FUNC_INFO <<
"passed keyAxis or valueAxis doesn't have this QCustomPlot as parent";
13725 newGraph->
setName(QLatin1String(
"Graph ")+QString::number(
mGraphs.size()));
13750 if (index >= 0 && index <
mGraphs.size())
13767 for (
int i=c-1; i >= 0; --i)
13792 QList<QCPGraph*> result;
13796 result.append(graph);
13811 if (index >= 0 && index <
mItems.size())
13813 return mItems.at(index);
13816 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13846 if (
mItems.contains(item))
13853 qDebug() << Q_FUNC_INFO <<
"item not in list:" <<
reinterpret_cast<quintptr
>(
item);
13864 if (index >= 0 && index <
mItems.size())
13868 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13883 for (
int i=c-1; i >= 0; --i)
13905 QList<QCPAbstractItem*> result;
13909 result.append(item);
13938 double currentDistance = item->
selectTest(pos,
false);
13939 if (currentDistance >= 0 && currentDistance < resultDistance)
13942 resultDistance = currentDistance;
13957 return mItems.contains(item);
13972 if (layer->
name() == name)
13986 if (index >= 0 && index <
mLayers.size())
13991 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
14021 qDebug() << Q_FUNC_INFO <<
"layer with name doesn't exist:" << name;
14036 if (!
mLayers.contains(layer))
14038 qDebug() << Q_FUNC_INFO <<
"layer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
layer);
14073 if (!
mLayers.contains(otherLayer))
14075 qDebug() << Q_FUNC_INFO <<
"otherLayer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(otherLayer);
14080 qDebug() << Q_FUNC_INFO <<
"A layer exists already with the name" << name;
14107 if (!
mLayers.contains(layer))
14109 qDebug() << Q_FUNC_INFO <<
"layer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
layer);
14114 qDebug() << Q_FUNC_INFO <<
"can't remove last layer";
14119 int removedIndex = layer->
index();
14120 bool isFirstLayer = removedIndex==0;
14122 QList<QCPLayerable*> children = layer->
children();
14125 for (
int i=children.size()-1; i>=0; --i)
14126 children.at(i)->moveToLayer(targetLayer,
true);
14129 for (
int i=0; i<children.size(); ++i)
14130 children.at(i)->moveToLayer(targetLayer,
false);
14156 if (!
mLayers.contains(layer))
14158 qDebug() << Q_FUNC_INFO <<
"layer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
layer);
14161 if (!
mLayers.contains(otherLayer))
14163 qDebug() << Q_FUNC_INFO <<
"otherLayer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(otherLayer);
14169 else if (layer->
index() < otherLayer->
index())
14217 const QList<QCPAxisRect*> rectList =
axisRects();
14218 if (index >= 0 && index < rectList.size())
14220 return rectList.at(index);
14223 qDebug() << Q_FUNC_INFO <<
"invalid axis rect index" << index;
14241 QList<QCPAxisRect*> result;
14242 QStack<QCPLayoutElement*> elementStack;
14246 while (!elementStack.isEmpty())
14252 elementStack.push(element);
14253 if (
QCPAxisRect *ar = qobject_cast<QCPAxisRect*>(element))
14274 bool searchSubElements =
true;
14275 while (searchSubElements && currentElement)
14277 searchSubElements =
false;
14282 currentElement = subElement;
14283 searchSubElements =
true;
14288 return currentElement;
14305 bool searchSubElements =
true;
14306 while (searchSubElements && currentElement)
14308 searchSubElements =
false;
14313 currentElement = subElement;
14314 searchSubElements =
true;
14315 if (
QCPAxisRect *ar = qobject_cast<QCPAxisRect*>(currentElement))
14333 QList<QCPAxis*> result, allAxes;
14335 allAxes << rect->
axes();
14337 foreach (
QCPAxis *axis, allAxes)
14340 result.append(axis);
14355 QList<QCPLegend*> result;
14357 QStack<QCPLayoutElement*> elementStack;
14361 while (!elementStack.isEmpty())
14367 elementStack.push(subElement);
14368 if (
QCPLegend *leg = qobject_cast<QCPLegend*>(subElement))
14371 result.append(leg);
14430 QTimer::singleShot(0,
this, SLOT(
replot()));
14468 QList<QCPAxis*> allAxes;
14470 allAxes << rect->
axes();
14472 foreach (
QCPAxis *axis, allAxes)
14473 axis->
rescale(onlyVisiblePlottables);
14515 bool success =
false;
14516 #ifdef QT_NO_PRINTER 14518 Q_UNUSED(exportPen)
14521 Q_UNUSED(pdfCreator)
14523 qDebug() << Q_FUNC_INFO <<
"Qt was built without printer support (QT_NO_PRINTER). PDF not created.";
14525 int newWidth, newHeight;
14526 if (width == 0 || height == 0)
14528 newWidth = this->width();
14529 newHeight = this->height();
14533 newHeight = height;
14536 QPrinter printer(QPrinter::ScreenResolution);
14537 printer.setOutputFileName(fileName);
14538 printer.setOutputFormat(QPrinter::PdfFormat);
14539 printer.setColorMode(QPrinter::Color);
14540 printer.printEngine()->setProperty(QPrintEngine::PPK_Creator, pdfCreator);
14541 printer.printEngine()->setProperty(QPrintEngine::PPK_DocumentName, pdfTitle);
14544 #if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) 14545 printer.setFullPage(
true);
14546 printer.setPaperSize(
viewport().size(), QPrinter::DevicePixel);
14548 QPageLayout pageLayout;
14549 pageLayout.setMode(QPageLayout::FullPageMode);
14550 pageLayout.setOrientation(QPageLayout::Portrait);
14551 pageLayout.setMargins(QMarginsF(0, 0, 0, 0));
14552 pageLayout.setPageSize(QPageSize(
viewport().size(), QPageSize::Point, QString(), QPageSize::ExactMatch));
14553 printer.setPageLayout(pageLayout);
14556 if (printpainter.
begin(&printer))
14567 draw(&printpainter);
14568 printpainter.end();
14572 #endif // QT_NO_PRINTER 14623 return saveRastered(fileName, width, height, scale,
"PNG", quality, resolution, resolutionUnit);
14670 return saveRastered(fileName, width, height, scale,
"JPG", quality, resolution, resolutionUnit);
14714 return saveRastered(fileName, width, height, scale,
"BMP", -1, resolution, resolutionUnit);
14749 if (painter.isActive())
14751 painter.setRenderHint(QPainter::HighQualityAntialiasing);
14755 for (
int bufferIndex = 0; bufferIndex <
mPaintBuffers.size(); ++bufferIndex)
14789 QList<QVariant> details;
14791 for (
int i=0; i<candidates.size(); ++i)
14794 candidates.at(i)->mouseDoubleClickEvent(event, details.at(i));
14795 if (event->isAccepted())
14804 if (!candidates.isEmpty())
14810 dataIndex = details.first().value<
QCPDataSelection>().dataRange().begin();
14812 }
else if (
QCPAxis *ax = qobject_cast<QCPAxis*>(candidates.first()))
14814 else if (
QCPAbstractItem *ai = qobject_cast<QCPAbstractItem*>(candidates.first()))
14816 else if (
QCPLegend *lg = qobject_cast<QCPLegend*>(candidates.first()))
14848 QList<QVariant> details;
14850 if (!candidates.isEmpty())
14856 for (
int i=0; i<candidates.size(); ++i)
14859 candidates.at(i)->mousePressEvent(event, details.at(i));
14860 if (event->isAccepted())
14921 if (event->button() == Qt::LeftButton)
14971 QList<QCPLayerable*> candidates =
layerableListAt(event->pos(),
false);
14972 for (
int i=0; i<candidates.size(); ++i)
14975 candidates.at(i)->wheelEvent(event);
14976 if (event->isAccepted())
15001 layer->
draw(painter);
15091 int bufferIndex = 0;
15095 for (
int layerIndex = 0; layerIndex <
mLayers.size(); ++layerIndex)
15139 #if defined(QCP_OPENGL_FBO) 15141 #elif defined(QCP_OPENGL_PBUFFER) 15144 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.";
15187 #ifdef QCP_OPENGL_FBO 15189 QSurfaceFormat proposedSurfaceFormat;
15191 #ifdef QCP_OPENGL_OFFSCREENSURFACE 15192 QOffscreenSurface *surface =
new QOffscreenSurface;
15194 QWindow *surface =
new QWindow;
15195 surface->setSurfaceType(QSurface::OpenGLSurface);
15197 surface->setFormat(proposedSurfaceFormat);
15199 mGlSurface = QSharedPointer<QSurface>(surface);
15200 mGlContext = QSharedPointer<QOpenGLContext>(
new QOpenGLContext);
15201 mGlContext->setFormat(mGlSurface->format());
15202 if (!mGlContext->create())
15204 qDebug() << Q_FUNC_INFO <<
"Failed to create OpenGL context";
15205 mGlContext.clear();
15206 mGlSurface.clear();
15209 if (!mGlContext->makeCurrent(mGlSurface.data()))
15211 qDebug() << Q_FUNC_INFO <<
"Failed to make opengl context current";
15212 mGlContext.clear();
15213 mGlSurface.clear();
15216 if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
15218 qDebug() << Q_FUNC_INFO <<
"OpenGL of this system doesn't support frame buffer objects";
15219 mGlContext.clear();
15220 mGlSurface.clear();
15223 mGlPaintDevice = QSharedPointer<QOpenGLPaintDevice>(
new QOpenGLPaintDevice);
15225 #elif defined(QCP_OPENGL_PBUFFER) 15226 return QGLFormat::hasOpenGL();
15245 #ifdef QCP_OPENGL_FBO 15246 mGlPaintDevice.clear();
15247 mGlContext.clear();
15248 mGlSurface.clear();
15278 if (this->legend == legend)
15301 bool selectionStateChanged =
false;
15305 QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> > potentialSelections;
15306 QRectF rectF(rect.normalized());
15314 QCPDataSelection dataSel = plottableInterface->selectTestRect(rectF,
true);
15316 potentialSelections.insertMulti(dataSel.
dataPointCount(), QPair<QCPAbstractPlottable*, QCPDataSelection>(
plottable, dataSel));
15323 if (!potentialSelections.isEmpty())
15325 QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> >::iterator it = potentialSelections.begin();
15326 while (it != potentialSelections.end()-1)
15327 it = potentialSelections.erase(it);
15340 if ((potentialSelections.isEmpty() || potentialSelections.constBegin()->first != layerable) &&
mInteractions.testFlag(layerable->
selectionCategory()))
15342 bool selChanged =
false;
15344 selectionStateChanged |= selChanged;
15351 QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> >::const_iterator it = potentialSelections.constEnd();
15352 while (it != potentialSelections.constBegin())
15355 if (
mInteractions.testFlag(it.value().first->selectionCategory()))
15357 bool selChanged =
false;
15358 it.value().first->selectEvent(event, additive, QVariant::fromValue(it.value().second), &selChanged);
15359 selectionStateChanged |= selChanged;
15365 if (selectionStateChanged)
15390 affectedAxes.removeAll(static_cast<QCPAxis*>(0));
15417 bool selectionStateChanged =
false;
15428 bool selChanged =
false;
15430 selectionStateChanged |= selChanged;
15438 bool selChanged =
false;
15439 clickedLayerable->
selectEvent(event, additive, details, &selChanged);
15440 selectionStateChanged |= selChanged;
15442 if (selectionStateChanged)
15464 qDebug() << Q_FUNC_INFO <<
"plottable already added to this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
plottable);
15469 qDebug() << Q_FUNC_INFO <<
"plottable not created with this QCustomPlot as parent:" <<
reinterpret_cast<quintptr
>(
plottable);
15477 if (!plottable->
layer())
15495 qDebug() << Q_FUNC_INFO <<
"passed graph is zero";
15500 qDebug() << Q_FUNC_INFO <<
"graph already registered with this QCustomPlot";
15520 if (
mItems.contains(item))
15522 qDebug() << Q_FUNC_INFO <<
"item already added to this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
item);
15527 qDebug() << Q_FUNC_INFO <<
"item not created with this QCustomPlot as parent:" <<
reinterpret_cast<quintptr
>(
item);
15532 if (!item->
layer())
15545 for (
int i=0; i<
mLayers.size(); ++i)
15566 QList<QVariant> details;
15567 QList<QCPLayerable*> candidates =
layerableListAt(pos, onlySelectable, selectionDetails ? &details : 0);
15568 if (selectionDetails && !details.isEmpty())
15569 *selectionDetails = details.first();
15570 if (!candidates.isEmpty())
15571 return candidates.first();
15596 QList<QCPLayerable*> result;
15597 for (
int layerIndex=
mLayers.size()-1; layerIndex>=0; --layerIndex)
15599 const QList<QCPLayerable*> layerables =
mLayers.at(layerIndex)->children();
15600 for (
int i=layerables.size()-1; i>=0; --i)
15602 if (!layerables.at(i)->realVisibility())
15605 double dist = layerables.at(i)->selectTest(pos, onlySelectable, selectionDetails ? &details : 0);
15608 result.append(layerables.at(i));
15609 if (selectionDetails)
15610 selectionDetails->append(details);
15637 QImage buffer =
toPixmap(width, height, scale).toImage();
15639 int dotsPerMeter = 0;
15640 switch (resolutionUnit)
15646 buffer.setDotsPerMeterX(dotsPerMeter);
15647 buffer.setDotsPerMeterY(dotsPerMeter);
15648 if (!buffer.isNull())
15649 return buffer.save(fileName, format, quality);
15665 int newWidth, newHeight;
15666 if (width == 0 || height == 0)
15668 newWidth = this->width();
15669 newHeight = this->height();
15673 newHeight = height;
15675 int scaledWidth = qRound(scale*newWidth);
15676 int scaledHeight = qRound(scale*newHeight);
15678 QPixmap result(scaledWidth, scaledHeight);
15681 painter.
begin(&result);
15682 if (painter.isActive())
15687 if (!qFuzzyCompare(scale, 1.0))
15691 painter.scale(scale, scale);
15700 qDebug() << Q_FUNC_INFO <<
"Couldn't activate painter on pixmap";
15721 int newWidth, newHeight;
15722 if (width == 0 || height == 0)
15724 newWidth = this->width();
15725 newHeight = this->height();
15729 newHeight = height;
15732 if (painter->isActive())
15742 qDebug() << Q_FUNC_INFO <<
"Passed painter is not active";
15792 mColorInterpolation(ciRGB),
15794 mColorBufferInvalidated(true)
15818 return ((other.
mLevelCount == this->mLevelCount) &&
15820 (other.
mPeriodic == this->mPeriodic) &&
15834 qDebug() << Q_FUNC_INFO <<
"n must be greater or equal 2 but was" << n;
15932 qDebug() << Q_FUNC_INFO <<
"null pointer given as data";
15937 qDebug() << Q_FUNC_INFO <<
"null pointer given as scanLine";
15948 for (
int i=0; i<n; ++i)
15950 int index = (int)((data[dataIndexFactor*i]-range.
lower)*posToIndexFactor) %
mLevelCount;
15957 for (
int i=0; i<n; ++i)
15959 int index = (data[dataIndexFactor*i]-range.
lower)*posToIndexFactor;
15971 for (
int i=0; i<n; ++i)
15980 for (
int i=0; i<n; ++i)
16006 qDebug() << Q_FUNC_INFO <<
"null pointer given as data";
16011 qDebug() << Q_FUNC_INFO <<
"null pointer given as alpha";
16016 qDebug() << Q_FUNC_INFO <<
"null pointer given as scanLine";
16027 for (
int i=0; i<n; ++i)
16029 int index = (int)((data[dataIndexFactor*i]-range.
lower)*posToIndexFactor) %
mLevelCount;
16032 if (alpha[dataIndexFactor*i] == 255)
16038 const float alphaF = alpha[dataIndexFactor*i]/255.0f;
16039 scanLine[i] = qRgba(qRed(rgb)*alphaF, qGreen(rgb)*alphaF, qBlue(rgb)*alphaF, qAlpha(rgb)*alphaF);
16044 for (
int i=0; i<n; ++i)
16046 int index = (data[dataIndexFactor*i]-range.
lower)*posToIndexFactor;
16051 if (alpha[dataIndexFactor*i] == 255)
16057 const float alphaF = alpha[dataIndexFactor*i]/255.0f;
16058 scanLine[i] = qRgba(qRed(rgb)*alphaF, qGreen(rgb)*alphaF, qBlue(rgb)*alphaF, qAlpha(rgb)*alphaF);
16066 for (
int i=0; i<n; ++i)
16071 if (alpha[dataIndexFactor*i] == 255)
16077 const float alphaF = alpha[dataIndexFactor*i]/255.0f;
16078 scanLine[i] = qRgba(qRed(rgb)*alphaF, qGreen(rgb)*alphaF, qBlue(rgb)*alphaF, qAlpha(rgb)*alphaF);
16083 for (
int i=0; i<n; ++i)
16090 if (alpha[dataIndexFactor*i] == 255)
16096 const float alphaF = alpha[dataIndexFactor*i]/255.0f;
16097 scanLine[i] = qRgba(qRed(rgb)*alphaF, qGreen(rgb)*alphaF, qBlue(rgb)*alphaF, qAlpha(rgb)*alphaF);
16273 for (QMap<double, QColor>::const_iterator it=
mColorStops.constBegin(); it!=
mColorStops.constEnd(); ++it)
16285 for (QMap<double, QColor>::const_iterator it=
mColorStops.constBegin(); it!=
mColorStops.constEnd(); ++it)
16287 if (it.value().alpha() < 255)
16304 double indexToPosFactor = 1.0/(double)(
mLevelCount-1);
16308 double position = i*indexToPosFactor;
16309 QMap<double, QColor>::const_iterator it =
mColorStops.lowerBound(position);
16314 const QColor col = (it-1).value();
16315 const float alphaPremultiplier = col.alpha()/255.0f;
16316 mColorBuffer[i] = qRgba(col.red()*alphaPremultiplier, col.green()*alphaPremultiplier, col.blue()*alphaPremultiplier, col.alpha());
16323 const QColor col = it.value();
16324 const float alphaPremultiplier = col.alpha()/255.0f;
16325 mColorBuffer[i] = qRgba(col.red()*alphaPremultiplier, col.green()*alphaPremultiplier, col.blue()*alphaPremultiplier, col.alpha());
16330 QMap<double, QColor>::const_iterator high = it;
16331 QMap<double, QColor>::const_iterator low = it-1;
16332 double t = (position-low.key())/(high.key()-low.key());
16339 const int alpha = (1-t)*low.value().alpha() + t*high.value().alpha();
16340 const float alphaPremultiplier = alpha/255.0f;
16341 mColorBuffer[i] = qRgba(((1-t)*low.value().red() + t*high.value().red())*alphaPremultiplier,
16342 ((1-t)*low.value().green() + t*high.value().green())*alphaPremultiplier,
16343 ((1-t)*low.value().blue() + t*high.value().blue())*alphaPremultiplier,
16347 mColorBuffer[i] = qRgb(((1-t)*low.value().red() + t*high.value().red()),
16348 ((1-t)*low.value().green() + t*high.value().green()),
16349 ((1-t)*low.value().blue() + t*high.value().blue()));
16355 QColor lowHsv = low.value().toHsv();
16356 QColor highHsv = high.value().toHsv();
16358 double hueDiff = highHsv.hueF()-lowHsv.hueF();
16360 hue = lowHsv.hueF() - t*(1.0-hueDiff);
16361 else if (hueDiff < -0.5)
16362 hue = lowHsv.hueF() + t*(1.0+hueDiff);
16364 hue = lowHsv.hueF() + t*hueDiff;
16365 if (hue < 0) hue += 1.0;
16366 else if (hue >= 1.0) hue -= 1.0;
16369 const QRgb rgb = QColor::fromHsvF(hue,
16370 (1-t)*lowHsv.saturationF() + t*highHsv.saturationF(),
16371 (1-t)*lowHsv.valueF() + t*highHsv.valueF()).rgb();
16372 const float alpha = (1-t)*lowHsv.alphaF() + t*highHsv.alphaF();
16373 mColorBuffer[i] = qRgba(qRed(rgb)*alpha, qGreen(rgb)*alpha, qBlue(rgb)*alpha, 255*alpha);
16378 (1-t)*lowHsv.saturationF() + t*highHsv.saturationF(),
16379 (1-t)*lowHsv.valueF() + t*highHsv.valueF()).rgb();
16388 const QRgb rgb =
mColorStops.constBegin().value().rgb();
16389 const float alpha =
mColorStops.constBegin().value().alphaF();
16390 mColorBuffer.fill(qRgba(qRed(rgb)*alpha, qGreen(rgb)*alpha, qBlue(rgb)*alpha, 255*alpha));
16427 mBracketPen(QPen(Qt::black)),
16428 mBracketBrush(Qt::NoBrush),
16430 mBracketHeight(50),
16431 mBracketStyle(bsSquareBracket),
16432 mTangentToData(false),
16559 qDebug() << Q_FUNC_INFO <<
"unknown/custom bracket style can't be handeld by default implementation:" <<
static_cast<int>(
mBracketStyle);
16583 int closeBracketDir = -openBracketDir;
16586 double openBracketAngle = 0;
16587 double closeBracketAngle = 0;
16591 closeBracketAngle =
getTangentAngle(interface1d, dataRange.
end()-1, closeBracketDir);
16594 QTransform oldTransform = painter->transform();
16597 painter->translate(openBracketPos);
16598 painter->rotate(openBracketAngle/M_PI*180.0);
16600 painter->setTransform(oldTransform);
16604 painter->translate(closeBracketPos);
16605 painter->rotate(closeBracketAngle/M_PI*180.0);
16607 painter->setTransform(oldTransform);
16627 if (!interface1d || dataIndex < 0 || dataIndex >= interface1d->
dataCount())
16629 direction = direction < 0 ? -1 : 1;
16637 qDebug() << averageCount;
16639 QVector<QPointF> points(averageCount);
16640 QPointF pointsAverage;
16641 int currentIndex = dataIndex;
16642 for (
int i=0; i<averageCount; ++i)
16645 pointsAverage += points[i];
16646 currentIndex += direction;
16648 pointsAverage /= (double)averageCount;
16652 double denomSum = 0;
16653 for (
int i=0; i<averageCount; ++i)
16655 const double dx = points.at(i).x()-pointsAverage.x();
16656 const double dy = points.at(i).y()-pointsAverage.y();
16660 if (!qFuzzyIsNull(denomSum) && !qFuzzyIsNull(numSum))
16662 return qAtan2(numSum, denomSum);
16676 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPointF(0, 0); }
16821 mBackgroundBrush(Qt::NoBrush),
16822 mBackgroundScaled(true),
16823 mBackgroundScaledMode(Qt::KeepAspectRatioByExpanding),
16825 mRangeDrag(Qt::Horizontal|Qt::Vertical),
16826 mRangeZoom(Qt::Horizontal|Qt::Vertical),
16827 mRangeZoomFactorHorz(0.85),
16828 mRangeZoomFactorVert(0.85),
16842 if (setupDefaultAxes)
16868 QList<QCPAxis*> axesList =
axes();
16869 for (
int i=0; i<axesList.size(); ++i)
16880 return mAxes.value(type).size();
16890 QList<QCPAxis*> ax(
mAxes.value(type));
16891 if (index >= 0 && index < ax.size())
16893 return ax.at(index);
16896 qDebug() << Q_FUNC_INFO <<
"Axis index out of bounds:" << index;
16911 QList<QCPAxis*> result;
16929 QList<QCPAxis*> result;
16930 QHashIterator<QCPAxis::AxisType, QList<QCPAxis*> > it(
mAxes);
16931 while (it.hasNext())
16934 result << it.value();
16964 newAxis =
new QCPAxis(
this, type);
16969 qDebug() << Q_FUNC_INFO <<
"passed axis has different axis type than specified in type parameter";
16974 qDebug() << Q_FUNC_INFO <<
"passed axis doesn't have this axis rect as parent axis rect";
16977 if (
axes().contains(newAxis))
16979 qDebug() << Q_FUNC_INFO <<
"passed axis is already owned by this axis rect";
16989 mAxes[type].append(newAxis);
17016 QList<QCPAxis*> result;
17038 QHashIterator<QCPAxis::AxisType, QList<QCPAxis*> > it(
mAxes);
17039 while (it.hasNext())
17042 if (it.value().contains(axis))
17044 if (it.value().first() == axis && it.value().size() > 1)
17045 it.value()[1]->setOffset(axis->
offset());
17046 mAxes[it.key()].removeOne(axis);
17047 if (qobject_cast<QCustomPlot*>(
parentPlot()))
17053 qDebug() << Q_FUNC_INFO <<
"Axis isn't in axis rect:" <<
reinterpret_cast<quintptr
>(
axis);
17084 qDebug() << Q_FUNC_INFO <<
"a passed axis was zero";
17089 pixelRange =
QCPRange(pixelRect.left(), pixelRect.right());
17091 pixelRange =
QCPRange(pixelRect.top(), pixelRect.bottom());
17117 QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2;
17151 xAxis2->
ticker()->setTickCount(xAxis->
ticker()->tickCount());
17152 xAxis2->
ticker()->setTickOrigin(xAxis->
ticker()->tickOrigin());
17160 yAxis2->
ticker()->setTickCount(yAxis->
ticker()->tickCount());
17161 yAxis2->
ticker()->setTickOrigin(yAxis->
ticker()->tickOrigin());
17165 connect(xAxis, SIGNAL(rangeChanged(
QCPRange)), xAxis2, SLOT(setRange(
QCPRange)));
17166 connect(yAxis, SIGNAL(rangeChanged(
QCPRange)), yAxis2, SLOT(setRange(
QCPRange)));
17181 QList<QCPAbstractPlottable*> result;
17201 QList<QCPGraph*> result;
17224 QList<QCPAbstractItem*> result;
17232 QList<QCPItemPosition*> positions =
mParentPlot->
mItems.at(itemId)->positions();
17233 for (
int posId=0; posId<positions.size(); ++posId)
17235 if (positions.at(posId)->axisRect() ==
this ||
17236 positions.at(posId)->keyAxis()->axisRect() ==
this ||
17237 positions.at(posId)->valueAxis()->axisRect() ==
this)
17265 QList<QCPAxis*> allAxes =
axes();
17266 for (
int i=0; i<allAxes.size(); ++i)
17267 allAxes.at(i)->setupTickVectors();
17285 QList<QCPLayoutElement*> result;
17290 result << mInsetLayout->
elements(recursive);
17394 if (orientation == Qt::Horizontal)
17408 if (orientation == Qt::Horizontal)
17421 QList<QCPAxis*> result;
17422 if (orientation == Qt::Horizontal)
17447 QList<QCPAxis*> result;
17448 if (orientation == Qt::Horizontal)
17529 QList<QCPAxis*> horz, vert;
17531 horz.append(horizontal);
17533 vert.append(vertical);
17548 QList<QCPAxis*> horz, vert;
17568 foreach (
QCPAxis *ax, horizontal)
17570 QPointer<QCPAxis> axPointer(ax);
17571 if (!axPointer.isNull())
17574 qDebug() << Q_FUNC_INFO <<
"invalid axis passed in horizontal list:" <<
reinterpret_cast<quintptr
>(ax);
17577 foreach (
QCPAxis *ax, vertical)
17579 QPointer<QCPAxis> axPointer(ax);
17580 if (!axPointer.isNull())
17583 qDebug() << Q_FUNC_INFO <<
"invalid axis passed in vertical list:" <<
reinterpret_cast<quintptr
>(ax);
17601 QList<QCPAxis*> horz, vert;
17603 horz.append(horizontal);
17605 vert.append(vertical);
17620 QList<QCPAxis*> horz, vert;
17640 foreach (
QCPAxis *ax, horizontal)
17642 QPointer<QCPAxis> axPointer(ax);
17643 if (!axPointer.isNull())
17646 qDebug() << Q_FUNC_INFO <<
"invalid axis passed in horizontal list:" <<
reinterpret_cast<quintptr
>(ax);
17649 foreach (
QCPAxis *ax, vertical)
17651 QPointer<QCPAxis> axPointer(ax);
17652 if (!axPointer.isNull())
17655 qDebug() << Q_FUNC_INFO <<
"invalid axis passed in vertical list:" <<
reinterpret_cast<quintptr
>(ax);
17739 const QList<QCPAxis*> axesList =
mAxes.value(type);
17740 if (axesList.isEmpty())
17743 bool isFirstVisible = !axesList.first()->visible();
17744 for (
int i=1; i<axesList.size(); ++i)
17746 int offset = axesList.at(i-1)->offset() + axesList.at(i-1)->calculateMargin();
17747 if (axesList.at(i)->visible())
17749 if (!isFirstVisible)
17750 offset += axesList.at(i)->tickLengthIn();
17751 isFirstVisible =
false;
17753 axesList.at(i)->setOffset(offset);
17761 qDebug() << Q_FUNC_INFO <<
"Called with side that isn't specified as auto margin";
17767 if (axesList.size() > 0)
17768 return axesList.last()->offset() + axesList.last()->calculateMargin();
17812 if (event->buttons() & Qt::LeftButton)
17935 double wheelSteps =
event->delta()/120.0;
18008 mParentLegend(parent),
18009 mFont(parent->font()),
18010 mTextColor(parent->textColor()),
18011 mSelectedFont(parent->selectedFont()),
18012 mSelectedTextColor(parent->selectedTextColor()),
18016 setLayer(QLatin1String(
"legend"));
18101 if (
mRect.contains(pos.toPoint()))
18128 if (selectionStateChanged)
18129 *selectionStateChanged =
mSelected != selBefore;
18140 if (selectionStateChanged)
18141 *selectionStateChanged =
mSelected != selBefore;
18182 mPlottable(plottable)
18229 QRectF textRect = painter->fontMetrics().boundingRect(0, 0, 0, iconSize.height(), Qt::TextDontClip,
mPlottable->
name());
18230 QRectF iconRect(
mRect.topLeft(), iconSize);
18231 int textHeight = qMax(textRect.height(), iconSize.height());
18235 painter->setClipRect(iconRect, Qt::IntersectClip);
18242 painter->setBrush(Qt::NoBrush);
18243 int halfPen = qCeil(painter->pen().widthF()*0.5)+1;
18244 painter->setClipRect(
mOuterRect.adjusted(-halfPen, -halfPen, halfPen, halfPen));
18245 painter->drawRect(iconRect);
18259 QSize result(0, 0);
18261 QFontMetrics fontMetrics(
getFont());
18263 textRect = fontMetrics.boundingRect(0, 0, 0, iconSize.height(), Qt::TextDontClip,
mPlottable->
name());
18265 result.setHeight(qMax(textRect.height(), iconSize.height()));
18333 setColumnSpacing(8);
18336 setIconSize(32, 18);
18338 setIconTextPadding(7);
18340 setSelectableParts(spLegendBox | spItems);
18341 setSelectedParts(spNone);
18343 setBorderPen(QPen(Qt::black, 0));
18344 setSelectedBorderPen(QPen(Qt::blue, 2));
18345 setIconBorderPen(Qt::NoPen);
18346 setSelectedIconBorderPen(QPen(Qt::blue, 2));
18347 setBrush(Qt::white);
18348 setSelectedBrush(Qt::white);
18364 bool hasSelectedItems =
false;
18365 for (
int i=0; i<itemCount(); ++i)
18367 if (item(i) && item(i)->selected())
18369 hasSelectedItems =
true;
18373 if (hasSelectedItems)
18374 return mSelectedParts | spItems;
18376 return mSelectedParts & ~spItems;
18407 for (
int i=0; i<itemCount(); ++i)
18410 item(i)->setFont(
mFont);
18426 for (
int i=0; i<itemCount(); ++i)
18429 item(i)->setTextColor(color);
18446 mIconSize.setWidth(width);
18447 mIconSize.setHeight(height);
18457 mIconTextPadding = padding;
18468 mIconBorderPen = pen;
18483 if (mSelectableParts != selectable)
18513 SelectableParts newSelected =
selected;
18514 mSelectedParts = this->selectedParts();
18516 if (mSelectedParts != newSelected)
18518 if (!mSelectedParts.testFlag(spItems) && newSelected.testFlag(spItems))
18520 qDebug() << Q_FUNC_INFO <<
"spItems flag can not be set, it can only be unset with this function";
18521 newSelected &= ~spItems;
18523 if (mSelectedParts.testFlag(spItems) && !newSelected.testFlag(spItems))
18525 for (
int i=0; i<itemCount(); ++i)
18528 item(i)->setSelected(
false);
18531 mSelectedParts = newSelected;
18544 mSelectedBorderPen = pen;
18554 mSelectedIconBorderPen = pen;
18565 mSelectedBrush = brush;
18578 for (
int i=0; i<itemCount(); ++i)
18581 item(i)->setSelectedFont(font);
18595 for (
int i=0; i<itemCount(); ++i)
18598 item(i)->setSelectedTextColor(color);
18622 for (
int i=0; i<itemCount(); ++i)
18643 return elementCount();
18653 for (
int i=0; i<itemCount(); ++i)
18655 if (item == this->item(i))
18669 return itemWithPlottable(plottable);
18684 return addElement(item);
18704 bool success =
remove(ali);
18706 setFillOrder(fillOrder(),
true);
18726 bool success =
remove(item);
18728 setFillOrder(fillOrder(),
true);
18737 for (
int i=itemCount()-1; i>=0; --i)
18749 QList<QCPAbstractLegendItem*> result;
18750 for (
int i=0; i<itemCount(); ++i)
18754 if (ali->selected())
18755 result.append(ali);
18788 return mSelectedParts.testFlag(spLegendBox) ? mSelectedBorderPen : mBorderPen;
18798 return mSelectedParts.testFlag(spLegendBox) ? mSelectedBrush : mBrush;
18809 painter->setBrush(getBrush());
18810 painter->
setPen(getBorderPen());
18818 if (onlySelectable && !mSelectableParts.testFlag(spLegendBox))
18823 if (details) details->setValue(spLegendBox);
18833 mSelectedParts = selectedParts();
18834 if (details.value<
SelectablePart>() == spLegendBox && mSelectableParts.testFlag(spLegendBox))
18836 SelectableParts selBefore = mSelectedParts;
18837 setSelectedParts(additive ? mSelectedParts^spLegendBox : mSelectedParts|spLegendBox);
18838 if (selectionStateChanged)
18839 *selectionStateChanged = mSelectedParts != selBefore;
18846 mSelectedParts = selectedParts();
18847 if (mSelectableParts.testFlag(spLegendBox))
18849 SelectableParts selBefore = mSelectedParts;
18850 setSelectedParts(selectedParts() & ~spLegendBox);
18851 if (selectionStateChanged)
18852 *selectionStateChanged = mSelectedParts != selBefore;
18871 if (parentPlot && !parentPlot->
legend)
18872 parentPlot->
legend =
this;
18928 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
18929 mFont(QFont(QLatin1String(
"sans serif"), 12)),
18938 mFont = parentPlot->font();
18953 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
18954 mFont(QFont(QLatin1String(
"sans serif"), 12)),
18963 mFont = parentPlot->font();
18978 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
18979 mFont(QFont(QLatin1String(
"sans serif"), pointSize)),
18981 mSelectedFont(QFont(QLatin1String(
"sans serif"), pointSize)),
18988 mFont = parentPlot->font();
18989 mFont.setPointSizeF(pointSize);
19005 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
19006 mFont(QFont(fontFamily, pointSize)),
19025 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
19159 QFontMetrics metrics(
mFont);
19160 QSize result(metrics.boundingRect(0, 0, 0, 0, Qt::AlignCenter,
mText).size());
19169 QFontMetrics metrics(
mFont);
19170 QSize result(metrics.boundingRect(0, 0, 0, 0, Qt::AlignCenter,
mText).size());
19171 result.setWidth(QWIDGETSIZE_MAX);
19185 if (selectionStateChanged)
19186 *selectionStateChanged =
mSelected != selBefore;
19197 if (selectionStateChanged)
19198 *selectionStateChanged =
mSelected != selBefore;
19244 if ((QPointF(event->pos())-startPos).manhattanLength() <= 3)
19374 mDataScaleType(
QCPAxis::stLinear),
19393 qDebug() << Q_FUNC_INFO <<
"internal color axis undefined";
19405 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19419 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19439 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19446 QString labelTransfer;
19447 QSharedPointer<QCPAxisTicker> tickerTransfer;
19454 tickerTransfer =
mColorAxis.data()->ticker();
19472 mColorAxis.data()->setTicker(tickerTransfer);
19545 mAxisRect.data()->mGradientImageInvalidated =
true;
19558 qDebug() << Q_FUNC_INFO <<
"internal color axis undefined";
19584 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19604 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19619 QList<QCPColorMap*> result;
19623 if (cm->colorScale() ==
this)
19637 QList<QCPColorMap*> maps =
colorMaps();
19639 bool haveRange =
false;
19643 for (
int i=0; i<maps.size(); ++i)
19645 if (!maps.at(i)->realVisibility() && onlyVisibleMaps)
19648 if (maps.at(i)->colorScale() ==
this)
19650 bool currentFoundRange =
true;
19651 mapRange = maps.at(i)->data()->dataBounds();
19654 if (mapRange.
lower <= 0 && mapRange.
upper > 0)
19656 else if (mapRange.
lower <= 0 && mapRange.
upper <= 0)
19657 currentFoundRange =
false;
19660 if (mapRange.
upper >= 0 && mapRange.
lower < 0)
19662 else if (mapRange.
upper >= 0 && mapRange.
lower >= 0)
19663 currentFoundRange =
false;
19665 if (currentFoundRange)
19668 newRange = mapRange;
19670 newRange.
expand(mapRange);
19679 double center = (newRange.
lower+newRange.
upper)*0.5;
19700 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19741 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19744 mAxisRect.data()->mousePressEvent(event, details);
19752 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19755 mAxisRect.data()->mouseMoveEvent(event, startPos);
19763 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19766 mAxisRect.data()->mouseReleaseEvent(event, startPos);
19774 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19800 mParentColorScale(parentColorScale),
19801 mGradientImageInvalidated(true)
19811 connect(
axis(type), SIGNAL(selectionChanged(QCPAxis::SelectableParts)),
this, SLOT(
axisSelectionChanged(QCPAxis::SelectableParts)));
19812 connect(
axis(type), SIGNAL(selectableChanged(QCPAxis::SelectableParts)),
this, SLOT(
axisSelectableChanged(QCPAxis::SelectableParts)));
19843 bool mirrorHorz =
false;
19844 bool mirrorVert =
false;
19851 painter->drawImage(
rect().adjusted(0, -1, 0, -1),
mGradientImage.mirrored(mirrorHorz, mirrorVert));
19862 if (
rect().isEmpty())
19865 const QImage::Format format = QImage::Format_ARGB32_Premultiplied;
19868 QVector<double> data(n);
19869 for (
int i=0; i<n; ++i)
19874 h =
rect().height();
19876 QVector<QRgb*> pixels;
19877 for (
int y=0; y<h; ++y)
19878 pixels.append(reinterpret_cast<QRgb*>(
mGradientImage.scanLine(y)));
19880 for (
int y=1; y<h; ++y)
19881 memcpy(pixels.at(y), pixels.first(), n*
sizeof(QRgb));
19884 w =
rect().width();
19887 for (
int y=0; y<h; ++y)
19889 QRgb *pixels =
reinterpret_cast<QRgb*
>(
mGradientImage.scanLine(y));
19891 for (
int x=0; x<w; ++x)
19892 pixels[x] = lineColor;
19909 if (
QCPAxis *senderAxis = qobject_cast<QCPAxis*>(sender()))
19910 if (senderAxis->axisType() == type)
19934 if (
QCPAxis *senderAxis = qobject_cast<QCPAxis*>(sender()))
19935 if (senderAxis->axisType() == type)
20114 setPen(QPen(Qt::blue, 0));
20161 addData(keys, values, alreadySorted);
20214 if (targetGraph ==
this)
20216 qDebug() << Q_FUNC_INFO <<
"targetGraph is this graph itself";
20223 qDebug() << Q_FUNC_INFO <<
"targetGraph not in same plot";
20281 if (keys.size() != values.size())
20282 qDebug() << Q_FUNC_INFO <<
"keys and values have different sizes:" << keys.size() << values.size();
20283 const int n = qMin(keys.size(), values.size());
20284 QVector<QCPGraphData> tempData(n);
20285 QVector<QCPGraphData>::iterator it = tempData.begin();
20286 const QVector<QCPGraphData>::iterator itEnd = tempData.end();
20288 while (it != itEnd)
20291 it->value = values[i];
20325 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
20348 return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange);
20354 if (!
mKeyAxis || !
mValueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
20358 QVector<QPointF> lines, scatters;
20361 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
20363 allSegments << unselectedSegments << selectedSegments;
20364 for (
int i=0; i<allSegments.size(); ++i)
20366 bool isSelectedSegment = i >= unselectedSegments.size();
20368 QCPDataRange lineDataRange = isSelectedSegment ? allSegments.at(i) : allSegments.at(i).
adjusted(-1, 1);
20372 #ifdef QCUSTOMPLOT_CHECK_DATA 20377 qDebug() << Q_FUNC_INFO <<
"Data point at" << it->key <<
"invalid." <<
"Plottable name:" <<
name();
20385 painter->setBrush(
mBrush);
20386 painter->
setPen(Qt::NoPen);
20396 painter->setBrush(Qt::NoBrush);
20407 if (!finalScatterStyle.
isNone())
20423 if (
mBrush.style() != Qt::NoBrush)
20426 painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0),
mBrush);
20433 painter->
drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0));
20443 scaledStyle.
setPixmap(scaledStyle.
pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
20445 scaledStyle.
drawShape(painter, QRectF(rect).center());
20476 if (!lines)
return;
20485 QVector<QCPGraphData> lineData;
20489 if (
mKeyAxis->rangeReversed() != (
mKeyAxis->orientation() == Qt::Vertical))
20490 std::reverse(lineData.begin(), lineData.end());
20494 case lsNone: lines->clear();
break;
20517 if (!scatters)
return;
20520 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis"; scatters->clear();
return; }
20530 QVector<QCPGraphData>
data;
20533 if (
mKeyAxis->rangeReversed() != (
mKeyAxis->orientation() == Qt::Vertical))
20534 std::reverse(data.begin(), data.end());
20536 scatters->resize(data.size());
20539 for (
int i=0; i<data.size(); ++i)
20541 if (!qIsNaN(data.at(i).value))
20543 (*scatters)[i].setX(valueAxis->
coordToPixel(data.at(i).value));
20544 (*scatters)[i].setY(keyAxis->
coordToPixel(data.at(i).key));
20549 for (
int i=0; i<data.size(); ++i)
20551 if (!qIsNaN(data.at(i).value))
20553 (*scatters)[i].setX(keyAxis->
coordToPixel(data.at(i).key));
20554 (*scatters)[i].setY(valueAxis->
coordToPixel(data.at(i).value));
20572 QVector<QPointF> result;
20575 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20577 result.resize(data.size());
20582 for (
int i=0; i<data.size(); ++i)
20584 result[i].setX(valueAxis->
coordToPixel(data.at(i).value));
20585 result[i].setY(keyAxis->
coordToPixel(data.at(i).key));
20589 for (
int i=0; i<data.size(); ++i)
20591 result[i].setX(keyAxis->
coordToPixel(data.at(i).key));
20592 result[i].setY(valueAxis->
coordToPixel(data.at(i).value));
20610 QVector<QPointF> result;
20613 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20615 result.resize(data.size()*2);
20620 double lastValue = valueAxis->
coordToPixel(data.first().value);
20621 for (
int i=0; i<data.size(); ++i)
20623 const double key = keyAxis->
coordToPixel(data.at(i).key);
20624 result[i*2+0].setX(lastValue);
20625 result[i*2+0].setY(key);
20626 lastValue = valueAxis->
coordToPixel(data.at(i).value);
20627 result[i*2+1].setX(lastValue);
20628 result[i*2+1].setY(key);
20632 double lastValue = valueAxis->
coordToPixel(data.first().value);
20633 for (
int i=0; i<data.size(); ++i)
20635 const double key = keyAxis->
coordToPixel(data.at(i).key);
20636 result[i*2+0].setX(key);
20637 result[i*2+0].setY(lastValue);
20638 lastValue = valueAxis->
coordToPixel(data.at(i).value);
20639 result[i*2+1].setX(key);
20640 result[i*2+1].setY(lastValue);
20658 QVector<QPointF> result;
20661 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20663 result.resize(data.size()*2);
20668 double lastKey = keyAxis->
coordToPixel(data.first().key);
20669 for (
int i=0; i<data.size(); ++i)
20671 const double value = valueAxis->
coordToPixel(data.at(i).value);
20672 result[i*2+0].setX(value);
20673 result[i*2+0].setY(lastKey);
20675 result[i*2+1].setX(value);
20676 result[i*2+1].setY(lastKey);
20680 double lastKey = keyAxis->
coordToPixel(data.first().key);
20681 for (
int i=0; i<data.size(); ++i)
20683 const double value = valueAxis->
coordToPixel(data.at(i).value);
20684 result[i*2+0].setX(lastKey);
20685 result[i*2+0].setY(value);
20687 result[i*2+1].setX(lastKey);
20688 result[i*2+1].setY(value);
20706 QVector<QPointF> result;
20709 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20711 result.resize(data.size()*2);
20716 double lastKey = keyAxis->
coordToPixel(data.first().key);
20717 double lastValue = valueAxis->
coordToPixel(data.first().value);
20718 result[0].setX(lastValue);
20719 result[0].setY(lastKey);
20720 for (
int i=1; i<data.size(); ++i)
20722 const double key = (keyAxis->
coordToPixel(data.at(i).key)+lastKey)*0.5;
20723 result[i*2-1].setX(lastValue);
20724 result[i*2-1].setY(key);
20725 lastValue = valueAxis->
coordToPixel(data.at(i).value);
20727 result[i*2+0].setX(lastValue);
20728 result[i*2+0].setY(key);
20730 result[data.size()*2-1].setX(lastValue);
20731 result[data.size()*2-1].setY(lastKey);
20734 double lastKey = keyAxis->
coordToPixel(data.first().key);
20735 double lastValue = valueAxis->
coordToPixel(data.first().value);
20736 result[0].setX(lastKey);
20737 result[0].setY(lastValue);
20738 for (
int i=1; i<data.size(); ++i)
20740 const double key = (keyAxis->
coordToPixel(data.at(i).key)+lastKey)*0.5;
20741 result[i*2-1].setX(key);
20742 result[i*2-1].setY(lastValue);
20743 lastValue = valueAxis->
coordToPixel(data.at(i).value);
20745 result[i*2+0].setX(key);
20746 result[i*2+0].setY(lastValue);
20748 result[data.size()*2-1].setX(lastKey);
20749 result[data.size()*2-1].setY(lastValue);
20766 QVector<QPointF> result;
20769 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20771 result.resize(data.size()*2);
20776 for (
int i=0; i<data.size(); ++i)
20778 const double key = keyAxis->
coordToPixel(data.at(i).key);
20780 result[i*2+0].setY(key);
20781 result[i*2+1].setX(valueAxis->
coordToPixel(data.at(i).value));
20782 result[i*2+1].setY(key);
20786 for (
int i=0; i<data.size(); ++i)
20788 const double key = keyAxis->
coordToPixel(data.at(i).key);
20789 result[i*2+0].setX(key);
20791 result[i*2+1].setX(key);
20792 result[i*2+1].setY(valueAxis->
coordToPixel(data.at(i).value));
20818 if (painter->brush().style() == Qt::NoBrush || painter->brush().color().alpha() == 0)
return;
20825 for (
int i=0; i<segments.size(); ++i)
20830 QVector<QPointF> otherLines;
20832 if (!otherLines.isEmpty())
20835 QVector<QPair<QCPDataRange, QCPDataRange> > segmentPairs =
getOverlappingSegments(segments, lines, otherSegments, &otherLines);
20836 for (
int i=0; i<segmentPairs.size(); ++i)
20837 painter->drawPolygon(
getChannelFillPolygon(lines, segmentPairs.at(i).first, &otherLines, segmentPairs.at(i).second));
20853 for (
int i=0; i<scatters.size(); ++i)
20854 style.
drawShape(painter, scatters.at(i).x(), scatters.at(i).y());
20865 if (painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0)
20882 if (painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0)
20885 QPen oldPen = painter->pen();
20886 QPen newPen = painter->pen();
20887 newPen.setCapStyle(Qt::FlatCap);
20888 painter->
setPen(newPen);
20889 painter->drawLines(lines);
20890 painter->
setPen(oldPen);
20908 if (!lineData)
return;
20911 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
20912 if (begin == end)
return;
20915 int maxCount = (std::numeric_limits<int>::max)();
20919 if (2*keyPixelSpan+2 < static_cast<double>((std::numeric_limits<int>::max)()))
20920 maxCount = 2*keyPixelSpan+2;
20926 double minValue = it->value;
20927 double maxValue = it->value;
20930 int reversedRound = reversedFactor==-1 ? 1 : 0;
20932 double lastIntervalEndKey = currentIntervalStartKey;
20933 double keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->
pixelToCoord(keyAxis->
coordToPixel(currentIntervalStartKey)+1.0*reversedFactor));
20935 int intervalDataCount = 1;
20939 if (it->key < currentIntervalStartKey+keyEpsilon)
20941 if (it->value < minValue)
20942 minValue = it->value;
20943 else if (it->value > maxValue)
20944 maxValue = it->value;
20945 ++intervalDataCount;
20948 if (intervalDataCount >= 2)
20950 if (lastIntervalEndKey < currentIntervalStartKey-keyEpsilon)
20951 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.2, currentIntervalFirstPoint->value));
20952 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.25, minValue));
20953 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.75, maxValue));
20954 if (it->key > currentIntervalStartKey+keyEpsilon*2)
20955 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.8, (it-1)->value));
20957 lineData->append(
QCPGraphData(currentIntervalFirstPoint->key, currentIntervalFirstPoint->value));
20958 lastIntervalEndKey = (it-1)->key;
20959 minValue = it->value;
20960 maxValue = it->value;
20961 currentIntervalFirstPoint = it;
20963 if (keyEpsilonVariable)
20964 keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->
pixelToCoord(keyAxis->
coordToPixel(currentIntervalStartKey)+1.0*reversedFactor));
20965 intervalDataCount = 1;
20970 if (intervalDataCount >= 2)
20972 if (lastIntervalEndKey < currentIntervalStartKey-keyEpsilon)
20973 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.2, currentIntervalFirstPoint->value));
20974 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.25, minValue));
20975 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.75, maxValue));
20977 lineData->append(
QCPGraphData(currentIntervalFirstPoint->key, currentIntervalFirstPoint->value));
20981 lineData->resize(dataCount);
20982 std::copy(begin, end, lineData->begin());
21000 if (!scatterData)
return;
21003 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
21009 while (doScatterSkip && begin != end && beginIndex % scatterModulo != 0)
21014 if (begin == end)
return;
21016 int maxCount = (std::numeric_limits<int>::max)();
21020 maxCount = 2*keyPixelSpan+2;
21025 double valueMaxRange = valueAxis->
range().
upper;
21026 double valueMinRange = valueAxis->
range().
lower;
21028 int itIndex = beginIndex;
21029 double minValue = it->value;
21030 double maxValue = it->value;
21035 int reversedRound = reversedFactor==-1 ? 1 : 0;
21037 double keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->
pixelToCoord(keyAxis->
coordToPixel(currentIntervalStartKey)+1.0*reversedFactor));
21039 int intervalDataCount = 1;
21041 if (!doScatterSkip)
21045 itIndex += scatterModulo;
21046 if (itIndex < endIndex)
21047 it += scatterModulo;
21051 itIndex = endIndex;
21057 if (it->key < currentIntervalStartKey+keyEpsilon)
21059 if (it->value < minValue && it->value > valueMinRange && it->value < valueMaxRange)
21061 minValue = it->value;
21063 }
else if (it->value > maxValue && it->value > valueMinRange && it->value < valueMaxRange)
21065 maxValue = it->value;
21068 ++intervalDataCount;
21071 if (intervalDataCount >= 2)
21075 int dataModulo = qMax(1, qRound(intervalDataCount/(valuePixelSpan/4.0)));
21078 while (intervalIt != it)
21080 if ((c % dataModulo == 0 || intervalIt == minValueIt || intervalIt == maxValueIt) && intervalIt->value > valueMinRange && intervalIt->value < valueMaxRange)
21081 scatterData->append(*intervalIt);
21083 if (!doScatterSkip)
21086 intervalIt += scatterModulo;
21088 }
else if (currentIntervalStart->value > valueMinRange && currentIntervalStart->value < valueMaxRange)
21089 scatterData->append(*currentIntervalStart);
21090 minValue = it->value;
21091 maxValue = it->value;
21092 currentIntervalStart = it;
21094 if (keyEpsilonVariable)
21095 keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->
pixelToCoord(keyAxis->
coordToPixel(currentIntervalStartKey)+1.0*reversedFactor));
21096 intervalDataCount = 1;
21099 if (!doScatterSkip)
21103 itIndex += scatterModulo;
21104 if (itIndex < endIndex)
21105 it += scatterModulo;
21109 itIndex = endIndex;
21114 if (intervalDataCount >= 2)
21118 int dataModulo = qMax(1, qRound(intervalDataCount/(valuePixelSpan/4.0)));
21122 while (intervalIt != it)
21124 if ((c % dataModulo == 0 || intervalIt == minValueIt || intervalIt == maxValueIt) && intervalIt->value > valueMinRange && intervalIt->value < valueMaxRange)
21125 scatterData->append(*intervalIt);
21127 if (!doScatterSkip)
21131 intervalItIndex += scatterModulo;
21132 if (intervalItIndex < itIndex)
21133 intervalIt += scatterModulo;
21137 intervalItIndex = itIndex;
21141 }
else if (currentIntervalStart->value > valueMinRange && currentIntervalStart->value < valueMaxRange)
21142 scatterData->append(*currentIntervalStart);
21147 int itIndex = beginIndex;
21148 scatterData->reserve(dataCount);
21151 scatterData->append(*it);
21153 if (!doScatterSkip)
21157 itIndex += scatterModulo;
21158 if (itIndex < endIndex)
21159 it += scatterModulo;
21163 itIndex = endIndex;
21181 if (rangeRestriction.
isEmpty())
21189 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
21194 mDataContainer->limitIteratorsToDataRange(begin, end, rangeRestriction);
21211 QVector<QCPDataRange> result;
21212 const int n = lineData->size();
21217 if (keyOrientation == Qt::Horizontal)
21221 while (i < n && qIsNaN(lineData->at(i).y()))
21226 while (i < n && !qIsNaN(lineData->at(i).y()))
21228 currentSegment.
setEnd(i++);
21229 result.append(currentSegment);
21235 while (i < n && qIsNaN(lineData->at(i).x()))
21240 while (i < n && !qIsNaN(lineData->at(i).x()))
21242 currentSegment.
setEnd(i++);
21243 result.append(currentSegment);
21267 QVector<QPair<QCPDataRange, QCPDataRange> >
QCPGraph::getOverlappingSegments(QVector<QCPDataRange> thisSegments,
const QVector<QPointF> *thisData, QVector<QCPDataRange> otherSegments,
const QVector<QPointF> *otherData)
const 21269 QVector<QPair<QCPDataRange, QCPDataRange> > result;
21270 if (thisData->isEmpty() || otherData->isEmpty() || thisSegments.isEmpty() || otherSegments.isEmpty())
21274 int otherIndex = 0;
21275 const bool verticalKey =
mKeyAxis->orientation() == Qt::Vertical;
21276 while (thisIndex < thisSegments.size() && otherIndex < otherSegments.size())
21278 if (thisSegments.at(thisIndex).size() < 2)
21283 if (otherSegments.at(otherIndex).size() < 2)
21288 double thisLower, thisUpper, otherLower, otherUpper;
21291 thisLower = thisData->at(thisSegments.at(thisIndex).begin()).x();
21292 thisUpper = thisData->at(thisSegments.at(thisIndex).end()-1).x();
21293 otherLower = otherData->at(otherSegments.at(otherIndex).begin()).x();
21294 otherUpper = otherData->at(otherSegments.at(otherIndex).end()-1).x();
21297 thisLower = thisData->at(thisSegments.at(thisIndex).begin()).y();
21298 thisUpper = thisData->at(thisSegments.at(thisIndex).end()-1).y();
21299 otherLower = otherData->at(otherSegments.at(otherIndex).begin()).y();
21300 otherUpper = otherData->at(otherSegments.at(otherIndex).end()-1).y();
21304 if (
segmentsIntersect(thisLower, thisUpper, otherLower, otherUpper, bPrecedence))
21305 result.append(QPair<QCPDataRange, QCPDataRange>(thisSegments.at(thisIndex), otherSegments.at(otherIndex)));
21307 if (bPrecedence <= 0)
21333 if (aLower > bUpper)
21337 }
else if (bLower > aUpper)
21343 if (aUpper > bUpper)
21345 else if (aUpper < bUpper)
21367 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPointF(); }
21374 result.setX(matchingDataPoint.x());
21379 result.setY(matchingDataPoint.y());
21392 result.setY(matchingDataPoint.y());
21395 result.setX(matchingDataPoint.x());
21424 if (segment.
size() < 2)
21425 return QPolygonF();
21426 QPolygonF result(segment.
size()+2);
21429 std::copy(lineData->constBegin()+segment.
begin(), lineData->constBegin()+segment.
end(), result.begin()+1);
21456 return QPolygonF();
21460 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPolygonF(); }
21461 if (!
mChannelFillGraph.data()->mKeyAxis) { qDebug() << Q_FUNC_INFO <<
"channel fill target key axis invalid";
return QPolygonF(); }
21464 return QPolygonF();
21466 if (thisData->isEmpty())
return QPolygonF();
21467 QVector<QPointF> thisSegmentData(thisSegment.
size());
21468 QVector<QPointF> otherSegmentData(otherSegment.
size());
21469 std::copy(thisData->constBegin()+thisSegment.
begin(), thisData->constBegin()+thisSegment.
end(), thisSegmentData.begin());
21470 std::copy(otherData->constBegin()+otherSegment.
begin(), otherData->constBegin()+otherSegment.
end(), otherSegmentData.begin());
21472 QVector<QPointF> *staticData = &thisSegmentData;
21473 QVector<QPointF> *croppedData = &otherSegmentData;
21480 if (staticData->first().x() < croppedData->first().x())
21481 qSwap(staticData, croppedData);
21482 const int lowBound =
findIndexBelowX(croppedData, staticData->first().x());
21483 if (lowBound == -1)
return QPolygonF();
21484 croppedData->remove(0, lowBound);
21486 if (croppedData->size() < 2)
return QPolygonF();
21488 if (!qFuzzyCompare(croppedData->at(1).x(), croppedData->at(0).x()))
21489 slope = (croppedData->at(1).y()-croppedData->at(0).y())/(croppedData->at(1).x()-croppedData->at(0).x());
21492 (*croppedData)[0].setY(croppedData->at(0).y()+slope*(staticData->first().x()-croppedData->at(0).x()));
21493 (*croppedData)[0].setX(staticData->first().x());
21496 if (staticData->last().x() > croppedData->last().x())
21497 qSwap(staticData, croppedData);
21498 int highBound =
findIndexAboveX(croppedData, staticData->last().x());
21499 if (highBound == -1)
return QPolygonF();
21500 croppedData->remove(highBound+1, croppedData->size()-(highBound+1));
21502 if (croppedData->size() < 2)
return QPolygonF();
21503 const int li = croppedData->size()-1;
21504 if (!qFuzzyCompare(croppedData->at(li).x(), croppedData->at(li-1).x()))
21505 slope = (croppedData->at(li).y()-croppedData->at(li-1).y())/(croppedData->at(li).x()-croppedData->at(li-1).x());
21508 (*croppedData)[li].setY(croppedData->at(li-1).y()+slope*(staticData->last().x()-croppedData->at(li-1).x()));
21509 (*croppedData)[li].setX(staticData->last().x());
21514 if (staticData->first().y() < croppedData->first().y())
21515 qSwap(staticData, croppedData);
21516 int lowBound =
findIndexBelowY(croppedData, staticData->first().y());
21517 if (lowBound == -1)
return QPolygonF();
21518 croppedData->remove(0, lowBound);
21520 if (croppedData->size() < 2)
return QPolygonF();
21522 if (!qFuzzyCompare(croppedData->at(1).y(), croppedData->at(0).y()))
21523 slope = (croppedData->at(1).x()-croppedData->at(0).x())/(croppedData->at(1).y()-croppedData->at(0).y());
21526 (*croppedData)[0].setX(croppedData->at(0).x()+slope*(staticData->first().y()-croppedData->at(0).y()));
21527 (*croppedData)[0].setY(staticData->first().y());
21530 if (staticData->last().y() > croppedData->last().y())
21531 qSwap(staticData, croppedData);
21532 int highBound =
findIndexAboveY(croppedData, staticData->last().y());
21533 if (highBound == -1)
return QPolygonF();
21534 croppedData->remove(highBound+1, croppedData->size()-(highBound+1));
21536 if (croppedData->size() < 2)
return QPolygonF();
21537 int li = croppedData->size()-1;
21538 if (!qFuzzyCompare(croppedData->at(li).y(), croppedData->at(li-1).y()))
21539 slope = (croppedData->at(li).x()-croppedData->at(li-1).x())/(croppedData->at(li).y()-croppedData->at(li-1).y());
21542 (*croppedData)[li].setX(croppedData->at(li-1).x()+slope*(staticData->last().y()-croppedData->at(li-1).y()));
21543 (*croppedData)[li].setY(staticData->last().y());
21547 for (
int i=otherSegmentData.size()-1; i>=0; --i)
21548 thisSegmentData << otherSegmentData.at(i);
21549 return QPolygonF(thisSegmentData);
21562 for (
int i=data->size()-1; i>=0; --i)
21564 if (data->at(i).x() < x)
21566 if (i<data->size()-1)
21569 return data->size()-1;
21585 for (
int i=0; i<data->size(); ++i)
21587 if (data->at(i).x() > x)
21608 for (
int i=data->size()-1; i>=0; --i)
21610 if (data->at(i).y() < y)
21612 if (i<data->size()-1)
21615 return data->size()-1;
21641 double minDistSqr = (std::numeric_limits<double>::max)();
21643 double posKeyMin, posKeyMax, dummy;
21646 if (posKeyMin > posKeyMax)
21647 qSwap(posKeyMin, posKeyMax);
21654 if (currentDistSqr < minDistSqr)
21656 minDistSqr = currentDistSqr;
21665 QVector<QPointF> lineData;
21669 for (
int i=0; i<lineData.size()-1; i+=step)
21672 if (currentDistSqr < minDistSqr)
21673 minDistSqr = currentDistSqr;
21677 return qSqrt(minDistSqr);
21690 for (
int i=0; i<data->size(); ++i)
21692 if (data->at(i).y() > y)
21867 setPen(QPen(Qt::blue, 0));
21910 void QCPCurve::setData(
const QVector<double> &t,
const QVector<double> &keys,
const QVector<double> &values,
bool alreadySorted)
21913 addData(t, keys, values, alreadySorted);
21986 void QCPCurve::addData(
const QVector<double> &t,
const QVector<double> &keys,
const QVector<double> &values,
bool alreadySorted)
21988 if (t.size() != keys.size() || t.size() != values.size())
21989 qDebug() << Q_FUNC_INFO <<
"ts, keys and values have different sizes:" << t.size() << keys.size() << values.size();
21990 const int n = qMin(qMin(t.size(), keys.size()), values.size());
21991 QVector<QCPCurveData> tempData(n);
21992 QVector<QCPCurveData>::iterator it = tempData.begin();
21993 const QVector<QCPCurveData>::iterator itEnd = tempData.end();
21995 while (it != itEnd)
21999 it->value = values[i];
22020 if (keys.size() != values.size())
22021 qDebug() << Q_FUNC_INFO <<
"keys and values have different sizes:" << keys.size() << values.size();
22022 const int n = qMin(keys.size(), values.size());
22028 QVector<QCPCurveData> tempData(n);
22029 QVector<QCPCurveData>::iterator it = tempData.begin();
22030 const QVector<QCPCurveData>::iterator itEnd = tempData.end();
22032 while (it != itEnd)
22034 it->t = tStart + i;
22036 it->value = values[i];
22087 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
22110 return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange);
22119 QVector<QPointF> lines, scatters;
22122 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
22124 allSegments << unselectedSegments << selectedSegments;
22125 for (
int i=0; i<allSegments.size(); ++i)
22127 bool isSelectedSegment = i >= unselectedSegments.size();
22130 QPen finalCurvePen =
mPen;
22134 QCPDataRange lineDataRange = isSelectedSegment ? allSegments.at(i) : allSegments.at(i).
adjusted(-1, 1);
22135 getCurveLines(&lines, lineDataRange, finalCurvePen.widthF());
22138 #ifdef QCUSTOMPLOT_CHECK_DATA 22143 qDebug() << Q_FUNC_INFO <<
"Data point at" << it->key <<
"invalid." <<
"Plottable name:" <<
name();
22152 painter->setBrush(
mBrush);
22153 painter->
setPen(Qt::NoPen);
22154 if (painter->brush().style() != Qt::NoBrush && painter->brush().color().alpha() != 0)
22155 painter->drawPolygon(QPolygonF(lines));
22160 painter->
setPen(finalCurvePen);
22161 painter->setBrush(Qt::NoBrush);
22169 if (!finalScatterStyle.
isNone())
22185 if (
mBrush.style() != Qt::NoBrush)
22188 painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0),
mBrush);
22195 painter->
drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0));
22205 scaledStyle.
setPixmap(scaledStyle.
pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
22207 scaledStyle.
drawShape(painter, QRectF(rect).center());
22224 if (painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0)
22243 for (
int i=0; i<points.size(); ++i)
22244 if (!qIsNaN(points.at(i).x()) && !qIsNaN(points.at(i).y()))
22245 style.
drawShape(painter, points.at(i));
22278 if (!lines)
return;
22282 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
22285 const double strokeMargin = qMax(qreal(1.0), qreal(penWidth*0.75));
22292 mDataContainer->limitIteratorsToDataRange(itBegin, itEnd, dataRange);
22293 if (itBegin == itEnd)
22297 int prevRegion =
getRegion(prevIt->key, prevIt->value, keyMin, valueMax, keyMax, valueMin);
22298 QVector<QPointF> trailingPoints;
22299 while (it != itEnd)
22301 const int currentRegion =
getRegion(it->key, it->value, keyMin, valueMax, keyMax, valueMin);
22302 if (currentRegion != prevRegion)
22304 if (currentRegion != 5)
22306 QPointF crossA, crossB;
22307 if (prevRegion == 5)
22309 lines->append(
getOptimizedPoint(currentRegion, it->key, it->value, prevIt->key, prevIt->value, keyMin, valueMax, keyMax, valueMin));
22311 *lines <<
getOptimizedCornerPoints(prevRegion, currentRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin);
22312 }
else if (
mayTraverse(prevRegion, currentRegion) &&
22313 getTraverse(prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin, crossA, crossB))
22316 QVector<QPointF> beforeTraverseCornerPoints, afterTraverseCornerPoints;
22317 getTraverseCornerPoints(prevRegion, currentRegion, keyMin, valueMax, keyMax, valueMin, beforeTraverseCornerPoints, afterTraverseCornerPoints);
22320 *lines << beforeTraverseCornerPoints;
22321 lines->append(crossA);
22322 lines->append(crossB);
22323 *lines << afterTraverseCornerPoints;
22326 lines->append(crossB);
22327 *lines << afterTraverseCornerPoints;
22328 trailingPoints << beforeTraverseCornerPoints << crossA ;
22332 *lines <<
getOptimizedCornerPoints(prevRegion, currentRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin);
22337 trailingPoints <<
getOptimizedPoint(prevRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin);
22339 lines->append(
getOptimizedPoint(prevRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin));
22344 if (currentRegion == 5)
22353 prevRegion = currentRegion;
22356 *lines << trailingPoints;
22381 if (!scatters)
return;
22385 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
22389 mDataContainer->limitIteratorsToDataRange(begin, end, dataRange);
22406 while (doScatterSkip && it != end && itIndex % scatterModulo != 0)
22415 if (!qIsNaN(it->value) && keyRange.
contains(it->key) && valueRange.
contains(it->value))
22419 if (!doScatterSkip)
22423 itIndex += scatterModulo;
22424 if (itIndex < endIndex)
22425 it += scatterModulo;
22429 itIndex = endIndex;
22437 if (!qIsNaN(it->value) && keyRange.
contains(it->key) && valueRange.
contains(it->value))
22441 if (!doScatterSkip)
22445 itIndex += scatterModulo;
22446 if (itIndex < endIndex)
22447 it += scatterModulo;
22451 itIndex = endIndex;
22477 int QCPCurve::getRegion(
double key,
double value,
double keyMin,
double valueMax,
double keyMax,
double valueMin)
const 22481 if (value > valueMax)
22483 else if (value < valueMin)
22487 }
else if (key > keyMax)
22489 if (value > valueMax)
22491 else if (value < valueMin)
22497 if (value > valueMax)
22499 else if (value < valueMin)
22521 QPointF
QCPCurve::getOptimizedPoint(
int otherRegion,
double otherKey,
double otherValue,
double key,
double value,
double keyMin,
double valueMax,
double keyMax,
double valueMin)
const 22528 const double keyMinPx =
mKeyAxis->coordToPixel(keyMin);
22529 const double keyMaxPx =
mKeyAxis->coordToPixel(keyMax);
22530 const double valueMinPx =
mValueAxis->coordToPixel(valueMin);
22531 const double valueMaxPx =
mValueAxis->coordToPixel(valueMax);
22532 const double otherValuePx =
mValueAxis->coordToPixel(otherValue);
22533 const double valuePx =
mValueAxis->coordToPixel(value);
22534 const double otherKeyPx =
mKeyAxis->coordToPixel(otherKey);
22535 const double keyPx =
mKeyAxis->coordToPixel(key);
22536 double intersectKeyPx = keyMinPx;
22537 double intersectValuePx = valueMinPx;
22538 switch (otherRegion)
22542 intersectValuePx = valueMaxPx;
22543 intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx);
22544 if (intersectKeyPx < qMin(keyMinPx, keyMaxPx) || intersectKeyPx > qMax(keyMinPx, keyMaxPx))
22546 intersectKeyPx = keyMinPx;
22547 intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx);
22553 intersectKeyPx = keyMinPx;
22554 intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx);
22559 intersectValuePx = valueMinPx;
22560 intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx);
22561 if (intersectKeyPx < qMin(keyMinPx, keyMaxPx) || intersectKeyPx > qMax(keyMinPx, keyMaxPx))
22563 intersectKeyPx = keyMinPx;
22564 intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx);
22570 intersectValuePx = valueMaxPx;
22571 intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx);
22580 intersectValuePx = valueMinPx;
22581 intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx);
22586 intersectValuePx = valueMaxPx;
22587 intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx);
22588 if (intersectKeyPx < qMin(keyMinPx, keyMaxPx) || intersectKeyPx > qMax(keyMinPx, keyMaxPx))
22590 intersectKeyPx = keyMaxPx;
22591 intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx);
22597 intersectKeyPx = keyMaxPx;
22598 intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx);
22603 intersectValuePx = valueMinPx;
22604 intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx);
22605 if (intersectKeyPx < qMin(keyMinPx, keyMaxPx) || intersectKeyPx > qMax(keyMinPx, keyMaxPx))
22607 intersectKeyPx = keyMaxPx;
22608 intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx);
22613 if (
mKeyAxis->orientation() == Qt::Horizontal)
22614 return QPointF(intersectKeyPx, intersectValuePx);
22616 return QPointF(intersectValuePx, intersectKeyPx);
22637 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 22639 QVector<QPointF> result;
22640 switch (prevRegion)
22644 switch (currentRegion)
22653 if ((value-prevValue)/(key-prevKey)*(keyMin-key)+value < valueMin)
22664 switch (currentRegion)
22668 case 4: { result <<
coordsToPixels(keyMin, valueMax); result.append(result.last());
break; }
22669 case 6: { result <<
coordsToPixels(keyMin, valueMin); result.append(result.last());
break; }
22670 case 7: { result <<
coordsToPixels(keyMin, valueMax); result.append(result.last()); result <<
coordsToPixels(keyMax, valueMax);
break; }
22671 case 9: { result <<
coordsToPixels(keyMin, valueMin); result.append(result.last()); result <<
coordsToPixels(keyMax, valueMin);
break; }
22677 switch (currentRegion)
22686 if ((value-prevValue)/(key-prevKey)*(keyMax-key)+value < valueMin)
22697 switch (currentRegion)
22701 case 2: { result <<
coordsToPixels(keyMin, valueMax); result.append(result.last());
break; }
22702 case 8: { result <<
coordsToPixels(keyMax, valueMax); result.append(result.last());
break; }
22703 case 3: { result <<
coordsToPixels(keyMin, valueMax); result.append(result.last()); result <<
coordsToPixels(keyMin, valueMin);
break; }
22704 case 9: { result <<
coordsToPixels(keyMax, valueMax); result.append(result.last()); result <<
coordsToPixels(keyMax, valueMin);
break; }
22710 switch (currentRegion)
22721 switch (currentRegion)
22725 case 2: { result <<
coordsToPixels(keyMin, valueMin); result.append(result.last());
break; }
22726 case 8: { result <<
coordsToPixels(keyMax, valueMin); result.append(result.last());
break; }
22727 case 1: { result <<
coordsToPixels(keyMin, valueMin); result.append(result.last()); result <<
coordsToPixels(keyMin, valueMax);
break; }
22728 case 7: { result <<
coordsToPixels(keyMax, valueMin); result.append(result.last()); result <<
coordsToPixels(keyMax, valueMax);
break; }
22734 switch (currentRegion)
22743 if ((value-prevValue)/(key-prevKey)*(keyMax-key)+value < valueMin)
22754 switch (currentRegion)
22758 case 4: { result <<
coordsToPixels(keyMax, valueMax); result.append(result.last());
break; }
22759 case 6: { result <<
coordsToPixels(keyMax, valueMin); result.append(result.last());
break; }
22760 case 1: { result <<
coordsToPixels(keyMax, valueMax); result.append(result.last()); result <<
coordsToPixels(keyMin, valueMax);
break; }
22761 case 3: { result <<
coordsToPixels(keyMax, valueMin); result.append(result.last()); result <<
coordsToPixels(keyMin, valueMin);
break; }
22767 switch (currentRegion)
22776 if ((value-prevValue)/(key-prevKey)*(keyMin-key)+value < valueMin)
22803 switch (prevRegion)
22807 switch (currentRegion)
22812 case 3:
return false;
22813 default:
return true;
22818 switch (currentRegion)
22821 case 3:
return false;
22822 default:
return true;
22827 switch (currentRegion)
22832 case 9:
return false;
22833 default:
return true;
22838 switch (currentRegion)
22841 case 7:
return false;
22842 default:
return true;
22845 case 5:
return false;
22848 switch (currentRegion)
22851 case 9:
return false;
22852 default:
return true;
22857 switch (currentRegion)
22862 case 9:
return false;
22863 default:
return true;
22868 switch (currentRegion)
22871 case 9:
return false;
22872 default:
return true;
22877 switch (currentRegion)
22882 case 7:
return false;
22883 default:
return true;
22886 default:
return true;
22904 bool QCPCurve::getTraverse(
double prevKey,
double prevValue,
double key,
double value,
double keyMin,
double valueMax,
double keyMax,
double valueMin, QPointF &crossA, QPointF &crossB)
const 22911 QList<QPointF> intersections;
22912 const double valueMinPx =
mValueAxis->coordToPixel(valueMin);
22913 const double valueMaxPx =
mValueAxis->coordToPixel(valueMax);
22914 const double keyMinPx =
mKeyAxis->coordToPixel(keyMin);
22915 const double keyMaxPx =
mKeyAxis->coordToPixel(keyMax);
22916 const double keyPx =
mKeyAxis->coordToPixel(key);
22917 const double valuePx =
mValueAxis->coordToPixel(value);
22918 const double prevKeyPx =
mKeyAxis->coordToPixel(prevKey);
22919 const double prevValuePx =
mValueAxis->coordToPixel(prevValue);
22920 if (qFuzzyIsNull(key-prevKey))
22923 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyPx, valueMinPx) : QPointF(valueMinPx, keyPx));
22924 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyPx, valueMaxPx) : QPointF(valueMaxPx, keyPx));
22925 }
else if (qFuzzyIsNull(value-prevValue))
22928 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyMinPx, valuePx) : QPointF(valuePx, keyMinPx));
22929 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyMaxPx, valuePx) : QPointF(valuePx, keyMaxPx));
22933 double keyPerValuePx = (keyPx-prevKeyPx)/(valuePx-prevValuePx);
22935 gamma = prevKeyPx + (valueMaxPx-prevValuePx)*keyPerValuePx;
22936 if (gamma >= qMin(keyMinPx, keyMaxPx) && gamma <= qMax(keyMinPx, keyMaxPx))
22937 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(gamma, valueMaxPx) : QPointF(valueMaxPx, gamma));
22939 gamma = prevKeyPx + (valueMinPx-prevValuePx)*keyPerValuePx;
22940 if (gamma >= qMin(keyMinPx, keyMaxPx) && gamma <= qMax(keyMinPx, keyMaxPx))
22941 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(gamma, valueMinPx) : QPointF(valueMinPx, gamma));
22942 const double valuePerKeyPx = 1.0/keyPerValuePx;
22944 gamma = prevValuePx + (keyMinPx-prevKeyPx)*valuePerKeyPx;
22945 if (gamma >= qMin(valueMinPx, valueMaxPx) && gamma <= qMax(valueMinPx, valueMaxPx))
22946 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyMinPx, gamma) : QPointF(gamma, keyMinPx));
22948 gamma = prevValuePx + (keyMaxPx-prevKeyPx)*valuePerKeyPx;
22949 if (gamma >= qMin(valueMinPx, valueMaxPx) && gamma <= qMax(valueMinPx, valueMaxPx))
22950 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyMaxPx, gamma) : QPointF(gamma, keyMaxPx));
22954 if (intersections.size() > 2)
22957 double distSqrMax = 0;
22959 for (
int i=0; i<intersections.size()-1; ++i)
22961 for (
int k=i+1; k<intersections.size(); ++k)
22963 QPointF distPoint = intersections.at(i)-intersections.at(k);
22964 double distSqr = distPoint.x()*distPoint.x()+distPoint.y()+distPoint.y();
22965 if (distSqr > distSqrMax)
22967 pv1 = intersections.at(i);
22968 pv2 = intersections.at(k);
22969 distSqrMax = distSqr;
22973 intersections = QList<QPointF>() << pv1 << pv2;
22974 }
else if (intersections.size() != 2)
22981 double xDelta = keyPx-prevKeyPx;
22982 double yDelta = valuePx-prevValuePx;
22983 if (
mKeyAxis->orientation() != Qt::Horizontal)
22984 qSwap(xDelta, yDelta);
22985 if (xDelta*(intersections.at(1).x()-intersections.at(0).x()) + yDelta*(intersections.at(1).y()-intersections.at(0).y()) < 0)
22986 intersections.move(0, 1);
22987 crossA = intersections.at(0);
22988 crossB = intersections.at(1);
23017 void QCPCurve::getTraverseCornerPoints(
int prevRegion,
int currentRegion,
double keyMin,
double valueMax,
double keyMax,
double valueMin, QVector<QPointF> &beforeTraverse, QVector<QPointF> &afterTraverse)
const 23019 switch (prevRegion)
23023 switch (currentRegion)
23025 case 6: { beforeTraverse <<
coordsToPixels(keyMin, valueMax);
break; }
23027 case 8: { beforeTraverse <<
coordsToPixels(keyMin, valueMax);
break; }
23033 switch (currentRegion)
23035 case 7: { afterTraverse <<
coordsToPixels(keyMax, valueMax);
break; }
23036 case 9: { afterTraverse <<
coordsToPixels(keyMax, valueMin);
break; }
23042 switch (currentRegion)
23044 case 4: { beforeTraverse <<
coordsToPixels(keyMin, valueMin);
break; }
23046 case 8: { beforeTraverse <<
coordsToPixels(keyMin, valueMin);
break; }
23052 switch (currentRegion)
23054 case 3: { afterTraverse <<
coordsToPixels(keyMin, valueMin);
break; }
23055 case 9: { afterTraverse <<
coordsToPixels(keyMax, valueMin);
break; }
23062 switch (currentRegion)
23064 case 1: { afterTraverse <<
coordsToPixels(keyMin, valueMax);
break; }
23065 case 7: { afterTraverse <<
coordsToPixels(keyMax, valueMax);
break; }
23071 switch (currentRegion)
23073 case 2: { beforeTraverse <<
coordsToPixels(keyMax, valueMax);
break; }
23075 case 6: { beforeTraverse <<
coordsToPixels(keyMax, valueMax);
break; }
23081 switch (currentRegion)
23083 case 1: { afterTraverse <<
coordsToPixels(keyMin, valueMax);
break; }
23084 case 3: { afterTraverse <<
coordsToPixels(keyMin, valueMin);
break; }
23090 switch (currentRegion)
23092 case 2: { beforeTraverse <<
coordsToPixels(keyMax, valueMin);
break; }
23094 case 4: { beforeTraverse <<
coordsToPixels(keyMax, valueMin);
break; }
23129 double minDistSqr = (std::numeric_limits<double>::max)();
23136 if (currentDistSqr < minDistSqr)
23138 minDistSqr = currentDistSqr;
23146 QVector<QPointF> lines;
23148 for (
int i=0; i<lines.size()-1; ++i)
23151 if (currentDistSqr < minDistSqr)
23152 minDistSqr = currentDistSqr;
23156 return qSqrt(minDistSqr);
23237 QObject(parentPlot),
23239 mSpacingType(stAbsolute),
23280 if (index >= 0 && index <
mBars.size())
23282 return mBars.at(index);
23285 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
23311 qDebug() << Q_FUNC_INFO <<
"bars is 0";
23315 if (!
mBars.contains(bars))
23318 qDebug() << Q_FUNC_INFO <<
"bars plottable is already in this bars group:" <<
reinterpret_cast<quintptr
>(
bars);
23334 qDebug() << Q_FUNC_INFO <<
"bars is 0";
23339 if (!
mBars.contains(bars))
23354 qDebug() << Q_FUNC_INFO <<
"bars is 0";
23358 if (
mBars.contains(bars))
23361 qDebug() << Q_FUNC_INFO <<
"bars plottable is not in this bars group:" <<
reinterpret_cast<quintptr
>(
bars);
23373 if (!
mBars.contains(bars))
23374 mBars.append(bars);
23386 mBars.removeOne(bars);
23398 QList<const QCPBars*> baseBars;
23403 if (!baseBars.contains(b))
23404 baseBars.append(b);
23413 int index = baseBars.indexOf(thisBase);
23416 if (baseBars.size() % 2 == 1 && index == (baseBars.size()-1)/2)
23421 double lowerPixelWidth, upperPixelWidth;
23423 int dir = (index <= (baseBars.size()-1)/2) ? -1 : 1;
23424 if (baseBars.size() % 2 == 0)
23426 startIndex = baseBars.size()/2 + (dir < 0 ? -1 : 0);
23430 startIndex = (baseBars.size()-1)/2+dir;
23431 baseBars.at((baseBars.size()-1)/2)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth);
23432 result += qAbs(upperPixelWidth-lowerPixelWidth)*0.5;
23433 result +=
getPixelSpacing(baseBars.at((baseBars.size()-1)/2), keyCoord);
23435 for (
int i = startIndex; i != index; i += dir)
23437 baseBars.at(i)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth);
23438 result += qAbs(upperPixelWidth-lowerPixelWidth);
23442 baseBars.at(index)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth);
23443 result += qAbs(upperPixelWidth-lowerPixelWidth)*0.5;
23653 mWidthType(wtPlotCoords),
23659 mPen.setColor(Qt::blue);
23660 mPen.setStyle(Qt::SolidLine);
23661 mBrush.setColor(QColor(40, 50, 255, 30));
23662 mBrush.setStyle(Qt::SolidPattern);
23704 void QCPBars::setData(
const QVector<double> &keys,
const QVector<double> &values,
bool alreadySorted)
23707 addData(keys, values, alreadySorted);
23790 void QCPBars::addData(
const QVector<double> &keys,
const QVector<double> &values,
bool alreadySorted)
23792 if (keys.size() != values.size())
23793 qDebug() << Q_FUNC_INFO <<
"keys and values have different sizes:" << keys.size() << values.size();
23794 const int n = qMin(keys.size(), values.size());
23795 QVector<QCPBarsData> tempData(n);
23796 QVector<QCPBarsData>::iterator it = tempData.begin();
23797 const QVector<QCPBarsData>::iterator itEnd = tempData.end();
23799 while (it != itEnd)
23802 it->value = values[i];
23836 if (bars ==
this)
return;
23839 qDebug() << Q_FUNC_INFO <<
"passed QCPBars* doesn't have same key and value axis as this QCPBars";
23869 if (bars ==
this)
return;
23872 qDebug() << Q_FUNC_INFO <<
"passed QCPBars* doesn't have same key and value axis as this QCPBars";
23902 if (rect.intersects(
getBarRect(it->key, it->value)))
23925 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
23932 if (
getBarRect(it->key, it->value).contains(pos))
23964 double lowerPixelWidth, upperPixelWidth, keyPixel;
23967 keyPixel =
mKeyAxis.data()->coordToPixel(range.
lower) + lowerPixelWidth;
23970 const double lowerCorrected =
mKeyAxis.data()->pixelToCoord(keyPixel);
23971 if (!qIsNaN(lowerCorrected) && qIsFinite(lowerCorrected) && range.
lower > lowerCorrected)
23972 range.
lower = lowerCorrected;
23975 keyPixel =
mKeyAxis.data()->coordToPixel(range.
upper) + upperPixelWidth;
23978 const double upperCorrected =
mKeyAxis.data()->pixelToCoord(keyPixel);
23979 if (!qIsNaN(upperCorrected) && qIsFinite(upperCorrected) && range.
upper < upperCorrected)
23980 range.
upper = upperCorrected;
23993 bool haveLower =
true;
23994 bool haveUpper =
true;
24005 if (qIsNaN(current))
continue;
24008 if (current < range.
lower || !haveLower)
24010 range.
lower = current;
24013 if (current > range.
upper || !haveUpper)
24015 range.
upper = current;
24028 if (index >= 0 && index < mDataContainer->size())
24032 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPointF(); }
24038 return QPointF(keyPixel, valuePixel);
24040 return QPointF(valuePixel, keyPixel);
24043 qDebug() << Q_FUNC_INFO <<
"Index out of bounds" << index;
24051 if (!
mKeyAxis || !
mValueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
24058 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
24060 allSegments << unselectedSegments << selectedSegments;
24061 for (
int i=0; i<allSegments.size(); ++i)
24063 bool isSelectedSegment = i >= unselectedSegments.size();
24066 mDataContainer->limitIteratorsToDataRange(begin, end, allSegments.at(i));
24073 #ifdef QCUSTOMPLOT_CHECK_DATA 24075 qDebug() << Q_FUNC_INFO <<
"Data point at" << it->key <<
"of drawn range invalid." <<
"Plottable name:" <<
name();
24084 painter->setBrush(
mBrush);
24088 painter->drawPolygon(
getBarRect(it->key, it->value));
24102 painter->setBrush(
mBrush);
24104 QRectF
r = QRectF(0, 0, rect.width()*0.67, rect.height()*0.67);
24105 r.moveCenter(rect.center());
24106 painter->drawRect(r);
24127 qDebug() << Q_FUNC_INFO <<
"invalid key axis";
24142 double lowerPixelBound =
mKeyAxis.data()->coordToPixel(
mKeyAxis.data()->range().lower);
24143 double upperPixelBound =
mKeyAxis.data()->coordToPixel(
mKeyAxis.data()->range().upper);
24150 const QRectF barRect =
getBarRect(it->key, it->value);
24151 if (
mKeyAxis.data()->orientation() == Qt::Horizontal)
24152 isVisible = ((!
mKeyAxis.data()->rangeReversed() && barRect.right() >= lowerPixelBound) || (
mKeyAxis.data()->rangeReversed() && barRect.left() <= lowerPixelBound));
24154 isVisible = ((!
mKeyAxis.data()->rangeReversed() && barRect.top() <= lowerPixelBound) || (
mKeyAxis.data()->rangeReversed() && barRect.bottom() >= lowerPixelBound));
24164 const QRectF barRect =
getBarRect(it->key, it->value);
24165 if (
mKeyAxis.data()->orientation() == Qt::Horizontal)
24166 isVisible = ((!
mKeyAxis.data()->rangeReversed() && barRect.left() <= upperPixelBound) || (
mKeyAxis.data()->rangeReversed() && barRect.right() >= upperPixelBound));
24168 isVisible = ((!
mKeyAxis.data()->rangeReversed() && barRect.bottom() >= upperPixelBound) || (
mKeyAxis.data()->rangeReversed() && barRect.top() <= upperPixelBound));
24187 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QRectF(); }
24189 double lowerPixelWidth, upperPixelWidth;
24193 double valuePixel = valueAxis->
coordToPixel(base+value);
24197 double bottomOffset = (
mBarBelow &&
mPen != Qt::NoPen ? 1 : 0)*(
mPen.isCosmetic() ? 1 :
mPen.widthF());
24200 if (qAbs(valuePixel-basePixel) <= qAbs(bottomOffset))
24201 bottomOffset = valuePixel-basePixel;
24204 return QRectF(QPointF(keyPixel+lowerPixelWidth, valuePixel), QPointF(keyPixel+upperPixelWidth, basePixel+bottomOffset)).normalized();
24207 return QRectF(QPointF(basePixel+bottomOffset, keyPixel+lowerPixelWidth), QPointF(valuePixel, keyPixel+upperPixelWidth)).normalized();
24236 if (
mKeyAxis.data()->orientation() == Qt::Horizontal)
24242 qDebug() << Q_FUNC_INFO <<
"No key axis or axis rect defined";
24249 double keyPixel =
mKeyAxis.data()->coordToPixel(key);
24255 qDebug() << Q_FUNC_INFO <<
"No key axis defined";
24276 double epsilon = qAbs(key)*(
sizeof(key)==4 ? 1e-6 : 1e-14);
24278 epsilon = (
sizeof(key)==4 ? 1e-6 : 1e-14);
24281 while (it != itEnd)
24283 if (it->key > key-epsilon && it->key < key+epsilon)
24285 if ((positive && it->value > max) ||
24286 (!positive && it->value < max))
24292 return max +
mBarBelow.data()->getStackedBaseValue(key, positive);
24307 if (!lower && !upper)
return;
24313 upper->
mBarBelow.data()->mBarAbove = 0;
24319 lower->
mBarAbove.data()->mBarBelow = 0;
24325 lower->
mBarAbove.data()->mBarBelow = 0;
24328 upper->
mBarBelow.data()->mBarAbove = 0;
24452 lowerQuartile(lowerQuartile),
24454 upperQuartile(upperQuartile),
24537 mWhiskerWidth(0.2),
24538 mWhiskerPen(Qt::black, 0, Qt::DashLine, Qt::FlatCap),
24539 mWhiskerBarPen(Qt::black),
24540 mWhiskerAntialiased(false),
24541 mMedianPen(Qt::black, 3, Qt::SolidLine, Qt::FlatCap),
24544 setPen(QPen(Qt::black));
24579 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)
24582 addData(keys, minimum, lowerQuartile, median, upperQuartile, maximum, alreadySorted);
24680 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)
24682 if (keys.size() != minimum.size() || minimum.size() != lowerQuartile.size() || lowerQuartile.size() != median.size() ||
24683 median.size() != upperQuartile.size() || upperQuartile.size() != maximum.size() || maximum.size() != keys.size())
24684 qDebug() << Q_FUNC_INFO <<
"keys, minimum, lowerQuartile, median, upperQuartile, maximum have different sizes:" 24685 << keys.size() << minimum.size() << lowerQuartile.size() << median.size() << upperQuartile.size() << maximum.size();
24686 const int n = qMin(keys.size(), qMin(minimum.size(), qMin(lowerQuartile.size(), qMin(median.size(), qMin(upperQuartile.size(), maximum.size())))));
24687 QVector<QCPStatisticalBoxData> tempData(n);
24688 QVector<QCPStatisticalBoxData>::iterator it = tempData.begin();
24689 const QVector<QCPStatisticalBoxData>::iterator itEnd = tempData.end();
24691 while (it != itEnd)
24694 it->minimum = minimum[i];
24695 it->lowerQuartile = lowerQuartile[i];
24696 it->median = median[i];
24697 it->upperQuartile = upperQuartile[i];
24698 it->maximum = maximum[i];
24713 void QCPStatisticalBox::addData(
double key,
double minimum,
double lowerQuartile,
double median,
double upperQuartile,
double maximum,
const QVector<double> &outliers)
24757 if (
mKeyAxis->axisRect()->rect().contains(pos.toPoint()))
24763 double minDistSqr = (std::numeric_limits<double>::max)();
24769 if (currentDistSqr < minDistSqr)
24771 minDistSqr = currentDistSqr;
24772 closestDataPoint = it;
24777 for (
int i=0; i<whiskerBackbones.size(); ++i)
24780 if (currentDistSqr < minDistSqr)
24782 minDistSqr = currentDistSqr;
24783 closestDataPoint = it;
24793 return qSqrt(minDistSqr);
24816 return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange);
24825 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
24831 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
24833 allSegments << unselectedSegments << selectedSegments;
24834 for (
int i=0; i<allSegments.size(); ++i)
24836 bool isSelectedSegment = i >= unselectedSegments.size();
24839 mDataContainer->limitIteratorsToDataRange(begin, end, allSegments.at(i));
24846 # ifdef QCUSTOMPLOT_CHECK_DATA 24850 qDebug() << Q_FUNC_INFO <<
"Data point at" << it->key <<
"of drawn range has invalid data." <<
"Plottable name:" <<
name();
24851 for (
int i=0; i<it->outliers.size(); ++i)
24853 qDebug() << Q_FUNC_INFO <<
"Data point outlier at" << it->key <<
"of drawn range invalid." <<
"Plottable name:" <<
name();
24863 painter->setBrush(
mBrush);
24883 painter->setBrush(
mBrush);
24884 QRectF
r = QRectF(0, 0, rect.width()*0.67, rect.height()*0.67);
24885 r.moveCenter(rect.center());
24886 painter->drawRect(r);
24902 painter->drawRect(quartileBox);
24905 painter->setClipRect(quartileBox, Qt::IntersectClip);
24918 for (
int i=0; i<it->outliers.size(); ++i)
24940 qDebug() << Q_FUNC_INFO <<
"invalid key axis";
24974 QVector<QLineF> result(2);
24989 QVector<QLineF> result(2);
25057 mKeyRange(keyRange),
25058 mValueRange(valueRange),
25062 mDataModified(true)
25096 if (&other !=
this)
25123 if (keyCell >= 0 && keyCell < mKeySize && valueCell >= 0 && valueCell <
mValueSize)
25132 if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex <
mValueSize)
25148 if (
mAlpha && keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex <
mValueSize)
25177 #ifdef __EXCEPTIONS 25181 #ifdef __EXCEPTIONS 25182 }
catch (...) {
mData = 0; }
25187 qDebug() << Q_FUNC_INFO <<
"out of memory for data dimensions "<<
mKeySize <<
"*" <<
mValueSize;
25290 if (keyCell >= 0 && keyCell < mKeySize && valueCell >= 0 && valueCell <
mValueSize)
25314 if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex <
mValueSize)
25323 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << keyIndex << valueIndex;
25343 if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex <
mValueSize)
25351 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << keyIndex << valueIndex;
25371 double minHeight =
mData[0];
25372 double maxHeight =
mData[0];
25374 for (
int i=0; i<dataCount; ++i)
25376 if (
mData[i] > maxHeight)
25377 maxHeight =
mData[i];
25378 if (
mData[i] < minHeight)
25379 minHeight =
mData[i];
25415 for (
int i=0; i<dataCount; ++i)
25435 for (
int i=0; i<dataCount; ++i)
25508 #ifdef __EXCEPTIONS 25512 #ifdef __EXCEPTIONS 25513 }
catch (...) {
mAlpha = 0; }
25517 if (initializeOpaque)
25522 qDebug() << Q_FUNC_INFO <<
"out of memory for data dimensions "<<
mKeySize <<
"*" <<
mValueSize;
25653 mDataScaleType(
QCPAxis::stLinear),
25656 mInterpolate(true),
25657 mTightBoundary(false),
25658 mMapImageInvalidated(true)
25678 qDebug() << Q_FUNC_INFO <<
"The data pointer is already in (and owned by) this plottable" <<
reinterpret_cast<quintptr
>(
data);
25842 if (recalculateDataBounds)
25870 mLegendIcon = QPixmap::fromImage(
mMapImage.mirrored(mirrorX, mirrorY)).scaled(thumbSize, Qt::KeepAspectRatio, transformMode);
25883 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
25885 double posKey, posValue;
25907 else if (result.
lower <= 0 && result.
upper <= 0)
25908 foundRange =
false;
25913 else if (result.
upper >= 0 && result.
lower >= 0)
25914 foundRange =
false;
25926 foundRange =
false;
25938 else if (result.
lower <= 0 && result.
upper <= 0)
25939 foundRange =
false;
25944 else if (result.
upper >= 0 && result.
lower >= 0)
25945 foundRange =
false;
25967 if (!keyAxis)
return;
25970 const QImage::Format format = QImage::Format_ARGB32_Premultiplied;
25973 int keyOversamplingFactor =
mInterpolate ? 1 : (int)(1.0+100.0/(
double)keySize);
25974 int valueOversamplingFactor =
mInterpolate ? 1 : (int)(1.0+100.0/(
double)valueSize);
25977 if (keyAxis->
orientation() == Qt::Horizontal && (
mMapImage.width() != keySize*keyOversamplingFactor ||
mMapImage.height() != valueSize*valueOversamplingFactor))
25978 mMapImage = QImage(QSize(keySize*keyOversamplingFactor, valueSize*valueOversamplingFactor), format);
25979 else if (keyAxis->
orientation() == Qt::Vertical && (
mMapImage.width() != valueSize*valueOversamplingFactor ||
mMapImage.height() != keySize*keyOversamplingFactor))
25980 mMapImage = QImage(QSize(valueSize*valueOversamplingFactor, keySize*keyOversamplingFactor), format);
25984 qDebug() << Q_FUNC_INFO <<
"Couldn't create map image (possibly too large for memory)";
25985 mMapImage = QImage(QSize(10, 10), format);
25990 if (keyOversamplingFactor > 1 || valueOversamplingFactor > 1)
26005 const int lineCount = valueSize;
26006 const int rowCount = keySize;
26007 for (
int line=0; line<lineCount; ++line)
26009 QRgb* pixels =
reinterpret_cast<QRgb*
>(localMapImage->scanLine(lineCount-1-line));
26017 const int lineCount = keySize;
26018 const int rowCount = valueSize;
26019 for (
int line=0; line<lineCount; ++line)
26021 QRgb* pixels =
reinterpret_cast<QRgb*
>(localMapImage->scanLine(lineCount-1-line));
26029 if (keyOversamplingFactor > 1 || valueOversamplingFactor > 1)
26032 mMapImage =
mUndersampledMapImage.scaled(keySize*keyOversamplingFactor, valueSize*valueOversamplingFactor, Qt::IgnoreAspectRatio, Qt::FastTransformation);
26034 mMapImage =
mUndersampledMapImage.scaled(valueSize*valueOversamplingFactor, keySize*keyOversamplingFactor, Qt::IgnoreAspectRatio, Qt::FastTransformation);
26054 QRectF mapBufferTarget;
26058 const double mapBufferPixelRatio = 3;
26059 mapBufferTarget = painter->clipRegion().boundingRect();
26060 mapBuffer = QPixmap((mapBufferTarget.size()*mapBufferPixelRatio).toSize());
26061 mapBuffer.fill(Qt::transparent);
26063 localPainter->scale(mapBufferPixelRatio, mapBufferPixelRatio);
26064 localPainter->translate(-mapBufferTarget.topLeft());
26070 double halfCellWidth = 0;
26071 double halfCellHeight = 0;
26072 if (
keyAxis()->orientation() == Qt::Horizontal)
26075 halfCellWidth = 0.5*imageRect.width()/(double)(
mMapData->
keySize()-1);
26081 halfCellHeight = 0.5*imageRect.height()/(double)(
mMapData->
keySize()-1);
26085 imageRect.adjust(-halfCellWidth, -halfCellHeight, halfCellWidth, halfCellHeight);
26088 const bool smoothBackup = localPainter->renderHints().testFlag(QPainter::SmoothPixmapTransform);
26089 localPainter->setRenderHint(QPainter::SmoothPixmapTransform,
mInterpolate);
26090 QRegion clipBackup;
26093 clipBackup = localPainter->clipRegion();
26096 localPainter->setClipRect(tightClipRect, Qt::IntersectClip);
26098 localPainter->drawImage(imageRect,
mMapImage.mirrored(mirrorX, mirrorY));
26100 localPainter->setClipRegion(clipBackup);
26101 localPainter->setRenderHint(QPainter::SmoothPixmapTransform, smoothBackup);
26105 delete localPainter;
26106 painter->drawPixmap(mapBufferTarget.toRect(), mapBuffer);
26117 QPixmap scaledIcon =
mLegendIcon.scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::FastTransformation);
26118 QRectF iconRect = QRectF(0, 0, scaledIcon.width(), scaledIcon.height());
26119 iconRect.moveCenter(rect.center());
26120 painter->drawPixmap(iconRect.topLeft(), scaledIcon);
26310 mChartStyle(csCandlestick),
26312 mWidthType(wtPlotCoords),
26314 mBrushPositive(QBrush(QColor(50, 160, 0))),
26315 mBrushNegative(QBrush(QColor(180, 0, 15))),
26316 mPenPositive(QPen(QColor(40, 150, 0))),
26317 mPenNegative(QPen(QColor(170, 5, 5)))
26357 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)
26360 addData(keys, open, high, low, close, alreadySorted);
26478 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)
26480 if (keys.size() != open.size() || open.size() != high.size() || high.size() != low.size() || low.size() != close.size() || close.size() != keys.size())
26481 qDebug() << Q_FUNC_INFO <<
"keys, open, high, low, close have different sizes:" << keys.size() << open.size() << high.size() << low.size() << close.size();
26482 const int n = qMin(keys.size(), qMin(open.size(), qMin(high.size(), qMin(low.size(), close.size()))));
26483 QVector<QCPFinancialData> tempData(n);
26484 QVector<QCPFinancialData>::iterator it = tempData.begin();
26485 const QVector<QCPFinancialData>::iterator itEnd = tempData.end();
26487 while (it != itEnd)
26490 it->open = open[i];
26491 it->high = high[i];
26493 it->close = close[i];
26554 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
26561 double result = -1;
26565 result =
ohlcSelectTest(pos, visibleBegin, visibleEnd, closestDataPoint);
break;
26598 return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange);
26618 int count = qMin(time.size(), value.size());
26622 QCPFinancialData currentBinData(0, value.first(), value.first(), value.first(), value.first());
26623 int currentBinIndex = qFloor((time.first()-timeBinOffset)/timeBinSize+0.5);
26624 for (
int i=0; i<count; ++i)
26626 int index = qFloor((time.at(i)-timeBinOffset)/timeBinSize+0.5);
26627 if (currentBinIndex == index)
26629 if (value.at(i) < currentBinData.low) currentBinData.low = value.at(i);
26630 if (value.at(i) > currentBinData.high) currentBinData.high = value.at(i);
26633 currentBinData.close = value.at(i);
26634 currentBinData.key = timeBinOffset+(index)*timeBinSize;
26635 data.
add(currentBinData);
26640 currentBinData.close = value.at(i-1);
26641 currentBinData.key = timeBinOffset+(index-1)*timeBinSize;
26642 data.
add(currentBinData);
26644 currentBinIndex = index;
26645 currentBinData.open = value.at(i);
26646 currentBinData.high = value.at(i);
26647 currentBinData.low = value.at(i);
26662 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
26664 allSegments << unselectedSegments << selectedSegments;
26665 for (
int i=0; i<allSegments.size(); ++i)
26667 bool isSelectedSegment = i >= unselectedSegments.size();
26670 mDataContainer->limitIteratorsToDataRange(begin, end, allSegments.at(i));
26678 drawOhlcPlot(painter, begin, end, isSelectedSegment);
break;
26700 painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.topLeft().toPoint()));
26701 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26702 painter->
drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft()));
26703 painter->
drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft()));
26707 painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.bottomRight().toPoint()));
26708 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26709 painter->
drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft()));
26710 painter->
drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft()));
26713 painter->setBrush(
mBrush);
26715 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26716 painter->
drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft()));
26717 painter->
drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft()));
26726 painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.topLeft().toPoint()));
26727 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft()));
26728 painter->
drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26729 painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft()));
26733 painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.bottomRight().toPoint()));
26734 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft()));
26735 painter->
drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26736 painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft()));
26739 painter->setBrush(
mBrush);
26741 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft()));
26742 painter->
drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26743 painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft()));
26758 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
26772 double closePixel = valueAxis->
coordToPixel(it->close);
26777 painter->
drawLine(QPointF(keyPixel-pixelWidth, openPixel), QPointF(keyPixel, openPixel));
26779 painter->
drawLine(QPointF(keyPixel, closePixel), QPointF(keyPixel+pixelWidth, closePixel));
26793 double closePixel = valueAxis->
coordToPixel(it->close);
26798 painter->
drawLine(QPointF(openPixel, keyPixel-pixelWidth), QPointF(openPixel, keyPixel));
26800 painter->
drawLine(QPointF(closePixel, keyPixel), QPointF(closePixel, keyPixel+pixelWidth));
26815 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
26832 painter->setBrush(
mBrush);
26836 double closePixel = valueAxis->
coordToPixel(it->close);
26843 painter->drawRect(QRectF(QPointF(keyPixel-pixelWidth, closePixel), QPointF(keyPixel+pixelWidth, openPixel)));
26860 painter->setBrush(
mBrush);
26864 double closePixel = valueAxis->
coordToPixel(it->close);
26871 painter->drawRect(QRectF(QPointF(closePixel, keyPixel-pixelWidth), QPointF(openPixel, keyPixel+pixelWidth)));
26903 if (
mKeyAxis.data()->orientation() == Qt::Horizontal)
26908 qDebug() << Q_FUNC_INFO <<
"No key axis or axis rect defined";
26914 result =
mKeyAxis.data()->coordToPixel(key+
mWidth*0.5)-keyPixel;
26916 qDebug() << Q_FUNC_INFO <<
"No key axis defined";
26936 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return -1; }
26938 double minDistSqr = (std::numeric_limits<double>::max)();
26946 if (currentDistSqr < minDistSqr)
26948 minDistSqr = currentDistSqr;
26949 closestDataPoint = it;
26959 if (currentDistSqr < minDistSqr)
26961 minDistSqr = currentDistSqr;
26962 closestDataPoint = it;
26966 return qSqrt(minDistSqr);
26983 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return -1; }
26985 double minDistSqr = (std::numeric_limits<double>::max)();
26990 double currentDistSqr;
26993 QCPRange boxValueRange(it->close, it->open);
26994 double posKey, posValue;
27005 currentDistSqr = qMin(highLineDistSqr, lowLineDistSqr);
27007 if (currentDistSqr < minDistSqr)
27009 minDistSqr = currentDistSqr;
27010 closestDataPoint = it;
27017 double currentDistSqr;
27020 QCPRange boxValueRange(it->close, it->open);
27021 double posKey, posValue;
27032 currentDistSqr = qMin(highLineDistSqr, lowLineDistSqr);
27034 if (currentDistSqr < minDistSqr)
27036 minDistSqr = currentDistSqr;
27037 closestDataPoint = it;
27041 return qSqrt(minDistSqr);
27062 qDebug() << Q_FUNC_INFO <<
"invalid key axis";
27080 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QRectF(); }
27087 return QRectF(keyPixel-keyWidthPixels, highPixel, keyWidthPixels*2, lowPixel-highPixel).normalized();
27089 return QRectF(highPixel, keyPixel-keyWidthPixels, lowPixel-highPixel, keyWidthPixels*2).normalized();
27139 errorMinus(errorMinus),
27140 errorPlus(errorPlus)
27205 mErrorType(etValueError),
27209 setPen(QPen(Qt::black, 0));
27268 addData(errorMinus, errorPlus);
27287 if (plottable && qobject_cast<QCPErrorBars*>(plottable))
27290 qDebug() << Q_FUNC_INFO <<
"can't set another QCPErrorBars instance as data plottable";
27296 qDebug() << Q_FUNC_INFO <<
"passed plottable doesn't implement 1d interface, can't associate with QCPErrorBars";
27357 if (errorMinus.size() != errorPlus.size())
27358 qDebug() << Q_FUNC_INFO <<
"minus and plus error vectors have different sizes:" << errorMinus.size() << errorPlus.size();
27359 const int n = qMin(errorMinus.size(), errorPlus.size());
27361 for (
int i=0; i<n; ++i)
27406 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27416 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27426 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27435 const double value =
mDataPlottable->interface1D()->dataMainValue(index);
27442 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27453 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27465 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27483 QCPErrorBarsDataContainer::const_iterator visibleBegin, visibleEnd;
27486 QVector<QLineF> backbones, whiskers;
27487 for (QCPErrorBarsDataContainer::const_iterator it=visibleBegin; it!=visibleEnd; ++it)
27492 for (
int i=0; i<backbones.size(); ++i)
27512 int beginIndex =
mDataPlottable->interface1D()->findBegin(sortKey, expandedRange);
27517 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27528 int endIndex =
mDataPlottable->interface1D()->findEnd(sortKey, expandedRange);
27533 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27554 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
27556 QCPErrorBarsDataContainer::const_iterator closestDataPoint =
mDataContainer->constEnd();
27572 if (!
mKeyAxis || !
mValueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
27577 bool checkPointVisibility = !
mDataPlottable->interface1D()->sortKeyIsMainKey();
27580 #ifdef QCUSTOMPLOT_CHECK_DATA 27581 QCPErrorBarsDataContainer::const_iterator it;
27585 qDebug() << Q_FUNC_INFO <<
"Data point at index" << it-
mDataContainer->constBegin() <<
"invalid." <<
"Plottable name:" <<
name();
27590 painter->setBrush(Qt::NoBrush);
27592 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
27594 allSegments << unselectedSegments << selectedSegments;
27595 QVector<QLineF> backbones, whiskers;
27596 for (
int i=0; i<allSegments.size(); ++i)
27598 QCPErrorBarsDataContainer::const_iterator begin, end;
27603 bool isSelectedSegment = i >= unselectedSegments.size();
27608 if (painter->pen().capStyle() == Qt::SquareCap)
27610 QPen capFixPen(painter->pen());
27611 capFixPen.setCapStyle(Qt::FlatCap);
27612 painter->
setPen(capFixPen);
27616 for (QCPErrorBarsDataContainer::const_iterator it=begin; it!=end; ++it)
27621 painter->drawLines(backbones);
27622 painter->drawLines(whiskers);
27637 painter->
drawLine(QLineF(rect.center().x(), rect.top()+2, rect.center().x(), rect.bottom()-1));
27638 painter->
drawLine(QLineF(rect.center().x()-4, rect.top()+2, rect.center().x()+4, rect.top()+2));
27639 painter->
drawLine(QLineF(rect.center().x()-4, rect.bottom()-1, rect.center().x()+4, rect.bottom()-1));
27642 painter->
drawLine(QLineF(rect.left()+2, rect.center().y(), rect.right()-2, rect.center().y()));
27643 painter->
drawLine(QLineF(rect.left()+2, rect.center().y()-4, rect.left()+2, rect.center().y()+4));
27644 painter->
drawLine(QLineF(rect.right()-2, rect.center().y()-4, rect.right()-2, rect.center().y()+4));
27653 foundRange =
false;
27658 bool haveLower =
false;
27659 bool haveUpper =
false;
27660 QCPErrorBarsDataContainer::const_iterator it;
27667 if (qIsNaN(current))
continue;
27670 if (current < range.
lower || !haveLower)
27672 range.
lower = current;
27675 if (current > range.
upper || !haveUpper)
27677 range.
upper = current;
27684 if (qIsNaN(dataKey))
continue;
27686 double current = dataKey + (qIsNaN(it->errorPlus) ? 0 : it->errorPlus);
27689 if (current > range.
upper || !haveUpper)
27691 range.
upper = current;
27696 current = dataKey - (qIsNaN(it->errorMinus) ? 0 : it->errorMinus);
27699 if (current < range.
lower || !haveLower)
27701 range.
lower = current;
27708 if (haveUpper && !haveLower)
27712 }
else if (haveLower && !haveUpper)
27718 foundRange = haveLower && haveUpper;
27727 foundRange =
false;
27732 const bool restrictKeyRange = inKeyRange !=
QCPRange();
27733 bool haveLower =
false;
27734 bool haveUpper =
false;
27735 QCPErrorBarsDataContainer::const_iterator itBegin =
mDataContainer->constBegin();
27736 QCPErrorBarsDataContainer::const_iterator itEnd =
mDataContainer->constEnd();
27737 if (
mDataPlottable->interface1D()->sortKeyIsMainKey() && restrictKeyRange)
27742 for (QCPErrorBarsDataContainer::const_iterator it = itBegin; it != itEnd; ++it)
27744 if (restrictKeyRange)
27747 if (dataKey < inKeyRange.lower || dataKey > inKeyRange.
upper)
27753 if (qIsNaN(dataValue))
continue;
27755 double current = dataValue + (qIsNaN(it->errorPlus) ? 0 : it->errorPlus);
27758 if (current > range.
upper || !haveUpper)
27760 range.
upper = current;
27765 current = dataValue - (qIsNaN(it->errorMinus) ? 0 : it->errorMinus);
27768 if (current < range.
lower || !haveLower)
27770 range.
lower = current;
27778 if (qIsNaN(current))
continue;
27781 if (current < range.
lower || !haveLower)
27783 range.
lower = current;
27786 if (current > range.
upper || !haveUpper)
27788 range.
upper = current;
27795 if (haveUpper && !haveLower)
27799 }
else if (haveLower && !haveUpper)
27805 foundRange = haveLower && haveUpper;
27825 QPointF centerPixel =
mDataPlottable->interface1D()->dataPixelPosition(index);
27826 if (qIsNaN(centerPixel.x()) || qIsNaN(centerPixel.y()))
27830 const double centerErrorAxisPixel = errorAxis->
orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
27831 const double centerOrthoAxisPixel = orthoAxis->
orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
27832 const double centerErrorAxisCoord = errorAxis->
pixelToCoord(centerErrorAxisPixel);
27835 double errorStart, errorEnd;
27836 if (!qIsNaN(it->errorPlus))
27838 errorStart = centerErrorAxisPixel+
symbolGap;
27839 errorEnd = errorAxis->
coordToPixel(centerErrorAxisCoord+it->errorPlus);
27843 backbones.append(QLineF(centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd));
27844 whiskers.append(QLineF(centerOrthoAxisPixel-
mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+
mWhiskerWidth*0.5, errorEnd));
27848 backbones.append(QLineF(errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel));
27849 whiskers.append(QLineF(errorEnd, centerOrthoAxisPixel-
mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+
mWhiskerWidth*0.5));
27853 if (!qIsNaN(it->errorMinus))
27855 errorStart = centerErrorAxisPixel-
symbolGap;
27856 errorEnd = errorAxis->
coordToPixel(centerErrorAxisCoord-it->errorMinus);
27860 backbones.append(QLineF(centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd));
27861 whiskers.append(QLineF(centerOrthoAxisPixel-
mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+
mWhiskerWidth*0.5, errorEnd));
27865 backbones.append(QLineF(errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel));
27866 whiskers.append(QLineF(errorEnd, centerOrthoAxisPixel-
mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+
mWhiskerWidth*0.5));
27893 if (!keyAxis || !valueAxis)
27895 qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
27912 dataRange = dataRange.
bounded(rangeRestriction);
27922 int i = beginIndex;
27923 while (i > 0 && i < n && i > rangeRestriction.
begin())
27930 while (i >= 0 && i < n && i < rangeRestriction.
end())
27955 qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
27959 QCPErrorBarsDataContainer::const_iterator begin, end;
27963 double minDistSqr = (std::numeric_limits<double>::max)();
27964 QVector<QLineF> backbones, whiskers;
27965 for (QCPErrorBarsDataContainer::const_iterator it=begin; it!=end; ++it)
27968 for (
int i=0; i<backbones.size(); ++i)
27971 if (currentDistSqr < minDistSqr)
27973 minDistSqr = currentDistSqr;
27978 return qSqrt(minDistSqr);
27990 selectedSegments.clear();
27991 unselectedSegments.clear();
27997 unselectedSegments << QCPDataRange(0,
dataCount());
28018 QPointF centerPixel =
mDataPlottable->interface1D()->dataPixelPosition(index);
28019 const double centerKeyPixel =
mKeyAxis->orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
28020 if (qIsNaN(centerKeyPixel))
28023 double keyMin, keyMax;
28026 const double centerKey =
mKeyAxis->pixelToCoord(centerKeyPixel);
28029 keyMax = centerKey+(qIsNaN(errorPlus) ? 0 : errorPlus);
28030 keyMin = centerKey-(qIsNaN(errorMinus) ? 0 : errorMinus);
28036 return ((keyMax >
mKeyAxis->range().lower) && (keyMin < mKeyAxis->range().upper));
28048 if (pixelRect.left() > line.x1() && pixelRect.left() > line.x2())
28050 else if (pixelRect.right() < line.x1() && pixelRect.right() < line.x2())
28052 else if (pixelRect.top() > line.y1() && pixelRect.top() > line.y2())
28054 else if (pixelRect.bottom() < line.y1() && pixelRect.bottom() < line.y2())
28085 point1(createPosition(QLatin1String(
"point1"))),
28086 point2(createPosition(QLatin1String(
"point2")))
28091 setPen(QPen(Qt::black));
28135 double clipPad =
mainPen().widthF();
28138 if (!line.isNull())
28157 if (vec.
x() == 0 && vec.
y() == 0)
28159 if (qFuzzyIsNull(vec.
x()))
28164 gamma = base.
x()-bx + (by-base.
y())*vec.
x()/vec.
y();
28165 if (gamma >= 0 && gamma <= rect.width())
28166 result.setLine(bx+gamma, rect.top(), bx+gamma, rect.bottom());
28167 }
else if (qFuzzyIsNull(vec.
y()))
28172 gamma = base.
y()-by + (bx-base.
x())*vec.
y()/vec.
x();
28173 if (gamma >= 0 && gamma <= rect.height())
28174 result.setLine(rect.left(), by+gamma, rect.right(), by+gamma);
28177 QList<QCPVector2D> pointVectors;
28181 gamma = base.
x()-bx + (by-base.
y())*vec.
x()/vec.
y();
28182 if (gamma >= 0 && gamma <= rect.width())
28186 by = rect.bottom();
28187 gamma = base.
x()-bx + (by-base.
y())*vec.
x()/vec.
y();
28188 if (gamma >= 0 && gamma <= rect.width())
28193 gamma = base.
y()-by + (bx-base.
x())*vec.
y()/vec.
x();
28194 if (gamma >= 0 && gamma <= rect.height())
28199 gamma = base.
y()-by + (bx-base.
x())*vec.
y()/vec.
x();
28200 if (gamma >= 0 && gamma <= rect.height())
28204 if (pointVectors.size() == 2)
28206 result.setPoints(pointVectors.at(0).toPointF(), pointVectors.at(1).toPointF());
28207 }
else if (pointVectors.size() > 2)
28210 double distSqrMax = 0;
28212 for (
int i=0; i<pointVectors.size()-1; ++i)
28214 for (
int k=i+1; k<pointVectors.size(); ++k)
28216 double distSqr = (pointVectors.at(i)-pointVectors.at(k)).lengthSquared();
28217 if (distSqr > distSqrMax)
28219 pv1 = pointVectors.at(i);
28220 pv2 = pointVectors.at(k);
28221 distSqrMax = distSqr;
28274 setPen(QPen(Qt::black));
28343 if (qFuzzyIsNull((startVec-endVec).lengthSquared()))
28347 clipPad = qMax(clipPad, (
double)
mainPen().widthF());
28350 if (!line.isNull())
28354 painter->setBrush(Qt::SolidPattern);
28356 mTail.
draw(painter, startVec, startVec-endVec);
28358 mHead.
draw(painter, endVec, endVec-startVec);
28371 bool containsStart = rect.contains(start.
x(), start.
y());
28372 bool containsEnd = rect.contains(end.
x(), end.
y());
28373 if (containsStart && containsEnd)
28381 QList<QCPVector2D> pointVectors;
28383 if (!qFuzzyIsNull(vec.
y()))
28388 mu = (by-base.y())/vec.
y();
28389 if (mu >= 0 && mu <= 1)
28391 gamma = base.x()-bx + mu*vec.
x();
28392 if (gamma >= 0 && gamma <= rect.width())
28397 by = rect.bottom();
28398 mu = (by-base.y())/vec.
y();
28399 if (mu >= 0 && mu <= 1)
28401 gamma = base.x()-bx + mu*vec.
x();
28402 if (gamma >= 0 && gamma <= rect.width())
28406 if (!qFuzzyIsNull(vec.
x()))
28411 mu = (bx-base.x())/vec.
x();
28412 if (mu >= 0 && mu <= 1)
28414 gamma = base.y()-by + mu*vec.
y();
28415 if (gamma >= 0 && gamma <= rect.height())
28421 mu = (bx-base.x())/vec.
x();
28422 if (mu >= 0 && mu <= 1)
28424 gamma = base.y()-by + mu*vec.
y();
28425 if (gamma >= 0 && gamma <= rect.height())
28431 pointVectors.append(start);
28433 pointVectors.append(end);
28436 if (pointVectors.size() == 2)
28438 result.setPoints(pointVectors.at(0).toPointF(), pointVectors.at(1).toPointF());
28439 }
else if (pointVectors.size() > 2)
28442 double distSqrMax = 0;
28444 for (
int i=0; i<pointVectors.size()-1; ++i)
28446 for (
int k=i+1; k<pointVectors.size(); ++k)
28448 double distSqr = (pointVectors.at(i)-pointVectors.at(k)).lengthSquared();
28449 if (distSqr > distSqrMax)
28451 pv1 = pointVectors.at(i);
28452 pv2 = pointVectors.at(k);
28453 distSqrMax = distSqr;
28516 setPen(QPen(Qt::black));
28582 QPainterPath cubicPath(startVec);
28583 cubicPath.cubicTo(startDirVec, endDirVec, endVec);
28585 QList<QPolygonF> polygons = cubicPath.toSubpathPolygons();
28586 if (polygons.isEmpty())
28588 const QPolygonF polygon = polygons.first();
28590 double minDistSqr = (std::numeric_limits<double>::max)();
28591 for (
int i=1; i<polygon.size(); ++i)
28594 if (distSqr < minDistSqr)
28595 minDistSqr = distSqr;
28597 return qSqrt(minDistSqr);
28607 if ((endVec-startVec).length() > 1e10)
28610 QPainterPath cubicPath(startVec.toPointF());
28611 cubicPath.cubicTo(startDirVec.toPointF(), endDirVec.toPointF(), endVec.toPointF());
28615 QRect cubicRect = cubicPath.controlPointRect().toRect();
28616 if (cubicRect.isEmpty())
28617 cubicRect.adjust(0, 0, 1, 1);
28618 if (clip.intersects(cubicRect))
28621 painter->drawPath(cubicPath);
28622 painter->setBrush(Qt::SolidPattern);
28624 mTail.
draw(painter, startVec, M_PI-cubicPath.angleAtPercent(0)/180.0*M_PI);
28626 mHead.
draw(painter, endVec, -cubicPath.angleAtPercent(1)/180.0*M_PI);
28668 topRight(
createAnchor(QLatin1String(
"topRight"), aiTopRight)),
28670 bottom(
createAnchor(QLatin1String(
"bottom"), aiBottom)),
28671 bottomLeft(
createAnchor(QLatin1String(
"bottomLeft"), aiBottomLeft)),
28677 setPen(QPen(Qt::black));
28737 bool filledRect =
mBrush.style() != Qt::NoBrush &&
mBrush.color().alpha() != 0;
28746 if (p1.toPoint() == p2.toPoint())
28748 QRectF rect = QRectF(p1, p2).normalized();
28749 double clipPad =
mainPen().widthF();
28750 QRectF boundingRect = rect.adjusted(-clipPad, -clipPad, clipPad, clipPad);
28751 if (boundingRect.intersects(
clipRect()))
28755 painter->drawRect(rect);
28765 case aiTop:
return (rect.topLeft()+rect.topRight())*0.5;
28767 case aiRight:
return (rect.topRight()+rect.bottomRight())*0.5;
28768 case aiBottom:
return (rect.bottomLeft()+rect.bottomRight())*0.5;
28770 case aiLeft:
return (rect.topLeft()+rect.bottomLeft())*0.5;
28773 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
28837 mText(QLatin1String(
"text")),
28838 mPositionAlignment(Qt::AlignCenter),
28839 mTextAlignment(Qt::AlignTop|Qt::AlignHCenter),
29000 QTransform inputTransform;
29001 inputTransform.translate(positionPixels.x(), positionPixels.y());
29003 inputTransform.translate(-positionPixels.x(), -positionPixels.y());
29004 QPointF rotatedPos = inputTransform.map(pos);
29005 QFontMetrics fontMetrics(
mFont);
29006 QRect textRect = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip|
mTextAlignment,
mText);
29009 textBoxRect.moveTopLeft(textPos.toPoint());
29018 QTransform transform = painter->transform();
29019 transform.translate(pos.x(), pos.y());
29023 QRect textRect = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip|
mTextAlignment,
mText);
29026 textRect.moveTopLeft(textPos.toPoint()+QPoint(
mPadding.left(),
mPadding.top()));
29027 textBoxRect.moveTopLeft(textPos.toPoint());
29028 double clipPad =
mainPen().widthF();
29029 QRect boundingRect = textBoxRect.adjusted(-clipPad, -clipPad, clipPad, clipPad);
29030 if (transform.mapRect(boundingRect).intersects(painter->transform().mapRect(
clipRect())))
29032 painter->setTransform(transform);
29038 painter->drawRect(textBoxRect);
29040 painter->setBrush(Qt::NoBrush);
29051 QTransform transform;
29052 transform.translate(pos.x(), pos.y());
29055 QFontMetrics fontMetrics(
mainFont());
29056 QRect textRect = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip|
mTextAlignment,
mText);
29059 textBoxRect.moveTopLeft(textPos.toPoint());
29060 QPolygonF rectPoly = transform.map(QPolygonF(textBoxRect));
29065 case aiTop:
return (rectPoly.at(0)+rectPoly.at(1))*0.5;
29067 case aiRight:
return (rectPoly.at(1)+rectPoly.at(2))*0.5;
29069 case aiBottom:
return (rectPoly.at(2)+rectPoly.at(3))*0.5;
29071 case aiLeft:
return (rectPoly.at(3)+rectPoly.at(0))*0.5;
29074 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
29090 if (positionAlignment == 0 || positionAlignment == (Qt::AlignLeft|Qt::AlignTop))
29093 QPointF result = pos;
29094 if (positionAlignment.testFlag(Qt::AlignHCenter))
29095 result.rx() -= rect.width()/2.0;
29096 else if (positionAlignment.testFlag(Qt::AlignRight))
29097 result.rx() -= rect.width();
29098 if (positionAlignment.testFlag(Qt::AlignVCenter))
29099 result.ry() -= rect.height()/2.0;
29100 else if (positionAlignment.testFlag(Qt::AlignBottom))
29101 result.ry() -= rect.height();
29172 topLeftRim(
createAnchor(QLatin1String(
"topLeftRim"), aiTopLeftRim)),
29174 topRightRim(
createAnchor(QLatin1String(
"topRightRim"), aiTopRightRim)),
29176 bottomRightRim(
createAnchor(QLatin1String(
"bottomRightRim"), aiBottomRightRim)),
29178 bottomLeftRim(
createAnchor(QLatin1String(
"bottomLeftRim"), aiBottomLeftRim)),
29180 center(
createAnchor(QLatin1String(
"center"), aiCenter))
29185 setPen(QPen(Qt::black));
29246 QPointF
center((p1+p2)/2.0);
29247 double a = qAbs(p1.x()-p2.x())/2.0;
29248 double b = qAbs(p1.y()-p2.y())/2.0;
29249 double x = pos.x()-center.x();
29250 double y = pos.y()-center.y();
29253 double c = 1.0/qSqrt(x*x/(a*a)+y*y/(b*b));
29254 double result = qAbs(c-1)*qSqrt(x*x+y*y);
29258 if (x*x/(a*a) + y*y/(b*b) <= 1)
29269 if (p1.toPoint() == p2.toPoint())
29271 QRectF ellipseRect = QRectF(p1, p2).normalized();
29273 if (ellipseRect.intersects(clip))
29277 #ifdef __EXCEPTIONS 29281 painter->drawEllipse(ellipseRect);
29282 #ifdef __EXCEPTIONS 29285 qDebug() << Q_FUNC_INFO <<
"Item too large for memory, setting invisible";
29298 case aiTopLeftRim:
return rect.center()+(rect.topLeft()-rect.center())*1/qSqrt(2);
29299 case aiTop:
return (rect.topLeft()+rect.topRight())*0.5;
29300 case aiTopRightRim:
return rect.center()+(rect.topRight()-rect.center())*1/qSqrt(2);
29301 case aiRight:
return (rect.topRight()+rect.bottomRight())*0.5;
29302 case aiBottomRightRim:
return rect.center()+(rect.bottomRight()-rect.center())*1/qSqrt(2);
29303 case aiBottom:
return (rect.bottomLeft()+rect.bottomRight())*0.5;
29304 case aiBottomLeftRim:
return rect.center()+(rect.bottomLeft()-rect.center())*1/qSqrt(2);
29305 case aiLeft:
return (rect.topLeft()+rect.bottomLeft())*0.5;
29306 case aiCenter:
return (rect.topLeft()+rect.bottomRight())*0.5;
29309 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
29367 topRight(
createAnchor(QLatin1String(
"topRight"), aiTopRight)),
29370 bottomLeft(
createAnchor(QLatin1String(
"bottomLeft"), aiBottomLeft)),
29373 mScaledPixmapInvalidated(true),
29374 mAspectRatioMode(Qt::KeepAspectRatio),
29375 mTransformationMode(Qt::SmoothTransformation)
29396 qDebug() << Q_FUNC_INFO <<
"pixmap is null";
29444 bool flipHorz =
false;
29445 bool flipVert =
false;
29447 double clipPad =
mainPen().style() == Qt::NoPen ? 0 :
mainPen().widthF();
29448 QRect boundingRect = rect.adjusted(-clipPad, -clipPad, clipPad, clipPad);
29449 if (boundingRect.intersects(
clipRect()))
29454 if (pen.style() != Qt::NoPen)
29457 painter->setBrush(Qt::NoBrush);
29458 painter->drawRect(rect);
29472 rect.adjust(rect.width(), 0, -rect.width(), 0);
29474 rect.adjust(0, rect.height(), 0, -rect.height());
29478 case aiTop:
return (rect.topLeft()+rect.topRight())*0.5;
29480 case aiRight:
return (rect.topRight()+rect.bottomRight())*0.5;
29481 case aiBottom:
return (rect.bottomLeft()+rect.bottomRight())*0.5;
29483 case aiLeft:
return (rect.topLeft()+rect.bottomLeft())*0.5;;
29486 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
29510 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 29511 double devicePixelRatio =
mPixmap.devicePixelRatio();
29513 double devicePixelRatio = 1.0;
29515 if (finalRect.isNull())
29520 if (flipHorz || flipVert)
29522 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 29548 bool flipHorz =
false;
29549 bool flipVert =
false;
29553 return QRect(p1, QSize(0, 0));
29556 QSize newSize = QSize(p2.x()-p1.x(), p2.y()-p1.y());
29558 if (newSize.width() < 0)
29561 newSize.rwidth() *= -1;
29562 topLeft.setX(p2.x());
29564 if (newSize.height() < 0)
29567 newSize.rheight() *= -1;
29568 topLeft.setY(p2.y());
29570 QSize scaledSize =
mPixmap.size();
29571 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 29572 scaledSize /=
mPixmap.devicePixelRatio();
29577 result = QRect(topLeft, scaledSize);
29580 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 29583 result = QRect(p1,
mPixmap.size());
29587 *flippedHorz = flipHorz;
29589 *flippedVert = flipVert;
29652 mStyle(tsCrosshair),
29655 mInterpolating(false)
29661 setPen(QPen(Qt::black));
29750 qDebug() << Q_FUNC_INFO <<
"graph isn't in same QCustomPlot instance as this item";
29795 double w =
mSize/2.0;
29802 if (
clipRect().intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29803 return qSqrt(qMin(
QCPVector2D(pos).distanceSquaredToLine(center+QPointF(-w, 0), center+QPointF(w, 0)),
29804 QCPVector2D(pos).distanceSquaredToLine(center+QPointF(0, -w), center+QPointF(0, w))));
29814 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29818 double circleLine = w;
29819 double result = qAbs(centerDist-circleLine);
29823 if (centerDist <= circleLine)
29832 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29834 QRectF rect = QRectF(center-QPointF(w, w), center+QPointF(w, w));
29835 bool filledRect =
mBrush.style() != Qt::NoBrush &&
mBrush.color().alpha() != 0;
29854 double w =
mSize/2.0;
29861 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29863 painter->
drawLine(QLineF(center+QPointF(-w, 0), center+QPointF(w, 0)));
29864 painter->
drawLine(QLineF(center+QPointF(0, -w), center+QPointF(0, w)));
29870 if (center.y() > clip.top() && center.y() < clip.bottom())
29871 painter->
drawLine(QLineF(clip.left(), center.y(), clip.right(), center.y()));
29872 if (center.x() > clip.left() && center.x() < clip.right())
29873 painter->
drawLine(QLineF(center.x(), clip.top(), center.x(), clip.bottom()));
29878 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29879 painter->drawEllipse(center, w, w);
29884 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29885 painter->drawRect(QRectF(center-QPointF(w, w), center+QPointF(w, w)));
29913 if (mGraphKey <= first->key)
29928 if (!qFuzzyCompare((
double)it->key, (
double)prevIt->key))
29929 slope = (it->value-prevIt->value)/(it->key-prevIt->key);
29934 if (
mGraphKey < (prevIt->key+it->key)*0.5)
29947 qDebug() << Q_FUNC_INFO <<
"graph has no data";
29949 qDebug() << Q_FUNC_INFO <<
"graph not contained in QCustomPlot instance (anymore)";
30012 center(
createAnchor(QLatin1String(
"center"), aiCenter)),
30019 setPen(QPen(Qt::black));
30084 if (leftVec.toPoint() == rightVec.toPoint())
30089 QCPVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec;
30099 return qSqrt(qMin(qMin(a, b), c));
30104 double a = p.
distanceSquaredToLine(centerVec-widthVec*0.75+lengthVec*0.15, centerVec+lengthVec*0.3);
30105 double b = p.
distanceSquaredToLine(centerVec-widthVec+lengthVec*0.7, centerVec-widthVec*0.75+lengthVec*0.15);
30106 double c = p.
distanceSquaredToLine(centerVec+widthVec*0.75+lengthVec*0.15, centerVec+lengthVec*0.3);
30107 double d = p.
distanceSquaredToLine(centerVec+widthVec+lengthVec*0.7, centerVec+widthVec*0.75+lengthVec*0.15);
30108 return qSqrt(qMin(qMin(a, b), qMin(c, d)));
30119 if (leftVec.toPoint() == rightVec.toPoint())
30124 QCPVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec;
30126 QPolygon boundingPoly;
30127 boundingPoly << leftVec.
toPoint() << rightVec.toPoint()
30128 << (rightVec-lengthVec).toPoint() << (leftVec-lengthVec).toPoint();
30130 if (clip.intersects(boundingPoly.boundingRect()))
30137 painter->
drawLine((centerVec+widthVec).toPointF(), (centerVec-widthVec).toPointF());
30138 painter->
drawLine((centerVec+widthVec).toPointF(), (centerVec+widthVec+lengthVec).toPointF());
30139 painter->
drawLine((centerVec-widthVec).toPointF(), (centerVec-widthVec+lengthVec).toPointF());
30144 painter->setBrush(Qt::NoBrush);
30146 path.moveTo((centerVec+widthVec+lengthVec).toPointF());
30147 path.cubicTo((centerVec+widthVec).toPointF(), (centerVec+widthVec).toPointF(), centerVec.
toPointF());
30148 path.cubicTo((centerVec-widthVec).toPointF(), (centerVec-widthVec).toPointF(), (centerVec-widthVec+lengthVec).toPointF());
30149 painter->drawPath(path);
30154 painter->setBrush(Qt::NoBrush);
30156 path.moveTo((centerVec+widthVec+lengthVec).toPointF());
30157 path.cubicTo((centerVec+widthVec-lengthVec*0.8).toPointF(), (centerVec+0.4*widthVec+lengthVec).toPointF(), centerVec.
toPointF());
30158 path.cubicTo((centerVec-0.4*widthVec+lengthVec).toPointF(), (centerVec-widthVec-lengthVec*0.8).toPointF(), (centerVec-widthVec+lengthVec).toPointF());
30159 painter->drawPath(path);
30164 painter->
setPen(Qt::NoPen);
30165 painter->setBrush(QBrush(
mainPen().color()));
30167 path.moveTo((centerVec+widthVec+lengthVec).toPointF());
30169 path.cubicTo((centerVec+widthVec-lengthVec*0.8).toPointF(), (centerVec+0.4*widthVec+0.8*lengthVec).toPointF(), centerVec.
toPointF());
30170 path.cubicTo((centerVec-0.4*widthVec+0.8*lengthVec).toPointF(), (centerVec-widthVec-lengthVec*0.8).toPointF(), (centerVec-widthVec+lengthVec).toPointF());
30172 path.cubicTo((centerVec-widthVec-lengthVec*0.5).toPointF(), (centerVec-0.2*widthVec+1.2*lengthVec).toPointF(), (centerVec+lengthVec*0.2).toPointF());
30173 path.cubicTo((centerVec+0.2*widthVec+1.2*lengthVec).toPointF(), (centerVec+widthVec-lengthVec*0.5).toPointF(), (centerVec+widthVec+lengthVec).toPointF());
30175 painter->drawPath(path);
30187 if (leftVec.toPoint() == rightVec.toPoint())
30192 QCPVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec;
30199 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
void setTickLabels(bool show)
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
SelectablePart getPartAt(const QPointF &pos) const
QFont mSelectedTickLabelFont
void setSelectedBrush(const QBrush &brush)
void drawBackground(QCPPainter *painter)
bool addLayer(const QString &name, QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove)
virtual QSize minimumOuterSizeHint() const
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
BracketStyle mBracketStyle
QList< QCPAbstractPlottable * > selectedPlottables() const
QCPItemAnchor *const right
int iconTextPadding() const
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)
bool mAntialiasedScatters
QCPGrid(QCPAxis *parentAxis)
void setBrush(const QBrush &brush)
void setBrush(const QBrush &brush)
double cleanMantissa(double input) const
QCPLineEnding tail() const
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
Qt::TransformationMode transformationMode() const
void setChannelFillGraph(QCPGraph *targetGraph)
double pointDistance(const QPointF &pixelPoint, QCPCurveDataContainer::const_iterator &closestData) const
void setWhiskerWidth(double pixels)
void drawSubGridLines(QCPPainter *painter) const
virtual int commonMargin(QCP::MarginSide side) const
virtual bool sortKeyIsMainKey() const Q_DECL_OVERRIDE
The base class tick generator used by QCPAxis to create tick positions and tick labels.
QCustomPlot * parentPlot() const
0x001 Axis ranges are draggable (see QCPAxisRect::setRangeDrag, QCPAxisRect::setRangeDragAxes) ...
QCPItemPosition *const position
QList< QCPGraph * > graphs() const
void setWidth(double width)
virtual QRect clipRect() const Q_DECL_OVERRIDE
void coordToCell(double key, double value, int *keyIndex, int *valueIndex) const
QCPItemPosition *const start
QCPLayer * currentLayer() const
QList< QCPAbstractPlottable * > plottables() const
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
Manages the position of an item.
QColor mSelectedLabelColor
void enforceType(QCP::SelectionType type)
QCPVector2D & operator/=(double divisor)
QCP::AntialiasedElements antialiasedElements() const
bool mNumberBeautifulPowers
void setBrush(const QBrush &brush)
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE
void insertColumn(int newIndex)
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const
QCPDataSelection & operator-=(const QCPDataSelection &other)
QCPLayoutElement(QCustomPlot *parentPlot=0)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QCPItemEllipse(QCustomPlot *parentPlot)
bool removeGraph(QCPGraph *graph)
QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis)
QPen getSubTickPen() const
QCPItemAnchor *const left
void setTickLabelFont(const QFont &font)
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
void setTimeFormat(const QString &format)
void setSelectedPen(const QPen &pen)
bool setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false)
Q_SLOT void setSelected(bool selected)
Fractions are written as rationals using ASCII characters only, e.g. "1/4" or "1/8".
0x04 Turns pen widths 0 to 1, i.e. disables cosmetic pens. (A cosmetic pen is always drawn with width...
Colors suitable for thermal imaging, ranging from dark blue over purple to orange, yellow and white.
0x0200 Zero-lines, see QCPGrid::setZeroLinePen
void setNumberPrecision(int precision)
static QSize getFinalMinimumOuterSize(const QCPLayoutElement *el)
QColor mSelectedTextColor
QPointer< QCPAxis > mKeyAxis
QCPLayoutInset * mInsetLayout
QVector< QPointF > dataToStepCenterLines(const QVector< QCPGraphData > &data) const
QList< QSharedPointer< QCPAbstractPaintBuffer > > mPaintBuffers
QCPLineEnding lowerEnding
Milliseconds, one thousandth of a second (%z in setTimeFormat)
void dataRangeChanged(const QCPRange &newRange)
int axisCount(QCPAxis::AxisType type) const
void setName(const QString &name)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setBracketBrush(const QBrush &brush)
void removeChild(QCPLayerable *layerable)
QCPBarsGroup * mBarsGroup
QCPItemPosition *const topLeft
void setPlottingHints(const QCP::PlottingHints &hints)
int dataRangeCount() const
Q_SLOT void setDataRange(const QCPRange &dataRange)
void moveRange(double diff)
void setLabel(const QString &str)
QSize maximumSize() const
void releaseElement(QCPLayoutElement *el)
void setSymbolGap(double pixels)
void removeChildY(QCPItemPosition *pos)
void setPixmap(const QPixmap &pixmap)
Any combination of data points/ranges can be selected.
void setAntialiasedZeroLine(bool enabled)
bool errorBarVisible(int index) const
QCPAxisRect * clipAxisRect() const
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
The abstract base class for layouts.
QRectF getBarRect(double key, double value) const
Resolution is given in dots per inch (DPI/PPI)
void setType(QCPAxis::AxisType type)
bool realVisibility() const
void drawOhlcPlot(QCPPainter *painter, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, bool isSelected)
Logarithmic scaling with correspondingly transformed axis coordinates (possibly also setTicker to a Q...
QList< QCPAxis * > rangeDragAxes(Qt::Orientation orientation)
void selectionChanged(bool selected)
QList< QCPRange > mDragStartHorzRange
Q_SLOT void setSelectableParts(const SelectableParts &selectableParts)
bool segmentsIntersect(double aLower, double aUpper, double bLower, double bUpper, int &bPrecedence) const
void selectionChanged(bool selected)
bool removeItem(QCPAbstractItem *item)
void setLabelFont(const QFont &font)
QCPColorScale * mParentColorScale
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
void setLabel(const QString &str)
QCPColorGradient gradient() const
void setKeyAxis(QCPAxis *axis)
QPointer< QCPGraph > mChannelFillGraph
void setSelectedColor(const QColor &color)
void setColorStops(const QMap< double, QColor > &colorStops)
void setPen(const QPen &pen)
QCPLayerable * parentLayerable() const
Cosmetic pens are converted to pens with pixel width 1 when exporting.
void setPen(const QPen &pen)
QRectF getQuartileBox(QCPStatisticalBoxDataContainer::const_iterator it) const
void setFont(const QFont &font)
line is drawn as steps where the step is in between two data points
PainterModes modes() const
void setSelectedTickLabelColor(const QColor &color)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
SizeConstraintRect sizeConstraintRect() const
bool removeItem(int index)
Qt::Alignment positionAlignment() const
QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes=true)
void setPeriodicity(int multiplesOfPi)
QColor getTextColor() const
virtual QVector< double > createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE
QVector< int > getSectionSizes(QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
void setScatterSkip(int skip)
QList< QCPDataRange > dataRanges() const
void setWidthType(WidthType widthType)
void setRangeDrag(Qt::Orientations orientations)
bool clipToAxisRect() const
virtual QList< QCPLayoutElement * > elements(bool recursive) const
QCPLineEnding upperEnding
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)
ScaleType scaleType() const
QCPLayoutGrid * mPlotLayout
void setClipToAxisRect(bool clip)
QVector< QPointF > dataToStepLeftLines(const QVector< QCPGraphData > &data) const
void setValueRange(const QCPRange &valueRange)
virtual void mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
void setPen(const QPen &pen)
Q_SLOT void updateLegendIcon(Qt::TransformationMode transformMode=Qt::SmoothTransformation, const QSize &thumbSize=QSize(32, 18))
void setSelectedPen(const QPen &pen)
virtual double dataMainValue(int index) const =0
QList< QPointer< QCPAxis > > mRangeZoomHorzAxis
QCPMarginGroup(QCustomPlot *parentPlot)
Q_SLOT void axisSelectableChanged(QCPAxis::SelectableParts selectableParts)
double distanceToStraightLine(const QCPVector2D &base, const QCPVector2D &direction) const
Controls how a plottable's data selection is drawn.
void setTightBoundary(bool enabled)
QColor mainTextColor() const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
const QPolygonF getChannelFillPolygon(const QVector< QPointF > *lineData, QCPDataRange thisSegment, const QVector< QPointF > *otherData, QCPDataRange otherSegment) const
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
void setBrush(const QBrush &brush)
each data point is represented by a line parallel to the value axis, which reaches from the data poin...
Rows are filled first, and a new element is wrapped to the next column if the row count would exceed ...
Represents the range an axis is encompassing.
virtual QCPItemPosition * toQCPItemPosition()
virtual void deselectEvent(bool *selectionStateChanged)
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
void setRangeUpper(double upper)
QRect axisSelectionBox() const
Candlestick representation.
void setTangentToData(bool enabled)
Hours (%h in setTimeFormat)
QCPLayoutElement * element(int row, int column) const
QLineF getRectClippedStraightLine(const QCPVector2D &point1, const QCPVector2D &vec, const QRect &rect) const
custom painter operations are performed per scatter (As QPainterPath, see setCustomPath) ...
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
bool antialiasing() const
void rescale(bool onlyVisiblePlottables=false)
Continuous lightness from black over icey colors to white (suited for non-biased data representation)...
QRect getFinalRect(bool *flippedHorz=0, bool *flippedVert=0) const
void setSelectedBorderPen(const QPen &pen)
virtual QVector< double > createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE
Queues the entire replot for the next event loop iteration. This way multiple redundant replots can b...
void recalculateDataBounds()
A plus shaped crosshair which spans the complete axis rect.
void setPen(const QPen &pen)
void mouseDoubleClick(QMouseEvent *event)
void setBracketPen(const QPen &pen)
virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE
void setNoAntialiasingOnDrag(bool enabled)
void setTickOrigin(double origin)
std::vector< double > values
virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
void setInteractions(const QCP::Interactions &interactions)
void updateGradientImage()
void setDateTimeFormat(const QString &format)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
QCPAxis::ScaleType mDataScaleType
void setTickLengthIn(int inside)
QCPAxis * valueAxis() const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
void setFromOther(const QCPScatterStyle &other, ScatterProperties properties)
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details)
void setData(QSharedPointer< QCPCurveDataContainer > data)
QCPAxisPainterPrivate(QCustomPlot *parentPlot)
QPointer< QCPAxisRect > mClipAxisRect
0x08 The shape property, see setShape
void setMinimumMargins(const QMargins &margins)
virtual double dataMainValue(int index) const Q_DECL_OVERRIDE
QCPDataSelection & operator+=(const QCPDataSelection &other)
Q_SLOT void setGradient(const QCPColorGradient &gradient)
QFont getLabelFont() const
void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical)
QWeakPointer< QCPAbstractPaintBuffer > mPaintBuffer
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=0
QCustomPlot * mParentPlot
void setRangeDrag(bool enabled)
Holds the data of one single data point for QCPCurve.
void setSubTickLengthIn(int inside)
QVector< QLineF > getWhiskerBarLines(QCPStatisticalBoxDataContainer::const_iterator it) const
QPen getBorderPen() const
Columns are filled first, and a new element is wrapped to the next row if the column count would exce...
QString unicodeSubscript(int number) const
QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis)
QVector< QPair< QCPDataRange, QCPDataRange > > getOverlappingSegments(QVector< QCPDataRange > thisSegments, const QVector< QPointF > *thisData, QVector< QCPDataRange > otherSegments, const QVector< QPointF > *otherData) const
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QCP::AntialiasedElements mAADragBackup
QPointF getFillBasePoint(QPointF matchingDataPoint) const
QCPItemPosition *const end
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
QCPItemPosition *const bottomRight
void setUsedScatterProperties(const QCPScatterStyle::ScatterProperties &properties)
0x004 axis (tick) labels will be cached as pixmaps, increasing replot performance.
QCPScatterStyle outlierStyle() const
{ssPlusSquare.png} a square with a plus inside
Qt::Alignment mTextAlignment
void setBrush(const QBrush &brush)
int findIndexAboveY(const QVector< QPointF > *data, double y) const
Q_SLOT void setSelectable(bool selectable)
ScatterShape shape() const
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
void setRowSpacing(int pixels)
QSet< QCPItemPosition * > mChildrenY
Bar width is given by a fraction of the axis rect size.
QPointer< QCPAxis > mValueAxis
QCustomPlot * mParentPlot
void setColumnStretchFactor(int column, double factor)
QVector< DataType >::const_iterator const_iterator
void setBrush(const QBrush &brush)
QCPItemBracket(QCustomPlot *parentPlot)
void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio, Qt::TransformationMode transformationMode=Qt::SmoothTransformation)
QCPBarsGroup * barsGroup() const
Holds the data of one single data point (one bar) for QCPBars.
virtual ~QCPMarginGroup()
Provides rect/rubber-band data selection and range zoom interaction.
bool removePlottable(QCPAbstractPlottable *plottable)
QPointF getOptimizedPoint(int prevRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const
bool removeLayer(QCPLayer *layer)
Full hue cycle, with highest and lowest color red (suitable for periodic data, such as angles and pha...
QCPTextElement(QCustomPlot *parentPlot)
virtual void axisRemoved(QCPAxis *axis)
Layer has its own paint buffer and may be replotted individually (see replot).
QSharedPointer< QCPErrorBarsDataContainer > data() const
bool moveLayer(QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove)
QList< QCPAxis * > rangeZoomAxes(Qt::Orientation orientation)
QSet< QCPItemPosition * > mChildrenX
SpacingType spacingType() const
void setFieldWidth(TimeUnit unit, int width)
void setSelectedFont(const QFont &font)
virtual QCPRange dataValueRange(int index) const Q_DECL_OVERRIDE
ScaleStrategy mScaleStrategy
QList< QCPLegend * > selectedLegends() const
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
QPointer< QCPColorScale > mColorScale
QCP::AntialiasedElements mAADragBackup
void setScatterSkip(int skip)
0x02 The brush property, see setBrush
QCPAbstractPlottable * mPlottable
void setTextAlignment(Qt::Alignment alignment)
void setSelectedTextColor(const QColor &color)
QCPScatterStyle::ScatterProperties mUsedScatterProperties
virtual QCP::Interaction selectionCategory() const
virtual void updateLayout()
Half hue spectrum from black over purple to blue and finally green (creates banding illusion but allo...
0x00 Default mode for painting on screen devices
QList< QCPDataRange > mDataRanges
Represents the visual appearance of scatter points.
The axis backbone and tick marks.
QPainterPath customPath() const
QCPRange sanitizedForLogScale() const
QList< QCPRange > mDragStartVertRange
An ellipse is drawn. The size of the ellipse is given by the bracket width/height properties...
no scatter symbols are drawn (e.g. in QCPGraph, data only represented with lines) ...
void setRangeReversed(bool reversed)
QCPLayoutElement * layoutElementAt(const QPointF &pos) const
virtual void updateLayout() Q_DECL_OVERRIDE
IMETHOD Vector diff(const Vector &p_w_a, const Vector &p_w_b, double dt=1)
QSharedPointer< QCPAxisTicker > ticker() const
virtual ~QCPAbstractPaintBuffer()
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
Q_SLOT void setGradient(const QCPColorGradient &gradient)
Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpRefreshHint)
void toPainter(QCPPainter *painter, int width=0, int height=0)
void setTickCount(int count)
QVariant mMouseSignalLayerableDetails
double ohlcSelectTest(const QPointF &pos, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, QCPFinancialDataContainer::const_iterator &closestDataPoint) const
QByteArray mLabelParameterHash
void drawBackground(QCPPainter *painter)
void setTickLengthOut(int outside)
void setSelectedPen(const QPen &pen)
QCPMarginGroup * marginGroup(QCP::MarginSide side) const
virtual bool take(QCPLayoutElement *element) Q_DECL_OVERRIDE
virtual QCPLayoutElement * elementAt(int index) const Q_DECL_OVERRIDE
QColor mSelectedTickLabelColor
QCPAbstractPlottable * plottableAt(const QPointF &pos, bool onlySelectable=false) const
bool stopsUseAlpha() const
QCPSelectionDecorator * mSelectionDecorator
QList< QCPGraph * > mGraphs
virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Defines an abstract interface for one-dimensional plottables.
void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
void setMaximumSize(const QSize &size)
virtual QSize maximumOuterSizeHint() const Q_DECL_OVERRIDE
QList< QCPAbstractPlottable * > plottables() const
void applyScattersAntialiasingHint(QCPPainter *painter) const
bool registerGraph(QCPGraph *graph)
bool abbreviateDecimalPowers
int getRegion(double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const
QCPItemPosition *const topLeft
QCPAxisRect * axisRectAt(const QPointF &pos) const
QCPAxis * axis(QCPAxis::AxisType type, int index=0) const
QCPLegend * mParentLegend
void getVisibleDataBounds(QCPFinancialDataContainer::const_iterator &begin, QCPFinancialDataContainer::const_iterator &end) const
virtual int getSubTickCount(double tickStep)
double pointDistance(const QPointF &pixelPoint, QCPErrorBarsDataContainer::const_iterator &closestData) const
Replots immediately, but queues the widget repaint, by calling QWidget::update() after the replot...
virtual void draw(QCPPainter *painter)
void setKeySize(int keySize)
0x0020 Main lines of plottables
virtual QList< QCPLayoutElement * > elements(bool recursive) const Q_DECL_OVERRIDE
virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE
QCPLayoutInset * insetLayout() const
QCPRange keyRange() const
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
A square bracket is drawn.
Colors suitable to represent different elevations on geographical maps.
friend class QCPPlottableLegendItem
QCPFinancial(QCPAxis *keyAxis, QCPAxis *valueAxis)
Fractions are displayed as regular decimal floating point numbers, e.g. "0.25" or "0...
void getCurveLines(QVector< QPointF > *lines, const QCPDataRange &dataRange, double penWidth) const
void updateScaledPixmap(QRect finalRect=QRect(), bool flipHorz=false, bool flipVert=false)
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
virtual QByteArray generateLabelParameterHash() const
QList< QPointer< QCPAxis > > mRangeZoomVertAxis
unsigned char alpha(int keyIndex, int valueIndex)
void setSelectedFont(const QFont &font)
QHash< QCP::MarginSide, QCPMarginGroup * > mMarginGroups
void colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false)
static AxisType marginSideToAxisType(QCP::MarginSide side)
QRectF selectionHitBox(QCPFinancialDataContainer::const_iterator it) const
QSharedPointer< QCPStatisticalBoxDataContainer > data() const
virtual int dataCount() const Q_DECL_OVERRIDE
QCPSelectionRect(QCustomPlot *parentPlot)
virtual QVector< QString > createLabelVector(const QVector< double > &ticks, const QLocale &locale, QChar formatChar, int precision)
QCP::AntialiasedElements mNotAADragBackup
enum QCPAxisTickerDateTime::DateStrategy mDateStrategy
QPointer< QCPAbstractPlottable > mDataPlottable
void setBufferDevicePixelRatio(double ratio)
void setInsetPlacement(int index, InsetPlacement placement)
void zoom(const QRectF &pixelRect)
void setInterpolating(bool enabled)
bool contains(const QCPDataSelection &other) const
virtual double dataMainKey(int index) const Q_DECL_OVERRIDE
void drawPolyline(QCPPainter *painter, const QVector< QPointF > &lineData) const
void selectableChanged(const QCPAxis::SelectableParts &parts)
QCPItemText(QCustomPlot *parentPlot)
When dragging the mouse, a selection rect becomes active. Upon releasing, the axes that are currently...
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
void setInsetRect(int index, const QRectF &rect)
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
bool registerPlottable(QCPAbstractPlottable *plottable)
Replots immediately and repaints the widget immediately by calling QWidget::repaint() after the replo...
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QMap< double, QString > & ticks()
virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE
Q_SLOT void setSelection(QCPDataSelection selection)
QCP::MarginSides mAutoMargins
QList< QCPItemPosition * > mPositions
QCPItemAnchor * parentAnchorX() const
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
AxisType axisType() const
double pointDistance(const QPointF &pixelPoint, QCPGraphDataContainer::const_iterator &closestData) const
bool addElement(int row, int column, QCPLayoutElement *element)
void setData(QSharedPointer< QCPBarsDataContainer > data)
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE
virtual ~QCPItemStraightLine()
QList< QCPAbstractItem * > items() const
QCPItemAnchor * parentAnchorY() const
Q_SLOT void setRange(const QCPRange &range)
static QCPFinancialDataContainer timeSeriesToOhlc(const QVector< double > &time, const QVector< double > &value, double timeBinSize, double timeBinOffset=0)
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
QCPAxis::ScaleType mDataScaleType
A brace with angled edges.
QPixmap mBackgroundPixmap
void setSelectedTextColor(const QColor &color)
A layer that may contain objects, to control the rendering order.
QPointer< QCPColorScaleAxisRectPrivate > mAxisRect
void mousePress(QMouseEvent *event)
void setSize(double size)
void setPen(const QPen &pen)
QCPItemPosition *const point2
QVariant mMouseEventLayerableDetails
0x02 Mode for all sorts of exports (e.g. PNG, PDF,...). For example, this prevents using cached pixma...
double lengthSquared() const
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
0x02 Axis is vertical and on the right side of the axis rect
void setMode(PainterMode mode, bool enabled=true)
virtual void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE
void setInverted(bool inverted)
static bool validRange(double lower, double upper)
Handles the different ending decorations for line-like items.
double pixelToCoord(double value) const
A filled arrow head with a straight/flat back (a triangle)
bool mayTraverse(int prevRegion, int currentRegion) const
QCustomPlot * mParentPlot
virtual void drawScatterPlot(QCPPainter *painter, const QVector< QPointF > &scatters, const QCPScatterStyle &style) const
width is given by a fraction of the axis rect size
bool mGradientImageInvalidated
The positive sign domain, i.e. numbers greater than zero.
void setColorScale(QCPColorScale *colorScale)
virtual QCPLayoutElement * elementAt(int index) const Q_DECL_OVERRIDE
Responsible for drawing the grid of a QCPAxis.
void applyBrush(QCPPainter *painter) const
virtual QSize sizeHint() const Q_DECL_OVERRIDE
void setDevicePixelRatio(double ratio)
Describes a data set by holding multiple QCPDataRange instances.
QCP::SelectionType mSelectable
virtual int calculateAutoMargin(QCP::MarginSide side)
QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis)
No line is drawn between data points (e.g. only scatters)
geometry_msgs::TransformStamped t
Q_SLOT void setDataRange(const QCPRange &dataRange)
0x004 The user can select multiple objects by holding the modifier set by QCustomPlot::setMultiSelect...
static void connectBars(QCPBars *lower, QCPBars *upper)
bool createAlpha(bool initializeOpaque=true)
void itemClick(QCPAbstractItem *item, QMouseEvent *event)
void selectionChangedByUser()
void setBrush(const QBrush &brush)
virtual void parentPlotInitialized(QCustomPlot *parentPlot)
void expand(const QCPRange &otherRange)
void setMode(LayerMode mode)
double distanceSquaredToLine(const QCPVector2D &start, const QCPVector2D &end) const
void layerChanged(QCPLayer *newLayer)
void setBackgroundScaled(bool scaled)
TracerStyle style() const
void setBarsGroup(QCPBarsGroup *barsGroup)
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
bool addItem(QCPAbstractLegendItem *item)
virtual void keyPressEvent(QKeyEvent *event)
void setIconTextPadding(int padding)
{ssCrossSquare.png} a square with a cross inside
void setBrushNegative(const QBrush &brush)
QCPItemRect(QCustomPlot *parentPlot)
void fillAlpha(unsigned char alpha)
void moveAbove(QCPBars *bars)
QList< QCPLayerable * > mChildren
void setTickLabelPadding(int padding)
virtual void updateMapImage()
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
Continuous lightness from black over firey colors to white (suited for non-biased data representation...
QCPDataRange adjusted(int changeBegin, int changeEnd) const
QCPColorGradient mGradient
virtual void moveSelection(QMouseEvent *event)
QSharedPointer< QCPBarsDataContainer > data() const
virtual int dataCount() const Q_DECL_OVERRIDE
void setWhiskerPen(const QPen &pen)
0x08 Axis is horizontal and on the bottom side of the axis rect
QCustomPlot * mParentPlot
void gradientChanged(const QCPColorGradient &newGradient)
0x020 Legends are selectable (or their child items, see QCPLegend::setSelectableParts) ...
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const =0
Q_SLOT bool setLayer(QCPLayer *layer)
Qt::TransformationMode mTransformationMode
void setCustomPath(const QPainterPath &customPath)
QCache< QString, CachedLabel > mLabelCache
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void getLines(QVector< QPointF > *lines, const QCPDataRange &dataRange) const
Defines a color gradient for use with e.g. QCPColorMap.
void rangeChanged(const QCPRange &newRange)
Q_SLOT void setSelectedParts(const SelectableParts &selectedParts)
void setInterpolate(bool enabled)
void getPixelWidth(double key, double &lower, double &upper) const
QSharedPointer< QCPCurveDataContainer > data() const
QCPItemPosition *const right
virtual void legendRemoved(QCPLegend *legend)
void setAdaptiveSampling(bool enabled)
QCPItemAnchor *const bottom
QCPRange expanded(const QCPRange &otherRange) const
A half ellipse is drawn. The size of the ellipse is given by the bracket width/height properties...
QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name, int anchorId=-1)
QList< QCPBars * > bars() const
QVector< QCPDataRange > getNonNanSegments(const QVector< QPointF > *lineData, Qt::Orientation keyOrientation) const
void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group)
void updateLayerIndices() const
InsetPlacement insetPlacement(int index) const
width is in key coordinates and thus scales with the key axis range
QCPDataRange intersection(const QCPDataRange &other) const
Q_SLOT void setSelectable(QCP::SelectionType selectable)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const
Q_SLOT void deselectAll()
virtual void parentPlotInitialized(QCustomPlot *parentPlot) Q_DECL_OVERRIDE
QCPItemPosition *const bottomRight
virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
{ssStar.png} a star with eight arms, i.e. a combination of cross and plus
QCPColorScale(QCustomPlot *parentPlot)
void setTangentAverage(int pointCount)
void setSelectedFont(const QFont &font)
QRgb color(double position, const QCPRange &range, bool logarithmic=false)
void setStyle(BracketStyle style)
void setPositionAlignment(Qt::Alignment alignment)
int numberPrecision() const
QFont getTickLabelFont() const
QCPRange dataRange() const
void setBackground(const QPixmap &pm)
Holds the data of one single data point for QCPStatisticalBox.
QCPAxis * addAxis(QCPAxis::AxisType type, QCPAxis *axis=0)
Phase in which the margins are calculated and set.
bool intersects(const QCPDataRange &other) const
void setRangeLower(double lower)
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
void setAntialiasedSubGrid(bool enabled)
Less readable tick steps are allowed which in turn facilitates getting closer to the requested tick c...
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
virtual ~QCPSelectionDecoratorBracket()
QVector< QPointF > dataToLines(const QVector< QCPGraphData > &data) const
QLatin1Char mNumberFormatChar
QCP::AntialiasedElements notAntialiasedElements() const
QCPAxisPainterPrivate * mAxisPainter
void setPlottingHint(QCP::PlottingHint hint, bool enabled=true)
void setIconBorderPen(const QPen &pen)
void unregisterBars(QCPBars *bars)
virtual void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
void setTextColor(const QColor &color)
QCP::AntialiasedElements mNotAntialiasedElements
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void loadPreset(GradientPreset preset)
The central class of the library. This is the QWidget which displays the plot and interacts with the ...
virtual void reallocateBuffer() Q_DECL_OVERRIDE
virtual void mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details)
A bar perpendicular to the line.
bool mAntialiasedZeroLine
Qt::AspectRatioMode mBackgroundScaledMode
QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange)
QCPAxis::AxisType type() const
One individual data point can be selected at a time.
virtual ~QCPSelectionDecorator()
a custom pixmap specified by setPixmap, centered on the data point coordinates
void getMaximumRowColSizes(QVector< int > *maxColWidths, QVector< int > *maxRowHeights) const
QCPScatterStyle scatterStyle() const
void setBarWidth(int width)
QVector< QPointF > getOptimizedCornerPoints(int prevRegion, int currentRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const
Q_SLOT void setScaleType(QCPAxis::ScaleType type)
double mRangeZoomFactorVert
QCPLayerable * layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=0) const
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QPixmap mScaledBackgroundPixmap
void setBasePen(const QPen &pen)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
QCPVector2D perpendicular() const
Qt::AspectRatioMode aspectRatioMode() const
QCPItemPosition *const left
LabelSide tickLabelSide() const
QCPItemPosition *const startDir
void setWidth(double width)
QPointer< QCPLayerable > mParentLayerable
Continuous lightness from black over weak blueish colors to white (suited for non-biased data represe...
QCPItemPosition *const topLeft
void setSelectedLabelColor(const QColor &color)
void setSelectedPen(const QPen &pen)
QPointer< QCPAxisRect > mAxisRect
void setPen(const QPen &pen)
void setStyle(TracerStyle style)
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)
0x04 The size property, see setSize
The errors are for the key dimension (bars appear parallel to the key axis)
void axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
Represents two doubles as a mathematical 2D vector.
void setAxes(QCPAxis *keyAxis, QCPAxis *valueAxis)
QCPDataSelection inverse(const QCPDataRange &outerRange) const
void drawShape(QCPPainter *painter, const QPointF &pos) const
bool hasInvalidatedPaintBuffers()
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
QCPRange dataRange() const
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
Qt::Orientations rangeDrag() const
virtual void startSelection(QMouseEvent *event)
void dataRangeChanged(const QCPRange &newRange)
Layer is used only for rendering order, and shares paint buffer with all other adjacent logical layer...
Layer is inserted above other layer.
QCPItemPosition *const bottomRight
int getMarginValue(const QMargins &margins, QCP::MarginSide side)
virtual void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE
void setSubTickPen(const QPen &pen)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
void drawGridLines(QCPPainter *painter) const
The generic data container for one-dimensional plottables.
Manages a legend inside a QCustomPlot.
QPen getIconBorderPen() const
double mBufferDevicePixelRatio
virtual QCPLayoutElement * takeAt(int index) Q_DECL_OVERRIDE
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
void setColor(const QColor &color)
void setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, bool enabled=true)
virtual int dataCount() const =0
void setTypeY(PositionType type)
void setSubTickCount(int subTicks)
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
line is drawn as steps where the step height is the value of the left data point
void setAlpha(int keyIndex, int valueIndex, unsigned char alpha)
void dataScaleTypeChanged(QCPAxis::ScaleType scaleType)
QCPItemAnchor *const bottomRight
QCPColorScale * colorScale() const
virtual int elementCount() const Q_DECL_OVERRIDE
void setMarginValue(QMargins &margins, QCP::MarginSide side, int value)
void adoptElement(QCPLayoutElement *el)
QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlottable *plottable)
void setupFullAxesBox(bool connectRanges=false)
QPointer< QCPBars > mBarBelow
QSharedPointer< QCPFinancialDataContainer > data() const
A nicely readable tick step is prioritized over matching the requested number of ticks (see setTickCo...
Qt::Orientations rangeZoom() const
void setAntialiased(bool enabled)
QPixmap mScaledBackgroundPixmap
void setSelectedPen(const QPen &pen)
static QSize getFinalMaximumOuterSize(const QCPLayoutElement *el)
SelectableParts selectableParts() const
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
QCPDataRange bounded(const QCPDataRange &other) const
void setBrush(const QBrush &brush)
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
The selection rect is disabled, and all mouse events are forwarded to the underlying objects...
void setValueAxis(QCPAxis *axis)
static AxisType opposite(AxisType type)
void setPen(const QPen &pen)
QCPAbstractPlottable * plottable()
void itemDoubleClick(QCPAbstractItem *item, QMouseEvent *event)
void addData(const QVector< double > &error)
void setMultiSelectModifier(Qt::KeyboardModifier modifier)
void setBrushPositive(const QBrush &brush)
double boundingDistance() const
QList< double > mRowStretchFactors
void setSelectedFont(const QFont &font)
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
A layout that arranges child elements in a grid.
virtual QVector< double > createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE
virtual TickLabelData getTickLabelData(const QFont &font, const QString &text) const
void clicked(QMouseEvent *event)
void setPen(const QPen &pen)
void setBaseValue(double baseValue)
QCPAbstractPlottable * mPlottable
void setAutoMargins(QCP::MarginSides sides)
void dataScaleTypeChanged(QCPAxis::ScaleType scaleType)
0x04 Axis is horizontal and on the top side of the axis rect
Qt::Orientation orientation() const
virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE
void simplifyFraction(int &numerator, int &denominator) const
QPainter subclass used internally.
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE
The abstract base class for all objects that form the layout system.
QCPItemPosition * position(const QString &name) const
void setScatterStyle(const QCPScatterStyle &style)
bool savePdf(const QString &fileName, int width=0, int height=0, QCP::ExportPen exportPen=QCP::epAllowCosmetic, const QString &pdfCreator=QString(), const QString &pdfTitle=QString())
Tick labels (numbers) of this axis (as a whole, not individually)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
Holds the data of one single data point for QCPGraph.
QList< QCPAbstractItem * > selectedItems() const
double getMantissa(double input, double *magnitude=0) const
EndingStyle style() const
QCPAxis * keyAxis() const
virtual void copyFrom(const QCPSelectionDecorator *other)
void addChildY(QCPItemPosition *pos)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
QCPVector2D & operator-=(const QCPVector2D &vector)
int tickLabelPadding() const
QList< QCPAbstractPlottable * > mPlottables
void setSizeConstraintRect(SizeConstraintRect constraintRect)
QVector< QPointF > dataToImpulseLines(const QVector< QCPGraphData > &data) const
double rangeZoomFactor(Qt::Orientation orientation)
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos)
QCPAbstractPlottable * plottable(int index)
Multiple contiguous data points (a data range) can be selected.
Holds multiple axes and arranges them in a rectangular shape.
void setTail(const QCPLineEnding &tail)
bool registerItem(QCPAbstractItem *item)
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
int plottableCount() const
void setPen(const QPen &pen)
void setInvalidated(bool invalidated=true)
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
void setPiValue(double pi)
void rescaleKeyAxis(bool onlyEnlarge=false) const
void setType(PositionType type)
double getPixelSpacing(const QCPBars *bars, double keyCoord)
bool mColorBufferInvalidated
virtual QRect clipRect() const Q_DECL_OVERRIDE
void setColorStopAt(double position, const QColor &color)
double candlestickSelectTest(const QPointF &pos, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, QCPFinancialDataContainer::const_iterator &closestDataPoint) const
void addData(const QVector< double > &t, const QVector< double > &keys, const QVector< double > &values, bool alreadySorted=false)
virtual int findEnd(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE
Hue variation similar to a spectrum, often used in numerical visualization (creates banding illusion ...
bool contains(const QCPDataRange &other) const
void setSubTickCount(int subTicks)
Both sign domains, including zero, i.e. all numbers.
void applyPen(QCPPainter *painter) const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
QCPLineEnding upperEnding() const
void setSize(double size)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE=0
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
void setTickLabelSide(LabelSide side)
Bar spacing is in absolute pixels.
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
void setClipAxisRect(QCPAxisRect *rect)
void sizeConstraintsChanged() const
double rectDistance(const QRectF &rect, const QPointF &pos, bool filledRect) const
virtual Q_SLOT void processRectSelection(QRect rect, QMouseEvent *event)
virtual void layoutChanged() Q_DECL_OVERRIDE
QString unicodeFraction(int numerator, int denominator) const
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
A color scale for use with color coding data such as QCPColorMap.
QPointer< QCPLayerable > mMouseSignalLayerable
QMap< double, QColor > mColorStops
Color channels hue, saturation and value are linearly interpolated (The hue is interpolated over the ...
Open-High-Low-Close bar representation.
void removeChild(QCP::MarginSide side, QCPLayoutElement *element)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
QCPLineEnding head() const
void pixelsToCoords(double x, double y, double &key, double &value) const
0x010 Axes are selectable (or parts of them, see QCPAxis::setSelectableParts)
void remove(QCPBars *bars)
QCP::AntialiasedElements mAntialiasedElements
Groups multiple QCPBars together so they appear side by side.
QCPLineEnding head() const
virtual bool take(QCPLayoutElement *element) Q_DECL_OVERRIDE
Qt::Alignment insetAlignment(int index) const
QCPBars * barBelow() const
virtual ~QCPItemEllipse()
QCPScatterStyle mOutlierStyle
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
virtual QPointF pixelPosition() const
void setOffset(int offset)
void setSelectedPen(const QPen &pen)
void rescaleValueAxis(bool onlyEnlarge=false, bool inKeyRange=false) const
bool removeFromLegend() const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
virtual void drawFill(QCPPainter *painter, QVector< QPointF > *lines) const
QList< QCPColorMap * > colorMaps() const
bool hasAnchor(const QString &name) const
void scaleTypeChanged(QCPAxis::ScaleType scaleType)
int pixelOrientation() const
Tick labels will be displayed outside the axis rect.
void removeChildX(QCPItemPosition *pos)
double realLength() const
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const =0
QList< QPointer< QCPAxis > > mRangeDragVertAxis
QPointF getPixelCoordinates(const QCPPlottableInterface1D *interface1d, int dataIndex) const
The abstract base class for all entries in a QCPLegend.
void initializeParentPlot(QCustomPlot *parentPlot)
SelectableParts selectableParts() const
QCPItemAnchor *const topRight
void setColumnSpacing(int pixels)
void setTail(const QCPLineEnding &tail)
PositionType mPositionTypeY
QCPItemAnchor * createAnchor(const QString &name, int anchorId)
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
QCP::AntialiasedElements mOpenGlAntialiasedElementsBackup
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
double pickClosest(double target, const QVector< double > &candidates) const
double cell(int keyIndex, int valueIndex)
Minimum/Maximum size constraints apply to inner rect.
SelectableParts mSelectedParts
Describes a data range given by begin and end index.
void setSelectedTickLabelFont(const QFont &font)
QCPAxis * rangeZoomAxis(Qt::Orientation orientation)
virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE
QCPGraph * addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0)
bool operator==(const QCPDataSelection &other) const
void addChild(QCPLayerable *layerable, bool prepend)
void setBackgroundScaledMode(Qt::AspectRatioMode mode)
virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE
void setBracketWidth(int width)
QCPScatterStyle::ScatterProperties usedScatterProperties() const
QVector< QLineF > getWhiskerBackboneLines(QCPStatisticalBoxDataContainer::const_iterator it) const
0x008 Plottables are selectable (e.g. graphs, curves, bars,... see QCPAbstractPlottable) ...
Phase used for any type of preparation that needs to be done before margin calculation and layout...
The abstract base class for paint buffers, which define the rendering backend.
QCPAbstractPaintBuffer * createPaintBuffer()
void setTextColor(const QColor &color)
void setPenNegative(const QPen &pen)
void setHead(const QCPLineEnding &head)
void setIconSize(const QSize &size)
void setSelectedBrush(const QBrush &brush)
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)
QCP::PlottingHints mPlottingHints
QCPPaintBufferPixmap(const QSize &size, double devicePixelRatio)
QList< QCPGraph * > graphs() const
void selectableChanged(bool selectable)
void setMinimumSize(const QSize &size)
QCPRange sanitizedForLinScale() const
void applyTo(QCPPainter *painter, const QPen &defaultPen) const
QColor mSelectedTextColor
void setCoords(double key, double value)
void addDataRange(const QCPDataRange &dataRange, bool simplify=true)
void setLength(double length)
A bar perpendicular to the line, pointing out to only one side (to which side can be changed with set...
void scaleRange(double factor)
QCPItemPosition * createPosition(const QString &name)
void setGraphKey(double key)
Minutes (%m in setTimeFormat)
QPointer< QCPBars > mBarAbove
void setBracketHeight(int height)
A legend item representing a plottable with an icon and the plottable name.
QCPAxis::LabelSide tickLabelSide
bool setCurrentLayer(const QString &name)
bool isPenDefined() const
void cellToCoord(int keyIndex, int valueIndex, double *key, double *value) const
QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const
void setOpenGl(bool enabled, int multisampling=16)
QCPVector2D & operator+=(const QCPVector2D &vector)
QCustomPlot * parentPlot() const
void setSelectionRect(QCPSelectionRect *selectionRect)
QCPLayerable(QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0)
Bar spacing is in key coordinates and thus scales with the key axis range.
const QCP::Interactions interactions() const
Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType)
virtual double dataSortKey(int index) const Q_DECL_OVERRIDE
void applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
WidthType widthType() const
void setLength(double length)
SelectableParts selectedParts() const
void setTicker(QSharedPointer< QCPAxisTicker > ticker)
QCP::SelectionRectMode mSelectionRectMode
void setPen(const QPen &pen)
void setSelectedTextColor(const QColor &color)
QMap< double, QString > mTicks
bool contains(double value) const
void setBrush(const QBrush &brush)
void setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, bool enabled=true)
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
void setInteraction(const QCP::Interaction &interaction, bool enabled=true)
int subTickLengthIn() const
QHash< TimeUnit, int > mFieldWidth
static double dateTimeToKey(const QDateTime dateTime)
QCPVector2D & operator*=(double factor)
Seconds (%s in setTimeFormat)
QCPItemAnchor * anchor(const QString &name) const
bool isInvalidData(double value)
void setStyle(EndingStyle style)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setTickPen(const QPen &pen)
0x0040 Main lines of items
Manages a single axis inside a QCustomPlot.
void addTicks(const QMap< double, QString > &ticks)
void selectionChanged(bool selected)
void clear(const QColor &color) Q_DECL_OVERRIDE
void setAntialiasedFill(bool enabled)
QPointer< QCPAxis > mValueAxis
0x01 Axis is vertical and on the left side of the axis rect
Bar spacing is given by a fraction of the axis rect size.
void setColorInterpolation(ColorInterpolation interpolation)
void setWhiskerBarPen(const QPen &pen)
virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE
QList< QCPAxis * > axes() const
void rescaleAxes(bool onlyEnlarge=false) const
void setZeroLinePen(const QPen &pen)
virtual Q_SLOT void processRectZoom(QRect rect, QMouseEvent *event)
QCPSelectionDecoratorBracket()
void setSubTickLength(int inside, int outside=0)
void rescaleDataRange(bool onlyVisibleMaps)
Q_SLOT void setSelectable(bool selectable)
static QDateTime keyToDateTime(double key)
A template base class for plottables with one-dimensional data.
0x01 The pen property, see setPen
PositionType mPositionTypeX
void setPen(const QPen &pen)
QRect tickLabelsSelectionBox() const
void setViewport(const QRect &rect)
QCPItemPosition *const end
void indexToRowCol(int index, int &row, int &column) const
SelectableParts selectedParts() const
QList< QCPAbstractItem * > mItems
double getStackedBaseValue(double key, bool positive) const
Dynamic positioning at a plot coordinate defined by two axes (see setAxes).
QCP::Interactions mInteractions
Qt::Orientations mRangeDrag
Q_SLOT void setSelectable(bool selectable)
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
void setTextColor(const QColor &color)
virtual void getOptimizedLineData(QVector< QCPGraphData > *lineData, const QCPGraphDataContainer::const_iterator &begin, const QCPGraphDataContainer::const_iterator &end) const
bool removeAxis(QCPAxis *axis)
QCPAxis * keyAxis() const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
QVector< QRgb > mColorBuffer
void rescaleDataRange(bool recalculateDataBounds=false)
Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts &selectedParts)
virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE
void setLineStyle(LineStyle ls)
bool hasItem(QCPAbstractItem *item) const
Days (%d in setTimeFormat)
{ssDisc.png} a circle which is filled with the pen's color (not the brush as with ssCircle) ...
void setPen(const QPen &pen)
void setCell(int keyIndex, int valueIndex, double z)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setData(QSharedPointer< QCPStatisticalBoxDataContainer > data)
QPointer< QCPAxis > mColorAxis
void setPadding(int padding)
void getDataSegments(QList< QCPDataRange > &selectedSegments, QList< QCPDataRange > &unselectedSegments) const
void setData(QSharedPointer< QCPFinancialDataContainer > data)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setSelectedLabelFont(const QFont &font)
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
QCPScatterStyle getFinalScatterStyle(const QCPScatterStyle &unselectedStyle) const
double data(double key, double value)
void addChildX(QCPItemPosition *pos)
A margin group allows synchronization of margin sides if working with multiple layout elements...
virtual ~QCPAxisPainterPrivate()
The tracer is not visible.
void setPen(const QPen &pen)
QCPDataSelection mSelection
Bar width is in absolute pixels.
QCPLineEnding lowerEnding() const
void setMedianPen(const QPen &pen)
QSharedPointer< QCPAxisTicker > mTicker
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE
void setOutlierStyle(const QCPScatterStyle &style)
void axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
QColor getLabelColor() const
void addTick(double position, const QString &label)
virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
The errors are for the value dimension (bars appear parallel to the value axis)
void setSelectedBrush(const QBrush &brush)
void setPen(const QPen &pen)
void addData(const QVector< double > &keys, const QVector< double > &values, bool alreadySorted=false)
QRectF insetRect(int index) const
void setTwoColored(bool twoColored)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QCPItemPosition *const start
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
QCPPlottableLegendItem * itemWithPlottable(const QCPAbstractPlottable *plottable) const
QRect labelSelectionBox() const
void setRangeZoom(Qt::Orientations orientations)
virtual int calculateMargin()
void registerBars(QCPBars *bars)
void started(QMouseEvent *event)
void setWhiskerAntialiased(bool enabled)
QCPDataRange expanded(const QCPDataRange &other) const
{ssTriangleInverted.png} an equilateral triangle, standing on corner
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
void setData(QSharedPointer< QCPGraphDataContainer > data)
Qt::KeyboardModifier mMultiSelectModifier
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setScaleRatio(const QCPAxis *otherAxis, double ratio=1.0)
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
virtual double getTickStep(const QCPRange &range)
void doubleClicked(QMouseEvent *event)
virtual ~QCPItemBracket()
void mouseWheel(QWheelEvent *event)
virtual void draw(QCPPainter *painter)=0
bool getTraverse(double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin, QPointF &crossA, QPointF &crossB) const
QList< QCPLayerable * > children() const
An anchor of an item to which positions can be attached to.
void setNumberFormat(const QString &formatCode)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QCPAbstractPaintBuffer(const QSize &size, double devicePixelRatio)
QPixmap toPixmap(int width=0, int height=0, double scale=1.0)
bool setParentAnchorY(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false)
friend class QCPItemAnchor
0x0100 Borders of fills (e.g. under or between graphs)
The abstract base class for all items in a plot.
A filled diamond (45 degrees rotated square)
virtual QPointF anchorPixelPosition(int anchorId) const
QCPAxisRect * axisRect() const
void setSelectedBrush(const QBrush &brush)
void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
static const double minRange
void setFont(const QFont &font)
bool hasPlottable(QCPAbstractPlottable *plottable) const
QVector< double > mTickVector
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
An integer power of the specified tick step is allowed.
QList< QPointer< QCPAxis > > mRangeDragHorzAxis
Selection behaves like stMultipleDataRanges, but if there are any data points selected, the entire plottable is drawn as selected.
virtual QRect clipRect() const Q_DECL_OVERRIDE
bool mAutoAddPlottableToLegend
virtual void layoutChanged()
virtual QCPLayoutElement * takeAt(int index) Q_DECL_OVERRIDE
SelectableParts mSelectableParts
bool mMapImageInvalidated
double mRangeZoomFactorHorz
void expandTo(int newRowCount, int newColumnCount)
Colors suitable to emphasize polarity around the center, with blue for negative, black in the middle ...
void setSubGridPen(const QPen &pen)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setNotAntialiasedElements(const QCP::AntialiasedElements ¬AntialiasedElements)
QList< QCPAxis * > axes(QCPAxis::AxisTypes types) const
QCPAbstractItem * itemAt(const QPointF &pos, bool onlySelectable=false) const
QCPColorGradient gradient() const
void replaceUnit(QString &text, TimeUnit unit, int value) const
A paint buffer based on QPixmap, using software raster rendering.
QImage mUndersampledMapImage
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
virtual QSize maximumOuterSizeHint() const
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
void setBackgroundScaledMode(Qt::AspectRatioMode mode)
QCPAxisRect * axisRect() const
void setFractionStyle(FractionStyle style)
bool hasItem(QCPAbstractLegendItem *item) const
QPixmap mBackgroundPixmap
virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const
QCPAbstractItem * mParentItem
void setText(const QString &text)
void setShape(ScatterShape shape)
BracketStyle style() const
void gradientChanged(const QCPColorGradient &newGradient)
void setWidth(double width)
virtual void drawDecoration(QCPPainter *painter, QCPDataSelection selection)
0x0080 Scatter symbols of plottables (excluding scatter symbols of type ssPixmap) ...
void getMinimumRowColSizes(QVector< int > *minColWidths, QVector< int > *minRowHeights) const
void moveBelow(QCPBars *bars)
bool noAntialiasingOnDrag() const
virtual Q_SLOT void processPointSelection(QMouseEvent *event)
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
virtual int findBegin(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE
void setVisible(bool visible)
TickStepStrategy mTickStepStrategy
virtual int elementCount() const Q_DECL_OVERRIDE
int findIndexAboveX(const QVector< QPointF > *data, double x) const
void setGraph(QCPGraph *graph)
QCPSelectionRect * selectionRect() const
void setColumnStretchFactors(const QList< double > &factors)
void setText(const QString &text)
A layout that places child elements aligned to the border or arbitrarily positioned.
bool remove(QCPLayoutElement *element)
Data points are connected with a straight line.
void setTickLength(int inside, int outside=0)
bool setParentAnchorX(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false)
Q_SLOT void rescaleAxes(bool onlyVisiblePlottables=false)
void setData(double key, double value, double z)
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
double getPixelWidth(double key, double keyPixel) const
void setFont(const QFont &font)
void setMargins(const QMargins &margins)
void setSelectedBasePen(const QPen &pen)
void accepted(const QRect &rect, QMouseEvent *event)
virtual void getOptimizedScatterData(QVector< QCPGraphData > *scatterData, QCPGraphDataContainer::const_iterator begin, QCPGraphDataContainer::const_iterator end) const
virtual bool registerWithPlottable(QCPAbstractPlottable *plottable)
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
0x080 All other objects are selectable (e.g. your own derived layerables, other layout elements...
void setSelectedSubTickPen(const QPen &pen)
bool operator==(const QCPColorGradient &other) const
QCPAbstractPlottable * plottable()
virtual QList< QCPLayoutElement * > elements(bool recursive) const Q_DECL_OVERRIDE
Whether to use immediate or queued refresh depends on whether the plotting hint QCP::phImmediateRefre...
0x002 Axis ranges are zoomable with the mouse wheel (see QCPAxisRect::setRangeZoom, QCPAxisRect::setRangeZoomAxes)
void addChild(QCP::MarginSide side, QCPLayoutElement *element)
QCPAbstractItem * item() const
void setErrorType(ErrorType type)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
line is drawn as steps where the step height is the value of the right data point ...
QCPLayout * mParentLayout
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const =0
void coordsToPixels(double key, double value, double &x, double &y) const
void setSelectionTolerance(int pixels)
virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE
void setPeriodic(bool enabled)
bool removeFromLegend(QCPLegend *legend) const
A non-filled arrow head with open back.
QCPItemAnchor *const left
virtual ~QCPLayoutElement()
void setDateTimeSpec(Qt::TimeSpec spec)
Qt::TimeSpec mDateTimeSpec
QPen iconBorderPen() const
virtual ~QCPSelectionRect()
virtual ~QCPAbstractPlottable()
A plottable representing a bar chart in a plot.
void setScatterStyle(const QCPScatterStyle &scatterStyle, QCPScatterStyle::ScatterProperties usedProperties=QCPScatterStyle::spPen)
QCustomPlot(QWidget *parent=0)
void setLowerEnding(const QCPLineEnding &ending)
Qt::AspectRatioMode mAspectRatioMode
double devicePixelRatio() const
double tickLabelRotation() const
void setFont(const QFont &font)
void mouseMove(QMouseEvent *event)
QCPColorMapData * mMapData
QString unicodeSuperscript(int number) const
0x8000 Other elements that don't fit into any of the existing categories
QPen selectedIconBorderPen() const
bool hasElement(int row, int column)
int findIndexBelowY(const QVector< QPointF > *data, double y) const
QCPLineEnding tail() const
void addData(const QVector< double > &keys, const QVector< double > &values, bool alreadySorted=false)
A brace with round edges.
QList< QCPGraph * > selectedGraphs() const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Qt::Orientations mRangeZoom
Static positioning in pixels, starting from the top left corner of the viewport/widget.
A filled arrow head with an indented back.
QSharedPointer< QCPErrorBarsDataContainer > mDataContainer
{ssPlusCircle.png} a circle with a plus inside
QCPAbstractLegendItem(QCPLegend *parent)
void setSpacing(double spacing)
virtual double dataMainKey(int index) const =0
void plottableDoubleClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event)
void add(const QCPDataContainer< DataType > &data)
void setTypeX(PositionType type)
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE
QCPRange valueRange() const
QString fractionToString(int numerator, int denominator) const
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)
void setBackground(const QPixmap &pm)
{ssPeace.png} a circle, with one vertical and two downward diagonal lines
QHash< QCPAxis::AxisType, QList< QCPAxis * > > mAxes
void getScatters(QVector< QPointF > *scatters, const QCPDataRange &dataRange) const
QVector< double > outliers
QCP::PlottingHints plottingHints() const
void setWidthType(WidthType widthType)
void getTraverseCornerPoints(int prevRegion, int currentRegion, double keyMin, double valueMax, double keyMax, double valueMin, QVector< QPointF > &beforeTraverse, QVector< QPointF > &afterTraverse) const
0x01 Mode for vectorized painting (e.g. PDF export). For example, this prevents some antialiasing fix...
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
QCPItemAnchor *const bottom
QCPScatterStyle mScatterStyle
Base class for all drawable objects.
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setPen(const QPen &pen)
Q_SLOT void setSelectableParts(const QCPAxis::SelectableParts &selectableParts)
QCPDataSelection selection() const
void draw(QCPPainter *painter, const QCPVector2D &pos, const QCPVector2D &dir) const
virtual void generate(const QCPRange &range, const QLocale &locale, QChar formatChar, int precision, QVector< double > &ticks, QVector< double > *subTicks, QVector< QString > *tickLabels)
void insert(int i, QCPBars *bars)
QCPColorGradient inverted() const
void setData(QSharedPointer< QCPErrorBarsDataContainer > data)
QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale)
int tickLengthOut() const
virtual void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE
bool mOpenGlCacheLabelsBackup
void setLabelColor(const QColor &color)
void setScatterStyle(const QCPScatterStyle &style)
virtual void reallocateBuffer()=0
QCPDataRange span() const
void setSelectedPen(const QPen &pen)
void getVisibleDataBounds(QCPBarsDataContainer::const_iterator &begin, QCPBarsDataContainer::const_iterator &end) const
void setTickLabelRotation(double degrees)
void setWhiskerWidth(double width)
QCP::SelectionType selectable() const
bool isVisible(PanelDockWidget *widget)
Tick labels will be displayed inside the axis rect and clipped to the inner axis rect.
{ssDot.png} a single pixel (use ssDisc or ssCircle if you want a round shape with a certain radius) ...
void setLineStyle(LineStyle style)
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
virtual void draw(QCPPainter *painter) const Q_DECL_OVERRIDE
QCP::AntialiasedElements mNotAADragBackup
void setHead(const QCPLineEnding &head)
QCPItemAnchor * mParentAnchorX
QCPItemPixmap(QCustomPlot *parentPlot)
QCPItemCurve(QCustomPlot *parentPlot)
QCPLayout * layout() const
QVector< double > mSubTickVector
void setRangeZoom(bool enabled)
virtual void simplify() Q_DECL_OVERRIDE
double bufferDevicePixelRatio() const
QCPBarsGroup(QCustomPlot *parentPlot)
The plottable is not selectable.
An approximation of the visible light spectrum (creates banding illusion but allows more precise magn...
void setValueSize(int valueSize)
Resolution is given in dots per centimeter (dpcm)
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE
A curly brace with varying stroke width giving a calligraphic impression.
virtual bool take(QCPLayoutElement *element)=0
bool mScaledPixmapInvalidated
virtual ~QCPItemPosition()
Fractions are written using sub- and superscript UTF-8 digits and the fraction symbol.
void setChartStyle(ChartStyle style)
void setBracketStyle(BracketStyle style)
void setSubTicks(bool show)
virtual QVector< double > createSubTickVector(int subTickCount, const QVector< double > &ticks)
QCPItemLine(QCustomPlot *parentPlot)
virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const
QCPAbstractLegendItem * item(int index) const
void selectionChanged(const QCPAxis::SelectableParts &parts)
void plottableClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event)
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE
void setTicks(const QMap< double, QString > &ticks)
void setModes(PainterModes modes)
void setStackingGap(double pixels)
void getScatters(QVector< QPointF > *scatters, const QCPDataRange &dataRange, double scatterWidth) const
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)
void setRotation(double degrees)
Q_SLOT void setSelected(bool selected)
QVector< double > tickPositions
void setBackgroundScaled(bool scaled)
virtual void endSelection(QMouseEvent *event)
A bar that is skewed (skew controllable via setLength)
virtual void updateLayout()
QList< QCPLayoutElement * > elements(QCP::MarginSide side) const
Qt::Alignment mPositionAlignment
QCPRange range(const QCPAxis *axis) const
{ssCrossCircle.png} a circle with a cross inside
QCPItemAnchor *const right
QPointer< QCPAxis > mKeyAxis
virtual QList< QCPLayoutElement * > elements(bool recursive) const Q_DECL_OVERRIDE
int findIndexBelowX(const QVector< QPointF > *data, double x) const
void setLogBase(double base)
virtual void drawCurveLine(QCPPainter *painter, const QVector< QPointF > &lines) const
void trimTicks(const QCPRange &range, QVector< double > &ticks, bool keepOneOutlier) const
A plottable representing a graph in a plot.
QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis)
int selectionTolerance() const
QHash< TimeUnit, QString > mFormatPattern
void setSubGridVisible(bool visible)
virtual void drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const
QVector< QString > mTickVectorLabels
void mouseRelease(QMouseEvent *event)
QString numberFormat() const
Modifications are not allowed, the specified tick step is absolutely fixed. This might cause a high t...
QLineF getRectClippedLine(const QCPVector2D &start, const QCPVector2D &end, const QRect &rect) const
QCPLayer(QCustomPlot *parentPlot, const QString &layerName)
QCPAxis * valueAxis() const
QCPItemStraightLine(QCustomPlot *parentPlot)
void setFillOrder(FillOrder order, bool rearrange=true)
QCPDataContainer< QCPFinancialData > QCPFinancialDataContainer
Bar width is in key coordinates and thus scales with the key axis range.
virtual QVector< double > createTickVector(double tickStep, const QCPRange &range)
QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis)
virtual void drawLinePlot(QCPPainter *painter, const QVector< QPointF > &lines) const
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
The negative sign domain, i.e. numbers smaller than zero.
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
QCPItemPosition *const position
void setParentLayerable(QCPLayerable *parentLayerable)
void selectableChanged(QCP::SelectionType selectable)
Continuous lightness from black to white (suited for non-biased data representation) ...
QPointer< QCPLayerable > mMouseEventLayerable
0x040 Items are selectable (Rectangles, Arrows, Textitems, etc. see QCPAbstractItem) ...
QColor getTickLabelColor() const
void selectableChanged(bool selectable)
Holds the two-dimensional data of a QCPColorMap plottable.
QCPColorGradient mGradient
void insertRow(int newIndex)
Final phase in which the layout system places the rects of the elements.
void setKeyRange(const QCPRange &keyRange)
void setAxisRect(QCPAxisRect *axisRect)
int subTickLengthOut() const
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
void draw(QCPPainter *painter)
None of the selectable parts.
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QSize minimumSize() const
QCPColorMapData & operator=(const QCPColorMapData &other)
void setRange(const QCPRange &keyRange, const QCPRange &valueRange)
The abstract base class for all data representing objects in a plot.
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
QCPItemAnchor *const bottom
virtual void placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize)
void setRangeZoomFactor(double horizontalFactor, double verticalFactor)
QCPDataRange dataRange(int index=0) const
void getVisibleDataBounds(QCPGraphDataContainer::const_iterator &begin, QCPGraphDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE
void setPixmap(const QPixmap &pixmap)
QCPItemAnchor *const center
QList< QCPAxisRect * > axisRects() const
void setTextFlags(int flags)
void setPiSymbol(QString symbol)
virtual ~QCPPaintBufferPixmap()
virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE
virtual int calculateAutoMargin(QCP::MarginSide side) Q_DECL_OVERRIDE
A plus shaped crosshair with limited size.
virtual void drawImpulsePlot(QCPPainter *painter, const QVector< QPointF > &lines) const
void selectableChanged(bool selectable)
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name)
void drawLine(const QLineF &line)
void drawCandlestickPlot(QCPPainter *painter, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, bool isSelected)
QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis)
virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE
QSharedPointer< QCPDataContainer< QCPGraphData > > mDataContainer
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
void setSelectedPen(const QPen &pen)
virtual void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE
void setRowStretchFactors(const QList< double > &factors)
Color channels red, green and blue are linearly interpolated.
QList< double > mColumnStretchFactors
0x0001 Axis base line and tick marks
void setAntialiasedScatters(bool enabled)
void setPenPositive(const QPen &pen)
void setSelectedIconBorderPen(const QPen &pen)
double max(double a, double b)
Q_SLOT void setSelected(bool selected)
QRect mTickLabelsSelectionBox
QVector< QPointF > dataToStepRightLines(const QVector< QCPGraphData > &data) const
QCPAbstractItem(QCustomPlot *parentPlot)
bool mNoAntialiasingOnDrag
void setLabelPadding(int padding)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
virtual void updateLayout() Q_DECL_OVERRIDE
PositionType type() const
data points are connected by a straight line
Holds the data of one single error bar for QCPErrorBars.
SizeConstraintRect mSizeConstraintRect
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision)
int rowColToIndex(int row, int column) const
void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical)
QCPItemAnchor * mParentAnchorY
void getErrorBarLines(QCPErrorBarsDataContainer::const_iterator it, QVector< QLineF > &backbones, QVector< QLineF > &whiskers) const
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
void changed(const QRect &rect, QMouseEvent *event)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
FractionStyle mFractionStyle
virtual void drawBracket(QCPPainter *painter, int direction) const
virtual void drawScatterPlot(QCPPainter *painter, const QVector< QPointF > &points, const QCPScatterStyle &style) const
void setAntialiasing(bool enabled)
void setBorderPen(const QPen &pen)
void getDataSegments(QList< QCPDataRange > &selectedSegments, QList< QCPDataRange > &unselectedSegments) const
void getVisibleDataBounds(QCPErrorBarsDataContainer::const_iterator &begin, QCPErrorBarsDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
void applyFillAntialiasingHint(QCPPainter *painter) const
virtual ~QCPLayoutInset()
void setSize(int keySize, int valueSize)
virtual void drawStatisticalBox(QCPPainter *painter, QCPStatisticalBoxDataContainer::const_iterator it, const QCPScatterStyle &outlierStyle) const
QCPScatterStyle mScatterStyle
QCPItemPosition *const endDir
bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
virtual QSize maximumOuterSizeHint() const Q_DECL_OVERRIDE
A plottable representing a two-dimensional color map in a plot.
QCPDataSelection intersection(const QCPDataRange &other) const
QVector< QString > tickLabels
void setPadding(const QMargins &padding)
0x002 Legend items individually (see selectedItems)
virtual void draw(QCPPainter *painter)
void canceled(const QRect &rect, QInputEvent *event)
QList< QCPItemAnchor * > mAnchors
virtual QCPPainter * startPainting() Q_DECL_OVERRIDE
Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType)
void setSize(const QSize &size)
An integer multiple of the specified tick step is allowed. The used factor follows the base class pro...
virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE
void setOuterRect(const QRect &rect)
Qt::AspectRatioMode mBackgroundScaledMode
virtual QPointF pixelPosition() const Q_DECL_OVERRIDE
WidthType widthType() const
QCPItemAnchor * parentAnchor() const
virtual QRect clipRect() const
double keyPixelOffset(const QCPBars *bars, double keyCoord)
QVector< double > subTickPositions
virtual QCPPlottableInterface1D * interface1D()
void setSelectedPen(const QPen &pen)
void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
QList< QCPAbstractLegendItem * > selectedItems() const
static const double maxRange
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const =0
double getTangentAngle(const QCPPlottableInterface1D *interface1d, int dataIndex, int direction) const
bool rangeReversed() const
QList< QList< QCPLayoutElement * > > mElements
QHash< QCP::MarginSide, QList< QCPLayoutElement * > > mChildren
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
void setSubTickLengthOut(int outside)
void setTickStepStrategy(TickStepStrategy strategy)
QCPScatterStyle mScatterStyle
QCPSelectionRect * mSelectionRect
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
QList< QCPLayerable * > layerableListAt(const QPointF &pos, bool onlySelectable, QList< QVariant > *selectionDetails=0) const
QCPItemPosition *const point1
void addElement(QCPLayoutElement *element, Qt::Alignment alignment)
QCPAxis(QCPAxisRect *parent, AxisType type)
const QPolygonF getFillPolygon(const QVector< QPointF > *lineData, QCPDataRange segment) const
void setInsetAlignment(int index, Qt::Alignment alignment)
virtual void parentPlotInitialized(QCustomPlot *parentPlot) Q_DECL_OVERRIDE
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
void append(QCPBars *bars)
QList< QCPAxis * > selectedAxes() const
QList< QCPAbstractItem * > items() const
QStack< bool > mAntialiasingStack
virtual ~QCPAbstractItem()
void getVisibleDataBounds(QCPStatisticalBoxDataContainer::const_iterator &begin, QCPStatisticalBoxDataContainer::const_iterator &end) const
QCPErrorBars(QCPAxis *keyAxis, QCPAxis *valueAxis)
void setWidth(double width)
void setTickLabelColor(const QColor &color)
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
{ssDiamond.png} a diamond
QCPAxis * rangeDragAxis(Qt::Orientation orientation)
QMap< double, QColor > colorStops() const
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
const QCPRange range() const
void setData(QCPColorMapData *data, bool copy=false)
virtual void drawDecoration(QCPPainter *painter, QCPDataSelection selection) Q_DECL_OVERRIDE
void setTickOrigin(double origin)
QList< QCPLayer * > mLayers
Holds the data of one single data point for QCPFinancial.
{ssTriangle.png} an equilateral triangle, standing on baseline
void setDataPlottable(QCPAbstractPlottable *plottable)
QCPAxisRect * axisRect(int index=0) const
QList< QCPAxis * > addAxes(QCPAxis::AxisTypes types)
void setAntialiasedElements(const QCP::AntialiasedElements &antialiasedElements)
int dataPointCount() const
When dragging the mouse, a selection rect becomes active. Upon releasing, plottable data points that ...
Q_SLOT void axisSelectionChanged(QCPAxis::SelectableParts selectedParts)
QCPRange dataBounds() const
Resolution is given in dots per meter (dpm)
void setAutoAddPlottableToLegend(bool on)
void setTickStep(double step)
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setSpacingType(SpacingType spacingType)
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
virtual void update(UpdatePhase phase)
void updateAxesOffset(QCPAxis::AxisType type)
QSharedPointer< QCPGraphDataContainer > data() const
virtual void wheelEvent(QWheelEvent *event)
QCPItemTracer(QCustomPlot *parentPlot)
void setScaleStrategy(ScaleStrategy strategy)
void setSelectedBrush(const QBrush &brush)
void selectionChanged(bool selected)
ColorInterpolation mColorInterpolation
QCPVector2D normalized() const
virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos)
void setSelectedTickPen(const QPen &pen)
void setLevelCount(int n)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QCPRange bounded(double lowerBound, double upperBound) const
void setRowStretchFactor(int row, double factor)
bool begin(QPaintDevice *device)
void setUpperEnding(const QCPLineEnding &ending)
QCPItemAnchor *const right
QCPItemAnchor *const bottomLeft
double dot(const QCPVector2D &vec) const
bool rectIntersectsLine(const QRectF &pixelRect, const QLineF &line) const
QCPLayer * layer(const QString &name) const
void setSelectionDecorator(QCPSelectionDecorator *decorator)
width is in absolute pixels
void setSelectionRectMode(QCP::SelectionRectMode mode)
QCPItemAnchor *const topLeft
bool addToLegend(QCPLegend *legend)
double coordToPixel(double value) const
void setPixelPosition(const QPointF &pixelPosition)
int axisRectCount() const
bool moveToLayer(QCPLayer *layer, bool prepend)
QCPItemAnchor *const left
QCPColorMapData * data() const