[904] | 1 | <!-- ******************************************************** --> |
---|
| 2 | <!-- --> |
---|
| 3 | <!-- [History] --> |
---|
| 4 | <!-- Converted to DocBook: Katsuya Amako, Aug-2006 --> |
---|
| 5 | <!-- --> |
---|
| 6 | <!-- ******************************************************** --> |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | <!-- ******************* Section (Level#1) ****************** --> |
---|
| 10 | <sect1 id="sect.VisPlylMrkTxt"> |
---|
| 11 | <title> |
---|
| 12 | Polylines, Markers and Text |
---|
| 13 | </title> |
---|
| 14 | |
---|
| 15 | <para> |
---|
| 16 | Polylines, markers and text are defined in the |
---|
| 17 | <literal>graphics_reps</literal> category, and are used only for |
---|
| 18 | visualization. Here we explain their definitions and usages. |
---|
| 19 | </para> |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | <!-- ******************* Section (Level#2) ****************** --> |
---|
| 23 | <sect2 id="sect.VisPlylMrkTxt.Plyl"> |
---|
| 24 | <title> |
---|
| 25 | Polylines |
---|
| 26 | </title> |
---|
| 27 | |
---|
| 28 | <para> |
---|
| 29 | A polyline is a set of successive line segments. It is defined with |
---|
| 30 | a class <emphasis>G4Polyline</emphasis> defined in the |
---|
| 31 | <literal>graphics_reps</literal> category. |
---|
| 32 | A polyline is used to visualize tracking steps, particle |
---|
| 33 | trajectories, coordinate axes, and any other user-defined objects |
---|
| 34 | made of line segments. |
---|
| 35 | </para> |
---|
| 36 | |
---|
| 37 | <para> |
---|
| 38 | <emphasis>G4Polyline</emphasis> is defined as a list of |
---|
| 39 | <emphasis>G4Point3D</emphasis> objects, i.e., vertex positions. |
---|
| 40 | The vertex positions are set to a <emphasis>G4Polyline</emphasis> |
---|
| 41 | object with the <literal>push_back()</literal> method. |
---|
| 42 | </para> |
---|
| 43 | |
---|
| 44 | <para> |
---|
| 45 | For example, an x-axis with length 5 cm and with red color is |
---|
| 46 | defined in <xref linkend="programlist_VisPlylMrkTxt_1" />. |
---|
| 47 | |
---|
| 48 | <example id="programlist_VisPlylMrkTxt_1"> |
---|
| 49 | <title> |
---|
| 50 | Defining an x-axis with length 5 cm and with colour red. |
---|
| 51 | </title> |
---|
| 52 | |
---|
| 53 | <programlisting> |
---|
| 54 | //----- C++ source codes: An example of defining a line segment |
---|
| 55 | // Instantiate an emply polyline object |
---|
| 56 | G4Polyline x_axis; |
---|
| 57 | |
---|
| 58 | // Set red line colour |
---|
| 59 | G4Colour red(1.0, 0.0, 0.0); |
---|
| 60 | G4VisAttributes att(red); |
---|
| 61 | x_axis.SetVisAttributes(&att); |
---|
| 62 | |
---|
| 63 | // Set vertex positions |
---|
| 64 | x_axis.push_back( G4Point3D(0., 0., 0.) ); |
---|
| 65 | x_axis.push_back( G4Point3D(5.*cm, 0., 0.) ); |
---|
| 66 | |
---|
| 67 | //----- end of C++ source codes |
---|
| 68 | </programlisting> |
---|
| 69 | </example> |
---|
| 70 | </para> |
---|
| 71 | |
---|
| 72 | </sect2> |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | <!-- ******************* Section (Level#2) ****************** --> |
---|
| 76 | <sect2 id="sect.VisPlylMrkTxt.Mrk"> |
---|
| 77 | <title> |
---|
| 78 | Markers |
---|
| 79 | </title> |
---|
| 80 | |
---|
| 81 | <para> |
---|
| 82 | Here we explain how to use 3D markers in Geant4 Visualization. |
---|
| 83 | </para> |
---|
| 84 | |
---|
| 85 | <!-- ******* Bridgehead ******* --> |
---|
| 86 | <bridgehead renderas='sect4'> |
---|
| 87 | What are Markers? |
---|
| 88 | </bridgehead> |
---|
| 89 | |
---|
| 90 | <para> |
---|
| 91 | Markers set marks at arbitrary positions in the 3D space. They |
---|
| 92 | are often used to visualize hits of particles at detector |
---|
| 93 | components. A marker is a 2-dimensional primitive with shape |
---|
| 94 | (square, circle, etc), color, and special properties (a) of always |
---|
| 95 | facing the camera and (b) of having the possibility of a size |
---|
| 96 | defined in screen units (pixels). Here "size" means "overall size", |
---|
| 97 | e.g., diameter of circle and side of square (but diameter and |
---|
| 98 | radius access functions are defined to avoid ambiguity). |
---|
| 99 | </para> |
---|
| 100 | |
---|
| 101 | <para> |
---|
| 102 | So the user who constructs a marker should decide whether or not |
---|
| 103 | it should be visualized to a given size in world coordinates by |
---|
| 104 | setting the world size. Alternatively, the user can set the screen |
---|
| 105 | size and the marker is visualized to its screen size. Finally, the |
---|
| 106 | user may decide not to set any size; in that case, it is drawn |
---|
| 107 | according to the sizes specified in the default marker specified in |
---|
| 108 | the class <emphasis>G4ViewParameters</emphasis>. |
---|
| 109 | </para> |
---|
| 110 | |
---|
| 111 | <para> |
---|
| 112 | By default, "square" and "circle" are supported in Geant4 |
---|
| 113 | Visualization. The former is described with class <emphasis>G4Square</emphasis>, |
---|
| 114 | and the latter with class <emphasis>G4Circle</emphasis>: |
---|
| 115 | |
---|
| 116 | <informaltable> |
---|
| 117 | <tgroup cols="2"> |
---|
| 118 | <tbody> |
---|
| 119 | <row> |
---|
| 120 | <entry> |
---|
| 121 | <emphasis role="bold">Marker Type</emphasis> |
---|
| 122 | </entry> |
---|
| 123 | <entry> |
---|
| 124 | <emphasis role="bold">Class Name</emphasis> |
---|
| 125 | </entry> |
---|
| 126 | </row> |
---|
| 127 | <row> |
---|
| 128 | <entry> |
---|
| 129 | circle |
---|
| 130 | </entry> |
---|
| 131 | <entry> |
---|
| 132 | <emphasis>G4Circle</emphasis> |
---|
| 133 | </entry> |
---|
| 134 | </row> |
---|
| 135 | <row> |
---|
| 136 | <entry> |
---|
| 137 | right square |
---|
| 138 | </entry> |
---|
| 139 | <entry> |
---|
| 140 | <emphasis>G4Square</emphasis> |
---|
| 141 | </entry> |
---|
| 142 | </row> |
---|
| 143 | </tbody> |
---|
| 144 | </tgroup> |
---|
| 145 | </informaltable> |
---|
| 146 | </para> |
---|
| 147 | |
---|
| 148 | <para> |
---|
| 149 | These classes are inherited from class <emphasis>G4VMarker</emphasis>. |
---|
| 150 | They have constructors as follows: |
---|
| 151 | |
---|
| 152 | <informalexample> |
---|
| 153 | <programlisting> |
---|
| 154 | //----- Constructors of G4Circle and G4Square |
---|
| 155 | G4Circle::G4Circle (const G4Point3D& pos ); |
---|
| 156 | G4Square::G4Square (const G4Point3D& pos); |
---|
| 157 | </programlisting> |
---|
| 158 | </informalexample> |
---|
| 159 | </para> |
---|
| 160 | |
---|
| 161 | <para> |
---|
| 162 | Access functions of class <emphasis>G4VMarker</emphasis> are summarized below. |
---|
| 163 | </para> |
---|
| 164 | |
---|
| 165 | <!-- ******* Bridgehead ******* --> |
---|
| 166 | <bridgehead renderas='sect4'> |
---|
| 167 | Access functions of markers |
---|
| 168 | </bridgehead> |
---|
| 169 | |
---|
| 170 | <para> |
---|
| 171 | <xref linkend="programlist_VisPlylMrkTxt_2" /> shows the access functions |
---|
| 172 | inherited from the base class <emphasis>G4VMarker</emphasis>. |
---|
| 173 | |
---|
| 174 | <example id="programlist_VisPlylMrkTxt_2"> |
---|
| 175 | <title> |
---|
| 176 | The access functions inherited from the base class |
---|
| 177 | <emphasis>G4VMarker</emphasis>. |
---|
| 178 | </title> |
---|
| 179 | |
---|
| 180 | <programlisting> |
---|
| 181 | //----- Set functions of G4VMarker |
---|
| 182 | void G4VMarker::SetPosition( const G4Point3D& ); |
---|
| 183 | void G4VMarker::SetWorldSize( G4double ); |
---|
| 184 | void G4VMarker::SetWorldDiameter( G4double ); |
---|
| 185 | void G4VMarker::SetWorldRadius( G4double ); |
---|
| 186 | void G4VMarker::SetScreenSize( G4double ); |
---|
| 187 | void G4VMarker::SetScreenDiameter( G4double ); |
---|
| 188 | void G4VMarker::SetScreenRadius( G4double ); |
---|
| 189 | void G4VMarker::SetFillStyle( FillStyle ); |
---|
| 190 | // Note: enum G4VMarker::FillStyle {noFill, hashed, filled}; |
---|
| 191 | |
---|
| 192 | //----- Get functions of G4VMarker |
---|
| 193 | G4Point3D G4VMarker::GetPosition () const; |
---|
| 194 | G4double G4VMarker::GetWorldSize () const; |
---|
| 195 | G4double G4VMarker::GetWorldDiameter () const; |
---|
| 196 | G4double G4VMarker::GetWorldRadius () const; |
---|
| 197 | G4double G4VMarker::GetScreenSize () const; |
---|
| 198 | G4double G4VMarker::GetScreenDiameter () const; |
---|
| 199 | G4double G4VMarker::GetScreenRadius () const; |
---|
| 200 | FillStyle G4VMarker::GetFillStyle () const; |
---|
| 201 | // Note: enum G4VMarker::FillStyle {noFill, hashed, filled}; |
---|
| 202 | </programlisting> |
---|
| 203 | </example> |
---|
| 204 | </para> |
---|
| 205 | |
---|
| 206 | <para> |
---|
| 207 | <xref linkend="programlist_VisPlylMrkTxt_3" /> shows sample C++ source |
---|
| 208 | code to define a very small red circle, i.e., a dot with diameter 1.0 pixel. |
---|
| 209 | Such a dot is often used to visualize a hit. |
---|
| 210 | |
---|
| 211 | <example id="programlist_VisPlylMrkTxt_3"> |
---|
| 212 | <title> |
---|
| 213 | Sample C++ source code to define a very small red circle. |
---|
| 214 | </title> |
---|
| 215 | |
---|
| 216 | <programlisting> |
---|
| 217 | //----- C++ source codes: An example of defining a red small maker |
---|
| 218 | G4Circle circle(position); // Instantiate a circle with its 3D |
---|
| 219 | // position. The argument "position" |
---|
| 220 | // is defined as G4Point3D instance |
---|
| 221 | circle.SetScreenDiameter (1.0); // Should be circle.SetScreenDiameter |
---|
| 222 | // (1.0 * pixels) - to be implemented |
---|
| 223 | circle.SetFillStyle (G4Circle::filled); // Make it a filled circle |
---|
| 224 | G4Colour colour(1.,0.,0.); // Define red color |
---|
| 225 | G4VisAttributes attribs(colour); // Define a red visualization attribute |
---|
| 226 | circle.SetVisAttributes(attribs); // Assign the red attribute to the circle |
---|
| 227 | //----- end of C++ source codes |
---|
| 228 | </programlisting> |
---|
| 229 | </example> |
---|
| 230 | </para> |
---|
| 231 | |
---|
| 232 | </sect2> |
---|
| 233 | |
---|
| 234 | |
---|
| 235 | <!-- ******************* Section (Level#2) ****************** --> |
---|
| 236 | <sect2 id="sect.VisPlylMrkTxt.Txt"> |
---|
| 237 | <title> |
---|
| 238 | Text |
---|
| 239 | </title> |
---|
| 240 | |
---|
| 241 | <para> |
---|
| 242 | Text, i.e., a character string, is used to visualize various kinds |
---|
| 243 | of description, particle name, energy, coordinate names etc. Text |
---|
| 244 | is described by the class <emphasis>G4Text</emphasis> . The following |
---|
| 245 | constructors are supported: |
---|
| 246 | |
---|
| 247 | <informalexample> |
---|
| 248 | <programlisting> |
---|
| 249 | //----- Constructors of G4Text |
---|
| 250 | G4Text (const G4String& text); |
---|
| 251 | G4Text (const G4String& text, const G4Point3D& pos); |
---|
| 252 | </programlisting> |
---|
| 253 | </informalexample> |
---|
| 254 | |
---|
| 255 | where the argument <literal>text</literal> is the text (string) to be |
---|
| 256 | visualized, and <literal>pos</literal> is the 3D position at which the text |
---|
| 257 | is visualized. |
---|
| 258 | </para> |
---|
| 259 | |
---|
| 260 | <para> |
---|
[1222] | 261 | Text is currently drawn only by the OpenGL drivers, such as OGLIX, OGLIXm, OGLIQt and OpenInventor. |
---|
| 262 | It is not yet supported on other drivers, including the Windows OpenGL drivers, HepRep, etc. |
---|
| 263 | </para> |
---|
| 264 | |
---|
| 265 | <para> |
---|
[904] | 266 | Note that class <emphasis>G4Text</emphasis> also inherits <emphasis>G4VMarker</emphasis>. |
---|
| 267 | Size of text is recognized as "font size", i.e., height of the |
---|
| 268 | text. All the access functions defined for class <emphasis>G4VMarker</emphasis> |
---|
| 269 | mentioned above are available. In addition, the following access |
---|
| 270 | functions are available, too: |
---|
| 271 | |
---|
| 272 | <informalexample> |
---|
| 273 | <programlisting> |
---|
| 274 | //----- Set functions of G4Text |
---|
| 275 | void G4Text::SetText ( const G4String& text ) ; |
---|
| 276 | void G4Text::SetOffset ( double dx, double dy ) ; |
---|
| 277 | |
---|
| 278 | //----- Get functions of G4Text |
---|
| 279 | G4String G4Text::GetText () const; |
---|
| 280 | G4double G4Text::GetXOffset () const; |
---|
| 281 | G4double G4Text::GetYOffset () const; |
---|
| 282 | </programlisting> |
---|
| 283 | </informalexample> |
---|
| 284 | </para> |
---|
| 285 | |
---|
| 286 | <para> |
---|
| 287 | Method <literal>SetText()</literal> defines text to be visualized, and |
---|
| 288 | <literal>GetText()</literal> returns the defined text. Method |
---|
| 289 | <literal>SetOffset()</literal> defines x (horizontal) and y (vertical) |
---|
| 290 | offsets in the screen coordinates. By default, both offsets are |
---|
| 291 | zero, and the text starts from the 3D position given to the |
---|
| 292 | constructor or to the method <literal>G4VMarker:SetPosition()</literal>. |
---|
| 293 | Offsets should be given with the same units as the one adopted for |
---|
| 294 | the size, i.e., world-size or screen-size units. |
---|
| 295 | </para> |
---|
| 296 | |
---|
| 297 | <para> |
---|
| 298 | <xref linkend="programlist_VisPlylMrkTxt_4" /> shows sample C++ source code |
---|
| 299 | to define text with the following properties: |
---|
| 300 | |
---|
| 301 | <itemizedlist spacing="compact"> |
---|
| 302 | <listitem><para> |
---|
| 303 | Text: "Welcome to Geant4 Visualization" |
---|
| 304 | </para></listitem> |
---|
| 305 | <listitem><para> |
---|
| 306 | Position: (0.,0.,0.) in the world coordinates |
---|
| 307 | </para></listitem> |
---|
| 308 | <listitem><para> |
---|
| 309 | Horizontal offset: 10 pixels |
---|
| 310 | </para></listitem> |
---|
| 311 | <listitem><para> |
---|
| 312 | Vertical offset: -20 pixels |
---|
| 313 | </para></listitem> |
---|
| 314 | <listitem><para> |
---|
| 315 | Colour: blue (default) |
---|
| 316 | </para></listitem> |
---|
| 317 | </itemizedlist> |
---|
| 318 | </para> |
---|
| 319 | |
---|
| 320 | <para> |
---|
| 321 | <example id="programlist_VisPlylMrkTxt_4"> |
---|
| 322 | <title> |
---|
| 323 | An example of defining text. |
---|
| 324 | </title> |
---|
| 325 | |
---|
| 326 | <programlisting> |
---|
| 327 | //----- C++ source codes: An example of defining a visualizable text |
---|
| 328 | |
---|
| 329 | //----- Instantiation |
---|
| 330 | G4Text text ; |
---|
| 331 | text.SetText ( "Welcome to Geant4 Visualization"); |
---|
| 332 | text.SetPosition ( G4Point3D(0.,0.,0.) ); |
---|
| 333 | // These three lines are equivalent to: |
---|
| 334 | // G4Text text ( "Welcome to Geant4 Visualization", |
---|
| 335 | // G4Point3D(0.,0.,0.) ); |
---|
| 336 | |
---|
| 337 | //----- Size (font size in units of pixels) |
---|
| 338 | G4double fontsize = 24.; // Should be 24. * pixels - to be implemented. |
---|
| 339 | text.SetScreenSize ( fontsize ); |
---|
| 340 | |
---|
| 341 | //----- Offsets |
---|
| 342 | G4double x_offset = 10.; // Should be 10. * pixels - to be implemented. |
---|
| 343 | G4double y_offset = -20.; // Should be -20. * pixels - to be implemented. |
---|
| 344 | text.SetOffset( x_offset, y_offset ); |
---|
| 345 | |
---|
| 346 | //----- Color (Blue is the default setting, and so the codes below are omissible) |
---|
| 347 | G4Colour blue( 0., 0., 1. ); |
---|
| 348 | G4VisAttributes att ( blue ); |
---|
| 349 | text.SetVisAttributes ( att ); |
---|
| 350 | |
---|
| 351 | //----- end of C++ source codes |
---|
| 352 | </programlisting> |
---|
| 353 | </example> |
---|
| 354 | </para> |
---|
| 355 | |
---|
| 356 | |
---|
| 357 | </sect2> |
---|
| 358 | </sect1> |
---|
| 359 | |
---|