11 std::string _name, QWidget *parent) :
12 mars::main_gui::BaseWidget(parent, cfg, _name),
13 dataBroker(_dataBroker), mainLib(_mainLib),
14 name(_name), nextPlotId(1) {
16 setStyleSheet(
"background-color:#eeeeee;");
18 colors[0] = QColor(255, 0, 0);
19 colors[1] = QColor(0, 255, 0);
20 colors[2] = QColor(0, 0, 255);
21 colors[3] = QColor(255, 155, 0);
22 colors[4] = QColor(0, 255, 255);
23 colors[5] = QColor(255, 0, 255);
24 colors[6] = QColor(127, 0, 255);
25 colors[7] = QColor(255, 0, 127);
29 qcPlot->xAxis2->setVisible(
true);
30 qcPlot->xAxis2->setTickLabels(
false);
31 qcPlot->yAxis2->setVisible(
true);
32 qcPlot->yAxis2->setTickLabels(
false);
33 connect(
qcPlot->xAxis, SIGNAL(rangeChanged(QCPRange)),
34 qcPlot->xAxis2, SLOT(setRange(QCPRange)));
35 connect(
qcPlot->yAxis, SIGNAL(rangeChanged(QCPRange)),
36 qcPlot->yAxis2, SLOT(setRange(QCPRange)));
39 QVBoxLayout *vLayout =
new QVBoxLayout();
40 vLayout->addWidget(
qcPlot);
55 std::vector<Plot*>::iterator it;
66 int callbackParam =
packageList.front().callbackParam;
68 if((*it)->dpId == callbackParam/10) {
72 dataPackage.
get(0, &x);
74 dataPackage.
get(0, &ix);
78 if(callbackParam % 10) {
86 xRange = fabs(
plots[0]->xRange.dValue);
87 if(xRange > 0.0000001) {
120 bool onlyEnlarge =
false;
121 for(it=
plots.begin(); it!=
plots.end(); ++it) {
122 if((*it)->gotNewData == 3) {
123 (*it)->curve->setData((*it)->xValues, (*it)->yValues);
124 (*it)->curve->rescaleAxes(onlyEnlarge);
126 (*it)->gotNewData = 0;
147 std::string cfgName =
name;
148 std::string tmpString;
150 QCPGraph *newCurve =
qcPlot->addGraph();
152 newCurve->setAntialiasedFill(
false);
155 sprintf(text,
"graph%02d", newPlot->
dpId);
156 newPlot->
name = std::string(text);
159 cfgName.append(newPlot->
name);
162 newCurve->setPen( QPen(
colors[(newPlot->
dpId-1) % 8], 0.5) );
163 newCurve->setLineStyle( QCPGraph::lsLine );
165 newPlot->
curve = newCurve;
167 plots.push_back(newPlot);
172 dbPackageX.
add(
"xvalue", (
double)0.0);
173 dbPackageY.
add(
"yvalue", (
double)0.0);
177 tmpString.append(
"/");
178 tmpString.append(text);
179 tmpString.append(
"/xvalue");
184 tmpString, newPlot->
dpId*10);
186 tmpString.append(
"/");
187 tmpString.append(text);
188 tmpString.append(
"/yvalue");
193 tmpString, newPlot->
dpId*10+1);
197 tmpString.append(
"sTime");
202 tmpString.append(
"xRange");
207 tmpString.append(
"yScale");
212 tmpString.append(
"yOffset");
232 std::map<mars::cfg_manager::cfgParamId, Plot*>::iterator it;
238 Plot *p = it->second;
239 std::map<mars::cfg_manager::cfgParamId, mars::cfg_manager::cfgPropertyStruct*>::iterator it2;
245 it2->second->dValue = _property.
dValue;
void receiveData(const mars::data_broker::DataInfo &info, const mars::data_broker::DataPackage &dataPackage, int callbackParam)
The DataBroker will call this method to notify the receiver of whenever the condition for which the r...
virtual const cfgPropertyStruct getOrCreateProperty(const std::string &_group, const std::string &_name, bool val, CFGClient *newClient=0)=0
mars::cfg_manager::cfgPropertyStruct yOffset
void hideEvent(QHideEvent *event)
virtual bool registerSyncReceiver(ReceiverInterface *receiver, const std::string &groupName, const std::string &dataName, int callbackParam=0)=0
register a receiver to receive a synchronous callback for a certain stream
QVector< double > xValues
QVector< double > yValues
bool get(const std::string &itemName, T *val) const
gets the value of the DataItem with the given name
mars::cfg_manager::cfgPropertyStruct yScale
cfg_manager::CFGManagerInterface * cfg
mars::cfg_manager::cfgPropertyStruct xRange
void cfgUpdateProperty(mars::cfg_manager::cfgPropertyStruct _property)
std::vector< Plot * > plots
Copyright 2012, DFKI GmbH Robotics Innovation Center.
virtual unsigned long pushData(const std::string &groupName, const std::string &dataName, const DataPackage &dataPackage, const ReceiverInterface *producer, PackageFlag flags)=0
pushes a DataPackage into the DataBroker
virtual bool unregisterSyncReceiver(ReceiverInterface *receiver, const std::string &groupName, const std::string &dataName)=0
unregister a receiver from receiving callbacks for certain group/data
void add(const DataItem &item)
adds the DataItem item to the end of the package.
std::map< mars::cfg_manager::cfgParamId, Plot * > cfgParamIdToPlot
Class containing information about a DataPackage.
DataBrokerPlotter(DataBrokerPlotterLib *_mainLib, mars::data_broker::DataBrokerInterface *_dataBroker, mars::cfg_manager::CFGManagerInterface *cfg, std::string _name, QWidget *parent=0)
A collection of DataItems.
mars::cfg_manager::cfgPropertyStruct sTime
The interface every DataBroker should implement.
std::map< mars::cfg_manager::cfgParamId, mars::cfg_manager::cfgPropertyStruct * > cfgParamIdProp
virtual void cfgUpdateProperty(cfg_manager::cfgPropertyStruct _property)
mars::data_broker::DataBrokerInterface * dataBroker
std::list< PackageData > packageList