00001 // -*- C++ -*- 00002 00003 /* 00004 * Gnome Chemistry Utils 00005 * crystalview.h 00006 * 00007 * Copyright (C) 2002-2004 00008 * 00009 * Developed by Jean Bréfort <jean.brefort@normalesup.org> 00010 * 00011 * This library is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU Lesser General Public 00013 * License as published by the Free Software Foundation; either 00014 * version 2.1 of the License, or (at your option) any later version. 00015 * 00016 * This library 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 GNU 00019 * Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public License 00022 * along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00024 * USA 00025 */ 00026 00027 #ifndef CRYSTAL_VIEW_H 00028 #define CRYSTAL_VIEW_H 00029 00030 #include <libxml/parser.h> 00031 #include <gcu/matrix.h> 00032 #include <list> 00033 #include <gtk/gtkwidget.h> 00034 00035 using namespace std; 00036 00037 namespace gcu 00038 { 00039 class CrystalDoc; 00040 00046 class CrystalView 00047 { 00048 public: 00050 00055 CrystalView (CrystalDoc* pDoc); 00057 00060 virtual ~CrystalView (); 00061 00066 GtkWidget* CreateNewWidget (); 00072 void Init (GtkWidget *widget); 00078 void Reshape (GtkWidget *widget); 00084 void Draw (GtkWidget *widget); 00088 void Update (); 00094 void Update (GtkWidget *widget); 00101 bool OnPressed (GtkWidget *widget, GdkEventButton *event); 00108 void OnMotion (GtkWidget *widget, GdkEventMotion *event); 00114 void OnDestroyed (GtkWidget *widget); 00115 00121 virtual bool Load (xmlNodePtr node); 00126 virtual xmlNodePtr Save (xmlDocPtr xml); 00127 00128 private: 00135 void Rotate (gdouble x, gdouble y); 00136 00137 protected: 00141 gdouble m_fAngle; 00145 gdouble m_fRadius; 00149 gdouble m_psi; 00153 gdouble m_theta; 00157 gdouble m_phi; 00161 gdouble m_height; 00165 gdouble m_width; 00169 gdouble m_near; 00170 /* 00171 The distance of the back plane delimiting the volume active in the OpenGL representation to the viewer. 00172 */ 00173 gdouble m_far; 00177 Matrix m_Euler; 00181 unsigned m_nGLList; 00182 //background color 00186 float m_fBlue; 00190 float m_fRed; 00194 float m_fGreen; 00198 float m_fAlpha; 00202 CrystalDoc* m_pDoc; 00206 GtkWidget* m_pWidget; 00207 00208 private: 00209 bool m_bInit; 00210 gdouble m_lastx, m_lasty; 00211 list<GtkWidget*> m_Widgets; 00212 }; 00213 00214 } //namespace gcu 00215 00216 #endif //CRYSTAL_VIEW_H