Skip to content

Commit

Permalink
Work on #81 and #18: Added Setting where the user may select the type…
Browse files Browse the repository at this point in the history
… of chart for prominence index distribution. It supports lines and bars. Area and Scatter types can be added later! We can now work to add this functionality in reports as well
  • Loading branch information
oxy86 committed Feb 27, 2019
1 parent 9649164 commit c0fb634
Show file tree
Hide file tree
Showing 8 changed files with 373 additions and 179 deletions.
45 changes: 45 additions & 0 deletions src/forms/dialogsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,32 @@ DialogSettings::DialogSettings(QMap<QString, QString> &appSettings,
setValue(m_appSettings["initReportsLabelsLength"].toInt(0, 10) );


QStringList chartTypesList;
chartTypesList << "None" << "Lines" << "Bars" ;
ui->reportsChartTypeSelect->addItems(chartTypesList);

switch (appSettings["initReportsChartType"].toInt()) {
case ChartType::None:
ui->reportsChartTypeSelect->setCurrentText( "None");
break;
case ChartType::Spline:
ui->reportsChartTypeSelect->setCurrentText( "Lines");
break;
case ChartType::Area:
ui->reportsChartTypeSelect->setCurrentText( "Area");
break;
case ChartType::Bars:
ui->reportsChartTypeSelect->setCurrentText( "Bars");
break;
default:
ui->reportsChartTypeSelect->setCurrentText( "Lines");
break;
}

qDebug() << "reportsChartTypeSelect"
<< ui->reportsChartTypeSelect->currentText();


//debugging
ui->printDebugChkBox->setChecked(
(appSettings["printDebug"] == "true") ? true:false
Expand Down Expand Up @@ -344,6 +370,11 @@ DialogSettings::DialogSettings(QMap<QString, QString> &appSettings,
connect (ui->reportsLabelsLengthSpin, SIGNAL(valueChanged(int)),
this, SLOT(getReportsLabelsLength(int)));


connect(ui->reportsChartTypeSelect, SIGNAL ( currentIndexChanged (const int &)),
this, SLOT(getReportsChartType(const int &)) );


connect (ui->printLogoChkBox, &QCheckBox::stateChanged,
this, &DialogSettings::setPrintLogo);

Expand Down Expand Up @@ -520,6 +551,20 @@ void DialogSettings::getReportsLabelsLength( const int &length) {
}



/**
* @brief Gets the chart type in reports
*/
void DialogSettings::getReportsChartType(const int &type){
//if (!type.isEmpty() ) {
qDebug() << "DialogSettings::getReportsChartType() - type: " << type;
m_appSettings["initReportsChartType"] = type-1;
emit setReportsChartType(type-1);
//}
}



/**
* @brief DialogSettings::getCanvasBgColor
* Opens a QColorDialog for the user to select a new bg color
Expand Down
5 changes: 5 additions & 0 deletions src/forms/dialogsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ class DialogSettings : public QDialog

public slots:
void getDataDir();

void getReportsRealNumberPrecision(const int &precision);
void getReportsLabelsLength(const int &length);
void getReportsChartType(const int &type);

void getCanvasBgColor();
void getCanvasBgImage();
void getCanvasUpdateMode(const QString &text);
Expand Down Expand Up @@ -86,6 +89,8 @@ public slots:
void setStyleSheetDefault(const bool &toggle);
void setReportsRealNumberPrecision(const int &precision);
void setReportsLabelLength(const int &length);
void setReportsChartType(const int &type);

void setProgressDialog(bool);
void setToolBar(bool);
void setStatusBar(bool);
Expand Down
119 changes: 91 additions & 28 deletions src/forms/dialogsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,17 @@
<property name="windowTitle">
<string>Settings &amp; Preferences</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="minimumSize">
Expand All @@ -41,8 +51,8 @@
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QGroupBox" name="appExportingGroupBox">
<property name="minimumSize">
<size>
Expand Down Expand Up @@ -122,20 +132,20 @@
</layout>
</widget>
</item>
<item row="1" column="0" colspan="2">
<item row="1" column="0">
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>470</width>
<height>19</height>
<height>26</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2">
<item row="2" column="0">
<widget class="QGroupBox" name="reportsGroupBox">
<property name="minimumSize">
<size>
Expand Down Expand Up @@ -179,7 +189,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>50</height>
<height>30</height>
</size>
</property>
</spacer>
Expand Down Expand Up @@ -249,7 +259,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>50</height>
<height>30</height>
</size>
</property>
</spacer>
Expand Down Expand Up @@ -287,23 +297,86 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_27">
<item>
<widget class="QLabel" name="label_25">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:600;&quot;&gt;Chart Type&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:10pt;&quot;&gt;This is the chart type that is used in reports, i.e. to plot the distribution of a prominence index, such as Degree Centrality.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:10pt;&quot;&gt;Use the select box on the right to select a chart type.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:10pt;&quot;&gt;SocNetV supports the following chart types:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:10pt;&quot;&gt;- Spline charts, which present data as a series of data points connected by lines. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:10pt;&quot;&gt;- Area charts, which present data as an area bound by two lines.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:10pt;&quot;&gt;- Bar charts, which present data as vertical bars. &lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Chart type</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_27">
<property name="font">
<font>
<family>DejaVu Sans</family>
<pointsize>11</pointsize>
</font>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>98</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="reportsChartTypeSelect">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>170</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:600;&quot;&gt;Chart Type&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:10pt;&quot;&gt;Select which kind of chart type will be used in reports, i.e. to plot the &lt;/span&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:10pt;&quot;&gt;distribution of a &lt;/span&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:10pt;&quot;&gt;prominence index, such as Degree Centrality.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:10pt;&quot;&gt;SocNetV supports the following chart types:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:10pt;&quot;&gt;- Spline charts, which present data as a series of data points connected by lines. &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:10pt;&quot;&gt;- Area charts, which present data as an area bound by two lines.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:10pt;&quot;&gt;- Bar charts, which present data as vertical bars. &lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="3" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>388</width>
<height>20</height>
<height>23</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="2">
<item row="4" column="0">
<widget class="QGroupBox" name="imageExportgroupBox">
<property name="minimumSize">
<size>
Expand Down Expand Up @@ -337,7 +410,7 @@
</layout>
</widget>
</item>
<item row="5" column="1">
<item row="5" column="0">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -350,7 +423,7 @@
</property>
</spacer>
</item>
<item row="6" column="0" colspan="2">
<item row="6" column="0">
<widget class="QGroupBox" name="debugGroupBox">
<property name="minimumSize">
<size>
Expand Down Expand Up @@ -413,7 +486,7 @@
</property>
</spacer>
</item>
<item row="8" column="0" colspan="2">
<item row="8" column="0">
<widget class="QGroupBox" name="styleGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
Expand Down Expand Up @@ -463,7 +536,7 @@
</property>
</spacer>
</item>
<item row="10" column="0" colspan="2">
<item row="10" column="0">
<widget class="QGroupBox" name="windowGroupBox">
<property name="minimumSize">
<size>
Expand All @@ -474,12 +547,12 @@
<property name="title">
<string>Window options</string>
</property>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>8</x>
<y>30</y>
<width>441</width>
<width>461</width>
<height>60</height>
</rect>
</property>
Expand Down Expand Up @@ -729,7 +802,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>90</height>
<height>67</height>
</size>
</property>
</spacer>
Expand Down Expand Up @@ -2374,16 +2447,6 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
Expand Down
6 changes: 6 additions & 0 deletions src/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ SOCNETV_BEGIN_NAMESPACE
};


enum ChartType {
None = -1,
Spline = 0,
Area = 1,
Bars = 2
};

static const int SUBGRAPH_CLIQUE = 1;
static const int SUBGRAPH_STAR = 2;
Expand Down
Loading

0 comments on commit c0fb634

Please sign in to comment.