<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>HippoDraw Class Library</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> <link rel="shortcut icon" href="hippoApp.ico"> </head><body> <!-- Generated by Doxygen 1.6.2 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_6dcc65b7c74f97460af44109581e51d3.html">reps</a> </div> </div> <div class="contents"> <h1>AxisRepColor.cxx</h1><a href="AxisRepColor_8cxx.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00012"></a>00012 <span class="preprocessor">#ifdef _MSC_VER</span> <a name="l00013"></a>00013 <span class="preprocessor"></span><span class="comment">// for min()</span> <a name="l00014"></a>00014 <span class="preprocessor">#include "msdevstudio/MSconfig.h"</span> <a name="l00015"></a>00015 <span class="preprocessor">#endif</span> <a name="l00016"></a>00016 <span class="preprocessor"></span> <a name="l00017"></a>00017 <span class="preprocessor">#include "<a class="code" href="AxisRepColor_8h.html" title="hippodraw::AxisRepColor class interface">AxisRepColor.h</a>"</span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="preprocessor">#include "<a class="code" href="AxisModelBase_8h.html" title="hippodraw::AxisModelBase class interface">axes/AxisModelBase.h</a>"</span> <a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="AxisTick_8h.html" title="AxisTick class interface.">axes/AxisTick.h</a>"</span> <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="BinToColor_8h.html" title="hippodraw::BinToColor class interface">colorreps/BinToColor.h</a>"</span> <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="DataView_8h.html" title="hippodraw::DataView class interface">graphics/DataView.h</a>"</span> <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="string__convert_8h.html" title="The namespace for conversion to string.">pattern/string_convert.h</a>"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="BinaryTransform_8h.html" title="hippodraw::BinaryTransform class interface">transforms/BinaryTransform.h</a>"</span> <a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="PlotterBase_8h.html" title="hippodraw::PlotterBase class interface.">plotters/PlotterBase.h</a>"</span> <a name="l00027"></a>00027 <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="preprocessor">#include <algorithm></span> <a name="l00030"></a>00030 <span class="preprocessor">#include <functional></span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="preprocessor">#include <cmath></span> <a name="l00033"></a>00033 <a name="l00034"></a>00034 <span class="preprocessor">#include <cassert></span> <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="preprocessor">#include <iostream></span> <a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="keyword">using</span> std::min; <a name="l00039"></a>00039 <span class="keyword">using</span> std::string; <a name="l00040"></a>00040 <span class="keyword">using</span> std::vector; <a name="l00041"></a>00041 <a name="l00042"></a>00042 <span class="keyword">using namespace </span>hippodraw; <a name="l00043"></a>00043 <a name="l00044"></a><a class="code" href="classhippodraw_1_1AxisRepColor.html#a6488663fc9815b246531bc797d463aa9">00044</a> AxisRepColor::AxisRepColor () <a name="l00045"></a>00045 : <a class="code" href="classhippodraw_1_1AxisRepBase.html" title="The base class for the axis representation hierarchy.">AxisRepBase</a> (), <a name="l00046"></a>00046 m_axis_z_origin( 0.0 ), <a name="l00047"></a>00047 m_axis_depth( 0.0 ) <a name="l00048"></a>00048 { <a name="l00049"></a>00049 } <a name="l00050"></a>00050 <a name="l00051"></a><a class="code" href="classhippodraw_1_1AxisRepColor.html#a964281fb8b994ce5c015d21ec94c4934">00051</a> <a class="code" href="classhippodraw_1_1AxisRepColor.html#a6488663fc9815b246531bc797d463aa9" title="The default constructor.">AxisRepColor::AxisRepColor</a>( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1AxisRepColor.html" title="The class for the 2D axes drawing with color.">AxisRepColor</a> & axis_rep ) <a name="l00052"></a>00052 : <a class="code" href="classhippodraw_1_1AxisRepBase.html" title="The base class for the axis representation hierarchy.">AxisRepBase</a>( axis_rep ), <a name="l00053"></a>00053 m_axis_z_origin( axis_rep.m_axis_z_origin ), <a name="l00054"></a>00054 m_axis_depth( axis_rep.m_axis_depth ) <a name="l00055"></a>00055 { <a name="l00056"></a>00056 } <a name="l00057"></a>00057 <a name="l00058"></a><a class="code" href="classhippodraw_1_1AxisRepColor.html#ac8589a46e51b5d3b54f4c79c02935f58">00058</a> <a class="code" href="classhippodraw_1_1AxisRepBase.html" title="The base class for the axis representation hierarchy.">AxisRepBase</a> * <a class="code" href="classhippodraw_1_1AxisRepColor.html#ac8589a46e51b5d3b54f4c79c02935f58" title="The clone function returns an object of its own kind which is a copy of this object...">AxisRepColor::clone</a>() <a name="l00059"></a>00059 { <a name="l00060"></a>00060 <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1AxisRepColor.html#a6488663fc9815b246531bc797d463aa9" title="The default constructor.">AxisRepColor</a>( *<span class="keyword">this</span> ); <a name="l00061"></a>00061 } <a name="l00062"></a>00062 <a name="l00063"></a>00063 <a name="l00064"></a><a class="code" href="AxisRepColor_8cxx.html#a1c69a51de5c2c56b9ee5c8fa18eacfa1">00064</a> <span class="keyword">inline</span> <span class="keywordtype">float</span> <a class="code" href="AxisRepColor_8cxx.html#a1c69a51de5c2c56b9ee5c8fa18eacfa1">XPADDING</a>( <a class="code" href="classhippodraw_1_1ViewBase.html" title="The abstract base class for views.">ViewBase</a> & view ) <a name="l00065"></a>00065 { <a name="l00066"></a>00066 <span class="keywordflow">return</span> ( view.<a class="code" href="classhippodraw_1_1ViewBase.html#a4a8f555bf8d011b2eb5a2ba4a379bff3" title="Returns the drawing Rectangle in the devices coordinate system.">getDrawRect</a>().<a class="code" href="classhippodraw_1_1Rect.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="A shortcut to get size.width.">getWidth</a>() * 0.01 ); <a name="l00067"></a>00067 } <a name="l00068"></a>00068 <a name="l00069"></a><a class="code" href="AxisRepColor_8cxx.html#a9e5d670f13de58263196fae1b65181f9">00069</a> <span class="keyword">inline</span> <span class="keywordtype">float</span> <a class="code" href="AxisRepColor_8cxx.html#a9e5d670f13de58263196fae1b65181f9">YPADDING</a>( <a class="code" href="classhippodraw_1_1ViewBase.html" title="The abstract base class for views.">ViewBase</a> & view ) <a name="l00070"></a>00070 { <a name="l00071"></a>00071 <span class="keywordflow">return</span> ( view.<a class="code" href="classhippodraw_1_1ViewBase.html#a4a8f555bf8d011b2eb5a2ba4a379bff3" title="Returns the drawing Rectangle in the devices coordinate system.">getDrawRect</a>().<a class="code" href="classhippodraw_1_1Rect.html#ab22b7a83bfd69953e9421f6941bc9304" title="A shortcut to get size.height.">getHeight</a>() * 0.01 ); <a name="l00072"></a>00072 } <a name="l00073"></a>00073 <a name="l00074"></a><a class="code" href="AxisRepColor_8cxx.html#a185e0b9a13066cc6f015e32b6ba4b8cf">00074</a> <span class="keyword">inline</span> <span class="keywordtype">float</span> <a class="code" href="AxisRepColor_8cxx.html#a185e0b9a13066cc6f015e32b6ba4b8cf">ZPADDING</a>( <a class="code" href="classhippodraw_1_1ViewBase.html" title="The abstract base class for views.">ViewBase</a> & view ) <a name="l00075"></a>00075 { <a name="l00076"></a>00076 <span class="keywordflow">return</span> ( view.<a class="code" href="classhippodraw_1_1ViewBase.html#a4a8f555bf8d011b2eb5a2ba4a379bff3" title="Returns the drawing Rectangle in the devices coordinate system.">getDrawRect</a>().<a class="code" href="classhippodraw_1_1Rect.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="A shortcut to get size.width.">getWidth</a>() * 0.01 ); <a name="l00077"></a>00077 } <a name="l00078"></a>00078 <a name="l00081"></a>00081 <span class="keywordtype">void</span> <a name="l00082"></a>00082 <a class="code" href="classhippodraw_1_1AxisRepColor.html#aea5491acec627ea09120491f1ea9045a" title="Draws the labels of the z axis.">AxisRepColor::</a> <a name="l00083"></a><a class="code" href="classhippodraw_1_1AxisRepColor.html#aea5491acec627ea09120491f1ea9045a">00083</a> <a class="code" href="classhippodraw_1_1AxisRepColor.html#aea5491acec627ea09120491f1ea9045a" title="Draws the labels of the z axis.">drawZLabels</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1AxisModelBase.html" title="The AxisModelBase class maintains the Range and scaling of an axis.">AxisModelBase</a> &, <span class="comment">// axisModel,</span> <a name="l00084"></a>00084 <a class="code" href="classhippodraw_1_1ViewBase.html" title="The abstract base class for views.">ViewBase</a> & base, <a name="l00085"></a>00085 <span class="keyword">const</span> std::string & z_label ) <a name="l00086"></a>00086 { <a name="l00087"></a>00087 <a name="l00088"></a>00088 <a class="code" href="classhippodraw_1_1DataView.html" title="The abstract base class for views that have a region for drawing data points with...">DataView</a> & view = dynamic_cast < <a class="code" href="classhippodraw_1_1DataView.html" title="The abstract base class for views that have a region for drawing data points with...">DataView</a> & > ( base ); <a name="l00089"></a>00089 <a name="l00090"></a>00090 <span class="comment">// Draw Latex at the top of the plotter if in Latex format</span> <a name="l00091"></a>00091 <span class="keywordflow">if</span> (<a class="code" href="namespacehippodraw_1_1String.html#a75ef7a56cccf4985ff6924ec6cf8ff33" title="Case insensitive find.">String::ci_find</a>(z_label, <span class="stringliteral">"tex:"</span>)==0) { <a name="l00092"></a>00092 <span class="keywordtype">string</span> tex_snippet = z_label.substr(4); <a name="l00093"></a>00093 view.<a class="code" href="classhippodraw_1_1ViewBase.html#ada5216dc1e1aad275e293f561804c4df" title="Draws a Latex equation.">drawLatex</a> ( tex_snippet, 4 ); <a name="l00094"></a>00094 <span class="keywordflow">return</span>; <a name="l00095"></a>00095 } <a name="l00096"></a>00096 <a name="l00097"></a>00097 <a class="code" href="classhippodraw_1_1Rect.html" title="Class representing a rectangle.">Rect</a> draw_rect = view.<a class="code" href="classhippodraw_1_1ViewBase.html#a4a8f555bf8d011b2eb5a2ba4a379bff3" title="Returns the drawing Rectangle in the devices coordinate system.">getDrawRect</a> (); <a name="l00098"></a>00098 <span class="keywordtype">float</span> dh = draw_rect.<a class="code" href="classhippodraw_1_1Rect.html#ab22b7a83bfd69953e9421f6941bc9304" title="A shortcut to get size.height.">getHeight</a> (); <a name="l00099"></a>00099 <a name="l00100"></a>00100 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Rect.html" title="Class representing a rectangle.">Rect</a> & margin_rect = view.<a class="code" href="classhippodraw_1_1DataView.html#a68d755b4942b64218ef9b9921c412e2c" title="Returns the rectangle area in which data points are drawn.">getMarginRect</a> (); <a name="l00101"></a>00101 <span class="keywordtype">float</span> mx = margin_rect.<a class="code" href="classhippodraw_1_1Rect.html#af71e522ec6aa935c2618819b54f20e02" title="A shortcut to get origin.X.">getX</a> (); <a name="l00102"></a>00102 <span class="keywordtype">float</span> mw = margin_rect.<a class="code" href="classhippodraw_1_1Rect.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="A shortcut to get size.width.">getWidth</a> (); <a name="l00103"></a>00103 <span class="keywordtype">float</span> my = margin_rect.<a class="code" href="classhippodraw_1_1Rect.html#acd84440598b1da2a23c326ce371db4e4" title="A shortcut to get origin.Y.">getY</a> (); <a name="l00104"></a>00104 <span class="keywordtype">float</span> mh = margin_rect.<a class="code" href="classhippodraw_1_1Rect.html#ab22b7a83bfd69953e9421f6941bc9304" title="A shortcut to get size.height.">getHeight</a> (); <a name="l00105"></a>00105 <a name="l00106"></a>00106 <span class="keywordtype">float</span> y_font_size = ( dh - mh ) / 2 * 0.20; <a name="l00107"></a>00107 <span class="keywordtype">float</span> x_font_size = ( mw * 2 ) / z_label.size() * 2 / 3; <a name="l00108"></a>00108 <a name="l00109"></a>00109 <a class="code" href="classhippodraw_1_1AxisRepBase.html#a8d43dad9f4dfcd6cdfa9aff560f943e8" title="Font size for the Z axis label.">m_z_font_size</a> = min ( x_font_size, y_font_size ); <a name="l00110"></a>00110 <a name="l00111"></a>00111 <span class="keywordtype">float</span> x = mx + 0.5 * mw; <a name="l00112"></a>00112 <span class="keywordtype">float</span> y = my - 37; <a name="l00113"></a>00113 <a name="l00114"></a>00114 <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1AxisRepBase.html#acc6442f46c2e7d89b6f19f03f66f553f" title="The font to be used to for the Z label overriding the default font.">m_titleFont</a> != 0) { <a name="l00115"></a>00115 y = y + 1.2 * <a class="code" href="classhippodraw_1_1AxisRepBase.html#acc6442f46c2e7d89b6f19f03f66f553f" title="The font to be used to for the Z label overriding the default font.">m_titleFont</a>-><a class="code" href="classhippodraw_1_1FontBase.html#aad3bfdef486bcb87bc672b48314f019d" title="Get the pointsize of the font.">pointSize</a>() - 11.0; <span class="comment">//experimental</span> <a name="l00116"></a>00116 } <a name="l00117"></a>00117 <a name="l00118"></a>00118 <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1AxisRepBase.html#acba23c66b5bcd9da594f2b1fad62b29f" title="The font to be used to for the Z label overriding the default font.">m_zLabelFont</a> != 0 ) { <a name="l00119"></a>00119 y = y + 1.2 * <a class="code" href="classhippodraw_1_1AxisRepBase.html#acba23c66b5bcd9da594f2b1fad62b29f" title="The font to be used to for the Z label overriding the default font.">m_zLabelFont</a>-><a class="code" href="classhippodraw_1_1FontBase.html#aad3bfdef486bcb87bc672b48314f019d" title="Get the pointsize of the font.">pointSize</a>() - 8.0; <span class="comment">// experimental</span> <a name="l00120"></a>00120 view.<a class="code" href="classhippodraw_1_1ViewBase.html#a22a47195eeee5c3564b9cb9389460ff5" title="Draws a text string at a point in the view&#39;s coordinate system.">drawText</a> ( z_label, x, y, 0.0, 0.0, <span class="charliteral">'c'</span>, <span class="charliteral">'b'</span>, <a name="l00121"></a>00121 <span class="keyword">false</span>, <a class="code" href="classhippodraw_1_1AxisRepBase.html#acba23c66b5bcd9da594f2b1fad62b29f" title="The font to be used to for the Z label overriding the default font.">m_zLabelFont</a> ); <a name="l00122"></a>00122 } <span class="keywordflow">else</span> { <a name="l00123"></a>00123 view.<a class="code" href="classhippodraw_1_1ViewBase.html#a22a47195eeee5c3564b9cb9389460ff5" title="Draws a text string at a point in the view&#39;s coordinate system.">drawText</a> ( z_label, x, y, <a class="code" href="classhippodraw_1_1AxisRepBase.html#a8d43dad9f4dfcd6cdfa9aff560f943e8" title="Font size for the Z axis label.">m_z_font_size</a>, 0.0, <span class="charliteral">'c'</span>, <span class="charliteral">'b'</span>, <span class="keyword">false</span> ); <a name="l00124"></a>00124 } <a name="l00125"></a>00125 } <a name="l00126"></a>00126 <a name="l00127"></a><a class="code" href="classhippodraw_1_1AxisRepColor.html#a62483c38438e51f5965839dc35bd0152">00127</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1AxisRepColor.html#a62483c38438e51f5965839dc35bd0152" title="Takes care of the z ticks drawing (that is, the ticks on the top of the plot).">AxisRepColor::drawAllZTicks</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1AxisModelBase.html" title="The AxisModelBase class maintains the Range and scaling of an axis.">AxisModelBase</a> & axisModel, <a name="l00128"></a>00128 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1TransformBase.html" title="A transform that transforms coordinates from one coordinate system to another.">TransformBase</a> & transform, <a name="l00129"></a>00129 <a class="code" href="classhippodraw_1_1ViewBase.html" title="The abstract base class for views.">ViewBase</a> & view ) <a name="l00130"></a>00130 { <a name="l00131"></a>00131 <a class="code" href="classhippodraw_1_1AxisRepColor.html#acb45952b2b149418f14e7d8aa29da2aa" title="Draws the Z tick lines.">drawZTickLines</a> ( axisModel, transform, view ); <a name="l00132"></a>00132 <a class="code" href="classhippodraw_1_1AxisRepColor.html#af9840af124cccfc9254164c291593877" title="Draws the labels for the Z ticks.">drawZTickLabels</a> ( axisModel, transform, view ); <a name="l00133"></a>00133 } <a name="l00134"></a>00134 <a name="l00135"></a><a class="code" href="classhippodraw_1_1AxisRepColor.html#acb45952b2b149418f14e7d8aa29da2aa">00135</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1AxisRepColor.html#acb45952b2b149418f14e7d8aa29da2aa" title="Draws the Z tick lines.">AxisRepColor::drawZTickLines</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1AxisModelBase.html" title="The AxisModelBase class maintains the Range and scaling of an axis.">AxisModelBase</a> & axisModel, <a name="l00136"></a>00136 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1TransformBase.html" title="A transform that transforms coordinates from one coordinate system to another.">TransformBase</a> & transform, <a name="l00137"></a>00137 <a class="code" href="classhippodraw_1_1ViewBase.html" title="The abstract base class for views.">ViewBase</a> & base ) <a name="l00138"></a>00138 { <a name="l00139"></a>00139 <a class="code" href="AxisLoc_8h.html#a9b53735ee323795d625bf1a39a5c3407" title="The base class for the binner hierarchy.">AxisLoc</a> loc = axisModel.<a class="code" href="classhippodraw_1_1AxisModelBase.html#aa5cfb1d5e022633d10836bab146bbe98">getLabelLocation</a> (); <a name="l00140"></a>00140 assert ( loc == <a class="code" href="AxisLoc_8h.html#a9b53735ee323795d625bf1a39a5c3407a25ea433b17e0001d3eb65ab2ed1fc8e3">PLOTBOTTOM</a> || <a class="code" href="AxisLoc_8h.html#a9b53735ee323795d625bf1a39a5c3407a9363ca9721c743eb231d5a8592ea1e97">PLOTTOP</a> ); <a name="l00141"></a>00141 <a name="l00142"></a>00142 <span class="keyword">const</span> vector< AxisTick > & ticks = axisModel.<a class="code" href="classhippodraw_1_1AxisModelBase.html#ad8181ef7ae5bba7ec82f538048fc5b72" title="Returns a reference of generated ticks.">getTicks</a> (); <a name="l00143"></a>00143 <span class="keywordflow">if</span> ( ticks.empty() ) <span class="keywordflow">return</span>; <a name="l00144"></a>00144 <a name="l00145"></a>00145 vector< double > xv; <a name="l00146"></a>00146 vector< double > yv; <a name="l00147"></a>00147 <a name="l00148"></a>00148 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">size</a> = 2 * ticks.size (); <a name="l00149"></a>00149 xv.reserve ( size ); <a name="l00150"></a>00150 yv.reserve ( size ); <a name="l00151"></a>00151 <a name="l00152"></a>00152 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1BinaryTransform.html" title="A transform that transforms coordinates from one 2D coordinate system to another...">BinaryTransform</a> & t <a name="l00153"></a>00153 = <span class="keyword">dynamic_cast<</span> <span class="keyword">const </span><a class="code" href="classhippodraw_1_1BinaryTransform.html" title="A transform that transforms coordinates from one 2D coordinate system to another...">BinaryTransform</a> & <span class="keyword">></span> ( transform ); <a name="l00154"></a>00154 <a class="code" href="classhippodraw_1_1DataView.html" title="The abstract base class for views that have a region for drawing data points with...">DataView</a> & view = dynamic_cast < <a class="code" href="classhippodraw_1_1DataView.html" title="The abstract base class for views that have a region for drawing data points with...">DataView</a> & > ( base ); <a name="l00155"></a>00155 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Rect.html" title="Class representing a rectangle.">Rect</a> & view_rect = view.<a class="code" href="classhippodraw_1_1DataView.html#a68d755b4942b64218ef9b9921c412e2c" title="Returns the rectangle area in which data points are drawn.">getMarginRect</a> (); <a name="l00156"></a>00156 <span class="keywordtype">double</span> tick_length = 5; <a name="l00157"></a>00157 <span class="keywordtype">double</span> y_base = view_rect.<a class="code" href="classhippodraw_1_1Rect.html#acd84440598b1da2a23c326ce371db4e4" title="A shortcut to get origin.Y.">getY</a>() - 24; <a name="l00158"></a>00158 <a name="l00159"></a>00159 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i < ticks.size(); i++ ) { <a name="l00160"></a>00160 <span class="keywordtype">double</span> user_z = ticks[i].value (); <a name="l00161"></a>00161 t.<a class="code" href="classhippodraw_1_1BinaryTransform.html#aa58baf76c2af700afcec2326e14f44c4" title="Transforms the z coordinate.">transformZ</a> ( user_z ); <a name="l00162"></a>00162 <span class="comment">// Reinstate the following line when XYZ transform exists.</span> <a name="l00163"></a>00163 <span class="comment">//t.transform ( user_z, y ); // Some valid value on Y.</span> <a name="l00164"></a>00164 <a name="l00165"></a>00165 <span class="keywordtype">double</span> view_x = view.<a class="code" href="classhippodraw_1_1ViewBase.html#a347138aa1cc8ca85552766ce188d7ce5" title="Converts a coordinate in user space to drawing space along the color (X) axis.">userToDrawColor</a> ( user_z ); <a name="l00166"></a>00166 <a name="l00167"></a>00167 xv.push_back ( view_x ); <a name="l00168"></a>00168 yv.push_back ( y_base ); <a name="l00169"></a>00169 xv.push_back ( view_x ); <a name="l00170"></a>00170 yv.push_back ( y_base + tick_length ); <a name="l00171"></a>00171 <a name="l00172"></a>00172 } <a name="l00173"></a>00173 <a name="l00174"></a>00174 view.<a class="code" href="classhippodraw_1_1ViewBase.html#ad8433e22caa9e6cf96057c173701113c" title="Draws multiple line segments.">drawViewLines</a> ( xv, yv, <a class="code" href="namespacehippodraw_1_1Line.html#addb2fa415e015ee482fa2cd9eba96af7a454a9f774a1f745414146aa891d201f0" title="________">Line::Solid</a>, <span class="keyword">false</span>, 0 ); <a name="l00175"></a>00175 <a name="l00176"></a>00176 } <a name="l00177"></a>00177 <a name="l00178"></a><a class="code" href="classhippodraw_1_1AxisRepColor.html#af9840af124cccfc9254164c291593877">00178</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1AxisRepColor.html#af9840af124cccfc9254164c291593877" title="Draws the labels for the Z ticks.">AxisRepColor::drawZTickLabels</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1AxisModelBase.html" title="The AxisModelBase class maintains the Range and scaling of an axis.">AxisModelBase</a> & axisModel, <a name="l00179"></a>00179 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1TransformBase.html" title="A transform that transforms coordinates from one coordinate system to another.">TransformBase</a> & transform, <a name="l00180"></a>00180 <a class="code" href="classhippodraw_1_1ViewBase.html" title="The abstract base class for views.">ViewBase</a> & base ) <a name="l00181"></a>00181 { <a name="l00182"></a>00182 vector < double > xv; <a name="l00183"></a>00183 vector < double > yv; <a name="l00184"></a>00184 <a name="l00185"></a>00185 <span class="keyword">const</span> vector< AxisTick > & ticks = axisModel.<a class="code" href="classhippodraw_1_1AxisModelBase.html#ad8181ef7ae5bba7ec82f538048fc5b72" title="Returns a reference of generated ticks.">getTicks</a> (); <a name="l00186"></a>00186 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">size</a> = ticks.size (); <a name="l00187"></a>00187 <span class="keywordflow">if</span> ( size == 0 ) <span class="keywordflow">return</span>; <a name="l00188"></a>00188 <a name="l00189"></a>00189 xv.reserve ( size ); <a name="l00190"></a>00190 yv.reserve ( size ); <a name="l00191"></a>00191 <a name="l00192"></a>00192 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1BinaryTransform.html" title="A transform that transforms coordinates from one 2D coordinate system to another...">BinaryTransform</a> & t <a name="l00193"></a>00193 = <span class="keyword">dynamic_cast<</span> <span class="keyword">const </span><a class="code" href="classhippodraw_1_1BinaryTransform.html" title="A transform that transforms coordinates from one 2D coordinate system to another...">BinaryTransform</a> & <span class="keyword">></span> ( transform ); <a name="l00194"></a>00194 <a name="l00195"></a>00195 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; <span class="comment">// For MS VC++.</span> <a name="l00196"></a>00196 <span class="keywordflow">for</span> ( ; i < size; i++ ) { <a name="l00197"></a>00197 <span class="keywordtype">double</span> value = ticks[i].value (); <a name="l00198"></a>00198 t.<a class="code" href="classhippodraw_1_1BinaryTransform.html#aa58baf76c2af700afcec2326e14f44c4" title="Transforms the z coordinate.">transformZ</a> ( value ); <a name="l00199"></a>00199 xv.push_back ( value ); <a name="l00200"></a>00200 yv.push_back ( 1.0 ); <span class="comment">// Use a valid Y value.</span> <a name="l00201"></a>00201 } <a name="l00202"></a>00202 <a name="l00203"></a>00203 <a name="l00204"></a>00204 <span class="comment">// Calculate the Y position in view coordinates.</span> <a name="l00205"></a>00205 <a class="code" href="classhippodraw_1_1DataView.html" title="The abstract base class for views that have a region for drawing data points with...">DataView</a> & view = dynamic_cast < <a class="code" href="classhippodraw_1_1DataView.html" title="The abstract base class for views that have a region for drawing data points with...">DataView</a> & > ( base ); <a name="l00206"></a>00206 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Rect.html" title="Class representing a rectangle.">Rect</a> & margin = view.<a class="code" href="classhippodraw_1_1DataView.html#a68d755b4942b64218ef9b9921c412e2c" title="Returns the rectangle area in which data points are drawn.">getMarginRect</a> (); <a name="l00207"></a>00207 <span class="keywordtype">float</span> y = margin.<a class="code" href="classhippodraw_1_1Rect.html#acd84440598b1da2a23c326ce371db4e4" title="A shortcut to get origin.Y.">getY</a>() - 42; <a name="l00208"></a>00208 <a name="l00209"></a>00209 i = 0; <span class="comment">// For MS VC++.</span> <a name="l00210"></a>00210 <span class="keywordflow">for</span> ( ; i < size; i++ ) { <a name="l00211"></a>00211 <span class="keywordtype">float</span> x = view.<a class="code" href="classhippodraw_1_1ViewBase.html#a347138aa1cc8ca85552766ce188d7ce5" title="Converts a coordinate in user space to drawing space along the color (X) axis.">userToDrawColor</a> ( xv[i] ); <a name="l00212"></a>00212 <a class="code" href="classhippodraw_1_1AxisRepBase.html#a258e73cdff9561b36b4a314397b8f112" title="Draws a tick label for X axis.">drawXTickLabel</a> ( ticks[i].content (), x, y, view ); <a name="l00213"></a>00213 } <a name="l00214"></a>00214 <a name="l00215"></a>00215 <span class="keywordflow">if</span> ( axisModel.<a class="code" href="classhippodraw_1_1AxisModelBase.html#a2162425b32653426fe8637e351769968" title="The following functions are used by the AxisRepBase * object.">needPMag</a> () ) { <a name="l00216"></a>00216 <span class="comment">// Logarithmic graphs do not need the magnitude written.</span> <a name="l00217"></a>00217 <span class="keywordflow">if</span> ( !(axisModel.<a class="code" href="classhippodraw_1_1AxisModelBase.html#a4d864ee8e8581e14a866141d6d47976d" title="Returns a boolean describing the type of the scale of the axis.">isLog</a>() ) ) { <a name="l00218"></a>00218 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Rect.html" title="Class representing a rectangle.">Rect</a> & margin_rect = view.<a class="code" href="classhippodraw_1_1DataView.html#a68d755b4942b64218ef9b9921c412e2c" title="Returns the rectangle area in which data points are drawn.">getMarginRect</a> (); <a name="l00219"></a>00219 <span class="keywordtype">float</span> xx = margin_rect.<a class="code" href="classhippodraw_1_1Rect.html#af71e522ec6aa935c2618819b54f20e02" title="A shortcut to get origin.X.">getX</a>() <a name="l00220"></a>00220 + margin_rect.<a class="code" href="classhippodraw_1_1Rect.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="A shortcut to get size.width.">getWidth</a> () <a name="l00221"></a>00221 - <a class="code" href="classhippodraw_1_1AxisRepBase.html#af1364099c3dcbf1fd3cb59ab313e980c" title="Font size for the Y axis label.">m_y_font_size</a>; <a name="l00222"></a>00222 <span class="keywordtype">float</span> yy = margin_rect.<a class="code" href="classhippodraw_1_1Rect.html#acd84440598b1da2a23c326ce371db4e4" title="A shortcut to get origin.Y.">getY</a>() - 30. - <a class="code" href="classhippodraw_1_1AxisRepBase.html#a5931b5247e5c63d544fb411a27c9452c" title="Font size for the y tick labels.">m_y_tick_font_size</a>; <a name="l00223"></a>00223 view.<a class="code" href="classhippodraw_1_1ViewBase.html#a22a47195eeee5c3564b9cb9389460ff5" title="Draws a text string at a point in the view&#39;s coordinate system.">drawText</a> ( <span class="stringliteral">"x10"</span>, xx, yy, <a class="code" href="classhippodraw_1_1AxisRepBase.html#a5931b5247e5c63d544fb411a27c9452c" title="Font size for the y tick labels.">m_y_tick_font_size</a>, 0., <span class="charliteral">'l'</span>, <span class="charliteral">'b'</span> ); <a name="l00224"></a>00224 <span class="keywordtype">double</span> mag = axisModel.<a class="code" href="classhippodraw_1_1AxisModelBase.html#aa5f0390d0531f504b59bbb13de685328" title="Returns the magnitude of the power of ten for the tick labels.">getPMag</a> (); <a name="l00225"></a>00225 <span class="keywordtype">int</span> i = static_cast < <span class="keywordtype">int</span> > ( mag ); <a name="l00226"></a>00226 <span class="keyword">const</span> <span class="keywordtype">string</span> text = <a class="code" href="namespacehippodraw_1_1Axes.html#ae2337bddf33bc8b17dd5c08e665422cd" title="Converts from string representation ot Axes::Type representation.">String::convert</a> ( i ); <a name="l00227"></a>00227 xx += 1.75* <a class="code" href="classhippodraw_1_1AxisRepBase.html#a5931b5247e5c63d544fb411a27c9452c" title="Font size for the y tick labels.">m_y_tick_font_size</a>; <a name="l00228"></a>00228 yy -= 0.5 * <a class="code" href="classhippodraw_1_1AxisRepBase.html#a5931b5247e5c63d544fb411a27c9452c" title="Font size for the y tick labels.">m_y_tick_font_size</a>; <a name="l00229"></a>00229 view.<a class="code" href="classhippodraw_1_1ViewBase.html#a22a47195eeee5c3564b9cb9389460ff5" title="Draws a text string at a point in the view&#39;s coordinate system.">drawText</a> ( text, xx, yy, <a class="code" href="classhippodraw_1_1AxisRepBase.html#a5931b5247e5c63d544fb411a27c9452c" title="Font size for the y tick labels.">m_y_tick_font_size</a>, 0., <span class="charliteral">'l'</span>, <span class="charliteral">'b'</span> ); <a name="l00230"></a>00230 } <a name="l00231"></a>00231 } <a name="l00232"></a>00232 <a name="l00233"></a>00233 } <a name="l00234"></a>00234 <a name="l00235"></a>00235 <span class="keywordtype">void</span> <a name="l00236"></a>00236 <a class="code" href="classhippodraw_1_1AxisRepColor.html#a771c2e6d33ebc609d5291042a591c611" title="Draws the color scale bar.">AxisRepColor::</a> <a name="l00237"></a><a class="code" href="classhippodraw_1_1AxisRepColor.html#a771c2e6d33ebc609d5291042a591c611">00237</a> <a class="code" href="classhippodraw_1_1AxisRepColor.html#a771c2e6d33ebc609d5291042a591c611" title="Draws the color scale bar.">drawColorScale</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1BinToColor.html" title="The base class for the value to the color transformation.">BinToColor</a> & bin_to_color, <a class="code" href="classhippodraw_1_1ViewBase.html" title="The abstract base class for views.">ViewBase</a> & base ) <a name="l00238"></a>00238 { <a name="l00239"></a>00239 <a class="code" href="classhippodraw_1_1DataView.html" title="The abstract base class for views that have a region for drawing data points with...">DataView</a> & view = dynamic_cast < <a class="code" href="classhippodraw_1_1DataView.html" title="The abstract base class for views that have a region for drawing data points with...">DataView</a> & > ( base ); <a name="l00240"></a>00240 <a class="code" href="classhippodraw_1_1PlotterBase.html" title="The base class for the PlotterBase hierarchy.">PlotterBase</a> * plotter = view.<a class="code" href="classhippodraw_1_1ViewBase.html#a78aa09930b4007dfa886e1ecb2dbf57b" title="Returns the plotter used by this view.">getPlotter</a> (); <a name="l00241"></a>00241 <a name="l00242"></a>00242 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Rect.html" title="Class representing a rectangle.">Rect</a> & margin = view.<a class="code" href="classhippodraw_1_1DataView.html#a68d755b4942b64218ef9b9921c412e2c" title="Returns the rectangle area in which data points are drawn.">getMarginRect</a>(); <a name="l00243"></a>00243 <a name="l00244"></a>00244 <span class="keywordtype">double</span> y_base = margin.<a class="code" href="classhippodraw_1_1Rect.html#acd84440598b1da2a23c326ce371db4e4" title="A shortcut to get origin.Y.">getY</a>() - 22; <a name="l00245"></a>00245 <a name="l00246"></a>00246 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Range.html" title="Expresses a range of values.">Range</a> range = bin_to_color.<a class="code" href="classhippodraw_1_1BinToColor.html#aa242fc96cb71313a51f25aefcf152e88" title="Get the Range of expected values.">getRange</a> (); <a name="l00247"></a>00247 <span class="keywordtype">double</span> value = range.<a class="code" href="classhippodraw_1_1Range.html#a3865c37c86de4e4eafc43b6b40ef05b9" title="Returns the minimum of the range object.">low</a> (); <a name="l00248"></a>00248 <span class="keywordtype">double</span> delta_v = range.<a class="code" href="classhippodraw_1_1Range.html#ad207cb443e371f73f07e874c504f60c1" title="Returns the length of the range object.">length</a> () / margin.<a class="code" href="classhippodraw_1_1Rect.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="A shortcut to get size.width.">getWidth</a> (); <a name="l00249"></a>00249 <span class="keywordflow">if</span> (delta_v == 0) { <a name="l00250"></a>00250 <span class="keywordflow">return</span>; <a name="l00251"></a>00251 } <a name="l00252"></a>00252 <span class="keywordflow">for</span> ( <span class="keywordtype">float</span> i = 0; i <= margin.<a class="code" href="classhippodraw_1_1Rect.html#a5410fe8e5b318eb82d84dcccf3634d8b" title="A shortcut to get size.width.">getWidth</a>() ; i++ ) { <a name="l00253"></a>00253 <a name="l00254"></a>00254 <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Color.html" title="A Color class for creating the color object following the standard RGB color space...">Color</a> & rep_color = plotter->repColor(); <a name="l00255"></a>00255 <a name="l00256"></a>00256 <a class="code" href="classhippodraw_1_1Color.html" title="A Color class for creating the color object following the standard RGB color space...">Color</a> color = rep_color; <a name="l00257"></a>00257 <a name="l00258"></a>00258 bin_to_color.<a class="code" href="classhippodraw_1_1BinToColor.html#aa1feadf0b266c72cb4e75e5c4e2e6bb4" title="This function does the actual calculation that transforms the given value into a...">doubleToColor</a> ( value, color ); <a name="l00259"></a>00259 view.<a class="code" href="classhippodraw_1_1ViewBase.html#ae11c4fc0fab54360e3ed1e53a5d257ee" title="Draws a colored square in view space.">drawViewSquare</a> ( margin.<a class="code" href="classhippodraw_1_1Rect.html#af71e522ec6aa935c2618819b54f20e02" title="A shortcut to get origin.X.">getX</a>() + i, <a name="l00260"></a>00260 y_base, <a name="l00261"></a>00261 margin.<a class="code" href="classhippodraw_1_1Rect.html#af71e522ec6aa935c2618819b54f20e02" title="A shortcut to get origin.X.">getX</a>() + i + 1.0, <a name="l00262"></a>00262 y_base + 6, <a name="l00263"></a>00263 color.<a class="code" href="classhippodraw_1_1Color.html#a554f0bc3f055386ee8d8af3bed2270e0">getRed</a>(), <a name="l00264"></a>00264 color.<a class="code" href="classhippodraw_1_1Color.html#a2f7edccf0a09b1eb61bdca066be488ce">getGreen</a>(), <a name="l00265"></a>00265 color.<a class="code" href="classhippodraw_1_1Color.html#a6ef3a4782f8f919620728bc62e80f1e1">getBlue</a> () ); <a name="l00266"></a>00266 value += delta_v; <a name="l00267"></a>00267 } <a name="l00268"></a>00268 <a name="l00269"></a>00269 view.<a class="code" href="classhippodraw_1_1ViewBase.html#ae11c4fc0fab54360e3ed1e53a5d257ee" title="Draws a colored square in view space.">drawViewSquare</a> ( margin.<a class="code" href="classhippodraw_1_1Rect.html#af71e522ec6aa935c2618819b54f20e02" title="A shortcut to get origin.X.">getX</a>(), <a name="l00270"></a>00270 y_base, <a name="l00271"></a>00271 margin.<a class="code" href="classhippodraw_1_1Rect.html#af71e522ec6aa935c2618819b54f20e02" title="A shortcut to get origin.X.">getX</a>(), <a name="l00272"></a>00272 y_base + 8, <a name="l00273"></a>00273 0, 0, 0 ); <a name="l00274"></a>00274 } </pre></div></div> <hr size="1"><address style="align: right;"><small> Generated for HippoDraw Class Library by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0> </a> </small></address> </body> </html>