本文整理汇总了Python中qad_getangle_cmd.QadGetAngleClass.run方法的典型用法代码示例。如果您正苦于以下问题:Python QadGetAngleClass.run方法的具体用法?Python QadGetAngleClass.run怎么用?Python QadGetAngleClass.run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qad_getangle_cmd.QadGetAngleClass
的用法示例。
在下文中一共展示了QadGetAngleClass.run方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QadRECTANGLECommandClass
# 需要导入模块: from qad_getangle_cmd import QadGetAngleClass [as 别名]
# 或者: from qad_getangle_cmd.QadGetAngleClass import run [as 别名]
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)
#.........这里部分代码省略.........
示例2: QadINSERTCommandClass
# 需要导入模块: from qad_getangle_cmd import QadGetAngleClass [as 别名]
# 或者: from qad_getangle_cmd.QadGetAngleClass import run [as 别名]
class QadINSERTCommandClass(QadCommandClass):
def instantiateNewCmd(self):
""" istanzia un nuovo comando dello stesso tipo """
return QadINSERTCommandClass(self.plugIn)
def getName(self):
return QadMsg.translate("Command_list", "INSER")
def getEnglishName(self):
return "INSERT"
def connectQAction(self, action):
QObject.connect(action, SIGNAL("triggered()"), self.plugIn.runINSERTCommand)
def getIcon(self):
return QIcon(":/plugins/qad/icons/insert.png")
def getNote(self):
# impostare le note esplicative del comando
return QadMsg.translate("Command_INSERT", "Inserisce un simbolo.")
def __init__(self, plugIn):
QadCommandClass.__init__(self, plugIn)
self.insPt = None
self.scale = self.plugIn.lastScale
self.rot = self.plugIn.lastRot
self.GetDistClass = None
self.GetAngleClass = None
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 (scala)
if self.step == 2:
return self.GetDistClass.getPointMapTool()
# quando si é in fase di richiesta rotazione
elif self.step == 3:
return self.GetAngleClass.getPointMapTool()
else:
return QadCommandClass.getPointMapTool(self, drawMode)
def addFeature(self, layer):
transformedPoint = self.mapToLayerCoordinates(layer, self.insPt)
g = QgsGeometry.fromPoint(transformedPoint)
f = QgsFeature()
f.setGeometry(g)
# Add attribute fields to feature.
fields = layer.pendingFields()
f.setFields(fields)
# assegno i valori di default
provider = layer.dataProvider()
for field in fields.toList():
i = fields.indexFromName(field.name())
f[field.name()] = provider.defaultValue(i)
# se la scala dipende da un campo
scaleFldName = qad_layer.get_symbolScaleFieldName(layer)
if len(scaleFldName) > 0:
f.setAttribute(scaleFldName, self.scale)
# se la rotazione dipende da un campo
rotFldName = qad_layer.get_symbolRotationFieldName(layer)
if len(rotFldName) > 0:
f.setAttribute(rotFldName, qad_utils.toDegrees(self.rot))
return qad_layer.addFeatureToLayer(self.plugIn, layer, f)
def run(self, msgMapTool = False, msg = None):
if self.plugIn.canvas.mapRenderer().destinationCrs().geographicFlag():
self.showMsg(QadMsg.translate("QAD", "\nIl sistema di riferimento del progetto deve essere un sistema di coordinate proiettate.\n"))
return True # fine comando
currLayer, errMsg = qad_layer.getCurrLayerEditable(self.plugIn.canvas, QGis.Point)
if currLayer is None:
self.showErr(errMsg)
return True # fine comando
if qad_layer.isSymbolLayer(currLayer) == False:
errMsg = QadMsg.translate("QAD", "\nIl layer corrente non é di tipo simbolo.")
errMsg = errMsg + QadMsg.translate("QAD", "\nUn layer simbolo é un layer vettoriale di tipo punto senza etichetta.\n")
self.showErr(errMsg)
return True # fine comando
#=========================================================================
# RICHIESTA PUNTO DI INSERIMENTO
if self.step == 0: # inizio del comando
self.waitForPoint() # si appresta ad attendere un punto
self.step = self.step + 1
return False
#=========================================================================
#.........这里部分代码省略.........
示例3: QadTEXTCommandClass
# 需要导入模块: from qad_getangle_cmd import QadGetAngleClass [as 别名]
# 或者: from qad_getangle_cmd.QadGetAngleClass import run [as 别名]
class QadTEXTCommandClass(QadCommandClass):
def instantiateNewCmd(self):
""" istanzia un nuovo comando dello stesso tipo """
return QadTEXTCommandClass(self.plugIn)
def getName(self):
return QadMsg.translate("Command_list", "TEXT")
def getEnglishName(self):
return "TEXT"
def connectQAction(self, action):
QObject.connect(action, SIGNAL("triggered()"), self.plugIn.runTEXTCommand)
def getIcon(self):
return QIcon(":/plugins/qad/icons/text.png")
def getNote(self):
# impostare le note esplicative del comando
return QadMsg.translate("Command_TEXT", "Inserts a text.")
def __init__(self, plugIn):
QadCommandClass.__init__(self, plugIn)
self.insPt = None
self.hText = self.plugIn.lastHText
self.rot = self.plugIn.lastRot
self.GetDistClass = None
self.GetAngleClass = None
self.labelFields = None
self.labelFieldNamesNdx = 0
self.labelFieldValues = []
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 (altezza testo)
if self.step == 2:
return self.GetDistClass.getPointMapTool()
# quando si éin fase di richiesta rotazione
elif self.step == 3:
return self.GetAngleClass.getPointMapTool()
else:
return QadCommandClass.getPointMapTool(self, drawMode)
def addFeature(self, layer):
transformedPoint = self.mapToLayerCoordinates(layer, self.insPt)
g = QgsGeometry.fromPoint(transformedPoint)
f = QgsFeature()
f.setGeometry(g)
# Add attribute fields to feature.
fields = layer.pendingFields()
f.setFields(fields)
# assegno i valori di default
provider = layer.dataProvider()
for field in fields.toList():
i = fields.indexFromName(field.name())
f[field.name()] = provider.defaultValue(i)
# se l'altezza testo dipende da un solo campo
sizeFldNames = qad_label.get_labelSizeFieldNames(layer)
if len(sizeFldNames) == 1 and len(sizeFldNames[0]) > 0:
f.setAttribute(sizeFldNames[0], self.hText)
# se la rotazione dipende da un solo campo
rotFldNames = qad_label.get_labelRotationFieldNames(layer)
if len(rotFldNames) == 1 and len(rotFldNames[0]) > 0:
f.setAttribute(rotFldNames[0], qad_utils.toDegrees(self.rot))
# setto i valori degli attributi che compongono l'etichetta
i = 0
tot = len(self.labelFields)
while i < tot:
f.setAttribute(self.labelFields[i].name(), self.labelFieldValues[i])
i = i + 1
return qad_layer.addFeatureToLayer(self.plugIn, layer, f)
def initLabelFields(self, layer):
labelFieldNames = qad_label.get_labelFieldNames(layer)
if len(labelFieldNames) > 0:
self.labelFields = QgsFields()
for field in layer.dataProvider().fields():
if field.name() in labelFieldNames:
self.labelFields.append(QgsField(field.name(), field.type()))
#============================================================================
# waitForFieldValue
#============================================================================
def waitForFieldValue(self):
self.step = 4
if self.labelFields is None:
return False
#.........这里部分代码省略.........
示例4: QadLENGTHENCommandClass
# 需要导入模块: from qad_getangle_cmd import QadGetAngleClass [as 别名]
# 或者: from qad_getangle_cmd.QadGetAngleClass import run [as 别名]
class QadLENGTHENCommandClass(QadCommandClass):
def instantiateNewCmd(self):
""" istanzia un nuovo comando dello stesso tipo """
return QadLENGTHENCommandClass(self.plugIn)
def getName(self):
return QadMsg.translate("Command_list", "LENGTHEN")
def getEnglishName(self):
return "LENGTHEN"
def connectQAction(self, action):
QObject.connect(action, SIGNAL("triggered()"), self.plugIn.runLENGTHENCommand)
def getIcon(self):
return QIcon(":/plugins/qad/icons/lengthen.png")
def getNote(self):
# impostare le note esplicative del comando
return QadMsg.translate("Command_LENGTHEN", "Lengthen an object.")
def __init__(self, plugIn):
QadCommandClass.__init__(self, plugIn)
self.OpMode = plugIn.lastOpMode_lengthen # "DElta" o "Percent" o "Total" o "DYnamic"
self.OpType = None # "length" o "Angle"
self.value = None
self.startPt = None
self.GetDistClass = None
self.GetAngleClass = None
self.entity = QadEntity()
self.linearObjectList = None
self.atSubGeom = None
self.move_startPt = None
self.nOperationsToUndo = 0
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):
if self.step == 3: # quando si é in fase di richiesta distanza
return self.GetDistClass.getPointMapTool()
if self.step == 4: # quando si é in fase di richiesta angolo
return self.GetAngleClass.getPointMapTool()
elif (self.plugIn is not None):
if self.PointMapTool is None:
self.PointMapTool = Qad_lengthen_maptool(self.plugIn)
return self.PointMapTool
else:
return None
def setInfo(self, entity, point):
# setta: self.entity, self.linearObjectList, self.atSubGeom e self.move_startPt
if self.linearObjectList is not None:
del self.linearObjectList
self.linearObjectList = None
self.entity.set(entity.layer, entity.featureId)
transformedPt = self.mapToLayerCoordinates(self.entity.layer, point)
f = self.entity.getFeature()
geom = self.entity.getGeometry()
# ritorna una tupla (<The squared cartesian distance>,
# <minDistPoint>
# <afterVertex>
# <leftOf>)
res = False
dummy = qad_utils.closestSegmentWithContext(transformedPt, geom)
if dummy[2] is None:
return False
# ritorna la sotto-geometria al vertice <atVertex> e la sua posizione nella geometria (0-based)
subGeom, self.atSubGeom = qad_utils.getSubGeomAtVertex(geom, dummy[2])
self.linearObjectList = qad_utils.QadLinearObjectList()
self.linearObjectList.fromPolyline(subGeom.asPolyline())
if qad_utils.getDistance(self.linearObjectList.getStartPt(), transformedPt) <= \
qad_utils.getDistance(self.linearObjectList.getEndPt(), transformedPt):
# si allunga dal punto iniziale
self.move_startPt = True
else:
# si allunga dal punto finale
self.move_startPt = False
return True
#============================================================================
# lengthen
#============================================================================
def lengthen(self, point):
layer = self.entity.layer
f = self.entity.getFeature()
if f is None: # non c'è più la feature
#.........这里部分代码省略.........
示例5: QadDIMARCCommandClass
# 需要导入模块: from qad_getangle_cmd import QadGetAngleClass [as 别名]
# 或者: from qad_getangle_cmd.QadGetAngleClass import run [as 别名]
class QadDIMARCCommandClass(QadCommandClass):
def instantiateNewCmd(self):
""" istanzia un nuovo comando dello stesso tipo """
return QadDIMARCCommandClass(self.plugIn)
def getName(self):
return QadMsg.translate("Command_list", "DIMARC")
def getEnglishName(self):
return "DIMARC"
def connectQAction(self, action):
QObject.connect(action, SIGNAL("triggered()"), self.plugIn.runDIMARCCommand)
def getIcon(self):
return QIcon(":/plugins/qad/icons/dimArc.png")
def getNote(self):
# impostare le note esplicative del comando
return QadMsg.translate("Command_DIM", "Creates an arc length dimension.")
def __init__(self, plugIn):
QadCommandClass.__init__(self, plugIn)
self.EntSelClass = None
self.GetAngleClass = None
self.dimPt1 = QgsPoint()
self.dimPt2 = QgsPoint()
self.dimArc = None # oggetto arco da quotare
self.measure = None # misura della quota (se None viene calcolato)
self.leader = False
# leggo lo stile di quotatura corrente
dimStyleName = QadVariables.get(QadMsg.translate("Environment variables", "DIMSTYLE"))
self.dimStyle = self.plugIn.dimStyles.findDimStyle(dimStyleName)
if self.dimStyle is not None:
self.dimStyle.dimType = QadDimTypeEnum.ALIGNED
def __del__(self):
QadCommandClass.__del__(self)
if self.EntSelClass is not None:
self.EntSelClass.entity.deselectOnLayer()
del self.EntSelClass
if self.GetAngleClass is not None:
del self.GetAngleClass
def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
if self.step == 1: # quando si é in fase di selezione entità
return self.EntSelClass.getPointMapTool(drawMode)
# quando si é in fase di richiesta rotazione
elif self.step == 6:
return self.GetAngleClass.getPointMapTool()
else:
if (self.plugIn is not None):
if self.PointMapTool is None:
self.PointMapTool = Qad_dim_maptool(self.plugIn)
return self.PointMapTool
else:
return None
#============================================================================
# addDimToLayers
#============================================================================
def addDimToLayers(self, linePosPt):
return self.dimStyle.addAlignedDimToLayers(self.plugIn, self.dimPt1, self.dimPt2, \
linePosPt, self.measure)
#============================================================================
# waitForEntsel
#============================================================================
def waitForEntsel(self, msgMapTool, msg):
if self.EntSelClass is not None:
del self.EntSelClass
self.step = 1
self.EntSelClass = QadEntSelClass(self.plugIn)
self.EntSelClass.msg = QadMsg.translate("Command_DIM", "Select arc or polyline arc segment: ")
# scarto la selezione di punti
self.EntSelClass.checkPointLayer = False
self.EntSelClass.checkLineLayer = True
self.EntSelClass.checkPolygonLayer = True
self.EntSelClass.getPointMapTool().setSnapType(QadSnapTypeEnum.DISABLE)
self.EntSelClass.run(msgMapTool, msg)
#============================================================================
# waitForDimensionLinePos
#============================================================================
def waitForDimensionLinePos(self):
self.step = 4
# imposto il map tool
self.getPointMapTool().dimPt2 = self.dimPt2
if self.getPointMapTool().dimPt1 is None: # in caso di selezione oggetto dimPt1 non era stato inizializzato
self.getPointMapTool().dimPt1 = self.dimPt1
self.getPointMapTool().dimCircle = self.dimCircle
self.getPointMapTool().dimStyle = self.dimStyle
self.getPointMapTool().setMode(Qad_dim_maptool_ModeEnum.FIRST_SECOND_PT_KNOWN_ASK_FOR_ALIGNED_DIM_LINE_POS)
#.........这里部分代码省略.........
示例6: QadDIMLINEARCommandClass
# 需要导入模块: from qad_getangle_cmd import QadGetAngleClass [as 别名]
# 或者: from qad_getangle_cmd.QadGetAngleClass import run [as 别名]
class QadDIMLINEARCommandClass(QadCommandClass):
def instantiateNewCmd(self):
""" istanzia un nuovo comando dello stesso tipo """
return QadDIMLINEARCommandClass(self.plugIn)
def getName(self):
return QadMsg.translate("Command_list", "DIMLINEARE")
def getEnglishName(self):
return "DIMLINEAR"
def connectQAction(self, action):
QObject.connect(action, SIGNAL("triggered()"), self.plugIn.runDIMLINEARCommand)
def getIcon(self):
return QIcon(":/plugins/qad/icons/dimLinear.png")
def getNote(self):
# impostare le note esplicative del comando
return QadMsg.translate("Command_DIM", "Crea una quota lineare orizzontale o verticale.")
def __init__(self, plugIn):
QadCommandClass.__init__(self, plugIn)
self.EntSelClass = None
self.GetAngleClass = None
self.dimPt1 = QgsPoint() # primo punto di quotatura esplicito
self.dimPt2 = QgsPoint() # secondo punto di quotatura esplicito
self.dimCircle = None # oggetto cerchio da quotare
self.measure = None # misura della quota (se None viene calcolato)
self.preferredAlignment = QadDimStyleAlignmentEnum.HORIZONTAL # allineamento della linea di quota
# leggo lo stile di quotatura corrente
dimStyleName = QadVariables.get(QadMsg.translate("Environment variables", "DIMSTYLE"))
self.forcedDimLineAlignment = None # allineamento della linea di quota forzato
self.forcedDimLineRot = 0.0 # rotazione della linea di quota forzato
_dimStyle = self.plugIn.dimStyles.findDimStyle(dimStyleName)
if _dimStyle is not None:
self.dimStyle = QadDimStyle(_dimStyle) # ne faccio una copia perché può venire modificato dal comando
self.dimStyle.dimType = QadDimTypeEnum.LINEAR
else:
self.dimStyle = None
def __del__(self):
QadCommandClass.__del__(self)
if self.EntSelClass is not None:
self.EntSelClass.entity.deselectOnLayer()
del self.EntSelClass
if self.GetAngleClass is not None:
del self.GetAngleClass
def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
if self.step == 2: # quando si é in fase di selezione entità
return self.EntSelClass.getPointMapTool(drawMode)
# quando si é in fase di richiesta rotazione
elif self.step == 6 or self.step == 7:
return self.GetAngleClass.getPointMapTool()
else:
if (self.plugIn is not None):
if self.PointMapTool is None:
self.PointMapTool = Qad_dim_maptool(self.plugIn)
return self.PointMapTool
else:
return None
#============================================================================
# addDimToLayers
#============================================================================
def addDimToLayers(self, linePosPt):
return self.dimStyle.addLinearDimToLayers(self.plugIn, self.dimPt1, self.dimPt2, \
linePosPt, self.measure, self.preferredAlignment, \
self.forcedDimLineRot)
#============================================================================
# waitForFirstPt
#============================================================================
def waitForFirstPt(self):
self.step = 1
# imposto il map tool
self.getPointMapTool().setMode(Qad_dim_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_PT)
msg = QadMsg.translate("Command_DIM", "Specificare l'origine della prima linea di estensione o <seleziona oggetto>: ")
# si appresta ad attendere un punto o enter
# msg, inputType, default, keyWords, nessun controllo
self.waitFor(msg, \
QadInputTypeEnum.POINT2D, \
None, \
"", QadInputModeEnum.NONE)
#============================================================================
# waitForSecondPt
#============================================================================
def waitForSecondPt(self):
#.........这里部分代码省略.........