TAttFill.cxx

Go to the documentation of this file.
00001 // @(#)root/base:$Id: TAttFill.cxx 34859 2010-08-19 10:56:34Z brun $
00002 // Author: Rene Brun   12/12/94
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "Riostream.h"
00013 #include "TAttFill.h"
00014 #include "TVirtualPad.h"
00015 #include "TStyle.h"
00016 #include "TVirtualX.h"
00017 #include "TVirtualPadEditor.h"
00018 #include "TColor.h"
00019 
00020 ClassImp(TAttFill)
00021 
00022 
00023 //______________________________________________________________________________
00024 /* Begin_Html
00025 <center><h2>Fill Area Attributes class</h2></center>
00026 
00027 This class is used (in general by secondary inheritance)
00028 by many other classes (graphics, histograms). It holds all the fill area
00029 attributes.
00030 
00031 <h3>Fill Area attributes</h3>
00032 Fill Area attributes are:
00033 <ul>
00034 <li><a href="#F1">Fill Area color.</a></li>
00035 <li><a href="#F2">Fill Area style.</a></li>
00036 </ul>
00037 
00038 <a name="F1"></a><h3>Fill Area color</h3>
00039 The fill area color is a color index (integer) pointing in the ROOT
00040 color table.
00041 The fill area color of any class inheriting from <tt>TAttFill</tt> can
00042 be changed using the method <tt>SetFillColor</tt> and retrieved using the
00043 method <tt>GetFillColor</tt>.
00044 The following table shows the first 50 default colors.
00045 End_Html
00046 Begin_Macro(source)
00047 {
00048    TCanvas *c = new TCanvas("c","Fill Area colors",0,0,500,200);
00049    c.DrawColorTable();
00050    return c;
00051 }
00052 End_Macro
00053 
00054 Begin_Html
00055 <h4>The ROOT Color Wheel.</h4>
00056 The wheel contains the recommended 216 colors to be used in web applications.
00057 The colors in the Color Wheel are created by TColor::CreateColorWheel.
00058 <p>Using this color set for your text, background or graphics will give your
00059 application a consistent appearance across different platforms and browsers.
00060 <p>Colors are grouped by hue, the aspect most important in human perception 
00061 Touching color chips have the same hue, but with different brightness and vividness.
00062 <p>Colors of slightly different hues <b>clash</b>. If you intend to display
00063 colors of the same hue together, you should pick them from the same group.
00064 <p>Each color chip is identified by a mnemonic (eg kYellow) and a number.
00065 The keywords, kRed, kBlue, kYellow, kPink, etc are defined in the header file <b>Rtypes.h</b>
00066 that is included in all ROOT other header files. We strongly recommend to use these keywords
00067 in your code instead of hardcoded color numbers, eg:
00068 <pre>
00069    myObject.SetFillColor(kRed);
00070    myObject.SetFillColor(kYellow-10);
00071    myLine.SetLineColor(kMagenta+2);
00072 </pre>
00073 
00074 End_Html
00075 Begin_Macro(source)
00076 {
00077    TColorWheel *w = new TColorWheel();
00078    w->Draw();
00079    return w->GetCanvas();
00080 }
00081 End_Macro
00082       
00083 Begin_Html
00084 <h4>Special case forcing black&white output.</h4>
00085 If the current style fill area color is set to 0, then ROOT will force
00086 a black&white output for all objects with a fill area defined and independently
00087 of the object fill style.
00088    
00089 <a name="F2"></a><h3>Fill Area style</h3>
00090 The fill area style defines the pattern used to fill a polygon.
00091 The fill area style of any class inheriting from <tt>TAttFill</tt> can
00092 be changed using the method <tt>SetFillStyle</tt> and retrieved using the
00093 method <tt>GetFillStyle</tt>.
00094 <h4>Conventions for fill styles:</h4>
00095 <ul>
00096 <li>  0    : hollow                   </li>
00097 <li>  1001 : Solid                    </li>
00098 <li>  2001 : hatch style              </li>
00099 <li>  3000+pattern_number (see below) </li>
00100 <li>  For TPad only:                  </li>
00101 <ul>
00102    <li>  4000 :the window is transparent.                            </li>
00103    <li>  4000 to 4100 the window is 100% transparent to 100% opaque. </li>
00104 </ul>
00105       The pad transparency is visible in binary outputs files like gif, jpg, png etc ..
00106       but not in vector graphics output files like PS, PDF and SVG.
00107 </ul>
00108 
00109 pattern_number can have any value from 1 to 25 (see table), or any
00110 value from 100 to 999. For the latest the numbering convention is the following:
00111 <pre>
00112       pattern_number = ijk      (FillStyle = 3ijk)
00113  
00114       i (1-9) : specify the space between each hatch
00115                 1 = 1/2mm  9 = 6mm
00116  
00117       j (0-9) : specify angle between 0 and 90 degrees
00118                 0 = 0
00119                 1 = 10
00120                 2 = 20
00121                 3 = 30
00122                 4 = 45
00123                 5 = Not drawn
00124                 6 = 60
00125                 7 = 70
00126                 8 = 80
00127                 9 = 90
00128   
00129       k (0-9) : specify angle between 90 and 180 degrees
00130                 0 = 180
00131                 1 = 170
00132                 2 = 160
00133                 3 = 150
00134                 4 = 135
00135                 5 = Not drawn
00136                 6 = 120
00137                 7 = 110
00138                 8 = 100
00139                 9 = 90
00140 </pre>
00141 The following table shows the list of pattern styles.
00142 The first table displays the 25 fixed patterns. They cannot be
00143 customized unlike the hatches displayed in the second table which be
00144 customized using:
00145 <ul>
00146 <li> <tt>gStyle->SetHatchesSpacing()</tt> to define the spacing between hatches.
00147 <li> <tt>gStyle->SetHatchesLineWidth()</tt> to define the hatches line width.
00148 </ul>
00149 End_Html
00150 Begin_Macro(source)
00151 fillpatterns.C
00152 End_Macro */
00153 
00154 
00155 //______________________________________________________________________________
00156 TAttFill::TAttFill()
00157 {
00158    // AttFill default constructor.
00159    // Default fill attributes are taking from the current style
00160 
00161    if (!gStyle) {fFillColor=1; fFillStyle=0; return;}
00162    fFillColor = gStyle->GetFillColor();
00163    fFillStyle = gStyle->GetFillStyle();
00164 }
00165 
00166 
00167 //______________________________________________________________________________
00168 TAttFill::TAttFill(Color_t color, Style_t style)
00169 {
00170    // AttFill normal constructor.
00171    // color Fill Color
00172    // style Fill Style
00173 
00174    fFillColor = color;
00175    fFillStyle = style;
00176 }
00177 
00178 
00179 //______________________________________________________________________________
00180 TAttFill::~TAttFill()
00181 {
00182    // AttFill destructor.
00183 }
00184 
00185 
00186 //______________________________________________________________________________
00187 void TAttFill::Copy(TAttFill &attfill) const
00188 {
00189    // Copy this fill attributes to a new TAttFill.
00190 
00191    attfill.fFillColor  = fFillColor;
00192    attfill.fFillStyle  = fFillStyle;
00193 }
00194 
00195 
00196 //______________________________________________________________________________
00197 void TAttFill::Modify()
00198 {
00199    // Change current fill area attributes if necessary.
00200 
00201    if (!gPad) return;
00202    if (!gPad->IsBatch()) {
00203       gVirtualX->SetFillColor(fFillColor);
00204       gVirtualX->SetFillStyle(fFillStyle);
00205    }
00206 
00207    gPad->SetAttFillPS(fFillColor,fFillStyle);
00208 }
00209 
00210 
00211 //______________________________________________________________________________
00212 void TAttFill::ResetAttFill(Option_t *)
00213 {
00214    // Reset this fill attributes to default values.
00215 
00216    fFillColor = 1;
00217    fFillStyle = 0;
00218 }
00219 
00220 
00221 //______________________________________________________________________________
00222 void TAttFill::SaveFillAttributes(ostream &out, const char *name, Int_t coldef, Int_t stydef)
00223 {
00224     // Save fill attributes as C++ statement(s) on output stream out
00225 
00226    if (fFillColor != coldef) {
00227       if (fFillColor > 228) {
00228          TColor::SaveColor(out, fFillColor);
00229          out<<"   "<<name<<"->SetFillColor(ci);" << endl;
00230       } else
00231          out<<"   "<<name<<"->SetFillColor("<<fFillColor<<");"<<endl;
00232    }
00233    if (fFillStyle != stydef) {
00234       out<<"   "<<name<<"->SetFillStyle("<<fFillStyle<<");"<<endl;
00235    }
00236 }
00237 
00238 
00239 //______________________________________________________________________________
00240 void TAttFill::SetFillAttributes()
00241 {
00242    // Invoke the DialogCanvas Fill attributes.
00243 
00244    TVirtualPadEditor::UpdateFillAttributes(fFillColor,fFillStyle);
00245 }

Generated on Tue Jul 5 14:11:18 2011 for ROOT_528-00b_version by  doxygen 1.5.1