libavogadro/src/boxcontrol.h

00001 /**********************************************************************
00002   BoxControl - Mouse control over the size of a cube/surface
00003 
00004   Copyright (C) 2008 Tim Vandermeersch
00005   Copyright (c) 2008-2009 Marcus D. Hanwell
00006   Copyright (c) 2009 Geoff Hutchison
00007 
00008   This file is part of the Avogadro molecular editor project.
00009   For more information, see <http://avogadro.openmolecules.net/>
00010 
00011   Avogadro is free software; you can redistribute it and/or modify
00012   it under the terms of the GNU General Public License as published by
00013   the Free Software Foundation; either version 2 of the License, or
00014   (at your option) any later version.
00015 
00016   Avogadro is distributed in the hope that it will be useful,
00017   but WITHOUT ANY WARRANTY; without even the implied warranty of
00018   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019   GNU General Public License for more details.
00020 
00021   You should have received a copy of the GNU General Public License
00022   along with this program; if not, write to the Free Software
00023   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00024   02110-1301, USA.
00025  **********************************************************************/
00026 
00027 #ifndef BOXCONTROL_H
00028 #define BOXCONTROL_H
00029 
00030 #include <avogadro/global.h>
00031 
00032 #include <QVector>
00033 #include <QPoint>
00034 
00035 #include <Eigen/Core>
00036 
00037 class QMouseEvent;
00038 
00039 namespace Avogadro {
00040 
00041   class Line;
00042   class Point;
00043 
00044   class A_EXPORT BoxControl : public QObject
00045   {
00046     Q_OBJECT
00047 
00048   public:
00052     BoxControl();
00056     ~BoxControl();
00060     void addPrimitives();
00064     void removePrimitives();
00069     bool isModified() const { return m_modified; }
00073     void setModified(bool value) { m_modified = value; }
00079     void setOppositeCorners(const Eigen::Vector3d &p1, const Eigen::Vector3d &p2);
00083     Eigen::Vector3d min() { return m_min; }
00087     Eigen::Vector3d max() { return m_max; }
00088   signals:
00093     void modified();
00094 
00095   public slots:
00096     // Handle points clicking...
00097     void mousePressEvent(Point *point, QMouseEvent * event);
00098     void mouseMoveEvent(Point *point, QMouseEvent * event);
00099     void mouseReleaseEvent(Point *point, QMouseEvent * event);
00100 
00101   private:
00105     void updatePrimitives();
00106 
00107     Eigen::Vector3d m_min, m_max;
00108     QVector<Point*> m_points;
00109     QVector<Line*>  m_lines;
00110     QPoint          m_lastDraggingPosition;
00111     bool            m_modified;
00112     bool            m_added;
00113   };
00114 
00115 } // end namespace Avogadro
00116 
00117 #endif

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