• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

kalzium

bondcentrictool.h

Go to the documentation of this file.
00001 /**********************************************************************
00002   BondCentricTool - Bond Centric Manipulation Tool for Avogadro
00003 
00004   Copyright (C) 2007 by Shahzad Ali
00005   Copyright (C) 2007 by Ross Braithwaite
00006   Copyright (C) 2007 by James Bunt
00007   Copyright (C) 2007 by Marcus D. Hanwell
00008   Copyright (C) 2006,2007 by Benoit Jacob
00009 
00010   This file is part of the Avogadro molecular editor project.
00011   For more information, see <http://avogadro.sourceforge.net/>
00012 
00013   Avogadro is free software; you can redistribute it and/or modify
00014   it under the terms of the GNU General Public License as published by
00015   the Free Software Foundation; either version 2 of the License, or
00016   (at your option) any later version.
00017 
00018   Avogadro is distributed in the hope that it will be useful,
00019   but WITHOUT ANY WARRANTY; without even the implied warranty of
00020   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021   GNU General Public License for more details.
00022 
00023   You should have received a copy of the GNU General Public License
00024   along with this program; if not, write to the Free Software
00025   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00026   02110-1301, USA.
00027  **********************************************************************/
00028 
00029 #ifndef BONDCENTRICTOOL_H
00030 #define BONDCENTRICTOOL_H
00031 
00032 #include "skeletontree.h"
00033 
00034 #include <avogadro/glwidget.h>
00035 #include <avogadro/tool.h>
00036 
00037 #include <openbabel/mol.h>
00038 
00039 #include <QGLWidget>
00040 #include <QObject>
00041 #include <QStringList>
00042 #include <QImage>
00043 #include <QAction>
00044 #include <QUndoCommand>
00045 
00046 #include <QLabel>
00047 #include <QSpinBox>
00048 #include <QCheckBox>
00049 #include <QGridLayout>
00050 
00051 
00052 namespace Avogadro {
00053 
00063   class BondCentricTool : public Tool
00064   {
00065     Q_OBJECT
00066 
00067     public:
00069       BondCentricTool(QObject *parent = 0);
00071       virtual ~BondCentricTool();
00072 
00074 
00075 
00076       virtual QString name() const { return(tr("Bond Centric Manipulate")); }
00078       virtual QString description() const { return(tr("Bond Centric Manipulation Tool")); }
00080 
00082 
00083 
00084       virtual QUndoCommand* mousePress(GLWidget *widget, const QMouseEvent *event);
00085       virtual QUndoCommand* mouseRelease(GLWidget *widget, const QMouseEvent *event);
00086       virtual QUndoCommand* mouseMove(GLWidget *widget, const QMouseEvent *event);
00087       virtual QUndoCommand* wheel(GLWidget *widget, const QWheelEvent *event);
00089 
00090       virtual int usefulness() const;
00091 
00092       virtual bool paint(GLWidget *widget);
00093 
00094       virtual QWidget *settingsWidget();
00098       virtual void writeSettings(QSettings &settings) const;
00099 
00103       virtual void readSettings(QSettings &settings);
00104 
00111       void setMolecule(Molecule* molecule);
00112 
00113     public Q_SLOTS:
00119       void snapToAngleChanged(int newAngle);
00120 
00130       void snapToCheckBoxChanged(int state);
00131 
00141       void showAnglesChanged(int state);
00142 
00143     protected:
00144       Molecule *          m_molecule;
00145       QWidget *           m_settingsWidget;
00146 
00147 
00148       Atom *              m_clickedAtom;
00149       Bond *              m_clickedBond;
00150       Bond *              m_selectedBond;
00151 
00152       SkeletonTree *      m_skeleton;
00153 
00154       Eigen::Vector3d *   m_referencePoint;
00155       Eigen::Vector3d *   m_currentReference;
00156       Eigen::Vector3d *   m_directionVector;
00157 
00158       bool                m_snapped;
00159       ToolGroup *         m_toolGroup;
00160 
00161       QUndoCommand *      m_undo; // The current undo command
00162 
00163       bool                m_leftButtonPressed;  // rotation
00164       bool                m_midButtonPressed;   // scale / zoom
00165       bool                m_rightButtonPressed; // translation
00166       bool                m_movedSinceButtonPressed;
00167 
00168       bool                m_showAngles;
00169       bool                m_snapToEnabled;
00170 
00171       int                 m_snapToAngle; // In degrees
00172 
00173       QPoint              m_lastDraggingPosition;
00174 
00175       QLabel *            m_snapToAngleLabel;
00176       QLabel *            m_spacer;
00177       QCheckBox *         m_showAnglesBox;
00178       QCheckBox *         m_snapToCheckBox;
00179       QSpinBox *          m_snapToAngleBox;
00180       QGridLayout *       m_layout;
00181 
00183 
00184 
00185 
00196       bool isAtomInBond(Atom *atom, Bond *bond);
00197 
00208       void drawAngleSector(GLWidget *widget, Eigen::Vector3d origin,
00209                            Eigen::Vector3d direction1, Eigen::Vector3d direction2,
00210                            bool alternateAngle = false);
00211 
00219       void drawAtomAngles(GLWidget *widget, Atom *atom);
00220 
00232       void drawAngles(GLWidget *widget, Atom *atom, Bond *bond);
00233 
00242       void drawSkeletonAngles(GLWidget *widget, SkeletonTree *skeleton);
00243 
00244       void drawDihedralAngle(GLWidget *widget, Atom *A, Atom *D, Bond *BC,
00245                              bool alternateAngle = false);
00246 
00247       void drawDihedralAngles(GLWidget *widget, Atom *A, Bond *BC);
00248 
00249       void drawSingleDihedralAngles(GLWidget *widget, Atom *A, Bond *BC);
00250 
00272       Eigen::Vector3d* calculateSnapTo(Bond *bond,  Eigen::Vector3d *referencePoint,
00273                                        double maximumAngle);
00274 
00286       void drawManipulationRectangle(GLWidget *widget, Bond *bond,
00287                                      Eigen::Vector3d *referencePoint, double rgb[3]);
00288 
00289       void drawDihedralRectangle(GLWidget *widget, Bond *bond, Atom *atom, double rgb[3]);
00290 
00291       void drawDihedralRectanglesOfAtom(GLWidget *widget, Bond *bond, Atom *atom,
00292                                         double rgb[3]);
00293 
00302       void drawSphere(GLWidget *widget, const Eigen::Vector3d &center, double radius,
00303                       float alpha);
00305 
00311       void clearData();
00312 
00325       Eigen::Vector3d performRotation(double angle, Eigen::Vector3d rotationVector,
00326                                       Eigen::Vector3d centerVector,
00327                                       Eigen::Vector3d positionVector);
00328 
00329     private Q_SLOTS:
00335       void toolChanged(bool checked);
00336 
00342       void primitiveRemoved(Primitive* primitive);
00343 
00347       void settingsWidgetDestroyed();
00348 
00349   };
00350 
00362   class BondCentricMoveCommand : public QUndoCommand
00363   {
00364     public:
00366 
00372       explicit BondCentricMoveCommand(Molecule *molecule, QUndoCommand *parent = 0);
00373 
00375 
00383       BondCentricMoveCommand(Molecule *molecule, Atom *atom,
00384                              Eigen::Vector3d pos, QUndoCommand *parent = 0);
00385 
00389       void redo();
00390 
00394       void undo();
00395 
00403       bool mergeWith(const QUndoCommand * command);
00404 
00410       int id() const;
00411 
00412     private:
00413       Molecule m_moleculeCopy;
00414       Molecule *m_molecule;
00415       int m_atomIndex;
00416       Eigen::Vector3d m_pos;
00417       bool undone;
00418   };
00419 
00420 
00421   class BondCentricToolFactory : public QObject, public ToolFactory
00422   {
00423     Q_OBJECT
00424     Q_INTERFACES(Avogadro::ToolFactory)
00425 
00426     public:
00427       Tool *createInstance(QObject *parent = 0) { return new BondCentricTool(parent); }
00428   };
00429 
00430 } // end namespace Avogadro
00431 
00432 #endif /*__BONDCENTRICTOOL_H*/

kalzium

Skip menu "kalzium"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal