[Clam-devel] GSoC, patch and questions...: Patch for autoadd sink and source
Pau Arumí Albó
parumi at iua.upf.edu
Thu Apr 24 03:46:28 PDT 2008
Ok, I see now it's functional. A few comments on the patch.
El dj 24 de 04 del 2008 a les 06:28 -0300, en/na Natanael Olaiz va
escriure:
> Index: NetworkEditor/src/NetworkCanvas.hxx
> ===================================================================
> --- NetworkEditor/src/NetworkCanvas.hxx (revision 11324)
> +++ NetworkEditor/src/NetworkCanvas.hxx (working copy)
> @@ -891,7 +891,8 @@
>
> markAsChanged();
> }
> - void addPortMonitorProcessing( ProcessingBox * processing,
> QPoint point, const QString & monitorType )
> + // renamed from addPortMonitorProcessing (patch on SVN 11324)
Unnecessary comment. we'll put that note in the commit log.
> + void addLinkedProcessing( ProcessingBox * processing, QPoint
> point, const QString & monitorType )
> {
> if (networkIsDummy()) return;
>
> @@ -906,6 +907,27 @@
>
> markAsChanged();
> }
> +
> +
> + void addLinkedSource( ProcessingBox * processing, QPoint
> point, const QString & monitorType )
As you said, "monitorType" should be something like "processingType".
Check similar cases.
> + {
> + if (networkIsDummy()) return;
> +
> + unsigned portIndex =
> processing->portIndexByYPos(point);
> + QString inPortName =
> processing->getInportName(portIndex);
> +
> + std::string processingId =
> _network->AddProcessing(monitorType.toStdString() );
> + CLAM::Processing & portMonitor =
> _network->GetProcessing( processingId );
> + // add box to canvas and connect
> + addProcessingBox( processingId.c_str(), &portMonitor,
> point+QPoint(-200,0));
> + addPortConnection(getBox(processingId.c_str()), 0,
> processing, portIndex);
> + markAsChanged();
> + }
> +
> +
> +
> +
> +
> virtual QWidget * embededWidgetFor(void * processing);
> virtual unsigned nInports(void * processing) { return
> ((CLAM::Processing*)processing)->GetInPorts().Size();}
> virtual unsigned nOutports(void * processing) { return
> ((CLAM::Processing*)processing)->GetOutPorts().Size();}
> @@ -1229,10 +1251,39 @@
> if (region==ProcessingBox::noRegion) continue;
> if (region!=ProcessingBox::outportsRegion)
> return;
>
> - addPortMonitorProcessing(_processings[i],
> point, monitorType);
> + addLinkedProcessing(_processings[i], point,
> monitorType);
> return;
> }
> }
> + void onAddSink()
> + {
> + QPoint point = ((QAction*)sender())->data().toPoint();
> + QString outputType = ((QAction*)sender())->text();
> + for (unsigned i = _processings.size(); i--; )
> + {
> + ProcessingBox::Region region =
> _processings[i]->getRegion(point);
> + if (region==ProcessingBox::noRegion) continue;
> + if (region!=ProcessingBox::outportsRegion)
> return;
> + addLinkedProcessing(_processings[i], point,
> outputType);
> + return;
> + }
> + }
> +
> + void onAddSource()
> + {
> + QPoint point = ((QAction*)sender())->data().toPoint();
> + QString inputType = ((QAction*)sender())->text();
> + for (unsigned i = _processings.size(); i--; )
> + {
> + ProcessingBox::Region region =
> _processings[i]->getRegion(point);
> + if (region==ProcessingBox::noRegion) continue;
> + if (region!=ProcessingBox::inportsRegion)
> return;
> + addLinkedSource(_processings[i], point,
> inputType);
> + return;
> + }
> + }
> +
I see that onAddSource and onAddMonitor, and addLinkedSource and
addMonitor are identical and both could be merged into the more general
addLinkedProcessing.
But we can leave this refactoring as a TODO.
I'd like to hear David's comments on this.
> void onConfigure()
> {
> QPoint point = ((QAction*)sender())->data().toPoint();
> @@ -1340,6 +1391,13 @@
> return
> ((CLAM::Processing*)processing)->GetOutPorts().GetByNumber(index).GetTypeId().name();
> }
>
> + std::string inportTypeId(void * processing, unsigned index)
> const
> + {
> + if (!processing) return "";
> + return
> ((CLAM::Processing*)processing)->GetInPorts().GetByNumber(index).GetTypeId().name();
> + }
> +
> +
> virtual void contextMenu(QMenu* menu, const QPoint &
> translatedPos)
> {
> for (unsigned i = _processings.size(); i--; )
> @@ -1375,7 +1433,26 @@
> QIcon icon =
> QIcon( QString(":/icons/images/%1").arg(iconPath.c_str()) );
> menu->addAction( icon,
> key, this, SLOT(onAddMonitor()))->setData(translatedPos);
> }
> + if
> (!((outportTypeId(_processings[i]->model(),portindex)).compare("f")))
Ups! I don't understand this. Why "f"?? it should be something like
"CLAM::AudioStream". But yes, I see it is working... A clue, anyone?
Style tip: prefer a==b over !a.compare(b)
I'm attaching two VERY simple icons -- improve/use others, if you want.
But at least now you'll be able to try if retrieving the icon from the
factory metadata works.
Good, we are very close to commitable state :-)
Pai
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sink.svg
Type: image/svg+xml
Size: 6251 bytes
Desc: not available
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20080424/7c7fbc64/attachment-0010.svg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: source.svg
Type: image/svg+xml
Size: 6253 bytes
Desc: not available
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20080424/7c7fbc64/attachment-0011.svg>
More information about the clam-devel
mailing list