summaryrefslogtreecommitdiffstats
path: root/kalzium/src/orbitswidget.h
blob: 0e7eb36b66c2e09924126fbcc90e6769e1f322da (plain)
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
#ifndef ORBITSWIDGET_H
#define ORBITSWIDGET_H
/***************************************************************************

                           orbitswidget.h  -  description
                             -------------------
    begin                : June 2003
    copyright            : (C) 2003, 2004, 2005 by Carsten Niehaus
    email                : cniehaus@kde.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.                                   *
 *                                                                         *
 ***************************************************************************/


#include <tqwidget.h>
#include <math.h>

/**
 * @short the widget which displays the Bohr-orbit of the element
 * @author Carsten Niehaus
 */
class OrbitsWidget : public TQWidget
{
	TQ_OBJECT
  

	public:
		OrbitsWidget( TQWidget *parent=0 , const char *name =0 );

		void setElementNumber( const int num );

	private:
		/**
		 * the elementnumber we are looking at
		 */
		int Elemno; 
	
		/**
		 * the number off hulls the atom has
		 */
		int num;
		
		typedef TQValueList<int> intList;
		intList numOfElectrons;

		const TQString& getNumber() const;
		
		/**
		 * @return the delta of the x-coordinate
		 * @param r is the radius of the circle
		 * @param angle is the n'st circle out of num
		 * @param num is the number of circles
		 */
		inline double translateToDX( const double r , const double angle , const int num )
		{
			return( r * sin( M_PI * angle / num * 2 ) );
		}
		
		/**
		 * @return the delta of the y-coordinate
		 * @param r is the radius of the circle
		 * @param angle is the n'st circle out of num
		 * @param num is the number of circles
		 */
		inline double translateToDY( const double r , const double angle , const int num )
		{
			return( r * cos( M_PI * angle / num * 2 ) );
		}

		/**
		 * sets everything up
		 */
		void getNumberOfOrbits();

	protected slots:
		virtual void paintEvent(  TQPaintEvent* );
};

#endif // ORBITSWIDGET_H