]> git.sesse.net Git - kdenlive/commitdiff
effectstack can setup the parameter now
authorMarco Gittler <marco@gitma.de>
Thu, 21 Feb 2008 00:38:52 +0000 (00:38 +0000)
committerMarco Gittler <marco@gitma.de>
Thu, 21 Feb 2008 00:38:52 +0000 (00:38 +0000)
svn path=/branches/KDE4/; revision=1894

src/effectstackview.cpp
src/effectstackview.h
src/parameterplotter.cpp
src/parameterplotter.h
src/widgets/effectstack_ui.ui

index 58131f975259d0a9987eb3e6180dad8f4445b944..08b27661c3adeebd9bfcdf63fa6332ae1a7950b8 100644 (file)
@@ -66,8 +66,9 @@ EffectStackView::EffectStackView(EffectsList *audioEffectList, EffectsList *vide
        connect (ui.buttonNewPoints, SIGNAL (clicked()), this , SLOT ( slotSetNew() ) );
        connect (ui.buttonHelp, SIGNAL (clicked()), this , SLOT ( slotSetHelp() ) );
        connect (ui.parameterList, SIGNAL (currentIndexChanged ( const QString &  ) ), this, SLOT( slotParameterChanged(const QString&) ) );
-       connect (ui.effectlist, SIGNAL (itemSelectionChanged() ) , this, SLOT ( itemSelectionChanged()));
-       
+       //connect (ui.effectlist, SIGNAL (itemSelectionChanged() ) , this, SLOT ( itemSelectionChanged()));
+       connect( this,SIGNAL (transferParamDesc(const QDomElement&,int ,int) ), ui.kplotwidget, SLOT(setPointLists(const QDomElement&,int ,int) ));
+       connect(ui.kplotwidget, SIGNAL (parameterChanged(QDomElement ) ), this , SLOT (slotUpdateEffectParams(QDomElement)));
        effectLists["audio"]=audioEffectList;
        effectLists["video"]=videoEffectList;
        effectLists["custom"]=customEffectList;
@@ -75,29 +76,11 @@ EffectStackView::EffectStackView(EffectsList *audioEffectList, EffectsList *vide
        ui.infoBox->hide();     
        updateButtonStatus();
        
-       
-       QList< QPair<QString, QMap<int,QVariant> > > points;
-       QMap<int,QVariant> data;
-       data[0]=0.1;
-       data[100]=30;
-       data[255]=50;
-       data[300]=100;
-       QPair<QString,QMap<int,QVariant> > testpair("gray",data);
-       points.append(testpair);
-       
-       QMap<int,QVariant> data1;
-       data1[0]=20;
-       data1[10]=70;
-       data1[155]=110;
-       data1[300]=133;
-       QPair<QString,QMap<int,QVariant> > testpair1("dx",data1);
-       points.append(testpair1);
-       ui.parameterList->addItem("all");
-       ui.parameterList->addItem("gray");
-       ui.parameterList->addItem("dx");
-       
-       ui.kplotwidget->setPointLists(points,0,305);
-       
+}
+
+void EffectStackView::slotUpdateEffectParams(QDomElement e){
+       if (clipref)
+               emit updateClipEffect(clipref, e);
 }
 
 void EffectStackView::slotClipItemSelected(ClipItem* c)
@@ -108,15 +91,29 @@ void EffectStackView::slotClipItemSelected(ClipItem* c)
                return;
        }
        setEnabled(true);
-       effects=clipref->effectNames();
-       setupListView(effects);
+       //effects=clipref->effectNames();
+       effects.clear();
+       for (int i=0;i<clipref->effectsCount();i++){
+               /*QString outstr;
+               QTextStream str(&outstr);
+               clipref->effectAt(i).save(str,2);
+               kDebug() << outstr;*/
+               effects.append(clipref->effectAt(i));
+       }
+       setupListView();
        
 }
 
