00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGLPolyMarker.h"
00015 #include "TGLRnrCtx.h"
00016 #include "TGLIncludes.h"
00017 #include "TGLUtil.h"
00018
00019 #include "TBuffer3D.h"
00020 #include "TBuffer3DTypes.h"
00021 #include "TMath.h"
00022
00023 #include "TAttMarker.h"
00024
00025
00026 #include "TClass.h"
00027 #include "TError.h"
00028
00029
00030
00031
00032
00033
00034
00035 ClassImp(TGLPolyMarker)
00036
00037
00038 TGLPolyMarker::TGLPolyMarker(const TBuffer3D & buffer) :
00039 TGLLogicalShape(buffer),
00040 fVertices(buffer.fPnts, buffer.fPnts + 3 * buffer.NbPnts()),
00041 fStyle(7),
00042 fSize(1.)
00043 {
00044
00045 if (TAttMarker *realObj = dynamic_cast<TAttMarker *>(buffer.fID)) {
00046 fStyle = realObj->GetMarkerStyle();
00047 fSize = realObj->GetMarkerSize() / 2.;
00048 }
00049 }
00050
00051
00052
00053 void TGLPolyMarker::DirectDraw(TGLRnrCtx & rnrCtx) const
00054 {
00055
00056 if (gDebug > 4) {
00057 Info("TGLPolyMarker::DirectDraw", "this %ld (class %s) LOD %d", (Long_t)this, IsA()->GetName(), rnrCtx.ShapeLOD());
00058 }
00059
00060 if (rnrCtx.DrawPass() == TGLRnrCtx::kPassOutlineLine)
00061 return;
00062
00063 const Double_t *vertices = &fVertices[0];
00064 UInt_t size = fVertices.size();
00065 Int_t stacks = 6, slices = 6;
00066 Float_t pixelSize = 1;
00067 Double_t topRadius = fSize;
00068
00069 switch (fStyle) {
00070 case 27:
00071 stacks = 2, slices = 4;
00072
00073 case 4:case 8:case 20:case 24:
00074 for (UInt_t i = 0; i < size; i += 3) {
00075 glPushMatrix();
00076 glTranslated(vertices[i], vertices[i + 1], vertices[i + 2]);
00077 gluSphere(rnrCtx.GetGluQuadric(), fSize, slices, stacks);
00078 glPopMatrix();
00079 }
00080 break;
00081 case 22:case 26:
00082 topRadius = 0.;
00083
00084 case 21:case 25:
00085 for (UInt_t i = 0; i < size; i += 3) {
00086 glPushMatrix();
00087 glTranslated(vertices[i], vertices[i + 1], vertices[i + 2]);
00088 gluCylinder(rnrCtx.GetGluQuadric(), fSize, topRadius, fSize, 4, 1);
00089 glPopMatrix();
00090 }
00091 break;
00092 case 23:
00093 for (UInt_t i = 0; i < size; i += 3) {
00094 glPushMatrix();
00095 glTranslated(vertices[i], vertices[i + 1], vertices[i + 2]);
00096 glRotated(180, 1., 0., 0.);
00097 gluCylinder(rnrCtx.GetGluQuadric(), fSize, 0., fSize, 4, 1);
00098 glPopMatrix();
00099 }
00100 break;
00101 case 3: case 2: case 5:
00102 DrawStars();
00103 break;
00104 case 7:
00105 pixelSize += 1;
00106
00107 case 6:
00108 pixelSize += 1;
00109
00110 case 1: case 9: case 10: case 11: default:
00111 TGLUtil::PointSize(pixelSize);
00112 glBegin(GL_POINTS);
00113 for (UInt_t i = 0; i < size; i += 3)
00114 glVertex3dv(vertices + i);
00115 glEnd();
00116 break;
00117 }
00118 }
00119
00120
00121
00122 void TGLPolyMarker::DrawStars()const
00123 {
00124
00125 glDisable(GL_LIGHTING);
00126 const Double_t diag = TMath::Sqrt(2 * fSize * fSize) / 2;
00127
00128 for (UInt_t i = 0; i < fVertices.size(); i += 3) {
00129 Double_t x = fVertices[i];
00130 Double_t y = fVertices[i + 1];
00131 Double_t z = fVertices[i + 2];
00132 glBegin(GL_LINES);
00133 if (fStyle == 2 || fStyle == 3) {
00134 glVertex3d(x - fSize, y, z);
00135 glVertex3d(x + fSize, y, z);
00136 glVertex3d(x, y, z - fSize);
00137 glVertex3d(x, y, z + fSize);
00138 glVertex3d(x, y - fSize, z);
00139 glVertex3d(x, y + fSize, z);
00140 }
00141 if(fStyle != 2) {
00142 glVertex3d(x - diag, y - diag, z - diag);
00143 glVertex3d(x + diag, y + diag, z + diag);
00144 glVertex3d(x - diag, y - diag, z + diag);
00145 glVertex3d(x + diag, y + diag, z - diag);
00146 glVertex3d(x - diag, y + diag, z - diag);
00147 glVertex3d(x + diag, y - diag, z + diag);
00148 glVertex3d(x - diag, y + diag, z + diag);
00149 glVertex3d(x + diag, y - diag, z - diag);
00150 }
00151 glEnd();
00152 }
00153 glEnable(GL_LIGHTING);
00154 }