ROOT logo
// @(#)root/gl:$Id: TGLSelectRecord.cxx 33124 2010-04-21 20:04:42Z matevz $
// Author:  Matevz Tadel, Jun 2007

/*************************************************************************
 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TGLSelectRecord.h"
#include <TObject.h>

#include <string.h>

//==============================================================================
// TGLSelectRecordBase
//==============================================================================

//______________________________________________________________________
//
// Base class for select records.
// Supports initialization from a raw GL record (UInt_t*) and
// copies the name-data into internal array.
//

ClassImp(TGLSelectRecordBase);

//______________________________________________________________________________
TGLSelectRecordBase::TGLSelectRecordBase() :
   fN     (0),
   fItems (0),
   fMinZ  (0),
   fMaxZ  (0),
   fPos   (0)
{
   // Default constructor.
}

//______________________________________________________________________________
TGLSelectRecordBase::TGLSelectRecordBase(UInt_t* data) :
   fN     (data[0]),
   fItems (0),
   fMinZ  ((Float_t)data[1] / 0x7fffffff),
   fMaxZ  ((Float_t)data[2] / 0x7fffffff),
   fPos   (0)
{
   // Constructor from raw GL-select record.

   CopyItems(&data[3]);
}

//______________________________________________________________________________
TGLSelectRecordBase::TGLSelectRecordBase(const TGLSelectRecordBase& rec) :
   fN     (rec.fN),
   fItems (0),
   fMinZ  (rec.fMinZ),
   fMaxZ  (rec.fMaxZ),
   fPos   (rec.fPos)
{
   // Copy constructor.

   CopyItems(rec.fItems);
}

//______________________________________________________________________________
TGLSelectRecordBase::~TGLSelectRecordBase()
{
   // Destructor.

   delete [] fItems;
}

//______________________________________________________________________________
TGLSelectRecordBase& TGLSelectRecordBase::operator=(const TGLSelectRecordBase& rec)
{
   // Copy operator.

   if (this != &rec)
   {
      fN      = rec.fN;
      fMinZ   = rec.fMinZ;
      fMaxZ   = rec.fMaxZ;
      fPos    = rec.fPos;
      CopyItems(rec.fItems);
   }
   return *this;
}

//______________________________________________________________________________
void TGLSelectRecordBase::CopyItems(UInt_t* items)
{
   // Copy data from names. fN must already be set.

   delete [] fItems;
   if (fN > 0) {
      fItems = new UInt_t[fN];
      memcpy(fItems, items, fN*sizeof(UInt_t));
   } else {
      fItems = 0;
   }
}

//______________________________________________________________________________
void TGLSelectRecordBase::SetRawOnly(UInt_t* data)
{
   // Setup the record from raw buffer.

   fN     = data[0];
   fMinZ  = (Float_t)data[1] / 0x7fffffff;
   fMaxZ  = (Float_t)data[2] / 0x7fffffff;
   CopyItems(&data[3]);
}

//______________________________________________________________________________
void TGLSelectRecordBase::Set(UInt_t* data)
{
   // Setup the record from raw buffer.

   fN     = data[0];
   fMinZ  = (Float_t)data[1] / 0x7fffffff;
   fMaxZ  = (Float_t)data[2] / 0x7fffffff;
   fPos   = 0;
   CopyItems(&data[3]);
}

//______________________________________________________________________________
void TGLSelectRecordBase::Reset()
{
   // Reinitalize all data to null values.

   delete [] fItems;
   fN     = 0;
   fItems = 0;
   fMinZ  = 0;
   fMaxZ  = 0;
   fPos   = 0;
}


//==============================================================================
// TGLSelectRecord
//==============================================================================

//______________________________________________________________________
//
// Standard selection record including information about containing
// scene and details ob out selected object (TGLPhysicalShape*,
// TObject* or simply a void* for foreign scenes).
//

ClassImp(TGLSelectRecord);

//______________________________________________________________________________
TGLSelectRecord::TGLSelectRecord() :
   TGLSelectRecordBase(),
   fTransparent (kFALSE),
   fSceneInfo   (0),
   fPhysShape   (0),
   fObject      (0),
   fSpecific    (0),
   fMultiple    (kFALSE),
   fHighlight   (kFALSE),
   fSecSelRes   (kNone)
{
   // Default constructor.
}

//______________________________________________________________________________
TGLSelectRecord::TGLSelectRecord(UInt_t* data) :
   TGLSelectRecordBase(data),
   fTransparent (kFALSE),
   fSceneInfo   (0),
   fPhysShape   (0),
   fObject      (0),
   fSpecific    (0),
   fMultiple    (kFALSE),
   fHighlight   (kFALSE),
   fSecSelRes   (kNone)
{
   // Constructor from raw GL-select record.
}

//______________________________________________________________________________
TGLSelectRecord::TGLSelectRecord(const TGLSelectRecord& rec) :
   TGLSelectRecordBase(rec),
   fTransparent (rec.fTransparent),
   fSceneInfo   (rec.fSceneInfo),
   fPhysShape   (rec.fPhysShape),
   fObject      (rec.fObject),
   fSpecific    (rec.fSpecific),
   fMultiple    (rec.fMultiple),
   fHighlight   (rec.fHighlight),
   fSecSelRes   (kNone)
{
   // Copy constructor.
}

//______________________________________________________________________________
TGLSelectRecord::~TGLSelectRecord()
{
   // Destructor.
}

//______________________________________________________________________________
TGLSelectRecord& TGLSelectRecord::operator=(const TGLSelectRecord& rec)
{
   // Copy operator.

   if (this != &rec)
   {
      TGLSelectRecordBase::operator=(rec);
      fTransparent = rec.fTransparent;
      fSceneInfo   = rec.fSceneInfo;
      fPhysShape   = rec.fPhysShape;
      fObject      = rec.fObject;
      fSpecific    = rec.fSpecific;
      fMultiple    = rec.fMultiple;
      fHighlight   = rec.fHighlight;
      fSecSelRes   = rec.fSecSelRes;
   }
   return *this;
}

//______________________________________________________________________________
void TGLSelectRecord::Set(UInt_t* data)
{
   // Setup the record from raw buffer.
   // Non-core members are reset.

   TGLSelectRecordBase::Set(data);
   fTransparent = kFALSE;
   fSceneInfo   = 0;
   fPhysShape   = 0;
   fObject      = 0;
   fSpecific    = 0;
   fMultiple    = kFALSE;
   fHighlight   = kFALSE;
   fSecSelRes   = kNone;
}

//______________________________________________________________________________
void TGLSelectRecord::Reset()
{
   // Reinitalize all data to null values.

   TGLSelectRecordBase::Reset();
   fTransparent = kFALSE;
   fSceneInfo   = 0;
   fPhysShape   = 0;
   fObject      = 0;
   fSpecific    = 0;
   fMultiple    = kFALSE;
   fHighlight   = kFALSE;
   fSecSelRes   = kNone;
}

//______________________________________________________________________________
void TGLSelectRecord::Print()
{
   // Print contents of the select record to stdout.

   printf("SelectRecord   N=%d, miZ=%.4f, maxZ=%.4f\n"
          "    sceneinfo=%p, pshp=%p, transp=%d,\n"
          "    tobj=%p (name='%s'), spec=%p\n",
          fN, fMinZ, fMaxZ,
          fSceneInfo,  fPhysShape,  fTransparent,
          fObject, fObject ? fObject->GetName() : "",
          fSpecific);
}

//______________________________________________________________________________
Bool_t TGLSelectRecord::AreSameSelectionWise(const TGLSelectRecord& r1,
                                             const TGLSelectRecord& r2)
{
   // Check if the records imply the same selection result, that is,
   // their secondary members are all equal.

   return r1.fSceneInfo == r2.fSceneInfo && r1.fPhysShape == r2.fPhysShape &&
          r1.fObject    == r2.fObject    && r1.fSpecific  == r2.fSpecific;
}


//==============================================================================
// TGLOvlSelectRecord
//==============================================================================

//______________________________________________________________________
//
// Selection record for overlay objects.
//

ClassImp(TGLOvlSelectRecord);

//______________________________________________________________________________
TGLOvlSelectRecord::TGLOvlSelectRecord() :
   TGLSelectRecordBase(),
   fOvlElement (0)
{
   // Default constructor.
}

//______________________________________________________________________________
TGLOvlSelectRecord::TGLOvlSelectRecord(UInt_t* data) :
   TGLSelectRecordBase(data),
   fOvlElement (0)
{
   // Constructor from raw GL-select record.
}

//______________________________________________________________________________
TGLOvlSelectRecord::TGLOvlSelectRecord(const TGLOvlSelectRecord& rec) :
   TGLSelectRecordBase(rec),
   fOvlElement (rec.fOvlElement)
{
   // Copy constructor.
}

//______________________________________________________________________________
TGLOvlSelectRecord::~TGLOvlSelectRecord()
{
   // Destructor.
}

//______________________________________________________________________________
TGLOvlSelectRecord& TGLOvlSelectRecord::operator=(const TGLOvlSelectRecord& rec)
{
   // Copy operator.

   if (this != &rec)
   {
      TGLSelectRecordBase::operator=(rec);
      fOvlElement = rec.fOvlElement;
   }
   return *this;
}

//______________________________________________________________________________
void TGLOvlSelectRecord::Set(UInt_t* data)
{
   // Setup the record from raw buffer.
   // Non-core members are reset.

   TGLSelectRecordBase::Set(data);
   fOvlElement = 0;
}

//______________________________________________________________________________
void TGLOvlSelectRecord::Reset()
{
   // Reinitalize all data to null values.

   TGLSelectRecordBase::Reset();
   fOvlElement = 0;
}

 TGLSelectRecord.cxx:1
 TGLSelectRecord.cxx:2
 TGLSelectRecord.cxx:3
 TGLSelectRecord.cxx:4
 TGLSelectRecord.cxx:5
 TGLSelectRecord.cxx:6
 TGLSelectRecord.cxx:7
 TGLSelectRecord.cxx:8
 TGLSelectRecord.cxx:9
 TGLSelectRecord.cxx:10
 TGLSelectRecord.cxx:11
 TGLSelectRecord.cxx:12
 TGLSelectRecord.cxx:13
 TGLSelectRecord.cxx:14
 TGLSelectRecord.cxx:15
 TGLSelectRecord.cxx:16
 TGLSelectRecord.cxx:17
 TGLSelectRecord.cxx:18
 TGLSelectRecord.cxx:19
 TGLSelectRecord.cxx:20
 TGLSelectRecord.cxx:21
 TGLSelectRecord.cxx:22
 TGLSelectRecord.cxx:23
 TGLSelectRecord.cxx:24
 TGLSelectRecord.cxx:25
 TGLSelectRecord.cxx:26
 TGLSelectRecord.cxx:27
 TGLSelectRecord.cxx:28
 TGLSelectRecord.cxx:29
 TGLSelectRecord.cxx:30
 TGLSelectRecord.cxx:31
 TGLSelectRecord.cxx:32
 TGLSelectRecord.cxx:33
 TGLSelectRecord.cxx:34
 TGLSelectRecord.cxx:35
 TGLSelectRecord.cxx:36
 TGLSelectRecord.cxx:37
 TGLSelectRecord.cxx:38
 TGLSelectRecord.cxx:39
 TGLSelectRecord.cxx:40
 TGLSelectRecord.cxx:41
 TGLSelectRecord.cxx:42
 TGLSelectRecord.cxx:43
 TGLSelectRecord.cxx:44
 TGLSelectRecord.cxx:45
 TGLSelectRecord.cxx:46
 TGLSelectRecord.cxx:47
 TGLSelectRecord.cxx:48
 TGLSelectRecord.cxx:49
 TGLSelectRecord.cxx:50
 TGLSelectRecord.cxx:51
 TGLSelectRecord.cxx:52
 TGLSelectRecord.cxx:53
 TGLSelectRecord.cxx:54
 TGLSelectRecord.cxx:55
 TGLSelectRecord.cxx:56
 TGLSelectRecord.cxx:57
 TGLSelectRecord.cxx:58
 TGLSelectRecord.cxx:59
 TGLSelectRecord.cxx:60
 TGLSelectRecord.cxx:61
 TGLSelectRecord.cxx:62
 TGLSelectRecord.cxx:63
 TGLSelectRecord.cxx:64
 TGLSelectRecord.cxx:65
 TGLSelectRecord.cxx:66
 TGLSelectRecord.cxx:67
 TGLSelectRecord.cxx:68
 TGLSelectRecord.cxx:69
 TGLSelectRecord.cxx:70
 TGLSelectRecord.cxx:71
 TGLSelectRecord.cxx:72
 TGLSelectRecord.cxx:73
 TGLSelectRecord.cxx:74
 TGLSelectRecord.cxx:75
 TGLSelectRecord.cxx:76
 TGLSelectRecord.cxx:77
 TGLSelectRecord.cxx:78
 TGLSelectRecord.cxx:79
 TGLSelectRecord.cxx:80
 TGLSelectRecord.cxx:81
 TGLSelectRecord.cxx:82
 TGLSelectRecord.cxx:83
 TGLSelectRecord.cxx:84
 TGLSelectRecord.cxx:85
 TGLSelectRecord.cxx:86
 TGLSelectRecord.cxx:87
 TGLSelectRecord.cxx:88
 TGLSelectRecord.cxx:89
 TGLSelectRecord.cxx:90
 TGLSelectRecord.cxx:91
 TGLSelectRecord.cxx:92
 TGLSelectRecord.cxx:93
 TGLSelectRecord.cxx:94
 TGLSelectRecord.cxx:95
 TGLSelectRecord.cxx:96
 TGLSelectRecord.cxx:97
 TGLSelectRecord.cxx:98
 TGLSelectRecord.cxx:99
 TGLSelectRecord.cxx:100
 TGLSelectRecord.cxx:101
 TGLSelectRecord.cxx:102
 TGLSelectRecord.cxx:103
 TGLSelectRecord.cxx:104
 TGLSelectRecord.cxx:105
 TGLSelectRecord.cxx:106
 TGLSelectRecord.cxx:107
 TGLSelectRecord.cxx:108
 TGLSelectRecord.cxx:109
 TGLSelectRecord.cxx:110
 TGLSelectRecord.cxx:111
 TGLSelectRecord.cxx:112
 TGLSelectRecord.cxx:113
 TGLSelectRecord.cxx:114
 TGLSelectRecord.cxx:115
 TGLSelectRecord.cxx:116
 TGLSelectRecord.cxx:117
 TGLSelectRecord.cxx:118
 TGLSelectRecord.cxx:119
 TGLSelectRecord.cxx:120
 TGLSelectRecord.cxx:121
 TGLSelectRecord.cxx:122
 TGLSelectRecord.cxx:123
 TGLSelectRecord.cxx:124
 TGLSelectRecord.cxx:125
 TGLSelectRecord.cxx:126
 TGLSelectRecord.cxx:127
 TGLSelectRecord.cxx:128
 TGLSelectRecord.cxx:129
 TGLSelectRecord.cxx:130
 TGLSelectRecord.cxx:131
 TGLSelectRecord.cxx:132
 TGLSelectRecord.cxx:133
 TGLSelectRecord.cxx:134
 TGLSelectRecord.cxx:135
 TGLSelectRecord.cxx:136
 TGLSelectRecord.cxx:137
 TGLSelectRecord.cxx:138
 TGLSelectRecord.cxx:139
 TGLSelectRecord.cxx:140
 TGLSelectRecord.cxx:141
 TGLSelectRecord.cxx:142
 TGLSelectRecord.cxx:143
 TGLSelectRecord.cxx:144
 TGLSelectRecord.cxx:145
 TGLSelectRecord.cxx:146
 TGLSelectRecord.cxx:147
 TGLSelectRecord.cxx:148
 TGLSelectRecord.cxx:149
 TGLSelectRecord.cxx:150
 TGLSelectRecord.cxx:151
 TGLSelectRecord.cxx:152
 TGLSelectRecord.cxx:153
 TGLSelectRecord.cxx:154
 TGLSelectRecord.cxx:155
 TGLSelectRecord.cxx:156
 TGLSelectRecord.cxx:157
 TGLSelectRecord.cxx:158
 TGLSelectRecord.cxx:159
 TGLSelectRecord.cxx:160
 TGLSelectRecord.cxx:161
 TGLSelectRecord.cxx:162
 TGLSelectRecord.cxx:163
 TGLSelectRecord.cxx:164
 TGLSelectRecord.cxx:165
 TGLSelectRecord.cxx:166
 TGLSelectRecord.cxx:167
 TGLSelectRecord.cxx:168
 TGLSelectRecord.cxx:169
 TGLSelectRecord.cxx:170
 TGLSelectRecord.cxx:171
 TGLSelectRecord.cxx:172
 TGLSelectRecord.cxx:173
 TGLSelectRecord.cxx:174
 TGLSelectRecord.cxx:175
 TGLSelectRecord.cxx:176
 TGLSelectRecord.cxx:177
 TGLSelectRecord.cxx:178
 TGLSelectRecord.cxx:179
 TGLSelectRecord.cxx:180
 TGLSelectRecord.cxx:181
 TGLSelectRecord.cxx:182
 TGLSelectRecord.cxx:183
 TGLSelectRecord.cxx:184
 TGLSelectRecord.cxx:185
 TGLSelectRecord.cxx:186
 TGLSelectRecord.cxx:187
 TGLSelectRecord.cxx:188
 TGLSelectRecord.cxx:189
 TGLSelectRecord.cxx:190
 TGLSelectRecord.cxx:191
 TGLSelectRecord.cxx:192
 TGLSelectRecord.cxx:193
 TGLSelectRecord.cxx:194
 TGLSelectRecord.cxx:195
 TGLSelectRecord.cxx:196
 TGLSelectRecord.cxx:197
 TGLSelectRecord.cxx:198
 TGLSelectRecord.cxx:199
 TGLSelectRecord.cxx:200
 TGLSelectRecord.cxx:201
 TGLSelectRecord.cxx:202
 TGLSelectRecord.cxx:203
 TGLSelectRecord.cxx:204
 TGLSelectRecord.cxx:205
 TGLSelectRecord.cxx:206
 TGLSelectRecord.cxx:207
 TGLSelectRecord.cxx:208
 TGLSelectRecord.cxx:209
 TGLSelectRecord.cxx:210
 TGLSelectRecord.cxx:211
 TGLSelectRecord.cxx:212
 TGLSelectRecord.cxx:213
 TGLSelectRecord.cxx:214
 TGLSelectRecord.cxx:215
 TGLSelectRecord.cxx:216
 TGLSelectRecord.cxx:217
 TGLSelectRecord.cxx:218
 TGLSelectRecord.cxx:219
 TGLSelectRecord.cxx:220
 TGLSelectRecord.cxx:221
 TGLSelectRecord.cxx:222
 TGLSelectRecord.cxx:223
 TGLSelectRecord.cxx:224
 TGLSelectRecord.cxx:225
 TGLSelectRecord.cxx:226
 TGLSelectRecord.cxx:227
 TGLSelectRecord.cxx:228
 TGLSelectRecord.cxx:229
 TGLSelectRecord.cxx:230
 TGLSelectRecord.cxx:231
 TGLSelectRecord.cxx:232
 TGLSelectRecord.cxx:233
 TGLSelectRecord.cxx:234
 TGLSelectRecord.cxx:235
 TGLSelectRecord.cxx:236
 TGLSelectRecord.cxx:237
 TGLSelectRecord.cxx:238
 TGLSelectRecord.cxx:239
 TGLSelectRecord.cxx:240
 TGLSelectRecord.cxx:241
 TGLSelectRecord.cxx:242
 TGLSelectRecord.cxx:243
 TGLSelectRecord.cxx:244
 TGLSelectRecord.cxx:245
 TGLSelectRecord.cxx:246
 TGLSelectRecord.cxx:247
 TGLSelectRecord.cxx:248
 TGLSelectRecord.cxx:249
 TGLSelectRecord.cxx:250
 TGLSelectRecord.cxx:251
 TGLSelectRecord.cxx:252
 TGLSelectRecord.cxx:253
 TGLSelectRecord.cxx:254
 TGLSelectRecord.cxx:255
 TGLSelectRecord.cxx:256
 TGLSelectRecord.cxx:257
 TGLSelectRecord.cxx:258
 TGLSelectRecord.cxx:259
 TGLSelectRecord.cxx:260
 TGLSelectRecord.cxx:261
 TGLSelectRecord.cxx:262
 TGLSelectRecord.cxx:263
 TGLSelectRecord.cxx:264
 TGLSelectRecord.cxx:265
 TGLSelectRecord.cxx:266
 TGLSelectRecord.cxx:267
 TGLSelectRecord.cxx:268
 TGLSelectRecord.cxx:269
 TGLSelectRecord.cxx:270
 TGLSelectRecord.cxx:271
 TGLSelectRecord.cxx:272
 TGLSelectRecord.cxx:273
 TGLSelectRecord.cxx:274
 TGLSelectRecord.cxx:275
 TGLSelectRecord.cxx:276
 TGLSelectRecord.cxx:277
 TGLSelectRecord.cxx:278
 TGLSelectRecord.cxx:279
 TGLSelectRecord.cxx:280
 TGLSelectRecord.cxx:281
 TGLSelectRecord.cxx:282
 TGLSelectRecord.cxx:283
 TGLSelectRecord.cxx:284
 TGLSelectRecord.cxx:285
 TGLSelectRecord.cxx:286
 TGLSelectRecord.cxx:287
 TGLSelectRecord.cxx:288
 TGLSelectRecord.cxx:289
 TGLSelectRecord.cxx:290
 TGLSelectRecord.cxx:291
 TGLSelectRecord.cxx:292
 TGLSelectRecord.cxx:293
 TGLSelectRecord.cxx:294
 TGLSelectRecord.cxx:295
 TGLSelectRecord.cxx:296
 TGLSelectRecord.cxx:297
 TGLSelectRecord.cxx:298
 TGLSelectRecord.cxx:299
 TGLSelectRecord.cxx:300
 TGLSelectRecord.cxx:301
 TGLSelectRecord.cxx:302
 TGLSelectRecord.cxx:303
 TGLSelectRecord.cxx:304
 TGLSelectRecord.cxx:305
 TGLSelectRecord.cxx:306
 TGLSelectRecord.cxx:307
 TGLSelectRecord.cxx:308
 TGLSelectRecord.cxx:309
 TGLSelectRecord.cxx:310
 TGLSelectRecord.cxx:311
 TGLSelectRecord.cxx:312
 TGLSelectRecord.cxx:313
 TGLSelectRecord.cxx:314
 TGLSelectRecord.cxx:315
 TGLSelectRecord.cxx:316
 TGLSelectRecord.cxx:317
 TGLSelectRecord.cxx:318
 TGLSelectRecord.cxx:319
 TGLSelectRecord.cxx:320
 TGLSelectRecord.cxx:321
 TGLSelectRecord.cxx:322
 TGLSelectRecord.cxx:323
 TGLSelectRecord.cxx:324
 TGLSelectRecord.cxx:325
 TGLSelectRecord.cxx:326
 TGLSelectRecord.cxx:327
 TGLSelectRecord.cxx:328
 TGLSelectRecord.cxx:329
 TGLSelectRecord.cxx:330
 TGLSelectRecord.cxx:331
 TGLSelectRecord.cxx:332
 TGLSelectRecord.cxx:333
 TGLSelectRecord.cxx:334
 TGLSelectRecord.cxx:335
 TGLSelectRecord.cxx:336
 TGLSelectRecord.cxx:337
 TGLSelectRecord.cxx:338
 TGLSelectRecord.cxx:339
 TGLSelectRecord.cxx:340
 TGLSelectRecord.cxx:341
 TGLSelectRecord.cxx:342
 TGLSelectRecord.cxx:343
 TGLSelectRecord.cxx:344
 TGLSelectRecord.cxx:345
 TGLSelectRecord.cxx:346
 TGLSelectRecord.cxx:347
 TGLSelectRecord.cxx:348
 TGLSelectRecord.cxx:349
 TGLSelectRecord.cxx:350
 TGLSelectRecord.cxx:351
 TGLSelectRecord.cxx:352
 TGLSelectRecord.cxx:353
 TGLSelectRecord.cxx:354
 TGLSelectRecord.cxx:355
 TGLSelectRecord.cxx:356
 TGLSelectRecord.cxx:357