def intLineEditWidgetValidation(self, widget, varName, msg):
        var = self.tempQadVariables.getVariable(
            QadMsg.translate("Environment variables", varName))

        err = False
        string = widget.text()
        if qad_utils.str2int(string) is None:
            err = True
        else:
            if var.minNum is not None:
                if qad_utils.str2int(string) < var.minNum:
                    err = True
            if var.maxNum is not None:
                if qad_utils.str2int(string) > var.maxNum:
                    err = True

        if err:
            msg = msg + QadMsg.translate("QAD", ": enter a number")
            if var.minNum is not None:
                msg = msg + QadMsg.translate("QAD", " >= {0}").format(
                    str(var.minNum))
            if var.maxNum is not None:
                if var.minNum is not None:
                    msg = msg + QadMsg.translate("QAD", " and")
                msg = msg + QadMsg.translate("QAD", " <= {0}").format(
                    str(var.maxNum))
            msg = msg + "."
            QMessageBox.critical(self, "QAD", msg)
            widget.setFocus()
            widget.selectAll()
            return False
        return True
Beispiel #2
0
   def intLineEditWidgetValidation(self, widget, varName, msg):
      var = self.tempQadVariables.getVariable(QadMsg.translate("Environment variables", varName))

      err = False
      string = widget.text()
      if qad_utils.str2int(string) is None:
         err = True
      else:
         if var.minNum is not None:
            if qad_utils.str2int(string) < var.minNum:
               err = True
         if var.maxNum is not None:
            if qad_utils.str2int(string) > var.maxNum:
               err = True
      
      if err:
         msg = msg + QadMsg.translate("QAD", ": enter a number")
         if var.minNum is not None:
            msg = msg + QadMsg.translate("QAD", " >= {0}").format(str(var.minNum))
         if var.maxNum is not None:
            if var.minNum is not None:
               msg = msg + QadMsg.translate("QAD", " and")
            msg = msg + QadMsg.translate("QAD", " <= {0}").format(str(var.maxNum))
         msg = msg + "."
         QMessageBox.critical(self, "QAD", msg)
         widget.setFocus()
         widget.selectAll()
         return False
      return True
