Example #1
0
def initialize():
    """Initialize the image module."""
    global image_formats_qt, image_formats_qtr, image_formats_gl2ps, image_formats_fromeps, gl2ps, _producer, _gl2ps_types

    # Find interesting supporting software
    utils.hasExternal("ImageMagick")
    # Set some globals
    GD.debug("LOADING IMAGE FORMATS")
    image_formats_qt = map(str, QtGui.QImageWriter.supportedImageFormats())
    image_formats_qtr = map(str, QtGui.QImageReader.supportedImageFormats())
    if GD.cfg.get("imagesfromeps", False):
        GD.image_formats_qt = []

    if utils.hasModule("gl2ps"):

        import gl2ps

        _producer = GD.Version + " (http://pyformex.berlios.de)"
        _gl2ps_types = {"ps": gl2ps.GL2PS_PS, "eps": gl2ps.GL2PS_EPS, "tex": gl2ps.GL2PS_TEX, "pdf": gl2ps.GL2PS_PDF}
        if utils.checkVersion("gl2ps", "1.03") >= 0:
            _gl2ps_types.update({"svg": gl2ps.GL2PS_SVG, "pgf": gl2ps.GL2PS_PGF})
        image_formats_gl2ps = _gl2ps_types.keys()
        image_formats_fromeps = ["ppm", "png", "jpeg", "rast", "tiff", "xwd", "y4m"]
    if GD.options.debug:
        print "Qt image types for saving: ", image_formats_qt
        print "Qt image types for input: ", image_formats_qtr
        print "gl2ps image types:", image_formats_gl2ps
        print "image types converted from EPS:", image_formats_fromeps
def check():
    """Warn the user that calpy was not found."""
    if calpy_path is None:
        detect()

    if not utils.hasModule('calpy',check=True):
        GD.warning("Sorry, I can not run this example, because you do not have calpy installed (at least not in a place where I can find it).")
        exit()
def check(trypaths=None):
    """Warn the user that calpy was not found."""
    if calpy_path is None:
        detect(trypaths)

    try:
        import calpy
    except ImportError:
        pass
    
    if not utils.hasModule('calpy',check=True):
        GD.warning("sys.path=%s\nSorry, I can not run this example, because you do not have calpy installed (at least not in a place where I can find it)." % sys.path)
        exit()
Example #4
0
def check(trypaths=None):
    """Warn the user that calpy was not found."""
    if calpy_path is None:
        detect(trypaths)

    try:
        import calpy
    except ImportError:
        pass

    if utils.hasModule('calpy', check=True):
        return True
    else:
        pf.warning(
            "sys.path=%s\nSorry, I can not run this example, because you do not have calpy installed (at least not in a place where I can find it)."
            % sys.path)
        return False
Example #5
0
def initialize():
    """Initialize the image module."""
    global image_formats_qt, image_formats_qtr, image_formats_gl2ps, image_formats_fromeps, gl2ps, _producer, _gl2ps_types

    # Find interesting supporting software
    utils.hasExternal('imagemagick')
    # Set some globals
    pf.debug("Loading Image Formats", pf.DEBUG.IMAGE)
    image_formats_qt = map(str, QtGui.QImageWriter.supportedImageFormats())
    image_formats_qtr = map(str, QtGui.QImageReader.supportedImageFormats())
    ## if pf.cfg.get('imagesfromeps',False):
    ##     pf.image_formats_qt = []

    if utils.hasModule('gl2ps'):

        import gl2ps

        _producer = pf.Version + ' (%s)' % pf.cfg.get('help/website', '')
        _gl2ps_types = {
            'ps': gl2ps.GL2PS_PS,
            'eps': gl2ps.GL2PS_EPS,
            'tex': gl2ps.GL2PS_TEX,
            'pdf': gl2ps.GL2PS_PDF,
        }
        if utils.checkVersion('gl2ps', '1.03') >= 0:
            _gl2ps_types.update({
                'svg': gl2ps.GL2PS_SVG,
                'pgf': gl2ps.GL2PS_PGF,
            })
        image_formats_gl2ps = _gl2ps_types.keys()
        image_formats_fromeps = [
            'ppm', 'png', 'jpeg', 'rast', 'tiff', 'xwd', 'y4m'
        ]
    pf.debug(
        """
Qt image types for saving: %s
Qt image types for input: %s
gl2ps image types: %s
image types converted from EPS: %s""" %
        (image_formats_qt, image_formats_qtr, image_formats_gl2ps,
         image_formats_fromeps), pf.DEBUG.IMAGE | pf.DEBUG.INFO)
