diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 38392367d7e..b842b379f2d 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1854,6 +1854,8 @@ void MainWindow::statisticsOnItem() statistics_dlg, SLOT(accept())); connect(statistics_ui->updateButton, SIGNAL(clicked()), this, SLOT(statisticsOnItem())); + connect(statistics_ui->exportButton, &QPushButton::clicked, + this, &MainWindow::exportStatistics); } 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); } +void MainWindow::exportStatistics() +{ + std::vector 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; jcomputeStats(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(); +} \ No newline at end of file diff --git a/Polyhedron/demo/Polyhedron/MainWindow.h b/Polyhedron/demo/Polyhedron/MainWindow.h index 747fca813ad..ee17a2e7a60 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.h +++ b/Polyhedron/demo/Polyhedron/MainWindow.h @@ -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`. */ 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: //!Gets the new selected item(s) from the Geometric Objects view and updates the scene diff --git a/Polyhedron/demo/Polyhedron/Statistics_on_item_dialog.ui b/Polyhedron/demo/Polyhedron/Statistics_on_item_dialog.ui index dafc0dacc8a..d5076cdcbbe 100644 --- a/Polyhedron/demo/Polyhedron/Statistics_on_item_dialog.ui +++ b/Polyhedron/demo/Polyhedron/Statistics_on_item_dialog.ui @@ -25,22 +25,8 @@ false - - - - - QDialogButtonBox::Ok - - - - - - - Update - - - - + + @@ -63,6 +49,44 @@ + + + + + + &Export... + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Update + + + + + + + + + QDialogButtonBox::Ok + + +