-void EffectStackView::setupListView(const QStringList& effects_list){
+void EffectStackView::setupListView(){
 
        ui.effectlist->clear();
-       ui.effectlist->addItems(effects);
+       foreach (QDomElement d,effects){
+               
+               QDomNode namenode = d.elementsByTagName("name").item(0);
+               if (!namenode.isNull()) 
+                       ui.effectlist->addItem(namenode.toElement().text() );
+       }
+       //ui.effectlist->addItems(effects);
        for (int i=0;i< ui.effectlist->count();i++){
                QListWidgetItem* item=ui.effectlist->item(i);
                item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsDragEnabled|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
@@ -133,6 +130,16 @@ void EffectStackView::slotItemSelectionChanged(){
        
        if (ui.effectlist->currentItem() && ui.effectlist->currentItem()->isSelected() ){
                activeRow=ui.effectlist->row( ui.effectlist->currentItem() );
+               ui.parameterList->clear();
+               ui.parameterList->addItem("all");
+               QDomNodeList namenode = effects.at(activeRow).elementsByTagName("parameter");
+               for (int i=0;i<namenode.count();i++){
+                       QDomNode pa=namenode.item(i);
+                       QDomNode na=pa.firstChildElement("name");
+                       ui.parameterList->addItem(na.toElement().text() );
+               }
+               
+               emit transferParamDesc(effects.at(activeRow) ,0,100);//minx max frame
        }else{
                activeRow=-1;
        }
@@ -146,7 +153,7 @@ void EffectStackView::slotItemUp(){
                effects.swap(activeRow, activeRow-1);
        }
        activeRow--;
-       setupListView(effects);
+       setupListView();
        
 }
 
@@ -155,7 +162,7 @@ void EffectStackView::slotItemDown(){
                effects.swap(activeRow, activeRow+1);
        }
        activeRow++;
-       setupListView(effects);
+       setupListView();
        
 }
 
@@ -167,7 +174,7 @@ void EffectStackView::slotItemDel(){
        }
        if (effects.size()>0 && activeRow>0)
        activeRow--;
-       setupListView(effects);
+       setupListView();
        
 }
 
@@ -242,9 +249,15 @@ void EffectStackView::slotNewEffect(){
        QAction *result=displayMenu->exec(mapToGlobal(ui.buttonNew->pos()+ui.buttonNew->rect().bottomRight()));
        
        if (result){
-               effects.append(result->data().toString());
-               setupListView(effects);
-               kDebug()<< result->data();
+               //TODO effects.append(result->data().toString());
+               foreach (EffectsList* e, effectLists.values()){
+                       QDomElement dom=e->getEffectByName(result->data().toString());
+                       clipref->addEffect(dom);
+                       slotClipItemSelected(clipref);
+               }
+               
+               setupListView();
+               //kDebug()<< result->data();
        }
        delete displayMenu;
        
index 662fd5e6005e1b83916857964a6b8329d78f1e83..dd2ad0567aeb5267c19a2445543a29d4c81229fe 100644 (file)
@@ -34,10 +34,10 @@ class EffectStackView : public QWidget
        
 private:
        int activeRow;
-       QStringList effects;
+       QList<QDomElement> effects;
        Ui::EffectStack_UI ui;
        ClipItem* clipref;
-       void setupListView(const QStringList& );
+       void setupListView();
        void updateButtonStatus();
        QMap<QString,EffectsList*> effectLists;
 
@@ -55,10 +55,12 @@ public slots:
        void slotShowInTimeline();
        void slotParameterChanged(const QString&);
        void itemSelectionChanged();
-
+       void slotUpdateEffectParams(QDomElement);
 signals:
+       void transferParamDesc(const QDomElement&,int ,int);
        void removeEffect(ClipItem*, QDomElement);
        void updateClipEffect(ClipItem*, QDomElement);
+
 };
 
 #endif
index 0b107daee7577eb78a77023091bab2ffa048a18b..4208e1407411642d8a0cf5ef6ec75206559c55ec 100644 (file)
@@ -37,27 +37,52 @@ ParameterPlotter::ParameterPlotter (QWidget *parent):KPlotWidget (parent){
        m_newPoints=false;
        activeIndexPlot=-1;
 }
-
-void ParameterPlotter::setPointLists(const QList< QPair<QString, QMap< int , QVariant > > >& params,int startframe, int endframe){
+/*
+    <name>Lines</name>
+    <description>Lines from top to bottom</description>
+    <author>Marco Gittler</author>
+    <properties tag="lines" id="lines" />
+    <parameter default="5" type="constant" value="5" min="0" name="num" max="255" >
+      <name>Num</name>
+    </parameter>
+    <parameter default="4" type="constant" value="4" min="0" name="width" max="255" >
+      <name>Width</name>
+    </parameter>
+  </effect>
+
+*/
+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");
        
-       QListIterator <QPair <QString, QMap< int , QVariant > > > nameit(params);
        int max_y=0;
+       removeAllPlotObjects ();
        parameterNameList.clear();
+       plotobjects.clear();
        
-       
-       while (nameit.hasNext() ){      
+
+       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();
-               parameterNameList << item.first;
-
-               QMapIterator <int,QVariant> pointit=item.second;
+               //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;
@@ -68,23 +93,31 @@ void ParameterPlotter::setPointLists(const QList< QPair<QString, QMap< int , QVa
 }
 
 void ParameterPlotter::createParametersNew(){
-       QList< QPair<QString, QMap<int,QVariant> > > ret;
+       
        QList<KPlotObject*> plotobjs=plotObjects();
        if (plotobjs.size() != parameterNameList.size() ){
                kDebug() << "ERROR size not equal";
        }
-       
-       for (int i=0;i<parameterNameList.size() ;i++){
+       QDomNodeList namenode = itemParameter.elementsByTagName("parameter");
+       for (int i=0;i<namenode.count() ;i++){
                QList<KPlotPoint*> points=plotobjs[i]->points();
+               QDomNode pa=namenode.item(i);
+               
+               
+               
+               
+               
+               
                QMap<int,QVariant> vals;
                foreach (KPlotPoint *o,points){
-                       vals[o->x()]=o->y();
+                       //vals[o->x()]=o->y();
+                       pa.attributes().namedItem("value").setNodeValue(QString::number(o->y()));
                }
                QPair<QString,QMap<int,QVariant> > pair("contrast",vals);
-               ret.append(pair);
+               //ret.append(pair);
        }
        
-       emit parameterChanged(ret);
+       emit parameterChanged(itemParameter);
        
 }
 
@@ -136,33 +169,37 @@ void ParameterPlotter::mousePressEvent ( QMouseEvent * event ) {
        //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 && 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;
+       if (event->button()==Qt::LeftButton){
+               if (list.size() > 0){
+                       movepoint=list[0];
+                       oldmousepoint=event->pos();
+               }else{
+                       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()));
                                }
-                               newpoints.append(QPointF(pt->x(),pt->y()));
-                       }
-                       p->clearPoints();
-                       foreach (QPointF qf, newpoints ){
-                               p->addPoint(qf);
+                               p->clearPoints();
+                               foreach (QPointF qf, newpoints ){
+                                       p->addPoint(qf);
+                               }
+                               replacePlotObject(activeIndexPlot,p);
                        }
-                       replacePlotObject(activeIndexPlot,p);
+                       movepoint=NULL;
                }
-               movepoint=NULL;
+       }else if (event->button()==Qt::LeftButton){
+               //menu for deleting or exact setup of point
        }
 }
 
