ROOT logo
// @(#)root/base:$Id: TAttMarker.cxx 37733 2011-01-07 09:41:53Z couet $
// Author: Rene Brun   12/05/95

/*************************************************************************
 * Copyright (C) 1995-2000, 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 "Riostream.h"
#include "Strlen.h"
#include "TAttMarker.h"
#include "TVirtualPad.h"
#include "TStyle.h"
#include "TVirtualX.h"
#include "TVirtualPadEditor.h"
#include "TColor.h"

ClassImp(TAttMarker)


//______________________________________________________________________________
/* Begin_Html
<center><h2>Marker Attributes class</h2></center>

This class is used (in general by secondary inheritance)
by many other classes (graphics, histograms). It holds all the markers
attributes.

<h3>Marker attributes</h3>
The marker attributes are:
<ul>
<li><a href="#M1">Marker color.</a></li>
<li><a href="#M2">Marker style.</a></li>
<li><a href="#M3">Marker size.</a></li>
</ul>

<a name="M1"></a><h3>Marker color</h3>
The marker color is a color index (integer) pointing in the ROOT color
table.
The marker color of any class inheriting from <tt>TAttMarker</tt> can
be changed using the method <tt>SetMarkerColor</tt> and retrieved using the
method <tt>GetMarkerColor</tt>.
The following table shows the first 50 default colors.
End_Html
Begin_Macro(source)
{
   TCanvas *c = new TCanvas("c","Marker colors",0,0,500,200);
   c.DrawColorTable();
   return c;
}
End_Macro

Begin_Html
<a name="M2"></a><h3>Marker style</h3>
The Marker style defines the markers' shape.
The marker style of any class inheriting from <tt>TAttMarker</tt> can
be changed using the method <tt>SetMarkerStyle</tt> and retrieved using the
method <tt>GetMarkerStyle</tt>.
The following list gives the currently supported markers (screen
and PostScript) style. Each marker style is identified by an integer number
(first column) corresponding to a marker shape (second column) and can be also
accessed via a global name (third column).
<p>
<pre>
   Marker number         Marker shape          Marker name
        1                    dot                  kDot
        2                    +                    kPlus
        3                    *                    kStar
        4                    o                    kCircle
        5                    x                    kMultiply
        6                    small dot            kFullDotSmall
        7                    medium dot           kFullDotMedium
        8                    large scalable dot   kFullDotLarge
        9 -->19              large scalable dot
       20                    full circle          kFullCircle
       21                    full square          kFullSquare
       22                    full triangle up     kFullTriangleUp
       23                    full triangle down   kFullTriangleDown
       24                    open circle          kOpenCircle
       25                    open square          kOpenSquare
       26                    open triangle up     kOpenTriangleUp
       27                    open diamond         kOpenDiamond
       28                    open cross           kOpenCross
       29                    full star            kOpenStar
       30                    open star            kFullStar
       31                    *
       32                    open triangle down
       33                    full diamond
       34                    full cross
</pre>
End_Html
Begin_Macro(source)
{
   TCanvas *c = new TCanvas("c","Marker types",0,0,500,200);
   TMarker marker;
   marker.DisplayMarkerTypes();
   return c;
}
End_Macro

Begin_Html
<a name="M3"></a><h3>Marker size</h3>
Various marker sizes are shown in the figure below. The default marker size=1
is shown in the top left corner. Marker sizes smaller than 1 can be
specified. The marker size does not refer to any coordinate systems, it is an
absolute value. Therefore the marker size is not affected by any change
in TPad's scale. A marker size equl to 1 correspond to 8 pixels.
That is, a square marker with size 1 will be drawn with a side equal to 8
pixels on the screen.
The marker size of any class inheriting from <tt>TAttMarker</tt> can
be changed using the method <tt>SetMarkerSize</tt> and retrieved using the
method <tt>GetMarkerSize</tt>.
End_Html
Begin_Macro(source)
{
   c = new TCanvas("c","Marker sizes",0,0,500,200);
   TMarker marker;
   marker.SetMarkerStyle(3);
   Double_t x = 0;
   Double_t dx = 1/6.0;
   for (Int_t i=1; i<6; i++) {
      x += dx;
      marker.SetMarkerSize(i*0.2); marker.DrawMarker(x,.165);
      marker.SetMarkerSize(i*0.8); marker.DrawMarker(x,.495);
      marker.SetMarkerSize(i*1.0); marker.DrawMarker(x,.835);
   }
   return c;
}
End_Macro

Begin_Html
Note that the marker styles number 1 6 and 7 (the dots), cannot be scaled. They
are meant to be very fast to draw and are always drawn with the same number of
pixels; therefore <tt>SetMarkerSize</tt> does not apply on them. To have a
"scalable dot" a filled circle should be used instead, i.e. the marker style
number 20. By default (if <tt>SetMarkerStyle</tt> is not specified), the marker
style used is 1. That's the most common one to draw scatter plots.
End_Html */


