# vPresent is an immersive presentation creation and display application.
# Copyright (C) 2007-2008 by Infiscape Corporation
#
# 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 2 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, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

import opendocument as od
AI = od.AttributeInfo

class Model(od.DocumentNode):
   __metaclass__ = od.OpenDocumentMeta
   overrides = {'vpresent:filename':AI(doc="Location of the file to be loaded."),
                'dr3d:transform':AI(required=False,
                                    default="1.0 0.0 0.0  0.0 1.0 0.0  0.0 0.0 1.0  0.0 0.0 0.0")
               }
   childTypes = []
   element_name = 'vpresent:model'

class Box(od.DocumentNode):
   __metaclass__ = od.OpenDocumentMeta
   overrides = {'vpresent:width': AI(default=2.0, get=od.getGTZFloat,
                                set=od.setGTZFloat, required=True,
                                doc="Width along x-axis."),
                'vpresent:height': AI(default=2.0, get=od.getGTZFloat,
                                set=od.setGTZFloat, required=True,
                                doc="Height along y-axis."),
                'vpresent:depth': AI(default=2.0, get=od.getGTZFloat,
                                set=od.setGTZFloat, required=True,
                                doc="Depth along z-axis."),
                'vpresent:width-res': AI(default=1,
                                         get=lambda o,rn,d: od.getInteger(o,rn,d,1),
                                         set=lambda o,rn,d: od.setInteger(o,rn,d,1),
                                         required=False, doc="Resolution of width."),
                'vpresent:height-res': AI(default=1,
                                          get=lambda o,rn,d: od.getInteger(o,rn,d,1),
                                          set=lambda o,rn,d: od.setInteger(o,rn,d,1),
                                          required=False,doc="Resolution of height."),
                'vpresent:depth-res': AI(default=1,
                                         get=lambda o,rn,d: od.getInteger(o,rn,d,1),
                                         set=lambda o,rn,d: od.setInteger(o,rn,d,1),
                                         required=False, doc="Resolution of depth."),
                'draw:style-name':AI(required=False, data_types=[u'NCName',]),
                'dr3d:transform':AI(required=False,
                                    default="1.0 0.0 0.0  0.0 1.0 0.0  0.0 0.0 1.0  0.0 0.0 0.0")
               }
   childTypes = []
   element_name = 'vpresent:box'

class Cylinder(od.DocumentNode):
   __metaclass__ = od.OpenDocumentMeta
   overrides = {'vpresent:height': AI(default=5.0, get=od.getGTZFloat,
                                      set=od.setGTZFloat, required=True,
                                      doc="Height along x-axis."),
                'vpresent:radius': AI(default=1.0, get=od.getGTZFloat,
                                      set=od.setGTZFloat, required=True,
                                      doc="Radius of base."),
                'vpresent:num-sides': AI(default=10,
                                     get=lambda o,rn,d: od.getInteger(o,rn,d,3),
                                     set=lambda o,rn,d: od.setInteger(o,rn,d,3),
                                     required=True, doc="Number of sides."),
                'vpresent:show-sides' : AI(default=True, get=od.getBoolean,
                                           set=od.setBoolean, required=False,
                                           doc="Show the sides."),
                'vpresent:show-top' : AI(default=True, get=od.getBoolean,
                                         set=od.setBoolean, required=False,
                                         doc="Show the top."),
                'vpresent:show-bottom' : AI(default=True, get=od.getBoolean,
                                            set=od.setBoolean, required=False,
                                            doc="Show the bottom."),
                'draw:style-name':AI(required=False, data_types=[u'NCName',]),
                'dr3d:transform':AI(required=False,
                                    default="1.0 0.0 0.0  0.0 1.0 0.0  0.0 0.0 1.0  0.0 0.0 0.0")
               }
   childTypes = []
   element_name = 'vpresent:cylinder'


class Billboard(od.DocumentNode):
   __metaclass__ = od.OpenDocumentMeta
   overrides = {'vpresent:width': AI(default=10.0, get=od.getGTZFloat,
                                set=od.setGTZFloat, required=True,
                                doc="Width along x-axis."),
                'vpresent:height': AI(default=10.0, get=od.getGTZFloat,
                                set=od.setGTZFloat, required=True,
                                doc="Height along y-axis."),
                'vpresent:width-res': AI(default=1,
                                         get=lambda o,rn,d: od.getInteger(o,rn,d,1),
                                         set=lambda o,rn,d: od.setInteger(o,rn,d,1),
                                         required=False, doc="Resolution of width."),
                'vpresent:height-res': AI(default=1,
                                          get=lambda o,rn,d: od.getInteger(o,rn,d,1),
                                          set=lambda o,rn,d: od.setInteger(o,rn,d,1),
                                          required=False,doc="Resolution of height."),
                'draw:style-name':AI(required=False, data_types=[u'NCName',]),
                'dr3d:transform':AI(required=False,
                                    default="1.0 0.0 0.0  0.0 1.0 0.0  0.0 0.0 1.0  0.0 0.0 0.0")
               }
   childTypes = []
   element_name = 'vpresent:billboard'