index 1208b089e7f87de6e9545608d7fee5d6f0e81d02..058286f0fa076cfad4434d6f2a6697b0490d8768 100644 (file)
@@ -16,6 +16,7 @@
  ***************************************************************************/
 
 #include <KPlotWidget>
+#include <QDomElement>
 
 class ParameterPlotter : public KPlotWidget {
        Q_OBJECT
@@ -41,14 +42,14 @@ class ParameterPlotter : public KPlotWidget {
                void createParametersNew();
                QList<KPlotObject*> plotobjects;
                QList<QColor> colors;
-               
+               QDomElement itemParameter;
        protected:
                void mouseMoveEvent ( QMouseEvent * event );
                void mousePressEvent ( QMouseEvent * event );
        public slots:
-               void setPointLists(const QList< QPair<QString, QMap<int,QVariant> > >&,int,int);
+               void setPointLists(const QDomElement&,int ,int);
        signals:
-               void parameterChanged(QList< QPair<QString, QMap<int,QVariant> > > );
+               void parameterChanged(QDomElement );
                void updateFrame(int);
        
 };
index 0fc695c6d456f9fc0a4085988700c551e28aba89..025d1e2c56957d1a06460ca99318af184f531578 100644 (file)
       <widget class="QWidget" name="layoutWidget" >
        <layout class="QVBoxLayout" >
         <item>
-         <widget class="ParameterPlotter" name="kplotwidget" >
-          <property name="sizePolicy" >
-           <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
-            <horstretch>0</horstretch>
-            <verstretch>0</verstretch>
-           </sizepolicy>
-          </property>
-          <property name="grid" stdset="0" >
-           <bool>true</bool>
+         <widget class="QStackedWidget" name="stackedWidget" >
+          <property name="currentIndex" >
+           <number>0</number>
           </property>
+          <widget class="QWidget" name="page" >
+           <layout class="QGridLayout" >
+            <item row="0" column="0" >
+             <layout class="QVBoxLayout" >
+              <item>
+               <widget class="ParameterPlotter" name="kplotwidget" />
+              </item>
+             </layout>
+            </item>
+           </layout>
+          </widget>
+          <widget class="QWidget" name="page_2" />
          </widget>
         </item>
         <item>
          <layout class="QHBoxLayout" >
           <item>
            <widget class="QToolButton" name="buttonLeftRight" >
+            <property name="toolTip" >
+             <string>move on X axis</string>
+            </property>
             <property name="text" >
              <string>...</string>
             </property>
             <property name="enabled" >
              <bool>true</bool>
             </property>
+            <property name="toolTip" >
+             <string>move on Y axis</string>
+            </property>
             <property name="text" >
              <string>...</string>
             </property>
             <property name="enabled" >
              <bool>false</bool>
             </property>
+            <property name="toolTip" >
+             <string>update values in timeline</string>
+            </property>
             <property name="text" >
              <string>...</string>
             </property>
             <property name="enabled" >
              <bool>false</bool>
             </property>
+            <property name="toolTip" >
+             <string>create new points</string>
+            </property>
             <property name="text" >
              <string>...</string>
             </property>
             </property>
            </spacer>
           </item>
+          <item>
+           <widget class="QCheckBox" name="checkBox" >
+            <property name="text" >
+             <string>GraphView</string>
+            </property>
+            <property name="checked" >
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
           <item>
            <widget class="KComboBox" name="parameterList" />
           </item>
             <property name="enabled" >
              <bool>true</bool>
             </property>
+            <property name="toolTip" >
+             <string>parameter description</string>
+            </property>
             <property name="text" >
              <string>...</string>
             </property>