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

Commit 56b9692

Browse files
troopa81Hugo Mercier
authored and
Hugo Mercier
committedDec 3, 2019
Add configure plot dialog
1 parent d2f4856 commit 56b9692

5 files changed

+158
-6
lines changed
 

‎config_create_dialog.py

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def __init__(self, parent):
2525
if layer.type() == QgsMapLayer.VectorLayer:
2626
self._source.addItem(layer.name(), layer)
2727

28-
2928
def __on_type_changed(self, index):
3029
self._type_widgets.setCurrentIndex(index)
3130

‎configure_plot_dialog.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# coding=UTF-8
2+
3+
import os
4+
5+
from PyQt5.QtWidgets import QDialog
6+
from PyQt5 import uic
7+
8+
9+
class ConfigurePlotDialog(QDialog):
10+
11+
def __init__(self, layer, parent):
12+
super().__init__(parent)
13+
14+
uic.loadUi(os.path.join(os.path.dirname(__file__),
15+
'configure_plot_dialog.ui'), self)
16+
17+
self._message.setText(self.tr("There is not plot configured for layer '{}'."
18+
"\nDo you want to configure one ?".format(layer.name())))
19+
self.setWindowTitle(self.tr("Configure a plot layer '{}'".format(layer.name())))
20+
21+
self._name.setText(layer.name())
22+
23+
for column_field in [self._id_column, self._name_column]:
24+
column_field.addItems(layer.fields().names())
25+
26+
def config(self):
27+
return {
28+
"layer_name": self._name.text(),
29+
"id_column": self._id_column.currentText(),
30+
"name_column": self._name_column.currentText(),
31+
"stratigraphy_config": [],
32+
"log_measures": [],
33+
"imagery_data": []
34+
}

‎configure_plot_dialog.ui

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>Dialog</class>
4+
<widget class="QDialog" name="Dialog">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>450</width>
10+
<height>177</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Configured a plot for this layer</string>
15+
</property>
16+
<layout class="QVBoxLayout" name="verticalLayout">
17+
<item>
18+
<widget class="QLabel" name="_message">
19+
<property name="text">
20+
<string>There is not plot configured for this layer.
21+
Do you want to configure one ?</string>
22+
</property>
23+
</widget>
24+
</item>
25+
<item>
26+
<layout class="QFormLayout" name="formLayout">
27+
<item row="0" column="0">
28+
<widget class="QLabel" name="label_2">
29+
<property name="text">
30+
<string>Name</string>
31+
</property>
32+
</widget>
33+
</item>
34+
<item row="0" column="1">
35+
<widget class="QLineEdit" name="_name">
36+
<property name="text">
37+
<string>New plot</string>
38+
</property>
39+
</widget>
40+
</item>
41+
<item row="1" column="0">
42+
<widget class="QLabel" name="label_11">
43+
<property name="text">
44+
<string>Id column</string>
45+
</property>
46+
</widget>
47+
</item>
48+
<item row="1" column="1">
49+
<widget class="QComboBox" name="_id_column"/>
50+
</item>
51+
<item row="2" column="0">
52+
<widget class="QLabel" name="label_12">
53+
<property name="text">
54+
<string>Name column</string>
55+
</property>
56+
</widget>
57+
</item>
58+
<item row="2" column="1">
59+
<widget class="QComboBox" name="_name_column"/>
60+
</item>
61+
</layout>
62+
</item>
63+
<item>
64+
<widget class="QDialogButtonBox" name="buttonBox">
65+
<property name="orientation">
66+
<enum>Qt::Horizontal</enum>
67+
</property>
68+
<property name="standardButtons">
69+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
70+
</property>
71+
</widget>
72+
</item>
73+
</layout>
74+
</widget>
75+
<resources/>
76+
<connections>
77+
<connection>
78+
<sender>buttonBox</sender>
79+
<signal>accepted()</signal>
80+
<receiver>Dialog</receiver>
81+
<slot>accept()</slot>
82+
<hints>
83+
<hint type="sourcelabel">
84+
<x>248</x>
85+
<y>254</y>
86+
</hint>
87+
<hint type="destinationlabel">
88+
<x>157</x>
89+
<y>274</y>
90+
</hint>
91+
</hints>
92+
</connection>
93+
<connection>
94+
<sender>buttonBox</sender>
95+
<signal>rejected()</signal>
96+
<receiver>Dialog</receiver>
97+
<slot>reject()</slot>
98+
<hints>
99+
<hint type="sourcelabel">
100+
<x>316</x>
101+
<y>260</y>
102+
</hint>
103+
<hint type="destinationlabel">
104+
<x>286</x>
105+
<y>274</y>
106+
</hint>
107+
</hints>
108+
</connection>
109+
</connections>
110+
</ui>

‎main_dialog.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,11 @@ def __init__(self, config, layer, iface):
222222
def __update_selected_features(self):
223223

224224
self.__well_log_view.setVisible(
225-
len(self.__config.get("stratigraphy_config", []))
226-
+ len(self.__config.get("log_measures", [])))
225+
self.__config.get("stratigraphy_config") is not None
226+
or self.__config.get("log_measures") is not None)
227227

228228
self.__time_series_view.setVisible(
229-
len(self.__config.get("timeseries", [])))
229+
self.__config.get("timeseries") is not None)
230230

231231
if not self.__layer.selectedFeatureCount():
232232
return

‎qgis_plugin.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
QgsGeometry, QgsFeatureRequest, QgsProject)
2727
from qgis.gui import QgsMapTool
2828

29+
from .configure_plot_dialog import ConfigurePlotDialog
2930
from .main_dialog import MainDialog
3031

3132

@@ -118,8 +119,16 @@ def on_view_plot(self):
118119
return
119120

120121
if layer.id() not in self.__config:
121-
self.iface.messageBar().pushInfo("QGeoloGIS", u"There is no plot configured for this layer")
122-
return
122+
dlg = ConfigurePlotDialog(layer, self.iface.mainWindow())
123+
if dlg.exec_():
124+
conf = dlg.config()
125+
self.__config[layer.id()] = conf
126+
127+
json_config = json.dumps(self.__config)
128+
QgsProject.instance().writeEntry("QGeoloGIS", "config", json_config)
129+
130+
else:
131+
return
123132

124133
dialog = MainDialog(self.__config, layer, self.iface)
125134
dialog.show()

0 commit comments

Comments
 (0)
This repository has been archived.