Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Commit

Permalink
wip adds min and max config (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmora authored and Hugo Mercier committed Jan 20, 2020
1 parent e71df0a commit 62ee876
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 18 deletions.
68 changes: 66 additions & 2 deletions config_create_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>561</width>
<height>375</height>
<width>643</width>
<height>539</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -239,6 +239,38 @@
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="minCheckBox">
<property name="text">
<string>Min value</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="minEdit">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="maxCheckBox">
<property name="text">
<string>Max value</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="maxEdit">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
Expand Down Expand Up @@ -285,5 +317,37 @@
</hint>
</hints>
</connection>
<connection>
<sender>minCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>minEdit</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>51</x>
<y>481</y>
</hint>
<hint type="destinationlabel">
<x>208</x>
<y>482</y>
</hint>
</hints>
</connection>
<connection>
<sender>maxCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>maxEdit</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>366</x>
<y>481</y>
</hint>
<hint type="destinationlabel">
<x>524</x>
<y>482</y>
</hint>
</hints>
</connection>
</connections>
</ui>
4 changes: 2 additions & 2 deletions main_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import os

from qgis.PyQt.QtWidgets import QDialog, QAction, QVBoxLayout
from qgis.PyQt.QtWidgets import QDialog, QAction, QVBoxLayout, QWidget
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtCore import QSize
from qgis.core import QgsProject, QgsFeatureRequest
Expand Down Expand Up @@ -216,7 +216,7 @@ def on_add_row(self):
s.exec_()


class MainDialog(QDialog):
class MainDialog(QWidget):

def __init__(self, parent, plot_type, config, layer, iface):
"""Create a plot dialog that updates when a layer selection updates.
Expand Down
12 changes: 6 additions & 6 deletions qgeologis/log_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# License along with this library; if not, see <http://www.gnu.org/licenses/>.
#

from qgis.PyQt.QtCore import Qt, QSizeF
from qgis.PyQt.QtCore import Qt, QSizeF, QRectF
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtWidgets import (QGraphicsView, QGraphicsScene, QWidget, QToolBar, QAction, QLabel,
QVBoxLayout)
Expand Down Expand Up @@ -321,14 +321,14 @@ def _update_data_column(self, data):
return

plot_item.set_data(data.get_x_values(), data.get_y_values())
win = plot_item.data_window()
min_x, min_y, max_x, max_y = win.left(), win.top(), win.right(), win.bottom()

# r = QRectF(0, min_y, (max_x-min_x)/delta, max_y)
# plot_item.set_data_window(r)
# TODO configured min_y max_y here

# legend
min_str = "{:.1f}".format(min(data.get_y_values()) if data.get_y_values() else 0)
max_str = "{:.1f}".format(max(data.get_y_values()) if data.get_y_values() else 0)
legend_item.set_scale(min_str, max_str)
legend_item.set_scale(min_y, max_y)
plot_item.set_data_window(QRectF(min_x, min_y, max_x-min_x, max_y-min_y))

self.__log_scene.update()

Expand Down
8 changes: 5 additions & 3 deletions qgeologis/timeseries_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,14 @@ def _update_data_row(self, data):
return

plot_item.set_data(data.get_x_values(), data.get_y_values())
win = plot_item.data_window()
min_x, min_y, max_x, max_y = win.left(), win.top(), win.right(), win.bottom()

#r = QRectF(0, min_y, (max_x-min_x)/delta, max_y)
#plot_item.set_data_window(r)
# TODO configured min_y max_y here

# legend
legend_item.set_scale(data.get_y_min(), data.get_y_max())
legend_item.set_scale(min_y, max_y)
plot_item.set_data_window(QRectF(min_x, min_y, max_x-min_x, max_y-min_y))

self.__scene.update()

Expand Down
14 changes: 9 additions & 5 deletions qgis_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from qgis.PyQt.QtCore import Qt, pyqtSignal
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtWidgets import QAction, QWidget
from qgis.PyQt.QtWidgets import QAction, QWidget, QDockWidget

from qgis.core import (QgsPoint, QgsCoordinateTransform, QgsRectangle,
QgsGeometry, QgsFeatureRequest, QgsProject)
Expand Down Expand Up @@ -92,7 +92,7 @@ def __init__(self, iface):
self.__tool = None

# Root widget, to attach children to
self.__widget = QWidget()
self.__dock = None

def initGui(self):

Expand Down Expand Up @@ -137,8 +137,10 @@ def on_view_plots(self, plot_type):
else:
return

dialog = MainDialog(self.__widget, plot_type, self.__config, layer, self.iface)
dialog.show()
self.__dock = QDockWidget("Well Log")
dialog = MainDialog(self.__dock, plot_type, self.__config, layer, self.iface)
self.__dock.setWidget(dialog)
self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.__dock)

def unload(self):

Expand All @@ -147,7 +149,9 @@ def unload(self):

self.__tool = None
self.__config = None
self.__widget = None
if self.__dock:
self.iface.removeDockWidget(self.__dock)
self.__dock.setParent(None)

self.iface.removeToolBarIcon(self.view_logs)
self.iface.removeToolBarIcon(self.view_timeseries)
Expand Down

0 comments on commit 62ee876

Please sign in to comment.