-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh: improved visualization of meta data parameters in the Info tab
- Loading branch information
1 parent
fcfbf90
commit 93dee35
Showing
5 changed files
with
137 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import numbers | ||
import pkg_resources | ||
|
||
from afmformats import meta | ||
from PyQt5 import uic, QtWidgets | ||
|
||
|
||
class TabInfo(QtWidgets.QWidget): | ||
def __init__(self, *args, **kwargs): | ||
super(TabInfo, self).__init__(*args, **kwargs) | ||
path_ui = pkg_resources.resource_filename("pyjibe.fd", | ||
"tab_info.ui") | ||
uic.loadUi(path_ui, self) | ||
|
||
def update_info(self, fdist): | ||
text = [] | ||
keys = list(fdist.metadata.keys()) | ||
|
||
text.append("<b>Dataset</b>") | ||
data_keys = ["path", "enum"] | ||
for kk in data_keys: | ||
text.append(get_string_rep(kk, fdist.metadata)) | ||
for kk in keys: | ||
if kk in meta.DEF_DATA and kk not in data_keys: | ||
text.append(get_string_rep(kk, fdist.metadata)) | ||
|
||
if set(keys) & set(meta.DEF_EXPERIMENT.keys()): | ||
text.append("") | ||
text.append("<b>Experiment:</b>") | ||
text_meta = [] | ||
for kk in keys: | ||
if kk in meta.DEF_EXPERIMENT: | ||
text_meta.append(get_string_rep(kk, fdist.metadata)) | ||
text += sorted(text_meta) | ||
|
||
if set(keys) & set(meta.DEF_QMAP.keys()): | ||
text.append("") | ||
text.append("<b>QMap:</b>") | ||
text_meta = [] | ||
for kk in keys: | ||
if kk in meta.DEF_QMAP: | ||
text_meta.append(get_string_rep(kk, fdist.metadata)) | ||
text += sorted(text_meta) | ||
|
||
if set(keys) & set(meta.DEF_ANALYSIS.keys()): | ||
text.append("") | ||
text.append("<b>Analysis:</b>") | ||
text_meta = [] | ||
for kk in keys: | ||
if kk in meta.DEF_ANALYSIS: | ||
text_meta.append(get_string_rep(kk, fdist.metadata)) | ||
text += sorted(text_meta) | ||
|
||
textstring = "<br>".join(text) | ||
|
||
self.info_text.setText(textstring) | ||
|
||
|
||
def get_string_rep(key, metadata): | ||
"""Return a nice string representation for a key in metadata""" | ||
value = metadata[key] | ||
desc, unit, validator = meta.DEF_ALL[key] | ||
|
||
value = validator(value) | ||
|
||
if unit == "m": | ||
unit = "µm" | ||
value *= 1e6 | ||
|
||
if isinstance(value, numbers.Integral): | ||
pass | ||
elif isinstance(value, numbers.Real): | ||
if abs(value) > 1: | ||
value = "{:.2f}".format(value) | ||
elif abs(value) > 1e-2: | ||
value = "{:.5f}".format(value) | ||
else: | ||
value = "{:.3e}".format(value) | ||
|
||
rep = "{}: {}".format(desc, value) | ||
if unit: | ||
rep += " {}".format(unit) | ||
return rep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>Form</class> | ||
<widget class="QWidget" name="Form"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>411</width> | ||
<height>396</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Form</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<widget class="QTextEdit" name="info_text"> | ||
<property name="lineWrapMode"> | ||
<enum>QTextEdit::NoWrap</enum> | ||
</property> | ||
<property name="readOnly"> | ||
<bool>true</bool> | ||
</property> | ||
<property name="html"> | ||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> | ||
<html><head><meta name="qrichtext" content="1" /><style type="text/css"> | ||
p, li { white-space: pre-wrap; } | ||
</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> | ||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string> | ||
</property> | ||
<property name="overwriteMode"> | ||
<bool>false</bool> | ||
</property> | ||
<property name="placeholderText"> | ||
<string>Nothing here yet.</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |