From e24f1b0e83ce38a3cef3944506d88fa36582e0ad Mon Sep 17 00:00:00 2001
From: Dimitris Kalamaras
Date: Fri, 1 Mar 2019 18:20:49 +0200
Subject: [PATCH] work on #81 - Working prominence index reports with nice
distribution chart! Right now, only works for lines
---
src/chart.cpp | 13 +-
src/forms/dialogsettings.cpp | 2 +
src/forms/dialogsettings.h | 5 +-
src/graph.cpp | 381 ++++++++++++++++++++++++++++++-----
src/graph.h | 15 +-
src/mainwindow.cpp | 55 +++--
src/mainwindow.h | 5 +-
7 files changed, 393 insertions(+), 83 deletions(-)
diff --git a/src/chart.cpp b/src/chart.cpp
index ada4352f..44527f9a 100644
--- a/src/chart.cpp
+++ b/src/chart.cpp
@@ -88,6 +88,7 @@ void Chart::addSeries(QAbstractSeries *series) {
qDebug() << "Chart::addSeries()" ;
// m_series = series;
if (series) {
+ qDebug() << "Chart::addSeries() - series name"<< series->name() ;
m_chart->addSeries(series);
}
else {
@@ -117,6 +118,7 @@ void Chart::appendToSeries(const QPointF &p) {
* @brief Removes and deletes all series objects that have been added to the chart.
*/
void Chart::removeAllSeries() {
+ qDebug() <<"Chart::removeAllSeries() " ;
m_chart->removeAllSeries();
}
@@ -143,8 +145,11 @@ QList Chart::axes(Qt::Orientations orientation,
* @brief Removes all previously attached X,Y axes from the QChart
*/
void Chart::removeAllAxes(){
- m_chart->removeAxis( m_chart->axisX() );
- m_chart->removeAxis( m_chart->axisY() );
+// m_chart->removeAxis( m_chart->axisX() );
+// m_chart->removeAxis( m_chart->axisY() );
+
+ qDebug() << "Chart::removeAllAxes()";
+ qDebug() << "Chart::removeAllAxes() - m_chart axes: "<< m_chart->axes().size();
if ( m_chart->axes().size()>0) {
foreach ( QAbstractAxis *axe, m_chart->axes() ) {
@@ -165,6 +170,7 @@ void Chart::removeAllAxes(){
* @param series
*/
void Chart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) {
+ qDebug()<<"Chart::setAxisX()";
m_chart->setAxisX(axis, series);
}
@@ -179,6 +185,7 @@ void Chart::setAxisX(QAbstractAxis *axis, QAbstractSeries *series) {
* @param series
*/
void Chart::setAxisY(QAbstractAxis *axis, QAbstractSeries *series) {
+ qDebug()<<"Chart::setAxisY()";
m_chart->setAxisY(axis, series);
}
@@ -386,6 +393,7 @@ void Chart::setAxesThemeDefault() {
void Chart::resetToTrivial() {
+ qDebug()<< "Chart::resetToTrivial()";
removeAllSeries();
addSeries();
createDefaultAxes();
@@ -422,6 +430,7 @@ QPixmap Chart::getPixmap()
//hide the widget
w->hide();
+ qDebug()<< "Chart::getPixmap() ends!";
w->deleteLater();
return pixmap;
}
diff --git a/src/forms/dialogsettings.cpp b/src/forms/dialogsettings.cpp
index 5ed051d1..e73a87e8 100755
--- a/src/forms/dialogsettings.cpp
+++ b/src/forms/dialogsettings.cpp
@@ -524,6 +524,8 @@ void DialogSettings::getDataDir(){
}
ui->dataDirEdit->setText(m_dataDir);
m_appSettings["dataDir"]= m_dataDir;
+
+ emit setReportsDataDir (m_dataDir);
}
}
diff --git a/src/forms/dialogsettings.h b/src/forms/dialogsettings.h
index 370bd504..6b5eb97e 100755
--- a/src/forms/dialogsettings.h
+++ b/src/forms/dialogsettings.h
@@ -86,11 +86,14 @@ public slots:
void getEdgeLabelsVisibility(const bool &toggle);
signals:
- void setStyleSheetDefault(const bool &toggle);
+ void setReportsDataDir (const QString &dir);
+
void setReportsRealNumberPrecision(const int &precision);
void setReportsLabelLength(const int &length);
void setReportsChartType(const int &type);
+ void setStyleSheetDefault(const bool &toggle);
+
void setProgressDialog(bool);
void setToolBar(bool);
void setStatusBar(bool);
diff --git a/src/graph.cpp b/src/graph.cpp
index c42df89d..03ab121e 100755
--- a/src/graph.cpp
+++ b/src/graph.cpp
@@ -119,6 +119,7 @@ Graph::Graph(GraphicsWidget *graphicsWidget) {
calculatedPRP=false;
calculatedTriad=false;
+ m_reportsDataDir = "";
m_reportsRealPrecision = 6;
m_reportsLabelLength = 8;
m_reportsChartType = ChartType::Spline;
@@ -6298,7 +6299,16 @@ void Graph::writeCentralityInformation(const QString fileName,
centralityInformation(considerWeights, inverseWeights);
- prominenceDistribution(IndexType::IC, m_reportsChartType);
+ QString distImageFileName ;
+
+ if ( m_reportsChartType != ChartType::None ) {
+
+ distImageFileName = QFileInfo(fileName).canonicalPath() +
+ QDir::separator() + QFileInfo(fileName).completeBaseName() + ".png";
+
+ }
+
+ prominenceDistribution(IndexType::IC, m_reportsChartType, distImageFileName);
VList::const_iterator it;
@@ -6475,6 +6485,16 @@ void Graph::writeCentralityInformation(const QString fileName,
outText << "
";
+ if ( m_reportsChartType != ChartType::None ) {
+ outText << ", PairVFCompare> seriesPQ;
@@ -7177,7 +7224,7 @@ void Graph::prominenceDistributionSpline(const H_StrToInt &discreteClasses,
frequency = seriesPQ.top().frequency;
series->append( value, frequency );
-
+ series1->append( value, frequency );
if ( initialSize == seriesPQ.size() ) {
min = value;
}
@@ -7192,50 +7239,59 @@ void Graph::prominenceDistributionSpline(const H_StrToInt &discreteClasses,
axisX->setMin(0);
axisX->setMax(max);
- Chart *m_chart = new Chart(Q_NULLPTR);
+ if (!distImageFileName.isEmpty() ) {
+ qDebug() << "Graph::prominenceDistributionSpline() - "
+ << "saving distribution image to" << distImageFileName ;
+ QChart *chart = new QChart();
+ QChartView *m_chart = new QChartView( chart );
+ //Chart *m_chart = new Chart(Q_NULLPTR);
- // Clear chart from old series.
- m_chart->removeAllSeries();
+ // Clear chart from old series.
+ //m_chart->removeAllSeries();
- // Remove all axes
- m_chart->removeAllAxes();
+ // Remove all axes
+ //m_chart->removeAllAxes();
- m_chart->show();
+ m_chart->show();
- m_chart->addSeries(series);
+ chart->addSeries(series);
+ //m_chart->addSeries(series);
- m_chart->setTitle(series->name() + QString(" distribution"),
- QFont("Times",7));
+ //chart->setTitle("sdfsdf");
+// m_chart->setTitle(series->name() + QString(" distribution"),
+// QFont("Times",7));
- m_chart->toggleLegend(false);
+ //m_chart->toggleLegend(false);
- m_chart->createDefaultAxes();
- m_chart->axes(Qt::Horizontal).first()->setMin(0);
- m_chart->axes(Qt::Horizontal).first()->setMax(max);
- m_chart->axes(Qt::Horizontal).first()->setLabelsAngle(-90);
- m_chart->axes(Qt::Horizontal).first()->setShadesVisible(false);
+ chart->createDefaultAxes();
-// axisX->setLabelsAngle(-90);
-// axisX->setShadesVisible(false);
+// m_chart->createDefaultAxes();
+// m_chart->axes(Qt::Vertical).first()->setMin(0);
+// m_chart->axes(Qt::Horizontal).first()->setMin(0);
+// m_chart->axes(Qt::Horizontal).first()->setMax(max);
+// m_chart->axes(Qt::Horizontal).first()->setLabelsAngle(-90);
+// m_chart->axes(Qt::Horizontal).first()->setShadesVisible(false);
- m_chart->resize(1000,700);
+ // axisX->setLabelsAngle(-90);
+ // axisX->setShadesVisible(false);
+ QSize size = m_chart->size();
+ chart->resize(900,600);
+ m_chart->resize(1000,700);
- // Apply our theme to axes:
- m_chart->setAxesThemeDefault();
+ // Apply our theme to axes:
+ //m_chart->setAxesThemeDefault();
- //appSettings["dataDir"]=
- //QPixmap p = m_chart->grab();
- QPixmap p = m_chart->getPixmap();
- //QPixmap p( m_chart->size() );
- //m_chart->render( p );
+ //QPixmap p = m_chart->getPixmap();
+ QPixmap p = m_chart->grab();
- p.save("./mychart.png", "PNG");
+ p.save( distImageFileName, "PNG");
- m_chart->hide();
- delete m_chart;
+ //m_chart->hide();
+ // m_chart->resize(size);
+ }
qDebug() << "Graph::prominenceDistributionSpline() - emitting signal to update";
- emit signalPromininenceDistributionChartUpdate(series, axisX, min, max);
+ emit signalPromininenceDistributionChartUpdate(series1, axisX, min, max);
}
@@ -7248,7 +7304,8 @@ void Graph::prominenceDistributionSpline(const H_StrToInt &discreteClasses,
* @param series
*/
void Graph::prominenceDistributionArea(const H_StrToInt &discreteClasses,
- const QString &name) {
+ const QString &name,
+ const QString &distImageFileName) {
qDebug() << "Graph::prominenceDistributionArea()";
@@ -7301,6 +7358,11 @@ void Graph::prominenceDistributionArea(const H_StrToInt &discreteClasses,
axisX->setMax(max);
series->setUpperSeries(upperSeries);
+
+ if (!distImageFileName.isEmpty()) {
+
+ }
+
emit signalPromininenceDistributionChartUpdate(series, axisX, min, max);
}
@@ -7316,7 +7378,8 @@ void Graph::prominenceDistributionArea(const H_StrToInt &discreteClasses,
* @param strX
*/
void Graph::prominenceDistributionBars(const H_StrToInt &discreteClasses,
- const QString &name) {
+ const QString &name,
+ const QString &distImageFileName) {
qDebug() << "Graph::prominenceDistributionBars() - Creating chart type: bars";
@@ -7376,6 +7439,10 @@ void Graph::prominenceDistributionBars(const H_StrToInt &discreteClasses,
series->append( barSet );
+ if (!distImageFileName.isEmpty()) {
+
+ }
+
emit signalPromininenceDistributionChartUpdate(series, axisX, min.toDouble(), max.toDouble());
}
@@ -7410,7 +7477,16 @@ void Graph::writeCentralityDegree ( const QString fileName,
centralityDegree(considerWeights, dropIsolates);
- prominenceDistribution(IndexType::DC, m_reportsChartType);
+ QString distImageFileName ;
+
+ if ( m_reportsChartType != ChartType::None ) {
+
+ distImageFileName = QFileInfo(fileName).canonicalPath() +
+ QDir::separator() + QFileInfo(fileName).completeBaseName() + ".png";
+
+ }
+
+ prominenceDistribution(IndexType::DC, m_reportsChartType,distImageFileName);
qreal maxIndexDC=vertices(dropIsolates)-1.0;
@@ -7589,6 +7665,17 @@ void Graph::writeCentralityDegree ( const QString fileName,
outText << "";
+
+ if ( m_reportsChartType != ChartType::None ) {
+ outText << "";
+ outText << tr("DC DISTRIBUTION")
+ << "
";
+ outText << "";
+ outText << "";
+ }
+
if (!considerWeights) {
outText << "
";
outText << tr("GROUP DEGREE CENTRALIZATION (GDC)")
@@ -7676,7 +7763,16 @@ void Graph::writeCentralityCloseness( const QString fileName,
graphDistancesGeodesic(true, considerWeights, inverseWeights, dropIsolates);
- prominenceDistribution(IndexType::CC, m_reportsChartType);
+ QString distImageFileName ;
+
+ if ( m_reportsChartType != ChartType::None ) {
+
+ distImageFileName = QFileInfo(fileName).canonicalPath() +
+ QDir::separator() + QFileInfo(fileName).completeBaseName() + ".png";
+
+ }
+
+ prominenceDistribution(IndexType::CC, m_reportsChartType,distImageFileName);
int rowCount=0;
int N = vertices();
@@ -7854,6 +7950,17 @@ void Graph::writeCentralityCloseness( const QString fileName,
outText << "";
+
+ if ( m_reportsChartType != ChartType::None ) {
+ outText << "";
+ outText << tr("CC DISTRIBUTION")
+ << "
";
+ outText << "
";
+ outText << "";
+ }
+
if (!considerWeights) {
outText << "
";
outText << tr("GROUP CLOSENESS CENTRALIZATION (GCC)")
@@ -8064,7 +8171,16 @@ void Graph::writeCentralityClosenessInfluenceRange(const QString fileName,
centralityClosenessIR(considerWeights,inverseWeights, dropIsolates);
- prominenceDistribution(IndexType::IRCC, m_reportsChartType);
+ QString distImageFileName ;
+
+ if ( m_reportsChartType != ChartType::None ) {
+
+ distImageFileName = QFileInfo(fileName).canonicalPath() +
+ QDir::separator() + QFileInfo(fileName).completeBaseName() + ".png";
+
+ }
+
+ prominenceDistribution(IndexType::IRCC, m_reportsChartType,distImageFileName);
int rowCount=0;
int N = vertices();
@@ -8227,6 +8343,16 @@ void Graph::writeCentralityClosenessInfluenceRange(const QString fileName,
<<"
";
outText << "";
+ if ( m_reportsChartType != ChartType::None ) {
+ outText << "";
+ outText << tr("IRCC DISTRIBUTION")
+ << "
";
+ outText << "
";
+ outText << "";
+ }
+
outText << "
";
outText << "";
@@ -8276,7 +8402,16 @@ void Graph::writeCentralityBetweenness(const QString fileName,
graphDistancesGeodesic(true, considerWeights, inverseWeights, dropIsolates);
- prominenceDistribution(IndexType::BC, m_reportsChartType);
+ QString distImageFileName ;
+
+ if ( m_reportsChartType != ChartType::None ) {
+
+ distImageFileName = QFileInfo(fileName).canonicalPath() +
+ QDir::separator() + QFileInfo(fileName).completeBaseName() + ".png";
+
+ }
+
+ prominenceDistribution(IndexType::BC, m_reportsChartType, distImageFileName);
int rowCount=0, progressCounter=0;
int N = vertices();
@@ -8450,6 +8585,16 @@ void Graph::writeCentralityBetweenness(const QString fileName,
outText << "
";
+ if ( m_reportsChartType != ChartType::None ) {
+ outText << "";
+ outText << tr("BC DISTRIBUTION")
+ << "
";
+ outText << "";
+ outText << "";
+ }
+
if (!considerWeights) {
outText << "
";
outText << tr("GROUP BETWEENNESS CENTRALIZATION (GBC)")
@@ -8534,7 +8679,16 @@ void Graph::writeCentralityStress( const QString fileName,
graphDistancesGeodesic(true, considerWeights, inverseWeights,dropIsolates);
- prominenceDistribution(IndexType::SC, m_reportsChartType);
+ QString distImageFileName ;
+
+ if ( m_reportsChartType != ChartType::None ) {
+
+ distImageFileName = QFileInfo(fileName).canonicalPath() +
+ QDir::separator() + QFileInfo(fileName).completeBaseName() + ".png";
+
+ }
+
+ prominenceDistribution(IndexType::SC, m_reportsChartType, distImageFileName);
VList::const_iterator it;
@@ -8705,6 +8859,16 @@ void Graph::writeCentralityStress( const QString fileName,
outText << "";
+ if ( m_reportsChartType != ChartType::None ) {
+ outText << "";
+ outText << tr("SC' DISTRIBUTION")
+ << "
";
+ outText << "
";
+ outText << "";
+ }
+
outText << "
";
outText << tr("Stress Centrality report,
");
@@ -8750,7 +8914,16 @@ void Graph::writeCentralityEccentricity(const QString fileName,
graphDistancesGeodesic(true, considerWeights, inverseWeights,dropIsolates);
- prominenceDistribution(IndexType::EC, m_reportsChartType);
+ QString distImageFileName ;
+
+ if ( m_reportsChartType != ChartType::None ) {
+
+ distImageFileName = QFileInfo(fileName).canonicalPath() +
+ QDir::separator() + QFileInfo(fileName).completeBaseName() + ".png";
+
+ }
+
+ prominenceDistribution(IndexType::EC, m_reportsChartType, distImageFileName);
VList::const_iterator it;
@@ -8904,6 +9077,16 @@ void Graph::writeCentralityEccentricity(const QString fileName,
outText << "
";
+ if ( m_reportsChartType != ChartType::None ) {
+ outText << "";
+ outText << tr("EC DISTRIBUTION")
+ << "
";
+ outText << "";
+ outText << "";
+ }
+
outText << "
";
outText << "";
outText << tr("Eccentricity Centrality report,
");
@@ -8951,7 +9134,17 @@ void Graph::writeCentralityPower(const QString fileName,
graphDistancesGeodesic(true, considerWeights, inverseWeights, dropIsolates);
- prominenceDistribution(IndexType::PC, m_reportsChartType);
+
+ QString distImageFileName ;
+
+ if ( m_reportsChartType != ChartType::None ) {
+
+ distImageFileName = QFileInfo(fileName).canonicalPath() +
+ QDir::separator() + QFileInfo(fileName).completeBaseName() + ".png";
+
+ }
+
+ prominenceDistribution(IndexType::PC, m_reportsChartType, distImageFileName);
VList::const_iterator it;
@@ -9124,6 +9317,18 @@ void Graph::writeCentralityPower(const QString fileName,
outText << "
";
+
+ if ( m_reportsChartType != ChartType::None ) {
+ outText << "";
+ outText << tr("PC' DISTRIBUTION")
+ << "
";
+ outText << "";
+ outText << "";
+ }
+
+
if (!considerWeights) {
outText << "
";
outText << tr("GROUP POWER CENTRALIZATION (GPC)")
@@ -9382,7 +9587,17 @@ void Graph::writePrestigeDegree (const QString fileName,
prestigeDegree(considerWeights, dropIsolates);
- prominenceDistribution(IndexType::DP, m_reportsChartType);
+
+ QString distImageFileName ;
+
+ if ( m_reportsChartType != ChartType::None ) {
+
+ distImageFileName = QFileInfo(fileName).canonicalPath() +
+ QDir::separator() + QFileInfo(fileName).completeBaseName() + ".png";
+
+ }
+
+ prominenceDistribution(IndexType::DP, m_reportsChartType, distImageFileName);
VList::const_iterator it;
@@ -9565,6 +9780,16 @@ void Graph::writePrestigeDegree (const QString fileName,
outText << "";
+ if ( m_reportsChartType != ChartType::None ) {
+ outText << "";
+ outText << tr("DP' DISTRIBUTION")
+ << "
";
+ outText << "
";
+ outText << "";
+ }
+
if (!considerWeights) {
outText << "
";
outText << tr("GROUP DEGREE PRESTIGE (GDP)")
@@ -9773,7 +9998,16 @@ void Graph::writePrestigeProximity( const QString fileName,
prestigeProximity(considerWeights, inverseWeights, dropIsolates);
- prominenceDistribution(IndexType::PP, m_reportsChartType);
+ QString distImageFileName ;
+
+ if ( m_reportsChartType != ChartType::None ) {
+
+ distImageFileName = QFileInfo(fileName).canonicalPath() +
+ QDir::separator() + QFileInfo(fileName).completeBaseName() + ".png";
+
+ }
+
+ prominenceDistribution(IndexType::PP, m_reportsChartType, fileName);
VList::const_iterator it;
@@ -9931,6 +10165,17 @@ void Graph::writePrestigeProximity( const QString fileName,
<<"
";
outText << "";
+
+ if ( m_reportsChartType != ChartType::None ) {
+ outText << "";
+ outText << tr("PP DISTRIBUTION")
+ << "
";
+ outText << "
";
+ outText << "";
+ }
+
outText << "
";
outText << "";
outText << tr("Proximity Prestige report,
");
@@ -10216,7 +10461,17 @@ void Graph::writePrestigePageRank(const QString fileName,
prestigePageRank(dropIsolates);
- prominenceDistribution(IndexType::PRP,m_reportsChartType);
+
+ QString distImageFileName ;
+
+ if ( m_reportsChartType != ChartType::None ) {
+
+ distImageFileName = QFileInfo(fileName).canonicalPath() +
+ QDir::separator() + QFileInfo(fileName).completeBaseName() + ".png";
+
+ }
+
+ prominenceDistribution(IndexType::PRP,m_reportsChartType,distImageFileName);
VList::const_iterator it;
@@ -10392,6 +10647,17 @@ void Graph::writePrestigePageRank(const QString fileName,
<<"
";
outText << "
";
+
+ if ( m_reportsChartType != ChartType::None ) {
+ outText << "";
+ outText << tr("PP DISTRIBUTION")
+ << "
";
+ outText << "";
+ outText << "";
+ }
+
outText << "
";
outText << "";
outText << tr("PageRank Prestige report,
");
@@ -15537,7 +15803,16 @@ bool Graph::graphSaveToGraphMLFormat (const QString &fileName,
}
+/**
+ * @brief Sets the directory where reports are saved
+ * This is used when exporting prominence distribution images to be used in
+ * HTML reports.
+ * @param dir
+ */
+void Graph::setReportsDataDir(const QString &dir) {
+ m_reportsDataDir = dir;
+}
/**
* @brief Sets the precision (number of fraction digits) the app will use
* when writing real numbers in reports.
diff --git a/src/graph.h b/src/graph.h
index d4932550..53e64632 100755
--- a/src/graph.h
+++ b/src/graph.h
@@ -725,7 +725,7 @@ public slots:
const bool &considerWeights);
/* REPORT EXPORTS */
-
+ void setReportsDataDir(const QString &reportsDir);
void setReportsRealNumberPrecision (const int & precision);
void setReportsLabelLength(const int &length);
void setReportsChartType(const int &type);
@@ -923,16 +923,20 @@ public slots:
const bool &dropIsolates=false) ;
void prominenceDistribution(const int &index,
- const ChartType &type=ChartType::Spline);
+ const ChartType &type,
+ const QString &distImageFileName=QString());
void prominenceDistributionBars(const H_StrToInt &discreteClasses,
- const QString &name);
+ const QString &name,
+ const QString &distImageFileName);
void prominenceDistributionArea(const H_StrToInt &discreteClasses,
- const QString &name);
+ const QString &name,
+ const QString &distImageFileName);
void prominenceDistributionSpline(const H_StrToInt &discreteClasses,
- const QString &name);
+ const QString &seriesName,
+ const QString &distImageFileName);
void centralityDegree(const bool &weights=true,
const bool &dropIsolates=false);
@@ -1234,6 +1238,7 @@ public slots:
H_StrToInt discreteIRCCs, discreteECs, discreteEccentricities;
H_StrToInt discretePCs, discreteICs, discretePRPs, discretePPs, discreteEVCs;
+ QString m_reportsDataDir;
int m_reportsRealPrecision;
int m_reportsLabelLength;
ChartType m_reportsChartType;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 01aeb634..f743433c 100755
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -154,8 +154,9 @@ MainWindow::MainWindow(const QString & m_fileName) {
initToolBar(); //build the toolbar
// Create our reports chart
- reportsChart = new Chart(this);
- reportsChart->hide();
+ //reportsChart = new Chart(this);
+// reportsChart->hide();
+
initPanels(); //build the toolbox
@@ -194,8 +195,7 @@ MainWindow::~MainWindow() {
delete scene;
delete graphicsWidget;
- delete reportsChart;
- delete chart;
+
foreach ( TextEditor *ed, m_textEditors) {
ed->close();
@@ -220,12 +220,14 @@ MainWindow::~MainWindow() {
*/
void MainWindow::closeEvent( QCloseEvent* ce ) {
- qDebug() << "MW::closeEvent() - Checking if Graph is saved...";
+ qDebug() << "MW::closeEvent() - Start closing app. Status message to user...";
statusMessage( tr("Closing SocNetV. Bye!") );
bool userCancelled=false;
+ qDebug() << "MW::closeEvent() - Checking if Graph is saved...";
+
if ( activeGraph->graphSaved() ) {
ce->accept();
qDebug() << "MW::closeEvent() - Graph is already saved. ";
@@ -266,12 +268,17 @@ void MainWindow::closeEvent( QCloseEvent* ce ) {
qDebug() << "MW::closeEvent() - Deleting other objects/pointers...";
+ qDebug() << "MW::closeEvent() - Deleting printer";
delete printer;
+ qDebug() << "MW::closeEvent() - Deleting printerPDF";
delete printerPDF;
+ qDebug() << "MW::closeEvent() - Deleting graphicsWidget";
delete graphicsWidget;
+ qDebug() << "MW::closeEvent() - Deleting activeGraph";
delete activeGraph;
+ qDebug() << "MW::closeEvent() - Deleting Scene";
delete scene;
- delete chart;
+// delete chart;
qDebug() << "MW::closeEvent() - Clearing and deleting text editors...";
foreach ( TextEditor *ed, m_textEditors) {
@@ -286,7 +293,7 @@ void MainWindow::closeEvent( QCloseEvent* ce ) {
qDebug() << "MW::closeEvent() - Clearing codecs...";
codecs.clear();
-
+ qDebug() << "MW::closeEvent() - Finished. Bye!";
}
@@ -369,10 +376,14 @@ QMap MainWindow::initSettings() {
this, &MainWindow::slotNetworkFileLoad );
qDebug() << "MW::initSettings - creating default settings" ;
+
+ // Our settings are always saved to this folder.
settingsDir = QDir::homePath() +QDir::separator() + "socnetv-data" + QDir::separator() ;
settingsFilePath = settingsDir + "settings.conf";
- // initially they are the same, but dataDir may be changed by the user
+ // dataDir is where our built-in datasets and reports are saved by default
+ // initially dataDir and settingsDir are the same, but dataDir may be
+ // changed by the user through Settings...
QString dataDir= settingsDir ;
maxNodes=5000; //Max nodes used by createRandomNetwork dialogues
@@ -553,6 +564,9 @@ void MainWindow::slotOpenSettingsDialog() {
connect( m_settingsDialog, &DialogSettings::saveSettings,
this, &MainWindow::saveSettings);
+ connect (m_settingsDialog, &DialogSettings::setReportsDataDir,
+ activeGraph, &Graph::setReportsDataDir);
+
connect (m_settingsDialog,&DialogSettings::setReportsRealNumberPrecision,
activeGraph, &Graph::setReportsRealNumberPrecision);
@@ -5586,7 +5600,7 @@ void MainWindow::initApp(){
activeGraph->setReportsLabelLength(appSettings["initReportsLabelsLength"].toInt());
activeGraph->setReportsChartType(appSettings["initReportsChartType"].toInt());
- emit signalSetReportsChart(reportsChart);
+ emit signalSetReportsDataDir(appSettings["dataDir"]);
/** Clear graphicsWidget scene and reset settings and transformations **/
graphicsWidget->clear();
@@ -6307,8 +6321,9 @@ QString MainWindow::getLastPath() {
/**
- * @brief Sets the last path used by user to open/save something
- * @param filePath
+ * @brief Sets the last path used by user to open/save a network and adds the file
+ * to recent files...
+ * @param filePath
*/
void MainWindow::setLastPath(const QString &filePath) {
qDebug()<< "MW::setLastPath() for " << filePath;
@@ -8081,6 +8096,7 @@ void MainWindow::slotNetworkDataSetRecreate (const QString m_fileName) {
qDebug()<< "MW::slotNetworkDataSetRecreate() datadir+fileName: "
<< appSettings["dataDir"]+m_fileName;
+
activeGraph->writeDataSetToFile(appSettings["dataDir"], m_fileName);
if (m_fileName.endsWith(".graphml")) {
@@ -13142,6 +13158,7 @@ void MainWindow::slotAnalyzeProminenceDistributionChartUpdate(QAbstractSeries *s
// Clear chart from old series.
chart->removeAllSeries();
+
// Remove all axes
chart->removeAllAxes();
@@ -13173,16 +13190,16 @@ void MainWindow::slotAnalyzeProminenceDistributionChartUpdate(QAbstractSeries *s
chart->setWhatsThis( chartHelpMsg );
// NOT USED: Attach axes to the Chart.
- // chart->createDefaultAxes();
+ chart->createDefaultAxes();
- // Instead of calling createDefaultAxes()
- // we use our own axes
- axisX->setLabelsAngle(-90);
- axisX->setShadesVisible(false);
- chart->setAxisX(axisX, series);
+// // Instead of calling createDefaultAxes()
+// // we use our own axes
+// axisX->setLabelsAngle(-90);
+// axisX->setShadesVisible(false);
+// chart->setAxisX(axisX, series);
- QValueAxis *axisY = new QValueAxis;
- chart->setAxisY(axisY, series);
+// QValueAxis *axisY = new QValueAxis;
+// chart->setAxisY(axisY, series);
// Apply our theme to axes:
chart->setAxesThemeDefault();
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 74f9b8f8..77da4c06 100755
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -563,7 +563,8 @@ public slots:
// void myMessageOutput(QtMsgType type, const char *msg);
signals:
void signalRelationAddAndChange(const QString &relName, const bool &changeRelation=true);
- void signalSetReportsChart(Chart *reportsChart);
+ void signalSetReportsChart(Chart *chart);
+ void signalSetReportsDataDir(const QString &dataDir );
private:
@@ -575,8 +576,6 @@ public slots:
QMap appSettings;
Chart *chart;
- Chart *reportsChart;
-
QStringList prominenceIndexList;
QStringList recentFiles;