File: brackets.h

package info (click to toggle)
gnome-chemistry-utils 0.14.9-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 17,836 kB
  • ctags: 7,337
  • sloc: cpp: 72,977; sh: 11,381; xml: 6,304; makefile: 1,663; ansic: 1,061
file content (236 lines) | stat: -rw-r--r-- 6,153 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
// -*- C++ -*-

/*
 * GChemPaint library
 * brackets.h
 *
 * Copyright (C) 2010-2012 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 3 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_BRACKETS_H
#define GCHEMPAINT_BRACKETS_H

#include <gcu/object.h>
#include <gccv/item-client.h>
#include <gccv/brackets.h>
#include <set>

/*!\file*/
namespace gcp {

extern gcu::TypeId BracketsType;

/*!\enum BracketContent
\brief The contents on a pair of brackets

Defines what is enclosed by a pair of brackets. One of the brackets might
be invisible.
*/
typedef enum {
/*!
Invalid or unknown content.
*/
	BracketContentInvalid,
/*!
The brackets enclose part of a molecule.
*/
	BracketContentFragment,
/*!
The brackets enclose a whole molecule.
*/
	BracketContentMolecule,
/*!
The brackets enclose several objects.
*/
	BracketContentGroup
} BracketContent;

/*!\enum BracketsDecorations
\brief Describes the objects that can be attached to the brackets.

Defines which of a superscript and subscript can be attached to a bracket.
The values can be combined. Actually, only subscript are supported for now.
*/
typedef enum {
/*!
Nothing allowed.
*/
	BracketDecorationNone = 0,
/*!
A subscript is allowed.
*/
	BracketSubscript = 1,
/*!
A superscript is allowed.
*/
	BracketSuperscript = 2
} BracketsDecorations;

/*!\class Brackets gcp/brackets.h
\brief Brackets class.

Represents brackets of various types that might be used in different situations
as to enclose part of a molecule or a whole object or several objects.
*/
class Brackets: public gcu::Object, public gccv::ItemClient
{
public:
/*!
\param type whether to create a brackets pair or a single bracket.

Used to create a brackets pair or a single, closing, or opening bracket.
*/
	Brackets (gccv::BracketsTypes type = gccv::BracketsTypeNormal);
/*!
The destructor.
*/
	virtual ~Brackets();


/*!
Used to add a representation of the brackets in the view.
*/
	void AddItem ();

/*!
@param node: a pointer to the xmlNode containing the serialized brackets.

Used to load a Brackets instance in memory.

@return true on succes, false otherwise.
*/
	bool Load (xmlNodePtr node);
/*!
	@param xml the xmlDoc used to save the document.

	Used to save the Brackects to the xmlDoc.
*/
	xmlNodePtr Save (xmlDocPtr xml) const;
/*!
@param state: the selection state of the brackets.

Used to set the selection state of the brackets.
The values of state might be gcp::SelStateUnselected, gcp::SelStateSelected,
gcp::SelStateUpdating, or gcp::SelStateErasing.
*/
	void SetSelected (int state);
/*!
For brackets, OnLoaded() is called each time an embedded object is added.
*/
	void OnLoaded ();

/*!
@param object the object just unlinked by Object::Unlink.

Called when an object has been unlinked. Programs should not call it
directly, but should call Object::OnUnlink instead.
*/
	void OnUnlink (Object *object);
/*!
@param UIManager: the gcu::UIManager to populate.
@param object the atom on which occured the mouse click.
@param x x coordinate of the mouse click.
@param y y coordinate of the mouse click.

This method is called to build a contextual menu for the brackets.
*/
	bool BuildContextualMenu (gcu::UIManager *UIManager, Object *object, double x, double y);

/*!
@param objects: the objects to enclose.

Sets the collection of objects that should be enclosed inside the brackets.
*/
	void SetEmbeddedObjects (std::set < gcu::Object * > objects);

/*!
@return the collection of objects that should be enclosed inside the brackets.
*/
	std::set < gcu::Object * > const &GetEmbeddedObjects () {return m_EmbeddedObjects;}

/*!
Tests if a collection of atoms can be enclosed inside brackets. Enclosing non
connected atoms is not allowed.
@return true if all atoms in the set are connected.
*/
	static bool ConnectedAtoms (std::set < gcu::Object * > const &objects);
/*!
@param m the Matrix2D of the transformation.
@param x the x component of the center of the transformation.
@param y the y component of the center of the transformation.

Used to move and/or transform brackets.
Brackets rotation is not currently supported. Actually, this method does not
do anything. The brackets are adjusted according to their content new position.
*/
	void Transform2D (gcu::Matrix2D& m, double x, double y);

private:
	std::set < gcu::Object * > m_EmbeddedObjects;
	bool m_Valid;
	BracketContent m_Content;

/*!\fn SetType(gccv::BracketsTypes val)
@param val the new type for the brackets.

Sets the new default bond length for the document.
*/
/*!\fn GetType()
@return the brackets type.
*/
/*!\fn GetRefType()
@return the brackets type as a reference.
*/
GCU_PROP (gccv::BracketsTypes, Type)

/*!\fn SetUsed(gccv::BracketsUses val)
@param val the brackets to use.

Sets the brackets used for this instance, opening, closing, or both.
*/
/*!\fn GetUsed()
@return the used brackets.
*/
/*!\fn GetRefUsed()
@return the used brackets as a reference.
*/
GCU_PROP (gccv::BracketsUses, Used)

/*!\fn GetDecorations()
@return the allowed additions to the brackets as a bit field composed of
BracketsDecorations values.
*/
GCU_RO_PROP (unsigned, Decorations)

/*!\fn SetFontDesc(std::string val)
@param val the font to use as a string.

Sets the font to use when displaying the brackets.
*/
/*!\fn GetFontDesc()
@return the font used to display the brackets.
*/
/*!\fn GetRefFontDesc()
@return the font used to display the brackets as a reference.
*/
GCU_PROP (std::string, FontDesc)
};

}	//	namespace gcp

#endif	//GCHEMPAINT_BRACKETS_H