** big change **

Added Layers managemnt.
Interfaces are changing...
This commit is contained in:
Paolo Cignoni cignoni 2007-04-16 09:24:37 +00:00
parent 3778812088
commit c6d3349cb4
9 changed files with 264 additions and 150 deletions

View File

@ -24,6 +24,11 @@
History
$Log$
Revision 1.121 2007/04/16 09:24:37 cignoni
** big change **
Added Layers managemnt.
Interfaces are changing...
Revision 1.120 2007/03/27 12:20:17 cignoni
Revamped logging iterface, changed function names in automatic parameters, better selection handling
@ -126,6 +131,8 @@ Removed various gl state leaking
#include "meshmodel.h"
#include "interfaces.h"
#include "glarea.h"
#include "layerDialog.h"
#include <wrap/gl/picking.h>
using namespace vcg;
@ -149,7 +156,7 @@ GLArea::GLArea(QWidget *parent)
currentShader = NULL;
lastFilterRef = NULL;
lastEditRef = NULL;
mm = NULL;
currentMesh = NULL;
currLogLevel = -1;
setAttribute(Qt::WA_DeleteOnClose,true);
// Projection Matrix starting settings
@ -159,7 +166,17 @@ GLArea::GLArea(QWidget *parent)
clipRatioNear = 1;
nearPlane = .2f;
farPlane = 5.f;
layerDialog = new LayerDialog(this);
}
void GLArea::addMesh(MeshModel *mm)
{
meshList.push_back(mm);
currentMesh=meshList.back();
//layerDialog->
}
/*
This member returns the information of the Mesh in terms of VC,VQ,FC,FQ,WT
@ -357,16 +374,19 @@ void GLArea::paintGL()
}
glPopMatrix();
// =============================================
/// Compute BBox
Box3f FullBBox;
foreach(MeshModel * mp, meshList)
FullBBox.Add(mp->cm.bbox);
// Finally apply the Trackball for the model
trackball.GetView();
glPushMatrix();
trackball.Apply(trackBallVisible && !takeSnapTile && iEdit==0);
float d=2.0f/mm->cm().bbox.Diag();
float d=2.0f/FullBBox.Diag();
glScale(d);
glTranslate(-mm->cm().bbox.Center());
glTranslate(-FullBBox.Center());
setLightModel();
// Modify frustum...
@ -389,16 +409,18 @@ void GLArea::paintGL()
if(rm.backFaceCull) glEnable(GL_CULL_FACE);
else glDisable(GL_CULL_FACE);
if(!mm->busy)
if(!mm()->busy)
{
if(iRenderer && currentShader) {
glPushAttrib(GL_ALL_ATTRIB_BITS);
iRenderer->Render(currentShader, *mm, rm, this);
iRenderer->Render(currentShader, *mm(), rm, this);
}
mm->Render(rm.drawMode,rm.colorMode,rm.textureMode);
foreach(MeshModel * mp, meshList)
if(mp->visible)
mp->Render(rm.drawMode,rm.colorMode,rm.textureMode);
if(iEdit) iEdit->Decorate(currentEditor,*mm,this);
if(iEdit) iEdit->Decorate(currentEditor,*mm(),this);
if(iRenderer) {
@ -407,11 +429,11 @@ void GLArea::paintGL()
}
// Draw the selection
if(rm.selectedFaces) mm->RenderSelectedFaces();
if(rm.selectedFaces) mm()->RenderSelectedFaces();
if(iDecoratorsList){
pair<QAction *,MeshDecorateInterface *> p;
foreach(p,*iDecoratorsList){p.second->Decorate(p.first,*mm,rm,this,qFont);}
foreach(p,*iDecoratorsList){p.second->Decorate(p.first,*mm(),rm,this,qFont);}
}
} ///end if busy
@ -501,11 +523,11 @@ void GLArea::displayInfo()
renderText(20,startPos+ 1*lineSpacing,tr("LOG MESSAGES"),qFont);
log.glDraw(this,currLogLevel,3,lineSpacing,qFont);
renderText(middleCol,startPos+ 1*lineSpacing,tr("Vertices: %1").arg(mm->cm().vn),qFont);
renderText(middleCol,startPos+ 2*lineSpacing,tr("Faces: %1").arg(mm->cm().fn),qFont);
renderText(middleCol,startPos+ 1*lineSpacing,tr("Vertices: %1").arg(mm()->cm.vn),qFont);
renderText(middleCol,startPos+ 2*lineSpacing,tr("Faces: %1").arg(mm()->cm.fn),qFont);
if(rm.selectedFaces)
renderText(middleCol,startPos+ 3*lineSpacing,tr("Selected: %1").arg(mm->cm().sfn),qFont);
renderText(middleCol,startPos+ 4*lineSpacing,GetMeshInfoString(mm->ioMask),qFont);
renderText(middleCol,startPos+ 3*lineSpacing,tr("Selected: %1").arg(mm()->cm.sfn),qFont);
renderText(middleCol,startPos+ 4*lineSpacing,GetMeshInfoString(mm()->ioMask),qFont);
renderText(rightCol,startPos+1*lineSpacing,QString("FOV: ")+QString::number((int)fov,10),qFont);
if ((cfps>0) && (cfps<500))
@ -589,7 +611,7 @@ void GLArea::closeEvent(QCloseEvent *event)
tr("MeshLab"),
tr("File %1 modified.\n\n"
"Continue without saving?")
.arg(fileName),
.arg(getFileName()),
QMessageBox::Yes|QMessageBox::Default,
QMessageBox::No|QMessageBox::Escape,
QMessageBox::NoButton) == QMessageBox::No)
@ -601,7 +623,10 @@ void GLArea::closeEvent(QCloseEvent *event)
event->ignore();
if(close)
{
if(mm){ delete mm;mm = NULL;} // quit without saving
if(mm()){
foreach(MeshModel *mmp, meshList)
delete mmp;
} // quit without saving
event->accept();
}
}
@ -626,7 +651,7 @@ void GLArea::mousePressEvent(QMouseEvent*e)
{
e->accept();
setFocus();
if(iEdit) iEdit->mousePressEvent(currentEditor,e,*mm,this);
if(iEdit) iEdit->mousePressEvent(currentEditor,e,*mm(),this);
else {
if ((e->modifiers() & Qt::ShiftModifier) && (e->modifiers() & Qt::ControlModifier) &&
(e->button()==Qt::LeftButton) )
@ -644,7 +669,7 @@ void GLArea::mouseMoveEvent(QMouseEvent*e)
{
if(e->buttons() | Qt::LeftButton)
{
if(iEdit) iEdit->mouseMoveEvent(currentEditor,e,*mm,this);
if(iEdit) iEdit->mouseMoveEvent(currentEditor,e,*mm(),this);
else {
if (isDefaultTrackBall())
{
@ -661,7 +686,7 @@ void GLArea::mouseReleaseEvent(QMouseEvent*e)
{
//clearFocus();
activeDefaultTrackball=true;
if(iEdit) iEdit->mouseReleaseEvent(currentEditor,e,*mm,this);
if(iEdit) iEdit->mouseReleaseEvent(currentEditor,e,*mm(),this);
else {
if (isDefaultTrackBall()) trackball.MouseUp(e->x(),height()-e->y(), QT2VCG(e->button(), e->modifiers() ) );
else trackball_light.MouseUp(e->x(),height()-e->y(), QT2VCG(e->button(),e->modifiers()) );
@ -726,27 +751,27 @@ void GLArea::setColorMode(vcg::GLW::ColorMode mode)
// Texture loading done during the first paint.
void GLArea::initTexture()
{
if(!mm->cm().textures.empty() && mm->glw.TMId.empty()){
if(!mm()->cm.textures.empty() && mm()->glw.TMId.empty()){
glEnable(GL_TEXTURE_2D);
for(unsigned int i =0; i< mm->cm().textures.size();++i){
for(unsigned int i =0; i< mm()->cm.textures.size();++i){
QImage img, imgScaled, imgGL;
img.load(mm->cm().textures[i].c_str());
img.load(mm()->cm.textures[i].c_str());
// image has to be scaled to a 2^n size. We choose the first 2^N <= picture size.
int bestW=pow(2.0,floor(::log(double(img.width() ))/::log(2.0)));
int bestH=pow(2.0,floor(::log(double(img.height()))/::log(2.0)));
imgScaled=img.scaled(bestW,bestH,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
imgGL=convertToGLFormat(imgScaled);
qDebug("loaded texture %s. with id %i w %i h %i",mm->cm().textures[i].c_str(),i, imgGL.width(), imgGL.height());
mm->glw.TMId.push_back(0);
qDebug("loaded texture %s. with id %i w %i h %i",mm()->cm.textures[i].c_str(),i, imgGL.width(), imgGL.height());
mm()->glw.TMId.push_back(0);
glGenTextures( 1, (GLuint*)&(mm->glw.TMId.back()) );
glBindTexture( GL_TEXTURE_2D, mm->glw.TMId.back() );
glGenTextures( 1, (GLuint*)&(mm()->glw.TMId.back()) );
glBindTexture( GL_TEXTURE_2D, mm()->glw.TMId.back() );
glTexImage2D( GL_TEXTURE_2D, 0, 3, imgGL.width(), imgGL.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, imgGL.bits() );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
qDebug("loaded texture %s. in %i",mm->cm().textures[i].c_str(),mm->glw.TMId[i]);
qDebug("loaded texture %s. in %i",mm()->cm.textures[i].c_str(),mm()->glw.TMId[i]);
}
}
glDisable(GL_TEXTURE_2D);

View File

@ -24,6 +24,11 @@
History
$Log$
Revision 1.73 2007/04/16 09:24:37 cignoni
** big change **
Added Layers managemnt.
Interfaces are changing...
Revision 1.72 2007/03/26 08:24:10 zifnab1974
When a user minimizes the window using a shortcut that uses modifiers (alt, ctrl, shift), the state of the button remained "pressed" after the window was reraised. Added a hideevent which resets the button state.
@ -120,6 +125,8 @@ Revision 1.51 2006/01/25 03:57:15 glvertex
enum LightingModel{LDOUBLE,LFANCY};
class LayerDialog;
class GLLightSetting
{
public:
@ -217,12 +224,18 @@ class GLArea : public QGLWidget
{
Q_OBJECT
private:
MeshModel *currentMesh;
public:
LayerDialog *layerDialog;
// Layer Management stuff.
QList<MeshModel *> meshList;
public:
GLArea(QWidget *parent = 0);
~GLArea(){}
MeshModel *mm;
MeshModel *mm(){return currentMesh;}
void addMesh(MeshModel *mm);
vcg::Trackball trackball;
vcg::Trackball trackball_light;
GLLogStream log;
@ -239,11 +252,11 @@ public:
void setLastAppliedFilter(QAction *qa) {lastFilterRef = qa;}
void setLastAppliedEdit(QAction *qa) {lastEditRef = qa;}
QString getFileName() {return fileName;}
QString getFileName() {return QString(currentMesh->fileName.c_str());}
void setFileName(QString name)
{
fileName = name;
ss.basename=QFileInfo(fileName).baseName().append("Snap");
currentMesh->fileName = qPrintable(name);
ss.basename=QFileInfo(getFileName()).baseName().append("Snap");
}
short getLogLevel() {return currLogLevel;}
@ -346,9 +359,7 @@ private:
private:
float cfps;
float lastTime;
QString fileName;
float lastTime;
SnapshotSetting ss;
QImage snapBuffer;

View File

@ -23,6 +23,11 @@
/****************************************************************************
History
$Log$
Revision 1.56 2007/04/16 09:24:37 cignoni
** big change **
Added Layers managemnt.
Interfaces are changing...
Revision 1.55 2007/03/27 12:20:16 cignoni
Revamped logging iterface, changed function names in automatic parameters, better selection handling
@ -139,27 +144,49 @@ class MeshFilterInterface
{
public:
typedef int FilterType;
enum FilterClass { Generic, Selection, Cleaning, Remeshing, FaceColoring, VertexColoring} ;
virtual ~MeshFilterInterface() {}
virtual const QString Info(QAction *)=0;
enum FilterClass { Generic, Selection, Cleaning, Remeshing, FaceColoring, VertexColoring} ;
virtual ~MeshFilterInterface() {}
// The filterclass describe in which submenu each filter should be placed
virtual const FilterClass getClass(QAction *) {return MeshFilterInterface::Generic;};
// The longer string describing each filtering action
// (this string is used in the About plugin dialog)
virtual const QString Info(FilterType filter)=0;
// The very short string describing each filtering action
// (this string is used also to define the menu entry)
virtual const QString ST(FilterType filter)=0;
// Generic Info about the plugin version and author.
virtual const PluginInfo &Info()=0;
// The filterclass describe in which generic class of filters it fits.
// This choice affect the submenu in which each filter will be placed
// For example filters that perform action only on the selection will be placed in the Ê
virtual const FilterClass getClass(QAction *) { return MeshFilterInterface::Generic; }
// This function invokes a dialog and get back the parameters
virtual bool getParameters(QAction *, QWidget * /*parent*/, MeshModel &/*m*/, FilterParameter & /*par*/) {return true;}
// The filters can have some additional requirements on the mesh capabiliteis.
// For example if a filters requires Face-Face Adjacency you shoud re-implement
// this function making it returns MeshModel::MM_FACETOPO.
// The framework will ensure that the mesh has the requirements satisfied before invoking the applyFilter function
virtual const int getRequirements(QAction *){return MeshModel::MM_NONE;}
// The main function that applies the selected filter.
// This function is called by the frameworl
virtual bool applyFilter(QAction * /*filter*/, MeshModel &/*m*/, FilterParameter & /*parent*/, vcg::CallBackPos * /*cb*/) = 0;
// Returns an array of standard parameters descriptors for the standard plugin window.
// FALSE is returned by default if the plugin doesn't implement this
virtual bool getStdFields(QAction *, MeshModel &, StdParList &){return false;}
// This function invokes a dialog and get back the parameters
virtual bool getParameters(QAction *, QWidget * /*parent*/, MeshModel &/*m*/, FilterParameter & /*par*/) {return true;};
// The filters can require some additional
virtual const int getRequirements(QAction *){return MeshModel::MM_NONE;}
/* Overloading of the function getParameters that supports the standard plugin window. If the plugin doesn't implement this, the classic function is called */
virtual bool getStdParameters(QAction *qa, QWidget *qw /*parent*/, MeshModel &mm/*m*/, FilterParameter &fp /*par*/) {return getParameters(qa,qw,mm,fp);};
// The main function that applies the selected filter
virtual bool applyFilter(QAction * /*filter*/, MeshModel &/*m*/, FilterParameter & /*parent*/, vcg::CallBackPos * /*cb*/) = 0;
virtual const PluginInfo &Info()=0;
/// Standard stuff that usually should not be redefined.
void setLog(GLLogStream *log) { this->log = log ; }
virtual const QString ST(FilterType filter)=0;
virtual const FilterType ID(QAction *a)
{
foreach( FilterType tt, types())
@ -167,20 +194,22 @@ public:
assert(0);
return 0;
}
virtual const QString Info(QAction *a){return Info(ID(a));};
virtual QList<QAction *> actions() const { return actionList;}
virtual QList<FilterType> &types() { return typeList;}
/* Returns an array of standard parameters descriptors for the standard plugin window .NULL is returned by default if the plugin doesn't implement this */
virtual bool getStdFields(QAction *, MeshModel &, StdParList &){return false;}
/* Overloading of the function getParameters that supports the standard plugin window. If the plugin doesn't implement this, the classic function is called */
virtual bool getStdParameters(QAction *qa, QWidget *qw /*parent*/, MeshModel &mm/*m*/, FilterParameter &fp /*par*/) {return getParameters(qa,qw,mm,fp);};
protected:
QList <QAction *> actionList;
QList <FilterType> typeList;
void Log(int Level, const char * f, ... )
// Each plugins exposes a set of filtering possibilities.
// Each filtering procedure corresponds to a single QAction with a corresponding FilterType id.
//
// The list of actions exported by the plugin. Each actions strictly corresponds to
QList <QAction *> actionList;
QList <FilterType> typeList;
void Log(int Level, const char * f, ... )
{
if(log)
{

View File

@ -23,6 +23,11 @@
/****************************************************************************
History
$Log$
Revision 1.83 2007/04/16 09:24:37 cignoni
** big change **
Added Layers managemnt.
Interfaces are changing...
Revision 1.82 2007/03/27 12:20:16 cignoni
Revamped logging iterface, changed function names in automatic parameters, better selection handling
@ -151,11 +156,12 @@ public:
// MaskObj maskobj;
public slots:
void open(QString fileName=QString());
void open(QString fileName=QString(), GLArea *gla=0);
private slots:
//////////// Slot Menu File //////////////////////
void openIn(QString fileName=QString());
void reload();
void openRecentFile();
bool saveAs();
@ -194,6 +200,7 @@ private slots:
void showInfoPane();
void showTrackBall();
void resetTrackBall();
void showLayerDlg();
///////////Slot Menu Windows /////////////////////
void updateWindowMenu();
void updateMenus();
@ -282,6 +289,7 @@ private:
//////////// Actions Menu File ///////////////////////
QAction *openAct;
QAction *openInAct;
QAction *closeAct;
QAction *reloadAct;
QAction *saveAsAct;
@ -322,6 +330,7 @@ private:
QAction *showInfoPaneAct;
QAction *showTrackBallAct;
QAction *resetTrackBallAct;
QAction *showLayerDlgAct;
///////////Actions Menu Windows /////////////////////
QAction *windowsTileAct;
QAction *windowsCascadeAct;

View File

@ -24,6 +24,11 @@
History
$Log$
Revision 1.75 2007/04/16 09:24:37 cignoni
** big change **
Added Layers managemnt.
Interfaces are changing...
Revision 1.74 2007/03/27 12:20:16 cignoni
Revamped logging iterface, changed function names in automatic parameters, better selection handling
@ -182,7 +187,7 @@ void MainWindow::createStdPluginWnd()
stddialog->setAllowedAreas ( Qt::NoDockWidgetArea );
//addDockWidget(Qt::RightDockWidgetArea,stddialog);
stddialog->setFloating(true);
//stddialog->move(0,120);
stddialog->move(50,100);
}
@ -193,6 +198,11 @@ void MainWindow::createActions()
openAct->setShortcutContext(Qt::ApplicationShortcut);
openAct->setShortcut(Qt::CTRL+Qt::Key_O);
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
openInAct = new QAction(QIcon(":/images/open.png"),tr("&Open inside..."), this);
openInAct->setShortcutContext(Qt::ApplicationShortcut);
openInAct->setShortcut(Qt::CTRL+Qt::Key_O);
connect(openInAct, SIGNAL(triggered()), this, SLOT(openIn()));
closeAct = new QAction(tr("&Close"), this);
closeAct->setShortcutContext(Qt::ApplicationShortcut);
@ -323,6 +333,12 @@ void MainWindow::createActions()
resetTrackBallAct->setShortcutContext(Qt::ApplicationShortcut);
resetTrackBallAct->setShortcut(Qt::CTRL+Qt::Key_H);
connect(resetTrackBallAct, SIGNAL(triggered()), this, SLOT(resetTrackBall()));
showLayerDlgAct = new QAction (tr("Show Layer Dialog"), this);
showLayerDlgAct->setCheckable(true);
showLayerDlgAct->setChecked(true);
connect(showLayerDlgAct, SIGNAL(triggered()), this, SLOT(showLayerDlg()));
//////////////Action Menu EDIT /////////////////////////////////////////////////////////////////////////
endEditModeAct = new QAction (QIcon(":/images/no_edit.png"),tr("Not editing"), this);
@ -406,6 +422,7 @@ void MainWindow::createMenus()
//////////////////// Menu File ////////////////////////////////////////////////////////////////////////////
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(openAct);
fileMenu->addAction(openInAct);
fileMenu->addAction(closeAct);
fileMenu->addAction(reloadAct);
fileMenu->addAction(saveAsAct);
@ -480,6 +497,7 @@ void MainWindow::createMenus()
//////////////////// Menu View ////////////////////////////////////////////////////////////////////////////
viewMenu = menuBar()->addMenu(tr("&View"));
viewMenu->addAction(fullScreenAct);
viewMenu->addAction(showLayerDlgAct);
trackBallMenu = viewMenu->addMenu(tr("&Trackball"));
trackBallMenu->addAction(showTrackBallAct);
@ -553,6 +571,7 @@ pluginsDir = QDir(qApp->applicationDirPath());
foreach(filterAction, iFilter->actions())
{
filterMap[filterAction->text()]=filterAction;
filterAction->setToolTip(iFilter->Info(filterAction));
connect(filterAction,SIGNAL(triggered()),this,SLOT(applyFilter()));
switch(iFilter->getClass(filterAction))
{
@ -632,7 +651,7 @@ void MainWindow::setCurrentFile(const QString &fileName)
if (mainWin) mainWin->updateRecentFileActions();
}
settings.setValue("totalKV", settings.value("totalKV",0).toInt() + (GLA()->mm->cm().vn)/1000);
settings.setValue("totalKV", settings.value("totalKV",0).toInt() + (GLA()->mm()->cm.vn)/1000);
settings.setValue("loadedMeshCounter",settings.value("loadedMeshCounter",0).toInt() + 1);
int loadedMeshCounter = settings.value("loadedMeshCounter",20).toInt();

View File

@ -24,6 +24,11 @@
History
$Log$
Revision 1.126 2007/04/16 09:24:37 cignoni
** big change **
Added Layers managemnt.
Interfaces are changing...
Revision 1.125 2007/03/27 12:20:17 cignoni
Revamped logging iterface, changed function names in automatic parameters, better selection handling
@ -104,6 +109,7 @@ Added Drag n drog opening of files (thanks to Valentino Fiorin)
#include "savemaskexporter.h"
#include "plugin_support.h"
#include "stdpardialog.h"
#include "layerDialog.h"
#include <wrap/io_trimesh/io_mask.h>
#include <vcg/complex/trimesh/update/normal.h>
@ -194,7 +200,7 @@ void MainWindow::updateMenus()
case GLW::DMHidden: renderModeHiddenLinesAct->setChecked(true); break;
default: break;
}
colorModePerFaceAct->setEnabled(HasPerFaceColor(GLA()->mm->cm()));
colorModePerFaceAct->setEnabled(HasPerFaceColor(GLA()->mm()->cm));
switch (rm.colorMode)
{
case GLW::CMNone: colorModeNoneAct->setChecked(true); break;
@ -224,7 +230,7 @@ void MainWindow::updateMenus()
showInfoPaneAct->setChecked(GLA()->infoAreaVisible);
showTrackBallAct->setChecked(GLA()->isTrackBallVisible());
backFaceCullAct->setChecked(GLA()->getCurrentRenderMode().backFaceCull);
renderModeTextureAct->setEnabled(GLA()->mm && !GLA()->mm->cm().textures.empty());
renderModeTextureAct->setEnabled(GLA()->mm() && !GLA()->mm()->cm.textures.empty());
renderModeTextureAct->setChecked(GLA()->getCurrentRenderMode().textureMode != GLW::TMNone);
setLightAct->setIcon(rm.lighting ? QIcon(":/images/lighton.png") : QIcon(":/images/lightoff.png") );
@ -240,6 +246,14 @@ void MainWindow::updateMenus()
foreach (p,*GLA()->iDecoratorsList){p.first->setChecked(true);}
}
}
if(GLA())
{
showLayerDlgAct->setChecked(GLA()->layerDialog->isVisible());
//if(GLA()->layerDialog->isVisible())
GLA()->layerDialog->updateTable();
}
}
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
@ -288,8 +302,8 @@ void MainWindow::runFilterScript()
MeshFilterInterface *iFilter = qobject_cast<MeshFilterInterface *>(action->parent());
int req=iFilter->getRequirements(action);
GLA()->mm->updateDataMask(req);
iFilter->applyFilter( action, *(GLA()->mm), (*ii).second, QCallBack );
GLA()->mm()->updateDataMask(req);
iFilter->applyFilter( action, *(GLA()->mm()), (*ii).second, QCallBack );
GLA()->log.Logf(GLLogStream::Info,"Re-Applied filter %s",qPrintable((*ii).first));
}
}
@ -305,14 +319,14 @@ void MainWindow::applyFilter()
// Ask for filter requirements (eg a filter can need topology, border flags etc)
// and statisfy them
int req=iFilter->getRequirements(action);
GLA()->mm->updateDataMask(req);
GLA()->mm()->updateDataMask(req);
/*
loads the plugin action in the standard plugin window.
If the plugin action doesn't support the use of the standard
plugin window, the function executeFilter() is immediately called
*/
stddialog->loadPluginAction(iFilter,GLA()->mm,action,this);
stddialog->loadPluginAction(iFilter,GLA()->mm(),action,this);
}
/* callback function that applies the filter action */
@ -327,12 +341,12 @@ void MainWindow::executeFilter(QAction *action,FilterParameter *par)
// and statisfy them
int req=iFilter->getRequirements(action);
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
GLA()->mm->updateDataMask(req);
GLA()->mm()->updateDataMask(req);
qApp->restoreOverrideCursor();
// (2) Ask for filter parameters (e.g. user defined threshold that could require a widget)
bool ret=iFilter->getStdParameters(action, GLA(),*(GLA()->mm), *par);
bool ret=iFilter->getStdParameters(action, GLA(),*(GLA()->mm()), *par);
if(!ret) return;
@ -347,9 +361,9 @@ void MainWindow::executeFilter(QAction *action,FilterParameter *par)
// (4) Apply the Filter
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
GLA()->mm->busy=true;
ret=iFilter->applyFilter(action, *(GLA()->mm), *par, QCallBack);
GLA()->mm->busy=false;
GLA()->mm()->busy=true;
ret=iFilter->applyFilter(action, *(GLA()->mm()), *par, QCallBack);
GLA()->mm()->busy=false;
qApp->restoreOverrideCursor();
// (5) Apply post filter actions (e.g. recompute non updated stuff if needed)
@ -366,12 +380,12 @@ void MainWindow::executeFilter(QAction *action,FilterParameter *par)
// at the end for filters that change the color set the appropriate color mode
if(iFilter->getClass(action)==MeshFilterInterface::FaceColoring ) {
GLA()->setColorMode(vcg::GLW::CMPerFace);
GLA()->mm->ioMask|=MeshModel::IOM_FACECOLOR;
GLA()->mm()->ioMask|=MeshModel::IOM_FACECOLOR;
}
if(iFilter->getClass(action)==MeshFilterInterface::VertexColoring ){
GLA()->setColorMode(vcg::GLW::CMPerVert);
GLA()->mm->ioMask|=MeshModel::IOM_VERTCOLOR;
GLA()->mm->ioMask|=MeshModel::IOM_VERTQUALITY;
GLA()->mm()->ioMask|=MeshModel::IOM_VERTCOLOR;
GLA()->mm()->ioMask|=MeshModel::IOM_VERTQUALITY;
}
if(iFilter->getClass(action)==MeshFilterInterface::Selection )
GLA()->setSelectionRendering(true);
@ -398,7 +412,7 @@ void MainWindow::endEditMode()
QAction *action = qobject_cast<QAction *>(GLA()->getLastAppliedEdit());
MeshEditInterface *iEdit = qobject_cast<MeshEditInterface *>(action->parent());
GLA()->setEdit(iEdit,action);
iEdit->StartEdit(action,*(GLA()->mm),GLA());
iEdit->StartEdit(action,*(GLA()->mm()),GLA());
GLA()->log.Logf(GLLogStream::Info,"Started Mode %s",qPrintable (action->text()));
GLA()->setSelectionRendering(true);
}
@ -419,7 +433,7 @@ void MainWindow::applyEditMode()
GLA()->setEdit(iEdit,action);
GLA()->setLastAppliedEdit(action);
iEdit->StartEdit(action,*(GLA()->mm),GLA());
iEdit->StartEdit(action,*(GLA()->mm()),GLA());
GLA()->log.Logf(GLLogStream::Info,"Started Mode %s",qPrintable (action->text()));
GLA()->setSelectionRendering(true);
updateMenus();
@ -431,7 +445,7 @@ void MainWindow::applyRenderMode()
// Make the call to the plugin core
MeshRenderInterface *iRenderTemp = qobject_cast<MeshRenderInterface *>(action->parent());
iRenderTemp->Init(action,*(GLA()->mm),GLA()->getCurrentRenderMode(),GLA());
iRenderTemp->Init(action,*(GLA()->mm()),GLA()->getCurrentRenderMode(),GLA());
if(action->text() == tr("None"))
{
@ -491,22 +505,11 @@ void MainWindow::applyDecorateMode()
bool MainWindow::QCallBack(const int pos, const char * str)
{
MainWindow::globalStatusBar()->showMessage(str,5000);
qb->show();
qb->setEnabled(true);
qb->setValue(pos);
// qb->update();
MainWindow::globalStatusBar()->update();
qApp->processEvents();
//qb->repaint();
//if(qb==0) return true;
//qb->setWindowTitle (str);
//qApp->processEvents();
//if (qb->wasCanceled())
//{
// qb->reset();
// return false;
//}
qApp->processEvents();
return true;
}
@ -558,10 +561,13 @@ void MainWindow::toggleSelectionRendering()
GLA()->setSelectionRendering(!rm.selectedFaces);
}
void MainWindow::openIn(QString fileName)
{
open(QString(),GLA());
}
void MainWindow::open(QString fileName)
void MainWindow::open(QString fileName, GLArea *gla)
{
// Opening files in a transparent form (IO plugins contribution is hidden to user)
QStringList filters;
@ -608,14 +614,13 @@ void MainWindow::open(QString fileName)
qb->show();
int mask = 0;
MeshModel *mm= new MeshModel();
MeshModel *mm= new MeshModel();
if (!pCurrentIOPlugin->open(extension, fileName, *mm ,mask,QCallBack,this /*gla*/))
delete mm;
else{
GLArea *gla;
gla=new GLArea(workspace);
gla->mm=mm;
gla->mm->ioMask = mask; // store mask into model structure
if(gla==0) gla=new GLArea(workspace);
gla->addMesh(mm);
gla->mm()->ioMask = mask; // store mask into model structure
gla->setFileName(fileName);
gla->setWindowTitle(QFileInfo(fileName).fileName()+tr("[*]"));
@ -628,22 +633,22 @@ void MainWindow::open(QString fileName)
gla->setColorMode(GLW::CMPerFace);
if( mask & vcg::tri::io::Mask::IOM_VERTCOLOR)
{
gla->mm->storeVertexColor();
gla->mm()->storeVertexColor();
gla->setColorMode(GLW::CMPerVert);
}
renderModeTextureAct->setChecked(false);
renderModeTextureAct->setEnabled(false);
if(!GLA()->mm->cm().textures.empty())
if(!GLA()->mm()->cm.textures.empty())
{
renderModeTextureAct->setChecked(true);
renderModeTextureAct->setEnabled(true);
GLA()->setTextureMode(GLW::TMPerWedgeMulti);
}
vcg::tri::UpdateNormals<CMeshO>::PerVertexNormalizedPerFace(mm->cm());
vcg::tri::UpdateBounding<CMeshO>::Box(mm->cm()); // updates bounding box
vcg::tri::UpdateNormals<CMeshO>::PerVertexNormalizedPerFace(mm->cm);
vcg::tri::UpdateBounding<CMeshO>::Box(mm->cm); // updates bounding box
updateMenus();
vcg::tri::Clean<CMeshO>::RemoveDegenerateFace(mm->cm());
GLA()->mm->busy=false;
vcg::tri::Clean<CMeshO>::RemoveDegenerateFace(mm->cm);
GLA()->mm()->busy=false;
}
qb->reset();
@ -709,11 +714,11 @@ bool MainWindow::saveAs()
int capability = pCurrentIOPlugin->GetExportMaskCapability(extension);
int mask = vcg::tri::io::SaveMaskToExporter::GetMaskToExporter(this->GLA()->mm, capability);
int mask = vcg::tri::io::SaveMaskToExporter::GetMaskToExporter(this->GLA()->mm(), capability);
if(mask == -1)
return false;
qb->show();
ret = pCurrentIOPlugin->save(extension, fileName, *this->GLA()->mm ,mask,QCallBack,this);
ret = pCurrentIOPlugin->save(extension, fileName, *this->GLA()->mm() ,mask,QCallBack,this);
qb->reset();
QSettings settings;
@ -781,6 +786,8 @@ void MainWindow::showToolbarRender(){
void MainWindow::showInfoPane() {if(GLA() != 0) GLA()->infoAreaVisible =!GLA()->infoAreaVisible;}
void MainWindow::showTrackBall() {if(GLA() != 0) GLA()->showTrackBall(!GLA()->isTrackBallVisible());}
void MainWindow::resetTrackBall(){if(GLA() != 0) GLA()->resetTrackBall();}
void MainWindow::showLayerDlg() {if(GLA() != 0) GLA()->layerDialog->setVisible( !GLA()->layerDialog->isVisible() );}
void MainWindow::setCustomize()
{
CustomDialog dialog(this);

View File

@ -23,6 +23,11 @@
/****************************************************************************
History
$Log$
Revision 1.26 2007/04/16 09:24:37 cignoni
** big change **
Added Layers managemnt.
Interfaces are changing...
Revision 1.25 2007/03/20 16:22:34 cignoni
Big small change in accessing mesh interface. First step toward layers
@ -68,14 +73,14 @@ bool MeshModel::RenderSelectedFaces()
glPolygonOffset(-1.0, -1);
CMeshO::FaceIterator fi;
glBegin(GL_TRIANGLES);
cm().sfn=0;
for(fi=cm().face.begin();fi!=cm().face.end();++fi)
cm.sfn=0;
for(fi=cm.face.begin();fi!=cm.face.end();++fi)
if(!(*fi).IsD() && (*fi).IsS())
{
glVertex((*fi).cP(0));
glVertex((*fi).cP(1));
glVertex((*fi).cP(2));
++cm().sfn;
++cm.sfn;
}
glEnd();
glPopAttrib();

View File

@ -23,6 +23,11 @@
/****************************************************************************
History
$Log$
Revision 1.34 2007/04/16 09:24:37 cignoni
** big change **
Added Layers managemnt.
Interfaces are changing...
Revision 1.33 2007/03/20 16:22:34 cignoni
Big small change in accessing mesh interface. First step toward layers
@ -59,14 +64,14 @@ abstract pointer to fileformat's dependent additional info added
#include <stdio.h>
#include <time.h>
#include<vcg/simplex/vertexplus/base.h>
#include <vcg/simplex/vertexplus/base.h>
#include <vcg/simplex/edge/edge.h>
#include<vcg/simplex/faceplus/base.h>
#include<vcg/simplex/face/topology.h>
#include <vcg/simplex/faceplus/base.h>
#include <vcg/simplex/face/topology.h>
#include<vcg/complex/trimesh/base.h>
#include<vcg/simplex/vertexplus/component_ocf.h>
#include<vcg/simplex/faceplus/component_ocf.h>
#include <vcg/complex/trimesh/base.h>
#include <vcg/simplex/vertexplus/component_ocf.h>
#include <vcg/simplex/faceplus/component_ocf.h>
#include <vcg/complex/trimesh/update/topology.h>
#include <vcg/complex/trimesh/update/flag.h>
@ -128,10 +133,9 @@ public :
};
/*
MeshModel Class
contiene i dati relativi ad un singolo oggetto.
Ogni oggetto si sa caricare e contiene una mesh
MeshModel Class
The base class for representing a single mesh.
It contains a single vcg mesh object with some additional information for keeping track of its origin and of what info it has.
*/
class MeshModel : public tri::io::Mask
@ -148,13 +152,12 @@ public:
MM_ALL = 0xffff} ;
CMeshO &cm(){return _cm;}
private:
CMeshO _cm;
CMeshO cm;
public:
GlTrimesh<CMeshO> glw;
vector<Color4b> originalVertexColor;
std::string fileName;
// Bitmask denoting what fields are currently kept updated in mesh
// it is composed by OR-ing MM_XXXX enums (defined in the above FilterReq)
@ -163,42 +166,43 @@ public:
// Bitmask denoting what fields are loaded/saved
// it is composed by OR-ing IOM_XXXX enums (defined in tri::io::Mask)
int ioMask;
bool busy;
bool visible;
//abstract pointer to fileformat's dependent additional info
AdditionalInfo* addinfo;
MeshModel() {
// size_t faceSize=sizeof(CFaceO);
// size_t vertSize=sizeof(CVertexO);
glw.m=&cm();
MeshModel() {
glw.m=&cm;
currentDataMask=MM_NONE;
ioMask= IOM_VERTCOORD | IOM_FACEINDEX | IOM_FLAGS;
busy=true;
visible=true;
}
bool Render(GLW::DrawMode dm, GLW::ColorMode cm, GLW::TextureMode tm);
bool RenderSelectedFaces();
inline void storeVertexColor()
{
originalVertexColor.resize(cm().vert.size());
originalVertexColor.resize(cm.vert.size());
vector<Color4b>::iterator ci;
CMeshO::VertexIterator vi;
for(vi=cm().vert.begin(),ci=originalVertexColor.begin();vi!=cm().vert.end();++vi,++ci)
for(vi=cm.vert.begin(),ci=originalVertexColor.begin();vi!=cm.vert.end();++vi,++ci)
(*ci)=(*vi).C();
}
inline void restoreVertexColor()
{
if(originalVertexColor.empty()) return;
if(originalVertexColor.size() != cm().vert.size()) return;
if(originalVertexColor.size() != cm.vert.size()) return;
vector<Color4b>::iterator ci;
CMeshO::VertexIterator vi;
for(vi=cm().vert.begin(),ci=originalVertexColor.begin();vi!=cm().vert.end();++vi,++ci)
for(vi=cm.vert.begin(),ci=originalVertexColor.begin();vi!=cm.vert.end();++vi,++ci)
(*vi).C()=(*ci);
}
// FUNZIONE equivalente alla updatedatamask ma solo che prende in ingresso mask da filetype.
// This function is roughly equivalent to the updateDataMask,
// but it takes in input a mask coming from a filetype instead of a filter requirement (like topology etc)
void Enable(int openingFileMask)
{
if( openingFileMask & IOM_WEDGTEXCOORD ) updateDataMask(MM_WEDGTEXCOORD);
@ -219,35 +223,35 @@ public:
{
if( ( (neededDataMask & MM_FACETOPO)!=0) && (currentDataMask& MM_FACETOPO)==0)
{
cm().face.EnableFFAdjacency();
cm.face.EnableFFAdjacency();
currentDataMask |= MM_FACETOPO;
tri::UpdateTopology<CMeshO>::FaceFace(cm());
tri::UpdateTopology<CMeshO>::FaceFace(cm);
}
if( ( (neededDataMask & MM_VERTFACETOPO)!=0) && (currentDataMask& MM_VERTFACETOPO)==0)
{
cm().face.EnableVFAdjacency();
cm.face.EnableVFAdjacency();
currentDataMask |= MM_VERTFACETOPO;
tri::UpdateTopology<CMeshO>::VertexFace(cm());
tri::UpdateTopology<CMeshO>::VertexFace(cm);
}
if( ( (neededDataMask & MM_BORDERFLAG)!=0) && (currentDataMask& MM_BORDERFLAG)==0)
{
if(currentDataMask& MM_FACETOPO) tri::UpdateFlags<CMeshO>::FaceBorderFromFF(cm());
else tri::UpdateFlags<CMeshO>::FaceBorderFromNone(cm());
if(currentDataMask& MM_FACETOPO) tri::UpdateFlags<CMeshO>::FaceBorderFromFF(cm);
else tri::UpdateFlags<CMeshO>::FaceBorderFromNone(cm);
currentDataMask |= MM_BORDERFLAG;
}
if( ( (neededDataMask & MM_WEDGTEXCOORD)!=0) && (currentDataMask& MM_WEDGTEXCOORD)==0)
{
cm().face.EnableWedgeTex();
cm.face.EnableWedgeTex();
currentDataMask |= MM_WEDGTEXCOORD;
}
if( ( (neededDataMask & MM_FACECOLOR)!=0) && (currentDataMask& MM_FACECOLOR)==0)
{
cm().face.EnableColor();
cm.face.EnableColor();
currentDataMask |= MM_FACECOLOR;
}
if( ( (neededDataMask & MM_FACEMARK)!=0) && (currentDataMask& MM_FACEMARK)==0)
{
cm().face.EnableMark();
cm.face.EnableMark();
currentDataMask |= MM_FACEMARK;
}
}

View File

@ -25,6 +25,11 @@
History
$Log$
Revision 1.11 2007/04/16 09:24:37 cignoni
** big change **
Added Layers managemnt.
Interfaces are changing...
Revision 1.10 2007/03/26 08:25:10 zifnab1974
added eol at the end of the files
@ -106,15 +111,15 @@ void SaveMaskExporterDialog::InitDialog()
void SaveMaskExporterDialog::SetTextureName()
{
if( m->cm().textures.size() == 0 )
if( m->cm.textures.size() == 0 )
{
ui.check_iom_wedgtexcoord->setDisabled(true);
ui.check_iom_wedgtexcoord->setChecked(false);
}
for(unsigned int i=0;i<m->cm().textures.size();i++)
for(unsigned int i=0;i<m->cm.textures.size();i++)
{
QString item(m->cm().textures[i].c_str());
QString item(m->cm.textures[i].c_str());
ui.listTextureName->addItem(item);
}
}
@ -211,8 +216,8 @@ void SaveMaskExporterDialog::SlotOkButton()
if( ui.check_iom_camera->isChecked() ) { newmask |= MeshModel::IOM_CAMERA;}
for(unsigned int i=0;i<m->cm().textures.size();i++)
m->cm().textures[i] = ui.listTextureName->item(i)->text().toStdString();
for(unsigned int i=0;i<m->cm.textures.size();i++)
m->cm.textures[i] = ui.listTextureName->item(i)->text().toStdString();
this->mask=newmask;
}
@ -224,7 +229,7 @@ void SaveMaskExporterDialog::SlotCancelButton()
void SaveMaskExporterDialog::SlotRenameTexture()
{
int row = ui.listTextureName->currentRow();
std::string newtexture = vcg::tri::io::TextureRename::GetNewTextureName(m->cm().textures[row].c_str());
std::string newtexture = vcg::tri::io::TextureRename::GetNewTextureName(m->cm.textures[row].c_str());
if(newtexture.size()>0)
{
QStringList lists = QString(newtexture.c_str()).split('/');