Skip to content

Commit e1b3e01

Browse files
committed
Merge pull request #28 from sergiobuj/fix_ui
Fix ui branch
2 parents 3150d35 + 6e17dac commit e1b3e01

5 files changed

Lines changed: 152 additions & 62 deletions

File tree

clusterpy_lightdialog.py

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ def __init__(self):
3939
self.help_browser.setHtml(abouthtml)
4040

4141
class maxpDialog(QtGui.QDialog, Ui_maxp_ui):
42-
ERROR_MSG = u"There are features from the shapefile that are disconnected. \
43-
Check the following areas for errors in the geometry: "
4442
DONE_MSG = "Finish"
4543

4644
def __init__(self):
@@ -108,48 +106,60 @@ def addToCanvas(self):
108106
addShapeToCanvas(self.layer_path.text())
109107

110108
def accept(self):
111-
layerindex = self.layer_combo.currentIndex()
112-
if layerindex < 0:
113-
return
114-
layer = self.mc.layer(layerindex)
115-
info = {
116-
'attrname' : self.attribute_combo.currentText(),
117-
'thresholdattr' : self.threshold_attr_combo.currentText(),
118-
'threshold' : self.threshold_spin.value(),
119-
'maxit' : self.maxit_spin.value(),
120-
'tabumax' : self.tabumax_spin.value(),
121-
'tabusize' : self.tabulength_spin.value(),
122-
'output_path' : self.layer_path.text(),
123-
'layer' : layer
124-
}
125-
worker = workers.MaxPWorker(info)
126-
thread = QtCore.QThread(self)
127-
worker.moveToThread(thread)
128-
worker.finished.connect(self.finishRun)
129-
worker.progress.connect(self.updateProgress)
130-
thread.started.connect(worker.run)
131-
self.thread = thread
132-
self.worker = worker
133-
thread.start()
109+
if self.layer_path.text() == "":
110+
QtGui.QMessageBox.warning(self,
111+
"Clusterpy",
112+
"Please specify output shapefile")
113+
else:
114+
self.okbutton = self.buttonBox.button( QtGui.QDialogButtonBox.Ok )
115+
self.okbutton.setEnabled(False)
116+
layerindex = self.layer_combo.currentIndex()
117+
if layerindex < 0:
118+
return
119+
layer = self.mc.layer(layerindex)
120+
info = {
121+
'attrname' : self.attribute_combo.currentText(),
122+
'thresholdattr' : self.threshold_attr_combo.currentText(),
123+
'threshold' : self.threshold_spin.value(),
124+
'maxit' : self.maxit_spin.value(),
125+
'tabumax' : self.tabumax_spin.value(),
126+
'tabusize' : self.tabulength_spin.value(),
127+
'output_path' : self.layer_path.text(),
128+
'layer' : layer
129+
}
130+
worker = workers.MaxPWorker(info)
131+
thread = QtCore.QThread(self)
132+
worker.moveToThread(thread)
133+
worker.finished.connect(self.finishRun)
134+
worker.progress.connect(self.updateProgress)
135+
thread.started.connect(worker.run)
136+
self.thread = thread
137+
self.worker = worker
138+
thread.start()
134139

135140
def finishRun(self, success, outputmsg):
136141
self.worker.deleteLater()
137142
self.thread.quit()
138143
self.thread.wait()
139144
self.thread.deleteLater()
145+
self.okbutton.setEnabled(True)
140146
if success:
141147
self.addToCanvas()
142-
self.showMessage("Clusterpy", "Success. File:" + outputmsg )
148+
self.showMessage("Clusterpy", "Success. File:" + outputmsg,
149+
duration=10 )
143150
else:
144-
self.showMessage("Clusterpy: Error",
151+
self.showMessage("Clusterpy Error",
145152
outputmsg,
146153
level=QgsMessageBar.CRITICAL)
154+
self.layer_path.clear()
155+
self.add_canvas.setChecked(Qt.Unchecked)
156+
self.updateProgress(0)
147157

148158
def updateProgress(self, value):
149159
self.progressBar.setValue(value)
150160

151161
def showMessage(self, msgtype, msgtext, level=QgsMessageBar.INFO,
152-
duration=5):
162+
duration=30):
153163
messagebar = self.iface.messageBar()
154164
messagebar.pushMessage(msgtype, msgtext, level=level, duration=duration)
155165

