Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGLPolyMarker.cxx
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Timur Pocheptsov 03/08/2004
3// NOTE: This code moved from obsoleted TGLSceneObject.h / .cxx - see these
4// attic files for previous CVS history
5
6/*************************************************************************
7 * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
8 * All rights reserved. *
9 * *
10 * For the licensing terms see $ROOTSYS/LICENSE. *
11 * For the list of contributors see $ROOTSYS/README/CREDITS. *
12 *************************************************************************/
13
14#include "TGLPolyMarker.h"
15#include "TGLRnrCtx.h"
16#include "TGLIncludes.h"
17#include "TGLUtil.h"
18
19#include "TBuffer3D.h"
20#include "TBuffer3DTypes.h"
21#include "TMath.h"
22
23#include "TAttMarker.h"
24
25// For debug tracing
26#include "TClass.h"
27#include "TError.h"
28
29/** \class TGLPolyMarker
30\ingroup opengl
31To draw a 3D polymarker in a GL window.
32*/
33
34
35////////////////////////////////////////////////////////////////////////////////
36///TAttMarker is not TObject descendant, so I need dynamic_cast
37
39 TGLLogicalShape(buffer),
40 fVertices(buffer.fPnts, buffer.fPnts + 3 * buffer.NbPnts()),
41 fStyle(7),
42 fSize(1.)
43{
44 if (TAttMarker *realObj = dynamic_cast<TAttMarker *>(buffer.fID)) {
45 fStyle = realObj->GetMarkerStyle();
46 fSize = realObj->GetMarkerSize() / 2.;
47 }
48}
49
50
51////////////////////////////////////////////////////////////////////////////////
52/// Debug tracing
53
55{
56 if (gDebug > 4) {
57 Info("TGLPolyMarker::DirectDraw", "this %zd (class %s) LOD %d", (size_t)this, IsA()->GetName(), rnrCtx.ShapeLOD());
58 }
59
60 if (rnrCtx.DrawPass() == TGLRnrCtx::kPassOutlineLine)
61 return;
62
63 const Double_t *vertices = &fVertices[0];
64 UInt_t size = fVertices.size();
65 Int_t stacks = 6, slices = 6;
68
69 switch (fStyle) {
70 case 27:
71 stacks = 2, slices = 4;
72 // intentionally no break
73 case 4:case 8:case 20:case 24:
74 for (UInt_t i = 0; i < size; i += 3) {
76 glTranslated(vertices[i], vertices[i + 1], vertices[i + 2]);
77 gluSphere(rnrCtx.GetGluQuadric(), fSize, slices, stacks);
79 }
80 break;
81 case 22:case 26:
82 topRadius = 0.;
83 // intentionally no break
84 case 21:case 25:
85 for (UInt_t i = 0; i < size; i += 3) {
87 glTranslated(vertices[i], vertices[i + 1], vertices[i + 2]);
88 gluCylinder(rnrCtx.GetGluQuadric(), fSize, topRadius, fSize, 4, 1);
90 }
91 break;
92 case 23:
93 for (UInt_t i = 0; i < size; i += 3) {
95 glTranslated(vertices[i], vertices[i + 1], vertices[i + 2]);
96 glRotated(180, 1., 0., 0.);
97 gluCylinder(rnrCtx.GetGluQuadric(), fSize, 0., fSize, 4, 1);
99 }
100 break;
101 case 3: case 2: case 5:
102 DrawStars();
103 break;
104 case 7:
105 pixelSize += 1;
106 // intentionally no break
107 case 6:
108 pixelSize += 1;
109 // intentionally no break
110 case 1: case 9: case 10: case 11: default:
112 glBegin(GL_POINTS);
113 for (UInt_t i = 0; i < size; i += 3)
114 glVertex3dv(vertices + i);
115 glEnd();
116 break;
117 }
118}
119
120
121////////////////////////////////////////////////////////////////////////////////
122/// Draw stars
123
125{
127 const Double_t diag = TMath::Sqrt(2 * fSize * fSize) / 2;
128
129 for (UInt_t i = 0; i < fVertices.size(); i += 3) {
130 Double_t x = fVertices[i];
131 Double_t y = fVertices[i + 1];
132 Double_t z = fVertices[i + 2];
133 glBegin(GL_LINES);
134 if (fStyle == 2 || fStyle == 3) {
135 glVertex3d(x - fSize, y, z);
136 glVertex3d(x + fSize, y, z);
137 glVertex3d(x, y, z - fSize);
138 glVertex3d(x, y, z + fSize);
139 glVertex3d(x, y - fSize, z);
140 glVertex3d(x, y + fSize, z);
141 }
142 if(fStyle != 2) {
143 glVertex3d(x - diag, y - diag, z - diag);
144 glVertex3d(x + diag, y + diag, z + diag);
145 glVertex3d(x - diag, y - diag, z + diag);
146 glVertex3d(x + diag, y + diag, z - diag);
147 glVertex3d(x - diag, y + diag, z - diag);
148 glVertex3d(x + diag, y - diag, z + diag);
149 glVertex3d(x - diag, y + diag, z + diag);
150 glVertex3d(x + diag, y - diag, z - diag);
151 }
152 glEnd();
153 }
155}
dim_t fSize
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:241
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:627
Marker Attributes class.
Definition TAttMarker.h:20
Generic 3D primitive description class.
Definition TBuffer3D.h:18
TObject * fID
Definition TBuffer3D.h:87
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
void DirectDraw(TGLRnrCtx &rnrCtx) const override
Debug tracing.
std::vector< Double_t > fVertices
TClass * IsA() const override
TGLPolyMarker(const TBuffer3D &buffer)
TAttMarker is not TObject descendant, so I need dynamic_cast.
void DrawStars() const
Draw stars.
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
@ kPassOutlineLine
Definition TGLRnrCtx.h:57
static Float_t PointSize()
Get the point-size, taking the global scaling into account.
Definition TGLUtil.cxx:1926
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:673