Skip to content

Commit

Permalink
DlgGraphSetting: add checkbox to select dragging of all Y axes
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHal committed Jan 8, 2025
1 parent 42ba730 commit 215b881
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 52 deletions.
6 changes: 4 additions & 2 deletions QtPMbrowser/DlgGraphSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ void DlgGraphSettings::selectBkTraceColor()
}

void DlgGraphSettings::setValues(bool autoscale, double xmin, double xmax, double ymin, double ymax,
int numtraces, bool grid_horz, bool grid_vert,
int numtraces, bool grid_horz, bool grid_vert, bool shift_all_y_scales,
QColor color_grid, QColor color_trace, QColor color_bktrace)
{
QLocale loc{};
ui.checkBoxEnableAutoscale->setChecked(autoscale);
ui.checkBoxHorzGrid->setChecked(grid_horz);
ui.checkBoxVertGrid->setChecked(grid_vert);
ui.checkBoxShiftAllYScales->setChecked(shift_all_y_scales);
ui.lineEditXMin->setText(loc.toString(xmin));
ui.lineEditXMax->setText(loc.toString(xmax));
ui.lineEditYMin->setText(loc.toString(ymin));
Expand All @@ -92,13 +93,14 @@ void DlgGraphSettings::setValues(bool autoscale, double xmin, double xmax, doubl
}

void DlgGraphSettings::getValues(bool& autoscale, double& xmin, double& xmax, double& ymin, double& ymax,
int& numtraces, bool& grid_horz, bool& grid_vert,
int& numtraces, bool& grid_horz, bool& grid_vert, bool& shift_all_y_scales,
QColor& color_grid, QColor& color_trace, QColor& color_bktrace)
{
QLocale loc{};
autoscale = ui.checkBoxEnableAutoscale->isChecked();
grid_horz = ui.checkBoxHorzGrid->isChecked();
grid_vert = ui.checkBoxVertGrid->isChecked();
shift_all_y_scales = ui.checkBoxShiftAllYScales->isChecked();
xmin = loc.toDouble(ui.lineEditXMin->text());
xmax = loc.toDouble(ui.lineEditXMax->text());
ymin = loc.toDouble(ui.lineEditYMin->text());
Expand Down
3 changes: 2 additions & 1 deletion QtPMbrowser/DlgGraphSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ private slots:
~DlgGraphSettings();
void setValues(bool autoscale, double xmin, double xmax,
double ymin, double ymax, int numtraces, bool grid_horz, bool gird_vert,
bool shift_all_y_scales,
QColor color_grid, QColor color_trace, QColor color_bktrace);
void getValues(bool& autoscale, double& xmin, double& xmax,
double& ymin, double& ymax, int& numtraces,
bool& grid_horz, bool& gird_vert,
bool& grid_horz, bool& gird_vert, bool& shift_all_y_scales,
QColor& color_grid, QColor& color_trace, QColor& color_bktrace);

private:
Expand Down
110 changes: 65 additions & 45 deletions QtPMbrowser/DlgGraphSettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,55 @@
<x>0</x>
<y>0</y>
<width>359</width>
<height>442</height>
<height>447</height>
</rect>
</property>
<property name="windowTitle">
<string>Graph Settings &amp; Axis Ranges</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="4" column="0" colspan="2">
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxHorzGrid">
<property name="text">
<string>show horizontal grid lines</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBoxVertGrid">
<property name="text">
<string>show vertical grid lines</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxEnableAutoscale">
<property name="text">
<string>autoscale when new trace is selected</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="lineEditNumTraces"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of traces to hold&lt;br/&gt;in persistance buffer (max. 99)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Axis Ranges</string>
Expand All @@ -31,7 +72,7 @@
<string>bottom/x</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
Expand All @@ -48,7 +89,7 @@
<string>min.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
Expand All @@ -58,7 +99,7 @@
<string>left/y</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
Expand All @@ -68,7 +109,7 @@
<string>max.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
Expand All @@ -84,7 +125,7 @@
<string>axis name</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
Expand All @@ -93,48 +134,14 @@
</layout>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of traces to hold&lt;br/&gt;in persistance buffer (max. 99)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxEnableAutoscale">
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxShiftAllYScales">
<property name="text">
<string>autoscale when new trace is selected</string>
<string>dragging affects all Y scales</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxHorzGrid">
<property name="text">
<string>show horizontal grid lines</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBoxVertGrid">
<property name="text">
<string>show vertical grid lines</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditNumTraces"/>
</item>
<item row="6" column="0" colspan="2">
<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="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<widget class="QGroupBox" name="groupBoxColors">
<property name="title">
<string>Select Line Colors</string>
Expand Down Expand Up @@ -185,6 +192,19 @@
</layout>
</widget>
</item>
<item row="7" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>
Expand Down
4 changes: 2 additions & 2 deletions QtPMbrowser/renderarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,11 +654,11 @@ void RenderArea::showSettingsDialog()
{
DlgGraphSettings dlg(this);
dlg.setValues(do_autoscale_on_load, x_min, x_max, currentYscale->y_min, currentYscale->y_max, numtraces,
show_grid_horz, show_grid_vert, color_grid, color_trace, color_bktrace);
show_grid_horz, show_grid_vert, shift_all_y_scales, color_grid, color_trace, color_bktrace);
if (dlg.exec()) {
settings_modified = true;
dlg.getValues(do_autoscale_on_load, x_min, x_max, currentYscale->y_min, currentYscale->y_max, numtraces,
show_grid_horz, show_grid_vert, color_grid, color_trace, color_bktrace);
show_grid_horz, show_grid_vert, shift_all_y_scales, color_grid, color_trace, color_bktrace);
// if numtraces has been reduced we want to get rid of excess traces
while (tracebuffer.size() > numtraces) {
delete tracebuffer.dequeue();
Expand Down
4 changes: 2 additions & 2 deletions QtPMbrowser/renderarea.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class RenderArea : public QWidget
bool isXYmode() { return xTrace.isValid(); };

bool YtraceHasX() { return (yTrace.isValid() && yTrace.has_x_trace()); };
bool isSettingsModified() { return settings_modified; };
bool isAutoscaleEnabled() { return do_autoscale_on_load; };
bool isSettingsModified() const { return settings_modified; };
bool isAutoscaleEnabled() const { return do_autoscale_on_load; };
void saveSettings();
void loadSettings();

Expand Down

0 comments on commit 215b881

Please sign in to comment.