//______________________________________________________________________________
TAttMarker::TAttMarker()
{
   // TAttMarker default constructor.
   //
   // Default text attributes are taking from the current style.

   if (!gStyle) {fMarkerColor=1; fMarkerStyle=1; fMarkerSize=1; return;}
   fMarkerColor = gStyle->GetMarkerColor();
   fMarkerStyle = gStyle->GetMarkerStyle();
   fMarkerSize  = gStyle->GetMarkerSize();
}


//______________________________________________________________________________
TAttMarker::TAttMarker(Color_t color, Style_t style, Size_t msize)
{
   // TAttMarker normal constructor.
   //
   // Text attributes are taking from the argument list
   //    color : Marker Color Index
   //    style : Marker style (from 1 to 30)
   //    size  : marker size (float)

   fMarkerColor = color;
   fMarkerSize  = msize;
   fMarkerStyle = style;
}


//______________________________________________________________________________
TAttMarker::~TAttMarker()
{
   // TAttMarker destructor.
}


//______________________________________________________________________________
void TAttMarker::Copy(TAttMarker &attmarker) const
{
   // Copy this marker attributes to a new TAttMarker.

   attmarker.fMarkerColor  = fMarkerColor;
   attmarker.fMarkerStyle  = fMarkerStyle;
   attmarker.fMarkerSize   = fMarkerSize;
}


//______________________________________________________________________________
void TAttMarker::Modify()
{
   // Change current marker attributes if necessary.

   if (!gPad) return;
   if (!gPad->IsBatch()) {
      gVirtualX->SetMarkerColor(fMarkerColor);
      gVirtualX->SetMarkerSize (fMarkerSize);
      gVirtualX->SetMarkerStyle(fMarkerStyle);
   }

   gPad->SetAttMarkerPS(fMarkerColor,fMarkerStyle,fMarkerSize);
}


//______________________________________________________________________________
void TAttMarker::ResetAttMarker(Option_t *)
{
   // Reset this marker attributes to the default values.

   fMarkerColor  = 1;
   fMarkerStyle  = 1;
   fMarkerSize   = 1;
}


//______________________________________________________________________________
void TAttMarker::SaveMarkerAttributes(ostream &out, const char *name, Int_t coldef, Int_t stydef, Int_t sizdef)
{
   // Save line attributes as C++ statement(s) on output stream out.

   if (fMarkerColor != coldef) {
      if (fMarkerColor > 228) {
         TColor::SaveColor(out, fMarkerColor);
         out<<"   "<<name<<"->SetMarkerColor(ci);" << endl;
      } else
         out<<"   "<<name<<"->SetMarkerColor("<<fMarkerColor<<");"<<endl;
   }
   if (fMarkerStyle != stydef) {
      out<<"   "<<name<<"->SetMarkerStyle("<<fMarkerStyle<<");"<<endl;
   }
   if (fMarkerSize != sizdef) {
      out<<"   "<<name<<"->SetMarkerSize("<<fMarkerSize<<");"<<endl;
   }
}


