datview 2.0.0__tar.gz → 2.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datview
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: GUI software for viewing images, text, cine, and HDF files.
5
5
  Home-page: https://github.com/algotom/datview
6
6
  Download-URL: https://github.com/algotom/datview.git
@@ -0,0 +1 @@
1
+ __version__ = "2.0.1"
@@ -677,6 +677,28 @@ class DatviewInteraction(QObject):
677
677
  self.active_viewer = viewer
678
678
  self.main_win.statusBar().showMessage(f"Active: {viewer.windowTitle()}")
679
679
 
680
+ def _get_save_start_path(self, default_ext: str):
681
+ """
682
+ Return a default save path based on the current active viewer file.
683
+ """
684
+ source_path = None
685
+
686
+ if self.active_viewer and hasattr(self.active_viewer, "file_path"):
687
+ source_path = self.active_viewer.file_path
688
+
689
+ if source_path:
690
+ source_path = os.path.normpath(source_path)
691
+
692
+ if os.path.isfile(source_path):
693
+ base_dir = os.path.dirname(source_path)
694
+ base_name = os.path.splitext(os.path.basename(source_path))[0]
695
+ return os.path.join(base_dir, base_name + default_ext)
696
+
697
+ if os.path.isdir(source_path):
698
+ return os.path.join(source_path, "output" + default_ext)
699
+
700
+ return os.path.join(os.getcwd(), "output" + default_ext)
701
+
680
702
  def save_to_image(self):
681
703
  if self.active_viewer and hasattr(self.active_viewer, 'viewer_state'):
682
704
  img = self.active_viewer.viewer_state.get("image")
@@ -688,13 +710,28 @@ class DatviewInteraction(QObject):
688
710
  QMessageBox.information(self.main_win, "Input needed",
689
711
  "No active image. Use Interactive-Viewer!")
690
712
  return
713
+ default_path = self._get_save_start_path(".tif")
714
+ path, selected_filter = QFileDialog.getSaveFileName(
715
+ self.main_win,
716
+ "Save Image As",
717
+ default_path,
718
+ "TIFF (*.tif);;PNG (*.png);;JPEG (*.jpg)")
719
+
720
+ if not path:
721
+ return
691
722
 
692
- path, _ = QFileDialog.getSaveFileName(self.main_win,
693
- "Save Image As", "",
694
- "TIFF (*.tif);;PNG (*.png);;"
695
- "JPEG (*.jpg)")
696
- if path:
697
- util.save_image(path, img)
723
+ if not os.path.splitext(path)[1]:
724
+ if "PNG" in selected_filter:
725
+ path += ".png"
726
+ elif "JPEG" in selected_filter:
727
+ path += ".jpg"
728
+ else:
729
+ path += ".tif"
730
+
731
+ err = util.save_image(path, img)
732
+ if err:
733
+ QMessageBox.critical(self, "Save failed", err)
734
+ else:
698
735
  self.main_win.statusBar().showMessage(f"Image saved to: {path}")
699
736
 
700
737
  def save_to_table(self):
@@ -718,11 +755,19 @@ class DatviewInteraction(QObject):
718
755
  f"({util.MAX_TABLE_SAVE} elements).")
719
756
  return
720
757
 
721
- path, _ = QFileDialog.getSaveFileName(self.main_win, "Save Data As", "",
722
- "CSV (*.csv)")
758
+ default_path = self._get_save_start_path(".csv")
759
+
760
+ path, _ = QFileDialog.getSaveFileName(self.main_win, "Save Data As",
761
+ default_path, "CSV (*.csv)")
762
+
723
763
  if path:
724
- util.save_table(path, data)
725
- self.main_win.statusBar().showMessage(f"Data saved to: {path}")
764
+ if not os.path.splitext(path)[1]:
765
+ path += ".csv"
766
+ err = util.save_table(path, data)
767
+ if err:
768
+ QMessageBox.critical(self, "Save failed", err)
769
+ else:
770
+ self.main_win.statusBar().showMessage(f"Data saved to: {path}")
726
771
 
727
772
  def _show_window(self, win):
728
773
  self.viewers.append(win)
@@ -96,6 +96,14 @@ THEME_QSS = f"""
96
96
  """
97
97
 
98
98
 
99
+ if platform.system() == "Linux":
100
+ for var in ("FONTCONFIG_FILE", "FONTCONFIG_PATH"):
101
+ if var in os.environ and not os.environ[var].strip():
102
+ del os.environ[var]
103
+ os.environ.setdefault("FONTCONFIG_FILE", "/etc/fonts/fonts.conf")
104
+ os.environ.setdefault("FONTCONFIG_PATH", "/etc/fonts")
105
+
106
+
99
107
  def select_ui_font(point_size: int = 13, weight: int = QFont.Normal) -> QFont:
100
108
  """
101
109
  Choose a UI font based on OS, using a priority list.
@@ -1621,7 +1629,6 @@ class InteractiveViewerWindow(BaseWindow):
1621
1629
  self.v_line.setPos(x)
1622
1630
  self.v_line.show()
1623
1631
  self.h_line.hide()
1624
- # data = img[:, x]
1625
1632
  data = np.asarray(img[:, x], dtype=np.float64)
1626
1633
  self.plot_widget.setTitle(f"Intensity at column: {x}")
1627
1634
  if not np.isfinite(data).all():
@@ -1652,6 +1659,7 @@ class InteractiveViewerWindow(BaseWindow):
1652
1659
  pass
1653
1660
 
1654
1661
  def save_current_image(self):
1662
+ self.perform_update()
1655
1663
  if hasattr(self.parent_app, "set_active_viewer"):
1656
1664
  self.parent_app.set_active_viewer(self)
1657
1665
  self.parent_app.save_to_image()
@@ -5,6 +5,7 @@ import argparse
5
5
  from PySide6.QtCore import QTimer
6
6
  import datview.lib.utilities as util
7
7
  from datview.lib.interactions import DatviewInteraction
8
+ from datview import __version__
8
9
 
9
10
  display_msg = """
10
11
  ===============================================================================
@@ -19,6 +20,8 @@ def parse_args():
19
20
  parser = argparse.ArgumentParser(
20
21
  description=display_msg,
21
22
  formatter_class=argparse.RawDescriptionHelpFormatter)
23
+ parser.add_argument("-v", "--version", action="version",
24
+ version=f"Datview {__version__}")
22
25
  parser.add_argument("-b", "--base", type=str, default=None,
23
26
  help="Specify the base folder")
24
27
  parser.add_argument("path", type=str, nargs="?", default=None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datview
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: GUI software for viewing images, text, cine, and HDF files.
5
5
  Home-page: https://github.com/algotom/datview
6
6
  Download-URL: https://github.com/algotom/datview.git
@@ -14,7 +14,7 @@ README = (HERE / "README.md").read_text()
14
14
 
15
15
  setuptools.setup(
16
16
  name="datview",
17
- version="2.0.0",
17
+ version="2.0.1",
18
18
  author="Nghia Vo",
19
19
  author_email="nvo@bnl.gov",
20
20
  description="GUI software for viewing images, text, cine, and HDF files.",
@@ -1 +0,0 @@
1
- __version__ = "2.0.0"
File without changes
File without changes
File without changes
File without changes