00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00020
00021 #ifndef GLSIMPLEMOLECULEVIEW_H
00022 #define GLSIMPLEMOLECULEVIEW_H
00023
00025
00026
00027 #include <vector>
00028
00029
00030 class QDomElement;
00031 #include <qfont.h>
00032
00033
00034 class AtomSet;
00035
00036
00037 #include "glmoleculeparameters.h"
00038 #include "glview.h"
00039
00040 class GLSimpleMoleculeView : public GLView
00041 {
00042 Q_OBJECT
00043
00044 public:
00046 GLSimpleMoleculeView(AtomSet* atomset, QWidget* parent=0, const char* name=0);
00047 ~GLSimpleMoleculeView();
00048
00050 enum DisplayStyle{None, Lines, Tubes, BallAndStick, VanDerWaals};
00051
00052 enum DisplaySource{Molecule, Forces};
00053
00055 unsigned int displayStyle(const DisplaySource source) const;
00056 bool isShowingElements() const;
00057 bool isShowingNumbers() const;
00058 bool isShowingCharges(const unsigned int type) const;
00059 unsigned int selectedAtoms() const;
00060 void loadCML(QDomElement* root);
00061 void saveCML(QDomElement* root);
00062 void setDisplayStyle(const DisplaySource source, const unsigned int style);
00063 void setLabels(const bool element, const bool number, const unsigned int type);
00064
00066 static void setParameters(GLMoleculeParameters params);
00067
00068 public slots:
00069 void updateAtomSet(const bool reset = false);
00070 void selectAll(const bool update = true);
00071 void unselectAll(const bool update = true);
00072
00073 protected slots:
00074 void reorderShapes();
00075
00076 protected:
00078 enum SelectionType{SELECTION_NONE, SELECTION_ATOM, SELECTION_BOND, SELECTION_ANGLE, SELECTION_TORSION, SELECTION_GROUP,
00079 SELECTION_BONDS, SELECTION_FORCES};
00080
00081 enum ShapeTypes{SHAPE_ATOMS, SHAPE_BONDS, SHAPE_FORCES, SHAPE_LABELS, SHAPE_IC, SHAPE_SELECTION, SHAPE_NEXT};
00082
00084 virtual void keyPressEvent(QKeyEvent* e);
00085 virtual void initializeGL();
00086 virtual void drawItem(const unsigned int);
00087 virtual void updateGLSettings();
00088 virtual float boundingSphereRadius();
00089 void clicked(const QPoint& position);
00090 virtual void updateShapes();
00091
00093 struct ShapeProperties
00095 {
00096 unsigned int id;
00097 unsigned int opacity;
00098 unsigned int type;
00099 bool operator<(ShapeProperties prop) const
00101 {
00102 return opacity > prop.opacity;
00103 }
00104 };
00105
00107 GLfloat centerX;
00108 GLfloat centerY;
00109 GLfloat centerZ;
00110 unsigned int selectionType;
00111 std::list<unsigned int> selectionList;
00112 std::vector<ShapeProperties> shapes;
00113
00115 static GLMoleculeParameters moleculeParameters;
00116
00117 private:
00119 enum Directions{DIRECTION_X, DIRECTION_Y, DIRECTION_Z};
00120 enum StartIndices{START_ATOMS = 100, START_BONDS = 1, START_FORCES = 2, START_SELECTEDATOMS = 3, START_SELECTEDBONDS = 4};
00121
00123 GLuint makeObjects(const int numSlices);
00124 void changeObjects(const GLuint startList, const int numSlices);
00125 void selectEntity(const QPoint position);
00126 void processSelection(const unsigned int id);
00127 void centerMolecule();
00128 void drawScene();
00129 void drawAtoms();
00130 void drawBonds();
00131 void drawLabels();
00132 void drawForces();
00133 void drawICValue();
00134 void drawSelections();
00135
00137 int atomObject;
00138 int bondObject;
00139 int forceObjectLines;
00140 int forceObjectTubes;
00141 unsigned int moleculeStyle;
00142 unsigned int forcesStyle;
00143 bool showElements;
00144 bool showNumbers;
00145 unsigned int chargeType;
00146 AtomSet* atoms;
00147 GLfloat selectionLineWidth;
00148 GLfloat selectionPointSize;
00149 float scaleFactor;
00150 QFont labelFont;
00151
00152
00153 static const float cylinderHeight;
00154
00155 };
00156
00157 #endif
00158