From $ROOTSYS/tutorials/eve/quadset.C

// @(#)root/eve:$Id$
// Author: Matevz Tadel

// Demonstates usage of 2D digit class TEveQuadSet.

TEveQuadSet* quadset(Float_t x=0, Float_t y=0, Float_t z=0,
                       Int_t num=100, Bool_t registerSet=kTRUE)
{
   TEveManager::Create();

   TRandom r(0);
   gStyle->SetPalette(1, 0);

   TEveRGBAPalette *pal = new TEveRGBAPalette(0, 130);
   TEveFrameBox    *box = new TEveFrameBox();
   box->SetAAQuadXY(-10, -10, 0, 20, 20);
   box->SetFrameColor(kGray);

   TEveQuadSet* q = new TEveQuadSet("RectangleXY");
   q->SetOwnIds(kTRUE);
   q->SetPalette(pal);
   q->SetFrame(box);
   q->Reset(TEveQuadSet::kQT_RectangleXY, kFALSE, 32);
   for (Int_t i=0; i<num; ++i)
   {
      q->AddQuad(r.Uniform(-10, 9), r.Uniform(-10, 9), 0,
                 r.Uniform(0.2, 1), r.Uniform(0.2, 1));
      q->QuadValue(r.Uniform(0, 130));
      q->QuadId(new TNamed(Form("QuadIdx %d", i),
                           "TNamed assigned to a quad as an indentifier."));
   }
   q->RefitPlex();

   TEveTrans& t = q->RefMainTrans();
   t.RotateLF(1, 3, 0.5*TMath::Pi());
   t.SetPos(x, y, z);

   TGLViewer* v = gEve->GetDefaultGLViewer();
   v->SetCurrentCamera(TGLViewer::kCameraOrthoZOY);
   TGLCameraOverlay* co = v->GetCameraOverlay();
   co->SetShowOrthographic(kTRUE);
   co->SetOrthographicMode(TGLCameraOverlay::kGridFront);

   // Uncomment these two lines to get internal highlight / selection.
   // q->SetPickable(1);
   // q->SetAlwaysSecSelect(1);

   TEveRGBAPaletteOverlay *po = new TEveRGBAPaletteOverlay(pal, 0.55, 0.1, 0.4, 0.05);
   v = gEve->GetDefaultGLViewer();
   v->AddOverlayElement(po);

   // To set user-interface (GUI + overlay) to display real values
   // mapped with a linear function: r = 0.1 * i + 0;
   // pal->SetUIDoubleRep(kTRUE, 0.1, 0);

   if (registerSet)
   {
      gEve->AddElement(q);
      gEve->Redraw3D(kTRUE);
   }

   Info("quadset", "use alt-left-mouse to select individual digits.");

   return q;
}

TEveQuadSet* quadset_emc(Float_t x=0, Float_t y=0, Float_t z=0, Int_t num=100)
{
   TEveManager::Create();

   TRandom r(0);
   gStyle->SetPalette(1, 0);

   TEveQuadSet* q = new TEveQuadSet("EMC Supermodule");
   q->SetOwnIds(kTRUE);
   q->Reset(TEveQuadSet::kQT_RectangleXZFixedDimY, kFALSE, 32);
   q->SetDefWidth(8);
   q->SetDefHeight(8);

   for (Int_t i=0; i<num; ++i)
   {
      q->AddQuad(r.Uniform(-100, 100), r.Uniform(-100, 100));
      q->QuadValue(r.Uniform(0, 130));
      q->QuadId(new TNamed(Form("Cell %d", i), "Dong!"));
   }
   q->RefitPlex();

   TEveTrans& t = q->RefMainTrans();
   t.SetPos(x, y, z);

   gEve->AddElement(q);
   gEve->Redraw3D();

   return q;
}

