forked from geosim/QAD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qad_rectangle_cmd.py
537 lines (467 loc) · 27.4 KB
/
qad_rectangle_cmd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
# -*- coding: utf-8 -*-
"""
/***************************************************************************
QAD Quantum Aided Design plugin
comando RECTANGLE per disegnare un rettangolo
-------------------
begin : 2013-12-02
copyright : iiiii
email : hhhhh
developers : bbbbb aaaaa ggggg
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
# Import the PyQt and QGIS libraries
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from qad_rectangle_maptool import *
from qad_generic_cmd import QadCommandClass
from qad_msg import QadMsg
from qad_textwindow import *
import qad_utils
import qad_layer
from qad_getdist_cmd import QadGetDistClass
from qad_getangle_cmd import QadGetAngleClass
# Classe che gestisce il comando RECTANGLE
class QadRECTANGLECommandClass(QadCommandClass):
def instantiateNewCmd(self):
""" istanzia un nuovo comando dello stesso tipo """
return QadRECTANGLECommandClass(self.plugIn)
def getName(self):
return QadMsg.translate("Command_list", "RECTANGLE")
def getEnglishName(self):
return "RECTANGLE"
def connectQAction(self, action):
QObject.connect(action, SIGNAL("triggered()"), self.plugIn.runRECTANGLECommand)
def getIcon(self):
return QIcon(":/plugins/qad/icons/rectangle.png")
def getNote(self):
# impostare le note esplicative del comando
return QadMsg.translate("Command_RECTANGLE", "Creates a rectangle.")
def __init__(self, plugIn):
QadCommandClass.__init__(self, plugIn)
# se questo flag = True il comando serve all'interno di un altro comando per disegnare un rettangolo
# che non verrà salvato su un layer
self.virtualCmd = False
self.firstCorner = None
self.gapType = 0 # 0 = Angoli retti; 1 = Raccorda i segmenti; 2 = Cima i segmenti
self.gapValue1 = 0 # se gapType = 1 -> raggio di curvatura; se gapType = 2 -> prima distanza di cimatura
self.gapValue2 = 0 # se gapType = 2 -> seconda distanza di cimatura
self.area = 100
self.dim1 = 10
self.rot = 0
self.vertices = []
self.GetDistClass = None
self.GetAngleClass = None
self.defaultValue = None # usato per gestire il tasto dx del mouse
def __del__(self):
QadCommandClass.__del__(self)
if self.GetDistClass is not None:
del self.GetDistClass
if self.GetAngleClass is not None:
del self.GetAngleClass
def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
# quando si é in fase di richiesta distanza
if self.step == 3 or self.step == 4 or self.step == 5 or \
self.step == 8 or self.step == 9 or self.step == 10 or self.step == 11:
return self.GetDistClass.getPointMapTool()
# quando si é in fase di richiesta rotazione
elif self.step == 13:
return self.GetAngleClass.getPointMapTool()
else:
if (self.plugIn is not None):
if self.PointMapTool is None:
self.PointMapTool = Qad_rectangle_maptool(self.plugIn)
return self.PointMapTool
else:
return None
def addRectangleToLayer(self, layer):
if layer.geometryType() == QGis.Line:
qad_layer.addLineToLayer(self.plugIn, layer, self.vertices)
elif layer.geometryType() == QGis.Polygon:
qad_layer.addPolygonToLayer(self.plugIn, layer, self.vertices)
#============================================================================
# WaitForFirstCorner
#============================================================================
def WaitForFirstCorner(self):
self.step = 1
self.getPointMapTool().setMode(Qad_rectangle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_CORNER)
keyWords = QadMsg.translate("Command_RECTANGLE", "Chamfer") + "/" + \
QadMsg.translate("Command_RECTANGLE", "Fillet")
prompt = QadMsg.translate("Command_RECTANGLE", "Specify first corner or [{0}]: ").format(keyWords)
englishKeyWords = "Chamfer" + "/" + "Fillet"
keyWords += "_" + englishKeyWords
# si appresta ad attendere un punto o enter
# msg, inputType, default, keyWords, nessun controllo
self.waitFor(prompt, \
QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
None, keyWords, QadInputModeEnum.NONE)
#============================================================================
# WaitForSecondCorner
#============================================================================
def WaitForSecondCorner(self, layer):
self.step = 2
self.getPointMapTool().rot = self.rot
self.getPointMapTool().gapType = self.gapType
self.getPointMapTool().gapValue1 = self.gapValue1
self.getPointMapTool().gapValue2 = self.gapValue2
self.getPointMapTool().setMode(Qad_rectangle_maptool_ModeEnum.FIRST_CORNER_KNOWN_ASK_FOR_SECOND_CORNER)
if layer is not None:
self.getPointMapTool().geomType = layer.geometryType()
keyWords = QadMsg.translate("Command_RECTANGLE", "Area") + "/" + \
QadMsg.translate("Command_RECTANGLE", "Dimensions") + "/" + \
QadMsg.translate("Command_RECTANGLE", "Rotation")
prompt = QadMsg.translate("Command_RECTANGLE", "Specify other corner or [{0}]: ").format(keyWords)
englishKeyWords = "Area" + "/" + "Dimensions" + "/" + "Rotation"
keyWords += "_" + englishKeyWords
# si appresta ad attendere un punto o enter
# msg, inputType, default, keyWords, nessun controllo
self.waitFor(prompt, \
QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
None, keyWords, QadInputModeEnum.NONE)
#============================================================================
# run
#============================================================================
def run(self, msgMapTool = False, msg = None):
if self.plugIn.canvas.mapRenderer().destinationCrs().geographicFlag():
self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n"))
return True # fine comando
currLayer = None
if self.virtualCmd == False: # se si vuole veramente salvare la polylinea in un layer
# il layer corrente deve essere editabile e di tipo linea o poligono
currLayer, errMsg = qad_layer.getCurrLayerEditable(self.plugIn.canvas, [QGis.Line, QGis.Polygon])
if currLayer is None:
self.showErr(errMsg)
return True # fine comando
#=========================================================================
# RICHIESTA PRIMO PUNTO
if self.step == 0: # inizio del comando
self.WaitForFirstCorner()
return False
#=========================================================================
# RISPOSTA ALLA RICHIESTA DEL PRIMO PUNTO DEL RETTANGOLO (da step = 0)
elif self.step == 1: # dopo aver atteso un punto si riavvia il comando
if msgMapTool == True: # il punto arriva da una selezione grafica
# la condizione seguente si verifica se durante la selezione di un punto
# é stato attivato un altro plugin che ha disattivato Qad
# quindi stato riattivato il comando che torna qui senza che il maptool
# abbia selezionato un punto
if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
self.showMsg(QadMsg.translate("Command_RECTANGLE", "Window not correct."))
self.WaitForFirstCorner()
return False
else:
self.setMapTool(self.getPointMapTool()) # riattivo il maptool
return False
value = self.getPointMapTool().point
else: # il punto arriva come parametro della funzione
value = msg
if type(value) == unicode:
if value == QadMsg.translate("Command_RECTANGLE", "Chamfer") or value == "Chamfer":
if self.GetDistClass is not None:
del self.GetDistClass
self.GetDistClass = QadGetDistClass(self.plugIn)
prompt = QadMsg.translate("Command_RECTANGLE", "Specify first chamfer distance for rectangle <{0}>: ")
self.GetDistClass.msg = prompt.format(str(self.gapValue1))
self.GetDistClass.dist = self.gapValue1
self.GetDistClass.inputMode = QadInputModeEnum.NOT_NEGATIVE
self.step = 4
self.GetDistClass.run(msgMapTool, msg)
elif value == QadMsg.translate("Command_RECTANGLE", "Fillet") or value == "Fillet":
if self.GetDistClass is not None:
del self.GetDistClass
self.GetDistClass = QadGetDistClass(self.plugIn)
prompt = QadMsg.translate("Command_RECTANGLE", "Specify rectangle fillet radius <{0}>: ")
self.GetDistClass.msg = prompt.format(str(self.gapValue1))
self.GetDistClass.dist = self.gapValue1
self.GetDistClass.inputMode = QadInputModeEnum.NOT_NEGATIVE
self.step = 3
self.GetDistClass.run(msgMapTool, msg)
elif type(value) == QgsPoint:
self.firstCorner = value
self.getPointMapTool().firstCorner = self.firstCorner
self.WaitForSecondCorner(currLayer)
return False # continua
#=========================================================================
# RISPOSTA ALLA RICHIESTA DEL SECONDO PUNTO DEL RETTANGOLO (da step = 1)
elif self.step == 2: # dopo aver atteso un punto si riavvia il comando
if msgMapTool == True: # il punto arriva da una selezione grafica
# la condizione seguente si verifica se durante la selezione di un punto
# é stato attivato un altro plugin che ha disattivato Qad
# quindi stato riattivato il comando che torna qui senza che il maptool
# abbia selezionato un punto
if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
self.showMsg(QadMsg.translate("Command_RECTANGLE", "Window not correct."))
self.WaitForSecondCorner(currLayer)
return False
else:
self.setMapTool(self.getPointMapTool()) # riattivo il maptool
return False
value = self.getPointMapTool().point
else: # il punto arriva come parametro della funzione
value = msg
if type(value) == unicode:
if value == QadMsg.translate("Command_RECTANGLE", "Area") or value == "Area":
msg = QadMsg.translate("Command_RECTANGLE", "Enter rectangle area in current units <{0}>: ")
# si appresta ad attendere un numero reale
# msg, inputType, default, keyWords, valori positivi
self.waitFor(msg.format(str(self.area)), QadInputTypeEnum.FLOAT, \
self.area, "", \
QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
self.getPointMapTool().setMode(Qad_rectangle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_CORNER)
self.step = 6
elif value == QadMsg.translate("Command_RECTANGLE", "Dimensions") or value == "Dimensions":
if self.GetDistClass is not None:
del self.GetDistClass
self.GetDistClass = QadGetDistClass(self.plugIn)
prompt = QadMsg.translate("Command_RECTANGLE", "Specify length for rectangle <{0}>: ")
self.GetDistClass.msg = prompt.format(str(self.dim1))
self.GetDistClass.dist = self.dim1
self.step = 10
self.GetDistClass.run(msgMapTool, msg)
elif value == QadMsg.translate("Command_RECTANGLE", "Rotation") or value == "Rotation":
keyWords = QadMsg.translate("Command_RECTANGLE", "Points")
self.defaultValue = self.rot
prompt = QadMsg.translate("Command_RECTANGLE", "Specify rotation angle or [{0}] <{1}>: ").format(keyWords, str(qad_utils.toDegrees(self.rot)))
englishKeyWords = "Points"
keyWords += "_" + englishKeyWords
# si appresta ad attendere un punto o un numero reale
# msg, inputType, default, keyWords, valori non nulli
self.waitFor(prompt, \
QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT | QadInputTypeEnum.KEYWORDS, \
self.rot, keyWords)
self.getPointMapTool().setMode(Qad_rectangle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_CORNER)
self.step = 12
elif type(value) == QgsPoint:
self.vertices.extend(qad_utils.getRectByCorners(self.firstCorner, value, self.rot, \
self.gapType, self.gapValue1, self.gapValue2))
if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer
self.addRectangleToLayer(currLayer)
return True
return False # continua
#=========================================================================
# RISPOSTA ALLA RICHIESTA RAGGIO DI CURVATURA (da step = 1)
elif self.step == 3:
if self.GetDistClass.run(msgMapTool, msg) == True:
if self.GetDistClass.dist is not None:
self.gapValue1 = self.GetDistClass.dist
if self.gapValue1 == 0:
self.gapType = 0 # 0 = Angoli retti
else:
self.gapType = 1 # 1 = Raccorda i segmenti
self.WaitForFirstCorner()
self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di distanza
return False # fine comando
#=========================================================================
# RISPOSTA ALLA RICHIESTA PRIMA DISTANZA DI CIMATURA (da step = 1)
elif self.step == 4:
if self.GetDistClass.run(msgMapTool, msg) == True:
if self.GetDistClass.dist is not None:
self.gapValue1 = self.GetDistClass.dist
if self.GetDistClass is not None:
del self.GetDistClass
self.GetDistClass = QadGetDistClass(self.plugIn)
prompt = QadMsg.translate("Command_RECTANGLE", "Specify second chamfer distance for rectangle <{0}>: ")
self.GetDistClass.msg = prompt.format(str(self.gapValue2))
self.GetDistClass.dist = self.gapValue2
self.GetDistClass.inputMode = QadInputModeEnum.NOT_NEGATIVE
self.step = 5
self.GetDistClass.run(msgMapTool, msg)
else:
self.WaitForFirstCorner()
self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di distanza
return False # fine comando
#=========================================================================
# RISPOSTA ALLA RICHIESTA SECONDA DISTANZA DI CIMATURA (da step = 1)
elif self.step == 5:
if self.GetDistClass.run(msgMapTool, msg) == True:
if self.GetDistClass.dist is not None:
self.gapValue2 = self.GetDistClass.dist
if self.gapValue1 == 0 or self.gapValue2 == 0:
self.gapType = 0 # 0 = Angoli retti
else:
self.gapType = 2 # 2 = Cima i segmenti
self.WaitForFirstCorner()
self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di distanza
return False # fine comando
#=========================================================================
# RISPOSTA ALLA RICHIESTA AREA RETTANGOLO (da step = 2)
elif self.step == 6: # dopo aver atteso un punto si riavvia il comando
keyWords = QadMsg.translate("Command_RECTANGLE", "Length") + "/" + \
QadMsg.translate("Command_RECTANGLE", "Width")
englishKeyWords = "Length" + "/" + "Width"
if msgMapTool == True: # il punto arriva da una selezione grafica
# la condizione seguente si verifica se durante la selezione di un punto
# é stato attivato un altro plugin che ha disattivato Qad
# quindi stato riattivato il comando che torna qui senza che il maptool
# abbia selezionato un punto
if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
self.defaultValue = QadMsg.translate("Command_RECTANGLE", "Length")
prompt = QadMsg.translate("Command_RECTANGLE", "Calcolate the rectangle dimensions based on [{0}] <{1}>: ").format(keyWords, self.defaultValue)
keyWords += "_" + englishKeyWords
# si appresta ad attendere una parola chiave
# msg, inputType, default, keyWords, valori positivi
self.waitFor(prompt, QadInputTypeEnum.KEYWORDS, \
self.defaultValue, \
keyWords, QadInputModeEnum.NONE)
self.step = 7
return False
else:
self.setMapTool(self.getPointMapTool()) # riattivo il maptool
return False
value = self.getPointMapTool().point
else: # il punto arriva come parametro della funzione
value = msg
if type(value) == float: # é stata inserita l'area
self.area = value
self.defaultValue = QadMsg.translate("Command_RECTANGLE", "Length")
prompt = QadMsg.translate("Command_RECTANGLE", "Calcolate the rectangle dimensions based on [{0}] <{1}>: ").format(keyWords, self.defaultValue)
keyWords += "_" + englishKeyWords
# si appresta ad attendere una parola chiave
# msg, inputType, default, keyWords, valori positivi
self.waitFor(prompt, QadInputTypeEnum.KEYWORDS, \
self.defaultValue, \
keyWords, QadInputModeEnum.NONE)
self.step = 7
return False
#=========================================================================
# RISPOSTA ALLA RICHIESTA DELLA MODALITA' (LUNGHEZZA / LARGHEZZA) DATA L'AREA (da step = 6)
elif self.step == 7: # dopo aver atteso un punto o un numero reale si riavvia il comando
if msgMapTool == True: # il punto arriva da una selezione grafica
# la condizione seguente si verifica se durante la selezione di un punto
# é stato attivato un altro plugin che ha disattivato Qad
# quindi stato riattivato il comando che torna qui senza che il maptool
# abbia selezionato un punto
if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
value = self.defaultValue
return True # fine comando
else:
self.setMapTool(self.getPointMapTool()) # riattivo il maptool
return False
else:
return False
else: # il punto arriva come parametro della funzione
value = msg
if value == QadMsg.translate("Command_RECTANGLE", "Length") or value == "Length":
if self.GetDistClass is not None:
del self.GetDistClass
self.GetDistClass = QadGetDistClass(self.plugIn)
prompt = QadMsg.translate("Command_RECTANGLE", "Enter length for rectangle <{0}>: ")
self.GetDistClass.msg = prompt.format(str(self.dim1))
self.GetDistClass.dist = self.dim1
self.step = 8
self.GetDistClass.run(msgMapTool, msg)
elif value == QadMsg.translate("Command_RECTANGLE", "Width") or value == "Width":
if self.GetDistClass is not None:
del self.GetDistClass
self.GetDistClass = QadGetDistClass(self.plugIn)
prompt = QadMsg.translate("Command_RECTANGLE", "Enter width for rectangle <{0}>: ")
self.GetDistClass.msg = prompt.format(str(self.dim1))
self.GetDistClass.dist = self.dim1
self.step = 9
self.GetDistClass.run(msgMapTool, msg)
return False
#=========================================================================
# RISPOSTA ALLA RICHIESTA LUNGHEZZA RETTANGOLO DATA L'AREA (da step = 7)
elif self.step == 8:
if self.GetDistClass.run(msgMapTool, msg) == True:
if self.GetDistClass.dist is not None:
self.vertices.extend(qad_utils.getRectByAreaAndLength(self.firstCorner, self.area, self.GetDistClass.dist, \
self.rot, self.gapType, self.gapValue1, self.gapValue2))
if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer
self.addRectangleToLayer(currLayer)
return True # fine comando
return False
#=========================================================================
# RISPOSTA ALLA RICHIESTA LARGHEZZA RETTANGOLO DATA L'AREA (da step = 7)
elif self.step == 9:
if self.GetDistClass.run(msgMapTool, msg) == True:
if self.GetDistClass.dist is not None:
self.vertices.extend(qad_utils.getRectByAreaAndWidth(self.firstCorner, self.area, self.GetDistClass.dist, \
self.rot, self.gapType, self.gapValue1, self.gapValue2))
if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer
self.addRectangleToLayer(currLayer)
return True # fine comando
return False
#=========================================================================
# RISPOSTA ALLA RICHIESTA LUNGHEZZA RETTANGOLO (da step = 2)
elif self.step == 10:
if self.GetDistClass.run(msgMapTool, msg) == True:
if self.GetDistClass.dist is not None:
self.dim1 = self.GetDistClass.dist
if self.GetDistClass is not None:
del self.GetDistClass
self.GetDistClass = QadGetDistClass(self.plugIn)
prompt = QadMsg.translate("Command_RECTANGLE", "Enter width for rectangle <{0}>: ")
self.GetDistClass.msg = prompt.format(str(self.dim1))
self.GetDistClass.dist = self.dim1
self.step = 11
self.GetDistClass.run(msgMapTool, msg)
return False
#=========================================================================
# RISPOSTA ALLA RICHIESTA LARGHEZZA RETTANGOLO (da step = 10)
elif self.step == 11:
if self.GetDistClass.run(msgMapTool, msg) == True:
if self.GetDistClass.dist is not None:
self.vertices.extend(qad_utils.getRectByCornerAndDims(self.firstCorner, self.dim1, self.GetDistClass.dist, \
self.rot, self.gapType, self.gapValue1, self.gapValue2))
if self.virtualCmd == False: # se si vuole veramente salvare i buffer in un layer
self.addRectangleToLayer(currLayer)
return True # fine comando
return False
#=========================================================================
# RISPOSTA ALLA RICHIESTA ROTAZIONE RETTANGOLO (da step = 2)
elif self.step == 12: # dopo aver atteso un punto si riavvia il comando
if msgMapTool == True: # il punto arriva da una selezione grafica
# la condizione seguente si verifica se durante la selezione di un punto
# é stato attivato un altro plugin che ha disattivato Qad
# quindi stato riattivato il comando che torna qui senza che il maptool
# abbia selezionato un punto
if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
value = self.defaultValue
else:
self.setMapTool(self.getPointMapTool()) # riattivo il maptool
return False
else:
value = self.getPointMapTool().point
else: # il punto arriva come parametro della funzione
value = msg
if type(value) == unicode:
if value == QadMsg.translate("Command_RECTANGLE", "Points") or value == "Points":
# si appresta ad attendere l'angolo di rotazione
if self.GetAngleClass is not None:
del self.GetAngleClass
self.GetAngleClass = QadGetAngleClass(self.plugIn)
self.GetAngleClass.msg = QadMsg.translate("Command_RECTANGLE", "Specify first point: ")
self.GetAngleClass.angle = self.rot
self.step = 13
self.GetAngleClass.run(msgMapTool, msg)
elif type(value) == QgsPoint:
self.rot = qad_utils.getAngleBy2Pts(self.firstCorner, value)
self.WaitForSecondCorner(currLayer)
elif type(value) == float:
self.rot = qad_utils.toRadians(value)
self.WaitForSecondCorner(currLayer)
return False # continua
#=========================================================================
# RISPOSTA ALLA RICHIESTA ROTAZIONE RETTANGOLO (da step = 12)
elif self.step == 13:
if self.GetAngleClass.run(msgMapTool, msg) == True:
if self.GetAngleClass.angle is not None:
self.rot = self.GetAngleClass.angle
self.plugIn.setLastRot(self.rot)
self.WaitForSecondCorner(currLayer)
self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di rotazione