Avogadro  1.1.0
/home/kitware/dashboards/avogadro/libavogadro/src/textmatrixeditor.h
00001 /**********************************************************************
00002   TextMatrixEditor - Text editor that edits 3x3 matrices
00003 
00004   Copyright (C) 2011 David C. Lonie
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 TEXTMATRIXEDITOR_H
00026 #define TEXTMATRIXEDITOR_H
00027 
00028 #include <avogadro/global.h> // For A_EXPORT
00029 
00030 #include <QtGui/QTextEdit>
00031 
00032 #include <Eigen/Core>
00033 
00034 class QRegExp;
00035 
00036 namespace Avogadro
00037 {
00038 
00053 class A_EXPORT TextMatrixEditor : public QTextEdit
00054 {
00055   Q_OBJECT
00056 public:
00058   explicit TextMatrixEditor(QWidget *parent = 0);
00060   virtual ~TextMatrixEditor();
00061 
00063   QRegExp * delimiters() {return this->m_delimiters;}
00065   const QRegExp * delimiters() const {return this->m_delimiters;}
00066 
00068   Eigen::Matrix3d matrix() const;
00069 
00070 signals:
00072   void isInvalid();
00074   void isValid();
00075 
00076 public slots:
00078   void setMatrix(const Eigen::Matrix3d &mat);
00080   void resetMatrix();
00081 
00082 protected slots:
00087   bool validate();
00088 
00090   void markAsInvalid();
00091 
00093   void markAsValid();
00094 
00095 protected:
00097   QTextCharFormat *m_charFormat;
00099   QRegExp *m_delimiters;
00101   Eigen::Matrix3d m_matrix;
00102 };
00103 
00104 } // namespace Avogadro
00105 
00106 #endif // TEXTMATRIXEDITOR_H