From 3ac5a5a6e91b21cc6a1230eeea27b0e00f9b16a2 Mon Sep 17 00:00:00 2001 From: Pierre Kraemer Date: Tue, 11 Dec 2012 17:01:52 +0100 Subject: [PATCH] SCHNApps: added orbits&cells info in maps dialog --- SCHNApps/forms/mapsDialog.ui | 132 +++++++++++++++++++++-- SCHNApps/include/dialogs/mapsDialog.h | 2 + SCHNApps/include/dialogs/pluginsDialog.h | 2 + SCHNApps/include/window.h | 3 +- SCHNApps/src/dialogs/mapsDialog.cpp | 93 ++++++++++------ SCHNApps/src/dialogs/pluginsDialog.cpp | 87 ++++++++------- SCHNApps/src/main.cpp | 3 +- SCHNApps/src/window.cpp | 3 +- include/Topology/generic/attribmap.h | 6 -- include/Topology/generic/attribmap.hpp | 5 - include/Topology/generic/genericmap.h | 6 ++ include/Topology/generic/genericmap.hpp | 5 + 12 files changed, 250 insertions(+), 97 deletions(-) diff --git a/SCHNApps/forms/mapsDialog.ui b/SCHNApps/forms/mapsDialog.ui index 6c65fe08..3e75d2ed 100644 --- a/SCHNApps/forms/mapsDialog.ui +++ b/SCHNApps/forms/mapsDialog.ui @@ -6,8 +6,8 @@ 0 0 - 683 - 659 + 457 + 374 @@ -19,7 +19,7 @@ - + 0 0 @@ -38,13 +38,37 @@ - 0 + 4 DART - + + + + + + + Nb orbits : + + + + + + + + + + Nb cells : + + + + + + + + @@ -54,7 +78,31 @@ VERTEX - + + + + + + + Nb orbits : + + + + + + + + + + Nb cells : + + + + + + + + @@ -65,6 +113,30 @@ EDGE + + + + + + Nb orbits : + + + + + + + + + + Nb cells : + + + + + + + + @@ -75,6 +147,30 @@ FACE + + + + + + Nb orbits : + + + + + + + + + + Nb cells : + + + + + + + + @@ -85,6 +181,30 @@ VOLUME + + + + + + Nb orbits : + + + + + + + + + + Nb cells : + + + + + + + + diff --git a/SCHNApps/include/dialogs/mapsDialog.h b/SCHNApps/include/dialogs/mapsDialog.h index c759a28e..b055dc29 100644 --- a/SCHNApps/include/dialogs/mapsDialog.h +++ b/SCHNApps/include/dialogs/mapsDialog.h @@ -23,6 +23,8 @@ public: private: Window* m_window; + void clearInfo(); + public slots: void cb_removeMap(); void cb_selectedMapChanged(); diff --git a/SCHNApps/include/dialogs/pluginsDialog.h b/SCHNApps/include/dialogs/pluginsDialog.h index db192b10..1d9060c4 100644 --- a/SCHNApps/include/dialogs/pluginsDialog.h +++ b/SCHNApps/include/dialogs/pluginsDialog.h @@ -40,6 +40,8 @@ protected: // bool restoreState(); + void addPluginsDirectory(const QString& dir); + private: bool init; diff --git a/SCHNApps/include/window.h b/SCHNApps/include/window.h index 61d3823d..a39fa9ad 100644 --- a/SCHNApps/include/window.h +++ b/SCHNApps/include/window.h @@ -31,7 +31,7 @@ public: * * \param parent the parent of the window */ - Window(QWidget* parent = NULL); + Window(const QString& appPath, QWidget* parent = NULL); /** * \fn ~Window() @@ -40,7 +40,6 @@ public: ~Window(); const QString& getAppPath() { return m_appPath; } - void setAppPath(const QString& path) { m_appPath = path; } /********************************************************* * MANAGE DOCK diff --git a/SCHNApps/src/dialogs/mapsDialog.cpp b/SCHNApps/src/dialogs/mapsDialog.cpp index 3336ffd1..5eb32423 100644 --- a/SCHNApps/src/dialogs/mapsDialog.cpp +++ b/SCHNApps/src/dialogs/mapsDialog.cpp @@ -30,6 +30,23 @@ MapsDialog::MapsDialog(Window* window) : MapsDialog::~MapsDialog() {} +void MapsDialog::clearInfo() +{ + dartAttributes->clear(); + vertexAttributes->clear(); + edgeAttributes->clear(); + faceAttributes->clear(); + volumeAttributes->clear(); + lineEdit_dart_orbits->setText(""); + lineEdit_dart_cells->setText(""); + lineEdit_vertex_orbits->setText(""); + lineEdit_vertex_cells->setText(""); + lineEdit_edge_orbits->setText(""); + lineEdit_edge_cells->setText(""); + lineEdit_face_orbits->setText(""); + lineEdit_face_cells->setText(""); +} + void MapsDialog::cb_removeMap() { QList currentItems = mapList->selectedItems(); @@ -38,7 +55,10 @@ void MapsDialog::cb_removeMap() const QString& name = currentItems[0]->text(); MapHandlerGen* m = m_window->getMap(name); if(!m->isUsed()) + { m_window->removeMap(name); + cb_selectedMapChanged(); + } else QMessageBox::warning(this, tr("Warning"), "Map is currently used"); } @@ -46,45 +66,50 @@ void MapsDialog::cb_removeMap() void MapsDialog::cb_selectedMapChanged() { + clearInfo(); + QList currentItems = mapList->selectedItems(); if(!currentItems.empty()) { QListWidgetItem* current = currentItems[0]; - dartAttributes->clear(); - vertexAttributes->clear(); - edgeAttributes->clear(); - faceAttributes->clear(); - volumeAttributes->clear(); - const QString& name = current->text(); MapHandlerGen* mh = m_window->getMap(name); - CGoGN::GenericMap* m = mh->getGenericMap(); - for(unsigned int orbit = CGoGN::DART; orbit <= CGoGN::VOLUME; ++orbit) + GenericMap* m = mh->getGenericMap(); + for(unsigned int orbit = DART; orbit <= FACE; ++orbit) { + unsigned int nbc = m->getNbCells(orbit); + switch(orbit) + { + case DART : { + unsigned int nb = m->getNbDarts(); + lineEdit_dart_orbits->setText(QString::number(nb)); + lineEdit_dart_cells->setText(QString::number(nbc)); + break; + } + case VERTEX : { + unsigned int nb = m->getNbOrbits(); + lineEdit_vertex_orbits->setText(QString::number(nb)); + lineEdit_vertex_cells->setText(QString::number(nbc)); + break; + } + case EDGE : { + unsigned int nb = m->getNbOrbits(); + lineEdit_edge_orbits->setText(QString::number(nb)); + lineEdit_edge_cells->setText(QString::number(nbc)); + break; + } + case FACE : { + unsigned int nb = m->getNbOrbits(); + lineEdit_face_orbits->setText(QString::number(nb)); + lineEdit_face_cells->setText(QString::number(nbc)); + break; + } + } + if(m->isOrbitEmbedded(orbit)) { -// unsigned int nb = 0; -// switch(orbit) -// { -// case CGoGN::DART : -// nb = m->getNbOrbits(); -// break; -// case CGoGN::VERTEX : -// nb = m->getNbOrbits(); -// break; -// case CGoGN::EDGE : -// nb = m->getNbOrbits(); -// break; -// case CGoGN::FACE : -// nb = m->getNbOrbits(); -// break; -// case CGoGN::VOLUME : -// nb = m->getNbOrbits(); -// break; -// } - - CGoGN::AttributeContainer& cont = m->getAttributeContainer(orbit); + AttributeContainer& cont = m->getAttributeContainer(orbit); std::vector names; std::vector types; cont.getAttributesNames(names); @@ -95,11 +120,11 @@ void MapsDialog::cb_selectedMapChanged() QString type = QString::fromStdString(types[i]); switch(orbit) { - case CGoGN::DART : dartAttributes->addItem(name + "(" + type + ")"); break; - case CGoGN::VERTEX : vertexAttributes->addItem(name + "(" + type + ")"); break; - case CGoGN::EDGE : edgeAttributes->addItem(name + "(" + type + ")"); break; - case CGoGN::FACE : faceAttributes->addItem(name + "(" + type + ")"); break; - case CGoGN::VOLUME : volumeAttributes->addItem(name + "(" + type + ")"); break; + case DART : dartAttributes->addItem(name + " (" + type + ")"); break; + case VERTEX : vertexAttributes->addItem(name + " (" + type + ")"); break; + case EDGE : edgeAttributes->addItem(name + " (" + type + ")"); break; + case FACE : faceAttributes->addItem(name + " (" + type + ")"); break; + case VOLUME : volumeAttributes->addItem(name + " (" + type + ")"); break; } } diff --git a/SCHNApps/src/dialogs/pluginsDialog.cpp b/SCHNApps/src/dialogs/pluginsDialog.cpp index bd28b275..f8b107ef 100644 --- a/SCHNApps/src/dialogs/pluginsDialog.cpp +++ b/SCHNApps/src/dialogs/pluginsDialog.cpp @@ -44,6 +44,8 @@ PluginsDialog::PluginsDialog(Window* window) : // restoreState(); + addPluginsDirectory(m_window->getAppPath() + QString("/../Plugins/")); + if (System::Error::code != System::Error::SUCCESS) System::Error::showError(this); @@ -156,6 +158,48 @@ PluginsDialog::~PluginsDialog() // return true; //} +void PluginsDialog::addPluginsDirectory(const QString& dir) +{ + QDir directory(dir); + + if (!directory.exists()) + System::Error::code = System::Error::BAD_PLUGIN_PATH_IN_FILE_f(directory.absolutePath()); + + QTreeWidgetItem *dirItem = new QTreeWidgetItem(treeWidget, DIR); + dirItem->setText(1, directory.path()); + + QStringList filters; + filters << "lib*.so"; + filters << "lib*.dylib"; + + QStringList dirFiles; + dirFiles = directory.entryList(filters, QDir::Files); + + const PluginHash& activePlugins = m_window->getPluginsHash(); + + foreach(QString pluginPath, dirFiles) + { + QFileInfo pfi(pluginPath); + QString pluginName = pfi.baseName().remove(0, 3); + PluginInfo pinfo(directory.absoluteFilePath(pluginPath), pluginName); + + QTreeWidgetItem *item = new QTreeWidgetItem(dirItem, FILE_DIR); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + + if (activePlugins.contains(pluginName)) + item->setCheckState(0, Qt::Checked); + else + item->setCheckState(0, Qt::Unchecked); + + item->setText(1, pluginName); + + m_listedPlugins[item] = pinfo; + } + + if (dirFiles.isEmpty()) + System::Error::code = System::Error::NO_PLUGIN_IN_DIR_f(directory.absolutePath()); +} + void PluginsDialog::cb_addPlugins() { init = true; @@ -163,7 +207,7 @@ void PluginsDialog::cb_addPlugins() QStringList files = QFileDialog::getOpenFileNames( this, "Select one or more plugins", - m_window->getAppPath() + QString("/../Plugins/"), + m_window->getAppPath(), "Plugins (lib*.so lib*.dylib)" ); @@ -202,46 +246,7 @@ void PluginsDialog::cb_addPluginsDirectory() ); if (!dir.isEmpty()) - { - QDir directory(dir); - - if (!directory.exists()) - System::Error::code = System::Error::BAD_PLUGIN_PATH_IN_FILE_f(directory.absolutePath()); - - QTreeWidgetItem *dirItem = new QTreeWidgetItem(treeWidget, DIR); - dirItem->setText(1, directory.path()); - - QStringList filters; - filters << "lib*.so"; - filters << "lib*.dylib"; - - QStringList dirFiles; - dirFiles = directory.entryList(filters, QDir::Files); - - const PluginHash& activePlugins = m_window->getPluginsHash(); - - foreach(QString pluginPath, dirFiles) - { - QFileInfo pfi(pluginPath); - QString pluginName = pfi.baseName().remove(0, 3); - PluginInfo pinfo(directory.absoluteFilePath(pluginPath), pluginName); - - QTreeWidgetItem *item = new QTreeWidgetItem(dirItem, FILE_DIR); - item->setFlags(item->flags() | Qt::ItemIsUserCheckable); - - if (activePlugins.contains(pluginName)) - item->setCheckState(0, Qt::Checked); - else - item->setCheckState(0, Qt::Unchecked); - - item->setText(1, pluginName); - - m_listedPlugins[item] = pinfo; - } - - if (dirFiles.isEmpty()) - System::Error::code = System::Error::NO_PLUGIN_IN_DIR_f(directory.absolutePath()); - } + addPluginsDirectory(dir); if (System::Error::code != System::Error::SUCCESS) System::Error::showError(this); diff --git a/SCHNApps/src/main.cpp b/SCHNApps/src/main.cpp index b87920e6..e37fba05 100644 --- a/SCHNApps/src/main.cpp +++ b/SCHNApps/src/main.cpp @@ -9,8 +9,7 @@ int main(int argc, char* argv[]) splash->show(); splash->showMessage("Welcome to SCHNApps", Qt::AlignBottom | Qt::AlignCenter); - CGoGN::SCHNApps::Window window; - window.setAppPath(app.applicationDirPath()); + CGoGN::SCHNApps::Window window(app.applicationDirPath()); window.show(); splash->finish(&window); diff --git a/SCHNApps/src/window.cpp b/SCHNApps/src/window.cpp index eda3c894..96f35d5c 100644 --- a/SCHNApps/src/window.cpp +++ b/SCHNApps/src/window.cpp @@ -24,8 +24,9 @@ namespace CGoGN namespace SCHNApps { -Window::Window(QWidget *parent) : +Window::Window(const QString& appPath, QWidget *parent) : QMainWindow(parent), + m_appPath(appPath), m_firstView(NULL), m_currentView(NULL) { diff --git a/include/Topology/generic/attribmap.h b/include/Topology/generic/attribmap.h index c5912b45..42643392 100644 --- a/include/Topology/generic/attribmap.h +++ b/include/Topology/generic/attribmap.h @@ -84,12 +84,6 @@ public: template bool copyAttribute(AttributeHandler& dst, AttributeHandler& src) ; - /** - * get the number of cell in the attribute container of an orbit - * @param orb the orbit to get number of cells - */ - unsigned int getNbCells(unsigned int orbit); - /**************************************** * UTILITIES * diff --git a/include/Topology/generic/attribmap.hpp b/include/Topology/generic/attribmap.hpp index 40e7c5be..670f7cf9 100644 --- a/include/Topology/generic/attribmap.hpp +++ b/include/Topology/generic/attribmap.hpp @@ -83,11 +83,6 @@ inline bool AttribMap::copyAttribute(AttributeHandler& dst, AttributeH return false ; } -inline unsigned int AttribMap::getNbCells(unsigned int orbit) -{ - return this->m_attribs[orbit].size() ; -} - /**************************************** * UTILITIES * ****************************************/ diff --git a/include/Topology/generic/genericmap.h b/include/Topology/generic/genericmap.h index f6e71877..7326f5cc 100644 --- a/include/Topology/generic/genericmap.h +++ b/include/Topology/generic/genericmap.h @@ -466,6 +466,12 @@ public: * ATTRIBUTES MANAGEMENT * ****************************************/ + /** + * get the number of cell in the attribute container of an orbit + * @param orb the orbit to get number of cells + */ + unsigned int getNbCells(unsigned int orbit); + /** * get the attrib container of a given orbit * @param orbit the orbit !!! (bilbo the orbit !) diff --git a/include/Topology/generic/genericmap.hpp b/include/Topology/generic/genericmap.hpp index 68841fe6..e0e7ef55 100644 --- a/include/Topology/generic/genericmap.hpp +++ b/include/Topology/generic/genericmap.hpp @@ -489,6 +489,11 @@ inline void GenericMap::disableQuickTraversal() * ATTRIBUTES MANAGEMENT * ****************************************/ +inline unsigned int GenericMap::getNbCells(unsigned int orbit) +{ + return m_attribs[orbit].size() ; +} + template inline AttributeContainer& GenericMap::getAttributeContainer() { -- GitLab