Visualisation and (G)UI Authors: Hajime Yoshida and Satoshi Tanaka.

Slides:



Advertisements
Similar presentations
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Advertisements

11 January 2011 Geant4 Visualization Commands J. Perl 1 DAWN OpenGL Geant4 Visualization Commands Basic Visualization Commands Makoto Asai (SLAC) slides.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
Introduction to Geant4 Visualization
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
Chapter Day 5. © 2007 Pearson Addison-Wesley. All rights reserved2-2 Agenda Day 5 Questions from last Class?? Problem set 1 Posted  Introduction on developing.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002 Getting Started.
15 Sept 2007 J. Perl Overview of Geant4 Visualization 1 HepRep/HepRApp DAWN OpenGL Overview of Geant4 Visualization Geant4 Mini-Tutorial Hebden Bridge.
Geant4 Visualization Review
12 May 2007 Geant4 Visualization Commands J. Perl 1 DAWN OpenGL Geant4 Visualization Commands Basic Visualization Commands Joseph Perl, SLAC HepRep/HepRApp.
Introduction to Geant4 Visualization
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Shading Languages By Markus Kummerer. Markus Kummerer 2 / 19 State of the Art Shading.
Abstraction: Polymorphism, pt. 1 Abstracting Objects.
Software Installation The full set of lecture notes of this Geant4 Course is available at
Chapter 3 Introduction to Event Handling and Windows Forms Applications.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
A First Program Using C#
- Circle markers produced by TAsimage: They do not match was is produced on screen. The line width is too thick. Some other markers need to be tune a bit.
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
Chapter 8: Writing Graphical User Interfaces
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
S. Guatelli, CPS Innovations, Knoxville, 13 th -21 st January Brachytherapy exercise.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Maria Grazia Pia Detector Response Acknowledgements: A. Lechner, J. Apostolakis, M. Asai, G. Cosmo, A. Howard.
S. Guatelli, M.G Pia, INFN Genova G. Cosmo, S. Guatelli, M.G Pia Salamanca, July 2002
1 Computer Graphics Week2 –Creating a Picture. Steps for creating a picture Creating a model Perform necessary transformation Lighting and rendering the.
Geant4 Visualization 1 OpenGL DAWN VRML. Visualization Visualization Seeing what one does usually helps One can visualize geometry, hits, trajectories.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Graphic Basics in C ATS 315. The Graphics Window Will look something like this.
User Application Luciano Pandola INFN-LNGS Partially based on a presentation by Maria Grazia Pia (INFN-Ge)
7 June 2005 Visualization & GGE Demo J. Perl 1 HepRep/WIRED DAWN OpenGL Geant4 Visualization & GGE Demo Joseph Perl, SLAC.
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
12 October 2006 G4Vis: Status, New Features and Issues 1 HepRep/WIRED DAWN OpenGL G4Vis: Status, New Features and Issues Geant4 Collaboration Workshop.
© TMC Computer School HC20203 VRML HIGHER DIPLOMA IN COMPUTING Chapter 2 – Basic VRML.
Maria Grazia Pia INFN Genova Salamanca, July 2002
C++ / G4MICE Course Session 5 Materials in G4MICE Units in G4MICE Visualisation in G4MICE G4MICE Modelling.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Chapter 5 Introduction to Defining Classes
In the name of God Computer Graphics.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
NoufNaief.net TA: Nouf Al-harbi.
May 20, 2005Wah-kai Ngai1 Basic Visualization Tutorial Using Geant4.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 2 – Welcome Application Introduction to Graphical.
Creating a Java Application and Applet
Geant4 examples Sébastien Incerti On behalf of the Geant4 collaboration with special thanks to Luciano Pandola, INFN.
Makoto Asai (SLAC) Getting Started MGP: added class diagram of basic user application.
Objects and Classes Start on Slide 30 for day 2 Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Much of.
Visualisation, (G)UI and Analysis The full set of lecture notes of this Geant4 Course is available at
June 4-8, G4 Paris Visualization II P. Gueye/J. Perl 1 DAWN OpenGL Geant4 Visualization Commands Basic Visualization Commands Paul Guèye, HU Courtesy:
Lesson 1 – Getting Started with App Inventor
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
In the name of God Computer Graphics.
Topics Graphical User Interfaces Using the tkinter Module
Chapter 3 Syntax, Errors, and Debugging
Chapter 3: Using Methods, Classes, and Objects
Visualisation and (G)UI
Basics of a user application
Geant4 Visualization Commands
.NET and .NET Core 7. XAML Pan Wuming 2017.
The full set of lecture notes of this Geant4 Course is available at
Visualisation, (G)UI and Analysis
Review Session Biggest discrepancy questions
Topics Graphical User Interfaces Using the tkinter Module
Visualization Status/Development
Visualisation and (G)UI
Presentation transcript:

Visualisation and (G)UI Authors: Hajime Yoshida and Satoshi Tanaka

Contents (1) pPart 1: How to perform visualisation l Introduction l Visualizable Objects l Visualisation Attributes l Polyline and Marker l Visualisation Drivers l main() Function l Visualisation Commands l How to Visualize from C++ Codes l Exercises l Information

Visualisation and GUI Part 1: Geant4 Visualisation

1. Introduction pGeant4 Visualisation must respond to varieties of user requirements. For example, l Quick response to survey successive events l Impressive special effects for demonstration l High-quality output to prepare journal papers l Flexible camera control for debugging geometry l Highlighting overlapping of physical volumes l Interactive picking of visualised objects l Etc

2. Visualisable Objects (1) pYou can visualise simulation data such as: l Detector components l A hierarchical structure of physical volumes l A piece of physical volume, logical volume, and solid l Particle trajectories and tracking steps l Hits of particles in detector components pVisualisation is performed either with commands or by writing C++ source codes of user-action classes

2. Visualisable Objects (2) pYou can also visualise other user defined objects such as: l A polyline, that is, a set of successive line segments for, e.g., coordinate axes l A marker which marks an arbitrary 3D position, for, e.g., eye guides l Texts, i.e., character strings for description, comments, or titles

3. Visualisation Attributes pNecessary for visualisation, but not included in geometrical information l Colour, visibility, forced-wireframe style, etc l A set of visualisation attributes is held by class G4VisAttributes pA G4VisAttributes object is assigned to a visualisable object with its SetVisAttributes () method, e.g., l experimentalHall_logical -> SetVisAttributes (G4VisAttributes::Invisible)

3.1 Constructors of G4VisAttributes The following constructors are supported by class G4VisAttributes: l G4VisAttributes G4VisAttributes () l G4VisAttributes (G4bool visibility) l G4VisAttributes (const G4Colour& colour) l G4VisAttributes (G4bool visibility, const G4Colour& colour)

3.2 Visibility pA boolean flag (G4bool) to control the visibility of objects p Access function l G4VisAttributes::SetVisibility (G4bool visibility) l If you give false to the argument, visualisation is skipped for objects for which this set of visualisation attributes is assigned. The default value of visibility is true.

3.3 Colour (1) pClass G4VisAttributes holds its colour entry as an instance of class G4Colour l An equivalent class name, G4Color, is also available pClass G4Colour is instantiated by giving RGB components to its constructor: l G4Colour::G4Colour ( G4double r = 1.0, G4double g = 1.0, G4double b = 1.0 ) l 0<=r, g, b <= 1.0 l The default arguments define “white” color

3.3 Colour (2) pAccess functions of G4VisAttributes to set G4Colour l SetColour (const G4Colour& colour) l SetColour ( G4double r, G4double g, G4double b)

3.4 Assigning G4VisAttributes a logical volume pClass G4LogicalVolume holds a pointer of G4VisAttributes pAccess functions of G4LogicalVolume l SetVisAttributes (const G4VisAttributes* pva)

//----- C++ source codes: Assigning G4VisAttributes to a logical volume...13 // Instantiation of a logical volume myTargetLog = new G4LogicalVolume( myTargetTube,BGO, "TLog", 0, 0, 0);... // Instantiation of a set of visualization attributes with cyan colour G4VisAttributes * calTubeVisAtt = new G4VisAttributes(G4Colour(0.,1.,1.)); // Set the forced wireframe style calTubeVisAtt->SetForceWireframe(true); // Assignment of the visualization attributes to the logical volume myTargetLog->SetVisAttributes(calTubeVisAtt); //----- end of C++ source codes Sample C++ Codes:

4. Polyline and Marker pPolyline and marker are defined in the graphics_reps category pThey are available to model 3D scenes for visualisation

4.1 Polyline pA set of successive line segments pDefined with a class G4Polyline pUsed to visualise tracking steps, particle trajectories, coordinate axes, etc pG4Polyline is defined as a list of G4Point3D objects. Elements of the list define vertex positions of a polyline.

