// @(#)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 "TEveShapeEditor.h"
#include "TEveShape.h"

#include "TColor.h"

// Cleanup these includes:
#include "TGLabel.h"
#include "TGButton.h"
#include "TGNumberEntry.h"
#include "TGColorSelect.h"
#include "TGColorDialog.h"


//______________________________________________________________________________
// GUI editor for TEveShape.
//

ClassImp(TEveShapeEditor);

//______________________________________________________________________________
TEveShapeEditor::TEveShapeEditor(const TGWindow *p, Int_t width, Int_t height,
             UInt_t options, Pixel_t back) :
   TGedFrame(p, width, height, options | kVerticalFrame, back),
   fM(0),
   fLineWidth(0),
   fLineColor(0),
   fDrawFrame(0),
   fHighlightFrame(0)
{
   // Constructor.

   MakeTitle("TEveShape");

   {
      TGCompositeFrame *f = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);

      TGLabel *l = new TGLabel(f, "LineColor:");
      f->AddFrame(l, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 0));
      fLineColor = new TGColorSelect(f, 0, -1);
      fLineColor->Connect("ColorSelected(Pixel_t)", "TEveShapeEditor", this, "DoLineColor(Pixel_t)");
      f->AddFrame(fLineColor, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));

      fLineWidth = new TGNumberEntry(f, 0., 4, -1,
                                     TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAPositive,
                                     TGNumberFormat::kNELLimitMinMax, 0.1, 20.0);
      fLineWidth->GetNumberEntry()->SetToolTipText("Line width of outline.");
      fLineWidth->Connect("ValueSet(Long_t)", "TEveShapeEditor", this, "DoLineWidth()");
      f->AddFrame(fLineWidth, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));

      AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
   }
   {
      TGHorizontalFrame* f = new TGHorizontalFrame(this);

      fDrawFrame  = new TGCheckButton(f, "Draw Frame");
      f->AddFrame(fDrawFrame, new TGLayoutHints(kLHintsLeft, 1,2,0,0));
      fDrawFrame->Connect("Toggled(Bool_t)", "TEveShapeEditor", this, "DoDrawFrame()");

      fHighlightFrame = new TGCheckButton(f, "Highlight Frame");
      f->AddFrame(fHighlightFrame, new TGLayoutHints(kLHintsLeft, 2,1,0,0));
      fHighlightFrame->Connect("Toggled(Bool_t)"," TEveShapeEditor", this, "DoHighlightFrame()");

      AddFrame(f, new TGLayoutHints(kLHintsTop, 0,0,2,1));
   }
}

//==============================================================================

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

   fM = dynamic_cast<TEveShape*>(obj);

   fLineWidth->SetNumber(fM->fLineWidth);
   fLineColor->SetColor(TColor::Number2Pixel(fM->fLineColor), kFALSE);
   fDrawFrame     ->SetState(fM->fDrawFrame      ? kButtonDown : kButtonUp);
   fHighlightFrame->SetState(fM->fHighlightFrame ? kButtonDown : kButtonUp);
}

//==============================================================================

//______________________________________________________________________________
void TEveShapeEditor::DoLineWidth()
{
   // Slot for setting line with of polygon outline.

   fM->SetLineWidth(fLineWidth->GetNumber());
   Update();
}

//______________________________________________________________________________
void TEveShapeEditor::DoLineColor(Pixel_t pixel)
{
   // Slot for setting line color of polygon outline.

   fM->SetLineColor(TColor::GetColor(pixel));
   Update();
}

//______________________________________________________________________________
void TEveShapeEditor::DoDrawFrame()
{
   // Slot for DrawFrame.

   fM->SetDrawFrame(fDrawFrame->IsOn());
   Update();
}

