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

Commit

Permalink
adds min and max config for continuous and instantaneous plots (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmora authored and Hugo Mercier committed Jan 21, 2020
1 parent 62ee876 commit 7d40f1f
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 53 deletions.
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def add_plot_config(self, config_type, plot_config):
self.__log_plots if config_type == "log_measures" else
self.__timeseries if config_type == "timeseries" else None)

plots.append(plot_config)
plots.append(plot_config.get_dict())

if config_type not in self.__config:
self.__config[config_type] = []
Expand Down
8 changes: 6 additions & 2 deletions config_create_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def config(self):
"interval_column": self._interval_column.currentText(),
"values_column": self._value_continuous_column.currentText(),
"uom": self._uom_continuous.text(),
"type": "continuous"
"type": "continuous",
"min": self._continuous_min.text() if self._continuous_min.isEnabled() else None,
"max": self._continuous_max.text() if self._continuous_max.isEnabled() else None
}

# log measure instantaneous
Expand All @@ -73,7 +75,9 @@ def config(self):
"event_column": self._event_column.currentText(),
"value_column": self._value_instantaneous_column.currentText(),
"uom": self._uom_instantaneous.text(),
"type": "instantaneous"
"type": "instantaneous",
"min": self._instantaneous_min.text() if self._instantaneous_min.isEnabled() else None,
"max": self._instantaneous_max.text() if self._instantaneous_max.isEnabled() else None
}

config["source"] = self._source.itemData(self._source.currentIndex()).id()
Expand Down
136 changes: 100 additions & 36 deletions config_create_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,38 @@
<item row="3" column="1">
<widget class="QComboBox" name="_value_continuous_column"/>
</item>
<item row="4" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="_continuous_min_chk">
<property name="text">
<string>Min value</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="_continuous_min">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_continuous_max_chk">
<property name="text">
<string>Max value</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="_continuous_max">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
Expand Down Expand Up @@ -233,44 +265,44 @@
<item row="0" column="1">
<widget class="QLineEdit" name="_uom_instantaneous"/>
</item>
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="_instantaneous_min_chk">
<property name="text">
<string>Min value</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="_instantaneous_min">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_instantaneous_max_chk">
<property name="text">
<string>Max value</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="_instantaneous_max">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</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 @@ -318,9 +350,9 @@
</hints>
</connection>
<connection>
<sender>minCheckBox</sender>
<sender>_continuous_min_chk</sender>
<signal>toggled(bool)</signal>
<receiver>minEdit</receiver>
<receiver>_continuous_min</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
Expand All @@ -334,9 +366,9 @@
</hints>
</connection>
<connection>
<sender>maxCheckBox</sender>
<sender>_continuous_max_chk</sender>
<signal>toggled(bool)</signal>
<receiver>maxEdit</receiver>
<receiver>_continuous_max</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
Expand All @@ -349,5 +381,37 @@
</hint>
</hints>
</connection>
<connection>
<sender>_instantaneous_min_chk</sender>
<signal>toggled(bool)</signal>
<receiver>_instantaneous_min</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>61</x>
<y>265</y>
</hint>
<hint type="destinationlabel">
<x>213</x>
<y>266</y>
</hint>
</hints>
</connection>
<connection>
<sender>_instantaneous_max_chk</sender>
<signal>toggled(bool)</signal>
<receiver>_instantaneous_max</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>366</x>
<y>265</y>
</hint>
<hint type="destinationlabel">
<x>519</x>
<y>266</y>
</hint>
</hints>
</connection>
</connections>
</ui>
2 changes: 1 addition & 1 deletion data_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def __load_feature(self, feature):
self.__viewer.add_data_column(data, title, uom,
station_name=feature_name)
if hasattr(self.__viewer, "add_data_row"):
self.__viewer.add_data_row(data, title, uom, station_name=feature_name)
self.__viewer.add_data_row(data, title, uom, station_name=feature_name, config=cfg)
elif cfg["type"] == "image":
self.__viewer.add_imagery_from_db(cfg, feature_id)

Expand Down
6 changes: 3 additions & 3 deletions main_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def load_plots(feature, config, add_function, config_list):
if data.get_x_min() is not None:
min_x.append(data.get_x_min())
max_x.append(data.get_x_max())
add_function(data, title, uom, station_name=feature_name)
add_function(data, title, uom, station_name=feature_name, config=cfg)
if not min_x:
return None, None
else:
Expand All @@ -81,9 +81,9 @@ def load_plots(feature, config, add_function, config_list):
class WellLogViewWrapper(WellLogView):
def __init__(self, config, iface):
WellLogView.__init__(self)
self.__config = config
self.__iface = iface
self.__features = []
self.__config = config

