diff --git a/SCHNApps/CMakeLists.txt b/SCHNApps/CMakeLists.txt index 51d7ae703a610cf1b8d66fab5a92d08126b80ae2..f728f2c272b44f14de797c1d1b70c3e5d6211d94 100644 --- a/SCHNApps/CMakeLists.txt +++ b/SCHNApps/CMakeLists.txt @@ -14,17 +14,6 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC") 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) - - -#=======Python=========# -find_package(PythonLibs REQUIRED) - - #======SCHNApps=======# SET(SCHNApps_ROOT_DIR ${CGoGN_ROOT_DIR}/SCHNApps) @@ -38,12 +27,12 @@ ENDIF (NOT WIN32) #======Documentation=======# -find_package(Doxygen) -if(DOXYGEN_FOUND) -configure_file(${CMAKE_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) -add_custom_target(doc - ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/Doc - COMMENT "Generating API documentation with Doxygen" VERBATIM -) -endif(DOXYGEN_FOUND) +#find_package(Doxygen) +#if(DOXYGEN_FOUND) +#configure_file(${CMAKE_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) +#add_custom_target(doc +# ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile +# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/Doc +# COMMENT "Generating API documentation with Doxygen" VERBATIM +#) +#endif(DOXYGEN_FOUND) diff --git a/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h b/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h index 23199d841119992bf372e8bd0658d9b187bdecbc..03769974adb8c30f94965086a3b4184f6e580cca 100644 --- a/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h +++ b/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h @@ -55,8 +55,8 @@ private: ComputeNormalDialog* m_computeNormalDialog; ComputeCurvatureDialog* m_computeCurvatureDialog; - QAction* computeNormalAction; - QAction* computeCurvatureAction; + QAction* m_computeNormalAction; + QAction* m_computeCurvatureAction; }; #endif diff --git a/SCHNApps/Plugins/differentialProperties/src/differentialProperties.cpp b/SCHNApps/Plugins/differentialProperties/src/differentialProperties.cpp index f50ddce2a8f81e82446f0513f750b4af70a4b240..1260c4d57cfc9986a1d317ef5f95376be4285e42 100644 --- a/SCHNApps/Plugins/differentialProperties/src/differentialProperties.cpp +++ b/SCHNApps/Plugins/differentialProperties/src/differentialProperties.cpp @@ -11,14 +11,14 @@ bool DifferentialPropertiesPlugin::enable() m_computeNormalDialog = new ComputeNormalDialog(m_window); m_computeCurvatureDialog = new ComputeCurvatureDialog(m_window); - computeNormalAction = new QAction("Compute Normal", this); - computeCurvatureAction = new QAction("Compute Curvature", this); + m_computeNormalAction = new QAction("Compute Normal", this); + m_computeCurvatureAction = new QAction("Compute Curvature", this); - addMenuAction("Surface;Differential Properties;Compute Normal", computeNormalAction); - addMenuAction("Surface;Differential Properties;Compute Curvature", computeCurvatureAction); + addMenuAction("Surface;Differential Properties;Compute Normal", m_computeNormalAction); + addMenuAction("Surface;Differential Properties;Compute Curvature", m_computeCurvatureAction); - connect(computeNormalAction, SIGNAL(triggered()), this, SLOT(cb_openComputeNormalDialog())); - connect(computeCurvatureAction, SIGNAL(triggered()), this, SLOT(cb_openComputeCurvatureDialog())); + connect(m_computeNormalAction, SIGNAL(triggered()), this, SLOT(cb_openComputeNormalDialog())); + connect(m_computeCurvatureAction, SIGNAL(triggered()), this, SLOT(cb_openComputeCurvatureDialog())); connect(m_computeNormalDialog, SIGNAL(accepted()), this, SLOT(cb_computeNormal())); connect(m_computeNormalDialog->button_apply, SIGNAL(clicked()), this, SLOT(cb_computeNormal())); @@ -56,6 +56,7 @@ void DifferentialPropertiesPlugin::cb_computeNormal() normalName = m_computeNormalDialog->combo_normalAttribute->currentText().toUtf8().constData(); else normalName = m_computeNormalDialog->normalAttributeName->text().toUtf8().constData(); + VertexAttribute position = map->getAttribute(positionName); VertexAttribute normal = map->getAttribute(normalName); if(!normal.isValid()) diff --git a/SCHNApps/Plugins/importSurface/importSurface.cpp b/SCHNApps/Plugins/importSurface/importSurface.cpp index 26705446b7b2242c8e09da16a9869b0da8123e8e..5c857f064e7096398196e66dccbb2bb8c59a36eb 100644 --- a/SCHNApps/Plugins/importSurface/importSurface.cpp +++ b/SCHNApps/Plugins/importSurface/importSurface.cpp @@ -11,15 +11,13 @@ bool ImportSurfacePlugin::enable() { importAction = new QAction("import", this); addMenuAction("Surface;Import", importAction); - connect(importAction, SIGNAL(triggered()), this, SLOT(cb_import())); + connect(importAction, SIGNAL(triggered()), this, SLOT(importFromFileDialog())); return true; } -void ImportSurfacePlugin::cb_import() +void ImportSurfacePlugin::importFromFile(const QString& fileName) { - QString fileName = QFileDialog::getOpenFileName(m_window, "Import file", m_window->getAppPath(), "Mesh Files (*.ply *.off *.trian)"); QFileInfo fi(fileName); - if(fi.exists()) { GenericMap* m = m_window->createMap(2); @@ -47,6 +45,12 @@ void ImportSurfacePlugin::cb_import() } } +void ImportSurfacePlugin::importFromFileDialog() +{ + QString fileName = QFileDialog::getOpenFileName(m_window, "Import file", m_window->getAppPath(), "Mesh Files (*.ply *.off *.trian)"); + importFromFile(fileName); +} + #ifndef DEBUG Q_EXPORT_PLUGIN2(ImportSurfacePlugin, ImportSurfacePlugin) #else diff --git a/SCHNApps/Plugins/importSurface/importSurface.h b/SCHNApps/Plugins/importSurface/importSurface.h index dacc9a7f66ef82b216c3af64e17f9b69345004d5..e8111c71c4706fde2a0ef4db59f13dad37cb2272 100644 --- a/SCHNApps/Plugins/importSurface/importSurface.h +++ b/SCHNApps/Plugins/importSurface/importSurface.h @@ -42,7 +42,8 @@ public: virtual void mapUnlinked(View* view, MapHandlerGen* m) {} public slots: - void cb_import(); + void importFromFile(const QString& fileName); + void importFromFileDialog(); private: QAction* importAction; diff --git a/SCHNApps/Plugins/render/render.ui b/SCHNApps/Plugins/render/render.ui index be4c41ec09e751b710165344e169387907dff1c0..45ddda069f6527fa00f609d20ef030d8d90c0ba3 100644 --- a/SCHNApps/Plugins/render/render.ui +++ b/SCHNApps/Plugins/render/render.ui @@ -7,7 +7,7 @@ 0 0 174 - 553 + 547 diff --git a/SCHNApps/Plugins/subdivideSurface/CMakeLists.txt b/SCHNApps/Plugins/subdivideSurface/CMakeLists.txt index 724d0d1edde52e626d237bd3523a32f8a6170045..c9aea0262cca489d9c810e869a4090aa4bca6e09 100644 --- a/SCHNApps/Plugins/subdivideSurface/CMakeLists.txt +++ b/SCHNApps/Plugins/subdivideSurface/CMakeLists.txt @@ -2,20 +2,22 @@ cmake_minimum_required(VERSION 2.8) INCLUDE_DIRECTORIES( ${SCHNApps_ROOT_DIR}/include - ${SCHNApps_ROOT_DIR}/Plugins/subdivideSurface + ${SCHNApps_ROOT_DIR}/Plugins/subdivideSurface/include ${CMAKE_CURRENT_BINARY_DIR} ) SET( PLUGIN_SRC - ${SCHNApps_ROOT_DIR}/Plugins/subdivideSurface/subdivideSurface.cpp + ${SCHNApps_ROOT_DIR}/Plugins/subdivideSurface/src/subdivideSurface.cpp + ${SCHNApps_ROOT_DIR}/Plugins/subdivideSurface/src/subdivideSurfaceDialog.cpp ) SET( PLUGIN_H - ${SCHNApps_ROOT_DIR}/Plugins/subdivideSurface/subdivideSurface.h + ${SCHNApps_ROOT_DIR}/Plugins/subdivideSurface/include/subdivideSurface.h + ${SCHNApps_ROOT_DIR}/Plugins/subdivideSurface/include/subdivideSurfaceDialog.h ) SET( PLUGIN_FORM - ${SCHNApps_ROOT_DIR}/Plugins/subdivideSurface/subdivideSurface.ui + ${SCHNApps_ROOT_DIR}/Plugins/subdivideSurface/forms/subdivideSurfaceDialog.ui ) IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) diff --git a/SCHNApps/Plugins/subdivideSurface/forms/subdivideSurfaceDialog.ui b/SCHNApps/Plugins/subdivideSurface/forms/subdivideSurfaceDialog.ui new file mode 100644 index 0000000000000000000000000000000000000000..a7d65ba6317da88bad35f634ccd2497331df6a12 --- /dev/null +++ b/SCHNApps/Plugins/subdivideSurface/forms/subdivideSurfaceDialog.ui @@ -0,0 +1,95 @@ + + + SubdivideSurfaceDialog + + + + 0 + 0 + 314 + 230 + + + + Subdivide surface + + + + + + + + + + + Position attribute : + + + + + + + + 0 + 0 + + + + + + + + + + + + Loop + + + + + + + Catmull-Clark + + + + + + + Triangule faces + + + + + + + + + + + Cancel + + + + + + + Apply + + + + + + + OK + + + + + + + + + + diff --git a/SCHNApps/Plugins/subdivideSurface/subdivideSurface.h b/SCHNApps/Plugins/subdivideSurface/include/subdivideSurface.h similarity index 71% rename from SCHNApps/Plugins/subdivideSurface/subdivideSurface.h rename to SCHNApps/Plugins/subdivideSurface/include/subdivideSurface.h index 31389f7222b210b8e1ad636cb42632335a351d42..acbb6b33e32421b2beb975bd55660f4df68b13bc 100644 --- a/SCHNApps/Plugins/subdivideSurface/subdivideSurface.h +++ b/SCHNApps/Plugins/subdivideSurface/include/subdivideSurface.h @@ -2,20 +2,14 @@ #define _SUBDIVIDESURFACE_PLUGIN_H_ #include "plugin.h" -#include "ui_subdivideSurface.h" + +#include "subdivideSurfaceDialog.h" using namespace CGoGN; using namespace SCHNApps; -class SubdivideSurfaceDockTab : public QWidget, public Ui::SubdivideSurfaceWidget -{ -public: - SubdivideSurfaceDockTab() { setupUi(this); } -}; - - class SubdivideSurfacePlugin : public Plugin { Q_OBJECT @@ -49,17 +43,18 @@ public: virtual void mapLinked(View* view, MapHandlerGen* m) {} virtual void mapUnlinked(View* view, MapHandlerGen* m) {} -protected: - SubdivideSurfaceDockTab* m_dockTab; - public slots: - void cb_addMapToList(MapHandlerGen* m); - void cb_removeMapFromList(MapHandlerGen* m); - void cb_selectedMapChanged(); + void cb_openSubdivideSurfaceDialog(); + void cb_subdivideSurface(); + + void loopSubdivision(PFP2::MAP* map, VertexAttribute& position); + void CCSubdivision(PFP2::MAP* map, VertexAttribute& position); + void trianguleFaces(PFP2::MAP* map, VertexAttribute& position); + +private: + SubdivideSurfaceDialog* m_subdivideSurfaceDialog; - void cb_loopSubdivision(); - void cb_CCSubdivision(); - void cb_trianguleFaces(); + QAction* m_subdivideSurfaceAction; }; #endif diff --git a/SCHNApps/Plugins/subdivideSurface/include/subdivideSurfaceDialog.h b/SCHNApps/Plugins/subdivideSurface/include/subdivideSurfaceDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..b7aebddab13d7e2f4680f9690e90143df191efe8 --- /dev/null +++ b/SCHNApps/Plugins/subdivideSurface/include/subdivideSurfaceDialog.h @@ -0,0 +1,33 @@ +#ifndef _SUBDIVIDESURFACE_DIALOG_H_ +#define _SUBDIVIDESURFACE_DIALOG_H_ + +#include "ui_subdivideSurfaceDialog.h" + +namespace CGoGN +{ + +namespace SCHNApps +{ + +class Window; + +class SubdivideSurfaceDialog : public QDialog, public Ui::SubdivideSurfaceDialog +{ + Q_OBJECT + +public: + SubdivideSurfaceDialog(Window* w); + void init(); + +public slots: + void cb_selectedMapChanged(); + +private: + Window* m_window; +}; + +} // namespace SCHNApps + +} // namespace CGoGN + +#endif diff --git a/SCHNApps/Plugins/subdivideSurface/src/subdivideSurface.cpp b/SCHNApps/Plugins/subdivideSurface/src/subdivideSurface.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7ad9c17a4f7359ac3c0b8561a106c40b63fd72be --- /dev/null +++ b/SCHNApps/Plugins/subdivideSurface/src/subdivideSurface.cpp @@ -0,0 +1,78 @@ +#include "subdivideSurface.h" + +#include "mapHandler.h" + +#include "Algo/Modelisation/subdivision.h" + +bool SubdivideSurfacePlugin::enable() +{ + m_subdivideSurfaceDialog = new SubdivideSurfaceDialog(m_window); + + m_subdivideSurfaceAction = new QAction("Subdivide surface", this); + + addMenuAction("Surface;Subdivide", m_subdivideSurfaceAction); + + connect(m_subdivideSurfaceAction, SIGNAL(triggered()), this, SLOT(cb_openSubdivideSurfaceDialog())); + + connect(m_subdivideSurfaceDialog, SIGNAL(accepted()), this, SLOT(cb_subdivideSurface())); + connect(m_subdivideSurfaceDialog->button_apply, SIGNAL(clicked()), this, SLOT(cb_subdivideSurface())); + + return true; +} + +void SubdivideSurfacePlugin::cb_openSubdivideSurfaceDialog() +{ + m_subdivideSurfaceDialog->init(); + m_subdivideSurfaceDialog->show(); +} + +void SubdivideSurfacePlugin::cb_subdivideSurface() +{ + QList currentItems = m_subdivideSurfaceDialog->mapList->selectedItems(); + if(!currentItems.empty()) + { + const QString& mapname = currentItems[0]->text(); + MapHandler* mh = static_cast*>(m_window->getMap(mapname)); + PFP2::MAP* map = mh->getMap(); + + std::string positionName = m_subdivideSurfaceDialog->combo_positionAttribute->currentText().toUtf8().constData(); + VertexAttribute position = map->getAttribute(positionName); + + if(m_subdivideSurfaceDialog->radio_Loop->isChecked()) + loopSubdivision(map, position); + else if(m_subdivideSurfaceDialog->radio_CC->isChecked()) + CCSubdivision(map, position); + else if(m_subdivideSurfaceDialog->radio_trianguleFaces->isChecked()) + trianguleFaces(map, position); + + mh->updatePrimitives(Algo::Render::GL2::POINTS); + mh->updatePrimitives(Algo::Render::GL2::LINES); + mh->updatePrimitives(Algo::Render::GL2::TRIANGLES); + mh->updateVBO(position); + + QList views = mh->getLinkedViews(); + foreach(View* view, views) + view->updateGL(); + } +} + +void SubdivideSurfacePlugin::loopSubdivision(PFP2::MAP* map, VertexAttribute& position) +{ + Algo::Surface::Modelisation::LoopSubdivision(*map, position); +} + +void SubdivideSurfacePlugin::CCSubdivision(PFP2::MAP* map, VertexAttribute& position) +{ + Algo::Surface::Modelisation::CatmullClarkSubdivision(*map, position); +} + +void SubdivideSurfacePlugin::trianguleFaces(PFP2::MAP* map, VertexAttribute& position) +{ + Algo::Surface::Modelisation::trianguleFaces(*map, position); +} + +#ifndef DEBUG +Q_EXPORT_PLUGIN2(SubdivideSurfacePlugin, SubdivideSurfacePlugin) +#else +Q_EXPORT_PLUGIN2(SubdivideSurfacePluginD, SubdivideSurfacePlugin) +#endif diff --git a/SCHNApps/Plugins/subdivideSurface/src/subdivideSurfaceDialog.cpp b/SCHNApps/Plugins/subdivideSurface/src/subdivideSurfaceDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4b09f579a9f8cdf77a741304d62290959afdc907 --- /dev/null +++ b/SCHNApps/Plugins/subdivideSurface/src/subdivideSurfaceDialog.cpp @@ -0,0 +1,61 @@ +#include "subdivideSurfaceDialog.h" + +#include "subdivideSurface.h" +#include "window.h" +#include "mapHandler.h" + +namespace CGoGN +{ + +namespace SCHNApps +{ + +SubdivideSurfaceDialog::SubdivideSurfaceDialog(Window* w) : m_window(w) +{ + setupUi(this); + connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapChanged())); +} + +void SubdivideSurfaceDialog::init() +{ + mapList->clear(); + combo_positionAttribute->clear(); + const QList& maps = m_window->getMapsList(); + foreach(MapHandlerGen* map, maps) + mapList->addItem(map->getName()); +} + +void SubdivideSurfaceDialog::cb_selectedMapChanged() +{ + QList currentItems = mapList->selectedItems(); + if(!currentItems.empty()) + { + combo_positionAttribute->clear(); + const QString& mapname = currentItems[0]->text(); + MapHandlerGen* mh = m_window->getMap(mapname); + GenericMap* map = mh->getGenericMap(); + AttributeContainer& cont = map->getAttributeContainer(); + + std::vector names; + std::vector types; + cont.getAttributesNames(names); + cont.getAttributesTypes(types); + std::string vec3TypeName = nameOfType(PFP2::VEC3()); + unsigned int j = 0; + for(unsigned int i = 0; i < names.size(); ++i) + { + if(types[i] == vec3TypeName) + { + combo_positionAttribute->addItem(QString::fromStdString(names[i])); + if(names[i] == "position") // try to select a position attribute named "position" + combo_positionAttribute->setCurrentIndex(j); + + ++j; + } + } + } +} + +} // namespace SCHNApps + +} // namespace CGoGN diff --git a/SCHNApps/Plugins/subdivideSurface/subdivideSurface.cpp b/SCHNApps/Plugins/subdivideSurface/subdivideSurface.cpp deleted file mode 100644 index 7dea2f92d42f31575f941924ec666ece7a1638dc..0000000000000000000000000000000000000000 --- a/SCHNApps/Plugins/subdivideSurface/subdivideSurface.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include "subdivideSurface.h" - -#include "mapHandler.h" - -#include "Algo/Modelisation/subdivision.h" - -bool SubdivideSurfacePlugin::enable() -{ - m_dockTab = new SubdivideSurfaceDockTab(); - addTabInDock(m_dockTab, "SubdivideSurface"); - - connect(m_window, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(cb_addMapToList(MapHandlerGen*))); - connect(m_window, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(cb_removeMapFromList(MapHandlerGen*))); - - connect(m_dockTab->mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapChanged())); - - connect(m_dockTab->button_trianguleFaces, SIGNAL(clicked()), this, SLOT(cb_trianguleFaces())); - connect(m_dockTab->button_loopSubdivision, SIGNAL(clicked()), this, SLOT(cb_loopSubdivision())); - connect(m_dockTab->button_CCSubdivision, SIGNAL(clicked()), this, SLOT(cb_CCSubdivision())); - - QList maps = m_window->getMapsList(); - foreach(MapHandlerGen* m, maps) - m_dockTab->mapList->addItem(m->getName()); - - return true; -} - -void SubdivideSurfacePlugin::cb_addMapToList(MapHandlerGen* m) -{ - m_dockTab->mapList->addItem(m->getName()); -} - -void SubdivideSurfacePlugin::cb_removeMapFromList(MapHandlerGen* m) -{ - for(int i = 0; i < m_dockTab->mapList->count(); ++i) - { - if(m_dockTab->mapList->item(i)->text() == m->getName()) - { - delete m_dockTab->mapList->item(i); - return; - } - } -} - -void SubdivideSurfacePlugin::cb_selectedMapChanged() -{ - QList currentItems = m_dockTab->mapList->selectedItems(); - if(!currentItems.empty()) - { - m_dockTab->combo_positionAttribute->clear(); - const QString& mapname = currentItems[0]->text(); - MapHandlerGen* mh = m_window->getMap(mapname); - GenericMap* map = mh->getGenericMap(); - AttributeContainer& cont = map->getAttributeContainer(); - std::vector names; - std::vector types; - cont.getAttributesNames(names); - cont.getAttributesTypes(types); - std::string vec3TypeName = nameOfType(PFP2::VEC3()); - unsigned int j = 0; - for(unsigned int i = 0; i < names.size(); ++i) - { - if(types[i] == vec3TypeName) - { - m_dockTab->combo_positionAttribute->addItem(QString::fromStdString(names[i])); - if(names[i] == "position") // try to select an attribute named "position" - m_dockTab->combo_positionAttribute->setCurrentIndex(j); - ++j; - } - } - } -} - -void SubdivideSurfacePlugin::cb_loopSubdivision() -{ - QList currentItems = m_dockTab->mapList->selectedItems(); - if(!currentItems.empty()) - { - const QString& mapname = currentItems[0]->text(); - MapHandler* mh = static_cast*>(m_window->getMap(mapname)); - PFP2::MAP* map = mh->getMap(); - std::string positionName = m_dockTab->combo_positionAttribute->currentText().toUtf8().constData(); - VertexAttribute position = map->getAttribute(positionName); - - Algo::Surface::Modelisation::LoopSubdivision(*map, position); - - mh->updatePrimitives(Algo::Render::GL2::POINTS); - mh->updatePrimitives(Algo::Render::GL2::LINES); - mh->updatePrimitives(Algo::Render::GL2::TRIANGLES); - mh->updateVBO(position); - - QList views = mh->getLinkedViews(); - foreach(View* view, views) - view->updateGL(); - } -} - -void SubdivideSurfacePlugin::cb_CCSubdivision() -{ - QList currentItems = m_dockTab->mapList->selectedItems(); - if(!currentItems.empty()) - { - const QString& mapname = currentItems[0]->text(); - MapHandler* mh = static_cast*>(m_window->getMap(mapname)); - PFP2::MAP* map = mh->getMap(); - std::string positionName = m_dockTab->combo_positionAttribute->currentText().toUtf8().constData(); - VertexAttribute position = map->getAttribute(positionName); - - Algo::Surface::Modelisation::CatmullClarkSubdivision(*map, position); - - mh->updatePrimitives(Algo::Render::GL2::POINTS); - mh->updatePrimitives(Algo::Render::GL2::LINES); - mh->updatePrimitives(Algo::Render::GL2::TRIANGLES); - mh->updateVBO(position); - - QList views = mh->getLinkedViews(); - foreach(View* view, views) - view->updateGL(); - } -} - -void SubdivideSurfacePlugin::cb_trianguleFaces() -{ - QList currentItems = m_dockTab->mapList->selectedItems(); - if(!currentItems.empty()) - { - const QString& mapname = currentItems[0]->text(); - MapHandler* mh = static_cast*>(m_window->getMap(mapname)); - PFP2::MAP* map = mh->getMap(); - std::string positionName = m_dockTab->combo_positionAttribute->currentText().toUtf8().constData(); - VertexAttribute position = map->getAttribute(positionName); - - Algo::Surface::Modelisation::trianguleFaces(*map, position); - - mh->updatePrimitives(Algo::Render::GL2::POINTS); - mh->updatePrimitives(Algo::Render::GL2::LINES); - mh->updatePrimitives(Algo::Render::GL2::TRIANGLES); - mh->updateVBO(position); - - QList views = mh->getLinkedViews(); - foreach(View* view, views) - view->updateGL(); - } -} - -#ifndef DEBUG -Q_EXPORT_PLUGIN2(SubdivideSurfacePlugin, SubdivideSurfacePlugin) -#else -Q_EXPORT_PLUGIN2(SubdivideSurfacePluginD, SubdivideSurfacePlugin) -#endif diff --git a/SCHNApps/Plugins/subdivideSurface/subdivideSurface.ui b/SCHNApps/Plugins/subdivideSurface/subdivideSurface.ui deleted file mode 100644 index c4781a1400c884b53d2283a63b77fe6d37318183..0000000000000000000000000000000000000000 --- a/SCHNApps/Plugins/subdivideSurface/subdivideSurface.ui +++ /dev/null @@ -1,79 +0,0 @@ - - - SubdivideSurfaceWidget - - - - 0 - 0 - 176 - 427 - - - - Form - - - - - - - - - - - Position : - - - - - - - - 0 - 0 - - - - - - - - - - Loop subdivision - - - - - - - Catmull-Clark subdivision - - - - - - - Triangule Faces - - - - - - - Qt::Vertical - - - - 156 - 161 - - - - - - - - - diff --git a/SCHNApps/Release/CMakeLists.txt b/SCHNApps/Release/CMakeLists.txt index 57ad489d3a994fd0c9d7949bc29948ca07b6114d..4cd0c8d692667d6bbb10277b7894005d254dac79 100644 --- a/SCHNApps/Release/CMakeLists.txt +++ b/SCHNApps/Release/CMakeLists.txt @@ -13,8 +13,6 @@ INCLUDE_DIRECTORIES( ${COMMON_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${QGLVIEWER_INCLUDE_DIR} - ${PYTHON_INCLUDE_DIRS} ${SCHNApps_ROOT_DIR}/include ) @@ -80,8 +78,6 @@ ADD_EXECUTABLE( SCHNApps TARGET_LINK_LIBRARIES( SCHNApps ${CGoGN_LIBS_R} ${COMMON_LIBS} - ${QGLVIEWER_LIBRARIES} - PythonQt ) diff --git a/SCHNApps/forms/window.ui b/SCHNApps/forms/window.ui index c43f64c47c7e50020938b531783c804551850d90..3f2eca7f48aa8ca5c0aab45c2e11dcc80c01f3d6 100644 --- a/SCHNApps/forms/window.ui +++ b/SCHNApps/forms/window.ui @@ -32,6 +32,7 @@ File + @@ -95,7 +96,7 @@ - Show/Hide Dock + Show/Hide Plugins Dock @@ -110,6 +111,11 @@ Manage maps + + + Show/Hide Python Dock + + diff --git a/SCHNApps/include/mapHandler.h b/SCHNApps/include/mapHandler.h index bccd560176367d43358666871550488dd4aec969..0fba013fa4b566ea9de95a868a8989198499a651 100644 --- a/SCHNApps/include/mapHandler.h +++ b/SCHNApps/include/mapHandler.h @@ -5,9 +5,11 @@ #include "types.h" #include "view.h" +#include "plugin.h" #include "Topology/generic/genericmap.h" #include "Topology/generic/functor.h" +#include "Topology/generic/attributeHandler.h" #include "Utils/vbo.h" #include "Algo/Render/GL2/mapRender.h" #include "Algo/Geometry/boundingbox.h" diff --git a/SCHNApps/include/plugin.h b/SCHNApps/include/plugin.h index a2e257dd852a3b62d9ed691a4af69bc3ffdaca9f..c31bf98d4c1d55ef38f72f0b2e5be5ca3378e949 100644 --- a/SCHNApps/include/plugin.h +++ b/SCHNApps/include/plugin.h @@ -57,7 +57,7 @@ public: * MANAGE LINKED VIEWS *********************************************************/ - bool linkView(View* view); + void linkView(View* view); void unlinkView(View* view); const QList& getLinkedViews() const { return l_views; } bool isLinkedToView(View* view) const { return l_views.contains(view); } diff --git a/SCHNApps/include/view.h b/SCHNApps/include/view.h index ce08a79ce3a3428e71c7de6a3d45cd52aa97624b..d18040549095abcc1acbb2699f43d5de31be1857 100644 --- a/SCHNApps/include/view.h +++ b/SCHNApps/include/view.h @@ -118,6 +118,10 @@ protected: MapsViewDialog* m_mapsViewDialog; public slots: + CameraViewDialog* getCameraViewDialog() { return m_cameraViewDialog; } + PluginsViewDialog* getPluginsViewDialog() { return m_pluginsViewDialog; } + MapsViewDialog* getMapsViewDialog() { return m_mapsViewDialog; } + void cb_cameraView(int x, int y, int globalX, int globalY); void cb_pluginsView(int x, int y, int globalX, int globalY); void cb_mapsView(int x, int y, int globalX, int globalY); diff --git a/SCHNApps/include/window.h b/SCHNApps/include/window.h index 0ac61c5f44c7f01f9088970ab53328c075aa5847..3d4eb5e356ee5e3f1c3d4a4a96189f3497914a49 100644 --- a/SCHNApps/include/window.h +++ b/SCHNApps/include/window.h @@ -3,8 +3,9 @@ #include "ui_window.h" -#include "PythonQt.h" #include "types.h" +#include "PythonQt.h" +#include "gui/PythonQtScriptingConsole.h" class QVBoxLayout; class QSplitter; @@ -30,7 +31,7 @@ public: * \fn Window() * \brief Constructor */ - Window(const QString& appPath, PythonQtObjectPtr& pythonContext); + Window(const QString& appPath, PythonQtObjectPtr& pythonContext, PythonQtScriptingConsole& pythonConsole); /** * \fn ~Window() @@ -44,22 +45,15 @@ public: * MANAGE DOCK *********************************************************/ - /** - * \fn QTabWidget* getDockTabWidget() - * \brief Accessor to the QTabWidget of this interface - * - * \return a pointer to the TabWidget, NULL if not allocated yet - */ QTabWidget* getDockTabWidget() const { return m_dockTabWidget; } /** - * \fn void addTabInDock(QWidget* tabWidget, const QString& tabText) + * \fn void addTabInDock(QWidget* tabWidget, const QString& tabText, bool enable) * \brief Adds the widget as a new tab in the interface's dock * * \param tabWidget the created and allocated pointer to the QWidget to add in the dock * \param tabText The text that will appears in the tab label - * - * \see removeTabInDock() + * \param enable is the new tab enabled ? */ void addTabInDock(QWidget* tabWidget, const QString& tabText, bool enable); @@ -70,8 +64,6 @@ public: * \param tabWidget the reference to the widget you want to remove * * If the widget does belong to the tab, it will be destroyed. - * - * \see addWidgetInDockTab() */ void removeTabInDock(QWidget* tabWidget); @@ -159,7 +151,11 @@ public: View* addView(const QString& name); View* addView(); void removeView(const QString& name); + +public slots: View* getView(const QString& name) const; + +public: QList getViewsList() const { return h_views.values(); } const ViewHash& getViewsHash() const { return h_views; } @@ -172,6 +168,7 @@ public: * MANAGE PLUGINS *********************************************************/ +public slots: /** * \fn bool loadPlugin(QString pluginPath) * \brief Loads and references a Plugin @@ -189,18 +186,9 @@ public: * This method calls the Plugin::enable() method of the concerned Plugin. That is why * when Plugin are written, this method is overriden and used as an initialization method. * - * \warning In the program this method is called under specific and controlled circumstances, you should probably not call it. - * * \return a boolean whether the loading succeeded or not. - * - * If the function failed, the error code ( Error::code ) is affected with a value - * depending on the error. This error can be shown with Error::showError - * - * \see unloadPlugin() - * \see getPlugins() - * \see Plugin::enable() */ -// Plugin* loadPlugin(const QString& pluginFilePath); + Plugin* loadPlugin(const QString& pluginFilePath); /** * \fn void unloadPlugin(QString pluginName) @@ -213,36 +201,10 @@ public: * * This method calls the Plugin::disable() method of the concerned Plugin. That is why, * when Plugin are written, this method is overriden and used as a destruction method. - * - * \warning In the program this method is called under specific and controlled circumstances, you should probably not call it. - * - * \see loadPlugin() - * \see getPlugins() - * \see Plugin::disable() */ void unloadPlugin(const QString& pluginName); - /** - * \fn Plugin* checkPluginDependencie(QString name, Plugin* dependantPlugin) - * \brief checks for a dependencie Plugin, and set the dependencie link for the found Plugin - * - * \param name the name of the Plugin you have to check the existence in order to make a dependencie - * \param dependantPlugin a reference to the Plugin that asks for the dependencie that will be set as a - * dependant Plugin for the found Plugin - * - * \warning In the program this method is called under specific and controlled circumstances - * by the Plugins you should probably not call it. - * - * \return a pointer to the found dependencie Plugin, NULL if this Plugin wasn't referenced - * - * If the function failed, the error code ( Error::code ) is affected with a value - depending on the error. This error can be shown with Error::showError - * - * \see loadPlugin() - * \see VisualPlugin::addDependencie() - */ -// Plugin *checkPluginDependencie(QString name, Plugin *dependantPlugin); - +public: Plugin* getPlugin(const QString& name) const; QList getPluginsList() const { return h_plugins.values(); } const PluginHash& getPluginsHash() const { return h_plugins; } @@ -258,16 +220,31 @@ public: QList getMapsList() const { return h_maps.values(); } const MapHash& getMapsHash() const { return h_maps; } + /********************************************************* + * MANAGE LINKS + *********************************************************/ + +public slots: + void linkViewAndPlugin(View* v, Plugin* p); + void unlinkViewAndPlugin(View* v, Plugin* p); + + void linkViewAndMap(View* v, MapHandlerGen* m); + void unlinkViewAndMap(View* v, MapHandlerGen* m); + + void linkViewAndCamera(View* v, Camera* c); + /********************************************************* * MANAGE TEXTURES *********************************************************/ +public: Texture* getTexture(const QString& image); void releaseTexture(const QString& image); protected: QString m_appPath; PythonQtObjectPtr& m_pythonContext; + PythonQtScriptingConsole& m_pythonConsole; bool m_initialization; @@ -281,6 +258,8 @@ protected: QDockWidget* m_dock; QTabWidget* m_dockTabWidget; + QDockWidget* m_pythonDock; + PluginHash h_plugins; ViewHash h_views; CameraHash h_cameras; @@ -293,9 +272,6 @@ protected: MapsDialog* m_mapsDialog; public slots: - - Plugin* loadPlugin(const QString& pluginFilePath); - /** * \fn void cb_about_SCHNApps(); * \brief function that is called when the "about SCHNApps" menu action is triggered @@ -310,6 +286,8 @@ public slots: void cb_showHideDock(); + void cb_showHidePythonDock(); + /** * \fn void cb_manageCameras() * \brief method called when the "Cameras" action is triggered. diff --git a/SCHNApps/src/dialogs/cameraViewDialog.cpp b/SCHNApps/src/dialogs/cameraViewDialog.cpp index 815f9cc6718967ed20ee272c1f9ac9eaaf6aa76e..643e6d88c18f39da146a999d198d98bdd61b6843 100644 --- a/SCHNApps/src/dialogs/cameraViewDialog.cpp +++ b/SCHNApps/src/dialogs/cameraViewDialog.cpp @@ -57,9 +57,7 @@ void CameraViewDialog::cb_selectedCameraChanged() { const QString& cname = currentItems[0]->text(); Camera* c = m_window->getCamera(cname); - m_view->getCurrentCamera()->unlinkView(m_view); - m_view->setCurrentCamera(c); - c->linkView(m_view); + m_window->linkViewAndCamera(m_view, c); } } diff --git a/SCHNApps/src/dialogs/mapsViewDialog.cpp b/SCHNApps/src/dialogs/mapsViewDialog.cpp index a797b689e8ef0ab032903612ba7471be3a14765a..5a0192356d568ff786358dd65749e900649aa2cd 100644 --- a/SCHNApps/src/dialogs/mapsViewDialog.cpp +++ b/SCHNApps/src/dialogs/mapsViewDialog.cpp @@ -44,14 +44,12 @@ void MapsViewDialog::cb_selectedMapsChanged() if(mapList->item(i)->isSelected() && !m_view->isLinkedToMap(map)) { assert(!map->isLinkedToView(m_view)); - m_view->linkMap(map); - map->linkView(m_view); + m_window->linkViewAndMap(m_view, map); } else if(!mapList->item(i)->isSelected() && m_view->isLinkedToMap(map)) { assert(map->isLinkedToView(m_view)); - m_view->unlinkMap(map); - map->unlinkView(m_view); + m_window->unlinkViewAndMap(m_view, map); } } m_view->updateGL(); diff --git a/SCHNApps/src/dialogs/pluginsViewDialog.cpp b/SCHNApps/src/dialogs/pluginsViewDialog.cpp index 194a26a2e750c32f43a08320cfd8b5a72b131374..5fd38fef9f088478a0760b9384b914bd7b2f187c 100644 --- a/SCHNApps/src/dialogs/pluginsViewDialog.cpp +++ b/SCHNApps/src/dialogs/pluginsViewDialog.cpp @@ -46,14 +46,12 @@ void PluginsViewDialog::cb_selectedPluginsChanged() if(pluginList->item(i)->isSelected() && !m_view->isLinkedToPlugin(plugin)) { assert(!plugin->isLinkedToView(m_view)); - m_view->linkPlugin(plugin); - plugin->linkView(m_view); + m_window->linkViewAndPlugin(m_view, plugin); } else if(!pluginList->item(i)->isSelected() && m_view->isLinkedToPlugin(plugin)) { assert(plugin->isLinkedToView(m_view)); - m_view->unlinkPlugin(plugin); - plugin->unlinkView(m_view); + m_window->unlinkViewAndPlugin(m_view, plugin); } } m_view->updateGL(); diff --git a/SCHNApps/src/main.cpp b/SCHNApps/src/main.cpp index bae584bc88a016c22f98539b59494964f060a9f5..484d6d84af9d9b3f271786d5099245ffde322024 100644 --- a/SCHNApps/src/main.cpp +++ b/SCHNApps/src/main.cpp @@ -14,19 +14,25 @@ int main(int argc, char* argv[]) // init PythonQt and Python itself PythonQt::init(); + QStringList classNames; + classNames.append("Plugin"); + classNames.append("View"); + classNames.append("MapHandlerGen"); + classNames.append("Camera"); + PythonQt::self()->registerQObjectClassNames(classNames); + // get a smart pointer to the __main__ module of the Python interpreter PythonQtObjectPtr pythonContext = PythonQt::self()->getMainModule(); + PythonQtScriptingConsole pythonConsole(NULL, pythonContext); - CGoGN::SCHNApps::Window window(app.applicationDirPath(), pythonContext); - window.show(); + CGoGN::SCHNApps::Window schnapps(app.applicationDirPath(), pythonContext, pythonConsole); + schnapps.show(); - pythonContext.addObject("window", &window); + pythonContext.addObject("schnapps", &schnapps); + pythonContext.evalFile(app.applicationDirPath() + QString("/init.py")); - splash->finish(&window); + splash->finish(&schnapps); delete splash; - PythonQtScriptingConsole pythonConsole(NULL, pythonContext); - pythonConsole.show(); - return app.exec(); } diff --git a/SCHNApps/src/plugin.cpp b/SCHNApps/src/plugin.cpp index 3798da66e1f128e434d4c79908e7a8ca470e7a68..96182523796f3e3b116e8fb4199b391908b71bf0 100644 --- a/SCHNApps/src/plugin.cpp +++ b/SCHNApps/src/plugin.cpp @@ -40,16 +40,13 @@ Plugin::~Plugin() * MANAGE LINKED VIEWS *********************************************************/ -bool Plugin::linkView(View* view) +void Plugin::linkView(View* view) { if(view && !l_views.contains(view)) { l_views.push_back(view); viewLinked(view); - return true; } - else - return false; } void Plugin::unlinkView(View* view) diff --git a/SCHNApps/src/window.cpp b/SCHNApps/src/window.cpp index de06b20832f2cb79dc77b79d85cad4cf57d7ce43..79cbcd8cc39dcbdeb178045ce3d4a48029e50608 100644 --- a/SCHNApps/src/window.cpp +++ b/SCHNApps/src/window.cpp @@ -26,10 +26,11 @@ namespace CGoGN namespace SCHNApps { -Window::Window(const QString& appPath, PythonQtObjectPtr& pythonContext) : +Window::Window(const QString& appPath, PythonQtObjectPtr& pythonContext, PythonQtScriptingConsole& pythonConsole) : QMainWindow(), m_appPath(appPath), m_pythonContext(pythonContext), + m_pythonConsole(pythonConsole), m_firstView(NULL), m_currentView(NULL) { @@ -42,9 +43,9 @@ Window::Window(const QString& appPath, PythonQtObjectPtr& pythonContext) : this->setupUi(this); - m_dock = new QDockWidget(tr("Control"), this); - m_dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); - m_dock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetClosable); + m_dock = new QDockWidget(tr("Plugins' Tabs"), this); + m_dock->setAllowedAreas(Qt::RightDockWidgetArea); + m_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetClosable); addDockWidget(Qt::RightDockWidgetArea, m_dock); m_dock->setVisible(false); @@ -56,6 +57,15 @@ Window::Window(const QString& appPath, PythonQtObjectPtr& pythonContext) : connect(actionShowHideDock, SIGNAL(triggered()), this, SLOT(cb_showHideDock())); + m_pythonDock = new QDockWidget(tr("Python"), this); + m_pythonDock->setAllowedAreas(Qt::BottomDockWidgetArea); + m_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetClosable); + addDockWidget(Qt::BottomDockWidgetArea, m_pythonDock); + m_pythonDock->setVisible(false); + m_pythonDock->setWidget(&m_pythonConsole); + + connect(actionShowHidePythonDock, SIGNAL(triggered()), this, SLOT(cb_showHidePythonDock())); + m_centralLayout = new QVBoxLayout(centralwidget); m_rootSplitter = new QSplitter(centralwidget); @@ -77,17 +87,12 @@ Window::Window(const QString& appPath, PythonQtObjectPtr& pythonContext) : connect(actionManagePlugins, SIGNAL(triggered()), this, SLOT(cb_managePlugins())); connect(actionManageMaps, SIGNAL(triggered()), this, SLOT(cb_manageMaps())); -// System::StateHandler::loadState(this, &h_plugin, &h_scene, m_splitArea); - // program in its initialization phase m_initialization = false; - - m_pythonContext.addObject("dock", m_dock); } Window::~Window() { -// System::StateHandler::saveState(this, h_plugins); } /********************************************************* @@ -387,24 +392,17 @@ void Window::splitView(const QString& name, Qt::Orientation orientation) { View* newView = addView(); -// std::cout << "splitView" << std::endl; - View* view = h_views[name]; QSplitter* parent = (QSplitter*)(view->parentWidget()); if(parent == m_rootSplitter && !b_rootSplitterInitialized) { -// std::cout << "init root splitter" << std::endl; m_rootSplitter->setOrientation(orientation); b_rootSplitterInitialized = true; } if(parent->orientation() == orientation) - { -// std::cout << "same orientation" << std::endl; parent->insertWidget(parent->indexOf(view)+1, newView); - } else { -// std::cout << "new orientation" << std::endl; int idx = parent->indexOf(view); view->setParent(NULL); QSplitter* spl = new QSplitter(orientation); @@ -564,6 +562,41 @@ MapHandlerGen* Window::getMap(const QString& name) const return NULL; } +/********************************************************* + * MANAGE LINKS + *********************************************************/ + +void Window::linkViewAndPlugin(View* v, Plugin* p) +{ + v->linkPlugin(p); + p->linkView(v); +} + +void Window::unlinkViewAndPlugin(View* v, Plugin* p) +{ + v->unlinkPlugin(p); + p->unlinkView(v); +} + +void Window::linkViewAndMap(View* v, MapHandlerGen* m) +{ + v->linkMap(m); + m->linkView(v); +} + +void Window::unlinkViewAndMap(View* v, MapHandlerGen* m) +{ + v->unlinkMap(m); + m->unlinkView(v); +} + +void Window::linkViewAndCamera(View* v, Camera* c) +{ + v->getCurrentCamera()->unlinkView(v); + v->setCurrentCamera(c); + c->linkView(v); +} + /********************************************************* * MANAGE TEXTURES *********************************************************/ @@ -629,6 +662,11 @@ void Window::cb_showHideDock() m_dock->setVisible(m_dock->isHidden()); } +void Window::cb_showHidePythonDock() +{ + m_pythonDock->setVisible(m_pythonDock->isHidden()); +} + void Window::cb_manageCameras() { m_camerasDialog->show(); diff --git a/apps_cmake.txt b/apps_cmake.txt index f0d0b1a4dc06b28df21c5f7aee0cd812dfa0f1f6..6bb5c025e249956a98283a2b717f81f82822197e 100644 --- a/apps_cmake.txt +++ b/apps_cmake.txt @@ -6,8 +6,8 @@ SET(CMAKE_MODULE_PATH ${CGoGN_ROOT_DIR}/cmake_modules/) SET ( WITH_ASSIMP ON CACHE BOOL "need Assimp") SET ( WITH_NUMERICAL ON CACHE BOOL "need numerical libs") -SET ( WITH_ZINRI ON CACHE BOOL "need Zinri lib ") -SET ( WITH_QT ON CACHE BOOL "need Qt lib ") +SET ( WITH_ZINRI ON CACHE BOOL "need Zinri lib") +SET ( WITH_QT ON CACHE BOOL "need Qt lib") # for CGoGN MR file(STRINGS ${CGoGN_ROOT_DIR}/include/cgogn_mr.h FORCE_MR) @@ -46,7 +46,6 @@ add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/") # define includes of external libs SET(COMMON_INCLUDES ${CGoGN_ROOT_DIR}/ThirdParty/glm - ${CGoGN_ROOT_DIR}/ThirdParty/PythonQt/src ${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} @@ -78,12 +77,28 @@ ENDIF (WITH_ZINRI) IF (WITH_QT) find_package(Qt4 REQUIRED) + find_package(QGLViewer REQUIRED) + find_package(PythonLibs REQUIRED) + add_definitions(-DWITH_QT) SET(QT_USE_QTOPENGL TRUE) INCLUDE(${QT_USE_FILE}) ADD_DEFINITIONS(${QT_DEFINITIONS}) - SET (COMMON_INCLUDES ${COMMON_INCLUDES} ${QT_INCLUDE_DIR}) - SET (COMMON_LIBS ${COMMON_LIBS} ${QT_LIBRARIES}) + + SET (COMMON_INCLUDES + ${COMMON_INCLUDES} + ${QT_INCLUDE_DIR} + ${QGLVIEWER_INCLUDE_DIR} + ${PYTHON_INCLUDE_DIRS} + ${CGoGN_ROOT_DIR}/ThirdParty/PythonQt/src + ) + SET (COMMON_LIBS + ${COMMON_LIBS} + ${QT_LIBRARIES} + ${QGLVIEWER_LIBRARIES} + ${PYTHON_LIBRARIES} + PythonQt + ) ENDIF (WITH_QT) IF (WITH_NUMERICAL)