tuto_oper3.h 4.29 KB
Newer Older
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 28 29 30 31 32 33 34 35 36 37 38 39
/*******************************************************************************
* 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_

//#define USE_GMAP


#include "Topology/generic/parameters.h"

#ifdef USE_GMAP
	#include "Topology/gmap/embeddedGMap3.h"
#else
	#include "Topology/map/embeddedMap3.h"
#endif

#include "Algo/Render/GL2/topo3Render.h"
40
#include "Algo/Geometry/boundingbox.h"
41 42

#include "ui_tuto_oper3.h"
43
#include "Utils/Qt/qtui.h"
44 45
#include "Utils/Qt/qtSimple.h"
#include "Utils/cgognStream.h"
46
#include "Utils/frameManipulator.h"
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64


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
#ifdef USE_GMAP
	typedef EmbeddedGMap3 MAP;
#else
	typedef EmbeddedMap3 MAP;
#endif
};

65 66
typedef PFP::MAP MAP ;
typedef PFP::VEC3 VEC3 ;
67 68 69 70 71 72


class MyQT: public Utils::QT::SimpleQT
{
	Q_OBJECT
public:
73
	MyQT():nb(myMap),m_render_topo(NULL),m_selected(NIL),m_selected2(NIL),dm(myMap),m_shift(0.01f),m_ex1(0.9f),m_ex2(0.9f),m_ex3(0.9f), clip_volume(true) , hide_clipping(false) {}
74 75 76 77

	void cb_redraw();
	void cb_initGL();
	void cb_mousePress(int button, int x, int y);
78 79
	void cb_mouseRelease(int button, int x, int y);
	void cb_mouseMove(int button, int x, int y);
80 81 82 83 84 85 86 87
	void cb_keyPress(int code);
	void cb_Open();
	void cb_Save();

	Utils::QT::uiDockInterface dock;

protected:
	// declaration of the map
88
	MAP myMap;
89

90
	VertexAttribute<VEC3> position;
91 92 93

	SelectorDartNoBoundary<PFP::MAP> nb;

94 95
	Geom::BoundingBox<PFP::VEC3> bb;

96 97 98 99 100 101 102 103
	// render (for the topo)
	Algo::Render::GL2::Topo3Render* m_render_topo;
	Dart m_selected;
	Dart m_selected2;
	std::vector<Dart> m_selecteds;
	DartMarker dm;
	float m_shift;

104
	float m_ex1, m_ex2, m_ex3;
105

106 107 108 109 110 111 112 113 114 115 116
	// 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;
	int clip_id1;
	int clip_id2;

117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
	// just for more compact writing
	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);}
	template<int X>
	Dart PHI(Dart d)	{return myMap.phi<X>(d);}

public:
	// example of simple map creation
	void createMap(int n);
	void updateMap();
	void importMesh(std::string& filename);

public slots:
	void operation(int x);
	void svg();
	void width(int w);
135 136 137

	void clipping_onoff(bool x);
	void hide_onoff(bool x);
138 139 140
};

#endif