G4CallbackModel.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // 
00030 // John Allison  31st December 1997.
00031 //
00032 // Class Description:
00033 //
00034 // G4CallbackModel calls a user-defined function containing, for
00035 // example, calls to the Draw methods of G4VVisManager or the
00036 // *Primitive* methods of G4VGraphicsScene.  This allows the user to
00037 // add his own graphical objects to a scene.  The idea is that the
00038 // callback function is invoked by the vis system to refresh the
00039 // screen or remake a graphical database whenever required.  The
00040 // function class must contain:
00041 //
00042 //   void operator()(G4VGraphicsScene&, const G4Transform3D&)
00043 //
00044 // A base class G4VUserVisAction is provided in the visualisation
00045 // category.  A G4CallbackModel is made by instantiating this template
00046 // with a pointer to the function object.  The G4VisManager does this
00047 // for the user if he/she registers it (SetUserAction) and issues the
00048 // command /vis/scene/add/userAction.  See the User Guide for
00049 // Application Developers, Section 8.8.7 and 8.8.8.
00050 
00051 #ifndef G4CALLBACKMODEL_HH
00052 #define G4CALLBACKMODEL_HH
00053 
00054 #include "G4VModel.hh"
00055 
00056 template <class F> class G4CallbackModel: public G4VModel {
00057 
00058  public:
00059   G4CallbackModel(F* function):
00060     fFunction(function) {}
00061   ~G4CallbackModel() {}
00062   void DescribeYourselfTo(G4VGraphicsScene& sceneHandler) {
00063     (*fFunction)(sceneHandler, fTransform);
00064   }
00065 
00066 protected:
00067 
00068   F* fFunction;
00069 
00070 private:
00071 
00072   // Private copy constructor and assigment operator - copying and
00073   // assignment not allowed.  Keeps CodeWizard happy.
00074   G4CallbackModel (const G4CallbackModel&);
00075   G4CallbackModel& operator = (const G4CallbackModel&);
00076 };
00077 
00078 #endif

Generated on Mon May 27 17:47:48 2013 for Geant4 by  doxygen 1.4.7