@@ -39,8 +39,6 @@ def __init__(self):
3939 self .help_browser .setHtml (abouthtml )
4040
4141class 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
0 commit comments