#
##
## This file is part of pyFormex 1.0.7 (Mon Jun 17 12:20:39 CEST 2019)
## pyFormex is a tool for generating, manipulating and transforming 3D
## geometrical models by sequences of mathematical operations.
## Home page: http://pyformex.org
## Project page: http://savannah.nongnu.org/projects/pyformex/
## Copyright 2004-2019 (C) Benedict Verhegghe (benedict.verhegghe@ugent.be)
## Distributed under the GNU General Public License version 3 or later.
##
## 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 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see http://www.gnu.org/licenses/.
##
#
"""Camera tools
Some extra tools to handle the camera.
"""
from __future__ import absolute_import, division, print_function
import pyformex as pf
from pyformex.gui.widgets import simpleInputItem as _I, InputDialog as Dialog
from pyformex.arraytools import stuur
dialog = None
def getCameraSettings(cam):
return dict([(k, getattr(cam, k)) for k in ['focus', 'dist', 'rot', 'fovy', 'aspect', 'area', 'near', 'far']])
def apply():
global dialog
dialog.acceptData()
settings = dialog.results
#print settings
cam = pf.canvas.camera
cam.setClip(settings['near'], settings['far'])
pf.canvas.update()
def close():
global dialog
if dialog:
dialog.close()
dialog = None
def updateSettings(cam):
global dialog
settings = getCameraSettings(cam)
dialog.updateData(settings)
def setNear(fld):
val = fld.value()/100.
cam = pf.canvas.camera
res = stuur(val, [0., 0.5, 1.0], [0.01*cam.dist, cam.dist, 100.*cam.dist])
#print "%s = %s" % (val,res)
cam.setClip(res, cam.far)
pf.canvas.update()
def setFar(fld):
val = fld.value()/100.
cam = pf.canvas.camera
res = stuur(val, [0., 0.5, 1.0], [0.01*cam.dist, cam.dist, 100.*cam.dist])
#print "%s = %s" % (val,res)
cam.setClip(cam.near, res)
pf.canvas.update()
if __name__ == '__draw__':
showCameraTool()
dialog.timeout = close
# End