25 #include <QGraphicsScene>    26 #include <QGraphicsView>    27 #include <QGraphicsItem>    28 #include <QHBoxLayout>    29 #include <QFormLayout>    30 #include <QResizeEvent>    31 #include <QtCore/QTime>    32 #include <QtCore/QTimer>    33 #include <QtCore/QFileInfo>    34 #include <QPushButton>    35 #include <QToolButton>    38 #include <QInputDialog>    39 #include <QMessageBox>    40 #include <QFileDialog>    42 #include <QApplication>    45 #include <QtSvg/QSvgGenerator>    50 #define ULOGGER_ERROR(A, ...)    51 #define ULOGGER_WARN(A, ...)    54         QGraphicsEllipseItem(0, 0, width, width, 0),
    61         this->setAcceptHoverEvents(
true);
    62         _text = 
new QGraphicsTextItem(
this);
    64         _text->setVisible(
false);
    65         this->setFlag(QGraphicsItem::ItemIsFocusable, 
true);
    69         QGraphicsEllipseItem(0, 0, width, width, 0),
    75         this->setAcceptHoverEvents(
true);
    76         _text = 
new QGraphicsTextItem(
this);
    78         _text->setVisible(
false);
    79         this->setFlag(QGraphicsItem::ItemIsFocusable, 
true);
   133                 this->setPen(QPen(Qt::black, 2));
   136                         QRectF rect = this->scene()->sceneRect();
   137                         QPointF p = this->pos();
   138                         QRectF br = 
_text->boundingRect();
   141                         if(p.x() - br.width() < 0)
   145                         else if(p.x() + br.width() > rect.width())
   147                                 p.setX(rect.width() - br.width());
   151                                 p.setX(p.x() - br.width());
   154                         if(p.y() - br.height() < 0)
   160                                 p.setY(p.y() - br.height());
   163                         _text->setPos(this->mapFromScene(p));
   166                 _text->setVisible(
true);
   170                 this->setPen(QPen(Qt::black, 1));
   171                 _text->setVisible(
false);
   177         QGraphicsScene * scene = this->scene();
   178         if(scene && scene->focusItem() == 0)
   184                 this->setPen(QPen(Qt::black, 2));
   186         QGraphicsEllipseItem::hoverEnterEvent(event);
   191         if(!this->hasFocus())
   195         QGraphicsEllipseItem::hoverEnterEvent(event);
   201         QGraphicsEllipseItem::focusInEvent(event);
   207         QGraphicsEllipseItem::focusOutEvent(event);
   213         if(keyEvent->key() == Qt::Key_Right)
   216                 while(next && !next->isVisible())
   220                 if(next && next->isVisible())
   226         else if(keyEvent->key() == Qt::Key_Left)
   229                 while(previous && !previous->isVisible())
   233                 if(previous && previous->isVisible())
   236                         previous->setFocus();
   239         QGraphicsEllipseItem::keyReleaseEvent(keyEvent);
   295         if(!plot || plot == 
_plot)
   304         for(
int i=0; i<
_items.size(); ++i)
   313         ULOGGER_DEBUG(
"curve=\"%s\" from plot=\"%s\"", this->objectName().toStdString().c_str(), plot?plot->objectName().toStdString().c_str():
"");
   315         if(plot && 
_plot == plot)
   318                 for(
int i=0; i<
_items.size(); ++i)
   340         for(
int i=0; i<
_items.size(); ++i)
   345                         x = item->
data().x();
   346                         y = item->
data().y();
   370                 float x = data->
data().x();
   371                 float y = data->
data().y();
   380                         QGraphicsLineItem * line = 
new QGraphicsLineItem();
   382                         line->setVisible(
false);
   403                 data->setVisible(
false);
   450         float v = value.toFloat(&ok);
   457                 ULOGGER_ERROR(
"Value not valid, must be a number, received %s", value.toStdString().c_str());
   463         for(
int i=0; i<data.size(); ++i)
   473         for(
int i=0; i<xs.size() && i<ys.size(); ++i)
   484         for(
int i=0; i<ys.size(); ++i)
   504         for(
int i=0; i<ys.size(); ++i)
   524         for(
unsigned int i=0; i<ys.size(); ++i)
   544         for(
unsigned int i=0; i<ys.size(); ++i)
   562         if(index >= 0 && index < 
_items.size())
   567                         delete _items.takeAt(index); 
   571                         delete _items.takeAt(index+1); 
   583                                         float x = tmp->
