Skip to content

Commit 97b88fe

Browse files
committed
Merge pull request #317 from schdub/issue316
plot: lineType and pointShape options
2 parents 641e182 + 220c5ba commit 97b88fe

4 files changed

Lines changed: 193 additions & 8 deletions

File tree

src/MainWindow.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ void MainWindow::init()
163163
restoreState(PreferencesDialog::getSettingsValue("MainWindow", "windowState").toByteArray());
164164
ui->comboLogSubmittedBy->setCurrentIndex(ui->comboLogSubmittedBy->findText(PreferencesDialog::getSettingsValue("SQLLogDock", "Log").toString()));
165165
ui->splitterForPlot->restoreState(PreferencesDialog::getSettingsValue("PlotDock", "splitterSize").toByteArray());
166+
ui->comboLineType->setCurrentIndex(PreferencesDialog::getSettingsValue("PlotDock", "lineType").toInt());
167+
ui->comboPointShape->setCurrentIndex(PreferencesDialog::getSettingsValue("PlotDock", "pointShape").toInt());
166168

167169
// plot widgets
168170
ui->treePlotColumns->setSelectionMode(QAbstractItemView::NoSelection);
@@ -432,6 +434,8 @@ void MainWindow::closeEvent( QCloseEvent* event )
432434
PreferencesDialog::setSettingsValue("MainWindow", "windowState", saveState());
433435
PreferencesDialog::setSettingsValue("SQLLogDock", "Log", ui->comboLogSubmittedBy->currentText());
434436
PreferencesDialog::setSettingsValue("PlotDock", "splitterSize", ui->splitterForPlot->saveState());
437+
PreferencesDialog::setSettingsValue("PlotDock", "lineType", ui->comboLineType->currentIndex());
438+
PreferencesDialog::setSettingsValue("PlotDock", "pointShape", ui->comboPointShape->currentIndex());
435439
QMainWindow::closeEvent(event);
436440
} else {
437441
event->ignore();
@@ -1624,8 +1628,8 @@ void MainWindow::updatePlot(SqliteTableModel *model, bool update)
16241628
// set some graph styles, this could also be improved to let the user choose
16251629
// some styling
16261630
graph->setData(xdata, ydata);
1627-
graph->setLineStyle(QCPGraph::lsLine);
1628-
graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5));
1631+
graph->setLineStyle((QCPGraph::LineStyle) ui->comboLineType->currentIndex());
1632+
graph->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)ui->comboPointShape->currentIndex(), 5));
16291633

16301634
// gather Y label column names
16311635
yAxisLabels << model->headerData(y, Qt::Horizontal).toString();
@@ -2110,3 +2114,31 @@ void MainWindow::copyCurrentCreateStatement()
21102114
// Copy the statement to the global application clipboard
21112115
QApplication::clipboard()->setText(stmt);
21122116
}
2117+
2118+
void MainWindow::on_comboLineType_currentIndexChanged(int index)
2119+
{
2120+
Q_ASSERT(index >= QCPGraph::lsNone &&
2121+
index <= QCPGraph::lsImpulse);
2122+
QCPGraph::LineStyle lineStyle = (QCPGraph::LineStyle) index;
2123+
for (int i = 0, ie = ui->plotWidget->graphCount(); i < ie; ++i)
2124+
{
2125+
QCPGraph * graph = ui->plotWidget->graph(i);
2126+
if (graph)
2127+
graph->setLineStyle(lineStyle);
2128+
}
2129+
ui->plotWidget->replot();
2130+
}
2131+
2132+
void MainWindow::on_comboPointShape_currentIndexChanged(int index)
2133+
{
2134+
Q_ASSERT(index >= QCPScatterStyle::ssNone &&
2135+
index < QCPScatterStyle::ssPixmap);
2136+
QCPScatterStyle::ScatterShape shape = (QCPScatterStyle::ScatterShape) index;
2137+
for (int i = 0, ie = ui->plotWidget->graphCount(); i < ie; ++i)
2138+
{
2139+
QCPGraph * graph = ui->plotWidget->graph(i);
2140+
if (graph)
2141+
graph->setScatterStyle(QCPScatterStyle(shape, 5));
2142+
}
2143+
ui->plotWidget->replot();
2144+
}

src/MainWindow.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ private slots:
177177
void switchToBrowseDataTab();
178178
void on_buttonClearFilters_clicked();
179179
void copyCurrentCreateStatement();
180+
void on_comboLineType_currentIndexChanged(int index);
181+
void on_comboPointShape_currentIndexChanged(int index);
180182
};
181183

182184
#endif

src/MainWindow.ui

