Commit 71167cef authored by Thomas Jund's avatar Thomas Jund

particleCell2D : namespace conflict solved

parents 8926d5b5 549ab145
......@@ -320,7 +320,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
......
......@@ -301,7 +301,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.toStatusBar(NULL);
// bounding box
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
......
......@@ -33,6 +33,8 @@ find_package(Boost COMPONENTS regex thread system REQUIRED)
find_package(ZLIB REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(GLEW REQUIRED)
find_package(SuiteSparse REQUIRED)
find_package(QGLViewer REQUIRED)
IF (DEFINED ASSERTON)
add_definitions(-DCGOGN_ASSERT_BOOL=${ASSERTON})
......@@ -72,11 +74,12 @@ SET (CGoGN_EXT_INCLUDES
${ZLIB_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
${QGLVIEWER_INCLUDE_DIR}
)
# define libs for external libs
SET (CGoGN_EXT_LIBS
nl
${OPENGL_LIBRARY}
${GLEW_LIBRARIES}
${ZLIB_LIBRARIES}
......@@ -84,6 +87,8 @@ SET (CGoGN_EXT_LIBS
${Boost_SYSTEM_LIBRARY}
${Boost_REGEX_LIBRARY}
${Boost_THREAD_LIBRARY}
${SUITESPARSE_LIBRARIES}
${QGLVIEWER_LIBRARIES}
)
#optionnal libs
......@@ -101,9 +106,11 @@ 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})
......
......@@ -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)
......@@ -6,6 +6,7 @@ ADD_SUBDIRECTORY(differentialProperties)
ADD_SUBDIRECTORY(render)
ADD_SUBDIRECTORY(renderVector)
ADD_SUBDIRECTORY(renderExplod)
ADD_SUBDIRECTORY(renderTopoSurface)
ADD_SUBDIRECTORY(subdivideSurface)
ADD_SUBDIRECTORY(surfaceDeformation)
#ADD_SUBDIRECTORY(renderTopoSurface)
......@@ -67,41 +67,6 @@
<string>Computed attributes</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Kmax :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Existing attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_KmaxAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
......@@ -116,16 +81,6 @@
</item>
</layout>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="check_KmaxCreateVBO">
<property name="text">
<string>create VBO</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="font">
......@@ -175,16 +130,6 @@
</item>
</layout>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="check_kmaxCreateVBO">
<property name="text">
<string>create VBO</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="font">
......@@ -234,16 +179,6 @@
</item>
</layout>
</item>
<item row="2" column="3">
<widget class="QCheckBox" name="check_KminCreateVBO">
<property name="text">
<string>create VBO</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_13">
<property name="font">
......@@ -293,16 +228,6 @@
</item>
</layout>
</item>
<item row="3" column="3">
<widget class="QCheckBox" name="check_kminCreateVBO">
<property name="text">
<string>create VBO</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_15">
<property name="font">
......@@ -352,16 +277,41 @@
</item>
</layout>
</item>
<item row="4" column="3">
<widget class="QCheckBox" name="check_KnormalCreateVBO">
<property name="text">
<string>create VBO</string>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="checked">
<bool>true</bool>
<property name="text">
<string>Kmax :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Existing attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_KmaxAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>447</width>
<height>311</height>
<width>472</width>
<height>276</height>
</rect>
</property>
<property name="windowTitle">
......@@ -75,16 +75,6 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="check_createVBO">
<property name="text">
<string>create VBO</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -28,8 +28,6 @@ public slots:
void addMapToList(MapHandlerGen* m);
void removeMapFromList(MapHandlerGen* m);
void addAttributeToList(unsigned int orbit, const QString& nameAttr);
void attributeModified(unsigned int orbit, QString nameAttr);
};
} // namespace SCHNApps
......
......@@ -38,18 +38,21 @@ public:
virtual void wheelEvent(View* view, QWheelEvent* event) {}
public slots:
void mapAdded(MapHandlerGen* map);
void mapRemoved(MapHandlerGen* map);
void attributeModified(unsigned int orbit, QString nameAttr);
void openComputeNormalDialog();
void openComputeCurvatureDialog();
void computeNormalFromDialog();
void computeCurvatureFromDialog();
void computeNormal(
const QString& mapName,
void computeNormal(const QString& mapName,
const QString& positionAttributeName = "position",
const QString& normalAttributeName = "normal",
bool createNormalVBO = true
);
bool autoUpdate = true);
void computeCurvature(
const QString& mapName,
const QString& positionAttributeName = "position",
......@@ -59,11 +62,7 @@ public slots:
const QString& KminAttributeName = "Kmin",
const QString& kminAttributeName = "kmin",
const QString& KnormalAttributeName = "Knormal",
bool createKmaxVBO = true,
bool createkmaxVBO = true,
bool createKminVBO = true,
bool createkminVBO = true,
bool createKnormalVBO = true
bool autoUpdate = true
);
private:
......@@ -76,11 +75,36 @@ private:
struct ComputeNormalParameters
{
ComputeNormalParameters() {}
ComputeNormalParameters(QString p, QString n) : positionName(p), normalName(n) {}
ComputeNormalParameters(const QString& p, const QString& n, bool update) :
positionName(p), normalName(n), autoUpdate(update)
{}
QString positionName;
QString normalName;
bool autoUpdate;
};
QHash<QString, ComputeNormalParameters> computeNormalLastParameters;
struct ComputeCurvatureParameters
{
ComputeCurvatureParameters() {}
ComputeCurvatureParameters(
const QString& p, const QString& n,
const QString& Kmax, const QString& kmax, const QString& Kmin, const QString& kmin, const QString& Knormal,
bool update) :
positionName(p), normalName(n),
KmaxName(Kmax), kmaxName(kmax), KminName(Kmin), kminName(kmin), KnormalName(Knormal),
autoUpdate(update)
{}
QString positionName;
QString normalName;
QString KmaxName;
QString kmaxName;
QString KminName;
QString kminName;
QString KnormalName;
bool autoUpdate;
};
QHash<QString, ComputeCurvatureParameters> computeCurvatureLastParameters;
};
#endif
......@@ -105,15 +105,6 @@ void ComputeNormalDialog::addAttributeToList(unsigned int orbit, const QString&
}
}
void ComputeNormalDialog::attributeModified(unsigned int orbit, QString nameAttr)
{
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
// if(orbit == VERTEX && nameAttr == )
// {
// }
}
} // namespace SCHNApps
} // namespace CGoGN
......@@ -25,9 +25,36 @@ bool DifferentialPropertiesPlugin::enable()
connect(m_computeCurvatureDialog, SIGNAL(accepted()), this, SLOT(computeCurvatureFromDialog()));
connect(m_computeCurvatureDialog->button_apply, SIGNAL(clicked()), this, SLOT(computeCurvatureFromDialog()));
connect(m_window, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
connect(m_window, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
return true;
}
void DifferentialPropertiesPlugin::mapAdded(MapHandlerGen *map)
{
connect(map, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString)));
}
void DifferentialPropertiesPlugin::mapRemoved(MapHandlerGen *map)
{
disconnect(map, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString)));
}
void DifferentialPropertiesPlugin::attributeModified(unsigned int orbit, QString nameAttr)
{
if(orbit == VERTEX)
{
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
if(computeNormalLastParameters.contains(map->getName()))
{
ComputeNormalParameters& params = computeNormalLastParameters[map->getName()];
if(params.positionName == nameAttr && params.autoUpdate)
computeNormal(map->getName(), params.positionName, params.normalName);
}
}
}
void DifferentialPropertiesPlugin::openComputeNormalDialog()
{
m_computeNormalDialog->show();
......@@ -46,15 +73,16 @@ void DifferentialPropertiesPlugin::computeNormalFromDialog()
const QString& mapName = currentItems[0]->text();
QString positionName = m_computeNormalDialog->combo_positionAttribute->currentText();
QString normalName;
if(m_computeNormalDialog->normalAttributeName->text().isEmpty())
normalName = m_computeNormalDialog->combo_normalAttribute->currentText();
else
normalName = m_computeNormalDialog->normalAttributeName->text();
bool createVBO = (m_computeNormalDialog->check_createVBO->checkState() == Qt::Checked);
bool autoUpdate = (currentItems[0]->checkState() == Qt::Checked);
computeNormal(mapName, positionName, normalName, createVBO);
computeNormal(mapName, positionName, normalName, autoUpdate);
}
}
......@@ -98,19 +126,13 @@ void DifferentialPropertiesPlugin::computeCurvatureFromDialog()
else
KnormalName = m_computeCurvatureDialog->KnormalAttributeName->text();
bool KmaxVBO = (m_computeCurvatureDialog->check_KmaxCreateVBO->checkState() == Qt::Checked);
bool kmaxVBO = (m_computeCurvatureDialog->check_kmaxCreateVBO->checkState() == Qt::Checked);
bool KminVBO = (m_computeCurvatureDialog->check_KminCreateVBO->checkState() == Qt::Checked);
bool kminVBO = (m_computeCurvatureDialog->check_kminCreateVBO->checkState() == Qt::Checked);
bool KnormalVBO = (m_computeCurvatureDialog->check_KnormalCreateVBO->checkState() == Qt::Checked);
bool autoUpdate = (currentItems[0]->checkState() == Qt::Checked);
computeCurvature(
mapName, positionName, normalName, KmaxName, kmaxName, KminName, kminName, KnormalName,
KmaxVBO, kmaxVBO, KminVBO, kminVBO, KnormalVBO
mapName,
positionName, normalName,
KmaxName, kmaxName, KminName, kminName, KnormalName,
autoUpdate
);
}
}
......@@ -119,7 +141,7 @@ void DifferentialPropertiesPlugin::computeNormal(
const QString& mapName,
const QString& positionAttributeName,
const QString& normalAttributeName,
bool createNormalVBO)
bool autoUpdate)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapName));
if(mh == NULL)
......@@ -136,15 +158,12 @@ void DifferentialPropertiesPlugin::computeNormal(
PFP2::MAP* map = mh->getMap();
Algo::Surface::Geometry::computeNormalVertices<PFP2>(*map, position, normal);
if(createNormalVBO)
mh->createVBO(normal);
computeNormalLastParameters[mapName] =
ComputeNormalParameters(positionAttributeName, normalAttributeName) ;
ComputeNormalParameters(positionAttributeName, normalAttributeName, autoUpdate);
QList<View*> views = mh->getLinkedViews();
foreach(View* view, views)
view->updateGL();
mh->createVBO(normal);
mh->notifyAttributeModification(normal);
}
void DifferentialPropertiesPlugin::computeCurvature(
......@@ -156,11 +175,7 @@ void DifferentialPropertiesPlugin::computeCurvature(
const QString& KminAttributeName,
const QString& kminAttributeName,
const QString& KnormalAttributeName,
bool createKmaxVBO,
bool createkmaxVBO,
bool createKminVBO,
bool createkminVBO,
bool createKnormalVBO)
bool autoUpdate)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapName));
if(mh == NULL)
......@@ -202,15 +217,23 @@ void DifferentialPropertiesPlugin::computeCurvature(
Algo::Surface::Geometry::computeAnglesBetweenNormalsOnEdges<PFP2>(*map, position, edgeAngle);
Algo::Surface::Geometry::computeCurvatureVertices_NormalCycles_Projected<PFP2>(*map, 0.02f * mh->getBBdiagSize(), position, normal, edgeAngle, kmax, kmin, Kmax, Kmin, Knormal);
if(createKmaxVBO) mh->createVBO(Kmax);
if(createkmaxVBO) mh->createVBO(kmax);
if(createKminVBO) mh->createVBO(Kmin);
if(createkminVBO) mh->createVBO(kmin);
if(createKnormalVBO) mh->createVBO(Knormal);
QList<View*> views = mh->getLinkedViews();
foreach(View* view, views)
view->updateGL();
computeCurvatureLastParameters[mapName] =
ComputeCurvatureParameters(
positionAttributeName, normalAttributeName,
KmaxAttributeName, kmaxAttributeName, KminAttributeName, kminAttributeName, KnormalAttributeName,
autoUpdate);
mh->createVBO(Kmax);
mh->createVBO(kmax);
mh->createVBO(Kmin);
mh->createVBO(kmin);
mh->createVBO(Knormal);
mh->notifyAttributeModification(Kmax);
mh->notifyAttributeModification(kmax);
mh->notifyAttributeModification(Kmin);
mh->notifyAttributeModification(kmin);
mh->notifyAttributeModification(Knormal);
}
#ifndef DEBUG
......
......@@ -4,9 +4,11 @@
#include "plugin.h"
using namespace CGoGN;
using namespace SCHNApps;
namespace CGoGN
{
namespace SCHNApps
{
class ImportSurfacePlugin : public Plugin
{
......@@ -42,4 +44,8 @@ private:
QAction* importAction;
};
} // namespace SCHNApps
} // namespace CGoGN
#endif
......@@ -7,6 +7,12 @@
#include <QFileDialog>
#include <QFileInfo>
namespace CGoGN
{
namespace SCHNApps
{
bool ImportSurfacePlugin::enable()
{
importAction = new QAction("import", this);
......@@ -30,12 +36,15 @@ MapHandlerGen* ImportSurfacePlugin::importFromFile(const QString& fileName)
Algo::Surface::Import::importMesh<PFP2>(*map, fileName.toStdString(), attrNames);
// get vertex position attribute
VertexAttribute<PFP2::VEC3> position = map->getAttribute<PFP2::VEC3, CGoGN::VERTEX>(attrNames[0]);
mh->registerAttribute<PFP2::VEC3, VERTEX>(position);
VertexAttribute<PFP2::VEC3> position = map->getAttribute<PFP2::VEC3, VERTEX>(attrNames[0]);
mh->registerAttribute(position);
// create VBO for vertex position attribute
// create position VBO
mh->createVBO(position);
// update corresponding VBO & emit attribute update signal
mh->notifyAttributeModification(position);
// compute map bounding box
mh->updateBB(position);
}
......@@ -56,3 +65,7 @@ Q_EXPORT_PLUGIN2(ImportSurfacePlugin, ImportSurfacePlugin)
#else
Q_EXPORT_PLUGIN2(ImportSurfacePluginD, ImportSurfacePlugin)
#endif
} // namespace SCHNApps
} // namespace CGoGN