Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

qwt_plot.cpp

00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** 00002 * Qwt Widget Library 00003 * Copyright (C) 1997 Josef Wilgen 00004 * Copyright (C) 2002 Uwe Rathmann 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the Qwt License, Version 1.0 00008 *****************************************************************************/ 00009 00010 // vim: expandtab 00011 00012 #include <qlabel.h> 00013 #include <qpainter.h> 00014 #include <qfocusdata.h> 00015 #include <qevent.h> 00016 #include "qwt_plot.h" 00017 #include "qwt_plot_layout.h" 00018 #include "qwt_plot_dict.h" 00019 #include "qwt_rect.h" 00020 #include "qwt_scale.h" 00021 #include "qwt_scale.h" 00022 #include "qwt_legend.h" 00023 #include "qwt_dyngrid_layout.h" 00024 #include "qwt_plot_canvas.h" 00025 #include "qwt_math.h" 00026 #include "qwt_paint_buffer.h" 00027 00034 QwtPlot::QwtPlot(QWidget *parent, const char *name) : 00035 QFrame(parent, name, Qt::WRepaintNoErase|Qt::WResizeNoErase) 00036 { 00037 initPlot(); 00038 } 00039 00040 00047 QwtPlot::QwtPlot(const QString &title, QWidget *parent, const char *name) : 00048 QFrame(parent, name, Qt::WRepaintNoErase|Qt::WResizeNoErase) 00049 { 00050 initPlot(title); 00051 } 00052 00054 QwtPlot::~QwtPlot() 00055 { 00056 delete d_layout; 00057 delete d_curves; 00058 delete d_markers; 00059 delete d_grid; 00060 } 00061 00066 void QwtPlot::initPlot(const QString &title) 00067 { 00068 d_layout = new QwtPlotLayout; 00069 00070 d_curves = new QwtCurveDict; 00071 d_markers = new QwtMarkerDict; 00072 00073 d_autoReplot = FALSE; 00074 00075 d_lblTitle = new QLabel(title, this); 00076 d_lblTitle->setFont(QFont(fontInfo().family(), 14, QFont::Bold)); 00077 d_lblTitle->setAlignment(Qt::AlignCenter|Qt::WordBreak|Qt::ExpandTabs); 00078 00079 d_legend = new QwtLegend(this); 00080 d_autoLegend = FALSE; 00081 00082 d_scale[yLeft] = new QwtScale(QwtScale::Left, this, "yLeft"); 00083 d_scale[yRight] = new QwtScale(QwtScale::Right, this, "yRight"); 00084 d_scale[xTop] = new QwtScale(QwtScale::Top, this, "xTop"); 00085 d_scale[xBottom] = new QwtScale(QwtScale::Bottom, this, "xBottom"); 00086 00087 initAxes(); 00088 00089 d_grid = new QwtPlotGrid(this); 00090 d_grid->setPen(QPen(Qt::black, 0, Qt::DotLine)); 00091 d_grid->enableXMin(FALSE); 00092 d_grid->enableYMin(FALSE); 00093 d_grid->setAxis(xBottom, yLeft); 00094 00095 d_canvas = new QwtPlotCanvas(this); 00096 d_canvas->setFrameStyle(QFrame::Panel|QFrame::Sunken); 00097 d_canvas->setLineWidth(2); 00098 d_canvas->setMidLineWidth(0); 00099 00100 #ifndef QWT_NO_COMPAT 00101 connect(d_canvas, SIGNAL(mousePressed(const QMouseEvent &)), 00102 this, SIGNAL(plotMousePressed(const QMouseEvent &))); 00103 connect(d_canvas, SIGNAL(mouseMoved(const QMouseEvent &)), 00104 this, SIGNAL(plotMouseMoved(const QMouseEvent &))); 00105 connect(d_canvas, SIGNAL(mouseReleased(const QMouseEvent &)), 00106 this, SIGNAL(plotMouseReleased(const QMouseEvent &))); 00107 #endif 00108 00109 updateTabOrder(); 00110 00111 QSizePolicy sp; 00112 sp.setHorData( QSizePolicy::MinimumExpanding ); 00113 sp.setVerData( QSizePolicy::MinimumExpanding ); 00114 setSizePolicy(sp); 00115 } 00116 00118 void QwtPlot::initAxes() 00119 { 00120 int axis; 00121 00122 QFont fscl(fontInfo().family(), 10); 00123 QFont fttl(fontInfo().family(), 12, QFont::Bold); 00124 00125 for(axis = 0; axis < axisCnt; axis++) 00126 { 00127 d_scale[axis]->setFont(fscl); 00128 d_scale[axis]->setTitleFont(fttl); 00129 d_scale[axis]->setBaselineDist(2); 00130 } 00131 00132 d_axisEnabled[yLeft] = TRUE; 00133 d_axisEnabled[yRight] = FALSE; 00134 d_axisEnabled[xBottom] = TRUE; 00135 d_axisEnabled[xTop] = FALSE; 00136 00137 for (axis=0; axis < axisCnt; axis++) 00138 { 00139 d_as[axis].adjust(0.0,1000.0,TRUE); 00140 d_scale[axis]->setScaleDiv(d_as[axis].scaleDiv()); 00141 } 00142 } 00143 00147 bool QwtPlot::event(QEvent *e) 00148 { 00149 bool ok = QFrame::event(e); 00150 switch(e->type()) 00151 { 00152 #if 0 00153 case QEvent::ChildInserted: 00154 case QEvent::ChildRemoved: 00155 #endif 00156 case QEvent::LayoutHint: 00157 updateLayout(); 00158 break; 00159 default:; 00160 } 00161 return ok; 00162 } 00163 00168 void QwtPlot::autoRefresh() 00169 { 00170 if (d_autoReplot) 00171 replot(); 00172 } 00173 00188 void QwtPlot::setAutoReplot(bool tf) 00189 { 00190 d_autoReplot = tf; 00191 } 00192 00196 bool QwtPlot::autoReplot() const 00197 { 00198 return d_autoReplot; 00199 } 00200 00205 void QwtPlot::setTitle(const QString &t) 00206 { 00207 d_lblTitle->setText(t); 00208 } 00209 00214 QString QwtPlot::title() const 00215 { 00216 return d_lblTitle->text(); 00217 } 00218 00219 00224 void QwtPlot::setTitleFont(const QFont &f) 00225 { 00226 d_lblTitle->setFont(f); 00227 } 00228 00232 QFont QwtPlot::titleFont() const 00233 { 00234 return d_lblTitle->font(); 00235 } 00236 00240 QwtPlotLayout *QwtPlot::plotLayout() 00241 { 00242 return d_layout; 00243 } 00244 00248 const QwtPlotLayout *QwtPlot::plotLayout() const 00249 { 00250 return d_layout; 00251 } 00252 00256 QLabel *QwtPlot::titleLabel() 00257 { 00258 return d_lblTitle; 00259 } 00260 00264 const QLabel *QwtPlot::titleLabel() const 00265 { 00266 return d_lblTitle; 00267 } 00268 00273 QwtLegend *QwtPlot::legend() 00274 { 00275 return d_legend; 00276 } 00277 00282 const QwtLegend *QwtPlot::legend() const 00283 { 00284 return d_legend; 00285 } 00286 00287 00291 QwtPlotCanvas *QwtPlot::canvas() 00292 { 00293 return d_canvas; 00294 } 00295 00299 const QwtPlotCanvas *QwtPlot::canvas() const 00300 { 00301 return d_canvas; 00302 } 00303 00309 QSize QwtPlot::sizeHint() const 00310 { 00311 int dw = 0; 00312 int dh = 0; 00313 for ( int axis = 0; axis < axisCnt; axis++ ) 00314 { 00315 if ( d_axisEnabled[axis] ) 00316 { 00317 const int niceDist = 40; 00318 const QwtScale *scale = d_scale[axis]; 00319 const int majCnt = scale->scaleDraw()->scaleDiv().majCnt(); 00320 00321 if ( axis == yLeft || axis == yRight ) 00322 { 00323 int hDiff = (majCnt - 1) * niceDist 00324 - scale->minimumSizeHint().height(); 00325 if ( hDiff > dh ) 00326 dh = hDiff; 00327 } 00328 else 00329 { 00330 int wDiff = (majCnt - 1) * niceDist 00331 - scale->minimumSizeHint().width(); 00332 if ( wDiff > dw ) 00333 dw = wDiff; 00334 } 00335 } 00336 } 00337 return minimumSizeHint() + QSize(dw, dh); 00338 } 00339 00343 QSize QwtPlot::minimumSizeHint() const 00344 { 00345 QSize hint = d_layout->minimumSizeHint(this); 00346 hint += QSize(2 * frameWidth(), 2 * frameWidth()); 00347 00348 return hint; 00349 } 00350 00352 void QwtPlot::resizeEvent(QResizeEvent *e) 00353 { 00354 QFrame::resizeEvent(e); 00355 updateLayout(); 00356 } 00357 00368 void QwtPlot::replot() 00369 { 00370 bool doAutoReplot = autoReplot(); 00371 setAutoReplot(FALSE); 00372 00373 updateAxes(); 00374 00375 d_canvas->invalidateCache(); 00376 d_canvas->repaint(d_canvas->contentsRect(), FALSE); 00377 00378 setAutoReplot(doAutoReplot); 00379 } 00380 00385 void QwtPlot::updateLayout() 00386 { 00387 d_layout->activate(this, contentsRect()); 00388 00389 // 00390 // resize and show the visible widgets 00391 // 00392 if (!d_lblTitle->text().isEmpty()) 00393 { 00394 d_lblTitle->setGeometry(d_layout->titleRect()); 00395 if (!d_lblTitle->isVisible()) 00396 d_lblTitle->show(); 00397 } 00398 else 00399 d_lblTitle->hide(); 00400 00401 for (int axis = 0; axis < axisCnt; axis++ ) 00402 { 00403 if (d_axisEnabled[axis]) 00404 { 00405 d_scale[axis]->setGeometry(d_layout->scaleRect(axis)); 00406 00407 if ( axis == xBottom || axis == xTop ) 00408 { 00409 QRegion r(d_layout->scaleRect(axis)); 00410 if ( d_axisEnabled[yLeft] ) 00411 r = r.subtract(QRegion(d_layout->scaleRect(yLeft))); 00412 if ( d_axisEnabled[yRight] ) 00413 r = r.subtract(QRegion(d_layout->scaleRect(yRight))); 00414 r.translate(-d_layout->scaleRect(axis).x(), 00415 -d_layout->scaleRect(axis).y()); 00416 00417 d_scale[axis]->setMask(r); 00418 } 00419 if (!d_scale[axis]->isVisible()) 00420 d_scale[axis]->show(); 00421 } 00422 else 00423 d_scale[axis]->hide(); 00424 } 00425 00426 if (d_legend->itemCount() > 0) 00427 { 00428 d_legend->setGeometry(d_layout->legendRect()); 00429 d_legend->show(); 00430 } 00431 else 00432 d_legend->hide(); 00433 00434 d_canvas->setGeometry(d_layout->canvasRect()); 00435 } 00436 00438 void QwtPlot::updateAxes() 00439 { 00440 int i; 00441 bool resetDone[axisCnt]; 00442 for (i = 0; i < axisCnt; i++) 00443 resetDone[i] = FALSE; 00444 00445 // 00446 // Adjust autoscalers 00447 // 00448 00449 QwtPlotCurveIterator itc = curveIterator(); 00450 for (const QwtPlotCurve *c = itc.toFirst(); c != 0; c = ++itc ) 00451 { 00452 const int xAxis = c->xAxis(); 00453 const int yAxis = c->yAxis(); 00454 00455 if ( d_as[xAxis].autoScale() || d_as[yAxis].autoScale() ) 00456 { 00457 const QwtDoubleRect rect = c->boundingRect(); 00458 if ( rect.isValid() ) 00459 { 00460 if ( d_as[xAxis].autoScale() ) 00461 { 00462 if ( !resetDone[xAxis] ) 00463 { 00464 d_as[xAxis].reset(); 00465 resetDone[xAxis] = TRUE; 00466 } 00467 d_as[xAxis].adjust(rect.x1(), rect.x2()); 00468 } 00469 00470 if ( d_as[yAxis].autoScale() ) 00471 { 00472 if ( !resetDone[yAxis] ) 00473 { 00474 d_as[yAxis].reset(); 00475 resetDone[yAxis] = TRUE; 00476 } 00477 d_as[yAxis].adjust(rect.y1(), rect.y2()); 00478 } 00479 } 00480 } 00481 } 00482 00483 // 00484 // Adjust scales 00485 // 00486 for (i = 0; i < axisCnt; i++) 00487 { 00488 d_scale[i]->setScaleDiv(d_as[i].scaleDiv()); 00489 00490 int startDist, endDist; 00491 d_scale[i]->minBorderDist(startDist, endDist); 00492 d_scale[i]->setBorderDist(startDist, endDist); 00493 } 00494 00495 d_grid->setXDiv(d_as[d_grid->xAxis()].scaleDiv()); 00496 d_grid->setYDiv(d_as[d_grid->yAxis()].scaleDiv()); 00497 } 00498 00500 00501 void QwtPlot::updateTabOrder() 00502 { 00503 // Depending on the position of the legend the 00504 // tab order will be changed that the canvas is 00505 // next to the last legend item, or directly before 00506 // the first one. The following code seems much too 00507 // complicated but is there a better implementation ? 00508 00509 if ( d_canvas->focusPolicy() == QWidget::NoFocus || focusData() == NULL ) 00510 return; 00511 00512 // move the cursor to the canvas 00513 00514 for ( int i = 0; i < focusData()->count(); i++ ) 00515 { 00516 if ( focusData()->next() == d_canvas ) 00517 break; 00518 } 00519 00520 const bool canvasFirst = d_layout->legendPosition() == QwtPlot::Bottom || 00521 d_layout->legendPosition() == QwtPlot::Right; 00522 00523 for ( int j = 0; j < focusData()->count(); j++ ) 00524 { 00525 QWidget *w = canvasFirst ? focusData()->next() : focusData()->prev(); 00526 00527 if ( w->focusPolicy() != QWidget::NoFocus 00528 && w->parent() && w->parent() == d_legend->contentsWidget() ) 00529 { 00530 if ( canvasFirst ) 00531 { 00532 do // go back to last non legend item 00533 { 00534 w = focusData()->prev(); // before the first legend item 00535 } while ( w->focusPolicy() == QWidget::NoFocus ); 00536 } 00537 00538 if ( w != d_canvas ) 00539 setTabOrder(w, d_canvas); 00540 break; 00541 } 00542 } 00543 } 00544 00546 // \sa QFrame::drawContents 00547 00548 void QwtPlot::drawContents( QPainter * ) 00549 { 00550 // We must erase the region that is not 00551 // occupied by our children 00552 QRegion cr( contentsRect() ); 00553 cr = cr.subtract( childrenRegion() ); 00554 erase( cr ); 00555 } 00556 00567 void QwtPlot::drawCanvas(QPainter *painter) 00568 { 00569 QwtArray<QwtDiMap> map(axisCnt); 00570 for ( int axis = 0; axis < axisCnt; axis++ ) 00571 map[axis] = canvasMap(axis); 00572 00573 drawCanvasItems(painter, 00574 d_canvas->contentsRect(), map, QwtPlotPrintFilter()); 00575 } 00576 00585 void QwtPlot::drawCanvasItems(QPainter *painter, const QRect &rect, 00586 const QwtArray<QwtDiMap> &map, const QwtPlotPrintFilter &pfilter) const 00587 { 00588 // 00589 // draw grid 00590 // 00591 if ( pfilter.options() & QwtPlotPrintFilter::PrintGrid ) 00592 { 00593 if ( d_grid->enabled() ) 00594 { 00595 d_grid->draw(painter, rect, 00596 map[d_grid->xAxis()], map[d_grid->yAxis()]); 00597 } 00598 } 00599 00600 // 00601 // draw curves 00602 // 00603 QwtPlotCurveIterator itc = curveIterator(); 00604 for (QwtPlotCurve *curve = itc.toFirst(); curve != 0; curve = ++itc ) 00605 { 00606 if ( curve->enabled() ) 00607 { 00608 curve->draw(painter, 00609 map[curve->xAxis()], map[curve->yAxis()]); 00610 } 00611 } 00612 00613 // 00614 // draw markers 00615 // 00616 QwtPlotMarkerIterator itm = markerIterator(); 00617 for (QwtPlotMarker *marker = itm.toFirst(); marker != 0; marker = ++itm ) 00618 { 00619 if ( marker->enabled() ) 00620 { 00621 marker->draw(painter, 00622 map[marker->xAxis()].transform(marker->xValue()), 00623 map[marker->yAxis()].transform(marker->yValue()), 00624 rect); 00625 } 00626 } 00627 } 00628 00641 void QwtPlot::drawCurve(long key, int from, int to) 00642 { 00643 QwtPlotCurve *curve = d_curves->find(key); 00644 if ( !curve ) 00645 return; 00646 00647 QPainter p(canvas()); 00648 00649 p.setClipping(TRUE); 00650 p.setClipRect(canvas()->contentsRect()); 00651 00652 curve->draw(&p, 00653 canvasMap(curve->xAxis()), canvasMap(curve->yAxis()), 00654 from, to); 00655 00656 if ( canvas()->cacheMode() && canvas()->cache()) 00657 { 00658 QPainter cachePainter(canvas()->cache()); 00659 cachePainter.translate(-canvas()->contentsRect().x(), 00660 -canvas()->contentsRect().y()); 00661 00662 curve->draw(&cachePainter, 00663 canvasMap(curve->xAxis()), canvasMap(curve->yAxis()), 00664 from, to); 00665 } 00666 } 00667 00675 QwtDiMap QwtPlot::canvasMap(int axis) const 00676 { 00677 QwtDiMap map; 00678 if ( !d_canvas ) 00679 return map; 00680 00681 const QwtScaleDiv &sd = d_as[axis].scaleDiv(); 00682 map.setDblRange(sd.lBound(), sd.hBound(), sd.logScale()); 00683 00684 if ( axisEnabled(axis) ) 00685 { 00686 const QwtScale *s = d_scale[axis]; 00687 if ( axis == yLeft || axis == yRight ) 00688 { 00689 int y = s->y() + s->startBorderDist() - d_canvas->y(); 00690 int h = s->height() - s->startBorderDist() - s->endBorderDist(); 00691 map.setIntRange(y + h - 1, y); 00692 } 00693 else 00694 { 00695 int x = s->x() + s->startBorderDist() - d_canvas->x(); 00696 int w = s->width() - s->startBorderDist() - s->endBorderDist(); 00697 map.setIntRange(x, x + w - 1); 00698 } 00699 } 00700 else 00701 { 00702 const int margin = plotLayout()->canvasMargin(axis); 00703 00704 const QRect &canvasRect = d_canvas->contentsRect(); 00705 if ( axis == yLeft || axis == yRight ) 00706 { 00707 map.setIntRange(canvasRect.bottom() - margin, 00708 canvasRect.top() + margin); 00709 } 00710 else 00711 { 00712 map.setIntRange(canvasRect.left() + margin, 00713 canvasRect.right() - margin); 00714 } 00715 } 00716 return map; 00717 } 00718 00726 void QwtPlot::setMargin(int margin) 00727 { 00728 if ( margin < 0 ) 00729 margin = 0; 00730 00731 if ( margin != d_layout->margin() ) 00732 { 00733 d_layout->setMargin(margin); 00734 updateLayout(); 00735 } 00736 } 00737 00742 int QwtPlot::margin() const 00743 { 00744 return d_layout->margin(); 00745 } 00746 00755 void QwtPlot::setCanvasBackground(const QColor &c) 00756 { 00757 QPalette p = d_canvas->palette(); 00758 00759 for ( int i = 0; i < QPalette::NColorGroups; i++ ) 00760 p.setColor((QPalette::ColorGroup)i, QColorGroup::Background, c); 00761 00762 canvas()->setPalette(p); 00763 } 00764 00771 const QColor & QwtPlot::canvasBackground() const 00772 { 00773 return canvas()->palette().color( 00774 QPalette::Normal, QColorGroup::Background); 00775 } 00776 00783 void QwtPlot::setCanvasLineWidth(int w) 00784 { 00785 canvas()->setLineWidth(w); 00786 } 00787 00793 int QwtPlot::canvasLineWidth() const 00794 { 00795 return canvas()->lineWidth(); 00796 } 00797 00798 #ifndef QWT_NO_COMPAT 00799 00814 void QwtPlot::enableOutline(bool tf) 00815 { 00816 d_canvas->enableOutline(tf); 00817 } 00818 00852 void QwtPlot::setOutlineStyle(Qwt::Shape os) 00853 { 00854 d_canvas->setOutlineStyle(os); 00855 } 00856 00865 void QwtPlot::setOutlinePen(const QPen &pn) 00866 { 00867 d_canvas->setOutlinePen(pn); 00868 } 00869 00876 bool QwtPlot::outlineEnabled() const 00877 { 00878 return d_canvas->outlineEnabled(); 00879 } 00880 00887 const QPen & QwtPlot::outlinePen() const 00888 { 00889 return d_canvas->outlinePen(); 00890 } 00891 00900 Qwt::Shape QwtPlot::outlineStyle() const 00901 { 00902 return d_canvas->outlineStyle(); 00903 } 00904 00905 #endif // ! QWT_NO_COMPAT 00906 00911 bool QwtPlot::axisValid(int axis) 00912 { 00913 return ((axis >= QwtPlot::yLeft) && (axis < QwtPlot::axisCnt)); 00914 } 00915 00921 void QwtPlot::lgdClicked() 00922 { 00923 if ( sender()->isWidgetType() ) 00924 { 00925 long key = d_legend->key((QWidget *)sender()); 00926 if ( key >= 0 ) 00927 emit legendClicked(key); 00928 } 00929 } 00930 00932 void QwtPlot::clear() 00933 { 00934 d_legend->clear(); 00935 d_curves->clear(); 00936 d_markers->clear(); 00937 } 00938 00939 00941 void QwtPlot::removeCurves() 00942 { 00943 d_curves->clear(); 00944 d_legend->clear(); 00945 autoRefresh(); 00946 } 00947 00949 void QwtPlot::removeMarkers() 00950 { 00951 d_markers->clear(); 00952 autoRefresh(); 00953 } 00954 00965 void QwtPlot::setAutoLegend(bool tf) 00966 { 00967 d_autoLegend = tf; 00968 } 00969 00973 bool QwtPlot::autoLegend() const 00974 { 00975 return d_autoLegend; 00976 } 00977 00978 00988 void QwtPlot::enableLegend(bool enable, long curveKey) 00989 { 00990 bool isUpdateEnabled = d_legend->isUpdatesEnabled(); 00991 d_legend->setUpdatesEnabled(FALSE); 00992 00993 if ( curveKey < 0 ) // legends for all curves 00994 { 00995 if ( enable ) 00996 { 00997 if ( d_legend->itemCount() < d_curves->count() ) 00998 { 00999 // not all curves have a legend 01000 01001 d_legend->clear(); 01002 01003 QwtPlotCurveIterator itc = curveIterator(); 01004 for ( const QwtPlotCurve *curve = itc.toFirst(); 01005 curve != 0; curve = ++itc ) 01006 { 01007 insertLegendItem(itc.currentKey()); 01008 } 01009 } 01010 } 01011 else 01012 { 01013 d_legend->clear(); 01014 } 01015 } 01016 else 01017 { 01018 QWidget *legendItem = d_legend->findItem(curveKey); 01019 if ( enable ) 01020 { 01021 if ( d_curves->find(curveKey) && !legendItem ) 01022 insertLegendItem(curveKey); 01023 } 01024 else 01025 delete legendItem; 01026 } 01027 01028 d_legend->setUpdatesEnabled(isUpdateEnabled); 01029 updateLayout(); 01030 } 01031 01037 bool QwtPlot::legendEnabled(long curveKey) const 01038 { 01039 return d_legend->findItem(curveKey) != 0; 01040 } 01041 01060 void QwtPlot::setLegendPosition(QwtPlot::Position pos, double ratio) 01061 { 01062 if (pos != d_layout->legendPosition()) 01063 { 01064 d_layout->setLegendPosition(pos, ratio); 01065 01066 QLayout *l = d_legend->contentsWidget()->layout(); 01067 if ( l && l->inherits("QwtDynGridLayout") ) 01068 { 01069 QwtDynGridLayout *tl = (QwtDynGridLayout *)l; 01070 if ( d_layout->legendPosition() == QwtPlot::Top || 01071 d_layout->legendPosition() == QwtPlot::Bottom ) 01072 { 01073 tl->setMaxCols(0); // unlimited 01074 } 01075 else 01076 tl->setMaxCols(1); // 1 column: align vertical 01077 } 01078 01079 updateLayout(); 01080 updateTabOrder(); 01081 } 01082 } 01083 01096 void QwtPlot::setLegendPosition(QwtPlot::Position pos) 01097 { 01098 setLegendPosition(pos, 0.0); 01099 } 01100 01105 QwtPlot::Position QwtPlot::legendPosition() const 01106 { 01107 return d_layout->legendPosition(); 01108 } 01109 01110 #ifndef QWT_NO_COMPAT 01111 01131 void QwtPlot::setLegendPos(int pos, double ratio) 01132 { 01133 setLegendPosition(QwtPlot::Position(pos), ratio); 01134 } 01135 01141 int QwtPlot::legendPos() const 01142 { 01143 return d_layout->legendPosition(); 01144 } 01145 01146 #endif // !QWT_NO_COMPAT 01147 01152 void QwtPlot::setLegendFont(const QFont &f) 01153 { 01154 d_legend->setFont(f); 01155 if (d_legend->isVisible()) 01156 updateLayout(); 01157 } 01158 01163 void QwtPlot::setLegendFrameStyle(int st) 01164 { 01165 d_legend->setFrameStyle(st); 01166 updateLayout(); 01167 } 01168 01172 int QwtPlot::legendFrameStyle() const 01173 { 01174 return d_legend->frameStyle(); 01175 } 01176 01180 const QFont QwtPlot::legendFont() const 01181 { 01182 return d_legend->font(); 01183 } 01184 01191 void QwtPlot::setLegendDisplayPolicy( 01192 QwtLegend::LegendDisplayPolicy policy, int mode) 01193 { 01194 d_legend->setDisplayPolicy(policy, mode); 01195 01196 for (QwtPlotCurveIterator iter=curveIterator(); iter.current(); ++iter) 01197 updateLegendItem(iter.currentKey()); 01198 } 01199 01200 // Local Variables: 01201 // mode: C++ 01202 // c-file-style: "stroustrup" 01203 // indent-tabs-mode: nil 01204 // End:

Generated on Tue Nov 16 21:12:20 2004 for Qwt User's Guide by doxygen 1.3.8