TEveQuadSet* quadset_circ()
{
   TEveManager::Create();

   TRandom rnd(0);
   gStyle->SetPalette(1, 0);

   Float_t R = 10, dW = 1, dH = .5;

   TEveFrameBox *box = new TEveFrameBox();
   {
      Float_t  frame[3*36];
      Float_t *p = frame;
      for (Int_t i = 0; i < 36; ++i, p += 3) {
         p[0] = 11 * TMath::Cos(TMath::TwoPi()*i/36);
         p[1] = 11 * TMath::Sin(TMath::TwoPi()*i/36);
         p[2] = 0;
      }
      box->SetQuadByPoints(frame, 36);
   }
   box->SetFrameColor(kGray);

   TEveQuadSet* q = new TEveQuadSet("Pepe");
   q->SetFrame(box);
   q->Reset(TEveQuadSet::kQT_HexagonXY, kFALSE, 32);

   for (Float_t r = R; r > 2; r *= 0.8)
   {
      Int_t maxI = 2.0*TMath::Pi()*r / 2;
      for (Int_t i = 0; i < maxI; ++i)
      {
         Float_t x = r * TMath::Cos(TMath::TwoPi()*i/maxI);
         Float_t y = r * TMath::Sin(TMath::TwoPi()*i/maxI);
         q->AddHexagon(x, y, rnd.Uniform(-1, 1), rnd.Uniform(0.2, 1));
         q->QuadValue(rnd.Uniform(0, 130));
      }
   }
   q->RefitPlex();

   TEveTrans& t = q->RefMainTrans();
   t.RotateLF(1, 3, 0.5*TMath::Pi());

   gEve->AddElement(q);
   gEve->Redraw3D();

   return q;
}

TEveQuadSet* quadset_hex(Float_t x=0, Float_t y=0, Float_t z=0,
                           Int_t num=100, Bool_t registerSet=kTRUE)
{
   TEveManager::Create();

   TRandom r(0);
   gStyle->SetPalette(1, 0);

   {
      TEveQuadSet* q = new TEveQuadSet("HexagonXY");
      q->Reset(TEveQuadSet::kQT_HexagonXY, kFALSE, 32);
      for (Int_t i=0; i<num; ++i)
      {
         q->AddHexagon(r.Uniform(-10, 10),
                       r.Uniform(-10, 10),
                       r.Uniform(-10, 10),
                       r.Uniform(0.2, 1));
         q->QuadValue(r.Uniform(0, 120));
      }
      q->RefitPlex();

      TEveTrans& t = q->RefMainTrans();
      t.SetPos(x, y, z);

      if (registerSet)
      {
         gEve->AddElement(q);
         gEve->Redraw3D();
      }
   }

   {
      TEveQuadSet* q = new TEveQuadSet("HexagonYX");
      q->Reset(TEveQuadSet::kQT_HexagonYX, kFALSE, 32);
      for (Int_t i=0; i<num; ++i)
      {
         q->AddHexagon(r.Uniform(-10, 10),
                       r.Uniform(-10, 10),
                       r.Uniform(-10, 10),
                       r.Uniform(0.2, 1));
         q->QuadValue(r.Uniform(0, 120));
      }
      q->RefitPlex();

      TEveTrans& t = q->RefMainTrans();
      t.SetPos(x, y, z);

      if (registerSet)
      {
         gEve->AddElement(q);
         gEve->Redraw3D();
      }

      return q;
   }
}