//______________________________________________________________________________
void TEveShapeEditor::DoHighlightFrame()
{
   // Slot for HighlightFrame.

   fM->SetHighlightFrame(fHighlightFrame->IsOn());
   Update();
}
 TEveShapeEditor.cxx:1
 TEveShapeEditor.cxx:2
 TEveShapeEditor.cxx:3
 TEveShapeEditor.cxx:4
 TEveShapeEditor.cxx:5
 TEveShapeEditor.cxx:6
 TEveShapeEditor.cxx:7
 TEveShapeEditor.cxx:8
 TEveShapeEditor.cxx:9
 TEveShapeEditor.cxx:10
 TEveShapeEditor.cxx:11
 TEveShapeEditor.cxx:12
 TEveShapeEditor.cxx:13
 TEveShapeEditor.cxx:14
 TEveShapeEditor.cxx:15
 TEveShapeEditor.cxx:16
 TEveShapeEditor.cxx:17
 TEveShapeEditor.cxx:18
 TEveShapeEditor.cxx:19
 TEveShapeEditor.cxx:20
 TEveShapeEditor.cxx:21
 TEveShapeEditor.cxx:22
 TEveShapeEditor.cxx:23
 TEveShapeEditor.cxx:24
 TEveShapeEditor.cxx:25
 TEveShapeEditor.cxx:26
 TEveShapeEditor.cxx:27
 TEveShapeEditor.cxx:28
 TEveShapeEditor.cxx:29
 TEveShapeEditor.cxx:30
 TEveShapeEditor.cxx:31
 TEveShapeEditor.cxx:32
 TEveShapeEditor.cxx:33
 TEveShapeEditor.cxx:34
 TEveShapeEditor.cxx:35
 TEveShapeEditor.cxx:36
 TEveShapeEditor.cxx:37
 TEveShapeEditor.cxx:38
 TEveShapeEditor.cxx:39
 TEveShapeEditor.cxx:40
 TEveShapeEditor.cxx:41
 TEveShapeEditor.cxx:42
 TEveShapeEditor.cxx:43
 TEveShapeEditor.cxx:44
 TEveShapeEditor.cxx:45
 TEveShapeEditor.cxx:46
 TEveShapeEditor.cxx:47
 TEveShapeEditor.cxx:48
 TEveShapeEditor.cxx:49
 TEveShapeEditor.cxx:50
 TEveShapeEditor.cxx:51
 TEveShapeEditor.cxx:52
 TEveShapeEditor.cxx:53
 TEveShapeEditor.cxx:54
 TEveShapeEditor.cxx:55
 TEveShapeEditor.cxx:56
 TEveShapeEditor.cxx:57
 TEveShapeEditor.cxx:58
 TEveShapeEditor.cxx:59
 TEveShapeEditor.cxx:60
 TEveShapeEditor.cxx:61
 TEveShapeEditor.cxx:62
 TEveShapeEditor.cxx:63
 TEveShapeEditor.cxx:64
 TEveShapeEditor.cxx:65
 TEveShapeEditor.cxx:66
 TEveShapeEditor.cxx:67
 TEveShapeEditor.cxx:68
 TEveShapeEditor.cxx:69
 TEveShapeEditor.cxx:70
 TEveShapeEditor.cxx:71
 TEveShapeEditor.cxx:72
 TEveShapeEditor.cxx:73
 TEveShapeEditor.cxx:74
 TEveShapeEditor.cxx:75
 TEveShapeEditor.cxx:76
 TEveShapeEditor.cxx:77
 TEveShapeEditor.cxx:78
 TEveShapeEditor.cxx:79
 TEveShapeEditor.cxx:80
 TEveShapeEditor.cxx:81
 TEveShapeEditor.cxx:82
 TEveShapeEditor.cxx:83
 TEveShapeEditor.cxx:84
 TEveShapeEditor.cxx:85
 TEveShapeEditor.cxx:86
 TEveShapeEditor.cxx:87
 TEveShapeEditor.cxx:88
 TEveShapeEditor.cxx:89
 TEveShapeEditor.cxx:90
 TEveShapeEditor.cxx:91
 TEveShapeEditor.cxx:92
 TEveShapeEditor.cxx:93
 TEveShapeEditor.cxx:94
 TEveShapeEditor.cxx:95
 TEveShapeEditor.cxx:96
 TEveShapeEditor.cxx:97
 TEveShapeEditor.cxx:98
 TEveShapeEditor.cxx:99
 TEveShapeEditor.cxx:100
 TEveShapeEditor.cxx:101
 TEveShapeEditor.cxx:102
 TEveShapeEditor.cxx:103
 TEveShapeEditor.cxx:104
 TEveShapeEditor.cxx:105
 TEveShapeEditor.cxx:106
 TEveShapeEditor.cxx:107
 TEveShapeEditor.cxx:108
 TEveShapeEditor.cxx:109
 TEveShapeEditor.cxx:110
 TEveShapeEditor.cxx:111
 TEveShapeEditor.cxx:112
 TEveShapeEditor.cxx:113
 TEveShapeEditor.cxx:114
 TEveShapeEditor.cxx:115
 TEveShapeEditor.cxx:116
 TEveShapeEditor.cxx:117
 TEveShapeEditor.cxx:118
 TEveShapeEditor.cxx:119
 TEveShapeEditor.cxx:120
 TEveShapeEditor.cxx:121
 TEveShapeEditor.cxx:122
 TEveShapeEditor.cxx:123
 TEveShapeEditor.cxx:124
 TEveShapeEditor.cxx:125
 TEveShapeEditor.cxx:126
 TEveShapeEditor.cxx:127
 TEveShapeEditor.cxx:128
 TEveShapeEditor.cxx:129