1 /**************************************************************************** 2 * MeshLab o o * 3 * A versatile mesh processing toolbox o o * 4 * _ O _ * 5 * Copyright(C) 2005 \/)\/ * 6 * Visual Computing Lab /\/| * 7 * ISTI - Italian National Research Council | * 8 * \ * 9 * All rights reserved. * 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 * This program is distributed in the hope that it will be useful, * 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 20 * for more details. * 21 * * 22 ****************************************************************************/ 23 24 #ifndef ML_DEFAULT_DECORATORS_H 25 #define ML_DEFAULT_DECORATORS_H 26 27 #include <common/ml_shared_data_context.h> 28 #include <common/meshmodel.h> 29 #include <common/GLLogStream.h> 30 31 class MainWindow; 32 33 class MLDefaultMeshDecorators 34 { 35 public: 36 MLDefaultMeshDecorators(MainWindow* mw); 37 38 typedef std::pair<Point3m,vcg::Color4b> PointPC; // this type is used to have a simple coord+color pair to rapidly draw non manifold faces 39 40 //the initMeshDecorationData is called when a mesh has been updated by a filter execution 41 bool initMeshDecorationData(MeshModel & mesh,const MLRenderingData& dt); 42 void decorateMesh(MeshModel & mesh,const MLRenderingData& dt, QPainter* painter, GLLogStream& log); 43 bool cleanMeshDecorationData(MeshModel& mesh,const MLRenderingData& dt); 44 45 //The updateMeshDecorationData is called when a decoration button is clicked on/off 46 bool updateMeshDecorationData(MeshModel& mesh,const MLRenderingData& previousdata,const MLRenderingData& currentdata); 47 selectionAttName()48 static const char* selectionAttName() { return "SelectionBuffers"; } 49 boundaryVertAttName()50 static const char* boundaryVertAttName() { return "BoundaryVertVector"; } boundaryEdgeAttName()51 static const char* boundaryEdgeAttName() { return "BoundaryEdgeVector"; } boundaryFaceAttName()52 static const char* boundaryFaceAttName() { return "BoundaryFaceVector"; } 53 nonManifEdgeAttName()54 static const char* nonManifEdgeAttName() { return "NonManifEdgeVector"; } nonManifEdgeFaceAttName()55 static const char* nonManifEdgeFaceAttName() { return "NonManifEdgeFaceVector"; } 56 nonManifVertAttName()57 static const char* nonManifVertAttName() { return "NonManifVertVector"; } nonManifVertFaceAttName()58 static const char* nonManifVertFaceAttName() { return "NonManifVertFaceVector"; } 59 boundaryTextVertAttName()60 static const char* boundaryTextVertAttName() { return "BoundaryTexVector"; } 61 62 private: 63 void initBoundaryDecoratorData(MeshModel& mm,bool edgeboundary,bool faceboundary); 64 void cleanBoundaryDecoratorData(MeshModel& mm,bool edgeboundary,bool faceboundary); 65 66 void initSelectionDecoratorData(MeshModel& mm,bool vertsel,bool facesel); 67 void cleanSelectionDecoratorData(MeshModel& mm, bool vertsel, bool facesel); 68 69 void initNonManifEdgeDecoratorData(MeshModel& mm); 70 void cleanNonManifEdgeDecoratorData(MeshModel& mm); 71 72 void initNonManifVertDecoratorData(MeshModel& mm); 73 void cleanNonManifVertDecoratorData(MeshModel& mm); 74 75 void initBoundaryTextDecoratorData(MeshModel& mm); 76 void cleanBoundaryTextDecoratorData(MeshModel& mm); 77 78 79 80 static void drawLineVector(const vcg::Matrix44f& tr,std::vector<PointPC> &EV); 81 static void drawTriVector(const vcg::Matrix44f& tr, std::vector<PointPC> &TV); 82 static void drawDotVector(const vcg::Matrix44f& tr, std::vector<PointPC> &TV, float baseSize=4.0f); 83 static void drawQuotedBox(MeshModel &m,QPainter *gla,QFont& qf); 84 static void drawQuotedLine(const vcg::Point3d &a,const vcg::Point3d &b, float aVal, float bVal, float tickScalarDistance, QPainter *painter, QFont& qf,float angle = 0,bool rightAlign = false); 85 static void chooseX(Box3m &box,double *mm,double *mp,GLint *vp,vcg::Point3d &x1,vcg::Point3d &x2); 86 static void chooseY(Box3m &box,double *mm,double *mp,GLint *vp,vcg::Point3d &y1,vcg::Point3d &y2); 87 static void chooseZ(Box3m &box,double *mm,double *mp,GLint *vp,vcg::Point3d &z1,vcg::Point3d &z2); 88 89 MainWindow* _mw; 90 }; 91 92 #endif