260 mPen.setColor(Qt::blue);
261 mPen.setStyle(Qt::SolidLine);
263 mBrush.setColor(Qt::blue);
264 mBrush.setStyle(Qt::NoBrush);
317 n = qMin(n, value.size());
319 for (
int i=0; i<n; ++i)
321 newData.
key = key[i];
322 newData.value = value[i];
323 mData->insertMulti(newData.key, newData);
338 n = qMin(n, value.size());
339 n = qMin(n, valueError.size());
341 for (
int i=0; i<n; ++i)
343 newData.
key = key[i];
344 newData.value = value[i];
345 newData.valueErrorMinus = valueError[i];
346 newData.valueErrorPlus = valueError[i];
347 mData->insertMulti(key[i], newData);
360 void QCPGraph::setDataValueError(
const QVector<double> &key,
const QVector<double> &value,
const QVector<double> &valueErrorMinus,
const QVector<double> &valueErrorPlus)
364 n = qMin(n, value.size());
365 n = qMin(n, valueErrorMinus.size());
366 n = qMin(n, valueErrorPlus.size());
368 for (
int i=0; i<n; ++i)
370 newData.
key = key[i];
371 newData.value = value[i];
372 newData.valueErrorMinus = valueErrorMinus[i];
373 newData.valueErrorPlus = valueErrorPlus[i];
374 mData->insertMulti(key[i], newData);
389 n = qMin(n, value.size());
390 n = qMin(n, keyError.size());
392 for (
int i=0; i<n; ++i)
394 newData.
key = key[i];
395 newData.value = value[i];
396 newData.keyErrorMinus = keyError[i];
397 newData.keyErrorPlus = keyError[i];
398 mData->insertMulti(key[i], newData);
411 void QCPGraph::setDataKeyError(
const QVector<double> &key,
const QVector<double> &value,
const QVector<double> &keyErrorMinus,
const QVector<double> &keyErrorPlus)
415 n = qMin(n, value.size());
416 n = qMin(n, keyErrorMinus.size());
417 n = qMin(n, keyErrorPlus.size());
419 for (
int i=0; i<n; ++i)
421 newData.
key = key[i];
422 newData.value = value[i];
423 newData.keyErrorMinus = keyErrorMinus[i];
424 newData.keyErrorPlus = keyErrorPlus[i];
425 mData->insertMulti(key[i], newData);
436 void QCPGraph::setDataBothError(
const QVector<double> &key,
const QVector<double> &value,
const QVector<double> &keyError,
const QVector<double> &valueError)
440 n = qMin(n, value.size());
441 n = qMin(n, valueError.size());
442 n = qMin(n, keyError.size());
444 for (
int i=0; i<n; ++i)
446 newData.
key = key[i];
447 newData.value = value[i];
448 newData.keyErrorMinus = keyError[i];
449 newData.keyErrorPlus = keyError[i];
450 newData.valueErrorMinus = valueError[i];
451 newData.valueErrorPlus = valueError[i];
452 mData->insertMulti(key[i], newData);
465 void QCPGraph::setDataBothError(
const QVector<double> &key,
const QVector<double> &value,
const QVector<double> &keyErrorMinus,
const QVector<double> &keyErrorPlus,
const QVector<double> &valueErrorMinus,
const QVector<double> &valueErrorPlus)
469 n = qMin(n, value.size());
470 n = qMin(n, valueErrorMinus.size());
471 n = qMin(n, valueErrorPlus.size());
472 n = qMin(n, keyErrorMinus.size());
473 n = qMin(n, keyErrorPlus.size());
475 for (
int i=0; i<n; ++i)
477 newData.
key = key[i];
478 newData.value = value[i];
479 newData.keyErrorMinus = keyErrorMinus[i];
480 newData.keyErrorPlus = keyErrorPlus[i];
481 newData.valueErrorMinus = valueErrorMinus[i];
482 newData.valueErrorPlus = valueErrorPlus[i];
483 mData->insertMulti(key[i], newData);
581 if (targetGraph ==
this)
583 qDebug() <<
FUNCNAME <<
"targetGraph is self";
590 qDebug() <<
FUNCNAME <<
"targetGraph not in same plot";
604 mData->unite(dataMap);
624 newData.
value = value;
625 mData->insertMulti(newData.
key, newData);
634 int n = qMin(keys.size(), values.size());
636 for (
int i=0; i<n; ++i)
638 newData.
key = keys[i];
639 newData.value = values[i];
640 mData->insertMulti(newData.key, newData);
650 QCPDataMap::iterator it =
mData->begin();
651 while (it !=
mData->end() && it.key() < key)
652 it =
mData->erase(it);
661 if (
mData->isEmpty())
return;
662 QCPDataMap::iterator it =
mData->upperBound(key);
663 while (it !=
mData->end())
664 it =
mData->erase(it);
676 if (fromKey >= toKey ||
mData->isEmpty())
return;
677 QCPDataMap::iterator it =
mData->upperBound(fromKey);
678 QCPDataMap::iterator itEnd =
mData->upperBound(toKey);
680 it =
mData->erase(it);
725 if (
mData->isEmpty())
return;
756 if (
mData->isEmpty())
return;
783 if (
mData->isEmpty())
return;
788 QVector<QPointF> *lineData =
new QVector<QPointF>;
789 QVector<QCPData> *pointData = 0;
791 pointData =
new QVector<QCPData>;
819 if (
mBrush.style() != Qt::NoBrush)
822 painter->fillRect(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0,
mBrush);
828 painter->setPen(
mPen);
829 painter->drawLine(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0);
839 newSize.scale(rect.size(), Qt::KeepAspectRatio);
841 targetRect.setSize(newSize);
842 targetRect.moveCenter(rect.center());
843 bool smoothBackup = painter->testRenderHint(QPainter::SmoothPixmapTransform);
844 painter->setRenderHint(QPainter::SmoothPixmapTransform,
true);
846 painter->setRenderHint(QPainter::SmoothPixmapTransform, smoothBackup);
849 painter->setPen(
mPen);
893 if (!pointData)
return;
896 QCPDataMap::const_iterator lower, upper;
901 pointData->resize(dataCount);
904 QCPDataMap::const_iterator it = lower;
905 QCPDataMap::const_iterator upperEnd = upper+1;
909 while (it != upperEnd)
911 (*pointData)[i] = it.value();
917 while (it != upperEnd)
919 (*pointData)[i] = it.value();
939 QCPDataMap::const_iterator lower, upper;
946 lineData->reserve(dataCount+2);
947 lineData->resize(dataCount);
950 pointData->resize(dataCount);
953 QCPDataMap::const_iterator it = lower;
954 QCPDataMap::const_iterator upperEnd = upper+1;
958 while (it != upperEnd)
961 (*pointData)[i] = it.value();
969 while (it != upperEnd)
972 (*pointData)[i] = it.value();
994 QCPDataMap::const_iterator lower, upper;
1002 lineData->reserve(dataCount*2+2);
1003 lineData->resize(dataCount*2);
1006 pointData->resize(dataCount);
1009 QCPDataMap::const_iterator it = lower;
1010 QCPDataMap::const_iterator upperEnd = upper+1;
1017 while (it != upperEnd)
1021 (*pointData)[ipoint] = it.value();
1025 (*lineData)[i].setX(lastValue);
1026 (*lineData)[i].setY(key);
1029 (*lineData)[i].setX(lastValue);
1030 (*lineData)[i].setY(key);
1038 while (it != upperEnd)
1042 (*pointData)[ipoint] = it.value();
1046 (*lineData)[i].setX(key);
1047 (*lineData)[i].setY(lastValue);
1050 (*lineData)[i].setX(key);
1051 (*lineData)[i].setY(lastValue);
1071 QCPDataMap::const_iterator lower, upper;
1079 lineData->reserve(dataCount*2+2);
1080 lineData->resize(dataCount*2);
1083 pointData->resize(dataCount);
1086 QCPDataMap::const_iterator it = lower;
1087 QCPDataMap::const_iterator upperEnd = upper+1;
1094 while (it != upperEnd)
1098 (*pointData)[ipoint] = it.value();
1102 (*lineData)[i].setX(value);
1103 (*lineData)[i].setY(lastKey);
1106 (*lineData)[i].setX(value);
1107 (*lineData)[i].setY(lastKey);
1115 while (it != upperEnd)
1119 (*pointData)[ipoint] = it.value();
1123 (*lineData)[i].setX(lastKey);
1124 (*lineData)[i].setY(value);
1127 (*lineData)[i].setX(lastKey);
1128 (*lineData)[i].setY(value);
1148 QCPDataMap::const_iterator lower, upper;
1156 lineData->reserve(dataCount*2+2);
1157 lineData->resize(dataCount*2);
1160 pointData->resize(dataCount);
1163 QCPDataMap::const_iterator it = lower;
1164 QCPDataMap::const_iterator upperEnd = upper+1;
1174 (*pointData)[ipoint] = it.value();
1177 (*lineData)[i].setX(lastValue);
1178 (*lineData)[i].setY(lastKey);
1181 while (it != upperEnd)
1185 (*pointData)[ipoint] = it.value();
1189 (*lineData)[i].setX(lastValue);
1190 (*lineData)[i].setY(key);
1194 (*lineData)[i].setX(lastValue);
1195 (*lineData)[i].setY(key);
1199 (*lineData)[i].setX(lastValue);
1200 (*lineData)[i].setY(lastKey);
1208 (*pointData)[ipoint] = it.value();
1211 (*lineData)[i].setX(lastKey);
1212 (*lineData)[i].setY(lastValue);
1215 while (it != upperEnd)
1219 (*pointData)[ipoint] = it.value();
1223 (*lineData)[i].setX(key);
1224 (*lineData)[i].setY(lastValue);
1228 (*lineData)[i].setX(key);
1229 (*lineData)[i].setY(lastValue);
1233 (*lineData)[i].setX(lastKey);
1234 (*lineData)[i].setY(lastValue);
1251 QCPDataMap::const_iterator lower, upper;
1258 lineData->resize(dataCount*2);
1261 pointData->resize(dataCount);
1264 QCPDataMap::const_iterator it = lower;
1265 QCPDataMap::const_iterator upperEnd = upper+1;
1272 while (it != upperEnd)
1276 (*pointData)[ipoint] = it.value();
1280 (*lineData)[i].setX(zeroPointX);
1281 (*lineData)[i].setY(key);
1284 (*lineData)[i].setY(key);
1292 while (it != upperEnd)
1296 (*pointData)[ipoint] = it.value();
1300 (*lineData)[i].setX(key);
1301 (*lineData)[i].setY(zeroPointY);
1303 (*lineData)[i].setX(key);
1325 if (
mBrush.style() == Qt::NoBrush ||
mBrush.color().alpha() == 0)
return;
1332 painter->setPen(Qt::NoPen);
1333 painter->setBrush(
mBrush);
1334 painter->drawPolygon(QPolygonF(*lineData));
1339 painter->setPen(Qt::NoPen);
1340 painter->setBrush(
mBrush);
1361 for (
int i=0; i<pointData->size(); ++i)
1365 for (
int i=0; i<pointData->size(); ++i)
1372 painter->setPen(
mPen);
1373 painter->setBrush(
mBrush);
1376 for (
int i=0; i<pointData->size(); ++i)
1380 for (
int i=0; i<pointData->size(); ++i)
1396 if (
mPen.style() != Qt::NoPen &&
mPen.color().alpha() != 0)
1399 painter->setPen(
mPen);
1400 painter->setBrush(Qt::NoBrush);
1401 painter->drawPolyline(QPolygonF(*lineData));
1414 if (
mPen.style() != Qt::NoPen &&
mPen.color().alpha() != 0)
1417 painter->setPen(
mPen);
1418 painter->setBrush(Qt::NoBrush);
1419 painter->drawLines(*lineData);
1446 painter->drawPoint(QPointF(x, y));
1451 painter->drawLine(QLineF(x-w, y-w, x+w, y+w));
1452 painter->drawLine(QLineF(x-w, y+w, x+w, y-w));
1457 painter->drawLine(QLineF(x-w, y, x+w, y));
1458 painter->drawLine(QLineF(x, y+w, x, y-w));
1463 painter->setBrush(Qt::NoBrush);
1469 painter->setBrush(QBrush(painter->pen().color()));
1470 painter->drawEllipse(QPointF(x,y), w, w);
1475 painter->setBrush(Qt::NoBrush);
1481 painter->drawLine(QLineF(x-w, y, x+w, y));
1482 painter->drawLine(QLineF(x, y+w, x, y-w));
1483 painter->drawLine(QLineF(x-w*0.707, y-w*0.707, x+w*0.707, y+w*0.707));
1484 painter->drawLine(QLineF(x-w*0.707, y+w*0.707, x+w*0.707, y-w*0.707));
1489 painter->drawLine(QLineF(x-w, y+0.755*w, x+w, y+0.755*w));
1490 painter->drawLine(QLineF(x+w, y+0.755*w, x, y-0.977*w));
1491 painter->drawLine(QLineF(x, y-0.977*w, x-w, y+0.755*w));
1496 painter->drawLine(QLineF(x-w, y-0.755*w, x+w, y-0.755*w));
1497 painter->drawLine(QLineF(x+w, y-0.755*w, x, y+0.977*w));
1498 painter->drawLine(QLineF(x, y+0.977*w, x-w, y-0.755*w));
1503 painter->setBrush(Qt::NoBrush);
1504 painter->drawLine(QLineF(x-w, y-w, x+w*0.95, y+w*0.95));
1505 painter->drawLine(QLineF(x-w, y+w*0.95, x+w*0.95, y-w));
1511 painter->setBrush(Qt::NoBrush);
1512 painter->drawLine(QLineF(x-w, y, x+w*0.95, y));
1513 painter->drawLine(QLineF(x, y+w, x, y-w));
1519 painter->setBrush(Qt::NoBrush);
1520 painter->drawLine(QLineF(x-w*0.707, y-w*0.707, x+w*0.67, y+w*0.67));
1521 painter->drawLine(QLineF(x-w*0.707, y+w*0.67, x+w*0.67, y-w*0.707));
1527 painter->setBrush(Qt::NoBrush);
1528 painter->drawLine(QLineF(x-w, y, x+w, y));
1529 painter->drawLine(QLineF(x, y+w, x, y-w));
1535 painter->setBrush(Qt::NoBrush);
1536 painter->drawLine(QLineF(x, y-w, x, y+w));
1537 painter->drawLine(QLineF(x, y, x-w*0.707, y+w*0.707));
1538 painter->drawLine(QLineF(x, y, x+w*0.707, y+w*0.707));
1583 if (a-y > skipSymbolMargin)
1584 painter->drawLine(QLineF(x, a, x, y+skipSymbolMargin));
1585 if (y-b > skipSymbolMargin)
1586 painter->drawLine(QLineF(x, y-skipSymbolMargin, x, b));
1588 painter->drawLine(QLineF(x, a, x, b));
1590 painter->drawLine(QLineF(x-barWidthHalf, a, x+barWidthHalf, a));
1591 painter->drawLine(QLineF(x-barWidthHalf, b, x+barWidthHalf, b));
1602 if (x-a > skipSymbolMargin)
1603 painter->drawLine(QLineF(a, y, x-skipSymbolMargin, y));
1604 if (b-x > skipSymbolMargin)
1605 painter->drawLine(QLineF(x+skipSymbolMargin, y, b, y));
1607 painter->drawLine(QLineF(a, y, b, y));
1609 painter->drawLine(QLineF(a, y-barWidthHalf, a, y+barWidthHalf));
1610 painter->drawLine(QLineF(b, y-barWidthHalf, b, y+barWidthHalf));
1624 if (x-a > skipSymbolMargin)
1625 painter->drawLine(QLineF(a, y, x-skipSymbolMargin, y));
1626 if (b-x > skipSymbolMargin)
1627 painter->drawLine(QLineF(x+skipSymbolMargin, y, b, y));
1629 painter->drawLine(QLineF(a, y, b, y));
1631 painter->drawLine(QLineF(a, y-barWidthHalf, a, y+barWidthHalf));
1632 painter->drawLine(QLineF(b, y-barWidthHalf, b, y+barWidthHalf));
1643 if (a-y > skipSymbolMargin)
1644 painter->drawLine(QLineF(x, a, x, y+skipSymbolMargin));
1645 if (y-b > skipSymbolMargin)
1646 painter->drawLine(QLineF(x, y-skipSymbolMargin, x, b));
1648 painter->drawLine(QLineF(x, a, x, b));
1650 painter->drawLine(QLineF(x-barWidthHalf, a, x+barWidthHalf, a));
1651 painter->drawLine(QLineF(x-barWidthHalf, b, x+barWidthHalf, b));
1674 bool lowoutlier = lbound !=
mData->constBegin();
1675 bool highoutlier = ubound+1 !=
mData->constEnd();
1676 lower = (lowoutlier ? lbound-1 : lbound);
1677 upper = (highoutlier ? ubound+1 : ubound);
1680 QCPDataMap::const_iterator it = lower;
1724 lineData->remove(lineData->size()-2, 2);
1748 point.setY(lowerKey);
1752 point.setY(lowerKey);
1755 point.setX(lowerKey);
1759 point.setX(lowerKey);
1773 point.setY(lowerKey);
1776 point.setX(lowerKey);
1808 point.setY(upperKey);
1812 point.setY(upperKey);
1815 point.setX(upperKey);
1819 point.setX(upperKey);
1833 point.setY(upperKey);
1836 point.setX(upperKey);
1861 if (lineData->isEmpty())
return QPolygonF();
1862 QVector<QPointF> otherData;
1864 if (otherData.isEmpty())
return QPolygonF();
1865 QVector<QPointF> thisData;
1866 thisData.reserve(lineData->size()+otherData.size());
1867 for (
int i=0; i<lineData->size(); ++i)
1868 thisData << lineData->at(i);
1871 QVector<QPointF> *staticData = &thisData;
1872 QVector<QPointF> *croppedData = &otherData;
1879 if (staticData->first().x() > staticData->last().x())
1881 int size = staticData->size();
1882 for (
int i=0; i<size/2; ++i)
1883 qSwap((*staticData)[i], (*staticData)[size-1-i]);
1885 if (croppedData->first().x() > croppedData->last().x())
1887 int size = croppedData->size();
1888 for (
int i=0; i<size/2; ++i)
1889 qSwap((*croppedData)[i], (*croppedData)[size-1-i]);
1892 if (staticData->first().x() < croppedData->first().x())
1893 qSwap(staticData, croppedData);
1895 if (lowBound == -1)
return QPolygonF();
1896 croppedData->remove(0, lowBound);
1899 if (croppedData->size() < 2)
return QPolygonF();
1901 if (croppedData->at(1).x()-croppedData->at(0).x() != 0)
1902 slope = (croppedData->at(1).y()-croppedData->at(0).y())/(croppedData->at(1).x()-croppedData->at(0).x());
1905 (*croppedData)[0].setY(croppedData->at(0).y()+slope*(staticData->first().x()-croppedData->at(0).x()));
1906 (*croppedData)[0].setX(staticData->first().x());
1909 if (staticData->last().x() > croppedData->last().x())
1910 qSwap(staticData, croppedData);
1912 if (highBound == -1)
return QPolygonF();
1913 croppedData->remove(highBound+1, croppedData->size()-(highBound+1));
1916 if (croppedData->size() < 2)
return QPolygonF();
1917 int li = croppedData->size()-1;
1918 if (croppedData->at(li).x()-croppedData->at(li-1).x() != 0)
1919 slope = (croppedData->at(li).y()-croppedData->at(li-1).y())/(croppedData->at(li).x()-croppedData->at(li-1).x());
1922 (*croppedData)[li].setY(croppedData->at(li-1).y()+slope*(staticData->last().x()-croppedData->at(li-1).x()));
1923 (*croppedData)[li].setX(staticData->last().x());
1930 if (staticData->first().y() < staticData->last().y())
1932 int size = staticData->size();
1933 for (
int i=0; i<size/2; ++i)
1934 qSwap((*staticData)[i], (*staticData)[size-1-i]);
1936 if (croppedData->first().y() < croppedData->last().y())
1938 int size = croppedData->size();
1939 for (
int i=0; i<size/2; ++i)
1940 qSwap((*croppedData)[i], (*croppedData)[size-1-i]);
1943 if (staticData->first().y() > croppedData->first().y())
1944 qSwap(staticData, croppedData);
1946 if (lowBound == -1)
return QPolygonF();
1947 croppedData->remove(0, lowBound);
1950 if (croppedData->size() < 2)
return QPolygonF();
1952 if (croppedData->at(1).y()-croppedData->at(0).y() != 0)
1953 slope = (croppedData->at(1).x()-croppedData->at(0).x())/(croppedData->at(1).y()-croppedData->at(0).y());
1956 (*croppedData)[0].setX(croppedData->at(0).x()+slope*(staticData->first().y()-croppedData->at(0).y()));
1957 (*croppedData)[0].setY(staticData->first().y());
1960 if (staticData->last().y() < croppedData->last().y())
1961 qSwap(staticData, croppedData);
1963 if (highBound == -1)
return QPolygonF();
1964 croppedData->remove(highBound+1, croppedData->size()-(highBound+1));
1967 if (croppedData->size() < 2)
return QPolygonF();
1968 int li = croppedData->size()-1;
1969 if (croppedData->at(li).y()-croppedData->at(li-1).y() != 0)
1970 slope = (croppedData->at(li).x()-croppedData->at(li-1).x())/(croppedData->at(li).y()-croppedData->at(li-1).y());
1973 (*croppedData)[li].setX(croppedData->at(li-1).x()+slope*(staticData->last().y()-croppedData->at(li-1).y()));
1974 (*croppedData)[li].setY(staticData->last().y());
1978 for (
int i=otherData.size()-1; i>=0; --i)
1979 thisData << otherData.at(i);
1980 return QPolygonF(thisData);
1992 for (
int i=data->size()-1; i>=0; --i)
1994 if (data->at(i).x() < x)
1996 if (i<data->size()-1)
1999 return data->size()-1;
2014 for (
int i=0; i<data->size(); ++i)
2016 if (data->at(i).x() > x)
2036 for (
int i=0; i<data->size(); ++i)
2038 if (data->at(i).y() < y)
2058 for (
int i=data->size()-1; i>=0; --i)
2060 if (data->at(i).y() > y)
2062 if (i<data->size()-1)
2065 return data->size()-1;
2076 return getKeyRange(validRange, inSignDomain,
true);
2095 bool haveLower =
false;
2096 bool haveUpper =
false;
2098 double current, currentErrorMinus, currentErrorPlus;
2100 if (inSignDomain ==
SDBoth)
2102 QCPDataMap::const_iterator it =
mData->constBegin();
2103 while (it !=
mData->constEnd())
2105 current = it.value().key;
2106 currentErrorMinus = (includeErrors ? it.value().keyErrorMinus : 0);
2107 currentErrorPlus = (includeErrors ? it.value().keyErrorPlus : 0);
2108 if (current-currentErrorMinus < range.
lower || !haveLower)
2110 range.
lower = current-currentErrorMinus;
2113 if (current+currentErrorPlus > range.
upper || !haveUpper)
2115 range.
upper = current+currentErrorPlus;
2122 QCPDataMap::const_iterator it =
mData->constBegin();
2123 while (it !=
mData->constEnd())
2125 current = it.value().key;
2126 currentErrorMinus = (includeErrors ? it.value().keyErrorMinus : 0);
2127 currentErrorPlus = (includeErrors ? it.value().keyErrorPlus : 0);
2128 if ((current-currentErrorMinus < range.
lower || !haveLower) && current-currentErrorMinus < 0)
2130 range.
lower = current-currentErrorMinus;
2133 if ((current+currentErrorPlus > range.
upper || !haveUpper) && current+currentErrorPlus < 0)
2135 range.
upper = current+currentErrorPlus;
2140 if ((current < range.
lower || !haveLower) && current < 0)
2142 range.
lower = current;
2145 if ((current > range.
upper || !haveUpper) && current < 0)
2147 range.
upper = current;
2155 QCPDataMap::const_iterator it =
mData->constBegin();
2156 while (it !=
mData->constEnd())
2158 current = it.value().key;
2159 currentErrorMinus = (includeErrors ? it.value().keyErrorMinus : 0);
2160 currentErrorPlus = (includeErrors ? it.value().keyErrorPlus : 0);
2161 if ((current-currentErrorMinus < range.
lower || !haveLower) && current-currentErrorMinus > 0)
2163 range.
lower = current-currentErrorMinus;
2166 if ((current+currentErrorPlus > range.
upper || !haveUpper) && current+currentErrorPlus > 0)
2168 range.
upper = current+currentErrorPlus;
2173 if ((current < range.
lower || !haveLower) && current > 0)
2175 range.
lower = current;
2178 if ((current > range.
upper || !haveUpper) && current > 0)
2180 range.
upper = current;
2188 validRange = haveLower && haveUpper;
2200 bool haveLower =
false;
2201 bool haveUpper =
false;
2203 double current, currentErrorMinus, currentErrorPlus;
2205 if (inSignDomain ==
SDBoth)
2207 QCPDataMap::const_iterator it =
mData->constBegin();
2208 while (it !=
mData->constEnd())
2210 current = it.value().value;
2211 currentErrorMinus = (includeErrors ? it.value().valueErrorMinus : 0);
2212 currentErrorPlus = (includeErrors ? it.value().valueErrorPlus : 0);
2213 if (current-currentErrorMinus < range.
lower || !haveLower)
2215 range.
lower = current-currentErrorMinus;
2218 if (current+currentErrorPlus > range.
upper || !haveUpper)
2220 range.
upper = current+currentErrorPlus;
2227 QCPDataMap::const_iterator it =
mData->constBegin();
2228 while (it !=
mData->constEnd())
2230 current = it.value().value;
2231 currentErrorMinus = (includeErrors ? it.value().valueErrorMinus : 0);
2232 currentErrorPlus = (includeErrors ? it.value().valueErrorPlus : 0);
2233 if ((current-currentErrorMinus < range.
lower || !haveLower) && current-currentErrorMinus < 0)
2235 range.
lower = current-currentErrorMinus;
2238 if ((current+currentErrorPlus > range.
upper || !haveUpper) && current+currentErrorPlus < 0)
2240 range.
upper = current+currentErrorPlus;
2245 if ((current < range.
lower || !haveLower) && current < 0)
2247 range.
lower = current;
2250 if ((current > range.
upper || !haveUpper) && current < 0)
2252 range.
upper = current;
2260 QCPDataMap::const_iterator it =
mData->constBegin();
2261 while (it !=
mData->constEnd())
2263 current = it.value().value;
2264 currentErrorMinus = (includeErrors ? it.value().valueErrorMinus : 0);
2265 currentErrorPlus = (includeErrors ? it.value().valueErrorPlus : 0);
2266 if ((current-currentErrorMinus < range.
lower || !haveLower) && current-currentErrorMinus > 0)
2268 range.
lower = current-currentErrorMinus;
2271 if ((current+currentErrorPlus > range.
upper || !haveUpper) && current+currentErrorPlus > 0)
2273 range.
upper = current+currentErrorPlus;
2278 if ((current < range.
lower || !haveLower) && current > 0)
2280 range.
lower = current;
2283 if ((current > range.
upper || !haveUpper) && current > 0)
2285 range.
upper = current;
2293 validRange = haveLower && haveUpper;
2342 this->lower =
lower;
2343 this->upper =
upper;
2386 double rangeFac = 1e-3;
2391 if (sanitizedRange.
lower == 0.0 && sanitizedRange.
upper != 0.0)
2394 if (rangeFac < sanitizedRange.
upper*rangeFac)
2395 sanitizedRange.
lower = rangeFac;
2397 sanitizedRange.
lower = sanitizedRange.
upper*rangeFac;
2399 else if (sanitizedRange.
lower != 0.0 && sanitizedRange.
upper == 0.0)
2402 if (-rangeFac > sanitizedRange.
lower*rangeFac)
2403 sanitizedRange.
upper = -rangeFac;
2405 sanitizedRange.
upper = sanitizedRange.
lower*rangeFac;
2406 }
else if (sanitizedRange.
lower < 0 && sanitizedRange.
upper > 0)
2409 if (-sanitizedRange.
lower > sanitizedRange.
upper)
2412 if (-rangeFac > sanitizedRange.
lower*rangeFac)
2413 sanitizedRange.
upper = -rangeFac;
2415 sanitizedRange.
upper = sanitizedRange.
lower*rangeFac;
2419 if (rangeFac < sanitizedRange.
upper*rangeFac)
2420 sanitizedRange.
lower = rangeFac;
2422 sanitizedRange.
lower = sanitizedRange.
upper*rangeFac;
2426 return sanitizedRange;
2437 return sanitizedRange;
2555 for (
int i=0; i<
mItems.size(); ++i)
2612 mSize = QSize(width, height);
2807 if (index >= 0 && index <
mItems.size())
2821 for (
int i=0; i<
mItems.size(); ++i)
2825 if (lip->plottable() == plottable)
2846 return mItems.contains(item);
2869 if (!
mItems.contains(item))
2886 if (index >= 0 && index <
mItems.size())
2939 painter->setBrush(
mBrush);
2944 painter->setClipRect(QRect(
mPosition,
mSize).adjusted(1, 1, 0, 0));
2945 painter->setPen(QPen());
2946 painter->setBrush(Qt::NoBrush);
2948 for (
int i=0; i<
mItems.size(); ++i)
2950 QSize itemSize =
mItems.at(i)->size(QSize(
mSize.width(), 0));
2965 for (
int i=0; i<
mItems.size(); ++i)
2967 QSize itemSize =
mItems.at(i)->size(QSize(
mSize.width(), 0));
2970 if (point->x() >= itemPosTopLeft.x() &&
2971 point->x() <= itemPosTopLeft.x()+itemSize.width() &&
2972 point->y() >= itemPosTopLeft.y() &&
2973 point->y() <= itemPosTopLeft.y()+itemSize.height())
2994 int repeatCount = 0;
2995 while (repeat && repeatCount < 3)
2999 for (
int i=0; i<
mItems.size(); ++i)
3001 QSize s =
mItems.at(i)->size(QSize(width, 0));
3002 currentTop += s.height();
3005 if (width < s.width())
3014 qDebug() <<
FUNCNAME <<
"hit repeat limit for iterative width calculation";
3018 mSize.setWidth(width);
3020 mSize.setHeight(currentTop);
3113 gPen.setColor(QColor(200,200,200));
3114 gPen.setStyle(Qt::DotLine);
3118 subgPen.setColor(QColor(220,220,220));
3119 subgPen.setStyle(Qt::DotLine);
3123 zlinePen.setColor(QColor(200,200,200));
3140 }
else if (type ==
ATLeft)
3229 qDebug() <<
FUNCNAME <<
"Invalid logarithmic scale base (must be greater 1):" << base;
3289 if (alignment == Qt::AlignLeft)
3291 else if (alignment == Qt::AlignRight)
3294 setRange(position-size/2.0, position+size/2.0);
3540 if (formatCode.length() < 1)
return;
3543 QString allowedFormatChars =
"eEfgG";
3544 if (allowedFormatChars.contains(formatCode.at(0)))
3549 qDebug() <<
FUNCNAME <<
"Invalid number format code (first char not in 'eEfgG'):" << formatCode;
3552 if (formatCode.length() < 2)
3565 qDebug() <<
FUNCNAME <<
"Invalid number format code (second char not 'b' or first char neither 'e' nor 'g'):" << formatCode;
3568 if (formatCode.length() < 3)
3575 if (formatCode.at(2) ==
'c')
3578 }
else if (formatCode.at(2) ==
'd')
3583 qDebug() <<
FUNCNAME <<
"Invalid number format code (third char neither 'c' nor 'd'):" << formatCode;
3853 qDebug() <<
FUNCNAME <<
"center of scaling operation doesn't lie in same logarithmic sign domain as range:" << center;
3868 int otherPixelSize, ownPixelSize;
3871 otherPixelSize = otherAxis->
mAxisRect.width();
3873 otherPixelSize = otherAxis->
mAxisRect.height();
3880 double newRangeSize = ratio*otherAxis->
mRange.
size()*ownPixelSize/(double)otherPixelSize;
3941 else if (value <= 0 && mRange.upper > 0)
3963 else if (value <= 0 && mRange.upper > 0)
4007 double subTickStep = 0;
4008 double subTickPosition = 0;
4009 int subTickIndex = 0;
4016 subTickPosition =
mTickVector->at(i-1) + k*subTickStep;
4024 (*mSubTickVector)[subTickIndex] = subTickPosition;
4041 for (
int i=0; i<vecsize; ++i)
4045 for (
int i=0; i<vecsize; ++i)
4077 double magnitudeFactor = pow(10, (
int)floor(log10(
mTickStep)));
4078 double tickStepMantissa =
mTickStep/magnitudeFactor;
4079 if (tickStepMantissa < 5)
4082 mTickStep = (int)(tickStepMantissa*2)/2.0*magnitudeFactor;
4086 mTickStep = (int)((tickStepMantissa/10.0)*5)/5.0*10*magnitudeFactor;
4094 int tickcount = lastStep-firstStep+1;
4095 if (tickcount < 0) tickcount = 0;
4097 for (
int i=0; i<tickcount; ++i)
4099 (*mTickVector)[i] = (firstStep+i)*
mTickStep;
4107 double currentMag = lowerMag;
4110 while (currentMag < mRange.upper && currentMag > 0)
4118 double currentMag = lowerMag;
4121 while (currentMag <
mRange.
upper && currentMag < 0)
4152 double magnitudeFactor = pow(10, (
int)floor(log10(tickStep)));
4153 double tickStepMantissa = tickStep/magnitudeFactor;
4156 double epsilon = 0.01;
4159 double fracPart = modf(tickStepMantissa, &intPartf);
4163 if (fracPart < epsilon || 1.0-fracPart < epsilon)
4165 if (1.0-fracPart < epsilon)
4169 case 1: result = 4;
break;
4170 case 2: result = 3;
break;
4171 case 3: result = 2;
break;
4172 case 4: result = 3;
break;
4173 case 5: result = 4;
break;
4174 case 6: result = 2;
break;
4175 case 7: result = 6;
break;
4176 case 8: result = 3;
break;
4177 case 9: result = 2;
break;
4182 if (qAbs(fracPart-0.5) < epsilon)
4186 case 1: result = 2;
break;
4187 case 2: result = 4;
break;
4188 case 3: result = 4;
break;
4189 case 4: result = 2;
break;
4190 case 5: result = 4;
break;
4191 case 6: result = 4;
break;
4192 case 7: result = 2;
break;
4193 case 8: result = 4;
break;
4194 case 9: result = 4;
break;
4213 int lowTick, highTick;
4219 int zeroLineIndex = -1;
4225 for (
int i=lowTick; i <= highTick; ++i)
4241 for (
int i=lowTick; i <= highTick; ++i)
4243 if (i == zeroLineIndex)
continue;
4251 int zeroLineIndex = -1;
4257 for (
int i=lowTick; i <= highTick; ++i)
4273 for (
int i=lowTick; i <= highTick; ++i)
4275 if (i == zeroLineIndex)
continue;
4335 int xCor = 0, yCor = 0;
4342 int lowTick, highTick;
4350 painter->drawLine(origin+QPoint(xCor, yCor), origin+QPoint(
mAxisRect.width()+xCor, yCor));
4352 painter->drawLine(origin+QPoint(xCor, yCor), origin+QPoint(xCor, -
mAxisRect.height()+yCor));
4362 for (
int i=lowTick; i <= highTick; ++i)
4369 for (
int i=lowTick; i <= highTick; ++i)
4402 QSize tickLabelsSize;
4407 for (
int i=lowTick; i <= highTick; ++i)
4414 margin += tickLabelsSize.height();
4416 margin += tickLabelsSize.width();
4424 bounds = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip,
mLabel);
4427 QTransform oldTransform = painter->transform();
4428 painter->translate((origin.x()-margin-bounds.height()), origin.y());
4429 painter->rotate(-90);
4430 painter->drawText(0, 0,
mAxisRect.height(), bounds.height(), Qt::TextDontClip | Qt::AlignCenter,
mLabel);
4431 painter->setTransform(oldTransform);
4435 QTransform oldTransform = painter->transform();
4436 painter->translate((origin.x()+margin+bounds.height()), origin.y()-
mAxisRect.height());
4437 painter->rotate(90);
4438 painter->drawText(0, 0,
mAxisRect.height(), bounds.height(), Qt::TextDontClip | Qt::AlignCenter,
mLabel);
4439 painter->setTransform(oldTransform);
4442 painter->drawText(origin.x(), origin.y()-margin-bounds.height(),
mAxisRect.width(), bounds.height(), Qt::TextDontClip | Qt::AlignCenter,
mLabel);
4444 painter->drawText(origin.x(), origin.y()+margin,
mAxisRect.width(), bounds.height(), Qt::TextDontClip | Qt::AlignCenter,
mLabel);
4468 void QCPAxis::drawTickLabel(QPainter *painter,
double position,
int distanceToAxis,
const QString &text, QSize *tickLabelsSize)
4473 bool useBeautifulPowers =
false;
4477 ePos = text.indexOf(
'e');
4479 useBeautifulPowers =
true;
4483 QRect bounds, baseBounds, expBounds;
4484 QString basePart, expPart;
4486 if (useBeautifulPowers)
4489 basePart = text.left(ePos);
4495 expPart = text.mid(ePos+1);
4497 while (expPart.at(1) ==
'0' && expPart.length() > 2)
4498 expPart.remove(1, 1);
4500 expPart.remove(0, 1);
4502 expFont = painter->font();
4503 expFont.setPointSize(expFont.pointSize()*0.75);
4505 baseBounds = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip, basePart);
4506 QFontMetrics expFontMetrics(expFont);
4507 expBounds = expFontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip, expPart);
4508 bounds = baseBounds.adjusted(0, 0, expBounds.width(), 0);
4511 bounds = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter, text);
4515 QRect rotatedBounds = bounds;
4518 QTransform transform;
4520 rotatedBounds = transform.mapRect(bounds);
4523 if (rotatedBounds.width() > tickLabelsSize->width())
4524 tickLabelsSize->setWidth(rotatedBounds.width());
4525 if (rotatedBounds.height() > tickLabelsSize->height())
4526 tickLabelsSize->setHeight(rotatedBounds.height());
4543 x =
mAxisRect.left()-cos(angle)*bounds.width()-distanceToAxis;
4544 y = position-sin(angle)*bounds.width()-cos(angle)*bounds.height()/2.0;
4547 x =
mAxisRect.left()-cos(-angle)*bounds.width()-sin(-angle)*bounds.height()-distanceToAxis;
4548 y = position+sin(-angle)*bounds.width()-cos(-angle)*bounds.height()/2.0;
4552 x =
mAxisRect.left()-bounds.width()-distanceToAxis;
4553 y = position-bounds.height()/2.0;
4561 x =
mAxisRect.right()+sin(angle)*bounds.height()+distanceToAxis;
4562 y = position-cos(angle)*bounds.height()/2.0;
4566 y = position-cos(-angle)*bounds.height()/2.0;
4571 y = position-bounds.height()/2.0;
4579 x = position-cos(angle)*bounds.width()+sin(angle)*bounds.height()/2.0;
4580 y =
mAxisRect.top()-sin(angle)*bounds.width()-cos(angle)*bounds.height()-distanceToAxis;
4583 x = position-sin(-angle)*bounds.height()/2.0;
4584 y =
mAxisRect.top()-cos(-angle)*bounds.height()-distanceToAxis;
4588 x = position-bounds.width()/2.0;
4589 y =
mAxisRect.top()-bounds.height()-distanceToAxis;
4597 x = position+sin(angle)*bounds.height()/2.0;
4601 x = position-cos(-angle)*bounds.width()-sin(-angle)*bounds.height()/2.0;
4602 y =
mAxisRect.bottom()+sin(-angle)*bounds.width()+distanceToAxis;
4606 x = position-bounds.width()/2.0;
4625 QTransform oldTransform = painter->transform();
4626 painter->translate(x, y);
4630 if (useBeautifulPowers)
4633 painter->drawText(0, 0, 0, 0, Qt::TextDontClip, basePart);
4635 painter->setFont(expFont);
4636 painter->drawText(baseBounds.width()+1, 0, expBounds.width(), expBounds.height(), Qt::TextDontClip, expPart);
4640 painter->drawText(0, 0, bounds.width(), bounds.height(), Qt::TextDontClip | Qt::AlignHCenter, text);
4644 painter->setTransform(oldTransform);
4661 bool useBeautifulPowers =
false;
4667 useBeautifulPowers =
true;
4671 QRect bounds, baseBounds, expBounds;
4672 QString basePart, expPart;
4674 if (useBeautifulPowers)
4677 basePart = text.left(ePos);
4683 expPart = text.mid(ePos+1);
4685 while (expPart.at(1) ==
'0' && expPart.length() > 2)
4686 expPart.remove(1, 1);
4688 expPart.remove(0, 1);
4691 expFont.setPointSize(expFont.pointSize()*0.75);
4693 QFontMetrics baseFontMetrics(font);
4694 baseBounds = baseFontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip, basePart);
4695 QFontMetrics expFontMetrics(expFont);
4696 expBounds = expFontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip, expPart);
4697 bounds = baseBounds.adjusted(0, 0, expBounds.width(), 0);
4700 QFontMetrics fontMetrics(font);
4701 bounds = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter, text);
4705 QRect rotatedBounds = bounds;
4708 QTransform transform;
4710 rotatedBounds = transform.mapRect(bounds);
4713 if (rotatedBounds.width() > tickLabelsSize->width())
4714 tickLabelsSize->setWidth(rotatedBounds.width());
4715 if (rotatedBounds.height() > tickLabelsSize->height())
4716 tickLabelsSize->setHeight(rotatedBounds.height());
4788 int lowTick, highTick;
4794 QSize tickLabelsSize(0, 0);
4797 for (
int i=lowTick; i <= highTick; ++i)
4812 bounds = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter | Qt::AlignVCenter,
mLabel);
4842 QCustomPlot::QCustomPlot(QWidget *parent) :
4845 setMouseTracking(
true);
4846 QLocale currentLocale = locale();
4847 currentLocale.setNumberOptions(QLocale::OmitGroupSeparator);
4848 setLocale(currentLocale);
4850 buffer = QPixmap(size());
4854 titleFont.setPointSize(14);
4855 titleFont.setBold(
true);
4856 setTitleFont(titleFont);
4858 setColor(Qt::white);
4859 setAntialiasedElements(AEGraphs | AEScatters | AEFills);
4861 legend->setVisible(
false);
4862 setAutoAddPlottableToLegend(
true);
4867 xAxis2->setGrid(
false);
4868 yAxis2->setGrid(
false);
4869 xAxis2->setZeroLinePen(Qt::NoPen);
4870 yAxis2->setZeroLinePen(Qt::NoPen);
4871 xAxis2->setVisible(
false);
4872 yAxis2->setVisible(
false);
4873 setAxisBackground(QPixmap());
4874 setAxisBackgroundScaled(
true);
4875 setAxisBackgroundScaledMode(Qt::KeepAspectRatioByExpanding);
4877 setRangeDragAxes(xAxis, yAxis);
4878 setRangeZoomAxes(xAxis, yAxis);
4881 setRangeZoomFactor(0.85);
4883 setMargin(0, 0, 0, 0);
4884 setAutoMargin(
true);
4888 QCustomPlot::~QCustomPlot()
5217 qDebug() <<
FUNCNAME <<
"index out of bounds:" << index;
5262 qDebug() <<
FUNCNAME <<
"plottable either already in list or not created with this QCustomPlot as parent:" <<
plottable;
5305 qDebug() <<
FUNCNAME <<
"index out of bounds:" << index;
5320 for (
int i=c-1; i >= 0; --i)
5345 if (index >= 0 && index <
mGraphs.size())
5350 qDebug() <<
FUNCNAME <<
"index out of bounds:" << index;
5385 if (!keyAxis) keyAxis =
xAxis;
5386 if (!valueAxis) valueAxis =
yAxis;
5419 if (index >= 0 && index <
mGraphs.size())
5433 for (
int i=c-1; i >= 0; --i)
5454 QPainter painter(&
buffer);
5455 if (!painter.isActive())
5457 qDebug() <<
FUNCNAME <<
"Couldn't activate painter on buffer";
5460 painter.fillRect(rect(),
mColor);
5566 int newWidth, newHeight;
5567 if (width == 0 || height == 0)
5569 newWidth = this->width();
5570 newHeight = this->height();
5577 QPrinter printer(QPrinter::ScreenResolution);
5578 printer.setOutputFileName(fileName);
5579 printer.setFullPage(
true);
5581 mViewport = QRect(0, 0, newWidth, newHeight);
5583 printer.setPaperSize(
mViewport.size(), QPrinter::DevicePixel);
5584 QPainter printpainter(&printer);
5586 printpainter.setRenderHint(QPainter::NonCosmeticDefaultPen, noCosmeticPen);
5587 draw(&printpainter);
5627 int newWidth, newHeight;
5628 if (width == 0 || height == 0)
5630 newWidth = this->width();
5631 newHeight = this->height();
5638 QPixmap pngBuffer(newWidth, newHeight);
5639 QPainter painter(&pngBuffer);
5640 painter.fillRect(pngBuffer.rect(),
mColor);
5642 mViewport = QRect(0, 0, newWidth, newHeight);
5647 pngBuffer.save(fileName);
5674 int newWidth, newHeight;
5675 if (width == 0 || height == 0)
5677 newWidth = this->width();
5678 newHeight = this->height();
5685 int scaledWidth = scale*newWidth;
5686 int scaledHeight = scale*newHeight;
5688 QPixmap pngBuffer(scaledWidth, scaledHeight);
5689 QPainter painter(&pngBuffer);
5690 painter.setRenderHint(QPainter::NonCosmeticDefaultPen);
5691 painter.fillRect(pngBuffer.rect(),
mColor);
5693 mViewport = QRect(0, 0, newWidth, newHeight);
5695 painter.scale(scale, scale);
5699 pngBuffer.save(fileName);
5711 QPainter painter(
this);
5712 painter.drawPixmap(0, 0,
buffer);
5725 buffer = QPixmap(event->size());
5752 if (event->buttons() & Qt::LeftButton)
5854 double wheelSteps =
event->delta()/120.0;
5883 titleBounds = painter->fontMetrics().boundingRect(0, 0, titleBounds.width(), titleBounds.height(), Qt::TextDontClip | Qt::AlignHCenter | Qt::AlignVCenter,
mTitle);
6093 mParentPlot(keyAxis->parentPlot()),
6097 mBrush(Qt::NoBrush),
6099 mValueAxis(valueAxis)
6102 qDebug() <<
FUNCNAME <<
"Parent plot of keyAxis is not the same as that of valueAxis.";
6104 qDebug() <<
FUNCNAME <<
"keyAxis and valueAxis must be orthogonal to each other.";
6369 mParentLegend(parent),
6370 mFont(parent->font())
6420 mPlottable(plottable)
6454 painter->setFont(
mFont);
6456 QRect iconRect(rect.topLeft(),
mIconSize);
6461 if (textRect.height() <
mIconSize.height())
6471 textRect = painter->fontMetrics().boundingRect(0, 0, 0, rect.height(), Qt::TextDontClip,
mPlottable->
name());
6472 if (textRect.height() <
mIconSize.height())
6482 painter->setClipRect(iconRect, Qt::IntersectClip);
6489 painter->setBrush(Qt::NoBrush);
6490 painter->drawRect(iconRect);
6510 QFontMetrics fontMetrics(
mFont);
6521 result.setHeight(qMax(textRect.height(),
mIconSize.height()));
6564 mPen.setColor(Qt::blue);
6565 mPen.setStyle(Qt::SolidLine);
6566 mBrush.setColor(Qt::blue);
6567 mBrush.setStyle(Qt::NoBrush);
6600 void QCPCurve::setData(
const QVector<double> &t,
const QVector<double> &key,
const QVector<double> &value)
6604 n = qMin(n, key.size());
6605 n = qMin(n, value.size());
6607 for (
int i=0; i<n; ++i)
6610 newData.key = key[i];
6611 newData.value = value[i];
6612 mData->insertMulti(newData.t, newData);
6625 n = qMin(n, value.size());
6627 for (
int i=0; i<n; ++i)
6630 newData.key = key[i];
6631 newData.value = value[i];
6632 mData->insertMulti(newData.t, newData);
6642 mData->unite(dataMap);
6651 mData->insertMulti(data.
t, data);
6663 newData.
value = value;
6664 mData->insertMulti(newData.
t, newData);
6678 if (!
mData->isEmpty())
6679 newData.
t = (
mData->constEnd()-1).key()+1;
6683 newData.
value = value;
6684 mData->insertMulti(newData.
t, newData);
6691 void QCPCurve::addData(
const QVector<double> &ts,
const QVector<double> &keys,
const QVector<double> &values)
6694 n = qMin(n, keys.size());
6695 n = qMin(n, values.size());
6697 for (
int i=0; i<n; ++i)
6700 newData.key = keys[i];
6701 newData.value = values[i];
6702 mData->insertMulti(newData.t, newData);
6712 QCPCurveDataMap::iterator it =
mData->begin();
6713 while (it !=
mData->end() && it.key() < t)
6714 it =
mData->erase(it);
6723 if (
mData->isEmpty())
return;
6724 QCPCurveDataMap::iterator it =
mData->upperBound(t);
6725 while (it !=
mData->end())
6726 it =
mData->erase(it);
6738 if (fromt >= tot ||
mData->isEmpty())
return;
6739 QCPCurveDataMap::iterator it =
mData->upperBound(fromt);
6740 QCPCurveDataMap::iterator itEnd =
mData->upperBound(tot);
6742 it =
mData->erase(it);
6772 if (
mData->isEmpty())
return;
6776 QVector<QPointF> *lineData =
new QVector<QPointF>;
6780 if (
mBrush.style() != Qt::NoBrush &&
mBrush.color().alpha() != 0)
6783 painter->setPen(Qt::NoPen);
6784 painter->setBrush(
mBrush);
6785 painter->drawPolygon(QPolygonF(*lineData));
6788 if (
mPen.style() != Qt::NoPen &&
mPen.color().alpha() != 0)
6791 painter->setPen(
mPen);
6792 painter->setBrush(Qt::NoBrush);
6793 painter->drawPolyline(QPolygonF(*lineData));
6803 if (
mBrush.style() != Qt::NoBrush)
6806 painter->fillRect(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0,
mBrush);
6810 painter->setPen(
mPen);
6811 painter->drawLine(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0);
6828 lineData->reserve(
mData->size());
6829 QCPCurveDataMap::const_iterator it;
6831 int currentRegion = 5;
6837 bool addedLastAlready =
true;
6838 bool firstPoint =
true;
6839 for (it =
mData->constBegin(); it !=
mData->constEnd(); ++it)
6842 y = it.value().value;
6848 else if (y < RBottom)
6852 }
else if (x > RRight)
6856 else if (y < RBottom)
6864 else if (y < RBottom)
6877 if (currentRegion == 5 || (firstPoint &&
mBrush.style() != Qt::NoBrush))
6879 if (!addedLastAlready)
6880 lineData->append(
coordsToPixels((it-1).value().key, (it-1).value().value));
6881 else if (lastRegion != 5)
6884 lineData->replace(lineData->size()-1,
coordsToPixels((it-1).value().key, (it-1).value().value));
6886 lineData->append(
coordsToPixels(it.value().key, it.value().value));
6887 addedLastAlready =
true;
6888 }
else if (currentRegion != lastRegion)
6893 if (lastRegion == 5 ||
6894 ((lastRegion==2 && currentRegion==4) || (lastRegion==4 && currentRegion==2)) ||
6895 ((lastRegion==4 && currentRegion==8) || (lastRegion==8 && currentRegion==4)) ||
6896 ((lastRegion==8 && currentRegion==6) || (lastRegion==6 && currentRegion==8)) ||
6897 ((lastRegion==6 && currentRegion==2) || (lastRegion==2 && currentRegion==6))
6901 if (!addedLastAlready)
6902 lineData->append(
coordsToPixels((it-1).value().key, (it-1).value().value));
6904 lineData->append(
coordsToPixels(it.value().key, it.value().value));
6908 if (!addedLastAlready)
6913 addedLastAlready =
true;
6916 addedLastAlready =
false;
6918 lastRegion = currentRegion;
6922 if (lastRegion != 5 &&
mBrush.style() != Qt::NoBrush && !
mData->isEmpty())
6943 case 2: result.setX(axisRect.left()-margin);
break;
6944 case 8: result.setX(axisRect.right()+margin);
break;
6945 case 4: result.setY(axisRect.top()-margin);
break;
6946 case 6: result.setY(axisRect.bottom()+margin);
break;
6947 case 1: result.setX(axisRect.left()-margin);
6948 result.setY(axisRect.top()-margin);
break;
6949 case 7: result.setX(axisRect.right()+margin);
6950 result.setY(axisRect.top()-margin);
break;
6951 case 9: result.setX(axisRect.right()+margin);
6952 result.setY(axisRect.bottom()+margin);
break;
6953 case 3: result.setX(axisRect.left()-margin);
6954 result.setY(axisRect.bottom()+margin);
break;
6963 bool haveLower =
false;
6964 bool haveUpper =
false;
6968 QCPCurveDataMap::const_iterator it =
mData->constBegin();
6969 while (it !=
mData->constEnd())
6971 current = it.value().key;
6974 if (current < range.
lower || !haveLower)
6976 range.
lower = current;
6979 if (current > range.
upper || !haveUpper)
6981 range.
upper = current;
6988 validRange = haveLower && haveUpper;
6996 bool haveLower =
false;
6997 bool haveUpper =
false;
7001 QCPCurveDataMap::const_iterator it =
mData->constBegin();
7002 while (it !=
mData->constEnd())
7004 current = it.value().value;
7007 if (current < range.
lower || !haveLower)
7009 range.
lower = current;
7012 if (current > range.
upper || !haveUpper)
7014 range.
upper = current;
7021 validRange = haveLower && haveUpper;
7087 mPen.setColor(Qt::blue);
7088 mPen.setStyle(Qt::SolidLine);
7089 mBrush.setColor(QColor(40, 50, 255, 30));
7090 mBrush.setStyle(Qt::SolidPattern);
7138 n = qMin(n, value.size());
7140 for (
int i=0; i<n; ++i)
7142 newData.
key = key[i];
7143 newData.value = value[i];
7144 mData->insertMulti(newData.key, newData);
7164 if (bars ==
this)
return;
7167 qDebug() <<
FUNCNAME <<
"passed QCPBars* doesn't have same key and value axis as this QCPBars";
7197 if (bars ==
this)
return;
7200 qDebug() <<
FUNCNAME <<
"passed QCPBars* doesn't have same key and value axis as this QCPBars";
7220 mData->unite(dataMap);
7229 mData->insertMulti(data.
key, data);
7240 newData.
value = value;
7241 mData->insertMulti(newData.
key, newData);
7250 int n = keys.size();
7251 n = qMin(n, values.size());
7253 for (
int i=0; i<n; ++i)
7255 newData.
key = keys[i];
7256 newData.value = values[i];
7257 mData->insertMulti(newData.key, newData);
7267 QCPBarDataMap::iterator it =
mData->begin();
7268 while (it !=
mData->end() && it.key() < key)
7269 it =
mData->erase(it);
7278 if (
mData->isEmpty())
return;
7279 QCPBarDataMap::iterator it =
mData->upperBound(key);
7280 while (it !=
mData->end())
7281 it =
mData->erase(it);
7293 if (fromKey >= toKey ||
mData->isEmpty())
return;
7294 QCPBarDataMap::iterator it =
mData->upperBound(fromKey);
7295 QCPBarDataMap::iterator itEnd =
mData->upperBound(toKey);
7297 it =
mData->erase(it);
7328 QCPBarDataMap::const_iterator it;
7329 for (it =
mData->constBegin(); it !=
mData->constEnd(); ++it)
7333 QPolygonF barPolygon =
getBarPolygon(it.key(), it.value().value);
7335 if (
mBrush.style() != Qt::NoBrush &&
mBrush.color().alpha() != 0)
7338 painter->setPen(Qt::NoPen);
7339 painter->setBrush(
mBrush);
7340 painter->drawPolygon(barPolygon);
7343 if (
mPen.style() != Qt::NoPen &&
mPen.color().alpha() != 0)
7346 painter->setPen(
mPen);
7347 painter->setBrush(Qt::NoBrush);
7348 painter->drawPolyline(barPolygon);
7357 painter->setBrush(
mBrush);
7358 painter->setPen(
mPen);
7360 QRect r = QRect(0, 0, rect.width()*0.67, rect.height()*0.67);
7361 r.moveCenter(rect.center());
7362 painter->drawRect(r);
7400 if ((positive && it.value().value > max) ||
7401 (!positive && it.value().value < max))
7402 max = it.value().value;
7421 if (!lower && !upper)
return;
7452 bool haveLower =
false;
7453 bool haveUpper =
false;
7456 double barWidthHalf =
mWidth*0.5;
7457 QCPBarDataMap::const_iterator it =
mData->constBegin();
7458 while (it !=
mData->constEnd())
7460 current = it.value().key;
7461 if (inSignDomain ==
SDBoth || (inSignDomain ==
SDNegative && current+barWidthHalf < 0) || (inSignDomain ==
SDPositive && current-barWidthHalf > 0))
7463 if (current-barWidthHalf < range.
lower || !haveLower)
7465 range.
lower = current-barWidthHalf;
7468 if (current+barWidthHalf > range.
upper || !haveUpper)
7470 range.
upper = current+barWidthHalf;
7477 validRange = haveLower && haveUpper;
7485 bool haveLower =
true;
7486 bool haveUpper =
true;
7490 QCPBarDataMap::const_iterator it =
mData->constBegin();
7491 while (it !=
mData->constEnd())
7493 current = it.value().value +
getBaseValue(it.value().key, it.value().value >= 0);
7496 if (current < range.
lower || !haveLower)
7498 range.
lower = current;
7501 if (current > range.
upper || !haveUpper)
7503 range.
upper = current;
7510 validRange = !qFuzzyCompare(range.
lower+1.0, range.
upper+1.0);
7587 whiskerPen.setStyle(Qt::DashLine);
7588 whiskerPen.setCapStyle(Qt::FlatCap);
7593 medianPen.setWidthF(3);
7594 medianPen.setCapStyle(Qt::FlatCap);
7601 outlierPen.setColor(Qt::blue);
7819 painter->setPen(
mPen);
7820 painter->setBrush(
mBrush);
7821 QRect r = QRect(0, 0, rect.width()*0.67, rect.height()*0.67);
7822 r.moveCenter(rect.center());
7823 painter->drawRect(r);
7835 painter->setPen(
mPen);
7836 painter->setBrush(
mBrush);
7837 painter->drawRect(box);
7850 painter->drawLine(medianLine);
7859 QLineF backboneMin, backboneMax, barMin, barMax;
7865 painter->drawLine(backboneMin);
7866 painter->drawLine(backboneMax);
7868 painter->drawLine(barMin);
7869 painter->drawLine(barMax);
7888 if (inSignDomain ==
SDBoth)
7921 if (inSignDomain ==
SDBoth)
7932 validRange = upper > lower;
7936 QVector<double> values;
7941 bool haveUpper =
false;
7942 bool haveLower =
false;
7945 for (
int i=0; i<values.size(); ++i)
7947 if ((inSignDomain ==
SDNegative && values.at(i) < 0) ||
7948 (inSignDomain ==
SDPositive && values.at(i) > 0))
7950 if (values.at(i) > upper || !haveUpper)
7952 upper = values.at(i);
7955 if (values.at(i) < lower || !haveLower)
7957 lower = values.at(i);
7963 if (haveLower && haveUpper && !qFuzzyCompare(upper+1.0, lower+1.0))
a square which is not filled, with a plus inside
void setOutliers(const QVector< double > &values)
Error bars for the key dimension of the data point are shown.
QList< QCPGraph * > mGraphs
QCPGraph * addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0)
QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis)
void setWhiskerBarPen(const QPen &pen)
Legend is positioned in the bottom right corner of the axis rect with distance to the border correspo...
static const double maxRange
Axis is vertical and on the right side of the axis rect of the parent QCustomPlot.
void setLineStyle(int ls)
line is drawn as steps where the step height is the value of the right data point ...
void setDateTimeFormat(const QString &format)
int plottableCount() const
void setAutoTickLabels(bool on)
QVector< double > * mSubTickVector
Legend is horizontally centered at the top of the axis rect with distance to the border corresponding...
void setRangeZoomFactor(double horizontalFactor, double verticalFactor)
void setScaleRatio(const QCPAxis *otherAxis, double ratio=1.0)
QMap< double, QCPData > QCPDataMap
line is drawn as steps where the step is in between two data points
QCPAxis(QCustomPlot *parentPlot, AxisType type)
A class holding the data of one single data point for QCPCurve.
void mouseMove(QMouseEvent *event)
virtual int calculateAutoSubTickCount(double tickStep) const
void rescaleKeyAxis(bool onlyEnlarge=false) const
bool mNumberBeautifulPowers
void setAutoMargin(bool enabled)
A legend item representing a plottable with an icon and the plottable name.
QCPGraph * mChannelFillGraph
void setIconTextPadding(int padding)
Qt::Orientations mRangeDrag
a square which is not filled, with a cross inside
virtual void rescaleValueAxis(bool onlyEnlarge, bool includeErrorBars) const
void setMedianPen(const QPen &pen)
void getScatterPlotData(QVector< QCPData > *pointData) const
void visibleTickBounds(int &lowIndex, int &highIndex) const
virtual void mouseMoveEvent(QMouseEvent *event)
a circle which is filled with the color of the graph's pen (not the brush!)
void setBasePen(const QPen &pen)
void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical)
The abstract base class for all items in a QCPLegend.
bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const
const QCPDataMap * data() const
void setPositionStyle(PositionStyle legendPositionStyle)
virtual void draw(QPainter *painter) const
void setMarginBottom(int margin)
void setName(const QString &name)
void setPaddingRight(int padding)
void setRangeReversed(bool reversed)
QPointF upperFillBasePoint(double upperKey) const
void setAxisRect(const QRect &arect)
bool mNumberMultiplyCross
void setWhiskerWidth(double width)
virtual int calculateMargin() const
const QCPRange range() const
void drawScatter(QPainter *painter, double x, double y, ScatterStyle style) const
virtual void wheelEvent(QWheelEvent *event)
void getImpulsePlotData(QVector< QPointF > *lineData, QVector< QCPData > *pointData) const
void removeDataBefore(double key)
virtual void generateTickVectors()
void setTickLabels(bool show)
QFlags< AntialiasedElement > mAntialiasedElements
void setBrush(const QBrush &brush)
bool mAxisBackgroundScaled
void setRange(double lower, double upper)
void setLowerQuartile(double value)
void setRangeDrag(Qt::Orientations orientations)
void mouseRelease(QMouseEvent *event)
void setWhiskerPen(const QPen &pen)
void setAutoTickStep(bool on)
int findIndexAboveY(const QVector< QPointF > *data, double y) const
void setSubTickCount(int count)
void rangeChanged(const QCPRange &newRange)
void mousePressOnLegendItem(QMouseEvent *event, QVariant itemIdx)
void setAutoTicks(bool on)
void mouseDoubleClick(QMouseEvent *event)
void setMarginLeft(int margin)
void setPosition(const QPoint &pixelPosition)
static bool validRange(double lower, double upper)
void setAutoSubTicks(bool on)
void setValueAxis(QCPAxis *axis)
void setPadding(int padding)
A plottable representing a bar chart in a plot.
virtual void rescaleKeyAxis(bool onlyEnlarge, bool includeErrorBars) const
bool removeGraph(QCPGraph *graph)
QCustomPlot * parentPlot() const
QCustomPlot * mParentPlot
void setAxisRect(const QRect &rect)
void setWidth(double width)
void moveAbove(QCPBars *bars)
virtual void mousePressEvent(QMouseEvent *event)
void moveBelow(QCPBars *bars)
void setScaleLogBase(double base)
void setRangeUpper(double upper)
virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=SDBoth) const
int getItemIndex(const QPoint *point)
void setMarginBottom(int margin)
void drawFill(QPainter *painter, QVector< QPointF > *lineData) const
virtual void draw(QPainter *painter)
void setTickLabelRotation(double degrees)
virtual ~QCPStatisticalBox()
QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis)
void setRangeZoom(Qt::Orientations orientations)
void setZeroLinePen(const QPen &pen)
void setSize(const QSize &size)
void setFont(const QFont &font)
double mTickLabelRotation
Legend is positioned in the top left corner of the axis rect with distance to the border correspondin...
void setWidth(double width)
QCPAxis * mRangeZoomHorzAxis
void setGridPen(const QPen &pen)
void removeDataBefore(double key)
virtual void drawMedian(QPainter *painter) const
The abstract base class for all data representing objects in a plot.
void savePngScaled(const QString &fileName, double scale, int width=0, int height=0)
void getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper, int &count) const
QCPRange sanitizedForLogScale() const
Both sign domains, including zero, i.e. all (rational) numbers.
an equilateral triangle which is not filled, standing on corner
void setAutoTickCount(int approximateCount)
QPointF outsideCoordsToPixels(double key, double value, int region) const
void removeData(double fromt, double tot)
QPointF lowerFillBasePoint(double lowerKey) const
QCPAxis * mRangeDragHorzAxis
void removeDataAfter(double t)
void setErrorBarSize(double size)
void setTickLabelFont(const QFont &font)
void setMarginRight(int margin)
PositionStyle mPositionStyle
virtual void drawLegendIcon(QPainter *painter, const QRect &rect) const
A plottable representing a graph in a plot.
int iconTextPadding() const
QCPAbstractLegendItem(QCPLegend *parent)
double mRangeZoomFactorHorz
void getStepCenterPlotData(QVector< QPointF > *lineData, QVector< QCPData > *pointData) const
void mousePressOnPlotArea(QMouseEvent *event)
void setRangeLower(double lower)
The central class which is also the QWidget which displays the plot and interacts with the user...
Qt::AspectRatioMode mAxisBackgroundScaledMode
void drawLinePlot(QPainter *painter, QVector< QPointF > *lineData) const
void setMedian(double value)
void setMinimum(double value)
Manages a single axis inside a QCustomPlot.
void setTickPen(const QPen &pen)
void setMaximum(double value)
int findIndexAboveX(const QVector< QPointF > *data, double x) const
Legend is positioned in the top right corner of the axis rect with distance to the border correspondi...
Manages a legend inside a QCustomPlot.
QCPRange mDragStartVertRange
a circle which is not filled, with one vertical and two downward diagonal lines
virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=SDBoth) const
bool addPlottable(QCPAbstractPlottable *plottable)
QCPAbstractPlottable * plottable()
void removeData(double fromKey, double toKey)
void setAxisType(AxisType type)
virtual void drawQuartileBox(QPainter *painter) const
virtual void calculateAutoPosition()
void addData(const QCPCurveDataMap &dataMap)
void setKeyAxis(QCPAxis *axis)
void savePng(const QString &fileName, int width=0, int height=0)
QPolygonF getBarPolygon(double key, double value) const
a circle which is not filled
Qt::Orientation orientation() const
ScatterStyle mScatterStyle
Tick coordinate is regarded as a date/time (seconds since 1970-01-01T00:00:00 UTC, see QDateTime::toTime_t) and will be displayed and formatted as such. (see setDateTimeFormat)
void mousePress(QMouseEvent *event)
void setFont(const QFont &font)
Legend is horizontally centered at the bottom of the axis rect with distance to the border correspond...
int findIndexBelowX(const QVector< QPointF > *data, double x) const
QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis)
virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=SDBoth) const
virtual QSize size(const QSize &targetSize) const
an equilateral triangle which is not filled, standing on baseline
double getBaseValue(double key, bool positive) const
QCPAxis * keyAxis() const
void setDataBothError(const QVector< double > &key, const QVector< double > &value, const QVector< double > &keyError, const QVector< double > &valueError)
void setPen(const QPen &pen)
void setUpperQuartile(double value)
const QCPBarDataMap * data() const
void setOutlierBrush(const QBrush &brush)
int findIndexBelowY(const QVector< QPointF > *data, double y) const
virtual bool removeFromLegend() const
QMap< double, QCPBarData > QCPBarDataMap
void removeData(double fromKey, double toKey)
a square which is not filled
virtual void drawLegendIcon(QPainter *painter, const QRect &rect) const
bool autoSubTicks() const
double scaleLogBase() const
virtual void drawLegendIcon(QPainter *painter, const QRect &rect) const
Axis is horizontal and on the bottom side of the axis rect of the parent QCustomPlot.
void removeFillBasePoints(QVector< QPointF > *lineData) const
virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=SDBoth) const =0
Legend is vertically centered at the left of the axis rect with distance to the border corresponding ...
A class holding the data of one single data point for QCPGraph.
QCPPlottableLegendItem(QCPLegend *parent, const QCPAbstractPlottable *plottable)
virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=SDBoth) const =0
void setSubGridPen(const QPen &pen)
QList< QCPAbstractPlottable * > mPlottables
QCPAxis * rangeDragAxis(Qt::Orientation orientation)
void setTickLength(int inside, int outside=0)
line is drawn as steps where the step height is the value of the left data point
Legend is vertically centered at the right of the axis rect with distance to the border corresponding...
void setScatterSize(double size)
void coordsToPixels(double key, double value, double &x, double &y) const
void setErrorBarSkipSymbol(bool enabled)
void setTextWrap(bool wrap)
void getPlotData(QVector< QPointF > *lineData, QVector< QCPData > *pointData) const
void setTitleFont(const QFont &font)
Logarithmic scaling with correspondingly transformed plots and (major) tick marks at every base power...
data points are represented by a straight line parallel to the value axis, which ranges down/up to th...
QPixmap mScaledAxisBackground
virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const
void setScatterPixmap(const QPixmap &pixmap)
void setIconBorderPen(const QPen &pen)
const QCPCurveDataMap * data() const
virtual void drawSubGrid(QPainter *painter)
void setAutoSize(bool on)
Qt::Orientation mOrientation
void setScaleType(ScaleType type)
virtual void drawWhiskers(QPainter *painter) const
void setNumberPrecision(int precision)
static const double minRange
void removeDataBefore(double t)
virtual void drawLegendIcon(QPainter *painter, const QRect &rect) const =0
QVector< double > mOutliers
void setTickVectorLabels(QVector< QString > *vec, bool copy=false)
void rescaleAxes(bool onlyEnlarge=false) const
bool autoTickStep() const
void setData(QCPBarDataMap *data, bool copy=false)
static void connectBars(QCPBars *lower, QCPBars *upper)
bool rangeReversed() const
QCustomPlot * parentPlot() const
void setPaddingBottom(int padding)
bool mAutoAddPlottableToLegend
The negative sign domain, i.e. numbers smaller than zero.
void scaleRange(double factor, double center)
void getCurveData(QVector< QPointF > *lineData) const
void setData(QCPCurveDataMap *data, bool copy=false)
double baseLog(double value) const
void rescaleValueAxis(bool onlyEnlarge=false) const
Qt::Orientations mRangeZoom
QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis)
virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=SDBoth) const
void setDataKeyError(const QVector< double > &key, const QVector< double > &value, const QVector< double > &keyError)
virtual bool addToLegend() const
void setPaddingTop(int padding)
Axis is horizontal and on the top side of the axis rect of the parent QCustomPlot.
double pixelToCoord(double value) const
Error bars for both key and value dimensions of the data point are shown.
virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=SDBoth) const
void addData(const QCPBarDataMap &dataMap)
void setColor(const QColor &color)
void setTickStep(double step)
const AntialiasedElements antialiasedElements() const
void setTickLabelType(LabelType type)
QVector< double > * mTickVector
double mScaleLogBaseLogInv
void removeDataAfter(double key)
bool hasItem(QCPAbstractLegendItem *item) const
void getLinePlotData(QVector< QPointF > *lineData, QVector< QCPData > *pointData) const
Error bars for the value dimension of the data point are shown.
void moveRange(double diff)
void setLabelFont(const QFont &font)
virtual void mouseDoubleClickEvent(QMouseEvent *event)
virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=SDBoth) const
void setData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum)
void setSubTickPen(const QPen &pen)
void setTickVector(QVector< double > *vec, bool copy=false)
void addFillBasePoints(QVector< QPointF > *lineData) const
void setNumberFormat(const QString &formatCode)
void setMargin(int left, int right, int top, int bottom)
virtual void rescaleAxes(bool onlyEnlarge, bool includeErrorBars) const
QCPAxis * mRangeDragVertAxis
ErrorType errorType() const
QCPRange sanitizedForLinScale() const
void setItemSpacing(int spacing)
void setMarginTop(int margin)
double rangeZoomFactor(Qt::Orientation orientation)
double basePow(double value) const
void setMarginTop(int margin)
QCPRange mDragStartHorzRange
QCustomPlot * mParentPlot
int autoTickCount() const
Tick coordinate is regarded as normal number and will be displayed as such. (see setNumberFormat) ...
QCPAbstractLegendItem * item(int index) const
QString numberFormat() const
void setErrorType(ErrorType errorType)
a circle which is not filled, with a plus inside
void mouseWheel(QWheelEvent *event)
bool addItem(QCPAbstractLegendItem *item)
void setVisible(bool visible)
void setDataValueError(const QVector< double > &key, const QVector< double > &value, const QVector< double > &valueError)
void setTickLabelPadding(int padding)
virtual void resizeEvent(QResizeEvent *event)
virtual QCPRange getKeyRange(bool &validRange, SignDomain inSignDomain=SDBoth) const
double mRangeZoomFactorVert
void setBrush(const QBrush &brush)
QCPGraph * graph(int index) const
QCPPlottableLegendItem * itemWithPlottable(const QCPAbstractPlottable *plottable) const
void setOutlierPen(const QPen &pen)
void setTitle(const QString &title)
virtual void drawGrid(QPainter *painter)
QCPAxis * valueAxis() const
QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis)
const QPolygonF getChannelFillPolygon(const QVector< QPointF > *lineData) const
void setAutoAddPlottableToLegend(bool on)
void setAntialiasedElements(const AntialiasedElements &antialiasedElements)
void setAntialiasedElement(AntialiasedElement antialiasedElement, bool enabled)
void setAxisBackgroundScaledMode(Qt::AspectRatioMode mode)
void removeDataAfter(double key)
void setMargin(int left, int right, int top, int bottom)
void setPadding(int left, int right, int top, int bottom)
The positive sign domain, i.e. numbers greater than zero.
void setBorderPen(const QPen &pen)
void savePdf(const QString &fileName, bool noCosmeticPen=false, int width=0, int height=0)
void setIconSize(const QSize &size)
virtual void mouseReleaseEvent(QMouseEvent *event)
void setData(QCPDataMap *data, bool copy=false)
double coordToPixel(double value) const
void setPaddingLeft(int padding)
virtual void drawAxisBackground(QPainter *painter)
QPen iconBorderPen() const
void setAxisBackground(const QPixmap &pm)
void setAxisBackgroundScaled(bool scaled)
void setErrorPen(const QPen &pen)
virtual void drawLegendIcon(QPainter *painter, const QRect &rect) const
void drawError(QPainter *painter, double x, double y, const QCPData &data) const
void setSubTickLength(int inside, int outside=0)
void setMinimumSize(const QSize &size)
Represents the range an axis is encompassing.
virtual void calculateAutoSize()
virtual void drawAxis(QPainter *painter)
const QCPAbstractPlottable * mPlottable
no scatter symbols are drawn (e.g. data only represented with lines, see setLineStyle) ...
virtual void generateAutoTicks()
bool removePlottable(QCPAbstractPlottable *plottable)
void setOutlierSize(double pixels)
ScaleType scaleType() const
QCPAxis * mRangeZoomVertAxis
bool removeItem(int index)
virtual void draw(QPainter *painter) const
friend class QCPPlottableLegendItem
void addData(const QCPDataMap &dataMap)
virtual void draw(QPainter *painter)
void drawScatterPlot(QPainter *painter, QVector< QCPData > *pointData) const
a star with eight arms, i.e. a combination of cross and plus
virtual void paintEvent(QPaintEvent *event)
QList< QCPAbstractLegendItem * > mItems
QCustomPlot * mParentPlot
void setLabel(const QString &str)
QMap< double, QCPCurveData > QCPCurveDataMap
virtual void draw(QPainter *painter) const
void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical)
virtual void drawOutliers(QPainter *painter) const
void setMarginLeft(int margin)
data points are connected by a straight line
void setMarginRight(int margin)
virtual void drawTickLabel(QPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize)
Axis is vertical and on the left side of the axis rect of the parent QCustomPlot. ...
QCPLegend(QCustomPlot *parentPlot)
virtual void draw(QPainter *painter) const
QVector< QString > * mTickVectorLabels
virtual QCPRange getValueRange(bool &validRange, SignDomain inSignDomain=SDBoth) const
a single pixel, setScatterSize has no influence on its size.
a circle which is not filled, with a cross inside
AxisType axisType() const
void setChannelFillGraph(QCPGraph *targetGraph)
void getStepRightPlotData(QVector< QPointF > *lineData, QVector< QCPData > *pointData) const
void setSubGrid(bool show)
void setScatterStyle(int ss)
QCPAxis * rangeZoomAxis(Qt::Orientation orientation)
QCPGraph * channelFillGraph() const
Legend is positioned in the bottom left corner of the axis rect with distance to the border correspon...
void getStepLeftPlotData(QVector< QPointF > *lineData, QVector< QCPData > *pointData) const
void drawImpulsePlot(QPainter *painter, QVector< QPointF > *lineData) const
virtual void draw(QPainter *painter, const QRect &rect) const
a custom pixmap specified by setScatterPixmap, centered on the data point coordinates. setScatterSize has no influence on its size.
A class holding the data of one single data point (one bar) for QCPBars.
void setLabelPadding(int padding)