From 8ae5507abd2e569887ef50fd89a976a173e6848c Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Tue, 17 Jan 2006 13:47:45 +0000 Subject: [PATCH] update interface meshio : formats -> importFormats() & exportFormts --- src/meshlab/interfaces.h | 6 ++- src/meshlab/mainwindow.h | 5 ++- src/meshlab/mainwindow_RunTime.cpp | 21 +++++++++-- src/meshlab/plugindialog.cpp | 21 +++++++++-- src/meshlabplugins/meshio/meshio.cpp | 55 +++++++++++++++++++++++----- src/meshlabplugins/meshio/meshio.h | 6 ++- 6 files changed, 94 insertions(+), 20 deletions(-) diff --git a/src/meshlab/interfaces.h b/src/meshlab/interfaces.h index 8bbeca342..665408b66 100644 --- a/src/meshlab/interfaces.h +++ b/src/meshlab/interfaces.h @@ -23,6 +23,9 @@ /**************************************************************************** History $Log$ +Revision 1.33 2006/01/17 13:47:45 fmazzant +update interface meshio : formats -> importFormats() & exportFormts + Revision 1.32 2006/01/17 10:04:20 cignoni Slightly change MeshEditInterface @@ -140,7 +143,8 @@ public: }; virtual ~MeshIOInterface() {} - virtual QList formats() const = 0; + virtual QList importFormats() const = 0; + virtual QList exportFormats() const = 0; virtual bool open( const QString &format, // "OBJ" diff --git a/src/meshlab/mainwindow.h b/src/meshlab/mainwindow.h index 33e359428..85602fff1 100644 --- a/src/meshlab/mainwindow.h +++ b/src/meshlab/mainwindow.h @@ -23,6 +23,9 @@ /**************************************************************************** History $Log$ +Revision 1.57 2006/01/17 13:47:45 fmazzant +update interface meshio : formats -> importFormats() & exportFormts + Revision 1.56 2006/01/14 00:51:06 davide_portelli A little change @@ -185,7 +188,7 @@ private: void updateRecentFileActions(); void setCurrentFile(const QString &fileName); void addToMenu(QList, QMenu *menu, const char *slot); - void LoadKnownFilters(QStringList &filters, QHash &allKnownFormats); + void LoadKnownFilters(QStringList &filters, QHash &allKnownFormats, int type); diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index a0933e801..5d8b545e2 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -24,6 +24,9 @@ History $Log$ +Revision 1.70 2006/01/17 13:47:45 fmazzant +update interface meshio : formats -> importFormats() & exportFormts + Revision 1.69 2006/01/16 15:30:24 fmazzant added rename texture dialog for exporter removed old maskobj @@ -675,7 +678,8 @@ void MainWindow::toggleBackFaceCulling() } -void MainWindow::LoadKnownFilters(QStringList &filters, QHash &allKnownFormats) +enum TypeIO{IMPORT,EXPORT}; +void MainWindow::LoadKnownFilters(QStringList &filters, QHash &allKnownFormats,int type) { QString allKnownFormatsFilter = tr("All known formats ("); std::vector::iterator itIOPlugin = meshIOPlugins.begin(); @@ -683,7 +687,16 @@ void MainWindow::LoadKnownFilters(QStringList &filters, QHash &all { MeshIOInterface* pMeshIOPlugin = *itIOPlugin; - QList currentFormats = pMeshIOPlugin->formats(); + QList currentFormats;// = pMeshIOPlugin->formats(); + + /* new */ + if(type == IMPORT) + currentFormats = pMeshIOPlugin->importFormats(); + + if(type == EXPORT) + currentFormats = pMeshIOPlugin->exportFormats(); + /* end new part */ + QList::iterator itFormat = currentFormats.begin(); while(itFormat != currentFormats.end()) { @@ -723,7 +736,7 @@ void MainWindow::open(QString fileName) // the index of first plugin which is able to open it QHash allKnownFormats; - LoadKnownFilters(filters, allKnownFormats); + LoadKnownFilters(filters, allKnownFormats,IMPORT); if (fileName.isEmpty()) fileName = QFileDialog::getOpenFileName(this,tr("Open File"),".", filters.join("\n")); @@ -805,7 +818,7 @@ bool MainWindow::saveAs() QHash allKnownFormats; - LoadKnownFilters(filters, allKnownFormats); + LoadKnownFilters(filters, allKnownFormats,EXPORT); QString fileName; diff --git a/src/meshlab/plugindialog.cpp b/src/meshlab/plugindialog.cpp index 3c18c8cd4..3977c997e 100644 --- a/src/meshlab/plugindialog.cpp +++ b/src/meshlab/plugindialog.cpp @@ -23,6 +23,9 @@ /**************************************************************************** History $Log$ +Revision 1.10 2006/01/17 13:47:45 fmazzant +update interface meshio : formats -> importFormats() & exportFormts + Revision 1.9 2006/01/17 10:03:29 cignoni Removed bug: crash on white space click @@ -131,9 +134,14 @@ void PluginDialog::populateTreeWidget(const QString &path,const QStringList &fil MeshIOInterface *iMeshIO = qobject_cast(plugin); if (iMeshIO){ QStringList Templist; - foreach(const MeshIOInterface::Format f,iMeshIO->formats()){ + foreach(const MeshIOInterface::Format f,iMeshIO->importFormats()){ QString formats; - foreach(const QString s,f.extensions) formats+=s+" "; + foreach(const QString s,f.extensions) formats+="Importer_"+s+" "; + Templist.push_back(formats); + } + foreach(const MeshIOInterface::Format f,iMeshIO->exportFormats()){ + QString formats; + foreach(const QString s,f.extensions) formats+="Exporter_"+s+" "; Templist.push_back(formats); } addItems(pluginItem,Templist); @@ -198,9 +206,14 @@ void PluginDialog::displayInfo(QTreeWidgetItem* item,int ncolumn) MeshIOInterface *iMeshIO = qobject_cast(plugin); if (iMeshIO){ if (item->parent()!=NULL) - foreach(const MeshIOInterface::Format f,iMeshIO->formats()){ + foreach(const MeshIOInterface::Format f,iMeshIO->importFormats()){ QString formats; - foreach(const QString s,f.extensions) formats+=s+" "; + foreach(const QString s,f.extensions) formats+="Importer_"+s+" "; + if (actionName==formats) labelInfo->setText(f.description); + } + foreach(const MeshIOInterface::Format f,iMeshIO->exportFormats()){ + QString formats; + foreach(const QString s,f.extensions) formats+="Importer_"+s+" "; if (actionName==formats) labelInfo->setText(f.description); } } diff --git a/src/meshlabplugins/meshio/meshio.cpp b/src/meshlabplugins/meshio/meshio.cpp index 66354955c..c99a53863 100644 --- a/src/meshlabplugins/meshio/meshio.cpp +++ b/src/meshlabplugins/meshio/meshio.cpp @@ -24,6 +24,9 @@ History $Log$ + Revision 1.51 2006/01/17 13:47:45 fmazzant + update interface meshio : formats -> importFormats() & exportFormts + Revision 1.50 2006/01/16 23:53:22 fmazzant bux-fix MeshModel &m -> MeshModel *m @@ -329,9 +332,10 @@ bool ExtraMeshIOPlugin::save(const QString &formatName,QString &fileName, MeshMo if(formatName.toUpper() == tr("OBJ")) { - int newmask = vcg::tri::io::SaveMaskToExporter::GetMaskToExporter(&m,vcg::tri::io::SaveMaskToExporter::_OBJ); + int newmask = vcg::tri::io::SaveMaskToExporter::GetMaskToExporter(&m,vcg::tri::io::SaveMaskToExporter::_OBJ,vcg::tri::io::ExporterOBJ::GetExportMaskCapability()); if( newmask == 0 )return false; - int result = vcg::tri::io::ExporterOBJ::Save(m.cm,filename.c_str(),false,newmask,cb);//salva escusivamente in formato ASCII + + int result = vcg::tri::io::ExporterOBJ::Save(m.cm,filename.c_str(),false,newmask,cb);//salva esclusivamente in formato ASCII if(result != vcg::tri::io::ExporterOBJ::E_NOERROR ) { QMessageBox::warning(parent, tr("OBJ Saving Error"), errorMsgFormat.arg(fileName, vcg::tri::io::ExporterOBJ::ErrorMsg(result))); @@ -342,7 +346,7 @@ bool ExtraMeshIOPlugin::save(const QString &formatName,QString &fileName, MeshMo if(formatName.toUpper() == tr("PLY")) { - int newmask = vcg::tri::io::SaveMaskToExporter::GetMaskToExporter(&m,vcg::tri::io::SaveMaskToExporter::_PLY); + int newmask = vcg::tri::io::SaveMaskToExporter::GetMaskToExporter(&m,vcg::tri::io::SaveMaskToExporter::_PLY,0);//aggiungere la capability if( newmask == 0 )return false; int result = vcg::tri::io::Exporter::Save(m.cm,filename.c_str(),newmask,cb); @@ -356,7 +360,7 @@ bool ExtraMeshIOPlugin::save(const QString &formatName,QString &fileName, MeshMo if(formatName.toUpper() == tr("OFF")) { - //int newmask = vcg::tri::io::SaveMaskToExporter::GetMaskToExporter(&m,vcg::tri::io::SaveMaskToExporter::_OFF); + //int newmask = vcg::tri::io::SaveMaskToExporter::GetMaskToExporter(&m,vcg::tri::io::SaveMaskToExporter::_OFF,0);//aggiungere la capability //if( newmask == 0 )return false; int result = vcg::tri::io::Exporter::Save(m.cm,filename.c_str(),cb); @@ -370,7 +374,7 @@ bool ExtraMeshIOPlugin::save(const QString &formatName,QString &fileName, MeshMo if(formatName.toUpper() == tr("STL")) { - int newmask = vcg::tri::io::SaveMaskToExporter::GetMaskToExporter(&m,vcg::tri::io::SaveMaskToExporter::_STL); + int newmask = vcg::tri::io::SaveMaskToExporter::GetMaskToExporter(&m,vcg::tri::io::SaveMaskToExporter::_STL,0);//aggiungere la capability if( newmask == 0 )return false; int result = vcg::tri::io::Exporter::Save(m.cm,filename.c_str(),newmask,cb); @@ -385,7 +389,7 @@ bool ExtraMeshIOPlugin::save(const QString &formatName,QString &fileName, MeshMo if(formatName.toUpper() == tr("3DS")) { - int newmask = vcg::tri::io::SaveMaskToExporter::GetMaskToExporter(&m,vcg::tri::io::SaveMaskToExporter::_3DS); + int newmask = vcg::tri::io::SaveMaskToExporter::GetMaskToExporter(&m,vcg::tri::io::SaveMaskToExporter::_3DS,vcg::tri::io::Exporter3DS::GetExportMaskCapability()); if( newmask == 0 )return false; int result = vcg::tri::io::Exporter3DS::Save(m.cm,filename.c_str(),true,newmask,cb);//salva esclusivamente in formato binario @@ -402,7 +406,7 @@ bool ExtraMeshIOPlugin::save(const QString &formatName,QString &fileName, MeshMo return false; } -QList ExtraMeshIOPlugin::formats() const +QList ExtraMeshIOPlugin::importFormats() const { QList formatList; @@ -432,8 +436,41 @@ QList ExtraMeshIOPlugin::formats() const formatList << stl; formatList << _3ds; - return formatList; -}; + return formatList; +} + +QList ExtraMeshIOPlugin::exportFormats() const +{ + QList formatList; + + Format ply; + ply.description = "Stanford Polygon File Format"; + ply.extensions << tr("PLY"); + + Format obj; + obj.description = "Alias Wavefront Object"; + obj.extensions << tr("OBJ"); + + Format off; + off.description = "Object File Format"; + off.extensions << tr("OFF"); + + Format stl; + stl.description = "STL File Format"; + stl.extensions << tr("STL"); + + Format _3ds; + _3ds.description = "3D-Studio File Format"; + _3ds.extensions << tr("3DS"); + + formatList << ply; + formatList << obj; + formatList << off; + formatList << stl; + formatList << _3ds; + + return formatList; +} Q_EXPORT_PLUGIN(ExtraMeshIOPlugin) \ No newline at end of file diff --git a/src/meshlabplugins/meshio/meshio.h b/src/meshlabplugins/meshio/meshio.h index cd66ab31d..def717bbb 100644 --- a/src/meshlabplugins/meshio/meshio.h +++ b/src/meshlabplugins/meshio/meshio.h @@ -24,6 +24,9 @@ History $Log$ + Revision 1.16 2006/01/17 13:47:45 fmazzant + update interface meshio : formats -> importFormats() & exportFormts + Revision 1.15 2005/12/15 01:20:28 buzzelli formats method adapted in order to fit with recent changes in MeshIOInterface @@ -76,7 +79,8 @@ class ExtraMeshIOPlugin : public QObject, public MeshIOInterface public: - QList formats() const; + QList importFormats() const; + QList exportFormats() const; bool open(const QString &formatName, QString &fileName, MeshModel &m, int& mask, vcg::CallBackPos *cb=0, QWidget *parent=0); bool save(const QString &formatName, QString &fileName, MeshModel &m, int& mask, vcg::CallBackPos *cb=0, QWidget *parent= 0);