diff --git a/src/common/interfaces.h b/src/common/interfaces.h index b951b9e92..b92f3fe00 100644 --- a/src/common/interfaces.h +++ b/src/common/interfaces.h @@ -425,9 +425,9 @@ public: MeshRenderInterface() :MeshCommonInterface() {} virtual ~MeshRenderInterface() {} - virtual void Init(QAction * , MeshDocument &, QMap&, QGLWidget * ){} - virtual void Render(QAction *, MeshDocument &, QMap&, QGLWidget *) = 0; - virtual void Finalize(QAction *, MeshDocument *, GLArea *){} + virtual void Init(QAction * , MeshDocument &, MLSceneGLSharedDataContext::PerMeshRenderingDataMap&, QGLWidget * ){} + virtual void Render(QAction *, MeshDocument &, MLSceneGLSharedDataContext::PerMeshRenderingDataMap&, QGLWidget *) = 0; + virtual void Finalize(QAction *, MeshDocument *, GLArea *){} virtual bool isSupported() = 0; virtual QList actions() = 0; }; diff --git a/src/common/meshmodel.cpp b/src/common/meshmodel.cpp index 454ce7a88..5ec0f82d3 100644 --- a/src/common/meshmodel.cpp +++ b/src/common/meshmodel.cpp @@ -166,21 +166,8 @@ QString NameDisambiguator(QList &elemList, QString meshLabel ) return newName; } -/* -When you create a new mesh it can be either a newly created one or an opened one. -If it is an opened one the fullpathname is meaningful and the label, by default is just the short name. -If it is a newly created one the fullpath is an empty string and the user has to provide a label. -*/ -MeshModel * MeshDocument::addOrGetMesh(QString fullPath, QString label, bool setAsCurrent,const RenderMode& rm) -{ - MeshModel*newMM = this->getMesh(label); - if(newMM==0) - newMM=this->addNewMesh(fullPath,label,setAsCurrent,rm); - return newMM; -} - -MeshModel * MeshDocument::addNewMesh(QString fullPath, QString label, bool setAsCurrent,const RenderMode& rm) +MeshModel * MeshDocument::addNewMesh(QString fullPath, QString label, bool setAsCurrent) { QString newlabel = NameDisambiguator(this->meshList,label); @@ -193,9 +180,7 @@ MeshModel * MeshDocument::addNewMesh(QString fullPath, QString label, bool setAs MeshModel *newMesh = new MeshModel(this,qPrintable(fullPath),newlabel); meshList.push_back(newMesh); emit meshSetChanged(); - qRegisterMetaType("RenderMode"); emit meshAdded(newMesh->id()); - emit meshAdded(newMesh->id(),rm); if(setAsCurrent) this->setCurrentMesh(newMesh->id()); @@ -775,11 +760,11 @@ int MeshModel::dataMask() const // return result; //} -RenderMode RenderMode::defaultRenderingAtts() -{ - RenderMode result; - result.pmmask = (unsigned int) vcg::GLMeshAttributesInfo::PR_SOLID; - result.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = true; - result.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTNORMAL] = true; - return result; -} +//RenderMode RenderMode::defaultRenderingAtts() +//{ +// RenderMode result; +// result.pmmask = (unsigned int) vcg::GLMeshAttributesInfo::PR_SOLID; +// result.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = true; +// result.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTNORMAL] = true; +// return result; +//} diff --git a/src/common/meshmodel.h b/src/common/meshmodel.h index b0cff1445..9b4b70537 100644 --- a/src/common/meshmodel.h +++ b/src/common/meshmodel.h @@ -40,8 +40,6 @@ #include #include - -#include #include #include #include @@ -304,104 +302,104 @@ public: }; };// end class RasterModel -class RenderMode -{ -private: - QList declist; - -public: - vcg::GLW::DrawMode drawMode; - vcg::GLW::ColorMode colorMode; - vcg::GLW::TextureMode textureMode; - - - - vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK pmmask; - vcg::GLMeshAttributesInfo::RendAtts atts; - - bool lighting; - bool backFaceCull; - bool doubleSideLighting; - bool fancyLighting; - - RenderMode(vcg::GLW::DrawMode dm) // :declist() - { - Init(); - drawMode=dm; - } - - RenderMode() { Init(); } - - void Init() - { - drawMode = vcg::GLW::DMSmooth; - colorMode = vcg::GLW::CMNone; - textureMode = vcg::GLW::TMNone; - - pmmask = vcg::GLMeshAttributesInfo::PR_SOLID; - atts = vcg::GLMeshAttributesInfo::RendAtts(); - atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = true; - atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTNORMAL] = true; - - lighting = true; - backFaceCull = false; - doubleSideLighting = false; - fancyLighting = false; - } - - inline void addPrimitiveModality(vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY addedpm) - { - pmmask = pmmask | addedpm; - } - - inline void removePrimitiveModality(vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY removedpm) - { - pmmask = pmmask & (~removedpm); - } - - inline void setDrawMode(const vcg::GLW::DrawMode dm) - { - drawMode = dm; - } - - inline void setColorMode(const vcg::GLW::ColorMode cm) - { - colorMode = cm; - } - - inline void setTextureMode(const vcg::GLW::TextureMode tm) - { - textureMode = tm; - } - - inline void setLighting(const bool ison) - { - lighting = ison; - } - - inline void setBackFaceCull(const bool ison) - { - backFaceCull = ison; - } - - inline void setDoubleFaceLighting(const bool ison) - { - doubleSideLighting = ison; - } - - inline void setFancyLighting(const bool ison) - { - fancyLighting = ison; - } - - inline QList& decoratorList() - { - return declist; - } - - static RenderMode defaultRenderingAtts(); -}; // end class RenderMode -Q_DECLARE_METATYPE(RenderMode) +//class RenderMode +//{ +//private: +// QList declist; +// +//public: +// vcg::GLW::DrawMode drawMode; +// vcg::GLW::ColorMode colorMode; +// vcg::GLW::TextureMode textureMode; +// +// +// +// vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK pmmask; +// vcg::GLMeshAttributesInfo::RendAtts atts; +// +// bool lighting; +// bool backFaceCull; +// bool doubleSideLighting; +// bool fancyLighting; +// +// RenderMode(vcg::GLW::DrawMode dm) // :declist() +// { +// Init(); +// drawMode=dm; +// } +// +// RenderMode() { Init(); } +// +// void Init() +// { +// drawMode = vcg::GLW::DMSmooth; +// colorMode = vcg::GLW::CMNone; +// textureMode = vcg::GLW::TMNone; +// +// pmmask = vcg::GLMeshAttributesInfo::PR_SOLID; +// atts = vcg::GLMeshAttributesInfo::RendAtts(); +// atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = true; +// atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTNORMAL] = true; +// +// lighting = true; +// backFaceCull = false; +// doubleSideLighting = false; +// fancyLighting = false; +// } +// +// inline void addPrimitiveModality(vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY addedpm) +// { +// pmmask = pmmask | addedpm; +// } +// +// inline void removePrimitiveModality(vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY removedpm) +// { +// pmmask = pmmask & (~removedpm); +// } +// +// inline void setDrawMode(const vcg::GLW::DrawMode dm) +// { +// drawMode = dm; +// } +// +// inline void setColorMode(const vcg::GLW::ColorMode cm) +// { +// colorMode = cm; +// } +// +// inline void setTextureMode(const vcg::GLW::TextureMode tm) +// { +// textureMode = tm; +// } +// +// inline void setLighting(const bool ison) +// { +// lighting = ison; +// } +// +// inline void setBackFaceCull(const bool ison) +// { +// backFaceCull = ison; +// } +// +// inline void setDoubleFaceLighting(const bool ison) +// { +// doubleSideLighting = ison; +// } +// +// inline void setFancyLighting(const bool ison) +// { +// fancyLighting = ison; +// } +// +// inline QList& decoratorList() +// { +// return declist; +// } +// +// static RenderMode defaultRenderingAtts(); +//}; // end class RenderMode +//Q_DECLARE_METATYPE(RenderMode) //class RasterModelState : public QObject //{ @@ -550,9 +548,7 @@ private: public: ///add a new mesh with the given name - MeshModel *addNewMesh(QString fullPath, QString Label, bool setAsCurrent=true,const RenderMode& rm = RenderMode()); - - MeshModel *addOrGetMesh(QString fullPath, QString Label, bool setAsCurrent=true,const RenderMode& rm = RenderMode()); + MeshModel *addNewMesh(QString fullPath, QString Label, bool setAsCurrent=true); ///remove the mesh from the list and delete it from memory bool delMesh(MeshModel *mmToDel); @@ -604,7 +600,6 @@ signals: void meshSetChanged(); void meshAdded(int index); - void meshAdded(int index,RenderMode rm); void meshRemoved(int index); ///whenever the rasterList is changed diff --git a/src/common/ml_shared_data_context.cpp b/src/common/ml_shared_data_context.cpp index e614dfeae..c17dd2ea8 100644 --- a/src/common/ml_shared_data_context.cpp +++ b/src/common/ml_shared_data_context.cpp @@ -44,7 +44,7 @@ void MLSceneGLSharedDataContext::setRequestedAttributesPerMeshView( int mmid,QGL if (man != NULL) { MLRenderingData outdt; - MLBridgeStandAloneFunctions::computeRequestedRenderingAttributesCompatibleWithMesh(mm,perviewdata._mask,perviewdata._atts,outdt._mask,outdt._atts); + MLBridgeStandAloneFunctions::computeRequestedRenderingDataCompatibleWithMesh(mm,perviewdata,outdt); man->setPerViewInfo(viewerid,outdt._mask,outdt._atts); man->setGLOptions(viewerid,outdt._opts); @@ -64,7 +64,7 @@ void MLSceneGLSharedDataContext::setRequestedAttributesPerMeshViews( int mmid,co if (man != NULL) { MLRenderingData outdt; - MLBridgeStandAloneFunctions::computeRequestedRenderingAttributesCompatibleWithMesh(mm,perviewdata._mask,perviewdata._atts,outdt._mask,outdt._atts); + MLBridgeStandAloneFunctions::computeRequestedRenderingDataCompatibleWithMesh(mm,perviewdata,outdt); foreach(QGLContext* vid,viewerid) { man->setPerViewInfo(vid,outdt._mask,outdt._atts); @@ -148,7 +148,10 @@ void MLSceneGLSharedDataContext::meshInserted( int mmid ) { MeshModel* mesh = _md.getMesh(mmid); if (mesh != NULL) + { _meshboman[mmid] = new PerMeshMultiViewManager(mesh->cm,_gpumeminfo,_perbatchtriangles); + _meshboman[mmid]->setDebugMode(true); + } } void MLSceneGLSharedDataContext::meshRemoved(int mmid) @@ -211,13 +214,14 @@ void MLSceneGLSharedDataContext::removeView( QGLContext* viewerid ) void MLSceneGLSharedDataContext::addView( QGLContext* viewerid,const MLRenderingData& dt) { - for(MeshIDManMap::iterator it = _meshboman.begin();it != _meshboman.end();++it) { MeshModel* mesh = _md.getMesh(it.key()); if (mesh != NULL) + { setRequestedAttributesPerMeshView(it.key(),viewerid,dt); - + manageBuffers(it.key()); + } } } @@ -284,12 +288,47 @@ void MLSceneGLSharedDataContext::manageBuffers( int mmid ) } } -void MLBridgeStandAloneFunctions::computeRequestedRenderingAttributesCompatibleWithMesh( MeshModel* meshmodel,const vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK& inputpm,const vcg::GLMeshAttributesInfo::RendAtts& inputatts, - vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK& outputpm, vcg::GLMeshAttributesInfo::RendAtts& outputatts ) +void MLSceneGLSharedDataContext::setDebugMode(int mmid,bool activatedebugmodality ) +{ + MeshModel* mm = _md.getMesh(mmid); + if (mm == NULL) + return; + + PerMeshMultiViewManager* man = meshAttributesMultiViewerManager(mmid); + if (man != NULL) + man->setDebugMode(activatedebugmodality); +} + +void MLSceneGLSharedDataContext::getLog( int mmid,vcg::GLMeshAttributesInfo::DebugInfo& info) +{ + MeshModel* mm = _md.getMesh(mmid); + if (mm == NULL) + return; + + PerMeshMultiViewManager* man = meshAttributesMultiViewerManager(mmid); + if (man != NULL) + man->getLog(info); + return; +} + +bool MLSceneGLSharedDataContext::isBORenderingAvailable( int mmid ) +{ + MeshModel* mm = _md.getMesh(mmid); + if (mm == NULL) + return false; + + PerMeshMultiViewManager* man = meshAttributesMultiViewerManager(mmid); + if (man != NULL) + return man->isBORenderingAvailable(); + return false; +} + +void MLBridgeStandAloneFunctions::computeRequestedRenderingDataCompatibleWithMesh( MeshModel* meshmodel,const MLRenderingData& inputdt,MLRenderingData& outputdt) + { //we use tmp value in order to avoid problems (resetting of the output values at the beginning of the function) if the (&inputpm == &outputpm) || (&inputatts == &outputatts) - vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK tmpoutputpm = outputpm; - vcg::GLMeshAttributesInfo::RendAtts tmpoutputatts = outputatts; + vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK tmpoutputpm = outputdt._mask; + vcg::GLMeshAttributesInfo::RendAtts tmpoutputatts = outputdt._atts; tmpoutputpm = 0; tmpoutputatts.reset(); @@ -298,39 +337,40 @@ void MLBridgeStandAloneFunctions::computeRequestedRenderingAttributesCompatibleW CMeshO& mesh = meshmodel->cm; if (mesh.VN() == 0) { - outputpm = tmpoutputpm; - outputatts = tmpoutputatts; + outputdt._mask = tmpoutputpm; + outputdt._atts = tmpoutputatts; return; } - tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = inputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] && meshmodel->hasDataMask(MeshModel::MM_VERTCOORD); + tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = inputdt._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] && meshmodel->hasDataMask(MeshModel::MM_VERTCOORD); bool validfaces = (mesh.FN() > 0); if (!validfaces) { - outputpm = (unsigned int) ((inputpm & vcg::GLMeshAttributesInfo::PR_POINTS) | (inputpm & vcg::GLMeshAttributesInfo::PR_BBOX)); - outputatts = tmpoutputatts; + outputdt._mask = (unsigned int) ((inputdt._mask & vcg::GLMeshAttributesInfo::PR_POINTS) | (inputdt._mask & vcg::GLMeshAttributesInfo::PR_BBOX)); + outputdt._atts = tmpoutputatts; return; } - - tmpoutputpm = inputpm; - if ((inputpm & vcg::GLMeshAttributesInfo::PR_WIREFRAME_EDGES) && (!meshmodel->hasDataMask(MeshModel::MM_POLYGONAL))) + + tmpoutputpm = inputdt._mask; + if ((inputdt._mask & vcg::GLMeshAttributesInfo::PR_WIREFRAME_EDGES) && (!meshmodel->hasDataMask(MeshModel::MM_POLYGONAL))) tmpoutputpm = tmpoutputpm & (!vcg::GLMeshAttributesInfo::PR_WIREFRAME_EDGES); - tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTNORMAL] = inputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTNORMAL] && meshmodel->hasDataMask(MeshModel::MM_VERTNORMAL); - tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACENORMAL] = inputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACENORMAL] && meshmodel->hasDataMask(MeshModel::MM_FACENORMAL); - tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTCOLOR] = inputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTCOLOR] && meshmodel->hasDataMask(MeshModel::MM_VERTCOLOR); - tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACECOLOR] = inputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACECOLOR] && meshmodel->hasDataMask(MeshModel::MM_FACECOLOR); - tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_MESHCOLOR] = inputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_MESHCOLOR] && meshmodel->hasDataMask(MeshModel::MM_COLOR); + tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTNORMAL] = inputdt._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTNORMAL] && meshmodel->hasDataMask(MeshModel::MM_VERTNORMAL); + tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACENORMAL] = inputdt._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACENORMAL] && meshmodel->hasDataMask(MeshModel::MM_FACENORMAL); + tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTCOLOR] = inputdt._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTCOLOR] && meshmodel->hasDataMask(MeshModel::MM_VERTCOLOR); + tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACECOLOR] = inputdt._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACECOLOR] && meshmodel->hasDataMask(MeshModel::MM_FACECOLOR); + tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_MESHCOLOR] = inputdt._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_MESHCOLOR] && meshmodel->hasDataMask(MeshModel::MM_COLOR); //horrible trick caused by MeshLab GUI. In MeshLab exists just a button turning on/off the texture visualization. //Unfortunately the RenderMode::textureMode member field is not just a boolean value but and enum one. //The enum-value depends from the enabled attributes of input mesh. bool wedgetexture = meshmodel->hasDataMask(MeshModel::MM_WEDGTEXCOORD); - tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTTEXTURE] = inputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTTEXTURE] && (meshmodel->hasDataMask(MeshModel::MM_VERTTEXCOORD) && (!wedgetexture)); - tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_WEDGETEXTURE] = inputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_WEDGETEXTURE] && wedgetexture; - outputatts = tmpoutputatts; - outputpm = tmpoutputpm; + tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTTEXTURE] = inputdt._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTTEXTURE] && (meshmodel->hasDataMask(MeshModel::MM_VERTTEXCOORD) && (!wedgetexture)); + tmpoutputatts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_WEDGETEXTURE] = inputdt._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_WEDGETEXTURE] && wedgetexture; + outputdt._atts = tmpoutputatts; + outputdt._mask = tmpoutputpm; + outputdt._opts = inputdt._opts; } void MLBridgeStandAloneFunctions::fromMeshModelMaskToMLRenderingAtts( int meshmodelmask,vcg::GLMeshAttributesInfo::RendAtts& atts ) diff --git a/src/common/ml_shared_data_context.h b/src/common/ml_shared_data_context.h index 6d8d61962..a7b9eb50a 100644 --- a/src/common/ml_shared_data_context.h +++ b/src/common/ml_shared_data_context.h @@ -36,16 +36,6 @@ class MeshModel; class MeshDocument; -struct MLBridgeStandAloneFunctions -{ - static void computeRequestedRenderingAttributesCompatibleWithMesh( MeshModel* meshmodel,const vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK& inputpm,const vcg::GLMeshAttributesInfo::RendAtts& inputatts, - vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK& outputpm, vcg::GLMeshAttributesInfo::RendAtts& outputatts ); - - static void fromMeshModelMaskToMLRenderingAtts(int meshmodelmask,vcg::GLMeshAttributesInfo::RendAtts& atts); - - static void updatedRenderingAttsAddedToRenderingAttsAccordingToPriorities(const vcg::GLMeshAttributesInfo::RendAtts& updated,const vcg::GLMeshAttributesInfo::RendAtts& current,vcg::GLMeshAttributesInfo::RendAtts& result); -}; - struct MLPerViewGLOptions : public vcg::PerViewPerRenderingModalityGLOptions { bool _visible; @@ -54,6 +44,9 @@ struct MLPerViewGLOptions : public vcg::PerViewPerRenderingModalityGLOptions bool _doublesidelighting; bool _fancylighting; + bool _vertexsel; + bool _facesel; + MLPerViewGLOptions() :vcg::PerViewPerRenderingModalityGLOptions(),_visible(true),_lighting(true),_backfacecull(false),_doublesidelighting(false),_fancylighting(false) { @@ -110,6 +103,16 @@ struct MLRenderingData } }; +struct MLBridgeStandAloneFunctions +{ + static void computeRequestedRenderingDataCompatibleWithMesh( MeshModel* meshmodel,const MLRenderingData& inputdt,MLRenderingData& outputdt); + + static void fromMeshModelMaskToMLRenderingAtts(int meshmodelmask,vcg::GLMeshAttributesInfo::RendAtts& atts); + + static void updatedRenderingAttsAddedToRenderingAttsAccordingToPriorities(const vcg::GLMeshAttributesInfo::RendAtts& updated,const vcg::GLMeshAttributesInfo::RendAtts& current,vcg::GLMeshAttributesInfo::RendAtts& result); +}; + + class MLSceneGLSharedDataContext : public QGLWidget { Q_OBJECT @@ -130,7 +133,8 @@ public: return _highprecision; } - + //Given a QGLContext the PerMeshRenderingDataMap contains the way per each mesh contained in MeshDocument all the current rendering data (eg. flat/smooth shading? pervertex/perface/permesh color?) + //and the 'meaningful' gl parameters used in the rendering system typedef QMap PerMeshRenderingDataMap; void initializeGL(); @@ -148,6 +152,10 @@ public: void meshInserted(int mmid); void meshRemoved(int mmid); void manageBuffers(int mmid); + void setDebugMode(int mmid,bool activatedebugmodality); + void getLog(int mmid,vcg::GLMeshAttributesInfo::DebugInfo& debug); + bool isBORenderingAvailable(int mmid); + public slots: void meshDeallocated(int mmid); void setRequestedAttributesPerMeshViews(int mmid,const QList& viewerid,const MLRenderingData& perviewdata); diff --git a/src/common/mlapplication.h b/src/common/mlapplication.h index 2d6f8c6f6..7288dc8e2 100644 --- a/src/common/mlapplication.h +++ b/src/common/mlapplication.h @@ -4,6 +4,7 @@ #include #include #include +#include "ml_mesh_type.h" template struct MeshLabScalarTest @@ -38,7 +39,7 @@ public: static const QString appName(){return tr("MeshLab"); } static const QString architecturalSuffix(const HW_ARCHITECTURE hw) {return "_" + QString::number(int(hw)) + "bit";} static const QString appArchitecturalName(const HW_ARCHITECTURE hw) {return appName() + architecturalSuffix(hw) + "_" + MeshLabScalarTest::floatingPointPrecision();} - static const QString appVer() {return tr("1.4.0"); } + static const QString appVer() {return tr("2016"); } static const QString completeName(const HW_ARCHITECTURE hw){return appArchitecturalName(hw) + " v" + appVer(); } static const QString organization(){return tr("VCG");} static const QString organizationHost() {return tr("http://vcg.isti.cnr.it");} diff --git a/src/meshlab/additionalgui.h b/src/meshlab/additionalgui.h index d9faa07c9..2b1f9e8d3 100644 --- a/src/meshlab/additionalgui.h +++ b/src/meshlab/additionalgui.h @@ -306,4 +306,35 @@ private slots: void changeFocus(const int k); }; +//class ColorPicker : public QWidget +//{ +// +// Q_OBJECT +// +//public: +// ColorWidget(QWidget *p, RichColor* newColor); +// ~ColorWidget(); +// +// void addWidgetToGridLayout(QGridLayout* lay,const int r); +// void collectWidgetValue(); +// void resetWidgetValue(); +// void setWidgetValue(const Value& nv); +// void initWidgetValue(); +// +//private: +// void updateColorInfo(const ColorValue& newColor); +// QPushButton* colorButton; +// QLabel* colorLabel; +// QLabel* descLabel; +// QColor pickcol; +// +// +//signals: +// void pickedColor(QColor col); +//private slots: +// void pickColor(); +//protected: +// QHBoxLayout* vlay; +//}; + #endif diff --git a/src/meshlab/glarea.cpp b/src/meshlab/glarea.cpp index 2dffbc10e..c438777cf 100644 --- a/src/meshlab/glarea.cpp +++ b/src/meshlab/glarea.cpp @@ -48,7 +48,7 @@ using namespace std; using namespace vcg; GLArea::GLArea(QWidget *parent, MultiViewer_Container *mvcont, RichParameterSet *current) - : QGLWidget(parent,mvcont->sharedDataContext()),interrbutshow(false),rendermodemap() + : QGLWidget(parent,mvcont->sharedDataContext()),interrbutshow(false) { makeCurrent(); parentmultiview = mvcont; @@ -101,23 +101,8 @@ GLArea::GLArea(QWidget *parent, MultiViewer_Container *mvcont, RichParameterSet connect(this->md(), SIGNAL(rasterSetChanged()), this, SLOT(updateRasterSetVisibilities())); connect(this->md(),SIGNAL(documentUpdated()),this,SLOT(completeUpdateRequested())); connect(this, SIGNAL(updateLayerTable()), this->mw(), SIGNAL(updateLayerTable())); - connect(md(),SIGNAL(meshAdded(int,RenderMode)),this,SLOT(meshAdded(int,RenderMode))); connect(md(),SIGNAL(meshRemoved(int)),this,SLOT(meshRemoved(int))); - foreach(MeshModel* mesh,md()->meshList) - { - RenderMode rm; - rendermodemap[mesh->id()] = rm; - vcg::GLMeshAttributesInfo::RendAtts req; - - - //////////////////**********************************************************/////////////////////// - /*MLSceneRenderModeAdapter::renderModeToReqAtts(rm,req); - reqattsmap[mesh->id()] = req;*/ - //////////////////**********************************************************/////////////////////// - - - } /*getting the meshlab MainWindow from parent, which is QWorkspace. *note as soon as the GLArea is added as Window to the QWorkspace the parent of GLArea is a QWidget, *which takes care about the window frame (its parent is the QWorkspace again). @@ -135,7 +120,6 @@ GLArea::GLArea(QWidget *parent, MultiViewer_Container *mvcont, RichParameterSet GLArea::~GLArea() { - rendermodemap.clear(); } /* @@ -465,19 +449,27 @@ void GLArea::paintEvent(QPaintEvent* /*event*/) if(!this->md()->isBusy()) { glPushAttrib(GL_ALL_ATTRIB_BITS); - - if (iRenderer) + + + if ((iRenderer) && (parentmultiview != NULL)) { - iRenderer->Render(currentShader, *this->md(), rendermodemap, this); - foreach(MeshModel * mp, this->md()->meshList) + MLSceneGLSharedDataContext* shared = parentmultiview->sharedDataContext(); + if (shared != NULL) { - if (mp->visible) + MLSceneGLSharedDataContext::PerMeshRenderingDataMap dt; + shared->getRenderInfoPerMeshView(context(),dt); + + iRenderer->Render(currentShader, *this->md(), dt, this); + foreach(MeshModel * mp, this->md()->meshList) { - QList& tmpset = iPerMeshDecoratorsListMap[mp->id()]; - for( QList::iterator it = tmpset.begin(); it != tmpset.end();++it) + if (mp->visible) { - MeshDecorateInterface * decorInterface = qobject_cast((*it)->parent()); - decorInterface->decorateMesh(*it,*mp,this->glas.currentGlobalParamSet, this,&painter,md()->Log); + QList& tmpset = iPerMeshDecoratorsListMap[mp->id()]; + for( QList::iterator it = tmpset.begin(); it != tmpset.end();++it) + { + MeshDecorateInterface * decorInterface = qobject_cast((*it)->parent()); + decorInterface->decorateMesh(*it,*mp,this->glas.currentGlobalParamSet, this,&painter,md()->Log); + } } } } @@ -501,13 +493,16 @@ void GLArea::paintEvent(QPaintEvent* /*event*/) //else foreach(MeshModel * mp, this->md()->meshList) { - QMap::iterator it = rendermodemap.find(mp->id()); if (meshVisibilityMap[mp->id()]) { - RenderMode rm = it.value(); - setLightModel(rm); +//WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! That's really important +/*RenderMode rm = it.value(); +setLightModel(rm);*/ +///////////////////////////////////////////////////////////////////////////////////// + MLRenderingData curr; datacont->getRenderInfoPerMeshView(mp->id(),context(),curr); + setLightModel(curr); if (curr._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTCOLOR] || curr._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACECOLOR] || curr._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_MESHCOLOR]) { glEnable(GL_COLOR_MATERIAL); @@ -515,11 +510,13 @@ void GLArea::paintEvent(QPaintEvent* /*event*/) } else glColor(Color4b(Color4b::LightGray)); - if(rm.backFaceCull) + + + if(curr._opts._backfacecull) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE); - + datacont->setMeshTransformationMatrix(mp->id(),mp->cm.Tr); datacont->draw(mp->id(),context()); @@ -732,7 +729,7 @@ void GLArea::displayRealTimeLog(QPainter *painter) void GLArea::displayInfo(QPainter *painter) { makeCurrent(); - if (mvc() == NULL) + if ((mvc() == NULL) || (md() == NULL)) return; painter->endNativePainting(); painter->save(); @@ -780,16 +777,13 @@ void GLArea::displayInfo(QPainter *painter) col1Text += "Vertices: " + engLocale.toString(mm()->cm.vn) + " (" + engLocale.toString(this->md()->vn()) + ") \n"; col1Text += "Faces: " + engLocale.toString(mm()->cm.fn) + " (" + engLocale.toString(this->md()->fn()) + ") \n"; } - QMap::iterator it = rendermodemap.find(md()->mm()->id()); - if (it != rendermodemap.end()) + + if (mm()->cm.sfn > 0 || mm()->cm.svn > 0) { - RenderMode rm = it.value(); - if (mm()->cm.sfn > 0 || mm()->cm.svn > 0) - { - QLocale engLocale(QLocale::English, QLocale::UnitedStates); - col1Text += "Selection: v: " + engLocale.toString(mm()->cm.svn) + " f: " + engLocale.toString(mm()->cm.sfn) + " \n"; - } + QLocale engLocale(QLocale::English, QLocale::UnitedStates); + col1Text += "Selection: v: " + engLocale.toString(mm()->cm.svn) + " f: " + engLocale.toString(mm()->cm.sfn) + " \n"; } + col1Text += GetMeshInfoString(); if(fov>5) col0Text += QString("FOV: %1\n").arg(fov); @@ -799,17 +793,24 @@ void GLArea::displayInfo(QPainter *painter) enum RenderingType {FULL_BO,MIXED,FULL_IMMEDIATE_MODE}; RenderingType rendtype = FULL_IMMEDIATE_MODE; - for(QMap::const_iterator mit = boallocated.begin();mit != boallocated.end();++mit) + if (parentmultiview != NULL) { - if (mit.value() == true) + MLSceneGLSharedDataContext* shared = parentmultiview->sharedDataContext(); + if (shared != NULL) { - rendtype = MIXED; - if ((rendtype == MIXED) && (mit == boallocated.end() - 1)) - rendtype = FULL_BO; - + int hh = 0; + foreach(MeshModel* meshmod,md()->meshList) + { + if (shared->isBORenderingAvailable(meshmod->id())) + { + rendtype = MIXED; + if ((rendtype == MIXED) && (hh == md()->meshList.size() - 1)) + rendtype = FULL_BO; + } + ++hh; + } } } - switch(rendtype) { case(FULL_BO): @@ -1313,89 +1314,89 @@ void GLArea::updateDecorator(QString name, bool toggle, bool stateToSet) } } -void GLArea::setDrawMode(vcg::GLW::DrawMode mode) +//void GLArea::setDrawMode(vcg::GLW::DrawMode mode) +//{ +// makeCurrent(); +// for(QMap::iterator it = rendermodemap.begin();it != rendermodemap.end();++it) +// it.value().drawMode = mode; +// update(); +//} +// +//void GLArea::setDrawMode(RenderMode& rm,vcg::GLW::DrawMode mode ) +//{ +// makeCurrent(); +// rm.drawMode = mode; +// update(); +//} +// +//void GLArea::setColorMode(vcg::GLW::ColorMode mode) +//{ +// makeCurrent(); +// for(QMap::iterator it = rendermodemap.begin();it != rendermodemap.end();++it) +// it.value().colorMode = mode; +// update(); +//} +// +//void GLArea::setColorMode( RenderMode& rm,vcg::GLW::ColorMode mode ) +//{ +// makeCurrent(); +// rm.colorMode = mode; +// update(); +//} +// +//void GLArea::setTextureMode(vcg::GLW::TextureMode mode) +//{ +// makeCurrent(); +// for(QMap::iterator it = rendermodemap.begin();it != rendermodemap.end();++it) +// it.value().textureMode = mode; +// update(); +//} +// +//void GLArea::setTextureMode(RenderMode& rm,vcg::GLW::TextureMode mode) +//{ +// makeCurrent(); +// rm.textureMode = mode; +// update(); +//} +// +//void GLArea::setLight(bool setState) +//{ +// makeCurrent(); +// for(QMap::iterator it = rendermodemap.begin();it != rendermodemap.end();++it) +// it.value().lighting = setState; +// update(); +//} +// +//void GLArea::setLightMode(bool state,LightingModel lmode) +//{ +// makeCurrent(); +// for(QMap::iterator it = rendermodemap.begin();it != rendermodemap.end();++it) +// { +// switch(lmode) +// { +// case LDOUBLE: it.value().doubleSideLighting = state; break; +// case LFANCY: it.value().fancyLighting = state; break; +// } +// } +// update(); +//} +// +//void GLArea::setBackFaceCulling(bool enabled) +//{ +// makeCurrent(); +// for(QMap::iterator it = rendermodemap.begin();it != rendermodemap.end();++it) +// it.value().backFaceCull = enabled; +// update(); +//} +// +void GLArea::setLightModel(MLRenderingData& dt) { - makeCurrent(); - for(QMap::iterator it = rendermodemap.begin();it != rendermodemap.end();++it) - it.value().drawMode = mode; - update(); -} - -void GLArea::setDrawMode(RenderMode& rm,vcg::GLW::DrawMode mode ) -{ - makeCurrent(); - rm.drawMode = mode; - update(); -} - -void GLArea::setColorMode(vcg::GLW::ColorMode mode) -{ - makeCurrent(); - for(QMap::iterator it = rendermodemap.begin();it != rendermodemap.end();++it) - it.value().colorMode = mode; - update(); -} - -void GLArea::setColorMode( RenderMode& rm,vcg::GLW::ColorMode mode ) -{ - makeCurrent(); - rm.colorMode = mode; - update(); -} - -void GLArea::setTextureMode(vcg::GLW::TextureMode mode) -{ - makeCurrent(); - for(QMap::iterator it = rendermodemap.begin();it != rendermodemap.end();++it) - it.value().textureMode = mode; - update(); -} - -void GLArea::setTextureMode(RenderMode& rm,vcg::GLW::TextureMode mode) -{ - makeCurrent(); - rm.textureMode = mode; - update(); -} - -void GLArea::setLight(bool setState) -{ - makeCurrent(); - for(QMap::iterator it = rendermodemap.begin();it != rendermodemap.end();++it) - it.value().lighting = setState; - update(); -} - -void GLArea::setLightMode(bool state,LightingModel lmode) -{ - makeCurrent(); - for(QMap::iterator it = rendermodemap.begin();it != rendermodemap.end();++it) - { - switch(lmode) - { - case LDOUBLE: it.value().doubleSideLighting = state; break; - case LFANCY: it.value().fancyLighting = state; break; - } - } - update(); -} - -void GLArea::setBackFaceCulling(bool enabled) -{ - makeCurrent(); - for(QMap::iterator it = rendermodemap.begin();it != rendermodemap.end();++it) - it.value().backFaceCull = enabled; - update(); -} - -void GLArea::setLightModel(RenderMode& rm) -{ - makeCurrent(); - if (rm.lighting) + makeCurrent(); + if (dt._opts._lighting) { glEnable(GL_LIGHTING); - if (rm.doubleSideLighting) + if (dt._opts._doublesidelighting) glEnable(GL_LIGHT1); else glDisable(GL_LIGHT1); @@ -1407,7 +1408,7 @@ void GLArea::setLightModel(RenderMode& rm) glLightfv(GL_LIGHT1, GL_AMBIENT, Color4f::Construct(glas.baseLightAmbientColor).V()); glLightfv(GL_LIGHT1, GL_DIFFUSE, Color4f::Construct(glas.baseLightDiffuseColor).V()); glLightfv(GL_LIGHT1, GL_SPECULAR,Color4f::Construct(glas.baseLightSpecularColor).V()); - if(rm.fancyLighting) + if(dt._opts._fancylighting) { glLightfv(GL_LIGHT0, GL_DIFFUSE, Color4f::Construct(glas.fancyFLightDiffuseColor).V()); glLightfv(GL_LIGHT1, GL_DIFFUSE, Color4f::Construct(glas.fancyBLightDiffuseColor).V()); @@ -2167,58 +2168,16 @@ void GLArea::completeUpdateRequested() // return NULL; //} -void GLArea::meshAdded( int index,RenderMode rm ) +void GLArea::meshAdded( int index) { - rendermodemap[index] = rm; -// vcg::GLMeshAttributesInfo::ReqAtts req; -// MLSceneRenderModeAdapter::renderModeToReqAtts(rm,req); -// reqattsmap[index] = req; - boallocated[index] = false; emit updateLayerTable(); } void GLArea::meshRemoved( int index ) { - rendermodemap.remove(index); -// reqattsmap.remove(index); - boallocated.remove(index); emit updateLayerTable(); } - -/*WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!! THIS FUNCTION IS UGLY!!!!! it takes the requested rendering mode directly from the correspondent value found in the rendermodemap!!!!!!! -be sure to have correctly setup it in the render mode map before call this function*/ -bool GLArea::setupRequestedAttributesPerMesh( int meshid ) -{ - bool allocated = false; - MLSceneGLSharedDataContext* shared = getSceneGLSharedContext(); - if (shared != NULL) - { - QMap::iterator itrm = rendermodemap.find(meshid); - if (itrm != rendermodemap.end()) - { -/*WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1*/ -//vcg::GLMeshAttributesInfo::RendAtts rq; -//MLSceneRenderModeAdapter::renderModeToReqAtts(itrm.value(),rq); -//vcg::GLMeshAttributesInfo::RendAtts rr = shared->setupRequestedAttributesPerMesh(meshid,rq,allocated); -//if (allocated) -// reqattsmap[meshid] = rr; -//else -// reqattsmap[meshid] = vcg::GLMeshAttributesInfo::ReqAtts(); - /*WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1*/ - - } - } - - boallocated[meshid] = allocated; - if (!allocated) - { - QString immrenderinginfo = QString("mesh[%1] -> immediate mode rendering").arg(meshid); - this->Logf(GLLogStream::WARNING,qPrintable(immrenderinginfo)); - } - return allocated; -} - void GLArea::setupTextureEnv( GLuint textid ) { makeCurrent(); diff --git a/src/meshlab/glarea.h b/src/meshlab/glarea.h index f8639e737..f9e5ff9b6 100644 --- a/src/meshlab/glarea.h +++ b/src/meshlab/glarea.h @@ -39,7 +39,6 @@ #include #include "glarea_setting.h" #include "snapshotsetting.h" -#include "rendermodeactions.h" #include "multiViewer_Container.h" #define SSHOT_BYTES_PER_PIXEL 4 @@ -89,17 +88,17 @@ public: QAction *getLastAppliedFilter() {return lastFilterRef;} void setLastAppliedFilter(QAction *qa) {lastFilterRef = qa;} - //RenderMode* getCurrentRenderMode(); - RenderMode* getCurrentRenderMode() - { - if ((md() != NULL) && (md()->mm() != NULL)) - { - QMap::iterator it = rendermodemap.find(md()->mm()->id()); - if (it != rendermodemap.end()) - return &it.value(); - } - return NULL; - } + ////RenderMode* getCurrentRenderMode(); + //RenderMode* getCurrentRenderMode() + //{ + // if ((md() != NULL) && (md()->mm() != NULL)) + // { + // QMap::iterator it = rendermodemap.find(md()->mm()->id()); + // if (it != rendermodemap.end()) + // return &it.value(); + // } + // return NULL; + //} void updateFps(float deltaTime); @@ -110,12 +109,13 @@ public: bool isTrackBallVisible() {return trackBallVisible;} bool isDefaultTrackBall() {return activeDefaultTrackball;} - void toggleHelpVisible() {helpVisible = !helpVisible; update();} - void setBackFaceCulling(bool enabled); - void setLight(bool state); - void setLightMode(bool state,LightingModel lmode); void saveSnapshot(); - void setLightModel(RenderMode& rm); + void toggleHelpVisible() {helpVisible = !helpVisible; update();} + /* void setBackFaceCulling(bool enabled); + void setLight(bool state); + void setLightMode(bool state,LightingModel lmode);*/ + + // void setLightModel(RenderMode& rm); void setView(); int RenderForSelection(int pickX, int pickY); @@ -131,12 +131,6 @@ public: QAction* getCurrentShaderAction() {return currentShader;} - /*WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!! THIS FUNCTION IS UGLY!!!!! it takes the requested rendering mode directly from the correspondent value found in the rendermodemap!!!!!!! - be sure to have correctly setup it in the render mode map before call this function*/ - bool setupRequestedAttributesPerMesh(int meshid); - /*****************************************************************************************************************************************************************************/ - - // Edit Mode management // In the glArea we can have a active Editor that can toggled into a ''suspendeed'' state // in which the mouse event are redirected back to the GLArea to drive the camera trackball @@ -156,12 +150,12 @@ public slots: void updateDecorator(QString name, bool toggle, bool stateToSet); //slots for changing the draw rendering and texturing mode - void setDrawMode(vcg::GLW::DrawMode mode); + /* void setDrawMode(vcg::GLW::DrawMode mode); void setDrawMode(RenderMode& rm,vcg::GLW::DrawMode mode ); void setColorMode(vcg::GLW::ColorMode mode); void setColorMode(RenderMode& rm,vcg::GLW::ColorMode mode); void setTextureMode(vcg::GLW::TextureMode mode); - void setTextureMode(RenderMode& rm,vcg::GLW::TextureMode mode); + void setTextureMode(RenderMode& rm,vcg::GLW::TextureMode mode);*/ void updateCustomSettingValues(RichParameterSet& rps); void endEdit(){ @@ -284,6 +278,8 @@ protected: void hideEvent(QHideEvent * event); private: + void GLArea::setLightModel(MLRenderingData& rm); + QMap curMap; void pasteTile(); void setTiledView(GLdouble fovY, float viewRatio, float fAspect, GLdouble zNear, GLdouble zFar, float cameraDist); @@ -319,9 +315,6 @@ private: public: inline MLSceneGLSharedDataContext* getSceneGLSharedContext() {return ((mvc() != NULL)? mvc()->sharedDataContext() : NULL);} - QMap rendermodemap; - QMap boallocated; - // view setting variables float fov; float clipRatioFar; @@ -347,7 +340,7 @@ public slots: void updateRasterSetVisibilities(); private slots: - void meshAdded(int index,RenderMode rm); + void meshAdded(int index); void meshRemoved(int index); private: diff --git a/src/meshlab/layerDialog.cpp b/src/meshlab/layerDialog.cpp index 49edb28ee..b48b75f16 100644 --- a/src/meshlab/layerDialog.cpp +++ b/src/meshlab/layerDialog.cpp @@ -46,10 +46,20 @@ LayerDialog::LayerDialog(QWidget *parent ) : QDockWidget(parent) setWindowFlags( windowFlags() | Qt::WindowStaysOnTopHint | Qt::SubWindow ); this-> QWidget::setAttribute( Qt::WA_MacAlwaysShowToolWindow); setVisible(false); - LayerDialog::ui->setupUi(this); + ui->setupUi(this); mw=qobject_cast(parent); - this->layout(); + /*Horrible trick*/ + _docitem = new QTreeWidgetItem(); + _docitem->setHidden(true); + _globaldoctool = new MLRenderingSideToolbar(); + _globaldoctool->setIconSize(QSize(16,16)); + _globaldoctool->setVisible(false); + /////////////////////////////////// + + createRenderingDataParsView(); + if (tabw != NULL) + ui->renderingLayout->addWidget(tabw); // The following connection is used to associate the click with the change of the current mesh. connect(ui->meshTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem * , int )) , this, SLOT(meshItemClicked(QTreeWidgetItem * , int ) ) ); @@ -70,7 +80,7 @@ LayerDialog::LayerDialog(QWidget *parent ) : QDockWidget(parent) void LayerDialog::keyPressEvent ( QKeyEvent * event ) { MeshDocument *md = mw->meshDoc(); - if(event->key() == Qt::Key_Space ) + if((md != NULL) && (event->key() == Qt::Key_Space )) { RasterModel *rm= md->nextRaster(md->rm()); if(rm!=0) md->setCurrentRaster(rm->id()); @@ -79,10 +89,12 @@ void LayerDialog::keyPressEvent ( QKeyEvent * event ) void LayerDialog::meshItemClicked (QTreeWidgetItem * item , int col) { - MeshTreeWidgetItem *mItem = dynamic_cast(item); - if(mItem) + if(item) { - int clickedId= mItem->_meshid; + int clickedId= -1; + MeshTreeWidgetItem *mItem = dynamic_cast(item); + if (mItem != NULL) + clickedId= mItem->_meshid; switch(col) { case 0 : @@ -96,13 +108,12 @@ void LayerDialog::meshItemClicked (QTreeWidgetItem * item , int col) if(QApplication::keyboardModifiers() == Qt::ControlModifier) { foreach(MeshModel *mp, md->meshList) - { mw->GLA()->meshSetVisibility(mp, false); - } } //Toggle visibility of current mesh - mw->GLA()->meshSetVisibility(md->getMesh(clickedId), !md->getMesh(clickedId)->visible); + if (mItem != NULL) + mw->GLA()->meshSetVisibility(md->getMesh(clickedId), !md->getMesh(clickedId)->visible); // EVEN NICER TRICK. // If the user has pressed alt when clicking on the eye icon, all layers will get visible @@ -124,8 +135,9 @@ void LayerDialog::meshItemClicked (QTreeWidgetItem * item , int col) } mw->GLA()->meshSetVisibility(md->getMesh(clickedId), !md->getMesh(clickedId)->visible); } - - mw->meshDoc()->setCurrentMesh(clickedId); + if (mItem != NULL) + mw->meshDoc()->setCurrentMesh(clickedId); + updateGlobalProjectVisibility(); } break; case 1 : @@ -133,10 +145,16 @@ void LayerDialog::meshItemClicked (QTreeWidgetItem * item , int col) case 3 : //the user has chosen to switch the layer - mw->meshDoc()->setCurrentMesh(clickedId); - this->updateDecoratorParsView(); + if (mItem != NULL) + mw->meshDoc()->setCurrentMesh(clickedId); + /*this->updateDecoratorParsView(clickedId);*/ + //updateRenderingDataParsView(); break; } + MLRenderingData dt; + if (clickedId != -1) + mw->getRenderingData(clickedId,dt); + tabw->setAssociatedMeshIdAndRenderingData(clickedId,dt); //make sure the right row is colored or that they right eye is drawn (open or closed) updateMeshItemSelectionStatus(); mw->GLA()->update(); @@ -318,18 +336,25 @@ void LayerDialog::updateTable(const MLSceneGLSharedDataContext::PerMeshRendering return; } MeshDocument *md=mw->meshDoc(); - this->setWindowTitle(md->docLabel()); + if (md == NULL) + return; /*for(int ii = 0;ii < tobedel.size();++ii) delete tobedel[ii];*/ ui->meshTreeWidget->clear(); ui->meshTreeWidget->setColumnCount(4); - ui->meshTreeWidget->setColumnWidth(0,40); - ui->meshTreeWidget->setColumnWidth(1,40); - //ui->meshTreeWidget->setColumnWidth(2,40); ui->meshTreeWidget->header()->hide(); + + _docitem = new QTreeWidgetItem(); + _docitem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator); + _globaldoctool = new MLRenderingSideToolbar(this); + _globaldoctool->setIconSize(QSize(16,16)); + + updateProjectName(md->docLabel()); + int maxwidth = 0; + QList itms; MeshTreeWidgetItem *selitem = NULL; foreach(MeshModel* mmd, md->meshList) { @@ -345,18 +370,25 @@ void LayerDialog::updateTable(const MLSceneGLSharedDataContext::PerMeshRendering MLSceneGLSharedDataContext::PerMeshRenderingDataMap::const_iterator rdit = dtf.find(mmd->id()); if (rdit != dtf.end()) { - MLRenderToolbar* rendertb = new MLRenderToolbar(mmd->id(),rdit->_mask,this); - connect(rendertb,SIGNAL(primitiveModalityUpdateRequested(unsigned int,vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK)),mw,SLOT(primitiveModalityUpdateRequested(unsigned int,vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK))); - MLRenderParametersFrame* renderfm = new MLRenderParametersFrame(this); - MeshTreeWidgetItem* item = new MeshTreeWidgetItem(mmd,ui->meshTreeWidget,rendertb,renderfm); - item->setExpanded(expandedMap.value(qMakePair(mmd->id(),-1))); - ui->meshTreeWidget->addTopLevelItem(item); + MLRenderingSideToolbar* rendertb = new MLRenderingSideToolbar(mmd->id(),this); + rendertb->setIconSize(QSize(16,16)); + rendertb->setAccordingToRenderingData((*rdit)); + connect(rendertb,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&)),this,SLOT(updateRenderingDataAccordingToActions(int,const QList&))); + MeshTreeWidgetItem* item = new MeshTreeWidgetItem(mmd,ui->meshTreeWidget,rendertb); + item->setExpanded(expandedMap.value(qMakePair(item->_meshid,-1))); + /* QTreeWidgetItem* childitem = new QTreeWidgetItem(); + item->addChild(childitem); + MLRenderingParametersFrame* renderfm = new MLRenderingParametersFrame(mmd->id(),(*rdit),this); + ui->meshTreeWidget->setItemWidget(childitem,3,renderfm);*/ + addDefaultNotes(item,mmd); + itms.push_back(item); //Adding default annotations - addDefaultNotes(item, mmd); + } else throw MeshLabException("Something bad happened! Mesh id has not been found in the rendermapmode map."); } + _docitem->addChildren(itms); int wid = 0; for(int i=0; i< ui->meshTreeWidget->columnCount(); i++) @@ -365,6 +397,7 @@ void LayerDialog::updateTable(const MLSceneGLSharedDataContext::PerMeshRendering wid += ui->meshTreeWidget->columnWidth(i); } ui->meshTreeWidget->setMinimumWidth(wid); + updateGlobalProjectVisibility(); updateMeshItemSelectionStatus(); if (md->rasterList.size() > 0) ui->rasterTreeWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); @@ -372,8 +405,8 @@ void LayerDialog::updateTable(const MLSceneGLSharedDataContext::PerMeshRendering ui->rasterTreeWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Ignored); ui->rasterTreeWidget->clear(); ui->rasterTreeWidget->setColumnCount(4); - ui->rasterTreeWidget->setColumnWidth(0,40); - ui->rasterTreeWidget->setColumnWidth(1,20); + //ui->rasterTreeWidget->setColumnWidth(0,40); + //ui->rasterTreeWidget->setColumnWidth(1,20); //TODO The fourth column is fake... solo per ora, E' per evitare che l'ultimacolonna si allunghi indefinitivamente //mettere una lunghezza fissa e' inutile perche' non so quanto e' lungo il nome. ui->rasterTreeWidget->header()->hide(); @@ -587,17 +620,6 @@ void LayerDialog::updateDecoratorParsView() //ui->decParsTree->expandAll(); } -void LayerDialog::renderingModalityChanged(const MLRenderingData& data ) -{ - for(int ii = 0;ii < ui->meshTreeWidget->topLevelItemCount();++ii) - { - //QTreeWidgetItem is NOT derived from QObject. The usual qobject_cast is not effective - MeshTreeWidgetItem* itm = dynamic_cast(ui->meshTreeWidget->topLevelItem(ii)); - if (itm != NULL) - itm->_rendertoolbar->setPrimitiveModality(data._mask); - } -} - void LayerDialog::updateMeshItemSelectionStatus() { MeshDocument* md = mw->meshDoc(); @@ -639,15 +661,84 @@ void LayerDialog::reset() ui->rasterTreeWidget->clear(); } -MeshTreeWidgetItem::MeshTreeWidgetItem(MeshModel* meshmodel,QTreeWidget* tree,MLRenderToolbar* rendertoolbar,MLRenderParametersFrame* frame) - :QTreeWidgetItem(tree),_rendertoolbar(rendertoolbar),_frame(frame) +void LayerDialog::updateRenderingDataParsView(int meshid,const MLRenderingData& dt ) { + tabw->setAssociatedMeshIdAndRenderingData(meshid,dt); +} + +void LayerDialog::createRenderingDataParsView() +{ + if (_globaldoctool != NULL) + { + tabw = new MLRenderingParametersTab(-1,_globaldoctool->getRenderingActions(),this); + tabw->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Expanding); + connect(tabw,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&)),this,SLOT(updateRenderingDataAccordingToActions(int,const QList&))); + } +} + +void LayerDialog::updateProjectName( const QString& name ) +{ + setWindowTitle(name); + QFileInfo fi(name); + _docitem->setText(1,""); + QFont fnt; + fnt.setBold(true); + _docitem->setFont(2,fnt); + _docitem->setText(2,fi.baseName()); + ui->meshTreeWidget->addTopLevelItem(_docitem); + ui->meshTreeWidget->setItemWidget(_docitem,3,_globaldoctool); +} + +void LayerDialog::updateGlobalProjectVisibility() +{ + if (mw == NULL) + return; + MeshDocument* md = mw->meshDoc(); + if (md == NULL) + return; + bool allhidden = true; + for(int ii = 0;ii < ui->meshTreeWidget->topLevelItemCount();++ii) + { + QTreeWidgetItem* qitm = ui->meshTreeWidget->topLevelItem(ii); + MeshTreeWidgetItem* mitm = dynamic_cast(qitm); + if (mitm != NULL) + { + MeshModel* mm = md->getMesh(mitm->_meshid); + if (mm != NULL) + { + allhidden = allhidden && !(mm->isVisible()); + mitm->updateVisibility(mm->isVisible()); + } + } + } + + if ((!md->meshList.isEmpty()) && allhidden) + _docitem->setIcon(0,QIcon(":/images/layer_eye_close.png")); + else + _docitem->setIcon(0,QIcon(":/images/layer_eye_open.png")); +} + +void LayerDialog::updateRenderingDataAccordingToActions(int meshid,const QList& acts) +{ + if (mw == NULL) + return; + MLRenderingData dt; + mw->getRenderingData(meshid,dt); + foreach(MLRenderingAction* act,acts) + { + if (act != NULL) + act->updateRenderingData(dt); + } + mw->setRenderingData(meshid,dt); + mw->GLA()->update(); +} + +MeshTreeWidgetItem::MeshTreeWidgetItem(MeshModel* meshmodel,QTreeWidget* tree,MLRenderingToolbar* rendertoolbar) + :QTreeWidgetItem(tree),_rendertoolbar(rendertoolbar) +{ if (meshmodel != NULL) { - if(meshmodel->visible) - setIcon(0,QIcon(":/images/layer_eye_open.png")); - else - setIcon(0,QIcon(":/images/layer_eye_close.png")); + updateVisibility(meshmodel->visible); setText(1, QString::number(meshmodel->id())); QString meshName = meshmodel->label(); @@ -655,13 +746,14 @@ MeshTreeWidgetItem::MeshTreeWidgetItem(MeshModel* meshmodel,QTreeWidget* tree,ML meshName += " *"; if (_rendertoolbar != NULL) tree->setItemWidget(this,3,_rendertoolbar); + setText(2, meshName); _meshid = meshmodel->id(); } } -MeshTreeWidgetItem::MeshTreeWidgetItem(QTreeWidget* tree,MLRenderToolbar* rendertoolbar,MLRenderParametersFrame* frame) - :QTreeWidgetItem(tree),_rendertoolbar(rendertoolbar),_frame(frame) +MeshTreeWidgetItem::MeshTreeWidgetItem(QTreeWidget* tree,MLRenderingToolbar* rendertoolbar) + :QTreeWidgetItem(tree),_rendertoolbar(rendertoolbar) { setIcon(0,QIcon(":/images/layer_eye_open.png")); @@ -676,6 +768,14 @@ MeshTreeWidgetItem::~MeshTreeWidgetItem() delete addwid;*/ } +void MeshTreeWidgetItem::updateVisibility( bool isvisible ) +{ + if(isvisible) + setIcon(0,QIcon(":/images/layer_eye_open.png")); + else + setIcon(0,QIcon(":/images/layer_eye_close.png")); +} + RasterTreeWidgetItem::RasterTreeWidgetItem(RasterModel *rasterModel) { if(rasterModel->visible) setIcon(0,QIcon(":/images/ok.png")); diff --git a/src/meshlab/layerDialog.h b/src/meshlab/layerDialog.h index 13ce17a73..d1193d493 100644 --- a/src/meshlab/layerDialog.h +++ b/src/meshlab/layerDialog.h @@ -20,20 +20,19 @@ * for more details. * * * ****************************************************************************/ -/**************************************************************************** -History -$Log: stdpardialog.cpp,v $ -****************************************************************************/ + #ifndef LAYER_DIALOG_H #define LAYER_DIALOG_H #include #include +#include #include #include #include "ml_render_gui.h" + class MainWindow; class QTreeWidget; class GLLogStream; @@ -52,15 +51,16 @@ namespace Ui class layerDialog; } + class MeshTreeWidgetItem : public QTreeWidgetItem { public: - MeshTreeWidgetItem(MeshModel* meshmodel,QTreeWidget* tree,MLRenderToolbar* rendertoolbar,MLRenderParametersFrame* frame); - MeshTreeWidgetItem(QTreeWidget* tree,MLRenderToolbar* rendertoolbar,MLRenderParametersFrame* frame); + MeshTreeWidgetItem(MeshModel* meshmodel,QTreeWidget* tree,MLRenderingToolbar* rendertoolbar); + MeshTreeWidgetItem(QTreeWidget* tree,MLRenderingToolbar* rendertoolbar); ~MeshTreeWidgetItem(); + void updateVisibility(bool isvisible); - MLRenderToolbar* _rendertoolbar; - MLRenderParametersFrame* _frame; + MLRenderingToolbar* _rendertoolbar; int _meshid; }; @@ -112,6 +112,7 @@ public: ~LayerDialog(); void updateLog(GLLogStream &Log); void updateDecoratorParsView(); + void updateRenderingDataParsView(int meshid,const MLRenderingData& dt); void reset(); public slots: void keyPressEvent ( QKeyEvent * event ); @@ -121,7 +122,7 @@ public slots: void showEvent ( QShowEvent * event ); void showContextMenu(const QPoint& pos); void adaptLayout(QTreeWidgetItem * item); - void renderingModalityChanged(const MLRenderingData& data); + void updateRenderingDataAccordingToActions(int meshid,const QList&); private: Ui::layerDialog* ui; @@ -134,15 +135,23 @@ private: QMap< QPair , bool> expandedMap; //QList tobedel; void addDefaultNotes(QTreeWidgetItem * parent, MeshModel *meshModel); + void updateColumnNumber(const QTreeWidgetItem * item); //QVector tobedeleted; void updateExpandedMap(int meshId, int tagId, bool expanded); void updateMeshItemSelectionStatus(); + void createRenderingDataParsView(); + void updateProjectName(const QString& name); + void updateGlobalProjectVisibility(); //it maintains mapping between the main toolbar action and the per mesh corresponding action in the side toolbar. //used when an action in the main toolbar is selected. A signal is emitted informing the current meshtreewidgetitem that it has to update its own side toolbar. QMap > maintb_sidetb_map; - MeshTreeWidgetItem* docitem; + QTreeWidgetItem* _docitem; + MLRenderingSideToolbar* _globaldoctool; + + + MLRenderingParametersTab* tabw; signals: void removeDecoratorRequested(QAction* ); void toBeShow(); diff --git a/src/meshlab/mainwindow.h b/src/meshlab/mainwindow.h index cae380327..5c81e8658 100644 --- a/src/meshlab/mainwindow.h +++ b/src/meshlab/mainwindow.h @@ -115,15 +115,13 @@ private slots: void meshAdded(int mid); void meshRemoved(int mid); + public slots: bool importMeshWithLayerManagement(QString fileName=QString()); bool importRaster(const QString& fileImg = QString()); bool openProject(QString fileName=QString()); bool appendProject(QString fileName=QString()); void updateCustomSettings(); - void updateRenderMode(); - void updateRenderMode(vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK pmmask,vcg::GLMeshAttributesInfo::RendAtts atts); - void primitiveModalityUpdateRequested(unsigned int mmid,vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK pmmask); private slots: bool importMesh(QString fileName=QString()); @@ -141,6 +139,8 @@ public: bool loadMeshWithStandardParams(QString& fullPath,MeshModel* mm, const Matrix44m &mtr=Matrix44m::Identity()); void defaultPerViewRenderingData(MLRenderingData& dt) const; + void getRenderingData(int mid,MLRenderingData& dt) const; + void setRenderingData(int mid,const MLRenderingData& dt); private slots: //////////// Slot Menu File ////////////////////// void reload(); @@ -183,7 +183,6 @@ private slots: void updateXMLStdDialog(); void enableDocumentSensibleActionsContainer(const bool enable); void updateLayerDialog(); - //void updatePerViewApplicationStatus(); void setSplit(QAction *qa); void setUnsplit(); @@ -218,7 +217,7 @@ private slots: void scriptCodeExecuted(const QScriptValue& val,const int time,const QString& output); private: - + void addRenderingSystemLogInfo(unsigned mmid); int longestActionWidthInMenu(QMenu* m,const int longestwidth); int longestActionWidthInMenu( QMenu* m); int longestActionWidthInAllMenus(); @@ -282,9 +281,8 @@ private: QDir lastUsedDirectory; //This will hold the last directory that was used to load/save a file/project in - vcg::GLW::TextureMode getBestTextureRenderModePerMesh(const int meshid); - void setBestTextureModePerMesh(RenderModeAction* textact,const int meshid, RenderMode& rm); - void getCurrentRenderingData(MLRenderingData& rdata) const; + //vcg::GLW::TextureMode getBestTextureRenderModePerMesh(const int meshid); + //void setBestTextureModePerMesh(RenderModeAction* textact,const int meshid, RenderMode& rm); public: PluginManager PM; @@ -338,7 +336,6 @@ public: void setHandleMenu(QPoint point, Qt::Orientation orientation, QSplitter *origin); QMenu* meshLayerMenu() { return filterMenuMeshLayer; } QMenu* rasterLayerMenu() { return filterMenuRasterLayer; } - void connectRenderModeActionList(QList& actlist); private: //the xml filters run in a different thread. The xmlfiltertimer starts on executeFilter and stops on postFilterExecution @@ -494,8 +491,6 @@ private: }; QMap existingmeshesbeforefilterexecution; static QString getDecoratedFileName(const QString& name); - - void updateRenderToolBar( RenderModeAction* act ); }; /// Event filter that is installed to intercept the open events sent directly by the Operative System diff --git a/src/meshlab/mainwindow_Init.cpp b/src/meshlab/mainwindow_Init.cpp index 0eb8048a6..4b4385d1c 100644 --- a/src/meshlab/mainwindow_Init.cpp +++ b/src/meshlab/mainwindow_Init.cpp @@ -75,6 +75,7 @@ MainWindow::MainWindow() // Permette di passare da una finestra all'altra e tenere aggiornato il workspace connect(windowMapper, SIGNAL(mapped(QWidget*)),this, SLOT(wrapSetActiveSubWindow(QWidget *))); // Quando si passa da una finestra all'altra aggiorna lo stato delle toolbar e dei menu + connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)),this, SLOT(updateLayerDialog())); connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)),this, SLOT(updateMenus())); connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)),this, SLOT(updateWindowMenu())); connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)),this, SLOT(updateStdDialog())); @@ -134,7 +135,7 @@ MainWindow::MainWindow() //qb->setAutoClose(true); //qb->setMinimumDuration(0); //qb->reset(); - connect(this, SIGNAL(updateLayerTable()), layerDialog, SLOT(updateTable())); + connect(this, SIGNAL(updateLayerTable()), this, SLOT(updateLayerDialog())); connect(layerDialog,SIGNAL(removeDecoratorRequested(QAction*)),this,SLOT(switchOffDecorator(QAction*))); } @@ -1158,7 +1159,8 @@ void MainWindow::submitBug() void MainWindow::wrapSetActiveSubWindow(QWidget* window){ QMdiSubWindow* subwindow; subwindow = dynamic_cast(window); - if(subwindow!= NULL){ + if(subwindow!= NULL) + { mdiarea->setActiveSubWindow(subwindow); }else{ qDebug("Type of window is not a QMdiSubWindow*"); diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index f91f74386..e02c5f4da 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -343,10 +343,16 @@ void MainWindow::updateLayerDialog() layerDialog->updateTable(dtf); layerDialog->updateLog(meshDoc()->Log); layerDialog->updateDecoratorParsView(); + MLRenderingData dt; + if (meshDoc()->mm() != NULL) + { + MLSceneGLSharedDataContext::PerMeshRenderingDataMap:: iterator it = dtf.find(meshDoc()->mm()->id()); + if (it != dtf.end()) + layerDialog->updateRenderingDataParsView(meshDoc()->mm()->id(),*it); + } } } - void MainWindow::updateMenus() { bool activeDoc = (bool) !mdiarea->subWindowList().empty() && mdiarea->currentSubWindow(); @@ -416,38 +422,41 @@ void MainWindow::updateMenus() showInfoPaneAct->setChecked(GLA()->infoAreaVisible); showTrackBallAct->setChecked(GLA()->isTrackBallVisible()); - RenderMode rendtmp; - if (meshDoc()->meshList.size() > 0) - { - QMap::iterator it = GLA()->rendermodemap.find(meshDoc()->meshList[0]->id()); - if (it == GLA()->rendermodemap.end()) - throw MeshLabException("Something really bad happened. Mesh id has not been found in rendermodemap."); - rendtmp = it.value(); - } - bool checktext = (rendtmp.textureMode != GLW::TMNone); - int ii = 0; - while(ii < meshDoc()->meshList.size()) - { - if (meshDoc()->meshList[ii] == NULL) - return; - QMap::iterator it = GLA()->rendermodemap.find(meshDoc()->meshList[ii]->id()); - if (it == GLA()->rendermodemap.end()) - throw MeshLabException("Something really bad happened. Mesh id has not been found in rendermodemap."); - RenderMode& rm = it.value(); - if (rendtmp.drawMode != rm.drawMode) - rendtmp.setDrawMode(vcg::GLW::DMNone); - if (rendtmp.colorMode != rm.colorMode) - rendtmp.setColorMode(vcg::GLW::CMNone); +//WARNING!!!! It may be useful +/* RenderMode rendtmp; +if (meshDoc()->meshList.size() > 0) +{ + QMap::iterator it = GLA()->rendermodemap.find(meshDoc()->meshList[0]->id()); + if (it == GLA()->rendermodemap.end()) + throw MeshLabException("Something really bad happened. Mesh id has not been found in rendermodemap."); + rendtmp = it.value(); +} +bool checktext = (rendtmp.textureMode != GLW::TMNone); +int ii = 0; +while(ii < meshDoc()->meshList.size()) +{ + if (meshDoc()->meshList[ii] == NULL) + return; + QMap::iterator it = GLA()->rendermodemap.find(meshDoc()->meshList[ii]->id()); + if (it == GLA()->rendermodemap.end()) + throw MeshLabException("Something really bad happened. Mesh id has not been found in rendermodemap."); + RenderMode& rm = it.value(); + if (rendtmp.drawMode != rm.drawMode) + rendtmp.setDrawMode(vcg::GLW::DMNone); - checktext &= (rm.textureMode != GLW::TMNone); + if (rendtmp.colorMode != rm.colorMode) + rendtmp.setColorMode(vcg::GLW::CMNone); - rendtmp.setLighting(rendtmp.lighting && rm.lighting); - rendtmp.setFancyLighting(rendtmp.fancyLighting && rm.fancyLighting); - rendtmp.setDoubleFaceLighting(rendtmp.doubleSideLighting && rm.doubleSideLighting); - rendtmp.setBackFaceCull(rendtmp.backFaceCull || rm.backFaceCull); - ++ii; - } + checktext &= (rm.textureMode != GLW::TMNone); + + rendtmp.setLighting(rendtmp.lighting && rm.lighting); + rendtmp.setFancyLighting(rendtmp.fancyLighting && rm.fancyLighting); + rendtmp.setDoubleFaceLighting(rendtmp.doubleSideLighting && rm.doubleSideLighting); + rendtmp.setBackFaceCull(rendtmp.backFaceCull || rm.backFaceCull); + ++ii; +}*/ +///////////////////////////// // Decorator Menu Checking and unChecking // First uncheck and disable all the decorators @@ -906,16 +915,16 @@ void MainWindow::runFilterScript() { if(classes & MeshFilterInterface::FaceColoring ) { - GLA()->setColorMode(vcg::GLW::CMPerFace); +//GLA()->setColorMode(vcg::GLW::CMPerFace); meshDoc()->mm()->updateDataMask(MeshModel::MM_FACECOLOR); } if(classes & MeshFilterInterface::VertexColoring ){ - GLA()->setColorMode(vcg::GLW::CMPerVert); +//GLA()->setColorMode(vcg::GLW::CMPerVert); meshDoc()->mm()->updateDataMask(MeshModel::MM_VERTCOLOR); } if(classes & MeshModel::MM_COLOR) { - GLA()->setColorMode(vcg::GLW::CMPerMesh); +//GLA()->setColorMode(vcg::GLW::CMPerMesh); meshDoc()->mm()->updateDataMask(MeshModel::MM_COLOR); } if(classes & MeshModel::MM_CAMERA) @@ -1202,7 +1211,7 @@ void MainWindow::updateSharedContextDataAfterFilterExecution(int postcondmask,in currentmeshnewlycreated = true; defaultPerViewRenderingData(dttoberendered); } - MLBridgeStandAloneFunctions::computeRequestedRenderingAttributesCompatibleWithMesh(mm,dttoberendered._mask,dttoberendered._atts,dttoberendered._mask,dttoberendered._atts); + MLBridgeStandAloneFunctions::computeRequestedRenderingDataCompatibleWithMesh(mm,dttoberendered,dttoberendered); foreach(GLArea* gla,mvc->viewerList) { if (gla != NULL) @@ -1217,6 +1226,7 @@ void MainWindow::updateSharedContextDataAfterFilterExecution(int postcondmask,in } } shared->manageBuffers(mm->id()); + addRenderingSystemLogInfo(mm->id()); } } } @@ -1332,7 +1342,7 @@ void MainWindow::executeFilter(QAction *action, RichParameterSet ¶ms, bool i { //WARNING!!!!! HERE IT SHOULD BE A CHECK IF THE FILTER IS FOR MESH OR FOR DOCUMENT (IN THIS CASE I SHOULD ACTIVATE ALL THE TEXTURE MODE FOR EVERYONE...) //NOW WE HAVE JUST TEXTURE FILTERS WORKING ON SINGLE MESH - QMap::iterator it = GLA()->rendermodemap.find(meshDoc()->mm()->id()); + //QMap::iterator it = GLA()->rendermodemap.find(meshDoc()->mm()->id()); //if (it != GLA()->rendermodemap.end()) // it.value().setTextureMode(GLW::TMPerWedgeMulti); updateTexture(meshDoc()->mm()->id()); @@ -1650,16 +1660,16 @@ void MainWindow::postFilterExecution() } if(fclasses & MeshFilterInterface::FaceColoring ) { - GLA()->setColorMode(vcg::GLW::CMPerFace); +//GLA()->setColorMode(vcg::GLW::CMPerFace); meshDoc()->mm()->updateDataMask(MeshModel::MM_FACECOLOR); } if(fclasses & MeshFilterInterface::VertexColoring ){ - GLA()->setColorMode(vcg::GLW::CMPerVert); +/*GLA()->setColorMode(vcg::GLW::CMPerVert);*/ meshDoc()->mm()->updateDataMask(MeshModel::MM_VERTCOLOR); } if(fclasses & MeshModel::MM_COLOR) { - GLA()->setColorMode(vcg::GLW::CMPerMesh); +/*GLA()->setColorMode(vcg::GLW::CMPerMesh);*/ meshDoc()->mm()->updateDataMask(MeshModel::MM_COLOR); } @@ -1672,11 +1682,14 @@ void MainWindow::postFilterExecution() if(fclasses & MeshFilterInterface::Texture ) { - //WARNING!!!!! HERE IT SHOULD BE A CHECK IF THE FILTER IS FOR MESH OR FOR DOCUMENT (IN THIS CASE I SHOULD ACTIVATE ALL THE TEXTURE MODE FOR EVERYONE...) - //NOW WE HAVE JUST TEXTURE FILTERS WORKING ON SINGLE MESH - QMap::iterator it = GLA()->rendermodemap.find(meshDoc()->mm()->id()); - if (it != GLA()->rendermodemap.end()) - it.value().setTextureMode(GLW::TMPerWedgeMulti); +//WARNING!!!!! This should be replaced in some way +//WARNING!!!!! HERE IT SHOULD BE A CHECK IF THE FILTER IS FOR MESH OR FOR DOCUMENT (IN THIS CASE I SHOULD ACTIVATE ALL THE TEXTURE MODE FOR EVERYONE...) +//NOW WE HAVE JUST TEXTURE FILTERS WORKING ON SINGLE MESH +//QMap::iterator it = GLA()->rendermodemap.find(meshDoc()->mm()->id()); +//if (it != GLA()->rendermodemap.end()) +// it.value().setTextureMode(GLW::TMPerWedgeMulti); +////////////////////////////////////////////////////////////////////////////// + updateTexture(meshDoc()->mm()->id()); } /* QMap::iterator it = envtobedeleted.find(obj); @@ -1783,20 +1796,27 @@ void MainWindow::applyRenderMode() // Make the call to the plugin core MeshRenderInterface *iRenderTemp = qobject_cast(action->parent()); bool initsupport = false; - if (iRenderTemp != NULL) + MultiViewer_Container* mw = this->currentViewContainer(); + if ((iRenderTemp != NULL) && (mw != NULL)) { - iRenderTemp->Init(action,*(meshDoc()),GLA()->rendermodemap,GLA()); - initsupport = iRenderTemp->isSupported(); - if (initsupport) - GLA()->setRenderer(iRenderTemp,action); - else + MLSceneGLSharedDataContext* shared = mw->sharedDataContext(); + if (shared != NULL) { - if (!initsupport) + MLSceneGLSharedDataContext::PerMeshRenderingDataMap dt; + shared->getRenderInfoPerMeshView(GLA()->context(),dt); + iRenderTemp->Init(action,*(meshDoc()),dt,GLA()); + initsupport = iRenderTemp->isSupported(); + if (initsupport) + GLA()->setRenderer(iRenderTemp,action); + else { - QString msg = "The selected shader is not supported by your graphic hardware!"; - GLA()->Logf(GLLogStream::SYSTEM,qPrintable(msg)); + if (!initsupport) + { + QString msg = "The selected shader is not supported by your graphic hardware!"; + GLA()->Logf(GLLogStream::SYSTEM,qPrintable(msg)); + } + iRenderTemp->Finalize(action,meshDoc(),GLA()); } - iRenderTemp->Finalize(action,meshDoc(),GLA()); } } @@ -2028,8 +2048,11 @@ bool MainWindow::openProject(QString fileName) return false; } - GLA()->setColorMode(GLW::CMPerVert); - GLA()->setDrawMode(GLW::DMPoints); + +//WARNING!!!!! i suppose it's not useful anymore but....... +/*GLA()->setColorMode(GLW::CMPerVert); +GLA()->setDrawMode(GLW::DMPoints);*/ +///////////////////////////////////////////////////////// } //////NVM @@ -2042,8 +2065,10 @@ bool MainWindow::openProject(QString fileName) QMessageBox::critical(this, tr("Meshlab Opening Error"), "Unable to open NVMs file"); return false; } - GLA()->setColorMode(GLW::CMPerVert); - GLA()->setDrawMode(GLW::DMPoints); +//WARNING!!!!! i suppose it's not useful anymore but....... +/*GLA()->setColorMode(GLW::CMPerVert); +GLA()->setDrawMode(GLW::DMPoints);*/ +///////////////////////////////////////////////////////// } meshDoc()->setBusy(false); @@ -2273,10 +2298,6 @@ bool MainWindow::loadMesh(const QString& fileName, MeshIOInterface *pCurrentIOPl if ((GLA() == NULL) || (mm == NULL)) return false; - QMap::iterator it = GLA()->rendermodemap.find(mm->id()); - if (it == GLA()->rendermodemap.end()) - return false; - RenderMode& rm = it.value(); QFileInfo fi(fileName); QString extension = fi.suffix(); if(!fi.exists()) @@ -2328,19 +2349,19 @@ bool MainWindow::loadMesh(const QString& fileName, MeshIOInterface *pCurrentIOPl saveRecentFileList(fileName); - if( mask & vcg::tri::io::Mask::IOM_FACECOLOR) - GLA()->setColorMode(GLW::CMPerFace); - if( mask & vcg::tri::io::Mask::IOM_VERTCOLOR) - GLA()->setColorMode(GLW::CMPerVert); if(!meshDoc()->mm()->cm.textures.empty()) { updateTexture(meshDoc()->mm()->id()); if(tri::HasPerVertexTexCoord(meshDoc()->mm()->cm) ) - GLA()->setTextureMode(rm,GLW::TMPerVert); +//WARNING!!!!!!!! +/*GLA()->setTextureMode(rm,GLW::TMPerVert)*/; +//////////////////////////////////////////// if(tri::HasPerWedgeTexCoord(meshDoc()->mm()->cm) ) - GLA()->setTextureMode(rm,GLW::TMPerWedgeMulti); +//WARNING!!!!!!!! +/*GLA()->setTextureMode(rm,GLW::TMPerWedgeMulti)*/; +//////////////////////////////////////////// } // In case of polygonal meshes the normal should be updated accordingly @@ -2362,16 +2383,19 @@ bool MainWindow::loadMesh(const QString& fileName, MeshIOInterface *pCurrentIOPl } vcg::tri::UpdateBounding::Box(mm->cm); // updates bounding box if(mm->cm.fn==0 && mm->cm.en==0){ - GLA()->setDrawMode(rm,vcg::GLW::DMPoints); if(!(mask & vcg::tri::io::Mask::IOM_VERTNORMAL)) - GLA()->setLight(false); +//WARNING!!!!! +/*GLA()->setLight(false)*/; +////////////////////////// else mm->updateDataMask(MeshModel::MM_VERTNORMAL); } if(mm->cm.fn==0 && mm->cm.en>0){ - GLA()->setDrawMode(rm,vcg::GLW::DMWire); if(!(mask & vcg::tri::io::Mask::IOM_VERTNORMAL)) - GLA()->setLight(false); + +//WARNING!!!!! +/*GLA()->setLight(false)*/; +////////////////////////// else mm->updateDataMask(MeshModel::MM_VERTNORMAL); } @@ -2385,7 +2409,6 @@ bool MainWindow::loadMesh(const QString& fileName, MeshIOInterface *pCurrentIOPl if(delVertNum>0 || delFaceNum>0 ) QMessageBox::warning(this, "MeshLab Warning", QString("Warning mesh contains %1 vertices with NAN coords and %2 degenerated faces.\nCorrected.").arg(delVertNum).arg(delFaceNum) ); mm->cm.Tr = mtr; - vcg::GLW::NormalMode nm = vcg::GlTrimesh::convertDrawModeToNormalMode(rm.drawMode); MultiViewer_Container* mv = currentViewContainer(); if (mv != NULL) @@ -2403,7 +2426,7 @@ bool MainWindow::loadMesh(const QString& fileName, MeshIOInterface *pCurrentIOPl MLRenderingData defdt; defaultPerViewRenderingData(defdt); shared->setRequestedAttributesPerMeshViews(mm->id(),contlist,defdt); - layerDialog->renderingModalityChanged(defdt); + updateLayerDialog(); } } @@ -3011,19 +3034,6 @@ void MainWindow::sendHistory() } -void MainWindow::updateRenderToolBar( RenderModeAction* /*act*/ ) -{ - //if (GLA() == NULL) - // return; - //QMap& rmode = GLA()->rendermodemap; - //const RenderMode& tmp = *(rmode.begin()); - //for(QMap::const_iterator it = rmode.begin(); it != rmode.end();++it) - //{ - // if () - //} -} - - void convertGLMeshAttributsInfoIntoString(vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK pmmask,vcg::GLMeshAttributesInfo::RendAtts& atts,QString& result) { result += "PRIMITIVE_MODALITY_MASK: "; @@ -3050,177 +3060,91 @@ void convertGLMeshAttributsInfoIntoString(vcg::GLMeshAttributesInfo::PRIMITIVE_M result += tmp; } -void MainWindow::updateRenderMode( vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK pmmask,vcg::GLMeshAttributesInfo::RendAtts atts ) -{ - QString rmstring; - convertGLMeshAttributsInfoIntoString(pmmask,atts,rmstring); - GLLogStream st; - st.Log(0,qPrintable(rmstring)); - layerDialog->updateLog(st); +//WARNING!!!! Probably it's useless +//void MainWindow::updateRenderMode( ) +//{ +// if ((GLA() == NULL) || (meshDoc() == NULL)) +// return; +// QMap& rmode = GLA()->rendermodemap; +// +// RenderModeAction* act = qobject_cast(sender()); +// RenderModeTexturePerWedgeAction* textact = qobject_cast(act); +// +// //act->data contains the meshid to which the action is referred. +// //if the meshid is -1 the action is intended to be per-document and not per mesh +// bool isvalidid = true; +// int meshid = act->data().toInt(&isvalidid); +// if (!isvalidid) +// throw MeshLabException("A RenderModeAction contains a non-integer data id."); +// +// if (meshid == -1) +// { +// for(QMap::iterator it = rmode.begin();it != rmode.end();++it) +// { +// RenderMode& rm = it.value(); +// RenderMode old = rm; +// +// act->updateRenderMode(rm); +// //horrible trick caused by MeshLab GUI. In MeshLab exists just a button turning on/off the texture visualization. +// //Unfortunately the RenderMode::textureMode member field is not just a boolean value but and enum one. +// //The enum-value depends from the enabled attributes of input mesh. +// if (textact != NULL) +// setBestTextureModePerMesh(textact,it.key(),rm); +// +// MeshModel* mmod = meshDoc()->getMesh(it.key()); +// if (mmod != NULL) +// { +// throw MeshLabException("A RenderModeAction referred to a non-existent mesh."); +// act->updateRenderMode(rm); +// if (textact != NULL) +// setBestTextureModePerMesh(textact,it.key(),rm); +// +//// deallocateReqAttsConsideringAllOtherGLArea(GLA(),it.key(),old,rm;) +// +// GLA()->setupRequestedAttributesPerMesh(it.key()); +// } +// else throw MeshLabException("A RenderModeAction referred to a non-existent mesh."); +// +// GLA()->setupRequestedAttributesPerMesh(it.key()); +// } +// } +// else +// { +// QMap::iterator it = rmode.find(meshid); +// RenderMode& rm = it.value(); +// RenderMode old = rm; +// if (it == rmode.end()) +// throw MeshLabException("A RenderModeAction contains a non-valid data meshid."); +// MeshModel* mmod = meshDoc()->getMesh(it.key()); +// if (mmod == NULL) +// throw MeshLabException("A RenderModeAction referred to a non-existent mesh."); +// act->updateRenderMode(rm); +// updateMenus(); +// //horrible trick caused by MeshLab GUI. In MeshLab exists just a button turning on/off the texture visualization. +// //Unfortunately the RenderMode::textureMode member field is not just a boolean value but and enum one. +// //The enum-value depends from the enabled attributes of input mesh. +// if (textact != NULL) +///*setBestTextureModePerMesh(textact,meshid,rm)*/; +// +//// deallocateReqAttsConsideringAllOtherGLArea(GLA(),it.key(),old,rm); +// GLA()->setupRequestedAttributesPerMesh(it.key()); +// } +// GLA()->update(); +//} - //if ((GLA() == NULL) || (meshDoc() == NULL)) - // return; +//WARNING!!!!!! I suppose it should not be useful anymore, but.... +//void MainWindow::setBestTextureModePerMesh(RenderModeAction* textact,const int meshid, RenderMode& rm) +//{ +// MeshModel* mesh = NULL; +// if ((meshDoc() == NULL) || ((mesh = meshDoc()->getMesh(meshid)) == NULL)) +// { +// bool clicked = (textact != NULL) && (textact->isChecked()); +// MLBridgeStandAloneFunctions::computeRequestedRenderingAttributesCompatibleWithMesh(mesh,rm.pmmask,rm.atts,rm.pmmask,rm.atts); +// rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTTEXTURE] = rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTTEXTURE] && clicked; +// rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_WEDGETEXTURE] = rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_WEDGETEXTURE] && clicked; +// } +//} - //RenderModeAction* act = qobject_cast(sender()); - //RenderModeTexturePerWedgeAction* textact = qobject_cast(act); - - // - ////act->data contains the meshid to which the action is referred. - ////if the meshid is -1 the action is intended to be per-document and not per mesh - //bool isvalidid = true; - //int meshid = act->data().toInt(&isvalidid); - //if (!isvalidid) - // throw MeshLabException("A RenderModeAction contains a non-integer data id."); - - //if (meshid == -1) - //{ - // foreach(MeshModel* mp,meshDoc()->meshList) - // { - // - // RenderMode& rm = it.value(); - // RenderMode old = rm; - - // //horrible trick caused by MeshLab GUI. In MeshLab exists just a button turning on/off the texture visualization. - // //Unfortunately the RenderMode::textureMode member field is not just a boolean value but and enum one. - // //The enum-value depends from the enabled attributes of input mesh. - // if (textact != NULL) - // setBestTextureModePerMesh(textact,it.key(),rm); - - // MeshModel* mmod = meshDoc()->getMesh(it.key()); - // if (mmod != NULL) - // { - // throw MeshLabException("A RenderModeAction referred to a non-existent mesh."); - // act->updateRenderMode(rm); - // if (textact != NULL) - // setBestTextureModePerMesh(textact,it.key(),rm); - - // deallocateReqAttsConsideringAllOtherGLArea(GLA(),it.key(),old,rm); - - // GLA()->setupRequestedAttributesPerMesh(it.key()); - // } - // else throw MeshLabException("A RenderModeAction referred to a non-existent mesh."); - - // GLA()->setupRequestedAttributesPerMesh(it.key()); - // } - //} - //else - //{ - // QMap::iterator it = rmode.find(meshid); - // RenderMode& rm = it.value(); - // RenderMode old = rm; - // if (it == rmode.end()) - // throw MeshLabException("A RenderModeAction contains a non-valid data meshid."); - // MeshModel* mmod = meshDoc()->getMesh(it.key()); - // if (mmod == NULL) - // throw MeshLabException("A RenderModeAction referred to a non-existent mesh."); - // act->updateRenderMode(rm); - // updateMenus(); - // //horrible trick caused by MeshLab GUI. In MeshLab exists just a button turning on/off the texture visualization. - // //Unfortunately the RenderMode::textureMode member field is not just a boolean value but and enum one. - // //The enum-value depends from the enabled attributes of input mesh. - // if (textact != NULL) - // setBestTextureModePerMesh(textact,meshid,rm); - - // deallocateReqAttsConsideringAllOtherGLArea(GLA(),it.key(),old,rm); - // GLA()->setupRequestedAttributesPerMesh(it.key()); - //} - //GLA()->update(); -} - - -void MainWindow::updateRenderMode( ) -{ - if ((GLA() == NULL) || (meshDoc() == NULL)) - return; - QMap& rmode = GLA()->rendermodemap; - - RenderModeAction* act = qobject_cast(sender()); - RenderModeTexturePerWedgeAction* textact = qobject_cast(act); - - //act->data contains the meshid to which the action is referred. - //if the meshid is -1 the action is intended to be per-document and not per mesh - bool isvalidid = true; - int meshid = act->data().toInt(&isvalidid); - if (!isvalidid) - throw MeshLabException("A RenderModeAction contains a non-integer data id."); - - if (meshid == -1) - { - for(QMap::iterator it = rmode.begin();it != rmode.end();++it) - { - RenderMode& rm = it.value(); - RenderMode old = rm; - - act->updateRenderMode(rm); - //horrible trick caused by MeshLab GUI. In MeshLab exists just a button turning on/off the texture visualization. - //Unfortunately the RenderMode::textureMode member field is not just a boolean value but and enum one. - //The enum-value depends from the enabled attributes of input mesh. - if (textact != NULL) - setBestTextureModePerMesh(textact,it.key(),rm); - - MeshModel* mmod = meshDoc()->getMesh(it.key()); - if (mmod != NULL) - { - throw MeshLabException("A RenderModeAction referred to a non-existent mesh."); - act->updateRenderMode(rm); - if (textact != NULL) - setBestTextureModePerMesh(textact,it.key(),rm); - -// deallocateReqAttsConsideringAllOtherGLArea(GLA(),it.key(),old,rm;) - - GLA()->setupRequestedAttributesPerMesh(it.key()); - } - else throw MeshLabException("A RenderModeAction referred to a non-existent mesh."); - - GLA()->setupRequestedAttributesPerMesh(it.key()); - } - } - else - { - QMap::iterator it = rmode.find(meshid); - RenderMode& rm = it.value(); - RenderMode old = rm; - if (it == rmode.end()) - throw MeshLabException("A RenderModeAction contains a non-valid data meshid."); - MeshModel* mmod = meshDoc()->getMesh(it.key()); - if (mmod == NULL) - throw MeshLabException("A RenderModeAction referred to a non-existent mesh."); - act->updateRenderMode(rm); - updateMenus(); - //horrible trick caused by MeshLab GUI. In MeshLab exists just a button turning on/off the texture visualization. - //Unfortunately the RenderMode::textureMode member field is not just a boolean value but and enum one. - //The enum-value depends from the enabled attributes of input mesh. - if (textact != NULL) - setBestTextureModePerMesh(textact,meshid,rm); - -// deallocateReqAttsConsideringAllOtherGLArea(GLA(),it.key(),old,rm); - GLA()->setupRequestedAttributesPerMesh(it.key()); - } - GLA()->update(); -} - -void MainWindow::connectRenderModeActionList(QList& actlist) -{ - for (int ii = 0; ii < actlist.size();++ii) - connect(actlist[ii],SIGNAL(triggered()),this,SLOT(updateRenderMode())); -} - -void MainWindow::setBestTextureModePerMesh(RenderModeAction* textact,const int meshid, RenderMode& rm) -{ - MeshModel* mesh = NULL; - if ((meshDoc() == NULL) || ((mesh = meshDoc()->getMesh(meshid)) == NULL)) - { - bool clicked = (textact != NULL) && (textact->isChecked()); - MLBridgeStandAloneFunctions::computeRequestedRenderingAttributesCompatibleWithMesh(mesh,rm.pmmask,rm.atts,rm.pmmask,rm.atts); - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTTEXTURE] = rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTTEXTURE] && clicked; - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_WEDGETEXTURE] = rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_WEDGETEXTURE] && clicked; - } -} - -void MainWindow::getCurrentRenderingData(MLRenderingData& rdata) const -{ - -} void MainWindow::meshAdded(int mid) { @@ -3243,8 +3167,7 @@ void MainWindow::meshAdded(int mid) shared->setRequestedAttributesPerMeshViews(mid,contlist,defdt); } } - if (layerDialog != NULL) - updateLayerDialog(); + updateLayerDialog(); } void MainWindow::meshRemoved(int mid) @@ -3256,12 +3179,22 @@ void MainWindow::meshRemoved(int mid) if (shared != NULL) shared->meshRemoved(mid); } - if (layerDialog != NULL) - updateLayerDialog(); + updateLayerDialog(); } -void MainWindow::primitiveModalityUpdateRequested( unsigned int mmid,vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK pmmask ) +void MainWindow::getRenderingData( int mid,MLRenderingData& dt) const +{ + MultiViewer_Container* cont = currentViewContainer(); + if (cont != NULL) + { + MLSceneGLSharedDataContext* share = cont->sharedDataContext(); + if ((share != NULL) && (GLA() != NULL)) + share->getRenderInfoPerMeshView(mid,GLA()->context(),dt); + } +} + +void MainWindow::setRenderingData(int mid,const MLRenderingData& dt) { MultiViewer_Container* cont = currentViewContainer(); if (cont != NULL) @@ -3269,13 +3202,32 @@ void MainWindow::primitiveModalityUpdateRequested( unsigned int mmid,vcg::GLMesh MLSceneGLSharedDataContext* share = cont->sharedDataContext(); if ((share != NULL) && (GLA() != NULL)) { - MLRenderingData dt; - share->getRenderInfoPerMeshView(mmid,GLA()->context(),dt); - dt._mask = pmmask; - share->setRequestedAttributesPerMeshView(mmid,GLA()->context(),dt); - share->manageBuffers(mmid); - GLA()->update(); + share->setRequestedAttributesPerMeshView(mid,GLA()->context(),dt); + share->manageBuffers(mid); + addRenderingSystemLogInfo(mid); } } - -} \ No newline at end of file +} + + +void MainWindow::addRenderingSystemLogInfo(unsigned mmid) +{ + MultiViewer_Container* cont = currentViewContainer(); + if (cont != NULL) + { + vcg::GLMeshAttributesInfo::DebugInfo deb; + MLSceneGLSharedDataContext* share = cont->sharedDataContext(); + if ((share != NULL) && (GLA() != NULL)) + { + share->getLog(mmid,deb); + MeshModel* mm = meshDoc()->getMesh(mmid); + if (mm != NULL) + { + QString data = QString(deb._currentlyallocated.c_str()) + "

" + QString(deb._tobedeallocated.c_str()) + "
" + QString(deb._tobeallocated.c_str()) + "
" + QString(deb._tobeupdated.c_str()) + "

"; + for(std::vector::iterator it = deb._perviewdata.begin();it != deb._perviewdata.end();++it) + data += QString((*it).c_str()) + "
"; + meshDoc()->Log.RealTimeLogText.insert("Rendering System Debug Info",qMakePair(mm->shortName(),data)); + } + } + } +} diff --git a/src/meshlab/meshlab.pro b/src/meshlab/meshlab.pro index ad35ac914..54b6b8173 100644 --- a/src/meshlab/meshlab.pro +++ b/src/meshlab/meshlab.pro @@ -31,8 +31,8 @@ HEADERS = ../common/interfaces.h \ additionalgui.h \ xmlgeneratorgui.h \ snapshotsetting.h \ - rendermodeactions.h \ ml_render_gui.h \ + ml_rendering_actions.h \ $$VCGDIR/wrap/gui/trackball.h \ $$VCGDIR/wrap/gui/trackmode.h \ $$VCGDIR/wrap/gl/trimesh.h \ @@ -53,8 +53,8 @@ SOURCES = main.cpp \ xmlstdpardialog.cpp \ additionalgui.cpp \ xmlgeneratorgui.cpp \ - rendermodeactions.cpp \ ml_render_gui.cpp \ + ml_rendering_actions.cpp \ $$VCGDIR/wrap/gui/trackball.cpp \ $$VCGDIR/wrap/gui/trackmode.cpp \ #$$GLEWDIR/src/glew.c \ diff --git a/src/meshlab/ml_render_gui.cpp b/src/meshlab/ml_render_gui.cpp index 473c4fb2e..594ea6e78 100644 --- a/src/meshlab/ml_render_gui.cpp +++ b/src/meshlab/ml_render_gui.cpp @@ -1,90 +1,323 @@ #include "ml_render_gui.h" #include +#include +#include +#include -MLRenderToolbar::MLRenderToolbar(vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK defaultrend,QWidget* parent ) - :QToolBar(parent),_meshid(-1),_mask(defaultrend) +MLRenderingToolbar::MLRenderingToolbar(bool exclusive,QWidget* parent ) + :QToolBar(parent),_meshid(-1),_exclusive(exclusive),_previoussel(NULL) +{ + connect(this,SIGNAL(actionTriggered(QAction*)),this,SLOT(toggle(QAction*))); +} + +MLRenderingToolbar::MLRenderingToolbar(int meshid,bool exclusive,QWidget* parent ) + :QToolBar(parent),_meshid(meshid),_exclusive(exclusive),_previoussel(NULL) +{ + connect(this,SIGNAL(actionTriggered(QAction*)),this,SLOT(toggle(QAction*))); +} + +MLRenderingToolbar::~MLRenderingToolbar() +{ +} + +void MLRenderingToolbar::addRenderingAction( MLRenderingAction* act ) +{ + _acts.push_back(act); + addAction(act); + act->setCheckable(true); + act->setVisible(true); +} + +void MLRenderingToolbar::toggle( QAction* act) +{ + MLRenderingAction* ract = qobject_cast(act); + if ((_exclusive) && (ract != NULL)) + { + foreach(MLRenderingAction* curact,_acts) + { + if (curact != NULL) + { + if (curact != ract) + curact->setChecked(false); + else + { + if (ract == _previoussel) + { + ract->setChecked(false); + _previoussel = NULL; + } + else + { + ract->setChecked(true); + _previoussel = ract; + } + } + } + } + } + if (ract != NULL) + emit updateRenderingDataAccordingToActions(_meshid,_acts); +} + +void MLRenderingToolbar::setAccordingToRenderingData(const MLRenderingData& dt) +{ + foreach(MLRenderingAction* rendact,_acts) + { + rendact->setChecked(rendact->isRenderingDataEnabled(dt)); + if ((_exclusive) && (rendact->isChecked())) + _previoussel = rendact; + + } +} + +void MLRenderingToolbar::getRenderingActionsCopy(QList& acts,QObject* newparent) const +{ + foreach(MLRenderingAction* act,_acts) + acts.push_back(act->copyAction(act,newparent)); +} + +void MLRenderingToolbar::setAssociatedMeshId( int meshid ) +{ + _meshid = meshid; + foreach(MLRenderingAction* act,_acts) + act->setMeshId(_meshid); +} + +QList& MLRenderingToolbar::getRenderingActions() +{ + return _acts; +} + + + +MLRenderingSolidParametersFrame::MLRenderingSolidParametersFrame(QWidget* parent ) + :MLRenderingParametersFrame(-1,parent) { initGui(); } -MLRenderToolbar::MLRenderToolbar( unsigned int meshid,vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK defaultrend,QWidget* parent ) - :QToolBar(parent),_meshid(meshid),_mask(defaultrend) +MLRenderingSolidParametersFrame::MLRenderingSolidParametersFrame( int meshid,QWidget* parent ) + :MLRenderingParametersFrame(meshid,parent) { initGui(); } -MLRenderToolbar::~MLRenderToolbar() -{ - //qDebug("Distruggo"); +void MLRenderingSolidParametersFrame::initGui() +{ + setAutoFillBackground(true); + QGridLayout* layout = new QGridLayout(); + _shadingtool = new MLRenderingToolbar(_meshid,true,this); + QLabel* shadelab = new QLabel("Shading",this); + QFont boldfont; + boldfont.setBold(true); + shadelab->setFont(boldfont); + layout->addWidget(shadelab,0,0,Qt::AlignLeft); + _shadingtool->addRenderingAction(new MLRenderingSmoothAction(_meshid,this)); + _shadingtool->addRenderingAction(new MLRenderingFlatAction(_meshid,this)); + layout->addWidget(_shadingtool,0,1,Qt::AlignLeft); + connect(_shadingtool,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&)),this,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&))); + + QLabel* colorlab = new QLabel("Color",this); + colorlab->setFont(boldfont); + layout->addWidget(colorlab,1,0,Qt::AlignLeft); + _colortool = new MLRenderingToolbar(_meshid,true,this); + _colortool->addRenderingAction(new MLRenderingPerVertexColorAction(_meshid,this)); + _colortool->addRenderingAction(new MLRenderingPerFaceColorAction(_meshid,this)); + _colortool->addRenderingAction(new MLRenderingPerMeshColorAction(_meshid,this)); + _colortool->addRenderingAction(new MLRenderingUserDefinedColorAction(vcg::GLMeshAttributesInfo::PR_SOLID,_meshid,this)); + layout->addWidget(_colortool,1,1,Qt::AlignLeft); + connect(_colortool,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&)),this,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&))); + + QLabel* textlab = new QLabel("Texture Coord",this); + textlab->setFont(boldfont); + layout->addWidget(textlab,2,0,Qt::AlignLeft); + _texttool = new MLRenderingToolbar(this); + _texttool->addRenderingAction(new MLRenderingPerVertTextCoordAction(_meshid,this)); + _texttool->addRenderingAction(new MLRenderingPerWedgeTextCoordAction(_meshid,this)); + layout->addWidget(_texttool,2,1,Qt::AlignLeft); + connect(_texttool,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&)),this,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&))); + setMinimumSize(layout->sizeHint()); + setLayout(layout); + showNormal(); + adjustSize(); } -void MLRenderToolbar::toggleBBox() +void MLRenderingSolidParametersFrame::setPrimitiveButtonStatesAccordingToRenderingData( const MLRenderingData& dt ) { - toggle(_bboxact,(unsigned int) vcg::GLMeshAttributesInfo::PR_BBOX); + _shadingtool->setAccordingToRenderingData(dt); + _colortool->setAccordingToRenderingData(dt); + _texttool->setAccordingToRenderingData(dt); } -void MLRenderToolbar::togglePoints() +void MLRenderingSolidParametersFrame::setAssociatedMeshId( int meshid ) { - toggle(_pointsact,(unsigned int) vcg::GLMeshAttributesInfo::PR_POINTS); + _meshid = meshid; + _shadingtool->setAssociatedMeshId(meshid); + _colortool->setAssociatedMeshId(meshid); + _texttool->setAssociatedMeshId(meshid); } -void MLRenderToolbar::toggleEdges() +MLRenderingSolidParametersFrame::~MLRenderingSolidParametersFrame() { - toggle(_edgeact,(unsigned int)(/*vcg::GLMeshAttributesInfo::PR_WIREFRAME_EDGES | */vcg::GLMeshAttributesInfo::PR_WIREFRAME_TRIANGLES)); + delete _shadingtool; + delete _colortool; + delete _texttool; } -void MLRenderToolbar::toggleSolid() +void MLRenderingSolidParametersFrame::getAllRenderingActions( QList& acts ) { - toggle(_solidact,(unsigned int) vcg::GLMeshAttributesInfo::PR_SOLID); + acts.append(_shadingtool->getRenderingActions()); + acts.append(_colortool->getRenderingActions()); + acts.append(_texttool->getRenderingActions()); } -void MLRenderToolbar::initGui() +//MLRenderingParametersFrame::~MLRenderingParametersFrame() +//{ +// +//} +// +//MLRenderingParametersFrame::MLRenderingParametersFrame( int meshid,const MLRenderingData& data,QWidget* parent ) +// :QFrame(parent),_meshid(meshid) +//{ +// initGui(data); +//} +// +//void MLRenderingParametersFrame::initGui( const MLRenderingData& dt ) +//{ +// setAutoFillBackground(true); +// QVBoxLayout* layout = new QVBoxLayout(); +// _paramgrouptree = new QTreeWidget(this); +// _paramgrouptree->setAutoFillBackground(true); +// _paramgrouptree->setFrameStyle(QFrame::NoFrame); +// _paramgrouptree->setContentsMargins(0,0,0,0); +// layout->addWidget(_paramgrouptree); +// _paramgrouptree->header()->hide(); +// QTreeWidgetItem* soliditm = new QTreeWidgetItem(); +// soliditm->setText(0,tr("solid_params")); +// _paramgrouptree->addTopLevelItem(soliditm); +// QTreeWidgetItem* widgitm = new QTreeWidgetItem(); +// soliditm->addChild(widgitm); +// _solid = new MLRenderingSolidParametersFrame(_meshid,dt,this); +// _paramgrouptree->setItemWidget(widgitm,0,_solid); +// //QPushButton* cb =new QPushButton("PUPPA",this); +// _paramgrouptree->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::MinimumExpanding); +// setContentsMargins(0,0,0,0); +// setLayout(layout); +// +//} + + + + +MLRenderingSideToolbar::MLRenderingSideToolbar(QWidget* parent /*= NULL*/ ) + :MLRenderingToolbar(false,parent) { - _bboxact = addAction(QIcon(":/images/bbox.png"),QString("Bounding Box"),this,SLOT(toggleBBox())); - _bboxact->setCheckable(true); - _pointsact = addAction(QIcon(":/images/points.png"),QString("Points"),this,SLOT(togglePoints())); - _pointsact->setCheckable(true); - _edgeact = addAction(QIcon(":/images/wire.png"),QString("Edges"),this,SLOT(toggleEdges())); - _edgeact->setCheckable(true); - _solidact = addAction(QIcon(":/images/smooth.png"),QString("Solid"),this,SLOT(toggleSolid())); - _solidact->setCheckable(true); - checkPrimitiveButtonsAccordingToMask(); + initGui(); } -void MLRenderToolbar::toggle( QAction* act,const vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK relatedprimit) +MLRenderingSideToolbar::MLRenderingSideToolbar(int meshid,QWidget* parent /*= NULL*/ ) + :MLRenderingToolbar(meshid,false,parent) { - bool actcheck = act->isChecked(); - if (actcheck) - _mask = _mask | relatedprimit; - else - _mask = _mask & ~(relatedprimit); - - if (_meshid != -1) - emit primitiveModalityUpdateRequested(_meshid,_mask); - /*else - emit primitiveModalityUpdateRequested(_mask);*/ + initGui(); } -void MLRenderToolbar::setPrimitiveModality( vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK mask ) +void MLRenderingSideToolbar::initGui() { - _mask = mask; - checkPrimitiveButtonsAccordingToMask(); + addRenderingAction(new MLRenderingBBoxAction(_meshid,this)); + addRenderingAction(new MLRenderingPointsAction(_meshid,this)); + addRenderingAction(new MLRenderingWireAction(_meshid,this)); + addRenderingAction(new MLRenderingSolidAction(_meshid,this)); + addRenderingAction(new MLRenderingLightOnOffAction(_meshid,this)); + } -void MLRenderToolbar::checkPrimitiveButtonsAccordingToMask() -{ - bool m(_mask & vcg::GLMeshAttributesInfo::PR_BBOX); - bool c(_mask & vcg::GLMeshAttributesInfo::PR_POINTS); - bool d(_mask & vcg::GLMeshAttributesInfo::PR_WIREFRAME_TRIANGLES); - bool e(_mask & vcg::GLMeshAttributesInfo::PR_SOLID); - _bboxact->setChecked(bool(_mask & vcg::GLMeshAttributesInfo::PR_BBOX)); - _pointsact->setChecked(bool(_mask & vcg::GLMeshAttributesInfo::PR_POINTS)); - _edgeact->setChecked(bool(_mask & (/*vcg::GLMeshAttributesInfo::PR_WIREFRAME_EDGES | */vcg::GLMeshAttributesInfo::PR_WIREFRAME_TRIANGLES))); - _solidact->setChecked(bool(_mask & vcg::GLMeshAttributesInfo::PR_SOLID)); -} - -MLRenderParametersFrame::MLRenderParametersFrame(QWidget* parent) - :QFrame(parent) +MLRenderingParametersFrame::MLRenderingParametersFrame( int meshid,QWidget* parent ) + :QFrame(parent),_meshid(-1) { } + +MLRenderingParametersFrame::~MLRenderingParametersFrame() +{ + +} + +MLRenderingParametersFrame* MLRenderingParametersFrame::factory( MLRenderingAction* act,int meshid,QWidget* parent) +{ + if (qobject_cast(act) != NULL) + return new MLRenderingSolidParametersFrame(meshid,parent); + + /*if (qobject_cast(act) != NULL) + return new MLRenderingPointsParametersFrame(meshid,parent); + + if (qobject_cast(act) != NULL) + return new MLRenderingWireParametersFrame(meshid,parent); + + if (qobject_cast(act) != NULL) + return new MLRenderingLightingParametersFrame(meshid,parent);*/ + + /*if (qobject_cast(act) != NULL) + return new MLRenderingSolidParametersFrame(meshid,parent);*/ + + return NULL; +} + +MLRenderingParametersTab::MLRenderingParametersTab( int meshid,const QList& tab, QWidget* parent ) + :QTabWidget(parent),_meshid(meshid) +{ + initGui(tab); +} + +void MLRenderingParametersTab::setAssociatedMeshId( int meshid ) +{ + _meshid = meshid; + for(QMap::iterator itt = _parframe.begin();itt != _parframe.end();++itt) + (*itt)->setAssociatedMeshId(meshid); +} + + +void MLRenderingParametersTab::switchTab( const QString& name ) +{ + QMap::iterator itt = _parframe.find(name); + if (itt != _parframe.end()) + setCurrentWidget((*itt)); +} + +void MLRenderingParametersTab::setPrimitiveButtonStatesAccordingToRenderingData(const MLRenderingData& dt ) +{ + for(QMap::iterator itt = _parframe.begin();itt != _parframe.end();++itt) + (*itt)->setPrimitiveButtonStatesAccordingToRenderingData(dt); +} + +void MLRenderingParametersTab::initGui(const QList& tab) +{ + foreach(MLRenderingAction* ract,tab) + { + if (ract != NULL) + { + MLRenderingParametersFrame* fr = MLRenderingParametersFrame::factory(ract,_meshid,this); + if (fr != NULL) + { + _parframe[ract->text()] = fr; + addTab(fr,ract->icon(),""); + connect(fr,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&)),this,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&))); + } + } + } +} + +MLRenderingParametersTab::~MLRenderingParametersTab() +{ + for(QMap::iterator it = _parframe.begin();it != _parframe.end();++it) + delete it.value(); +} + +void MLRenderingParametersTab::setAssociatedMeshIdAndRenderingData( int meshid,const MLRenderingData& dt ) +{ + for(QMap::iterator itt = _parframe.begin();itt != _parframe.end();++itt) + { + (*itt)->setAssociatedMeshId(meshid); + (*itt)->setPrimitiveButtonStatesAccordingToRenderingData(dt); + } +} + diff --git a/src/meshlab/ml_render_gui.h b/src/meshlab/ml_render_gui.h index fe42b3d4b..631418baf 100644 --- a/src/meshlab/ml_render_gui.h +++ b/src/meshlab/ml_render_gui.h @@ -28,46 +28,168 @@ #include #include #include +#include "ml_rendering_actions.h" #include "additionalgui.h" -class MLRenderToolbar : public QToolBar + +class MLRenderingToolbar : public QToolBar { Q_OBJECT public: - MLRenderToolbar(vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK defaultrend,QWidget* parent = NULL); - MLRenderToolbar(unsigned int meshid,vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK defaultrend,QWidget* parent = NULL); + MLRenderingToolbar(bool exclusive,QWidget* parent = NULL); + MLRenderingToolbar(int meshid,bool exclusive,QWidget* parent = NULL); + + ~MLRenderingToolbar(); + + void addRenderingAction( MLRenderingAction* act ); + void setAccordingToRenderingData(const MLRenderingData& dt); + QList& getRenderingActions(); + void getRenderingActionsCopy(QList& acts,QObject* newparent = 0) const; + void setAssociatedMeshId(int meshid); + +protected: + QList _acts; + int _meshid; + MLRenderingAction* _previoussel; - ~MLRenderToolbar(); -public slots: - void setPrimitiveModality(vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK mask); private slots: - void toggleBBox(); - void togglePoints(); - void toggleEdges(); - void toggleSolid(); -signals: - void primitiveModalityUpdateRequested(unsigned int,vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK); - //void primitiveModalityUpdateRequested(vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK); -private: - QAction* _bboxact; - QAction* _pointsact; - QAction* _edgeact; - QAction* _solidact; - + void toggle(QAction* act); - void initGui(); - void toggle(QAction* but,const vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK relatedprimit); - void checkPrimitiveButtonsAccordingToMask(); + +signals: + void updateRenderingDataAccordingToActions(int,const QList& acts); + +private: //if meshid is -1 it means that the actions are intended to be deployed to all the document and not to a specific mesh model - unsigned int _meshid; - vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY_MASK _mask; + bool _exclusive; }; -class MLRenderParametersFrame : public QFrame +class MLRenderingSideToolbar: public MLRenderingToolbar +{ + + Q_OBJECT +public: + MLRenderingSideToolbar(QWidget* parent = NULL); + MLRenderingSideToolbar(int meshid,QWidget* parent = NULL); + + ~MLRenderingSideToolbar() {} +private: + void initGui(); +}; + +class MLRenderingParametersFrame : public QFrame { Q_OBJECT public: - MLRenderParametersFrame(QWidget* parent = NULL); + MLRenderingParametersFrame(int meshid,QWidget* parent); + virtual ~MLRenderingParametersFrame(); + virtual void setPrimitiveButtonStatesAccordingToRenderingData(const MLRenderingData& dt) = 0; + virtual void setAssociatedMeshId(int meshid) = 0; + virtual void getAllRenderingActions(QList& acts) = 0; + static MLRenderingParametersFrame* factory(MLRenderingAction* act,int meshid,QWidget* parent); + static void destroy(MLRenderingParametersFrame* pf); + +protected: + int _meshid; + +signals: + void updateRenderingDataAccordingToActions(int,const QList&); }; +class MLRenderingSolidParametersFrame : public MLRenderingParametersFrame +{ + Q_OBJECT +public: + MLRenderingSolidParametersFrame(QWidget* parent); + MLRenderingSolidParametersFrame(int meshid,QWidget* parent); + ~MLRenderingSolidParametersFrame(); + void setPrimitiveButtonStatesAccordingToRenderingData(const MLRenderingData& dt); + void setAssociatedMeshId(int meshid); + void getAllRenderingActions(QList& acts); + +private: + void initGui(); + MLRenderingToolbar* _shadingtool; + MLRenderingToolbar* _colortool; + MLRenderingToolbar* _texttool; +}; + +//class MLRenderingSolidParametersFrame : public MLRenderingParametersFrame +//{ +// Q_OBJECT +//public: +// MLRenderingSolidParametersFrame(QWidget* parent); +// MLRenderingSolidParametersFrame(int meshid,QWidget* parent); +// ~MLRenderingSolidParametersFrame(); +// void setPrimitiveButtonStatesAccordingToRenderingData(const MLRenderingData& dt); +// void setAssociatedMeshId(int meshid); +// +//private: +// void initGui(); +// MLRenderingToolbar* _shadingtool; +// MLRenderingToolbar* _colortool; +// MLRenderingToolbar* _texttool; +//}; +// +// +//class MLRenderingSolidParametersFrame : public MLRenderingParametersFrame +//{ +// Q_OBJECT +//public: +// MLRenderingSolidParametersFrame(QWidget* parent); +// MLRenderingSolidParametersFrame(int meshid,QWidget* parent); +// ~MLRenderingSolidParametersFrame(); +// void setPrimitiveButtonStatesAccordingToRenderingData(const MLRenderingData& dt); +// void setAssociatedMeshId(int meshid); +// +//private: +// void initGui(); +// MLRenderingToolbar* _shadingtool; +// MLRenderingToolbar* _colortool; +// MLRenderingToolbar* _texttool; +//}; +// +// +//class MLRenderingSolidParametersFrame : public MLRenderingParametersFrame +//{ +// Q_OBJECT +//public: +// MLRenderingSolidParametersFrame(QWidget* parent); +// MLRenderingSolidParametersFrame(int meshid,QWidget* parent); +// ~MLRenderingSolidParametersFrame(); +// void setPrimitiveButtonStatesAccordingToRenderingData(const MLRenderingData& dt); +// void setAssociatedMeshId(int meshid); +// +//private: +// void initGui(); +// MLRenderingToolbar* _shadingtool; +// MLRenderingToolbar* _colortool; +// MLRenderingToolbar* _texttool; +//}; + + +class MLRenderingParametersTab : public QTabWidget +{ + Q_OBJECT +public: + MLRenderingParametersTab(int meshid,const QList& tab, QWidget* parent); + ~MLRenderingParametersTab(); + + void setPrimitiveButtonStatesAccordingToRenderingData(const MLRenderingData& dt); + void setAssociatedMeshIdAndRenderingData(int meshid,const MLRenderingData& dt); +private: + void initGui(const QList& tab); + + int _meshid; +public slots: + void switchTab(const QString& name); + void setAssociatedMeshId(int meshid); + +signals: + void updateRenderingDataAccordingToActions(int,const QList&); +private: + QMap _parframe; +}; + + #endif \ No newline at end of file diff --git a/src/meshlab/ml_rendering_actions.cpp b/src/meshlab/ml_rendering_actions.cpp new file mode 100644 index 000000000..20231c620 --- /dev/null +++ b/src/meshlab/ml_rendering_actions.cpp @@ -0,0 +1,638 @@ +#include "ml_rendering_actions.h" +#include +#include + +MLRenderingAction::MLRenderingAction( QObject* parent ) + :QAction(parent) +{ + setCheckable(true); + setChecked(false); + setMeshId(-1); +} + +MLRenderingAction::MLRenderingAction(int meshid,QObject* parent ) + :QAction(parent) +{ + setCheckable(true); + setChecked(false); + setMeshId(meshid); +} + +int MLRenderingAction::meshId() const +{ + bool isvalidid = false; + return data().toInt(&isvalidid); +} + + +void MLRenderingAction::setMeshId(int meshid) +{ + setData(QVariant(meshid)); +} + +MLRenderingAction* MLRenderingAction::copyAction( const MLRenderingAction* tocopy,QObject* newactionparent ) +{ + MLRenderingAction* res = tocopy->copyCtr(tocopy,newactionparent); + res->setMeshId(tocopy->meshId()); + res->setChecked(tocopy->isChecked()); + return res; +} + +MLRenderingBBoxAction::MLRenderingBBoxAction( QObject* parent) + :MLRenderingAction(parent) +{ + setIcon(QIcon(":/images/bbox.png")); + setText(QString("Bounding Box")); +} + +MLRenderingBBoxAction::MLRenderingBBoxAction( int meshid,QObject* parent) + :MLRenderingAction(meshid,parent) +{ + setIcon(QIcon(":/images/bbox.png")); + setText(QString("Bounding Box")); +} + +void MLRenderingBBoxAction::updateRenderingData(MLRenderingData& rd) +{ + if (isChecked()) + rd._mask = vcg::GLMeshAttributesInfo::addPrimitiveModality(rd._mask,vcg::GLMeshAttributesInfo::PR_BBOX); + else + rd._mask = vcg::GLMeshAttributesInfo::removePrimitiveModality(rd._mask,vcg::GLMeshAttributesInfo::PR_BBOX); +} + +bool MLRenderingBBoxAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return (bool)(rd._mask & vcg::GLMeshAttributesInfo::PR_BBOX); +} + +MLRenderingAction* MLRenderingBBoxAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingBBoxAction(newactionparent); +} + +MLRenderingPointsAction::MLRenderingPointsAction( QObject* parent) + :MLRenderingAction(parent) +{ + setIcon(QIcon(":/images/points.png")); + setText(QString("Points")); +} + +MLRenderingPointsAction::MLRenderingPointsAction( int meshid,QObject* parent) + :MLRenderingAction(meshid, parent) +{ + setIcon(QIcon(":/images/points.png")); + setText(QString("Points")); +} + +void MLRenderingPointsAction::updateRenderingData(MLRenderingData& rd ) +{ + if (isChecked()) + rd._mask = vcg::GLMeshAttributesInfo::addPrimitiveModality(rd._mask,vcg::GLMeshAttributesInfo::PR_POINTS); + else + rd._mask = vcg::GLMeshAttributesInfo::removePrimitiveModality(rd._mask,vcg::GLMeshAttributesInfo::PR_POINTS); +} + +bool MLRenderingPointsAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return (bool)(rd._mask & vcg::GLMeshAttributesInfo::PR_POINTS); +} + +MLRenderingAction* MLRenderingPointsAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingPointsAction(newactionparent); +} + +MLRenderingWireAction::MLRenderingWireAction( QObject* parent) + :MLRenderingAction(parent) +{ + setIcon(QIcon(":/images/wire.png")); + setText(QString("Wireframe")); +} + +MLRenderingWireAction::MLRenderingWireAction( int meshid,QObject* parent) + :MLRenderingAction(meshid,parent) +{ + setIcon(QIcon(":/images/wire.png")); + setText(QString("Wireframe")); +} + +void MLRenderingWireAction::updateRenderingData(MLRenderingData& rd ) +{ + if (isChecked()) + rd._mask = vcg::GLMeshAttributesInfo::addPrimitiveModality(rd._mask,vcg::GLMeshAttributesInfo::PR_WIREFRAME_TRIANGLES); + else + rd._mask = vcg::GLMeshAttributesInfo::removePrimitiveModality(rd._mask,vcg::GLMeshAttributesInfo::PR_WIREFRAME_TRIANGLES); +} + +bool MLRenderingWireAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return (bool)(rd._mask & vcg::GLMeshAttributesInfo::PR_WIREFRAME_TRIANGLES); +} + +MLRenderingAction* MLRenderingWireAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingWireAction(newactionparent); +} + +MLRenderingSolidAction::MLRenderingSolidAction( QObject* parent ) + :MLRenderingAction(parent) +{ + setIcon(QIcon(":/images/smooth.png")); + setText(QString("Solid")); +} + +MLRenderingSolidAction::MLRenderingSolidAction( int meshid,QObject* parent ) + :MLRenderingAction(meshid,parent) +{ + setIcon(QIcon(":/images/smooth.png")); + setText(QString("Solid")); +} + +void MLRenderingSolidAction::updateRenderingData( MLRenderingData& rd ) +{ + if (isChecked()) + rd._mask = vcg::GLMeshAttributesInfo::addPrimitiveModality(rd._mask,vcg::GLMeshAttributesInfo::PR_SOLID); + else + rd._mask = vcg::GLMeshAttributesInfo::removePrimitiveModality(rd._mask,vcg::GLMeshAttributesInfo::PR_SOLID); +} + +bool MLRenderingSolidAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return (bool)(rd._mask & vcg::GLMeshAttributesInfo::PR_SOLID); +} + +MLRenderingAction* MLRenderingSolidAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingSolidAction(newactionparent); +} + +MLRenderingEdgeWireAction::MLRenderingEdgeWireAction( QObject* parent ) + :MLRenderingAction(parent) +{ + setText(QString("Edges Wireframe")); +} + +MLRenderingEdgeWireAction::MLRenderingEdgeWireAction( int meshid,QObject* parent ) + :MLRenderingAction(meshid,parent) +{ + setText(QString("Edges Wireframe")); +} + +void MLRenderingEdgeWireAction::updateRenderingData( MLRenderingData& rd ) +{ + if (isChecked()) + rd._mask = vcg::GLMeshAttributesInfo::addPrimitiveModality(rd._mask,vcg::GLMeshAttributesInfo::PR_WIREFRAME_EDGES); + else + rd._mask = vcg::GLMeshAttributesInfo::removePrimitiveModality(rd._mask,vcg::GLMeshAttributesInfo::PR_WIREFRAME_EDGES); +} + +bool MLRenderingEdgeWireAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return (bool)(rd._mask & vcg::GLMeshAttributesInfo::PR_WIREFRAME_EDGES); +} + +MLRenderingAction* MLRenderingEdgeWireAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingEdgeWireAction(newactionparent); +} + +MLRenderingHiddenLinesAction::MLRenderingHiddenLinesAction( QObject* parent) + :MLRenderingAction(parent) +{ + setText(QString("Back Face Culling")); +} + +MLRenderingHiddenLinesAction::MLRenderingHiddenLinesAction( int meshid,QObject* parent) + :MLRenderingAction(meshid,parent) +{ + setText(QString("Back Face Culling")); +} + +void MLRenderingHiddenLinesAction::updateRenderingData(MLRenderingData& rd ) +{ + rd._opts._backfacecull = isChecked(); +} + +bool MLRenderingHiddenLinesAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return (rd._opts._backfacecull); +} + +MLRenderingAction* MLRenderingHiddenLinesAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingHiddenLinesAction(newactionparent); +} + +MLRenderingFlatAction::MLRenderingFlatAction( QObject* parent) + :MLRenderingAction(parent) +{ + setText(QString("Flat")); +} + +MLRenderingFlatAction::MLRenderingFlatAction( int meshid,QObject* parent) + :MLRenderingAction(meshid, parent) +{ + setText(QString("Flat")); +} + +void MLRenderingFlatAction::updateRenderingData(MLRenderingData& rd ) +{ + rd._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACENORMAL] = isChecked(); +} + +bool MLRenderingFlatAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return rd._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACENORMAL]; +} + +MLRenderingAction* MLRenderingFlatAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingFlatAction(newactionparent); +} + +MLRenderingSmoothAction::MLRenderingSmoothAction( QObject* parent) + :MLRenderingAction(parent) +{ + setText(QString("Smooth")); +} + +MLRenderingSmoothAction::MLRenderingSmoothAction( int meshid,QObject* parent) + :MLRenderingAction(meshid,parent) +{ + setText(QString("Smooth")); +} + +void MLRenderingSmoothAction::updateRenderingData(MLRenderingData& rd ) +{ + rd._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTNORMAL] = isChecked(); +} + +bool MLRenderingSmoothAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return rd._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTNORMAL]; +} + +MLRenderingAction* MLRenderingSmoothAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingSmoothAction(newactionparent); +} + +MLRenderingPerVertTextCoordAction::MLRenderingPerVertTextCoordAction( QObject* parent) + :MLRenderingAction(parent) +{ + setText(QString("Per-Vert")); +} + +MLRenderingPerVertTextCoordAction::MLRenderingPerVertTextCoordAction( int meshid,QObject* parent) + :MLRenderingAction(meshid,parent) +{ + setText(QString("Per-Vert")); +} + +void MLRenderingPerVertTextCoordAction::updateRenderingData(MLRenderingData& rd ) +{ + rd._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTTEXTURE] = isChecked(); +} + +bool MLRenderingPerVertTextCoordAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return rd._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTTEXTURE]; +} + +MLRenderingAction* MLRenderingPerVertTextCoordAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingPerVertTextCoordAction(newactionparent); +} + +MLRenderingPerWedgeTextCoordAction::MLRenderingPerWedgeTextCoordAction( QObject* parent) + :MLRenderingAction(parent) +{ + setText(QString("Per-Wedge")); +} + +MLRenderingPerWedgeTextCoordAction::MLRenderingPerWedgeTextCoordAction( int meshid,QObject* parent) + :MLRenderingAction(meshid,parent) +{ + setText(QString("Per-Wedge")); +} + +void MLRenderingPerWedgeTextCoordAction::updateRenderingData(MLRenderingData& rd ) +{ + rd._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_WEDGETEXTURE] = isChecked(); +} + +bool MLRenderingPerWedgeTextCoordAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return rd._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_WEDGETEXTURE]; +} + +MLRenderingAction* MLRenderingPerWedgeTextCoordAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingPerWedgeTextCoordAction(newactionparent); +} + +MLRenderingDoubleLightingAction::MLRenderingDoubleLightingAction( QObject* parent) + :MLRenderingAction(parent) +{ + setText(QString("Double side lighting")); +} + +MLRenderingDoubleLightingAction::MLRenderingDoubleLightingAction( int meshid,QObject* parent) + :MLRenderingAction(meshid,parent) +{ + setText(QString("Double side lighting")); +} + +void MLRenderingDoubleLightingAction::updateRenderingData(MLRenderingData& rd ) +{ + rd._opts._doublesidelighting = !rd._opts._doublesidelighting; +} + +bool MLRenderingDoubleLightingAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return rd._opts._doublesidelighting; +} + +MLRenderingAction* MLRenderingDoubleLightingAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingDoubleLightingAction(newactionparent); +} + +MLRenderingFancyLightingAction::MLRenderingFancyLightingAction( QObject* parent) + :MLRenderingAction(parent) +{ + setText(QString("Fancy Lighting")); +} + +MLRenderingFancyLightingAction::MLRenderingFancyLightingAction( int meshid,QObject* parent) + :MLRenderingAction(meshid,parent) +{ + setText(QString("Fancy Lighting")); +} + +void MLRenderingFancyLightingAction::updateRenderingData(MLRenderingData& rd ) +{ + rd._opts._fancylighting = isChecked(); +} + +bool MLRenderingFancyLightingAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return rd._opts._fancylighting; +} + +MLRenderingAction* MLRenderingFancyLightingAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingFancyLightingAction(newactionparent); +} + + +MLRenderingLightOnOffAction::MLRenderingLightOnOffAction( QObject* parent) + :MLRenderingAction(parent) +{ + setIcon(QIcon(":/images/lighton.png")); + setText(QString("Light on/off")); +} + +MLRenderingLightOnOffAction::MLRenderingLightOnOffAction( int meshid,QObject* parent) + :MLRenderingAction(meshid,parent) +{ + setIcon(QIcon(":/images/lighton.png")); + setText(QString("Light on/off")); +} + +void MLRenderingLightOnOffAction::updateRenderingData(MLRenderingData& rd ) +{ + rd._opts._lighting = isChecked(); +} + +bool MLRenderingLightOnOffAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return rd._opts._lighting; +} + +MLRenderingAction* MLRenderingLightOnOffAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingLightOnOffAction(newactionparent); +} + +MLRenderingFaceCullAction::MLRenderingFaceCullAction( QObject* parent) + :MLRenderingAction(parent) +{ + setText(QString("BackFace Culling")); +} + +MLRenderingFaceCullAction::MLRenderingFaceCullAction( int meshid,QObject* parent) + :MLRenderingAction(meshid,parent) +{ + setText(QString("BackFace Culling")); +} + +void MLRenderingFaceCullAction::updateRenderingData(MLRenderingData& rd ) +{ + rd._opts._backfacecull = isChecked(); +} + +bool MLRenderingFaceCullAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return rd._opts._backfacecull; +} + +MLRenderingAction* MLRenderingFaceCullAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingFaceCullAction(newactionparent); +} + + +MLRenderingPerMeshColorAction::MLRenderingPerMeshColorAction( QObject* parent) + :MLRenderingAction(parent) +{ + setText(QString("Per-Mesh")); +} + +MLRenderingPerMeshColorAction::MLRenderingPerMeshColorAction(int meshid,QObject* parent) + :MLRenderingAction(meshid,parent) +{ + setText(QString("Per-Mesh")); +} + +void MLRenderingPerMeshColorAction::updateRenderingData(MLRenderingData& rd) +{ + rd._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_MESHCOLOR] = isChecked(); + rd._opts._permesh_color = _col; +} + +bool MLRenderingPerMeshColorAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return rd._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_MESHCOLOR]; +} + +MLRenderingAction* MLRenderingPerMeshColorAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + MLRenderingPerMeshColorAction* tmp = new MLRenderingPerMeshColorAction(newactionparent); + const MLRenderingPerMeshColorAction* tmpcopy = qobject_cast(tocopy); + if (tmpcopy != NULL) + tmp->_col = tmpcopy->_col; + return tmp; +} + +MLRenderingPerVertexColorAction::MLRenderingPerVertexColorAction(QObject* parent) + :MLRenderingAction(parent) +{ + setText(QString("Per-Vertex")); +} + +MLRenderingPerVertexColorAction::MLRenderingPerVertexColorAction(int meshid,QObject* parent) + :MLRenderingAction(meshid,parent) +{ + setText(QString("Per-Vertex")); +} + +void MLRenderingPerVertexColorAction::updateRenderingData(MLRenderingData& rd ) +{ + rd._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTCOLOR] = isChecked(); +} + +bool MLRenderingPerVertexColorAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return rd._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTCOLOR]; +} + +MLRenderingAction* MLRenderingPerVertexColorAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingPerVertexColorAction(newactionparent); +} + +MLRenderingPerFaceColorAction::MLRenderingPerFaceColorAction(QObject* parent) + :MLRenderingAction(parent) +{ + setText(QString("Per-Face")); +} + +MLRenderingPerFaceColorAction::MLRenderingPerFaceColorAction(int meshid,QObject* parent) + :MLRenderingAction(meshid,parent) +{ + setText(QString("Per-Face")); +} + +void MLRenderingPerFaceColorAction::updateRenderingData(MLRenderingData& rd ) +{ + rd._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACECOLOR] = isChecked(); +} + +bool MLRenderingPerFaceColorAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + return rd._atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACECOLOR]; +} + +MLRenderingAction* MLRenderingPerFaceColorAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + (void*) tocopy; + return new MLRenderingPerFaceColorAction(newactionparent); +} + + + +MLRenderingUserDefinedColorAction::MLRenderingUserDefinedColorAction( vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY pm,QObject* parent ) + :MLRenderingAction(-1,parent),_pm(pm),_col(vcg::Color4b::DarkGray) +{ + setText(QString("User-Defined")); +} + +MLRenderingUserDefinedColorAction::MLRenderingUserDefinedColorAction( vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY pm,int meshid, QObject* parent ) + :MLRenderingAction(meshid,parent),_pm(pm) +{ + setText(QString("User-Defined")); +} + +void MLRenderingUserDefinedColorAction::updateRenderingData( MLRenderingData& rd ) +{ + switch(_pm) + { + case (vcg::GLMeshAttributesInfo::PR_POINTS): + { + rd._opts._use_perpoint_fixedcolor = !(rd._opts._use_perpoint_fixedcolor); + if (rd._opts._use_perpoint_fixedcolor) + rd._opts._perpoint_fixedcolor = _col; + break; + } + case (vcg::GLMeshAttributesInfo::PR_WIREFRAME_EDGES): + case (vcg::GLMeshAttributesInfo::PR_WIREFRAME_TRIANGLES): + { + rd._opts._use_peredge_fixedcolor = !(rd._opts._use_peredge_fixedcolor); + if (rd._opts._use_peredge_fixedcolor) + rd._opts._peredge_fixedcolor = _col; + break; + } + case (vcg::GLMeshAttributesInfo::PR_SOLID): + { + rd._opts._use_perface_fixedcolor = !(rd._opts._use_perface_fixedcolor); + if (rd._opts._use_perface_fixedcolor) + rd._opts._perface_fixedcolor = _col; + break; + } + default: + break; + } +} + +bool MLRenderingUserDefinedColorAction::isRenderingDataEnabled( const MLRenderingData& rd ) const +{ + switch(_pm) + { + case (vcg::GLMeshAttributesInfo::PR_POINTS): + { + + return (rd._opts._use_perpoint_fixedcolor); + break; + } + case (vcg::GLMeshAttributesInfo::PR_WIREFRAME_EDGES): + case (vcg::GLMeshAttributesInfo::PR_WIREFRAME_TRIANGLES): + { + + return (rd._opts._use_peredge_fixedcolor); + break; + } + case (vcg::GLMeshAttributesInfo::PR_SOLID): + { + return (rd._opts._use_perface_fixedcolor); + break; + } + default: + break; + } + return false; +} + +void MLRenderingUserDefinedColorAction::setColor( const QColor& col ) +{ + _col = vcg::ColorConverter::ToColor4b(col); +} + +void MLRenderingUserDefinedColorAction::setColor( const vcg::Color4b& col ) +{ + _col = col; +} + +MLRenderingAction* MLRenderingUserDefinedColorAction::copyCtr( const MLRenderingAction* tocopy,QObject* newactionparent ) const +{ + MLRenderingUserDefinedColorAction* tmp = new MLRenderingUserDefinedColorAction(_pm,newactionparent); + const MLRenderingUserDefinedColorAction* tmpcopy = qobject_cast(tocopy); + if (tmpcopy != NULL) + tmp->_col = tmpcopy->_col; + return tmp; +} diff --git a/src/meshlab/ml_rendering_actions.h b/src/meshlab/ml_rendering_actions.h new file mode 100644 index 000000000..c3d4783cd --- /dev/null +++ b/src/meshlab/ml_rendering_actions.h @@ -0,0 +1,270 @@ +#ifndef RENDER_MODE_ACTIONS_H +#define RENDER_MODE_ACTIONS_H + +#include +#include "../common/ml_shared_data_context.h" + + +class MLRenderingAction : public QAction +{ + Q_OBJECT +public: + MLRenderingAction(QObject* parent); + MLRenderingAction(int meshid,QObject* parent); + + MLRenderingAction* copyAction(const MLRenderingAction* tocopy,QObject* newactionparent); + + virtual void updateRenderingData(MLRenderingData& rd) = 0; + virtual bool isRenderingDataEnabled(const MLRenderingData& rd) const = 0; + int meshId() const; + void setMeshId(int meshid); +protected: + virtual MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const = 0; + void copyActionState(const MLRenderingAction* tocopy); +}; + +class MLRenderingBBoxAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingBBoxAction(QObject* parent); + MLRenderingBBoxAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; + +}; + +class MLRenderingPointsAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingPointsAction(QObject* parent); + MLRenderingPointsAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingWireAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingWireAction(QObject* parent); + MLRenderingWireAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingSolidAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingSolidAction(QObject* parent); + MLRenderingSolidAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingEdgeWireAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingEdgeWireAction(QObject* parent); + MLRenderingEdgeWireAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingHiddenLinesAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingHiddenLinesAction(QObject* parent); + MLRenderingHiddenLinesAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingFlatAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingFlatAction(QObject* parent); + MLRenderingFlatAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingSmoothAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingSmoothAction(QObject* parent); + MLRenderingSmoothAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingPerVertTextCoordAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingPerVertTextCoordAction(QObject* parent); + MLRenderingPerVertTextCoordAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingPerWedgeTextCoordAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingPerWedgeTextCoordAction(QObject* parent); + MLRenderingPerWedgeTextCoordAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingDoubleLightingAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingDoubleLightingAction(QObject* parent); + MLRenderingDoubleLightingAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingFancyLightingAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingFancyLightingAction(QObject* parent); + MLRenderingFancyLightingAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingLightOnOffAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingLightOnOffAction(QObject* parent); + MLRenderingLightOnOffAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingFaceCullAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingFaceCullAction(QObject* parent); + MLRenderingFaceCullAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingPerMeshColorAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingPerMeshColorAction(QObject* parent); + MLRenderingPerMeshColorAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; + void setColor(const QColor& col); + void setColor(const vcg::Color4b& col); +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +private: + vcg::Color4b _col; +}; + +class MLRenderingPerVertexColorAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingPerVertexColorAction(QObject* parent); + MLRenderingPerVertexColorAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingPerFaceColorAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingPerFaceColorAction(QObject* parent); + MLRenderingPerFaceColorAction(int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +}; + +class MLRenderingUserDefinedColorAction : public MLRenderingAction +{ + Q_OBJECT +public: + MLRenderingUserDefinedColorAction(vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY pm,QObject* parent); + MLRenderingUserDefinedColorAction(vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY pm,int meshid,QObject* parent); + + void updateRenderingData(MLRenderingData& rd); + bool isRenderingDataEnabled(const MLRenderingData& rd) const; + void setColor(const QColor& col); + void setColor(const vcg::Color4b& col); +protected: + MLRenderingAction* copyCtr(const MLRenderingAction* tocopy,QObject* newactionparent) const; +private: + vcg::GLMeshAttributesInfo::PRIMITIVE_MODALITY _pm; + vcg::Color4b _col; +}; + +#endif diff --git a/src/meshlab/rendermodeactions.cpp b/src/meshlab/rendermodeactions.cpp deleted file mode 100644 index 3a44b69f4..000000000 --- a/src/meshlab/rendermodeactions.cpp +++ /dev/null @@ -1,580 +0,0 @@ -#include "rendermodeactions.h" -#include - -RenderModeAction::RenderModeAction( QObject* parent ) - :QAction(parent) -{ - setCheckable(true); - setChecked(false); - commonInit(-1); -} - -RenderModeAction::RenderModeAction( const unsigned int meshid,QObject* parent ) - :QAction(parent) -{ - setCheckable(true); - setChecked(false); - commonInit(meshid); -} - - - -unsigned int RenderModeAction::meshId() const -{ - bool isvalidid = false; - return data().toUInt(&isvalidid); -} - - -void RenderModeAction::commonInit(const unsigned int meshid) -{ - setData(QVariant(meshid)); -} - -bool RenderModeAction::isBufferObjectUpdateRequired() const -{ - return false; -} - -RenderModeBBoxAction::RenderModeBBoxAction( QObject* parent) - :RenderModeAction(parent) -{ - setIcon(QIcon(":/images/bbox.png")); - setText(QString("Bounding Box")); -} - -RenderModeBBoxAction::RenderModeBBoxAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid,parent) -{ - setIcon(QIcon(":/images/bbox.png")); - setText(QString("Bounding Box")); -} - -void RenderModeBBoxAction::updateRenderMode(RenderMode& rm ) -{ - if (!isRenderModeEnabled(rm)) - rm.addPrimitiveModality(vcg::GLMeshAttributesInfo::PR_BBOX); - else - rm.removePrimitiveModality(vcg::GLMeshAttributesInfo::PR_BBOX); -} - -bool RenderModeBBoxAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return (rm.pmmask & vcg::GLMeshAttributesInfo::PR_BBOX); -} - -bool RenderModeBBoxAction::isBufferObjectUpdateRequired() const -{ - return true; -} - -RenderModePointsAction::RenderModePointsAction( QObject* parent) - :RenderModeAction(parent) -{ - setIcon(QIcon(":/images/points.png")); - setText(QString("Points")); -} - -RenderModePointsAction::RenderModePointsAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid, parent) -{ - setIcon(QIcon(":/images/points.png")); - setText(QString("Points")); -} - -void RenderModePointsAction::updateRenderMode(RenderMode& rm ) -{ - if (!isRenderModeEnabled(rm)) - { - rm.addPrimitiveModality(vcg::GLMeshAttributesInfo::PR_POINTS); - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = true; - } - else - { - rm.removePrimitiveModality(vcg::GLMeshAttributesInfo::PR_POINTS); - //BBOX doesn't require ATT_VERTPOS. If it is the last remaining PRIMITIVE_MODALITY i do not need to request the ATT_VERTPOSITION bo - if ((rm.pmmask == vcg::GLMeshAttributesInfo::PR_BBOX) || (rm.pmmask == vcg::GLMeshAttributesInfo::PR_NONE)) - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = false; - } -} - -bool RenderModePointsAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return ((rm.pmmask & vcg::GLMeshAttributesInfo::PR_POINTS) && (rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION])); -} - -bool RenderModePointsAction::isBufferObjectUpdateRequired() const -{ - return true; -} - - -RenderModeWireAction::RenderModeWireAction( QObject* parent) - :RenderModeAction(parent) -{ - setIcon(QIcon(":/images/wire.png")); - setText(QString("Wireframe")); -} - -RenderModeWireAction::RenderModeWireAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid,parent) -{ - -} - -void RenderModeWireAction::updateRenderMode(RenderMode& rm ) -{ - if (!isRenderModeEnabled(rm)) - { - rm.addPrimitiveModality(vcg::GLMeshAttributesInfo::PR_WIREFRAME_TRIANGLES); - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = true; - } - else - { - rm.removePrimitiveModality(vcg::GLMeshAttributesInfo::PR_WIREFRAME_TRIANGLES); - //BBOX doesn't require ATT_VERTPOS. If it is the last remaining PRIMITIVE_MODALITY i do not need to request the ATT_VERTPOSITION bo - if ((rm.pmmask == vcg::GLMeshAttributesInfo::PR_BBOX) || (rm.pmmask == vcg::GLMeshAttributesInfo::PR_NONE)) - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = false; - } -} - -bool RenderModeWireAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return (((rm.pmmask & vcg::GLMeshAttributesInfo::PR_WIREFRAME_EDGES) || (rm.pmmask & vcg::GLMeshAttributesInfo::PR_WIREFRAME_TRIANGLES)) && (rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION])); -} - -bool RenderModeWireAction::isBufferObjectUpdateRequired() const -{ - return true; -} - -RenderModeQuadWireAction::RenderModeQuadWireAction( QObject* parent ) - :RenderModeAction(parent) -{ - setIcon(QIcon(":/images/poly_wire.png")); - setText(QString("Quads Wireframe")); -} - -RenderModeQuadWireAction::RenderModeQuadWireAction( const unsigned int meshid,QObject* parent ) - :RenderModeAction(meshid,parent) -{ - setIcon(QIcon(":/images/poly_wire.png")); - setText(QString("Quads Wireframe")); -} - -void RenderModeQuadWireAction::updateRenderMode( RenderMode& rm ) -{ - if (!isRenderModeEnabled(rm)) - { - rm.addPrimitiveModality(vcg::GLMeshAttributesInfo::PR_WIREFRAME_EDGES); - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = true; - } - else - { - rm.removePrimitiveModality(vcg::GLMeshAttributesInfo::PR_WIREFRAME_EDGES); - //BBOX doesn't require ATT_VERTPOS. If it is the last remaining PRIMITIVE_MODALITY i do not need to request the ATT_VERTPOSITION bo - if ((rm.pmmask == vcg::GLMeshAttributesInfo::PR_BBOX) || (rm.pmmask == vcg::GLMeshAttributesInfo::PR_NONE)) - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = false; - } -} - -bool RenderModeQuadWireAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return ((rm.pmmask & vcg::GLMeshAttributesInfo::PR_WIREFRAME_EDGES) && (rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION])); -} - -bool RenderModeQuadWireAction::isBufferObjectUpdateRequired() const -{ - return true; -} - - - -RenderModeHiddenLinesAction::RenderModeHiddenLinesAction( QObject* parent) - :RenderModeAction(parent) -{ - setIcon(QIcon(":/images/backlines.png")); - setText(QString("Back Face Culling")); -} - -RenderModeHiddenLinesAction::RenderModeHiddenLinesAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid,parent) -{ - setIcon(QIcon(":/images/backlines.png")); - setText(QString("Back Face Culling")); -} - -void RenderModeHiddenLinesAction::updateRenderMode(RenderMode& rm ) -{ - //rm.setDrawMode(vcg::GLW::DMHidden); -} - -bool RenderModeHiddenLinesAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - //return (rm.drawMode == vcg::GLW::DMHidden); - return false; -} - - - -RenderModeFlatAction::RenderModeFlatAction( QObject* parent) - :RenderModeAction(parent) -{ - setIcon(QIcon(":/images/flat.png")); - setText(QString("Flat")); -} - -RenderModeFlatAction::RenderModeFlatAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid, parent) -{ - setIcon(QIcon(":/images/flat.png")); - setText(QString("Flat")); -} - -void RenderModeFlatAction::updateRenderMode(RenderMode& rm ) -{ - if (!isRenderModeEnabled(rm)) - { - rm.addPrimitiveModality(vcg::GLMeshAttributesInfo::PR_SOLID); - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = true; - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACENORMAL] = true; - } - else - { - rm.removePrimitiveModality(vcg::GLMeshAttributesInfo::PR_SOLID); - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACENORMAL] = false; - if ((rm.pmmask == vcg::GLMeshAttributesInfo::PR_BBOX) || (rm.pmmask == vcg::GLMeshAttributesInfo::PR_NONE)) - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = false; - } -} - -bool RenderModeFlatAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return ((rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACENORMAL]) && (rm.pmmask & vcg::GLMeshAttributesInfo::PR_SOLID) && (rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION])); -} - -bool RenderModeFlatAction::isBufferObjectUpdateRequired() const -{ - return true; -} - - -RenderModeSmoothAction::RenderModeSmoothAction( QObject* parent) - :RenderModeAction(parent) -{ - setIcon(QIcon(":/images/smooth.png")); - setText(QString("Smooth")); -} - -RenderModeSmoothAction::RenderModeSmoothAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid,parent) -{ - setIcon(QIcon(":/images/smooth.png")); - setText(QString("Smooth")); -} - -void RenderModeSmoothAction::updateRenderMode(RenderMode& rm ) -{ - if (!isRenderModeEnabled(rm)) - { - rm.addPrimitiveModality(vcg::GLMeshAttributesInfo::PR_SOLID); - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = true; - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTNORMAL] = true; - } - else - { - rm.removePrimitiveModality(vcg::GLMeshAttributesInfo::PR_SOLID); - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTNORMAL] = false; - if ((rm.pmmask == vcg::GLMeshAttributesInfo::PR_BBOX) || (rm.pmmask == vcg::GLMeshAttributesInfo::PR_NONE)) - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION] = false; - } -} - -bool RenderModeSmoothAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return ((rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTNORMAL]) && (rm.pmmask & vcg::GLMeshAttributesInfo::PR_SOLID) && (rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTPOSITION])); -} - -bool RenderModeSmoothAction::isBufferObjectUpdateRequired() const -{ - return true; -} - - -RenderModeTexturePerVertAction::RenderModeTexturePerVertAction( QObject* parent) - :RenderModeAction(/*QIcon(":/images/textures.png"),QString("&Texture"),*/parent) -{ - setIcon(QIcon(":/images/textures.png")); - setText(QString("Per-Vert Texture")); -} - -RenderModeTexturePerVertAction::RenderModeTexturePerVertAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid/*,QIcon(":/images/textures.png"),QString("&Texture")*/,parent) -{ - setIcon(QIcon(":/images/textures.png")); - setText(QString("Per-Vert Texture")); -} - -void RenderModeTexturePerVertAction::updateRenderMode(RenderMode& rm ) -{ - //rm.setTextureMode(!isChecked() ? vcg::GLW::TMNone : vcg::GLW::TMPerVert); - if (!isRenderModeEnabled(rm)) - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTTEXTURE] = true; - else - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTTEXTURE] = false; -} - -bool RenderModeTexturePerVertAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTTEXTURE]; -} - -bool RenderModeTexturePerVertAction::isBufferObjectUpdateRequired() const -{ - return true; -} - -RenderModeTexturePerWedgeAction::RenderModeTexturePerWedgeAction( QObject* parent) - :RenderModeAction(/*QIcon(":/images/textures.png"),QString("&Texture"),*/parent) -{ - setIcon(QIcon(":/images/textures.png")); - setText(QString("Per-Wedge Texture")); -} - -RenderModeTexturePerWedgeAction::RenderModeTexturePerWedgeAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid/*,QIcon(":/images/textures.png"),QString("&Texture")*/,parent) -{ - setIcon(QIcon(":/images/textures.png")); - setText(QString("Per-Wedge Texture")); -} - -void RenderModeTexturePerWedgeAction::updateRenderMode(RenderMode& rm ) -{ - //rm.setTextureMode((!isChecked() ? vcg::GLW::TMNone : vcg::GLW::TMPerWedgeMulti)); - if (!isRenderModeEnabled(rm)) - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_WEDGETEXTURE] = true; - else - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_WEDGETEXTURE] = false; -} - -bool RenderModeTexturePerWedgeAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - //return ((rm.textureMode == vcg::GLW::TMPerWedgeMulti) || (rm.textureMode == vcg::GLW::TMPerWedge)); - return rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_WEDGETEXTURE]; -} - -bool RenderModeTexturePerWedgeAction::isBufferObjectUpdateRequired() const -{ - return true; -} - - -RenderModeDoubleLightingAction::RenderModeDoubleLightingAction( QObject* parent) - :RenderModeAction(/*QString("&Double side lighting"),*/parent) -{ - setText(QString("Double side lighting")); -} - -RenderModeDoubleLightingAction::RenderModeDoubleLightingAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid/*,QString("&Double side lighting")*/,parent) -{ - setText(QString("Double side lighting")); -} - -void RenderModeDoubleLightingAction::updateRenderMode(RenderMode& rm ) -{ - rm.setDoubleFaceLighting(isChecked()); -} - -bool RenderModeDoubleLightingAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return rm.doubleSideLighting; -} - -RenderModeFancyLightingAction::RenderModeFancyLightingAction( QObject* parent) - :RenderModeAction(/*QString("&Fancy Lighting"),*/parent) -{ - setText(QString("Fancy Lighting")); -} - -RenderModeFancyLightingAction::RenderModeFancyLightingAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid,/*QString("&Fancy Lighting"),*/parent) -{ - setText(QString("Fancy Lighting")); -} - -void RenderModeFancyLightingAction::updateRenderMode(RenderMode& rm ) -{ - rm.setFancyLighting(isChecked()); -} - -bool RenderModeFancyLightingAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return rm.fancyLighting; -} - - -RenderModeLightOnOffAction::RenderModeLightOnOffAction( QObject* parent) - :RenderModeAction(/*QIcon(":/images/lighton.png"),QString("&Light on/off"),*/parent) -{ - setIcon(QIcon(":/images/lighton.png")); - setText(QString("Light on/off")); -} - -RenderModeLightOnOffAction::RenderModeLightOnOffAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid/*,QIcon(":/images/lighton.png"),QString("&Light on/off")*/,parent) -{ - setIcon(QIcon(":/images/lighton.png")); - setText(QString("Light on/off")); -} - -void RenderModeLightOnOffAction::updateRenderMode(RenderMode& rm ) -{ - rm.setLighting(isChecked()); -} - -bool RenderModeLightOnOffAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return rm.lighting; -} - -RenderModeFaceCullAction::RenderModeFaceCullAction( QObject* parent) - :RenderModeAction(/*QString("BackFace &Culling"),*/parent) -{ - setText(QString("BackFace Culling")); -} - -RenderModeFaceCullAction::RenderModeFaceCullAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid/*,QString("BackFace &Culling")*/,parent) -{ - setText(QString("BackFace Culling")); -} - -void RenderModeFaceCullAction::updateRenderMode(RenderMode& rm ) -{ - rm.setBackFaceCull(isChecked()); -} - -bool RenderModeFaceCullAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return rm.backFaceCull; -} - -RenderModeColorModeNoneAction::RenderModeColorModeNoneAction( QObject* parent) - :RenderModeAction(/*QString("&None"),*/parent) -{ - setText(QString("None")); -} - -RenderModeColorModeNoneAction::RenderModeColorModeNoneAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid/*,QString("&None")*/,parent) -{ - setText(QString("None")); -} - -void RenderModeColorModeNoneAction::updateRenderMode(RenderMode& rm ) -{ - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_MESHCOLOR] = false; - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTCOLOR] = false; - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACECOLOR] = false; -} - -bool RenderModeColorModeNoneAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return (!rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_MESHCOLOR] && !rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTCOLOR] && !rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACECOLOR]); -} - -bool RenderModeColorModeNoneAction::isBufferObjectUpdateRequired() const -{ - return true; -} - - -RenderModeColorModePerMeshAction::RenderModeColorModePerMeshAction( QObject* parent) - :RenderModeAction(/*QString("Per &Mesh"),*/parent) -{ - setIcon(QIcon(":/images/per_mesh.png")); - setText(QString("Per-Mesh Color")); -} - -RenderModeColorModePerMeshAction::RenderModeColorModePerMeshAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid,/*QString("Per &Mesh"),*/parent) -{ - setIcon(QIcon(":/images/per_mesh.png")); - setText(QString("Per-Mesh Color")); -} - -void RenderModeColorModePerMeshAction::updateRenderMode(RenderMode& rm ) -{ - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_MESHCOLOR] = true; -} - -bool RenderModeColorModePerMeshAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return (vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_MESHCOLOR); -} - -bool RenderModeColorModePerMeshAction::isBufferObjectUpdateRequired() const -{ - return true; -} - -RenderModeColorModePerVertexAction::RenderModeColorModePerVertexAction( QObject* parent) - :RenderModeAction(/*QString("Per &Vertex"),*/parent) -{ - setIcon(QIcon(":/images/per_vertex.png")); - setText(QString("Per-Vertex Color")); -} - -RenderModeColorModePerVertexAction::RenderModeColorModePerVertexAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid,/*QString("Per &Vertex"),*/parent) -{ - setIcon(QIcon(":/images/per_vertex.png")); - setText(QString("Per-Vertex Color")); -} - -void RenderModeColorModePerVertexAction::updateRenderMode(RenderMode& rm ) -{ - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTCOLOR] = true; -} - -bool RenderModeColorModePerVertexAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_VERTCOLOR]; -} - -bool RenderModeColorModePerVertexAction::isBufferObjectUpdateRequired() const -{ - return true; -} - -RenderModeColorModePerFaceAction::RenderModeColorModePerFaceAction( QObject* parent) - :RenderModeAction(/*QString("Per &Face Color"),*/parent) -{ - setIcon(QIcon(":/images/per_face.png")); - setText(QString("Per-Face Color")); -} - -RenderModeColorModePerFaceAction::RenderModeColorModePerFaceAction( const unsigned int meshid,QObject* parent) - :RenderModeAction(meshid,/*QString("Per &Face"),*/parent) -{ - setIcon(QIcon(":/images/per_face.png")); - setText(QString("Per-Face Color")); -} - -void RenderModeColorModePerFaceAction::updateRenderMode(RenderMode& rm ) -{ - rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACECOLOR]; -} - -bool RenderModeColorModePerFaceAction::isRenderModeEnabled( const RenderMode& rm ) const -{ - return rm.atts[vcg::GLMeshAttributesInfo::ATT_NAMES::ATT_FACECOLOR]; -} - -bool RenderModeColorModePerFaceAction::isBufferObjectUpdateRequired() const -{ - return true; -} - - diff --git a/src/meshlab/rendermodeactions.h b/src/meshlab/rendermodeactions.h deleted file mode 100644 index 5dc30a88d..000000000 --- a/src/meshlab/rendermodeactions.h +++ /dev/null @@ -1,226 +0,0 @@ -#ifndef RENDER_MODE_ACTIONS_H -#define RENDER_MODE_ACTIONS_H - -#include "../common/meshmodel.h" -#include - -class RenderModeAction : public QAction -{ - Q_OBJECT -public: - RenderModeAction(QObject* parent); - RenderModeAction(const unsigned int meshid,QObject* parent); - - virtual void updateRenderMode(RenderMode& rm) = 0; - virtual bool isRenderModeEnabled(const RenderMode& rm) const = 0; - virtual bool isBufferObjectUpdateRequired() const; - unsigned int meshId() const; - -private: - void commonInit(const unsigned int meshid); - -}; - -class RenderModeBBoxAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeBBoxAction(QObject* parent); - RenderModeBBoxAction(const unsigned int meshid,QObject* parent); - -protected: - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; - bool isBufferObjectUpdateRequired() const; -}; - -class RenderModePointsAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModePointsAction(QObject* parent); - RenderModePointsAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; - bool isBufferObjectUpdateRequired() const; -}; - -class RenderModeWireAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeWireAction(QObject* parent); - RenderModeWireAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; - bool isBufferObjectUpdateRequired() const; -}; - - -class RenderModeQuadWireAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeQuadWireAction(QObject* parent); - RenderModeQuadWireAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; - bool isBufferObjectUpdateRequired() const; -}; - -class RenderModeHiddenLinesAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeHiddenLinesAction(QObject* parent); - RenderModeHiddenLinesAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; -}; - -class RenderModeFlatAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeFlatAction(QObject* parent); - RenderModeFlatAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; - bool isBufferObjectUpdateRequired() const; -}; - -class RenderModeSmoothAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeSmoothAction(QObject* parent); - RenderModeSmoothAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; - bool isBufferObjectUpdateRequired() const; -}; - -class RenderModeTexturePerVertAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeTexturePerVertAction(QObject* parent); - RenderModeTexturePerVertAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; - bool isBufferObjectUpdateRequired() const; -}; - -class RenderModeTexturePerWedgeAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeTexturePerWedgeAction(QObject* parent); - RenderModeTexturePerWedgeAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; - bool isBufferObjectUpdateRequired() const; -}; - -class RenderModeDoubleLightingAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeDoubleLightingAction(QObject* parent); - RenderModeDoubleLightingAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; -}; - -class RenderModeFancyLightingAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeFancyLightingAction(QObject* parent); - RenderModeFancyLightingAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; -}; - -class RenderModeLightOnOffAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeLightOnOffAction(QObject* parent); - RenderModeLightOnOffAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; -}; - -class RenderModeFaceCullAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeFaceCullAction(QObject* parent); - RenderModeFaceCullAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; -}; - -class RenderModeColorModeNoneAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeColorModeNoneAction(QObject* parent); - RenderModeColorModeNoneAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; - bool isBufferObjectUpdateRequired() const; -}; - -class RenderModeColorModePerMeshAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeColorModePerMeshAction(QObject* parent); - RenderModeColorModePerMeshAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; - bool isBufferObjectUpdateRequired() const; -}; - -class RenderModeColorModePerVertexAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeColorModePerVertexAction(QObject* parent); - RenderModeColorModePerVertexAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; - bool isBufferObjectUpdateRequired() const; -}; - -class RenderModeColorModePerFaceAction : public RenderModeAction -{ - Q_OBJECT -public: - RenderModeColorModePerFaceAction(QObject* parent); - RenderModeColorModePerFaceAction(const unsigned int meshid,QObject* parent); - - void updateRenderMode(RenderMode& rm); - bool isRenderModeEnabled(const RenderMode& rm) const; - bool isBufferObjectUpdateRequired() const; -}; - - -#endif diff --git a/src/meshlab/ui/layerDialog.ui b/src/meshlab/ui/layerDialog.ui index 0ff2d6a12..f7030b181 100644 --- a/src/meshlab/ui/layerDialog.ui +++ b/src/meshlab/ui/layerDialog.ui @@ -45,6 +45,9 @@ + + +