Avogadro  1.1.0
/home/kitware/dashboards/avogadro/libavogadro/src/primitive.h
00001 /**********************************************************************
00002   Primitive - Wrapper class around the OpenBabel classes
00003 
00004   Copyright (C) 2007 Donald Ephraim Curtis
00005   Copyright (C) 2008 Marcus D. Hanwell
00006 
00007   This file is part of the Avogadro molecular editor project.
00008   For more information, see <http://avogadro.openmolecules.net/>
00009 
00010   Avogadro is free software; you can redistribute it and/or modify
00011   it under the terms of the GNU General Public License as published by
00012   the Free Software Foundation; either version 2 of the License, or
00013   (at your option) any later version.
00014 
00015   Avogadro is distributed in the hope that it will be useful,
00016   but WITHOUT ANY WARRANTY; without even the implied warranty of
00017   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018   GNU General Public License for more details.
00019 
00020   You should have received a copy of the GNU General Public License
00021   along with this program; if not, write to the Free Software
00022   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00023   02110-1301, USA.
00024  **********************************************************************/
00025 
00026 #ifndef PRIMITIVE_H
00027 #define PRIMITIVE_H
00028 
00029 #include "global.h"
00030 
00031 #include <QObject>
00032 #include <QMetaType>
00033 
00034 #include <Eigen/Core>
00035 #include <limits> // To get the maximum size of long for FALSE_ID
00036 
00037 namespace Avogadro {
00038 
00039   // Define the overflow resulting from long (-1) as the error/not found
00040   const unsigned long FALSE_ID = std::numeric_limits<unsigned long>::max();
00041 
00047   class PrimitivePrivate;
00048   class A_EXPORT Primitive : public QObject
00049   {
00050   Q_OBJECT
00051   Q_PROPERTY(Type type READ type)
00052   Q_ENUMS(Type)
00053 
00054   public:
00059     enum Type {
00061       OtherType=0,
00063       MoleculeType,
00065       AtomType,
00067       BondType,
00069       ResidueType,
00071       ChainType,
00073       FragmentType,
00075       SurfaceType,
00077       MeshType,
00079       CubeType,
00081       PlaneType,
00083       GridType,
00085       PointType,
00087       LineType,
00089       VectorType,
00091       NonbondedType,
00093       TextType,
00095       LastType,
00097       FirstType=OtherType
00098     };
00099 
00104     Primitive(QObject *parent = 0);
00105 
00111     explicit Primitive(Type type, QObject *parent=0);
00112 
00116     virtual ~Primitive();
00117 
00127     void update();
00128 
00137     Type type() const;
00138 
00142     unsigned long id() const { return m_id; }
00143 
00148     unsigned long index() const { return m_index; }
00149 
00150   Q_SIGNALS:
00154     void updated();
00155 
00156   protected:
00161     void setId(unsigned long m_id);
00162 
00167     void setIndex(unsigned long m_index);
00168 
00169     PrimitivePrivate * const d_ptr;
00170     Primitive(PrimitivePrivate &dd, QObject *parent = 0);
00171     Primitive(PrimitivePrivate &dd, Type type, QObject *parent=0);
00172 
00173     enum Primitive::Type m_type;
00174     unsigned long m_id;
00175     unsigned long m_index;
00176 
00177   private:
00178     Q_DECLARE_PRIVATE(Primitive)
00179   };
00180 
00181 } // namespace Avogadro
00182 
00183 Q_DECLARE_METATYPE(Avogadro::Primitive*)
00184 
00185 #endif // PRIMITIVE_H