source: trunk/documents/UserDoc/DocBookUsersGuides/ForApplicationDeveloper/xml/Visualization/markertext.xml @ 904

Last change on this file since 904 was 904, checked in by garnier, 16 years ago

ajout de la doc

File size: 10.6 KB
Line 
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>
12Polylines, 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
18visualization. Here we explain their definitions and usages.
19</para>
20
21
22<!-- ******************* Section (Level#2) ****************** -->
23<sect2 id="sect.VisPlylMrkTxt.Plyl">
24<title>
25Polylines
26</title>
27
28<para>
29A polyline is a set of successive line segments. It is defined with
30a class <emphasis>G4Polyline</emphasis> defined in the
31<literal>graphics_reps</literal> category.
32A polyline is used to visualize tracking steps, particle
33trajectories, coordinate axes, and any other user-defined objects
34made 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.
40The vertex positions are set to a <emphasis>G4Polyline</emphasis> 
41object with the <literal>push_back()</literal> method.
42</para>
43
44<para>
45For example, an x-axis with length 5 cm and with red color is
46defined in <xref linkend="programlist_VisPlylMrkTxt_1" />.
47
48<example id="programlist_VisPlylMrkTxt_1">
49<title>
50Defining 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
56G4Polyline  x_axis;
57
58// Set red line colour
59G4Colour         red(1.0, 0.0, 0.0);
60G4VisAttributes  att(red);     
61x_axis.SetVisAttributes(&amp;att);
62
63// Set vertex positions
64x_axis.push_back( G4Point3D(0., 0., 0.) );
65x_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>
78Markers
79</title>
80
81<para>
82Here we explain how to use 3D markers in Geant4 Visualization.
83</para>
84
85<!-- ******* Bridgehead ******* -->
86<bridgehead renderas='sect4'>
87What are Markers?
88</bridgehead>
89
90<para>
91Markers set marks at arbitrary positions in the 3D space. They
92are often used to visualize hits of particles at detector
93components. A marker is a 2-dimensional primitive with shape
94(square, circle, etc), color, and special properties (a) of always
95facing the camera and (b) of having the possibility of a size
96defined in screen units (pixels). Here "size" means "overall size",
97e.g., diameter of circle and side of square (but diameter and
98radius access functions are defined to avoid ambiguity).
99</para>
100
101<para>
102So the user who constructs a marker should decide whether or not
103it should be visualized to a given size in world coordinates by
104setting the world size. Alternatively, the user can set the screen
105size and the marker is visualized to its screen size. Finally, the
106user may decide not to set any size; in that case, it is drawn
107according to the sizes specified in the default marker specified in
108the class <emphasis>G4ViewParameters</emphasis>.
109</para>
110
111<para>
112By default, "square" and "circle" are supported in Geant4
113Visualization. The former is described with class <emphasis>G4Square</emphasis>,
114and 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>
149These classes are inherited from class <emphasis>G4VMarker</emphasis>.
150They have constructors as follows:
151
152<informalexample>
153<programlisting>
154      //----- Constructors of G4Circle and G4Square
155      G4Circle::G4Circle (const G4Point3D&amp; pos );
156      G4Square::G4Square (const G4Point3D&amp; pos);
157</programlisting>
158</informalexample>
159</para>
160
161<para>
162Access functions of class <emphasis>G4VMarker</emphasis> are summarized below.
163</para>
164
165<!-- ******* Bridgehead ******* -->
166<bridgehead renderas='sect4'>
167Access functions of markers
168</bridgehead>
169
170<para>
171<xref linkend="programlist_VisPlylMrkTxt_2" /> shows the access functions
172inherited from the base class <emphasis>G4VMarker</emphasis>.
173
174<example id="programlist_VisPlylMrkTxt_2">
175<title>
176The 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&amp; );
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
208code to define a very small red circle, i.e., a dot with diameter 1.0 pixel.
209Such a dot is often used to visualize a hit.
210
211<example id="programlist_VisPlylMrkTxt_3">
212<title>
213Sample 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>
238Text
239</title>
240
241<para>
242Text, i.e., a character string, is used to visualize various kinds
243of description, particle name, energy, coordinate names etc. Text
244is described by the class <emphasis>G4Text</emphasis> . The following
245constructors are supported:
246
247<informalexample>
248<programlisting>
249     //----- Constructors of G4Text
250     G4Text (const G4String&amp; text);
251     G4Text (const G4String&amp; text, const G4Point3D&amp; pos);
252</programlisting>
253</informalexample>
254
255where the argument <literal>text</literal> is the text (string) to be
256visualized, and <literal>pos</literal> is the 3D position at which the text
257is visualized.
258</para>
259
260<para>
261Note that class <emphasis>G4Text</emphasis> also inherits <emphasis>G4VMarker</emphasis>.
262Size of text is recognized as "font size", i.e., height of the
263text. All the access functions defined for class <emphasis>G4VMarker</emphasis>
264mentioned above are available. In addition, the following access
265functions are available, too:
266
267<informalexample>
268<programlisting>
269     //----- Set functions of G4Text
270     void G4Text::SetText ( const G4String&amp; text ) ;
271     void G4Text::SetOffset ( double dx, double dy ) ;
272
273     //----- Get functions of G4Text
274     G4String G4Text::GetText () const;
275     G4double G4Text::GetXOffset () const;
276     G4double G4Text::GetYOffset () const;
277</programlisting>
278</informalexample>
279</para>
280
281<para>
282Method <literal>SetText()</literal> defines text to be visualized, and
283<literal>GetText()</literal> returns the defined text. Method
284<literal>SetOffset()</literal> defines x (horizontal) and y (vertical)
285offsets in the screen coordinates. By default, both offsets are
286zero, and the text starts from the 3D position given to the
287constructor or to the method <literal>G4VMarker:SetPosition()</literal>.
288Offsets should be given with the same units as the one adopted for
289the size, i.e., world-size or screen-size units.
290</para>
291
292<para>
293<xref linkend="programlist_VisPlylMrkTxt_4" /> shows sample C++ source code
294to define text with the following properties:
295
296<itemizedlist spacing="compact">
297  <listitem><para>
298    Text: "Welcome to Geant4 Visualization"
299  </para></listitem>
300  <listitem><para>
301    Position: (0.,0.,0.) in the world coordinates
302  </para></listitem>
303  <listitem><para>
304    Horizontal offset: 10 pixels
305  </para></listitem>
306  <listitem><para>
307    Vertical offset: -20 pixels
308  </para></listitem>
309  <listitem><para>
310    Colour: blue (default)
311  </para></listitem>
312</itemizedlist>
313</para>
314
315<para>
316<example id="programlist_VisPlylMrkTxt_4">
317<title>
318An example of defining text.
319</title>
320
321<programlisting>
322 //----- C++ source codes: An example of defining a visualizable text
323
324 //----- Instantiation
325 G4Text text ;
326 text.SetText ( "Welcome to Geant4 Visualization");
327 text.SetPosition ( G4Point3D(0.,0.,0.) );
328 // These three lines are equivalent to:
329 //  G4Text text ( "Welcome to Geant4 Visualization",
330 //                 G4Point3D(0.,0.,0.) );
331
332 //----- Size (font size in units of pixels)
333 G4double fontsize = 24.; // Should be 24. * pixels - to be implemented.
334 text.SetScreenSize ( fontsize );
335
336 //----- Offsets
337 G4double x_offset = 10.; // Should be 10. * pixels - to be implemented.
338 G4double y_offset = -20.; // Should be -20. * pixels - to be implemented.
339 text.SetOffset( x_offset, y_offset );
340
341 //----- Color (Blue is the default setting, and so the codes below are omissible)
342 G4Colour blue( 0., 0., 1. );
343 G4VisAttributes att ( blue );
344 text.SetVisAttributes ( att );
345
346 //----- end of C++ source codes
347</programlisting>
348</example>
349</para>
350
351
352</sect2>
353</sect1>
354
Note: See TracBrowser for help on using the repository browser.