// @(#)root/gl:$Id: TGLSelectRecord.cxx 20882 2007-11-19 11:31:26Z rdm $
// 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)
{
   // Default constructor.
}

//______________________________________________________________________________
TGLSelectRecord::TGLSelectRecord(UInt_t* data) :
   TGLSelectRecordBase(data),
   fTransparent (kFALSE),
   fSceneInfo   (0),
   fPhysShape   (0),
   fObject      (0),
   fSpecific    (0)
{
   // 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)
{
   // 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;
   }
   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;
}

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

   TGLSelectRecordBase::Reset();
   fTransparent = kFALSE;
   fSceneInfo   = 0;
   fPhysShape   = 0;
   fObject      = 0;
   fSpecific    = 0;
}

//______________________________________________________________________________
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;
}


Last change: Wed Jun 25 08:41:22 2008
Last generated: 2008-06-25 08:41

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.