<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_28fb57ed95c79fe5ed14c4f71fb4c2a2.html">qt</a> </div> </div> <div class="contents"> <h1>QtViewWidget.cxx</h1><a href="QtViewWidget_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="comment">// inconsistent dll linkage</span> <a name="l00013"></a>00013 <span class="preprocessor">#ifdef _MSC_VER</span> <a name="l00014"></a>00014 <span class="preprocessor"></span><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="QtViewWidget_8h.html" title="hippodraw::QtViewWidget class interface">QtViewWidget.h</a>"</span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="preprocessor">#include "<a class="code" href="DrawBorder_8h.html" title="DrawBorder class interface.">DrawBorder.h</a>"</span> <a name="l00020"></a>00020 <span class="preprocessor">#include "<a class="code" href="qwt__paint__buffer_8h.html">qwt_paint_buffer.h</a>"</span> <a name="l00021"></a>00021 <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="PlotterBase_8h.html" title="hippodraw::PlotterBase class interface.">plotters/PlotterBase.h</a>"</span> <a name="l00023"></a>00023 <span class="preprocessor">#include "qpainter.h"</span> <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="preprocessor">#if QT_VERSION < 0x040000</span> <a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#else</span> <a name="l00027"></a>00027 <span class="preprocessor"></span><span class="comment">//Added by the Qt porting tool:</span> <a name="l00028"></a>00028 <span class="preprocessor">#include <QtGui/QMouseEvent></span> <a name="l00029"></a>00029 <span class="preprocessor">#include <QtGui/QPaintEvent></span> <a name="l00030"></a>00030 <span class="preprocessor">#endif</span> <a name="l00031"></a>00031 <span class="preprocessor"></span> <a name="l00032"></a>00032 <a name="l00033"></a>00033 <span class="preprocessor">#include <cassert></span> <a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="keyword">using</span> std::vector; <a name="l00036"></a>00036 <a name="l00037"></a>00037 <span class="keyword">using namespace </span>hippodraw; <a name="l00038"></a>00038 <a name="l00039"></a>00039 QtViewWidget:: <a name="l00040"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#a504e6feeb08ca54ae2329f095c35c868">00040</a> QtViewWidget ( <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html">QWidget</a> * parent, <span class="keyword">const</span> <span class="keywordtype">char</span> * name, Qt::WFlags wflags ) <a name="l00041"></a>00041 : <a class="code" href="classhippodraw_1_1QtViewImp.html" title="The class of derived from ViewBase for drawing to the screen and PostScript generation...">QtViewImp</a> ( 0 ), <span class="comment">// sets m_plotter to 0</span> <a name="l00042"></a>00042 <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html">QWidget</a> ( parent, name, wflags ) <a name="l00043"></a>00043 { <a name="l00044"></a>00044 <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html#setPaletteBackgroundColor">setPaletteBackgroundColor</a> ( <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qcolor.html">QColor</a> ( <span class="stringliteral">"white"</span> ) ); <a name="l00045"></a>00045 <a class="code" href="classhippodraw_1_1QtViewWidget.html#adf3c81a4c7ddf32da876f3dc84cc91c0">setDoubleBuffering</a>(0); <a name="l00046"></a>00046 } <a name="l00047"></a>00047 <a name="l00048"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#acaa8f2b045d5c1edd73d570954ee8023">00048</a> <a class="code" href="classhippodraw_1_1QtViewWidget.html#acaa8f2b045d5c1edd73d570954ee8023" title="The required virtual destructor.">QtViewWidget::~QtViewWidget</a> () <a name="l00049"></a>00049 { <a name="l00050"></a>00050 } <a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="comment">/* virtual */</span> <a name="l00053"></a>00053 <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qsize.html">QSize</a> <a name="l00054"></a>00054 <a class="code" href="classhippodraw_1_1QtViewWidget.html#aefbfb651cd9de25bd4e8ca0db19b2044" title="Re-implements inherited member to return a reasonable size.">QtViewWidget::</a> <a name="l00055"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#aefbfb651cd9de25bd4e8ca0db19b2044">00055</a> <a class="code" href="classhippodraw_1_1QtViewWidget.html#aefbfb651cd9de25bd4e8ca0db19b2044" title="Re-implements inherited member to return a reasonable size.">sizeHint</a> ()<span class="keyword"> const</span> <a name="l00056"></a>00056 <span class="keyword"></span>{ <a name="l00057"></a>00057 <span class="keywordflow">return</span> <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html#size">size</a>(); <a name="l00058"></a>00058 } <a name="l00059"></a>00059 <a name="l00060"></a>00060 <span class="keywordtype">void</span> <a name="l00061"></a>00061 <a class="code" href="classhippodraw_1_1QtViewWidget.html#aef6d1e0b5d9cec89fd206eda4d0f2c89" title="Re-implements inherited member to test something for SIP.">QtViewWidget::</a> <a name="l00062"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#aef6d1e0b5d9cec89fd206eda4d0f2c89">00062</a> <a class="code" href="classhippodraw_1_1QtViewWidget.html#aef6d1e0b5d9cec89fd206eda4d0f2c89" title="Re-implements inherited member to test something for SIP.">setPlotter</a> ( <a class="code" href="classhippodraw_1_1PlotterBase.html" title="The base class for the PlotterBase hierarchy.">PlotterBase</a> * plotter ) <a name="l00063"></a>00063 { <a name="l00064"></a>00064 <a class="code" href="classhippodraw_1_1QtViewWidget.html#aef6d1e0b5d9cec89fd206eda4d0f2c89" title="Re-implements inherited member to test something for SIP.">ViewBase::setPlotter</a> ( plotter ); <a name="l00065"></a>00065 plotter -> addObserver ( <span class="keyword">this</span> ); <a name="l00066"></a>00066 } <a name="l00067"></a>00067 <a name="l00068"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#a85bf5f2fd170a0352fc7f81733a7f245">00068</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1QtViewWidget.html#a85bf5f2fd170a0352fc7f81733a7f245" title="Re-implements the inherited function.">QtViewWidget::draw</a> ( <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qpainter.html">QPainter</a> & painter ) <a name="l00069"></a>00069 { <a name="l00070"></a>00070 <a class="code" href="classhippodraw_1_1QtViewImp.html#a67b1b3cc5e4689425f4537bedb4ceb3f" title="The current Qt QPainter object.">m_painter</a> = & painter; <a name="l00071"></a>00071 <a name="l00072"></a>00072 <a class="code" href="classhippodraw_1_1ViewBase.html#a7dd51b6bbe20a6d4fdd65068ef18bf54" title="Draws itself.">drawSelf</a> (); <a name="l00073"></a>00073 } <a name="l00074"></a>00074 <a name="l00075"></a>00075 <span class="keywordtype">void</span> <a name="l00076"></a>00076 <a class="code" href="classhippodraw_1_1QtViewWidget.html#ad06d035e601c42cc2a3b9d1229c73d36" title="Overrides virtual function of QWidget to do drawing.">QtViewWidget::</a> <a name="l00077"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#ad06d035e601c42cc2a3b9d1229c73d36">00077</a> <a class="code" href="classhippodraw_1_1QtViewWidget.html#ad06d035e601c42cc2a3b9d1229c73d36" title="Overrides virtual function of QWidget to do drawing.">paintEvent</a> ( <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qpaintevent.html">QPaintEvent</a> * ev ) <a name="l00078"></a>00078 { <a name="l00079"></a>00079 <a name="l00080"></a>00080 <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1ViewBase.html#a1de80faff2428b8dc67995112931b636" title="The plotter object used by this view.">m_plotter</a> == 0 ) <span class="keywordflow">return</span>; <a name="l00081"></a>00081 <a name="l00082"></a>00082 <a class="code" href="classhippodraw_1_1DataView.html#a5958ddebacf2da2cfddeb0b6640677a7" title="Prepares the margin rectangle.">prepareMarginRect</a> (); <a name="l00083"></a>00083 <a name="l00084"></a>00084 <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1QtViewWidget.html#a8cb3f1dc92fd8f2a07d0948a67ee0c4d">double_buffer</a> == 1) <a name="l00085"></a>00085 { <a name="l00086"></a>00086 <span class="comment">// Use double-buffering</span> <a name="l00087"></a>00087 <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qrect.html">QRect</a> &ur = ev-><a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qpaintevent.html#rect">rect</a>(); <a name="l00088"></a>00088 <span class="keywordflow">if</span> ( ur.<a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qrect.html#isValid">isValid</a>() ) <a name="l00089"></a>00089 { <a name="l00090"></a>00090 <a name="l00091"></a>00091 QwtPaintBuffer paintBuffer(<span class="keyword">this</span>, ur); <a name="l00092"></a>00092 <a class="code" href="classhippodraw_1_1QtViewImp.html#a67b1b3cc5e4689425f4537bedb4ceb3f" title="The current Qt QPainter object.">m_painter</a> = paintBuffer.painter(); <a name="l00093"></a>00093 <a class="code" href="classhippodraw_1_1ViewBase.html#a7dd51b6bbe20a6d4fdd65068ef18bf54" title="Draws itself.">drawSelf</a> (); <a name="l00094"></a>00094 } <a name="l00095"></a>00095 } <a name="l00096"></a>00096 <span class="keywordflow">else</span> <a name="l00097"></a>00097 { <a name="l00098"></a>00098 <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qpainter.html">QPainter</a> painter ( <span class="keyword">this</span> ); <a name="l00099"></a>00099 <a class="code" href="classhippodraw_1_1QtViewImp.html#a67b1b3cc5e4689425f4537bedb4ceb3f" title="The current Qt QPainter object.">m_painter</a> = & painter; <a name="l00100"></a>00100 <a class="code" href="classhippodraw_1_1ViewBase.html#a7dd51b6bbe20a6d4fdd65068ef18bf54" title="Draws itself.">drawSelf</a> (); <a name="l00101"></a>00101 } <a name="l00102"></a>00102 } <a name="l00103"></a>00103 <a name="l00104"></a>00104 <a class="code" href="classhippodraw_1_1Rect.html" title="Class representing a rectangle.">Rect</a> <a name="l00105"></a>00105 <a class="code" href="classhippodraw_1_1QtViewWidget.html#a9b7c5f2dc9b2a9aff42c13200dae82aa" title="Returns the drawing Rectangle in the devices coordinate system.">QtViewWidget::</a> <a name="l00106"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#a9b7c5f2dc9b2a9aff42c13200dae82aa">00106</a> <a class="code" href="classhippodraw_1_1QtViewWidget.html#a9b7c5f2dc9b2a9aff42c13200dae82aa" title="Returns the drawing Rectangle in the devices coordinate system.">getDrawRect</a> ()<span class="keyword"> const</span> <a name="l00107"></a>00107 <span class="keyword"></span>{ <a name="l00108"></a>00108 <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qrect.html">QRect</a> & <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html#rect">rect</a> = <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html#geometry">geometry</a> (); <a name="l00109"></a>00109 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1Rect.html" title="Class representing a rectangle.">Rect</a> ( 0.0, 0.0, rect.<a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qrect.html#width">width</a>(), rect.<a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qrect.html#height">height</a>() ); <a name="l00110"></a>00110 } <a name="l00111"></a>00111 <a name="l00112"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#ae6b85d8f95c1889865463b18e33d08a5">00112</a> <span class="keywordtype">void</span> <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html#update">QtViewWidget:: update</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Observable.html" title="Part of an implementation of the Observable-Observer pattern based on the example...">Observable</a> * display ) <a name="l00113"></a>00113 { <a name="l00114"></a>00114 <span class="keywordflow">if</span> ( display == 0 ) <span class="keywordflow">return</span>; <a name="l00115"></a>00115 <a name="l00116"></a>00116 <span class="comment">// Adjust the width if the aspect ratio needs changing.</span> <a name="l00117"></a>00117 <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1ViewBase.html#a1de80faff2428b8dc67995112931b636" title="The plotter object used by this view.">m_plotter</a> != 0 ) { <a name="l00118"></a>00118 <span class="keywordtype">double</span> ratio = <a class="code" href="classhippodraw_1_1ViewBase.html#a1de80faff2428b8dc67995112931b636" title="The plotter object used by this view.">m_plotter</a> -> <a class="code" href="classhippodraw_1_1ViewBase.html#a92b295524262e25d2f5ae55a22ac3c87" title="Get the aspect ratio.">getAspectRatio</a> (); <a name="l00119"></a>00119 <span class="keywordflow">if</span> ( ratio != 0. ) { <a name="l00120"></a>00120 <span class="keywordtype">double</span> w = <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html#width">width</a> (); <a name="l00121"></a>00121 <span class="keywordtype">double</span> h = <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html#height">height</a> (); <a name="l00122"></a>00122 <span class="keywordtype">double</span> diff = ratio - w / h; <a name="l00123"></a>00123 <span class="keywordflow">if</span> ( diff > 0.00001 ) { <a name="l00124"></a>00124 <span class="keywordtype">int</span> new_h = <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html#height">height</a>(); <a name="l00125"></a>00125 <span class="keywordtype">int</span> new_w = static_cast < <span class="keywordtype">int</span> > ( w * ratio ); <a name="l00126"></a>00126 <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html#setFixedSize">setFixedSize</a> ( new_w, new_h ); <a name="l00127"></a>00127 <a class="code" href="classhippodraw_1_1DataView.html#a5958ddebacf2da2cfddeb0b6640677a7" title="Prepares the margin rectangle.">prepareMarginRect</a> (); <a name="l00128"></a>00128 } <a name="l00129"></a>00129 } <a name="l00130"></a>00130 } <a name="l00131"></a>00131 <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html#update">QtViewImp::update</a> ( display ); <a name="l00132"></a>00132 <a name="l00133"></a>00133 <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html#update">QWidget::update</a> (); <a name="l00134"></a>00134 } <a name="l00135"></a>00135 <a name="l00136"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#a3b42b94073bbc2a8430cb8558a05ae73">00136</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1QtViewWidget.html#a3b42b94073bbc2a8430cb8558a05ae73" title="Sets the drawing rectangle in the paint device space.">QtViewWidget::setDrawRect</a> ( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qrect.html">QRect</a> & rect ) <a name="l00137"></a>00137 { <a name="l00138"></a>00138 <a class="code" href="classhippodraw_1_1QtViewWidget.html#a3b42b94073bbc2a8430cb8558a05ae73" title="Sets the drawing rectangle in the paint device space.">setDrawRect</a> ( rect.<a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qrect.html#x">x</a> (), rect.<a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qrect.html#y">y</a> (), rect.<a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qrect.html#width">width</a> (), rect. <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html#height">height</a> () ); <a name="l00139"></a>00139 } <a name="l00140"></a>00140 <a name="l00141"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#ad0c0ab625c1bd811a030e9b3c2acdfda">00141</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1QtViewWidget.html#a3b42b94073bbc2a8430cb8558a05ae73" title="Sets the drawing rectangle in the paint device space.">QtViewWidget::setDrawRect</a> ( <span class="keywordtype">float</span> x, <span class="keywordtype">float</span> y, <span class="keywordtype">float</span> w, <span class="keywordtype">float</span> h ) <a name="l00142"></a>00142 { <a name="l00143"></a>00143 <span class="keywordtype">int</span> ix = static_cast < <span class="keywordtype">int</span> > ( x ); <a name="l00144"></a>00144 <span class="keywordtype">int</span> iy = static_cast < <span class="keywordtype">int</span> > ( y ); <a name="l00145"></a>00145 <span class="keywordtype">int</span> iw = static_cast < <span class="keywordtype">int</span> > ( w ); <a name="l00146"></a>00146 <span class="keywordtype">int</span> ih = static_cast < <span class="keywordtype">int</span> > ( h ); <a name="l00147"></a>00147 <a name="l00148"></a>00148 <a class="code" href="classhippodraw_1_1QtViewWidget.html#aa822d69dc7bd5cedfb1f96f85b0824d2" title="Overloads the inherit member function in order to prepare the margin rectangle.">setGeometry</a> ( ix, iy, iw, ih ); <a name="l00149"></a>00149 } <a name="l00150"></a>00150 <a name="l00151"></a>00151 <span class="keywordtype">void</span> <a name="l00152"></a>00152 <a class="code" href="classhippodraw_1_1QtViewWidget.html#aa822d69dc7bd5cedfb1f96f85b0824d2" title="Overloads the inherit member function in order to prepare the margin rectangle.">QtViewWidget::</a> <a name="l00153"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#aa822d69dc7bd5cedfb1f96f85b0824d2">00153</a> <a class="code" href="classhippodraw_1_1QtViewWidget.html#aa822d69dc7bd5cedfb1f96f85b0824d2" title="Overloads the inherit member function in order to prepare the margin rectangle.">setGeometry</a> ( <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h ) <a name="l00154"></a>00154 { <a name="l00155"></a>00155 <a class="code" href="classhippodraw_1_1QtViewWidget.html#aa822d69dc7bd5cedfb1f96f85b0824d2" title="Overloads the inherit member function in order to prepare the margin rectangle.">QWidget::setGeometry</a> ( x, y, w, h ); <a name="l00156"></a>00156 <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1ViewBase.html#a1de80faff2428b8dc67995112931b636" title="The plotter object used by this view.">m_plotter</a> != 0 ) { <a name="l00157"></a>00157 <a class="code" href="classhippodraw_1_1DataView.html#a5958ddebacf2da2cfddeb0b6640677a7" title="Prepares the margin rectangle.">prepareMarginRect</a> (); <a name="l00158"></a>00158 } <a name="l00159"></a>00159 } <a name="l00160"></a>00160 <a name="l00161"></a>00161 <span class="keywordtype">void</span> <a name="l00162"></a>00162 <a class="code" href="classhippodraw_1_1QtViewWidget.html#aa822d69dc7bd5cedfb1f96f85b0824d2" title="Overloads the inherit member function in order to prepare the margin rectangle.">QtViewWidget::</a> <a name="l00163"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#ab437cf91a85332c40f0adcfb5b04bea9">00163</a> <a class="code" href="classhippodraw_1_1QtViewWidget.html#aa822d69dc7bd5cedfb1f96f85b0824d2" title="Overloads the inherit member function in order to prepare the margin rectangle.">setGeometry</a> ( <span class="keyword">const</span> <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qrect.html">QRect</a> & rect ) <a name="l00164"></a>00164 { <a name="l00165"></a>00165 <a class="code" href="classhippodraw_1_1QtViewWidget.html#aa822d69dc7bd5cedfb1f96f85b0824d2" title="Overloads the inherit member function in order to prepare the margin rectangle.">setGeometry</a> ( rect.<a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qrect.html#x">x</a>(), rect.<a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qrect.html#y">y</a>(), rect.<a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qrect.html#width">width</a>(), rect.<a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qrect.html#height">height</a>() ); <a name="l00166"></a>00166 } <a name="l00167"></a>00167 <a name="l00168"></a>00168 <a name="l00169"></a>00169 <span class="keywordtype">void</span> <a name="l00170"></a>00170 <a class="code" href="classhippodraw_1_1QtViewWidget.html#a6fbc07cec19868c41d513b9ef8343e9a" title="Overloads the inherit member function to set the margin rectangle.">QtViewWidget::</a> <a name="l00171"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#a6fbc07cec19868c41d513b9ef8343e9a">00171</a> <a class="code" href="classhippodraw_1_1QtViewWidget.html#a6fbc07cec19868c41d513b9ef8343e9a" title="Overloads the inherit member function to set the margin rectangle.">resizeEvent</a> ( <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qresizeevent.html">QResizeEvent</a> * event ) <a name="l00172"></a>00172 { <a name="l00173"></a>00173 <a class="code" href="classhippodraw_1_1QtViewWidget.html#a6fbc07cec19868c41d513b9ef8343e9a" title="Overloads the inherit member function to set the margin rectangle.">QWidget::resizeEvent</a> ( event ); <a name="l00174"></a>00174 <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1ViewBase.html#a1de80faff2428b8dc67995112931b636" title="The plotter object used by this view.">m_plotter</a> != 0 ) { <a name="l00175"></a>00175 <a class="code" href="classhippodraw_1_1DataView.html#a5958ddebacf2da2cfddeb0b6640677a7" title="Prepares the margin rectangle.">prepareMarginRect</a> (); <a name="l00176"></a>00176 } <a name="l00177"></a>00177 } <a name="l00178"></a>00178 <a name="l00179"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#afca6b3ed41824b26fdaf6e1b7581052d">00179</a> <span class="keywordtype">int</span> <a class="code" href="classhippodraw_1_1QtViewWidget.html#afca6b3ed41824b26fdaf6e1b7581052d" title="Converts the data space coordinate X to the view space coordinate X.">QtViewWidget::toViewX</a> ( <span class="keywordtype">double</span> datX )<span class="keyword"> const</span> <a name="l00180"></a>00180 <span class="keyword"></span>{ <a name="l00181"></a>00181 <span class="keywordflow">return</span> <span class="keyword">static_cast<</span> <span class="keywordtype">int</span> <span class="keyword">></span> ( <a class="code" href="classhippodraw_1_1DataView.html#ab04d1171abbedff5fed56c7a20fccee2" title="Converts the user X coordinate into the margin X coordinate.">userToMarginX</a> ( datX ) ); <a name="l00182"></a>00182 } <a name="l00183"></a>00183 <a name="l00184"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#a9726f4c2d6b718553349919aaa59ce17">00184</a> <span class="keywordtype">int</span> <a class="code" href="classhippodraw_1_1QtViewWidget.html#a9726f4c2d6b718553349919aaa59ce17" title="Converts the data space coordinate Y to the view space coordinate Y.">QtViewWidget::toViewY</a> ( <span class="keywordtype">double</span> datY )<span class="keyword"> const</span> <a name="l00185"></a>00185 <span class="keyword"></span>{ <a name="l00186"></a>00186 <span class="keywordflow">return</span> <span class="keyword">static_cast<</span> <span class="keywordtype">int</span> <span class="keyword">></span> ( <a class="code" href="classhippodraw_1_1DataView.html#ae98a2eca3fda293f98fd2af1764e0d11" title="Converts the user Y coordinate into the top-left based margin Y coordinate.">userToInvertedMarginY</a> ( datY ) ); <a name="l00187"></a>00187 } <a name="l00188"></a>00188 <a name="l00189"></a>00189 <span class="keywordtype">void</span> <a name="l00190"></a>00190 <a class="code" href="classhippodraw_1_1QtViewWidget.html#a59ce8eaae7105edf74adf7463f5df5ce" title="Fills the picked point vector.">QtViewWidget::</a> <a name="l00191"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#a59ce8eaae7105edf74adf7463f5df5ce">00191</a> <a class="code" href="classhippodraw_1_1QtViewWidget.html#a59ce8eaae7105edf74adf7463f5df5ce" title="Fills the picked point vector.">fillPickedPoint</a> ( <span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y, <a name="l00192"></a>00192 std::vector < double > & picked )<span class="keyword"> const</span> <a name="l00193"></a>00193 <span class="keyword"></span>{ <a name="l00194"></a>00194 <span class="keywordtype">double</span> xx = <a class="code" href="classhippodraw_1_1DataView.html#a89d3a971fe1c4fcbb4acadbc92a52247" title="Converts from view coordinate to data coordinate, without taking into account transforms...">marginToUserX</a> ( x ); <a name="l00195"></a>00195 <span class="keywordtype">double</span> yy = <a class="code" href="classhippodraw_1_1DataView.html#a48bdfcf650bd32575950147f16cde1c2" title="Converts from inverted view coordinate to data coordinate, without taking into account...">marginToInvertedUserY</a> ( y ); <a name="l00196"></a>00196 <a name="l00197"></a>00197 <a class="code" href="classhippodraw_1_1ViewBase.html#a1de80faff2428b8dc67995112931b636" title="The plotter object used by this view.">m_plotter</a> -> fillPickedPointFrom ( xx, yy, picked ); <a name="l00198"></a>00198 } <a name="l00199"></a>00199 <a name="l00200"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#aeafc551153eb91273c8ac06b1c172503">00200</a> <span class="keywordtype">int</span> <a class="code" href="classhippodraw_1_1QtViewWidget.html#aeafc551153eb91273c8ac06b1c172503" title="Converts coordinate from view space to canvas space.">QtViewWidget::toCanvasX</a> ( <span class="keywordtype">double</span> dx )<span class="keyword"> const</span> <a name="l00201"></a>00201 <span class="keyword"></span>{ <a name="l00202"></a>00202 <span class="keywordflow">return</span> static_cast < <span class="keywordtype">int</span> > ( dx ); <a name="l00203"></a>00203 } <a name="l00204"></a>00204 <a name="l00205"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#a3edf52b6c32b702cfec8679e1c1b4f80">00205</a> <span class="keywordtype">int</span> <a class="code" href="classhippodraw_1_1QtViewWidget.html#a3edf52b6c32b702cfec8679e1c1b4f80" title="Converts coordinate from view space to canvas space.">QtViewWidget::toCanvasY</a> ( <span class="keywordtype">double</span> dy )<span class="keyword"> const</span> <a name="l00206"></a>00206 <span class="keyword"></span>{ <a name="l00207"></a>00207 <span class="keywordflow">return</span> static_cast < <span class="keywordtype">int</span> > ( dy ); <a name="l00208"></a>00208 } <a name="l00209"></a>00209 <a name="l00210"></a>00210 <span class="keywordtype">void</span> <a name="l00211"></a>00211 <a class="code" href="classhippodraw_1_1QtViewWidget.html" title="The class of derived from ViewBase for drawing as a Qt Widget.">QtViewWidget</a>:: <a name="l00212"></a>00212 <span class="preprocessor">#if QT_VERSION < 0x040000</span> <a name="l00213"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#a481e00186f32b95769a3f9d679bd3374">00213</a> <span class="preprocessor"></span>transformAndFill ( <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qpointarray.html">QPointArray</a> & array, <a name="l00214"></a>00214 #<span class="keywordflow">else</span> <a name="l00215"></a>00215 transformAndFill ( QPolygon & array, <a name="l00216"></a>00216 #endif <a name="l00217"></a>00217 <span class="keyword">const</span> std::vector< double > & x, <a name="l00218"></a>00218 <span class="keyword">const</span> std::vector< double > & y, <a name="l00219"></a>00219 <span class="keywordtype">int</span> (<a class="code" href="classhippodraw_1_1QtViewWidget.html" title="The class of derived from ViewBase for drawing as a Qt Widget.">QtViewWidget</a>::* xfunc) ( <span class="keywordtype">double</span> ) <span class="keyword">const</span>, <a name="l00220"></a>00220 <span class="keywordtype">int</span> (<a class="code" href="classhippodraw_1_1QtViewWidget.html" title="The class of derived from ViewBase for drawing as a Qt Widget.">QtViewWidget</a>::* yfunc) ( <span class="keywordtype">double</span> ) <span class="keyword">const</span> ) <a name="l00221"></a>00221 { <a name="l00222"></a>00222 <a name="l00223"></a>00223 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">size</a> = x.size(); <a name="l00224"></a>00224 assert ( size == y.size() ); <a name="l00225"></a>00225 <a name="l00226"></a>00226 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i < size; i++ ) { <a name="l00227"></a>00227 <span class="keywordtype">int</span> ix = (this->*xfunc) ( x[i] ); <a name="l00228"></a>00228 <span class="keywordtype">int</span> iy = (this->*yfunc) ( y[i] ); <a name="l00229"></a>00229 array.setPoint ( i , ix, iy ); <a name="l00230"></a>00230 } <a name="l00231"></a>00231 <a name="l00232"></a>00232 } <a name="l00233"></a>00233 <a name="l00236"></a>00236 <span class="keywordtype">void</span> <a name="l00237"></a>00237 <a class="code" href="classhippodraw_1_1QtViewWidget.html#a449d64a4eb683be123dc5797d185bc4b" title="Draws in the view using the specified method.">QtViewWidget::</a> <a name="l00238"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#a449d64a4eb683be123dc5797d185bc4b">00238</a> <a class="code" href="classhippodraw_1_1QtViewWidget.html#a449d64a4eb683be123dc5797d185bc4b" title="Draws in the view using the specified method.">drawViewMethod</a> ( <span class="keyword">const</span> std::vector< double > & x, <a name="l00239"></a>00239 <span class="keyword">const</span> std::vector< double > & y, <a name="l00240"></a>00240 <span class="keywordtype">int</span>, <span class="comment">// style,</span> <a name="l00241"></a>00241 <span class="keywordtype">int</span> ) <span class="comment">// color )</span> <a name="l00242"></a>00242 { <a name="l00243"></a>00243 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html#size">size</a> = x.size(); <a name="l00244"></a>00244 assert ( size == y.size() ); <a name="l00245"></a>00245 <a name="l00246"></a>00246 <span class="preprocessor">#if QT_VERSION < 0x040000</span> <a name="l00247"></a>00247 <span class="preprocessor"></span> <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qpointarray.html">QPointArray</a> array ( size ); <a name="l00248"></a>00248 <span class="preprocessor">#else</span> <a name="l00249"></a>00249 <span class="preprocessor"></span> QPolygon array ( size ); <a name="l00250"></a>00250 <span class="preprocessor">#endif</span> <a name="l00251"></a>00251 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1QtViewWidget.html#a481e00186f32b95769a3f9d679bd3374" title="Fills the array with QPoint objects whose coordinates are in the QPaintDevice space...">transformAndFill</a> ( array, x, y, <a name="l00252"></a>00252 &<a class="code" href="classhippodraw_1_1QtViewWidget.html#aeafc551153eb91273c8ac06b1c172503" title="Converts coordinate from view space to canvas space.">QtViewWidget::toCanvasX</a>, &<a class="code" href="classhippodraw_1_1QtViewWidget.html#a3edf52b6c32b702cfec8679e1c1b4f80" title="Converts coordinate from view space to canvas space.">QtViewWidget::toCanvasY</a> ); <a name="l00253"></a>00253 <a name="l00254"></a>00254 <a class="code" href="classhippodraw_1_1QtViewImp.html#a67b1b3cc5e4689425f4537bedb4ceb3f" title="The current Qt QPainter object.">m_painter</a>-><a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qpainter.html#drawLineSegments">drawLineSegments</a> ( array ); <a name="l00255"></a>00255 } <a name="l00256"></a>00256 <a name="l00259"></a>00259 <span class="keywordtype">void</span> <a name="l00260"></a>00260 <a class="code" href="classhippodraw_1_1QtViewWidget.html#ad9d26d93ced269a4fa744849162259b6" title="Draws in the view using the specified method.">QtViewWidget::</a> <a name="l00261"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#ad9d26d93ced269a4fa744849162259b6">00261</a> <a class="code" href="classhippodraw_1_1QtViewWidget.html#ad9d26d93ced269a4fa744849162259b6" title="Draws in the view using the specified method.">drawMethod</a> ( <span class="keyword">const</span> std::vector < double > & x, <a name="l00262"></a>00262 <span class="keyword">const</span> std::vector < double > & y, <a name="l00263"></a>00263 <span class="keywordtype">int</span>, <span class="comment">// style,</span> <a name="l00264"></a>00264 <span class="keywordtype">int</span> ) <span class="comment">//color )</span> <a name="l00265"></a>00265 { <a name="l00266"></a>00266 <a name="l00267"></a>00267 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qwidget.html#size">size</a> = x.size(); <a name="l00268"></a>00268 assert ( size == y.size() ); <a name="l00269"></a>00269 <a name="l00270"></a>00270 <span class="preprocessor">#if QT_VERSION < 0x040000</span> <a name="l00271"></a>00271 <span class="preprocessor"></span> <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qpointarray.html">QPointArray</a> array ( size ); <a name="l00272"></a>00272 <span class="preprocessor">#else</span> <a name="l00273"></a>00273 <span class="preprocessor"></span> QPolygon array ( size ); <a name="l00274"></a>00274 <span class="preprocessor">#endif</span> <a name="l00275"></a>00275 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1QtViewWidget.html#a481e00186f32b95769a3f9d679bd3374" title="Fills the array with QPoint objects whose coordinates are in the QPaintDevice space...">transformAndFill</a> ( array, x, y, <a name="l00276"></a>00276 &<a class="code" href="classhippodraw_1_1QtViewWidget.html#afca6b3ed41824b26fdaf6e1b7581052d" title="Converts the data space coordinate X to the view space coordinate X.">QtViewWidget::toViewX</a>, &<a class="code" href="classhippodraw_1_1QtViewWidget.html#a9726f4c2d6b718553349919aaa59ce17" title="Converts the data space coordinate Y to the view space coordinate Y.">QtViewWidget::toViewY</a> ); <a name="l00277"></a>00277 <a name="l00278"></a>00278 <a class="code" href="classhippodraw_1_1QtViewImp.html#a67b1b3cc5e4689425f4537bedb4ceb3f" title="The current Qt QPainter object.">m_painter</a>-><a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qpainter.html#drawPolyline">drawPolyline</a> ( array, 0, -1 ); <a name="l00279"></a>00279 } <a name="l00280"></a>00280 <a name="l00281"></a>00281 <span class="keywordtype">void</span> <a name="l00282"></a>00282 <a class="code" href="classhippodraw_1_1QtViewWidget.html#adf3c81a4c7ddf32da876f3dc84cc91c0">QtViewWidget::</a> <a name="l00283"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#adf3c81a4c7ddf32da876f3dc84cc91c0">00283</a> <a class="code" href="classhippodraw_1_1QtViewWidget.html#adf3c81a4c7ddf32da876f3dc84cc91c0">setDoubleBuffering</a>( <span class="keywordtype">unsigned</span> dblbuf) <a name="l00284"></a>00284 { <a name="l00285"></a>00285 <a class="code" href="classhippodraw_1_1QtViewWidget.html#a8cb3f1dc92fd8f2a07d0948a67ee0c4d">double_buffer</a> = dblbuf; <a name="l00286"></a>00286 } <a name="l00287"></a>00287 <a name="l00288"></a>00288 <span class="keywordtype">void</span> <a name="l00289"></a>00289 <a class="code" href="classhippodraw_1_1QtViewWidget.html#a3571373ca6fedac4299977ab5fa2b88a" title="overrides the inherited virtual function.">QtViewWidget::</a> <a name="l00290"></a><a class="code" href="classhippodraw_1_1QtViewWidget.html#a3571373ca6fedac4299977ab5fa2b88a">00290</a> <a class="code" href="classhippodraw_1_1QtViewWidget.html#a3571373ca6fedac4299977ab5fa2b88a" title="overrides the inherited virtual function.">mousePressEvent</a> ( <a class="codeRef" doxygen="qt.tag:http://doc.trolltech.com/3.3/" href="http://doc.trolltech.com/3.3/qmouseevent.html">QMouseEvent</a> * e ) <a name="l00291"></a>00291 { <a name="l00292"></a>00292 <span class="keywordflow">if</span> ( e -> state () == Qt::ControlButton ) { <a name="l00293"></a>00293 <a class="code" href="classhippodraw_1_1ViewBase.html#a1de80faff2428b8dc67995112931b636" title="The plotter object used by this view.">m_plotter</a> -> toggleActivePlot (); <a name="l00294"></a>00294 e -> accept (); <a name="l00295"></a>00295 } <a name="l00296"></a>00296 } </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>