-void ParameterPlotter::setPointLists(const QDomElement& d,int startframe,int endframe){
-
- //QListIterator <QPair <QString, QMap< int , QVariant > > > nameit(params);
- itemParameter=d;
- QDomNodeList namenode = d.elementsByTagName("parameter");
-
- int max_y=0;
- kplotwidget->removeAllPlotObjects ();
- parameterNameList.clear();
- plotobjects.clear();
-
-
- for (int i=0;i< namenode.count() ;i++){
- KPlotObject *plot=new KPlotObject(colors[plotobjects.size()%colors.size()]);
- plot->setShowLines(true);
- //QPair<QString, QMap< int , QVariant > > item=nameit.next();
- QDomNode pa=namenode.item(i);
- QDomNode na=pa.firstChildElement("name");
-
- parameterNameList << na.toElement().text();
-
-
- max_y=pa.attributes().namedItem("max").nodeValue().toInt();
- int val=pa.attributes().namedItem("value").nodeValue().toInt();
- plot->addPoint((i+1)*20,val);
- /*TODO keyframes
- while (pointit.hasNext()){
- pointit.next();
- plot->addPoint(QPointF(pointit.key(),pointit.value().toDouble()),item.first,1);
- if (pointit.value().toInt() >maxy)
- max_y=pointit.value().toInt();
- }*/
- plotobjects.append(plot);
- }
- maxx=endframe;
- maxy=max_y;
- kplotwidget->setLimits(0,endframe,0,maxy+10);
- kplotwidget->addPlotObjects(plotobjects);
+void ParameterPlotter::setPointLists(const QDomElement& d, const QString& paramName, int startframe, int endframe) {
+
+ //QListIterator <QPair <QString, QMap< int , QVariant > > > nameit(params);
+ m_paramName = paramName;
+ itemParameter = d;
+ QDomNodeList namenode = d.elementsByTagName("parameter");
+
+ max_y = 0;
+ min_y = 0;
+ removeAllPlotObjects();
+ stretchFactors.clear();
+ parameterNameList.clear();
+ plotobjects.clear();
+
+ QString dat;
+ QTextStream stre(&dat);
+ d.save(stre, 2);
+ kDebug() << dat;
+ int i = 0;
+ while (!namenode.item(i).isNull() && namenode.item(i).toElement().attribute("name") != m_paramName)
+ i++;
+ if (namenode.count()) {
+
+
+ QDomElement pa = namenode.item(i).toElement();
+ QDomNode na = pa.firstChildElement("name");
+
+ parameterNameList << pa.attribute("namedesc").split(";");
+ emit parameterList(parameterNameList);
+
+ //max_y=pa.attributes().namedItem("max").nodeValue().toInt();
+ //int val=pa.attributes().namedItem("value").nodeValue().toInt();
+ QStringList defaults;
+ if (pa.attribute("start").contains(";"))
+ defaults = pa.attribute("start").split(";");
+ else if (pa.attribute("value").contains(";"))
+ defaults = pa.attribute("value").split(";");
+ else if (pa.attribute("default").contains(";"))
+ defaults = pa.attribute("default").split(";");
+ QStringList maxv = pa.attribute("max").split(";");
+ QStringList minv = pa.attribute("min").split(";");
+ for (int i = 0;i < maxv.size() && i < minv.size();i++) {
+ if (max_y < maxv[i].toInt()) max_y = maxv[i].toInt();
+ if (min_y > minv[i].toInt()) min_y = minv[i].toInt();
+ }
+ for (int i = 0;i < parameterNameList.count();i++) {
+ KPlotObject *plot = new KPlotObject(colors[plotobjects.size()%colors.size()]);
+ plot->setShowLines(true);
+ if (!stretchFactors.contains(i) && i < maxv.size()) {
+ if (maxv[i].toInt() != 0)
+ stretchFactors[i] = max_y / maxv[i].toInt();
+ else
+ stretchFactors[i] = 1.0;
+ }
+ if (i < defaults.size() && defaults[i].toDouble() > max_y)
+ defaults[i] = max_y;
+ int def = 0;
+ if (i < defaults.size())
+ def = (int)(defaults[i].toInt() * stretchFactors[i]);
+ QString name = "";
+ if (i < parameterNameList.size())
+ name = parameterNameList[i];
+ plot->addPoint(startframe, def, name);
+ //add keyframes here
+ plot->addPoint(endframe, def);
+
+ plotobjects.append(plot);
+ }
+
+ /*TODO keyframes
+ while (pointit.hasNext()){
+ pointit.next();
+ plot->addPoint(QPointF(pointit.key(),pointit.value().toDouble()),item.first,1);
+ if (pointit.value().toInt() >maxy)
+ max_y=pointit.value().toInt();
+ }*/
+
+ }
+ maxx = endframe;
+ maxy = max_y;
+ setLimits(-1, endframe + 1, min_y - 10, maxy + 10);
+
+ addPlotObjects(plotobjects);