NBody.h

Go to the documentation of this file.
00001 //# NBody.h: class which provides brute force n-body simulation and display
00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 
00028 #ifndef TRIALDISPLAY_NBODY_H
00029 #define TRIALDISPLAY_NBODY_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/Arrays/Vector.h>
00033 #include <casa/Quanta/Quantum.h>
00034 #include <casa/Containers/Record.h>
00035 #include <display/DisplayEvents/WCPositionEvent.h>
00036 #include <display/DisplayEvents/WCPositionEH.h>
00037 #include <display/DisplayEvents/WCMotionEvent.h>
00038 #include <display/DisplayEvents/WCMotionEH.h>
00039 #include <display/DisplayDatas/DisplayData.h>
00040 #include <casa/Containers/List.h>
00041 
00042 namespace casa { //# NAMESPACE CASA - BEGIN
00043 
00044         class WorldCanvas;
00045         class WCResampleHandler;
00046         class WorldCanvasHolder;
00047         class AttributeBuffer;
00048         class Attribute;
00049         class Unit;
00050         class IPosition;
00051 
00052 // <summary>
00053 // Simple class which provides brute force n-body simulation and display.
00054 // </summary>
00055 
00056 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00057 // </reviewed>
00058 
00059 // <synopsis>
00060 
00061 // This class provides a simple object which can (by brute force)
00062 // calculated the internal gravitational forces acting on a
00063 // self-gravitating set of bodies.
00064 // </synopsis>
00065 
00066         class NBody : public DisplayData {
00067 
00068         public:
00069 
00070                 // Constructor.
00071                 NBody();
00072 
00073                 // Destructor.
00074                 virtual ~NBody();
00075 
00076                 // Coordinate transformations, called by the WorldCanvasHolder.
00077                 // <group>
00078                 virtual Bool linToWorld(Vector<Double>& world, const Vector<Double>& lin);
00079                 virtual Bool worldToLin(Vector<Double>& lin, const Vector<Double>& world);
00080                 // </group>
00081 
00082                 // irrelevant in this part of the tree
00083                 virtual void setActiveImage(uInt /*zindex*/) {
00084                         return;
00085                 };
00086 
00087                 // Routines which yield information on the axis names and units, and
00088                 // some miscellaneous information.
00089                 // <group>
00090                 virtual Vector<String> worldAxisNames() const;
00091                 virtual Vector<String> worldAxisUnits() const;
00092                 virtual const Unit dataUnit() ;
00093                 virtual const RecordInterface& miscInfo() ;
00094                 // </group>
00095 
00096                 // Return the number of elements in this DisplayData.
00097                 virtual uInt nelements(const WorldCanvasHolder& wcHolder) const;
00098                 virtual uInt nelements() const;
00099 
00100                 // Add a restriction for item <src>itemNum</src> of this
00101                 // DisplayData.
00102                 // <group>
00103                 virtual void addElementRestrictions(const uInt itemNum,
00104                                                     AttributeBuffer& other);
00105                 virtual void addElementRestriction(const uInt itemNum,
00106                                                    Attribute& newRestriction,
00107                                                    Bool permanent);
00108                 // </group>
00109 
00110                 // Set a restriction for item <src>itemNum</src> of this
00111                 // DisplayData.
00112                 // <group>
00113                 virtual void setElementRestrictions(const uInt itemNum,
00114                                                     AttributeBuffer& other);
00115                 virtual void setElementRestriction(const uInt itemNum,
00116                                                    Attribute& newRestriction);
00117                 // </group>
00118 
00119                 // Remove a restriction from item <src>itemNum</src>.
00120                 virtual void removeElementRestriction(const uInt itemNum,
00121                                                       const String& name);
00122 
00123                 // Clear all restrictions of item <src>itemNum</src> (except the
00124                 // ones that are permanent of course).
00125                 virtual void clearElementRestrictions(const uInt itemNum);
00126 
00127                 // Check if a restriction for item <src>itemNum</src> with name
00128                 // <src>name</src> exists.
00129                 virtual Bool existElementRestriction(const uInt itemNum,
00130                                                      const String& name);
00131 
00132                 // Get a handle to the buffer of restrictions for item
00133                 // <src>itemNum</src>.  Throws an exception of type AipsError if
00134                 // <src>itemNum</src> is out of range.
00135                 virtual AttributeBuffer *elementRestrictionBuffer(const uInt itemNum);
00136 
00137                 // Report the minimum and maximum data values for this DisplayData.
00138                 // <group>
00139                 virtual Double getDataMin();
00140                 virtual Double getDataMax();
00141                 // </group>
00142 
00143                 // sizeControlFunction, called by the WorldCanvasHolder.
00144                 virtual Bool sizeControl(WorldCanvasHolder& wcHolder,
00145                                          AttributeBuffer& holderBuf);
00146 
00147                 // Position event handler, called by the WorldCanvasHolder.
00148                 virtual void positionEH(const WCPositionEvent& ev);
00149 
00150                 // Motion event handler, called by the WorldCanvasHolder.
00151                 virtual void motionEH(const WCMotionEvent& ev);
00152 
00153                 // Refresh event handler, called by the WorldCanvasHolder.
00154                 virtual void refreshEH(const WCRefreshEvent& ev);
00155 
00156                 // Clean up, ie. remove cached images etc.
00157                 virtual void cleanup();
00158 
00159                 // required functions with null implementations
00160                 virtual String showPosition(const Vector<Double> &, const Bool &) {
00161                         return String("");
00162                 }
00163                 virtual String showValue(const Vector<Double> &) {
00164                         return String("");
00165                 }
00166                 virtual Display::DisplayDataType classType() {
00167                         return Display::Vector;
00168                 }
00169 
00170         private:
00171 
00172                 void setupStars();
00173                 void cleanupStars();
00174                 void drawImage(WorldCanvas& wCanvas);
00175                 void setScale();
00176 
00177                 // General restrictions  (already declared in DisplayData.h)
00178                 //  AttributeBuffer restrictions;
00179                 //True if nothing should be drawn by the NBody
00180                 Bool turnedOff;
00181 
00182                 // The min and max to use for drawing
00183                 Double dataMin;
00184                 Double dataMax;
00185 
00186                 Double itsTimeStep;
00187                 Double itsDampingFactor;
00188                 Int itsNumSteps;
00189                 Int itsXSize;
00190                 Int itsYSize;
00191 
00192                 // internal bookkeeping:
00193                 // buffer for stroing sizecontrol done by this NBody
00194                 AttributeBuffer sizeControlBuf;
00195 
00196 
00197                 // Check if this NBody did the sizeControl
00198                 Bool iDidSizeControl(WorldCanvas& wCanvas);
00199 
00200                 void drawMovie(WorldCanvas& wCanvas, Int numSteps, Double timeStep,
00201                                Double dampingFactor);
00202 
00203                 Record miscInfoDummy;
00204 
00205                 List<void *> itsGalaxyList;
00206                 ListIter<void *> *itsGalaxyListIter;
00207 
00208         };
00209 
00210 
00211 } //# NAMESPACE CASA - END
00212 
00213 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1