Commit 05d5b401 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: missing plugin files

parent 7a0cad68
cmake_minimum_required(VERSION 2.8)
INCLUDE_DIRECTORIES(
${SCHNApps_ROOT_DIR}/include
${SCHNApps_ROOT_DIR}/Plugins/demo
${CMAKE_CURRENT_BINARY_DIR}
)
SET( PLUGIN_SRC
${SCHNApps_ROOT_DIR}/Plugins/demo/demo.cpp
)
SET( PLUGIN_H
${SCHNApps_ROOT_DIR}/Plugins/demo/demo.h
)
SET( PLUGIN_FORM
${SCHNApps_ROOT_DIR}/Plugins/demo/demo.ui
)
IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
ADD_DEFINITIONS(-DDEBUG)
IF(WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ELSE (WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Debug ${CGoGN_ROOT_DIR}/lib/Release )
ENDIF (WIN32)
QT4_WRAP_UI( PLUGIN_UI ${PLUGIN_FORM} )
QT4_WRAP_CPP( PLUGIN_MOC ${PLUGIN_H} )
ADD_LIBRARY( DemoPluginD SHARED
${PLUGIN_SRC}
${PLUGIN_UI}
${PLUGIN_MOC}
)
TARGET_LINK_LIBRARIES( DemoPluginD
${CGoGN_LIBS_D}
${COMMON_LIBS}
${QGLVIEWER_LIBRARIES}
)
ADD_DEPENDENCIES( DemoPluginD SCHNAppsD )
SET_TARGET_PROPERTIES( DemoPluginD PROPERTIES COMPILE_DEFINITIONS "DEBUG" )
ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
IF(WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ELSE (WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ENDIF (WIN32)
QT4_WRAP_UI( PLUGIN_UI ${PLUGIN_FORM} )
QT4_WRAP_CPP( PLUGIN_MOC ${PLUGIN_H} )
ADD_LIBRARY( DemoPlugin SHARED
${PLUGIN_SRC}
${PLUGIN_UI}
${PLUGIN_MOC}
)
TARGET_LINK_LIBRARIES( DemoPlugin
${CGoGN_LIBS_R}
${COMMON_LIBS}
${QGLVIEWER_LIBRARIES}
)
ADD_DEPENDENCIES( DemoPlugin SCHNApps )
ENDIF ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
#include "demo.h"
#include "mapHandler.h"
#include "Algo/Import/import.h"
bool DemoPlugin::enable()
{
addTabInDock(new DemoDockTab(), "demoTab");
m_flatShader = new CGoGN::Utils::ShaderFlat() ;
m_flatShader->setAmbiant(CGoGN::Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f)) ;
m_flatShader->setDiffuse(CGoGN::Geom::Vec4f(0.8f, 0.9f, 0.7f, 1.0f)) ;
m_flatShader->setExplode(1.0f) ;
CGoGN::Utils::GLSLShader::registerShader(NULL, m_flatShader) ;
return true;
}
void DemoPlugin::disable()
{
delete m_flatShader;
}
void DemoPlugin::redraw(View* view)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) ;
glEnable(GL_LIGHTING) ;
QList<MapHandlerGen*> maps = view->getLinkedMaps();
foreach(MapHandlerGen* m, maps)
{
CGoGN::Utils::VBO* positionVBO = m->getVBO("position");
m_flatShader->setAttributePosition(positionVBO);
m->draw(m_flatShader, CGoGN::Algo::Render::GL2::TRIANGLES) ;
}
}
/**
* If we want to compile this plugin in debug mode,
* we also define a DEBUG macro at the compilation
*/
#ifndef DEBUG
// essential Qt function:
// arguments are
// - the compiled name of the plugin
// - the main class of our plugin
Q_EXPORT_PLUGIN2(DemoPlugin, DemoPlugin)
#else
Q_EXPORT_PLUGIN2(DemoPluginD, DemoPlugin)
#endif
#ifndef _DEMO_PLUGIN_H_
#define _DEMO_PLUGIN_H_
#include "plugin.h"
#include "ui_demo.h"
#include "Topology/generic/functor.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Utils/Shaders/shaderFlat.h"
struct PFP: public CGoGN::PFP_STANDARD
{
// definition of the map
typedef CGoGN::EmbeddedMap2 MAP;
};
typedef PFP::MAP MAP;
typedef PFP::VEC3 VEC3;
class DemoDockTab : public QWidget, public Ui::DemoWidget
{
public:
DemoDockTab() { setupUi(this); }
};
struct TabParams
{
bool b_showVertices;
bool b_showEdges;
};
/**
* This class is a basic minimal plugin.
* All the methods in this class are overloaded methods.
* In order to create a valid plugin, all the method in this
* needs to be declared (they are actually overloaded methods
* from VisualPlugin), even if your plugin doesn't make any
* drawing.
*/
/**
* Our plugin must inherit from Plugin
*/
class DemoPlugin : public Plugin
{
/**
* Essential Qt macros.
*/
Q_OBJECT
Q_INTERFACES(Plugin)
public:
DemoPlugin()
{
setProvidesRendering(true);
}
~DemoPlugin()
{}
/**
* 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 enable();
/**
* The plugin's disable method
* Each time the main application will unload the plugin
* it will call this method.
*/
void disable();
virtual void redraw(View *view);
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) {}
virtual void viewLinked(View* view) {}
virtual void viewUnlinked(View* view) {}
protected:
CGoGN::Utils::ShaderFlat* m_flatShader ;
};
#endif // _FIRSTPLUGIN_H_
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DemoWidget</class>
<widget class="QWidget" name="DemoWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>177</width>
<height>211</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="check_renderVertices">
<property name="text">
<string>render vertices</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="check_renderEdges">
<property name="text">
<string>render edges</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>156</width>
<height>136</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
cmake_minimum_required(VERSION 2.8)
INCLUDE_DIRECTORIES(
${SCHNApps_ROOT_DIR}/include
${SCHNApps_ROOT_DIR}/Plugins/import
${CMAKE_CURRENT_BINARY_DIR}
)
SET( PLUGIN_SRC
${SCHNApps_ROOT_DIR}/Plugins/import/import.cpp
)
SET( PLUGIN_H
${SCHNApps_ROOT_DIR}/Plugins/import/import.h
)
IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
ADD_DEFINITIONS(-DDEBUG)
IF(WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ELSE (WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Debug ${CGoGN_ROOT_DIR}/lib/Release )
ENDIF (WIN32)
QT4_WRAP_UI( PLUGIN_UI ${PLUGIN_FORM} )
QT4_WRAP_CPP( PLUGIN_MOC ${PLUGIN_H} )
ADD_LIBRARY( ImportPluginD SHARED
${PLUGIN_SRC}
${PLUGIN_UI}
${PLUGIN_MOC}
)
TARGET_LINK_LIBRARIES( ImportPluginD
${CGoGN_LIBS_D}
${COMMON_LIBS}
${QGLVIEWER_LIBRARIES}
)
ADD_DEPENDENCIES( ImportPluginD SCHNAppsD )
SET_TARGET_PROPERTIES( ImportPluginD PROPERTIES COMPILE_DEFINITIONS "DEBUG" )
ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
IF(WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ELSE (WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ENDIF (WIN32)
QT4_WRAP_UI( PLUGIN_UI ${PLUGIN_FORM} )
QT4_WRAP_CPP( PLUGIN_MOC ${PLUGIN_H} )
ADD_LIBRARY( ImportPlugin SHARED
${PLUGIN_SRC}
${PLUGIN_UI}
${PLUGIN_MOC}
)
TARGET_LINK_LIBRARIES( ImportPlugin
${CGoGN_LIBS_R}
${COMMON_LIBS}
${QGLVIEWER_LIBRARIES}
)
ADD_DEPENDENCIES( ImportPlugin SCHNApps )
ENDIF ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
#include "import.h"
#include "mapHandler.h"
#include "Algo/Import/import.h"
bool ImportPlugin::enable()
{
importAction = new QAction("import", this);
addMenuAction("Import;import", importAction);
connect(importAction, SIGNAL(triggered()), this, SLOT(cb_import()));
return true;
}
void ImportPlugin::disable()
{
}
void ImportPlugin::cb_import()
{
MAP* m = new MAP();
MapHandler<PFP>* h = new MapHandler<PFP>("duck", m_window, m);
std::vector<std::string> attrNames ;
CGoGN::Algo::Import::importMesh<PFP>(*m, "/home/kraemer/Media/Data/surface/lowRes/duck_163.ply", attrNames);
CGoGN::VertexAttribute<PFP::VEC3> position = m->getAttribute<PFP::VEC3, CGoGN::VERTEX>(attrNames[0]);
CGoGN::Geom::BoundingBox<PFP::VEC3> bb = CGoGN::Algo::Geometry::computeBoundingBox<PFP>(*m, 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]);
h->setBBmin(min);
h->setBBmax(max);
h->updatePrimitives(CGoGN::Algo::Render::GL2::POINTS, CGoGN::allDarts) ;
h->updatePrimitives(CGoGN::Algo::Render::GL2::LINES, CGoGN::allDarts) ;
h->updatePrimitives(CGoGN::Algo::Render::GL2::TRIANGLES, CGoGN::allDarts) ;
m_window->addMap(h);
CGoGN::Utils::VBO* positionVBO = h->getVBO(position.name());
positionVBO->updateData(position);
}
/**
* If we want to compile this plugin in debug mode,
* we also define a DEBUG macro at the compilation
*/
#ifndef DEBUG
// essential Qt function:
// arguments are
// - the compiled name of the plugin
// - the main class of our plugin
Q_EXPORT_PLUGIN2(ImportPlugin, ImportPlugin)
#else
Q_EXPORT_PLUGIN2(ImportPluginD, ImportPlugin)
#endif
#ifndef _IMPORT_PLUGIN_H_
#define _IMPORT_PLUGIN_H_
#include "plugin.h"
#include "Topology/generic/functor.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
struct PFP: public CGoGN::PFP_STANDARD
{
// definition of the map
typedef CGoGN::EmbeddedMap2 MAP;
};
typedef PFP::MAP MAP;
typedef PFP::VEC3 VEC3;
/**
* This class is a basic minimal plugin.
* All the methods in this class are overloaded methods.
* In order to create a valid plugin, all the method in this
* needs to be declared (they are actually overloaded methods
* from VisualPlugin), even if your plugin doesn't make any
* drawing.
*/
/**
* Our plugin must inherit from Plugin
*/
class ImportPlugin : public Plugin
{
/**
* Essential Qt macros.
*/
Q_OBJECT
Q_INTERFACES(Plugin)
public:
ImportPlugin()
{
setProvidesRendering(false);
}
~ImportPlugin()
{}
/**
* 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 enable();
/**
* The plugin's disable method
* Each time the main application will unload the plugin
* it will call this method.
*/
void disable();
virtual void redraw(View *view) {}
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) {}
virtual void viewLinked(View* view) {}
virtual void viewUnlinked(View* view) {}
public slots:
void cb_import();
private:
QAction* importAction;
};
#endif // _FIRSTPLUGIN_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment