tuto_oper3.h 4.67 KB
Newer Older
Sylvain Thery's avatar
Sylvain Thery committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
*                                                                              *
* 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.           *
*                                                                              *
* Web site: http://cgogn.unistra.fr/                                           *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef _TUTO_OPER3_
#define _TUTO_OPER3_

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

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

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

39
#include "Algo/Render/GL2/topoRender.h"
40
#include "Algo/Geometry/boundingbox.h"
Sylvain Thery's avatar
Sylvain Thery committed
41
42

#include "ui_tuto_oper3.h"
43
#include "Utils/Qt/qtui.h"
Sylvain Thery's avatar
Sylvain Thery committed
44
45
#include "Utils/Qt/qtSimple.h"
#include "Utils/cgognStream.h"
46
#include "Utils/frameManipulator.h"
Sylvain Thery's avatar
Sylvain Thery committed
47
48
49
50
51
52
53
54
55
56
57
58
59

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 EmbeddedMap3 MAP;
};

60
typedef PFP::MAP MAP ;
Pierre Kraemer's avatar
Pierre Kraemer committed
61
typedef PFP::MAP::IMPL MAP_IMPL ;
62
typedef PFP::VEC3 VEC3 ;
Sylvain Thery's avatar
Sylvain Thery committed
63
64
65
66

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

Sylvain Thery's avatar
Sylvain Thery committed
68
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
69
70
71
72
73
74
75
76
77
78
79
	MyQT() :
		m_render_topo(NULL),
		m_selected(NIL),
		m_selected2(NIL),
		m_shift(0.01f),
		m_ex1(0.9f),
		m_ex2(0.9f),
		m_ex3(0.9f),
		clip_volume(true),
		hide_clipping(false)
	{}
Sylvain Thery's avatar
Sylvain Thery committed
80
81
82
83

	void cb_redraw();
	void cb_initGL();
	void cb_mousePress(int button, int x, int y);
84
85
	void cb_mouseRelease(int button, int x, int y);
	void cb_mouseMove(int button, int x, int y);
Sylvain Thery's avatar
Sylvain Thery committed
86
87
88
89
90
91
92
93
	void cb_keyPress(int code);
	void cb_Open();
	void cb_Save();

	Utils::QT::uiDockInterface dock;

protected:
	// declaration of the map
94
	MAP myMap;
Sylvain Thery's avatar
Sylvain Thery committed
95

Pierre Kraemer's avatar
Pierre Kraemer committed
96
	VertexAttribute<VEC3, MAP_IMPL> position;
Sylvain Thery's avatar
Sylvain Thery committed
97

Pierre Kraemer's avatar
Pierre Kraemer committed
98
//	SelectorDartNoBoundary<MAP> nb;
Sylvain Thery's avatar
Sylvain Thery committed
99

Pierre Kraemer's avatar
Pierre Kraemer committed
100
	Geom::BoundingBox<VEC3> bb;
101

Sylvain Thery's avatar
Sylvain Thery committed
102
	// render (for the topo)
untereiner's avatar
untereiner committed
103
#ifdef PRIMAL_TOPO
Pierre Kraemer's avatar
Pierre Kraemer committed
104
	Algo::Render::GL2::Topo3PrimalRender<PFP>* m_render_topo;
untereiner's avatar
untereiner committed
105
#else
Pierre Kraemer's avatar
Pierre Kraemer committed
106
	Algo::Render::GL2::Topo3RenderMap<PFP>* m_render_topo;
untereiner's avatar
untereiner committed
107
#endif
Pierre Kraemer's avatar
Pierre Kraemer committed
108
	Algo::Render::GL2::TopoRenderMap<PFP>* m_render_topo_boundary;
Sylvain Thery's avatar
Sylvain Thery committed
109
110
111
112
113
	Dart m_selected;
	Dart m_selected2;
	std::vector<Dart> m_selecteds;
	float m_shift;

114
	float m_ex1, m_ex2, m_ex3;
Sylvain Thery's avatar
Sylvain Thery committed
115

116
117
118
119
120
121
122
123
124
	// for clipping plane manipulation
    bool clip_volume;
    bool hide_clipping;
	Utils::Pickable* m_PlanePick;
	Utils::FrameManipulator* m_frame;
	unsigned int m_pickedAxis;
	int m_begX;
	int m_begY;

Sylvain Thery's avatar
Sylvain Thery committed
125
	// just for more compact writing
Pierre Kraemer's avatar
Pierre Kraemer committed
126
127
128
129
	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); }
	inline Dart PHI3(Dart d)	{ return myMap.phi3(d); }
Sylvain Thery's avatar
Sylvain Thery committed
130
	template<int X>
Pierre Kraemer's avatar
Pierre Kraemer committed
131
	Dart PHI(Dart d)			{ return myMap.phi<X>(d); }
Sylvain Thery's avatar
Sylvain Thery committed
132

133
134
135
136
	int clip_id1;
	int clip_id2;
	int clip_id3;
	int clip_id4;
137
138
	Utils::ClippingShader* m_sh1;
	Utils::ClippingShader* m_sh2;
139
140
141
	Utils::ClippingShader* m_sh3;
	Utils::ClippingShader* m_sh4;

Sylvain Thery's avatar
Sylvain Thery committed
142
143
144
public:
	// example of simple map creation
	void createMap(int n);
untereiner's avatar
untereiner committed
145
    void createMapTets();
Sylvain Thery's avatar
Sylvain Thery committed
146
147
148
149
150
151
152
	void updateMap();
	void importMesh(std::string& filename);

public slots:
	void operation(int x);
	void svg();
	void width(int w);
153
154
155

	void clipping_onoff(bool x);
	void hide_onoff(bool x);
Sylvain Thery's avatar
Sylvain Thery committed
156
157
158
};

#endif