ROOT logo
// @(#)root/eve:$Id$
// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 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 "TEveElementEditor.h"
#include "TEveElement.h"
#include "TEveTransEditor.h"

#include "TVirtualPad.h"
#include "TColor.h"

#include "TGLabel.h"
#include "TGButton.h"
#include "TGNumberEntry.h"
#include "TGColorSelect.h"
#include "TGDoubleSlider.h"

//==============================================================================
//==============================================================================
// TEveElementEditor
//==============================================================================

//______________________________________________________________________________
//
// Editor for TEveElement class.

ClassImp(TEveElementEditor);

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

   fRE           (0),
   fHFrame       (0),
   fPreLabel     (0),
   fRnrSelf      (0),
   fRnrChildren  (0),
   fRnrState     (0),
   fMainColor    (0),
   fTransparency (0),
   fTrans        (0)
{
   // Constructor.

   MakeTitle("TEveElement");
   fPriority = 0;

   fHFrame = new TGHorizontalFrame(this);

   fPreLabel = new TGLabel(fHFrame, "Show:");
   fHFrame->AddFrame(fPreLabel, new TGLayoutHints(kLHintsLeft, 1, 6, 2, 0));
   fRnrSelf = new TGCheckButton(fHFrame, "Self");
   fHFrame->AddFrame(fRnrSelf, new TGLayoutHints(kLHintsLeft, 0, 2, 1, 1));
   fRnrSelf->Connect
      ("Toggled(Bool_t)",
       "TEveElementEditor", this, "DoRnrSelf()");

   fRnrChildren = new TGCheckButton(fHFrame, "Children");
   fHFrame->AddFrame(fRnrChildren, new TGLayoutHints(kLHintsLeft, 0, 1, 1, 1));
   fRnrChildren->Connect
      ("Toggled(Bool_t)",
       "TEveElementEditor", this, "DoRnrChildren()");

   fRnrState = new TGCheckButton(fHFrame, "");
   fHFrame->AddFrame(fRnrState, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
   fRnrState->Connect
      ("Toggled(Bool_t)",
       "TEveElementEditor", this, "DoRnrState()");

   fMainColor = new TGColorSelect(fHFrame, 0, -1);
   fHFrame->AddFrame(fMainColor, new TGLayoutHints(kLHintsLeft, 2, 0, -2, 0));
   fMainColor->Connect
      ("ColorSelected(Pixel_t)",
       "TEveElementEditor", this, "DoMainColor(Pixel_t)");

   fTransparency = new TGNumberEntry(fHFrame, 0., 2, -1,
                                     TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
                                     TGNumberFormat::kNELLimitMinMax, 0, 100);
   fTransparency->SetHeight(18);
   fTransparency->GetNumberEntry()->SetToolTipText("Transparency: 0 is opaque, 100 fully transparent.");
   fHFrame->AddFrame(fTransparency, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
   fTransparency->Connect
      ("ValueSet(Long_t)",
       "TEveElementEditor", this, "DoTransparency()");

   AddFrame(fHFrame, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));

   fTrans = new TEveTransSubEditor(this);
   fTrans->Connect("UseTrans()",     "TEveElementEditor", this, "Update()");
   fTrans->Connect("TransChanged()", "TEveElementEditor", this, "Update()");
   AddFrame(fTrans, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 0, 0));
}

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

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

   fRE = dynamic_cast<TEveElement*>(obj);

   fPreLabel   ->UnmapWindow();
   fRnrSelf    ->UnmapWindow();
   fRnrChildren->UnmapWindow();
   fRnrState   ->UnmapWindow();
   if (fRE->CanEditElement()) {
      fPreLabel->MapWindow();
      if (fRE->SingleRnrState()) {
         fRnrState->SetState(fRE->GetRnrState() ? kButtonDown : kButtonUp);
         fRnrState->MapWindow();
      } else {
         fRnrSelf->SetState(fRE->GetRnrSelf() ? kButtonDown : kButtonUp);
         fRnrChildren->SetState(fRE->GetRnrChildren() ? kButtonDown : kButtonUp);
         fRnrSelf->MapWindow();
         fRnrChildren->MapWindow();
      }
   }

   if (fRE->CanEditMainColor()) {
      fMainColor->SetColor(TColor::Number2Pixel(fRE->GetMainColor()), kFALSE);
      fMainColor->MapWindow();
   } else {
      fMainColor->UnmapWindow();
   }
   if (fRE->CanEditMainTransparency()) {
      fTransparency->SetNumber(fRE->GetMainTransparency());
      fTransparency->MapWindow();
   } else {
      fTransparency->UnmapWindow();
   }
   if (fRE->CanEditMainTrans()) {
      fTrans->SetModel(fRE->PtrMainTrans());
      fTrans->MapWindow();
   } else {
      fTrans->UnmapWindow();
   }

   fHFrame->Layout();
}

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