image_dir = os.path.join(os.path.dirname(__file__), "qgeologis", "img")
self.__action_add_configuration = QAction(QIcon(os.path.join(image_dir, "new_plot.svg")),
Expand Down Expand Up @@ -141,7 +141,7 @@ def __load_feature(self, feature):

def on_add_column(self):

if not self.__features:
if not self.__features and self.__iface:
self.__iface.messageBar().pushWarning(
"QGeoloGIS",
u"Impossible to add plot without selecting a feature")
Expand Down
13 changes: 8 additions & 5 deletions qgeologis/log_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def on_plot_tooltip(self, txt, station_name = None):
else:
self.__status_bar.showMessage(txt)

def add_data_column(self, data, title, uom, station_name = None):
def add_data_column(self, data, title, uom, station_name = None, config = None):
plot_item = PlotItem(size=QSizeF(self.DEFAULT_COLUMN_WIDTH, self.__log_scene.height()),
render_type = POLYGON_RENDERER,
x_orientation = ORIENTATION_DOWNWARD,
Expand All @@ -303,14 +303,14 @@ def add_data_column(self, data, title, uom, station_name = None):
plot_item.tooltipRequested.connect(lambda txt: self.on_plot_tooltip(txt, station_name))

legend_item = LegendItem(self.DEFAULT_COLUMN_WIDTH, title, unit_of_measure=uom)
data.data_modified.connect(lambda data=data : self._update_data_column(data))
data.data_modified.connect(lambda data=data : self._update_data_column(data, config))

self.__data2logitems[data] = (plot_item, legend_item)
self._add_column(plot_item, legend_item)
self._update_data_column(data)
self._update_data_column(data, config)
self._update_column_depths()

def _update_data_column(self, data):
def _update_data_column(self, data, config):

plot_item, legend_item = self.__data2logitems[data]

Expand All @@ -324,7 +324,10 @@ def _update_data_column(self, data):
win = plot_item.data_window()
min_x, min_y, max_x, max_y = win.left(), win.top(), win.right(), win.bottom()

# TODO configured min_y max_y here
if config and 'min' in config.get_dict() and config['min'] is not None:
min_y = float(config['min'])
if config and 'max' in config.get_dict() and config['max'] is not None:
max_y = float(config['max'])

# legend
legend_item.set_scale(min_y, max_y)
Expand Down
13 changes: 8 additions & 5 deletions qgeologis/timeseries_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def on_plot_tooltip(self, station_name, txt):
else:
self.__status_bar.showMessage(txt)

def add_data_row(self, data, title, uom, station_name = None):
def add_data_row(self, data, title, uom, station_name = None, config=None):
plot_item = PlotItem(size=QSizeF(self.__scene.width(), self.DEFAULT_ROW_HEIGHT),
render_type = POINT_RENDERER,
x_orientation = ORIENTATION_LEFT_TO_RIGHT,
Expand All @@ -277,7 +277,7 @@ def add_data_row(self, data, title, uom, station_name = None):
plot_item.tooltipRequested.connect(lambda txt:self.on_plot_tooltip(station_name, txt))

legend_item = LegendItem(self.DEFAULT_ROW_HEIGHT, title, unit_of_measure=uom, is_vertical=True)
data.data_modified.connect(lambda data=data : self._update_data_row(data))
data.data_modified.connect(lambda data=data : self._update_data_row(data, config))

# center on new data
self._min_x, self._max_x = data.get_x_min(), data.get_x_max()
Expand All @@ -288,15 +288,15 @@ def add_data_row(self, data, title, uom, station_name = None):

self.__data2logitems[data] = (plot_item, legend_item)
self._add_row(plot_item, legend_item)
self._update_data_row(data)
self._update_data_row(data, config)
self._update_row_depths()

def add_time_scale(self, title="Time"):
scale_item = TimeScaleItem(self.__scene.width(), self.DEFAULT_ROW_HEIGHT * 3 / 4, self._min_x, self._max_x)
legend_item = LegendItem(self.DEFAULT_ROW_HEIGHT * 3 / 4, title, is_vertical = True)
self._add_row(scale_item, legend_item)

def _update_data_row(self, data):
def _update_data_row(self, data, config):

plot_item, legend_item = self.__data2logitems[data]

Expand All @@ -310,7 +310,10 @@ def _update_data_row(self, data):
win = plot_item.data_window()
min_x, min_y, max_x, max_y = win.left(), win.top(), win.right(), win.bottom()

# TODO configured min_y max_y here
if config and 'min' in config.get_dict() and config['min'] is not None:
min_y = float(config['min'])
if config and 'max' in config.get_dict() and config['max'] is not None:
max_y = float(config['max'])

# legend
legend_item.set_scale(min_y, max_y)
Expand Down

0 comments on commit 7d40f1f

Please sign in to comment.