Beispiel #3
0
   def accept_selection_tab(self):
      # PICKBOX
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "PICKBOX"), self.horizontalSlider_PICKBOX.value())

      # PICKFIRST
      pickFirst = 1 if self.checkBox_PICKFIRST.checkState() == Qt.Checked else 0
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "PICKFIRST"), pickFirst)

      # PICKADD
      pickAdd = 0 if self.checkBox_PICKADD.checkState() == Qt.Checked else 1
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "PICKADD"), pickAdd)

      # GRIPSIZE
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "GRIPSIZE"), self.horizontalSlider_GRIPSIZE.value())

      # GRIPS
      grips = 1 if self.checkBox_GRIPS.checkState() == Qt.Checked else 0
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "GRIPS"), grips)

      # GRIPMULTIFUNCTIONAL
      gripMultiFunctional = self.tempQadVariables.get(QadMsg.translate("Environment variables", "GRIPMULTIFUNCTIONAL"))
      if self.checkBox_GRIPMULTIFUNCTIONAL_ON_DYNAMIC_MENU_AND_HOT_GRIPT.checkState() == Qt.Checked:
         gripMultiFunctional = gripMultiFunctional | QadGRIPMULTIFUNCTIONALEnum.ON_DYNAMIC_MENU_AND_HOT_GRIPT # aggiungo i bit
      else:
         gripMultiFunctional = gripMultiFunctional &~ QadGRIPMULTIFUNCTIONALEnum.ON_DYNAMIC_MENU_AND_HOT_GRIPT # tolgo i bit
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "GRIPMULTIFUNCTIONAL"), gripMultiFunctional)

      # GRIPOBJLIMIT
      gripObjLimit = qad_utils.str2int(self.lineEdit_GRIPOBJLIMIT.text())
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "GRIPOBJLIMIT"), gripObjLimit)
Beispiel #4
0
   def load(self, Path=""):
      """
      Carica il dizionario delle variabili da file
      Ritorna True in caso di successo, false in caso di errore
      """
      # svuoto il dizionario e lo reimposto con i valori di default
      self.__VariableValuesDict.clear()
      self.__init__()
      if Path == "":
         # Se la path non é indicata uso il file "qad.ini" in 
         Path = QDir.cleanPath(QgsApplication.qgisSettingsDirPath()) + "python/plugins/qad/"
         Path = Path + "qad.ini"

      if not os.path.exists(Path):
         return False
                    
      file = open(Path, "r") # apre il file in lettura
      for line in file:
         # leggo il valore + il tipo (es var = 5 <type 'int'>)
         sep = line.rfind(" = ")
         VarName = line[0:sep]
         VarName = VarName.strip(" ") # rimuovo gli spazi prima e dopo
         VarValue = line[sep+3:]
         sep = VarValue.rfind(" <type '")
         sep2 = VarValue.rfind("'>")
         VarType = VarValue[sep+8:sep2]
         VarValue = VarValue[:sep]
         if VarType == "int":
            VarValue = qad_utils.str2int(VarValue)
            if VarValue is None:
               self.set(VarName, int(0))
            else:
               self.set(VarName, VarValue)
         elif VarType == "long":
            VarValue = qad_utils.str2long(VarValue)
            if VarValue is None:
               self.set(VarName, long(0))
            else:
               self.set(VarName, VarValue)
         elif VarType == "float":
            VarValue = qad_utils.str2float(VarValue)
            if VarValue is None:
               self.set(VarName, float(0))
            else:
               self.set(VarName, VarValue)
         elif VarType == "bool":
            VarValue = qad_utils.str2bool(VarValue)
            if VarValue is None:
               self.set(VarName, False)
            else:
               self.set(VarName, VarValue)
         else:
            self.set(VarName, str(VarValue))
            
      file.close()
      
      return True
Beispiel #5
0
   def accept_display_tab(self):
      # Memorizzo il valore di SHOWTEXTWINDOW
      newSHOWTEXTWINDOW = True if self.checkBox_SHOWTEXTWINDOW.checkState() == Qt.Checked else False
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "SHOWTEXTWINDOW"), newSHOWTEXTWINDOW)

      # Memorizzo il valore di CMDINPUTHISTORYMAX
      SHistoryMax = self.lineEdit_CMDINPUTHISTORYMAX.text()
      historyMax = qad_utils.str2int(SHistoryMax)
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "CMDINPUTHISTORYMAX"), historyMax)

      # Memorizzo il valore di INPUTSEARCHOPTIONS
      newInputSearchOptions = 0
      if self.checkBox_INPUTSEARCHOPTIONS_ON.checkState() == Qt.Checked:
         newInputSearchOptions = newInputSearchOptions | QadINPUTSEARCHOPTIONSEnum.ON
      if self.checkBox_INPUTSEARCHOPTIONS_AUTOCOMPLETE.checkState() == Qt.Checked:
         newInputSearchOptions = newInputSearchOptions | QadINPUTSEARCHOPTIONSEnum.AUTOCOMPLETE
      if self.checkBox_INPUTSEARCHOPTIONS_DISPLAY_LIST.checkState() == Qt.Checked:
         newInputSearchOptions = newInputSearchOptions | QadINPUTSEARCHOPTIONSEnum.DISPLAY_LIST
      if self.checkBox_INPUTSEARCHOPTIONS_DISPLAY_ICON.checkState() == Qt.Checked:
         newInputSearchOptions = newInputSearchOptions | QadINPUTSEARCHOPTIONSEnum.DISPLAY_ICON
      if self.checkBox_INPUTSEARCHOPTIONS_EXCLUDE_SYS_VAR.checkState() == Qt.Checked:
         newInputSearchOptions = newInputSearchOptions | QadINPUTSEARCHOPTIONSEnum.EXCLUDE_SYS_VAR
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "INPUTSEARCHOPTIONS"), newInputSearchOptions)

      # Memorizzo il valore di INPUTSEARCHDELAY
      SInputSearchDelay = self.lineEdit_INPUTSEARCHDELAY.text()
      InputSearchDelay = qad_utils.str2int(SInputSearchDelay)
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "INPUTSEARCHDELAY"), InputSearchDelay)

      # Memorizzo il valore di ARCMINSEGMENTQTY
      SArcMinSegmentQty = self.lineEdit_ARCMINSEGMENTQTY.text()
      ArcMinSegmentQty = qad_utils.str2int(SArcMinSegmentQty)
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "ARCMINSEGMENTQTY"), ArcMinSegmentQty)

      # Memorizzo il valore di CIRCLEMINSEGMENTQTY
      SCircleMinSegmentQty = self.lineEdit_CIRCLEMINSEGMENTQTY.text()
      CircleMinSegmentQty = qad_utils.str2int(SCircleMinSegmentQty)
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "CIRCLEMINSEGMENTQTY"), CircleMinSegmentQty)

      # Memorizzo il valore di TOLERANCE2APPROXCURVE
      STolerance2ApproxCurve = self.lineEdit_TOLERANCE2APPROXCURVE.text()
      Tolerance2ApproxCurve = qad_utils.str2int(STolerance2ApproxCurve)
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "TOLERANCE2APPROXCURVE"), Tolerance2ApproxCurve)

      # Memorizzo il valore di CURSORSIZE
      SCursorSize = self.lineEdit_CURSORSIZE.text()
      CursorSize = qad_utils.str2int(SCursorSize)
      self.tempQadVariables.set(QadMsg.translate("Environment variables", "CURSORSIZE"), CursorSize)
