📄 qwt__plot_8cpp-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Qwt User's Guide: qwt_plot.cpp Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.6 --><div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li id="current"><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul></div><h1>qwt_plot.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************</span><a name="l00002"></a>00002 <span class="comment"> * Qwt Widget Library</span><a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 1997 Josef Wilgen</span><a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2002 Uwe Rathmann</span><a name="l00005"></a>00005 <span class="comment"> *</span><a name="l00006"></a>00006 <span class="comment"> * This library is free software; you can redistribute it and/or</span><a name="l00007"></a>00007 <span class="comment"> * modify it under the terms of the Qwt License, Version 1.0</span><a name="l00008"></a>00008 <span class="comment"> *****************************************************************************/</span><a name="l00009"></a>00009 <a name="l00010"></a>00010 <span class="preprocessor">#include <qpainter.h></span><a name="l00011"></a>00011 <span class="preprocessor">#if QT_VERSION < 0x040000</span><a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor">#include <qguardedptr.h></span><a name="l00013"></a>00013 <span class="preprocessor">#include <qfocusdata.h></span><a name="l00014"></a>00014 <span class="preprocessor">#else</span><a name="l00015"></a>00015 <span class="preprocessor"></span><span class="preprocessor">#include <qpointer.h></span><a name="l00016"></a>00016 <span class="preprocessor">#include <qpaintengine.h></span><a name="l00017"></a>00017 <span class="preprocessor">#endif</span><a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#include <qapplication.h></span><a name="l00019"></a>00019 <span class="preprocessor">#include <qevent.h></span><a name="l00020"></a>00020 <span class="preprocessor">#include "qwt_plot.h"</span><a name="l00021"></a>00021 <span class="preprocessor">#include "qwt_plot_dict.h"</span><a name="l00022"></a>00022 <span class="preprocessor">#include "qwt_plot_layout.h"</span><a name="l00023"></a>00023 <span class="preprocessor">#include "qwt_rect.h"</span><a name="l00024"></a>00024 <span class="preprocessor">#include "qwt_scale_widget.h"</span><a name="l00025"></a>00025 <span class="preprocessor">#include "qwt_scale_engine.h"</span><a name="l00026"></a>00026 <span class="preprocessor">#include "qwt_text_label.h"</span><a name="l00027"></a>00027 <span class="preprocessor">#include "qwt_legend.h"</span><a name="l00028"></a>00028 <span class="preprocessor">#include "qwt_dyngrid_layout.h"</span><a name="l00029"></a>00029 <span class="preprocessor">#include "qwt_plot_canvas.h"</span><a name="l00030"></a>00030 <span class="preprocessor">#include "qwt_paint_buffer.h"</span><a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="keyword">class </span>QwtPlot::PrivateData<a name="l00033"></a>00033 {<a name="l00034"></a>00034 <span class="keyword">public</span>:<a name="l00035"></a>00035 <span class="preprocessor">#if QT_VERSION < 0x040000</span><a name="l00036"></a>00036 <span class="preprocessor"></span> QGuardedPtr<QwtTextLabel> lblTitle;<a name="l00037"></a>00037 QGuardedPtr<QwtPlotCanvas> <a class="code" href="class_qwt_plot.html#afcc82150034fbeb393ceb9f54ba2f1a">canvas</a>;<a name="l00038"></a>00038 QGuardedPtr<QwtLegend> <a class="code" href="class_qwt_plot.html#ab1f2cf0e567e09a4c4bce3181c03ba0">legend</a>;<a name="l00039"></a>00039 <span class="preprocessor">#else</span><a name="l00040"></a>00040 <span class="preprocessor"></span> QPointer<QwtTextLabel> lblTitle;<a name="l00041"></a>00041 QPointer<QwtPlotCanvas> <a class="code" href="class_qwt_plot.html#afcc82150034fbeb393ceb9f54ba2f1a">canvas</a>;<a name="l00042"></a>00042 QPointer<QwtLegend> <a class="code" href="class_qwt_plot.html#ab1f2cf0e567e09a4c4bce3181c03ba0">legend</a>;<a name="l00043"></a>00043 <span class="preprocessor">#endif</span><a name="l00044"></a>00044 <span class="preprocessor"></span> <a class="code" href="class_qwt_plot_layout.html">QwtPlotLayout</a> *layout;<a name="l00045"></a>00045 <a name="l00046"></a>00046 <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#f14053ca41be0f9c6f820ed3c4379831">autoReplot</a>;<a name="l00047"></a>00047 };<a name="l00048"></a>00048 <a name="l00053"></a><a class="code" href="class_qwt_plot.html#cde7121614da027e9a1dbc4591613ca7">00053</a> <a class="code" href="class_qwt_plot.html#cde7121614da027e9a1dbc4591613ca7">QwtPlot::QwtPlot</a>(QWidget *parent):<a name="l00054"></a>00054 QFrame(parent)<a name="l00055"></a>00055 {<a name="l00056"></a>00056 initPlot(<a class="code" href="class_qwt_text.html">QwtText</a>());<a name="l00057"></a>00057 }<a name="l00058"></a>00058 <a name="l00064"></a><a class="code" href="class_qwt_plot.html#12888a2101ba2091db0e4710c6a109cb">00064</a> <a class="code" href="class_qwt_plot.html#cde7121614da027e9a1dbc4591613ca7">QwtPlot::QwtPlot</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_text.html">QwtText</a> &title, QWidget *parent):<a name="l00065"></a>00065 QFrame(parent)<a name="l00066"></a>00066 {<a name="l00067"></a>00067 initPlot(<a class="code" href="class_qwt_plot.html#1ae4b2e10f6691b7f1a14af70f743e2c">title</a>);<a name="l00068"></a>00068 }<a name="l00069"></a>00069 <a name="l00070"></a>00070 <span class="preprocessor">#if QT_VERSION < 0x040000</span><a name="l00071"></a>00071 <span class="preprocessor"></span><a name="l00076"></a>00076 <a class="code" href="class_qwt_plot.html#cde7121614da027e9a1dbc4591613ca7">QwtPlot::QwtPlot</a>(QWidget *parent, <span class="keyword">const</span> <span class="keywordtype">char</span> *name):<a name="l00077"></a>00077 QFrame(parent, name)<a name="l00078"></a>00078 { <a name="l00079"></a>00079 initPlot(<a class="code" href="class_qwt_text.html">QwtText</a>());<a name="l00080"></a>00080 } <a name="l00081"></a>00081 <span class="preprocessor">#endif</span><a name="l00082"></a>00082 <span class="preprocessor"></span><a name="l00083"></a>00083 <a name="l00085"></a><a class="code" href="class_qwt_plot.html#2b60620e3681810946dcc66002aad016">00085</a> <a class="code" href="class_qwt_plot.html#2b60620e3681810946dcc66002aad016">QwtPlot::~QwtPlot</a>()<a name="l00086"></a>00086 {<a name="l00087"></a>00087 <a class="code" href="class_qwt_plot_dict.html#cb2e402e05c693433ed7e84696fbdfc0">detachItems</a>(QwtPlotItem::Rtti_PlotItem, <a class="code" href="class_qwt_plot_dict.html#10dfae8b454fa4258b0372366013507a">autoDelete</a>());<a name="l00088"></a>00088 <a name="l00089"></a>00089 <span class="keyword">delete</span> d_data->layout;<a name="l00090"></a>00090 deleteAxesData();<a name="l00091"></a>00091 <span class="keyword">delete</span> d_data;<a name="l00092"></a>00092 }<a name="l00093"></a>00093 <a name="l00098"></a>00098 <span class="keywordtype">void</span> QwtPlot::initPlot(<span class="keyword">const</span> <a class="code" href="class_qwt_text.html">QwtText</a> &title)<a name="l00099"></a>00099 {<a name="l00100"></a>00100 d_data = <span class="keyword">new</span> PrivateData;<a name="l00101"></a>00101 <a name="l00102"></a>00102 <span class="preprocessor">#if QT_VERSION < 0x040000</span><a name="l00103"></a>00103 <span class="preprocessor"></span> setWFlags(Qt::WNoAutoErase);<a name="l00104"></a>00104 <span class="preprocessor">#endif </span><a name="l00105"></a>00105 <span class="preprocessor"></span><a name="l00106"></a>00106 d_data->layout = <span class="keyword">new</span> <a class="code" href="class_qwt_plot_layout.html">QwtPlotLayout</a>;<a name="l00107"></a>00107 <a name="l00108"></a>00108 d_data->autoReplot = <span class="keyword">false</span>;<a name="l00109"></a>00109 <a name="l00110"></a>00110 d_data->lblTitle = <span class="keyword">new</span> <a class="code" href="class_qwt_text_label.html">QwtTextLabel</a>(<a class="code" href="class_qwt_plot.html#1ae4b2e10f6691b7f1a14af70f743e2c">title</a>, <span class="keyword">this</span>);<a name="l00111"></a>00111 d_data->lblTitle->setFont(QFont(fontInfo().family(), 14, QFont::Bold));<a name="l00112"></a>00112 <a name="l00113"></a>00113 <a class="code" href="class_qwt_text.html">QwtText</a> text(<a class="code" href="class_qwt_plot.html#1ae4b2e10f6691b7f1a14af70f743e2c">title</a>);<a name="l00114"></a>00114 <span class="keywordtype">int</span> flags = Qt::AlignCenter;<a name="l00115"></a>00115 <span class="preprocessor">#if QT_VERSION < 0x040000</span><a name="l00116"></a>00116 <span class="preprocessor"></span> flags |= Qt::WordBreak | Qt::ExpandTabs;<a name="l00117"></a>00117 <span class="preprocessor">#else</span><a name="l00118"></a>00118 <span class="preprocessor"></span> flags |= Qt::TextWordWrap;<a name="l00119"></a>00119 <span class="preprocessor">#endif</span><a name="l00120"></a>00120 <span class="preprocessor"></span> text.setRenderFlags(flags);<a name="l00121"></a>00121 d_data->lblTitle->setText(text);<a name="l00122"></a>00122 <a name="l00123"></a>00123 d_data->legend = NULL;<a name="l00124"></a>00124 <a name="l00125"></a>00125 initAxesData();<a name="l00126"></a>00126 <a name="l00127"></a>00127 d_data->canvas = <span class="keyword">new</span> <a class="code" href="class_qwt_plot.html#ccdb72255f819eb70751e070294496fd">QwtPlotCanvas</a>(<span class="keyword">this</span>);<a name="l00128"></a>00128 d_data->canvas->setFrameStyle(QFrame::Panel|QFrame::Sunken);<a name="l00129"></a>00129 d_data->canvas->setLineWidth(2);<a name="l00130"></a>00130 d_data->canvas->setMidLineWidth(0);<a name="l00131"></a>00131 <a name="l00132"></a>00132 <a class="code" href="class_qwt_plot.html#6455596162a69876a3504c0017531cf3">updateTabOrder</a>();<a name="l00133"></a>00133 <a name="l00134"></a>00134 setSizePolicy(QSizePolicy::MinimumExpanding, <a name="l00135"></a>00135 QSizePolicy::MinimumExpanding);<a name="l00136"></a>00136 }<a name="l00137"></a>00137 <a name="l00141"></a><a class="code" href="class_qwt_plot.html#f40d1bfdd9b6cd94e9981db8b254b961">00141</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot.html#f40d1bfdd9b6cd94e9981db8b254b961">QwtPlot::event</a>(QEvent *e)<a name="l00142"></a>00142 {<a name="l00143"></a>00143 <span class="keywordtype">bool</span> ok = QFrame::event(e);<a name="l00144"></a>00144 <span class="keywordflow">switch</span>(e->type())<a name="l00145"></a>00145 {<a name="l00146"></a>00146 #<span class="keywordflow">if</span> QT_VERSION < 0x040000<a name="l00147"></a>00147 <span class="keywordflow">case</span> QEvent::LayoutHint:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -