00001 // -*- C++ -*- 00002 00003 /* 00004 * Gnome Chemistry Utils 00005 * crystalview.h 00006 * 00007 * Copyright (C) 2002-2004 Jean Bréfort <jean.brefort@normalesup.org> 00008 * 00009 * This program is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License as 00011 * published by the Free Software Foundation; either version 2 of the 00012 * License, or (at your option) any later version. 00013 * 00014 * This program 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 St, Fifth Floor, Boston, MA 02110-1301 00022 * USA 00023 */ 00024 00025 #ifndef CRYSTAL_VIEW_H 00026 #define CRYSTAL_VIEW_H 00027 00028 #include <libxml/parser.h> 00029 #include <gcu/matrix.h> 00030 #include <list> 00031 #include <gtk/gtkwidget.h> 00032 00033 using namespace std; 00034 00035 namespace gcu 00036 { 00037 class CrystalDoc; 00038 00044 class CrystalView 00045 { 00046 public: 00048 00053 CrystalView (CrystalDoc* pDoc); 00055 00058 virtual ~CrystalView (); 00059 00064 GtkWidget* CreateNewWidget (); 00070 void Init (GtkWidget *widget); 00076 void Reshape (GtkWidget *widget); 00082 void Draw (GtkWidget *widget); 00086 void Update (); 00092 void Update (GtkWidget *widget); 00099 bool OnPressed (GtkWidget *widget, GdkEventButton *event); 00106 void OnMotion (GtkWidget *widget, GdkEventMotion *event); 00112 void OnDestroyed (GtkWidget *widget); 00113 00119 virtual bool Load (xmlNodePtr node); 00124 virtual xmlNodePtr Save (xmlDocPtr xml); 00125 00126 private: 00133 void Rotate (gdouble x, gdouble y); 00134 00135 protected: 00139 gdouble m_fAngle; 00143 gdouble m_fRadius; 00147 gdouble m_psi; 00151 gdouble m_theta; 00155 gdouble m_phi; 00159 gdouble m_height; 00163 gdouble m_width; 00167 gdouble m_near; 00168 /* 00169 The distance of the back plane delimiting the volume active in the OpenGL representation to the viewer. 00170 */ 00171 gdouble m_far; 00175 Matrix m_Euler; 00179 unsigned m_nGLList; 00180 //background color 00184 float m_fBlue; 00188 float m_fRed; 00192 float m_fGreen; 00196 float m_fAlpha; 00200 CrystalDoc* m_pDoc; 00204 GtkWidget* m_pWidget; 00205 00206 private: 00207 bool m_bInit; 00208 gdouble m_lastx, m_lasty; 00209 list<GtkWidget*> m_Widgets; 00210 }; 00211 00212 } //namespace gcu 00213 00214 #endif //CRYSTAL_VIEW_H