1 /***************************************************************************
2 parameterplotter.cpp - description
5 copyright : (C) 2008 by Marco Gittler
6 email : g.marco@freenet.de
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
18 #include "parameterplotter.h"
20 #include <KPlotObject>
21 #include <QMouseEvent>
25 ParameterPlotter::ParameterPlotter (QWidget *parent):KPlotWidget (parent){
26 setAntialiasing(true);
32 plot=new KPlotObject();
33 plot->setShowLines(true);
36 void ParameterPlotter::setPointLists(const QList< QPair<QString, QMap< int , QVariant > > >& params,int startframe, int endframe){
38 QListIterator <QPair <QString, QMap< int , QVariant > > > nameit(params);
40 while (nameit.hasNext() ){
42 QPair<QString, QMap< int , QVariant > > item=nameit.next();
43 QString name(item.first);
44 QMapIterator <int,QVariant> pointit=item.second;
45 while (pointit.hasNext()){
47 plot->addPoint(QPointF(pointit.key(),pointit.value().toDouble()),"",1);
48 if (pointit.value().toInt() >maxy)
49 maxy=pointit.value().toInt();
54 setLimits(0,endframe,0,maxy);
58 QList< QPair<QString, QMap<int,QVariant> > > ParameterPlotter::getPointLists(){
62 void ParameterPlotter::mouseMoveEvent ( QMouseEvent * event ) {
65 QList<KPlotPoint*> list= pointsUnderPoint (event->pos()-QPoint(leftPadding(), topPadding() ) ) ;
67 foreach (KPlotObject *o, plotObjects() ){
68 foreach (KPlotPoint* p, o->points()){
70 QPoint delta=event->pos()-oldmousepoint;
71 movepoint->setY(movepoint->y()-delta.y()*dataRect().height()/pixRect().height() );
73 movepoint->setX(movepoint->x()+delta.x()*dataRect().width()/pixRect().width() );
74 replacePlotObject(i,o);
75 oldmousepoint=event->pos();
83 void ParameterPlotter::mousePressEvent ( QMouseEvent * event ) {
84 QList<KPlotPoint*> list= pointsUnderPoint (event->pos()-QPoint(leftPadding(), topPadding() ) ) ;
87 oldmousepoint=event->pos();