data().x();
   584                                         float y = tmp->
data().y();
   589                                         for(
int i = 2; i<
_items.size(); i+=2)
   614         for(
int i=0; i<
_items.size(); ++i)
   629                         item->scene()->removeItem(item);
   648         for(
int i=1; i<
_items.size(); i+=2)
   660 void UPlotCurve::update(
float scaleX, 
float scaleY, 
float offsetX, 
float offsetY, 
float xDir, 
float yDir, 
bool allDataKept)
   664         xDir<0?xDir=-1:xDir=1;
   665         yDir<0?yDir=-1:yDir=1;
   668         for(
int i=
_items.size()-1; i>=0; --i)
   678                                         if(!item->isVisible())
   682                                         item->setVisible(
false);
   692                                 QPointF newPos(((xDir*item->
data().x()+offsetX)*scaleX-item->rect().width()/2.0f),
   693                                                            ((yDir*item->
data().y()+offsetY)*scaleY-item->rect().width()/2.0f));
   694                                 if(!item->isVisible())
   696                                         item->setVisible(
true);
   698                                 item->setPos(newPos);
   705                                 _items.at(i)->setVisible(
false);
   711                                 QGraphicsLineItem * lineItem = (QGraphicsLineItem *)
_items.at(i);
   712                                 lineItem->setLine((xDir*from->
data().x()+offsetX)*scaleX,
   713                                                                 (yDir*from->
data().y()+offsetY)*scaleY,
   714                                                                 (xDir*to->
data().x()+offsetX)*scaleX,
   715                                                                 (yDir*to->
data().y()+offsetY)*scaleY);
   716                                 if(!lineItem->isVisible())
   718                                         lineItem->setVisible(
true);
   722                                 QLineF line = lineItem->line();
   723                                 if((line.x1() <= line.x2() && line.x2() < 0-((line.x2() - line.x1()))) ||
   724                                         (line.x1() > line.x2() && line.x2() > lineItem->scene()->sceneRect().width() + ((line.x1() - line.x2()))))
   739                 for(
int i=
_items.size()-1; i>=0 && 
_items.at(i)->isVisible(); i-=2)
   743                         int x = (int)item->x();
   753                                 painter->setPen(this->
pen());
   754                                 painter->setBrush(this->
brush());
   756                                 const QGraphicsLineItem * item = (
const QGraphicsLineItem *)
_items.at(i-1);
   757                                 QLineF line = item->line();
   758                                 int x = (int)line.p1().x();
   761                                         line.setP1(QPoint(0, line.p1().y()));
   763                                 painter->drawLine(line);
   767                         painter->drawEllipse(item->pos()+QPointF(item->rect().width()/2, item->rect().height()/2), (
int)item->rect().width()/2, (int)item->rect().height()/2);
   781         if(index>=0 && index < 
_items.size() && index % 2 == 0 )
   795         for(
int i=0; i<
_items.size(); ++i)
   797                 _items.at(i)->setVisible(visible);
   814         for(
int i = 0; i<data.size(); ++i)
   822         if(x.size() == y.size())
   825                 int margin = int((
_items.size()+1)/2) - x.size();
   840                 QVector<float>::const_iterator i=x.begin();
   841                 QVector<float>::const_iterator j=y.begin();
   842                 for(; i!=x.end() && j!=y.end(); ++i, ++j, index+=2)
   859         if(x.size() == y.size())
   862                 int margin = int((
_items.size()+1)/2) - int(x.size());
   877                 std::vector<float>::const_iterator i=x.begin();
   878                 std::vector<float>::const_iterator j=y.begin();
   879                 for(; i!=x.end() && j!=y.end(); ++i, ++j, index+=2)
   896         this->
setData(y.toStdVector());
   902         int margin = int((
_items.size()+1)/2) - int(y.size());
   918         std::vector<float>::const_iterator j=y.begin();
   919         for(; j!=y.end(); ++j, index+=2)
   935                 x.resize((
_items.size()-1)/2+1);
   938                 for(
int i=0; i<
_items.size(); i+=2)
   952         _orientation(orientation)
   982                         item->
