File: chem3ddoc.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 (174 lines) | stat: -rw-r--r-- 4,569 bytes parent folder | download | duplicates (4)
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
// -*- C++ -*-

/*
 * Gnome Chemistry Utils
 * gcu/chem3ddoc.h
 *
 * Copyright (C) 2006-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 GCU_CHEM3D_DOCUMENT_H
#define GCU_CHEM3D_DOCUMENT_H

#include <gcu/macros.h>
#include <gcu/gldocument.h>
#include <gcu/molecule.h>

/*!\file*/
namespace gcu {

/*! \enum Display3DMode
 3D display mode.
 Possible values are:
	 - BALL_AND_STICK: use ball and stick representation; atoms are represented by spheres with a radius equal to 20% of
	 their van der Waals radius and bonds are displayed as cylinders Multiple bonds are displayed as multiple cylinders.
	 - SPACEFILL: use space filling representation; atoms are represented by spheres with a radius equal
	 their van der Waals radius; bonds are not displayed.
	 - CYLINDERS: only bonds are represented as cylinders, atoms just end the cylinders.
	 - WIREFRAME: bonds are represented as narrow lines, atoms just end the lines.
*/
typedef enum
{
	BALL_AND_STICK,
	SPACEFILL,
	CYLINDERS,
	WIREFRAME
} Display3DMode;

class Application;
class Matrix;

/*!
\class Chem3dDoc gcu/chem3ddoc.h

Document base class for a molecule.
*/
class Chem3dDoc: public GLDocument
{
public:
/*!
Default constructor
*/
	Chem3dDoc ();
/*!
@param App the application.
@param View: an optional already existing GLView instance.
*/
	Chem3dDoc (Application *App, GLView *View);
/*!
Default destructor
*/
	virtual ~Chem3dDoc ();

/*!
@param m the Matrix giving the current model orientation

Displays the molecule using OpenGL.
*/
	void Draw (Matrix const &m) const;

/*!
@return true if the molecule have no atom, false otherwise.
*/
	bool IsEmpty () {return !m_Mol || m_Mol->GetAtomsNumber () == 0;}

/*!
@param uri the uri of the molecule file.
@param mime_type the mime type of the molecule file.

Loads a molecule from the provided uri.
*/
	void Load (char const *uri, char const *mime_type);

/*!
@param data the inline data.
@param mime_type the mime type of the data.
@param size the size of the data. If nul, the size will be evaluated from
the string length.

Loads a molecule from the provided data.
*/
	ContentType LoadData (char const *data, char const *mime_type, size_t size = 0);

/*!
@param filename the name of the vrml file to which the data should be written.

Exports the embedded molecule as a vrml scene.
*/
	void OnExportVRML (std::string const &filename);

/*!
Clears the document.
*/
	void Clear ();

/*!
	 Pure virtual method used to create a view. Must be overriden in derived classes.

@return the newly created view.
*/
	virtual GLView *CreateView () = 0;

/*!
@param name the name of the display mode.

Converts a string to an actual display mode. Supported names are: "ball&stick",
"spacefill", "cylinders", and "wireframe".
@return the display mode or BALL_AND_STICK on error.

*/
	static Display3DMode Display3DModeFromString (char const *name);

/*!
@param mode a display mode.

@return a string representation of the display mode.
*/
	static char const *Display3DModeAsString (Display3DMode mode);

/*!
@param property the property id as defined in objprops.h
@param value the property value as a string

Used when loading to set properties to the document
@return true if the property could be set, or if the property is not relevant, false otherwise.
*/
	bool SetProperty (unsigned property, char const *value);

/*!\fn SetDisplay3D(Display3DMode mode)
@param mode: the new mode.

Sets the display mode to one of the available Display3DMode values.
*/
/*!\fn GetDisplay3D()
@return the current mode.
*/
GCU_PROP_EX (Display3DMode, Display3D)
/*!\fn GetMol()
@return the molecule dispayed inside the document.
*/
GCU_RO_PROP (Molecule *, Mol)

private:
	/* cell parameters to support molecule loaded from a crystal structure */
	gdouble m_a, m_b, m_c, m_alpha, m_beta, m_gamma;
};

}	// namespace gcu

#endif	//	GCU_CHEM3D_DOCUMENT_H