From 5269e26dfb8deeac289b63bbd8210053f2abdff7 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Sat, 3 Dec 2005 16:07:14 +0000 Subject: [PATCH] Added samples for core-plugin calls --- src/meshlab/mainwindow.h | 3 +- src/meshlab/mainwindow_Init.cpp | 37 ++++++++++++--------- src/meshlab/mainwindow_RunTime.cpp | 53 +++++++++++++++++++----------- 3 files changed, 55 insertions(+), 38 deletions(-) diff --git a/src/meshlab/mainwindow.h b/src/meshlab/mainwindow.h index 047eab244..36577c60e 100644 --- a/src/meshlab/mainwindow.h +++ b/src/meshlab/mainwindow.h @@ -97,8 +97,7 @@ private: void loadPlugins(); void updateRecentFileActions(); void setCurrentFile(const QString &fileName); - void addToMenu(QObject *plugin, const QStringList &texts, QMenu *menu, - const char *member, QActionGroup *actionGroup = 0,bool chackable = false); + void addToMenu(QList, QMenu *menu, const char *slot); diff --git a/src/meshlab/mainwindow_Init.cpp b/src/meshlab/mainwindow_Init.cpp index bfa742d3c..821350392 100644 --- a/src/meshlab/mainwindow_Init.cpp +++ b/src/meshlab/mainwindow_Init.cpp @@ -24,6 +24,9 @@ History $Log$ +Revision 1.4 2005/12/03 16:07:14 glvertex +Added samples for core-plugin calls + Revision 1.3 2005/12/02 17:39:07 glvertex modified plugin import code. old plugins have been disabled cause of new interface. @@ -330,6 +333,7 @@ void MainWindow::createActions() showLogAct= new QAction (tr("Show &Infos"), this); showLogAct->setCheckable(true); + showLogAct->setChecked(true); connect(showLogAct, SIGNAL(triggered()), this, SLOT(showLog())); showInfoPaneAct= new QAction (tr("Show Info &Pane"), this); @@ -495,9 +499,7 @@ void MainWindow::loadPlugins() // NEW VERSION MeshRenderInterface *iDummy = qobject_cast(plugin); if(iDummy) - renderMenu->addActions(iDummy->actions()); - - + addToMenu(iDummy->actions(),renderMenu,SLOT(applyRenderMode())); pluginFileNames += fileName; } @@ -505,21 +507,24 @@ void MainWindow::loadPlugins() filterMenu->setEnabled(!filterMenu->actions().isEmpty() && workspace->activeWindow()); } -void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,QMenu *menu, const char *member, - QActionGroup *actionGroup,bool chackable) +void MainWindow::addToMenu(QList actionList, QMenu *menu, const char *slot) { - foreach (QString text, texts) { - QAction *action = new QAction(text, plugin); - TotalRenderList.push_back(action); - connect(action, SIGNAL(triggered()), this, member); - action->setCheckable(chackable); - menu->addAction(action); - - if (actionGroup) { - action->setCheckable(true); - actionGroup->addAction(action); - } + foreach (QAction *a, actionList) + { + connect(a,SIGNAL(triggered()),this,slot); + menu->addAction(a); } +// OLD LOOP CORE +// QAction *action = new QAction(text, plugin); +// TotalRenderList.push_back(action); +// connect(action, SIGNAL(triggered()), this, member); +// action->setCheckable(chackable); +// menu->addAction(action); +// +// if (actionGroup) { +// action->setCheckable(true); +// actionGroup->addAction(action); +// } } void MainWindow::setCurrentFile(const QString &fileName) diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index 62f000caa..dd48c66cb 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -24,6 +24,9 @@ History $Log$ +Revision 1.6 2005/12/03 16:07:14 glvertex +Added samples for core-plugin calls + Revision 1.5 2005/12/02 17:39:07 glvertex modified plugin import code. old plugins have been disabled cause of new interface. @@ -321,27 +324,37 @@ void MainWindow::applyFilter() void MainWindow::applyRenderMode() { - QAction *action = qobject_cast(sender()); + // NEW VERSION + QAction *action = qobject_cast(sender()); // find the action which has sent the signal + + // Make the call to the plugin core MeshRenderInterface *iRenderTemp = qobject_cast(action->parent()); - if(GLA()->iRendersList==0){ - GLA()->iRendersList= new list >; - GLA()->iRendersList->push_back(make_pair(action,iRenderTemp)); - GLA()->log.Log(GLLogStream::Info,"Enable Render mode %s",action->text().toLocal8Bit().constData());// .data()); - }else{ - bool found=false; - pair p; - foreach(p,*GLA()->iRendersList){ - if(iRenderTemp==p.second && p.first->text()==action->text()){ - GLA()->iRendersList->remove(p); - GLA()->log.Log(0,"Disabled Render mode %s",action->text().toLocal8Bit().constData());// .data()); - found=true; - } - } - if(!found){ - GLA()->iRendersList->push_back(make_pair(action,iRenderTemp)); - GLA()->log.Log(GLLogStream::Info,"Enable Render mode %s",action->text().toLocal8Bit().constData());// .data()); - } - } + iRenderTemp->Render(action,*(GLA()->mm),GLA()->getCurrentRenderMode(),GLA()); + + GLA()->log.Log(GLLogStream::Info,"%s",action->text().toLocal8Bit().constData()); // Prints out action name + + // OLD VERSION + //QAction *action = qobject_cast(sender()); + //MeshRenderInterface *iRenderTemp = qobject_cast(action->parent()); + //if(GLA()->iRendersList==0){ + // GLA()->iRendersList= new list >; + // GLA()->iRendersList->push_back(make_pair(action,iRenderTemp)); + // GLA()->log.Log(GLLogStream::Info,"Enable Render mode %s",action->text().toLocal8Bit().constData());// .data()); + //}else{ + // bool found=false; + // pair p; + // foreach(p,*GLA()->iRendersList){ + // if(iRenderTemp==p.second && p.first->text()==action->text()){ + // GLA()->iRendersList->remove(p); + // GLA()->log.Log(0,"Disabled Render mode %s",action->text().toLocal8Bit().constData());// .data()); + // found=true; + // } + // } + // if(!found){ + // GLA()->iRendersList->push_back(make_pair(action,iRenderTemp)); + // GLA()->log.Log(GLLogStream::Info,"Enable Render mode %s",action->text().toLocal8Bit().constData());// .data()); + // } + //} }