YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
plotmanager.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: GPL-3.0-or-later
4 */
5
6#include "plotmanager.h"
7
8PlotManager::PlotManager(QObject *parent) :
9 QObject(parent)
10{
11 timer.setTimerType(Qt::PreciseTimer);
12 connect(&timer,SIGNAL(timeout()),this,SLOT(onTimeout()),Qt::DirectConnection);
13}
14
16{
17
18 if(timer.isActive()){
19 timer.stop();
20 }
21
22 /*while(!plotterList.isEmpty()){
23 delete ((Plotter*)plotterList.takeLast());
24 }*/
25}
26
33
35QList<QObject *>* PlotManager::getPlotters()
36{
37 return &plotterList;
38}
39
52Plotter * PlotManager::addPlot(const QString &title,
53 int gridx,
54 int gridy,
55 int hspan,
56 int vspan,
57 float minval,
58 float maxval,
59 int size,
60 const QString &bgcolor,
61 bool autorescale)
62{
63 auto* plotter = new Plotter(title,gridx,gridy,hspan,vspan,minval,maxval,size,bgcolor,autorescale,this);
64 plotterList.append(plotter);
65 emit plottersChanged();
66 emit plotter->plotSampleSizeChanged();
67
68 return plotter;
69
70}
71
72
76void PlotManager::setInterval(int interval)
77{
78
79 timer.setInterval(interval);
80 if (!timer.isActive()) {
81 timer.start();
82 }
83}
84
87{
88 int c = plotterList.count();
89 for(int i=0;i<c;i++){
90 ((Plotter*)plotterList.at(i))->onTimeout();
91 }
92 emit requestRepaint();
93}
94
99{
100 if(!check){
101 timer.stop();
102 }else{
103 timer.start();
104 }
105}
106
109{
110 for(int i=0;i<plotterList.count();i++){
111 ((Plotter*)plotterList.at(i))->clear();
112 }
113}
114
117{
118 for(int i=0;i<plotterList.count();i++){
119 ((Plotter*)plotterList.at(i))->rescale();
120 }
121}
int SIGNAL(int pid, int signum)
The Manager of the plotters.
Definition plotmanager.h:19
void playPressed(bool check)
Sets the play or pause state.
void setInterval(int interval)
Sets the refresh interval.
void clear()
Clear all plotters datas.
QList< QObject * > * getPlotters()
Returns a list of all plotters.
static PlotManager * instance()
Returns an instance of the class (Singleton).
Plotter * addPlot(const QString &title, int gridx, int gridy, int hspan, int vspan, float minval, float maxval, int size, const QString &bgcolor, bool autorescale)
Adds a new Plotter.
void requestRepaint()
void onTimeout()
Timeout of the refresh timer.
PlotManager(QObject *parent=0)
void rescale()
Rescale all plotters.
void plottersChanged()
Class representing a Plotter.
Definition plotter.h:115