Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Visualisation and (G)UI Authors: Hajime Yoshida and Satoshi Tanaka."— Presentation transcript:

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

2 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

3 Visualisation and GUI Part 1: Geant4 Visualisation

4 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

5 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

6 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

7 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)

8 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)

9 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.

10 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

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

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

13 //----- 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:

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

15 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.

16 //----- 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:

17 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)

18 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)

19 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.

20 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

21 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

22 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

23 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

24 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

25 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.

26 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

27 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

28 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”

29 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

30 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 70 20 /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

31 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

32 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

33 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

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

35 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 ”

36 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

37 Sample Visualisation (1)

38 Sample Visualisation (2)

39 Sample Visualisation (3)

40 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

41 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.

42 10. Information pGeant4 User Guide (and source codes) pREADME file: l geant4/source/visualisation/README pLink collection l http://geant4.kek.jp/~tanaka/GEANT4/g4_vis_gui_linkpage.html http://geant4.kek.jp/~tanaka/GEANT4/g4_vis_gui_linkpage.html pInformation on Geant4 visualisation on Linux l http://geant4.kek.jp/~tanaka/GEANT4/g4vis_on_linux.html http://geant4.kek.jp/~tanaka/GEANT4/g4vis_on_linux.html


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

Similar presentations


Ads by Google