Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions QtPMbrowser/DlgGraphSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ void DlgGraphSettings::selectBkTraceColor()
}
}

void DlgGraphSettings::setValues(bool autoscale, double xmin, double xmax, double ymin, double ymax,
void DlgGraphSettings::setValues(bool autoscale, bool global_autoscale,
double xmin, double xmax, double ymin, double ymax,
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.checkBoxGlobalAutoscale->setChecked(global_autoscale);
ui.checkBoxHorzGrid->setChecked(grid_horz);
ui.checkBoxVertGrid->setChecked(grid_vert);
ui.checkBoxShiftAllYScales->setChecked(shift_all_y_scales);
Expand All @@ -92,12 +94,14 @@ void DlgGraphSettings::setValues(bool autoscale, double xmin, double xmax, doubl
ui.widgetColorBkTrace->setPalette(QPalette(m_color_bktrace));
}

void DlgGraphSettings::getValues(bool& autoscale, double& xmin, double& xmax, double& ymin, double& ymax,
void DlgGraphSettings::getValues(bool& autoscale, bool& global_autoscale,
double& xmin, double& xmax, double& ymin, double& ymax,
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();
global_autoscale = ui.checkBoxGlobalAutoscale->isChecked();
grid_horz = ui.checkBoxHorzGrid->isChecked();
grid_vert = ui.checkBoxVertGrid->isChecked();
shift_all_y_scales = ui.checkBoxShiftAllYScales->isChecked();
Expand Down
4 changes: 2 additions & 2 deletions QtPMbrowser/DlgGraphSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ private slots:
public:
DlgGraphSettings(QWidget *parent = Q_NULLPTR);
~DlgGraphSettings();
void setValues(bool autoscale, double xmin, double xmax,
void setValues(bool autoscale, bool global_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,
void getValues(bool& autoscale, bool& global_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);
Expand Down
91 changes: 49 additions & 42 deletions QtPMbrowser/DlgGraphSettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
<x>0</x>
<y>0</y>
<width>359</width>
<height>447</height>
<height>501</height>
</rect>
</property>
<property name="windowTitle">
<string>Graph Settings &amp; Axis Ranges</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxHorzGrid">
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxVertGrid">
<property name="text">
<string>show horizontal grid lines</string>
<string>show vertical grid lines</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBoxVertGrid">
<widget class="QCheckBox" name="checkBoxHorzGrid">
<property name="text">
<string>show vertical grid lines</string>
<string>show horizontal grid lines</string>
</property>
</widget>
</item>
Expand All @@ -35,27 +35,7 @@
</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">
<item row="6" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Axis Ranges</string>
Expand Down Expand Up @@ -134,14 +114,33 @@
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxShiftAllYScales">
<property name="text">
<string>dragging affects all Y scales</string>
<item row="9" 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="4" column="0" colspan="2">
<item row="8" 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>
<item row="7" column="1">
<widget class="QLineEdit" name="lineEditNumTraces"/>
</item>
<item row="5" column="0" colspan="2">
<widget class="QGroupBox" name="groupBoxColors">
<property name="title">
<string>Select Line Colors</string>
Expand Down Expand Up @@ -192,18 +191,26 @@
</layout>
</widget>
</item>
<item row="7" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBoxShiftAllYScales">
<property name="text">
<string>dragging affects all Y scales</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</widget>
</item>
<item row="7" 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>
</spacer>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxGlobalAutoscale">
<property name="text">
<string>autoscale regards all displayed trace</string>
</property>
</widget>
</item>
</layout>
</widget>
Expand Down
60 changes: 49 additions & 11 deletions QtPMbrowser/renderarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ RenderArea::RenderArea(QWidget* parent) :
clipped{ false },
x_min{ 0.0 }, x_max{ 0.0 },
a_x{}, b_x{}, a_y{}, b_y{}, numtraces{ 10 },
do_autoscale_on_load{ true }, isTraceDragging{ false }, isPinching{false},
do_autoscale_on_load{ true }, global_autoscale{false},
isTraceDragging{ false }, isPinching{false},
isSelecting{ false }, selStart{}, selEnd{}, tempPixMap{ nullptr },
settings_modified{ false }
{
Expand Down Expand Up @@ -565,18 +566,51 @@ static void find_min_max(std::vector<double>::const_iterator first,
void RenderArea::autoScale()
{
if (noData()) return;
if (isXYmode()) {
find_min_max(xTrace.data.cbegin(), xTrace.data.cend(), x_min, x_max);

double g_x_min{std::numeric_limits<double>::max()},
g_x_max{std::numeric_limits<double>::min()},
g_y_min{std::numeric_limits<double>::max()},
g_y_max{std::numeric_limits<double>::min()};
// first find min/max for x
if(isXYmode()){
find_min_max(xTrace.data.cbegin(), xTrace.data.cend(), g_x_min, g_x_max);
}
else if (yTrace.has_x_trace()) {
find_min_max(yTrace.p_xdata->cbegin(), yTrace.p_xdata->cend(), x_min, x_max);
find_min_max(yTrace.p_xdata->cbegin(), yTrace.p_xdata->cend(), g_x_min, g_x_max);
}
else
{
x_min = yTrace.x0;
x_max = yTrace.x0 + static_cast<double>(yTrace.data.size() - 1) * yTrace.deltax;
g_x_min = yTrace.x0;
g_x_max = yTrace.x0 + static_cast<double>(yTrace.data.size() - 1) * yTrace.deltax;
}
if(global_autoscale){
for(const auto* t: tracebuffer){
if(t->has_x_trace()){
double minx, maxx;
find_min_max(t->p_xdata->cbegin(), t->p_xdata->cend(), minx, maxx);
g_x_min=std::min(g_x_min,minx);
g_x_max=std::max(g_x_max, maxx);
}
}
}
x_min=g_x_min;
x_max=g_x_max;


//find_min_max(yTrace.data.cbegin(), yTrace.data.cend(), currentYscale->y_min, currentYscale->y_max);
find_min_max(yTrace.data.cbegin(), yTrace.data.cend(), g_y_min, g_y_max);
if(global_autoscale){
for(const auto* t: tracebuffer){
// only touch scaling for curent y-unit
if(t->y_unit!=yTrace.y_unit) continue;
double miny, maxy;
find_min_max(t->data.cbegin(), t->data.cend(), miny, maxy);
g_y_min=std::min(g_y_min,miny);
g_y_max=std::max(g_y_max, maxy);
}
}
find_min_max(yTrace.data.cbegin(), yTrace.data.cend(), currentYscale->y_min, currentYscale->y_max);
currentYscale->y_min=g_y_min;
currentYscale->y_max=g_y_max;
update();
}

Expand Down Expand Up @@ -655,11 +689,13 @@ void RenderArea::copyToClipboard()
void RenderArea::showSettingsDialog()
{
DlgGraphSettings dlg(this);
dlg.setValues(do_autoscale_on_load, x_min, x_max, currentYscale->y_min, currentYscale->y_max, numtraces,
dlg.setValues(do_autoscale_on_load, global_autoscale,
x_min, x_max, currentYscale->y_min, currentYscale->y_max, numtraces,
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,
dlg.getValues(do_autoscale_on_load, global_autoscale,
x_min, x_max, currentYscale->y_min, currentYscale->y_max, numtraces,
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) {
Expand Down Expand Up @@ -845,7 +881,8 @@ void RenderArea::loadSettings()
{
QSettings s;
s.beginGroup("renderarea");
do_autoscale_on_load = s.value("do_autoscale_on_load", int(do_autoscale_on_load)).toInt();
do_autoscale_on_load = s.value("do_autoscale_on_load", do_autoscale_on_load).toBool();
global_autoscale = s.value("global_autoscale", global_autoscale).toBool();
shift_all_y_scales = s.value("shift_all_y_scales", int(shift_all_y_scales)).toInt();
show_grid_horz = s.value("show_grid_horz", int(show_grid_horz)).toInt();
show_grid_vert = s.value("show_grid_vert", int(show_grid_vert)).toInt();
Expand All @@ -863,7 +900,8 @@ void RenderArea::saveSettings()
{
QSettings s;
s.beginGroup("renderarea");
s.setValue("do_autoscale_on_load", int(do_autoscale_on_load));
s.setValue("do_autoscale_on_load", do_autoscale_on_load);
s.setValue("global_autoscale", global_autoscale);
s.setValue("shift_all_y_scales", int(shift_all_y_scales));
s.setValue("show_grid_horz", int(show_grid_horz));
s.setValue("show_grid_vert", int(show_grid_vert));
Expand Down
1 change: 1 addition & 0 deletions QtPMbrowser/renderarea.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public slots:
double a_x, b_x, a_y, b_y; // for scaling
int numtraces; // number of traces in persistance buffer
bool do_autoscale_on_load;
bool global_autoscale;
bool show_grid_horz{ true }, show_grid_vert{ true };
bool isTraceDragging, isPinching;
// for marquee zoom function:
Expand Down