Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > by-pkgid > 9601c7beb4ff23e834bfa171795ed560 > files > 149

vidalia-0.2.9-1mdv2010.1.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Vidalia: GraphFrame.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</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&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="dir_b47abd1aad201a152869566145babb61.html">src</a>&nbsp;&raquo;&nbsp;<a class="el" href="dir_695ba8f8357372e02d38c40b3c6dbe81.html">vidalia</a>&nbsp;&raquo;&nbsp;<a class="el" href="dir_b8299d6fcca538b98c7d31c1201c7907.html">bwgraph</a>
  </div>
</div>
<div class="contents">
<h1>GraphFrame.h</h1><a href="_graph_frame_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">**  This file is part of Vidalia, and is subject to the license terms in the</span>
<a name="l00003"></a>00003 <span class="comment">**  LICENSE file, found in the top level directory of this distribution. If you</span>
<a name="l00004"></a>00004 <span class="comment">**  did not receive the LICENSE file with this file, you may obtain it from the</span>
<a name="l00005"></a>00005 <span class="comment">**  Vidalia source package distributed by the Vidalia Project at</span>
<a name="l00006"></a>00006 <span class="comment">**  http://www.vidalia-project.net/. No part of Vidalia, including this file,</span>
<a name="l00007"></a>00007 <span class="comment">**  may be copied, modified, propagated, or distributed except according to the</span>
<a name="l00008"></a>00008 <span class="comment">**  terms described in the LICENSE file.</span>
<a name="l00009"></a>00009 <span class="comment">*/</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="comment">/*</span>
<a name="l00012"></a>00012 <span class="comment">** \file GraphFrame.h</span>
<a name="l00013"></a>00013 <span class="comment">** \version $Id: GraphFrame.h 3735 2009-04-28 20:28:01Z edmanm $</span>
<a name="l00014"></a>00014 <span class="comment">** \brief Graphs a series of send and receive data points</span>
<a name="l00015"></a>00015 <span class="comment">*/</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#ifndef _GRAPHFRAME_H</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define _GRAPHFRAME_H</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;QApplication&gt;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;QDesktopWidget&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;QFrame&gt;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;QPainter&gt;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;QPen&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;QList&gt;</span>
<a name="l00026"></a>00026 
<a name="l00027"></a><a class="code" href="_graph_frame_8h.html#ac6ae838acfc961a07c2259f2a2d19cc9">00027</a> <span class="preprocessor">#define HOR_SPC       2   </span><span class="comment">/** Space between data points */</span>
<a name="l00028"></a><a class="code" href="_graph_frame_8h.html#a5c9b0db0503faa2e5b82de06ef0db6ad">00028</a> <span class="preprocessor">#define MIN_SCALE     10  </span><span class="comment">/** 10 kB/s is the minimum scale */</span>
<a name="l00029"></a><a class="code" href="_graph_frame_8h.html#ac819bd8776f2a5676917cdb64e959133">00029</a> <span class="preprocessor">#define SCROLL_STEP   4   </span><span class="comment">/** Horizontal change on graph update */</span>
<a name="l00030"></a>00030 
<a name="l00031"></a><a class="code" href="_graph_frame_8h.html#a6de323223a88added192b027237ada79">00031</a> <span class="preprocessor">#define BACK_COLOR    Qt::black</span>
<a name="l00032"></a><a class="code" href="_graph_frame_8h.html#a743ce8f7b1d0500b4808f037de5b152a">00032</a> <span class="preprocessor"></span><span class="preprocessor">#define SCALE_COLOR   Qt::green</span>
<a name="l00033"></a><a class="code" href="_graph_frame_8h.html#aa144abea62a576df6a8b38fcbff5cabd">00033</a> <span class="preprocessor"></span><span class="preprocessor">#define GRID_COLOR    Qt::darkGreen</span>
<a name="l00034"></a><a class="code" href="_graph_frame_8h.html#ab46c84ed7433deb7226f2fc2b3d594bf">00034</a> <span class="preprocessor"></span><span class="preprocessor">#define RECV_COLOR    Qt::cyan</span>
<a name="l00035"></a><a class="code" href="_graph_frame_8h.html#a63529aabf494c7e4cc8d45cec0df946b">00035</a> <span class="preprocessor"></span><span class="preprocessor">#define SEND_COLOR    Qt::yellow</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span>
<a name="l00037"></a><a class="code" href="_graph_frame_8h.html#aa968a61524f9ed159c4c5464cb26dd41">00037</a> <span class="preprocessor">#define FONT_SIZE     11</span>
<a name="l00038"></a>00038 <span class="preprocessor"></span>
<a name="l00039"></a>00039 
<a name="l00040"></a><a class="code" href="class_graph_frame.html">00040</a> <span class="keyword">class </span><a class="code" href="class_graph_frame.html">GraphFrame</a> : <span class="keyword">public</span> QFrame
<a name="l00041"></a>00041 {
<a name="l00042"></a>00042   Q_OBJECT
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 <span class="keyword">public</span>:<span class="comment"></span>
<a name="l00045"></a>00045 <span class="comment">  /** Bandwidth graph style. */</span>
<a name="l00046"></a><a class="code" href="class_graph_frame.html#a3b7b5fa094ff22d70a0fe9dead0392ec">00046</a>   <span class="keyword">enum</span> <a class="code" href="class_graph_frame.html#a3b7b5fa094ff22d70a0fe9dead0392ec">GraphStyle</a> {
<a name="l00047"></a><a class="code" href="class_graph_frame.html#a3b7b5fa094ff22d70a0fe9dead0392eca609e7ca0bca446ed9cb0c198c9ec5029">00047</a>     <a class="code" href="class_graph_frame.html#a3b7b5fa094ff22d70a0fe9dead0392eca609e7ca0bca446ed9cb0c198c9ec5029">SolidLine</a> = 0,  <span class="comment">/**&lt; Plot bandwidth as solid lines. */</span>
<a name="l00048"></a><a class="code" href="class_graph_frame.html#a3b7b5fa094ff22d70a0fe9dead0392eca4e6d6ba510f2bd93c33522797a66d53b">00048</a>     <a class="code" href="class_graph_frame.html#a3b7b5fa094ff22d70a0fe9dead0392eca4e6d6ba510f2bd93c33522797a66d53b">AreaGraph</a>       <span class="comment">/**&lt; Plot bandwidth as alpha blended area graphs. */</span>
<a name="l00049"></a>00049   };
<a name="l00050"></a>00050   <span class="comment"></span>
<a name="l00051"></a>00051 <span class="comment">  /** Default Constructor */</span>
<a name="l00052"></a>00052   <a class="code" href="class_graph_frame.html#a5ef6a3e4a70a1185506d9212a6b074d9">GraphFrame</a>(QWidget *parent = 0);<span class="comment"></span>
<a name="l00053"></a>00053 <span class="comment">  /** Default Destructor */</span>
<a name="l00054"></a>00054   <a class="code" href="class_graph_frame.html#a0ac38ec44c553430716afd9886e8312b">~GraphFrame</a>();
<a name="l00055"></a>00055 <span class="comment"></span>
<a name="l00056"></a>00056 <span class="comment">  /** Add data points. */</span>
<a name="l00057"></a>00057   <span class="keywordtype">void</span> <a class="code" href="class_graph_frame.html#a53bc9a0e971ed0703546d64386a18077">addPoints</a>(qreal recv, qreal send);<span class="comment"></span>
<a name="l00058"></a>00058 <span class="comment">  /** Clears the graph. */</span>
<a name="l00059"></a>00059   <span class="keywordtype">void</span> <a class="code" href="class_graph_frame.html#a6a96a64f206c4a32c24d448e057a73b4">resetGraph</a>();<span class="comment"></span>
<a name="l00060"></a>00060 <span class="comment">  /** Toggles display of data counters. */</span>
<a name="l00061"></a>00061   <span class="keywordtype">void</span> <a class="code" href="class_graph_frame.html#aa9caabe44431ef15b79bae204d577564">setShowCounters</a>(<span class="keywordtype">bool</span> showRecv, <span class="keywordtype">bool</span> showSend);<span class="comment"></span>
<a name="l00062"></a>00062 <span class="comment">  /** Sets the graph style used to display bandwidth data. */</span>
<a name="l00063"></a><a class="code" href="class_graph_frame.html#aeea7b5538ea4fa4b5e53ad536073c139">00063</a>   <span class="keywordtype">void</span> <a class="code" href="class_graph_frame.html#aeea7b5538ea4fa4b5e53ad536073c139">setGraphStyle</a>(<a class="code" href="class_graph_frame.html#a3b7b5fa094ff22d70a0fe9dead0392ec">GraphStyle</a> style) { <a class="code" href="class_graph_frame.html#acd149d07b38b8078c5484ea6abbb1740">_graphStyle</a> = style; }
<a name="l00064"></a>00064 
<a name="l00065"></a>00065 <span class="keyword">protected</span>:<span class="comment"></span>
<a name="l00066"></a>00066 <span class="comment">  /** Overloaded QWidget::paintEvent() */</span>
<a name="l00067"></a>00067   <span class="keywordtype">void</span> <a class="code" href="class_graph_frame.html#aab09a1b8d58a1f48d4c25738967a2830">paintEvent</a>(QPaintEvent *event);
<a name="l00068"></a>00068 
<a name="l00069"></a>00069 <span class="keyword">private</span>:<span class="comment"></span>
<a name="l00070"></a>00070 <span class="comment">  /** Returns the width in pixels of &lt;b&gt;label&lt;/b&gt; using the current painter&#39;s</span>
<a name="l00071"></a>00071 <span class="comment">   * font. */</span>
<a name="l00072"></a>00072   <span class="keywordtype">int</span> <a class="code" href="class_graph_frame.html#afd04387763c8aa343d9589d8cd11b47c">labelWidth</a>(<span class="keyword">const</span> QString &amp;label);<span class="comment"></span>
<a name="l00073"></a>00073 <span class="comment">  /** Gets the width of the desktop, the max # of points. */</span>
<a name="l00074"></a>00074   <span class="keywordtype">int</span> <a class="code" href="class_graph_frame.html#a9e815c1b83d9ce59547c525a66f10b63">getNumPoints</a>();<span class="comment"></span>
<a name="l00075"></a>00075 <span class="comment">  /** Paints an integral and an outline of that integral for each data set</span>
<a name="l00076"></a>00076 <span class="comment">   * (send and/or receive) that is to be displayed. */</span>
<a name="l00077"></a>00077   <span class="keywordtype">void</span> <a class="code" href="class_graph_frame.html#a5d632ed29d15631d9d5c7a876b3c47c9">paintData</a>();<span class="comment"></span>
<a name="l00078"></a>00078 <span class="comment">  /** Paints the send/receive totals. */</span>
<a name="l00079"></a>00079   <span class="keywordtype">void</span> <a class="code" href="class_graph_frame.html#acf90d220e8a559e00bb54d5a0b15cd56">paintTotals</a>();<span class="comment"></span>
<a name="l00080"></a>00080 <span class="comment">  /** Paints the scale in the graph. */</span>
<a name="l00081"></a>00081   <span class="keywordtype">void</span> <a class="code" href="class_graph_frame.html#addaabcb5bb88ae42bddad6bd7ccaa5cb">paintScale</a>();<span class="comment"></span>
<a name="l00082"></a>00082 <span class="comment">  /** Returns a formatted string representation of total. */</span>
<a name="l00083"></a>00083   QString <a class="code" href="class_graph_frame.html#ad6c479bd01937c2ab19d2b844c64a070">totalToStr</a>(qreal total);<span class="comment"></span>
<a name="l00084"></a>00084 <span class="comment">  /** Returns a list of points on the bandwidth graph based on the supplied set</span>
<a name="l00085"></a>00085 <span class="comment">   * of send or receive values. */</span>
<a name="l00086"></a>00086   QVector&lt;QPointF&gt; <a class="code" href="class_graph_frame.html#af125b12aaeb7871e2a9741b0e5d869c8">pointsFromData</a>(QList&lt;qreal&gt;* list);<span class="comment"></span>
<a name="l00087"></a>00087 <span class="comment">  /** Paints a line with the data in &lt;b&gt;points&lt;/b&gt;. */</span>
<a name="l00088"></a>00088   <span class="keywordtype">void</span> <a class="code" href="class_graph_frame.html#a705a6da7f2ae34e4ab89bfc902f2f2c6">paintLine</a>(QVector&lt;QPointF&gt; points, QColor color, 
<a name="l00089"></a>00089                  Qt::PenStyle lineStyle = Qt::SolidLine);<span class="comment"></span>
<a name="l00090"></a>00090 <span class="comment">  /** Paints an integral using the supplied data. */</span>
<a name="l00091"></a>00091   <span class="keywordtype">void</span> <a class="code" href="class_graph_frame.html#a5128bc36afa191dcc1a3396545ccffb0">paintIntegral</a>(QVector&lt;QPointF&gt; points, QColor color, qreal alpha = 1.0);
<a name="l00092"></a>00092 <span class="comment"></span>
<a name="l00093"></a>00093 <span class="comment">  /** Style with which the bandwidth data will be graphed. */</span>
<a name="l00094"></a><a class="code" href="class_graph_frame.html#acd149d07b38b8078c5484ea6abbb1740">00094</a>   <a class="code" href="class_graph_frame.html#a3b7b5fa094ff22d70a0fe9dead0392ec">GraphStyle</a> <a class="code" href="class_graph_frame.html#acd149d07b38b8078c5484ea6abbb1740">_graphStyle</a>;<span class="comment"></span>
<a name="l00095"></a>00095 <span class="comment">  /** A QPainter object that handles drawing the various graph elements. */</span>
<a name="l00096"></a><a class="code" href="class_graph_frame.html#a01fe1be15610a74098efc4ad3ae38e83">00096</a>   QPainter* <a class="code" href="class_graph_frame.html#a01fe1be15610a74098efc4ad3ae38e83">_painter</a>;<span class="comment"></span>
<a name="l00097"></a>00097 <span class="comment">  /** Holds the received data points. */</span>
<a name="l00098"></a><a class="code" href="class_graph_frame.html#a3ff8bf370e5bfee72e44ae30d5009815">00098</a>   QList&lt;qreal&gt; *<a class="code" href="class_graph_frame.html#a3ff8bf370e5bfee72e44ae30d5009815">_recvData</a>;<span class="comment"></span>
<a name="l00099"></a>00099 <span class="comment">  /** Holds the sent data points. */</span>
<a name="l00100"></a><a class="code" href="class_graph_frame.html#ab1e7c7c99cf1fcc71525aaf611ee292d">00100</a>   QList&lt;qreal&gt; *<a class="code" href="class_graph_frame.html#ab1e7c7c99cf1fcc71525aaf611ee292d">_sendData</a>;<span class="comment"></span>
<a name="l00101"></a>00101 <span class="comment">  /** The current dimensions of the graph. */</span>
<a name="l00102"></a><a class="code" href="class_graph_frame.html#a5e9ae3af923019fa0bd15624825288db">00102</a>   QRect <a class="code" href="class_graph_frame.html#a5e9ae3af923019fa0bd15624825288db">_rec</a>;<span class="comment"></span>
<a name="l00103"></a>00103 <span class="comment">  /** The maximum data value plotted. */</span>
<a name="l00104"></a><a class="code" href="class_graph_frame.html#a1c24c5e36f3efa83b786e0897e7e812a">00104</a>   qreal <a class="code" href="class_graph_frame.html#a1c24c5e36f3efa83b786e0897e7e812a">_maxValue</a>;<span class="comment"></span>
<a name="l00105"></a>00105 <span class="comment">  /** The maximum number of points to store. */</span>
<a name="l00106"></a><a class="code" href="class_graph_frame.html#a4c27c0466a85ad76c6ed0551363e86ee">00106</a>   <span class="keywordtype">int</span> <a class="code" href="class_graph_frame.html#a4c27c0466a85ad76c6ed0551363e86ee">_maxPoints</a>;<span class="comment"></span>
<a name="l00107"></a>00107 <span class="comment">  /** The total data sent/recv. */</span>
<a name="l00108"></a><a class="code" href="class_graph_frame.html#ac198ff3ca22164eb0dec7a08c209654c">00108</a>   qreal <a class="code" href="class_graph_frame.html#ac198ff3ca22164eb0dec7a08c209654c">_totalSend</a>;
<a name="l00109"></a><a class="code" href="class_graph_frame.html#a3c97e6baa7a341ef640f3857faf15dbb">00109</a>   qreal <a class="code" href="class_graph_frame.html#a3c97e6baa7a341ef640f3857faf15dbb">_totalRecv</a>;<span class="comment"></span>
<a name="l00110"></a>00110 <span class="comment">  /** Show the respective lines and counters. */</span>
<a name="l00111"></a><a class="code" href="class_graph_frame.html#a3f3cdcc8694bae5e39636a4efa63bd01">00111</a>   <span class="keywordtype">bool</span> <a class="code" href="class_graph_frame.html#a3f3cdcc8694bae5e39636a4efa63bd01">_showRecv</a>;
<a name="l00112"></a><a class="code" href="class_graph_frame.html#ad5ce7b61e01ae3a164e815588dfda099">00112</a>   <span class="keywordtype">bool</span> <a class="code" href="class_graph_frame.html#ad5ce7b61e01ae3a164e815588dfda099">_showSend</a>;<span class="comment"></span>
<a name="l00113"></a>00113 <span class="comment">  /** Width (in pixels) of the scale marker area on the left side of the</span>
<a name="l00114"></a>00114 <span class="comment">   * graph. */</span>
<a name="l00115"></a><a class="code" href="class_graph_frame.html#aa0893911bc2078c7a24ce77489d317b2">00115</a>   <span class="keywordtype">int</span> <a class="code" href="class_graph_frame.html#aa0893911bc2078c7a24ce77489d317b2">_scaleWidth</a>;
<a name="l00116"></a>00116 };
<a name="l00117"></a>00117 
<a name="l00118"></a>00118 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Mon Aug 30 22:58:54 2010 for Vidalia by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>