# crystalbond.h

    00001 // -*- C++ -*-
    00002
    00003 /*
    00004  * Gnome Chemistry Utils
    00005  * crystalbond.h
    00006  *
    00007  * Copyright (C) 2002-2008 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_BOND_H
    00026 #define CRYSTAL_BOND_H
    00027
    00028 #include <libxml/parser.h>
    00029 #include <list>
    00030 #include "bond.h"
    00031
    00032 namespace gcu
    00033 {
    00034
    00038 class CrystalBond: public Bond
    00039 {
    00040 public:
    00041         CrystalBond ();
    00042         virtual ~CrystalBond ();
    00043
    00044 public :
    00045         CrystalBond (double X1, double Y1, double Z1, double X2, double Y2, double Z2, double r, float red, float green, float blue, float alpha);
    00046         CrystalBond (CrystalBond& cbBond);
    00047         CrystalBond& operator= (CrystalBond&);
    00048
    00049         void Draw ();
    00050         double X1 (void) {return m_dx;}
    00051         double Y1 (void) {return m_dy;}
    00052         double Z1 (void) {return m_dz;}
    00053         double X2 (void) {return m_dx2;}
    00054         double Y2 (void) {return m_dy2;}
    00055         double Z2 (void) {return m_dz2;}
    00056         double Xmax ();
    00057         double Ymax ();
    00058         double Zmax ();
    00059         double Xmin ();
    00060         double Ymin ();
    00061         double Zmin ();
    00062         double Long () {return m_dl;}
    00063         void SetPosition (double x, double y, double z, double x1, double y1, double z1);
    00064         void SetColor (float red, float green, float blue, float alpha);
    00065         void GetColor (double *red, double *green, double *blue, double *alpha);
    00066         void SetRadius (double r);
    00067         double GetRadius () {return m_dr;};
    00068         bool operator== (CrystalBond&);
    00069         virtual void Move (double x, double y, double z);
    00070         double ScalProd (int h, int k, int l);
    00071         void Cleave () {m_nCleave++;}
    00072         void NetToCartesian (double a, double b, double c, double alpha, double beta, double gamma);
    00073         double Distance (double x, double y, double z, bool bFixed);
    00074         bool IsCleaved () {return m_nCleave != 0;}
    00075         void GetRotation (double& x, double& y, double& z, double& th);
    00076         virtual xmlNodePtr Save (xmlDocPtr xml);
    00077         virtual bool Load (xmlNodePtr node);
    00078
    00079 private :
    00080         float m_fBlue, m_fRed, m_fGreen, m_fAlpha;
    00081         double m_dx, m_dy, m_dz, m_dx2, m_dy2, m_dz2, m_dr, m_dl;
    00082         double m_dxrot, m_dyrot, m_darot;//rotation axis coordinates (z = 0) and angle
    00083         int m_nCleave; //0 if not cleaved
    00084 };
    00085
    00086 typedef std::list<CrystalBond*> CrystalBondList;
    00087
    00088 }// namespace gcu
    00089
    00090 #endif // CRYSTAL_BOND_H