//______________________________________________________________________________
void TAttMarker::SetMarkerAttributes()
{
   // Invoke the DialogCanvas Marker attributes.

   TVirtualPadEditor::UpdateMarkerAttributes(fMarkerColor,fMarkerStyle,fMarkerSize);
}
 TAttMarker.cxx:1
 TAttMarker.cxx:2
 TAttMarker.cxx:3
 TAttMarker.cxx:4
 TAttMarker.cxx:5
 TAttMarker.cxx:6
 TAttMarker.cxx:7
 TAttMarker.cxx:8
 TAttMarker.cxx:9
 TAttMarker.cxx:10
 TAttMarker.cxx:11
 TAttMarker.cxx:12
 TAttMarker.cxx:13
 TAttMarker.cxx:14
 TAttMarker.cxx:15
 TAttMarker.cxx:16
 TAttMarker.cxx:17
 TAttMarker.cxx:18
 TAttMarker.cxx:19
 TAttMarker.cxx:20
 TAttMarker.cxx:21
 TAttMarker.cxx:22
 TAttMarker.cxx:23
 TAttMarker.cxx:24
 TAttMarker.cxx:25
 TAttMarker.cxx:26
 TAttMarker.cxx:27
 TAttMarker.cxx:28
 TAttMarker.cxx:29
 TAttMarker.cxx:30
 TAttMarker.cxx:31
 TAttMarker.cxx:32
 TAttMarker.cxx:33
 TAttMarker.cxx:34
 TAttMarker.cxx:35
 TAttMarker.cxx:36
 TAttMarker.cxx:37
 TAttMarker.cxx:38
 TAttMarker.cxx:39
 TAttMarker.cxx:40
 TAttMarker.cxx:41
 TAttMarker.cxx:42
 TAttMarker.cxx:43
 TAttMarker.cxx:44
 TAttMarker.cxx:45
 TAttMarker.cxx:46
 TAttMarker.cxx:47
 TAttMarker.cxx:48
 TAttMarker.cxx:49
 TAttMarker.cxx:50
 TAttMarker.cxx:51
 TAttMarker.cxx:52
 TAttMarker.cxx:53
 TAttMarker.cxx:54
 TAttMarker.cxx:55
 TAttMarker.cxx:56
 TAttMarker.cxx:57
 TAttMarker.cxx:58
 TAttMarker.cxx:59
 TAttMarker.cxx:60
 TAttMarker.cxx:61
 TAttMarker.cxx:62
 TAttMarker.cxx:63
 TAttMarker.cxx:64
 TAttMarker.cxx:65
 TAttMarker.cxx:66
 TAttMarker.cxx:67
 TAttMarker.cxx:68
 TAttMarker.cxx:69
 TAttMarker.cxx:70
 TAttMarker.cxx:71
 TAttMarker.cxx:72
 TAttMarker.cxx:73
 TAttMarker.cxx:74
 TAttMarker.cxx:75
 TAttMarker.cxx:76
 TAttMarker.cxx:77
 TAttMarker.cxx:78
 TAttMarker.cxx:79
 TAttMarker.cxx:80
 TAttMarker.cxx:81
 TAttMarker.cxx:82
 TAttMarker.cxx:83
 TAttMarker.cxx:84
 TAttMarker.cxx:85
 TAttMarker.cxx:86
 TAttMarker.cxx:87
 TAttMarker.cxx:88
 TAttMarker.cxx:89
 TAttMarker.cxx:90
 TAttMarker.cxx:91
 TAttMarker.cxx:92
 TAttMarker.cxx:93
 TAttMarker.cxx:94
 TAttMarker.cxx:95
 TAttMarker.cxx:96
 TAttMarker.cxx:97
 TAttMarker.cxx:98
 TAttMarker.cxx:99
 TAttMarker.cxx:100
 TAttMarker.cxx:101
 TAttMarker.cxx:102
 TAttMarker.cxx:103
 TAttMarker.cxx:104
 TAttMarker.cxx:105
 TAttMarker.cxx:106
 TAttMarker.cxx:107
 TAttMarker.cxx:108
 TAttMarker.cxx:109
 TAttMarker.cxx:110
 TAttMarker.cxx:111
 TAttMarker.cxx:112
 TAttMarker.cxx:113
 TAttMarker.cxx:114
 TAttMarker.cxx:115
 TAttMarker.cxx:116
 TAttMarker.cxx:117
 TAttMarker.cxx:118
 TAttMarker.cxx:119
 TAttMarker.cxx:120
 TAttMarker.cxx:121
 TAttMarker.cxx:122
 TAttMarker.cxx:123
 TAttMarker.cxx:124
 TAttMarker.cxx:125
 TAttMarker.cxx:126
 TAttMarker.cxx:127
 TAttMarker.cxx:128
 TAttMarker.cxx:129
 TAttMarker.cxx:130
 TAttMarker.cxx:131
 TAttMarker.cxx:132
 TAttMarker.cxx:133
 TAttMarker.cxx:134
 TAttMarker.cxx:135
 TAttMarker.cxx:136
 TAttMarker.cxx:137
 TAttMarker.cxx:138
 TAttMarker.cxx:139
 TAttMarker.cxx:140
 TAttMarker.cxx:141
 TAttMarker.cxx:142
 TAttMarker.cxx:143
 TAttMarker.cxx:144
 TAttMarker.cxx:145
 TAttMarker.cxx:146
 TAttMarker.cxx:147
 TAttMarker.cxx:148
 TAttMarker.cxx:149
 TAttMarker.cxx:150
 TAttMarker.cxx:151
 TAttMarker.cxx:152
 TAttMarker.cxx:153
 TAttMarker.cxx:154
 TAttMarker.cxx:155
 TAttMarker.cxx:156
 TAttMarker.cxx:157
 TAttMarker.cxx:158
 TAttMarker.cxx:159
 TAttMarker.cxx:160
 TAttMarker.cxx:161
 TAttMarker.cxx:162
 TAttMarker.cxx:163
 TAttMarker.cxx:164
 TAttMarker.cxx:165
 TAttMarker.cxx:166
 TAttMarker.cxx:167
 TAttMarker.cxx:168
 TAttMarker.cxx:169
 TAttMarker.cxx:170
 TAttMarker.cxx:171
 TAttMarker.cxx:172
 TAttMarker.cxx:173
 TAttMarker.cxx:174
 TAttMarker.cxx:175
 TAttMarker.cxx:176
 TAttMarker.cxx:177
 TAttMarker.cxx:178
 TAttMarker.cxx:179
 TAttMarker.cxx:180
 TAttMarker.cxx:181
 TAttMarker.cxx:182
 TAttMarker.cxx:183
 TAttMarker.cxx:184
 TAttMarker.cxx:185
 TAttMarker.cxx:186
 TAttMarker.cxx:187
 TAttMarker.cxx:188
 TAttMarker.cxx:189
 TAttMarker.cxx:190
 TAttMarker.cxx:191
 TAttMarker.cxx:192
 TAttMarker.cxx:193
 TAttMarker.cxx:194
 TAttMarker.cxx:195
 TAttMarker.cxx:196
 TAttMarker.cxx:197
 TAttMarker.cxx:198
 TAttMarker.cxx:199
 TAttMarker.cxx:200
 TAttMarker.cxx:201
 TAttMarker.cxx:202
 TAttMarker.cxx:203
 TAttMarker.cxx:204
 TAttMarker.cxx:205
 TAttMarker.cxx:206
 TAttMarker.cxx:207
 TAttMarker.cxx:208
 TAttMarker.cxx:209
 TAttMarker.cxx:210
 TAttMarker.cxx:211
 TAttMarker.cxx:212
 TAttMarker.cxx:213
 TAttMarker.cxx:214
 TAttMarker.cxx:215
 TAttMarker.cxx:216
 TAttMarker.cxx:217
 TAttMarker.cxx:218
 TAttMarker.cxx:219
 TAttMarker.cxx:220
 TAttMarker.cxx:221
 TAttMarker.cxx:222
 TAttMarker.cxx:223
 TAttMarker.cxx:224
 TAttMarker.cxx:225
 TAttMarker.cxx:226
 TAttMarker.cxx:227
 TAttMarker.cxx:228
 TAttMarker.cxx:229
 TAttMarker.cxx:230
 TAttMarker.cxx:231
 TAttMarker.cxx:232
 TAttMarker.cxx:233
 TAttMarker.cxx:234
 TAttMarker.cxx:235
 TAttMarker.cxx:236
 TAttMarker.cxx:237
 TAttMarker.cxx:238
 TAttMarker.cxx:239
 TAttMarker.cxx:240
 TAttMarker.cxx:241
 TAttMarker.cxx:242
 TAttMarker.cxx:243
 TAttMarker.cxx:244
 TAttMarker.cxx:245
 TAttMarker.cxx:246