[segyio] 136/376: Removed SegyView code from SegyIO. This will be moved to separate repository.
Jørgen Kvalsvik
jokva-guest at moszumanska.debian.org
Wed Sep 20 08:04:21 UTC 2017
This is an automated email from the git hooks/post-receive script.
jokva-guest pushed a commit to branch debian
in repository segyio.
commit e648f031198780155841dfa340ddc91fe99ab534
Author: Jean-Paul Balabanian <jepebe at users.noreply.github.com>
Date: Wed Nov 23 16:09:07 2016 +0100
Removed SegyView code from SegyIO. This will be moved to separate repository.
---
.travis.yml | 8 +-
CMakeLists.txt | 1 -
applications/CMakeLists.txt | 8 -
applications/segyviewer.py | 211 ------------------------
appveyor.yml | 4 +-
examples/CMakeLists.txt | 1 -
examples/showcase_gui.py | 58 -------
python/CMakeLists.txt | 1 -
python/segyview/CMakeLists.txt | 15 --
python/segyview/__init__.py | 42 -----
python/segyview/colormapcombo.py | 84 ----------
python/segyview/controlwidgets.py | 133 ---------------
python/segyview/layoutcanvas.py | 130 ---------------
python/segyview/layoutcombo.py | 97 -----------
python/segyview/layoutfigure.py | 31 ----
python/segyview/progresswidget.py | 25 ---
python/segyview/segyiowrapper.py | 176 --------------------
python/segyview/segyplot.py | 146 ----------------
python/segyview/slicewidget.py | 123 --------------
python/segyview/viewer.py | 189 ---------------------
resources/CMakeLists.txt | 1 -
resources/img/CMakeLists.txt | 21 ---
resources/img/layouts_four_grid.png | Bin 1428 -> 0 bytes
resources/img/layouts_single.png | Bin 1246 -> 0 bytes
resources/img/layouts_three_bottom_grid.png | Bin 2345 -> 0 bytes
resources/img/layouts_three_horizontal_grid.png | Bin 2228 -> 0 bytes
resources/img/layouts_three_top_grid.png | Bin 2397 -> 0 bytes
resources/img/layouts_three_vertical_grid.png | Bin 1408 -> 0 bytes
resources/img/layouts_two_horizontal_grid.png | Bin 2341 -> 0 bytes
resources/img/layouts_two_vertical_grid.png | Bin 2277 -> 0 bytes
resources/img/readme.txt | 7 -
tests/CMakeLists.txt | 1 -
tests/test_segyview.py | 25 ---
33 files changed, 3 insertions(+), 1535 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 42b04dc..64b69ae 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,12 +28,6 @@ addons:
- cmake-data
- valgrind
- python-numpy
- - python-matplotlib
-
-install:
- - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
- pip install --user matplotlib;
- fi
before_script:
# Valgrind is experimental(ish) on MacOS with false positives on among others printf
@@ -49,4 +43,4 @@ before_script:
- make
- export LD_LIBRARY_PATH=$PWD
-script: make && ctest --output-on-failure -E gui
+script: make && ctest --output-on-failure
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 97ce261..324b3f2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -56,7 +56,6 @@ add_subdirectory(python)
add_subdirectory(applications)
add_subdirectory(examples)
add_subdirectory(tests)
-add_subdirectory(resources)
# install the library
install(FILES src/segyio/segy.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/segyio)
diff --git a/applications/CMakeLists.txt b/applications/CMakeLists.txt
index ad30c64..e67bff1 100644
--- a/applications/CMakeLists.txt
+++ b/applications/CMakeLists.txt
@@ -1,11 +1,3 @@
-configure_file(segyviewer.py segyviewer COPYONLY)
-
-if (BUILD_PYTHON)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/segyviewer
- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_EXECUTE WORLD_READ
- DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
-endif ()
-
add_executable(segyinfo segyinfo.c)
target_link_libraries(segyinfo segyio-static)
add_dependencies(segyinfo segyio-static)
diff --git a/applications/segyviewer.py b/applications/segyviewer.py
deleted file mode 100755
index 5f386e2..0000000
--- a/applications/segyviewer.py
+++ /dev/null
@@ -1,211 +0,0 @@
-#!/usr/bin/env python
-import sys
-
-from PyQt4 import QtGui, QtCore
-from segyview import *
-
-
-class SegyViewer(QtGui.QMainWindow):
- def __init__(self, filename):
- QtGui.QMainWindow.__init__(self)
-
- # qthreads needs to be in scope of main thread to not be "accidentally" garbage collected
- self.file_loader_thread = None
- self.file_loader_worker = None
- self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
-
- # signal monitors
- self.sliceview_monitor = SliceViewMonitor(self)
- self.line_monitor = LineSelectionMonitor(self)
- self.file_activity_monitor = FileActivityMonitor(self)
-
- # the wrapper around segyio
- self.swrap = None
-
- # menus
- available_colormaps = ['seismic', 'spectral', 'RdGy', 'hot', 'jet', 'gray']
- self.configure_main_menu(self.menuBar(), self.sliceview_monitor, available_colormaps)
-
- # layout
- self.setWindowTitle("SegyViewer")
- self.xdock = QtGui.QDockWidget("x-line")
- self.xdock.setFeatures(QtGui.QDockWidget.DockWidgetFloatable | QtGui.QDockWidget.DockWidgetMovable)
-
- self.idock = QtGui.QDockWidget("i-line")
- self.idock.setFeatures(QtGui.QDockWidget.DockWidgetFloatable | QtGui.QDockWidget.DockWidgetMovable)
-
- self.ddock = QtGui.QDockWidget("depth slice")
- self.ddock.setFeatures(QtGui.QDockWidget.DockWidgetFloatable | QtGui.QDockWidget.DockWidgetMovable)
-
-
- self.cdock= QtGui.QDockWidget("Control Panel")
- self.cdock.setFeatures(QtGui.QDockWidget.DockWidgetFloatable | QtGui.QDockWidget.DockWidgetMovable)
-
- self.setup_dock_widgets()
-
- # progress bar
- self.progress_bar = ProgressWidget(self.file_activity_monitor.set_cancel_operation)
- self.statusBar().addWidget(self.progress_bar, 1)
- self.progress_bar.hide()
-
- #set up an initial size
- self.resize(1200, 800)
-
- # connect cursor overrides to file activity that might take long time
- self.file_activity_monitor.started.connect(
- lambda: QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.BusyCursor)))
- self.file_activity_monitor.finished.connect(
- lambda: QtGui.QApplication.restoreOverrideCursor())
-
- # initiate the first file load
- if filename:
- self.load_file_and_setup_slice_widgets(filename)
-
-
- def setup_dock_widgets(self):
- self.setDockOptions(QtGui.QMainWindow.AllowNestedDocks)
- self.addDockWidget(QtCore.Qt.TopDockWidgetArea, self.xdock)
- self.addDockWidget(QtCore.Qt.TopDockWidgetArea, self.idock)
- self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.ddock)
- self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.cdock)
-
-
- def configure_main_menu(self, menu, colormap_monitor, available_colormaps):
- menu.fileMenu = menu.addMenu('&File')
-
- exitAction = QtGui.QAction('&Exit', menu)
- menu.fileMenu.addAction(exitAction)
-
- openAction = QtGui.QAction('&Open', menu)
- openAction.setShortcut("Ctrl+O")
- menu.fileMenu.addAction(openAction)
- openAction.triggered.connect(self.open_file_dialogue)
-
- menu.viewMenu = menu.addMenu('&View')
- menu.colormapMenu = menu.viewMenu.addMenu("&Colormap")
-
- def set_selected_cmap(cmap_name):
- for item in menu.colormapMenu.actions():
- item.setChecked(str(item.text()) == cmap_name)
-
- colormap_monitor.cmap_changed.connect(set_selected_cmap)
-
- def colormap_changer(color_map_name):
- def perform_colormap_change():
- colormap_monitor.colormap_updated(color_map_name)
-
- return perform_colormap_change
-
- for item in available_colormaps:
- action = menu.colormapMenu.addAction(item)
- action.setCheckable(True)
- action.triggered.connect(colormap_changer(item))
-
- def remove_all_slice_widgets(self):
- # removing old widgets
- for tbar in self.findChildren(QtGui.QToolBar):
- self.removeToolBar(tbar)
-
- # removing old slice widgets from dock widgets
- for dock_widget in self.findChildren(QtGui.QDockWidget):
- for widgt in dock_widget.findChildren(QtGui.QWidget):
- widgt.deleteLater()
-
- def open_file_dialogue(self):
-
- f_dialog = QtGui.QFileDialog(self)
- f_dialog.setViewMode(QtGui.QFileDialog.Detail)
- f_dialog.setNameFilter("Segy File (*.seg *.segy *.sgy)")
- load_to_memory_label = QtGui.QLabel("Read entire Segy file to memory")
- load_to_memory_cbox = QtGui.QCheckBox()
- load_to_memory_cbox.setChecked(True)
- layout = f_dialog.layout()
- layout.addWidget(load_to_memory_label)
- layout.addWidget(load_to_memory_cbox)
-
- def file_selected(filename):
-
- if filename:
- self.load_file_and_setup_slice_widgets(filename, read_to_memory=load_to_memory_cbox.isChecked())
-
- f_dialog.fileSelected.connect(file_selected)
-
- f_dialog.show()
-
- #filename = f_dialog.getOpenFileName(None, "Open Segy File", filter="Segy file (*.seg *.segy *.sgy)")
-
- def load_file_and_setup_slice_widgets(self, filename, read_to_memory=True):
- #remove old widgets
- self.remove_all_slice_widgets()
-
- # progress bar
- self.progress_bar.show()
-
- self.file_activity_monitor.reset()
-
- # calling close on current filehandler
- if self.swrap is not None:
- self.swrap.close()
-
- # instantiating a new wrapper
- self.swrap = SegyIOWrapper.open_file_and_wrap(file_name=filename,
- file_activity_monitor=self.file_activity_monitor)
- # callback when finished
- def complete_finished_file_load_operation(status):
- if status == 0: # when completed successfully
- self.initialize_slice_widgets()
- self.progress_bar.hide()
-
-
- # a memory read, might take some time. Set up a separate thread and update the progressbar
- if read_to_memory:
- # worker thread and worker obj are referenced from main thread to not get gc'ed by accident
- self.file_loader_thread = QtCore.QThread()
- self.file_loader_worker = FileLoaderWorker(self.swrap)
- self.file_loader_worker.moveToThread(self.file_loader_thread)
-
- # what to do
- self.file_loader_thread.started.connect(self.file_loader_worker.load_file)
-
- # update progress
- self.file_loader_worker.progress.connect(self.progress_bar.set_value)
-
- # set up finished callback
- self.file_loader_worker.finished.connect(complete_finished_file_load_operation)
- self.file_loader_worker.finished.connect(self.file_loader_thread.quit)
-
-
- # and start
- self.file_loader_thread.start()
- else:
- complete_finished_file_load_operation(0)
-
- def initialize_slice_widgets(self):
- self.addToolBar(SegyViewerToolBar(self.swrap,
- self.line_monitor, self.sliceview_monitor))
-
- x_wdgt, i_wdgt, d_wdgt = viewer.initialize_slice_widgets(self.swrap, self.line_monitor, self.sliceview_monitor)
-
- self.xdock.setWidget(x_wdgt)
- self.idock.setWidget(i_wdgt)
- self.ddock.setWidget(d_wdgt)
- self.cdock.setWidget(ColorBarWidget(self.swrap, colormap_monitor=self.sliceview_monitor))
-
-def main():
-
- filename = None
- if len(sys.argv) == 2:
- filename = sys.argv[1]
-
- q_app = QtGui.QApplication(sys.argv)
- segy_viewer = SegyViewer(filename)
- segy_viewer.show()
- sys.exit(q_app.exec_())
-
-if __name__ == '__main__':
- main()
-
-
-
-
-
diff --git a/appveyor.yml b/appveyor.yml
index e451145..a51c0d7 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -18,9 +18,9 @@ environment:
- PYTHON: C:\Python27
build_script:
- - python -m pip install --user numpy matplotlib
+ - python -m pip install --user numpy
- mkdir build
- pushd build
- cmake C:\projects\SegyIO -DBUILD_MEX=OFF -DBUILD_PYTHON=ON -DCMAKE_BUILD_TYPE=%configuration%
- cmake --build . --config %configuration%
- - ctest -C %configuration% --output-on-failure -E gui
+ - ctest -C %configuration% --output-on-failure
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 89c59c9..a48d185 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -7,4 +7,3 @@ add_python_example(python.examples.makefile make-file.py test-data/large-file.sg
add_python_example(python.examples.makepsfile make-ps-file.py test-data/small-prestack.sgy 10 1 5 1 4 1 3)
add_python_example(python.examples.subcube copy-sub-cube.py test-data/small.sgy test-data/copy.sgy)
add_python_example(python.examples.scan_min_max scan_min_max.py test-data/small.sgy)
-add_python_example(python.examples.gui showcase_gui.py display_nothing)
diff --git a/examples/showcase_gui.py b/examples/showcase_gui.py
deleted file mode 100644
index 19f694d..0000000
--- a/examples/showcase_gui.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env python
-import sys
-
-from PyQt4.QtCore import Qt
-from PyQt4.QtGui import QMainWindow, QWidget, QApplication, QLabel, QVBoxLayout
-
-from segyview import LayoutCombo, ColormapCombo, LayoutCanvas
-
-
-class TestGUI(QMainWindow):
- def __init__(self):
- QMainWindow.__init__(self)
-
- self.setAttribute(Qt.WA_DeleteOnClose)
- self.setWindowTitle("GUI Test")
-
- toolbar = self.addToolBar("Stuff")
- """:type: QToolBar"""
-
- layout_combo = LayoutCombo()
- toolbar.addWidget(layout_combo)
- layout_combo.layout_changed.connect(self._layout_changed)
-
- self._colormap_combo = ColormapCombo()
- toolbar.addWidget(self._colormap_combo)
- self._colormap_combo.currentIndexChanged[int].connect(self._colormap_changed)
-
- central_widget = QWidget()
- layout = QVBoxLayout()
- central_widget.setLayout(layout)
-
- self._layout_canvas = LayoutCanvas(width=5, height=5)
- self._layout_canvas.set_plot_layout(layout_combo.get_current_layout())
- layout.addWidget(self._layout_canvas)
-
- self._colormap_label = QLabel()
- layout.addWidget(self._colormap_label)
-
- self.setCentralWidget(central_widget)
-
- def _layout_changed(self, layout):
- self._layout_canvas.set_plot_layout(layout)
-
- def _colormap_changed(self, index):
- colormap = str(self._colormap_combo.itemText(index))
- self._colormap_label.setText("Colormap selected: %s" % colormap)
-
-
-if __name__ == '__main__':
- if len(sys.argv) > 1:
- sys.exit()
- else:
- q_app = QApplication(sys.argv)
-
- gui = TestGUI()
- gui.show()
- gui.raise_()
- sys.exit(q_app.exec_())
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index ea0590f..7523ec4 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -50,4 +50,3 @@ add_custom_command(TARGET _segyio POST_BUILD
${CMAKE_BINARY_DIR}/python/segyio/_segyio.${LIB_SUFFIX})
add_subdirectory(segyio)
-add_subdirectory(segyview)
diff --git a/python/segyview/CMakeLists.txt b/python/segyview/CMakeLists.txt
deleted file mode 100644
index ddbffed..0000000
--- a/python/segyview/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-set(PYTHON_SOURCES
- __init__.py
- controlwidgets.py
- progresswidget.py
- segyiowrapper.py
- segyplot.py
- slicewidget.py
- viewer.py
- layoutcombo.py
- colormapcombo.py
- layoutfigure.py
- layoutcanvas.py
- )
-
-add_python_package(segyview segyview "${PYTHON_SOURCES}")
diff --git a/python/segyview/__init__.py b/python/segyview/__init__.py
deleted file mode 100644
index 295852a..0000000
--- a/python/segyview/__init__.py
+++ /dev/null
@@ -1,42 +0,0 @@
-import os.path as path
-
-from .segyplot import SegyPlot
-from .segyiowrapper import SegyIOWrapper, SlicesWrapper
-
-img_prefix = path.abspath(path.join(path.dirname(path.abspath(__file__)), "resources", "img"))
-
-if not path.exists(img_prefix):
- img_prefix = path.abspath(path.join(path.dirname(path.abspath(__file__)), "..", "..", "resources", "img"))
-
-
-def resource_icon_path(name):
- return path.join(img_prefix, name)
-
-
-def resource_icon(name):
- """Load an image as an icon"""
- # print("Icon used: %s" % name)
- from PyQt4.QtGui import QIcon
- return QIcon(resource_icon_path(name))
-
-
-try:
- from .colormapcombo import ColormapCombo
- from .layoutcombo import LayoutCombo
- from .layoutfigure import LayoutFigure
- from .layoutcanvas import LayoutCanvas
- from .progresswidget import ProgressWidget
- from .slicewidget import SliceWidget, ColorBarWidget
- from .segyiowrapper import SegyIOWrapper, SlicesWrapper
- from .controlwidgets import *
- from .viewer import *
-except ImportError as e:
- import sys
- import traceback
- exc_type, exc_value, exc_traceback = sys.exc_info()
- traceback.print_exception(exc_type, exc_value, exc_traceback, limit=2, file=sys.stderr)
-
-__version__ = '1.0.4'
-__copyright__ = 'Copyright 2016, Statoil ASA'
-__license__ = 'GNU Lesser General Public License version 3'
-__status__ = 'Production'
diff --git a/python/segyview/colormapcombo.py b/python/segyview/colormapcombo.py
deleted file mode 100644
index ba4e195..0000000
--- a/python/segyview/colormapcombo.py
+++ /dev/null
@@ -1,84 +0,0 @@
-from PyQt4.QtCore import QSize
-from PyQt4.QtGui import QComboBox, QPixmap, qRgb
-from PyQt4.QtCore import Qt
-from PyQt4.QtGui import QImage
-
-import numpy as np
-from matplotlib.cm import ScalarMappable
-
-
-class ColormapCombo(QComboBox):
- def __init__(self, color_maps=None, parent=None):
- QComboBox.__init__(self, parent)
- self.setMaxVisibleItems(10)
- self.setStyleSheet("QComboBox { combobox-popup: 0; }")
-
- if color_maps is None:
- color_maps = self._type_sorted_color_maps()
-
- self.setMinimumWidth(170)
- self.setMaximumWidth(170)
- self.setMinimumHeight(30)
-
- self.setIconSize(QSize(128, 16))
-
- icon_width = 256
- icon_height = 16
- values = np.linspace(0, 1, icon_width)
- color_indexes = np.linspace(0, 255, icon_width, dtype=np.uint8)
- color_indexes = np.tile(color_indexes, icon_height)
- image = QImage(color_indexes.data, icon_width, icon_height, QImage.Format_Indexed8)
-
- for index, item in enumerate(color_maps):
- self.addItem(item)
- pix_map = self._create_icon(item, image, values)
- self.setItemData(index, "", Qt.DisplayRole)
- self.setItemData(index, item, Qt.ToolTipRole)
- self.setItemData(index, pix_map, Qt.DecorationRole)
-
- def _create_icon(self, color_map_name, image, values):
- """"
- :type color_map_name: str
- :type image: QImage
- :type values: np.ndarray
- """
-
- color_map = ScalarMappable(cmap=color_map_name)
- rgba = color_map.to_rgba(values, bytes=True)
-
- color_table = [qRgb(c[0], c[1], c[2]) for c in rgba]
- image.setColorTable(color_table)
-
- return QPixmap.fromImage(image).scaledToWidth(128)
-
- def _type_sorted_color_maps(self):
- cmaps = [('Perceptually Uniform Sequential', ['viridis', 'inferno', 'plasma', 'magma']),
- ('Sequential', ['Blues', 'BuGn', 'BuPu',
- 'GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd',
- 'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu',
- 'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd']),
- ('Sequential (2)', ['afmhot', 'autumn', 'bone', 'cool',
- 'copper', 'gist_heat', 'gray', 'hot',
- 'pink', 'spring', 'summer', 'winter']),
- ('Diverging', ['BrBG', 'bwr', 'coolwarm', 'PiYG', 'PRGn', 'PuOr',
- 'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'Spectral', 'seismic']),
- ('Qualitative', ['Accent', 'Dark2', 'Paired', 'Pastel1',
- 'Pastel2', 'Set1', 'Set2', 'Set3']),
- ('Miscellaneous', ['gist_earth', 'terrain', 'ocean', 'gist_stern',
- 'brg', 'CMRmap', 'cubehelix',
- 'gnuplot', 'gnuplot2', 'gist_ncar',
- 'nipy_spectral', 'jet', 'rainbow',
- 'gist_rainbow', 'hsv', 'flag', 'prism'])
- ]
-
- # color_maps = sorted(m for m in cm.datad if not m.endswith("_r"))
-
- color_maps = []
-
- for cm_group in cmaps:
- color_maps.extend(cm_group[1])
-
- return color_maps
-
- def itemText(self, index):
- return str(self.itemData(index, Qt.ToolTipRole).toString())
diff --git a/python/segyview/controlwidgets.py b/python/segyview/controlwidgets.py
deleted file mode 100644
index 4b81657..0000000
--- a/python/segyview/controlwidgets.py
+++ /dev/null
@@ -1,133 +0,0 @@
-import sys
-from PyQt4 import QtGui, QtCore
-
-
-class LineSelector(QtGui.QWidget):
- indexChanged = QtCore.pyqtSignal(int)
-
- def __init__(self, parent, label, indexes, monitor_func):
- super(QtGui.QWidget, self).__init__(parent)
- self.label = label
- self.indexes = indexes
- self.monitor_func = monitor_func
-
- self.layout = QtGui.QHBoxLayout()
- self.slabel = QtGui.QLabel(self.label)
- self.sbox = QtGui.QSpinBox(self)
- self.sbox.setRange(self.indexes[0], self.indexes[-1])
- self.sbox.valueChanged.connect(self.monitor_func)
- self.layout.addWidget(self.slabel)
- self.layout.addWidget(self.sbox)
- self.setLayout(self.layout)
-
- def index_changed(self, val):
- self.indexChanged.emit(val)
-
- def set_index(self, val):
- self.sbox.blockSignals(True)
- self.sbox.setValue(val)
- self.sbox.blockSignals(False)
-
-
-class MinMaxControls(QtGui.QWidget):
- def __init__(self, segyio_wrapper, sliceview_monitor=None):
- super(MinMaxControls, self).__init__()
-
- self.swrap = segyio_wrapper
- self.colormap_monitor = sliceview_monitor
-
- # default to 0,1 when not set
- minv, maxv = self.swrap.min_max or (0,1)
-
- stepsize = (maxv - minv) / float(100)
- number_of_decimals = self._get_number_of_decimals_for_spinbox(stepsize)
- self.min_input = self._setup_spinbox(stepsize, number_of_decimals, minv)
- self.max_input = self._setup_spinbox(stepsize, number_of_decimals, maxv)
-
- self.min_input.setToolTip("step in 1% intervals")
- self.max_input.setToolTip("step in 1% intervals")
-
- # signals
- self.min_input.valueChanged.connect(self.min_input_changed)
- self.max_input.valueChanged.connect(self.max_input_changed)
-
- # reset button to reset spinboxes to original value from segyio_wrapper
- self.reset_btn = QtGui.QToolButton()
- self.reset_btn.clicked.connect(self.reset_min_max)
- self.reset_btn.setIcon(QtGui.QIcon.fromTheme("edit-undo"))
-
- self.layout = QtGui.QHBoxLayout(self)
- self.layout.addWidget(QtGui.QLabel("min"))
- self.layout.addWidget(self.min_input)
- self.layout.addWidget(QtGui.QLabel("max"))
- self.layout.addWidget(self.max_input)
- self.layout.addWidget(self.reset_btn)
-
- @staticmethod
- def _get_number_of_decimals_for_spinbox(step_s):
- # identify the number of decimals for spinbox
- no_of_dec, upper_bound = 1, 1.0
-
- while step_s < upper_bound:
- upper_bound /= 10
- no_of_dec += 1
-
- return no_of_dec
-
- @staticmethod
- def _setup_spinbox(step_s, decimals, initial_value):
- sbox = QtGui.QDoubleSpinBox()
- sbox.setSingleStep(step_s)
- sbox.setDecimals(decimals)
- sbox.setRange(-sys.float_info.max, sys.float_info.max)
- sbox.setValue(initial_value)
- return sbox
-
-
- def reset_min_max(self):
- min_v, max_v = self.swrap.min_max or (0, 1)
- self.min_input.setValue(min_v)
- self.max_input.setValue(max_v)
-
- def min_input_changed(self, val):
- self.max_input.setMinimum(val)
- self.colormap_monitor.min_max_updated((self.min_input.value(),
- self.max_input.value()))
-
- def max_input_changed(self, val):
- self.min_input.setMaximum(val)
- self.colormap_monitor.min_max_updated((self.min_input.value(),
- self.max_input.value()))
-
-
-class SegyViewerToolBar(QtGui.QToolBar):
- def __init__(self, segyio_wrapper, line_selection_monitor, sliceview_monitor):
- super(SegyViewerToolBar, self).__init__("")
- self.swrap = segyio_wrapper
- self.xline_indexes = self.swrap.xlines
- self.iline_indexes = self.swrap.ilines
- self.depth_indexes = range(self.swrap.samples)
-
- self.line_selection_monitor = line_selection_monitor
- self.colormap_monitor = sliceview_monitor
-
- # xline
- self.xline_selector = LineSelector(self, "x-line", self.xline_indexes, self.line_selection_monitor.xline_updated)
- self.line_selection_monitor.xline_changed.connect(self.xline_selector.set_index)
- self.addWidget(self.xline_selector)
-
- # iline
- self.iline_selector = LineSelector(self, "i-line", self.iline_indexes, self.line_selection_monitor.iline_updated)
- self.line_selection_monitor.iline_changed.connect(self.iline_selector.set_index)
- self.addWidget(self.iline_selector)
-
- # depth
- self.depth_selector = LineSelector(self, "depth", self.depth_indexes, self.line_selection_monitor.depth_updated)
- self.addWidget(self.depth_selector)
-
- # seperator
- self.addSeparator()
-
- # controls for adjusting min and max threshold for the slice plots, and colorbar
- self.minmax_ctrls = MinMaxControls(self.swrap, sliceview_monitor=self.colormap_monitor)
- self.addWidget(self.minmax_ctrls)
diff --git a/python/segyview/layoutcanvas.py b/python/segyview/layoutcanvas.py
deleted file mode 100644
index 9da61f0..0000000
--- a/python/segyview/layoutcanvas.py
+++ /dev/null
@@ -1,130 +0,0 @@
-from PyQt4 import QtGui
-from PyQt4.QtCore import pyqtSignal, Qt
-
-from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
-
-from segyview import LayoutFigure
-
-
-class Keys(object):
- def __init__(self, key=None, ctrl=False, alt=False, shift=False, meta=False):
- super(Keys, self).__init__()
- self.key = key
- self.alt = alt
- self.ctrl = ctrl
- self.super = meta
- self.shift = shift
-
- def state(self, ctrl=False, alt=False, shift=False, meta=False):
- return self.ctrl == ctrl and self.alt == alt and self.shift == shift and self.super == meta
-
- def __bool__(self):
- return not (self.key is None and not self.alt and not self.ctrl and not self.super and not self.shift)
-
- __nonzero__ = __bool__
-
- def __str__(self):
- return "%s ctrl: %s shift: %s alt: %s super: %s self: %s" % (self.key, self.ctrl, self.shift, self.alt, self.super, bool(self))
-
-
-class LayoutCanvas(FigureCanvas):
- layout_changed = pyqtSignal()
- subplot_pressed = pyqtSignal(dict)
- subplot_released = pyqtSignal(dict)
- subplot_motion = pyqtSignal(dict)
- subplot_scrolled = pyqtSignal(dict)
-
- def __init__(self, width=11.7, height=8.3, dpi=100, parent=None):
- self._figure = LayoutFigure(width, height, dpi)
-
- FigureCanvas.__init__(self, self._figure)
- self.setParent(parent)
-
- self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
- self.updateGeometry()
- self.setFocusPolicy(Qt.WheelFocus)
- self.setFocus()
-
- self.mpl_connect('scroll_event', self._mouse_scrolled)
- self.mpl_connect('button_press_event', self._mouse_pressed)
- self.mpl_connect('button_release_event', self._mouse_released)
- self.mpl_connect('motion_notify_event', self._mouse_motion)
- self.mpl_connect('key_press_event', self._key_press_event)
- self.mpl_connect('key_release_event', self._key_release_event)
-
- self._start_x = None
- self._start_y = None
- self._start_subplot_index = None
- self._keys = Keys()
-
- def _create_event(self, event):
- data = {
- "x": event.xdata,
- "y": event.ydata,
- "mx": event.x,
- "my": event.y,
- "dx": None if self._start_x is None else event.xdata - self._start_x,
- "dy": None if self._start_y is None else event.ydata - self._start_y,
- "button": event.button,
- "key": self._keys,
- "step": event.step,
- "subplot_index": self._start_subplot_index or self._figure.index(event.inaxes),
- "gui_event": event.guiEvent
- }
- return data
-
- def _key_press_event(self, event):
- if len(event.key) > 0:
- self._keys.ctrl = 'ctrl' in event.key or 'control' in event.key
- self._keys.shift = 'shift' in event.key
- self._keys.alt = 'alt' in event.key
- self._keys.meta = 'super' in event.key
- keys = event.key.replace('ctrl', '')
- keys = keys.replace('control', '')
- keys = keys.replace('alt', '')
- keys = keys.replace('super', '')
- keys = keys.replace('+', '')
- self._keys.keys = keys
-
- def _key_release_event(self, event):
- # the event is unclear on what key is actually released -> wiping every key :)
- self._keys.keys = None
- self._keys.ctrl = False
- self._keys.alt = False
- self._keys.shift = False
- self._keys.super = False
-
- def _mouse_scrolled(self, event):
- if event.inaxes is not None:
- data = self._create_event(event)
- self.subplot_scrolled.emit(data)
-
- def _mouse_pressed(self, event):
- if event.inaxes is not None:
- data = self._create_event(event)
- self._start_x = data['x']
- self._start_y = data['y']
- self._start_subplot_index = data['subplot_index']
- self.subplot_pressed.emit(data)
-
- def _mouse_released(self, event):
- if event.inaxes is not None:
- self._start_x = None
- self._start_y = None
- self._start_subplot_index = None
- data = self._create_event(event)
- self.subplot_released.emit(data)
-
- def _mouse_motion(self, event):
- if event.inaxes is not None:
- data = self._create_event(event)
- self.subplot_motion.emit(data)
-
- def set_plot_layout(self, layout_spec):
- self._figure.set_plot_layout(layout_spec)
- self.layout_changed.emit()
- self.draw()
-
- def layout_figure(self):
- """ :rtype: LayoutFigure """
- return self._figure
diff --git a/python/segyview/layoutcombo.py b/python/segyview/layoutcombo.py
deleted file mode 100644
index f74f620..0000000
--- a/python/segyview/layoutcombo.py
+++ /dev/null
@@ -1,97 +0,0 @@
-from PyQt4.QtCore import Qt, pyqtSignal, QVariant
-from PyQt4.QtGui import QComboBox, QIcon
-
-from segyview import resource_icon
-
-
-class LayoutCombo(QComboBox):
- layout_changed = pyqtSignal(object)
-
- def __init__(self, parent=None):
- QComboBox.__init__(self, parent)
-
- layouts = [
- # {
- # "icon": "layouts_four_grid.png",
- # "spec": {
- # "dims": (2, 2),
- # "grid": [(0, 0), (0, 1), (1, 0), (1, 1)]
- # }
- # },
- {
- "icon": "layouts_three_bottom_grid.png",
- "spec": {
- "dims": (2, 2),
- "grid": [(0, 0), (0, 1), (1, slice(0, 2))]
- }
- },
- {
- "icon": "layouts_three_top_grid.png",
- "spec": {
- "dims": (2, 2),
- "grid": [(0, slice(0, 2)), (1, 0), (1, 1)]
- }
- },
- {
- "icon": "layouts_two_horizontal_grid.png",
- "spec": {
- "dims": (2, 1),
- "grid": [(0, 0), (1, 0)]
- }
- },
- {
- "icon": "layouts_two_vertical_grid.png",
- "spec": {
- "dims": (1, 2),
- "grid": [(0, 0), (0, 1)]
- }
- },
- {
- "icon": "layouts_three_horizontal_grid.png",
- "spec": {
- "dims": (3, 1),
- "grid": [(0, 0), (1, 0), (2, 0)]
- }
- },
- {
- "icon": "layouts_three_vertical_grid.png",
- "spec": {
- "dims": (1, 3),
- "grid": [(0, 0), (0, 1), (0, 2)]
- }
- },
- {
- "icon": "layouts_single.png",
- "spec": {
- "dims": (1, 1),
- "grid": [(0, 0)]
- }
- }
- ]
-
- for layout in layouts:
- self.add_layout_item(layout)
-
- self.setMinimumHeight(45)
- self.setMinimumWidth(60)
- self.setMaximumWidth(60)
- self.setMaximumHeight(45)
-
- self.currentIndexChanged.connect(self._layout_changed)
-
- def add_layout_item(self, layout_item):
- self.addItem(resource_icon(layout_item['icon']), "", layout_item['spec'])
-
- def _layout_changed(self, index):
- spec = self._get_spec(index)
- self.layout_changed.emit(spec)
-
- def _get_spec(self, index):
- user_data = self.itemData(index)
- """ :type: QVariant"""
- spec = user_data.toPyObject()
- spec = {str(key): value for key, value in spec.items()}
- return spec
-
- def get_current_layout(self):
- return self._get_spec(self.currentIndex())
diff --git a/python/segyview/layoutfigure.py b/python/segyview/layoutfigure.py
deleted file mode 100644
index c81a79f..0000000
--- a/python/segyview/layoutfigure.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from matplotlib import gridspec
-from matplotlib.figure import Figure
-from matplotlib.axes import Axes
-
-
-class LayoutFigure(Figure):
- def __init__(self, width=11.7, height=8.3, dpi=100, tight_layout=True, **kwargs):
- super(LayoutFigure, self).__init__(figsize=(width, height), dpi=dpi, tight_layout=tight_layout, **kwargs)
-
- self._axes = []
- """ :type: list[Axes] """
-
- def set_plot_layout(self, layout_spec):
- grid_spec = gridspec.GridSpec(*layout_spec['dims'])
-
- for axes in self._axes:
- self.delaxes(axes)
-
- self._axes = [self.add_subplot(grid_spec[sub_spec]) for sub_spec in layout_spec['grid']]
-
- def index(self, axes):
- """
- :param axes: The Axes instance to find the index of.
- :type axes: Axes
- :rtype: int
- """
- return self._axes.index(axes)
-
- def layout_axes(self):
- """ :rtype: list[Axes] """
- return list(self._axes)
diff --git a/python/segyview/progresswidget.py b/python/segyview/progresswidget.py
deleted file mode 100644
index 4bf2244..0000000
--- a/python/segyview/progresswidget.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from PyQt4 import QtGui
-
-
-class ProgressWidget(QtGui.QWidget):
-
- def __init__(self, call_on_cancel):
- super(ProgressWidget, self).__init__()
- self.call_on_cancel = call_on_cancel
-
- layout = QtGui.QHBoxLayout()
- # progress bar
- self.p_bar = QtGui.QProgressBar(self)
- cancel_file_load_btn = QtGui.QPushButton()
- cancel_file_load_btn.setText("cancel")
-
- cancel_file_load_btn.clicked.connect(self.call_on_cancel)
-
- layout.addWidget(self.p_bar, 2)
- layout.addWidget(cancel_file_load_btn)
-
- self.setLayout(layout)
-
- def set_value(self, value):
- self.p_bar.setValue(value)
-
diff --git a/python/segyview/segyiowrapper.py b/python/segyview/segyiowrapper.py
deleted file mode 100644
index d564ec5..0000000
--- a/python/segyview/segyiowrapper.py
+++ /dev/null
@@ -1,176 +0,0 @@
-import sys
-import math
-import numpy as np
-import segyio
-import itertools
-
-
-class SlicesWrapper(object):
- """ Simple wrapper either around the Line class (when read_from_file) or a native Numpy array in memory.
- (by. mapping index to line number).
-
- Will signal file read start and finished events through the FileActivityMonitor when file read operations in
- segyio api are used.
- """
-
- def __init__(self, segyiowrapper, indexes, cube, read_from_file=False):
- self.indexes = indexes
- self.cube = cube
- self.swrap = segyiowrapper
- self.read_from_file = read_from_file
-
- def __getitem__(self, item):
-
- if self.read_from_file:
- self.swrap.file_activity_monitor.set_file_read_started()
- slice_from_file = self.cube[item]
- self.swrap.file_activity_monitor.set_file_read_finished()
- return slice_from_file
- else:
- return self.cube[self.indexes.index(item)]
-
- def __len__(self):
- return len(self.indexes)
-
-
-class SegyIOWrapper(object):
- """ Wraps around the functionality offered by the segyio api - and proxies read operations either towards segyio,
- or an in-memory numpy array.
- """
- def __init__(self, segy=None, file_name=None, file_activity_monitor=None):
- self.segy = segy
- self.file_name = file_name
- self.file_activity_monitor = file_activity_monitor
- self.iline_slices, self.xline_slices, self.depth_slices, self._min_max = None, None, None, None
-
- @classmethod
- def wrap(cls, segy, file_activity_monitor=None):
- """
- Wraps an existing segyio instance. Caller is responsible for closing the file.
- :param segy:
- :param file_activity_monitor:
- :return: SegyIOWrapper
- """
- wrapped = cls(segy=segy, file_activity_monitor=file_activity_monitor)
- wrapped._wrap_segyio_slices()
- return wrapped
-
- @classmethod
- def open_file_and_wrap(cls, file_name, file_activity_monitor=None):
- """
- Creates and wrap a segyio instance for a given filename.
- :param file_name:
- :param file_activity_monitor:
- :return: SegyIOWrapper
- """
- wrapped = cls(file_name=file_name, file_activity_monitor=file_activity_monitor)
- wrapped.segy = segyio.open(str(file_name))
- wrapped._wrap_segyio_slices()
-
- return wrapped
-
- def _wrap_segyio_slices(self):
- self.iline_slices = SlicesWrapper(self, self.segy.ilines.tolist(), self.segy.iline, read_from_file=True)
- self.xline_slices = SlicesWrapper(self, self.segy.xlines.tolist(), self.segy.xline, read_from_file=True)
- self.depth_slices = SlicesWrapper(self, range(self.segy.samples), self.segy.depth_slice, read_from_file=True)
- self._min_max = None
-
- def close(self):
- """
- Closing the referenced segy file
- :return:
- """
- if self.segy is not None:
- try:
- self.segy.close()
- except Exception:
- raise
-
- def __del__(self):
- self.close()
-
- def read_all_traces_to_memory(self, progress_callback=None, number_of_read_iterations=100):
- """ Read all traces into memory and identify global min and max values.
-
- Utility method to handle the challenge of navigating up and down in depth slices,
- as each depth slice consist of samples from all traces in the segy file.
-
- The cubes created are transposed in aspect of the iline, xline and depth plane. Where each slice of the
- returned depth cube consists of all samples for the given depth, oriented by [iline, xline]
-
- Returns True if operation was able to run to completion. False if actively cancelled, or disrupted in any
- other way.
- """
-
- all_traces = np.empty(shape=((len(self.segy.ilines) * len(self.segy.xlines)), self.segy.samples), dtype=np.single)
-
- # signal file read start to anyone listening to the monitor
- if self.file_activity_monitor is not None:
- self.file_activity_monitor.set_file_read_started()
-
- step_size = int(math.ceil(float(self.segy.tracecount)/number_of_read_iterations))
-
- # read traces into memory in step_size
- for i, in itertools.izip(range(0, self.segy.tracecount, step_size)):
-
- if self.file_activity_monitor is not None and self.file_activity_monitor.cancelled_operation:
- self.file_activity_monitor.set_file_read_finished()
- return False
-
- all_traces[i: i+step_size] = self.segy.trace.raw[i:i+step_size]
-
- if progress_callback is not None:
- progress_callback((float(i+step_size) / self.segy.tracecount) * 100)
-
- if self.file_activity_monitor is not None:
- self.file_activity_monitor.set_file_read_finished()
-
- ils = all_traces.reshape(len(self.segy.ilines), len(self.segy.xlines), self.segy.samples)
- xls = ils.transpose(1, 0, 2)
-
- self.depth_slices = ils.transpose(2, 0, 1)
-
- self.iline_slices = SlicesWrapper(self, self.segy.ilines.tolist(), ils, read_from_file=False)
- self.xline_slices = SlicesWrapper(self, self.segy.xlines.tolist(), xls, read_from_file=False)
- self._min_max = self.identify_min_max(all_traces)
- return True
-
- @staticmethod
- def identify_min_max(all_traces):
-
- # removing positive and negative infinite numbers
- all_traces[all_traces == np.inf] = 0
- all_traces[all_traces == -np.inf] = 0
-
- min_value = np.nanmin(all_traces)
- max_value = np.nanmax(all_traces)
-
- return min_value, max_value
-
- @property
- def samples(self):
- return self.segy.samples
-
- @property
- def xlines(self):
- return self.segy.xlines.tolist()
-
- @property
- def ilines(self):
- return self.segy.ilines.tolist()
-
- @property
- def iline(self):
- return self.iline_slices
-
- @property
- def xline(self):
- return self.xline_slices
-
- @property
- def depth_slice(self):
- return self.depth_slices
-
- @property
- def min_max(self):
- return self._min_max
diff --git a/python/segyview/segyplot.py b/python/segyview/segyplot.py
deleted file mode 100644
index 348f5c8..0000000
--- a/python/segyview/segyplot.py
+++ /dev/null
@@ -1,146 +0,0 @@
-from matplotlib.ticker import FuncFormatter, MaxNLocator
-import matplotlib.patches as patches
-
-import matplotlib
-
-class SegyPlot(object):
-
- """
- Plots a segy slice and line indicators on the provided axes.
- """
-
- def __init__(self, slices, indexes, axes, cmap='seismic', x_axis_indexes=None, y_axis_indexes=None,
- display_horizontal_indicator=False,
- display_vertical_indicator=False, v_min_max=None):
-
- self.slices = slices
- self.indexes = indexes
- self.cmap = cmap
-
- self.vmin, self.vmax = v_min_max or (None, None)
-
- self.plane_height = len(self.slices[self.indexes[0]][0])
- self.plane_width = len(self.slices[self.indexes[0]][:])
-
- self.x_axis_name, self.x_axis_indexes = x_axis_indexes or (None, None)
- self.y_axis_name, self.y_axis_indexes = y_axis_indexes or (None, None)
-
- self.slice_axes = axes
- self.slice_axes.tick_params(axis='both', labelsize=8)
-
- if self.x_axis_indexes is not None:
- def x_axis_label_formatter(val, position):
- if 0 <= val < len(self.x_axis_indexes):
- return self.x_axis_indexes[int(val)]
- return ''
-
- self.slice_axes.set_xlabel(self.x_axis_name, fontsize=8)
- self.slice_axes.get_xaxis().set_major_formatter(FuncFormatter(x_axis_label_formatter))
- self.slice_axes.get_xaxis().set_major_locator(MaxNLocator(20)) # max 20 ticks are shown
-
- if self.y_axis_indexes is not None:
- def y_axis_label_formatter(val, position):
- if 0 <= val < len(self.y_axis_indexes):
- return self.y_axis_indexes[int(val)]
- return ''
-
- self.slice_axes.set_ylabel(self.y_axis_name, fontsize=8)
- self.slice_axes.get_yaxis().set_major_formatter(FuncFormatter(y_axis_label_formatter))
- self.slice_axes.get_yaxis().set_major_locator(MaxNLocator(10)) # max 20 ticks are shown
-
- self.im = self.slice_axes.imshow(slices[indexes[0]].T,
- interpolation="nearest",
- aspect="auto",
- cmap=self.cmap,
- vmin=self.vmin,
- vmax=self.vmax)
-
-
- if display_vertical_indicator:
- self.vertical_indicator_rect = self.slice_axes.add_patch(
- patches.Rectangle(
- (-0.5, -0.5),
- 1,
- self.plane_height,
- fill=False,
- alpha=1,
- color='black',
- linestyle='dashed',
- linewidth=0.5,
-
- )
- )
-
- if display_horizontal_indicator:
- self.horizontal_indicator_rect = self.slice_axes.add_patch(
- patches.Rectangle(
- (-0.5, -0.5),
- self.plane_width,
- 1,
- fill=False,
- alpha=1,
- color='black',
- linestyle='dashed',
- linewidth=0.5
- )
- )
-
- self.disabled_overlay = self.slice_axes.add_patch(
- patches.Rectangle(
- (-0.5, -0.5), # (x,y)
- len(self.slices[self.indexes[0]][0]),
- len(self.slices[self.indexes[0]][0]),
- alpha=0.5,
- color='gray',
- visible=False
- )
- )
-
- def set_min_max(self, v_min_max):
- self.vmin, self.vmax = v_min_max or (None, None)
- self.im.set_clim(self.vmin,self.vmax)
-
-
-
- def set_colormap(self, cmap):
- self.cmap = cmap
- self.im.set_cmap(cmap)
-
- def update_image(self, index):
- self.im.set_data(self.slices[index].T)
-
- def set_vertical_line_indicator(self, line_index):
- if self.x_axis_indexes is not None:
- self.vertical_indicator_rect.set_x(self.x_axis_indexes.index(line_index) - 0.5)
-
- def set_horizontal_line_indicator(self, line_index):
- if self.y_axis_indexes is not None:
- line_index = self.y_axis_indexes.index(line_index)
- self.horizontal_indicator_rect.set_y(line_index - 0.5)
-
- def enable_overlay(self):
- self.disabled_overlay.set_visible(True)
-
- def disable_overlay(self):
- self.disabled_overlay.set_visible(False)
-
-class ColorBarPlot(object):
- def __init__(self, axes, cmap=None, v_min_max=None):
- self.axes = axes
- self.cmap = cmap
-
- # default to 0,1 when not set
- min, max = v_min_max or (0,1)
-
- norm = matplotlib.colors.Normalize(vmin=min, vmax=max)
- self.colorbar = matplotlib.colorbar.ColorbarBase(self.axes, cmap=cmap, norm=norm)
-
- def set_cmap(self, cmap):
- self.colorbar.set_cmap(str(cmap))
- self.colorbar.draw_all()
-
- def set_min_max(self, min_max):
- min, max = min_max
- self.colorbar.set_clim(min, max)
- self.colorbar.draw_all()
-
diff --git a/python/segyview/slicewidget.py b/python/segyview/slicewidget.py
deleted file mode 100644
index 033821c..0000000
--- a/python/segyview/slicewidget.py
+++ /dev/null
@@ -1,123 +0,0 @@
-from PyQt4 import QtGui, QtCore
-
-from segyplot import SegyPlot, ColorBarPlot
-from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
-from matplotlib.figure import Figure
-
-
-class SliceWidget(QtGui.QWidget):
- """
- Main widget holding the slice matplotlib Figure wrapped in FigureCanvasQTAgg.
- """
- index_changed = QtCore.pyqtSignal(int)
-
- def __init__(self, slices, indexes, dataset_title=None, default_cmap='seismic',
- x_axis_indexes=None, y_axis_indexes=None,
- show_h_indicator=False, show_v_indicator=False, v_min_max=None):
- super(SliceWidget, self).__init__()
-
- self.slices = slices
- self.indexes = indexes
-
- self.x_axis_name, self.x_axis_indexes = x_axis_indexes or (None, None)
- self.y_axis_name, self.y_axis_indexes = y_axis_indexes or (None, None)
-
- self.default_cmap = default_cmap
-
- self.show_h_indicator = show_h_indicator
- self.show_v_indicator = show_v_indicator
-
- self.palette().setColor(self.backgroundRole(), QtCore.Qt.white)
-
- self.current_index = 0
-
- # setting up the figure and canvas
- self.figure = Figure(figsize=(16, 4), dpi=100, facecolor='white')
-
- self.axes = self.figure.add_subplot(111)
-
- self.segy_plot = SegyPlot(self.slices,
- self.indexes,
- self.axes,
- self.default_cmap,
- x_axis_indexes=x_axis_indexes,
- y_axis_indexes=y_axis_indexes,
- display_horizontal_indicator=self.show_h_indicator,
- display_vertical_indicator=self.show_v_indicator,
- v_min_max=v_min_max)
-
- self.figure_canvas = FigureCanvas(self.figure)
- self.figure_canvas.setParent(self)
-
- # connect to mouse click events
- self.figure_canvas.mpl_connect('button_press_event', self._mouse_clicked)
-
- # widget layout
- self.layout = QtGui.QVBoxLayout(self)
- self.layout.addWidget(self.figure_canvas)
-
- def _mouse_clicked(self, evt):
- if evt.inaxes is not None:
- self.current_index = int(evt.xdata)
- self._signal_index_change(self.current_index)
-
- def _signal_index_change(self, x):
- if self.x_axis_indexes is not None:
- self.index_changed.emit(self.x_axis_indexes[x])
-
- def update_image(self, index):
- self.segy_plot.update_image(index)
- self.figure_canvas.draw()
-
- def set_cmap(self, cmap):
- self.segy_plot.set_colormap(str(cmap))
- self.figure_canvas.draw()
-
- def set_min_max(self, min_max):
- self.segy_plot.set_min_max(min_max)
- self.figure_canvas.draw()
-
- def set_vertical_line_indicator(self, line):
- self.segy_plot.set_vertical_line_indicator(line)
- self.figure_canvas.draw()
-
- def set_horizontal_line_indicator(self, line):
- self.segy_plot.set_horizontal_line_indicator(line)
- self.figure_canvas.draw()
-
-
-
-class ColorBarWidget(QtGui.QWidget):
- """
- Widget displaying a colorbar, with the selected min-max range and colormap
- """
- def __init__(self, segyio_wrapper, colormap_monitor=None):
- super(ColorBarWidget, self).__init__()
-
- self.swrap = segyio_wrapper
-
- # setting up the colorbar figure
- self.colormap_monitor = colormap_monitor
- self.figure = Figure(figsize=(1, 3), dpi=50, facecolor='white')
- self.axes = self.figure.add_subplot(111)
- self.cbar_plt = ColorBarPlot(self.axes, cmap='seismic', v_min_max=self.swrap.min_max)
- self.figure_canvas = FigureCanvas(self.figure)
- self.figure_canvas.setParent(self)
-
- # signals
- self.colormap_monitor.cmap_changed.connect(self.set_cmap)
-
- self.colormap_monitor.min_max_changed.connect(self.set_min_max)
-
- self.layout = QtGui.QVBoxLayout(self)
- self.layout.addWidget(self.figure_canvas)
-
-
- def set_cmap(self,value):
- self.cbar_plt.set_cmap(str(value))
- self.figure_canvas.draw()
-
- def set_min_max(self, min_max):
- self.cbar_plt.set_min_max(min_max)
- self.figure_canvas.draw()
-
diff --git a/python/segyview/viewer.py b/python/segyview/viewer.py
deleted file mode 100644
index 1218530..0000000
--- a/python/segyview/viewer.py
+++ /dev/null
@@ -1,189 +0,0 @@
-from segyview import SegyIOWrapper, SliceWidget
-from PyQt4 import QtGui, QtCore
-
-
-class LineSelectionMonitor(QtCore.QObject):
- iline_changed = QtCore.pyqtSignal(int)
- xline_changed = QtCore.pyqtSignal(int)
- depth_changed = QtCore.pyqtSignal(int)
-
- def __init__(self, parent):
- QtCore.QObject.__init__(self, parent)
-
- def iline_updated(self, new_index):
- self.iline_changed.emit(new_index)
-
- def xline_updated(self, new_index):
- self.xline_changed.emit(new_index)
-
- def depth_updated(self, new_index):
- self.depth_changed.emit(new_index)
-
-
-class SliceViewMonitor(QtCore.QObject):
- cmap_changed = QtCore.pyqtSignal(str)
- min_max_changed = QtCore.pyqtSignal(object)
-
- def __init__(self, parent=None):
- QtCore.QObject.__init__(self, parent)
-
- def colormap_updated(self, value):
- self.cmap_changed.emit(str(value))
-
- def min_max_updated(self, values):
- self.min_max_changed.emit(tuple(map(float, values)))
-
-
-class FileActivityMonitor(QtCore.QObject):
- started = QtCore.pyqtSignal()
- finished = QtCore.pyqtSignal()
- cancelled_operation = False
-
- def __init__(self, parent=None):
- QtCore.QObject.__init__(self, parent)
- self.cancelled_operation = False
-
- def reset(self):
- self.cancelled_operation = False
-
- def set_file_read_started(self):
- self.started.emit()
-
- def set_file_read_finished(self):
- self.finished.emit()
-
- def set_cancel_operation(self):
- self.finished.emit()
- self.cancelled_operation = True
-
-
-class FileLoaderWorker(QtCore.QObject):
- finished = QtCore.pyqtSignal(int)
- progress = QtCore.pyqtSignal(int)
-
- def __init__(self, segyio_wrapper):
- QtCore.QObject.__init__(self)
- self.segyio_wrapper = segyio_wrapper
-
- def load_file(self):
-
- if self.segyio_wrapper.read_all_traces_to_memory(progress_callback=self.progress.emit):
- self.finished.emit(0)
- else:
- self.finished.emit(1)
-
- return None
-
-
-class View(object):
- """ A container for a standalone pre defined three-slices view, wrapped in a single QWidget. Plus monitor instances
- for qt-signaling GUI events either from or to the slice viewers.
-
- The widget, and monitors are provided through the class properties.
- """
-
- def __init__(self, segy, read_file_to_memory=False):
-
- self.segy = segy
-
- self._file_activity_monitor = FileActivityMonitor()
-
- self._swrap = SegyIOWrapper.wrap(segy, self.file_activity_monitor)
-
- if read_file_to_memory:
- self._swrap.read_all_traces_to_memory()
-
- self._main_widget = QtGui.QWidget()
- self._line_selection_monitor = LineSelectionMonitor(self._main_widget)
- self._sliceview_monitor = SliceViewMonitor(self._main_widget)
-
- x_slice_widget, i_slice_widget, depth_slice_widget = initialize_slice_widgets(self._swrap,
- self._line_selection_monitor,
- self._sliceview_monitor)
- # layout for the single parent widget
- top_row = QtGui.QHBoxLayout()
- top_row.addWidget(x_slice_widget, 0)
- top_row.addWidget(depth_slice_widget, 0)
-
- bottom_row = QtGui.QHBoxLayout()
- bottom_row.addWidget(i_slice_widget)
-
- layout = QtGui.QVBoxLayout()
- layout.addLayout(top_row)
- layout.addLayout(bottom_row)
-
-
- self._main_widget.setLayout(layout)
-
- @property
- def main_widget(self):
- return self._main_widget
-
- @property
- def line_selection_monitor(self):
- return self._line_selection_monitor
-
- @property
- def colormap_monitor(self):
- return self._sliceview_monitor
-
- @property
- def file_activity_monitor(self):
- return self._file_activity_monitor
-
-
-def initialize_slice_widgets(segyio_wrapper, line_selection_monitor, sliceview_monitor):
- """
- Given a segio_wrapper, and signal monitors, sliceviewer widgets for all three slices in a segy-cube are created.
- :param segyio_wrapper:
- :param line_selection_monitor:
- :param sliceview_monitor:
- :return: three QWidgets for the three segy slices, in x, i and depth slice order.
- """
-
- # initialize slice widgets
- x_slice_widget = SliceWidget(segyio_wrapper.xline, segyio_wrapper.xlines,
- x_axis_indexes=('i-lines', segyio_wrapper.ilines),
- y_axis_indexes=('depth', range(segyio_wrapper.samples)),
- show_v_indicator=True,
- v_min_max=segyio_wrapper.min_max)
-
- i_slice_widget = SliceWidget(segyio_wrapper.iline, segyio_wrapper.ilines,
- x_axis_indexes=('x-lines', segyio_wrapper.xlines),
- y_axis_indexes=('depth', range(segyio_wrapper.samples)),
- show_v_indicator=True,
- v_min_max=segyio_wrapper.min_max)
-
- depth_slice_widget = SliceWidget(segyio_wrapper.depth_slice, range(segyio_wrapper.samples),
- x_axis_indexes=('i-lines', segyio_wrapper.ilines),
- y_axis_indexes=('x-lines', segyio_wrapper.xlines),
- show_v_indicator=True,
- show_h_indicator=True,
- v_min_max=segyio_wrapper.min_max)
-
- # attach line-index change signals
- x_slice_widget.index_changed.connect(line_selection_monitor.iline_updated)
- i_slice_widget.index_changed.connect(line_selection_monitor.xline_updated)
-
- line_selection_monitor.iline_changed.connect(x_slice_widget.set_vertical_line_indicator)
- line_selection_monitor.iline_changed.connect(depth_slice_widget.set_vertical_line_indicator)
- line_selection_monitor.iline_changed.connect(i_slice_widget.update_image)
-
- line_selection_monitor.xline_changed.connect(i_slice_widget.set_vertical_line_indicator)
- line_selection_monitor.xline_changed.connect(depth_slice_widget.set_horizontal_line_indicator)
- line_selection_monitor.xline_changed.connect(x_slice_widget.update_image)
-
- line_selection_monitor.depth_changed.connect(depth_slice_widget.update_image)
-
- # colormap signals
- sliceview_monitor.cmap_changed.connect(x_slice_widget.set_cmap)
- sliceview_monitor.cmap_changed.connect(i_slice_widget.set_cmap)
- sliceview_monitor.cmap_changed.connect(depth_slice_widget.set_cmap)
-
- # setting min max thresholds
- sliceview_monitor.min_max_changed.connect(x_slice_widget.set_min_max)
- sliceview_monitor.min_max_changed.connect(i_slice_widget.set_min_max)
- sliceview_monitor.min_max_changed.connect(depth_slice_widget.set_min_max)
-
- return x_slice_widget, i_slice_widget, depth_slice_widget
-
diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt
deleted file mode 100644
index 58720c2..0000000
--- a/resources/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_subdirectory(img)
diff --git a/resources/img/CMakeLists.txt b/resources/img/CMakeLists.txt
deleted file mode 100644
index 1866304..0000000
--- a/resources/img/CMakeLists.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-set(RESOURCES
- layouts_four_grid.png
- layouts_single.png
- layouts_three_bottom_grid.png
- layouts_three_horizontal_grid.png
- layouts_three_top_grid.png
- layouts_three_vertical_grid.png
- layouts_two_horizontal_grid.png
- layouts_two_vertical_grid.png
-)
-
-add_custom_target(install_resources ALL)
-
-foreach (file ${RESOURCES})
- add_custom_command(TARGET install_resources
- COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/resources
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${file} ${CMAKE_BINARY_DIR}/resources/img
- )
-endforeach ()
-get_target_property(INSTALL_PATH package_segyview PACKAGE_INSTALL_PATH)
-install(FILES ${RESOURCES} DESTINATION ${INSTALL_PATH}/resources/img)
diff --git a/resources/img/layouts_four_grid.png b/resources/img/layouts_four_grid.png
deleted file mode 100755
index 2473593..0000000
Binary files a/resources/img/layouts_four_grid.png and /dev/null differ
diff --git a/resources/img/layouts_single.png b/resources/img/layouts_single.png
deleted file mode 100755
index 3b7eff2..0000000
Binary files a/resources/img/layouts_single.png and /dev/null differ
diff --git a/resources/img/layouts_three_bottom_grid.png b/resources/img/layouts_three_bottom_grid.png
deleted file mode 100644
index 99568e3..0000000
Binary files a/resources/img/layouts_three_bottom_grid.png and /dev/null differ
diff --git a/resources/img/layouts_three_horizontal_grid.png b/resources/img/layouts_three_horizontal_grid.png
deleted file mode 100644
index da39ea4..0000000
Binary files a/resources/img/layouts_three_horizontal_grid.png and /dev/null differ
diff --git a/resources/img/layouts_three_top_grid.png b/resources/img/layouts_three_top_grid.png
deleted file mode 100644
index bf67b0f..0000000
Binary files a/resources/img/layouts_three_top_grid.png and /dev/null differ
diff --git a/resources/img/layouts_three_vertical_grid.png b/resources/img/layouts_three_vertical_grid.png
deleted file mode 100755
index 412b49f..0000000
Binary files a/resources/img/layouts_three_vertical_grid.png and /dev/null differ
diff --git a/resources/img/layouts_two_horizontal_grid.png b/resources/img/layouts_two_horizontal_grid.png
deleted file mode 100644
index ded8588..0000000
Binary files a/resources/img/layouts_two_horizontal_grid.png and /dev/null differ
diff --git a/resources/img/layouts_two_vertical_grid.png b/resources/img/layouts_two_vertical_grid.png
deleted file mode 100644
index c83b880..0000000
Binary files a/resources/img/layouts_two_vertical_grid.png and /dev/null differ
diff --git a/resources/img/readme.txt b/resources/img/readme.txt
deleted file mode 100644
index e699b19..0000000
--- a/resources/img/readme.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-Free FatCow-Farm Fresh Icons
-http://www.fatcow.com/free-icons
-
-These icons are licensed under a Creative Commons Attribution 3.0 License.
-http://creativecommons.org/licenses/by/3.0/us/ if you do not know how to link
-back to FatCow's website, you can ask https://plus.google.com/+MarcisGasuns
-Biggest icon set drawn by a single designer (in pixel smooth style) worldwide.
\ No newline at end of file
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 05a9c88..37d7aa3 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -19,5 +19,4 @@ if(BUILD_PYTHON)
add_python_test(python.segy test_segy.py)
add_python_test(python.h.segy test_segyio_c.py)
add_python_test(python.enum.segy test_enum.py)
- add_python_test(python.segyview test_segyview.py)
endif()
diff --git a/tests/test_segyview.py b/tests/test_segyview.py
deleted file mode 100644
index a14f19c..0000000
--- a/tests/test_segyview.py
+++ /dev/null
@@ -1,25 +0,0 @@
-import os
-from unittest import TestCase
-import segyio
-from segyview import SegyIOWrapper, resource_icon_path
-import itertools
-
-
-class TestSegyView(TestCase):
- def setUp(self):
- self.filename = "test-data/small.sgy"
-
- def test_resources(self):
- path = resource_icon_path("layouts_single.png")
- print(path)
- self.assertTrue(os.path.exists(path))
-
- def test_read_all_traces_to_memory_compare_with_depth_slice_and_verify_cube_rotation(self):
- with segyio.open(self.filename, "r") as segy:
- swrap = SegyIOWrapper.wrap(segy)
- swrap.read_all_traces_to_memory()
- for i, depth_slice in enumerate(swrap.depth_slices):
- for ilno, xlno in itertools.product(range(len(segy.ilines)), range(len(segy.xlines))):
- self.assertEqual(depth_slice[ilno, xlno], segy.depth_slice[i][ilno, xlno],
- "the cube values from read_all_traces and depth_slice differ {0} != {1}"
- .format(depth_slice[ilno, xlno], segy.depth_slice[i][ilno, xlno]))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/segyio.git
More information about the debian-science-commits
mailing list