]> git.sesse.net Git - kdenlive/commitdiff
new points can be simple added
authorMarco Gittler <marco@gitma.de>
Wed, 20 Feb 2008 19:53:47 +0000 (19:53 +0000)
committerMarco Gittler <marco@gitma.de>
Wed, 20 Feb 2008 19:53:47 +0000 (19:53 +0000)
svn path=/branches/KDE4/; revision=1889

src/effectstackview.cpp
src/parameterplotter.cpp
src/parameterplotter.h

index ee58d49b63865cc6a7c7b71c382f6eafda24d2f2..a981a69b81f870de73cdcc113eb07d74617c2ff5 100644 (file)
@@ -198,6 +198,7 @@ void EffectStackView::updateButtonStatus(){
 void EffectStackView::slotParameterChanged(const QString& text){
        
        //ui.buttonNewPoints->setEnabled(text!="all");
+       ui.kplotwidget->replot(text);
        updateButtonStatus();
 }
 
index ef50c768922dbf47aa2807681238dea32844ed23..0b107daee7577eb78a77023091bab2ffa048a18b 100644 (file)
@@ -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<QString, QMap< int , QVariant > > >& params,int startframe, int endframe){
@@ -63,6 +64,7 @@ void ParameterPlotter::setPointLists(const QList< QPair<QString, QMap< int , QVa
        maxy=max_y;
        setLimits(0,endframe,0,maxy+10);
        addPlotObjects(plotobjects);
+
 }
 
 void ParameterPlotter::createParametersNew(){
@@ -116,14 +118,49 @@ void ParameterPlotter::mouseMoveEvent ( QMouseEvent * event ) {
        }
 }
 
+void ParameterPlotter::replot(const QString & name){
+       //removeAllPlotObjects();
+       int i=0;
+       bool drawAll=name.isEmpty() || name=="all";
+       activeIndexPlot=-1;
+       foreach (KPlotObject* p,plotObjects() ){
+               p->setShowPoints(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<KPlotPoint*> 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<KPlotPoint*> 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<KPlotPoint*> points=p->points();
+                       QList<QPointF> 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
+}
index a8c3a98027c1ba229859371f056036ef8ab8e3f6..1208b089e7f87de6e9545608d7fee5d6f0e81d02 100644 (file)
@@ -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<KPlotObject*> plotobjects;
                QList<QColor> colors;
+               
        protected:
                void mouseMoveEvent ( QMouseEvent * event );
                void mousePressEvent ( QMouseEvent * event );