mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-16 17:44:36 +00:00
Added new plugins intefaces, tested with shownormal render mode
This commit is contained in:
parent
cbdc96ff57
commit
a20ba59f29
@ -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 <GL/glew.h>
|
||||
#include <wrap/gl/space.h>
|
||||
|
||||
#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();
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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 <QToolBar>
|
||||
|
||||
|
||||
#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<MeshFilterInterface *>(plugin);
|
||||
if (iFilter)
|
||||
addToMenu(plugin, iFilter->filters(), filterMenu, SLOT(applyFilter()));
|
||||
MeshRenderInterface *iRender = qobject_cast<MeshRenderInterface *>(plugin);
|
||||
if (iRender)
|
||||
addToMenu(plugin, iRender->modes(), renderMenu, SLOT(applyRenderMode()));
|
||||
|
||||
pluginFileNames += fileName;
|
||||
}
|
||||
@ -408,8 +420,23 @@ void MainWindow::applyFilter()
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
MeshFilterInterface *iFilter = qobject_cast<MeshFilterInterface *>(action->parent());
|
||||
|
||||
iFilter->applyFilter(action->text(),*(((GLArea *)(workspace->activeWindow()))->mm ), this);
|
||||
qobject_cast<GLArea *>(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<QAction *>(sender());
|
||||
MeshRenderInterface *iRender = qobject_cast<MeshRenderInterface *>(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);
|
||||
/////////////////////////////////////////
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#include <QWorkspace>
|
||||
#include <QStringList>
|
||||
#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<GLArea *>(workspace->activeWindow()); }
|
||||
GLArea *gla;
|
||||
vector<MeshModel *> VM;
|
||||
QScrollArea *scrollArea;
|
||||
@ -90,7 +92,7 @@ private:
|
||||
|
||||
QMenu *fileMenu;
|
||||
QMenu *filterMenu;
|
||||
QMenu *RenderMenu;
|
||||
QMenu *renderMenu;
|
||||
QMenu *viewMenu;
|
||||
QMenu *toolBarMenu;
|
||||
QMenu *windowsMenu;
|
||||
|
||||
@ -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<CMeshO>::Box(cm);
|
||||
vcg::tri::UpdateNormals<CMeshO>::PerVertexPerFace(cm);
|
||||
vcg::tri::UpdateNormals<CMeshO>::PerVertexNormalizedPerFace(cm);
|
||||
|
||||
return ret==::vcg::ply::E_NOERROR;
|
||||
}
|
||||
|
||||
@ -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 <QtGui>
|
||||
|
||||
#include "meshmodel.h"
|
||||
#include "interfaces.h"
|
||||
#include "plugindialog.h"
|
||||
|
||||
|
||||
@ -25,8 +25,8 @@
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
#include <meshlab/interfaces.h>
|
||||
#include <meshlab/meshmodel.h>
|
||||
#include <meshlab/interfaces.h>
|
||||
|
||||
class ExtraMeshFilterPlugin : public QObject, public MeshFilterInterface
|
||||
{
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = meshfilter
|
||||
SUBDIRS = meshfilter \
|
||||
meshrender
|
||||
|
||||
# install
|
||||
target.path = $$[QT_INSTALL_EXAMPLES]/tools/plugandpaintplugins
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user