From 47d455dd55be855e4cc691c32f687f723d9247ee Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kpovmodeler/pmpoint.h | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 kpovmodeler/pmpoint.h (limited to 'kpovmodeler/pmpoint.h') diff --git a/kpovmodeler/pmpoint.h b/kpovmodeler/pmpoint.h new file mode 100644 index 00000000..729d60c0 --- /dev/null +++ b/kpovmodeler/pmpoint.h @@ -0,0 +1,122 @@ +//-*-C++-*- +/* +************************************************************************** + description + -------------------- + copyright : (C) 2000-2001 by Andreas Zehender + email : zehender@kde.org +************************************************************************** + +************************************************************************** +* * +* 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. * +* * +**************************************************************************/ + + +#ifndef PMPOINT_H +#define PMPOINT_H + +#include "GL/gl.h" +#include + +class PMVector; +class PMMatrix; + +/** + * Class for 3d points. + * + * Used in @ref PMViewStructure. + * + * Optimized for rendering with opengl + */ + +class PMPoint +{ +public: + /** + * Creates a point with coordinates [0,0,0] + */ + PMPoint( ); + /** + * Creates a point with coordinates [x,y,z] + */ + PMPoint( GLdouble x, GLdouble y, GLdouble z ); + /** + * Creates a point from a vector. The size of the vector has to be 3 + */ + PMPoint( const PMVector& v ); + /** + * Copy constructor + */ + PMPoint( const PMPoint& p ); + + /** + * Returns a reference to a coordinate, 0:x, 1:y, 2:z + */ + GLdouble& operator[] ( int index ) { return m_coord[index];} + /** + * Returns a reference to a coordinate, 0:x, 1:y, 2:z + */ + const GLdouble& operator[] ( int index ) const { return m_coord[index];} + + /** + * Returns the x coordinate + */ + GLdouble x( ) const { return m_coord[0]; } + /** + * Returns the y coordinate + */ + GLdouble y( ) const { return m_coord[1]; } + /** + * Returns the z coordinate + */ + GLdouble z( ) const { return m_coord[2]; } + + /** + * Sets the x coordinate + */ + void setX( const GLdouble newx ) { m_coord[0] = newx; } + /** + * Sets the y coordinate + */ + void setY( const GLdouble newy ) { m_coord[1] = newy; } + /** + * Sets the z coordinate + */ + void setZ( const GLdouble newz ) { m_coord[2] = newz; } + + /** + * Transforms the point p with the matrix m + * @see transform + */ + friend PMPoint operator* ( const PMMatrix& m, const PMPoint& p ); + /** + * Assigns c to the point + */ + PMPoint& operator= ( const PMPoint& c ); + /** + * Transforms the point with the matrix m. Same as p = m * p + * + * size must be 3! + */ + void transform( const PMMatrix& m ); + +private: + /** + * The coords. THIS MEMBER HAS TO BE THE FIRST AND ONLY ONE + * (for rendering with OpenGL)! + */ + GLdouble m_coord[3]; +}; + +/** + * @ref QMemArray of PMPoints + */ +typedef QMemArray PMPointArray; + + +#endif -- cgit v1.2.3