Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEveScalableStraightLineSet.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
13 #include "TEveChunkManager.h"
14 
15 /** \class TEveScalableStraightLineSet
16 \ingroup TEve
17 Straight-line-set with extra scaling, useful for projectables that need
18 to be scaled in accordance with an external object.
19 */
20 
21 ClassImp(TEveScalableStraightLineSet);
22 
23 ////////////////////////////////////////////////////////////////////////////////
24 /// Constructor.
25 
26 TEveScalableStraightLineSet::TEveScalableStraightLineSet(const char* n, const char* t):
27  TEveStraightLineSet (n, t),
28  fCurrentScale(1.0)
29 {
30  fScaleCenter[0] = 0;
31  fScaleCenter[1] = 0;
32  fScaleCenter[2] = 0;
33 }
34 
35 ////////////////////////////////////////////////////////////////////////////////
36 /// Set scale center.
37 
38 void TEveScalableStraightLineSet::SetScaleCenter(Float_t x, Float_t y, Float_t z)
39 {
40  fScaleCenter[0] = x;
41  fScaleCenter[1] = y;
42  fScaleCenter[2] = z;
43 }
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 /// Return current scale.
47 
48 Double_t TEveScalableStraightLineSet::GetScale() const
49 {
50  return fCurrentScale;
51 }
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 /// Loop over line parameters and scale coordinates.
55 
56 void TEveScalableStraightLineSet::SetScale(Double_t scale)
57 {
58  TEveChunkManager::iterator li(GetLinePlex());
59  while (li.next())
60  {
61  TEveStraightLineSet::Line_t& l = * (TEveStraightLineSet::Line_t*) li();
62  l.fV1[0] = fScaleCenter[0]+(l.fV1[0]-fScaleCenter[0])/fCurrentScale*scale;
63  l.fV1[1] = fScaleCenter[1]+(l.fV1[1]-fScaleCenter[1])/fCurrentScale*scale;
64  l.fV1[2] = fScaleCenter[2]+(l.fV1[2]-fScaleCenter[2])/fCurrentScale*scale;
65  l.fV2[0] = fScaleCenter[0]+(l.fV2[0]-fScaleCenter[0])/fCurrentScale*scale;
66  l.fV2[1] = fScaleCenter[1]+(l.fV2[1]-fScaleCenter[1])/fCurrentScale*scale;
67  l.fV2[2] = fScaleCenter[2]+(l.fV2[2]-fScaleCenter[2])/fCurrentScale*scale;
68  }
69  fCurrentScale = scale;
70 }