1 /****************************************************************************
2 * MeshLab                                                           o o     *
3 * An extendible mesh processor                                    o     o   *
4 *                                                                _   O  _   *
5 * Copyright(C) 2005, 2009                                          \/)\/    *
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 SLIDEPLUGIN_H
25 #define SLIDEPLUGIN_H
26 
27 #include "svgpro.h"
28 #include "slicedialog.h"
29 #include <common/interfaces.h>
30 #include <wrap/gui/trackball.h>
31 
32 #include <vcg/space/index/grid_static_ptr.h>
33 #include <vcg/complex/edgemesh/base.h>
34 #include <vcg/simplex/edge/base.h>
35 #include <vcg/simplex/edge/component.h>
36 #include <wrap/io_edgemesh/export_svg.h>
37 
38 typedef CMeshO n_Mesh;
39 
40 class n_Vertex;
41 class n_Face;
42 class n_Edge;
43 
44 class n_UsedTypes: public vcg::UsedTypes < vcg::Use<n_Vertex>::AsVertexType,
45                                           vcg::Use<n_Edge   >::AsEdgeType,
46                                           vcg::Use<n_Face  >::AsFaceType >{};
47 
48 class n_Vertex  : public vcg::Vertex<n_UsedTypes, vcg::vertex::Coord3f, vcg::vertex::BitFlags> {};
49 class n_Edge    : public vcg::Edge<n_UsedTypes, vcg::edge::VertexRef> {};
50 
51 
52 class n_EdgeMesh: public vcg::edg::EdgeMesh< std::vector<n_Vertex>, std::vector<n_Edge> > {};
53 
54 typedef vcg::GridStaticPtr<CMeshO::FaceType, CMeshO::ScalarType> TriMeshGrid;
55 typedef vcg::edg::EdgeMesh<std::vector<n_Vertex>,std::vector<n_Edge> > Edge_Mesh;
56 typedef vcg::edg::io::SVGProperties SVGProperties;
57 
58 
59 
60 class ExtraMeshSlidePlugin : public QObject, public MeshEditInterface
61 {
62 	Q_OBJECT
63 	MESHLAB_PLUGIN_IID_EXPORTER(MESH_EDIT_INTERFACE_IID)
64 	Q_INTERFACES(MeshEditInterface)
65 
66 public:
67 
68 	ExtraMeshSlidePlugin();
69     vcg::Trackball trackball_slice;
70 	virtual ~ExtraMeshSlidePlugin();
71 	static const QString Info();
72 	virtual bool StartEdit(MeshModel &/*m*/, GLArea * /*parent*/);
73     virtual void EndEdit(MeshModel &/*m*/, GLArea * /*parent*/);
74     virtual void Decorate(MeshModel &/*m*/, GLArea * /*parent*/);
75     virtual void mousePressEvent(QMouseEvent *event, MeshModel &/*m*/, GLArea * );
76     virtual void mouseMoveEvent(QMouseEvent *event, MeshModel &/*m*/, GLArea * );
77     virtual void mouseReleaseEvent(QMouseEvent *event, MeshModel &/*m*/, GLArea * );
78 
79 private:
80 	TriMeshGrid* mesh_grid;
81 	n_EdgeMesh* edge_mesh;
82 	n_Mesh trimesh;
83 	std::vector< TriMeshGrid::Cell *> intersected_cells;
84 	std::vector<vcg::Point3f> point_Vector;
85 	QString fileName, dirName, fileN;
86 	bool isDragging;
87 	GLArea * gla;
88 	MeshModel *m;
89   vcg::Box3f b;
90 	SVGPro *svgpro;
91 	float edgeMax;
92 SVGProperties pr;
93 	dialogslice *dialogsliceobj;
94     void DrawPlane(GLArea * gla,MeshModel &m);
95 	void UpdateVal(SVGPro * sv, SVGProperties * pr);
96 	bool  activeDefaultTrackball;
97     bool disableTransision;
98 
99 public Q_SLOTS:
100 	void RestoreDefault();
101 	void SlotExportButton();
102 	void upGlA();
103 };
104 #endif
105