clipping.h 5.13 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
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

25 26
#ifndef __CLIPPING_H__
#define __CLIPPING_H__
27 28 29

#include <iostream>

30
#include "Utils/Qt/qtSimple.h"
31
#include "Utils/qtInputs.h"
32

33
#include "ui_clipping.h"
34
// inclure qtui.h juste après le ui_xxx.h
35
#include "Utils/qtui.h"
36 37

#include "Topology/generic/parameters.h"
38
#include "Topology/map/embeddedMap3.h"
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
#include "Geometry/bounding_box.h"

#include "Algo/Import/import.h"
//#include "Algo/Export/export.h"

#include "Algo/Geometry/boundingbox.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Algo/Render/GL2/topo3Render.h"
#include "Utils/Shaders/shaderSimpleColor.h"

#include "Utils/frameManipulator.h"

54
#include "Utils/clippingPresets.h"
55
#include "Utils/clippingPresetsAnimated.h"
56

57 58 59
#include "Utils/cgognStream.h"
#include "Utils/drawer.h"

untereiner's avatar
untereiner committed
60 61
#include "Algo/Modelisation/primitives3d.h"

62 63 64 65 66 67 68 69
#include <string>
#include <sstream>

using namespace CGoGN ;

struct PFP: public PFP_STANDARD
{
	// definition of the map
70
	typedef EmbeddedMap3 MAP;
71 72 73
};


74
class Clipping: public Utils::QT::SimpleQT
75 76 77 78 79
{
	Q_OBJECT

public:
	typedef PFP::MAP MAP;
80
	typedef PFP::VEC3 VEC3;
81 82 83

	//Manip Carte
	MAP myMap ;
84
	AttributeHandler<VEC3, VERTEX> position;
85 86 87 88 89 90 91 92 93
	Dart dglobal;

	//Render
	bool m_drawVertices;
	bool m_drawLines;
	bool m_drawFaces;
	bool m_drawTopo;

	Algo::Render::GL2::MapRender* m_render;
94
	Algo::Render::GL2::Topo3Render* m_render_topo;
95 96 97 98 99 100 101 102 103 104 105 106 107

	Geom::BoundingBox<PFP::VEC3> m_bb;

	Utils::VBO* m_positionVBO;

	Utils::ShaderSimpleColor* m_shader;

	Geom::Vec3f m_coeffTopoExplod;
	Geom::Vec3f gPosObj ;
	float gWidthObj ;

	//QT
	Utils::QT::uiDockInterface dock;
108
	QTimer *m_timer;
109

Maire Nicolas's avatar
Maire Nicolas committed
110
	// Picking
111 112 113
	Utils::LineDrawable* m_planeDrawable;
	Utils::LineDrawable* m_sphereDrawable;
	Utils::FrameManipulator* m_frameManipulator;
Maire Nicolas's avatar
Maire Nicolas committed
114 115 116
	unsigned int m_frameManipulatorPickedAxis;
	std::vector<Utils::Pickable*> m_pickablePlanes;
	std::vector<Utils::Pickable*> m_pickableSpheres;
117
	Utils::Pickable* m_lastPickedObject;
Maire Nicolas's avatar
Maire Nicolas committed
118
	int m_lastClickedX, m_lastClickedY;
119

120 121 122
	// Clipping
	Utils::ClippingPresetAnimated *m_lastAnimatedClippingPreset;

123
	Clipping();
124 125 126 127 128 129 130

	void initGUI();
	void cb_Open();
	void updateVBOprimitives(int upType);
	void cb_initGL();
	void cb_redraw();
	void cb_mousePress(int button, int x, int y);
Maire Nicolas's avatar
Maire Nicolas committed
131
	void cb_mouseMove(int buttons, int x, int y);
132 133
	void cb_keyPress(int code);
	void importMesh(std::string& filename);
134
	void updatePickables();
135 136 137 138 139 140 141 142 143 144 145 146 147

public slots:
	void slot_drawVertices(bool b);
	void slot_drawLines(bool b);
	void slot_drawFaces(bool b);
	void slot_drawTopo(bool b);

	void slot_explodTopoPhi1(double c);
	void slot_explodTopoPhi2(double c);
	void slot_explodTopoPhi3(double c);

	void slot_pushButton_addPlane();

148
	void slot_spinBox_GridResolution(int i);
149
	void slot_pushButton_changePlanesColor();
150 151 152

	void slot_pushButton_addSphere();

153
	void slot_spinBox_SphereResolution(int i);
154
	void slot_pushButton_changeSpheresColor();
155 156

	void slot_doubleSpinBox_ColorAttenuationFactor(double c);
157 158
	void slot_radioButton_ClippingMode(bool b);
	void slot_radioButton_ColorAttenuationMode(bool b);
159

160 161
	void slot_pushButton_deleteSelectedObject();

162 163 164 165 166 167
	void slot_pushButton_applyStaticClippingPreset();

	void slot_pushButton_applyAnimatedClippingPreset();
	void slot_pushButton_StopAnimation();
	void slot_doubleSpinBox_AnimatedClippingPresetSpeed(double c);

168 169
	void slot_setAnimationState(bool state);

170
	void slot_animationTimer();
171

172 173 174 175
	void button_compile();
};

#endif