class Fisheye(od.DocumentNode):
   __metaclass__ = od.OpenDocumentMeta
   childTypes = []
   element_name = 'vpresent:fisheye'
   overrides = {'dr3d:size': AI(default=10.0, get=od.getGTZFloat,
                                set=od.setGTZFloat, required=True,
                                doc="Radius of the fisheye."),
                'vpresent:latres': AI(default=50,
                                      get=lambda o,rn,d: od.getInteger(o,rn,d,4),
                                      set=lambda o,rn,d: od.setInteger(o,rn,d,4),
                                      required=False, doc="Latitude resolution."),
                'vpresent:lonres': AI(default=50,
                                      get=lambda o,rn,d: od.getInteger(o,rn,d,4),
                                      set=lambda o,rn,d: od.setInteger(o,rn,d,4),
                                      required=False, doc="Longitude resolution."),
                'vpresent:span':
                  AI(default=180.0,
                     get=lambda o,rn,d:od.getFloat(o,rn,d,0.0,360.0),
                     set=lambda o,rn,d:od.setFloat(o,rn,d,0.0,360.0),
                     required=False, doc="Span of fisheye."),
                'draw:style-name':AI(required=False, data_types=[u'NCName',]),
                'dr3d:transform':AI(required=False,
                                    default="1.0 0.0 0.0  0.0 1.0 0.0  0.0 0.0 1.0  0.0 0.0 0.0")
                }

class Page3dProperties(od.DocumentNode):
   __metaclass__ = od.OpenDocumentMeta
   element_name = 'vpresent:page3d-properties'
   overrides = {}
   childTypes = ['vpresent:sphere-background', 'vpresent:cylinder-background']

class SphereBackground(od.DocumentNode):
   __metaclass__ = od.OpenDocumentMeta
   element_name = 'vpresent:sphere-background'
   childTypes = [u'dr3d:sphere',u'vpresent:fill-image-ref']
   # cubic requires six fill-image-refs
   #    order: negx, posx, negy, posy, negz, posz.
   # mercator requries one fill-image-ref
   overrides = {'vpresent:type':AI(default='mercator', required=True, values=['mercator', 'cubic']),}

class FillImageRef(od.DocumentNode):
   __metaclass__ = od.OpenDocumentMeta
   element_name = 'vpresent:fill-image-ref'
   childTypes = []
   overrides = {'draw:fill-image-name':AI(required=False, data_types=[u'NCName',]),
                'vpresent:order':AI(required=False, get=od.getPositiveInteger,
                                    set=od.setPositiveInteger),
                'vpresent:mirror':AI(values=['none', 'horizontal', 'vertical','both'], default='none')
               }

class CylinderBackground(od.DocumentNode):
   __metaclass__ = od.OpenDocumentMeta
   element_name = 'vpresent:cylinder-background'
   childTypes = [u'vpresent:cylinder', u'vpresent:fill-image-ref']
   overrides = {}

class CylinderPanorama(od.DocumentNode):
   __metaclass__ = od.OpenDocumentMeta
   element_name = 'vpresent:cylinder-panorama'
   childTypes = [u'vpresent:fill-image-ref',]
   overrides = {'vpresent:height': AI(default=10.0, get=od.getGTZFloat,
                                      set=od.setGTZFloat, required=True,
                                      doc="Height along x-axis."),
                'vpresent:radius': AI(default=5.0, get=od.getGTZFloat,
                                      set=od.setGTZFloat, required=True,
                                      doc="Radius of base."),
                'vpresent:start-arc':
                     AI(default=0.0,
                        get=lambda o,rn,d:od.getFloat(o,rn,d,0.0,360.0),
                        set=lambda o,rn,d:od.setFloat(o,rn,d,0.0,360.0),
                        required=True, doc="Starting arc in degrees."),
                'vpresent:end-arc':
                     AI(default=360.0,
                        get=lambda o,rn,d:od.getFloat(o,rn,d,0.0,360.0),
                        set=lambda o,rn,d:od.setFloat(o,rn,d,0.0,360.0),
                        required=True, doc="End arc in degrees."),
                'vpresent:num-sides-per-texture':
                     AI(default=10,
                        get=lambda o,rn,d: od.getInteger(o,rn,d,1),
                        set=lambda o,rn,d: od.setInteger(o,rn,d,1),
                        required=True, doc="Number of sides."),
                'dr3d:transform':AI(required=False,
                                    default="1.0 0.0 0.0  0.0 1.0 0.0  0.0 0.0 1.0  0.0 0.0 0.0")
               }