TEveQuadSet* quadset_hexid(Float_t x=0, Float_t y=0, Float_t z=0,
                             Int_t num=100, Bool_t registerSet=kTRUE)
{
   TEveManager::Create();

   TRandom r(0);
   gStyle->SetPalette(1, 0);

   TEveQuadSet* q = new TEveQuadSet("HexagonXY");

   {

      q->SetOwnIds(kTRUE);
      q->Reset(TEveQuadSet::kQT_HexagonXY, kFALSE, 32);
      for (Int_t i=0; i<num; ++i)
      {
         q->AddHexagon(r.Uniform(-10, 10),
                       r.Uniform(-10, 10),
                       r.Uniform(-10, 10),
                       r.Uniform(0.2, 1));
         q->QuadValue(r.Uniform(0, 120));
         q->QuadId(new TNamed(Form("Quad with idx=%d", i),
                              "This title is not confusing."));
      }
      q->RefitPlex();

      TEveTrans& t = q->RefMainTrans();
      t.SetPos(x, y, z);

      if (registerSet)
      {
         gEve->AddElement(q);
         gEve->Redraw3D();
      }
   }

   // This show another way of getting notified about
   // secondary selection hit. The callback function and the
   // setting of it must be done in compiled code.
   gROOT->ProcessLine(".L quadset_callback.cxx+");
   quadset_set_callback(q);

   return q;
}