Beispiel #6
0
   def evaluate(self, cmd):      
      #------------------------------------------------------------------------------
      # nome di un comando
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.COMMAND:
         if cmd == "":
            cmd = unicode(self.showLast()) # ripeto ultimo comando
         
         if self.parentWidget().isValidCommand(cmd):
            self.updateHistory(cmd)
            self.parentWidget().runCommand(cmd)
         else:
            msg = QadMsg.translate("QAD", "\nComando sconosciuto \"{0}\".")
            self.showMsg(msg.format(cmd.encode('ascii','ignore')), True) # ripete il prompt
         return

      if cmd == "":
         if self.default is not None:
            if type(self.default) == QgsPoint:
               cmd = self.default.toString()
            else:
               cmd = unicode(self.default)              
               
         if cmd == "" and \
            not (self.inputMode & QadInputModeEnum.NOT_NULL): # permesso input nullo              
            self.parentWidget().continueCommand(None)         
            return
                       
      #------------------------------------------------------------------------------
      # punto 2D
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.POINT2D:
         snapType = qad_utils.str2snapTypeEnum(cmd)
         if snapType != -1:
            # se é stato forzato uno snap
            snapParams = qad_utils.str2snapParams(cmd)
            self.parentWidget().forceCommandMapToolSnapTypeOnce(snapType, snapParams)
            self.showMsg(QadMsg.translate("QAD", "\n(impostato snap temporaneo)\n"), True) # ripeti il prompt
            return
         if (self.inputType & QadInputTypeEnum.INT) or \
            (self.inputType & QadInputTypeEnum.LONG) or \
            (self.inputType & QadInputTypeEnum.FLOAT) or \
            (self.inputType & QadInputTypeEnum.ANGLE) or \
            (self.inputType & QadInputTypeEnum.BOOL):
            oneNumberAllowed = False
         else:
            oneNumberAllowed = True
            
         pt = qad_utils.str2QgsPoint(cmd, \
                                     self.parentWidget().getLastPoint(), \
                                     self.parentWidget().getCurrenPointFromCommandMapTool(), \
                                     oneNumberAllowed)
                      
         if pt is not None:
            self.parentWidget().setLastPoint(pt)
            self.parentWidget().continueCommand(pt)
            return
            
      #------------------------------------------------------------------------------
      # punto 3D
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.POINT3D: # punto
         pass
      
      #------------------------------------------------------------------------------
      # una parola chiave
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.KEYWORDS:
         keyWord = self.evaluateKeyWords(cmd)
               
         if keyWord is not None:
            self.parentWidget().continueCommand(keyWord)
            return
                      
      #------------------------------------------------------------------------------
      # una stringa
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.STRING:            
         if cmd is not None:            
            self.parentWidget().continueCommand(cmd)
            return       
                     
      #------------------------------------------------------------------------------
      # un numero intero
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.INT:
         num = qad_utils.str2int(cmd)
         if num == 0 and (self.inputMode & QadInputModeEnum.NOT_ZERO): # non permesso valore = 0              
            num = None
         elif num < 0 and (self.inputMode & QadInputModeEnum.NOT_NEGATIVE): # non permesso valore < 0              
            num = None
         elif num > 0 and (self.inputMode & QadInputModeEnum.NOT_POSITIVE): # non permesso valore > 0              
            num = None
               
         if num is not None:
            self.parentWidget().continueCommand(int(num))
            return       
                     
      #------------------------------------------------------------------------------
      # un numero lungo
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.LONG:
         num = qad_utils.str2long(cmd)
         if num == 0 and (self.inputMode & QadInputModeEnum.NOT_ZERO): # non permesso valore = 0              
            num = None
         elif num < 0 and (self.inputMode & QadInputModeEnum.NOT_NEGATIVE): # non permesso valore < 0              
            num = None
         elif num > 0 and (self.inputMode & QadInputModeEnum.NOT_POSITIVE): # non permesso valore > 0              
            num = None
            
         if num is not None:
            self.parentWidget().continueCommand(long(num))
            return       
                     
      #------------------------------------------------------------------------------
      # un numero reale
      #------------------------------------------------------------------------------ 
      if self.inputType & QadInputTypeEnum.FLOAT or self.inputType & QadInputTypeEnum.ANGLE:
         num = qad_utils.str2float(cmd)
         if num == 0 and (self.inputMode & QadInputModeEnum.NOT_ZERO): # non permesso valore = 0              
            num = None
         elif num < 0 and (self.inputMode & QadInputModeEnum.NOT_NEGATIVE): # non permesso valore < 0              
            num = None
         elif num > 0 and (self.inputMode & QadInputModeEnum.NOT_POSITIVE): # non permesso valore > 0              
            num = None
            
         if num is not None:
            if self.inputType & QadInputTypeEnum.ANGLE: # se é un angolo in gradi
               # i gradi vanno convertiti in radianti
               num = qad_utils.toRadians(num)            
            self.parentWidget().continueCommand(float(num))         
            return       

      #------------------------------------------------------------------------------
      # un valore booleano
      #------------------------------------------------------------------------------ 
      elif self.inputType & QadInputTypeEnum.BOOL:
         value = qad_utils.str2bool(cmd)
            
         if value is not None:
            self.parentWidget().continueCommand(value)
            return       

      self.showMsg(self.getInvalidInputMsg())
      
      if self.inputType & QadInputTypeEnum.KEYWORDS:
         self.displayKeyWordsPrompt()
      else:
         self.displayPrompt()
         
      return
 def lineEdit_CURSORSIZE_textChanged(self):
     value = qad_utils.str2int(self.lineEdit_CURSORSIZE.text())
     self.horizontalSlider_CURSORSIZE.setValue(value)
Beispiel #8
0
 def lineEdit_CURSORSIZE_textChanged(self):
    value = qad_utils.str2int(self.lineEdit_CURSORSIZE.text())
    self.horizontalSlider_CURSORSIZE.setValue(value)