diff --git a/src/meshlab/glarea.cpp b/src/meshlab/glarea.cpp index 15f1d6029..6d4f00449 100644 --- a/src/meshlab/glarea.cpp +++ b/src/meshlab/glarea.cpp @@ -24,6 +24,9 @@ History $Log$ +Revision 1.13 2005/11/24 01:38:36 cignoni +Added new plugins intefaces, tested with shownormal render mode + Revision 1.12 2005/11/22 21:51:53 alemochi Changed frustum values. @@ -73,15 +76,15 @@ First rough version. It simply load a mesh. #include #include +#include "meshmodel.h" #include "interfaces.h" #include "glarea.h" -#include "meshmodel.h" using namespace vcg; GLArea::GLArea(QWidget *parent) : QGLWidget(parent) { - + iRender=0; } QSize GLArea::minimumSizeHint() const { @@ -105,8 +108,8 @@ void GLArea::initializeGL() glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); - drawMode = GLW::DMSmooth; - drawColor = GLW::CMNone; + rm.drawMode = GLW::DMSmooth; + rm.drawColor = GLW::CMNone; } void GLArea::paintGL() @@ -140,8 +143,9 @@ void GLArea::paintGL() glScale(d); glTranslate(-mm->cm.bbox.Center()); - mm->Render(drawMode,drawColor); - + mm->Render(rm.drawMode,rm.drawColor); + if(iRender) + iRender->Render(iRenderString,*mm,rm,this); glPushAttrib(GL_ENABLE_BIT); glDisable(GL_LIGHTING); log.glDraw(this,0,3); @@ -203,6 +207,6 @@ void GLArea::wheelEvent(QWheelEvent*e) void GLArea::setDrawMode(vcg::GLW::DrawMode mode) { - drawMode = mode; + rm.drawMode = mode; updateGL(); } \ No newline at end of file diff --git a/src/meshlab/glarea.h b/src/meshlab/glarea.h index d16f3442b..51880638f 100644 --- a/src/meshlab/glarea.h +++ b/src/meshlab/glarea.h @@ -24,6 +24,9 @@ History $Log$ +Revision 1.7 2005/11/24 01:38:36 cignoni +Added new plugins intefaces, tested with shownormal render mode + Revision 1.6 2005/11/20 19:30:50 glvertex - Added lighting parameters (still working on...) - Added logging events @@ -54,6 +57,24 @@ First rough version. It simply load a mesh. #include "GLLogStream.h" +#include "meshmodel.h" +#include "interfaces.h" + +class RenderMode +{ +public: + vcg::GLW::DrawMode drawMode; + vcg::GLW::ColorMode drawColor; + vcg::GLW::TextureMode drawTexture; + + bool Lighting; + bool BackFaceCull; + bool DoubleSideLighting; + bool FancyLighting; + bool CastShadow; + vcg::Point3f LightDir; +}; + class MeshModel; class GLArea : public QGLWidget @@ -72,6 +93,8 @@ public: QSize sizeHint() const; void setDrawMode(vcg::GLW::DrawMode mode); + MeshRenderInterface *iRender; + QString iRenderString; protected: void initializeGL(); void paintGL(); @@ -81,10 +104,11 @@ protected: void mouseReleaseEvent(QMouseEvent *event); void wheelEvent(QWheelEvent*e); - + private: - vcg::GLW::DrawMode drawMode; - vcg::GLW::ColorMode drawColor; + RenderMode rm; + }; + #endif diff --git a/src/meshlab/interfaces.h b/src/meshlab/interfaces.h index 8b9ce859c..bea3a25fe 100644 --- a/src/meshlab/interfaces.h +++ b/src/meshlab/interfaces.h @@ -23,6 +23,9 @@ /**************************************************************************** History $Log$ +Revision 1.6 2005/11/24 01:38:36 cignoni +Added new plugins intefaces, tested with shownormal render mode + Revision 1.5 2005/11/23 00:25:06 glvertex Reverted plugin interface to prev version @@ -43,9 +46,11 @@ class QPainter; class QPainterPath; class QPoint; class QRect; +class QIcon; class QString; class QStringList; class MeshModel; +class RenderMode; class MeshIOInterface { @@ -53,23 +58,58 @@ public: virtual ~MeshIOInterface() {} virtual QStringList format() const = 0; + + virtual bool open( + QString &filter, // "OBJ" + MeshModel &m, + int mask, + CallBackPos *cb=0, + QWidget *parent=0); + + virtual bool save( + QString &filter, // "OBJ" + MeshModel &m, + int mask, + vcg::CallBackPos *cb=0, + QWidget *parent= 0) ; // prima istanza il dialogo di opzioni viene sempre. }; class MeshFilterInterface { public: virtual ~MeshFilterInterface() {} - virtual bool applyFilter(QString &filter,MeshModel &m, QWidget *parent) = 0; + virtual QIcon *getIcon(QString &filter, QWidget *parent) {return 0;}; + virtual bool applyFilter(QString &filter, MeshModel &m, QWidget *parent) = 0; virtual QStringList filters() const = 0; }; +/* +Serve per customizzare totalmente il processo di rendering +Viene invocata al posto del rendering standard della mesh. +- Con che stato opengl gia settato per quanto riguarda: + - Matrici proj e model + - Lighting (dir e tipo luci) + - Bf cull ecc e tutto lo stato classico +*/ class MeshRenderInterface { public: virtual ~MeshRenderInterface() {} - virtual QStringList mode() const = 0; + virtual void Init( QString &mode, MeshModel &m, QWidget *parent){}; + virtual void Render( QString &mode, MeshModel &m, RenderMode &rm, QWidget *parent) =0; + virtual void Finalize(QString &mode, MeshModel &m, QWidget *parent){}; + + virtual QStringList modes() const = 0; +}; + +class MeshColorizeInterface +{ + virtual void Compute( QString &mode, MeshModel &m, QWidget *parent){}; + virtual void Show(QString &mode, bool show, MeshModel &m, QWidget *parent) {}; + virtual void Finalize(QString &mode, MeshModel &m, QWidget *parent){}; + virtual QStringList colorsFrom() const = 0; }; Q_DECLARE_INTERFACE(MeshIOInterface, diff --git a/src/meshlab/mainwindow.cpp b/src/meshlab/mainwindow.cpp index f87e426f2..973a00111 100644 --- a/src/meshlab/mainwindow.cpp +++ b/src/meshlab/mainwindow.cpp @@ -24,6 +24,9 @@ History $Log$ +Revision 1.24 2005/11/24 01:38:36 cignoni +Added new plugins intefaces, tested with shownormal render mode + Revision 1.23 2005/11/23 00:25:06 glvertex Reverted plugin interface to prev version @@ -117,6 +120,7 @@ First rough version. It simply load a mesh. #include +#include "meshmodel.h" #include "interfaces.h" #include "mainwindow.h" #include "glarea.h" @@ -165,7 +169,7 @@ void MainWindow::open(QString fileName) if(!nm->Open(fileName.toAscii())){ QMessageBox::information(this, tr("Plug & Paint"), tr("Cannot load %1.").arg(fileName)); - + delete nm; return; } @@ -180,6 +184,11 @@ void MainWindow::open(QString fileName) if(workspace->isVisible()) gla->showMaximized(); else QTimer::singleShot(00, gla, SLOT(showMaximized())); setCurrentFile(fileName); + if(!gla->mm->cm.textures.empty()) + { + QMessageBox::information(this, tr("Plug & Paint"), + tr("Cannot load %1.").arg(gla->mm->cm.textures[0].c_str())); + } return; } } @@ -335,8 +344,8 @@ void MainWindow::createMenus() //////////////////// Menu Render ////////////////////////////////////////////////////////////// - RenderMenu = menuBar()->addMenu(tr("&Render")); - RenderMenu->addActions(renderModeGroup->actions()); + renderMenu = menuBar()->addMenu(tr("&Render")); + renderMenu->addActions(renderModeGroup->actions()); //////////////////// Menu View //////////////////////////////////////////////////////////////// viewMenu = menuBar()->addMenu(tr("&View")); @@ -380,6 +389,9 @@ void MainWindow::loadPlugins() MeshFilterInterface *iFilter = qobject_cast(plugin); if (iFilter) addToMenu(plugin, iFilter->filters(), filterMenu, SLOT(applyFilter())); + MeshRenderInterface *iRender = qobject_cast(plugin); + if (iRender) + addToMenu(plugin, iRender->modes(), renderMenu, SLOT(applyRenderMode())); pluginFileNames += fileName; } @@ -408,8 +420,23 @@ void MainWindow::applyFilter() QAction *action = qobject_cast(sender()); MeshFilterInterface *iFilter = qobject_cast(action->parent()); - iFilter->applyFilter(action->text(),*(((GLArea *)(workspace->activeWindow()))->mm ), this); - qobject_cast(workspace->activeWindow())->log.Log(0,"Applied filter %s",action->text().toLocal8Bit().constData());// .data()); + iFilter->applyFilter(action->text(),*(GLA()->mm ), this); + GLA()->log.Log(0,"Applied filter %s",action->text().toLocal8Bit().constData());// .data()); +} + +void MainWindow::applyRenderMode() +{ + QAction *action = qobject_cast(sender()); + MeshRenderInterface *iRender = qobject_cast(action->parent()); + if(iRender==GLA()->iRender && GLA()->iRenderString ==action->text()) + { + GLA()->iRender=0; + GLA()->log.Log(0,"Disabled Render mode %s",GLA()->iRenderString.toLocal8Bit().constData());// .data()); + } else { + GLA()->iRender = iRender; + GLA()->iRenderString =action->text(); + GLA()->log.Log(0,"Enable Render mode %s",action->text().toLocal8Bit().constData());// .data()); + } } @@ -513,7 +540,7 @@ void MainWindow::updateMenus() ////////////////////////////////////////// filterMenu->setEnabled(active); ////////////////////////////////////////// - RenderMenu->setEnabled(active); + renderMenu->setEnabled(active); ////////////////////////////////////////// windowsMenu->setEnabled(active); ///////////////////////////////////////// diff --git a/src/meshlab/mainwindow.h b/src/meshlab/mainwindow.h index 0e1fc0f61..574170437 100644 --- a/src/meshlab/mainwindow.h +++ b/src/meshlab/mainwindow.h @@ -27,6 +27,7 @@ #include #include #include "meshmodel.h" +#include "glarea.h" #define MAXRECENTFILES 4 @@ -34,7 +35,6 @@ class QAction; class QActionGroup; class QMenu; class QScrollArea; -class GLArea; class QSignalMapper; class MainWindow : public QMainWindow @@ -52,6 +52,8 @@ private slots: void about(); void aboutPlugins(); void applyFilter(); + void applyRenderMode(); + void windowsTile(); void windowsCascade(); void updateWindowMenu(); @@ -78,7 +80,7 @@ private: QWorkspace *workspace; QSignalMapper *windowMapper; - + GLArea *GLA(){return qobject_cast(workspace->activeWindow()); } GLArea *gla; vector VM; QScrollArea *scrollArea; @@ -90,7 +92,7 @@ private: QMenu *fileMenu; QMenu *filterMenu; - QMenu *RenderMenu; + QMenu *renderMenu; QMenu *viewMenu; QMenu *toolBarMenu; QMenu *windowsMenu; diff --git a/src/meshlab/meshmodel.cpp b/src/meshlab/meshmodel.cpp index d98f23ed2..9add070b4 100644 --- a/src/meshlab/meshmodel.cpp +++ b/src/meshlab/meshmodel.cpp @@ -23,6 +23,9 @@ /**************************************************************************** History $Log$ +Revision 1.11 2005/11/24 01:38:36 cignoni +Added new plugins intefaces, tested with shownormal render mode + Revision 1.10 2005/11/23 00:04:03 cignoni added hint for better hiddenline @@ -62,7 +65,7 @@ bool MeshModel::Open(const char *filename) qDebug("Face 0 %f %f \n",cm.face[0].WT(0).u(),cm.face[0].WT(0).v()); vcg::tri::UpdateBounding::Box(cm); - vcg::tri::UpdateNormals::PerVertexPerFace(cm); + vcg::tri::UpdateNormals::PerVertexNormalizedPerFace(cm); return ret==::vcg::ply::E_NOERROR; } diff --git a/src/meshlab/plugindialog.cpp b/src/meshlab/plugindialog.cpp index 2927cd2ed..107902147 100644 --- a/src/meshlab/plugindialog.cpp +++ b/src/meshlab/plugindialog.cpp @@ -23,6 +23,9 @@ /**************************************************************************** History $Log$ +Revision 1.3 2005/11/24 01:38:36 cignoni +Added new plugins intefaces, tested with shownormal render mode + Revision 1.2 2005/11/21 12:12:54 cignoni Added copyright info @@ -30,6 +33,7 @@ Added copyright info #include +#include "meshmodel.h" #include "interfaces.h" #include "plugindialog.h" diff --git a/src/meshlabplugins/meshfilter/meshfilter.h b/src/meshlabplugins/meshfilter/meshfilter.h index 10e216f25..ae04e36d0 100644 --- a/src/meshlabplugins/meshfilter/meshfilter.h +++ b/src/meshlabplugins/meshfilter/meshfilter.h @@ -25,8 +25,8 @@ #include #include -#include #include +#include class ExtraMeshFilterPlugin : public QObject, public MeshFilterInterface { diff --git a/src/meshlabplugins/meshlabplugins.pro b/src/meshlabplugins/meshlabplugins.pro index d0852df56..a4f1d6c67 100644 --- a/src/meshlabplugins/meshlabplugins.pro +++ b/src/meshlabplugins/meshlabplugins.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs -SUBDIRS = meshfilter +SUBDIRS = meshfilter \ + meshrender # install target.path = $$[QT_INSTALL_EXAMPLES]/tools/plugandpaintplugins