ROOT logo
// $Id: RndSMorphCreator.cxx 2088 2008-11-23 20:26:46Z matevz $

// Copyright (C) 1999-2008, Matevz Tadel. All rights reserved.
// This file is part of GLED, released under GNU General Public License version 2.
// For the licensing terms see $GLEDSYS/LICENSE or http://www.gnu.org/.

//__________________________________________________________________________
// RndSMorphCreator
//
//

#include "RndSMorphCreator.h"
#include "RndSMorphCreator.c7"
#include "SMorph.h"
#include <Glasses/ZQueen.h>

#include <Gled/GledNS.h>

ClassImp(RndSMorphCreator);

/**************************************************************************/

void RndSMorphCreator::_init()
{
  mTarget = 0;
  bReportID  = true;
  bGetResult = true;
  mRnd.SetSeed(0);
}

/**************************************************************************/

inline
Double_t RndSMorphCreator::rnd(Double_t k, Double_t n)
{
  return k*mRnd.Rndm() + n;
}

/**************************************************************************/

void RndSMorphCreator::Operate(Operator::Arg* op_arg)
{
  static const Exc_t _eh("RndSMorphCreator::Operate ");

  Operator::PreOperate(op_arg);
  if(mTarget != 0) {
    SMorph m(GForm("Random SMorph %d", int(rnd(1e6,1))));
    m.SetPos(rnd(20,-10), rnd(20,-10), rnd(20,-10));
    m.SetUseScale(1);
    m.SetScales(rnd(1.5,0.5), rnd(1.5,0.5), rnd(1.5,0.5));
    m.SetTLevel((int)rnd(20,3)); m.SetPLevel((int)rnd(20,3));
    m.SetColor(rnd(0.6,0.4), rnd(0.6,0.4), rnd(0.6,0.4));

    auto_ptr<ZMIR> mir
      (mTarget->GetQueen()->S_IncarnateWAttach());
    GledNS::StreamLens(*mir, &m);
    auto_ptr<ZMIR> att_mir( mTarget->S_Add(0) );
    mir->ChainMIR(att_mir.get());

    if(bGetResult) {
      auto_ptr<ZMIR_RR> res( mSaturn->ShootMIRWaitResult(mir) );
      if(res->HasException()) {
	cout << _eh << "got exception: " << res->fException.Data() << endl;

      }
      if(res->HasResult()) {
	ID_t id; *res >> id;
	if(bReportID)
	  printf("%sgot id %u, at %p\n", _eh.Data(), id, mSaturn->DemangleID(id));
      }
    } else {
      mSaturn->ShootMIR(mir);
    }
  }
  Operator::PostOperate(op_arg);
}

/**************************************************************************/
 RndSMorphCreator.cxx:1
 RndSMorphCreator.cxx:2
 RndSMorphCreator.cxx:3
 RndSMorphCreator.cxx:4
 RndSMorphCreator.cxx:5
 RndSMorphCreator.cxx:6
 RndSMorphCreator.cxx:7
 RndSMorphCreator.cxx:8
 RndSMorphCreator.cxx:9
 RndSMorphCreator.cxx:10
 RndSMorphCreator.cxx:11
 RndSMorphCreator.cxx:12
 RndSMorphCreator.cxx:13
 RndSMorphCreator.cxx:14
 RndSMorphCreator.cxx:15
 RndSMorphCreator.cxx:16
 RndSMorphCreator.cxx:17
 RndSMorphCreator.cxx:18
 RndSMorphCreator.cxx:19
 RndSMorphCreator.cxx:20
 RndSMorphCreator.cxx:21
 RndSMorphCreator.cxx:22
 RndSMorphCreator.cxx:23
 RndSMorphCreator.cxx:24
 RndSMorphCreator.cxx:25
 RndSMorphCreator.cxx:26
 RndSMorphCreator.cxx:27
 RndSMorphCreator.cxx:28
 RndSMorphCreator.cxx:29
 RndSMorphCreator.cxx:30
 RndSMorphCreator.cxx:31
 RndSMorphCreator.cxx:32
 RndSMorphCreator.cxx:33
 RndSMorphCreator.cxx:34
 RndSMorphCreator.cxx:35
 RndSMorphCreator.cxx:36
 RndSMorphCreator.cxx:37
 RndSMorphCreator.cxx:38
 RndSMorphCreator.cxx:39
 RndSMorphCreator.cxx:40
 RndSMorphCreator.cxx:41
 RndSMorphCreator.cxx:42
 RndSMorphCreator.cxx:43
 RndSMorphCreator.cxx:44
 RndSMorphCreator.cxx:45
 RndSMorphCreator.cxx:46
 RndSMorphCreator.cxx:47
 RndSMorphCreator.cxx:48
 RndSMorphCreator.cxx:49
 RndSMorphCreator.cxx:50
 RndSMorphCreator.cxx:51
 RndSMorphCreator.cxx:52
 RndSMorphCreator.cxx:53
 RndSMorphCreator.cxx:54
 RndSMorphCreator.cxx:55
 RndSMorphCreator.cxx:56
 RndSMorphCreator.cxx:57
 RndSMorphCreator.cxx:58
 RndSMorphCreator.cxx:59
 RndSMorphCreator.cxx:60
 RndSMorphCreator.cxx:61
 RndSMorphCreator.cxx:62
 RndSMorphCreator.cxx:63
 RndSMorphCreator.cxx:64
 RndSMorphCreator.cxx:65
 RndSMorphCreator.cxx:66
 RndSMorphCreator.cxx:67
 RndSMorphCreator.cxx:68
 RndSMorphCreator.cxx:69
 RndSMorphCreator.cxx:70
 RndSMorphCreator.cxx:71
 RndSMorphCreator.cxx:72
 RndSMorphCreator.cxx:73
 RndSMorphCreator.cxx:74
 RndSMorphCreator.cxx:75
 RndSMorphCreator.cxx:76
 RndSMorphCreator.cxx:77
 RndSMorphCreator.cxx:78