Import Geant4 11.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2025-12-05 08:54:02 +01:00
parent a499fb82e9
commit b4a16de652
6484 changed files with 232674 additions and 221097 deletions
-6
View File
@@ -1,6 +1,5 @@
# - Builds for always-on vis libraries
add_subdirectory(FukuiRenderer)
add_subdirectory(HepRep)
add_subdirectory(RayTracer)
add_subdirectory(Tree)
add_subdirectory(VRML)
@@ -19,11 +18,6 @@ if(GEANT4_USE_INVENTOR)
add_subdirectory(OpenInventor)
endif()
# Qt3D is available if Qt is used and > 5.15
if(GEANT4_USE_QT3D)
add_subdirectory(Qt3D)
endif()
# VTK is optional depending on user selection
if(GEANT4_USE_VTK)
add_subdirectory(Vtk)
@@ -1,3 +0,0 @@
# - G4visHepRep category build
include(sources.cmake)
geant4_add_category(G4visHepRep MODULES G4visHepRep)
-594
View File
@@ -1,594 +0,0 @@
# Category vis-HepRep History
See `CONTRIBUTING.rst` for details of **required** info/format for each entry,
which **must** added in reverse chronological order (newest at the top). It must **not**
be used as a substitute for writing good git commit messages!
## 2023-02-06 Ben Morgan (vis-HepRep-V11-01-00)
- Isolate private headers and update dependencies
## 2022-09-03 Ben Morgan (vis-HepRep-V11-00-02)
- Make dependencies consistent.
## 2022-01-28 Ben Morgan (vis-HepRep-V11-00-01)
- Replace `geant4_global_library_target` with direct file inclusion and
call to `geant4_add_category` to define library build from source modules.
## 2021-12-10 Ben Morgan (vis-HepRep-V11-00-00)
- Change to new Markdown History format
---
# History entries prior to 11.0
27 August 2021 Ben Morgan (vis-HepRep-V10-07-04)
- Remove obsolete HepRep(WIRED) driver and associated files
30 June 2021 John Allison (vis-HepRep-V10-07-03)
- Requires greps-V10-07-09, modeling-V10-07-11 and visman-V10-07-11.
- Revise vis models. See visualization/modeling/History for more details.
- Consequent changes:
o AddPrimitive(const G4Scale&) has been removed from all scene handlers.
29 June 2021 Gabriele Cosmo (vis-HepRep-V10-07-02)
- Fixed compilation error in G4HepRepSceneHandler when c++20 is enabled.
07 June 2021 John Allison (vis-HepRep-V10-07-01)
- Fix hidden function warning.
14 April 2021 Ben Morgan (vis-HepRep-V10-07-00)
- Migrate to modular CMake build
12 December Ben Morgan (vis-HepRep-V10-06-00)
- Cleanup CMake build, removing obsolete granular library option and
explicit include_directories.
29 August 2019 John Allison (vis-HepRep-V10-05-00)
- Part of vis-V10-05-24.
- Add G4TessellatedSolid to list of solids that may be specially treated
14th September 2017 John Allison (vis-HepRep-V10-03-01)
- G4HepRepMessenger.cc: Fix Coverity warning.
23rd May 2017 John Allison (vis-HepRep-V10-03-00)
- Fixes for gcc-7.1 warnings.
18th November 2016 John Allison (vis-HepRep-V10-02-04)
- Fixed the GetColour() problem.
17th November 2016 Joseph Perl (vis-HepRep-V10-02-03)
- G4HepRepFileSceneHandler.cc: restore color to trajectories.
7th November 2016 John Allison (vis-HepRep-V10-02-02)
- G4HepRepFileSceneHandler.cc:1504: Fixed Coverity warning.
11th September 2016 John Allison (vis-HepRep-V10-02-01)
- GetColour/GetColor no longer takes an argument.
- Make sure applicable vis attributes are obtained.
// Get and check applicable vis attributes.
// fpVisAttribs = fpViewer->GetApplicableVisAttributes(fpVisAttribs);
// Note: the vis attributes may have been modified by the viewer. See
// code in G4VViewer::GetApplicableVisAttributes.
31st August 2016 John Allison (vis-HepRep-V10-02-00)
- Fix G4Orb and G4Ellipsoid hiding warnings.
25th November 2015 Laurent Garnier (vis-HepRep-V10-01-02)
- Fix a warning on int64 on VC15
19th November 2015 Laurent Garnier (vis-HepRep-V10-01-01)
- Fix a warning on int64 on VC15
2nd February 2015 Gabriele Cosmo (vis-HepRep-V10-01-00)
- Fix to sources.cmake script to include missing dependency on external library.
9th December 2013 John Allison (vis-HepRep-V10-00-00)
- G4HepRep.cc, G4HepRepFile.cc: Declared as G4VGraphicsSystem::fileWriter.
16th June 2013 John Allison (vis-HepRep-V09-06-06)
o G4HepRepSceneHandler.cc: Added an assert to keep Coverity happy.
26th March 2013 Ben Morgan (vis-HepRep-V09-06-05)
- sources.cmake:
o BUGFIX #1322 : Update include paths/library linking to use new
ZLIB variables allowing transparent use of internal/external ZLIB
as required.
- G4HepRepSceneHandler:
o BUGFIX #1322 : Remove #ifndef block on G4LIB_USE_ZLIB as we now
always have zlib available.
24th February 2013 John Allison (vis-HepRep-V09-06-04)
- G4HepRepMessenger, G4HepRepSceneHandler:
o Removed unused fields as warned by new clang compiler.
29th January 2013 John Allison (vis-HepRep-V09-06-03)
- More Coverity fixes and un-doing of some previous ones.
12th and 13th January 2013 John Allison (vis-HepRep-V09-06-02)
o Coverity fixes.
2nd December 2012 John Allison (vis-HepRep-V09-06-00)
- Remove NURBS.
8th August 2012 John Allison (vis-HepRep-V09-05-05 and 06)
- G4HepRepSceneHandler.cc: Intercepted 2D primitives.
5th July 2012 Gabriele Cosmo (vis-HepRep-V09-05-04)
- Explicitly use inclusion of headers for system of units and physical
constants, in plan to remove implicit inclusion from globals.hh.
10th June 2012 John Allison (vis-HepRep-V09-05-03)
- Fixed shadowing in the following files:
o include/cheprep/AbstractXMLWriter.h
o src/IndentPrintWriter.cc
o src/XMLWriter.cc
o src/DefaultHepRepAttDef.cc
o src/DefaultHepRepTreeID.cc
o src/ZipOutputStreamBuffer.cc
o src/DeflateOutputStreamBuffer.cc
o src/DefaultHepRepInstanceTree.cc
o src/DefaultHepRepAttValue.cc
o src/GZIPOutputStreamBuffer.cc
o src/DefaultHepRepPoint.cc
o src/BHepRepWriter.cc
o src/DefaultHepRepAction.cc
o src/G4HepRepSceneHandler.cc
8th June 2012 John Allison (vis-HepRep-V09-05-02)
- G4HepRepFileSceneHandler.cc: Shadow clean.
23rd May 2012 John Allison (vis-HepRep-V09-05-01)
- Health Check 2012: Migrated (see management/History):
o G4HepRepFileSceneHandler::ClearTransientStore:
. Removed call to G4VSceneHandler::ClearTransientStore.
28th February 2012 John Allison (vis-HepRep-V09-05-00)
- Migrated to G4VScenehandler::fObjectTransformation.
28th October 2011 Joseph Perl (vis-HepRep-V09-04-03)
- Add /vis/heprep/scale and /vis/heprep/center
13th October 2011 Andrea Dotti (vis-HepRep-V09-04-02)
- Solving "variable set but not used" warning in GCC 4.6
26th September 2011 John Allison (vis-HepRep-V09-04-01)
- Tagged.
17th September 2011 John Allison
- Migrated to new G4Exception.
25th March 2011 G.Cosmo (vis-HepRep-V09-04-00)
- Use G4RotationMatrix typedef instead of native CLHEP type in
G4HepRepFileSceneHandler.cc.
23th January 2011 L.Garnier
- GNUMakefile : Remove G4VIS_BUILD.gmk use
7th November 2010 Joseph Perl (vis-HepRep-V09-03-04)
- G4HepRepFileSceneHandler.hh: Fix coverity warning about uninitialized variables. Turns out they were unneeded.
20th June 2010 Joseph Perl (vis-HepRep-V09-03-03)
- G4HepRepMessenger: Correct default of new option renderCylAsPolygons
4th June 2010 Joseph Perl (vis-HepRep-V09-03-02)
- G4HepRepMessenger: Add command renderCylAsPolygons
- G4HepRepFileSceneHandler: Use new command
30th May 2010 John Allison (vis-HepRep-V09-03-00)
- G4HepRep[File}SceneHandler: Added AddCompound(const G4VDigi&).
22nd November 2009 Joseph Perl (vis-HepRep-V09-02-03)
- Changed messenger to a singleton.
- Added messenger commands to HepRepFile.
- Render G4Tubs as polygons if G4Tubs is not at a standard angle.
21st October 2009 John Allison (vis-HepRep-V09-02-02 coworks greps-V09-02-02)
- Added default AddCompound (const G4THitsMap<G4double>&) methods.
o Prevents warnings about hiding - calls G4VSceneHandler base class.
8 May 2009 Gabriele Cosmo (vis-HepRep-V09-02-00)
- Added inclusion of <cstdio> in DeflateOutputStreamBuffer.h to resolve
compilation errors reported by gcc-4.4.0.
4 January 2008 John Allison (vis-HepRep-V09-01-00)
- Adapted to new BeginPrimitives2D signature.
16 November 2007 Joseph Perl (vis-HepRep-V09-00-01)
- Adjust geometry hierarchy in G4HepRepFileSceneHandler to accomodate
parallel worlds. Where used to just have world at top of hierarchy,
now have world or worlds as one level below top level of geometry.
- Cleaned up G4HepRepSceneHandler (just removing inaccurate old comment).
22 May 2007 John Allison (vis-HepRep-V08-03-00)
- Fixed memory leak in G4HepRepFile.
16 November 2006 Joseph Perl (vis-HepRep-V08-01-04)
- Omit Pos and Aux attributes for hits.
- Protect against null Region (as in parallel geometries).
14 November 2006 Joseph Perl (vis-HepRep-V08-01-03)
- Improve handling of Trajectory Points.
13 November 2006 Joseph Perl (vis-HepRep-V08-01-02)
- Corrected handling of Hits that come via AddSolids.
5 November 2006 John Allison (vis-HepRep-V08-01-01)
- Protected against zero material pointer.
- Corrected material pointer - pick up from PVModel instead of logical volume
so that it is correct for parameterised volumes.
1 November 2006 John Allison (vis-HepRep-V08-01-00)
- G4HepRepFileSceneHandler.cc:
o Exploit G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::GetNonCulledDepth().
(Saves some lines of code.)
4 June 2006 Joseph Perl (vis-HepRep-V08-00-04)
- G4HepRepFileSceneHandler: Bring trajectory points under control of filtering.
- G4HepRepFileSceneHandler: Correct direction of G4Cons and G4Tubs.
- G4HepRepFileSceneHandler: Use GetMarkerSize for marks and text.
- G4HepRepFileSceneHandler: Apply correct units for Density and Radlen.
- G4HepRepFileSceneHandler: Use BeginPrimitives2D and EndPrimitives2D to be able to cleanly
reject cases that don't apply to HepRep: 3D text and 2D lines and markers.
- G4HepRepFileSceneHandler: Improve handling for case of culled volumes.
2 June 2006 Joseph Perl (vis-HepRep-V08-00-03)
- G4HepRepFileSceneHandler: Support 2D Text.
- G4HepRepFileSceneHandler: Avoid creating Traj or Hit instances if they
have no primitives due to filtering.
- G4HepRepFileSceneHandler: Assign Hits to various HepRepTypes depending on
attribute HitType.
- G4HepRepFileSceneHandler: Support G4VisTrajContext.
- G4HepRepFileSceneHandler: Include G4Version attribute in HepRep file.
- G4HepRepFileSceneHandler: Handle Axes and other primitives that are neither
transients nor geometry.
- G4HepRepFileViewer: Call ShowView from destructor to assure file is
properly terminated.
22nd May 2006 John Allison (vis-HepRep-V08-00-02)
- Removed dependency on Run. (G4HepRepSceneHandler.cc: Version string
now obtained directly from G4Version.hh.)
4th May 2006 John Allison (vis-HepRep-V08-00-01)
- Improved protection for null models and parameters.
19 April 2006 John Allison (vis-HepRep-V08-00-00)
- G4HepRepSceneHandler and G4HepRepFileSceneHandler: Migrated to direct
access to G4PhysicalVolumeModel.
31 October 2005 Mark Donszelmann (vis-HepRep-V07-01-04)
- Further fix for GEANT-61.
13 October 2005 John Allison (vis-HepRep-V07-01-03)
- Migrated to <sstream>.
12 October 2005 Mark Donszelmann (vis-HepRep-V07-01-02)
- Fixed compilation warning on MacOSX
- Further fix for GEANT-61.
27 September 2005 Mark Donszelmann (vis-HepRep-V07-01-01)
- Fixed GEANT-61: Cones face wrong way.
4 August 2005 Mark Donszelmann (vis-HepRep-V07-01-00)
- Fixed GEANT-60: DrawAs value wrong for solids that use Geant4 primitives.
28 June 2005 Gabriele Cosmo (vis-HepRep-V07-00-04)
- Fixed GNUmakefile to include ZLIB module for DLLs build on Windows.
2 June 2005 Mark Donszelmann (vis-HepRep-V07-00-03)
- HepRepXML (heprep2) handles: Solids, Attributes on Hits and Tracks.
- cheprep at 2.0.5, fix for g++ 4.0.
1 June 2005 Joseph Perl
- For HeRepFile, use attributes from hits.
1 June 2005 Mark Donszelmann (vis-HepRep-V07-00-02)
- updated documentation.
31 May 2005 Joseph Perl
- For HeRepFile, use G4AttCheck to standardize attribute units.
30 May 2005 Joseph Perl
- For HeRepFile, respect Drawing Mode.
30 May 2005 Joseph Perl
- For HeRepFile, make trajectory color come from visible->GetColour.
28 May 2005 Joseph Perl
- For HeRepFile, implement G4HEPREPFILE_CULL.
28 May 2005 Joseph Perl
- For HeRepFile, correct heprep xmlns reference.
25 May 2005 Joseph Perl
- For HeRepFile, allow user to specify output directory, filename
and whether to overwrite.
25 May 2005 Mark Donszelmann (vis-HepRep-V07-00-01 against geant4-07-00-ref-03)
- optionally needs externals/zlib (vis-zlib-V07-00-00)
- HEPREP at version 2.0.1
- cheprep at version 2.0.4
- Added writing an EOF marker for each binary HepRep file.
- Added version files to the copied filesets from FreeHEP.
24 May 2005 Joseph Perl
- Improve handling of solids (in HepRepFile).
16 May 2005 Mark Donszelmann
- Fixed problems with sequential heprep files, gz files,
too much info in the heprep file and some compilation mistakes.
12 May 2005 Mark Donszelmann
- Renamed zconf.h, zlib.h and zutil.h back into their old names.
- Removed -DZ_PREFIX from the zlib compilation step.
- Added G4LIB_BUILD_ZLIB for building zlib and G4LIB_USE_ZLIB for using zlib.
- Removed all files belonging to zipios++ from include and src.
- Removed all files from the ref include directory.
- Moved zlib to the externals/zlib package.
- Added cheprep src and include files and changed GNUmakefile.
3 May 2005 Mark Donszelmann
- Removed the following zlib and zipios files which are not necessary for writing
zip or gz files: include/zipios++/basicentry.h, include/zipios++/collcoll.h,
include/zipios++/dircoll.h, include/zipios++/filepath.h,
include/zipios++/filterinputstreambuf.h, include/zipios++/inflateinputstreambuf.h,
include/zipios++/zipfile.h, include/zipios++/zipinputstream.h,
include/zipios++/zipinputstreambuf.h,
include/zlib/inffast.h, include/zlib/inffixed.h, include/zlib/inflate.h,
include/zlib/inftrees.h, src/basicentry.cc, src/collcoll.cc, src/filepath.cc,
src/filterinputstreambuf.cc, src/infback.cc, src/inffast.cc, src/inflate.cc,
src/inflateinputstreambuf.cc, src/inftrees.cc, src/uncompr.cc, src/zipfile.cc,
src/zipinputstream.cc, src/zipinputstreambuf.cc
16 February 2005 Mark Donszelmann (vis-HepRep-V07-00-00 against geant4-07-00-ref-00)
- Fix for g++ compiler 2.95.2 on Linux.
22 November 2004 Mark Donszelmann (vis-HepRep-V06-02-02 against geant4-06-02-ref)
- Upgraded to latest version C++ HepRep driver from FreeHEP.
- Fixed GEANT-51, upgrade zlib to version 1.2.2 (for AMD64 compatibility).
22 August 2004 Mark Donszelmann (vis-HepRep-V06-02-01)
- Fixed a compilation problem in zlib for AMD64, reported by Peter Niessen.
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.
1 March 2004 Mark Donszelmann (vis-HepRep-V06-00-05)
- Fixed compilation warnings for the Linux-icc (8.0) compiler.
18 February 2004 Mark Donszelmann
- Removed appendzip.cc file, since it is strictly not necessary.
12 Febryary 2004 Mark Donszelmann
- GEANT-42: Renamed the HepRep schema locator to
http://java.freehep.org/schemas/heprep/2.0
5 February 2004 Mark Donszelmann (vis-HepRep-V06-00-04)
- Fixed compilation problems for the Linux-icc (7.0) compiler.
3 February 2004 Mark Donszelmann (vis-HepRep-V06-00-03)
- Further fix to GEANT-40, renamed zutil.h, zlib.h and zconf.h
into HepRep-zutil.h, ... to avoid conflicts with those files
on Unix systems if /usr/include or /usr/local/include is
on the include search path.
28 January 2004 Mark Donszelmann (vis-HepRep-V06-00-01)
- Attempted to fix GEANT-40. For some unclear reason the symbols zcalloc and zcfree
of the zlib library were being called as C++ mangled names.
To get rid of the situation of a mix of C++ and C names, we took
out the 'extern "C"' declarations from our zlib.h and zutil.h.
All names are C++ mangled now.
11 December 2003 Mark Donszelmann
- Removed the HepRep2 driver from FreeHEP, so the HepRep2 sources now live
in this directory. Modified the copyfreehep scripts, and the READMEs.
Re-added the cvs expand keywords to show revision and tagname.
05 December 2003 Joseph Perl (vis-HepRep-V05-02-09)
- Fix bug with CalHits by moving faces to separate HepRepType
19 November 2003 Joseph Perl (vis-HepRep-V05-02-07)
- Set two additional attributes to get correct pick response within client,
PickParent and ShowParentAttributes.
Fixes GEANT-38
17 November 2003 Mark Donszelmann (vis-HepRep-V05-02-06)
- Removed dependency on sstream which made compilation fail on Linux-g++2.95.2
and on Solaris 5.2.
- Added flags for zipios++ to compile OutputStringStream using sstream only on
g++ 3.x (Linux/MacOS X) and on WIN32.
- Added include to OutputStringStream.h to make it work on Solaris.
- Removed our own sstream since it is no longer used.
- Fixed GEANT-34
14 November 2003 Mark Donszelmann
- Fixed GEANT-25, GEANT-35 and GEANT-36 (vis-HepRep-V05-02-05)
see http://bugs.freehep.org/secure/BrowseProject.jspa?id=10041
14 November 2003 Joseph Perl
- Fixed GEANT-30
14 November 2003 Mark Donszelmann and Joseph Perl (vis-HepRep-05-02-03)
- Fixed GEANT-32
13 November 2003 Mark Donszelmann
- Fixed GEANT-29, GEANT-33
12 November 2003 Joseph Perl
- Added G4HepRepFileSceneHandler::ClearTransientStore to make geometry
be properly included with each event of a /run/beamOn n.
12 November 2003 Mark Donszelmann
- Fixed GEANT-18, GEANT-19, GEANT-28
11 November 2003 Mark Donszelmann
- Fixed GEANT-23, GEANT-26, GEANT-27
10 November 2003 Mark Donszelmann
- Fixed GEANT-22, GEANT-24
6 November 2003 Mark Donszelmann
- Fixed GEANT-14, GEANT-20
5 November 2003 Mark Donszelmann
- Fixed GEANT-16
4 November 2003 Mark Donszelmann
- Fixed GEANT-15
30 October 2003 Mark Donszelmann
- Fixed GEANT-10, WIRED-170
28 October 2003 Mark Donszelmann
- Several fixes (GEANT-11, GEANT-12, GEANT-3 and GEANT-13)
24 October 2003 Mark Donszelmann
- Several fixes (GEANT-2, GEANT-4, GEANT-8 and GEANT-9)
22 October 2003 Mark Donszelmann
- Added latest HepRep2 driver.
12th July 2003 Mark Donszelmann
- Renamed XMLHepRepWriter to G4HepRepFileXMLWriter and moved its header to include.
Fixed initialization of some variabled in G4HepRep and G4HepRepSceneHandler, found
by valgrind. Removed dependency in gzio.cc of fdopen (platform specific).
11th July 2003 Mark Donszelmann
- Removed the HepRepStreamer and replaced it by a fully functional HepRep implementation
in C++. Added compression using ZLIB and ZIPIOS++. Moved private header files to
subdirectories of include so that they do not get copied by the "gmake includes"
command.
The current HepRep files are invalid, but we first need to get rid of some memory
leaks, using Linux, so we check this in.
30th May 2003 John Allison
- Eliminated pedantic warnings at head (johna-030530) and on
geant4-05-01-ref-02 (vis-V05-00-02).
29th May 2003 Mark Donszelmann and Joseph Perl (mark-joseph-050329)
- Modified G4HepRepSceneHandler (HEPREP2) to write more complete heprep, including
attributes.
- Copied new Streamer from FREEHEP library.
28th February 2003 Joseph Perl
- Modified G4HepRepFileSceneHandler to allow some volumes to be initially invisible.
24th January 2003 Joseph Perl
- Modified G4HepRepFileSceneHandler:AddThis (const G4VTrajectory& traj)
to incorporate G4Attributes into the HepRep1 file.
- Moved some of HepRepXMLWriter's warning messages into ifdef debug blocks.
11th December 2002 John Allison (vis-V04-01-10)
- Fixed default view parameters (global culling false).
9th December 2002 Mark Donszelmann
- Fixed bug that files were left open. Will close now, apart from stdin/stderr
- Fixed color call not to use array creation.
- Fixed HepRep standard (reader related), G4 is a writer.
- Fixed include file now to only include HepRep.h (which includes all others)
3rd December 2002 Mark Donszelmann
- Fixed bug that XML Output can be routed to stdout or stderr.
27th November 2002 Mark Donszelmann
- Fixed core dump (Solaris) if open HepRepXML and closed it w/o writing anything
27th November 2002 John Allison (vis-V04-01-08)
- Changed mickname of HepRep to HepRepXML.
- Fixed description of HepRepFile.
26th November 2002 Mark Donszelmann
- Fixed FillStyle, LineStyle, LineWidth, HasFrame and Symbol Names
- Fixed parent-child relationship for calorimeter hits
- Fixed material state number, now a string
- Fixed fillColor to be equal to color
25th November 2002 Mark Donszelmann
- Fixed HepRep1 warnings in HepRepFileSceneHandler
- Fixed HepRep2 radius of markers to be non-zero
- Fixed HepRep2 attributes some of which had wrong names, especially the markers
- Fixed HepRep2 filename to have sequence number
13th November 2002 Mark Donszelmann
- Added HepRep2 Driver
4th February 2002 Joseph Perl (vis-V04-00-01)
- Check for missing hierarchy layers in HepRepXMLWriter.
(Not strictly needed since have a culled layer check in SceneHandler,
but may be useful in other applications of HepRepXMLWriter).
3rd February 2002 Joseph Perl
- Detect transient data by testing for
!fpCurrentPV || fReadyForTransients
rather than just fReadyForTransients
1st February 2002 Joseph Perl
- Defer file opening until first real HepRepType is to be written.
- Moved HepRep code from AddThis to AddPrimitive.
- Add additional levels to hierarchy if any appear to have been
removed by culling.
- Add visibility attribute.
29th January 2002 Joseph Perl
- Relocate file-opening logic to constructor and ShowView
(had been in SetView).
28th January 2002 Joseph Perl
- Produce hierarchical output rather than flat HepRepType structure.
- Handle trajectories as well as detector geometry.
- Output files now named G4Data<n>.heprep where n increments with each open.
19th November 2001 John Allison (vis-V03-02-19)
- Added G4HEPREPFILEDEBUG to control debug code.
- Changed <fstream.h> to "g4std/fstream".
- Changed cout to G4cout, endl to G4endl.
- Changed G4HepRep.xml to G4HepRepFile.xml in hepRepXMLWriter->open("..."");
8th November 2001 Joseph Perl
- HepRep Type names now come from Physical Volume names.
- Added many HepRep Attributes for other volume properties.
6th November 2001 John Allison (HepRep-pure-C++-1st-version)
- Removed HepRep files G4HepRep.hh, G4HepRepSceneHandler.hh,
G4HepRepViewer.hh, G4HepRep.cc, G4HepRepSceneHandler.cc and
G4HepRepViewer.cc (recoverable with tag HepRep-Java-version).
- Added HepRepFile from version of 27th September 2001 Joseph Perl.
First pure C++ version (eliminates need for Java jni or freehep).
Named as HepRepFile rather than HepRep.
- GNUmakefile: removed CPPFLAGS += -DHEPREP and CPPFLAGS += -DDEBUG.
- README: completely re-written for HepRepFile.
6th November 2001 John Allison (HepRep-Java-version)
- Tagged before major revision.
4th September 2001 Joseph Perl
- minor improvements to README.
26th August 2001 Joseph Perl
- handle PolyHedron.getNoFacets()==0 and improve README.
24th August 2001 Joseph Perl (vis-V03-02-13-00)
- First version of HepRep Graphics Driver
-152
View File
@@ -1,152 +0,0 @@
This G4 Graphics Driver creates a HepRep File suitable for viewing
by the HepRApp, Wired4 or FRED Event Display clients.
It requires no external packages.
The HepRep graphics format is further described at
http://www.slac.stanford.edu/~perl/heprep/
Two different drivers are available for either HepRep1 or HepRep2.
Driver: HepRepFile
------------------
The version of HepRep produced by this driver is HepRep Version 1.
Writes files with file extension .heprep.
First file is written to current directory and is named G4Data0.heprep.
Subsequent files increment the number, as in G4Data1.heprep, G4Data2.heprep...
To specify a different output file directory (instead of current directory),
set G4HEPREPFILE_DIR
To specify a different output file name (instead of G4Data),
set G4HEPREPFILE_NAME
To repeatedly overwrite the same output file (instead of having incremental
numbers at the end of the file name),
set G4HEPREPFILE_OVERWRITE
By default, invisible objects are not culled but are left in the heprep file
with their visibility initially set to false (so that you can subsequently
choose to make them visible from within the heprep browser).
To force culling of invisible objects,
set G44HEPREPFILE_CULL
View the file using the HepRApp HepRep Browser, available from:
http://www.slac.stanford.edu/~perl/HepRApp
HepRApp can read xml files in zipped format as well as unzipped,
so you can save space by applying gzip to the xml file.
This will reduce the file to about five percent of its original size.
Joseph Perl
15 November 2007
Driver: HepRepXML
-----------------
The version of HepRep produced by this driver is HepRep Version 2.
This driver can write both Binary HepRep (.bheprep) and XML HepRep
(.heprep) files. Binary HepRep files are a one-to-one translation
of XML HepRep files, but they are considerably shorter and faster
to parse by a HepRepViewer such as WIRED 4.
You can view the files using the WIRED 4 Event Display, available from:
http://wired4.freehep.org
Both Binary HepRep and XML HepRep can be compressed using the standard
zlib library if linked into Geant4 using G4LIB_USE_ZLIB. If a standard
zlib is not available (WIN32-VC for instance) you should also set
G4LIB_BUILD_ZLIB to build G4zlib included with Geant4.
HepRep files (Binary and XML) can contain multiple HepRep events/geometries.
If the file contains more than one HepRep it is not strictly XML anymore.
Files can be written in .heprep.zip, .heprep.gz or .heprep format and their
binary versions .bheprep.zip, .bheprep.gz or .bheprep.
The .heprep.zip is the default for file output, the .heprep is the default
for stdout and stderr.
(Optional) To set the filename with a particular extension such as:
.heprep.zip, .heprep.gz, .heprep, .bheprep.zip, .bheprep.gz or .bheprep
use for instance:
/vis/scene/create filename.bheprep.zip
(Optional) To create separate files for each event, you can set a suffix such as
"-0001" to start writing files from filename-0001.bheprep.zip to
filename-9999.bheprep.zip (or up), while "-55-sub" will start write files
filename-55-sub.bheprep.zip to filename-99-sub.bheprep.zip (or up).
/vis/heprep/setEventNumberSuffix -0001
(Note: suffix has to contain at least one digit)
(Optional) To route the HepRep XML output to stdout (or stderr),
by default uncompressed, use:
/vis/scene/create stdout
To select the driver, where the file if not create by scene is set to
G4HepRepOutput.heprep.zip, use:
/vis/open HepRepXML
(Optional) To write a geometry, use:
/vis/viewer/flush
(Optional) To signal a change in geometry (to be written with the next event), use:
/vis/viewer/refresh
To write 10 events (and geometries), use:
/run/beamOn 10
(Optional) To accumulate multiple (5) G4 events into one HepRep event, use:
/vis/scene/endOfEventAction accumulate
/run/beamOn 5
/vis/viewer/update
(Optional) To add attributes to each point on a trajectory, use:
/vis/heprep/addPointAttributes 1
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
Limitations:
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 4 you can create as many views (SceneHandlers) as you like.
1 June 2005
Mark.Donszelmann@slac.stanford.edu
@@ -1,51 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// John Allison 5th April 2001
// A graphics system to dump geometry hierarchy.
#ifndef G4HepRepFile_HH
#define G4HepRepFile_HH
#include "G4VGraphicsSystem.hh"
// HepRep
#include "G4HepRepFileXMLWriter.hh"
class G4HepRepFile : public G4VGraphicsSystem
{
public:
G4HepRepFile();
virtual ~G4HepRepFile();
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer(G4VSceneHandler&, const G4String& name = "");
G4HepRepFileXMLWriter* GetHepRepXMLWriter();
};
#endif
@@ -1,100 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//--------------------------------------------------------------------------
// File and Version Information:
//
// Description:
// Create a HepRep XML File (HepRep version 1).
//
// Environment:
// Software developed for the general High Energy Physics community.
//
// Author :
// J. Perl Original Author
//
// Copyright Information:
// Copyright (C) 2001 Stanford Linear Accelerator Center
//------------------------------------------------------------------------
#ifndef G4HepRepFileXMLWriter_hh
#define G4HepRepFileXMLWriter_hh
//#define G4HEPREPFILEDEBUG // Comment this out to suppress debug code.
#include "globals.hh"
#include <fstream>
class G4HepRepFileXMLWriter
{
public:
G4HepRepFileXMLWriter();
void addType(const char* name, int newTypeDepth);
void addInstance();
void addPrimitive();
void addPoint(double x, double y, double z);
void addAttDef(const char* name, const char* desc, const char* type,
const char* extra);
void addAttValue(const char* name, const char* value);
void addAttValue(const char* name, double value);
void addAttValue(const char* name, int value);
void addAttValue(const char* name, bool value);
void addAttValue(const char* name, double value1, double value2,
double value3);
void open(const char* filespec);
void close();
void endTypes();
bool isOpen;
int typeDepth;
bool inType[50];
bool inInstance[50];
char* prevTypeName[50];
private:
std::ofstream fout;
void init();
bool inPrimitive;
bool inPoint;
void endType();
void endInstance();
void endPrimitive();
void endPoint();
void indent();
};
#endif
@@ -1,23 +0,0 @@
Apart from the heprep1 files:
G4HepRepFile.hh
G4HepRepFileSceneHandler.hh
G4HepRepFileViewer.hh
G4HepRepFileXMLWriter.hh
and heprep2 files:
G4HepRep.hh
G4HepRepSceneHandler.hh
G4HepRepMessenger.hh
G4HepRepViewer.hh
the other sources are copies from the FreeHEP library
(java.freehep.org) and are maintained there.
The files starting with G4 are geant4 compliant, the others may not be.
Changes made here may be overwritten.
4 May 2005
Mark Donszelmann
@@ -1,160 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// Joseph Perl 27th January 2002
// A base class for a scene handler to export geometry and trajectories
// to the HepRep xml file format.
#ifndef G4HepRepFileSCENEHANDLER_HH
#define G4HepRepFileSCENEHANDLER_HH
//#define G4HEPREPFILEDEBUG // Comment this out to suppress debug code.
#include "G4VSceneHandler.hh"
#include "G4Box.hh"
#include "G4Cons.hh"
#include "G4Tubs.hh"
#include "G4Trd.hh"
#include "G4Trap.hh"
#include "G4Sphere.hh"
#include "G4Para.hh"
#include "G4Torus.hh"
#include "G4Polycone.hh"
#include "G4Polyhedra.hh"
// HepRep
#include "G4HepRepFileXMLWriter.hh"
class G4VPhysicalVolume;
class G4LogicalVolume;
class G4ModelingParameters;
class G4VisTrajContext;
class G4HepRepFileSceneHandler : public G4VSceneHandler
{
public:
G4HepRepFileSceneHandler(G4VGraphicsSystem& system, const G4String& name);
virtual ~G4HepRepFileSceneHandler();
////////////////////////////////////////////////////////////////
// No need to implement these, but if you do...
void AddSolid(const G4Box&);
void AddSolid(const G4Cons&);
void AddSolid(const G4Tubs&);
void AddSolid(const G4Trd&);
void AddSolid(const G4Trap&);
void AddSolid(const G4Sphere&);
void AddSolid(const G4Para&);
void AddSolid(const G4Torus&);
void AddSolid(const G4Polycone&);
void AddSolid(const G4Polyhedra&);
void AddSolid(const G4Orb&);
void AddSolid(const G4Ellipsoid&);
void AddSolid(const G4TessellatedSolid&);
void AddSolid(const G4VSolid&);
using G4VSceneHandler::AddCompound;
void AddCompound(const G4VTrajectory&);
void InitTrajectory();
void AddCompound(const G4VHit&);
void InitHit();
// void PreAddSolid(const G4Transform3D& objectTransformation,
// const G4VisAttributes&);
// void PostAddSolid();
////////////////////////////////////////////////////////////////
// Required implementation of pure virtual functions...
using G4VSceneHandler::AddPrimitive;
void AddPrimitive(const G4Polyline&);
void AddPrimitive(const G4Text&);
void AddPrimitive(const G4Circle&);
void AddPrimitive(const G4Square&);
void AddPrimitive(const G4Polyhedron&);
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// Further optional AddPrimtive methods. Explicitly invoke base
// class methods if not otherwise defined to avoid warnings about
// hiding of base class methods.
void AddPrimitive(const G4Polymarker&);
////////////////////////////////////////////////////////////////
// Further optional virtual functions...
// void BeginPrimitives(const G4Transform3D& objectTransformation);
// void EndPrimitives();
void BeginModeling();
void EndModeling();
void BeginPrimitives2D(const G4Transform3D& objectTransformation);
void EndPrimitives2D();
//////////////////////////////////////////////////////////////
// Administration functions.
// void ClearStore ();
void ClearTransientStore();
////////////////////////////////////////////////////////////////
// Required...
G4HepRepFileXMLWriter* GetHepRepXMLWriter();
protected:
static G4int fSceneIdCount; // Counter for HepRep scene handlers.
private:
G4HepRepFileXMLWriter* hepRepXMLWriter;
void AddHepRepInstance(const char* primName, const G4Visible visible);
void CheckFileOpen();
int fileCounter;
G4bool haveVisible;
G4bool inPrimitives2D;
G4bool warnedAbout3DText;
G4bool warnedAbout2DMarkers;
G4bool drawingTraj;
G4bool doneInitTraj;
G4bool drawingHit;
G4bool doneInitHit;
const G4VisTrajContext* trajContext;
std::vector<G4AttValue>* trajAttValues;
std::map<G4String, G4AttDef>* trajAttDefs;
std::vector<G4AttValue>* hitAttValues;
std::map<G4String, G4AttDef>* hitAttDefs;
#ifdef G4HEPREPFILEDEBUG
void PrintThings();
#endif
};
#endif
@@ -1,56 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// John Allison 5th April 2001
// A base class for a dummy viewer to dump geometry hierarchy.
#ifndef G4HepRepFileVIEWER_HH
#define G4HepRepFileVIEWER_HH
// #define G4HEPREPFILEDEBUG // Comment this out to suppress debug code.
#include "G4VViewer.hh"
#include "G4HepRepFileXMLWriter.hh"
#include "G4HepRepFileSceneHandler.hh"
class G4HepRepFileViewer : public G4VViewer
{
public:
G4HepRepFileViewer(G4VSceneHandler&, const G4String& name);
virtual ~G4HepRepFileViewer();
void SetView();
void ClearView();
void DrawView();
void ShowView();
private:
G4HepRepFileXMLWriter* hepRepXMLWriter;
};
#endif
@@ -1,107 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
#ifndef G4HepRepMessenger_HH
#define G4HepRepMessenger_HH 1
#include "G4UImessenger.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADouble.hh"
#include "G4UIcmdWith3VectorAndUnit.hh"
#include "G4UIcommand.hh"
#include "G4ThreeVector.hh"
class G4HepRepMessenger : public G4UImessenger
{
public:
static G4HepRepMessenger* GetInstance(); // Singleton constructor.
virtual ~G4HepRepMessenger();
virtual G4String GetCurrentValue(G4UIcommand* command);
virtual void SetNewValue(G4UIcommand* command, G4String newValue);
// Used by HepRepFile
virtual G4String getFileDir();
virtual G4String getFileName();
virtual G4bool getOverwrite();
virtual G4bool getCullInvisibles();
virtual G4bool renderCylAsPolygons();
virtual G4double getScale();
virtual G4ThreeVector getCenter();
// Used by HepRepXML
virtual G4String getEventNumberSuffix();
virtual G4bool appendGeometry();
virtual G4bool addPointAttributes();
virtual G4bool useSolids();
virtual G4bool writeInvisibles();
private:
G4HepRepMessenger(); // Private constructor.
static G4HepRepMessenger* fpInstance;
G4UIdirectory* heprepDirectory;
G4String fileDir;
G4UIcmdWithAString* setFileDirCommand;
G4String fileName;
G4UIcmdWithAString* setFileNameCommand;
G4bool overwrite;
G4UIcmdWithABool* setOverwriteCommand;
G4bool cullInvisibles;
G4UIcmdWithABool* setCullInvisiblesCommand;
G4bool cylAsPolygons;
G4UIcmdWithABool* renderCylAsPolygonsCommand;
G4double scale;
G4UIcmdWithADouble* setScaleCommand;
G4ThreeVector center;
G4UIcmdWith3VectorAndUnit* setCenterCommand;
G4String suffix;
G4UIcmdWithAString* setEventNumberSuffixCommand;
G4bool geometry;
G4UIcmdWithABool* appendGeometryCommand;
G4bool pointAttributes;
G4UIcmdWithABool* addPointAttributesCommand;
G4bool solids;
G4UIcmdWithABool* useSolidsCommand;
G4bool invisibles;
};
#endif
-34
View File
@@ -1,34 +0,0 @@
# - G4visHepRep module build definition
# Define the Geant4 Module.
geant4_add_module(G4visHepRep
PUBLIC_HEADERS
G4HepRepFile.hh
G4HepRepFileXMLWriter.hh
PRIVATE_HEADERS
G4HepRepFileSceneHandler.hh
G4HepRepFileViewer.hh
G4HepRepMessenger.hh
SOURCES
G4HepRepFile.cc
G4HepRepFileSceneHandler.cc
G4HepRepFileViewer.cc
G4HepRepFileXMLWriter.cc
G4HepRepMessenger.cc)
geant4_module_link_libraries(G4visHepRep
PUBLIC
G4globman
G4vis_management
PRIVATE
G4csg
G4geometrymng
G4graphics_reps
G4hits
G4intercoms
G4materials
G4modeling
G4specsolids
G4tracking)
# List any source specific properties here
@@ -1,88 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// Joseph Perl 1 October 2001
// A graphics system to dump geometry hierarchy to the
// HepRep graphics format (HepRep version 1).
// HepRep
#include "G4HepRepFileXMLWriter.hh"
#include "G4HepRepFile.hh"
#include "G4HepRepFileSceneHandler.hh"
#include "G4HepRepFileViewer.hh"
#include "G4HepRepMessenger.hh"
static G4HepRepFileXMLWriter* hepRepXMLWriter;
G4HepRepFile::G4HepRepFile()
: G4VGraphicsSystem("G4HepRepFile", "HepRepFile",
"A HepRep (format 1) ascii file driver",
G4VGraphicsSystem::fileWriter)
{
G4HepRepMessenger::GetInstance();
hepRepXMLWriter = new G4HepRepFileXMLWriter();
}
G4HepRepFile::~G4HepRepFile() { delete hepRepXMLWriter; }
G4VSceneHandler* G4HepRepFile::CreateSceneHandler(const G4String& name)
{
G4VSceneHandler* pScene = new G4HepRepFileSceneHandler(*this, name);
return pScene;
}
G4VViewer* G4HepRepFile::CreateViewer(G4VSceneHandler& scene,
const G4String& name)
{
G4VViewer* pView =
new G4HepRepFileViewer((G4HepRepFileSceneHandler&) scene, name);
if(pView)
{
if(pView->GetViewId() < 0)
{
G4cout << "G4HepRepFile::CreateViewer: ERROR flagged by negative"
" view id in G4HepRepFileViewer creation."
"\n Destroying view and returning null pointer."
<< G4endl;
delete pView;
pView = 0;
}
}
else
{
G4cout << "G4HepRepFile::CreateViewer: ERROR: null pointer on new "
"G4HepRepFileViewer."
<< G4endl;
}
return pView;
}
G4HepRepFileXMLWriter* G4HepRepFile::GetHepRepXMLWriter()
{
return hepRepXMLWriter;
}
File diff suppressed because it is too large Load Diff
@@ -1,81 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
#include "G4HepRepFileViewer.hh"
#include "G4VSceneHandler.hh"
#include "G4HepRepFileSceneHandler.hh"
// HepRep
#include "G4HepRepFileXMLWriter.hh"
G4HepRepFileViewer::G4HepRepFileViewer(G4VSceneHandler& sceneHandler,
const G4String& name)
: G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name)
{
hepRepXMLWriter =
((G4HepRepFileSceneHandler*) (&sceneHandler))->GetHepRepXMLWriter();
// Make changes to view parameters for HepRep...
fVP.SetCulling(false);
fDefaultVP.SetCulling(false);
}
G4HepRepFileViewer::~G4HepRepFileViewer() { ShowView(); }
void G4HepRepFileViewer::SetView()
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileViewer::SetView() called.=" << G4endl;
#endif
}
void G4HepRepFileViewer::ClearView()
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileViewer::ClearView() called." << G4endl;
#endif
}
void G4HepRepFileViewer::DrawView()
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileViewer::DrawView() called." << G4endl;
#endif
NeedKernelVisit(); // Always need to visit G4 kernel.
ProcessView();
}
void G4HepRepFileViewer::ShowView()
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileViewer::ShowView" << G4endl;
#endif
G4VViewer::ShowView();
if(hepRepXMLWriter->isOpen)
hepRepXMLWriter->close();
}
@@ -1,458 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//--------------------------------------------------------------------------
// File and Version Information:
//
// Description:
// Create a HepRep XML File (HepRep version 1).
//
// Environment:
// Software developed for the general High Energy Physics community.
//
// Author :
// J. Perl Original Author
//
// Copyright Information:
// Copyright (C) 2001 Stanford Linear Accelerator Center
//------------------------------------------------------------------------
#include "G4HepRepFileXMLWriter.hh"
#include "G4HepRepMessenger.hh"
#include "G4ios.hh"
G4HepRepFileXMLWriter::G4HepRepFileXMLWriter()
{
isOpen = false;
init();
}
void G4HepRepFileXMLWriter::init()
{
typeDepth = -1;
int i = -1;
while(i++ < 49)
{
prevTypeName[i] = new char[1];
strcpy(prevTypeName[i], "");
inType[i] = false;
inInstance[i] = false;
}
inPrimitive = false;
inPoint = false;
}
void G4HepRepFileXMLWriter::addType(const char* name, int newTypeDepth)
{
if(fout.good())
{
// Flatten structure if it exceeds maximum allowed typeDepth of 49.
if(newTypeDepth > 49)
newTypeDepth = 49;
if(newTypeDepth < 0)
newTypeDepth = 0;
// Insert any layers that are missing from the hierarchy (protects against
// callers that skip from, say, layer 1 to layer 3 with no layer 2).
while(typeDepth < (newTypeDepth - 1))
{
addType("Layer Inserted by G4HepRepFileXMLWriter", typeDepth + 1);
addInstance();
}
// If moving closer to the root, close previously open types.
while(newTypeDepth < typeDepth)
endType();
// Close any remaining primitives of the current instance.
endPrimitive();
// If this is a new type name for the current depth, declare the
// new Type. Otherwise, it is just another Instance of the current Type.
if(strcmp(name, prevTypeName[newTypeDepth]) != 0)
{
if(inType[newTypeDepth])
endType();
prevTypeName[newTypeDepth] = new char[strlen(name) + 1];
strcpy(prevTypeName[newTypeDepth], name);
inType[newTypeDepth] = true;
indent();
fout << "<heprep:type version=\"null\" name=\"" << name << "\">"
<< G4endl;
typeDepth = newTypeDepth;
}
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addType No file is currently open."
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addInstance()
{
if(fout.good())
{
if(inType[typeDepth])
{
endInstance();
inInstance[typeDepth] = true;
indent();
fout << "<heprep:instance>" << G4endl;
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout
<< "G4HepRepFileXMLWriter:addInstance No HepRep Type is currently open"
<< G4endl;
#endif
}
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addInstance No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addPrimitive()
{
if(fout.good())
{
if(inInstance[typeDepth])
{
endPrimitive();
inPrimitive = true;
indent();
fout << "<heprep:primitive>" << G4endl;
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addPrimitive No HepRep Instance is "
"currently open"
<< G4endl;
#endif
}
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addPrimitive No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addPoint(double x, double y, double z)
{
if(fout.good())
{
if(inPrimitive)
{
endPoint();
inPoint = true;
indent();
// Include scale and center values
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
G4double scale = messenger->getScale();
G4ThreeVector center = messenger->getCenter();
G4double xNew = scale * (x - center.x());
G4double yNew = scale * (y - center.y());
G4double zNew = scale * (z - center.z());
fout << "<heprep:point x=\"" << xNew << "\" y=\"" << yNew << "\" z=\""
<< zNew << "\">" << G4endl;
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addPoint No HepRep Primitive is "
"currently open"
<< G4endl;
#endif
}
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addPoint No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addAttDef(const char* name, const char* desc,
const char* type, const char* extra)
{
if(fout.good())
{
indent();
fout << " <heprep:attdef extra=\"" << extra << "\" name=\"" << name
<< "\" type=\"" << type << "\"" << G4endl;
indent();
fout << " desc=\"" << desc << "\"/>" << G4endl;
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addAttDef No file is currently open"
<< G4endl;
#endif
}
}
// Four methods to fill attValues
void G4HepRepFileXMLWriter::addAttValue(const char* name, const char* value)
{
if(fout.good())
{
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\""
<< G4endl;
indent();
fout << " value=\"" << value << "\"/>" << G4endl;
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addAttValue(const char* name, double value)
{
if(fout.good())
{
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\""
<< G4endl;
indent();
fout << " value=\"" << value << "\"/>" << G4endl;
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addAttValue(const char* name, int value)
{
if(fout.good())
{
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\""
<< G4endl;
indent();
fout << " value=\"" << value << "\"/>" << G4endl;
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addAttValue(const char* name, bool value)
{
if(fout.good())
{
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\""
<< G4endl;
indent();
if(value)
fout << " value=\"True\"/>" << G4endl;
else
fout << " value=\"False\"/>" << G4endl;
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addAttValue(const char* name, double value1,
double value2, double value3)
{
if(fout.good())
{
int redness = int(value1 * 255.);
int greenness = int(value2 * 255.);
int blueness = int(value3 * 255.);
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\""
<< G4endl;
indent();
fout << " value=\"" << redness << "," << greenness << "," << blueness
<< "\"/>" << G4endl;
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::open(const char* fileSpec)
{
if(isOpen)
close();
fout.open(fileSpec);
if(fout.good())
{
fout << "<?xml version=\"1.0\" ?>" << G4endl;
fout << "<heprep:heprep "
"xmlns:heprep=\"http://www.slac.stanford.edu/~perl/heprep/\""
<< G4endl;
fout << " xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" "
"xsi:schemaLocation=\"HepRep.xsd\">"
<< G4endl;
isOpen = true;
init();
}
else
{
G4cout << "G4HepRepFileXMLWriter:open Unable to write to file " << fileSpec
<< G4endl;
}
}
void G4HepRepFileXMLWriter::close()
{
// Close any remaining open Types
endTypes();
if(fout.good())
{
fout << "</heprep:heprep>" << G4endl;
fout.close();
isOpen = false;
}
else
{
G4cout << "G4HepRepFileXMLWriter:close No file is currently open" << G4endl;
}
}
void G4HepRepFileXMLWriter::endTypes()
{
// Close any remaining open Types
while(typeDepth > -1)
endType();
}
void G4HepRepFileXMLWriter::endType()
{
endInstance();
indent();
fout << "</heprep:type>" << G4endl;
inType[typeDepth] = false;
delete[] prevTypeName[typeDepth];
prevTypeName[typeDepth] = new char[1];
strcpy(prevTypeName[typeDepth], "");
typeDepth--;
}
void G4HepRepFileXMLWriter::endInstance()
{
if(inInstance[typeDepth])
{
endPrimitive();
indent();
fout << "</heprep:instance>" << G4endl;
inInstance[typeDepth] = false;
}
}
void G4HepRepFileXMLWriter::endPrimitive()
{
if(inPrimitive)
{
endPoint();
indent();
fout << "</heprep:primitive>" << G4endl;
inPrimitive = false;
}
}
void G4HepRepFileXMLWriter::endPoint()
{
if(inPoint)
{
indent();
fout << "</heprep:point>" << G4endl;
inPoint = false;
}
}
void G4HepRepFileXMLWriter::indent()
{
if(fout.good())
{
int i = 0;
while(inType[i] && i < 12)
{
fout << " ";
if(inInstance[i])
fout << " ";
i++;
}
if(inPrimitive)
fout << " ";
if(inPoint)
fout << " ";
}
}
@@ -1,327 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
#include "G4HepRepMessenger.hh"
G4HepRepMessenger* G4HepRepMessenger::fpInstance = 0;
G4HepRepMessenger* G4HepRepMessenger::GetInstance()
{
if(!fpInstance)
fpInstance = new G4HepRepMessenger;
return fpInstance;
}
G4HepRepMessenger::G4HepRepMessenger()
: fileDir("")
, fileName("G4Data")
, overwrite(false)
, cullInvisibles(false)
, cylAsPolygons(false)
, scale(1.)
, suffix("")
, geometry(true)
, pointAttributes(false)
, solids(true)
, invisibles(true)
{
heprepDirectory = new G4UIdirectory("/vis/heprep/");
heprepDirectory->SetGuidance("HepRep commands.");
setFileDirCommand = new G4UIcmdWithAString("/vis/heprep/setFileDir", this);
setFileDirCommand->SetGuidance("Set directory for output.");
setFileDirCommand->SetGuidance(
"This command is used by HepRepFile, not by HepRepXML.");
setFileDirCommand->SetParameterName("directory", false);
if(std::getenv("G4HEPREPFILE_DIR") == NULL)
{
setFileDirCommand->SetDefaultValue("");
}
else
{
setFileDirCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_DIR"));
fileDir = std::getenv("G4HEPREPFILE_DIR");
}
setFileDirCommand->AvailableForStates(G4State_Idle);
setFileNameCommand = new G4UIcmdWithAString("/vis/heprep/setFileName", this);
setFileNameCommand->SetGuidance("Set file name for output.");
setFileNameCommand->SetGuidance(
"This command is used by HepRepFile, not by HepRepXML.");
setFileNameCommand->SetParameterName("directory", false);
if(std::getenv("G4HEPREPFILE_NAME") == NULL)
{
setFileNameCommand->SetDefaultValue("G4Data");
}
else
{
setFileNameCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_NAME"));
fileName = std::getenv("G4HEPREPFILE_NAME");
}
setFileNameCommand->AvailableForStates(G4State_Idle);
setOverwriteCommand = new G4UIcmdWithABool("/vis/heprep/setOverwrite", this);
setOverwriteCommand->SetGuidance(
"Set true to write all output to exact same file name.");
setOverwriteCommand->SetGuidance(
"Set false to increment the file name for each new output.");
setOverwriteCommand->SetGuidance(
"This command is used by HepRepFile, not by HepRepXML.");
setOverwriteCommand->SetParameterName("flag", false);
if(std::getenv("G4HEPREPFILE_OVERWRITE") == NULL)
{
setOverwriteCommand->SetDefaultValue(false);
}
else
{
setOverwriteCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_OVERWRITE"));
overwrite =
setOverwriteCommand->ConvertToBool(std::getenv("G4HEPREPFILE_OVERWRITE"));
}
setOverwriteCommand->AvailableForStates(G4State_Idle);
setCullInvisiblesCommand =
new G4UIcmdWithABool("/vis/heprep/setCullInvisibles", this);
setCullInvisiblesCommand->SetGuidance(
"Remove invisible objects from output file.");
setCullInvisiblesCommand->SetGuidance(
"This command is used by HepRepFile, not by HepRepXML.");
setCullInvisiblesCommand->SetParameterName("flag", false);
if(std::getenv("G4HEPREPFILE_CULL") == NULL)
{
setCullInvisiblesCommand->SetDefaultValue(false);
}
else
{
setCullInvisiblesCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_CULL"));
cullInvisibles =
setCullInvisiblesCommand->ConvertToBool(std::getenv("G4HEPREPFILE_CULL"));
}
setCullInvisiblesCommand->AvailableForStates(G4State_Idle);
renderCylAsPolygonsCommand =
new G4UIcmdWithABool("/vis/heprep/renderCylAsPolygons", this);
renderCylAsPolygonsCommand->SetGuidance(
"Render cylinders and cones as polygons.");
renderCylAsPolygonsCommand->SetGuidance(
"This command is used by HepRepFile, not by HepRepXML.");
renderCylAsPolygonsCommand->SetParameterName("flag", false);
renderCylAsPolygonsCommand->SetDefaultValue(false);
renderCylAsPolygonsCommand->AvailableForStates(G4State_Idle);
setScaleCommand = new G4UIcmdWithADouble("/vis/heprep/scale", this);
setScaleCommand->SetGuidance("Re-Scale coordinates.");
setScaleCommand->SetParameterName("Scale", true);
setScaleCommand->SetDefaultValue(1.);
setScaleCommand->SetRange("Scale > 0");
setCenterCommand = new G4UIcmdWith3VectorAndUnit("/vis/heprep/center", this);
setCenterCommand->SetGuidance("Re-Center coordinates.");
setCenterCommand->SetParameterName("CenterX", "CenterY", "CenterZ", true);
setCenterCommand->SetDefaultValue(G4ThreeVector(0., 0., 0.));
setCenterCommand->SetDefaultUnit("m");
setEventNumberSuffixCommand =
new G4UIcmdWithAString("/vis/heprep/setEventNumberSuffix", this);
setEventNumberSuffixCommand->SetGuidance(
"Write separate event files, appended with given suffix.");
setEventNumberSuffixCommand->SetGuidance(
"Define the suffix with a pattern such as '-0000'.");
setEventNumberSuffixCommand->SetGuidance(
"This command is used by HepRepXML, not by HepRepFile.");
setEventNumberSuffixCommand->SetParameterName("suffix", false);
setEventNumberSuffixCommand->SetDefaultValue("");
setEventNumberSuffixCommand->AvailableForStates(G4State_Idle);
appendGeometryCommand =
new G4UIcmdWithABool("/vis/heprep/appendGeometry", this);
appendGeometryCommand->SetGuidance(
"Appends copy of geometry to every event.");
appendGeometryCommand->SetGuidance(
"This command is used by HepRepXML, not by HepRepFile.");
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->SetGuidance(
"This command is used by HepRepXML, not by HepRepFile.");
addPointAttributesCommand->SetParameterName("flag", false);
addPointAttributesCommand->SetDefaultValue(false);
addPointAttributesCommand->AvailableForStates(G4State_Idle);
useSolidsCommand = new G4UIcmdWithABool("/vis/heprep/useSolids", this);
useSolidsCommand->SetGuidance(
"Use HepRep Solids, rather than Geant4 Primitives.");
useSolidsCommand->SetGuidance(
"This command is used by HepRepXML, not by HepRepFile..");
useSolidsCommand->SetParameterName("flag", false);
useSolidsCommand->SetDefaultValue(true);
useSolidsCommand->AvailableForStates(G4State_Idle);
}
G4HepRepMessenger::~G4HepRepMessenger()
{
delete setFileDirCommand;
delete setFileNameCommand;
delete setOverwriteCommand;
delete setCullInvisiblesCommand;
delete renderCylAsPolygonsCommand;
delete setScaleCommand;
delete setCenterCommand;
delete setEventNumberSuffixCommand;
delete appendGeometryCommand;
delete addPointAttributesCommand;
delete useSolidsCommand;
delete heprepDirectory;
}
G4String G4HepRepMessenger::GetCurrentValue(G4UIcommand* command)
{
if(command == setFileDirCommand)
{
return fileDir;
}
else if(command == setFileNameCommand)
{
return fileName;
}
else if(command == setOverwriteCommand)
{
return G4UIcommand::ConvertToString(overwrite);
}
else if(command == setCullInvisiblesCommand)
{
return G4UIcommand::ConvertToString(cullInvisibles);
}
else if(command == renderCylAsPolygonsCommand)
{
return renderCylAsPolygonsCommand->ConvertToString(cylAsPolygons);
}
else if(command == setScaleCommand)
{
return setScaleCommand->ConvertToString(scale);
}
else if(command == setCenterCommand)
{
return setCenterCommand->ConvertToString(center, "m");
}
else if(command == setEventNumberSuffixCommand)
{
return suffix;
}
else if(command == appendGeometryCommand)
{
return appendGeometryCommand->ConvertToString(geometry);
}
else if(command == addPointAttributesCommand)
{
return addPointAttributesCommand->ConvertToString(pointAttributes);
}
else if(command == useSolidsCommand)
{
return useSolidsCommand->ConvertToString(solids);
}
else
{
return "";
}
}
void G4HepRepMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if(command == setFileDirCommand)
{
fileDir = newValue;
}
else if(command == setFileNameCommand)
{
fileName = newValue;
}
else if(command == setOverwriteCommand)
{
overwrite = setOverwriteCommand->GetNewBoolValue(newValue);
}
else if(command == setCullInvisiblesCommand)
{
cullInvisibles = setCullInvisiblesCommand->GetNewBoolValue(newValue);
}
else if(command == renderCylAsPolygonsCommand)
{
cylAsPolygons = renderCylAsPolygonsCommand->GetNewBoolValue(newValue);
}
else if(command == setScaleCommand)
{
scale = setScaleCommand->GetNewDoubleValue(newValue);
}
else if(command == setCenterCommand)
{
center = setCenterCommand->GetNew3VectorValue(newValue);
}
else if(command == setEventNumberSuffixCommand)
{
suffix = newValue;
}
else if(command == appendGeometryCommand)
{
geometry = appendGeometryCommand->GetNewBoolValue(newValue);
}
else if(command == addPointAttributesCommand)
{
pointAttributes = addPointAttributesCommand->GetNewBoolValue(newValue);
}
else if(command == useSolidsCommand)
{
solids = useSolidsCommand->GetNewBoolValue(newValue);
}
}
G4String G4HepRepMessenger::getFileDir() { return fileDir; }
G4String G4HepRepMessenger::getFileName() { return fileName; }
G4bool G4HepRepMessenger::getOverwrite() { return overwrite; }
G4bool G4HepRepMessenger::getCullInvisibles() { return cullInvisibles; }
G4bool G4HepRepMessenger::renderCylAsPolygons() { return cylAsPolygons; }
G4double G4HepRepMessenger::getScale() { return scale; }
G4ThreeVector G4HepRepMessenger::getCenter() { return center; }
G4String G4HepRepMessenger::getEventNumberSuffix() { return suffix; }
G4bool G4HepRepMessenger::appendGeometry() { return geometry; }
G4bool G4HepRepMessenger::addPointAttributes() { return pointAttributes; }
G4bool G4HepRepMessenger::useSolids() { return solids; }
G4bool G4HepRepMessenger::writeInvisibles() { return invisibles; }
+6
View File
@@ -6,6 +6,12 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2025-11-07 John Allison (vis-V11-03-01)
- CMakeLists.txt: Remove HepRep.
## 2025-11-03 John Allison (vis-V11-03-00)
- CMakeLists.txt: Remove Qt3D.
## 2022-12-12 Ben Morgan (vis-V11-01-00)
- Remove obsolete GNUmakefile scripts
+32
View File
@@ -5,6 +5,38 @@ which **must** added in reverse chronological order (newest at the top).
It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2025-10-31 Andrea Barresi (opengl-V11-03-09)
- G4OpenGLQtViewer
- Improved context menu behavior for picking
- Added condition to avoid picking with rigth mouse button
## 2025-10-01 John Allison (opengl-V11-03-08)
- Implement policy for dotsSize and dotsSmooth.
- G4OpenGLSceneHandler.cc:
- BeginPrimitives() and BeginPrimitives2D():
- Set OpenGL states to default values:
- glClearColor (0.0, 0.0, 0.0, 0.0);
- glClearDepth (1.0);
- glDisable (GL_LINE_SMOOTH);
- glDisable (GL_POLYGON_SMOOTH);
- glDisable (GL_POINT_SMOOTH);
- AddPrimitive(G4Polymarker):
- For dots and circles, glEnable (GL_POINT_SMOOTH);
- G4OpenGLStoredViewer.cc and G4OpenGLStoredQtViewer.cc:
- CompareForKernelVisit():
- Include dotsSize and dotsSmooth for decision on kernel visit.
- G4OpenGLViewer.cc:
- InitializeGLView():
- Add glDisable (GL_POINT_SMOOTH).
## 2025-06-18 Andrea Barresi (opengl-V11-03-07)
- G4OpenGLQtViewer
- Implemented new virtual methods of G4VViewer: GetWindowSize and GetRenderAreaSize
- Modified wheel_rotate function to call ZoomFromMouseWheel of G4VViewer
- Updated the moveScene method to work correctly in perspective mode with dolly zoom.
-G4OpenGLWin32Viewer:
- Implemented new virtual methods of G4VViewer: GetWindowSize and GetRenderAreaSize
- Modified SetZoom function to call ZoomFromMouseWheel of G4VViewer
## 2025-05-23 Andrea Barresi (opengl-V11-03-06)
- G4OpenGLWin32Viewer:
@@ -170,6 +170,8 @@ public:
bool isTouchableVisible(int POindex);
void clearTreeWidget();
bool exportImage(std::string name="", int width=-1, int height=-1);
G4bool GetWindowSize(unsigned int& a_w, unsigned int& a_h);
G4bool GetRenderAreaSize(unsigned int& a_w, unsigned int& a_h);
public:
void G4MousePressEvent(QMouseEvent *event);
@@ -152,7 +152,7 @@ protected:
unsigned int getWinHeight() const;
G4bool sizeHasChanged();
// return true if size has change since last redraw
GLdouble getSceneNearWidth();
G4double GetSceneNearWidth();
GLdouble getSceneFarWidth();
GLdouble getSceneDepth();
void addExportImageFormat(std::string format);
@@ -66,6 +66,8 @@ private:
void SetShift(G4int, G4int);
void SetRotation(G4int, G4int);
void SetZoom(G4int);
G4bool GetWindowSize(unsigned int& a_w, unsigned int& a_h);
G4bool GetRenderAreaSize(unsigned int& a_w, unsigned int& a_h);
HWND fWindow;
HGLRC fHGLRC;
@@ -37,6 +37,7 @@
#include "G4UnitsTable.hh"
#include "G4OpenGLStoredQtViewer.hh"
#include "G4Threading.hh"
#include "G4SystemOfUnits.hh"
#include "G4OpenGLQtViewer.hh"
#include "G4OpenGLSceneHandler.hh"
@@ -500,8 +501,8 @@ G4OpenGLQtViewer::~G4OpenGLQtViewer (
if (fSceneTreeWidget != NULL) {
if (fSceneTreeWidget->layout() != NULL) {
while ((wItem = fSceneTreeWidget->layout()->takeAt(0)) != 0) {
delete wItem->widget();
delete wItem;
delete wItem->widget();
delete wItem;
}
}
}
@@ -530,7 +531,7 @@ G4bool G4OpenGLQtViewer::ReadyToDraw() {
//
// Create a popup menu for the widget. This menu is activated by right-mouse click
//
void G4OpenGLQtViewer::createPopupMenu() {
void G4OpenGLQtViewer::createPopupMenu() {
fContextMenu = new QMenu("All");
@@ -702,6 +703,7 @@ void G4OpenGLQtViewer::G4manageContextMenuEvent(QContextMenuEvent *e)
// launch menu
if ( fContextMenu ) {
updateToolbarAndMouseContextMenu();
fContextMenu->exec( e->globalPos() );
// delete fContextMenu;
}
@@ -957,13 +959,9 @@ void G4OpenGLQtViewer::toggleAux(bool check) {
void G4OpenGLQtViewer::togglePicking() {
// FIXME : Not the good way to do, we should handle the multiple cases of Icon/ContextMenu and CheckBox in a better way
if (fUiQt) {
if (!fVP.IsPicking()) {
fUiQt->SetIconPickSelected();
} else {
fUiQt->SetIconRotateSelected();
}
fUiQt->TogglePickSelection();
}
G4UImanager* UI = G4UImanager::GetUIpointer();
@@ -1226,9 +1224,9 @@ void G4OpenGLQtViewer::G4MousePressEvent(QMouseEvent *evnt)
float deltaY = ((float)getWinHeight()/2-evnt->pos().y());
G4double coefTrans = 0;
coefTrans = ((G4double)getSceneNearWidth())/((G4double)getWinWidth());
coefTrans = ((G4double)GetSceneNearWidth())/((G4double)getWinWidth());
if (getWinHeight() <getWinWidth()) {
coefTrans = ((G4double)getSceneNearWidth())/((G4double)getWinHeight());
coefTrans = ((G4double)GetSceneNearWidth())/((G4double)getWinHeight());
}
fVP.IncrementPan(-deltaX*coefTrans,deltaY*coefTrans,0);
fVP.SetZoomFactor(1.5 * fVP.GetZoomFactor());
@@ -1282,7 +1280,7 @@ void G4OpenGLQtViewer::G4MouseReleaseEvent(QMouseEvent *evnt)
fGLWidget->setCursor(QCursor(Qt::ArrowCursor));
if (fVP.IsPicking()){ // pick
if ((delta.x() != 0) || (delta.y() != 0)) {
if ((delta.x() != 0) || (delta.y() != 0) || (evnt->button() & Qt::RightButton)) {
return;
}
updatePickInfosWidget(evnt->pos().x()*factorX,evnt->pos().y()*factorY);
@@ -1413,15 +1411,7 @@ void G4OpenGLQtViewer::G4MouseMoveEvent(QMouseEvent *evnt)
} else if (fAltKeyPress) {
rotateQtSceneToggle(((float)deltaX),((float)deltaY));
} else if (fShiftKeyPress) {
unsigned int sizeWin;
sizeWin = getWinWidth();
if (getWinHeight() < getWinWidth()) {
sizeWin = getWinHeight();
}
// L.Garnier : 08/2010 100 is the good value, but don't ask me why !
float factor = ((float)100/(float)sizeWin) ;
moveScene(-(float)deltaX*factor,-(float)deltaY*factor,0,false);
moveScene(-(float)deltaX, -(float)deltaY, 0, true);
} else if (fControlKeyPress) {
fVP.SetZoomFactor(fVP.GetZoomFactor()*(1+((float)deltaY)));
}
@@ -1452,12 +1442,24 @@ void G4OpenGLQtViewer::moveScene(float dx,float dy, float dz,bool mouseMove)
G4double coefTrans = 0;
GLdouble coefDepth = 0;
if(mouseMove) {
coefTrans = ((G4double)getSceneNearWidth())/((G4double)getWinWidth());
if (getWinHeight() <getWinWidth()) {
coefTrans = ((G4double)getSceneNearWidth())/((G4double)getWinHeight());
if (fVP.GetFieldHalfAngle() == 0.0) {
// Orthographic projection
coefTrans = ((G4double)GetSceneNearWidth()) / ((G4double)getWinWidth());
if (getWinHeight() < getWinWidth()) {
coefTrans = ((G4double)GetSceneNearWidth()) / ((G4double)getWinHeight());
}
} else {
// Perspective projection
G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
if (radius <= 0.) radius = 1.;
const G4double cameraDistance = fVP.GetCameraDistance(radius);
coefTrans = cameraDistance * std::tan(fVP.GetFieldHalfAngle()) / ((G4double)getWinWidth());
if (getWinHeight() < getWinWidth()) {
coefTrans = cameraDistance * std::tan(fVP.GetFieldHalfAngle()) / ((G4double)getWinHeight());
}
}
} else {
coefTrans = getSceneNearWidth()*fPan_sens;
coefTrans = GetSceneNearWidth()*fPan_sens;
coefDepth = getSceneDepth()*fDeltaDepth;
}
fVP.IncrementPan(-dx*coefTrans,dy*coefTrans,dz*coefDepth);
@@ -1507,7 +1509,19 @@ void G4OpenGLQtViewer::rotateQtSceneToggle(float dx, float dy)
}
G4bool G4OpenGLQtViewer::GetWindowSize(unsigned int& a_w, unsigned int& a_h)
{
a_w = fWinSize_x / fGLWidget->devicePixelRatio();
a_h = fWinSize_y / fGLWidget->devicePixelRatio();
return true;
}
G4bool G4OpenGLQtViewer::GetRenderAreaSize(unsigned int& a_w, unsigned int& a_h)
{
a_w = fWinSize_x;
a_h = fWinSize_y;
return true;
}
/** This is the benning of a rescale function. It does nothing for the moment
@@ -1537,10 +1551,13 @@ void G4OpenGLQtViewer::rescaleImage(
void G4OpenGLQtViewer::G4wheelEvent (QWheelEvent * evnt)
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
fVP.SetZoomFactor(fVP.GetZoomFactor()+(fVP.GetZoomFactor()*(evnt->delta())/1200));
double delta = evnt->delta();
#else
fVP.SetZoomFactor(fVP.GetZoomFactor()+(fVP.GetZoomFactor()*(evnt->angleDelta().y())/1200));
double delta = evnt->angleDelta().y();
#endif
ZoomFromMouseWheel(delta, evnt->modifiers() & Qt::ShiftModifier, evnt->position().x(), evnt->position().y());
updateQWidget();
}
@@ -2709,9 +2726,9 @@ void G4OpenGLQtViewer::setCheckComponent(QTreeWidgetItem* item,bool check)
#if QT_VERSION < 0x060000
#else
//G.Barrand : from stackoverflow "How to render text with QOpenGLWidget":
static void transform_point(GLdouble out[4], const GLdouble m[16], const GLdouble in[4])
static void transform_point(GLdouble out[4], const GLdouble model[16], const GLdouble in[4])
{
#define M(row,col) m[col*4+row]
#define M(row,col) model[col*4+row]
out[0] =
M(0, 0) * in[0] + M(0, 1) * in[1] + M(0, 2) * in[2] + M(0, 3) * in[3];
out[1] =
@@ -4106,7 +4123,7 @@ void G4OpenGLQtViewer::updateToolbarAndMouseContextMenu(){
if (fBatchMode) {
return;
}
G4ViewParameters::DrawingStyle
d_style = fVP.GetDrawingStyle();
@@ -4168,31 +4185,26 @@ void G4OpenGLQtViewer::updateToolbarAndMouseContextMenu(){
if (fUiQt && fContextMenu) {
if (fUiQt->IsIconPickSelected()) {
fMousePickAction->setChecked(true);
fMouseZoomOutAction->setChecked(false);
fMouseZoomInAction->setChecked(false);
fMouseRotateAction->setChecked(false);
fMouseMoveAction->setChecked(false);
} else if (fUiQt->IsIconZoomOutSelected()) {
} else {
fMousePickAction->setChecked(false);
}
if (fUiQt->IsIconZoomOutSelected()) {
fMouseZoomOutAction->setChecked(true);
fMousePickAction->setChecked(false);
fMouseZoomInAction->setChecked(false);
fMouseRotateAction->setChecked(false);
fMouseMoveAction->setChecked(false);
} else if (fUiQt->IsIconZoomInSelected()) {
fMouseZoomInAction->setChecked(true);
fMousePickAction->setChecked(false);
fMouseZoomOutAction->setChecked(false);
fMouseRotateAction->setChecked(false);
fMouseMoveAction->setChecked(false);
} else if (fUiQt->IsIconRotateSelected()) {
fMouseRotateAction->setChecked(true);
fMousePickAction->setChecked(false);
fMouseZoomOutAction->setChecked(false);
fMouseZoomInAction->setChecked(false);
fMouseMoveAction->setChecked(false);
} else if (fUiQt->IsIconMoveSelected()) {
fMouseMoveAction->setChecked(true);
fMousePickAction->setChecked(false);
fMouseZoomOutAction->setChecked(false);
fMouseZoomInAction->setChecked(false);
fMouseRotateAction->setChecked(false);
@@ -302,6 +302,12 @@ void G4OpenGLSceneHandler::PreAddSolid
void G4OpenGLSceneHandler::BeginPrimitives
(const G4Transform3D& objectTransformation)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glClearDepth (1.0);
glDisable (GL_LINE_SMOOTH);
glDisable (GL_POLYGON_SMOOTH);
glDisable (GL_POINT_SMOOTH);
G4VSceneHandler::BeginPrimitives (objectTransformation);
}
@@ -313,6 +319,12 @@ void G4OpenGLSceneHandler::EndPrimitives ()
void G4OpenGLSceneHandler::BeginPrimitives2D
(const G4Transform3D& objectTransformation)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glClearDepth (1.0);
glDisable (GL_LINE_SMOOTH);
glDisable (GL_POLYGON_SMOOTH);
glDisable (GL_POINT_SMOOTH);
G4VSceneHandler::BeginPrimitives2D (objectTransformation);
}
@@ -432,8 +444,7 @@ void G4OpenGLSceneHandler::AddPrimitive (const G4Polymarker& polymarker)
switch (polymarker.GetMarkerType()) {
default:
case G4Polymarker::dots:
size = 1.;
[[fallthrough]]; // Fall through to circles
[[fallthrough]]; // Fall through to circles
case G4Polymarker::circles:
nSides = GetNoOfSides(fpVisAttribs);
startPhi = 0.;
@@ -467,14 +478,17 @@ void G4OpenGLSceneHandler::AddPrimitive (const G4Polymarker& polymarker)
pGLViewer->ChangePointSize(size);
//Antialiasing only for circles
switch (polymarker.GetMarkerType()) {
default:
case G4Polymarker::dots:
case G4Polymarker::circles:
glEnable (GL_POINT_SMOOTH); break;
case G4Polymarker::squares:
glDisable (GL_POINT_SMOOTH); break;
default:
case G4Polymarker::dots:
[[fallthrough]]; // Fall through to circles
case G4Polymarker::circles:
if (fpViewer->GetViewParameters().IsDotsSmooth()) {
glEnable (GL_POINT_SMOOTH);
}
break;
case G4Polymarker::squares:
break;
}
glBegin (GL_POINTS);
for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
@@ -155,7 +155,9 @@ G4bool G4OpenGLStoredQtViewer::CompareForKernelVisit(G4ViewParameters& lastVP)
(lastVP.IsPicking () != fVP.IsPicking ()) ||
(lastVP.IsSpecialMeshRendering() != fVP.IsSpecialMeshRendering()) ||
(lastVP.GetSpecialMeshRenderingOption() != fVP.GetSpecialMeshRenderingOption()) ||
(lastVP.GetTransparencyByDepth() != fVP.GetTransparencyByDepth())
(lastVP.GetTransparencyByDepth() != fVP.GetTransparencyByDepth()) ||
(lastVP.IsDotsSmooth() != fVP.IsDotsSmooth()) ||
(lastVP.GetDotsSize() != fVP.GetDotsSize())
)
return true;
@@ -102,7 +102,9 @@ G4bool G4OpenGLStoredViewer::CompareForKernelVisit(G4ViewParameters& lastVP) {
fVP.IsSpecialMeshRendering()) ||
(lastVP.GetSpecialMeshRenderingOption() !=
fVP.GetSpecialMeshRenderingOption()) ||
(lastVP.GetTransparencyByDepth() != fVP.GetTransparencyByDepth())
(lastVP.GetTransparencyByDepth() != fVP.GetTransparencyByDepth()) ||
(lastVP.IsDotsSmooth() != fVP.IsDotsSmooth()) ||
(lastVP.GetDotsSize() != fVP.GetDotsSize())
)
return true;
@@ -134,6 +134,7 @@ void G4OpenGLViewer::InitializeGLView ()
glClearDepth (1.0);
glDisable (GL_LINE_SMOOTH);
glDisable (GL_POLYGON_SMOOTH);
glDisable (GL_POINT_SMOOTH);
// clear the buffers and window?
ClearView ();
@@ -1031,7 +1032,7 @@ std::string G4OpenGLViewer::getRealPrintFilename() {
return temp;
}
GLdouble G4OpenGLViewer::getSceneNearWidth()
G4double G4OpenGLViewer::GetSceneNearWidth()
{
if (!fSceneHandler.GetScene()) {
return 0;
@@ -130,15 +130,15 @@ void G4OpenGLWin32Viewer::CreateMainWindow (
//FIXME : NOT tested !
fWindow = ::CreateWindowEx(0, (PTSTR)className, (PTSTR)fName.c_str(),
WS_OVERLAPPEDWINDOW,
//WS_CHILD | WS_VISIBLE,
WS_OVERLAPPEDWINDOW,
//WS_CHILD | WS_VISIBLE,
// 0,0,
fVP.GetWindowAbsoluteLocationHintX(x_res),
fVP.GetWindowAbsoluteLocationHintY(y_res),
getWinWidth(), getWinHeight(),
NULL, NULL,
::GetModuleHandle(NULL),
NULL);
getWinWidth(), getWinHeight(),
NULL, NULL,
::GetModuleHandle(NULL),
NULL);
if(!fWindow) return;
::SetWindowLongPtr(fWindow,GWLP_USERDATA,LONG_PTR(this));
@@ -341,7 +341,6 @@ LRESULT CALLBACK G4OpenGLWin32Viewer::WindowProc(
G4int delta = (short) HIWORD(aWParam);
This->SetZoom(delta);
This->SetView();
This->ClearView();
This->DrawView();
@@ -399,9 +398,9 @@ G4bool G4OpenGLWin32Viewer::SetWindowPixelFormat(
if (pixelIndex==0) {
pixelIndex = 1;
if (::DescribePixelFormat(aHdc,
pixelIndex,
sizeof(PIXELFORMATDESCRIPTOR),
&pfd)==0) {
pixelIndex,
sizeof(PIXELFORMATDESCRIPTOR),
&pfd)==0) {
return false;
}
}
@@ -476,18 +475,28 @@ void G4OpenGLWin32Viewer::SetRotation(
}
//////////////////////////////////////////////////////////////////////////////
void G4OpenGLWin32Viewer::SetZoom(
G4int delta
)
void G4OpenGLWin32Viewer::SetZoom(G4int delta)
//////////////////////////////////////////////////////////////////////////////
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
{
if (fVP.GetFieldHalfAngle() == 0.) { // Orthographic projection
const G4double scale = 500; // Empirically chosen
fVP.MultiplyZoomFactor(1. + delta/scale);
} else { // Perspective projection
const G4double scale = fVP.GetFieldHalfAngle()/(10.*deg); // Empirical
fVP.SetDolly(fVP.GetDolly() + delta/scale);
}
POINT mousePos;
GetCursorPos(&mousePos);
ScreenToClient(fWindow, &mousePos);
ZoomFromMouseWheel(delta, GetKeyState(VK_SHIFT) & 0x8000, mousePos.x, mousePos.y);
}
G4bool G4OpenGLWin32Viewer::GetWindowSize(unsigned int& a_w, unsigned int& a_h)
{
a_w = fWinSize_x;
a_h = fWinSize_y;
return true;
}
G4bool G4OpenGLWin32Viewer::GetRenderAreaSize(unsigned int& a_w, unsigned int& a_h)
{
a_w = fWinSize_x;
a_h = fWinSize_y;
return true;
}
@@ -6,6 +6,11 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2025-10-01 John Allison (openinventor-V11-03-03)
- G4OpenInventorViewer.cc:
- CompareForKernelVisit():
- Include dotsSize and dotsSmooth for decision on kernel visit.
## 2025-03-06 John Allison (openinventor-V11-03-02)
- G4OpenInventorViewer:
- Implement CompareForTransientsRedraw().
@@ -192,7 +192,9 @@ G4bool G4OpenInventorViewer::CompareForKernelVisit(G4ViewParameters& vp) {
(vp.GetVisAttributesModifiers() != fVP.GetVisAttributesModifiers()) ||
(vp.IsSpecialMeshRendering() != fVP.IsSpecialMeshRendering()) ||
(vp.GetSpecialMeshRenderingOption()!= fVP.GetSpecialMeshRenderingOption())||
(vp.GetTransparencyByDepth() != fVP.GetTransparencyByDepth())
(vp.GetTransparencyByDepth() != fVP.GetTransparencyByDepth()) ||
(vp.IsDotsSmooth() != fVP.IsDotsSmooth()) ||
(vp.GetDotsSize() != fVP.GetDotsSize())
)
return true;
-3
View File
@@ -1,3 +0,0 @@
# - G4visQt3D category build
include(sources.cmake)
geant4_add_category(G4visQt3D MODULES G4visQt3D)
-246
View File
@@ -1,246 +0,0 @@
# Category visQt3D History
See `CONTRIBUTING.rst` for details of **required** info/format for each entry,
which **must** added in reverse chronological order (newest at the top).
It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2025-03-06 John Allison (visQt3D-V11-03-02)
- G4Qt3DViewer:
- Implement CompareForTransientsRedraw().
- Take advantage of ProcessTransients(), which reconstructs that part of
the graphical database for transient objects, e.g., trajectories,
without reconstructing the "permanent" (run-duration) objects, e.g.,
the detector. In other words, something short of a complete "kernel
visit". For example, if the time window changes.
- Maximises the efficiency of the recently implemented "generic" time
windowing.
## 2025-02-13 John Allison (visQt3D-V11-03-01)
- G4Qt3DViewer.cc: CompareForKernelVisit:
- Cause kernel visit if viewer start/end time changes.
- This is to take advantage of the new generic time window - modeling-V11-03-04.
## 2025-01-06 John Allison (visQt3D-V11-03-00)
- Co-works: visman-V11-03-00, interfaces-V11-03-00, modeling-V11-03-00,
opengl-V11-03-00, vis_toolssg-V11-03-00, openinventor-V11-03-00,
greps-V11-03-00.
- Re-instate the transparency slider (see lengthy explanation in management/History).
- G4Qt3DViewer:
- Initiate kernel visit if TransparencyByDepth or its options change.
## 2024-08-14 John Allison (visQt3D-V11-02-03)
- G4Qt3DViewer:
- Resolve the timing issues around switching to the vis sub-thread with the
use of G4CONDITIONWAITLAMBDA.
## 2024-07-12 Guy Barrand (visQt3D-V11-02-02)
- G4Qt3DViewer: implement a resizeEvent() method to avoid a bad aspect ratio at viewer creation.
- G4Qt3DSceneHandler: in AddPrimitive(G4Polyline), stay with the Qt5 code. The one for Qt6 using
Qt3DCore::QGeometryView is crashy.
- G4Qt3DViewer: in MovingToVisSubThread(), SwitchToMasterThread() protect against nullptr for p1, p2.
It permits to avoid crash in case of doing /run/beamOn in vis.mac at startup.
## 2024-05-23 Guy Barrand (visQt3D-V11-02-01)
- G4Qt3DSceneHandler::EstablishG4Qt3DQEntities(): have a missing:
fpPhysicalVolumeObjects.clear();
It avoids a crash if doing multiple "/vis/open Qt3D".
- G4Qt3DViewer destructor: do a setRootEntity(nullptr) to disconnect
the G4Qt3DSceneHandler::fpQt3DScene from a viewer.
- G4Qt3DSceneHandler destructor: clear the fpQt3DScene scene tree.
A crash (seen on most platforms) is now avoided here because of the
disconnection of the fpQt3DScene in a viewer destructor.
(This "scene clearing" assumes that the deletion a G4Qt3DSceneHandler happens after
all related viewers are already deleted).
## 2024-03-13 Gabriele Cosmo (visQt3D-V11-02-00)
- Fixed compilation error on Windows for ambiguous string assignment in
G4Qt3DSceneHandler::CreateNewNode().
## 2023-10-14 John Allison (visQt3D-V11-01-07)
- G4Qt3DSceneHandler.cc: Add dummy normal line attributes - Qt6 seems to require!!
- I am puzzled - why do lines need normals?
- Fixes wireframe drawing.
- Does not seem to fix trajectory line drawing, which is curious.
## 2023-10-07 John Allison (visQt3D-V11-01-06)
- G4Qt3DSceneHandler.cc:
- Establish the top physical volume Qt3D entities from the scene.
- This is a better way than using transportation worlds.
- In some circumstances, such as the standalone examples,
G4TransportationManager is no longer instantiated in time,
causing a crash. But this way is better anyway.
## 2023-08-14 John Allison (visQt3D-V11-01-05)
- G4Qt3D:
- Simplify IsUISessionCompatible.
- Exploit new method, G4UImanager::GetBaseSession (intercoms-V11-01-07).
## 2023-07-01 John Allison (visQt3D-V11-01-04)
- Fix precision-loss warning
## 2023-04-26 Ben Morgan (visQt3D-V11-01-03)
- Support compilation against Qt5 and Qt6.
## 2023-03-22 Ben Morgan (visQt3D-V11-01-02)
- Export public compile definitions to indicate availablity of specific drivers. Moves to
"use on link" model.
## 2023-02-06 Ben Morgan (visQt3D-V11-01-01)
- Isolate private headers and update dependencies
## 2023-01-30 Ben Morgan (visQt3D-V11-01-00)
- Link to new G4UIcore/UIimplementation modules in place of former G4UIbasic/UIcommon
## 2022-11-25 Gabriele Cosmo (visQt3D-V11-00-12)
- Fixed compilation warning for implicit type conversions on macOS/XCode 14.1.
## 2022-11-06 John Allison (visQt3D-V11-00-11)
- Eliminate G4cerr and introduce G4warn.
- `#define G4warn G4cout`
- The above is temporary until a genuine G4warn output stream is
implemented.
- Change G4cerr to G4warn in all cases.
- Change G4cout to G4warn in those cases where it is clearly
an error report or a warning.
## 2022-10-28 John Allison (visQt3D-V11-00-10)
- Request kernel visit when cutaway mode changes:
- G4Qt3DViewer.cc
## 2022-09-14 John Allison (visQt3D-V11-00-09)
- G4Qt3DViewer.cc:
- Add check on special mesh rendering option in CompareForKernelVisit.
## 2022-09-03 Ben Morgan (visQt3D-V11-00-08)
- Remove unused header from G4heprandom to resolve consistency test
## 2022-04-06 John Allison (visQt3D-V11-00-07)
- Fix compiler warnings:
- G4Qt3DSceneHandler.hh: Add `using G4VSceneHandler::AddCompound` to
avoid warnings.
- G4Qt3DSceneHandler.cc: Change `world` to `wrld` to avoid warnings.
- `world` shadows an `enum` in `G4VSceneHandler`. Maybe a better solution
is to encapsulate the enum.
## 2022-05-03 Ben Morgan (visQt3D-V11-00-06)
- Preliminary build support for Qt5 and Qt6
## 2022-04-06 John Allison (visQt3D-V11-00-05)
- `G4Qt3DSceneHandler`:
- `void G4Qt3DSceneHandler::AddPrimitive (const G4Polymarker& polymarker)`:
- Update to current usage.
- `void G4Qt3DSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron)`:
- Comment out common line elimination - too expensive for a large
polyhedron.
- Maybe eliminate altogether in future?.
- Allow the graphics-reps utilities to optimise things like this.
- Use StandardSpecialMeshRendering(mesh).
- Of course, only if special mesh rendering is requested.
## 2022-03-05 John Allison (visQt3D-V11-00-04)
- G4Qt3DSceneHandler::AddCompound(const G4Mesh& mesh):
- For parameterised tetrahedron mesh, call default
G4VSceneHandler::DrawTetMeshAsDots(mesh).
- Tested on "ICRP145", a Geant4 application that we hope can become
a Geant4 advanced example, downloaded from the supplementary material
of Kim et al, ICRP, 2020. Adult mesh-type reference computational phantoms,
ICRP Publication 145, Ann. ICRP 49(3).
## 2022-01-28 Ben Morgan (visQt3D-V11-00-03)
- Replace `geant4_global_library_target` with direct file inclusion and
call to `geant4_add_category` to define library build from source modules.
## 2022-01-16 John Allison (visQt3D-V11-00-02)
- G4Qt3DViewer::wheelEvent:
- Re-program wheelEvent for perspective projection:
- Takes into account the extent of the scene.
## 2021-12-16 John Allison (visQt3D-V11-00-01)
- G4Qt3DSceneHandler.cc:
- AddCompound(const G4Mesh& mesh):
- Use base class utility G4VSceneHandler::Draw3DRectMeshAsDots(mesh);
## 2021-12-10 Ben Morgan (visQt3D-V11-00-00)
- Change to new Markdown History format
---
# History entries prior to 11.0
12 November 2021 - Ben Morgan (visQt3D-V10-07-12)
- Retire G4VIS_... preprocessor symbols in toolkit build, only required
by obsolete GNUmake system
8 November 2021 - Ben Morgan (visQt3D-V10-07-11)
- Retire G4UI/G4INTY_... preprocessor symbols in toolkit build, only required
by obsolete GNUmake system
20 October 2021 Gabriele Cosmo (visQt3D-V10-07-10)
- Fixed broken dependency in GNUmakefile...
18 October 2021 John Allison (visQt3D-V10-07-09)
- G4Qt3DSceneHandler:
- Introduce AddCompound(const G4Mesh&).
- This copies G4OpenGLSceneHandler.
- Subsequently it may be refined for Qt3D - but works well for now.
01 September 2021 John Allison (visQt3D-V10-07-08)
- G4Qt3DSceneHandler.cc:
o Raise G4Exception if no available node.
- G4Qt3DViewer.cc:
o Protect against illegal call to show() - it may only be called from
the master thread.
22 August 2021 John Allison (visQt3D-V10-07-07)
- Fix the problem of drawing from the vis sub-thread.
20 August 2021 John Allison (visQt3D-V10-07-06)
- Minor updates - optional debug printing, etc.
- Revert to black background.
- Add G4Qt3DViewer::MovingToVisSubThread and MovingToMasterThread.
07 June 2021 John Allison (visQt3D-V10-07-05)
- Requires greps-V10-07-07 (new method AddCompound (const G4Mesh&)).
- Requires modeling-V10-07-09 (new class G4Mesh).
- Requires visman-V10-07-10 (new default method and new commands).
- G4Qt3DViewer.hh:
o Fix hidden function warning.
- G4Qt3DViewer.cc:
o Force kernel visit if special mesh rendering parameters change.
28-May-2021 Ben Morgan (visQt3D-V10-07-04)
- Migrate to modular CMake build
27 May 2021 John Allison (visQt3D-V10-07-03)
- AddPrimitive(const G4Polyhedron&):
o Minor improvement to error message in the case of unexpected number
of edges.
17-Apr-2021 John Allison (visQt3D-V10-07-02)
- Fix compiler warning (unused variable "text")
08-Apr-2021 John Allison (visQt3D-V10-07-01)
- Move //#define G4QT3DDEBUG to G4Qt3DUtils.hh.
o Improve overall protection of debug output with #ifdef G4QT3DDEBUG.
- Include some trial code for text output, but comment it out.
29-Dec-2020 John Allison (visQt3D-V10-07-00)
- G4Qt3DViewer: Move code from constructor to G4Qt3DViewer::Initialise().
- G4Qt3DSceneHandler:
o Implement auxiliary edge suppression.
o Tidy up G4Qt3DSceneHandler::AddPrimitive(const G4Text& - still doesn't work.
29-Oct-2020 Ben Morgan (visQt3D-V10-06-02)
- Remove inclusion of obsolete CMake module
26-Oct-2020 Gabriele Cosmo (visQt3D-V10-06-01)
- Corrected GNUmake setup and fixed compilation warnings.
23-Oct-2020 John Allison (visQt3D-V10-06-00)
- First version.
- Requires cmake-V10-06-34.
27-Sep-2019 John Allison
- First skeleton. Based on XXXSG driver.
@@ -1,42 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// John Allison 17th June 2019
#ifndef G4QT3D_HH
#define G4QT3D_HH
#include "G4VGraphicsSystem.hh"
class G4Qt3D: public G4VGraphicsSystem {
public:
G4Qt3D();
virtual ~G4Qt3D();
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
G4bool IsUISessionCompatible () const;
};
#endif
@@ -1,47 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// John Allison, 30th August 2020
#ifndef G4QT3DQENTITY_HH
#define G4QT3DQENTITY_HH
#include <Qt3DCore>
#include "G4PhysicalVolumeModel.hh"
class G4Qt3DQEntity: public Qt3DCore::QEntity {
public:
G4Qt3DQEntity(Qt3DCore::QNode *parent = nullptr)
: Qt3DCore::QEntity(parent) {}
const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID& GetPVNodeID () const
{return fPVNodeID;}
void SetPVNodeID(const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID& id)
{fPVNodeID = id;}
private:
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID fPVNodeID;
};
#endif
@@ -1,88 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// John Allison 17th June 2019
#ifndef G4QT3DSCENEHANDLER_HH
#define G4QT3DSCENEHANDLER_HH
#include "G4VSceneHandler.hh"
#include <vector>
namespace Qt3DCore {
class QEntity;
}
class G4Qt3DQEntity;
class G4Qt3DSceneHandler: public G4VSceneHandler {
friend class G4Qt3DViewer;
public:
G4Qt3DSceneHandler(G4VGraphicsSystem& system,
const G4String& name);
virtual ~G4Qt3DSceneHandler();
void PreAddSolid(const G4Transform3D& objectTransformation,
const G4VisAttributes&);
void PostAddSolid();
void BeginPrimitives2D(const G4Transform3D& objectTransformation);
void EndPrimitives2D();
void BeginPrimitives(const G4Transform3D& objectTransformation);
void EndPrimitives();
using G4VSceneHandler::AddPrimitive;
void AddPrimitive(const G4Polyline&);
void AddPrimitive(const G4Polymarker&);
void AddPrimitive(const G4Text&);
void AddPrimitive(const G4Circle&);
void AddPrimitive(const G4Square&);
void AddPrimitive(const G4Polyhedron&);
using G4VSceneHandler::AddCompound;
void AddCompound(const G4Mesh&);
void ClearStore ();
void ClearTransientStore ();
protected:
void EstablishG4Qt3DQEntities();
G4Qt3DQEntity* CreateNewNode(); // For next solid or primitive
static G4int fSceneIdCount; // Counter for Qt3D scene handlers.
Qt3DCore::QEntity* fpQt3DScene;
Qt3DCore::QEntity* fpTransientObjects;
Qt3DCore::QEntity* fpPersistentObjects;
std::vector<G4Qt3DQEntity*> fpPhysicalVolumeObjects;
};
#endif
@@ -1,59 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// John Allison, 18th July 2020
#ifndef G4QT3DUTILS_HH
#define G4QT3DUTILS_HH
#include "G4Transform3D.hh"
#include "G4ThreeVector.hh"
#include <Qt3DCore>
#include <fstream>
//#define G4QT3DDEBUG
class G4Colour;
namespace G4Qt3DUtils {
Qt3DCore::QTransform* CreateQTransformFrom(const G4Transform3D&);
QColor ConvertToQColor(const G4Colour& c);
QVector3D ConvertToQVector3D(const G4ThreeVector& v);
void delete_entity_recursively(Qt3DCore::QNode *node);
void delete_components_and_children_of_entity_recursively(Qt3DCore::QNode *node);
#ifdef G4QT3DDEBUG
extern std::ofstream LogFile;
void PrintQObjectTree
(const QObject* node,
const G4String& where = "");
#endif
} // namespace G4Qt3DUtils
#endif
@@ -1,81 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// John Allison 17th June 2019
#ifndef G4QT3DVIEWER_HH
#define G4QT3DVIEWER_HH
#include "G4Qt3DSceneHandler.hh"
#include "G4VViewer.hh"
#include <Qt3DExtras>
class G4Qt3DViewer: public G4VViewer, public Qt3DExtras::Qt3DWindow
{
public:
G4Qt3DViewer(G4Qt3DSceneHandler&,const G4String& name);
virtual ~G4Qt3DViewer();
void Initialise();
void SetView();
void ClearView();
void DrawView();
void ShowView();
void FinishView();
void MovingToVisSubThread();
void SwitchToVisSubThread();
void MovingToMasterThread();
void SwitchToMasterThread();
protected:
virtual void resizeEvent(QResizeEvent*);
void KernelVisitDecision ();
G4bool CompareForKernelVisit(G4ViewParameters&);
G4bool CompareForTransientsRedraw(G4ViewParameters&);
void keyPressEvent (QKeyEvent*);
void keyReleaseEvent (QKeyEvent*);
void mouseDoubleClickEvent(QMouseEvent*);
void mouseMoveEvent (QMouseEvent*);
void mousePressEvent (QMouseEvent*);
void mouseReleaseEvent (QMouseEvent*);
void wheelEvent (QWheelEvent*);
G4ViewParameters fLastVP; // Memory for making kernel visit decisions.
G4Qt3DSceneHandler& fQt3DSceneHandler;
QWidget* fUIWidget;
G4bool fKeyPressed;
int fKey;
G4bool fMousePressed;
G4double fMousePressedX, fMousePressedY;
};
#endif
-37
View File
@@ -1,37 +0,0 @@
# - G4visQt3D module build definition
# Define the Geant4 Module.
geant4_add_module(G4visQt3D
PUBLIC_HEADERS
G4Qt3D.hh
PRIVATE_HEADERS
G4Qt3DQEntity.hh
G4Qt3DSceneHandler.hh
G4Qt3DUtils.hh
G4Qt3DViewer.hh
SOURCES
G4Qt3D.cc
G4Qt3DSceneHandler.cc
G4Qt3DUtils.cc
G4Qt3DViewer.cc)
geant4_module_compile_definitions(G4visQt3D PUBLIC G4VIS_USE_QT3D)
geant4_module_link_libraries(G4visQt3D
PUBLIC
G4vis_management
PRIVATE
G4csg
G4graphics_reps
G4globman
G4geometrymng
G4hepgeometry
G4modeling
G4navigation
G4UIimplementation
G4intercoms
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::3DCore
Qt${QT_VERSION_MAJOR}::3DExtras
Qt${QT_VERSION_MAJOR}::3DRender)
-81
View File
@@ -1,81 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// John Allison 17th June 2019
#include "G4Qt3D.hh"
#include "G4Qt3DSceneHandler.hh"
#include "G4Qt3DViewer.hh"
#include "G4UIQt.hh"
#include "G4UImanager.hh"
#include "G4UIbatch.hh"
#define G4warn G4cout
G4Qt3D::G4Qt3D():
G4VGraphicsSystem
("Qt3D",
"Qt3D",
"Qt3D graphics driver",
G4VGraphicsSystem::threeDInteractive) {}
G4Qt3D::~G4Qt3D() {}
G4VSceneHandler* G4Qt3D::CreateSceneHandler(const G4String& name) {
G4VSceneHandler* pScene = new G4Qt3DSceneHandler(*this, name);
return pScene;
}
G4VViewer* G4Qt3D::CreateViewer(G4VSceneHandler& scene,
const G4String& name) {
G4VViewer* pView =
new G4Qt3DViewer((G4Qt3DSceneHandler&) scene, name);
if (pView) {
if (pView->GetViewId() < 0) {
G4warn <<
"G4Qt3D::CreateViewer: ERROR flagged by negative"
" view id in G4Qt3DViewer creation."
"\n Destroying view and returning null pointer."
<< G4endl;
delete pView;
pView = 0;
}
}
if (!pView) {
G4warn <<
"G4Qt3D::CreateViewer: ERROR: null pointer on new G4Qt3DViewer."
<< G4endl;
}
return pView;
}
G4bool G4Qt3D::IsUISessionCompatible () const
{
// Qt windows require a Qt session.
G4UIsession* baseSession = G4UImanager::GetUIpointer()->GetBaseSession();
if (dynamic_cast<G4UIQt*>(baseSession) != nullptr) return true;
return false;
}
File diff suppressed because it is too large Load Diff
@@ -1,180 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// John Allison, 18th July 2020
#include "G4Qt3DUtils.hh"
#include "G4Qt3DQEntity.hh"
#include "G4PhysicalVolumeModel.hh"
Qt3DCore::QTransform* G4Qt3DUtils::CreateQTransformFrom(const G4Transform3D& g)
{
auto* q = new Qt3DCore::QTransform;
q->setMatrix
(QMatrix4x4
(g.xx(),g.xy(),g.xz(),g.dx(),
g.yx(),g.yy(),g.yz(),g.dy(),
g.zx(),g.zy(),g.zz(),g.dz(),
0,0,0,1));
q->setObjectName("transform");
return q;
}
QColor G4Qt3DUtils::ConvertToQColor(const G4Colour& c) {
QColor qColor;
qColor.setRgbF(c.GetRed(),c.GetGreen(),c.GetBlue(),c.GetAlpha());
return qColor;
}
QVector3D G4Qt3DUtils::ConvertToQVector3D(const G4ThreeVector& v) {
return QVector3D(v.x(),v.y(),v.z());
}
// https://stackoverflow.com/questions/45759274/how-can-i-delete-all-nodes-recursively-in-the-root-entity-of-qt3dwindow
void G4Qt3DUtils::delete_entity_recursively(Qt3DCore::QNode *node){
#ifdef G4QT3DDEBUG
G4Qt3DUtils::LogFile << "node " << node->objectName().toStdString() << std::endl;
#endif
Qt3DCore::QEntity* entity = dynamic_cast<Qt3DCore::QEntity*>(node);
if(entity == nullptr){
#ifdef G4QT3DDEBUG
G4String name = node->objectName().toStdString();
if (name == "") name = "X";
G4Qt3DUtils::LogFile << (void*)node << ": "
<< "Deleting non-entity node " << name << std::endl;
#endif
delete node;
node = nullptr;
return;
}
for (auto component: entity->components()) {
#ifdef G4QT3DDEBUG
G4String name = component->objectName().toStdString();
if (name == "") name = "X";
G4Qt3DUtils::LogFile << (void*)node << ": " << "Deleting component " << name
<< " of " << entity->objectName().toStdString() << std::endl;
#endif
entity->removeComponent(component);
delete component;
component = nullptr;
}
for (auto child_node: entity->childNodes()) {
G4String name = child_node->objectName().toStdString();
if (name == "") name = "X";
#ifdef G4QT3DDEBUG
G4Qt3DUtils::LogFile << (void*)child_node << ": " << "Child node " << name
<< " of " << entity->objectName().toStdString() << std::endl;
#endif
delete_entity_recursively(child_node);
}
G4String name = entity->objectName().toStdString();
if (name == "") name = "X";
#ifdef G4QT3DDEBUG
G4Qt3DUtils::LogFile << (void*)entity << ": " << "Deleting entity " << name << std::endl;
#endif
delete entity;
entity = nullptr;
}
void G4Qt3DUtils::delete_components_and_children_of_entity_recursively(Qt3DCore::QNode *node){
Qt3DCore::QEntity* entity = dynamic_cast<Qt3DCore::QEntity*>(node);
if(entity == nullptr){
#ifdef G4QT3DDEBUG
G4String name = node->objectName().toStdString();
if (name == "") name = "X";
G4Qt3DUtils::LogFile << (void*)node << ": " << "Found non-entity node " << name << std::endl;
#endif
return;
}
for (auto component: entity->components()){
#ifdef G4QT3DDEBUG
G4String name = component->objectName().toStdString();
if (name == "") name = "X";
G4Qt3DUtils::LogFile << (void*)entity << ": " << "Deleting component " << name
<< " of " << entity->objectName().toStdString() << std::endl;
#endif
entity->removeComponent(component);
delete(component);
component = nullptr;
}
auto child_nodes = entity->childNodes();
for (auto child_node: child_nodes) {
G4String name = child_node->objectName().toStdString();
if (name == "") name = "X";
#ifdef G4QT3DDEBUG
G4Qt3DUtils::LogFile << (void*)child_node << ": " << "Child node " << name
<< " of " << entity->objectName().toStdString() << std::endl;
#endif
delete_entity_recursively(child_node);
}
G4String name = entity->objectName().toStdString();
if (name == "") name = "X";
#ifdef G4QT3DDEBUG
G4Qt3DUtils::LogFile << (void*)entity << ": " << "Clearing child nodes of " << name << std::endl;
#endif
child_nodes.clear();
}
#ifdef G4QT3DDEBUG
std::ofstream G4Qt3DUtils::LogFile("LogFile.txt");
void G4Qt3DUtils::PrintQObjectTree
(const QObject* node,
const G4String& where)
{
auto& logFile = G4Qt3DUtils::LogFile;
if (where.length()) logFile << "\n===== QObjectTree at " << where << std::endl;
static G4int iDep = -1;
++iDep;
G4String nodeName = node->objectName().toStdString();
if (nodeName == "") nodeName = "X";
for (G4int i = 0; i < iDep; ++i) logFile << " ";
logFile << (void*)node << ": "
<< "Node at depth " << iDep << ": " << nodeName << ": "
<< "thread: " << node->thread() << ": "
<< "parent: " << node->parent() << ": ";
const auto* g4node = dynamic_cast<const G4Qt3DQEntity*>(node);
if (g4node) {
logFile << g4node->GetPVNodeID() << std::endl;
} else {
logFile << typeid(node).name() << std::endl;
}
if (g4node) {
for (const auto& component: g4node->components()) {
G4String name = component->objectName().toStdString();
if (name == "") name = "X";
for (G4int i = 0; i < iDep; ++i) logFile << " ";
logFile << (void*)component << ": "<< "Component at depth " << iDep << " "
<< name << " of " << nodeName << std::endl;
}
}
for (const auto& child: node->children()) {
PrintQObjectTree(child);
}
--iDep;
if (where.length()) logFile << "===== End: QObjectTree at " << where << std::endl;
return;
}
#endif
@@ -1,483 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// John Allison 17th June 2019
#include "G4Qt3DViewer.hh"
#include "G4Qt3DSceneHandler.hh"
#include "G4Qt3DUtils.hh"
#include "G4Scene.hh"
#include "G4UImanager.hh"
#include "G4UIQt.hh"
#include "G4SystemOfUnits.hh"
#define G4warn G4cout
G4Qt3DViewer::G4Qt3DViewer
(G4Qt3DSceneHandler& sceneHandler, const G4String& name)
: G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name)
, fQt3DSceneHandler(sceneHandler)
, fKeyPressed(false)
, fMousePressed(false)
, fMousePressedX(0.)
, fMousePressedY(0.)
{}
void G4Qt3DViewer::Initialise()
{
setObjectName(fName.c_str());
fVP.SetAutoRefresh(true);
fDefaultVP.SetAutoRefresh(true);
auto UI = G4UImanager::GetUIpointer();
auto uiQt = dynamic_cast<G4UIQt*>(UI->GetG4UIWindow());
if (!uiQt) {
fViewId = -1; // This flags an error.
G4warn << "G4Qt3DViewer::G4Qt3DViewer requires G4UIQt"
<< G4endl;
return;
}
fUIWidget = QWidget::createWindowContainer(this);
uiQt->AddTabWidget(fUIWidget,QString(fName));
setRootEntity(fQt3DSceneHandler.fpQt3DScene);
}
G4Qt3DViewer::~G4Qt3DViewer()
{
setRootEntity(nullptr);
}
void G4Qt3DViewer::resizeEvent(QResizeEvent*) {
SetView();
}
void G4Qt3DViewer::SetView()
{
// Background colour
defaultFrameGraph()->setClearColor(G4Qt3DUtils::ConvertToQColor(fVP.GetBackgroundColour()));
// Get radius of scene, etc.
// Note that this procedure properly takes into account zoom, dolly and pan.
const G4Point3D targetPoint
= fSceneHandler.GetScene()->GetStandardTargetPoint()
+ fVP.GetCurrentTargetPoint ();
G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
if(radius<=0.) radius = 1.;
const G4double cameraDistance = fVP.GetCameraDistance (radius);
const G4Point3D cameraPosition =
targetPoint + cameraDistance * fVP.GetViewpointDirection().unit();
const GLdouble pnear = fVP.GetNearDistance (cameraDistance, radius);
const GLdouble pfar = fVP.GetFarDistance (cameraDistance, pnear, radius);
const GLdouble right = fVP.GetFrontHalfHeight (pnear, radius);
const GLdouble left = -right;
const GLdouble top = fVP.GetFrontHalfHeight (pnear, radius);
const GLdouble bottom = -top;
camera()->setObjectName((fName + " camera").c_str());
camera()->setViewCenter(G4Qt3DUtils::ConvertToQVector3D(targetPoint));
camera()->setPosition(G4Qt3DUtils::ConvertToQVector3D(cameraPosition));
camera()->setUpVector(G4Qt3DUtils::ConvertToQVector3D(fVP.GetUpVector()));
// auto lightEntity = new Qt3DCore::QEntity(fQt3DSceneHandler.fpQt3DScene);
// auto directionalLight = new Qt3DRender::QDirectionalLight(lightEntity);
//// directionalLight->setColor("white");
//// directionalLight->setIntensity(1.);
// directionalLight->setWorldDirection(G4Qt3DUtils::ConvertToQVector3D(fVP.GetActualLightpointDirection()));
// lightEntity->addComponent(directionalLight);
const auto& size = fUIWidget->size();
G4double w = size.width();
G4double h = size.height();
#ifdef G4QT3DDEBUG
// Curiously w,h are wrong first time - 640,480 instead of (my Mac) 991,452.
G4cout << "W,H: " << w << ',' << h << G4endl;
#endif
const G4double aspectRatio = w/h;
if (fVP.GetFieldHalfAngle() == 0.) {
camera()->lens()->setOrthographicProjection
(left*aspectRatio,right*aspectRatio,bottom,top,pnear,pfar);
} else {
camera()->lens()->setPerspectiveProjection
(2.*fVP.GetFieldHalfAngle()/deg,aspectRatio,pnear,pfar);
}
}
void G4Qt3DViewer::ClearView()
{}
void G4Qt3DViewer::DrawView()
{
// First, a view should decide when to re-visit the G4 kernel.
// Sometimes it might not be necessary, e.g., if the scene is stored
// in a graphical database (e.g., OpenGL's display lists) and only
// the viewing angle has changed. But graphics systems without a
// graphical database will always need to visit the G4 kernel.
// The fNeedKernelVisit flag might have been set by the user in
// /vis/viewer/rebuild, but if not, make decision and set flag only
// if necessary...
if (!fNeedKernelVisit) KernelVisitDecision();
G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
ProcessView (); // Clears store and processes scene only if necessary.
if (kernelVisitWasNeeded) {
// We might need to do something if the kernel was visited.
} else { // Or even if it was not!
if (!fTransientsNeedRedrawing) CompareForTransientsRedraw(fLastVP);
if (fTransientsNeedRedrawing) {
ProcessTransients();
}
}
fLastVP = fVP;
// ...before finally...
FinishView (); // Flush streams and/or swap buffers.
}
void G4Qt3DViewer::ShowView()
{
#if QT_VERSION < 0x060000
// show() may only be called from master thread
if (G4Threading::IsMasterThread()) {
show();
}
// The way Qt seems to work, we don't seem to need a show() anyway, but
// we'll leave it in - it seems not to have any effect, good or bad.
#endif
}
void G4Qt3DViewer::FinishView()
{
#if QT_VERSION < 0x060000
if (G4Threading::IsMasterThread()) {
show();
}
#endif
}
// Note: the order of calling of MovingToVisSubThread and SwitchToVisSubThread
// is undefined. The order of calling is
// DoneWithMasterThread
// MovingToVisSubThread ) or ( SwitchToVisSubThread
// SwitchToVisSubThread ) ( MovingToVisSubThread
// DoneWithVisSubThread
// MovingToMasterThread
// SwitchToMasterThread
// So regarding the move/switch to the vis sub-thread, we have to employ mutex locks and conditions.
// If the viewer wishes to accept drawing from the vis sub-thread, Qt3D has to moveToThread.
// But at this point we are still on the master thread and the value of the sub-thread's QThread is
// not known. So it has to wait - a conditional wait, conditional on establishment of the sub-thread
// and the provision of a pointer to the QThread version of the vis sub-thread. In turn, the
// sub-thread has to wait until the QObjects have been moved to the sub-thread.
namespace {
QThread* masterQThread = nullptr;
QThread* visSubThreadQThread = nullptr;
G4Mutex visSubThreadMutex = G4MUTEX_INITIALIZER;
G4Condition waitForVisSubThreadInitialized = G4CONDITION_INITIALIZER;
G4bool visSubThreadEstablished = false;
G4bool qObjectsSwitched = false;
}
void G4Qt3DViewer::MovingToVisSubThread()
// Still on master thread but vis thread has been launched
{
// Make note of master QThread
masterQThread = QThread::currentThread();
// Wait until SwitchToVisSubThread has found vis sub-thread QThread
{
G4AutoLock lock(&visSubThreadMutex);
G4CONDITIONWAITLAMBDA(&waitForVisSubThreadInitialized, &lock, []{return visSubThreadEstablished;})
}
// Move relevant stuff to vis sub-thread QThread
auto p1 = fQt3DSceneHandler.fpQt3DScene->parent();
if(p1) {
auto p2 = p1->parent();
if(p2) {
p2->moveToThread(visSubThreadQThread);
} else {
p1->moveToThread(visSubThreadQThread);
}
}
// Inform sub-thread
G4AutoLock lock(&visSubThreadMutex);
qObjectsSwitched = true;
lock.unlock();
G4CONDITIONBROADCAST(&waitForVisSubThreadInitialized);
}
void G4Qt3DViewer::SwitchToVisSubThread()
// On vis sub-thread before any drawing
{
// Make note of vis-subthread QThread for MovingToVisSubThread
visSubThreadQThread = QThread::currentThread();
// Let MovingToVisSubThread know we have the QThread
{
G4AutoLock lock(&visSubThreadMutex);
visSubThreadEstablished = true;
G4CONDITIONBROADCAST(&waitForVisSubThreadInitialized);
}
// Wait until MovingToVisSubThread has moved stuff
{
G4AutoLock lock(&visSubThreadMutex);
G4CONDITIONWAITLAMBDA(&waitForVisSubThreadInitialized, &lock, []{return qObjectsSwitched;})
}
}
void G4Qt3DViewer::MovingToMasterThread()
// On vis sub-thread just before exit
{
// Move relevant stuff to master QThread.
auto p1 = fQt3DSceneHandler.fpQt3DScene->parent();
if(p1) {
auto p2 = p1->parent();
if(p2) {
p2->moveToThread(masterQThread);
} else {
p1->moveToThread(masterQThread);
}
}
// Reset
visSubThreadQThread = nullptr;
qObjectsSwitched = false;
}
void G4Qt3DViewer::SwitchToMasterThread()
// On master thread after vis sub-thread has terminated
{
visSubThreadEstablished = false;
}
void G4Qt3DViewer::KernelVisitDecision () {
// If there's a significant difference with the last view parameters
// of either the scene handler or this viewer, trigger a rebuild.
if (CompareForKernelVisit(fLastVP)) {
NeedKernelVisit (); // Sets fNeedKernelVisit.
}
}
G4bool G4Qt3DViewer::CompareForKernelVisit(G4ViewParameters& vp)
{
// Typical comparison. Taken from OpenInventor.
if (
(vp.GetDrawingStyle () != fVP.GetDrawingStyle ()) ||
(vp.GetNumberOfCloudPoints() != fVP.GetNumberOfCloudPoints()) ||
(vp.IsAuxEdgeVisible () != fVP.IsAuxEdgeVisible ()) ||
(vp.IsCulling () != fVP.IsCulling ()) ||
(vp.IsCullingInvisible () != fVP.IsCullingInvisible ()) ||
(vp.IsDensityCulling () != fVP.IsDensityCulling ()) ||
(vp.IsCullingCovered () != fVP.IsCullingCovered ()) ||
(vp.GetCBDAlgorithmNumber() !=
fVP.GetCBDAlgorithmNumber()) ||
(vp.IsSection () != fVP.IsSection ()) ||
(vp.IsCutaway () != fVP.IsCutaway ()) ||
// This assumes use of generic clipping (sectioning, slicing,
// DCUT, cutaway). If a decision is made to implement locally,
// this will need changing. See G4OpenGLViewer::SetView,
// G4OpenGLStoredViewer.cc::CompareForKernelVisit and
// G4OpenGLStoredSceneHander::CreateSection/CutawayPolyhedron.
(vp.IsExplode () != fVP.IsExplode ()) ||
(vp.GetNoOfSides () != fVP.GetNoOfSides ()) ||
(vp.GetGlobalMarkerScale() != fVP.GetGlobalMarkerScale()) ||
(vp.GetGlobalLineWidthScale() != fVP.GetGlobalLineWidthScale()) ||
(vp.IsMarkerNotHidden () != fVP.IsMarkerNotHidden ()) ||
(vp.GetDefaultVisAttributes()->GetColour() !=
fVP.GetDefaultVisAttributes()->GetColour()) ||
(vp.GetDefaultTextVisAttributes()->GetColour() !=
fVP.GetDefaultTextVisAttributes()->GetColour()) ||
(vp.GetBackgroundColour ()!= fVP.GetBackgroundColour ())||
(vp.IsPicking () != fVP.IsPicking ()) ||
// Scaling for Qt3D is done by the scene handler (is it really????) so it
// needs a kernel visit. (In this respect, it differs from the
// OpenGL drivers, where it's done in SetView.)
(vp.GetScaleFactor () != fVP.GetScaleFactor ()) ||
(vp.GetVisAttributesModifiers() != fVP.GetVisAttributesModifiers()) ||
(vp.IsSpecialMeshRendering() != fVP.IsSpecialMeshRendering()) ||
(vp.GetSpecialMeshRenderingOption()!= fVP.GetSpecialMeshRenderingOption())||
(vp.GetTransparencyByDepth() != fVP.GetTransparencyByDepth())
)
return true;
if (vp.IsDensityCulling () &&
(vp.GetVisibleDensity () != fVP.GetVisibleDensity ()))
return true;
if (vp.GetCBDAlgorithmNumber() > 0) {
if (vp.GetCBDParameters().size() != fVP.GetCBDParameters().size()) return true;
else if (vp.GetCBDParameters() != fVP.GetCBDParameters()) return true;
}
if (vp.IsSection () &&
(vp.GetSectionPlane () != fVP.GetSectionPlane ()))
return true;
if (vp.IsCutaway ()) {
if (vp.GetCutawayMode() != fVP.GetCutawayMode()) return true;
if (vp.GetCutawayPlanes ().size () !=
fVP.GetCutawayPlanes ().size ()) return true;
for (size_t i = 0; i < vp.GetCutawayPlanes().size(); ++i)
if (vp.GetCutawayPlanes()[i] != fVP.GetCutawayPlanes()[i])
return true;
}
if (vp.IsExplode () &&
(vp.GetExplodeFactor () != fVP.GetExplodeFactor ()))
return true;
if (vp.IsSpecialMeshRendering() &&
(vp.GetSpecialMeshVolumes() != fVP.GetSpecialMeshVolumes()))
return true;
if (vp.GetTransparencyByDepth() > 0. &&
vp.GetTransparencyByDepthOption() != fVP.GetTransparencyByDepthOption())
return true;
return false;
}
G4bool G4Qt3DViewer::CompareForTransientsRedraw(G4ViewParameters& vp)
{
if (vp.GetTimeParameters() != fVP.GetTimeParameters()) {
return fTransientsNeedRedrawing = true;
}
return false;
}
void G4Qt3DViewer::keyPressEvent(QKeyEvent* ev)
{
fKeyPressed = true;
fKey = ev->key();
}
void G4Qt3DViewer::keyReleaseEvent(QKeyEvent* /*ev*/)
{
fKeyPressed = false;
}
void G4Qt3DViewer::mouseDoubleClickEvent(QMouseEvent* /*ev*/) {}
void G4Qt3DViewer::mouseMoveEvent(QMouseEvent* ev)
{
// I think we only want these if a mouse button is pressed.
// But they come even when not pressed (on my MacBook Pro trackpad).
// Documentation says:
/* Mouse move events will occur only when a mouse button is pressed down,
unless mouse tracking has been enabled with QWidget::setMouseTracking().*/
// But this is a window not a widget.
// As a workaround we maintain a flag changed by mousePress/ReleaseEvent.
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
G4double x = ev->x();
G4double y = ev->y();
#else
G4double x = ev->position().x();
G4double y = ev->position().y();
#endif
G4double dx = x-fMousePressedX;
G4double dy = y-fMousePressedY;
fMousePressedX = x;
fMousePressedY = y;
if (fMousePressed) {
if (fKeyPressed && fKey == Qt::Key_Shift) { // Translation (pan)
const G4double sceneRadius = fQt3DSceneHandler.fpScene->GetExtent().GetExtentRadius();
const G4double scale = 300; // Roughly pixels per window, empirically chosen
const G4double dxScene = dx*sceneRadius/scale;
const G4double dyScene = dy*sceneRadius/scale;
fVP.IncrementPan(-dxScene,dyScene);
} else { // Rotation
// Simple ad-hoc algorithms
const G4Vector3D& x_prime = fVP.GetViewpointDirection().cross(fVP.GetUpVector());
const G4Vector3D& y_prime = x_prime.cross(fVP.GetViewpointDirection());
const G4double scale = 200; // Roughly pixels per window, empirically chosen
G4Vector3D newViewpointDirection = fVP.GetViewpointDirection();
newViewpointDirection += dx*x_prime/scale;
newViewpointDirection += dy*y_prime/scale;
fVP.SetViewpointDirection(newViewpointDirection.unit());
if (fVP.GetRotationStyle() == G4ViewParameters::freeRotation) {
G4Vector3D newUpVector = fVP.GetUpVector();
newUpVector += dx*x_prime/scale;
newUpVector += dy*y_prime/scale;
fVP.SetUpVector(newUpVector.unit());
}
}
}
SetView();
DrawView();
}
void G4Qt3DViewer::mousePressEvent(QMouseEvent* ev)
{
fMousePressed = true;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
fMousePressedX = ev->x();
fMousePressedY = ev->y();
#else
fMousePressedX = ev->position().x();
fMousePressedY = ev->position().y();
#endif
}
void G4Qt3DViewer::mouseReleaseEvent(QMouseEvent* /*ev*/)
{
fMousePressed = false;
}
void G4Qt3DViewer::wheelEvent(QWheelEvent* ev)
{
// Take note of up-down motion only
const G4double angleY = ev->angleDelta().y();
if (fVP.GetFieldHalfAngle() == 0.) { // Orthographic projection
const G4double scale = 500; // Empirically chosen
fVP.MultiplyZoomFactor(1.+angleY/scale);
} else { // Perspective projection
const G4double delta = fSceneHandler.GetExtent().GetExtentRadius()/200.; // Empirical
fVP.SetDolly(fVP.GetDolly()+angleY*delta);
}
SetView();
DrawView();
}
+31
View File
@@ -5,6 +5,37 @@ which **must** added in reverse chronological order (newest at the top).
It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2025-10-24 Guy Barrand (vis_toolssg-V11-03-12)
- implementation/sources.cmake: handle "-DTOOLS_USE_GL_VERSION_3_2" in case "GEANT4_USE_VTK".
## 2025-10-13 Guy Barrand (vis_toolssg-V11-03-11)
- G4ToolsSceneHandler.cc/AddPrimitive(G4Polymarker):
- G4Polymarker::dots: handle "dot smoothing".
- G4Polymarker::circles, squares: by default, have them "filled" instead of "line" to match OGLI/OGLS style.
- G4ToolsSceneHandler.cc/ClearTransientStore: have a "viewer EmitWindowRender()" to fix a "missing refresh" with
extended/runAndEvent/RE03/run.mac.
- G4ToolsSGViewer.hh: have a G4ToolsSG_viewer base class with a virtual EmitWindowRender() method
to be used in G4ToolsSceneHander::ClearTransientStore.
- G4ToolsSceneHandler.cc: two corrections to quiet Coverity.
## 2025-10-01 John Allison (vis_toolssg-V11-03-10)
- G4ToolsSGViewer.hh:
- CompareForKernelVisit():
- Include dotsSize and dotsSmooth for decision on kernel visit.
- G4ToolsSGSceneHandler.cc:
- AddPrimitive(G4Polymarker&):
- Respect marker size for dots.
## 2025-08-12 Guy Barrand (vis_toolssg-V11-03-09)
- G4ToolsSGViewer.hh: in CreateSG(), for 3D scenes, have a tools::sg::shade_model node set to "smooth" so that
TSG_GLES have the same "/vis/viewer/set/style surface" rendering as in OGLI/OGLS. (Then issuing Gouraud shading
on surfaces by default, as for OGLI/OGLS). Note that for TSG_ZB, the rendering of surfaces will be still "flat",
since we have not (yet) Gouraud shading on triangles for this TSG sub driver.
## 2025-06-18 Andrea Barresi (vis_toolssg-V11-03-08)
- G4ToolsSGViewer.hh:
- Modified wheel_rotate function to call ZoomFromMouseWheel of G4VViewer
- Added method GetSceneNearWidth
## 2025-06-17 Guy Barrand (vis_toolssg-V11-03-07)
- G4ToolsSGViewer.hh: in mouse_move(), use the event.shift_modifier() method, introduced
@@ -41,6 +41,7 @@
#include <tools/sg/separator>
#include <tools/sg/ortho>
#include <tools/sg/perspective>
#include <tools/sg/shade_model>
#include <tools/sg/torche>
#include <tools/sg/blend>
#include <tools/sg/noderef>
@@ -49,9 +50,21 @@
#include <tools/tokenize>
#include <tools/sg/write_paper>
class G4ToolsSG_viewer {
public:
G4ToolsSG_viewer() {}
virtual ~G4ToolsSG_viewer() {}
protected:
G4ToolsSG_viewer(const G4ToolsSG_viewer&){}
G4ToolsSG_viewer& operator=(const G4ToolsSG_viewer&){return *this;}
public:
virtual void EmitWindowRender() {}
};
template <class SG_SESSION,class SG_VIEWER>
class G4ToolsSGViewer : public G4VViewer, tools::sg::device_interactor {
class G4ToolsSGViewer : public G4VViewer, public G4ToolsSG_viewer, tools::sg::device_interactor {
typedef G4VViewer parent;
typedef G4ToolsSG_viewer parent_viewer;
typedef tools::sg::device_interactor parent_interactor;
public: //tools::sg::device_interactor interface.
virtual void key_press(const tools::sg::key_down_event&) {}
@@ -103,14 +116,9 @@ public: //tools::sg::device_interactor interface.
DrawView();
}
virtual void wheel_rotate(const tools::sg::wheel_rotate_event& a_event) {
const G4double angleY = a_event.angle();
if (fVP.GetFieldHalfAngle() == 0.) { // Orthographic projection
const G4double scale = 500; // Empirically chosen
fVP.MultiplyZoomFactor(1.+angleY/scale);
} else { // Perspective projection
const G4double delta = fSceneHandler.GetExtent().GetExtentRadius()/200.; // Empirical
fVP.SetDolly(fVP.GetDolly()+angleY*delta);
}
ZoomFromMouseWheel(a_event.angle(), a_event.shift_modifier(), a_event.x(), a_event.y());
SetView();
DrawView();
}
@@ -124,7 +132,6 @@ public:
,fMousePressedX(0)
,fMousePressedY(0)
{
//::printf("debug : G4ToolsSGViewer::G4ToolsSGViewer: %lu, %s\n",this,a_name.c_str());
Messenger::Create();
}
@@ -138,6 +145,7 @@ public:
protected:
G4ToolsSGViewer(const G4ToolsSGViewer& a_from)
:parent(a_from)
,parent_viewer(a_from)
,parent_interactor(a_from)
,fSGSession(a_from.fSGSession)
,fSGSceneHandler(a_from.fSGSceneHandler)
@@ -253,14 +261,14 @@ public:
} else {
//G4cout << "debug : camera : perspec : heightAngle " << float(2*fVP.GetFieldHalfAngle()) << std::endl;
tools::sg::perspective* perspective_camera = new tools::sg::perspective;
perspective_camera->height_angle.value(float(2*fVP.GetFieldHalfAngle()));
perspective_camera->height_angle.value(2 * std::atan(std::tan(fVP.GetFieldHalfAngle()) / fVP.GetZoomFactor()));
_camera = perspective_camera;
}
_camera->position.value
(tools::vec3f(float(cameraPosition.x()),
float(cameraPosition.y()),
float(cameraPosition.z())));
float(cameraPosition.y()),
float(cameraPosition.z())));
_camera->znear.value(float(pnear));
_camera->zfar.value(float(pfar));
@@ -272,7 +280,7 @@ public:
const G4Vector3D& actualLightDirection = fVP.GetActualLightpointDirection();
G4cout << "debug : actualLightDirection : " << actualLightDirection.x() << " " << actualLightDirection.y() << " " << actualLightDirection.z() << std::endl;
*/
CreateSG(_camera,fVP.GetActualLightpointDirection());
{G4Color background = fVP.GetBackgroundColour ();
@@ -308,21 +316,26 @@ public:
fSGSceneHandler.TouchPlotters(fSGViewer->sg());
fSGViewer->show();
fSGViewer->win_render();
fSGSession.sync();
}
}
public:
G4bool GetWindowSize(unsigned int& a_w,unsigned int& a_h) {
if(!fSGViewer) {a_w = 0;a_h = 0;return false;}
if(!fSGViewer) {a_w = 0; a_h = 0; return false;}
return fSGViewer->window_size(a_w,a_h);
}
G4bool GetRenderAreaSize(unsigned int& a_w,unsigned int& a_h) {
if(!fSGViewer) {a_w = 0;a_h = 0;return false;}
fSGViewer->render_area_size(a_w,a_h);
G4bool GetRenderAreaSize(unsigned int& a_w, unsigned int& a_h) {
if (!fSGViewer) {a_w = 0; a_h = 0; return false;}
fSGViewer->render_area_size(a_w, a_h);
return true;
}
//SG_VIEWER* sg_viewer() {return fSGViewer;}
virtual void EmitWindowRender() {
if(!fSGViewer) return;
fSGViewer->emit_win_render();
}
protected:
void KernelVisitDecision () {
if (CompareForKernelVisit(fLastVP)) {
@@ -367,7 +380,9 @@ protected:
(vp.GetVisAttributesModifiers() != fVP.GetVisAttributesModifiers()) ||
(vp.IsSpecialMeshRendering() != fVP.IsSpecialMeshRendering()) ||
(vp.GetSpecialMeshRenderingOption()!= fVP.GetSpecialMeshRenderingOption())||
(vp.GetTransparencyByDepth() != fVP.GetTransparencyByDepth())
(vp.GetTransparencyByDepth() != fVP.GetTransparencyByDepth()) ||
(vp.IsDotsSmooth() != fVP.IsDotsSmooth()) ||
(vp.GetDotsSize() != fVP.GetDotsSize())
)
return true;
@@ -436,6 +451,10 @@ protected:
scene_3D->add(a_camera);
{tools::sg::shade_model* shade_model = new tools::sg::shade_model;
shade_model->model = tools::sg::shade_smooth;
scene_3D->add(shade_model);}
{tools::sg::torche* light = new tools::sg::torche;
light->on = true;
light->direction = tools::vec3f(-a_light_dir.x(),-a_light_dir.y(),-a_light_dir.z());
@@ -465,6 +484,27 @@ protected:
}
}
G4double GetSceneNearWidth() {
if (!fSGSceneHandler.GetScene()) {
return 0;
}
const G4Point3D targetPoint =
fSGSceneHandler.GetScene()->GetStandardTargetPoint() + fVP.GetCurrentTargetPoint();
G4double radius = fSGSceneHandler.GetScene()->GetExtent().GetExtentRadius();
if (radius <= 0.) radius = 1.;
const G4double cameraDistance = fVP.GetCameraDistance(radius);
const G4double pnear = fVP.GetNearDistance(cameraDistance, radius);
G4double frontHalfHeight;
if (fVP.GetFieldHalfAngle() == 0.) {
frontHalfHeight = radius / fVP.GetZoomFactor();
} else {
// Code from G4ViewParameters adapted to the different zoom behavior in TSG (angle)
frontHalfHeight = pnear * std::tan(fVP.GetFieldHalfAngle() / fVP.GetZoomFactor());
}
return 2 * frontHalfHeight;
}
protected:
class Messenger: public G4VVisCommand {
public:
@@ -473,6 +513,7 @@ protected:
Messenger() {
G4UIparameter* parameter;
//////////////////////////////////////////////////////////
/// /vis/tsg/export : ////////////////////////////////////
//////////////////////////////////////////////////////////
write_scene = new G4UIcommand("/vis/tsg/export", this);
write_scene->SetGuidance("Write the content of the current viewer in a file at various formats.");
@@ -490,15 +531,15 @@ protected:
parameter = new G4UIparameter("format",'s',true);
parameter->SetDefaultValue("gl2ps_eps");
write_scene->SetParameter (parameter);
write_scene->SetParameter(parameter);
parameter = new G4UIparameter("file",'s',true);
parameter->SetDefaultValue("out.eps");
write_scene->SetParameter (parameter);
write_scene->SetParameter(parameter);
parameter = new G4UIparameter ("do_transparency", 'b', true);
parameter->SetDefaultValue ("true");
write_scene->SetParameter (parameter);
parameter->SetDefaultValue("true");
write_scene->SetParameter(parameter);
}
virtual ~Messenger() {
@@ -514,7 +555,7 @@ protected:
}
G4ToolsSGViewer* tsg_viewer = dynamic_cast<G4ToolsSGViewer*>(viewer);
if(!tsg_viewer) {
G4cout << "G4ToolsSGViewer::SetNewValue:"
G4cout << "G4ToolsSGViewer::Messenger::SetNewValue:"
<< " current viewer is not a G4ToolsSGViewer." << G4endl;
return;
}
@@ -128,3 +128,7 @@ if(WIN32)
geant4_module_sources(G4ToolsSG PUBLIC_HEADERS G4ToolsSGWindowsZB.hh SOURCES G4ToolsSGWindowsZB.cc)
geant4_module_compile_definitions(G4ToolsSG PUBLIC G4VIS_USE_TOOLSSG_WINDOWS_ZB)
endif()
if(GEANT4_USE_VTK)
geant4_module_compile_definitions(G4ToolsSG PRIVATE TOOLS_USE_GL_VERSION_3_2)
endif()
@@ -200,10 +200,16 @@ void G4ToolsSGSceneHandler::ClearStore ()
EstablishBaseNodes();
}
#include "G4ToolsSGViewer.hh"
void G4ToolsSGSceneHandler::ClearTransientStore ()
{
fpTransient2DObjects.clear();
fpTransient3DObjects.clear();
if(fpViewer) {
G4ToolsSG_viewer* tsg_viewer = dynamic_cast<G4ToolsSG_viewer*>(fpViewer);
if(tsg_viewer) tsg_viewer->EmitWindowRender();
}
}
void G4ToolsSGSceneHandler::AddPrimitive(const G4Polyline& a_polyline)
@@ -290,11 +296,12 @@ void G4ToolsSGSceneHandler::AddPrimitive (const G4Polymarker& a_polymarker)
switch (a_polymarker.GetMarkerType()) {
default:
case G4Polymarker::dots:{
//::printf("debug : GB : Add Markers : +++++++++++++++++++++++++++++++++++++++++++ : dots\n");
tools::sg::draw_style* ds = new tools::sg::draw_style;
ds->style = tools::sg::draw_points;
ds->point_size = 1;
ds->point_size = markerSize;
ds->point_smooth = fpViewer->GetViewParameters().IsDotsSmooth()?true:false;
currentNode->add(ds);
tools::sg::vertices* vtxs = new tools::sg::vertices;
vtxs->mode = tools::gl::points();
{for (const auto& i : a_polymarker) {
@@ -303,7 +310,6 @@ void G4ToolsSGSceneHandler::AddPrimitive (const G4Polymarker& a_polymarker)
currentNode->add(vtxs);
}break;
case G4Polymarker::circles:{
//::printf("debug : GB : Add Markers : +++++++++++++++++++++++++++++++++++++++++++ : circles\n");
{tools::sg::markers* markers = new tools::sg::markers;
G4double diameter = markerSize; // OK for "screen-size" (the usual case)
if (markerSizeType == G4VSceneHandler::world ) {
@@ -311,14 +317,13 @@ void G4ToolsSGSceneHandler::AddPrimitive (const G4Polymarker& a_polymarker)
diameter *= fpScene->GetExtent().GetExtentRadius()/scale;
}
markers->size = diameter;
markers->style = tools::sg::marker_circle_line;
markers->style = tools::sg::marker_circle_filled;
for (const auto& i : a_polymarker) {
markers->add(float(i.x()),float(i.y()),float(i.z()));
}
currentNode->add(markers);}
}break;
case G4Polymarker::squares:{
//::printf("debug : GB : Add Markers : +++++++++++++++++++++++++++++++++++++++++++ : square\n");
{tools::sg::markers* markers = new tools::sg::markers;
G4double side = markerSize; // OK for "screen-size" (the usual case)
if (markerSizeType == G4VSceneHandler::world ) {
@@ -326,7 +331,7 @@ void G4ToolsSGSceneHandler::AddPrimitive (const G4Polymarker& a_polymarker)
side *= fpScene->GetExtent().GetExtentRadius()/scale;
}
markers->size = side;
markers->style = tools::sg::marker_square_line;
markers->style = tools::sg::marker_square_filled;
for (const auto& i : a_polymarker) {
markers->add(float(i.x()),float(i.y()),float(i.z()));
}
@@ -495,9 +500,9 @@ void G4ToolsSGSceneHandler::AddPrimitive(const G4Polyhedron& a_polyhedron)
if(isAuxilaryEdgeVisible||edgeFlag[3]>0)insertIfNew(Line(vertex[3],vertex[0]));
} else {
G4cerr
<< "ERROR: polyhedron face with unexpected number of edges (" << nEdges << ')'
<< "\n Tag: " << fpModel->GetCurrentTag()
<< G4endl;
<< "G4ToolsSGSceneHandler::AddPrimitive(G4Polyhedron): WARNING:"
<< "\n G4Polyhedron facet with unexpected number of edges (" << nEdges << ")."
<< G4endl;
return;
}
} while (notLastFace);
@@ -774,6 +779,7 @@ class plots_cbk : public tools::sg::ecbk {
TOOLS_CBK(plots_cbk,plots_cbk,tools::sg::ecbk)
public:
virtual tools::sg::return_action action() {
if(!m_event) return tools::sg::return_none;
if(const tools::sg::size_event* sz_evt = tools::sg::event_cast<tools::sg::event,tools::sg::size_event>(*m_event)){
m_plots.adjust_size(sz_evt->width(),sz_evt->height());
m_event_action->set_done(true);
+4
View File
@@ -6,6 +6,10 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2025-09-03 John Allison (visVtk-V11-03-00)
- G4VtkSceneHandler::ClearStore:
- Clear both stores.
## 2024-10-17 John Allison (visVtk-V11-02-07)
- G4VtkMessenger.cc:
- Added x3d to /vis/vtk/export format parameter guidance.
@@ -184,6 +184,7 @@ void G4VtkSceneHandler::ClearStore()
G4cout << "G4VtkSceneHandler::ClearStore()" << G4endl;
#endif
store.Clear();
transientStore.Clear();
}
void G4VtkSceneHandler::ClearTransientStore()
+103
View File
@@ -6,6 +6,109 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2025-11-07 John Allison (visman-V11-03-24)
- G4VisExecutive.icc:
- Remove all references to HepRep.
- G4VisManager.cc:
- Substitute G4FRSCENEHANDLER for G4HepRepFile in a comment about ClearTransientStore.
- G4VisCommandsSceneAdd.cc, G4VisCommandsTouchable.cc, G4VisCommandsViewer.cc:
- Remove a mention of HepRep in command guidance.
## 2025-11-05 John Allison (visman-V11-03-23)
- G4VSceneHandler.cc: Fix another Coverity warning.
## 2025-11-03 John Allison (visman-V11-03-22)
- G4VisExecutive.icc:
- Remove all references to Qt3D.
## 2025-11-03 John Allison (visman-V11-03-21)
- G4VSceneHandler.cc: Fix Coverity warning.
## 2025-10-31 Andrea Barresi (visman-V11-03-20)
- G4VViewer:
- Added UpdateGUIControlWidgets, UpdateGUIDrawingStyle, UpdateGUIProjectionStyle,
and UpdateGUITransparencySlider methods to update the GUI control widgets
-G4VisCommandsViewer:
- Added UpdateGUIControlWidgets to G4VisCommandViewerSelect::SetNewValue to
update the control widget when the viewer is changed
## 2025-10-24 Guy Barrand (visman-V11-03-19)
- G4VisExecutive.icc: Vtk: remove "#undef G4VIS_USE_TOOLSSG_QT_GLES" within the
first "#ifdef G4VIS_USE_VTK" block, since ToolsSG-GLES compiles now with OpenGL-3.2
if Vtk is choosen, and then can cowork with Vtk at run time.
Remove also the "#undef G4VIS_USE_TOOLSSG_[X11,XT,WINDOWS]_GLES" irrelevant with
a Qt build.
## 2025-10-15 John Allison (visman-V11-03-18)
- Smooth dots default and end-of-run drawing.
- Following updates to ToolsSG, its behaviour matches OGL's.
- Change dotsSmooth initialisation so that dots are typically drawn as
filled circles.
- We can remove temporary "workaround" in G4VisManager.
- G4ViewParameters.cc:
- fDotsSmooth initialised to true.
- G4VisCommandsViewerSet.cc:
- Improved guidance for vis/viewer/set/dotsSmooth:
- "Smooth" typically means rounded, i.e., dots drawn as filled circles.
The vis system is configured by default to draw smooth dots. This may
be switched off with "/vis/viewer/set/dotsSmooth false" - typically
this will result in square dots.
- G4VisManager.cc:
- Remove temporary "workaround" RefreshView() from G4VisManager::EndDraw(2D)().
## 2025-10-01 John Allison (visman-V11-03-17)
- Add /vis/viewer/set/dotsSize and dotsSmooth.
- G4PolyMarkers have a MarkerType that can be dots, circles, or squares. If
the MarkerType is G4PolyMarker::dots, the size is determined _only_ by
G4ViewParameters::GetDotsSize(), set with /vis/viewer/set/dotsSize. This
policy is enforced in G4VSceneHandler::GetMarkerSize(). Other types of
marker may be changed in size with /vis/viewer/set/globalMarkerScale.
- *Individual scene handlers should use GetMarkerSize() for _all_
types of marker*.
- *Thus, dots size can no longer be changed with /vis/viewer/set/globalMarkerScale.
Use /vis/viewer/set/dotsSize instead*.
- G4ViewParameters:
- Add data members fDotsSize and fDotsSmooth and their access functions.
- Also augment operator>> and !=, PrintDifferences and the command dumping
routines (for /vis/viewer/save) as apppropriate.
- Change GetZoomToCursor() to IsZoomToCursor() to follow convention
for Boolean parameters.
- G4VisCommandsViewerSet:
- Add /vis/viewer/set/dotsSize and dotsSmooth.
- Follow change in G4ViewParameters: GetZoomToCursor() to IsZoomToCursor().
- G4VSceneHandler.cc:
- Enforce the above policy in G4VSceneHandler::GetMarkerSize().
- Remove statements such as dots.SetSize(G4VMarker::screen,1.), which
now have no effect for a polymarker of dots.
- G4VViewer:
- Follow change in G4ViewParameters: GetZoomToCursor() to IsZoomToCursor().
## 2025-08-23 Andrea Barresi (visman-V11-03-16)
- G4VViewer.cc:
- Changed Shift key modifier behavior to enable ZoomToCursor while pressed.
## 2025-08-22 John Allison (visman-V11-03-15)
- G4VisManager.cc:
- EndDraw() and EndDraw2D(): Refresh view at end of drawing.
## 2025-08-04 John Allison (visman-V11-03-14)
- G4VisExecutive.icc:
- Introduce nickname/alias TSGZB for appropriate driver by priority.
- G4VisCommands.cc:
- Always print available drivers when using /vis/list.
## 2025-06-18 Andrea Barresi (visman-V11-03-13)
- G4ViewParameters:
- Added zoomToCursor parameter to control the zoom behavior of the mouse wheel.
- G4VisCommandsViewerSet:
- Added command /vis/viewer/set/zoomToCursor to set the zoomToCursor VP
- G4VViewer:
- Added ZoomFromMouseWheel function to control mouse wheel behavior
- Added virtual methods to get window size, render area size and scene near width
- Implemented ZoomToCursor algorithm to zoom toward the mouse cursor.
- General optimization of zoom behavior with mouse wheel. Added Shift key modifier
to change zoom mode in perspective projection from Dolly (default) to zoomFactor.
## 2025-06-08 John Allison (visman-V11-03-12)
- G4ViewParameters.cc:
- Fix for bug report 2460.
@@ -188,6 +188,13 @@ public: // With description
const G4SceneTreeItem& GetSceneTree() {return fSceneTree;}
G4SceneTreeItem& AccessSceneTree() {return fSceneTree;}
void UpdateGUISceneTree(); // A utility
//GUI update functions
void UpdateGUIControlWidgets();
void UpdateGUIDrawingStyle();
void UpdateGUIProjectionStyle();
void UpdateGUITransparencySlider();
const G4int fMaxAllTouchables = 10000; // Limits memory to about 50 MB per PV model
G4bool fCurtailDescent = false; // Flag to curtail descent into PV model for scene tree
@@ -230,6 +237,11 @@ public: // With description
void ProcessTransients ();
// Re-draws transients only
void ZoomFromMouseWheel(G4double delta, G4bool shift = false, G4double xPos = 0, G4double yPos = 0);
virtual G4bool GetWindowSize(unsigned int& a_w,unsigned int& a_h) {a_w = 0; a_h = 0; return false;}
virtual G4double GetSceneNearWidth() {return 0;}
protected:
//////////////////////////////////////////////////////////////
@@ -201,6 +201,9 @@ public: // With description
const std::vector<G4ModelingParameters::PVNameCopyNo>& GetSpecialMeshVolumes () const;
G4double GetTransparencyByDepth () const;
G4int GetTransparencyByDepthOption () const;
G4bool IsZoomToCursor () const;
G4bool IsDotsSmooth () const;
G4double GetDotsSize () const;
// Here Follow functions to evaluate useful quantities as a
// function of the radius of the Bounding Extent of the object being
@@ -281,6 +284,9 @@ public: // With description
void SetSpecialMeshVolumes (const std::vector<G4ModelingParameters::PVNameCopyNo>&);
void SetTransparencyByDepth (G4double);
void SetTransparencyByDepthOption (G4int);
void SetZoomToCursor (G4bool);
void SetDotsSmooth (G4bool);
void SetDotsSize (G4double);
// Command dumping functions.
// For camera commands we need to provide the standard target point from
@@ -371,6 +377,9 @@ private:
std::vector<G4ModelingParameters::PVNameCopyNo> fSpecialMeshVolumes; // If empty, all meshes.
G4double fTransparencyByDepth; // Transparency ~= (geometry depth) - fTransparencyByDepth
G4int fTransparencyByDepthOption; // Its option
G4bool fZoomToCursor; // If possible zoom to cursor with mouse wheel
G4bool fDotsSmooth; // Use glEnable(GL_POINT_SMOOTH) or equivalent for dots if available
G4double fDotsSize; // Size of G4Polymarker::dots
enum { // Constants for geometry mask in ParseGeometry and related functions.
fNoValue = 0,
@@ -253,6 +253,18 @@ inline G4int G4ViewParameters::GetTransparencyByDepthOption () const {
return fTransparencyByDepthOption;
}
inline G4bool G4ViewParameters::IsZoomToCursor () const {
return fZoomToCursor;
}
inline G4bool G4ViewParameters::IsDotsSmooth () const {
return fDotsSmooth;
}
inline G4double G4ViewParameters:: GetDotsSize () const {
return fDotsSize;
}
inline void
G4ViewParameters::SetDrawingStyle (G4ViewParameters::DrawingStyle style) {
fDrawingStyle = style;
@@ -462,3 +474,15 @@ inline void G4ViewParameters::SetTransparencyByDepth (G4double transparencyByDep
inline void G4ViewParameters::SetTransparencyByDepthOption (G4int transparencyByDepthOption) {
fTransparencyByDepthOption = transparencyByDepthOption;
}
inline void G4ViewParameters::SetZoomToCursor (G4bool zoomToCursor){
fZoomToCursor = zoomToCursor;
}
inline void G4ViewParameters::SetDotsSmooth (G4bool dotsSmooth){
fDotsSmooth = dotsSmooth;
}
inline void G4ViewParameters::SetDotsSize (G4double dotsSize){
fDotsSize = dotsSize;
}
@@ -60,6 +60,8 @@ private:
G4UIcmdWithAString* fpCommandCutawayMode;
G4UIcommand* fpCommandDefaultColour;
G4UIcommand* fpCommandDefaultTextColour;
G4UIcmdWithADouble* fpCommandDotsSize;
G4UIcmdWithABool* fpCommandDotsSmooth;
G4UIcmdWithABool* fpCommandEdge;
G4UIcommand* fpCommandExplodeFactor;
G4UIcmdWithADouble* fpCommandGlobalMarkerScale;
@@ -95,6 +97,7 @@ private:
G4UIcommand* fpCommandTimeWindowEndTime;
G4UIcmdWithADouble* fpCommandTimeWindowFadeFactor;
G4UIcommand* fpCommandTimeWindowStartTime;
G4UIcmdWithABool* fpCommandZoomToCursor;
};
#endif
@@ -41,7 +41,6 @@
// Not needing external packages or libraries...
#include "G4ASCIITree.hh" // no_geant4_module_check
#include "G4DAWNFILE.hh" // no_geant4_module_check
#include "G4HepRepFile.hh" // no_geant4_module_check
#include "G4RayTracer.hh" // no_geant4_module_check
#include "G4VRML2File.hh" // no_geant4_module_check
#include "G4GMocrenFile.hh" // no_geant4_module_check
@@ -89,10 +88,6 @@
#include "G4RayTracerQt.hh" // no_geant4_module_check
#endif
#ifdef G4VIS_USE_QT3D
#include "G4Qt3D.hh" // no_geant4_module_check
#endif
#ifdef G4VIS_USE_TOOLSSG_X11_GLES
#include "G4ToolsSGX11GLES.hh" // no_geant4_module_check
#endif
@@ -128,10 +123,6 @@
#ifdef G4VIS_USE_VTK
#include "G4Vtk.hh" // no_geant4_module_check
#include "G4VtkOffscreen.hh" // no_geant4_module_check
#undef G4VIS_USE_TOOLSSG_X11_GLES
#undef G4VIS_USE_TOOLSSG_XT_GLES
#undef G4VIS_USE_TOOLSSG_QT_GLES
#undef G4VIS_USE_TOOLSSG_WINDOWS_GLES
#undef G4VIS_USE_OPENGLQT
#undef G4VIS_USE_OPENGLXM
#undef G4VIS_USE_OPENGLX
@@ -326,8 +317,6 @@ void G4VisExecutive::SetDefaultsByBuildFlags()
#elif defined G4VIS_USE_TOOLSSG_QT_ZB || G4VIS_USE_TOOLSSG_X11_ZB ||\
G4VIS_USE_TOOLSSG_XT_ZB || G4VIS_USE_TOOLSSG_WINDOWS_ZB
fDefaultGraphicsSystemName = "TSG";
#elif defined G4VIS_USE_QT3D
fDefaultGraphicsSystemName = "Qt3D";
#else
// Choose a graphics system not needing external packages or libraries
fDefaultGraphicsSystemName = "TSG_OFFSCREEN";
@@ -342,7 +331,6 @@ void G4VisExecutive::RegisterGraphicsSystems () {
// Graphics Systems not needing external packages or libraries...
RegisterGraphicsSystem (new G4ASCIITree);
RegisterGraphicsSystem (new G4DAWNFILE);
RegisterGraphicsSystem (new G4HepRepFile);
RegisterGraphicsSystem (new G4RayTracer);
RegisterGraphicsSystem (new G4VRML2File);
RegisterGraphicsSystem (new G4GMocrenFile);
@@ -441,10 +429,6 @@ void G4VisExecutive::RegisterGraphicsSystems () {
RegisterGraphicsSystem(new G4RayTracerQt);
#endif
#ifdef G4VIS_USE_QT3D
RegisterGraphicsSystem(new G4Qt3D);
#endif
#ifdef G4VIS_USE_TOOLSSG_X11_GLES
G4VGraphicsSystem* tsg_x11_gles = new G4ToolsSGX11GLES;
RegisterGraphicsSystem(tsg_x11_gles);
@@ -505,15 +489,27 @@ void G4VisExecutive::RegisterGraphicsSystems () {
#ifdef G4VIS_USE_TOOLSSG_QT_GLES
tsg_qt_gles->AddNickname("TSG");
tsg_qt_gles->AddNickname("OGL");
#ifdef G4VIS_USE_TOOLSSG_QT_ZB
tsg_qt_zb->AddNickname("TSGZB");
#endif
#elif defined(G4VIS_USE_TOOLSSG_XT_GLES)
tsg_xt_gles->AddNickname("TSG");
tsg_xt_gles->AddNickname("OGL");
#ifdef G4VIS_USE_TOOLSSG_XT_ZB
tsg_xt_zb->AddNickname("TSGZB");
#endif
#elif defined(G4VIS_USE_TOOLSSG_X11_GLES)
tsg_x11_gles->AddNickname("TSG");
tsg_x11_gles->AddNickname("OGL");
#ifdef G4VIS_USE_TOOLSSG_X11_ZB
tsg_x11_zb->AddNickname("TSGZB");
#endif
#elif defined(G4VIS_USE_TOOLSSG_WINDOWS_GLES)
tsg_windows_gles->AddNickname("TSG");
tsg_windows_gles->AddNickname("OGL");
#ifdef G4VIS_USE_TOOLSSG_WINDOWS_ZB
tsg_windows_zb->AddNickname("TSGZB");
#endif
#else
#ifdef G4VIS_USE_TOOLSSG_QT_ZB
tsg_qt_zb->AddNickname("TSG");
@@ -637,7 +637,6 @@ void G4VSceneHandler::RequestPrimitives (const G4VSolid& solid)
// entry, something we would want to avoid.
dots.SetVisAttributes(fpVisAttribs);
dots.SetMarkerType(G4Polymarker::dots);
dots.SetSize(G4VMarker::screen,1.);
G4int numberOfCloudPoints = GetNumberOfCloudPoints(fpVisAttribs);
if (numberOfCloudPoints <= 0) numberOfCloudPoints = vp.GetNumberOfCloudPoints();
for (G4int i = 0; i < numberOfCloudPoints; ++i) {
@@ -1289,6 +1288,17 @@ G4double G4VSceneHandler::GetMarkerSize
(const G4VMarker& marker,
G4VSceneHandler::MarkerSizeType& markerSizeType)
{
// Deal with G4Polymarker::dots
const auto& vp = fpViewer->GetViewParameters();
try {
const auto& polymarker = dynamic_cast<const G4Polymarker&>(marker);
if (polymarker.GetMarkerType() == G4Polymarker::dots) {
return vp.GetDotsSize();
}
}
catch (const std::bad_cast&) {} // Continue
// Other markers
G4bool userSpecified = marker.GetWorldSize() || marker.GetScreenSize();
const G4VMarker& defaultMarker =
fpViewer -> GetViewParameters().GetDefaultMarker();
@@ -1533,7 +1543,6 @@ void G4VSceneHandler::Draw3DRectMeshAsDots(const G4Mesh& mesh)
dots.SetInfo(name);
dots.SetVisAttributes(visAtts);
dots.SetMarkerType(G4Polymarker::dots);
dots.SetSize(G4VMarker::screen,1.);
// Enter empty polymarker into the map
dotsByMaterial[material] = dots;
// Now fill it in situ
@@ -1815,7 +1824,6 @@ void G4VSceneHandler::DrawTetMeshAsDots(const G4Mesh& mesh)
G4Polymarker dots;
dots.SetVisAttributes(visAtts);
dots.SetMarkerType(G4Polymarker::dots);
dots.SetSize(G4VMarker::screen,1.);
dots.SetInfo(name);
// Enter empty polymarker into the map
dotsByMaterial[material] = dots;
@@ -124,6 +124,7 @@ void G4VViewer::ProcessView()
fSceneHandler.ClearStore();
fSceneHandler.ProcessScene();
UpdateGUISceneTree();
UpdateGUIControlWidgets();
timer.Stop();
fKernelVisitElapsedTimeSeconds = timer.GetRealElapsed();
}
@@ -140,6 +141,78 @@ void G4VViewer::ProcessTransients()
}
}
void G4VViewer::ZoomFromMouseWheel(G4double delta, G4bool shift, G4double xPos, G4double yPos) {
G4double sceneWidth = GetSceneNearWidth();
unsigned int winWidth = 0, winHeight = 0;
G4bool winSizeOk = GetWindowSize(winWidth, winHeight);
if ((fVP.IsZoomToCursor() || shift) && sceneWidth > 0 && winSizeOk) {
// Compute mouse position in scene coordinates
G4double minWidth = winWidth > winHeight ? winHeight : winWidth;
G4double px = xPos - G4double(winWidth) / 2;
G4double py = -(yPos - G4double(winHeight) / 2);
G4double xi = px * sceneWidth / minWidth;
G4double yi = py * sceneWidth / minWidth;
// ZoomToCursor enabled
if (fVP.GetFieldHalfAngle() == 0.) {
// Orthographic projection
G4double zoomFactor = 1. + std::abs(double(delta)) / 1200;
if (delta < 0) zoomFactor = 1. / zoomFactor;
G4double xf = xi / zoomFactor;
G4double yf = yi / zoomFactor;
G4double deltaX = xf - xi;
G4double deltaY = yf - yi;
fVP.MultiplyZoomFactor(zoomFactor);
fVP.IncrementPan(-deltaX, -deltaY, 0);
}
else {
// Perspective projection
G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
if (radius <= 0.) radius = 1.;
const G4double cameraDistance = fVP.GetCameraDistance(radius);
const G4double pnear = fVP.GetNearDistance(cameraDistance, radius);
G4double deltaDolly = 0.1 * cameraDistance * std::abs(delta) / 120;
if (delta < 0) deltaDolly = -deltaDolly;
G4double deltaX = -xi * deltaDolly / pnear;
G4double deltaY = -yi * deltaDolly / pnear;
// This condition prevents going too deeply into the scene, but what if there are volumes with very different sizes?
// if(deltaDolly<0 || cameraDistance > radius / std::sin(fVP.GetFieldHalfAngle()) * 1e-2)
fVP.IncrementDolly(deltaDolly);
fVP.IncrementPan(-deltaX, -deltaY, 0);
}
}
else {
// ZoomToCursor disabled
if (fVP.GetFieldHalfAngle() == 0.) {
// Orthographic projection
G4double zoomFactor = 1. + std::abs(double(delta)) / 1200;
if (delta < 0) zoomFactor = 1. / zoomFactor;
fVP.MultiplyZoomFactor(zoomFactor);
}
else {
// Perspective projection
G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
if (radius <= 0.) radius = 1.;
const G4double cameraDistance = fVP.GetCameraDistance(radius);
G4double deltaDolly = 0.1 * cameraDistance * std::abs(delta) / 120;
if (delta < 0) deltaDolly = -deltaDolly;
// This condition prevents going too deeply into the scene, but what if there are volumes with very different sizes?
//if (deltaDolly < 0 || cameraDistance > radius / std::sin(fVP.GetFieldHalfAngle()) * 1e-2)
fVP.IncrementDolly(deltaDolly);
}
}
}
void G4VViewer::SetViewParameters(const G4ViewParameters& vp)
{
fVP = vp;
@@ -246,6 +319,30 @@ void G4VViewer::UpdateGUISceneTree()
if (uiWindow) uiWindow->UpdateSceneTree(fSceneTree);
}
void G4VViewer::UpdateGUIControlWidgets() {
this->UpdateGUIDrawingStyle();
this->UpdateGUIProjectionStyle();
this->UpdateGUITransparencySlider();
}
void G4VViewer::UpdateGUIDrawingStyle()
{
G4UImanager* UI = G4UImanager::GetUIpointer();
auto uiWindow = dynamic_cast<G4VInteractiveSession*>(UI->GetG4UIWindow());
if (uiWindow) uiWindow->UpdateDrawingStyle(fVP.GetDrawingStyle());
}
void G4VViewer::UpdateGUIProjectionStyle() {
G4UImanager* UI = G4UImanager::GetUIpointer();
auto uiWindow = dynamic_cast<G4VInteractiveSession*>(UI->GetG4UIWindow());
if (uiWindow) uiWindow->UpdateProjectionStyle(fVP.GetFieldHalfAngle() == 0 ? 0 : 1);
}
void G4VViewer::UpdateGUITransparencySlider() {
G4UImanager* UI = G4UImanager::GetUIpointer();
auto uiWindow = dynamic_cast<G4VInteractiveSession*>(UI->GetG4UIWindow());
if (uiWindow)
uiWindow->UpdateTransparencySlider(fVP.GetTransparencyByDepth(), fVP.GetTransparencyByDepthOption());
}
void G4VViewer::InsertModelInSceneTree(G4VModel* model)
{
const auto& modelType = model->GetType();
@@ -88,7 +88,10 @@ G4ViewParameters::G4ViewParameters ():
fSpecialMeshRendering(false),
fSpecialMeshRenderingOption(meshAsDefault),
fTransparencyByDepth(0.),
fTransparencyByDepthOption(1)
fTransparencyByDepthOption(1),
fZoomToCursor(false),
fDotsSmooth(true),
fDotsSize(1.)
{
// Pick up default no of sides from G4Polyhedron.
// Note that this parameter is variously called:
@@ -454,6 +457,22 @@ G4String G4ViewParameters::DrawingStyleCommands() const
oss << ' ' << volume.GetName() << ' ' << volume.GetCopyNo();
}
oss << "\n/vis/viewer/set/zoomToCursor ";
if (fZoomToCursor) {
oss << "true";
} else {
oss << "false";
}
oss << "\n/vis/viewer/set/dotsSmooth ";
if (fDotsSmooth) {
oss << "true";
} else {
oss << "false";
}
oss << "\n/vis/viewer/set/dotsSize " << fDotsSize;
oss << std::endl;
return oss.str();
@@ -785,7 +804,10 @@ void G4ViewParameters::PrintDifferences (const G4ViewParameters& v) const {
(fPicking != v.fPicking) ||
(fRotationStyle != v.fRotationStyle) ||
(fTransparencyByDepth != v.fTransparencyByDepth) ||
(fTransparencyByDepthOption != v.fTransparencyByDepthOption)
(fTransparencyByDepthOption != v.fTransparencyByDepthOption) ||
(fZoomToCursor != v.fZoomToCursor) ||
(fDotsSmooth != v.fDotsSmooth) ||
(fDotsSize != v.fDotsSize)
)
G4cout << "Difference in 1st batch." << G4endl;
@@ -1089,6 +1111,16 @@ std::ostream& operator << (std::ostream& os, const G4ViewParameters& v) {
os << "\nTransparency by depth: " << v.fTransparencyByDepth
<< ", option: " << v.fTransparencyByDepthOption;
os << "\nZoom to cursor requested: ";
if (v.fZoomToCursor) os << "true";
else os << "false";
os << "\nSmooth dots requested: ";
if (v.fDotsSmooth) os << "true";
else os << "false";
os << "\nDots size: " << v.fDotsSize;
return os;
}
@@ -1137,7 +1169,10 @@ G4bool G4ViewParameters::operator != (const G4ViewParameters& v) const {
(fSpecialMeshRendering != v.fSpecialMeshRendering) ||
(fSpecialMeshRenderingOption != v.fSpecialMeshRenderingOption) ||
(fTransparencyByDepth != v.fTransparencyByDepth) ||
(fTransparencyByDepthOption != v.fTransparencyByDepthOption)
(fTransparencyByDepthOption != v.fTransparencyByDepthOption) ||
(fZoomToCursor != v.fZoomToCursor) ||
(fDotsSmooth != v.fDotsSmooth) ||
(fDotsSize != v.fDotsSize)
)
return true;
@@ -218,7 +218,7 @@ void G4VisCommandList::SetNewValue (G4UIcommand*, G4String newValue)
G4VisManager::PrintAvailableVerbosity(G4cout);
G4cout << G4endl;
fpVisManager->PrintAvailableGraphicsSystems(verbosity);
fpVisManager->PrintAvailableGraphicsSystems(G4VisManager::all);
G4cout << G4endl;
fpVisManager->PrintAvailableModels(verbosity);
G4cout << G4endl;
@@ -3117,8 +3117,7 @@ G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume () {
"\nFor example, \"/Shap/\" adds \"Shape1\" and \"Shape2\".");
fpCommand -> SetGuidance
("It may help to see a textual representation of the geometry hierarchy of"
"\nthe worlds. Try \"/vis/drawTree [worlds]\" or one of the driver/browser"
"\ncombinations that have the required functionality, e.g., HepRepFile.");
"\nthe worlds. Try \"/vis/drawTree [worlds]\".");
fpCommand -> SetGuidance
("If clip-volume-type is specified, the subsequent parameters are used to"
"\nto define a clipping volume. For example,"
@@ -96,8 +96,7 @@ G4VisCommandsTouchable::G4VisCommandsTouchable()
"\nFor example, \"/Shap/\" matches \"Shape1\" and \"Shape2\".");
fpCommandFindPath -> SetGuidance
("It may help to see a textual representation of the geometry hierarchy of"
"\nthe worlds. Try \"/vis/drawTree [worlds]\" or one of the driver/browser"
"\ncombinations that have the required functionality, e.g., HepRep.");
"\nthe worlds. Try \"/vis/drawTree [worlds]\".");
G4UIparameter* parameter;
parameter = new G4UIparameter ("physical-volume-name", 's', omitable = true);
parameter -> SetDefaultValue ("world");
@@ -153,8 +153,7 @@ G4VisCommandViewerCentreOn::G4VisCommandViewerCentreOn () {
"\nFor example, \"/Shap/\" matches \"Shape1\" and \"Shape2\".");
fpCommandCentreAndZoomInOn->SetGuidance
("It may help to see a textual representation of the geometry hierarchy of"
"\nthe worlds. Try \"/vis/drawTree [worlds]\" or one of the driver/browser"
"\ncombinations that have the required functionality, e.g., HepRepFile.");
"\nthe worlds. Try \"/vis/drawTree [worlds]\"");
fpCommandCentreAndZoomInOn->SetGuidance
("If there are more than one matching physical volumes they will all be"
"\nincluded. If this is not what you want, and what you want is to centre on a"
@@ -2178,6 +2177,7 @@ void G4VisCommandViewerSelect::SetNewValue (G4UIcommand*, G4String newValue) {
// Update GUI scene tree (make sure it's in sync)
viewer->UpdateGUISceneTree();
viewer->UpdateGUIControlWidgets();
}
////////////// /vis/viewer/update ///////////////////////////////////////
@@ -180,6 +180,21 @@ fViewpointVector (G4ThreeVector(0.,0.,1.))
parameter -> SetDefaultValue (1.);
fpCommandDefaultTextColour -> SetParameter (parameter);
fpCommandDotsSize = new G4UIcmdWithADouble("/vis/viewer/set/dotsSize", this);
fpCommandDotsSize->SetGuidance("Set dots size.");
fpCommandDotsSize->SetParameterName("dots-size", omitable=true);
fpCommandDotsSize->SetDefaultValue(1.);
fpCommandDotsSmooth = new G4UIcmdWithABool("/vis/viewer/set/dotsSmooth", this);
fpCommandDotsSmooth->SetGuidance("True/false to enable/disable smooth dots (if available).");
fpCommandDotsSmooth->SetGuidance
("\"Smooth\" typically means rounded, i.e., dots drawn as filled circles."
"\nThe vis system is configured by default to draw smooth dots. This may"
"\nbe switched off with \"/vis/viewer/set/dotsSmooth false\" - typically"
"\nthis will result in square dots.");
fpCommandDotsSmooth->SetParameterName("dots-smooth-enabled", omitable = true);
fpCommandDotsSmooth->SetDefaultValue(true);
fpCommandEdge = new G4UIcmdWithABool("/vis/viewer/set/edge",this);
fpCommandEdge->SetGuidance
("Edges become visible/invisible in surface mode.");
@@ -652,9 +667,15 @@ fViewpointVector (G4ThreeVector(0.,0.,1.))
parameter = new G4UIparameter ("time-range-unit", 's', omitable = true);
parameter->SetDefaultValue("ns");
fpCommandTimeWindowStartTime->SetParameter(parameter);
fpCommandZoomToCursor = new G4UIcmdWithABool("/vis/viewer/set/zoomToCursor", this);
fpCommandZoomToCursor->SetGuidance("True/false to enable/disable zoom to cursor with mouse wheel");
fpCommandZoomToCursor->SetParameterName("zoomToCursor-enabled", omitable = true);
fpCommandZoomToCursor->SetDefaultValue(true);
}
G4VisCommandsViewerSet::~G4VisCommandsViewerSet() {
delete fpCommandZoomToCursor;
delete fpCommandTimeWindowStartTime;
delete fpCommandTimeWindowFadeFactor;
delete fpCommandTimeWindowEndTime;
@@ -685,6 +706,8 @@ G4VisCommandsViewerSet::~G4VisCommandsViewerSet() {
delete fpCommandHiddenEdge;
delete fpCommandGlobalMarkerScale;
delete fpCommandGlobalLineWidthScale;
delete fpCommandDotsSmooth;
delete fpCommandDotsSize;
delete fpCommandExplodeFactor;
delete fpCommandEdge;
delete fpCommandDefaultTextColour;
@@ -714,8 +737,8 @@ G4String G4VisCommandsViewerSet::GetCurrentValue(G4UIcommand* command) {
}
else {
return "";
}
return "";
}
}
void G4VisCommandsViewerSet::SetNewValue
@@ -968,6 +991,21 @@ void G4VisCommandsViewerSet::SetNewValue
}
}
else if (command == fpCommandDotsSize) {
G4double dotsSize = fpCommandDotsSize->GetNewDoubleValue(newValue);
vp.SetDotsSize(dotsSize);
if (verbosity >= G4VisManager::confirmations) {
G4cout << "Dots size changed to " << vp.GetDotsSize() << G4endl;
}
}
else if (command == fpCommandDotsSmooth) {
vp.SetDotsSmooth(command->ConvertToBool(newValue));
if (verbosity >= G4VisManager::confirmations) {
G4cout << "DotsSmooth mode changed to " << vp.IsDotsSmooth() << G4endl;
}
}
else if (command == fpCommandEdge) {
G4ViewParameters::DrawingStyle existingStyle = vp.GetDrawingStyle();
if (G4UIcommand::ConvertToBool(newValue)) { // true
@@ -1608,17 +1646,17 @@ void G4VisCommandsViewerSet::SetNewValue
else if (command == fpCommandTimeWindowEndTime)
{
G4String end_time_string, end_time_unit, time_range_string, time_range_unit;
std::istringstream iss(newValue);
std::istringstream iss(newValue);
iss >> end_time_string >> end_time_unit >> time_range_string >> time_range_unit;
auto endTime = command->ConvertToDimensionedDouble
(G4String(end_time_string + ' ' + end_time_unit));
auto timeRange = command->ConvertToDimensionedDouble
(G4String(time_range_string + ' ' + time_range_unit));
(G4String(time_range_string + ' ' + time_range_unit));
auto timeParameters = vp.GetTimeParameters();
timeParameters.fEndTime = endTime;
if (timeRange > 0.) {
if (timeRange > 0.) {
timeParameters.fStartTime = endTime - timeRange;
}
}
vp.SetTimeParameters(timeParameters);
if (verbosity >= G4VisManager::confirmations) {
G4cout
@@ -1667,6 +1705,13 @@ void G4VisCommandsViewerSet::SetNewValue
}
}
else if (command == fpCommandZoomToCursor) {
vp.SetZoomToCursor(command->ConvertToBool(newValue));
if (verbosity >= G4VisManager::confirmations) {
G4cout << "ZoomToCursor mode changed to " << vp.IsZoomToCursor() << G4endl;
}
}
else {
if (verbosity >= G4VisManager::errors) {
G4warn <<
@@ -1953,7 +1953,7 @@ G4ThreadFunReturnType G4VisManager::G4VisSubThread(G4ThreadFunArgType p)
// We have postponed this so that, for normal viewers like OGL, the
// previous event(s) stay on screen until this new event comes
// along. For a file-writing viewer the geometry has to be drawn.
// See, for example, G4HepRepFileSceneHandler::ClearTransientStore.
// See, for example, G4FRSCENEHANDLER::ClearTransientStore.
pVisManager->ClearTransientStoreIfMarked();
// Now draw the event...
@@ -2232,7 +2232,7 @@ void G4VisManager::EndOfEventKernel (const G4Event* currentEvent)
// We have postponed this so that, for normal viewers like OGL, the
// previous event(s) stay on screen until this new event comes
// along. For a file-writing viewer the geometry has to be drawn.
// See, for example, G4HepRepFileSceneHandler::ClearTransientStore.
// See, for example, G4FRSCENEHANDLER::ClearTransientStore.
ClearTransientStoreIfMarked();
// Keep while post processing (i.e., drawing), relinquished in EndOfEventCleanup