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

/*************************************************************************
 * Copyright (C) 1995-2007, 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 "TEveArrowEditor.h"
#include "TEveArrow.h"
#include "TVirtualPad.h"
#include "TGLabel.h"
#include "TEveGValuators.h"

//______________________________________________________________________________
// GUI editor for TEveArrow.
//

ClassImp(TEveArrowEditor);

//______________________________________________________________________________
TEveArrowEditor::TEveArrowEditor(const TGWindow *p, Int_t width, Int_t height,
                                 UInt_t options, Pixel_t back) :
   TGedFrame(p, width, height, options | kVerticalFrame, back),
   fM(0),

   fTubeR(0),
   fConeR(0),
   fConeL(0),

   fOrigin(0),
   fVector(0)
{
   // Constructor.

   MakeTitle("TEveArrow");
   Int_t labelW = 51;

   fTubeR = new TEveGValuator(this, "TubeR:", 90, 0);
   fTubeR->SetLabelWidth(labelW);
   fTubeR->SetNELength(6);
   fTubeR->Build();
   fTubeR->SetLimits(0.001, 1, 101, TGNumberFormat::kNESRealThree);
   fTubeR->Connect("ValueSet(Double_t)", "TEveArrowEditor", this, "DoTubeR()");
   AddFrame(fTubeR, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));

   fConeR = new TEveGValuator(this, "ConeR:", 90, 0);
   fConeR->SetLabelWidth(labelW);
   fConeR->SetNELength(6);
   fConeR->Build();
   fConeR->SetLimits(0.001, 1, 101, TGNumberFormat::kNESRealThree);
   fConeR->Connect("ValueSet(Double_t)", "TEveArrowEditor", this, "DoConeR()");
   AddFrame(fConeR, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));

   fConeL = new TEveGValuator(this, "ConeL:", 90, 0);
   fConeL->SetLabelWidth(labelW);
   fConeL->SetNELength(6);
   fConeL->Build();
   fConeL->SetLimits(0.001, 1, 101, TGNumberFormat::kNESRealThree);
   fConeL->Connect("ValueSet(Double_t)", "TEveArrowEditor", this, "DoConeL()");
   AddFrame(fConeL, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));

   TGFont *font = gClient->GetFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
   {
      TGHorizontalFrame* hfp = new TGHorizontalFrame(this);
      TGLabel* labp = new TGLabel(hfp, "Origin");
      labp->SetTextFont(font);
      hfp->AddFrame(labp);
      AddFrame(hfp,  new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,2,0));
      fOrigin = new TEveGTriVecValuator(this, "Origin", 160, 20);
      fOrigin->SetNELength(6);
      fOrigin->Build(kFALSE, "", "", "");
      fOrigin->SetLimits(-1e5, 1e5, TGNumberFormat::kNESRealThree);
      AddFrame(fOrigin, new TGLayoutHints(kLHintsTop , 0,0,0,0));
   }

   {
      TGHorizontalFrame* hfp = new TGHorizontalFrame(this);
      TGLabel* labp = new TGLabel(hfp, "Vector");
      labp->SetTextFont(font);
      hfp->AddFrame(labp);
      AddFrame(hfp,  new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,2,0));
      fVector = new TEveGTriVecValuator(this, "Vector", 160, 20);
      fVector->SetNELength(6);
      fVector->Build(kFALSE, "", "", "");
      fVector->SetLimits(-1e5, 1e5, TGNumberFormat::kNESRealThree);
      AddFrame(fVector, new TGLayoutHints(kLHintsTop , 0,0,0,0));
   }

   fVector->Connect("ValueSet()", "TEveArrowEditor", this, "DoVertex()");
   fOrigin->Connect("ValueSet()", "TEveArrowEditor", this, "DoVertex()");
}

//______________________________________________________________________________
void TEveArrowEditor::SetModel(TObject* obj)
{
   // Set model object.

   fM = dynamic_cast<TEveArrow*>(obj);

   fTubeR->SetValue(fM->fTubeR);
   fTubeR->SetValue(fM->fTubeR);
   fConeL->SetValue(fM->fConeL);

   fOrigin->SetValues(&fM->fOrigin[0]);
   fVector->SetValues(&fM->fVector[0]);
}

//______________________________________________________________________________
void TEveArrowEditor::DoTubeR()
{
   // Slot for TubeR.

   fM->SetTubeR(fTubeR->GetValue());
   Update();
}

//______________________________________________________________________________
void TEveArrowEditor::DoConeR()
{
   // Slot for ConeR.

   fM->SetConeR(fConeR->GetValue());
   Update();
}

//______________________________________________________________________________
void TEveArrowEditor::DoConeL()
{
   // Slot for ConeL.

   fM->SetConeL(fConeL->GetValue());
   Update();
}

//______________________________________________________________________________
void TEveArrowEditor::DoVertex()
{
   // Slot for origin and vector.

   Double_t v[3];
   fOrigin->GetValues(v);
   fM->fOrigin.Set(v);
   fVector->GetValues(v);
   fM->fVector.Set(v);
   Update();
}


 TEveArrowEditor.cxx:1
 TEveArrowEditor.cxx:2
 TEveArrowEditor.cxx:3
 TEveArrowEditor.cxx:4
 TEveArrowEditor.cxx:5
 TEveArrowEditor.cxx:6
 TEveArrowEditor.cxx:7
 TEveArrowEditor.cxx:8
 TEveArrowEditor.cxx:9
 TEveArrowEditor.cxx:10
 TEveArrowEditor.cxx:11
 TEveArrowEditor.cxx:12
 TEveArrowEditor.cxx:13
 TEveArrowEditor.cxx:14
 TEveArrowEditor.cxx:15
 TEveArrowEditor.cxx:16
 TEveArrowEditor.cxx:17
 TEveArrowEditor.cxx:18
 TEveArrowEditor.cxx:19
 TEveArrowEditor.cxx:20
 TEveArrowEditor.cxx:21
 TEveArrowEditor.cxx:22
 TEveArrowEditor.cxx:23
 TEveArrowEditor.cxx:24
 TEveArrowEditor.cxx:25
 TEveArrowEditor.cxx:26
 TEveArrowEditor.cxx:27
 TEveArrowEditor.cxx:28
 TEveArrowEditor.cxx:29
 TEveArrowEditor.cxx:30
 TEveArrowEditor.cxx:31
 TEveArrowEditor.cxx:32
 TEveArrowEditor.cxx:33
 TEveArrowEditor.cxx:34
 TEveArrowEditor.cxx:35
 TEveArrowEditor.cxx:36
 TEveArrowEditor.cxx:37
 TEveArrowEditor.cxx:38
 TEveArrowEditor.cxx:39
 TEveArrowEditor.cxx:40
 TEveArrowEditor.cxx:41
 TEveArrowEditor.cxx:42
 TEveArrowEditor.cxx:43
 TEveArrowEditor.cxx:44
 TEveArrowEditor.cxx:45
 TEveArrowEditor.cxx:46
 TEveArrowEditor.cxx:47
 TEveArrowEditor.cxx:48
 TEveArrowEditor.cxx:49
 TEveArrowEditor.cxx:50
 TEveArrowEditor.cxx:51
 TEveArrowEditor.cxx:52
 TEveArrowEditor.cxx:53
 TEveArrowEditor.cxx:54
 TEveArrowEditor.cxx:55
 TEveArrowEditor.cxx:56
 TEveArrowEditor.cxx:57
 TEveArrowEditor.cxx:58
 TEveArrowEditor.cxx:59
 TEveArrowEditor.cxx:60
 TEveArrowEditor.cxx:61
 TEveArrowEditor.cxx:62
 TEveArrowEditor.cxx:63
 TEveArrowEditor.cxx:64
 TEveArrowEditor.cxx:65
 TEveArrowEditor.cxx:66
 TEveArrowEditor.cxx:67
 TEveArrowEditor.cxx:68
 TEveArrowEditor.cxx:69
 TEveArrowEditor.cxx:70
 TEveArrowEditor.cxx:71
 TEveArrowEditor.cxx:72
 TEveArrowEditor.cxx:73
 TEveArrowEditor.cxx:74
 TEveArrowEditor.cxx:75
 TEveArrowEditor.cxx:76
 TEveArrowEditor.cxx:77
 TEveArrowEditor.cxx:78
 TEveArrowEditor.cxx:79
 TEveArrowEditor.cxx:80
 TEveArrowEditor.cxx:81
 TEveArrowEditor.cxx:82
 TEveArrowEditor.cxx:83
 TEveArrowEditor.cxx:84
 TEveArrowEditor.cxx:85
 TEveArrowEditor.cxx:86
 TEveArrowEditor.cxx:87
 TEveArrowEditor.cxx:88
 TEveArrowEditor.cxx:89
 TEveArrowEditor.cxx:90
 TEveArrowEditor.cxx:91
 TEveArrowEditor.cxx:92
 TEveArrowEditor.cxx:93
 TEveArrowEditor.cxx:94
 TEveArrowEditor.cxx:95
 TEveArrowEditor.cxx:96
 TEveArrowEditor.cxx:97
 TEveArrowEditor.cxx:98
 TEveArrowEditor.cxx:99
 TEveArrowEditor.cxx:100
 TEveArrowEditor.cxx:101
 TEveArrowEditor.cxx:102
 TEveArrowEditor.cxx:103
 TEveArrowEditor.cxx:104
 TEveArrowEditor.cxx:105
 TEveArrowEditor.cxx:106
 TEveArrowEditor.cxx:107
 TEveArrowEditor.cxx:108
 TEveArrowEditor.cxx:109
 TEveArrowEditor.cxx:110
 TEveArrowEditor.cxx:111
 TEveArrowEditor.cxx:112
 TEveArrowEditor.cxx:113
 TEveArrowEditor.cxx:114
 TEveArrowEditor.cxx:115
 TEveArrowEditor.cxx:116
 TEveArrowEditor.cxx:117
 TEveArrowEditor.cxx:118
 TEveArrowEditor.cxx:119
 TEveArrowEditor.cxx:120
 TEveArrowEditor.cxx:121
 TEveArrowEditor.cxx:122
 TEveArrowEditor.cxx:123
 TEveArrowEditor.cxx:124
 TEveArrowEditor.cxx:125
 TEveArrowEditor.cxx:126
 TEveArrowEditor.cxx:127
 TEveArrowEditor.cxx:128
 TEveArrowEditor.cxx:129
 TEveArrowEditor.cxx:130
 TEveArrowEditor.cxx:131
 TEveArrowEditor.cxx:132
 TEveArrowEditor.cxx:133
 TEveArrowEditor.cxx:134
 TEveArrowEditor.cxx:135
 TEveArrowEditor.cxx:136
 TEveArrowEditor.cxx:137
 TEveArrowEditor.cxx:138
 TEveArrowEditor.cxx:139
 TEveArrowEditor.cxx:140
 TEveArrowEditor.cxx:141
 TEveArrowEditor.cxx:142
 TEveArrowEditor.cxx:143
 TEveArrowEditor.cxx:144
 TEveArrowEditor.cxx:145
 TEveArrowEditor.cxx:146
 TEveArrowEditor.cxx:147
 TEveArrowEditor.cxx:148
 TEveArrowEditor.cxx:149
 TEveArrowEditor.cxx:150
 TEveArrowEditor.cxx:151
 TEveArrowEditor.cxx:152