Import Geant4 6.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 10:56:29 +02:00
parent 1d812b78b1
commit e083ffb441
1415 changed files with 111223 additions and 21207 deletions
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.4 2003/10/03 15:21:20 gcosmo Exp $
# $Id: GNUmakefile,v 1.5 2004/06/03 11:40:12 gcosmo Exp $
name := G4FR
@@ -6,6 +6,13 @@ ifndef G4INSTALL
G4INSTALL = ../../..
endif
GLOBLIBS = libG4vis_management.lib libG4modeling.lib
GLOBLIBS += libG4run.lib libG4event.lib
GLOBLIBS += libG4tracking.lib libG4processes.lib libG4digits_hits.lib
GLOBLIBS += libG4track.lib libG4particles.lib libG4geometry.lib
GLOBLIBS += libG4materials.lib libG4graphics_reps.lib
GLOBLIBS += libG4intercoms.lib libG4global.lib
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/G4VIS_BUILD.gmk
include $(G4INSTALL)/config/interactivity.gmk
+3 -4
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.15 2003/11/06 14:53:11 johna Exp $
# $Id: GNUmakefile,v 1.18 2004/06/03 11:40:11 gcosmo Exp $
# -----------------------------------------------------------------------
# GNUmakefile for visualization and modeling. John Allison, 5/7/95.
# Modeling is always made. Others by environment. John Allison 4/7/98.
@@ -48,14 +48,13 @@ endif #G4VIS_BUILD
.PHONY: granular glob global clean
glob global: granular
granular:
@for dir in $(SUBDIRS); do (cd $$dir; $(MAKE)); done
includes:
@for dir in $(SUBDIRS); do (cd $$dir && $(MAKE) $@ ); done
glob global:
@echo "ERROR: The global target not relevant for the visualization category."
clean clean_libs:
@for dir in $(SUBDIRS); do (cd $$dir; $(MAKE) $@); done
+15 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.15 2003/11/17 23:13:01 duns Exp $
# $Id: GNUmakefile,v 1.18 2004/06/04 14:17:54 duns Exp $
name := G4visHepRep
@@ -6,6 +6,13 @@ ifndef G4INSTALL
G4INSTALL = ../../..
endif
GLOBLIBS = libG4vis_management.lib libG4modeling.lib
GLOBLIBS += libG4run.lib libG4event.lib
GLOBLIBS += libG4tracking.lib libG4processes.lib libG4digits_hits.lib
GLOBLIBS += libG4track.lib libG4particles.lib libG4geometry.lib
GLOBLIBS += libG4materials.lib libG4graphics_reps.lib
GLOBLIBS += libG4intercoms.lib libG4global.lib
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/G4VIS_BUILD.gmk
include $(G4INSTALL)/config/interactivity.gmk
@@ -15,15 +22,22 @@ CPPFLAGS += -I$(G4BASE)/visualization/HepRep/include/ref
CPPFLAGS += -I$(G4BASE)/visualization/HepRep/include/zipios++
CPPFLAGS += -I$(G4BASE)/visualization/HepRep/include/zlib
CPPFLAGS += -I$(G4BASE)/event/include
CPPFLAGS += -I$(G4BASE)/track/include
CPPFLAGS += -I$(G4BASE)/run/include
CPPFLAGS += -I$(G4BASE)/digits_hits/hits/include
CPPFLAGS += -I$(G4BASE)/particles/management/include
CPPFLAGS += -I$(G4BASE)/tracking/include
CPPFLAGS += -I$(G4BASE)/visualization/management/include
CPPFLAGS += -I$(G4BASE)/visualization/modeling/include
CPPFLAGS += -I$(G4BASE)/global/management/include
CPPFLAGS += -I$(G4BASE)/global/HEPRandom/include
CPPFLAGS += -I$(G4BASE)/global/HEPGeometry/include
CPPFLAGS += -I$(G4BASE)/graphics_reps/include
CPPFLAGS += -I$(G4BASE)/intercoms/include
CPPFLAGS += -I$(G4BASE)/processes/management/include
CPPFLAGS += -I$(G4BASE)/geometry/management/include
CPPFLAGS += -I$(G4BASE)/geometry/navigation/include
CPPFLAGS += -I$(G4BASE)/geometry/solids/CSG/include
CPPFLAGS += -I$(G4BASE)/geometry/volumes/include
CPPFLAGS += -I$(G4BASE)/geometry/solids/specific/include
+24 -1
View File
@@ -1,4 +1,4 @@
.$Id: History,v 1.67 2004/03/15 08:05:37 perl Exp $
.$Id: History,v 1.75 2004/06/17 06:50:35 duns Exp $
-------------------------------------------------------------------
=========================================================
@@ -19,6 +19,29 @@ committal in the CVS repository !
History file for visualization/HepRep sub-category
--------------------------------------------------
17 June 2004 Mark Donszelmann (vis-HepRep-V06-01-05 against geant4-06-02-cand-02)
- Fixed GEANT-50:
- Renamed zlib prefix from z_ to heprep_z_
- Added symbol z_errmsg to list for renaming to avoid conflicts with other
programs who contain a copy of zlib (such as Root).
4 June 2004 Mark Donszelmann (vis-HepRep-V06-01-04 against geant4-06-01-ref-02)
- Fixed compilation problem with G4RunManagerKernel
27 May 2004 Joseph Perl (vis-HepRep-V06-01-02)
- Added attributes for Region and Root Region to both HepRep drivers.
27 May 2004 Mark Donszelmann (vis-HepRep-V06-01-01)
- Fixed GEANT17: geometry files can be written separately.
- Updated README with instructions
see http://bugs.freehep.org/secure/BrowseProject.jspa?id=10041
26 May 2004 Mark Donszelmann (vis-HepRep-V06-01-00)
- Fixed GEANT-47: Added initial viewpoint settings and a command to set the
coordinate system.
- Fixed GEANT-41: copied new interfaces for HepRep, which uses fewer pointers,
see http://bugs.freehep.org/secure/BrowseProject.jspa?id=10041
14 March 2004 Joseph Perl (vis-HepRep-V06-00-06)
- HepRepFile handle duplicate ShowView.
- HepRepFile improve layering and hierarchy for hits.
+13 -1
View File
@@ -93,6 +93,18 @@ To write 10 events (and geometries), use:
Be aware that this may increase the size of the output dramatically.
(Optional) You may use the commands:
/vis/viewer/zoom to set an initial zoom factor
/vis/viewer/set/viewpointThetaPhi to set an initial view point
/vis/heprep/setCoordinateSystem uvw to change the coordinate system, where uvw can be "xyz", "zxy", ...
(Optional) You may decide to write .zip files with events and geometry separated (but linked).
This results in a smaller zip file, as the geometry is only written once. Use the command:
/vis/heprep/appendGeometry false
(Optional) To close the file, remove the SceneHandler, use:
/vis/sceneHandler/remove scene-handler-0
@@ -109,5 +121,5 @@ Only one SceneHandler can exist at any time, connected to a single Viewer.
Since the HepRep format is a model rather than a view this is not a real
limitation. In WIRED you can create as many views (SceneHandlers) as you like.
4 November 2003
27 May 2004
Mark.Donszelmann@slac.stanford.edu
@@ -20,8 +20,8 @@
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4HepRepMessenger.hh,v 1.3 2003/12/11 21:55:54 duns Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4HepRepMessenger.hh,v 1.5 2004/05/27 05:55:19 duns Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
#ifndef G4HepRepMessenger_HH
@@ -45,6 +45,7 @@ class G4HepRepMessenger : public G4UImessenger {
virtual G4String getEventNumberSuffix();
virtual G4bool appendGeometry();
virtual G4bool addPointAttributes();
virtual G4String getCoordinateSystem();
private:
@@ -54,10 +55,13 @@ class G4HepRepMessenger : public G4UImessenger {
G4UIcmdWithAString* setEventNumberSuffixCommand;
G4bool geometry;
// G4UIcmdWithABool* appendGeometryCommand;
G4UIcmdWithABool* appendGeometryCommand;
G4bool pointAttributes;
G4UIcmdWithABool* addPointAttributesCommand;
G4String coordinateSystem;
G4UIcmdWithAString* setCoordinateSystemCommand;
};
#endif
@@ -20,8 +20,8 @@
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4HepRepSceneHandler.hh,v 1.30 2003/12/11 21:55:55 duns Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4HepRepSceneHandler.hh,v 1.32 2004/05/27 05:55:20 duns Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/**
@@ -127,12 +127,16 @@ class G4HepRepSceneHandler: public G4VSceneHandler {
void open(G4String name);
void close();
void writeLayers(HEPREP::HepRep* heprep);
void addAttDefs(HEPREP::HepRepDefinition* definition, const std::map<G4String,G4AttDef>* attDefs);
void addAttVals(HEPREP::HepRepAttribute* attribute, const std::map<G4String,G4AttDef>* attDefs, std::vector<G4AttValue>* attValues);
void addTopLevelAttributes(HEPREP::HepRepType* type);
// Returns the particular instance/type or if not created, creates them and adds them to the HepRep
HEPREP::HepRep* getHepRep();
HEPREP::HepRep* getHepRepGeometry();
HEPREP::HepRepInstanceTree* getGeometryInstanceTree();
HEPREP::HepRepInstance* getGeometryInstance(G4LogicalVolume* volume, int depth);
HEPREP::HepRepInstance* getGeometryInstance(G4String volumeName, int depth);
@@ -172,6 +176,7 @@ class G4HepRepSceneHandler: public G4VSceneHandler {
// DO NOT USE member vars directly, use get methods.
HEPREP::HepRep* _heprep;
HEPREP::HepRep* _heprepGeometry;
HEPREP::HepRepInstanceTree* _geometryInstanceTree;
std::vector<HEPREP::HepRepInstance*> _geometryInstance;
HEPREP::HepRepInstance* _geometryRootInstance;
@@ -20,8 +20,8 @@
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4HepRepViewer.hh,v 1.16 2003/12/11 21:55:55 duns Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4HepRepViewer.hh,v 1.17 2004/05/27 05:55:20 duns Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/**
@@ -37,9 +37,11 @@
// Geant4
#include "G4VViewer.hh"
#include "G4HepRepMessenger.hh"
class G4HepRepViewer: public G4VViewer {
public:
G4HepRepViewer (G4VSceneHandler& scene, const G4String& name = "");
G4HepRepViewer (G4VSceneHandler& scene, G4HepRepMessenger& messenger, const G4String& name = "");
virtual ~G4HepRepViewer ();
void SetView ();
void ClearView ();
@@ -47,8 +49,11 @@ class G4HepRepViewer: public G4VViewer {
void ShowView ();
void FinishView ();
void reset();
private:
bool geometryIncluded;
G4HepRepMessenger& messenger;
};
#endif
@@ -7,8 +7,9 @@
#ifndef HEPREP_HEPREP_H
#define HEPREP_HEPREP_H 1
// Copyright 2000-2003, FreeHEP.
// Copyright 2000-2004, FreeHEP.
#include <set>
#include <string>
#include <vector>
@@ -17,14 +18,15 @@
#include "HEPREP/HepRepAction.h"
#include "HEPREP/HepRepAttDef.h"
#include "HEPREP/HepRepAttribute.h"
#include "HEPREP/HepRepAttributeListener.h"
#include "HEPREP/HepRepAttValue.h"
#include "HEPREP/HepRepConstants.h"
#include "HEPREP/HepRepDefinition.h"
#include "HEPREP/HepRepFactory.h"
#include "HEPREP/HepRepFrameListener.h"
#include "HEPREP/HepRepInstance.h"
#include "HEPREP/HepRepInstanceTree.h"
#include "HEPREP/HepRepIterator.h"
#include "HEPREP/HepRepIteratorListener.h"
#include "HEPREP/HepRepPoint.h"
#include "HEPREP/HepRepSelectFilter.h"
#include "HEPREP/HepRepTreeID.h"
@@ -37,7 +39,6 @@ namespace HEPREP {
class HepRepAction;
class HepRepInstanceTree;
class HepRepSelectFilter;
class HepRepType;
class HepRepTypeTree;
/**
@@ -61,22 +62,21 @@ public:
*
* @param layer name of layer to be added to the back of the list.
*/
virtual bool addLayer(std::string layer) = 0;
virtual void addLayer(std::string layer) = 0;
/**
* Returns the list of layers.
*
* @return the known layer names, in the order back-to-front.
*/
virtual std::vector<std::string> * getLayerOrder() = 0;
virtual std::vector<std::string> getLayerOrder() = 0;
/**
* Add a typetree to this heprep.
*
* @param typeTree to be added.
* @return false only if the tree is written immediately to some stream.
*/
virtual bool addTypeTree(HepRepTypeTree * typeTree) = 0;
virtual void addTypeTree(HepRepTypeTree * typeTree) = 0;
/**
* Remove a typetree from this heprep.
@@ -90,7 +90,7 @@ public:
*
* @return collection of HepRepTypeTrees.
*/
virtual std::vector<HepRepTypeTree *> * getTypeTrees() = 0;
virtual std::set<HepRepTypeTree *> getTypeTrees() = 0;
/**
* Returns a named and versioned typetree.
@@ -108,15 +108,13 @@ public:
* @param name name of type.
* @return named HepRepType.
*/
virtual HepRepType * getType(std::string name) = 0;
// HepRepType* getType(String name);
/**
* Adds an instancetree to this heprep.
*
* @param instanceTree to be added.
* @return false only if the tree is written immediately to some stream.
*/
virtual bool addInstanceTree(HepRepInstanceTree * instanceTree) = 0;
virtual void addInstanceTree(HepRepInstanceTree * instanceTree) = 0;
/**
* Overlays an instancetree to this heprep, overriding attributes and adding children.
@@ -137,7 +135,7 @@ public:
*
* @return collection of HepRepInstanceTrees.
*/
virtual std::vector<HepRepInstanceTree *> * getInstanceTrees() = 0;
virtual std::set<HepRepInstanceTree *> getInstanceTrees() = 0;
/**
* Returns a named and versioned instancetree.
@@ -9,6 +9,7 @@
// Copyright 2000-2002, FreeHEP.
#include <set>
#include <string>
#include <vector>
@@ -33,9 +34,8 @@ public:
* Adds an attValue.
*
* @param attValue to be added.
* @return false only if the value is immediately written to a stream.
*/
virtual bool addAttValue(HepRepAttValue * attValue) = 0;
virtual void addAttValue(HepRepAttValue * attValue) = 0;
/**
@@ -47,18 +47,16 @@ public:
* @param key name of attValue
* @param value value of attValue
* @param showLabel show this as label
* @return false if an IOException was created.
*/
virtual bool addAttValue(std::string key, char* value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
virtual void addAttValue(std::string key, char* value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Adds an attValue.
*
* @param key name of attValue
* @param value value of attValue
* @param showLabel show this as label
* @return false only if the value is immediately written to a stream.
*/
virtual bool addAttValue(std::string key, std::string value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
virtual void addAttValue(std::string key, std::string value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Adds an attValue.
@@ -66,9 +64,8 @@ public:
* @param key name of attValue
* @param value value of attValue
* @param showLabel show this as label
* @return false only if the value is immediately written to a stream.
*/
virtual bool addAttValue(std::string key, int value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
virtual void addAttValue(std::string key, int value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Adds an attValue.
@@ -76,9 +73,8 @@ public:
* @param key name of attValue
* @param value value of attValue
* @param showLabel show this as label
* @return false only if the value is immediately written to a stream.
*/
virtual bool addAttValue(std::string key, double value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
virtual void addAttValue(std::string key, double value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Adds an attValue.
@@ -86,9 +82,8 @@ public:
* @param key name of attValue
* @param value value of attValue
* @param showLabel show this as label
* @return false only if the value is immediately written to a stream.
*/
virtual bool addAttValue(std::string key, bool value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
virtual void addAttValue(std::string key, bool value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Adds a Color attValue.
@@ -96,9 +91,8 @@ public:
* @param key name of attValue
* @param value value of attValue
* @param showLabel show this as label
* @return false only if the value is immediately written to a stream.
*/
virtual bool addAttValue(std::string key, std::vector<double> value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
virtual void addAttValue(std::string key, std::vector<double> value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Adds a Color attValue.
@@ -109,9 +103,8 @@ public:
* @param blue color
* @param alpha value
* @param showLabel show this as label
* @return false only if the value is immediately written to a stream.
*/
virtual bool addAttValue(std::string key, double red, double green, double blue, double alpha = 1.0, int showLabel = HepRepConstants::SHOW_NONE) = 0;
virtual void addAttValue(std::string key, double red, double green, double blue, double alpha = 1.0, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Remove the attvalue named by key.
@@ -135,7 +128,7 @@ public:
*
* @return collection of HepRepAttValues.
*/
virtual std::vector<HepRepAttValue *> * getAttValuesFromNode() = 0;
virtual std::set<HepRepAttValue *> getAttValuesFromNode() = 0;
/**
* Returns a named attribute value from this node.
@@ -4,10 +4,10 @@
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPITERATORLISTENER_H
#define HEPREP_HEPREPITERATORLISTENER_H 1
#ifndef HEPREP_HEPREPATTRIBUTELISTENER_H
#define HEPREP_HEPREPATTRIBUTELISTENER_H 1
// Copyright 2000-2002, FreeHEP.
// Copyright 2000-2004, FreeHEP.
#include <string>
#include <vector>
@@ -15,25 +15,25 @@
namespace HEPREP {
/**
* HepRepIteratorListener interface. The implementor is called back for changes
* HepRepAttributeListener interface. The implementor is called back for changes
* of attributes while using the HepRepIterator to iterate over all the HepRepInstances.
*
* All names are lowercased.
*
* @author Mark Donszelmann
*/
class HepRepIteratorListener {
class HepRepAttributeListener {
public:
/// Destructor.
virtual ~HepRepIteratorListener() { /* nop */; }
virtual ~HepRepAttributeListener() { /* nop */; }
/**
* Called if attribute key changes its value.
*
* @param key name of the changed attribute.
* @param value value of the changed attribute.
* @param value value of the changed attribute.
* @param lowerCaseValue lower case value of the changed attribute.
* @param showLabel value of showLabel.
*/
virtual void setAttribute(std::string key, std::string value, std::string lowerCaseValue, int showLabel) = 0;
@@ -91,4 +91,4 @@ public:
virtual void removeAttribute(std::string key) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPITERATORLISTENER_H */
#endif /* ifndef HEPREP_HEPREPATTRIBUTELISTENER_H */
@@ -9,8 +9,8 @@
// Copyright 2000-2002, FreeHEP.
#include <set>
#include <string>
#include <vector>
#include "HEPREP/HepRepAttribute.h"
@@ -37,17 +37,15 @@ public:
* @param desc description of the definition.
* @param category category of the definition.
* @param extra extra info of the definition.
* @return false only if this definition is written immediately to a stream.
*/
virtual bool addAttDef(std::string name, std::string desc, std::string category, std::string extra) = 0;
virtual void addAttDef(std::string name, std::string desc, std::string category, std::string extra) = 0;
/**
* Adds an attdef.
*
* @param attDef to be added.
* @return false only if this definition is written immediately to a stream.
*/
virtual bool addAttDef(HepRepAttDef * attDef) = 0;
virtual void addAttDef(HepRepAttDef * attDef) = 0;
/**
* Return a named attribute definition searched on this node and any parent nodes.
@@ -62,7 +60,7 @@ public:
*
* @return collection of attributes definitions.
*/
virtual std::vector<HepRepAttDef *> * getAttDefsFromNode() = 0;
virtual std::set<HepRepAttDef *> getAttDefsFromNode() = 0;
/**
* Returns a named attribute definition defined on this node.
@@ -113,6 +113,14 @@ public:
*/
virtual HepRepInstanceTree * createHepRepInstanceTree(std::string name, std::string version, HepRepTreeID * typeTree) = 0;
/**
* Creates a HepRepType.
*
* @param parent to add this type to.
* @param name of the type to create.
*/
virtual HepRepType * createHepRepType(HepRepTypeTree * parent, std::string name) = 0;
/**
* Creates a HepRepType.
*
@@ -0,0 +1,34 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPFRAMELISTENER_H
#define HEPREP_HEPREPFRAMELISTENER_H 1
// Copyright 2004, FreeHEP.
namespace HEPREP {
/**
* HepRepFrameListener interface. The implementor is called back for changes in
* drawing in or out of the frame layer.
*
* @author Mark Donszelmann
*/
class HepRepFrameListener {
public:
/// Destructor.
virtual ~HepRepFrameListener() { /* nop */; }
/**
* Called if we switch from a normal layer to a frame layer, and back.
*
* @param inFrame true if in a frame layer
*/
virtual void setFrameLayer(bool inFrame) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPFRAMELISTENER_H */
@@ -7,7 +7,7 @@
#ifndef HEPREP_HEPREPINSTANCE_H
#define HEPREP_HEPREPINSTANCE_H 1
// Copyright 2000-2002, FreeHEP.
// Copyright 2000-2004, FreeHEP.
#include <vector>
@@ -15,11 +15,11 @@
namespace HEPREP {
class HepRep;
class HepRepInstanceTree;
class HepRepPoint;
class HepRepSelectFilter;
class HepRepType;
class HepRepTypeTree;
/**
* HepRepInstance interface.
@@ -45,9 +45,8 @@ public:
* Adds an sub-instance to this instance.
*
* @param instance sub-instance.
* @return false only if written immediately to a stream.
*/
virtual bool addInstance(HepRepInstance * instance) = 0;
virtual void addInstance(HepRepInstance * instance) = 0;
/**
* Removes a sub-instance from this instance.
@@ -61,7 +60,7 @@ public:
*
* @return collection of HepRepInstances.
*/
virtual std::vector<HepRepInstance *> * getInstances() = 0;
virtual std::vector<HepRepInstance *> getInstances() = 0;
/**
* Returns the associated type for this instance.
@@ -74,36 +73,56 @@ public:
* Adds a point to this instance.
*
* @param point to be added.
* @return false only if written immediately to a stream.
*/
virtual bool addPoint(HepRepPoint * point) = 0;
virtual void addPoint(HepRepPoint * point) = 0;
/**
* Returns a collection of all points this instance keeps.
*
* @return collection of HepRepPoints.
*/
virtual std::vector<HepRepPoint *> * getPoints() = 0;
virtual std::vector<HepRepPoint *> getPoints() = 0;
/**
* Fills a double[3][n] array with the coordinates of all points, if
* none of the points have any attributes defined on them.
* The actual number of points filled is returned. In case the number
* of points is larger than n, or if any points have attributes, -1 is returned.
* One could then call getPoint().
*
* @see #getPoints()
*
* @param xyz a double[3][n] array to be filled with points.
* @return number of points filled in xyz, or -1 in case of error or non-implementation.
*
* ONLY in JAVA
*/
/**
* Returns the parent of this instance.
*
* @return parent of instance, or null if top-level.
*/
virtual HepRepInstance * getSuperInstance() = 0;
/**
* Returns a deep copy of this instance.
*
* @param heprep needed to find the associated type.
* @param typeTree needed to find the associated type.
* @param parent to which the copy is added.
* @param filter run on all instances before copying.
* @return copy of this instance.
*/
virtual HepRepInstance * copy(HepRep * heprep, HepRepInstance * parent, HepRepSelectFilter * filter = NULL) = 0;
virtual HepRepInstance * copy(HepRepTypeTree * typeTree, HepRepInstance * parent, HepRepSelectFilter * filter = NULL) = 0;
/**
* Returns a deep copy of this instance.
*
* @param heprep needed to find the associated type.
* @param typeTree needed to find the associated type.
* @param parent to which the copy is added.
* @param filter run on all instances before copying.
* @return copy of this instance.
*/
virtual HepRepInstance * copy(HepRep * heprep, HepRepInstanceTree * parent, HepRepSelectFilter * filter = NULL) = 0;
virtual HepRepInstance * copy(HepRepTypeTree * typeTree, HepRepInstanceTree * parent, HepRepSelectFilter * filter = NULL) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPINSTANCE_H */
@@ -7,18 +7,19 @@
#ifndef HEPREP_HEPREPINSTANCETREE_H
#define HEPREP_HEPREPINSTANCETREE_H 1
// Copyright 2000-2002, FreeHEP.
// Copyright 2000-2004, FreeHEP.
#include <set>
#include <vector>
#include "HEPREP/HepRepTreeID.h"
namespace HEPREP {
class HepRep;
class HepRepInstance;
class HepRepSelectFilter;
class HepRepTreeID;
class HepRepTypeTree;
/**
* HepRepInstanceTree interface.
@@ -42,9 +43,8 @@ public:
* Adds an instance to this instancetree.
*
* @param instance to be added.
* @return false only if written immediately to a stream.
*/
virtual bool addInstance(HepRepInstance * instance) = 0;
virtual void addInstance(HepRepInstance * instance) = 0;
/**
* Removes an instance from this instancetree.
@@ -58,22 +58,21 @@ public:
*
* @return collection of HepRepInstances.
*/
virtual std::vector<HepRepInstance *> * getInstances() = 0;
virtual std::vector<HepRepInstance *> getInstances() = 0;
/**
* Adds a related instance tree to this instancetree.
*
* @param instanceTree related instancetree.
* @return false only if written immediately to a stream.
*/
virtual bool addInstanceTree(HepRepTreeID * instanceTree) = 0;
virtual void addInstanceTree(HepRepTreeID * instanceTree) = 0;
/**
* Returns a collection of associated instance trees.
*
* @return collection of HepRepTreeIDs.
*/
virtual std::vector<HepRepTreeID *> * getInstanceTrees() = 0;
virtual std::set<HepRepTreeID *> getInstanceTrees() = 0;
/**
* Returns the associated typetree.
@@ -85,13 +84,10 @@ public:
/**
* Returns a deep copy of this instancetree.
*
* @param heprep needed to find the associated type.
* @param filter to filter the instances.
* @return copy of this instancetree.
*/
virtual HepRepInstanceTree * copy(HepRep * heprep, HepRepSelectFilter * filter = NULL) = 0;
virtual HepRepTreeID * copy() = 0;
virtual HepRepInstanceTree * copy(HepRepTypeTree * typeTree, HepRepSelectFilter * filter = NULL) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPINSTANCETREE_H */
@@ -7,15 +7,15 @@
#ifndef HEPREP_HEPREPITERATOR_H
#define HEPREP_HEPREPITERATOR_H 1
// Copyright 2000-2002, FreeHEP.
// Copyright 2000-2004, FreeHEP.
#include <string>
namespace HEPREP {
class HepRepAttValue;
class HepRepAttributeListener;
class HepRepFrameListener;
class HepRepInstance;
class HepRepIteratorListener;
/**
* HepRepIterator interface.
@@ -47,22 +47,41 @@ public:
*
* @param listener to be added.
*/
virtual bool addHepRepIteratorListener(HepRepIteratorListener * listener) = 0;
virtual void addHepRepAttributeListener(std::string name, HepRepAttributeListener * listener) = 0;
/**
* Removes a listener.
*
* @param listener to be removed.
*/
virtual void removeHepRepIteratorListener(HepRepIteratorListener * listener) = 0;
virtual void removeHepRepAttributeListener(std::string name, HepRepAttributeListener * listener) = 0;
/**
* Adds a listener to be informed about attribute changes while iterating.
*
* @param listener to be added.
*/
virtual void addHepRepFrameListener(HepRepFrameListener * listener) = 0;
/**
* Removes a listener.
*
* @param listener to be removed.
*/
virtual void removeHepRepFrameListener(HepRepFrameListener * listener) = 0;
/**
* Returns true if the current instance, just delivered by nextInstance(), is to be drawn as a frame.
*/
virtual bool drawAsFrame() = 0;
/**
* Returns the attValue for key at the current point of iteration.
*
* @param key name of tye attribute to be looked up.
* @param key name of the attribute to be looked up.
* @return value associated to name at this point in the iteration.
*/
virtual HepRepAttValue * getAttValue(std::string key) = 0;
// HepRepAttValue* getAttValue(String key);
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPITERATOR_H */
@@ -7,7 +7,7 @@
#ifndef HEPREP_HEPREPTREEID_H
#define HEPREP_HEPREPTREEID_H 1
// Copyright 2000-2002, FreeHEP.
// Copyright 2000-2003, FreeHEP.
#include <string>
@@ -56,8 +56,9 @@ public:
* Returns a deep copy of this treeID.
*
* @return copy of this treeID.
* @throws CloneNotSupportedException if copying is not possible.
*/
virtual HepRepTreeID * copy() = 0;
// HepRepTreeID* copy() throws CloneNotSupportedException;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPTREEID_H */
@@ -7,17 +7,15 @@
#ifndef HEPREP_HEPREPTYPE_H
#define HEPREP_HEPREPTYPE_H 1
// Copyright 2000-2002, FreeHEP.
// Copyright 2000-2003, FreeHEP.
#include <set>
#include <string>
#include <vector>
#include "HEPREP/HepRepDefinition.h"
namespace HEPREP {
class HepRep;
/**
* HepRepType interface.
*
@@ -33,9 +31,8 @@ public:
* Adds a sub-type to this type.
*
* @param type sub-type to be added.
* @return false only if written directly to a stream.
*/
virtual bool addType(HepRepType * type) = 0;
virtual void addType(HepRepType * type) = 0;
/**
* Returns the name of this type.
@@ -65,6 +62,13 @@ public:
*/
virtual std::string getDescription() = 0;
/**
* Sets the description of this type.
*
* @param infoURL
*/
virtual void setDescription(std::string description) = 0;
/**
* Returns the information URL of this type.
*
@@ -72,6 +76,13 @@ public:
*/
virtual std::string getInfoURL() = 0;
/**
* Sets the information URL of this type.
*
* @param infoURL
*/
virtual void setInfoURL(std::string infoURL) = 0;
/**
* Returns the parent of this type.
*
@@ -84,16 +95,15 @@ public:
*
* @return collection of HepRepTypes.
*/
virtual std::vector<HepRepType *> * getTypes() = 0;
virtual std::set<HepRepType *> getTypes() = 0;
/**
* Returns a deep copy of this type.
*
* @param heprep top-level heprep. (Not sure if this is necessary).
* @param parent to which this copy is added.
* @return copy of this type.
*/
virtual HepRepType * copy(HepRep * heprep, HepRepType * parent) = 0;
virtual HepRepType * copy(HepRepType * parent) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPTYPE_H */
@@ -9,14 +9,13 @@
// Copyright 2000-2002, FreeHEP.
#include <vector>
#include <set>
#include <string>
#include "HEPREP/HepRepTreeID.h"
namespace HEPREP {
class HepRep;
class HepRepTreeID;
class HepRepType;
/**
@@ -34,29 +33,34 @@ public:
* Adds a type to this typetree.
*
* @param type to be added.
* @return false only if written immediatelty to a stream.
*/
virtual bool addType(HepRepType * type) = 0;
virtual void addType(HepRepType * type) = 0;
/**
* Returns a collection of all types in this tree.
*
* @return collection of HepRepTypes.
*/
virtual std::vector<HepRepType *> * getTypes() = 0;
virtual std::set<HepRepType *> getTypes() = 0;
/**
* Returns type
*/
virtual HepRepType * getType(std::string fullName) = 0;
/**
* Returns a deep copy of this typetree.
*
* @param heprep top-level heprep. (Not sure if this is necessary).
* @return copy of this typetree.
*/
virtual HepRepTypeTree * copy(HepRep * heprep) = 0;
virtual HepRepTypeTree * copy() = 0;
//
// To be enable in g++ 3.0
// using HepRep::HepRepTreeID::copy;
// To be disabled in g++ 3.0
virtual HepRepTreeID * copy() = 0;
// HepRepTreeID * copy();
//
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPTYPETREE_H */
@@ -38,6 +38,15 @@ public:
/// Destructor.
virtual ~HepRepWriter() { /* nop */; }
/**
* Adds a property, to be written to the HepRep file when closed.
*
* @param key
* @param value
* @return false in case of a stream problem.
*/
virtual bool addProperty(std::string key, std::string value) = 0;
/**
* Closes the writer and its underlying stream.
*
@@ -60,7 +69,7 @@ public:
* @param layerOrder to be written.
* @return false in case of a stream problem.
*/
virtual bool write(std::vector<std::string> * layerOrder) = 0;
virtual bool write(std::vector<std::string> layerOrder) = 0;
/**
* Writes a HepRepTypeTree.
@@ -5,6 +5,7 @@
#include <string>
#include <vector>
#include <set>
#include "HEPREP/HepRep.h"
#include "HEPREP/HepRepSelectFilter.h"
@@ -21,22 +22,21 @@ class DefaultHepRep : public virtual HEPREP::HepRep {
private:
std::vector<std::string> layers;
std::vector<HEPREP::HepRepTypeTree*> typeTrees;
std::vector<HEPREP::HepRepInstanceTree*> instanceTrees;
std::set<HEPREP::HepRepTypeTree*> typeTrees;
std::set<HEPREP::HepRepInstanceTree*> instanceTrees;
public:
DefaultHepRep();
~DefaultHepRep();
HEPREP::HepRep* copy(HEPREP::HepRepSelectFilter* filter);
std::vector<std::string>* getLayerOrder();
bool addLayer(std::string layer);
bool addTypeTree(HEPREP::HepRepTypeTree* typeTree);
std::vector<std::string> getLayerOrder();
void addLayer(std::string layer);
void addTypeTree(HEPREP::HepRepTypeTree* typeTree);
void removeTypeTree(HEPREP::HepRepTypeTree* typeTree);
HEPREP::HepRepTypeTree* getTypeTree(std::string name, std::string version);
std::vector<HEPREP::HepRepTypeTree*>* getTypeTrees();
HEPREP::HepRepType* getType(std::string name);
bool addInstanceTree(HEPREP::HepRepInstanceTree* instanceTree);
std::set<HEPREP::HepRepTypeTree*> getTypeTrees();
void addInstanceTree(HEPREP::HepRepInstanceTree* instanceTree);
void overlayInstanceTree(HEPREP::HepRepInstanceTree * instanceTree);
void removeInstanceTree(HEPREP::HepRepInstanceTree* instanceTree);
HEPREP::HepRepInstanceTree* getInstanceTreeTop(std::string name, std::string version);
@@ -52,7 +52,7 @@ class DefaultHepRep : public virtual HEPREP::HepRep {
bool getNonDrawAtts,
std::vector<std::string> invertAtts);
std::string checkForException();
std::vector<HEPREP::HepRepInstanceTree*>* getInstanceTrees();
std::set<HEPREP::HepRepInstanceTree*> getInstanceTrees();
};
#endif
@@ -5,6 +5,7 @@
#include <string>
#include <map>
#include <set>
#include <vector>
#include "HEPREP/HepRepAttribute.h"
@@ -20,21 +21,20 @@ class DefaultHepRepAttribute : public virtual HEPREP::HepRepAttribute {
private:
std::map<std::string, HEPREP::HepRepAttValue*> attValues;
std::vector<HEPREP::HepRepAttValue*> attList;
public:
DefaultHepRepAttribute();
~DefaultHepRepAttribute();
std::vector<HEPREP::HepRepAttValue*>* getAttValuesFromNode();
bool addAttValue(HEPREP::HepRepAttValue* hepRepAttValue);
bool addAttValue(std::string key, char *value, int showLabel);
bool addAttValue(std::string key, std::string value, int showLabel);
bool addAttValue(std::string key, int value, int showLabel);
bool addAttValue(std::string key, double value, int showLabel);
bool addAttValue(std::string key, bool value, int showLabel);
bool addAttValue(std::string key, std::vector<double> value, int showLabel);
bool addAttValue(std::string key, double red, double green, double blue, double alpha, int showLabel);
std::set<HEPREP::HepRepAttValue*> getAttValuesFromNode();
void addAttValue(HEPREP::HepRepAttValue* hepRepAttValue);
void addAttValue(std::string key, char *value, int showLabel);
void addAttValue(std::string key, std::string value, int showLabel);
void addAttValue(std::string key, int value, int showLabel);
void addAttValue(std::string key, double value, int showLabel);
void addAttValue(std::string key, bool value, int showLabel);
void addAttValue(std::string key, std::vector<double> value, int showLabel);
void addAttValue(std::string key, double red, double green, double blue, double alpha, int showLabel);
HEPREP::HepRepAttValue* getAttValueFromNode(std::string lowerCaseName);
HEPREP::HepRepAttValue* removeAttValue(std::string key);
@@ -5,6 +5,7 @@
#include <string>
#include <vector>
#include <set>
#include "HEPREP/HepRepDefinition.h"
#include "HEPREP/HepRepWriter.h"
@@ -19,15 +20,14 @@ class DefaultHepRepDefinition : public DefaultHepRepAttribute, public virtual HE
private:
std::map<std::string, HEPREP::HepRepAttDef*> attDefs;
std::vector<HEPREP::HepRepAttDef*> attList;
public:
DefaultHepRepDefinition();
~DefaultHepRepDefinition();
bool addAttDef(HEPREP::HepRepAttDef* hepRepAttDef);
bool addAttDef(std::string name, std::string desc, std::string type, std::string extra);
std::vector<HEPREP::HepRepAttDef *>* getAttDefsFromNode();
void addAttDef(HEPREP::HepRepAttDef* hepRepAttDef);
void addAttDef(std::string name, std::string desc, std::string type, std::string extra);
std::set<HEPREP::HepRepAttDef *> getAttDefsFromNode();
HEPREP::HepRepAttDef* getAttDefFromNode(std::string lowerCaseName);
HEPREP::HepRepAttDef* getAttDef(std::string name) = 0;
@@ -41,6 +41,7 @@ class DefaultHepRepFactory : public virtual HEPREP::HepRepFactory {
HEPREP::HepRepInstanceTree* createHepRepInstanceTree (std::string name, std::string version,
HEPREP::HepRepTreeID* typeTreeID);
HEPREP::HepRepType* createHepRepType (HEPREP::HepRepType* parent, std::string name);
HEPREP::HepRepType* createHepRepType (HEPREP::HepRepTypeTree* parent, std::string name);
HEPREP::HepRepTypeTree* createHepRepTypeTree (HEPREP::HepRepTreeID* treeID);
HEPREP::HepRep* createHepRep ();
};
@@ -24,7 +24,7 @@
class DefaultHepRepInstance : public DefaultHepRepAttribute, public virtual HEPREP::HepRepInstance {
private:
void* parent;
HEPREP::HepRepInstance* parent;
HEPREP::HepRepType* type;
std::vector<HEPREP::HepRepPoint*> points;
std::vector<HEPREP::HepRepInstance*> instances;
@@ -35,14 +35,15 @@ class DefaultHepRepInstance : public DefaultHepRepAttribute, public virtual HEPR
~DefaultHepRepInstance();
void overlay(HEPREP::HepRepInstance * instance);
HEPREP::HepRepInstance* copy(HEPREP::HepRep* heprep, HEPREP::HepRepInstance* parent, HEPREP::HepRepSelectFilter* filter);
HEPREP::HepRepInstance* copy(HEPREP::HepRep* heprep, HEPREP::HepRepInstanceTree* parent, HEPREP::HepRepSelectFilter* filter);
HEPREP::HepRepInstance* copy(HEPREP::HepRepTypeTree* typeTree, HEPREP::HepRepInstance* parent, HEPREP::HepRepSelectFilter* filter);
HEPREP::HepRepInstance* copy(HEPREP::HepRepTypeTree* typeTree, HEPREP::HepRepInstanceTree* parent, HEPREP::HepRepSelectFilter* filter);
HEPREP::HepRepType* getType();
bool addPoint(HEPREP::HepRepPoint* point);
std::vector<HEPREP::HepRepPoint *>* getPoints();
bool addInstance(HEPREP::HepRepInstance* instance);
void addPoint(HEPREP::HepRepPoint* point);
std::vector<HEPREP::HepRepPoint *> getPoints();
HEPREP::HepRepInstance* getSuperInstance();
void addInstance(HEPREP::HepRepInstance* instance);
void removeInstance(HEPREP::HepRepInstance* instance);
std::vector<HEPREP::HepRepInstance *>* getInstances();
std::vector<HEPREP::HepRepInstance *> getInstances();
HEPREP::HepRepAttValue* getAttValue(std::string name);
@@ -5,6 +5,7 @@
#include <string>
#include <vector>
#include <set>
#include "HEPREP/HepRep.h"
#include "HEPREP/HepRepSelectFilter.h"
@@ -24,21 +25,20 @@ class DefaultHepRepInstanceTree : public DefaultHepRepTreeID, public virtual HEP
private:
HEPREP::HepRepTreeID* typeTree;
std::vector<HEPREP::HepRepInstance*> instances;
std::vector<HEPREP::HepRepTreeID*> instanceTrees;
std::set<HEPREP::HepRepTreeID*> instanceTrees;
public:
DefaultHepRepInstanceTree(std::string name, std::string version, HEPREP::HepRepTreeID* typeTree);
~DefaultHepRepInstanceTree();
void overlay(HEPREP::HepRepInstanceTree * instanceTree);
HEPREP::HepRepInstanceTree* copy(HEPREP::HepRep* heprep, HEPREP::HepRepSelectFilter* filter);
HEPREP::HepRepTreeID* copy();
bool addInstance(HEPREP::HepRepInstance* instance);
HEPREP::HepRepInstanceTree* copy(HEPREP::HepRepTypeTree* typeTree, HEPREP::HepRepSelectFilter* filter);
void addInstance(HEPREP::HepRepInstance* instance);
void removeInstance(HEPREP::HepRepInstance* instance);
std::vector<HEPREP::HepRepInstance*>* getInstances();
bool addInstanceTree(HEPREP::HepRepTreeID* treeID);
std::vector<HEPREP::HepRepInstance*> getInstances();
void addInstanceTree(HEPREP::HepRepTreeID* treeID);
HEPREP::HepRepTreeID* getTypeTree();
std::vector<HEPREP::HepRepTreeID*>* getInstanceTrees();
std::set<HEPREP::HepRepTreeID*> getInstanceTrees();
};
#endif
@@ -27,7 +27,6 @@ class DefaultHepRepTreeID : public virtual HEPREP::HepRepTreeID {
void setQualifier(std::string qualifier);
std::string getName();
std::string getVersion();
HEPREP::HepRepTreeID* copy();
};
#endif
@@ -5,6 +5,7 @@
#include <string>
#include <vector>
#include <set>
#include "HEPREP/HepRep.h"
#include "HEPREP/HepRepType.h"
@@ -22,27 +23,28 @@ class DefaultHepRepType : public DefaultHepRepDefinition, public virtual HEPREP:
private:
HEPREP::HepRepType* parent;
std::vector<HEPREP::HepRepType*> types;
std::set<HEPREP::HepRepType*> types;
std::string name;
std::string description;
std::string infoURL;
public:
DefaultHepRepType(HEPREP::HepRepType* parent, std::string name);
DefaultHepRepType(HEPREP::HepRepTypeTree* parent, std::string name);
~DefaultHepRepType();
HEPREP::HepRepType* getSuperType();
HEPREP::HepRepAttDef* getAttDef(std::string name);
HEPREP::HepRepAttValue* getAttValue(std::string name);
HEPREP::HepRepType* copy(HEPREP::HepRep* heprep, HEPREP::HepRepType* parent);
HEPREP::HepRepType* copy(HEPREP::HepRepType* parent);
std::string getName();
std::string getFullName();
std::string getDescription();
void setDescription(std::string description);
std::string getInfoURL();
void setInfoURL(std::string infoURL);
bool addType(HEPREP::HepRepType* type);
std::vector<HEPREP::HepRepType*>* getTypes();
void addType(HEPREP::HepRepType* type);
std::set<HEPREP::HepRepType*> getTypes();
};
#endif
@@ -5,6 +5,7 @@
#include <string>
#include <vector>
#include <set>
#include "HEPREP/HepRep.h"
#include "HEPREP/HepRepTypeTree.h"
@@ -21,16 +22,16 @@
class DefaultHepRepTypeTree : public DefaultHepRepTreeID, public virtual HEPREP::HepRepTypeTree {
private:
std::vector<HEPREP::HepRepType*> types;
std::set<HEPREP::HepRepType*> types;
public:
DefaultHepRepTypeTree(HEPREP::HepRepTreeID* typeTree);
~DefaultHepRepTypeTree();
HEPREP::HepRepTypeTree* copy(HEPREP::HepRep* heprep);
HEPREP::HepRepTreeID* copy();
bool addType(HEPREP::HepRepType* type);
std::vector<HEPREP::HepRepType* >* getTypes();
HEPREP::HepRepTypeTree* copy();
void addType(HEPREP::HepRepType* type);
std::set<HEPREP::HepRepType* > getTypes();
HEPREP::HepRepType* getType(std::string name);
};
#endif
@@ -4,11 +4,23 @@
#ifdef WIN32
#ifndef GNU_GCC
// Disable warning C4786: identifier was truncated to '255' characters in the debug information
#pragma warning ( disable : 4786 )
#pragma warning ( disable : 4786 )
// Disable warning C4250: inherits via dominance
#pragma warning ( disable : 4250 )
#endif
#endif
#pragma warning ( disable : 4250 )
#ifdef VC6
// FIX for KB 168440 - VC6
// Stream Operator << Cannot Handle __int64 Type
#include<iostream>
#endif
inline std::ostream& operator<<(std::ostream& os, __int64 i ) {
char buf[20];
sprintf(buf,"%I64d", i );
os << buf;
return os;
}
#endif // VC6
#endif // GNU_GCC
#endif // WIN32
#endif // FREEHEPTYPES_H
@@ -6,7 +6,9 @@
#include <iostream>
#include <string>
#include <stack>
#include <set>
#include <vector>
#include <map>
#include "zipios++/zipoutputstream.h"
#include "zipios++/gzipoutputstream.h"
@@ -38,14 +40,16 @@ class XMLHepRepWriter : public virtual HEPREP::HepRepWriter {
XMLWriter *xml;
zipios::ZipOutputStream *zip;
zipios::GZIPOutputStream *gz;
std::map<std::string, std::string> properties;
public:
XMLHepRepWriter(std::ostream* out, bool randomAccess, bool compress);
~XMLHepRepWriter();
bool addProperty(std::string key, std::string value);
bool close();
bool write(HEPREP::HepRep* heprep, std::string name);
bool write(std::vector<std::string> *layers);
bool write(std::vector<std::string> layers);
bool write(HEPREP::HepRepTypeTree* typeTree);
bool write(HEPREP::HepRepType* type);
bool write(HEPREP::HepRepTreeID* treeID);
@@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in HepRep-zlib.h
*/
/* @(#) $Id: HepRep-zconf.h,v 1.1 2004/02/03 19:34:43 duns Exp $ */
/* @(#) $Id: HepRep-zconf.h,v 1.2 2004/06/16 21:05:27 duns Exp $ */
#ifndef _HEPREP_ZCONF_H
#define _HEPREP_ZCONF_H
@@ -16,39 +16,43 @@
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
*/
#ifdef Z_PREFIX
# define deflateInit_ z_deflateInit_
# define deflate z_deflate
# define deflateEnd z_deflateEnd
# define inflateInit_ z_inflateInit_
# define inflate z_inflate
# define inflateEnd z_inflateEnd
# define deflateInit2_ z_deflateInit2_
# define deflateSetDictionary z_deflateSetDictionary
# define deflateCopy z_deflateCopy
# define deflateReset z_deflateReset
# define deflateParams z_deflateParams
# define inflateInit2_ z_inflateInit2_
# define inflateSetDictionary z_inflateSetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateReset z_inflateReset
# define compress z_compress
# define compress2 z_compress2
# define uncompress z_uncompress
# define adler32 z_adler32
# define crc32 z_crc32
# define get_crc_table z_get_crc_table
/* MD: changes z_ into heprep_z_ */
# define deflateInit_ heprep_z_deflateInit_
# define deflate heprep_z_deflate
# define deflateEnd heprep_z_deflateEnd
# define inflateInit_ heprep_z_inflateInit_
# define inflate heprep_z_inflate
# define inflateEnd heprep_z_inflateEnd
# define deflateInit2_ heprep_z_deflateInit2_
# define deflateSetDictionary heprep_z_deflateSetDictionary
# define deflateCopy heprep_z_deflateCopy
# define deflateReset heprep_z_deflateReset
# define deflateParams heprep_z_deflateParams
# define inflateInit2_ heprep_z_inflateInit2_
# define inflateSetDictionary heprep_z_inflateSetDictionary
# define inflateSync heprep_z_inflateSync
# define inflateSyncPoint heprep_z_inflateSyncPoint
# define inflateReset heprep_z_inflateReset
# define compress heprep_z_compress
# define compress2 heprep_z_compress2
# define uncompress heprep_z_uncompress
# define adler32 heprep_z_adler32
# define crc32 heprep_z_crc32
# define get_crc_table heprep_z_get_crc_table
# define Byte z_Byte
# define uInt z_uInt
# define uLong z_uLong
# define Bytef z_Bytef
# define charf z_charf
# define intf z_intf
# define uIntf z_uIntf
# define uLongf z_uLongf
# define voidpf z_voidpf
# define voidp z_voidp
# define Byte heprep_z_Byte
# define uInt heprep_z_uInt
# define uLong heprep_z_uLong
# define Bytef heprep_z_Bytef
# define charf heprep_z_charf
# define intf heprep_z_intf
# define uIntf heprep_z_uIntf
# define uLongf heprep_z_uLongf
# define voidpf heprep_z_voidpf
# define voidp heprep_z_voidp
/* MD: added define for lonely symbol not renamed... */
# define z_errmsg heprep_z_errmsg
#endif
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
@@ -8,10 +8,10 @@ DefaultHepRep::DefaultHepRep() {
}
DefaultHepRep::~DefaultHepRep() {
for (vector<HepRepTypeTree*>::iterator i1 = typeTrees.begin(); i1 != typeTrees.end(); i1++) {
for (set<HepRepTypeTree*>::iterator i1 = typeTrees.begin(); i1 != typeTrees.end(); i1++) {
delete (*i1);
}
for (vector<HepRepInstanceTree*>::iterator i2 = instanceTrees.begin(); i2 != instanceTrees.end(); i2++) {
for (set<HepRepInstanceTree*>::iterator i2 = instanceTrees.begin(); i2 != instanceTrees.end(); i2++) {
delete (*i2);
}
}
@@ -21,18 +21,16 @@ HepRep* DefaultHepRep::copy(HepRepSelectFilter*) {
return NULL;
}
vector<string>* DefaultHepRep::getLayerOrder() {
return &layers;
vector<string> DefaultHepRep::getLayerOrder() {
return layers;
}
bool DefaultHepRep::addLayer(string layer) {
void DefaultHepRep::addLayer(string layer) {
layers.push_back(layer);
return true;
}
bool DefaultHepRep::addTypeTree(HepRepTypeTree* typeTree) {
typeTrees.push_back(typeTree);
return true;
void DefaultHepRep::addTypeTree(HepRepTypeTree* typeTree) {
typeTrees.insert(typeTree);
}
void DefaultHepRep::removeTypeTree(HepRepTypeTree*) {
@@ -44,18 +42,12 @@ HepRepTypeTree* DefaultHepRep::getTypeTree(string, string) {
return NULL;
}
vector<HepRepTypeTree*>* DefaultHepRep::getTypeTrees() {
return &typeTrees;
set<HepRepTypeTree*> DefaultHepRep::getTypeTrees() {
return typeTrees;
}
HepRepType* DefaultHepRep::getType(string) {
cerr << "DefaultHepRep::getType(string) not implemented." << endl;
return NULL;
}
bool DefaultHepRep::addInstanceTree(HepRepInstanceTree* instanceTree) {
instanceTrees.push_back(instanceTree);
return true;
void DefaultHepRep::addInstanceTree(HepRepInstanceTree* instanceTree) {
instanceTrees.insert(instanceTree);
}
void DefaultHepRep::overlayInstanceTree(HepRepInstanceTree *) {
@@ -94,7 +86,7 @@ string DefaultHepRep::checkForException() {
return NULL;
}
vector<HepRepInstanceTree*>* DefaultHepRep::getInstanceTrees() {
return &instanceTrees;
set<HepRepInstanceTree*> DefaultHepRep::getInstanceTrees() {
return instanceTrees;
}
@@ -16,56 +16,53 @@ DefaultHepRepAttribute::~DefaultHepRepAttribute() {
for (map<string, HepRepAttValue*>::iterator i = attValues.begin(); i != attValues.end(); i++) {
delete (*i).second;
}
attList.clear();
}
vector<HepRepAttValue*>* DefaultHepRepAttribute::getAttValuesFromNode() {
attList.clear();
set<HepRepAttValue*> DefaultHepRepAttribute::getAttValuesFromNode() {
set<HepRepAttValue*> attSet;
for (map<string, HepRepAttValue*>::iterator i = attValues.begin(); i != attValues.end(); i++) {
if ((*i).first != "layer") attList.push_back((*i).second);
if ((*i).first != "layer") attSet.insert((*i).second);
}
return &attList;
return attSet;
}
bool DefaultHepRepAttribute::addAttValue(HepRepAttValue* hepRepAttValue) {
void DefaultHepRepAttribute::addAttValue(HepRepAttValue* hepRepAttValue) {
string lowerCaseName = hepRepAttValue->getLowerCaseName();
if (attValues[lowerCaseName] != NULL) delete attValues[lowerCaseName];
attValues[lowerCaseName] = hepRepAttValue;
return true;
}
bool DefaultHepRepAttribute::addAttValue(string key, char *value, int showLabel) {
return addAttValue(key, (std::string)value, showLabel);
void DefaultHepRepAttribute::addAttValue(string key, char *value, int showLabel) {
addAttValue(key, (std::string)value, showLabel);
}
bool DefaultHepRepAttribute::addAttValue(string key, string value, int showLabel) {
return addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
void DefaultHepRepAttribute::addAttValue(string key, string value, int showLabel) {
addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
}
bool DefaultHepRepAttribute::addAttValue(string key, int value, int showLabel) {
return addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
void DefaultHepRepAttribute::addAttValue(string key, int value, int showLabel) {
addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
}
bool DefaultHepRepAttribute::addAttValue(string key, double value, int showLabel) {
return addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
void DefaultHepRepAttribute::addAttValue(string key, double value, int showLabel) {
addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
}
bool DefaultHepRepAttribute::addAttValue(string key, bool value, int showLabel) {
return addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
void DefaultHepRepAttribute::addAttValue(string key, bool value, int showLabel) {
addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
}
bool DefaultHepRepAttribute::addAttValue(string key, vector<double> value, int showLabel) {
return addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
void DefaultHepRepAttribute::addAttValue(string key, vector<double> value, int showLabel) {
addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
}
bool DefaultHepRepAttribute::addAttValue(string key, double red, double green, double blue, double alpha, int showLabel) {
void DefaultHepRepAttribute::addAttValue(string key, double red, double green, double blue, double alpha, int showLabel) {
vector<double> color;
color.push_back(red);
color.push_back(green);
color.push_back(blue);
color.push_back(alpha);
return addAttValue(new DefaultHepRepAttValue(key, color, showLabel));
addAttValue(new DefaultHepRepAttValue(key, color, showLabel));
}
HepRepAttValue* DefaultHepRepAttribute::getAttValueFromNode(string name) {
@@ -13,29 +13,28 @@ DefaultHepRepDefinition::DefaultHepRepDefinition()
}
DefaultHepRepDefinition::~DefaultHepRepDefinition() {
vector<HepRepAttDef *>* list = getAttDefsFromNode();
for (vector<HepRepAttDef*>::iterator i1 = list->begin(); i1 != list->end(); i1++) {
set<HepRepAttDef *> list = getAttDefsFromNode();
for (set<HepRepAttDef*>::iterator i1 = list.begin(); i1 != list.end(); i1++) {
delete (*i1);
}
}
vector<HepRepAttDef *>* DefaultHepRepDefinition::getAttDefsFromNode() {
attList.clear();
set<HepRepAttDef *> DefaultHepRepDefinition::getAttDefsFromNode() {
set<HepRepAttDef*> attSet;
for (map<string, HepRepAttDef*>::iterator i = attDefs.begin(); i != attDefs.end(); i++) {
attList.push_back((*i).second);
attSet.insert((*i).second);
}
return &attList;
return attSet;
}
bool DefaultHepRepDefinition::addAttDef(HepRepAttDef* hepRepAttDef) {
void DefaultHepRepDefinition::addAttDef(HepRepAttDef* hepRepAttDef) {
string lowerCaseName = hepRepAttDef->getLowerCaseName();
if (attDefs[lowerCaseName] != NULL) delete attDefs[lowerCaseName];
attDefs[lowerCaseName] = hepRepAttDef;
return true;
}
bool DefaultHepRepDefinition::addAttDef(string name, string desc, string type, string extra) {
return addAttDef(new DefaultHepRepAttDef(name, desc, type, extra));
void DefaultHepRepDefinition::addAttDef(string name, string desc, string type, string extra) {
addAttDef(new DefaultHepRepAttDef(name, desc, type, extra));
}
HepRepAttDef* DefaultHepRepDefinition::getAttDefFromNode(string name) {
@@ -67,6 +67,10 @@ HepRepType* DefaultHepRepFactory::createHepRepType (HepRepType* parent, string n
return new DefaultHepRepType(parent, name);
}
HepRepType* DefaultHepRepFactory::createHepRepType (HepRepTypeTree* parent, string name) {
return new DefaultHepRepType(parent, name);
}
HepRepTypeTree* DefaultHepRepFactory::createHepRepTypeTree (HepRepTreeID* treeID) {
return new DefaultHepRepTypeTree(treeID);
}
@@ -10,14 +10,14 @@ DefaultHepRepInstance::DefaultHepRepInstance(HepRepInstance* instance, HepRepTyp
: DefaultHepRepAttribute(), parent(instance), type(heprepType) {
if (type == NULL) cerr << "HepRepInstance cannot be created without a HepRepType." << endl;
((HepRepInstance*)parent)->addInstance(this);
parent->addInstance(this);
}
DefaultHepRepInstance::DefaultHepRepInstance(HepRepInstanceTree* instanceTree, HepRepType* heprepType)
: DefaultHepRepAttribute(), parent(instanceTree), type(heprepType) {
: DefaultHepRepAttribute(), parent(NULL), type(heprepType) {
if (type == NULL) cerr << "HepRepInstance cannot be created without a HepRepType." << endl;
((HepRepInstanceTree*)parent)->addInstance(this);
instanceTree->addInstance(this);
}
DefaultHepRepInstance::~DefaultHepRepInstance() {
@@ -35,13 +35,13 @@ void DefaultHepRepInstance::overlay(HepRepInstance *) {
cerr << "DefaultHepRepInstance::overlay(HepRepInstance * instance) not implemented." << endl;
}
HepRepInstance* DefaultHepRepInstance::copy(HepRep*, HepRepInstance*, HepRepSelectFilter*) {
cerr << "DefaultHepRepInstance::copy(HepRep*, HepRepInstance*, HepRepSelectFilter*) not implemented." << endl;
HepRepInstance* DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstance*, HepRepSelectFilter*) {
cerr << "DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstance*, HepRepSelectFilter*) not implemented." << endl;
return NULL;
}
HepRepInstance* DefaultHepRepInstance::copy(HepRep*, HepRepInstanceTree*, HepRepSelectFilter*) {
cerr << "DefaultHepRepInstance::copy(HepRep*, HepRepInstanceTree*, HepRepSelectFilter*) not implemented." << endl;
HepRepInstance* DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstanceTree*, HepRepSelectFilter*) {
cerr << "DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstanceTree*, HepRepSelectFilter*) not implemented." << endl;
return NULL;
}
@@ -49,26 +49,28 @@ HepRepType* DefaultHepRepInstance::getType() {
return type;
}
bool DefaultHepRepInstance::addPoint(HepRepPoint* point) {
void DefaultHepRepInstance::addPoint(HepRepPoint* point) {
points.push_back(point);
return true;
}
vector<HepRepPoint*>* DefaultHepRepInstance::getPoints() {
return &points;
vector<HepRepPoint*> DefaultHepRepInstance::getPoints() {
return points;
}
bool DefaultHepRepInstance::addInstance(HepRepInstance* instance) {
HepRepInstance* DefaultHepRepInstance::getSuperInstance() {
return parent;
}
void DefaultHepRepInstance::addInstance(HepRepInstance* instance) {
instances.push_back(instance);
return true;
}
void DefaultHepRepInstance::removeInstance(HepRepInstance*) {
cerr << "DefaultHepRepInstance::removeInstance(HepRepInstance*) not implemented." << endl;
}
vector<HepRepInstance*>* DefaultHepRepInstance::getInstances() {
return &instances;
vector<HepRepInstance*> DefaultHepRepInstance::getInstances() {
return instances;
}
HepRepAttValue* DefaultHepRepInstance::getAttValue(string name) {
@@ -19,38 +19,32 @@ void DefaultHepRepInstanceTree::overlay(HepRepInstanceTree *) {
cerr << "DefaultHepRepInstanceTree::overlay(HepRepInstanceTree * instanceTree) not implemented." << endl;
}
HepRepTreeID* DefaultHepRepInstanceTree::copy() {
return DefaultHepRepTreeID::copy();
}
HepRepInstanceTree* DefaultHepRepInstanceTree::copy(HepRep*, HepRepSelectFilter*) {
cerr << "DefaultHepRepInstanceTree::copy(HepRep*, HepRepSelectFilter*) not implemented." << endl;
HepRepInstanceTree* DefaultHepRepInstanceTree::copy(HepRepTypeTree*, HepRepSelectFilter*) {
cerr << "DefaultHepRepInstanceTree::copy(HepRepTypeTree*, HepRepSelectFilter*) not implemented." << endl;
return NULL;
}
bool DefaultHepRepInstanceTree::addInstance(HepRepInstance* instance) {
void DefaultHepRepInstanceTree::addInstance(HepRepInstance* instance) {
instances.push_back(instance);
return true;
}
void DefaultHepRepInstanceTree::removeInstance(HepRepInstance*) {
cerr << "DefaultHepRepInstanceTree::removeInstance(HepRepInstance*) not implemented." << endl;
}
vector<HepRepInstance*>* DefaultHepRepInstanceTree::getInstances() {
return &instances;
vector<HepRepInstance*> DefaultHepRepInstanceTree::getInstances() {
return instances;
}
bool DefaultHepRepInstanceTree::addInstanceTree(HepRepTreeID* treeID) {
instanceTrees.push_back(treeID);
return true;
void DefaultHepRepInstanceTree::addInstanceTree(HepRepTreeID* treeID) {
instanceTrees.insert(treeID);
}
HepRepTreeID* DefaultHepRepInstanceTree::getTypeTree() {
return typeTree;
}
vector<HepRepTreeID*>* DefaultHepRepInstanceTree::getInstanceTrees() {
return &instanceTrees;
set<HepRepTreeID*> DefaultHepRepInstanceTree::getInstanceTrees() {
return instanceTrees;
}
@@ -28,8 +28,3 @@ string DefaultHepRepTreeID::getName() {
string DefaultHepRepTreeID::getVersion() {
return version;
}
HepRepTreeID* DefaultHepRepTreeID::copy() {
return new DefaultHepRepTreeID(name, version, qualifier);
}
@@ -15,8 +15,16 @@ DefaultHepRepType::DefaultHepRepType(HepRepType* parentType, string typeName)
}
}
DefaultHepRepType::DefaultHepRepType(HepRepTypeTree* parentTypeTree, string typeName)
: DefaultHepRepDefinition(), parent(NULL), name(typeName) {
this->description = "No Description";
this->infoURL = "No Info URL";
parentTypeTree->addType(this);
}
DefaultHepRepType::~DefaultHepRepType() {
for (vector<HepRepType*>::iterator i1 = types.begin(); i1 != types.end(); i1++) {
for (set<HepRepType*>::iterator i1 = types.begin(); i1 != types.end(); i1++) {
delete (*i1);
}
}
@@ -56,8 +64,8 @@ HepRepAttValue* DefaultHepRepType::getAttValue(string attName) {
return value;
}
HepRepType* DefaultHepRepType::copy(HepRep*, HepRepType*) {
cerr << "DefaultHepRepType::copy(HepRep*, HepRepType*) not implemented." << endl;
HepRepType* DefaultHepRepType::copy(HepRepType*) {
cerr << "DefaultHepRepType::copy(HepRepType*) not implemented." << endl;
return NULL;
}
@@ -85,12 +93,11 @@ void DefaultHepRepType::setInfoURL(string info) {
this->infoURL = info;
}
bool DefaultHepRepType::addType(HepRepType* type) {
types.push_back(type);
return true;
void DefaultHepRepType::addType(HepRepType* type) {
types.insert(type);
}
vector<HepRepType*>* DefaultHepRepType::getTypes() {
return &types;
set<HepRepType*> DefaultHepRepType::getTypes() {
return types;
}
@@ -12,26 +12,25 @@ DefaultHepRepTypeTree::DefaultHepRepTypeTree(HepRepTreeID* typeTree)
}
DefaultHepRepTypeTree::~DefaultHepRepTypeTree() {
for (vector<HepRepType*>::iterator i1 = types.begin(); i1 != types.end(); i1++) {
for (set<HepRepType*>::iterator i1 = types.begin(); i1 != types.end(); i1++) {
delete (*i1);
}
}
HepRepTreeID* DefaultHepRepTypeTree::copy() {
return DefaultHepRepTreeID::copy();
}
HepRepTypeTree* DefaultHepRepTypeTree::copy(HepRep*) {
cerr << "DefaultHepRepTypeTree::copy(HepRep*) not implemented." << endl;
HepRepTypeTree* DefaultHepRepTypeTree::copy() {
cerr << "DefaultHepRepTypeTree::copy() not implemented." << endl;
return NULL;
}
bool DefaultHepRepTypeTree::addType(HepRepType* type) {
types.push_back(type);
return true;
void DefaultHepRepTypeTree::addType(HepRepType* type) {
types.insert(type);
}
vector<HepRepType*>* DefaultHepRepTypeTree::getTypes() {
return &types;
set<HepRepType*> DefaultHepRepTypeTree::getTypes() {
return types;
}
HepRepType* DefaultHepRepTypeTree::getType(string /*typeName*/) {
cerr << "DefaultHepRepTypeTree::getType(string) not implemented." << endl;
return NULL;
}
+3 -3
View File
@@ -20,8 +20,8 @@
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4HepRep.cc,v 1.20 2003/12/11 21:55:55 duns Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4HepRep.cc,v 1.21 2004/05/27 05:55:20 duns Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/**
@@ -71,7 +71,7 @@ G4VViewer* G4HepRep::CreateViewer (G4VSceneHandler& scene, const G4String& name)
cout << "G4HepRep::CreateViewer: Cannot create more than one G4HepRepViewer" << endl;
return NULL;
}
viewer = new G4HepRepViewer ((G4HepRepSceneHandler&)scene, name);
viewer = new G4HepRepViewer ((G4HepRepSceneHandler&)scene, *messenger, name);
return viewer;
}
@@ -20,8 +20,8 @@
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4HepRepFileSceneHandler.cc,v 1.18 2004/03/15 08:00:22 perl Exp $
// GEANT4 tag $Name: geant4-06-01 $
// $Id: G4HepRepFileSceneHandler.cc,v 1.19 2004/05/28 04:59:54 perl Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Joseph Perl 27th January 2002
@@ -674,6 +674,8 @@ void G4HepRepFileSceneHandler::AddHepRepInstance(const char* primName,
// Additional attributes.
hepRepXMLWriter->addAttValue("Layer",hepRepXMLWriter->typeDepth);
hepRepXMLWriter->addAttValue("LVol", fpCurrentLV->GetName());
hepRepXMLWriter->addAttValue("Region", fpCurrentLV->GetRegion()->GetName());
hepRepXMLWriter->addAttValue("RootRegion", fpCurrentLV->IsRootRegion());
hepRepXMLWriter->addAttValue("Solid", fpCurrentLV->GetSolid()->GetName());
hepRepXMLWriter->addAttValue("EType", fpCurrentLV->GetSolid()->GetEntityType());
hepRepXMLWriter->addAttValue("Material", fpCurrentLV->GetMaterial()->GetName());
@@ -731,6 +733,8 @@ void G4HepRepFileSceneHandler::CheckFileOpen() {
fileCounter++;
hepRepXMLWriter->addAttDef("LVol", "Logical Volume", "Physics","");
hepRepXMLWriter->addAttDef("Region", "Cuts Region", "Physics","");
hepRepXMLWriter->addAttDef("RootRegion", "Root Region", "Physics","");
hepRepXMLWriter->addAttDef("Solid", "Solid Name", "Physics","");
hepRepXMLWriter->addAttDef("EType", "Entity Type", "Physics","");
hepRepXMLWriter->addAttDef("Material", "Material Name", "Physics","");
@@ -20,8 +20,8 @@
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4HepRepMessenger.cc,v 1.4 2003/12/11 21:55:55 duns Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4HepRepMessenger.cc,v 1.6 2004/05/27 05:55:20 duns Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
#include "G4HepRepMessenger.hh"
@@ -39,35 +39,42 @@ G4HepRepMessenger::G4HepRepMessenger() :
setEventNumberSuffixCommand->SetDefaultValue("");
setEventNumberSuffixCommand->AvailableForStates(G4State_Idle);
/*
appendGeometryCommand = new G4UIcmdWithABool("/vis/heprep/appendGeometry", this);
appendGeometryCommand->SetGuidance("Appends copy of geometry to every event.");
appendGeometryCommand->SetParameterName("flag",false);
appendGeometryCommand->SetDefaultValue(true);
appendGeometryCommand->AvailableForStates(G4State_Idle);
*/
addPointAttributesCommand = new G4UIcmdWithABool("/vis/heprep/addPointAttributes", this);
addPointAttributesCommand->SetGuidance("Adds point attributes to the points of trajectories.");
addPointAttributesCommand->SetParameterName("flag",false);
addPointAttributesCommand->SetDefaultValue(false);
addPointAttributesCommand->AvailableForStates(G4State_Idle);
setCoordinateSystemCommand = new G4UIcmdWithAString("/vis/heprep/setCoordinateSystem", this);
setCoordinateSystemCommand->SetGuidance("Sets the prefered Coordinate System (e.g. \"xyz\" or \"zxy\".");
setCoordinateSystemCommand->SetParameterName("coordinateSystem",false);
setCoordinateSystemCommand->SetDefaultValue("xyz");
setCoordinateSystemCommand->AvailableForStates(G4State_Idle);
}
G4HepRepMessenger::~G4HepRepMessenger() {
delete setEventNumberSuffixCommand;
// delete appendGeometryCommand;
delete appendGeometryCommand;
delete addPointAttributesCommand;
delete heprepDirectory;
delete setCoordinateSystemCommand;
}
G4String G4HepRepMessenger::GetCurrentValue(G4UIcommand * command) {
if (command==setEventNumberSuffixCommand) {
return suffix;
// } else if (command==appendGeometryCommand) {
// return appendGeometryCommand->ConvertToString(geometry);
} else if (command==appendGeometryCommand) {
return appendGeometryCommand->ConvertToString(geometry);
} else if (command==addPointAttributesCommand) {
return addPointAttributesCommand->ConvertToString(pointAttributes);
} else if (command==setCoordinateSystemCommand) {
return coordinateSystem;
} else {
return "";
}
@@ -76,10 +83,12 @@ G4String G4HepRepMessenger::GetCurrentValue(G4UIcommand * command) {
void G4HepRepMessenger::SetNewValue(G4UIcommand * command, G4String newValue) {
if (command==setEventNumberSuffixCommand) {
suffix = newValue;
// } else if (command==appendGeometryCommand) {
// geometry = appendGeometryCommand->GetNewBoolValue(newValue);
} else if (command==appendGeometryCommand) {
geometry = appendGeometryCommand->GetNewBoolValue(newValue);
} else if (command==addPointAttributesCommand) {
pointAttributes = addPointAttributesCommand->GetNewBoolValue(newValue);
} else if (command==setCoordinateSystemCommand) {
coordinateSystem = newValue;
}
}
@@ -94,3 +103,7 @@ G4bool G4HepRepMessenger::appendGeometry() {
G4bool G4HepRepMessenger::addPointAttributes() {
return pointAttributes;
}
G4String G4HepRepMessenger::getCoordinateSystem() {
return coordinateSystem;
}
@@ -20,8 +20,8 @@
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4HepRepSceneHandler.cc,v 1.70 2004/02/05 18:41:49 duns Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4HepRepSceneHandler.cc,v 1.76 2004/05/28 04:59:54 perl Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/**
@@ -43,6 +43,8 @@
#include "HEPREP/HepRep.h"
//G4
#include "G4Vector3D.hh"
#include "G4RunManagerKernel.hh"
#include "G4Types.hh"
#include "G4Point3D.hh"
#include "G4Normal3D.hh"
@@ -78,6 +80,7 @@ using namespace std;
G4int G4HepRepSceneHandler::sceneCount = 0;
//#define LDEBUG 1
//#define SDEBUG 1
//#define PDEBUG 1
@@ -100,10 +103,11 @@ G4HepRepSceneHandler::G4HepRepSceneHandler (G4VGraphicsSystem& system, G4HepRepM
currentDepth (0),
currentPV (0),
currentLV (0),
_heprep (NULL)
_heprep (NULL),
_heprepGeometry (NULL)
{
#ifdef SDEBUG
#ifdef LDEBUG
cout << "G4HepRepSceneHandler::G4HepRepSceneHandler: " << system << endl;
#endif
@@ -121,7 +125,7 @@ G4HepRepSceneHandler::G4HepRepSceneHandler (G4VGraphicsSystem& system, G4HepRepM
G4HepRepSceneHandler::~G4HepRepSceneHandler () {
#ifdef SDEBUG
#ifdef LDEBUG
cout << "G4HepRepSceneHandler::~G4HepRepSceneHandler() " << endl;
#endif
close();
@@ -137,7 +141,7 @@ void G4HepRepSceneHandler::open(G4String name) {
if (writer != NULL) return;
if (name == "stdout") {
#ifdef SDEBUG
#ifdef LDEBUG
cout << "G4HepRepSceneHandler::Open() stdout" << endl;
#endif
writer = factory->createHepRepWriter(&cout, false, false);
@@ -150,7 +154,7 @@ void G4HepRepSceneHandler::open(G4String name) {
eventNumber = 0;
eventNumberWidth = 0;
} else if (name == "stderr") {
#ifdef SDEBUG
#ifdef LDEBUG
cout << "G4HepRepSceneHandler::Open() stderr" << endl;
#endif
writer = factory->createHepRepWriter(&cerr, false, false);
@@ -163,7 +167,7 @@ void G4HepRepSceneHandler::open(G4String name) {
eventNumber = 0;
eventNumberWidth = 0;
} else {
#ifdef SDEBUG
#ifdef LDEBUG
cout << "G4HepRepSceneHandler::Open() " << name << endl;
#endif
if (eventNumberWidth < 0) {
@@ -231,13 +235,14 @@ void G4HepRepSceneHandler::open(G4String name) {
void G4HepRepSceneHandler::openHepRep() {
#ifdef SDEBUG
#ifdef LDEBUG
cout << "G4HepRepSceneHandler::OpenHepRep() " << endl;
#endif
if (_heprep != NULL) return;
// all done on demand, once pointers are set to NULL
_heprepGeometry = NULL;
_geometryInstanceTree = NULL;
_geometryRootInstance = NULL;
_geometryInstance.clear();
@@ -262,7 +267,7 @@ void G4HepRepSceneHandler::openHepRep() {
bool G4HepRepSceneHandler::closeHepRep(bool final) {
if (_heprep == NULL) return true;
#ifdef SDEBUG
#ifdef LDEBUG
cout << "G4HepRepSceneHandler::CloseHepRep() start" << endl;
#endif
@@ -278,10 +283,21 @@ bool G4HepRepSceneHandler::closeHepRep(bool final) {
// using DrawView() called from /vis/viewer/flush)
if (_eventInstanceTree != NULL) {
GetCurrentViewer()->DrawView();
// couple geometry to event if geometry was written
if ((_geometryInstanceTree != NULL)) {
getEventInstanceTree()->addInstanceTree(getGeometryInstanceTree());
// couple geometry
if (messenger.appendGeometry()) {
// couple geometry to event if geometry was written
if ((_geometryInstanceTree != NULL)) {
getEventInstanceTree()->addInstanceTree(getGeometryInstanceTree());
}
} else {
char name[128];
if (writeMultipleFiles) {
sprintf(name, "%s%s%s#%s", baseName.c_str(), "-geometry", extension.c_str(), "G4GeometryData");
} else {
sprintf(name, "%s%s#%s", "geometry", ".heprep", "G4GeometryData");
}
getEventInstanceTree()->addInstanceTree(factory->createHepRepTreeID(name, "1.0"));
}
}
@@ -296,16 +312,31 @@ bool G4HepRepSceneHandler::closeHepRep(bool final) {
// Give this HepRep all of the layer order info for both geometry and event,
// since these will both end up in a single HepRep.
if (_geometryRootType != NULL) _heprep->addLayer(geometryLayer);
if (_eventType != NULL) _heprep->addLayer(eventLayer);
if (_calHitType != NULL) _heprep->addLayer(calHitLayer);
if (_trajectoryType != NULL) _heprep->addLayer(trajectoryLayer);
if (_hitType != NULL) _heprep->addLayer(hitLayer);
writeLayers(_heprepGeometry);
writeLayers(_heprep);
// open heprep file
if (writer == NULL) {
open((GetScene() == NULL) ? G4String("G4HepRepOutput.heprep.zip") : GetScene()->GetName());
}
// write out separate geometry
if (!messenger.appendGeometry() && (_heprepGeometry != NULL)) {
if (writeMultipleFiles) {
char fileName[128];
sprintf(fileName, "%s%s%s", baseName.c_str(), "-geometry", extension.c_str());
openFile(G4String(fileName));
}
if (!writeMultipleFiles) writer->addProperty("RecordLoop.ignore", "geometry.heprep");
writer->write(_heprepGeometry, G4String("geometry.heprep"));
delete _heprepGeometry;
_heprepGeometry = NULL;
if (writeMultipleFiles) closeFile();
}
if (writeMultipleFiles) {
// NOTE: does not work on Solaris 5.2 and Linux 2.95.2
@@ -346,16 +377,19 @@ bool G4HepRepSceneHandler::closeHepRep(bool final) {
void G4HepRepSceneHandler::close() {
#ifdef SDEBUG
#ifdef LDEBUG
cout << "G4HepRepSceneHandler::Close() " << endl;
#endif
if (writer == NULL) return;
if (!writeMultipleFiles) {
closeHepRep(true);
closeFile();
}
G4HepRepViewer* viewer = dynamic_cast<G4HepRepViewer*>(GetCurrentViewer());
viewer->reset();
}
void G4HepRepSceneHandler::openFile(G4String name) {
@@ -372,6 +406,14 @@ void G4HepRepSceneHandler::closeFile() {
out = NULL;
}
void G4HepRepSceneHandler::writeLayers(HepRep* heprep) {
if (heprep == NULL) return;
heprep->addLayer(geometryLayer);
heprep->addLayer(eventLayer);
heprep->addLayer(calHitLayer);
heprep->addLayer(trajectoryLayer);
heprep->addLayer(hitLayer);
}
void G4HepRepSceneHandler::EstablishSpecials(G4PhysicalVolumeModel& model) {
#ifdef SDEBUG
@@ -937,6 +979,43 @@ bool G4HepRepSceneHandler::isEventData () {
return !currentPV || fReadyForTransients;
}
void G4HepRepSceneHandler::addTopLevelAttributes(HepRepType* type) {
// Some non-standard attributes
type->addAttDef( "Generator", "Generator of the file", "General", "");
type->addAttValue("Generator", G4String("Geant4"));
type->addAttDef( "GeneratorVersion", "Version of the Generator", "General", "");
type->addAttValue("GeneratorVersion", G4RunManagerKernel::GetRunManagerKernel()->GetVersionString());
type->addAttDef( "CoordinateSystem", "Coordinate System", "Draw", "");
type->addAttValue("CoordinateSystem", messenger.getCoordinateSystem());
const G4ViewParameters parameters = GetCurrentViewer()->GetViewParameters();
const G4Vector3D& viewPointDirection = parameters.GetViewpointDirection();
type->addAttDef( "ViewTheta", "Theta of initial suggested viewpoint", "Draw", "rad");
type->addAttValue("ViewTheta", viewPointDirection.theta());
type->addAttDef( "ViewPhi", "Phi of initial suggested viewpoint", "Draw", "rad");
type->addAttValue("ViewPhi", viewPointDirection.phi());
type->addAttDef( "ViewScale", "Scale of initial suggested viewpoint", "Draw", "");
type->addAttValue("ViewScale", parameters.GetZoomFactor());
// FIXME, no way to set these
type->addAttDef( "ViewTranslateX", "Translate in X of initial suggested viewpoint", "Draw", "");
type->addAttValue("ViewTranslateX", 0.0);
type->addAttDef( "ViewTranslateY", "Translate in Y of initial suggested viewpoint", "Draw", "");
type->addAttValue("ViewTranslateY", 0.0);
type->addAttDef( "ViewTranslateZ", "Translate in Z of initial suggested viewpoint", "Draw", "");
type->addAttValue("ViewTranslateZ", 0.0);
type->addAttDef( "PointUnit", "Length", "Physics", "");
type->addAttValue("PointUnit", G4String("m"));
}
HepRep* G4HepRepSceneHandler::getHepRep() {
if (_heprep == NULL) {
// Create the HepRep that holds the Trees.
@@ -945,11 +1024,23 @@ HepRep* G4HepRepSceneHandler::getHepRep() {
return _heprep;
}
HepRep* G4HepRepSceneHandler::getHepRepGeometry() {
if (_heprepGeometry == NULL) {
// Create the HepRep that holds the Trees.
_heprepGeometry = factory->createHepRep();
}
return _heprepGeometry;
}
HepRepInstanceTree* G4HepRepSceneHandler::getGeometryInstanceTree() {
if (_geometryInstanceTree == NULL) {
// Create the Geometry InstanceTree.
_geometryInstanceTree = factory->createHepRepInstanceTree("G4GeometryData", "1.0", getGeometryTypeTree());
getHepRep()->addInstanceTree(_geometryInstanceTree);
if (messenger.appendGeometry()) {
getHepRep()->addInstanceTree(_geometryInstanceTree);
} else {
getHepRepGeometry()->addInstanceTree(_geometryInstanceTree);
}
}
return _geometryInstanceTree;
}
@@ -965,12 +1056,14 @@ HepRepInstance* G4HepRepSceneHandler::getGeometryRootInstance() {
HepRepInstance* G4HepRepSceneHandler::getGeometryInstance(G4LogicalVolume* volume, int depth) {
HepRepInstance* instance = getGeometryInstance(volume->GetName(), depth);
setAttribute(instance, "LVol", volume->GetName());
setAttribute(instance, "Solid", volume->GetSolid()->GetName());
setAttribute(instance, "EType", volume->GetSolid()->GetEntityType());
setAttribute(instance, "Material", volume->GetMaterial()->GetName());
setAttribute(instance, "Density", volume->GetMaterial()->GetDensity());
setAttribute(instance, "Radlen", volume->GetMaterial()->GetRadlen());
setAttribute(instance, "LVol", volume->GetName());
setAttribute(instance, "Region", volume->GetRegion()->GetName());
setAttribute(instance, "RootRegion", volume->IsRootRegion());
setAttribute(instance, "Solid", volume->GetSolid()->GetName());
setAttribute(instance, "EType", volume->GetSolid()->GetEntityType());
setAttribute(instance, "Material", volume->GetMaterial()->GetName());
setAttribute(instance, "Density", volume->GetMaterial()->GetDensity());
setAttribute(instance, "Radlen", volume->GetMaterial()->GetRadlen());
G4String state = materialState[volume->GetMaterial()->GetState()];
setAttribute(instance, "State", state);
@@ -1004,7 +1097,11 @@ HepRepTypeTree* G4HepRepSceneHandler::getGeometryTypeTree() {
// Create the Geometry TypeTree.
HepRepTreeID* geometryTreeID = factory->createHepRepTreeID("G4GeometryTypes", "1.0");
_geometryTypeTree = factory->createHepRepTypeTree(geometryTreeID);
getHepRep()->addTypeTree(_geometryTypeTree);
if (messenger.appendGeometry()) {
getHepRep()->addTypeTree(_geometryTypeTree);
} else {
getHepRepGeometry()->addTypeTree(_geometryTypeTree);
}
}
return _geometryTypeTree;
}
@@ -1012,12 +1109,16 @@ HepRepTypeTree* G4HepRepSceneHandler::getGeometryTypeTree() {
HepRepType* G4HepRepSceneHandler::getGeometryRootType() {
if (_geometryRootType == NULL) {
// Create the top level Geometry Type.
_geometryRootType = factory->createHepRepType(NULL, rootVolumeName);
_geometryRootType = factory->createHepRepType(getGeometryTypeTree(), rootVolumeName);
_geometryRootType->addAttValue("Layer", geometryLayer);
// Add attdefs used by all geometry types.
_geometryRootType->addAttDef ("LVol", "Logical Volume", "Physics","");
_geometryRootType->addAttValue("LVol", G4String(""));
_geometryRootType->addAttDef ("Region", "Cuts Region", "Physics","");
_geometryRootType->addAttValue("Region", G4String(""));
_geometryRootType->addAttDef ("RootRegion", "Root Region", "Physics","");
_geometryRootType->addAttValue("RootRegion", false);
_geometryRootType->addAttDef ("Solid", "Solid Name", "Physics","");
_geometryRootType->addAttValue("Solid", G4String(""));
_geometryRootType->addAttDef ("EType", "Entity Type", "Physics","");
@@ -1042,9 +1143,9 @@ HepRepType* G4HepRepSceneHandler::getGeometryRootType() {
_geometryRootType->addAttValue("MarkSizeMultiplier", 4.0);
_geometryRootType->addAttValue("LineWidthMultiplier", 1.0);
getGeometryTypeTree()->addType(_geometryRootType);
addTopLevelAttributes(_geometryRootType);
_geometryType["/"+_geometryRootType->getName()] = _geometryRootType;
}
return _geometryRootType;
@@ -1129,7 +1230,7 @@ HepRepTypeTree* G4HepRepSceneHandler::getEventTypeTree() {
HepRepType* G4HepRepSceneHandler::getEventType() {
if (_eventType == NULL) {
// Create the top level Event Type.
_eventType = factory->createHepRepType(NULL, "Event");
_eventType = factory->createHepRepType(getEventTypeTree(), "Event");
_eventType->addAttValue("Layer", eventLayer);
// add defaults for Events
@@ -1144,11 +1245,7 @@ HepRepType* G4HepRepSceneHandler::getEventType() {
_eventType->addAttValue("MarkSizeMultiplier", 4.0);
_eventType->addAttValue("LineWidthMultiplier", 1.0);
// Some non-standard attributes
_eventType->addAttDef("PointUnit", "Length", "Physics", "");
_eventType->addAttValue("PointUnit", G4String("m"));
getEventTypeTree()->addType(_eventType);
addTopLevelAttributes(_eventType);
}
return _eventType;
@@ -20,8 +20,8 @@
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4HepRepViewer.cc,v 1.22 2003/12/11 21:55:55 duns Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4HepRepViewer.cc,v 1.25 2004/05/27 05:59:08 duns Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/**
@@ -43,9 +43,10 @@
using namespace HEPREP;
using namespace std;
G4HepRepViewer::G4HepRepViewer (G4VSceneHandler& sceneHandler, const G4String& name)
G4HepRepViewer::G4HepRepViewer (G4VSceneHandler& sceneHandler, G4HepRepMessenger& heprepMessenger, const G4String& name)
: G4VViewer (sceneHandler, sceneHandler.IncrementViewCount(), name),
geometryIncluded(false) {
geometryIncluded(false),
messenger(heprepMessenger) {
#ifdef SDEBUG
cout << "G4HepRepViewer::G4HepRepViewer " << name << endl;
@@ -106,7 +107,7 @@ void G4HepRepViewer::ShowView () {
G4HepRepSceneHandler* sceneHandler = dynamic_cast<G4HepRepSceneHandler*>(GetSceneHandler());
if (sceneHandler->closeHepRep()) {
sceneHandler->openHepRep();
geometryIncluded = false;
if (messenger.appendGeometry()) geometryIncluded = false;
}
}
@@ -116,3 +117,7 @@ void G4HepRepViewer::FinishView () {
#endif
G4VViewer::FinishView();
}
void G4HepRepViewer::reset() {
geometryIncluded = false;
}
@@ -37,9 +37,22 @@ XMLHepRepWriter::~XMLHepRepWriter() {
delete xml;
}
bool XMLHepRepWriter::addProperty(std::string key, std::string value) {
properties[key] = value;
return true;
}
bool XMLHepRepWriter::close() {
xml->closeDoc(true);
if (zip != NULL) {
zip->putNextEntry(ZipCDirEntry("heprep.properties"));
map<string, string>::iterator i = properties.begin();
while (i != properties.end()) {
*zip << (*i).first << "=" << (*i).second << endl;
i++;
}
zip->closeEntry();
zip->finish();
zip->close();
}
@@ -58,15 +71,15 @@ bool XMLHepRepWriter::write(HepRep* heprep, string name) {
xml->openDoc();
xml->setAttribute("xmlns", "http://java.freehep.org/schemas/heprep/2.0");
xml->setAttribute("xmlns", "xsi", "http://www.w3.org/2001/XMLSchema-instance");
xml->setAttribute("xsi", "schemaLocation", "HepRep.xsd");
xml->setAttribute("xsi", "schemaLocation", "http://java.freehep.org/schemas/heprep/2.0 http://java.freehep.org/schemas/heprep/2.0/HepRep.xsd");
xml->openTag(nameSpace, "heprep");
write(heprep->getLayerOrder());
vector<HepRepTypeTree*>* typeTreeList = heprep->getTypeTrees();
for (vector<HepRepTypeTree*>::iterator i1=typeTreeList->begin(); i1 != typeTreeList->end(); i1++) {
set<HepRepTypeTree*> typeTreeSet = heprep->getTypeTrees();
for (set<HepRepTypeTree*>::iterator i1=typeTreeSet.begin(); i1 != typeTreeSet.end(); i1++) {
write(*i1);
}
vector<HepRepInstanceTree*>* instanceTreeList = heprep->getInstanceTrees();
for (vector<HepRepInstanceTree*>::iterator i2=instanceTreeList->begin(); i2 != instanceTreeList->end(); i2++) {
set<HepRepInstanceTree*> instanceTreeSet = heprep->getInstanceTrees();
for (set<HepRepInstanceTree*>::iterator i2=instanceTreeSet.begin(); i2 != instanceTreeSet.end(); i2++) {
write(*i2);
}
xml->closeTag();
@@ -78,10 +91,10 @@ bool XMLHepRepWriter::write(HepRep* heprep, string name) {
return true;
}
bool XMLHepRepWriter::write(vector<string> *layers) {
bool XMLHepRepWriter::write(vector<string> layers) {
string layerOrder = "";
bool comma = false;
for (vector<string>::iterator i=layers->begin(); i != layers->end(); i++) {
for (vector<string>::iterator i=layers.begin(); i != layers.end(); i++) {
if (comma) {
layerOrder.append(", ");
}
@@ -98,8 +111,8 @@ bool XMLHepRepWriter::write(HepRepTypeTree* typeTree) {
xml->setAttribute("version", typeTree->getVersion());
xml->openTag(nameSpace, "typetree");
vector<HepRepType*>* list = typeTree->getTypes();
for (vector<HepRepType*>::iterator i=list->begin(); i != list->end(); i++) {
set<HepRepType*> types = typeTree->getTypes();
for (set<HepRepType*>::iterator i=types.begin(); i != types.end(); i++) {
write(*i);
}
xml->closeTag();
@@ -112,8 +125,8 @@ bool XMLHepRepWriter::write(HepRepType* type) {
write((HepRepDefinition*)type);
write((HepRepAttribute*)type);
vector<HepRepType*>* list = type->getTypes();
for (vector<HepRepType*>::iterator i=list->begin(); i != list->end(); i++) {
set<HepRepType*> types = type->getTypes();
for (set<HepRepType*>::iterator i=types.begin(); i != types.end(); i++) {
write(*i);
}
xml->closeTag();
@@ -142,14 +155,14 @@ bool XMLHepRepWriter::write(HepRepInstanceTree* instanceTree) {
xml->setAttribute("typetreeversion", instanceTree->getTypeTree()->getVersion());
xml->openTag(nameSpace, "instancetree");
// refs
vector<HepRepTreeID*>* instanceTreeList = instanceTree->getInstanceTrees();
for (vector<HepRepTreeID*>::iterator i1=instanceTreeList->begin(); i1 != instanceTreeList->end(); i1++) {
set<HepRepTreeID*> instanceTreeSet = instanceTree->getInstanceTrees();
for (set<HepRepTreeID*>::iterator i1=instanceTreeSet.begin(); i1 != instanceTreeSet.end(); i1++) {
write(*i1);
}
// instances
vector<HepRepInstance*>* instanceList = instanceTree->getInstances();
for (vector<HepRepInstance*>::iterator i2=instanceList->begin(); i2 != instanceList->end(); i2++) {
vector<HepRepInstance*> instanceList = instanceTree->getInstances();
for (vector<HepRepInstance*>::iterator i2=instanceList.begin(); i2 != instanceList.end(); i2++) {
write(*i2);
}
xml->closeTag();
@@ -162,13 +175,13 @@ bool XMLHepRepWriter::write(HepRepInstance* instance) {
xml->openTag(nameSpace, "instance");
write((HepRepAttribute*)instance);
vector<HepRepPoint*>* pointList = instance->getPoints();
for (vector<HepRepPoint*>::iterator i1=pointList->begin(); i1 != pointList->end(); i1++) {
vector<HepRepPoint*> pointList = instance->getPoints();
for (vector<HepRepPoint*>::iterator i1=pointList.begin(); i1 != pointList.end(); i1++) {
write(*i1);
}
vector<HepRepInstance*>* instanceList = instance->getInstances();
for (vector<HepRepInstance*>::iterator i2=instanceList->begin(); i2 != instanceList->end(); i2++) {
vector<HepRepInstance*> instanceList = instance->getInstances();
for (vector<HepRepInstance*>::iterator i2=instanceList.begin(); i2 != instanceList.end(); i2++) {
write(*i2);
}
xml->closeTag();
@@ -179,7 +192,7 @@ bool XMLHepRepWriter::write(HepRepPoint* point) {
xml->setAttribute("x", point->getX());
xml->setAttribute("y", point->getY());
xml->setAttribute("z", point->getZ());
if (point->getAttValuesFromNode()->size() != 0) {
if (point->getAttValuesFromNode().size() != 0) {
xml->openTag(nameSpace, "point");
write((HepRepAttribute*)point);
xml->closeTag();
@@ -195,16 +208,16 @@ bool XMLHepRepWriter::write(HepRepAttribute* attribute) {
HepRepAttValue* layerAtt = attribute->getAttValueFromNode("layer");
if (layerAtt != NULL) write(layerAtt);
vector<HepRepAttValue*>* list = attribute->getAttValuesFromNode();
for (vector<HepRepAttValue*>::iterator i=list->begin(); i != list->end(); i++) {
set<HepRepAttValue*> attSet = attribute->getAttValuesFromNode();
for (set<HepRepAttValue*>::iterator i=attSet.begin(); i != attSet.end(); i++) {
write(*i);
}
return true;
}
bool XMLHepRepWriter::write(HepRepDefinition* definition) {
vector<HepRepAttDef*>* list = definition->getAttDefsFromNode();
for (vector<HepRepAttDef*>::iterator i=list->begin(); i != list->end(); i++) {
set<HepRepAttDef*> list = definition->getAttDefsFromNode();
for (set<HepRepAttDef*>::iterator i=list.begin(); i != list.end(); i++) {
write(*i);
}
return true;
+28 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.241 2004/03/16 08:46:58 gcosmo Exp $
$Id: History,v 1.247 2004/06/09 07:40:49 gcosmo Exp $
-------------------------------------------------------------------
=========================================================
@@ -24,10 +24,37 @@ committal in the CVS repository !
History file for visualization category
---------------------------------------
9th June 2004 Gabriele Cosmo (vis-V06-01-03)
- Adopt G4DLLIMPORT/G4DLLEXPORT technique to handle extern simbols for
allowing support of DLLs on Windows.
- Minor correction in modeling/GNUmakefile for GLOBLIBS definition.
- Coworks with "global-V06-01-02b".
7th June 2004 Gabriele Cosmo (vis-V06-01-02)
- Includes "vis-HepRep-V06-01-04".
- Export extern symbols for allowing support of DLLs on Windows.
Modified files: G4RayTrajectory.hh, G4RayTrajectoryPoint.hh.
- GNUmakefiles: added definition of GLOBLIBS for DLLs support on Windows.
- Coworks with "global-V06-01-02a".
9th April 2004 John Allison (vis-V06-01-01 + interfaces-V06-01-00)
- Tagged OpenGL as below. Joint with interfaces-V06-01-00.
7th April 2004 Guy Barrand
- visualization/OpenGL/* : use the G4OpenGL.hh file.
- Added : visualization/OpenGL/include/G4OpenGL.hh to encapsulate
the include of gl/gl.h and gl/glu.h that may be platform dependant.
It permits to rm some #ifdef WIN32 spread in the code. It opens also
the way to the usage of the Apple OpenGL on a Mac.
14 March 2004 Joseph Perl (vis-V06-00-01)
- HepRepFile handle duplicate ShowView.
- HepRepFile improve layering and hierarchy for hits.
17th February 2004 John Allison (opengl-V06-00-00)
- Fixed bug #581: wrong order of statements in
G4OpenGLXViewer::~G4OpenGLXViewer (see bug report).
1st December 2003 John Allison
- Added checks and minor improvment of behaviour at end of event and run:
o G4VisManager::EndOfRun: added check on MarkForClearingTransientStore.
+8 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.5 2003/10/03 15:06:56 gcosmo Exp $
# $Id: GNUmakefile,v 1.6 2004/06/03 11:40:13 gcosmo Exp $
name := G4OpenGL
@@ -6,6 +6,13 @@ ifndef G4INSTALL
G4INSTALL = ../../..
endif
GLOBLIBS = libG4vis_management.lib libG4modeling.lib
GLOBLIBS += libG4interfaces.lib libG4run.lib libG4event.lib
GLOBLIBS += libG4tracking.lib libG4processes.lib libG4digits_hits.lib
GLOBLIBS += libG4track.lib libG4particles.lib libG4geometry.lib
GLOBLIBS += libG4materials.lib libG4graphics_reps.lib
GLOBLIBS += libG4intercoms.lib libG4global.lib
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/G4VIS_BUILD.gmk
include $(G4INSTALL)/config/interactivity.gmk
@@ -0,0 +1,33 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
#ifndef G4OpenGL_h
#define G4OpenGL_h
#ifdef WIN32
#include <windows.h>
#endif
#include <GL/gl.h>
#include <GL/glu.h>
#endif
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLSceneHandler.hh,v 1.14 2003/06/10 17:58:55 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenGLSceneHandler.hh,v 1.15 2004/04/07 15:17:12 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Andrew Walkden 27th March 1996
@@ -37,11 +37,7 @@
#include "globals.hh"
#include "G4RotationMatrix.hh"
#ifdef WIN32
#include <windows.h>
#endif
#include <GL/gl.h>
#include <GL/glu.h>
#include "G4OpenGL.hh"
#include "G4VSceneHandler.hh"
#include "G4OpenGLViewer.hh"
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLTransform3D.hh,v 1.5 2003/06/10 17:41:04 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenGLTransform3D.hh,v 1.6 2004/04/07 15:17:12 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Andrew Walkden 24th October 1996
@@ -36,10 +36,7 @@
#include "G4Transform3D.hh"
#ifdef WIN32
#include <windows.h>
#endif
#include <GL/gl.h>
#include "G4OpenGL.hh"
class G4OpenGLTransform3D : public G4Transform3D {
public:
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLXViewer.hh,v 1.18 2003/09/22 10:37:50 johna Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4OpenGLXViewer.hh,v 1.19 2004/04/07 15:17:12 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Andrew Walkden 7th February 1997
@@ -42,9 +42,7 @@
#include <X11/Intrinsic.h>
#include <X11/Xmu/StdCmap.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glu.h>
class G4OpenGLSceneHandler;
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLImmediateXViewer.cc,v 1.8 2003/06/10 17:13:32 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenGLImmediateXViewer.cc,v 1.9 2004/04/07 15:18:22 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Andrew Walkden 7th February 1997
@@ -33,8 +33,6 @@
#include "G4OpenGLImmediateXViewer.hh"
#include <GL/gl.h>
#include "G4ios.hh"
G4OpenGLImmediateXViewer::
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLImmediateXm.cc,v 1.8 2002/02/24 01:48:05 johna Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenGLImmediateXm.cc,v 1.9 2004/04/07 15:18:22 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Andrew Walkden 10th February 1997
@@ -30,8 +30,6 @@
#ifdef G4VIS_BUILD_OPENGLXM_DRIVER
#include <GL/gl.h>
#include "G4VisFeaturesOfOpenGL.hh"
#include "G4VSceneHandler.hh"
#include "G4OpenGLSceneHandler.hh"
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLImmediateXmViewer.cc,v 1.8 2003/06/10 17:13:33 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenGLImmediateXmViewer.cc,v 1.9 2004/04/07 15:18:22 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Andrew Walkden 10th February 1997
@@ -33,8 +33,6 @@
#include "G4OpenGLImmediateXmViewer.hh"
#include <GL/gl.h>
#include "G4ios.hh"
G4OpenGLImmediateXmViewer::
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLStoredWin32.cc,v 1.10 2003/06/10 17:41:04 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenGLStoredWin32.cc,v 1.11 2004/04/07 15:18:22 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// OpenGLStoredWin32 graphics system factory.
@@ -37,11 +37,6 @@
#include "G4OpenGLStoredWin32.hh"
#include "G4OpenGLStoredWin32Viewer.hh"
#ifdef WIN32
#include <windows.h>
#endif
#include <GL/gl.h>
G4OpenGLStoredWin32::G4OpenGLStoredWin32 ():
G4VGraphicsSystem ("OpenGLStoredWin32",
"OGLSWin32",
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLStoredX.cc,v 1.8 2002/02/24 01:48:17 johna Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenGLStoredX.cc,v 1.9 2004/04/07 15:18:22 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Andrew Walkden 10th February 1997
@@ -31,8 +31,6 @@
#ifdef G4VIS_BUILD_OPENGLX_DRIVER
#include <GL/gl.h>
#include "G4VisFeaturesOfOpenGL.hh"
#include "G4VSceneHandler.hh"
#include "G4OpenGLSceneHandler.hh"
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLStoredXViewer.cc,v 1.9 2003/06/10 17:13:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenGLStoredXViewer.cc,v 1.10 2004/04/07 15:18:22 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Andrew Walkden 7th February 1997
@@ -33,8 +33,6 @@
#include "G4OpenGLStoredXViewer.hh"
#include <GL/gl.h>
#include "G4ios.hh"
G4OpenGLStoredXViewer::
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLStoredXmViewer.cc,v 1.8 2003/06/10 17:13:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenGLStoredXmViewer.cc,v 1.9 2004/04/07 15:18:23 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Andrew Walkden 10th February 1997
@@ -33,8 +33,6 @@
#include "G4OpenGLStoredXmViewer.hh"
#include <GL/gl.h>
#include "G4ios.hh"
G4OpenGLStoredXmViewer::
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLWin32Viewer.cc,v 1.9 2003/06/25 09:01:12 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenGLWin32Viewer.cc,v 1.13 2004/04/08 15:36:32 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// G4OpenGLWin32Viewer : Class to provide WindowsNT specific
@@ -71,6 +71,12 @@ void G4OpenGLWin32Viewer::FinishView (
{
if(!fHDC) return;
::SwapBuffers(fHDC);
// Empty the Windows message queue :
MSG event;
while ( ::PeekMessage(&event, NULL, 0, 0, PM_REMOVE) ) {
::TranslateMessage(&event);
::DispatchMessage (&event);
}
}
//////////////////////////////////////////////////////////////////////////////
@@ -197,10 +203,10 @@ LRESULT CALLBACK G4OpenGLWin32Viewer::WindowProc (
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
/*
switch (aMessage) {
case WM_PAINT:{
G4OpenGLWin32Viewer* This =
(G4OpenGLWin32Viewer*)::GetWindowLong(aWindow,GWL_USERDATA);
printf("debug : PAINT\n");
HDC hDC;
PAINTSTRUCT ps;
hDC = BeginPaint(aWindow,&ps);
@@ -208,11 +214,26 @@ LRESULT CALLBACK G4OpenGLWin32Viewer::WindowProc (
// FIXME : To have an automatic refresh someone have to redraw here.
}
EndPaint(aWindow, &ps);
//FIXME : have to handle WM_RESIZE
//pView->WinSize_x = (G4int) width;
//pView->WinSize_y = (G4int) height;
G4OpenGLWin32Viewer* This =
(G4OpenGLWin32Viewer*)::GetWindowLong(aWindow,GWL_USERDATA);
if(This) {
This->SetView();
glViewport(0,0,This->WinSize_x,This->WinSize_y);
This->ClearView();
This->DrawView();
// WARNING : the below empty the Windows message queue...
This->FinishView();
}
return 0;
} return 0;
default:
return DefWindowProc(aWindow,aMessage,aWParam,aLParam);
}
*/
return DefWindowProc(aWindow,aMessage,aWParam,aLParam);
}
//////////////////////////////////////////////////////////////////////////////
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLXViewer.cc,v 1.20 2004/02/17 18:17:34 johna Exp $
// GEANT4 tag $Name: geant4-06-01 $
// $Id: G4OpenGLXViewer.cc,v 1.21 2004/04/07 15:18:23 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Andrew Walkden 7th February 1997
@@ -33,10 +33,6 @@
#include "G4OpenGLXViewer.hh"
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glu.h>
#include "G4ios.hh"
#include "G4VisExtent.hh"
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenGLXmViewer.cc,v 1.11 2002/02/24 01:48:29 johna Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenGLXmViewer.cc,v 1.12 2004/04/07 15:18:23 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Andrew Walkden 10th February 1997
@@ -35,10 +35,6 @@
#include "G4OpenGLXmViewer.hh"
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glu.h>
#include "G4ios.hh"
#include "G4VisExtent.hh"
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.5 2003/10/03 15:11:05 gcosmo Exp $
# $Id: GNUmakefile,v 1.6 2004/06/03 11:40:13 gcosmo Exp $
name := G4OpenInventor
@@ -6,6 +6,13 @@ ifndef G4INSTALL
G4INSTALL = ../../..
endif
GLOBLIBS = libG4vis_management.lib libG4modeling.lib
GLOBLIBS += libG4interfaces.lib libG4run.lib libG4event.lib
GLOBLIBS += libG4tracking.lib libG4processes.lib libG4digits_hits.lib
GLOBLIBS += libG4track.lib libG4particles.lib libG4geometry.lib
GLOBLIBS += libG4materials.lib libG4graphics_reps.lib
GLOBLIBS += libG4intercoms.lib libG4global.lib
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/G4VIS_BUILD.gmk
include $(G4INSTALL)/config/interactivity.gmk
+14 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.5 2003/10/29 10:02:24 gcosmo Exp $
$Id: History,v 1.7 2004/06/14 09:27:33 gcosmo Exp $
-------------------------------------------------------------------
=========================================================
@@ -20,6 +20,19 @@ committal in the CVS repository !
History file for visualization/OpenInventor
-------------------------------------------
08th April 2004 Guy Barrand (openinventor-V06-01-00)
- Bring in the repository the necessary HEPVis code. In fact few of HEPVis
is used in this G4 driver. Then HEPVis is no more needed.
Note that, to avoid clashes of G4/vis within experiments, the HEPVis
node are protected by some : #define Geant4_<node> <node>. Then, for
example, within the G4OpenInventor lib there are Geant4_SoBox, etc...
(and not SoBox,... that may clash with other HEPVis code in experiments).
- Have code to run on Windows.
- Split Viewer to have G4OpenInventorXtViewer and G4OpenInventorWinViewer.
- Split G4OpenInventor to have G4OpenInventorXt and G4OpenInventorWin.
Xt and Win (and not X and Win32 like in vis/OpenGL) to follow
the conventions found in the OpenInventor world.
29th October 2003 Cosmo Gabriele (openinventor-V05-02-00)
- Patch in G4OpenInventorSceneHandler in PreAddThis() to cope with changes
introduced in G4VPhysicalVolume in "geant4-05-02-ref-04", where pointer to
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenInventor.hh,v 1.6 2001/07/11 10:08:59 gunter Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenInventor.hh,v 1.7 2004/04/08 09:39:37 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
// Guy Barrand 26 Mar 1998.
// OpenInventor graphics system factory.
@@ -40,11 +40,10 @@ class G4OpenInventor: public G4VGraphicsSystem {
public:
G4OpenInventor(const G4String,const G4String,G4VGraphicsSystem::Functionality);
virtual ~G4OpenInventor();
G4VViewer* CreateViewer(G4VSceneHandler&,const G4String& name = "");
void SetInteractorManager(G4VInteractorManager*);
G4VInteractorManager* GetInteractorManager();
G4VSceneHandler* CreateSceneHandler (const G4String& name);
void InitHEPVis();
void InitNodes();
private:
G4VInteractorManager* interactorManager;
};
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorSceneHandler.hh,v 1.15 2003/10/29 10:01:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4OpenInventorSceneHandler.hh,v 1.16 2004/04/08 09:39:38 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// J Kallenbach 27th Aug 1996
@@ -44,7 +44,8 @@ class SoSeparator;
// Base class for various OpenInventorScene classes.
class G4OpenInventorSceneHandler: public G4VSceneHandler {
friend class G4OpenInventorViewer;
friend class G4OpenInventorXtViewer;
friend class G4OpenInventorWinViewer;
public:
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorSceneHandler.icc,v 1.4 2001/07/11 10:08:59 gunter Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenInventorSceneHandler.icc,v 1.5 2004/04/08 09:39:38 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// J Kallenbach 27th Aug 1996
@@ -21,16 +21,16 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorTransform3D.hh,v 1.4 2001/07/11 10:09:00 gunter Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenInventorTransform3D.hh,v 1.5 2004/04/08 09:39:38 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// jck 17 Dec 1996
// G4OpenGLInventorTransform3D provides SoSFMatrix transformation matrix
// from G4Transform3D.
#ifndef G4OpenInventorTRANSFORM3D_HH
#define G4OpenInventorTRANSFORM3D_HH
#ifndef G4OPENINVENTORTRANSFORM3D_HH
#define G4OPENINVENTORTRANSFORM3D_HH
#ifdef G4VIS_BUILD_OI_DRIVER
@@ -20,40 +20,26 @@
// * statement, and all its terms. *
// ********************************************************************
//
#ifndef G4SOWINDOW_h
#define G4SOWINDOW_h
//
// $Id: G4OpenInventorWin.hh,v 1.1 2004/04/08 09:37:30 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
// OpenInventor graphics system factory.
#include <Inventor/Xt/SoXt.h>
#include <HEPVis/SbBasic.h>
#if defined (G4VIS_BUILD_OIWIN32_DRIVER) || defined (G4VIS_USE_OIWIN32)
class SbDict;
#ifndef G4OPENINVENTORWIN_HH
#define G4OPENINVENTORWIN_HH
class G4SoWindow {
#include "G4OpenInventor.hh"
class G4OpenInventorWin: public G4OpenInventor {
public:
G4SoWindow(const char*,SbBool=FALSE);
virtual ~G4SoWindow();
Widget getWidget() const;
void show();
void hide();
void setTitle(const char*);
void setSize(const SbVec2s&);
SbVec2s getSize();
void setWMClose(SbBool);
SbBool getWMClose() const;
static void clearClass();
protected:
void registerWidget(Widget);
void unregisterWidget(Widget);
static G4SoWindow* getWindow(Widget);
private:
Widget fWidget;
SbBool fWMClose;
static SbDict* fWidgetDictionary;
#ifdef HEPVisXt
static void widgetDestroyedCB(Widget,XtPointer,XtPointer);
public:
static void closeWindow(Widget,XEvent*,char**,Cardinal*);
#endif
G4OpenInventorWin ();
virtual ~G4OpenInventorWin ();
G4VViewer* CreateViewer(G4VSceneHandler&,const G4String& name = "");
};
#endif
#endif
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorWin32.hh,v 1.5 2001/07/11 10:09:00 gunter Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenInventorWin32.hh,v 1.6 2004/04/08 09:39:38 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
// OpenInventor graphics system factory.
@@ -31,12 +31,14 @@
#ifndef G4OPENINVENTORWIN32_HH
#define G4OPENINVENTORWIN32_HH
#include "G4OpenInventor.hh"
// For backward compatibilty.
class G4OpenInventorWin32: public G4OpenInventor {
#include "G4OpenInventorWin.hh"
class G4OpenInventorWin32: public G4OpenInventorWin {
public:
G4OpenInventorWin32 ();
virtual ~G4OpenInventorWin32 ();
G4OpenInventorWin32 () {}
virtual ~G4OpenInventorWin32 () {}
};
#endif
@@ -0,0 +1,69 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4OpenInventorWinViewer.hh,v 1.2 2004/04/08 10:49:10 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Jeff Kallenbach 01 Aug 1996
// OpenInventor viewer - opens window, hard copy, etc.
#ifndef G4OPENINVENTORWINVIEWER_HH
#define G4OPENINVENTORWINVIEWER_HH
#ifdef G4VIS_BUILD_OI_DRIVER
#include "G4VViewer.hh"
#include <windows.h>
class SoWinExaminerViewer;
class SoSelection;
class G4OpenInventorSceneHandler;
class G4VInteractorManager;
class G4OpenInventorWinViewer: public G4VViewer {
public:
G4OpenInventorWinViewer(G4OpenInventorSceneHandler& scene,
const G4String& name = "");
virtual ~G4OpenInventorWinViewer();
void DrawView();
void ShowView();
private:
void ClearView();
void FinishView();
void SetView();
void KernelVisitDecision();
G4bool CompareForKernelVisit(G4ViewParameters&);
G4OpenInventorSceneHandler& fG4OpenInventorSceneHandler;
G4ViewParameters fLastVP; // Memory for making kernel visit decisions.
HWND fShell;
SoWinExaminerViewer* fViewer;
SoSelection* fSelection;
G4VInteractorManager* fInteractorManager;
};
#endif
#endif
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorX.hh,v 1.5 2001/07/11 10:09:00 gunter Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenInventorX.hh,v 1.6 2004/04/08 09:39:38 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Andrew Walkden 27th March 1996
@@ -33,12 +33,14 @@
#ifndef G4OPENINVENTORX_HH
#define G4OPENINVENTORX_HH
#include "G4OpenInventor.hh"
// For backward compatibilty.
class G4OpenInventorX: public G4OpenInventor {
#include "G4OpenInventorXt.hh"
class G4OpenInventorX: public G4OpenInventorXt {
public:
G4OpenInventorX ();
virtual ~G4OpenInventorX ();
G4OpenInventorX () {}
virtual ~G4OpenInventorX () {}
};
#endif
@@ -0,0 +1,47 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4OpenInventorXt.hh,v 1.1 2004/04/08 09:37:30 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Andrew Walkden 27th March 1996
// OpenInventor graphics system factory.
#if defined (G4VIS_BUILD_OIX_DRIVER) || defined (G4VIS_USE_OIX)
#ifndef G4OPENINVENTORXT_HH
#define G4OPENINVENTORXT_HH
#include "G4OpenInventor.hh"
class G4OpenInventorXt: public G4OpenInventor {
public:
G4OpenInventorXt ();
virtual ~G4OpenInventorXt ();
G4VViewer* CreateViewer(G4VSceneHandler&,const G4String& name = "");
};
#endif
#endif
@@ -21,51 +21,48 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorViewer.hh,v 1.10 2001/11/14 14:56:11 barrand Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenInventorXtViewer.hh,v 1.1 2004/04/08 09:37:30 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Jeff Kallenbach 01 Aug 1996
// OpenInventor viewer - opens window, hard copy, etc.
#ifndef G4OPENINVENTORVIEWER_HH
#define G4OPENINVENTORVIEWER_HH
#ifndef G4OPENINVENTORXTVIEWER_HH
#define G4OPENINVENTORXTVIEWER_HH
#ifdef G4VIS_BUILD_OI_DRIVER
#include <Inventor/Xt/SoXt.h>
#include "G4VViewer.hh"
class SoXtComponent;
#include <X11/Intrinsic.h>
class SoXtExaminerViewer;
class SoSelection;
class G4SoWindow;
class G4OpenInventorSceneHandler;
class G4VInteractorManager;
//
// Base class for various OpenInventorView classes.
//
class G4OpenInventorViewer: public G4VViewer {
class G4OpenInventorXtViewer: public G4VViewer {
public:
G4OpenInventorViewer (G4OpenInventorSceneHandler& scene,
const G4String& name = "");
virtual ~G4OpenInventorViewer ();
void DrawView ();
void ShowView ();
G4OpenInventorXtViewer(G4OpenInventorSceneHandler& scene,
const G4String& name = "");
virtual ~G4OpenInventorXtViewer();
void DrawView();
void ShowView();
private:
void ClearView ();
void FinishView ();
void SetView ();
void KernelVisitDecision ();
void ClearView();
void FinishView();
void SetView();
void KernelVisitDecision();
G4bool CompareForKernelVisit(G4ViewParameters&);
G4OpenInventorSceneHandler& fG4OpenInventorSceneHandler;
G4ViewParameters fLastVP; // Memory for making kernel visit decisions.
Widget fShell;
G4SoWindow* fWindow;
SoXtComponent* fViewer; // The Inventor Viewer
SoXtExaminerViewer* fViewer;
SoSelection* fSelection;
G4VInteractorManager* fInteractorManager;
};
@@ -0,0 +1,53 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: SbMath.h,v 1.2 2004/06/14 09:27:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
#ifndef HEPVis_SbMath_h
#define HEPVis_SbMath_h
#include <math.h>
#ifndef M_PI
#define M_PI 3.1415926535897931160E0
#define M_PI_2 1.5707963267948965580E0
#endif
#define SbMinimum(a,b) ((a)<(b)?a:b)
#define SbMaximum(a,b) ((a)>(b)?a:b)
#define FCOS(x) ((float)cos((double)(x)))
#define FSIN(x) ((float)sin((double)(x)))
#define FACOS(x) ((float)acos((double)(x)))
#define FASIN(x) ((float)asin((double)(x)))
#define FTAN(x) ((float)tan((double)(x)))
#define FATAN(x) ((float)atan((double)(x)))
#define FSQRT(x) ((float)sqrt((double)(x)))
#define FPOW(x,y) ((float)pow((double)(x),(double)(y)))
#define FLOG(x) ((float)log((double)(x)))
#define FLOG10(x) ((float)log10((double)(x)))
#define FFLOOR(x) ((float)floor((double)(x)))
#define FFABS(x) ((float)fabs((double)(x)))
#define FCEIL(x) ((float)ceil((double)(x)))
#endif
@@ -0,0 +1,115 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: SoDetectorTreeKit.h,v 1.2 2004/06/14 09:27:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/*-----------------------------Hepvis----------------------------------------*/
/* */
/* Node: SoDetectorTreeKit */
/* Description: Easy way of browsing through a tree of detectors */
/* Author: Joe Boudreau Nov 11 1996 */
/* */
/*---------------------------------------------------------------------------*/
#ifndef HEPVis_SoDetectorTreeKit_h
#define HEPVis_SoDetectorTreeKit_h
#include <Inventor/nodekits/SoBaseKit.h>
#include <Inventor/nodes/SoEventCallback.h>
class SoSFNode;
class SoHandleEventAction;
class SoSeparator;
#define SoDetectorTreeKit Geant4_SoDetectorTreeKit
class SoDetectorTreeKit:public SoBaseKit {
// The following is required:
SO_KIT_HEADER(SoDetectorTreeKit);
////////////////////////////////////////////
SoSFNode alternateRep;
////////////////////////////////////////////
SO_KIT_CATALOG_ENTRY_HEADER(callbackList);
SO_KIT_CATALOG_ENTRY_HEADER(topSeparator);
SO_KIT_CATALOG_ENTRY_HEADER(pickStyle);
SO_KIT_CATALOG_ENTRY_HEADER(appearance);
SO_KIT_CATALOG_ENTRY_HEADER(units);
SO_KIT_CATALOG_ENTRY_HEADER(transform);
SO_KIT_CATALOG_ENTRY_HEADER(texture2Transform);
SO_KIT_CATALOG_ENTRY_HEADER(childList);
SO_KIT_CATALOG_ENTRY_HEADER(previewSeparator);
SO_KIT_CATALOG_ENTRY_HEADER(fullSeparator);
public:
// Constructor, required
SoDetectorTreeKit();
// This is required
virtual SbBool affectsState() const;
// Class Initializer, required
static void initClass();
// Turn the preview on or off
virtual void setPreview(SbBool Flag);
// Return the preview state
virtual SbBool getPreview() const;
// Return the preview Separator
virtual SoSeparator *getPreviewSeparator() const;
// Return the full Separator
virtual SoSeparator *getFullSeparator() const;
// Generate AlternateRep, required. Generating an alternate representation
// must be done upon users request. It allows an Inventor program to read
// back the file without requiring *this* code to be dynamically linked.
// If the users expects that *this* code will be dynamically linked, he
// need not invoke this method.
virtual void generateAlternateRep();
// We better be able to clear it, too!
virtual void clearAlternateRep();
protected:
// Destructor.
virtual ~SoDetectorTreeKit();
private:
// This is needed as well
void createInitialTree();
// This is the callback function that will be
// added to the callback list
static void expand (void *userData, SoEventCallback *eventCB);
static void contract (void *userData, SoEventCallback *eventCB);
};
#endif
@@ -0,0 +1,155 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: SoBox.h,v 1.2 2004/06/14 09:27:36 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/*-----------------------------Hepvis----------------------------------------*/
/* */
/* Node: SoBox */
/* Description: Represents the G4Box Geant Geometry entity */
/* Author: Joe Boudreau Nov 11 1996 */
/* */
/*---------------------------------------------------------------------------*/
#ifndef HEPVis_SoBox_h
#define HEPVis_SoBox_h
#include <Inventor/fields/SoSFFloat.h>
#include <Inventor/fields/SoSFNode.h>
#include <Inventor/nodes/SoShape.h>
class SoSFNode;
//! SoBox - Inventor version of the G4Box Geant Geometry entity
/*!
* Node: SoBox
*
* Description: The Inventor version of the G4Box Geant Geometry entity
*
* Author: Joe Boudreau Nov 11 1996
*
* class G4Box
*
* A Box is a cuboid of given half lengths dx,dy,dz. The Box is
* centred on the origin with sides parallel to the x/y/z axes.
*
* Always use Inventor Fields. This allows Inventor to detect a change to
* the data field and take the appropriate action; e.g., redraw the scene.
*/
#define SoBox Geant4_SoBox
class SoBox:public SoShape {
// The following is required:
SO_NODE_HEADER(SoBox);
public:
//
//! Half-length along X
//
SoSFFloat fDx;
//
//! Half-length along Y
//
SoSFFloat fDy;
//
//! Half-length along Z
//
SoSFFloat fDz;
//
//! Alternate rep - for use by users without HEPVis shared objects
//
SoSFNode alternateRep;
//
//! Constructor, required
//
SoBox();
//
//! Class Initializer, required
//
static void initClass();
//
//! Generate AlternateRep, required. Generating an alternate representation
//! must be done upon users request. It allows an Inventor program to read
//! back the file without requiring *this* code to be dynamically linked.
//! If the users expects that *this* code will be dynamically linked, he
//! need not invoke this method.
//
virtual void generateAlternateRep();
//
//! We better be able to clear it, too!
//
virtual void clearAlternateRep();
protected:
//
//! compute bounding Box, required
//
virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center );
//
//! Generate Primitives, required
//
virtual void generatePrimitives(SoAction *action);
//
//! GetChildList, required whenever the class has hidden children
//
virtual SoChildList *getChildren() const;
protected:
//
//! Destructor, required
//
virtual ~SoBox();
private:
//
//! Generate Children. Used to create the hidden children. Required whenever
//! the node has hidden children.
//
void generateChildren();
//
//! Used to modify hidden children when a data field is changed. Required
//! whenever the class has hidden children.
//
void updateChildren();
//
//! ChildList. Required whenever the class has hidden children.
//
SoChildList *children;
};
#endif
@@ -0,0 +1,191 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: SoCons.h,v 1.2 2004/06/14 09:27:36 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/*-----------------------------Hepvis----------------------------------------*/
/* */
/* Node: SoCons */
/* Description: Represents the G4Cons Geant Geometry entity */
/* Author: Joe Boudreau Nov 11 1996 */
/* */
/*---------------------------------------------------------------------------*/
#ifndef HEPVis_SoCons_h
#define HEPVis_SoCons_h
#include <Inventor/fields/SoSFFloat.h>
#include <Inventor/fields/SoSFNode.h>
#include <Inventor/fields/SoSFBool.h>
#include <Inventor/nodes/SoShape.h>
class SoSFNode;
//! SoCons - Inventor version of the G4Cons Geant Geometry entity
/*!
* Node: SoCons
*
* Description: The Inventor version of the G4Cons Geant Geometry entity
*
* Author: Joe Boudreau Nov 11 1996
*
* A G4Cons is, in the general case, a Phi segment of a cone, with half-length
* fDz, inner and outer radii specified at -fDz and +fDz. The Phi segment is
* described by a starting fSPhi angle, and the +fDPhi delta angle for the shape.
* If the delta angle is >=2*M_PI, the shape is treated as continuous in Phi
*
* Member Data:
*
* fRmin1 inside radius at -fDz
* fRmin2 inside radius at +fDz
* fRmax1 outside radius at -fDz
* fRmax2 outside radius at +fDz
* fDz half length in z
*
* fSPhi starting angle of the segment in radians
* fDPhi delta angle of the segment in radians
*/
#define SoCons Geant4_SoCons
class SoCons:public SoShape {
// The following is required:
SO_NODE_HEADER(SoCons);
public:
//
//! Inside radius at -fDz
//
SoSFFloat fRmin1;
//
//! Inside radius at +fDz
//
SoSFFloat fRmin2;
//
//! Outside radius at -fDz
//
SoSFFloat fRmax1;
//
//! Outside radius at +fDz
//
SoSFFloat fRmax2;
//
//! Half-length along Z
//
SoSFFloat fDz;
//
//! Starting angle, in radians
//
SoSFFloat fSPhi;
//
//! Delta-angle, in radians
//
SoSFFloat fDPhi;
//
//! An Inventor option - slightly better render, worse performance
//
SoSFBool smoothDraw;
//
//! Alternate rep required - for use by users without HEPVis shared objects
//
SoSFNode alternateRep;
//
//! Constructor, required
//
SoCons();
//
//! Class Initializer, required
//
static void initClass();
//
//! Generate AlternateRep, required. Generating an alternate representation
//! must be done upon users request. It allows an Inventor program to read
//! back the file without requiring *this* code to be dynamically linked.
//! If the users expects that *this* code will be dynamically linked, he
//! need not invoke this method.
//
virtual void generateAlternateRep();
//
//! We better be able to clear it, too!
//
virtual void clearAlternateRep();
protected:
//
//! compute bounding Box, required
//
virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center );
//
//! Generate Primitives, required
//
virtual void generatePrimitives(SoAction *action);
//
//! GetChildList, required whenever the class has hidden children
//
virtual SoChildList *getChildren() const;
protected:
//
//! Destructor, required
//
virtual ~SoCons();
private:
//
//! Generate Children. Used to create the hidden children. Required whenever
//! the node has hidden children.
//
void generateChildren();
//
//! Used to modify hidden children when a data field is changed. Required
//! whenever the class has hidden children.
//
void updateChildren();
//
//! ChildList. Required whenever the class has hidden children.
//
SoChildList *children;
//
//! help with trigonometry. increments sines an cosines by an angle.
//
void inc(double & sinPhi, double & cosPhi, double sinDeltaPhi, double cosDeltaPhi) const {
double oldSin=sinPhi,oldCos=cosPhi;
sinPhi = oldSin*cosDeltaPhi+oldCos*sinDeltaPhi;
cosPhi = oldCos*cosDeltaPhi-oldSin*sinDeltaPhi;
}
};
#endif
@@ -0,0 +1,213 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: SoTrap.h,v 1.2 2004/06/14 09:27:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/*-----------------------------Hepvis----------------------------------------*/
/* */
/* Node: SoTrap */
/* Description: Represents the G4Trap Geant Geometry entity */
/* Author: Joe Boudreau Nov 11 1996 */
/* */
/*---------------------------------------------------------------------------*/
#ifndef HEPVis_SoTrap_h
#define HEPVis_SoTrap_h
#include <Inventor/fields/SoSFNode.h>
#include <Inventor/fields/SoSFBool.h>
#include <Inventor/nodes/SoShape.h>
//adding fields
#ifdef WIN32
#include <SoWinEnterScope.h>
#endif
// Defining Class
#ifdef WIN32
#include <SoWinLeaveScope.h>
#endif
class SoSFNode;
//! SoTrap - Inventor version of the G4Trap Geant Geometry entity
/*! Node: SoTrap
*
* Description: Inventor version of the G4Trap Geant Geometry entity
*
* Author: Joe Boudreau Nov 11 1996
*
* A G4Trap is a general trapezoid: The faces perpendicular to the z planes
* are tapezia, and their centres are not necessarily on a line parallel to
* the z axis.
*
* Note that of the 11 parameters desribed below, only 9 are really
* independent - a check for planarity is made in the calculation of the
* equation for each plane. If the planes are not parallel, a call to
* G4Exception is made.
*
* Always use Inventor Fields. This allows Inventor to detect a change to
* the data field and take the appropriate action; e.g., redraw the scene.
*
*/
#define SoTrap Geant4_SoTrap
class SoTrap:public SoShape {
// The following is required:
SO_NODE_HEADER(SoTrap);
public:
#if defined(WIN32) && defined(BUILDING_DLL)
// When building the node as a DLL under Win32 we must explicitly
// declare this entry point as visible outside the DLL. The macro
// BUILDING_DLL is defined in the node's source file.
_declspec(dllexport)
#endif
//
//! half-length along Z
//
SoSFFloat pDz;
//
//! Polar angle of the line joining the centres of the faces at -/+pDz
//
SoSFFloat pTheta;
//
//! Azimuthal angle of the line joing the centre of the face at -pDz
//! to the centre of the face at +pDz
//
SoSFFloat pPhi;
//
//! Half-length along y of the face at -pDz
//
SoSFFloat pDy1;
//
//! Half-length along x of the side at y=-pDy1 of the face at -pDz
//
SoSFFloat pDx1;
//
//! Half-length along x of the side at y=+pDy1 of the face at -pDz
//
SoSFFloat pDx2;
//
//! Half-length along y of the face at +pDz
//
SoSFFloat pDy2;
//
//! Half-length along x of the side at y=-pDy2 of the face at +pDz
//
SoSFFloat pDx3;
//
//! Half-length along x of the side at y=+pDy2 of the face at +pDz
//
SoSFFloat pDx4;
//
//! Angle with respect to the y axis from the centre of the side at
//! y=-pDy1 to the centre at y=+pDy1 of the face at -pDz
//
SoSFFloat pAlp1;
//
//! Angle with respect to the y axis from the centre of the side at
//! y=-pDy2 to the centre at y=+pDy2 of the face at +pDz
//
SoSFFloat pAlp2;
//
//! Alternate rep - required
//
SoSFNode alternateRep;
//
//! Constructor, required
//
SoTrap();
//
//! Class Initializer, required
//
static void initClass();
//
//! Generate AlternateRep, required. Generating an alternate representation
//! must be done upon users request. It allows an Inventor program to read
//! back the file without requiring *this* code to be dynamically linked.
//! If the users expects that *this* code will be dynamically linked, he
//! need not invoke this method.
//
virtual void generateAlternateRep();
//
//! We better be able to clear it, too!
//
virtual void clearAlternateRep();
protected:
//
//! compute bounding Box, required
//
virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center );
//
//! Generate Primitives, required
//
virtual void generatePrimitives(SoAction *action);
//
//! GetChildList, required whenever the class has hidden children
//
virtual SoChildList *getChildren() const;
//
//! Destructor, required
//
virtual ~SoTrap();
private:
//
//! Generate Children. Used to create the hidden children. Required whenever
//! the node has hidden children.
//
void generateChildren();
//
//! Used to modify hidden children when a data field is changed. Required
//! whenever the class has hidden children.
//
void updateChildren();
//
//! ChildList. Required whenever the class has hidden children.
//
SoChildList *children;
};
#ifdef WIN32
#include <SoWinEnterScope.h>
#endif
#endif
@@ -0,0 +1,169 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: SoTrd.h,v 1.2 2004/06/14 09:27:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/*-----------------------------Hepvis----------------------------------------*/
/* */
/* Node: SoTrd */
/* Description: Represents the G4Trd Geant Geometry entity */
/* Author: Joe Boudreau Nov 11 1996 */
/* */
/*---------------------------------------------------------------------------*/
#ifndef HEPVis_SoTrd_h
#define HEPVis_SoTrd_h
#include <Inventor/fields/SoSFFloat.h>
#include <Inventor/fields/SoSFNode.h>
#include <Inventor/fields/SoSFBool.h>
#include <Inventor/nodes/SoShape.h>
class SoSFNode;
//! SoTrd - Inventor version of the G4Trd Geant Geometry entity
/*!
* Node: SoTrd
*
* Description: Inventor version of the G4Trd Geant Geometry entity
*
* Author: Joe Boudreau Nov 11 1996
*
* A Trd is a trapezoid with the x and y dimensions varying along z
*
* Always use Inventor Fields. This allows Inventor to detect a change to
* the data field and take the appropriate action; e.g., redraw the scene.
*
*/
#define SoTrd Geant4_SoTrd
class SoTrd:public SoShape {
//
//! This is required
//
SO_NODE_HEADER(SoTrd);
public:
//
//! half-length of x, at -fDz
//
SoSFFloat fDx1;
//
//! half-length of x, at +fDz
//
SoSFFloat fDx2;
//
//! half-length of y, at -fDz
//
SoSFFloat fDy1;
//
//! half-length of y, at +fDz
//
SoSFFloat fDy2;
//
//! half-length along Z
//
SoSFFloat fDz;
//
//! Alternate rep - required
//
SoSFNode alternateRep;
//
//! Constructor, required
//
SoTrd();
//
//! Class Initializer, required
//
static void initClass();
//
//! Generate AlternateRep, required. Generating an alternate representation
//! must be done upon users request. It allows an Inventor program to read
//! back the file without requiring *this* code to be dynamically linked.
//! If the users expects that *this* code will be dynamically linked, he
//! need not invoke this method.
//
virtual void generateAlternateRep();
//
//! We better be able to clear it, too!
//
virtual void clearAlternateRep();
protected:
//
//! compute bounding Box, required
//
virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center );
//
//! Generate Primitives, required
//
virtual void generatePrimitives(SoAction *action);
//
//! GetChildList, required whenever the class has hidden children
//
virtual SoChildList *getChildren() const;
protected:
//
//! Destructor, required
//
virtual ~SoTrd();
private:
//
//! Generate Children. Used to create the hidden children. Required whenever
//! the node has hidden children.
//
void generateChildren();
//
//! Used to modify hidden children when a data field is changed. Required
//! whenever the class has hidden children.
//
void updateChildren();
//
//! ChildList. Required whenever the class has hidden children.
//
SoChildList *children;
};
#endif
@@ -0,0 +1,180 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: SoTubs.h,v 1.2 2004/06/14 09:27:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/*-----------------------------Hepvis----------------------------------------*/
/* */
/* Node: SoTubs */
/* Description: Represents the G4Tubs Geant Geometry entity */
/* Author: Joe Boudreau Nov 11 1996 */
/* */
/*---------------------------------------------------------------------------*/
#ifndef HEPVis_SoTubs_h
#define HEPVis_SoTubs_h
#include <Inventor/fields/SoSFFloat.h>
#include <Inventor/fields/SoSFNode.h>
#include <Inventor/fields/SoSFBool.h>
#include <Inventor/nodes/SoShape.h>
class SoSFNode;
//! SoTubs - Inventor version of the G4Tubs Geant Geometry entity
/*!
* Node: SoTubs
*
* Description: The Inventor version of the G4Tubs Geant Geometry entity
*
* Author: Joe Boudreau Nov 11 1996
*
* class G4Tubs
*
* A tube or tube segment with curved sides parallel to
* the z-axis. The tube has a specified half-length along
* the z axis, about which it is centred, and a given
* minimum and maximum radius. A minimum radius of 0
* signifies a filled tube /cylinder. The tube segment is
* specified by starting and delta
* angles for phi, with 0 being the +x axis, PI/2
* the +y axis. A delta angle of 2PI signifies a
* complete, unsegmented tube/cylinder
*
* Always use Inventor Fields. This allows Inventor to detect a change to
* the data field and take the appropriate action; e.g., redraw the scene.
*/
#define SoTubs Geant4_SoTubs
class SoTubs:public SoShape {
// The following is required:
SO_NODE_HEADER(SoTubs);
public:
//
//! Inside radius of the tube
//
SoSFFloat pRMin;
//
//! Outside radius of the tube
//
SoSFFloat pRMax;
//
//! Half-length in Z
//
SoSFFloat pDz;
//
//! Starting angle, in radians
//
SoSFFloat pSPhi;
//
//! Delta-angle, in radians
//
SoSFFloat pDPhi;
//
//! Alternate rep - required
//
SoSFNode alternateRep;
//
//! Constructor, required
//
SoTubs();
//
//! Class Initializer, required
//
static void initClass();
//
//! Generate AlternateRep, required. Generating an alternate representation
//! must be done upon users request. It allows an Inventor program to read
//! back the file without requiring *this* code to be dynamically linked.
//! If the users expects that *this* code will be dynamically linked, he
//! need not invoke this method.
//
virtual void generateAlternateRep();
//
//! We better be able to clear it, too!
//
virtual void clearAlternateRep();
protected:
//
//! compute bounding Box, required
//
virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center );
//
//! Generate Primitives, required
//
virtual void generatePrimitives(SoAction *action);
//
//! GetChildList, required whenever the class has hidden children
//
virtual SoChildList *getChildren() const;
protected:
//
//! Destructor, required
//
virtual ~SoTubs();
private:
//
//! Generate Children. Used to create the hidden children. Required whenever
//! the node has hidden children.
//
void generateChildren();
//
//! Used to modify hidden children when a data field is changed. Required
//! whenever the class has hidden children.
//
void updateChildren();
//
//! ChildList. Required whenever the class has hidden children.
//
SoChildList *children;
//
//! help with trigonometry. increments sines an cosines by an angle.
//
void inc(double & sinPhi, double & cosPhi, double sinDeltaPhi, double cosDeltaPhi) const {
double oldSin=sinPhi,oldCos=cosPhi;
sinPhi = oldSin*cosDeltaPhi+oldCos*sinDeltaPhi;
cosPhi = oldCos*cosDeltaPhi-oldSin*sinDeltaPhi;
}
};
#endif
@@ -21,23 +21,22 @@
// ********************************************************************
//
//
// $Id: G4OpenInventor.cc,v 1.9 2003/10/29 10:02:06 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4OpenInventor.cc,v 1.11 2004/06/14 09:27:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
#ifdef G4VIS_BUILD_OI_DRIVER
//#include <HEPVis/SoDB.h>
#include <HEPVis/nodes/SoG4Box.h>
#include <HEPVis/nodes/SoG4Tubs.h>
#include <HEPVis/nodes/SoG4Cons.h>
#include <HEPVis/nodes/SoG4Trd.h>
#include <HEPVis/nodes/SoG4Trap.h>
#include <HEPVis/nodekits/SoDetectorTreeKit.h>
// this :
#include "G4OpenInventor.hh"
#include "G4OpenInventorSceneHandler.hh"
#include "G4OpenInventorViewer.hh"
#include "HEPVis/nodes/SoBox.h"
#include "HEPVis/nodes/SoTubs.h"
#include "HEPVis/nodes/SoCons.h"
#include "HEPVis/nodes/SoTrd.h"
#include "HEPVis/nodes/SoTrap.h"
#include "HEPVis/nodekits/SoDetectorTreeKit.h"
#include "G4OpenInventorSceneHandler.hh"
G4OpenInventor::G4OpenInventor (
const G4String name
@@ -64,23 +63,13 @@ G4VSceneHandler* G4OpenInventor::CreateSceneHandler (const G4String& name) {
return p;
}
G4VViewer* G4OpenInventor::CreateViewer (G4VSceneHandler& scene, const G4String& name)
void G4OpenInventor::InitNodes()
{
G4OpenInventorSceneHandler* pScene = (G4OpenInventorSceneHandler*)&scene;
G4OpenInventorViewer* pView = new G4OpenInventorViewer (*pScene, name);
return pView;
}
void G4OpenInventor::InitHEPVis()
{
// The below is too much for most loaders :
// HEPVis_SoDB::init();
SoG4Box::initClass();
SoG4Tubs::initClass();
SoG4Cons::initClass();
SoG4Trd::initClass();
SoG4Trap::initClass();
SoBox::initClass();
SoTubs::initClass();
SoCons::initClass();
SoTrd::initClass();
SoTrap::initClass();
SoDetectorTreeKit::initClass();
}
@@ -21,14 +21,17 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorSceneHandler.cc,v 1.15 2003/10/29 10:01:36 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4OpenInventorSceneHandler.cc,v 1.17 2004/06/14 09:27:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Jeff Kallenbach 01 Aug 1996
// OpenInventor stored scene - creates OpenInventor display lists.
#ifdef G4VIS_BUILD_OI_DRIVER
// this :
#include "G4OpenInventorSceneHandler.hh"
#include <Inventor/SoPath.h>
#include <Inventor/SoNodeKitPath.h>
#include <Inventor/nodes/SoCoordinate3.h>
@@ -54,18 +57,16 @@
#include <Inventor/nodes/SoTransform.h>
#include <Inventor/nodes/SoResetTransform.h>
#include <HEPVis/nodes/SoG4Box.h>
#include <HEPVis/nodes/SoG4Tubs.h>
#include <HEPVis/nodes/SoG4Cons.h>
#include <HEPVis/nodes/SoG4Trd.h>
#include <HEPVis/nodes/SoG4Trap.h>
#include <HEPVis/nodekits/SoDetectorTreeKit.h>
#include "HEPVis/nodes/SoBox.h"
#include "HEPVis/nodes/SoTubs.h"
#include "HEPVis/nodes/SoCons.h"
#include "HEPVis/nodes/SoTrd.h"
#include "HEPVis/nodes/SoTrap.h"
#include "HEPVis/nodekits/SoDetectorTreeKit.h"
#include "G4Scene.hh"
#include "G4NURBS.hh"
#include "G4OpenInventor.hh"
#include "G4OpenInventorSceneHandler.hh"
#include "G4OpenInventorViewer.hh"
#include "G4OpenInventorTransform3D.hh"
#include "G4ThreeVector.hh"
#include "G4Point3D.hh"
@@ -88,7 +89,7 @@
#include "G4Material.hh"
#include "G4VisAttributes.hh"
typedef SoDetectorTreeKit SoG4DetectorTreeKit;
typedef SoDetectorTreeKit SoDetectorTreeKit;
G4Point3D translation;
G4OpenInventorSceneHandler::G4OpenInventorSceneHandler (G4OpenInventor& system,
@@ -548,7 +549,7 @@ void G4OpenInventorSceneHandler::AddThis (const G4Box & Box) {
}
void G4OpenInventorSceneHandler::AddThis (const G4Tubs & Tubs) {
if(currentSeparator==0) return;
SoG4Tubs *g4Tubs = new SoG4Tubs();
SoTubs *g4Tubs = new SoTubs();
g4Tubs->pRMin = Tubs.GetRMin();
g4Tubs->pRMax = Tubs.GetRMax();
g4Tubs->pDz = Tubs.GetDz();
@@ -558,7 +559,7 @@ void G4OpenInventorSceneHandler::AddThis (const G4Tubs & Tubs) {
}
void G4OpenInventorSceneHandler::AddThis (const G4Cons &cons) {
if(currentSeparator==0) return;
SoG4Cons *g4Cons = new SoG4Cons();
SoCons *g4Cons = new SoCons();
g4Cons->fRmin1 = cons.GetRmin1();
g4Cons->fRmin2 = cons.GetRmin2();
g4Cons->fRmax1 = cons.GetRmax1();
@@ -572,7 +573,7 @@ void G4OpenInventorSceneHandler::AddThis (const G4Cons &cons) {
void G4OpenInventorSceneHandler::AddThis (const G4Trap &trap) {
if(currentSeparator==0) return;
G4ThreeVector SymAxis=trap.GetSymAxis();
SoG4Trap *g4Trap = new SoG4Trap();
SoTrap *g4Trap = new SoTrap();
g4Trap->pDz = trap.GetZHalfLength();
g4Trap->pPhi = atan2(SymAxis(kYAxis),SymAxis(kXAxis));
g4Trap->pTheta = acos(SymAxis(kZAxis));
@@ -587,7 +588,7 @@ void G4OpenInventorSceneHandler::AddThis (const G4Trap &trap) {
void G4OpenInventorSceneHandler::AddThis (const G4Trd &trd) {
if(currentSeparator==0) return;
SoG4Trd *g4Trd = new SoG4Trd();
SoTrd *g4Trd = new SoTrd();
g4Trd->fDx1 = trd.GetXHalfLength1();
g4Trd->fDx2 = trd.GetXHalfLength2();
g4Trd->fDy1 = trd.GetYHalfLength1();
@@ -650,7 +651,7 @@ void G4OpenInventorSceneHandler::PreAddThis
//
// Make the detector tree kit:
//
SoG4DetectorTreeKit* g4DetectorTreeKit = new SoG4DetectorTreeKit();
SoDetectorTreeKit* g4DetectorTreeKit = new SoDetectorTreeKit();
SoSeparator* previewSeparator =
(SoSeparator*) g4DetectorTreeKit->getPart("previewSeparator",TRUE);
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorTransform3D.cc,v 1.4 2001/07/11 10:09:01 gunter Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenInventorTransform3D.cc,v 1.5 2004/04/08 09:41:11 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// jck 17 Dec 1996
@@ -31,10 +31,11 @@
#ifdef G4VIS_BUILD_OI_DRIVER
#include <Inventor/fields/SoSFMatrix.h>
// this :
#include "G4OpenInventorTransform3D.hh"
#include <Inventor/fields/SoSFMatrix.h>
G4OpenInventorTransform3D::G4OpenInventorTransform3D (const G4Transform3D &t)
: G4Transform3D (t) {
m[0] = xx;
@@ -21,36 +21,42 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorWin32.cc,v 1.5 2001/07/11 10:09:01 gunter Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenInventorWin.cc,v 1.4 2004/04/08 10:49:57 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
// OpenInventor graphics system factory.
#ifdef G4VIS_BUILD_OIWIN32_DRIVER
#include <Inventor/Xt/SoXt.h>
// this :
#include "G4OpenInventorWin.hh"
#include "G4OpenInventorWin32.hh"
#include <Inventor/Win/SoWin.h>
#include "G4OpenInventorSceneHandler.hh"
#include "G4OpenInventorViewer.hh"
#include "G4OpenInventorWinViewer.hh"
#include "G4Win32.hh"
G4OpenInventorWin32::G4OpenInventorWin32 ()
:G4OpenInventor("OpenInventorWin32","OIWIN32",G4VGraphicsSystem::threeD)
G4OpenInventorWin::G4OpenInventorWin ()
:G4OpenInventor("OpenInventorWin","OIWin32",G4VGraphicsSystem::threeD)
{
SetInteractorManager (G4Win32::getInstance());
GetInteractorManager () -> RemoveDispatcher((G4DispatchFunction)G4Win32::dispatchWin32Event);
GetInteractorManager () -> AddDispatcher ((G4DispatchFunction)SoXt::dispatchEvent);
GetInteractorManager () -> AddDispatcher((G4DispatchFunction)SoWin::dispatchEvent);
Widget toplevel = (Widget)GetInteractorManager()->GetMainInteractor();
HWND toplevel = (HWND)GetInteractorManager()->GetMainInteractor();
SoXt::init(toplevel);
SoWin::init(toplevel);
InitHEPVis();
InitNodes();
}
G4OpenInventorWin::~G4OpenInventorWin () {}
G4VViewer* G4OpenInventorWin::CreateViewer (G4VSceneHandler& scene, const G4String& name)
{
G4OpenInventorSceneHandler* pScene = (G4OpenInventorSceneHandler*)&scene;
return new G4OpenInventorWinViewer (*pScene, name);
}
G4OpenInventorWin32::~G4OpenInventorWin32 () {}
#endif
@@ -0,0 +1,271 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4OpenInventorWinViewer.cc,v 1.2 2004/04/08 10:49:57 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/*
* jck 05 Feb 1997 - Initial Implementation
* jck 21 Apr 1997
* Mods for SoXtHepViewer
* gb : on Win32 use an SoXtExaminerViewer.
* gb 05 April 2004 : creation.
*/
#ifdef G4VIS_BUILD_OIWIN32_DRIVER
// this :
#include "G4OpenInventorWinViewer.hh"
#include <Inventor/nodes/SoSelection.h>
#include <Inventor/Win/SoWin.h>
#include <Inventor/Win/viewers/SoWinExaminerViewer.h>
#include "G4OpenInventor.hh"
#include "G4OpenInventorSceneHandler.hh"
#include "G4VInteractorManager.hh"
#include <windowsx.h>
//
// Global variables
//
//static void SecondaryLoopPostAction ();
static LRESULT CALLBACK WindowProc (HWND,UINT,WPARAM,LPARAM);
static const char className[] = "G4OpenInventorShellWindow";
void G4OpenInventorWinViewer::FinishView () {
if(!fViewer) return;
fViewer->viewAll();
fViewer->saveHomePosition();
}
void G4OpenInventorWinViewer::KernelVisitDecision () {
// If there's a significant difference with the last view parameters
// of either the scene handler or this viewer, trigger a rebuild.
if (
//??fG4OpenInventorSceneHandler.fPODLList.size() == 0 ||
// We need a test for empty scene graph, such as
// staticRoot.size() or something?????????? See temporary fix
// in contructor. (John Allison Aug 2001)
CompareForKernelVisit(fG4OpenInventorSceneHandler.fLastVP) ||
CompareForKernelVisit(fLastVP)) {
NeedKernelVisit ();
}
fLastVP = fVP;
fG4OpenInventorSceneHandler.fLastVP = fVP;
}
G4bool G4OpenInventorWinViewer::CompareForKernelVisit
(G4ViewParameters&) {
if (
(fLastVP.GetDrawingStyle () != fVP.GetDrawingStyle ()) ||
(fLastVP.GetRepStyle () != fVP.GetRepStyle ()) ||
(fLastVP.IsCulling () != fVP.IsCulling ()) ||
(fLastVP.IsCullingInvisible () != fVP.IsCullingInvisible ()) ||
(fLastVP.IsDensityCulling () != fVP.IsDensityCulling ()) ||
(fLastVP.IsCullingCovered () != fVP.IsCullingCovered ()) ||
(fLastVP.IsSection () != fVP.IsSection ()) ||
// No need to visit kernel if section plane changes.
(fLastVP.IsCutaway () != fVP.IsCutaway ()) ||
(fLastVP.GetCutawayPlanes ().size () !=
fVP.GetCutawayPlanes ().size ()) ||
// No need to visit kernel if cutaway planes change.
(fLastVP.IsExplode () != fVP.IsExplode ()) ||
(fLastVP.GetNoOfSides () != fVP.GetNoOfSides ())
) {
return true;;
}
if (fLastVP.IsDensityCulling () &&
(fLastVP.GetVisibleDensity () != fVP.GetVisibleDensity ()))
return true;
if (fLastVP.IsExplode () &&
(fLastVP.GetExplodeFactor () != fVP.GetExplodeFactor ()))
return true;
return false;
}
G4OpenInventorWinViewer::G4OpenInventorWinViewer
(G4OpenInventorSceneHandler& sceneHandler,
const G4String& name)
:G4VViewer (sceneHandler, sceneHandler.IncrementViewCount(), name)
,fG4OpenInventorSceneHandler(sceneHandler)
,fShell(0)
,fViewer(0)
,fSelection(0)
,fInteractorManager(0)
{
fNeedKernelVisit = true; //?? Temporary, until KernelVisitDecision fixed.
fInteractorManager =
((G4OpenInventor*)fG4OpenInventorSceneHandler.GetGraphicsSystem())->
GetInteractorManager();
//Widget toplevel = (Widget)fInteractorManager->GetMainInteractor ();
//fInteractorManager->
//AddSecondaryLoopPostAction((G4SecondaryLoopAction)SecondaryLoopPostAction);
G4cout << "Window name: " << fName << G4endl;
//
// Selection
//
fSelection = new SoSelection;
fSelection->policy = SoSelection::SINGLE;
fSelection->ref();
fSelection->addChild(fG4OpenInventorSceneHandler.root);
G4String wName = fName;
#define SIZE 400
HWND parent = (HWND)fInteractorManager->GetParentInteractor ();
if(!parent) {
//Create a shell window :
G4String shellName = wName;
shellName += "_shell";
static SbBool done = FALSE;
if(done==FALSE) {
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = ::GetModuleHandle(0);
wc.hIcon = ::LoadIcon(0, IDI_APPLICATION);
wc.hCursor = ::LoadCursor(0, IDC_ARROW);
wc.hbrBackground = 0;
wc.lpszMenuName = className;
wc.lpszClassName = className;
::RegisterClass(&wc);
done = TRUE;
}
// Compell window to be created at 0,0 to bypass
// the 'black border' problem.
fShell = ::CreateWindow(className, shellName.c_str(),
WS_OVERLAPPEDWINDOW,
//CW_USEDEFAULT, CW_USEDEFAULT,
0,0,400,400,0, 0,::GetModuleHandle(0),0);
// Retreive window and client sizez :
RECT wrect,crect;
GetWindowRect((HWND)fShell,&wrect);
GetClientRect((HWND)fShell,&crect);
int ww = wrect.right-wrect.left;
int wh = wrect.bottom-wrect.top;
int cw = crect.right-crect.left;
int ch = crect.bottom-crect.top;
// Compell client rect to be 400 400 :
MoveWindow((HWND)fShell,wrect.left,wrect.top,400+ww-cw,400+wh-ch,TRUE);
::SetWindowLong((HWND)fShell,GWL_USERDATA,LONG(this));
::SetWindowText((HWND)fShell,shellName.c_str());
parent = fShell;
fInteractorManager->AddShell(fShell);
} else {
char* str = fInteractorManager->GetCreationString();
if(str!=0) wName = str;
}
fViewer = new SoWinExaminerViewer(parent,wName.c_str(),TRUE);
fViewer->setSize(SbVec2s(SIZE,SIZE));
fViewer->setSceneGraph(fSelection);
fViewer->viewAll();
fViewer->saveHomePosition();
fViewer->setTitle(fName);
fViewer->show();
if(fShell) {
SoWin::show(fShell);
fInteractorManager->FlushAndWaitExecution ();
}
fInteractorManager->SetCreatedInteractor (fViewer -> getWidget());
}
G4OpenInventorWinViewer::~G4OpenInventorWinViewer () {
if(fShell) fInteractorManager->RemoveShell(fShell);
if(fViewer) delete fViewer;
if(fShell) {
::SetWindowLong((HWND)fShell,GWL_USERDATA,LONG(0));
::DestroyWindow((HWND)fShell);
}
if(fSelection) fSelection->unref();
}
void G4OpenInventorWinViewer::ClearView () {
}
void G4OpenInventorWinViewer::SetView () {
}
void G4OpenInventorWinViewer::DrawView () {
G4cout << "debug Iv::DrawViewer " <<G4endl;
KernelVisitDecision();
ProcessView();
FinishView();
}
void G4OpenInventorWinViewer::ShowView () {
fInteractorManager -> SecondaryLoop ();
}
//////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WindowProc (
HWND aWindow
,UINT aMessage
,WPARAM aWParam
,LPARAM aLParam
)
//////////////////////////////////////////////////////////////////////////////
// Below treatment of WM_SIZE, WM_SETFOCUS not necessary
// with TGS, but needed with SoFree. WM_DESTROY needed for
// 'main top level window' so that 'Close window' induces
// the end of the task.
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
switch (aMessage) {
case WM_SIZE:{ // Assume one child window !
int width = LOWORD(aLParam);
int height = HIWORD(aLParam);
//printf("debug : G4SoWindow : WMS_SIZE : %d %d\n",width,height);
HWND hwnd = ::GetFirstChild(aWindow);
if(hwnd!=0) {
::MoveWindow(hwnd,0,0,width,height,TRUE);
}
}return 0;
case WM_SETFOCUS:{ // Assume one child window !
HWND hwnd = ::GetFirstChild(aWindow);
if(hwnd!=0) ::SetFocus(hwnd);
}return 0;
case WM_DESTROY:{
//G4OpenInventorWinViewer* This =
// (G4OpenInventorWinViewer*)::GetWindowLong(aWindow,GWL_USERDATA);
//::PostQuitMessage(0);
}return 0;
default:
return (::DefWindowProc(aWindow,aMessage,aWParam,aLParam));
}
}
#endif
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorX.cc,v 1.5 2001/07/11 10:09:01 gunter Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4OpenInventorXt.cc,v 1.1 2004/04/08 09:41:11 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// Jeff Kallenbach 01 Aug 1996
@@ -30,16 +30,17 @@
#ifdef G4VIS_BUILD_OIX_DRIVER
// this :
#include "G4OpenInventorXt.hh"
#include <Inventor/Xt/SoXt.h>
#include "G4OpenInventorX.hh"
#include "G4OpenInventorSceneHandler.hh"
#include "G4OpenInventorViewer.hh"
#include "G4Xt.hh"
#include "G4OpenInventorSceneHandler.hh"
#include "G4OpenInventorXtViewer.hh"
G4OpenInventorX::G4OpenInventorX ()
:G4OpenInventor("OpenInventorX","OIX",G4VGraphicsSystem::threeD)
G4OpenInventorXt::G4OpenInventorXt ()
:G4OpenInventor("OpenInventorXt","OIX",G4VGraphicsSystem::threeD)
{
SetInteractorManager (G4Xt::getInstance ());
GetInteractorManager () ->
@@ -48,12 +49,17 @@ G4OpenInventorX::G4OpenInventorX ()
AddDispatcher ((G4DispatchFunction)SoXt::dispatchEvent);
Widget toplevel = (Widget)GetInteractorManager()->GetMainInteractor();
SoXt::init(toplevel);
SoXt::init (toplevel);
InitHEPVis();
InitNodes();
}
G4OpenInventorXt::~G4OpenInventorXt () {}
G4VViewer* G4OpenInventorXt::CreateViewer (G4VSceneHandler& scene, const G4String& name)
{
G4OpenInventorSceneHandler* pScene = (G4OpenInventorSceneHandler*)&scene;
return new G4OpenInventorXtViewer (*pScene, name);
}
G4OpenInventorX::~G4OpenInventorX () {}
#endif
@@ -21,33 +21,29 @@
// ********************************************************************
//
//
// $Id: G4OpenInventorViewer.cc,v 1.10 2003/08/28 11:44:22 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4OpenInventorXtViewer.cc,v 1.1 2004/04/08 09:41:11 gbarrand Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/*
* jck 05 Feb 1997 - Initial Implementation
* jck 21 Apr 1997
* Mods for SoXtHepViewer
* gb : on Win32 use an SoXtExaminerViewer.
* gb 05 April 2004 : revisit to separate Windows things.
*/
#ifdef G4VIS_BUILD_OI_DRIVER
#ifdef G4VIS_BUILD_OIX_DRIVER
// this :
#include "G4OpenInventorXtViewer.hh"
#include <Inventor/nodes/SoSelection.h>
#include <Inventor/Xt/SoXt.h>
#include <Inventor/nodes/SoSelection.h>
#include <Inventor/nodes/SoSelection.h>
#include "G4SoWindow.hh"
#ifdef WIN32
#include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
#else
#include <HEPVis/Xt/viewers/SoXtHepViewer.h>
#endif
#include <X11/StringDefs.h>
#include "G4OpenInventor.hh"
#include "G4OpenInventorViewer.hh"
#include "G4OpenInventorSceneHandler.hh"
#include "G4VInteractorManager.hh"
//
@@ -56,24 +52,10 @@
//static void SecondaryLoopPostAction ();
void G4OpenInventorViewer::FinishView () {
if(fViewer==0) return;
#ifdef WIN32
((SoXtViewer*)fViewer)->viewAll();
((SoXtViewer*)fViewer)->saveHomePosition();
#else
((SoXtHepViewer*)fViewer)->getCurrentViewer()->viewAll();
((SoXtHepViewer*)fViewer)->getCurrentViewer()->saveHomePosition();
#endif
}
//
// Exit
//
int quitCB(void* interactorManager) {
((G4VInteractorManager*)interactorManager) ->
RequireExitSecondaryLoop (OIV_EXIT_CODE);
return 0;
void G4OpenInventorXtViewer::FinishView () {
if(!fViewer) return;
fViewer->viewAll();
fViewer->saveHomePosition();
}
//static void SecondaryLoopPostAction ()
@@ -85,7 +67,7 @@ int quitCB(void* interactorManager) {
// }
//}
void G4OpenInventorViewer::KernelVisitDecision () {
void G4OpenInventorXtViewer::KernelVisitDecision () {
// If there's a significant difference with the last view parameters
// of either the scene handler or this viewer, trigger a rebuild.
@@ -103,7 +85,7 @@ void G4OpenInventorViewer::KernelVisitDecision () {
fG4OpenInventorSceneHandler.fLastVP = fVP;
}
G4bool G4OpenInventorViewer::CompareForKernelVisit
G4bool G4OpenInventorXtViewer::CompareForKernelVisit
(G4ViewParameters&) {
if (
@@ -135,13 +117,12 @@ G4bool G4OpenInventorViewer::CompareForKernelVisit
return false;
}
G4OpenInventorViewer::G4OpenInventorViewer
G4OpenInventorXtViewer::G4OpenInventorXtViewer
(G4OpenInventorSceneHandler& sceneHandler,
const G4String& name)
:G4VViewer (sceneHandler, sceneHandler.IncrementViewCount(), name)
,fG4OpenInventorSceneHandler(sceneHandler)
,fShell(0)
,fWindow(0)
,fViewer(0)
,fSelection(0)
,fInteractorManager(0)
@@ -151,10 +132,10 @@ G4OpenInventorViewer::G4OpenInventorViewer
fInteractorManager =
((G4OpenInventor*)fG4OpenInventorSceneHandler.GetGraphicsSystem())->
GetInteractorManager();
//Widget toplevel = (Widget)fInteractorManager->GetMainInteractor ();
//Widget toplevel = (Widget)fInteractorManager->GetMainInteractor ();
//fInteractorManager->
//AddSecondaryLoopPostAction ((G4SecondaryLoopAction)SecondaryLoopPostAction);
//fInteractorManager->
//AddSecondaryLoopPostAction((G4SecondaryLoopAction)SecondaryLoopPostAction);
G4cout << "Window name: " << fName << G4endl;
//
@@ -165,78 +146,68 @@ G4OpenInventorViewer::G4OpenInventorViewer
fSelection->ref();
fSelection->addChild(fG4OpenInventorSceneHandler.root);
Widget parent = (Widget)fInteractorManager->GetParentInteractor ();
G4String wName = fName;
const char* wname = wName.data();
#define SIZE 400
if(parent==0) { //Create a shell window :
fWindow = new G4SoWindow(wname);
fWindow->setTitle(wname);
fWindow->setSize(SbVec2s(SIZE,SIZE));
fShell = parent = fWindow->getWidget();
Widget parent = (Widget)fInteractorManager->GetParentInteractor ();
if(!parent) {
//Create a shell window :
G4String shellName = wName;
shellName += "_shell";
Arg args[3];
char s[32];
sprintf(s,"%dx%d",SIZE,SIZE);
XtSetArg(args[0],XtNgeometry,XtNewString(s));
XtSetArg(args[1],XtNborderWidth,0);
XtSetArg(args[2],XtNtitle,XtNewString(wName.c_str()));
fShell = XtAppCreateShell(shellName.c_str(),"Inventor",
topLevelShellWidgetClass,
SoXt::getDisplay(),
args,3);
parent = fShell;
fInteractorManager->AddShell(fShell);
} else {
char* str = fInteractorManager->GetCreationString ();
if(str!=0) wname = str;
char* str = fInteractorManager->GetCreationString();
if(str!=0) wName = str;
}
//
// Create and Customize the Viewer
//
#ifdef WIN32
fViewer = new SoXtExaminerViewer(parent,wname,TRUE);
fViewer = new SoXtExaminerViewer(parent,wName.c_str(),TRUE);
fViewer->setSize(SbVec2s(SIZE,SIZE));
((SoXtViewer*)fViewer)->setSceneGraph(fSelection);
((SoXtViewer*)fViewer)->viewAll();
((SoXtViewer*)fViewer)->saveHomePosition();
#else
fViewer = new SoXtHepViewer (parent,wname,TRUE);
((SoXtHepViewer*)fViewer)->hideTextArea();
((SoXtHepViewer*)fViewer)->resizeMain(SIZE,SIZE);
((SoXtHepViewer*)fViewer)->setQuitCallback(quitCB, fInteractorManager);
((SoXtHepViewer*)fViewer)->setSceneGraph(fSelection);
((SoXtHepViewer*)fViewer)->getCurrentViewer()->viewAll();
((SoXtHepViewer*)fViewer)->getCurrentViewer()->saveHomePosition();
#endif
fViewer->setSceneGraph(fSelection);
fViewer->viewAll();
fViewer->saveHomePosition();
fViewer->setTitle(fName);
fViewer->show();
if(fWindow!=0) {
fWindow->show();
if(fShell) {
SoXt::show(fShell);
fInteractorManager->FlushAndWaitExecution ();
}
fInteractorManager->SetCreatedInteractor (fViewer -> getWidget());
}
G4OpenInventorViewer::~G4OpenInventorViewer () {
if(fShell!=0) fInteractorManager -> RemoveShell (fShell);
if(fViewer!=0) {
#ifdef WIN32
delete ((SoXtExaminerViewer*)fViewer);
#else
delete ((SoXtHepViewer*)fViewer);
#endif
}
if(fWindow!=0) delete fWindow;
if(fSelection!=0) fSelection->unref();
G4OpenInventorXtViewer::~G4OpenInventorXtViewer () {
if(fShell) fInteractorManager->RemoveShell(fShell);
if(fViewer) delete fViewer;
if(fShell) XtDestroyWidget(fShell);
if(fSelection) fSelection->unref();
}
void G4OpenInventorViewer::ClearView () {
void G4OpenInventorXtViewer::ClearView () {
}
void G4OpenInventorViewer::SetView () {
void G4OpenInventorXtViewer::SetView () {
}
void G4OpenInventorViewer::DrawView () {
void G4OpenInventorXtViewer::DrawView () {
G4cout << "debug Iv::DrawViewer " <<G4endl;
KernelVisitDecision ();
ProcessView ();
FinishView ();
KernelVisitDecision();
ProcessView();
FinishView();
}
void G4OpenInventorViewer::ShowView () {
void G4OpenInventorXtViewer::ShowView () {
fInteractorManager -> SecondaryLoop ();
}
@@ -1,403 +0,0 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define SbWarn printf
#include <HEPVis/SbBasic.h>
// For backward compatibility :
#ifdef HEPVisWin
#define HEPVisWin32
#endif
#ifdef CDF
#ifndef LINUX
#define u_long unsigned long
#endif
#endif
#ifdef HEPVisXt
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <X11/StringDefs.h>
#include <X11/IntrinsicP.h>
#endif
#ifdef HEPVisWin32
#include <windowsx.h> //For GetWindowInstance.
#endif
#include <Inventor/SbString.h>
#include <Inventor/SbDict.h>
#include "G4SoWindow.hh"
#ifdef HEPVisXt
static XtTranslations trans_table = 0;
static XtActionsRec closeAction =
{(String)"CloseG4SoWindow",G4SoWindow::closeWindow};
//static void XWidgetSetDimension(Widget,Dimension,Dimension);
#endif
#ifdef HEPVisWin32
static LRESULT CALLBACK WindowProc (HWND,UINT,WPARAM,LPARAM);
static const char className[] = "G4SoWindow";
#endif
SbDict* G4SoWindow::fWidgetDictionary = 0;
//////////////////////////////////////////////////////////////////////////////
void G4SoWindow::clearClass (
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
if(fWidgetDictionary!=0) delete fWidgetDictionary;
fWidgetDictionary = 0;
}
//////////////////////////////////////////////////////////////////////////////
G4SoWindow::G4SoWindow(
const char* aName
,SbBool aWMClose
)
:fWidget(0)
,fWMClose(aWMClose)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
#ifdef HEPVisXt
if(trans_table==0) {
trans_table =
XtParseTranslationTable("<Message>WM_PROTOCOLS:CloseG4SoWindow()");
XtAppAddActions(SoXt::getAppContext(),&closeAction,1);
}
SbString shellName = aName;
shellName += "_shell";
Arg args[2];
XtSetArg(args[0],XtNgeometry,XtNewString("400x400"));
XtSetArg(args[1],XtNborderWidth,0);
fWidget = XtAppCreateShell(shellName.getString(),"Inventor",
topLevelShellWidgetClass,
SoXt::getDisplay(),
args,2);
if(fWidget!=0) {
XtOverrideTranslations(fWidget,trans_table);
XtAddCallback(fWidget,XtNdestroyCallback,
(XtCallbackProc)G4SoWindow::widgetDestroyedCB,0);
}
#endif
#ifdef HEPVisWin32
static SbBool done = FALSE;
if(done==FALSE) {
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = ::GetModuleHandle(0);
wc.hIcon = ::LoadIcon(0, IDI_APPLICATION);
wc.hCursor = ::LoadCursor(0, IDC_ARROW);
wc.hbrBackground = 0;
wc.lpszMenuName = className;
wc.lpszClassName = className;
::RegisterClass(&wc);
done = TRUE;
}
// Compell window to be created at 0,0 to bypass
// the 'black border' problem.
fWidget = ::CreateWindow(className, aName,
WS_OVERLAPPEDWINDOW,
//CW_USEDEFAULT, CW_USEDEFAULT,
0,0,
400,400,
0, 0,
::GetModuleHandle(0),
0);
// Retreive window and client sizez :
RECT wrect,crect;
GetWindowRect((HWND)fWidget,&wrect);
GetClientRect((HWND)fWidget,&crect);
int ww = wrect.right-wrect.left;
int wh = wrect.bottom-wrect.top;
int cw = crect.right-crect.left;
int ch = crect.bottom-crect.top;
// Compell client rect to be 400 400 :
MoveWindow((HWND)fWidget,wrect.left,wrect.top,400+ww-cw,400+wh-ch,TRUE);
//
::SetWindowLong((HWND)fWidget,GWL_USERDATA,LONG(this));
#endif
registerWidget(fWidget);
}
//////////////////////////////////////////////////////////////////////////////
G4SoWindow::~G4SoWindow(
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
if(fWidget==0) return;
unregisterWidget(fWidget);
#ifdef HEPVisXt
XtDestroyWidget(fWidget);
#endif
#ifdef HEPVisWin32
::SetWindowLong((HWND)fWidget,GWL_USERDATA,LONG(0));
::DestroyWindow((HWND)fWidget);
#endif
}
//////////////////////////////////////////////////////////////////////////////
Widget G4SoWindow::getWidget(
) const
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
return fWidget;
}
//////////////////////////////////////////////////////////////////////////////
void G4SoWindow::setWMClose(
SbBool aValue
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
fWMClose = aValue;
}
//////////////////////////////////////////////////////////////////////////////
SbBool G4SoWindow::getWMClose(
) const
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
return fWMClose;
}
//////////////////////////////////////////////////////////////////////////////
void G4SoWindow::show(
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
if(fWidget==0) return;
SoXt::show(fWidget);
}
//////////////////////////////////////////////////////////////////////////////
void G4SoWindow::hide(
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
if(fWidget==0) return;
SoXt::hide(fWidget);
}
//////////////////////////////////////////////////////////////////////////////
void G4SoWindow::setTitle(
const char* aString
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
if(aString==0) return;
#ifdef HEPVisXt
Arg args[1];
XtSetArg(args[0],XtNtitle,XtNewString(aString));
XtSetValues(fWidget,args,1);
#endif
#ifdef HEPVisWin32
::SetWindowText((HWND)fWidget,aString);
#endif
}
//////////////////////////////////////////////////////////////////////////////
void G4SoWindow::setSize(
const SbVec2s& aSize
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
if(fWidget==0) return;
#ifdef HEPVisXt
Arg args[1];
char s[32];
sprintf(s,"%dx%d",aSize[0],aSize[1]);
XtSetArg(args[0],XtNgeometry,XtNewString(s));
XtSetValues(fWidget,args,1);
//XWidgetSetDimension(fWidget,aSize[0],aSize[1]);
#endif
#ifdef HEPVisWin32
// Retreive window and client sizez :
RECT wrect,crect;
GetWindowRect((HWND)fWidget,&wrect);
GetClientRect((HWND)fWidget,&crect);
int ww = wrect.right-wrect.left;
int wh = wrect.bottom-wrect.top;
int cw = crect.right-crect.left;
int ch = crect.bottom-crect.top;
// Compell client rect to be 400 400 :
MoveWindow((HWND)fWidget,
wrect.left,wrect.top,
aSize[0]+ww-cw,aSize[1]+wh-ch,TRUE);
#endif
}
//////////////////////////////////////////////////////////////////////////////
SbVec2s G4SoWindow::getSize(
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
if(fWidget==0) return SbVec2s();
#ifdef HEPVisXt
Dimension width,height;
Arg args[2];
XtSetArg(args[0],XtNwidth ,&width);
XtSetArg(args[1],XtNheight,&height);
XtGetValues(fWidget,args,2);
return SbVec2s(width,height);
#endif
#ifdef HEPVisWin32
RECT rect;
::GetClientRect((HWND)fWidget,&rect);
return SbVec2s((short)(rect.right-rect.left),(short)(rect.bottom-rect.top));
#endif
}
//////////////////////////////////////////////////////////////////////////////
void G4SoWindow::registerWidget(
Widget aWidget
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
if(aWidget==0) return;
if(fWidgetDictionary==0) fWidgetDictionary = new SbDict;
fWidgetDictionary->enter((unsigned long)aWidget,this);
}
//////////////////////////////////////////////////////////////////////////////
void G4SoWindow::unregisterWidget(
Widget aWidget
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
if(aWidget==0) return;
if(fWidgetDictionary==0) return;
fWidgetDictionary->remove((unsigned long)aWidget);
}
//////////////////////////////////////////////////////////////////////////////
G4SoWindow* G4SoWindow::getWindow(
Widget aWidget
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
if(aWidget==0) return 0;
if(fWidgetDictionary==0) return 0;
void* value;
SbBool found = fWidgetDictionary->find((unsigned long)aWidget,value);
return (G4SoWindow*)(found==FALSE ? 0 : value);
}
#ifdef HEPVisXt
//////////////////////////////////////////////////////////////////////////////
void G4SoWindow::widgetDestroyedCB(
Widget aWidget
,XtPointer
,XtPointer
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
G4SoWindow* This = G4SoWindow::getWindow(aWidget);
if(This==0) return; // XtDestroyWidget called from ~G4SoWindow.
//printf("debug : G4SoWindow::widgetDestroyCB\n");
This->unregisterWidget(aWidget);
}
//////////////////////////////////////////////////////////////////////////////
void G4SoWindow::closeWindow(
Widget aWidget
,XEvent* /*aEvent*/
,char** /*aArgs*/
,Cardinal* /*aNarg*/
)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
G4SoWindow* This = G4SoWindow::getWindow(aWidget);
if( (This!=0) && (This->getWMClose()==TRUE) ) {
//SbWarn ("debug : CloseWindow : close\n");
#ifdef SoFreePackage
SoXt::sendExit ();
#else
exit (EXIT_SUCCESS);
#endif
} else {
// Should destroy G4SoWindow.
XtUnmapWidget(aWidget);
}
}
/*
#include <X11/IntrinsicP.h> //Dangerous.
void XWidgetSetDimension(Widget aWidget,Dimension a_width,Dimension a_height){
if(aWidget==0) return;
if((a_width<=0)||(a_height<=0)) return;
XtResizeWidget (aWidget,a_width,a_height,aWidget->core.border_width);
}
*/
#endif
#ifdef HEPVisWin32
//////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WindowProc (
HWND aWindow
,UINT aMessage
,WPARAM aWParam
,LPARAM aLParam
)
//////////////////////////////////////////////////////////////////////////////
// Below treatment of WM_SIZE, WM_SETFOCUS not necessary
// with TGS, but needed with SoFree. WM_DESTROY needed for
// 'main top level window' so that 'Close window' induces
// the end of the task.
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
switch (aMessage) {
case WM_SIZE:{ // Assume one child window !
int width = LOWORD(aLParam);
int height = HIWORD(aLParam);
//printf("debug : G4SoWindow : WMS_SIZE : %d %d\n",width,height);
HWND hwnd = ::GetFirstChild(aWindow);
if(hwnd!=0) {
::MoveWindow(hwnd,0,0,width,height,TRUE);
}
}return 0;
case WM_SETFOCUS:{ // Assume one child window !
HWND hwnd = ::GetFirstChild(aWindow);
if(hwnd!=0) ::SetFocus(hwnd);
}return 0;
case WM_DESTROY:{
G4SoWindow* This = (G4SoWindow*)::GetWindowLong(aWindow,GWL_USERDATA);
if( (This!=0) && (This->getWMClose()==TRUE) ) {
::PostQuitMessage(0);
}
}return 0;
default:
return (::DefWindowProc(aWindow,aMessage,aWParam,aLParam));
}
}
#endif
@@ -0,0 +1,273 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: SoBox.cc,v 1.2 2004/06/14 09:27:39 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/*----------------------------Hepvis----------------------------------------*/
/* */
/* Node: SoBox */
/* Description: Represents the G4Box Geant Geometry entity */
/* Author: Joe Boudreau Nov 11 1996 */
/* */
/*--------------------------------------------------------------------------*/
#include <assert.h>
#include <math.h>
#include <Inventor/SbBox.h>
#include <Inventor/fields/SoSFFloat.h>
#include <Inventor/misc/SoChildList.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoCube.h>
#include <Inventor/nodes/SoScale.h>
#include <Inventor/actions/SoAction.h>
#include <Inventor/nodes/SoIndexedFaceSet.h>
#include <Inventor/SoPrimitiveVertex.h>
#include <Inventor/elements/SoTextureCoordinateElement.h>
#include "HEPVis/nodes/SoBox.h"
// This statement is required
SO_NODE_SOURCE(SoBox)
// Constructor
SoBox::SoBox() {
// This statement is required
SO_NODE_CONSTRUCTOR(SoBox);
// Data fields are initialized like this:
SO_NODE_ADD_FIELD(fDx, (1.0));
SO_NODE_ADD_FIELD(fDy, (1.0));
SO_NODE_ADD_FIELD(fDz, (1.0));
SO_NODE_ADD_FIELD(alternateRep, (NULL));
children = new SoChildList(this);
}
// Destructor
SoBox::~SoBox() {
delete children;
}
// initClass
void SoBox::initClass(){
// This statement is required.
SO_NODE_INIT_CLASS(SoBox,SoShape,"Shape");
}
// generatePrimitives
void SoBox::generatePrimitives(SoAction *action) {
// This variable is used to store each vertex
SoPrimitiveVertex pv;
// Access the stat from the action
SoState *state = action->getState();
// See if we have to use a texture coordinate function,
// rather than generating explicit texture coordinates.
SbBool useTexFunction=
(SoTextureCoordinateElement::getType(state) ==
SoTextureCoordinateElement::FUNCTION);
// If we need to generate texture coordinates with a function,
// we'll need an SoGLTextureCoordinateElement. Otherwise, we'll
// set up the coordinates directly.
const SoTextureCoordinateElement *tce = NULL;
SbVec4f texCoord;
if (useTexFunction) {
tce = SoTextureCoordinateElement::getInstance(state);
}
else {
texCoord[2] = 0.0;
texCoord[3] = 1.0;
}
SbVec3f point, normal;
//////////////////////////////////////////
//----------------------------------------
#define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
point.setValue(x,y,z); \
normal.setValue(nx,ny,nz); \
if (useTexFunction) { \
texCoord=tce->get(point,normal); \
} \
else { \
texCoord[0]=s; \
texCoord[1]=t; \
} \
pv.setPoint(point); \
pv.setNormal(normal); \
pv.setTextureCoords(texCoord); \
shapeVertex(&pv);
//----------------------------------------
//////////////////////////////////////////
const int NPOINTS=8, NFACES=6, NINDICES = NFACES*5;
int indices[NINDICES] = {3,2,1,0, SO_END_FACE_INDEX, //z back.
4,5,6,7, SO_END_FACE_INDEX, //z front.
0,1,5,4, SO_END_FACE_INDEX, //y up.
1,2,6,5, SO_END_FACE_INDEX, //x left.
2,3,7,6, SO_END_FACE_INDEX, //y down.
3,0,4,7, SO_END_FACE_INDEX}; //x right.
// points for the eight vertices
float points[NPOINTS][3];
points[0][0] = fDx.getValue();
points[0][1] = fDy.getValue();
points[0][2] = -fDz.getValue();
points[1][0] = -fDx.getValue();
points[1][1] = fDy.getValue();
points[1][2] = -fDz.getValue();
points[2][0] = -fDx.getValue();
points[2][1] = -fDy.getValue();
points[2][2] = -fDz.getValue();
points[3][0] = fDx.getValue();
points[3][1] = -fDy.getValue();
points[3][2] = -fDz.getValue();
points[4][0] = fDx.getValue();
points[4][1] = fDy.getValue();
points[4][2] = fDz.getValue();
points[5][0] = -fDx.getValue();
points[5][1] = fDy.getValue();
points[5][2] = fDz.getValue();
points[6][0] = -fDx.getValue();
points[6][1] = -fDy.getValue();
points[6][2] = fDz.getValue();
points[7][0] = fDx.getValue();
points[7][1] = -fDy.getValue();
points[7][2] = fDz.getValue();
float normals[NFACES][3];
//z back.
normals[0][0] = 0 ; normals[0][1] = 0; normals [0][2] = -1;
//z front.
normals[1][0] = 0 ; normals[1][1] = 0; normals [1][2] = 1;
//y up.
normals[2][0] = 0 ; normals[2][1] = 1; normals [2][2] = 0;
//x left.
normals[3][0] = -1 ; normals[3][1] = 0; normals [3][2] = 0;
//y down.
normals[4][0] = 0 ; normals[4][1] = -1; normals [4][2] = 0;
//x right.
normals[5][0] = 1 ; normals[5][1] = 0; normals [5][2] = 0;
float x,y,z;
int index;
for (int nf=0;nf<NFACES;nf++) {
beginShape(action,TRIANGLE_FAN);
index = indices[nf * 5];
x = points[index][0];
y = points[index][1];
z = points[index][2];
GEN_VERTEX(pv,x,y,z,0.0,0.0,normals[nf][0],normals[nf][1],normals[nf][2]);
index = indices[nf * 5 + 1];
x = points[index][0];
y = points[index][1];
z = points[index][2];
GEN_VERTEX(pv,x,y,z,0.0,0.0,normals[nf][0],normals[nf][1],normals[nf][2]);
index = indices[nf * 5 + 2];
x = points[index][0];
y = points[index][1];
z = points[index][2];
GEN_VERTEX(pv,x,y,z,0.0,0.0,normals[nf][0],normals[nf][1],normals[nf][2]);
index = indices[nf * 5 + 3];
x = points[index][0];
y = points[index][1];
z = points[index][2];
GEN_VERTEX(pv,x,y,z,0.0,0.0,normals[nf][0],normals[nf][1],normals[nf][2]);
endShape();
}
}
// getChildren
SoChildList *SoBox::getChildren() const {
return children;
}
// computeBBox
void SoBox::computeBBox(SoAction *, SbBox3f &box, SbVec3f &center ){
SbVec3f vmin(-fDx.getValue(),-fDy.getValue(),-fDz.getValue()),
vmax( fDx.getValue(), fDy.getValue(), fDz.getValue());
center.setValue(0,0,0);
box.setBounds(vmin,vmax);
}
// updateChildren
void SoBox::updateChildren() {
// Redraw the G4Box....
assert(children->getLength()==1);
SoSeparator *sep = (SoSeparator *) ( *children)[0];
SoScale *scale = (SoScale *)( sep->getChild(0));
//SoCube *cube = (SoCube *)( sep->getChild(1));
scale->scaleFactor.setValue(fDx.getValue(), fDy.getValue(), fDz.getValue());
}
// generateChildren
void SoBox::generateChildren() {
// A box consists of a set of scale factors and a
// cube.
assert(children->getLength() ==0);
SoSeparator *sep = new SoSeparator();
SoScale *scale = new SoScale();
SoCube *cube = new SoCube();
sep->addChild(scale);
sep->addChild(cube);
children->append(sep);
}
// generateAlternateRep
void SoBox::generateAlternateRep() {
// This routine sets the alternate representation to the child
// list of this mode.
if (children->getLength() == 0) generateChildren();
updateChildren();
alternateRep.setValue((SoSeparator *) ( *children)[0]);
}
// clearAlternateRep
void SoBox::clearAlternateRep() {
alternateRep.setValue(NULL);
}
@@ -0,0 +1,436 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: SoCons.cc,v 1.2 2004/06/14 09:27:39 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/*-----------------------------Hepvis---------------------------------------*/
/* */
/* Node: SoCons */
/* Description: Represents the G4Cons Geant Geometry entity */
/* Author: Joe Boudreau Nov 11 1996 */
/* */
/*--------------------------------------------------------------------------*/
#include <assert.h>
#include <math.h>
#include <Inventor/SbBox.h>
#include <Inventor/actions/SoAction.h>
#include <Inventor/fields/SoSFFloat.h>
#include <Inventor/misc/SoChildList.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoIndexedFaceSet.h>
#include <Inventor/nodes/SoNormal.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoNormalBinding.h>
#include <Inventor/SoPrimitiveVertex.h>
#include <Inventor/elements/SoTextureCoordinateElement.h>
#include "HEPVis/SbMath.h"
#include "HEPVis/nodes/SoCons.h"
// This statement is required
SO_NODE_SOURCE(SoCons)
// Constructor
SoCons::SoCons() {
// This statement is required
SO_NODE_CONSTRUCTOR(SoCons);
// Data fields are initialized like this:
SO_NODE_ADD_FIELD(fRmin1, (0.0));
SO_NODE_ADD_FIELD(fRmin2, (0.0));
SO_NODE_ADD_FIELD(fRmax1, (1.0));
SO_NODE_ADD_FIELD(fRmax2, (1.0));
SO_NODE_ADD_FIELD(fDz, (10.0));
SO_NODE_ADD_FIELD(fSPhi, (0.0));
SO_NODE_ADD_FIELD(fDPhi, ((float)(2*M_PI)));
SO_NODE_ADD_FIELD(smoothDraw, (TRUE));
SO_NODE_ADD_FIELD(alternateRep, (NULL));
children = new SoChildList(this);
}
// Destructor
SoCons::~SoCons() {
delete children;
}
// initClass
void SoCons::initClass(){
// This statement is required.
SO_NODE_INIT_CLASS(SoCons,SoShape,"Shape");
}
// generatePrimitives
void SoCons::generatePrimitives(SoAction *action) {
// This variable is used to store each vertex
SoPrimitiveVertex pv;
// Access the stat from the action
SoState *state = action->getState();
// See if we have to use a texture coordinate function,
// rather than generating explicit texture coordinates.
SbBool useTexFunction=
(SoTextureCoordinateElement::getType(state) ==
SoTextureCoordinateElement::FUNCTION);
// If we need to generate texture coordinates with a function,
// we'll need an SoGLTextureCoordinateElement. Otherwise, we'll
// set up the coordinates directly.
const SoTextureCoordinateElement *tce = NULL;
SbVec4f texCoord;
if (useTexFunction) {
tce = SoTextureCoordinateElement::getInstance(state);
} else {
texCoord[2] = 0.0;
texCoord[3] = 1.0;
}
SbVec3f point, normal;
///////////////////////////////////////////////////////
//-----------------------------------------------------
#define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
point.setValue((float)(x),(float)(y),(float)(z)); \
normal.setValue((float)(nx),(float)(ny),(float)(nz)); \
if (useTexFunction) { \
texCoord=tce->get(point,normal); \
} else { \
texCoord[0]=(float)(s); \
texCoord[1]=(float)(t); \
} \
pv.setPoint(point); \
pv.setNormal(normal); \
pv.setTextureCoords(texCoord); \
shapeVertex(&pv);
//-----------------------------------------------------
///////////////////////////////////////////////////////
int NPHI = (int)(2+22*fabs(fDPhi.getValue()/(2.0*M_PI)));
double deltaPhi = fDPhi.getValue()/NPHI;
double phi0 = fSPhi.getValue();
double phi1 = phi0 + fDPhi.getValue();
double rMax1 = fRmax1.getValue();
double rMin1 = fRmin1.getValue();
double rMax2 = fRmax2.getValue();
double rMin2 = fRmin2.getValue();
double zMax = fDz.getValue();
double zMin = -zMax;
double cosPhi0 = cos(phi0);
double sinPhi0 = sin(phi0);
double cosPhi1 = cos(phi1);
double sinPhi1 = sin(phi1);
double cosDeltaPhi = cos(deltaPhi);
double sinDeltaPhi = sin(deltaPhi);
//
// The outer surface!
//
beginShape(action,TRIANGLE_STRIP);
int i;
double sinPhi=sinPhi0;
double cosPhi=cosPhi0;
for (i = 0; i<=NPHI; i++) {
GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,0.0,0.0,cosPhi,sinPhi,0);
GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,cosPhi,sinPhi,0);
inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
}
endShape();
//
// The inner surface!
//
beginShape(action,TRIANGLE_STRIP);
sinPhi=sinPhi0;
cosPhi=cosPhi0;
for (i = 0; i<=NPHI; i++) {
GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,0.0,0.0,-cosPhi,-sinPhi,0);
GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,1.0,1.0,-cosPhi,-sinPhi,0);
inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
}
endShape();
if (fabs(deltaPhi)<2.0*M_PI) {
//
// The end
//
beginShape(action,TRIANGLE_STRIP);
sinPhi=sinPhi0;
cosPhi=cosPhi0;
GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,0.0,0.0,sinPhi,-cosPhi,0);
GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,sinPhi,-cosPhi,0);
GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,1.0,0.0,sinPhi,-cosPhi,0);
GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,0.0,1.0,sinPhi,-cosPhi,0);
endShape();
//
// The other end
//
beginShape(action,TRIANGLE_STRIP);
sinPhi=sinPhi1;
cosPhi=cosPhi1;
GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi, zMax,0.0,0.0,-sinPhi,+cosPhi,0);
GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi, zMin,1.0,1.0,-sinPhi,+cosPhi,0);
GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi, zMax,1.0,0.0,-sinPhi,+cosPhi,0);
GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi, zMin,0.0,1.0,-sinPhi,+cosPhi,0);
endShape();
}
//
// The outer surface at z=+PDZ
//
beginShape(action,TRIANGLE_STRIP);
sinPhi=sinPhi0;
cosPhi=cosPhi0;
for (i = 0; i<=NPHI; i++) {
GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,0.0,0.0,0,0,1);
GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,1.0,1.0,0,0,1);
inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
}
endShape();
//
// The outer surface at z=-PDZ
//
beginShape(action,TRIANGLE_STRIP);
sinPhi=sinPhi0;
cosPhi=cosPhi0;
for (i = 0; i<=NPHI; i++) {
GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,0.0,0.0,0,0,-1);
GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,0,0,-1);
inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
}
endShape();
}
// getChildren
SoChildList *SoCons::getChildren() const {
return children;
}
// computeBBox
void SoCons::computeBBox(SoAction *, SbBox3f &box, SbVec3f &center ){
float fRmax= fRmax1.getValue();
if (fRmax2.getValue() > fRmax) fRmax = fRmax2.getValue();
SbVec3f vmin(-fRmax,-fRmax,-fDz.getValue()),
vmax( fRmax, fRmax, fDz.getValue());
center.setValue(0,0,0);
box.setBounds(vmin,vmax);
}
// updateChildren
void SoCons::updateChildren() {
// Redraw the G4Cons....
assert(children->getLength()==1);
SoSeparator *sep = (SoSeparator *) ( *children)[0];
SoCoordinate3 *theCoordinates = (SoCoordinate3 *) ( sep->getChild(0));
SoNormal *theNormals = (SoNormal *) ( sep->getChild(1));
SoNormalBinding *theNormalBinding = (SoNormalBinding *) ( sep->getChild(2));
SoIndexedFaceSet *theFaceSet = (SoIndexedFaceSet *) ( sep->getChild(3));
const int NPHI=24, NPOINTS=2*(2*NPHI+2), NFACES=4*NPHI+2, NINDICES = NFACES*5;
float points[NPOINTS][3], normals[NFACES][3];
#ifdef INVENTOR2_0
static long indices[NINDICES];
#else
static int32_t indices[NINDICES];
#endif
static int init=0;
double phi, pp, DeltaPhi;
// Indices need to be generated once! This is here to keep it close to the point
// generation, since otherwise it will be confusing.
int i;
if (!init) {
init = 1;
// Outer face
for (i = 0; i< NPHI; i++) {
// 0 1 3 2;
indices[5*i+0] = 2*i+0;
indices[5*i+1] = 2*i+1;
indices[5*i+2] = 2*i+3;
indices[5*i+3] = 2*i+2;
indices[5*i+4] = SO_END_FACE_INDEX;
}
// the inner face
for (i=0;i<NPHI;i++) {
indices[5*1*NPHI + 5*i+0] = 2*NPHI+2 + 2*i+0;
indices[5*1*NPHI + 5*i+1] = 2*NPHI+2 + 2*i+1;
indices[5*1*NPHI + 5*i+2] = 2*NPHI+2 + 2*i+3;
indices[5*1*NPHI + 5*i+3] = 2*NPHI+2 + 2*i+2;
indices[5*1*NPHI + 5*i+4] = SO_END_FACE_INDEX;
}
// the top side
for (i=0;i<NPHI;i++) {
indices[5*2*NPHI + 5*i+0] = 2*i+0;
indices[5*2*NPHI + 5*i+1] = 2*i+2;
indices[5*2*NPHI + 5*i+2] = NPOINTS - (2*i+4);
indices[5*2*NPHI + 5*i+3] = NPOINTS - (2*i+2);
indices[5*2*NPHI + 5*i+4] = SO_END_FACE_INDEX;
}
// the bottom side
for (i=0;i<NPHI;i++) {
indices[5*3*NPHI + 5*i+0] = 2*i+1;
indices[5*3*NPHI + 5*i+1] = NPOINTS - (2*i+1);
indices[5*3*NPHI + 5*i+2] = NPOINTS - (2*i+3);
indices[5*3*NPHI + 5*i+3] = 2*i+3;
indices[5*3*NPHI + 5*i+4] = SO_END_FACE_INDEX;
}
// the odd side
indices[5*4*NPHI +0] = 2*NPHI;
indices[5*4*NPHI +1] = 2*NPHI+1;
indices[5*4*NPHI +2] = 2*NPHI+3;
indices[5*4*NPHI +3] = 2*NPHI+2;
indices[5*4*NPHI +4] = SO_END_FACE_INDEX;
// aother odd side
indices[5*4*NPHI +5 +0] = 0;
indices[5*4*NPHI +5 +1] = NPOINTS-2;
indices[5*4*NPHI +5 +2] = NPOINTS-1;
indices[5*4*NPHI +5 +3] = 1;
indices[5*4*NPHI +5 +4] = SO_END_FACE_INDEX;
}
// Points need to be generated each time:
// The outer surface
DeltaPhi = fDPhi.getValue()/NPHI, phi = fSPhi.getValue();
float t,st,ct;
t = FATAN((fRmax2.getValue()-fRmax1.getValue())/(2*fDz.getValue()));
st = FSIN(t);
ct = FCOS(t);
for (i = 0; i<=NPHI; i++) {
points[2*i+0][0] = fRmax2.getValue()*FCOS(phi);
points[2*i+0][1] = fRmax2.getValue()*FSIN(phi);
points[2*i+0][2] = +fDz.getValue();
points[2*i+1][0] = fRmax1.getValue()*FCOS(phi);
points[2*i+1][1] = fRmax1.getValue()*FSIN(phi);
points[2*i+1][2] = -fDz.getValue();
pp = phi+DeltaPhi/2.0;
if (i!=NPHI) {
normals[i][0] = ct * FCOS(pp);
normals[i][1] = ct * FSIN(pp);
normals[i][2] = -st;
}
phi+=DeltaPhi;
}
// The inner surface
phi = fSPhi.getValue() + fDPhi.getValue();
t = FATAN((fRmin2.getValue()-fRmin1.getValue())/(2*fDz.getValue()));
st = FSIN(t);
ct = FCOS(t);
for (i = 0; i<=NPHI; i++) {
points[2*NPHI+2+2*i+0][0] = fRmin2.getValue()*FCOS(phi);
points[2*NPHI+2+2*i+0][1] = fRmin2.getValue()*FSIN(phi);
points[2*NPHI+2+2*i+0][2] = +fDz.getValue();
points[2*NPHI+2+2*i+1][0] = fRmin1.getValue()*FCOS(phi);
points[2*NPHI+2+2*i+1][1] = fRmin1.getValue()*FSIN(phi);
points[2*NPHI+2+2*i+1][2] = -fDz.getValue();
pp = phi-DeltaPhi/2.0;
if (i!=NPHI) {
normals[NPHI+i][0] = -ct*FCOS(pp);
normals[NPHI+i][1] = -ct*FSIN(pp);
normals[NPHI+i][2] = st;
}
phi-=DeltaPhi;
}
// The top side
for (i=0;i<NPHI;i++) {
normals[2*NPHI+i][0]=normals[2*NPHI+i][1]=0;
normals[2*NPHI+i][2]= 1.0;
}
// The bottom side
for (i=0;i<NPHI;i++) {
normals[3*NPHI+i][0]=normals[3*NPHI+i][1]=0;
normals[3*NPHI+i][2]= -1.0;
}
// The odd side
phi = fSPhi.getValue();
normals[4*NPHI+0][0]= FSIN(phi);
normals[4*NPHI+0][1]= -FCOS(phi);
normals[4*NPHI+0][2]= 0;
// Another odd side
phi = fSPhi.getValue()+fDPhi.getValue();
normals[4*NPHI+1][0]= -FSIN(phi);
normals[4*NPHI+1][1]= +FCOS(phi);
normals[4*NPHI+1][2]=0;
for (int np=0;np<NPOINTS;np++) theCoordinates->point.set1Value(np,points[np][0],points[np][1],points[np][2]);
theFaceSet->coordIndex.setValues(0,NINDICES,indices);
if (smoothDraw.getValue()) {
// This Line is replaced by the next one because of an apparent Bug in Inventor (mem. leak).
// theNormals->vector.deleteValues(0);
for (int nf=0;nf<NFACES;nf++) theNormals->vector.set1Value(nf,normals[nf][0],normals[nf][1],normals[nf][2]);
theNormalBinding->value=SoNormalBinding::PER_FACE;
}
else {
for (int nf=0;nf<NFACES;nf++) theNormals->vector.set1Value(nf,normals[nf][0],normals[nf][1],normals[nf][2]);
theNormalBinding->value=SoNormalBinding::PER_FACE;
}
}
// generateChildren
void SoCons::generateChildren() {
// This routines creates one SoSeparator, one SoCoordinate3, and
// one SoLineSet, and puts it in the child list. This is done only
// once, whereas redrawing the position of the coordinates occurs each
// time an update is necessary, in the updateChildren routine.
assert(children->getLength() ==0);
SoSeparator *sep = new SoSeparator();
SoCoordinate3 *theCoordinates = new SoCoordinate3();
SoNormal *theNormals = new SoNormal();
SoNormalBinding *theNormalBinding = new SoNormalBinding();
SoIndexedFaceSet *theFaceSet = new SoIndexedFaceSet();
//
// This line costs some in render quality! but gives speed.
//
sep->addChild(theCoordinates);
sep->addChild(theNormals);
sep->addChild(theNormalBinding);
sep->addChild(theFaceSet);
children->append(sep);
}
// generateAlternateRep
void SoCons::generateAlternateRep() {
// This routine sets the alternate representation to the child
// list of this mode.
if (children->getLength() == 0) generateChildren();
updateChildren();
alternateRep.setValue((SoSeparator *) ( *children)[0]);
}
// clearAlternateRep
void SoCons::clearAlternateRep() {
alternateRep.setValue(NULL);
}
@@ -0,0 +1,214 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: SoDetectorTreeKit.cc,v 1.2 2004/06/14 09:27:40 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/*-----------------------------Hepvis----------------------------------------*/
/* */
/* Node: SoDetectorTreeKit */
/* Description: Represents a single sided silicon strip detector */
/* Author: Joe Boudreau Nov 11 1996 */
/* */
/*---------------------------------------------------------------------------*/
#include <math.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/events/SoMouseButtonEvent.h>
#include <Inventor/SoPickedPoint.h>
#include <Inventor/nodes/SoPickStyle.h>
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodekits/SoAppearanceKit.h>
#include <Inventor/nodekits/SoNodeKitListPart.h>
#include <Inventor/nodekits/SoBaseKit.h>
#include <Inventor/nodes/SoSwitch.h>
#include <Inventor/nodekits/SoSeparatorKit.h>
#include <Inventor/nodekits/SoShapeKit.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/actions/SoHandleEventAction.h>
#include <Inventor/nodes/SoUnits.h>
#include <Inventor/nodes/SoTransform.h>
#include <Inventor/nodes/SoTexture2Transform.h>
#include "HEPVis/nodekits/SoDetectorTreeKit.h"
// This statement is required
SO_KIT_SOURCE(SoDetectorTreeKit)
// initClass
void SoDetectorTreeKit::initClass(){
SO_KIT_INIT_CLASS(SoDetectorTreeKit,SoBaseKit,"BaseKit");
}
// Constructor
SoDetectorTreeKit::SoDetectorTreeKit() {
SO_KIT_CONSTRUCTOR(SoDetectorTreeKit);
SO_NODE_ADD_FIELD(alternateRep, (NULL));
SO_KIT_ADD_CATALOG_ENTRY ( topSeparator, SoSeparator, FALSE, this,\0, FALSE);
SO_KIT_ADD_CATALOG_ENTRY ( pickStyle, SoSeparator, TRUE , topSeparator,\0, TRUE);
SO_KIT_ADD_CATALOG_ENTRY ( appearance, SoAppearanceKit, TRUE, topSeparator ,\0, TRUE);
SO_KIT_ADD_CATALOG_ENTRY ( units, SoUnits, TRUE, topSeparator ,\0, TRUE);
SO_KIT_ADD_CATALOG_ENTRY ( transform, SoTransform, TRUE , topSeparator,\0, TRUE);
SO_KIT_ADD_CATALOG_ENTRY (texture2Transform, SoTexture2Transform, TRUE, topSeparator ,\0, TRUE);
SO_KIT_ADD_CATALOG_ENTRY ( childList, SoSwitch, FALSE, topSeparator,\0, FALSE);
SO_KIT_ADD_CATALOG_ENTRY ( previewSeparator, SoSeparator, FALSE, childList,\0, TRUE);
SO_KIT_ADD_CATALOG_ENTRY ( fullSeparator, SoSeparator, FALSE, childList,\0, TRUE);
SO_KIT_INIT_INSTANCE();
createInitialTree();
}
// Destructor
SoDetectorTreeKit::~SoDetectorTreeKit() {
}
SbBool SoDetectorTreeKit::affectsState() const {
return FALSE;
}
void SoDetectorTreeKit::createInitialTree() {
SoEventCallback *myCallback = new SoEventCallback();
myCallback->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
SoDetectorTreeKit::expand,
this);
myCallback->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
SoDetectorTreeKit::contract ,
this);
if(setPart("callbackList[0]",myCallback)==FALSE) myCallback->unref();
SoSwitch *theChildList = (SoSwitch *) childList.getValue();
theChildList->whichChild.setValue(0);
}
void SoDetectorTreeKit::expand(void *userData, SoEventCallback *eventCB){
// Was the event previously handled? Is it the right kind?
if (eventCB->isHandled()) return;
const SoMouseButtonEvent *event= (SoMouseButtonEvent *) eventCB->getEvent();
if (!SoMouseButtonEvent::isButtonPressEvent(event,SoMouseButtonEvent::BUTTON1)) return;
if (!event->wasCtrlDown()) return;
if (event->wasShiftDown()) return;
// Which Strip Detector is this being called for?
SoDetectorTreeKit *This = (SoDetectorTreeKit *) userData;
// Find out whether that's the one that has been picked. This is the lowest detector
// tree kit in the hierarchy.
SoHandleEventAction *handleEventAction = eventCB->getAction();
const SoPickedPoint *pickedPoint = handleEventAction->getPickedPoint();
if (!pickedPoint) return;
SoFullPath *path = (SoFullPath *) pickedPoint->getPath();
SoNode *ancestorNode=NULL;
for (int i=0;i<path->getLength();i++) {
ancestorNode = path->getNodeFromTail(i);
if (ancestorNode->isOfType(SoDetectorTreeKit::getClassTypeId())) break;
}
if (This!=ancestorNode) return;
// if (!ancestorNode->isOfType(SoDetectorTreeKit::getClassTypeId())) return;
// Deactivate the Preview
This->setPreview(FALSE);
eventCB->setHandled();
}
void SoDetectorTreeKit::contract(void *userData, SoEventCallback *eventCB){
// Was the event previously handled? Is it the right kind?
if (eventCB->isHandled()) return;
const SoMouseButtonEvent *event= (SoMouseButtonEvent *) eventCB->getEvent();
if (!SoMouseButtonEvent::isButtonPressEvent(event,SoMouseButtonEvent::BUTTON1)) return;
if (event->wasCtrlDown()) return;
if (!event->wasShiftDown()) return;
// Which Strip Detector is this being called for?
SoDetectorTreeKit *This = (SoDetectorTreeKit *) userData;
// Find out whether that's the one that has been picked
SoHandleEventAction *handleEventAction = eventCB->getAction();
const SoPickedPoint *pickedPoint = handleEventAction->getPickedPoint();
if (!pickedPoint) return;
// Find out whether that's the one that has been picked. This is the lowest detector
// tree kit in the hierarchy.
SoFullPath *path = (SoFullPath *) pickedPoint->getPath();
SoNode *ancestorNode=NULL;
SbBool firstTreeFound=FALSE;
for (int i=0;i<path->getLength();i++) {
ancestorNode = path->getNodeFromTail(i);
if (ancestorNode->isOfType(SoDetectorTreeKit::getClassTypeId())) {
if (!firstTreeFound) {
if (This!=ancestorNode) return;
firstTreeFound=TRUE;
}
SoDetectorTreeKit *That = (SoDetectorTreeKit *) ancestorNode;
if (!That->getPreview()) {
That->setPreview(TRUE);
eventCB->setHandled();
return;
}
}
}
}
void SoDetectorTreeKit::setPreview(SbBool Flag) {
SoSwitch *theChildList = (SoSwitch *) childList.getValue();
if (Flag) {
theChildList->whichChild.setValue(0);
}
else {
theChildList->whichChild.setValue(1);
}
}
SbBool SoDetectorTreeKit::getPreview() const {
SoSwitch *theChildList = (SoSwitch *) childList.getValue();
if (theChildList->whichChild.getValue()==0) return TRUE;
return FALSE;
}
SoSeparator *SoDetectorTreeKit::getPreviewSeparator() const {
return (SoSeparator *) previewSeparator.getValue();
}
SoSeparator *SoDetectorTreeKit::getFullSeparator() const {
return (SoSeparator *) fullSeparator.getValue();
}
// generateAlternateRep
void SoDetectorTreeKit::generateAlternateRep() {
alternateRep.setValue(topSeparator.getValue());
}
void SoDetectorTreeKit::clearAlternateRep() {
alternateRep.setValue(NULL);
}
@@ -0,0 +1,403 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: SoTrap.cc,v 1.2 2004/06/14 09:27:40 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/*-----------------------------Hepvis----------------------------------------*/
/* */
/* Node: SoTrap */
/* Description: Represents the G4Trap Geant Geometry entity */
/* Author: Joe Boudreau Nov 11 1996 */
/* */
/* */
/*---------------------------------------------------------------------------*/
#include <assert.h>
#include <math.h>
#include <Inventor/SbBox.h>
#include <Inventor/actions/SoGLRenderAction.h>
#include <Inventor/actions/SoAction.h>
#include <Inventor/fields/SoSFFloat.h>
#include <Inventor/misc/SoChildList.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoIndexedFaceSet.h>
#include <Inventor/nodes/SoNormal.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoNormalBinding.h>
#include <Inventor/SoPrimitiveVertex.h>
#include <Inventor/elements/SoTextureCoordinateElement.h>
#include "HEPVis/SbMath.h"
#include "HEPVis/nodes/SoTrap.h"
// This statement is required
SO_NODE_SOURCE(SoTrap)
// Constructor
SoTrap::SoTrap() {
// This statement is required
SO_NODE_CONSTRUCTOR(SoTrap);
// Data fields are initialized like this:
SO_NODE_ADD_FIELD(pDz, (1.0));
SO_NODE_ADD_FIELD(pTheta, (0.0));
SO_NODE_ADD_FIELD(pPhi, (0.0));
SO_NODE_ADD_FIELD(pDy1, (1.0));
SO_NODE_ADD_FIELD(pDx1, (1.0));
SO_NODE_ADD_FIELD(pDx2, (1.0));
SO_NODE_ADD_FIELD(pDy2, (1.0));
SO_NODE_ADD_FIELD(pDx3, (1.0));
SO_NODE_ADD_FIELD(pDx4, (1.0));
SO_NODE_ADD_FIELD(pAlp1, (0.0));
SO_NODE_ADD_FIELD(pAlp2, (0.0));
SO_NODE_ADD_FIELD(alternateRep, (NULL));
children = new SoChildList(this);
}
// Destructor
SoTrap::~SoTrap() {
delete children;
}
// initClass
void SoTrap::initClass(){
// This statement is required.
SO_NODE_INIT_CLASS(SoTrap,SoShape,"Shape");
}
// generatePrimitives
void SoTrap::generatePrimitives(SoAction *action) {
// This variable is used to store each vertex
SoPrimitiveVertex pv;
// Access the stat from the action
SoState *state = action->getState();
// See if we have to use a texture coordinate function,
// rather than generating explicit texture coordinates.
SbBool useTexFunction=
(SoTextureCoordinateElement::getType(state) ==
SoTextureCoordinateElement::FUNCTION);
// If we need to generate texture coordinates with a function,
// we'll need an SoGLTextureCoordinateElement. Otherwise, we'll
// set up the coordinates directly.
const SoTextureCoordinateElement *tce = NULL;
SbVec4f texCoord;
if (useTexFunction) {
tce = SoTextureCoordinateElement::getInstance(state);
}
else {
texCoord[2] = 0.0;
texCoord[3] = 1.0;
}
SbVec3f point, normal;
//////////////////////////////////////////
//----------------------------------------
#define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
point.setValue(x,y,z); \
normal.setValue(nx,ny,nz); \
if (useTexFunction) { \
texCoord=tce->get(point,normal); \
} \
else { \
texCoord[0]=s; \
texCoord[1]=t; \
} \
pv.setPoint(point); \
pv.setNormal(normal); \
pv.setTextureCoords(texCoord); \
shapeVertex(&pv);
//----------------------------------------
//////////////////////////////////////////
const int NPOINTS=8, NFACES=6, NINDICES = NFACES*5;
int indices[NINDICES] = {3,2,1,0, SO_END_FACE_INDEX, //z back.
4,5,6,7, SO_END_FACE_INDEX, //z front.
0,1,5,4, SO_END_FACE_INDEX, //y up.
1,2,6,5, SO_END_FACE_INDEX, //x left.
2,3,7,6, SO_END_FACE_INDEX, //y down.
3,0,4,7, SO_END_FACE_INDEX}; //x right.
// points for the eight vertices
float TthetaCphi = FTAN(pTheta.getValue())*FCOS(pPhi.getValue());
float TthetaSphi = FTAN(pTheta.getValue())*FSIN(pPhi.getValue());
float Talp1 = FTAN(pAlp1.getValue());
float Talp2 = FTAN(pAlp2.getValue());
float points[NPOINTS][3];
points[0][0] = pDx2.getValue()+pDy1.getValue()*Talp1;
points[0][1] = pDy1.getValue();
points[0][2] = -pDz.getValue();
points[1][0] = -pDx2.getValue()+pDy1.getValue()*Talp1;
points[1][1] = pDy1.getValue();
points[1][2] = -pDz.getValue();
points[2][0] = -pDx1.getValue()-pDy1.getValue()*Talp1;
points[2][1] = -pDy1.getValue();
points[2][2] = -pDz.getValue();
points[3][0] = pDx1.getValue()-pDy1.getValue()*Talp1;
points[3][1] = -pDy1.getValue();
points[3][2] = -pDz.getValue();
points[4][0] = pDx4.getValue()+pDy2.getValue()*Talp2;
points[4][1] = pDy2.getValue();
points[4][2] = pDz.getValue();
points[5][0] = -pDx4.getValue()+pDy2.getValue()*Talp2;
points[5][1] = pDy2.getValue();
points[5][2] = pDz.getValue();
points[6][0] = -pDx3.getValue()-pDy2.getValue()*Talp2;
points[6][1] = -pDy2.getValue();
points[6][2] = pDz.getValue();
points[7][0] = pDx3.getValue()-pDy2.getValue()*Talp2;
points[7][1] = -pDy2.getValue();
points[7][2] = pDz.getValue();
int i;
for (i=0;i<4;i++) {
points[i][0] -= pDz.getValue()*TthetaCphi;
points[i][1] -= pDz.getValue()*TthetaSphi;
}
for (i=4;i<8;i++) {
points[i][0] += pDz.getValue()*TthetaCphi;
points[i][1] += pDz.getValue()*TthetaSphi;
}
SbVec3f normals[NFACES];
int nf;
for (nf=0;nf<NFACES;nf++) {
int j0 = indices[5*nf + 0];
int j1 = indices[5*nf + 1];
int j2 = indices[5*nf + 2];
SbVec3f p0(points[j0][0],points[j0][1],points[j0][2]);
SbVec3f p1(points[j1][0],points[j1][1],points[j1][2]);
SbVec3f p2(points[j2][0],points[j2][1],points[j2][2]);
normals[nf] = (p1-p0).cross(p2-p0);
normals[nf].normalize();
}
float x,y,z;
int index;
for (nf=0;nf<NFACES;nf++) {
beginShape(action,TRIANGLE_FAN);
index = indices[nf * 5];
x = points[index][0];
y = points[index][1];
z = points[index][2];
GEN_VERTEX(pv,x,y,z,0.0,0.0,normals[nf][0],normals[nf][1],normals[nf][2]);
index = indices[nf * 5 + 1];
x = points[index][0];
y = points[index][1];
z = points[index][2];
GEN_VERTEX(pv,x,y,z,0.0,0.0,normals[nf][0],normals[nf][1],normals[nf][2]);
index = indices[nf * 5 + 2];
x = points[index][0];
y = points[index][1];
z = points[index][2];
GEN_VERTEX(pv,x,y,z,0.0,0.0,normals[nf][0],normals[nf][1],normals[nf][2]);
index = indices[nf * 5 + 3];
x = points[index][0];
y = points[index][1];
z = points[index][2];
GEN_VERTEX(pv,x,y,z,0.0,0.0,normals[nf][0],normals[nf][1],normals[nf][2]);
endShape();
}
}
// getChildren
SoChildList *SoTrap::getChildren() const {
return children;
}
// computeBBox
void SoTrap::computeBBox(SoAction *, SbBox3f &box, SbVec3f &center ){
float pDx= pDx1.getValue(),pDy=pDy1.getValue();
if (pDx2.getValue() > pDx) pDx = pDx2.getValue();
if (pDx3.getValue() > pDx) pDx = pDx3.getValue();
if (pDx4.getValue() > pDx) pDx = pDx4.getValue();
if (pDy2.getValue() > pDy) pDy = pDy2.getValue();
float TthetaCphi = FTAN(pTheta.getValue())*FCOS(pPhi.getValue());
float TthetaSphi = FTAN(pTheta.getValue())*FSIN(pPhi.getValue());
float Xalp = FFABS(tan(pAlp1.getValue())*pDy1.getValue());
float Xalp2 = FFABS(tan(pAlp2.getValue())*pDy2.getValue());
if (Xalp< Xalp2) Xalp=Xalp2;
pDx += FFABS(TthetaCphi*pDz.getValue());
pDx += Xalp;
pDy += FFABS(TthetaSphi*pDz.getValue());
center.setValue(0,0,0);
box.setBounds(SbVec3f(-pDx,-pDy,-pDz.getValue()),
SbVec3f( pDx, pDy, pDz.getValue()));
}
// updateChildren
void SoTrap::updateChildren() {
// Redraw the G4Trap....
assert(children->getLength()==1);
SoSeparator *sep = (SoSeparator *) ( *children)[0];
SoCoordinate3 *theCoordinates = (SoCoordinate3 *) ( sep->getChild(0));
SoNormal *theNormals = (SoNormal *) ( sep->getChild(1));
SoNormalBinding *theNormalBinding = (SoNormalBinding *) ( sep->getChild(2));
SoIndexedFaceSet *theFaceSet = (SoIndexedFaceSet *) ( sep->getChild(3));
const int NPOINTS=8, NFACES=6, NINDICES = NFACES*5;
float points[NPOINTS][3];
// Indices for the eight faces
#ifdef INVENTOR2_0
static long
#else
static int32_t
#endif
indices[NINDICES] = {3,2,1,0, SO_END_FACE_INDEX, // bottom
4,5,6,7, SO_END_FACE_INDEX, // top
0,1,5,4, SO_END_FACE_INDEX,
1,2,6,5, SO_END_FACE_INDEX,
2,3,7,6, SO_END_FACE_INDEX,
3,0,4,7, SO_END_FACE_INDEX};
// points for the eight vertices
float TthetaCphi = FTAN(pTheta.getValue())*FCOS(pPhi.getValue());
float TthetaSphi = FTAN(pTheta.getValue())*FSIN(pPhi.getValue());
float Talp1 = FTAN(pAlp1.getValue());
float Talp2 = FTAN(pAlp2.getValue());
points[0][0] = pDx2.getValue()+pDy1.getValue()*Talp1;
points[0][1] = pDy1.getValue();
points[0][2] = -pDz.getValue();
points[1][0] = -pDx2.getValue()+pDy1.getValue()*Talp1;
points[1][1] = pDy1.getValue();
points[1][2] = -pDz.getValue();
points[2][0] = -pDx1.getValue()-pDy1.getValue()*Talp1;
points[2][1] = -pDy1.getValue();
points[2][2] = -pDz.getValue();
points[3][0] = pDx1.getValue()-pDy1.getValue()*Talp1;
points[3][1] = -pDy1.getValue();
points[3][2] = -pDz.getValue();
points[4][0] = pDx4.getValue()+pDy2.getValue()*Talp2;
points[4][1] = pDy2.getValue();
points[4][2] = pDz.getValue();
points[5][0] = -pDx4.getValue()+pDy2.getValue()*Talp2;
points[5][1] = pDy2.getValue();
points[5][2] = pDz.getValue();
points[6][0] = -pDx3.getValue()-pDy2.getValue()*Talp2;
points[6][1] = -pDy2.getValue();
points[6][2] = pDz.getValue();
points[7][0] = pDx3.getValue()-pDy2.getValue()*Talp2;
points[7][1] = -pDy2.getValue();
points[7][2] = pDz.getValue();
int i;
for (i=0;i<4;i++) {
points[i][0] -= pDz.getValue()*TthetaCphi;
points[i][1] -= pDz.getValue()*TthetaSphi;
}
for (i=4;i<8;i++) {
points[i][0] += pDz.getValue()*TthetaCphi;
points[i][1] += pDz.getValue()*TthetaSphi;
}
for (int np=0;np<NPOINTS;np++) theCoordinates->point.set1Value(np,points[np][0],points[np][1],points[np][2]);
theFaceSet->coordIndex.setValues(0,NINDICES,indices);
theNormals->vector.deleteValues(0);
theNormals->vector.insertSpace(0,6);
for (int n=0;n<6;n++) {
int i0 = 5*n+0,i1=5*n+1,i2=5*n+2;
int j0 = theFaceSet->coordIndex[i0];
int j1 = theFaceSet->coordIndex[i1];
int j2 = theFaceSet->coordIndex[i2];
SbVec3f p0= theCoordinates->point[j0];
SbVec3f p1= theCoordinates->point[j1];
SbVec3f p2= theCoordinates->point[j2];
SbVec3f normal = (p1-p0).cross(p2-p0);
normal.normalize();
theNormals->vector.set1Value(n,normal);
}
theNormalBinding->value=SoNormalBinding::PER_FACE;
}
// generateChildren
void SoTrap::generateChildren() {
// This routines creates one SoSeparator, one SoCoordinate3, and
// one SoLineSet, and puts it in the child list. This is done only
// once, whereas redrawing the position of the coordinates occurs each
// time an update is necessary, in the updateChildren routine.
assert(children->getLength() ==0);
SoSeparator *sep = new SoSeparator();
SoCoordinate3 *theCoordinates = new SoCoordinate3();
SoNormal *theNormals = new SoNormal();
SoNormalBinding *theNormalBinding = new SoNormalBinding();
SoIndexedFaceSet *theFaceSet = new SoIndexedFaceSet();
//
// This line costs some in render quality! but gives speed.
//
sep->addChild(theCoordinates);
sep->addChild(theNormals);
sep->addChild(theNormalBinding);
sep->addChild(theFaceSet);
children->append(sep);
}
// generateAlternateRep
void SoTrap::generateAlternateRep() {
// This routine sets the alternate representation to the child
// list of this mode.
if (children->getLength() == 0) generateChildren();
updateChildren();
alternateRep.setValue((SoSeparator *) ( *children)[0]);
}
// clearAlternateRep
void SoTrap::clearAlternateRep() {
alternateRep.setValue(NULL);
}
@@ -0,0 +1,339 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: SoTrd.cc,v 1.2 2004/06/14 09:27:41 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/*-----------------------------Hepvis---------------------------------------*/
/* */
/* Node: SoTrd */
/* Description: Represents the G4Trd Geant Geometry entity */
/* Author: Joe Boudreau Nov 11 1996 */
/* */
/*--------------------------------------------------------------------------*/
#include <assert.h>
#include <math.h>
#include <Inventor/SbBox.h>
#include <Inventor/actions/SoAction.h>
#include <Inventor/fields/SoSFFloat.h>
#include <Inventor/misc/SoChildList.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoIndexedFaceSet.h>
#include <Inventor/nodes/SoNormal.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoNormalBinding.h>
#include <Inventor/SoPrimitiveVertex.h>
#include <Inventor/elements/SoTextureCoordinateElement.h>
#include "HEPVis/SbMath.h"
#include "HEPVis/nodes/SoTrd.h"
// This statement is required
SO_NODE_SOURCE(SoTrd)
// initClass
void SoTrd::initClass(){
SO_NODE_INIT_CLASS(SoTrd,SoShape,"Shape");
}
// Constructor
SoTrd::SoTrd() {
// This statement is required
SO_NODE_CONSTRUCTOR(SoTrd);
// Data fields are initialized like this:
SO_NODE_ADD_FIELD(fDx1,(1.0));
SO_NODE_ADD_FIELD(fDx2,(1.0));
SO_NODE_ADD_FIELD(fDy1,(1.0));
SO_NODE_ADD_FIELD(fDy2,(1.0));
SO_NODE_ADD_FIELD(fDz,(1.0));
SO_NODE_ADD_FIELD(alternateRep,(NULL));
children = new SoChildList(this);
}
// Destructor
SoTrd::~SoTrd() {
delete children;
}
// generatePrimitives
void SoTrd::generatePrimitives(SoAction *action) {
// This variable is used to store each vertex
SoPrimitiveVertex pv;
// Access the stat from the action
SoState *state = action->getState();
// See if we have to use a texture coordinate function,
// rather than generating explicit texture coordinates.
SbBool useTexFunction=
(SoTextureCoordinateElement::getType(state) ==
SoTextureCoordinateElement::FUNCTION);
// If we need to generate texture coordinates with a function,
// we'll need an SoGLTextureCoordinateElement. Otherwise, we'll
// set up the coordinates directly.
const SoTextureCoordinateElement *tce = NULL;
SbVec4f texCoord;
if (useTexFunction) {
tce = SoTextureCoordinateElement::getInstance(state);
}
else {
texCoord[2] = 0.0;
texCoord[3] = 1.0;
}
SbVec3f point, normal;
//////////////////////////////////////////
//----------------------------------------
#define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
point.setValue(x,y,z); \
normal.setValue(nx,ny,nz); \
if (useTexFunction) { \
texCoord=tce->get(point,normal); \
} \
else { \
texCoord[0]=s; \
texCoord[1]=t; \
} \
pv.setPoint(point); \
pv.setNormal(normal); \
pv.setTextureCoords(texCoord); \
shapeVertex(&pv);
//----------------------------------------
//////////////////////////////////////////
const int NPOINTS=8, NFACES=6, NINDICES = NFACES*5;
int indices[NINDICES] = {3,2,1,0, SO_END_FACE_INDEX, //z back.
4,5,6,7, SO_END_FACE_INDEX, //z front.
0,1,5,4, SO_END_FACE_INDEX, //y up.
1,2,6,5, SO_END_FACE_INDEX, //x left.
2,3,7,6, SO_END_FACE_INDEX, //y down.
3,0,4,7, SO_END_FACE_INDEX}; //x right.
// points for the eight vertices
float points[NPOINTS][3];
points[0][0] = fDx1.getValue();
points[0][1] = fDy1.getValue();
points[0][2] = -fDz.getValue();
points[1][0] = -fDx1.getValue();
points[1][1] = fDy1.getValue();
points[1][2] = -fDz.getValue();
points[2][0] = -fDx1.getValue();
points[2][1] = -fDy1.getValue();
points[2][2] = -fDz.getValue();
points[3][0] = fDx1.getValue();
points[3][1] = -fDy1.getValue();
points[3][2] = -fDz.getValue();
points[4][0] = fDx2.getValue();
points[4][1] = fDy2.getValue();
points[4][2] = fDz.getValue();
points[5][0] = -fDx2.getValue();
points[5][1] = fDy2.getValue();
points[5][2] = fDz.getValue();
points[6][0] = -fDx2.getValue();
points[6][1] = -fDy2.getValue();
points[6][2] = fDz.getValue();
points[7][0] = fDx2.getValue();
points[7][1] = -fDy2.getValue();
points[7][2] = fDz.getValue();
float t1 = FATAN((fDx2.getValue()-fDx1.getValue())/(2*fDz.getValue()));
float t2 = FATAN((fDy2.getValue()-fDy1.getValue())/(2*fDz.getValue()));
float st1 = FSIN(t1);
float st2 = FSIN(t2);
float ct1 = FCOS(t1);
float ct2 = FCOS(t2);
float normals[NFACES][3];
//z back.
normals[0][0] = 0 ; normals[0][1] = 0; normals [0][2] = -1;
//z front.
normals[1][0] = 0 ; normals[1][1] = 0; normals [1][2] = 1;
//y up.
normals[2][0] = 0 ; normals[2][1] = ct2; normals [2][2] = -st2;
//x left.
normals[3][0] = -ct1; normals[3][1] = 0; normals [3][2] = -st1;
//y down.
normals[4][0] = 0 ; normals[4][1] = -ct2; normals [4][2] = -st2;
//x right.
normals[5][0] = ct1; normals[5][1] = 0; normals [5][2] = -st1;
float x,y,z;
int index;
for (int nf=0;nf<NFACES;nf++) {
beginShape(action,TRIANGLE_FAN);
index = indices[nf * 5];
x = points[index][0];
y = points[index][1];
z = points[index][2];
GEN_VERTEX(pv,x,y,z,0.0,0.0,normals[nf][0],normals[nf][1],normals[nf][2]);
index = indices[nf * 5 + 1];
x = points[index][0];
y = points[index][1];
z = points[index][2];
GEN_VERTEX(pv,x,y,z,0.0,0.0,normals[nf][0],normals[nf][1],normals[nf][2]);
index = indices[nf * 5 + 2];
x = points[index][0];
y = points[index][1];
z = points[index][2];
GEN_VERTEX(pv,x,y,z,0.0,0.0,normals[nf][0],normals[nf][1],normals[nf][2]);
index = indices[nf * 5 + 3];
x = points[index][0];
y = points[index][1];
z = points[index][2];
GEN_VERTEX(pv,x,y,z,0.0,0.0,normals[nf][0],normals[nf][1],normals[nf][2]);
endShape();
}
}
// getChildren
SoChildList *SoTrd::getChildren() const {
return children;
}
// computeBBox
void SoTrd::computeBBox(SoAction *, SbBox3f &box, SbVec3f &center ){
float fDx= fDx1.getValue(),fDy=fDy1.getValue();
if (fDx2.getValue() > fDx) fDx = fDx2.getValue();
if (fDy2.getValue() > fDy) fDy = fDy2.getValue();
SbVec3f vmin(-fDx,-fDy,-fDz.getValue()),
vmax( fDx, fDy, fDz.getValue());
center.setValue(0,0,0);
box.setBounds(vmin,vmax);
}
// updateChildren
void SoTrd::updateChildren() {
// Redraw the G4Trd....
assert(children->getLength()==1);
SoSeparator *sep = (SoSeparator *) ( *children)[0];
SoCoordinate3 *theCoordinates = (SoCoordinate3 *) ( sep->getChild(0));
SoNormal *theNormals = (SoNormal *) ( sep->getChild(1));
SoNormalBinding *theNormalBinding = (SoNormalBinding *) ( sep->getChild(2));
SoIndexedFaceSet *theFaceSet = (SoIndexedFaceSet *) ( sep->getChild(3));
const int NPOINTS=8, NFACES=6, NINDICES = NFACES*5;
float points[NPOINTS][3];
float normals[NFACES][3]= {{0,0,-1}, {0,0,1}, {0,1,0}, {-1, 0, 0}, {0, -1, 0}, {1,0,0}};
// Indices for the eight faces
#ifdef INVENTOR2_0
static long
#else
static int32_t
#endif
indices[NINDICES] = {3,2,1,0, SO_END_FACE_INDEX, // bottom
4,5,6,7, SO_END_FACE_INDEX, // top
0,1,5,4, SO_END_FACE_INDEX,
1,2,6,5, SO_END_FACE_INDEX,
2,3,7,6, SO_END_FACE_INDEX,
3,0,4,7, SO_END_FACE_INDEX};
// points for the eight vertices
points[0][0] = fDx1.getValue(); points[0][1] = fDy1.getValue(); points[0][2] = -fDz.getValue();
points[1][0] = -fDx1.getValue(); points[1][1] = fDy1.getValue(); points[1][2] = -fDz.getValue();
points[2][0] = -fDx1.getValue(); points[2][1] = -fDy1.getValue(); points[2][2] = -fDz.getValue();
points[3][0] = fDx1.getValue(); points[3][1] = -fDy1.getValue(); points[3][2] = -fDz.getValue();
points[4][0] = fDx2.getValue(); points[4][1] = fDy2.getValue(); points[4][2] = fDz.getValue();
points[5][0] = -fDx2.getValue(); points[5][1] = fDy2.getValue(); points[5][2] = fDz.getValue();
points[6][0] = -fDx2.getValue(); points[6][1] = -fDy2.getValue(); points[6][2] = fDz.getValue();
points[7][0] = fDx2.getValue(); points[7][1] = -fDy2.getValue(); points[7][2] = fDz.getValue();
float t1 = FATAN((fDx2.getValue()-fDx1.getValue())/(2*fDz.getValue()));
float t2 = FATAN((fDy2.getValue()-fDy1.getValue())/(2*fDz.getValue()));
float st1 = FSIN(t1);
float st2 = FSIN(t2);
float ct1 = FCOS(t1);
float ct2 = FCOS(t2);
normals[0][0] = 0 ; normals[0][1] = 0; normals [0][2] = -1;
normals[1][0] = 0 ; normals[1][1] = 0; normals [1][2] = 1;
normals[2][0] = 0 ; normals[2][1] = ct2; normals [2][2] = -st2;
normals[3][0] = -ct1; normals[3][1] = 0; normals [3][2] = -st1;
normals[4][0] = 0 ; normals[4][1] = -ct2; normals [4][2] = -st2;
normals[5][0] = ct1; normals[5][1] = 0; normals [5][2] = -st1;
for (int np=0;np<NPOINTS;np++) theCoordinates->point.set1Value(np,points[np][0],points[np][1],points[np][2]);
theFaceSet->coordIndex.setValues(0,NINDICES,indices);
for (int nf=0;nf<NFACES;nf++) theNormals->vector.set1Value(nf,normals[nf][0],normals[nf][1],normals[nf][2]);
theNormalBinding->value=SoNormalBinding::PER_FACE;
}
// generateChildren
void SoTrd::generateChildren() {
// This routines creates one SoSeparator, one SoCoordinate3, and
// one SoLineSet, and puts it in the child list. This is done only
// once, whereas redrawing the position of the coordinates occurs each
// time an update is necessary, in the updateChildren routine.
assert(children->getLength() ==0);
SoSeparator *sep = new SoSeparator();
SoCoordinate3 *theCoordinates = new SoCoordinate3();
SoNormal *theNormals = new SoNormal();
SoNormalBinding *theNormalBinding = new SoNormalBinding();
SoIndexedFaceSet *theFaceSet = new SoIndexedFaceSet();
//
// This line costs some in render quality! but gives speed.
//
sep->addChild(theCoordinates);
sep->addChild(theNormals);
sep->addChild(theNormalBinding);
sep->addChild(theFaceSet);
children->append(sep);
}
// generateAlternateRep
void SoTrd::generateAlternateRep() {
// This routine sets the alternate representation to the child
// list of this mode.
if (children->getLength() == 0) generateChildren();
updateChildren();
alternateRep.setValue((SoSeparator *) ( *children)[0]);
}
// clearAlternateRep
void SoTrd::clearAlternateRep() {
alternateRep.setValue(NULL);
}
@@ -0,0 +1,462 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: SoTubs.cc,v 1.2 2004/06/14 09:27:41 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
/*-----------------------------Hepvis---------------------------------------*/
/* */
/* Node: SoTubs */
/* Description: Represents the G4Tubs Geant Geometry entity */
/* Author: Joe Boudreau Nov 11 1996 */
/* */
/*--------------------------------------------------------------------------*/
#include <assert.h>
#include <math.h>
#include <Inventor/SbBox.h>
#include <Inventor/actions/SoGLRenderAction.h>
#include <Inventor/fields/SoSFFloat.h>
#include <Inventor/misc/SoChildList.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoIndexedFaceSet.h>
#include <Inventor/nodes/SoNormal.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoNormalBinding.h>
#include <Inventor/SoPrimitiveVertex.h>
#include <Inventor/elements/SoTextureCoordinateElement.h>
#include "HEPVis/SbMath.h"
#include "HEPVis/nodes/SoTubs.h"
// This statement is required
SO_NODE_SOURCE(SoTubs)
// Constructor
SoTubs::SoTubs() {
// This statement is required
SO_NODE_CONSTRUCTOR(SoTubs);
// Data fields are initialized like this:
SO_NODE_ADD_FIELD(pRMin, (0));
SO_NODE_ADD_FIELD(pRMax, (1));
SO_NODE_ADD_FIELD(pDz, (10));
SO_NODE_ADD_FIELD(pSPhi, (0));
SO_NODE_ADD_FIELD(pDPhi, ((float)(2*M_PI)));
SO_NODE_ADD_FIELD(alternateRep, (NULL));
children = new SoChildList(this);
}
// Destructor
SoTubs::~SoTubs() {
delete children;
}
// initClass
void SoTubs::initClass(){
// This statement is required.
SO_NODE_INIT_CLASS(SoTubs,SoShape,"Shape");
}
// generatePrimitives
void SoTubs::generatePrimitives(SoAction *action) {
// This variable is used to store each vertex
SoPrimitiveVertex pv;
// Access the stat from the action
SoState *state = action->getState();
// See if we have to use a texture coordinate function,
// rather than generating explicit texture coordinates.
SbBool useTexFunction=
(SoTextureCoordinateElement::getType(state) ==
SoTextureCoordinateElement::FUNCTION);
// If we need to generate texture coordinates with a function,
// we'll need an SoGLTextureCoordinateElement. Otherwise, we'll
// set up the coordinates directly.
const SoTextureCoordinateElement* tce = NULL;
SbVec4f texCoord;
if (useTexFunction) {
tce = SoTextureCoordinateElement::getInstance(state);
}
else {
texCoord[2] = 0.0;
texCoord[3] = 1.0;
}
SbVec3f point, normal;
///////////////////////////////////////////////////////
//-----------------------------------------------------
#define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
point.setValue((float)(x),(float)(y),(float)(z)); \
normal.setValue((float)(nx),(float)(ny),(float)(nz)); \
if (useTexFunction) { \
texCoord=tce->get(point,normal); \
} else { \
texCoord[0]=(float)(s); \
texCoord[1]=(float)(t); \
} \
pv.setPoint(point); \
pv.setNormal(normal); \
pv.setTextureCoords(texCoord); \
shapeVertex(&pv);
//-----------------------------------------------------
///////////////////////////////////////////////////////
int NPHI = (int)(2+22*fabs(pDPhi.getValue()/(2.0*M_PI)));
double deltaPhi = pDPhi.getValue()/NPHI, phi0 = pSPhi.getValue(),phi1=phi0+pDPhi.getValue();
double rMax=pRMax.getValue(),rMin=pRMin.getValue();
double zMax=pDz.getValue(),zMin=-zMax;
double cosPhi0=cos(phi0), sinPhi0=sin(phi0);
double cosPhi1=cos(phi1), sinPhi1=sin(phi1);
double cosDeltaPhi=cos(deltaPhi),sinDeltaPhi=sin(deltaPhi);
//
// The outer surface!
//
int i;
double sinPhi,cosPhi;
beginShape(action,TRIANGLE_STRIP);
sinPhi=sinPhi0;
cosPhi=cosPhi0;
for (i = 0; i<=NPHI; i++) {
GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMax,0.0,0.0,cosPhi,sinPhi,0);
GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,cosPhi,sinPhi,0);
inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
}
endShape();
//
// The inner surface!
//
if(rMin!=0.F) {
beginShape(action,TRIANGLE_STRIP);
sinPhi=sinPhi0;
cosPhi=cosPhi0;
for (i = 0; i<=NPHI; i++) {
GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMax,0.0,0.0,-cosPhi,-sinPhi,0);
GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMin,1.0,1.0,-cosPhi,-sinPhi,0);
inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
}
endShape();
}
if (fabs(deltaPhi)<2.0*M_PI) {
//
// The end
//
beginShape(action,TRIANGLE_STRIP);
sinPhi=sinPhi0;
cosPhi=cosPhi0;
GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMax,0.0,0.0,sinPhi,-cosPhi,0);
GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,sinPhi,-cosPhi,0);
GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMax,1.0,0.0,sinPhi,-cosPhi,0);
GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMin,0.0,1.0,sinPhi,-cosPhi,0);
endShape();
//
// The other end
//
beginShape(action,TRIANGLE_STRIP);
sinPhi=sinPhi1;
cosPhi=cosPhi1;
GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi, zMax,0.0,0.0,-sinPhi,+cosPhi,0);
GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi, zMin,1.0,1.0,-sinPhi,+cosPhi,0);
GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi, zMax,1.0,0.0,-sinPhi,+cosPhi,0);
GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi, zMin,0.0,1.0,-sinPhi,+cosPhi,0);
endShape();
}
//
// The outer surface at z=+PDZ
//
if(rMin==0.F) {
beginShape(action,TRIANGLE_FAN);
sinPhi=sinPhi0;
cosPhi=cosPhi0;
GEN_VERTEX(pv,0,0,zMax,0.0,0.0,0,0,1);
for (i = 0; i<=NPHI; i++) {
GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMax,1.0,1.0,0,0,1);
inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
}
endShape();
//
// The outer surface at z=-PDZ
//
beginShape(action,TRIANGLE_FAN);
sinPhi=sinPhi0;
cosPhi=cosPhi0;
GEN_VERTEX(pv,0,0,zMin,0.0,0.0,0,0,-1);
for (i = 0; i<=NPHI; i++) {
GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,0,0,-1);
inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
}
endShape();
} else {
beginShape(action,TRIANGLE_STRIP);
sinPhi=sinPhi0;
cosPhi=cosPhi0;
for (i = 0; i<=NPHI; i++) {
GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMax,0.0,0.0,0,0,1);
GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMax,1.0,1.0,0,0,1);
inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
}
endShape();
//
// The outer surface at z=-PDZ
//
beginShape(action,TRIANGLE_STRIP);
sinPhi=sinPhi0;
cosPhi=cosPhi0;
for (i = 0; i<=NPHI; i++) {
GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMin,0.0,0.0,0,0,-1);
GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,0,0,-1);
inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
}
endShape();
}
}
// getChildren
SoChildList *SoTubs::getChildren() const {
return children;
}
// computeBBox
void SoTubs::computeBBox(SoAction *, SbBox3f &box, SbVec3f &center ){
SbVec3f vmin(-pRMax.getValue(),-pRMax.getValue(),-pDz.getValue()),
vmax( pRMax.getValue(), pRMax.getValue(), pDz.getValue());
center.setValue(0,0,0);
box.setBounds(vmin,vmax);
}
// updateChildren
void SoTubs::updateChildren() {
// Redraw the G4Tubs....
assert(children->getLength()==1);
SoSeparator *sep = (SoSeparator *) ( *children)[0];
SoCoordinate3 *theCoordinates = (SoCoordinate3 *) ( sep->getChild(0));
SoNormal *theNormals = (SoNormal *) ( sep->getChild(1));
SoNormalBinding *theNormalBinding = (SoNormalBinding *) ( sep->getChild(2));
SoIndexedFaceSet *theFaceSet = (SoIndexedFaceSet *) ( sep->getChild(3));
const int NPHI=24, NPOINTS=2*(2*NPHI+2), NFACES=4*NPHI+2, NINDICES = NFACES*5;
float points[NPOINTS][3],normals[NFACES][3];
#ifdef INVENTOR2_0
static long indices[NINDICES];
#else
static int32_t indices[NINDICES];
#endif
static int init=0;
double phi, pp, DeltaPhi;
// Indices need to be generated once! This is here to keep it close to the point
// generation, since otherwise it will be confusing.
int i;
if (!init) {
init = 1;
// Outer face
for (i = 0; i< NPHI; i++) {
// 0 1 3 2;
indices[5*i+0] = 2*i+0;
indices[5*i+1] = 2*i+1;
indices[5*i+2] = 2*i+3;
indices[5*i+3] = 2*i+2;
indices[5*i+4] = SO_END_FACE_INDEX;
}
// the inner face
for (i=0;i<NPHI;i++) {
indices[5*1*NPHI + 5*i+0] = 2*NPHI+2 + 2*i+0;
indices[5*1*NPHI + 5*i+1] = 2*NPHI+2 + 2*i+1;
indices[5*1*NPHI + 5*i+2] = 2*NPHI+2 + 2*i+3;
indices[5*1*NPHI + 5*i+3] = 2*NPHI+2 + 2*i+2;
indices[5*1*NPHI + 5*i+4] = SO_END_FACE_INDEX;
}
// the top side
for (i=0;i<NPHI;i++) {
indices[5*2*NPHI + 5*i+0] = 2*i+0;
indices[5*2*NPHI + 5*i+1] = 2*i+2;
indices[5*2*NPHI + 5*i+2] = NPOINTS - (2*i+4);
indices[5*2*NPHI + 5*i+3] = NPOINTS - (2*i+2);
indices[5*2*NPHI + 5*i+4] = SO_END_FACE_INDEX;
}
// the bottom side
for (i=0;i<NPHI;i++) {
indices[5*3*NPHI + 5*i+0] = 2*i+1;
indices[5*3*NPHI + 5*i+1] = NPOINTS - (2*i+1);
indices[5*3*NPHI + 5*i+2] = NPOINTS - (2*i+3);
indices[5*3*NPHI + 5*i+3] = 2*i+3;
indices[5*3*NPHI + 5*i+4] = SO_END_FACE_INDEX;
}
// the odd side
indices[5*4*NPHI +0] = 2*NPHI;
indices[5*4*NPHI +1] = 2*NPHI+1;
indices[5*4*NPHI +2] = 2*NPHI+3;
indices[5*4*NPHI +3] = 2*NPHI+2;
indices[5*4*NPHI +4] = SO_END_FACE_INDEX;
// aother odd side
indices[5*4*NPHI +5 +0] = 0;
indices[5*4*NPHI +5 +1] = NPOINTS-2;
indices[5*4*NPHI +5 +2] = NPOINTS-1;
indices[5*4*NPHI +5 +3] = 1;
indices[5*4*NPHI +5 +4] = SO_END_FACE_INDEX;
}
// Points need to be generated each time:
if (pDPhi.getValue()<2*M_PI) {
// the odd side
indices[5*4*NPHI +0] = 2*NPHI;
indices[5*4*NPHI +1] = 2*NPHI+1;
indices[5*4*NPHI +2] = 2*NPHI+3;
indices[5*4*NPHI +3] = 2*NPHI+2;
indices[5*4*NPHI +4] = SO_END_FACE_INDEX;
// aother odd side
indices[5*4*NPHI +5 +0] = 0;
indices[5*4*NPHI +5 +1] = NPOINTS-2;
indices[5*4*NPHI +5 +2] = NPOINTS-1;
indices[5*4*NPHI +5 +3] = 1;
indices[5*4*NPHI +5 +4] = SO_END_FACE_INDEX;
}
else {
// the odd side
indices[5*4*NPHI +0] = SO_END_FACE_INDEX;
indices[5*4*NPHI +1] = SO_END_FACE_INDEX;
indices[5*4*NPHI +2] = SO_END_FACE_INDEX;
indices[5*4*NPHI +3] = SO_END_FACE_INDEX;
indices[5*4*NPHI +4] = SO_END_FACE_INDEX;
// aother odd side
indices[5*4*NPHI +5 +0] = SO_END_FACE_INDEX;
indices[5*4*NPHI +5 +1] = SO_END_FACE_INDEX;
indices[5*4*NPHI +5 +2] = SO_END_FACE_INDEX;
indices[5*4*NPHI +5 +3] = SO_END_FACE_INDEX;
indices[5*4*NPHI +5 +4] = SO_END_FACE_INDEX;
}
// The outer surface
DeltaPhi = pDPhi.getValue()/NPHI, phi = pSPhi.getValue();
for (i = 0; i<=NPHI; i++) {
points[2*i+0][0] = pRMax.getValue()*FCOS(phi);
points[2*i+0][1]= pRMax.getValue()*FSIN(phi);
points[2*i+0][2] = +pDz.getValue();
points[2*i+1][0] = pRMax.getValue()*FCOS(phi);
points[2*i+1][1]= pRMax.getValue()*FSIN(phi);
points[2*i+1][2] = -pDz.getValue();
pp = phi+DeltaPhi/2.0;
if (i!=NPHI) {
normals[i][0] = FCOS(pp);
normals[i][1] = FSIN(pp);
normals[i][2] = 0;
}
phi+=DeltaPhi;
}
// The inner surface
phi = pSPhi.getValue() + pDPhi.getValue();
for (i = 0; i<=NPHI; i++) {
points[2*NPHI+2+2*i+0][0] = pRMin.getValue()*FCOS(phi);
points[2*NPHI+2+2*i+0][1] = pRMin.getValue()*FSIN(phi);
points[2*NPHI+2+2*i+0][2] = +pDz.getValue();
points[2*NPHI+2+2*i+1][0] = pRMin.getValue()*FCOS(phi);
points[2*NPHI+2+2*i+1][1] = pRMin.getValue()*FSIN(phi);
points[2*NPHI+2+2*i+1][2] = -pDz.getValue();
pp = phi-DeltaPhi/2.0;
if (i!=NPHI) {
normals[NPHI+i][0] = -FCOS(pp);
normals[NPHI+i][1] = -FSIN(pp);
normals[NPHI+i][2] = 0;
}
phi-=DeltaPhi;
}
// The top side
for (i=0;i<NPHI;i++) {
normals[2*NPHI+i][0]=normals[2*NPHI+i][1]=0;
normals[2*NPHI+i][2]= 1.0;
}
// The bottom side
for (i=0;i<NPHI;i++) {
normals[3*NPHI+i][0]=normals[3*NPHI+i][1]=0;
normals[3*NPHI+i][2]= -1.0;
}
// The odd side
phi = pSPhi.getValue();
normals[4*NPHI+0][0]= FSIN(phi);
normals[4*NPHI+0][1]= -FCOS(phi);
normals[4*NPHI+0][2]=0;
// Another odd side
phi = pSPhi.getValue()+pDPhi.getValue();
normals[4*NPHI+1][0]= -FSIN(phi);
normals[4*NPHI+1][1]= +FCOS(phi);
normals[4*NPHI+1][2]=0;
for (int np=0;np<NPOINTS; np++) theCoordinates->point.set1Value(np,points[np][0],points[np][1],points[np][2]);
for (int ni=0;ni<NINDICES;ni++) theFaceSet->coordIndex.set1Value(ni,indices[ni]);
for (int nf=0;nf<NFACES;nf++) theNormals->vector.set1Value(nf,normals[nf][0],normals[nf][1],normals[nf][2]);
theNormalBinding->value=SoNormalBinding::PER_FACE;
}
// generateChildren
void SoTubs::generateChildren() {
// This routines creates one SoSeparator, one SoCoordinate3, and
// one SoLineSet, and puts it in the child list. This is done only
// once, whereas redrawing the position of the coordinates occurs each
// time an update is necessary, in the updateChildren routine.
assert(children->getLength() ==0);
SoSeparator *sep = new SoSeparator();
SoCoordinate3 *theCoordinates = new SoCoordinate3();
SoNormal *theNormals = new SoNormal();
SoNormalBinding *theNormalBinding = new SoNormalBinding();
SoIndexedFaceSet *theFaceSet = new SoIndexedFaceSet();
//
// This line costs some in render quality! but gives speed.
//
sep->addChild(theCoordinates);
sep->addChild(theNormals);
sep->addChild(theNormalBinding);
sep->addChild(theFaceSet);
children->append(sep);
}
// generateAlternateRep
void SoTubs::generateAlternateRep() {
// This routine sets the alternate representation to the child
// list of this mode.
if (children->getLength() == 0) generateChildren();
updateChildren();
alternateRep.setValue((SoSeparator *) ( *children)[0]);
}
// clearAlternateRep
void SoTubs::clearAlternateRep() {
alternateRep.setValue(NULL);
}
+10 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.7 2003/11/12 22:46:00 duns Exp $
# $Id: GNUmakefile,v 1.9 2004/06/11 14:30:49 gcosmo Exp $
name := G4RayTracer
@@ -6,10 +6,19 @@ ifndef G4INSTALL
G4INSTALL = ../../..
endif
GLOBLIBS = libG4vis_management.lib libG4modeling.lib
GLOBLIBS += libG4run.lib libG4event.lib
GLOBLIBS += libG4tracking.lib libG4processes.lib libG4digits_hits.lib
GLOBLIBS += libG4track.lib libG4particles.lib libG4geometry.lib
GLOBLIBS += libG4materials.lib libG4graphics_reps.lib
GLOBLIBS += libG4intercoms.lib libG4global.lib
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/G4VIS_BUILD.gmk
include $(G4INSTALL)/config/interactivity.gmk
CPPFLAGS += -DG4VIS_ALLOC_EXPORT
CPPFLAGS += -I$(G4BASE)/visualization/modeling/include
CPPFLAGS += -I$(G4BASE)/visualization/management/include
CPPFLAGS += -I$(G4BASE)/graphics_reps/include
+5 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.24 2003/11/12 22:46:00 duns Exp $
$Id: History,v 1.25 2004/06/11 15:23:39 gcosmo Exp $
-------------------------------------------------------------------
=========================================================
@@ -24,6 +24,10 @@ committal in the CVS repository !
History file for visualization category
---------------------------------------
11th June 2004 Gabriele Cosmo (raytracer-V06-01-00)
- Use global flag G4VIS_ALLOC_EXPORT to export extern symbols for DLLs.
Modified GNUmakefile and rearranged usage of extern symbols in classes.
12th November 2003 Mark Donszelmann
- GNUmakefile: added Modeling/include directory to compile on Windows.
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4RayTrajectory.hh,v 1.11 2003/06/16 17:13:42 gunter Exp $
// GEANT4 tag $Name: geant4-05-02-patch-01 $
// $Id: G4RayTrajectory.hh,v 1.14 2004/06/11 14:30:49 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
@@ -87,8 +87,11 @@ class G4RayTrajectory : public G4VTrajectory
std::vector<G4RayTrajectoryPoint*>* positionRecord;
};
extern G4Allocator<G4RayTrajectory> G4RayTrajectoryAllocator;
#if defined G4VIS_ALLOC_EXPORT
extern G4DLLEXPORT G4Allocator<G4RayTrajectory> G4RayTrajectoryAllocator;
#else
extern G4DLLIMPORT G4Allocator<G4RayTrajectory> G4RayTrajectoryAllocator;
#endif
inline void* G4RayTrajectory::operator new(size_t)
{

Some files were not shown because too many files have changed in this diff Show More