From f55254afa9ecb6b3fdcf1eaf47e50393d911a7af Mon Sep 17 00:00:00 2001 From: Marco Gittler Date: Wed, 20 Feb 2008 19:53:47 +0000 Subject: [PATCH] new points can be simple added svn path=/branches/KDE4/; revision=1889 --- src/effectstackview.cpp | 1 + src/parameterplotter.cpp | 43 +++++++++++++++++++++++++++++++++++++--- src/parameterplotter.h | 3 +++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/effectstackview.cpp b/src/effectstackview.cpp index ee58d49b..a981a69b 100644 --- a/src/effectstackview.cpp +++ b/src/effectstackview.cpp @@ -198,6 +198,7 @@ void EffectStackView::updateButtonStatus(){ void EffectStackView::slotParameterChanged(const QString& text){ //ui.buttonNewPoints->setEnabled(text!="all"); + ui.kplotwidget->replot(text); updateButtonStatus(); } diff --git a/src/parameterplotter.cpp b/src/parameterplotter.cpp index ef50c768..0b107dae 100644 --- a/src/parameterplotter.cpp +++ b/src/parameterplotter.cpp @@ -35,6 +35,7 @@ ParameterPlotter::ParameterPlotter (QWidget *parent):KPlotWidget (parent){ m_moveY=true; m_moveTimeline=true; m_newPoints=false; + activeIndexPlot=-1; } void ParameterPlotter::setPointLists(const QList< QPair > >& params,int startframe, int endframe){ @@ -63,6 +64,7 @@ void ParameterPlotter::setPointLists(const QList< QPairsetShowPoints(drawAll || parameterNameList[i]==name); + p->setShowLines(drawAll || parameterNameList[i]==name); + if ( parameterNameList[i]==name ) + activeIndexPlot = i; + replacePlotObject(i++,p); + } +} + void ParameterPlotter::mousePressEvent ( QMouseEvent * event ) { - QList list= pointsUnderPoint (event->pos()-QPoint(leftPadding(), topPadding() ) ) ; + //topPadding and other padding can be wrong and this (i hope) will be correctet in newer kde versions + QPoint inPlot=event->pos()-QPoint(leftPadding(), topPadding() ); + QList list= pointsUnderPoint (inPlot ) ; if (list.size() > 0){ movepoint=list[0]; oldmousepoint=event->pos(); }else{ - if (m_newPoints){ + if (m_newPoints && activeIndexPlot>=0){ //setup new points + KPlotObject* p=plotObjects()[activeIndexPlot]; + QList points=p->points(); + QList newpoints; + + double newx=inPlot.x()*dataRect().width()/pixRect().width(); + double newy=(height()-inPlot.y()-bottomPadding()-topPadding() )*dataRect().height()/pixRect().height(); + bool inserted=false; + foreach (KPlotPoint* pt,points){ + if (pt->x() >newx && !inserted){ + newpoints.append(QPointF(newx,newy)); + inserted=true; + } + newpoints.append(QPointF(pt->x(),pt->y())); + } + p->clearPoints(); + foreach (QPointF qf, newpoints ){ + p->addPoint(qf); + } + replacePlotObject(activeIndexPlot,p); } movepoint=NULL; } @@ -159,4 +196,4 @@ bool ParameterPlotter::isMoveTimeline(){ bool ParameterPlotter::isNewPoints(){ return m_newPoints; -} \ No newline at end of file +} diff --git a/src/parameterplotter.h b/src/parameterplotter.h index a8c3a980..1208b089 100644 --- a/src/parameterplotter.h +++ b/src/parameterplotter.h @@ -30,8 +30,10 @@ class ParameterPlotter : public KPlotWidget { bool isMoveY(); bool isMoveTimeline(); bool isNewPoints(); + void replot(const QString& name=""); private: KPlotPoint* movepoint; + int activeIndexPlot; bool m_moveX,m_moveY,m_moveTimeline,m_newPoints; QPoint oldmousepoint; int maxx,maxy; @@ -39,6 +41,7 @@ class ParameterPlotter : public KPlotWidget { void createParametersNew(); QList plotobjects; QList colors; + protected: void mouseMoveEvent ( QMouseEvent * event ); void mousePressEvent ( QMouseEvent * event ); -- 2.39.2