Avogadro
1.1.0
|
Widget to edit 3x3 matrices in plain text. More...
#include <avogadro/textmatrixeditor.h>
Public Slots | |
void | setMatrix (const Eigen::Matrix3d &mat) |
Set the matrix. This will update the text. | |
void | resetMatrix () |
Reset the text to the last known good matrix. | |
Signals | |
void | isInvalid () |
Emitted when the text cannot be parsed into a matrix. | |
void | isValid () |
Emitted when the text has been parsed into a matrix. | |
Public Member Functions | |
TextMatrixEditor (QWidget *parent=0) | |
Constructor. | |
virtual | ~TextMatrixEditor () |
Destructor. | |
QRegExp * | delimiters () |
const QRegExp * | delimiters () const |
Eigen::Matrix3d | matrix () const |
Protected Slots | |
bool | validate () |
void | markAsInvalid () |
Turn the text red. | |
void | markAsValid () |
Reset the text appearance. | |
Protected Attributes | |
QTextCharFormat * | m_charFormat |
Stores the text properties while invalid. | |
QRegExp * | m_delimiters |
Acceptable column separators. See class definition for default. | |
Eigen::Matrix3d | m_matrix |
Stores the current (or last known good) matrix. |
Widget to edit 3x3 matrices in plain text.
TextMatrixEditor is a QTextEdit that displays and allows editing of a 3x3 matrix as plain text. Input is validated with each keystroke, and the text turns red if the input is invalid. The matrix can be set/get with matrix() and setMatrix(). The delimiters used to separate columns can be set and accessed through the pointer returned by delimiters(). The default delimiter regexp is QRegExp("\\s+|,|;|\\||\[|\]|\\{|\\}|\(|\)|\\&|/|<|>"). resetMatrix() will replace the text with the last known good matrix.
QRegExp* Avogadro::TextMatrixEditor::delimiters | ( | ) | [inline] |
const QRegExp* Avogadro::TextMatrixEditor::delimiters | ( | ) | const [inline] |
Eigen::Matrix3d Avogadro::TextMatrixEditor::matrix | ( | ) | const |
References m_matrix.
bool Avogadro::TextMatrixEditor::validate | ( | ) | [protected, slot] |
Check if input can be parsed. Sets m_matrix, emits isValid(), and returns true if so. Otherwise emits isInvalid() and returns false.
References QList::append(), QList::at(), QTextCursor::clearSelection(), QTextEdit::document(), isInvalid(), isValid(), m_delimiters, m_matrix, QTextEdit::setTextCursor(), QList::size(), QString::split(), QTextEdit::text(), QTextEdit::textCursor(), and QTextDocument::toPlainText().
Referenced by TextMatrixEditor().