//----- C++ source codes: An example of defining a line segment // Instantiation G4Polyline x_axis; // Vertex positions x_axis.append ( G4Point3D ( 0., 0., 0.) ); x_axis.append ( G4Point3D ( 5. * cm, 0., 0.) ); // Color G4Colour red ( 1.0, 0.0, 0.0 ); // color for x-axis G4VisAttributes att ( red ); x_axis.SetVisAttributes( att ); //----- end of C++ source codes Sample C++ Codes:

4.2 Marker (1) pSet a mark to an arbitrary 3D position pUsually used to visualise hits of particles pDesigned as a 2-dimensional primitive with shape (square, circle, etc), color, and special properties of l (a) always facing the camera and l (b) having the possibility of its size (diameter) defined either in real 3D or 2D screen units (pixels)

4.2 Marker (2) pKinds of markers l Square : G4Square l Circle : G4Circle l Text : G4Text pConstructors l G4Circle (const G4Point3D& pos ) l G4Square (const G4Point3D& pos) l G4Text (const G4String& text, const G4Point3D& pos)

4.2 Marker (3) pEach marker class inherits class G4VMarker pAll access functions of G4VMarker are available. For example, l SetPosition( const G4Point3D& ) l SetWorldSize( G4double real_3d_size) SetScreenSize( G4double 2d_size_pixel) l etc.

Sample C++ Codes to define a small red circle as a marker : //----- C++ source codes: An example of defining a red small maker G4Circle circle(position); // Instantiate a circle with its 3D // position. The argument "position" // is defined as G4Point3D instance circle.SetScreenDiameter (1.0); // Should be circle.SetScreenDiameter // (1.0 * pixels) - to be implemented circle.SetFillStyle (G4Circle::filled); // Make it a filled circle G4Colour colour(1.,0.,0.); // Define red color G4VisAttributes attribs(colour); // Define a red visualization attribute circle.SetVisAttributes(attribs); // Assign the red attribute to the circle //----- end of C++ source codes

5. Visualisation Drivers pVisualisation drivers are interfaces to 3D graphics software pYou can select your favorite one(s) depending on your purposes such as l Demo l Preparing precise figures for journal papers l Publication of results on Web l Debugging geometry l Etc

5.1 Available Graphics Software pBy default, Geant4 provides visualisation drivers, i.e. interfaces for l DAWN : Technical High-quality PostScript output l OPACS: Interactivity, unified GUI l OpenGL: Quick and flexible visualisation l OpenInventor: Interactivity, virtual reality, etc l RayTracer : Photo-realistic rendering l VRML: Interactivity, 3D graphics on Web

5.2 Available Visualisation Drivers and its Driver Name pDAWNFILE  Fukui Renderer DAWN pOPENGLX  OpenGL with Xlib pOPACS  OPACS (o packages) pOIX  OpenInventor with Xlib pRAYTRACER  JPEG files pVRMLFILE  VRML 1.0/2.0 viewer and file petc

5.3 How to Use Visualisation Drivers pUsers can select/use visualisation driver(s) by setting environmental variables before compilation: setenv G4VIS_USE_DRIVERNAME 1 pExample (DAWNFILE, OpenGLXlib, and VRMLFILE drivers): l setenv G4VIS_USE_DAWNFILE 1 l setenv G4VIS_USE_OPENGLX 1 l setenv G4VIS_USE_VRMLFILE 1  Note that Geant4 library should be installed with setting the corresponding environmental variables G4VIS_BUILD_DRIVERNAME_DRIVER to “ 1 ” beforehand, e.g., l setenv G4VIS_BUILD_DAWNFILE_DRIVER 1

6. main() Function (1) pDerive your own concrete class from G4VisManager according to your computer environments pDescribe the followings in your main(): l Include the header file of your visualisation manager l Instantiate and initialize your visualisation manager. The Initialize() method do the initialization l Delete your visualisation manager at the end pYou can use the C macro “G4VIS_USE”, which is automatically set if you incorporate a visualisation driver in compilation.

6. main() Function (2)  A typical form of main() function:..... // Include the header file of your visualisation manager #ifdef G4VIS_USE #include “ ExN03VisManager.hh ” #endif..... // Instantiate and initialize the visualisation manager #ifdef G4VIS_USE G4VisManager* visManager = new ExN03VisManager; visManager->Initialize(); #endif..... // Delete the visualisation manager #ifdef G4VIS_USE delete visManager; #endif

