Warning, file /office/calligra/libs/odf/Ko3dScene.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  *
0003  * Copyright (C) 2012 Inge Wallin <inge@lysator.liu.se>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #ifndef KO3DSCENE_H
0022 #define KO3DSCENE_H
0023 
0024 // Qt
0025 #include <QColor>
0026 #include <QVector3D>
0027 
0028 class KoXmlWriter;
0029 class KoXmlElement;
0030 
0031 
0032 /** A scene in which to show 3d objects.
0033  *
0034  * The scene parameters include camera parameters (origin, direction
0035  * and up direction), the projection to be used and a shadow
0036  * slant. All these are attributes of the element.
0037  *
0038  * The scene can also have a number of light sources as child
0039  * elements.  These are picked up from the XML element but others are
0040  * ignored and have to be loaded by code that handles the actual
0041  * element.
0042  *
0043  * In ODF 1.2, a scene description can be part of a dr3d:scene or
0044  * chart:plot-area if the chart also has 3D mode set.
0045  */
0046 
0047 
0048 #include "koodf_export.h"
0049 
0050 
0051 class KOODF_EXPORT Ko3dScene
0052 {
0053 public:
0054     enum Projection {
0055         Parallel,
0056         Perspective
0057     };
0058 
0059     enum Shademode {
0060         Flat,
0061         Gouraud,
0062         Phong,
0063         Draft                   // Wireframe
0064     };
0065 
0066     class Lightsource
0067     {
0068     public:
0069         Lightsource();
0070         ~Lightsource();
0071 
0072         bool loadOdf(const KoXmlElement &lightElement);
0073         void saveOdf(KoXmlWriter &writer) const;
0074 
0075         // getters
0076         QColor diffuseColor() const;
0077         QVector3D direction() const;
0078         bool enabled() const;
0079         bool specular() const;
0080 
0081         // setters
0082         void setDiffuseColor(const QColor &color);
0083         void setDirection(const QVector3D &direction);
0084         void setEnabled(const bool enabled);
0085         void setSpecular(const bool specular);
0086 
0087     private:
0088         QColor m_diffuseColor;
0089         QVector3D  m_direction;
0090         bool m_enabled;
0091         bool m_specular;
0092     };
0093 
0094     Ko3dScene();
0095     ~Ko3dScene();
0096 
0097     bool loadOdf(const KoXmlElement &sceneElement);
0098     void saveOdfAttributes(KoXmlWriter &writer) const;
0099     void saveOdfChildren(KoXmlWriter &writer) const;
0100 
0101     // getters
0102     QVector3D vrp() const;
0103     QVector3D vpn() const;
0104     QVector3D vup() const;
0105     Projection projection() const;
0106     QString distance() const;
0107     QString focalLength() const;
0108     QString shadowSlant() const;
0109     Shademode shadeMode() const;
0110     QColor ambientColor() const;
0111     bool lightingMode() const;
0112     QString transform() const;
0113 
0114     // setters
0115     void setVrp(const QVector3D &vrp);
0116     void setVpn(const QVector3D &vpn);
0117     void setVup(const QVector3D &vup);
0118     void setProjection(Projection projection);
0119     void setDistance(const QString &distance);
0120     void setFocalLength(const QString &focalLength);
0121     void setShadowSlant(const QString &shadowSlant);
0122     void setShadeMode(Shademode shadeMode);
0123     void setAmbientColor(const QColor &ambientColor);
0124     void setLightingMode(bool lightingMode);
0125     void setTransform(const QString &transform);
0126 
0127 private:
0128     class Private;
0129     Private * const d;
0130 };
0131 
0132 Q_DECLARE_TYPEINFO(Ko3dScene::Lightsource, Q_MOVABLE_TYPE);
0133 
0134 
0135 /** Try to load a 3d scene from an element and return a pointer to a
0136  * Ko3dScene if it succeeded.
0137  */
0138 KOODF_EXPORT Ko3dScene *load3dScene(const KoXmlElement &element);
0139 
0140 
0141 #endif