Commit 0db0b7b1 authored by Sylvain Thery's avatar Sylvain Thery

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

parents 4e02ea52 81df0944
......@@ -146,6 +146,7 @@ IF(WIN32)
# set(CMAKE_CONFIGURATION_TYPES "Release Debug" CACHE STRING "Only Release or Debug" FORCE)
ELSE(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC")
add_subdirectory(Release)
add_subdirectory(Debug)
add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps)
......
......@@ -8,12 +8,15 @@ SET( QT_USE_QTDESIGNER TRUE )
SET( QT_USE_QTGUI TRUE )
SET( QT_USE_QTPLUGIN TRUE )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC")
#========CGoGN========#
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/.. CACHE STRING "CGoGN root dir")
INCLUDE(${CGoGN_ROOT_DIR}/apps_cmake.txt)
find_package(Qt4 REQUIRED)
#=======QGLViewer=========#
find_package(QGLViewer REQUIRED)
......
......@@ -20,34 +20,49 @@ INCLUDE_DIRECTORIES(
file(
GLOB
SCHNApps_SRC_FILES
${SCHNApps_ROOT_DIR}/src/camera.cpp
${SCHNApps_ROOT_DIR}/src/context.cpp
${SCHNApps_ROOT_DIR}/src/main.cpp
${SCHNApps_ROOT_DIR}/src/interface/*.cpp
${SCHNApps_ROOT_DIR}/src/visualization/*.cpp
${SCHNApps_ROOT_DIR}/src/dialogs/*.cpp
${SCHNApps_ROOT_DIR}/src/mapHandler.cpp
${SCHNApps_ROOT_DIR}/src/plugin.cpp
${SCHNApps_ROOT_DIR}/src/splitArea.cpp
${SCHNApps_ROOT_DIR}/src/system.cpp
${SCHNApps_ROOT_DIR}/src/view.cpp
${SCHNApps_ROOT_DIR}/src/window.cpp
${SCHNApps_ROOT_DIR}/src/viewButtonArea.cpp
${SCHNApps_ROOT_DIR}/src/viewSelector.cpp
${SCHNApps_ROOT_DIR}/src/cameraDialog.cpp
${SCHNApps_ROOT_DIR}/src/pluginDialog.cpp
${SCHNApps_ROOT_DIR}/src/cameraViewDialog.cpp
${SCHNApps_ROOT_DIR}/src/pluginsViewDialog.cpp
${SCHNApps_ROOT_DIR}/src/mapsViewDialog.cpp
)
SET(SCHNApps_H_OBJECT_FILES
${SCHNApps_ROOT_DIR}/include/interface/window.h
${SCHNApps_ROOT_DIR}/include/interface/system.h
${SCHNApps_ROOT_DIR}/include/interface/viewButtonArea.h
${SCHNApps_ROOT_DIR}/include/interface/splitArea.h
${SCHNApps_ROOT_DIR}/include/visualization/view.h
${SCHNApps_ROOT_DIR}/include/visualization/scene.h
${SCHNApps_ROOT_DIR}/include/dialogs/newSceneDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/sceneSelector.h
${SCHNApps_ROOT_DIR}/include/dialogs/cameraViewDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/cameraOptionDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/cameraSceneDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/globalCameraDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/pluginDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/linkViewDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/mapPluginDialog.h
${SCHNApps_ROOT_DIR}/include/camera.h
${SCHNApps_ROOT_DIR}/include/mapHandler.h
${SCHNApps_ROOT_DIR}/include/plugin.h
${SCHNApps_ROOT_DIR}/include/splitArea.h
${SCHNApps_ROOT_DIR}/include/view.h
${SCHNApps_ROOT_DIR}/include/window.h
${SCHNApps_ROOT_DIR}/include/viewButtonArea.h
${SCHNApps_ROOT_DIR}/include/viewSelector.h
${SCHNApps_ROOT_DIR}/include/cameraDialog.h
${SCHNApps_ROOT_DIR}/include/pluginDialog.h
${SCHNApps_ROOT_DIR}/include/cameraViewDialog.h
${SCHNApps_ROOT_DIR}/include/pluginsViewDialog.h
${SCHNApps_ROOT_DIR}/include/mapsViewDialog.h
)
file(
GLOB
SCHNApps_FORM_FILES
${SCHNApps_ROOT_DIR}/forms/*.ui
${SCHNApps_ROOT_DIR}/forms/window.ui
${SCHNApps_ROOT_DIR}/forms/cameraDialog.ui
${SCHNApps_ROOT_DIR}/forms/pluginDialog.ui
${SCHNApps_ROOT_DIR}/forms/cameraViewDialog.ui
${SCHNApps_ROOT_DIR}/forms/pluginsViewDialog.ui
${SCHNApps_ROOT_DIR}/forms/mapsViewDialog.ui
)
QT4_WRAP_UI( UI_H_FILES
......
......@@ -7,17 +7,17 @@ INCLUDE_DIRECTORIES(
)
SET( FIRSTPLUGIN_PLUGIN_SRC
${SCHNApps_ROOT_DIR}/src/plugins/visualPlugin.cpp
${SCHNApps_ROOT_DIR}/Plugins/firstPlugin/src/firstPlugin.cpp
)
SET( FIRSTPLUGIN_PLUGIN_H
${SCHNApps_ROOT_DIR}/include/plugins/visualPlugin.h
${SCHNApps_ROOT_DIR}/Plugins/firstPlugin/include/firstPlugin.h
)
IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
ADD_DEFINITIONS(-DDEBUG)
IF(WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ELSE (WIN32)
......
#ifndef _FIRSTPLUGIN_H_
#define _FIRSTPLUGIN_H_
#include "plugins/visualPlugin.h"
#include "plugin.h"
/**---CGoGN includes **/
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Algo/Render/GL2/topoRender.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderFlat.h"
/**---CGoGN includes **/
/**---Definitions specific to CGoGN ---*/
......@@ -36,12 +37,9 @@ typedef PFP::VEC3 VEC3;
*/
/**
* Our plugin must inherit from VisualPlugin,
* that is a class that itself is an implementation
* of the Plugin interface (virtual class). It contains
* many useful and essantial methods.
* Our plugin must inherit from Plugin
*/
class FirstPlugin : public VisualPlugin
class FirstPlugin : public Plugin
{
/**
* Essential Qt macros.
......@@ -50,70 +48,50 @@ class FirstPlugin : public VisualPlugin
Q_INTERFACES(Plugin)
public:
FirstPlugin() {}
~FirstPlugin() {}
FirstPlugin()
{
setProvidesRendering(true);
}
/**
* The classical call back for the initGL method
* When a scene will be link to this plugin, it will call
* back this method with itself as a parameter.
*/
void cb_initGL(Scene *scene);
~FirstPlugin()
{}
/**
* The drawing method that needs to be overloaded.
* Each time a scene (that is to say, at least one of the
* views that is contains) needs to be refresh, it calls back
* this method with itself as a parameter
*/
void cb_redraw(Scene *scene);
/**
* The plugin's activation method
* The plugin's enable method
* Each time the main application loads this plugin,
* it call this method. Writing this method is
* the occasion to initialize the plugin and check certain
* conditions.
* If this methods return 'false', the plugin load will be aborted.
*/
bool activate();
bool enable();
/**
* The plugin's disabling method
* The plugin's disable method
* Each time the main application will unload the plugin
* it will call this method.
*/
void disable();
protected:
/** Attributes that are specific to this plugin **/
MAP myMap;
virtual void redraw(View *view);
// attribute for vertices positions
VertexAttribute<VEC3> position;
virtual void keyPress(View* view, int key) {}
virtual void keyRelease(View* view, int key) {}
virtual void mousePress(View* view, int button, int x, int y) {}
virtual void mouseRelease(View* view, int button, int x, int y) {}
// virtual void mouseClick(View* view, int button, int x, int y) {}
virtual void mouseMove(View* view, int buttons, int x, int y) {}
virtual void wheelEvent(View* view, int delta, int x, int y) {}
// render (for the topo)
Algo::Render::GL2::TopoRender *m_render_topo;
virtual void viewAdded(View* view);
virtual void viewRemoved(View* view) {}
// 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);
}
template<int X>
Dart PHI(Dart d)
{
return myMap.phi<X>(d);
}
/** Attributes that are specific to this plugin **/
protected:
MAP myMap;
VertexAttribute<VEC3> position;
Algo::Render::GL2::MapRender* m_render ;
Utils::VBO* m_positionVBO ;
Utils::ShaderFlat* m_flatShader ;
};
#endif // _FIRSTPLUGIN_H_
#include "firstPlugin.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Import/import.h"
void FirstPlugin::cb_initGL(Scene *scene)
bool FirstPlugin::enable()
{
if (scene)
{
// we fit the first (possibly the only) view of the newly liked
// scene to the content of our map
m_render = new Algo::Render::GL2::MapRender() ;
m_positionVBO = new Utils::VBO() ;
m_flatShader = new Utils::ShaderFlat() ;
m_flatShader->setAttributePosition(m_positionVBO) ;
m_flatShader->setAmbiant(Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f)) ;
m_flatShader->setDiffuse(Geom::Vec4f(0.8f, 0.9f, 0.7f, 1.0f)) ;
m_flatShader->setExplode(1.0f) ;
CGoGN::Utils::GLSLShader::registerShader(NULL, m_flatShader) ;
// bounding box of scene
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
std::vector<std::string> attrNames ;
CGoGN::Algo::Import::importMesh<PFP>(myMap, "/home/kraemer/Media/Data/surface/lowRes/duck_163.ply", attrNames);
position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]) ;
scene->firstViewFitSphere(bb.center()[0], bb.center()[1], bb.center()[2], bb.maxSize());
m_render->initPrimitives<PFP>(myMap, allDarts, CGoGN::Algo::Render::GL2::POINTS) ;
m_render->initPrimitives<PFP>(myMap, allDarts, CGoGN::Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, allDarts, CGoGN::Algo::Render::GL2::TRIANGLES) ;
m_render_topo = new Algo::Render::GL2::TopoRender() ;
m_positionVBO->updateData(position) ;
// render the topo of the map without boundary darts
SelectorDartNoBoundary<PFP::MAP> nb(myMap);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, nb);
}
return true;
}
void FirstPlugin::cb_redraw(Scene *scene)
void FirstPlugin::disable()
{
m_render_topo->drawTopo();
}
bool FirstPlugin::activate()
void FirstPlugin::redraw(View* view)
{
// creation of 2 new faces: 1 triangle and 1 square
Dart d1 = myMap.newFace(3);
Dart d2 = myMap.newFace(4);
// sew these faces along one of their edge
myMap.sewFaces(d1, d2);
// creation of a new attribute on vertices of type 3D vector for position.
// a handler to this attribute is returned
position = myMap.addAttribute<VEC3, VERTEX>("position");
// affect position by moving in the map
position[d1] = VEC3(0, 0, 0);
position[PHI1(d1)] = VEC3(2, 0, 0);
position[PHI_1(d1)] = VEC3(1, 2, 0);
position[PHI<11>(d2)] = VEC3(0, -2, 0);
position[PHI_1(d2)] = VEC3(2, -2, 0);
m_render_topo = NULL;
return true;
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) ;
glEnable(GL_LIGHTING) ;
m_render->draw(m_flatShader, Algo::Render::GL2::TRIANGLES) ;
}
void FirstPlugin::disable()
void FirstPlugin::viewAdded(View* view)
{
if (m_render_topo)
{
delete m_render_topo;
}
CGoGN::Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
qglviewer::Vec min(bb.min()[0], bb.min()[1], bb.min()[2]);
qglviewer::Vec max(bb.max()[0], bb.max()[1], bb.max()[2]);
view->setSceneBoundingBox(min, max);
}
/**
......@@ -67,7 +53,7 @@ void FirstPlugin::disable()
// essential Qt function:
// arguments are
// - the complied name of the plugin
// - the main class of our plugin (that extends VisualPlugin)
// - the main class of our plugin
Q_EXPORT_PLUGIN2(FirstPlugin, FirstPlugin)
#else
Q_EXPORT_PLUGIN2(FirstPluginD, FirstPlugin)
......
......@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 2.8)
SET(CMAKE_BUILD_TYPE Release)
ADD_DEFINITIONS(-fPIC)
IF(WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ELSE (WIN32)
......@@ -22,34 +20,49 @@ INCLUDE_DIRECTORIES(
file(
GLOB
SCHNApps_SRC_FILES
${SCHNApps_ROOT_DIR}/src/camera.cpp
${SCHNApps_ROOT_DIR}/src/context.cpp
${SCHNApps_ROOT_DIR}/src/main.cpp
${SCHNApps_ROOT_DIR}/src/interface/*.cpp
${SCHNApps_ROOT_DIR}/src/visualization/*.cpp
${SCHNApps_ROOT_DIR}/src/dialogs/*.cpp
${SCHNApps_ROOT_DIR}/src/mapHandler.cpp
${SCHNApps_ROOT_DIR}/src/plugin.cpp
${SCHNApps_ROOT_DIR}/src/splitArea.cpp
${SCHNApps_ROOT_DIR}/src/system.cpp
${SCHNApps_ROOT_DIR}/src/view.cpp
${SCHNApps_ROOT_DIR}/src/window.cpp
${SCHNApps_ROOT_DIR}/src/viewButtonArea.cpp
${SCHNApps_ROOT_DIR}/src/viewSelector.cpp
${SCHNApps_ROOT_DIR}/src/cameraDialog.cpp
${SCHNApps_ROOT_DIR}/src/pluginDialog.cpp
${SCHNApps_ROOT_DIR}/src/cameraViewDialog.cpp
${SCHNApps_ROOT_DIR}/src/pluginsViewDialog.cpp
${SCHNApps_ROOT_DIR}/src/mapsViewDialog.cpp
)
SET(SCHNApps_H_OBJECT_FILES
${SCHNApps_ROOT_DIR}/include/interface/window.h
${SCHNApps_ROOT_DIR}/include/interface/system.h
${SCHNApps_ROOT_DIR}/include/interface/viewButtonArea.h
${SCHNApps_ROOT_DIR}/include/interface/splitArea.h
${SCHNApps_ROOT_DIR}/include/visualization/view.h
${SCHNApps_ROOT_DIR}/include/visualization/scene.h
${SCHNApps_ROOT_DIR}/include/dialogs/newSceneDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/sceneSelector.h
${SCHNApps_ROOT_DIR}/include/dialogs/cameraViewDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/cameraOptionDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/cameraSceneDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/globalCameraDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/pluginDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/linkViewDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/mapPluginDialog.h
${SCHNApps_ROOT_DIR}/include/camera.h
${SCHNApps_ROOT_DIR}/include/mapHandler.h
${SCHNApps_ROOT_DIR}/include/plugin.h
${SCHNApps_ROOT_DIR}/include/splitArea.h
${SCHNApps_ROOT_DIR}/include/view.h
${SCHNApps_ROOT_DIR}/include/window.h
${SCHNApps_ROOT_DIR}/include/viewButtonArea.h
${SCHNApps_ROOT_DIR}/include/viewSelector.h
${SCHNApps_ROOT_DIR}/include/cameraDialog.h
${SCHNApps_ROOT_DIR}/include/pluginDialog.h
${SCHNApps_ROOT_DIR}/include/cameraViewDialog.h
${SCHNApps_ROOT_DIR}/include/pluginsViewDialog.h
${SCHNApps_ROOT_DIR}/include/mapsViewDialog.h
)
file(
GLOB
SCHNApps_FORM_FILES
${SCHNApps_ROOT_DIR}/forms/*.ui
${SCHNApps_ROOT_DIR}/forms/window.ui
${SCHNApps_ROOT_DIR}/forms/cameraDialog.ui
${SCHNApps_ROOT_DIR}/forms/pluginDialog.ui
${SCHNApps_ROOT_DIR}/forms/cameraViewDialog.ui
${SCHNApps_ROOT_DIR}/forms/pluginsViewDialog.ui
${SCHNApps_ROOT_DIR}/forms/mapsViewDialog.ui
)
QT4_WRAP_UI( UI_H_FILES
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CameraDialog</class>
<widget class="QDialog" name="CameraDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>198</width>
<height>318</height>
</rect>
</property>
<property name="windowTitle">
<string>CameraDialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="addCameraButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeCameraButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="cameraList"/>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="OKButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>OKButton</sender>
<signal>clicked()</signal>
<receiver>CameraDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>115</x>
<y>407</y>
</hint>
<hint type="destinationlabel">
<x>115</x>
<y>214</y>
</hint>
</hints>
</connection>
</connections>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CODialog</class>
<widget class="QDialog" name="CODialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>363</width>
<height>357</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Camera draw options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="draw_Check">
<property name="text">
<string>Draw</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="farPlane_Check">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Draw far plane</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Camera scale:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="scale_Spin">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="drawPath_Check">
<property name="text">
<string>Draw user path</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>Draw path option</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="drawAxis_Check">
<property name="text">
<string>draw axis</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Scale:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="frameScale_Spin">
<property name="minimum">
<double>0.100000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>CODialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>