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

SCHNApps: added orbits&cells info in maps dialog

parent 7a3c137f
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>683</width>
<height>659</height>
<width>457</width>
<height>374</height>
</rect>
</property>
<property name="windowTitle">
......@@ -19,7 +19,7 @@
<item>
<widget class="QListWidget" name="mapList">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
......@@ -38,13 +38,37 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>4</number>
</property>
<widget class="QWidget" name="dartTab">
<attribute name="title">
<string>DART</string>
</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>
<widget class="QListWidget" name="dartAttributes"/>
</item>
......@@ -54,7 +78,31 @@
<attribute name="title">
<string>VERTEX</string>
</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>
<widget class="QListWidget" name="vertexAttributes"/>
</item>
......@@ -65,6 +113,30 @@
<string>EDGE</string>
</attribute>
<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>
<widget class="QListWidget" name="edgeAttributes"/>
</item>
......@@ -75,6 +147,30 @@
<string>FACE</string>
</attribute>
<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>
<widget class="QListWidget" name="faceAttributes"/>
</item>
......@@ -85,6 +181,30 @@
<string>VOLUME</string>
</attribute>
<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>
<widget class="QListWidget" name="volumeAttributes"/>
</item>
......
......@@ -23,6 +23,8 @@ public:
private:
Window* m_window;
void clearInfo();
public slots:
void cb_removeMap();
void cb_selectedMapChanged();
......
......@@ -40,6 +40,8 @@ protected:
// bool restoreState();
void addPluginsDirectory(const QString& dir);
private:
bool init;
......
......@@ -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
......
......@@ -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<QListWidgetItem*> 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<QListWidgetItem*> 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<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))
{
// unsigned int nb = 0;
// 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);
AttributeContainer& cont = m->getAttributeContainer(orbit);
std::vector<std::string> names;
std::vector<std::string> 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;
}
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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)
{
......
......@@ -84,12 +84,6 @@ public:
template <typename T, unsigned int ORBIT>
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 *
......
......@@ -83,11 +83,6 @@ inline bool AttribMap::copyAttribute(AttributeHandler<T, ORBIT>& dst, AttributeH
return false ;
}
inline unsigned int AttribMap::getNbCells(unsigned int orbit)
{
return this->m_attribs[orbit].size() ;
}
/****************************************
* UTILITIES *
****************************************/
......
......@@ -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 !)
......
......@@ -489,6 +489,11 @@ inline void GenericMap::disableQuickTraversal()
* ATTRIBUTES MANAGEMENT *
****************************************/
inline unsigned int GenericMap::getNbCells(unsigned int orbit)
{
return m_attribs[orbit].size() ;
}
template <unsigned int ORBIT>
inline AttributeContainer& GenericMap::getAttributeContainer()
{
......
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