Ejemplo n.º 1
0
def ramp_color_rgb(values, feature, parent):
    """
        Return only the rgb part of a defined color ramp
        
        <p><h4>Syntax</h4>
        ramp_color_rgb(<i>ramp_name,value</i>)</p>

        <p><h4>Arguments</h4>
        <i>  ramp_name</i> &rarr; the name of the color ramp as a string, for example 'Spectral'.<br>
        <i>  value</i> &rarr; the position on the ramp to select the color from as a real number between 0 and 1.<br></p>
        
        <p><h4>Example</h4>
        <!-- Show example of function.-->
             ramp_color_rgb('Spectral',0.3) &rarr; '253,190,115'</p>
        
        <p><h4>Note:</h4>
        The color ramps available vary between QGIS installations.  This function
        may not give the expected results if you move your Quantum project.
        </p>
    """
    ramp_name = values[0]
    ramp_position = values[1]

    ramp = QgsStyleV2.defaultStyle().colorRampRef(ramp_name)
    if not ramp:
        parent.setEvalErrorString(QObject.tr('"{}" is not a valid color ramp'.format(ramp_name)))
        return QColor(0, 0, 0).name()

    value, error = getFloat(ramp_position)
    if error:
        parent.setEvalErrorString(error)

    color = ramp.color(value)
    return "{},{},{}".format(color.red(), color.green(), color.blue())
Ejemplo n.º 2
0
	def error( parent, text, critical=False ):
		"""
		Standardisierte Dialogbox für die Mitteilung eines Fehlers an den Benutzer.

		Ein Fehler wird auch auf der kommandozeile ausgegeben, wenn "verbose" aktiviert ist.

		\param critical=True macht daraus einen kritischen Fehler, bei welchem das Programm beendet werden muß.
		"""

		if GlobalState.is_verbose:
			Shell.print_error( text, critical=critical )

		obj = QObject()
		headline = obj.tr("Error")
		if critical:
			headline = obj.tr("Critical Error")
		QMessageBox.critical( parent, headline, str( text ) )
Ejemplo n.º 3
0
    def usage(self, command ):
        parts = self.parseCommands( command )
        if parts:
            cmd = parts[0]
        else:
            cmd = ''
        
        if  cmd == "style" :
            usage = []
            
            usage.append( "Usage: %s [list | STYLE]"  % cmd )
            usage.append(self.description( cmd ))
            usage.append('')
            usage.append(QObject.tr( "%s list\t\tShow the available styles" % 
                                      cmd ))
            usage.append(QObject.tr( 
                    "%s STYLE\t\tChange the application style to STYLE" % cmd ))
            
            return '\n'.join(usage)

        return pConsoleCommand.usage( command )
Ejemplo n.º 4
0
	def warning( parent, text ):
		"""
		Standardisierte Dialogbox für die Mitteilung einer Warnung an den Benutzer.

		Eine Warnung wird auch auf der kommandozeile ausgegeben, wenn "verbose" aktiviert ist.
		"""

		if GlobalState.is_verbose:
			Shell.print_warning( text )

		obj = QObject()
		QMessageBox.warning( parent, obj.tr("Warning"), str( text ) )
Ejemplo n.º 5
0
class Err(Exception):
	"""
	@brief Basisklasse für die Ausnahmebehandlung

	Diese Klasse liegt allen eigenen Ausnahmebehandlungen zugrunde.

	\param critical (bool) Kritische Fehler führen zu einem Abbruch des Programms.
	"""

	def __init__( self, text=None, critical=False ):
		super().__init__()

		self.obj = QObject()

		if text is None:
			text = self.obj.tr( "Unknown generic Exception." )

		# Kurze Benachrichtigung der Ausnahme
		self.text = text
		self.critical = critical


	def __str__(self):
		return self.text
Ejemplo n.º 6
0
def saveFile(filename):
  transObj = QObject()
  fName = QFileDialog.getSaveFileName(None, transObj.tr("Save media file"), filename, "")
  if fName.isEmpty() == False:
    rootObject.targetFilename(fName)  
Ejemplo n.º 7
0
def openFile():
  transObj = QObject()
  fName = QFileDialog.getOpenFileName(None, transObj.tr("Open media file"), home, transObj.tr("Media Files (*.mp4 *.avi *.mp3 *.wav *.ogg *.flv *.ogv *.m4v *.m4a *.aac *.flac *.webm *.mpg *.mpeg *.wmv *.wma *.mp2 *.mov *.oga *.aif *.aiff *.aifc *.ape *.mka *.asf *.3gp *.dv *.m2t *.mts *.ts *.divx *.nsv *.ogm)"))
  if fName.isEmpty() == False:
    rootObject.sourceFilename(fName)
Ejemplo n.º 8
0
        try:
            from cs_package import package
            iok = True
        except ImportError,e:
            mess = ObjectTR.tr("INFO_DLG_INVALID_ENV").arg(code) + e.__str__()
            if "cs_package" in e.__str__():
                mess = mess + " ; Check for cs_package file in Code_Saturne python package"
            elif "code_saturne" in e.__str__():
                mess = mess + " ; Check PYTHONPATH then your installation "
            iok = False
    elif code == CFD_Neptune:
        try:
            from nc_package import package
            iok = True
        except ImportError,e:
            mess = ObjectTR.tr("INFO_DLG_INVALID_ENV").arg(code) + e.__str__()
            if "nc_package" in e.__str__():
                mess = mess + " ; Check for nc_package file in NEPTUNE_CFD python package"
            elif "neptune_cfd" in e.__str__():
                mess = mess + " ; Check PYTHONPATH then your installation "
            iok = False
    else:
        raise ApplicationError, "Invalid name of solver!"

    if iok:
        pkg = package()
        prefix = pkg.get_dir('prefix')
        log.debug("CheckCFD_CodeEnv -> prefix = %s" % (prefix))

        bindir = pkg.get_dir('bindir')
        log.debug("CheckCFD_CodeEnv -> prefix = %s" % (bindir))
Ejemplo n.º 9
0
log.setLevel(logging.NOTSET)

#-------------------------------------------------------------------------------
# Global definitions
#-------------------------------------------------------------------------------
__MODULE_NAME__ = "CFDSTUDY"
studyId = salome.myStudyId
d_activation = {}

# Desktop manager: instance of CFDSTUDYGUI_DesktopMgr class to store the SALOME Workspace
_DesktopMgr = CFDSTUDYGUI_DesktopMgr.CFDSTUDYGUI_DesktopMgr()

# ObjectTR is a convenient object for traduction purpose
ObjectTR = QObject()

DEFAULT_EDITOR_NAME = ObjectTR.tr("CFDSTUDY_PREF_EDITOR")

#-------------------------------------------------------------------------------
# Callback GUI functions
#-------------------------------------------------------------------------------

def initialize():
    """
    This method is called when GUI module is being created and initialized.
    """
    # nothing to do here.
    log.debug("initialize")
    if not sgPyQt.hasSetting( "CFDSTUDY", "ExternalEditor"):
        sgPyQt.addSetting( "CFDSTUDY", "ExternalEditor", DEFAULT_EDITOR_NAME )
    pass
Ejemplo n.º 10
0
 def name(cls):
     return QObject.tr(translator, 'Export to FTP site')
Ejemplo n.º 11
0
 def name(cls):
     return QObject.tr(translator, 'Export to folder')
Ejemplo n.º 12
0
 def name(cls):
     return QObject.tr(translator, 'OpenLayers')
Ejemplo n.º 13
0
 def name(cls):
     return QObject.tr(translator, 'Leaflet')