7. Visualisation Commands pHere, we introduce some frequently-used built-in visualisation commands p For simplicity, we assume that the Geant4 executable is compiled, incorporating DAWNFILE, OPENGLX, and VRMLFILE drivers l setenv G4VIS_USE_DAWNFILE 1 l setenv G4VIS_USE_OPENGLX 1 l setenv G4VIS_USE_VRMLFILE 1

7.1 Scene, Scene Hander, and Viewer pIn order to use visualisation commands, you should understand ideas of “scene”, “scene handler”, and “viewer”. pScene: A set of visualizable 3D data pScene handler: CG-data modeler, which uses raw data in a scene pViewer: Image generator pEach scene handler is assigned to a scene pEach viewer is assigned to a scene handler p“visualisation driver” = “scene_handler” + “viewer”

7.2 Steps of Visualisation pStep 1: Create a scene handler and a viewer pStep 2: Create an empty scene pStep 3: Add 3D data to the created scene pStep 4: Attach the current scene handler to the current scene pStep 5: Set camera parameters, drawing style (wireframe/surface), etc pStep 6: Make the viewer execute visualisation pStep 7: Declare the end of visualisation

7.3 An Example of Visualizing Detector p# Invoke the OGLIX driver: Create a scene handler and a viewer. /vis/open OGLIX # Set camera and drawing style /vis/viewer/reset /vis/viewer/viewpointThetaPhi /vis/viewer/set/style wireframe # Visualize of the whole detector geometry # The “/vis/drawVolume” create a scene, add the world volume # to it, and let viewer execute visualisation.. # The “/vis/viewer/update” declare the end of visualisation. /vis/drawVolume /vis/viewer/update

7.4 An Example of Visualizing Events p# Store particle trajactories for visualisation /tracking/storeTrajectory # Invoke the DAWNFILE driver: Create a scene handler and a viewer. /vis/open DAWNFILE ….. Canera setting, and drawing style selection, if necessary ….. # Create a new empty scene /vis/scene/create # Add the world volume and trajectories to the current scene /vis/scene/add/volume /vis/scene/add/trajectories # Let the viewer visualise the scene, and declare end of visualisation /run/beamOn 10

7.5 /vis/open Command pCommand l Idle> /vis/open The “ driver_tag_name ” is a name which shows “ driver name ” + “ mode ” pAction: Create a visualisation driver l In other words, create a scene hander and a viewer pExample: Creating the OPENGLX driver in the immediate mode: l Idle> /vis/open OGLIX pHow to list available driver_tag_name l Idle> help /vis/open or Idle> help /vis/sceneHandler/create

7.6 /vis/viewer/… Commands pCommands Viewpoint setting: Idle> /vis/viewer/viewpointThetaPhi l Zooming Idle> /vis/viewer/zoom l Initialization of camera parameters: Idle> /vis/viewer/reset

7.7 /vis/viewer/set/style Command pCommand Idle> /vis/viewer/set/style The “ style_name ” is “ wireframe ”, “ surface ”, etc

7.8 /vis/drawVolume and /vis/viewer/update Commands pCommands: l Idle> /vis/drawVolume (Default: world) Idle> /vis/viewer/update l Note that /vis/viewer/update should be executed to declare end of visualisation. pYou can add visualisation commands of, say, coordinate axes between the two commands. For example, l Idle> /vis/drawVolume Idle> /vis/draw/axes Idle> /vis/viewer/update Note: “ /vis/draw/axes ” will be renamed to “ /vis/scene/add/axes ”

7.9 Commands to Visualize Events pCommands l Idle> /tracking/storeTrajectory 1 Idle> /vis/scene/add/trajectories Idle> /run/beamOn pAction: l Automatic visualisation of events

Sample Visualisation (1)

Sample Visualisation (2)

Sample Visualisation (3)

8. Visualisation from C++ codes pIt is also possible to perform visualisation from C++ codes pYou can describe the visualisation commands in C++ codes via the ApplyCommand() method of the UI manager: l pUI->ApplyCommand(“/vis/…”); pOr you can use Draw() methods of visualizable classes

9. Exercises pRead and execute sample visualisation macros for examples/novice/N03 l The macro files are “exN03VisX.mac”, where X=0,1,2,… l Explanation of macros is all described in the macro files as comment lines.

10. Information pGeant4 User Guide (and source codes) pREADME file: l geant4/source/visualisation/README pLink collection l pInformation on Geant4 visualisation on Linux l