ROOT logo
// @(#)root/ged:$Id: TAttMarkerEditor.cxx 20882 2007-11-19 11:31:26Z rdm $
// Author: Ilka Antcheva   11/05/04

/*************************************************************************
 * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
//  TAttMarkerEditor                                                    //
//                                                                      //
//  Implements GUI for editing marker attributes.                       //
//            color, style and size                                     //
//                                                                      //
//////////////////////////////////////////////////////////////////////////
//Begin_Html
/*
<img src="gif/TAttMarkerEditor.gif">
*/
//End_Html


#include "TAttMarkerEditor.h"
#include "TGedMarkerSelect.h"
#include "TGColorSelect.h"
#include "TGNumberEntry.h"
#include "TColor.h"
#include "snprintf.h"

ClassImp(TAttMarkerEditor)

enum EMarkerWid {
   kCOLOR,
   kMARKER,
   kMARKER_SIZE
};

//______________________________________________________________________________
TAttMarkerEditor::TAttMarkerEditor(const TGWindow *p, Int_t width,
                                   Int_t height,UInt_t options, Pixel_t back)
   : TGedFrame(p, width, height, options | kVerticalFrame, back)
{
   // Constructor of marker attributes GUI.

   fAttMarker = 0;
   fSizeForText = kFALSE;
   
   MakeTitle("Marker");

   TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
   fColorSelect = new TGColorSelect(f2, 0, kCOLOR);
   f2->AddFrame(fColorSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
   fColorSelect->Associate(this);

   fMarkerType = new TGedMarkerSelect(f2, 1, kMARKER);
   f2->AddFrame(fMarkerType, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
   fMarkerType->Associate(this);

   fMarkerSize = new TGNumberEntry(f2, 0., 4, kMARKER_SIZE, 
                                   TGNumberFormat::kNESRealOne,
                                   TGNumberFormat::kNEANonNegative, 
                                   TGNumberFormat::kNELLimitMinMax, 0.2, 5.0);
   fMarkerSize->GetNumberEntry()->SetToolTipText("Set marker size");
   f2->AddFrame(fMarkerSize, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
   fMarkerSize->Associate(this);
   AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
}

//______________________________________________________________________________
TAttMarkerEditor::~TAttMarkerEditor()
{
   // Destructor of marker editor.
}

//______________________________________________________________________________
void TAttMarkerEditor::ConnectSignals2Slots()
{
   // Connect signals to slots.

   fColorSelect->Connect("ColorSelected(Pixel_t)", "TAttMarkerEditor", this, "DoMarkerColor(Pixel_t)");
   fMarkerType->Connect("MarkerSelected(Style_t)", "TAttMarkerEditor", this, "DoMarkerStyle(Style_t)");
   fMarkerSize->Connect("ValueSet(Long_t)", "TAttMarkerEditor", this, "DoMarkerSize()");
   (fMarkerSize->GetNumberEntry())->Connect("ReturnPressed()", "TAttMarkerEditor", this, "DoMarkerSize()");
   fInit = kFALSE;
}

//______________________________________________________________________________
void TAttMarkerEditor::SetModel(TObject* obj)
{
   // Pick up the values of used marker attributes.
   fAvoidSignal = kTRUE;

   fAttMarker = dynamic_cast<TAttMarker *>(obj);

   TString str = GetDrawOption();
   str.ToUpper();
   if (obj->InheritsFrom("TH2") && str.Contains("TEXT")) {
      fSizeForText = kTRUE;
   } else {
      fSizeForText = kFALSE;
   }   
   Style_t marker = fAttMarker->GetMarkerStyle();
   if ((marker==1 || marker==6 || marker==7) && !fSizeForText) {
      fMarkerSize->SetNumber(1.);
      fMarkerSize->SetState(kFALSE);
   } else {
      Float_t s = fAttMarker->GetMarkerSize();
      fMarkerSize->SetState(kTRUE);
      fMarkerSize->SetNumber(s);
   }
   fMarkerType->SetMarkerStyle(marker);

   Color_t c = fAttMarker->GetMarkerColor();
   Pixel_t p = TColor::Number2Pixel(c);
   fColorSelect->SetColor(p);

   if (fInit) ConnectSignals2Slots();
   fAvoidSignal = kFALSE;
}


//______________________________________________________________________________
void TAttMarkerEditor::DoMarkerColor(Pixel_t color)
{
   // Slot connected to the marker color.

   if (fAvoidSignal) return;
   fAttMarker->SetMarkerColor(TColor::GetColor(color));
   Update();
}

//______________________________________________________________________________
void TAttMarkerEditor::DoMarkerStyle(Style_t marker)
{
   // Slot connected to the marker type.

   if (fAvoidSignal) return;
   if ((marker==1 || marker==6 || marker==7) && !fSizeForText) {
      fMarkerSize->SetNumber(1.);
      fMarkerSize->SetState(kFALSE);
   } else
      fMarkerSize->SetState(kTRUE);

   fAttMarker->SetMarkerStyle(marker);
   Update();
}

//______________________________________________________________________________
void TAttMarkerEditor::DoMarkerSize()
{
   // Slot connected to the marker size.

   if (fAvoidSignal) return;
   Style_t marker = fAttMarker->GetMarkerStyle();
   if ((marker==1 || marker==6 || marker==7) && !fSizeForText) {
      fMarkerSize->SetNumber(1.);
      fMarkerSize->SetState(kFALSE);
   } else
      fMarkerSize->SetState(kTRUE);
   Float_t size = fMarkerSize->GetNumber();
   fAttMarker->SetMarkerSize(size);
   Update();
}
 TAttMarkerEditor.cxx:1
 TAttMarkerEditor.cxx:2
 TAttMarkerEditor.cxx:3
 TAttMarkerEditor.cxx:4
 TAttMarkerEditor.cxx:5
 TAttMarkerEditor.cxx:6
 TAttMarkerEditor.cxx:7
 TAttMarkerEditor.cxx:8
 TAttMarkerEditor.cxx:9
 TAttMarkerEditor.cxx:10
 TAttMarkerEditor.cxx:11
 TAttMarkerEditor.cxx:12
 TAttMarkerEditor.cxx:13
 TAttMarkerEditor.cxx:14
 TAttMarkerEditor.cxx:15
 TAttMarkerEditor.cxx:16
 TAttMarkerEditor.cxx:17
 TAttMarkerEditor.cxx:18
 TAttMarkerEditor.cxx:19
 TAttMarkerEditor.cxx:20
 TAttMarkerEditor.cxx:21
 TAttMarkerEditor.cxx:22
 TAttMarkerEditor.cxx:23
 TAttMarkerEditor.cxx:24
 TAttMarkerEditor.cxx:25
 TAttMarkerEditor.cxx:26
 TAttMarkerEditor.cxx:27
 TAttMarkerEditor.cxx:28
 TAttMarkerEditor.cxx:29
 TAttMarkerEditor.cxx:30
 TAttMarkerEditor.cxx:31
 TAttMarkerEditor.cxx:32
 TAttMarkerEditor.cxx:33
 TAttMarkerEditor.cxx:34
 TAttMarkerEditor.cxx:35
 TAttMarkerEditor.cxx:36
 TAttMarkerEditor.cxx:37
 TAttMarkerEditor.cxx:38
 TAttMarkerEditor.cxx:39
 TAttMarkerEditor.cxx:40
 TAttMarkerEditor.cxx:41
 TAttMarkerEditor.cxx:42
 TAttMarkerEditor.cxx:43
 TAttMarkerEditor.cxx:44
 TAttMarkerEditor.cxx:45
 TAttMarkerEditor.cxx:46
 TAttMarkerEditor.cxx:47
 TAttMarkerEditor.cxx:48
 TAttMarkerEditor.cxx:49
 TAttMarkerEditor.cxx:50
 TAttMarkerEditor.cxx:51
 TAttMarkerEditor.cxx:52
 TAttMarkerEditor.cxx:53
 TAttMarkerEditor.cxx:54
 TAttMarkerEditor.cxx:55
 TAttMarkerEditor.cxx:56
 TAttMarkerEditor.cxx:57
 TAttMarkerEditor.cxx:58
 TAttMarkerEditor.cxx:59
 TAttMarkerEditor.cxx:60
 TAttMarkerEditor.cxx:61
 TAttMarkerEditor.cxx:62
 TAttMarkerEditor.cxx:63
 TAttMarkerEditor.cxx:64
 TAttMarkerEditor.cxx:65
 TAttMarkerEditor.cxx:66
 TAttMarkerEditor.cxx:67
 TAttMarkerEditor.cxx:68
 TAttMarkerEditor.cxx:69
 TAttMarkerEditor.cxx:70
 TAttMarkerEditor.cxx:71
 TAttMarkerEditor.cxx:72
 TAttMarkerEditor.cxx:73
 TAttMarkerEditor.cxx:74
 TAttMarkerEditor.cxx:75
 TAttMarkerEditor.cxx:76
 TAttMarkerEditor.cxx:77
 TAttMarkerEditor.cxx:78
 TAttMarkerEditor.cxx:79
 TAttMarkerEditor.cxx:80
 TAttMarkerEditor.cxx:81
 TAttMarkerEditor.cxx:82
 TAttMarkerEditor.cxx:83
 TAttMarkerEditor.cxx:84
 TAttMarkerEditor.cxx:85
 TAttMarkerEditor.cxx:86
 TAttMarkerEditor.cxx:87
 TAttMarkerEditor.cxx:88
 TAttMarkerEditor.cxx:89
 TAttMarkerEditor.cxx:90
 TAttMarkerEditor.cxx:91
 TAttMarkerEditor.cxx:92
 TAttMarkerEditor.cxx:93
 TAttMarkerEditor.cxx:94
 TAttMarkerEditor.cxx:95
 TAttMarkerEditor.cxx:96
 TAttMarkerEditor.cxx:97
 TAttMarkerEditor.cxx:98
 TAttMarkerEditor.cxx:99
 TAttMarkerEditor.cxx:100
 TAttMarkerEditor.cxx:101
 TAttMarkerEditor.cxx:102
 TAttMarkerEditor.cxx:103
 TAttMarkerEditor.cxx:104
 TAttMarkerEditor.cxx:105
 TAttMarkerEditor.cxx:106
 TAttMarkerEditor.cxx:107
 TAttMarkerEditor.cxx:108
 TAttMarkerEditor.cxx:109
 TAttMarkerEditor.cxx:110
 TAttMarkerEditor.cxx:111
 TAttMarkerEditor.cxx:112
 TAttMarkerEditor.cxx:113
 TAttMarkerEditor.cxx:114
 TAttMarkerEditor.cxx:115
 TAttMarkerEditor.cxx:116
 TAttMarkerEditor.cxx:117
 TAttMarkerEditor.cxx:118
 TAttMarkerEditor.cxx:119
 TAttMarkerEditor.cxx:120
 TAttMarkerEditor.cxx:121
 TAttMarkerEditor.cxx:122
 TAttMarkerEditor.cxx:123
 TAttMarkerEditor.cxx:124
 TAttMarkerEditor.cxx:125
 TAttMarkerEditor.cxx:126
 TAttMarkerEditor.cxx:127
 TAttMarkerEditor.cxx:128
 TAttMarkerEditor.cxx:129
 TAttMarkerEditor.cxx:130
 TAttMarkerEditor.cxx:131
 TAttMarkerEditor.cxx:132
 TAttMarkerEditor.cxx:133
 TAttMarkerEditor.cxx:134
 TAttMarkerEditor.cxx:135
 TAttMarkerEditor.cxx:136
 TAttMarkerEditor.cxx:137
 TAttMarkerEditor.cxx:138
 TAttMarkerEditor.cxx:139
 TAttMarkerEditor.cxx:140
 TAttMarkerEditor.cxx:141
 TAttMarkerEditor.cxx:142
 TAttMarkerEditor.cxx:143
 TAttMarkerEditor.cxx:144
 TAttMarkerEditor.cxx:145
 TAttMarkerEditor.cxx:146
 TAttMarkerEditor.cxx:147
 TAttMarkerEditor.cxx:148
 TAttMarkerEditor.cxx:149
 TAttMarkerEditor.cxx:150
 TAttMarkerEditor.cxx:151
 TAttMarkerEditor.cxx:152
 TAttMarkerEditor.cxx:153
 TAttMarkerEditor.cxx:154
 TAttMarkerEditor.cxx:155
 TAttMarkerEditor.cxx:156
 TAttMarkerEditor.cxx:157
 TAttMarkerEditor.cxx:158
 TAttMarkerEditor.cxx:159
 TAttMarkerEditor.cxx:160
 TAttMarkerEditor.cxx:161
 TAttMarkerEditor.cxx:162
 TAttMarkerEditor.cxx:163
 TAttMarkerEditor.cxx:164
 TAttMarkerEditor.cxx:165
 TAttMarkerEditor.cxx:166
 TAttMarkerEditor.cxx:167