⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grapher-grapher-cpp.html

📁 qtopiaphone英文帮助,用于初学者和开发人员,初学者可以用来学习,开发人员可以用来资料查询.
💻 HTML
📖 第 1 页 / 共 2 页
字号:
    for (rowdata = data.first();        rowdata; rowdata = data.next())    {        <a href="qcolor.html">QColor</a> c;        c.<a href="qcolor.html#e47175">setHsv</a>( ( i * 255)/data.count(), 255, 255 );// rainbow effect        p.<a href="qpainter.html#3e0cc8">setBrush</a>( c );                        // solid fill with color c        int a = int(( rowdata[0].dbl * 360.0 ) / total * 16.0 + 0.5);        p.<a name="drawPie"></a><a href="qpainter.html#3ca7a2">drawPie</a>( w/10, h/10, xd, yd, -apos, -a );        apos += a;        i++;    }    if (model.colType(1) == GraphModel::Label) {        double apos = (pieRotation-90)*M_PI/180;        for (rowdata = data.first();            rowdata; rowdata = data.next())        {            double a = rowdata[0].dbl * 360 / total * M_PI / 180;            int x = int(cos(apos+a/2)*w*5/16 + w/2 + 0.5);            int y = int(sin(apos+a/2)*h*5/16 + h/2 + 0.5);            // ### This causes a crash, so comment out for now            /*p.<a href="qpainter.html#0f088f">drawText</a>(x-w/8, y-h/8, w/4, h/4,                WordBreak|AlignCenter,                *rowdata[1].str);*/            apos += a;        }    }    <a href="qpainter.html">QPainter</a> p2(this);    p2.<a href="qpainter.html#898839">setClipRect</a>(event-&gt;<a href="qpaintevent.html#2d6e18">rect</a>());    p2.<a name="drawPixmap"></a><a href="qpainter.html#c64b89">drawPixmap</a>(0,0,pm);}void <a name="427"></a>Graph::paintWait(<a href="qpaintevent.html">QPaintEvent</a>*){    <a href="qpainter.html">QPainter</a> p(this);    p.<a href="qpainter.html#0f088f">drawText</a>(<a name="rect"></a><a href="qwidget.html#75ae71">rect</a>(), AlignCenter, "Loading...");}void <a name="428"></a>Graph::paintEvent(<a href="qpaintevent.html">QPaintEvent</a>* event){        if (!model.nCols()) {        <a name="paintWait"></a><a href="#427">paintWait</a>(event);    } else {        switch (style) {          case Pie:            <a name="paintPie"></a><a href="#426">paintPie</a>(event);            break;          case Bar:            <a name="paintBar"></a><a href="#425">paintBar</a>(event);            break;        }    }}void <a name="429"></a>Graph::setStyleFromMenu(int id){    <a href=#421>setStyle</a>(Style(id-100));}const char* <a name="430"></a>Graph::styleName[] = { "Pie", "Bar", 0 };Grapher::Grapher(){    data.setAutoDelete(TRUE);    firstline = TRUE;    ncols = 0;    line.open(IO_WriteOnly|IO_Truncate);}Grapher::~Grapher(){}<a href="qlist.html">QList</a>&lt;GraphModel::Datum&gt;&amp; <a name="<a name="411">"></a><a href="#411"><a name="411"></a>Grapher::graphData</a>(){    return data;}GraphModel::ColType <a name="412"></a>Grapher::colType(int col) const{    return coltype[col];}int <a name="413"></a>Grapher::nCols() const{    return ncols;}<a name="QNPWidget"></a><a href="qnpwidget.html">QNPWidget</a>* <a name="414"></a>Grapher::newWindow(){    // Create a Graph - our subclass of QNPWidget.    Graph *graph = new Graph(*this);    // Look at the arguments from the EMBED tag.    //   GRAPHSTYLE chooses pie or bar    //   FONTFAMILY and FONTSIZE choose the font    //    const char* style = arg("GRAPHSTYLE");    if ( style ) graph-&gt;<a name="setStyle"></a><a href="qwidget.html#287f79">setStyle</a>(style);    const char* fontfamily = arg("FONTFAMILY");    const char* fontsize = arg("FONTSIZE");    int ptsize = fontsize ? atoi(fontsize) : graph-&gt;<a href="qwidget.html#167922">font</a>().pointSize();    if (fontfamily) graph-&gt;<a name="setFont"></a><a href="qwidget.html#090d60">setFont</a>(<a name="QFont"></a><a href="qfont.html">QFont</a>(fontfamily, ptsize));    <a name="connect"></a><a href="qobject.html#fbde73">connect</a>(graph, SIGNAL(<a name="aboutPlugin"></a><a href="#417">aboutPlugin</a>()), this, SLOT(<a href=#417>aboutPlugin</a>()));    <a href="qobject.html#fbde73">connect</a>(graph, SIGNAL(<a name="aboutData"></a><a href="#418">aboutData</a>()), this, SLOT(<a href=#418>aboutData</a>()));    return graph;}void <a name="415"></a>Grapher::consumeLine(){    line.close();    line.open(IO_ReadOnly);    <a name="QTextStream"></a><a href="qtextstream.html">QTextStream</a> ts( &amp;line );    if (firstline) {        firstline = FALSE;        ncols=0;        <a href="qlist.html">QList</a>&lt;ColType&gt; typelist;        typelist.<a name="setAutoDelete"></a><a href="qcollection.html#a8ef9f">setAutoDelete</a>(TRUE);        do {            <a name="QString"></a><a href="qstring.html">QString</a> typestr;            ts &gt;&gt; typestr &gt;&gt; ws;            ColType* t = 0;            if ( typestr == "num" ) {                t = new ColType(Numeric);            } else if ( typestr == "label" ) {                t = new ColType(Label);            }            if (t) typelist.<a name="append"></a><a href="qlist.html#c5746a">append</a>(t);        } while (!ts.<a name="eof"></a><a href="qtextstream.html#bb145b">eof</a>());        coltype = new ColType[ncols];        for (ColType* t = typelist.<a name="first"></a><a href="qlist.html#e625f9">first</a>(); t; t = typelist.<a name="next"></a><a href="qlist.html#f95ddd">next</a>()) {            coltype[ncols++] = *t;        }    } else {        int col=0;        Datum *rowdata = new Datum[ncols];        while ( col &lt; ncols &amp;&amp; !ts.<a href="qtextstream.html#bb145b">eof</a>() ) {            switch (coltype[col]) {              case Numeric: {                double value;                ts &gt;&gt; value &gt;&gt; ws;                rowdata[col].dbl = value;                break;              }              case Label: {                <a href="qstring.html">QString</a>* value = new <a href="qstring.html">QString</a>;                ts &gt;&gt; *value &gt;&gt; ws;                rowdata[col].str = value;                break;              }            }            col++;        }        data.append(rowdata);    }    line.close();    line.open(IO_WriteOnly|IO_Truncate);}int <a name="416"></a>Grapher::write(<a name="QNPStream"></a><a href="qnpstream.html">QNPStream</a>* /*str*/, int /*offset*/, int len, void* buffer){    // The browser calls this function when data is available on one    // of the streams the plugin has requested.  Since we are only    // processing one stream - the URL in the SRC argument of the EMBED    // tag, we assume the QNPStream is that one.  Also, since we do not    // override QNPInstance::writeReady(), we must accepts ALL the data    // that is sent to this function.    //    char* txt = (char*)buffer;    for (int i=0; i&lt;len; i++) {        char ch = txt[i];        switch ( ch ) {          case '\n':            <a name="consumeLine"></a><a href="#415">consumeLine</a>();            break;          case '\r': // ignore;            break;          default:            line.putch(ch);        }    }    if ( widget() ) {        <a name="widget"></a><a href="qnpinstance.html#9ac952">widget</a>()-&gt;update();    }    return len;}void <a name="417"></a>Grapher::aboutPlugin(){    <a name="getURL"></a><a href="qnpinstance.html#d57f95">getURL</a>( "http://www.trolltech.com/nsplugin/", "_blank" );}void <a name="418"></a>Grapher::aboutData(){    const char* page = arg("DATAPAGE");    if (page)        <a href="qnpinstance.html#d57f95">getURL</a>( page, "_blank" );    else        <a name="QMessageBox::message"></a><a href="qmessagebox.html#6f1d2d">QMessageBox::message</a>("Help", "No help for this data");}//// GrapherPlugin is the start of everything.  It is a QNPlugin subclass,// and it is responsible for describing the plugin to the browser, and// creating instances of the plugin when it appears in web page.//class GrapherPlugin : public QNPlugin {public:    GrapherPlugin()    {    }    <a name="QNPInstance"></a><a href="qnpinstance.html">QNPInstance</a>* newInstance()    {        // Make a new Grapher, our subclass of QNPInstance.        return new Grapher;    }    const char* getMIMEDescription() const    {        // Describe the MIME types which this plugin can        // process.  Just the concocted "application/x-graphable"        // type, with the "g1n" filename extension.        //        return "application/x-graphable:g1n:Graphable ASCII numeric data";    }    const char * getPluginNameString() const    {        // The name of the plugin.  This is the title string used in        // the "About Plugins" page of the browser.        //        return "Qt-based Graph Plugin";    }    const char * getPluginDescriptionString() const    {        // A longer description of the plugin.        //        return "A Qt-based LiveConnected plug-in that graphs numeric data";    }};//// Finally, we provide the implementation of QNPlugin::create(), to// provide our subclass of QNPlugin.//<a name="QNPlugin"></a><a href="qnplugin.html">QNPlugin</a>* QNPlugin::create(){    return new GrapherPlugin;}</pre><p><address><hr><div align="center"><table width="100%" cellspacing="0" border="0"><tr><td>Copyright 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -