1 // -*- C++ -*-
2 
3 /*
4  * GChemPaint arrows plugin
5  * curvedarrowtool.h
6  *
7  * Copyright (C) 2004-2009 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
22  * USA
23  */
24 
25 #ifndef GCHEMPAINT_CURVED_ARROW_TOOL_H
26 #define GCHEMPAINT_CURVED_ARROW_TOOL_H
27 
28 #include <gcp/tool.h>
29 #include <gcu/macros.h>
30 
31 namespace gcp {
32 	class Atom;
33 	class Bond;
34 	class Electron;
35 };
36 
37 class gcpCurvedArrowTool: public gcp::Tool
38 {
39 public:
40 	gcpCurvedArrowTool (gcp::Application *App, std::string Id);
41 	virtual ~gcpCurvedArrowTool ();
42 
43 	bool OnClicked ();
44 	void OnDrag ();
45 	void OnMotion ();
46 	void OnRelease ();
47 	void OnLeaveNotify ();
48 	GtkWidget *GetPropertyPage ();
GetHelpTag()49 	char const *GetHelpTag () {return "curved-arrow";}
50 
51 private:
52 	bool AllowAsSource (gcp::Atom *atom);
53 	bool AllowAsTarget (gcp::Atom *atom);
54 	bool AllowAsSource (gcp::Bond *bond);
55 	bool AllowAsTarget (gcp::Bond *bond);
56 	bool AllowAsSource (gcp::Electron *elec);
57 
58 	void AtomToAdjBond ();
59 	void AtomToAtom ();
60 	void BondToAdjAtom ();
61 	void BondToAdjBond ();
62 	void BondToAtom ();
63 	void ElectronToAdjBond ();
64 	void ElectronToAtom ();
65 
66 private:
67 	bool m_Full; // if false use half heads
68 	gcu::Object *m_Target, *m_SourceAux, *m_LastTarget;
69 	double m_CPx0, m_CPy0, m_CPx1, m_CPy1, m_CPx2, m_CPy2, m_CPx3, m_CPy3; // x and y deltas from ends to central control points
70 	bool m_SetEnd;
71 
72 GCU_PROP (bool, EndAtBondCenter)
73 };
74 
75 #endif	//GCHEMPAINT_CURVED_ARROW_TOOL_H
76