libavogadro/src/line.h

00001 /**********************************************************************
00002   Line - Line class derived from the base Primitive class
00003 
00004   Copyright (C) 2008 Tim Vandermeersch
00005 
00006   This file is part of the Avogadro molecular editor project.
00007   For more information, see <http://avogadro.openmolecules.net/>
00008 
00009   Avogadro is free software; you can redistribute it and/or modify
00010   it under the terms of the GNU General Public License as published by
00011   the Free Software Foundation; either version 2 of the License, or
00012   (at your option) any later version.
00013 
00014   Avogadro is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017   GNU General Public License for more details.
00018 
00019   You should have received a copy of the GNU General Public License
00020   along with this program; if not, write to the Free Software
00021   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00022   02110-1301, USA.
00023  **********************************************************************/
00024 
00025 #ifndef LINE_H
00026 #define LINE_H
00027 
00028 #include <avogadro/primitive.h>
00029 #include <avogadro/color.h>
00030 
00031 #include <QList>
00032 #include <QMouseEvent>
00033 
00034 namespace Avogadro {
00035 
00044   class LinePrivate;
00045   class A_EXPORT Line : public Primitive
00046   {
00047     Q_OBJECT
00048 
00049     public:
00055       Line(QObject *parent=0);
00056 
00057       ~Line();
00058 
00063       inline const Eigen::Vector3d &begin () const
00064       {
00065         return m_begin;
00066       }
00067 
00072       inline const Eigen::Vector3d &end () const
00073       {
00074         return m_end;
00075       }
00076 
00081       inline void setBegin(const Eigen::Vector3d &vec)
00082       {
00083         m_begin = vec;
00084       }
00085 
00090       inline void setEnd(const Eigen::Vector3d &vec)
00091       {
00092         m_end = vec;
00093       }
00094 
00098       double width() const 
00099       {
00100         return m_width;
00101       }
00105       void setWidth(double value)
00106       {
00107         m_width = value;
00108       }
00109  
00113       const Color* color()
00114       {
00115         return &m_color;
00116       }
00120       void setColor(const Color &color)
00121       {
00122         float red = color.red();
00123         float green = color.green();
00124         float blue = color.blue();
00125         float alpha = color.alpha();
00126         m_color.set(red, green, blue, alpha);
00127       }
00128 
00129       void mousePressed(QMouseEvent *event) { emit mousePressEvent(this, event); }
00130       void mouseMoved(QMouseEvent *event) { emit mouseMoveEvent(this, event); }
00131       void mouseReleased(QMouseEvent *event) { emit mouseReleaseEvent(this, event); }
00132     signals:
00133       void mousePressEvent(Line *line, QMouseEvent * event);
00134       void mouseMoveEvent(Line *line, QMouseEvent * event);
00135       void mouseReleaseEvent(Line *line, QMouseEvent * event);
00136 
00137     private:
00138       Eigen::Vector3d m_begin;
00139       Eigen::Vector3d m_end;
00140       double          m_width;
00141       Color           m_color;
00142       Q_DECLARE_PRIVATE(Line)
00143   };
00144 
00145 } // End namespace Avoagdro
00146 
00147 #endif

Generated on Sat May 30 02:00:38 2009 for Avogadro by  doxygen 1.5.4