setData(QPointF(item->
data().x(), threshold));
   984                         item->
setData(QPointF(item->
data().x(), threshold));
   989                         item->
setData(QPointF(threshold, item->
data().y()));
   991                         item->
setData(QPointF(threshold, item->
data().y()));
   996                 ULOGGER_ERROR(
"A threshold must has only 3 items (1 PlotItem + 1 QGraphicsLineItem + 1 PlotItem)");
  1015                         ULOGGER_ERROR(
"A threshold must has only 3 items (1 PlotItem + 1 QGraphicsLineItem + 1 PlotItem)");
  1031                                 item->
setData(QPointF(-offsetX/xDir, item->
data().y()));
  1038                                 item->
setData(QPointF(item->
data().x(), -offsetY/yDir));
  1047                 ULOGGER_ERROR(
"A threshold must has only 3 items (1 PlotItem + 1 QGraphicsLineItem + 1 PlotItem)");
  1070         this->setMinimumSize(15, 25);
  1072         this->setMinimumSize(15, 25);
  1102                 borderMin = borderMax = this->fontMetrics().height()/2;
  1109         int border = borderMin>borderMax?borderMin:borderMax;
  1114                 length = (this->height()-border*2);
  1118                 length = (this->width()-border*2);
  1125         else if(length <= 175)
  1129         else if(length <= 350)
  1133         else if(length <= 700)
  1137         else if(length <= 1000)
  1141         else if(length <= 1300)
  1154                 float rangef = max - min;
  1155                 int countStep = 
_count/5;
  1157                 for(
int i=0; i<6; ++i)
  1159                         val = (rangef/float(countStep)) * mul;
  1160                         if( val >= 1.0
f && val < 10.0
f)
  1174                 int minR = min*mul-0.9;
  1175                 int maxR = max*mul+0.9;
  1176                 min = float(minR)/mul;
  1177                 max = float(maxR)/mul;
  1201         if(borderDelta%2 != 0)
  1206         _border = border + borderDelta/2;
  1212                 for (
int i = 0; i <= 
_count; i+=5)
  1215                         if(this->fontMetrics().width(n) > minWidth)
  1217                                 minWidth = this->fontMetrics().width(n);
  1220                 this->setMinimumWidth(15+minWidth);
  1226         QPainter painter(
this);
  1229                 painter.translate(0, 
_border);
  1230                 for (
int i = 0; i <= 
_count; ++i)
  1234                                 painter.drawLine(this->width(), 0, this->width()-10, 0);
  1236                                 painter.drawText(this->width()-(12+n.sizeHint().width()), n.sizeHint().height()/2-2, n.text());
  1240                                 painter.drawLine(this->width(), 0, this->width()-5, 0);
  1242                         painter.translate(0, 
_step);
  1247                 painter.translate(
_border, 0);
  1248                 for (
int i = 0; i <= 
_count; ++i)
  1252                                 painter.drawLine(0, 0, 0, 10);
  1254                                 painter.drawText(-(n.sizeHint().width()/2)+1, 22, n.text());
  1258                                 painter.drawLine(0, 0, 0, 5);
  1260                         painter.translate(
_step, 0);
  1269                 QPushButton(parent),
  1272         QString nameSpaced = curve->
name();
  1273         nameSpaced.replace(
'_', 
' ');
  1274         this->setText(nameSpaced);
  1276         _aChangeText = 
new QAction(tr(
"Change text..."), 
this);
  1277         _aResetText = 
new QAction(tr(
"Reset text..."), 
this);
  1280         _menu = 
new QMenu(tr(
"Curve"), 
this);
  1293         QAction * 
action = 
_menu->exec(event->globalPos());
  1297                 QString text = QInputDialog::getText(
this, 
_aChangeText->text(), tr(
"Name :"), QLineEdit::Normal, this->text(), &ok);
  1298                 if(ok && !text.isEmpty())
  1300                         this->setText(text);
  1323                         for(
int i=0; i<x.size(); ++i)
  1325                                 textX.append(QString::number(x[i]));
  1326                                 textY.append(QString::number(y[i]));
  1333                         QClipboard * clipboard = QApplication::clipboard();
  1334                         clipboard->setText((textX+
"\n")+textY);
  1352         _menu = 