void quadset_hierarchy(Int_t n=4)
{
   TEveManager::Create();

   gStyle->SetPalette(1, 0);

   TEveRGBAPalette* pal = new TEveRGBAPalette(20, 100);
   pal->SetLimits(0, 120);

   TEveFrameBox* box = new TEveFrameBox();
   box->SetAABox(-10, -10, -10, 20, 20, 20);
   box->SetFrameColor(33);

   TEveElementList* l = new TEveElementList("Parent/Dir");
   l->SetTitle("Tooltip");
   //  l->SetMainColor(3);
   gEve->AddElement(l);

   for (Int_t i=0; i<n; ++i)
   {
      TEveQuadSet* qs = quadset_hexid(0, 0, 50*i, 50, kFALSE);
      qs->SetPalette(pal);
      qs->SetFrame(box);
      l->AddElement(qs);
   }

   gEve->Redraw3D();
}
 quadset.C:1
 quadset.C:2
 quadset.C:3
 quadset.C:4
 quadset.C:5
 quadset.C:6
 quadset.C:7
 quadset.C:8
 quadset.C:9
 quadset.C:10
 quadset.C:11
 quadset.C:12
 quadset.C:13
 quadset.C:14
 quadset.C:15
 quadset.C:16
 quadset.C:17
 quadset.C:18
 quadset.C:19
 quadset.C:20
 quadset.C:21
 quadset.C:22
 quadset.C:23
 quadset.C:24
 quadset.C:25
 quadset.C:26
 quadset.C:27
 quadset.C:28
 quadset.C:29
 quadset.C:30
 quadset.C:31
 quadset.C:32
 quadset.C:33
 quadset.C:34
 quadset.C:35
 quadset.C:36
 quadset.C:37
 quadset.C:38
 quadset.C:39
 quadset.C:40
 quadset.C:41
 quadset.C:42
 quadset.C:43
 quadset.C:44
 quadset.C:45
 quadset.C:46
 quadset.C:47
 quadset.C:48
 quadset.C:49
 quadset.C:50
 quadset.C:51
 quadset.C:52
 quadset.C:53
 quadset.C:54
 quadset.C:55
 quadset.C:56
 quadset.C:57
 quadset.C:58
 quadset.C:59
 quadset.C:60
 quadset.C:61
 quadset.C:62
 quadset.C:63
 quadset.C:64
 quadset.C:65
 quadset.C:66
 quadset.C:67
 quadset.C:68
 quadset.C:69
 quadset.C:70
 quadset.C:71
 quadset.C:72
 quadset.C:73
 quadset.C:74
 quadset.C:75
 quadset.C:76
 quadset.C:77
 quadset.C:78
 quadset.C:79
 quadset.C:80
 quadset.C:81
 quadset.C:82
 quadset.C:83
 quadset.C:84
 quadset.C:85
 quadset.C:86
 quadset.C:87
 quadset.C:88
 quadset.C:89
 quadset.C:90
 quadset.C:91
 quadset.C:92
 quadset.C:93
 quadset.C:94
 quadset.C:95
 quadset.C:96
 quadset.C:97
 quadset.C:98
 quadset.C:99
 quadset.C:100
 quadset.C:101
 quadset.C:102
 quadset.C:103
 quadset.C:104
 quadset.C:105
 quadset.C:106
 quadset.C:107
 quadset.C:108
 quadset.C:109
 quadset.C:110
 quadset.C:111
 quadset.C:112
 quadset.C:113
 quadset.C:114
 quadset.C:115
 quadset.C:116
 quadset.C:117
 quadset.C:118
 quadset.C:119
 quadset.C:120
 quadset.C:121
 quadset.C:122
 quadset.C:123
 quadset.C:124
 quadset.C:125
 quadset.C:126
 quadset.C:127
 quadset.C:128
 quadset.C:129
 quadset.C:130
 quadset.C:131
 quadset.C:132
 quadset.C:133
 quadset.C:134
 quadset.C:135
 quadset.C:136
 quadset.C:137
 quadset.C:138
 quadset.C:139
 quadset.C:140
 quadset.C:141
 quadset.C:142
 quadset.C:143
 quadset.C:144
 quadset.C:145
 quadset.C:146
 quadset.C:147
 quadset.C:148
 quadset.C:149
 quadset.C:150
 quadset.C:151
 quadset.C:152
 quadset.C:153
 quadset.C:154
 quadset.C:155
 quadset.C:156
 quadset.C:157
 quadset.C:158
 quadset.C:159
 quadset.C:160
 quadset.C:161
 quadset.C:162
 quadset.C:163
 quadset.C:164
 quadset.C:165
 quadset.C:166
 quadset.C:167
 quadset.C:168
 quadset.C:169
 quadset.C:170
 quadset.C:171
 quadset.C:172
 quadset.C:173
 quadset.C:174
 quadset.C:175
 quadset.C:176
 quadset.C:177
 quadset.C:178
 quadset.C:179
 quadset.C:180
 quadset.C:181
 quadset.C:182
 quadset.C:183
 quadset.C:184
 quadset.C:185
 quadset.C:186
 quadset.C:187
 quadset.C:188
 quadset.C:189
 quadset.C:190
 quadset.C:191
 quadset.C:192
 quadset.C:193
 quadset.C:194
 quadset.C:195
 quadset.C:196
 quadset.C:197
 quadset.C:198
 quadset.C:199
 quadset.C:200
 quadset.C:201
 quadset.C:202
 quadset.C:203
 quadset.C:204
 quadset.C:205
 quadset.C:206
 quadset.C:207
 quadset.C:208
 quadset.C:209
 quadset.C:210
 quadset.C:211
 quadset.C:212
 quadset.C:213
 quadset.C:214
 quadset.C:215
 quadset.C:216
 quadset.C:217
 quadset.C:218
 quadset.C:219
 quadset.C:220
 quadset.C:221
 quadset.C:222
 quadset.C:223
 quadset.C:224
 quadset.C:225
 quadset.C:226
 quadset.C:227
 quadset.C:228
 quadset.C:229
 quadset.C:230
 quadset.C:231
 quadset.C:232
 quadset.C:233
 quadset.C:234
 quadset.C:235
 quadset.C:236
 quadset.C:237
 quadset.C:238
 quadset.C:239
 quadset.C:240
 quadset.C:241
 quadset.C:242
 quadset.C:243
 quadset.C:244
 quadset.C:245
 quadset.C:246
 quadset.C:247
 quadset.C:248
 quadset.C:249
 quadset.C:250
 quadset.C:251
 quadset.C:252
 quadset.C:253
 quadset.C:254
 quadset.C:255
 quadset.C:256
 quadset.C:257
 quadset.C:258
 quadset.C:259
 quadset.C:260
 quadset.C:261
 quadset.C:262
 quadset.C:263
 quadset.C:264
 quadset.C:265
 quadset.C:266
 quadset.C:267
 quadset.C:268
 quadset.C:269
 quadset.C:270
 quadset.C:271
 quadset.C:272
 quadset.C:273
 quadset.C:274
 quadset.C:275