// -*- C++ -*-
/*
* GChemPaint library
* bond.h
*
* Copyright (C) 2001-2006 Jean Bréfort <jean.brefort@normalesup.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef GCHEMPAINT_BOND_H
#define GCHEMPAINT_BOND_H
#include <gcu/bond.h>
#include <list>
#include <libgnomecanvas/gnome-canvas-path-def.h>
typedef enum
{
NormalBondType,
UpBondType,
DownBondType,
ForeBondType,
UndeterminedBondType
} gcpBondType;
typedef struct {
double a;
bool is_before;
} gcpBondCrossing;
using namespace gcu;
class gcpAtom;
class gcpCycle;
class gcpWidgetData;
class gcpBond: public Bond
{
public:
gcpBond();
gcpBond(gcpAtom* first, gcpAtom* last, unsigned char order);
virtual ~gcpBond();
virtual Object* GetAtomAt(double x, double y, double z = 0.);
gcpBondType GetType() {return m_type;}
void SetType(gcpBondType type);
double GetAngle2D(gcpAtom* pAtom);
double GetAngle2DRad(gcpAtom* pAtom);
void AddCycle(gcpCycle* pCycle);
void RemoveCycle(gcpCycle* pCycle);
void RemoveAllCycles();
unsigned IsCyclic() {return m_Cycles.size();}
gcpCycle* GetFirstCycle(std::list<gcpCycle*>::iterator& i, gcpCycle * pCycle);
gcpCycle* GetNextCycle(std::list<gcpCycle*>::iterator& i, gcpCycle * pCycle);
bool IsInCycle(gcpCycle* pCycle);
bool GetLine2DCoords(unsigned Num, double* x1, double* y1, double* x2, double* y2);
virtual bool SaveNode(xmlDocPtr xml, xmlNodePtr);
virtual bool LoadNode(xmlNodePtr);
virtual void Update(GtkWidget* w);
virtual void Move(double x, double y, double z = 0);
virtual void Transform2D(Matrix2D& m, double x, double y);
double GetDist(double x, double y);
void SetDirty();
void Revert();
double Get2DLength();
void IncOrder(int n = 1);
virtual void SetSelected(GtkWidget* w, int state);
void Add(GtkWidget* w);
bool ReplaceAtom(gcpAtom* oldAtom, gcpAtom* newAtom);
virtual double GetYAlign ();
bool IsCrossing (gcpBond *pBond);
bool BuildContextualMenu (GtkUIManager *UIManager, Object *object, double x, double y);
void MoveToBack ();
void BringToFront ();
private:
GnomeCanvasPathDef* BuildPathDef (gcpWidgetData* pData);
GnomeCanvasPathDef* BuildCrossingPathDef (gcpWidgetData* pData);
protected:
gcpBondType m_type;
double m_coords[16];//coordinates of the lines used to represent the bond in the canvas
bool m_CoordsCalc; //true if m_coords have been calculated, false else
list<gcpCycle*> m_Cycles;
map<gcpBond*, gcpBondCrossing> m_Crossing;
int m_level; // to know which bond shouldbe considered front
};
#endif // GCHEMPAINT_BOND_H
syntax highlighted by Code2HTML, v. 0.9.1