Commit 3ac5a5a6 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: added orbits&cells info in maps dialog

parent 7a3c137f
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>683</width> <width>457</width>
<height>659</height> <height>374</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<item> <item>
<widget class="QListWidget" name="mapList"> <widget class="QListWidget" name="mapList">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
...@@ -38,13 +38,37 @@ ...@@ -38,13 +38,37 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>4</number>
</property> </property>
<widget class="QWidget" name="dartTab"> <widget class="QWidget" name="dartTab">
<attribute name="title"> <attribute name="title">
<string>DART</string> <string>DART</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_dart_orbits">
<property name="text">
<string>Nb orbits :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dart_orbits"/>
</item>
<item>
<widget class="QLabel" name="label_dart_cells">
<property name="text">
<string>Nb cells :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dart_cells"/>
</item>
</layout>
</item>
<item> <item>
<widget class="QListWidget" name="dartAttributes"/> <widget class="QListWidget" name="dartAttributes"/>
</item> </item>
...@@ -54,7 +78,31 @@ ...@@ -54,7 +78,31 @@
<attribute name="title"> <attribute name="title">
<string>VERTEX</string> <string>VERTEX</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_vertex_orbits">
<property name="text">
<string>Nb orbits :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_vertex_orbits"/>
</item>
<item>
<widget class="QLabel" name="label_vertex_cells">
<property name="text">
<string>Nb cells :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_vertex_cells"/>
</item>
</layout>
</item>
<item> <item>
<widget class="QListWidget" name="vertexAttributes"/> <widget class="QListWidget" name="vertexAttributes"/>
</item> </item>
...@@ -65,6 +113,30 @@ ...@@ -65,6 +113,30 @@
<string>EDGE</string> <string>EDGE</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_edge_orbits">
<property name="text">
<string>Nb orbits :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_edge_orbits"/>
</item>
<item>
<widget class="QLabel" name="label_edge_cells">
<property name="text">
<string>Nb cells :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_edge_cells"/>
</item>
</layout>
</item>
<item> <item>
<widget class="QListWidget" name="edgeAttributes"/> <widget class="QListWidget" name="edgeAttributes"/>
</item> </item>
...@@ -75,6 +147,30 @@ ...@@ -75,6 +147,30 @@
<string>FACE</string> <string>FACE</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_face_orbits">
<property name="text">
<string>Nb orbits :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_face_orbits"/>
</item>
<item>
<widget class="QLabel" name="label_face_cells">
<property name="text">
<string>Nb cells :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_face_cells"/>
</item>
</layout>
</item>
<item> <item>
<widget class="QListWidget" name="faceAttributes"/> <widget class="QListWidget" name="faceAttributes"/>
</item> </item>
...@@ -85,6 +181,30 @@ ...@@ -85,6 +181,30 @@
<string>VOLUME</string> <string>VOLUME</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_volume_orbits">
<property name="text">
<string>Nb orbits :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_volume_orbits"/>
</item>
<item>
<widget class="QLabel" name="label_volume_cells">
<property name="text">
<string>Nb cells :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_volume_cells"/>
</item>
</layout>
</item>
<item> <item>
<widget class="QListWidget" name="volumeAttributes"/> <widget class="QListWidget" name="volumeAttributes"/>
</item> </item>
......
...@@ -23,6 +23,8 @@ public: ...@@ -23,6 +23,8 @@ public:
private: private:
Window* m_window; Window* m_window;
void clearInfo();
public slots: public slots:
void cb_removeMap(); void cb_removeMap();
void cb_selectedMapChanged(); void cb_selectedMapChanged();
......
...@@ -40,6 +40,8 @@ protected: ...@@ -40,6 +40,8 @@ protected:
// bool restoreState(); // bool restoreState();
void addPluginsDirectory(const QString& dir);
private: private:
bool init; bool init;
......
...@@ -31,7 +31,7 @@ public: ...@@ -31,7 +31,7 @@ public:
* *
* \param parent the parent of the window * \param parent the parent of the window
*/ */
Window(QWidget* parent = NULL); Window(const QString& appPath, QWidget* parent = NULL);
/** /**
* \fn ~Window() * \fn ~Window()
...@@ -40,7 +40,6 @@ public: ...@@ -40,7 +40,6 @@ public:
~Window(); ~Window();
const QString& getAppPath() { return m_appPath; } const QString& getAppPath() { return m_appPath; }
void setAppPath(const QString& path) { m_appPath = path; }
/********************************************************* /*********************************************************
* MANAGE DOCK * MANAGE DOCK
......
...@@ -30,6 +30,23 @@ MapsDialog::MapsDialog(Window* window) : ...@@ -30,6 +30,23 @@ MapsDialog::MapsDialog(Window* window) :
MapsDialog::~MapsDialog() 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() void MapsDialog::cb_removeMap()
{ {
QList<QListWidgetItem*> currentItems = mapList->selectedItems(); QList<QListWidgetItem*> currentItems = mapList->selectedItems();
...@@ -38,7 +55,10 @@ void MapsDialog::cb_removeMap() ...@@ -38,7 +55,10 @@ void MapsDialog::cb_removeMap()
const QString& name = currentItems[0]->text(); const QString& name = currentItems[0]->text();
MapHandlerGen* m = m_window->getMap(name); MapHandlerGen* m = m_window->getMap(name);
if(!m->isUsed()) if(!m->isUsed())
{
m_window->removeMap(name); m_window->removeMap(name);
cb_selectedMapChanged();
}
else else
QMessageBox::warning(this, tr("Warning"), "Map is currently used"); QMessageBox::warning(this, tr("Warning"), "Map is currently used");
} }
...@@ -46,45 +66,50 @@ void MapsDialog::cb_removeMap() ...@@ -46,45 +66,50 @@ void MapsDialog::cb_removeMap()
void MapsDialog::cb_selectedMapChanged() void MapsDialog::cb_selectedMapChanged()
{ {
clearInfo();
QList<QListWidgetItem*> currentItems = mapList->selectedItems(); QList<QListWidgetItem*> currentItems = mapList->selectedItems();
if(!currentItems.empty()) if(!currentItems.empty())
{ {
QListWidgetItem* current = currentItems[0]; QListWidgetItem* current = currentItems[0];
dartAttributes->clear();
vertexAttributes->clear();
edgeAttributes->clear();
faceAttributes->clear();
volumeAttributes->clear();
const QString& name = current->text(); const QString& name = current->text();
MapHandlerGen* mh = m_window->getMap(name); MapHandlerGen* mh = m_window->getMap(name);
CGoGN::GenericMap* m = mh->getGenericMap(); GenericMap* m = mh->getGenericMap();
for(unsigned int orbit = CGoGN::DART; orbit <= CGoGN::VOLUME; ++orbit) 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<VERTEX>();
lineEdit_vertex_orbits->setText(QString::number(nb));
lineEdit_vertex_cells->setText(QString::number(nbc));
break;
}
case EDGE : {
unsigned int nb = m->getNbOrbits<EDGE>();
lineEdit_edge_orbits->setText(QString::number(nb));
lineEdit_edge_cells->setText(QString::number(nbc));
break;
}
case FACE : {
unsigned int nb = m->getNbOrbits<FACE>();
lineEdit_face_orbits->setText(QString::number(nb));
lineEdit_face_cells->setText(QString::number(nbc));
break;
}
}
if(m->isOrbitEmbedded(orbit)) if(m->isOrbitEmbedded(orbit))
{ {
// unsigned int nb = 0; AttributeContainer& cont = m->getAttributeContainer(orbit);
// switch(orbit)
// {
// case CGoGN::DART :
// nb = m->getNbOrbits<CGoGN::DART>();
// break;
// case CGoGN::VERTEX :
// nb = m->getNbOrbits<CGoGN::VERTEX>();
// break;
// case CGoGN::EDGE :
// nb = m->getNbOrbits<CGoGN::EDGE>();
// break;
// case CGoGN::FACE :
// nb = m->getNbOrbits<CGoGN::FACE>();
// break;
// case CGoGN::VOLUME :
// nb = m->getNbOrbits<CGoGN::VOLUME>();
// break;
// }
CGoGN::AttributeContainer& cont = m->getAttributeContainer(orbit);
std::vector<std::string> names; std::vector<std::string> names;
std::vector<std::string> types; std::vector<std::string> types;
cont.getAttributesNames(names); cont.getAttributesNames(names);
...@@ -95,11 +120,11 @@ void MapsDialog::cb_selectedMapChanged() ...@@ -95,11 +120,11 @@ void MapsDialog::cb_selectedMapChanged()
QString type = QString::fromStdString(types[i]); QString type = QString::fromStdString(types[i]);
switch(orbit) switch(orbit)
{ {
case CGoGN::DART : dartAttributes->addItem(name + "(" + type + ")"); break; case DART : dartAttributes->addItem(name + " (" + type + ")"); break;
case CGoGN::VERTEX : vertexAttributes->addItem(name + "(" + type + ")"); break; case VERTEX : vertexAttributes->addItem(name + " (" + type + ")"); break;
case CGoGN::EDGE : edgeAttributes->addItem(name + "(" + type + ")"); break; case EDGE : edgeAttributes->addItem(name + " (" + type + ")"); break;
case CGoGN::FACE : faceAttributes->addItem(name + "(" + type + ")"); break; case FACE : faceAttributes->addItem(name + " (" + type + ")"); break;
case CGoGN::VOLUME : volumeAttributes->addItem(name + "(" + type + ")"); break; case VOLUME : volumeAttributes->addItem(name + " (" + type + ")"); break;
} }
} }
......
...@@ -44,6 +44,8 @@ PluginsDialog::PluginsDialog(Window* window) : ...@@ -44,6 +44,8 @@ PluginsDialog::PluginsDialog(Window* window) :
// restoreState(); // restoreState();
addPluginsDirectory(m_window->getAppPath() + QString("/../Plugins/"));
if (System::Error::code != System::Error::SUCCESS) if (System::Error::code != System::Error::SUCCESS)
System::Error::showError(this); System::Error::showError(this);
...@@ -156,6 +158,48 @@ PluginsDialog::~PluginsDialog() ...@@ -156,6 +158,48 @@ PluginsDialog::~PluginsDialog()
// return true; // 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() void PluginsDialog::cb_addPlugins()
{ {
init = true; init = true;
...@@ -163,7 +207,7 @@ void PluginsDialog::cb_addPlugins() ...@@ -163,7 +207,7 @@ void PluginsDialog::cb_addPlugins()
QStringList files = QFileDialog::getOpenFileNames( QStringList files = QFileDialog::getOpenFileNames(
this, this,
"Select one or more plugins", "Select one or more plugins",
m_window->getAppPath() + QString("/../Plugins/"), m_window->getAppPath(),
"Plugins (lib*.so lib*.dylib)" "Plugins (lib*.so lib*.dylib)"
); );
...@@ -202,46 +246,7 @@ void PluginsDialog::cb_addPluginsDirectory() ...@@ -202,46 +246,7 @@ void PluginsDialog::cb_addPluginsDirectory()
); );
if (!dir.isEmpty()) if (!dir.isEmpty())
{ addPluginsDirectory(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());
}
if (System::Error::code != System::Error::SUCCESS) if (System::Error::code != System::Error::SUCCESS)
System::Error::showError(this); System::Error::showError(this);
......
...@@ -9,8 +9,7 @@ int main(int argc, char* argv[]) ...@@ -9,8 +9,7 @@ int main(int argc, char* argv[])
splash->show(); splash->show();
splash->showMessage("Welcome to SCHNApps", Qt::AlignBottom | Qt::AlignCenter); splash->showMessage("Welcome to SCHNApps", Qt::AlignBottom | Qt::AlignCenter);
CGoGN::SCHNApps::Window window; CGoGN::SCHNApps::Window window(app.applicationDirPath());
window.setAppPath(app.applicationDirPath());
window.show(); window.show();
splash->finish(&window); splash->finish(&window);
......
...@@ -24,8 +24,9 @@ namespace CGoGN ...@@ -24,8 +24,9 @@ namespace CGoGN
namespace SCHNApps namespace SCHNApps
{ {
Window::Window(QWidget *parent) : Window::Window(const QString& appPath, QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
m_appPath(appPath),
m_firstView(NULL), m_firstView(NULL),
m_currentView(NULL) m_currentView(NULL)
{ {
......
...@@ -84,12 +84,6 @@ public: ...@@ -84,12 +84,6 @@ public:
template <typename T, unsigned int ORBIT> template <typename T, unsigned int ORBIT>
bool copyAttribute(AttributeHandler<T, ORBIT>& dst, AttributeHandler<T, ORBIT>& src) ; bool copyAttribute(AttributeHandler<T, ORBIT>& dst, AttributeHandler<T, ORBIT>& 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 * * UTILITIES *
......
...@@ -83,11 +83,6 @@ inline bool AttribMap::copyAttribute(AttributeHandler<T, ORBIT>& dst, AttributeH ...@@ -83,11 +83,6 @@ inline bool AttribMap::copyAttribute(AttributeHandler<T, ORBIT>& dst, AttributeH
return false ; return false ;
} }
inline unsigned int AttribMap::getNbCells(unsigned int orbit)
{
return this->m_attribs[orbit].size() ;
}
/**************************************** /****************************************
* UTILITIES * * UTILITIES *
****************************************/ ****************************************/
......
...@@ -466,6 +466,12 @@ public: ...@@ -466,6 +466,12 @@ public:
* ATTRIBUTES MANAGEMENT * * ATTRIBUTES MANAGEMENT *
****************************************/ ****************************************/