tuto_oper2.h 3.75 KB
Newer Older
1
2
3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
*                                                                              *
* This library is free software; you can redistribute it and/or modify it      *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your     *
* option) any later version.                                                   *
*                                                                              *
* This library is distributed in the hope that it will be useful, but WITHOUT  *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
* for more details.                                                            *
*                                                                              *
* You should have received a copy of the GNU Lesser General Public License     *
* along with this library; if not, write to the Free Software Foundation,      *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
*                                                                              *
20
* Web site: http://cgogn.unistra.fr/                                           *
21
22
23
24
25
26
27
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef _TUTO_OPER2_
#define _TUTO_OPER2_

untereiner's avatar
untereiner committed
28
//#define PRIMAL_TOPO 1
29
30

#include "Topology/generic/parameters.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
31
#include "Topology/map/embeddedMap2.h"
32

untereiner's avatar
untereiner committed
33
34
35
36
37
#ifdef PRIMAL_TOPO
    #include "Algo/Render/GL2/topoPrimalRender.h"
#else
    #include "Algo/Render/GL2/topoRender.h"
#endif
38
39

#include "ui_tuto_oper2.h"
40
#include "Utils/Qt/qtui.h"
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "Utils/Qt/qtSimple.h"
#include "Utils/cgognStream.h"


using namespace CGoGN ;

/**
 * Struct that contains some informations about the types of the manipulated objects
 * Mainly here to be used by the algorithms that are parameterized by it
 */
struct PFP: public PFP_STANDARD
{
	// definition of the type of the map
	typedef EmbeddedMap2 MAP;
};

57
typedef PFP::MAP MAP ;
Pierre Kraemer's avatar
Pierre Kraemer committed
58
typedef PFP::MAP::IMPL MAP_IMPL ;
59
typedef PFP::VEC3 VEC3 ;
60
61
62
63

class MyQT: public Utils::QT::SimpleQT
{
	Q_OBJECT
Pierre Kraemer's avatar
Pierre Kraemer committed
64

65
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
66
67
68
69
70
71
72
	MyQT():
		m_render_topo(NULL),
		m_selected(NIL),
		m_selected2(NIL),
		dm(myMap),
		m_shift(0.01f)
	{}
73
74
75
76
77

	void cb_redraw();
	void cb_initGL();
	void cb_mousePress(int button, int x, int y);
	void cb_keyPress(int code);
Sylvain Thery's avatar
Sylvain Thery committed
78
79
	void cb_Open();
	void cb_Save();
80
81
82
83
84

	Utils::QT::uiDockInterface dock;

protected:
	// declaration of the map
85
	MAP myMap;
86

Pierre Kraemer's avatar
Pierre Kraemer committed
87
88
	VertexAttribute<VEC3, MAP_IMPL> position;
	DartAttribute<VEC3, MAP_IMPL> colorDarts;
89
90

	// render (for the topo)
untereiner's avatar
untereiner committed
91
#ifdef PRIMAL_TOPO
Pierre Kraemer's avatar
Pierre Kraemer committed
92
	Algo::Render::GL2::TopoPrimalRender<PFP>* m_render_topo;
untereiner's avatar
untereiner committed
93
#else
Pierre Kraemer's avatar
Pierre Kraemer committed
94
	Algo::Render::GL2::TopoRenderMap<PFP>* m_render_topo;
untereiner's avatar
untereiner committed
95
#endif
96
97
	Dart m_selected;
	Dart m_selected2;
Pierre Kraemer's avatar
Pierre Kraemer committed
98
	DartMarker<MAP> dm;
Sylvain Thery's avatar
Sylvain Thery committed
99
	float m_shift;
100
101

	// just for more compact writing
Pierre Kraemer's avatar
Pierre Kraemer committed
102
103
104
	inline Dart PHI1(Dart d)	{ return myMap.phi1(d); }
	inline Dart PHI_1(Dart d)	{ return myMap.phi_1(d); }
	inline Dart PHI2(Dart d)	{ return myMap.phi2(d); }
105
	template<int X>
Pierre Kraemer's avatar
Pierre Kraemer committed
106
	Dart PHI(Dart d)			{ return myMap.phi<X>(d); }
107
108
109
110
111

public:
	// example of simple map creation
	void createMap(int n);
	void updateMap();
Sylvain Thery's avatar
Sylvain Thery committed
112
	void importMesh(std::string& filename);
113
114
115

public slots:
	void operation(int x);
116
117
	void svg();
	void width(int w);
118
119
120
};

#endif