engines directory ported
[kdeedu-porting.git] / kalzium / libavogadro-kalzium / src / engines / sphereengine.h
bloba4ceb430645d6da84958bc6a37ad0a2f3ce5987c
1 /**********************************************************************
2 SphereEngine - Engine for "spheres" display
4 Copyright (C) 2006-2007 Geoffrey R. Hutchison
5 Copyright (C) 2007 Benoit Jacob
6 Copyright (C) 2007 Marcus D. Hanwell
8 This file is part of the Avogadro molecular editor project.
9 For more information, see <http://avogadro.sourceforge.net/>
11 Avogadro is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 Avogadro is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 02110-1301, USA.
25 **********************************************************************/
27 #ifndef __SPHEREENGINE_H
28 #define __SPHEREENGINE_H
30 #include <avogadro/global.h>
31 #include <avogadro/engine.h>
34 #include "ui_spheresettingswidget.h"
36 namespace Avogadro {
38 //! Sphere Engine class.
39 class SphereSettingsWidget;
40 class SphereEngine : public Engine
42 Q_OBJECT
43 AVOGADRO_ENGINE(tr("Van der Waals Spheres"))
45 public:
46 //! Constructor
47 SphereEngine(QObject *parent=0);
48 //! Deconstructor
49 ~SphereEngine();
51 //! Copy
52 Engine *clone() const;
54 //! \name Render Methods
55 //@{
56 bool renderOpaque(PainterDevice *pd);
57 bool renderTransparent(PainterDevice *pd);
58 //! Render an Atom.
59 bool render(PainterDevice *pd, const Atom *a);
60 //@}
62 double transparencyDepth() const;
63 EngineFlags flags() const;
65 double radius(const PainterDevice *pd, const Primitive *p = 0) const;
67 QWidget* settingsWidget();
68 /**
69 * Write the engine settings so that they can be saved between sessions.
71 void writeSettings(QSettings &settings) const;
73 /**
74 * Read in the settings that have been saved for the engine instance.
76 void readSettings(QSettings &settings);
78 private:
79 inline double radius(const Atom *a) const;
81 SphereSettingsWidget *m_settingsWidget;
83 double m_alpha; // transparency of the VdW spheres
85 private Q_SLOTS:
86 void settingsWidgetDestroyed();
89 /**
90 * @param value opacity of the VdW spheres / 20
92 void setOpacity(int value);
96 class SphereSettingsWidget : public QWidget, public Ui::SphereSettingsWidget
98 public:
99 SphereSettingsWidget(QWidget *parent=0) : QWidget(parent) {
100 setupUi(this);
104 //! Generates instances of our SphereEngine class
105 class SphereEngineFactory : public QObject, public EngineFactory
107 Q_OBJECT
108 Q_INTERFACES(Avogadro::EngineFactory)
109 AVOGADRO_ENGINE_FACTORY(SphereEngine)
112 } // end namespace Avogadro
114 #endif