mirror of https://github.com/CGAL/cgal
Merge pull request #2235 from maxGimeno/Make_the_statistics_exportable-GF
Polyhedron_demo: make the statistics exportable
This commit is contained in:
commit
25367b9141
|
|
@ -1854,6 +1854,8 @@ void MainWindow::statisticsOnItem()
|
||||||
statistics_dlg, SLOT(accept()));
|
statistics_dlg, SLOT(accept()));
|
||||||
connect(statistics_ui->updateButton, SIGNAL(clicked()),
|
connect(statistics_ui->updateButton, SIGNAL(clicked()),
|
||||||
this, SLOT(statisticsOnItem()));
|
this, SLOT(statisticsOnItem()));
|
||||||
|
connect(statistics_ui->exportButton, &QPushButton::clicked,
|
||||||
|
this, &MainWindow::exportStatistics);
|
||||||
}
|
}
|
||||||
statistics_ui->label_htmltab->setText(get_item_stats());
|
statistics_ui->label_htmltab->setText(get_item_stats());
|
||||||
|
|
||||||
|
|
@ -2032,3 +2034,53 @@ void MainWindow::set_facegraph_mode_adapter(bool is_polyhedron)
|
||||||
set_face_graph_default_type(SURFACE_MESH);
|
set_face_graph_default_type(SURFACE_MESH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::exportStatistics()
|
||||||
|
{
|
||||||
|
std::vector<Scene_item*> items;
|
||||||
|
Q_FOREACH(int id, getSelectedSceneItemIndices())
|
||||||
|
{
|
||||||
|
Scene_item* s_item = scene->item(id);
|
||||||
|
items.push_back(s_item);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString str;
|
||||||
|
Q_FOREACH(Scene_item* sit, items)
|
||||||
|
{
|
||||||
|
CGAL::Three::Scene_item::Header_data data = sit->header();
|
||||||
|
if(data.titles.size()>0)
|
||||||
|
{
|
||||||
|
int titles_limit =0;
|
||||||
|
int title = 0;
|
||||||
|
str.append(QString("%1: \n").arg(sit->name()));
|
||||||
|
for(int j=0; j<data.categories.size(); j++)
|
||||||
|
{
|
||||||
|
str.append(QString(" %1: \n")
|
||||||
|
.arg(data.categories[j].first));
|
||||||
|
titles_limit+=data.categories[j].second;
|
||||||
|
for(;title<titles_limit; ++title)
|
||||||
|
{
|
||||||
|
str.append(QString(" %1: ").arg(data.titles.at(title)));
|
||||||
|
str.append(QString("%1\n").arg(sit->computeStats(title)));
|
||||||
|
title++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString filename =
|
||||||
|
QFileDialog::getSaveFileName((QWidget*)sender(),
|
||||||
|
"",
|
||||||
|
QString("Statistics.txt"),
|
||||||
|
"Text Files (*.txt)");
|
||||||
|
if(filename.isEmpty())
|
||||||
|
return;
|
||||||
|
QFile output(filename);
|
||||||
|
output.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
|
|
||||||
|
if(!output.isOpen()){
|
||||||
|
qDebug() << "- Error, unable to open" << "outputFilename" << "for output";
|
||||||
|
}
|
||||||
|
QTextStream outStream(&output);
|
||||||
|
outStream << str;
|
||||||
|
output.close();
|
||||||
|
}
|
||||||
|
|
@ -240,6 +240,11 @@ public Q_SLOTS:
|
||||||
* set_face_graph_default_type sets the global state of the application to `Polyhedron mode` or `Surface_mesh mode`.
|
* set_face_graph_default_type sets the global state of the application to `Polyhedron mode` or `Surface_mesh mode`.
|
||||||
*/
|
*/
|
||||||
void set_face_graph_default_type(MainWindow::Face_graph_mode m);
|
void set_face_graph_default_type(MainWindow::Face_graph_mode m);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Writes the statistics dialog content in a text file.
|
||||||
|
*/
|
||||||
|
void exportStatistics();
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
|
|
||||||
//!Gets the new selected item(s) from the Geometric Objects view and updates the scene
|
//!Gets the new selected item(s) from the Geometric Objects view and updates the scene
|
||||||
|
|
|
||||||
|
|
@ -25,22 +25,8 @@
|
||||||
<property name="modal">
|
<property name="modal">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,0,0">
|
||||||
<item row="4" column="0">
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="okButtonBox">
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0" alignment="Qt::AlignRight">
|
|
||||||
<widget class="QToolButton" name="updateButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Update</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextEdit" name="label_htmltab">
|
<widget class="QTextEdit" name="label_htmltab">
|
||||||
|
|
@ -63,6 +49,44 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1,0">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="exportButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Export...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="updateButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Update</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="okButtonBox">
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue