Commit ab764478 authored by Pierre Kraemer's avatar Pierre Kraemer

new plugin : surface subdivision

parent 353f07b8
...@@ -4,3 +4,4 @@ ADD_SUBDIRECTORY(surface_import) ...@@ -4,3 +4,4 @@ ADD_SUBDIRECTORY(surface_import)
ADD_SUBDIRECTORY(surface_render) ADD_SUBDIRECTORY(surface_render)
ADD_SUBDIRECTORY(surface_renderVector) ADD_SUBDIRECTORY(surface_renderVector)
ADD_SUBDIRECTORY(surface_differentialProperties) ADD_SUBDIRECTORY(surface_differentialProperties)
ADD_SUBDIRECTORY(surface_subdivision)
...@@ -25,8 +25,8 @@ private: ...@@ -25,8 +25,8 @@ private:
public slots: public slots:
void selectedMapChanged(); void selectedMapChanged();
void addMapToList(MapHandlerGen* m); void addMapToList(MapHandlerGen* map);
void removeMapFromList(MapHandlerGen* m); void removeMapFromList(MapHandlerGen* map);
void addAttributeToList(unsigned int orbit, const QString& nameAttr); void addAttributeToList(unsigned int orbit, const QString& nameAttr);
}; };
......
...@@ -54,7 +54,6 @@ void Dialog_ComputeNormal::selectedMapChanged() ...@@ -54,7 +54,6 @@ void Dialog_ComputeNormal::selectedMapChanged()
{ {
combo_positionAttribute->addItem(i.key()); combo_positionAttribute->addItem(i.key());
combo_normalAttribute->addItem(i.key()); combo_normalAttribute->addItem(i.key());
++j; ++j;
} }
} }
...@@ -66,19 +65,19 @@ void Dialog_ComputeNormal::selectedMapChanged() ...@@ -66,19 +65,19 @@ void Dialog_ComputeNormal::selectedMapChanged()
m_selectedMap = NULL; m_selectedMap = NULL;
} }
void Dialog_ComputeNormal::addMapToList(MapHandlerGen* m) void Dialog_ComputeNormal::addMapToList(MapHandlerGen* map)
{ {
QListWidgetItem* item = new QListWidgetItem(m->getName(), list_maps); QListWidgetItem* item = new QListWidgetItem(map->getName(), list_maps);
item->setCheckState(Qt::Unchecked); item->setCheckState(Qt::Unchecked);
} }
void Dialog_ComputeNormal::removeMapFromList(MapHandlerGen* m) void Dialog_ComputeNormal::removeMapFromList(MapHandlerGen* map)
{ {
QList<QListWidgetItem*> items = list_maps->findItems(m->getName(), Qt::MatchExactly); QList<QListWidgetItem*> items = list_maps->findItems(map->getName(), Qt::MatchExactly);
if(!items.empty()) if(!items.empty())
delete items[0]; delete items[0];
if(m_selectedMap == m) if(m_selectedMap == map)
{ {
disconnect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&))); disconnect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&)));
m_selectedMap = NULL; m_selectedMap = NULL;
......
...@@ -125,7 +125,7 @@ void Surface_RenderVector_DockTab::updateMapParameters() ...@@ -125,7 +125,7 @@ void Surface_RenderVector_DockTab::updateMapParameters()
{ {
const MapParameters& p = m_plugin->h_viewParameterSet[view][map]; const MapParameters& p = m_plugin->h_viewParameterSet[view][map];
unsigned int i = 0; unsigned int i = 1;
foreach(Utils::VBO* vbo, map->getVBOSet().values()) foreach(Utils::VBO* vbo, map->getVBOSet().values())
{ {
if(vbo->dataSize() == 3) if(vbo->dataSize() == 3)
......
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
SET( PLUGIN_NAME SubdivideSurface ) SET( PLUGIN_NAME Surface_Subdivision )
SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/subdivideSurface ) SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/surface_subdivision )
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${PLUGIN_ROOT_DIR}/include ${PLUGIN_ROOT_DIR}/include
...@@ -25,8 +25,8 @@ file( ...@@ -25,8 +25,8 @@ file(
SET( SET(
PLUGIN_QOBJECT_FILES PLUGIN_QOBJECT_FILES
${PLUGIN_ROOT_DIR}/include/subdivideSurface.h ${PLUGIN_ROOT_DIR}/include/surface_subdivision.h
${PLUGIN_ROOT_DIR}/include/subdivideSurfaceDialog.h ${PLUGIN_ROOT_DIR}/include/dialog_surface_subdivision.h
) )
include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt ) include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt )
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_Surface_Subdivision</class>
<widget class="QDialog" name="Dialog_Surface_Subdivision">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>314</width>
<height>230</height>
</rect>
</property>
<property name="windowTitle">
<string>Subdivide surface</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="5">
<widget class="QListWidget" name="list_maps"/>
</item>
<item row="1" column="0" colspan="3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position attribute :</string>
</property>
</widget>
</item>
<item row="1" column="3" colspan="2">
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radio_Loop">
<property name="text">
<string>Loop</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QRadioButton" name="radio_CC">
<property name="text">
<string>Catmull-Clark</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QRadioButton" name="radio_trianguleFaces">
<property name="text">
<string>Triangule faces</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="button_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="3" column="2" colspan="2">
<widget class="QPushButton" name="button_apply">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QPushButton" name="button_ok">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SubdivideSurfaceDialog</class>
<widget class="QDialog" name="SubdivideSurfaceDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>314</width>
<height>230</height>
</rect>
</property>
<property name="windowTitle">
<string>Subdivide surface</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="mapList"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="radio_Loop">
<property name="text">
<string>Loop</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_CC">
<property name="text">
<string>Catmull-Clark</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_trianguleFaces">
<property name="text">
<string>Triangule faces</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="button_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_apply">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_ok">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#ifndef _SUBDIVIDESURFACE_DIALOG_H_ #ifndef _DIALOG_SURFACE_SUBDIVISION_H_
#define _SUBDIVIDESURFACE_DIALOG_H_ #define _DIALOG_SURFACE_SUBDIVISION_H_
#include "ui_subdivideSurfaceDialog.h" #include "ui_dialog_surface_subdivision.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -9,25 +9,25 @@ namespace CGoGN ...@@ -9,25 +9,25 @@ namespace CGoGN
namespace SCHNApps namespace SCHNApps
{ {
class Window; class SCHNApps;
class MapHandlerGen; class MapHandlerGen;
class SubdivideSurfaceDialog : public QDialog, public Ui::SubdivideSurfaceDialog class Dialog_Surface_Subdivision : public QDialog, public Ui::Dialog_Surface_Subdivision
{ {
Q_OBJECT Q_OBJECT
public: public:
SubdivideSurfaceDialog(Window* w); Dialog_Surface_Subdivision(SCHNApps* s);
private: private:
Window* m_window; SCHNApps* m_schnapps;
MapHandlerGen* m_selectedMap; MapHandlerGen* m_selectedMap;
public slots: public slots:
void selectedMapChanged(); void selectedMapChanged();
void addMapToList(MapHandlerGen* m); void addMapToList(MapHandlerGen* map);
void removeMapFromList(MapHandlerGen* m); void removeMapFromList(MapHandlerGen* map);
void addAttributeToList(unsigned int orbit, const QString& name); void addAttributeToList(unsigned int orbit, const QString& nameAttr);
}; };
} // namespace SCHNApps } // namespace SCHNApps
......
#ifndef _SUBDIVIDESURFACE_PLUGIN_H_ #ifndef _SURFACE_SUBDIVISION_PLUGIN_H_
#define _SUBDIVIDESURFACE_PLUGIN_H_ #define _SURFACE_SUBDIVISION_PLUGIN_H_
#include "plugin.h" #include "plugin_processing.h"
#include "subdivideSurfaceDialog.h"
#include "dialog_surface_subdivision.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -10,36 +11,26 @@ namespace CGoGN ...@@ -10,36 +11,26 @@ namespace CGoGN
namespace SCHNApps namespace SCHNApps
{ {
class SubdivideSurfacePlugin : public Plugin class Surface_Subdivision_Plugin : public Plugin
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin) Q_INTERFACES(CGoGN::SCHNApps::Plugin)
public: public:
SubdivideSurfacePlugin() Surface_Subdivision_Plugin()
{ {}
setProvidesRendering(false);
}
~SubdivideSurfacePlugin() ~Surface_Subdivision_Plugin()
{} {}
virtual bool enable(); virtual bool enable();
virtual void disable() {} virtual void disable() {}
virtual void redraw(View *view) {} private slots:
void openSubdivisionDialog();
virtual void keyPress(View* view, QKeyEvent* event) {} void subdivideFromDialog();
virtual void keyRelease(View* view, QKeyEvent* event) {}
virtual void mousePress(View* view, QMouseEvent* event) {}
virtual void mouseRelease(View* view, QMouseEvent* event) {}
virtual void mouseMove(View* view, QMouseEvent* event) {}
virtual void wheelEvent(View* view, QWheelEvent* event) {}
public slots: public slots:
void openSubdivideSurfaceDialog();
void subdivideSurfaceFromDialog();
void loopSubdivision( void loopSubdivision(
const QString& mapName, const QString& mapName,
const QString& positionAttributeName = "position" const QString& positionAttributeName = "position"
...@@ -54,9 +45,9 @@ public slots: ...@@ -54,9 +45,9 @@ public slots:
); );
private: private:
SubdivideSurfaceDialog* m_subdivideSurfaceDialog; Dialog_Surface_Subdivision* m_subdivisionDialog;
QAction* m_subdivideSurfaceAction; QAction* m_subdivisionAction;
}; };
} // namespace SCHNApps } // namespace SCHNApps
......
#include "subdivideSurfaceDialog.h" #include "dialog_surface_subdivision.h"
#include "subdivideSurface.h" #include "surface_subdivision.h"
#include "window.h" #include "schnapps.h"
#include "mapHandler.h" #include "mapHandler.h"
namespace CGoGN namespace CGoGN
...@@ -10,47 +10,43 @@ namespace CGoGN ...@@ -10,47 +10,43 @@ namespace CGoGN
namespace SCHNApps namespace SCHNApps
{ {
SubdivideSurfaceDialog::SubdivideSurfaceDialog(Window* w) : Dialog_Surface_Subdivision::Dialog_Surface_Subdivision(SCHNApps* s) :
m_window(w), m_schnapps(s),
m_selectedMap(NULL) m_selectedMap(NULL)
{ {
setupUi(this); setupUi(this);
connect(m_window, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(addMapToList(MapHandlerGen*))); connect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(addMapToList(MapHandlerGen*)));
connect(m_window, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(removeMapFromList(MapHandlerGen*))); connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(removeMapFromList(MapHandlerGen*)));
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged())); connect(list_maps, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
const QList<MapHandlerGen*>& maps = m_window->getMapsList(); foreach(MapHandlerGen* map, m_schnapps->getMapSet().values())
foreach(MapHandlerGen* map, maps) list_maps->addItem(map->getName());
mapList->addItem(map->getName());
} }
void SubdivideSurfaceDialog::selectedMapChanged() void Dialog_Surface_Subdivision::selectedMapChanged()
{ {
if(m_selectedMap) if(m_selectedMap)
disconnect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&))); disconnect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&)));
QList<QListWidgetItem*> currentItems = mapList->selectedItems(); QList<QListWidgetItem*> currentItems = list_maps->selectedItems();
if(!currentItems.empty()) if(!currentItems.empty())
{ {
combo_positionAttribute->clear(); combo_positionAttribute->clear();
const QString& mapname = currentItems[0]->text(); const QString& mapname = currentItems[0]->text();
MapHandlerGen* mh = m_window->getMap(mapname); MapHandlerGen* mh = m_schnapps->getMap(mapname);
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3())); QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
unsigned int j = 0; unsigned int j = 0;
const AttributeHash& attribs = mh->getAttributesList(VERTEX); const AttributeSet& attribs = mh->getAttributeSet(VERTEX);
for(AttributeHash::const_iterator i = attribs.constBegin(); i != attribs.constEnd(); ++i) for(AttributeSet::const_iterator i = attribs.constBegin(); i != attribs.constEnd(); ++i)
{ {
if(i.value() == vec3TypeName) if(i.value() == vec3TypeName)
{ {
combo_positionAttribute->addItem(i.key()); combo_positionAttribute->addItem(i.key());
if(i.key() == "position") // try to select a position attribute named "position"
combo_positionAttribute->setCurrentIndex(j);
++j; ++j;
} }
} }
...@@ -62,25 +58,25 @@ void SubdivideSurfaceDialog::selectedMapChanged() ...@@ -62,25 +58,25 @@ void SubdivideSurfaceDialog::selectedMapChanged()
m_selectedMap = NULL; m_selectedMap = NULL;
} }
void SubdivideSurfaceDialog::addMapToList(MapHandlerGen* m) void Dialog_Surface_Subdivision::addMapToList(MapHandlerGen* map)
{ {
mapList->addItem(m->getName()); list_maps->addItem(map->getName());
} }
void SubdivideSurfaceDialog::removeMapFromList(MapHandlerGen* m) void Dialog_Surface_Subdivision::removeMapFromList(MapHandlerGen* map)
{ {
QList<QListWidgetItem*> items = mapList->findItems(m->getName(), Qt::MatchExactly); QList<QListWidgetItem*> items = list_maps->findItems(map->getName(), Qt::MatchExactly);
if(!items.empty()) if(!items.empty())
delete items[0]; delete items[0];
if(m_selectedMap == m) if(m_selectedMap == map)
{ {
disconnect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&))); disconnect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&)));
m_selectedMap = NULL; m_selectedMap = NULL;
} }
} }
void SubdivideSurfaceDialog::addAttributeToList(unsigned int orbit, const QString& nameAttr) void Dialog_Surface_Subdivision::addAttributeToList(unsigned int orbit, const QString& nameAttr)
{ {
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3())); QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
......
#include "subdivideSurface.h" #include "surface_subdivision.h"
#include "mapHandler.h" #include "mapHandler.h"
...@@ -10,49 +10,49 @@ namespace CGoGN ...@@ -10,49 +10,49 @@ namespace CGoGN
namespace SCHNApps namespace SCHNApps
{ {
bool SubdivideSurfacePlugin::enable() bool Surface_Subdivision_Plugin::enable()
{