new QMenu(tr(
"Legend"), 
this);
  1355         QVBoxLayout * vLayout = 
new QVBoxLayout(
this);
  1356         vLayout->setContentsMargins(0,0,0,0);
  1357         this->setLayout(vLayout);
  1358         vLayout->addStretch(0);
  1359         vLayout->setSpacing(0);
  1374                 QList<UPlotLegendItem*> items = this->findChildren<UPlotLegendItem*>();
  1375                 for(
int i=0; i<items.size(); ++i)
  1377                         items.at(i)->setFlat(
_flat);
  1378                         items.at(i)->setChecked(!items.at(i)->isChecked());
  1389                 legendItem->setAutoDefault(
false);
  1390                 legendItem->setFlat(
_flat);
  1391                 legendItem->setCheckable(
true);
  1392                 legendItem->setChecked(
false);
  1394                 legendItem->setIconSize(QSize(25,20));
  1395                 connect(legendItem, SIGNAL(toggled(
bool)), 
this, SLOT(
redirectToggled(
bool)));
  1399                 QHBoxLayout * hLayout = 
new QHBoxLayout();
  1400                 hLayout->addWidget(legendItem);
  1401                 hLayout->addStretch(0);
  1402                 hLayout->setMargin(0);
  1405                 ((QVBoxLayout*)this->layout())->insertLayout(this->layout()->count()-1, hLayout);
  1411         QPixmap pixmap(50, 50);
  1412         pixmap.fill(Qt::transparent);
  1413         QPainter painter(&pixmap);
  1417         painter.drawLine(0.0, 25.0, 50.0, 25.0);
  1423         QList<UPlotLegendItem *> items = this->findChildren<UPlotLegendItem*>();
  1424         for(
int i=0; i<items.size(); ++i)
  1426                 if(items.at(i)->curve() == curve)
  1437         if(this->
remove(curve))
  1445         QAction * 
action = 
_menu->exec(event->globalPos());
  1471         QLabel(text, parent),
  1472         _orientation(orientation)
  1482         QSize size = QLabel::sizeHint();
  1491         QSize size = QLabel::minimumSizeHint();
  1502         case Qt::Horizontal:
  1503                 setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
  1507                 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
  1518         case Qt::Horizontal:
  1522                 p.translate(-height(), 0);
  1523                 QSize size = r.size();
  1528         p.drawText(r, this->alignment() | (this->wordWrap()?Qt::TextWordWrap:0), this->text());
  1545         _maxVisibleItems(-1),
  1546         _autoScreenCaptureFormat(
"png")
  1560         for(
int i=0; i<4; ++i)
  1590         _view = 
new QGraphicsView(
this);
  1591         _view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  1592         _view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  1593         _view->setScene(
new QGraphicsScene(0,0,0,0,
this));
  1594         _view->setStyleSheet( 
"QGraphicsView { border-style: none; }" );
  1606         _title->setAlignment(Qt::AlignCenter);
  1607         _xLabel->setAlignment(Qt::AlignCenter);
  1608         _yLabel->setAlignment(Qt::AlignCenter);
  1610         _title->setWordWrap(
true);
  1613         _title->setVisible(
false);
  1620         vLayout->setContentsMargins(0,0,0,0);
  1621         vLayout->addWidget(
_view);
  1623         QGridLayout * grid = 
new QGridLayout(
this);
  1624         grid->setContentsMargins(0,0,0,0);
  1625         grid->addWidget(
_title, 0, 2);
  1626         grid->addWidget(
_yLabel, 1, 0);
  1630         grid->setColumnStretch(2, 1);
  1631         grid->setRowStretch(1, 1);
  1633         grid->addWidget(
_xLabel, 3, 2);
  1634         grid->addWidget(
_legend, 1, 3);
  1644         _aShowGrid = 
new QAction(tr(
"Show grid"), 
this);
  1652         _aLimit0 = 
new QAction(tr(
"No maximum items shown"), 
this);
  1653         _aLimit10 = 
new QAction(tr(
"10"), 
this);
  1654         _aLimit50 = 
new QAction(tr(
"50"), 
this);
  1675         _aSaveFigure = 
new QAction(tr(
"Save figure..."), 
this);
  1678         _aClearData = 
