Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c919707
updating doc
ChrisHal Jan 9, 2025
1b6adbd
update some copyrigth years
ChrisHal Jan 9, 2025
2a15067
improve design of DlgExportMetadata and make it lokk good on macOS
ChrisHal Dec 12, 2024
9356eb4
code cleanup after clazy clang-tidy, and better comments
ChrisHal Dec 18, 2024
46629a7
times are probably not UTC, so ommit UTC when formatting
ChrisHal Dec 18, 2024
bec6700
keep Y scaling seperate for each trace unit
ChrisHal Jan 6, 2025
f3aff73
shift all y scales while dragging (is configurable)
ChrisHal Jan 6, 2025
1d95730
DlgGraphSetting: add checkbox to select dragging of all Y axes
ChrisHal Jan 8, 2025
cb425c8
renderarea: ensure that currentYScale is always initialized
ChrisHal Jan 8, 2025
c265f46
updating doc
ChrisHal Jan 9, 2025
8fddb4b
update some copyrigth years
ChrisHal Jan 9, 2025
986d7b6
Merge branch 'improvements' of https://github.com/ChrisHal/PMbrowser …
ChrisHal Jan 9, 2025
f81a2bd
json formatting: values should not have unneeded quotes
ChrisHal Jan 13, 2025
5100fe8
JSON files: always use C locale
ChrisHal Jan 15, 2025
ed45b6c
set globale c++ locale to system locale (in RenderArea we already use…
ChrisHal Jan 15, 2025
c11c3f3
use locale aware formatting for double values
ChrisHal Jan 15, 2025
ac3a9b1
make use of system locale an option in Preferences dialog
ChrisHal Jan 15, 2025
928bda8
change list seperator to ';', since ',' might be used as decimal sepe…
ChrisHal Jan 15, 2025
b6d9dd2
enforce const correctness
ChrisHal Jan 17, 2025
26dc08c
more const correctness
ChrisHal Jan 17, 2025
2ddcb61
doc: remove obsolete ref. to no longer supported appimage
ChrisHal Jan 20, 2025
188d8e2
new python script expample: calc means of multiple files
ChrisHal Jan 24, 2025
d07de87
add parameter TrDataPoints
ChrisHal Jan 24, 2025
b0d5379
fix system locale on macOS
ChrisHal Mar 6, 2025
4ed3deb
refine setting of global locale at startup (necessary for macOS)
ChrisHal Mar 11, 2025
e241520
usr utf8 encoding in example python scripts, fixes issue #59
ChrisHal Mar 11, 2025
a3fefe5
fix copyright year
ChrisHal Mar 11, 2025
9014966
fix metadata table export with system locale on macOS
ChrisHal Mar 11, 2025
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.16)
project(QtPMbrowser VERSION 2.4.3 LANGUAGES CXX)
set(MY_COPYRIGHT "2020 - 2024 Christian R. Halaszovich")
set(MY_COPYRIGHT "2020 - 2025 Christian R. Halaszovich")
set(LINUX_RELEASE_DESCRIPTION "<p>This is a bugfix release.</p>")

set(CMAKE_CXX_STANDARD 20)
Expand Down
2 changes: 1 addition & 1 deletion QtPMbrowser/DlgGraphSettings.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 - 2022 Christian R. Halaszovich
Copyright 2020 - 2022, 2025 Christian R. Halaszovich

This file is part of PMbrowser.

Expand Down
2 changes: 1 addition & 1 deletion QtPMbrowser/DlgGraphSettings.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 -2022 Christian R. Halaszovich
Copyright 2020 -2022, 2025 Christian R. Halaszovich

This file is part of PMbrowser.

Expand Down
2 changes: 2 additions & 0 deletions QtPMbrowser/DlgPreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ DlgPreferences::DlgPreferences(QWidget *parent)
else ui->radioButtonCustomExt->setChecked(true);
ui->lineEditVmon->setText(settings.value("Vmon", "Vmon").toString());
ui->lineEditImon->setText(settings.value("Imon", "Imon").toString());
ui->checkBoxSysLocale->setChecked(!settings.value("use_C_locale", false).toBool());