uifiles/about.html

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,40 @@ <h2>Research in Spatial Economics</h2>
66
their georeferenced data. Our methodologies are characterized by their
77
multidisciplinarity, involving research domains such as operation research,
88
econometrics and exploratory spatial data analysis.</p>
9-
Contact us: <a href="mailto:contacto@rise-group.org">contacto@rise-group.org </a>
9+
<h3>Cite the Plugin</h3>
10+
If you are interested in citing this plugin, you can use:
11+
<p>
12+
Duque, J.C.; Botero, Sergio (2014). Clusterpy QGIS plugin, Version 1.0 RiSE-group (Research in Spatial Economics). EAFIT University. http://www.rise-group.org.
13+
</p>
14+
Or this BibTeX entry:
15+
<pre><code>
16+
@Manual{clusterpy-qgis-plugin,
17+
title = {Clusterpy QGIS plugin,
18+
{Version} 1.0.0},
19+
author = {Duque, Juan C. and Botero, Sergio},
20+
organization = {RiSE-group (Research in Spatial Economics). EAFIT University.},
21+
address = {Colombia},
22+
year = {2014},
23+
url = {http://www.rise-group.org}
24+
}
25+
</code></pre>
26+
<h3>Development team</h3>
27+
<ul>
28+
<li>
29+
<a href='http://www.rise-group.org/section/People/Member/juancduque/'>Juan C. Duque</a>
30+
</li>
31+
<li>
32+
<a href='http://www.rise-group.org/section/People/Member/sergiobuj/'>Sergio Botero</a>
33+
<a href='https://github.com/sergiobuj'>(Github)</a>
34+
</li>
35+
</ul>
36+
37+
<h3>About Clusterpy</h3>
38+
<p>This algorithm is part of a set of algorithms that can be found in the
39+
Clusterpy library for Python. <a href='http://www.rise-group.org/section/Software/clusterPy/'>Website</a>.
40+
Also on <a href='https://github.com/sergiobuj/clusterpy'>Github</a></p>
41+
42+
43+
<h3>Contact and website</h3>
44+
<p>visit us: <a href='http://www.rise-group.org/'>rise-group.org</a></p>
45+
<p>email us: <a href="mailto:contacto@rise-group.org">contacto@rise-group.org</a></p>

uifiles/maxphelp.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@ <h2>Parameters</h2>
2929
<li><b>Tabu maximum steps:</b> Number of steps for the Tabu procedure.</li>
3030
<li><b>Tabu List length:</b> Number of times a reverse move is prohibited</li>
3131
</ul>
32+
33+
<h1>About Clusterpy</h1>
34+
<p>This algorithm is part of a set of algorithms that can be found in the
35+
Clusterpy library for Python. <a href='http://www.rise-group.org/section/Software/clusterPy/'>Website</a>.
36+
Also on <a href='https://github.com/sergiobuj/clusterpy'>Github</a></p>
37+

uifiles/ui_maxp.ui

Lines changed: 68 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</size>
2424
</property>
2525
<property name="windowTitle">
26-
<string>clusterpy_light</string>
26+
<string>Clusterpy light: Max-p</string>
2727
</property>
2828
<widget class="QDialogButtonBox" name="buttonBox">
2929
<property name="geometry">
@@ -66,7 +66,7 @@
6666
<x>20</x>
6767
<y>20</y>
6868
<width>331</width>
69-
<height>181</height>
69+
<height>171</height>
7070
</rect>
7171
</property>
7272
<property name="minimumSize">
@@ -145,9 +145,9 @@
145145
<property name="geometry">
146146
<rect>
147147
<x>20</x>
148-
<y>220</y>
148+
<y>270</y>
149149
<width>331</width>
150-
<height>151</height>
150+
<height>111</height>
151151
</rect>
152152
</property>
153153
<property name="minimumSize">
@@ -165,37 +165,26 @@
165165
<x>20</x>
166166
<y>20</y>
167167
<width>291</width>
168-
<height>111</height>
168+
<height>81</height>
169169
</rect>
170170
</property>
171171
<layout class="QFormLayout" name="formLayout">
172+
<property name="fieldGrowthPolicy">
173+
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
174+
</property>
172175
<property name="horizontalSpacing">
173176
<number>12</number>
174177
</property>
175178
<property name="verticalSpacing">
176179
<number>12</number>
177180
</property>
178-
<item row="0" column="0">
179-
<widget class="QLabel" name="label_2">
180-
<property name="text">
181-
<string>Maximum iterations</string>
182-
</property>
183-
</widget>
184-
</item>
185-
<item row="0" column="1">
186-
<widget class="QSpinBox" name="maxit_spin">
181+
<item row="1" column="1">
182+
<widget class="QSpinBox" name="tabumax_spin">
187183
<property name="minimum">
188184
<number>1</number>
189185
</property>
190186
<property name="value">
191-
<number>2</number>
192-
</property>
193-
</widget>
194-
</item>
195-
<item row="1" column="0">
196-
<widget class="QLabel" name="label_3">
197-
<property name="text">
198-
<string>Tabu maximum steps</string>
187+
<number>5</number>
199188
</property>
200189
</widget>
201190
</item>
@@ -206,8 +195,8 @@
206195
</property>
207196
</widget>
208197
</item>
209-
<item row="1" column="1">
210-
<widget class="QSpinBox" name="tabumax_spin">
198+
<item row="2" column="1">
199+
<widget class="QSpinBox" name="tabulength_spin">
211200
<property name="minimum">
212201
<number>1</number>
213202
</property>
@@ -216,13 +205,10 @@
216205
</property>
217206
</widget>
218207
</item>
219-
<item row="2" column="1">
220-
<widget class="QSpinBox" name="tabulength_spin">
221-
<property name="minimum">
222-
<number>1</number>
223-
</property>
224-
<property name="value">
225-
<number>5</number>
208+
<item row="1" column="0">
209+
<widget class="QLabel" name="label_3">
210+
<property name="text">
211+
<string>Tabu maximum steps</string>
226212
</property>
227213
</widget>
228214
</item>
@@ -278,6 +264,57 @@
278264
<string>Add to map canvas</string>
279265
</property>
280266
</widget>
267+
<widget class="QGroupBox" name="groupBox_3">
268+
<property name="geometry">
269+
<rect>
270+
<x>20</x>
271+
<y>200</y>
272+
<width>331</width>
273+
<height>61</height>
274+
</rect>
275+
</property>
276+
<property name="title">
277+
<string>Construction phase parameters</string>
278+
</property>
279+
<widget class="QWidget" name="formLayoutWidget_3">
280+
<property name="geometry">
281+
<rect>
282+
<x>20</x>
283+
<y>20</y>
284+
<width>291</width>
285+
<height>31</height>
286+
</rect>
287+
</property>
288+
<layout class="QFormLayout" name="formLayout_3">
289+
<property name="horizontalSpacing">
290+
<number>12</number>
291+
</property>
292+
<property name="verticalSpacing">
293+
<number>12</number>
294+
</property>
295+
<item row="0" column="0">
296+
<widget class="QLabel" name="label_2">
297+
<property name="text">
298+
<string>Maximum iterations</string>
299+
</property>
300+
</widget>
301+
</item>
302+
<item row="0" column="1">
303+
<widget class="QSpinBox" name="maxit_spin">
304+
<property name="minimum">
305+
<number>1</number>
306+
</property>
307+
<property name="maximum">
308+
<number>99999</number>
309+
</property>
310+
<property name="value">
311+
<number>2</number>
312+
</property>
313+
</widget>
314+
</item>
315+
</layout>
316+
</widget>
317+
</widget>
281318
</widget>
282319
<widget class="QWidget" name="tab_2">
283320
<attribute name="title">

workers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def run(self):
1616

1717
class MaxPWorker(Worker):
1818
ERROR_MSG = u"There are features from the shapefile that are disconnected. \
19-
Check the following areas for errors in the geometry: "
19+
Check the areas identified with the following IDs for errors \
20+
in the geometry: "
2021

2122
def __init__(self, info={}):
2223
super(Worker, self).__init__()
@@ -72,6 +73,6 @@ def run(self):
7273
del newlayer
7374
outputmsg = self.output_path
7475
else:
75-
outputmsg = self.ERROR_MSG + str(islands)
76+
outputmsg = self.ERROR_MSG + str(map(str, islands))
7677
self.progress.emit(100.0)
7778
self.finished.emit(valid, outputmsg)

0 commit comments

Comments
 (0)