new QAction(tr(
"Clear data"), 
this);
  1680         QActionGroup * grpLimit = 
new QActionGroup(
this);
  1693         _menu = 
new QMenu(tr(
"Plot"), 
this);
  1699         _menu->addSeparator()->setStatusTip(tr(
"Maximum items shown"));
  1707         _menu->addSeparator();
  1708         QMenu * addLineMenu = 
_menu->addMenu(tr(
"Add line"));
  1711         _menu->addSeparator();
  1714         QMenu * yLabelMenu = 
_menu->addMenu(tr(
"Y label"));
  1719         _menu->addSeparator();
  1745                 if(!qobject_cast<UPlotCurveThreshold*>(curve))
  1747                         for(
int i=
_curves.size()-1; i>=0; --i)
  1749                                 if(!qobject_cast<UPlotCurveThreshold*>(
_curves.at(i)))
  1760                 if(ownershipTransferred)
  1762                         curve->setParent(
this);
  1772                 ULOGGER_DEBUG(
"Curve \"%s\" added to plot \"%s\"", curve->
name().toStdString().c_str(), this->
title().toStdString().c_str());
  1787         for(QList<UPlotCurve*>::iterator iter = 
_curves.begin(); iter!=
_curves.end(); ++iter)
  1791                         names.append((*iter)->name());
  1799         for(QList<UPlotCurve*>::iterator iter = 
_curves.begin(); iter!=
_curves.end(); ++iter)
  1801                 if(*iter && (*iter)->name().compare(curveName) == 0)
  1821                 for(QList<UPlotCurve *>::iterator i=
_curves.begin(); i!=
_curves.end(); ++i)
  1823                         if((*i)->isVisible() && ((
UPlotCurve *)(*i))->itemsSize() > maxItem)
  1835         float axis[4] = {0};
  1836         for(
int i=0; i<4; ++i)
  1852         _view->scene()->setSceneRect(newRect);
  1864                 float w = newRect.width()-(borderHor*2);
  1865                 float h = newRect.height()-(borderVer*2);
  1868                 QPen pen(Qt::DashLine);
  1869                 for(
float i=0.0
f; i*stepV <= h+stepV; i+=5.0f)
  1876                                         painter->drawLine(0, stepV*i+borderVer+0.5
f, borderHor, stepV*i+borderVer+0.5
f);
  1878                                         painter->setPen(pen);
  1879                                         painter->drawLine(borderHor, stepV*i+borderVer+0.5
f, w+borderHor, stepV*i+borderVer+0.5
f);
  1881                                         painter->drawLine(w+borderHor, stepV*i+borderVer+0.5
f, w+borderHor*2, stepV*i+borderVer+0.5
f);
  1886                                 hGridLines.append(
new QGraphicsLineItem(0, stepV*i+borderVer, borderHor, stepV*i+borderVer, 
_sceneRoot));
  1887                                 hGridLines.append(
new QGraphicsLineItem(borderHor, stepV*i+borderVer, w+borderHor, stepV*i+borderVer, 
_sceneRoot));
  1889                                 hGridLines.append(
new QGraphicsLineItem(w+borderHor, stepV*i+borderVer, w+borderHor*2, stepV*i+borderVer, 
_sceneRoot));
  1892                 for(
float i=0; i*stepH < w+stepH; i+=5.0f)
  1899                                         painter->drawLine(stepH*i+borderHor+0.5
f, 0, stepH*i+borderHor+0.5
f, borderVer);
  1901                                         painter->setPen(pen);
  1902                                         painter->drawLine(stepH*i+borderHor+0.5
f, borderVer, stepH*i+borderHor+0.5
f, h+borderVer);
  1904                                         painter->drawLine(stepH*i+borderHor+0.5
f, h+borderVer, stepH*i+borderHor+0.5
f, h+borderVer*2);
  1909                                 vGridLines.append(
new QGraphicsLineItem(stepH*i+borderHor, 0, stepH*i+borderHor, borderVer, 
_sceneRoot));
  1910                                 vGridLines.append(
new QGraphicsLineItem(stepH*i+borderHor, borderVer, stepH*i+borderHor, h+borderVer, 
_sceneRoot));
  1912                                 vGridLines.append(
new QGraphicsLineItem(stepH*i+borderHor, h+borderVer, stepH*i+borderHor, h+borderVer*2, 
_sceneRoot));
  1921         den = axis[1] - axis[0];
  1924                 scaleX = (newRect.width()-(borderHor*2)) / den;
  1926         den = axis[3] - axis[2];
  1929                 scaleY = (newRect.height()-(borderVer*2)) / den;
  1931         for(QList<UPlotCurve *>::iterator i=
_curves.begin(); i!=
_curves.end(); ++i)
  1933                 if((*i)->isVisible())
  1937                         (*i)->update(scaleX,
  1939                                                 xDir<0?axis[1]+borderHor/scaleX:-(axis[0]-borderHor/scaleX),
  1940                                                 yDir<0?axis[3]+borderVer/scaleY:-(axis[2]-borderVer/scaleY),
  1946                                 (*i)->draw(painter);
  1987                 const QVector<float> & minMax = curve->
getMinMax();
  1989                 if(minMax.size() != 4)
  1994                 this->
updateAxis(minMax[0], minMax[1], minMax[2], minMax[3]);
  2001         bool modified = 
false;
  2017         bool modified = 
false;
  2052         for(
int i=0; i<4; ++i)
  2061         for(
int i=0; i<
_curves.size(); ++i)
  2065                         const QVector<float> & minMax = 
_curves.at(i)->getMinMax();
  2066                         this->
updateAxis(minMax[0], minMax[1], minMax[2], minMax[3]);
  2082                 QPainter painter(
this);
  2085                 painter.setBrush(Qt::white);
  2086                 painter.setPen(QPen(Qt::NoPen));
  2094                 QWidget::paintEvent(event);
  2104         QWidget::resizeEvent(event);
  2109         QAction * 
action = 
_menu->exec(event->globalPos());
  2148                 QString text = QInputDialog::getText(
this, action->text(), tr(
"New line name :"), QLineEdit::Normal, 
"", &ok);
  2149                 while(ok && text.isEmpty())
  2151                         QMessageBox::warning(
this, action->text(), tr(
"The name is not valid or it is already used in this plot."));
  2152                         text = QInputDialog::getText(
this, action->text(), tr(
"New line name :"), QLineEdit::Normal, 
"", &ok);
  2165                         double value = QInputDialog::getDouble(
this,
  2167                                         tr(
"%1 value (min=%2, max=%3):").arg(axis).arg(min).arg(max),
  2189                 QString text = 
_title->text();
  2192                         text = this->objectName();
  2194                 text = QInputDialog::getText(
this, 
_aChangeTitle->text(), tr(
"Title :"), QLineEdit::Normal, text, &ok);
  2203                 QString text = QInputDialog::getText(
this, 
_aChangeXLabel->text(), tr(
"X axis label :"), QLineEdit::Normal, 
_xLabel->text(), &ok);
  2212                 QString text = QInputDialog::getText(
this, 
_aChangeYLabel->text(), tr(
"Y axis label :"), QLineEdit::Normal, 
_yLabel->text(), &ok);
  2227                 text = QFileDialog::getSaveFileName(
this, tr(
"Save figure to ..."), (QDir::homePath() + 
"/") + this->
title() + 
".png", 
"*.png *.xpm *.jpg *.pdf *.svg");
  2229                 text = QFileDialog::getSaveFileName(
this, tr(
"Save figure to ..."), (QDir::homePath() + 
"/") + this->
title() + 
".png", 
"*.png *.xpm *.jpg *.pdf");
  2233                         bool flatModified = 
false;
  2237                                 flatModified = 
true;
  2240                         QPalette p(palette());
  2242                         QColor c = p.color(QPalette::Background);
  2243                         p.setColor(QPalette::Background, Qt::white);
  2247                         if(QFileInfo(text).suffix().compare(
"svg") == 0)
  2249                                 QSvgGenerator generator;
  2250                                 generator.setFileName(text);
  2251                                 generator.setSize(this->size());
  2253                                 painter.begin(&generator);
  2254                                 this->render(&painter);
  2260                                 if(QFileInfo(text).suffix().compare(
"pdf") == 0)
  2263                                         printer.setOutputFormat(QPrinter::PdfFormat);
  2264                                         printer.setOutputFileName(text);
  2265                                         this->render(&printer);
  2269                                         QPixmap figure = QPixmap::grabWidget(
this);
  2276                         p.setColor(QPalette::Background, c);
  2310                 ULOGGER_ERROR(
"The directory \"%s\" doesn't exist", workingDirectory.toStdString().c_str());
  2322         if(!dir.exists(targetDir))
  2324                 dir.mkdir(targetDir);
  2327         targetDir += this->
title().replace(
" ", 
"_");
  2328         if(!dir.exists(targetDir))
  2330                 dir.mkdir(targetDir);
  2334         QPixmap figure = QPixmap::grabWidget(
this);
  2335         figure.save(targetDir + name);
  2341         items << QString(
"png") << QString(
"jpg");
  2343         QString item = QInputDialog::getItem(
this, tr(
"Select format"), tr(
"Format:"), items, 0, 
false, &ok);
  2344         if(ok && !item.isEmpty())
  2353         for(
int i=0; i<
_curves.size(); ++i)
  2356                 if(qobject_cast<UPlotCurveThreshold*>(
_curves.at(i)) == 0)
  2368         QPen pen = curve->
pen();
  2388         _title->setVisible(!text.isEmpty());
  2392                 QTimer::singleShot(10, 
this, SLOT(
updateAxis()));
  2399         _xLabel->setVisible(!text.isEmpty());
  2403                 QTimer::singleShot(10, 
this, SLOT(
updateAxis()));
  2411         _yLabel->setVisible(!text.isEmpty());
  2416                 QTimer::singleShot(10, 
this, SLOT(
updateAxis()));
  2432                 QTimer::singleShot(10, 
this, SLOT(
updateAxis()));
  2449                 QTimer::singleShot(10, 
this, SLOT(
updateAxis()));
  2456         _view->setVisible(on);
  2467         if(maxVisibleItems <= 0)
  2471         else if(maxVisibleItems == 10)
  2475         else if(maxVisibleItems == 50)
  2479         else if(maxVisibleItems == 100)
  2483         else if(maxVisibleItems == 500)
  2487         else if(maxVisibleItems == 1000)
  2503         return _view->sceneRect();
  2508         QList<UPlotCurve*> tmp = 
_curves;
  2509         for(QList<UPlotCurve*>::iterator iter=tmp.begin(); iter!=tmp.end(); ++iter)
  2518         QList<UPlotCurve *>::iterator iter = qFind(
_curves.begin(), 
_curves.end(), curve);
  2520         ULOGGER_DEBUG(
"Plot=\"%s\" removing curve=\"%s\"", this->objectName().toStdString().c_str(), curve?curve->
name().toStdString().c_str():
"");
  2528                 if(!qobject_cast<UPlotCurveThreshold*>(c))
  2531                         for(
int i=
_curves.size()-1; i>=0; --i)
  2533                                 if(!qobject_cast<UPlotCurveThreshold*>(
_curves.at(i)))
  2541                 if(c->parent() == 
this)
  2552         QList<UPlotCurve *>::iterator iter = qFind(
_curves.begin(), 
_curves.end(), curve);
 QString _autoScreenCaptureFormat
QPointF getItemData(int index)
UPlotCurveThreshold(const QString &name, float thesholdValue, Qt::Orientation orientation=Qt::Horizontal, QObject *parent=0)
QGraphicsTextItem * _text
virtual void contextMenuEvent(QContextMenuEvent *event)
void setOrientation(Qt::Orientation orientation)
void redirectToggled(bool)
QGraphicsItem * _sceneRoot
UPlotAxis * _verticalAxis
QList< UPlotCurve * > _curves
virtual ~UPlotCurveThreshold()
void showGrid(bool shown)
void setXIncrement(float increment)
const QVector< float > & getMinMax() const
virtual void contextMenuEvent(QContextMenuEvent *event)
const QBrush & brush() const
int removeItem(int index)
void setFixedYAxis(float y1, float y2)
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void setBrush(const QBrush &brush)
UPlotAxis(Qt::Orientation orientation=Qt::Horizontal, float min=0, float max=1, QWidget *parent=0)
const UPlotCurve * _curve
void setFixedXAxis(float x1, float x2)
QAction * _aAddVerticalLine
UPlotItem * _previousItem
const UPlotCurve * curve() const
virtual ~UOrientableLabel()
virtual void contextMenuEvent(QContextMenuEvent *event)
virtual bool isMinMaxValid() const
void showRefreshRate(bool shown)
UOrientableLabel * _yLabel
void addValue(UPlotItem *data)
QWidget * _graphicsViewHolder
Qt::Orientation _orientation
QTime _refreshIntervalTime
void getData(QVector< float > &x, QVector< float > &y) const
void setPen(const QPen &pen)
void setData(QVector< UPlotItem *> &data)
Qt::Orientation orientation() const
UPlotLegendItem(const UPlotCurve *curve, QWidget *parent=0)
QString _workingDirectory
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
QPen getRandomPenColored()
UPlotAxis * _horizontalAxis
virtual void showDescription(bool shown)
bool remove(const UPlotCurve *curve)
void removeLegendItem(const UPlotCurve *curve)
virtual void paintEvent(QPaintEvent *event)
void setVisible(bool visible)
#define ULOGGER_DEBUG(...)
Qt::Orientation _orientation
void setOrientation(Qt::Orientation orientation)
UPlotCurve * addCurve(const QString &curveName, const QColor &color=QColor())
QAction * _aShowRefreshRate
void removeCurve(const UPlotCurve *curve)
UPlotItem(qreal dataX, qreal dataY, qreal width=2)
void setGraphicsView(bool on)
QAction * _aAddHorizontalLine
void _addValue(UPlotItem *data)
void setThreshold(float threshold)
void legendItemRemoved(const UPlotCurve *)
virtual ~UPlotLegendItem()
UPlotLegend(QWidget *parent=0)
QSize minimumSizeHint() const
virtual void keyReleaseEvent(QKeyEvent *keyEvent)
virtual void update(float scaleX, float scaleY, float offsetX, float offsetY, float xDir, float yDir, bool allDataKept)
QList< QGraphicsItem * > _items
virtual void resizeEvent(QResizeEvent *event)
QAction * _aYLabelVertical
QPixmap createSymbol(const QPen &pen, const QBrush &brush)
bool contains(const QString &curveName)
UOrientableLabel(const QString &text, Qt::Orientation orientation=Qt::Horizontal, QWidget *parent=0)
void keepAllData(bool kept)
void setXLabel(const QString &text)
QList< QGraphicsLineItem * > vGridLines
QAction * _aCopyToClipboard
QAction * _aAutoScreenCapture
UPlotCurveThreshold * addThreshold(const QString &name, float value, Qt::Orientation orientation=Qt::Horizontal)
void selectScreenCaptureFormat()
void setTitle(const QString &text)
virtual void update(float scaleX, float scaleY, float offsetX, float offsetY, float xDir, float yDir, bool allDataKept)
virtual void paintEvent(QPaintEvent *event)
#define ULOGGER_WARN(A,...)
virtual void focusOutEvent(QFocusEvent *event)
void legendItemRemoved(const UPlotCurve *curve)
UPlotItem * nextItem() const
UPlotItem * previousItem() const
void setData(const QPointF &data)
void setMaxVisibleItems(int maxVisibleItems)
const QPointF & data() const
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
ROSCPP_DECL bool exists(const std::string &service_name, bool print_failure_reason)
#define ULOGGER_ERROR(A,...)
virtual void focusInEvent(QFocusEvent *event)
void addItem(QGraphicsItem *item)
QAction * _aUseFlatButtons
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void replot(QPainter *painter)
virtual void paintEvent(QPaintEvent *event)
void showLegend(bool shown)
void dataChanged(const UPlotCurve *)
UPlotCurve(const QString &name, QObject *parent=0)
void setYLabel(const QString &text, Qt::Orientation orientation=Qt::Vertical)
void showCurve(const UPlotCurve *curve, bool shown)
void setReversed(bool reversed)
void setAxis(float &min, float &max)
void setNextItem(UPlotItem *nextItem)
QList< QGraphicsLineItem * > hGridLines
void draw(QPainter *painter)
void addValues(QVector< UPlotItem *> &data)
void addItem(const UPlotCurve *curve)
Qt::Orientation _orientation
void setWorkingDirectory(const QString &workingDirectory)
void legendItemToggled(const UPlotCurve *curve, bool toggled)
void setPreviousItem(UPlotItem *previousItem)
void setXStart(float val)