settings.endGroup();
}
Expand All @@ -56,6 +57,7 @@ void DlgPreferences::accept()
settings.setValue("selectionButton", selection);
settings.setValue("Vmon", ui->lineEditVmon->text());
settings.setValue("Imon", ui->lineEditImon->text());
settings.setValue("use_C_locale", !ui->checkBoxSysLocale->isChecked());
settings.endGroup();
switch (selection) {
case 0:
Expand Down
55 changes: 31 additions & 24 deletions QtPMbrowser/DlgPreferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>453</width>
<height>321</height>
<height>360</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -17,29 +17,6 @@
<locale language="English" country="UnitedStates"/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0" colspan="3">
<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="0" column="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="title">
Expand Down Expand Up @@ -128,6 +105,36 @@
</layout>
</widget>
</item>
<item row="2" column="0" colspan="3">
<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="0" column="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBoxSysLocale">
<property name="text">
<string>Use System Locale (takes effect only after re-start!)</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
Expand Down
15 changes: 14 additions & 1 deletion QtPMbrowser/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 - 2022 Christian R. Halaszovich
Copyright 2020 - 2025 Christian R. Halaszovich

This file is part of PMbrowser.

Expand All @@ -17,9 +17,11 @@
along with PMbrowser. If not, see <https://www.gnu.org/licenses/>.
*/

#include <locale>
#include "pmbrowserwindow.h"
#include <QApplication>
#include <QSettings>
#include <QDebug>

int main(int argc, char *argv[])
{
Expand All @@ -30,6 +32,17 @@ int main(int argc, char *argv[])
QCoreApplication::setApplicationName("PM browser");
QSettings::setDefaultFormat(QSettings::IniFormat);
QApplication::setWindowIcon(QIcon(QString(":/myappico.ico"))); // sets icon in OS X dock

{
QSettings settings;
const bool use_C_locale = settings.value("Preferences/use_C_locale", false).toBool();
if (use_C_locale) {
QLocale::setDefault(QLocale::c());
}
QLocale loc;
std::locale::global(std::locale(loc.name().toUtf8()));
qDebug() << std::locale().name();
}
PMbrowserWindow w;
w.show();
if (argc > 1) {
Expand Down
23 changes: 12 additions & 11 deletions QtPMbrowser/pmbrowserwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 - 2024 Christian R. Halaszovich
Copyright 2020 - 2025 Christian R. Halaszovich

This file is part of PMbrowser.

Expand Down Expand Up @@ -111,7 +111,7 @@ void PMbrowserWindow::populateTreeView()
tree->expandAll();
}

void PMbrowserWindow::traceSelected(QTreeWidgetItem* item, hkTreeNode* trace)
void PMbrowserWindow::traceSelected(const QTreeWidgetItem* item, const hkTreeNode* trace)
{
(void)item;
int indextrace = trace->extractInt32(TrTraceID);
Expand All @@ -129,7 +129,7 @@ void PMbrowserWindow::traceSelected(QTreeWidgetItem* item, hkTreeNode* trace)

// keep the following, since here we format it more nicely, with correct name and units
// this is beyond what PMparmaters can do right now.
QString info = QString("%1=%2 %3").arg(prefix).arg(holding).arg(QLatin1StringView(yunit));
QString info = QString("%1=%L2 %3").arg(prefix).arg(holding).arg(QLatin1StringView(yunit));
std::string str;
formatParamListPrint(*trace, parametersTrace, str);
info.append("\n");
Expand All @@ -138,7 +138,7 @@ void PMbrowserWindow::traceSelected(QTreeWidgetItem* item, hkTreeNode* trace)
ui->renderArea->renderTrace(trace, this->infile);
}

void PMbrowserWindow::collectChildTraces(QTreeWidgetItem* item, int level, std::vector<hkTreeNode*>& trace_list)
void PMbrowserWindow::collectChildTraces(const QTreeWidgetItem* item, int level, std::vector<hkTreeNode*>& trace_list)
{
if (!item->isHidden()) {
if (level < hkTreeNode::LevelTrace) {
Expand Down Expand Up @@ -180,7 +180,7 @@ void PMbrowserWindow::animateTraceList(const QString& info_text, const std::vect
progress.setValue(num_traces);
}

static hkLib::hkTreeNode* item2node(QTreeWidgetItem* item)
static const hkLib::hkTreeNode* item2node(const QTreeWidgetItem* item)
{
return item->data(0, Qt::UserRole).value<hkTreeNode*>();
}
Expand Down Expand Up @@ -228,7 +228,7 @@ hkLib::hkTreeView PMbrowserWindow::getVisibleNodes()
return tree;
}

void PMbrowserWindow::sweepSelected(QTreeWidgetItem* item, hkTreeNode* sweep) {
void PMbrowserWindow::sweepSelected(const QTreeWidgetItem* item, const hkTreeNode* sweep) {
(void)item;
QString txt = MakeSweepLabel(*sweep) + '\n';
std::string str;
Expand All @@ -239,7 +239,7 @@ void PMbrowserWindow::sweepSelected(QTreeWidgetItem* item, hkTreeNode* sweep) {
ui->textEdit->append(txt);
}

void PMbrowserWindow::seriesSelected(QTreeWidgetItem* item, hkTreeNode* series)
void PMbrowserWindow::seriesSelected(const QTreeWidgetItem* item, const hkTreeNode* series)
{
(void)item;
QString label = qs_from_sv(series->getString(SeLabel));
Expand All @@ -252,7 +252,7 @@ void PMbrowserWindow::seriesSelected(QTreeWidgetItem* item, hkTreeNode* series)
ui->textEdit->append(txt);
}

void PMbrowserWindow::groupSelected(QTreeWidgetItem* item, hkTreeNode* group)
void PMbrowserWindow::groupSelected(const QTreeWidgetItem* item, const hkTreeNode* group)
{
(void)item;
QString label = qs_from_sv(group->getString(GrLabel));
Expand Down Expand Up @@ -803,7 +803,8 @@ void PMbrowserWindow::on_actionExport_Metadata_as_Table_triggered()
try {
hkLib::locale_manager lm;
if (dlg.useSystemLocale()) {
lm.setLocale(""); // set default locale
// for macOS, we need to jump to some hoops
lm.setLocale(QLocale::system().name().toUtf8());
}
else {
lm.setLocale("C");
Expand Down Expand Up @@ -1009,12 +1010,12 @@ void PMbrowserWindow::on_actionSelect_Parameters_triggered()
}
}

void ::PMbrowserWindow::printAllParameters(QTreeWidgetItem* item)
void ::PMbrowserWindow::printAllParameters(const QTreeWidgetItem* item)
{
printAllParameters(item->data(0, Qt::UserRole).value<hkTreeNode*>());
}

void ::PMbrowserWindow::printAllParameters(hkTreeNode* n)
void ::PMbrowserWindow::printAllParameters(const hkTreeNode* n)
{
std::string s;
QString lb;
Expand Down
14 changes: 7 additions & 7 deletions QtPMbrowser/pmbrowserwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ public slots:
void loadFile() {loadFile(currentFile);};
void closeFile();
void populateTreeView();
void groupSelected(QTreeWidgetItem* item, hkLib::hkTreeNode* node);
void seriesSelected(QTreeWidgetItem* item, hkLib::hkTreeNode* node);
void sweepSelected(QTreeWidgetItem* item, hkLib::hkTreeNode* node);
void traceSelected(QTreeWidgetItem* item, hkLib::hkTreeNode* trace);
void collectChildTraces(QTreeWidgetItem* item, int level, std::vector<hkLib::hkTreeNode*>& trace_list);
void groupSelected(const QTreeWidgetItem* item, const hkLib::hkTreeNode* node);
void seriesSelected(const QTreeWidgetItem* item, const hkLib::hkTreeNode* node);
void sweepSelected(const QTreeWidgetItem* item, const hkLib::hkTreeNode* node);
void traceSelected(const QTreeWidgetItem* item, const hkLib::hkTreeNode* trace);
void collectChildTraces(const QTreeWidgetItem* item, int level, std::vector<hkLib::hkTreeNode*>& trace_list);
void animateTraceList(const QString& info_text, const std::vector<hkLib::hkTreeNode*>& trace_list);
hkLib::hkTreeView getVisibleNodes();
void printAllParameters(QTreeWidgetItem* item);
void printAllParameters(hkLib::hkTreeNode* node);
void printAllParameters(const QTreeWidgetItem* item);
void printAllParameters(const hkLib::hkTreeNode* node);
void printAmplifierState(const hkLib::hkTreeNode* series);
void drawStimulus(const hkLib::hkTreeNode* sweep);
void useStimAsX(const hkLib::hkTreeNode* sweep);
Expand Down
4 changes: 2 additions & 2 deletions QtPMbrowser/renderarea.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 - 2022 Christian R. Halaszovich
Copyright 2020 - 2022, 2025 Christian R. Halaszovich

This file is part of PMbrowser.

Expand Down Expand Up @@ -683,7 +683,7 @@ void RenderArea::zoomIn(double x_center, double y_center, double factor)
update();
}

void RenderArea::renderTrace(hkLib::hkTreeNode* TrRecord, std::istream& infile)
void RenderArea::renderTrace(const hkLib::hkTreeNode* TrRecord, std::istream& infile)
{
using namespace hkLib;
DisplayTrace newYtrace{};
Expand Down
4 changes: 2 additions & 2 deletions QtPMbrowser/renderarea.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 - 2022 Christian R. Halaszovich
Copyright 2020 - 2022, 2025 Christian R. Halaszovich

This file is part of PMbrowser.

Expand Down Expand Up @@ -48,7 +48,7 @@ class RenderArea : public QWidget
explicit RenderArea(QWidget *parent = nullptr);
~RenderArea();
bool noData() { return !yTrace.isValid(); };
void renderTrace(hkLib::hkTreeNode* trace, std::istream& infile);
void renderTrace(const hkLib::hkTreeNode* trace, std::istream& infile);
void addTrace(DisplayTrace&& dt);

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PMbrowser
Copyright 2020 - 2024 Christian R. Halaszovich
Copyright 2020 - 2025 Christian R. Halaszovich

Created using Qt under GPLv3.

Expand Down
2 changes: 1 addition & 1 deletion demo/calc_mean.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def getMeta(npy_filename):
json_filename=os.path.splitext(npy_filename)[0]+".json"
with open(json_filename, "r", encoding='latin1') as f:
with open(json_filename, "r", encoding='utf8') as f:
meta=json.load(f)
return meta

Expand Down
68 changes: 68 additions & 0 deletions demo/calc_means.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# This Python file uses the following encoding: utf-8
import os.path
import sys
import json
import glob
import numpy as np

def getMeta(npy_filename):
json_filename=os.path.splitext(npy_filename)[0]+".json"
with open(json_filename, "r", encoding='utf8') as f:
meta=json.load(f)
return meta

def getNpyBasename(npy_filename):
return os.path.basename(os.path.splitext(npy_filename)[0])

class TraceKey:
"""Key useable for sorting tracenames."""
def __init__(self,npy_filename):
c=getNpyBasename(npy_filename).split('_')
self.prefix=c[0]
self.group=int(c[1])
self.series=int(c[2])
self.sweep=int(c[3])
self.trace=c[4]

def __lt__(self, other):
if(self.prefix<other.prefix):
return True
if(self.prefix>other.prefix):
return False
if(self.group<other.group):
return True
if(self.group>other.group):
return False
if(self.series<other.series):
return True
if(self.series>other.series):
return False
if(self.sweep<other.sweep):
return True
if(self.sweep>other.sweep):
return False
if(self.trace<other.trace):
return True
return False

if __name__ == '__main__':
if(len(sys.argv)<4):
print("""
usage: calc_mean <1st point> <last point> <file1>.npy [additional files ...]
example: calc_mean 0 100 PM_1_1_1_Imon.npy
""",file=sys.stderr)
sys.exit(-1)
p1=int(sys.argv[1])
p2=int(sys.argv[2])
filelist=[]
for index in range(3,len(sys.argv)):
filelist+=glob.glob(sys.argv[index])
if(len(filelist)==0):
print("no matching files found",file=sys.stderr)
sys.exit(-1)
filelist.sort(key=TraceKey)
for npy_filename in filelist:
basename=os.path.basename(os.path.splitext(npy_filename)[0])
meta=getMeta(npy_filename)
y_w=np.load(npy_filename)
print(basename, meta['params']['sweep']['Rel. Sweep Time'], np.mean(y_w[p1:p2]), sep='\t')
2 changes: 1 addition & 1 deletion demo/multiplot_traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def getMeta(npy_filename):
json_filename=os.path.splitext(npy_filename)[0]+".json"
with open(json_filename, "r", encoding='latin1') as f:
with open(json_filename, "r", encoding='utf8') as f:
meta=json.load(f)
return meta

Expand Down
Loading