//______________________________________________________________________________
void TEveElementEditor::DoRnrSelf()
{
   // Slot for RnrSelf.

   fRE->SetRnrSelf(fRnrSelf->IsOn());
   Update();
}

//______________________________________________________________________________
void TEveElementEditor::DoRnrChildren()
{
   // Slot for RnrChildren.

   fRE->SetRnrChildren(fRnrChildren->IsOn());
   Update();
}

//______________________________________________________________________________
void TEveElementEditor::DoRnrState()
{
   // Slot for RnrState.

   fRE->SetRnrState(fRnrState->IsOn());
   Update();
}

//______________________________________________________________________________
void TEveElementEditor::DoMainColor(Pixel_t color)
{
   // Slot for MainColor.

   fRE->SetMainColorPixel(color);
   Update();
}

//______________________________________________________________________________
void TEveElementEditor::DoTransparency()
{
   // Slot for Transparency.

   fRE->SetMainTransparency((Char_t)(fTransparency->GetNumber()));
   Update();
}
 TEveElementEditor.cxx:1
 TEveElementEditor.cxx:2
 TEveElementEditor.cxx:3
 TEveElementEditor.cxx:4
 TEveElementEditor.cxx:5
 TEveElementEditor.cxx:6
 TEveElementEditor.cxx:7
 TEveElementEditor.cxx:8
 TEveElementEditor.cxx:9
 TEveElementEditor.cxx:10
 TEveElementEditor.cxx:11
 TEveElementEditor.cxx:12
 TEveElementEditor.cxx:13
 TEveElementEditor.cxx:14
 TEveElementEditor.cxx:15
 TEveElementEditor.cxx:16
 TEveElementEditor.cxx:17
 TEveElementEditor.cxx:18
 TEveElementEditor.cxx:19
 TEveElementEditor.cxx:20
 TEveElementEditor.cxx:21
 TEveElementEditor.cxx:22
 TEveElementEditor.cxx:23
 TEveElementEditor.cxx:24
 TEveElementEditor.cxx:25
 TEveElementEditor.cxx:26
 TEveElementEditor.cxx:27
 TEveElementEditor.cxx:28
 TEveElementEditor.cxx:29
 TEveElementEditor.cxx:30
 TEveElementEditor.cxx:31
 TEveElementEditor.cxx:32
 TEveElementEditor.cxx:33
 TEveElementEditor.cxx:34
 TEveElementEditor.cxx:35
 TEveElementEditor.cxx:36
 TEveElementEditor.cxx:37
 TEveElementEditor.cxx:38
 TEveElementEditor.cxx:39
 TEveElementEditor.cxx:40
 TEveElementEditor.cxx:41
 TEveElementEditor.cxx:42
 TEveElementEditor.cxx:43
 TEveElementEditor.cxx:44
 TEveElementEditor.cxx:45
 TEveElementEditor.cxx:46
 TEveElementEditor.cxx:47
 TEveElementEditor.cxx:48
 TEveElementEditor.cxx:49
 TEveElementEditor.cxx:50
 TEveElementEditor.cxx:51
 TEveElementEditor.cxx:52
 TEveElementEditor.cxx:53
 TEveElementEditor.cxx:54
 TEveElementEditor.cxx:55
 TEveElementEditor.cxx:56
 TEveElementEditor.cxx:57
 TEveElementEditor.cxx:58
 TEveElementEditor.cxx:59
 TEveElementEditor.cxx:60
 TEveElementEditor.cxx:61
 TEveElementEditor.cxx:62
 TEveElementEditor.cxx:63
 TEveElementEditor.cxx:64
 TEveElementEditor.cxx:65
 TEveElementEditor.cxx:66
 TEveElementEditor.cxx:67
 TEveElementEditor.cxx:68
 TEveElementEditor.cxx:69
 TEveElementEditor.cxx:70
 TEveElementEditor.cxx:71
 TEveElementEditor.cxx:72
 TEveElementEditor.cxx:73
 TEveElementEditor.cxx:74
 TEveElementEditor.cxx:75
 TEveElementEditor.cxx:76
 TEveElementEditor.cxx:77
 TEveElementEditor.cxx:78
 TEveElementEditor.cxx:79
 TEveElementEditor.cxx:80
 TEveElementEditor.cxx:81
 TEveElementEditor.cxx:82
 TEveElementEditor.cxx:83
 TEveElementEditor.cxx:84
 TEveElementEditor.cxx:85
 TEveElementEditor.cxx:86
 TEveElementEditor.cxx:87
 TEveElementEditor.cxx:88
 TEveElementEditor.cxx:89
 TEveElementEditor.cxx:90
 TEveElementEditor.cxx:91
 TEveElementEditor.cxx:92
 TEveElementEditor.cxx:93
 TEveElementEditor.cxx:94
 TEveElementEditor.cxx:95
 TEveElementEditor.cxx:96
 TEveElementEditor.cxx:97
 TEveElementEditor.cxx:98
 TEveElementEditor.cxx:99
 TEveElementEditor.cxx:100
 TEveElementEditor.cxx:101
 TEveElementEditor.cxx:102
 TEveElementEditor.cxx:103
 TEveElementEditor.cxx:104
 TEveElementEditor.cxx:105
 TEveElementEditor.cxx:106
 TEveElementEditor.cxx:107
 TEveElementEditor.cxx:108
 TEveElementEditor.cxx:109
 TEveElementEditor.cxx:110
 TEveElementEditor.cxx:111
 TEveElementEditor.cxx:112
 TEveElementEditor.cxx:113
 TEveElementEditor.cxx:114
 TEveElementEditor.cxx:115
 TEveElementEditor.cxx:116
 TEveElementEditor.cxx:117
 TEveElementEditor.cxx:118
 TEveElementEditor.cxx:119
 TEveElementEditor.cxx:120
 TEveElementEditor.cxx:121
 TEveElementEditor.cxx:122
 TEveElementEditor.cxx:123
 TEveElementEditor.cxx:124
 TEveElementEditor.cxx:125
 TEveElementEditor.cxx:126
 TEveElementEditor.cxx:127
 TEveElementEditor.cxx:128
 TEveElementEditor.cxx:129
 TEveElementEditor.cxx:130
 TEveElementEditor.cxx:131
 TEveElementEditor.cxx:132
 TEveElementEditor.cxx:133
 TEveElementEditor.cxx:134
 TEveElementEditor.cxx:135
 TEveElementEditor.cxx:136
 TEveElementEditor.cxx:137
 TEveElementEditor.cxx:138
 TEveElementEditor.cxx:139
 TEveElementEditor.cxx:140
 TEveElementEditor.cxx:141
 TEveElementEditor.cxx:142
 TEveElementEditor.cxx:143
 TEveElementEditor.cxx:144
 TEveElementEditor.cxx:145
 TEveElementEditor.cxx:146
 TEveElementEditor.cxx:147
 TEveElementEditor.cxx:148
 TEveElementEditor.cxx:149
 TEveElementEditor.cxx:150
 TEveElementEditor.cxx:151
 TEveElementEditor.cxx:152
 TEveElementEditor.cxx:153
 TEveElementEditor.cxx:154
 TEveElementEditor.cxx:155
 TEveElementEditor.cxx:156
 TEveElementEditor.cxx:157
 TEveElementEditor.cxx:158
 TEveElementEditor.cxx:159
 TEveElementEditor.cxx:160
 TEveElementEditor.cxx:161
 TEveElementEditor.cxx:162
 TEveElementEditor.cxx:163
 TEveElementEditor.cxx:164
 TEveElementEditor.cxx:165
 TEveElementEditor.cxx:166
 TEveElementEditor.cxx:167
 TEveElementEditor.cxx:168
 TEveElementEditor.cxx:169
 TEveElementEditor.cxx:170
 TEveElementEditor.cxx:171
 TEveElementEditor.cxx:172
 TEveElementEditor.cxx:173
 TEveElementEditor.cxx:174
 TEveElementEditor.cxx:175
 TEveElementEditor.cxx:176
 TEveElementEditor.cxx:177
 TEveElementEditor.cxx:178
 TEveElementEditor.cxx:179
 TEveElementEditor.cxx:180
 TEveElementEditor.cxx:181
 TEveElementEditor.cxx:182
 TEveElementEditor.cxx:183
 TEveElementEditor.cxx:184
 TEveElementEditor.cxx:185
 TEveElementEditor.cxx:186
 TEveElementEditor.cxx:187
 TEveElementEditor.cxx:188
 TEveElementEditor.cxx:189
 TEveElementEditor.cxx:190
 TEveElementEditor.cxx:191
 TEveElementEditor.cxx:192
 TEveElementEditor.cxx:193
 TEveElementEditor.cxx:194
 TEveElementEditor.cxx:195
 TEveElementEditor.cxx:196