Commit 5087f653 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

Merge branch 'master' of cgogn:~cgogn/CGoGN

parents 19816a41 b82bd2ed
......@@ -318,7 +318,6 @@ void Viewer::slot_drawNormals(bool b)
void Viewer::slot_normalsSize(int i)
{
normalScaleFactor = i / 50.0f ;
m_topoRender->updateData<PFP>(myMap, position, i / 100.0f, i / 100.0f) ;
updateGL() ;
}
......
......@@ -42,9 +42,24 @@ int main(int argc, char **argv)
// final show for redraw
sqt.show();
// and wait for the end
// QGLViewer* ptr = sqt.getQGLWidget();
return app.exec();
}
void MyQT::cb_keyPress(int keycode)
{
switch(keycode)
{
case 'c' :
getQGLWidget()->camera()->centerScene();
updateGL();
break;
default:
break;
}
}
void MyQT::createMap()
{
// creation of a new attribute on vertices of type 3D vector for position.
......@@ -70,6 +85,7 @@ void MyQT::createMap()
float lWidthObj = std::max<PFP::REAL>(std::max<PFP::REAL>(bb.size(0), bb.size(1)), bb.size(2));
Geom::Vec3f lPosObj = (bb.min() + bb.max()) / PFP::REAL(2);
show();
// send BB info to interface for centering on GL screen
setParamObject(lWidthObj, lPosObj.data());
......
......@@ -27,7 +27,8 @@
//#define USE_GMAP
#include "Utils/Qt/qtSimple.h"
//#include "Utils/Qt/qtSimple.h"
#include "Utils/Qt/qtQGLV.h"
#include "Utils/cgognStream.h"
#include "Topology/generic/parameters.h"
......@@ -59,7 +60,7 @@ struct PFP: public PFP_STANDARD
typedef PFP::MAP MAP;
typedef PFP::VEC3 VEC3;
class MyQT : public Utils::QT::SimpleQT
class MyQT : public Utils::QT::SimpleQGLV
{
Q_OBJECT
public:
......@@ -67,6 +68,7 @@ public:
void cb_redraw();
void cb_initGL();
void cb_keyPress(int keycode);
protected:
// declaration of the map
......
......@@ -300,7 +300,7 @@ int main(int argc, char **argv)
CGoGNout << "CGoGNOut dans la console" << Geom::Vec3f(2.5f, 2.2f, 4.3f) << CGoGNendl;
CGoGNout.toStatusBar(NULL);
CGoGNout.noStatusBar();
// bounding box
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
......
......@@ -104,13 +104,16 @@ ENDIF (WITH_ZINRI)
IF (WITH_QT)
add_definitions(-DWITH_QT)
find_package(Qt4 REQUIRED)
SET(QT_USE_QTCORE TRUE)
SET(QT_USE_QTOPENGL TRUE)
SET(QT_USE_QTSVG TRUE)
find_package(Qt4 REQUIRED)
SET(QT_USE_QTXML TRUE )
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
SET (CGoGN_EXT_INCLUDES ${CGoGN_EXT_INCLUDES} ${QT_INCLUDE_DIR})
SET (CGoGN_EXT_LIBS ${CGoGN_EXT_LIBS} ${QT_LIBRARIES} )
find_package(QGLViewer REQUIRED)
SET (CGoGN_EXT_INCLUDES ${CGoGN_EXT_INCLUDES} ${QT_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR} )
SET (CGoGN_EXT_LIBS ${CGoGN_EXT_LIBS} ${QT_LIBRARIES} ${QGLVIEWER_LIBRARIES} )
ENDIF (WITH_QT)
IF (WITH_GLEWMX)
......
......@@ -92,7 +92,9 @@ IF(WITH_QT)
utils_qt_headers
${CGoGN_ROOT_DIR}/include/Utils/Qt/qtgl.h
${CGoGN_ROOT_DIR}/include/Utils/Qt/qtSimple.h
${CGoGN_ROOT_DIR}/include/Utils/Qt/qtpopup.h
${CGoGN_ROOT_DIR}/include/Utils/Qt/qtQGLV_glw.h
${CGoGN_ROOT_DIR}/include/Utils/Qt/qtQGLV.h
${CGoGN_ROOT_DIR}/include/Utils/Qt/qtpopup.h
${CGoGN_ROOT_DIR}/include/Utils/Qt/qthistodraw.h
${CGoGN_ROOT_DIR}/include/Utils/Qt/qtcolorschooser.h
)
......
......@@ -90,7 +90,9 @@ IF(WITH_QT)
utils_qt_headers
${CGoGN_ROOT_DIR}/include/Utils/Qt/qtgl.h
${CGoGN_ROOT_DIR}/include/Utils/Qt/qtSimple.h
${CGoGN_ROOT_DIR}/include/Utils/Qt/qtpopup.h
${CGoGN_ROOT_DIR}/include/Utils/Qt/qtQGLV_glw.h
${CGoGN_ROOT_DIR}/include/Utils/Qt/qtQGLV.h
${CGoGN_ROOT_DIR}/include/Utils/Qt/qtpopup.h
${CGoGN_ROOT_DIR}/include/Utils/Qt/qthistodraw.h
${CGoGN_ROOT_DIR}/include/Utils/Qt/qtcolorschooser.h
)
......@@ -99,6 +101,17 @@ IF(WITH_QT)
SET (files_utils_withQt ${files_utils} ${files_utils_qt} ${UTILS_QT_HEADERS_MOC})
ENDIF (WITH_QT)
file( GLOB_RECURSE
files_geometry
${CGoGN_ROOT_DIR}/include/Geometry/*.h
${CGoGN_ROOT_DIR}/include/Geometry/*.hpp
)
file( GLOB_RECURSE
files_thirdParty
${CGoGN_ROOT_DIR}/ThirdParty/include/*.h
${CGoGN_ROOT_DIR}/ThirdParty/include/*.hpp
)
IF (ONELIB)
IF(WITH_QT)
......@@ -116,5 +129,7 @@ ELSE (ONELIB)
ELSE(WITH_QT)
add_library( utils ${files_utils} )
ENDIF (WITH_QT)
add_dependencies(utils shader_target )
add_custom_target( Geometry SOURCES ${files_geometry} )
add_custom_target( ThirdParty SOURCES ${files_thirdParty} )
add_dependencies( utils shader_target )
ENDIF (ONELIB)
......@@ -77,13 +77,17 @@ IF (WITH_ZINRI)
ENDIF (WITH_ZINRI)
IF (WITH_QT)
find_package(Qt4 REQUIRED)
add_definitions(-DWITH_QT)
find_package(Qt4 REQUIRED)
SET(QT_USE_QTCORE TRUE)
SET(QT_USE_QTOPENGL TRUE)
SET(QT_USE_QTSVG TRUE)
SET(QT_USE_QTXML TRUE )
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
SET (COMMON_INCLUDES ${COMMON_INCLUDES} ${QT_INCLUDE_DIR})
SET (COMMON_LIBS ${COMMON_LIBS} ${QT_LIBRARIES})
find_package(QGLViewer REQUIRED)
SET (COMMON_INCLUDES ${COMMON_INCLUDES} ${QT_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR})
SET (COMMON_LIBS ${COMMON_LIBS} ${QT_LIBRARIES} ${QGLVIEWER_LIBRARIES})
ENDIF (WITH_QT)
# qq definition specifiques pour mac
......
......@@ -111,8 +111,11 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
if (good_dart != NIL)
{
map.sewFaces(d, good_dart, false);
m.unmarkOrbit<EDGE>(d);
if ((d != map.phi2(d)) && (good_dart != map.phi2(good_dart)) )
{
map.sewFaces(d, good_dart, false);
m.unmarkOrbit<EDGE>(d);
}
}
else
{
......
This diff is collapsed.
/*******************************************************************************
* 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 __QTQGLVIEWER_GLW_H
#define __QTQGLVIEWER_GLW_H
#include <QApplication>
#include <QDesktopWidget>
#include <QMainWindow>
#include <QWidget>
#include <QtGui>
#include <GL/glew.h>
#include <QGLViewer/qglviewer.h>
#include <set>
#include <string>
#include "Geometry/vector_gen.h"
#include "Utils/gl_matrices.h"
namespace CGoGN { namespace Utils { class GLSLShader; } }
namespace CGoGN
{
namespace Utils
{
namespace QT
{
// forward definition
class SimpleQGLV;
class QGLView : public QGLViewer
{
Q_OBJECT
protected:
SimpleQGLV* m_sqgl;
int W;
int H;
int m_state_modifier;
public:
QGLView(SimpleQGLV* ptr, QWidget *parent = 0);
~QGLView();
void setObjectBB(float* bbmin, float* bbmax);
void setParamObject(float width, float* pos);
void glMousePosition(int& x, int& y);
virtual void init();
virtual void preDraw();
virtual void draw();
virtual void postDraw() {}
virtual void resizeGL(int width, int height);
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void mouseClickEvent(QMouseEvent* event);
// void mouseDoubleClickEvent(QMouseEvent* event);
// void mouseMoveEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent* event);
void keyReleaseEvent(QKeyEvent* event);
// void wheelEvent(QWheelEvent* event);
bool Shift() { return m_state_modifier & Qt::ShiftModifier; }
bool Control() { return m_state_modifier & Qt::ControlModifier; }
bool Alt() { return m_state_modifier & Qt::AltModifier; }
int getHeight() const { return H; }
int getWidth() const { return W; }
QSize minimumSizeHint() const;
QSize sizeHint() const;
};
} // namespace QT
} // namespace Utils
} // namespace CGoGN
#endif
......@@ -33,6 +33,7 @@
//forward definitions
namespace CGoGN { namespace Utils { namespace QT { class SimpleQT; } } }
namespace CGoGN { namespace Utils { namespace QT { class SimpleQGLV; } } }
class QTextEdit;
namespace CGoGN
......@@ -56,11 +57,13 @@ void allToFile(const std::string& filename);
* set all outputs to status bar of Qt interface
*/
void allToStatusBar(Utils::QT::SimpleQT* sqt);
void allToStatusBar(Utils::QT::SimpleQGLV* sqglv);
/**
* set all outputs to console of Qt interface
*/
void allToConsole(Utils::QT::SimpleQT* sqt);
void allToConsole(Utils::QT::SimpleQGLV* sqglv);
#endif
......@@ -92,9 +95,12 @@ protected:
#ifdef WITH_QT
Utils::QT::SimpleQT* m_sqt_bar;
Utils::QT::SimpleQT* m_sqt_console;
Utils::QT::SimpleQGLV* m_sqglv_bar;
Utils::QT::SimpleQGLV* m_sqglv_console;
QTextEdit* m_qte;
#endif
......@@ -126,15 +132,37 @@ public:
void toFile(const std::string& filename);
#ifdef WITH_QT
/**
* remove output to status bars
*/
void noStatusBar();
/**
* remove output to consoles
*/
void noConsole();
/**
* set output to status bar of Qt interface
*/
void toStatusBar(Utils::QT::SimpleQT* sqt);
void toStatusBar(Utils::QT::SimpleQT* sqt = NULL);
/**
* set output to console of Qt interface
*/
void toConsole(Utils::QT::SimpleQT* sqt);
void toConsole(Utils::QT::SimpleQT* sqt = NULL);
/**
* set output to status bar of Qt interface
*/
void toStatusBar(Utils::QT::SimpleQGLV* sqglv = NULL);
/**
* set output to console of Qt interface
*/
void toConsole(Utils::QT::SimpleQGLV* sqglv = NULL);
#endif
/**
......
......@@ -35,91 +35,91 @@ namespace Utils {
/**
* Create a ref to a type from a ref from another type
* No copy only casting. No need to used IN template parameter
* No copy only casting. No need to used T_IN template parameter
* @param vec input ref
* @ return a ref on same object with OUT type
* @ return a ref on same object with T_OUT type
*/
template <typename OUT, typename IN>
inline OUT& convertRef(IN& vec)
template <typename T_OUT, typename T_IN>
inline T_OUT& convertRef(T_IN& vec)
{
assert(sizeof(IN) == sizeof(OUT) || "incompatible size cast");
return *(reinterpret_cast<OUT*>(&vec));
assert(sizeof(T_IN) == sizeof(T_OUT) || "incompatible size cast");
return *(reinterpret_cast<T_OUT*>(&vec));
}
/**
* Create a const ref to a type from a const ref from another type
* No copy only casting. No need to used IN template parameter
* No copy only casting. No need to used T_IN template parameter
* @param vec input ref
* @ return a ref on same object with OUT type
* @ return a ref on same object with T_OUT type
*/
template <typename OUT, typename IN>
inline const OUT& convertRef(const IN& vec)
template <typename T_OUT, typename T_IN>
inline const T_OUT& convertRef(const T_IN& vec)
{
assert(sizeof(IN) == sizeof(OUT) || "incompatible size cast");
return *(reinterpret_cast<const OUT*>(&vec));
assert(sizeof(T_IN) == sizeof(T_OUT) || "incompatible size cast");
return *(reinterpret_cast<const T_OUT*>(&vec));
}
/**
* Create a ptr of a type from a ptr of another type
* Just a reinterpret cast in fact
* @param vec input ptr
* @return a ptr on same object with OUT type
* @return a ptr on same object with T_OUT type
*/
template <typename OUT, typename IN>
inline OUT* convertPtr(IN* vec)
template <typename T_OUT, typename T_IN>
inline T_OUT* convertPtr(T_IN* vec)
{
assert(sizeof(IN) == sizeof(OUT) || "incompatible size cast");
return reinterpret_cast<OUT*>(vec);
assert(sizeof(T_IN) == sizeof(T_OUT) || "incompatible size cast");
return reinterpret_cast<T_OUT*>(vec);
}
/**
* Create a const ptr of a type from a const ptr of another type
* Just a reinterpret cast in fact
* @param vec input ptr
* @return a ptr on same object with OUT type
* @return a ptr on same object with T_OUT type
*/
template <typename OUT, typename IN>
inline const OUT* convertPtr(const IN* vec)
template <typename T_OUT, typename T_IN>
inline const T_OUT* convertPtr(const T_IN* vec)
{
assert(sizeof(IN) == sizeof(OUT) || "incompatible size cast");
return reinterpret_cast<const OUT*>(vec);
assert(sizeof(T_IN) == sizeof(T_OUT) || "incompatible size cast");
return reinterpret_cast<const T_OUT*>(vec);
}
template <typename OUT, typename IN>
inline std::vector<OUT>& convertVector(std::vector<IN>& vec)
template <typename T_OUT, typename T_IN>
inline std::vector<T_OUT>& convertVector(std::vector<T_IN>& vec)
{
assert(sizeof(IN) == sizeof(OUT) || "incompatible size cast");
return *(reinterpret_cast< std::vector<OUT>* >(&vec));
assert(sizeof(T_IN) == sizeof(T_OUT) || "incompatible size cast");
return *(reinterpret_cast< std::vector<T_OUT>* >(&vec));
}
template <typename OUT, typename IN>
inline const std::vector<OUT>& convertVector(const std::vector<IN>& vec)
template <typename T_OUT, typename T_IN>
inline const std::vector<T_OUT>& convertVector(const std::vector<T_IN>& vec)
{
assert(sizeof(IN) == sizeof(OUT) || "incompatible size cast");
return *(reinterpret_cast< const std::vector<OUT>* >(&vec));
assert(sizeof(T_IN) == sizeof(T_OUT) || "incompatible size cast");
return *(reinterpret_cast< const std::vector<T_OUT>* >(&vec));
}
template <typename OUT, typename IN>
inline const std::list<OUT>& convertList(const std::list<IN>& vec)
template <typename T_OUT, typename T_IN>
inline const std::list<T_OUT>& convertList(const std::list<T_IN>& vec)
{
assert(sizeof(IN) == sizeof(OUT) || "incompatible size cast");
return *(reinterpret_cast< const std::list<OUT>* >(&vec));
assert(sizeof(T_IN) == sizeof(T_OUT) || "incompatible size cast");
return *(reinterpret_cast< const std::list<T_OUT>* >(&vec));
}
template <typename OUT, typename IN>
inline std::list<OUT>& convertList(std::list<IN>& vec)
template <typename T_OUT, typename T_IN>
inline std::list<T_OUT>& convertList(std::list<T_IN>& vec)
{
assert(sizeof(IN) == sizeof(OUT) || "incompatible size cast");
return *(reinterpret_cast< std::list<OUT>* >(&vec));
assert(sizeof(T_IN) == sizeof(T_OUT) || "incompatible size cast");
return *(reinterpret_cast< std::list<T_OUT>* >(&vec));
}
......
This diff is collapsed.
/*******************************************************************************
* 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 *
* *
*******************************************************************************/
#include "Utils/GLSLShader.h"
#include "Utils/Qt/qtQGLV.h"
#include "glm/gtc/matrix_transform.hpp"
#include "glm/gtc/type_precision.hpp"
#include "glm/gtc/type_ptr.hpp"
#include <QtGui/QTextEdit>
#include <QImage>
namespace CGoGN
{
namespace Utils
{
namespace QT
{
QGLView::QGLView(SimpleQGLV* ptr, QWidget *parent):
QGLViewer(parent),
m_sqgl(ptr),m_state_modifier(0)
{
}
QGLView::~QGLView()
{
}
void QGLView::setParamObject(float width, float* pos)
{
qglviewer::Vec bbMin(pos[0]-width/2.0f, pos[1]-width/2.0f, pos[2]-width/2.0f);
qglviewer::Vec bbMax(pos[0]+width/2.0f, pos[1]+width/2.0f, pos[2]+width/2.0f);
camera()->setSceneBoundingBox(bbMin, bbMax);
camera()->showEntireScene();
}
void QGLView::setObjectBB(float* bbmin, float* bbmax)
{
qglviewer::Vec bbMin(bbmin[0], bbmin[1], bbmin[2]);
qglviewer::Vec bbMax(bbmax[0], bbmax[1], bbmax[2]);
camera()->setSceneBoundingBox(bbMin, bbMax);
camera()->showEntireScene();
}
QSize QGLView::minimumSizeHint() const
{
return QSize(200, 200);
}
QSize QGLView::sizeHint() const
{
return QSize(500, 500);
}
void QGLView::init()
{
glewInit();
if (m_sqgl)
m_sqgl->cb_initGL();
}
void QGLView::preDraw()
{
GLdouble gl_mvm[16];
camera()->getModelViewMatrix(gl_mvm);
glm::mat4& mvm = m_sqgl->modelViewMatrix();
for(unsigned int i = 0; i < 4; ++i)
{
for(unsigned int j = 0; j < 4; ++j)
mvm[i][j] = (float)gl_mvm[i*4+j];
}
GLdouble gl_pm[16];
camera()->getProjectionMatrix(gl_pm);
glm::mat4& pm = m_sqgl->projectionMatrix();
for(unsigned int i = 0; i < 4; ++i)
{
for(unsigned int j = 0; j < 4; ++j)
pm[i][j] = (float)gl_pm[i*4+j];
}
m_sqgl->cb_updateMatrix();
}
void QGLView::draw()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (m_sqgl)
{
Utils::GLSLShader::s_current_matrices = m_sqgl->matricesPtr();
m_sqgl->cb_redraw();
}
}
void QGLView::resizeGL(int w, int h)
{
W = w;
H = h;
QGLViewer::resizeGL(w,h);
}
void QGLView::keyPressEvent(QKeyEvent* event)
{
QGLViewer::keyPressEvent(event);
if (m_sqgl)
{
m_state_modifier = event->modifiers();
int k = event->key();
if ( (k >= 65) && (k <= 91) && !(m_state_modifier & Qt::ShiftModifier) )
k += 32;
m_sqgl->cb_keyPress(k);
}
}
void QGLView::keyReleaseEvent(QKeyEvent* event)
{
QGLViewer::keyReleaseEvent(event);
if (m_sqgl)
{
m_state_modifier = event->modifiers();
int k = event->key();
if ( (k >= 65) && (k <= 91) && !(m_state_modifier & Qt::ShiftModifier) )
k += 32;
m_sqgl->cb_keyRelease(k);
}
}
void QGLView::mousePressEvent(QMouseEvent* event)
{
// beginx = event->x();
// beginy = event->y();
// clickPoint = event->pos();
// m_current_button = event->button();
if (m_sqgl)
m_sqgl->cb_mousePress(event->button(), event->x(), getHeight() - event->y());
QGLViewer::mousePressEvent(event);
}
void QGLView::mouseReleaseEvent(QMouseEvent* event)
{
if (m_sqgl)
m_sqgl->cb_mouseRelease(event->button(), event->x(), getHeight() - event->y());
QGLViewer::mouseReleaseEvent(event);
}
void QGLView::mouseClickEvent(QMouseEvent* event)
{
if (m_sqgl)
m_sqgl->cb_mouseClick(event->button(), event->x(), getHeight() - event->y());
}