Example #6
0
def initialize():
    """Initialize the image module."""
    global image_formats_qt,image_formats_qtr,image_formats_gl2ps,image_formats_fromeps,gl2ps,_producer,_gl2ps_types
    
    # Find interesting supporting software
    utils.hasExternal('ImageMagick')
    # Set some globals
    pf.debug("LOADING IMAGE FORMATS")
    image_formats_qt = map(str,QtGui.QImageWriter.supportedImageFormats())
    image_formats_qtr = map(str,QtGui.QImageReader.supportedImageFormats())
    ## if pf.cfg.get('imagesfromeps',False):
    ##     pf.image_formats_qt = []

    if utils.hasModule('gl2ps'):

        import gl2ps

        _producer = pf.Version + ' (http://pyformex.berlios.de)'
        _gl2ps_types = {
            'ps':gl2ps.GL2PS_PS,
            'eps':gl2ps.GL2PS_EPS,
            'tex':gl2ps.GL2PS_TEX,
            'pdf':gl2ps.GL2PS_PDF,
            }
        if utils.checkVersion('gl2ps','1.03') >= 0:
            _gl2ps_types.update({
                'svg':gl2ps.GL2PS_SVG,
                'pgf':gl2ps.GL2PS_PGF,
                })
        image_formats_gl2ps = _gl2ps_types.keys()
        image_formats_fromeps = [ 'ppm', 'png', 'jpeg', 'rast', 'tiff',
                                     'xwd', 'y4m' ]
    pf.debug("""
Qt image types for saving: %s
Qt image types for input: %s
gl2ps image types: %s
image types converted from EPS: %s""" % (image_formats_qt,image_formats_qtr,image_formats_gl2ps,image_formats_fromeps))
Example #7
0
# $Id$
##
## This file is part of pyFormex 0.5 Release Fri Aug 10 12:04:07 2007
## pyFormex is a Python implementation of Formex algebra
## Website: http://pyformex.berlios.de/
## Copyright (C) Benedict Verhegghe ([email protected]) 
##
## This program is distributed under the GNU General Public License
## version 2 or later (see file COPYING for details)
##
"""Graphical User Interface for pyFormex."""

import globaldata as GD
import sys,utils
if not ( utils.hasModule('numpy') and
         utils.hasModule('pyopengl') and
         utils.hasModule('pyqt4') ):
    sys.exit()

import time,os.path,string,re

from PyQt4 import QtCore, QtGui

import menu
import cameraMenu
import fileMenu
import scriptsMenu
import prefMenu
import toolbar
import viewport
Example #8
0
        msg = checkLibraries()
    
    if msg:
        msg += """
        
I had a problem rebuilding the libraries in %s/lib. 
You should probably exit pyFormex, fix the problem first and then restart pyFormex.
""" % pyformexdir
    startup_warnings += msg

import utils

# intended Python version
minimal_version = '2.5'
target_version = '2.6'
found_version = utils.hasModule('python')


if utils.SaneVersion(found_version) < utils.SaneVersion(minimal_version):
#if utils.checkVersion('python',minimal_version) < 0:
    startup_warnings += """
Your Python version is %s, but pyFormex requires Python >= %s. We advice you to upgrade your Python version. Getting pyFormex to run on Python 2.4 requires only minor adjustements. Lower versions are problematic.
""" % (found_version,minimal_version)
    print startup_warnings
    sys.exit()
    
if utils.SaneVersion(found_version[:3]) > utils.SaneVersion(target_version):
#if utils.checkVersion('python',target_version) > 0:
    startup_warnings += """
Your Python version is %s, but pyFormex has only been tested with Python <= %s. We expect pyFormex to run correctly with your Python version, but if you encounter problems, please contact the developers at pyformex.berlios.de.
""" % (found_version,target_version)
Example #9
0
        GD.debug("Image format can be converted from eps")
        fneps = os.path.splitext(fn)[0] + '.eps'
        delete = not os.path.exists(fneps)
        save_PS(canvas,fneps,'eps')
        if os.path.exists(fneps):
            cmd = 'pstopnm -portrait -stdout %s' % fneps
            if fmt != 'ppm':
                cmd += '| pnmto%s > %s' % (fmt,fn)
            utils.runCommand(cmd)
            if delete:
                os.remove(fneps)

    return sta


if utils.hasModule('gl2ps'):

    import gl2ps

    _producer = GD.Version + ' (http://pyformex.berlios.de)'
    _gl2ps_types = { 'ps':gl2ps.GL2PS_PS, 'eps':gl2ps.GL2PS_EPS,
                     'pdf':gl2ps.GL2PS_PDF, 'tex':gl2ps.GL2PS_TEX }
    image_formats_gl2ps = _gl2ps_types.keys()
    image_formats_fromeps = [ 'ppm', 'png', 'jpeg', 'rast', 'tiff',
                                 'xwd', 'y4m' ]

    def save_PS(canvas,filename,filetype=None,title='',producer='',
               viewport=None):
        """ Export OpenGL rendering to PostScript/PDF/TeX format.

        Exporting OpenGL renderings to PostScript is based on the PS2GL
Example #10
0
        pass

# Set the proper revision number when running from git sources
if pf.installtype == 'G':
    try:
        sta, out, err = utils.system('cd %s && git describe --always' %
                                     pyformexdir)
        if sta == 0:
            pf.__revision__ = out.split('\n')[0].strip()
    except:
        pass

# intended Python version
minimal_version = '2.5'
target_version = '2.7'
found_version = utils.hasModule('python')

if utils.SaneVersion(found_version) < utils.SaneVersion(minimal_version):
    #if utils.checkVersion('python',minimal_version) < 0:
    startup_warnings += """
Your Python version is %s, but pyFormex requires Python >= %s. We advice you to upgrade your Python version. Getting pyFormex to run on Python 2.4 requires only minor adjustements. Lower versions are problematic.
""" % (found_version, minimal_version)
    print(startup_warnings)
    sys.exit()

if utils.SaneVersion(found_version[:3]) > utils.SaneVersion(target_version):
    #if utils.checkVersion('python',target_version) > 0:
    startup_warnings += """
Your Python version is %s, but pyFormex has only been tested with Python <= %s. We expect pyFormex to run correctly with your Python version, but if you encounter problems, please contact the developers at http://pyformex.org.
""" % (
        found_version,