Skip to content

Commit

Permalink
Add point-only mode in PlotTab
Browse files Browse the repository at this point in the history
Fixes #45
  • Loading branch information
wh201906 committed Nov 21, 2023
1 parent 9b8a814 commit daf3460
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 13 deletions.
32 changes: 25 additions & 7 deletions src/plottab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void PlotTab::initSettings()
connect(ui->plot_dataSpEdit, &QLineEdit::editingFinished, this, &PlotTab::savePlotPreference);
connect(ui->plot_clearFlagTypeBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PlotTab::savePlotPreference);
connect(ui->plot_clearFlagEdit, &QLineEdit::editingFinished, this, &PlotTab::savePlotPreference);
connect(ui->plot_scatterBox, &QCheckBox::clicked, this, &PlotTab::savePlotPreference);
connect(ui->plot_plotStyleBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PlotTab::savePlotPreference);

}

Expand Down Expand Up @@ -388,17 +388,35 @@ void PlotTab::on_plot_XTypeBox_currentIndexChanged(int index)
}
}

void PlotTab::on_plot_scatterBox_stateChanged(int arg1)

void PlotTab::on_plot_plotStyleBox_currentIndexChanged(int index)
{
if(arg1 == Qt::Checked)
if(index == 0)
{
// line only
for(int i = 0; i < ui->qcpWidget->graphCount(); i++)
{
ui->qcpWidget->graph(i)->setLineStyle(QCPGraph::lsLine);
ui->qcpWidget->graph(i)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssNone));
}
}
else if(index == 1)
{
// point only
for(int i = 0; i < ui->qcpWidget->graphCount(); i++)
{
ui->qcpWidget->graph(i)->setLineStyle(QCPGraph::lsNone);
ui->qcpWidget->graph(i)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle));
}
}
else
else if(index == 2)
{
// line with point
for(int i = 0; i < ui->qcpWidget->graphCount(); i++)
ui->qcpWidget->graph(i)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssNone));
{
ui->qcpWidget->graph(i)->setLineStyle(QCPGraph::lsLine);
ui->qcpWidget->graph(i)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle));
}
}
}

Expand Down Expand Up @@ -447,7 +465,7 @@ void PlotTab::savePlotPreference()
settings->setValue("DataSp_Context", ui->plot_dataSpEdit->text());
settings->setValue("ClearF_Type", ui->plot_clearFlagTypeBox->currentIndex());
settings->setValue("ClearF_Context", ui->plot_clearFlagEdit->text());
settings->setValue("Scatter", ui->plot_scatterBox->isChecked());
settings->setValue("PlotStyle", ui->plot_plotStyleBox->currentIndex());
settings->endGroup();
}

Expand Down Expand Up @@ -480,7 +498,7 @@ void PlotTab::loadPreference()
ui->plot_dataSpEdit->setText(settings->value("DataSp_Context", defaultDataSp).toString());
ui->plot_clearFlagTypeBox->setCurrentIndex(settings->value("ClearF_Type", 1).toInt());
ui->plot_clearFlagEdit->setText(settings->value("ClearF_Context", "cls").toString());
ui->plot_scatterBox->setChecked(settings->value("Scatter", false).toBool());
ui->plot_plotStyleBox->setCurrentIndex(settings->value("PlotStyle", 0).toInt());
colorList = settings->value("GraphColor", QStringList()).toStringList();
nameList = settings->value("GraphName", QStringList()).toStringList();
settings->endGroup();
Expand Down
3 changes: 2 additions & 1 deletion src/plottab.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private slots:
void on_plot_advancedBox_stateChanged(int arg1);
void on_plot_frameSpTypeBox_currentIndexChanged(int index);
void on_plot_dataSpTypeBox_currentIndexChanged(int index);
void on_plot_scatterBox_stateChanged(int arg1);
void on_plot_plotStyleBox_currentIndexChanged(int index);
void on_plot_frameSpEdit_editingFinished();
void on_plot_dataSpEdit_editingFinished();
void on_plot_clearFlagTypeBox_currentIndexChanged(int index);
Expand All @@ -57,6 +57,7 @@ private slots:
void savePlotPreference();
void loadPreference();
void processData();

private:
Ui::PlotTab *ui;

Expand Down
26 changes: 21 additions & 5 deletions src/ui/plottab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1208</width>
<height>59</height>
<height>61</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down Expand Up @@ -348,16 +348,32 @@
<item>
<widget class="QLineEdit" name="plot_clearFlagEdit"/>
</item>
<item>
<widget class="QCheckBox" name="plot_scatterBox"/>
</item>
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Scatter</string>
<string>Style:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="plot_plotStyleBox">
<item>
<property name="text">
<string>Line</string>
</property>
</item>
<item>
<property name="text">
<string>Point</string>
</property>
</item>
<item>
<property name="text">
<string>Both</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
Expand Down

0 comments on commit daf3460

Please sign in to comment.