Lines changed: 145 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>1000</width>
9+
<width>1037</width>
1010
<height>630</height>
1111
</rect>
1212
</property>
@@ -22,7 +22,7 @@
2222
<item>
2323
<widget class="QTabWidget" name="mainTab">
2424
<property name="currentIndex">
25-
<number>0</number>
25+
<number>3</number>
2626
</property>
2727
<widget class="QWidget" name="structure">
2828
<attribute name="title">
@@ -324,8 +324,8 @@
324324
<rect>
325325
<x>0</x>
326326
<y>0</y>
327-
<width>294</width>
328-
<height>444</height>
327+
<width>472</width>
328+
<height>531</height>
329329
</rect>
330330
</property>
331331
<layout class="QFormLayout" name="formLayout">
@@ -809,8 +809,8 @@
809809
<rect>
810810
<x>0</x>
811811
<y>0</y>
812-
<width>1000</width>
813-
<height>19</height>
812+
<width>1037</width>
813+
<height>25</height>
814814
</rect>
815815
</property>
816816
<widget class="QMenu" name="fileMenu">
@@ -1074,6 +1074,144 @@
10741074
<property name="bottomMargin">
10751075
<number>0</number>
10761076
</property>
1077+
<item>
1078+
<widget class="QLabel" name="label_2">
1079+
<property name="text">
1080+
<string>Line type:</string>
1081+
</property>
1082+
</widget>
1083+
</item>
1084+
<item>
1085+
<widget class="QComboBox" name="comboLineType">
1086+
<property name="currentIndex">
1087+
<number>1</number>
1088+
</property>
1089+
<item>
1090+
<property name="text">
1091+
<string>None</string>
1092+
</property>
1093+
</item>
1094+
<item>
1095+
<property name="text">
1096+
<string>Line</string>
1097+
</property>
1098+
</item>
1099+
<item>
1100+
<property name="text">
1101+
<string>StepLeft</string>
1102+
</property>
1103+
</item>
1104+
<item>
1105+
<property name="text">
1106+
<string>StepRight</string>
1107+
</property>
1108+
</item>
1109+
<item>
1110+
<property name="text">
1111+
<string>StepCenter</string>
1112+
</property>
1113+
</item>
1114+
<item>
1115+
<property name="text">
1116+
<string>Impulse</string>
1117+
</property>
1118+
</item>
1119+
</widget>
1120+
</item>
1121+
<item>
1122+
<widget class="QLabel" name="label_3">
1123+
<property name="text">
1124+
<string>Point shape:</string>
1125+
</property>
1126+
</widget>
1127+
</item>
1128+
<item>
1129+
<widget class="QComboBox" name="comboPointShape">
1130+
<property name="currentIndex">
1131+
<number>5</number>
1132+
</property>
1133+
<item>
1134+
<property name="text">
1135+
<string>None</string>
1136+
</property>
1137+
</item>
1138+
<item>
1139+
<property name="text">
1140+
<string>Dot</string>
1141+
</property>
1142+
</item>
1143+
<item>
1144+
<property name="text">
1145+
<string>Cross</string>
1146+
</property>
1147+
</item>
1148+
<item>
1149+
<property name="text">
1150+
<string>Plus</string>
1151+
</property>
1152+
</item>
1153+
<item>
1154+
<property name="text">
1155+
<string>Circle</string>
1156+
</property>
1157+
</item>
1158+
<item>
1159+
<property name="text">
1160+
<string>Disc</string>
1161+
</property>
1162+
</item>
1163+
<item>
1164+
<property name="text">
1165+
<string>Square</string>
1166+
</property>
1167+
</item>
1168+
<item>
1169+
<property name="text">
1170+
<string>Diamond</string>
1171+
</property>
1172+
</item>
1173+
<item>
1174+
<property name="text">
1175+
<string>Star</string>
1176+
</property>
1177+
</item>
1178+
<item>
1179+
<property name="text">
1180+
<string>Triangle</string>
1181+
</property>
1182+
</item>
1183+
<item>
1184+
<property name="text">
1185+
<string>TriangleInverted</string>
1186+
</property>
1187+
</item>
1188+
<item>
1189+
<property name="text">
1190+
<string>CrossSquare</string>
1191+
</property>
1192+
</item>
1193+
<item>
1194+
<property name="text">
1195+
<string>PlusSquare</string>
1196+
</property>
1197+
</item>
1198+
<item>
1199+
<property name="text">
1200+
<string>CrossCircle</string>
1201+
</property>
1202+
</item>
1203+
<item>
1204+
<property name="text">
1205+
<string>PlusCircle</string>
1206+
</property>
1207+
</item>
1208+
<item>
1209+
<property name="text">
1210+
<string>Peace</string>
1211+
</property>
1212+
</item>
1213+
</widget>
1214+
</item>
10771215
<item>
10781216
<spacer name="horizontalSpacer_4">
10791217
<property name="orientation">
@@ -1656,6 +1794,7 @@
16561794
<tabstop>dbTreeWidget</tabstop>
16571795
<tabstop>comboBrowseTable</tabstop>
16581796
<tabstop>buttonRefresh</tabstop>
1797+
<tabstop>buttonClearFilters</tabstop>
16591798
<tabstop>buttonNewRecord</tabstop>
16601799
<tabstop>buttonDeleteRecord</tabstop>
16611800
<tabstop>dataTable</tabstop>

src/PreferencesDialog.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,18 @@ QVariant PreferencesDialog::getSettingsDefaultValue(const QString& group, const
300300
if(group == "extension" && name == "disableregex")
301301
return false;
302302

303+
// PlotDock/lineType or pointShape?
304+
if(group == "PlotDock")
305+
{
306+
// QCPGraph::lsLine
307+
if(name == "lineType")
308+
return 1;
309+
310+
// QCPScatterStyle::ssDisk
311+
if(name == "pointShape")
312+
return 5;
313+
}
314+
303315
// Unknown combination of group and name? Return an invalid QVariant!
304316
return QVariant();
305317
}

0 commit comments

Comments
 (0)