diff --git a/qwt/.gitignore b/qwt/.gitignore deleted file mode 100644 index 78ccff244..000000000 --- a/qwt/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -lib -qwtconfig.pri -*.so -moc*.cpp -*.obj -*.o diff --git a/qwt/CHANGES b/qwt/CHANGES deleted file mode 100644 index 1538f1500..000000000 --- a/qwt/CHANGES +++ /dev/null @@ -1,510 +0,0 @@ -Release 6.0.1 -=================== - -Changes -------- -1) Incompatibilities with Qt < 4.6.1 fixed -2) Reduce warnings with pedantic compiler options -3) Examples fixed -4) Legend identifiers of with symbol and line fixed - -Release 6.0.0 -=================== - -Changes -------- -1) Qt3 support dropped -2) QwtPlot layout/render code ported from int to double - Exported/printed documents in scalable formats like SVG or PDF - are 100% scalable now. -3) Template base classes introduced for curve and curve data - to be reusable in all plot items displaying series of samples. -4) New plot items - - QwtPlotHistogram - - QwtPlotIntervalCurve ( error bars or displaying the area between 2 curves ) - - QwtPlotSpectroCurve ( mapping the z value to a color ) -5) Raster items - - QwtMatrixRasterData introduced - - More accurate rendering - - Several API changes - - Thread support for rendering spectrograms -6) QwtPlot::print moved to QwtPlotRenderer -7) Other new classes - QwtColumnSymbol - QwtDoublePoint3D - QwtIntervalSymbol - QwtPlotDirectPainter - QwtSamplingThread - QwtSystemClock -8) QwtPicker and friends reorganized, - QwtPickerTrackerMachine added for displaying a rubberband for - mouse moves. Enter/Leave added to events, that are handled - by the picker machines. -9) QwtScaleWidget::LayoutFlag added - Introduced to control the direction of vertical axis titles. -10)QwtWeedingCurveFitter added - QwtWeedingCurveFitter is an implementation of the Douglas/Peuker - algorithm, that can be used to reduce the number of curve points. - It can be very useful to improve the performance of painting - curves of many lines ( f.e. by implementing different level of details ). -11)Legend code update for representing different pixmaps for different - types of plot items. -12)Copy operators removed, using pointers instead -13)QwtPolarPoint from qwtpolar added -14)QwtThermo - Optional QwtColorMaps added -15)Interfaces and code of all sliders/dials cleaned up. - QApplication::globalStrut(), styled backgrounds ... - - -Release 5.2.2 -=================== - -Bug Fixes ---------- -1) QwtSplineCurveFitter - Rounding to integers values removed -2) QwtPlot - initial size of 200x200 -3) QwtPlotPrintFilter, QwtPlot::print - handling of background color in QwtPlot::print -4) QwtPlotPrintFilter - Problem with colored plot titles fixed -5) QwtPlotItem - Crash fixed, when changing the z order of attached items -6) QwtLinearScaleEngine, QwtLog10ScaleEngine - Several minor fixes - -Release 5.2.1 -=================== - -Bug Fixes ---------- -1) Export declarations removed from qwt_valuelist.h to avoid - compiler errors with Qt 4.6 + certain compilers on Windows. -2) QwtScaleDraw - Wrong border dist hints for unregular scale divisions fixed - Layout calculation for the tick labels fixed. - The layout was wrong by 1 pixel for top/left/bottom axes. - On a left axis without a title the labels were sometimes cut off. -3) QwtPainter - Splits polylines for all pens to avoid a bottleneck of the - raster paint engine. -4) QwtScaleWidget - Calculation of the colorbar position fixed ( spacing/margin ) -5) QwtPlotCurve - Wrong clipping rect fixed -6) QwtPicker - QwtPicker::setTrackerFont() fixed. - Recursion on the Mac, when constructing the rubberband fixed. - Workaround for a Qt3 bug added that is responsible for left aligning - all tracker texts to the canvas. - -Changes -------- -1) Project files adopted for symbian -2) qwt.pro - CONFIG += ordered added for using make -j - CONFIG += silent added - -Release 5.2.0 -=================== - -Changes -------- -1) Ported to Qt 4.5.x -2) Scaling of non cosmetic pens (for printing to devices in high resolution) -3) Clipping of polygons for SVG rendering -4) QwtRect removed - use QwtClipper instead -5) QwtPlotRescaler - Introduced -6) QwtDoubleInterval - BorderMode introduced -7) QwtPlotCurve - Performance of incremental curve painting ( = draw(from, to) ) improved. -8) QwtLegendItem - setIdentfierMode renamed to setIdentifierMode -9) QwtPlotCanvas::replot() introduced - code from QwtPlot::replot shifted -10)QwtPlot - drawCanvas(), updateAxes() changed from protected to public -11)QwtScaleEngine - loMargin/hiMargin renamed to lowerMargin/upperMargin -12)QwtScaleDiv - lBound/hBound renamed to lowerBound/upperBound -13)QwtSpline - cofficientA/B/C introduced -14)QwtDial - counter clockwise scales introduced -15)QwtPlotMarker - Vertical text labels -16)doc/qwt-5.2.0.qch added foe browsing the Qwt docs in the Qt assistant - -Bug Fixes ---------- -1) QwtLinearScaleEngine - Rounding problems fixed -2) Again some print layout problems fixed -3) QwtPlotScaleItem: 1 pixel offset fixed -4) QwtPlotSpectrogram, clipping of contour lines - against the bounding rect -5) QwtPlotZoomer::setZoomStack for stacks with unlimited depth -6) Printing of rotated tick labels - - -Release 5.1.1 -=================== - -Bug Fixes ---------- -1) Several compiler incompatibilities fixed -2) DBL_EPSILON removed - Using DBL_EPSILON in the calculations of the dials/sliders and the - scale engines leads to problems with the inaccuracy of floating points. - The behaviour has been reverted to 5.0.x. -3) QwtSlider/QwtKnob - setScaleDraw() fixed. -4) QwtRect - Pointless private declaration removed - -Release 5.1.0 -=================== - -Changes -------- -1) QwtSymbol::copy introduced - Now it is possible to use derived symbol classes for curves -2) QwtPlotScaleItem introduced - A new type of plot item for displaying axes on the canvas -3) QwtClipper added - A collection of clipping algos -4) Using DBL_EPSILON - This change allows smaller intervals for sliders/dials -5) QwtPanner - setOrientation() added. -6) QwtPlot - axisStepSize() added - clear is virtual now -7) QwtPlotPrintFilter - PrintCanvasBackground splitted into PrintBackground, PrintFrameWithScales -8) QwtPlotZoomer - setZoomStack() added -9) Changes for the QwtPolar package - QwtLegendItemManager introduced - QwtMagnifier introduced -10)Suffix rules added in qwtconfig.pri for different targets for - debug/release builds. - -Bug Fixes ---------- -1. QwtAbstractScaleDraw::setAbstractScaleDraw - Reinitialization problem fixed -2. QwtLegendItem - key event handlers fixed -3. QwtPicker - solaris-cc compiler problem fixed -4. Inaccurate mapping of scale to widget coordinates fixed -5. QwtPlotCurve::draw - Updates for Qt 4.3 added -6. QwtPlotLayout - AlignToCanvas layout calculation fixed -7. QwtPlot::print - Workaround for a QPen initialization problem, - when printing to Pdf, added -8. QwtText - Layout of rich text documents fixed -9. Designer - Handling of QwtScaleWidget fixed -10. realtime example - Qt::WA_PaintOutsidePaintEvent added, ScrollZoomer fixed -11. Several others I have forgotten - -Release 5.0.2 -=================== - -Bug Fixes ---------- -1. QwtPlotCurve::Xfy curve type fixed -2. Memory leak in QwtLegend fixed -3. Vertical alignment of rich texts fixed -4. Workaround for a Qt4 bug added, that produces horrible performance - when painting curves with a pen width > 1. -5. Background for the tracker text of QwtPickers fixed. - Improved (faster + better rendered texts) implementation of - painting tracker texts, using capabilities of Qt >= 4.3. -6. QwtArrowButton/QwtCounter: workaround for layout bug ( Qt < 4.3 ) - of the Cleanlook style added. -7. A couple of minor fixes - -Changes -------- -1. QSvgGenerator added to the bode example - -Release 5.0.1 -=================== - -Changes -------- -1. A couple of problems, when building Qwt fixed. -2. Displaying Rich Text with Qt 4.x fixed - -Release 5.0.0 -=================== - -Platforms ---------- -Support of Qt3 and Qt4. Qt2 is not supported any longer. - -Key features ------------- -1. Redesign of plot items. Makes it much easier to develop - individual items. -2. Redesign of the scale classes. All calculations are - collected in scale engines, where the application can - implement it´s own (f.e log2, or date scales). Now it´s - also possible to have individual and completely irregular scales -3. Redesign of the QwtText classes. The MathML renderer of - the Qt4 solutions package is embedded. - work for all expressions/situations. -4. New classes for navigating: QwtPanner, QwtMaginfier -5. Spectrogram/Contour plots and other classes for displaying - raster data added. - -Changes -------- -5.0.0 is by far the release with the most changes in the history of Qwt -- too many to make list. - - -Release 4.2.0/0.4.2 -=================== - -License --------- -A couple of exceptions to the LGPL with the intention to allow static -linking with commercial applications. See COPYING. - -Key features: -------------- -1. Designer plugin -2. Rich Text support ( f.e. E = m * c2 ) added. -3. QwtDial class family added (QwtDial, QwtCompass, QwtAnalogClock, ...) -4. QwtPicker class family added. Includes QwtPlotZoomer, a complete - implementation of recursive zooming. -5. Device metrics independent printing of QwtPlot. (QPrinter::HighResolution) -6. QwtPlot::setCurveBrush(), QwtCurve::setBrush() added. The area - between curve and baseline will be filled with this brush. -7. Rotation of axis tick labels added. Very useful for axis with long - labels like time scales ... -8. Added a new abstract QwtData class to plot data from almost any type of - container class. -9. QwtDoublePoint, QwtDoubleSize, QwtDoubleRect double counterparts - for QPoint, QSize, QRect. -10. First steps to support Qtopia. All examples can be compiled and started - in the qvfb emulator. - - -Changes: ---------- -1. Rewrite of QwtLegend/QwtLegendItem (no QTable anymore) -2. Each plot item will be painted, even if one of the axis it is - attached to is disabled. (like in all other releases beside 0.4.1) -3. Code for double buffering moved to a new class QwtPaintBuffer. - Double buffering can be enabled/disabled now. -4. QwtPainter, QwtMetricsMap, QwtLayoutMetrics added - Hide paint device metrics dependencies. -5. Layout code rewritten and moved to a new class QwtPlotLayout - New layout options canvasMargin(), alignCanvasToScales() -6. QwtPlot: sizeHint() != minimumSizeHint() -9. Internal plot data are private again. A couple of get methods - added instead. -10. canvas repaints triggered by paint events. Enables event filtering -11. QwtPlot::drawCanvasItems added. In opposite to QwtPlot::drawCanvas - it is used by the printing code too. -12. qwtMax, qwtMin, qwtInt mapped to QMAX, QMIN, qRound from qglobal.h -13. operator= for plot item classes changed. -14. readOnly property added for sliders. -15. valid flag added for QwtDblRange -16. QwtCounter wrap around policy: a counter under- or overflow sets - focus to the smallest up/down button and disables counting. - A space bar keypress release event re-enables counting. -17. QwtPushButton added. A class that adds rich text and alignments - features to QPushButton, like they are used in QLabel -18. Clipped painting code moved from QwtCurve to QwtPainter/QwtRect -19. Canvas cache added to optimize trivial repaints. -20. QwtPlot::drawCurve added for incremental curve data -21. QwtSliderBase, readOnly, isValid added -22. Added filtering of the colors of the title and scales to QwtPrintFilter. -23. Support of QT_NO_CAST_ASII and QT_NO_COMPAT added -24. Batch file added for generating Visual Studio project files -25. QwtPlotCurve, QwtPlotMarker, QwtPlotGrid: more methods public -26. QwtPlot::setLegendPosition added -27. A lot of changes I don't remember, ... sorry. - -Bugfixes: ---------- -1. Autodetection of painter redirection. QPixmap::grabWidget() works - with Qwt Widgets again. -2. QwtSlider: Rounding double->int conversions instead of simple casts. -3. Bad additional line, connected to the first curve point, when zooming - deep, fixed. -4. QwtMarker: Painting of symbols with width != height fixed -5. QwtPlot::plotMouseXXX/canvasMap pixel coordinates synced. - Now both include the canvas frame. -6. Layout fixed for QwtScaleDraws without tick labels -8. Tab focus chains fixed, focus indications added. -9. Support QwtAutoScale::Inverted when autoScale is off also. -10. Keyboard control, focus indications added. -11. Improved QStyle awareness. -12. Printing of plots with disabled axes - -Examples --------- -1. New example linux/cpustat added. Runs also on non linux boxes - with dummy values. Beside showing a couple of features that - are new with 0.4.1 and 0.4.2, it shows how to extend and customize - a QwtPlots. -2. Added new example event_filter to demonstrate event filtering. - This example shows how to add additional controls to the scales, - how to translate mouse clicks on the scales into signals and - how to move points on the canvas. -3. realtime example shows how to use scrollbars when zooming - -Release 0.4.1 -============ - -Changes: ---------- -1. Platform independent project files. makefiles directory removed. -2. RPM spec file template added. -3. __declspec formalism added for Win32 DLLs. Requires - 'DEFINES += QWT_DLL' in the .pro file. -4. QString used for visible texts. -5. Code for error curves removed. These type of features should be - implemented in derived curve classes. -6. A lot of Qt 1.2 related code removed/replaced. -7. QwtColorFilter, QwtPixFrame removed. QwtPlotPixFrame renamed - to QwtPlotCanvas. -8. qmodules.h aware. Skips QwtLegend in case of !QT_MODULE_TABLE -9. All Widgets including QwtPlot optimized to reduce flicker - during resize/repaint. -10. QwtPlot curves/markers can be disabled/enabled to hide/show individual - curves without removing the curves from the plot. -11. Internal maps removed from QwtCurve. QwtCurve::setMap, QwtCurve::setRect, - QwtCurve::setRange removed. - -Feature additions: ------------------- -1. Printing - QwtPlot::print prints to any type of QPaintDevice now. - Hardcoded printer attributes margin, creator and document title have - been removed and must/can be set by the applications now. - Printing of background and legends added. QwtColorFilter replaced - by QwtPlotPrintFilter. -2. Layout - Many layout fixes and additions. Now all Widgets behave well in - QLayouts and provide sensible sizeHints. QwtPlot::setMargin(int) added. - Fieldwidth added for QwtPlot::setAxisFormat for application that need - range independent width. Title and axis title are Qt:Alignment aware. - Qt::WordBreak or multiline titles are possible. -3. Legend - En/Disabling of single curves in the legend added. - QwtPlot::setAutoLegend added. -4. Extensibility - QwtPlot::insertCurve + QwtPlot::insertMarker added. Now derived - classes of QwtPlotCurve and QwtPlotMarker can be added. Virtual - methods provided by QwtPlotCurve for sub-classing. - QwtScale::setScaleDraw + QwtPlot::setAxisScaleDraw + some virtual - methods for QwtScaleDraw added. Application can implement individual - axis labels now. -5. Sliders - QWheelEvent added. The MouseWheel stepsize is controlled by the - Scroll Page Size. QwtWheel::setWheelWidth added. QwtKnob::setSymbol, - QwtKnob::symbol added. - -Bugfixes: ---------- -1. Workaround for spontanous curves resulting from overruns - when zooming too deep. -2. Wrong QColorGroup::ColorRole for background colors fixed. - Necessary for several non default QStyles. -3. QwtWheel fixed for vertical wheels. Better color support. -4. QwtSlider fixed. -5. Many forgotten others - -Release 0.4.0 -============ - -Bugfixes: ---------- -1. A few occurences of the boolean literal \c false were changed into macro - \c FALSE for cross compiler compatibility. -2. A few local variables in member functions were renamed to suppress - warnings issued by really picky compilers about global/class variables - being hidden. -3. In qwt_legend.h, a fully qualified name was used in a class declaration. - The HPUX compiler chokes on this (and it's ugly), so it was fixed. -4. Macro M_2PI is now only defined is this hasn't already been done by the - system's clib. - -Feature additions: ------------------- -1. Qwt now works with Qt3.0. In order to achieve this, QwtLegend now no - longer derives from QTableView, but from QTable. This seems to have had - quite a few consequences. Kudo's to Uwe Rathmann for uploading this nice - fix to the CVS tree. -2. Getters for a plot's title and title font have been added. - -Release 0.3.0 -============ - -License: --------- -1. The license has changed from GPL to LGPL. - -Bugfixes: ---------- -1. The makefiles for win32 caused object files to have extension .o instead of - .obj. The 'propagate' file was changed to fix this, using tmake's target - platform flag. -2. There were problems with rint() on win32 platforms. rint() is a BSD call, - not even available on all unices. All calls to rint(x) have been replaced - by floor(x+.5). -3. Some static class data members were initialized with the value of other - static class data members (from Qt). This caused programs depend on the - initialization order of class members. This is now fixed by replacing the - static properties by static signleton factories. -4. When a plot was zoomed and then printed, curves and markers laying outside - the plot's scale were still printed. The print() function now uses clipping. - -Feature additions: ------------------- -1. Multi-line plot titles are now supported: the PostScript document name is - not the plot title, with "\n" characters replaced by "--". Geometry - management has been changed to support multi-line titles. -2. In the mailinglist, there were often feature requests for features that - were in fact implemented, but not available through QwtPlot's API. Many - private members have been made protected or even public, to give users - more control. This is poor design, but Qwt will be refactored anyway. -3. Qwt always displayed floats with 5 digits. This was insufficient for many - applications. QwtPlot, QwtScale, QwtAutoScale got some methods to set the - label format. This is a printf like format for the numbers at the scales, - consisting of 'f' and a precision, or 'g' and the significance. - -Build system: -------------- -1. The 'makefiles' directory was removed from the cvs tree, and is now only - generated for releases. CVS users should have tmake installed, to generate - the makefiles themselves. -2. The 'examples' directory now uses tmake's 'subdirs' template, to iterate - over all subdirectories and build all examples with one command. There was - allready a makefile for this, but now the process is automated by tmake. -3. Under unix, the library now gets a proper version number. Current version - is 0.3.0. - -Documentation: --------------- -1. All documentation is converted to the Doxygen documentation system. The - release contains two settings files, 'Doxygen' and 'Doxygen.users', - generating a developer's and user's manual, respectively. diff --git a/qwt/COPYING b/qwt/COPYING deleted file mode 100644 index 9c01f7e21..000000000 --- a/qwt/COPYING +++ /dev/null @@ -1,543 +0,0 @@ - Qwt License - Version 1.0, January 1, 2003 - -The Qwt library and included programs are provided under the terms -of the GNU LESSER GENERAL PUBLIC LICENSE (LGPL) with the following -exceptions: - - 1. Widgets that are subclassed from Qwt widgets do not - constitute a derivative work. - - 2. Static linking of applications and widgets to the - Qwt library does not constitute a derivative work - and does not require the author to provide source - code for the application or widget, use the shared - Qwt libraries, or link their applications or - widgets against a user-supplied version of Qwt. - - If you link the application or widget to a modified - version of Qwt, then the changes to Qwt must be - provided under the terms of the LGPL in sections - 1, 2, and 4. - - 3. You do not have to provide a copy of the Qwt license - with programs that are linked to the Qwt library, nor - do you have to identify the Qwt license in your - program or documentation as required by section 6 - of the LGPL. - - - However, programs must still identify their use of Qwt. - The following example statement can be included in user - documentation to satisfy this requirement: - - [program/widget] is based in part on the work of - the Qwt project (http://qwt.sf.net). - ----------------------------------------------------------------------- - - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/qwt/INSTALL b/qwt/INSTALL deleted file mode 100644 index f180ef02c..000000000 --- a/qwt/INSTALL +++ /dev/null @@ -1,164 +0,0 @@ -Introduction -============ - -Qwt uses qmake to build all its components and examples. -qmake is part of a Qt distribution. - -qmake reads project files, that contain the options and rules how to -build a certain project. A project file ends with the suffix "*.pro". -Files that end with the suffix "*.pri" are included by the project -files and contain definitions, that are common for several project files. - -qwtconfig.pri and qwtbuild.pri are read by all project files of the Qwt -package. qwtconfig.pri is also read by qwt.prf, when building your -application. So the first step is to edit the *.pri files to adjust -them to your needs. - -The subdirs template of qmake is known to be buggy when using spaces -in path names. So better don't build Qwt below a path name with spaces. -( Otherwise you might have to run qmake in all subdirs manually ). - -Documentation -========================== - -Qwt includes a class documentation, that is available in various formats: - -- Html files -- PDF document -- Qt Compressed Help (*.qch ) for the Qt assistant or creator. - You can load it "Edit Preferences" -> "Documentation" -> "Add..." -- Man pages ( UNIX only ) - -Building Qwt -========================== - -The easiest way to build Qwt is from the command line - but you insist on -using an IDE don't forget the "make install" step. - -A) Unix --------- - -qmake -make -make install - -If you have installed a shared library it's path has to be known to -the run-time linker of your operating system. On Linux systems read -"man ldconfig" ( or google for it ). Another option is to use -the LD_LIBRARY_PATH (on some systems LIBPATH is used instead, on MacOSX -it is called DYLD_LIBRARY_PATH) environment variable. - -If you only want to check the Qwt examples without installing something, -you can set the LD_LIBRARY_PATH to the lib directory -of your local build. - -If you didn't enable autobuilding of the examples in qwtconfig.pri -you have to build the examples this way: - -cd examples -qmake -make - - -B) Win32/MSVC --------- - -Check that your Qt version has been built with MSVC - not with MinGW ! - -Please read the qmake documentation how to convert -your *.pro files into your development environment. - -F.e MSVC with nmake: -qmake qwt.pro -nmake -nmake install - -If you didn't enable autobuilding of the examples in qwtconfig.pri -you have to build the examples this way: - -cd examples -qmake examples.pro -nmake - -Windows doesn't like mixing of debug and release binaries. Most -of the problems with using the Qwt designer plugin are because -of trying to load a Qwt debug library into a designer release -executable. - -It's not possible to load a plugin, that has been built with MinGW -into a Qt Designer/Creator, that has been built with MSVC ( and v.v ). -This is a common reason for problems, when working with prebuild -binaries of the Qt Creator. - -C) Win32/MinGW --------- - -Check that your Qt version has been built with MinGW - not with MSVC ! - -Start a Shell, where Qt4 is initialized. ( F.e. with -"Programs->Qt by Trolltech ...->Qt 4.x.x Command Prompt" ). -Check if you can execute "make" or something like "mingw32-make". - -qmake qwt.pro -make -make install - -If you didn't enable autobuilding of the examples in qwtconfig.pri -you have to build the examples this way: - -cd examples -qmake examples.pro -make - -Windows doesn't like mixing of debug and release binaries. Most -of the problems with using the Qwt designer plugin are because -of trying to load a Qwt debug library into a designer release -executable. - -Don't forget to tell qmake where to find qwt.prf: -qmake -set QMAKEFEATURES ... - -D) MacOSX --------- - -Well, the Mac is only another Unix system. So read the instructions in A). - -In the recent Qt4 releases the default target of qmake is to generate -XCode project files instead of makefiles. So you might need to do the -following: - -qmake -spec macx-g++ -... - -D) Qt Embedded --------- - -I only tested Qwt with Qt Embedded in qvfb (Virtual Framebuffer Devivce) -Emulator on my Linux box. To build Qwt for the emulator was as simple as -for a regular Unix build. - -F) Symbian --------- - -I never tried this platform myself. - -Using Qwt -=========== - -For building a Qwt application with qmake use the Qwt configuration features -file, that has been installed by "make install". When qmake is able to find -it ( http://doc.qt.nokia.com/4.7/qmake-advanced-usage.html#adding-new-configuration-features ) -you can simply add "CONFIG += qwt" to your application project file. - -If you don't use qmake you have to add the include path to find the Qwt -headers to your compiler flags and the Qwt library to your linker list. -Don't forget to add QWT_DLL to the compiler flags, when you work with a -Qwt-DLLs on Windows. - -For using the designer plugin you have to configure the Qt designer/creator -where to look for plugins. This can be done by setting the QT_PLUGIN_PATH or -using a qt.conf file ( see http://doc.qt.nokia.com/4.7/deployment-plugins.html ). -Beside the plugin the Qwt library itsself also needs to be known to the Designer/Creator -( see LD_LIBRARY_PATH, PATH ... above ). - -Good luck ! diff --git a/qwt/README b/qwt/README deleted file mode 100644 index e45bbb95c..000000000 --- a/qwt/README +++ /dev/null @@ -1,33 +0,0 @@ - -The Qwt Widget Library ----------------------- - - Qwt is an extension to the Qt GUI library from Troll Tech AS. - The Qwt library contains widgets and components which are - primarily useful for technical and scientifical purposes. - It includes a 2-D plotting widget, different kinds of sliders, - and much more. - - Qwt is hosted at http://qwt.sf.net - -Installation ------------- - - Read INSTALL how to build and install Qwt. - -Copyright ---------- - - Qwt Widget Library - Copyright (C) 1997 Josef Wilgen - Copyright (C) 2002 Uwe Rathmann - - Qwt is published under the Qwt License, Version 1.0. - You should have received a copy of this licence in the file - COPYING. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - diff --git a/qwt/designer/designer.pro b/qwt/designer/designer.pro deleted file mode 100644 index f1f6e4f8b..000000000 --- a/qwt/designer/designer.pro +++ /dev/null @@ -1,72 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -QWT_ROOT = $${PWD}/.. - -include ( $${QWT_ROOT}/qwtconfig.pri ) -include ( $${QWT_ROOT}/qwtbuild.pri ) - -contains(QWT_CONFIG, QwtDesigner) { - - CONFIG += qt designer plugin - CONFIG += warn_on - - TEMPLATE = lib - TARGET = qwt_designer_plugin - - DESTDIR = plugins/designer - - INCLUDEPATH += $${QWT_ROOT}/src - DEPENDPATH += $${QWT_ROOT}/src - - contains(QWT_CONFIG, QwtFramework) { - - LIBS += -F$${QWT_ROOT}/lib - } - else { - - LIBS += -L$${QWT_ROOT}/lib - } - - IPATH = $${INCLUDEPATH} - qtAddLibrary(qwt) - INCLUDEPATH = $${IPATH} - - contains(QWT_CONFIG, QwtDll) { - - win32 { - DEFINES += QT_DLL QWT_DLL - } - } - - !contains(QWT_CONFIG, QwtPlot) { - DEFINES += NO_QWT_PLOT - } - - !contains(QWT_CONFIG, QwtWidgets) { - DEFINES += NO_QWT_WIDGETS - } - - HEADERS += qwt_designer_plugin.h - SOURCES += qwt_designer_plugin.cpp - - contains(QWT_CONFIG, QwtPlot) { - - HEADERS += qwt_designer_plotdialog.h - SOURCES += qwt_designer_plotdialog.cpp - } - - RESOURCES += qwt_designer_plugin.qrc - - target.path = $${QWT_INSTALL_PLUGINS} - INSTALLS += target -} -else { - TEMPLATE = subdirs # do nothing -} diff --git a/qwt/designer/pixmaps/qwtanalogclock.png b/qwt/designer/pixmaps/qwtanalogclock.png deleted file mode 100644 index 89f3451ac..000000000 Binary files a/qwt/designer/pixmaps/qwtanalogclock.png and /dev/null differ diff --git a/qwt/designer/pixmaps/qwtcompass.png b/qwt/designer/pixmaps/qwtcompass.png deleted file mode 100644 index e1e54a11d..000000000 Binary files a/qwt/designer/pixmaps/qwtcompass.png and /dev/null differ diff --git a/qwt/designer/pixmaps/qwtcounter.png b/qwt/designer/pixmaps/qwtcounter.png deleted file mode 100644 index 1daddb63f..000000000 Binary files a/qwt/designer/pixmaps/qwtcounter.png and /dev/null differ diff --git a/qwt/designer/pixmaps/qwtdial.png b/qwt/designer/pixmaps/qwtdial.png deleted file mode 100644 index 46f079c71..000000000 Binary files a/qwt/designer/pixmaps/qwtdial.png and /dev/null differ diff --git a/qwt/designer/pixmaps/qwtknob.png b/qwt/designer/pixmaps/qwtknob.png deleted file mode 100644 index 2118dfa36..000000000 Binary files a/qwt/designer/pixmaps/qwtknob.png and /dev/null differ diff --git a/qwt/designer/pixmaps/qwtplot.png b/qwt/designer/pixmaps/qwtplot.png deleted file mode 100644 index 8e1ca4ed5..000000000 Binary files a/qwt/designer/pixmaps/qwtplot.png and /dev/null differ diff --git a/qwt/designer/pixmaps/qwtscale.png b/qwt/designer/pixmaps/qwtscale.png deleted file mode 100644 index 00a142122..000000000 Binary files a/qwt/designer/pixmaps/qwtscale.png and /dev/null differ diff --git a/qwt/designer/pixmaps/qwtslider.png b/qwt/designer/pixmaps/qwtslider.png deleted file mode 100644 index 8e9316c21..000000000 Binary files a/qwt/designer/pixmaps/qwtslider.png and /dev/null differ diff --git a/qwt/designer/pixmaps/qwtthermo.png b/qwt/designer/pixmaps/qwtthermo.png deleted file mode 100644 index 3b2bd50d8..000000000 Binary files a/qwt/designer/pixmaps/qwtthermo.png and /dev/null differ diff --git a/qwt/designer/pixmaps/qwtwheel.png b/qwt/designer/pixmaps/qwtwheel.png deleted file mode 100644 index c1f562cd5..000000000 Binary files a/qwt/designer/pixmaps/qwtwheel.png and /dev/null differ diff --git a/qwt/designer/pixmaps/qwtwidget.png b/qwt/designer/pixmaps/qwtwidget.png deleted file mode 100644 index cf72b754d..000000000 Binary files a/qwt/designer/pixmaps/qwtwidget.png and /dev/null differ diff --git a/qwt/designer/qwt_designer_plotdialog.cpp b/qwt/designer/qwt_designer_plotdialog.cpp deleted file mode 100644 index 50d62dd80..000000000 --- a/qwt/designer/qwt_designer_plotdialog.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include -#include -#include -#include -#include "qwt_designer_plotdialog.h" - -using namespace QwtDesignerPlugin; - -PlotDialog::PlotDialog(const QString &properties, QWidget *parent): - QDialog(parent) -{ - setWindowTitle("Plot Properties"); - - QLineEdit *lineEdit = new QLineEdit(properties); - connect(lineEdit, SIGNAL(textChanged(const QString &)), - SIGNAL(edited(const QString &))); - - QTabWidget *tabWidget = new QTabWidget(this); - tabWidget->addTab(lineEdit, "General"); - - QPushButton *closeButton = new QPushButton("Close"); - connect(closeButton, SIGNAL(clicked()), this, SLOT(accept())); - - QHBoxLayout *buttonLayout = new QHBoxLayout; - buttonLayout->addStretch(1); - buttonLayout->addWidget(closeButton); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(tabWidget); - mainLayout->addLayout(buttonLayout); - setLayout(mainLayout); -} diff --git a/qwt/designer/qwt_designer_plotdialog.h b/qwt/designer/qwt_designer_plotdialog.h deleted file mode 100644 index b2e150724..000000000 --- a/qwt/designer/qwt_designer_plotdialog.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_DESIGNER_PLOTDIALOG_H -#define QWT_DESIGNER_PLOTDIALOG_H - -#include - -namespace QwtDesignerPlugin -{ - -class PlotDialog: public QDialog -{ - Q_OBJECT - -public: - PlotDialog(const QString &properties, QWidget *parent = NULL); - -Q_SIGNALS: - void edited(const QString&); -}; - -} - -#endif diff --git a/qwt/designer/qwt_designer_plugin.cpp b/qwt/designer/qwt_designer_plugin.cpp deleted file mode 100644 index d0bad355d..000000000 --- a/qwt/designer/qwt_designer_plugin.cpp +++ /dev/null @@ -1,512 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#if defined(_MSC_VER) /* MSVC Compiler */ -#pragma warning ( disable : 4786 ) -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "qwt_designer_plugin.h" - -#ifndef NO_QWT_PLOT -#include "qwt_designer_plotdialog.h" -#include "qwt_plot.h" -#include "qwt_scale_widget.h" -#endif - -#ifndef NO_QWT_WIDGETS -#include "qwt_counter.h" -#include "qwt_wheel.h" -#include "qwt_thermo.h" -#include "qwt_knob.h" -#include "qwt_slider.h" -#include "qwt_analog_clock.h" -#include "qwt_compass.h" -#endif - -#include "qwt_text_label.h" - -using namespace QwtDesignerPlugin; - -CustomWidgetInterface::CustomWidgetInterface(QObject *parent): - QObject(parent), - d_isInitialized(false) -{ -} - -bool CustomWidgetInterface::isContainer() const -{ - return false; -} - -bool CustomWidgetInterface::isInitialized() const -{ - return d_isInitialized; -} - -QIcon CustomWidgetInterface::icon() const -{ - return d_icon; -} - -QString CustomWidgetInterface::codeTemplate() const -{ - return d_codeTemplate; -} - -QString CustomWidgetInterface::domXml() const -{ - return d_domXml; -} - -QString CustomWidgetInterface::group() const -{ - return "Qwt Widgets"; -} - -QString CustomWidgetInterface::includeFile() const -{ - return d_include; -} - -QString CustomWidgetInterface::name() const -{ - return d_name; -} - -QString CustomWidgetInterface::toolTip() const -{ - return d_toolTip; -} - -QString CustomWidgetInterface::whatsThis() const -{ - return d_whatsThis; -} - -void CustomWidgetInterface::initialize( - QDesignerFormEditorInterface *formEditor) -{ - if ( d_isInitialized ) - return; - - QExtensionManager *manager = formEditor->extensionManager(); - if ( manager ) - { - manager->registerExtensions(new TaskMenuFactory(manager), - Q_TYPEID(QDesignerTaskMenuExtension)); - } - - d_isInitialized = true; -} - -#ifndef NO_QWT_PLOT - -PlotInterface::PlotInterface(QObject *parent): - CustomWidgetInterface(parent) -{ - d_name = "QwtPlot"; - d_include = "qwt_plot.h"; - d_icon = QPixmap(":/pixmaps/qwtplot.png"); - d_domXml = - "\n" - " \n" - " \n" - " 0\n" - " 0\n" - " 400\n" - " 200\n" - " \n" - " \n" - "\n"; -} - -QWidget *PlotInterface::createWidget(QWidget *parent) -{ - return new QwtPlot(parent); -} - -#endif - -#ifndef NO_QWT_WIDGETS - -AnalogClockInterface::AnalogClockInterface(QObject *parent): - CustomWidgetInterface(parent) -{ - d_name = "QwtAnalogClock"; - d_include = "qwt_analog_clock.h"; - d_icon = QPixmap(":/pixmaps/qwtanalogclock.png"); - d_domXml = - "\n" - " \n" - " \n" - " 0\n" - " 0\n" - " 200\n" - " 200\n" - " \n" - " \n" - " \n" - " 4\n" - " \n" - "\n"; -} - -QWidget *AnalogClockInterface::createWidget(QWidget *parent) -{ - return new QwtAnalogClock(parent); -} - -#endif - -#ifndef NO_QWT_WIDGETS - -CompassInterface::CompassInterface(QObject *parent): - CustomWidgetInterface(parent) -{ - d_name = "QwtCompass"; - d_include = "qwt_compass.h"; - d_icon = QPixmap(":/pixmaps/qwtcompass.png"); - d_domXml = - "\n" - " \n" - " \n" - " 0\n" - " 0\n" - " 200\n" - " 200\n" - " \n" - " \n" - " \n" - " 4\n" - " \n" - "\n"; -} - -QWidget *CompassInterface::createWidget(QWidget *parent) -{ - return new QwtCompass(parent); -} - -#endif - -#ifndef NO_QWT_WIDGETS - -CounterInterface::CounterInterface(QObject *parent): - CustomWidgetInterface(parent) -{ - d_name = "QwtCounter"; - d_include = "qwt_counter.h"; - d_icon = QPixmap(":/pixmaps/qwtcounter.png"); - d_domXml = - "\n" - "\n"; -} - -QWidget *CounterInterface::createWidget(QWidget *parent) -{ - return new QwtCounter(parent); -} - -#endif - -#ifndef NO_QWT_WIDGETS - -DialInterface::DialInterface(QObject *parent): - CustomWidgetInterface(parent) -{ - d_name = "QwtDial"; - d_include = "qwt_dial.h"; - d_icon = QPixmap(":/pixmaps/qwtdial.png"); - d_domXml = - "\n" - " \n" - " \n" - " 0\n" - " 0\n" - " 200\n" - " 200\n" - " \n" - " \n" - " \n" - " 4\n" - " \n" - "\n"; -} - -QWidget *DialInterface::createWidget(QWidget *parent) -{ - return new QwtDial(parent); -} - -#endif - -#ifndef NO_QWT_WIDGETS - -KnobInterface::KnobInterface(QObject *parent): - CustomWidgetInterface(parent) -{ - d_name = "QwtKnob"; - d_include = "qwt_knob.h"; - d_icon = QPixmap(":/pixmaps/qwtknob.png"); - d_domXml = - "\n" - " \n" - " \n" - " 0\n" - " 0\n" - " 100\n" - " 100\n" - " \n" - " \n" - "\n"; -} - -QWidget *KnobInterface::createWidget(QWidget *parent) -{ - return new QwtKnob(parent); -} - -#endif - -#ifndef NO_QWT_PLOT - -ScaleWidgetInterface::ScaleWidgetInterface(QObject *parent): - CustomWidgetInterface(parent) -{ - d_name = "QwtScaleWidget"; - d_include = "qwt_scale_widget.h"; - d_icon = QPixmap(":/pixmaps/qwtscale.png"); - d_domXml = - "\n" - "\n"; -} - -QWidget *ScaleWidgetInterface::createWidget(QWidget *parent) -{ - return new QwtScaleWidget(QwtScaleDraw::LeftScale, parent); -} - -#endif - -#ifndef NO_QWT_WIDGETS - -SliderInterface::SliderInterface(QObject *parent): - CustomWidgetInterface(parent) -{ - d_name = "QwtSlider"; - d_include = "qwt_slider.h"; - d_icon = QPixmap(":/pixmaps/qwtslider.png"); - d_domXml = - "\n" - " \n" - " \n" - " 0\n" - " 0\n" - " 200\n" - " 60\n" - " \n" - " \n" - "\n"; -} - -QWidget *SliderInterface::createWidget(QWidget *parent) -{ - QwtSlider *slider = new QwtSlider(parent); -#if 0 - slider->setScalePosition(QwtSlider::Bottom); - slider->setRange(0.0, 10.0, 1.0, 0); - slider->setValue(3.0); -#endif - return slider; -} - -#endif - -TextLabelInterface::TextLabelInterface(QObject *parent): - CustomWidgetInterface(parent) -{ - d_name = "QwtTextLabel"; - d_include = "qwt_text_label.h"; - - d_icon = QPixmap(":/pixmaps/qwtwidget.png"); - d_domXml = - "\n" - " \n" - " \n" - " 0\n" - " 0\n" - " 100\n" - " 20\n" - " \n" - " \n" - "\n"; -} - -QWidget *TextLabelInterface::createWidget(QWidget *parent) -{ - return new QwtTextLabel(parent); -} - -#ifndef NO_QWT_WIDGETS - -ThermoInterface::ThermoInterface(QObject *parent): - CustomWidgetInterface(parent) -{ - d_name = "QwtThermo"; - d_include = "qwt_thermo.h"; - d_icon = QPixmap(":/pixmaps/qwtthermo.png"); - d_domXml = - "\n" - "\n"; -} - -QWidget *ThermoInterface::createWidget(QWidget *parent) -{ - return new QwtThermo(parent); -} - -#endif - -#ifndef NO_QWT_WIDGETS - -WheelInterface::WheelInterface(QObject *parent): - CustomWidgetInterface(parent) -{ - d_name = "QwtWheel"; - d_include = "qwt_wheel.h"; - d_icon = QPixmap(":/pixmaps/qwtwheel.png"); - d_domXml = - "\n" - "\n"; -} - -QWidget *WheelInterface::createWidget(QWidget *parent) -{ - return new QwtWheel(parent); -} - -#endif - -CustomWidgetCollectionInterface::CustomWidgetCollectionInterface( - QObject *parent): - QObject(parent) -{ -#ifndef NO_QWT_PLOT - d_plugins.append(new PlotInterface(this)); - d_plugins.append(new ScaleWidgetInterface(this)); -#endif - -#ifndef NO_QWT_WIDGETS - d_plugins.append(new AnalogClockInterface(this)); - d_plugins.append(new CompassInterface(this)); - d_plugins.append(new CounterInterface(this)); - d_plugins.append(new DialInterface(this)); - d_plugins.append(new KnobInterface(this)); - d_plugins.append(new SliderInterface(this)); - d_plugins.append(new ThermoInterface(this)); - d_plugins.append(new WheelInterface(this)); -#endif - - d_plugins.append(new TextLabelInterface(this)); -} - -QList - CustomWidgetCollectionInterface::customWidgets(void) const -{ - return d_plugins; -} - -TaskMenuFactory::TaskMenuFactory(QExtensionManager *parent): - QExtensionFactory(parent) -{ -} - -QObject *TaskMenuFactory::createExtension( - QObject *object, const QString &iid, QObject *parent) const -{ - if (iid == Q_TYPEID(QDesignerTaskMenuExtension)) - { -#ifndef NO_QWT_PLOT - if (QwtPlot *plot = qobject_cast(object)) - return new TaskMenuExtension(plot, parent); -#endif -#ifndef NO_QWT_WIDGETS - if (QwtDial *dial = qobject_cast(object)) - return new TaskMenuExtension(dial, parent); -#endif - } - - return QExtensionFactory::createExtension(object, iid, parent); -} - - -TaskMenuExtension::TaskMenuExtension(QWidget *widget, QObject *parent): - QObject(parent), - d_widget(widget) -{ - d_editAction = new QAction(tr("Edit Qwt Attributes ..."), this); - connect(d_editAction, SIGNAL(triggered()), - this, SLOT(editProperties())); -} - -QList TaskMenuExtension::taskActions() const -{ - QList list; - list.append(d_editAction); - return list; -} - -QAction *TaskMenuExtension::preferredEditAction() const -{ - return d_editAction; -} - -void TaskMenuExtension::editProperties() -{ - const QVariant v = d_widget->property("propertiesDocument"); - if ( v.type() != QVariant::String ) - return; - -#ifndef NO_QWT_PLOT - QString properties = v.toString(); - - if ( qobject_cast(d_widget) ) - { - PlotDialog dialog(properties); - connect(&dialog, SIGNAL(edited(const QString&)), - SLOT(applyProperties(const QString &))); - (void)dialog.exec(); - return; - } -#endif - - static QErrorMessage *errorMessage = NULL; - if ( errorMessage == NULL ) - errorMessage = new QErrorMessage(); - errorMessage->showMessage("Not implemented yet."); -} - -void TaskMenuExtension::applyProperties(const QString &properties) -{ - QDesignerFormWindowInterface *formWindow - = QDesignerFormWindowInterface::findFormWindow(d_widget); - if ( formWindow && formWindow->cursor() ) - formWindow->cursor()->setProperty("propertiesDocument", properties); -} - -Q_EXPORT_PLUGIN2(QwtDesignerPlugin, CustomWidgetCollectionInterface) diff --git a/qwt/designer/qwt_designer_plugin.h b/qwt/designer/qwt_designer_plugin.h deleted file mode 100644 index b181844f9..000000000 --- a/qwt/designer/qwt_designer_plugin.h +++ /dev/null @@ -1,234 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_DESIGNER_PLUGIN_H -#define QWT_DESIGNER_PLUGIN_H - -#include -#include -#include - -namespace QwtDesignerPlugin -{ - -class CustomWidgetInterface: public QObject, - public QDesignerCustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) - -public: - CustomWidgetInterface(QObject *parent); - - virtual bool isContainer() const; - virtual bool isInitialized() const; - virtual QIcon icon() const; - virtual QString codeTemplate() const; - virtual QString domXml() const; - virtual QString group() const; - virtual QString includeFile() const; - virtual QString name() const; - virtual QString toolTip() const; - virtual QString whatsThis() const; - virtual void initialize(QDesignerFormEditorInterface *); - -protected: - QString d_name; - QString d_include; - QString d_toolTip; - QString d_whatsThis; - QString d_domXml; - QString d_codeTemplate; - QIcon d_icon; - -private: - bool d_isInitialized; -}; - -class CustomWidgetCollectionInterface: public QObject, - public QDesignerCustomWidgetCollectionInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetCollectionInterface) - -public: - CustomWidgetCollectionInterface(QObject *parent = NULL); - - virtual QList customWidgets() const; - -private: - QList d_plugins; -}; - -#ifndef NO_QWT_PLOT -class PlotInterface: public CustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) - -public: - PlotInterface(QObject *parent); - virtual QWidget *createWidget(QWidget *parent); -}; -#endif - -#ifndef NO_QWT_WIDGETS -class AnalogClockInterface: public CustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) - -public: - AnalogClockInterface(QObject *parent); - virtual QWidget *createWidget(QWidget *parent); -}; -#endif - -#ifndef NO_QWT_WIDGETS -class CompassInterface: public CustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) - -public: - CompassInterface(QObject *parent); - virtual QWidget *createWidget(QWidget *parent); -}; -#endif - -#ifndef NO_QWT_WIDGETS -class CounterInterface: public CustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) - -public: - CounterInterface(QObject *parent); - virtual QWidget *createWidget(QWidget *parent); -}; -#endif - -#ifndef NO_QWT_WIDGETS -class DialInterface: public CustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) - -public: - DialInterface(QObject *parent); - virtual QWidget *createWidget(QWidget *parent); -}; -#endif - -#ifndef NO_QWT_WIDGETS -class KnobInterface: public CustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) - -public: - KnobInterface(QObject *parent); - virtual QWidget *createWidget(QWidget *parent); -}; -#endif - -#ifndef NO_QWT_PLOT -class ScaleWidgetInterface: public CustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) - -public: - ScaleWidgetInterface(QObject *parent); - virtual QWidget *createWidget(QWidget *parent); -}; -#endif - -#ifndef NO_QWT_WIDGETS -class SliderInterface: public CustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) - -public: - SliderInterface(QObject *parent); - virtual QWidget *createWidget(QWidget *parent); -}; -#endif - -class TextLabelInterface: public CustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) - -public: - TextLabelInterface(QObject *parent); - virtual QWidget *createWidget(QWidget *parent); -}; - -#ifndef NO_QWT_WIDGETS -class ThermoInterface: public CustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) - -public: - ThermoInterface(QObject *parent); - virtual QWidget *createWidget(QWidget *parent); -}; -#endif - -#ifndef NO_QWT_WIDGETS -class WheelInterface: public CustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) - -public: - WheelInterface(QObject *parent); - virtual QWidget *createWidget(QWidget *parent); -}; -#endif - -class TaskMenuFactory: public QExtensionFactory -{ - Q_OBJECT - -public: - TaskMenuFactory(QExtensionManager *parent = 0); - -protected: - QObject *createExtension(QObject *object, - const QString &iid, QObject *parent) const; -}; - -class TaskMenuExtension: public QObject, - public QDesignerTaskMenuExtension -{ - Q_OBJECT - Q_INTERFACES(QDesignerTaskMenuExtension) - -public: - TaskMenuExtension(QWidget *widget, QObject *parent); - - QAction *preferredEditAction() const; - QList taskActions() const; - -private Q_SLOTS: - void editProperties(); - void applyProperties(const QString &); - -private: - QAction *d_editAction; - QWidget *d_widget; -}; - -}; - -#endif diff --git a/qwt/designer/qwt_designer_plugin.qrc b/qwt/designer/qwt_designer_plugin.qrc deleted file mode 100644 index 01e4ffc8f..000000000 --- a/qwt/designer/qwt_designer_plugin.qrc +++ /dev/null @@ -1,15 +0,0 @@ - - - pixmaps/qwtplot.png - pixmaps/qwtanalogclock.png - pixmaps/qwtcounter.png - pixmaps/qwtcompass.png - pixmaps/qwtdial.png - pixmaps/qwtknob.png - pixmaps/qwtscale.png - pixmaps/qwtslider.png - pixmaps/qwtthermo.png - pixmaps/qwtwheel.png - pixmaps/qwtwidget.png - - diff --git a/qwt/designer/resources/qrc_qwt_designer_plugin.cpp b/qwt/designer/resources/qrc_qwt_designer_plugin.cpp deleted file mode 100644 index 247e0a57e..000000000 --- a/qwt/designer/resources/qrc_qwt_designer_plugin.cpp +++ /dev/null @@ -1,615 +0,0 @@ -/**************************************************************************** -** Resource object code -** -** Created: Thu Feb 2 22:55:24 2012 -** by: The Resource Compiler for Qt version 4.7.4 -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - -#include - -static const unsigned char qt_resource_data[] = { - // /Users/grauser/Documents/DEV/Qt/qwt-6.0.1/designer/pixmaps/qwtslider.png - 0x0,0x0,0x1,0xc4, - 0x89, - 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, - 0x0,0x0,0x16,0x0,0x0,0x0,0x16,0x8,0x6,0x0,0x0,0x0,0xc4,0xb4,0x6c,0x3b, - 0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xd2,0xa,0x9,0x13,0xa,0x30,0x66, - 0xcc,0x85,0xa0,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x12,0x0, - 0x0,0xb,0x12,0x1,0xd2,0xdd,0x7e,0xfc,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41, - 0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x1,0x53,0x49,0x44,0x41,0x54, - 0x78,0xda,0x63,0x60,0x18,0x5,0xc3,0xf,0xfc,0x47,0x2,0x75,0x4b,0xba,0xfe,0x93, - 0xaa,0x9f,0x9,0x9f,0xe4,0xa7,0x6f,0x9f,0x18,0x8e,0x5c,0x3e,0x2,0x66,0xfb,0x54, - 0x5,0x92,0x64,0x38,0x13,0x29,0x8a,0x7,0x85,0xc1,0x2c,0x30,0x6,0xa3,0x3,0xdb, - 0xff,0xff,0xc,0xff,0x21,0x76,0x31,0x62,0x2a,0x3c,0x7d,0xed,0x24,0x3,0x83,0x23, - 0x3b,0xee,0xe0,0x60,0x62,0x66,0xe0,0x16,0x55,0x64,0xf8,0xba,0xe2,0x2a,0x23,0xdc, - 0x60,0x26,0xa0,0xa1,0xff,0x18,0x99,0x18,0xf8,0x85,0x14,0x18,0xd8,0xd8,0x79,0x19, - 0x18,0x81,0x8a,0xb0,0x1,0x31,0x69,0x43,0x1c,0xa6,0x32,0x32,0x30,0xb1,0xb0,0x31, - 0xbc,0xf8,0xf0,0x88,0x41,0xa2,0x2a,0xe1,0xff,0x8b,0xb6,0x5,0x8c,0x60,0x83,0xff, - 0x31,0x32,0x32,0x8,0x89,0xaa,0x32,0x18,0x5a,0xa7,0x30,0xe8,0x2a,0x6a,0x3,0x2d, - 0x67,0xc1,0xd0,0xca,0x2d,0xac,0xcc,0x10,0x10,0xd4,0x8c,0xdd,0xb1,0x40,0x87,0xbc, - 0xff,0xf5,0x9f,0xe1,0xee,0xc5,0x5,0xc,0x92,0x2,0x22,0xc,0xcb,0x61,0x2e,0xe6, - 0x16,0x53,0x66,0x78,0xf7,0xf3,0x13,0xc3,0xb1,0xb3,0x8b,0x19,0x98,0xbf,0x1a,0x33, - 0xb0,0xb3,0xb0,0x32,0x30,0x78,0xd9,0xa3,0x68,0xfe,0xfa,0xe9,0x29,0xc3,0xed,0xab, - 0x6b,0xb0,0x1a,0xcc,0xc9,0xce,0xc1,0xa0,0x2c,0x2e,0xcb,0xe0,0xe0,0x18,0xc8,0x20, - 0x22,0x2a,0x7,0x34,0xb8,0xb,0x62,0xf0,0xd7,0x95,0xd7,0x18,0x25,0x2a,0xe3,0xfe, - 0x4b,0xfc,0xfb,0xce,0x20,0x21,0x20,0xcc,0xc0,0xce,0xca,0x86,0xa1,0x99,0x9d,0x95, - 0x9d,0x41,0x42,0x50,0x4,0xab,0xc1,0x1c,0x40,0x39,0x61,0x1e,0x7e,0x6,0x69,0x49, - 0x25,0x6,0x27,0x15,0x6d,0x46,0x48,0xe0,0xe0,0x0,0xa0,0x8c,0x1,0x4a,0xc7,0x97, - 0xee,0x5e,0x62,0xd8,0x7d,0xe9,0x38,0xc3,0xb9,0x6b,0xc7,0x19,0xb6,0xb4,0xad,0xc7, - 0xa9,0x1e,0x23,0x78,0x88,0x55,0x48,0x2a,0xa0,0x7d,0x3a,0x46,0x7,0x69,0x53,0x2b, - 0x28,0x32,0x18,0x6f,0x98,0xa1,0x97,0xf,0xa4,0x84,0xf1,0x28,0x80,0x3,0x0,0xb9, - 0xf0,0x60,0x59,0x7a,0xd9,0xd8,0x20,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae, - 0x42,0x60,0x82, - // /Users/grauser/Documents/DEV/Qt/qwt-6.0.1/designer/pixmaps/qwtdial.png - 0x0,0x0,0x1,0xb1, - 0x89, - 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, - 0x0,0x0,0x16,0x0,0x0,0x0,0x16,0x8,0x2,0x0,0x0,0x0,0x4b,0xd6,0xfb,0x6c, - 0x0,0x0,0x1,0x78,0x49,0x44,0x41,0x54,0x78,0x9c,0x9d,0x94,0x31,0x8e,0xc2,0x30, - 0x10,0x45,0x7,0x67,0x63,0x8d,0x81,0x2b,0x50,0x86,0x3,0xa4,0xa6,0xe2,0x0,0xf4, - 0x5c,0x82,0x9e,0x1b,0x70,0x83,0xb4,0x91,0xb8,0x41,0x2a,0x9a,0x70,0x84,0xa4,0x81, - 0xa,0x21,0x21,0x51,0x50,0x50,0x23,0x41,0x50,0xa4,0x2d,0x7e,0xd6,0xc,0xe,0xc9, - 0x66,0xf7,0x57,0x96,0x3d,0xff,0x79,0x3c,0xc9,0x4c,0x2f,0xcb,0x32,0x12,0x3a,0x1c, - 0xe,0xd4,0xaa,0x20,0x8,0x9c,0x9d,0xaf,0x8f,0xfe,0x3c,0xcf,0x99,0xd9,0x18,0xe3, - 0x79,0x9e,0xc,0x18,0x8d,0x46,0x88,0x91,0xa0,0x9e,0xcd,0x2,0x67,0x69,0x9a,0x6a, - 0xad,0x8d,0x31,0xf3,0xf9,0xdc,0xb9,0x6d,0xbb,0xdd,0x5a,0x90,0xa4,0x54,0x8,0xf8, - 0x93,0x24,0xf1,0x7d,0x7f,0xb1,0x58,0x48,0x67,0x18,0x86,0xf2,0xb1,0x0,0x49,0x8a, - 0xb2,0xfe,0xf5,0x7a,0x5d,0x14,0x5,0xfc,0x61,0x18,0x5a,0x8f,0x53,0xac,0xe9,0x74, - 0x4a,0x44,0xe7,0xf3,0xd9,0x1a,0x15,0xe,0xa2,0x28,0x2a,0x8a,0x62,0xb9,0x5c,0x3a, - 0xb6,0x44,0xb0,0x2c,0xd7,0xa1,0x28,0x90,0xca,0xb2,0x5c,0xad,0x56,0xd4,0x2a,0x99, - 0xe,0x28,0x90,0x22,0xa2,0x38,0x8e,0x8d,0x31,0x4e,0xfe,0x2d,0x42,0x98,0xd6,0xfa, - 0x7a,0xbd,0x56,0x8,0x63,0xc,0x52,0x70,0x9e,0xdd,0x9e,0xce,0x64,0x32,0xc1,0xc5, - 0x15,0xa2,0x29,0x7a,0x96,0x65,0x49,0x73,0x6a,0xcc,0x5c,0x21,0x7c,0xdf,0xef,0x72, - 0x79,0x5d,0x30,0x2a,0x22,0x1a,0xe,0x87,0xd4,0xb9,0x10,0x10,0x82,0x7,0x83,0x41, - 0x85,0xd0,0x5a,0x53,0x73,0x21,0x66,0x9f,0xf6,0x11,0xc,0xe3,0x2f,0xb5,0x68,0xd7, - 0xab,0x16,0xcc,0xbc,0xd9,0x6c,0xfe,0x81,0x78,0x7d,0x91,0xf1,0x78,0x8c,0x94,0xfe, - 0xea,0x3f,0x1e,0x8f,0x64,0x7f,0x70,0x12,0x8d,0xd8,0x51,0x65,0x59,0x62,0xa1,0xd0, - 0x6d,0xe8,0xbc,0x8e,0x94,0xdb,0xed,0xf6,0x7c,0x3e,0xf7,0xfb,0x3d,0x11,0x5,0x41, - 0xa0,0xe8,0xa7,0x67,0x3b,0x52,0x2e,0x97,0xcb,0xfd,0x7e,0x3f,0x9d,0x4e,0xd6,0xe8, - 0x8e,0x1c,0xf4,0x1f,0xbd,0x37,0x12,0xb4,0xdb,0xed,0x98,0x59,0x6b,0xfd,0x78,0x3c, - 0xa8,0x3e,0x72,0x24,0x45,0x82,0x20,0xcf,0xf3,0x98,0x99,0x99,0xfb,0xfd,0x3e,0x76, - 0xe4,0xe0,0x7b,0x9b,0x9d,0xf5,0xd1,0x5a,0x57,0x3d,0xe6,0x1b,0xf1,0xc5,0xa7,0x36, - 0x5f,0xe6,0x63,0x88,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, - - // /Users/grauser/Documents/DEV/Qt/qwt-6.0.1/designer/pixmaps/qwtwheel.png - 0x0,0x0,0x1,0x2a, - 0x89, - 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, - 0x0,0x0,0x16,0x0,0x0,0x0,0x16,0x8,0x3,0x0,0x0,0x0,0xf3,0x6a,0x9c,0x9, - 0x0,0x0,0x0,0x2a,0x74,0x45,0x58,0x74,0x43,0x72,0x65,0x61,0x74,0x69,0x6f,0x6e, - 0x20,0x54,0x69,0x6d,0x65,0x0,0x4d,0x69,0x20,0x39,0x20,0x4f,0x6b,0x74,0x20,0x32, - 0x30,0x30,0x32,0x20,0x32,0x32,0x3a,0x35,0x33,0x3a,0x30,0x30,0x20,0x2b,0x30,0x31, - 0x30,0x30,0x8a,0x59,0x4f,0x7f,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xd2, - 0xa,0x9,0x14,0x38,0x1c,0xbc,0x2b,0xab,0xb7,0x0,0x0,0x0,0x9,0x70,0x48,0x59, - 0x73,0x0,0x0,0xe,0xc3,0x0,0x0,0xe,0xc3,0x1,0xc7,0x6f,0xa8,0x64,0x0,0x0, - 0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0, - 0x0,0x27,0x50,0x4c,0x54,0x45,0xfb,0xb3,0x8,0xfb,0xfb,0xfb,0x75,0x75,0x75,0xd7, - 0xd7,0xd7,0xe1,0xe1,0xe1,0xf2,0xf2,0xf2,0xea,0xea,0xea,0xc6,0xc6,0xc6,0xbd,0xbd, - 0xbd,0xb3,0xb3,0xb3,0xa1,0xa1,0xa1,0x86,0x86,0x86,0x7d,0x7d,0x7d,0xab,0xa1,0x7c, - 0x5d,0x0,0x0,0x0,0x1,0x74,0x52,0x4e,0x53,0x0,0x40,0xe6,0xd8,0x66,0x0,0x0, - 0x0,0x43,0x49,0x44,0x41,0x54,0x78,0xda,0xcd,0x8f,0x37,0xe,0x0,0x20,0x10,0xc3, - 0xc8,0xd1,0xcb,0xff,0xdf,0x4b,0x13,0x4c,0x61,0x3,0x9,0xf,0x1e,0x9c,0x29,0x4a, - 0xdd,0x40,0x18,0xa0,0x19,0x3d,0x83,0x30,0xf3,0x98,0xe6,0x2e,0x2b,0x6b,0x6d,0x4, - 0xd6,0x35,0xf9,0x10,0x93,0x20,0x97,0xcf,0xf2,0xf8,0xb5,0xd5,0x8d,0xf3,0x79,0xd0, - 0xf3,0xe0,0xf9,0x21,0x15,0xd5,0x8b,0x3,0xae,0x41,0xc3,0x32,0xc9,0x0,0x0,0x0, - 0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, - // /Users/grauser/Documents/DEV/Qt/qwt-6.0.1/designer/pixmaps/qwtplot.png - 0x0,0x0,0x2,0x1f, - 0x89, - 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, - 0x0,0x0,0x16,0x0,0x0,0x0,0x16,0x8,0x6,0x0,0x0,0x0,0xc4,0xb4,0x6c,0x3b, - 0x0,0x0,0x0,0x2a,0x74,0x45,0x58,0x74,0x43,0x72,0x65,0x61,0x74,0x69,0x6f,0x6e, - 0x20,0x54,0x69,0x6d,0x65,0x0,0x4d,0x69,0x20,0x39,0x20,0x4f,0x6b,0x74,0x20,0x32, - 0x30,0x30,0x32,0x20,0x32,0x31,0x3a,0x32,0x34,0x3a,0x33,0x30,0x20,0x2b,0x30,0x31, - 0x30,0x30,0x72,0xfb,0x2a,0xa8,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xd2, - 0xa,0x9,0x13,0x21,0x1,0x41,0x62,0x78,0xf3,0x0,0x0,0x0,0x9,0x70,0x48,0x59, - 0x73,0x0,0x0,0xa,0xf0,0x0,0x0,0xa,0xf0,0x1,0x42,0xac,0x34,0x98,0x0,0x0, - 0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0, - 0x1,0x78,0x49,0x44,0x41,0x54,0x78,0xda,0x63,0x60,0x18,0x5,0x74,0x5,0x1a,0x62, - 0x5c,0xff,0xa9,0x65,0x16,0x23,0x36,0x43,0x6f,0xbc,0xfa,0xc6,0x48,0x9e,0x71,0x8, - 0xc0,0x34,0x28,0x82,0xe2,0x8c,0x28,0x13,0xb,0x10,0xf3,0x82,0x68,0xaa,0xb9,0x18, - 0x68,0x98,0x12,0xab,0x84,0xd4,0x46,0x16,0x11,0xb1,0xb,0x2c,0xc2,0x22,0x1b,0x81, - 0x7c,0x1d,0x8a,0xd,0x6,0x1a,0xc2,0xc5,0x22,0x2e,0x39,0x8b,0x4d,0x5e,0xc9,0x41, - 0xaa,0x7b,0x9a,0x12,0xbb,0xba,0xb6,0x3d,0xd0,0x82,0x79,0x40,0x71,0x41,0x8a,0x82, - 0xe2,0x82,0x96,0xa4,0xf7,0x39,0x25,0x81,0x9f,0x6f,0x76,0x6f,0xfb,0xff,0xfd,0xfb, - 0xf7,0xff,0x1f,0x2e,0x9e,0xfb,0x7f,0x41,0x53,0xe2,0xfb,0x5,0xd,0xf1,0x2c,0x8a, - 0x5c,0xcc,0xc8,0xce,0x9e,0xc0,0xa1,0xaa,0xc9,0xc4,0x69,0x60,0x2,0xe6,0xb3,0xab, - 0x6a,0x30,0xf0,0xfb,0x87,0xb2,0x32,0x30,0x31,0x65,0x2,0x5d,0xcd,0x47,0x96,0xc1, - 0xa0,0xc8,0xfa,0xff,0xeb,0x97,0x9,0xaf,0x87,0x1f,0xb,0x13,0xf,0x2f,0xd4,0x26, - 0x46,0x6,0x81,0xe0,0x28,0xe6,0xff,0x3f,0x7f,0xa8,0x30,0x71,0xf3,0xb8,0x92,0x65, - 0x30,0xb3,0xa0,0x50,0x0,0x23,0xb,0x8b,0x18,0xaf,0x93,0x3b,0x8a,0x38,0xbb,0xba, - 0x16,0x3,0xb7,0x8d,0x23,0x33,0xb3,0xa0,0x70,0x2e,0xd0,0x72,0x36,0xa2,0xd,0x6, - 0x29,0x3e,0x2b,0xcd,0xe1,0xf3,0xff,0xf7,0xef,0xe,0x7e,0xbf,0x50,0x66,0x90,0xf7, - 0x51,0x82,0x87,0x95,0x8d,0x41,0x24,0xbd,0x80,0x95,0x91,0x91,0xd1,0x8c,0x55,0x5a, - 0xb6,0x10,0xdd,0x70,0x26,0x2c,0x6,0x32,0x9e,0x95,0x64,0xb3,0x7,0x25,0x29,0x26, - 0xe,0xce,0xe5,0x40,0x43,0x85,0x45,0xf3,0x2a,0xd8,0x41,0xde,0x47,0x7,0x9c,0x86, - 0xa6,0x3f,0x84,0x92,0xb3,0x19,0xff,0x7d,0xf9,0x5c,0xcf,0xa6,0xa8,0xd2,0xf,0xd4, - 0xcb,0xc,0x93,0xc3,0x96,0xd0,0x99,0x19,0xd9,0xd8,0x4d,0x59,0xa5,0x64,0xdf,0x9, - 0x84,0xc7,0xf5,0xf3,0x79,0xf8,0x3d,0x65,0xe2,0xe1,0xf9,0x85,0xc3,0x63,0xf,0xf9, - 0xdc,0x7d,0x3f,0xfe,0xb8,0x7c,0x5e,0xe7,0xef,0xfb,0x77,0x4f,0xf5,0x4e,0xdd,0xfa, - 0x8b,0x55,0x15,0x25,0x85,0x10,0x48,0x2f,0xb2,0x7e,0x46,0x74,0x49,0x72,0xd,0x46, - 0x6,0xd4,0x28,0xc4,0x70,0xba,0x78,0xe8,0x1,0x0,0x3e,0x3c,0x69,0x30,0x7,0xb3, - 0x24,0xc3,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, - // /Users/grauser/Documents/DEV/Qt/qwt-6.0.1/designer/pixmaps/qwtscale.png - 0x0,0x0,0x1,0x75, - 0x89, - 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, - 0x0,0x0,0x16,0x0,0x0,0x0,0x16,0x8,0x6,0x0,0x0,0x0,0xc4,0xb4,0x6c,0x3b, - 0x0,0x0,0x0,0x2b,0x74,0x45,0x58,0x74,0x43,0x72,0x65,0x61,0x74,0x69,0x6f,0x6e, - 0x20,0x54,0x69,0x6d,0x65,0x0,0x53,0x6f,0x20,0x32,0x37,0x20,0x4f,0x6b,0x74,0x20, - 0x32,0x30,0x30,0x32,0x20,0x31,0x36,0x3a,0x31,0x33,0x3a,0x32,0x32,0x20,0x2b,0x30, - 0x31,0x30,0x30,0x8c,0x3a,0x78,0x7b,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7, - 0xd2,0xa,0x1b,0x11,0x10,0x23,0xab,0xcb,0x75,0xdf,0x0,0x0,0x0,0x9,0x70,0x48, - 0x59,0x73,0x0,0x0,0xa,0xf0,0x0,0x0,0xa,0xf0,0x1,0x42,0xac,0x34,0x98,0x0, - 0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0, - 0x0,0x0,0xcd,0x49,0x44,0x41,0x54,0x78,0xda,0x63,0x64,0xc0,0x3,0x74,0xf4,0xa6, - 0x54,0x2,0x29,0x6f,0x1c,0xd2,0x6c,0x40,0xfc,0x13,0x88,0x23,0xaf,0x5c,0xca,0x79, - 0x82,0x2e,0xc9,0xc2,0x80,0x1f,0xf4,0x3,0xf1,0x14,0x5c,0xf6,0x2,0xf1,0x5a,0x20, - 0x16,0x2,0x62,0xd2,0xc,0x6,0xba,0xe4,0x7,0x90,0xfa,0x81,0xc3,0x37,0x5f,0x81, - 0xd4,0x7f,0x5c,0x7a,0x99,0x18,0x68,0x4,0x8,0x5,0x5,0xc8,0x65,0x32,0x50,0xef, - 0xa2,0x3,0x35,0x20,0x66,0x26,0xdb,0x60,0x68,0xc4,0x3c,0x29,0x29,0xbb,0x73,0x64, - 0xc7,0x8e,0x1d,0xc8,0x52,0xdc,0x40,0xcc,0x49,0x89,0x8b,0x39,0x80,0x14,0x2b,0xd0, - 0x50,0x4f,0x74,0x29,0x6,0x48,0xe4,0x91,0xed,0x62,0xac,0x11,0x38,0x2,0x23,0xf, - 0x8,0x62,0x19,0xb0,0xe7,0x3e,0xca,0x22,0x8f,0x1,0x77,0xee,0x1b,0x8d,0x3c,0x38, - 0xa0,0x4e,0xce,0xeb,0xe9,0xfb,0x72,0x64,0xc1,0x82,0x5,0xc8,0x52,0x78,0x23,0x8f, - 0x91,0x8,0x17,0x83,0x73,0x1e,0x36,0x29,0x6,0x48,0xe4,0x79,0x0,0x2d,0xbf,0x44, - 0x8e,0x8b,0x87,0x50,0xe4,0xe1,0x89,0x38,0x10,0xa0,0x28,0xf2,0x70,0xe5,0x3a,0x10, - 0xa0,0x28,0xe7,0xe1,0xab,0xf3,0x4,0x80,0xd8,0x1e,0x88,0x1f,0x63,0x93,0x4,0x0, - 0xa7,0x60,0x4a,0x2f,0x7f,0x4f,0xa0,0xf9,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44, - 0xae,0x42,0x60,0x82, - // /Users/grauser/Documents/DEV/Qt/qwt-6.0.1/designer/pixmaps/qwtanalogclock.png - 0x0,0x0,0x1,0xa6, - 0x89, - 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, - 0x0,0x0,0x16,0x0,0x0,0x0,0x16,0x8,0x2,0x0,0x0,0x0,0x4b,0xd6,0xfb,0x6c, - 0x0,0x0,0x1,0x6d,0x49,0x44,0x41,0x54,0x78,0x9c,0x9d,0x54,0x31,0x8e,0xc2,0x40, - 0xc,0x34,0x4b,0x58,0xb1,0x8f,0xd8,0x32,0x1d,0x95,0x85,0x44,0x8b,0xb6,0xa3,0x47, - 0xe2,0x7,0x54,0x48,0x34,0x3c,0x3,0xf1,0x3,0x5a,0xa4,0x48,0xf4,0x14,0x91,0x22, - 0x5e,0xe0,0x8a,0xce,0x65,0x5e,0xc0,0xf,0xae,0xf0,0x9d,0x65,0x36,0x90,0xcb,0xdd, - 0x54,0x6b,0xed,0xce,0x78,0xec,0x38,0x1e,0x11,0x11,0x18,0x30,0x33,0x0,0x3c,0x1e, - 0xf,0xef,0x7d,0x8,0xc1,0x5e,0xc5,0x18,0x1,0xa0,0x2c,0x4b,0x78,0x45,0x91,0xf1, - 0xef,0xf7,0x7b,0x8,0x61,0xb1,0x58,0xe8,0x53,0x44,0x94,0x34,0x4d,0xd3,0xe8,0x4b, - 0x2b,0xe4,0x2c,0xff,0x76,0xbb,0x2d,0x97,0xcb,0xd3,0xe9,0xd4,0x4d,0x5,0x0,0x29, - 0xa5,0x94,0x52,0xdb,0xb6,0x6a,0xf6,0x45,0x82,0x99,0xaf,0xd7,0xeb,0x6a,0xb5,0x7a, - 0x4b,0x56,0x20,0x62,0x57,0xc5,0x49,0x70,0x3e,0x9f,0xd7,0xeb,0xb5,0xf0,0x89,0x8, - 0x11,0x95,0x96,0x35,0x4b,0xec,0x58,0x95,0x11,0x11,0xed,0xf7,0xfb,0xdd,0x6e,0xf7, - 0x29,0xbf,0xc8,0x89,0xae,0x95,0x6b,0x9a,0x46,0x1a,0xec,0x98,0xd9,0x7b,0xbf,0xd9, - 0x6c,0x6c,0xe6,0xb7,0xc8,0xec,0x1c,0xe,0x87,0xef,0x42,0x2e,0x97,0xcb,0x76,0xbb, - 0x25,0xa2,0xcc,0x7f,0xf,0x10,0x51,0x1c,0x3d,0x9f,0x4f,0x0,0x28,0xbc,0xf7,0x5a, - 0x42,0xb7,0xec,0x7e,0x3b,0xf3,0xf9,0x9c,0x99,0xdd,0x74,0x3a,0x1d,0x42,0xeb,0x81, - 0xcb,0x46,0xf0,0x1f,0x28,0x42,0x8,0xda,0x82,0x9e,0x42,0xb2,0xcf,0xac,0x61,0x55, - 0x55,0x45,0x8,0x61,0x60,0xb,0x2c,0x94,0xc2,0xcc,0xc5,0x64,0x32,0x19,0xf8,0xfa, - 0x13,0xdc,0x6c,0x36,0xab,0xeb,0xfa,0x4f,0x16,0xb4,0xa,0x99,0x4e,0x7,0x0,0xe3, - 0xf1,0x38,0xbb,0xfb,0xd5,0x97,0x8c,0x86,0x84,0x5,0x0,0xc4,0x18,0x75,0x8a,0x7, - 0x1a,0x21,0x22,0xfd,0xcd,0x46,0x1a,0xb4,0x6d,0x9b,0x52,0xea,0xf7,0x6f,0xbb,0x28, - 0x87,0xb2,0x2c,0x1d,0xfc,0xec,0x8f,0x18,0xa3,0x2e,0x15,0x5b,0x91,0xfd,0xe4,0x72, - 0xb6,0x7c,0xd0,0x7d,0xd1,0x55,0xf9,0x84,0x8c,0xf,0x76,0x6b,0xa9,0xa,0x22,0x1e, - 0x8f,0xc7,0xb7,0xe4,0xaa,0xaa,0x32,0x3e,0x48,0x2f,0x7a,0x52,0x75,0xd1,0x5d,0x2b, - 0x5f,0xb,0x0,0xbe,0xfd,0x70,0x63,0x0,0x15,0x0,0x0,0x0,0x0,0x49,0x45,0x4e, - 0x44,0xae,0x42,0x60,0x82, - // /Users/grauser/Documents/DEV/Qt/qwt-6.0.1/designer/pixmaps/qwtcounter.png - 0x0,0x0,0x4,0x2, - 0x89, - 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, - 0x0,0x0,0x16,0x0,0x0,0x0,0x16,0x8,0x6,0x0,0x0,0x0,0xc4,0xb4,0x6c,0x3b, - 0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xd2,0xa,0x9,0x15,0x9,0x2d,0x2a, - 0x6a,0xc6,0x8,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x12,0x0, - 0x0,0xb,0x12,0x1,0xd2,0xdd,0x7e,0xfc,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41, - 0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x3,0x91,0x49,0x44,0x41,0x54, - 0x78,0xda,0xad,0x95,0x5b,0x68,0x13,0x59,0x1c,0xc6,0xbf,0x5c,0x6d,0x6a,0xd2,0x34, - 0x69,0x2e,0xbd,0xc5,0x34,0x49,0xa1,0x46,0xbc,0x81,0x14,0x53,0x44,0xc5,0xdb,0x52, - 0x16,0xca,0xb2,0xb,0x22,0xfa,0x24,0xcb,0xae,0x3e,0x6d,0x1f,0x7c,0x13,0x65,0x97, - 0x85,0x45,0x41,0x45,0xc4,0xdb,0x83,0x88,0xa,0x8a,0xa2,0x20,0x8a,0xdd,0x15,0x41, - 0x1f,0x54,0x76,0xdb,0x2e,0x1b,0xb7,0xd5,0xd6,0x5a,0x35,0xb1,0x35,0x6d,0xc5,0x71, - 0x9a,0x9b,0x69,0x26,0xe9,0x34,0x33,0xc7,0x39,0x27,0xda,0x26,0x8a,0x9a,0x8a,0x1f, - 0x4c,0x38,0x27,0x9c,0xfc,0xe6,0x3b,0xdf,0xff,0x9f,0x73,0x54,0x28,0x90,0xb9,0x65, - 0x3d,0x49,0xf2,0x1c,0xbe,0x44,0x66,0xbb,0x13,0xc9,0xae,0x5b,0xaa,0x77,0x73,0x2d, - 0xfd,0x68,0xd8,0xb4,0x8d,0xc,0xdf,0xeb,0x42,0x4b,0xad,0x15,0x96,0x26,0x17,0xaa, - 0x8c,0x73,0x67,0x5,0x8d,0x4e,0xa4,0x21,0xa9,0xb5,0xb8,0xc4,0x2f,0x22,0xd,0xcb, - 0x5a,0x30,0x7c,0xf1,0x84,0x2a,0xff,0x86,0xc6,0x45,0xa4,0x75,0x89,0x1f,0x8d,0x35, - 0xe,0xf8,0xfd,0x7e,0xb8,0x5c,0x2e,0x98,0x4c,0xa6,0x92,0xa0,0x6a,0xb5,0x1a,0x84, - 0x10,0xe8,0xf5,0x7a,0x4,0x7,0x9f,0xa2,0x7d,0xcf,0x1,0x20,0xd4,0xa7,0xd2,0xd2, - 0xed,0x53,0xa7,0x14,0xda,0xd6,0xd6,0x86,0xe6,0xe6,0x66,0x18,0x8d,0x46,0xe8,0x74, - 0xba,0xcf,0x42,0x25,0x99,0x28,0x6e,0x27,0x91,0x11,0x73,0x70,0x56,0xcc,0x41,0x20, - 0x10,0x80,0xd3,0xe9,0xc4,0xb6,0x3f,0xe,0x10,0x35,0xcd,0xd4,0x62,0x9a,0xb,0xaf, - 0xd7,0xcb,0xa0,0x16,0x8b,0xa5,0x24,0x28,0x55,0x42,0x10,0x71,0xae,0x33,0x82,0xed, - 0xa7,0x83,0x18,0x78,0x36,0x8a,0x6c,0x36,0x8b,0xf9,0x3e,0xf,0x28,0x93,0x65,0x4c, - 0x33,0xad,0xaf,0xaf,0x67,0x4e,0x4b,0x15,0x75,0x1b,0x4f,0x4f,0x82,0x4f,0x65,0x71, - 0xff,0xf9,0x38,0xfe,0xed,0x49,0xc1,0x66,0xd4,0x63,0x81,0xcf,0x3b,0x53,0x3c,0xaa, - 0x52,0xb7,0x5f,0xe8,0xf6,0xc6,0x3,0xe,0x2f,0x92,0x79,0xf8,0xd1,0x8e,0x3e,0x78, - 0x6b,0x6d,0xb0,0x56,0x9a,0xf3,0xd9,0x17,0x2f,0x9e,0xc2,0xc9,0x3b,0x43,0x1f,0x1, - 0x4d,0xa1,0xfd,0x7c,0x2f,0xfa,0x46,0x93,0x6f,0xb3,0xcd,0x62,0x2c,0x91,0xc1,0x33, - 0x5e,0x80,0x24,0xc9,0xe0,0x26,0xa6,0xf0,0x30,0x34,0x8c,0x58,0x3c,0x1,0xa5,0x9a, - 0xc5,0xe0,0x5f,0xaf,0x3e,0xc4,0xce,0xcb,0xfd,0x1f,0x40,0xcf,0x77,0x8f,0x60,0xe3, - 0xf1,0x6e,0xdc,0x1e,0xe4,0xb1,0x72,0xef,0x1d,0x56,0xb0,0x53,0x77,0x9f,0xe3,0x7a, - 0x3f,0x87,0xbf,0xfb,0xc2,0x40,0x3c,0x82,0x44,0x22,0x89,0x93,0xd7,0xfe,0xc1,0xa3, - 0x70,0x84,0x81,0xb5,0x85,0x80,0xc3,0x5b,0x96,0xe2,0x82,0x2,0x79,0x5f,0x5b,0x2, - 0x2e,0xac,0x68,0xac,0x82,0xdb,0x56,0x8e,0x85,0xbb,0x6f,0xb2,0x2e,0xe8,0x1c,0x18, - 0x41,0x74,0xe0,0x3f,0x38,0x5e,0xd,0x41,0x16,0x5,0x20,0x37,0x9,0xe8,0xcb,0x11, - 0x8f,0x45,0x15,0xb0,0x5c,0xc,0xfe,0x94,0x28,0x74,0xed,0xbe,0xbb,0x4a,0xa1,0xf5, - 0xac,0xb5,0xe,0x6d,0x5e,0x88,0x70,0xa8,0xc,0xb1,0xe8,0x7c,0x48,0xb9,0x9c,0xb2, - 0x42,0xe9,0x65,0xa5,0x46,0x75,0xe,0x6b,0x71,0xf1,0x3e,0x96,0x6b,0x65,0xf9,0x4c, - 0x41,0x7f,0x5a,0xe5,0xc1,0x8f,0xa7,0x82,0x78,0x99,0x14,0xe1,0x9f,0xe7,0x40,0x5d, - 0x65,0x19,0x32,0x99,0x4c,0xd1,0x6f,0xc,0x6,0x3,0xfd,0xd7,0x7c,0x1a,0x5c,0x8, - 0x7d,0x17,0xc9,0x9e,0x3f,0x7,0x11,0x4b,0x8b,0xe8,0xe8,0x1d,0xc7,0xcb,0xd7,0x59, - 0xf0,0xca,0xf3,0x3a,0x9b,0xc3,0x53,0x6e,0x2,0x9a,0x34,0x8f,0x63,0x5b,0x97,0x7f, - 0xe8,0x98,0x3a,0xcc,0x49,0x64,0x7a,0x6e,0xfb,0xa5,0x3,0xe3,0x47,0xda,0xd8,0xf8, - 0xe7,0x33,0xf7,0xb0,0xcc,0x6d,0x41,0x85,0x41,0xab,0x44,0xa1,0x47,0x88,0x4b,0x61, - 0x24,0x41,0x5b,0x4d,0x44,0xff,0x58,0x12,0xa9,0xa1,0x1e,0xf8,0x75,0x3c,0x5e,0x44, - 0x1c,0x80,0x2c,0x17,0x77,0x45,0x77,0x28,0x8a,0xdf,0xbf,0x5f,0xc0,0x5a,0x8a,0x75, - 0xc9,0x77,0x7e,0x1c,0xbe,0x15,0x62,0xe3,0xe5,0x1e,0x2b,0x22,0x31,0x1,0x9d,0xbb, - 0xd6,0xb0,0x9c,0xbf,0x69,0x32,0xe1,0xf1,0x58,0xc,0xdd,0xe1,0x28,0x12,0xe1,0xff, - 0x61,0xe6,0x82,0xf8,0x76,0xb1,0x13,0x86,0xb7,0x56,0x8b,0x1c,0xb7,0x2e,0xae,0x46, - 0x6b,0xc1,0xbc,0x7d,0x7d,0xe3,0x4c,0xbe,0xab,0x3d,0xd3,0xe3,0x39,0x3a,0x2d,0x7c, - 0x35,0x16,0x58,0xd,0x3a,0x90,0xc9,0x28,0x34,0x89,0x8,0x2c,0xda,0x1c,0x5c,0xb5, - 0xd5,0xa8,0x76,0x2a,0x8e,0x55,0xea,0x62,0xc7,0xa5,0x4a,0xa5,0x1c,0x8a,0x6e,0x7b, - 0x5,0x76,0x6c,0x98,0x7,0x9b,0x36,0x83,0x4a,0x95,0x80,0x1f,0x36,0x4,0xe0,0x6b, - 0x50,0xe6,0x36,0x1b,0x5d,0x90,0x77,0x4c,0xcf,0xd3,0x9c,0xd2,0x32,0x92,0x24,0x41, - 0xa3,0xd1,0x94,0x4,0x2f,0xd3,0xeb,0xd0,0x54,0x57,0x85,0x6,0x23,0x81,0x60,0x35, - 0xc2,0xe3,0x76,0xa3,0xae,0xb6,0x6,0x23,0xaf,0xf8,0x3c,0x98,0x9e,0xfc,0xf1,0x54, - 0x9a,0x9d,0xa9,0xa2,0x28,0xe6,0xdb,0xa5,0x44,0xd7,0x1e,0xa7,0x19,0x47,0xb6,0xaf, - 0xc3,0x68,0xc4,0x7,0x5b,0x45,0x39,0xec,0x76,0x3b,0x6e,0x7,0x7b,0xd8,0x6d,0x92, - 0x97,0x72,0xd0,0xff,0xb6,0xff,0x20,0x99,0xad,0x64,0x59,0x26,0x82,0x20,0x10,0x8e, - 0xe3,0xd8,0x73,0xf6,0xca,0x35,0x42,0x59,0xd3,0x6f,0xa7,0x57,0x13,0xfd,0xe2,0xe2, - 0x5f,0x37,0xc8,0x83,0xc7,0x4f,0x66,0xd,0xef,0x1d,0x78,0x44,0x2e,0x74,0x5c,0x67, - 0xc,0x7a,0x71,0xb0,0x1d,0x15,0x6e,0xef,0x6b,0x5e,0xa6,0x6f,0x0,0x1e,0x59,0xe5, - 0x15,0x7,0x8d,0xbc,0x11,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60, - 0x82, - // /Users/grauser/Documents/DEV/Qt/qwt-6.0.1/designer/pixmaps/qwtcompass.png - 0x0,0x0,0x3,0xe0, - 0x89, - 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, - 0x0,0x0,0x16,0x0,0x0,0x0,0x16,0x8,0x2,0x0,0x0,0x0,0x4b,0xd6,0xfb,0x6c, - 0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x12,0x0,0x0,0xb,0x12, - 0x1,0xd2,0xdd,0x7e,0xfc,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xd3,0x4, - 0xe,0xd,0x34,0x33,0x41,0x3,0x14,0x60,0x0,0x0,0x3,0x7f,0x49,0x44,0x41,0x54, - 0x78,0x9c,0x6d,0x54,0xcb,0x6e,0xdb,0x46,0x14,0xbd,0xf3,0x20,0x45,0x72,0xc4,0x21, - 0xf4,0x82,0x64,0x4b,0xb5,0x90,0x8,0x96,0x83,0x78,0x55,0x67,0xdb,0xae,0xbc,0xc9, - 0xa6,0x5d,0x7,0x68,0x7f,0x21,0x9b,0x16,0x8,0xb2,0xce,0xb2,0xfd,0x85,0x7c,0x41, - 0x11,0x20,0x7f,0x11,0x78,0x99,0x38,0x80,0x5b,0x38,0x80,0x1d,0x55,0xb6,0x1e,0x21, - 0x44,0x4a,0x91,0xf8,0x18,0x92,0xc3,0xe9,0x82,0x82,0x22,0x5b,0xbd,0x2b,0xf2,0xc, - 0xef,0xb9,0xe7,0xde,0x73,0x39,0xe8,0xcd,0x5f,0x6f,0xe0,0x6e,0xe4,0x79,0xbe,0x58, - 0x2c,0xa2,0x38,0xd2,0x4b,0xba,0x6d,0xdb,0x94,0x50,0x95,0x2b,0x40,0x40,0x30,0x41, - 0x8,0xc1,0x4e,0xd0,0xed,0x17,0xa5,0xd4,0xcd,0xed,0x4d,0xae,0xf2,0x7e,0xbf,0xdf, - 0x6c,0x35,0x9,0x21,0xdb,0x47,0x61,0x18,0x6,0x41,0x90,0xc6,0x69,0x92,0x24,0xff, - 0x4f,0x91,0x24,0xc9,0xc5,0xe5,0xc5,0x93,0x93,0x27,0x7,0x7,0x7,0x1b,0xf0,0xfa, - 0xfa,0x1a,0x0,0x1e,0x3c,0x78,0x80,0x10,0x62,0x8c,0x31,0xc6,0xd2,0x24,0xd,0x56, - 0xc1,0x62,0xbe,0xc8,0xf3,0xfc,0xe,0x45,0x92,0x24,0x97,0x57,0x97,0xa7,0xa7,0xa7, - 0xdc,0xe6,0x5,0x22,0xa5,0x14,0x42,0x58,0x96,0x65,0x18,0xc6,0x72,0xb9,0xb4,0x6d, - 0xbb,0xc0,0x35,0x5d,0x73,0x2a,0xe,0x63,0x6c,0x3c,0x1a,0x4b,0x29,0x1,0x0,0x17, - 0x22,0x2f,0x2e,0x2f,0xf6,0xf7,0xf6,0xbd,0x99,0xb7,0x5a,0xae,0xf2,0x3c,0xf7,0x3c, - 0x2f,0x8a,0x22,0x8c,0x71,0xb3,0xd9,0x74,0x1c,0x87,0x52,0xea,0xfb,0x7e,0x71,0x34, - 0x99,0x4c,0xae,0xae,0xae,0xe2,0x24,0xee,0x74,0x3a,0xc5,0x68,0x28,0x0,0xc,0x86, - 0x83,0x93,0xef,0x4f,0xb2,0x2c,0x33,0x4d,0x53,0x8,0x21,0x73,0x59,0xad,0x56,0xb7, - 0xbb,0x35,0x4d,0xd3,0x34,0x4d,0x4a,0xe9,0x6a,0xb5,0x32,0xc,0x63,0x36,0x9b,0x61, - 0x8c,0x35,0x43,0xab,0x37,0xea,0xee,0x17,0x17,0x4b,0x29,0x65,0x2e,0xbb,0xdd,0x6e, - 0xaf,0xd7,0x6b,0x34,0x1a,0x54,0xa3,0x9c,0xf3,0xdd,0xb1,0x6b,0x9a,0xf6,0xe8,0xe8, - 0x51,0xa5,0x52,0x1,0x80,0xe3,0xe3,0x63,0xc6,0x98,0x94,0x72,0x7f,0x6f,0x9f,0x10, - 0x82,0x7d,0xdf,0xef,0xf7,0xfb,0xc5,0x77,0xf3,0xf9,0xdc,0x71,0x9c,0x5d,0xe7,0x30, - 0xc6,0xbd,0x87,0xbd,0xe9,0x97,0x69,0x14,0x45,0x8e,0xe3,0xf8,0xbe,0x5f,0xe0,0xa9, - 0x4c,0x6b,0xb5,0x1a,0x8e,0xa2,0xa8,0xdd,0x6e,0x17,0xf3,0xd3,0x75,0x7d,0xb7,0x3e, - 0x0,0x74,0xf,0xba,0x61,0x18,0xba,0xae,0xb,0x0,0x8,0x21,0x4a,0xa9,0x52,0xa, - 0x0,0x62,0x11,0xb7,0x5a,0x2d,0xac,0x95,0xb4,0xc2,0x7f,0x21,0x4,0xa5,0xf4,0x5e, - 0xb2,0x69,0x9a,0xed,0x76,0x9b,0x52,0x3a,0xbc,0x19,0x6e,0x40,0x84,0x50,0x9a,0xa6, - 0x85,0xf,0xe5,0x72,0x19,0x33,0xc6,0xd2,0x34,0x1d,0xc,0x6,0x93,0xc9,0xc4,0x30, - 0x8c,0x3b,0xf9,0x9f,0x3e,0xb5,0xfe,0xfe,0x27,0x11,0xc9,0xe7,0xc1,0xe7,0xa2,0x6c, - 0x11,0xba,0xae,0xbb,0xae,0x3b,0xfc,0x77,0x8,0x0,0x80,0x0,0xeb,0xba,0xae,0x69, - 0x1a,0x21,0xa4,0x56,0xab,0xdd,0x93,0xa0,0x8f,0xc7,0xe1,0x8b,0x17,0xf2,0xf5,0xeb, - 0x2c,0xcb,0xb6,0x71,0x42,0x88,0x65,0x59,0xdc,0xe1,0x6b,0xa,0x99,0x49,0x0,0xe8, - 0x74,0x3a,0x18,0xe3,0x28,0x8a,0xbe,0x59,0xe0,0xba,0xdf,0xfd,0xf1,0x67,0xfc,0xfc, - 0xb9,0xff,0xf3,0x4f,0xdb,0x12,0x0,0x20,0x8,0x2,0xd3,0x34,0x1d,0xc7,0x1,0x0, - 0x82,0x9,0x6,0x80,0x62,0x55,0x6d,0xdb,0x8e,0xe3,0x78,0x6d,0x41,0x14,0x3f,0xfc, - 0xed,0xf7,0xe9,0xaf,0xbf,0x2c,0x7e,0xfc,0x41,0x61,0x7c,0x4f,0x9d,0x94,0xb2,0x68, - 0xb9,0xa8,0x8a,0x4b,0x7a,0x29,0x8,0x82,0x75,0x65,0xaa,0x15,0x74,0xdd,0x57,0xaf, - 0xa2,0xa3,0xbe,0xfb,0xec,0xd9,0xae,0x3b,0x52,0x4a,0x4d,0xd3,0x8a,0x67,0x6e,0xf3, - 0xe9,0x74,0x8a,0x9,0x21,0xcb,0xaf,0xcb,0x2,0xb2,0x98,0xb5,0x5c,0x2e,0xab,0x6f, - 0xdf,0x52,0xcf,0x1b,0xbe,0x7c,0xb9,0x9b,0x9f,0x65,0x59,0x10,0x4,0xe5,0x72,0x79, - 0x4d,0xc1,0xf9,0x78,0x34,0xa6,0x0,0x90,0x88,0x24,0x8e,0xe3,0xd1,0x68,0x4,0xa, - 0xca,0x76,0x79,0xf8,0xf8,0xb1,0xff,0xf4,0xa9,0xda,0x31,0x58,0x4a,0x19,0x86,0x61, - 0x18,0x86,0x83,0xc1,0xa0,0xd7,0xeb,0xed,0xb5,0xf6,0x6e,0x6f,0x6e,0xb3,0x2c,0xa3, - 0x0,0xa0,0x72,0xb5,0xfa,0xba,0xb2,0x2c,0xcb,0x34,0x4d,0x84,0x10,0x3b,0x3a,0xf2, - 0x7c,0x9f,0x66,0x19,0x42,0x48,0xd7,0x75,0x42,0x48,0x10,0x4,0x85,0x7e,0xce,0xb9, - 0xa6,0x69,0x42,0x8,0xc6,0x58,0x99,0x95,0xcf,0xdf,0x9f,0xc3,0xe6,0x67,0x5f,0xad, - 0x56,0x8d,0x7a,0x83,0xd9,0xc,0x10,0x0,0x40,0xa5,0x52,0x51,0x4a,0xa5,0x69,0xea, - 0xfb,0xbe,0x61,0x18,0xa5,0x52,0x69,0xb3,0x32,0xa6,0x69,0x1e,0x1e,0x1e,0xb6,0x9a, - 0xad,0xb3,0x77,0x67,0xc5,0xe0,0xd6,0xd3,0x56,0xb9,0x9a,0xcd,0x66,0x22,0x16,0x18, - 0xad,0x91,0x42,0x2,0xa5,0x54,0x8,0xb1,0xbd,0x72,0xe,0x77,0x1a,0xb5,0xc6,0xd9, - 0xbb,0x33,0x21,0x44,0x81,0x7c,0x6b,0x58,0x4a,0x39,0x1e,0x8d,0x2b,0x95,0x4a,0xa3, - 0xd5,0xc0,0x80,0x45,0x2a,0x94,0x52,0x9b,0x7d,0xc3,0x18,0x73,0x9b,0x73,0xce,0x6f, - 0x6f,0x6e,0xcf,0xdf,0x9f,0x6f,0xae,0x2c,0xd8,0xbd,0x3b,0x3d,0xcf,0x9b,0xcf,0xe7, - 0xd5,0x6a,0xb5,0x5e,0xaf,0x73,0x9b,0x3,0x1,0x4a,0x28,0x21,0x24,0x8a,0xa2,0xe9, - 0x74,0xfa,0xf1,0xc3,0xc7,0x7b,0x9b,0xa,0x0,0xff,0x1,0xeb,0xd6,0xb9,0xfd,0x35, - 0x6a,0x40,0xa3,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, - // /Users/grauser/Documents/DEV/Qt/qwt-6.0.1/designer/pixmaps/qwtknob.png - 0x0,0x0,0x3,0x27, - 0x89, - 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, - 0x0,0x0,0x16,0x0,0x0,0x0,0x16,0x8,0x2,0x0,0x0,0x0,0x4b,0xd6,0xfb,0x6c, - 0x0,0x0,0x0,0x2a,0x74,0x45,0x58,0x74,0x43,0x72,0x65,0x61,0x74,0x69,0x6f,0x6e, - 0x20,0x54,0x69,0x6d,0x65,0x0,0x4d,0x69,0x20,0x39,0x20,0x4f,0x6b,0x74,0x20,0x32, - 0x30,0x30,0x32,0x20,0x32,0x33,0x3a,0x31,0x32,0x3a,0x30,0x37,0x20,0x2b,0x30,0x31, - 0x30,0x30,0xcd,0x73,0xb0,0xc8,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xd2, - 0xa,0x9,0x15,0xf,0x9,0x40,0x33,0x85,0x5f,0x0,0x0,0x0,0x9,0x70,0x48,0x59, - 0x73,0x0,0x0,0xe,0xc3,0x0,0x0,0xe,0xc3,0x1,0xc7,0x6f,0xa8,0x64,0x0,0x0, - 0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0, - 0x2,0x80,0x49,0x44,0x41,0x54,0x78,0xda,0xad,0x54,0x6b,0x6b,0xd3,0x50,0x18,0x6e, - 0xd3,0x5b,0xd6,0x26,0xdd,0xb2,0x5e,0xd2,0x76,0x75,0x75,0x17,0x10,0xc6,0xaa,0x93, - 0xb5,0x9b,0x88,0x96,0x21,0x88,0xfe,0x6,0x61,0xf8,0x41,0xf0,0x8f,0x88,0x1f,0xfc, - 0xf,0xc2,0x44,0xf0,0xb3,0x82,0xb8,0x31,0xd1,0x8f,0x7e,0xd0,0x8d,0x2a,0xeb,0x6c, - 0xb3,0xae,0xdd,0x4c,0xb7,0x5e,0xd7,0xa4,0xcd,0x65,0x4d,0xba,0x66,0xa9,0x6f,0x8d, - 0xc,0x7b,0x5b,0x95,0xf9,0xe4,0x25,0x9c,0xf3,0x9c,0xf7,0x3d,0x3c,0xef,0x73,0x4e, - 0xa2,0xdf,0xf8,0xf4,0x5e,0x77,0x31,0x20,0x17,0xac,0x7,0x18,0xbb,0xa9,0x7d,0x9a, - 0x96,0xe5,0xba,0x7f,0xcc,0x87,0x63,0xd8,0x9f,0xfc,0x6e,0x7a,0x4f,0xae,0xc9,0x6e, - 0xb7,0x8b,0x24,0x5d,0x3,0x54,0xac,0xbc,0x78,0xc5,0x32,0x6c,0x3c,0x41,0x75,0xf0, - 0xf1,0xef,0x9,0x2a,0x99,0xfc,0x91,0xa1,0x3b,0x78,0x7d,0xb7,0x17,0x95,0x2a,0x97, - 0xcb,0xe5,0xa6,0x26,0xa7,0x50,0xd4,0xc,0xd3,0x83,0xc3,0xec,0x25,0xff,0x18,0xc, - 0xa8,0x64,0xca,0x68,0x44,0x46,0x9,0x2,0x62,0x40,0x23,0xc4,0xc8,0xb0,0xdd,0x8e, - 0x47,0xa3,0xdf,0x30,0x1c,0xe3,0x79,0x9e,0xa6,0x33,0x62,0x70,0xd6,0x64,0x32,0x3b, - 0x46,0x9,0x97,0xd3,0xf1,0x57,0x5e,0x0,0x58,0xb6,0x22,0x49,0x72,0x78,0xf1,0x86, - 0xd3,0xe9,0x86,0x69,0xb9,0x5c,0x5a,0x5b,0x5d,0xd,0xcd,0x5f,0xef,0x99,0xdc,0xd9, - 0x88,0x20,0x8a,0x5b,0x5b,0xdb,0x5e,0x9f,0xef,0x76,0xe4,0xe,0x5b,0x2e,0x4a,0x35, - 0x1,0xc8,0x21,0x2b,0x3e,0xea,0x24,0x3f,0x7e,0x58,0x67,0x18,0x66,0x7a,0x6a,0x82, - 0x74,0xbb,0x3a,0x55,0x9c,0xaa,0xaa,0xd2,0x50,0x9a,0x4d,0x15,0x45,0x51,0x9b,0xcd, - 0x66,0x36,0x99,0x6f,0xde,0x8a,0x64,0x33,0xa9,0xb3,0x24,0xd8,0xe8,0x80,0xe6,0x8f, - 0xa5,0xba,0xc1,0x80,0xb8,0x5c,0x4e,0x8d,0xac,0xc9,0x32,0xbc,0xad,0x28,0x6a,0x78, - 0xfc,0x68,0x99,0xe3,0xf8,0xe7,0x2b,0x2f,0x25,0xb9,0x95,0x51,0xc8,0x17,0x83,0xd7, - 0xe6,0x4e,0x4f,0xea,0x8a,0xd2,0x68,0x53,0xab,0xd7,0x83,0xbb,0x8a,0xa2,0x82,0x10, - 0x49,0x96,0x4a,0xc5,0xa3,0xd7,0x6f,0xde,0x6e,0xc5,0xe2,0xa1,0xf9,0xb9,0xd6,0xa1, - 0x32,0x2c,0x33,0x17,0x9c,0x1d,0xb1,0x3,0xf0,0x58,0x3c,0xe1,0x26,0xbd,0xb2,0x5c, - 0xeb,0xee,0x19,0x5c,0x56,0x55,0x5d,0x2c,0xb6,0x6d,0x34,0x1a,0x31,0x3b,0x36,0x33, - 0x73,0x25,0x30,0xee,0xff,0xdd,0xc8,0xf4,0xe4,0x24,0x84,0x96,0xa7,0xb1,0x1a,0xa0, - 0xc1,0x6a,0x85,0x73,0x38,0xda,0x8e,0x30,0x10,0x18,0xf7,0x79,0x3c,0x30,0xf0,0x92, - 0x64,0xef,0xab,0x55,0x2e,0x33,0xa5,0x62,0x1e,0x45,0xad,0x50,0xff,0xe4,0xe9,0x33, - 0x5e,0xe0,0xcf,0x96,0xaa,0x1c,0x8f,0x20,0xad,0x84,0x8e,0x92,0xb6,0x2d,0xc0,0xa1, - 0x85,0x70,0x28,0x1a,0xdd,0x1c,0x71,0xba,0x3f,0x7f,0xd9,0x7c,0xb8,0xfc,0x60,0xe2, - 0x72,0x40,0x5b,0x52,0x9b,0xcd,0x7d,0xfa,0x50,0x14,0xf8,0xa5,0xa5,0x8,0xc3,0x54, - 0xfa,0xde,0xb,0xb0,0x17,0xa2,0xa1,0x34,0xbe,0x6e,0x6e,0x20,0x6,0xb,0x86,0xdb, - 0xa1,0xf2,0x97,0x59,0xd5,0xf4,0x5e,0xc6,0xef,0x6b,0x9d,0xa5,0x6d,0x68,0x8,0xa2, - 0xaf,0xa,0xd,0xc,0xc3,0xda,0x71,0x6c,0x21,0x74,0xf5,0xf8,0x58,0x4a,0x50,0x69, - 0x8,0x18,0xc0,0xd4,0xeb,0xf5,0x14,0x4b,0x47,0xd0,0xe0,0x80,0xab,0xf5,0x6e,0x6d, - 0xfd,0xfe,0xbd,0xbb,0x6,0xa4,0xf7,0x4f,0x0,0xea,0xf3,0x85,0x42,0x36,0x9b,0x13, - 0x45,0x11,0xc3,0xb0,0xc5,0x70,0xa8,0x87,0xa,0x6a,0x27,0xd5,0xaf,0x1e,0x0,0x4b, - 0x4,0x41,0x24,0x12,0x3b,0x14,0xb5,0xcb,0x71,0x42,0x6f,0x15,0x9c,0x20,0xc,0xe3, - 0xb8,0xae,0x3f,0xc0,0x9d,0xc6,0x9,0x3c,0xd,0xb5,0xa9,0x6a,0x99,0x9d,0x9f,0xd9, - 0xf9,0xf5,0x2d,0xd9,0x7a,0xbd,0xc5,0x62,0x86,0x38,0xcf,0xce,0x7f,0xc5,0x7f,0xd8, - 0xe2,0x27,0x25,0x35,0x22,0x3,0x9a,0x52,0xcb,0xd9,0x0,0x0,0x0,0x0,0x49,0x45, - 0x4e,0x44,0xae,0x42,0x60,0x82, - // /Users/grauser/Documents/DEV/Qt/qwt-6.0.1/designer/pixmaps/qwtthermo.png - 0x0,0x0,0x2,0x44, - 0x89, - 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, - 0x0,0x0,0xd,0x0,0x0,0x0,0x16,0x8,0x2,0x0,0x0,0x0,0x94,0x98,0x81,0x73, - 0x0,0x0,0x0,0x2a,0x74,0x45,0x58,0x74,0x43,0x72,0x65,0x61,0x74,0x69,0x6f,0x6e, - 0x20,0x54,0x69,0x6d,0x65,0x0,0x4d,0x69,0x20,0x39,0x20,0x4f,0x6b,0x74,0x20,0x32, - 0x30,0x30,0x32,0x20,0x32,0x33,0x3a,0x30,0x33,0x3a,0x31,0x31,0x20,0x2b,0x30,0x31, - 0x30,0x30,0x4c,0x45,0x31,0x92,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xd2, - 0xa,0x1b,0xf,0x2,0x6,0x8e,0x83,0x5f,0x31,0x0,0x0,0x0,0x9,0x70,0x48,0x59, - 0x73,0x0,0x0,0xe,0x74,0x0,0x0,0xe,0x74,0x1,0x6b,0x24,0xb3,0xd6,0x0,0x0, - 0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0, - 0x1,0x9d,0x49,0x44,0x41,0x54,0x78,0xda,0x8d,0x53,0xd9,0x6a,0xc2,0x50,0x10,0xcd, - 0xe6,0x52,0x12,0x22,0x62,0x44,0x51,0x7c,0xd0,0x44,0x83,0xa2,0xe2,0x77,0xb4,0x8f, - 0xfd,0x64,0x5f,0x84,0x56,0x2b,0x42,0xab,0xf,0x22,0x28,0xa6,0x5a,0x97,0x98,0xa8, - 0x91,0xba,0xd2,0xa3,0x57,0x34,0xca,0x6d,0xe9,0x81,0x84,0x99,0x9b,0x99,0x33,0xe7, - 0xce,0x4c,0xd8,0x72,0xb9,0xcc,0xfc,0x3,0x2,0x9e,0x6a,0xb5,0x2a,0x49,0xd2,0xf2, - 0x4,0x4d,0xd3,0xe2,0xf1,0xf8,0x62,0xb1,0xc0,0xf9,0x6e,0xb7,0xeb,0xf5,0x7a,0xb9, - 0x5c,0xce,0xe3,0xf1,0x70,0xf0,0x39,0x8e,0x5b,0xad,0x56,0xfb,0xfd,0x5e,0x10,0x84, - 0xd9,0x6c,0x86,0x93,0xd1,0x68,0xd4,0x6c,0x36,0x2b,0x95,0x4a,0x24,0x12,0x51,0x55, - 0xf5,0xcc,0x87,0xc,0xbc,0xd7,0x27,0x84,0xc3,0x61,0xd8,0xa2,0x28,0xb6,0x5a,0x2d, - 0xe4,0x5f,0xea,0x1e,0x2d,0x9f,0xcf,0x77,0x38,0x1c,0xc0,0x87,0x42,0xe4,0x34,0x1a, - 0x8d,0xa2,0xfa,0xbd,0x3e,0x0,0xd9,0x96,0x65,0xf9,0xfd,0xfe,0xc9,0x64,0x52,0x28, - 0x14,0xea,0xf5,0xfa,0xdd,0x3d,0xce,0xcc,0x28,0x14,0x8,0x4,0xb6,0xdb,0x6d,0x28, - 0x14,0x82,0x5b,0x2a,0x95,0xc8,0x79,0xa7,0x63,0x2d,0x97,0x9b,0x2b,0x5f,0x26,0x93, - 0x71,0x67,0xf,0x87,0x43,0xc7,0x61,0xde,0x3f,0xe4,0xd7,0x97,0x37,0x5d,0x2f,0x22, - 0xf7,0xcc,0x67,0x18,0x46,0xbb,0xdd,0xae,0xd5,0x6a,0xb6,0x6d,0x13,0x7d,0xdf,0x6b, - 0xc6,0xf8,0x7c,0x60,0x39,0xfe,0xa6,0x6e,0x7,0x5,0x2c,0x8b,0x65,0x59,0x18,0x70, - 0x7f,0xd5,0x97,0xcd,0x66,0x15,0x45,0xf1,0x7a,0xbd,0x30,0xe0,0xa2,0xdb,0xe6,0x74, - 0x4a,0xb9,0xaf,0x72,0x82,0xfb,0x83,0x2c,0xcb,0x94,0xb8,0xf1,0x78,0xc,0x7d,0x64, - 0x6e,0xc9,0x64,0x72,0x30,0x18,0xd0,0xeb,0x9a,0xa6,0x9,0x7d,0xe8,0xf6,0x66,0x73, - 0xec,0x42,0x2c,0x16,0xa3,0xec,0x1,0xa0,0xeb,0x7a,0x3a,0x9d,0x46,0x1c,0x46,0xc, - 0x17,0x7b,0xc0,0xba,0x86,0x76,0xe5,0x9b,0xcf,0xe7,0xe8,0x19,0x2e,0x8b,0xe9,0x91, - 0xbe,0xf0,0x3c,0x4f,0x89,0x3,0xba,0xdd,0xae,0xe3,0x38,0x8d,0x46,0xe3,0xaf,0xbe, - 0x60,0xcf,0xb0,0x29,0xd8,0x97,0x44,0x22,0xe1,0x9e,0xdb,0xbd,0xbe,0x7c,0x3e,0x4f, - 0xda,0x76,0x99,0x1b,0x9d,0x8f,0x0,0x8b,0x89,0x6,0x11,0x7d,0x74,0x3e,0x2,0x2c, - 0x62,0xbf,0xdf,0x87,0x0,0xe8,0x93,0x44,0xe6,0xe9,0x31,0xa8,0xa9,0xcf,0xa9,0x54, - 0xd0,0xb6,0xbf,0x6e,0xe2,0xf0,0x97,0x90,0x2d,0x77,0xeb,0x43,0x10,0xde,0x3f,0x4, - 0xb,0xc6,0xcd,0x1c,0x98,0xbd,0xf5,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae, - 0x42,0x60,0x82, - // /Users/grauser/Documents/DEV/Qt/qwt-6.0.1/designer/pixmaps/qwtwidget.png - 0x0,0x0,0x4,0x36, - 0x89, - 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, - 0x0,0x0,0x16,0x0,0x0,0x0,0x16,0x8,0x3,0x0,0x0,0x0,0xf3,0x6a,0x9c,0x9, - 0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xd2,0xa,0x9,0x12,0x32,0xe,0xb1, - 0xf0,0x4e,0xc7,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x12,0x0, - 0x0,0xb,0x12,0x1,0xd2,0xdd,0x7e,0xfc,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41, - 0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x3,0x0,0x50,0x4c,0x54,0x45, - 0xf7,0x0,0x0,0xf7,0x8,0x8,0xf7,0x10,0x10,0xff,0x10,0x10,0xff,0x18,0x18,0xff, - 0x21,0x21,0xff,0x29,0x29,0xff,0x31,0x31,0xff,0x39,0x39,0xff,0x42,0x42,0xff,0x52, - 0x52,0xff,0x5a,0x5a,0xff,0x63,0x63,0xff,0x6b,0x6b,0xff,0x73,0x73,0xff,0x7b,0x7b, - 0xff,0x84,0x84,0xff,0x8c,0x8c,0xff,0x94,0x94,0xff,0x9c,0x9c,0xff,0xa5,0xa5,0xff, - 0xad,0xad,0xff,0xb5,0xb5,0xff,0xbd,0xbd,0xff,0xc6,0xc6,0xff,0xce,0xce,0xff,0xd6, - 0xd6,0xff,0xde,0xde,0xff,0xe7,0xe7,0xff,0xef,0xef,0xff,0xf7,0xf7,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0x21,0x6a,0xf5,0x10,0x0,0x0,0x0,0x20,0x74,0x52,0x4e,0x53,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x5c,0x5c,0x1b,0xed, - 0x0,0x0,0x0,0x8d,0x49,0x44,0x41,0x54,0x78,0xda,0xbd,0x90,0xdd,0xa,0xc3,0x20, - 0xc,0x85,0x8d,0xd0,0xfa,0x53,0xb3,0xb6,0xae,0x15,0x5b,0xd4,0xf3,0xfe,0x6f,0xb9, - 0xb8,0xab,0x6d,0xf4,0x72,0x5b,0x8,0xe4,0xf0,0x41,0x38,0x39,0x51,0xb8,0x2c,0xf5, - 0x53,0xdc,0xa2,0xd1,0xa1,0x7d,0xe2,0xe6,0xb8,0xb6,0x99,0xdf,0x20,0x43,0xad,0x93, - 0xcc,0xaa,0x5f,0x60,0x9,0x9,0xca,0xe4,0x2e,0x9,0xd0,0x94,0x61,0xf,0xc,0x22, - 0x8,0x8a,0x3a,0xcd,0xa3,0x6c,0xc,0x28,0x1a,0xad,0xf7,0x9,0xa5,0xab,0x60,0xbf, - 0x0,0x5b,0xc0,0xea,0xb1,0x33,0x92,0x15,0xcb,0x69,0x6e,0x95,0x9d,0x5c,0x12,0xf6, - 0x64,0xe3,0x61,0x2a,0xf8,0x2e,0xb8,0x38,0x1a,0xe3,0xd3,0x5e,0xc7,0x8d,0xec,0x9, - 0xdc,0x68,0xe9,0x71,0xa8,0x94,0x7a,0x91,0x92,0xc9,0x97,0xff,0x7e,0xf0,0xb,0xf8, - 0x1,0x79,0x65,0x34,0x9a,0xd3,0x83,0x54,0x7c,0x0,0x0,0x0,0x0,0x49,0x45,0x4e, - 0x44,0xae,0x42,0x60,0x82, - -}; - -static const unsigned char qt_resource_name[] = { - // pixmaps - 0x0,0x7, - 0x7,0xf,0x38,0x93, - 0x0,0x70, - 0x0,0x69,0x0,0x78,0x0,0x6d,0x0,0x61,0x0,0x70,0x0,0x73, - // qwtslider.png - 0x0,0xd, - 0xb,0x12,0x13,0x47, - 0x0,0x71, - 0x0,0x77,0x0,0x74,0x0,0x73,0x0,0x6c,0x0,0x69,0x0,0x64,0x0,0x65,0x0,0x72,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, - // qwtdial.png - 0x0,0xb, - 0xf,0x8e,0x82,0x7, - 0x0,0x71, - 0x0,0x77,0x0,0x74,0x0,0x64,0x0,0x69,0x0,0x61,0x0,0x6c,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, - // qwtwheel.png - 0x0,0xc, - 0x4,0xa2,0x2c,0x87, - 0x0,0x71, - 0x0,0x77,0x0,0x74,0x0,0x77,0x0,0x68,0x0,0x65,0x0,0x65,0x0,0x6c,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, - // qwtplot.png - 0x0,0xb, - 0x3,0x96,0x81,0xa7, - 0x0,0x71, - 0x0,0x77,0x0,0x74,0x0,0x70,0x0,0x6c,0x0,0x6f,0x0,0x74,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, - // qwtscale.png - 0x0,0xc, - 0xb,0x3d,0x24,0x67, - 0x0,0x71, - 0x0,0x77,0x0,0x74,0x0,0x73,0x0,0x63,0x0,0x61,0x0,0x6c,0x0,0x65,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, - // qwtanalogclock.png - 0x0,0x12, - 0x3,0xcf,0x42,0x7, - 0x0,0x71, - 0x0,0x77,0x0,0x74,0x0,0x61,0x0,0x6e,0x0,0x61,0x0,0x6c,0x0,0x6f,0x0,0x67,0x0,0x63,0x0,0x6c,0x0,0x6f,0x0,0x63,0x0,0x6b,0x0,0x2e,0x0,0x70,0x0,0x6e, - 0x0,0x67, - // qwtcounter.png - 0x0,0xe, - 0x7,0x91,0x99,0xc7, - 0x0,0x71, - 0x0,0x77,0x0,0x74,0x0,0x63,0x0,0x6f,0x0,0x75,0x0,0x6e,0x0,0x74,0x0,0x65,0x0,0x72,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, - // qwtcompass.png - 0x0,0xe, - 0x5,0xf2,0x81,0xa7, - 0x0,0x71, - 0x0,0x77,0x0,0x74,0x0,0x63,0x0,0x6f,0x0,0x6d,0x0,0x70,0x0,0x61,0x0,0x73,0x0,0x73,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, - // qwtknob.png - 0x0,0xb, - 0x5,0xa4,0x81,0x7, - 0x0,0x71, - 0x0,0x77,0x0,0x74,0x0,0x6b,0x0,0x6e,0x0,0x6f,0x0,0x62,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, - // qwtthermo.png - 0x0,0xd, - 0x9,0x19,0xb,0x27, - 0x0,0x71, - 0x0,0x77,0x0,0x74,0x0,0x74,0x0,0x68,0x0,0x65,0x0,0x72,0x0,0x6d,0x0,0x6f,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, - // qwtwidget.png - 0x0,0xd, - 0xc,0x10,0xe9,0xe7, - 0x0,0x71, - 0x0,0x77,0x0,0x74,0x0,0x77,0x0,0x69,0x0,0x64,0x0,0x67,0x0,0x65,0x0,0x74,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, - -}; - -static const unsigned char qt_resource_struct[] = { - // : - 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1, - // :/pixmaps - 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0xb,0x0,0x0,0x0,0x2, - // :/pixmaps/qwtplot.png - 0x0,0x0,0x0,0x6e,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x4,0xab, - // :/pixmaps/qwtanalogclock.png - 0x0,0x0,0x0,0xa8,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x8,0x47, - // :/pixmaps/qwtwheel.png - 0x0,0x0,0x0,0x50,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x3,0x7d, - // :/pixmaps/qwtknob.png - 0x0,0x0,0x1,0x16,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x11,0xdb, - // :/pixmaps/qwtcompass.png - 0x0,0x0,0x0,0xf4,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0xd,0xf7, - // :/pixmaps/qwtcounter.png - 0x0,0x0,0x0,0xd2,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x9,0xf1, - // :/pixmaps/qwtthermo.png - 0x0,0x0,0x1,0x32,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x15,0x6, - // :/pixmaps/qwtslider.png - 0x0,0x0,0x0,0x14,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0, - // :/pixmaps/qwtscale.png - 0x0,0x0,0x0,0x8a,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x6,0xce, - // :/pixmaps/qwtwidget.png - 0x0,0x0,0x1,0x52,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x17,0x4e, - // :/pixmaps/qwtdial.png - 0x0,0x0,0x0,0x34,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x1,0xc8, - -}; - -QT_BEGIN_NAMESPACE - -extern Q_CORE_EXPORT bool qRegisterResourceData - (int, const unsigned char *, const unsigned char *, const unsigned char *); - -extern Q_CORE_EXPORT bool qUnregisterResourceData - (int, const unsigned char *, const unsigned char *, const unsigned char *); - -QT_END_NAMESPACE - - -int QT_MANGLE_NAMESPACE(qInitResources_qwt_designer_plugin)() -{ - QT_PREPEND_NAMESPACE(qRegisterResourceData) - (0x01, qt_resource_struct, qt_resource_name, qt_resource_data); - return 1; -} - -Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources_qwt_designer_plugin)) - -int QT_MANGLE_NAMESPACE(qCleanupResources_qwt_designer_plugin)() -{ - QT_PREPEND_NAMESPACE(qUnregisterResourceData) - (0x01, qt_resource_struct, qt_resource_name, qt_resource_data); - return 1; -} - -Q_DESTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qCleanupResources_qwt_designer_plugin)) diff --git a/qwt/examples/bode/bode.pro b/qwt/examples/bode/bode.pro deleted file mode 100644 index bc10f56ab..000000000 --- a/qwt/examples/bode/bode.pro +++ /dev/null @@ -1,23 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = bode - -HEADERS = \ - mainwindow.h \ - plot.h \ - complexnumber.h \ - pixmaps.h - -SOURCES = \ - plot.cpp \ - mainwindow.cpp \ - main.cpp diff --git a/qwt/examples/bode/complexnumber.h b/qwt/examples/bode/complexnumber.h deleted file mode 100644 index 744a56d7d..000000000 --- a/qwt/examples/bode/complexnumber.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef _COMPLEX_NUMBER_H_ -#define _COMPLEX_NUMBER_H_ - -#include - -class ComplexNumber -{ -public: - ComplexNumber() ; - ComplexNumber(double r, double i = 0.0); - - double real() const; - double imag() const; - - friend ComplexNumber operator*( - const ComplexNumber &, const ComplexNumber &); - - friend ComplexNumber operator+( - const ComplexNumber &, const ComplexNumber &); - - friend ComplexNumber operator-( - const ComplexNumber &, const ComplexNumber &); - friend ComplexNumber operator/( - const ComplexNumber &, const ComplexNumber &); - -private: - double d_real; - double d_imag; -}; - -inline ComplexNumber::ComplexNumber(): - d_real(0.0), - d_imag(-0.0) -{ -} - -inline ComplexNumber::ComplexNumber(double re, double im): - d_real(re), - d_imag(im) -{ -} - -inline double ComplexNumber::real() const -{ - return d_real; -} - -inline double ComplexNumber::imag() const -{ - return d_imag; -} - -inline ComplexNumber operator+( - const ComplexNumber &x1, const ComplexNumber &x2) -{ - return ComplexNumber(x1.d_real + x2.d_real, x1.d_imag + x2.d_imag); -} - -inline ComplexNumber operator-( - const ComplexNumber &x1, const ComplexNumber &x2) -{ - return ComplexNumber(x1.d_real - x2.d_real, x1.d_imag - x2.d_imag); -} - -inline ComplexNumber operator*( - const ComplexNumber &x1, const ComplexNumber &x2) -{ - return ComplexNumber(x1.d_real * x2.d_real - x1.d_imag * x2.d_imag, - x1.d_real * x2.d_imag + x2.d_real * x1.d_imag); -} - -inline ComplexNumber operator/( - const ComplexNumber &x1, const ComplexNumber &x2) -{ - double denom = x2.d_real * x2.d_real + x2.d_imag * x2.d_imag; - - return ComplexNumber( - (x1.d_real * x2.d_real + x1.d_imag * x2.d_imag) / denom, - (x1.d_imag * x2.d_real - x2.d_imag * x1.d_real) / denom - ); -} - -#endif diff --git a/qwt/examples/bode/main.cpp b/qwt/examples/bode/main.cpp deleted file mode 100644 index b352d05bd..000000000 --- a/qwt/examples/bode/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include "mainwindow.h" - -int main (int argc, char **argv) -{ - QApplication a(argc, argv); - - MainWindow w; - w.resize(540,400); - w.show(); - - return a.exec(); -} diff --git a/qwt/examples/bode/mainwindow.cpp b/qwt/examples/bode/mainwindow.cpp deleted file mode 100644 index 00ccd2add..000000000 --- a/qwt/examples/bode/mainwindow.cpp +++ /dev/null @@ -1,276 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "pixmaps.h" -#include "plot.h" -#include "mainwindow.h" - -class Zoomer: public QwtPlotZoomer -{ -public: - Zoomer(int xAxis, int yAxis, QwtPlotCanvas *canvas): - QwtPlotZoomer(xAxis, yAxis, canvas) - { - setTrackerMode(QwtPicker::AlwaysOff); - setRubberBand(QwtPicker::NoRubberBand); - - // RightButton: zoom out by 1 - // Ctrl+RightButton: zoom out to full size - - setMousePattern(QwtEventPattern::MouseSelect2, - Qt::RightButton, Qt::ControlModifier); - setMousePattern(QwtEventPattern::MouseSelect3, - Qt::RightButton); - } -}; - -//----------------------------------------------------------------- -// -// bode.cpp -- A demo program featuring QwtPlot and QwtCounter -// -// This example demonstrates the mapping of different curves -// to different axes in a QwtPlot widget. It also shows how to -// display the cursor position and how to implement zooming. -// -//----------------------------------------------------------------- - -MainWindow::MainWindow(QWidget *parent): - QMainWindow(parent) -{ - d_plot = new Plot(this); - - const int margin = 5; - d_plot->setContentsMargins( margin, margin, margin, 0 ); - - setContextMenuPolicy(Qt::NoContextMenu); - - d_zoomer[0] = new Zoomer( QwtPlot::xBottom, QwtPlot::yLeft, - d_plot->canvas()); - d_zoomer[0]->setRubberBand(QwtPicker::RectRubberBand); - d_zoomer[0]->setRubberBandPen(QColor(Qt::green)); - d_zoomer[0]->setTrackerMode(QwtPicker::ActiveOnly); - d_zoomer[0]->setTrackerPen(QColor(Qt::white)); - - d_zoomer[1] = new Zoomer(QwtPlot::xTop, QwtPlot::yRight, - d_plot->canvas()); - - d_panner = new QwtPlotPanner(d_plot->canvas()); - d_panner->setMouseButton(Qt::MidButton); - - d_picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, - QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, - d_plot->canvas()); - d_picker->setStateMachine(new QwtPickerDragPointMachine()); - d_picker->setRubberBandPen(QColor(Qt::green)); - d_picker->setRubberBand(QwtPicker::CrossRubberBand); - d_picker->setTrackerPen(QColor(Qt::white)); - - setCentralWidget(d_plot); - - QToolBar *toolBar = new QToolBar(this); - - QToolButton *btnZoom = new QToolButton(toolBar); - btnZoom->setText("Zoom"); - btnZoom->setIcon(QIcon(zoom_xpm)); - btnZoom->setCheckable(true); - btnZoom->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - toolBar->addWidget(btnZoom); - connect(btnZoom, SIGNAL(toggled(bool)), SLOT(enableZoomMode(bool))); - -#ifndef QT_NO_PRINTER - QToolButton *btnPrint = new QToolButton(toolBar); - btnPrint->setText("Print"); - btnPrint->setIcon(QIcon(print_xpm)); - btnPrint->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - toolBar->addWidget(btnPrint); - connect(btnPrint, SIGNAL(clicked()), SLOT(print())); -#endif - - QToolButton *btnExport = new QToolButton(toolBar); - btnExport->setText("Export"); - btnExport->setIcon(QIcon(print_xpm)); - btnExport->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - toolBar->addWidget(btnExport); - connect(btnExport, SIGNAL(clicked()), SLOT(exportDocument())); - - toolBar->addSeparator(); - - QWidget *hBox = new QWidget(toolBar); - - QHBoxLayout *layout = new QHBoxLayout(hBox); - layout->setSpacing(0); - layout->addWidget(new QWidget(hBox), 10); // spacer - layout->addWidget(new QLabel("Damping Factor", hBox), 0); - layout->addSpacing(10); - - QwtCounter *cntDamp = new QwtCounter(hBox); - cntDamp->setRange(0.0, 5.0, 0.01); - cntDamp->setValue(0.0); - - layout->addWidget(cntDamp, 0); - - (void)toolBar->addWidget(hBox); - - addToolBar(toolBar); -#ifndef QT_NO_STATUSBAR - (void)statusBar(); -#endif - - enableZoomMode(false); - showInfo(); - - connect(cntDamp, SIGNAL(valueChanged(double)), - d_plot, SLOT(setDamp(double))); - - connect(d_picker, SIGNAL(moved(const QPoint &)), - SLOT(moved(const QPoint &))); - connect(d_picker, SIGNAL(selected(const QPolygon &)), - SLOT(selected(const QPolygon &))); -} - -#ifndef QT_NO_PRINTER - -void MainWindow::print() -{ - QPrinter printer(QPrinter::HighResolution); - - QString docName = d_plot->title().text(); - if ( !docName.isEmpty() ) - { - docName.replace (QRegExp (QString::fromLatin1 ("\n")), tr (" -- ")); - printer.setDocName (docName); - } - - printer.setCreator("Bode example"); - printer.setOrientation(QPrinter::Landscape); - - QPrintDialog dialog(&printer); - if ( dialog.exec() ) - { - QwtPlotRenderer renderer; - - if ( printer.colorMode() == QPrinter::GrayScale ) - { - renderer.setDiscardFlag(QwtPlotRenderer::DiscardCanvasBackground); - renderer.setLayoutFlag(QwtPlotRenderer::FrameWithScales); - } - - renderer.renderTo(d_plot, printer); - } -} - -#endif - -void MainWindow::exportDocument() -{ -#ifndef QT_NO_PRINTER - QString fileName = "bode.pdf"; -#else - QString fileName = "bode.png"; -#endif - -#ifndef QT_NO_FILEDIALOG - const QList imageFormats = - QImageWriter::supportedImageFormats(); - - QStringList filter; - filter += "PDF Documents (*.pdf)"; -#ifndef QWT_NO_SVG - filter += "SVG Documents (*.svg)"; -#endif - filter += "Postscript Documents (*.ps)"; - - if ( imageFormats.size() > 0 ) - { - QString imageFilter("Images ("); - for ( int i = 0; i < imageFormats.size(); i++ ) - { - if ( i > 0 ) - imageFilter += " "; - imageFilter += "*."; - imageFilter += imageFormats[i]; - } - imageFilter += ")"; - - filter += imageFilter; - } - - fileName = QFileDialog::getSaveFileName( - this, "Export File Name", fileName, - filter.join(";;"), NULL, QFileDialog::DontConfirmOverwrite); -#endif - - if ( !fileName.isEmpty() ) - { - QwtPlotRenderer renderer; - - // flags to make the document look like the widget - renderer.setDiscardFlag(QwtPlotRenderer::DiscardBackground, false); - renderer.setLayoutFlag(QwtPlotRenderer::KeepFrames, true); - - renderer.renderDocument(d_plot, fileName, QSizeF(300, 200), 85); - } -} - -void MainWindow::enableZoomMode(bool on) -{ - d_panner->setEnabled(on); - - d_zoomer[0]->setEnabled(on); - d_zoomer[0]->zoom(0); - - d_zoomer[1]->setEnabled(on); - d_zoomer[1]->zoom(0); - - d_picker->setEnabled(!on); - - showInfo(); -} - -void MainWindow::showInfo(QString text) -{ - if ( text == QString::null ) - { - if ( d_picker->rubberBand() ) - text = "Cursor Pos: Press left mouse button in plot region"; - else - text = "Zoom: Press mouse button and drag"; - } - -#ifndef QT_NO_STATUSBAR - statusBar()->showMessage(text); -#endif -} - -void MainWindow::moved(const QPoint &pos) -{ - QString info; - info.sprintf("Freq=%g, Ampl=%g, Phase=%g", - d_plot->invTransform(QwtPlot::xBottom, pos.x()), - d_plot->invTransform(QwtPlot::yLeft, pos.y()), - d_plot->invTransform(QwtPlot::yRight, pos.y()) - ); - showInfo(info); -} - -void MainWindow::selected(const QPolygon &) -{ - showInfo(); -} diff --git a/qwt/examples/bode/mainwindow.h b/qwt/examples/bode/mainwindow.h deleted file mode 100644 index a846cf6d8..000000000 --- a/qwt/examples/bode/mainwindow.h +++ /dev/null @@ -1,35 +0,0 @@ -#include - -class QwtPlotZoomer; -class QwtPlotPicker; -class QwtPlotPanner; -class Plot; -class QPolygon; - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = 0); - -private Q_SLOTS: - void moved(const QPoint &); - void selected(const QPolygon &); - -#ifndef QT_NO_PRINTER - void print(); -#endif - - void exportDocument(); - void enableZoomMode(bool); - -private: - void showInfo(QString text = QString::null); - - Plot *d_plot; - - QwtPlotZoomer *d_zoomer[2]; - QwtPlotPicker *d_picker; - QwtPlotPanner *d_panner; -}; diff --git a/qwt/examples/bode/pixmaps.h b/qwt/examples/bode/pixmaps.h deleted file mode 100644 index 048a6aea2..000000000 --- a/qwt/examples/bode/pixmaps.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef PIXMAPS_H -#define PIXMAPS_H - -static const char *print_xpm[]={ -"32 32 12 1", -"a c #ffffff", -"h c #ffff00", -"c c #ffffff", -"f c #dcdcdc", -"b c #c0c0c0", -"j c #a0a0a4", -"e c #808080", -"g c #808000", -"d c #585858", -"i c #00ff00", -"# c #000000", -". c None", -"................................", -"................................", -"...........###..................", -"..........#abb###...............", -".........#aabbbbb###............", -".........#ddaaabbbbb###.........", -"........#ddddddaaabbbbb###......", -".......#deffddddddaaabbbbb###...", -"......#deaaabbbddddddaaabbbbb###", -".....#deaaaaaaabbbddddddaaabbbb#", -"....#deaaabbbaaaa#ddedddfggaaad#", -"...#deaaaaaaaaaa#ddeeeeafgggfdd#", -"..#deaaabbbaaaa#ddeeeeabbbbgfdd#", -".#deeefaaaaaaa#ddeeeeabbhhbbadd#", -"#aabbbeeefaaa#ddeeeeabbbbbbaddd#", -"#bbaaabbbeee#ddeeeeabbiibbadddd#", -"#bbbbbaaabbbeeeeeeabbbbbbaddddd#", -"#bjbbbbbbaaabbbbeabbbbbbadddddd#", -"#bjjjjbbbbbbaaaeabbbbbbaddddddd#", -"#bjaaajjjbbbbbbaaabbbbadddddddd#", -"#bbbbbaaajjjbbbbbbaaaaddddddddd#", -"#bjbbbbbbaaajjjbbbbbbddddddddd#.", -"#bjjjjbbbbbbaaajjjbbbdddddddd#..", -"#bjaaajjjbbbbbbjaajjbddddddd#...", -"#bbbbbaaajjjbbbjbbaabdddddd#....", -"###bbbbbbaaajjjjbbbbbddddd#.....", -"...###bbbbbbaaajbbbbbdddd#......", -"......###bbbbbbjbbbbbddd#.......", -".........###bbbbbbbbbdd#........", -"............###bbbbbbd#.........", -"...............###bbb#..........", -"..................###..........."}; - - -static const char *zoom_xpm[]={ -"32 32 8 1", -"# c #000000", -"b c #c0c0c0", -"a c #ffffff", -"e c #585858", -"d c #a0a0a4", -"c c #0000ff", -"f c #00ffff", -". c None", -"..######################........", -".#a#baaaaaaaaaaaaaaaaaa#........", -"#aa#baaaaaaaaaaaaaccaca#........", -"####baaaaaaaaaaaaaaaaca####.....", -"#bbbbaaaaaaaaaaaacccaaa#da#.....", -"#aaaaaaaaaaaaaaaacccaca#da#.....", -"#aaaaaaaaaaaaaaaaaccaca#da#.....", -"#aaaaaaaaaabe###ebaaaaa#da#.....", -"#aaaaaaaaa#########aaaa#da#.....", -"#aaaaaaaa###dbbbb###aaa#da#.....", -"#aaaaaaa###aaaaffb###aa#da#.....", -"#aaaaaab##aaccaaafb##ba#da#.....", -"#aaaaaae#daaccaccaad#ea#da#.....", -"#aaaaaa##aaaaaaccaab##a#da#.....", -"#aaaaaa##aacccaaaaab##a#da#.....", -"#aaaaaa##aaccccaccab##a#da#.....", -"#aaaaaae#daccccaccad#ea#da#.....", -"#aaaaaab##aacccaaaa##da#da#.....", -"#aaccacd###aaaaaaa###da#da#.....", -"#aaaaacad###daaad#####a#da#.....", -"#acccaaaad##########da##da#.....", -"#acccacaaadde###edd#eda#da#.....", -"#aaccacaaaabdddddbdd#eda#a#.....", -"#aaaaaaaaaaaaaaaaaadd#eda##.....", -"#aaaaaaaaaaaaaaaaaaadd#eda#.....", -"#aaaaaaaccacaaaaaaaaadd#eda#....", -"#aaaaaaaaaacaaaaaaaaaad##eda#...", -"#aaaaaacccaaaaaaaaaaaaa#d#eda#..", -"########################dd#eda#.", -"...#dddddddddddddddddddddd##eda#", -"...#aaaaaaaaaaaaaaaaaaaaaa#.####", -"...########################..##."}; - -#endif diff --git a/qwt/examples/bode/plot.cpp b/qwt/examples/bode/plot.cpp deleted file mode 100644 index ad16f9258..000000000 --- a/qwt/examples/bode/plot.cpp +++ /dev/null @@ -1,186 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "complexnumber.h" -#include "plot.h" - -#if QT_VERSION < 0x040601 -#define qExp(x) ::exp(x) -#define qAtan2(y, x) ::atan2(y, x) -#endif - -static void logSpace(double *array, int size, double xmin, double xmax) -{ - if ((xmin <= 0.0) || (xmax <= 0.0) || (size <= 0)) - return; - - const int imax = size -1; - - array[0] = xmin; - array[imax] = xmax; - - const double lxmin = log(xmin); - const double lxmax = log(xmax); - const double lstep = (lxmax - lxmin) / double(imax); - - for (int i = 1; i < imax; i++) - array[i] = qExp(lxmin + double(i) * lstep); -} - -Plot::Plot(QWidget *parent): - QwtPlot(parent) -{ - setAutoReplot(false); - - setTitle("Frequency Response of a Second-Order System"); - - setCanvasBackground(QColor(Qt::darkBlue)); - - // legend - QwtLegend *legend = new QwtLegend; - insertLegend(legend, QwtPlot::BottomLegend); - - // grid - QwtPlotGrid *grid = new QwtPlotGrid; - grid->enableXMin(true); - grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine)); - grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine)); - grid->attach(this); - - // axes - enableAxis(QwtPlot::yRight); - setAxisTitle(QwtPlot::xBottom, "Normalized Frequency"); - setAxisTitle(QwtPlot::yLeft, "Amplitude [dB]"); - setAxisTitle(QwtPlot::yRight, "Phase [deg]"); - - setAxisMaxMajor(QwtPlot::xBottom, 6); - setAxisMaxMinor(QwtPlot::xBottom, 10); - setAxisScaleEngine(QwtPlot::xBottom, new QwtLog10ScaleEngine); - - // curves - d_curve1 = new QwtPlotCurve("Amplitude"); - d_curve1->setRenderHint(QwtPlotItem::RenderAntialiased); - d_curve1->setPen(QPen(Qt::yellow)); - d_curve1->setLegendAttribute(QwtPlotCurve::LegendShowLine); - d_curve1->setYAxis(QwtPlot::yLeft); - d_curve1->attach(this); - - d_curve2 = new QwtPlotCurve("Phase"); - d_curve2->setRenderHint(QwtPlotItem::RenderAntialiased); - d_curve2->setPen(QPen(Qt::cyan)); - d_curve2->setLegendAttribute(QwtPlotCurve::LegendShowLine); - d_curve2->setYAxis(QwtPlot::yRight); - d_curve2->attach(this); - - // marker - d_marker1 = new QwtPlotMarker(); - d_marker1->setValue(0.0, 0.0); - d_marker1->setLineStyle(QwtPlotMarker::VLine); - d_marker1->setLabelAlignment(Qt::AlignRight | Qt::AlignBottom); - d_marker1->setLinePen(QPen(Qt::green, 0, Qt::DashDotLine)); - d_marker1->attach(this); - - d_marker2 = new QwtPlotMarker(); - d_marker2->setLineStyle(QwtPlotMarker::HLine); - d_marker2->setLabelAlignment(Qt::AlignRight | Qt::AlignBottom); - d_marker2->setLinePen(QPen(QColor(200,150,0), 0, Qt::DashDotLine)); - d_marker2->setSymbol( new QwtSymbol(QwtSymbol::Diamond, - QColor(Qt::yellow), QColor(Qt::green), QSize(7,7))); - d_marker2->attach(this); - - setDamp(0.0); - - setAutoReplot(true); -} - -void Plot::showData(const double *frequency, const double *amplitude, - const double *phase, int count) -{ - d_curve1->setSamples(frequency, amplitude, count); - d_curve2->setSamples(frequency, phase, count); -} - -void Plot::showPeak(double freq, double amplitude) -{ - QString label; - label.sprintf("Peak: %.3g dB", amplitude); - - QwtText text(label); - text.setFont(QFont("Helvetica", 10, QFont::Bold)); - text.setColor(QColor(200,150,0)); - - d_marker2->setValue(freq, amplitude); - d_marker2->setLabel(text); -} - -void Plot::show3dB(double freq) -{ - QString label; - label.sprintf("-3 dB at f = %.3g", freq); - - QwtText text(label); - text.setFont(QFont("Helvetica", 10, QFont::Bold)); - text.setColor(Qt::green); - - d_marker1->setValue(freq, 0.0); - d_marker1->setLabel(text); -} - -// -// re-calculate frequency response -// -void Plot::setDamp(double damping) -{ - const bool doReplot = autoReplot(); - setAutoReplot(false); - - const int ArraySize = 200; - - double frequency[ArraySize]; - double amplitude[ArraySize]; - double phase[ArraySize]; - - // build frequency vector with logarithmic division - logSpace(frequency, ArraySize, 0.01, 100); - - int i3 = 1; - double fmax = 1; - double amax = -1000.0; - - for (int i = 0; i < ArraySize; i++) - { - double f = frequency[i]; - const ComplexNumber g = - ComplexNumber(1.0) / ComplexNumber(1.0 - f * f, 2.0 * damping * f); - - amplitude[i] = 20.0 * log10(qSqrt( g.real() * g.real() + g.imag() * g.imag())); - phase[i] = qAtan2(g.imag(), g.real()) * (180.0 / M_PI); - - if ((i3 <= 1) && (amplitude[i] < -3.0)) - i3 = i; - if (amplitude[i] > amax) - { - amax = amplitude[i]; - fmax = frequency[i]; - } - - } - - double f3 = frequency[i3] - - (frequency[i3] - frequency[i3 - 1]) - / (amplitude[i3] - amplitude[i3 -1]) * (amplitude[i3] + 3); - - showPeak(fmax, amax); - show3dB(f3); - showData(frequency, amplitude, phase, ArraySize); - - setAutoReplot(doReplot); - - replot(); -} diff --git a/qwt/examples/bode/plot.h b/qwt/examples/bode/plot.h deleted file mode 100644 index d80dfb057..000000000 --- a/qwt/examples/bode/plot.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _PLOT_H_ -#define _PLOT_H_ - -#include - -class QwtPlotCurve; -class QwtPlotMarker; - -class Plot: public QwtPlot -{ - Q_OBJECT - -public: - Plot(QWidget *parent); - -public Q_SLOTS: - void setDamp(double damping); - -private: - void showData(const double *frequency, const double *amplitude, - const double *phase, int count); - void showPeak(double freq, double amplitude); - void show3dB(double freq); - - QwtPlotCurve *d_curve1; - QwtPlotCurve *d_curve2; - QwtPlotMarker *d_marker1; - QwtPlotMarker *d_marker2; -}; - -#endif diff --git a/qwt/examples/cpuplot/cpupiemarker.cpp b/qwt/examples/cpuplot/cpupiemarker.cpp deleted file mode 100644 index 814e0d709..000000000 --- a/qwt/examples/cpuplot/cpupiemarker.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include "cpuplot.h" -#include "cpupiemarker.h" - -CpuPieMarker::CpuPieMarker() -{ - setZ(1000); - setRenderHint(QwtPlotItem::RenderAntialiased, true); -} - -int CpuPieMarker::rtti() const -{ - return QwtPlotItem::Rtti_PlotUserItem; -} - -void CpuPieMarker::draw(QPainter *p, - const QwtScaleMap &, const QwtScaleMap &, - const QRectF &rect) const -{ - const CpuPlot *cpuPlot = (CpuPlot *)plot(); - - const QwtScaleMap yMap = cpuPlot->canvasMap(QwtPlot::yLeft); - - const int margin = 5; - - QRect pieRect; - pieRect.setX(rect.x() + margin); - pieRect.setY(rect.y() + margin); - pieRect.setHeight( qRound(yMap.transform(80.0)) ); - pieRect.setWidth( pieRect.height() ); - - const int dataType[] = { CpuPlot::User, CpuPlot::System, CpuPlot::Idle }; - - int angle = (int)(5760 * 0.75); - for ( unsigned int i = 0; - i < sizeof(dataType) / sizeof(dataType[0]); i++ ) - { - const QwtPlotCurve *curve = cpuPlot->cpuCurve(dataType[i]); - if ( curve->dataSize() > 0 ) - { - const int value = (int)(5760 * curve->sample(0).y() / 100.0); - - p->save(); - p->setBrush(QBrush(curve->pen().color(), Qt::SolidPattern)); - if ( value != 0 ) - p->drawPie(pieRect, -angle, -value); - p->restore(); - - angle += value; - } - } -} diff --git a/qwt/examples/cpuplot/cpupiemarker.h b/qwt/examples/cpuplot/cpupiemarker.h deleted file mode 100644 index 2ab9fd371..000000000 --- a/qwt/examples/cpuplot/cpupiemarker.h +++ /dev/null @@ -1,18 +0,0 @@ -//----------------------------------------------------------------- -// This class shows how to extend QwtPlotItems. It displays a -// pie chart of user/total/idle cpu usage in percent. -//----------------------------------------------------------------- - -#include - -class CpuPieMarker: public QwtPlotItem -{ -public: - CpuPieMarker(); - - virtual int rtti() const; - - virtual void draw(QPainter *p, - const QwtScaleMap &, const QwtScaleMap &, - const QRectF &rect) const; -}; diff --git a/qwt/examples/cpuplot/cpuplot.cpp b/qwt/examples/cpuplot/cpuplot.cpp deleted file mode 100644 index ddea5091e..000000000 --- a/qwt/examples/cpuplot/cpuplot.cpp +++ /dev/null @@ -1,233 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cpupiemarker.h" -#include "cpuplot.h" - -class TimeScaleDraw: public QwtScaleDraw -{ -public: - TimeScaleDraw(const QTime &base): - baseTime(base) - { - } - virtual QwtText label(double v) const - { - QTime upTime = baseTime.addSecs((int)v); - return upTime.toString(); - } -private: - QTime baseTime; -}; - -class Background: public QwtPlotItem -{ -public: - Background() - { - setZ(0.0); - } - - virtual int rtti() const - { - return QwtPlotItem::Rtti_PlotUserItem; - } - - virtual void draw(QPainter *painter, - const QwtScaleMap &, const QwtScaleMap &yMap, - const QRectF &rect) const - { - QColor c(Qt::white); - QRectF r = rect; - - for ( int i = 100; i > 0; i -= 10 ) - { - r.setBottom(yMap.transform(i - 10)); - r.setTop(yMap.transform(i)); - painter->fillRect(r, c); - - c = c.dark(110); - } - } -}; - -class CpuCurve: public QwtPlotCurve -{ -public: - CpuCurve(const QString &title): - QwtPlotCurve(title) - { - setRenderHint(QwtPlotItem::RenderAntialiased); - } - - void setColor(const QColor &color) - { - QColor c = color; - c.setAlpha(150); - - setPen(c); - setBrush(c); - } -}; - -CpuPlot::CpuPlot(QWidget *parent): - QwtPlot(parent), - dataCount(0) -{ - setAutoReplot(false); - - canvas()->setBorderRadius( 10 ); - - plotLayout()->setAlignCanvasToScales(true); - - QwtLegend *legend = new QwtLegend; - legend->setItemMode(QwtLegend::CheckableItem); - insertLegend(legend, QwtPlot::RightLegend); - - setAxisTitle(QwtPlot::xBottom, " System Uptime [h:m:s]"); - setAxisScaleDraw(QwtPlot::xBottom, - new TimeScaleDraw(cpuStat.upTime())); - setAxisScale(QwtPlot::xBottom, 0, HISTORY); - setAxisLabelRotation(QwtPlot::xBottom, -50.0); - setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom); - - /* - In situations, when there is a label at the most right position of the - scale, additional space is needed to display the overlapping part - of the label would be taken by reducing the width of scale and canvas. - To avoid this "jumping canvas" effect, we add a permanent margin. - We don't need to do the same for the left border, because there - is enough space for the overlapping label below the left scale. - */ - - QwtScaleWidget *scaleWidget = axisWidget(QwtPlot::xBottom); - const int fmh = QFontMetrics(scaleWidget->font()).height(); - scaleWidget->setMinBorderDist(0, fmh / 2); - - setAxisTitle(QwtPlot::yLeft, "Cpu Usage [%]"); - setAxisScale(QwtPlot::yLeft, 0, 100); - - Background *bg = new Background(); - bg->attach(this); - - CpuPieMarker *pie = new CpuPieMarker(); - pie->attach(this); - - CpuCurve *curve; - - curve = new CpuCurve("System"); - curve->setColor(Qt::red); - curve->attach(this); - data[System].curve = curve; - - curve = new CpuCurve("User"); - curve->setColor(Qt::blue); - curve->setZ(curve->z() - 1); - curve->attach(this); - data[User].curve = curve; - - curve = new CpuCurve("Total"); - curve->setColor(Qt::black); - curve->setZ(curve->z() - 2); - curve->attach(this); - data[Total].curve = curve; - - curve = new CpuCurve("Idle"); - curve->setColor(Qt::darkCyan); - curve->setZ(curve->z() - 3); - curve->attach(this); - data[Idle].curve = curve; - - showCurve(data[System].curve, true); - showCurve(data[User].curve, true); - showCurve(data[Total].curve, false); - showCurve(data[Idle].curve, false); - - for ( int i = 0; i < HISTORY; i++ ) - timeData[HISTORY - 1 - i] = i; - - (void)startTimer(1000); // 1 second - - connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)), - SLOT(showCurve(QwtPlotItem *, bool))); -} - -void CpuPlot::timerEvent(QTimerEvent *) -{ - for ( int i = dataCount; i > 0; i-- ) - { - for ( int c = 0; c < NCpuData; c++ ) - { - if ( i < HISTORY ) - data[c].data[i] = data[c].data[i-1]; - } - } - - cpuStat.statistic(data[User].data[0], data[System].data[0]); - - data[Total].data[0] = data[User].data[0] + - data[System].data[0]; - data[Idle].data[0] = 100.0 - data[Total].data[0]; - - if ( dataCount < HISTORY ) - dataCount++; - - for ( int j = 0; j < HISTORY; j++ ) - timeData[j]++; - - setAxisScale(QwtPlot::xBottom, - timeData[HISTORY - 1], timeData[0]); - - for ( int c = 0; c < NCpuData; c++ ) - { - data[c].curve->setRawSamples( - timeData, data[c].data, dataCount); - } - - replot(); -} - -void CpuPlot::showCurve(QwtPlotItem *item, bool on) -{ - item->setVisible(on); - QWidget *w = legend()->find(item); - if ( w && w->inherits("QwtLegendItem") ) - ((QwtLegendItem *)w)->setChecked(on); - - replot(); -} - -int main(int argc, char **argv) -{ - QApplication a(argc, argv); - - QWidget vBox; - vBox.setWindowTitle("Cpu Plot"); - - CpuPlot *plot = new CpuPlot(&vBox); - plot->setTitle("History"); - - const int margin = 5; - plot->setContentsMargins(margin, margin, margin, margin); - - QString info("Press the legend to en/disable a curve"); - - QLabel *label = new QLabel(info, &vBox); - - QVBoxLayout *layout = new QVBoxLayout(&vBox); - layout->addWidget(plot); - layout->addWidget(label); - - vBox.resize(600,400); - vBox.show(); - - return a.exec(); -} diff --git a/qwt/examples/cpuplot/cpuplot.h b/qwt/examples/cpuplot/cpuplot.h deleted file mode 100644 index b16a66c87..000000000 --- a/qwt/examples/cpuplot/cpuplot.h +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include "cpustat.h" - -#define HISTORY 60 // seconds - -class QwtPlotCurve; - -class CpuPlot : public QwtPlot -{ - Q_OBJECT -public: - enum CpuData - { - User, - System, - Total, - Idle, - - NCpuData - }; - - CpuPlot(QWidget * = 0); - const QwtPlotCurve *cpuCurve(int id) const - { return data[id].curve; } - -protected: - void timerEvent(QTimerEvent *e); - -private Q_SLOTS: - void showCurve(QwtPlotItem *, bool on); - -private: - struct - { - QwtPlotCurve *curve; - double data[HISTORY]; - } data[NCpuData]; - double timeData[HISTORY]; - - int dataCount; - CpuStat cpuStat; -}; diff --git a/qwt/examples/cpuplot/cpuplot.pro b/qwt/examples/cpuplot/cpuplot.pro deleted file mode 100644 index 037f4b944..000000000 --- a/qwt/examples/cpuplot/cpuplot.pro +++ /dev/null @@ -1,22 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = cpuplot - -HEADERS = \ - cpuplot.h \ - cpustat.h \ - cpupiemarker.h - -SOURCES = \ - cpuplot.cpp \ - cpustat.cpp \ - cpupiemarker.cpp diff --git a/qwt/examples/cpuplot/cpustat.cpp b/qwt/examples/cpuplot/cpustat.cpp deleted file mode 100644 index 1f6dc072a..000000000 --- a/qwt/examples/cpuplot/cpustat.cpp +++ /dev/null @@ -1,218 +0,0 @@ -#include -#include -#include -#include "cpustat.h" - -CpuStat::CpuStat() -{ - lookUp(procValues); -} - -QTime CpuStat::upTime() const -{ - QTime t; - for ( int i = 0; i < NValues; i++ ) - t = t.addSecs(int(procValues[i] / 100)); - - return t; -} - -void CpuStat::statistic(double &user, double &system) -{ - double values[NValues]; - - lookUp(values); - - double userDelta = values[User] + values[Nice] - - procValues[User] - procValues[Nice]; - double systemDelta = values[System] - procValues[System]; - - double totalDelta = 0; - for ( int i = 0; i < NValues; i++ ) - totalDelta += values[i] - procValues[i]; - - user = userDelta / totalDelta * 100.0; - system = systemDelta / totalDelta * 100.0; - - for ( int j = 0; j < NValues; j++ ) - procValues[j] = values[j]; -} - -void CpuStat::lookUp(double values[NValues]) const -{ - QFile file("/proc/stat"); - if ( !file.open(QIODevice::ReadOnly) ) - { - static double dummyValues[][NValues] = - { - { 103726, 0, 23484, 819556 }, - { 103783, 0, 23489, 819604 }, - { 103798, 0, 23490, 819688 }, - { 103820, 0, 23490, 819766 }, - { 103840, 0, 23493, 819843 }, - { 103875, 0, 23499, 819902 }, - { 103917, 0, 23504, 819955 }, - { 103950, 0, 23508, 820018 }, - { 103987, 0, 23510, 820079 }, - { 104020, 0, 23513, 820143 }, - { 104058, 0, 23514, 820204 }, - { 104099, 0, 23520, 820257 }, - { 104121, 0, 23525, 820330 }, - { 104159, 0, 23530, 820387 }, - { 104176, 0, 23534, 820466 }, - { 104215, 0, 23538, 820523 }, - { 104245, 0, 23541, 820590 }, - { 104267, 0, 23545, 820664 }, - { 104311, 0, 23555, 820710 }, - { 104355, 0, 23565, 820756 }, - { 104367, 0, 23567, 820842 }, - { 104383, 0, 23572, 820921 }, - { 104396, 0, 23577, 821003 }, - { 104413, 0, 23579, 821084 }, - { 104446, 0, 23588, 821142 }, - { 104521, 0, 23594, 821161 }, - { 104611, 0, 23604, 821161 }, - { 104708, 0, 23607, 821161 }, - { 104804, 0, 23611, 821161 }, - { 104895, 0, 23620, 821161 }, - { 104993, 0, 23622, 821161 }, - { 105089, 0, 23626, 821161 }, - { 105185, 0, 23630, 821161 }, - { 105281, 0, 23634, 821161 }, - { 105379, 0, 23636, 821161 }, - { 105472, 0, 23643, 821161 }, - { 105569, 0, 23646, 821161 }, - { 105666, 0, 23649, 821161 }, - { 105763, 0, 23652, 821161 }, - { 105828, 0, 23661, 821187 }, - { 105904, 0, 23666, 821206 }, - { 105999, 0, 23671, 821206 }, - { 106094, 0, 23676, 821206 }, - { 106184, 0, 23686, 821206 }, - { 106273, 0, 23692, 821211 }, - { 106306, 0, 23700, 821270 }, - { 106341, 0, 23703, 821332 }, - { 106392, 0, 23709, 821375 }, - { 106423, 0, 23715, 821438 }, - { 106472, 0, 23721, 821483 }, - { 106531, 0, 23727, 821517 }, - { 106562, 0, 23732, 821582 }, - { 106597, 0, 23736, 821643 }, - { 106633, 0, 23737, 821706 }, - { 106666, 0, 23742, 821768 }, - { 106697, 0, 23744, 821835 }, - { 106730, 0, 23748, 821898 }, - { 106765, 0, 23751, 821960 }, - { 106799, 0, 23754, 822023 }, - { 106831, 0, 23758, 822087 }, - { 106862, 0, 23761, 822153 }, - { 106899, 0, 23763, 822214 }, - { 106932, 0, 23766, 822278 }, - { 106965, 0, 23768, 822343 }, - { 107009, 0, 23771, 822396 }, - { 107040, 0, 23775, 822461 }, - { 107092, 0, 23780, 822504 }, - { 107143, 0, 23787, 822546 }, - { 107200, 0, 23795, 822581 }, - { 107250, 0, 23803, 822623 }, - { 107277, 0, 23810, 822689 }, - { 107286, 0, 23810, 822780 }, - { 107313, 0, 23817, 822846 }, - { 107325, 0, 23818, 822933 }, - { 107332, 0, 23818, 823026 }, - { 107344, 0, 23821, 823111 }, - { 107357, 0, 23821, 823198 }, - { 107368, 0, 23823, 823284 }, - { 107375, 0, 23824, 823377 }, - { 107386, 0, 23825, 823465 }, - { 107396, 0, 23826, 823554 }, - { 107422, 0, 23830, 823624 }, - { 107434, 0, 23831, 823711 }, - { 107456, 0, 23835, 823785 }, - { 107468, 0, 23838, 823870 }, - { 107487, 0, 23840, 823949 }, - { 107515, 0, 23843, 824018 }, - { 107528, 0, 23846, 824102 }, - { 107535, 0, 23851, 824190 }, - { 107548, 0, 23853, 824275 }, - { 107562, 0, 23857, 824357 }, - { 107656, 0, 23863, 824357 }, - { 107751, 0, 23868, 824357 }, - { 107849, 0, 23870, 824357 }, - { 107944, 0, 23875, 824357 }, - { 108043, 0, 23876, 824357 }, - { 108137, 0, 23882, 824357 }, - { 108230, 0, 23889, 824357 }, - { 108317, 0, 23902, 824357 }, - { 108412, 0, 23907, 824357 }, - { 108511, 0, 23908, 824357 }, - { 108608, 0, 23911, 824357 }, - { 108704, 0, 23915, 824357 }, - { 108801, 0, 23918, 824357 }, - { 108891, 0, 23928, 824357 }, - { 108987, 0, 23932, 824357 }, - { 109072, 0, 23943, 824361 }, - { 109079, 0, 23943, 824454 }, - { 109086, 0, 23944, 824546 }, - { 109098, 0, 23950, 824628 }, - { 109108, 0, 23955, 824713 }, - { 109115, 0, 23957, 824804 }, - { 109122, 0, 23958, 824896 }, - { 109132, 0, 23959, 824985 }, - { 109142, 0, 23961, 825073 }, - { 109146, 0, 23962, 825168 }, - { 109153, 0, 23964, 825259 }, - { 109162, 0, 23966, 825348 }, - { 109168, 0, 23969, 825439 }, - { 109176, 0, 23971, 825529 }, - { 109185, 0, 23974, 825617 }, - { 109193, 0, 23977, 825706 }, - { 109198, 0, 23978, 825800 }, - { 109206, 0, 23978, 825892 }, - { 109212, 0, 23981, 825983 }, - { 109219, 0, 23981, 826076 }, - { 109225, 0, 23981, 826170 }, - { 109232, 0, 23984, 826260 }, - { 109242, 0, 23984, 826350 }, - { 109255, 0, 23986, 826435 }, - { 109268, 0, 23987, 826521 }, - { 109283, 0, 23990, 826603 }, - { 109288, 0, 23991, 826697 }, - { 109295, 0, 23993, 826788 }, - { 109308, 0, 23994, 826874 }, - { 109322, 0, 24009, 826945 }, - { 109328, 0, 24011, 827037 }, - { 109338, 0, 24012, 827126 }, - { 109347, 0, 24012, 827217 }, - { 109354, 0, 24017, 827305 }, - { 109367, 0, 24017, 827392 }, - { 109371, 0, 24019, 827486 }, - }; - static int counter = 0; - - for ( int i = 0; i < NValues; i++ ) - values[i] = dummyValues[counter][i]; - - counter = (counter + 1) - % (sizeof(dummyValues) / sizeof(dummyValues[0])); - } - else - { - QTextStream textStream(&file); - do { - QString line = textStream.readLine(); - line = line.trimmed(); - if ( line.startsWith("cpu ") ) - { - const QStringList valueList = - line.split(" ", QString::SkipEmptyParts); - if ( valueList.count() >= 5 ) - { - for ( int i = 0; i < NValues; i++ ) - values[i] = valueList[i+1].toDouble(); - } - break; - } - } while(!textStream.atEnd()); - } -} diff --git a/qwt/examples/cpuplot/cpustat.h b/qwt/examples/cpuplot/cpustat.h deleted file mode 100644 index 5515354c8..000000000 --- a/qwt/examples/cpuplot/cpustat.h +++ /dev/null @@ -1,23 +0,0 @@ -#include - -class CpuStat -{ -public: - CpuStat(); - void statistic(double &user, double &system); - QTime upTime() const; - - enum Value - { - User, - Nice, - System, - Idle, - - NValues - }; - -private: - void lookUp(double[NValues]) const; - double procValues[NValues]; -}; diff --git a/qwt/examples/curvdemo1/curvdemo1.cpp b/qwt/examples/curvdemo1/curvdemo1.cpp deleted file mode 100644 index 3b3a520d5..000000000 --- a/qwt/examples/curvdemo1/curvdemo1.cpp +++ /dev/null @@ -1,202 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include -#include - -//------------------------------------------------------------ -// curvdemo1 -// -// This example program features some of the different -// display styles of the QwtPlotCurve class -//------------------------------------------------------------ - - -// -// Array Sizes -// -const int Size = 27; -const int CurvCnt = 6; - -// -// Arrays holding the values -// -double xval[Size]; -double yval[Size]; -QwtScaleMap xMap; -QwtScaleMap yMap; - -class MainWin : public QFrame -{ -public: - MainWin(); - -protected: - virtual void paintEvent(QPaintEvent *); - void drawContents(QPainter *p); - -private: - void shiftDown(QRect &rect, int offset) const; - - QwtPlotCurve d_curves[CurvCnt]; -}; - -MainWin::MainWin() -{ - int i; - - xMap.setScaleInterval(-0.5, 10.5); - yMap.setScaleInterval(-1.1, 1.1); - - // - // Frame style - // - setFrameStyle(QFrame::Box|QFrame::Raised); - setLineWidth(2); - setMidLineWidth(3); - - // - // Calculate values - // - for(i=0; isetRenderHint(QPainter::Antialiasing, - d_curves[i].testRenderHint(QwtPlotItem::RenderAntialiased) ); - d_curves[i].draw(painter, xMap, yMap, r); - - shiftDown(r, deltay); - } - - // - // draw titles - // - r = contentsRect(); // reset r - painter->setFont(QFont("Helvetica", 8)); - - const int alignment = Qt::AlignTop|Qt::AlignHCenter; - - painter->setPen(Qt::black); - - painter->drawText(0,r.top(),r.width(), painter->fontMetrics().height(), - alignment, "Style: Line/Fitted, Symbol: Cross"); - shiftDown(r, deltay); - - painter->drawText(0,r.top(),r.width(), painter->fontMetrics().height(), - alignment, "Style: Sticks, Symbol: Ellipse"); - shiftDown(r, deltay); - - painter->drawText(0 ,r.top(),r.width(), painter->fontMetrics().height(), - alignment, "Style: Lines, Symbol: None"); - shiftDown(r, deltay); - - painter->drawText(0 ,r.top(),r.width(), painter->fontMetrics().height(), - alignment, "Style: Lines, Symbol: None, Antialiased"); - shiftDown(r, deltay); - - painter->drawText(0, r.top(),r.width(), painter->fontMetrics().height(), - alignment, "Style: Steps, Symbol: None"); - shiftDown(r, deltay); - - painter->drawText(0,r.top(),r.width(), painter->fontMetrics().height(), - alignment, "Style: NoCurve, Symbol: XCross"); -} - -int main (int argc, char **argv) -{ - QApplication a(argc, argv); - - MainWin w; - - w.resize(300,600); - w.show(); - - return a.exec(); -} diff --git a/qwt/examples/curvdemo1/curvdemo1.pro b/qwt/examples/curvdemo1/curvdemo1.pro deleted file mode 100644 index 298c97744..000000000 --- a/qwt/examples/curvdemo1/curvdemo1.pro +++ /dev/null @@ -1,15 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = curvdemo1 - -SOURCES = \ - curvdemo1.cpp diff --git a/qwt/examples/curvdemo2/curvdemo2.cpp b/qwt/examples/curvdemo2/curvdemo2.cpp deleted file mode 100644 index 25e60f44f..000000000 --- a/qwt/examples/curvdemo2/curvdemo2.cpp +++ /dev/null @@ -1,214 +0,0 @@ -#include -#include -#include -#include -#include -#include "curvdemo2.h" - - -//------------------------------------------------------------ -// curvdemo2 -// -// This example shows a simple animation featuring -// with several QwtPlotCurves -// -//------------------------------------------------------------ - -// -// Array Sizes -// -const int Size = 15; -const int USize = 13; - -// -// Arrays holding the values -// -double xval[Size]; -double yval[Size]; -double zval[Size]; -double uval[USize]; -double vval[USize]; - - -// -// CONSTRUCT MAIN WINDOW -// -MainWin::MainWin(): - QFrame() -{ - setFrameStyle(QFrame::Box|QFrame::Raised); - setLineWidth(2); - setMidLineWidth(3); - - const QColor bgColor(30,30,50); - - QPalette p = palette(); - p.setColor(backgroundRole(), bgColor); - setPalette(p); - - QwtSplineCurveFitter* curveFitter; - - // - // curve 1 - // - int i = 0; - xMap[i].setScaleInterval(-1.5, 1.5); - yMap[i].setScaleInterval(0.0, 6.28); - - curve[i].setPen(QPen(QColor(150,150,200),2)); - curve[i].setStyle(QwtPlotCurve::Lines); - curve[i].setCurveAttribute(QwtPlotCurve::Fitted, true); - curveFitter = new QwtSplineCurveFitter(); - curveFitter->setSplineSize(150); - curve[i].setCurveFitter(curveFitter); - - QwtSymbol *symbol = new QwtSymbol(QwtSymbol::XCross); - symbol->setPen(QPen(Qt::yellow,2)); - symbol->setSize(7); - - curve[i].setSymbol(symbol); - - curve[i].setRawSamples(yval,xval,Size); - - // - // curve 2 - // - i++; - xMap[i].setScaleInterval(0.0, 6.28); - yMap[i].setScaleInterval(-3.0, 1.1); - curve[i].setPen(QPen(QColor(200,150,50))); - curve[i].setStyle(QwtPlotCurve::Sticks); - curve[i].setSymbol(new QwtSymbol(QwtSymbol::Ellipse, - QColor(Qt::blue), QColor(Qt::yellow), QSize(5,5))); - - curve[i].setRawSamples(xval,zval,Size); - - - // - // curve 3 - // - i++; - xMap[i].setScaleInterval(-1.1, 3.0); - yMap[i].setScaleInterval(-1.1, 3.0); - curve[i].setStyle(QwtPlotCurve::Lines); - curve[i].setCurveAttribute(QwtPlotCurve::Fitted, true); - curve[i].setPen(QColor(100,200,150)); - curveFitter = new QwtSplineCurveFitter(); - curveFitter->setFitMode(QwtSplineCurveFitter::ParametricSpline); - curveFitter->setSplineSize(200); - curve[i].setCurveFitter(curveFitter); - - curve[i].setRawSamples(yval,zval,Size); - - - // - // curve 4 - // - i++; - xMap[i].setScaleInterval(-5, 1.1); - yMap[i].setScaleInterval(-1.1, 5.0); - curve[i].setStyle(QwtPlotCurve::Lines); - curve[i].setCurveAttribute(QwtPlotCurve::Fitted, true); - curve[i].setPen(QColor(Qt::red)); - curveFitter = new QwtSplineCurveFitter(); - curveFitter->setSplineSize(200); - curve[i].setCurveFitter(curveFitter); - - curve[i].setRawSamples(uval,vval,USize); - - // - // initialize values - // - double base = 2.0 * M_PI / double(USize - 1); - double toggle = 1.0; - for (i = 0; i < USize; i++) - { - uval[i] = toggle * qCos( double(i) * base); - vval[i] = toggle * qSin( double(i) * base); - - if (toggle == 1.0) - toggle = 0.5; - else - toggle = 1.0; - } - - newValues(); - - // - // start timer - // - (void)startTimer(250); -} - -void MainWin::paintEvent(QPaintEvent *event) -{ - QFrame::paintEvent(event); - - QPainter painter(this); - painter.setClipRect(contentsRect()); - drawContents(&painter); -} - -void MainWin::drawContents(QPainter *painter) -{ - const QRect &r = contentsRect(); - - for ( int i = 0; i < curveCount; i++ ) - { - xMap[i].setPaintInterval(r.left(), r.right()); - yMap[i].setPaintInterval(r.top(), r.bottom()); - curve[i].draw(painter, xMap[i], yMap[i], r); - } -} - -// -// TIMER EVENT -// -void MainWin::timerEvent(QTimerEvent *) -{ - newValues(); - repaint(); -} - -// -// RE-CALCULATE VALUES -// -void MainWin::newValues() -{ - int i; - static double phs = 0.0; - double s,c,u; - - for (i=0;i 6.28) - phs = 0.0; - -} - -int main (int argc, char **argv) -{ - QApplication a(argc, argv); - - MainWin w; - - w.resize(300,300); - w.show(); - - return a.exec(); -} diff --git a/qwt/examples/curvdemo2/curvdemo2.h b/qwt/examples/curvdemo2/curvdemo2.h deleted file mode 100644 index f8612c860..000000000 --- a/qwt/examples/curvdemo2/curvdemo2.h +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include - -class MainWin : public QFrame -{ -public: - enum { curveCount = 4 }; - - QwtScaleMap xMap[curveCount]; - QwtScaleMap yMap[curveCount]; - QwtPlotCurve curve[curveCount]; - -public: - MainWin(); - -protected: - virtual void timerEvent(QTimerEvent *t); - virtual void paintEvent(QPaintEvent *); - virtual void drawContents(QPainter *); - -private: - void newValues(); -}; diff --git a/qwt/examples/curvdemo2/curvdemo2.pro b/qwt/examples/curvdemo2/curvdemo2.pro deleted file mode 100644 index 2418a7388..000000000 --- a/qwt/examples/curvdemo2/curvdemo2.pro +++ /dev/null @@ -1,18 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = curvdemo2 - -HEADERS = \ - curvdemo2.h - -SOURCES = \ - curvdemo2.cpp diff --git a/qwt/examples/dials/attitude_indicator.cpp b/qwt/examples/dials/attitude_indicator.cpp deleted file mode 100644 index 10b26ca69..000000000 --- a/qwt/examples/dials/attitude_indicator.cpp +++ /dev/null @@ -1,125 +0,0 @@ -#include "attitude_indicator.h" -#include -#include -#include -#include - -AttitudeIndicatorNeedle::AttitudeIndicatorNeedle(const QColor &c) -{ - QPalette palette; - for ( int i = 0; i < QPalette::NColorGroups; i++ ) - { - palette.setColor((QPalette::ColorGroup)i, - QPalette::Text, c); - } - setPalette(palette); -} - -void AttitudeIndicatorNeedle::drawNeedle(QPainter *painter, - double length, QPalette::ColorGroup colorGroup) const -{ - double triangleSize = length * 0.1; - double pos = length - 2.0; - - QPainterPath path; - path.moveTo( pos, 0 ); - path.lineTo( pos - 2 * triangleSize, triangleSize ); - path.lineTo( pos - 2 * triangleSize, -triangleSize ); - path.closeSubpath(); - - painter->setBrush( palette().brush(colorGroup, QPalette::Text ) ); - painter->drawPath( path ); - - double l = length - 2; - painter->setPen( QPen(palette().color( colorGroup, QPalette::Text ), 3) ); - painter->drawLine( 0, -l, 0, l ); -} - -AttitudeIndicator::AttitudeIndicator( - QWidget *parent): - QwtDial(parent), - d_gradient(0.0) -{ - setMode(RotateScale); - setWrapping(true); - - setOrigin(270.0); - setScaleComponents( QwtAbstractScaleDraw::Ticks ); - setScale(0, 0, 30.0); - - const QColor color = palette().color(QPalette::Text); - setNeedle(new AttitudeIndicatorNeedle(color)); -} - -void AttitudeIndicator::setGradient(double gradient) -{ - if ( gradient < -1.0 ) - gradient = -1.0; - else if ( gradient > 1.0 ) - gradient = 1.0; - - if ( d_gradient != gradient ) - { - d_gradient = gradient; - update(); - } -} - -void AttitudeIndicator::drawScale(QPainter *painter, const QPointF ¢er, - double radius, double origin, double minArc, double maxArc) const -{ - // counter clockwise, radian - - const double dir = (360.0 - origin) * M_PI / 180.0; - const double offset = 4.0; - - const QPointF p0 = qwtPolar2Pos( center, offset, dir + M_PI ); - - const double w = innerRect().width(); - - QPainterPath path; - path.moveTo( qwtPolar2Pos( p0, w, dir - M_PI_2 ) ); - path.lineTo( qwtPolar2Pos( path.currentPosition(), 2 * w, dir + M_PI_2 ) ); - path.lineTo( qwtPolar2Pos( path.currentPosition(), w, dir ) ); - path.lineTo( qwtPolar2Pos( path.currentPosition(), w, dir - M_PI_2 ) ); - - painter->save(); - painter->setClipPath( path ); // swallow 180 - 360 degrees - - QwtDial::drawScale(painter, - center, radius, origin, minArc, maxArc); - - painter->restore(); -} - -void AttitudeIndicator::drawScaleContents(QPainter *painter, - const QPointF &, double) const -{ - int dir = 360 - qRound(origin() - value()); // counter clockwise - int arc = 90 + qRound(gradient() * 90); - - const QColor skyColor(38, 151, 221); - - painter->save(); - painter->setBrush(skyColor); - painter->drawChord(scaleInnerRect(), - (dir - arc) * 16, 2 * arc * 16 ); - painter->restore(); -} - -void AttitudeIndicator::keyPressEvent(QKeyEvent *e) -{ - switch(e->key()) - { - case Qt::Key_Plus: - setGradient(gradient() + 0.05); - break; - - case Qt::Key_Minus: - setGradient(gradient() - 0.05); - break; - - default: - QwtDial::keyPressEvent(e); - } -} diff --git a/qwt/examples/dials/attitude_indicator.h b/qwt/examples/dials/attitude_indicator.h deleted file mode 100644 index 57aa5c4c4..000000000 --- a/qwt/examples/dials/attitude_indicator.h +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include - -class AttitudeIndicatorNeedle: public QwtDialNeedle -{ -public: - AttitudeIndicatorNeedle(const QColor &); - -protected: - virtual void drawNeedle(QPainter *, - double length, QPalette::ColorGroup) const; -}; - -class AttitudeIndicator: public QwtDial -{ - Q_OBJECT - -public: - AttitudeIndicator(QWidget *parent = NULL); - - double angle() const { return value(); } - double gradient() const { return d_gradient; } - -public Q_SLOTS: - void setGradient(double); - void setAngle(double angle) { setValue(angle); } - -protected: - virtual void keyPressEvent(QKeyEvent *); - - virtual void drawScale(QPainter *, const QPointF ¢er, - double radius, double origin, double arcMin, double arcMax) const; - - virtual void drawScaleContents(QPainter *painter, - const QPointF ¢er, double radius) const; - -private: - double d_gradient; -}; diff --git a/qwt/examples/dials/cockpit_grid.cpp b/qwt/examples/dials/cockpit_grid.cpp deleted file mode 100644 index 324ef48e1..000000000 --- a/qwt/examples/dials/cockpit_grid.cpp +++ /dev/null @@ -1,193 +0,0 @@ -#include -#include -#include -#include "attitude_indicator.h" -#include "speedo_meter.h" -#include "cockpit_grid.h" - -CockpitGrid::CockpitGrid(QWidget *parent): - QFrame(parent) -{ - setAutoFillBackground(true); - - setPalette(colorTheme(QColor(Qt::darkGray).dark(150))); - - QGridLayout *layout = new QGridLayout(this); - layout->setSpacing(5); - layout->setMargin(0); - - int i; - for ( i = 0; i < 3; i++ ) - { - QwtDial *dial = createDial(i); - layout->addWidget(dial, 0, i); - } - - for ( i = 0; i < layout->columnCount(); i++ ) - layout->setColumnStretch(i, 1); -} - -QwtDial *CockpitGrid::createDial(int pos) -{ - QwtDial *dial = NULL; - switch(pos) - { - case 0: - { - d_clock = new QwtAnalogClock(this); - - const QColor knobColor = QColor(Qt::gray).light(130); - - for ( int i = 0; i < QwtAnalogClock::NHands; i++) - { - QColor handColor = QColor(Qt::gray).light(150); - int width = 8; - - if ( i == QwtAnalogClock::SecondHand ) - { - handColor = Qt::gray; - width = 5; - } - - QwtDialSimpleNeedle *hand = new QwtDialSimpleNeedle( - QwtDialSimpleNeedle::Arrow, true, handColor, knobColor); - hand->setWidth(width); - - d_clock->setHand((QwtAnalogClock::Hand)i, hand); - } - - QTimer *timer = new QTimer(d_clock); - timer->connect(timer, SIGNAL(timeout()), - d_clock, SLOT(setCurrentTime())); - timer->start(1000); - - dial = d_clock; - break; - } - case 1: - { - d_speedo = new SpeedoMeter(this); - d_speedo->setRange(0.0, 240.0); - d_speedo->setScale(-1, 2, 20); - - QTimer *timer = new QTimer(d_speedo); - timer->connect(timer, SIGNAL(timeout()), - this, SLOT(changeSpeed())); - timer->start(50); - - dial = d_speedo; - break; - } - case 2: - { - d_ai = new AttitudeIndicator(this); - - QTimer *gradientTimer = new QTimer(d_ai); - gradientTimer->connect(gradientTimer, SIGNAL(timeout()), - this, SLOT(changeGradient())); - gradientTimer->start(100); - - QTimer *angleTimer = new QTimer(d_ai); - angleTimer->connect(angleTimer, SIGNAL(timeout()), - this, SLOT(changeAngle())); - angleTimer->start(100); - - dial = d_ai; - break; - } - - } - - if ( dial ) - { - dial->setReadOnly(true); - dial->scaleDraw()->setPenWidth(3); - dial->setLineWidth(4); - dial->setFrameShadow(QwtDial::Sunken); - } - return dial; -} - -QPalette CockpitGrid::colorTheme(const QColor &base) const -{ - const QColor background = base.dark(150); - const QColor foreground = base.dark(200); - - const QColor mid = base.dark(110); - const QColor dark = base.dark(170); - const QColor light = base.light(170); - const QColor text = foreground.light(800); - - QPalette palette; - for ( int i = 0; i < QPalette::NColorGroups; i++ ) - { - QPalette::ColorGroup cg = (QPalette::ColorGroup)i; - - palette.setColor(cg, QPalette::Base, base); - palette.setColor(cg, QPalette::Window, background); - palette.setColor(cg, QPalette::Mid, mid); - palette.setColor(cg, QPalette::Light, light); - palette.setColor(cg, QPalette::Dark, dark); - palette.setColor(cg, QPalette::Text, text); - palette.setColor(cg, QPalette::WindowText, foreground); - } - - return palette; -} - -void CockpitGrid::changeSpeed() -{ - static double offset = 0.8; - - double speed = d_speedo->value(); - - if ( (speed < 40.0 && offset < 0.0 ) || - (speed > 160.0 && offset > 0.0) ) - { - offset = -offset; - } - - static int counter = 0; - switch(counter++ % 12 ) - { - case 0: - case 2: - case 7: - case 8: - break; - default: - d_speedo->setValue(speed + offset); - } -} - -void CockpitGrid::changeAngle() -{ - static double offset = 0.05; - - double angle = d_ai->angle(); - if ( angle > 180.0 ) - angle -= 360.0; - - if ( (angle < -5.0 && offset < 0.0 ) || - (angle > 5.0 && offset > 0.0) ) - { - offset = -offset; - } - - d_ai->setAngle(angle + offset); -} - -void CockpitGrid::changeGradient() -{ - static double offset = 0.005; - - double gradient = d_ai->gradient(); - - if ( (gradient < -0.05 && offset < 0.0 ) || - (gradient > 0.05 && offset > 0.0) ) - { - offset = -offset; - } - - d_ai->setGradient(gradient + offset); -} diff --git a/qwt/examples/dials/cockpit_grid.h b/qwt/examples/dials/cockpit_grid.h deleted file mode 100644 index de088261b..000000000 --- a/qwt/examples/dials/cockpit_grid.h +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -class QwtDial; -class QwtAnalogClock; -class SpeedoMeter; -class AttitudeIndicator; - -class CockpitGrid: public QFrame -{ - Q_OBJECT - -public: - CockpitGrid(QWidget *parent = NULL); - -private Q_SLOTS: - void changeSpeed(); - void changeGradient(); - void changeAngle(); - -private: - QPalette colorTheme(const QColor &) const; - QwtDial *createDial(int pos); - - QwtAnalogClock *d_clock; - SpeedoMeter *d_speedo; - AttitudeIndicator *d_ai; -}; diff --git a/qwt/examples/dials/compass_grid.cpp b/qwt/examples/dials/compass_grid.cpp deleted file mode 100644 index 1344818f6..000000000 --- a/qwt/examples/dials/compass_grid.cpp +++ /dev/null @@ -1,202 +0,0 @@ -#include -#include -#include -#include -#include "compass_grid.h" - -CompassGrid::CompassGrid(QWidget *parent): - QFrame(parent) -{ - QPalette p = palette(); - p.setColor(backgroundRole(), Qt::gray); - setPalette(p); - - setAutoFillBackground(true); - - QGridLayout *layout = new QGridLayout(this); - layout->setSpacing(5); - layout->setMargin(0); - - int i; - for ( i = 0; i < 6; i++ ) - { - QwtCompass *compass = createCompass(i); - layout->addWidget(compass, i / 3, i % 3); - } - - for ( i = 0; i < layout->columnCount(); i++ ) - layout->setColumnStretch(i, 1); -} - -QwtCompass *CompassGrid::createCompass(int pos) -{ - int c; - - QPalette colorGroup; - for ( c = 0; c < QPalette::NColorRoles; c++ ) - colorGroup.setColor((QPalette::ColorRole)c, QColor()); - - colorGroup.setColor(QPalette::Base, - palette().color(backgroundRole()).light(120)); - colorGroup.setColor(QPalette::WindowText, - colorGroup.color(QPalette::Base)); - - QwtCompass *compass = new QwtCompass(this); - compass->setLineWidth(4); - compass->setFrameShadow( - pos <= 2 ? QwtCompass::Sunken : QwtCompass::Raised); - - switch(pos) - { - case 0: - { - /* - A compass with a rose and no needle. Scale and rose are - rotating. - */ - compass->setMode(QwtCompass::RotateScale); - - QwtSimpleCompassRose *rose = new QwtSimpleCompassRose(16, 2); - rose->setWidth(0.15); - - compass->setRose(rose); - break; - } - case 1: - { - /* - A windrose, with a scale indicating the main directions only - */ - QMap map; - map.insert(0.0, "N"); - map.insert(90.0, "E"); - map.insert(180.0, "S"); - map.insert(270.0, "W"); - - compass->setLabelMap(map); - - QwtSimpleCompassRose *rose = new QwtSimpleCompassRose(4, 1); - compass->setRose(rose); - - compass->setNeedle( - new QwtCompassWindArrow(QwtCompassWindArrow::Style2)); - compass->setValue(60.0); - break; - } - case 2: - { - /* - A compass with a rotating needle in darkBlue. Shows - a ticks for each degree. - */ - - colorGroup.setColor(QPalette::Base, Qt::darkBlue); - colorGroup.setColor(QPalette::WindowText, - QColor(Qt::darkBlue).dark(120)); - colorGroup.setColor(QPalette::Text, Qt::white); - - compass->setScaleComponents( - QwtAbstractScaleDraw::Ticks | QwtAbstractScaleDraw::Labels); - compass->setScaleTicks(1, 1, 3); - compass->setScale(36, 5, 0); - - compass->setNeedle( - new QwtCompassMagnetNeedle(QwtCompassMagnetNeedle::ThinStyle)); - compass->setValue(220.0); - - break; - } - case 3: - { - /* - A compass without a frame, showing numbers as tick labels. - The origin is at 220.0 - */ - colorGroup.setColor(QPalette::Base, - palette().color(backgroundRole())); - colorGroup.setColor(QPalette::WindowText, Qt::blue); - - compass->setLineWidth(0); - - compass->setScaleComponents( QwtAbstractScaleDraw::Backbone | - QwtAbstractScaleDraw::Ticks | QwtAbstractScaleDraw::Labels ); - compass->setScaleTicks(0, 0, 3); - - QMap map; - for ( double d = 0.0; d < 360.0; d += 60.0 ) - { - QString label; - label.sprintf("%.0f", d); - map.insert(d, label); - } - compass->setLabelMap(map); - compass->setScale(36, 5, 0); - - compass->setNeedle(new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Ray, - true, Qt::white)); - compass->setOrigin(220.0); - compass->setValue(20.0); - break; - } - case 4: - { - /* - A compass showing another needle - */ - compass->setScaleComponents( - QwtAbstractScaleDraw::Ticks | QwtAbstractScaleDraw::Labels ); - compass->setScaleTicks(0, 0, 3); - - compass->setNeedle(new QwtCompassMagnetNeedle( - QwtCompassMagnetNeedle::TriangleStyle, Qt::white, Qt::red)); - compass->setValue(220.0); - break; - } - case 5: - { - /* - A compass with a yellow on black ray - */ - colorGroup.setColor(QPalette::WindowText, Qt::black); - - compass->setNeedle(new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Ray, - false, Qt::yellow)); - compass->setValue(315.0); - break; - } - } - - QPalette newPalette = compass->palette(); - for ( c = 0; c < QPalette::NColorRoles; c++ ) - { - if ( colorGroup.color((QPalette::ColorRole)c).isValid() ) - { - for ( int cg = 0; cg < QPalette::NColorGroups; cg++ ) - { - newPalette.setColor( - (QPalette::ColorGroup)cg, - (QPalette::ColorRole)c, - colorGroup.color((QPalette::ColorRole)c)); - } - } - } - - for ( int i = 0; i < QPalette::NColorGroups; i++ ) - { - QPalette::ColorGroup cg = (QPalette::ColorGroup)i; - - const QColor light = - newPalette.color(cg, QPalette::Base).light(170); - const QColor dark = newPalette.color(cg, QPalette::Base).dark(170); - const QColor mid = compass->frameShadow() == QwtDial::Raised - ? newPalette.color(cg, QPalette::Base).dark(110) - : newPalette.color(cg, QPalette::Base).light(110); - - newPalette.setColor(cg, QPalette::Dark, dark); - newPalette.setColor(cg, QPalette::Mid, mid); - newPalette.setColor(cg, QPalette::Light, light); - } - compass->setPalette(newPalette); - - return compass; -} diff --git a/qwt/examples/dials/compass_grid.h b/qwt/examples/dials/compass_grid.h deleted file mode 100644 index 912cac107..000000000 --- a/qwt/examples/dials/compass_grid.h +++ /dev/null @@ -1,11 +0,0 @@ -#include -class QwtCompass; - -class CompassGrid: public QFrame -{ -public: - CompassGrid(QWidget *parent = NULL); - -private: - QwtCompass *createCompass(int pos); -}; diff --git a/qwt/examples/dials/dials.cpp b/qwt/examples/dials/dials.cpp deleted file mode 100644 index 40ef20853..000000000 --- a/qwt/examples/dials/dials.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include "compass_grid.h" -#include "cockpit_grid.h" - -//----------------------------------------------------------------- -// -// dials.cpp -- A demo program featuring QwtDial and friends -// -//----------------------------------------------------------------- - -int main (int argc, char **argv) -{ - QApplication a(argc, argv); - - QTabWidget tabWidget; - tabWidget.addTab(new CompassGrid, "Compass"); - tabWidget.addTab(new CockpitGrid, "Cockpit"); - - tabWidget.show(); - - return a.exec(); -} diff --git a/qwt/examples/dials/dials.pro b/qwt/examples/dials/dials.pro deleted file mode 100644 index 1d4a6a43b..000000000 --- a/qwt/examples/dials/dials.pro +++ /dev/null @@ -1,25 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = dials - -HEADERS = \ - attitude_indicator.h \ - speedo_meter.h \ - cockpit_grid.h \ - compass_grid.h - -SOURCES = \ - attitude_indicator.cpp \ - speedo_meter.cpp \ - cockpit_grid.cpp \ - compass_grid.cpp \ - dials.cpp diff --git a/qwt/examples/dials/speedo_meter.cpp b/qwt/examples/dials/speedo_meter.cpp deleted file mode 100644 index 66f8785b1..000000000 --- a/qwt/examples/dials/speedo_meter.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#include "speedo_meter.h" - -SpeedoMeter::SpeedoMeter(QWidget *parent): - QwtDial(parent), - d_label("km/h") -{ - setWrapping(false); - setReadOnly(true); - - setOrigin(135.0); - setScaleArc(0.0, 270.0); - scaleDraw()->setSpacing(8); - - QwtDialSimpleNeedle *needle = new QwtDialSimpleNeedle( - QwtDialSimpleNeedle::Arrow, true, Qt::red, - QColor(Qt::gray).light(130)); - setNeedle(needle); - - setScaleComponents( - QwtAbstractScaleDraw::Ticks | QwtAbstractScaleDraw::Labels); - setScaleTicks(0, 4, 8); -} - -void SpeedoMeter::setLabel(const QString &label) -{ - d_label = label; - update(); -} - -QString SpeedoMeter::label() const -{ - return d_label; -} - -void SpeedoMeter::drawScaleContents(QPainter *painter, - const QPointF ¢er, double radius) const -{ - QRectF rect( 0.0, 0.0, 2.0 * radius, 2.0 * radius - 10.0); - rect.moveCenter(center); - - const QColor color = palette().color(QPalette::Text); - painter->setPen(color); - - const int flags = Qt::AlignBottom | Qt::AlignHCenter; - painter->drawText(rect, flags, d_label); -} diff --git a/qwt/examples/dials/speedo_meter.h b/qwt/examples/dials/speedo_meter.h deleted file mode 100644 index 24653a493..000000000 --- a/qwt/examples/dials/speedo_meter.h +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -class SpeedoMeter: public QwtDial -{ -public: - SpeedoMeter(QWidget *parent = NULL); - - void setLabel(const QString &); - QString label() const; - -protected: - virtual void drawScaleContents(QPainter *painter, - const QPointF ¢er, double radius) const; - -private: - QString d_label; -}; diff --git a/qwt/examples/event_filter/README b/qwt/examples/event_filter/README deleted file mode 100644 index 05fc24205..000000000 --- a/qwt/examples/event_filter/README +++ /dev/null @@ -1,27 +0,0 @@ -QwtPlot is a composite widget consisting of a title label, -the canvas, the scales and a legend. Although all components -should be exchangable some day, the current design isn´t ready for it. - -In this situation event filtering is the mechanism to extend the behaviour -of the plot components. event_filter shows 3 examples how to use it: - -1) CanvasPicker - -The CanvasPicker implements a solution, how to move points on the canvas -with mouse and keyboard. - -2) ScalePicker - -The ScalePicker translates the position of mouse clicks on the scales -and emits them as signals. - -3) Plot: ColorBar, QSlider - -The Plot class shows how to add widgets to the scales. In this example -there is no filter class. The derived plot widget filters its components. - - -Please note that CanvasPicker and ScalePicker are standalone classes -that could be connected with your QwtPlot as well. - -Uwe diff --git a/qwt/examples/event_filter/canvaspicker.cpp b/qwt/examples/event_filter/canvaspicker.cpp deleted file mode 100644 index bab21714c..000000000 --- a/qwt/examples/event_filter/canvaspicker.cpp +++ /dev/null @@ -1,328 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "canvaspicker.h" - -CanvasPicker::CanvasPicker(QwtPlot *plot): - QObject(plot), - d_selectedCurve(NULL), - d_selectedPoint(-1) -{ - QwtPlotCanvas *canvas = plot->canvas(); - - canvas->installEventFilter(this); - - // We want the focus, but no focus rect. The - // selected point will be highlighted instead. - - canvas->setFocusPolicy(Qt::StrongFocus); -#ifndef QT_NO_CURSOR - canvas->setCursor(Qt::PointingHandCursor); -#endif - canvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator); - canvas->setFocus(); - - const char *text = - "All points can be moved using the left mouse button " - "or with these keys:\n\n" - "- Up:\t\tSelect next curve\n" - "- Down:\t\tSelect previous curve\n" - "- Left, ´-´:\tSelect next point\n" - "- Right, ´+´:\tSelect previous point\n" - "- 7, 8, 9, 4, 6, 1, 2, 3:\tMove selected point"; - canvas->setWhatsThis(text); - - shiftCurveCursor(true); -} - -bool CanvasPicker::event(QEvent *e) -{ - if ( e->type() == QEvent::User ) - { - showCursor(true); - return true; - } - return QObject::event(e); -} - -bool CanvasPicker::eventFilter(QObject *object, QEvent *e) -{ - if ( object != (QObject *)plot()->canvas() ) - return false; - - switch(e->type()) - { - case QEvent::FocusIn: - showCursor(true); - case QEvent::FocusOut: - showCursor(false); - - case QEvent::Paint: - { - QApplication::postEvent(this, new QEvent(QEvent::User)); - break; - } - case QEvent::MouseButtonPress: - { - select(((QMouseEvent *)e)->pos()); - return true; - } - case QEvent::MouseMove: - { - move(((QMouseEvent *)e)->pos()); - return true; - } - case QEvent::KeyPress: - { - const int delta = 5; - switch(((const QKeyEvent *)e)->key()) - { - case Qt::Key_Up: - shiftCurveCursor(true); - return true; - - case Qt::Key_Down: - shiftCurveCursor(false); - return true; - - case Qt::Key_Right: - case Qt::Key_Plus: - if ( d_selectedCurve ) - shiftPointCursor(true); - else - shiftCurveCursor(true); - return true; - - case Qt::Key_Left: - case Qt::Key_Minus: - if ( d_selectedCurve ) - shiftPointCursor(false); - else - shiftCurveCursor(true); - return true; - - // The following keys represent a direction, they are - // organized on the keyboard. - - case Qt::Key_1: - moveBy(-delta, delta); - break; - case Qt::Key_2: - moveBy(0, delta); - break; - case Qt::Key_3: - moveBy(delta, delta); - break; - case Qt::Key_4: - moveBy(-delta, 0); - break; - case Qt::Key_6: - moveBy(delta, 0); - break; - case Qt::Key_7: - moveBy(-delta, -delta); - break; - case Qt::Key_8: - moveBy(0, -delta); - break; - case Qt::Key_9: - moveBy(delta, -delta); - break; - default: - break; - } - } - default: - break; - } - return QObject::eventFilter(object, e); -} - -// Select the point at a position. If there is no point -// deselect the selected point - -void CanvasPicker::select(const QPoint &pos) -{ - QwtPlotCurve *curve = NULL; - double dist = 10e10; - int index = -1; - - const QwtPlotItemList& itmList = plot()->itemList(); - for ( QwtPlotItemIterator it = itmList.begin(); - it != itmList.end(); ++it ) - { - if ( (*it)->rtti() == QwtPlotItem::Rtti_PlotCurve ) - { - QwtPlotCurve *c = (QwtPlotCurve*)(*it); - - double d; - int idx = c->closestPoint(pos, &d); - if ( d < dist ) - { - curve = c; - index = idx; - dist = d; - } - } - } - - showCursor(false); - d_selectedCurve = NULL; - d_selectedPoint = -1; - - if ( curve && dist < 10 ) // 10 pixels tolerance - { - d_selectedCurve = curve; - d_selectedPoint = index; - showCursor(true); - } -} - -// Move the selected point -void CanvasPicker::moveBy(int dx, int dy) -{ - if ( dx == 0 && dy == 0 ) - return; - - if ( !d_selectedCurve ) - return; - - const QPointF sample = - d_selectedCurve->sample(d_selectedPoint); - - const double x = plot()->transform( - d_selectedCurve->xAxis(), sample.x()); - const double y = plot()->transform( - d_selectedCurve->yAxis(), sample.y()); - - move( QPoint(qRound(x + dx), qRound(y + dy)) ); -} - -// Move the selected point -void CanvasPicker::move(const QPoint &pos) -{ - if ( !d_selectedCurve ) - return; - - QVector xData(d_selectedCurve->dataSize()); - QVector yData(d_selectedCurve->dataSize()); - - for ( int i = 0; i < (int)d_selectedCurve->dataSize(); i++ ) - { - if ( i == d_selectedPoint ) - { - xData[i] = plot()->invTransform( - d_selectedCurve->xAxis(), pos.x()); - yData[i] = plot()->invTransform( - d_selectedCurve->yAxis(), pos.y()); - } - else - { - const QPointF sample = d_selectedCurve->sample(i); - xData[i] = sample.x(); - yData[i] = sample.y(); - } - } - d_selectedCurve->setSamples(xData, yData); - - /* - Enable QwtPlotCanvas::ImmediatePaint, so that the canvas has been - updated before we paint the cursor on it. - */ - plot()->canvas()->setPaintAttribute( QwtPlotCanvas::ImmediatePaint, true); - plot()->replot(); - plot()->canvas()->setPaintAttribute( QwtPlotCanvas::ImmediatePaint, false); - - showCursor(true); -} - -// Hightlight the selected point -void CanvasPicker::showCursor(bool showIt) -{ - if ( !d_selectedCurve ) - return; - - QwtSymbol *symbol = const_cast( d_selectedCurve->symbol() ); - - const QBrush brush = symbol->brush(); - if ( showIt ) - symbol->setBrush(symbol->brush().color().dark(180)); - - QwtPlotDirectPainter directPainter; - directPainter.drawSeries(d_selectedCurve, d_selectedPoint, d_selectedPoint); - - if ( showIt ) - symbol->setBrush(brush); // reset brush -} - -// Select the next/previous curve -void CanvasPicker::shiftCurveCursor(bool up) -{ - QwtPlotItemIterator it; - - const QwtPlotItemList &itemList = plot()->itemList(); - - QwtPlotItemList curveList; - for ( it = itemList.begin(); it != itemList.end(); ++it ) - { - if ( (*it)->rtti() == QwtPlotItem::Rtti_PlotCurve ) - curveList += *it; - } - if ( curveList.isEmpty() ) - return; - - it = curveList.begin(); - - if ( d_selectedCurve ) - { - for ( it = curveList.begin(); it != curveList.end(); ++it ) - { - if ( d_selectedCurve == *it ) - break; - } - if ( it == curveList.end() ) // not found - it = curveList.begin(); - - if ( up ) - { - ++it; - if ( it == curveList.end() ) - it = curveList.begin(); - } - else - { - if ( it == curveList.begin() ) - it = curveList.end(); - --it; - } - } - - showCursor(false); - d_selectedPoint = 0; - d_selectedCurve = (QwtPlotCurve *)*it; - showCursor(true); -} - -// Select the next/previous neighbour of the selected point -void CanvasPicker::shiftPointCursor(bool up) -{ - if ( !d_selectedCurve ) - return; - - int index = d_selectedPoint + (up ? 1 : -1); - index = (index + d_selectedCurve->dataSize()) % d_selectedCurve->dataSize(); - - if ( index != d_selectedPoint ) - { - showCursor(false); - d_selectedPoint = index; - showCursor(true); - } -} diff --git a/qwt/examples/event_filter/canvaspicker.h b/qwt/examples/event_filter/canvaspicker.h deleted file mode 100644 index 89113829d..000000000 --- a/qwt/examples/event_filter/canvaspicker.h +++ /dev/null @@ -1,33 +0,0 @@ -#include - -class QPoint; -class QCustomEvent; -class QwtPlot; -class QwtPlotCurve; - -class CanvasPicker: public QObject -{ - Q_OBJECT -public: - CanvasPicker(QwtPlot *plot); - virtual bool eventFilter(QObject *, QEvent *); - - virtual bool event(QEvent *); - -private: - void select(const QPoint &); - void move(const QPoint &); - void moveBy(int dx, int dy); - - void release(); - - void showCursor(bool enable); - void shiftPointCursor(bool up); - void shiftCurveCursor(bool up); - - QwtPlot *plot() { return (QwtPlot *)parent(); } - const QwtPlot *plot() const { return (QwtPlot *)parent(); } - - QwtPlotCurve *d_selectedCurve; - int d_selectedPoint; -}; diff --git a/qwt/examples/event_filter/colorbar.cpp b/qwt/examples/event_filter/colorbar.cpp deleted file mode 100644 index 8d24ddd3c..000000000 --- a/qwt/examples/event_filter/colorbar.cpp +++ /dev/null @@ -1,111 +0,0 @@ -#include -#include -#include -#include -#include "colorbar.h" - -ColorBar::ColorBar(Qt::Orientation o, QWidget *parent): - QWidget(parent), - d_orientation(o), - d_light(Qt::white), - d_dark(Qt::black) -{ -#ifndef QT_NO_CURSOR - setCursor(Qt::PointingHandCursor); -#endif -} - -void ColorBar::setOrientation(Qt::Orientation o) -{ - d_orientation = o; - update(); -} - -void ColorBar::setLight(const QColor &light) -{ - d_light = light; - update(); -} - -void ColorBar::setDark(const QColor &dark) -{ - d_dark = dark; - update(); -} - -void ColorBar::setRange(const QColor &light, const QColor &dark) -{ - d_light = light; - d_dark = dark; - update(); -} - -void ColorBar::mousePressEvent(QMouseEvent *e) -{ - if( e->button() == Qt::LeftButton ) - { - // emit the color of the position where the mouse click - // happened - - const QPixmap pm = QPixmap::grabWidget(this); - const QRgb rgb = pm.toImage().pixel(e->x(), e->y()); - - Q_EMIT selected(QColor(rgb)); - e->accept(); - } -} - -void ColorBar::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - drawColorBar(&painter, rect()); -} - -void ColorBar::drawColorBar(QPainter *painter, const QRect &rect) const -{ - int h1, s1, v1; - int h2, s2, v2; - - d_light.getHsv(&h1, &s1, &v1); - d_dark.getHsv(&h2, &s2, &v2); - - painter->save(); - painter->setClipRect(rect); - painter->setClipping(true); - - painter->fillRect(rect, d_dark); - - const int sectionSize = 2; - - int numIntervalls; - if ( d_orientation == Qt::Horizontal ) - numIntervalls = rect.width() / sectionSize; - else - numIntervalls = rect.height() / sectionSize; - - for ( int i = 0; i < numIntervalls; i++ ) - { - QRect section; - if ( d_orientation == Qt::Horizontal ) - { - section.setRect(rect.x() + i * sectionSize, rect.y(), - sectionSize, rect.height()); - } - else - { - section.setRect(rect.x(), rect.y() + i * sectionSize, - rect.width(), sectionSize); - } - - const double ratio = i / (double)numIntervalls; - - QColor c; - c.setHsv( h1 + qRound(ratio * (h2 - h1)), - s1 + qRound(ratio * (s2 - s1)), - v1 + qRound(ratio * (v2 - v1)) ); - - painter->fillRect(section, c); - } - - painter->restore(); -} diff --git a/qwt/examples/event_filter/colorbar.h b/qwt/examples/event_filter/colorbar.h deleted file mode 100644 index cafb2040c..000000000 --- a/qwt/examples/event_filter/colorbar.h +++ /dev/null @@ -1,34 +0,0 @@ -#include - -class ColorBar: public QWidget -{ - Q_OBJECT - -public: - ColorBar(Qt::Orientation = Qt::Horizontal, - QWidget * = NULL); - - virtual void setOrientation(Qt::Orientation o); - Qt::Orientation orientation() const { return d_orientation; } - - void setRange(const QColor &light, const QColor &dark); - void setLight(const QColor &light); - void setDark(const QColor &dark); - - QColor light() const { return d_light; } - QColor dark() const { return d_dark; } - -Q_SIGNALS: - void selected(const QColor &); - -protected: - virtual void mousePressEvent(QMouseEvent *); - virtual void paintEvent(QPaintEvent *); - - void drawColorBar(QPainter *, const QRect &) const; - -private: - Qt::Orientation d_orientation; - QColor d_light; - QColor d_dark; -}; diff --git a/qwt/examples/event_filter/event_filter.cpp b/qwt/examples/event_filter/event_filter.cpp deleted file mode 100644 index 9a0e140fb..000000000 --- a/qwt/examples/event_filter/event_filter.cpp +++ /dev/null @@ -1,51 +0,0 @@ -//----------------------------------------------------------------- -// A demo program showing how to use event filtering -//----------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include "plot.h" -#include "canvaspicker.h" -#include "scalepicker.h" - -int main (int argc, char **argv) -{ - QApplication a(argc, argv); - - QMainWindow mainWindow; - QToolBar *toolBar = new QToolBar(&mainWindow); - QAction *action = QWhatsThis::createAction(toolBar); - toolBar->addAction(action); - mainWindow.addToolBar(toolBar); - - Plot *plot = new Plot(&mainWindow); - - // The canvas picker handles all mouse and key - // events on the plot canvas - - (void) new CanvasPicker(plot); - - // The scale picker translates mouse clicks - // int o clicked() signals - - ScalePicker *scalePicker = new ScalePicker(plot); - a.connect(scalePicker, SIGNAL(clicked(int, double)), - plot, SLOT(insertCurve(int, double))); - - mainWindow.setCentralWidget(plot); - - mainWindow.resize(540, 400); - mainWindow.show(); - - const char *text = - "An useless plot to demonstrate how to use event filtering.\n\n" - "You can click on the color bar, the scales or move the wheel.\n" - "All points can be moved using the mouse or the keyboard."; - plot->setWhatsThis(text); - - int rv = a.exec(); - return rv; -} diff --git a/qwt/examples/event_filter/event_filter.pro b/qwt/examples/event_filter/event_filter.pro deleted file mode 100644 index 008d9904d..000000000 --- a/qwt/examples/event_filter/event_filter.pro +++ /dev/null @@ -1,25 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = event_filter - -HEADERS = \ - colorbar.h \ - scalepicker.h \ - canvaspicker.h \ - plot.h - -SOURCES = \ - colorbar.cpp \ - scalepicker.cpp \ - canvaspicker.cpp \ - plot.cpp \ - event_filter.cpp diff --git a/qwt/examples/event_filter/plot.cpp b/qwt/examples/event_filter/plot.cpp deleted file mode 100644 index 1a013e248..000000000 --- a/qwt/examples/event_filter/plot.cpp +++ /dev/null @@ -1,176 +0,0 @@ -#include "plot.h" -#include "colorbar.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -Plot::Plot(QWidget *parent): - QwtPlot(parent) -{ - setTitle("Interactive Plot"); - - setCanvasColor(Qt::darkCyan); - - QwtPlotGrid *grid = new QwtPlotGrid; - grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine)); - grid->attach(this); - - // axes - - setAxisScale(QwtPlot::xBottom, 0.0, 100.0); - setAxisScale(QwtPlot::yLeft, 0.0, 100.0); - - // Avoid jumping when label with 3 digits - // appear/disappear when scrolling vertically - - QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); - sd->setMinimumExtent( sd->extent(axisWidget(QwtPlot::yLeft)->font())); - - plotLayout()->setAlignCanvasToScales(true); - - insertCurve(Qt::Vertical, Qt::blue, 30.0); - insertCurve(Qt::Vertical, Qt::magenta, 70.0); - insertCurve(Qt::Horizontal, Qt::yellow, 30.0); - insertCurve(Qt::Horizontal, Qt::white, 70.0); - - replot(); - - // ------------------------------------ - // We add a color bar to the left axis - // ------------------------------------ - - QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(yLeft); - scaleWidget->setMargin(10); // area for the color bar - d_colorBar = new ColorBar(Qt::Vertical, scaleWidget); - d_colorBar->setRange(Qt::red, Qt::darkBlue); - d_colorBar->setFocusPolicy(Qt::TabFocus); - - connect(d_colorBar, SIGNAL(selected(const QColor &)), - SLOT(setCanvasColor(const QColor &))); - - // we need the resize events, to lay out the color bar - scaleWidget->installEventFilter(this); - - // ------------------------------------ - // We add a wheel to the canvas - // ------------------------------------ - - d_wheel = new QwtWheel(canvas()); - d_wheel->setOrientation(Qt::Vertical); - d_wheel->setRange(-100, 100); - d_wheel->setValue(0.0); - d_wheel->setMass(0.2); - d_wheel->setTotalAngle(4 * 360.0); - - connect(d_wheel, SIGNAL(valueChanged(double)), - SLOT(scrollLeftAxis(double))); - - // we need the resize events, to lay out the wheel - canvas()->installEventFilter(this); - - d_colorBar->setWhatsThis( - "Selecting a color will change the background of the plot."); - scaleWidget->setWhatsThis( - "Selecting a value at the scale will insert a new curve."); - d_wheel->setWhatsThis( - "With the wheel you can move the visible area."); - axisWidget(xBottom)->setWhatsThis( - "Selecting a value at the scale will insert a new curve."); -} - -void Plot::setCanvasColor(const QColor &c) -{ - setCanvasBackground(c); - replot(); -} - -void Plot::scrollLeftAxis(double value) -{ - setAxisScale(yLeft, value, value + 100.0); - replot(); -} - -bool Plot::eventFilter(QObject *object, QEvent *e) -{ - if ( e->type() == QEvent::Resize ) - { - const QSize &size = ((QResizeEvent *)e)->size(); - if ( object == (QObject *)axisWidget(yLeft) ) - { - const QwtScaleWidget *scaleWidget = axisWidget(yLeft); - - const int margin = 2; - - // adjust the color bar to the scale backbone - const int x = size.width() - scaleWidget->margin() + margin; - const int w = scaleWidget->margin() - 2 * margin; - const int y = scaleWidget->startBorderDist(); - const int h = size.height() - - scaleWidget->startBorderDist() - scaleWidget->endBorderDist(); - - d_colorBar->setGeometry(x, y, w, h); - } - if ( object == canvas() ) - { - const int w = 16; - const int h = 50; - const int margin = 2; - - const QRect cr = canvas()->contentsRect(); - d_wheel->setGeometry( - cr.right() - margin - w, cr.center().y() - h / 2, w, h); - } - } - - return QwtPlot::eventFilter(object, e); -} - -void Plot::insertCurve(int axis, double base) -{ - Qt::Orientation o; - if ( axis == yLeft || axis == yRight ) - o = Qt::Horizontal; - else - o = Qt::Vertical; - - QRgb rgb = (uint)rand(); - insertCurve(o, QColor(rgb), base); - replot(); -} - -void Plot::insertCurve(Qt::Orientation o, - const QColor &c, double base) -{ - QwtPlotCurve *curve = new QwtPlotCurve(); - - curve->setPen(c); - curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse, - Qt::gray, c, QSize(8, 8))); - - double x[10]; - double y[sizeof(x) / sizeof(x[0])]; - - for ( uint i = 0; i < sizeof(x) / sizeof(x[0]); i++ ) - { - double v = 5.0 + i * 10.0; - if ( o == Qt::Horizontal ) - { - x[i] = v; - y[i] = base; - } - else - { - x[i] = base; - y[i] = v; - } - } - - curve->setSamples(x, y, sizeof(x) / sizeof(x[0])); - curve->attach(this); -} diff --git a/qwt/examples/event_filter/plot.h b/qwt/examples/event_filter/plot.h deleted file mode 100644 index 5a2f760ee..000000000 --- a/qwt/examples/event_filter/plot.h +++ /dev/null @@ -1,25 +0,0 @@ -#include - -class ColorBar; -class QwtWheel; - -class Plot: public QwtPlot -{ - Q_OBJECT -public: - Plot(QWidget *parent = NULL); - virtual bool eventFilter(QObject *, QEvent *); - -public Q_SLOTS: - void setCanvasColor(const QColor &); - void insertCurve(int axis, double base); - -private Q_SLOTS: - void scrollLeftAxis(double); - -private: - void insertCurve(Qt::Orientation, const QColor &, double base); - - ColorBar *d_colorBar; - QwtWheel *d_wheel; -}; diff --git a/qwt/examples/event_filter/scalepicker.cpp b/qwt/examples/event_filter/scalepicker.cpp deleted file mode 100644 index 5b2c81625..000000000 --- a/qwt/examples/event_filter/scalepicker.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include -#include -#include -#include "scalepicker.h" - -ScalePicker::ScalePicker(QwtPlot *plot): - QObject(plot) -{ - for ( uint i = 0; i < QwtPlot::axisCnt; i++ ) - { - QwtScaleWidget *scaleWidget = (QwtScaleWidget *)plot->axisWidget(i); - if ( scaleWidget ) - scaleWidget->installEventFilter(this); - } -} - -bool ScalePicker::eventFilter(QObject *object, QEvent *e) -{ - if ( object->inherits("QwtScaleWidget") && - e->type() == QEvent::MouseButtonPress ) - { - mouseClicked((const QwtScaleWidget *)object, - ((QMouseEvent *)e)->pos()); - return true; - } - - return QObject::eventFilter(object, e); -} - -void ScalePicker::mouseClicked(const QwtScaleWidget *scale, const QPoint &pos) -{ - QRect rect = scaleRect(scale); - - int margin = 10; // 10 pixels tolerance - rect.setRect(rect.x() - margin, rect.y() - margin, - rect.width() + 2 * margin, rect.height() + 2 * margin); - - if ( rect.contains(pos) ) // No click on the title - { - // translate the position in a value on the scale - - double value = 0.0; - int axis = -1; - - const QwtScaleDraw *sd = scale->scaleDraw(); - switch(scale->alignment()) - { - case QwtScaleDraw::LeftScale: - { - value = sd->scaleMap().invTransform(pos.y()); - axis = QwtPlot::yLeft; - break; - } - case QwtScaleDraw::RightScale: - { - value = sd->scaleMap().invTransform(pos.y()); - axis = QwtPlot::yRight; - break; - } - case QwtScaleDraw::BottomScale: - { - value = sd->scaleMap().invTransform(pos.x()); - axis = QwtPlot::xBottom; - break; - } - case QwtScaleDraw::TopScale: - { - value = sd->scaleMap().invTransform(pos.x()); - axis = QwtPlot::xTop; - break; - } - } - Q_EMIT clicked(axis, value); - } -} - -// The rect of a scale without the title -QRect ScalePicker::scaleRect(const QwtScaleWidget *scale) const -{ - const int bld = scale->margin(); - const int mjt = scale->scaleDraw()->maxTickLength(); - const int sbd = scale->startBorderDist(); - const int ebd = scale->endBorderDist(); - - QRect rect; - switch(scale->alignment()) - { - case QwtScaleDraw::LeftScale: - { - rect.setRect(scale->width() - bld - mjt, sbd, - mjt, scale->height() - sbd - ebd); - break; - } - case QwtScaleDraw::RightScale: - { - rect.setRect(bld, sbd, - mjt, scale->height() - sbd - ebd); - break; - } - case QwtScaleDraw::BottomScale: - { - rect.setRect(sbd, bld, - scale->width() - sbd - ebd, mjt); - break; - } - case QwtScaleDraw::TopScale: - { - rect.setRect(sbd, scale->height() - bld - mjt, - scale->width() - sbd - ebd, mjt); - break; - } - } - return rect; -} diff --git a/qwt/examples/event_filter/scalepicker.h b/qwt/examples/event_filter/scalepicker.h deleted file mode 100644 index b15fca1f5..000000000 --- a/qwt/examples/event_filter/scalepicker.h +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -class QwtPlot; -class QwtScaleWidget; - -class ScalePicker: public QObject -{ - Q_OBJECT -public: - ScalePicker(QwtPlot *plot); - virtual bool eventFilter(QObject *, QEvent *); - -Q_SIGNALS: - void clicked(int axis, double value); - -private: - void mouseClicked(const QwtScaleWidget *, const QPoint &); - QRect scaleRect(const QwtScaleWidget *) const; -}; diff --git a/qwt/examples/examples.pri b/qwt/examples/examples.pri deleted file mode 100644 index a6911c8de..000000000 --- a/qwt/examples/examples.pri +++ /dev/null @@ -1,49 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################### - -QWT_ROOT = $${PWD}/.. -include( $${QWT_ROOT}/qwtconfig.pri ) -include( $${QWT_ROOT}/qwtbuild.pri ) - -TEMPLATE = app - -INCLUDEPATH += $${QWT_ROOT}/src -DEPENDPATH += $${QWT_ROOT}/src -DESTDIR = $${QWT_ROOT}/examples/bin - -QMAKE_RPATHDIR *= $${QWT_ROOT}/lib - -contains(QWT_CONFIG, QwtFramework) { - - LIBS += -F$${QWT_ROOT}/lib -} -else { - - LIBS += -L$${QWT_ROOT}/lib -} - -IPATH = $${INCLUDEPATH} -qtAddLibrary(qwt) -INCLUDEPATH = $${IPATH} - -contains(QWT_CONFIG, QwtSvg) { - - QT += svg -} -else { - - DEFINES += QWT_NO_SVG -} - - -win32 { - contains(QWT_CONFIG, QwtDll) { - DEFINES += QT_DLL QWT_DLL - } -} diff --git a/qwt/examples/examples.pro b/qwt/examples/examples.pro deleted file mode 100644 index b3b0f5fd3..000000000 --- a/qwt/examples/examples.pro +++ /dev/null @@ -1,52 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../qwtconfig.pri ) - -TEMPLATE = subdirs - -contains(QWT_CONFIG, QwtPlot) { - - SUBDIRS += \ - cpuplot \ - curvdemo1 \ - curvdemo2 \ - friedberg \ - sinusplot \ - realtime \ - refreshtest \ - navigation \ - plotmatrix \ - spectrogram \ - rasterview \ - tvplot - - contains(QWT_CONFIG, QwtWidgets) { - - SUBDIRS += \ - bode \ - event_filter \ - oscilloscope - } - - contains(QWT_CONFIG, QwtSvg) { - - SUBDIRS += \ - svgmap - } -} - -contains(QWT_CONFIG, QwtWidgets) { - - SUBDIRS += \ - sysinfo \ - radio \ - dials \ - sliders -} diff --git a/qwt/examples/friedberg/friedberg.pro b/qwt/examples/friedberg/friedberg.pro deleted file mode 100644 index 3a15c5b6b..000000000 --- a/qwt/examples/friedberg/friedberg.pro +++ /dev/null @@ -1,21 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = friedberg - -HEADERS = \ - plot.h \ - friedberg2007.h - -SOURCES = \ - friedberg2007.cpp \ - plot.cpp \ - main.cpp diff --git a/qwt/examples/friedberg/friedberg2007.cpp b/qwt/examples/friedberg/friedberg2007.cpp deleted file mode 100644 index 19f688e9e..000000000 --- a/qwt/examples/friedberg/friedberg2007.cpp +++ /dev/null @@ -1,384 +0,0 @@ -#include "friedberg2007.h" - -// Temperature 2007 from Friedberg somewhere in Germany -// See: http://wetter61169.de - -Temperature friedberg2007[] = -{ - /* 01.01 */ Temperature( 2.6, 9.8, 7.07862 ), - /* 02.01 */ Temperature( 0.8, 5.8, 3.6993 ), - /* 03.01 */ Temperature( 2, 7, 5.02388 ), - /* 04.01 */ Temperature( 5.3, 7.8, 6.37778 ), - /* 05.01 */ Temperature( 5.6, 7.7, 6.83149 ), - /* 06.01 */ Temperature( 7.2, 8.9, 8.0816 ), - /* 07.01 */ Temperature( 4.2, 9.9, 7.54704 ), - /* 08.01 */ Temperature( 3.5, 8.9, 6.71951 ), - /* 09.01 */ Temperature( 8.2, 12.9, 10.8594 ), - /* 10.01 */ Temperature( 6.3, 11.9, 9.76424 ), - /* 11.01 */ Temperature( 3.9, 9.2, 6.18223 ), - /* 12.01 */ Temperature( 6.9, 9.7, 8.44236 ), - /* 13.01 */ Temperature( 9, 12.3, 10.6649 ), - /* 14.01 */ Temperature( 1.8, 10.8, 7.23438 ), - /* 15.01 */ Temperature( -2.8, 1.8, -0.518403 ), - /* 16.01 */ Temperature( -0.6, 4.5, 2.39479 ), - /* 17.01 */ Temperature( 4.3, 10.2, 7.23472 ), - /* 18.01 */ Temperature( 9.1, 13.6, 10.9316 ), - /* 19.01 */ Temperature( 6.9, 12.4, 9.4128 ), - /* 20.01 */ Temperature( 7.1, 13.3, 10.5083 ), - /* 21.01 */ Temperature( 3.5, 9.6, 6.10871 ), - /* 22.01 */ Temperature( -1.8, 6, 2.89028 ), - /* 23.01 */ Temperature( -5.4, 1.7, -2.46678 ), - /* 24.01 */ Temperature( -5.3, -1.3, -3.71483 ), - /* 25.01 */ Temperature( -7.5, 3.3, -3.36736 ), - /* 26.01 */ Temperature( -11.1, 0.3, -5.50662 ), - /* 27.01 */ Temperature( 0.2, 3.2, 1.95345 ), - /* 28.01 */ Temperature( 1.9, 5.2, 3.43633 ), - /* 29.01 */ Temperature( 4.4, 9.1, 6.24236 ), - /* 30.01 */ Temperature( 2.3, 11.5, 6.03114 ), - /* 31.01 */ Temperature( 4.6, 10.2, 6.04192 ), - - /* 01.02 */ Temperature( 4.8, 13.8, 7.87674 ), - /* 02.02 */ Temperature( 5.7, 10, 7.28646 ), - /* 03.02 */ Temperature( 2.9, 8.2, 5.71771 ), - /* 04.02 */ Temperature( -1.5, 7.2, 4.71319 ), - /* 05.02 */ Temperature( -2.6, 4.4, 1.23542 ), - /* 06.02 */ Temperature( 0.3, 9.2, 2.59965 ), - /* 07.02 */ Temperature( -0.4, 2.4, 0.641667 ), - /* 08.02 */ Temperature( -1.7, 3.8, 0.811458 ), - /* 09.02 */ Temperature( 0.7, 7, 3.58328 ), - /* 10.02 */ Temperature( 1, 6, 3.51181 ), - /* 11.02 */ Temperature( 4.7, 9.6, 6.14913 ), - /* 12.02 */ Temperature( 5.3, 8.7, 6.80552 ), - /* 13.02 */ Temperature( 4.4, 10.3, 6.84552 ), - /* 14.02 */ Temperature( 2.6, 6.5, 4.58681 ), - /* 15.02 */ Temperature( -0.8, 13.4, 6.38542 ), - /* 16.02 */ Temperature( -3, 14.4, 4.11336 ), - /* 17.02 */ Temperature( 0.5, 13, 5.87457 ), - /* 18.02 */ Temperature( -2.2, 14.1, 4.36528 ), - /* 19.02 */ Temperature( 3.9, 5.6, 4.63737 ), - /* 20.02 */ Temperature( -0.4, 9.2, 4.37014 ), - /* 21.02 */ Temperature( -1.9, 5.5, 1.85675 ), - /* 22.02 */ Temperature( 1, 13.1, 5.41176 ), - /* 23.02 */ Temperature( 1.9, 13.9, 7.74251 ), - /* 24.02 */ Temperature( 3.8, 9.6, 7.19306 ), - /* 25.02 */ Temperature( 5.8, 10.8, 7.80312 ), - /* 26.02 */ Temperature( 5.2, 10.4, 6.79481 ), - /* 27.02 */ Temperature( 3.2, 7.4, 5.22986 ), - /* 28.02 */ Temperature( 6.4, 13.4, 9.13356 ), - - /* 01.03 */ Temperature( 4.6, 11.4, 7.70554 ), - /* 02.03 */ Temperature( 3.4, 10.9, 5.98408 ), - /* 03.03 */ Temperature( 2.9, 10.5, 5.45675 ), - /* 04.03 */ Temperature( -0.7, 16.8, 7.29585 ), - /* 05.03 */ Temperature( 4.2, 13.4, 8.35862 ), - /* 06.03 */ Temperature( 3, 13, 7.76644 ), - /* 07.03 */ Temperature( 2, 13.3, 8.24618 ), - /* 08.03 */ Temperature( -0.8, 15, 6.11765 ), - /* 09.03 */ Temperature( -0.7, 11, 5.7568 ), - /* 10.03 */ Temperature( 1.2, 14.4, 6.61389 ), - /* 11.03 */ Temperature( -1.7, 18, 6.66146 ), - /* 12.03 */ Temperature( -0.6, 21.9, 8.9816 ), - /* 13.03 */ Temperature( -0.9, 19.6, 9.08299 ), - /* 14.03 */ Temperature( 5.3, 18.9, 10.5562 ), - /* 15.03 */ Temperature( 2, 20.5, 9.65156 ), - /* 16.03 */ Temperature( 0.2, 16.7, 7.8699 ), - /* 17.03 */ Temperature( 4.5, 10.6, 7.87535 ), - /* 18.03 */ Temperature( 2.7, 9.7, 6.71806 ), - /* 19.03 */ Temperature( 0.4, 10.9, 3.92404 ), - /* 20.03 */ Temperature( -2, 12.7, 4.01359 ), - /* 21.03 */ Temperature( 0.3, 6.8, 3.00382 ), - /* 22.03 */ Temperature( 0.9, 4.2, 2.2816 ), - /* 23.03 */ Temperature( 2, 5.7, 3.39233 ), - /* 24.03 */ Temperature( 3.9, 9.3, 6.41076 ), - /* 25.03 */ Temperature( 4.2, 19.1, 9.92182 ), - /* 26.03 */ Temperature( 2.3, 22, 12.5716 ), - /* 27.03 */ Temperature( 4.9, 20.6, 13.4568 ), - /* 28.03 */ Temperature( 0.3, 22.8, 10.755 ), - /* 29.03 */ Temperature( 1.8, 17.2, 9.43924 ), - /* 30.03 */ Temperature( 1.9, 19.8, 10.25 ), - /* 31.03 */ Temperature( 6.7, 17, 11.1324 ), - - /* 01.04 */ Temperature( 5.7, 22, 12.8457 ), - /* 02.04 */ Temperature( 6.4, 22.1, 13.3847 ), - /* 03.04 */ Temperature( 5.8, 17.5, 10.5614 ), - /* 04.04 */ Temperature( 2.8, 16.2, 8.06574 ), - /* 05.04 */ Temperature( -0.6, 20.8, 9.18062 ), - /* 06.04 */ Temperature( 2.1, 24, 13.0069 ), - /* 07.04 */ Temperature( 5.3, 16.2, 10.2771 ), - /* 08.04 */ Temperature( 0.1, 20.7, 9.79861 ), - /* 09.04 */ Temperature( 0.3, 18.9, 10.0087 ), - /* 10.04 */ Temperature( 4, 16.4, 11.4208 ), - /* 11.04 */ Temperature( 2.3, 23.4, 13.083 ), - /* 12.04 */ Temperature( 7, 29.4, 16.5826 ), - /* 13.04 */ Temperature( 10.6, 31.5, 19.2249 ), - /* 14.04 */ Temperature( 11.8, 34, 21.441 ), - /* 15.04 */ Temperature( 11.6, 33.8, 21.0201 ), - /* 16.04 */ Temperature( 8.7, 31.1, 18.7885 ), - /* 17.04 */ Temperature( 5.5, 27.2, 16.1432 ), - /* 18.04 */ Temperature( 6.1, 17.2, 10.6688 ), - /* 19.04 */ Temperature( -0.6, 21.3, 10.4806 ), - /* 20.04 */ Temperature( 5.9, 21.6, 12.6257 ), - /* 21.04 */ Temperature( 2.1, 21.6, 11.0858 ), - /* 22.04 */ Temperature( 3.9, 25.9, 14.2108 ), - /* 23.04 */ Temperature( 3.1, 27.8, 15.7111 ), - /* 24.04 */ Temperature( 13.7, 29, 19.6397 ), - /* 25.04 */ Temperature( 9.8, 31.6, 19.601 ), - /* 26.04 */ Temperature( 8.2, 32.4, 20.0389 ), - /* 27.04 */ Temperature( 11.8, 32.1, 21.0726 ), - /* 28.04 */ Temperature( 12.6, 33.3, 21.6993 ), - /* 29.04 */ Temperature( 10.5, 27.4, 19.1206 ), - /* 30.04 */ Temperature( 5.3, 26.4, 15.0972 ), - - /* 01.05 */ Temperature( 6.9, 25.3, 15.2802 ), - /* 02.05 */ Temperature( 4.3, 26.2, 14.8401 ), - /* 03.05 */ Temperature( 7.1, 28.5, 17.2145 ), - /* 04.05 */ Temperature( 11, 28.5, 18.537 ), - /* 05.05 */ Temperature( 12, 28, 18.1672 ), - /* 06.05 */ Temperature( 10.4, 29, 18.3844 ), - /* 07.05 */ Temperature( 13, 18.1, 15.0028 ), - /* 08.05 */ Temperature( 10.7, 18.3, 13.2014 ), - /* 09.05 */ Temperature( 10.8, 14.4, 12.5208 ), - /* 10.05 */ Temperature( 11.9, 23.5, 16.9632 ), - /* 11.05 */ Temperature( 9.8, 16.9, 15.0795 ), - /* 12.05 */ Temperature( 9.2, 19.6, 13.8521 ), - /* 13.05 */ Temperature( 8.9, 26.3, 16.2028 ), - /* 14.05 */ Temperature( 11.1, 17.5, 13.2934 ), - /* 15.05 */ Temperature( 6.5, 17, 11.7743 ), - /* 16.05 */ Temperature( 4.9, 13.6, 9.75625 ), - /* 17.05 */ Temperature( 6.8, 16.6, 9.96701 ), - /* 18.05 */ Temperature( 2.4, 21.2, 11.4311 ), - /* 19.05 */ Temperature( 8.2, 24.4, 15.4188 ), - /* 20.05 */ Temperature( 14.1, 31.7, 21.3303 ), - /* 21.05 */ Temperature( 11, 30.9, 21.5359 ), - /* 22.05 */ Temperature( 13.8, 31, 21.5177 ), - /* 23.05 */ Temperature( 16, 27.8, 21.0271 ), - /* 24.05 */ Temperature( 15, 34, 23.4142 ), - /* 25.05 */ Temperature( 14.3, 31.8, 22.8903 ), - /* 26.05 */ Temperature( 13.6, 33.1, 22.6156 ), - /* 27.05 */ Temperature( 11.2, 23.4, 16.6192 ), - /* 28.05 */ Temperature( 9.6, 13.1, 11.3222 ), - /* 29.05 */ Temperature( 8.3, 11.2, 10.3529 ), - /* 30.05 */ Temperature( 4.2, 20.8, 12.6218 ), - /* 31.05 */ Temperature( 9.2, 23.6, 15.1073 ), - - /* 01.06 */ Temperature( 10.8, 24.4, 16.3205 ), - /* 02.06 */ Temperature( 13, 26.5, 18.9649 ), - /* 03.06 */ Temperature( 14, 25.1, 18.5398 ), - /* 04.06 */ Temperature( 13, 28, 20.2139 ), - /* 05.06 */ Temperature( 14, 28.8, 20.438 ), - /* 06.06 */ Temperature( 14, 30.4, 21.7821 ), - /* 07.06 */ Temperature( 17, 34.8, 25.3087 ), - /* 08.06 */ Temperature( 17.9, 35.7, 25.7872 ), - /* 09.06 */ Temperature( 17.8, 31.6, 22.0788 ), - /* 10.06 */ Temperature( 15.5, 33.4, 22.4458 ), - /* 11.06 */ Temperature( 16.6, 28.3, 19.8797 ), - /* 12.06 */ Temperature( 14, 27.3, 20.2566 ), - /* 13.06 */ Temperature( 13.2, 28.2, 19.4233 ), - /* 14.06 */ Temperature( 12.7, 30, 20.1427 ), - /* 15.06 */ Temperature( 15.2, 22.6, 18.5917 ), - /* 16.06 */ Temperature( 13.2, 24, 17.7014 ), - /* 17.06 */ Temperature( 11.7, 27.9, 19.8229 ), - /* 18.06 */ Temperature( 15.9, 27.2, 20.3358 ), - /* 19.06 */ Temperature( 12.6, 33.7, 22.2427 ), - /* 20.06 */ Temperature( 15.7, 30.8, 23.7507 ), - /* 21.06 */ Temperature( 14.8, 22.6, 18.2538 ), - /* 22.06 */ Temperature( 12.4, 21.3, 15.9969 ), - /* 23.06 */ Temperature( 12.6, 21.6, 15.8149 ), - /* 24.06 */ Temperature( 13, 26, 18.4176 ), - /* 25.06 */ Temperature( 12.9, 24.4, 17.1299 ), - /* 26.06 */ Temperature( 10.8, 18.8, 13.2913 ), - /* 27.06 */ Temperature( 9.9, 18.8, 13.5465 ), - /* 28.06 */ Temperature( 12, 19.8, 14.8434 ), - /* 29.06 */ Temperature( 12, 19, 15.155 ), - /* 30.06 */ Temperature( 12.4, 22.4, 17.1354 ), - - /* 01.07 */ Temperature( 12.1, 24.9, 19.1639 ), - /* 02.07 */ Temperature( 15.7, 24.3, 18.4554 ), - /* 03.07 */ Temperature( 12.7, 17.2, 14.6564 ), - /* 04.07 */ Temperature( 11.2, 19, 13.9529 ), - /* 05.07 */ Temperature( 11.5, 19, 14.6422 ), - /* 06.07 */ Temperature( 12.4, 22, 16.6146 ), - /* 07.07 */ Temperature( 11.6, 24, 17.666 ), - /* 08.07 */ Temperature( 9, 28, 19.1351 ), - /* 09.07 */ Temperature( 11.3, 21.5, 16.5271 ), - /* 10.07 */ Temperature( 11.3, 20.2, 14.2326 ), - /* 11.07 */ Temperature( 10.2, 19.2, 14.0649 ), - /* 12.07 */ Temperature( 13.2, 23.1, 16.6346 ), - /* 13.07 */ Temperature( 15, 27, 19.6844 ), - /* 14.07 */ Temperature( 13.4, 32.4, 23.845 ), - /* 15.07 */ Temperature( 15, 38.2, 26.8559 ), - /* 16.07 */ Temperature( 16.1, 36.5, 26.4483 ), - /* 17.07 */ Temperature( 19.7, 30.5, 24.189 ), - /* 18.07 */ Temperature( 14.2, 29.3, 22.1363 ), - /* 19.07 */ Temperature( 16.4, 25.9, 19.0819 ), - /* 20.07 */ Temperature( 16.2, 30.8, 22.151 ), - /* 21.07 */ Temperature( 14, 24.3, 18.6573 ), - /* 22.07 */ Temperature( 13.2, 24.5, 18.3301 ), - /* 23.07 */ Temperature( 10.6, 23.4, 16.6903 ), - /* 24.07 */ Temperature( 13.2, 20.8, 16.2743 ), - /* 25.07 */ Temperature( 12.2, 25.8, 18.8267 ), - /* 26.07 */ Temperature( 11.9, 28.9, 20.5522 ), - /* 27.07 */ Temperature( 17.6, 25.8, 21.5691 ), - /* 28.07 */ Temperature( 16.6, 24.6, 19.2295 ), - /* 29.07 */ Temperature( 13, 19, 15.9021 ), - /* 30.07 */ Temperature( 9.6, 19.7, 13.875 ), - /* 31.07 */ Temperature( 8, 22, 14.5284 ), - - /* 01.08 */ Temperature( 7.6, 27.5, 17.5684 ), - /* 02.08 */ Temperature( 9.2, 22.2, 16.1035 ), - /* 03.08 */ Temperature( 12.7, 25.3, 18.2958 ), - /* 04.08 */ Temperature( 8.6, 31.3, 19.7941 ), - /* 05.08 */ Temperature( 10.3, 32.7, 21.492 ), - /* 06.08 */ Temperature( 10, 33.4, 22.4431 ), - /* 07.08 */ Temperature( 16.8, 22.6, 19.5583 ), - /* 08.08 */ Temperature( 13.5, 16.7, 15.0264 ), - /* 09.08 */ Temperature( 13.2, 18.8, 15.6003 ), - /* 10.08 */ Temperature( 14.6, 27.9, 18.8292 ), - /* 11.08 */ Temperature( 16.3, 26.4, 20.3837 ), - /* 12.08 */ Temperature( 12.1, 28.7, 19.9892 ), - /* 13.08 */ Temperature( 15, 27.4, 19.7542 ), - /* 14.08 */ Temperature( 11.3, 28.3, 20.5656 ), - /* 15.08 */ Temperature( 18.6, 28.4, 23.1215 ), - /* 16.08 */ Temperature( 16, 23.6, 19.491 ), - /* 17.08 */ Temperature( 12.6, 22, 17.0437 ), - /* 18.08 */ Temperature( 8.5, 25.7, 16.5589 ), - /* 19.08 */ Temperature( 13.4, 25.8, 18.0543 ), - /* 20.08 */ Temperature( 10.9, 21.5, 16.1306 ), - /* 21.08 */ Temperature( 10.6, 19.2, 14.6177 ), - /* 22.08 */ Temperature( 14, 24.6, 17.3841 ), - /* 23.08 */ Temperature( 13.8, 30.4, 20.6125 ), - /* 24.08 */ Temperature( 12.3, 30.3, 20.7622 ), - /* 25.08 */ Temperature( 12.8, 30.2, 21.6736 ), - /* 26.08 */ Temperature( 15, 29.3, 21.266 ), - /* 27.08 */ Temperature( 12.9, 25.9, 18.791 ), - /* 28.08 */ Temperature( 9.3, 24.6, 16.2833 ), - /* 29.08 */ Temperature( 10.8, 25, 16.8459 ), - /* 30.08 */ Temperature( 8.2, 24.4, 15.9267 ), - /* 31.08 */ Temperature( 14.1, 20.5, 16.6128 ), - - /* 01.09 */ Temperature( 13.4, 21.9, 16.2205 ), - /* 02.09 */ Temperature( 12, 20.7, 16.0882 ), - /* 03.09 */ Temperature( 10.8, 21.3, 14.7913 ), - /* 04.09 */ Temperature( 7.8, 18.2, 12.2747 ), - /* 05.09 */ Temperature( 8.1, 22.2, 12.9406 ), - /* 06.09 */ Temperature( 10, 23.8, 13.8785 ), - /* 07.09 */ Temperature( 10.7, 21.2, 15.4823 ), - /* 08.09 */ Temperature( 12.4, 21, 15.8194 ), - /* 09.09 */ Temperature( 12.7, 16.9, 14.7212 ), - /* 10.09 */ Temperature( 10.3, 17.7, 12.9271 ), - /* 11.09 */ Temperature( 10.6, 20.8, 14.4788 ), - /* 12.09 */ Temperature( 10.8, 21.9, 15.0184 ), - /* 13.09 */ Temperature( 6.9, 24.6, 14.5222 ), - /* 14.09 */ Temperature( 8.1, 24, 15.6583 ), - /* 15.09 */ Temperature( 8.8, 22.8, 15.941 ), - /* 16.09 */ Temperature( 3.1, 24.5, 14.1486 ), - /* 17.09 */ Temperature( 12.4, 21.2, 16.0497 ), - /* 18.09 */ Temperature( 7.8, 16.1, 12.024 ), - /* 19.09 */ Temperature( 5.3, 18.1, 10.3003 ), - /* 20.09 */ Temperature( 6.4, 20.3, 12.3177 ), - /* 21.09 */ Temperature( 6, 23.8, 13.6247 ), - /* 22.09 */ Temperature( 5.7, 27, 14.6847 ), - /* 23.09 */ Temperature( 7.8, 28, 16.6238 ), - /* 24.09 */ Temperature( 9.6, 24.9, 16.7191 ), - /* 25.09 */ Temperature( 8.4, 17.6, 12.636 ), - /* 26.09 */ Temperature( 4.3, 18.9, 10.0809 ), - /* 27.09 */ Temperature( 9.4, 11.2, 10.3344 ), - /* 28.09 */ Temperature( 7.7, 12.6, 10.5337 ), - /* 29.09 */ Temperature( 9.8, 15.3, 11.9306 ), - /* 30.09 */ Temperature( 9.6, 21.1, 13.6635 ), - - /* 01.10 */ Temperature( 8.9, 24.5, 14.8163 ), - /* 02.10 */ Temperature( 13.5, 20.2, 16.1628 ), - /* 03.10 */ Temperature( 12.5, 18, 15.4691 ), - /* 04.10 */ Temperature( 13.8, 25, 17.2073 ), - /* 05.10 */ Temperature( 9.1, 23.2, 14.6181 ), - /* 06.10 */ Temperature( 6.4, 23.4, 12.8625 ), - /* 07.10 */ Temperature( 4.6, 22.1, 11.0052 ), - /* 08.10 */ Temperature( 2, 22.2, 10.1677 ), - /* 09.10 */ Temperature( 7.8, 21.6, 12.2139 ), - /* 10.10 */ Temperature( 7.1, 22.7, 13.0115 ), - /* 11.10 */ Temperature( 6.1, 21.2, 11.4333 ), - /* 12.10 */ Temperature( 4.3, 15.2, 10.6104 ), - /* 13.10 */ Temperature( 5.8, 23, 12.8875 ), - /* 14.10 */ Temperature( 1, 23, 9.72986 ), - /* 15.10 */ Temperature( 1, 19.3, 9.33021 ), - /* 16.10 */ Temperature( 8.5, 20.4, 13.2639 ), - /* 17.10 */ Temperature( 6.8, 17.3, 11.8174 ), - /* 18.10 */ Temperature( 5.2, 15.6, 9.06076 ), - /* 19.10 */ Temperature( 2.7, 13.5, 7.1309 ), - /* 20.10 */ Temperature( -0.2, 15.8, 6.01667 ), - /* 21.10 */ Temperature( 2.6, 6.1, 4.9441 ), - /* 22.10 */ Temperature( -0.8, 13.2, 4.50694 ), - /* 23.10 */ Temperature( -0.4, 13.3, 4.71007 ), - /* 24.10 */ Temperature( 2.9, 8.1, 5.96979 ), - /* 25.10 */ Temperature( 6.3, 10.5, 8.01206 ), - /* 26.10 */ Temperature( 7, 10.8, 8.14965 ), - /* 27.10 */ Temperature( 6.6, 9.7, 7.7809 ), - /* 28.10 */ Temperature( 1.7, 10.8, 6.95728 ), - /* 29.10 */ Temperature( 2.2, 9.9, 6.62917 ), - /* 30.10 */ Temperature( 5.8, 15, 8.76181 ), - /* 31.10 */ Temperature( 0.7, 15, 6.01528 ), - - /* 01.11 */ Temperature( -0.2, 9.7, 3.75842 ), - /* 02.11 */ Temperature( 6.4, 9.6, 8.00138 ), - /* 03.11 */ Temperature( 8.7, 13.1, 10.5676 ), - /* 04.11 */ Temperature( 8, 11.8, 9.54306 ), - /* 05.11 */ Temperature( 5.8, 15.9, 8.52345 ), - /* 06.11 */ Temperature( 5.5, 10.8, 7.16493 ), - /* 07.11 */ Temperature( 5.5, 8.9, 7.30172 ), - /* 08.11 */ Temperature( 7, 11.7, 8.96701 ), - /* 09.11 */ Temperature( 2.5, 8.4, 4.86528 ), - /* 10.11 */ Temperature( 3.7, 9, 5.20828 ), - /* 11.11 */ Temperature( 2.8, 10.6, 6.80756 ), - /* 12.11 */ Temperature( 2.7, 9.5, 5.07647 ), - /* 13.11 */ Temperature( 0.1, 5.4, 3.3945 ), - /* 14.11 */ Temperature( -0.7, 7.9, 2.02234 ), - /* 15.11 */ Temperature( -1.8, 6.5, 1.07778 ), - /* 16.11 */ Temperature( -4.4, 5.1, -0.693772 ), - /* 17.11 */ Temperature( -0.3, 3.4, 1.33229 ), - /* 18.11 */ Temperature( -0.4, 4.3, 2.4622 ), - /* 19.11 */ Temperature( 1.8, 3.6, 2.78282 ), - /* 20.11 */ Temperature( 1.3, 5.6, 2.95979 ), - /* 21.11 */ Temperature( 1.6, 5.7, 3.62284 ), - /* 22.11 */ Temperature( 3.1, 7.3, 5.60277 ), - /* 23.11 */ Temperature( 4.2, 7.7, 6.28166 ), - /* 24.11 */ Temperature( -0.5, 11.5, 3.25931 ), - /* 25.11 */ Temperature( -1, 8.8, 2.86505 ), - /* 26.11 */ Temperature( 1.2, 6.8, 3.09414 ), - /* 27.11 */ Temperature( -0.8, 7.5, 3.17805 ), - /* 28.11 */ Temperature( -2.8, 3.1, -0.920139 ), - /* 29.11 */ Temperature( -2.6, 1.7, -0.491696 ), - /* 30.11 */ Temperature( 1.3, 6.5, 3.85 ), - - /* 01.12 */ Temperature( 4.1, 8.7, 5.88924 ), - /* 02.12 */ Temperature( 4.8, 9, 6.81667 ), - /* 03.12 */ Temperature( 3.5, 8.5, 6.23633 ), - /* 04.12 */ Temperature( 2.7, 6.6, 4.63045 ), - /* 05.12 */ Temperature( 4.3, 8.6, 6.85993 ), - /* 06.12 */ Temperature( 5.5, 9.3, 7.79201 ), - /* 07.12 */ Temperature( 3.1, 13.4, 8.79444 ), - /* 08.12 */ Temperature( 2.6, 6.3, 4.67093 ), - /* 09.12 */ Temperature( 3, 10.4, 5.75724 ), - /* 10.12 */ Temperature( 4.1, 6.8, 5.31834 ), - /* 11.12 */ Temperature( 4.1, 7.4, 5.28993 ), - /* 12.12 */ Temperature( 3.9, 6.4, 4.64479 ), - /* 13.12 */ Temperature( 1.7, 9.1, 4.15363 ), - /* 14.12 */ Temperature( 0.4, 1.8, 0.934602 ), - /* 15.12 */ Temperature( -4.5, 2.1, -1.17292 ), - /* 16.12 */ Temperature( -5, 4.8, -2.17431 ), - /* 17.12 */ Temperature( -5.6, 6.1, -1.35448 ), - /* 18.12 */ Temperature( -4.9, 6.4, -1.25502 ), - /* 19.12 */ Temperature( -4.4, 6.6, -1.02396 ), - /* 20.12 */ Temperature( -7.3, 5.2, -2.63854 ), - /* 21.12 */ Temperature( -8.5, 5.7, -3.58333 ), - /* 22.12 */ Temperature( -7.9, -5.3, -6.13438 ), - /* 23.12 */ Temperature( -6.1, -4.4, -5.23472 ), - /* 24.12 */ Temperature( -4.6, -3.3, -3.84291 ), - /* 25.12 */ Temperature( -4.9, -2.8, -3.9066 ), - /* 26.12 */ Temperature( -4.7, -1.9, -3.10379 ), - /* 27.12 */ Temperature( -1.9, -0.2, -0.679791 ), - /* 28.12 */ Temperature( -1.8, 0.5, -0.521875 ), - /* 29.12 */ Temperature( -2.2, 2.3, -0.430796 ), - /* 30.12 */ Temperature( 0.9, 5.2, 2.83437 ), - /* 31.12 */ Temperature( -1, 8.3, 2.27093 ) -}; diff --git a/qwt/examples/friedberg/friedberg2007.h b/qwt/examples/friedberg/friedberg2007.h deleted file mode 100644 index 691f10141..000000000 --- a/qwt/examples/friedberg/friedberg2007.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _FRIEDBERG_2007_H_ -#define _FRIEDBERG_2007_H_ - -class Temperature -{ -public: - Temperature(): - minValue( 0.0 ), - maxValue( 0.0 ), - averageValue( 0.0 ) - { - } - - Temperature( double min, double max, double average ): - minValue( min ), - maxValue( max ), - averageValue( average ) - { - } - - double minValue; - double maxValue; - double averageValue; -}; - -extern Temperature friedberg2007[]; - -#endif diff --git a/qwt/examples/friedberg/main.cpp b/qwt/examples/friedberg/main.cpp deleted file mode 100644 index 1c1f603b6..000000000 --- a/qwt/examples/friedberg/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include "plot.h" - -class MainWindow: public QMainWindow -{ -public: - MainWindow( QWidget * = NULL ); - -private: - Plot *d_plot; -}; - -MainWindow::MainWindow( QWidget *parent ): - QMainWindow( parent ) -{ - d_plot = new Plot( this ); - setCentralWidget( d_plot ); - - QToolBar *toolBar = new QToolBar( this ); - - QComboBox *typeBox = new QComboBox( toolBar ); - typeBox->addItem( "Bars" ); - typeBox->addItem( "Tube" ); - typeBox->setCurrentIndex( 1 ); - typeBox->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); - - QToolButton *btnExport = new QToolButton( toolBar ); - btnExport->setText( "Export" ); - btnExport->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); - connect( btnExport, SIGNAL( clicked() ), d_plot, SLOT( exportPlot() ) ); - - toolBar->addWidget( typeBox ); - toolBar->addWidget( btnExport ); - addToolBar( toolBar ); - - d_plot->setMode( typeBox->currentIndex() ); - connect( typeBox, SIGNAL( currentIndexChanged( int ) ), - d_plot, SLOT( setMode( int ) ) ); -} - -int main( int argc, char **argv ) -{ - QApplication a( argc, argv ); - - MainWindow w; - w.setObjectName( "MainWindow" ); - w.resize( 600, 400 ); - w.show(); - - return a.exec(); -} diff --git a/qwt/examples/friedberg/plot.cpp b/qwt/examples/friedberg/plot.cpp deleted file mode 100644 index 299612cd3..000000000 --- a/qwt/examples/friedberg/plot.cpp +++ /dev/null @@ -1,252 +0,0 @@ -#include "plot.h" -#include "friedberg2007.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class Grid: public QwtPlotGrid -{ -public: - Grid() - { - enableXMin( true ); - setMajPen( QPen( Qt::white, 0, Qt::DotLine ) ); - setMinPen( QPen( Qt::gray, 0 , Qt::DotLine ) ); - } - - virtual void updateScaleDiv( const QwtScaleDiv &xMap, - const QwtScaleDiv &yMap ) - { - QList ticks[QwtScaleDiv::NTickTypes]; - - ticks[QwtScaleDiv::MajorTick] = - xMap.ticks( QwtScaleDiv::MediumTick ); - ticks[QwtScaleDiv::MinorTick] = - xMap.ticks( QwtScaleDiv::MinorTick ); - - QwtPlotGrid::updateScaleDiv( - QwtScaleDiv( xMap.lowerBound(), xMap.upperBound(), ticks ), - yMap ); - } -}; - -class YearScaleDraw: public QwtScaleDraw -{ -public: - YearScaleDraw() - { - setTickLength( QwtScaleDiv::MajorTick, 0 ); - setTickLength( QwtScaleDiv::MinorTick, 0 ); - setTickLength( QwtScaleDiv::MediumTick, 6 ); - - setLabelRotation( -60.0 ); - setLabelAlignment( Qt::AlignLeft | Qt::AlignVCenter ); - - setSpacing( 15 ); - } - - virtual QwtText label( double value ) const - { - return QDate::longMonthName( int( value / 30 ) + 1 ); - } -}; - -Plot::Plot( QWidget *parent ): - QwtPlot( parent ) -{ - setObjectName( "FriedbergPlot" ); - setTitle( "Temperature of Friedberg/Germany" ); - - setAxisTitle( QwtPlot::xBottom, "2007" ); - setAxisScaleDiv( QwtPlot::xBottom, yearScaleDiv() ); - setAxisScaleDraw( QwtPlot::xBottom, new YearScaleDraw() ); - - setAxisTitle( QwtPlot::yLeft, - QString( "Temperature [%1C]" ).arg( QChar( 0x00B0 ) ) ); - - // grid - QwtPlotGrid *grid = new Grid; - grid->attach( this ); - - insertLegend( new QwtLegend(), QwtPlot::RightLegend ); - - const int numDays = 365; - QVector averageData( numDays ); - QVector rangeData( numDays ); - - for ( int i = 0; i < numDays; i++ ) - { - const Temperature &t = friedberg2007[i]; - averageData[i] = QPointF( double( i ), t.averageValue ); - rangeData[i] = QwtIntervalSample( double( i ), - QwtInterval( t.minValue, t.maxValue ) ); - } - - insertCurve( "Average", averageData, Qt::black ); - insertErrorBars( "Range", rangeData, Qt::blue ); - - // LeftButton for the zooming - // MidButton for the panning - // RightButton: zoom out by 1 - // Ctrl+RighButton: zoom out to full size - - QwtPlotZoomer* zoomer = new QwtPlotZoomer( canvas() ); - zoomer->setRubberBandPen( QColor( Qt::black ) ); - zoomer->setTrackerPen( QColor( Qt::black ) ); - zoomer->setMousePattern( QwtEventPattern::MouseSelect2, - Qt::RightButton, Qt::ControlModifier ); - zoomer->setMousePattern( QwtEventPattern::MouseSelect3, - Qt::RightButton ); - - QwtPlotPanner *panner = new QwtPlotPanner( canvas() ); - panner->setMouseButton( Qt::MidButton ); - - canvas()->setPalette( Qt::darkGray ); - canvas()->setBorderRadius( 10 ); -} - -QwtScaleDiv Plot::yearScaleDiv() const -{ - const int days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - - QList ticks[QwtScaleDiv::NTickTypes]; - - QList &mediumTicks = ticks[QwtScaleDiv::MediumTick]; - mediumTicks += 0.0; - for ( uint i = 0; i < sizeof( days ) / sizeof( days[0] ); i++ ) - mediumTicks += mediumTicks.last() + days[i]; - - QList &minorTicks = ticks[QwtScaleDiv::MinorTick]; - for ( int i = 1; i <= 365; i += 7 ) - minorTicks += i; - - QList &majorTicks = ticks[QwtScaleDiv::MajorTick]; - for ( int i = 0; i < 12; i++ ) - majorTicks += i * 30 + 15; - - QwtScaleDiv scaleDiv( mediumTicks.first(), mediumTicks.last() + 1, ticks ); - return scaleDiv; -} - -void Plot::insertCurve( const QString& title, - const QVector& samples, const QColor &color ) -{ - d_curve = new QwtPlotCurve( title ); - d_curve->setRenderHint( QwtPlotItem::RenderAntialiased ); - d_curve->setStyle( QwtPlotCurve::NoCurve ); - d_curve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol ); - - QwtSymbol *symbol = new QwtSymbol( QwtSymbol::XCross ); - symbol->setSize( 4 ); - symbol->setPen( QPen( color ) ); - d_curve->setSymbol( symbol ); - - d_curve->setSamples( samples ); - d_curve->attach( this ); -} - -void Plot::insertErrorBars( - const QString &title, - const QVector& samples, - const QColor &color ) -{ - d_intervalCurve = new QwtPlotIntervalCurve( title ); - d_intervalCurve->setRenderHint( QwtPlotItem::RenderAntialiased ); - d_intervalCurve->setPen( QPen( Qt::white ) ); - - QColor bg( color ); - bg.setAlpha( 150 ); - d_intervalCurve->setBrush( QBrush( bg ) ); - d_intervalCurve->setStyle( QwtPlotIntervalCurve::Tube ); - - d_intervalCurve->setSamples( samples ); - d_intervalCurve->attach( this ); -} - -void Plot::setMode( int style ) -{ - if ( style == Tube ) - { - d_intervalCurve->setStyle( QwtPlotIntervalCurve::Tube ); - d_intervalCurve->setSymbol( NULL ); - d_intervalCurve->setRenderHint( QwtPlotItem::RenderAntialiased, true ); - } - else - { - d_intervalCurve->setStyle( QwtPlotIntervalCurve::NoCurve ); - - QColor c( d_intervalCurve->brush().color().rgb() ); // skip alpha - - QwtIntervalSymbol *errorBar = - new QwtIntervalSymbol( QwtIntervalSymbol::Bar ); - errorBar->setWidth( 8 ); // should be something even - errorBar->setPen( c ); - - d_intervalCurve->setSymbol( errorBar ); - d_intervalCurve->setRenderHint( QwtPlotItem::RenderAntialiased, false ); - } - - replot(); -} - -void Plot::exportPlot() -{ -#ifndef QT_NO_PRINTER - QString fileName = "friedberg.pdf"; -#else - QString fileName = "friedberg.png"; -#endif - -#ifndef QT_NO_FILEDIALOG - const QList imageFormats = - QImageWriter::supportedImageFormats(); - - QStringList filter; - filter += "PDF Documents (*.pdf)"; -#ifndef QWT_NO_SVG - filter += "SVG Documents (*.svg)"; -#endif - filter += "Postscript Documents (*.ps)"; - - if ( imageFormats.size() > 0 ) - { - QString imageFilter("Images ("); - for ( int i = 0; i < imageFormats.size(); i++ ) - { - if ( i > 0 ) - imageFilter += " "; - imageFilter += "*."; - imageFilter += imageFormats[i]; - } - imageFilter += ")"; - - filter += imageFilter; - } - - fileName = QFileDialog::getSaveFileName( - this, "Export File Name", fileName, - filter.join(";;"), NULL, QFileDialog::DontConfirmOverwrite); -#endif - if ( !fileName.isEmpty() ) - { - QwtPlotRenderer renderer; - renderer.setDiscardFlag(QwtPlotRenderer::DiscardBackground, false); - - renderer.renderDocument(this, fileName, QSizeF(300, 200), 85); - } -} diff --git a/qwt/examples/friedberg/plot.h b/qwt/examples/friedberg/plot.h deleted file mode 100644 index 387655433..000000000 --- a/qwt/examples/friedberg/plot.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _PLOT_H_ -#define _PLOT_H_ - -#include -#include -#include - -class QwtPlotCurve; -class QwtPlotIntervalCurve; - -class Plot: public QwtPlot -{ - Q_OBJECT - -public: - enum Mode - { - Bars, - Tube - }; - - Plot( QWidget * = NULL ); - -public Q_SLOTS: - void setMode( int ); - void exportPlot(); - -private: - void insertCurve( const QString &title, - const QVector &, const QColor & ); - - void insertErrorBars( const QString &title, - const QVector &, - const QColor &color ); - - - QwtScaleDiv yearScaleDiv() const; - - QwtPlotIntervalCurve *d_intervalCurve; - QwtPlotCurve *d_curve; -}; - -#endif diff --git a/qwt/examples/navigation/main.cpp b/qwt/examples/navigation/main.cpp deleted file mode 100644 index 2afb77977..000000000 --- a/qwt/examples/navigation/main.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include "mainwindow.h" - -int main(int argc, char **argv) -{ - QApplication a(argc, argv); - - MainWindow mainWindow; - - mainWindow.resize(800,600); - mainWindow.show(); - - return a.exec(); -} diff --git a/qwt/examples/navigation/mainwindow.cpp b/qwt/examples/navigation/mainwindow.cpp deleted file mode 100644 index 4b8b615da..000000000 --- a/qwt/examples/navigation/mainwindow.cpp +++ /dev/null @@ -1,183 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "plot.h" -#include "mainwindow.h" - -MainWindow::MainWindow() -{ - QFrame *w = new QFrame(this); - - QWidget *panel = createPanel(w); - panel->setFixedWidth(2 * panel->sizeHint().width()); - d_plot = createPlot(w); - - QHBoxLayout *layout = new QHBoxLayout(w); - layout->setMargin(0); - layout->addWidget(panel, 0); - layout->addWidget(d_plot, 10); - - setCentralWidget(w); - - setRescaleMode(0); - setMouseMode(0); - - (void)statusBar(); -} - -QWidget *MainWindow::createPanel(QWidget *parent) -{ - QGroupBox *panel = new QGroupBox("Navigation Panel", parent); - - QComboBox *navigationBox = new QComboBox(panel); - navigationBox->setEditable(false); - navigationBox->insertItem(Tracking, "Tracking"); - navigationBox->insertItem(Zooming, "Zooming"); - navigationBox->insertItem(Panning, "Panning"); - - connect(navigationBox, SIGNAL(activated(int)), SLOT(setMouseMode(int))); - - d_navigationInfo = new QLabel(panel); - d_navigationInfo->setSizePolicy( - QSizePolicy::Expanding, QSizePolicy::Expanding); - d_navigationInfo->setWordWrap(true); - - QComboBox *rescaleBox = new QComboBox(panel); - rescaleBox->setEditable(false); - rescaleBox->insertItem(KeepScales, "None"); - rescaleBox->insertItem(Fixed, "Fixed"); - rescaleBox->insertItem(Expanding, "Expanding"); - rescaleBox->insertItem(Fitting, "Fitting"); - - connect(rescaleBox, SIGNAL(activated(int)), SLOT(setRescaleMode(int))); - - d_rescaleInfo = new QLabel(panel); - d_rescaleInfo->setSizePolicy( - QSizePolicy::Expanding, QSizePolicy::Expanding); - d_rescaleInfo->setWordWrap(true); - - QVBoxLayout *layout = new QVBoxLayout(panel); - layout->addWidget(navigationBox); - layout->addWidget(d_navigationInfo); - layout->addWidget(rescaleBox); - layout->addWidget(d_rescaleInfo); - layout->addStretch(10); - - return panel; -} - -Plot *MainWindow::createPlot(QWidget *parent) -{ - Plot *plot = new Plot(parent, QwtInterval(0.0, 1000.0)); - plot->replot(); - - d_rescaler = new QwtPlotRescaler(plot->canvas()); - d_rescaler->setReferenceAxis(QwtPlot::xBottom); - d_rescaler->setAspectRatio(QwtPlot::yLeft, 1.0); - d_rescaler->setAspectRatio(QwtPlot::yRight, 0.0); - d_rescaler->setAspectRatio(QwtPlot::xTop, 0.0); - - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - d_rescaler->setIntervalHint(axis, QwtInterval(0.0, 1000.0)); - - connect(plot, SIGNAL(resized(double, double)), - SLOT(showRatio(double, double))); - return plot; -} - -void MainWindow::setMouseMode(int mode) -{ - switch(mode) - { - case Tracking: - { - d_navigationInfo->setText("Tracking"); - break; - } - case Zooming: - { - d_navigationInfo->setText("Zooming"); - break; - } - case Panning: - { - d_navigationInfo->setText("Panning"); - break; - } - } -} - -void MainWindow::setRescaleMode(int mode) -{ - bool doEnable = true; - QString info; - QRectF rectOfInterest; - QwtPlotRescaler::ExpandingDirection direction = QwtPlotRescaler::ExpandUp; - - switch(mode) - { - case KeepScales: - { - doEnable = false; - info = "All scales remain unchanged, when the plot is resized"; - break; - } - case Fixed: - { - d_rescaler->setRescalePolicy(QwtPlotRescaler::Fixed); - info = "The scale of the bottom axis remains unchanged, " - "when the plot is resized. All other scales are changed, " - "so that a pixel on screen means the same distance for" - "all scales."; - break; - } - case Expanding: - { - d_rescaler->setRescalePolicy(QwtPlotRescaler::Expanding); - info = "The scales of all axis are shrinked/expanded, when " - "resizing the plot, keeping the distance that is represented " - "by one pixel."; - d_rescaleInfo->setText("Expanding"); - break; - } - case Fitting: - { - d_rescaler->setRescalePolicy(QwtPlotRescaler::Fitting); - const QwtInterval xIntv = - d_rescaler->intervalHint(QwtPlot::xBottom); - const QwtInterval yIntv = - d_rescaler->intervalHint(QwtPlot::yLeft); - - rectOfInterest = QRectF( xIntv.minValue(), yIntv.minValue(), - xIntv.width(), yIntv.width()); - direction = QwtPlotRescaler::ExpandBoth; - - info = "Fitting"; - break; - } - } - - d_plot->setRectOfInterest(rectOfInterest); - - d_rescaleInfo->setText(info); - d_rescaler->setEnabled(doEnable); - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - d_rescaler->setExpandingDirection(direction); - - if ( doEnable ) - d_rescaler->rescale(); - else - d_plot->replot(); -} - -void MainWindow::showRatio(double xRatio, double yRatio) -{ - const QString msg = QString("%1, %2").arg(xRatio).arg(yRatio); - statusBar()->showMessage(msg); -} diff --git a/qwt/examples/navigation/mainwindow.h b/qwt/examples/navigation/mainwindow.h deleted file mode 100644 index 0c52836eb..000000000 --- a/qwt/examples/navigation/mainwindow.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _MAINWINDOW_H_ -#define _MAINWINDOW_H_ 1 - -#include -#include - -class QwtPlotRescaler; -class QLabel; -class Plot; - -class MainWindow: public QMainWindow -{ - Q_OBJECT - -public: - enum MouseMode - { - Tracking, - Zooming, - Panning - }; - - enum RescaleMode - { - KeepScales, - Fixed, - Expanding, - Fitting - }; - - MainWindow(); - -private Q_SLOTS: - void setMouseMode(int); - void setRescaleMode(int); - void showRatio(double, double); - -private: - QWidget *createPanel(QWidget *); - Plot *createPlot(QWidget *); - - QwtPlotRescaler *d_rescaler; - QLabel *d_navigationInfo; - QLabel *d_rescaleInfo; - - Plot *d_plot; -}; - -#endif diff --git a/qwt/examples/navigation/navigation.pro b/qwt/examples/navigation/navigation.pro deleted file mode 100644 index 588982ecf..000000000 --- a/qwt/examples/navigation/navigation.pro +++ /dev/null @@ -1,21 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = navigation - -HEADERS = \ - mainwindow.h \ - plot.h - -SOURCES = \ - mainwindow.cpp \ - plot.cpp \ - main.cpp diff --git a/qwt/examples/navigation/plot.cpp b/qwt/examples/navigation/plot.cpp deleted file mode 100644 index 434880ff8..000000000 --- a/qwt/examples/navigation/plot.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "plot.h" -#include -#include -#include -#include -#include -#include -#include -#include - -class RectItem: public QwtPlotItem -{ -public: - enum Type - { - Rect, - Ellipse - }; - - RectItem(Type type): - d_type(type) - { - } - - void setPen(const QPen &pen) - { - if ( pen != d_pen ) - { - d_pen = pen; - itemChanged(); - } - } - - void setBrush(const QBrush &brush) - { - if ( brush != d_brush ) - { - d_brush = brush; - itemChanged(); - } - } - void setRect(const QRectF &rect) - { - if ( d_rect != rect ) - { - d_rect = rect; - itemChanged(); - } - } - - virtual QRectF boundingRect() const - { - return d_rect; - } - - virtual void draw(QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &) const - { - if ( d_rect.isValid() ) - { - const QRectF rect = QwtScaleMap::transform( - xMap, yMap, d_rect); - painter->setPen(d_pen); - painter->setBrush(d_brush); - if ( d_type == Ellipse ) - QwtPainter::drawEllipse(painter, rect); - else - QwtPainter::drawRect(painter, rect); - } - } -private: - QPen d_pen; - QBrush d_brush; - QRectF d_rect; - Type d_type; -}; - -Plot::Plot(QWidget *parent, const QwtInterval &interval): - QwtPlot(parent) -{ - for ( int axis = 0; axis < QwtPlot::axisCnt; axis ++ ) - setAxisScale(axis, interval.minValue(), interval.maxValue()); - - setCanvasBackground(QColor(Qt::darkBlue)); - plotLayout()->setAlignCanvasToScales(true); - - // grid - QwtPlotGrid *grid = new QwtPlotGrid; - //grid->enableXMin(true); - grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine)); - grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine)); - grid->attach(this); - - const int numEllipses = 10; - - for ( int i = 0; i < numEllipses; i++ ) - { - const double x = interval.minValue() + - qrand() % qRound(interval.width()); - const double y = interval.minValue() + - qrand() % qRound(interval.width()); - const double r = interval.minValue() + - qrand() % qRound(interval.width() / 6); - - const QRectF area(x - r, y - r , 2 * r, 2 * r); - - RectItem *item = new RectItem(RectItem::Ellipse); - item->setRenderHint(QwtPlotItem::RenderAntialiased, true); - item->setRect(area); - item->setPen(QPen(Qt::yellow)); - item->attach(this); - } - - - d_rectOfInterest = new RectItem(RectItem::Rect); - d_rectOfInterest->setPen(Qt::NoPen); - QColor c = Qt::gray; - c.setAlpha(100); - d_rectOfInterest->setBrush(QBrush(c)); - d_rectOfInterest->attach(this); -} - -void Plot::updateLayout() -{ - QwtPlot::updateLayout(); - - const QwtScaleMap xMap = canvasMap(QwtPlot::xBottom); - const QwtScaleMap yMap = canvasMap(QwtPlot::yLeft); - - const QRect cr = canvas()->contentsRect(); - const double x1 = xMap.invTransform(cr.left()); - const double x2 = xMap.invTransform(cr.right()); - const double y1 = yMap.invTransform(cr.bottom()); - const double y2 = yMap.invTransform(cr.top()); - - const double xRatio = (x2 - x1) / cr.width(); - const double yRatio = (y2 - y1) / cr.height(); - - Q_EMIT resized(xRatio, yRatio); -} - -void Plot::setRectOfInterest(const QRectF &rect) -{ - d_rectOfInterest->setRect(rect); -} diff --git a/qwt/examples/navigation/plot.h b/qwt/examples/navigation/plot.h deleted file mode 100644 index 3cfd7c9da..000000000 --- a/qwt/examples/navigation/plot.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _PLOT_H_ -#define _PLOT_H_ 1 - -#include - -class RectItem; -class QwtInterval; - -class Plot: public QwtPlot -{ - Q_OBJECT - -public: - Plot(QWidget *parent, const QwtInterval &); - virtual void updateLayout(); - - void setRectOfInterest(const QRectF &); - -Q_SIGNALS: - void resized(double xRatio, double yRatio); - -private: - RectItem *d_rectOfInterest; -}; - -#endif diff --git a/qwt/examples/oscilloscope/curvedata.cpp b/qwt/examples/oscilloscope/curvedata.cpp deleted file mode 100644 index 70ea567aa..000000000 --- a/qwt/examples/oscilloscope/curvedata.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "curvedata.h" -#include "signaldata.h" - -const SignalData &CurveData::values() const -{ - return SignalData::instance(); -} - -SignalData &CurveData::values() -{ - return SignalData::instance(); -} - -QPointF CurveData::sample(size_t i) const -{ - return SignalData::instance().value(i); -} - -size_t CurveData::size() const -{ - return SignalData::instance().size(); -} - -QRectF CurveData::boundingRect() const -{ - return SignalData::instance().boundingRect(); -} diff --git a/qwt/examples/oscilloscope/curvedata.h b/qwt/examples/oscilloscope/curvedata.h deleted file mode 100644 index 5f208e1af..000000000 --- a/qwt/examples/oscilloscope/curvedata.h +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -class SignalData; - -class CurveData: public QwtSeriesData -{ -public: - const SignalData &values() const; - SignalData &values(); - - virtual QPointF sample(size_t i) const; - virtual size_t size() const; - - virtual QRectF boundingRect() const; -}; diff --git a/qwt/examples/oscilloscope/knob.cpp b/qwt/examples/oscilloscope/knob.cpp deleted file mode 100644 index 9ca0845d0..000000000 --- a/qwt/examples/oscilloscope/knob.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "knob.h" -#include -#include -#include -#include -#include -#include -#include - -Knob::Knob(const QString &title, double min, double max, QWidget *parent): - QWidget(parent) -{ - QFont font("Helvetica", 10); - - d_knob = new QwtKnob(this); - d_knob->setFont(font); - d_knob->setRange(min, max); - - QwtScaleDiv scaleDiv = - d_knob->scaleEngine()->divideScale(min, max, 5, 3); - - QList ticks = scaleDiv.ticks(QwtScaleDiv::MajorTick); - if ( ticks.size() > 0 && ticks[0] > min ) - { - if ( ticks.first() > min ) - ticks.prepend(min); - if ( ticks.last() < max ) - ticks.append(max); - } - scaleDiv.setTicks(QwtScaleDiv::MajorTick, ticks); - d_knob->setScale(scaleDiv); - - d_knob->setKnobWidth(50); - - font.setBold(true); - d_label = new QLabel(title, this); - d_label->setFont(font); - d_label->setAlignment(Qt::AlignTop | Qt::AlignHCenter); - - setSizePolicy(QSizePolicy::MinimumExpanding, - QSizePolicy::MinimumExpanding); - - connect(d_knob, SIGNAL(valueChanged(double)), - this, SIGNAL(valueChanged(double))); -} - -QSize Knob::sizeHint() const -{ - QSize sz1 = d_knob->sizeHint(); - QSize sz2 = d_label->sizeHint(); - - const int w = qMax(sz1.width(), sz2.width()); - const int h = sz1.height() + sz2.height(); - - int off = d_knob->scaleDraw()->extent(d_knob->font()); - off -= 10; // spacing - - return QSize(w, h - off); -} - -void Knob::setValue(double value) -{ - d_knob->setValue(value); -} - -double Knob::value() const -{ - return d_knob->value(); -} - -void Knob::resizeEvent(QResizeEvent *e) -{ - const QSize sz = e->size(); - - int h = d_label->sizeHint().height(); - - d_label->setGeometry(0, sz.height() - h, - sz.width(), h); - - h = d_knob->sizeHint().height(); - int off = d_knob->scaleDraw()->extent(d_knob->font()); - off -= 10; // spacing - - d_knob->setGeometry(0, d_label->pos().y() - h + off, - sz.width(), h); -} diff --git a/qwt/examples/oscilloscope/knob.h b/qwt/examples/oscilloscope/knob.h deleted file mode 100644 index 6b06c65a3..000000000 --- a/qwt/examples/oscilloscope/knob.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _KNOB_H_ -#define _KNOB_H_ - -#include - -class QwtKnob; -class QLabel; - -class Knob: public QWidget -{ - Q_OBJECT - -public: - Knob(const QString &title, - double min, double max, QWidget *parent = NULL); - - virtual QSize sizeHint() const; - - void setValue(double value); - double value() const; - -Q_SIGNALS: - double valueChanged(double); - -protected: - virtual void resizeEvent(QResizeEvent *); - -private: - QwtKnob *d_knob; - QLabel *d_label; -}; - -#endif diff --git a/qwt/examples/oscilloscope/main.cpp b/qwt/examples/oscilloscope/main.cpp deleted file mode 100644 index 1ee6e9347..000000000 --- a/qwt/examples/oscilloscope/main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include "mainwindow.h" -#include "samplingthread.h" - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - MainWindow window; - window.resize(800,400); - - SamplingThread samplingThread; - samplingThread.setFrequency(window.frequency()); - samplingThread.setAmplitude(window.amplitude()); - samplingThread.setInterval(window.signalInterval()); - - window.connect(&window, SIGNAL(frequencyChanged(double)), - &samplingThread, SLOT(setFrequency(double))); - window.connect(&window, SIGNAL(amplitudeChanged(double)), - &samplingThread, SLOT(setAmplitude(double))); - window.connect(&window, SIGNAL(signalIntervalChanged(double)), - &samplingThread, SLOT(setInterval(double))); - - window.show(); - - samplingThread.start(); - window.start(); - - bool ok = app.exec(); - - samplingThread.stop(); - samplingThread.wait(1000); - - return ok; -} diff --git a/qwt/examples/oscilloscope/mainwindow.cpp b/qwt/examples/oscilloscope/mainwindow.cpp deleted file mode 100644 index abc158136..000000000 --- a/qwt/examples/oscilloscope/mainwindow.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "mainwindow.h" -#include "plot.h" -#include "knob.h" -#include "wheelbox.h" -#include -#include -#include - -MainWindow::MainWindow(QWidget *parent): - QWidget(parent) -{ - const double intervalLength = 10.0; // seconds - - d_plot = new Plot(this); - d_plot->setIntervalLength(intervalLength); - - d_amplitudeKnob = new Knob("Amplitude", 0.0, 200.0, this); - d_amplitudeKnob->setValue(160.0); - - d_frequencyKnob = new Knob("Frequency [Hz]", 0.1, 20.0, this); - d_frequencyKnob->setValue(17.8); - - d_intervalWheel = new WheelBox("Displayed [s]", 1.0, 100.0, 1.0, this); - d_intervalWheel->setValue(intervalLength); - - d_timerWheel = new WheelBox("Sample Interval [ms]", 0.0, 20.0, 0.1, this); - d_timerWheel->setValue(10.0); - - QVBoxLayout* vLayout1 = new QVBoxLayout(); - vLayout1->addWidget(d_intervalWheel); - vLayout1->addWidget(d_timerWheel); - vLayout1->addStretch(10); - vLayout1->addWidget(d_amplitudeKnob); - vLayout1->addWidget(d_frequencyKnob); - - QHBoxLayout *layout = new QHBoxLayout(this); - layout->addWidget(d_plot, 10); - layout->addLayout(vLayout1); - - connect(d_amplitudeKnob, SIGNAL(valueChanged(double)), - SIGNAL(amplitudeChanged(double))); - connect(d_frequencyKnob, SIGNAL(valueChanged(double)), - SIGNAL(frequencyChanged(double))); - connect(d_timerWheel, SIGNAL(valueChanged(double)), - SIGNAL(signalIntervalChanged(double))); - - connect(d_intervalWheel, SIGNAL(valueChanged(double)), - d_plot, SLOT(setIntervalLength(double)) ); -} - -void MainWindow::start() -{ - d_plot->start(); -} - -double MainWindow::frequency() const -{ - return d_frequencyKnob->value(); -} - -double MainWindow::amplitude() const -{ - return d_amplitudeKnob->value(); -} - -double MainWindow::signalInterval() const -{ - return d_timerWheel->value(); -} diff --git a/qwt/examples/oscilloscope/mainwindow.h b/qwt/examples/oscilloscope/mainwindow.h deleted file mode 100644 index 8f360f9c3..000000000 --- a/qwt/examples/oscilloscope/mainwindow.h +++ /dev/null @@ -1,32 +0,0 @@ -#include - -class Plot; -class Knob; -class WheelBox; - -class MainWindow : public QWidget -{ - Q_OBJECT - -public: - MainWindow(QWidget * = NULL); - - void start(); - - double amplitude() const; - double frequency() const; - double signalInterval() const; - -Q_SIGNALS: - void amplitudeChanged(double); - void frequencyChanged(double); - void signalIntervalChanged(double); - -private: - Knob *d_frequencyKnob; - Knob *d_amplitudeKnob; - WheelBox *d_timerWheel; - WheelBox *d_intervalWheel; - - Plot *d_plot; -}; diff --git a/qwt/examples/oscilloscope/oscilloscope.pro b/qwt/examples/oscilloscope/oscilloscope.pro deleted file mode 100644 index 6f2755262..000000000 --- a/qwt/examples/oscilloscope/oscilloscope.pro +++ /dev/null @@ -1,31 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = oscilloscope - -HEADERS = \ - signaldata.h \ - plot.h \ - knob.h \ - wheelbox.h \ - samplingthread.h \ - curvedata.h \ - mainwindow.h - -SOURCES = \ - signaldata.cpp \ - plot.cpp \ - knob.cpp \ - wheelbox.cpp \ - samplingthread.cpp \ - curvedata.cpp \ - mainwindow.cpp \ - main.cpp diff --git a/qwt/examples/oscilloscope/plot.cpp b/qwt/examples/oscilloscope/plot.cpp deleted file mode 100644 index df58b036b..000000000 --- a/qwt/examples/oscilloscope/plot.cpp +++ /dev/null @@ -1,232 +0,0 @@ -#include "plot.h" -#include "curvedata.h" -#include "signaldata.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -Plot::Plot(QWidget *parent): - QwtPlot(parent), - d_paintedPoints(0), - d_interval(0.0, 10.0), - d_timerId(-1) -{ - d_directPainter = new QwtPlotDirectPainter(); - - setAutoReplot(false); - - // The backing store is important, when working with widget - // overlays ( f.e rubberbands for zooming ). - // Here we don't have them and the internal - // backing store of QWidget is good enough. - - canvas()->setPaintAttribute(QwtPlotCanvas::BackingStore, false); - - -#if defined(Q_WS_X11) - // Even if not recommended by TrollTech, Qt::WA_PaintOutsidePaintEvent - // works on X11. This has a nice effect on the performance. - - canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true); - - // Disabling the backing store of Qt improves the performance - // for the direct painter even more, but the canvas becomes - // a native window of the window system, receiving paint events - // for resize and expose operations. Those might be expensive - // when there are many points and the backing store of - // the canvas is disabled. So in this application - // we better don't both backing stores. - - if ( canvas()->testPaintAttribute( QwtPlotCanvas::BackingStore ) ) - { - canvas()->setAttribute(Qt::WA_PaintOnScreen, true); - canvas()->setAttribute(Qt::WA_NoSystemBackground, true); - } - -#endif - - initGradient(); - - plotLayout()->setAlignCanvasToScales(true); - - setAxisTitle(QwtPlot::xBottom, "Time [s]"); - setAxisScale(QwtPlot::xBottom, d_interval.minValue(), d_interval.maxValue()); - setAxisScale(QwtPlot::yLeft, -200.0, 200.0); - - QwtPlotGrid *grid = new QwtPlotGrid(); - grid->setPen(QPen(Qt::gray, 0.0, Qt::DotLine)); - grid->enableX(true); - grid->enableXMin(true); - grid->enableY(true); - grid->enableYMin(false); - grid->attach(this); - - d_origin = new QwtPlotMarker(); - d_origin->setLineStyle(QwtPlotMarker::Cross); - d_origin->setValue(d_interval.minValue() + d_interval.width() / 2.0, 0.0); - d_origin->setLinePen(QPen(Qt::gray, 0.0, Qt::DashLine)); - d_origin->attach(this); - - d_curve = new QwtPlotCurve(); - d_curve->setStyle(QwtPlotCurve::Lines); - d_curve->setPen(QPen(Qt::green)); -#if 1 - d_curve->setRenderHint(QwtPlotItem::RenderAntialiased, true); -#endif -#if 1 - d_curve->setPaintAttribute(QwtPlotCurve::ClipPolygons, false); -#endif - d_curve->setData(new CurveData()); - d_curve->attach(this); -} - -Plot::~Plot() -{ - delete d_directPainter; -} - -void Plot::initGradient() -{ - QPalette pal = canvas()->palette(); - -#if QT_VERSION >= 0x040400 - QLinearGradient gradient( 0.0, 0.0, 1.0, 0.0 ); - gradient.setCoordinateMode( QGradient::StretchToDeviceMode ); - gradient.setColorAt(0.0, QColor( 0, 49, 110 ) ); - gradient.setColorAt(1.0, QColor( 0, 87, 174 ) ); - - pal.setBrush(QPalette::Window, QBrush(gradient)); -#else - pal.setBrush(QPalette::Window, QBrush( color )); -#endif - - canvas()->setPalette(pal); -} - -void Plot::start() -{ - d_clock.start(); - d_timerId = startTimer(10); -} - -void Plot::replot() -{ - CurveData *data = (CurveData *)d_curve->data(); - data->values().lock(); - - QwtPlot::replot(); - d_paintedPoints = data->size(); - - data->values().unlock(); -} - -void Plot::setIntervalLength(double interval) -{ - if ( interval > 0.0 && interval != d_interval.width() ) - { - d_interval.setMaxValue(d_interval.minValue() + interval); - setAxisScale(QwtPlot::xBottom, - d_interval.minValue(), d_interval.maxValue()); - - replot(); - } -} - -void Plot::updateCurve() -{ - CurveData *data = (CurveData *)d_curve->data(); - data->values().lock(); - - const int numPoints = data->size(); - if ( numPoints > d_paintedPoints ) - { - const bool doClip = !canvas()->testAttribute( Qt::WA_PaintOnScreen ); - if ( doClip ) - { - /* - Depending on the platform setting a clip might be an important - performance issue. F.e. for Qt Embedded this reduces the - part of the backing store that has to be copied out - maybe - to an unaccelerated frame buffer device. - */ - - const QwtScaleMap xMap = canvasMap( d_curve->xAxis() ); - const QwtScaleMap yMap = canvasMap( d_curve->yAxis() ); - - QRectF br = qwtBoundingRect( *data, - d_paintedPoints - 1, numPoints - 1 ); - - const QRect clipRect = QwtScaleMap::transform( xMap, yMap, br ).toRect(); - d_directPainter->setClipRegion( clipRect ); - } - - d_directPainter->drawSeries(d_curve, - d_paintedPoints - 1, numPoints - 1); - d_paintedPoints = numPoints; - } - - data->values().unlock(); -} - -void Plot::incrementInterval() -{ - d_interval = QwtInterval(d_interval.maxValue(), - d_interval.maxValue() + d_interval.width()); - - CurveData *data = (CurveData *)d_curve->data(); - data->values().clearStaleValues(d_interval.minValue()); - - // To avoid, that the grid is jumping, we disable - // the autocalculation of the ticks and shift them - // manually instead. - - QwtScaleDiv scaleDiv = *axisScaleDiv(QwtPlot::xBottom); - scaleDiv.setInterval(d_interval); - - for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ ) - { - QList ticks = scaleDiv.ticks(i); - for ( int j = 0; j < ticks.size(); j++ ) - ticks[j] += d_interval.width(); - scaleDiv.setTicks(i, ticks); - } - setAxisScaleDiv(QwtPlot::xBottom, scaleDiv); - - d_origin->setValue(d_interval.minValue() + d_interval.width() / 2.0, 0.0); - - d_paintedPoints = 0; - replot(); -} - -void Plot::timerEvent(QTimerEvent *event) -{ - if ( event->timerId() == d_timerId ) - { - updateCurve(); - - const double elapsed = d_clock.elapsed() / 1000.0; - if ( elapsed > d_interval.maxValue() ) - incrementInterval(); - - return; - } - - QwtPlot::timerEvent(event); -} - -void Plot::resizeEvent(QResizeEvent *event) -{ - d_directPainter->reset(); - QwtPlot::resizeEvent(event); -} - -void Plot::showEvent( QShowEvent * ) -{ - replot(); -} diff --git a/qwt/examples/oscilloscope/plot.h b/qwt/examples/oscilloscope/plot.h deleted file mode 100644 index 27a9d3210..000000000 --- a/qwt/examples/oscilloscope/plot.h +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include - -class QwtPlotCurve; -class QwtPlotMarker; -class QwtPlotDirectPainter; - -class Plot: public QwtPlot -{ - Q_OBJECT - -public: - Plot(QWidget * = NULL); - virtual ~Plot(); - - void start(); - virtual void replot(); - -public Q_SLOTS: - void setIntervalLength(double); - -protected: - virtual void showEvent(QShowEvent *); - virtual void resizeEvent(QResizeEvent *); - virtual void timerEvent(QTimerEvent *); - -private: - void initGradient(); - - void updateCurve(); - void incrementInterval(); - - QwtPlotMarker *d_origin; - QwtPlotCurve *d_curve; - int d_paintedPoints; - - QwtPlotDirectPainter *d_directPainter; - - QwtInterval d_interval; - int d_timerId; - - QwtSystemClock d_clock; -}; diff --git a/qwt/examples/oscilloscope/samplingthread.cpp b/qwt/examples/oscilloscope/samplingthread.cpp deleted file mode 100644 index 9d617e52c..000000000 --- a/qwt/examples/oscilloscope/samplingthread.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "samplingthread.h" -#include "signaldata.h" -#include -#include - -#if QT_VERSION < 0x040600 -#define qFastSin(x) ::sin(x) -#endif - -SamplingThread::SamplingThread(QObject *parent): - QwtSamplingThread(parent), - d_frequency(5.0), - d_amplitude(20.0) -{ -} - -void SamplingThread::setFrequency(double frequency) -{ - d_frequency = frequency; -} - -double SamplingThread::frequency() const -{ - return d_frequency; -} - -void SamplingThread::setAmplitude(double amplitude) -{ - d_amplitude = amplitude; -} - -double SamplingThread::amplitude() const -{ - return d_amplitude; -} - -void SamplingThread::sample(double elapsed) -{ - if ( d_frequency > 0.0 ) - { - const QPointF s(elapsed, value(elapsed)); - SignalData::instance().append(s); - } -} - -double SamplingThread::value(double timeStamp) const -{ - const double period = 1.0 / d_frequency; - - const double x = ::fmod(timeStamp, period); - const double v = d_amplitude * qFastSin(x / period * 2 * M_PI); - - return v; -} diff --git a/qwt/examples/oscilloscope/samplingthread.h b/qwt/examples/oscilloscope/samplingthread.h deleted file mode 100644 index 551d8acca..000000000 --- a/qwt/examples/oscilloscope/samplingthread.h +++ /dev/null @@ -1,25 +0,0 @@ -#include - -class SamplingThread: public QwtSamplingThread -{ - Q_OBJECT - -public: - SamplingThread(QObject *parent = NULL); - - double frequency() const; - double amplitude() const; - -public Q_SLOTS: - void setAmplitude(double); - void setFrequency(double); - -protected: - virtual void sample(double elapsed); - -private: - virtual double value(double timeStamp) const; - - double d_frequency; - double d_amplitude; -}; diff --git a/qwt/examples/oscilloscope/signaldata.cpp b/qwt/examples/oscilloscope/signaldata.cpp deleted file mode 100644 index 1e07cc389..000000000 --- a/qwt/examples/oscilloscope/signaldata.cpp +++ /dev/null @@ -1,133 +0,0 @@ -#include "signaldata.h" -#include -#include -#include - -class SignalData::PrivateData -{ -public: - PrivateData(): - boundingRect(1.0, 1.0, -2.0, -2.0) // invalid - { - values.reserve(1000); - } - - inline void append(const QPointF &sample) - { - values.append(sample); - - // adjust the bounding rectangle - - if ( boundingRect.width() < 0 || boundingRect.height() < 0 ) - { - boundingRect.setRect(sample.x(), sample.y(), 0.0, 0.0); - } - else - { - boundingRect.setRight(sample.x()); - - if ( sample.y() > boundingRect.bottom() ) - boundingRect.setBottom(sample.y()); - - if ( sample.y() < boundingRect.top() ) - boundingRect.setTop(sample.y()); - } - } - - QReadWriteLock lock; - - QVector values; - QRectF boundingRect; - - QMutex mutex; // protecting pendingValues - QVector pendingValues; -}; - -SignalData::SignalData() -{ - d_data = new PrivateData(); -} - -SignalData::~SignalData() -{ - delete d_data; -} - -int SignalData::size() const -{ - return d_data->values.size(); -} - -QPointF SignalData::value(int index) const -{ - return d_data->values[index]; -} - -QRectF SignalData::boundingRect() const -{ - return d_data->boundingRect; -} - -void SignalData::lock() -{ - d_data->lock.lockForRead(); -} - -void SignalData::unlock() -{ - d_data->lock.unlock(); -} - -void SignalData::append(const QPointF &sample) -{ - d_data->mutex.lock(); - d_data->pendingValues += sample; - - const bool isLocked = d_data->lock.tryLockForWrite(); - if ( isLocked ) - { - const int numValues = d_data->pendingValues.size(); - const QPointF *pendingValues = d_data->pendingValues.data(); - - for ( int i = 0; i < numValues; i++ ) - d_data->append(pendingValues[i]); - - d_data->pendingValues.clear(); - - d_data->lock.unlock(); - } - - d_data->mutex.unlock(); -} - -void SignalData::clearStaleValues(double limit) -{ - d_data->lock.lockForWrite(); - - d_data->boundingRect = QRectF(1.0, 1.0, -2.0, -2.0); // invalid - - const QVector values = d_data->values; - d_data->values.clear(); - d_data->values.reserve(values.size()); - - int index; - for ( index = values.size() - 1; index >= 0; index-- ) - { - if ( values[index].x() < limit ) - break; - } - - if ( index > 0 ) - d_data->append(values[index++]); - - while ( index < values.size() - 1 ) - d_data->append(values[index++]); - - d_data->lock.unlock(); -} - -SignalData &SignalData::instance() -{ - static SignalData valueVector; - return valueVector; -} diff --git a/qwt/examples/oscilloscope/signaldata.h b/qwt/examples/oscilloscope/signaldata.h deleted file mode 100644 index d487a3ba9..000000000 --- a/qwt/examples/oscilloscope/signaldata.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _SIGNAL_DATA_H_ -#define _SIGNAL_DATA_H_ 1 - -#include - -class SignalData -{ -public: - static SignalData &instance(); - - void append(const QPointF &pos); - void clearStaleValues(double min); - - int size() const; - QPointF value(int index) const; - - QRectF boundingRect() const; - - void lock(); - void unlock(); - -private: - SignalData(); - SignalData(const SignalData &); - SignalData &operator=( const SignalData & ); - - virtual ~SignalData(); - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/examples/oscilloscope/wheelbox.cpp b/qwt/examples/oscilloscope/wheelbox.cpp deleted file mode 100644 index e89b8a453..000000000 --- a/qwt/examples/oscilloscope/wheelbox.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "wheelbox.h" -#include -#include -#include -#include -#include -#include - -class Wheel: public QwtWheel -{ -public: - Wheel(WheelBox *parent): - QwtWheel(parent) - { - setFocusPolicy(Qt::WheelFocus); - parent->installEventFilter(this); - } - - virtual bool eventFilter(QObject *object, QEvent *ev) - { - if ( ev->type() == QEvent::Wheel ) - { - QWheelEvent *we = (QWheelEvent *)ev; - - QWheelEvent wheelEvent(QPoint(5, 5), we->delta(), - we->buttons(), we->modifiers(), - we->orientation()); - - QApplication::sendEvent(this, &wheelEvent); - return true; - } - return QwtWheel::eventFilter(object, ev); - } -}; - -WheelBox::WheelBox(const QString &title, - double min, double max, double stepSize, QWidget *parent): - QWidget(parent) -{ - - d_number = new QLCDNumber(this); - d_number->setSegmentStyle(QLCDNumber::Filled); - d_number->setAutoFillBackground(true); - d_number->setFixedHeight(d_number->sizeHint().height() * 2 ); - d_number->setFocusPolicy(Qt::WheelFocus); - - QPalette pal(Qt::black); - pal.setColor(QPalette::WindowText, Qt::green); - d_number->setPalette(pal); - - d_wheel = new Wheel(this); - d_wheel->setOrientation(Qt::Vertical); - d_wheel->setRange(min, max, stepSize); - d_wheel->setFixedSize( - qRound(d_number->height() / 2.5), d_number->height()); - - d_number->setFocusProxy(d_wheel); - - QFont font("Helvetica", 10); - font.setBold(true); - - d_label = new QLabel(title, this); - d_label->setFont(font); - - QHBoxLayout *hLayout = new QHBoxLayout; - hLayout->setContentsMargins(0, 0, 0, 0); - hLayout->setSpacing(2); - hLayout->addWidget(d_number, 10); - hLayout->addWidget(d_wheel); - - QVBoxLayout *vLayout = new QVBoxLayout(this); - vLayout->addLayout(hLayout, 10); - vLayout->addWidget(d_label, 0, Qt::AlignTop | Qt::AlignHCenter); - - connect(d_wheel, SIGNAL(valueChanged(double)), - d_number, SLOT(display(double))); - connect(d_wheel, SIGNAL(valueChanged(double)), - this, SIGNAL(valueChanged(double))); -} - -void WheelBox::setValue(double value) -{ - d_wheel->setValue(value); - d_number->display(value); -} - -double WheelBox::value() const -{ - return d_wheel->value(); -} diff --git a/qwt/examples/oscilloscope/wheelbox.h b/qwt/examples/oscilloscope/wheelbox.h deleted file mode 100644 index d79963e42..000000000 --- a/qwt/examples/oscilloscope/wheelbox.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _WHEELBOX_H_ -#define _WHEELBOX_H_ - -#include - -class QwtWheel; -class QLabel; -class QLCDNumber; - -class WheelBox: public QWidget -{ - Q_OBJECT - -public: - WheelBox(const QString &title, - double min, double max, double stepSize, - QWidget *parent = NULL); - - void setUnit(const QString &); - QString unit() const; - - void setValue(double value); - double value() const; - -Q_SIGNALS: - double valueChanged(double); - -private: - QLCDNumber *d_number; - QwtWheel *d_wheel; - QLabel *d_label; - - QString d_unit; -}; - -#endif diff --git a/qwt/examples/plotmatrix/main.cpp b/qwt/examples/plotmatrix/main.cpp deleted file mode 100644 index a17dc61e7..000000000 --- a/qwt/examples/plotmatrix/main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include -#include "plotmatrix.h" - -class MainWindow: public PlotMatrix -{ -public: - MainWindow(); -}; - -MainWindow::MainWindow(): - PlotMatrix(3, 4) -{ - enableAxis(QwtPlot::yLeft); - enableAxis(QwtPlot::yRight); - enableAxis(QwtPlot::xBottom); - - for ( int row = 0; row < numRows(); row++ ) - { - const double v = qPow(10.0, row); - setAxisScale(QwtPlot::yLeft, row, -v, v); - setAxisScale(QwtPlot::yRight, row, -v, v); - } - - for ( int col = 0; col < numColumns(); col++ ) - { - const double v = qPow(10.0, col); - setAxisScale(QwtPlot::xBottom, col, -v, v); - setAxisScale(QwtPlot::xTop, col, -v, v); - } - - for ( int row = 0; row < numRows(); row++ ) - { - for ( int col = 0; col < numColumns(); col++ ) - { - QwtPlot *plt = plot(row, col); - plt->setCanvasBackground(QColor(Qt::darkBlue)); - - QwtPlotGrid *grid = new QwtPlotGrid(); - grid->enableXMin(true); - grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine)); - grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine)); - grid->attach(plt); - } - } -} - -int main(int argc, char **argv) -{ - QApplication a(argc, argv); - - MainWindow mainWindow; - - mainWindow.resize(800,600); - mainWindow.show(); - - return a.exec(); -} diff --git a/qwt/examples/plotmatrix/plotmatrix.cpp b/qwt/examples/plotmatrix/plotmatrix.cpp deleted file mode 100644 index b75b1d49e..000000000 --- a/qwt/examples/plotmatrix/plotmatrix.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -// vim: expandtab - -#include -#include -#include -#include -#include -#include "plotmatrix.h" - -class PlotMatrix::PrivateData -{ -public: - PrivateData(): - inScaleSync(false) - { - isAxisEnabled[QwtPlot::xBottom] = true; - isAxisEnabled[QwtPlot::xTop] = false; - isAxisEnabled[QwtPlot::yLeft] = true; - isAxisEnabled[QwtPlot::yRight] = false; - } - - bool isAxisEnabled[QwtPlot::axisCnt]; - QVector plotWidgets; - mutable bool inScaleSync; -}; - -PlotMatrix::PlotMatrix( int numRows, int numColumns, QWidget *parent): - QFrame(parent) -{ - d_data = new PrivateData(); - d_data->plotWidgets.resize(numRows * numColumns); - - QGridLayout *layout = new QGridLayout(this); - for ( int row = 0; row < numRows; row++ ) - { - for ( int col = 0; col < numColumns; col++ ) - { - QwtPlot *plot = new QwtPlot(this); - layout->addWidget(plot, row, col); - - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - { - connect(plot->axisWidget(axis), - SIGNAL(scaleDivChanged()), SLOT(scaleDivChanged()) ); - } - d_data->plotWidgets[row * numColumns + col] = plot; - } - } - - updateLayout(); -} - -PlotMatrix::~PlotMatrix() -{ - delete d_data; -} - -int PlotMatrix::numRows() const -{ - const QGridLayout *l = qobject_cast(layout()); - if ( l ) - return l->rowCount(); - - return 0; -} - -int PlotMatrix::numColumns() const -{ - const QGridLayout *l = qobject_cast(layout()); - if ( l ) - return l->columnCount(); - return 0; -} - -QwtPlot* PlotMatrix::plot(int row, int column) -{ - const int index = row * numColumns() + column; - if ( index < (int)d_data->plotWidgets.size() ) - return d_data->plotWidgets[index]; - - return NULL; -} - -const QwtPlot* PlotMatrix::plot(int row, int column) const -{ - const int index = row * numColumns() + column; - if ( index < (int)d_data->plotWidgets.size() ) - return d_data->plotWidgets[index]; - - return NULL; -} - -void PlotMatrix::enableAxis(int axis, bool tf) -{ - if ( axis >= 0 && axis < QwtPlot::axisCnt ) - { - if ( tf != d_data->isAxisEnabled[axis] ) - { - d_data->isAxisEnabled[axis] = tf; - updateLayout(); - } - } -} - -bool PlotMatrix::axisEnabled(int axis) const -{ - if ( axis >= 0 && axis < QwtPlot::axisCnt ) - return d_data->isAxisEnabled[axis]; - - return false; -} - -void PlotMatrix::setAxisScale(int axis, int rowOrColumn, - double min, double max, double step) -{ - int row = 0; - int col = 0; - - if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop ) - col = rowOrColumn; - else - row = rowOrColumn; - - QwtPlot *plt = plot(row, col); - if ( plt ) - { - plt->setAxisScale(axis, min, max, step); - plt->updateAxes(); - } -} - -void PlotMatrix::scaleDivChanged() -{ - if ( d_data->inScaleSync ) - return; - - d_data->inScaleSync = true; - - QwtPlot *plt = NULL; - int axisId = -1; - int rowOrColumn = -1; - - // find the changed axis - for ( int row = 0; row < numRows(); row++ ) - { - for ( int col = 0; col < numColumns(); col++ ) - { - QwtPlot *p = plot(row, col); - if ( p ) - { - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - { - if ( p->axisWidget(axis) == sender() ) - { - plt = p; - axisId = axis; - if ( axisId == QwtPlot::xBottom || axisId == QwtPlot::xTop ) - rowOrColumn = col; - else - rowOrColumn = row; - - } - } - } - } - } - - if ( plt ) - { - - // synchronize the axes - if ( axisId == QwtPlot::xBottom || axisId == QwtPlot::xTop ) - { - for ( int row = 0; row < numRows(); row++ ) - { - QwtPlot *p = plot(row, rowOrColumn); - if ( p != plt ) - p->setAxisScaleDiv(axisId, *plt->axisScaleDiv(axisId)); - } - } - else - { - for ( int col = 0; col < numColumns(); col++ ) - { - QwtPlot *p = plot(rowOrColumn, col); - if ( p != plt ) - p->setAxisScaleDiv(axisId, *plt->axisScaleDiv(axisId)); - } - } - - updateLayout(); - } - - d_data->inScaleSync = false; -} - -void PlotMatrix::updateLayout() -{ - for ( int row = 0; row < numRows(); row++ ) - { - for ( int col = 0; col < numColumns(); col++ ) - { - QwtPlot *p = plot(row, col); - if ( p ) - { - bool showAxis[QwtPlot::axisCnt]; - showAxis[QwtPlot::xBottom] = - axisEnabled(QwtPlot::xBottom) && row == numRows() - 1; - showAxis[QwtPlot::xTop] = - axisEnabled(QwtPlot::xTop) && row == 0; - showAxis[QwtPlot::yLeft] = - axisEnabled(QwtPlot::yLeft) && col == 0; - showAxis[QwtPlot::yRight] = - axisEnabled(QwtPlot::yRight) && col == numColumns() - 1; - - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - { - if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop ) - p->enableAxis(axis, showAxis[axis]); - else - { - p->enableAxis(axis, true); - - QwtScaleDraw *sd = p->axisScaleDraw(axis); - sd->enableComponent( - QwtScaleDraw::Backbone, showAxis[axis]); - sd->enableComponent( - QwtScaleDraw::Ticks, showAxis[axis]); - sd->enableComponent( - QwtScaleDraw::Labels, showAxis[axis]); - } - } - } - } - } - - for ( int col = 0; col < numColumns(); col++ ) - { - alignVAxes(col, QwtPlot::yLeft); - alignVAxes(col, QwtPlot::yRight); - } - - for ( int row = 0; row < numRows(); row++ ) - { - for ( int col = 0; col < numColumns(); col++ ) - { - QwtPlot *p = plot(row, col); - if ( p ) - p->replot(); - } - } -} - -void PlotMatrix::alignVAxes(int col, int axis) -{ - if ( axis != QwtPlot::yLeft && axis != QwtPlot::yRight ) - return; - - int maxExtent = 0; - for ( int row = 0; row < numRows(); row++ ) - { - QwtPlot *p = plot(row, col); - if ( p ) - { - QwtScaleWidget *scaleWidget = p->axisWidget(axis); - - QwtScaleDraw *sd = scaleWidget->scaleDraw(); - sd->setMinimumExtent(0); - - const int extent = sd->extent( scaleWidget->font() ); - if ( extent > maxExtent ) - maxExtent = extent; - } - } - for ( int row = 0; row < numRows(); row++ ) - { - QwtPlot *p = plot(row, col); - if ( p ) - { - QwtScaleWidget *scaleWidget = p->axisWidget(axis); - scaleWidget->scaleDraw()->setMinimumExtent(maxExtent); - } - } -} diff --git a/qwt/examples/plotmatrix/plotmatrix.h b/qwt/examples/plotmatrix/plotmatrix.h deleted file mode 100644 index ab20f29f7..000000000 --- a/qwt/examples/plotmatrix/plotmatrix.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _PLOT_MATRIX_H_ -#define _PLOT_MATRIX_H_ - -#include -#include - -class PlotMatrix: public QFrame -{ - Q_OBJECT - -public: - PlotMatrix( int rows, int columns, QWidget * parent = NULL); - virtual ~PlotMatrix(); - - int numRows() const; - int numColumns() const; - - QwtPlot* plot(int row, int column); - const QwtPlot* plot(int row, int column) const; - - void enableAxis(int axisId, bool tf = true); - bool axisEnabled(int axisId) const; - - void setAxisScale(int axisId, int rowOrColumn, - double min, double max, double step = 0); - -private Q_SLOTS: - void scaleDivChanged(); - -private: - void updateLayout(); - void alignVAxes(int col, int axis); - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/examples/plotmatrix/plotmatrix.pro b/qwt/examples/plotmatrix/plotmatrix.pro deleted file mode 100644 index f092bebe7..000000000 --- a/qwt/examples/plotmatrix/plotmatrix.pro +++ /dev/null @@ -1,19 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = plotmatrix - -HEADERS = \ - plotmatrix.h - -SOURCES = \ - plotmatrix.cpp \ - main.cpp diff --git a/qwt/examples/radio/ampfrm.cpp b/qwt/examples/radio/ampfrm.cpp deleted file mode 100644 index 2e0dec3de..000000000 --- a/qwt/examples/radio/ampfrm.cpp +++ /dev/null @@ -1,201 +0,0 @@ -#include "ampfrm.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if QT_VERSION < 0x040600 -#define qFastSin(x) ::sin(x) -#define qFastCos(x) ::cos(x) -#endif - -class Knob: public QWidget -{ -public: - Knob(const QString &title, double min, double max, QWidget *parent): - QWidget(parent) - { - d_knob = new QwtKnob(this); - d_knob->setRange(min, max, 0,1); - d_knob->setScaleMaxMajor(10); - - d_knob->setKnobStyle(QwtKnob::Raised); - d_knob->setKnobWidth(50); - d_knob->setBorderWidth(2); - d_knob->setMarkerStyle(QwtKnob::Notch); - d_knob->setMarkerSize( 8 ); - - d_knob->scaleDraw()->setTickLength( QwtScaleDiv::MinorTick, 4 ); - d_knob->scaleDraw()->setTickLength( QwtScaleDiv::MediumTick, 4 ); - d_knob->scaleDraw()->setTickLength( QwtScaleDiv::MajorTick, 6 ); - - d_label = new QLabel(title, this); - d_label->setAlignment(Qt::AlignTop | Qt::AlignHCenter); - - setSizePolicy(QSizePolicy::MinimumExpanding, - QSizePolicy::MinimumExpanding); - } - - virtual QSize sizeHint() const - { - QSize sz1 = d_knob->sizeHint(); - QSize sz2 = d_label->sizeHint(); - - const int w = qMax(sz1.width(), sz2.width()); - const int h = sz1.height() + sz2.height(); - - int off = d_knob->scaleDraw()->extent(d_knob->font()); - off -= 10; // spacing - - return QSize(w, h - off); - } - - void setValue( double value ) - { - d_knob->setValue( value ); - } - - double value() const - { - return d_knob->value(); - } - -protected: - virtual void resizeEvent(QResizeEvent *e) - { - const QSize sz = e->size(); - - int h = d_label->sizeHint().height(); - - d_label->setGeometry(0, sz.height() - h, - sz.width(), h); - - h = d_knob->sizeHint().height(); - int off = d_knob->scaleDraw()->extent(d_knob->font()); - off -= 10; // spacing - - d_knob->setGeometry(0, d_label->pos().y() - h + off, - sz.width(), h); - } - -private: - QwtKnob *d_knob; - QLabel *d_label; -}; - -class Thermo: public QWidget -{ -public: - Thermo(const QString &title, QWidget *parent): - QWidget(parent) - { - d_thermo = new QwtThermo( this ); - d_thermo->setPipeWidth( 6 ); - d_thermo->setRange( -40, 10 ); - d_thermo->setFillBrush( Qt::green ); - d_thermo->setAlarmBrush( Qt::red ); - d_thermo->setAlarmLevel( 0.0 ); - d_thermo->setAlarmEnabled( true ); - - QLabel *label = new QLabel(title, this); - label->setAlignment(Qt::AlignTop | Qt::AlignLeft); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); - layout->setSpacing(0); - layout->addWidget(d_thermo, 10); - layout->addWidget(label); - } - - void setValue(double value) - { - d_thermo->setValue(value); - } - -private: - QwtThermo *d_thermo; -}; - -AmpFrame::AmpFrame(QWidget *p): - QFrame(p) -{ - d_knbVolume = new Knob("Volume", 0.0, 10.0, this); - d_knbBalance = new Knob("Balance", -10.0, 10.0, this); - d_knbTreble = new Knob("Treble", -10.0, 10.0, this); - d_knbBass = new Knob("Bass", -10.0, 10.0, this); - - d_thmLeft = new Thermo("Left [dB]", this); - d_thmRight = new Thermo("Right [dB]", this); - - QHBoxLayout *layout = new QHBoxLayout(this); - layout->setSpacing(0); - layout->setMargin(10); - layout->addWidget(d_knbVolume); - layout->addWidget(d_knbBalance); - layout->addWidget(d_knbTreble); - layout->addWidget(d_knbBass); - layout->addSpacing(20); - layout->addStretch(10); - layout->addWidget(d_thmLeft); - layout->addSpacing(10); - layout->addWidget(d_thmRight); - - d_knbVolume->setValue( 7.0 ); - (void)startTimer(50); -} - -void AmpFrame::timerEvent(QTimerEvent *) -{ - static double phs = 0; - - // - // This amplifier generates its own input signal... - // - - const double sig_bass = (1.0 + 0.1 * d_knbBass->value()) - * qFastSin(13.0 * phs); - const double sig_mid_l = qFastSin(17.0 * phs); - const double sig_mid_r = qFastCos(17.5 * phs); - const double sig_trbl_l = 0.5 * (1.0 + 0.1 * d_knbTreble->value()) - * qFastSin(35.0 * phs); - const double sig_trbl_r = 0.5 * (1.0 + 0.1 * d_knbTreble->value()) - * qFastSin(34.0 * phs); - - double sig_l = 0.05 * d_master * d_knbVolume->value() - * qwtSqr(sig_bass + sig_mid_l + sig_trbl_l); - double sig_r = 0.05 * d_master * d_knbVolume->value() - * qwtSqr(sig_bass + sig_mid_r + sig_trbl_r); - - double balance = 0.1 * d_knbBalance->value(); - if (balance > 0) - sig_l *= (1.0 - balance); - else - sig_r *= (1.0 + balance); - - if (sig_l > 0.01) - sig_l = 20.0 * log10(sig_l); - else - sig_l = -40.0; - - if (sig_r > 0.01) - sig_r = 20.0 * log10(sig_r); - else - sig_r = - 40.0; - - d_thmLeft->setValue(sig_l); - d_thmRight->setValue(sig_r); - - phs += M_PI / 100; - if (phs > M_PI) - phs = 0; -} - -void AmpFrame::setMaster(double v) -{ - d_master = v; -} diff --git a/qwt/examples/radio/ampfrm.h b/qwt/examples/radio/ampfrm.h deleted file mode 100644 index 940b9cad0..000000000 --- a/qwt/examples/radio/ampfrm.h +++ /dev/null @@ -1,26 +0,0 @@ -#include - -class Knob; -class Thermo; - -class AmpFrame : public QFrame -{ - Q_OBJECT -public: - AmpFrame(QWidget *); - -public Q_SLOTS: - void setMaster(double v); - -protected: - void timerEvent(QTimerEvent *); - -private: - Knob *d_knbVolume; - Knob *d_knbBalance; - Knob *d_knbTreble; - Knob *d_knbBass; - Thermo *d_thmLeft; - Thermo *d_thmRight; - double d_master; -}; diff --git a/qwt/examples/radio/mainwindow.cpp b/qwt/examples/radio/mainwindow.cpp deleted file mode 100644 index 838078799..000000000 --- a/qwt/examples/radio/mainwindow.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include "tunerfrm.h" -#include "ampfrm.h" -#include "mainwindow.h" - -MainWindow::MainWindow(): - QWidget() -{ - TunerFrame *frmTuner = new TunerFrame(this); - frmTuner->setFrameStyle(QFrame::Panel|QFrame::Raised); - - AmpFrame *frmAmp = new AmpFrame(this); - frmAmp->setFrameStyle(QFrame::Panel|QFrame::Raised); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); - layout->setSpacing(0); - layout->addWidget(frmTuner); - layout->addWidget(frmAmp); - - connect(frmTuner, SIGNAL(fieldChanged(double)), - frmAmp, SLOT(setMaster(double))); - - frmTuner->setFreq(90.0); - - setPalette( QPalette( QColor( 192, 192, 192 ) ) ); - updateGradient(); -} - -void MainWindow::resizeEvent( QResizeEvent * ) -{ -#ifdef Q_WS_X11 - updateGradient(); -#endif -} - -void MainWindow::updateGradient() -{ - QPalette pal = palette(); - - const QColor buttonColor = pal.color( QPalette::Button ); - const QColor lightColor = pal.color( QPalette::Light ); - const QColor midLightColor = pal.color( QPalette::Midlight ); - -#ifdef Q_WS_X11 - // Qt 4.7.1: QGradient::StretchToDeviceMode is buggy on X11 - - QLinearGradient gradient( rect().topLeft(), rect().topRight() ); -#else - QLinearGradient gradient( 0, 0, 1, 0 ); - gradient.setCoordinateMode( QGradient::StretchToDeviceMode ); -#endif - - gradient.setColorAt( 0.0, midLightColor ); - gradient.setColorAt( 0.7, buttonColor ); - gradient.setColorAt( 1.0, buttonColor ); - - pal.setBrush( QPalette::Window, gradient ); - setPalette( pal ); -} diff --git a/qwt/examples/radio/mainwindow.h b/qwt/examples/radio/mainwindow.h deleted file mode 100644 index 4159f4a9b..000000000 --- a/qwt/examples/radio/mainwindow.h +++ /dev/null @@ -1,13 +0,0 @@ -#include - -class MainWindow : public QWidget -{ -public: - MainWindow(); - -protected: - virtual void resizeEvent( QResizeEvent * ); - -private: - void updateGradient(); -}; diff --git a/qwt/examples/radio/radio.cpp b/qwt/examples/radio/radio.cpp deleted file mode 100644 index 646df24f9..000000000 --- a/qwt/examples/radio/radio.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include "mainwindow.h" - -int main (int argc, char **argv) -{ - QApplication a(argc, argv); - - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qwt/examples/radio/radio.pro b/qwt/examples/radio/radio.pro deleted file mode 100644 index 6149808f8..000000000 --- a/qwt/examples/radio/radio.pro +++ /dev/null @@ -1,23 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = radio - -HEADERS = \ - mainwindow.h \ - ampfrm.h \ - tunerfrm.h - -SOURCES = \ - mainwindow.cpp \ - ampfrm.cpp \ - tunerfrm.cpp \ - radio.cpp diff --git a/qwt/examples/radio/tunerfrm.cpp b/qwt/examples/radio/tunerfrm.cpp deleted file mode 100644 index ad9440d9c..000000000 --- a/qwt/examples/radio/tunerfrm.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "tunerfrm.h" - -#if QT_VERSION < 0x040600 -#define qFastSin(x) ::sin(x) -#define qFastCos(x) ::cos(x) -#endif - -class TuningThermo: public QWidget -{ -public: - TuningThermo(QWidget *parent): - QWidget(parent) - { - d_thermo = new QwtThermo(this); - d_thermo->setOrientation(Qt::Horizontal, QwtThermo::NoScale); - d_thermo->setRange(0.0, 1.0); - d_thermo->setFillBrush( Qt::green ); - - QLabel *label = new QLabel("Tuning", this); - label->setAlignment(Qt::AlignCenter); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); - layout->addWidget(d_thermo); - layout->addWidget(label); - - setFixedWidth(3 * label->sizeHint().width()); - } - - void setValue(double value) - { - d_thermo->setValue(value); - } - -private: - QwtThermo *d_thermo; -}; - -TunerFrame::TunerFrame(QWidget *parent): - QFrame(parent) -{ - d_sliderFrequency = new QwtSlider(this, Qt::Horizontal, QwtSlider::TopScale); - d_sliderFrequency->setRange(87.5, 108, 0.01, 10); - d_sliderFrequency->setScaleMaxMinor(5); - d_sliderFrequency->setScaleMaxMajor(12); - d_sliderFrequency->setHandleSize(80, 20 ); - d_sliderFrequency->setBorderWidth(1); - - d_thermoTune = new TuningThermo(this); - - d_wheelFrequency = new QwtWheel(this); - d_wheelFrequency->setMass(0.5); - d_wheelFrequency->setRange(87.5, 108, 0.01); - d_wheelFrequency->setTotalAngle(3600.0); - d_wheelFrequency->setFixedHeight(30); - - - connect(d_wheelFrequency, SIGNAL(valueChanged(double)), SLOT(adjustFreq(double))); - connect(d_sliderFrequency, SIGNAL(valueChanged(double)), SLOT(adjustFreq(double))); - - QVBoxLayout *mainLayout = new QVBoxLayout(this); - mainLayout->setMargin(10); - mainLayout->setSpacing(5); - mainLayout->addWidget(d_sliderFrequency); - - QHBoxLayout *hLayout = new QHBoxLayout; - hLayout->setMargin(0); - hLayout->addWidget(d_thermoTune, 0); - hLayout->addStretch(5); - hLayout->addWidget(d_wheelFrequency, 2); - - mainLayout->addLayout(hLayout); -} - -void TunerFrame::adjustFreq(double frq) -{ - const double factor = 13.0 / (108 - 87.5); - - const double x = (frq - 87.5) * factor; - const double field = qwtSqr(qFastSin(x) * qFastCos(4.0 * x)); - - d_thermoTune->setValue(field); - - if (d_sliderFrequency->value() != frq) - d_sliderFrequency->setValue(frq); - if (d_wheelFrequency->value() != frq) - d_wheelFrequency->setValue(frq); - - Q_EMIT fieldChanged(field); -} - -void TunerFrame::setFreq(double frq) -{ - d_wheelFrequency->setValue(frq); -} diff --git a/qwt/examples/radio/tunerfrm.h b/qwt/examples/radio/tunerfrm.h deleted file mode 100644 index ddcaa532d..000000000 --- a/qwt/examples/radio/tunerfrm.h +++ /dev/null @@ -1,26 +0,0 @@ -#include - -class QwtWheel; -class QwtSlider; -class TuningThermo; - -class TunerFrame : public QFrame -{ - Q_OBJECT -public: - TunerFrame(QWidget *p); - -Q_SIGNALS: - void fieldChanged(double f); - -public Q_SLOTS: - void setFreq(double frq); - -private Q_SLOTS: - void adjustFreq(double frq); - -private: - QwtWheel *d_wheelFrequency; - TuningThermo *d_thermoTune; - QwtSlider *d_sliderFrequency; -}; diff --git a/qwt/examples/rasterview/main.cpp b/qwt/examples/rasterview/main.cpp deleted file mode 100644 index e915374f6..000000000 --- a/qwt/examples/rasterview/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include "plot.h" - -class MainWindow: public QMainWindow -{ -public: - MainWindow(QWidget * = NULL); -}; - -MainWindow::MainWindow(QWidget *parent): - QMainWindow(parent) -{ - Plot *plot = new Plot(this); - setCentralWidget(plot); - - QToolBar *toolBar = new QToolBar(this); - - QComboBox *rasterBox = new QComboBox(toolBar); - rasterBox->setStyle(new QWindowsStyle() ); - rasterBox->addItem("Wikipedia"); - - toolBar->addWidget(new QLabel("Data ", toolBar)); - toolBar->addWidget(rasterBox); - toolBar->addSeparator(); - - QComboBox *modeBox = new QComboBox(toolBar); - modeBox->setStyle(new QWindowsStyle() ); - modeBox->addItem("Nearest Neighbour"); - modeBox->addItem("Bilinear Interpolation"); - - toolBar->addWidget(new QLabel("Resampling ", toolBar)); - toolBar->addWidget(modeBox); - - toolBar->addSeparator(); - - QToolButton *btnExport = new QToolButton(toolBar); - btnExport->setText("Export"); - btnExport->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - toolBar->addWidget(btnExport); - - addToolBar(toolBar); - - connect(modeBox, SIGNAL(activated(int)), plot, SLOT(setResampleMode(int))); - connect(btnExport, SIGNAL(clicked()), plot, SLOT(exportPlot()) ); -} - -int main(int argc, char **argv) -{ - QApplication a(argc, argv); - - MainWindow mainWindow; - mainWindow.resize(600,400); - mainWindow.show(); - - return a.exec(); -} diff --git a/qwt/examples/rasterview/plot.cpp b/qwt/examples/rasterview/plot.cpp deleted file mode 100644 index 6472464dd..000000000 --- a/qwt/examples/rasterview/plot.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "plot.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class RasterData: public QwtMatrixRasterData -{ -public: - RasterData() - { - const double matrix[] = - { - 1, 2, 4, 1, - 6, 3, 5, 2, - 4, 2, 1, 5, - 5, 4, 2, 3 - }; - - QVector values; - for ( uint i = 0; i < sizeof(matrix) / sizeof(double); i++ ) - values += matrix[i]; - - const int numColumns = 4; - setValueMatrix(values, numColumns); - - setInterval( Qt::XAxis, - QwtInterval( -0.5, 3.5, QwtInterval::ExcludeMaximum ) ); - setInterval( Qt::YAxis, - QwtInterval( -0.5, 3.5, QwtInterval::ExcludeMaximum ) ); - setInterval( Qt::ZAxis, QwtInterval(1.0, 6.0) ); - } -}; - -class ColorMap: public QwtLinearColorMap -{ -public: - ColorMap(): - QwtLinearColorMap(Qt::darkBlue, Qt::darkRed) - { - addColorStop(0.2, Qt::blue); - addColorStop(0.4, Qt::cyan); - addColorStop(0.6, Qt::yellow); - addColorStop(0.8, Qt::red); - } -}; - -Plot::Plot(QWidget *parent): - QwtPlot(parent) -{ -#if 0 - QwtPlotGrid *grid = new QwtPlotGrid(); - grid->setPen(QPen(Qt::DotLine)); - grid->attach(this); -#endif - - d_spectrogram = new QwtPlotSpectrogram(); - d_spectrogram->setRenderThreadCount(0); // use system specific thread count - - d_spectrogram->setColorMap( new ColorMap() ); - - d_spectrogram->setData(new RasterData()); - d_spectrogram->attach(this); - - const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis ); - // A color bar on the right axis - QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight); - rightAxis->setColorBarEnabled(true); - rightAxis->setColorBarWidth(40); - rightAxis->setColorMap(zInterval, new ColorMap() ); - - setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() ); - enableAxis(QwtPlot::yRight); - - plotLayout()->setAlignCanvasToScales(true); - - setAxisScale(QwtPlot::xBottom, 0.0, 3.0); - setAxisMaxMinor(QwtPlot::xBottom, 0); - setAxisScale(QwtPlot::yLeft, 0.0, 3.0); - setAxisMaxMinor(QwtPlot::yLeft, 0); - - QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas() ); - magnifier->setAxisEnabled( QwtPlot::yRight, false); - - QwtPlotPanner *panner = new QwtPlotPanner( canvas() ); - panner->setAxisEnabled( QwtPlot::yRight, false); - - canvas()->setBorderRadius( 10 ); -} - -void Plot::exportPlot() -{ - QString fileName = "rasterview.pdf"; - -#ifndef QT_NO_FILEDIALOG - const QList imageFormats = - QImageWriter::supportedImageFormats(); - - QStringList filter; - filter += "PDF Documents (*.pdf)"; -#ifndef QWT_NO_SVG - filter += "SVG Documents (*.svg)"; -#endif - filter += "Postscript Documents (*.ps)"; - - if ( imageFormats.size() > 0 ) - { - QString imageFilter("Images ("); - for ( int i = 0; i < imageFormats.size(); i++ ) - { - if ( i > 0 ) - imageFilter += " "; - imageFilter += "*."; - imageFilter += imageFormats[i]; - } - imageFilter += ")"; - - filter += imageFilter; - } - - fileName = QFileDialog::getSaveFileName( - this, "Export File Name", fileName, - filter.join(";;"), NULL, QFileDialog::DontConfirmOverwrite); -#endif - if ( !fileName.isEmpty() ) - { - QwtPlotRenderer renderer; - renderer.renderDocument(this, fileName, QSizeF(300, 200), 85); - } -} - -void Plot::setResampleMode(int mode) -{ - RasterData *data = (RasterData *)d_spectrogram->data(); - data->setResampleMode( (QwtMatrixRasterData::ResampleMode) mode); - - replot(); -} diff --git a/qwt/examples/rasterview/plot.h b/qwt/examples/rasterview/plot.h deleted file mode 100644 index e1cfe6a2d..000000000 --- a/qwt/examples/rasterview/plot.h +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include - -class Plot: public QwtPlot -{ - Q_OBJECT - -public: - Plot(QWidget * = NULL); - -public Q_SLOTS: - void exportPlot(); - void setResampleMode(int); - -private: - QwtPlotSpectrogram *d_spectrogram; -}; diff --git a/qwt/examples/rasterview/rasterview.pro b/qwt/examples/rasterview/rasterview.pro deleted file mode 100644 index 942877140..000000000 --- a/qwt/examples/rasterview/rasterview.pro +++ /dev/null @@ -1,19 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = rasterview - -HEADERS = \ - plot.h - -SOURCES = \ - plot.cpp \ - main.cpp diff --git a/qwt/examples/realtime/README b/qwt/examples/realtime/README deleted file mode 100644 index 68776401f..000000000 --- a/qwt/examples/realtime/README +++ /dev/null @@ -1,25 +0,0 @@ -1) Incremental plots - -IncrementalPlot shows an example how to implement a plot that -displays growing data. - -The example produces random data when you push the start button. -With 'Timer' you can adjust the intervall between the -the generation of the points, with 'Points' you can set the number -of points to be generated. - -Unfortunately in Qt4 incremental painting is not possible with QPaintEngines -that doesn't support the QPaintEngine::PaintOutsidePaintEvent feature. -( These are all common paint engines beside the OpenGL engine, but this one -is not supported by Qwt yet. ) -That is the reason why you can see much faster repaints with Qt3. - -2) Stacked Zooming with scrollbars - -ScrollZoomer adds scrollbars for zooming. There are a couple of -reasons why the implementation is a hack and therefore the class -is not part of the Qwt lib, but it should be working with all -types of QwtPlots. Copy the code of scrollbar.[h|cpp] and -scrollzoomer.[h|cpp] to the application code. - -Uwe diff --git a/qwt/examples/realtime/clear.xpm b/qwt/examples/realtime/clear.xpm deleted file mode 100644 index 86c72b849..000000000 --- a/qwt/examples/realtime/clear.xpm +++ /dev/null @@ -1,51 +0,0 @@ -/* XPM */ -static const char *clear_xpm[] = { -/* width height num_colors chars_per_pixel */ -" 32 32 12 1", -/* colors */ -". c #000000", -"# c #004040", -"a c #303030", -"b c #400000", -"c c #404000", -"d c #585858", -"e c #808080", -"f c #a0a0a4", -"g c #bdbdbd", -"h c #c0c0c0", -"i c #dcdcdc", -"j c #ffffff", -/* pixels */ -"gggggggggggggggggggggggggggggggg", -"gggggggggggggg..gggggggggggggggg", -"gggggggggg....ficggggggggggggggg", -"ggggggg...fdad#ai......ggggggggg", -"gggg...fhjjidfbc#f.fffe...gggggg", -"ggg.fhjjjjihc#dhef.fhhhffe.ggggg", -"ggg.#jjjjjihhhhhe..ehhhfff.ggggg", -"ggg.#dffjjjjiihhcadehhfddd.ggggg", -"ggg.iiiffhfjjjjjhhhfdddddd.ggggg", -"ggg.#fjjiiffeeeeddddeeeddd.ggggg", -"gggg.#eeiiiiifffffffeee...gggggg", -"gggg.ffffffiifffffffddddd.gggggg", -"gggg.fffjfffeeeeddddeed.d.gggggg", -"gggg.fefiiiifhffeeeeded.d.gggggg", -"gggg.fefijhfhifefff.ded.d.gggggg", -"gggg.fefijeffifeefe.ded.d.gggggg", -"gggg.fefijeffifeefe.ded.d.gggggg", -"gggg.fefijeffifeefe.ded.d.gggggg", -"gggg.fefijeffifeefe.ded.d.gggggg", -"gggg.fefijeffifeefe.ded.d.gggggg", -"gggg.fefijeffifeefe.ded.d.gggggg", -"gggg.fefijeffifeefe.ded.d.gggggg", -"gggg.fefijeffifeefe.ded.d.gggggg", -"gggg.fefijeffifeefe.ded.d.gggggg", -"gggg.fefijeffifeefe.ded.d.gggggg", -"gggg.fefijeffifeefe.ded.d.gggggg", -"gggg.fffijeffifeefe.deddd.gggggg", -"gggg.ffiijeffifeefeddedd#.gggggg", -"gggg.eiijjjeiifdffedded#..gggggg", -"ggggg..fjjiiiiffffedddd..ggggggg", -"ggggggg...fhhfffffdd...ggggggggg", -"gggggggggg..........gggggggggggg" -}; diff --git a/qwt/examples/realtime/incrementalplot.cpp b/qwt/examples/realtime/incrementalplot.cpp deleted file mode 100644 index 81307db65..000000000 --- a/qwt/examples/realtime/incrementalplot.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include -#include -#include -#include -#include -#include "incrementalplot.h" -#include - -class CurveData: public QwtArraySeriesData -{ -public: - CurveData() - { - } - - virtual QRectF boundingRect() const - { - if ( d_boundingRect.width() < 0.0 ) - d_boundingRect = qwtBoundingRect( *this ); - - return d_boundingRect; - } - - inline void append( const QPointF &point ) - { - d_samples += point; - } - - void clear() - { - d_samples.clear(); - d_samples.squeeze(); - d_boundingRect = QRectF( 0.0, 0.0, -1.0, -1.0 ); - } -}; - -IncrementalPlot::IncrementalPlot(QWidget *parent): - QwtPlot(parent), - d_curve(NULL) -{ - d_directPainter = new QwtPlotDirectPainter(this); - -#if defined(Q_WS_X11) - canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true); - canvas()->setAttribute(Qt::WA_PaintOnScreen, true); -#endif - - d_curve = new QwtPlotCurve("Test Curve"); - d_curve->setStyle(QwtPlotCurve::NoCurve); - d_curve->setData( new CurveData() ); - - d_curve->setSymbol(new QwtSymbol(QwtSymbol::XCross, - Qt::NoBrush, QPen(Qt::white), QSize( 4, 4 ) ) ); - - d_curve->attach(this); - - setAutoReplot(false); -} - -IncrementalPlot::~IncrementalPlot() -{ - delete d_curve; -} - -void IncrementalPlot::appendPoint( const QPointF &point ) -{ - CurveData *data = static_cast( d_curve->data() ); - data->append(point); - - const bool doClip = !canvas()->testAttribute( Qt::WA_PaintOnScreen ); - if ( doClip ) - { - /* - Depending on the platform setting a clip might be an important - performance issue. F.e. for Qt Embedded this reduces the - part of the backing store that has to be copied out - maybe - to an unaccelerated frame buffer device. - */ - const QwtScaleMap xMap = canvasMap( d_curve->xAxis() ); - const QwtScaleMap yMap = canvasMap( d_curve->yAxis() ); - - QRegion clipRegion; - - const QSize symbolSize = d_curve->symbol()->size(); - QRect r( 0, 0, symbolSize.width() + 2, symbolSize.height() + 2 ); - - const QPointF center = - QwtScaleMap::transform( xMap, yMap, point ); - r.moveCenter( center.toPoint() ); - clipRegion += r; - - d_directPainter->setClipRegion( clipRegion ); - } - - d_directPainter->drawSeries(d_curve, - data->size() - 1, data->size() - 1); -} - -void IncrementalPlot::clearPoints() -{ - CurveData *data = static_cast( d_curve->data() ); - data->clear(); - - replot(); -} diff --git a/qwt/examples/realtime/incrementalplot.h b/qwt/examples/realtime/incrementalplot.h deleted file mode 100644 index 8372dbe00..000000000 --- a/qwt/examples/realtime/incrementalplot.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _INCREMENTALPLOT_H_ -#define _INCREMENTALPLOT_H_ 1 - -#include - -class QwtPlotCurve; -class QwtPlotDirectPainter; - -class IncrementalPlot : public QwtPlot -{ - Q_OBJECT - -public: - IncrementalPlot(QWidget *parent = NULL); - virtual ~IncrementalPlot(); - - void appendPoint( const QPointF &); - void clearPoints(); - -private: - QwtPlotCurve *d_curve; - QwtPlotDirectPainter *d_directPainter; -}; - -#endif // _INCREMENTALPLOT_H_ diff --git a/qwt/examples/realtime/main.cpp b/qwt/examples/realtime/main.cpp deleted file mode 100644 index 30f9c6d10..000000000 --- a/qwt/examples/realtime/main.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include "mainwindow.h" - -int main(int argc, char **argv) -{ - QApplication a(argc, argv); - - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qwt/examples/realtime/mainwindow.cpp b/qwt/examples/realtime/mainwindow.cpp deleted file mode 100644 index 18775703e..000000000 --- a/qwt/examples/realtime/mainwindow.cpp +++ /dev/null @@ -1,185 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include "randomplot.h" -#include "mainwindow.h" -#include "start.xpm" -#include "clear.xpm" - -class MyToolBar: public QToolBar -{ -public: - MyToolBar(MainWindow *parent): - QToolBar(parent) - { - } - void addSpacing(int spacing) - { - QLabel *label = new QLabel(this); - addWidget(label); - label->setFixedWidth(spacing); - } -}; - -class Counter: public QWidget -{ -public: - Counter(QWidget *parent, - const QString &prefix, const QString &suffix, - int min, int max, int step): - QWidget(parent) - { - QHBoxLayout *layout = new QHBoxLayout(this); - - if ( !prefix.isEmpty() ) - layout->addWidget(new QLabel(prefix + " ", this)); - - d_counter = new QSpinBox(this); - d_counter->setRange(min, max); - d_counter->setSingleStep(step); - layout->addWidget(d_counter); - - if ( !suffix.isEmpty() ) - layout->addWidget(new QLabel(QString(" ") + suffix, this)); - } - - void setValue(int value) { d_counter->setValue(value); } - int value() const { return d_counter->value(); } - -private: - QSpinBox *d_counter; -}; - -MainWindow::MainWindow() -{ - addToolBar(toolBar()); -#ifndef QT_NO_STATUSBAR - (void)statusBar(); -#endif - - d_plot = new RandomPlot(this); - const int margin = 4; - d_plot->setContentsMargins( margin, margin, margin, margin); - - setCentralWidget(d_plot); - - connect(d_startAction, SIGNAL( toggled(bool) ), this, SLOT( appendPoints(bool) ) ); - connect(d_clearAction, SIGNAL( triggered() ), d_plot, SLOT( clear() ) ); - connect(d_plot, SIGNAL( running(bool) ), this, SLOT( showRunning(bool) ) ); - connect(d_plot, SIGNAL( elapsed(int) ), this, SLOT( showElapsed( int ) ) ); - - initWhatsThis(); - - setContextMenuPolicy(Qt::NoContextMenu); -} - -QToolBar *MainWindow::toolBar() -{ - MyToolBar *toolBar = new MyToolBar(this); - - toolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea); - setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - - d_startAction = new QAction(QIcon(start_xpm), "Clear", toolBar); - d_startAction->setCheckable(true); - d_clearAction = new QAction(QIcon(clear_xpm), "Clear", toolBar); - QAction *whatsThisAction = QWhatsThis::createAction(toolBar); - whatsThisAction->setText("Help"); - - toolBar->addAction(d_startAction); - toolBar->addAction(d_clearAction); - toolBar->addAction(whatsThisAction); - - setIconSize(QSize(22, 22)); - - QWidget *hBox = new QWidget(toolBar); - - d_randomCount = - new Counter(hBox, "Points", QString::null, 1, 100000, 100); - d_randomCount->setValue(1000); - - d_timerCount = new Counter(hBox, "Delay", "ms", 0, 100000, 100); - d_timerCount->setValue(0); - - QHBoxLayout *layout = new QHBoxLayout(hBox); - layout->setMargin(0); - layout->setSpacing(0); - layout->addSpacing(10); - layout->addWidget(new QWidget(hBox), 10); // spacer - layout->addWidget(d_randomCount); - layout->addSpacing(5); - layout->addWidget(d_timerCount); - - showRunning(false); - - toolBar->addWidget(hBox); - - return toolBar; -} - -void MainWindow::appendPoints(bool on) -{ - if ( on ) - d_plot->append(d_timerCount->value(), - d_randomCount->value()); - else - d_plot->stop(); -} - -void MainWindow::showRunning(bool running) -{ - d_randomCount->setEnabled(!running); - d_timerCount->setEnabled(!running); - d_startAction->setChecked(running); - d_startAction->setText(running ? "Stop" : "Start"); -} - -void MainWindow::showElapsed(int ms) -{ - QString text; - text.setNum(ms); - text += " ms"; - - statusBar()->showMessage( text ); -} - -void MainWindow::initWhatsThis() -{ - const char *text1 = - "Zooming is enabled until the selected area gets " - "too small for the significance on the axes.\n\n" - "You can zoom in using the left mouse button.\n" - "The middle mouse button is used to go back to the " - "previous zoomed area.\n" - "The right mouse button is used to unzoom completely."; - - const char *text2 = - "Number of random points that will be generated."; - - const char *text3 = - "Delay between the generation of two random points."; - - const char *text4 = - "Start generation of random points.\n\n" - "The intention of this example is to show how to implement " - "growing curves. The points will be generated and displayed " - "one after the other.\n" - "To check the performance, a small delay and a large number " - "of points are useful. To watch the curve growing, a delay " - " > 300 ms and less points are better.\n" - "To inspect the curve, stacked zooming is implemented using the " - "mouse buttons on the plot."; - - const char *text5 = "Remove all points."; - - d_plot->setWhatsThis(text1); - d_randomCount->setWhatsThis(text2); - d_timerCount->setWhatsThis(text3); - d_startAction->setWhatsThis(text4); - d_clearAction->setWhatsThis(text5); -} diff --git a/qwt/examples/realtime/mainwindow.h b/qwt/examples/realtime/mainwindow.h deleted file mode 100644 index 4dee7297f..000000000 --- a/qwt/examples/realtime/mainwindow.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef _MAINWINDOW_H_ -#define _MAINWINDOW_H_ 1 - -#include -#include - -class QSpinBox; -class QPushButton; -class RandomPlot; -class Counter; - -class MainWindow: public QMainWindow -{ - Q_OBJECT -public: - MainWindow(); - -private Q_SLOTS: - void showRunning( bool ); - void appendPoints( bool ); - void showElapsed( int ); - -private: - QToolBar *toolBar(); - void initWhatsThis(); - -private: - Counter *d_randomCount; - Counter *d_timerCount; - QAction *d_startAction; - QAction *d_clearAction; - RandomPlot *d_plot; -}; - -#endif diff --git a/qwt/examples/realtime/randomplot.cpp b/qwt/examples/realtime/randomplot.cpp deleted file mode 100644 index 1a04d8e72..000000000 --- a/qwt/examples/realtime/randomplot.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include "scrollzoomer.h" -#include "randomplot.h" - -const unsigned int c_rangeMax = 1000; - -class Zoomer: public ScrollZoomer -{ -public: - Zoomer(QwtPlotCanvas *canvas): - ScrollZoomer(canvas) - { -#if 0 - setRubberBandPen(QPen(Qt::red, 2, Qt::DotLine)); -#else - setRubberBandPen(QPen(Qt::red)); -#endif - } - - virtual QwtText trackerTextF(const QPointF &pos) const - { - QColor bg(Qt::white); - - QwtText text = QwtPlotZoomer::trackerTextF(pos); - text.setBackgroundBrush( QBrush( bg )); - return text; - } - - virtual void rescale() - { - QwtScaleWidget *scaleWidget = plot()->axisWidget(yAxis()); - QwtScaleDraw *sd = scaleWidget->scaleDraw(); - - int minExtent = 0; - if ( zoomRectIndex() > 0 ) - { - // When scrolling in vertical direction - // the plot is jumping in horizontal direction - // because of the different widths of the labels - // So we better use a fixed extent. - - minExtent = sd->spacing() + sd->maxTickLength() + 1; - minExtent += sd->labelSize( - scaleWidget->font(), c_rangeMax).width(); - } - - sd->setMinimumExtent(minExtent); - - ScrollZoomer::rescale(); - } -}; - -RandomPlot::RandomPlot(QWidget *parent): - IncrementalPlot(parent), - d_timer(0), - d_timerCount(0) -{ - setFrameStyle(QFrame::NoFrame); - setLineWidth(0); - setCanvasLineWidth(2); - - plotLayout()->setAlignCanvasToScales(true); - - QwtPlotGrid *grid = new QwtPlotGrid; - grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine)); - grid->attach(this); - - setCanvasBackground(QColor(29, 100, 141)); // nice blue - - setAxisScale(xBottom, 0, c_rangeMax); - setAxisScale(yLeft, 0, c_rangeMax); - - replot(); - - // enable zooming - - (void) new Zoomer(canvas()); -} - -QSize RandomPlot::sizeHint() const -{ - return QSize(540,400); -} - -void RandomPlot::appendPoint() -{ - double x = qrand() % c_rangeMax; - x += ( qrand() % 100 ) / 100; - - double y = qrand() % c_rangeMax; - y += ( qrand() % 100 ) / 100; - - IncrementalPlot::appendPoint( QPointF( x, y ) ); - - if ( --d_timerCount <= 0 ) - stop(); -} - -void RandomPlot::append(int timeout, int count) -{ - if ( !d_timer ) - { - d_timer = new QTimer(this); - connect(d_timer, SIGNAL(timeout()), SLOT(appendPoint())); - } - - d_timerCount = count; - - Q_EMIT running(true); - d_timeStamp.start(); - - canvas()->setPaintAttribute(QwtPlotCanvas::BackingStore, false); - d_timer->start(timeout); -} - -void RandomPlot::stop() -{ - Q_EMIT elapsed( d_timeStamp.elapsed() ); - - if ( d_timer ) - { - d_timer->stop(); - Q_EMIT running(false); - } - - canvas()->setPaintAttribute(QwtPlotCanvas::BackingStore, true); -} - -void RandomPlot::clear() -{ - clearPoints(); - replot(); -} diff --git a/qwt/examples/realtime/randomplot.h b/qwt/examples/realtime/randomplot.h deleted file mode 100644 index 498c27354..000000000 --- a/qwt/examples/realtime/randomplot.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef _RANDOMPLOT_H_ -#define _RANDOMPLOT_H_ 1 - -#include "incrementalplot.h" -#include - -class QTimer; - -class RandomPlot: public IncrementalPlot -{ - Q_OBJECT - -public: - RandomPlot(QWidget *parent); - - virtual QSize sizeHint() const; - -Q_SIGNALS: - void running( bool ); - void elapsed( int ms ); - -public Q_SLOTS: - void clear(); - void stop(); - void append( int timeout, int count ); - -private Q_SLOTS: - void appendPoint(); - -private: - void initCurve(); - - QTimer *d_timer; - int d_timerCount; - - QTime d_timeStamp; -}; - -#endif // _RANDOMPLOT_H_ diff --git a/qwt/examples/realtime/realtime.pro b/qwt/examples/realtime/realtime.pro deleted file mode 100644 index c4ba7b989..000000000 --- a/qwt/examples/realtime/realtime.pro +++ /dev/null @@ -1,27 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = realtime - -HEADERS = \ - mainwindow.h \ - scrollzoomer.h \ - scrollbar.h \ - incrementalplot.h \ - randomplot.h - -SOURCES = \ - main.cpp \ - mainwindow.cpp \ - scrollzoomer.cpp \ - scrollbar.cpp \ - incrementalplot.cpp \ - randomplot.cpp diff --git a/qwt/examples/realtime/scrollbar.cpp b/qwt/examples/realtime/scrollbar.cpp deleted file mode 100644 index bf6a5f5a2..000000000 --- a/qwt/examples/realtime/scrollbar.cpp +++ /dev/null @@ -1,169 +0,0 @@ -#include -#include -#include "scrollbar.h" - -ScrollBar::ScrollBar(QWidget * parent): - QScrollBar(parent) -{ - init(); -} - -ScrollBar::ScrollBar(Qt::Orientation o, - QWidget *parent): - QScrollBar(o, parent) -{ - init(); -} - -ScrollBar::ScrollBar(double minBase, double maxBase, - Qt::Orientation o, QWidget *parent): - QScrollBar(o, parent) -{ - init(); - setBase(minBase, maxBase); - moveSlider(minBase, maxBase); -} - -void ScrollBar::init() -{ - d_inverted = orientation() == Qt::Vertical; - d_baseTicks = 1000000; - d_minBase = 0.0; - d_maxBase = 1.0; - moveSlider(d_minBase, d_maxBase); - - connect(this, SIGNAL(sliderMoved(int)), SLOT(catchSliderMoved(int))); - connect(this, SIGNAL(valueChanged(int)), SLOT(catchValueChanged(int))); -} - -void ScrollBar::setInverted(bool inverted) -{ - if ( d_inverted != inverted ) - { - d_inverted = inverted; - moveSlider(minSliderValue(), maxSliderValue()); - } -} - -bool ScrollBar::isInverted() const -{ - return d_inverted; -} - -void ScrollBar::setBase(double min, double max) -{ - if ( min != d_minBase || max != d_maxBase ) - { - d_minBase = min; - d_maxBase = max; - - moveSlider(minSliderValue(), maxSliderValue()); - } -} - -void ScrollBar::moveSlider(double min, double max) -{ - const int sliderTicks = qRound((max - min) / - (d_maxBase - d_minBase) * d_baseTicks); - - // setRange initiates a valueChanged of the scrollbars - // in some situations. So we block - // and unblock the signals. - - blockSignals(true); - - setRange(sliderTicks / 2, d_baseTicks - sliderTicks / 2); - int steps = sliderTicks / 200; - if ( steps <= 0 ) - steps = 1; - - setSingleStep(steps); - setPageStep(sliderTicks); - - int tick = mapToTick(min + (max - min) / 2); - if ( isInverted() ) - tick = d_baseTicks - tick; - - setSliderPosition(tick); - blockSignals(false); -} - -double ScrollBar::minBaseValue() const -{ - return d_minBase; -} - -double ScrollBar::maxBaseValue() const -{ - return d_maxBase; -} - -void ScrollBar::sliderRange(int value, double &min, double &max) const -{ - if ( isInverted() ) - value = d_baseTicks - value; - - const int visibleTicks = pageStep(); - - min = mapFromTick(value - visibleTicks / 2); - max = mapFromTick(value + visibleTicks / 2); -} - -double ScrollBar::minSliderValue() const -{ - double min, dummy; - sliderRange(value(), min, dummy); - - return min; -} - -double ScrollBar::maxSliderValue() const -{ - double max, dummy; - sliderRange(value(), dummy, max); - - return max; -} - -int ScrollBar::mapToTick(double v) const -{ - return (int) ( ( v - d_minBase) / (d_maxBase - d_minBase ) * d_baseTicks ); -} - -double ScrollBar::mapFromTick(int tick) const -{ - return d_minBase + ( d_maxBase - d_minBase ) * tick / d_baseTicks; -} - -void ScrollBar::catchValueChanged(int value) -{ - double min, max; - sliderRange(value, min, max); - Q_EMIT valueChanged(orientation(), min, max); -} - -void ScrollBar::catchSliderMoved(int value) -{ - double min, max; - sliderRange(value, min, max); - Q_EMIT sliderMoved(orientation(), min, max); -} - -int ScrollBar::extent() const -{ - QStyleOptionSlider opt; - opt.init(this); - opt.subControls = QStyle::SC_None; - opt.activeSubControls = QStyle::SC_None; - opt.orientation = orientation(); - opt.minimum = minimum(); - opt.maximum = maximum(); - opt.sliderPosition = sliderPosition(); - opt.sliderValue = value(); - opt.singleStep = singleStep(); - opt.pageStep = pageStep(); - opt.upsideDown = invertedAppearance(); - if (orientation() == Qt::Horizontal) - opt.state |= QStyle::State_Horizontal; - return style()->pixelMetric(QStyle::PM_ScrollBarExtent, &opt, this); -} diff --git a/qwt/examples/realtime/scrollbar.h b/qwt/examples/realtime/scrollbar.h deleted file mode 100644 index 518aa679d..000000000 --- a/qwt/examples/realtime/scrollbar.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef _SCROLLBAR_H -#define _SCROLLBAR_H 1 - -#include - -class ScrollBar: public QScrollBar -{ - Q_OBJECT - -public: - ScrollBar(QWidget *parent = NULL); - ScrollBar(Qt::Orientation, QWidget *parent = NULL); - ScrollBar(double minBase, double maxBase, - Qt::Orientation o, QWidget *parent = NULL); - - void setInverted(bool); - bool isInverted() const; - - double minBaseValue() const; - double maxBaseValue() const; - - double minSliderValue() const; - double maxSliderValue() const; - - int extent() const; - -Q_SIGNALS: - void sliderMoved(Qt::Orientation, double, double); - void valueChanged(Qt::Orientation, double, double); - -public Q_SLOTS: - virtual void setBase(double min, double max); - virtual void moveSlider(double min, double max); - -protected: - void sliderRange(int value, double &min, double &max) const; - int mapToTick(double) const; - double mapFromTick(int) const; - -private Q_SLOTS: - void catchValueChanged(int value); - void catchSliderMoved(int value); - -private: - void init(); - - bool d_inverted; - double d_minBase; - double d_maxBase; - int d_baseTicks; -}; - -#endif diff --git a/qwt/examples/realtime/scrollzoomer.cpp b/qwt/examples/realtime/scrollzoomer.cpp deleted file mode 100644 index 2b3daa083..000000000 --- a/qwt/examples/realtime/scrollzoomer.cpp +++ /dev/null @@ -1,477 +0,0 @@ -#include -#include -#include -#include -#include -#include "scrollbar.h" -#include "scrollzoomer.h" - -class ScrollData -{ -public: - ScrollData(): - scrollBar(NULL), - position(ScrollZoomer::OppositeToScale), - mode(Qt::ScrollBarAsNeeded) - { - } - - ~ScrollData() - { - delete scrollBar; - } - - ScrollBar *scrollBar; - ScrollZoomer::ScrollBarPosition position; - Qt::ScrollBarPolicy mode; -}; - -ScrollZoomer::ScrollZoomer(QwtPlotCanvas *canvas): - QwtPlotZoomer(canvas), - d_cornerWidget(NULL), - d_hScrollData(NULL), - d_vScrollData(NULL), - d_inZoom(false), - d_alignCanvasToScales(false) -{ - if ( !canvas ) - return; - - d_hScrollData = new ScrollData; - d_vScrollData = new ScrollData; -} - -ScrollZoomer::~ScrollZoomer() -{ - delete d_cornerWidget; - delete d_vScrollData; - delete d_hScrollData; -} - -void ScrollZoomer::rescale() -{ - QwtScaleWidget *xScale = plot()->axisWidget(xAxis()); - QwtScaleWidget *yScale = plot()->axisWidget(yAxis()); - - if ( zoomRectIndex() <= 0 ) - { - if ( d_inZoom ) - { - xScale->setMinBorderDist(0, 0); - yScale->setMinBorderDist(0, 0); - - QwtPlotLayout *layout = plot()->plotLayout(); - layout->setAlignCanvasToScales(d_alignCanvasToScales); - - d_inZoom = false; - } - } - else - { - if ( !d_inZoom ) - { - /* - We set a minimum border distance. - Otherwise the canvas size changes when scrolling, - between situations where the major ticks are at - the canvas borders (requiring extra space for the label) - and situations where all labels can be painted below/top - or left/right of the canvas. - */ - int start, end; - - xScale->getBorderDistHint(start, end); - xScale->setMinBorderDist(start, end); - - yScale->getBorderDistHint(start, end); - yScale->setMinBorderDist(start, end); - - QwtPlotLayout *layout = plot()->plotLayout(); - d_alignCanvasToScales = layout->alignCanvasToScales(); - layout->setAlignCanvasToScales(false); - - d_inZoom = true; - } - } - - QwtPlotZoomer::rescale(); - updateScrollBars(); -} - -ScrollBar *ScrollZoomer::scrollBar(Qt::Orientation o) -{ - ScrollBar *&sb = (o == Qt::Vertical) - ? d_vScrollData->scrollBar : d_hScrollData->scrollBar; - - if ( sb == NULL ) - { - sb = new ScrollBar(o, canvas()); - sb->hide(); - connect(sb, - SIGNAL(valueChanged(Qt::Orientation, double, double)), - SLOT(scrollBarMoved(Qt::Orientation, double, double))); - } - return sb; -} - -ScrollBar *ScrollZoomer::horizontalScrollBar() const -{ - return d_hScrollData->scrollBar; -} - -ScrollBar *ScrollZoomer::verticalScrollBar() const -{ - return d_vScrollData->scrollBar; -} - -void ScrollZoomer::setHScrollBarMode(Qt::ScrollBarPolicy mode) -{ - if ( hScrollBarMode() != mode ) - { - d_hScrollData->mode = mode; - updateScrollBars(); - } -} - -void ScrollZoomer::setVScrollBarMode(Qt::ScrollBarPolicy mode) -{ - if ( vScrollBarMode() != mode ) - { - d_vScrollData->mode = mode; - updateScrollBars(); - } -} - -Qt::ScrollBarPolicy ScrollZoomer::hScrollBarMode() const -{ - return d_hScrollData->mode; -} - -Qt::ScrollBarPolicy ScrollZoomer::vScrollBarMode() const -{ - return d_vScrollData->mode; -} - -void ScrollZoomer::setHScrollBarPosition(ScrollBarPosition pos) -{ - if ( d_hScrollData->position != pos ) - { - d_hScrollData->position = pos; - updateScrollBars(); - } -} - -void ScrollZoomer::setVScrollBarPosition(ScrollBarPosition pos) -{ - if ( d_vScrollData->position != pos ) - { - d_vScrollData->position = pos; - updateScrollBars(); - } -} - -ScrollZoomer::ScrollBarPosition ScrollZoomer::hScrollBarPosition() const -{ - return d_hScrollData->position; -} - -ScrollZoomer::ScrollBarPosition ScrollZoomer::vScrollBarPosition() const -{ - return d_vScrollData->position; -} - -void ScrollZoomer::setCornerWidget(QWidget *w) -{ - if ( w != d_cornerWidget ) - { - if ( canvas() ) - { - delete d_cornerWidget; - d_cornerWidget = w; - if ( d_cornerWidget->parent() != canvas() ) - d_cornerWidget->setParent(canvas()); - - updateScrollBars(); - } - } -} - -QWidget *ScrollZoomer::cornerWidget() const -{ - return d_cornerWidget; -} - -bool ScrollZoomer::eventFilter(QObject *o, QEvent *e) -{ - if ( o == canvas() ) - { - switch(e->type()) - { - case QEvent::Resize: - { - const int fw = ((QwtPlotCanvas *)canvas())->frameWidth(); - - QRect rect; - rect.setSize(((QResizeEvent *)e)->size()); - rect.setRect(rect.x() + fw, rect.y() + fw, - rect.width() - 2 * fw, rect.height() - 2 * fw); - - layoutScrollBars(rect); - break; - } - case QEvent::ChildRemoved: - { - const QObject *child = ((QChildEvent *)e)->child(); - if ( child == d_cornerWidget ) - d_cornerWidget = NULL; - else if ( child == d_hScrollData->scrollBar ) - d_hScrollData->scrollBar = NULL; - else if ( child == d_vScrollData->scrollBar ) - d_vScrollData->scrollBar = NULL; - break; - } - default: - break; - } - } - return QwtPlotZoomer::eventFilter(o, e); -} - -bool ScrollZoomer::needScrollBar(Qt::Orientation o) const -{ - Qt::ScrollBarPolicy mode; - double zoomMin, zoomMax, baseMin, baseMax; - - if ( o == Qt::Horizontal ) - { - mode = d_hScrollData->mode; - baseMin = zoomBase().left(); - baseMax = zoomBase().right(); - zoomMin = zoomRect().left(); - zoomMax = zoomRect().right(); - } - else - { - mode = d_vScrollData->mode; - baseMin = zoomBase().top(); - baseMax = zoomBase().bottom(); - zoomMin = zoomRect().top(); - zoomMax = zoomRect().bottom(); - } - - bool needed = false; - switch(mode) - { - case Qt::ScrollBarAlwaysOn: - needed = true; - break; - case Qt::ScrollBarAlwaysOff: - needed = false; - break; - default: - { - if ( baseMin < zoomMin || baseMax > zoomMax ) - needed = true; - break; - } - } - return needed; -} - -void ScrollZoomer::updateScrollBars() -{ - if ( !canvas() ) - return; - - const int xAxis = QwtPlotZoomer::xAxis(); - const int yAxis = QwtPlotZoomer::yAxis(); - - int xScrollBarAxis = xAxis; - if ( hScrollBarPosition() == OppositeToScale ) - xScrollBarAxis = oppositeAxis(xScrollBarAxis); - - int yScrollBarAxis = yAxis; - if ( vScrollBarPosition() == OppositeToScale ) - yScrollBarAxis = oppositeAxis(yScrollBarAxis); - - - QwtPlotLayout *layout = plot()->plotLayout(); - - bool showHScrollBar = needScrollBar(Qt::Horizontal); - if ( showHScrollBar ) - { - ScrollBar *sb = scrollBar(Qt::Horizontal); - - sb->setPalette(plot()->palette()); - - const QwtScaleDiv *sd = plot()->axisScaleDiv(xAxis); - sb->setInverted(sd->lowerBound() > sd->upperBound() ); - - sb->setBase(zoomBase().left(), zoomBase().right()); - sb->moveSlider(zoomRect().left(), zoomRect().right()); - - if ( !sb->isVisibleTo(canvas()) ) - { - sb->show(); - layout->setCanvasMargin(layout->canvasMargin(xScrollBarAxis) - + sb->extent(), xScrollBarAxis); - } - } - else - { - if ( horizontalScrollBar() ) - { - horizontalScrollBar()->hide(); - layout->setCanvasMargin(layout->canvasMargin(xScrollBarAxis) - - horizontalScrollBar()->extent(), xScrollBarAxis); - } - } - - bool showVScrollBar = needScrollBar(Qt::Vertical); - if ( showVScrollBar ) - { - ScrollBar *sb = scrollBar(Qt::Vertical); - - sb->setPalette(plot()->palette()); - - const QwtScaleDiv *sd = plot()->axisScaleDiv(yAxis); - sb->setInverted(sd->lowerBound() < sd->upperBound() ); - - sb->setBase(zoomBase().top(), zoomBase().bottom()); - sb->moveSlider(zoomRect().top(), zoomRect().bottom()); - - if ( !sb->isVisibleTo(canvas()) ) - { - sb->show(); - layout->setCanvasMargin(layout->canvasMargin(yScrollBarAxis) - + sb->extent(), yScrollBarAxis); - } - } - else - { - if ( verticalScrollBar() ) - { - verticalScrollBar()->hide(); - layout->setCanvasMargin(layout->canvasMargin(yScrollBarAxis) - - verticalScrollBar()->extent(), yScrollBarAxis); - } - } - - if ( showHScrollBar && showVScrollBar ) - { - if ( d_cornerWidget == NULL ) - { - d_cornerWidget = new QWidget(canvas()); - d_cornerWidget->setAutoFillBackground(true); - d_cornerWidget->setPalette(plot()->palette()); - } - d_cornerWidget->show(); - } - else - { - if ( d_cornerWidget ) - d_cornerWidget->hide(); - } - - layoutScrollBars(((QwtPlotCanvas *)canvas())->contentsRect()); - plot()->updateLayout(); -} - -void ScrollZoomer::layoutScrollBars(const QRect &rect) -{ - int hPos = xAxis(); - if ( hScrollBarPosition() == OppositeToScale ) - hPos = oppositeAxis(hPos); - - int vPos = yAxis(); - if ( vScrollBarPosition() == OppositeToScale ) - vPos = oppositeAxis(vPos); - - ScrollBar *hScrollBar = horizontalScrollBar(); - ScrollBar *vScrollBar = verticalScrollBar(); - - const int hdim = hScrollBar ? hScrollBar->extent() : 0; - const int vdim = vScrollBar ? vScrollBar->extent() : 0; - - if ( hScrollBar && hScrollBar->isVisible() ) - { - int x = rect.x(); - int y = (hPos == QwtPlot::xTop) - ? rect.top() : rect.bottom() - hdim + 1; - int w = rect.width(); - - if ( vScrollBar && vScrollBar->isVisible() ) - { - if ( vPos == QwtPlot::yLeft ) - x += vdim; - w -= vdim; - } - - hScrollBar->setGeometry(x, y, w, hdim); - } - if ( vScrollBar && vScrollBar->isVisible() ) - { - int pos = yAxis(); - if ( vScrollBarPosition() == OppositeToScale ) - pos = oppositeAxis(pos); - - int x = (vPos == QwtPlot::yLeft) - ? rect.left() : rect.right() - vdim + 1; - int y = rect.y(); - - int h = rect.height(); - - if ( hScrollBar && hScrollBar->isVisible() ) - { - if ( hPos == QwtPlot::xTop ) - y += hdim; - - h -= hdim; - } - - vScrollBar->setGeometry(x, y, vdim, h); - } - if ( hScrollBar && hScrollBar->isVisible() && - vScrollBar && vScrollBar->isVisible() ) - { - if ( d_cornerWidget ) - { - QRect cornerRect( - vScrollBar->pos().x(), hScrollBar->pos().y(), - vdim, hdim); - d_cornerWidget->setGeometry(cornerRect); - } - } -} - -void ScrollZoomer::scrollBarMoved( - Qt::Orientation o, double min, double max) -{ - Q_UNUSED(max); - - if ( o == Qt::Horizontal ) - moveTo( QPointF( min, zoomRect().top() ) ); - else - moveTo( QPointF( zoomRect().left(), min ) ); - - Q_EMIT zoomed(zoomRect()); -} - -int ScrollZoomer::oppositeAxis(int axis) const -{ - switch(axis) - { - case QwtPlot::xBottom: - return QwtPlot::xTop; - case QwtPlot::xTop: - return QwtPlot::xBottom; - case QwtPlot::yLeft: - return QwtPlot::yRight; - case QwtPlot::yRight: - return QwtPlot::yLeft; - default: - break; - } - - return axis; -} diff --git a/qwt/examples/realtime/scrollzoomer.h b/qwt/examples/realtime/scrollzoomer.h deleted file mode 100644 index 9b9c3aa73..000000000 --- a/qwt/examples/realtime/scrollzoomer.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef _SCROLLZOOMER_H -#define _SCROLLZOOMER_H - -#include -#include - -class ScrollData; -class ScrollBar; - -class ScrollZoomer: public QwtPlotZoomer -{ - Q_OBJECT -public: - enum ScrollBarPosition - { - AttachedToScale, - OppositeToScale - }; - - ScrollZoomer(QwtPlotCanvas *); - virtual ~ScrollZoomer(); - - ScrollBar *horizontalScrollBar() const; - ScrollBar *verticalScrollBar() const; - - void setHScrollBarMode(Qt::ScrollBarPolicy); - void setVScrollBarMode(Qt::ScrollBarPolicy); - - Qt::ScrollBarPolicy vScrollBarMode () const; - Qt::ScrollBarPolicy hScrollBarMode () const; - - void setHScrollBarPosition(ScrollBarPosition); - void setVScrollBarPosition(ScrollBarPosition); - - ScrollBarPosition hScrollBarPosition() const; - ScrollBarPosition vScrollBarPosition() const; - - QWidget* cornerWidget() const; - virtual void setCornerWidget(QWidget *); - - virtual bool eventFilter(QObject *, QEvent *); - - virtual void rescale(); - -protected: - virtual ScrollBar *scrollBar(Qt::Orientation); - virtual void updateScrollBars(); - virtual void layoutScrollBars(const QRect &); - -private Q_SLOTS: - void scrollBarMoved(Qt::Orientation o, double min, double max); - -private: - bool needScrollBar(Qt::Orientation) const; - int oppositeAxis(int) const; - - QWidget *d_cornerWidget; - - ScrollData *d_hScrollData; - ScrollData *d_vScrollData; - - bool d_inZoom; - bool d_alignCanvasToScales; -}; - -#endif diff --git a/qwt/examples/realtime/start.xpm b/qwt/examples/realtime/start.xpm deleted file mode 100644 index 62146842a..000000000 --- a/qwt/examples/realtime/start.xpm +++ /dev/null @@ -1,266 +0,0 @@ -/* XPM */ -static const char *start_xpm[] = { -/* width height num_colors chars_per_pixel */ -" 32 32 227 2", -/* colors */ -".. c #040204", -".# c #848684", -".a c #c4c2b4", -".b c #843a04", -".c c #444244", -".d c #ece2cc", -".e c #fca234", -".f c #c45e04", -".g c #bca27c", -".h c #646264", -".i c #e4c69c", -".j c #847254", -".k c #c4a684", -".l c #443e34", -".m c #a48e6c", -".n c #f4f2e4", -".o c #24261c", -".p c #a44a04", -".q c #c4825c", -".r c #644634", -".s c #b4b2ac", -".t c #747274", -".u c #844e2c", -".v c #ece6dc", -".w c #c4b6a4", -".x c #a49274", -".y c #343634", -".z c #fcd69c", -".A c #b4aa9c", -".B c #8c8e8c", -".C c #545254", -".D c #f4f2ec", -".E c #fcb67c", -".F c #e4965c", -".G c #e46634", -".H c #141614", -".I c #d4c2a4", -".J c #746a5c", -".K c #fcc2a4", -".L c #342a1c", -".M c #fc9204", -".N c #a45e2c", -".O c #94521c", -".P c #a4560c", -".Q c #645e54", -".R c #ec7a04", -".S c #f4deac", -".T c #5c462c", -".U c #bcaa8c", -".V c #d4be9c", -".W c #fcfaf4", -".X c #d4cab4", -".Y c #1c0a04", -".Z c #6c6a6c", -".0 c #e4caa4", -".1 c #2c2a1c", -".2 c #74462c", -".3 c #84562c", -".4 c #f4eee4", -".5 c #c4beb4", -".6 c #a49a84", -".7 c #f4ba7c", -".8 c #dc966c", -".9 c #948674", -"#. c #fc8a04", -"## c #f4eab4", -"#a c #fcb26c", -"#b c #c4ae94", -"#c c #f4e6d4", -"#d c #9c8e74", -"#e c #fc7e04", -"#f c #140604", -"#g c #b4a28c", -"#h c #6c625c", -"#i c #8c7e64", -"#j c #f4ae84", -"#k c #e4decc", -"#l c #ac5204", -"#m c #e48a4c", -"#n c #7c7a7c", -"#o c #ccba9c", -"#p c #fcd2b4", -"#q c #bcae9c", -"#r c #dcc6a4", -"#s c #ac723c", -"#t c #e4ceb4", -"#u c #ec9e74", -"#v c #8c8a8c", -"#w c #8c4204", -"#x c #4c4a34", -"#y c #7c3a04", -"#z c #fcfecc", -"#A c #2c221c", -"#B c #ac4e04", -"#C c #d48264", -"#D c #bcb2a4", -"#E c #a49684", -"#F c #b4aeac", -"#G c #5c5a5c", -"#H c #fcf2ec", -"#I c #fcb28c", -"#J c #7c6e5c", -"#K c #fcce9c", -"#L c #3c2e24", -"#M c #bc9e71", -"#N c #fc922c", -"#O c #bc622c", -"#P c #b45604", -"#Q c #f47a08", -"#R c #fcdeb8", -"#S c #544e44", -"#T c #fcfefc", -"#U c #e4ceaa", -"#V c #8c5a2c", -"#W c #e49e7c", -"#X c #f4eadb", -"#Y c #9c9284", -"#Z c #f4ae90", -"#0 c #c47e5c", -"#1 c #bc824c", -"#2 c #e47634", -"#3 c #e46e24", -"#4 c #b48e6c", -"#5 c #7c5a4c", -"#6 c #744e2c", -"#7 c #fcba9c", -"#8 c #cccacc", -"#9 c #f4722c", -"a. c #c46224", -"a# c #e47a54", -"aa c #ac663c", -"ab c #fce2cc", -"ac c #945634", -"ad c #fceacc", -"ae c #3c3e3c", -"af c #ec9e54", -"ag c #843e1c", -"ah c #fccab0", -"ai c #8c8274", -"aj c #4c4634", -"ak c #ecc2ac", -"al c #8c765c", -"am c #7c7264", -"an c #e49a7c", -"ao c #6c4e34", -"ap c #fc9a2c", -"aq c #4c4a4c", -"ar c #ccbea4", -"as c #fcf6dc", -"at c #3c3a3c", -"au c #949294", -"av c #fceebc", -"aw c #fcaa7c", -"ax c #ecdac8", -"ay c #0c0604", -"az c #fc8204", -"aA c #847664", -"aB c #e4d6c4", -"aC c #fcd2ac", -"aD c #1c1a14", -"aE c #342e2c", -"aF c #240e04", -"aG c #2c2e2c", -"aH c #fcbe7c", -"aI c #fc8e14", -"aJ c #fc7a14", -"aK c #944604", -"aL c #7c3e14", -"aM c #fcfadc", -"aN c #645244", -"aO c #bcb6b4", -"aP c #bc5604", -"aQ c #7c522c", -"aR c #cc8264", -"aS c #dccab0", -"aT c #ac9a84", -"aU c #f4e2cc", -"aV c #a45e3c", -"aW c #9c5634", -"aX c #fca634", -"aY c #c4aa89", -"aZ c #a44e07", -"a0 c #b4b6b4", -"a1 c #c4baa9", -"a2 c #a4967c", -"a3 c #b4aea4", -"a4 c #d4c6a8", -"a5 c #5c4a34", -"a6 c #bcae94", -"a7 c #845a2c", -"a8 c #948a7c", -"a9 c #c4b299", -"b. c #b4a690", -"b# c #6c6658", -"ba c #fcd6b4", -"bb c #2c261d", -"bc c #fcf6f0", -"bd c #fcb694", -"be c #fc9624", -"bf c #646664", -"bg c #747674", -"bh c #eceadc", -"bi c #545654", -"bj c #b49e7c", -"bk c #6c6e6c", -"bl c #fc8e04", -"bm c #fcb66c", -"bn c #7c7e7c", -"bo c #5c5e5c", -"bp c #8c8674", -"bq c #fc8604", -"br c #bc5a04", -"bs c #fca23c", -"bt c #443e3c", -"bu c #a4927c", -"bv c #b4aaa4", -"bw c #746a64", -"bx c #342a24", -"by c #fcfafc", -"bz c #2c2a24", -"bA c #a49a8c", -"bB c #bcbabc", -"bC c #9c8e7c", -"bD c #8c7e6c", -"bE c #ccbaa4", -"bF c #fcd2bc", -"bG c #fcb294", -/* pixels */ -"#Gbi#G.#bnbg.t.Zbfbf.hbo#G.Caqaq.c.C.C.C.C.C.C.C.C.C.C.Cbi#Gbi#G", -"#Gbi#Gbg#8#8.a#8#8#8#8#8#8#8#8.B#8#8#8#8#8#8#8#8#8#8#8.C#Gbi#Gbi", -"bi#Gbi#n#8#T#T#T#T#T#T#T#T#T#TbB#T#T#T#T#T#T#T#T#T#T#8aq#6afbm#z", -"#Gbi#Gbk#8#T#T#T#T#T#T#T#T#T#TbB#T#T#T#T#T#T#T#T#T#T#8#6af#aavaX", -"bi#Gbibk#8#T#T#T#T#T#T#T#T#T#TbB#T#T#T#T#T#T#T#T#T#T#6af#a##aX#.", -"#Gbi#Gbk#8#T#T#T#T#T#T#T#T#T#TbB#T#T#T#T#T#T#T#T#T.3af#a.S.e#.bq", -"#Gbi#G.Z#8#T#T#T#T#T#T#T#T#T#TbB#T#T#T#T#T#T#T#TaQaf#a#R.e#eazbq", -"bi#GbibkaubBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBa7af#aba.e#eazbq.M", -"#Gbi#G.Z#8#T#T#T#T#T#T#T#T#T#TbB#T#T#T#T#T#T#Vaf#ababs#ebqbq#.az", -"#Gbi#Gbf#8#T#T#T#T#T#T#T#T#T#TbB#T#T#Tby#T#saf#a#Kap#ebqbqbl#Q.f", -"bi#Gbi.Z#8#T#T#T#T#T#T#T#T#T#TbB#T#T#T#T.Naf#a.z#N#ebqbqbl.R.f#l", -"#Gbi#Gbf#8#T#T#T#T#T#T#T#T#T#TbB#T#T#T#1af.EaHbe#ebqbq#..Rbr#B#y", -"bi#Gbibf#8#T#T#T#T#T#T#T#T#T#TbB#T#T.F.7#jawaI#ebqbqbl.R#PaZ.b..", -"#Gbi#GbfaubBbBbBbBbBbBbBbBbBbBbBbBbG#RaMak#m#ebqbqbl#Q#P#B#w.Y.y", -"bi#Gbibf#8#T#T#T#T#T#T#T#T#T#TaObyaC.Wab#Z#2bqbq.M.RaP.p#way.y.y", -"#Gbi#G.h#8#T#T#T#T#T#T#T#T#Tbya0#I#Tad.K#j#2#QaJ.Rbr.p#yaF.y.yat", -"bi#Gbi.h#8#T#T#T#T#T#T#T#Tby.W.saCasba#Za#.G#9#3aPaZaK.Y.y.yat.c", -"#Gbi#Gbo#8#T#T#T#T#T#T#Tby.Wbc#I#T#p#7.8#0a.#O.P.paLay...yatbtaq", -"bi#Gbi.h#8#T#T#T#T#T#Tby.Wbc.DaCadah#W#0aa.O.2.ragaF#h..ataeaq.C", -"#Gbi#GboaubBbBbBbBbBaOa0.sa3bdasahanaRaV.u.Ta5ae#f.Q#S..aeaq.Cbi", -"bi#Gbibo#8#T#T#T#T.Wbcbc.D#HaCbF#uaRaWaQa5ajbt.HbDai#J..aq.Cbibi", -"#Gbi#Gbo#8#T#Tby.W.W.D#H.nbdab#u#Cac.uaN.o..bDaiaia8#i...Cbibi#G", -"bi#Gbibo#8#T#Tbybc.Dbc.n.4#4.8.q#5.r.l..#vbDaia8a2#g#d..bibi#Gbi", -"#Gbi#G#G#8#T.Wbc.D#H.D#X.j.Lao#5#L.H#vaibpbpbCaT.U#oa2..bi#Gbi#G", -"bi#Gbi#G#8.Wbc.D#H.n.4bjajaD#A...#bpai.9bC#E#ga9.V#r.gbb#Gbi#Gbi", -"#Gbi#Gbiaua0.s.s#Fa3bvaG....#vbwb#b#.JbwaA#i.9bC.m.xal.1bi#Gbi#G", -"bi#Gbi#G#8.D#H.4.4#X.v#x#v#qbAb##Y.6b.a6ar.I#r#r.0.i.g.Lbi#Gbi#G", -"bi#Gbibi#8.D.4.4#X#c.vax.X.AbAamb.#D#oa4aS#r.0.0.i.i#M#A#Gbi#Gbi", -"#Gbi#G.C#8.n.4#X#X.daUaBaS.wa6aiar#raS.0#U#U.0.i.0#r#Mbb#Gbi#Gbi", -"bi#Gbiaq#8.4#Xbh.v#c.d#kaB.Xa4buaS#U#t#U#U.0.0#r.i.i#Mbbbi#Gbi#G", -"#Gbi#Gae.a.a.5a1bE.w.w.w#ba6.U#iaYaYaY.k.g.g.g#M#M#M#M.Lbi#Gbi#G", -"bi#Gbi.HbxaEbxaEbz.LaEbzbzbbbzbbbbbxbb.Lbbbb.1.Lbb.1#Aay#Gbi#Gbi" -}; diff --git a/qwt/examples/refreshtest/circularbuffer.cpp b/qwt/examples/refreshtest/circularbuffer.cpp deleted file mode 100644 index 097efde56..000000000 --- a/qwt/examples/refreshtest/circularbuffer.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "circularbuffer.h" -#include - -CircularBuffer::CircularBuffer(double interval, size_t numPoints): - d_y(NULL), - d_referenceTime(0.0), - d_startIndex(0), - d_offset(0.0) -{ - fill(interval, numPoints); -} - -void CircularBuffer::fill(double interval, size_t numPoints) -{ - if ( interval <= 0.0 || numPoints < 2 ) - return; - - d_values.resize(numPoints); - d_values.fill(0.0); - - if ( d_y ) - { - d_step = interval / (numPoints - 2); - for ( size_t i = 0; i < numPoints; i++ ) - d_values[i] = d_y(i * d_step); - } - - d_interval = interval; -} - -void CircularBuffer::setFunction(double(*y)(double)) -{ - d_y = y; -} - -void CircularBuffer::setReferenceTime(double timeStamp) -{ - d_referenceTime = timeStamp; - - const double startTime = ::fmod(d_referenceTime, d_values.size() * d_step); - - d_startIndex = int(startTime / d_step); // floor - d_offset = ::fmod(startTime, d_step); -} - -double CircularBuffer::referenceTime() const -{ - return d_referenceTime; -} - -size_t CircularBuffer::size() const -{ - return d_values.size(); -} - -QPointF CircularBuffer::sample(size_t i) const -{ - const int size = d_values.size(); - - int index = d_startIndex + i; - if ( index >= size ) - index -= size; - - const double x = i * d_step - d_offset - d_interval; - const double y = d_values.data()[index]; - - return QPointF(x, y); -} - -QRectF CircularBuffer::boundingRect() const -{ - return QRectF(-1.0, -d_interval, 2.0, d_interval); -} \ No newline at end of file diff --git a/qwt/examples/refreshtest/circularbuffer.h b/qwt/examples/refreshtest/circularbuffer.h deleted file mode 100644 index baf1f0849..000000000 --- a/qwt/examples/refreshtest/circularbuffer.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef _CIRCULAR_BUFFER_H_ -#define _CIRCULAR_BUFFER_H_ - -#include -#include - -class CircularBuffer: public QwtSeriesData -{ -public: - CircularBuffer(double interval = 10.0, size_t numPoints = 1000); - void fill(double interval, size_t numPoints); - - void setReferenceTime(double); - double referenceTime() const; - - virtual size_t size() const; - virtual QPointF sample(size_t i) const; - - virtual QRectF boundingRect() const; - - void setFunction(double(*y)(double)); - -private: - double (*d_y)(double); - - double d_referenceTime; - double d_interval; - QVector d_values; - - double d_step; - int d_startIndex; - double d_offset; -}; - -#endif diff --git a/qwt/examples/refreshtest/main.cpp b/qwt/examples/refreshtest/main.cpp deleted file mode 100644 index f1398ec7f..000000000 --- a/qwt/examples/refreshtest/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include "mainwindow.h" - -int main(int argc, char **argv) -{ - QApplication a(argc, argv); - - MainWindow mainWindow; - mainWindow.resize(600,400); - mainWindow.show(); - - return a.exec(); -} diff --git a/qwt/examples/refreshtest/mainwindow.cpp b/qwt/examples/refreshtest/mainwindow.cpp deleted file mode 100644 index 2f03d6ec3..000000000 --- a/qwt/examples/refreshtest/mainwindow.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "panel.h" -#include "plot.h" -#include "mainwindow.h" - -MainWindow::MainWindow(QWidget *parent): - QMainWindow(parent) -{ - QWidget *w = new QWidget(this); - - d_panel = new Panel(w); - - d_plot = new Plot(w); - d_plot->canvas()->installEventFilter(this); - - QHBoxLayout *hLayout = new QHBoxLayout(w); - hLayout->addWidget(d_panel); - hLayout->addWidget(d_plot, 10); - - setCentralWidget(w); - - d_frameCount = new QLabel(this); - statusBar()->addWidget(d_frameCount, 10); - - d_plot->setSettings(d_panel->settings()); - - connect(d_panel, SIGNAL(settingsChanged(const Settings &)), - d_plot, SLOT(setSettings(const Settings &))); -} - -bool MainWindow::eventFilter(QObject *object, QEvent *event) -{ - if ( object == d_plot->canvas() && event->type() == QEvent::Paint ) - { - static int counter; - static QTime timeStamp; - - if ( !timeStamp.isValid() ) - { - timeStamp.start(); - counter = 0; - } - else - { - counter++; - - const double elapsed = timeStamp.elapsed() / 1000.0; - if ( elapsed >= 1 ) - { - QString fps; - fps.setNum(qRound(counter / elapsed)); - fps += " Fps"; - - d_frameCount->setText(fps); - - counter = 0; - timeStamp.start(); - } - } - } - - return QMainWindow::eventFilter(object, event); -}; diff --git a/qwt/examples/refreshtest/mainwindow.h b/qwt/examples/refreshtest/mainwindow.h deleted file mode 100644 index b725f8f11..000000000 --- a/qwt/examples/refreshtest/mainwindow.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _MAIN_WINDOW_H_ -#define _MAIN_WINDOW_H_ - -#include - -class Plot; -class Panel; -class QLabel; - -class MainWindow: public QMainWindow -{ -public: - MainWindow(QWidget *parent = NULL); - virtual bool eventFilter(QObject *, QEvent *); - -private: - Plot *d_plot; - Panel *d_panel; - QLabel *d_frameCount; -}; - -#endif diff --git a/qwt/examples/refreshtest/panel.cpp b/qwt/examples/refreshtest/panel.cpp deleted file mode 100644 index cee9d0e5b..000000000 --- a/qwt/examples/refreshtest/panel.cpp +++ /dev/null @@ -1,264 +0,0 @@ -#include "panel.h" -#include -#include -#include -#include -#include -#include - -class SpinBox: public QSpinBox -{ -public: - SpinBox(int min, int max, int step, QWidget *parent): - QSpinBox(parent) - { - setRange(min, max); - setSingleStep(step); - } -}; - -class CheckBox: public QCheckBox -{ -public: - CheckBox(const QString &title, QWidget *parent): - QCheckBox(title, parent) - { - } - - void setChecked(bool checked) - { - setCheckState(checked ? Qt::Checked : Qt::Unchecked); - } - - bool isChecked() const - { - return checkState() == Qt::Checked; - } -}; - -Panel::Panel(QWidget *parent): - QTabWidget(parent) -{ - setTabPosition(QTabWidget::West); - - addTab(createPlotTab(this), "Plot"); - addTab(createCanvasTab(this), "Canvas"); - addTab(createCurveTab(this), "Curve"); - - setSettings(Settings()); - - connect(d_numPoints, SIGNAL(valueChanged(int)), SLOT(edited()) ); - connect(d_updateInterval, SIGNAL(valueChanged(int)), SLOT(edited()) ); - connect(d_curveWidth, SIGNAL(valueChanged(int)), SLOT(edited()) ); - connect(d_paintCache, SIGNAL(stateChanged(int)), SLOT(edited()) ); - connect(d_paintOnScreen, SIGNAL(stateChanged(int)), SLOT(edited()) ); - connect(d_immediatePaint, SIGNAL(stateChanged(int)), SLOT(edited()) ); - connect(d_curveAntialiasing, SIGNAL(stateChanged(int)), SLOT(edited()) ); - connect(d_curveClipping, SIGNAL(stateChanged(int)), SLOT(edited()) ); - connect(d_lineSplitting, SIGNAL(stateChanged(int)), SLOT(edited()) ); - connect(d_curveFilled, SIGNAL(stateChanged(int)), SLOT(edited()) ); - - connect(d_updateType, SIGNAL(currentIndexChanged(int)), SLOT(edited()) ); - connect(d_gridStyle, SIGNAL(currentIndexChanged(int)), SLOT(edited()) ); - connect(d_curveType, SIGNAL(currentIndexChanged(int)), SLOT(edited()) ); - connect(d_curvePen, SIGNAL(currentIndexChanged(int)), SLOT(edited()) ); -} - -QWidget *Panel::createPlotTab(QWidget *parent) -{ - QWidget *page = new QWidget(parent); - - d_updateInterval = new SpinBox(0, 1000, 10, page); - d_numPoints = new SpinBox(10, 1000000, 1000, page); - - d_updateType = new QComboBox(page); - d_updateType->addItem("Repaint"); - d_updateType->addItem("Replot"); - - int row = 0; - - QGridLayout *layout = new QGridLayout(page); - - layout->addWidget(new QLabel("Updates", page), row, 0 ); - layout->addWidget(d_updateInterval, row, 1); - layout->addWidget(new QLabel("ms", page), row++, 2 ); - - layout->addWidget(new QLabel("Points", page), row, 0 ); - layout->addWidget(d_numPoints, row++, 1); - - layout->addWidget(new QLabel("Update", page), row, 0 ); - layout->addWidget(d_updateType, row++, 1); - - layout->addLayout(new QHBoxLayout(), row++, 0); - - layout->setColumnStretch(1, 10); - layout->setRowStretch(row, 10); - - return page; -} - -QWidget *Panel::createCanvasTab(QWidget *parent) -{ - QWidget *page = new QWidget(parent); - - d_gridStyle = new QComboBox(page); - d_gridStyle->addItem("None"); - d_gridStyle->addItem("Solid"); - d_gridStyle->addItem("Dashes"); - - d_paintCache = new CheckBox("Paint Cache", page); - d_paintOnScreen = new CheckBox("Paint On Screen", page); - d_immediatePaint = new CheckBox("Immediate Paint", page); - - int row = 0; - - QGridLayout *layout = new QGridLayout(page); - layout->addWidget(new QLabel("Grid", page), row, 0); - layout->addWidget(d_gridStyle, row++, 1); - - layout->addWidget(d_paintCache, row++, 0, 1, -1); - layout->addWidget(d_paintOnScreen, row++, 0, 1, -1); - layout->addWidget(d_immediatePaint, row++, 0, 1, -1); - - layout->addLayout(new QHBoxLayout(), row++, 0); - - layout->setColumnStretch(1, 10); - layout->setRowStretch(row, 10); - - return page; -} - -QWidget *Panel::createCurveTab(QWidget *parent) -{ - QWidget *page = new QWidget(parent); - - d_curveType = new QComboBox(page); - d_curveType->addItem("Wave"); - d_curveType->addItem("Noise"); - - d_curveAntialiasing = new CheckBox("Antialiasing", page); - d_curveClipping = new CheckBox("Clipping", page); - d_lineSplitting = new CheckBox("Split Lines", page); - - d_curveWidth = new SpinBox(0, 10, 1, page); - - d_curvePen = new QComboBox(page); - d_curvePen->addItem("Solid"); - d_curvePen->addItem("Dotted"); - - d_curveFilled = new CheckBox("Filled", page); - - int row = 0; - - QGridLayout *layout = new QGridLayout(page); - layout->addWidget(new QLabel("Type", page), row, 0 ); - layout->addWidget(d_curveType, row++, 1); - - layout->addWidget(d_curveAntialiasing, row++, 0, 1, -1); - layout->addWidget(d_curveClipping, row++, 0, 1, -1); - layout->addWidget(d_lineSplitting, row++, 0, 1, -1); - - layout->addWidget(new QLabel("Width", page), row, 0 ); - layout->addWidget(d_curveWidth, row++, 1); - - layout->addWidget(new QLabel("Style", page), row, 0 ); - layout->addWidget(d_curvePen, row++, 1); - - layout->addWidget(d_curveFilled, row++, 0, 1, -1); - - layout->addLayout(new QHBoxLayout(), row++, 0); - - layout->setColumnStretch(1, 10); - layout->setRowStretch(row, 10); - - return page; -} - -void Panel::edited() -{ - const Settings s = settings(); - Q_EMIT settingsChanged(s); -} - - -Settings Panel::settings() const -{ - Settings s; - - s.grid.pen = QPen(Qt::black); - - switch(d_gridStyle->currentIndex()) - { - case 0: - s.grid.pen.setStyle(Qt::NoPen); - break; - case 2: - s.grid.pen.setStyle(Qt::DashLine); - break; - } - - s.curve.pen.setStyle(d_curvePen->currentIndex() == 0 ? - Qt::SolidLine : Qt::DotLine); - s.curve.pen.setWidth(d_curveWidth->value()); - s.curve.brush.setStyle((d_curveFilled->isChecked()) ? - Qt::SolidPattern : Qt::NoBrush); - s.curve.numPoints = d_numPoints->value(); - s.curve.functionType = (Settings::FunctionType)d_curveType->currentIndex(); - if ( d_curveClipping->isChecked() ) - s.curve.paintAttributes |= QwtPlotCurve::ClipPolygons; - else - s.curve.paintAttributes &= ~QwtPlotCurve::ClipPolygons; - - if ( d_curveAntialiasing->isChecked() ) - s.curve.renderHint |= QwtPlotCurve::RenderAntialiased; - else - s.curve.renderHint &= ~QwtPlotCurve::RenderAntialiased; - - s.curve.lineSplitting = (d_lineSplitting->isChecked() ); - - s.canvas.useBackingStore = (d_paintCache->isChecked() ); - s.canvas.paintOnScreen = (d_paintOnScreen->isChecked() ); - s.canvas.immediatePaint = (d_immediatePaint->isChecked() ); - - s.updateInterval = d_updateInterval->value(); - s.updateType = (Settings::UpdateType)d_updateType->currentIndex(); - - return s; -} - -void Panel::setSettings(const Settings &s) -{ - d_numPoints->setValue(s.curve.numPoints); - d_updateInterval->setValue(s.updateInterval); - d_updateType->setCurrentIndex(s.updateType); - - switch(s.grid.pen.style()) - { - case Qt::NoPen: - d_gridStyle->setCurrentIndex(0); - break; - case Qt::DashLine: - d_gridStyle->setCurrentIndex(2); - break; - default: - d_gridStyle->setCurrentIndex(1); // Solid - } - - d_paintCache->setChecked(s.canvas.useBackingStore ); - d_paintOnScreen->setChecked(s.canvas.paintOnScreen); - d_immediatePaint->setChecked(s.canvas.immediatePaint); - - d_curveType->setCurrentIndex(s.curve.functionType); - d_curveAntialiasing->setChecked( - s.curve.renderHint & QwtPlotCurve::RenderAntialiased ); - - d_curveClipping->setChecked( - s.curve.paintAttributes & QwtPlotCurve::ClipPolygons); - - d_lineSplitting->setChecked(s.curve.lineSplitting ); - - d_curveWidth->setValue(s.curve.pen.width()); - d_curvePen->setCurrentIndex( - s.curve.pen.style() == Qt::SolidLine ? 0 : 1); - d_curveFilled->setChecked(s.curve.brush.style() != Qt::NoBrush); -} diff --git a/qwt/examples/refreshtest/panel.h b/qwt/examples/refreshtest/panel.h deleted file mode 100644 index 74a1e0555..000000000 --- a/qwt/examples/refreshtest/panel.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _PANEL_H_ -#define _PANEL_H_ 1 - -#include "settings.h" -#include - -class QComboBox; -class SpinBox; -class CheckBox; - -class Panel: public QTabWidget -{ - Q_OBJECT - -public: - Panel(QWidget * = NULL); - - Settings settings() const; - void setSettings(const Settings &); - -Q_SIGNALS: - void settingsChanged(const Settings &); - -private Q_SLOTS: - void edited(); - -private: - QWidget *createPlotTab(QWidget *); - QWidget *createCanvasTab(QWidget *); - QWidget *createCurveTab(QWidget *); - - SpinBox *d_numPoints; - SpinBox *d_updateInterval; - QComboBox *d_updateType; - - QComboBox *d_gridStyle; - CheckBox *d_paintCache; - CheckBox *d_paintOnScreen; - CheckBox *d_immediatePaint; - - QComboBox *d_curveType; - CheckBox *d_curveAntialiasing; - CheckBox *d_curveClipping; - CheckBox *d_lineSplitting; - SpinBox *d_curveWidth; - QComboBox *d_curvePen; - CheckBox *d_curveFilled; -}; - -#endif diff --git a/qwt/examples/refreshtest/plot.cpp b/qwt/examples/refreshtest/plot.cpp deleted file mode 100644 index 870507647..000000000 --- a/qwt/examples/refreshtest/plot.cpp +++ /dev/null @@ -1,161 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include "plot.h" -#include "circularbuffer.h" -#include "settings.h" - -static double wave(double x) -{ - const double period = 1.0; - const double c = 5.0; - - double v = ::fmod(x, period); - - const double amplitude = qAbs(x - qRound(x / c) * c) / ( 0.5 * c ); - v = amplitude * qSin(v / period * 2 * M_PI); - - return v; -} - -static double noise(double) -{ - return 2.0 * ( qrand() / ((double)RAND_MAX + 1) ) - 1.0; -} - -Plot::Plot(QWidget *parent): - QwtPlot(parent), - d_interval(10.0), // seconds - d_timerId(-1) -{ - // Assign a title - setTitle("Testing Refresh Rates"); - - setCanvasBackground(Qt::white); - - alignScales(); - - // Insert grid - d_grid = new QwtPlotGrid(); - d_grid->attach(this); - - // Insert curve - d_curve = new QwtPlotCurve("Data Moving Right"); - d_curve->setPen(QPen(Qt::black)); - d_curve->setData(new CircularBuffer(d_interval, 10)); - d_curve->attach(this); - - // Axis - setAxisTitle(QwtPlot::xBottom, "Seconds"); - setAxisScale(QwtPlot::xBottom, -d_interval, 0.0); - - setAxisTitle(QwtPlot::yLeft, "Values"); - setAxisScale(QwtPlot::yLeft, -1.0, 1.0); - - d_clock.start(); - - setSettings(d_settings); -} - -// -// Set a plain canvas frame and align the scales to it -// -void Plot::alignScales() -{ - // The code below shows how to align the scales to - // the canvas frame, but is also a good example demonstrating - // why the spreaded API needs polishing. - - canvas()->setFrameStyle(QFrame::Box | QFrame::Plain ); - canvas()->setLineWidth(1); - - for ( int i = 0; i < QwtPlot::axisCnt; i++ ) - { - QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(i); - if ( scaleWidget ) - scaleWidget->setMargin(0); - - QwtScaleDraw *scaleDraw = (QwtScaleDraw *)axisScaleDraw(i); - if ( scaleDraw ) - scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false); - } - - plotLayout()->setAlignCanvasToScales(true); -} - -void Plot::setSettings(const Settings &s) -{ - if ( d_timerId >= 0 ) - killTimer(d_timerId); - - d_timerId = startTimer(s.updateInterval); - - d_grid->setPen(s.grid.pen); - d_grid->setVisible(s.grid.pen.style() != Qt::NoPen); - - CircularBuffer *buffer = (CircularBuffer *)d_curve->data(); - if ( s.curve.numPoints != buffer->size() || - s.curve.functionType != d_settings.curve.functionType ) - { - - switch(s.curve.functionType) - { - case Settings::Wave: - buffer->setFunction(wave); - break; - case Settings::Noise: - buffer->setFunction(noise); - break; - default: - buffer->setFunction(NULL); - } - - buffer->fill(d_interval, s.curve.numPoints); - } - - d_curve->setPen(s.curve.pen); - d_curve->setBrush(s.curve.brush); - - d_curve->setPaintAttribute(QwtPlotCurve::ClipPolygons, - s.curve.paintAttributes & QwtPlotCurve::ClipPolygons); - d_curve->setRenderHint(QwtPlotCurve::RenderAntialiased, - s.curve.renderHint & QwtPlotCurve::RenderAntialiased); - - canvas()->setAttribute(Qt::WA_PaintOnScreen, s.canvas.paintOnScreen); - - canvas()->setPaintAttribute( - QwtPlotCanvas::BackingStore, s.canvas.useBackingStore); - canvas()->setPaintAttribute( - QwtPlotCanvas::ImmediatePaint, s.canvas.immediatePaint); - - QwtPainter::setPolylineSplitting(s.curve.lineSplitting); - - d_settings = s; -} - -void Plot::timerEvent(QTimerEvent *) -{ - CircularBuffer *buffer = (CircularBuffer *)d_curve->data(); - buffer->setReferenceTime(d_clock.elapsed() / 1000.0); - - switch(d_settings.updateType) - { - case Settings::RepaintCanvas: - { - // the axes in this example doesn't change. So all we need to do - // is to repaint the canvas. - - canvas()->replot(); - break; - } - default: - { - replot(); - } - } -} diff --git a/qwt/examples/refreshtest/plot.h b/qwt/examples/refreshtest/plot.h deleted file mode 100644 index e28499604..000000000 --- a/qwt/examples/refreshtest/plot.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _PLOT_H_ -#define _PLOT_H_ 1 - -#include -#include -#include "settings.h" - -class QwtPlotGrid; -class QwtPlotCurve; - -class Plot: public QwtPlot -{ - Q_OBJECT - -public: - Plot(QWidget* = NULL); - -public Q_SLOTS: - void setSettings(const Settings &); - -protected: - virtual void timerEvent(QTimerEvent *e); - -private: - void alignScales(); - - QwtPlotGrid *d_grid; - QwtPlotCurve *d_curve; - - QwtSystemClock d_clock; - double d_interval; - - int d_timerId; - - Settings d_settings; -}; - -#endif diff --git a/qwt/examples/refreshtest/refreshtest.pro b/qwt/examples/refreshtest/refreshtest.pro deleted file mode 100644 index 33da0de1e..000000000 --- a/qwt/examples/refreshtest/refreshtest.pro +++ /dev/null @@ -1,26 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = refreshtest - -HEADERS = \ - settings.h \ - circularbuffer.h \ - panel.h \ - plot.h \ - mainwindow.h - -SOURCES = \ - circularbuffer.cpp \ - panel.cpp \ - plot.cpp \ - mainwindow.cpp \ - main.cpp diff --git a/qwt/examples/refreshtest/settings.h b/qwt/examples/refreshtest/settings.h deleted file mode 100644 index 6fbfc9ef3..000000000 --- a/qwt/examples/refreshtest/settings.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _SETTINGS_H_ -#define _SETTINGS_H_ - -#include -#include - -class Settings -{ -public: - enum FunctionType - { - NoFunction = -1, - - Wave, - Noise - }; - - enum UpdateType - { - RepaintCanvas, - Replot - }; - - Settings() - { - grid.pen = Qt::NoPen; - - curve.brush = Qt::NoBrush; - curve.numPoints = 1000; - curve.functionType = Wave; - curve.paintAttributes = 0; - curve.renderHint = 0; - curve.lineSplitting = true; - - canvas.useBackingStore = false; - canvas.paintOnScreen = false; - canvas.immediatePaint = true; - - updateType = RepaintCanvas; - updateInterval = 20; - } - - struct gridSettings - { - QPen pen; - } grid; - - struct curveSettings - { - QPen pen; - QBrush brush; - uint numPoints; - FunctionType functionType; - int paintAttributes; - int renderHint; - bool lineSplitting; - } curve; - - struct canvasSettings - { - bool useBackingStore; - bool paintOnScreen; - bool immediatePaint; - } canvas; - - UpdateType updateType; - int updateInterval; -}; - -#endif diff --git a/qwt/examples/sinusplot/sinusplot.cpp b/qwt/examples/sinusplot/sinusplot.cpp deleted file mode 100644 index ec9e9e462..000000000 --- a/qwt/examples/sinusplot/sinusplot.cpp +++ /dev/null @@ -1,182 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//----------------------------------------------------------------- -// simple.cpp -// -// A simple example which shows how to use QwtPlot connected -// to a data class without any storage, calculating each values -// on the fly. -//----------------------------------------------------------------- - -class FunctionData: public QwtSyntheticPointData -{ -public: - FunctionData(double(*y)(double)): - QwtSyntheticPointData(100), - d_y(y) - { - } - - virtual double y(double x) const - { - return d_y(x); - } - -private: - double(*d_y)(double); -}; - -class Plot : public QwtPlot -{ -public: - Plot( QWidget *parent = NULL); - -protected: - virtual void resizeEvent( QResizeEvent * ); - -private: - void populate(); - void updateGradient(); -}; - - -Plot::Plot(QWidget *parent): - QwtPlot( parent ) -{ - // panning with the left mouse button - (void) new QwtPlotPanner( canvas() ); - - // zoom in/out with the wheel - (void) new QwtPlotMagnifier( canvas() ); - - setAutoFillBackground( true ); - setPalette( QPalette( QColor( 165, 193, 228 ) ) ); - updateGradient(); - - setTitle("A Simple QwtPlot Demonstration"); - insertLegend(new QwtLegend(), QwtPlot::RightLegend); - - // axes - setAxisTitle(xBottom, "x -->" ); - setAxisScale(xBottom, 0.0, 10.0); - - setAxisTitle(yLeft, "y -->"); - setAxisScale(yLeft, -1.0, 1.0); - - // canvas - canvas()->setLineWidth( 1 ); - canvas()->setFrameStyle( QFrame::Box | QFrame::Plain ); - canvas()->setBorderRadius( 15 ); - - QPalette canvasPalette( Qt::white ); - canvasPalette.setColor( QPalette::Foreground, QColor( 133, 190, 232 ) ); - canvas()->setPalette( canvasPalette ); - - populate(); -} - -void Plot::populate() -{ - // Insert new curves - QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)"); - cSin->setRenderHint(QwtPlotItem::RenderAntialiased); - cSin->setLegendAttribute(QwtPlotCurve::LegendShowLine, true); - cSin->setPen(QPen(Qt::red)); - cSin->attach(this); - - QwtPlotCurve *cCos = new QwtPlotCurve("y = cos(x)"); - cCos->setRenderHint(QwtPlotItem::RenderAntialiased); - cCos->setLegendAttribute(QwtPlotCurve::LegendShowLine, true); - cCos->setPen(QPen(Qt::blue)); - cCos->attach(this); - - // Create sin and cos data - cSin->setData(new FunctionData(::sin)); - cCos->setData(new FunctionData(::cos)); - - // Insert markers - - // ...a horizontal line at y = 0... - QwtPlotMarker *mY = new QwtPlotMarker(); - mY->setLabel(QString::fromLatin1("y = 0")); - mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop); - mY->setLineStyle(QwtPlotMarker::HLine); - mY->setYValue(0.0); - mY->attach(this); - - // ...a vertical line at x = 2 * pi - QwtPlotMarker *mX = new QwtPlotMarker(); - mX->setLabel(QString::fromLatin1("x = 2 pi")); - mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom); - mX->setLabelOrientation(Qt::Vertical); - mX->setLineStyle(QwtPlotMarker::VLine); - mX->setLinePen(QPen(Qt::black, 0, Qt::DashDotLine)); - mX->setXValue(2.0 * M_PI); - mX->attach(this); -} - -void Plot::updateGradient() -{ - QPalette pal = palette(); - - const QColor buttonColor = pal.color( QPalette::Button ); - -#ifdef Q_WS_X11 - // Qt 4.7.1: QGradient::StretchToDeviceMode is buggy on X11 - - QLinearGradient gradient( rect().topLeft(), rect().bottomLeft() ); - gradient.setColorAt( 0.0, Qt::white ); - gradient.setColorAt( 0.7, buttonColor ); - gradient.setColorAt( 1.0, buttonColor ); -#else - QLinearGradient gradient( 0, 0, 0, 1 ); - gradient.setCoordinateMode( QGradient::StretchToDeviceMode ); - gradient.setColorAt( 0.0, Qt::white ); - gradient.setColorAt( 0.7, buttonColor ); - gradient.setColorAt( 1.0, buttonColor ); -#endif - - pal.setBrush( QPalette::Window, gradient ); - setPalette( pal ); -} - -void Plot::resizeEvent( QResizeEvent *event ) -{ - QwtPlot::resizeEvent( event ); -#ifdef Q_WS_X11 - updateGradient(); -#endif -} - -int main(int argc, char **argv) -{ - QApplication a(argc, argv); - - Plot *plot = new Plot(); - - // We put a dummy widget around to have - // so that Qt paints a widget background - // when resizing - - QWidget window; - QHBoxLayout *layout = new QHBoxLayout( &window ); - layout->setContentsMargins( 0, 0, 0, 0 ); - layout->addWidget( plot ); - - window.resize(600,400); - window.show(); - - return a.exec(); -} diff --git a/qwt/examples/sinusplot/sinusplot.pro b/qwt/examples/sinusplot/sinusplot.pro deleted file mode 100644 index e190dfd0b..000000000 --- a/qwt/examples/sinusplot/sinusplot.pro +++ /dev/null @@ -1,15 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = sinusplot - -SOURCES = \ - sinusplot.cpp diff --git a/qwt/examples/sliders/sliders.cpp b/qwt/examples/sliders/sliders.cpp deleted file mode 100644 index 7590c28af..000000000 --- a/qwt/examples/sliders/sliders.cpp +++ /dev/null @@ -1,193 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "sliders.h" - -class Layout: public QBoxLayout -{ -public: - Layout(Qt::Orientation o, QWidget *parent = NULL): - QBoxLayout(QBoxLayout::LeftToRight, parent) - { - if ( o == Qt::Vertical ) - setDirection(QBoxLayout::TopToBottom); - - setSpacing(20); - setMargin(0); - } -}; - -Slider::Slider(QWidget *parent, int sliderType): - QWidget(parent) -{ - d_slider = createSlider(this, sliderType); - - QFlags alignment; - switch(d_slider->scalePosition()) - { - case QwtSlider::NoScale: - if ( d_slider->orientation() == Qt::Horizontal ) - alignment = Qt::AlignHCenter | Qt::AlignTop; - else - alignment = Qt::AlignVCenter | Qt::AlignLeft; - break; - case QwtSlider::LeftScale: - alignment = Qt::AlignVCenter | Qt::AlignRight; - break; - case QwtSlider::RightScale: - alignment = Qt::AlignVCenter | Qt::AlignLeft; - break; - case QwtSlider::TopScale: - alignment = Qt::AlignHCenter | Qt::AlignBottom; - break; - case QwtSlider::BottomScale: - alignment = Qt::AlignHCenter | Qt::AlignTop; - break; - } - - d_label = new QLabel("0", this); - d_label->setAlignment(alignment); - d_label->setFixedWidth(d_label->fontMetrics().width("10000.9")); - - connect(d_slider, SIGNAL(valueChanged(double)), SLOT(setNum(double))); - - QBoxLayout *layout; - if ( d_slider->orientation() == Qt::Horizontal ) - layout = new QHBoxLayout(this); - else - layout = new QVBoxLayout(this); - - layout->addWidget(d_slider); - layout->addWidget(d_label); -} - -QwtSlider *Slider::createSlider(QWidget *parent, int sliderType) const -{ - QwtSlider *slider = NULL; - - switch( sliderType ) - { - case 0: - { - slider = new QwtSlider(parent, Qt::Horizontal, - QwtSlider::TopScale, QwtSlider::Trough); - slider->setHandleSize( 30, 16 ); - slider->setRange(-10.0, 10.0, 1.0, 0); // paging disabled - break; - } - case 1: - { - slider = new QwtSlider(parent, Qt::Horizontal, - QwtSlider::NoScale, QwtSlider::Trough | QwtSlider::Groove ); - slider->setRange(0.0, 1.0, 0.01, 5); - break; - } - case 2: - { - slider = new QwtSlider(parent, Qt::Horizontal, - QwtSlider::BottomScale, QwtSlider::Groove); - slider->setHandleSize( 12, 25 ); - slider->setRange(1000.0, 3000.0, 10.0, 10); - break; - } - case 3: - { - slider = new QwtSlider(parent, Qt::Vertical, - QwtSlider::LeftScale, QwtSlider::Groove); - slider->setRange(0.0, 100.0, 1.0, 5); - slider->setScaleMaxMinor(5); - break; - } - case 4: - { - slider = new QwtSlider(parent, Qt::Vertical, - QwtSlider::NoScale, QwtSlider::Trough); - slider->setRange(0.0,100.0,1.0, 10); - break; - } - case 5: - { - slider = new QwtSlider(parent, Qt::Vertical, - QwtSlider::RightScale, QwtSlider::Trough | QwtSlider::Groove); - slider->setScaleEngine(new QwtLog10ScaleEngine); - slider->setHandleSize( 20, 32 ); - slider->setBorderWidth(1); - slider->setRange(0.0, 4.0, 0.01); - slider->setScale(1.0, 1.0e4); - slider->setScaleMaxMinor(10); - break; - } - } - - if ( slider ) - { - QString name( "Slider %1" ); - slider->setObjectName( name.arg( sliderType ) ); - } - - return slider; -} - -void Slider::setNum( double v ) -{ - if ( d_slider->scaleMap().transformation()->type() == - QwtScaleTransformation::Log10 ) - { - v = qPow(10.0, v); - } - - QString text; - text.setNum(v, 'f', 1); - - d_label->setText(text); -} - -SliderDemo::SliderDemo(QWidget *p): - QWidget(p) -{ - int i; - - Layout *hSliderLayout = new Layout(Qt::Vertical); - for ( i = 0; i < 3; i++ ) - hSliderLayout->addWidget(new Slider(this, i)); - hSliderLayout->addStretch(); - - Layout *vSliderLayout = new Layout(Qt::Horizontal); - for ( ; i < 6; i++ ) - vSliderLayout->addWidget(new Slider(this, i)); - - QLabel *vTitle = new QLabel("Vertical Sliders", this); - vTitle->setFont(QFont("Helvetica", 14, QFont::Bold)); - vTitle->setAlignment(Qt::AlignHCenter); - - Layout *layout1 = new Layout(Qt::Vertical); - layout1->addWidget(vTitle, 0); - layout1->addLayout(vSliderLayout, 10); - - QLabel *hTitle = new QLabel("Horizontal Sliders", this); - hTitle->setFont(vTitle->font()); - hTitle->setAlignment(Qt::AlignHCenter); - - Layout *layout2 = new Layout(Qt::Vertical); - layout2->addWidget(hTitle, 0); - layout2->addLayout(hSliderLayout, 10); - - Layout *mainLayout = new Layout(Qt::Horizontal, this); - mainLayout->addLayout(layout1); - mainLayout->addLayout(layout2, 10); -} - -int main (int argc, char **argv) -{ - QApplication a(argc, argv); - - QApplication::setFont(QFont("Helvetica",10)); - - SliderDemo w; - w.show(); - - return a.exec(); -} diff --git a/qwt/examples/sliders/sliders.h b/qwt/examples/sliders/sliders.h deleted file mode 100644 index 02d10475b..000000000 --- a/qwt/examples/sliders/sliders.h +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include - -class QLabel; -class QLayout; - -class Slider: public QWidget -{ - Q_OBJECT -public: - Slider(QWidget *parent, int sliderType); - -private Q_SLOTS: - void setNum(double v); - -private: - QwtSlider *createSlider(QWidget *, int sliderType) const; - - QwtSlider *d_slider; - QLabel *d_label; -}; - -class SliderDemo : public QWidget -{ -public: - SliderDemo(QWidget *p = NULL); -}; diff --git a/qwt/examples/sliders/sliders.pro b/qwt/examples/sliders/sliders.pro deleted file mode 100644 index 10cffc76b..000000000 --- a/qwt/examples/sliders/sliders.pro +++ /dev/null @@ -1,18 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = sliders - -HEADERS = \ - sliders.h - -SOURCES = \ - sliders.cpp diff --git a/qwt/examples/spectrogram/main.cpp b/qwt/examples/spectrogram/main.cpp deleted file mode 100644 index 0cb50c93e..000000000 --- a/qwt/examples/spectrogram/main.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include -#include -#include -#include "plot.h" - -class MainWindow: public QMainWindow -{ -public: - MainWindow(QWidget * = NULL); - -private: - Plot *d_plot; -}; - -MainWindow::MainWindow(QWidget *parent): - QMainWindow(parent) -{ - d_plot = new Plot(this); - - setCentralWidget(d_plot); - - QToolBar *toolBar = new QToolBar(this); - - QToolButton *btnSpectrogram = new QToolButton(toolBar); - btnSpectrogram->setText("Spectrogram"); - btnSpectrogram->setCheckable(true); - btnSpectrogram->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - toolBar->addWidget(btnSpectrogram); - connect(btnSpectrogram, SIGNAL(toggled(bool)), - d_plot, SLOT(showSpectrogram(bool))); - - QToolButton *btnContour = new QToolButton(toolBar); - btnContour->setText("Contour"); - btnContour->setCheckable(true); - btnContour->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - toolBar->addWidget(btnContour); - connect(btnContour, SIGNAL(toggled(bool)), - d_plot, SLOT(showContour(bool))); - -#ifndef QT_NO_PRINTER - QToolButton *btnPrint = new QToolButton(toolBar); - btnPrint->setText("Print"); - btnPrint->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - toolBar->addWidget(btnPrint); - connect(btnPrint, SIGNAL(clicked()), - d_plot, SLOT(printPlot()) ); -#endif - - addToolBar(toolBar); - - btnSpectrogram->setChecked(true); - btnContour->setChecked(false); -} - -int main(int argc, char **argv) -{ - QApplication a(argc, argv); - - MainWindow mainWindow; - mainWindow.resize(600,400); - mainWindow.show(); - - return a.exec(); -} diff --git a/qwt/examples/spectrogram/plot.cpp b/qwt/examples/spectrogram/plot.cpp deleted file mode 100644 index ca5d66a67..000000000 --- a/qwt/examples/spectrogram/plot.cpp +++ /dev/null @@ -1,158 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "plot.h" - -class MyZoomer: public QwtPlotZoomer -{ -public: - MyZoomer(QwtPlotCanvas *canvas): - QwtPlotZoomer(canvas) - { - setTrackerMode(AlwaysOn); - } - - virtual QwtText trackerTextF(const QPointF &pos) const - { - QColor bg(Qt::white); - bg.setAlpha(200); - - QwtText text = QwtPlotZoomer::trackerTextF(pos); - text.setBackgroundBrush( QBrush( bg )); - return text; - } -}; - -class SpectrogramData: public QwtRasterData -{ -public: - SpectrogramData() - { - setInterval( Qt::XAxis, QwtInterval( -1.5, 1.5 ) ); - setInterval( Qt::YAxis, QwtInterval( -1.5, 1.5 ) ); - setInterval( Qt::ZAxis, QwtInterval( 0.0, 10.0 ) ); - } - - virtual double value(double x, double y) const - { - const double c = 0.842; - - const double v1 = x * x + (y-c) * (y+c); - const double v2 = x * (y+c) + x * (y+c); - - return 1.0 / (v1 * v1 + v2 * v2); - } -}; - -class ColorMap: public QwtLinearColorMap -{ -public: - ColorMap(): - QwtLinearColorMap(Qt::darkCyan, Qt::red) - { - addColorStop(0.1, Qt::cyan); - addColorStop(0.6, Qt::green); - addColorStop(0.95, Qt::yellow); - } -}; - -Plot::Plot(QWidget *parent): - QwtPlot(parent) -{ - d_spectrogram = new QwtPlotSpectrogram(); - d_spectrogram->setRenderThreadCount(0); // use system specific thread count - - d_spectrogram->setColorMap(new ColorMap()); - - d_spectrogram->setData(new SpectrogramData()); - d_spectrogram->attach(this); - - QList contourLevels; - for ( double level = 0.5; level < 10.0; level += 1.0 ) - contourLevels += level; - d_spectrogram->setContourLevels(contourLevels); - - const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis ); - // A color bar on the right axis - QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight); - rightAxis->setTitle("Intensity"); - rightAxis->setColorBarEnabled(true); - rightAxis->setColorMap( zInterval, new ColorMap()); - - setAxisScale(QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() ); - enableAxis(QwtPlot::yRight); - - plotLayout()->setAlignCanvasToScales(true); - replot(); - - // LeftButton for the zooming - // MidButton for the panning - // RightButton: zoom out by 1 - // Ctrl+RighButton: zoom out to full size - - QwtPlotZoomer* zoomer = new MyZoomer(canvas()); - zoomer->setMousePattern(QwtEventPattern::MouseSelect2, - Qt::RightButton, Qt::ControlModifier); - zoomer->setMousePattern(QwtEventPattern::MouseSelect3, - Qt::RightButton); - - QwtPlotPanner *panner = new QwtPlotPanner(canvas()); - panner->setAxisEnabled(QwtPlot::yRight, false); - panner->setMouseButton(Qt::MidButton); - - // Avoid jumping when labels with more/less digits - // appear/disappear when scrolling vertically - - const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); - QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft); - sd->setMinimumExtent( fm.width("100.00") ); - - const QColor c(Qt::darkBlue); - zoomer->setRubberBandPen(c); - zoomer->setTrackerPen(c); -} - -void Plot::showContour(bool on) -{ - d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ContourMode, on); - replot(); -} - -void Plot::showSpectrogram(bool on) -{ - d_spectrogram->setDisplayMode(QwtPlotSpectrogram::ImageMode, on); - d_spectrogram->setDefaultContourPen(on ? QPen() : QPen(Qt::NoPen)); - replot(); -} - -#ifndef QT_NO_PRINTER - -void Plot::printPlot() -{ -#if 1 - QPrinter printer; -#else - QPrinter printer(QPrinter::HighResolution); -#endif - printer.setOrientation(QPrinter::Landscape); - printer.setOutputFileName("spectrogram.pdf"); - QPrintDialog dialog(&printer); - if ( dialog.exec() ) - { - QwtPlotRenderer renderer; - - renderer.setDiscardFlag(QwtPlotRenderer::DiscardBackground, false); - renderer.setLayoutFlag(QwtPlotRenderer::KeepFrames, true); - - renderer.renderTo(this, printer); - } -} - -#endif diff --git a/qwt/examples/spectrogram/plot.h b/qwt/examples/spectrogram/plot.h deleted file mode 100644 index 3d9da9f40..000000000 --- a/qwt/examples/spectrogram/plot.h +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -class Plot: public QwtPlot -{ - Q_OBJECT - -public: - Plot(QWidget * = NULL); - -public Q_SLOTS: - void showContour(bool on); - void showSpectrogram(bool on); - -#ifndef QT_NO_PRINTER - void printPlot(); -#endif - -private: - QwtPlotSpectrogram *d_spectrogram; -}; diff --git a/qwt/examples/spectrogram/spectrogram.pro b/qwt/examples/spectrogram/spectrogram.pro deleted file mode 100644 index aea5ddcbd..000000000 --- a/qwt/examples/spectrogram/spectrogram.pro +++ /dev/null @@ -1,19 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = spectrogram - -HEADERS = \ - plot.h - -SOURCES = \ - plot.cpp \ - main.cpp diff --git a/qwt/examples/stylesheets/choco.css b/qwt/examples/stylesheets/choco.css deleted file mode 100644 index e2fe171ad..000000000 --- a/qwt/examples/stylesheets/choco.css +++ /dev/null @@ -1,38 +0,0 @@ -QwtPlot -{ - border: 1px solid white; - border-radius: 10px; - padding: 10px; - background-color: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 Brown, stop: 0.5 Chocolate, stop: 1 Brown ); -} - -QwtPlotCanvas -{ - border: 1px solid White; - border-radius: 10px; - background-color: Tan; -} - -QwtScaleWidget -{ - color: palette(light); -} - -QwtTextLabel#QwtPlotTitle -{ - color: palette(light); -} - -QwtLegend -{ - border: 1px solid white; - border-radius: 10px; - padding: 10px; - background: brown; -} - -QwtLegendItem -{ - color: palette(light); -} diff --git a/qwt/examples/svgmap/main.cpp b/qwt/examples/svgmap/main.cpp deleted file mode 100644 index 27091f1bc..000000000 --- a/qwt/examples/svgmap/main.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include -#include -#include -#include "plot.h" - -class MainWindow: public QMainWindow -{ -public: - MainWindow(const QString &fileName) - { - Plot *plot = new Plot(this); - if ( !fileName.isEmpty() ) - plot->loadSVG(fileName); - - setCentralWidget(plot); - -#ifndef QT_NO_FILEDIALOG - - QToolBar *toolBar = new QToolBar(this); - - QToolButton *btnLoad = new QToolButton(toolBar); - - btnLoad->setText("Load SVG"); - btnLoad->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - toolBar->addWidget(btnLoad); - - addToolBar(toolBar); - - connect(btnLoad, SIGNAL(clicked()), plot, SLOT(loadSVG())); -#endif - } -}; - -int main(int argc, char **argv) -{ - QApplication a(argc, argv); - - QString fileName; - if ( argc > 1 ) - fileName = argv[1]; - - MainWindow w(fileName); - w.resize(600,400); - w.show(); - - int rv = a.exec(); - return rv; -} diff --git a/qwt/examples/svgmap/plot.cpp b/qwt/examples/svgmap/plot.cpp deleted file mode 100644 index 2d8cd6b70..000000000 --- a/qwt/examples/svgmap/plot.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include "plot.h" - -Plot::Plot(QWidget *parent): - QwtPlot(parent), - d_mapItem(NULL), - d_mapRect(0.0, 0.0, 100.0, 100.0) // something -{ -#if 1 - /* - d_mapRect is only a reference for zooming, but - the ranges are nothing useful for the user. So we - hide the axes. - */ - plotLayout()->setCanvasMargin(0); - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - enableAxis(axis, false); -#else - QwtPlotGrid *grid = new QwtPlotGrid(); - grid->attach(this); -#endif - - /* - Navigation: - - Left Mouse Button: Panning - Mouse Wheel: Zooming In/Out - Right Mouse Button: Reset to initial - */ - - (void)new QwtPlotPanner(canvas()); - (void)new QwtPlotMagnifier(canvas()); - - canvas()->setFocusPolicy(Qt::WheelFocus); - rescale(); -} - -#ifndef QT_NO_FILEDIALOG - -void Plot::loadSVG() -{ - QString dir; - const QString fileName = QFileDialog::getOpenFileName( NULL, - "Load a Scaleable Vector Graphic (SVG) Map", - dir, "SVG Files (*.svg)"); - - if ( !fileName.isEmpty() ) - loadSVG(fileName); -} - -#endif - -void Plot::loadSVG(const QString &fileName) -{ - if ( d_mapItem == NULL ) - { - d_mapItem = new QwtPlotSvgItem(); - d_mapItem->attach(this); - } - - d_mapItem->loadFile(d_mapRect, fileName); - rescale(); - - replot(); -} - -void Plot::rescale() -{ - setAxisScale(QwtPlot::xBottom, - d_mapRect.left(), d_mapRect.right()); - setAxisScale(QwtPlot::yLeft, - d_mapRect.top(), d_mapRect.bottom()); -} diff --git a/qwt/examples/svgmap/plot.h b/qwt/examples/svgmap/plot.h deleted file mode 100644 index 392e4decd..000000000 --- a/qwt/examples/svgmap/plot.h +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include - -class QwtPlotSvgItem; - -class Plot: public QwtPlot -{ - Q_OBJECT - -public: - Plot(QWidget * = NULL); - -public Q_SLOTS: - -#ifndef QT_NO_FILEDIALOG - void loadSVG(); -#endif - - void loadSVG(const QString &); - -private: - void rescale(); - - QwtPlotSvgItem *d_mapItem; - const QRectF d_mapRect; -}; diff --git a/qwt/examples/svgmap/svgmap.pro b/qwt/examples/svgmap/svgmap.pro deleted file mode 100644 index 1324f70de..000000000 --- a/qwt/examples/svgmap/svgmap.pro +++ /dev/null @@ -1,26 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -!contains(QWT_CONFIG, QwtSvg) { - - message(Are you trying to build Qwt with the Qt Creator as Shadow Build ?) - error(Qwt is configured without SVG support !) -} - -TARGET = svgmap -QT += svg - -HEADERS = \ - plot.h - -SOURCES = \ - plot.cpp \ - main.cpp diff --git a/qwt/examples/sysinfo/sysinfo.cpp b/qwt/examples/sysinfo/sysinfo.cpp deleted file mode 100644 index 6315b839a..000000000 --- a/qwt/examples/sysinfo/sysinfo.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -class ValueBar: public QWidget -{ -public: - ValueBar( Qt::Orientation orientation, - const QString &text, QWidget *parent, double value = 0.0 ): - QWidget( parent ) - { - d_label = new QLabel( text, this ); - d_label->setFont( QFont( "Helvetica", 10 ) ); - - d_thermo = new QwtThermo( this ); - d_thermo->setRange( 0.0, 100.0 ); - d_thermo->setValue( value ); - d_thermo->setFont( QFont( "Helvetica", 8 ) ); - d_thermo->setPipeWidth( 6 ); - d_thermo->setScaleMaxMajor( 6 ); - d_thermo->setScaleMaxMinor( 5 ); - d_thermo->setFillBrush( Qt::darkMagenta ); - -#if 0 - QwtLinearColorMap *colorMap = - new QwtLinearColorMap( Qt::blue, Qt::red ); - - colorMap->addColorStop( 0.2, Qt::yellow ); - colorMap->addColorStop( 0.3, Qt::cyan ); - colorMap->addColorStop( 0.4, Qt::green ); - colorMap->addColorStop( 0.5, Qt::magenta ); - colorMap->setMode( QwtLinearColorMap::FixedColors ); - d_thermo->setColorMap( colorMap ); -#endif - - QVBoxLayout *layout = new QVBoxLayout( this ); - layout->setMargin( 0 ); - layout->setSpacing( 0 ); - - if ( orientation == Qt::Horizontal ) - { - d_label->setAlignment( Qt::AlignCenter ); - d_thermo->setOrientation( orientation, QwtThermo::BottomScale ); - layout->addWidget( d_label ); - layout->addWidget( d_thermo ); - } - else - { - d_label->setAlignment( Qt::AlignRight ); - d_thermo->setOrientation( orientation, QwtThermo::LeftScale ); - layout->addWidget( d_thermo, 10, Qt::AlignHCenter ); - layout->addWidget( d_label, 0 ); - } - } - - void setValue( double value ) - { - d_thermo->setValue( value ); - } -private: - QLabel *d_label; - QwtThermo *d_thermo; -}; - -class SysInfo : public QFrame -{ -public: - SysInfo( QWidget *parent = NULL ): - QFrame( parent ) - { - QGroupBox *memBox = new QGroupBox( "Memory Usage", this ); - memBox->setFont( QFont( "Helvetica", 10 ) ); - - QVBoxLayout *memLayout = new QVBoxLayout( memBox ); - memLayout->setMargin( 15 ); - memLayout->setSpacing( 5 ); - - Qt::Orientation o = Qt::Horizontal; - memLayout->addWidget( new ValueBar( o, "Used", memBox, 57 ) ); - memLayout->addWidget( new ValueBar( o, "Shared", memBox, 17 ) ); - memLayout->addWidget( new ValueBar( o, "Cache", memBox, 30 ) ); - memLayout->addWidget( new ValueBar( o, "Buffers", memBox, 22 ) ); - memLayout->addWidget( new ValueBar( o, "Swap Used", memBox, 57 ) ); - memLayout->addWidget( new QWidget( memBox ), 10 ); // spacer - - QGroupBox *cpuBox = new QGroupBox( "Cpu Usage", this ); - cpuBox->setFont( QFont( "Helvetica", 10 ) ); - - QHBoxLayout *cpuLayout = new QHBoxLayout( cpuBox ); - cpuLayout->setMargin( 15 ); - cpuLayout->setSpacing( 5 ); - - o = Qt::Vertical; - cpuLayout->addWidget( new ValueBar( o, "User", cpuBox, 57 ) ); - cpuLayout->addWidget( new ValueBar( o, "Total", cpuBox, 73 ) ); - cpuLayout->addWidget( new ValueBar( o, "System", cpuBox, 16 ) ); - cpuLayout->addWidget( new ValueBar( o, "Idle", cpuBox, 27 ) ); - - QHBoxLayout *layout = new QHBoxLayout( this ); - layout->setMargin( 10 ); - layout->addWidget( memBox, 10 ); - layout->addWidget( cpuBox, 0 ); - } -}; - -int main ( int argc, char **argv ) -{ - QApplication a( argc, argv ); - - SysInfo info; - info.resize( info.sizeHint().expandedTo( QSize( 600, 400 ) ) ); - info.show(); - - int rv = a.exec(); - return rv; -} diff --git a/qwt/examples/sysinfo/sysinfo.pro b/qwt/examples/sysinfo/sysinfo.pro deleted file mode 100644 index c520f6de8..000000000 --- a/qwt/examples/sysinfo/sysinfo.pro +++ /dev/null @@ -1,15 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = sysinfo - -SOURCES = \ - sysinfo.cpp diff --git a/qwt/examples/tvplot/main.cpp b/qwt/examples/tvplot/main.cpp deleted file mode 100644 index 0359bc11b..000000000 --- a/qwt/examples/tvplot/main.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include "tvplot.h" - -int main(int argc, char **argv) -{ - QApplication a(argc, argv); - - TVPlot plot; - - plot.resize(600,400); - plot.show(); - - return a.exec(); -} diff --git a/qwt/examples/tvplot/tvplot.cpp b/qwt/examples/tvplot/tvplot.cpp deleted file mode 100644 index 7033072cf..000000000 --- a/qwt/examples/tvplot/tvplot.cpp +++ /dev/null @@ -1,124 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "tvplot.h" - -class Histogram: public QwtPlotHistogram -{ -public: - Histogram(const QString &, const QColor &); - - void setColor(const QColor &); - void setValues(uint numValues, const double *); -}; - -Histogram::Histogram(const QString &title, const QColor &symbolColor): - QwtPlotHistogram(title) -{ - setStyle(QwtPlotHistogram::Columns); - - setColor(symbolColor); -} - -void Histogram::setColor(const QColor &symbolColor) -{ - QColor color = symbolColor; - color.setAlpha(180); - - setPen(QPen(Qt::black)); - setBrush(QBrush(color)); - - QwtColumnSymbol *symbol = new QwtColumnSymbol(QwtColumnSymbol::Box); - symbol->setFrameStyle(QwtColumnSymbol::Raised); - symbol->setLineWidth(2); - symbol->setPalette(QPalette(color)); - setSymbol(symbol); -} - -void Histogram::setValues(uint numValues, const double *values) -{ - QVector samples(numValues); - for ( uint i = 0; i < numValues; i++ ) - { - QwtInterval interval(double(i), i + 1.0); - interval.setBorderFlags(QwtInterval::ExcludeMaximum); - - samples[i] = QwtIntervalSample(values[i], interval); - } - - setData(new QwtIntervalSeriesData(samples)); -} - -TVPlot::TVPlot(QWidget *parent): - QwtPlot(parent) -{ - setTitle("Watching TV during a weekend"); - - setCanvasBackground(QColor(Qt::gray)); - plotLayout()->setAlignCanvasToScales(true); - - setAxisTitle(QwtPlot::yLeft, "Number of People"); - setAxisTitle(QwtPlot::xBottom, "Number of Hours"); - - QwtLegend *legend = new QwtLegend; - legend->setItemMode(QwtLegend::CheckableItem); - insertLegend(legend, QwtPlot::RightLegend); - - populate(); - - connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)), - SLOT(showItem(QwtPlotItem *, bool))); - - replot(); // creating the legend items - - QwtPlotItemList items = itemList(QwtPlotItem::Rtti_PlotHistogram); - for ( int i = 0; i < items.size(); i++ ) - { - if ( i == 0 ) - { - QwtLegendItem *legendItem = (QwtLegendItem *)legend->find(items[i]); - if ( legendItem ) - legendItem->setChecked(true); - items[i]->setVisible(true); - } - else - items[i]->setVisible(false); - } - - setAutoReplot(true); -} - -void TVPlot::populate() -{ - QwtPlotGrid *grid = new QwtPlotGrid; - grid->enableX(false); - grid->enableY(true); - grid->enableXMin(false); - grid->enableYMin(false); - grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine)); - grid->attach(this); - - const double juneValues[] = { 7, 19, 24, 32, 10, 5, 3 }; - const double novemberValues[] = { 4, 15, 22, 34, 13, 8, 4 }; - - Histogram *histogramJune = new Histogram("Summer", Qt::red); - histogramJune->setValues( - sizeof(juneValues) / sizeof(double), juneValues); - histogramJune->attach(this); - - Histogram *histogramNovember = new Histogram("Winter", Qt::blue); - histogramNovember->setValues( - sizeof(novemberValues) / sizeof(double), novemberValues); - histogramNovember->attach(this); -} - -void TVPlot::showItem(QwtPlotItem *item, bool on) -{ - item->setVisible(on); -} diff --git a/qwt/examples/tvplot/tvplot.h b/qwt/examples/tvplot/tvplot.h deleted file mode 100644 index 23128f271..000000000 --- a/qwt/examples/tvplot/tvplot.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _TV_PLOT_H_ - -#include - -class TVPlot: public QwtPlot -{ - Q_OBJECT - -public: - TVPlot(QWidget * = NULL); - -private: - void populate(); - -private Q_SLOTS: - void showItem(QwtPlotItem *, bool on); -}; - -#endif diff --git a/qwt/examples/tvplot/tvplot.pro b/qwt/examples/tvplot/tvplot.pro deleted file mode 100644 index f91401551..000000000 --- a/qwt/examples/tvplot/tvplot.pro +++ /dev/null @@ -1,19 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( $${PWD}/../examples.pri ) - -TARGET = tvplot - -SOURCES = \ - tvplot.cpp \ - main.cpp - -HEADERS = \ - tvplot.h diff --git a/qwt/qwt.prf b/qwt/qwt.prf deleted file mode 100644 index a4ebb2e35..000000000 --- a/qwt/qwt.prf +++ /dev/null @@ -1,44 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include ( ./qwtconfig.pri ) - -contains(QWT_CONFIG, QwtDll) { - - DEFINES *= QWT_DLL -} - -contains(QWT_CONFIG, QwtSvg) { - - QT *= svg -} -else { - - DEFINES *= QWT_NO_SVG -} - -contains(QWT_CONFIG, QwtFramework) { - - INCLUDEPATH *= $${QWT_INSTALL_LIBS}/qwt.framework/Headers - LIBS *= -F$${QWT_INSTALL_LIBS} -} -else { - - INCLUDEPATH *= $${QWT_INSTALL_HEADERS} - LIBS *= -L$${QWT_INSTALL_LIBS} -} - -INCLUDEPATH_QWT = $${INCLUDEPATH} -qtAddLibrary(qwt) - -# we don't want qtAddLibrary to expand the -# include path, with directories, that might -# conflict with other installations of qwt - -INCLUDEPATH = $${INCLUDEPATH_QWT} diff --git a/qwt/qwt.pro b/qwt/qwt.pro deleted file mode 100644 index 17e088652..000000000 --- a/qwt/qwt.pro +++ /dev/null @@ -1,30 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -include( qwtconfig.pri ) - -TEMPLATE = subdirs -CONFIG += ordered - -SUBDIRS = \ - src \ - textengines - -contains(QWT_CONFIG, QwtDesigner ) { - SUBDIRS += designer -} - -contains(QWT_CONFIG, QwtExamples ) { - SUBDIRS += examples -} - -qwtspec.files = qwtconfig.pri qwt.prf -qwtspec.path = $${QWT_INSTALL_FEATURES} - -INSTALLS += qwtspec diff --git a/qwt/qwt.pro.user b/qwt/qwt.pro.user deleted file mode 100644 index 61f39f6b9..000000000 --- a/qwt/qwt.pro.user +++ /dev/null @@ -1,2047 +0,0 @@ - - - - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - System - false - 4 - true - 1 - true - 0 - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - - ProjectExplorer.Project.Target.0 - - Desktop - Desktop - Qt4ProjectManager.Target.DesktopTarget - 0 - 0 - 0 - - ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-macos-generic-mach_o-64bit./usr/bin/gdb - - - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - - - Make - - Qt4ProjectManager.MakeStep - false - - - - 2 - Compiler - - ProjectExplorer.BuildSteps.Build - - - - Make - - Qt4ProjectManager.MakeStep - true - clean - - - 1 - Nettoyer - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Desktop Qt 4.7.4 for GCC (Qt SDK) Debug - - Qt4ProjectManager.Qt4BuildConfiguration - 2 - /Users/grauser/Documents/DEV/Qt/qwt-6.0.1 - 12 - false - - - ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-macos-generic-mach_o-64bit./usr/bin/gdb - - - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - - - Make - - Qt4ProjectManager.MakeStep - false - - - - 2 - Compiler - - ProjectExplorer.BuildSteps.Build - - - - Make - - Qt4ProjectManager.MakeStep - true - clean - - - 1 - Nettoyer - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Desktop Qt 4.7.4 for GCC (Qt SDK) Release - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - /Users/grauser/Documents/DEV/Qt/qwt-6.0.1 - 12 - false - - - ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-macos-generic-mach_o-64bit./usr/bin/gdb - - - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - - - Make - - Qt4ProjectManager.MakeStep - false - - - - 2 - Compiler - - ProjectExplorer.BuildSteps.Build - - - - Make - - Qt4ProjectManager.MakeStep - true - clean - - - 1 - Nettoyer - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Qt dans le PATH Debug - - Qt4ProjectManager.Qt4BuildConfiguration - 2 - /Users/grauser/Documents/DEV/Qt/qwt-6.0.1 - 2 - false - - - ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-macos-generic-mach_o-64bit./usr/bin/gdb - - - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - - - Make - - Qt4ProjectManager.MakeStep - false - - - - 2 - Compiler - - ProjectExplorer.BuildSteps.Build - - - - Make - - Qt4ProjectManager.MakeStep - true - clean - - - 1 - Nettoyer - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Qt dans le PATH Release - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - /Users/grauser/Documents/DEV/Qt/qwt-6.0.1 - 2 - false - - - ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-macos-generic-mach_o-64bit./usr/bin/gdb - - - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - - - Make - - Qt4ProjectManager.MakeStep - false - - - - 2 - Compiler - - ProjectExplorer.BuildSteps.Build - - - - Make - - Qt4ProjectManager.MakeStep - true - clean - - - 1 - Nettoyer - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - 4.7.0 Debug - - Qt4ProjectManager.Qt4BuildConfiguration - 2 - /Users/grauser/Documents/DEV/Qt/qwt-6.0.1 - 8 - false - - - ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-macos-generic-mach_o-64bit./usr/bin/gdb - - - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - - - Make - - Qt4ProjectManager.MakeStep - false - - - - 2 - Compiler - - ProjectExplorer.BuildSteps.Build - - - - Make - - Qt4ProjectManager.MakeStep - true - clean - - - 1 - Nettoyer - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - 4.7.0 Release - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - /Users/grauser/Documents/DEV/Qt/qwt-6.0.1 - 8 - false - - - ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-macos-generic-mach_o-64bit./usr/bin/gdb - - - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - - - Make - - Qt4ProjectManager.MakeStep - false - - - - 2 - Compiler - - ProjectExplorer.BuildSteps.Build - - - - Make - - Qt4ProjectManager.MakeStep - true - clean - - - 1 - Nettoyer - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - 4.6.1 Debug - - Qt4ProjectManager.Qt4BuildConfiguration - 2 - /Users/grauser/Documents/DEV/Qt/qwt-6.0.1 - 4 - false - - - ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-macos-generic-mach_o-64bit./usr/bin/gdb - - - qmake - - QtProjectManager.QMakeBuildStep - false - true - - false - - - Make - - Qt4ProjectManager.MakeStep - false - - - - 2 - Compiler - - ProjectExplorer.BuildSteps.Build - - - - Make - - Qt4ProjectManager.MakeStep - true - clean - - - 1 - Nettoyer - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - 4.6.1 Release - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - /Users/grauser/Documents/DEV/Qt/qwt-6.0.1 - 4 - false - - 8 - - - 0 - Déploiement - - ProjectExplorer.BuildSteps.Deploy - - 1 - Pas de déploiement - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - dials - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/dials/dials.pro - false - false - - - 3768 - true - false - false - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - plotmatrix - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/plotmatrix/plotmatrix.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - spectrogram - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/spectrogram/spectrogram.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - navigation - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/navigation/navigation.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - refreshtest - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/refreshtest/refreshtest.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - bode - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/bode/bode.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - curvdemo2 - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/curvdemo2/curvdemo2.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - oscilloscope - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/oscilloscope/oscilloscope.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - rasterview - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/rasterview/rasterview.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - svgmap - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/svgmap/svgmap.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - radio - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/radio/radio.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - sysinfo - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/sysinfo/sysinfo.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - cpuplot - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/cpuplot/cpuplot.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - curvdemo1 - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/curvdemo1/curvdemo1.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - sinusplot - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/sinusplot/sinusplot.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - sliders - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/sliders/sliders.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - event_filter - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/event_filter/event_filter.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - realtime - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/realtime/realtime.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - friedberg - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/friedberg/friedberg.pro - false - false - - - 3768 - true - false - true - - - true - true - - - false - false - false - false - false - false - false - false - true - true - 0.01 - 0.01 - 10 - 10 - true - true - 25 - 25 - - - true - true - valgrind - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - tvplot - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - examples/tvplot/tvplot.pro - false - false - - - 3768 - true - false - true - - 20 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.EnvironmentId - {aacf4a18-beff-41d4-a574-373b7bf4e503} - - - ProjectExplorer.Project.Updater.FileVersion - 10 - - diff --git a/qwt/qwtbuild.pri b/qwt/qwtbuild.pri deleted file mode 100644 index 8777b51a1..000000000 --- a/qwt/qwtbuild.pri +++ /dev/null @@ -1,69 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -###################################################################### -# qmake internal options -###################################################################### - -CONFIG += qt -CONFIG += warn_on -CONFIG += no_keywords -CONFIG += silent - -###################################################################### -# release/debug mode -###################################################################### - -win32 { - # On Windows you can't mix release and debug libraries. - # The designer is built in release mode. If you like to use it - # you need a release version. For your own application development you - # might need a debug version. - # Enable debug_and_release + build_all if you want to build both. - - CONFIG += debug_and_release - CONFIG += build_all -} -else { - - CONFIG += release - - VER_MAJ = $${QWT_VER_MAJ} - VER_MIN = $${QWT_VER_MIN} - VER_PAT = $${QWT_VER_PAT} - VERSION = $${QWT_VERSION} -} - -linux-g++ { - # CONFIG += separate_debug_info -} - -###################################################################### -# paths for building qwt -###################################################################### - -MOC_DIR = moc -RCC_DIR = resources -!debug_and_release { - OBJECTS_DIR = obj -} - -unix { - - exists( $${QMAKE_LIBDIR_QT}/libqwt.* ) { - - # On some Linux distributions the Qwt libraries are installed - # in the same directory as the Qt libraries. Unfortunately - # qmake always adds QMAKE_LIBDIR_QT at the beginning of the - # linker path, so that the installed libraries will be - # used instead of the local ones. - - error( "local build will conflict with $${QMAKE_LIBDIR_QT}/libqwt.*" ) - } -} diff --git a/qwt/qwtconfig.pri.in b/qwt/qwtconfig.pri.in deleted file mode 100644 index d584ebfe4..000000000 --- a/qwt/qwtconfig.pri.in +++ /dev/null @@ -1,124 +0,0 @@ -################################################################ -# Qwt Widget Library -# Copyright (C) 1997 Josef Wilgen -# Copyright (C) 2002 Uwe Rathmann -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the Qwt License, Version 1.0 -################################################################ - -QWT_VER_MAJ = 6 -QWT_VER_MIN = 0 -QWT_VER_PAT = 1 -QWT_VERSION = $${QWT_VER_MAJ}.$${QWT_VER_MIN}.$${QWT_VER_PAT} - -###################################################################### -# Install paths -###################################################################### - -QWT_INSTALL_PREFIX = $$[QT_INSTALL_PREFIX] - -unix { - QWT_INSTALL_PREFIX = /usr/local/qwt-$$QWT_VERSION -} - -win32 { - QWT_INSTALL_PREFIX = C:/Qwt-$$QWT_VERSION -} - -QWT_INSTALL_DOCS = $${QWT_INSTALL_PREFIX}/doc -QWT_INSTALL_HEADERS = $${QWT_INSTALL_PREFIX}/include -QWT_INSTALL_LIBS = $${QWT_INSTALL_PREFIX}/lib - -###################################################################### -# Designer plugin -###################################################################### - -QWT_INSTALL_PLUGINS = $${QWT_INSTALL_PREFIX}/plugins/designer -# QWT_INSTALL_PLUGINS = $${QT_INSTALL_PREFIX}/plugins/designer - -###################################################################### -# Features -# When building a Qwt application with qmake you might want to load -# the compiler/linker flags, that are required to build a Qwt application -# from qwt.prf. Therefore all you need to do is to add "CONFIG += qwt" -# to your project file and take care, that qwt.prf can be found by qmake. -# ( see http://doc.trolltech.com/4.7/qmake-advanced-usage.html#adding-new-configuration-features ) -# I recommend not to install the Qwt features together with the -# Qt features, because you will have to reinstall the Qwt features, -# with every Qt upgrade. -###################################################################### - -QWT_INSTALL_FEATURES = $${QWT_INSTALL_PREFIX}/features -# QWT_INSTALL_FEATURES = $${QT_INSTALL_PREFIX}/features - -###################################################################### -# Build the static/shared libraries. -# If QwtDll is enabled, a shared library is built, otherwise -# it will be a static library. -###################################################################### - -#QWT_CONFIG += QwtDll - -###################################################################### -# QwtPlot enables all classes, that are needed to use the QwtPlot -# widget. -###################################################################### - -QWT_CONFIG += QwtPlot - -###################################################################### -# QwtWidgets enables all classes, that are needed to use the all other -# widgets (sliders, dials, ...), beside QwtPlot. -###################################################################### - -QWT_CONFIG += QwtWidgets - -###################################################################### -# If you want to display svg images on the plot canvas, or -# export a plot to a SVG document -###################################################################### - -QWT_CONFIG += QwtSvg - -###################################################################### -# You can use the MathML renderer of the Qt solutions package to -# enable MathML support in Qwt. Because of license implications -# the ( modified ) code of the MML Widget solution is included and -# linked together with the QwtMathMLTextEngine into an own library. -# To use it you will have to add "CONFIG += qwtmathml" -# to your qmake project file. -###################################################################### - -QWT_CONFIG += QwtMathML - -###################################################################### -# If you want to build the Qwt designer plugin, -# enable the line below. -# Otherwise you have to build it from the designer directory. -###################################################################### - -# QWT_CONFIG += QwtDesigner - -###################################################################### -# If you want to auto build the examples, enable the line below -# Otherwise you have to build them from the examples directory. -###################################################################### - -# QWT_CONFIG += QwtExamples - -###################################################################### -# Add GoldenCheetah patched plot -###################################################################### - -QWT_CONFIG += GoldenCheetahPatch - -###################################################################### -# When Qt has been built as framework qmake ( qtAddLibrary ) wants -# to link frameworks instead of regular libs -###################################################################### - -macx:CONFIG(qt_framework, qt_framework|qt_no_framework) { - - QWT_CONFIG += QwtFramework -} diff --git a/qwt/src/qwt.h b/qwt/src/qwt.h deleted file mode 100644 index 37494933e..000000000 --- a/qwt/src/qwt.h +++ /dev/null @@ -1,22 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_H -#define QWT_H - -#include "qwt_global.h" - -/*! - Some constants for use within Qwt. -*/ -namespace Qwt -{ -}; - -#endif diff --git a/qwt/src/qwt_abstract_scale.cpp b/qwt/src/qwt_abstract_scale.cpp deleted file mode 100644 index e44776e6e..000000000 --- a/qwt/src/qwt_abstract_scale.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_abstract_scale.h" -#include "qwt_scale_engine.h" -#include "qwt_scale_draw.h" -#include "qwt_scale_div.h" -#include "qwt_scale_map.h" -#include "qwt_interval.h" - -class QwtAbstractScale::PrivateData -{ -public: - PrivateData(): - maxMajor( 5 ), - maxMinor( 3 ), - stepSize( 0.0 ), - autoScale( true ) - { - scaleEngine = new QwtLinearScaleEngine; - scaleDraw = new QwtScaleDraw(); - } - - ~PrivateData() - { - delete scaleEngine; - delete scaleDraw; - } - - QwtScaleEngine *scaleEngine; - QwtAbstractScaleDraw *scaleDraw; - - int maxMajor; - int maxMinor; - double stepSize; - - bool autoScale; -}; - -/*! - Constructor - - Creates a default QwtScaleDraw and a QwtLinearScaleEngine. - Autoscaling is enabled, and the stepSize is initialized by 0.0. -*/ - -QwtAbstractScale::QwtAbstractScale() -{ - d_data = new PrivateData; - rescale( 0.0, 100.0 ); -} - -//! Destructor -QwtAbstractScale::~QwtAbstractScale() -{ - delete d_data; -} - -/*! - \brief Specify a scale. - - Disable autoscaling and define a scale by an interval and a step size - - \param vmin lower limit of the scale interval - \param vmax upper limit of the scale interval - \param stepSize major step size - \sa setAutoScale() -*/ -void QwtAbstractScale::setScale( double vmin, double vmax, double stepSize ) -{ - d_data->autoScale = false; - d_data->stepSize = stepSize; - - rescale( vmin, vmax, stepSize ); -} - -/*! - \brief Specify a scale. - - Disable autoscaling and define a scale by an interval and a step size - - \param interval Interval - \param stepSize major step size - \sa setAutoScale() -*/ -void QwtAbstractScale::setScale( const QwtInterval &interval, double stepSize ) -{ - setScale( interval.minValue(), interval.maxValue(), stepSize ); -} - - -/*! - \brief Specify a scale. - - Disable autoscaling and define a scale by a scale division - - \param scaleDiv Scale division - \sa setAutoScale() -*/ -void QwtAbstractScale::setScale( const QwtScaleDiv &scaleDiv ) -{ - d_data->autoScale = false; - - if ( scaleDiv != d_data->scaleDraw->scaleDiv() ) - { - d_data->scaleDraw->setScaleDiv( scaleDiv ); - scaleChange(); - } -} - -/*! - Recalculate the scale division and update the scale draw. - - \param vmin Lower limit of the scale interval - \param vmax Upper limit of the scale interval - \param stepSize Major step size - - \sa scaleChange() -*/ -void QwtAbstractScale::rescale( double vmin, double vmax, double stepSize ) -{ - const QwtScaleDiv scaleDiv = d_data->scaleEngine->divideScale( - vmin, vmax, d_data->maxMajor, d_data->maxMinor, stepSize ); - - if ( scaleDiv != d_data->scaleDraw->scaleDiv() ) - { - d_data->scaleDraw->setTransformation( - d_data->scaleEngine->transformation() ); - d_data->scaleDraw->setScaleDiv( scaleDiv ); - scaleChange(); - } -} - -/*! - \brief Advise the widget to control the scale range internally. - - Autoscaling is on by default. - \sa setScale(), autoScale() -*/ -void QwtAbstractScale::setAutoScale() -{ - if ( !d_data->autoScale ) - { - d_data->autoScale = true; - scaleChange(); - } -} - -/*! - \return \c true if autoscaling is enabled -*/ -bool QwtAbstractScale::autoScale() const -{ - return d_data->autoScale; -} - -/*! - \brief Set the maximum number of major tick intervals. - - The scale's major ticks are calculated automatically such that - the number of major intervals does not exceed ticks. - The default value is 5. - \param ticks maximal number of major ticks. - \sa QwtAbstractScaleDraw -*/ -void QwtAbstractScale::setScaleMaxMajor( int ticks ) -{ - if ( ticks != d_data->maxMajor ) - { - d_data->maxMajor = ticks; - updateScaleDraw(); - } -} - -/*! - \brief Set the maximum number of minor tick intervals - - The scale's minor ticks are calculated automatically such that - the number of minor intervals does not exceed ticks. - The default value is 3. - \param ticks - \sa QwtAbstractScaleDraw -*/ -void QwtAbstractScale::setScaleMaxMinor( int ticks ) -{ - if ( ticks != d_data->maxMinor ) - { - d_data->maxMinor = ticks; - updateScaleDraw(); - } -} - -/*! - \return Max. number of minor tick intervals - The default value is 3. -*/ -int QwtAbstractScale::scaleMaxMinor() const -{ - return d_data->maxMinor; -} - -/*! - \return Max. number of major tick intervals - The default value is 5. -*/ -int QwtAbstractScale::scaleMaxMajor() const -{ - return d_data->maxMajor; -} - -/*! - \brief Set a scale draw - - scaleDraw has to be created with new and will be deleted in - ~QwtAbstractScale or the next call of setAbstractScaleDraw. -*/ -void QwtAbstractScale::setAbstractScaleDraw( QwtAbstractScaleDraw *scaleDraw ) -{ - if ( scaleDraw == NULL || scaleDraw == d_data->scaleDraw ) - return; - - if ( d_data->scaleDraw != NULL ) - scaleDraw->setScaleDiv( d_data->scaleDraw->scaleDiv() ); - - delete d_data->scaleDraw; - d_data->scaleDraw = scaleDraw; -} - -/*! - \return Scale draw - \sa setAbstractScaleDraw() -*/ -QwtAbstractScaleDraw *QwtAbstractScale::abstractScaleDraw() -{ - return d_data->scaleDraw; -} - -/*! - \return Scale draw - \sa setAbstractScaleDraw() -*/ -const QwtAbstractScaleDraw *QwtAbstractScale::abstractScaleDraw() const -{ - return d_data->scaleDraw; -} - -void QwtAbstractScale::updateScaleDraw() -{ - rescale( d_data->scaleDraw->scaleDiv().lowerBound(), - d_data->scaleDraw->scaleDiv().upperBound(), d_data->stepSize ); -} - -/*! - \brief Set a scale engine - - The scale engine is responsible for calculating the scale division, - and in case of auto scaling how to align the scale. - - scaleEngine has to be created with new and will be deleted in - ~QwtAbstractScale or the next call of setScaleEngine. -*/ -void QwtAbstractScale::setScaleEngine( QwtScaleEngine *scaleEngine ) -{ - if ( scaleEngine != NULL && scaleEngine != d_data->scaleEngine ) - { - delete d_data->scaleEngine; - d_data->scaleEngine = scaleEngine; - } -} - -/*! - \return Scale engine - \sa setScaleEngine() -*/ -const QwtScaleEngine *QwtAbstractScale::scaleEngine() const -{ - return d_data->scaleEngine; -} - -/*! - \return Scale engine - \sa setScaleEngine() -*/ -QwtScaleEngine *QwtAbstractScale::scaleEngine() -{ - return d_data->scaleEngine; -} - -/*! - \brief Notify changed scale - - Dummy empty implementation, intended to be overloaded by derived classes -*/ -void QwtAbstractScale::scaleChange() -{ -} - -/*! - \return abstractScaleDraw()->scaleMap() -*/ -const QwtScaleMap &QwtAbstractScale::scaleMap() const -{ - return d_data->scaleDraw->scaleMap(); -} diff --git a/qwt/src/qwt_abstract_scale.h b/qwt/src/qwt_abstract_scale.h deleted file mode 100644 index 670d2281c..000000000 --- a/qwt/src/qwt_abstract_scale.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_ABSTRACT_SCALE_H -#define QWT_ABSTRACT_SCALE_H - -#include "qwt_global.h" - -class QwtScaleEngine; -class QwtAbstractScaleDraw; -class QwtScaleDiv; -class QwtScaleMap; -class QwtInterval; - -/*! - \brief An abstract base class for classes containing a scale - - QwtAbstractScale is used to provide classes with a QwtScaleDraw, - and a QwtScaleDiv. The QwtScaleDiv might be set explicitely - or calculated by a QwtScaleEngine. -*/ - -class QWT_EXPORT QwtAbstractScale -{ -public: - QwtAbstractScale(); - virtual ~QwtAbstractScale(); - - void setScale( double vmin, double vmax, double step = 0.0 ); - void setScale( const QwtInterval &, double step = 0.0 ); - void setScale( const QwtScaleDiv & ); - - void setAutoScale(); - bool autoScale() const; - - void setScaleMaxMajor( int ticks ); - int scaleMaxMinor() const; - - void setScaleMaxMinor( int ticks ); - int scaleMaxMajor() const; - - void setScaleEngine( QwtScaleEngine * ); - const QwtScaleEngine *scaleEngine() const; - QwtScaleEngine *scaleEngine(); - - const QwtScaleMap &scaleMap() const; - -protected: - void rescale( double vmin, double vmax, double step = 0.0 ); - - void setAbstractScaleDraw( QwtAbstractScaleDraw * ); - const QwtAbstractScaleDraw *abstractScaleDraw() const; - QwtAbstractScaleDraw *abstractScaleDraw(); - - virtual void scaleChange(); - -private: - void updateScaleDraw(); - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_abstract_scale_draw.cpp b/qwt/src/qwt_abstract_scale_draw.cpp deleted file mode 100644 index c29e226a0..000000000 --- a/qwt/src/qwt_abstract_scale_draw.cpp +++ /dev/null @@ -1,412 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_abstract_scale_draw.h" -#include "qwt_math.h" -#include "qwt_text.h" -#include "qwt_painter.h" -#include "qwt_scale_map.h" -#include -#include -#include -#include - -class QwtAbstractScaleDraw::PrivateData -{ -public: - PrivateData(): - spacing( 4.0 ), - penWidth( 0 ), - minExtent( 0.0 ) - { - components = QwtAbstractScaleDraw::Backbone - | QwtAbstractScaleDraw::Ticks - | QwtAbstractScaleDraw::Labels; - - tickLength[QwtScaleDiv::MinorTick] = 4.0; - tickLength[QwtScaleDiv::MediumTick] = 6.0; - tickLength[QwtScaleDiv::MajorTick] = 8.0; - } - - ScaleComponents components; - - QwtScaleMap map; - QwtScaleDiv scldiv; - - double spacing; - double tickLength[QwtScaleDiv::NTickTypes]; - int penWidth; - - double minExtent; - - QMap labelCache; -}; - -/*! - \brief Constructor - - The range of the scale is initialized to [0, 100], - The spacing (distance between ticks and labels) is - set to 4, the tick lengths are set to 4,6 and 8 pixels -*/ -QwtAbstractScaleDraw::QwtAbstractScaleDraw() -{ - d_data = new QwtAbstractScaleDraw::PrivateData; -} - -//! Destructor -QwtAbstractScaleDraw::~QwtAbstractScaleDraw() -{ - delete d_data; -} - -/*! - En/Disable a component of the scale - - \param component Scale component - \param enable On/Off - - \sa hasComponent() -*/ -void QwtAbstractScaleDraw::enableComponent( - ScaleComponent component, bool enable ) -{ - if ( enable ) - d_data->components |= component; - else - d_data->components &= ~component; -} - -/*! - Check if a component is enabled - \sa enableComponent() -*/ -bool QwtAbstractScaleDraw::hasComponent( ScaleComponent component ) const -{ - return ( d_data->components & component ); -} - -/*! - Change the scale division - \param sd New scale division -*/ -void QwtAbstractScaleDraw::setScaleDiv( const QwtScaleDiv &sd ) -{ - d_data->scldiv = sd; - d_data->map.setScaleInterval( sd.lowerBound(), sd.upperBound() ); - d_data->labelCache.clear(); -} - -/*! - Change the transformation of the scale - \param transformation New scale transformation -*/ -void QwtAbstractScaleDraw::setTransformation( - QwtScaleTransformation *transformation ) -{ - d_data->map.setTransformation( transformation ); -} - -//! \return Map how to translate between scale and pixel values -const QwtScaleMap &QwtAbstractScaleDraw::scaleMap() const -{ - return d_data->map; -} - -//! \return Map how to translate between scale and pixel values -QwtScaleMap &QwtAbstractScaleDraw::scaleMap() -{ - return d_data->map; -} - -//! \return scale division -const QwtScaleDiv& QwtAbstractScaleDraw::scaleDiv() const -{ - return d_data->scldiv; -} - -/*! - \brief Specify the width of the scale pen - \param width Pen width - \sa penWidth() -*/ -void QwtAbstractScaleDraw::setPenWidth( int width ) -{ - if ( width < 0 ) - width = 0; - - if ( width != d_data->penWidth ) - d_data->penWidth = width; -} - -/*! - \return Scale pen width - \sa setPenWidth() -*/ -int QwtAbstractScaleDraw::penWidth() const -{ - return d_data->penWidth; -} - -/*! - \brief Draw the scale - - \param painter The painter - - \param palette Palette, text color is used for the labels, - foreground color for ticks and backbone -*/ -void QwtAbstractScaleDraw::draw( QPainter *painter, - const QPalette& palette ) const -{ - painter->save(); - - QPen pen = painter->pen(); - pen.setWidth( d_data->penWidth ); - pen.setCosmetic( false ); - painter->setPen( pen ); - - if ( hasComponent( QwtAbstractScaleDraw::Labels ) ) - { - painter->save(); - painter->setPen( palette.color( QPalette::Text ) ); // ignore pen style - - const QList &majorTicks = - d_data->scldiv.ticks( QwtScaleDiv::MajorTick ); - - for ( int i = 0; i < majorTicks.count(); i++ ) - { - const double v = majorTicks[i]; - if ( d_data->scldiv.contains( v ) ) - drawLabel( painter, v ); - } - - painter->restore(); - } - - if ( hasComponent( QwtAbstractScaleDraw::Ticks ) ) - { - painter->save(); - - QPen pen = painter->pen(); - pen.setColor( palette.color( QPalette::WindowText ) ); - pen.setCapStyle( Qt::FlatCap ); - - painter->setPen( pen ); - - for ( int tickType = QwtScaleDiv::MinorTick; - tickType < QwtScaleDiv::NTickTypes; tickType++ ) - { - const QList &ticks = d_data->scldiv.ticks( tickType ); - for ( int i = 0; i < ticks.count(); i++ ) - { - const double v = ticks[i]; - if ( d_data->scldiv.contains( v ) ) - drawTick( painter, v, d_data->tickLength[tickType] ); - } - } - - painter->restore(); - } - - if ( hasComponent( QwtAbstractScaleDraw::Backbone ) ) - { - painter->save(); - - QPen pen = painter->pen(); - pen.setColor( palette.color( QPalette::WindowText ) ); - pen.setCapStyle( Qt::FlatCap ); - - painter->setPen( pen ); - - drawBackbone( painter ); - - painter->restore(); - } - - painter->restore(); -} - -/*! - \brief Set the spacing between tick and labels - - The spacing is the distance between ticks and labels. - The default spacing is 4 pixels. - - \param spacing Spacing - - \sa spacing() -*/ -void QwtAbstractScaleDraw::setSpacing( double spacing ) -{ - if ( spacing < 0 ) - spacing = 0; - - d_data->spacing = spacing; -} - -/*! - \brief Get the spacing - - The spacing is the distance between ticks and labels. - The default spacing is 4 pixels. - - \sa setSpacing() -*/ -double QwtAbstractScaleDraw::spacing() const -{ - return d_data->spacing; -} - -/*! - \brief Set a minimum for the extent - - The extent is calculated from the coomponents of the - scale draw. In situations, where the labels are - changing and the layout depends on the extent (f.e scrolling - a scale), setting an upper limit as minimum extent will - avoid jumps of the layout. - - \param minExtent Minimum extent - - \sa extent(), minimumExtent() -*/ -void QwtAbstractScaleDraw::setMinimumExtent( double minExtent ) -{ - if ( minExtent < 0.0 ) - minExtent = 0.0; - - d_data->minExtent = minExtent; -} - -/*! - Get the minimum extent - \sa extent(), setMinimumExtent() -*/ -double QwtAbstractScaleDraw::minimumExtent() const -{ - return d_data->minExtent; -} - -/*! - Set the length of the ticks - - \param tickType Tick type - \param length New length - - \warning the length is limited to [0..1000] -*/ -void QwtAbstractScaleDraw::setTickLength( - QwtScaleDiv::TickType tickType, double length ) -{ - if ( tickType < QwtScaleDiv::MinorTick || - tickType > QwtScaleDiv::MajorTick ) - { - return; - } - - if ( length < 0.0 ) - length = 0.0; - - const double maxTickLen = 1000.0; - if ( length > maxTickLen ) - length = maxTickLen; - - d_data->tickLength[tickType] = length; -} - -/*! - Return the length of the ticks - - \sa setTickLength(), maxTickLength() -*/ -double QwtAbstractScaleDraw::tickLength( QwtScaleDiv::TickType tickType ) const -{ - if ( tickType < QwtScaleDiv::MinorTick || - tickType > QwtScaleDiv::MajorTick ) - { - return 0; - } - - return d_data->tickLength[tickType]; -} - -/*! - \return Length of the longest tick - - Useful for layout calculations - \sa tickLength(), setTickLength() -*/ -double QwtAbstractScaleDraw::maxTickLength() const -{ - double length = 0.0; - for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ ) - length = qMax( length, d_data->tickLength[i] ); - - return length; -} - -/*! - \brief Convert a value into its representing label - - The value is converted to a plain text using - QLocale::system().toString(value). - This method is often overloaded by applications to have individual - labels. - - \param value Value - \return Label string. -*/ -QwtText QwtAbstractScaleDraw::label( double value ) const -{ - return QLocale().toString( value ); -} - -/*! - \brief Convert a value into its representing label and cache it. - - The conversion between value and label is called very often - in the layout and painting code. Unfortunately the - calculation of the label sizes might be slow (really slow - for rich text in Qt4), so it's necessary to cache the labels. - - \param font Font - \param value Value - - \return Tick label -*/ -const QwtText &QwtAbstractScaleDraw::tickLabel( - const QFont &font, double value ) const -{ - QMap::const_iterator it = d_data->labelCache.find( value ); - if ( it == d_data->labelCache.end() ) - { - QwtText lbl = label( value ); - lbl.setRenderFlags( 0 ); - lbl.setLayoutAttribute( QwtText::MinimumLayout ); - - ( void )lbl.textSize( font ); // initialize the internal cache - - it = d_data->labelCache.insert( value, lbl ); - } - - return ( *it ); -} - -/*! - Invalidate the cache used by QwtAbstractScaleDraw::tickLabel - - The cache is invalidated, when a new QwtScaleDiv is set. If - the labels need to be changed. while the same QwtScaleDiv is set, - invalidateCache() needs to be called manually. -*/ -void QwtAbstractScaleDraw::invalidateCache() -{ - d_data->labelCache.clear(); -} diff --git a/qwt/src/qwt_abstract_scale_draw.h b/qwt/src/qwt_abstract_scale_draw.h deleted file mode 100644 index 1dd64c03b..000000000 --- a/qwt/src/qwt_abstract_scale_draw.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_ABSTRACT_SCALE_DRAW_H -#define QWT_ABSTRACT_SCALE_DRAW_H - -#include "qwt_global.h" -#include "qwt_scale_div.h" -#include "qwt_text.h" - -class QPalette; -class QPainter; -class QFont; -class QwtScaleTransformation; -class QwtScaleMap; - -/*! - \brief A abstract base class for drawing scales - - QwtAbstractScaleDraw can be used to draw linear or logarithmic scales. - - After a scale division has been specified as a QwtScaleDiv object - using QwtAbstractScaleDraw::setScaleDiv(const QwtScaleDiv &s), - the scale can be drawn with the QwtAbstractScaleDraw::draw() member. -*/ -class QWT_EXPORT QwtAbstractScaleDraw -{ -public: - - /*! - Components of a scale - \sa enableComponent(), hasComponent - */ - enum ScaleComponent - { - //! Backbone = the line where the ticks are located - Backbone = 0x01, - - //! Ticks - Ticks = 0x02, - - //! Labels - Labels = 0x04 - }; - - //! Scale components - typedef QFlags ScaleComponents; - - QwtAbstractScaleDraw(); - virtual ~QwtAbstractScaleDraw(); - - void setScaleDiv( const QwtScaleDiv &s ); - const QwtScaleDiv& scaleDiv() const; - - void setTransformation( QwtScaleTransformation * ); - const QwtScaleMap &scaleMap() const; - QwtScaleMap &scaleMap(); - - void enableComponent( ScaleComponent, bool enable = true ); - bool hasComponent( ScaleComponent ) const; - - void setTickLength( QwtScaleDiv::TickType, double length ); - double tickLength( QwtScaleDiv::TickType ) const; - double maxTickLength() const; - - void setSpacing( double margin ); - double spacing() const; - - void setPenWidth( int width ); - int penWidth() const; - - virtual void draw( QPainter *, const QPalette & ) const; - - virtual QwtText label( double ) const; - - /*! - Calculate the extent - - The extent is the distcance from the baseline to the outermost - pixel of the scale draw in opposite to its orientation. - It is at least minimumExtent() pixels. - - \sa setMinimumExtent(), minimumExtent() - */ - virtual double extent( const QFont & ) const = 0; - - void setMinimumExtent( double ); - double minimumExtent() const; - -protected: - /*! - Draw a tick - - \param painter Painter - \param value Value of the tick - \param len Lenght of the tick - - \sa drawBackbone(), drawLabel() - */ - virtual void drawTick( QPainter *painter, double value, double len ) const = 0; - - /*! - Draws the baseline of the scale - \param painter Painter - - \sa drawTick(), drawLabel() - */ - virtual void drawBackbone( QPainter *painter ) const = 0; - - /*! - Draws the label for a major scale tick - - \param painter Painter - \param value Value - - \sa drawTick(), drawBackbone() - */ - virtual void drawLabel( QPainter *painter, double value ) const = 0; - - void invalidateCache(); - const QwtText &tickLabel( const QFont &, double value ) const; - -private: - QwtAbstractScaleDraw( const QwtAbstractScaleDraw & ); - QwtAbstractScaleDraw &operator=( const QwtAbstractScaleDraw & ); - - class PrivateData; - PrivateData *d_data; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtAbstractScaleDraw::ScaleComponents ) - -#endif diff --git a/qwt/src/qwt_abstract_slider.cpp b/qwt/src/qwt_abstract_slider.cpp deleted file mode 100644 index a2599af1b..000000000 --- a/qwt/src/qwt_abstract_slider.cpp +++ /dev/null @@ -1,597 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_abstract_slider.h" -#include "qwt_math.h" -#include -#include - -#if QT_VERSION < 0x040601 -#define qFabs(x) ::fabs(x) -#define qExp(x) ::exp(x) -#endif - -class QwtAbstractSlider::PrivateData -{ -public: - PrivateData(): - scrollMode( QwtAbstractSlider::ScrNone ), - mouseOffset( 0.0 ), - tracking( true ), - tmrID( 0 ), - updTime( 150 ), - mass( 0.0 ), - readOnly( false ) - { - } - - QwtAbstractSlider::ScrollMode scrollMode; - double mouseOffset; - int direction; - int tracking; - - int tmrID; - int updTime; - int timerTick; - QTime time; - double speed; - double mass; - Qt::Orientation orientation; - bool readOnly; -}; - -/*! - \brief Constructor - - \param orientation Orientation - \param parent Parent widget -*/ -QwtAbstractSlider::QwtAbstractSlider( - Qt::Orientation orientation, QWidget *parent ): - QWidget( parent, NULL ) -{ - d_data = new QwtAbstractSlider::PrivateData; - d_data->orientation = orientation; - - setFocusPolicy( Qt::TabFocus ); -} - -//! Destructor -QwtAbstractSlider::~QwtAbstractSlider() -{ - if ( d_data->tmrID ) - killTimer( d_data->tmrID ); - - delete d_data; -} - -/*! - En/Disable read only mode - - In read only mode the slider can't be controlled by mouse - or keyboard. - - \param readOnly Enables in case of true - \sa isReadOnly() -*/ -void QwtAbstractSlider::setReadOnly( bool readOnly ) -{ - d_data->readOnly = readOnly; - update(); -} - -/*! - In read only mode the slider can't be controlled by mouse - or keyboard. - - \return true if read only - \sa setReadOnly() -*/ -bool QwtAbstractSlider::isReadOnly() const -{ - return d_data->readOnly; -} - -/*! - \brief Set the orientation. - \param o Orientation. Allowed values are - Qt::Horizontal and Qt::Vertical. -*/ -void QwtAbstractSlider::setOrientation( Qt::Orientation o ) -{ - d_data->orientation = o; -} - -/*! - \return Orientation - \sa setOrientation() -*/ -Qt::Orientation QwtAbstractSlider::orientation() const -{ - return d_data->orientation; -} - -//! Stop updating if automatic scrolling is active - -void QwtAbstractSlider::stopMoving() -{ - if ( d_data->tmrID ) - { - killTimer( d_data->tmrID ); - d_data->tmrID = 0; - } -} - -/*! - \brief Specify the update interval for automatic scrolling - \param t update interval in milliseconds - \sa getScrollMode() -*/ -void QwtAbstractSlider::setUpdateTime( int t ) -{ - if ( t < 50 ) - t = 50; - d_data->updTime = t; -} - - -/*! - Mouse press event handler - \param e Mouse event -*/ -void QwtAbstractSlider::mousePressEvent( QMouseEvent *e ) -{ - if ( isReadOnly() ) - { - e->ignore(); - return; - } - if ( !isValid() ) - return; - - const QPoint &p = e->pos(); - - d_data->timerTick = 0; - - getScrollMode( p, d_data->scrollMode, d_data->direction ); - stopMoving(); - - switch ( d_data->scrollMode ) - { - case ScrPage: - case ScrTimer: - d_data->mouseOffset = 0; - d_data->tmrID = startTimer( qMax( 250, 2 * d_data->updTime ) ); - break; - - case ScrMouse: - d_data->time.start(); - d_data->speed = 0; - d_data->mouseOffset = getValue( p ) - value(); - Q_EMIT sliderPressed(); - break; - - default: - d_data->mouseOffset = 0; - d_data->direction = 0; - break; - } -} - - -//! Emits a valueChanged() signal if necessary -void QwtAbstractSlider::buttonReleased() -{ - if ( ( !d_data->tracking ) || ( value() != prevValue() ) ) - Q_EMIT valueChanged( value() ); -} - - -/*! - Mouse Release Event handler - \param e Mouse event -*/ -void QwtAbstractSlider::mouseReleaseEvent( QMouseEvent *e ) -{ - if ( isReadOnly() ) - { - e->ignore(); - return; - } - if ( !isValid() ) - return; - - const double inc = step(); - - switch ( d_data->scrollMode ) - { - case ScrMouse: - { - setPosition( e->pos() ); - d_data->direction = 0; - d_data->mouseOffset = 0; - if ( d_data->mass > 0.0 ) - { - const int ms = d_data->time.elapsed(); - if ( ( qFabs( d_data->speed ) > 0.0 ) && ( ms < 50 ) ) - d_data->tmrID = startTimer( d_data->updTime ); - } - else - { - d_data->scrollMode = ScrNone; - buttonReleased(); - } - Q_EMIT sliderReleased(); - - break; - } - - case ScrDirect: - { - setPosition( e->pos() ); - d_data->direction = 0; - d_data->mouseOffset = 0; - d_data->scrollMode = ScrNone; - buttonReleased(); - break; - } - - case ScrPage: - { - stopMoving(); - if ( !d_data->timerTick ) - QwtDoubleRange::incPages( d_data->direction ); - d_data->timerTick = 0; - buttonReleased(); - d_data->scrollMode = ScrNone; - break; - } - - case ScrTimer: - { - stopMoving(); - if ( !d_data->timerTick ) - QwtDoubleRange::fitValue( value() + double( d_data->direction ) * inc ); - d_data->timerTick = 0; - buttonReleased(); - d_data->scrollMode = ScrNone; - break; - } - - default: - { - d_data->scrollMode = ScrNone; - buttonReleased(); - } - } -} - - -/*! - Move the slider to a specified point, adjust the value - and emit signals if necessary. -*/ -void QwtAbstractSlider::setPosition( const QPoint &p ) -{ - QwtDoubleRange::fitValue( getValue( p ) - d_data->mouseOffset ); -} - - -/*! - \brief Enables or disables tracking. - - If tracking is enabled, the slider emits a - valueChanged() signal whenever its value - changes (the default behaviour). If tracking - is disabled, the value changed() signal will only - be emitted if:
    -
  • the user releases the mouse - button and the value has changed or -
  • at the end of automatic scrolling.
- Tracking is enabled by default. - \param enable \c true (enable) or \c false (disable) tracking. -*/ -void QwtAbstractSlider::setTracking( bool enable ) -{ - d_data->tracking = enable; -} - -/*! - Mouse Move Event handler - \param e Mouse event -*/ -void QwtAbstractSlider::mouseMoveEvent( QMouseEvent *e ) -{ - if ( isReadOnly() ) - { - e->ignore(); - return; - } - - if ( !isValid() ) - return; - - if ( d_data->scrollMode == ScrMouse ) - { - setPosition( e->pos() ); - if ( d_data->mass > 0.0 ) - { - double ms = double( d_data->time.elapsed() ); - if ( ms < 1.0 ) - ms = 1.0; - d_data->speed = ( exactValue() - exactPrevValue() ) / ms; - d_data->time.start(); - } - if ( value() != prevValue() ) - Q_EMIT sliderMoved( value() ); - } -} - -/*! - Wheel Event handler - \param e Whell event -*/ -void QwtAbstractSlider::wheelEvent( QWheelEvent *e ) -{ - if ( isReadOnly() ) - { - e->ignore(); - return; - } - - if ( !isValid() ) - return; - - QwtAbstractSlider::ScrollMode mode = ScrNone; - int direction = 0; - - // Give derived classes a chance to say ScrNone - getScrollMode( e->pos(), mode, direction ); - if ( mode != QwtAbstractSlider::ScrNone ) - { - // Most mouse types work in steps of 15 degrees, in which case - // the delta value is a multiple of 120 - - const int inc = e->delta() / 120; - QwtDoubleRange::incPages( inc ); - if ( value() != prevValue() ) - Q_EMIT sliderMoved( value() ); - } -} - -/*! - Handles key events - - - Key_Down, KeyLeft\n - Decrement by 1 - - Key_Up, Key_Right\n - Increment by 1 - - \param e Key event - \sa isReadOnly() -*/ -void QwtAbstractSlider::keyPressEvent( QKeyEvent *e ) -{ - if ( isReadOnly() ) - { - e->ignore(); - return; - } - - if ( !isValid() ) - return; - - int increment = 0; - switch ( e->key() ) - { - case Qt::Key_Down: - if ( orientation() == Qt::Vertical ) - increment = -1; - break; - case Qt::Key_Up: - if ( orientation() == Qt::Vertical ) - increment = 1; - break; - case Qt::Key_Left: - if ( orientation() == Qt::Horizontal ) - increment = -1; - break; - case Qt::Key_Right: - if ( orientation() == Qt::Horizontal ) - increment = 1; - break; - default:; - e->ignore(); - } - - if ( increment != 0 ) - { - QwtDoubleRange::incValue( increment ); - if ( value() != prevValue() ) - Q_EMIT sliderMoved( value() ); - } -} - -/*! - Qt timer event - \param e Timer event -*/ -void QwtAbstractSlider::timerEvent( QTimerEvent * ) -{ - const double inc = step(); - - switch ( d_data->scrollMode ) - { - case ScrMouse: - { - if ( d_data->mass > 0.0 ) - { - d_data->speed *= qExp( - double( d_data->updTime ) * 0.001 / d_data->mass ); - const double newval = - exactValue() + d_data->speed * double( d_data->updTime ); - QwtDoubleRange::fitValue( newval ); - // stop if d_data->speed < one step per second - if ( qFabs( d_data->speed ) < 0.001 * qFabs( step() ) ) - { - d_data->speed = 0; - stopMoving(); - buttonReleased(); - } - - } - else - stopMoving(); - break; - } - - case ScrPage: - { - QwtDoubleRange::incPages( d_data->direction ); - if ( !d_data->timerTick ) - { - killTimer( d_data->tmrID ); - d_data->tmrID = startTimer( d_data->updTime ); - } - break; - } - case ScrTimer: - { - QwtDoubleRange::fitValue( value() + double( d_data->direction ) * inc ); - if ( !d_data->timerTick ) - { - killTimer( d_data->tmrID ); - d_data->tmrID = startTimer( d_data->updTime ); - } - break; - } - default: - { - stopMoving(); - break; - } - } - - d_data->timerTick = 1; -} - - -/*! - Notify change of value - - This function can be reimplemented by derived classes - in order to keep track of changes, i.e. repaint the widget. - The default implementation emits a valueChanged() signal - if tracking is enabled. -*/ -void QwtAbstractSlider::valueChange() -{ - if ( d_data->tracking ) - Q_EMIT valueChanged( value() ); -} - -/*! - \brief Set the slider's mass for flywheel effect. - - If the slider's mass is greater then 0, it will continue - to move after the mouse button has been released. Its speed - decreases with time at a rate depending on the slider's mass. - A large mass means that it will continue to move for a - long time. - - Derived widgets may overload this function to make it public. - - \param val New mass in kg - - \bug If the mass is smaller than 1g, it is set to zero. - The maximal mass is limited to 100kg. - \sa mass() -*/ -void QwtAbstractSlider::setMass( double val ) -{ - if ( val < 0.001 ) - d_data->mass = 0.0; - else if ( val > 100.0 ) - d_data->mass = 100.0; - else - d_data->mass = val; -} - -/*! - \return mass - \sa setMass() -*/ -double QwtAbstractSlider::mass() const -{ - return d_data->mass; -} - - -/*! - \brief Move the slider to a specified value - - This function can be used to move the slider to a value - which is not an integer multiple of the step size. - \param val new value - \sa fitValue() -*/ -void QwtAbstractSlider::setValue( double val ) -{ - if ( d_data->scrollMode == ScrMouse ) - stopMoving(); - QwtDoubleRange::setValue( val ); -} - - -/*! - \brief Set the slider's value to the nearest integer multiple - of the step size. - - \param value Value - \sa setValue(), incValue() -*/ -void QwtAbstractSlider::fitValue( double value ) -{ - if ( d_data->scrollMode == ScrMouse ) - stopMoving(); - QwtDoubleRange::fitValue( value ); -} - -/*! - \brief Increment the value by a specified number of steps - \param steps number of steps - \sa setValue() -*/ -void QwtAbstractSlider::incValue( int steps ) -{ - if ( d_data->scrollMode == ScrMouse ) - stopMoving(); - QwtDoubleRange::incValue( steps ); -} - -/*! - \sa mouseOffset() -*/ -void QwtAbstractSlider::setMouseOffset( double offset ) -{ - d_data->mouseOffset = offset; -} - -/*! - \sa setMouseOffset() -*/ -double QwtAbstractSlider::mouseOffset() const -{ - return d_data->mouseOffset; -} - -//! sa ScrollMode -int QwtAbstractSlider::scrollMode() const -{ - return d_data->scrollMode; -} diff --git a/qwt/src/qwt_abstract_slider.h b/qwt/src/qwt_abstract_slider.h deleted file mode 100644 index 3d7599080..000000000 --- a/qwt/src/qwt_abstract_slider.h +++ /dev/null @@ -1,188 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_ABSTRACT_SLIDER_H -#define QWT_ABSTRACT_SLIDER_H - -#include "qwt_global.h" -#include "qwt_double_range.h" -#include - -/*! - \brief An abstract base class for slider widgets - - QwtAbstractSlider is a base class for - slider widgets. It handles mouse events - and updates the slider's value accordingly. Derived classes - only have to implement the getValue() and - getScrollMode() members, and should react to a - valueChange(), which normally requires repainting. -*/ - -class QWT_EXPORT QwtAbstractSlider : public QWidget, public QwtDoubleRange -{ - Q_OBJECT - Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly ) - Q_PROPERTY( bool valid READ isValid WRITE setValid ) - Q_PROPERTY( double mass READ mass WRITE setMass ) - Q_PROPERTY( Qt::Orientation orientation - READ orientation WRITE setOrientation ) - -public: - /*! - Scroll mode - \sa getScrollMode() - */ - enum ScrollMode - { - //! Scrolling switched off. Don't change the value. - ScrNone, - - /*! - Change the value while the user keeps the - button pressed and moves the mouse. - */ - ScrMouse, - - /*! - Automatic scrolling. Increment the value in the specified direction - as long as the user keeps the button pressed. - */ - ScrTimer, - - ScrDirect, - - //! Automatic scrolling. Same as ScrTimer, but increment by page size. - ScrPage - }; - - explicit QwtAbstractSlider( Qt::Orientation, QWidget *parent = NULL ); - virtual ~QwtAbstractSlider(); - - void setUpdateTime( int t ); - void stopMoving(); - void setTracking( bool enable ); - - virtual void setMass( double val ); - virtual double mass() const; - - virtual void setOrientation( Qt::Orientation o ); - Qt::Orientation orientation() const; - - bool isReadOnly() const; - - /* - Wrappers for QwtDblRange::isValid/QwtDblRange::setValid made - to be available as Q_PROPERTY in the designer. - */ - - /*! - \sa QwtDblRange::isValid() - */ - bool isValid() const - { - return QwtDoubleRange::isValid(); - } - - /*! - \param valid true/false - \sa QwtDblRange::isValid() - */ - void setValid( bool valid ) - { - QwtDoubleRange::setValid( valid ); - } - -public Q_SLOTS: - virtual void setValue( double val ); - virtual void fitValue( double val ); - virtual void incValue( int steps ); - - virtual void setReadOnly( bool ); - -Q_SIGNALS: - - /*! - \brief Notify a change of value. - - In the default setting - (tracking enabled), this signal will be emitted every - time the value changes ( see setTracking() ). - \param value new value - */ - void valueChanged( double value ); - - /*! - This signal is emitted when the user presses the - movable part of the slider (start ScrMouse Mode). - */ - void sliderPressed(); - - /*! - This signal is emitted when the user releases the - movable part of the slider. - */ - - void sliderReleased(); - /*! - This signal is emitted when the user moves the - slider with the mouse. - \param value new value - */ - void sliderMoved( double value ); - -protected: - virtual void setPosition( const QPoint & ); - virtual void valueChange(); - - virtual void timerEvent( QTimerEvent *e ); - virtual void mousePressEvent( QMouseEvent *e ); - virtual void mouseReleaseEvent( QMouseEvent *e ); - virtual void mouseMoveEvent( QMouseEvent *e ); - virtual void keyPressEvent( QKeyEvent *e ); - virtual void wheelEvent( QWheelEvent *e ); - - /*! - \brief Determine the value corresponding to a specified poind - - This is an abstract virtual function which is called when - the user presses or releases a mouse button or moves the - mouse. It has to be implemented by the derived class. - \param p point - */ - virtual double getValue( const QPoint & p ) = 0; - - /*! - \brief Determine what to do when the user presses a mouse button. - - This function is abstract and has to be implemented by derived classes. - It is called on a mousePress event. The derived class can determine - what should happen next in dependence of the position where the mouse - was pressed by returning scrolling mode and direction. - - \param pos point where the mouse was pressed - \retval scrollMode The scrolling mode - \retval direction direction: 1, 0, or -1. - */ - virtual void getScrollMode( const QPoint &pos, - ScrollMode &scrollMode, int &direction ) const = 0; - - void setMouseOffset( double ); - double mouseOffset() const; - - int scrollMode() const; - -private: - void buttonReleased(); - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_analog_clock.cpp b/qwt/src/qwt_analog_clock.cpp deleted file mode 100644 index 1aa0f3ec8..000000000 --- a/qwt/src/qwt_analog_clock.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_analog_clock.h" -#include - -/*! - Constructor - \param parent Parent widget -*/ -QwtAnalogClock::QwtAnalogClock( QWidget *parent ): - QwtDial( parent ) -{ - initClock(); -} - -void QwtAnalogClock::initClock() -{ - setWrapping( true ); - setReadOnly( true ); - - setOrigin( 270.0 ); - setRange( 0.0, 60.0 * 60.0 * 12.0 ); // seconds - setScale( -1, 5, 60.0 * 60.0 ); - - setScaleComponents( - QwtAbstractScaleDraw::Ticks | QwtAbstractScaleDraw::Labels ); - setScaleTicks( 1, 0, 8 ); - scaleDraw()->setSpacing( 8 ); - - QColor knobColor = palette().color( QPalette::Active, QPalette::Text ); - knobColor = knobColor.dark( 120 ); - - QColor handColor; - int width; - - for ( int i = 0; i < NHands; i++ ) - { - if ( i == SecondHand ) - { - width = 2; - handColor = knobColor.dark( 120 ); - } - else - { - width = 8; - handColor = knobColor; - } - - QwtDialSimpleNeedle *hand = new QwtDialSimpleNeedle( - QwtDialSimpleNeedle::Arrow, true, handColor, knobColor ); - hand->setWidth( width ); - - d_hand[i] = NULL; - setHand( ( Hand )i, hand ); - } -} - -//! Destructor -QwtAnalogClock::~QwtAnalogClock() -{ - for ( int i = 0; i < NHands; i++ ) - delete d_hand[i]; -} - -/*! - Nop method, use setHand instead - \sa setHand() -*/ -void QwtAnalogClock::setNeedle( QwtDialNeedle * ) -{ - // no op - return; -} - -/*! - Set a clockhand - \param hand Specifies the type of hand - \param needle Hand - \sa hand() -*/ -void QwtAnalogClock::setHand( Hand hand, QwtDialNeedle *needle ) -{ - if ( hand >= 0 || hand < NHands ) - { - delete d_hand[hand]; - d_hand[hand] = needle; - } -} - -/*! - \return Clock hand - \param hd Specifies the type of hand - \sa setHand() -*/ -QwtDialNeedle *QwtAnalogClock::hand( Hand hd ) -{ - if ( hd < 0 || hd >= NHands ) - return NULL; - - return d_hand[hd]; -} - -/*! - \return Clock hand - \param hd Specifies the type of hand - \sa setHand() -*/ -const QwtDialNeedle *QwtAnalogClock::hand( Hand hd ) const -{ - return const_cast( this )->hand( hd ); -} - -/*! - \brief Set the current time - - This is the same as QwtAnalogClock::setTime(), but Qt < 3.0 - can't handle default parameters for slots. -*/ -void QwtAnalogClock::setCurrentTime() -{ - setTime( QTime::currentTime() ); -} - -/*! - Set a time - \param time Time to display -*/ -void QwtAnalogClock::setTime( const QTime &time ) -{ - if ( time.isValid() ) - { - setValue( ( time.hour() % 12 ) * 60.0 * 60.0 - + time.minute() * 60.0 + time.second() ); - } - else - setValid( false ); -} - -/*! - Find the scale label for a given value - - \param value Value - \return Label -*/ -QwtText QwtAnalogClock::scaleLabel( double value ) const -{ - if ( value == 0.0 ) - value = 60.0 * 60.0 * 12.0; - - return QString::number( int( value / ( 60.0 * 60.0 ) ) ); -} - -/*! - \brief Draw the needle - - A clock has no single needle but three hands instead. drawNeedle - translates value() into directions for the hands and calls - drawHand(). - - \param painter Painter - \param center Center of the clock - \param radius Maximum length for the hands - \param dir Dummy, not used. - \param colorGroup ColorGroup - - \sa drawHand() -*/ -void QwtAnalogClock::drawNeedle( QPainter *painter, const QPointF ¢er, - double radius, double dir, QPalette::ColorGroup colorGroup ) const -{ - Q_UNUSED( dir ); - - if ( isValid() ) - { - const double hours = value() / ( 60.0 * 60.0 ); - const double minutes = - ( value() - qFloor(hours) * 60.0 * 60.0 ) / 60.0; - const double seconds = value() - qFloor(hours) * 60.0 * 60.0 - - qFloor(minutes) * 60.0; - - double angle[NHands]; - angle[HourHand] = 360.0 * hours / 12.0; - angle[MinuteHand] = 360.0 * minutes / 60.0; - angle[SecondHand] = 360.0 * seconds / 60.0; - - for ( int hand = 0; hand < NHands; hand++ ) - { - double d = angle[hand]; - if ( direction() == Clockwise ) - d = 360.0 - d; - - d -= origin(); - - drawHand( painter, ( Hand )hand, center, radius, d, colorGroup ); - } - } -} - -/*! - Draw a clock hand - - \param painter Painter - \param hd Specify the type of hand - \param center Center of the clock - \param radius Maximum length for the hands - \param direction Direction of the hand in degrees, counter clockwise - \param cg ColorGroup -*/ -void QwtAnalogClock::drawHand( QPainter *painter, Hand hd, - const QPointF ¢er, double radius, double direction, - QPalette::ColorGroup cg ) const -{ - const QwtDialNeedle *needle = hand( hd ); - if ( needle ) - { - if ( hd == HourHand ) - radius = qRound( 0.8 * radius ); - - needle->draw( painter, center, radius, direction, cg ); - } -} diff --git a/qwt/src/qwt_analog_clock.h b/qwt/src/qwt_analog_clock.h deleted file mode 100644 index f20c3f1f2..000000000 --- a/qwt/src/qwt_analog_clock.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_ANALOG_CLOCK_H -#define QWT_ANALOG_CLOCK_H - -#include "qwt_global.h" -#include "qwt_dial.h" -#include "qwt_dial_needle.h" -#include - -/*! - \brief An analog clock - - \image html analogclock.png - - \par Example - \verbatim #include - - QwtAnalogClock *clock = new QwtAnalogClock(...); - clock->scaleDraw()->setPenWidth(3); - clock->setLineWidth(6); - clock->setFrameShadow(QwtDial::Sunken); - clock->setTime(); - - // update the clock every second - QTimer *timer = new QTimer(clock); - timer->connect(timer, SIGNAL(timeout()), clock, SLOT(setCurrentTime())); - timer->start(1000); - - \endverbatim - - Qwt is missing a set of good looking hands. - Contributions are very welcome. - - \note The examples/dials example shows how to use QwtAnalogClock. -*/ - -class QWT_EXPORT QwtAnalogClock: public QwtDial -{ - Q_OBJECT - -public: - /*! - Hand type - \sa setHand(), hand() - */ - enum Hand - { - //! Needle displaying the seconds - SecondHand, - - //! Needle displaying the minutes - MinuteHand, - - //! Needle displaying the hours - HourHand, - - //! Number of needles - NHands - }; - - explicit QwtAnalogClock( QWidget* parent = NULL ); - virtual ~QwtAnalogClock(); - - virtual void setHand( Hand, QwtDialNeedle * ); - const QwtDialNeedle *hand( Hand ) const; - QwtDialNeedle *hand( Hand ); - -public Q_SLOTS: - void setCurrentTime(); - void setTime( const QTime & = QTime::currentTime() ); - -protected: - virtual QwtText scaleLabel( double ) const; - - virtual void drawNeedle( QPainter *, const QPointF &, - double radius, double direction, QPalette::ColorGroup ) const; - - virtual void drawHand( QPainter *, Hand, const QPointF &, - double radius, double direction, QPalette::ColorGroup ) const; - -private: - virtual void setNeedle( QwtDialNeedle * ); - void initClock(); - - QwtDialNeedle *d_hand[NHands]; -}; - -#endif diff --git a/qwt/src/qwt_arrow_button.cpp b/qwt/src/qwt_arrow_button.cpp deleted file mode 100644 index f451b44cd..000000000 --- a/qwt/src/qwt_arrow_button.cpp +++ /dev/null @@ -1,332 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_arrow_button.h" -#include "qwt_math.h" -#include -#include -#include -#include -#include - -static const int MaxNum = 3; -static const int Margin = 2; -static const int Spacing = 1; - -class QwtArrowButton::PrivateData -{ -public: - int num; - Qt::ArrowType arrowType; -}; - -static QStyleOptionButton styleOpt( const QwtArrowButton* btn ) -{ - QStyleOptionButton option; - option.init( btn ); - option.features = QStyleOptionButton::None; - if ( btn->isFlat() ) - option.features |= QStyleOptionButton::Flat; - if ( btn->menu() ) - option.features |= QStyleOptionButton::HasMenu; - if ( btn->autoDefault() || btn->isDefault() ) - option.features |= QStyleOptionButton::AutoDefaultButton; - if ( btn->isDefault() ) - option.features |= QStyleOptionButton::DefaultButton; - if ( btn->isDown() ) - option.state |= QStyle::State_Sunken; - if ( !btn->isFlat() && !btn->isDown() ) - option.state |= QStyle::State_Raised; - - return option; -} - -/*! - \param num Number of arrows - \param arrowType see Qt::ArowType in the Qt docs. - \param parent Parent widget -*/ -QwtArrowButton::QwtArrowButton( int num, - Qt::ArrowType arrowType, QWidget *parent ): - QPushButton( parent ) -{ - d_data = new PrivateData; - d_data->num = qBound( 1, num, MaxNum ); - d_data->arrowType = arrowType; - - setAutoRepeat( true ); - setAutoDefault( false ); - - switch ( d_data->arrowType ) - { - case Qt::LeftArrow: - case Qt::RightArrow: - setSizePolicy( QSizePolicy::Expanding, - QSizePolicy::Fixed ); - break; - default: - setSizePolicy( QSizePolicy::Fixed, - QSizePolicy::Expanding ); - } -} - -//! Destructor -QwtArrowButton::~QwtArrowButton() -{ - delete d_data; - d_data = NULL; -} - -/*! - \brief The direction of the arrows -*/ -Qt::ArrowType QwtArrowButton::arrowType() const -{ - return d_data->arrowType; -} - -/*! - \brief The number of arrows -*/ -int QwtArrowButton::num() const -{ - return d_data->num; -} - -/*! - \return the bounding rect for the label -*/ -QRect QwtArrowButton::labelRect() const -{ - const int m = Margin; - - QRect r = rect(); - r.setRect( r.x() + m, r.y() + m, - r.width() - 2 * m, r.height() - 2 * m ); - - if ( isDown() ) - { - QStyleOptionButton option = styleOpt( this ); - const int ph = style()->pixelMetric( - QStyle::PM_ButtonShiftHorizontal, &option, this ); - const int pv = style()->pixelMetric( - QStyle::PM_ButtonShiftVertical, &option, this ); - - r.translate( ph, pv ); - } - - return r; -} - -/*! - Paint event handler - \param event Paint event -*/ -void QwtArrowButton::paintEvent( QPaintEvent *event ) -{ - QPushButton::paintEvent( event ); - QPainter painter( this ); - drawButtonLabel( &painter ); -} - -/*! - \brief Draw the button label - - \param painter Painter - \sa The Qt Manual on QPushButton -*/ -void QwtArrowButton::drawButtonLabel( QPainter *painter ) -{ - const bool isVertical = d_data->arrowType == Qt::UpArrow || - d_data->arrowType == Qt::DownArrow; - - const QRect r = labelRect(); - QSize boundingSize = labelRect().size(); - if ( isVertical ) - boundingSize.transpose(); - - const int w = - ( boundingSize.width() - ( MaxNum - 1 ) * Spacing ) / MaxNum; - - QSize arrow = arrowSize( Qt::RightArrow, - QSize( w, boundingSize.height() ) ); - - if ( isVertical ) - arrow.transpose(); - - QRect contentsSize; // aligned rect where to paint all arrows - if ( d_data->arrowType == Qt::LeftArrow || d_data->arrowType == Qt::RightArrow ) - { - contentsSize.setWidth( d_data->num * arrow.width() - + ( d_data->num - 1 ) * Spacing ); - contentsSize.setHeight( arrow.height() ); - } - else - { - contentsSize.setWidth( arrow.width() ); - contentsSize.setHeight( d_data->num * arrow.height() - + ( d_data->num - 1 ) * Spacing ); - } - - QRect arrowRect( contentsSize ); - arrowRect.moveCenter( r.center() ); - arrowRect.setSize( arrow ); - - painter->save(); - for ( int i = 0; i < d_data->num; i++ ) - { - drawArrow( painter, arrowRect, d_data->arrowType ); - - int dx = 0; - int dy = 0; - - if ( isVertical ) - dy = arrow.height() + Spacing; - else - dx = arrow.width() + Spacing; - - arrowRect.translate( dx, dy ); - } - painter->restore(); - - if ( hasFocus() ) - { - QStyleOptionFocusRect option; - option.init( this ); - option.backgroundColor = palette().color( QPalette::Window ); - - style()->drawPrimitive( QStyle::PE_FrameFocusRect, - &option, painter, this ); - } -} - -/*! - Draw an arrow int a bounding rect - - \param painter Painter - \param r Rectangle where to paint the arrow - \param arrowType Arrow type -*/ -void QwtArrowButton::drawArrow( QPainter *painter, - const QRect &r, Qt::ArrowType arrowType ) const -{ - QPolygon pa( 3 ); - - switch ( arrowType ) - { - case Qt::UpArrow: - pa.setPoint( 0, r.bottomLeft() ); - pa.setPoint( 1, r.bottomRight() ); - pa.setPoint( 2, r.center().x(), r.top() ); - break; - case Qt::DownArrow: - pa.setPoint( 0, r.topLeft() ); - pa.setPoint( 1, r.topRight() ); - pa.setPoint( 2, r.center().x(), r.bottom() ); - break; - case Qt::RightArrow: - pa.setPoint( 0, r.topLeft() ); - pa.setPoint( 1, r.bottomLeft() ); - pa.setPoint( 2, r.right(), r.center().y() ); - break; - case Qt::LeftArrow: - pa.setPoint( 0, r.topRight() ); - pa.setPoint( 1, r.bottomRight() ); - pa.setPoint( 2, r.left(), r.center().y() ); - break; - default: - break; - } - - painter->save(); - - painter->setPen( palette().color( QPalette::ButtonText ) ); - painter->setBrush( palette().brush( QPalette::ButtonText ) ); - painter->drawPolygon( pa ); - - painter->restore(); -} - -/*! - \return a size hint -*/ -QSize QwtArrowButton::sizeHint() const -{ - const QSize hint = minimumSizeHint(); - return hint.expandedTo( QApplication::globalStrut() ); -} - -/*! - \brief Return a minimum size hint -*/ -QSize QwtArrowButton::minimumSizeHint() const -{ - const QSize asz = arrowSize( Qt::RightArrow, QSize() ); - - QSize sz( - 2 * Margin + ( MaxNum - 1 ) * Spacing + MaxNum * asz.width(), - 2 * Margin + asz.height() - ); - - if ( d_data->arrowType == Qt::UpArrow || d_data->arrowType == Qt::DownArrow ) - sz.transpose(); - - QStyleOption styleOption; - styleOption.init( this ); - - sz = style()->sizeFromContents( QStyle::CT_PushButton, - &styleOption, sz, this ); - - return sz; -} - -/*! - Calculate the size for a arrow that fits into a rect of a given size - - \param arrowType Arrow type - \param boundingSize Bounding size - \return Size of the arrow -*/ -QSize QwtArrowButton::arrowSize( Qt::ArrowType arrowType, - const QSize &boundingSize ) const -{ - QSize bs = boundingSize; - if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow ) - bs.transpose(); - - const int MinLen = 2; - const QSize sz = bs.expandedTo( - QSize( MinLen, 2 * MinLen - 1 ) ); // minimum - - int w = sz.width(); - int h = 2 * w - 1; - - if ( h > sz.height() ) - { - h = sz.height(); - w = ( h + 1 ) / 2; - } - - QSize arrSize( w, h ); - if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow ) - arrSize.transpose(); - - return arrSize; -} - -/*! - \brief autoRepeat for the space keys -*/ -void QwtArrowButton::keyPressEvent( QKeyEvent *event ) -{ - if ( event->isAutoRepeat() && event->key() == Qt::Key_Space ) - Q_EMIT clicked(); - - QPushButton::keyPressEvent( event ); -} diff --git a/qwt/src/qwt_arrow_button.h b/qwt/src/qwt_arrow_button.h deleted file mode 100644 index ae436fec0..000000000 --- a/qwt/src/qwt_arrow_button.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_ARROW_BUTTON_H -#define QWT_ARROW_BUTTON_H - -#include "qwt_global.h" -#include - -/*! - \brief Arrow Button - - A push button with one or more filled triangles on its front. - An Arrow button can have 1 to 3 arrows in a row, pointing - up, down, left or right. -*/ -class QWT_EXPORT QwtArrowButton : public QPushButton -{ -public: - explicit QwtArrowButton ( int num, Qt::ArrowType, QWidget *parent = NULL ); - virtual ~QwtArrowButton(); - - Qt::ArrowType arrowType() const; - int num() const; - - virtual QSize sizeHint() const; - virtual QSize minimumSizeHint() const; - -protected: - virtual void paintEvent( QPaintEvent *event ); - - virtual void drawButtonLabel( QPainter *p ); - virtual void drawArrow( QPainter *, - const QRect &, Qt::ArrowType ) const; - virtual QRect labelRect() const; - virtual QSize arrowSize( Qt::ArrowType, - const QSize &boundingSize ) const; - - virtual void keyPressEvent( QKeyEvent * ); - -private: - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_clipper.cpp b/qwt/src/qwt_clipper.cpp deleted file mode 100644 index 6eabb7ddf..000000000 --- a/qwt/src/qwt_clipper.cpp +++ /dev/null @@ -1,486 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_clipper.h" -#include "qwt_point_polar.h" -#include - -#if QT_VERSION < 0x040601 -#define qAtan(x) ::atan(x) -#endif - -namespace QwtClip -{ - // some templates used for inlining - template class LeftEdge; - template class RightEdge; - template class TopEdge; - template class BottomEdge; - - template class PointBuffer; -} - -template -class QwtClip::LeftEdge -{ -public: - inline LeftEdge( Value x1, Value, Value, Value ): - d_x1( x1 ) - { - } - - inline bool isInside( const Point &p ) const - { - return p.x() >= d_x1; - } - - inline Point intersection( const Point &p1, const Point &p2 ) const - { - double dy = ( p1.y() - p2.y() ) / double( p1.x() - p2.x() ); - return Point( d_x1, ( Value ) ( p2.y() + ( d_x1 - p2.x() ) * dy ) ); - } -private: - const Value d_x1; -}; - -template -class QwtClip::RightEdge -{ -public: - inline RightEdge( Value, Value x2, Value, Value ): - d_x2( x2 ) - { - } - - inline bool isInside( const Point &p ) const - { - return p.x() <= d_x2; - } - - inline Point intersection( const Point &p1, const Point &p2 ) const - { - double dy = ( p1.y() - p2.y() ) / double( p1.x() - p2.x() ); - return Point( d_x2, ( Value ) ( p2.y() + ( d_x2 - p2.x() ) * dy ) ); - } - -private: - const Value d_x2; -}; - -template -class QwtClip::TopEdge -{ -public: - inline TopEdge( Value, Value, Value y1, Value ): - d_y1( y1 ) - { - } - - inline bool isInside( const Point &p ) const - { - return p.y() >= d_y1; - } - - inline Point intersection( const Point &p1, const Point &p2 ) const - { - double dx = ( p1.x() - p2.x() ) / double( p1.y() - p2.y() ); - return Point( ( Value )( p2.x() + ( d_y1 - p2.y() ) * dx ), d_y1 ); - } - -private: - const Value d_y1; -}; - -template -class QwtClip::BottomEdge -{ -public: - inline BottomEdge( Value, Value, Value, Value y2 ): - d_y2( y2 ) - { - } - - inline bool isInside( const Point &p ) const - { - return p.y() <= d_y2; - } - - inline Point intersection( const Point &p1, const Point &p2 ) const - { - double dx = ( p1.x() - p2.x() ) / double( p1.y() - p2.y() ); - return Point( ( Value )( p2.x() + ( d_y2 - p2.y() ) * dx ), d_y2 ); - } - -private: - const Value d_y2; -}; - -template -class QwtClip::PointBuffer -{ -public: - PointBuffer( int capacity = 0 ): - m_capacity( 0 ), - m_size( 0 ), - m_buffer( NULL ) - { - if ( capacity > 0 ) - reserve( capacity ); - } - - ~PointBuffer() - { - if ( m_buffer ) - qFree( m_buffer ); - } - - inline void setPoints( int numPoints, const Point *points ) - { - reserve( numPoints ); - - m_size = numPoints; - qMemCopy( m_buffer, points, m_size * sizeof( Point ) ); - } - - inline void reset() - { - m_size = 0; - } - - inline int size() const - { - return m_size; - } - - inline Point *data() const - { - return m_buffer; - } - - inline Point &operator[]( int i ) - { - return m_buffer[i]; - } - - inline const Point &operator[]( int i ) const - { - return m_buffer[i]; - } - - inline void add( const Point &point ) - { - if ( m_capacity <= m_size ) - reserve( m_size + 1 ); - - m_buffer[m_size++] = point; - } - -private: - inline void reserve( int size ) - { - if ( m_capacity == 0 ) - m_capacity = 1; - - while ( m_capacity < size ) - m_capacity *= 2; - - m_buffer = ( Point * ) qRealloc( - m_buffer, m_capacity * sizeof( Point ) ); - } - - int m_capacity; - int m_size; - Point *m_buffer; -}; - -using namespace QwtClip; - -template -class QwtPolygonClipper -{ -public: - QwtPolygonClipper( const Rect &clipRect ): - d_clipRect( clipRect ) - { - } - - Polygon clipPolygon( const Polygon &polygon, bool closePolygon ) const - { -#if 0 - if ( d_clipRect.contains( polygon.boundingRect() ) ) - return polygon; -#endif - - PointBuffer points1; - PointBuffer points2( qMin( 256, polygon.size() ) ); - - points1.setPoints( polygon.size(), polygon.data() ); - - clipEdge< LeftEdge >( closePolygon, points1, points2 ); - clipEdge< RightEdge >( closePolygon, points2, points1 ); - clipEdge< TopEdge >( closePolygon, points1, points2 ); - clipEdge< BottomEdge >( closePolygon, points2, points1 ); - - Polygon p; - p.resize( points1.size() ); - qMemCopy( p.data(), points1.data(), points1.size() * sizeof( Point ) ); - - return p; - } - -private: - template - inline void clipEdge( bool closePolygon, - PointBuffer &points, PointBuffer &clippedPoints ) const - { - clippedPoints.reset(); - - if ( points.size() < 2 ) - { - if ( points.size() == 1 ) - clippedPoints.add( points[0] ); - return; - } - - const Edge edge( d_clipRect.x(), d_clipRect.x() + d_clipRect.width(), - d_clipRect.y(), d_clipRect.y() + d_clipRect.height() ); - - int lastPos, start; - if ( closePolygon ) - { - start = 0; - lastPos = points.size() - 1; - } - else - { - start = 1; - lastPos = 0; - - if ( edge.isInside( points[0] ) ) - clippedPoints.add( points[0] ); - } - - const uint nPoints = points.size(); - for ( uint i = start; i < nPoints; i++ ) - { - const Point &p1 = points[i]; - const Point &p2 = points[lastPos]; - - if ( edge.isInside( p1 ) ) - { - if ( edge.isInside( p2 ) ) - { - clippedPoints.add( p1 ); - } - else - { - clippedPoints.add( edge.intersection( p1, p2 ) ); - clippedPoints.add( p1 ); - } - } - else - { - if ( edge.isInside( p2 ) ) - { - clippedPoints.add( edge.intersection( p1, p2 ) ); - } - } - lastPos = i; - } - } - - const Rect d_clipRect; -}; - -class QwtCircleClipper -{ -public: - QwtCircleClipper( const QRectF &r ); - QVector clipCircle( const QPointF &, double radius ) const; - -private: - enum Edge - { - Left, - Top, - Right, - Bottom, - - NEdges - }; - - QList cuttingPoints( - Edge, const QPointF &pos, double radius ) const; - - double toAngle( const QPointF &, const QPointF & ) const; - - const QRectF d_rect; -}; - - -QwtCircleClipper::QwtCircleClipper( const QRectF &r ): - d_rect( r ) -{ -} - -QVector QwtCircleClipper::clipCircle( - const QPointF &pos, double radius ) const -{ - QList points; - for ( int edge = 0; edge < NEdges; edge++ ) - points += cuttingPoints( ( Edge )edge, pos, radius ); - - QVector intv; - if ( points.size() <= 0 ) - { - QRectF cRect( 0, 0, 2 * radius, 2 * radius ); - cRect.moveCenter( pos ); - if ( d_rect.contains( cRect ) ) - intv += QwtInterval( 0.0, 2 * M_PI ); - } - else - { - QList angles; - for ( int i = 0; i < points.size(); i++ ) - angles += toAngle( pos, points[i] ); - qSort( angles ); - - const int in = d_rect.contains( qwtPolar2Pos( pos, radius, - angles[0] + ( angles[1] - angles[0] ) / 2 ) ); - - if ( in ) - { - for ( int i = 0; i < angles.size() - 1; i += 2 ) - intv += QwtInterval( angles[i], angles[i+1] ); - } - else - { - for ( int i = 1; i < angles.size() - 1; i += 2 ) - intv += QwtInterval( angles[i], angles[i+1] ); - intv += QwtInterval( angles.last(), angles.first() ); - } - } - - return intv; -} - -double QwtCircleClipper::toAngle( - const QPointF &from, const QPointF &to ) const -{ - if ( from.x() == to.x() ) - return from.y() <= to.y() ? M_PI / 2.0 : 3 * M_PI / 2.0; - - const double m = qAbs( ( to.y() - from.y() ) / ( to.x() - from.x() ) ); - - double angle = qAtan( m ); - if ( to.x() > from.x() ) - { - if ( to.y() > from.y() ) - angle = 2 * M_PI - angle; - } - else - { - if ( to.y() > from.y() ) - angle = M_PI + angle; - else - angle = M_PI - angle; - } - - return angle; -} - -QList QwtCircleClipper::cuttingPoints( - Edge edge, const QPointF &pos, double radius ) const -{ - QList points; - - if ( edge == Left || edge == Right ) - { - const double x = ( edge == Left ) ? d_rect.left() : d_rect.right(); - if ( qAbs( pos.x() - x ) < radius ) - { - const double off = qSqrt( qwtSqr( radius ) - qwtSqr( pos.x() - x ) ); - const double m_y1 = pos.y() + off; - if ( m_y1 >= d_rect.top() && m_y1 <= d_rect.bottom() ) - points += QPointF( x, m_y1 ); - - const double m_y2 = pos.y() - off; - if ( m_y2 >= d_rect.top() && m_y2 <= d_rect.bottom() ) - points += QPointF( x, m_y2 ); - } - } - else - { - const double y = ( edge == Top ) ? d_rect.top() : d_rect.bottom(); - if ( qAbs( pos.y() - y ) < radius ) - { - const double off = qSqrt( qwtSqr( radius ) - qwtSqr( pos.y() - y ) ); - const double x1 = pos.x() + off; - if ( x1 >= d_rect.left() && x1 <= d_rect.right() ) - points += QPointF( x1, y ); - - const double m_x2 = pos.x() - off; - if ( m_x2 >= d_rect.left() && m_x2 <= d_rect.right() ) - points += QPointF( m_x2, y ); - } - } - return points; -} - -/*! - Sutherland-Hodgman polygon clipping - - \param clipRect Clip rectangle - \param polygon Polygon - \param closePolygon True, when the polygon is closed - - \return Clipped polygon -*/ -QPolygon QwtClipper::clipPolygon( - const QRect &clipRect, const QPolygon &polygon, bool closePolygon ) -{ - QwtPolygonClipper clipper( clipRect ); - return clipper.clipPolygon( polygon, closePolygon ); -} - -/*! - Sutherland-Hodgman polygon clipping - - \param clipRect Clip rectangle - \param polygon Polygon - \param closePolygon True, when the polygon is closed - - \return Clipped polygon -*/ -QPolygonF QwtClipper::clipPolygonF( - const QRectF &clipRect, const QPolygonF &polygon, bool closePolygon ) -{ - QwtPolygonClipper clipper( clipRect ); - return clipper.clipPolygon( polygon, closePolygon ); -} - -/*! - Circle clipping - - clipCircle() devides a circle into intervals of angles representing arcs - of the circle. When the circle is completely inside the clip rectangle - an interval [0.0, 2 * M_PI] is returned. - - \param clipRect Clip rectangle - \param center Center of the circle - \param radius Radius of the circle - - \return Arcs of the circle -*/ -QVector QwtClipper::clipCircle( const QRectF &clipRect, - const QPointF ¢er, double radius ) -{ - QwtCircleClipper clipper( clipRect ); - return clipper.clipCircle( center, radius ); -} diff --git a/qwt/src/qwt_clipper.h b/qwt/src/qwt_clipper.h deleted file mode 100644 index 5e67b841b..000000000 --- a/qwt/src/qwt_clipper.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_CLIPPER_H -#define QWT_CLIPPER_H - -#include "qwt_global.h" -#include "qwt_interval.h" -#include -#include - -class QRect; -class QRectF; - -/*! - \brief Some clipping algos -*/ - -class QWT_EXPORT QwtClipper -{ -public: - static QPolygon clipPolygon( const QRect &, - const QPolygon &, bool closePolygon = false ); - static QPolygonF clipPolygonF( const QRectF &, - const QPolygonF &, bool closePolygon = false ); - - static QVector clipCircle( - const QRectF &, const QPointF &, double radius ); -}; - -#endif diff --git a/qwt/src/qwt_color_map.cpp b/qwt/src/qwt_color_map.cpp deleted file mode 100644 index 4318e5a0a..000000000 --- a/qwt/src/qwt_color_map.cpp +++ /dev/null @@ -1,440 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_color_map.h" -#include "qwt_math.h" -#include "qwt_interval.h" -#include - -class QwtLinearColorMap::ColorStops -{ -public: - ColorStops() - { - _stops.reserve( 256 ); - } - - void insert( double pos, const QColor &color ); - QRgb rgb( QwtLinearColorMap::Mode, double pos ) const; - - QVector stops() const; - -private: - - class ColorStop - { - public: - ColorStop(): - pos( 0.0 ), - rgb( 0 ) - { - }; - - ColorStop( double p, const QColor &c ): - pos( p ), - rgb( c.rgb() ) - { - r = qRed( rgb ); - g = qGreen( rgb ); - b = qBlue( rgb ); - } - - double pos; - QRgb rgb; - int r, g, b; - }; - - inline int findUpper( double pos ) const; - QVector _stops; -}; - -void QwtLinearColorMap::ColorStops::insert( double pos, const QColor &color ) -{ - // Lookups need to be very fast, insertions are not so important. - // Anyway, a balanced tree is what we need here. TODO ... - - if ( pos < 0.0 || pos > 1.0 ) - return; - - int index; - if ( _stops.size() == 0 ) - { - index = 0; - _stops.resize( 1 ); - } - else - { - index = findUpper( pos ); - if ( index == _stops.size() || - qAbs( _stops[index].pos - pos ) >= 0.001 ) - { - _stops.resize( _stops.size() + 1 ); - for ( int i = _stops.size() - 1; i > index; i-- ) - _stops[i] = _stops[i-1]; - } - } - - _stops[index] = ColorStop( pos, color ); -} - -inline QVector QwtLinearColorMap::ColorStops::stops() const -{ - QVector positions( _stops.size() ); - for ( int i = 0; i < _stops.size(); i++ ) - positions[i] = _stops[i].pos; - return positions; -} - -inline int QwtLinearColorMap::ColorStops::findUpper( double pos ) const -{ - int index = 0; - int n = _stops.size(); - - const ColorStop *stops = _stops.data(); - - while ( n > 0 ) - { - const int half = n >> 1; - const int middle = index + half; - - if ( stops[middle].pos <= pos ) - { - index = middle + 1; - n -= half + 1; - } - else - n = half; - } - - return index; -} - -inline QRgb QwtLinearColorMap::ColorStops::rgb( - QwtLinearColorMap::Mode mode, double pos ) const -{ - if ( pos <= 0.0 ) - return _stops[0].rgb; - if ( pos >= 1.0 ) - return _stops[ _stops.size() - 1 ].rgb; - - const int index = findUpper( pos ); - if ( mode == FixedColors ) - { - return _stops[index-1].rgb; - } - else - { - const ColorStop &s1 = _stops[index-1]; - const ColorStop &s2 = _stops[index]; - - const double ratio = ( pos - s1.pos ) / ( s2.pos - s1.pos ); - - const int r = s1.r + qRound( ratio * ( s2.r - s1.r ) ); - const int g = s1.g + qRound( ratio * ( s2.g - s1.g ) ); - const int b = s1.b + qRound( ratio * ( s2.b - s1.b ) ); - - return qRgb( r, g, b ); - } -} - -//! Constructor -QwtColorMap::QwtColorMap( Format format ): - d_format( format ) -{ -} - -//! Destructor -QwtColorMap::~QwtColorMap() -{ -} - -/*! - Build and return a color map of 256 colors - - The color table is needed for rendering indexed images in combination - with using colorIndex(). - - \param interval Range for the values - \return A color table, that can be used for a QImage -*/ -QVector QwtColorMap::colorTable( const QwtInterval &interval ) const -{ - QVector table( 256 ); - - if ( interval.isValid() ) - { - const double step = interval.width() / ( table.size() - 1 ); - for ( int i = 0; i < table.size(); i++ ) - table[i] = rgb( interval, interval.minValue() + step * i ); - } - - return table; -} - -class QwtLinearColorMap::PrivateData -{ -public: - ColorStops colorStops; - QwtLinearColorMap::Mode mode; -}; - -/*! - Build a color map with two stops at 0.0 and 1.0. The color - at 0.0 is Qt::blue, at 1.0 it is Qt::yellow. - - \param format Preferred format of the color map -*/ -QwtLinearColorMap::QwtLinearColorMap( QwtColorMap::Format format ): - QwtColorMap( format ) -{ - d_data = new PrivateData; - d_data->mode = ScaledColors; - - setColorInterval( Qt::blue, Qt::yellow ); -} - -/*! - Build a color map with two stops at 0.0 and 1.0. - - \param color1 Color used for the minimum value of the value interval - \param color2 Color used for the maximum value of the value interval - \param format Preferred format of the coor map -*/ -QwtLinearColorMap::QwtLinearColorMap( const QColor &color1, - const QColor &color2, QwtColorMap::Format format ): - QwtColorMap( format ) -{ - d_data = new PrivateData; - d_data->mode = ScaledColors; - setColorInterval( color1, color2 ); -} - -//! Destructor -QwtLinearColorMap::~QwtLinearColorMap() -{ - delete d_data; -} - -/*! - \brief Set the mode of the color map - - FixedColors means the color is calculated from the next lower - color stop. ScaledColors means the color is calculated - by interpolating the colors of the adjacent stops. - - \sa mode() -*/ -void QwtLinearColorMap::setMode( Mode mode ) -{ - d_data->mode = mode; -} - -/*! - \return Mode of the color map - \sa setMode() -*/ -QwtLinearColorMap::Mode QwtLinearColorMap::mode() const -{ - return d_data->mode; -} - -/*! - Set the color range - - Add stops at 0.0 and 1.0. - - \param color1 Color used for the minimum value of the value interval - \param color2 Color used for the maximum value of the value interval - - \sa color1(), color2() -*/ -void QwtLinearColorMap::setColorInterval( - const QColor &color1, const QColor &color2 ) -{ - d_data->colorStops = ColorStops(); - d_data->colorStops.insert( 0.0, color1 ); - d_data->colorStops.insert( 1.0, color2 ); -} - -/*! - Add a color stop - - The value has to be in the range [0.0, 1.0]. - F.e. a stop at position 17.0 for a range [10.0,20.0] must be - passed as: (17.0 - 10.0) / (20.0 - 10.0) - - \param value Value between [0.0, 1.0] - \param color Color stop -*/ -void QwtLinearColorMap::addColorStop( double value, const QColor& color ) -{ - if ( value >= 0.0 && value <= 1.0 ) - d_data->colorStops.insert( value, color ); -} - -/*! - Return all positions of color stops in increasing order -*/ -QVector QwtLinearColorMap::colorStops() const -{ - return d_data->colorStops.stops(); -} - -/*! - \return the first color of the color range - \sa setColorInterval() -*/ -QColor QwtLinearColorMap::color1() const -{ - return QColor( d_data->colorStops.rgb( d_data->mode, 0.0 ) ); -} - -/*! - \return the second color of the color range - \sa setColorInterval() -*/ -QColor QwtLinearColorMap::color2() const -{ - return QColor( d_data->colorStops.rgb( d_data->mode, 1.0 ) ); -} - -/*! - Map a value of a given interval into a rgb value - - \param interval Range for all values - \param value Value to map into a rgb value -*/ -QRgb QwtLinearColorMap::rgb( - const QwtInterval &interval, double value ) const -{ - if ( qIsNaN(value) ) - return qRgba(0, 0, 0, 0); - - const double width = interval.width(); - - double ratio = 0.0; - if ( width > 0.0 ) - ratio = ( value - interval.minValue() ) / width; - - return d_data->colorStops.rgb( d_data->mode, ratio ); -} - -/*! - Map a value of a given interval into a color index, between 0 and 255 - - \param interval Range for all values - \param value Value to map into a color index -*/ -unsigned char QwtLinearColorMap::colorIndex( - const QwtInterval &interval, double value ) const -{ - const double width = interval.width(); - - if ( qIsNaN(value) || width <= 0.0 || value <= interval.minValue() ) - return 0; - - if ( value >= interval.maxValue() ) - return ( unsigned char )255; - - const double ratio = ( value - interval.minValue() ) / width; - - unsigned char index; - if ( d_data->mode == FixedColors ) - index = ( unsigned char )( ratio * 255 ); // always floor - else - index = ( unsigned char )qRound( ratio * 255 ); - - return index; -} - -class QwtAlphaColorMap::PrivateData -{ -public: - QColor color; - QRgb rgb; -}; - - -/*! - Constructor - \param color Color of the map -*/ -QwtAlphaColorMap::QwtAlphaColorMap( const QColor &color ): - QwtColorMap( QwtColorMap::RGB ) -{ - d_data = new PrivateData; - d_data->color = color; - d_data->rgb = color.rgb() & qRgba( 255, 255, 255, 0 ); -} - -//! Destructor -QwtAlphaColorMap::~QwtAlphaColorMap() -{ - delete d_data; -} - -/*! - Set the color - - \param color Color - \sa color() -*/ -void QwtAlphaColorMap::setColor( const QColor &color ) -{ - d_data->color = color; - d_data->rgb = color.rgb(); -} - -/*! - \return the color - \sa setColor() -*/ -QColor QwtAlphaColorMap::color() const -{ - return d_data->color; -} - -/*! - \brief Map a value of a given interval into a alpha value - - alpha := (value - interval.minValue()) / interval.width(); - - \param interval Range for all values - \param value Value to map into a rgb value - \return rgb value, with an alpha value -*/ -QRgb QwtAlphaColorMap::rgb( const QwtInterval &interval, double value ) const -{ - const double width = interval.width(); - if ( !qIsNaN(value) && width >= 0.0 ) - { - const double ratio = ( value - interval.minValue() ) / width; - int alpha = qRound( 255 * ratio ); - if ( alpha < 0 ) - alpha = 0; - if ( alpha > 255 ) - alpha = 255; - - return d_data->rgb | ( alpha << 24 ); - } - return d_data->rgb; -} - -/*! - Dummy function, needed to be implemented as it is pure virtual - in QwtColorMap. Color indices make no sense in combination with - an alpha channel. - - \return Always 0 -*/ -unsigned char QwtAlphaColorMap::colorIndex( - const QwtInterval &, double ) const -{ - return 0; -} diff --git a/qwt/src/qwt_color_map.h b/qwt/src/qwt_color_map.h deleted file mode 100644 index e75483026..000000000 --- a/qwt/src/qwt_color_map.h +++ /dev/null @@ -1,198 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_COLOR_MAP_H -#define QWT_COLOR_MAP_H - -#include "qwt_global.h" -#include "qwt_interval.h" -#include -#include - -/*! - \brief QwtColorMap is used to map values into colors. - - For displaying 3D data on a 2D plane the 3rd dimension is often - displayed using colors, like f.e in a spectrogram. - - Each color map is optimized to return colors for only one of the - following image formats: - - - QImage::Format_Indexed8\n - - QImage::Format_ARGB32\n - - \sa QwtPlotSpectrogram, QwtScaleWidget -*/ - -class QWT_EXPORT QwtColorMap -{ -public: - /*! - Format for color mapping - \sa rgb(), colorIndex(), colorTable() - */ - - enum Format - { - //! The map is intended to map into QRgb values. - RGB, - - /*! - The map is intended to map into 8 bit values, that - are indices into the color table. - */ - Indexed - }; - - QwtColorMap( Format = QwtColorMap::RGB ); - virtual ~QwtColorMap(); - - Format format() const; - - /*! - Map a value of a given interval into a rgb value. - \param interval Range for the values - \param value Value - \return rgb value, corresponding to value - */ - virtual QRgb rgb( const QwtInterval &interval, - double value ) const = 0; - - /*! - Map a value of a given interval into a color index - \param interval Range for the values - \param value Value - \return color index, corresponding to value - */ - virtual unsigned char colorIndex( - const QwtInterval &interval, double value ) const = 0; - - QColor color( const QwtInterval &, double value ) const; - virtual QVector colorTable( const QwtInterval & ) const; - -private: - Format d_format; -}; - -/*! - \brief QwtLinearColorMap builds a color map from color stops. - - A color stop is a color at a specific position. The valid - range for the positions is [0.0, 1.0]. When mapping a value - into a color it is translated into this interval according to mode(). -*/ -class QWT_EXPORT QwtLinearColorMap: public QwtColorMap -{ -public: - /*! - Mode of color map - \sa setMode(), mode() - */ - enum Mode - { - //! Return the color from the next lower color stop - FixedColors, - - //! Interpolating the colors of the adjacent stops. - ScaledColors - }; - - QwtLinearColorMap( QwtColorMap::Format = QwtColorMap::RGB ); - QwtLinearColorMap( const QColor &from, const QColor &to, - QwtColorMap::Format = QwtColorMap::RGB ); - - virtual ~QwtLinearColorMap(); - - void setMode( Mode ); - Mode mode() const; - - void setColorInterval( const QColor &color1, const QColor &color2 ); - void addColorStop( double value, const QColor& ); - QVector colorStops() const; - - QColor color1() const; - QColor color2() const; - - virtual QRgb rgb( const QwtInterval &, double value ) const; - virtual unsigned char colorIndex( - const QwtInterval &, double value ) const; - - class ColorStops; - -private: - // Disabled copy constructor and operator= - QwtLinearColorMap( const QwtLinearColorMap & ); - QwtLinearColorMap &operator=( const QwtLinearColorMap & ); - - class PrivateData; - PrivateData *d_data; -}; - -/*! - \brief QwtAlphaColorMap variies the alpha value of a color -*/ -class QWT_EXPORT QwtAlphaColorMap: public QwtColorMap -{ -public: - QwtAlphaColorMap( const QColor & = QColor( Qt::gray ) ); - virtual ~QwtAlphaColorMap(); - - void setColor( const QColor & ); - QColor color() const; - - virtual QRgb rgb( const QwtInterval &, double value ) const; - -private: - QwtAlphaColorMap( const QwtAlphaColorMap & ); - QwtAlphaColorMap &operator=( const QwtAlphaColorMap & ); - - virtual unsigned char colorIndex( - const QwtInterval &, double value ) const; - - class PrivateData; - PrivateData *d_data; -}; - - -/*! - Map a value into a color - - \param interval Valid interval for values - \param value Value - - \return Color corresponding to value - - \warning This method is slow for Indexed color maps. If it is - necessary to map many values, its better to get the - color table once and find the color using colorIndex(). -*/ -inline QColor QwtColorMap::color( - const QwtInterval &interval, double value ) const -{ - if ( d_format == RGB ) - { - return QColor( rgb( interval, value ) ); - } - else - { - const unsigned int index = colorIndex( interval, value ); - return colorTable( interval )[index]; // slow - } -} - -/*! - \return Intended format of the color map - \sa Format -*/ -inline QwtColorMap::Format QwtColorMap::format() const -{ - return d_format; -} - -#endif diff --git a/qwt/src/qwt_column_symbol.cpp b/qwt/src/qwt_column_symbol.cpp deleted file mode 100644 index 314e9d2f1..000000000 --- a/qwt/src/qwt_column_symbol.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_column_symbol.h" -#include "qwt_math.h" -#include "qwt_text.h" -#include "qwt_painter.h" -#include -#include - -static void drawBox( QPainter *p, const QRectF &rect, - const QPalette &pal, double lw ) -{ - if ( lw > 0.0 ) - { - if ( rect.width() == 0.0 ) - { - p->setPen( pal.dark().color() ); - p->drawLine( rect.topLeft(), rect.bottomLeft() ); - return; - } - - if ( rect.height() == 0.0 ) - { - p->setPen( pal.dark().color() ); - p->drawLine( rect.topLeft(), rect.topRight() ); - return; - } - - lw = qMin( lw, rect.height() / 2.0 - 1.0 ); - lw = qMin( lw, rect.width() / 2.0 - 1.0 ); - - const QRectF outerRect = rect.adjusted( 0, 0, 1, 1 ); - QPolygonF polygon( outerRect ); - - if ( outerRect.width() > 2 * lw && - outerRect.height() > 2 * lw ) - { - const QRectF innerRect = outerRect.adjusted( lw, lw, -lw, -lw ); - polygon = polygon.subtracted( innerRect ); - } - - p->setPen( Qt::NoPen ); - - p->setBrush( pal.dark() ); - p->drawPolygon( polygon ); - } - - const QRectF windowRect = rect.adjusted( lw, lw, -lw + 1, -lw + 1 ); - if ( windowRect.isValid() ) - p->fillRect( windowRect, pal.window() ); -} - -static void drawPanel( QPainter *painter, const QRectF &rect, - const QPalette &pal, double lw ) -{ - if ( lw > 0.0 ) - { - if ( rect.width() == 0.0 ) - { - painter->setPen( pal.window().color() ); - painter->drawLine( rect.topLeft(), rect.bottomLeft() ); - return; - } - - if ( rect.height() == 0.0 ) - { - painter->setPen( pal.window().color() ); - painter->drawLine( rect.topLeft(), rect.topRight() ); - return; - } - - lw = qMin( lw, rect.height() / 2.0 - 1.0 ); - lw = qMin( lw, rect.width() / 2.0 - 1.0 ); - - const QRectF outerRect = rect.adjusted( 0, 0, 1, 1 ); - const QRectF innerRect = outerRect.adjusted( lw, lw, -lw, -lw ); - - QPolygonF lines[2]; - - lines[0] += outerRect.bottomLeft(); - lines[0] += outerRect.topLeft(); - lines[0] += outerRect.topRight(); - lines[0] += innerRect.topRight(); - lines[0] += innerRect.topLeft(); - lines[0] += innerRect.bottomLeft(); - - lines[1] += outerRect.topRight(); - lines[1] += outerRect.bottomRight(); - lines[1] += outerRect.bottomLeft(); - lines[1] += innerRect.bottomLeft(); - lines[1] += innerRect.bottomRight(); - lines[1] += innerRect.topRight(); - - painter->setPen( Qt::NoPen ); - - painter->setBrush( pal.light() ); - painter->drawPolygon( lines[0] ); - painter->setBrush( pal.dark() ); - painter->drawPolygon( lines[1] ); - } - - painter->fillRect( rect.adjusted( lw, lw, -lw + 1, -lw + 1 ), pal.window() ); -} - -class QwtColumnSymbol::PrivateData -{ -public: - PrivateData(): - style( QwtColumnSymbol::Box ), - frameStyle( QwtColumnSymbol::Raised ), - lineWidth( 2 ) - { - palette = QPalette( Qt::gray ); - } - - QwtColumnSymbol::Style style; - QwtColumnSymbol::FrameStyle frameStyle; - - QPalette palette; - QwtText label; - - int lineWidth; -}; - -/*! - Constructor - - \param style Style of the symbol - \sa setStyle(), style(), Style -*/ -QwtColumnSymbol::QwtColumnSymbol( Style style ) -{ - d_data = new PrivateData(); - d_data->style = style; -} - -//! Destructor -QwtColumnSymbol::~QwtColumnSymbol() -{ - delete d_data; -} - -/*! - Specify the symbol style - - \param style Style - \sa style(), setPalette() -*/ -void QwtColumnSymbol::setStyle( Style style ) -{ - d_data->style = style; -} - -/*! - \return Current symbol style - \sa setStyle() -*/ -QwtColumnSymbol::Style QwtColumnSymbol::style() const -{ - return d_data->style; -} - -/*! - Assign a palette for the symbol - - \param palette Palette - \sa palette(), setStyle() -*/ -void QwtColumnSymbol::setPalette( const QPalette &palette ) -{ - d_data->palette = palette; -} - -/*! - \return Current palette - \sa setPalette() -*/ -const QPalette& QwtColumnSymbol::palette() const -{ - return d_data->palette; -} - -/*! - Set the frame, that is used for the Box style. - - \param frameStyle Frame style - \sa frameStyle(), setLineWidth(), setStyle() -*/ -void QwtColumnSymbol::setFrameStyle( FrameStyle frameStyle ) -{ - d_data->frameStyle = frameStyle; -} - -/*! - \return Current frame style, that is used for the Box style. - \sa setFrameStyle(), lineWidth(), setStyle() -*/ -QwtColumnSymbol::FrameStyle QwtColumnSymbol::frameStyle() const -{ - return d_data->frameStyle; -} - -/*! - Set the line width of the frame, that is used for the Box style. - - \param width Width - \sa lineWidth(), setFrameStyle() -*/ -void QwtColumnSymbol::setLineWidth( int width ) -{ - if ( width < 0 ) - width = 0; - - d_data->lineWidth = width; -} - -/*! - \return Line width of the frame, that is used for the Box style. - \sa setLineWidth(), frameStyle(), setStyle() -*/ -int QwtColumnSymbol::lineWidth() const -{ - return d_data->lineWidth; -} - -/*! - Draw the symbol depending on its style. - - \param painter Painter - \param rect Directed rectangle - - \sa drawBox() -*/ -void QwtColumnSymbol::draw( QPainter *painter, - const QwtColumnRect &rect ) const -{ - painter->save(); - - switch ( d_data->style ) - { - case QwtColumnSymbol::Box: - { - drawBox( painter, rect ); - break; - } - default:; - } - - painter->restore(); -} - -/*! - Draw the symbol when it is in Box style. - - \param painter Painter - \param rect Directed rectangle - - \sa draw() -*/ -void QwtColumnSymbol::drawBox( QPainter *painter, - const QwtColumnRect &rect ) const -{ - QRectF r = rect.toRect(); - if ( QwtPainter::roundingAlignment( painter ) ) - { - r.setLeft( qRound( r.left() ) ); - r.setRight( qRound( r.right() ) ); - r.setTop( qRound( r.top() ) ); - r.setBottom( qRound( r.bottom() ) ); - } - - switch ( d_data->frameStyle ) - { - case QwtColumnSymbol::Raised: - { - ::drawPanel( painter, r, d_data->palette, d_data->lineWidth ); - break; - } - case QwtColumnSymbol::Plain: - { - ::drawBox( painter, r, d_data->palette, d_data->lineWidth ); - break; - } - default: - { - painter->fillRect( r, d_data->palette.window() ); - } - } -} diff --git a/qwt/src/qwt_column_symbol.h b/qwt/src/qwt_column_symbol.h deleted file mode 100644 index 3c278f19a..000000000 --- a/qwt/src/qwt_column_symbol.h +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_COLUMN_SYMBOL_H -#define QWT_COLUMN_SYMBOL_H - -#include "qwt_global.h" -#include "qwt_interval.h" -#include -#include -#include - -class QPainter; -class QPalette; -class QRect; -class QwtText; - -/*! - \brief Directed rectangle representing bounding rectangle und orientation - of a column. -*/ -class QWT_EXPORT QwtColumnRect -{ -public: - //! Direction of the column - enum Direction - { - //! From left to right - LeftToRight, - - //! From right to left - RightToLeft, - - //! From bottom to top - BottomToTop, - - //! From top to bottom - TopToBottom - }; - - //! Build an rectangle with invalid intervals directed BottomToTop. - QwtColumnRect(): - direction( BottomToTop ) - { - } - - //! \return A normalized QRect built from the intervals - QRectF toRect() const - { - QRectF r( hInterval.minValue(), vInterval.minValue(), - hInterval.maxValue() - hInterval.minValue(), - vInterval.maxValue() - vInterval.minValue() ); - r = r.normalized(); - - if ( hInterval.borderFlags() & QwtInterval::ExcludeMinimum ) - r.adjust( 1, 0, 0, 0 ); - if ( hInterval.borderFlags() & QwtInterval::ExcludeMaximum ) - r.adjust( 0, 0, -1, 0 ); - if ( vInterval.borderFlags() & QwtInterval::ExcludeMinimum ) - r.adjust( 0, 1, 0, 0 ); - if ( vInterval.borderFlags() & QwtInterval::ExcludeMaximum ) - r.adjust( 0, 0, 0, -1 ); - - return r; - } - - //! \return Orientation - Qt::Orientation orientation() const - { - if ( direction == LeftToRight || direction == RightToLeft ) - return Qt::Horizontal; - - return Qt::Vertical; - } - - //! Interval for the horizontal coordinates - QwtInterval hInterval; - - //! Interval for the vertical coordinates - QwtInterval vInterval; - - //! Direction - Direction direction; -}; - -//! A drawing primitive for columns -class QWT_EXPORT QwtColumnSymbol -{ -public: - /*! - Style - \sa setStyle(), style() - */ - enum Style - { - //! No Style, the symbol draws nothing - NoStyle = -1, - - /*! - The column is painted with a frame depending on the frameStyle() - and lineWidth() using the palette(). - */ - Box, - - /*! - Styles >= QwtColumnSymbol::UserStyle are reserved for derived - classes of QwtColumnSymbol that overload draw() with - additional application specific symbol types. - */ - UserStyle = 1000 - }; - - /*! - Frame Style used in Box style(). - \sa Style, setFrameStyle(), frameStyle(), setStyle(), setPalette() - */ - enum FrameStyle - { - //! No frame - NoFrame, - - //! A plain frame style - Plain, - - //! A raised frame style - Raised - }; - -public: - QwtColumnSymbol( Style = NoStyle ); - virtual ~QwtColumnSymbol(); - - void setFrameStyle( FrameStyle style ); - FrameStyle frameStyle() const; - - void setLineWidth( int width ); - int lineWidth() const; - - void setPalette( const QPalette & ); - const QPalette &palette() const; - - void setStyle( Style ); - Style style() const; - - virtual void draw( QPainter *, const QwtColumnRect & ) const; - -protected: - void drawBox( QPainter *, const QwtColumnRect & ) const; - -private: - class PrivateData; - PrivateData* d_data; -}; - -#endif diff --git a/qwt/src/qwt_compass.cpp b/qwt/src/qwt_compass.cpp deleted file mode 100644 index 17ab03340..000000000 --- a/qwt/src/qwt_compass.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_compass.h" -#include "qwt_compass_rose.h" -#include "qwt_math.h" -#include "qwt_scale_draw.h" -#include "qwt_painter.h" -#include "qwt_dial_needle.h" -#include -#include -#include - -class QwtCompass::PrivateData -{ -public: - PrivateData(): - rose( NULL ) - { - } - - ~PrivateData() - { - delete rose; - } - - QwtCompassRose *rose; - QMap labelMap; -}; - -/*! - \brief Constructor - \param parent Parent widget - - Create a compass widget with a scale, no needle and no rose. - The default origin is 270.0 with no valid value. It accepts - mouse and keyboard inputs and has no step size. The default mode - is QwtDial::RotateNeedle. -*/ -QwtCompass::QwtCompass( QWidget* parent ): - QwtDial( parent ) -{ - initCompass(); -} - -//! Destructor -QwtCompass::~QwtCompass() -{ - delete d_data; -} - -void QwtCompass::initCompass() -{ - d_data = new PrivateData; - - // Only labels, no backbone, no ticks - setScaleComponents( QwtAbstractScaleDraw::Labels ); - - setOrigin( 270.0 ); - setWrapping( true ); - - - d_data->labelMap.insert( 0.0, QString::fromLatin1( "N" ) ); - d_data->labelMap.insert( 45.0, QString::fromLatin1( "NE" ) ); - d_data->labelMap.insert( 90.0, QString::fromLatin1( "E" ) ); - d_data->labelMap.insert( 135.0, QString::fromLatin1( "SE" ) ); - d_data->labelMap.insert( 180.0, QString::fromLatin1( "S" ) ); - d_data->labelMap.insert( 225.0, QString::fromLatin1( "SW" ) ); - d_data->labelMap.insert( 270.0, QString::fromLatin1( "W" ) ); - d_data->labelMap.insert( 315.0, QString::fromLatin1( "NW" ) ); - -#if 0 - d_data->labelMap.insert( 22.5, QString::fromLatin1( "NNE" ) ); - d_data->labelMap.insert( 67.5, QString::fromLatin1( "NEE" ) ); - d_data->labelMap.insert( 112.5, QString::fromLatin1( "SEE" ) ); - d_data->labelMap.insert( 157.5, QString::fromLatin1( "SSE" ) ); - d_data->labelMap.insert( 202.5, QString::fromLatin1( "SSW" ) ); - d_data->labelMap.insert( 247.5, QString::fromLatin1( "SWW" ) ); - d_data->labelMap.insert( 292.5, QString::fromLatin1( "NWW" ) ); - d_data->labelMap.insert( 337.5, QString::fromLatin1( "NNW" ) ); -#endif -} - -/*! - Draw the contents of the scale - - \param painter Painter - \param center Center of the content circle - \param radius Radius of the content circle -*/ -void QwtCompass::drawScaleContents( QPainter *painter, - const QPointF ¢er, double radius ) const -{ - QPalette::ColorGroup cg; - if ( isEnabled() ) - cg = hasFocus() ? QPalette::Active : QPalette::Inactive; - else - cg = QPalette::Disabled; - - double north = origin(); - if ( isValid() ) - { - if ( mode() == RotateScale ) - north -= value(); - } - - const int margin = 4; - drawRose( painter, center, radius - margin, 360.0 - north, cg ); -} - -/*! - Draw the compass rose - - \param painter Painter - \param center Center of the compass - \param radius of the circle, where to paint the rose - \param north Direction pointing north, in degrees counter clockwise - \param cg Color group -*/ -void QwtCompass::drawRose( QPainter *painter, const QPointF ¢er, - double radius, double north, QPalette::ColorGroup cg ) const -{ - if ( d_data->rose ) - d_data->rose->draw( painter, center, radius, north, cg ); -} - -/*! - Set a rose for the compass - \param rose Compass rose - \warning The rose will be deleted, when a different rose is - set or in ~QwtCompass - \sa rose() -*/ -void QwtCompass::setRose( QwtCompassRose *rose ) -{ - if ( rose != d_data->rose ) - { - if ( d_data->rose ) - delete d_data->rose; - - d_data->rose = rose; - update(); - } -} - -/*! - \return rose - \sa setRose() -*/ -const QwtCompassRose *QwtCompass::rose() const -{ - return d_data->rose; -} - -/*! - \return rose - \sa setRose() -*/ -QwtCompassRose *QwtCompass::rose() -{ - return d_data->rose; -} - -/*! - Handles key events - - Beside the keys described in QwtDial::keyPressEvent numbers - from 1-9 (without 5) set the direction according to their - position on the num pad. - - \sa isReadOnly() -*/ -void QwtCompass::keyPressEvent( QKeyEvent *kev ) -{ - if ( isReadOnly() ) - return; - -#if 0 - if ( kev->key() == Key_5 ) - { - invalidate(); // signal ??? - return; - } -#endif - - double newValue = value(); - - if ( kev->key() >= Qt::Key_1 && kev->key() <= Qt::Key_9 ) - { - if ( mode() != RotateNeedle || kev->key() == Qt::Key_5 ) - return; - - switch ( kev->key() ) - { - case Qt::Key_6: - newValue = 180.0 * 0.0; - break; - case Qt::Key_3: - newValue = 180.0 * 0.25; - break; - case Qt::Key_2: - newValue = 180.0 * 0.5; - break; - case Qt::Key_1: - newValue = 180.0 * 0.75; - break; - case Qt::Key_4: - newValue = 180.0 * 1.0; - break; - case Qt::Key_7: - newValue = 180.0 * 1.25; - break; - case Qt::Key_8: - newValue = 180.0 * 1.5; - break; - case Qt::Key_9: - newValue = 180.0 * 1.75; - break; - } - newValue -= origin(); - setValue( newValue ); - } - else - { - QwtDial::keyPressEvent( kev ); - } -} - -/*! - \return map, mapping values to labels - \sa setLabelMap() -*/ -const QMap &QwtCompass::labelMap() const -{ - return d_data->labelMap; -} - -/*! - \return map, mapping values to labels - \sa setLabelMap() -*/ -QMap &QwtCompass::labelMap() -{ - return d_data->labelMap; -} - -/*! - \brief Set a map, mapping values to labels - \param map value to label map - - The values of the major ticks are found by looking into this - map. The default map consists of the labels N, NE, E, SE, S, SW, W, NW. - - \warning The map will have no effect for values that are no major - tick values. Major ticks can be changed by QwtScaleDraw::setScale - - \sa labelMap(), scaleDraw(), setScale() -*/ -void QwtCompass::setLabelMap( const QMap &map ) -{ - d_data->labelMap = map; -} - -/*! - Map a value to a corresponding label - \param value Value that will be mapped - \return Label, or QString::null - - label() looks in a map for a corresponding label for value - or return an null text. - \sa labelMap(), setLabelMap() -*/ - -QwtText QwtCompass::scaleLabel( double value ) const -{ - if ( qFuzzyCompare( value, 0.0 ) ) - value = 0.0; - - if ( value < 0.0 ) - value += 360.0; - - if ( d_data->labelMap.contains( value ) ) - return d_data->labelMap[value]; - - return QwtText(); -} diff --git a/qwt/src/qwt_compass.h b/qwt/src/qwt_compass.h deleted file mode 100644 index a1044b7f5..000000000 --- a/qwt/src/qwt_compass.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_COMPASS_H -#define QWT_COMPASS_H 1 - -#include "qwt_global.h" -#include "qwt_dial.h" -#include -#include - -class QwtCompassRose; - -/*! - \brief A Compass Widget - - QwtCompass is a widget to display and enter directions. It consists - of a scale, an optional needle and rose. - - \image html dials1.png - - \note The examples/dials example shows how to use QwtCompass. -*/ - -class QWT_EXPORT QwtCompass: public QwtDial -{ - Q_OBJECT - -public: - explicit QwtCompass( QWidget* parent = NULL ); - virtual ~QwtCompass(); - - void setRose( QwtCompassRose *rose ); - const QwtCompassRose *rose() const; - QwtCompassRose *rose(); - - const QMap &labelMap() const; - QMap &labelMap(); - void setLabelMap( const QMap &map ); - -protected: - virtual QwtText scaleLabel( double value ) const; - - virtual void drawRose( QPainter *, const QPointF ¢er, - double radius, double north, QPalette::ColorGroup ) const; - - virtual void drawScaleContents( QPainter *, - const QPointF ¢er, double radius ) const; - - virtual void keyPressEvent( QKeyEvent * ); - -private: - void initCompass(); - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_compass_rose.cpp b/qwt/src/qwt_compass_rose.cpp deleted file mode 100644 index 064e5b14f..000000000 --- a/qwt/src/qwt_compass_rose.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_compass_rose.h" -#include "qwt_point_polar.h" -#include "qwt_painter.h" -#include - -static QPointF qwtIntersection( - QPointF p11, QPointF p12, QPointF p21, QPointF p22 ) -{ - const QLineF line1( p11, p12 ); - const QLineF line2( p21, p22 ); - - QPointF pos; - if ( line1.intersect( line2, &pos ) == QLineF::NoIntersection ) - return QPointF(); - - return pos; -} - -class QwtSimpleCompassRose::PrivateData -{ -public: - PrivateData(): - width( 0.2 ), - numThorns( 8 ), - numThornLevels( -1 ), - shrinkFactor( 0.9 ) - { - } - - double width; - int numThorns; - int numThornLevels; - double shrinkFactor; -}; - -/*! - Constructor - - \param numThorns Number of thorns - \param numThornLevels Number of thorn levels -*/ -QwtSimpleCompassRose::QwtSimpleCompassRose( - int numThorns, int numThornLevels ) -{ - d_data = new PrivateData(); - d_data->numThorns = numThorns; - d_data->numThornLevels = numThornLevels; - - const QColor dark( 128, 128, 255 ); - const QColor light( 192, 255, 255 ); - - QPalette palette; - for ( int i = 0; i < QPalette::NColorGroups; i++ ) - { - palette.setColor( ( QPalette::ColorGroup )i, - QPalette::Dark, dark ); - palette.setColor( ( QPalette::ColorGroup )i, - QPalette::Light, light ); - } - - setPalette( palette ); -} - -//! Destructor -QwtSimpleCompassRose::~QwtSimpleCompassRose() -{ - delete d_data; -} - -/*! - Set the Factor how to shrink the thorns with each level - The default value is 0.9. - - \sa shrinkFactor() -*/ -void QwtSimpleCompassRose::setShrinkFactor( double factor ) -{ - d_data->shrinkFactor = factor; -} - -/*! - \return Factor how to shrink the thorns with each level - \sa setShrinkFactor() -*/ -double QwtSimpleCompassRose::shrinkFactor() const -{ - return d_data->shrinkFactor; -} - -/*! - Draw the rose - - \param painter Painter - \param center Center point - \param radius Radius of the rose - \param north Position - \param cg Color group -*/ -void QwtSimpleCompassRose::draw( QPainter *painter, const QPointF ¢er, - double radius, double north, QPalette::ColorGroup cg ) const -{ - QPalette pal = palette(); - pal.setCurrentColorGroup( cg ); - - drawRose( painter, pal, center, radius, north, d_data->width, - d_data->numThorns, d_data->numThornLevels, d_data->shrinkFactor ); -} - -/*! - Draw the rose - - \param painter Painter - \param palette Palette - \param center Center of the rose - \param radius Radius of the rose - \param north Position pointing to north - \param width Width of the rose - \param numThorns Number of thorns - \param numThornLevels Number of thorn levels - \param shrinkFactor Factor to shrink the thorns with each level -*/ -void QwtSimpleCompassRose::drawRose( - QPainter *painter, - const QPalette &palette, - const QPointF ¢er, double radius, double north, double width, - int numThorns, int numThornLevels, double shrinkFactor ) -{ - if ( numThorns < 4 ) - numThorns = 4; - - if ( numThorns % 4 ) - numThorns += 4 - numThorns % 4; - - if ( numThornLevels <= 0 ) - numThornLevels = numThorns / 4; - - if ( shrinkFactor >= 1.0 ) - shrinkFactor = 1.0; - - if ( shrinkFactor <= 0.5 ) - shrinkFactor = 0.5; - - painter->save(); - - painter->setPen( Qt::NoPen ); - - for ( int j = 1; j <= numThornLevels; j++ ) - { - double step = qPow( 2.0, j ) * M_PI / numThorns; - if ( step > M_PI_2 ) - break; - - double r = radius; - for ( int k = 0; k < 3; k++ ) - { - if ( j + k < numThornLevels ) - r *= shrinkFactor; - } - - double leafWidth = r * width; - if ( 2.0 * M_PI / step > 32 ) - leafWidth = 16; - - const double origin = north / 180.0 * M_PI; - for ( double angle = origin; - angle < 2.0 * M_PI + origin; angle += step ) - { - const QPointF p = qwtPolar2Pos( center, r, angle ); - const QPointF p1 = qwtPolar2Pos( center, leafWidth, angle + M_PI_2 ); - const QPointF p2 = qwtPolar2Pos( center, leafWidth, angle - M_PI_2 ); - const QPointF p3 = qwtPolar2Pos( center, r, angle + step / 2.0 ); - const QPointF p4 = qwtPolar2Pos( center, r, angle - step / 2.0 ); - - QPainterPath darkPath; - darkPath.moveTo( center ); - darkPath.lineTo( p ); - darkPath.lineTo( qwtIntersection( center, p3, p1, p ) ); - - painter->setBrush( palette.brush( QPalette::Dark ) ); - painter->drawPath( darkPath ); - - QPainterPath lightPath; - lightPath.moveTo( center ); - lightPath.lineTo( p ); - lightPath.lineTo( qwtIntersection( center, p4, p2, p ) ); - - painter->setBrush( palette.brush( QPalette::Light ) ); - painter->drawPath( lightPath ); - } - } - painter->restore(); -} - -/*! - Set the width of the rose heads. Lower value make thinner heads. - The range is limited from 0.03 to 0.4. - - \param width Width -*/ -void QwtSimpleCompassRose::setWidth( double width ) -{ - d_data->width = width; - if ( d_data->width < 0.03 ) - d_data->width = 0.03; - - if ( d_data->width > 0.4 ) - d_data->width = 0.4; -} - -//! \sa setWidth() -double QwtSimpleCompassRose::width() const -{ - return d_data->width; -} - -/*! - Set the number of thorns on one level - The number is aligned to a multiple of 4, with a minimum of 4 - - \param numThorns Number of thorns - \sa numThorns(), setNumThornLevels() -*/ -void QwtSimpleCompassRose::setNumThorns( int numThorns ) -{ - if ( numThorns < 4 ) - numThorns = 4; - - if ( numThorns % 4 ) - numThorns += 4 - numThorns % 4; - - d_data->numThorns = numThorns; -} - -/*! - \return Number of thorns - \sa setNumThorns(), setNumThornLevels() -*/ -int QwtSimpleCompassRose::numThorns() const -{ - return d_data->numThorns; -} - -/*! - Set the of thorns levels - - \param numThornLevels Number of thorns levels - \sa setNumThorns(), numThornLevels() -*/ -void QwtSimpleCompassRose::setNumThornLevels( int numThornLevels ) -{ - d_data->numThornLevels = numThornLevels; -} - -/*! - \return Number of thorn levels - \sa setNumThorns(), setNumThornLevels() -*/ -int QwtSimpleCompassRose::numThornLevels() const -{ - return d_data->numThornLevels; -} diff --git a/qwt/src/qwt_compass_rose.h b/qwt/src/qwt_compass_rose.h deleted file mode 100644 index 4272a6e82..000000000 --- a/qwt/src/qwt_compass_rose.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_COMPASS_ROSE_H -#define QWT_COMPASS_ROSE_H 1 - -#include "qwt_global.h" -#include - -class QPainter; - -/*! - \brief Abstract base class for a compass rose -*/ -class QWT_EXPORT QwtCompassRose -{ -public: - //! Destructor - virtual ~QwtCompassRose() {}; - - //! Assign a palette - virtual void setPalette( const QPalette &p ) - { - d_palette = p; - } - - //! \return Current palette - const QPalette &palette() const - { - return d_palette; - } - - /*! - Draw the rose - - \param painter Painter - \param center Center point - \param radius Radius of the rose - \param north Position - \param colorGroup Color group - */ - virtual void draw( QPainter *painter, - const QPointF ¢er, double radius, double north, - QPalette::ColorGroup colorGroup = QPalette::Active ) const = 0; - -private: - QPalette d_palette; -}; - -/*! - \brief A simple rose for QwtCompass -*/ -class QWT_EXPORT QwtSimpleCompassRose: public QwtCompassRose -{ -public: - QwtSimpleCompassRose( int numThorns = 8, int numThornLevels = -1 ); - virtual ~QwtSimpleCompassRose(); - - void setWidth( double w ); - double width() const; - - void setNumThorns( int count ); - int numThorns() const; - - void setNumThornLevels( int count ); - int numThornLevels() const; - - void setShrinkFactor( double factor ); - double shrinkFactor() const; - - virtual void draw( QPainter *, const QPointF ¢er, double radius, - double north, QPalette::ColorGroup = QPalette::Active ) const; - - static void drawRose( QPainter *, const QPalette &, - const QPointF ¢er, double radius, double origin, double width, - int numThorns, int numThornLevels, double shrinkFactor ); - -private: - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_compat.h b/qwt/src/qwt_compat.h deleted file mode 100644 index dc74a5d28..000000000 --- a/qwt/src/qwt_compat.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef _QWT_COMPAT_H_ -#define _QWT_COMPAT_H_ - -#include "qwt_global.h" -#include -#include -#include -#include -#include -#include - -// A couple of definition for Qwt5 compatibility - -#define qwtMax qMax -#define qwtMin qMin -#define qwtAbs qAbs -#define qwtRound qRound - -#define QwtArray QVector - -typedef QList QwtValueList; -typedef QPointF QwtDoublePoint; -typedef QSizeF QwtDoubleSize; -typedef QRectF QwtDoubleRect; - -typedef QPolygon QwtPolygon; -typedef QPolygonF QwtPolygonF; -typedef QwtInterval QwtDoubleInterval; -typedef QwtPoint3D QwtDoublePoint3D; - -#endif diff --git a/qwt/src/qwt_counter.cpp b/qwt/src/qwt_counter.cpp deleted file mode 100644 index 8ecc89c39..000000000 --- a/qwt/src/qwt_counter.cpp +++ /dev/null @@ -1,602 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_arrow_button.h" -#include "qwt_math.h" -#include "qwt_counter.h" -#include -#include -#include -#include -#include - -class QwtCounter::PrivateData -{ -public: - PrivateData(): - editable( true ) - { - increment[Button1] = 1; - increment[Button2] = 10; - increment[Button3] = 100; - } - - QwtArrowButton *buttonDown[ButtonCnt]; - QwtArrowButton *buttonUp[ButtonCnt]; - QLineEdit *valueEdit; - - int increment[ButtonCnt]; - int numButtons; - - bool editable; -}; - -/*! - The default number of buttons is set to 2. The default increments are: - \li Button 1: 1 step - \li Button 2: 10 steps - \li Button 3: 100 steps - - \param parent - */ -QwtCounter::QwtCounter( QWidget *parent ): - QWidget( parent ) -{ - initCounter(); -} - -void QwtCounter::initCounter() -{ - d_data = new PrivateData; - - QHBoxLayout *layout = new QHBoxLayout( this ); - layout->setSpacing( 0 ); - layout->setMargin( 0 ); - - for ( int i = ButtonCnt - 1; i >= 0; i-- ) - { - QwtArrowButton *btn = - new QwtArrowButton( i + 1, Qt::DownArrow, this ); - btn->setFocusPolicy( Qt::NoFocus ); - btn->installEventFilter( this ); - layout->addWidget( btn ); - - connect( btn, SIGNAL( released() ), SLOT( btnReleased() ) ); - connect( btn, SIGNAL( clicked() ), SLOT( btnClicked() ) ); - - d_data->buttonDown[i] = btn; - } - - d_data->valueEdit = new QLineEdit( this ); - d_data->valueEdit->setReadOnly( false ); - d_data->valueEdit->setValidator( new QDoubleValidator( d_data->valueEdit ) ); - layout->addWidget( d_data->valueEdit ); - - connect( d_data->valueEdit, SIGNAL( editingFinished() ), - SLOT( textChanged() ) ); - - layout->setStretchFactor( d_data->valueEdit, 10 ); - - for ( int i = 0; i < ButtonCnt; i++ ) - { - QwtArrowButton *btn = - new QwtArrowButton( i + 1, Qt::UpArrow, this ); - btn->setFocusPolicy( Qt::NoFocus ); - btn->installEventFilter( this ); - layout->addWidget( btn ); - - connect( btn, SIGNAL( released() ), SLOT( btnReleased() ) ); - connect( btn, SIGNAL( clicked() ), SLOT( btnClicked() ) ); - - d_data->buttonUp[i] = btn; - } - - setNumButtons( 2 ); - setRange( 0.0, 1.0, 0.001 ); - setValue( 0.0 ); - - setSizePolicy( - QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) ); - - setFocusProxy( d_data->valueEdit ); - setFocusPolicy( Qt::StrongFocus ); -} - -//! Destructor -QwtCounter::~QwtCounter() -{ - delete d_data; -} - -//! Set from lineedit -void QwtCounter::textChanged() -{ - if ( !d_data->editable ) - return; - - bool converted = false; - - const double value = d_data->valueEdit->text().toDouble( &converted ); - if ( converted ) - setValue( value ); -} - -/** - \brief Allow/disallow the user to manually edit the value - - \param editable true enables editing - \sa editable() -*/ -void QwtCounter::setEditable( bool editable ) -{ - if ( editable == d_data->editable ) - return; - - d_data->editable = editable; - d_data->valueEdit->setReadOnly( !editable ); -} - -//! returns whether the line edit is edatble. (default is yes) -bool QwtCounter::editable() const -{ - return d_data->editable; -} - -/*! - Handle PolishRequest events - \param event Event -*/ -bool QwtCounter::event( QEvent *event ) -{ - if ( event->type() == QEvent::PolishRequest ) - { - const int w = d_data->valueEdit->fontMetrics().width( "W" ) + 8; - for ( int i = 0; i < ButtonCnt; i++ ) - { - d_data->buttonDown[i]->setMinimumWidth( w ); - d_data->buttonUp[i]->setMinimumWidth( w ); - } - } - - return QWidget::event( event ); -} - -/*! - Handle key events - - - Ctrl + Qt::Key_Home\n - Step to minValue() - - Ctrl + Qt::Key_End\n - Step to maxValue() - - Qt::Key_Up\n - Increment by incSteps(QwtCounter::Button1) - - Qt::Key_Down\n - Decrement by incSteps(QwtCounter::Button1) - - Qt::Key_PageUp\n - Increment by incSteps(QwtCounter::Button2) - - Qt::Key_PageDown\n - Decrement by incSteps(QwtCounter::Button2) - - Shift + Qt::Key_PageUp\n - Increment by incSteps(QwtCounter::Button3) - - Shift + Qt::Key_PageDown\n - Decrement by incSteps(QwtCounter::Button3) - - \param event Key event -*/ -void QwtCounter::keyPressEvent ( QKeyEvent *event ) -{ - bool accepted = true; - - switch ( event->key() ) - { - case Qt::Key_Home: - { - if ( event->modifiers() & Qt::ControlModifier ) - setValue( minValue() ); - else - accepted = false; - break; - } - case Qt::Key_End: - { - if ( event->modifiers() & Qt::ControlModifier ) - setValue( maxValue() ); - else - accepted = false; - break; - } - case Qt::Key_Up: - { - incValue( d_data->increment[0] ); - break; - } - case Qt::Key_Down: - { - incValue( -d_data->increment[0] ); - break; - } - case Qt::Key_PageUp: - case Qt::Key_PageDown: - { - int increment = d_data->increment[0]; - if ( d_data->numButtons >= 2 ) - increment = d_data->increment[1]; - if ( d_data->numButtons >= 3 ) - { - if ( event->modifiers() & Qt::ShiftModifier ) - increment = d_data->increment[2]; - } - if ( event->key() == Qt::Key_PageDown ) - increment = -increment; - incValue( increment ); - break; - } - default: - { - accepted = false; - } - } - - if ( accepted ) - { - event->accept(); - return; - } - - QWidget::keyPressEvent ( event ); -} - -/*! - Handle wheel events - \param event Wheel event -*/ -void QwtCounter::wheelEvent( QWheelEvent *event ) -{ - event->accept(); - - if ( d_data->numButtons <= 0 ) - return; - - int increment = d_data->increment[0]; - if ( d_data->numButtons >= 2 ) - { - if ( event->modifiers() & Qt::ControlModifier ) - increment = d_data->increment[1]; - } - if ( d_data->numButtons >= 3 ) - { - if ( event->modifiers() & Qt::ShiftModifier ) - increment = d_data->increment[2]; - } - - for ( int i = 0; i < d_data->numButtons; i++ ) - { - if ( d_data->buttonDown[i]->geometry().contains( event->pos() ) || - d_data->buttonUp[i]->geometry().contains( event->pos() ) ) - { - increment = d_data->increment[i]; - } - } - - const int wheel_delta = 120; - - int delta = event->delta(); - if ( delta >= 2 * wheel_delta ) - delta /= 2; // Never saw an abs(delta) < 240 - - incValue( delta / wheel_delta * increment ); -} - -/*! - Specify the number of steps by which the value - is incremented or decremented when a specified button - is pushed. - - \param button Button index - \param nSteps Number of steps - - \sa incSteps() -*/ -void QwtCounter::setIncSteps( QwtCounter::Button button, int nSteps ) -{ - if ( button >= 0 && button < ButtonCnt ) - d_data->increment[button] = nSteps; -} - -/*! - \return the number of steps by which a specified button increments the value - or 0 if the button is invalid. - \param button Button index - - \sa setIncSteps() -*/ -int QwtCounter::incSteps( QwtCounter::Button button ) const -{ - if ( button >= 0 && button < ButtonCnt ) - return d_data->increment[button]; - - return 0; -} - -/*! - \brief Set a new value - - Calls QwtDoubleRange::setValue and does all visual updates. - - \param value New value - \sa QwtDoubleRange::setValue() -*/ - -void QwtCounter::setValue( double value ) -{ - QwtDoubleRange::setValue( value ); - - showNum( this->value() ); - updateButtons(); -} - -/*! - \brief Notify a change of value -*/ -void QwtCounter::valueChange() -{ - if ( isValid() ) - showNum( value() ); - else - d_data->valueEdit->setText( QString::null ); - - updateButtons(); - - if ( isValid() ) - Q_EMIT valueChanged( value() ); -} - -/*! - \brief Update buttons according to the current value - - When the QwtCounter under- or over-flows, the focus is set to the smallest - up- or down-button and counting is disabled. - - Counting is re-enabled on a button release event (mouse or space bar). -*/ -void QwtCounter::updateButtons() -{ - if ( isValid() ) - { - // 1. save enabled state of the smallest down- and up-button - // 2. change enabled state on under- or over-flow - - for ( int i = 0; i < QwtCounter::ButtonCnt; i++ ) - { - d_data->buttonDown[i]->setEnabled( value() > minValue() ); - d_data->buttonUp[i]->setEnabled( value() < maxValue() ); - } - } - else - { - for ( int i = 0; i < QwtCounter::ButtonCnt; i++ ) - { - d_data->buttonDown[i]->setEnabled( false ); - d_data->buttonUp[i]->setEnabled( false ); - } - } -} - -/*! - \brief Specify the number of buttons on each side of the label - \param numButtons Number of buttons -*/ -void QwtCounter::setNumButtons( int numButtons ) -{ - if ( numButtons < 0 || numButtons > QwtCounter::ButtonCnt ) - return; - - for ( int i = 0; i < QwtCounter::ButtonCnt; i++ ) - { - if ( i < numButtons ) - { - d_data->buttonDown[i]->show(); - d_data->buttonUp[i]->show(); - } - else - { - d_data->buttonDown[i]->hide(); - d_data->buttonUp[i]->hide(); - } - } - - d_data->numButtons = numButtons; -} - -/*! - \return The number of buttons on each side of the widget. -*/ -int QwtCounter::numButtons() const -{ - return d_data->numButtons; -} - -/*! - Display number string - - \param number Number -*/ -void QwtCounter::showNum( double number ) -{ - QString text; - text.setNum( number ); - - const int cursorPos = d_data->valueEdit->cursorPosition(); - d_data->valueEdit->setText( text ); - d_data->valueEdit->setCursorPosition( cursorPos ); -} - -//! Button clicked -void QwtCounter::btnClicked() -{ - for ( int i = 0; i < ButtonCnt; i++ ) - { - if ( d_data->buttonUp[i] == sender() ) - incValue( d_data->increment[i] ); - - if ( d_data->buttonDown[i] == sender() ) - incValue( -d_data->increment[i] ); - } -} - -//! Button released -void QwtCounter::btnReleased() -{ - Q_EMIT buttonReleased( value() ); -} - -/*! - \brief Notify change of range - - This function updates the enabled property of - all buttons contained in QwtCounter. -*/ -void QwtCounter::rangeChange() -{ - updateButtons(); -} - -//! A size hint -QSize QwtCounter::sizeHint() const -{ - QString tmp; - - int w = tmp.setNum( minValue() ).length(); - int w1 = tmp.setNum( maxValue() ).length(); - if ( w1 > w ) - w = w1; - w1 = tmp.setNum( minValue() + step() ).length(); - if ( w1 > w ) - w = w1; - w1 = tmp.setNum( maxValue() - step() ).length(); - if ( w1 > w ) - w = w1; - - tmp.fill( '9', w ); - - QFontMetrics fm( d_data->valueEdit->font() ); - w = fm.width( tmp ) + 2; - if ( d_data->valueEdit->hasFrame() ) - w += 2 * style()->pixelMetric( QStyle::PM_DefaultFrameWidth ); - - // Now we replace default sizeHint contribution of d_data->valueEdit by - // what we really need. - - w += QWidget::sizeHint().width() - d_data->valueEdit->sizeHint().width(); - - const int h = qMin( QWidget::sizeHint().height(), - d_data->valueEdit->minimumSizeHint().height() ); - return QSize( w, h ); -} - -//! returns the step size -double QwtCounter::step() const -{ - return QwtDoubleRange::step(); -} - -/*! - Set the step size - \param stepSize Step size - \sa QwtDoubleRange::setStep() -*/ -void QwtCounter::setStep( double stepSize ) -{ - QwtDoubleRange::setStep( stepSize ); -} - -//! returns the minimum value of the range -double QwtCounter::minValue() const -{ - return QwtDoubleRange::minValue(); -} - -/*! - Set the minimum value of the range - - \param value Minimum value - \sa setMaxValue(), minValue() -*/ -void QwtCounter::setMinValue( double value ) -{ - setRange( value, maxValue(), step() ); -} - -//! returns the maximum value of the range -double QwtCounter::maxValue() const -{ - return QwtDoubleRange::maxValue(); -} - -/*! - Set the maximum value of the range - - \param value Maximum value - \sa setMinValue(), maxVal() -*/ -void QwtCounter::setMaxValue( double value ) -{ - setRange( minValue(), value, step() ); -} - -/*! - Set the number of increment steps for button 1 - \param nSteps Number of steps -*/ -void QwtCounter::setStepButton1( int nSteps ) -{ - setIncSteps( Button1, nSteps ); -} - -//! returns the number of increment steps for button 1 -int QwtCounter::stepButton1() const -{ - return incSteps( Button1 ); -} - -/*! - Set the number of increment steps for button 2 - \param nSteps Number of steps -*/ -void QwtCounter::setStepButton2( int nSteps ) -{ - setIncSteps( Button2, nSteps ); -} - -//! returns the number of increment steps for button 2 -int QwtCounter::stepButton2() const -{ - return incSteps( Button2 ); -} - -/*! - Set the number of increment steps for button 3 - \param nSteps Number of steps -*/ -void QwtCounter::setStepButton3( int nSteps ) -{ - setIncSteps( Button3, nSteps ); -} - -//! returns the number of increment steps for button 3 -int QwtCounter::stepButton3() const -{ - return incSteps( Button3 ); -} - -//! \return Current value -double QwtCounter::value() const -{ - return QwtDoubleRange::value(); -} diff --git a/qwt/src/qwt_counter.h b/qwt/src/qwt_counter.h deleted file mode 100644 index b3f4ad549..000000000 --- a/qwt/src/qwt_counter.h +++ /dev/null @@ -1,160 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_COUNTER_H -#define QWT_COUNTER_H - -#include "qwt_global.h" -#include "qwt_double_range.h" -#include - -/*! - \brief The Counter Widget - - A Counter consists of a label displaying a number and - one ore more (up to three) push buttons on each side - of the label which can be used to increment or decrement - the counter's value. - - A Counter has a range from a minimum value to a maximum value - and a step size. The range can be specified using - QwtDblRange::setRange(). - The counter's value is an integer multiple of the step size. - The number of steps by which a button increments or decrements - the value can be specified using QwtCounter::setIncSteps(). - The number of buttons can be changed with - QwtCounter::setNumButtons(). - - Holding the space bar down with focus on a button is the - fastest method to step through the counter values. - When the counter underflows/overflows, the focus is set - to the smallest up/down button and counting is disabled. - Counting is re-enabled on a button release event (mouse or - space bar). - - Example: -\code -#include "../include/qwt_counter.h> - -QwtCounter *cnt; - -cnt = new QwtCounter(parent, name); - -cnt->setRange(0.0, 100.0, 1.0); // From 0.0 to 100, step 1.0 -cnt->setNumButtons(2); // Two buttons each side -cnt->setIncSteps(QwtCounter::Button1, 1); // Button 1 increments 1 step -cnt->setIncSteps(QwtCounter::Button2, 20); // Button 2 increments 20 steps - -connect(cnt, SIGNAL(valueChanged(double)), my_class, SLOT(newValue(double))); -\endcode - */ - -class QWT_EXPORT QwtCounter : public QWidget, public QwtDoubleRange -{ - Q_OBJECT - - Q_PROPERTY( int numButtons READ numButtons WRITE setNumButtons ) - Q_PROPERTY( double basicstep READ step WRITE setStep ) - Q_PROPERTY( double minValue READ minValue WRITE setMinValue ) - Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue ) - Q_PROPERTY( int stepButton1 READ stepButton1 WRITE setStepButton1 ) - Q_PROPERTY( int stepButton2 READ stepButton2 WRITE setStepButton2 ) - Q_PROPERTY( int stepButton3 READ stepButton3 WRITE setStepButton3 ) - Q_PROPERTY( double value READ value WRITE setValue ) - Q_PROPERTY( bool editable READ editable WRITE setEditable ) - -public: - //! Button index - enum Button - { - //! Button intended for minor steps - Button1, - - //! Button intended for medium steps - Button2, - - //! Button intended for large steps - Button3, - - //! Number of buttons - ButtonCnt - }; - - explicit QwtCounter( QWidget *parent = NULL ); - virtual ~QwtCounter(); - - bool editable() const; - void setEditable( bool ); - - void setNumButtons( int n ); - int numButtons() const; - - void setIncSteps( QwtCounter::Button btn, int nSteps ); - int incSteps( QwtCounter::Button btn ) const; - - virtual void setValue( double ); - virtual QSize sizeHint() const; - - // a set of dummies to help the designer - - double step() const; - void setStep( double s ); - - double minValue() const; - void setMinValue( double m ); - - double maxValue() const; - void setMaxValue( double m ); - - void setStepButton1( int nSteps ); - int stepButton1() const; - - void setStepButton2( int nSteps ); - int stepButton2() const; - - void setStepButton3( int nSteps ); - int stepButton3() const; - - virtual double value() const; - -Q_SIGNALS: - /*! - This signal is emitted when a button has been released - \param value The new value - */ - void buttonReleased ( double value ); - - /*! - This signal is emitted when the counter's value has changed - \param value The new value - */ - void valueChanged ( double value ); - -protected: - virtual bool event( QEvent * ); - virtual void wheelEvent( QWheelEvent * ); - virtual void keyPressEvent( QKeyEvent * ); - virtual void rangeChange(); - -private Q_SLOTS: - void btnReleased(); - void btnClicked(); - void textChanged(); - -private: - void initCounter(); - void updateButtons(); - void showNum( double ); - virtual void valueChange(); - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_curve_fitter.cpp b/qwt/src/qwt_curve_fitter.cpp deleted file mode 100644 index 639a80dab..000000000 --- a/qwt/src/qwt_curve_fitter.cpp +++ /dev/null @@ -1,405 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_curve_fitter.h" -#include "qwt_math.h" -#include "qwt_spline.h" -#include -#include - -#if QT_VERSION < 0x040601 -#define qFabs(x) ::fabs(x) -#endif - -//! Constructor -QwtCurveFitter::QwtCurveFitter() -{ -} - -//! Destructor -QwtCurveFitter::~QwtCurveFitter() -{ -} - -class QwtSplineCurveFitter::PrivateData -{ -public: - PrivateData(): - fitMode( QwtSplineCurveFitter::Auto ), - splineSize( 250 ) - { - } - - QwtSpline spline; - QwtSplineCurveFitter::FitMode fitMode; - int splineSize; -}; - -//! Constructor -QwtSplineCurveFitter::QwtSplineCurveFitter() -{ - d_data = new PrivateData; -} - -//! Destructor -QwtSplineCurveFitter::~QwtSplineCurveFitter() -{ - delete d_data; -} - -/*! - Select the algorithm used for building the spline - - \param mode Mode representing a spline algorithm - \sa fitMode() -*/ -void QwtSplineCurveFitter::setFitMode( FitMode mode ) -{ - d_data->fitMode = mode; -} - -/*! - \return Mode representing a spline algorithm - \sa setFitMode() -*/ -QwtSplineCurveFitter::FitMode QwtSplineCurveFitter::fitMode() const -{ - return d_data->fitMode; -} - -/*! - Assign a spline - - \param spline Spline - \sa spline() -*/ -void QwtSplineCurveFitter::setSpline( const QwtSpline &spline ) -{ - d_data->spline = spline; - d_data->spline.reset(); -} - -/*! - \return Spline - \sa setSpline() -*/ -const QwtSpline &QwtSplineCurveFitter::spline() const -{ - return d_data->spline; -} - -/*! - \return Spline - \sa setSpline() -*/ -QwtSpline &QwtSplineCurveFitter::spline() -{ - return d_data->spline; -} - -/*! - Assign a spline size ( has to be at least 10 points ) - - \param splineSize Spline size - \sa splineSize() -*/ -void QwtSplineCurveFitter::setSplineSize( int splineSize ) -{ - d_data->splineSize = qMax( splineSize, 10 ); -} - -/*! - \return Spline size - \sa setSplineSize() -*/ -int QwtSplineCurveFitter::splineSize() const -{ - return d_data->splineSize; -} - -/*! - Find a curve which has the best fit to a series of data points - - \param points Series of data points - \return Curve points -*/ -QPolygonF QwtSplineCurveFitter::fitCurve( const QPolygonF &points ) const -{ - const int size = points.size(); - if ( size <= 2 ) - return points; - - FitMode fitMode = d_data->fitMode; - if ( fitMode == Auto ) - { - fitMode = Spline; - - const QPointF *p = points.data(); - for ( int i = 1; i < size; i++ ) - { - if ( p[i].x() <= p[i-1].x() ) - { - fitMode = ParametricSpline; - break; - } - }; - } - - if ( fitMode == ParametricSpline ) - return fitParametric( points ); - else - return fitSpline( points ); -} - -QPolygonF QwtSplineCurveFitter::fitSpline( const QPolygonF &points ) const -{ - d_data->spline.setPoints( points ); - if ( !d_data->spline.isValid() ) - return points; - - QPolygonF fittedPoints( d_data->splineSize ); - - const double x1 = points[0].x(); - const double x2 = points[int( points.size() - 1 )].x(); - const double dx = x2 - x1; - const double delta = dx / ( d_data->splineSize - 1 ); - - for ( int i = 0; i < d_data->splineSize; i++ ) - { - QPointF &p = fittedPoints[i]; - - const double v = x1 + i * delta; - const double sv = d_data->spline.value( v ); - - p.setX( v ); - p.setY( sv ); - } - d_data->spline.reset(); - - return fittedPoints; -} - -QPolygonF QwtSplineCurveFitter::fitParametric( const QPolygonF &points ) const -{ - int i; - const int size = points.size(); - - QPolygonF fittedPoints( d_data->splineSize ); - QPolygonF splinePointsX( size ); - QPolygonF splinePointsY( size ); - - const QPointF *p = points.data(); - QPointF *spX = splinePointsX.data(); - QPointF *spY = splinePointsY.data(); - - double param = 0.0; - for ( i = 0; i < size; i++ ) - { - const double x = p[i].x(); - const double y = p[i].y(); - if ( i > 0 ) - { - const double delta = qSqrt( qwtSqr( x - spX[i-1].y() ) - + qwtSqr( y - spY[i-1].y() ) ); - param += qMax( delta, 1.0 ); - } - spX[i].setX( param ); - spX[i].setY( x ); - spY[i].setX( param ); - spY[i].setY( y ); - } - - d_data->spline.setPoints( splinePointsX ); - if ( !d_data->spline.isValid() ) - return points; - - const double deltaX = - splinePointsX[size - 1].x() / ( d_data->splineSize - 1 ); - for ( i = 0; i < d_data->splineSize; i++ ) - { - const double dtmp = i * deltaX; - fittedPoints[i].setX( d_data->spline.value( dtmp ) ); - } - - d_data->spline.setPoints( splinePointsY ); - if ( !d_data->spline.isValid() ) - return points; - - const double deltaY = - splinePointsY[size - 1].x() / ( d_data->splineSize - 1 ); - for ( i = 0; i < d_data->splineSize; i++ ) - { - const double dtmp = i * deltaY; - fittedPoints[i].setY( d_data->spline.value( dtmp ) ); - } - - return fittedPoints; -} - -class QwtWeedingCurveFitter::PrivateData -{ -public: - PrivateData(): - tolerance( 1.0 ) - { - } - - double tolerance; -}; - -class QwtWeedingCurveFitter::Line -{ -public: - Line( int i1 = 0, int i2 = 0 ): - from( i1 ), - to( i2 ) - { - } - - int from; - int to; -}; - -/*! - Constructor - - \param tolerance Tolerance - \sa setTolerance(), tolerance() -*/ -QwtWeedingCurveFitter::QwtWeedingCurveFitter( double tolerance ) -{ - d_data = new PrivateData; - setTolerance( tolerance ); -} - -//! Destructor -QwtWeedingCurveFitter::~QwtWeedingCurveFitter() -{ - delete d_data; -} - -/*! - Assign the tolerance - - The tolerance is the maximum distance, that is accaptable - between the original curve and the smoothed curve. - - Increasing the tolerance will reduce the number of the - resulting points. - - \param tolerance Tolerance - - \sa tolerance() -*/ -void QwtWeedingCurveFitter::setTolerance( double tolerance ) -{ - d_data->tolerance = qMax( tolerance, 0.0 ); -} - -/*! - \return Tolerance - \sa setTolerance() -*/ -double QwtWeedingCurveFitter::tolerance() const -{ - return d_data->tolerance; -} - -/*! - \param points Series of data points - \return Curve points -*/ -QPolygonF QwtWeedingCurveFitter::fitCurve( const QPolygonF &points ) const -{ - QStack stack; - stack.reserve( 500 ); - - const QPointF *p = points.data(); - const int nPoints = points.size(); - - QVector usePoint( nPoints, false ); - - double distToSegment; - - stack.push( Line( 0, nPoints - 1 ) ); - - while ( !stack.isEmpty() ) - { - const Line r = stack.pop(); - - // initialize line segment - const double vecX = p[r.to].x() - p[r.from].x(); - const double vecY = p[r.to].y() - p[r.from].y(); - - const double vecLength = qSqrt( vecX * vecX + vecY * vecY ); - - const double unitVecX = ( vecLength != 0.0 ) ? vecX / vecLength : 0.0; - const double unitVecY = ( vecLength != 0.0 ) ? vecY / vecLength : 0.0; - - double maxDist = 0.0; - int nVertexIndexMaxDistance = r.from + 1; - for ( int i = r.from + 1; i < r.to; i++ ) - { - //compare to anchor - const double fromVecX = p[i].x() - p[r.from].x(); - const double fromVecY = p[i].y() - p[r.from].y(); - const double fromVecLength = - qSqrt( fromVecX * fromVecX + fromVecY * fromVecY ); - - if ( fromVecX * unitVecX + fromVecY * unitVecY < 0.0 ) - { - distToSegment = fromVecLength; - } - if ( fromVecX * unitVecX + fromVecY * unitVecY < 0.0 ) - { - distToSegment = fromVecLength; - } - else - { - const double toVecX = p[i].x() - p[r.to].x(); - const double toVecY = p[i].y() - p[r.to].y(); - const double toVecLength = qSqrt( toVecX * toVecX + toVecY * toVecY ); - const double s = toVecX * ( -unitVecX ) + toVecY * ( -unitVecY ); - if ( s < 0.0 ) - distToSegment = toVecLength; - else - { - distToSegment = qSqrt( qFabs( toVecLength * toVecLength - s * s ) ); - } - } - - if ( maxDist < distToSegment ) - { - maxDist = distToSegment; - nVertexIndexMaxDistance = i; - } - } - if ( maxDist <= d_data->tolerance ) - { - usePoint[r.from] = true; - usePoint[r.to] = true; - } - else - { - stack.push( Line( r.from, nVertexIndexMaxDistance ) ); - stack.push( Line( nVertexIndexMaxDistance, r.to ) ); - } - } - - int cnt = 0; - - QPolygonF stripped( nPoints ); - for ( int i = 0; i < nPoints; i++ ) - { - if ( usePoint[i] ) - stripped[cnt++] = p[i]; - } - stripped.resize( cnt ); - return stripped; -} diff --git a/qwt/src/qwt_curve_fitter.h b/qwt/src/qwt_curve_fitter.h deleted file mode 100644 index c9ae60373..000000000 --- a/qwt/src/qwt_curve_fitter.h +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_CURVE_FITTER_H -#define QWT_CURVE_FITTER_H - -#include "qwt_global.h" -#include -#include - -class QwtSpline; - -/*! - \brief Abstract base class for a curve fitter -*/ -class QWT_EXPORT QwtCurveFitter -{ -public: - virtual ~QwtCurveFitter(); - - /*! - Find a curve which has the best fit to a series of data points - - \param polygon Series of data points - \return Curve points - */ - virtual QPolygonF fitCurve( const QPolygonF &polygon ) const = 0; - -protected: - QwtCurveFitter(); - -private: - QwtCurveFitter( const QwtCurveFitter & ); - QwtCurveFitter &operator=( const QwtCurveFitter & ); -}; - -/*! - \brief A curve fitter using cubic splines -*/ -class QWT_EXPORT QwtSplineCurveFitter: public QwtCurveFitter -{ -public: - /*! - Spline type - The default setting is Auto - \sa setFitMode(), FitMode() - */ - enum FitMode - { - /*! - Use the default spline algorithm for polygons with - increasing x values ( p[i-1] < p[i] ), otherwise use - a parametric spline algorithm. - */ - Auto, - - //! Use a default spline algorithm - Spline, - - //! Use a parametric spline algorithm - ParametricSpline - }; - - QwtSplineCurveFitter(); - virtual ~QwtSplineCurveFitter(); - - void setFitMode( FitMode ); - FitMode fitMode() const; - - void setSpline( const QwtSpline& ); - const QwtSpline &spline() const; - QwtSpline &spline(); - - void setSplineSize( int size ); - int splineSize() const; - - virtual QPolygonF fitCurve( const QPolygonF & ) const; - -private: - QPolygonF fitSpline( const QPolygonF & ) const; - QPolygonF fitParametric( const QPolygonF & ) const; - - class PrivateData; - PrivateData *d_data; -}; - -/*! - \brief A curve fitter implementing Douglas and Peucker algorithm - - The purpose of the Douglas and Peucker algorithm is that given a 'curve' - composed of line segments to find a curve not too dissimilar but that - has fewer points. The algorithm defines 'too dissimilar' based on the - maximum distance (tolerance) between the original curve and the - smoothed curve. - - The smoothed curve consists of a subset of the points that defined the - original curve. - - In opposite to QwtSplineCurveFitter the Douglas and Peucker algorithm reduces - the number of points. By adjusting the tolerance parameter according to the - axis scales QwtSplineCurveFitter can be used to implement different - level of details to speed up painting of curves of many points. -*/ -class QWT_EXPORT QwtWeedingCurveFitter: public QwtCurveFitter -{ -public: - QwtWeedingCurveFitter( double tolerance = 1.0 ); - virtual ~QwtWeedingCurveFitter(); - - void setTolerance( double ); - double tolerance() const; - - virtual QPolygonF fitCurve( const QPolygonF & ) const; - -private: - class Line; - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_dial.cpp b/qwt/src/qwt_dial.cpp deleted file mode 100644 index 4df7d0a33..000000000 --- a/qwt/src/qwt_dial.cpp +++ /dev/null @@ -1,1155 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_dial.h" -#include "qwt_dial_needle.h" -#include "qwt_math.h" -#include "qwt_scale_engine.h" -#include "qwt_scale_map.h" -#include "qwt_painter.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if QT_VERSION < 0x040601 -#define qAtan(x) ::atan(x) -#endif - -class QwtDial::PrivateData -{ -public: - PrivateData(): - frameShadow( Sunken ), - lineWidth( 0 ), - mode( RotateNeedle ), - direction( Clockwise ), - origin( 90.0 ), - minScaleArc( 0.0 ), - maxScaleArc( 0.0 ), - scaleDraw( 0 ), - maxMajIntv( 36 ), - maxMinIntv( 10 ), - scaleStep( 0.0 ), - needle( 0 ) - { - } - - ~PrivateData() - { - delete scaleDraw; - delete needle; - } - Shadow frameShadow; - int lineWidth; - - QwtDial::Mode mode; - QwtDial::Direction direction; - - double origin; - double minScaleArc; - double maxScaleArc; - - QwtDialScaleDraw *scaleDraw; - int maxMajIntv; - int maxMinIntv; - double scaleStep; - - QwtDialNeedle *needle; - - static double previousDir; -}; - -double QwtDial::PrivateData::previousDir = -1.0; - -/*! - Constructor - - \param parent Parent dial widget -*/ -QwtDialScaleDraw::QwtDialScaleDraw( QwtDial *parent ): - d_parent( parent ), - d_penWidth( 1.0 ) -{ -} - -/*! - Set the pen width used for painting the scale - - \param penWidth Pen width - \sa penWidth(), QwtDial::drawScale() -*/ - -void QwtDialScaleDraw::setPenWidth( double penWidth ) -{ - d_penWidth = qMax( penWidth, 0.0 ); -} - -/*! - \return Pen width used for painting the scale - \sa setPenWidth, QwtDial::drawScale() -*/ -double QwtDialScaleDraw::penWidth() const -{ - return d_penWidth; -} - -/*! - Call QwtDial::scaleLabel of the parent dial widget. - - \param value Value to display - - \sa QwtDial::scaleLabel() -*/ -QwtText QwtDialScaleDraw::label( double value ) const -{ - if ( d_parent == NULL ) - return QwtRoundScaleDraw::label( value ); - - return d_parent->scaleLabel( value ); -} - -/*! - \brief Constructor - \param parent Parent widget - - Create a dial widget with no scale and no needle. - The default origin is 90.0 with no valid value. It accepts - mouse and keyboard inputs and has no step size. The default mode - is QwtDial::RotateNeedle. -*/ -QwtDial::QwtDial( QWidget* parent ): - QwtAbstractSlider( Qt::Horizontal, parent ) -{ - initDial(); -} - -void QwtDial::initDial() -{ - d_data = new PrivateData; - - setFocusPolicy( Qt::TabFocus ); - - QPalette p = palette(); - for ( int i = 0; i < QPalette::NColorGroups; i++ ) - { - const QPalette::ColorGroup cg = ( QPalette::ColorGroup )i; - - // Base: background color of the circle inside the frame. - // WindowText: background color of the circle inside the scale - - p.setColor( cg, QPalette::WindowText, - p.color( cg, QPalette::Base ) ); - } - setPalette( p ); - - d_data->scaleDraw = new QwtDialScaleDraw( this ); - d_data->scaleDraw->setRadius( 0 ); - - setScaleArc( 0.0, 360.0 ); // scale as a full circle - setRange( 0.0, 360.0, 1.0, 10 ); // degrees as default -} - -//! Destructor -QwtDial::~QwtDial() -{ - delete d_data; -} - -/*! - Sets the frame shadow value from the frame style. - \param shadow Frame shadow - \sa setLineWidth(), QFrame::setFrameShadow() -*/ -void QwtDial::setFrameShadow( Shadow shadow ) -{ - if ( shadow != d_data->frameShadow ) - { - d_data->frameShadow = shadow; - if ( lineWidth() > 0 ) - update(); - } -} - -/*! - \return Frame shadow - /sa setFrameShadow(), lineWidth(), QFrame::frameShadow -*/ -QwtDial::Shadow QwtDial::frameShadow() const -{ - return d_data->frameShadow; -} - -/*! - Sets the line width - - \param lineWidth Line width - \sa setFrameShadow() -*/ -void QwtDial::setLineWidth( int lineWidth ) -{ - if ( lineWidth < 0 ) - lineWidth = 0; - - if ( d_data->lineWidth != lineWidth ) - { - d_data->lineWidth = lineWidth; - update(); - } -} - -/*! - \return Line width of the frame - \sa setLineWidth(), frameShadow(), lineWidth() -*/ -int QwtDial::lineWidth() const -{ - return d_data->lineWidth; -} - -/*! - \return bounding rect of the circle inside the frame - \sa setLineWidth(), scaleInnerRect(), boundingRect() -*/ -QRectF QwtDial::innerRect() const -{ - const double lw = lineWidth(); - return boundingRect().adjusted( lw, lw, -lw, -lw ); -} - -/*! - \return bounding rect of the dial including the frame - \sa setLineWidth(), scaleInnerRect(), innerRect() -*/ -QRectF QwtDial::boundingRect() const -{ - const QRectF cr = contentsRect(); - - const double dim = qMin( cr.width(), cr.height() ); - - QRectF inner( 0, 0, dim, dim ); - inner.moveCenter( cr.center() ); - - return inner; -} - -/*! - \return rect inside the scale - \sa setLineWidth(), boundingRect(), innerRect() -*/ -QRectF QwtDial::scaleInnerRect() const -{ - QRectF rect = innerRect(); - - if ( d_data->scaleDraw ) - { - double scaleDist = qCeil( d_data->scaleDraw->extent( font() ) ); - scaleDist++; // margin - - rect.adjust( scaleDist, scaleDist, -scaleDist, -scaleDist ); - } - - return rect; -} - -/*! - \brief Change the mode of the meter. - \param mode New mode - - The value of the meter is indicated by the difference - between north of the scale and the direction of the needle. - In case of QwtDial::RotateNeedle north is pointing - to the origin() and the needle is rotating, in case of - QwtDial::RotateScale, the needle points to origin() - and the scale is rotating. - - The default mode is QwtDial::RotateNeedle. - - \sa mode(), setValue(), setOrigin() -*/ -void QwtDial::setMode( Mode mode ) -{ - if ( mode != d_data->mode ) - { - d_data->mode = mode; - update(); - } -} - -/*! - \return mode of the dial. - - The value of the dial is indicated by the difference - between the origin and the direction of the needle. - In case of QwtDial::RotateNeedle the scale arc is fixed - to the origin() and the needle is rotating, in case of - QwtDial::RotateScale, the needle points to origin() - and the scale is rotating. - - The default mode is QwtDial::RotateNeedle. - - \sa setMode(), origin(), setScaleArc(), value() -*/ -QwtDial::Mode QwtDial::mode() const -{ - return d_data->mode; -} - -/*! - Sets whether it is possible to step the value from the highest value to - the lowest value and vice versa to on. - - \param wrapping en/disables wrapping - - \sa wrapping(), QwtDoubleRange::periodic() - \note The meaning of wrapping is like the wrapping property of QSpinBox, - but not like it is used in QDial. -*/ -void QwtDial::setWrapping( bool wrapping ) -{ - setPeriodic( wrapping ); -} - -/*! - wrapping() holds whether it is possible to step the value from the - highest value to the lowest value and vice versa. - - \sa setWrapping(), QwtDoubleRange::setPeriodic() - \note The meaning of wrapping is like the wrapping property of QSpinBox, - but not like it is used in QDial. -*/ -bool QwtDial::wrapping() const -{ - return periodic(); -} - -/*! - Set the direction of the dial (clockwise/counterclockwise) - - \param direction Direction - \sa direction() -*/ -void QwtDial::setDirection( Direction direction ) -{ - if ( direction != d_data->direction ) - { - d_data->direction = direction; - update(); - } -} - -/*! - \return Direction of the dial - - The default direction of a dial is QwtDial::Clockwise - - \sa setDirection() -*/ -QwtDial::Direction QwtDial::direction() const -{ - return d_data->direction; -} - -/*! - Paint the dial - \param event Paint event -*/ -void QwtDial::paintEvent( QPaintEvent *event ) -{ - QPainter painter( this ); - painter.setClipRegion( event->region() ); - - QStyleOption opt; - opt.init(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); - - painter.setRenderHint( QPainter::Antialiasing, true ); - - painter.save(); - drawContents( &painter ); - painter.restore(); - - painter.save(); - drawFrame( &painter ); - painter.restore(); - - if ( hasFocus() ) - drawFocusIndicator( &painter ); -} - -/*! - Draw a dotted round circle, if !isReadOnly() - - \param painter Painter -*/ -void QwtDial::drawFocusIndicator( QPainter *painter ) const -{ - if ( !isReadOnly() ) - { - QRectF focusRect = innerRect(); - - const int margin = 2; - focusRect.adjust( margin, margin, -margin, -margin ); - - QColor color = palette().color( QPalette::Base ); - if ( color.isValid() ) - { - const QColor gray( Qt::gray ); - - int h, s, v; - color.getHsv( &h, &s, &v ); - color = ( v > 128 ) ? gray.dark( 120 ) : gray.light( 120 ); - } - else - color = Qt::darkGray; - - painter->save(); - painter->setBrush( Qt::NoBrush ); - painter->setPen( QPen( color, 0, Qt::DotLine ) ); - painter->drawEllipse( focusRect ); - painter->restore(); - } -} - -/*! - Draw the frame around the dial - - \param painter Painter - \sa lineWidth(), frameShadow() -*/ -void QwtDial::drawFrame( QPainter *painter ) -{ - if ( lineWidth() <= 0 ) - return; - - const double lw2 = 0.5 * lineWidth(); - - QRectF r = boundingRect(); - r.adjust( lw2, lw2, -lw2, -lw2 ); - - QPen pen; - - switch ( d_data->frameShadow ) - { - case QwtDial::Raised: - case QwtDial::Sunken: - { - QColor c1 = palette().color( QPalette::Light ); - QColor c2 = palette().color( QPalette::Dark ); - - if ( d_data->frameShadow == QwtDial::Sunken ) - qSwap( c1, c2 ); - - QLinearGradient gradient( r.topLeft(), r.bottomRight() ); - gradient.setColorAt( 0.0, c1 ); -#if 0 - gradient.setColorAt( 0.3, c1 ); - gradient.setColorAt( 0.7, c2 ); -#endif - gradient.setColorAt( 1.0, c2 ); - - pen = QPen( gradient, lineWidth() ); - break; - } - default: // Plain - { - pen = QPen( palette().brush( QPalette::Dark ), lineWidth() ); - } - } - - painter->save(); - - painter->setPen( pen ); - painter->setBrush( Qt::NoBrush ); - painter->drawEllipse( r ); - - painter->restore(); -} - -/*! - \brief Draw the contents inside the frame - - QPalette::Window is the background color outside of the frame. - QPalette::Base is the background color inside the frame. - QPalette::WindowText is the background color inside the scale. - - \param painter Painter - \sa boundingRect(), innerRect(), - scaleInnerRect(), QWidget::setPalette() -*/ -void QwtDial::drawContents( QPainter *painter ) const -{ - if ( testAttribute( Qt::WA_NoSystemBackground ) || - palette().brush( QPalette::Base ) != - palette().brush( QPalette::Window ) ) - { - const QRectF br = boundingRect(); - - painter->save(); - painter->setPen( Qt::NoPen ); - painter->setBrush( palette().brush( QPalette::Base ) ); - painter->drawEllipse( br ); - painter->restore(); - } - - - const QRectF insideScaleRect = scaleInnerRect(); - if ( palette().brush( QPalette::WindowText ) != - palette().brush( QPalette::Base ) ) - { - painter->save(); - painter->setPen( Qt::NoPen ); - painter->setBrush( palette().brush( QPalette::WindowText ) ); - painter->drawEllipse( insideScaleRect ); - painter->restore(); - } - - const QPointF center = insideScaleRect.center(); - const double radius = 0.5 * insideScaleRect.width(); - - double direction = d_data->origin; - - if ( isValid() ) - { - direction = d_data->minScaleArc; - if ( maxValue() > minValue() && - d_data->maxScaleArc > d_data->minScaleArc ) - { - const double ratio = - ( value() - minValue() ) / ( maxValue() - minValue() ); - direction += ratio * ( d_data->maxScaleArc - d_data->minScaleArc ); - } - - if ( d_data->direction == QwtDial::CounterClockwise ) - direction = d_data->maxScaleArc - ( direction - d_data->minScaleArc ); - - direction += d_data->origin; - if ( direction >= 360.0 ) - direction -= 360.0; - else if ( direction < 0.0 ) - direction += 360.0; - } - - double origin = d_data->origin; - if ( mode() == RotateScale ) - { - origin -= direction - d_data->origin; - direction = d_data->origin; - } - - painter->save(); - drawScale( painter, center, radius, origin, - d_data->minScaleArc, d_data->maxScaleArc ); - painter->restore(); - - painter->save(); - drawScaleContents( painter, center, radius ); - painter->restore(); - - if ( isValid() ) - { - QPalette::ColorGroup cg; - if ( isEnabled() ) - cg = hasFocus() ? QPalette::Active : QPalette::Inactive; - else - cg = QPalette::Disabled; - - painter->save(); - drawNeedle( painter, center, radius, direction, cg ); - painter->restore(); - } -} - -/*! - Draw the needle - - \param painter Painter - \param center Center of the dial - \param radius Length for the needle - \param direction Direction of the needle in degrees, counter clockwise - \param cg ColorGroup -*/ -void QwtDial::drawNeedle( QPainter *painter, const QPointF ¢er, - double radius, double direction, QPalette::ColorGroup cg ) const -{ - if ( d_data->needle ) - { - direction = 360.0 - direction; // counter clockwise - d_data->needle->draw( painter, center, radius, direction, cg ); - } -} - -/*! - Draw the scale - - \param painter Painter - \param center Center of the dial - \param radius Radius of the scale - \param origin Origin of the scale - \param minArc Minimum of the arc - \param maxArc Minimum of the arc - - \sa QwtRoundScaleDraw::setAngleRange() -*/ -void QwtDial::drawScale( QPainter *painter, const QPointF ¢er, - double radius, double origin, double minArc, double maxArc ) const -{ - if ( d_data->scaleDraw == NULL ) - return; - - origin -= 270.0; // hardcoded origin of QwtScaleDraw - - double angle = maxArc - minArc; - if ( angle > 360.0 ) - angle = ::fmod( angle, 360.0 ); - - minArc += origin; - if ( minArc < -360.0 ) - minArc = ::fmod( minArc, 360.0 ); - - maxArc = minArc + angle; - if ( maxArc > 360.0 ) - { - // QwtRoundScaleDraw::setAngleRange accepts only values - // in the range [-360.0..360.0] - minArc -= 360.0; - maxArc -= 360.0; - } - - if ( d_data->direction == QwtDial::CounterClockwise ) - qSwap( minArc, maxArc ); - - painter->setFont( font() ); - - d_data->scaleDraw->setAngleRange( minArc, maxArc ); - d_data->scaleDraw->setRadius( radius ); - d_data->scaleDraw->moveCenter( center ); - - QPalette pal = palette(); - - const QColor textColor = pal.color( QPalette::Text ); - pal.setColor( QPalette::WindowText, textColor ); //ticks, backbone - - painter->setPen( QPen( textColor, d_data->scaleDraw->penWidth() ) ); - - painter->setBrush( Qt::red ); - d_data->scaleDraw->draw( painter, pal ); -} - -/*! - Draw the contents inside the scale - - Paints nothing. - - \param painter Painter - \param center Center of the contents circle - \param radius Radius of the contents circle -*/ - -void QwtDial::drawScaleContents( QPainter *painter, - const QPointF ¢er, double radius ) const -{ - Q_UNUSED(painter); - Q_UNUSED(center); - Q_UNUSED(radius); -} - -/*! - Set a needle for the dial - - Qwt is missing a set of good looking needles. - Contributions are very welcome. - - \param needle Needle - \warning The needle will be deleted, when a different needle is - set or in ~QwtDial() -*/ -void QwtDial::setNeedle( QwtDialNeedle *needle ) -{ - if ( needle != d_data->needle ) - { - if ( d_data->needle ) - delete d_data->needle; - - d_data->needle = needle; - update(); - } -} - -/*! - \return needle - \sa setNeedle() -*/ -const QwtDialNeedle *QwtDial::needle() const -{ - return d_data->needle; -} - -/*! - \return needle - \sa setNeedle() -*/ -QwtDialNeedle *QwtDial::needle() -{ - return d_data->needle; -} - -//! QwtDoubleRange update hook -void QwtDial::rangeChange() -{ - updateScale(); -} - -/*! - Update the scale with the current attributes - \sa setScale() -*/ -void QwtDial::updateScale() -{ - if ( d_data->scaleDraw ) - { - QwtLinearScaleEngine scaleEngine; - - const QwtScaleDiv scaleDiv = scaleEngine.divideScale( - minValue(), maxValue(), - d_data->maxMajIntv, d_data->maxMinIntv, d_data->scaleStep ); - - d_data->scaleDraw->setTransformation( scaleEngine.transformation() ); - d_data->scaleDraw->setScaleDiv( scaleDiv ); - } -} - -//! Return the scale draw -QwtDialScaleDraw *QwtDial::scaleDraw() -{ - return d_data->scaleDraw; -} - -//! Return the scale draw -const QwtDialScaleDraw *QwtDial::scaleDraw() const -{ - return d_data->scaleDraw; -} - -/*! - Set an individual scale draw - - \param scaleDraw Scale draw - \warning The previous scale draw is deleted -*/ -void QwtDial::setScaleDraw( QwtDialScaleDraw *scaleDraw ) -{ - if ( scaleDraw != d_data->scaleDraw ) - { - if ( d_data->scaleDraw ) - delete d_data->scaleDraw; - - d_data->scaleDraw = scaleDraw; - updateScale(); - update(); - } -} - -/*! - Change the intervals of the scale - - \param maxMajIntv Maximum for the number of major steps - \param maxMinIntv Maximum number of minor steps - \param step Step size - - \sa QwtScaleEngine::divideScale() -*/ -void QwtDial::setScale( int maxMajIntv, int maxMinIntv, double step ) -{ - d_data->maxMajIntv = maxMajIntv; - d_data->maxMinIntv = maxMinIntv; - d_data->scaleStep = step; - - updateScale(); -} - -/*! - A wrapper method for accessing the scale draw. - - \param components Scale components - \sa QwtAbstractScaleDraw::enableComponent() -*/ -void QwtDial::setScaleComponents( - QwtAbstractScaleDraw::ScaleComponents components ) -{ - if ( components == 0 ) - setScaleDraw( NULL ); - - QwtDialScaleDraw *sd = d_data->scaleDraw; - if ( sd == NULL ) - return; - - sd->enableComponent( QwtAbstractScaleDraw::Backbone, - components & QwtAbstractScaleDraw::Backbone ); - - sd->enableComponent( QwtAbstractScaleDraw::Ticks, - components & QwtAbstractScaleDraw::Ticks ); - - sd->enableComponent( QwtAbstractScaleDraw::Labels, - components & QwtAbstractScaleDraw::Labels ); -} - -/*! - Assign length and width of the ticks - - \param minLen Length of the minor ticks - \param medLen Length of the medium ticks - \param majLen Length of the major ticks - \param penWidth Width of the pen for all ticks - - \sa QwtAbstractScaleDraw::setTickLength(), QwtDialScaleDraw::setPenWidth() -*/ -void QwtDial::setScaleTicks( int minLen, int medLen, - int majLen, int penWidth ) -{ - QwtDialScaleDraw *sd = d_data->scaleDraw; - if ( sd ) - { - sd->setTickLength( QwtScaleDiv::MinorTick, minLen ); - sd->setTickLength( QwtScaleDiv::MediumTick, medLen ); - sd->setTickLength( QwtScaleDiv::MajorTick, majLen ); - sd->setPenWidth( penWidth ); - } -} - -/*! - Find the label for a value - - \param value Value - \return label -*/ -QwtText QwtDial::scaleLabel( double value ) const -{ -#if 1 - if ( value == -0 ) - value = 0; -#endif - - return QString::number( value ); -} - -//! \return Lower limit of the scale arc -double QwtDial::minScaleArc() const -{ - return d_data->minScaleArc; -} - -//! \return Upper limit of the scale arc -double QwtDial::maxScaleArc() const -{ - return d_data->maxScaleArc; -} - -/*! - \brief Change the origin - - The origin is the angle where scale and needle is relative to. - - \param origin New origin - \sa origin() -*/ -void QwtDial::setOrigin( double origin ) -{ - d_data->origin = origin; - update(); -} - -/*! - The origin is the angle where scale and needle is relative to. - - \return Origin of the dial - \sa setOrigin() -*/ -double QwtDial::origin() const -{ - return d_data->origin; -} - -/*! - Change the arc of the scale - - \param minArc Lower limit - \param maxArc Upper limit -*/ -void QwtDial::setScaleArc( double minArc, double maxArc ) -{ - if ( minArc != 360.0 && minArc != -360.0 ) - minArc = ::fmod( minArc, 360.0 ); - if ( maxArc != 360.0 && maxArc != -360.0 ) - maxArc = ::fmod( maxArc, 360.0 ); - - d_data->minScaleArc = qMin( minArc, maxArc ); - d_data->maxScaleArc = qMax( minArc, maxArc ); - if ( d_data->maxScaleArc - d_data->minScaleArc > 360.0 ) - d_data->maxScaleArc = d_data->minScaleArc + 360.0; - - update(); -} - -//! QwtDoubleRange update hook -void QwtDial::valueChange() -{ - update(); - QwtAbstractSlider::valueChange(); -} - -/*! - \return Size hint -*/ -QSize QwtDial::sizeHint() const -{ - int sh = 0; - if ( d_data->scaleDraw ) - sh = qCeil( d_data->scaleDraw->extent( font() ) ); - - const int d = 6 * sh + 2 * lineWidth(); - - QSize hint( d, d ); - if ( !isReadOnly() ) - hint = hint.expandedTo( QApplication::globalStrut() ); - - return hint; -} - -/*! - \brief Return a minimum size hint - \warning The return value of QwtDial::minimumSizeHint() depends on the - font and the scale. -*/ -QSize QwtDial::minimumSizeHint() const -{ - int sh = 0; - if ( d_data->scaleDraw ) - sh = qCeil( d_data->scaleDraw->extent( font() ) ); - - const int d = 3 * sh + 2 * lineWidth(); - - return QSize( d, d ); -} - -static double line2Radians( const QPointF &p1, const QPointF &p2 ) -{ - const QPointF p = p2 - p1; - - double angle; - if ( p.x() == 0 ) - angle = ( p.y() <= 0.0 ) ? M_PI_2 : 3 * M_PI_2; - else - { - angle = qAtan( double( -p.y() ) / double( p.x() ) ); - if ( p.x() < 0.0 ) - angle += M_PI; - if ( angle < 0.0 ) - angle += 2 * M_PI; - } - return 360.0 - angle * 180.0 / M_PI; -} - -/*! - Find the value for a given position - - \param pos Position - \return Value -*/ -double QwtDial::getValue( const QPoint &pos ) -{ - if ( d_data->maxScaleArc == d_data->minScaleArc || maxValue() == minValue() ) - return minValue(); - - double dir = line2Radians( innerRect().center(), pos ) - d_data->origin; - if ( dir < 0.0 ) - dir += 360.0; - - if ( mode() == RotateScale ) - dir = 360.0 - dir; - - // The position might be in the area that is outside the scale arc. - // We need the range of the scale if it was a complete circle. - - const double completeCircle = 360.0 / ( d_data->maxScaleArc - d_data->minScaleArc ) - * ( maxValue() - minValue() ); - - double posValue = minValue() + completeCircle * dir / 360.0; - - if ( scrollMode() == ScrMouse ) - { - if ( d_data->previousDir >= 0.0 ) // valid direction - { - // We have to find out whether the mouse is moving - // clock or counter clockwise - - bool clockWise = false; - - const double angle = dir - d_data->previousDir; - if ( ( angle >= 0.0 && angle <= 180.0 ) || angle < -180.0 ) - clockWise = true; - - if ( clockWise ) - { - if ( dir < d_data->previousDir && mouseOffset() > 0.0 ) - { - // We passed 360 -> 0 - setMouseOffset( mouseOffset() - completeCircle ); - } - - if ( wrapping() ) - { - if ( posValue - mouseOffset() > maxValue() ) - { - // We passed maxValue and the value will be set - // to minValue. We have to adjust the mouseOffset. - - setMouseOffset( posValue - minValue() ); - } - } - else - { - if ( posValue - mouseOffset() > maxValue() || - value() == maxValue() ) - { - // We fix the value at maxValue by adjusting - // the mouse offset. - - setMouseOffset( posValue - maxValue() ); - } - } - } - else - { - if ( dir > d_data->previousDir && mouseOffset() < 0.0 ) - { - // We passed 0 -> 360 - setMouseOffset( mouseOffset() + completeCircle ); - } - - if ( wrapping() ) - { - if ( posValue - mouseOffset() < minValue() ) - { - // We passed minValue and the value will be set - // to maxValue. We have to adjust the mouseOffset. - - setMouseOffset( posValue - maxValue() ); - } - } - else - { - if ( posValue - mouseOffset() < minValue() || - value() == minValue() ) - { - // We fix the value at minValue by adjusting - // the mouse offset. - - setMouseOffset( posValue - minValue() ); - } - } - } - } - d_data->previousDir = dir; - } - - return posValue; -} - -/*! - See QwtAbstractSlider::getScrollMode() - - \param pos point where the mouse was pressed - \retval scrollMode The scrolling mode - \retval direction direction: 1, 0, or -1. - - \sa QwtAbstractSlider::getScrollMode() -*/ -void QwtDial::getScrollMode( const QPoint &pos, - QwtAbstractSlider::ScrollMode &scrollMode, int &direction ) const -{ - direction = 0; - scrollMode = QwtAbstractSlider::ScrNone; - - const QRegion region( innerRect().toRect(), QRegion::Ellipse ); - if ( region.contains( pos ) && pos != innerRect().center() ) - { - scrollMode = QwtAbstractSlider::ScrMouse; - d_data->previousDir = -1.0; - } -} - -/*! - Handles key events - - - Key_Down, KeyLeft\n - Decrement by 1 - - Key_Prior\n - Decrement by pageSize() - - Key_Home\n - Set the value to minValue() - - - Key_Up, KeyRight\n - Increment by 1 - - Key_Next\n - Increment by pageSize() - - Key_End\n - Set the value to maxValue() - - \param event Key event - \sa isReadOnly() -*/ -void QwtDial::keyPressEvent( QKeyEvent *event ) -{ - if ( isReadOnly() ) - { - event->ignore(); - return; - } - - if ( !isValid() ) - return; - - double previous = prevValue(); - switch ( event->key() ) - { - case Qt::Key_Down: - case Qt::Key_Left: - QwtDoubleRange::incValue( -1 ); - break; - case Qt::Key_PageUp: - QwtDoubleRange::incValue( -pageSize() ); - break; - case Qt::Key_Home: - setValue( minValue() ); - break; - - case Qt::Key_Up: - case Qt::Key_Right: - QwtDoubleRange::incValue( 1 ); - break; - case Qt::Key_PageDown: - QwtDoubleRange::incValue( pageSize() ); - break; - case Qt::Key_End: - setValue( maxValue() ); - break; - default:; - event->ignore(); - } - - if ( value() != previous ) - Q_EMIT sliderMoved( value() ); -} diff --git a/qwt/src/qwt_dial.h b/qwt/src/qwt_dial.h deleted file mode 100644 index 0d34c799a..000000000 --- a/qwt/src/qwt_dial.h +++ /dev/null @@ -1,215 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_DIAL_H -#define QWT_DIAL_H 1 - -#include "qwt_global.h" -#include "qwt_abstract_slider.h" -#include "qwt_round_scale_draw.h" -#include -#include - -class QwtDialNeedle; -class QwtDial; - -/*! - \brief A special scale draw made for QwtDial - - \sa QwtDial, QwtCompass -*/ -class QWT_EXPORT QwtDialScaleDraw: public QwtRoundScaleDraw -{ -public: - explicit QwtDialScaleDraw( QwtDial * ); - - virtual QwtText label( double value ) const; - - void setPenWidth( double ); - double penWidth() const; - -private: - QwtDial *d_parent; - double d_penWidth; -}; - -/*! - \brief QwtDial class provides a rounded range control. - - QwtDial is intended as base class for dial widgets like - speedometers, compass widgets, clocks ... - - \image html dials2.png - - A dial contains a scale and a needle indicating the current value - of the dial. Depending on Mode one of them is fixed and the - other is rotating. If not isReadOnly() the - dial can be rotated by dragging the mouse or using keyboard inputs - (see keyPressEvent()). A dial might be wrapping, what means - a rotation below/above one limit continues on the other limit (f.e compass). - The scale might cover any arc of the dial, its values are related to - the origin() of the dial. - - Qwt is missing a set of good looking needles (QwtDialNeedle). - Contributions are very welcome. - - \sa QwtCompass, QwtAnalogClock, QwtDialNeedle - \note The examples/dials example shows different types of dials. -*/ - -class QWT_EXPORT QwtDial: public QwtAbstractSlider -{ - Q_OBJECT - - Q_ENUMS( Shadow ) - Q_ENUMS( Mode ) - Q_ENUMS( Direction ) - - Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth ) - Q_PROPERTY( Shadow frameShadow READ frameShadow WRITE setFrameShadow ) - Q_PROPERTY( Mode mode READ mode WRITE setMode ) - Q_PROPERTY( double origin READ origin WRITE setOrigin ) - Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping ) - Q_PROPERTY( Direction direction READ direction WRITE setDirection ) - - friend class QwtDialScaleDraw; -public: - - /*! - \brief Frame shadow - - Unfortunately it is not possible to use QFrame::Shadow - as a property of a widget that is not derived from QFrame. - The following enum is made for the designer only. It is safe - to use QFrame::Shadow instead. - */ - enum Shadow - { - //! QFrame::Plain - Plain = QFrame::Plain, - - //! QFrame::Raised - Raised = QFrame::Raised, - - //! QFrame::Sunken - Sunken = QFrame::Sunken - }; - - //! Mode controlling wether the needle or the scale is rotating - enum Mode - { - //! The needle is rotating - RotateNeedle, - - //! The needle is fixed, the scales are rotating - RotateScale - }; - - //! Direction of the dial - enum Direction - { - //! Clockwise - Clockwise, - - //! Counter clockwise - CounterClockwise - }; - - explicit QwtDial( QWidget *parent = NULL ); - virtual ~QwtDial(); - - void setFrameShadow( Shadow ); - Shadow frameShadow() const; - - void setLineWidth( int ); - int lineWidth() const; - - void setMode( Mode ); - Mode mode() const; - - virtual void setWrapping( bool ); - bool wrapping() const; - - virtual void setScale( int maxMajIntv, int maxMinIntv, double step = 0.0 ); - - void setScaleArc( double min, double max ); - void setScaleComponents( QwtAbstractScaleDraw::ScaleComponents ); - void setScaleTicks( int minLen, int medLen, int majLen, int penWidth = 1 ); - - double minScaleArc() const; - double maxScaleArc() const; - - virtual void setOrigin( double ); - double origin() const; - - void setDirection( Direction ); - Direction direction() const; - - virtual void setNeedle( QwtDialNeedle * ); - const QwtDialNeedle *needle() const; - QwtDialNeedle *needle(); - - QRectF boundingRect() const; - QRectF innerRect() const; - virtual QRectF scaleInnerRect() const; - - virtual QSize sizeHint() const; - virtual QSize minimumSizeHint() const; - - virtual void setScaleDraw( QwtDialScaleDraw * ); - - QwtDialScaleDraw *scaleDraw(); - const QwtDialScaleDraw *scaleDraw() const; - -protected: - virtual void paintEvent( QPaintEvent * ); - virtual void keyPressEvent( QKeyEvent * ); - - virtual void drawFrame( QPainter *p ); - virtual void drawContents( QPainter * ) const; - virtual void drawFocusIndicator( QPainter * ) const; - - virtual void drawScale( - QPainter *, const QPointF ¢er, - double radius, double origin, - double arcMin, double arcMax ) const; - - /*! - Draw the contents inside the scale - - Paints nothing. - - \param painter Painter - \param center Center of the contents circle - \param radius Radius of the contents circle - */ - virtual void drawScaleContents( QPainter *painter, - const QPointF ¢er, double radius ) const; - - virtual void drawNeedle( QPainter *, const QPointF &, - double radius, double direction, QPalette::ColorGroup ) const; - - virtual QwtText scaleLabel( double ) const; - void updateScale(); - - virtual void rangeChange(); - virtual void valueChange(); - - virtual double getValue( const QPoint & ); - virtual void getScrollMode( const QPoint &, - QwtAbstractSlider::ScrollMode &, int &direction ) const; - -private: - void initDial(); - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_dial_needle.cpp b/qwt/src/qwt_dial_needle.cpp deleted file mode 100644 index 6c4a46a1e..000000000 --- a/qwt/src/qwt_dial_needle.cpp +++ /dev/null @@ -1,452 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_dial_needle.h" -#include "qwt_global.h" -#include "qwt_math.h" -#include "qwt_painter.h" -#include -#include - -static void qwtDrawStyle1Needle( QPainter *painter, - const QPalette &palette, QPalette::ColorGroup colorGroup, - double length ) -{ - const double r[] = { 0.4, 0.3, 1, 0.8, 1, 0.3, 0.4 }; - const double a[] = { -45, -20, -15, 0, 15, 20, 45 }; - - QPainterPath path; - for ( int i = 0; i < 7; i++ ) - { - const double angle = a[i] / 180.0 * M_PI; - const double radius = r[i] * length; - - const double x = radius * qCos( angle ); - const double y = radius * qSin( angle ); - - path.lineTo( x, -y ); - } - - painter->setPen( Qt::NoPen ); - painter->setBrush( palette.brush( colorGroup, QPalette::Light ) ); - painter->drawPath( path ); -} - -static void qwtDrawStyle2Needle( QPainter *painter, - const QPalette &palette, QPalette::ColorGroup colorGroup, double length ) -{ - const double ratioX = 0.7; - const double ratioY = 0.3; - - QPainterPath path1; - path1.lineTo( ratioX * length, 0.0 ); - path1.lineTo( length, ratioY * length ); - - QPainterPath path2; - path2.lineTo( ratioX * length, 0.0 ); - path2.lineTo( length, -ratioY * length ); - - painter->setPen( Qt::NoPen ); - - painter->setBrush( palette.brush( colorGroup, QPalette::Light ) ); - painter->drawPath( path1 ); - - painter->setBrush( palette.brush( colorGroup, QPalette::Dark ) ); - painter->drawPath( path2 ); -} - -static void qwtDrawShadedPointer( QPainter *painter, - const QColor &lightColor, const QColor &darkColor, - double length, double width ) -{ - const double peak = qMax( length / 10.0, 5.0 ); - - const double knobWidth = width + 8; - QRectF knobRect( 0, 0, knobWidth, knobWidth ); - knobRect.moveCenter( QPointF(0, 0) ); - - QPainterPath path1; - path1.lineTo( 0.0, 0.5 * width ); - path1.lineTo( length - peak, 0.5 * width ); - path1.lineTo( length, 0.0 ); - path1.lineTo( 0.0, 0.0 ); - - QPainterPath arcPath1; - arcPath1.arcTo( knobRect, 0.0, -90.0 ); - - path1 = path1.united( arcPath1 ); - - QPainterPath path2; - path2.lineTo( 0.0, -0.5 * width ); - path2.lineTo( length - peak, -0.5 * width ); - path2.lineTo( length, 0.0 ); - path2.lineTo( 0.0, 0.0 ); - - QPainterPath arcPath2; - arcPath2.arcTo( knobRect, 0.0, 90.0 ); - - path2 = path2.united( arcPath2 ); - - painter->setPen( Qt::NoPen ); - - painter->setBrush( lightColor ); - painter->drawPath( path1 ); - - painter->setBrush( darkColor ); - painter->drawPath( path2 ); -} - -static void qwtDrawArrowNeedle( QPainter *painter, - const QPalette &palette, QPalette::ColorGroup colorGroup, - double length, double width ) -{ - if ( width <= 0 ) - width = qMax( length * 0.06, 9.0 ); - - const double peak = qMax( 2.0, 0.4 * width ); - - QPainterPath path; - path.moveTo( 0.0, 0.5 * width ); - path.lineTo( length - peak, 0.3 * width ); - path.lineTo( length, 0.0 ); - path.lineTo( length - peak, -0.3 * width ); - path.lineTo( 0.0, -0.5 * width ); - - QRectF br = path.boundingRect(); - - QPalette pal( palette.color( QPalette::Mid ) ); - QColor c1 = pal.color( QPalette::Light ); - QColor c2 = pal.color( QPalette::Dark ); - - QLinearGradient gradient( br.topLeft(), br.bottomLeft() ); - gradient.setColorAt( 0.0, c1 ); - gradient.setColorAt( 0.5, c1 ); - gradient.setColorAt( 0.5001, c2 ); - gradient.setColorAt( 1.0, c2 ); - - QPen pen( gradient, 1 ); - pen.setJoinStyle( Qt::MiterJoin ); - - painter->setPen( pen ); - painter->setBrush( palette.brush( colorGroup, QPalette::Mid ) ); - - painter->drawPath( path ); -} - -static void qwtDrawTriangleNeedle( QPainter *painter, - const QPalette &palette, QPalette::ColorGroup colorGroup, - double length ) -{ - const double width = qRound( length / 3.0 ); - - QPainterPath path[4]; - - path[0].lineTo( length, 0.0 ); - path[0].lineTo( 0.0, width / 2 ); - - path[1].lineTo( length, 0.0 ); - path[1].lineTo( 0.0, -width / 2 ); - - path[2].lineTo( -length, 0.0 ); - path[2].lineTo( 0.0, width / 2 ); - - path[3].lineTo( -length, 0.0 ); - path[3].lineTo( 0.0, -width / 2 ); - - - const int colorOffset = 10; - const QColor darkColor = palette.color( colorGroup, QPalette::Dark ); - const QColor lightColor = palette.color( colorGroup, QPalette::Light ); - - QColor color[4]; - color[0] = darkColor.light( 100 + colorOffset ); - color[1] = darkColor.dark( 100 + colorOffset ); - color[2] = lightColor.light( 100 + colorOffset ); - color[3] = lightColor.dark( 100 + colorOffset ); - - painter->setPen( Qt::NoPen ); - - for ( int i = 0; i < 4; i++ ) - { - painter->setBrush( color[i] ); - painter->drawPath( path[i] ); - } -} - -//! Constructor -QwtDialNeedle::QwtDialNeedle(): - d_palette( QApplication::palette() ) -{ -} - -//! Destructor -QwtDialNeedle::~QwtDialNeedle() -{ -} - -/*! - Sets the palette for the needle. - - \param palette New Palette -*/ -void QwtDialNeedle::setPalette( const QPalette &palette ) -{ - d_palette = palette; -} - -/*! - \return the palette of the needle. -*/ -const QPalette &QwtDialNeedle::palette() const -{ - return d_palette; -} - -/*! - Draw the needle - - \param painter Painter - \param center Center of the dial, start position for the needle - \param length Length of the needle - \param direction Direction of the needle, in degrees counter clockwise - \param colorGroup Color group, used for painting -*/ -void QwtDialNeedle::draw( QPainter *painter, - const QPointF ¢er, double length, double direction, - QPalette::ColorGroup colorGroup ) const -{ - painter->save(); - - painter->translate( center ); - painter->rotate( -direction ); - - drawNeedle( painter, length, colorGroup ); - - painter->restore(); -} - -//! Draw the knob -void QwtDialNeedle::drawKnob( QPainter *painter, - double width, const QBrush &brush, bool sunken ) const -{ - QPalette palette( brush.color() ); - - QColor c1 = palette.color( QPalette::Light ); - QColor c2 = palette.color( QPalette::Dark ); - - if ( sunken ) - qSwap( c1, c2 ); - - QRectF rect( 0.0, 0.0, width, width ); - rect.moveCenter( painter->combinedTransform().map( QPointF() ) ); - - QLinearGradient gradient( rect.topLeft(), rect.bottomRight() ); - gradient.setColorAt( 0.0, c1 ); - gradient.setColorAt( 0.3, c1 ); - gradient.setColorAt( 0.7, c2 ); - gradient.setColorAt( 1.0, c2 ); - - painter->save(); - - painter->resetTransform(); - - painter->setPen( QPen( gradient, 1 ) ); - painter->setBrush( brush ); - painter->drawEllipse( rect ); - - painter->restore(); -} - -/*! - Constructor - - \param style Style - \param hasKnob With/Without knob - \param mid Middle color - \param base Base color -*/ -QwtDialSimpleNeedle::QwtDialSimpleNeedle( Style style, bool hasKnob, - const QColor &mid, const QColor &base ): - d_style( style ), - d_hasKnob( hasKnob ), - d_width( -1 ) -{ - QPalette palette; - for ( int i = 0; i < QPalette::NColorGroups; i++ ) - { - palette.setColor( ( QPalette::ColorGroup )i, - QPalette::Mid, mid ); - palette.setColor( ( QPalette::ColorGroup )i, - QPalette::Base, base ); - } - - setPalette( palette ); -} - -/*! - Set the width of the needle - \param width Width - \sa width() -*/ -void QwtDialSimpleNeedle::setWidth( double width ) -{ - d_width = width; -} - -/*! - \return the width of the needle - \sa setWidth() -*/ -double QwtDialSimpleNeedle::width() const -{ - return d_width; -} - -/*! - Draw the needle - - \param painter Painter - \param length Length of the needle - \param colorGroup Color group, used for painting -*/ -void QwtDialSimpleNeedle::drawNeedle( QPainter *painter, - double length, QPalette::ColorGroup colorGroup ) const -{ - double knobWidth = 0.0; - double width = d_width; - - if ( d_style == Arrow ) - { - if ( width <= 0.0 ) - width = qMax(length * 0.06, 6.0); - - qwtDrawArrowNeedle( painter, - palette(), colorGroup, length, width ); - - knobWidth = qMin( width * 2.0, 0.2 * length ); - } - else - { - if ( width <= 0.0 ) - width = 5.0; - - QPen pen ( palette().brush( colorGroup, QPalette::Mid ), width ); - pen.setCapStyle( Qt::FlatCap ); - - painter->setPen( pen ); - painter->drawLine( 0, 0, length, 0 ); - - knobWidth = qMax( width * 3.0, 5.0 ); - } - - if ( d_hasKnob && knobWidth > 0.0 ) - { - drawKnob( painter, knobWidth, - palette().brush( colorGroup, QPalette::Base ), false ); - } -} - -//! Constructor - -QwtCompassMagnetNeedle::QwtCompassMagnetNeedle( Style style, - const QColor &light, const QColor &dark ): - d_style( style ) -{ - QPalette palette; - for ( int i = 0; i < QPalette::NColorGroups; i++ ) - { - palette.setColor( ( QPalette::ColorGroup )i, - QPalette::Light, light ); - palette.setColor( ( QPalette::ColorGroup )i, - QPalette::Dark, dark ); - palette.setColor( ( QPalette::ColorGroup )i, - QPalette::Base, Qt::gray ); - } - - setPalette( palette ); -} - -/*! - Draw the needle - - \param painter Painter - \param length Length of the needle - \param colorGroup Color group, used for painting -*/ -void QwtCompassMagnetNeedle::drawNeedle( QPainter *painter, - double length, QPalette::ColorGroup colorGroup ) const -{ - if ( d_style == ThinStyle ) - { - const double width = qMax( length / 6.0, 3.0 ); - - const int colorOffset = 10; - - const QColor light = palette().color( colorGroup, QPalette::Light ); - const QColor dark = palette().color( colorGroup, QPalette::Dark ); - - qwtDrawShadedPointer( painter, - dark.light( 100 + colorOffset ), - dark.dark( 100 + colorOffset ), - length, width ); - - painter->rotate( 180.0 ); - - qwtDrawShadedPointer( painter, - light.light( 100 + colorOffset ), - light.dark( 100 + colorOffset ), - length, width ); - - const QBrush baseBrush = palette().brush( colorGroup, QPalette::Base ); - drawKnob( painter, width, baseBrush, true ); - } - else - { - qwtDrawTriangleNeedle( painter, palette(), colorGroup, length ); - } -} - -/*! - Constructor - - \param style Arrow style - \param light Light color - \param dark Dark color -*/ -QwtCompassWindArrow::QwtCompassWindArrow( Style style, - const QColor &light, const QColor &dark ): - d_style( style ) -{ - QPalette palette; - for ( int i = 0; i < QPalette::NColorGroups; i++ ) - { - palette.setColor( ( QPalette::ColorGroup )i, - QPalette::Light, light ); - palette.setColor( ( QPalette::ColorGroup )i, - QPalette::Dark, dark ); - } - - setPalette( palette ); -} - -/*! - Draw the needle - - \param painter Painter - \param length Length of the needle - \param colorGroup Color group, used for painting -*/ -void QwtCompassWindArrow::drawNeedle( QPainter *painter, - double length, QPalette::ColorGroup colorGroup ) const -{ - if ( d_style == Style1 ) - qwtDrawStyle1Needle( painter, palette(), colorGroup, length ); - else - qwtDrawStyle2Needle( painter, palette(), colorGroup, length ); -} diff --git a/qwt/src/qwt_dial_needle.h b/qwt/src/qwt_dial_needle.h deleted file mode 100644 index e76b9d129..000000000 --- a/qwt/src/qwt_dial_needle.h +++ /dev/null @@ -1,190 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_DIAL_NEEDLE_H -#define QWT_DIAL_NEEDLE_H 1 - -#include "qwt_global.h" -#include - -class QPainter; -class QPoint; - -/*! - \brief Base class for needles that can be used in a QwtDial. - - QwtDialNeedle is a pointer that indicates a value by pointing - to a specific direction. - - Qwt is missing a set of good looking needles. - Contributions are very welcome. - - \sa QwtDial, QwtCompass -*/ - -class QWT_EXPORT QwtDialNeedle -{ -public: - QwtDialNeedle(); - virtual ~QwtDialNeedle(); - - virtual void setPalette( const QPalette & ); - const QPalette &palette() const; - - virtual void draw( QPainter *painter, const QPointF ¢er, - double length, double direction, - QPalette::ColorGroup = QPalette::Active ) const; - -protected: - /*! - \brief Draw the needle - - The origin of the needle is at position (0.0, 0.0 ) - pointing in direction 0.0 ( = east ). - - The painter is already initilaized with translation and - rotation. - - \param painter Painter - \param length Length of the needle - \param colorGroup Color group, used for painting - - \sa setPalette(), palette() - */ - virtual void drawNeedle( QPainter *painter, - double length, QPalette::ColorGroup colorGroup ) const = 0; - - virtual void drawKnob( QPainter *, double width, - const QBrush &, bool sunken ) const; - -private: - QPalette d_palette; -}; - -/*! - \brief A needle for dial widgets - - The following colors are used: - - - QPalette::Mid\n - Pointer - - QPalette::Base\n - Knob - - \sa QwtDial, QwtCompass -*/ - -class QWT_EXPORT QwtDialSimpleNeedle: public QwtDialNeedle -{ -public: - //! Style of the needle - enum Style - { - //! Arrow - Arrow, - - //! A straight line from the center - Ray - }; - - QwtDialSimpleNeedle( Style, bool hasKnob = true, - const QColor &mid = Qt::gray, const QColor &base = Qt::darkGray ); - - void setWidth( double width ); - double width() const; - -protected: - virtual void drawNeedle( QPainter *, double length, - QPalette::ColorGroup ) const; - -private: - Style d_style; - bool d_hasKnob; - double d_width; -}; - -/*! - \brief A magnet needle for compass widgets - - A magnet needle points to two opposite directions indicating - north and south. - - The following colors are used: - - QPalette::Light\n - Used for pointing south - - QPalette::Dark\n - Used for pointing north - - QPalette::Base\n - Knob (ThinStyle only) - - \sa QwtDial, QwtCompass -*/ - -class QWT_EXPORT QwtCompassMagnetNeedle: public QwtDialNeedle -{ -public: - //! Style of the needle - enum Style - { - //! A needle with a triangular shape - TriangleStyle, - - //! A thin needle - ThinStyle - }; - - QwtCompassMagnetNeedle( Style = TriangleStyle, - const QColor &light = Qt::white, const QColor &dark = Qt::red ); - -protected: - virtual void drawNeedle( QPainter *, - double length, QPalette::ColorGroup ) const; - -private: - Style d_style; -}; - -/*! - \brief An indicator for the wind direction - - QwtCompassWindArrow shows the direction where the wind comes from. - - - QPalette::Light\n - Used for Style1, or the light half of Style2 - - QPalette::Dark\n - Used for the dark half of Style2 - - \sa QwtDial, QwtCompass -*/ - -class QWT_EXPORT QwtCompassWindArrow: public QwtDialNeedle -{ -public: - //! Style of the arrow - enum Style - { - //! A needle pointing to the center - Style1, - - //! A needle pointing to the center - Style2 - }; - - QwtCompassWindArrow( Style, const QColor &light = Qt::white, - const QColor &dark = Qt::gray ); - -protected: - virtual void drawNeedle( QPainter *, - double length, QPalette::ColorGroup ) const; - -private: - Style d_style; -}; - -#endif diff --git a/qwt/src/qwt_double_range.cpp b/qwt/src/qwt_double_range.cpp deleted file mode 100644 index 3748f2a11..000000000 --- a/qwt/src/qwt_double_range.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_double_range.h" -#include "qwt_math.h" - -#if QT_VERSION < 0x040601 -#define qFabs(x) ::fabs(x) -#endif - -class QwtDoubleRange::PrivateData -{ -public: - PrivateData(): - minValue( 0.0 ), - maxValue( 0.0 ), - step( 1.0 ), - pageSize( 1 ), - isValid( false ), - value( 0.0 ), - exactValue( 0.0 ), - exactPrevValue( 0.0 ), - prevValue( 0.0 ), - periodic( false ) - { - } - - double minValue; - double maxValue; - double step; - int pageSize; - - bool isValid; - double value; - double exactValue; - double exactPrevValue; - double prevValue; - - bool periodic; -}; - -/*! - The range is initialized to [0.0, 100.0], the - step size to 1.0, and the value to 0.0. -*/ -QwtDoubleRange::QwtDoubleRange() -{ - d_data = new PrivateData(); -} - -//! Destroys the QwtDoubleRange -QwtDoubleRange::~QwtDoubleRange() -{ - delete d_data; -} - -//! Set the value to be valid/invalid -void QwtDoubleRange::setValid( bool isValid ) -{ - if ( isValid != d_data->isValid ) - { - d_data->isValid = isValid; - valueChange(); - } -} - -//! Indicates if the value is valid -bool QwtDoubleRange::isValid() const -{ - return d_data->isValid; -} - -void QwtDoubleRange::setNewValue( double value, bool align ) -{ - d_data->prevValue = d_data->value; - - const double vmin = qMin( d_data->minValue, d_data->maxValue ); - const double vmax = qMax( d_data->minValue, d_data->maxValue ); - - if ( value < vmin ) - { - if ( d_data->periodic && vmin != vmax ) - { - d_data->value = value + - qwtCeilF( ( vmin - value ) / ( vmax - vmin ) ) * ( vmax - vmin ); - } - else - d_data->value = vmin; - } - else if ( value > vmax ) - { - if ( ( d_data->periodic ) && ( vmin != vmax ) ) - { - d_data->value = value - - qwtCeilF( ( value - vmax ) / ( vmax - vmin ) ) * ( vmax - vmin ); - } - else - d_data->value = vmax; - } - else - { - d_data->value = value; - } - - d_data->exactPrevValue = d_data->exactValue; - d_data->exactValue = d_data->value; - - if ( align ) - { - if ( d_data->step != 0.0 ) - { - d_data->value = d_data->minValue + - qRound( ( d_data->value - d_data->minValue ) / d_data->step ) * d_data->step; - } - else - d_data->value = d_data->minValue; - - const double minEps = 1.0e-10; - // correct rounding error at the border - if ( qFabs( d_data->value - d_data->maxValue ) < minEps * qAbs( d_data->step ) ) - d_data->value = d_data->maxValue; - - // correct rounding error if value = 0 - if ( qFabs( d_data->value ) < minEps * qAbs( d_data->step ) ) - d_data->value = 0.0; - } - - if ( !d_data->isValid || d_data->prevValue != d_data->value ) - { - d_data->isValid = true; - valueChange(); - } -} - -/*! - \brief Adjust the value to the closest point in the step raster. - \param x value - \warning The value is clipped when it lies outside the range. - When the range is QwtDoubleRange::periodic, it will - be mapped to a point in the interval such that - \verbatim new value := x + n * (max. value - min. value)\endverbatim - with an integer number n. -*/ -void QwtDoubleRange::fitValue( double x ) -{ - setNewValue( x, true ); -} - - -/*! - \brief Set a new value without adjusting to the step raster - \param x new value - \warning The value is clipped when it lies outside the range. - When the range is QwtDoubleRange::periodic, it will - be mapped to a point in the interval such that - \verbatim new value := x + n * (max. value - min. value)\endverbatim - with an integer number n. -*/ -void QwtDoubleRange::setValue( double x ) -{ - setNewValue( x, false ); -} - -/*! - \brief Specify range and step size - - \param vmin lower boundary of the interval - \param vmax higher boundary of the interval - \param vstep step width - \param pageSize page size in steps - \warning - \li A change of the range changes the value if it lies outside the - new range. The current value - will *not* be adjusted to the new step raster. - \li vmax < vmin is allowed. - \li If the step size is left out or set to zero, it will be - set to 1/100 of the interval length. - \li If the step size has an absurd value, it will be corrected - to a better one. -*/ -void QwtDoubleRange::setRange( - double vmin, double vmax, double vstep, int pageSize ) -{ - const bool rchg = ( d_data->maxValue != vmax || d_data->minValue != vmin ); - - if ( rchg ) - { - d_data->minValue = vmin; - d_data->maxValue = vmax; - } - - // look if the step width has an acceptable - // value or otherwise change it. - setStep( vstep ); - - // limit page size - const int max = - int( qAbs( ( d_data->maxValue - d_data->minValue ) / d_data->step ) ); - d_data->pageSize = qBound( 0, pageSize, max ); - - // If the value lies out of the range, it - // will be changed. Note that it will not be adjusted to - // the new step width. - setNewValue( d_data->value, false ); - - // call notifier after the step width has been - // adjusted. - if ( rchg ) - rangeChange(); -} - -/*! - \brief Change the step raster - \param vstep new step width - \warning The value will \e not be adjusted to the new step raster. -*/ -void QwtDoubleRange::setStep( double vstep ) -{ - const double intv = d_data->maxValue - d_data->minValue; - - double newStep; - if ( vstep == 0.0 ) - { - const double defaultRelStep = 1.0e-2; - newStep = intv * defaultRelStep; - } - else - { - if ( ( intv > 0.0 && vstep < 0.0 ) || ( intv < 0.0 && vstep > 0.0 ) ) - newStep = -vstep; - else - newStep = vstep; - - const double minRelStep = 1.0e-10; - if ( qFabs( newStep ) < qFabs( minRelStep * intv ) ) - newStep = minRelStep * intv; - } - - if ( newStep != d_data->step ) - { - d_data->step = newStep; - stepChange(); - } -} - - -/*! - \brief Make the range periodic - - When the range is periodic, the value will be set to a point - inside the interval such that - - \verbatim point = value + n * width \endverbatim - - if the user tries to set a new value which is outside the range. - If the range is nonperiodic (the default), values outside the - range will be clipped. - - \param tf true for a periodic range -*/ -void QwtDoubleRange::setPeriodic( bool tf ) -{ - d_data->periodic = tf; -} - -/*! - \brief Increment the value by a specified number of steps - \param nSteps Number of steps to increment - \warning As a result of this operation, the new value will always be - adjusted to the step raster. -*/ -void QwtDoubleRange::incValue( int nSteps ) -{ - if ( isValid() ) - setNewValue( d_data->value + double( nSteps ) * d_data->step, true ); -} - -/*! - \brief Increment the value by a specified number of pages - \param nPages Number of pages to increment. - A negative number decrements the value. - \warning The Page size is specified in the constructor. -*/ -void QwtDoubleRange::incPages( int nPages ) -{ - if ( isValid() ) - { - const double off = d_data->step * d_data->pageSize * nPages; - setNewValue( d_data->value + off, true ); - } -} - -/*! - \brief Notify a change of value - - This virtual function is called whenever the value changes. - The default implementation does nothing. -*/ -void QwtDoubleRange::valueChange() -{ -} - - -/*! - \brief Notify a change of the range - - This virtual function is called whenever the range changes. - The default implementation does nothing. -*/ -void QwtDoubleRange::rangeChange() -{ -} - - -/*! - \brief Notify a change of the step size - - This virtual function is called whenever the step size changes. - The default implementation does nothing. -*/ -void QwtDoubleRange::stepChange() -{ -} - -/*! - \return the step size - \sa setStep(), setRange() -*/ -double QwtDoubleRange::step() const -{ - return qAbs( d_data->step ); -} - -/*! - \brief Returns the value of the second border of the range - - maxValue returns the value which has been specified - as the second parameter in QwtDoubleRange::setRange. - - \sa setRange() -*/ -double QwtDoubleRange::maxValue() const -{ - return d_data->maxValue; -} - -/*! - \brief Returns the value at the first border of the range - - minValue returns the value which has been specified - as the first parameter in setRange(). - - \sa setRange() -*/ -double QwtDoubleRange::minValue() const -{ - return d_data->minValue; -} - -/*! - \brief Returns true if the range is periodic - \sa setPeriodic() -*/ -bool QwtDoubleRange::periodic() const -{ - return d_data->periodic; -} - -//! Returns the page size in steps. -int QwtDoubleRange::pageSize() const -{ - return d_data->pageSize; -} - -//! Returns the current value. -double QwtDoubleRange::value() const -{ - return d_data->value; -} - -/*! - \brief Returns the exact value - - The exact value is the value which QwtDoubleRange::value would return - if the value were not adjusted to the step raster. It differs from - the current value only if fitValue() or incValue() have been used before. - This function is intended for internal use in derived classes. -*/ -double QwtDoubleRange::exactValue() const -{ - return d_data->exactValue; -} - -//! Returns the exact previous value -double QwtDoubleRange::exactPrevValue() const -{ - return d_data->exactPrevValue; -} - -//! Returns the previous value -double QwtDoubleRange::prevValue() const -{ - return d_data->prevValue; -} diff --git a/qwt/src/qwt_double_range.h b/qwt/src/qwt_double_range.h deleted file mode 100644 index 209857f8a..000000000 --- a/qwt/src/qwt_double_range.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_DOUBLE_RANGE_H -#define QWT_DOUBLE_RANGE_H - -#include "qwt_global.h" - -/*! - \brief A class which controls a value within an interval - - This class is useful as a base class or a member for sliders. - It represents an interval of type double within which a value can - be moved. The value can be either an arbitrary point inside - the interval (see QwtDoubleRange::setValue), or it can be fitted - into a step raster (see QwtDoubleRange::fitValue and - QwtDoubleRange::incValue). - - As a special case, a QwtDoubleRange can be periodic, which means that - a value outside the interval will be mapped to a value inside the - interval when QwtDoubleRange::setValue(), QwtDoubleRange::fitValue(), - QwtDoubleRange::incValue() or QwtDoubleRange::incPages() are called. -*/ - -class QWT_EXPORT QwtDoubleRange -{ -public: - QwtDoubleRange(); - virtual ~QwtDoubleRange(); - - void setRange( double vmin, double vmax, - double vstep = 0.0, int pagesize = 1 ); - - void setValid( bool ); - bool isValid() const; - - virtual void setValue( double ); - double value() const; - - void setPeriodic( bool tf ); - bool periodic() const; - - void setStep( double ); - double step() const; - - double maxValue() const; - double minValue() const; - - int pageSize() const; - - virtual void incValue( int ); - virtual void incPages( int ); - virtual void fitValue( double ); - -protected: - - double exactValue() const; - double exactPrevValue() const; - double prevValue() const; - - virtual void valueChange(); - virtual void stepChange(); - virtual void rangeChange(); - -private: - void setNewValue( double value, bool align = false ); - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_dyngrid_layout.cpp b/qwt/src/qwt_dyngrid_layout.cpp deleted file mode 100644 index cd621dcfc..000000000 --- a/qwt/src/qwt_dyngrid_layout.cpp +++ /dev/null @@ -1,571 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_dyngrid_layout.h" -#include "qwt_math.h" -#include -#include - -class QwtDynGridLayout::PrivateData -{ -public: - PrivateData(): - isDirty( true ) - { - } - - void updateLayoutCache(); - - mutable QList itemList; - - uint maxCols; - uint numRows; - uint numCols; - - Qt::Orientations expanding; - - bool isDirty; - QVector itemSizeHints; -}; - -void QwtDynGridLayout::PrivateData::updateLayoutCache() -{ - itemSizeHints.resize( itemList.count() ); - - int index = 0; - - for ( QList::iterator it = itemList.begin(); - it != itemList.end(); ++it, index++ ) - { - itemSizeHints[ index ] = ( *it )->sizeHint(); - } - - isDirty = false; -} - -/*! - \param parent Parent widget - \param margin Margin - \param spacing Spacing -*/ - -QwtDynGridLayout::QwtDynGridLayout( QWidget *parent, - int margin, int spacing ): - QLayout( parent ) -{ - init(); - - setSpacing( spacing ); - setMargin( margin ); -} - -/*! - \param spacing Spacing -*/ - -QwtDynGridLayout::QwtDynGridLayout( int spacing ) -{ - init(); - setSpacing( spacing ); -} - -/*! - Initialize the layout with default values. -*/ -void QwtDynGridLayout::init() -{ - d_data = new QwtDynGridLayout::PrivateData; - d_data->maxCols = d_data->numRows = d_data->numCols = 0; - d_data->expanding = 0; -} - -//! Destructor - -QwtDynGridLayout::~QwtDynGridLayout() -{ - for ( int i = 0; i < d_data->itemList.size(); i++ ) - delete d_data->itemList[i]; - - delete d_data; -} - -//! Invalidate all internal caches -void QwtDynGridLayout::invalidate() -{ - d_data->isDirty = true; - QLayout::invalidate(); -} - -/*! - Limit the number of columns. - \param maxCols upper limit, 0 means unlimited - \sa maxCols() -*/ -void QwtDynGridLayout::setMaxCols( uint maxCols ) -{ - d_data->maxCols = maxCols; -} - -/*! - Return the upper limit for the number of columns. - 0 means unlimited, what is the default. - \sa setMaxCols() -*/ - -uint QwtDynGridLayout::maxCols() const -{ - return d_data->maxCols; -} - -//! Adds item to the next free position. - -void QwtDynGridLayout::addItem( QLayoutItem *item ) -{ - d_data->itemList.append( item ); - invalidate(); -} - -/*! - \return true if this layout is empty. -*/ - -bool QwtDynGridLayout::isEmpty() const -{ - return d_data->itemList.isEmpty(); -} - -/*! - \return number of layout items -*/ - -uint QwtDynGridLayout::itemCount() const -{ - return d_data->itemList.count(); -} - -/*! - Find the item at a spcific index - - \param index Index - \sa takeAt() -*/ -QLayoutItem *QwtDynGridLayout::itemAt( int index ) const -{ - if ( index < 0 || index >= d_data->itemList.count() ) - return NULL; - - return d_data->itemList.at( index ); -} - -/*! - Find the item at a spcific index and remove it from the layout - - \param index Index - \sa itemAt() -*/ -QLayoutItem *QwtDynGridLayout::takeAt( int index ) -{ - if ( index < 0 || index >= d_data->itemList.count() ) - return NULL; - - d_data->isDirty = true; - return d_data->itemList.takeAt( index ); -} - -//! \return Number of items in the layout -int QwtDynGridLayout::count() const -{ - return d_data->itemList.count(); -} - -/*! - Set whether this layout can make use of more space than sizeHint(). - A value of Qt::Vertical or Qt::Horizontal means that it wants to grow in only - one dimension, while Qt::Vertical | Qt::Horizontal means that it wants - to grow in both dimensions. The default value is 0. - - \param expanding Or'd orientations - \sa expandingDirections() -*/ -void QwtDynGridLayout::setExpandingDirections( Qt::Orientations expanding ) -{ - d_data->expanding = expanding; -} - -/*! - Returns whether this layout can make use of more space than sizeHint(). - A value of Qt::Vertical or Qt::Horizontal means that it wants to grow in only - one dimension, while Qt::Vertical | Qt::Horizontal means that it wants - to grow in both dimensions. - \sa setExpandingDirections() -*/ -Qt::Orientations QwtDynGridLayout::expandingDirections() const -{ - return d_data->expanding; -} - -/*! - Reorganizes columns and rows and resizes managed widgets within - the rectangle rect. - - \param rect Layout geometry -*/ -void QwtDynGridLayout::setGeometry( const QRect &rect ) -{ - QLayout::setGeometry( rect ); - - if ( isEmpty() ) - return; - - d_data->numCols = columnsForWidth( rect.width() ); - d_data->numRows = itemCount() / d_data->numCols; - if ( itemCount() % d_data->numCols ) - d_data->numRows++; - - QList itemGeometries = layoutItems( rect, d_data->numCols ); - - int index = 0; - for ( QList::iterator it = d_data->itemList.begin(); - it != d_data->itemList.end(); ++it ) - { - QWidget *w = ( *it )->widget(); - if ( w ) - { - w->setGeometry( itemGeometries[index] ); - index++; - } - } -} - -/*! - Calculate the number of columns for a given width. It tries to - use as many columns as possible (limited by maxCols()) - - \param width Available width for all columns - \sa maxCols(), setMaxCols() -*/ - -uint QwtDynGridLayout::columnsForWidth( int width ) const -{ - if ( isEmpty() ) - return 0; - - const int maxCols = ( d_data->maxCols > 0 ) ? d_data->maxCols : itemCount(); - if ( maxRowWidth( maxCols ) <= width ) - return maxCols; - - for ( int numCols = 2; numCols <= maxCols; numCols++ ) - { - const int rowWidth = maxRowWidth( numCols ); - if ( rowWidth > width ) - return numCols - 1; - } - - return 1; // At least 1 column -} - -/*! - Calculate the width of a layout for a given number of - columns. - - \param numCols Given number of columns - \param itemWidth Array of the width hints for all items -*/ -int QwtDynGridLayout::maxRowWidth( int numCols ) const -{ - int col; - - QVector colWidth( numCols ); - for ( col = 0; col < numCols; col++ ) - colWidth[col] = 0; - - if ( d_data->isDirty ) - d_data->updateLayoutCache(); - - for ( int index = 0; - index < d_data->itemSizeHints.count(); index++ ) - { - col = index % numCols; - colWidth[col] = qMax( colWidth[col], - d_data->itemSizeHints[int( index )].width() ); - } - - int rowWidth = 2 * margin() + ( numCols - 1 ) * spacing(); - for ( col = 0; col < numCols; col++ ) - rowWidth += colWidth[col]; - - return rowWidth; -} - -/*! - \return the maximum width of all layout items -*/ -int QwtDynGridLayout::maxItemWidth() const -{ - if ( isEmpty() ) - return 0; - - if ( d_data->isDirty ) - d_data->updateLayoutCache(); - - int w = 0; - for ( int i = 0; i < d_data->itemSizeHints.count(); i++ ) - { - const int itemW = d_data->itemSizeHints[i].width(); - if ( itemW > w ) - w = itemW; - } - - return w; -} - -/*! - Calculate the geometries of the layout items for a layout - with numCols columns and a given rect. - - \param rect Rect where to place the items - \param numCols Number of columns - \return item geometries -*/ - -QList QwtDynGridLayout::layoutItems( const QRect &rect, - uint numCols ) const -{ - QList itemGeometries; - if ( numCols == 0 || isEmpty() ) - return itemGeometries; - - uint numRows = itemCount() / numCols; - if ( numRows % itemCount() ) - numRows++; - - QVector rowHeight( numRows ); - QVector colWidth( numCols ); - - layoutGrid( numCols, rowHeight, colWidth ); - - bool expandH, expandV; - expandH = expandingDirections() & Qt::Horizontal; - expandV = expandingDirections() & Qt::Vertical; - - if ( expandH || expandV ) - stretchGrid( rect, numCols, rowHeight, colWidth ); - - const int maxCols = d_data->maxCols; - d_data->maxCols = numCols; - const QRect alignedRect = alignmentRect( rect ); - d_data->maxCols = maxCols; - - const int xOffset = expandH ? 0 : alignedRect.x(); - const int yOffset = expandV ? 0 : alignedRect.y(); - - QVector colX( numCols ); - QVector rowY( numRows ); - - const int xySpace = spacing(); - - rowY[0] = yOffset + margin(); - for ( int r = 1; r < ( int )numRows; r++ ) - rowY[r] = rowY[r-1] + rowHeight[r-1] + xySpace; - - colX[0] = xOffset + margin(); - for ( int c = 1; c < ( int )numCols; c++ ) - colX[c] = colX[c-1] + colWidth[c-1] + xySpace; - - const int itemCount = d_data->itemList.size(); - for ( int i = 0; i < itemCount; i++ ) - { - const int row = i / numCols; - const int col = i % numCols; - - QRect itemGeometry( colX[col], rowY[row], - colWidth[col], rowHeight[row] ); - itemGeometries.append( itemGeometry ); - } - - return itemGeometries; -} - - -/*! - Calculate the dimensions for the columns and rows for a grid - of numCols columns. - - \param numCols Number of columns. - \param rowHeight Array where to fill in the calculated row heights. - \param colWidth Array where to fill in the calculated column widths. -*/ - -void QwtDynGridLayout::layoutGrid( uint numCols, - QVector& rowHeight, QVector& colWidth ) const -{ - if ( numCols <= 0 ) - return; - - if ( d_data->isDirty ) - d_data->updateLayoutCache(); - - for ( uint index = 0; - index < ( uint )d_data->itemSizeHints.count(); index++ ) - { - const int row = index / numCols; - const int col = index % numCols; - - const QSize &size = d_data->itemSizeHints[int( index )]; - - rowHeight[row] = ( col == 0 ) - ? size.height() : qMax( rowHeight[row], size.height() ); - colWidth[col] = ( row == 0 ) - ? size.width() : qMax( colWidth[col], size.width() ); - } -} - -/*! - \return true: QwtDynGridLayout implements heightForWidth. - \sa heightForWidth() -*/ -bool QwtDynGridLayout::hasHeightForWidth() const -{ - return true; -} - -/*! - \return The preferred height for this layout, given the width w. - \sa hasHeightForWidth() -*/ -int QwtDynGridLayout::heightForWidth( int width ) const -{ - if ( isEmpty() ) - return 0; - - const uint numCols = columnsForWidth( width ); - uint numRows = itemCount() / numCols; - if ( itemCount() % numCols ) - numRows++; - - QVector rowHeight( numRows ); - QVector colWidth( numCols ); - - layoutGrid( numCols, rowHeight, colWidth ); - - int h = 2 * margin() + ( numRows - 1 ) * spacing(); - for ( int row = 0; row < ( int )numRows; row++ ) - h += rowHeight[row]; - - return h; -} - -/*! - Stretch columns in case of expanding() & QSizePolicy::Horizontal and - rows in case of expanding() & QSizePolicy::Vertical to fill the entire - rect. Rows and columns are stretched with the same factor. - - \sa setExpanding(), expanding() -*/ -void QwtDynGridLayout::stretchGrid( const QRect &rect, - uint numCols, QVector& rowHeight, QVector& colWidth ) const -{ - if ( numCols == 0 || isEmpty() ) - return; - - bool expandH, expandV; - expandH = expandingDirections() & Qt::Horizontal; - expandV = expandingDirections() & Qt::Vertical; - - if ( expandH ) - { - int xDelta = rect.width() - 2 * margin() - ( numCols - 1 ) * spacing(); - for ( int col = 0; col < ( int )numCols; col++ ) - xDelta -= colWidth[col]; - - if ( xDelta > 0 ) - { - for ( int col = 0; col < ( int )numCols; col++ ) - { - const int space = xDelta / ( numCols - col ); - colWidth[col] += space; - xDelta -= space; - } - } - } - - if ( expandV ) - { - uint numRows = itemCount() / numCols; - if ( itemCount() % numCols ) - numRows++; - - int yDelta = rect.height() - 2 * margin() - ( numRows - 1 ) * spacing(); - for ( int row = 0; row < ( int )numRows; row++ ) - yDelta -= rowHeight[row]; - - if ( yDelta > 0 ) - { - for ( int row = 0; row < ( int )numRows; row++ ) - { - const int space = yDelta / ( numRows - row ); - rowHeight[row] += space; - yDelta -= space; - } - } - } -} - -/*! - Return the size hint. If maxCols() > 0 it is the size for - a grid with maxCols() columns, otherwise it is the size for - a grid with only one row. - - \sa maxCols(), setMaxCols() -*/ -QSize QwtDynGridLayout::sizeHint() const -{ - if ( isEmpty() ) - return QSize(); - - const uint numCols = ( d_data->maxCols > 0 ) ? d_data->maxCols : itemCount(); - uint numRows = itemCount() / numCols; - if ( itemCount() % numCols ) - numRows++; - - QVector rowHeight( numRows ); - QVector colWidth( numCols ); - - layoutGrid( numCols, rowHeight, colWidth ); - - int h = 2 * margin() + ( numRows - 1 ) * spacing(); - for ( int row = 0; row < ( int )numRows; row++ ) - h += rowHeight[row]; - - int w = 2 * margin() + ( numCols - 1 ) * spacing(); - for ( int col = 0; col < ( int )numCols; col++ ) - w += colWidth[col]; - - return QSize( w, h ); -} - -/*! - \return Number of rows of the current layout. - \sa numCols() - \warning The number of rows might change whenever the geometry changes -*/ -uint QwtDynGridLayout::numRows() const -{ - return d_data->numRows; -} - -/*! - \return Number of columns of the current layout. - \sa numRows() - \warning The number of columns might change whenever the geometry changes -*/ -uint QwtDynGridLayout::numCols() const -{ - return d_data->numCols; -} diff --git a/qwt/src/qwt_dyngrid_layout.h b/qwt/src/qwt_dyngrid_layout.h deleted file mode 100644 index 0b835f03a..000000000 --- a/qwt/src/qwt_dyngrid_layout.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_DYNGRID_LAYOUT_H -#define QWT_DYNGRID_LAYOUT_H - -#include "qwt_global.h" -#include -#include -#include - -/*! - \brief The QwtDynGridLayout class lays out widgets in a grid, - adjusting the number of columns and rows to the current size. - - QwtDynGridLayout takes the space it gets, divides it up into rows and - columns, and puts each of the widgets it manages into the correct cell(s). - It lays out as many number of columns as possible (limited by maxCols()). -*/ - -class QWT_EXPORT QwtDynGridLayout : public QLayout -{ - Q_OBJECT -public: - explicit QwtDynGridLayout( QWidget *, int margin = 0, int space = -1 ); - explicit QwtDynGridLayout( int space = -1 ); - - virtual ~QwtDynGridLayout(); - - virtual void invalidate(); - - void setMaxCols( uint maxCols ); - uint maxCols() const; - - uint numRows () const; - uint numCols () const; - - virtual void addItem( QLayoutItem * ); - - virtual QLayoutItem *itemAt( int index ) const; - virtual QLayoutItem *takeAt( int index ); - virtual int count() const; - - void setExpandingDirections( Qt::Orientations ); - virtual Qt::Orientations expandingDirections() const; - QList layoutItems( const QRect &, uint numCols ) const; - - virtual int maxItemWidth() const; - - virtual void setGeometry( const QRect &rect ); - - virtual bool hasHeightForWidth() const; - virtual int heightForWidth( int ) const; - - virtual QSize sizeHint() const; - - virtual bool isEmpty() const; - uint itemCount() const; - - virtual uint columnsForWidth( int width ) const; - -protected: - - void layoutGrid( uint numCols, - QVector& rowHeight, QVector& colWidth ) const; - void stretchGrid( const QRect &rect, uint numCols, - QVector& rowHeight, QVector& colWidth ) const; - -private: - void init(); - int maxRowWidth( int numCols ) const; - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_event_pattern.cpp b/qwt/src/qwt_event_pattern.cpp deleted file mode 100644 index 2579616c1..000000000 --- a/qwt/src/qwt_event_pattern.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_event_pattern.h" -#include - -/*! - Constructor - - \sa MousePatternCode, KeyPatternCode -*/ - -QwtEventPattern::QwtEventPattern(): - d_mousePattern( MousePatternCount ), - d_keyPattern( KeyPatternCount ) -{ - initKeyPattern(); - initMousePattern( 3 ); -} - -//! Destructor -QwtEventPattern::~QwtEventPattern() -{ -} - -/*! - Set default mouse patterns, depending on the number of mouse buttons - - \param numButtons Number of mouse buttons ( <= 3 ) - \sa MousePatternCode -*/ -void QwtEventPattern::initMousePattern( int numButtons ) -{ - const int altButton = Qt::AltModifier; - const int controlButton = Qt::ControlModifier; - const int shiftButton = Qt::ShiftModifier; - - d_mousePattern.resize( MousePatternCount ); - - switch ( numButtons ) - { - case 1: - { - setMousePattern( MouseSelect1, Qt::LeftButton ); - setMousePattern( MouseSelect2, Qt::LeftButton, controlButton ); - setMousePattern( MouseSelect3, Qt::LeftButton, altButton ); - break; - } - case 2: - { - setMousePattern( MouseSelect1, Qt::LeftButton ); - setMousePattern( MouseSelect2, Qt::RightButton ); - setMousePattern( MouseSelect3, Qt::LeftButton, altButton ); - break; - } - default: - { - setMousePattern( MouseSelect1, Qt::LeftButton ); - setMousePattern( MouseSelect2, Qt::RightButton ); - setMousePattern( MouseSelect3, Qt::MidButton ); - } - } - for ( int i = 0; i < 3; i++ ) - { - setMousePattern( MouseSelect4 + i, - d_mousePattern[MouseSelect1 + i].button, - d_mousePattern[MouseSelect1 + i].state | shiftButton ); - } -} - -/*! - Set default mouse patterns. - - \sa KeyPatternCode -*/ -void QwtEventPattern::initKeyPattern() -{ - d_keyPattern.resize( KeyPatternCount ); - - setKeyPattern( KeySelect1, Qt::Key_Return ); - setKeyPattern( KeySelect2, Qt::Key_Space ); - setKeyPattern( KeyAbort, Qt::Key_Escape ); - - setKeyPattern( KeyLeft, Qt::Key_Left ); - setKeyPattern( KeyRight, Qt::Key_Right ); - setKeyPattern( KeyUp, Qt::Key_Up ); - setKeyPattern( KeyDown, Qt::Key_Down ); - - setKeyPattern( KeyRedo, Qt::Key_Plus ); - setKeyPattern( KeyUndo, Qt::Key_Minus ); - setKeyPattern( KeyHome, Qt::Key_Escape ); -} - -/*! - Change one mouse pattern - - \param pattern Index of the pattern - \param button Button - \param state State - - \sa QMouseEvent -*/ -void QwtEventPattern::setMousePattern( uint pattern, int button, int state ) -{ - if ( pattern < ( uint )d_mousePattern.count() ) - { - d_mousePattern[int( pattern )].button = button; - d_mousePattern[int( pattern )].state = state; - } -} - -/*! - Change one key pattern - - \param pattern Index of the pattern - \param key Key - \param state State - - \sa QKeyEvent -*/ -void QwtEventPattern::setKeyPattern( uint pattern, int key, int state ) -{ - if ( pattern < ( uint )d_keyPattern.count() ) - { - d_keyPattern[int( pattern )].key = key; - d_keyPattern[int( pattern )].state = state; - } -} - -//! Change the mouse event patterns -void QwtEventPattern::setMousePattern( const QVector &pattern ) -{ - d_mousePattern = pattern; -} - -//! Change the key event patterns -void QwtEventPattern::setKeyPattern( const QVector &pattern ) -{ - d_keyPattern = pattern; -} - -//! Return mouse patterns -const QVector & -QwtEventPattern::mousePattern() const -{ - return d_mousePattern; -} - -//! Return key patterns -const QVector & -QwtEventPattern::keyPattern() const -{ - return d_keyPattern; -} - -//! Return ,ouse patterns -QVector &QwtEventPattern::mousePattern() -{ - return d_mousePattern; -} - -//! Return Key patterns -QVector &QwtEventPattern::keyPattern() -{ - return d_keyPattern; -} - -/*! - \brief Compare a mouse event with an event pattern. - - A mouse event matches the pattern when both have the same button - value and in the state value the same key flags(Qt::KeyButtonMask) - are set. - - \param pattern Index of the event pattern - \param event Mouse event - \return true if matches - - \sa keyMatch() -*/ -bool QwtEventPattern::mouseMatch( uint pattern, - const QMouseEvent *event ) const -{ - bool ok = false; - - if ( event && pattern < ( uint )d_mousePattern.count() ) - ok = mouseMatch( d_mousePattern[int( pattern )], event ); - - return ok; -} - -/*! - \brief Compare a mouse event with an event pattern. - - A mouse event matches the pattern when both have the same button - value and in the state value the same key flags(Qt::KeyButtonMask) - are set. - - \param pattern Mouse event pattern - \param event Mouse event - \return true if matches - - \sa keyMatch() -*/ - -bool QwtEventPattern::mouseMatch( const MousePattern &pattern, - const QMouseEvent *event ) const -{ - if ( event->button() != pattern.button ) - return false; - - const bool matched = - ( event->modifiers() & Qt::KeyboardModifierMask ) == - ( int )( pattern.state & Qt::KeyboardModifierMask ); - - return matched; -} - -/*! - \brief Compare a key event with an event pattern. - - A key event matches the pattern when both have the same key - value and in the state value the same key flags (Qt::KeyButtonMask) - are set. - - \param pattern Index of the event pattern - \param event Key event - \return true if matches - - \sa mouseMatch() -*/ -bool QwtEventPattern::keyMatch( uint pattern, - const QKeyEvent *event ) const -{ - bool ok = false; - - if ( event && pattern < ( uint )d_keyPattern.count() ) - ok = keyMatch( d_keyPattern[int( pattern )], event ); - - return ok; -} - -/*! - \brief Compare a key event with an event pattern. - - A key event matches the pattern when both have the same key - value and in the state value the same key flags (Qt::KeyButtonMask) - are set. - - \param pattern Key event pattern - \param event Key event - \return true if matches - - \sa mouseMatch() -*/ - -bool QwtEventPattern::keyMatch( - const KeyPattern &pattern, const QKeyEvent *event ) const -{ - if ( event->key() != pattern.key ) - return false; - - const bool matched = - ( event->modifiers() & Qt::KeyboardModifierMask ) == - ( int )( pattern.state & Qt::KeyboardModifierMask ); - - return matched; -} diff --git a/qwt/src/qwt_event_pattern.h b/qwt/src/qwt_event_pattern.h deleted file mode 100644 index a88f5f4a9..000000000 --- a/qwt/src/qwt_event_pattern.h +++ /dev/null @@ -1,225 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_EVENT_PATTERN -#define QWT_EVENT_PATTERN 1 - -#include "qwt_global.h" -#include -#include - -class QMouseEvent; -class QKeyEvent; - -/*! - \brief A collection of event patterns - - QwtEventPattern introduces an level of indirection for mouse and - keyboard inputs. Those are represented by symbolic names, so - the application code can be configured by individual mappings. - - \sa QwtPicker, QwtPickerMachine, QwtPlotZoomer -*/ -class QWT_EXPORT QwtEventPattern -{ -public: - /*! - \brief Symbolic mouse input codes - - The default initialization for 3 button mice is: - - MouseSelect1\n - Qt::LeftButton - - MouseSelect2\n - Qt::RightButton - - MouseSelect3\n - Qt::MidButton - - MouseSelect4\n - Qt::LeftButton + Qt::ShiftButton - - MouseSelect5\n - Qt::RightButton + Qt::ShiftButton - - MouseSelect6\n - Qt::MidButton + Qt::ShiftButton - - The default initialization for 2 button mice is: - - MouseSelect1\n - Qt::LeftButton - - MouseSelect2\n - Qt::RightButton - - MouseSelect3\n - Qt::LeftButton + Qt::AltButton - - MouseSelect4\n - Qt::LeftButton + Qt::ShiftButton - - MouseSelect5\n - Qt::RightButton + Qt::ShiftButton - - MouseSelect6\n - Qt::LeftButton + Qt::AltButton + Qt::ShiftButton - - The default initialization for 1 button mice is: - - MouseSelect1\n - Qt::LeftButton - - MouseSelect2\n - Qt::LeftButton + Qt::ControlButton - - MouseSelect3\n - Qt::LeftButton + Qt::AltButton - - MouseSelect4\n - Qt::LeftButton + Qt::ShiftButton - - MouseSelect5\n - Qt::LeftButton + Qt::ControlButton + Qt::ShiftButton - - MouseSelect6\n - Qt::LeftButton + Qt::AltButton + Qt::ShiftButton - - \sa initMousePattern() - */ - - enum MousePatternCode - { - MouseSelect1, - MouseSelect2, - MouseSelect3, - MouseSelect4, - MouseSelect5, - MouseSelect6, - - MousePatternCount - }; - - /*! - \brief Symbolic keyboard input codes - - Default initialization: - - KeySelect1\n - Qt::Key_Return - - KeySelect2\n - Qt::Key_Space - - KeyAbort\n - Qt::Key_Escape - - - KeyLeft\n - Qt::Key_Left - - KeyRight\n - Qt::Key_Right - - KeyUp\n - Qt::Key_Up - - KeyDown\n - Qt::Key_Down - - - KeyUndo\n - Qt::Key_Minus - - KeyRedo\n - Qt::Key_Plus - - KeyHome\n - Qt::Key_Escape - */ - enum KeyPatternCode - { - KeySelect1, - KeySelect2, - KeyAbort, - - KeyLeft, - KeyRight, - KeyUp, - KeyDown, - - KeyRedo, - KeyUndo, - KeyHome, - - KeyPatternCount - }; - - //! A pattern for mouse events - class MousePattern - { - public: - //! Constructor - MousePattern( int btn = Qt::NoButton, int st = Qt::NoButton ) - { - button = btn; - state = st; - } - - //! Button code - int button; - - //! State - int state; - }; - - //! A pattern for key events - class KeyPattern - { - public: - //! Constructor - KeyPattern( int k = 0, int st = Qt::NoButton ) - { - key = k; - state = st; - } - - //! Key code - int key; - - //! State - int state; - }; - - QwtEventPattern(); - virtual ~QwtEventPattern(); - - void initMousePattern( int numButtons ); - void initKeyPattern(); - - void setMousePattern( uint pattern, int button, int state = Qt::NoButton ); - void setKeyPattern( uint pattern, int key, int state = Qt::NoButton ); - - void setMousePattern( const QVector & ); - void setKeyPattern( const QVector & ); - - const QVector &mousePattern() const; - const QVector &keyPattern() const; - - QVector &mousePattern(); - QVector &keyPattern(); - - bool mouseMatch( uint pattern, const QMouseEvent * ) const; - bool keyMatch( uint pattern, const QKeyEvent * ) const; - -protected: - virtual bool mouseMatch( const MousePattern &, const QMouseEvent * ) const; - virtual bool keyMatch( const KeyPattern &, const QKeyEvent * ) const; - -private: - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable: 4251) -#endif - QVector d_mousePattern; - QVector d_keyPattern; -#if defined(_MSC_VER) -#pragma warning(pop) -#endif -}; - -//! Compare operator -inline bool operator==( QwtEventPattern::MousePattern b1, - QwtEventPattern::MousePattern b2 ) -{ - return b1.button == b2.button && b1.state == b2.state; -} - -//! Compare operator -inline bool operator==( QwtEventPattern::KeyPattern b1, - QwtEventPattern::KeyPattern b2 ) -{ - return b1.key == b2.key && b1.state == b2.state; -} - -#endif diff --git a/qwt/src/qwt_global.h b/qwt/src/qwt_global.h deleted file mode 100644 index cf3126b6a..000000000 --- a/qwt/src/qwt_global.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_GLOBAL_H -#define QWT_GLOBAL_H - -#include - -// QWT_VERSION is (major << 16) + (minor << 8) + patch. - -#define QWT_VERSION 0x060001 -#define QWT_VERSION_STR "6.0.1" - -#if defined(Q_WS_WIN) || defined(Q_WS_S60) - -#if defined(_MSC_VER) /* MSVC Compiler */ -/* template-class specialization 'identifier' is already instantiated */ -#pragma warning(disable: 4660) -#endif // _MSC_VER - -#ifdef QWT_DLL - -#if defined(QWT_MAKEDLL) // create a Qwt DLL library -#define QWT_EXPORT __declspec(dllexport) -#define QWT_TEMPLATEDLL -#else // use a Qwt DLL library -#define QWT_EXPORT __declspec(dllimport) -#endif - -#endif // QWT_DLL - -#endif // Q_WS_WIN || Q_WS_S60 - -#ifndef QWT_EXPORT -#define QWT_EXPORT -#endif - -// #define QWT_NO_COMPAT 1 // disable withdrawn functionality - -#endif diff --git a/qwt/src/qwt_interval.cpp b/qwt/src/qwt_interval.cpp deleted file mode 100644 index f8355671e..000000000 --- a/qwt/src/qwt_interval.cpp +++ /dev/null @@ -1,334 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_interval.h" -#include "qwt_math.h" -#include - -/*! - \brief Normalize the limits of the interval - - If maxValue() < minValue() the limits will be inverted. - \return Normalized interval - - \sa isValid(), inverted() -*/ -QwtInterval QwtInterval::normalized() const -{ - if ( d_minValue > d_maxValue ) - { - return inverted(); - } - if ( d_minValue == d_maxValue && d_borderFlags == ExcludeMinimum ) - { - return inverted(); - } - - return *this; -} - -/*! - Invert the limits of the interval - \return Inverted interval - \sa normalized() -*/ -QwtInterval QwtInterval::inverted() const -{ - BorderFlags borderFlags = IncludeBorders; - if ( d_borderFlags & ExcludeMinimum ) - borderFlags |= ExcludeMaximum; - if ( d_borderFlags & ExcludeMaximum ) - borderFlags |= ExcludeMinimum; - - return QwtInterval( d_maxValue, d_minValue, borderFlags ); -} - -/*! - Test if a value is inside an interval - - \param value Value - \return true, if value >= minValue() && value <= maxValue() -*/ -bool QwtInterval::contains( double value ) const -{ - if ( !isValid() ) - return false; - - if ( value < d_minValue || value > d_maxValue ) - return false; - - if ( value == d_minValue && d_borderFlags & ExcludeMinimum ) - return false; - - if ( value == d_maxValue && d_borderFlags & ExcludeMaximum ) - return false; - - return true; -} - -//! Unite 2 intervals -QwtInterval QwtInterval::unite( const QwtInterval &other ) const -{ - /* - If one of the intervals is invalid return the other one. - If both are invalid return an invalid default interval - */ - if ( !isValid() ) - { - if ( !other.isValid() ) - return QwtInterval(); - else - return other; - } - if ( !other.isValid() ) - return *this; - - QwtInterval united; - BorderFlags flags = IncludeBorders; - - // minimum - if ( d_minValue < other.minValue() ) - { - united.setMinValue( d_minValue ); - flags &= d_borderFlags & ExcludeMinimum; - } - else if ( other.minValue() < d_minValue ) - { - united.setMinValue( other.minValue() ); - flags &= other.borderFlags() & ExcludeMinimum; - } - else // d_minValue == other.minValue() - { - united.setMinValue( d_minValue ); - flags &= ( d_borderFlags & other.borderFlags() ) & ExcludeMinimum; - } - - // maximum - if ( d_maxValue > other.maxValue() ) - { - united.setMaxValue( d_maxValue ); - flags &= d_borderFlags & ExcludeMaximum; - } - else if ( other.maxValue() > d_maxValue ) - { - united.setMaxValue( other.maxValue() ); - flags &= other.borderFlags() & ExcludeMaximum; - } - else // d_maxValue == other.maxValue() ) - { - united.setMaxValue( d_maxValue ); - flags &= d_borderFlags & other.borderFlags() & ExcludeMaximum; - } - - united.setBorderFlags( flags ); - return united; -} - -//! Intersect 2 intervals -QwtInterval QwtInterval::intersect( const QwtInterval &other ) const -{ - if ( !other.isValid() || !isValid() ) - return QwtInterval(); - - QwtInterval i1 = *this; - QwtInterval i2 = other; - - // swap i1/i2, so that the minimum of i1 - // is smaller then the minimum of i2 - - if ( i1.minValue() > i2.minValue() ) - { - qSwap( i1, i2 ); - } - else if ( i1.minValue() == i2.minValue() ) - { - if ( i1.borderFlags() & ExcludeMinimum ) - qSwap( i1, i2 ); - } - - if ( i1.maxValue() < i2.minValue() ) - { - return QwtInterval(); - } - - if ( i1.maxValue() == i2.minValue() ) - { - if ( i1.borderFlags() & ExcludeMaximum || - i2.borderFlags() & ExcludeMinimum ) - { - return QwtInterval(); - } - } - - QwtInterval intersected; - BorderFlags flags = IncludeBorders; - - intersected.setMinValue( i2.minValue() ); - flags |= i2.borderFlags() & ExcludeMinimum; - - if ( i1.maxValue() < i2.maxValue() ) - { - intersected.setMaxValue( i1.maxValue() ); - flags |= i1.borderFlags() & ExcludeMaximum; - } - else if ( i2.maxValue() < i1.maxValue() ) - { - intersected.setMaxValue( i2.maxValue() ); - flags |= i2.borderFlags() & ExcludeMaximum; - } - else // i1.maxValue() == i2.maxValue() - { - intersected.setMaxValue( i1.maxValue() ); - flags |= i1.borderFlags() & i2.borderFlags() & ExcludeMaximum; - } - - intersected.setBorderFlags( flags ); - return intersected; -} - -//! Unites this interval with the given interval. -QwtInterval& QwtInterval::operator|=( const QwtInterval & interval ) -{ - *this = *this | interval; - return *this; -} - -//! Intersects this interval with the given interval. -QwtInterval& QwtInterval::operator&=( const QwtInterval & interval ) -{ - *this = *this & interval; - return *this; -} - -/*! - Test if two intervals overlap -*/ -bool QwtInterval::intersects( const QwtInterval &other ) const -{ - if ( !isValid() || !other.isValid() ) - return false; - - QwtInterval i1 = *this; - QwtInterval i2 = other; - - // swap i1/i2, so that the minimum of i1 - // is smaller then the minimum of i2 - - if ( i1.minValue() > i2.minValue() ) - { - qSwap( i1, i2 ); - } - else if ( i1.minValue() == i2.minValue() && - i1.borderFlags() & ExcludeMinimum ) - { - qSwap( i1, i2 ); - } - - if ( i1.maxValue() > i2.minValue() ) - { - return true; - } - if ( i1.maxValue() == i2.minValue() ) - { - return !( ( i1.borderFlags() & ExcludeMaximum ) || - ( i2.borderFlags() & ExcludeMinimum ) ); - } - return false; -} - -/*! - Adjust the limit that is closer to value, so that value becomes - the center of the interval. - - \param value Center - \return Interval with value as center -*/ -QwtInterval QwtInterval::symmetrize( double value ) const -{ - if ( !isValid() ) - return *this; - - const double delta = - qMax( qAbs( value - d_maxValue ), qAbs( value - d_minValue ) ); - - return QwtInterval( value - delta, value + delta ); -} - -/*! - Limit the interval, keeping the border modes - - \param lowerBound Lower limit - \param upperBound Upper limit - - \return Limited interval -*/ -QwtInterval QwtInterval::limited( double lowerBound, double upperBound ) const -{ - if ( !isValid() || lowerBound > upperBound ) - return QwtInterval(); - - double minValue = qMax( d_minValue, lowerBound ); - minValue = qMin( minValue, upperBound ); - - double maxValue = qMax( d_maxValue, lowerBound ); - maxValue = qMin( maxValue, upperBound ); - - return QwtInterval( minValue, maxValue, d_borderFlags ); -} - -/*! - Extend the interval - - If value is below minValue, value becomes the lower limit. - If value is above maxValue, value becomes the upper limit. - - extend has no effect for invalid intervals - - \param value Value - \sa isValid() -*/ -QwtInterval QwtInterval::extend( double value ) const -{ - if ( !isValid() ) - return *this; - - return QwtInterval( qMin( value, d_minValue ), - qMax( value, d_maxValue ), d_borderFlags ); -} - -/*! - Extend an interval - - \param value Value - \return Reference of the extended interval - - \sa extend() -*/ -QwtInterval& QwtInterval::operator|=( double value ) -{ - *this = *this | value; - return *this; -} - -#ifndef QT_NO_DEBUG_STREAM - -QDebug operator<<( QDebug debug, const QwtInterval &interval ) -{ - const int flags = interval.borderFlags(); - - debug.nospace() << "QwtInterval(" - << ( ( flags & QwtInterval::ExcludeMinimum ) ? "]" : "[" ) - << interval.minValue() << "," << interval.maxValue() - << ( ( flags & QwtInterval::ExcludeMaximum ) ? "[" : "]" ) - << ")"; - - return debug.space(); -} - -#endif diff --git a/qwt/src/qwt_interval.h b/qwt/src/qwt_interval.h deleted file mode 100644 index 74df2da55..000000000 --- a/qwt/src/qwt_interval.h +++ /dev/null @@ -1,296 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_INTERVAL_H -#define QWT_INTERVAL_H - -#include "qwt_global.h" -#ifndef QT_NO_DEBUG_STREAM -#include -#endif - -/*! - \brief A class representing an interval - - The interval is represented by 2 doubles, the lower and the upper limit. -*/ - -class QWT_EXPORT QwtInterval -{ -public: - /*! - Flag indicating if a border is included or excluded - \sa setBorderFlags(), borderFlags() - */ - enum BorderFlag - { - //! Min/Max values are inside the interval - IncludeBorders = 0x00, - - //! Min value is not included in the interval - ExcludeMinimum = 0x01, - - //! Max value is not included in the interval - ExcludeMaximum = 0x02, - - //! Min/Max values are not included in the interval - ExcludeBorders = ExcludeMinimum | ExcludeMaximum - }; - - //! Border flags - typedef QFlags BorderFlags; - - QwtInterval(); - QwtInterval( double minValue, double maxValue, - BorderFlags = IncludeBorders ); - - void setInterval( double minValue, double maxValue, - BorderFlags = IncludeBorders ); - - QwtInterval normalized() const; - QwtInterval inverted() const; - QwtInterval limited( double minValue, double maxValue ) const; - - bool operator==( const QwtInterval & ) const; - bool operator!=( const QwtInterval & ) const; - - void setBorderFlags( BorderFlags ); - BorderFlags borderFlags() const; - - double minValue() const; - double maxValue() const; - - double width() const; - - void setMinValue( double ); - void setMaxValue( double ); - - bool contains( double value ) const; - - bool intersects( const QwtInterval & ) const; - QwtInterval intersect( const QwtInterval & ) const; - QwtInterval unite( const QwtInterval & ) const; - - QwtInterval operator|( const QwtInterval & ) const; - QwtInterval operator&( const QwtInterval & ) const; - - QwtInterval &operator|=( const QwtInterval & ); - QwtInterval &operator&=( const QwtInterval & ); - - QwtInterval extend( double value ) const; - QwtInterval operator|( double ) const; - QwtInterval &operator|=( double ); - - bool isValid() const; - bool isNull() const; - void invalidate(); - - QwtInterval symmetrize( double value ) const; - -private: - double d_minValue; - double d_maxValue; - BorderFlags d_borderFlags; -}; - -Q_DECLARE_TYPEINFO(QwtInterval, Q_MOVABLE_TYPE); - -/*! - \brief Default Constructor - - Creates an invalid interval [0.0, -1.0] - \sa setInterval(), isValid() -*/ -inline QwtInterval::QwtInterval(): - d_minValue( 0.0 ), - d_maxValue( -1.0 ), - d_borderFlags( IncludeBorders ) -{ -} - -/*! - Constructor - - Build an interval with from min/max values - - \param minValue Minimum value - \param maxValue Maximum value - \param borderFlags Include/Exclude borders -*/ -inline QwtInterval::QwtInterval( - double minValue, double maxValue, BorderFlags borderFlags ): - d_minValue( minValue ), - d_maxValue( maxValue ), - d_borderFlags( borderFlags ) -{ -} - -/*! - Assign the limits of the interval - - \param minValue Minimum value - \param maxValue Maximum value - \param borderFlags Include/Exclude borders -*/ -inline void QwtInterval::setInterval( - double minValue, double maxValue, BorderFlags borderFlags ) -{ - d_minValue = minValue; - d_maxValue = maxValue; - d_borderFlags = borderFlags; -} - -/*! - Change the border flags - - \param borderFlags Or'd BorderMode flags - \sa borderFlags() -*/ -inline void QwtInterval::setBorderFlags( BorderFlags borderFlags ) -{ - d_borderFlags = borderFlags; -} - -/*! - \return Border flags - \sa setBorderFlags() -*/ -inline QwtInterval::BorderFlags QwtInterval::borderFlags() const -{ - return d_borderFlags; -} - -/*! - Assign the lower limit of the interval - - \param minValue Minimum value -*/ -inline void QwtInterval::setMinValue( double minValue ) -{ - d_minValue = minValue; -} - -/*! - Assign the upper limit of the interval - - \param maxValue Maximum value -*/ -inline void QwtInterval::setMaxValue( double maxValue ) -{ - d_maxValue = maxValue; -} - -//! \return Lower limit of the interval -inline double QwtInterval::minValue() const -{ - return d_minValue; -} - -//! \return Upper limit of the interval -inline double QwtInterval::maxValue() const -{ - return d_maxValue; -} - -/*! - Return the width of an interval - The width of invalid intervals is 0.0, otherwise the result is - maxValue() - minValue(). - - \sa isValid() -*/ -inline double QwtInterval::width() const -{ - return isValid() ? ( d_maxValue - d_minValue ) : 0.0; -} - -/*! - Intersection of two intervals - \sa intersect() -*/ -inline QwtInterval QwtInterval::operator&( - const QwtInterval &interval ) const -{ - return intersect( interval ); -} - -/*! - Union of two intervals - \sa unite() -*/ -inline QwtInterval QwtInterval::operator|( - const QwtInterval &interval ) const -{ - return unite( interval ); -} - -//! Compare two intervals -inline bool QwtInterval::operator==( const QwtInterval &other ) const -{ - return ( d_minValue == other.d_minValue ) && - ( d_maxValue == other.d_maxValue ) && - ( d_borderFlags == other.d_borderFlags ); -} - -//! Compare two intervals -inline bool QwtInterval::operator!=( const QwtInterval &other ) const -{ - return ( !( *this == other ) ); -} - -/*! - Extend an interval - - \param value Value - \return Extended interval - \sa extend() -*/ -inline QwtInterval QwtInterval::operator|( double value ) const -{ - return extend( value ); -} - -//! \return true, if isValid() && (minValue() >= maxValue()) -inline bool QwtInterval::isNull() const -{ - return isValid() && d_minValue >= d_maxValue; -} - -/*! - A interval is valid when minValue() <= maxValue(). - In case of QwtInterval::ExcludeBorders it is true - when minValue() < maxValue() -*/ -inline bool QwtInterval::isValid() const -{ - if ( ( d_borderFlags & ExcludeBorders ) == 0 ) - return d_minValue <= d_maxValue; - else - return d_minValue < d_maxValue; -} - -/*! - Invalidate the interval - - The limits are set to interval [0.0, -1.0] - \sa isValid() -*/ -inline void QwtInterval::invalidate() -{ - d_minValue = 0.0; - d_maxValue = -1.0; -} - -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtInterval::BorderFlags ) - -#ifndef QT_NO_DEBUG_STREAM -QWT_EXPORT QDebug operator<<( QDebug, const QwtInterval & ); -#endif - -#endif diff --git a/qwt/src/qwt_interval_symbol.cpp b/qwt/src/qwt_interval_symbol.cpp deleted file mode 100644 index 881acb4b2..000000000 --- a/qwt/src/qwt_interval_symbol.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_interval_symbol.h" -#include "qwt_painter.h" -#include "qwt_math.h" -#include - -#if QT_VERSION < 0x040601 -#define qAtan2(y, x) ::atan2(y, x) -#endif - -class QwtIntervalSymbol::PrivateData -{ -public: - PrivateData(): - style( QwtIntervalSymbol::NoSymbol ), - width( 6 ) - { - } - - bool operator==( const PrivateData &other ) const - { - return ( style == other.style ) - && ( width == other.width ) - && ( brush == other.brush ) - && ( pen == other.pen ); - } - - QwtIntervalSymbol::Style style; - int width; - - QPen pen; - QBrush brush; -}; - -/*! - Constructor - - \param style Style of the symbol - \sa setStyle(), style(), Style -*/ -QwtIntervalSymbol::QwtIntervalSymbol( Style style ) -{ - d_data = new PrivateData(); - d_data->style = style; -} - -//! Copy constructor -QwtIntervalSymbol::QwtIntervalSymbol( const QwtIntervalSymbol &other ) -{ - d_data = new PrivateData(); - *d_data = *other.d_data; -} - -//! Destructor -QwtIntervalSymbol::~QwtIntervalSymbol() -{ - delete d_data; -} - -//! \brief Assignment operator -QwtIntervalSymbol &QwtIntervalSymbol::operator=( - const QwtIntervalSymbol &other ) -{ - *d_data = *other.d_data; - return *this; -} - -//! \brief Compare two symbols -bool QwtIntervalSymbol::operator==( - const QwtIntervalSymbol &other ) const -{ - return *d_data == *other.d_data; -} - -//! \brief Compare two symbols -bool QwtIntervalSymbol::operator!=( - const QwtIntervalSymbol &other ) const -{ - return !( *d_data == *other.d_data ); -} - -/*! - Specify the symbol style - - \param style Style - \sa style(), Style -*/ -void QwtIntervalSymbol::setStyle( Style style ) -{ - d_data->style = style; -} - -/*! - \return Current symbol style - \sa setStyle() -*/ -QwtIntervalSymbol::Style QwtIntervalSymbol::style() const -{ - return d_data->style; -} - -/*! - Specify the width of the symbol - It is used depending on the style. - - \param width Width - \sa width(), setStyle() -*/ -void QwtIntervalSymbol::setWidth( int width ) -{ - d_data->width = width; -} - -/*! - \return Width of the symbol. - \sa setWidth(), setStyle() -*/ -int QwtIntervalSymbol::width() const -{ - return d_data->width; -} - -/*! - \brief Assign a brush - - The brush is used for the Box style. - - \param brush Brush - \sa brush() -*/ -void QwtIntervalSymbol::setBrush( const QBrush &brush ) -{ - d_data->brush = brush; -} - -/*! - \return Brush - \sa setBrush() -*/ -const QBrush& QwtIntervalSymbol::brush() const -{ - return d_data->brush; -} - -/*! - Assign a pen - - \param pen Pen - \sa pen(), setBrush() -*/ -void QwtIntervalSymbol::setPen( const QPen &pen ) -{ - d_data->pen = pen; -} - -/*! - \return Pen - \sa setPen(), brush() -*/ -const QPen& QwtIntervalSymbol::pen() const -{ - return d_data->pen; -} - -/*! - Draw a symbol depending on its style - - \param painter Painter - \param orientation Orientation - \param from Start point of the interval in target device coordinates - \param to End point of the interval in target device coordinates - - \sa setStyle() -*/ -void QwtIntervalSymbol::draw( QPainter *painter, Qt::Orientation orientation, - const QPointF &from, const QPointF &to ) const -{ - const qreal pw = qMax( painter->pen().widthF(), qreal( 1.0 ) ); - - QPointF p1 = from; - QPointF p2 = to; - if ( QwtPainter::roundingAlignment( painter ) ) - { - p1 = p1.toPoint(); - p2 = p2.toPoint(); - } - - switch ( d_data->style ) - { - case QwtIntervalSymbol::Bar: - { - QwtPainter::drawLine( painter, p1, p2 ); - if ( d_data->width > pw ) - { - if ( ( orientation == Qt::Horizontal ) - && ( p1.y() == p2.y() ) ) - { - const double sw = d_data->width; - - const double y = p1.y() - sw / 2; - QwtPainter::drawLine( painter, - p1.x(), y, p1.x(), y + sw ); - QwtPainter::drawLine( painter, - p2.x(), y, p2.x(), y + sw ); - } - else if ( ( orientation == Qt::Vertical ) - && ( p1.x() == p2.x() ) ) - { - const double sw = d_data->width; - - const double x = p1.x() - sw / 2; - QwtPainter::drawLine( painter, - x, p1.y(), x + sw, p1.y() ); - QwtPainter::drawLine( painter, - x, p2.y(), x + sw, p2.y() ); - } - else - { - const double sw = d_data->width; - - const double dx = p2.x() - p1.x(); - const double dy = p2.y() - p1.y(); - const double angle = qAtan2( dy, dx ) + M_PI_2; - double dw2 = sw / 2.0; - - const double cx = qCos( angle ) * dw2; - const double sy = qSin( angle ) * dw2; - - QwtPainter::drawLine( painter, - p1.x() - cx, p1.y() - sy, - p1.x() + cx, p1.y() + sy ); - QwtPainter::drawLine( painter, - p2.x() - cx, p2.y() - sy, - p2.x() + cx, p2.y() + sy ); - } - } - break; - } - case QwtIntervalSymbol::Box: - { - if ( d_data->width <= pw ) - { - QwtPainter::drawLine( painter, p1, p2 ); - } - else - { - if ( ( orientation == Qt::Horizontal ) - && ( p1.y() == p2.y() ) ) - { - const double sw = d_data->width; - - const double y = p1.y() - d_data->width / 2; - QwtPainter::drawRect( painter, - p1.x(), y, p2.x() - p1.x(), sw ); - } - else if ( ( orientation == Qt::Vertical ) - && ( p1.x() == p2.x() ) ) - { - const double sw = d_data->width; - - const double x = p1.x() - d_data->width / 2; - QwtPainter::drawRect( painter, - x, p1.y(), sw, p2.y() - p1.y() ); - } - else - { - const double sw = d_data->width; - - const double dx = p2.x() - p1.x(); - const double dy = p2.y() - p1.y(); - const double angle = qAtan2( dy, dx ) + M_PI_2; - double dw2 = sw / 2.0; - - const int cx = qCos( angle ) * dw2; - const int sy = qSin( angle ) * dw2; - - QPolygonF polygon; - polygon += QPointF( p1.x() - cx, p1.y() - sy ); - polygon += QPointF( p1.x() + cx, p1.y() + sy ); - polygon += QPointF( p2.x() + cx, p2.y() + sy ); - polygon += QPointF( p2.x() - cx, p2.y() - sy ); - - QwtPainter::drawPolygon( painter, polygon ); - } - } - break; - } - default:; - } -} diff --git a/qwt/src/qwt_interval_symbol.h b/qwt/src/qwt_interval_symbol.h deleted file mode 100644 index 3ea4fe4fa..000000000 --- a/qwt/src/qwt_interval_symbol.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_INTERVAL_SYMBOL_H -#define QWT_INTERVAL_SYMBOL_H - -#include "qwt_global.h" -#include -#include - -class QPainter; -class QRect; -class QPointF; - -/*! - \brief A drawing primitive for displaying an interval like an error bar - - \sa QwtPlotIntervalCurve -*/ -class QWT_EXPORT QwtIntervalSymbol -{ -public: - //! Symbol style - enum Style - { - //! No Style. The symbol cannot be drawn. - NoSymbol = -1, - - /*! - The symbol displays a line with caps at the beginning/end. - The size of the caps depends on the symbol width(). - */ - Bar, - - /*! - The symbol displays a plain rectangle using pen() and brush(). - The size of the rectangle depends on the translated interval and - the width(), - */ - Box, - - /*! - Styles >= UserSymbol are reserved for derived - classes of QwtIntervalSymbol that overload draw() with - additional application specific symbol types. - */ - UserSymbol = 1000 - }; - -public: - QwtIntervalSymbol( Style = NoSymbol ); - QwtIntervalSymbol( const QwtIntervalSymbol & ); - virtual ~QwtIntervalSymbol(); - - QwtIntervalSymbol &operator=( const QwtIntervalSymbol & ); - bool operator==( const QwtIntervalSymbol & ) const; - bool operator!=( const QwtIntervalSymbol & ) const; - - void setWidth( int ); - int width() const; - - void setBrush( const QBrush& b ); - const QBrush& brush() const; - - void setPen( const QPen & ); - const QPen& pen() const; - - void setStyle( Style ); - Style style() const; - - virtual void draw( QPainter *, Qt::Orientation, - const QPointF& from, const QPointF& to ) const; - -private: - - class PrivateData; - PrivateData* d_data; -}; - -#endif diff --git a/qwt/src/qwt_knob.cpp b/qwt/src/qwt_knob.cpp deleted file mode 100644 index 0cc8e4230..000000000 --- a/qwt/src/qwt_knob.cpp +++ /dev/null @@ -1,666 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_knob.h" -#include "qwt_round_scale_draw.h" -#include "qwt_math.h" -#include "qwt_painter.h" -#include -#include -#include -#include -#include -#include -#include - -#if QT_VERSION < 0x040601 -#define qAtan2(y, x) ::atan2(y, x) -#define qFabs(x) ::fabs(x) -#define qFastCos(x) ::cos(x) -#define qFastSin(x) ::sin(x) -#endif - -class QwtKnob::PrivateData -{ -public: - PrivateData() - { - angle = 0.0; - nTurns = 0.0; - borderWidth = 2; - borderDist = 4; - totalAngle = 270.0; - scaleDist = 4; - markerStyle = QwtKnob::Notch; - maxScaleTicks = 11; - knobStyle = QwtKnob::Raised; - knobWidth = 50; - markerSize = 8; - } - - QwtKnob::KnobStyle knobStyle; - QwtKnob::MarkerStyle markerStyle; - - int borderWidth; - int borderDist; - int scaleDist; - int maxScaleTicks; - int knobWidth; - int markerSize; - - double angle; - double totalAngle; - double nTurns; - - mutable QRectF knobRect; // bounding rect of the knob without scale -}; - -/*! - Constructor - \param parent Parent widget -*/ -QwtKnob::QwtKnob( QWidget* parent ): - QwtAbstractSlider( Qt::Horizontal, parent ) -{ - initKnob(); -} - -void QwtKnob::initKnob() -{ - d_data = new PrivateData; - - setScaleDraw( new QwtRoundScaleDraw() ); - - setUpdateTime( 50 ); - setTotalAngle( 270.0 ); - recalcAngle(); - setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); - - setRange( 0.0, 10.0, 1.0 ); - setValue( 0.0 ); -} - -//! Destructor -QwtKnob::~QwtKnob() -{ - delete d_data; -} - -/*! - \brief Set the knob type - - \param knobStyle Knob type - \sa knobStyle(), setBorderWidth() -*/ -void QwtKnob::setKnobStyle( KnobStyle knobStyle ) -{ - if ( d_data->knobStyle != knobStyle ) - { - d_data->knobStyle = knobStyle; - update(); - } -} - -/*! - \return Marker type of the knob - \sa setKnobStyle(), setBorderWidth() -*/ -QwtKnob::KnobStyle QwtKnob::knobStyle() const -{ - return d_data->knobStyle; -} - -/*! - \brief Set the marker type of the knob - - \param markerStyle Marker type - \sa markerStyle(), setMarkerSize() -*/ -void QwtKnob::setMarkerStyle( MarkerStyle markerStyle ) -{ - if ( d_data->markerStyle != markerStyle ) - { - d_data->markerStyle = markerStyle; - update(); - } -} - -/*! - \return Marker type of the knob - \sa setMarkerStyle(), setMarkerSize() -*/ -QwtKnob::MarkerStyle QwtKnob::markerStyle() const -{ - return d_data->markerStyle; -} - -/*! - \brief Set the total angle by which the knob can be turned - \param angle Angle in degrees. - - The default angle is 270 degrees. It is possible to specify - an angle of more than 360 degrees so that the knob can be - turned several times around its axis. -*/ -void QwtKnob::setTotalAngle ( double angle ) -{ - if ( angle < 10.0 ) - d_data->totalAngle = 10.0; - else - d_data->totalAngle = angle; - - scaleDraw()->setAngleRange( -0.5 * d_data->totalAngle, - 0.5 * d_data->totalAngle ); - layoutKnob( true ); -} - -//! Return the total angle -double QwtKnob::totalAngle() const -{ - return d_data->totalAngle; -} - -/*! - Change the scale draw of the knob - - For changing the labels of the scales, it - is necessary to derive from QwtRoundScaleDraw and - overload QwtRoundScaleDraw::label(). - - \sa scaleDraw() -*/ -void QwtKnob::setScaleDraw( QwtRoundScaleDraw *scaleDraw ) -{ - setAbstractScaleDraw( scaleDraw ); - setTotalAngle( d_data->totalAngle ); -} - -/*! - \return the scale draw of the knob - \sa setScaleDraw() -*/ -const QwtRoundScaleDraw *QwtKnob::scaleDraw() const -{ - return static_cast( abstractScaleDraw() ); -} - -/*! - \return the scale draw of the knob - \sa setScaleDraw() -*/ -QwtRoundScaleDraw *QwtKnob::scaleDraw() -{ - return static_cast( abstractScaleDraw() ); -} - -/*! - \brief Notify change of value - - Sets the knob's value to the nearest multiple - of the step size. -*/ -void QwtKnob::valueChange() -{ - recalcAngle(); - update(); - QwtAbstractSlider::valueChange(); -} - -/*! - \brief Determine the value corresponding to a specified position - - Called by QwtAbstractSlider - \param pos point -*/ -double QwtKnob::getValue( const QPoint &pos ) -{ - const double dx = rect().center().x() - pos.x(); - const double dy = rect().center().y() - pos.y(); - - const double arc = qAtan2( -dx, dy ) * 180.0 / M_PI; - - double newValue = 0.5 * ( minValue() + maxValue() ) - + ( arc + d_data->nTurns * 360.0 ) * ( maxValue() - minValue() ) - / d_data->totalAngle; - - const double oneTurn = qFabs( maxValue() - minValue() ) * 360.0 / d_data->totalAngle; - const double eqValue = value() + mouseOffset(); - - if ( qFabs( newValue - eqValue ) > 0.5 * oneTurn ) - { - if ( newValue < eqValue ) - newValue += oneTurn; - else - newValue -= oneTurn; - } - - return newValue; -} - -/*! - \brief Set the scrolling mode and direction - - Called by QwtAbstractSlider - \param pos Point in question - \param scrollMode Scrolling mode - \param direction Direction -*/ -void QwtKnob::getScrollMode( const QPoint &pos, - QwtAbstractSlider::ScrollMode &scrollMode, int &direction ) const -{ - const int r = d_data->knobRect.width() / 2; - - const int dx = d_data->knobRect.x() + r - pos.x(); - const int dy = d_data->knobRect.y() + r - pos.y(); - - if ( ( dx * dx ) + ( dy * dy ) <= ( r * r ) ) // point is inside the knob - { - scrollMode = QwtAbstractSlider::ScrMouse; - direction = 0; - } - else // point lies outside - { - scrollMode = QwtAbstractSlider::ScrTimer; - double arc = qAtan2( double( -dx ), double( dy ) ) * 180.0 / M_PI; - if ( arc < d_data->angle ) - direction = -1; - else if ( arc > d_data->angle ) - direction = 1; - else - direction = 0; - } -} - -/*! - \brief Notify a change of the range - - Called by QwtAbstractSlider -*/ -void QwtKnob::rangeChange() -{ - if ( autoScale() ) - rescale( minValue(), maxValue() ); - - layoutKnob( true ); - recalcAngle(); -} - -/*! - Qt Resize Event - \param event Resize event -*/ -void QwtKnob::resizeEvent( QResizeEvent *event ) -{ - Q_UNUSED( event ); - layoutKnob( false ); -} - -/*! - Handle QEvent::StyleChange and QEvent::FontChange; - \param event Change event -*/ -void QwtKnob::changeEvent( QEvent *event ) -{ - switch( event->type() ) - { - case QEvent::StyleChange: - case QEvent::FontChange: - layoutKnob( true ); - break; - default: - break; - } -} - -/*! - Recalculate the knob's geometry and layout based on - the current rect and fonts. - - \param update_geometry notify the layout system and call update - to redraw the scale -*/ -void QwtKnob::layoutKnob( bool update_geometry ) -{ - const double d = d_data->knobWidth; - - d_data->knobRect.setWidth( d ); - d_data->knobRect.setHeight( d ); - d_data->knobRect.moveCenter( rect().center() ); - - scaleDraw()->setRadius( 0.5 * d + d_data->scaleDist ); - scaleDraw()->moveCenter( rect().center() ); - - if ( update_geometry ) - { - updateGeometry(); - update(); - } -} - -/*! - Repaint the knob - \param event Paint event -*/ -void QwtKnob::paintEvent( QPaintEvent *event ) -{ - QPainter painter( this ); - painter.setClipRegion( event->region() ); - - QStyleOption opt; - opt.init(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); - - painter.setRenderHint( QPainter::Antialiasing, true ); - - if ( !d_data->knobRect.contains( event->region().boundingRect() ) ) - scaleDraw()->draw( &painter, palette() ); - - drawKnob( &painter, d_data->knobRect ); - drawMarker( &painter, d_data->knobRect, d_data->angle ); - - painter.setRenderHint( QPainter::Antialiasing, false ); - - if ( hasFocus() ) - QwtPainter::drawFocusRect( &painter, this ); -} - -/*! - \brief Draw the knob - \param painter painter - \param knobRect Bounding rectangle of the knob (without scale) -*/ -void QwtKnob::drawKnob( QPainter *painter, - const QRectF &knobRect ) const -{ - double dim = qMin( knobRect.width(), knobRect.height() ); - dim -= d_data->borderWidth * 0.5; - - QRectF aRect( 0, 0, dim, dim ); - aRect.moveCenter( knobRect.center() ); - - QPen pen( Qt::NoPen ); - if ( d_data->borderWidth > 0 ) - { - QColor c1 = palette().color( QPalette::Light ); - QColor c2 = palette().color( QPalette::Dark ); - - QLinearGradient gradient( aRect.topLeft(), aRect.bottomRight() ); - gradient.setColorAt( 0.0, c1 ); - gradient.setColorAt( 0.3, c1 ); - gradient.setColorAt( 0.7, c2 ); - gradient.setColorAt( 1.0, c2 ); - - pen = QPen( gradient, d_data->borderWidth ); - } - - QBrush brush; - switch( d_data->knobStyle ) - { - case QwtKnob::Raised: - { - double off = 0.3 * knobRect.width(); - QRadialGradient gradient( knobRect.center(), - knobRect.width(), knobRect.topLeft() + QPoint( off, off ) ); - - gradient.setColorAt( 0.0, palette().color( QPalette::Midlight ) ); - gradient.setColorAt( 1.0, palette().color( QPalette::Button ) ); - - brush = QBrush( gradient ); - - break; - } - case QwtKnob::Sunken: - { - QLinearGradient gradient( - knobRect.topLeft(), knobRect.bottomRight() ); - gradient.setColorAt( 0.0, palette().color( QPalette::Mid ) ); - gradient.setColorAt( 0.5, palette().color( QPalette::Button ) ); - gradient.setColorAt( 1.0, palette().color( QPalette::Midlight ) ); - brush = QBrush( gradient ); - - break; - } - default: - brush = palette().brush( QPalette::Button ); - } - - painter->setPen( pen ); - painter->setBrush( brush ); - painter->drawEllipse( aRect ); -} - - -/*! - \brief Draw the marker at the knob's front - \param painter Painter - \param rect Bounding rectangle of the knob without scale - \param angle Angle of the marker in degrees -*/ -void QwtKnob::drawMarker( QPainter *painter, - const QRectF &rect, double angle ) const -{ - if ( d_data->markerStyle == NoMarker || !isValid() ) - return; - - const double radians = angle * M_PI / 180.0; - const double sinA = -qFastSin( radians ); - const double cosA = qFastCos( radians ); - - const double xm = rect.center().x(); - const double ym = rect.center().y(); - const double margin = 4.0; - - double radius = 0.5 * ( rect.width() - d_data->borderWidth ) - margin; - if ( radius < 1.0 ) - radius = 1.0; - - switch ( d_data->markerStyle ) - { - case Notch: - case Nub: - { - const double dotWidth = - qMin( double( d_data->markerSize ), radius); - - const double dotCenterDist = radius - 0.5 * dotWidth; - if ( dotCenterDist > 0.0 ) - { - const QPointF center( xm - sinA * dotCenterDist, - ym - cosA * dotCenterDist ); - - QRectF ellipse( 0.0, 0.0, dotWidth, dotWidth ); - ellipse.moveCenter( center ); - - QColor c1 = palette().color( QPalette::Light ); - QColor c2 = palette().color( QPalette::Mid ); - - if ( d_data->markerStyle == Notch ) - qSwap( c1, c2 ); - - QLinearGradient gradient( - ellipse.topLeft(), ellipse.bottomRight() ); - gradient.setColorAt( 0.0, c1 ); - gradient.setColorAt( 1.0, c2 ); - - painter->setPen( Qt::NoPen ); - painter->setBrush( gradient ); - - painter->drawEllipse( ellipse ); - } - break; - } - case Dot: - { - const double dotWidth = - qMin( double( d_data->markerSize ), radius); - - const double dotCenterDist = radius - 0.5 * dotWidth; - if ( dotCenterDist > 0.0 ) - { - const QPointF center( xm - sinA * dotCenterDist, - ym - cosA * dotCenterDist ); - - QRectF ellipse( 0.0, 0.0, dotWidth, dotWidth ); - ellipse.moveCenter( center ); - - painter->setPen( Qt::NoPen ); - painter->setBrush( palette().color( QPalette::ButtonText ) ); - painter->drawEllipse( ellipse ); - } - - break; - } - case Tick: - { - const double rb = qMax( radius - d_data->markerSize, 1.0 ); - const double re = radius; - - const QLine line( xm - sinA * rb, ym - cosA * rb, - xm - sinA * re, ym - cosA * re ); - - QPen pen( palette().color( QPalette::ButtonText ), 0 ); - pen.setCapStyle( Qt::FlatCap ); - painter->setPen( pen ); - painter->drawLine ( line ); - - break; - } -#if 0 - case Triangle: - { - const double rb = qMax( radius - d_data->markerSize, 1.0 ); - const double re = radius; - - painter->translate( rect.center() ); - painter->rotate( angle - 90.0 ); - - QPolygonF polygon; - polygon += QPointF( re, 0.0 ); - polygon += QPointF( rb, 0.5 * ( re - rb ) ); - polygon += QPointF( rb, -0.5 * ( re - rb ) ); - - painter->setPen( Qt::NoPen ); - painter->setBrush( palette().color( QPalette::Text ) ); - painter->drawPolygon( polygon ); - break; - } -#endif - default: - break; - } -} - -/*! - \brief Change the knob's width. - - The specified width must be >= 5, or it will be clipped. - \param width New width -*/ -void QwtKnob::setKnobWidth( int width ) -{ - d_data->knobWidth = qMax( width, 5 ); - layoutKnob( true ); -} - -//! Return the width of the knob -int QwtKnob::knobWidth() const -{ - return d_data->knobWidth; -} - -/*! - \brief Set the knob's border width - \param borderWidth new border width -*/ -void QwtKnob::setBorderWidth( int borderWidth ) -{ - d_data->borderWidth = qMax( borderWidth, 0 ); - layoutKnob( true ); -} - -//! Return the border width -int QwtKnob::borderWidth() const -{ - return d_data->borderWidth; -} - -/*! - \brief Set the size of the marker - \sa markerSize(), markerStyle() -*/ -void QwtKnob::setMarkerSize( int size ) -{ - if ( d_data->markerSize != size ) - { - d_data->markerSize = size; - update(); - } -} - -//! Return the marker size -int QwtKnob::markerSize() const -{ - return d_data->markerSize; -} - -/*! - \brief Recalculate the marker angle corresponding to the - current value -*/ -void QwtKnob::recalcAngle() -{ - // - // calculate the angle corresponding to the value - // - if ( maxValue() == minValue() ) - { - d_data->angle = 0; - d_data->nTurns = 0; - } - else - { - d_data->angle = ( value() - 0.5 * ( minValue() + maxValue() ) ) - / ( maxValue() - minValue() ) * d_data->totalAngle; - d_data->nTurns = qFloor( ( d_data->angle + 180.0 ) / 360.0 ); - d_data->angle = d_data->angle - d_data->nTurns * 360.0; - } -} - - -/*! - Recalculates the layout - \sa layoutKnob() -*/ -void QwtKnob::scaleChange() -{ - layoutKnob( true ); -} - -/*! - \return minimumSizeHint() -*/ -QSize QwtKnob::sizeHint() const -{ - const QSize hint = minimumSizeHint(); - return hint.expandedTo( QApplication::globalStrut() ); -} - -/*! - \brief Return a minimum size hint - \warning The return value of QwtKnob::minimumSizeHint() depends on the - font and the scale. -*/ -QSize QwtKnob::minimumSizeHint() const -{ - // Add the scale radial thickness to the knobWidth - const int sh = qCeil( scaleDraw()->extent( font() ) ); - const int d = 2 * sh + 2 * d_data->scaleDist + d_data->knobWidth; - - return QSize( d, d ); -} diff --git a/qwt/src/qwt_knob.h b/qwt/src/qwt_knob.h deleted file mode 100644 index 735fff0e6..000000000 --- a/qwt/src/qwt_knob.h +++ /dev/null @@ -1,159 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_KNOB_H -#define QWT_KNOB_H - -#include "qwt_global.h" -#include "qwt_abstract_slider.h" -#include "qwt_abstract_scale.h" - -class QwtRoundScaleDraw; - -/*! - \brief The Knob Widget - - The QwtKnob widget imitates look and behaviour of a volume knob on a radio. - It contains a scale around the knob which is set up automatically or can - be configured manually (see QwtAbstractScale). - Automatic scrolling is enabled when the user presses a mouse - button on the scale. For a description of signals, slots and other - members, see QwtAbstractSlider. - - \image html knob.png - \sa QwtAbstractSlider and QwtAbstractScale for the descriptions - of the inherited members. -*/ - -class QWT_EXPORT QwtKnob : public QwtAbstractSlider, public QwtAbstractScale -{ - Q_OBJECT - - Q_ENUMS ( KnobStyle ) - Q_ENUMS ( MarkerStyle ) - - Q_PROPERTY( KnobStyle knobStyle READ knobStyle WRITE setKnobStyle ) - Q_PROPERTY( MarkerStyle markerStyle READ markerStyle WRITE setMarkerStyle ) - Q_PROPERTY( int knobWidth READ knobWidth WRITE setKnobWidth ) - Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth ) - Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle ) - Q_PROPERTY( int markerSize READ markerSize WRITE setMarkerSize ) - Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth ) - -public: - /*! - \brief Style of the knob surface - - Depending on the KnobStyle the surface of the knob is - filled from the brushes of the widget palette(). - - \sa setKnobStyle(), knobStyle() - */ - enum KnobStyle - { - //! Fill the knob with a brush from QPalette::Button. - NoStyle = -1, - - //! Build a gradient from QPalette::Midlight and QPalette::Button - Raised, - - /*! - Build a gradient from QPalette::Midlight, QPalette::Button - and QPalette::Midlight - */ - Sunken - }; - - /*! - \brief Marker type - - The marker indicates the current value on the knob - The default setting is a Notch marker. - - \sa setMarkerStyle(), setMarkerSize() - */ - enum MarkerStyle - { - //! Don't paint any marker - NoMarker = -1, - - //! Paint a single tick in QPalette::ButtonText color - Tick, - - //! Paint a circle in QPalette::ButtonText color - Dot, - - /*! - Draw a raised ellipse with a gradient build from - QPalette::Light and QPalette::Mid - */ - Nub, - - /*! - Draw a sunken ellipse with a gradient build from - QPalette::Light and QPalette::Mid - */ - Notch - }; - - explicit QwtKnob( QWidget* parent = NULL ); - virtual ~QwtKnob(); - - void setKnobWidth( int w ); - int knobWidth() const; - - void setTotalAngle ( double angle ); - double totalAngle() const; - - void setKnobStyle( KnobStyle ); - KnobStyle knobStyle() const; - - void setBorderWidth( int bw ); - int borderWidth() const; - - void setMarkerStyle( MarkerStyle ); - MarkerStyle markerStyle() const; - - void setMarkerSize( int ); - int markerSize() const; - - virtual QSize sizeHint() const; - virtual QSize minimumSizeHint() const; - - void setScaleDraw( QwtRoundScaleDraw * ); - const QwtRoundScaleDraw *scaleDraw() const; - QwtRoundScaleDraw *scaleDraw(); - -protected: - virtual void paintEvent( QPaintEvent * ); - virtual void resizeEvent( QResizeEvent * ); - virtual void changeEvent( QEvent * ); - - virtual void drawKnob( QPainter *, const QRectF & ) const; - virtual void drawMarker( QPainter *, - const QRectF &, double arc ) const; - - virtual double getValue( const QPoint &p ); - virtual void getScrollMode( const QPoint &, - QwtAbstractSlider::ScrollMode &, int &direction ) const; - -private: - void initKnob(); - void layoutKnob( bool update ); - void recalcAngle(); - - virtual void valueChange(); - virtual void rangeChange(); - virtual void scaleChange(); - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_legend.cpp b/qwt/src/qwt_legend.cpp deleted file mode 100644 index 473ff34fc..000000000 --- a/qwt/src/qwt_legend.cpp +++ /dev/null @@ -1,519 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_legend.h" -#include "qwt_legend_itemmanager.h" -#include "qwt_legend_item.h" -#include "qwt_dyngrid_layout.h" -#include "qwt_math.h" -#include -#include -#include -#include - -class QwtLegend::PrivateData -{ -public: - class LegendMap - { - public: - void insert( const QwtLegendItemManager *, QWidget * ); - - void remove( const QwtLegendItemManager * ); - void remove( QWidget * ); - - void clear(); - - uint count() const; - - inline const QWidget *find( const QwtLegendItemManager * ) const; - inline QWidget *find( const QwtLegendItemManager * ); - - inline const QwtLegendItemManager *find( const QWidget * ) const; - inline QwtLegendItemManager *find( const QWidget * ); - - const QMap &widgetMap() const; - QMap &widgetMap(); - - private: - QMap d_widgetMap; - QMap d_itemMap; - }; - - QwtLegend::LegendItemMode itemMode; - - LegendMap map; - - class LegendView; - LegendView *view; -}; - -class QwtLegend::PrivateData::LegendView: public QScrollArea -{ -public: - LegendView( QWidget *parent ): - QScrollArea( parent ) - { - setFocusPolicy( Qt::NoFocus ); - - contentsWidget = new QWidget( this ); - contentsWidget->setObjectName( "QwtLegendViewContents" ); - - setWidget( contentsWidget ); - setWidgetResizable( false ); - - viewport()->setObjectName( "QwtLegendViewport" ); - - // QScrollArea::setWidget internally sets autoFillBackground to true - // But we don't want a background. - contentsWidget->setAutoFillBackground( false ); - viewport()->setAutoFillBackground( false ); - } - - virtual bool viewportEvent( QEvent *e ) - { - bool ok = QScrollArea::viewportEvent( e ); - - if ( e->type() == QEvent::Resize ) - { - QEvent event( QEvent::LayoutRequest ); - QApplication::sendEvent( contentsWidget, &event ); - } - return ok; - } - - QSize viewportSize( int w, int h ) const - { - const int sbHeight = horizontalScrollBar()->sizeHint().height(); - const int sbWidth = verticalScrollBar()->sizeHint().width(); - - const int cw = contentsRect().width(); - const int ch = contentsRect().height(); - - int vw = cw; - int vh = ch; - - if ( w > vw ) - vh -= sbHeight; - - if ( h > vh ) - { - vw -= sbWidth; - if ( w > vw && vh == ch ) - vh -= sbHeight; - } - return QSize( vw, vh ); - } - - QWidget *contentsWidget; -}; - -void QwtLegend::PrivateData::LegendMap::insert( - const QwtLegendItemManager *item, QWidget *widget ) -{ - d_itemMap.insert( item, widget ); - d_widgetMap.insert( widget, item ); -} - -void QwtLegend::PrivateData::LegendMap::remove( const QwtLegendItemManager *item ) -{ - QWidget *widget = d_itemMap[item]; - d_itemMap.remove( item ); - d_widgetMap.remove( widget ); -} - -void QwtLegend::PrivateData::LegendMap::remove( QWidget *widget ) -{ - const QwtLegendItemManager *item = d_widgetMap[widget]; - d_itemMap.remove( item ); - d_widgetMap.remove( widget ); -} - -void QwtLegend::PrivateData::LegendMap::clear() -{ - - /* - We can't delete the widgets in the following loop, because - we would get ChildRemoved events, changing d_itemMap, while - we are iterating. - */ - - QList widgets; - - QMap::const_iterator it; - for ( it = d_itemMap.begin(); it != d_itemMap.end(); ++it ) - widgets.append( it.value() ); - - d_itemMap.clear(); - d_widgetMap.clear(); - - for ( int i = 0; i < widgets.size(); i++ ) - delete widgets[i]; -} - -uint QwtLegend::PrivateData::LegendMap::count() const -{ - return d_itemMap.count(); -} - -inline const QWidget *QwtLegend::PrivateData::LegendMap::find( - const QwtLegendItemManager *item ) const -{ - if ( !d_itemMap.contains( item ) ) - return NULL; - - return d_itemMap[item]; -} - -inline QWidget *QwtLegend::PrivateData::LegendMap::find( - const QwtLegendItemManager *item ) -{ - if ( !d_itemMap.contains( item ) ) - return NULL; - - return d_itemMap[item]; -} - -inline const QwtLegendItemManager *QwtLegend::PrivateData::LegendMap::find( - const QWidget *widget ) const -{ - QWidget *w = const_cast( widget ); - if ( !d_widgetMap.contains( w ) ) - return NULL; - - return d_widgetMap[w]; -} - -inline QwtLegendItemManager *QwtLegend::PrivateData::LegendMap::find( - const QWidget *widget ) -{ - QWidget *w = const_cast( widget ); - if ( !d_widgetMap.contains( w ) ) - return NULL; - - return const_cast( d_widgetMap[w] ); -} - -inline const QMap & -QwtLegend::PrivateData::LegendMap::widgetMap() const -{ - return d_widgetMap; -} - -inline QMap & -QwtLegend::PrivateData::LegendMap::widgetMap() -{ - return d_widgetMap; -} - -/*! - Constructor - - \param parent Parent widget -*/ -QwtLegend::QwtLegend( QWidget *parent ): - QFrame( parent ) -{ - setFrameStyle( NoFrame ); - - d_data = new QwtLegend::PrivateData; - d_data->itemMode = QwtLegend::ReadOnlyItem; - - d_data->view = new QwtLegend::PrivateData::LegendView( this ); - d_data->view->setObjectName( "QwtLegendView" ); - d_data->view->setFrameStyle( NoFrame ); - - QwtDynGridLayout *gridLayout = new QwtDynGridLayout( - d_data->view->contentsWidget ); - gridLayout->setAlignment( Qt::AlignHCenter | Qt::AlignTop ); - - d_data->view->contentsWidget->installEventFilter( this ); - - QVBoxLayout *layout = new QVBoxLayout( this ); - layout->setContentsMargins( 0, 0, 0, 0 ); - layout->addWidget( d_data->view ); -} - -//! Destructor -QwtLegend::~QwtLegend() -{ - delete d_data; -} - -//! \sa LegendItemMode -void QwtLegend::setItemMode( LegendItemMode mode ) -{ - d_data->itemMode = mode; -} - -//! \sa LegendItemMode -QwtLegend::LegendItemMode QwtLegend::itemMode() const -{ - return d_data->itemMode; -} - -/*! - The contents widget is the only child of the viewport of - the internal QScrollArea and the parent widget of all legend items. - - \return Container widget of the legend items -*/ -QWidget *QwtLegend::contentsWidget() -{ - return d_data->view->contentsWidget; -} - -/*! - \return Horizontal scrollbar - \sa verticalScrollBar() -*/ -QScrollBar *QwtLegend::horizontalScrollBar() const -{ - return d_data->view->horizontalScrollBar(); -} - -/*! - \return Vertical scrollbar - \sa horizontalScrollBar() -*/ -QScrollBar *QwtLegend::verticalScrollBar() const -{ - return d_data->view->verticalScrollBar(); -} - -/*! - The contents widget is the only child of the viewport of - the internal QScrollArea and the parent widget of all legend items. - - \return Container widget of the legend items - -*/ -const QWidget *QwtLegend::contentsWidget() const -{ - return d_data->view->contentsWidget; -} - -/*! - Insert a new item for a plot item - \param plotItem Plot item - \param legendItem New legend item - \note The parent of item will be changed to contentsWidget() -*/ -void QwtLegend::insert( const QwtLegendItemManager *plotItem, QWidget *legendItem ) -{ - if ( legendItem == NULL || plotItem == NULL ) - return; - - QWidget *contentsWidget = d_data->view->contentsWidget; - - if ( legendItem->parent() != contentsWidget ) - legendItem->setParent( contentsWidget ); - - legendItem->show(); - - d_data->map.insert( plotItem, legendItem ); - - layoutContents(); - - if ( contentsWidget->layout() ) - { - contentsWidget->layout()->addWidget( legendItem ); - - // set tab focus chain - - QWidget *w = NULL; - - for ( int i = 0; i < contentsWidget->layout()->count(); i++ ) - { - QLayoutItem *item = contentsWidget->layout()->itemAt( i ); - if ( w && item->widget() ) - QWidget::setTabOrder( w, item->widget() ); - - w = item->widget(); - } - } - if ( parentWidget() && parentWidget()->layout() == NULL ) - { - /* - updateGeometry() doesn't post LayoutRequest in certain - situations, like when we are hidden. But we want the - parent widget notified, so it can show/hide the legend - depending on its items. - */ - QApplication::postEvent( parentWidget(), - new QEvent( QEvent::LayoutRequest ) ); - } -} - -/*! - Find the widget that represents a plot item - - \param plotItem Plot item - \return Widget on the legend, or NULL -*/ -QWidget *QwtLegend::find( const QwtLegendItemManager *plotItem ) const -{ - return d_data->map.find( plotItem ); -} - -/*! - Find the widget that represents a plot item - - \param legendItem Legend item - \return Widget on the legend, or NULL -*/ -QwtLegendItemManager *QwtLegend::find( const QWidget *legendItem ) const -{ - return d_data->map.find( legendItem ); -} - -/*! - Find the corresponding item for a plotItem and remove it - from the item list. - - \param plotItem Plot item -*/ -void QwtLegend::remove( const QwtLegendItemManager *plotItem ) -{ - QWidget *legendItem = d_data->map.find( plotItem ); - d_data->map.remove( legendItem ); - delete legendItem; -} - -//! Remove all items. -void QwtLegend::clear() -{ - bool doUpdate = updatesEnabled(); - if ( doUpdate ) - setUpdatesEnabled( false ); - - d_data->map.clear(); - - if ( doUpdate ) - setUpdatesEnabled( true ); - - update(); -} - -//! Return a size hint. -QSize QwtLegend::sizeHint() const -{ - QSize hint = d_data->view->contentsWidget->sizeHint(); - hint += QSize( 2 * frameWidth(), 2 * frameWidth() ); - - return hint; -} - -/*! - \return The preferred height, for the width w. - \param width Width -*/ -int QwtLegend::heightForWidth( int width ) const -{ - width -= 2 * frameWidth(); - - int h = d_data->view->contentsWidget->heightForWidth( width ); - if ( h >= 0 ) - h += 2 * frameWidth(); - - return h; -} - -/*! - Adjust contents widget and item layout to the size of the viewport(). -*/ -void QwtLegend::layoutContents() -{ - const QSize visibleSize = - d_data->view->viewport()->contentsRect().size(); - - const QwtDynGridLayout *tl = qobject_cast( - d_data->view->contentsWidget->layout() ); - if ( tl ) - { - const int minW = int( tl->maxItemWidth() ) + 2 * tl->margin(); - - int w = qMax( visibleSize.width(), minW ); - int h = qMax( tl->heightForWidth( w ), visibleSize.height() ); - - const int vpWidth = d_data->view->viewportSize( w, h ).width(); - if ( w > vpWidth ) - { - w = qMax( vpWidth, minW ); - h = qMax( tl->heightForWidth( w ), visibleSize.height() ); - } - - d_data->view->contentsWidget->resize( w, h ); - } -} - -/*! - Handle QEvent::ChildRemoved andQEvent::LayoutRequest events - for the contentsWidget(). - - \param object Object to be filtered - \param event Event -*/ -bool QwtLegend::eventFilter( QObject *object, QEvent *event ) -{ - if ( object == d_data->view->contentsWidget ) - { - switch ( event->type() ) - { - case QEvent::ChildRemoved: - { - const QChildEvent *ce = - static_cast(event); - if ( ce->child()->isWidgetType() ) - { - QWidget *w = static_cast< QWidget * >( ce->child() ); - d_data->map.remove( w ); - } - break; - } - case QEvent::LayoutRequest: - { - layoutContents(); - break; - } - default: - break; - } - } - - return QFrame::eventFilter( object, event ); -} - - -//! Return true, if there are no legend items. -bool QwtLegend::isEmpty() const -{ - return d_data->map.count() == 0; -} - -//! Return the number of legend items. -uint QwtLegend::itemCount() const -{ - return d_data->map.count(); -} - -//! Return a list of all legend items -QList QwtLegend::legendItems() const -{ - const QMap &map = - d_data->map.widgetMap(); - - QList list; - - QMap::const_iterator it; - for ( it = map.begin(); it != map.end(); ++it ) - list += it.key(); - - return list; -} \ No newline at end of file diff --git a/qwt/src/qwt_legend.h b/qwt/src/qwt_legend.h deleted file mode 100644 index 56ffae217..000000000 --- a/qwt/src/qwt_legend.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_LEGEND_H -#define QWT_LEGEND_H - -#include "qwt_global.h" -#include -#include - -class QScrollBar; -class QwtLegendItemManager; - -/*! - \brief The legend widget - - The QwtLegend widget is a tabular arrangement of legend items. Legend - items might be any type of widget, but in general they will be - a QwtLegendItem. - - \sa QwtLegendItem, QwtLegendItemManager QwtPlot -*/ - -class QWT_EXPORT QwtLegend : public QFrame -{ - Q_OBJECT - -public: - /*! - \brief Interaction mode for the legend items - - The default is QwtLegend::ReadOnlyItem. - - \sa setItemMode(), itemMode(), QwtLegendItem::IdentifierMode - QwtLegendItem::clicked(), QwtLegendItem::checked(), - QwtPlot::legendClicked(), QwtPlot::legendChecked() - */ - - enum LegendItemMode - { - //! The legend item is not interactive, like a label - ReadOnlyItem, - - //! The legend item is clickable, like a push button - ClickableItem, - - //! The legend item is checkable, like a checkable button - CheckableItem - }; - - explicit QwtLegend( QWidget *parent = NULL ); - virtual ~QwtLegend(); - - void setItemMode( LegendItemMode ); - LegendItemMode itemMode() const; - - QWidget *contentsWidget(); - const QWidget *contentsWidget() const; - - void insert( const QwtLegendItemManager *, QWidget * ); - void remove( const QwtLegendItemManager * ); - - QWidget *find( const QwtLegendItemManager * ) const; - QwtLegendItemManager *find( const QWidget * ) const; - - virtual QList legendItems() const; - - void clear(); - - bool isEmpty() const; - uint itemCount() const; - - virtual bool eventFilter( QObject *, QEvent * ); - - virtual QSize sizeHint() const; - virtual int heightForWidth( int w ) const; - - QScrollBar *horizontalScrollBar() const; - QScrollBar *verticalScrollBar() const; - -protected: - virtual void layoutContents(); - -private: - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_legend_item.cpp b/qwt/src/qwt_legend_item.cpp deleted file mode 100644 index 81a30ac36..000000000 --- a/qwt/src/qwt_legend_item.cpp +++ /dev/null @@ -1,405 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_legend_item.h" -#include "qwt_math.h" -#include "qwt_painter.h" -#include "qwt_symbol.h" -#include -#include -#include -#include -#include -#include -#include - -static const int ButtonFrame = 2; -static const int Margin = 2; - -static QSize buttonShift( const QwtLegendItem *w ) -{ - QStyleOption option; - option.init( w ); - - const int ph = w->style()->pixelMetric( - QStyle::PM_ButtonShiftHorizontal, &option, w ); - const int pv = w->style()->pixelMetric( - QStyle::PM_ButtonShiftVertical, &option, w ); - return QSize( ph, pv ); -} - -class QwtLegendItem::PrivateData -{ -public: - PrivateData(): - itemMode( QwtLegend::ReadOnlyItem ), - isDown( false ), - identifierSize( 8, 8 ), - spacing( Margin ) - { - } - - QwtLegend::LegendItemMode itemMode; - bool isDown; - - QSize identifierSize; - QPixmap identifier; - - int spacing; -}; - -/*! - \param parent Parent widget -*/ -QwtLegendItem::QwtLegendItem( QWidget *parent ): - QwtTextLabel( parent ) -{ - d_data = new PrivateData; - setMargin( Margin ); - setIndent( Margin + d_data->identifierSize.width() + 2 * d_data->spacing ); -} - -//! Destructor -QwtLegendItem::~QwtLegendItem() -{ - delete d_data; - d_data = NULL; -} - -/*! - Set the text to the legend item - - \param text Text label - \sa QwtTextLabel::text() -*/ -void QwtLegendItem::setText( const QwtText &text ) -{ - const int flags = Qt::AlignLeft | Qt::AlignVCenter - | Qt::TextExpandTabs | Qt::TextWordWrap; - - QwtText txt = text; - txt.setRenderFlags( flags ); - - QwtTextLabel::setText( txt ); -} - -/*! - Set the item mode - The default is QwtLegend::ReadOnlyItem - - \param mode Item mode - \sa itemMode() -*/ -void QwtLegendItem::setItemMode( QwtLegend::LegendItemMode mode ) -{ - if ( mode != d_data->itemMode ) - { - d_data->itemMode = mode; - d_data->isDown = false; - - setFocusPolicy( mode != QwtLegend::ReadOnlyItem ? Qt::TabFocus : Qt::NoFocus ); - setMargin( ButtonFrame + Margin ); - - updateGeometry(); - } -} - -/*! - Return the item mode - - \sa setItemMode() -*/ -QwtLegend::LegendItemMode QwtLegendItem::itemMode() const -{ - return d_data->itemMode; -} - -/*! - Assign the identifier - The identifier needs to be created according to the identifierWidth() - - \param identifier Pixmap representing a plot item - - \sa identifier(), identifierWidth() -*/ -void QwtLegendItem::setIdentifier( const QPixmap &identifier ) -{ - d_data->identifier = identifier; - update(); -} - -/*! - \return pixmap representing a plot item - \sa setIdentifier() -*/ -QPixmap QwtLegendItem::identifier() const -{ - return d_data->identifier; -} - -/*! - Set the size for the identifier - Default is 8x8 pixels - - \param size New size - - \sa identifierSize() -*/ -void QwtLegendItem::setIdentifierSize( const QSize &size ) -{ - QSize sz = size.expandedTo( QSize( 0, 0 ) ); - if ( sz != d_data->identifierSize ) - { - d_data->identifierSize = sz; - setIndent( margin() + d_data->identifierSize.width() - + 2 * d_data->spacing ); - updateGeometry(); - } -} -/*! - Return the width of the identifier - - \sa setIdentifierSize() -*/ -QSize QwtLegendItem::identifierSize() const -{ - return d_data->identifierSize; -} - -/*! - Change the spacing - \param spacing Spacing - \sa spacing(), identifierWidth(), QwtTextLabel::margin() -*/ -void QwtLegendItem::setSpacing( int spacing ) -{ - spacing = qMax( spacing, 0 ); - if ( spacing != d_data->spacing ) - { - d_data->spacing = spacing; - setIndent( margin() + d_data->identifierSize.width() - + 2 * d_data->spacing ); - } -} - -/*! - Return the spacing - \sa setSpacing(), identifierWidth(), QwtTextLabel::margin() -*/ -int QwtLegendItem::spacing() const -{ - return d_data->spacing; -} - -/*! - Check/Uncheck a the item - - \param on check/uncheck - \sa setItemMode() -*/ -void QwtLegendItem::setChecked( bool on ) -{ - if ( d_data->itemMode == QwtLegend::CheckableItem ) - { - const bool isBlocked = signalsBlocked(); - blockSignals( true ); - - setDown( on ); - - blockSignals( isBlocked ); - } -} - -//! Return true, if the item is checked -bool QwtLegendItem::isChecked() const -{ - return d_data->itemMode == QwtLegend::CheckableItem && isDown(); -} - -//! Set the item being down -void QwtLegendItem::setDown( bool down ) -{ - if ( down == d_data->isDown ) - return; - - d_data->isDown = down; - update(); - - if ( d_data->itemMode == QwtLegend::ClickableItem ) - { - if ( d_data->isDown ) - Q_EMIT pressed(); - else - { - Q_EMIT released(); - Q_EMIT clicked(); - } - } - - if ( d_data->itemMode == QwtLegend::CheckableItem ) - Q_EMIT checked( d_data->isDown ); -} - -//! Return true, if the item is down -bool QwtLegendItem::isDown() const -{ - return d_data->isDown; -} - -//! Return a size hint -QSize QwtLegendItem::sizeHint() const -{ - QSize sz = QwtTextLabel::sizeHint(); - sz.setHeight( qMax( sz.height(), d_data->identifier.height() + 4 ) ); - - if ( d_data->itemMode != QwtLegend::ReadOnlyItem ) - { - sz += buttonShift( this ); - sz = sz.expandedTo( QApplication::globalStrut() ); - } - - return sz; -} - -//! Paint event -void QwtLegendItem::paintEvent( QPaintEvent *e ) -{ - const QRect cr = contentsRect(); - - QPainter painter( this ); - painter.setClipRegion( e->region() ); - - if ( d_data->isDown ) - { - qDrawWinButton( &painter, 0, 0, width(), height(), - palette(), true ); - } - - painter.save(); - - if ( d_data->isDown ) - { - const QSize shiftSize = buttonShift( this ); - painter.translate( shiftSize.width(), shiftSize.height() ); - } - - painter.setClipRect( cr ); - - drawContents( &painter ); - - if ( !d_data->identifier.isNull() ) - { - QRect identRect = cr; - identRect.setX( identRect.x() + margin() ); - if ( d_data->itemMode != QwtLegend::ReadOnlyItem ) - identRect.setX( identRect.x() + ButtonFrame ); - - identRect.setSize( d_data->identifier.size() ); - identRect.moveCenter( QPoint( identRect.center().x(), cr.center().y() ) ); - - painter.drawPixmap( identRect, d_data->identifier ); - } - - painter.restore(); -} - -//! Handle mouse press events -void QwtLegendItem::mousePressEvent( QMouseEvent *e ) -{ - if ( e->button() == Qt::LeftButton ) - { - switch ( d_data->itemMode ) - { - case QwtLegend::ClickableItem: - { - setDown( true ); - return; - } - case QwtLegend::CheckableItem: - { - setDown( !isDown() ); - return; - } - default:; - } - } - QwtTextLabel::mousePressEvent( e ); -} - -//! Handle mouse release events -void QwtLegendItem::mouseReleaseEvent( QMouseEvent *e ) -{ - if ( e->button() == Qt::LeftButton ) - { - switch ( d_data->itemMode ) - { - case QwtLegend::ClickableItem: - { - setDown( false ); - return; - } - case QwtLegend::CheckableItem: - { - return; // do nothing, but accept - } - default:; - } - } - QwtTextLabel::mouseReleaseEvent( e ); -} - -//! Handle key press events -void QwtLegendItem::keyPressEvent( QKeyEvent *e ) -{ - if ( e->key() == Qt::Key_Space ) - { - switch ( d_data->itemMode ) - { - case QwtLegend::ClickableItem: - { - if ( !e->isAutoRepeat() ) - setDown( true ); - return; - } - case QwtLegend::CheckableItem: - { - if ( !e->isAutoRepeat() ) - setDown( !isDown() ); - return; - } - default:; - } - } - - QwtTextLabel::keyPressEvent( e ); -} - -//! Handle key release events -void QwtLegendItem::keyReleaseEvent( QKeyEvent *e ) -{ - if ( e->key() == Qt::Key_Space ) - { - switch ( d_data->itemMode ) - { - case QwtLegend::ClickableItem: - { - if ( !e->isAutoRepeat() ) - setDown( false ); - return; - } - case QwtLegend::CheckableItem: - { - return; // do nothing, but accept - } - default:; - } - } - - QwtTextLabel::keyReleaseEvent( e ); -} \ No newline at end of file diff --git a/qwt/src/qwt_legend_item.h b/qwt/src/qwt_legend_item.h deleted file mode 100644 index 75887fd57..000000000 --- a/qwt/src/qwt_legend_item.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_LEGEND_ITEM_H -#define QWT_LEGEND_ITEM_H - -#include "qwt_global.h" -#include "qwt_legend.h" -#include "qwt_text.h" -#include "qwt_text_label.h" -#include - -/*! - \brief A widget representing something on a QwtLegend(). -*/ -class QWT_EXPORT QwtLegendItem: public QwtTextLabel -{ - Q_OBJECT -public: - explicit QwtLegendItem( QWidget *parent = 0 ); - virtual ~QwtLegendItem(); - - void setItemMode( QwtLegend::LegendItemMode ); - QwtLegend::LegendItemMode itemMode() const; - - void setSpacing( int spacing ); - int spacing() const; - - virtual void setText( const QwtText & ); - - void setIdentifier( const QPixmap & ); - QPixmap identifier() const; - - void setIdentifierSize( const QSize & ); - QSize identifierSize() const; - - virtual QSize sizeHint() const; - - bool isChecked() const; - -public Q_SLOTS: - void setChecked( bool on ); - -Q_SIGNALS: - //! Signal, when the legend item has been clicked - void clicked(); - - //! Signal, when the legend item has been pressed - void pressed(); - - //! Signal, when the legend item has been relased - void released(); - - //! Signal, when the legend item has been toggled - void checked( bool ); - -protected: - void setDown( bool ); - bool isDown() const; - - virtual void paintEvent( QPaintEvent * ); - virtual void mousePressEvent( QMouseEvent * ); - virtual void mouseReleaseEvent( QMouseEvent * ); - virtual void keyPressEvent( QKeyEvent * ); - virtual void keyReleaseEvent( QKeyEvent * ); - -private: - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_legend_itemmanager.h b/qwt/src/qwt_legend_itemmanager.h deleted file mode 100644 index 0d6b58d76..000000000 --- a/qwt/src/qwt_legend_itemmanager.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_LEGEND_ITEM_MANAGER_H -#define QWT_LEGEND_ITEM_MANAGER_H - -#include "qwt_global.h" - -class QwtLegend; -class QWidget; -class QRectF; -class QPainter; - -/*! - \brief Abstract API to bind plot items to the legend -*/ - -class QWT_EXPORT QwtLegendItemManager -{ -public: - //! Constructor - QwtLegendItemManager() - { - } - - //! Destructor - virtual ~QwtLegendItemManager() - { - } - - /*! - Update the widget that represents the item on the legend - \param legend Legend - \sa legendItem() - */ - virtual void updateLegend( QwtLegend *legend ) const = 0; - - /*! - Allocate the widget that represents the item on the legend - \return Allocated widget - \sa updateLegend() QwtLegend() - */ - - virtual QWidget *legendItem() const = 0; - - /*! - QwtLegendItem can display an icon-identifier followed - by a text. The icon helps to identify a plot item on - the plot canvas and depends on the type of information, - that is displayed. - - The default implementation paints nothing. - */ - virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const - { - } -}; - -#endif diff --git a/qwt/src/qwt_magnifier.cpp b/qwt/src/qwt_magnifier.cpp deleted file mode 100644 index 4cc93087e..000000000 --- a/qwt/src/qwt_magnifier.cpp +++ /dev/null @@ -1,472 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_magnifier.h" -#include "qwt_math.h" -#include -#include - -class QwtMagnifier::PrivateData -{ -public: - PrivateData(): - isEnabled( false ), - wheelFactor( 0.9 ), - wheelButtonState( Qt::NoButton ), - mouseFactor( 0.95 ), - mouseButton( Qt::RightButton ), - mouseButtonState( Qt::NoButton ), - keyFactor( 0.9 ), - zoomInKey( Qt::Key_Plus ), - zoomOutKey( Qt::Key_Minus ), - zoomInKeyModifiers( Qt::NoModifier ), - zoomOutKeyModifiers( Qt::NoModifier ), - mousePressed( false ) - { - } - - bool isEnabled; - - double wheelFactor; - int wheelButtonState; - - double mouseFactor; - int mouseButton; - int mouseButtonState; - - double keyFactor; - int zoomInKey; - int zoomOutKey; - int zoomInKeyModifiers; - int zoomOutKeyModifiers; - - bool mousePressed; - bool hasMouseTracking; - QPoint mousePos; -}; - -/*! - Constructor - \param parent Widget to be magnified -*/ -QwtMagnifier::QwtMagnifier( QWidget *parent ): - QObject( parent ) -{ - d_data = new PrivateData(); - setEnabled( true ); -} - -//! Destructor -QwtMagnifier::~QwtMagnifier() -{ - delete d_data; -} - -/*! - \brief En/disable the magnifier - - When enabled is true an event filter is installed for - the observed widget, otherwise the event filter is removed. - - \param on true or false - \sa isEnabled(), eventFilter() -*/ -void QwtMagnifier::setEnabled( bool on ) -{ - if ( d_data->isEnabled != on ) - { - d_data->isEnabled = on; - - QObject *o = parent(); - if ( o ) - { - if ( d_data->isEnabled ) - o->installEventFilter( this ); - else - o->removeEventFilter( this ); - } - } -} - -/*! - \return true when enabled, false otherwise - \sa setEnabled(), eventFilter() -*/ -bool QwtMagnifier::isEnabled() const -{ - return d_data->isEnabled; -} - -/*! - \brief Change the wheel factor - - The wheel factor defines the ratio between the current range - on the parent widget and the zoomed range for each step of the wheel. - The default value is 0.9. - - \param factor Wheel factor - \sa wheelFactor(), setWheelButtonState(), - setMouseFactor(), setKeyFactor() -*/ -void QwtMagnifier::setWheelFactor( double factor ) -{ - d_data->wheelFactor = factor; -} - -/*! - \return Wheel factor - \sa setWheelFactor() -*/ -double QwtMagnifier::wheelFactor() const -{ - return d_data->wheelFactor; -} - -/*! - Assign a mandatory button state for zooming in/out using the wheel. - The default button state is Qt::NoButton. - - \param buttonState Button state - \sa wheelButtonState() -*/ -void QwtMagnifier::setWheelButtonState( int buttonState ) -{ - d_data->wheelButtonState = buttonState; -} - -/*! - \return Wheel button state - \sa setWheelButtonState() -*/ -int QwtMagnifier::wheelButtonState() const -{ - return d_data->wheelButtonState; -} - -/*! - \brief Change the mouse factor - - The mouse factor defines the ratio between the current range - on the parent widget and the zoomed range for each vertical mouse movement. - The default value is 0.95. - - \param factor Wheel factor - \sa mouseFactor(), setMouseButton(), setWheelFactor(), setKeyFactor() -*/ -void QwtMagnifier::setMouseFactor( double factor ) -{ - d_data->mouseFactor = factor; -} - -/*! - \return Mouse factor - \sa setMouseFactor() -*/ -double QwtMagnifier::mouseFactor() const -{ - return d_data->mouseFactor; -} - -/*! - Assign the mouse button, that is used for zooming in/out. - The default value is Qt::RightButton. - - \param button Button - \param buttonState Button state - \sa getMouseButton() -*/ -void QwtMagnifier::setMouseButton( int button, int buttonState ) -{ - d_data->mouseButton = button; - d_data->mouseButtonState = buttonState; -} - -//! \sa setMouseButton() -void QwtMagnifier::getMouseButton( - int &button, int &buttonState ) const -{ - button = d_data->mouseButton; - buttonState = d_data->mouseButtonState; -} - -/*! - \brief Change the key factor - - The key factor defines the ratio between the current range - on the parent widget and the zoomed range for each key press of - the zoom in/out keys. The default value is 0.9. - - \param factor Key factor - \sa keyFactor(), setZoomInKey(), setZoomOutKey(), - setWheelFactor, setMouseFactor() -*/ -void QwtMagnifier::setKeyFactor( double factor ) -{ - d_data->keyFactor = factor; -} - -/*! - \return Key factor - \sa setKeyFactor() -*/ -double QwtMagnifier::keyFactor() const -{ - return d_data->keyFactor; -} - -/*! - Assign the key, that is used for zooming in. - The default combination is Qt::Key_Plus + Qt::NoModifier. - - \param key - \param modifiers - \sa getZoomInKey(), setZoomOutKey() -*/ -void QwtMagnifier::setZoomInKey( int key, int modifiers ) -{ - d_data->zoomInKey = key; - d_data->zoomInKeyModifiers = modifiers; -} - -//! \sa setZoomInKey() -void QwtMagnifier::getZoomInKey( int &key, int &modifiers ) const -{ - key = d_data->zoomInKey; - modifiers = d_data->zoomInKeyModifiers; -} - -/*! - Assign the key, that is used for zooming out. - The default combination is Qt::Key_Minus + Qt::NoModifier. - - \param key - \param modifiers - \sa getZoomOutKey(), setZoomOutKey() -*/ -void QwtMagnifier::setZoomOutKey( int key, int modifiers ) -{ - d_data->zoomOutKey = key; - d_data->zoomOutKeyModifiers = modifiers; -} - -//! \sa setZoomOutKey() -void QwtMagnifier::getZoomOutKey( int &key, int &modifiers ) const -{ - key = d_data->zoomOutKey; - modifiers = d_data->zoomOutKeyModifiers; -} - -/*! - \brief Event filter - - When isEnabled() the mouse events of the observed widget are filtered. - - \param object Object to be filtered - \param event Event - - \sa widgetMousePressEvent(), widgetMouseReleaseEvent(), - widgetMouseMoveEvent(), widgetWheelEvent(), widgetKeyPressEvent() - widgetKeyReleaseEvent() -*/ -bool QwtMagnifier::eventFilter( QObject *object, QEvent *event ) -{ - if ( object && object == parent() ) - { - switch ( event->type() ) - { - case QEvent::MouseButtonPress: - { - widgetMousePressEvent( ( QMouseEvent * )event ); - break; - } - case QEvent::MouseMove: - { - widgetMouseMoveEvent( ( QMouseEvent * )event ); - break; - } - case QEvent::MouseButtonRelease: - { - widgetMouseReleaseEvent( ( QMouseEvent * )event ); - break; - } - case QEvent::Wheel: - { - widgetWheelEvent( ( QWheelEvent * )event ); - break; - } - case QEvent::KeyPress: - { - widgetKeyPressEvent( ( QKeyEvent * )event ); - break; - } - case QEvent::KeyRelease: - { - widgetKeyReleaseEvent( ( QKeyEvent * )event ); - break; - } - default:; - } - } - return QObject::eventFilter( object, event ); -} - -/*! - Handle a mouse press event for the observed widget. - - \param mouseEvent Mouse event - \sa eventFilter(), widgetMouseReleaseEvent(), widgetMouseMoveEvent() -*/ -void QwtMagnifier::widgetMousePressEvent( QMouseEvent *mouseEvent ) -{ - if ( ( mouseEvent->button() != d_data->mouseButton) - || parentWidget() == NULL ) - { - return; - } - - if ( ( mouseEvent->modifiers() & Qt::KeyboardModifierMask ) != - ( int )( d_data->mouseButtonState & Qt::KeyboardModifierMask ) ) - { - return; - } - - d_data->hasMouseTracking = parentWidget()->hasMouseTracking(); - parentWidget()->setMouseTracking( true ); - d_data->mousePos = mouseEvent->pos(); - d_data->mousePressed = true; -} - -/*! - Handle a mouse release event for the observed widget. - - \param mouseEvent Mouse event - - \sa eventFilter(), widgetMousePressEvent(), widgetMouseMoveEvent(), -*/ -void QwtMagnifier::widgetMouseReleaseEvent( QMouseEvent *mouseEvent ) -{ - Q_UNUSED( mouseEvent ); - - if ( d_data->mousePressed && parentWidget() ) - { - d_data->mousePressed = false; - parentWidget()->setMouseTracking( d_data->hasMouseTracking ); - } -} - -/*! - Handle a mouse move event for the observed widget. - - \param mouseEvent Mouse event - \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent(), -*/ -void QwtMagnifier::widgetMouseMoveEvent( QMouseEvent *mouseEvent ) -{ - if ( !d_data->mousePressed ) - return; - - const int dy = mouseEvent->pos().y() - d_data->mousePos.y(); - if ( dy != 0 ) - { - double f = d_data->mouseFactor; - if ( dy < 0 ) - f = 1 / f; - - rescale( f ); - } - - d_data->mousePos = mouseEvent->pos(); -} - -/*! - Handle a wheel event for the observed widget. - - \param wheelEvent Wheel event - \sa eventFilter() -*/ -void QwtMagnifier::widgetWheelEvent( QWheelEvent *wheelEvent ) -{ - if ( ( wheelEvent->modifiers() & Qt::KeyboardModifierMask ) != - ( int )( d_data->wheelButtonState & Qt::KeyboardModifierMask ) ) - { - return; - } - - if ( d_data->wheelFactor != 0.0 ) - { - /* - A positive delta indicates that the wheel was - rotated forwards away from the user; a negative - value indicates that the wheel was rotated - backwards toward the user. - Most mouse types work in steps of 15 degrees, - in which case the delta value is a multiple - of 120 (== 15 * 8). - */ - double f = qPow( d_data->wheelFactor, - qAbs( wheelEvent->delta() / 120 ) ); - - if ( wheelEvent->delta() > 0 ) - f = 1 / f; - - rescale( f ); - } -} - -/*! - Handle a key press event for the observed widget. - - \param keyEvent Key event - \sa eventFilter(), widgetKeyReleaseEvent() -*/ -void QwtMagnifier::widgetKeyPressEvent( QKeyEvent *keyEvent ) -{ - const int key = keyEvent->key(); - const int state = keyEvent->modifiers(); - - if ( key == d_data->zoomInKey && - state == d_data->zoomInKeyModifiers ) - { - rescale( d_data->keyFactor ); - } - else if ( key == d_data->zoomOutKey && - state == d_data->zoomOutKeyModifiers ) - { - rescale( 1.0 / d_data->keyFactor ); - } -} - -/*! - Handle a key release event for the observed widget. - - \param keyEvent Key event - \sa eventFilter(), widgetKeyReleaseEvent() -*/ -void QwtMagnifier::widgetKeyReleaseEvent( QKeyEvent *keyEvent ) -{ - Q_UNUSED( keyEvent ); -} - -//! \return Parent widget, where the rescaling happens -QWidget *QwtMagnifier::parentWidget() -{ - if ( parent()->inherits( "QWidget" ) ) - return ( QWidget * )parent(); - - return NULL; -} - -//! \return Parent widget, where the rescaling happens -const QWidget *QwtMagnifier::parentWidget() const -{ - if ( parent()->inherits( "QWidget" ) ) - return ( const QWidget * )parent(); - - return NULL; -} diff --git a/qwt/src/qwt_magnifier.h b/qwt/src/qwt_magnifier.h deleted file mode 100644 index f2f4bbd98..000000000 --- a/qwt/src/qwt_magnifier.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_MAGNIFIER_H -#define QWT_MAGNIFIER_H 1 - -#include "qwt_global.h" -#include - -class QWidget; -class QMouseEvent; -class QWheelEvent; -class QKeyEvent; - -/*! - \brief QwtMagnifier provides zooming, by magnifying in steps. - - Using QwtMagnifier a plot can be zoomed in/out in steps using - keys, the mouse wheel or moving a mouse button in vertical direction. -*/ -class QWT_EXPORT QwtMagnifier: public QObject -{ - Q_OBJECT - -public: - explicit QwtMagnifier( QWidget * ); - virtual ~QwtMagnifier(); - - QWidget *parentWidget(); - const QWidget *parentWidget() const; - - void setEnabled( bool ); - bool isEnabled() const; - - // mouse - void setMouseFactor( double ); - double mouseFactor() const; - - void setMouseButton( int button, int buttonState = Qt::NoButton ); - void getMouseButton( int &button, int &buttonState ) const; - - // mouse wheel - void setWheelFactor( double ); - double wheelFactor() const; - - void setWheelButtonState( int buttonState ); - int wheelButtonState() const; - - // keyboard - void setKeyFactor( double ); - double keyFactor() const; - - void setZoomInKey( int key, int modifiers ); - void getZoomInKey( int &key, int &modifiers ) const; - - void setZoomOutKey( int key, int modifiers ); - void getZoomOutKey( int &key, int &modifiers ) const; - - virtual bool eventFilter( QObject *, QEvent * ); - -protected: - /*! - Rescale the parent widget - \param factor Scale factor - */ - virtual void rescale( double factor ) = 0; - - virtual void widgetMousePressEvent( QMouseEvent * ); - virtual void widgetMouseReleaseEvent( QMouseEvent * ); - virtual void widgetMouseMoveEvent( QMouseEvent * ); - virtual void widgetWheelEvent( QWheelEvent * ); - virtual void widgetKeyPressEvent( QKeyEvent * ); - virtual void widgetKeyReleaseEvent( QKeyEvent * ); - -private: - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_math.cpp b/qwt/src/qwt_math.cpp deleted file mode 100644 index 06a039aec..000000000 --- a/qwt/src/qwt_math.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_math.h" - -/*! - \brief Find the smallest value in an array - \param array Pointer to an array - \param size Array size -*/ -double qwtGetMin( const double *array, int size ) -{ - if ( size <= 0 ) - return 0.0; - - double rv = array[0]; - for ( int i = 1; i < size; i++ ) - rv = qMin( rv, array[i] ); - - return rv; -} - - -/*! - \brief Find the largest value in an array - \param array Pointer to an array - \param size Array size -*/ -double qwtGetMax( const double *array, int size ) -{ - if ( size <= 0 ) - return 0.0; - - double rv = array[0]; - for ( int i = 1; i < size; i++ ) - rv = qMax( rv, array[i] ); - - return rv; -} diff --git a/qwt/src/qwt_math.h b/qwt/src/qwt_math.h deleted file mode 100644 index fa1f0675b..000000000 --- a/qwt/src/qwt_math.h +++ /dev/null @@ -1,182 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_MATH_H -#define QWT_MATH_H - -#include "qwt_global.h" - -#if defined(_MSC_VER) -/* - Microsoft says: - - Define _USE_MATH_DEFINES before including math.h to expose these macro - definitions for common math constants. These are placed under an #ifdef - since these commonly-defined names are not part of the C/C++ standards. -*/ -#define _USE_MATH_DEFINES 1 -#endif - -#include -#include -#include "qwt_global.h" - -#ifndef LOG10_2 -#define LOG10_2 0.30102999566398119802 /* log10(2) */ -#endif - -#ifndef LOG10_3 -#define LOG10_3 0.47712125471966243540 /* log10(3) */ -#endif - -#ifndef LOG10_5 -#define LOG10_5 0.69897000433601885749 /* log10(5) */ -#endif - -#ifndef M_2PI -#define M_2PI 6.28318530717958623200 /* 2 pi */ -#endif - -#ifndef LOG_MIN -//! Mininum value for logarithmic scales -#define LOG_MIN 1.0e-100 -#endif - -#ifndef LOG_MAX -//! Maximum value for logarithmic scales -#define LOG_MAX 1.0e100 -#endif - -#ifndef M_E -#define M_E 2.7182818284590452354 /* e */ -#endif - -#ifndef M_LOG2E -#define M_LOG2E 1.4426950408889634074 /* log_2 e */ -#endif - -#ifndef M_LOG10E -#define M_LOG10E 0.43429448190325182765 /* log_10 e */ -#endif - -#ifndef M_LN2 -#define M_LN2 0.69314718055994530942 /* log_e 2 */ -#endif - -#ifndef M_LN10 -#define M_LN10 2.30258509299404568402 /* log_e 10 */ -#endif - -#ifndef M_PI -#define M_PI 3.14159265358979323846 /* pi */ -#endif - -#ifndef M_PI_2 -#define M_PI_2 1.57079632679489661923 /* pi/2 */ -#endif - -#ifndef M_PI_4 -#define M_PI_4 0.78539816339744830962 /* pi/4 */ -#endif - -#ifndef M_1_PI -#define M_1_PI 0.31830988618379067154 /* 1/pi */ -#endif - -#ifndef M_2_PI -#define M_2_PI 0.63661977236758134308 /* 2/pi */ -#endif - -#ifndef M_2_SQRTPI -#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ -#endif - -#ifndef M_SQRT2 -#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ -#endif - -#ifndef M_SQRT1_2 -#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ -#endif - -QWT_EXPORT double qwtGetMin( const double *array, int size ); -QWT_EXPORT double qwtGetMax( const double *array, int size ); - -/*! - \brief Compare 2 values, relative to an interval - - Values are "equal", when : - \f$\cdot value2 - value1 <= abs(intervalSize * 10e^{-6})\f$ - - \param value1 First value to compare - \param value2 Second value to compare - \param intervalSize interval size - - \return 0: if equal, -1: if value2 > value1, 1: if value1 > value2 -*/ -inline int qwtFuzzyCompare( double value1, double value2, double intervalSize ) -{ - const double eps = qAbs( 1.0e-6 * intervalSize ); - - if ( value2 - value1 > eps ) - return -1; - - if ( value1 - value2 > eps ) - return 1; - - return 0; -} - - -inline bool qwtFuzzyGreaterOrEqual( double d1, double d2 ) -{ - return ( d1 >= d2 ) || qFuzzyCompare( d1, d2 ); -} - -inline bool qwtFuzzyLessOrEqual( double d1, double d2 ) -{ - return ( d1 <= d2 ) || qFuzzyCompare( d1, d2 ); -} - -//! Return the sign -inline int qwtSign( double x ) -{ - if ( x > 0.0 ) - return 1; - else if ( x < 0.0 ) - return ( -1 ); - else - return 0; -} - -//! Return the square of a number -inline double qwtSqr( double x ) -{ - return x * x; -} - -//! Like qRound, but without converting the result to an int -inline double qwtRoundF(double d) -{ - return ::floor( d + 0.5 ); -} - -//! Like qFloor, but without converting the result to an int -inline double qwtFloorF(double d) -{ - return ::floor( d ); -} - -//! Like qCeil, but without converting the result to an int -inline double qwtCeilF(double d) -{ - return ::ceil( d ); -} - -#endif diff --git a/qwt/src/qwt_matrix_raster_data.cpp b/qwt/src/qwt_matrix_raster_data.cpp deleted file mode 100644 index 51216bb82..000000000 --- a/qwt/src/qwt_matrix_raster_data.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_matrix_raster_data.h" -#include -#include - -class QwtMatrixRasterData::PrivateData -{ -public: - PrivateData(): - resampleMode(QwtMatrixRasterData::NearestNeighbour), - numColumns(0) - { - } - - inline double value(size_t row, size_t col) const - { - return values.data()[ row * numColumns + col ]; - } - - QwtMatrixRasterData::ResampleMode resampleMode; - - QVector values; - size_t numColumns; - size_t numRows; - - double dx; - double dy; -}; - -//! Constructor -QwtMatrixRasterData::QwtMatrixRasterData() -{ - d_data = new PrivateData(); - update(); -} - -//! Destructor -QwtMatrixRasterData::~QwtMatrixRasterData() -{ - delete d_data; -} - -/*! - \brief Set the resampling algorithm - - \param mode Resampling mode - \sa resampleMode(), value() -*/ -void QwtMatrixRasterData::setResampleMode(ResampleMode mode) -{ - d_data->resampleMode = mode; -} - -/*! - \return resampling algorithm - \sa setResampleMode(), value() -*/ -QwtMatrixRasterData::ResampleMode QwtMatrixRasterData::resampleMode() const -{ - return d_data->resampleMode; -} - -/*! - \brief Assign the bounding interval for an axis - - Setting the bounding intervals for the X/Y axis is mandatory - to define the positions for the values of the value matrix. - The interval in Z direction defines the possible range for - the values in the matrix, what is f.e used by QwtPlotSpectrogram - to map values to colors. The Z-interval might be the bounding - interval of the values in the matrix, but usually it isn't. - ( f.e a interval of 0.0-100.0 for values in percentage ) - - \param axis X, Y or Z axis - \param interval Interval - - \sa QwtRasterData::interval(), setValueMatrix() -*/ -void QwtMatrixRasterData::setInterval( - Qt::Axis axis, const QwtInterval &interval ) -{ - QwtRasterData::setInterval( axis, interval ); - update(); -} - -/*! - \brief Assign a value matrix - - The positions of the values are calculated by dividing - the bounding rectangle of the X/Y intervals into equidistant - rectangles ( pixels ). Each value corresponds to the center of - a pixel. - - \param values Vector of values - \param numColumns Number of columns - - \sa valueMatrix(), numColumns(), numRows(), setInterval()() -*/ -void QwtMatrixRasterData::setValueMatrix( - const QVector &values, size_t numColumns ) -{ - d_data->values = values; - d_data->numColumns = numColumns; - update(); -} - -/*! - \return Value matrix - \sa setValueMatrix(), numColumns(), numRows(), setInterval() -*/ -const QVector QwtMatrixRasterData::valueMatrix() const -{ - return d_data->values; -} - -/*! - \return Number of columns of the value matrix - \sa valueMatrix(), numRows(), setValueMatrix() -*/ -size_t QwtMatrixRasterData::numColumns() const -{ - return d_data->numColumns; -} - -/*! - \return Number of rows of the value matrix - \sa valueMatrix(), numColumns(), setValueMatrix() -*/ -size_t QwtMatrixRasterData::numRows() const -{ - return d_data->numRows; -} - -/*! - \brief Pixel hint - - - NearestNeighbour\n - pixelHint() returns the surrounding pixel of the top left value - in the matrix. - - - BilinearInterpolation\n - Returns an empty rectangle recommending - to render in target device ( f.e. screen ) resolution. - - \sa ResampleMode, setMatrix(), setInterval() -*/ -QRectF QwtMatrixRasterData::pixelHint( const QRectF & ) const -{ - QRectF rect; - if ( d_data->resampleMode == NearestNeighbour ) - { - const QwtInterval intervalX = interval( Qt::XAxis ); - const QwtInterval intervalY = interval( Qt::YAxis ); - if ( intervalX.isValid() && intervalY.isValid() ) - { - rect = QRectF( intervalX.minValue(), intervalY.minValue(), - d_data->dx, d_data->dy ); - } - } - - return rect; -} - -/*! - \return the value at a raster position - - \param x X value in plot coordinates - \param y Y value in plot coordinates - - \sa ResampleMode -*/ -double QwtMatrixRasterData::value( double x, double y ) const -{ - const QwtInterval xInterval = interval( Qt::XAxis ); - const QwtInterval yInterval = interval( Qt::YAxis ); - - if ( !( xInterval.contains(x) && yInterval.contains(y) ) ) - return qQNaN(); - - double value; - - switch( d_data->resampleMode ) - { - case BilinearInterpolation: - { - int col1 = qRound( (x - xInterval.minValue() ) / d_data->dx ) - 1; - int row1 = qRound( (y - yInterval.minValue() ) / d_data->dy ) - 1; - int col2 = col1 + 1; - int row2 = row1 + 1; - - if ( col1 < 0 ) - col1 = col2; - else if ( col2 >= (int)d_data->numColumns ) - col2 = col1; - - if ( row1 < 0 ) - row1 = row2; - else if ( row2 >= (int)d_data->numRows ) - row2 = row1; - - const double v11 = d_data->value( row1, col1 ); - const double v21 = d_data->value( row1, col2 ); - const double v12 = d_data->value( row2, col1 ); - const double v22 = d_data->value( row2, col2 ); - - const double x2 = xInterval.minValue() + - ( col2 + 0.5 ) * d_data->dx; - const double y2 = yInterval.minValue() + - ( row2 + 0.5 ) * d_data->dy; - - const double rx = ( x2 - x ) / d_data->dx; - const double ry = ( y2 - y ) / d_data->dy; - - const double vr1 = rx * v11 + ( 1.0 - rx ) * v21; - const double vr2 = rx * v12 + ( 1.0 - rx ) * v22; - - value = ry * vr1 + ( 1.0 - ry ) * vr2; - - break; - } - case NearestNeighbour: - default: - { - uint row = uint( (y - yInterval.minValue() ) / d_data->dy ); - uint col = uint( (x - xInterval.minValue() ) / d_data->dx ); - - // In case of intervals, where the maximum is included - // we get out of bound for row/col, when the value for the - // maximum is requested. Instead we return the value - // from the last row/col - - if ( row >= d_data->numRows ) - row = d_data->numRows - 1; - - if ( col >= d_data->numColumns ) - col = d_data->numColumns - 1; - - value = d_data->value( row, col ); - } - } - - return value; -} - -void QwtMatrixRasterData::update() -{ - d_data->numRows = 0; - d_data->dx = 0.0; - d_data->dy = 0.0; - - if ( d_data->numColumns > 0 ) - { - d_data->numRows = d_data->values.size() / d_data->numColumns; - - const QwtInterval xInterval = interval( Qt::XAxis ); - const QwtInterval yInterval = interval( Qt::YAxis ); - if ( xInterval.isValid() ) - d_data->dx = xInterval.width() / d_data->numColumns; - if ( yInterval.isValid() ) - d_data->dy = yInterval.width() / d_data->numRows; - } -} diff --git a/qwt/src/qwt_matrix_raster_data.h b/qwt/src/qwt_matrix_raster_data.h deleted file mode 100644 index 9ead58733..000000000 --- a/qwt/src/qwt_matrix_raster_data.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_MATRIX_RASTER_DATA_H -#define QWT_MATRIX_RASTER_DATA_H 1 - -#include "qwt_global.h" -#include "qwt_raster_data.h" -#include - -/*! - \brief A class representing a matrix of values as raster data - - QwtMatrixRasterData implements an interface for a matrix of - equidistant values, that can be used by a QwtPlotRasterItem. - It implements a couple of resampling algorithms, to provide - values for positions, that or not on the value matrix. -*/ -class QWT_EXPORT QwtMatrixRasterData: public QwtRasterData -{ -public: - /*! - \brief Resampling algorithm - The default setting is NearestNeighbour; - */ - enum ResampleMode - { - /*! - Return the value from the matrix, that is nearest to the - the requested position. - */ - NearestNeighbour, - - /*! - Interpolate the value from the distances and values of the - 4 surrounding values in the matrix, - */ - BilinearInterpolation - }; - - QwtMatrixRasterData(); - virtual ~QwtMatrixRasterData(); - - void setResampleMode(ResampleMode mode); - ResampleMode resampleMode() const; - - virtual void setInterval( Qt::Axis, const QwtInterval & ); - void setValueMatrix( const QVector &values, size_t numColumns ); - - const QVector valueMatrix() const; - size_t numColumns() const; - size_t numRows() const; - - virtual QRectF pixelHint( const QRectF & ) const; - - virtual double value( double x, double y ) const; - -private: - void update(); - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_null_paintdevice.cpp b/qwt/src/qwt_null_paintdevice.cpp deleted file mode 100644 index 1806a5649..000000000 --- a/qwt/src/qwt_null_paintdevice.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_null_paintdevice.h" -#include -#include - -class QwtNullPaintDevice::PrivateData -{ -public: - PrivateData(): - size( 0, 0 ) - { - } - - QSize size; -}; - -class QwtNullPaintDevice::PaintEngine: public QPaintEngine -{ -public: - PaintEngine( QPaintEngine::PaintEngineFeatures ); - - virtual bool begin( QPaintDevice * ); - virtual bool end(); - - virtual Type type () const; - virtual void updateState(const QPaintEngineState &); - - virtual void drawRects(const QRect *, int ); - virtual void drawRects(const QRectF *, int ); - - virtual void drawLines(const QLine *, int ); - virtual void drawLines(const QLineF *, int ); - - virtual void drawEllipse(const QRectF &); - virtual void drawEllipse(const QRect &); - - virtual void drawPath(const QPainterPath &); - - virtual void drawPoints(const QPointF *, int ); - virtual void drawPoints(const QPoint *, int ); - - virtual void drawPolygon(const QPointF *, int , PolygonDrawMode ); - virtual void drawPolygon(const QPoint *, int , PolygonDrawMode ); - - virtual void drawPixmap(const QRectF &, - const QPixmap &, const QRectF &); - - virtual void drawTextItem(const QPointF &, const QTextItem &); - virtual void drawTiledPixmap(const QRectF &, - const QPixmap &, const QPointF &s); - virtual void drawImage(const QRectF &, - const QImage &, const QRectF &, Qt::ImageConversionFlags ); - -private: - QwtNullPaintDevice *d_device; -}; - -QwtNullPaintDevice::PaintEngine::PaintEngine( - QPaintEngine::PaintEngineFeatures features ): - QPaintEngine( features ), - d_device(NULL) -{ -} - -bool QwtNullPaintDevice::PaintEngine::begin( - QPaintDevice *device ) -{ - d_device = static_cast( device ); - return true; -} - -bool QwtNullPaintDevice::PaintEngine::end() -{ - d_device = NULL; - return true; -} - -QPaintEngine::Type -QwtNullPaintDevice::PaintEngine::type () const -{ - return QPaintEngine::User; -} - -void QwtNullPaintDevice::PaintEngine::drawRects( - const QRect *rects, int rectCount) -{ - if ( d_device ) - d_device->drawRects( rects, rectCount ); -} - -void QwtNullPaintDevice::PaintEngine::drawRects( - const QRectF *rects, int rectCount) -{ - if ( d_device ) - d_device->drawRects( rects, rectCount ); -} - -void QwtNullPaintDevice::PaintEngine::drawLines( - const QLine *lines, int lineCount) -{ - if ( d_device ) - d_device->drawLines( lines, lineCount ); -} - -void QwtNullPaintDevice::PaintEngine::drawLines( - const QLineF *lines, int lineCount) -{ - if ( d_device ) - d_device->drawLines( lines, lineCount ); -} - -void QwtNullPaintDevice::PaintEngine::drawEllipse( - const QRectF &rect) -{ - if ( d_device ) - d_device->drawEllipse( rect ); -} - -void QwtNullPaintDevice::PaintEngine::drawEllipse( - const QRect &rect) -{ - if ( d_device ) - d_device->drawEllipse( rect ); -} - - -void QwtNullPaintDevice::PaintEngine::drawPath( - const QPainterPath &path) -{ - if ( d_device ) - d_device->drawPath( path ); -} - -void QwtNullPaintDevice::PaintEngine::drawPoints( - const QPointF *points, int pointCount) -{ - if ( d_device ) - d_device->drawPoints( points, pointCount ); -} - -void QwtNullPaintDevice::PaintEngine::drawPoints( - const QPoint *points, int pointCount) -{ - if ( d_device ) - d_device->drawPoints( points, pointCount ); -} - -void QwtNullPaintDevice::PaintEngine::drawPolygon( - const QPointF *points, int pointCount, PolygonDrawMode mode) -{ - if ( d_device ) - d_device->drawPolygon( points, pointCount, mode ); -} - -void QwtNullPaintDevice::PaintEngine::drawPolygon( - const QPoint *points, int pointCount, PolygonDrawMode mode) -{ - if ( d_device ) - d_device->drawPolygon( points, pointCount, mode ); -} - -void QwtNullPaintDevice::PaintEngine::drawPixmap( - const QRectF &rect, const QPixmap &pm, const QRectF &subRect ) -{ - if ( d_device ) - d_device->drawPixmap( rect, pm, subRect ); -} - -void QwtNullPaintDevice::PaintEngine::drawTextItem( - const QPointF &pos, const QTextItem &textItem) -{ - if ( d_device ) - d_device->drawTextItem( pos, textItem ); -} - -void QwtNullPaintDevice::PaintEngine::drawTiledPixmap( - const QRectF &rect, const QPixmap &pixmap, - const QPointF &subRect) -{ - if ( d_device ) - d_device->drawTiledPixmap( rect, pixmap, subRect ); -} - -void QwtNullPaintDevice::PaintEngine::drawImage( - const QRectF &rect, const QImage &image, - const QRectF &subRect, Qt::ImageConversionFlags flags) -{ - if ( d_device ) - d_device->drawImage( rect, image, subRect, flags ); -} - -void QwtNullPaintDevice::PaintEngine::updateState( - const QPaintEngineState &state) -{ - if ( d_device ) - d_device->updateState( state ); -} - -//! Constructor -QwtNullPaintDevice::QwtNullPaintDevice( - QPaintEngine::PaintEngineFeatures features ) -{ - init( features ); -} - -//! Constructor -QwtNullPaintDevice::QwtNullPaintDevice( const QSize &size, - QPaintEngine::PaintEngineFeatures features ) -{ - init( features ); - d_data->size = size; -} - -void QwtNullPaintDevice::init( - QPaintEngine::PaintEngineFeatures features ) -{ - d_engine = new PaintEngine( features ); - d_data = new PrivateData; -} - -//! Destructor -QwtNullPaintDevice::~QwtNullPaintDevice() -{ - delete d_engine; - delete d_data; -} - -/*! - Set the size of the paint device - - \param size Size - \sa size() -*/ -void QwtNullPaintDevice::setSize( const QSize & size ) -{ - d_data->size = size; -} - -/*! - \return Size of the paint device - \sa setSize() -*/ -QSize QwtNullPaintDevice::size() const -{ - return d_data->size; -} - -//! See QPaintDevice::paintEngine() -QPaintEngine *QwtNullPaintDevice::paintEngine() const -{ - return d_engine; -} - -/*! - See QPaintDevice::metric() - \sa setSize() -*/ -int QwtNullPaintDevice::metric( PaintDeviceMetric metric ) const -{ - static QPixmap pm; - - int value; - - switch ( metric ) - { - case PdmWidth: - value = qMax( d_data->size.width(), 0 ); - break; - case PdmHeight: - value = qMax( d_data->size.height(), 0 ); - break; - case PdmNumColors: - value = 16777216; - break; - case PdmDepth: - value = 24; - break; - case PdmPhysicalDpiX: - case PdmDpiY: - case PdmPhysicalDpiY: - case PdmWidthMM: - case PdmHeightMM: - case PdmDpiX: - default: - value = 0; - } - return value; - -} - -//! See QPaintEngine::drawRects() -void QwtNullPaintDevice::drawRects( - const QRect *rects, int rectCount) -{ - Q_UNUSED(rects); - Q_UNUSED(rectCount); -} - -//! See QPaintEngine::drawRects() -void QwtNullPaintDevice::drawRects( - const QRectF *rects, int rectCount) -{ - Q_UNUSED(rects); - Q_UNUSED(rectCount); -} - -//! See QPaintEngine::drawLines() -void QwtNullPaintDevice::drawLines( - const QLine *lines, int lineCount) -{ - Q_UNUSED(lines); - Q_UNUSED(lineCount); -} - -//! See QPaintEngine::drawLines() -void QwtNullPaintDevice::drawLines( - const QLineF *lines, int lineCount) -{ - Q_UNUSED(lines); - Q_UNUSED(lineCount); -} - -//! See QPaintEngine::drawEllipse() -void QwtNullPaintDevice::drawEllipse( const QRectF &rect ) -{ - Q_UNUSED(rect); -} - -//! See QPaintEngine::drawEllipse() -void QwtNullPaintDevice::drawEllipse( const QRect &rect ) -{ - Q_UNUSED(rect); -} - -//! See QPaintEngine::drawPath() -void QwtNullPaintDevice::drawPath( const QPainterPath &path ) -{ - Q_UNUSED(path); -} - -//! See QPaintEngine::drawPoints() -void QwtNullPaintDevice::drawPoints( - const QPointF *points, int pointCount) -{ - Q_UNUSED(points); - Q_UNUSED(pointCount); -} - -//! See QPaintEngine::drawPoints() -void QwtNullPaintDevice::drawPoints( - const QPoint *points, int pointCount) -{ - Q_UNUSED(points); - Q_UNUSED(pointCount); -} - -//! See QPaintEngine::drawPolygon() -void QwtNullPaintDevice::drawPolygon( - const QPointF *points, int pointCount, - QPaintEngine::PolygonDrawMode mode) -{ - Q_UNUSED(points); - Q_UNUSED(pointCount); - Q_UNUSED(mode); -} - -//! See QPaintEngine::drawPolygon() -void QwtNullPaintDevice::drawPolygon( - const QPoint *points, int pointCount, - QPaintEngine::PolygonDrawMode mode) -{ - Q_UNUSED(points); - Q_UNUSED(pointCount); - Q_UNUSED(mode); -} - -//! See QPaintEngine::drawPixmap() -void QwtNullPaintDevice::drawPixmap( const QRectF &rect, - const QPixmap &pm, const QRectF &subRect ) -{ - Q_UNUSED(rect); - Q_UNUSED(pm); - Q_UNUSED(subRect); -} - -//! See QPaintEngine::drawTextItem() -void QwtNullPaintDevice::drawTextItem( - const QPointF &pos, const QTextItem &textItem) -{ - Q_UNUSED(pos); - Q_UNUSED(textItem); -} - -//! See QPaintEngine::drawTiledPixmap() -void QwtNullPaintDevice::drawTiledPixmap( - const QRectF &rect, const QPixmap &pixmap, - const QPointF &subRect) -{ - Q_UNUSED(rect); - Q_UNUSED(pixmap); - Q_UNUSED(subRect); -} - -//! See QPaintEngine::drawImage() -void QwtNullPaintDevice::drawImage( - const QRectF &rect, const QImage &image, - const QRectF &subRect, Qt::ImageConversionFlags flags) -{ - Q_UNUSED(rect); - Q_UNUSED(image); - Q_UNUSED(subRect); - Q_UNUSED(flags); -} - -//! See QPaintEngine::updateState() -void QwtNullPaintDevice::updateState( - const QPaintEngineState &state ) -{ - Q_UNUSED(state); -} diff --git a/qwt/src/qwt_null_paintdevice.h b/qwt/src/qwt_null_paintdevice.h deleted file mode 100644 index f103eb79f..000000000 --- a/qwt/src/qwt_null_paintdevice.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_NULL_PAINT_DEVICE_H -#define QWT_NULL_PAINT_DEVICE_H 1 - -#include "qwt_global.h" -#include -#include - -/*! - \brief A null paint device doing nothing - - Sometimes important layout/rendering geometries are not - available or changable from the public Qt class interface. - ( f.e hidden in the style implementation ). - - QwtNullPaintDevice can be used to manipulate or filter out - these informations by analyzing the stream of paint primitives. - - F.e. QwtNullPaintDevice is used by QwtPlotCanvas to identify - styled backgrounds with rounded corners. -*/ - -class QWT_EXPORT QwtNullPaintDevice: public QPaintDevice -{ -public: - QwtNullPaintDevice( QPaintEngine::PaintEngineFeatures ); - QwtNullPaintDevice( const QSize &size, - QPaintEngine::PaintEngineFeatures ); - - virtual ~QwtNullPaintDevice(); - - void setSize( const QSize &); - QSize size() const; - - virtual QPaintEngine *paintEngine() const; - virtual int metric( PaintDeviceMetric metric ) const; - - virtual void drawRects(const QRect *, int ); - virtual void drawRects(const QRectF *, int ); - - virtual void drawLines(const QLine *, int ); - virtual void drawLines(const QLineF *, int ); - - virtual void drawEllipse(const QRectF &); - virtual void drawEllipse(const QRect &); - - virtual void drawPath(const QPainterPath &); - - virtual void drawPoints(const QPointF *, int ); - virtual void drawPoints(const QPoint *, int ); - - virtual void drawPolygon( - const QPointF *, int , QPaintEngine::PolygonDrawMode ); - - virtual void drawPolygon( - const QPoint *, int , QPaintEngine::PolygonDrawMode ); - - virtual void drawPixmap(const QRectF &, - const QPixmap &, const QRectF &); - - virtual void drawTextItem(const QPointF &, const QTextItem &); - - virtual void drawTiledPixmap(const QRectF &, - const QPixmap &, const QPointF &s); - - virtual void drawImage(const QRectF &, - const QImage &, const QRectF &, Qt::ImageConversionFlags ); - - virtual void updateState( const QPaintEngineState &state ); - -private: - void init( QPaintEngine::PaintEngineFeatures ); - - class PaintEngine; - PaintEngine *d_engine; - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_painter.cpp b/qwt/src/qwt_painter.cpp deleted file mode 100644 index 0da97014d..000000000 --- a/qwt/src/qwt_painter.cpp +++ /dev/null @@ -1,704 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_painter.h" -#include "qwt_math.h" -#include "qwt_clipper.h" -#include "qwt_color_map.h" -#include "qwt_scale_map.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -bool QwtPainter::d_polylineSplitting = true; -bool QwtPainter::d_roundingAlignment = true; - -static inline bool isClippingNeeded( const QPainter *painter, QRectF &clipRect ) -{ - bool doClipping = false; - const QPaintEngine *pe = painter->paintEngine(); - if ( pe && pe->type() == QPaintEngine::SVG ) - { - // The SVG paint engine ignores any clipping, - - if ( painter->hasClipping() ) - { - doClipping = true; - clipRect = painter->clipRegion().boundingRect(); - } - } - - return doClipping; -} - -static inline void drawPolyline( QPainter *painter, - const QPointF *points, int pointCount, bool polylineSplitting ) -{ - bool doSplit = false; - if ( polylineSplitting ) - { - const QPaintEngine *pe = painter->paintEngine(); - if ( pe && pe->type() == QPaintEngine::Raster ) - { - /* - The raster paint engine seems to use some algo with O(n*n). - ( Qt 4.3 is better than Qt 4.2, but remains unacceptable) - To work around this problem, we have to split the polygon into - smaller pieces. - */ - doSplit = true; - } - } - - if ( doSplit ) - { - const int splitSize = 20; - for ( int i = 0; i < pointCount; i += splitSize ) - { - const int n = qMin( splitSize + 1, pointCount - i ); - painter->drawPolyline( points + i, n ); - } - } - else - painter->drawPolyline( points, pointCount ); -} - -static inline void unscaleFont( QPainter *painter ) -{ - if ( painter->font().pixelSize() >= 0 ) - return; - - static QSize screenResolution; - if ( !screenResolution.isValid() ) - { - QDesktopWidget *desktop = QApplication::desktop(); - if ( desktop ) - { - screenResolution.setWidth( desktop->logicalDpiX() ); - screenResolution.setHeight( desktop->logicalDpiY() ); - } - } - - const QPaintDevice *pd = painter->device(); - if ( pd->logicalDpiX() != screenResolution.width() || - pd->logicalDpiY() != screenResolution.height() ) - { - QFont pixelFont( painter->font(), QApplication::desktop() ); - pixelFont.setPixelSize( QFontInfo( pixelFont ).pixelSize() ); - - painter->setFont( pixelFont ); - } -} - -/*! - Check if the painter is using a paint engine, that aligns - coordinates to integers. Today these are all paint engines - beside QPaintEngine::Pdf and QPaintEngine::SVG. - - \param painter Painter - \return true, when the paint engine is aligning - - \sa setRoundingAlignment() -*/ -bool QwtPainter::isAligning( QPainter *painter ) -{ - if ( painter && painter->isActive() ) - { - switch ( painter->paintEngine()->type() ) - { - case QPaintEngine::Pdf: - case QPaintEngine::SVG: - return false; - - default:; - } - } - - return true; -} - -/*! - Enable whether coordinates should be rounded, before they are painted - to a paint engine that floors to integer values. For other paint engines - this ( Pdf, SVG ), this flag has no effect. - QwtPainter stores this flag only, the rounding itsself is done in - the painting code ( f.e the plot items ). - - The default setting is true. - - \sa roundingAlignment(), isAligning() -*/ -void QwtPainter::setRoundingAlignment( bool enable ) -{ - d_roundingAlignment = enable; -} - -/*! - \brief En/Disable line splitting for the raster paint engine - - The raster paint engine paints polylines of many points - much faster when they are splitted in smaller chunks. - - \sa polylineSplitting() -*/ -void QwtPainter::setPolylineSplitting( bool enable ) -{ - d_polylineSplitting = enable; -} - -//! Wrapper for QPainter::drawPath() -void QwtPainter::drawPath( QPainter *painter, const QPainterPath &path ) -{ - painter->drawPath( path ); -} - -//! Wrapper for QPainter::drawRect() -void QwtPainter::drawRect( QPainter *painter, double x, double y, double w, double h ) -{ - drawRect( painter, QRectF( x, y, w, h ) ); -} - -//! Wrapper for QPainter::drawRect() -void QwtPainter::drawRect( QPainter *painter, const QRectF &rect ) -{ - const QRectF r = rect; - - QRectF clipRect; - const bool deviceClipping = isClippingNeeded( painter, clipRect ); - - if ( deviceClipping ) - { - if ( !clipRect.intersects( r ) ) - return; - - if ( !clipRect.contains( r ) ) - { - fillRect( painter, r & clipRect, painter->brush() ); - - painter->save(); - painter->setBrush( Qt::NoBrush ); - drawPolyline( painter, QPolygonF( r ) ); - painter->restore(); - - return; - } - } - - painter->drawRect( r ); -} - -//! Wrapper for QPainter::fillRect() -void QwtPainter::fillRect( QPainter *painter, - const QRectF &rect, const QBrush &brush ) -{ - if ( !rect.isValid() ) - return; - - QRectF clipRect; - const bool deviceClipping = isClippingNeeded( painter, clipRect ); - - /* - Performance of Qt4 is horrible for non trivial brushs. Without - clipping expect minutes or hours for repainting large rects - (might result from zooming) - */ - - if ( deviceClipping ) - clipRect &= painter->window(); - else - clipRect = painter->window(); - - if ( painter->hasClipping() ) - clipRect &= painter->clipRegion().boundingRect(); - - QRectF r = rect; - if ( deviceClipping ) - r = r.intersect( clipRect ); - - if ( r.isValid() ) - painter->fillRect( r, brush ); -} - -//! Wrapper for QPainter::drawPie() -void QwtPainter::drawPie( QPainter *painter, const QRectF &rect, - int a, int alen ) -{ - QRectF clipRect; - const bool deviceClipping = isClippingNeeded( painter, clipRect ); - if ( deviceClipping && !clipRect.contains( rect ) ) - return; - - painter->drawPie( rect, a, alen ); -} - -//! Wrapper for QPainter::drawEllipse() -void QwtPainter::drawEllipse( QPainter *painter, const QRectF &rect ) -{ - QRectF clipRect; - const bool deviceClipping = isClippingNeeded( painter, clipRect ); - - if ( deviceClipping && !clipRect.contains( rect ) ) - return; - - painter->drawEllipse( rect ); -} - -//! Wrapper for QPainter::drawText() -void QwtPainter::drawText( QPainter *painter, double x, double y, - const QString &text ) -{ - drawText( painter, QPointF( x, y ), text ); -} - -//! Wrapper for QPainter::drawText() -void QwtPainter::drawText( QPainter *painter, const QPointF &pos, - const QString &text ) -{ - QRectF clipRect; - const bool deviceClipping = isClippingNeeded( painter, clipRect ); - - if ( deviceClipping && !clipRect.contains( pos ) ) - return; - - - painter->save(); - unscaleFont( painter ); - painter->drawText( pos, text ); - painter->restore(); -} - -//! Wrapper for QPainter::drawText() -void QwtPainter::drawText( QPainter *painter, - double x, double y, double w, double h, - int flags, const QString &text ) -{ - drawText( painter, QRectF( x, y, w, h ), flags, text ); -} - -//! Wrapper for QPainter::drawText() -void QwtPainter::drawText( QPainter *painter, const QRectF &rect, - int flags, const QString &text ) -{ - painter->save(); - unscaleFont( painter ); - painter->drawText( rect, flags, text ); - painter->restore(); -} - -#ifndef QT_NO_RICHTEXT - -/*! - Draw a text document into a rectangle - - \param painter Painter - \param rect Traget rectangle - \param flags Alignments/Text flags, see QPainter::drawText() - \param text Text document -*/ -void QwtPainter::drawSimpleRichText( QPainter *painter, const QRectF &rect, - int flags, const QTextDocument &text ) -{ - QTextDocument *txt = text.clone(); - - painter->save(); - - painter->setFont( txt->defaultFont() ); - unscaleFont( painter ); - - txt->setDefaultFont( painter->font() ); - txt->setPageSize( QSizeF( rect.width(), QWIDGETSIZE_MAX ) ); - - QAbstractTextDocumentLayout* layout = txt->documentLayout(); - - const double height = layout->documentSize().height(); - double y = rect.y(); - if ( flags & Qt::AlignBottom ) - y += ( rect.height() - height ); - else if ( flags & Qt::AlignVCenter ) - y += ( rect.height() - height ) / 2; - - QAbstractTextDocumentLayout::PaintContext context; - context.palette.setColor( QPalette::Text, painter->pen().color() ); - - painter->translate( rect.x(), y ); - layout->draw( painter, context ); - - painter->restore(); - delete txt; -} - -#endif // !QT_NO_RICHTEXT - - -//! Wrapper for QPainter::drawLine() -void QwtPainter::drawLine( QPainter *painter, - const QPointF &p1, const QPointF &p2 ) -{ - QRectF clipRect; - const bool deviceClipping = isClippingNeeded( painter, clipRect ); - - if ( deviceClipping && - !( clipRect.contains( p1 ) && clipRect.contains( p2 ) ) ) - { - QPolygonF polygon; - polygon += p1; - polygon += p2; - drawPolyline( painter, polygon ); - return; - } - - painter->drawLine( p1, p2 ); -} - -//! Wrapper for QPainter::drawPolygon() -void QwtPainter::drawPolygon( QPainter *painter, const QPolygonF &polygon ) -{ - QRectF clipRect; - const bool deviceClipping = isClippingNeeded( painter, clipRect ); - - QPolygonF cpa = polygon; - if ( deviceClipping ) - cpa = QwtClipper::clipPolygonF( clipRect, polygon ); - - painter->drawPolygon( cpa ); -} - -//! Wrapper for QPainter::drawPolyline() -void QwtPainter::drawPolyline( QPainter *painter, const QPolygonF &polygon ) -{ - QRectF clipRect; - const bool deviceClipping = isClippingNeeded( painter, clipRect ); - - QPolygonF cpa = polygon; - if ( deviceClipping ) - cpa = QwtClipper::clipPolygonF( clipRect, cpa ); - - ::drawPolyline( painter, - cpa.constData(), cpa.size(), d_polylineSplitting ); -} - -//! Wrapper for QPainter::drawPolyline() -void QwtPainter::drawPolyline( QPainter *painter, - const QPointF *points, int pointCount ) -{ - QRectF clipRect; - const bool deviceClipping = isClippingNeeded( painter, clipRect ); - - if ( deviceClipping ) - { - QPolygonF polygon( pointCount ); - qMemCopy( polygon.data(), points, pointCount * sizeof( QPointF ) ); - - polygon = QwtClipper::clipPolygonF( clipRect, polygon ); - ::drawPolyline( painter, - polygon.constData(), polygon.size(), d_polylineSplitting ); - } - else - ::drawPolyline( painter, points, pointCount, d_polylineSplitting ); -} - -//! Wrapper for QPainter::drawPoint() -void QwtPainter::drawPoint( QPainter *painter, const QPointF &pos ) -{ - QRectF clipRect; - const bool deviceClipping = isClippingNeeded( painter, clipRect ); - - if ( deviceClipping && !clipRect.contains( pos ) ) - return; - - painter->drawPoint( pos ); -} - -//! Wrapper for QPainter::drawImage() -void QwtPainter::drawImage( QPainter *painter, - const QRectF &rect, const QImage &image ) -{ - const QRect alignedRect = rect.toAlignedRect(); - - if ( alignedRect != rect ) - { - const QRectF clipRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); - - painter->save(); - painter->setClipRect( clipRect, Qt::IntersectClip ); - painter->drawImage( alignedRect, image ); - painter->restore(); - } - else - { - painter->drawImage( alignedRect, image ); - } -} - -//! Wrapper for QPainter::drawPixmap() -void QwtPainter::drawPixmap( QPainter *painter, - const QRectF &rect, const QPixmap &pixmap ) -{ - const QRect alignedRect = rect.toAlignedRect(); - - if ( alignedRect != rect ) - { - const QRectF clipRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); - - painter->save(); - painter->setClipRect( clipRect, Qt::IntersectClip ); - painter->drawPixmap( alignedRect, pixmap ); - painter->restore(); - } - else - { - painter->drawPixmap( alignedRect, pixmap ); - } -} - -//! Draw a focus rectangle on a widget using its style. -void QwtPainter::drawFocusRect( QPainter *painter, QWidget *widget ) -{ - drawFocusRect( painter, widget, widget->rect() ); -} - -//! Draw a focus rectangle on a widget using its style. -void QwtPainter::drawFocusRect( QPainter *painter, QWidget *widget, - const QRect &rect ) -{ - QStyleOptionFocusRect opt; - opt.init( widget ); - opt.rect = rect; - opt.state |= QStyle::State_HasFocus; - - widget->style()->drawPrimitive( QStyle::PE_FrameFocusRect, - &opt, painter, widget ); -} - -/*! - Draw a frame with rounded borders - - \param painter Painter - \param rect Frame rectangle - \param xRadius x-radius of the ellipses defining the corners - \param yRadius y-radius of the ellipses defining the corners - \param palette QPalette::WindowText is used for plain borders - QPalette::Dark and QPalette::Light for raised - or sunken borders - \param lineWidth Line width - \param frameStyle bitwise OR´ed value of QFrame::Shape and QFrame::Shadow -*/ - -void QwtPainter::drawRoundedFrame( QPainter *painter, - const QRectF &rect, double xRadius, double yRadius, - const QPalette &palette, int lineWidth, int frameStyle ) -{ - painter->save(); - painter->setRenderHint( QPainter::Antialiasing, true ); - painter->setBrush( Qt::NoBrush ); - - double lw2 = lineWidth * 0.5; - QRectF r = rect.adjusted( lw2, lw2, -lw2, -lw2 ); - - QPainterPath path; - path.addRoundedRect( r, xRadius, yRadius ); - - enum Style - { - Plain, - Sunken, - Raised - }; - - Style style = Plain; - if ( (frameStyle & QFrame::Sunken) == QFrame::Sunken ) - style = Sunken; - else if ( (frameStyle & QFrame::Raised) == QFrame::Raised ) - style = Raised; - - if ( style != Plain && path.elementCount() == 17 ) - { - // move + 4 * ( cubicTo + lineTo ) - QPainterPath pathList[8]; - - for ( int i = 0; i < 4; i++ ) - { - const int j = i * 4 + 1; - - pathList[ 2 * i ].moveTo( - path.elementAt(j - 1).x, path.elementAt( j - 1 ).y - ); - - pathList[ 2 * i ].cubicTo( - path.elementAt(j + 0).x, path.elementAt(j + 0).y, - path.elementAt(j + 1).x, path.elementAt(j + 1).y, - path.elementAt(j + 2).x, path.elementAt(j + 2).y ); - - pathList[ 2 * i + 1 ].moveTo( - path.elementAt(j + 2).x, path.elementAt(j + 2).y - ); - pathList[ 2 * i + 1 ].lineTo( - path.elementAt(j + 3).x, path.elementAt(j + 3).y - ); - } - - QColor c1( palette.color( QPalette::Dark ) ); - QColor c2( palette.color( QPalette::Light ) ); - - if ( style == Raised ) - qSwap( c1, c2 ); - - for ( int i = 0; i < 4; i++ ) - { - QRectF r = pathList[2 * i].controlPointRect(); - - QPen arcPen; - arcPen.setWidth( lineWidth ); - - QPen linePen; - linePen.setWidth( lineWidth ); - - switch( i ) - { - case 0: - { - arcPen.setColor( c1 ); - linePen.setColor( c1 ); - break; - } - case 1: - { - QLinearGradient gradient; - gradient.setStart( r.topLeft() ); - gradient.setFinalStop( r.bottomRight() ); - gradient.setColorAt( 0.0, c1 ); - gradient.setColorAt( 1.0, c2 ); - - arcPen.setBrush( gradient ); - linePen.setColor( c2 ); - break; - } - case 2: - { - arcPen.setColor( c2 ); - linePen.setColor( c2 ); - break; - } - case 3: - { - QLinearGradient gradient; - - gradient.setStart( r.bottomRight() ); - gradient.setFinalStop( r.topLeft() ); - gradient.setColorAt( 0.0, c2 ); - gradient.setColorAt( 1.0, c1 ); - - arcPen.setBrush( gradient ); - linePen.setColor( c1 ); - break; - } - } - - - painter->setPen( arcPen ); - painter->drawPath( pathList[ 2 * i] ); - - painter->setPen( linePen ); - painter->drawPath( pathList[ 2 * i + 1] ); - } - } - else - { - QPen pen( palette.color( QPalette::WindowText ), lineWidth ); - painter->setPen( pen ); - painter->drawPath( path ); - } - - painter->restore(); -} - -/*! - Draw a color bar into a rectangle - - \param painter Painter - \param colorMap Color map - \param interval Value range - \param scaleMap Scale map - \param orientation Orientation - \param rect Traget rectangle -*/ -void QwtPainter::drawColorBar( QPainter *painter, - const QwtColorMap &colorMap, const QwtInterval &interval, - const QwtScaleMap &scaleMap, Qt::Orientation orientation, - const QRectF &rect ) -{ - QVector colorTable; - if ( colorMap.format() == QwtColorMap::Indexed ) - colorTable = colorMap.colorTable( interval ); - - QColor c; - - const QRect devRect = rect.toAlignedRect(); - - /* - We paint to a pixmap first to have something scalable for printing - ( f.e. in a Pdf document ) - */ - - QPixmap pixmap( devRect.size() ); - QPainter pmPainter( &pixmap ); - pmPainter.translate( -devRect.x(), -devRect.y() ); - - if ( orientation == Qt::Horizontal ) - { - QwtScaleMap sMap = scaleMap; - sMap.setPaintInterval( rect.left(), rect.right() ); - - for ( int x = devRect.left(); x <= devRect.right(); x++ ) - { - const double value = sMap.invTransform( x ); - - if ( colorMap.format() == QwtColorMap::RGB ) - c.setRgb( colorMap.rgb( interval, value ) ); - else - c = colorTable[colorMap.colorIndex( interval, value )]; - - pmPainter.setPen( c ); - pmPainter.drawLine( x, devRect.top(), x, devRect.bottom() ); - } - } - else // Vertical - { - QwtScaleMap sMap = scaleMap; - sMap.setPaintInterval( rect.bottom(), rect.top() ); - - for ( int y = devRect.top(); y <= devRect.bottom(); y++ ) - { - const double value = sMap.invTransform( y ); - - if ( colorMap.format() == QwtColorMap::RGB ) - c.setRgb( colorMap.rgb( interval, value ) ); - else - c = colorTable[colorMap.colorIndex( interval, value )]; - - pmPainter.setPen( c ); - pmPainter.drawLine( devRect.left(), y, devRect.right(), y ); - } - } - pmPainter.end(); - - drawPixmap( painter, rect, pixmap ); -} diff --git a/qwt/src/qwt_painter.h b/qwt/src/qwt_painter.h deleted file mode 100644 index 91a867d7b..000000000 --- a/qwt/src/qwt_painter.h +++ /dev/null @@ -1,149 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_PAINTER_H -#define QWT_PAINTER_H - -#include "qwt_global.h" - -#include -#include -#include -#include - -class QPainter; -class QBrush; -class QColor; -class QWidget; -class QPolygonF; -class QRectF; -class QImage; -class QPixmap; -class QwtScaleMap; -class QwtColorMap; -class QwtInterval; - -class QPalette; -class QTextDocument; -class QPainterPath; - -/*! - \brief A collection of QPainter workarounds -*/ -class QWT_EXPORT QwtPainter -{ -public: - static void setPolylineSplitting( bool ); - static bool polylineSplitting(); - - static void setRoundingAlignment( bool ); - static bool roundingAlignment(); - static bool roundingAlignment(QPainter *); - - static void drawText( QPainter *, double x, double y, const QString & ); - static void drawText( QPainter *, const QPointF &, const QString & ); - static void drawText( QPainter *, double x, double y, double w, double h, - int flags, const QString & ); - static void drawText( QPainter *, const QRectF &, - int flags, const QString & ); - -#ifndef QT_NO_RICHTEXT - static void drawSimpleRichText( QPainter *, const QRectF &, - int flags, const QTextDocument & ); -#endif - - static void drawRect( QPainter *, double x, double y, double w, double h ); - static void drawRect( QPainter *, const QRectF &rect ); - static void fillRect( QPainter *, const QRectF &, const QBrush & ); - - static void drawEllipse( QPainter *, const QRectF & ); - static void drawPie( QPainter *, const QRectF & r, int a, int alen ); - - static void drawLine( QPainter *, double x1, double y1, double x2, double y2 ); - static void drawLine( QPainter *, const QPointF &p1, const QPointF &p2 ); - static void drawLine( QPainter *, const QLineF & ); - - static void drawPolygon( QPainter *, const QPolygonF &pa ); - static void drawPolyline( QPainter *, const QPolygonF &pa ); - static void drawPolyline( QPainter *, const QPointF *, int pointCount ); - - static void drawPoint( QPainter *, double x, double y ); - static void drawPoint( QPainter *, const QPointF & ); - - static void drawPath( QPainter *, const QPainterPath & ); - static void drawImage( QPainter *, const QRectF &, const QImage & ); - static void drawPixmap( QPainter *, const QRectF &, const QPixmap & ); - - static void drawRoundedFrame( QPainter *, - const QRectF &, double xRadius, double yRadius, - const QPalette &, int lineWidth, int frameStyle ); - - static void drawFocusRect( QPainter *, QWidget * ); - static void drawFocusRect( QPainter *, QWidget *, const QRect & ); - - static void drawColorBar( QPainter *painter, - const QwtColorMap &, const QwtInterval &, - const QwtScaleMap &, Qt::Orientation, const QRectF & ); - - static bool isAligning( QPainter *painter ); - -private: - static bool d_polylineSplitting; - static bool d_roundingAlignment; -}; - -//! Wrapper for QPainter::drawPoint() -inline void QwtPainter::drawPoint( QPainter *painter, double x, double y ) -{ - QwtPainter::drawPoint( painter, QPointF( x, y ) ); -} - -//! Wrapper for QPainter::drawLine() -inline void QwtPainter::drawLine( QPainter *painter, - double x1, double y1, double x2, double y2 ) -{ - QwtPainter::drawLine( painter, QPointF( x1, y1 ), QPointF( x2, y2 ) ); -} - -//! Wrapper for QPainter::drawLine() -inline void QwtPainter::drawLine( QPainter *painter, const QLineF &line ) -{ - QwtPainter::drawLine( painter, line.p1(), line.p2() ); -} - -/*! - Returns whether line splitting for the raster paint engine is enabled. - \sa setPolylineSplitting() -*/ -inline bool QwtPainter::polylineSplitting() -{ - return d_polylineSplitting; -} - -/*! - Returns whether coordinates should be rounded, before they are painted - to a paint engine that floors to integer values. For other paint engines - this ( Pdf, SVG ), this flag has no effect. - - \sa setRoundingAlignment(), isAligning() -*/ -inline bool QwtPainter::roundingAlignment() -{ - return d_roundingAlignment; -} - -/*! - \return roundingAlignment() && isAligning(painter); - \param painter Painter -*/ -inline bool QwtPainter::roundingAlignment(QPainter *painter) -{ - return d_roundingAlignment && isAligning(painter); -} -#endif diff --git a/qwt/src/qwt_panner.cpp b/qwt/src/qwt_panner.cpp deleted file mode 100644 index 32768060d..000000000 --- a/qwt/src/qwt_panner.cpp +++ /dev/null @@ -1,534 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_panner.h" -#include "qwt_picker.h" -#include -#include -#include -#include -#include - -static QVector qwtActivePickers( QWidget *w ) -{ - QVector pickers; - - QObjectList children = w->children(); - for ( int i = 0; i < children.size(); i++ ) - { - QObject *obj = children[i]; - if ( obj->inherits( "QwtPicker" ) ) - { - QwtPicker *picker = ( QwtPicker * )obj; - if ( picker->isEnabled() ) - pickers += picker; - } - } - - return pickers; -} - -class QwtPanner::PrivateData -{ -public: - PrivateData(): - button( Qt::LeftButton ), - buttonState( Qt::NoButton ), - abortKey( Qt::Key_Escape ), - abortKeyState( Qt::NoButton ), -#ifndef QT_NO_CURSOR - cursor( NULL ), - restoreCursor( NULL ), - hasCursor( false ), -#endif - isEnabled( false ) - { - orientations = Qt::Vertical | Qt::Horizontal; - } - - ~PrivateData() - { -#ifndef QT_NO_CURSOR - delete cursor; - delete restoreCursor; -#endif - } - - int button; - int buttonState; - int abortKey; - int abortKeyState; - - QPoint initialPos; - QPoint pos; - - QPixmap pixmap; - QBitmap contentsMask; - -#ifndef QT_NO_CURSOR - QCursor *cursor; - QCursor *restoreCursor; - bool hasCursor; -#endif - bool isEnabled; - Qt::Orientations orientations; -}; - -/*! - Creates an panner that is enabled for the left mouse button. - - \param parent Parent widget to be panned -*/ -QwtPanner::QwtPanner( QWidget *parent ): - QWidget( parent ) -{ - d_data = new PrivateData(); - - setAttribute( Qt::WA_TransparentForMouseEvents ); - setAttribute( Qt::WA_NoSystemBackground ); - setFocusPolicy( Qt::NoFocus ); - hide(); - - setEnabled( true ); -} - -//! Destructor -QwtPanner::~QwtPanner() -{ - delete d_data; -} - -/*! - Change the mouse button - The defaults are Qt::LeftButton and Qt::NoButton -*/ -void QwtPanner::setMouseButton( int button, int buttonState ) -{ - d_data->button = button; - d_data->buttonState = buttonState; -} - -//! Get the mouse button -void QwtPanner::getMouseButton( int &button, int &buttonState ) const -{ - button = d_data->button; - buttonState = d_data->buttonState; -} - -/*! - Change the abort key - The defaults are Qt::Key_Escape and Qt::NoButton - - \param key Key ( See Qt::Keycode ) - \param state State -*/ -void QwtPanner::setAbortKey( int key, int state ) -{ - d_data->abortKey = key; - d_data->abortKeyState = state; -} - -//! Get the abort key -void QwtPanner::getAbortKey( int &key, int &state ) const -{ - key = d_data->abortKey; - state = d_data->abortKeyState; -} - -/*! - Change the cursor, that is active while panning - The default is the cursor of the parent widget. - - \param cursor New cursor - - \sa setCursor() -*/ -#ifndef QT_NO_CURSOR -void QwtPanner::setCursor( const QCursor &cursor ) -{ - d_data->cursor = new QCursor( cursor ); -} -#endif - -/*! - \return Cursor that is active while panning - \sa setCursor() -*/ -#ifndef QT_NO_CURSOR -const QCursor QwtPanner::cursor() const -{ - if ( d_data->cursor ) - return *d_data->cursor; - - if ( parentWidget() ) - return parentWidget()->cursor(); - - return QCursor(); -} -#endif - -/*! - \brief En/disable the panner - - When enabled is true an event filter is installed for - the observed widget, otherwise the event filter is removed. - - \param on true or false - \sa isEnabled(), eventFilter() -*/ -void QwtPanner::setEnabled( bool on ) -{ - if ( d_data->isEnabled != on ) - { - d_data->isEnabled = on; - - QWidget *w = parentWidget(); - if ( w ) - { - if ( d_data->isEnabled ) - { - w->installEventFilter( this ); - } - else - { - w->removeEventFilter( this ); - hide(); - } - } - } -} - -/*! - Set the orientations, where panning is enabled - The default value is in both directions: Qt::Horizontal | Qt::Vertical - - /param o Orientation -*/ -void QwtPanner::setOrientations( Qt::Orientations o ) -{ - d_data->orientations = o; -} - -//! Return the orientation, where paning is enabled -Qt::Orientations QwtPanner::orientations() const -{ - return d_data->orientations; -} - -/*! - Return true if a orientatio is enabled - \sa orientations(), setOrientations() -*/ -bool QwtPanner::isOrientationEnabled( Qt::Orientation o ) const -{ - return d_data->orientations & o; -} - -/*! - \return true when enabled, false otherwise - \sa setEnabled, eventFilter() -*/ -bool QwtPanner::isEnabled() const -{ - return d_data->isEnabled; -} - -/*! - \brief Paint event - - Repaint the grabbed pixmap on its current position and - fill the empty spaces by the background of the parent widget. - - \param pe Paint event -*/ -void QwtPanner::paintEvent( QPaintEvent *pe ) -{ - int dx = d_data->pos.x() - d_data->initialPos.x(); - int dy = d_data->pos.y() - d_data->initialPos.y(); - - QRect r( 0, 0, d_data->pixmap.width(), d_data->pixmap.height() ); - r.moveCenter( QPoint( r.center().x() + dx, r.center().y() + dy ) ); - - QPixmap pm( size() ); - pm.fill( parentWidget(), 0, 0 ); - - QPainter painter( &pm ); - - if ( !d_data->contentsMask.isNull() ) - { - QPixmap masked = d_data->pixmap; - masked.setMask( d_data->contentsMask ); - painter.drawPixmap( r, masked ); - } - else - { - painter.drawPixmap( r, d_data->pixmap ); - } - - painter.end(); - - if ( !d_data->contentsMask.isNull() ) - pm.setMask( d_data->contentsMask ); - - painter.begin( this ); - painter.setClipRegion( pe->region() ); - painter.drawPixmap( 0, 0, pm ); -} - -/*! - \brief Calculate a mask for the contents of the panned widget - - Sometimes only parts of the contents of a widget should be - panned. F.e. for a widget with a styled background with rounded borders - only the area inside of the border should be panned. - - \return An empty bitmap, indicating no mask -*/ -QBitmap QwtPanner::contentsMask() const -{ - return QBitmap(); -} - -/*! - Grab the widget into a pixmap. -*/ -QPixmap QwtPanner::grab() const -{ - return QPixmap::grabWidget( parentWidget() ); -} - -/*! - \brief Event filter - - When isEnabled() the mouse events of the observed widget are filtered. - - \param object Object to be filtered - \param event Event - - \sa widgetMousePressEvent(), widgetMouseReleaseEvent(), - widgetMouseMoveEvent() -*/ -bool QwtPanner::eventFilter( QObject *object, QEvent *event ) -{ - if ( object == NULL || object != parentWidget() ) - return false; - - switch ( event->type() ) - { - case QEvent::MouseButtonPress: - { - widgetMousePressEvent( ( QMouseEvent * )event ); - break; - } - case QEvent::MouseMove: - { - widgetMouseMoveEvent( ( QMouseEvent * )event ); - break; - } - case QEvent::MouseButtonRelease: - { - widgetMouseReleaseEvent( ( QMouseEvent * )event ); - break; - } - case QEvent::KeyPress: - { - widgetKeyPressEvent( ( QKeyEvent * )event ); - break; - } - case QEvent::KeyRelease: - { - widgetKeyReleaseEvent( ( QKeyEvent * )event ); - break; - } - case QEvent::Paint: - { - if ( isVisible() ) - return true; - break; - } - default:; - } - - return false; -} - -/*! - Handle a mouse press event for the observed widget. - - \param mouseEvent Mouse event - \sa eventFilter(), widgetMouseReleaseEvent(), - widgetMouseMoveEvent(), -*/ -void QwtPanner::widgetMousePressEvent( QMouseEvent *mouseEvent ) -{ - if ( mouseEvent->button() != d_data->button ) - return; - - QWidget *w = parentWidget(); - if ( w == NULL ) - return; - - if ( ( mouseEvent->modifiers() & Qt::KeyboardModifierMask ) != - ( int )( d_data->buttonState & Qt::KeyboardModifierMask ) ) - { - return; - } - -#ifndef QT_NO_CURSOR - showCursor( true ); -#endif - - d_data->initialPos = d_data->pos = mouseEvent->pos(); - - setGeometry( parentWidget()->rect() ); - - // We don't want to grab the picker ! - QVector pickers = qwtActivePickers( parentWidget() ); - for ( int i = 0; i < ( int )pickers.size(); i++ ) - pickers[i]->setEnabled( false ); - - d_data->pixmap = grab(); - d_data->contentsMask = contentsMask(); - - for ( int i = 0; i < ( int )pickers.size(); i++ ) - pickers[i]->setEnabled( true ); - - show(); -} - -/*! - Handle a mouse move event for the observed widget. - - \param mouseEvent Mouse event - \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent() -*/ -void QwtPanner::widgetMouseMoveEvent( QMouseEvent *mouseEvent ) -{ - if ( !isVisible() ) - return; - - QPoint pos = mouseEvent->pos(); - if ( !isOrientationEnabled( Qt::Horizontal ) ) - pos.setX( d_data->initialPos.x() ); - if ( !isOrientationEnabled( Qt::Vertical ) ) - pos.setY( d_data->initialPos.y() ); - - if ( pos != d_data->pos && rect().contains( pos ) ) - { - d_data->pos = pos; - update(); - - Q_EMIT moved( d_data->pos.x() - d_data->initialPos.x(), - d_data->pos.y() - d_data->initialPos.y() ); - } -} - -/*! - Handle a mouse release event for the observed widget. - - \param mouseEvent Mouse event - \sa eventFilter(), widgetMousePressEvent(), - widgetMouseMoveEvent(), -*/ -void QwtPanner::widgetMouseReleaseEvent( QMouseEvent *mouseEvent ) -{ - if ( isVisible() ) - { - hide(); -#ifndef QT_NO_CURSOR - showCursor( false ); -#endif - - QPoint pos = mouseEvent->pos(); - if ( !isOrientationEnabled( Qt::Horizontal ) ) - pos.setX( d_data->initialPos.x() ); - if ( !isOrientationEnabled( Qt::Vertical ) ) - pos.setY( d_data->initialPos.y() ); - - d_data->pixmap = QPixmap(); - d_data->contentsMask = QBitmap(); - d_data->pos = pos; - - if ( d_data->pos != d_data->initialPos ) - { - Q_EMIT panned( d_data->pos.x() - d_data->initialPos.x(), - d_data->pos.y() - d_data->initialPos.y() ); - } - } -} - -/*! - Handle a key press event for the observed widget. - - \param keyEvent Key event - \sa eventFilter(), widgetKeyReleaseEvent() -*/ -void QwtPanner::widgetKeyPressEvent( QKeyEvent *keyEvent ) -{ - if ( keyEvent->key() == d_data->abortKey ) - { - const bool matched = - ( keyEvent->modifiers() & Qt::KeyboardModifierMask ) == - ( int )( d_data->abortKeyState & Qt::KeyboardModifierMask ); - if ( matched ) - { - hide(); -#ifndef QT_NO_CURSOR - showCursor( false ); -#endif - d_data->pixmap = QPixmap(); - } - } -} - -/*! - Handle a key release event for the observed widget. - - \param keyEvent Key event - \sa eventFilter(), widgetKeyReleaseEvent() -*/ -void QwtPanner::widgetKeyReleaseEvent( QKeyEvent *keyEvent ) -{ - Q_UNUSED( keyEvent ); -} - -#ifndef QT_NO_CURSOR -void QwtPanner::showCursor( bool on ) -{ - if ( on == d_data->hasCursor ) - return; - - QWidget *w = parentWidget(); - if ( w == NULL || d_data->cursor == NULL ) - return; - - d_data->hasCursor = on; - - if ( on ) - { - if ( w->testAttribute( Qt::WA_SetCursor ) ) - { - delete d_data->restoreCursor; - d_data->restoreCursor = new QCursor( w->cursor() ); - } - w->setCursor( *d_data->cursor ); - } - else - { - if ( d_data->restoreCursor ) - { - w->setCursor( *d_data->restoreCursor ); - delete d_data->restoreCursor; - d_data->restoreCursor = NULL; - } - else - w->unsetCursor(); - } -} -#endif diff --git a/qwt/src/qwt_panner.h b/qwt/src/qwt_panner.h deleted file mode 100644 index 247d4a393..000000000 --- a/qwt/src/qwt_panner.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_PANNER_H -#define QWT_PANNER_H 1 - -#include "qwt_global.h" -#include -#include - -class QCursor; - -/*! - \brief QwtPanner provides panning of a widget - - QwtPanner grabs the contents of a widget, that can be dragged - in all directions. The offset between the start and the end position - is emitted by the panned signal. - - QwtPanner grabs the content of the widget into a pixmap and moves - the pixmap around, without initiating any repaint events for the widget. - Areas, that are not part of content are not painted while panning. - This makes panning fast enough for widgets, where - repaints are too slow for mouse movements. - - For widgets, where repaints are very fast it might be better to - implement panning manually by mapping mouse events into paint events. -*/ -class QWT_EXPORT QwtPanner: public QWidget -{ - Q_OBJECT - -public: - QwtPanner( QWidget* parent ); - virtual ~QwtPanner(); - - void setEnabled( bool ); - bool isEnabled() const; - - void setMouseButton( int button, int buttonState = Qt::NoButton ); - void getMouseButton( int &button, int &buttonState ) const; - void setAbortKey( int key, int state = Qt::NoButton ); - void getAbortKey( int &key, int &state ) const; - - void setCursor( const QCursor & ); - const QCursor cursor() const; - - void setOrientations( Qt::Orientations ); - Qt::Orientations orientations() const; - - bool isOrientationEnabled( Qt::Orientation ) const; - - virtual bool eventFilter( QObject *, QEvent * ); - -Q_SIGNALS: - /*! - Signal emitted, when panning is done - - \param dx Offset in horizontal direction - \param dy Offset in vertical direction - */ - void panned( int dx, int dy ); - - /*! - Signal emitted, while the widget moved, but panning - is not finished. - - \param dx Offset in horizontal direction - \param dy Offset in vertical direction - */ - void moved( int dx, int dy ); - -protected: - virtual void widgetMousePressEvent( QMouseEvent * ); - virtual void widgetMouseReleaseEvent( QMouseEvent * ); - virtual void widgetMouseMoveEvent( QMouseEvent * ); - virtual void widgetKeyPressEvent( QKeyEvent * ); - virtual void widgetKeyReleaseEvent( QKeyEvent * ); - - virtual void paintEvent( QPaintEvent * ); - - virtual QBitmap contentsMask() const; - virtual QPixmap grab() const; - -private: -#ifndef QT_NO_CURSOR - void showCursor( bool ); -#endif - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_picker.cpp b/qwt/src/qwt_picker.cpp deleted file mode 100644 index 8e1f1a11f..000000000 --- a/qwt/src/qwt_picker.cpp +++ /dev/null @@ -1,1433 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_picker.h" -#include "qwt_picker_machine.h" -#include "qwt_painter.h" -#include "qwt_math.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class QwtPicker::PickerWidget: public QWidget -{ -public: - enum Type - { - RubberBand, - Text - }; - - PickerWidget( QwtPicker *, QWidget *, Type ); - void updateMask(); - - /* - For a tracker text with a background we can use the background - rect as mask. Also for "regular" Qt widgets >= 4.3.0 we - don't need to mask the text anymore. - */ - bool d_hasTextMask; - -protected: - virtual void paintEvent( QPaintEvent * ); - - QwtPicker *d_picker; - Type d_type; -}; - -class QwtPicker::PrivateData -{ -public: - bool enabled; - - QwtPickerMachine *stateMachine; - - QwtPicker::ResizeMode resizeMode; - - QwtPicker::RubberBand rubberBand; - QPen rubberBandPen; - - QwtPicker::DisplayMode trackerMode; - QPen trackerPen; - QFont trackerFont; - - QPolygon pickedPoints; - bool isActive; - QPoint trackerPosition; - - bool mouseTracking; // used to save previous value - - /* - On X11 the widget below the picker widgets gets paint events - with a region that is the bounding rect of the mask, if it is complex. - In case of (f.e) a CrossRubberBand and a text this creates complete - repaints of the widget. So we better use two different widgets. - */ - - QPointer rubberBandWidget; - QPointer trackerWidget; -}; - -QwtPicker::PickerWidget::PickerWidget( - QwtPicker *picker, QWidget *parent, Type type ): - QWidget( parent ), - d_hasTextMask( false ), - d_picker( picker ), - d_type( type ) -{ - setAttribute( Qt::WA_TransparentForMouseEvents ); - setAttribute( Qt::WA_NoSystemBackground ); - setFocusPolicy( Qt::NoFocus ); -} - -void QwtPicker::PickerWidget::updateMask() -{ - QRegion mask; - - if ( d_type == RubberBand ) - { - QBitmap bm( width(), height() ); - bm.fill( Qt::color0 ); - - QPainter painter( &bm ); - QPen pen = d_picker->rubberBandPen(); - pen.setColor( Qt::color1 ); - painter.setPen( pen ); - - d_picker->drawRubberBand( &painter ); - - mask = QRegion( bm ); - } - if ( d_type == Text ) - { - d_hasTextMask = parentWidget()->testAttribute( Qt::WA_PaintOnScreen ); - - if ( d_hasTextMask ) - { - const QwtText label = d_picker->trackerText( - d_picker->trackerPosition() ); - - if ( label.testPaintAttribute( QwtText::PaintBackground ) - && label.backgroundBrush().style() != Qt::NoBrush ) - { - if ( label.backgroundBrush().color().alpha() > 0 ) - { - // We don't need a text mask, when we have a background - d_hasTextMask = false; - } - } - } - - if ( d_hasTextMask ) - { - QBitmap bm( width(), height() ); - bm.fill( Qt::color0 ); - - QPainter painter( &bm ); - painter.setFont( font() ); - - QPen pen = d_picker->trackerPen(); - pen.setColor( Qt::color1 ); - painter.setPen( pen ); - - d_picker->drawTracker( &painter ); - - mask = QRegion( bm ); - } - else - { - mask = d_picker->trackerRect( font() ); - } - } - - QWidget *w = parentWidget(); - if ( w && !w->testAttribute( Qt::WA_PaintOnScreen ) ) - { - // The parent widget gets an update for its complete rectangle - // when the mask is changed in visible state. - // With this hide/show we only get an update for the - // previous mask. - - hide(); - } - setMask( mask ); - setVisible( !mask.isEmpty() ); -} - -void QwtPicker::PickerWidget::paintEvent( QPaintEvent *e ) -{ - QPainter painter( this ); - painter.setClipRegion( e->region() ); - - if ( d_type == RubberBand ) - { - painter.setPen( d_picker->rubberBandPen() ); - d_picker->drawRubberBand( &painter ); - } - - if ( d_type == Text ) - { - /* - If we have a text mask we simply fill the region of - the mask. This gives better results for antialiased fonts. - */ - if ( d_hasTextMask ) - { - painter.fillRect( e->rect(), - QBrush( d_picker->trackerPen().color() ) ); - } - else - { - painter.setPen( d_picker->trackerPen() ); - d_picker->drawTracker( &painter ); - } - } -} - -/*! - Constructor - - Creates an picker that is enabled, but without a state machine. - rubberband and tracker are disabled. - - \param parent Parent widget, that will be observed - */ - -QwtPicker::QwtPicker( QWidget *parent ): - QObject( parent ) -{ - init( parent, NoRubberBand, AlwaysOff ); -} - -/*! - Constructor - - \param rubberBand Rubberband style - \param trackerMode Tracker mode - \param parent Parent widget, that will be observed - */ -QwtPicker::QwtPicker( RubberBand rubberBand, - DisplayMode trackerMode, QWidget *parent ): - QObject( parent ) -{ - init( parent, rubberBand, trackerMode ); -} - -//! Destructor -QwtPicker::~QwtPicker() -{ - setMouseTracking( false ); - delete d_data->stateMachine; - delete d_data->rubberBandWidget; - delete d_data->trackerWidget; - delete d_data; -} - -//! Init the picker, used by the constructors -void QwtPicker::init( QWidget *parent, - RubberBand rubberBand, DisplayMode trackerMode ) -{ - d_data = new PrivateData; - - d_data->rubberBandWidget = NULL; - d_data->trackerWidget = NULL; - - d_data->rubberBand = rubberBand; - d_data->enabled = false; - d_data->resizeMode = Stretch; - d_data->trackerMode = AlwaysOff; - d_data->isActive = false; - d_data->trackerPosition = QPoint( -1, -1 ); - d_data->mouseTracking = false; - - d_data->stateMachine = NULL; - - if ( parent ) - { - if ( parent->focusPolicy() == Qt::NoFocus ) - parent->setFocusPolicy( Qt::WheelFocus ); - - d_data->trackerFont = parent->font(); - d_data->mouseTracking = parent->hasMouseTracking(); - setEnabled( true ); - } - setTrackerMode( trackerMode ); -} - -/*! - Set a state machine and delete the previous one - - \param stateMachine State machine - \sa stateMachine() -*/ -void QwtPicker::setStateMachine( QwtPickerMachine *stateMachine ) -{ - if ( d_data->stateMachine != stateMachine ) - { - reset(); - - delete d_data->stateMachine; - d_data->stateMachine = stateMachine; - - if ( d_data->stateMachine ) - d_data->stateMachine->reset(); - } -} - -/*! - \return Assigned state machine - \sa setStateMachine() -*/ -QwtPickerMachine *QwtPicker::stateMachine() -{ - return d_data->stateMachine; -} - -/*! - \return Assigned state machine - \sa setStateMachine() -*/ -const QwtPickerMachine *QwtPicker::stateMachine() const -{ - return d_data->stateMachine; -} - -//! Return the parent widget, where the selection happens -QWidget *QwtPicker::parentWidget() -{ - QObject *obj = parent(); - if ( obj && obj->isWidgetType() ) - return static_cast( obj ); - - return NULL; -} - -//! Return the parent widget, where the selection happens -const QWidget *QwtPicker::parentWidget() const -{ - QObject *obj = parent(); - if ( obj && obj->isWidgetType() ) - return static_cast< const QWidget *>( obj ); - - return NULL; -} - -/*! - Set the rubberband style - - \param rubberBand Rubberband style - The default value is NoRubberBand. - - \sa rubberBand(), RubberBand, setRubberBandPen() -*/ -void QwtPicker::setRubberBand( RubberBand rubberBand ) -{ - d_data->rubberBand = rubberBand; -} - -/*! - \return Rubberband style - \sa setRubberBand(), RubberBand, rubberBandPen() -*/ -QwtPicker::RubberBand QwtPicker::rubberBand() const -{ - return d_data->rubberBand; -} - -/*! - \brief Set the display mode of the tracker. - - A tracker displays information about current position of - the cursor as a string. The display mode controls - if the tracker has to be displayed whenever the observed - widget has focus and cursor (AlwaysOn), never (AlwaysOff), or - only when the selection is active (ActiveOnly). - - \param mode Tracker display mode - - \warning In case of AlwaysOn, mouseTracking will be enabled - for the observed widget. - \sa trackerMode(), DisplayMode -*/ - -void QwtPicker::setTrackerMode( DisplayMode mode ) -{ - if ( d_data->trackerMode != mode ) - { - d_data->trackerMode = mode; - setMouseTracking( d_data->trackerMode == AlwaysOn ); - } -} - -/*! - \return Tracker display mode - \sa setTrackerMode(), DisplayMode -*/ -QwtPicker::DisplayMode QwtPicker::trackerMode() const -{ - return d_data->trackerMode; -} - -/*! - \brief Set the resize mode. - - The resize mode controls what to do with the selected points of an active - selection when the observed widget is resized. - - Stretch means the points are scaled according to the new - size, KeepSize means the points remain unchanged. - - The default mode is Stretch. - - \param mode Resize mode - \sa resizeMode(), ResizeMode -*/ -void QwtPicker::setResizeMode( ResizeMode mode ) -{ - d_data->resizeMode = mode; -} - -/*! - \return Resize mode - \sa setResizeMode(), ResizeMode -*/ - -QwtPicker::ResizeMode QwtPicker::resizeMode() const -{ - return d_data->resizeMode; -} - -/*! - \brief En/disable the picker - - When enabled is true an event filter is installed for - the observed widget, otherwise the event filter is removed. - - \param enabled true or false - \sa isEnabled(), eventFilter() -*/ -void QwtPicker::setEnabled( bool enabled ) -{ - if ( d_data->enabled != enabled ) - { - d_data->enabled = enabled; - - QWidget *w = parentWidget(); - if ( w ) - { - if ( enabled ) - w->installEventFilter( this ); - else - w->removeEventFilter( this ); - } - - updateDisplay(); - } -} - -/*! - \return true when enabled, false otherwise - \sa setEnabled(), eventFilter() -*/ - -bool QwtPicker::isEnabled() const -{ - return d_data->enabled; -} - -/*! - Set the font for the tracker - - \param font Tracker font - \sa trackerFont(), setTrackerMode(), setTrackerPen() -*/ -void QwtPicker::setTrackerFont( const QFont &font ) -{ - if ( font != d_data->trackerFont ) - { - d_data->trackerFont = font; - updateDisplay(); - } -} - -/*! - \return Tracker font - \sa setTrackerFont(), trackerMode(), trackerPen() -*/ - -QFont QwtPicker::trackerFont() const -{ - return d_data->trackerFont; -} - -/*! - Set the pen for the tracker - - \param pen Tracker pen - \sa trackerPen(), setTrackerMode(), setTrackerFont() -*/ -void QwtPicker::setTrackerPen( const QPen &pen ) -{ - if ( pen != d_data->trackerPen ) - { - d_data->trackerPen = pen; - updateDisplay(); - } -} - -/*! - \return Tracker pen - \sa setTrackerPen(), trackerMode(), trackerFont() -*/ -QPen QwtPicker::trackerPen() const -{ - return d_data->trackerPen; -} - -/*! - Set the pen for the rubberband - - \param pen Rubberband pen - \sa rubberBandPen(), setRubberBand() -*/ -void QwtPicker::setRubberBandPen( const QPen &pen ) -{ - if ( pen != d_data->rubberBandPen ) - { - d_data->rubberBandPen = pen; - updateDisplay(); - } -} - -/*! - \return Rubberband pen - \sa setRubberBandPen(), rubberBand() -*/ -QPen QwtPicker::rubberBandPen() const -{ - return d_data->rubberBandPen; -} - -/*! - \brief Return the label for a position - - In case of HLineRubberBand the label is the value of the - y position, in case of VLineRubberBand the value of the x position. - Otherwise the label contains x and y position separated by a ',' . - - The format for the string conversion is "%d". - - \param pos Position - \return Converted position as string -*/ - -QwtText QwtPicker::trackerText( const QPoint &pos ) const -{ - QString label; - - switch ( rubberBand() ) - { - case HLineRubberBand: - label.sprintf( "%d", pos.y() ); - break; - case VLineRubberBand: - label.sprintf( "%d", pos.x() ); - break; - default: - label.sprintf( "%d, %d", pos.x(), pos.y() ); - } - return label; -} - -/*! - Draw a rubberband, depending on rubberBand() - - \param painter Painter, initialized with clip rect - - \sa rubberBand(), RubberBand -*/ - -void QwtPicker::drawRubberBand( QPainter *painter ) const -{ - if ( !isActive() || rubberBand() == NoRubberBand || - rubberBandPen().style() == Qt::NoPen ) - { - return; - } - - const QRect &pRect = pickRect(); - const QPolygon pa = adjustedPoints( d_data->pickedPoints ); - - QwtPickerMachine::SelectionType selectionType = - QwtPickerMachine::NoSelection; - - if ( d_data->stateMachine ) - selectionType = d_data->stateMachine->selectionType(); - - switch ( selectionType ) - { - case QwtPickerMachine::NoSelection: - case QwtPickerMachine::PointSelection: - { - if ( pa.count() < 1 ) - return; - - const QPoint pos = pa[0]; - - switch ( rubberBand() ) - { - case VLineRubberBand: - QwtPainter::drawLine( painter, pos.x(), - pRect.top(), pos.x(), pRect.bottom() ); - break; - - case HLineRubberBand: - QwtPainter::drawLine( painter, pRect.left(), - pos.y(), pRect.right(), pos.y() ); - break; - - case CrossRubberBand: - QwtPainter::drawLine( painter, pos.x(), - pRect.top(), pos.x(), pRect.bottom() ); - QwtPainter::drawLine( painter, pRect.left(), - pos.y(), pRect.right(), pos.y() ); - break; - default: - break; - } - break; - } - case QwtPickerMachine::RectSelection: - { - if ( pa.count() < 2 ) - return; - - const QPoint p1 = pa[0]; - const QPoint p2 = pa[int( pa.count() - 1 )]; - - const QRect rect = QRect( p1, p2 ).normalized(); - switch ( rubberBand() ) - { - case EllipseRubberBand: - QwtPainter::drawEllipse( painter, rect ); - break; - case RectRubberBand: - QwtPainter::drawRect( painter, rect ); - break; - default: - break; - } - break; - } - case QwtPickerMachine::PolygonSelection: - { - if ( rubberBand() == PolygonRubberBand ) - painter->drawPolyline( pa ); - break; - } - default: - break; - } -} - -/*! - Draw the tracker - - \param painter Painter - \sa trackerRect(), trackerText() -*/ - -void QwtPicker::drawTracker( QPainter *painter ) const -{ - const QRect textRect = trackerRect( painter->font() ); - if ( !textRect.isEmpty() ) - { - const QwtText label = trackerText( d_data->trackerPosition ); - if ( !label.isEmpty() ) - label.draw( painter, textRect ); - } -} - -/*! - \brief Map the pickedPoints() into a selection() - - adjustedPoints() maps the points, that have been collected on - the parentWidget() into a selection(). The default implementation - simply returns the points unmodified. - - The reason, why a selection() differs from the picked points - depends on the application requirements. F.e. : - - - A rectangular selection might need to have a specific aspect ratio only.\n - - A selection could accept non intersecting polygons only.\n - - ...\n - - The example below is for a rectangular selection, where the first - point is the center of the selected rectangle. - \par Example - \verbatim QPolygon MyPicker::adjustedPoints(const QPolygon &points) const -{ - QPolygon adjusted; - if ( points.size() == 2 ) - { - const int width = qAbs(points[1].x() - points[0].x()); - const int height = qAbs(points[1].y() - points[0].y()); - - QRect rect(0, 0, 2 * width, 2 * height); - rect.moveCenter(points[0]); - - adjusted += rect.topLeft(); - adjusted += rect.bottomRight(); - } - return adjusted; -}\endverbatim\n -*/ -QPolygon QwtPicker::adjustedPoints( const QPolygon &points ) const -{ - return points; -} - -/*! - \return Selected points - \sa pickedPoints(), adjustedPoints() -*/ -QPolygon QwtPicker::selection() const -{ - return adjustedPoints( d_data->pickedPoints ); -} - -//! \return Current position of the tracker -QPoint QwtPicker::trackerPosition() const -{ - return d_data->trackerPosition; -} - -/*! - Calculate the bounding rectangle for the tracker text - from the current position of the tracker - - \param font Font of the tracker text - \return Bounding rectangle of the tracker text - - \sa trackerPosition() -*/ -QRect QwtPicker::trackerRect( const QFont &font ) const -{ - if ( trackerMode() == AlwaysOff || - ( trackerMode() == ActiveOnly && !isActive() ) ) - { - return QRect(); - } - - if ( d_data->trackerPosition.x() < 0 || d_data->trackerPosition.y() < 0 ) - return QRect(); - - QwtText text = trackerText( d_data->trackerPosition ); - if ( text.isEmpty() ) - return QRect(); - - const QSizeF textSize = text.textSize( font ); - QRect textRect( 0, 0, qCeil( textSize.width() ), qCeil( textSize.height() ) ); - - const QPoint &pos = d_data->trackerPosition; - - int alignment = 0; - if ( isActive() && d_data->pickedPoints.count() > 1 - && rubberBand() != NoRubberBand ) - { - const QPoint last = - d_data->pickedPoints[int( d_data->pickedPoints.count() ) - 2]; - - alignment |= ( pos.x() >= last.x() ) ? Qt::AlignRight : Qt::AlignLeft; - alignment |= ( pos.y() > last.y() ) ? Qt::AlignBottom : Qt::AlignTop; - } - else - alignment = Qt::AlignTop | Qt::AlignRight; - - const int margin = 5; - - int x = pos.x(); - if ( alignment & Qt::AlignLeft ) - x -= textRect.width() + margin; - else if ( alignment & Qt::AlignRight ) - x += margin; - - int y = pos.y(); - if ( alignment & Qt::AlignBottom ) - y += margin; - else if ( alignment & Qt::AlignTop ) - y -= textRect.height() + margin; - - textRect.moveTopLeft( QPoint( x, y ) ); - - int right = qMin( textRect.right(), pickRect().right() - margin ); - int bottom = qMin( textRect.bottom(), pickRect().bottom() - margin ); - textRect.moveBottomRight( QPoint( right, bottom ) ); - - int left = qMax( textRect.left(), pickRect().left() + margin ); - int top = qMax( textRect.top(), pickRect().top() + margin ); - textRect.moveTopLeft( QPoint( left, top ) ); - - return textRect; -} - -/*! - \brief Event filter - - When isEnabled() == true all events of the observed widget are filtered. - Mouse and keyboard events are translated into widgetMouse- and widgetKey- - and widgetWheel-events. Paint and Resize events are handled to keep - rubberband and tracker up to date. - - \param object Object to be filtered - \param event Event - - \sa widgetEnterEvent(), widgetLeaveEvent(), - widgetMousePressEvent(), widgetMouseReleaseEvent(), - widgetMouseDoubleClickEvent(), widgetMouseMoveEvent(), - widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent(), - QObject::installEventFilter(), QObject::event() -*/ -bool QwtPicker::eventFilter( QObject *object, QEvent *event ) -{ - if ( object && object == parentWidget() ) - { - switch ( event->type() ) - { - case QEvent::Resize: - { - const QResizeEvent *re = ( QResizeEvent * )event; - if ( d_data->resizeMode == Stretch ) - stretchSelection( re->oldSize(), re->size() ); - - if ( d_data->rubberBandWidget ) - d_data->rubberBandWidget->resize( re->size() ); - - if ( d_data->trackerWidget ) - d_data->trackerWidget->resize( re->size() ); - break; - } - case QEvent::Enter: - widgetEnterEvent( event ); - break; - case QEvent::Leave: - widgetLeaveEvent( event ); - break; - case QEvent::MouseButtonPress: - widgetMousePressEvent( ( QMouseEvent * )event ); - break; - case QEvent::MouseButtonRelease: - widgetMouseReleaseEvent( ( QMouseEvent * )event ); - break; - case QEvent::MouseButtonDblClick: - widgetMouseDoubleClickEvent( ( QMouseEvent * )event ); - break; - case QEvent::MouseMove: - widgetMouseMoveEvent( ( QMouseEvent * )event ); - break; - case QEvent::KeyPress: - widgetKeyPressEvent( ( QKeyEvent * )event ); - break; - case QEvent::KeyRelease: - widgetKeyReleaseEvent( ( QKeyEvent * )event ); - break; - case QEvent::Wheel: - widgetWheelEvent( ( QWheelEvent * )event ); - break; - default: - break; - } - } - return false; -} - -/*! - Handle a mouse press event for the observed widget. - - \param mouseEvent Mouse event - - \sa eventFilter(), widgetMouseReleaseEvent(), - widgetMouseDoubleClickEvent(), widgetMouseMoveEvent(), - widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent() -*/ -void QwtPicker::widgetMousePressEvent( QMouseEvent *mouseEvent ) -{ - transition( mouseEvent ); -} - -/*! - Handle a mouse move event for the observed widget. - - \param mouseEvent Mouse event - - \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent(), - widgetMouseDoubleClickEvent(), - widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent() -*/ -void QwtPicker::widgetMouseMoveEvent( QMouseEvent *mouseEvent ) -{ - if ( pickRect().contains( mouseEvent->pos() ) ) - d_data->trackerPosition = mouseEvent->pos(); - else - d_data->trackerPosition = QPoint( -1, -1 ); - - if ( !isActive() ) - updateDisplay(); - - transition( mouseEvent ); -} - -/*! - Handle a enter event for the observed widget. - - \param event Qt event - - \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent(), - widgetMouseDoubleClickEvent(), - widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent() -*/ -void QwtPicker::widgetEnterEvent( QEvent *event ) -{ - transition( event ); -} - -/*! - Handle a leave event for the observed widget. - - \param event Qt event - - \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent(), - widgetMouseDoubleClickEvent(), - widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent() -*/ -void QwtPicker::widgetLeaveEvent( QEvent *event ) -{ - transition( event ); - - d_data->trackerPosition = QPoint( -1, -1 ); - if ( !isActive() ) - updateDisplay(); -} - -/*! - Handle a mouse relase event for the observed widget. - - \param mouseEvent Mouse event - - \sa eventFilter(), widgetMousePressEvent(), - widgetMouseDoubleClickEvent(), widgetMouseMoveEvent(), - widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent() -*/ -void QwtPicker::widgetMouseReleaseEvent( QMouseEvent *mouseEvent ) -{ - transition( mouseEvent ); -} - -/*! - Handle mouse double click event for the observed widget. - - \param mouseEvent Mouse event - - \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent(), - widgetMouseMoveEvent(), - widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent() -*/ -void QwtPicker::widgetMouseDoubleClickEvent( QMouseEvent *mouseEvent ) -{ - transition( mouseEvent ); -} - - -/*! - Handle a wheel event for the observed widget. - - Move the last point of the selection in case of isActive() == true - - \param wheelEvent Wheel event - - \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent(), - widgetMouseDoubleClickEvent(), widgetMouseMoveEvent(), - widgetKeyPressEvent(), widgetKeyReleaseEvent() -*/ -void QwtPicker::widgetWheelEvent( QWheelEvent *wheelEvent ) -{ - if ( pickRect().contains( wheelEvent->pos() ) ) - d_data->trackerPosition = wheelEvent->pos(); - else - d_data->trackerPosition = QPoint( -1, -1 ); - - updateDisplay(); - - transition( wheelEvent ); -} - -/*! - Handle a key press event for the observed widget. - - Selections can be completely done by the keyboard. The arrow keys - move the cursor, the abort key aborts a selection. All other keys - are handled by the current state machine. - - \param keyEvent Key event - - \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent(), - widgetMouseDoubleClickEvent(), widgetMouseMoveEvent(), - widgetWheelEvent(), widgetKeyReleaseEvent(), stateMachine(), - QwtEventPattern::KeyPatternCode -*/ -void QwtPicker::widgetKeyPressEvent( QKeyEvent *keyEvent ) -{ - int dx = 0; - int dy = 0; - - int offset = 1; - if ( keyEvent->isAutoRepeat() ) - offset = 5; - - if ( keyMatch( KeyLeft, keyEvent ) ) - dx = -offset; - else if ( keyMatch( KeyRight, keyEvent ) ) - dx = offset; - else if ( keyMatch( KeyUp, keyEvent ) ) - dy = -offset; - else if ( keyMatch( KeyDown, keyEvent ) ) - dy = offset; - else if ( keyMatch( KeyAbort, keyEvent ) ) - { - reset(); - } - else - transition( keyEvent ); - - if ( dx != 0 || dy != 0 ) - { - const QRect rect = pickRect(); - const QPoint pos = parentWidget()->mapFromGlobal( QCursor::pos() ); - - int x = pos.x() + dx; - x = qMax( rect.left(), x ); - x = qMin( rect.right(), x ); - - int y = pos.y() + dy; - y = qMax( rect.top(), y ); - y = qMin( rect.bottom(), y ); - - QCursor::setPos( parentWidget()->mapToGlobal( QPoint( x, y ) ) ); - } -} - -/*! - Handle a key release event for the observed widget. - - Passes the event to the state machine. - - \param keyEvent Key event - - \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent(), - widgetMouseDoubleClickEvent(), widgetMouseMoveEvent(), - widgetWheelEvent(), widgetKeyPressEvent(), stateMachine() -*/ -void QwtPicker::widgetKeyReleaseEvent( QKeyEvent *keyEvent ) -{ - transition( keyEvent ); -} - -/*! - Passes an event to the state machine and executes the resulting - commands. Append and Move commands use the current position - of the cursor (QCursor::pos()). - - \param event Event -*/ -void QwtPicker::transition( const QEvent *event ) -{ - if ( !d_data->stateMachine ) - return; - - const QList commandList = - d_data->stateMachine->transition( *this, event ); - - QPoint pos; - switch ( event->type() ) - { - case QEvent::MouseButtonDblClick: - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - case QEvent::MouseMove: - { - const QMouseEvent *me = - static_cast< const QMouseEvent * >( event ); - pos = me->pos(); - break; - } - default: - pos = parentWidget()->mapFromGlobal( QCursor::pos() ); - } - - for ( int i = 0; i < commandList.count(); i++ ) - { - switch ( commandList[i] ) - { - case QwtPickerMachine::Begin: - { - begin(); - break; - } - case QwtPickerMachine::Append: - { - append( pos ); - break; - } - case QwtPickerMachine::Move: - { - move( pos ); - break; - } - case QwtPickerMachine::Remove: - { - remove(); - break; - } - case QwtPickerMachine::End: - { - end(); - break; - } - } - } -} - -/*! - Open a selection setting the state to active - - \sa isActive(), end(), append(), move() -*/ -void QwtPicker::begin() -{ - if ( d_data->isActive ) - return; - - d_data->pickedPoints.resize( 0 ); - d_data->isActive = true; - Q_EMIT activated( true ); - - if ( trackerMode() != AlwaysOff ) - { - if ( d_data->trackerPosition.x() < 0 || d_data->trackerPosition.y() < 0 ) - { - QWidget *w = parentWidget(); - if ( w ) - d_data->trackerPosition = w->mapFromGlobal( QCursor::pos() ); - } - } - - updateDisplay(); - setMouseTracking( true ); -} - -/*! - \brief Close a selection setting the state to inactive. - - The selection is validated and maybe fixed by accept(). - - \param ok If true, complete the selection and emit a selected signal - otherwise discard the selection. - \return true if the selection is accepted, false otherwise - \sa isActive(), begin(), append(), move(), selected(), accept() -*/ -bool QwtPicker::end( bool ok ) -{ - if ( d_data->isActive ) - { - setMouseTracking( false ); - - d_data->isActive = false; - Q_EMIT activated( false ); - - if ( trackerMode() == ActiveOnly ) - d_data->trackerPosition = QPoint( -1, -1 ); - - if ( ok ) - ok = accept( d_data->pickedPoints ); - - if ( ok ) - Q_EMIT selected( d_data->pickedPoints ); - else - d_data->pickedPoints.resize( 0 ); - - updateDisplay(); - } - else - ok = false; - - return ok; -} - -/*! - Reset the state machine and terminate (end(false)) the selection -*/ -void QwtPicker::reset() -{ - if ( d_data->stateMachine ) - d_data->stateMachine->reset(); - - if ( isActive() ) - end( false ); -} - -/*! - Append a point to the selection and update rubberband and tracker. - The appended() signal is emitted. - - \param pos Additional point - - \sa isActive(), begin(), end(), move(), appended() -*/ -void QwtPicker::append( const QPoint &pos ) -{ - if ( d_data->isActive ) - { - const int idx = d_data->pickedPoints.count(); - d_data->pickedPoints.resize( idx + 1 ); - d_data->pickedPoints[idx] = pos; - - updateDisplay(); - Q_EMIT appended( pos ); - } -} - -/*! - Move the last point of the selection - The moved() signal is emitted. - - \param pos New position - \sa isActive(), begin(), end(), append() -*/ -void QwtPicker::move( const QPoint &pos ) -{ - if ( d_data->isActive ) - { - const int idx = d_data->pickedPoints.count() - 1; - if ( idx >= 0 ) - { - if ( d_data->pickedPoints[idx] != pos ) - { - d_data->pickedPoints[idx] = pos; - - updateDisplay(); - Q_EMIT moved( pos ); - } - } - } -} - -/*! - Remove the last point of the selection - The removed() signal is emitted. - - \sa isActive(), begin(), end(), append(), move() -*/ -void QwtPicker::remove() -{ - if ( d_data->isActive ) - { - const int idx = d_data->pickedPoints.count() - 1; - if ( idx > 0 ) - { - const int idx = d_data->pickedPoints.count(); - - const QPoint pos = d_data->pickedPoints[idx - 1]; - d_data->pickedPoints.resize( idx - 1 ); - - updateDisplay(); - Q_EMIT removed( pos ); - } - } -} - -/*! - \brief Validate and fixup the selection - - Accepts all selections unmodified - - \param selection Selection to validate and fixup - \return true, when accepted, false otherwise -*/ -bool QwtPicker::accept( QPolygon &selection ) const -{ - Q_UNUSED( selection ); - return true; -} - -/*! - A picker is active between begin() and end(). - \return true if the selection is active. -*/ -bool QwtPicker::isActive() const -{ - return d_data->isActive; -} - -/*! - Return the points, that have been collected so far. The selection() - is calculated from the pickedPoints() in adjustedPoints(). - \return Picked points -*/ -const QPolygon &QwtPicker::pickedPoints() const -{ - return d_data->pickedPoints; -} - -/*! - Scale the selection by the ratios of oldSize and newSize - The changed() signal is emitted. - - \param oldSize Previous size - \param newSize Current size - - \sa ResizeMode, setResizeMode(), resizeMode() -*/ -void QwtPicker::stretchSelection( const QSize &oldSize, const QSize &newSize ) -{ - if ( oldSize.isEmpty() ) - { - // avoid division by zero. But scaling for small sizes also - // doesn't make much sense, because of rounding losses. TODO ... - return; - } - - const double xRatio = - double( newSize.width() ) / double( oldSize.width() ); - const double yRatio = - double( newSize.height() ) / double( oldSize.height() ); - - for ( int i = 0; i < int( d_data->pickedPoints.count() ); i++ ) - { - QPoint &p = d_data->pickedPoints[i]; - p.setX( qRound( p.x() * xRatio ) ); - p.setY( qRound( p.y() * yRatio ) ); - - Q_EMIT changed( d_data->pickedPoints ); - } -} - -/*! - Set mouse tracking for the observed widget. - - In case of enable is true, the previous value - is saved, that is restored when enable is false. - - \warning Even when enable is false, mouse tracking might be restored - to true. When mouseTracking for the observed widget - has been changed directly by QWidget::setMouseTracking - while mouse tracking has been set to true, this value can't - be restored. -*/ - -void QwtPicker::setMouseTracking( bool enable ) -{ - QWidget *widget = parentWidget(); - if ( !widget ) - return; - - if ( enable ) - { - d_data->mouseTracking = widget->hasMouseTracking(); - widget->setMouseTracking( true ); - } - else - { - widget->setMouseTracking( d_data->mouseTracking ); - } -} - -/*! - Find the area of the observed widget, where selection might happen. - - \return parentWidget()->contentsRect() -*/ -QRect QwtPicker::pickRect() const -{ - const QWidget *widget = parentWidget(); - if ( widget ) - return widget->contentsRect(); - - return QRect(); -} - -//! Update the state of rubberband and tracker label -void QwtPicker::updateDisplay() -{ - QWidget *w = parentWidget(); - - bool showRubberband = false; - bool showTracker = false; - if ( w && w->isVisible() && d_data->enabled ) - { - if ( rubberBand() != NoRubberBand && isActive() && - rubberBandPen().style() != Qt::NoPen ) - { - showRubberband = true; - } - - if ( trackerMode() == AlwaysOn || - ( trackerMode() == ActiveOnly && isActive() ) ) - { - if ( trackerPen() != Qt::NoPen ) - showTracker = true; - } - } - - QPointer &rw = d_data->rubberBandWidget; - if ( showRubberband ) - { - if ( rw.isNull() ) - { - rw = new PickerWidget( this, w, PickerWidget::RubberBand ); - rw->resize( w->size() ); - } - rw->updateMask(); - rw->update(); // Needed, when the mask doesn't change - } - else - delete rw; - - QPointer &tw = d_data->trackerWidget; - if ( showTracker ) - { - if ( tw.isNull() ) - { - tw = new PickerWidget( this, w, PickerWidget::Text ); - tw->resize( w->size() ); - } - tw->setFont( d_data->trackerFont ); - tw->updateMask(); - tw->update(); // Needed, when the mask doesn't change - } - else - delete tw; -} - -//! \return Widget displaying the rubberband -const QWidget *QwtPicker::rubberBandWidget() const -{ - return d_data->rubberBandWidget; -} - -//! \return Widget displaying the tracker text -const QWidget *QwtPicker::trackerWidget() const -{ - return d_data->trackerWidget; -} diff --git a/qwt/src/qwt_picker.h b/qwt/src/qwt_picker.h deleted file mode 100644 index c0b22dcdf..000000000 --- a/qwt/src/qwt_picker.h +++ /dev/null @@ -1,327 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_PICKER -#define QWT_PICKER 1 - -#include "qwt_global.h" -#include "qwt_text.h" -#include "qwt_event_pattern.h" -#include -#include -#include -#include - -class QWidget; -class QMouseEvent; -class QWheelEvent; -class QKeyEvent; -class QwtPickerMachine; - -/*! - \brief QwtPicker provides selections on a widget - - QwtPicker filters all enter, leave, mouse and keyboard events of a widget - and translates them into an array of selected points. - - The way how the points are collected depends on type of state machine - that is connected to the picker. Qwt offers a couple of predefined - state machines for selecting: - - - Nothing\n - QwtPickerTrackerMachine - - Single points\n - QwtPickerClickPointMachine, QwtPickerDragPointMachine - - Rectangles\n - QwtPickerClickRectMachine, QwtPickerDragRectMachine - - Polygons\n - QwtPickerPolygonMachine - - While these state machines cover the most common ways to collect points - it is also possible to implement individual machines as well. - - QwtPicker translates the picked points into a selection using the - adjustedPoints method. adjustedPoints is intended to be reimplemented - to fixup the selection according to application specific requirements. - (F.e. when an application accepts rectangles of a fixed aspect ratio only.) - - Optionally QwtPicker support the process of collecting points by a - rubberband and tracker displaying a text for the current mouse - position. - - \par Example - \verbatim #include -#include - -QwtPicker *picker = new QwtPicker(widget); -picker->setStateMachine(new QwtPickerDragRectMachine); -picker->setTrackerMode(QwtPicker::ActiveOnly); -picker->setRubberBand(QwtPicker::RectRubberBand); \endverbatim\n - - The state machine triggers the following commands: - - - begin()\n - Activate/Initialize the selection. - - append()\n - Add a new point - - move() \n - Change the position of the last point. - - remove()\n - Remove the last point. - - end()\n - Terminate the selection and call accept to validate the picked points. - - The picker is active (isActive()), between begin() and end(). - In active state the rubberband is displayed, and the tracker is visible - in case of trackerMode is ActiveOnly or AlwaysOn. - - The cursor can be moved using the arrow keys. All selections can be aborted - using the abort key. (QwtEventPattern::KeyPatternCode) - - \warning In case of QWidget::NoFocus the focus policy of the observed - widget is set to QWidget::WheelFocus and mouse tracking - will be manipulated while the picker is active, - or if trackerMode() is AlwayOn. -*/ - -class QWT_EXPORT QwtPicker: public QObject, public QwtEventPattern -{ - Q_OBJECT - - Q_ENUMS( RubberBand ) - Q_ENUMS( DisplayMode ) - Q_ENUMS( ResizeMode ) - - Q_PROPERTY( bool isEnabled READ isEnabled WRITE setEnabled ) - Q_PROPERTY( ResizeMode resizeMode READ resizeMode WRITE setResizeMode ) - - Q_PROPERTY( DisplayMode trackerMode READ trackerMode WRITE setTrackerMode ) - Q_PROPERTY( QPen trackerPen READ trackerPen WRITE setTrackerPen ) - Q_PROPERTY( QFont trackerFont READ trackerFont WRITE setTrackerFont ) - - Q_PROPERTY( RubberBand rubberBand READ rubberBand WRITE setRubberBand ) - Q_PROPERTY( QPen rubberBandPen READ rubberBandPen WRITE setRubberBandPen ) - -public: - /*! - Rubberband style - - The default value is QwtPicker::NoRubberBand. - \sa setRubberBand(), rubberBand() - */ - - enum RubberBand - { - //! No rubberband. - NoRubberBand = 0, - - //! A horizontal line ( only for QwtPicker::PointSelection ) - HLineRubberBand, - - //! A vertical line ( only for QwtPicker::PointSelection ) - VLineRubberBand, - - //! A crosshair ( only for QwtPicker::PointSelection ) - CrossRubberBand, - - //! A rectangle ( only for QwtPicker::RectSelection ) - RectRubberBand, - - //! An ellipse ( only for QwtPicker::RectSelection ) - EllipseRubberBand, - - //! A polygon ( only for QwtPicker::&PolygonSelection ) - PolygonRubberBand, - - /*! - Values >= UserRubberBand can be used to define additional - rubber bands. - */ - UserRubberBand = 100 - }; - - /*! - \brief Display mode - \sa setTrackerMode(), trackerMode(), isActive() - */ - enum DisplayMode - { - //! Display never - AlwaysOff, - - //! Display always - AlwaysOn, - - //! Display only when the selection is active - ActiveOnly - }; - - /*! - Controls what to do with the selected points of an active - selection when the observed widget is resized. - - The default value is QwtPicker::Stretch. - \sa setResizeMode() - */ - - enum ResizeMode - { - //! All points are scaled according to the new size, - Stretch, - - //! All points remain unchanged. - KeepSize - }; - - explicit QwtPicker( QWidget *parent ); - explicit QwtPicker( RubberBand rubberBand, - DisplayMode trackerMode, QWidget * ); - - virtual ~QwtPicker(); - - void setStateMachine( QwtPickerMachine * ); - const QwtPickerMachine *stateMachine() const; - QwtPickerMachine *stateMachine(); - - void setRubberBand( RubberBand ); - RubberBand rubberBand() const; - - void setTrackerMode( DisplayMode ); - DisplayMode trackerMode() const; - - void setResizeMode( ResizeMode ); - ResizeMode resizeMode() const; - - void setRubberBandPen( const QPen & ); - QPen rubberBandPen() const; - - void setTrackerPen( const QPen & ); - QPen trackerPen() const; - - void setTrackerFont( const QFont & ); - QFont trackerFont() const; - - bool isEnabled() const; - bool isActive() const; - - virtual bool eventFilter( QObject *, QEvent * ); - - QWidget *parentWidget(); - const QWidget *parentWidget() const; - - virtual QRect pickRect() const; - - virtual void drawRubberBand( QPainter * ) const; - virtual void drawTracker( QPainter * ) const; - - virtual QwtText trackerText( const QPoint &pos ) const; - QPoint trackerPosition() const; - virtual QRect trackerRect( const QFont & ) const; - - QPolygon selection() const; - -public Q_SLOTS: - void setEnabled( bool ); - -Q_SIGNALS: - /*! - A signal indicating, when the picker has been activated. - Together with setEnabled() it can be used to implement - selections with more than one picker. - - \param on True, when the picker has been activated - */ - void activated( bool on ); - - /*! - A signal emitting the selected points, - at the end of a selection. - - \param polygon Selected points - */ - void selected( const QPolygon &polygon ); - - /*! - A signal emitted when a point has been appended to the selection - - \param pos Position of the appended point. - \sa append(). moved() - */ - void appended( const QPoint &pos ); - - /*! - A signal emitted whenever the last appended point of the - selection has been moved. - - \param pos Position of the moved last point of the selection. - \sa move(), appended() - */ - void moved( const QPoint &pos ); - - /*! - A signal emitted whenever the last appended point of the - selection has been removed. - - \sa remove(), appended() - */ - void removed( const QPoint &pos ); - /*! - A signal emitted when the active selection has been changed. - This might happen when the observed widget is resized. - - \param selection Changed selection - \sa stretchSelection() - */ - void changed( const QPolygon &selection ); - -protected: - virtual QPolygon adjustedPoints( const QPolygon & ) const; - - virtual void transition( const QEvent * ); - - virtual void begin(); - virtual void append( const QPoint & ); - virtual void move( const QPoint & ); - virtual void remove(); - virtual bool end( bool ok = true ); - - virtual bool accept( QPolygon & ) const; - virtual void reset(); - - virtual void widgetMousePressEvent( QMouseEvent * ); - virtual void widgetMouseReleaseEvent( QMouseEvent * ); - virtual void widgetMouseDoubleClickEvent( QMouseEvent * ); - virtual void widgetMouseMoveEvent( QMouseEvent * ); - virtual void widgetWheelEvent( QWheelEvent * ); - virtual void widgetKeyPressEvent( QKeyEvent * ); - virtual void widgetKeyReleaseEvent( QKeyEvent * ); - virtual void widgetEnterEvent( QEvent * ); - virtual void widgetLeaveEvent( QEvent * ); - - virtual void stretchSelection( const QSize &oldSize, - const QSize &newSize ); - - virtual void updateDisplay(); - - const QWidget *rubberBandWidget() const; - const QWidget *trackerWidget() const; - - const QPolygon &pickedPoints() const; - -private: - void init( QWidget *, RubberBand rubberBand, DisplayMode trackerMode ); - - void setMouseTracking( bool ); - - class PickerWidget; - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_picker_machine.cpp b/qwt/src/qwt_picker_machine.cpp deleted file mode 100644 index 97d890ec1..000000000 --- a/qwt/src/qwt_picker_machine.cpp +++ /dev/null @@ -1,450 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_picker_machine.h" -#include "qwt_event_pattern.h" -#include - -//! Constructor -QwtPickerMachine::QwtPickerMachine( SelectionType type ): - d_selectionType( type ), - d_state( 0 ) -{ -} - -//! Destructor -QwtPickerMachine::~QwtPickerMachine() -{ -} - -//! Return the selection type -QwtPickerMachine::SelectionType QwtPickerMachine::selectionType() const -{ - return d_selectionType; -} - -//! Return the current state -int QwtPickerMachine::state() const -{ - return d_state; -} - -//! Change the current state -void QwtPickerMachine::setState( int state ) -{ - d_state = state; -} - -//! Set the current state to 0. -void QwtPickerMachine::reset() -{ - setState( 0 ); -} - -//! Constructor -QwtPickerTrackerMachine::QwtPickerTrackerMachine(): - QwtPickerMachine( NoSelection ) -{ -} - -//! Transition -QList QwtPickerTrackerMachine::transition( - const QwtEventPattern &, const QEvent *e ) -{ - QList cmdList; - - switch ( e->type() ) - { - case QEvent::Enter: - case QEvent::MouseMove: - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - setState( 1 ); - } - else - { - cmdList += Move; - } - break; - } - case QEvent::Leave: - { - cmdList += Remove; - cmdList += End; - setState( 0 ); - } - default: - break; - } - - return cmdList; -} - -//! Constructor -QwtPickerClickPointMachine::QwtPickerClickPointMachine(): - QwtPickerMachine( PointSelection ) -{ -} - -//! Transition -QList QwtPickerClickPointMachine::transition( - const QwtEventPattern &eventPattern, const QEvent *e ) -{ - QList cmdList; - - switch ( e->type() ) - { - case QEvent::MouseButtonPress: - { - if ( eventPattern.mouseMatch( - QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) ) - { - cmdList += Begin; - cmdList += Append; - cmdList += End; - } - break; - } - case QEvent::KeyPress: - { - if ( eventPattern.keyMatch( - QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) ) - { - cmdList += Begin; - cmdList += Append; - cmdList += End; - } - break; - } - default: - break; - } - - return cmdList; -} - -//! Constructor -QwtPickerDragPointMachine::QwtPickerDragPointMachine(): - QwtPickerMachine( PointSelection ) -{ -} - -//! Transition -QList QwtPickerDragPointMachine::transition( - const QwtEventPattern &eventPattern, const QEvent *e ) -{ - QList cmdList; - - switch ( e->type() ) - { - case QEvent::MouseButtonPress: - { - if ( eventPattern.mouseMatch( - QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - setState( 1 ); - } - } - break; - } - case QEvent::MouseMove: - case QEvent::Wheel: - { - if ( state() != 0 ) - cmdList += Move; - break; - } - case QEvent::MouseButtonRelease: - { - if ( state() != 0 ) - { - cmdList += End; - setState( 0 ); - } - break; - } - case QEvent::KeyPress: - { - if ( eventPattern.keyMatch( - QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - setState( 1 ); - } - else - { - cmdList += End; - setState( 0 ); - } - } - break; - } - default: - break; - } - - return cmdList; -} - -//! Constructor -QwtPickerClickRectMachine::QwtPickerClickRectMachine(): - QwtPickerMachine( RectSelection ) -{ -} - -//! Transition -QList QwtPickerClickRectMachine::transition( - const QwtEventPattern &eventPattern, const QEvent *e ) -{ - QList cmdList; - - switch ( e->type() ) - { - case QEvent::MouseButtonPress: - { - if ( eventPattern.mouseMatch( - QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) ) - { - switch ( state() ) - { - case 0: - { - cmdList += Begin; - cmdList += Append; - setState( 1 ); - break; - } - case 1: - { - // Uh, strange we missed the MouseButtonRelease - break; - } - default: - { - cmdList += End; - setState( 0 ); - } - } - } - } - case QEvent::MouseMove: - case QEvent::Wheel: - { - if ( state() != 0 ) - cmdList += Move; - break; - } - case QEvent::MouseButtonRelease: - { - if ( eventPattern.mouseMatch( - QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) ) - { - if ( state() == 1 ) - { - cmdList += Append; - setState( 2 ); - } - } - break; - } - case QEvent::KeyPress: - { - if ( eventPattern.keyMatch( - QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - setState( 1 ); - } - else - { - if ( state() == 1 ) - { - cmdList += Append; - setState( 2 ); - } - else if ( state() == 2 ) - { - cmdList += End; - setState( 0 ); - } - } - } - break; - } - default: - break; - } - - return cmdList; -} - -//! Constructor -QwtPickerDragRectMachine::QwtPickerDragRectMachine(): - QwtPickerMachine( RectSelection ) -{ -} - -//! Transition -QList QwtPickerDragRectMachine::transition( - const QwtEventPattern &eventPattern, const QEvent *e ) -{ - QList cmdList; - - switch ( e->type() ) - { - case QEvent::MouseButtonPress: - { - if ( eventPattern.mouseMatch( - QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - cmdList += Append; - setState( 2 ); - } - } - break; - } - case QEvent::MouseMove: - case QEvent::Wheel: - { - if ( state() != 0 ) - cmdList += Move; - break; - } - case QEvent::MouseButtonRelease: - { - if ( state() == 2 ) - { - cmdList += End; - setState( 0 ); - } - break; - } - case QEvent::KeyPress: - { - if ( eventPattern.keyMatch( - QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - cmdList += Append; - setState( 2 ); - } - else - { - cmdList += End; - setState( 0 ); - } - } - break; - } - default: - break; - } - - return cmdList; -} - -//! Constructor -QwtPickerPolygonMachine::QwtPickerPolygonMachine(): - QwtPickerMachine( PolygonSelection ) -{ -} - -//! Transition -QList QwtPickerPolygonMachine::transition( - const QwtEventPattern &eventPattern, const QEvent *e ) -{ - QList cmdList; - - switch ( e->type() ) - { - case QEvent::MouseButtonPress: - { - if ( eventPattern.mouseMatch( - QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - cmdList += Append; - setState( 1 ); - } - else - { - cmdList += End; - setState( 0 ); - } - } - if ( eventPattern.mouseMatch( - QwtEventPattern::MouseSelect2, ( const QMouseEvent * )e ) ) - { - if ( state() == 1 ) - cmdList += Append; - } - break; - } - case QEvent::MouseMove: - case QEvent::Wheel: - { - if ( state() != 0 ) - cmdList += Move; - break; - } - case QEvent::KeyPress: - { - if ( eventPattern.keyMatch( - QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) ) - { - if ( state() == 0 ) - { - cmdList += Begin; - cmdList += Append; - cmdList += Append; - setState( 1 ); - } - else - { - cmdList += End; - setState( 0 ); - } - } - else if ( eventPattern.keyMatch( - QwtEventPattern::KeySelect2, ( const QKeyEvent * )e ) ) - { - if ( state() == 1 ) - cmdList += Append; - } - break; - } - default: - break; - } - - return cmdList; -} diff --git a/qwt/src/qwt_picker_machine.h b/qwt/src/qwt_picker_machine.h deleted file mode 100644 index 8527115de..000000000 --- a/qwt/src/qwt_picker_machine.h +++ /dev/null @@ -1,190 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_PICKER_MACHINE -#define QWT_PICKER_MACHINE 1 - -#include "qwt_global.h" -#include - -class QEvent; -class QwtEventPattern; - -/*! - \brief A state machine for QwtPicker selections - - QwtPickerMachine accepts key and mouse events and translates them - into selection commands. - - \sa QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode -*/ - -class QWT_EXPORT QwtPickerMachine -{ -public: - /*! - Type of a selection. - \sa selectionType() - */ - enum SelectionType - { - //! The state machine not usable for any type of selection. - NoSelection = -1, - - //! The state machine is for selecting a single point. - PointSelection, - - //! The state machine is for selecting a rectangle (2 points). - RectSelection, - - //! The state machine is for selecting a polygon (many points). - PolygonSelection - }; - - //! Commands - the output of a state machine - enum Command - { - Begin, - Append, - Move, - Remove, - End - }; - - QwtPickerMachine( SelectionType ); - virtual ~QwtPickerMachine(); - - //! Transition - virtual QList transition( - const QwtEventPattern &, const QEvent * ) = 0; - void reset(); - - int state() const; - void setState( int ); - - SelectionType selectionType() const; - -private: - const SelectionType d_selectionType; - int d_state; -}; - -/*! - \brief A state machine for indicating mouse movements - - QwtPickerTrackerMachine supports displaying information - corresponding to mouse movements, but is not intended for - selecting anything. Begin/End are related to Enter/Leave events. -*/ -class QWT_EXPORT QwtPickerTrackerMachine: public QwtPickerMachine -{ -public: - QwtPickerTrackerMachine(); - - virtual QList transition( - const QwtEventPattern &, const QEvent * ); -}; - -/*! - \brief A state machine for point selections - - Pressing QwtEventPattern::MouseSelect1 or - QwtEventPattern::KeySelect1 selects a point. - - \sa QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode -*/ -class QWT_EXPORT QwtPickerClickPointMachine: public QwtPickerMachine -{ -public: - QwtPickerClickPointMachine(); - - virtual QList transition( - const QwtEventPattern &, const QEvent * ); -}; - -/*! - \brief A state machine for point selections - - Pressing QwtEventPattern::MouseSelect1 or QwtEventPattern::KeySelect1 - starts the selection, releasing QwtEventPattern::MouseSelect1 or - a second press of QwtEventPattern::KeySelect1 terminates it. -*/ -class QWT_EXPORT QwtPickerDragPointMachine: public QwtPickerMachine -{ -public: - QwtPickerDragPointMachine(); - - virtual QList transition( - const QwtEventPattern &, const QEvent * ); -}; - -/*! - \brief A state machine for rectangle selections - - Pressing QwtEventPattern::MouseSelect1 starts - the selection, releasing it selects the first point. Pressing it - again selects the second point and terminates the selection. - Pressing QwtEventPattern::KeySelect1 also starts the - selection, a second press selects the first point. A third one selects - the second point and terminates the selection. - - \sa QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode -*/ - -class QWT_EXPORT QwtPickerClickRectMachine: public QwtPickerMachine -{ -public: - QwtPickerClickRectMachine(); - - virtual QList transition( - const QwtEventPattern &, const QEvent * ); -}; - -/*! - \brief A state machine for rectangle selections - - Pressing QwtEventPattern::MouseSelect1 selects - the first point, releasing it the second point. - Pressing QwtEventPattern::KeySelect1 also selects the - first point, a second press selects the second point and terminates - the selection. - - \sa QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode -*/ - -class QWT_EXPORT QwtPickerDragRectMachine: public QwtPickerMachine -{ -public: - QwtPickerDragRectMachine(); - - virtual QList transition( - const QwtEventPattern &, const QEvent * ); -}; - -/*! - \brief A state machine for polygon selections - - Pressing QwtEventPattern::MouseSelect1 or QwtEventPattern::KeySelect1 - starts the selection and selects the first point, or appends a point. - Pressing QwtEventPattern::MouseSelect2 or QwtEventPattern::KeySelect2 - appends the last point and terminates the selection. - - \sa QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode -*/ - -class QWT_EXPORT QwtPickerPolygonMachine: public QwtPickerMachine -{ -public: - QwtPickerPolygonMachine(); - - virtual QList transition( - const QwtEventPattern &, const QEvent * ); -}; - -#endif diff --git a/qwt/src/qwt_plot.cpp b/qwt/src/qwt_plot.cpp deleted file mode 100644 index 467223f2f..000000000 --- a/qwt/src/qwt_plot.cpp +++ /dev/null @@ -1,773 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_plot.h" -#include "qwt_plot_dict.h" -#include "qwt_plot_layout.h" -#include "qwt_scale_widget.h" -#include "qwt_scale_engine.h" -#include "qwt_text_label.h" -#include "qwt_legend.h" -#include "qwt_dyngrid_layout.h" -#include "qwt_plot_canvas.h" -#include -#include -#include -#include -#include - -class QwtPlot::PrivateData -{ -public: - QPointer lblTitle; - QPointer canvas; - QPointer legend; - QwtPlotLayout *layout; - - bool autoReplot; -}; - -/*! - \brief Constructor - \param parent Parent widget - */ -QwtPlot::QwtPlot( QWidget *parent ): - QFrame( parent ) -{ - initPlot( QwtText() ); -} - -/*! - \brief Constructor - \param title Title text - \param parent Parent widget - */ -QwtPlot::QwtPlot( const QwtText &title, QWidget *parent ): - QFrame( parent ) -{ - initPlot( title ); -} - -//! Destructor -QwtPlot::~QwtPlot() -{ - detachItems( QwtPlotItem::Rtti_PlotItem, autoDelete() ); - - delete d_data->layout; - deleteAxesData(); - delete d_data; -} - -/*! - \brief Initializes a QwtPlot instance - \param title Title text - */ -void QwtPlot::initPlot( const QwtText &title ) -{ - d_data = new PrivateData; - - d_data->layout = new QwtPlotLayout; - d_data->autoReplot = false; - - d_data->lblTitle = new QwtTextLabel( title, this ); - d_data->lblTitle->setObjectName( "QwtPlotTitle" ); - - d_data->lblTitle->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) ); - - QwtText text( title ); - text.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap ); - d_data->lblTitle->setText( text ); - - d_data->legend = NULL; - - initAxesData(); - - d_data->canvas = new QwtPlotCanvas( this ); - d_data->canvas->setObjectName( "QwtPlotCanvas" ); - d_data->canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken ); - d_data->canvas->setLineWidth( 2 ); - - updateTabOrder(); - - setSizePolicy( QSizePolicy::MinimumExpanding, - QSizePolicy::MinimumExpanding ); - - resize( 200, 200 ); -} - -/*! - \brief Adds handling of layout requests - \param event Event -*/ -bool QwtPlot::event( QEvent *event ) -{ - bool ok = QFrame::event( event ); - switch ( event->type() ) - { - case QEvent::LayoutRequest: - updateLayout(); - break; - case QEvent::PolishRequest: - replot(); - break; - default:; - } - return ok; -} - -//! Replots the plot if autoReplot() is \c true. -void QwtPlot::autoRefresh() -{ - if ( d_data->autoReplot ) - replot(); -} - -/*! - \brief Set or reset the autoReplot option - - If the autoReplot option is set, the plot will be - updated implicitly by manipulating member functions. - Since this may be time-consuming, it is recommended - to leave this option switched off and call replot() - explicitly if necessary. - - The autoReplot option is set to false by default, which - means that the user has to call replot() in order to make - changes visible. - \param tf \c true or \c false. Defaults to \c true. - \sa replot() -*/ -void QwtPlot::setAutoReplot( bool tf ) -{ - d_data->autoReplot = tf; -} - -/*! - \return true if the autoReplot option is set. - \sa setAutoReplot() -*/ -bool QwtPlot::autoReplot() const -{ - return d_data->autoReplot; -} - -/*! - Change the plot's title - \param title New title -*/ -void QwtPlot::setTitle( const QString &title ) -{ - if ( title != d_data->lblTitle->text().text() ) - { - d_data->lblTitle->setText( title ); - updateLayout(); - } -} - -/*! - Change the plot's title - \param title New title -*/ -void QwtPlot::setTitle( const QwtText &title ) -{ - if ( title != d_data->lblTitle->text() ) - { - d_data->lblTitle->setText( title ); - updateLayout(); - } -} - -//! \return the plot's title -QwtText QwtPlot::title() const -{ - return d_data->lblTitle->text(); -} - -//! \return the plot's title -QwtPlotLayout *QwtPlot::plotLayout() -{ - return d_data->layout; -} - -//! \return the plot's titel label. -const QwtPlotLayout *QwtPlot::plotLayout() const -{ - return d_data->layout; -} - -//! \return the plot's titel label. -QwtTextLabel *QwtPlot::titleLabel() -{ - return d_data->lblTitle; -} - -/*! - \return the plot's titel label. -*/ -const QwtTextLabel *QwtPlot::titleLabel() const -{ - return d_data->lblTitle; -} - -/*! - \return the plot's legend - \sa insertLegend() -*/ -QwtLegend *QwtPlot::legend() -{ - return d_data->legend; -} - -/*! - \return the plot's legend - \sa insertLegend() -*/ -const QwtLegend *QwtPlot::legend() const -{ - return d_data->legend; -} - - -/*! - \return the plot's canvas -*/ -QwtPlotCanvas *QwtPlot::canvas() -{ - return d_data->canvas; -} - -/*! - \return the plot's canvas -*/ -const QwtPlotCanvas *QwtPlot::canvas() const -{ - return d_data->canvas; -} - -/*! - Return sizeHint - \sa minimumSizeHint() -*/ - -QSize QwtPlot::sizeHint() const -{ - int dw = 0; - int dh = 0; - for ( int axisId = 0; axisId < axisCnt; axisId++ ) - { - if ( axisEnabled( axisId ) ) - { - const int niceDist = 40; - const QwtScaleWidget *scaleWidget = axisWidget( axisId ); - const QwtScaleDiv &scaleDiv = scaleWidget->scaleDraw()->scaleDiv(); - const int majCnt = scaleDiv.ticks( QwtScaleDiv::MajorTick ).count(); - - if ( axisId == yLeft || axisId == yRight || - axisId == yLeft1 || axisId == yRight1 || - axisId == yLeft2 || axisId == yRight2 || - axisId == yLeft3 || axisId == yRight3 ) - { - int hDiff = ( majCnt - 1 ) * niceDist - - scaleWidget->minimumSizeHint().height(); - if ( hDiff > dh ) - dh = hDiff; - } - else - { - int wDiff = ( majCnt - 1 ) * niceDist - - scaleWidget->minimumSizeHint().width(); - if ( wDiff > dw ) - dw = wDiff; - } - } - } - return minimumSizeHint() + QSize( dw, dh ); -} - -/*! - \brief Return a minimum size hint -*/ -QSize QwtPlot::minimumSizeHint() const -{ - QSize hint = d_data->layout->minimumSizeHint( this ); - hint += QSize( 2 * frameWidth(), 2 * frameWidth() ); - - return hint; -} - -/*! - Resize and update internal layout - \param e Resize event -*/ -void QwtPlot::resizeEvent( QResizeEvent *e ) -{ - QFrame::resizeEvent( e ); - updateLayout(); -} - -/*! - \brief Redraw the plot - - If the autoReplot option is not set (which is the default) - or if any curves are attached to raw data, the plot has to - be refreshed explicitly in order to make changes visible. - - \sa setAutoReplot() - \warning Calls canvas()->repaint, take care of infinite recursions -*/ -void QwtPlot::replot() -{ - bool doAutoReplot = autoReplot(); - setAutoReplot( false ); - - updateAxes(); - - /* - Maybe the layout needs to be updated, because of changed - axes labels. We need to process them here before painting - to avoid that scales and canvas get out of sync. - */ - QApplication::sendPostedEvents( this, QEvent::LayoutRequest ); - - d_data->canvas->replot(); - - setAutoReplot( doAutoReplot ); -} - -/*! - \brief Adjust plot content to its current size. - \sa resizeEvent() -*/ -void QwtPlot::updateLayout() -{ - d_data->layout->activate( this, contentsRect() ); - - QRect titleRect = d_data->layout->titleRect().toRect(); - QRect scaleRect[QwtPlot::axisCnt]; - for ( int axisId = 0; axisId < axisCnt; axisId++ ) - scaleRect[axisId] = d_data->layout->scaleRect( axisId ).toRect(); - QRect legendRect = d_data->layout->legendRect().toRect(); - QRect canvasRect = d_data->layout->canvasRect().toRect(); - - // - // resize and show the visible widgets - // - if ( !d_data->lblTitle->text().isEmpty() ) - { - d_data->lblTitle->setGeometry( titleRect ); - if ( !d_data->lblTitle->isVisibleTo( this ) ) - d_data->lblTitle->show(); - } - else - d_data->lblTitle->hide(); - - for ( int axisId = 0; axisId < axisCnt; axisId++ ) - { - if ( axisEnabled( axisId ) ) - { - axisWidget( axisId )->setGeometry( scaleRect[axisId] ); - - if ( axisId == xBottom || axisId == xTop ) - { - QRegion r( scaleRect[axisId] ); - if ( axisEnabled( yLeft ) ) - r = r.subtract( QRegion( scaleRect[yLeft] ) ); - - if ( axisEnabled( yLeft1 ) ) - r = r.subtract( QRegion( scaleRect[yLeft1] ) ); - if ( axisEnabled( yLeft2 ) ) - r = r.subtract( QRegion( scaleRect[yLeft2] ) ); - if ( axisEnabled( yLeft3 ) ) - r = r.subtract( QRegion( scaleRect[yLeft3] ) ); - - if ( axisEnabled( yRight ) ) - r = r.subtract( QRegion( scaleRect[yRight] ) ); - - if ( axisEnabled( yRight1 ) ) - r = r.subtract( QRegion( scaleRect[yRight1] ) ); - if ( axisEnabled( yRight2 ) ) - r = r.subtract( QRegion( scaleRect[yRight2] ) ); - if ( axisEnabled( yRight3 ) ) - r = r.subtract( QRegion( scaleRect[yRight3] ) ); - - r.translate( -d_data->layout->scaleRect( axisId ).x(), - -scaleRect[axisId].y() ); - - axisWidget( axisId )->setMask( r ); - } - if ( !axisWidget( axisId )->isVisibleTo( this ) ) - axisWidget( axisId )->show(); - } - else - axisWidget( axisId )->hide(); - } - - if ( d_data->legend && - d_data->layout->legendPosition() != ExternalLegend ) - { - if ( d_data->legend->itemCount() > 0 ) - { - d_data->legend->setGeometry( legendRect ); - d_data->legend->show(); - } - else - d_data->legend->hide(); - } - - d_data->canvas->setGeometry( canvasRect ); -} - -/*! - Update the focus tab order - - The order is changed so that the canvas will be in front of the - first legend item, or behind the last legend item - depending - on the position of the legend. -*/ - -void QwtPlot::updateTabOrder() -{ - if ( d_data->canvas->focusPolicy() == Qt::NoFocus ) - return; - if ( d_data->legend.isNull() - || d_data->layout->legendPosition() == ExternalLegend - || d_data->legend->legendItems().count() == 0 ) - { - return; - } - - // Depending on the position of the legend the - // tab order will be changed that the canvas is - // next to the last legend item, or before - // the first one. - - const bool canvasFirst = - d_data->layout->legendPosition() == QwtPlot::BottomLegend || - d_data->layout->legendPosition() == QwtPlot::RightLegend; - - QWidget *previous = NULL; - - QWidget *w = d_data->canvas; - while ( ( w = w->nextInFocusChain() ) != d_data->canvas ) - { - bool isLegendItem = false; - if ( w->focusPolicy() != Qt::NoFocus - && w->parent() && w->parent() == d_data->legend->contentsWidget() ) - { - isLegendItem = true; - } - - if ( canvasFirst ) - { - if ( isLegendItem ) - break; - - previous = w; - } - else - { - if ( isLegendItem ) - previous = w; - else - { - if ( previous ) - break; - } - } - } - - if ( previous && previous != d_data->canvas ) - setTabOrder( previous, d_data->canvas ); -} - -/*! - Redraw the canvas. - \param painter Painter used for drawing - - \warning drawCanvas calls drawItems what is also used - for printing. Applications that like to add individual - plot items better overload drawItems() - \sa drawItems() -*/ -void QwtPlot::drawCanvas( QPainter *painter ) -{ - QwtScaleMap maps[axisCnt]; - for ( int axisId = 0; axisId < axisCnt; axisId++ ) - maps[axisId] = canvasMap( axisId ); - - drawItems( painter, d_data->canvas->contentsRect(), maps ); -} - -/*! - Redraw the canvas items. - \param painter Painter used for drawing - \param canvasRect Bounding rectangle where to paint - \param map QwtPlot::axisCnt maps, mapping between plot and paint device coordinates -*/ - -void QwtPlot::drawItems( QPainter *painter, const QRectF &canvasRect, - const QwtScaleMap map[axisCnt] ) const -{ - const QwtPlotItemList& itmList = itemList(); - for ( QwtPlotItemIterator it = itmList.begin(); - it != itmList.end(); ++it ) - { - QwtPlotItem *item = *it; - if ( item && item->isVisible() ) - { - painter->save(); - - painter->setRenderHint( QPainter::Antialiasing, - item->testRenderHint( QwtPlotItem::RenderAntialiased ) ); - - item->draw( painter, - map[item->xAxis()], map[item->yAxis()], - canvasRect ); - - painter->restore(); - } - } -} - -/*! - \param axisId Axis - \return Map for the axis on the canvas. With this map pixel coordinates can - translated to plot coordinates and vice versa. - \sa QwtScaleMap, transform(), invTransform() - -*/ -QwtScaleMap QwtPlot::canvasMap( int axisId ) const -{ - QwtScaleMap map; - if ( !d_data->canvas ) - return map; - - map.setTransformation( axisScaleEngine( axisId )->transformation() ); - - const QwtScaleDiv *sd = axisScaleDiv( axisId ); - map.setScaleInterval( sd->lowerBound(), sd->upperBound() ); - - if ( axisEnabled( axisId ) ) - { - const QwtScaleWidget *s = axisWidget( axisId ); - if ( axisId == yLeft || axisId == yRight || - axisId == yLeft1 || axisId == yRight1 || - axisId == yLeft2 || axisId == yRight2 || - axisId == yLeft3 || axisId == yRight3 ) - { - double y = s->y() + s->startBorderDist() - d_data->canvas->y(); - double h = s->height() - s->startBorderDist() - s->endBorderDist(); - map.setPaintInterval( y + h, y ); - } - else - { - double x = s->x() + s->startBorderDist() - d_data->canvas->x(); - double w = s->width() - s->startBorderDist() - s->endBorderDist(); - map.setPaintInterval( x, x + w ); - } - } - else - { - int margin = 0; - if ( !plotLayout()->alignCanvasToScales() ) - margin = plotLayout()->canvasMargin( axisId ); - - const QRect &canvasRect = d_data->canvas->contentsRect(); - if ( axisId == yLeft || axisId == yRight || - axisId == yLeft1 || axisId == yRight1 || - axisId == yLeft2 || axisId == yRight2 || - axisId == yLeft3 || axisId == yRight3 ) - { - map.setPaintInterval( canvasRect.bottom() - margin, - canvasRect.top() + margin ); - } - else - { - map.setPaintInterval( canvasRect.left() + margin, - canvasRect.right() - margin ); - } - } - return map; -} - -/*! - \brief Change the background of the plotting area - - Sets brush to QPalette::Window of all colorgroups of - the palette of the canvas. Using canvas()->setPalette() - is a more powerful way to set these colors. - - \param brush New background brush - \sa canvasBackground() -*/ -void QwtPlot::setCanvasBackground( const QBrush &brush ) -{ - QPalette pal = d_data->canvas->palette(); - - for ( int i = 0; i < QPalette::NColorGroups; i++ ) - pal.setBrush( ( QPalette::ColorGroup )i, QPalette::Window, brush ); - - canvas()->setPalette( pal ); -} - -/*! - Nothing else than: canvas()->palette().brush( - QPalette::Normal, QPalette::Window); - - \return Background brush of the plotting area. - \sa setCanvasBackground() -*/ -QBrush QwtPlot::canvasBackground() const -{ - return canvas()->palette().brush( - QPalette::Normal, QPalette::Window ); -} - -/*! - \brief Change the border width of the plotting area - - Nothing else than canvas()->setLineWidth(w), - left for compatibility only. - - \param width New border width -*/ -void QwtPlot::setCanvasLineWidth( int width ) -{ - canvas()->setLineWidth( width ); - updateLayout(); -} - -/*! - Nothing else than: canvas()->lineWidth(), - left for compatibility only. - - \return the border width of the plotting area -*/ -int QwtPlot::canvasLineWidth() const -{ - return canvas()->lineWidth(); -} - -/*! - \return \c true if the specified axis exists, otherwise \c false - \param axisId axis index - */ -bool QwtPlot::axisValid( int axisId ) -{ - return ( ( axisId >= QwtPlot::yLeft ) && ( axisId < QwtPlot::axisCnt ) ); -} - -/*! - Called internally when the legend has been clicked on. - Emits a legendClicked() signal. -*/ -void QwtPlot::legendItemClicked() -{ - if ( d_data->legend && sender()->isWidgetType() ) - { - QwtPlotItem *plotItem = - ( QwtPlotItem* )d_data->legend->find( ( QWidget * )sender() ); - if ( plotItem ) - Q_EMIT legendClicked( plotItem ); - } -} - -/*! - Called internally when the legend has been checked - Emits a legendClicked() signal. -*/ -void QwtPlot::legendItemChecked( bool on ) -{ - if ( d_data->legend && sender()->isWidgetType() ) - { - QwtPlotItem *plotItem = - ( QwtPlotItem* )d_data->legend->find( ( QWidget * )sender() ); - if ( plotItem ) - Q_EMIT legendChecked( plotItem, on ); - } -} - -/*! - \brief Insert a legend - - If the position legend is \c QwtPlot::LeftLegend or \c QwtPlot::RightLegend - the legend will be organized in one column from top to down. - Otherwise the legend items will be placed in a table - with a best fit number of columns from left to right. - - If pos != QwtPlot::ExternalLegend the plot widget will become - parent of the legend. It will be deleted when the plot is deleted, - or another legend is set with insertLegend(). - - \param legend Legend - \param pos The legend's position. For top/left position the number - of colums will be limited to 1, otherwise it will be set to - unlimited. - - \param ratio Ratio between legend and the bounding rect - of title, canvas and axes. The legend will be shrinked - if it would need more space than the given ratio. - The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0 - it will be reset to the default ratio. - The default vertical/horizontal ratio is 0.33/0.5. - - \sa legend(), QwtPlotLayout::legendPosition(), - QwtPlotLayout::setLegendPosition() -*/ -void QwtPlot::insertLegend( QwtLegend *legend, - QwtPlot::LegendPosition pos, double ratio ) -{ - d_data->layout->setLegendPosition( pos, ratio ); - - if ( legend != d_data->legend ) - { - if ( d_data->legend && d_data->legend->parent() == this ) - delete d_data->legend; - - d_data->legend = legend; - - if ( d_data->legend ) - { - if ( pos != ExternalLegend ) - { - if ( d_data->legend->parent() != this ) - d_data->legend->setParent( this ); - } - - const QwtPlotItemList& itmList = itemList(); - for ( QwtPlotItemIterator it = itmList.begin(); - it != itmList.end(); ++it ) - { - ( *it )->updateLegend( d_data->legend ); - } - - QwtDynGridLayout *tl = qobject_cast( - d_data->legend->contentsWidget()->layout() ); - if ( tl ) - { - switch ( d_data->layout->legendPosition() ) - { - case LeftLegend: - case RightLegend: - tl->setMaxCols( 1 ); // 1 column: align vertical - break; - case TopLegend: - case BottomLegend: - tl->setMaxCols( 0 ); // unlimited - break; - case ExternalLegend: - break; - } - } - } - updateTabOrder(); - } - - updateLayout(); -} diff --git a/qwt/src/qwt_plot.h b/qwt/src/qwt_plot.h deleted file mode 100644 index 211a8b00e..000000000 --- a/qwt/src/qwt_plot.h +++ /dev/null @@ -1,298 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_PLOT_H -#define QWT_PLOT_H - -#include "qwt_global.h" -#include "qwt_text.h" -#include "qwt_plot_dict.h" -#include "qwt_scale_map.h" -#include "qwt_interval.h" -#include - -class QwtPlotLayout; -class QwtLegend; -class QwtScaleWidget; -class QwtScaleEngine; -class QwtScaleDiv; -class QwtScaleDraw; -class QwtTextLabel; -class QwtPlotCanvas; - -/*! - \brief A 2-D plotting widget - - QwtPlot is a widget for plotting two-dimensional graphs. - An unlimited number of plot items can be displayed on - its canvas. Plot items might be curves (QwtPlotCurve), markers - (QwtPlotMarker), the grid (QwtPlotGrid), or anything else derived - from QwtPlotItem. - A plot can have up to four axes, with each plot item attached to an x- and - a y axis. The scales at the axes can be explicitely set (QwtScaleDiv), or - are calculated from the plot items, using algorithms (QwtScaleEngine) which - can be configured separately for each axis. - - \image html plot.png - - \par Example - The following example shows (schematically) the most simple - way to use QwtPlot. By default, only the left and bottom axes are - visible and their scales are computed automatically. - \verbatim -#include -#include - -QwtPlot *myPlot = new QwtPlot("Two Curves", parent); - -// add curves -QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1"); -QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2"); - -// copy the data into the curves -curve1->setData(...); -curve2->setData(...); - -curve1->attach(myPlot); -curve2->attach(myPlot); - -// finally, refresh the plot -myPlot->replot(); -\endverbatim -*/ - -class QWT_EXPORT QwtPlot: public QFrame, public QwtPlotDict -{ - Q_OBJECT - Q_PROPERTY( QString propertiesDocument - READ grabProperties WRITE applyProperties ) - -public: - //! \brief Axis index - enum Axis - { - //! Y axis left of the canvas - yLeft, - - yLeft1, - yLeft2, - yLeft3, - - //! Y axis right of the canvas - yRight, - - yRight1, - yRight2, - yRight3, - - //! X axis below the canvas - xBottom, - - //! X axis above the canvas - xTop, - - //! Number of axes - axisCnt - }; - - /*! - Position of the legend, relative to the canvas. - - \sa insertLegend() - \note In case of ExternalLegend, the legend is not - handled by QwtPlotRenderer - */ - enum LegendPosition - { - //! The legend will be left from the QwtPlot::yLeft axis. - LeftLegend, - - //! The legend will be right from the QwtPlot::yRight axis. - RightLegend, - - //! The legend will be below QwtPlot::xBottom axis. - BottomLegend, - - //! The legend will be between QwtPlot::xTop axis and the title. - TopLegend, - - /*! - External means that only the content of the legend - will be handled by QwtPlot, but not its geometry. - This type can be used to have a legend in an - external window ( or on the canvas ). - */ - ExternalLegend - }; - - explicit QwtPlot( QWidget * = NULL ); - explicit QwtPlot( const QwtText &title, QWidget *p = NULL ); - - virtual ~QwtPlot(); - - void applyProperties( const QString & ); - QString grabProperties() const; - - void setAutoReplot( bool tf = true ); - bool autoReplot() const; - - // Layout - - QwtPlotLayout *plotLayout(); - const QwtPlotLayout *plotLayout() const; - - // Title - - void setTitle( const QString & ); - void setTitle( const QwtText &t ); - QwtText title() const; - - QwtTextLabel *titleLabel(); - const QwtTextLabel *titleLabel() const; - - // Canvas - - QwtPlotCanvas *canvas(); - const QwtPlotCanvas *canvas() const; - - void setCanvasBackground( const QBrush & ); - QBrush canvasBackground() const; - - void setCanvasLineWidth( int w ); - int canvasLineWidth() const; - - virtual QwtScaleMap canvasMap( int axisId ) const; - - double invTransform( int axisId, int pos ) const; - double transform( int axisId, double value ) const; - - // Axes - - QwtScaleEngine *axisScaleEngine( int axisId ); - const QwtScaleEngine *axisScaleEngine( int axisId ) const; - void setAxisScaleEngine( int axisId, QwtScaleEngine * ); - - void setAxisAutoScale( int axisId, bool on = true ); - bool axisAutoScale( int axisId ) const; - - void enableAxis( int axisId, bool tf = true ); - bool axisEnabled( int axisId ) const; - - void setAxisFont( int axisId, const QFont &f ); - QFont axisFont( int axisId ) const; - - void setAxisScale( int axisId, double min, double max, double step = 0 ); - void setAxisScaleDiv( int axisId, const QwtScaleDiv & ); - void setAxisScaleDraw( int axisId, QwtScaleDraw * ); - - double axisStepSize( int axisId ) const; - QwtInterval axisInterval( int axisId ) const; - - const QwtScaleDiv *axisScaleDiv( int axisId ) const; - QwtScaleDiv *axisScaleDiv( int axisId ); - - const QwtScaleDraw *axisScaleDraw( int axisId ) const; - QwtScaleDraw *axisScaleDraw( int axisId ); - - const QwtScaleWidget *axisWidget( int axisId ) const; - QwtScaleWidget *axisWidget( int axisId ); - - void setAxisLabelAlignment( int axisId, Qt::Alignment ); - void setAxisLabelRotation( int axisId, double rotation ); - - void setAxisTitle( int axisId, const QString & ); - void setAxisTitle( int axisId, const QwtText & ); - QwtText axisTitle( int axisId ) const; - - void setAxisMaxMinor( int axisId, int maxMinor ); - int axisMaxMinor( int axisId ) const; - - void setAxisMaxMajor( int axisId, int maxMajor ); - int axisMaxMajor( int axisId ) const; - - // Legend - - void insertLegend( QwtLegend *, LegendPosition = QwtPlot::RightLegend, - double ratio = -1.0 ); - - QwtLegend *legend(); - const QwtLegend *legend() const; - - // Misc - - virtual QSize sizeHint() const; - virtual QSize minimumSizeHint() const; - - virtual void updateLayout(); - virtual void drawCanvas( QPainter * ); - - void updateAxes(); - - virtual bool event( QEvent * ); - - virtual void drawItems( QPainter *, const QRectF &, - const QwtScaleMap maps[axisCnt] ) const; - -Q_SIGNALS: - /*! - A signal which is emitted when the user has clicked on - a legend item, which is in QwtLegend::ClickableItem mode. - - \param plotItem Corresponding plot item of the - selected legend item - - \note clicks are disabled as default - \sa QwtLegend::setItemMode(), QwtLegend::itemMode() - */ - void legendClicked( QwtPlotItem *plotItem ); - - /*! - A signal which is emitted when the user has clicked on - a legend item, which is in QwtLegend::CheckableItem mode - - \param plotItem Corresponding plot item of the - selected legend item - \param on True when the legen item is checked - - \note clicks are disabled as default - \sa QwtLegend::setItemMode(), QwtLegend::itemMode() - */ - - void legendChecked( QwtPlotItem *plotItem, bool on ); - -public Q_SLOTS: - virtual void replot(); - void autoRefresh(); - -protected Q_SLOTS: - virtual void legendItemClicked(); - virtual void legendItemChecked( bool ); - -protected: - static bool axisValid( int axisId ); - - virtual void updateTabOrder(); - - virtual void resizeEvent( QResizeEvent *e ); - -private: - void initAxesData(); - void deleteAxesData(); - void updateScaleDiv(); - - void initPlot( const QwtText &title ); - - class AxisData; - AxisData *d_axisData[axisCnt]; - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_plot_axis.cpp b/qwt/src/qwt_plot_axis.cpp deleted file mode 100644 index 2ce25fd21..000000000 --- a/qwt/src/qwt_plot_axis.cpp +++ /dev/null @@ -1,705 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_plot.h" -#include "qwt_math.h" -#include "qwt_scale_widget.h" -#include "qwt_scale_div.h" -#include "qwt_scale_engine.h" - -class QwtPlot::AxisData -{ -public: - bool isEnabled; - bool doAutoScale; - - double minValue; - double maxValue; - double stepSize; - - int maxMajor; - int maxMinor; - - QwtScaleDiv scaleDiv; - QwtScaleEngine *scaleEngine; - QwtScaleWidget *scaleWidget; -}; - -//! Initialize axes -void QwtPlot::initAxesData() -{ - int axisId; - - for ( axisId = 0; axisId < axisCnt; axisId++ ) - d_axisData[axisId] = new AxisData; - - d_axisData[yLeft]->scaleWidget = - new QwtScaleWidget( QwtScaleDraw::LeftScale, this ); - - d_axisData[yLeft1]->scaleWidget = - new QwtScaleWidget( QwtScaleDraw::LeftScale, this ); - d_axisData[yLeft2]->scaleWidget = - new QwtScaleWidget( QwtScaleDraw::LeftScale, this ); - d_axisData[yLeft3]->scaleWidget = - new QwtScaleWidget( QwtScaleDraw::LeftScale, this ); - - d_axisData[yRight]->scaleWidget = - new QwtScaleWidget( QwtScaleDraw::RightScale, this ); - - d_axisData[yRight1]->scaleWidget = - new QwtScaleWidget( QwtScaleDraw::RightScale, this ); - d_axisData[yRight2]->scaleWidget = - new QwtScaleWidget( QwtScaleDraw::RightScale, this ); - d_axisData[yRight3]->scaleWidget = - new QwtScaleWidget( QwtScaleDraw::RightScale, this ); - - d_axisData[xTop]->scaleWidget = - new QwtScaleWidget( QwtScaleDraw::TopScale, this ); - d_axisData[xBottom]->scaleWidget = - new QwtScaleWidget( QwtScaleDraw::BottomScale, this ); - - d_axisData[yLeft]->scaleWidget->setObjectName( "QwtPlotAxisYLeft" ); - - d_axisData[yLeft1]->scaleWidget->setObjectName( "QwtPlotAxisYLeft1" ); - d_axisData[yLeft2]->scaleWidget->setObjectName( "QwtPlotAxisYLeft2" ); - d_axisData[yLeft3]->scaleWidget->setObjectName( "QwtPlotAxisYLeft3" ); - - d_axisData[yRight]->scaleWidget->setObjectName( "QwtPlotAxisYRight" ); - - d_axisData[yRight1]->scaleWidget->setObjectName( "QwtPlotAxisYRight1" ); - d_axisData[yRight2]->scaleWidget->setObjectName( "QwtPlotAxisYRight2" ); - d_axisData[yRight3]->scaleWidget->setObjectName( "QwtPlotAxisYRight3" ); - - d_axisData[xTop]->scaleWidget->setObjectName( "QwtPlotAxisXTop" ); - d_axisData[xBottom]->scaleWidget->setObjectName( "QwtPlotAxisXBottom" ); - - QFont fscl( fontInfo().family(), 10 ); - QFont fttl( fontInfo().family(), 12, QFont::Bold ); - - for ( axisId = 0; axisId < axisCnt; axisId++ ) - { - AxisData &d = *d_axisData[axisId]; - - d.scaleWidget->setFont( fscl ); - d.scaleWidget->setMargin( 2 ); - - QwtText text = d.scaleWidget->title(); - text.setFont( fttl ); - d.scaleWidget->setTitle( text ); - - d.doAutoScale = true; - - d.minValue = 0.0; - d.maxValue = 1000.0; - d.stepSize = 0.0; - - d.maxMinor = 5; - d.maxMajor = 8; - - d.scaleEngine = new QwtLinearScaleEngine; - - d.scaleDiv.invalidate(); - } - - d_axisData[yLeft]->isEnabled = true; - - d_axisData[yLeft1]->isEnabled = false; - d_axisData[yLeft2]->isEnabled = false; - d_axisData[yLeft3]->isEnabled = false; - - d_axisData[yRight]->isEnabled = false; - - d_axisData[yRight1]->isEnabled = false; - d_axisData[yRight2]->isEnabled = false; - d_axisData[yRight3]->isEnabled = false; - - d_axisData[xBottom]->isEnabled = true; - d_axisData[xTop]->isEnabled = false; -} - -void QwtPlot::deleteAxesData() -{ - for ( int axisId = 0; axisId < axisCnt; axisId++ ) - { - delete d_axisData[axisId]->scaleEngine; - delete d_axisData[axisId]; - d_axisData[axisId] = NULL; - } -} - -/*! - \return specified axis, or NULL if axisId is invalid. - \param axisId axis index -*/ -const QwtScaleWidget *QwtPlot::axisWidget( int axisId ) const -{ - if ( axisValid( axisId ) ) - return d_axisData[axisId]->scaleWidget; - - return NULL; -} - -/*! - \return specified axis, or NULL if axisId is invalid. - \param axisId axis index -*/ -QwtScaleWidget *QwtPlot::axisWidget( int axisId ) -{ - if ( axisValid( axisId ) ) - return d_axisData[axisId]->scaleWidget; - - return NULL; -} - -/*! - Change the scale engine for an axis - - \param axisId axis index - \param scaleEngine Scale engine - - \sa axisScaleEngine() -*/ -void QwtPlot::setAxisScaleEngine( int axisId, QwtScaleEngine *scaleEngine ) -{ - if ( axisValid( axisId ) && scaleEngine != NULL ) - { - AxisData &d = *d_axisData[axisId]; - - delete d.scaleEngine; - d.scaleEngine = scaleEngine; - - d.scaleDiv.invalidate(); - - autoRefresh(); - } -} - -/*! - \param axisId axis index - \return Scale engine for a specific axis -*/ -QwtScaleEngine *QwtPlot::axisScaleEngine( int axisId ) -{ - if ( axisValid( axisId ) ) - return d_axisData[axisId]->scaleEngine; - else - return NULL; -} - -/*! - \param axisId axis index - \return Scale engine for a specific axis -*/ -const QwtScaleEngine *QwtPlot::axisScaleEngine( int axisId ) const -{ - if ( axisValid( axisId ) ) - return d_axisData[axisId]->scaleEngine; - else - return NULL; -} -/*! - \return \c true if autoscaling is enabled - \param axisId axis index -*/ -bool QwtPlot::axisAutoScale( int axisId ) const -{ - if ( axisValid( axisId ) ) - return d_axisData[axisId]->doAutoScale; - else - return false; - -} - -/*! - \return \c true if a specified axis is enabled - \param axisId axis index -*/ -bool QwtPlot::axisEnabled( int axisId ) const -{ - if ( axisValid( axisId ) ) - return d_axisData[axisId]->isEnabled; - else - return false; -} - -/*! - \return the font of the scale labels for a specified axis - \param axisId axis index -*/ -QFont QwtPlot::axisFont( int axisId ) const -{ - if ( axisValid( axisId ) ) - return axisWidget( axisId )->font(); - else - return QFont(); - -} - -/*! - \return the maximum number of major ticks for a specified axis - \param axisId axis index - \sa setAxisMaxMajor() -*/ -int QwtPlot::axisMaxMajor( int axisId ) const -{ - if ( axisValid( axisId ) ) - return d_axisData[axisId]->maxMajor; - else - return 0; -} - -/*! - \return the maximum number of minor ticks for a specified axis - \param axisId axis index - \sa setAxisMaxMinor() -*/ -int QwtPlot::axisMaxMinor( int axisId ) const -{ - if ( axisValid( axisId ) ) - return d_axisData[axisId]->maxMinor; - else - return 0; -} - -/*! - \brief Return the scale division of a specified axis - - axisScaleDiv(axisId)->lowerBound(), axisScaleDiv(axisId)->upperBound() - are the current limits of the axis scale. - - \param axisId axis index - \return Scale division - - \sa QwtScaleDiv, setAxisScaleDiv() -*/ -const QwtScaleDiv *QwtPlot::axisScaleDiv( int axisId ) const -{ - if ( !axisValid( axisId ) ) - return NULL; - - return &d_axisData[axisId]->scaleDiv; -} - -/*! - \brief Return the scale division of a specified axis - - axisScaleDiv(axisId)->lowerBound(), axisScaleDiv(axisId)->upperBound() - are the current limits of the axis scale. - - \param axisId axis index - \return Scale division - - \sa QwtScaleDiv, setAxisScaleDiv() -*/ -QwtScaleDiv *QwtPlot::axisScaleDiv( int axisId ) -{ - if ( !axisValid( axisId ) ) - return NULL; - - return &d_axisData[axisId]->scaleDiv; -} - -/*! - \returns the scale draw of a specified axis - \param axisId axis index - \return specified scaleDraw for axis, or NULL if axis is invalid. - \sa QwtScaleDraw -*/ -const QwtScaleDraw *QwtPlot::axisScaleDraw( int axisId ) const -{ - if ( !axisValid( axisId ) ) - return NULL; - - return axisWidget( axisId )->scaleDraw(); -} - -/*! - \returns the scale draw of a specified axis - \param axisId axis index - \return specified scaleDraw for axis, or NULL if axis is invalid. - \sa QwtScaleDraw -*/ -QwtScaleDraw *QwtPlot::axisScaleDraw( int axisId ) -{ - if ( !axisValid( axisId ) ) - return NULL; - - return axisWidget( axisId )->scaleDraw(); -} - -/*! - Return the step size parameter, that has been set - in setAxisScale. This doesn't need to be the step size - of the current scale. - - \param axisId axis index - \return step size parameter value - - \sa setAxisScale() -*/ -double QwtPlot::axisStepSize( int axisId ) const -{ - if ( !axisValid( axisId ) ) - return 0; - - return d_axisData[axisId]->stepSize; -} - -/*! - \brief Return the current interval of the specified axis - - This is only a convenience function for axisScaleDiv( axisId )->interval(); - - \param axisId axis index - \return Scale interval - - \sa QwtScaleDiv, axisScaleDiv() -*/ -QwtInterval QwtPlot::axisInterval( int axisId ) const -{ - if ( !axisValid( axisId ) ) - return QwtInterval(); - - return d_axisData[axisId]->scaleDiv.interval(); -} - -/*! - \return the title of a specified axis - \param axisId axis index -*/ -QwtText QwtPlot::axisTitle( int axisId ) const -{ - if ( axisValid( axisId ) ) - return axisWidget( axisId )->title(); - else - return QwtText(); -} - -/*! - \brief Enable or disable a specified axis - - When an axis is disabled, this only means that it is not - visible on the screen. Curves, markers and can be attached - to disabled axes, and transformation of screen coordinates - into values works as normal. - - Only xBottom and yLeft are enabled by default. - \param axisId axis index - \param tf \c true (enabled) or \c false (disabled) -*/ -void QwtPlot::enableAxis( int axisId, bool tf ) -{ - if ( axisValid( axisId ) && tf != d_axisData[axisId]->isEnabled ) - { - d_axisData[axisId]->isEnabled = tf; - updateLayout(); - } -} - -/*! - Transform the x or y coordinate of a position in the - drawing region into a value. - \param axisId axis index - \param pos position - \warning The position can be an x or a y coordinate, - depending on the specified axis. -*/ -double QwtPlot::invTransform( int axisId, int pos ) const -{ - if ( axisValid( axisId ) ) - return( canvasMap( axisId ).invTransform( pos ) ); - else - return 0.0; -} - - -/*! - \brief Transform a value into a coordinate in the plotting region - \param axisId axis index - \param value value - \return X or y coordinate in the plotting region corresponding - to the value. -*/ -double QwtPlot::transform( int axisId, double value ) const -{ - if ( axisValid( axisId ) ) - return( canvasMap( axisId ).transform( value ) ); - else - return 0.0; -} - -/*! - \brief Change the font of an axis - \param axisId axis index - \param f font - \warning This function changes the font of the tick labels, - not of the axis title. -*/ -void QwtPlot::setAxisFont( int axisId, const QFont &f ) -{ - if ( axisValid( axisId ) ) - axisWidget( axisId )->setFont( f ); -} - -/*! - \brief Enable autoscaling for a specified axis - - This member function is used to switch back to autoscaling mode - after a fixed scale has been set. Autoscaling is enabled by default. - - \param axisId axis index - \param on On/Off - \sa setAxisScale(), setAxisScaleDiv(), updateAxes() - - \note The autoscaling flag has no effect until updateAxes() is executed - ( called by replot() ). -*/ -void QwtPlot::setAxisAutoScale( int axisId, bool on ) -{ - if ( axisValid( axisId ) && ( d_axisData[axisId]->doAutoScale != on ) ) - { - d_axisData[axisId]->doAutoScale = on; - autoRefresh(); - } -} - -/*! - \brief Disable autoscaling and specify a fixed scale for a selected axis. - \param axisId axis index - \param min - \param max minimum and maximum of the scale - \param stepSize Major step size. If step == 0, the step size is - calculated automatically using the maxMajor setting. - \sa setAxisMaxMajor(), setAxisAutoScale(), axisStepSize() -*/ -void QwtPlot::setAxisScale( int axisId, double min, double max, double stepSize ) -{ - if ( axisValid( axisId ) ) - { - AxisData &d = *d_axisData[axisId]; - - d.doAutoScale = false; - d.scaleDiv.invalidate(); - - d.minValue = min; - d.maxValue = max; - d.stepSize = stepSize; - - autoRefresh(); - } -} - -/*! - \brief Disable autoscaling and specify a fixed scale for a selected axis. - \param axisId axis index - \param scaleDiv Scale division - \sa setAxisScale(), setAxisAutoScale() -*/ -void QwtPlot::setAxisScaleDiv( int axisId, const QwtScaleDiv &scaleDiv ) -{ - if ( axisValid( axisId ) ) - { - AxisData &d = *d_axisData[axisId]; - - d.doAutoScale = false; - d.scaleDiv = scaleDiv; - - autoRefresh(); - } -} - -/*! - \brief Set a scale draw - \param axisId axis index - \param scaleDraw object responsible for drawing scales. - - By passing scaleDraw it is possible to extend QwtScaleDraw - functionality and let it take place in QwtPlot. Please note - that scaleDraw has to be created with new and will be deleted - by the corresponding QwtScale member ( like a child object ). - - \sa QwtScaleDraw, QwtScaleWidget - \warning The attributes of scaleDraw will be overwritten by those of the - previous QwtScaleDraw. -*/ - -void QwtPlot::setAxisScaleDraw( int axisId, QwtScaleDraw *scaleDraw ) -{ - if ( axisValid( axisId ) ) - { - axisWidget( axisId )->setScaleDraw( scaleDraw ); - autoRefresh(); - } -} - -/*! - Change the alignment of the tick labels - \param axisId axis index - \param alignment Or'd Qt::AlignmentFlags see - \sa QwtScaleDraw::setLabelAlignment() -*/ -void QwtPlot::setAxisLabelAlignment( int axisId, Qt::Alignment alignment ) -{ - if ( axisValid( axisId ) ) - axisWidget( axisId )->setLabelAlignment( alignment ); -} - -/*! - Rotate all tick labels - \param axisId axis index - \param rotation Angle in degrees. When changing the label rotation, - the label alignment might be adjusted too. - \sa QwtScaleDraw::setLabelRotation(), setAxisLabelAlignment() -*/ -void QwtPlot::setAxisLabelRotation( int axisId, double rotation ) -{ - if ( axisValid( axisId ) ) - axisWidget( axisId )->setLabelRotation( rotation ); -} - -/*! - Set the maximum number of minor scale intervals for a specified axis - - \param axisId axis index - \param maxMinor maximum number of minor steps - \sa axisMaxMinor() -*/ -void QwtPlot::setAxisMaxMinor( int axisId, int maxMinor ) -{ - if ( axisValid( axisId ) ) - { - maxMinor = qBound( 0, maxMinor, 100 ); - - AxisData &d = *d_axisData[axisId]; - if ( maxMinor != d.maxMinor ) - { - d.maxMinor = maxMinor; - d.scaleDiv.invalidate(); - autoRefresh(); - } - } -} - -/*! - Set the maximum number of major scale intervals for a specified axis - - \param axisId axis index - \param maxMajor maximum number of major steps - \sa axisMaxMajor() -*/ -void QwtPlot::setAxisMaxMajor( int axisId, int maxMajor ) -{ - if ( axisValid( axisId ) ) - { - maxMajor = qBound( 1, maxMajor, 10000 ); - - AxisData &d = *d_axisData[axisId]; - if ( maxMajor != d.maxMajor ) - { - d.maxMajor = maxMajor; - d.scaleDiv.invalidate(); - autoRefresh(); - } - } -} - -/*! - \brief Change the title of a specified axis - \param axisId axis index - \param title axis title -*/ -void QwtPlot::setAxisTitle( int axisId, const QString &title ) -{ - if ( axisValid( axisId ) ) - axisWidget( axisId )->setTitle( title ); -} - -/*! - \brief Change the title of a specified axis - \param axisId axis index - \param title axis title -*/ -void QwtPlot::setAxisTitle( int axisId, const QwtText &title ) -{ - if ( axisValid( axisId ) ) - axisWidget( axisId )->setTitle( title ); -} - -//! Rebuild the scales -void QwtPlot::updateAxes() -{ - // Find bounding interval of the item data - // for all axes, where autoscaling is enabled - - QwtInterval intv[axisCnt]; - - const QwtPlotItemList& itmList = itemList(); - - QwtPlotItemIterator it; - for ( it = itmList.begin(); it != itmList.end(); ++it ) - { - const QwtPlotItem *item = *it; - - if ( !item->testItemAttribute( QwtPlotItem::AutoScale ) ) - continue; - - if ( !item->isVisible() ) - continue; - - if ( axisAutoScale( item->xAxis() ) || axisAutoScale( item->yAxis() ) ) - { - const QRectF rect = item->boundingRect(); - intv[item->xAxis()] |= QwtInterval( rect.left(), rect.right() ); - intv[item->yAxis()] |= QwtInterval( rect.top(), rect.bottom() ); - } - } - - // Adjust scales - - for ( int axisId = 0; axisId < axisCnt; axisId++ ) - { - AxisData &d = *d_axisData[axisId]; - - double minValue = d.minValue; - double maxValue = d.maxValue; - double stepSize = d.stepSize; - - if ( d.doAutoScale && intv[axisId].isValid() ) - { - d.scaleDiv.invalidate(); - - minValue = intv[axisId].minValue(); - maxValue = intv[axisId].maxValue(); - - d.scaleEngine->autoScale( d.maxMajor, - minValue, maxValue, stepSize ); - } - if ( !d.scaleDiv.isValid() ) - { - d.scaleDiv = d.scaleEngine->divideScale( - minValue, maxValue, - d.maxMajor, d.maxMinor, stepSize ); - } - - QwtScaleWidget *scaleWidget = axisWidget( axisId ); - scaleWidget->setScaleDiv( - d.scaleEngine->transformation(), d.scaleDiv ); - - int startDist, endDist; - scaleWidget->getBorderDistHint( startDist, endDist ); - scaleWidget->setBorderDist( startDist, endDist ); - } - - for ( it = itmList.begin(); it != itmList.end(); ++it ) - { - QwtPlotItem *item = *it; - item->updateScaleDiv( *axisScaleDiv( item->xAxis() ), - *axisScaleDiv( item->yAxis() ) ); - } -} diff --git a/qwt/src/qwt_plot_canvas.cpp b/qwt/src/qwt_plot_canvas.cpp deleted file mode 100644 index 5fd70d98a..000000000 --- a/qwt/src/qwt_plot_canvas.cpp +++ /dev/null @@ -1,1079 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_plot_canvas.h" -#include "qwt_painter.h" -#include "qwt_null_paintdevice.h" -#include "qwt_math.h" -#include "qwt_plot.h" -#include -#include -#include -#include -#include -#include -#ifdef Q_WS_X11 -#include -#endif - -class QwtStyleSheetRecorder: public QwtNullPaintDevice -{ -public: - QwtStyleSheetRecorder( const QSize &size ): - QwtNullPaintDevice( QPaintEngine::AllFeatures ) - { - setSize( size ); - } - - virtual void updateState( const QPaintEngineState &state ) - { - if ( state.state() & QPaintEngine::DirtyPen ) - { - d_pen = state.pen(); - } - if ( state.state() & QPaintEngine::DirtyBrush ) - { - d_brush = state.brush(); - } - if ( state.state() & QPaintEngine::DirtyBrushOrigin ) - { - d_origin = state.brushOrigin(); - } - } - - virtual void drawRects(const QRectF *rects, int count ) - { - for ( int i = 0; i < count; i++ ) - border.rectList += rects[i]; - } - - virtual void drawPath( const QPainterPath &path ) - { - const QRectF rect( QPointF( 0.0, 0.0 ) , size() ); - if ( path.controlPointRect().contains( rect.center() ) ) - { - setCornerRects( path ); - alignCornerRects( rect ); - - background.path = path; - background.brush = d_brush; - background.origin = d_origin; - } - else - { - border.pathList += path; - } - } - - void setCornerRects( const QPainterPath &path ) - { - QPointF pos( 0.0, 0.0 ); - - for ( int i = 0; i < path.elementCount(); i++ ) - { - QPainterPath::Element el = path.elementAt(i); - switch( el.type ) - { - case QPainterPath::MoveToElement: - case QPainterPath::LineToElement: - { - pos.setX( el.x ); - pos.setY( el.y ); - break; - } - case QPainterPath::CurveToElement: - { - QRectF r( pos, QPointF( el.x, el.y ) ); - clipRects += r.normalized(); - - pos.setX( el.x ); - pos.setY( el.y ); - - break; - } - case QPainterPath::CurveToDataElement: - { - if ( clipRects.size() > 0 ) - { - QRectF r = clipRects.last(); - r.setCoords( - qMin( r.left(), el.x ), - qMin( r.top(), el.y ), - qMax( r.right(), el.x ), - qMax( r.bottom(), el.y ) - ); - clipRects.last() = r.normalized(); - } - break; - } - } - } - } - -private: - void alignCornerRects( const QRectF &rect ) - { - for ( int i = 0; i < clipRects.size(); i++ ) - { - QRectF &r = clipRects[i]; - if ( r.center().x() < rect.center().x() ) - r.setLeft( rect.left() ); - else - r.setRight( rect.right() ); - - if ( r.center().y() < rect.center().y() ) - r.setTop( rect.top() ); - else - r.setBottom( rect.bottom() ); - } - } - - -public: - QVector clipRects; - - struct Border - { - QList pathList; - QList rectList; - QRegion clipRegion; - } border; - - struct Background - { - QPainterPath path; - QBrush brush; - QPointF origin; - } background; - -private: - QPen d_pen; - QBrush d_brush; - QPointF d_origin; -}; - -static void qwtDrawBackground( QPainter *painter, QWidget *widget ) -{ - const QBrush &brush = - widget->palette().brush( widget->backgroundRole() ); - - if ( brush.style() == Qt::TexturePattern ) - { - QPixmap pm( widget->size() ); - pm.fill( widget, 0, 0 ); - painter->drawPixmap( 0, 0, pm ); - } - else if ( brush.gradient() ) - { - QVector rects; - - if ( brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode ) - { - rects += widget->rect(); - } - else - { - rects = painter->clipRegion().rects(); - } - -#if 1 - bool useRaster = false; - - if ( painter->paintEngine()->type() == QPaintEngine::X11 ) - { - // Qt 4.7.1: gradients on X11 are broken ( subrects + - // QGradient::StretchToDeviceMode ) and horrible slow. - // As workaround we have to use the raster paintengine. - // Even if the QImage -> QPixmap translation is slow - // it is three times faster, than using X11 directly - - useRaster = true; - } -#endif - if ( useRaster ) - { - QImage::Format format = QImage::Format_RGB32; - - const QGradientStops stops = brush.gradient()->stops(); - for ( int i = 0; i < stops.size(); i++ ) - { - if ( stops[i].second.alpha() != 255 ) - { - // don't use Format_ARGB32_Premultiplied. It's - // recommended by the Qt docs, but QPainter::drawImage() - // is horrible slow on X11. - - format = QImage::Format_ARGB32; - break; - } - } - - QImage image( widget->size(), format ); - - QPainter p( &image ); - p.setPen( Qt::NoPen ); - p.setBrush( brush ); - - p.drawRects( rects ); - - p.end(); - - painter->drawImage( 0, 0, image ); - } - else - { - painter->save(); - - painter->setPen( Qt::NoPen ); - painter->setBrush( brush ); - - painter->drawRects( rects ); - - painter->restore(); - } - } - else - { - painter->save(); - - painter->setPen( Qt::NoPen ); - painter->setBrush( brush ); - - painter->drawRects( painter->clipRegion().rects() ); - - painter->restore(); - } -} - -static inline void qwtRevertPath( QPainterPath &path ) -{ - if ( path.elementCount() == 4 ) - { - QPainterPath::Element &el0 = - const_cast( path.elementAt(0) ); - QPainterPath::Element &el2 = - const_cast( path.elementAt(3) ); - - qSwap( el0.x, el2.x ); - qSwap( el0.y, el2.y ); - } -} - -static QPainterPath qwtCombinePathList( const QRectF &rect, - const QList &pathList ) -{ - if ( pathList.isEmpty() ) - return QPainterPath(); - - QPainterPath ordered[8]; // starting top left - - for ( int i = 0; i < pathList.size(); i++ ) - { - int index = -1; - QPainterPath subPath = pathList[i]; - - const QRectF br = pathList[i].controlPointRect(); - if ( br.center().x() < rect.center().x() ) - { - if ( br.center().y() < rect.center().y() ) - { - if ( qAbs( br.top() - rect.top() ) < - qAbs( br.left() - rect.left() ) ) - { - index = 1; - } - else - { - index = 0; - } - } - else - { - if ( qAbs( br.bottom() - rect.bottom() ) < - qAbs( br.left() - rect.left() ) ) - { - index = 6; - } - else - { - index = 7; - } - } - - if ( subPath.currentPosition().y() > br.center().y() ) - qwtRevertPath( subPath ); - } - else - { - if ( br.center().y() < rect.center().y() ) - { - if ( qAbs( br.top() - rect.top() ) < - qAbs( br.right() - rect.right() ) ) - { - index = 2; - } - else - { - index = 3; - } - } - else - { - if ( qAbs( br.bottom() - rect.bottom() ) < - qAbs( br.right() - rect.right() ) ) - { - index = 5; - } - else - { - index = 4; - } - } - if ( subPath.currentPosition().y() < br.center().y() ) - qwtRevertPath( subPath ); - } - ordered[index] = subPath; - } - - for ( int i = 0; i < 4; i++ ) - { - if ( ordered[ 2 * i].isEmpty() != ordered[2 * i + 1].isEmpty() ) - { - // we don't accept incomplete rounded borders - return QPainterPath(); - } - } - - - const QPolygonF corners( rect ); - - QPainterPath path; - //path.moveTo( rect.topLeft() ); - - for ( int i = 0; i < 4; i++ ) - { - if ( ordered[2 * i].isEmpty() ) - { - path.lineTo( corners[i] ); - } - else - { - path.connectPath( ordered[2 * i] ); - path.connectPath( ordered[2 * i + 1] ); - } - } - - path.closeSubpath(); - -#if 0 - return path.simplified(); -#else - return path; -#endif -} - -static inline void qwtDrawStyledBackground( - QWidget *w, QPainter *painter ) -{ - QStyleOption opt; - opt.initFrom(w); - w->style()->drawPrimitive( QStyle::PE_Widget, &opt, painter, w); -} - -static QWidget *qwtBackgroundWidget( QWidget *w ) -{ - if ( w->parentWidget() == NULL ) - return w; - - if ( w->autoFillBackground() ) - { - const QBrush brush = w->palette().brush( w->backgroundRole() ); - if ( brush.color().alpha() > 0 ) - return w; - } - - if ( w->testAttribute( Qt::WA_StyledBackground ) ) - { - QImage image( 1, 1, QImage::Format_ARGB32 ); - image.fill( Qt::transparent ); - - QPainter painter( &image ); - painter.translate( -w->rect().center() ); - qwtDrawStyledBackground( w, &painter ); - painter.end(); - - if ( qAlpha( image.pixel( 0, 0 ) ) != 0 ) - return w; - } - - return qwtBackgroundWidget( w->parentWidget() ); -} - -static void qwtFillBackground( QPainter *painter, - QWidget *widget, const QVector &fillRects ) -{ - if ( fillRects.isEmpty() ) - return; - - QRegion clipRegion; - if ( painter->hasClipping() ) - clipRegion = painter->transform().map( painter->clipRegion() ); - else - clipRegion = widget->contentsRect(); - - // Try to find out which widget fills - // the unfilled areas of the styled background - - QWidget *bgWidget = qwtBackgroundWidget( widget->parentWidget() ); - - for ( int i = 0; i < fillRects.size(); i++ ) - { - const QRect rect = fillRects[i].toAlignedRect(); - if ( clipRegion.intersects( rect ) ) - { - QPixmap pm( rect.size() ); - pm.fill( bgWidget, widget->mapTo( bgWidget, rect.topLeft() ) ); - painter->drawPixmap( rect, pm ); - } - } -} - -static void qwtFillBackground( QPainter *painter, QwtPlotCanvas *canvas ) -{ - QVector rects; - - if ( canvas->testAttribute( Qt::WA_StyledBackground ) ) - { - QwtStyleSheetRecorder recorder( canvas->size() ); - - QPainter p( &recorder ); - qwtDrawStyledBackground( canvas, &p ); - p.end(); - - if ( recorder.background.brush.isOpaque() ) - rects = recorder.clipRects; - else - rects += canvas->rect(); - } - else - { - const QRectF r = canvas->rect(); - const double radius = canvas->borderRadius(); - if ( radius > 0.0 ) - { - QSize sz( radius, radius ); - - rects += QRectF( r.topLeft(), sz ); - rects += QRectF( r.topRight() - QPointF( radius, 0 ), sz ); - rects += QRectF( r.bottomRight() - QPointF( radius, radius ), sz ); - rects += QRectF( r.bottomLeft() - QPointF( 0, radius ), sz ); - } - } - - qwtFillBackground( painter, canvas, rects); -} - - -class QwtPlotCanvas::PrivateData -{ -public: - PrivateData(): - focusIndicator( NoFocusIndicator ), - borderRadius( 0 ), - paintAttributes( 0 ), - backingStore( NULL ) - { - styleSheet.hasBorder = false; - } - - ~PrivateData() - { - delete backingStore; - } - - FocusIndicator focusIndicator; - double borderRadius; - QwtPlotCanvas::PaintAttributes paintAttributes; - QPixmap *backingStore; - - struct StyleSheet - { - bool hasBorder; - QPainterPath borderPath; - QVector cornerRects; - - struct StyleSheetBackground - { - QBrush brush; - QPointF origin; - } background; - - } styleSheet; - -}; - -//! Sets a cross cursor, enables QwtPlotCanvas::BackingStore - -QwtPlotCanvas::QwtPlotCanvas( QwtPlot *plot ): - QFrame( plot ) -{ - d_data = new PrivateData; - -#ifndef QT_NO_CURSOR - setCursor( Qt::CrossCursor ); -#endif - - setAutoFillBackground( true ); - setPaintAttribute( QwtPlotCanvas::BackingStore, true ); - setPaintAttribute( QwtPlotCanvas::Opaque, true ); - setPaintAttribute( QwtPlotCanvas::HackStyledBackground, true ); -} - -//! Destructor -QwtPlotCanvas::~QwtPlotCanvas() -{ - delete d_data; -} - -//! Return parent plot widget -QwtPlot *QwtPlotCanvas::plot() -{ - return qobject_cast( parentWidget() ); -} - -//! Return parent plot widget -const QwtPlot *QwtPlotCanvas::plot() const -{ - return qobject_cast( parentWidget() ); -} - -/*! - \brief Changing the paint attributes - - \param attribute Paint attribute - \param on On/Off - - \sa testPaintAttribute(), backingStore() -*/ -void QwtPlotCanvas::setPaintAttribute( PaintAttribute attribute, bool on ) -{ - if ( bool( d_data->paintAttributes & attribute ) == on ) - return; - - if ( on ) - d_data->paintAttributes |= attribute; - else - d_data->paintAttributes &= ~attribute; - - switch ( attribute ) - { - case BackingStore: - { - if ( on ) - { - if ( d_data->backingStore == NULL ) - d_data->backingStore = new QPixmap(); - - if ( isVisible() ) - { - *d_data->backingStore = - QPixmap::grabWidget( this, rect() ); - } - } - else - { - delete d_data->backingStore; - d_data->backingStore = NULL; - } - break; - } - case Opaque: - { - if ( on ) - setAttribute( Qt::WA_OpaquePaintEvent, true ); - - break; - } - case HackStyledBackground: - case ImmediatePaint: - { - break; - } - } -} - -/*! - Test wether a paint attribute is enabled - - \param attribute Paint attribute - \return true if the attribute is enabled - \sa setPaintAttribute() -*/ -bool QwtPlotCanvas::testPaintAttribute( PaintAttribute attribute ) const -{ - return d_data->paintAttributes & attribute; -} - -//! \return Backing store, might be null -const QPixmap *QwtPlotCanvas::backingStore() const -{ - return d_data->backingStore; -} - -//! Invalidate the internal backing store -void QwtPlotCanvas::invalidateBackingStore() -{ - if ( d_data->backingStore ) - *d_data->backingStore = QPixmap(); -} - -/*! - Set the focus indicator - - \sa FocusIndicator, focusIndicator() -*/ -void QwtPlotCanvas::setFocusIndicator( FocusIndicator focusIndicator ) -{ - d_data->focusIndicator = focusIndicator; -} - -/*! - \return Focus indicator - - \sa FocusIndicator, setFocusIndicator() -*/ -QwtPlotCanvas::FocusIndicator QwtPlotCanvas::focusIndicator() const -{ - return d_data->focusIndicator; -} - -/*! - Set the radius for the corners of the border frame - - \param radius Radius of a rounded corner - \sa borderRadius() -*/ -void QwtPlotCanvas::setBorderRadius( double radius ) -{ - d_data->borderRadius = qMax( 0.0, radius ); -} - -/*! - \return Radius for the corners of the border frame - \sa setBorderRadius() -*/ -double QwtPlotCanvas::borderRadius() const -{ - return d_data->borderRadius; -} - -/*! - Qt event handler for QEvent::PolishRequest and QEvent::StyleChange - \param event Qt Event -*/ -bool QwtPlotCanvas::event( QEvent *event ) -{ - if ( event->type() == QEvent::PolishRequest ) - { - if ( testPaintAttribute( QwtPlotCanvas::Opaque ) ) - { - // Setting a style sheet changes the - // Qt::WA_OpaquePaintEvent attribute, but we insist - // on painting the background. - - setAttribute( Qt::WA_OpaquePaintEvent, true ); - } - } - - if ( event->type() == QEvent::PolishRequest || - event->type() == QEvent::StyleChange ) - { - updateStyleSheetInfo(); - } - - return QFrame::event( event ); -} - -/*! - Paint event - \param event Paint event -*/ -void QwtPlotCanvas::paintEvent( QPaintEvent *event ) -{ - QPainter painter( this ); - painter.setClipRegion( event->region() ); - - if ( testPaintAttribute( QwtPlotCanvas::BackingStore ) && - d_data->backingStore != NULL ) - { - QPixmap &bs = *d_data->backingStore; - if ( bs.size() != size() ) - { - bs = QPixmap( size() ); - -#ifdef Q_WS_X11 - if ( bs.x11Info().screen() != x11Info().screen() ) - bs.x11SetScreen( x11Info().screen() ); -#endif - - if ( testAttribute(Qt::WA_StyledBackground) ) - { - QPainter p( &bs ); - qwtFillBackground( &p, this ); - drawCanvas( &p, true ); - } - else - { - QPainter p; - if ( d_data->borderRadius <= 0.0 ) - { - bs.fill( this, 0, 0 ); - p.begin( &bs ); - drawCanvas( &p, false ); - } - else - { - p.begin( &bs ); - qwtFillBackground( &p, this ); - drawCanvas( &p, true ); - } - - if ( frameWidth() > 0 ) - drawBorder( &p ); - } - } - - painter.drawPixmap( 0, 0, *d_data->backingStore ); - } - else - { - if ( testAttribute(Qt::WA_StyledBackground ) ) - { - if ( testAttribute( Qt::WA_OpaquePaintEvent ) ) - { - qwtFillBackground( &painter, this ); - drawCanvas( &painter, true ); - } - else - { - drawCanvas( &painter, false ); - } - } - else - { - if ( testAttribute( Qt::WA_OpaquePaintEvent ) ) - { - if ( autoFillBackground() ) - qwtDrawBackground( &painter, this ); - } - - drawCanvas( &painter, false ); - - if ( frameWidth() > 0 ) - drawBorder( &painter ); - } - } - - if ( hasFocus() && focusIndicator() == CanvasFocusIndicator ) - drawFocusIndicator( &painter ); -} - -void QwtPlotCanvas::drawCanvas( QPainter *painter, bool withBackground ) -{ - bool hackStyledBackground = false; - - if ( withBackground && testAttribute( Qt::WA_StyledBackground ) - && testPaintAttribute( HackStyledBackground ) ) - { - // Antialiasing rounded borders is done by - // inserting pixels with colors between the - // border color and the color on the canvas, - // When the border is painted before the plot items - // these colors are interpolated for the canvas - // and the plot items need to be clipped excluding - // the anialiased pixels. In situations, where - // the plot items fill the area at the rounded - // borders this is noticeable. - // The only way to avoid these annoying "artefacts" - // is to paint the border on top of the plot items. - - if ( d_data->styleSheet.hasBorder && - !d_data->styleSheet.borderPath.isEmpty() ) - { - // We have a border with at least one rounded corner - hackStyledBackground = true; - } - } - - if ( withBackground ) - { - painter->save(); - - if ( testAttribute( Qt::WA_StyledBackground ) ) - { - if ( hackStyledBackground ) - { - // paint background without border - - painter->setPen( Qt::NoPen ); - painter->setBrush( d_data->styleSheet.background.brush ); - painter->setBrushOrigin( d_data->styleSheet.background.origin ); - painter->setClipPath( d_data->styleSheet.borderPath ); - painter->drawRect( contentsRect() ); - } - else - { - qwtDrawStyledBackground( this, painter ); - } - } - else if ( autoFillBackground() ) - { - painter->setPen( Qt::NoPen ); - painter->setBrush( palette().brush( backgroundRole() ) ); - - if ( d_data->borderRadius > 0.0 ) - { - if ( frameWidth() > 0 ) - { - painter->setClipPath( borderPath( rect() ) ); - painter->drawRect( rect() ); - } - else - { - painter->setRenderHint( QPainter::Antialiasing, true ); - painter->drawPath( borderPath( rect() ) ); - } - } - else - { - painter->drawRect( contentsRect() ); - } - } - - painter->restore(); - } - - painter->save(); - - if ( !d_data->styleSheet.borderPath.isEmpty() ) - { - painter->setClipPath( - d_data->styleSheet.borderPath, Qt::IntersectClip ); - } - else - { - if ( d_data->borderRadius > 0.0 ) - painter->setClipPath( borderPath( rect() ), Qt::IntersectClip ); - else - painter->setClipRect( contentsRect(), Qt::IntersectClip ); - } - - plot()->drawCanvas( painter ); - - painter->restore(); - - if ( withBackground && hackStyledBackground ) - { - // Now paint the border on top - QStyleOptionFrame opt; - opt.initFrom(this); - style()->drawPrimitive( QStyle::PE_Frame, &opt, painter, this); - } -} - -/*! - Draw the border of the plot canvas - - \param painter Painter - \sa setBorderRadius(), QFrame::drawFrame() -*/ -void QwtPlotCanvas::drawBorder( QPainter *painter ) -{ - if ( d_data->borderRadius > 0 ) - { - if ( frameWidth() > 0 ) - { - QwtPainter::drawRoundedFrame( painter, QRectF( rect() ), - d_data->borderRadius, d_data->borderRadius, - palette(), frameWidth(), frameStyle() ); - } - } - else - { - drawFrame( painter ); - } -} - -/*! - Resize event - \param event Resize event -*/ -void QwtPlotCanvas::resizeEvent( QResizeEvent *event ) -{ - QFrame::resizeEvent( event ); - updateStyleSheetInfo(); -} - -/*! - Draw the focus indication - \param painter Painter -*/ -void QwtPlotCanvas::drawFocusIndicator( QPainter *painter ) -{ - const int margin = 1; - - QRect focusRect = contentsRect(); - focusRect.setRect( focusRect.x() + margin, focusRect.y() + margin, - focusRect.width() - 2 * margin, focusRect.height() - 2 * margin ); - - QwtPainter::drawFocusRect( painter, this, focusRect ); -} - -/*! - Invalidate the paint cache and repaint the canvas - \sa invalidatePaintCache() -*/ -void QwtPlotCanvas::replot() -{ - invalidateBackingStore(); - - if ( testPaintAttribute( QwtPlotCanvas::ImmediatePaint ) ) - repaint( contentsRect() ); - else - update( contentsRect() ); -} - -//! Update the cached informations about the current style sheet -void QwtPlotCanvas::updateStyleSheetInfo() -{ - if ( !testAttribute(Qt::WA_StyledBackground ) ) - return; - - QwtStyleSheetRecorder recorder( size() ); - - QPainter painter( &recorder ); - - QStyleOption opt; - opt.initFrom(this); - style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, this); - - painter.end(); - - d_data->styleSheet.hasBorder = !recorder.border.rectList.isEmpty(); - d_data->styleSheet.cornerRects = recorder.clipRects; - - if ( recorder.background.path.isEmpty() ) - { - if ( !recorder.border.rectList.isEmpty() ) - { - d_data->styleSheet.borderPath = - qwtCombinePathList( rect(), recorder.border.pathList ); - } - } - else - { - d_data->styleSheet.borderPath = recorder.background.path; - d_data->styleSheet.background.brush = recorder.background.brush; - d_data->styleSheet.background.origin = recorder.background.origin; - } -} - -/*! - Calculate the painter path for a styled or rounded border - - When the canvas has no styled background or rounded borders - the painter path is empty. - - \param rect Bounding rectangle of the canvas - \return Painter path, that can be used for clipping -*/ -QPainterPath QwtPlotCanvas::borderPath( const QRect &rect ) const -{ - if ( testAttribute(Qt::WA_StyledBackground ) ) - { - QwtStyleSheetRecorder recorder( rect.size() ); - - QPainter painter( &recorder ); - - QStyleOption opt; - opt.initFrom(this); - opt.rect = rect; - style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, this); - - painter.end(); - - if ( !recorder.background.path.isEmpty() ) - return recorder.background.path; - - if ( !recorder.border.rectList.isEmpty() ) - return qwtCombinePathList( rect, recorder.border.pathList ); - } - else if ( d_data->borderRadius > 0.0 ) - { - double fw2 = frameWidth() * 0.5; - QRectF r = QRectF(rect).adjusted( fw2, fw2, -fw2, -fw2 ); - - QPainterPath path; - path.addRoundedRect( r, d_data->borderRadius, d_data->borderRadius ); - return path; - } - - return QPainterPath(); -} - -/*! - Calculate a mask, that can be used to clip away the border frame - - \param size Size including the frame -*/ -QBitmap QwtPlotCanvas::borderMask( const QSize &size ) const -{ - const QRect r( 0, 0, size.width(), size.height() ); - - const QPainterPath path = borderPath( r ); - if ( path.isEmpty() ) - return QBitmap(); - - QImage image( size, QImage::Format_ARGB32_Premultiplied ); - image.fill( Qt::color0 ); - - QPainter painter( &image ); - painter.setClipPath( path ); - painter.fillRect( r, Qt::color1 ); - - // now erase the frame - - painter.setCompositionMode( QPainter::CompositionMode_DestinationOut ); - - if ( testAttribute(Qt::WA_StyledBackground ) ) - { - QStyleOptionFrame opt; - opt.initFrom(this); - opt.rect = r; - style()->drawPrimitive( QStyle::PE_Frame, &opt, &painter, this ); - } - else - { - if ( d_data->borderRadius > 0 && frameWidth() > 0 ) - { - painter.setPen( QPen( Qt::color1, frameWidth() ) ); - painter.setBrush( Qt::NoBrush ); - painter.setRenderHint( QPainter::Antialiasing, true ); - - painter.drawPath( path ); - } - } - - painter.end(); - - const QImage mask = image.createMaskFromColor( - QColor( Qt::color1 ).rgb(), Qt::MaskOutColor ); - - return QBitmap::fromImage( mask ); -} diff --git a/qwt/src/qwt_plot_canvas.h b/qwt/src/qwt_plot_canvas.h deleted file mode 100644 index c6ff758be..000000000 --- a/qwt/src/qwt_plot_canvas.h +++ /dev/null @@ -1,168 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_PLOT_CANVAS_H -#define QWT_PLOT_CANVAS_H - -#include "qwt_global.h" -#include -#include -#include -#include - -class QwtPlot; -class QPixmap; - -/*! - \brief Canvas of a QwtPlot. - \sa QwtPlot -*/ -class QWT_EXPORT QwtPlotCanvas : public QFrame -{ - Q_OBJECT - -public: - - /*! - \brief Paint attributes - - The default setting enables BackingStore and Opaque. - - \sa setPaintAttribute(), testPaintAttribute() - */ - enum PaintAttribute - { - /*! - \brief Paint double buffered reusing the content - of the pixmap buffer when possible. - - Using a backing store might improve the performance - significantly, when workin with widget overlays ( like rubberbands ). - Disabling the cache might improve the performance for - incremental paints (using QwtPlotDirectPainter ). - - \sa backingStore(), invalidateBackingStore() - */ - BackingStore = 1, - - /*! - \brief Try to fill the complete contents rectangle - of the plot canvas - - When using styled backgrounds Qt assumes, that the - canvas doesn't fill its area completely - ( f.e because of rounded borders ) and fills the area - below the canvas. When this is done with gradients it might - result in a serious performance bottleneck - depending on the size. - - When the Opaque attribute is enabled the canvas tries to - identify the gaps with some heuristics and to fill those only. - - \warning Will not work for semitransparent backgrounds - */ - Opaque = 2, - - /*! - \brief Try to improve painting of styled backgrounds - - QwtPlotCanvas supports the box model attributes for - customizing the layout with style sheets. Unfortunately - the design of Qt style sheets has no concept how to - handle backgrounds with rounded corners - beside of padding. - - When HackStyledBackground is enabled the plot canvas tries - to seperate the background from the background border - by reverse engeneering to paint the background before and - the border after the plot items. In this order the border - gets prefectly antialiased and you can avoid some pixel - artifacts in the corners. - */ - HackStyledBackground = 4, - - /*! - When ImmediatePaint is set replot() calls repaint() - instead of update(). - - \sa replot(), QWidget::repaint(), QWidget::update() - */ - ImmediatePaint = 8 - }; - - //! Paint attributes - typedef QFlags PaintAttributes; - - /*! - \brief Focus indicator - - - NoFocusIndicator\n - Don't paint a focus indicator - - - CanvasFocusIndicator\n - The focus is related to the complete canvas. - Paint the focus indicator using paintFocus() - - - ItemFocusIndicator\n - The focus is related to an item (curve, point, ...) on - the canvas. It is up to the application to display a - focus indication using f.e. highlighting. - - \sa setFocusIndicator(), focusIndicator(), paintFocus() - */ - - enum FocusIndicator - { - NoFocusIndicator, - CanvasFocusIndicator, - ItemFocusIndicator - }; - - explicit QwtPlotCanvas( QwtPlot * ); - virtual ~QwtPlotCanvas(); - - QwtPlot *plot(); - const QwtPlot *plot() const; - - void setFocusIndicator( FocusIndicator ); - FocusIndicator focusIndicator() const; - - void setBorderRadius( double ); - double borderRadius() const; - - QPainterPath borderPath( const QRect &rect ) const; - QBitmap borderMask( const QSize & ) const; - - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; - - const QPixmap *backingStore() const; - void invalidateBackingStore(); - - void replot(); - - virtual bool event( QEvent * ); - -protected: - virtual void paintEvent( QPaintEvent * ); - virtual void resizeEvent( QResizeEvent * ); - - virtual void drawFocusIndicator( QPainter * ); - virtual void drawBorder( QPainter * ); - - void updateStyleSheetInfo(); - -private: - void drawCanvas( QPainter *, bool withBackground ); - - class PrivateData; - PrivateData *d_data; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCanvas::PaintAttributes ) - -#endif diff --git a/qwt/src/qwt_plot_curve.cpp b/qwt/src/qwt_plot_curve.cpp deleted file mode 100644 index cb786c7c6..000000000 --- a/qwt/src/qwt_plot_curve.cpp +++ /dev/null @@ -1,1123 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_plot_curve.h" -#include "qwt_math.h" -#include "qwt_clipper.h" -#include "qwt_painter.h" -#include "qwt_legend.h" -#include "qwt_legend_item.h" -#include "qwt_scale_map.h" -#include "qwt_plot.h" -#include "qwt_plot_canvas.h" -#include "qwt_curve_fitter.h" -#include "qwt_symbol.h" -#include -#include -#include -#include - -static int verifyRange( int size, int &i1, int &i2 ) -{ - if ( size < 1 ) - return 0; - - i1 = qBound( 0, i1, size - 1 ); - i2 = qBound( 0, i2, size - 1 ); - - if ( i1 > i2 ) - qSwap( i1, i2 ); - - return ( i2 - i1 + 1 ); -} - -class QwtPlotCurve::PrivateData -{ -public: - PrivateData(): - style( QwtPlotCurve::Lines ), - baseline( 0.0 ), - symbol( NULL ), - attributes( 0 ), - paintAttributes( QwtPlotCurve::ClipPolygons ), - legendAttributes( 0 ) - { - pen = QPen( Qt::black ); - curveFitter = new QwtSplineCurveFitter; - } - - ~PrivateData() - { - delete symbol; - delete curveFitter; - } - - QwtPlotCurve::CurveStyle style; - double baseline; - - const QwtSymbol *symbol; - QwtCurveFitter *curveFitter; - - QPen pen; - QBrush brush; - - QwtPlotCurve::CurveAttributes attributes; - QwtPlotCurve::PaintAttributes paintAttributes; - - QwtPlotCurve::LegendAttributes legendAttributes; -}; - -/*! - Constructor - \param title Title of the curve -*/ -QwtPlotCurve::QwtPlotCurve( const QwtText &title ): - QwtPlotSeriesItem( title ) -{ - init(); -} - -/*! - Constructor - \param title Title of the curve -*/ -QwtPlotCurve::QwtPlotCurve( const QString &title ): - QwtPlotSeriesItem( QwtText( title ) ) -{ - init(); -} - -//! Destructor -QwtPlotCurve::~QwtPlotCurve() -{ - delete d_data; -} - -//! Initialize internal members -void QwtPlotCurve::init() -{ - setItemAttribute( QwtPlotItem::Legend ); - setItemAttribute( QwtPlotItem::AutoScale ); - - d_data = new PrivateData; - d_series = new QwtPointSeriesData(); - - setZ( 20.0 ); -} - -//! \return QwtPlotItem::Rtti_PlotCurve -int QwtPlotCurve::rtti() const -{ - return QwtPlotItem::Rtti_PlotCurve; -} - -/*! - Specify an attribute how to draw the curve - - \param attribute Paint attribute - \param on On/Off - \sa testPaintAttribute() -*/ -void QwtPlotCurve::setPaintAttribute( PaintAttribute attribute, bool on ) -{ - if ( on ) - d_data->paintAttributes |= attribute; - else - d_data->paintAttributes &= ~attribute; -} - -/*! - \brief Return the current paint attributes - \sa setPaintAttribute() -*/ -bool QwtPlotCurve::testPaintAttribute( PaintAttribute attribute ) const -{ - return ( d_data->paintAttributes & attribute ); -} - -/*! - Specify an attribute how to draw the legend identifier - - \param attribute Attribute - \param on On/Off - /sa testLegendAttribute() -*/ -void QwtPlotCurve::setLegendAttribute( LegendAttribute attribute, bool on ) -{ - if ( on ) - d_data->legendAttributes |= attribute; - else - d_data->legendAttributes &= ~attribute; -} - -/*! - \brief Return the current paint attributes - \sa setLegendAttribute() -*/ -bool QwtPlotCurve::testLegendAttribute( LegendAttribute attribute ) const -{ - return ( d_data->legendAttributes & attribute ); -} - -/*! - Set the curve's drawing style - - \param style Curve style - \sa style() -*/ -void QwtPlotCurve::setStyle( CurveStyle style ) -{ - if ( style != d_data->style ) - { - d_data->style = style; - itemChanged(); - } -} - -/*! - Return the current style - \sa setStyle() -*/ -QwtPlotCurve::CurveStyle QwtPlotCurve::style() const -{ - return d_data->style; -} - -/*! - Assign a symbol - - \param symbol Symbol - \sa symbol() -*/ -void QwtPlotCurve::setSymbol( const QwtSymbol *symbol ) -{ - if ( symbol != d_data->symbol ) - { - delete d_data->symbol; - d_data->symbol = symbol; - itemChanged(); - } -} - -/*! - \return Current symbol or NULL, when no symbol has been assigned - \sa setSymbol() -*/ -const QwtSymbol *QwtPlotCurve::symbol() const -{ - return d_data->symbol; -} - -/*! - Assign a pen - - \param pen New pen - \sa pen(), brush() -*/ -void QwtPlotCurve::setPen( const QPen &pen ) -{ - if ( pen != d_data->pen ) - { - d_data->pen = pen; - itemChanged(); - } -} - -/*! - \return Pen used to draw the lines - \sa setPen(), brush() -*/ -const QPen& QwtPlotCurve::pen() const -{ - return d_data->pen; -} - -/*! - \brief Assign a brush. - - In case of brush.style() != QBrush::NoBrush - and style() != QwtPlotCurve::Sticks - the area between the curve and the baseline will be filled. - - In case !brush.color().isValid() the area will be filled by - pen.color(). The fill algorithm simply connects the first and the - last curve point to the baseline. So the curve data has to be sorted - (ascending or descending). - - \param brush New brush - \sa brush(), setBaseline(), baseline() -*/ -void QwtPlotCurve::setBrush( const QBrush &brush ) -{ - if ( brush != d_data->brush ) - { - d_data->brush = brush; - itemChanged(); - } -} - -/*! - \return Brush used to fill the area between lines and the baseline - \sa setBrush(), setBaseline(), baseline() -*/ -const QBrush& QwtPlotCurve::brush() const -{ - return d_data->brush; -} - -/*! - Draw an interval of the curve - - \param painter Painter - \param xMap Maps x-values into pixel coordinates. - \param yMap Maps y-values into pixel coordinates. - \param canvasRect Contents rect of the canvas - \param from Index of the first point to be painted - \param to Index of the last point to be painted. If to < 0 the - curve will be painted to its last point. - - \sa drawCurve(), drawSymbols(), -*/ -void QwtPlotCurve::drawSeries( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const -{ - if ( !painter || dataSize() <= 0 ) - return; - - if ( to < 0 ) - to = dataSize() - 1; - - if ( verifyRange( dataSize(), from, to ) > 0 ) - { - painter->save(); - painter->setPen( d_data->pen ); - - /* - Qt 4.0.0 is slow when drawing lines, but it's even - slower when the painter has a brush. So we don't - set the brush before we really need it. - */ - - drawCurve( painter, d_data->style, xMap, yMap, canvasRect, from, to ); - painter->restore(); - - if ( d_data->symbol && - ( d_data->symbol->style() != QwtSymbol::NoSymbol ) ) - { - painter->save(); - drawSymbols( painter, *d_data->symbol, - xMap, yMap, canvasRect, from, to ); - painter->restore(); - } - } -} - -/*! - \brief Draw the line part (without symbols) of a curve interval. - \param painter Painter - \param style curve style, see QwtPlotCurve::CurveStyle - \param xMap x map - \param yMap y map - \param canvasRect Contents rect of the canvas - \param from index of the first point to be painted - \param to index of the last point to be painted - \sa draw(), drawDots(), drawLines(), drawSteps(), drawSticks() -*/ -void QwtPlotCurve::drawCurve( QPainter *painter, int style, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const -{ - switch ( style ) - { - case Lines: - if ( testCurveAttribute( Fitted ) ) - { - // we always need the complete - // curve for fitting - from = 0; - to = dataSize() - 1; - } - drawLines( painter, xMap, yMap, canvasRect, from, to ); - break; - case Sticks: - drawSticks( painter, xMap, yMap, canvasRect, from, to ); - break; - case Steps: - drawSteps( painter, xMap, yMap, canvasRect, from, to ); - break; - case Dots: - drawDots( painter, xMap, yMap, canvasRect, from, to ); - break; - case NoCurve: - default: - break; - } -} - -/*! - \brief Draw lines - - If the CurveAttribute Fitted is enabled a QwtCurveFitter tries - to interpolate/smooth the curve, before it is painted. - - \param painter Painter - \param xMap x map - \param yMap y map - \param canvasRect Contents rect of the canvas - \param from index of the first point to be painted - \param to index of the last point to be painted - - \sa setCurveAttribute(), setCurveFitter(), draw(), - drawLines(), drawDots(), drawSteps(), drawSticks() -*/ -void QwtPlotCurve::drawLines( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const -{ - int size = to - from + 1; - if ( size <= 0 ) - return; - - const bool doAlign = QwtPainter::roundingAlignment( painter ); - - QPolygonF polyline( size ); - - QPointF *points = polyline.data(); - for ( int i = from; i <= to; i++ ) - { - const QPointF sample = d_series->sample( i ); - - double x = xMap.transform( sample.x() ); - double y = yMap.transform( sample.y() ); - if ( doAlign ) - { - x = qRound( x ); - y = qRound( y ); - } - - points[i - from].rx() = x; - points[i - from].ry() = y; - } - - if ( ( d_data->attributes & Fitted ) && d_data->curveFitter ) - polyline = d_data->curveFitter->fitCurve( polyline ); - - if ( d_data->paintAttributes & ClipPolygons ) - { - qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF()); - const QPolygonF clipped = QwtClipper::clipPolygonF( - canvasRect.adjusted(-pw, -pw, pw, pw), polyline, false ); - - QwtPainter::drawPolyline( painter, clipped ); - } - else - { - QwtPainter::drawPolyline( painter, polyline ); - } - - if ( d_data->brush.style() != Qt::NoBrush ) - fillCurve( painter, xMap, yMap, canvasRect, polyline ); -} - -/*! - Draw sticks - - \param painter Painter - \param xMap x map - \param yMap y map - \param canvasRect Contents rect of the canvas - \param from index of the first point to be painted - \param to index of the last point to be painted - - \sa draw(), drawCurve(), drawDots(), drawLines(), drawSteps() -*/ -void QwtPlotCurve::drawSticks( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &, int from, int to ) const -{ - painter->save(); - painter->setRenderHint( QPainter::Antialiasing, false ); - - const bool doAlign = QwtPainter::roundingAlignment( painter ); - - double x0 = xMap.transform( d_data->baseline ); - double y0 = yMap.transform( d_data->baseline ); - if ( doAlign ) - { - x0 = qRound( x0 ); - y0 = qRound( y0 ); - } - - const Qt::Orientation o = orientation(); - - for ( int i = from; i <= to; i++ ) - { - const QPointF sample = d_series->sample( i ); - double xi = xMap.transform( sample.x() ); - double yi = yMap.transform( sample.y() ); - if ( doAlign ) - { - xi = qRound( xi ); - yi = qRound( yi ); - } - - if ( o == Qt::Horizontal ) - QwtPainter::drawLine( painter, x0, yi, xi, yi ); - else - QwtPainter::drawLine( painter, xi, y0, xi, yi ); - } - - painter->restore(); -} - -/*! - Draw dots - - \param painter Painter - \param xMap x map - \param yMap y map - \param canvasRect Contents rect of the canvas - \param from index of the first point to be painted - \param to index of the last point to be painted - - \sa draw(), drawCurve(), drawSticks(), drawLines(), drawSteps() -*/ -void QwtPlotCurve::drawDots( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const -{ - const bool doFill = d_data->brush.style() != Qt::NoBrush; - const bool doAlign = QwtPainter::roundingAlignment( painter ); - - QPolygonF polyline; - if ( doFill ) - polyline.resize( to - from + 1 ); - - QPointF *points = polyline.data(); - - for ( int i = from; i <= to; i++ ) - { - const QPointF sample = d_series->sample( i ); - double xi = xMap.transform( sample.x() ); - double yi = yMap.transform( sample.y() ); - if ( doAlign ) - { - xi = qRound( xi ); - yi = qRound( yi ); - } - - QwtPainter::drawPoint( painter, QPointF( xi, yi ) ); - - if ( doFill ) - { - points[i - from].rx() = xi; - points[i - from].ry() = yi; - } - } - - if ( doFill ) - fillCurve( painter, xMap, yMap, canvasRect, polyline ); -} - -/*! - Draw step function - - The direction of the steps depends on Inverted attribute. - - \param painter Painter - \param xMap x map - \param yMap y map - \param canvasRect Contents rect of the canvas - \param from index of the first point to be painted - \param to index of the last point to be painted - - \sa CurveAttribute, setCurveAttribute(), - draw(), drawCurve(), drawDots(), drawLines(), drawSticks() -*/ -void QwtPlotCurve::drawSteps( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const -{ - const bool doAlign = QwtPainter::roundingAlignment( painter ); - - QPolygonF polygon( 2 * ( to - from ) + 1 ); - QPointF *points = polygon.data(); - - bool inverted = orientation() == Qt::Vertical; - if ( d_data->attributes & Inverted ) - inverted = !inverted; - - int i, ip; - for ( i = from, ip = 0; i <= to; i++, ip += 2 ) - { - const QPointF sample = d_series->sample( i ); - double xi = xMap.transform( sample.x() ); - double yi = yMap.transform( sample.y() ); - if ( doAlign ) - { - xi = qRound( xi ); - yi = qRound( yi ); - } - - if ( ip > 0 ) - { - const QPointF &p0 = points[ip - 2]; - QPointF &p = points[ip - 1]; - - if ( inverted ) - { - p.rx() = p0.x(); - p.ry() = yi; - } - else - { - p.rx() = xi; - p.ry() = p0.y(); - } - } - - points[ip].rx() = xi; - points[ip].ry() = yi; - } - - if ( d_data->paintAttributes & ClipPolygons ) - { - const QPolygonF clipped = QwtClipper::clipPolygonF( - canvasRect, polygon, false ); - - QwtPainter::drawPolyline( painter, clipped ); - } - else - { - QwtPainter::drawPolyline( painter, polygon ); - } - - if ( d_data->brush.style() != Qt::NoBrush ) - fillCurve( painter, xMap, yMap, canvasRect, polygon ); -} - - -/*! - Specify an attribute for drawing the curve - - \param attribute Curve attribute - \param on On/Off - - /sa testCurveAttribute(), setCurveFitter() -*/ -void QwtPlotCurve::setCurveAttribute( CurveAttribute attribute, bool on ) -{ - if ( bool( d_data->attributes & attribute ) == on ) - return; - - if ( on ) - d_data->attributes |= attribute; - else - d_data->attributes &= ~attribute; - - itemChanged(); -} - -/*! - \return true, if attribute is enabled - \sa setCurveAttribute() -*/ -bool QwtPlotCurve::testCurveAttribute( CurveAttribute attribute ) const -{ - return d_data->attributes & attribute; -} - -/*! - Assign a curve fitter - - The curve fitter "smooths" the curve points, when the Fitted - CurveAttribute is set. setCurveFitter(NULL) also disables curve fitting. - - The curve fitter operates on the translated points ( = widget coordinates) - to be functional for logarithmic scales. Obviously this is less performant - for fitting algorithms, that reduce the number of points. - - For situations, where curve fitting is used to improve the performance - of painting huge series of points it might be better to execute the fitter - on the curve points once and to cache the result in the QwtSeriesData object. - - \param curveFitter() Curve fitter - \sa Fitted -*/ -void QwtPlotCurve::setCurveFitter( QwtCurveFitter *curveFitter ) -{ - delete d_data->curveFitter; - d_data->curveFitter = curveFitter; - - itemChanged(); -} - -/*! - Get the curve fitter. If curve fitting is disabled NULL is returned. - - \return Curve fitter - \sa setCurveFitter(), Fitted -*/ -QwtCurveFitter *QwtPlotCurve::curveFitter() const -{ - return d_data->curveFitter; -} - -/*! - Fill the area between the curve and the baseline with - the curve brush - - \param painter Painter - \param xMap x map - \param yMap y map - \param canvasRect Contents rect of the canvas - \param polygon Polygon - will be modified ! - - \sa setBrush(), setBaseline(), setStyle() -*/ -void QwtPlotCurve::fillCurve( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, QPolygonF &polygon ) const -{ - if ( d_data->brush.style() == Qt::NoBrush ) - return; - - closePolyline( painter, xMap, yMap, polygon ); - if ( polygon.count() <= 2 ) // a line can't be filled - return; - - QBrush brush = d_data->brush; - if ( !brush.color().isValid() ) - brush.setColor( d_data->pen.color() ); - - if ( d_data->paintAttributes & ClipPolygons ) - polygon = QwtClipper::clipPolygonF( canvasRect, polygon, true ); - - painter->save(); - - painter->setPen( Qt::NoPen ); - painter->setBrush( brush ); - - QwtPainter::drawPolygon( painter, polygon ); - - painter->restore(); -} - -/*! - \brief Complete a polygon to be a closed polygon including the - area between the original polygon and the baseline. - - \param painter Painter - \param xMap X map - \param yMap Y map - \param polygon Polygon to be completed -*/ -void QwtPlotCurve::closePolyline( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - QPolygonF &polygon ) const -{ - if ( polygon.size() < 2 ) - return; - - const bool doAlign = QwtPainter::roundingAlignment( painter ); - - double baseline = d_data->baseline; - - if ( orientation() == Qt::Vertical ) - { - if ( yMap.transformation()->type() == QwtScaleTransformation::Log10 ) - { - if ( baseline < QwtScaleMap::LogMin ) - baseline = QwtScaleMap::LogMin; - } - - double refY = yMap.transform( baseline ); - if ( doAlign ) - refY = qRound( refY ); - - polygon += QPointF( polygon.last().x(), refY ); - polygon += QPointF( polygon.first().x(), refY ); - } - else - { - if ( xMap.transformation()->type() == QwtScaleTransformation::Log10 ) - { - if ( baseline < QwtScaleMap::LogMin ) - baseline = QwtScaleMap::LogMin; - } - - double refX = xMap.transform( baseline ); - if ( doAlign ) - refX = qRound( refX ); - - polygon += QPointF( refX, polygon.last().y() ); - polygon += QPointF( refX, polygon.first().y() ); - } -} - -/*! - Draw symbols - - \param painter Painter - \param symbol Curve symbol - \param xMap x map - \param yMap y map - \param canvasRect Contents rect of the canvas - \param from Index of the first point to be painted - \param to Index of the last point to be painted - - \sa setSymbol(), drawSeries(), drawCurve() -*/ -void QwtPlotCurve::drawSymbols( QPainter *painter, const QwtSymbol &symbol, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const -{ - const bool doAlign = QwtPainter::roundingAlignment( painter ); - - bool usePixmap = testPaintAttribute( CacheSymbols ); - if ( usePixmap && !doAlign ) - { - // Don't use the pixmap, when the paint device - // could generate scalable vectors - - usePixmap = false; - } - - if ( usePixmap ) - { - QPixmap pm( symbol.boundingSize() ); - pm.fill( Qt::transparent ); - - const double pw2 = 0.5 * pm.width(); - const double ph2 = 0.5 * pm.height(); - - QPainter p( &pm ); - p.setRenderHints( painter->renderHints() ); - symbol.drawSymbol( &p, QPointF( pw2, ph2 ) ); - p.end(); - - for ( int i = from; i <= to; i++ ) - { - const QPointF sample = d_series->sample( i ); - - double xi = xMap.transform( sample.x() ); - double yi = yMap.transform( sample.y() ); - if ( doAlign ) - { - xi = qRound( xi ); - yi = qRound( yi ); - } - - if ( canvasRect.contains( xi, yi ) ) - { - const int left = qCeil( xi ) - pw2; - const int top = qCeil( yi ) - ph2; - - painter->drawPixmap( left, top, pm ); - } - } - } - else - { - const int chunkSize = 500; - - for ( int i = from; i <= to; i += chunkSize ) - { - const int n = qMin( chunkSize, to - i + 1 ); - - QPolygonF points; - for ( int j = 0; j < n; j++ ) - { - const QPointF sample = d_series->sample( i + j ); - - const double xi = xMap.transform( sample.x() ); - const double yi = yMap.transform( sample.y() ); - - if ( canvasRect.contains( xi, yi ) ) - points += QPointF( xi, yi ); - } - - if ( points.size() > 0 ) - symbol.drawSymbols( painter, points ); - } - } -} - -/*! - \brief Set the value of the baseline - - The baseline is needed for filling the curve with a brush or - the Sticks drawing style. - The interpretation of the baseline depends on the CurveType. - With QwtPlotCurve::Yfx, the baseline is interpreted as a horizontal line - at y = baseline(), with QwtPlotCurve::Yfy, it is interpreted as a vertical - line at x = baseline(). - - The default value is 0.0. - - \param value Value of the baseline - \sa baseline(), setBrush(), setStyle(), setStyle() -*/ -void QwtPlotCurve::setBaseline( double value ) -{ - if ( d_data->baseline != value ) - { - d_data->baseline = value; - itemChanged(); - } -} - -/*! - \return Value of the baseline - \sa setBaseline() -*/ -double QwtPlotCurve::baseline() const -{ - return d_data->baseline; -} - -/*! - Find the closest curve point for a specific position - - \param pos Position, where to look for the closest curve point - \param dist If dist != NULL, closestPoint() returns the distance between - the position and the clostest curve point - \return Index of the closest curve point, or -1 if none can be found - ( f.e when the curve has no points ) - \note closestPoint() implements a dumb algorithm, that iterates - over all points -*/ -int QwtPlotCurve::closestPoint( const QPoint &pos, double *dist ) const -{ - if ( plot() == NULL || dataSize() <= 0 ) - return -1; - - const QwtScaleMap xMap = plot()->canvasMap( xAxis() ); - const QwtScaleMap yMap = plot()->canvasMap( yAxis() ); - - int index = -1; - double dmin = 1.0e10; - - for ( uint i = 0; i < dataSize(); i++ ) - { - const QPointF sample = d_series->sample( i ); - - const double cx = xMap.transform( sample.x() ) - pos.x(); - const double cy = yMap.transform( sample.y() ) - pos.y(); - - const double f = qwtSqr( cx ) + qwtSqr( cy ); - if ( f < dmin ) - { - index = i; - dmin = f; - } - } - if ( dist ) - *dist = qSqrt( dmin ); - - return index; -} - -/*! - \brief Update the widget that represents the item on the legend - - \param legend Legend - \sa drawLegendIdentifier(), legendItem(), QwtPlotItem::Legend -*/ -void QwtPlotCurve::updateLegend( QwtLegend *legend ) const -{ - if ( legend && testItemAttribute( QwtPlotItem::Legend ) - && ( d_data->legendAttributes & QwtPlotCurve::LegendShowSymbol ) - && d_data->symbol - && d_data->symbol->style() != QwtSymbol::NoSymbol ) - { - QWidget *lgdItem = legend->find( this ); - if ( lgdItem == NULL ) - { - lgdItem = legendItem(); - if ( lgdItem ) - legend->insert( this, lgdItem ); - } - - QwtLegendItem *l = qobject_cast( lgdItem ); - if ( l ) - { - QSize sz = d_data->symbol->boundingSize(); - sz += QSize( 2, 2 ); // margin - - if ( d_data->legendAttributes & QwtPlotCurve::LegendShowLine ) - { - // Avoid, that the line is completely covered by the symbol - - int w = qCeil( 1.5 * sz.width() ); - if ( w % 2 ) - w++; - - sz.setWidth( qMax( 8, w ) ); - } - - l->setIdentifierSize( sz ); - } - } - - QwtPlotItem::updateLegend( legend ); -} - -/*! - \brief Draw the identifier representing the curve on the legend - - \param painter Painter - \param rect Bounding rectangle for the identifier - - \sa setLegendAttribute(), QwtPlotItem::Legend -*/ -void QwtPlotCurve::drawLegendIdentifier( - QPainter *painter, const QRectF &rect ) const -{ - if ( rect.isEmpty() ) - return; - - const int dim = qMin( rect.width(), rect.height() ); - - QSize size( dim, dim ); - - QRectF r( 0, 0, size.width(), size.height() ); - r.moveCenter( rect.center() ); - - if ( d_data->legendAttributes == 0 ) - { - QBrush brush = d_data->brush; - if ( brush.style() == Qt::NoBrush ) - { - if ( style() != QwtPlotCurve::NoCurve ) - brush = QBrush( pen().color() ); - else if ( d_data->symbol && - ( d_data->symbol->style() != QwtSymbol::NoSymbol ) ) - { - brush = QBrush( d_data->symbol->pen().color() ); - } - } - if ( brush.style() != Qt::NoBrush ) - painter->fillRect( r, brush ); - } - if ( d_data->legendAttributes & QwtPlotCurve::LegendShowBrush ) - { - if ( d_data->brush.style() != Qt::NoBrush ) - painter->fillRect( r, d_data->brush ); - } - if ( d_data->legendAttributes & QwtPlotCurve::LegendShowLine ) - { - if ( pen() != Qt::NoPen ) - { - painter->setPen( pen() ); - QwtPainter::drawLine( painter, rect.left(), rect.center().y(), - rect.right() - 1.0, rect.center().y() ); - } - } - if ( d_data->legendAttributes & QwtPlotCurve::LegendShowSymbol ) - { - if ( d_data->symbol && - ( d_data->symbol->style() != QwtSymbol::NoSymbol ) ) - { - QSize symbolSize = d_data->symbol->boundingSize(); - symbolSize -= QSize( 2, 2 ); - - // scale the symbol size down if it doesn't fit into rect. - - double xRatio = 1.0; - if ( rect.width() < symbolSize.width() ) - xRatio = rect.width() / symbolSize.width(); - double yRatio = 1.0; - if ( rect.height() < symbolSize.height() ) - yRatio = rect.height() / symbolSize.height(); - - const double ratio = qMin( xRatio, yRatio ); - - painter->save(); - painter->scale( ratio, ratio ); - - d_data->symbol->drawSymbol( painter, rect.center() / ratio ); - - painter->restore(); - } - } -} - -/*! - Initialize data with an array of points (explicitly shared). - - \param samples Vector of points -*/ -void QwtPlotCurve::setSamples( const QVector &samples ) -{ - delete d_series; - d_series = new QwtPointSeriesData( samples ); - itemChanged(); -} - -#ifndef QWT_NO_COMPAT - -/*! - \brief Initialize the data by pointing to memory blocks which - are not managed by QwtPlotCurve. - - setRawSamples is provided for efficiency. - It is important to keep the pointers - during the lifetime of the underlying QwtCPointerData class. - - \param xData pointer to x data - \param yData pointer to y data - \param size size of x and y - - \sa QwtCPointerData -*/ -void QwtPlotCurve::setRawSamples( - const double *xData, const double *yData, int size ) -{ - delete d_series; - d_series = new QwtCPointerData( xData, yData, size ); - itemChanged(); -} - -/*! - Set data by copying x- and y-values from specified memory blocks. - Contrary to setRawSamples(), this function makes a 'deep copy' of - the data. - - \param xData pointer to x values - \param yData pointer to y values - \param size size of xData and yData - - \sa QwtPointArrayData -*/ -void QwtPlotCurve::setSamples( - const double *xData, const double *yData, int size ) -{ - delete d_series; - d_series = new QwtPointArrayData( xData, yData, size ); - itemChanged(); -} - -/*! - \brief Initialize data with x- and y-arrays (explicitly shared) - - \param xData x data - \param yData y data - - \sa QwtPointArrayData -*/ -void QwtPlotCurve::setSamples( const QVector &xData, - const QVector &yData ) -{ - delete d_series; - d_series = new QwtPointArrayData( xData, yData ); - itemChanged(); -} -#endif // !QWT_NO_COMPAT diff --git a/qwt/src/qwt_plot_curve.h b/qwt/src/qwt_plot_curve.h deleted file mode 100644 index e42a4c38c..000000000 --- a/qwt/src/qwt_plot_curve.h +++ /dev/null @@ -1,319 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_PLOT_CURVE_H -#define QWT_PLOT_CURVE_H - -#include "qwt_global.h" -#include "qwt_plot_seriesitem.h" -#include "qwt_series_data.h" -#include "qwt_text.h" -#include -#include - -class QPainter; -class QPolygonF; -class QwtScaleMap; -class QwtSymbol; -class QwtCurveFitter; - -/*! - \brief A plot item, that represents a series of points - - A curve is the representation of a series of points in the x-y plane. - It supports different display styles, interpolation ( f.e. spline ) - and symbols. - - \par Usage -
a) Assign curve properties
-
When a curve is created, it is configured to draw black solid lines - with in QwtPlotCurve::Lines style and no symbols. - You can change this by calling - setPen(), setStyle() and setSymbol().
-
b) Connect/Assign data.
-
QwtPlotCurve gets its points using a QwtSeriesData object offering - a bridge to the real storage of the points ( like QAbstractItemModel ). - There are several convenience classes derived from QwtSeriesData, that also store - the points inside ( like QStandardItemModel ). QwtPlotCurve also offers - a couple of variations of setSamples(), that build QwtSeriesData objects from - arrays internally.
-
c) Attach the curve to a plot
-
See QwtPlotItem::attach() -
- - \par Example: - see examples/bode - - \sa QwtPointSeriesData, QwtSymbol, QwtScaleMap -*/ -class QWT_EXPORT QwtPlotCurve: public QwtPlotSeriesItem -{ -public: - /*! - Curve styles. - \sa setStyle(), style() - */ - enum CurveStyle - { - /*! - Don't draw a curve. Note: This doesn't affect the symbols. - */ - NoCurve = -1, - - /*! - Connect the points with straight lines. The lines might - be interpolated depending on the 'Fitted' attribute. Curve - fitting can be configured using setCurveFitter(). - */ - Lines, - - /*! - Draw vertical or horizontal sticks ( depending on the - orientation() ) from a baseline which is defined by setBaseline(). - */ - Sticks, - - /*! - Connect the points with a step function. The step function - is drawn from the left to the right or vice versa, - depending on the QwtPlotCurve::Inverted attribute. - */ - Steps, - - /*! - Draw dots at the locations of the data points. Note: - This is different from a dotted line (see setPen()), and faster - as a curve in QwtPlotCurve::NoStyle style and a symbol - painting a point. - */ - Dots, - - /*! - Styles >= QwtPlotCurve::UserCurve are reserved for derived - classes of QwtPlotCurve that overload drawCurve() with - additional application specific curve types. - */ - UserCurve = 100 - }; - - /*! - Attribute for drawing the curve - \sa setCurveAttribute(), testCurveAttribute(), curveFitter() - */ - enum CurveAttribute - { - /*! - For QwtPlotCurve::Steps only. - Draws a step function from the right to the left. - */ - Inverted = 0x01, - - /*! - Only in combination with QwtPlotCurve::Lines - A QwtCurveFitter tries to - interpolate/smooth the curve, before it is painted. - - \note Curve fitting requires temorary memory - for calculating coefficients and additional points. - If painting in QwtPlotCurve::Fitted mode is slow it might be better - to fit the points, before they are passed to QwtPlotCurve. - */ - Fitted = 0x02 - }; - - //! Curve attributes - typedef QFlags CurveAttributes; - - /*! - Attributes how to represent the curve on the legend - - \sa setLegendAttribute(), testLegendAttribute(), - drawLegendIdentifier() - */ - - enum LegendAttribute - { - /*! - QwtPlotCurve tries to find a color representing the curve - and paints a rectangle with it. - */ - LegendNoAttribute = 0x00, - - /*! - If the style() is not QwtPlotCurve::NoCurve a line - is painted with the curve pen(). - */ - LegendShowLine = 0x01, - - /*! - If the curve has a valid symbol it is painted. - */ - LegendShowSymbol = 0x02, - - /*! - If the curve has a brush a rectangle filled with the - curve brush() is painted. - */ - LegendShowBrush = 0x04 - }; - - //! Legend attributes - typedef QFlags LegendAttributes; - - /*! - Attributes to modify the drawing algorithm. - The default setting enables ClipPolygons - - \sa setPaintAttribute(), testPaintAttribute() - */ - enum PaintAttribute - { - /*! - Clip polygons before painting them. In situations, where points - are far outside the visible area (f.e when zooming deep) this - might be a substantial improvement for the painting performance - */ - ClipPolygons = 0x01, - - /*! - Paint the symbol to a QPixmap and paint the pixmap - instead rendering the symbol for each point. The flag has - no effect, when the curve is not painted to the canvas - ( f.e when exporting the plot to a PDF document ). - */ - CacheSymbols = 0x02 - }; - - //! Paint attributes - typedef QFlags PaintAttributes; - - explicit QwtPlotCurve( const QString &title = QString::null ); - explicit QwtPlotCurve( const QwtText &title ); - - virtual ~QwtPlotCurve(); - - virtual int rtti() const; - - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; - - void setLegendAttribute( LegendAttribute, bool on = true ); - bool testLegendAttribute( LegendAttribute ) const; - -#ifndef QWT_NO_COMPAT - void setRawSamples( const double *xData, const double *yData, int size ); - void setSamples( const double *xData, const double *yData, int size ); - void setSamples( const QVector &xData, const QVector &yData ); -#endif - void setSamples( const QVector & ); - - int closestPoint( const QPoint &pos, double *dist = NULL ) const; - - double minXValue() const; - double maxXValue() const; - double minYValue() const; - double maxYValue() const; - - void setCurveAttribute( CurveAttribute, bool on = true ); - bool testCurveAttribute( CurveAttribute ) const; - - void setPen( const QPen & ); - const QPen &pen() const; - - void setBrush( const QBrush & ); - const QBrush &brush() const; - - void setBaseline( double ref ); - double baseline() const; - - void setStyle( CurveStyle style ); - CurveStyle style() const; - - void setSymbol( const QwtSymbol *s ); - const QwtSymbol *symbol() const; - - void setCurveFitter( QwtCurveFitter * ); - QwtCurveFitter *curveFitter() const; - - virtual void drawSeries( QPainter *, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const; - - virtual void updateLegend( QwtLegend * ) const; - virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const; - -protected: - - void init(); - - virtual void drawCurve( QPainter *p, int style, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const; - - virtual void drawSymbols( QPainter *p, const QwtSymbol &, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const; - - void drawLines( QPainter *p, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const; - - void drawSticks( QPainter *p, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const; - - void drawDots( QPainter *p, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const; - - void drawSteps( QPainter *p, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const; - - virtual void fillCurve( QPainter *, - const QwtScaleMap &, const QwtScaleMap &, - const QRectF &canvasRect, QPolygonF & ) const; - - void closePolyline( QPainter *, - const QwtScaleMap &, const QwtScaleMap &, QPolygonF & ) const; - -private: - class PrivateData; - PrivateData *d_data; -}; - -//! boundingRect().left() -inline double QwtPlotCurve::minXValue() const -{ - return boundingRect().left(); -} - -//! boundingRect().right() -inline double QwtPlotCurve::maxXValue() const -{ - return boundingRect().right(); -} - -//! boundingRect().top() -inline double QwtPlotCurve::minYValue() const -{ - return boundingRect().top(); -} - -//! boundingRect().bottom() -inline double QwtPlotCurve::maxYValue() const -{ - return boundingRect().bottom(); -} - -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::PaintAttributes ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::LegendAttributes ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCurve::CurveAttributes ) - -#endif diff --git a/qwt/src/qwt_plot_dict.cpp b/qwt/src/qwt_plot_dict.cpp deleted file mode 100644 index 4125137e8..000000000 --- a/qwt/src/qwt_plot_dict.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_plot_dict.h" - -class QwtPlotDict::PrivateData -{ -public: - - class ItemList: public QList - { - public: - void insertItem( QwtPlotItem *item ) - { - if ( item == NULL ) - return; - - QList::iterator it = - qUpperBound( begin(), end(), item, LessZThan() ); - insert( it, item ); - } - - void removeItem( QwtPlotItem *item ) - { - if ( item == NULL ) - return; - - QList::iterator it = - qLowerBound( begin(), end(), item, LessZThan() ); - - for ( ; it != end(); ++it ) - { - if ( item == *it ) - { - erase( it ); - break; - } - } - } - private: - class LessZThan - { - public: - inline bool operator()( const QwtPlotItem *item1, - const QwtPlotItem *item2 ) const - { - return item1->z() < item2->z(); - } - }; - }; - - ItemList itemList; - bool autoDelete; -}; - -/*! - Constructor - - Auto deletion is enabled. - \sa setAutoDelete(), attachItem() -*/ -QwtPlotDict::QwtPlotDict() -{ - d_data = new QwtPlotDict::PrivateData; - d_data->autoDelete = true; -} - -/*! - Destructor - - If autoDelete is on, all attached items will be deleted - \sa setAutoDelete(), autoDelete(), attachItem() -*/ -QwtPlotDict::~QwtPlotDict() -{ - detachItems( QwtPlotItem::Rtti_PlotItem, d_data->autoDelete ); - delete d_data; -} - -/*! - En/Disable Auto deletion - - If Auto deletion is on all attached plot items will be deleted - in the destructor of QwtPlotDict. The default value is on. - - \sa autoDelete(), attachItem() -*/ -void QwtPlotDict::setAutoDelete( bool autoDelete ) -{ - d_data->autoDelete = autoDelete; -} - -/*! - \return true if auto deletion is enabled - \sa setAutoDelete(), attachItem() -*/ -bool QwtPlotDict::autoDelete() const -{ - return d_data->autoDelete; -} - -/*! - Attach/Detach a plot item - - Attached items will be deleted in the destructor, - if auto deletion is enabled (default). Manually detached - items are not deleted. - - \param item Plot item to attach/detach - \ on If true attach, else detach the item - - \sa setAutoDelete(), ~QwtPlotDict() -*/ -void QwtPlotDict::attachItem( QwtPlotItem *item, bool on ) -{ - if ( on ) - d_data->itemList.insertItem( item ); - else - d_data->itemList.removeItem( item ); -} - -/*! - Detach items from the dictionary - - \param rtti In case of QwtPlotItem::Rtti_PlotItem detach all items - otherwise only those items of the type rtti. - \param autoDelete If true, delete all detached items -*/ -void QwtPlotDict::detachItems( int rtti, bool autoDelete ) -{ - PrivateData::ItemList list = d_data->itemList; - QwtPlotItemIterator it = list.begin(); - while ( it != list.end() ) - { - QwtPlotItem *item = *it; - - ++it; // increment before removing item from the list - - if ( rtti == QwtPlotItem::Rtti_PlotItem || item->rtti() == rtti ) - { - item->attach( NULL ); - if ( autoDelete ) - delete item; - } - } -} - -/*! - \brief A QwtPlotItemList of all attached plot items. - - Use caution when iterating these lists, as removing/detaching an item will - invalidate the iterator. Instead you can place pointers to objects to be - removed in a removal list, and traverse that list later. - - \return List of all attached plot items. -*/ -const QwtPlotItemList &QwtPlotDict::itemList() const -{ - return d_data->itemList; -} - -/*! - \return List of all attached plot items of a specific type. - \sa QwtPlotItem::rtti() -*/ -QwtPlotItemList QwtPlotDict::itemList( int rtti ) const -{ - if ( rtti == QwtPlotItem::Rtti_PlotItem ) - return d_data->itemList; - - QwtPlotItemList items; - - PrivateData::ItemList list = d_data->itemList; - for ( QwtPlotItemIterator it = list.begin(); it != list.end(); ++it ) - { - QwtPlotItem *item = *it; - if ( item->rtti() == rtti ) - items += item; - } - - return items; -} diff --git a/qwt/src/qwt_plot_dict.h b/qwt/src/qwt_plot_dict.h deleted file mode 100644 index f68c80b10..000000000 --- a/qwt/src/qwt_plot_dict.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -/*! \file !*/ -#ifndef QWT_PLOT_DICT -#define QWT_PLOT_DICT - -#include "qwt_global.h" -#include "qwt_plot_item.h" -#include - -/// \var typedef QList< QwtPlotItem *> QwtPlotItemList -/// \brief See QT 4.x assistant documentation for QList -typedef QList QwtPlotItemList; -typedef QList::ConstIterator QwtPlotItemIterator; - -/*! - \brief A dictionary for plot items - - QwtPlotDict organizes plot items in increasing z-order. - If autoDelete() is enabled, all attached items will be deleted - in the destructor of the dictionary. - - \sa QwtPlotItem::attach(), QwtPlotItem::detach(), QwtPlotItem::z() -*/ -class QWT_EXPORT QwtPlotDict -{ -public: - explicit QwtPlotDict(); - virtual ~QwtPlotDict(); - - void setAutoDelete( bool ); - bool autoDelete() const; - - const QwtPlotItemList& itemList() const; - QwtPlotItemList itemList( int rtti ) const; - - void detachItems( int rtti = QwtPlotItem::Rtti_PlotItem, - bool autoDelete = true ); - -private: - friend class QwtPlotItem; - - void attachItem( QwtPlotItem *, bool ); - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_plot_directpainter.cpp b/qwt/src/qwt_plot_directpainter.cpp deleted file mode 100644 index 8ae82324a..000000000 --- a/qwt/src/qwt_plot_directpainter.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_plot_directpainter.h" -#include "qwt_scale_map.h" -#include "qwt_plot.h" -#include "qwt_plot_canvas.h" -#include "qwt_plot_seriesitem.h" -#include -#include -#include -#include - -static inline void renderItem( - QPainter *painter, const QRect &canvasRect, - QwtPlotAbstractSeriesItem *seriesItem, int from, int to ) -{ - // A minor performance improvement is possible - // with caching the maps. TODO ... - - QwtPlot *plot = seriesItem->plot(); - const QwtScaleMap xMap = plot->canvasMap( seriesItem->xAxis() ); - const QwtScaleMap yMap = plot->canvasMap( seriesItem->yAxis() ); - - painter->setRenderHint( QPainter::Antialiasing, - seriesItem->testRenderHint( QwtPlotItem::RenderAntialiased ) ); - seriesItem->drawSeries( painter, xMap, yMap, canvasRect, from, to ); -} - -class QwtPlotDirectPainter::PrivateData -{ -public: - PrivateData(): - attributes( 0 ), - hasClipping(false), - seriesItem( NULL ) - { - } - - QwtPlotDirectPainter::Attributes attributes; - - bool hasClipping; - QRegion clipRegion; - - QPainter painter; - - QwtPlotAbstractSeriesItem *seriesItem; - int from; - int to; -}; - -//! Constructor -QwtPlotDirectPainter::QwtPlotDirectPainter( QObject *parent ): - QObject( parent ) -{ - d_data = new PrivateData; -} - -//! Destructor -QwtPlotDirectPainter::~QwtPlotDirectPainter() -{ - delete d_data; -} - -/*! - Change an attribute - - \param attribute Attribute to change - \param on On/Off - - \sa Attribute, testAttribute() -*/ -void QwtPlotDirectPainter::setAttribute( Attribute attribute, bool on ) -{ - if ( bool( d_data->attributes & attribute ) != on ) - { - if ( on ) - d_data->attributes |= attribute; - else - d_data->attributes &= ~attribute; - - if ( ( attribute == AtomicPainter ) && on ) - reset(); - } -} - -/*! - Check if a attribute is set. - - \param attribute Attribute to be tested - \sa Attribute, setAttribute() -*/ -bool QwtPlotDirectPainter::testAttribute( Attribute attribute ) const -{ - return d_data->attributes & attribute; -} - -/*! - En/Disables clipping - - \param enable Enables clipping is true, disable it otherwise - \sa hasClipping(), clipRegion(), setClipRegion() -*/ -void QwtPlotDirectPainter::setClipping( bool enable ) -{ - d_data->hasClipping = enable; -} - -/*! - \return true, when clipping is enabled - \sa setClipping(), clipRegion(), setClipRegion() -*/ -bool QwtPlotDirectPainter::hasClipping() const -{ - return d_data->hasClipping; -} - -/*! - \brief Assign a clip region and enable clipping - - Depending on the environment setting a proper clip region might improve - the performance heavily. F.e. on Qt embedded only the clipped part of - the backing store will be copied to a ( maybe unaccelerated ) frame buffer - device. - - \param region Clip region - \sa clipRegion(), hasClipping(), setClipping() -*/ -void QwtPlotDirectPainter::setClipRegion( const QRegion ®ion ) -{ - d_data->clipRegion = region; - d_data->hasClipping = true; -} - -/*! - \return Currently set clip region. - \sa setClipRegion(), setClipping(), hasClipping() -*/ -QRegion QwtPlotDirectPainter::clipRegion() const -{ - return d_data->clipRegion; -} - -/*! - \brief Draw a set of points of a seriesItem. - - When observing an measurement while it is running, new points have to be - added to an existing seriesItem. drawSeries can be used to display them avoiding - a complete redraw of the canvas. - - Setting plot()->canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true); - will result in faster painting, if the paint engine of the canvas widget - supports this feature. - - \param seriesItem Item to be painted - \param from Index of the first point to be painted - \param to Index of the last point to be painted. If to < 0 the - series will be painted to its last point. -*/ -void QwtPlotDirectPainter::drawSeries( - QwtPlotAbstractSeriesItem *seriesItem, int from, int to ) -{ - if ( seriesItem == NULL || seriesItem->plot() == NULL ) - return; - - QwtPlotCanvas *canvas = seriesItem->plot()->canvas(); - const QRect canvasRect = canvas->contentsRect(); - - const bool hasBackingStore = - canvas->testPaintAttribute( QwtPlotCanvas::BackingStore ) - && canvas->backingStore() && !canvas->backingStore()->isNull(); - - if ( hasBackingStore ) - { - QPainter painter( const_cast( canvas->backingStore() ) ); - painter.translate( -canvasRect.x(), -canvasRect.y() ); - - if ( d_data->hasClipping ) - painter.setClipRegion( d_data->clipRegion ); - - renderItem( &painter, canvasRect, seriesItem, from, to ); - - if ( testAttribute( QwtPlotDirectPainter::FullRepaint ) ) - { - canvas->repaint(); - return; - } - } - - bool immediatePaint = true; - if ( !canvas->testAttribute( Qt::WA_WState_InPaintEvent ) && - !canvas->testAttribute( Qt::WA_PaintOutsidePaintEvent ) ) - { - immediatePaint = false; - } - - if ( immediatePaint ) - { - QwtPlotCanvas *canvas = seriesItem->plot()->canvas(); - if ( !d_data->painter.isActive() ) - { - reset(); - - d_data->painter.begin( canvas ); - canvas->installEventFilter( this ); - } - - if ( d_data->hasClipping ) - { - d_data->painter.setClipRegion( - QRegion( canvasRect ) & d_data->clipRegion ); - } - else - { - if ( !d_data->painter.hasClipping() ) - d_data->painter.setClipRect( canvasRect ); - } - - renderItem( &d_data->painter, canvasRect, seriesItem, from, to ); - - if ( d_data->attributes & QwtPlotDirectPainter::AtomicPainter ) - { - reset(); - } - else - { - if ( d_data->hasClipping ) - d_data->painter.setClipping( false ); - } - } - else - { - reset(); - - d_data->seriesItem = seriesItem; - d_data->from = from; - d_data->to = to; - - QRegion clipRegion = canvasRect; - if ( d_data->hasClipping ) - clipRegion &= d_data->clipRegion; - - canvas->installEventFilter( this ); - canvas->repaint(clipRegion); - canvas->removeEventFilter( this ); - - d_data->seriesItem = NULL; - } -} - -//! Close the internal QPainter -void QwtPlotDirectPainter::reset() -{ - if ( d_data->painter.isActive() ) - { - QWidget *w = ( QWidget * )d_data->painter.device(); - if ( w ) - w->removeEventFilter( this ); - - d_data->painter.end(); - } -} - -//! Event filter -bool QwtPlotDirectPainter::eventFilter( QObject *, QEvent *event ) -{ - if ( event->type() == QEvent::Paint ) - { - reset(); - - if ( d_data->seriesItem ) - { - const QPaintEvent *pe = static_cast< QPaintEvent *>( event ); - - QwtPlotCanvas *canvas = d_data->seriesItem->plot()->canvas(); - - QPainter painter( canvas ); - painter.setClipRegion( pe->region() ); - - bool copyCache = testAttribute( CopyBackingStore ) - && canvas->testPaintAttribute( QwtPlotCanvas::BackingStore ); - - if ( copyCache ) - { - // is something valid in the cache ? - copyCache = ( canvas->backingStore() != NULL ) - && !canvas->backingStore()->isNull(); - } - - if ( copyCache ) - { - painter.drawPixmap( - canvas->contentsRect().topLeft(), - *canvas->backingStore() ); - } - else - { - renderItem( &painter, canvas->contentsRect(), - d_data->seriesItem, d_data->from, d_data->to ); - } - - return true; // don't call QwtPlotCanvas::paintEvent() - } - } - - return false; -} diff --git a/qwt/src/qwt_plot_directpainter.h b/qwt/src/qwt_plot_directpainter.h deleted file mode 100644 index 293278de3..000000000 --- a/qwt/src/qwt_plot_directpainter.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_PLOT_DIRECT_PAINTER_H -#define QWT_PLOT_DIRECT_PAINTER_H - -#include "qwt_global.h" -#include - -class QRegion; -class QwtPlotAbstractSeriesItem; - -/*! - \brief Painter object trying to paint incrementally - - Often applications want to display samples while they are - collected. When there are too many samples complete replots - will be expensive to be processed in a collection cycle. - - QwtPlotDirectPainter offers an API to paint - subsets ( f.e all additions points ) without erasing/repainting - the plot canvas. - - On certain environments it might be important to calculate a proper - clip region before painting. F.e. for Qt Embedded only the clipped part - of the backing store will be copied to a ( maybe unaccelerated ) - frame buffer. - - \warning Incremental painting will only help when no replot is triggered - by another operation ( like changing scales ) and nothing needs - to be erased. -*/ -class QWT_EXPORT QwtPlotDirectPainter: public QObject -{ -public: - /*! - \brief Paint attributes - \sa setAttribute(), testAttribute(), drawSeries() - */ - enum Attribute - { - /*! - Initializing a QPainter is an expensive operation. - When AtomicPainter is set each call of drawSeries() opens/closes - a temporary QPainter. Otherwise QwtPlotDirectPainter tries to - use the same QPainter as long as possible. - */ - AtomicPainter = 0x01, - - /*! - When FullRepaint is set the plot canvas is explicitely repainted - after the samples have been rendered. - */ - FullRepaint = 0x02, - - /*! - When QwtPlotCanvas::BackingStore is enabled the painter - has to paint to the backing store and the widget. In certain - situations/environments it might be faster to paint to - the backing store only and then copy the backingstore to the canvas. - This flag can also be useful for settings, where Qt fills the - the clip region with the widget background. - */ - CopyBackingStore = 0x04 - }; - - //! Paint attributes - typedef QFlags Attributes; - - QwtPlotDirectPainter( QObject *parent = NULL ); - virtual ~QwtPlotDirectPainter(); - - void setAttribute( Attribute, bool on ); - bool testAttribute( Attribute ) const; - - void setClipping( bool ); - bool hasClipping() const; - - void setClipRegion( const QRegion & ); - QRegion clipRegion() const; - - void drawSeries( QwtPlotAbstractSeriesItem *, int from, int to ); - void reset(); - - virtual bool eventFilter( QObject *, QEvent * ); - -private: - class PrivateData; - PrivateData *d_data; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotDirectPainter::Attributes ) - -#endif diff --git a/qwt/src/qwt_plot_grid.cpp b/qwt/src/qwt_plot_grid.cpp deleted file mode 100644 index 8e25aebaa..000000000 --- a/qwt/src/qwt_plot_grid.cpp +++ /dev/null @@ -1,367 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_plot_grid.h" -#include "qwt_painter.h" -#include "qwt_text.h" -#include "qwt_scale_map.h" -#include "qwt_scale_div.h" -#include "qwt_math.h" -#include -#include - -class QwtPlotGrid::PrivateData -{ -public: - PrivateData(): - xEnabled( true ), - yEnabled( true ), - xMinEnabled( false ), - yMinEnabled( false ) - { - } - - bool xEnabled; - bool yEnabled; - bool xMinEnabled; - bool yMinEnabled; - - QwtScaleDiv xScaleDiv; - QwtScaleDiv yScaleDiv; - - QPen majPen; - QPen minPen; -}; - -//! Enables major grid, disables minor grid -QwtPlotGrid::QwtPlotGrid(): - QwtPlotItem( QwtText( "Grid" ) ) -{ - d_data = new PrivateData; - setZ( 10.0 ); -} - -//! Destructor -QwtPlotGrid::~QwtPlotGrid() -{ - delete d_data; -} - -//! \return QwtPlotItem::Rtti_PlotGrid -int QwtPlotGrid::rtti() const -{ - return QwtPlotItem::Rtti_PlotGrid; -} - -/*! - \brief Enable or disable vertical gridlines - \param tf Enable (true) or disable - - \sa Minor gridlines can be enabled or disabled with - enableXMin() -*/ -void QwtPlotGrid::enableX( bool tf ) -{ - if ( d_data->xEnabled != tf ) - { - d_data->xEnabled = tf; - itemChanged(); - } -} - -/*! - \brief Enable or disable horizontal gridlines - \param tf Enable (true) or disable - \sa Minor gridlines can be enabled or disabled with enableYMin() -*/ -void QwtPlotGrid::enableY( bool tf ) -{ - if ( d_data->yEnabled != tf ) - { - d_data->yEnabled = tf; - itemChanged(); - } -} - -/*! - \brief Enable or disable minor vertical gridlines. - \param tf Enable (true) or disable - \sa enableX() -*/ -void QwtPlotGrid::enableXMin( bool tf ) -{ - if ( d_data->xMinEnabled != tf ) - { - d_data->xMinEnabled = tf; - itemChanged(); - } -} - -/*! - \brief Enable or disable minor horizontal gridlines - \param tf Enable (true) or disable - \sa enableY() -*/ -void QwtPlotGrid::enableYMin( bool tf ) -{ - if ( d_data->yMinEnabled != tf ) - { - d_data->yMinEnabled = tf; - itemChanged(); - } -} - -/*! - Assign an x axis scale division - - \param scaleDiv Scale division -*/ -void QwtPlotGrid::setXDiv( const QwtScaleDiv &scaleDiv ) -{ - if ( d_data->xScaleDiv != scaleDiv ) - { - d_data->xScaleDiv = scaleDiv; - itemChanged(); - } -} - -/*! - Assign a y axis division - - \param scaleDiv Scale division -*/ -void QwtPlotGrid::setYDiv( const QwtScaleDiv &scaleDiv ) -{ - if ( d_data->yScaleDiv != scaleDiv ) - { - d_data->yScaleDiv = scaleDiv; - itemChanged(); - } -} - -/*! - Assign a pen for both major and minor gridlines - - \param pen Pen - \sa setMajPen(), setMinPen() -*/ -void QwtPlotGrid::setPen( const QPen &pen ) -{ - if ( d_data->majPen != pen || d_data->minPen != pen ) - { - d_data->majPen = pen; - d_data->minPen = pen; - itemChanged(); - } -} - -/*! - Assign a pen for the major gridlines - - \param pen Pen - \sa majPen(), setMinPen(), setPen() -*/ -void QwtPlotGrid::setMajPen( const QPen &pen ) -{ - if ( d_data->majPen != pen ) - { - d_data->majPen = pen; - itemChanged(); - } -} - -/*! - Assign a pen for the minor gridlines - - \param pen Pen - \sa minPen(), setMajPen(), setPen() -*/ -void QwtPlotGrid::setMinPen( const QPen &pen ) -{ - if ( d_data->minPen != pen ) - { - d_data->minPen = pen; - itemChanged(); - } -} - -/*! - \brief Draw the grid - - The grid is drawn into the bounding rectangle such that - gridlines begin and end at the rectangle's borders. The X and Y - maps are used to map the scale divisions into the drawing region - screen. - \param painter Painter - \param xMap X axis map - \param yMap Y axis - \param canvasRect Contents rect of the plot canvas -*/ -void QwtPlotGrid::draw( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect ) const -{ - // draw minor gridlines - QPen minPen = d_data->minPen; - minPen.setCapStyle( Qt::FlatCap ); - - painter->setPen( minPen ); - - if ( d_data->xEnabled && d_data->xMinEnabled ) - { - drawLines( painter, canvasRect, Qt::Vertical, xMap, - d_data->xScaleDiv.ticks( QwtScaleDiv::MinorTick ) ); - drawLines( painter, canvasRect, Qt::Vertical, xMap, - d_data->xScaleDiv.ticks( QwtScaleDiv::MediumTick ) ); - } - - if ( d_data->yEnabled && d_data->yMinEnabled ) - { - drawLines( painter, canvasRect, Qt::Horizontal, yMap, - d_data->yScaleDiv.ticks( QwtScaleDiv::MinorTick ) ); - drawLines( painter, canvasRect, Qt::Horizontal, yMap, - d_data->yScaleDiv.ticks( QwtScaleDiv::MediumTick ) ); - } - - // draw major gridlines - QPen majPen = d_data->majPen; - majPen.setCapStyle( Qt::FlatCap ); - - painter->setPen( majPen ); - - if ( d_data->xEnabled ) - { - drawLines( painter, canvasRect, Qt::Vertical, xMap, - d_data->xScaleDiv.ticks( QwtScaleDiv::MajorTick ) ); - } - - if ( d_data->yEnabled ) - { - drawLines( painter, canvasRect, Qt::Horizontal, yMap, - d_data->yScaleDiv.ticks( QwtScaleDiv::MajorTick ) ); - } -} - -void QwtPlotGrid::drawLines( QPainter *painter, const QRectF &canvasRect, - Qt::Orientation orientation, const QwtScaleMap &scaleMap, - const QList &values ) const -{ - const double x1 = canvasRect.left(); - const double x2 = canvasRect.right() - 1.0; - const double y1 = canvasRect.top(); - const double y2 = canvasRect.bottom() - 1.0; - - const bool doAlign = QwtPainter::roundingAlignment( painter ); - - for ( int i = 0; i < values.count(); i++ ) - { - double value = scaleMap.transform( values[i] ); - if ( doAlign ) - value = qRound( value ); - - if ( orientation == Qt::Horizontal ) - { - if ( qwtFuzzyGreaterOrEqual( value, y1 ) && - qwtFuzzyLessOrEqual( value, y2 ) ) - { - QwtPainter::drawLine( painter, x1, value, x2, value ); - } - } - else - { - if ( qwtFuzzyGreaterOrEqual( value, x1 ) && - qwtFuzzyLessOrEqual( value, x2 ) ) - { - QwtPainter::drawLine( painter, value, y1, value, y2 ); - } - } - } -} - -/*! - \return the pen for the major gridlines - \sa setMajPen(), setMinPen(), setPen() -*/ -const QPen &QwtPlotGrid::majPen() const -{ - return d_data->majPen; -} - -/*! - \return the pen for the minor gridlines - \sa setMinPen(), setMajPen(), setPen() -*/ -const QPen &QwtPlotGrid::minPen() const -{ - return d_data->minPen; -} - -/*! - \return true if vertical gridlines are enabled - \sa enableX() -*/ -bool QwtPlotGrid::xEnabled() const -{ - return d_data->xEnabled; -} - -/*! - \return true if minor vertical gridlines are enabled - \sa enableXMin() -*/ -bool QwtPlotGrid::xMinEnabled() const -{ - return d_data->xMinEnabled; -} - -/*! - \return true if horizontal gridlines are enabled - \sa enableY() -*/ -bool QwtPlotGrid::yEnabled() const -{ - return d_data->yEnabled; -} - -/*! - \return true if minor horizontal gridlines are enabled - \sa enableYMin() -*/ -bool QwtPlotGrid::yMinEnabled() const -{ - return d_data->yMinEnabled; -} - - -/*! \return the scale division of the x axis */ -const QwtScaleDiv &QwtPlotGrid::xScaleDiv() const -{ - return d_data->xScaleDiv; -} - -/*! \return the scale division of the y axis */ -const QwtScaleDiv &QwtPlotGrid::yScaleDiv() const -{ - return d_data->yScaleDiv; -} - -/*! - Update the grid to changes of the axes scale division - - \param xScaleDiv Scale division of the x-axis - \param yScaleDiv Scale division of the y-axis - - \sa QwtPlot::updateAxes() -*/ -void QwtPlotGrid::updateScaleDiv( const QwtScaleDiv& xScaleDiv, - const QwtScaleDiv& yScaleDiv ) -{ - setXDiv( xScaleDiv ); - setYDiv( yScaleDiv ); -} diff --git a/qwt/src/qwt_plot_grid.h b/qwt/src/qwt_plot_grid.h deleted file mode 100644 index c8278abc9..000000000 --- a/qwt/src/qwt_plot_grid.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_PLOT_GRID_H -#define QWT_PLOT_GRID_H - -#include "qwt_global.h" -#include "qwt_plot_item.h" -#include "qwt_scale_div.h" - -class QPainter; -class QPen; -class QwtScaleMap; -class QwtScaleDiv; - -/*! - \brief A class which draws a coordinate grid - - The QwtPlotGrid class can be used to draw a coordinate grid. - A coordinate grid consists of major and minor vertical - and horizontal gridlines. The locations of the gridlines - are determined by the X and Y scale divisions which can - be assigned with setXDiv() and setYDiv(). - The draw() member draws the grid within a bounding - rectangle. -*/ - -class QWT_EXPORT QwtPlotGrid: public QwtPlotItem -{ -public: - explicit QwtPlotGrid(); - virtual ~QwtPlotGrid(); - - virtual int rtti() const; - - void enableX( bool tf ); - bool xEnabled() const; - - void enableY( bool tf ); - bool yEnabled() const; - - void enableXMin( bool tf ); - bool xMinEnabled() const; - - void enableYMin( bool tf ); - bool yMinEnabled() const; - - void setXDiv( const QwtScaleDiv &sx ); - const QwtScaleDiv &xScaleDiv() const; - - void setYDiv( const QwtScaleDiv &sy ); - const QwtScaleDiv &yScaleDiv() const; - - void setPen( const QPen &p ); - - void setMajPen( const QPen &p ); - const QPen& majPen() const; - - void setMinPen( const QPen &p ); - const QPen& minPen() const; - - virtual void draw( QPainter *p, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &rect ) const; - - virtual void updateScaleDiv( - const QwtScaleDiv &xMap, const QwtScaleDiv &yMap ); - -private: - void drawLines( QPainter *painter, const QRectF &, - Qt::Orientation orientation, const QwtScaleMap &, - const QList & ) const; - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_plot_histogram.cpp b/qwt/src/qwt_plot_histogram.cpp deleted file mode 100644 index 1fcf87109..000000000 --- a/qwt/src/qwt_plot_histogram.cpp +++ /dev/null @@ -1,648 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_plot_histogram.h" -#include "qwt_plot.h" -#include "qwt_legend.h" -#include "qwt_legend_item.h" -#include "qwt_painter.h" -#include "qwt_column_symbol.h" -#include "qwt_scale_map.h" -#include -#include - -static inline bool isCombinable( const QwtInterval &d1, - const QwtInterval &d2 ) -{ - if ( d1.isValid() && d2.isValid() ) - { - if ( d1.maxValue() == d2.minValue() ) - { - if ( !( d1.borderFlags() & QwtInterval::ExcludeMaximum - && d2.borderFlags() & QwtInterval::ExcludeMinimum ) ) - { - return true; - } - } - } - - return false; -} - -class QwtPlotHistogram::PrivateData -{ -public: - PrivateData(): - baseline( 0.0 ), - style( Columns ), - symbol( NULL ) - { - } - - ~PrivateData() - { - delete symbol; - } - - double baseline; - - QPen pen; - QBrush brush; - QwtPlotHistogram::HistogramStyle style; - const QwtColumnSymbol *symbol; -}; - -/*! - Constructor - \param title Title of the histogram. -*/ - -QwtPlotHistogram::QwtPlotHistogram( const QwtText &title ): - QwtPlotSeriesItem( title ) -{ - init(); -} - -/*! - Constructor - \param title Title of the histogram. -*/ -QwtPlotHistogram::QwtPlotHistogram( const QString &title ): - QwtPlotSeriesItem( title ) -{ - init(); -} - -//! Destructor -QwtPlotHistogram::~QwtPlotHistogram() -{ - delete d_data; -} - -//! Initialize data members -void QwtPlotHistogram::init() -{ - d_data = new PrivateData(); - d_series = new QwtIntervalSeriesData(); - - setItemAttribute( QwtPlotItem::AutoScale, true ); - setItemAttribute( QwtPlotItem::Legend, true ); - - setZ( 20.0 ); -} - -/*! - Set the histogram's drawing style - - \param style Histogram style - \sa HistogramStyle, style() -*/ -void QwtPlotHistogram::setStyle( HistogramStyle style ) -{ - if ( style != d_data->style ) - { - d_data->style = style; - itemChanged(); - } -} - -/*! - Return the current style - \sa HistogramStyle, setStyle() -*/ -QwtPlotHistogram::HistogramStyle QwtPlotHistogram::style() const -{ - return d_data->style; -} - -/*! - Assign a pen, that is used in a style() depending way. - - \param pen New pen - \sa pen(), brush() -*/ -void QwtPlotHistogram::setPen( const QPen &pen ) -{ - if ( pen != d_data->pen ) - { - d_data->pen = pen; - itemChanged(); - } -} - -/*! - \return Pen used in a style() depending way. - \sa setPen(), brush() -*/ -const QPen &QwtPlotHistogram::pen() const -{ - return d_data->pen; -} - -/*! - Assign a brush, that is used in a style() depending way. - - \param brush New brush - \sa pen(), brush() -*/ -void QwtPlotHistogram::setBrush( const QBrush &brush ) -{ - if ( brush != d_data->brush ) - { - d_data->brush = brush; - itemChanged(); - } -} - -/*! - \return Brush used in a style() depending way. - \sa setPen(), brush() -*/ -const QBrush &QwtPlotHistogram::brush() const -{ - return d_data->brush; -} - -/*! - \brief Assign a symbol - - In Column style an optional symbol can be assigned, that is responsible - for displaying the rectangle that is defined by the interval and - the distance between baseline() and value. When no symbol has been - defined the area is displayed as plain rectangle using pen() and brush(). - - \sa style(), symbol(), drawColumn(), pen(), brush() - - \note In applications, where different intervals need to be displayed - in a different way ( f.e different colors or even using differnt symbols) - it is recommended to overload drawColumn(). -*/ -void QwtPlotHistogram::setSymbol( const QwtColumnSymbol *symbol ) -{ - if ( symbol != d_data->symbol ) - { - delete d_data->symbol; - d_data->symbol = symbol; - itemChanged(); - } -} - -/*! - \return Current symbol or NULL, when no symbol has been assigned - \sa setSymbol() -*/ -const QwtColumnSymbol *QwtPlotHistogram::symbol() const -{ - return d_data->symbol; -} - -/*! - \brief Set the value of the baseline - - Each column representing an QwtIntervalSample is defined by its - interval and the interval between baseline and the value of the sample. - - The default value of the baseline is 0.0. - - \param value Value of the baseline - \sa baseline() -*/ -void QwtPlotHistogram::setBaseline( double value ) -{ - if ( d_data->baseline != value ) - { - d_data->baseline = value; - itemChanged(); - } -} - -/*! - \return Value of the baseline - \sa setBaseline() -*/ -double QwtPlotHistogram::baseline() const -{ - return d_data->baseline; -} - -/*! - \return Bounding rectangle of all samples. - For an empty series the rectangle is invalid. -*/ -QRectF QwtPlotHistogram::boundingRect() const -{ - QRectF rect = d_series->boundingRect(); - if ( !rect.isValid() ) - return rect; - - if ( orientation() == Qt::Horizontal ) - { - rect = QRectF( rect.y(), rect.x(), - rect.height(), rect.width() ); - - if ( rect.left() > d_data->baseline ) - rect.setLeft( d_data->baseline ); - else if ( rect.right() < d_data->baseline ) - rect.setRight( d_data->baseline ); - } - else - { - if ( rect.bottom() < d_data->baseline ) - rect.setBottom( d_data->baseline ); - else if ( rect.top() > d_data->baseline ) - rect.setTop( d_data->baseline ); - } - - return rect; -} - -//! \return QwtPlotItem::Rtti_PlotHistogram -int QwtPlotHistogram::rtti() const -{ - return QwtPlotItem::Rtti_PlotHistogram; -} - -/*! - Initialize data with an array of samples. - \param samples Vector of points -*/ -void QwtPlotHistogram::setSamples( - const QVector &samples ) -{ - delete d_series; - d_series = new QwtIntervalSeriesData( samples ); - itemChanged(); -} - -/*! - Draw a subset of the histogram samples - - \param painter Painter - \param xMap Maps x-values into pixel coordinates. - \param yMap Maps y-values into pixel coordinates. - \param canvasRect Contents rect of the canvas - \param from Index of the first sample to be painted - \param to Index of the last sample to be painted. If to < 0 the - series will be painted to its last sample. - - \sa drawOutline(), drawLines(), drawColumns -*/ -void QwtPlotHistogram::drawSeries( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &, int from, int to ) const -{ - if ( !painter || dataSize() <= 0 ) - return; - - if ( to < 0 ) - to = dataSize() - 1; - - switch ( d_data->style ) - { - case Outline: - drawOutline( painter, xMap, yMap, from, to ); - break; - case Lines: - drawLines( painter, xMap, yMap, from, to ); - break; - case Columns: - drawColumns( painter, xMap, yMap, from, to ); - break; - default: - break; - } -} - -/*! - Draw a histogram in Outline style() - - \param painter Painter - \param xMap Maps x-values into pixel coordinates. - \param yMap Maps y-values into pixel coordinates. - \param from Index of the first sample to be painted - \param to Index of the last sample to be painted. If to < 0 the - histogram will be painted to its last point. - - \sa setStyle(), style() - \warning The outline style requires, that the intervals are in increasing - order and not overlapping. -*/ -void QwtPlotHistogram::drawOutline( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - int from, int to ) const -{ - const bool doAlign = QwtPainter::roundingAlignment( painter ); - - double v0 = ( orientation() == Qt::Horizontal ) ? - xMap.transform( baseline() ) : yMap.transform( baseline() ); - if ( doAlign ) - v0 = qRound( v0 ); - - QwtIntervalSample previous; - - QPolygonF polygon; - for ( int i = from; i <= to; i++ ) - { - const QwtIntervalSample sample = d_series->sample( i ); - - if ( !sample.interval.isValid() ) - { - flushPolygon( painter, v0, polygon ); - previous = sample; - continue; - } - - if ( previous.interval.isValid() ) - { - if ( !isCombinable( previous.interval, sample.interval ) ) - flushPolygon( painter, v0, polygon ); - } - - if ( orientation() == Qt::Vertical ) - { - double x1 = xMap.transform( sample.interval.minValue() ); - double x2 = xMap.transform( sample.interval.maxValue() ); - double y = yMap.transform( sample.value ); - if ( doAlign ) - { - x1 = qRound( x1 ); - x2 = qRound( x2 ); - y = qRound( y ); - } - - if ( polygon.size() == 0 ) - polygon += QPointF( x1, v0 ); - - polygon += QPointF( x1, y ); - polygon += QPointF( x2, y ); - } - else - { - double y1 = yMap.transform( sample.interval.minValue() ); - double y2 = yMap.transform( sample.interval.maxValue() ); - double x = xMap.transform( sample.value ); - if ( doAlign ) - { - y1 = qRound( y1 ); - y2 = qRound( y2 ); - x = qRound( x ); - } - - if ( polygon.size() == 0 ) - polygon += QPointF( v0, y1 ); - - polygon += QPointF( x, y1 ); - polygon += QPointF( x, y2 ); - } - previous = sample; - } - - flushPolygon( painter, v0, polygon ); -} - -/*! - Draw a histogram in Columns style() - - \param painter Painter - \param xMap Maps x-values into pixel coordinates. - \param yMap Maps y-values into pixel coordinates. - \param from Index of the first sample to be painted - \param to Index of the last sample to be painted. If to < 0 the - histogram will be painted to its last point. - - \sa setStyle(), style(), setSymbol(), drawColumn() -*/ -void QwtPlotHistogram::drawColumns( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - int from, int to ) const -{ - painter->setPen( d_data->pen ); - painter->setBrush( d_data->brush ); - - for ( int i = from; i <= to; i++ ) - { - const QwtIntervalSample sample = d_series->sample( i ); - if ( !sample.interval.isNull() ) - { - const QwtColumnRect rect = columnRect( sample, xMap, yMap ); - drawColumn( painter, rect, sample ); - } - } -} - -/*! - Draw a histogram in Lines style() - - \param painter Painter - \param xMap Maps x-values into pixel coordinates. - \param yMap Maps y-values into pixel coordinates. - \param from Index of the first sample to be painted - \param to Index of the last sample to be painted. If to < 0 the - histogram will be painted to its last point. - - \sa setStyle(), style(), setPen() -*/ -void QwtPlotHistogram::drawLines( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - int from, int to ) const -{ - const bool doAlign = QwtPainter::roundingAlignment( painter ); - - painter->setPen( d_data->pen ); - painter->setBrush( Qt::NoBrush ); - - for ( int i = from; i <= to; i++ ) - { - const QwtIntervalSample sample = d_series->sample( i ); - if ( !sample.interval.isNull() ) - { - const QwtColumnRect rect = columnRect( sample, xMap, yMap ); - - QRectF r = rect.toRect(); - if ( doAlign ) - { - r.setLeft( qRound( r.left() ) ); - r.setRight( qRound( r.right() ) ); - r.setTop( qRound( r.top() ) ); - r.setBottom( qRound( r.bottom() ) ); - } - - switch ( rect.direction ) - { - case QwtColumnRect::LeftToRight: - { - QwtPainter::drawLine( painter, - r.topRight(), r.bottomRight() ); - break; - } - case QwtColumnRect::RightToLeft: - { - QwtPainter::drawLine( painter, - r.topLeft(), r.bottomLeft() ); - break; - } - case QwtColumnRect::TopToBottom: - { - QwtPainter::drawLine( painter, - r.bottomRight(), r.bottomLeft() ); - break; - } - case QwtColumnRect::BottomToTop: - { - QwtPainter::drawLine( painter, - r.topRight(), r.topLeft() ); - break; - } - } - } - } -} - -//! Internal, used by the Outline style. -void QwtPlotHistogram::flushPolygon( QPainter *painter, - double baseLine, QPolygonF &polygon ) const -{ - if ( polygon.size() == 0 ) - return; - - if ( orientation() == Qt::Horizontal ) - polygon += QPointF( baseLine, polygon.last().y() ); - else - polygon += QPointF( polygon.last().x(), baseLine ); - - if ( d_data->brush.style() != Qt::NoBrush ) - { - painter->setPen( Qt::NoPen ); - painter->setBrush( d_data->brush ); - - if ( orientation() == Qt::Horizontal ) - { - polygon += QPointF( polygon.last().x(), baseLine ); - polygon += QPointF( polygon.first().x(), baseLine ); - } - else - { - polygon += QPointF( baseLine, polygon.last().y() ); - polygon += QPointF( baseLine, polygon.first().y() ); - } - QwtPainter::drawPolygon( painter, polygon ); - polygon.resize( polygon.size() - 2 ); - } - if ( d_data->pen.style() != Qt::NoPen ) - { - painter->setBrush( Qt::NoBrush ); - painter->setPen( d_data->pen ); - QwtPainter::drawPolyline( painter, polygon ); - } - polygon.clear(); -} - -/*! - Calculate the area that is covered by a sample - - \param sample Sample - \param xMap Maps x-values into pixel coordinates. - \param yMap Maps y-values into pixel coordinates. - - \return Rectangle, that is covered by a sample -*/ -QwtColumnRect QwtPlotHistogram::columnRect( const QwtIntervalSample &sample, - const QwtScaleMap &xMap, const QwtScaleMap &yMap ) const -{ - QwtColumnRect rect; - - const QwtInterval &iv = sample.interval; - if ( !iv.isValid() ) - return rect; - - if ( orientation() == Qt::Horizontal ) - { - const double x0 = xMap.transform( baseline() ); - const double x = xMap.transform( sample.value ); - const double y1 = yMap.transform( iv.minValue() ); - const double y2 = yMap.transform( iv.maxValue() ); - - rect.hInterval.setInterval( x0, x ); - rect.vInterval.setInterval( y1, y2, iv.borderFlags() ); - rect.direction = ( x < x0 ) ? QwtColumnRect::RightToLeft : - QwtColumnRect::LeftToRight; - } - else - { - const double x1 = xMap.transform( iv.minValue() ); - const double x2 = xMap.transform( iv.maxValue() ); - const double y0 = yMap.transform( baseline() ); - const double y = yMap.transform( sample.value ); - - rect.hInterval.setInterval( x1, x2, iv.borderFlags() ); - rect.vInterval.setInterval( y0, y ); - rect.direction = ( y < y0 ) ? QwtColumnRect::BottomToTop : - QwtColumnRect::TopToBottom; - } - - return rect; -} - -/*! - Draw a column for a sample in Columns style(). - - When a symbol() has been set the symbol is used otherwise the - column is displayed as plain rectangle using pen() and brush(). - - \param painter Painter - \param rect Rectangle where to paint the column in paint device coordinates - \param sample Sample to be displayed - - \note In applications, where different intervals need to be displayed - in a different way ( f.e different colors or even using differnt symbols) - it is recommended to overload drawColumn(). -*/ -void QwtPlotHistogram::drawColumn( QPainter *painter, - const QwtColumnRect &rect, const QwtIntervalSample &sample ) const -{ - Q_UNUSED( sample ); - - if ( d_data->symbol && - ( d_data->symbol->style() != QwtColumnSymbol::NoStyle ) ) - { - d_data->symbol->draw( painter, rect ); - } - else - { - QRectF r = rect.toRect(); - if ( QwtPainter::roundingAlignment( painter ) ) - { - r.setLeft( qRound( r.left() ) ); - r.setRight( qRound( r.right() ) ); - r.setTop( qRound( r.top() ) ); - r.setBottom( qRound( r.bottom() ) ); - } - - QwtPainter::drawRect( painter, r ); - } -} - -/*! - Draw a plain rectangle without pen using the brush() as identifier - - \param painter Painter - \param rect Bounding rectangle for the identifier -*/ -void QwtPlotHistogram::drawLegendIdentifier( - QPainter *painter, const QRectF &rect ) const -{ - const double dim = qMin( rect.width(), rect.height() ); - - QSizeF size( dim, dim ); - - QRectF r( 0, 0, size.width(), size.height() ); - r.moveCenter( rect.center() ); - - painter->fillRect( r, d_data->brush ); -} diff --git a/qwt/src/qwt_plot_histogram.h b/qwt/src/qwt_plot_histogram.h deleted file mode 100644 index cf6d98e5b..000000000 --- a/qwt/src/qwt_plot_histogram.h +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_PLOT_HISTOGRAM_H -#define QWT_PLOT_HISTOGRAM_H - -#include "qwt_global.h" -#include "qwt_plot_seriesitem.h" -#include "qwt_column_symbol.h" -#include -#include - -class QwtIntervalData; -class QString; -class QPolygonF; - -/*! - \brief QwtPlotHistogram represents a series of samples, where an interval - is associated with a value ( \f$y = f([x1,x2])\f$ ). - - The representation depends on the style() and an optional symbol() - that is displayed for each interval. - - \note The term "histogram" is used in a different way in the areas of - digital image processing and statistics. Wikipedia introduces the - terms "image histogram" and "color histogram" to avoid confusions. - While "image histograms" can be displayed by a QwtPlotCurve there - is no applicable plot item for a "color histogram" yet. -*/ - -class QWT_EXPORT QwtPlotHistogram: public QwtPlotSeriesItem -{ -public: - /*! - Histogram styles. - The default style is QwtPlotHistogram::Columns. - - \sa setStyle(), style(), setSymbol(), symbol(), setBaseline() - */ - enum HistogramStyle - { - /*! - Draw an outline around the area, that is build by all intervals - using the pen() and fill it with the brush(). The outline style - requires, that the intervals are in increasing order and - not overlapping. - */ - Outline, - - /*! - Draw a column for each interval. When a symbol() has been set - the symbol is used otherwise the column is displayed as - plain rectangle using pen() and brush(). - */ - Columns, - - /*! - Draw a simple line using the pen() for each interval. - */ - Lines, - - /*! - Styles >= UserStyle are reserved for derived - classes that overload drawSeries() with - additional application specific ways to display a histogram. - */ - UserStyle = 100 - }; - - explicit QwtPlotHistogram( const QString &title = QString::null ); - explicit QwtPlotHistogram( const QwtText &title ); - virtual ~QwtPlotHistogram(); - - virtual int rtti() const; - - void setPen( const QPen & ); - const QPen &pen() const; - - void setBrush( const QBrush & ); - const QBrush &brush() const; - - void setSamples( const QVector & ); - - void setBaseline( double reference ); - double baseline() const; - - void setStyle( HistogramStyle style ); - HistogramStyle style() const; - - void setSymbol( const QwtColumnSymbol * ); - const QwtColumnSymbol *symbol() const; - - virtual void drawSeries( QPainter *p, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const; - - virtual QRectF boundingRect() const; - - virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const; - -protected: - virtual QwtColumnRect columnRect( const QwtIntervalSample &, - const QwtScaleMap &, const QwtScaleMap & ) const; - - virtual void drawColumn( QPainter *, const QwtColumnRect &, - const QwtIntervalSample & ) const; - - void drawColumns( QPainter *, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - int from, int to ) const; - - void drawOutline( QPainter *, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - int from, int to ) const; - - void drawLines( QPainter *, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - int from, int to ) const; - -private: - void init(); - void flushPolygon( QPainter *, double baseLine, QPolygonF & ) const; - - class PrivateData; - PrivateData *d_data; -}; - -#endif diff --git a/qwt/src/qwt_plot_intervalcurve.cpp b/qwt/src/qwt_plot_intervalcurve.cpp deleted file mode 100644 index 94e57acf8..000000000 --- a/qwt/src/qwt_plot_intervalcurve.cpp +++ /dev/null @@ -1,547 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_plot_intervalcurve.h" -#include "qwt_interval_symbol.h" -#include "qwt_scale_map.h" -#include "qwt_clipper.h" -#include "qwt_painter.h" - -#include - -static inline bool qwtIsHSampleInside( const QwtIntervalSample &sample, - double xMin, double xMax, double yMin, double yMax ) -{ - const double y = sample.value; - const double x1 = sample.interval.minValue(); - const double x2 = sample.interval.maxValue(); - - const bool isOffScreen = ( y < yMin ) || ( y > yMax ) - || ( x1 < xMin && x2 < xMin ) || ( x1 > yMax && x2 > xMax ); - - return !isOffScreen; -} - -static inline bool qwtIsVSampleInside( const QwtIntervalSample &sample, - double xMin, double xMax, double yMin, double yMax ) -{ - const double x = sample.value; - const double y1 = sample.interval.minValue(); - const double y2 = sample.interval.maxValue(); - - const bool isOffScreen = ( x < xMin ) || ( x > xMax ) - || ( y1 < yMin && y2 < yMin ) || ( y1 > yMax && y2 > yMax ); - - return !isOffScreen; -} - -class QwtPlotIntervalCurve::PrivateData -{ -public: - PrivateData(): - style( Tube ), - symbol( NULL ), - pen( Qt::black ), - brush( Qt::white ) - { - paintAttributes = QwtPlotIntervalCurve::ClipPolygons; - paintAttributes |= QwtPlotIntervalCurve::ClipSymbol; - - pen.setCapStyle( Qt::FlatCap ); - } - - ~PrivateData() - { - delete symbol; - } - - CurveStyle style; - const QwtIntervalSymbol *symbol; - - QPen pen; - QBrush brush; - - QwtPlotIntervalCurve::PaintAttributes paintAttributes; -}; - -/*! - Constructor - \param title Title of the curve -*/ -QwtPlotIntervalCurve::QwtPlotIntervalCurve( const QwtText &title ): - QwtPlotSeriesItem( title ) -{ - init(); -} - -/*! - Constructor - \param title Title of the curve -*/ -QwtPlotIntervalCurve::QwtPlotIntervalCurve( const QString &title ): - QwtPlotSeriesItem( QwtText( title ) ) -{ - init(); -} - -//! Destructor -QwtPlotIntervalCurve::~QwtPlotIntervalCurve() -{ - delete d_data; -} - -//! Initialize internal members -void QwtPlotIntervalCurve::init() -{ - setItemAttribute( QwtPlotItem::Legend, true ); - setItemAttribute( QwtPlotItem::AutoScale, true ); - - d_data = new PrivateData; - d_series = new QwtIntervalSeriesData(); - - setZ( 19.0 ); -} - -//! \return QwtPlotItem::Rtti_PlotIntervalCurve -int QwtPlotIntervalCurve::rtti() const -{ - return QwtPlotIntervalCurve::Rtti_PlotIntervalCurve; -} - -/*! - Specify an attribute how to draw the curve - - \param attribute Paint attribute - \param on On/Off - \sa testPaintAttribute() -*/ -void QwtPlotIntervalCurve::setPaintAttribute( - PaintAttribute attribute, bool on ) -{ - if ( on ) - d_data->paintAttributes |= attribute; - else - d_data->paintAttributes &= ~attribute; -} - -/*! - \brief Return the current paint attributes - \sa PaintAttribute, setPaintAttribute() -*/ -bool QwtPlotIntervalCurve::testPaintAttribute( - PaintAttribute attribute ) const -{ - return ( d_data->paintAttributes & attribute ); -} - -/*! - Initialize data with an array of samples. - \param samples Vector of samples -*/ -void QwtPlotIntervalCurve::setSamples( - const QVector &samples ) -{ - delete d_series; - d_series = new QwtIntervalSeriesData( samples ); - itemChanged(); -} - -/*! - Set the curve's drawing style - - \param style Curve style - \sa CurveStyle, style() -*/ -void QwtPlotIntervalCurve::setStyle( CurveStyle style ) -{ - if ( style != d_data->style ) - { - d_data->style = style; - itemChanged(); - } -} - -/*! - \brief Return the current style - \sa setStyle() -*/ -QwtPlotIntervalCurve::CurveStyle QwtPlotIntervalCurve::style() const -{ - return d_data->style; -} - -/*! - Assign a symbol. - - \param symbol Symbol - \sa symbol() -*/ -void QwtPlotIntervalCurve::setSymbol( const QwtIntervalSymbol *symbol ) -{ - if ( symbol != d_data->symbol ) - { - delete d_data->symbol; - d_data->symbol = symbol; - itemChanged(); - } -} - -/*! - \return Current symbol or NULL, when no symbol has been assigned - \sa setSymbol() -*/ -const QwtIntervalSymbol *QwtPlotIntervalCurve::symbol() const -{ - return d_data->symbol; -} - -/*! - \brief Assign a pen - \param pen New pen - \sa pen(), brush() -*/ -void QwtPlotIntervalCurve::setPen( const QPen &pen ) -{ - if ( pen != d_data->pen ) - { - d_data->pen = pen; - itemChanged(); - } -} - -/*! - \brief Return the pen used to draw the lines - \sa setPen(), brush() -*/ -const QPen& QwtPlotIntervalCurve::pen() const -{ - return d_data->pen; -} - -/*! - Assign a brush. - - The brush is used to fill the area in Tube style(). - - \param brush Brush - \sa brush(), pen(), setStyle(), CurveStyle -*/ -void QwtPlotIntervalCurve::setBrush( const QBrush &brush ) -{ - if ( brush != d_data->brush ) - { - d_data->brush = brush; - itemChanged(); - } -} - -/*! - \return Brush used to fill the area in Tube style() - \sa setBrush(), setStyle(), CurveStyle -*/ -const QBrush& QwtPlotIntervalCurve::brush() const -{ - return d_data->brush; -} - -/*! - \return Bounding rectangle of all samples. - For an empty series the rectangle is invalid. -*/ -QRectF QwtPlotIntervalCurve::boundingRect() const -{ - QRectF rect = QwtPlotSeriesItem::boundingRect(); - if ( rect.isValid() && orientation() == Qt::Vertical ) - rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() ); - - return rect; -} - -/*! - Draw a subset of the samples - - \param painter Painter - \param xMap Maps x-values into pixel coordinates. - \param yMap Maps y-values into pixel coordinates. - \param canvasRect Contents rect of the canvas - \param from Index of the first sample to be painted - \param to Index of the last sample to be painted. If to < 0 the - series will be painted to its last sample. - - \sa drawTube(), drawSymbols() -*/ -void QwtPlotIntervalCurve::drawSeries( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const -{ - if ( to < 0 ) - to = dataSize() - 1; - - if ( from < 0 ) - from = 0; - - if ( from > to ) - return; - - switch ( d_data->style ) - { - case Tube: - drawTube( painter, xMap, yMap, canvasRect, from, to ); - break; - - case NoCurve: - default: - break; - } - - if ( d_data->symbol && - ( d_data->symbol->style() != QwtIntervalSymbol::NoSymbol ) ) - { - drawSymbols( painter, *d_data->symbol, - xMap, yMap, canvasRect, from, to ); - } -} - -/*! - Draw a tube - - Builds 2 curves from the upper and lower limits of the intervals - and draws them with the pen(). The area between the curves is - filled with the brush(). - - \param painter Painter - \param xMap Maps x-values into pixel coordinates. - \param yMap Maps y-values into pixel coordinates. - \param canvasRect Contents rect of the canvas - \param from Index of the first sample to be painted - \param to Index of the last sample to be painted. If to < 0 the - series will be painted to its last sample. - - \sa drawSeries(), drawSymbols() -*/ -void QwtPlotIntervalCurve::drawTube( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const -{ - const bool doAlign = QwtPainter::roundingAlignment( painter ); - - painter->save(); - - const size_t size = to - from + 1; - QPolygonF polygon( 2 * size ); - QPointF *points = polygon.data(); - - for ( uint i = 0; i < size; i++ ) - { - QPointF &minValue = points[i]; - QPointF &maxValue = points[2 * size - 1 - i]; - - const QwtIntervalSample intervalSample = sample( from + i ); - if ( orientation() == Qt::Vertical ) - { - double x = xMap.transform( intervalSample.value ); - double y1 = yMap.transform( intervalSample.interval.minValue() ); - double y2 = yMap.transform( intervalSample.interval.maxValue() ); - if ( doAlign ) - { - x = qRound( x ); - y1 = qRound( y1 ); - y2 = qRound( y2 ); - } - - minValue.rx() = x; - minValue.ry() = y1; - maxValue.rx() = x; - maxValue.ry() = y2; - } - else - { - double y = yMap.transform( intervalSample.value ); - double x1 = xMap.transform( intervalSample.interval.minValue() ); - double x2 = xMap.transform( intervalSample.interval.maxValue() ); - if ( doAlign ) - { - y = qRound( y ); - x1 = qRound( x1 ); - x2 = qRound( x2 ); - } - - minValue.rx() = x1; - minValue.ry() = y; - maxValue.rx() = x2; - maxValue.ry() = y; - } - } - - if ( d_data->brush.style() != Qt::NoBrush ) - { - painter->setPen( QPen( Qt::NoPen ) ); - painter->setBrush( d_data->brush ); - - if ( d_data->paintAttributes & ClipPolygons ) - { - const qreal m = 1.0; - const QPolygonF p = QwtClipper::clipPolygonF( - canvasRect.adjusted(-m, -m, m, m), polygon, true ); - - QwtPainter::drawPolygon( painter, p ); - } - else - { - QwtPainter::drawPolygon( painter, polygon ); - } - } - - if ( d_data->pen.style() != Qt::NoPen ) - { - painter->setPen( d_data->pen ); - painter->setBrush( Qt::NoBrush ); - - if ( d_data->paintAttributes & ClipPolygons ) - { - qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF()); - const QRectF clipRect = canvasRect.adjusted(-pw, -pw, pw, pw); - - QPolygonF p; - - p.resize( size ); - qMemCopy( p.data(), points, size * sizeof( QPointF ) ); - p = QwtClipper::clipPolygonF( canvasRect, p ); - QwtPainter::drawPolyline( painter, p ); - - p.resize( size ); - qMemCopy( p.data(), points + size, size * sizeof( QPointF ) ); - p = QwtClipper::clipPolygonF( canvasRect, p ); - QwtPainter::drawPolyline( painter, p ); - } - else - { - QwtPainter::drawPolyline( painter, points, size ); - QwtPainter::drawPolyline( painter, points + size, size ); - } - } - - painter->restore(); -} - -/*! - Draw symbols for a subset of the samples - - \param painter Painter - \param symbol Interval symbol - \param xMap x map - \param yMap y map - \param canvasRect Contents rect of the canvas - \param from Index of the first sample to be painted - \param to Index of the last sample to be painted - - \sa setSymbol(), drawSeries(), drawTube() -*/ -void QwtPlotIntervalCurve::drawSymbols( - QPainter *painter, const QwtIntervalSymbol &symbol, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const -{ - painter->save(); - - QPen pen = symbol.pen(); - pen.setCapStyle( Qt::FlatCap ); - - painter->setPen( pen ); - painter->setBrush( symbol.brush() ); - - const QRectF &tr = QwtScaleMap::invTransform( xMap, yMap, canvasRect); - - const double xMin = tr.left(); - const double xMax = tr.right(); - const double yMin = tr.top(); - const double yMax = tr.bottom(); - - const bool doClip = d_data->paintAttributes & ClipPolygons; - - for ( int i = from; i <= to; i++ ) - { - const QwtIntervalSample s = sample( i ); - - if ( orientation() == Qt::Vertical ) - { - if ( !doClip || qwtIsVSampleInside( s, xMin, xMax, yMin, yMax ) ) - { - const double x = xMap.transform( s.value ); - const double y1 = yMap.transform( s.interval.minValue() ); - const double y2 = yMap.transform( s.interval.maxValue() ); - - symbol.draw( painter, orientation(), - QPointF( x, y1 ), QPointF( x, y2 ) ); - } - } - else - { - if ( !doClip || qwtIsHSampleInside( s, xMin, xMax, yMin, yMax ) ) - { - const double y = yMap.transform( s.value ); - const double x1 = xMap.transform( s.interval.minValue() ); - const double x2 = xMap.transform( s.interval.maxValue() ); - - symbol.draw( painter, orientation(), - QPointF( x1, y ), QPointF( x2, y ) ); - } - } - } - - painter->restore(); -} - -/*! - In case of Tibe stale() a plain rectangle is painted without a pen filled - the brush(). If a symbol is assigned it is painted cebtered into rect. - - \param painter Painter - \param rect Bounding rectangle for the identifier -*/ - -void QwtPlotIntervalCurve::drawLegendIdentifier( - QPainter *painter, const QRectF &rect ) const -{ - const double dim = qMin( rect.width(), rect.height() ); - - QSizeF size( dim, dim ); - - QRectF r( 0, 0, size.width(), size.height() ); - r.moveCenter( rect.center() ); - - if ( d_data->style == Tube ) - { - painter->fillRect( r, d_data->brush ); - } - - if ( d_data->symbol && - ( d_data->symbol->style() != QwtIntervalSymbol::NoSymbol ) ) - { - QPen pen = d_data->symbol->pen(); - pen.setWidthF( pen.widthF() ); - pen.setCapStyle( Qt::FlatCap ); - - painter->setPen( pen ); - painter->setBrush( d_data->symbol->brush() ); - - if ( orientation() == Qt::Vertical ) - { - d_data->symbol->draw( painter, orientation(), - QPointF( r.center().x(), r.top() ), - QPointF( r.center().x(), r.bottom() - 1 ) ); - } - else - { - d_data->symbol->draw( painter, orientation(), - QPointF( r.left(), r.center().y() ), - QPointF( r.right() - 1, r.center().y() ) ); - } - } -} diff --git a/qwt/src/qwt_plot_intervalcurve.h b/qwt/src/qwt_plot_intervalcurve.h deleted file mode 100644 index b26586e64..000000000 --- a/qwt/src/qwt_plot_intervalcurve.h +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_PLOT_INTERVAL_CURVE_H -#define QWT_PLOT_INTERVAL_CURVE_H - -#include "qwt_global.h" -#include "qwt_plot_seriesitem.h" -#include "qwt_series_data.h" - -class QwtIntervalSymbol; - -/*! - \brief QwtPlotIntervalCurve represents a series of samples, where each value - is associated with an interval ( \f$[y1,y2] = f(x)\f$ ). - - The representation depends on the style() and an optional symbol() - that is displayed for each interval. QwtPlotIntervalCurve might be used - to disply error bars or the area between 2 curves. -*/ - -class QWT_EXPORT QwtPlotIntervalCurve: public QwtPlotSeriesItem -{ -public: - /*! - \brief Curve styles. - The default setting is QwtPlotIntervalCurve::Tube. - - \sa setStyle(), style() - */ - - enum CurveStyle - { - /*! - Don't draw a curve. Note: This doesn't affect the symbols. - */ - NoCurve, - - /*! - Build 2 curves from the upper and lower limits of the intervals - and draw them with the pen(). The area between the curves is - filled with the brush(). - */ - Tube, - - /*! - Styles >= QwtPlotIntervalCurve::UserCurve are reserved for derived - classes that overload drawSeries() with - additional application specific curve types. - */ - UserCurve = 100 - }; - - /*! - Attributes to modify the drawing algorithm. - \sa setPaintAttribute(), testPaintAttribute() - */ - enum PaintAttribute - { - /*! - Clip polygons before painting them. In situations, where points - are far outside the visible area (f.e when zooming deep) this - might be a substantial improvement for the painting performance. - */ - ClipPolygons = 0x01, - - //! Check if a symbol is on the plot canvas before painting it. - ClipSymbol = 0x02 - }; - - //! Paint attributes - typedef QFlags PaintAttributes; - - explicit QwtPlotIntervalCurve( const QString &title = QString::null ); - explicit QwtPlotIntervalCurve( const QwtText &title ); - - virtual ~QwtPlotIntervalCurve(); - - virtual int rtti() const; - - void setPaintAttribute( PaintAttribute, bool on = true ); - bool testPaintAttribute( PaintAttribute ) const; - - void setSamples( const QVector & ); - - void setPen( const QPen & ); - const QPen &pen() const; - - void setBrush( const QBrush & ); - const QBrush &brush() const; - - void setStyle( CurveStyle style ); - CurveStyle style() const; - - void setSymbol( const QwtIntervalSymbol * ); - const QwtIntervalSymbol *symbol() const; - - virtual void drawSeries( QPainter *p, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const; - - virtual QRectF boundingRect() const; - virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const; - -protected: - - void init(); - - virtual void drawTube( QPainter *, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const; - - virtual void drawSymbols( QPainter *, const QwtIntervalSymbol &, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect, int from, int to ) const; - -private: - class PrivateData; - PrivateData *d_data; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotIntervalCurve::PaintAttributes ) - -#endif diff --git a/qwt/src/qwt_plot_item.cpp b/qwt/src/qwt_plot_item.cpp deleted file mode 100644 index 7601f4400..000000000 --- a/qwt/src/qwt_plot_item.cpp +++ /dev/null @@ -1,548 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_plot_item.h" -#include "qwt_text.h" -#include "qwt_plot.h" -#include "qwt_legend.h" -#include "qwt_legend_item.h" -#include "qwt_scale_div.h" -#include - -class QwtPlotItem::PrivateData -{ -public: - PrivateData(): - plot( NULL ), - isVisible( true ), - attributes( 0 ), - renderHints( 0 ), - z( 0.0 ), - xAxis( QwtPlot::xBottom ), - yAxis( QwtPlot::yLeft ) - { - } - - mutable QwtPlot *plot; - - bool isVisible; - QwtPlotItem::ItemAttributes attributes; - QwtPlotItem::RenderHints renderHints; - double z; - - int xAxis; - int yAxis; - - QwtText title; -}; - -/*! - Constructor - \param title Title of the item -*/ -QwtPlotItem::QwtPlotItem( const QwtText &title ) -{ - d_data = new PrivateData; - d_data->title = title; -} - -//! Destroy the QwtPlotItem -QwtPlotItem::~QwtPlotItem() -{ - attach( NULL ); - delete d_data; -} - -/*! - \brief Attach the item to a plot. - - This method will attach a QwtPlotItem to the QwtPlot argument. It will first - detach the QwtPlotItem from any plot from a previous call to attach (if - necessary). If a NULL argument is passed, it will detach from any QwtPlot it - was attached to. - - \param plot Plot widget - \sa detach() -*/ -void QwtPlotItem::attach( QwtPlot *plot ) -{ - if ( plot == d_data->plot ) - return; - - // remove the item from the previous plot - - if ( d_data->plot ) - { - if ( d_data->plot->legend() ) - d_data->plot->legend()->remove( this ); - - d_data->plot->attachItem( this, false ); - - if ( d_data->plot->autoReplot() ) - d_data->plot->update(); - } - - d_data->plot = plot; - - if ( d_data->plot ) - { - // insert the item into the current plot - - d_data->plot->attachItem( this, true ); - itemChanged(); - } -} - -/*! - \brief This method detaches a QwtPlotItem from any - QwtPlot it has been associated with. - - detach() is equivalent to calling attach( NULL ) - \sa attach() -*/ -void QwtPlotItem::detach() -{ - attach( NULL ); -} - -/*! - Return rtti for the specific class represented. QwtPlotItem is simply - a virtual interface class, and base classes will implement this method - with specific rtti values so a user can differentiate them. - - The rtti value is useful for environments, where the - runtime type information is disabled and it is not possible - to do a dynamic_cast<...>. - - \return rtti value - \sa RttiValues -*/ -int QwtPlotItem::rtti() const -{ - return Rtti_PlotItem; -} - -//! Return attached plot -QwtPlot *QwtPlotItem::plot() const -{ - return d_data->plot; -} - -/*! - Plot items are painted in increasing z-order. - - \return setZ(), QwtPlotDict::itemList() -*/ -double QwtPlotItem::z() const -{ - return d_data->z; -} - -/*! - \brief Set the z value - - Plot items are painted in increasing z-order. - - \param z Z-value - \sa z(), QwtPlotDict::itemList() -*/ -void QwtPlotItem::setZ( double z ) -{ - if ( d_data->z != z ) - { - if ( d_data->plot ) // update the z order - d_data->plot->attachItem( this, false ); - - d_data->z = z; - - if ( d_data->plot ) - d_data->plot->attachItem( this, true ); - - itemChanged(); - } -} - -/*! - Set a new title - - \param title Title - \sa title() -*/ -void QwtPlotItem::setTitle( const QString &title ) -{ - setTitle( QwtText( title ) ); -} - -/*! - Set a new title - - \param title Title - \sa title() -*/ -void QwtPlotItem::setTitle( const QwtText &title ) -{ - if ( d_data->title != title ) - { - d_data->title = title; - itemChanged(); - } -} - -/*! - \return Title of the item - \sa setTitle() -*/ -const QwtText &QwtPlotItem::title() const -{ - return d_data->title; -} - -/*! - Toggle an item attribute - - \param attribute Attribute type - \param on true/false - - \sa testItemAttribute(), ItemAttribute -*/ -void QwtPlotItem::setItemAttribute( ItemAttribute attribute, bool on ) -{ - if ( bool( d_data->attributes & attribute ) != on ) - { - if ( on ) - d_data->attributes |= attribute; - else - d_data->attributes &= ~attribute; - - itemChanged(); - } -} - -/*! - Test an item attribute - - \param attribute Attribute type - \return true/false - \sa setItemAttribute(), ItemAttribute -*/ -bool QwtPlotItem::testItemAttribute( ItemAttribute attribute ) const -{ - return ( d_data->attributes & attribute ); -} - -/*! - Toggle an render hint - - \param hint Render hint - \param on true/false - - \sa testRenderHint(), RenderHint -*/ -void QwtPlotItem::setRenderHint( RenderHint hint, bool on ) -{ - if ( ( ( d_data->renderHints & hint ) != 0 ) != on ) - { - if ( on ) - d_data->renderHints |= hint; - else - d_data->renderHints &= ~hint; - - itemChanged(); - } -} - -/*! - Test a render hint - - \param hint Render hint - \return true/false - \sa setRenderHint(), RenderHint -*/ -bool QwtPlotItem::testRenderHint( RenderHint hint ) const -{ - return ( d_data->renderHints & hint ); -} - -//! Show the item -void QwtPlotItem::show() -{ - setVisible( true ); -} - -//! Hide the item -void QwtPlotItem::hide() -{ - setVisible( false ); -} - -/*! - Show/Hide the item - - \param on Show if true, otherwise hide - \sa isVisible(), show(), hide() -*/ -void QwtPlotItem::setVisible( bool on ) -{ - if ( on != d_data->isVisible ) - { - d_data->isVisible = on; - itemChanged(); - } -} - -/*! - \return true if visible - \sa setVisible(), show(), hide() -*/ -bool QwtPlotItem::isVisible() const -{ - return d_data->isVisible; -} - -/*! - Update the legend and call QwtPlot::autoRefresh for the - parent plot. - - \sa updateLegend() -*/ -void QwtPlotItem::itemChanged() -{ - if ( d_data->plot ) - { - if ( d_data->plot->legend() ) - updateLegend( d_data->plot->legend() ); - - d_data->plot->autoRefresh(); - } -} - -/*! - Set X and Y axis - - The item will painted according to the coordinates its Axes. - - \param xAxis X Axis - \param yAxis Y Axis - - \sa setXAxis(), setYAxis(), xAxis(), yAxis() -*/ -void QwtPlotItem::setAxes( int xAxis, int yAxis ) -{ - if ( xAxis == QwtPlot::xBottom || xAxis == QwtPlot::xTop ) - d_data->xAxis = xAxis; - - if ( yAxis == QwtPlot::yLeft || yAxis == QwtPlot::yRight || - yAxis == QwtPlot::yLeft1 || yAxis == QwtPlot::yRight1 || - yAxis == QwtPlot::yLeft2 || yAxis == QwtPlot::yRight2 || - yAxis == QwtPlot::yLeft3 || yAxis == QwtPlot::yRight3 ) - d_data->yAxis = yAxis; - - itemChanged(); -} - -/*! - Set the X axis - - The item will painted according to the coordinates its Axes. - - \param axis X Axis - \sa setAxes(), setYAxis(), xAxis() -*/ -void QwtPlotItem::setXAxis( int axis ) -{ - if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop ) - { - d_data->xAxis = axis; - itemChanged(); - } -} - -/*! - Set the Y axis - - The item will painted according to the coordinates its Axes. - - \param axis Y Axis - \sa setAxes(), setXAxis(), yAxis() -*/ -void QwtPlotItem::setYAxis( int axis ) -{ - if ( axis == QwtPlot::yLeft || axis == QwtPlot::yRight || - axis == QwtPlot::yLeft1 || axis == QwtPlot::yRight1 || - axis == QwtPlot::yLeft2 || axis == QwtPlot::yRight2 || - axis == QwtPlot::yLeft3 || axis == QwtPlot::yRight3 ) - { - d_data->yAxis = axis; - itemChanged(); - } -} - -//! Return xAxis -int QwtPlotItem::xAxis() const -{ - return d_data->xAxis; -} - -//! Return yAxis -int QwtPlotItem::yAxis() const -{ - return d_data->yAxis; -} - -/*! - \return An invalid bounding rect: QRectF(1.0, 1.0, -2.0, -2.0) -*/ -QRectF QwtPlotItem::boundingRect() const -{ - return QRectF( 1.0, 1.0, -2.0, -2.0 ); // invalid -} - -/*! - \brief Allocate the widget that represents the item on the legend - - The default implementation returns a QwtLegendItem(), but an item - could be represented by any type of widget, - by overloading legendItem() and updateLegend(). - - \return QwtLegendItem() - \sa updateLegend() QwtLegend() -*/ -QWidget *QwtPlotItem::legendItem() const -{ - QwtLegendItem *item = new QwtLegendItem; - if ( d_data->plot ) - { - QObject::connect( item, SIGNAL( clicked() ), - d_data->plot, SLOT( legendItemClicked() ) ); - QObject::connect( item, SIGNAL( checked( bool ) ), - d_data->plot, SLOT( legendItemChecked( bool ) ) ); - } - return item; -} - -/*! - \brief Update the widget that represents the item on the legend - - updateLegend() is called from itemChanged() to adopt the widget - representing the item on the legend to its new configuration. - - The default implementation updates a QwtLegendItem(), - but an item could be represented by any type of widget, - by overloading legendItem() and updateLegend(). - - \param legend Legend - - \sa legendItem(), itemChanged(), QwtLegend() -*/ -void QwtPlotItem::updateLegend( QwtLegend *legend ) const -{ - if ( legend == NULL ) - return; - - QWidget *lgdItem = legend->find( this ); - if ( testItemAttribute( QwtPlotItem::Legend ) ) - { - if ( lgdItem == NULL ) - { - lgdItem = legendItem(); - if ( lgdItem ) - legend->insert( this, lgdItem ); - } - - QwtLegendItem *label = qobject_cast( lgdItem ); - if ( label ) - { - // paint the identifier - const QSize sz = label->identifierSize(); - - QPixmap identifier( sz.width(), sz.height() ); - identifier.fill( Qt::transparent ); - - QPainter painter( &identifier ); - painter.setRenderHint( QPainter::Antialiasing, - testRenderHint( QwtPlotItem::RenderAntialiased ) ); - drawLegendIdentifier( &painter, - QRect( 0, 0, sz.width(), sz.height() ) ); - painter.end(); - - const bool doUpdate = label->updatesEnabled(); - if ( doUpdate ) - label->setUpdatesEnabled( false ); - - label->setText( title() ); - label->setIdentifier( identifier ); - label->setItemMode( legend->itemMode() ); - - if ( doUpdate ) - label->setUpdatesEnabled( true ); - - label->update(); - } - } - else - { - if ( lgdItem ) - { - lgdItem->hide(); - lgdItem->deleteLater(); - } - } -} - -/*! - \brief Update the item to changes of the axes scale division - - Update the item, when the axes of plot have changed. - The default implementation does nothing, but items that depend - on the scale division (like QwtPlotGrid()) have to reimplement - updateScaleDiv() - - \param xScaleDiv Scale division of the x-axis - \param yScaleDiv Scale division of the y-axis - - \sa QwtPlot::updateAxes() -*/ -void QwtPlotItem::updateScaleDiv( const QwtScaleDiv &xScaleDiv, - const QwtScaleDiv &yScaleDiv ) -{ - Q_UNUSED( xScaleDiv ); - Q_UNUSED( yScaleDiv ); -} - -/*! - \brief Calculate the bounding scale rect of 2 maps - - \param xMap X map - \param yMap X map - - \return Bounding scale rect of the scale maps, normalized -*/ -QRectF QwtPlotItem::scaleRect( const QwtScaleMap &xMap, - const QwtScaleMap &yMap ) const -{ - return QRectF( xMap.s1(), yMap.s1(), - xMap.sDist(), yMap.sDist() ); -} - -/*! - \brief Calculate the bounding paint rect of 2 maps - - \param xMap X map - \param yMap X map - - \return Bounding paint rect of the scale maps, normalized -*/ -QRectF QwtPlotItem::paintRect( const QwtScaleMap &xMap, - const QwtScaleMap &yMap ) const -{ - const QRectF rect( xMap.p1(), yMap.p1(), - xMap.pDist(), yMap.pDist() ); - - return rect; -} diff --git a/qwt/src/qwt_plot_item.h b/qwt/src/qwt_plot_item.h deleted file mode 100644 index ca3b5f037..000000000 --- a/qwt/src/qwt_plot_item.h +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_PLOT_ITEM_H -#define QWT_PLOT_ITEM_H - -#include "qwt_global.h" -#include "qwt_legend_itemmanager.h" -#include "qwt_text.h" -#include - -class QString; -class QPainter; -class QWidget; -class QwtPlot; -class QwtLegend; -class QwtScaleMap; -class QwtScaleDiv; - -/*! - \brief Base class for items on the plot canvas - - A plot item is "something", that can be painted on the plot canvas, - or only affects the scales of the plot widget. They can be categorized as: - - - Representator\n - A "Representator" is an item that represents some sort of data - on the plot canvas. The different representator classes are organized - according to the characteristics of the data: - - QwtPlotMarker - Represents a point or a horizontal/vertical coordinate - - QwtPlotCurve - Represents a series of points - - QwtPlotSpectrogram ( QwtPlotRasterItem ) - Represents raster data - - ... - - - Decorators\n - A "Decorator" is an item, that displays additional information, that - is not related to any data: - - QwtPlotGrid - - QwtPlotScaleItem - - QwtPlotSvgItem - - ... - - Depending on the QwtPlotItem::ItemAttribute flags, an item is included - into autoscaling or has an entry on the legnd. - - Before misusing the existing item classes it might be better to - implement a new type of plot item - ( don't implement a watermark as spectrogram ). - Deriving a new type of QwtPlotItem primarily means to implement - the YourPlotItem::draw() method. - - \sa The cpuplot example shows the implementation of additional plot items. -*/ - -class QWT_EXPORT QwtPlotItem: public QwtLegendItemManager -{ -public: - /*! - \brief Runtime type information - - RttiValues is used to cast plot items, without - having to enable runtime type information of the compiler. - */ - enum RttiValues - { - Rtti_PlotItem = 0, - - Rtti_PlotGrid, - Rtti_PlotScale, - Rtti_PlotMarker, - Rtti_PlotCurve, - Rtti_PlotSpectroCurve, - Rtti_PlotIntervalCurve, - Rtti_PlotHistogram, - Rtti_PlotSpectrogram, - Rtti_PlotSVG, - - Rtti_PlotUserItem = 1000 - }; - - /*! - Plot Item Attributes - \sa setItemAttribute(), testItemAttribute() - */ - enum ItemAttribute - { - //! The item is represented on the legend. - Legend = 0x01, - - /*! - The boundingRect() of the item is included in the - autoscaling calculation. - */ - AutoScale = 0x02 - }; - - //! Plot Item Attributes - typedef QFlags ItemAttributes; - - //! Render hints - enum RenderHint - { - //! Enable antialiasing - RenderAntialiased = 1 - }; - - //! Render hints - typedef QFlags RenderHints; - - explicit QwtPlotItem( const QwtText &title = QwtText() ); - virtual ~QwtPlotItem(); - - void attach( QwtPlot *plot ); - void detach(); - - QwtPlot *plot() const; - - void setTitle( const QString &title ); - void setTitle( const QwtText &title ); - const QwtText &title() const; - - virtual int rtti() const; - - void setItemAttribute( ItemAttribute, bool on = true ); - bool testItemAttribute( ItemAttribute ) const; - - void setRenderHint( RenderHint, bool on = true ); - bool testRenderHint( RenderHint ) const; - - double z() const; - void setZ( double z ); - - void show(); - void hide(); - virtual void setVisible( bool ); - bool isVisible () const; - - void setAxes( int xAxis, int yAxis ); - - void setXAxis( int axis ); - int xAxis() const; - - void setYAxis( int axis ); - int yAxis() const; - - virtual void itemChanged(); - - /*! - \brief Draw the item - - \param painter Painter - \param xMap Maps x-values into pixel coordinates. - \param yMap Maps y-values into pixel coordinates. - \param canvasRect Contents rect of the canvas in painter coordinates - */ - virtual void draw( QPainter *painter, - const QwtScaleMap &xMap, const QwtScaleMap &yMap, - const QRectF &canvasRect ) const = 0; - - virtual QRectF boundingRect() const; - - virtual void updateLegend( QwtLegend * ) const; - virtual void updateScaleDiv( - const QwtScaleDiv&, const QwtScaleDiv& ); - - virtual QWidget *legendItem() const; - - QRectF scaleRect( const QwtScaleMap &, const QwtScaleMap & ) const; - QRectF paintRect( const QwtScaleMap &, const QwtScaleMap & ) const; - -private: - // Disabled copy constructor and operator= - QwtPlotItem( const QwtPlotItem & ); - QwtPlotItem &operator=( const QwtPlotItem & ); - - class PrivateData; - PrivateData *d_data; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemAttributes ) -Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::RenderHints ) - -#endif diff --git a/qwt/src/qwt_plot_layout.cpp b/qwt/src/qwt_plot_layout.cpp deleted file mode 100644 index 9d319504d..000000000 --- a/qwt/src/qwt_plot_layout.cpp +++ /dev/null @@ -1,1353 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#include "qwt_plot_layout.h" -#include "qwt_text.h" -#include "qwt_text_label.h" -#include "qwt_plot_canvas.h" -#include "qwt_scale_widget.h" -#include "qwt_legend.h" -#include -#include - -class QwtPlotLayout::LayoutData -{ -public: - void init( const QwtPlot *, const QRectF &rect ); - - struct t_legendData - { - int frameWidth; - int vScrollBarWidth; - int hScrollBarHeight; - QSize hint; - } legend; - - struct t_titleData - { - QwtText text; - int frameWidth; - } title; - - struct t_scaleData - { - bool isEnabled; - const QwtScaleWidget *scaleWidget; - QFont scaleFont; - int start; - int end; - int baseLineOffset; - int tickOffset; - int dimWithoutTitle; - } scale[QwtPlot::axisCnt]; - - struct t_canvasData - { - int frameWidth; - } canvas; -}; - -/* - Extract all layout relevant data from the plot components -*/ - -void QwtPlotLayout::LayoutData::init( const QwtPlot *plot, const QRectF &rect ) -{ - // legend - - if ( plot->plotLayout()->legendPosition() != QwtPlot::ExternalLegend - && plot->legend() ) - { - legend.frameWidth = plot->legend()->frameWidth(); - legend.vScrollBarWidth = - plot->legend()->verticalScrollBar()->sizeHint().width(); - legend.hScrollBarHeight = - plot->legend()->horizontalScrollBar()->sizeHint().height(); - - const QSize hint = plot->legend()->sizeHint(); - - int w = qMin( hint.width(), qFloor( rect.width() ) ); - int h = plot->legend()->heightForWidth( w ); - if ( h == 0 ) - h = hint.height(); - - if ( h > rect.height() ) - w += legend.vScrollBarWidth; - - legend.hint = QSize( w, h ); - } - - // title - - title.frameWidth = 0; - title.text = QwtText(); - - if ( plot->titleLabel() ) - { - const QwtTextLabel *label = plot->titleLabel(); - title.text = label->text(); - if ( !( title.text.testPaintAttribute( QwtText::PaintUsingTextFont ) ) ) - title.text.setFont( label->font() ); - - title.frameWidth = plot->titleLabel()->frameWidth(); - } - - // scales - - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - { - if ( plot->axisEnabled( axis ) ) - { - const QwtScaleWidget *scaleWidget = plot->axisWidget( axis ); - - scale[axis].isEnabled = true; - - scale[axis].scaleWidget = scaleWidget; - - scale[axis].scaleFont = scaleWidget->font(); - - scale[axis].start = scaleWidget->startBorderDist(); - scale[axis].end = scaleWidget->endBorderDist(); - - scale[axis].baseLineOffset = scaleWidget->margin(); - scale[axis].tickOffset = scaleWidget->margin(); - if ( scaleWidget->scaleDraw()->hasComponent( - QwtAbstractScaleDraw::Ticks ) ) - { - scale[axis].tickOffset += - scaleWidget->scaleDraw()->maxTickLength(); - } - - scale[axis].dimWithoutTitle = scaleWidget->dimForLength( - QWIDGETSIZE_MAX, scale[axis].scaleFont ); - - if ( !scaleWidget->title().isEmpty() ) - { - scale[axis].dimWithoutTitle -= - scaleWidget->titleHeightForWidth( QWIDGETSIZE_MAX ); - } - } - else - { - scale[axis].isEnabled = false; - scale[axis].start = 0; - scale[axis].end = 0; - scale[axis].baseLineOffset = 0; - scale[axis].tickOffset = 0; - scale[axis].dimWithoutTitle = 0; - } - } - - // canvas - - canvas.frameWidth = plot->canvas()->frameWidth(); -} - -class QwtPlotLayout::PrivateData -{ -public: - PrivateData(): - spacing( 5 ), - alignCanvasToScales( false ) - { - } - - QRectF titleRect; - QRectF legendRect; - QRectF scaleRect[QwtPlot::axisCnt]; - QRectF canvasRect; - - QwtPlotLayout::LayoutData layoutData; - - QwtPlot::LegendPosition legendPos; - double legendRatio; - unsigned int spacing; - unsigned int canvasMargin[QwtPlot::axisCnt]; - bool alignCanvasToScales; -}; - -/*! - \brief Constructor - */ - -QwtPlotLayout::QwtPlotLayout() -{ - d_data = new PrivateData; - - setLegendPosition( QwtPlot::BottomLegend ); - setCanvasMargin( 4 ); - - invalidate(); -} - -//! Destructor -QwtPlotLayout::~QwtPlotLayout() -{ - delete d_data; -} - -/*! - Change a margin of the canvas. The margin is the space - above/below the scale ticks. A negative margin will - be set to -1, excluding the borders of the scales. - - \param margin New margin - \param axis One of QwtPlot::Axis. Specifies where the position of the margin. - -1 means margin at all borders. - \sa canvasMargin() - - \warning The margin will have no effect when alignCanvasToScales is true -*/ - -void QwtPlotLayout::setCanvasMargin( int margin, int axis ) -{ - if ( margin < -1 ) - margin = -1; - - if ( axis == -1 ) - { - for ( axis = 0; axis < QwtPlot::axisCnt; axis++ ) - d_data->canvasMargin[axis] = margin; - } - else if ( axis >= 0 && axis < QwtPlot::axisCnt ) - d_data->canvasMargin[axis] = margin; -} - -/*! - \return Margin around the scale tick borders - \sa setCanvasMargin() -*/ -int QwtPlotLayout::canvasMargin( int axis ) const -{ - if ( axis < 0 || axis >= QwtPlot::axisCnt ) - return 0; - - return d_data->canvasMargin[axis]; -} - -/*! - Change the align-canvas-to-axis-scales setting. The canvas may: - - extend beyond the axis scale ends to maximize its size, - - align with the axis scale ends to control its size. - - \param alignCanvasToScales New align-canvas-to-axis-scales setting - - \sa setCanvasMargin() - \note In this context the term 'scale' means the backbone of a scale. - \warning In case of alignCanvasToScales == true canvasMargin will have - no effect -*/ -void QwtPlotLayout::setAlignCanvasToScales( bool alignCanvasToScales ) -{ - d_data->alignCanvasToScales = alignCanvasToScales; -} - -/*! - Return the align-canvas-to-axis-scales setting. The canvas may: - - extend beyond the axis scale ends to maximize its size - - align with the axis scale ends to control its size. - - \return align-canvas-to-axis-scales setting - \sa setAlignCanvasToScales, setCanvasMargin() - \note In this context the term 'scale' means the backbone of a scale. -*/ -bool QwtPlotLayout::alignCanvasToScales() const -{ - return d_data->alignCanvasToScales; -} - -/*! - Change the spacing of the plot. The spacing is the distance - between the plot components. - - \param spacing new spacing - \sa setMargin(), spacing() -*/ -void QwtPlotLayout::setSpacing( int spacing ) -{ - d_data->spacing = qMax( 0, spacing ); -} - -/*! - \return spacing - \sa margin(), setSpacing() -*/ -int QwtPlotLayout::spacing() const -{ - return d_data->spacing; -} - -/*! - \brief Specify the position of the legend - \param pos The legend's position. - \param ratio Ratio between legend and the bounding rect - of title, canvas and axes. The legend will be shrinked - if it would need more space than the given ratio. - The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0 - it will be reset to the default ratio. - The default vertical/horizontal ratio is 0.33/0.5. - - \sa QwtPlot::setLegendPosition() -*/ - -void QwtPlotLayout::setLegendPosition( QwtPlot::LegendPosition pos, double ratio ) -{ - if ( ratio > 1.0 ) - ratio = 1.0; - - switch ( pos ) - { - case QwtPlot::TopLegend: - case QwtPlot::BottomLegend: - if ( ratio <= 0.0 ) - ratio = 0.33; - d_data->legendRatio = ratio; - d_data->legendPos = pos; - break; - case QwtPlot::LeftLegend: - case QwtPlot::RightLegend: - if ( ratio <= 0.0 ) - ratio = 0.5; - d_data->legendRatio = ratio; - d_data->legendPos = pos; - break; - case QwtPlot::ExternalLegend: - d_data->legendRatio = ratio; // meaningless - d_data->legendPos = pos; - default: - break; - } -} - -/*! - \brief Specify the position of the legend - \param pos The legend's position. Valid values are - \c QwtPlot::LeftLegend, \c QwtPlot::RightLegend, - \c QwtPlot::TopLegend, \c QwtPlot::BottomLegend. - - \sa QwtPlot::setLegendPosition() -*/ -void QwtPlotLayout::setLegendPosition( QwtPlot::LegendPosition pos ) -{ - setLegendPosition( pos, 0.0 ); -} - -/*! - \return Position of the legend - \sa setLegendPosition(), QwtPlot::setLegendPosition(), - QwtPlot::legendPosition() -*/ -QwtPlot::LegendPosition QwtPlotLayout::legendPosition() const -{ - return d_data->legendPos; -} - -/*! - Specify the relative size of the legend in the plot - \param ratio Ratio between legend and the bounding rect - of title, canvas and axes. The legend will be shrinked - if it would need more space than the given ratio. - The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0 - it will be reset to the default ratio. - The default vertical/horizontal ratio is 0.33/0.5. -*/ -void QwtPlotLayout::setLegendRatio( double ratio ) -{ - setLegendPosition( legendPosition(), ratio ); -} - -/*! - \return The relative size of the legend in the plot. - \sa setLegendPosition() -*/ -double QwtPlotLayout::legendRatio() const -{ - return d_data->legendRatio; -} - -/*! - \return Geometry for the title - \sa activate(), invalidate() -*/ - -const QRectF &QwtPlotLayout::titleRect() const -{ - return d_data->titleRect; -} - -/*! - \return Geometry for the legend - \sa activate(), invalidate() -*/ - -const QRectF &QwtPlotLayout::legendRect() const -{ - return d_data->legendRect; -} - -/*! - \param axis Axis index - \return Geometry for the scale - \sa activate(), invalidate() -*/ - -const QRectF &QwtPlotLayout::scaleRect( int axis ) const -{ - if ( axis < 0 || axis >= QwtPlot::axisCnt ) - { - static QRectF dummyRect; - return dummyRect; - } - return d_data->scaleRect[axis]; -} - -/*! - \return Geometry for the canvas - \sa activate(), invalidate() -*/ - -const QRectF &QwtPlotLayout::canvasRect() const -{ - return d_data->canvasRect; -} - -/*! - Invalidate the geometry of all components. - \sa activate() -*/ -void QwtPlotLayout::invalidate() -{ - d_data->titleRect = d_data->legendRect = d_data->canvasRect = QRect(); - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - d_data->scaleRect[axis] = QRect(); -} - -/*! - \brief Return a minimum size hint - \sa QwtPlot::minimumSizeHint() -*/ - -QSize QwtPlotLayout::minimumSizeHint( const QwtPlot *plot ) const -{ - class ScaleData - { - public: - ScaleData() - { - w = h = minLeft = minRight = tickOffset = 0; - } - - int w; - int h; - int minLeft; - int minRight; - int tickOffset; - } scaleData[QwtPlot::axisCnt]; - - int canvasBorder[QwtPlot::axisCnt]; - - int axis; - for ( axis = 0; axis < QwtPlot::axisCnt; axis++ ) - { - if ( plot->axisEnabled( axis ) ) - { - const QwtScaleWidget *scl = plot->axisWidget( axis ); - ScaleData &sd = scaleData[axis]; - - const QSize hint = scl->minimumSizeHint(); - sd.w = hint.width(); - sd.h = hint.height(); - scl->getBorderDistHint( sd.minLeft, sd.minRight ); - sd.tickOffset = scl->margin(); - if ( scl->scaleDraw()->hasComponent( QwtAbstractScaleDraw::Ticks ) ) - sd.tickOffset += scl->scaleDraw()->maxTickLength(); - } - - canvasBorder[axis] = plot->canvas()->frameWidth() + - d_data->canvasMargin[axis] + 1; - - } - - - for ( axis = 0; axis < QwtPlot::axisCnt; axis++ ) - { - ScaleData &sd = scaleData[axis]; - if ( sd.w && ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop ) ) - { - if ( (sd.minLeft > canvasBorder[QwtPlot::yLeft3]) - && scaleData[QwtPlot::yLeft3].w ) - { - int shiftLeft = sd.minLeft - canvasBorder[QwtPlot::yLeft3]; - if ( shiftLeft > scaleData[QwtPlot::yLeft3].w ) - shiftLeft = scaleData[QwtPlot::yLeft3].w; - - sd.w -= shiftLeft; - } - if ( (sd.minLeft > canvasBorder[QwtPlot::yLeft3]) - && scaleData[QwtPlot::yLeft2].w ) - { - int shiftLeft = sd.minLeft - scaleData[QwtPlot::yLeft3].w - canvasBorder[QwtPlot::yLeft3]; - if ( shiftLeft > (scaleData[QwtPlot::yLeft3].w + scaleData[QwtPlot::yLeft2].w) ) - shiftLeft = scaleData[QwtPlot::yLeft3].w + scaleData[QwtPlot::yLeft2].w; - - sd.w -= shiftLeft; - } - if ( (sd.minLeft > canvasBorder[QwtPlot::yLeft3]) - && scaleData[QwtPlot::yLeft1].w ) - { - int shiftLeft = sd.minLeft - scaleData[QwtPlot::yLeft3].w - scaleData[QwtPlot::yLeft2].w - canvasBorder[QwtPlot::yLeft3]; - if ( shiftLeft > (scaleData[QwtPlot::yLeft3].w + scaleData[QwtPlot::yLeft2].w + scaleData[QwtPlot::yLeft1].w) ) - shiftLeft = scaleData[QwtPlot::yLeft3].w + scaleData[QwtPlot::yLeft2].w + scaleData[QwtPlot::yLeft1].w; - - sd.w -= shiftLeft; - } - if ( (sd.minLeft > canvasBorder[QwtPlot::yLeft3]) - && scaleData[QwtPlot::yLeft].w ) - { - int shiftLeft = sd.minLeft - scaleData[QwtPlot::yLeft3].w - scaleData[QwtPlot::yLeft2].w - - scaleData[QwtPlot::yLeft1].w - canvasBorder[QwtPlot::yLeft3]; - if ( shiftLeft > (scaleData[QwtPlot::yLeft3].w + scaleData[QwtPlot::yLeft2].w + - scaleData[QwtPlot::yLeft1].w + scaleData[QwtPlot::yLeft].w) ) - shiftLeft = scaleData[QwtPlot::yLeft3].w + scaleData[QwtPlot::yLeft2].w + - scaleData[QwtPlot::yLeft1].w + scaleData[QwtPlot::yLeft].w; - sd.w -= shiftLeft; - } - - if ( (sd.minRight > canvasBorder[QwtPlot::yRight3]) - && scaleData[QwtPlot::yRight3].w ) - { - int shiftRight = sd.minRight - canvasBorder[QwtPlot::yRight3]; - if ( shiftRight > scaleData[QwtPlot::yRight3].w ) - shiftRight = scaleData[QwtPlot::yRight3].w; - - sd.w -= shiftRight; - } - if ( (sd.minRight > canvasBorder[QwtPlot::yRight3]) - && scaleData[QwtPlot::yRight2].w ) - { - int shiftRight = sd.minRight - scaleData[QwtPlot::yRight3].w - canvasBorder[QwtPlot::yRight3]; - if ( shiftRight > (scaleData[QwtPlot::yRight3].w + scaleData[QwtPlot::yRight2].w) ) - shiftRight = scaleData[QwtPlot::yRight3].w + scaleData[QwtPlot::yRight2].w; - - sd.w -=shiftRight; - } - if ( (sd.minRight > canvasBorder[QwtPlot::yRight3]) - && scaleData[QwtPlot::yRight1].w ) - { - int shiftRight = sd.minRight - scaleData[QwtPlot::yRight3].w - scaleData[QwtPlot::yRight2].w - - canvasBorder[QwtPlot::yRight3]; - if ( shiftRight > (scaleData[QwtPlot::yRight3].w + scaleData[QwtPlot::yRight2].w + scaleData[QwtPlot::yRight1].w) ) - shiftRight = scaleData[QwtPlot::yRight3].w + scaleData[QwtPlot::yRight2].w + scaleData[QwtPlot::yRight1].w; - - sd.w -= shiftRight; - } - if ( (sd.minRight > canvasBorder[QwtPlot::yRight3]) - && scaleData[QwtPlot::yRight].w ) - { - int shiftRight = sd.minRight - scaleData[QwtPlot::yRight3].w - scaleData[QwtPlot::yRight2].w - - scaleData[QwtPlot::yRight1].w - canvasBorder[QwtPlot::yRight3]; - if ( shiftRight > (scaleData[QwtPlot::yRight3].w + scaleData[QwtPlot::yRight2].w - +scaleData[QwtPlot::yRight1].w + scaleData[QwtPlot::yRight].w) ) - shiftRight = scaleData[QwtPlot::yRight3].w + scaleData[QwtPlot::yRight2].w - +scaleData[QwtPlot::yRight1].w + scaleData[QwtPlot::yRight].w; - - sd.w -= shiftRight; - } - - - /*if ( ( sd.minLeft > canvasBorder[QwtPlot::yLeft] ) - && scaleData[QwtPlot::yLeft].w ) - { - int shiftLeft = sd.minLeft - canvasBorder[QwtPlot::yLeft]; - if ( shiftLeft > scaleData[QwtPlot::yLeft].w ) - shiftLeft = scaleData[QwtPlot::yLeft].w; - - sd.w -= shiftLeft; - } - if ( ( sd.minRight > canvasBorder[QwtPlot::yRight] ) - && scaleData[QwtPlot::yRight].w ) - { - int shiftRight = sd.minRight - canvasBorder[QwtPlot::yRight]; - if ( shiftRight > scaleData[QwtPlot::yRight].w ) - shiftRight = scaleData[QwtPlot::yRight].w; - - sd.w -= shiftRight; - }*/ - } - - if ( sd.h && (axis == QwtPlot::yLeft || axis == QwtPlot::yRight || - axis == QwtPlot::yLeft1 || axis == QwtPlot::yRight1 || - axis == QwtPlot::yLeft2 || axis == QwtPlot::yRight2 || - axis == QwtPlot::yLeft3 || axis == QwtPlot::yRight3)) - { - if ( ( sd.minLeft > canvasBorder[QwtPlot::xBottom] ) && - scaleData[QwtPlot::xBottom].h ) - { - int shiftBottom = sd.minLeft - canvasBorder[QwtPlot::xBottom]; - if ( shiftBottom > scaleData[QwtPlot::xBottom].tickOffset ) - shiftBottom = scaleData[QwtPlot::xBottom].tickOffset; - - sd.h -= shiftBottom; - } - if ( ( sd.minLeft > canvasBorder[QwtPlot::xTop] ) && - scaleData[QwtPlot::xTop].h ) - { - int shiftTop = sd.minRight - canvasBorder[QwtPlot::xTop]; - if ( shiftTop > scaleData[QwtPlot::xTop].tickOffset ) - shiftTop = scaleData[QwtPlot::xTop].tickOffset; - - sd.h -= shiftTop; - } - } - } - - const QwtPlotCanvas *canvas = plot->canvas(); - const QSize minCanvasSize = canvas->minimumSize(); - - //int w = scaleData[QwtPlot::yLeft].w + scaleData[QwtPlot::yRight].w; - int w = scaleData[QwtPlot::yLeft].w + scaleData[QwtPlot::yRight].w - + scaleData[QwtPlot::yLeft1].w + scaleData[QwtPlot::yRight1].w - + scaleData[QwtPlot::yLeft2].w + scaleData[QwtPlot::yRight2].w - + scaleData[QwtPlot::yLeft3].w + scaleData[QwtPlot::yRight3].w; - - int cw = qMax( scaleData[QwtPlot::xBottom].w, scaleData[QwtPlot::xTop].w ) - + 2 * ( canvas->frameWidth() + 1 ); - w += qMax( cw, minCanvasSize.width() ); - - int h = scaleData[QwtPlot::xBottom].h + scaleData[QwtPlot::xTop].h; - int ch = qMax( scaleData[QwtPlot::yLeft].h, scaleData[QwtPlot::yRight].h ) - + 2 * ( canvas->frameWidth() + 1 ); - h += qMax( ch, minCanvasSize.height() ); - - const QwtTextLabel *title = plot->titleLabel(); - if ( title && !title->text().isEmpty() ) - { - // If only QwtPlot::yLeft or QwtPlot::yRight is showing, - // we center on the plot canvas. - const bool centerOnCanvas = !( plot->axisEnabled( QwtPlot::yLeft ) - && plot->axisEnabled( QwtPlot::yRight ) ); - - int titleW = w; - if ( centerOnCanvas ) - { - titleW -= scaleData[QwtPlot::yLeft].w - + scaleData[QwtPlot::yRight].w; - } - - int titleH = title->heightForWidth( titleW ); - if ( titleH > titleW ) // Compensate for a long title - { - w = titleW = titleH; - if ( centerOnCanvas ) - { - w += scaleData[QwtPlot::yLeft].w - + scaleData[QwtPlot::yRight].w; - } - - titleH = title->heightForWidth( titleW ); - } - h += titleH + d_data->spacing; - } - - // Compute the legend contribution - - const QwtLegend *legend = plot->legend(); - if ( d_data->legendPos != QwtPlot::ExternalLegend - && legend && !legend->isEmpty() ) - { - if ( d_data->legendPos == QwtPlot::LeftLegend - || d_data->legendPos == QwtPlot::RightLegend ) - { - int legendW = legend->sizeHint().width(); - int legendH = legend->heightForWidth( legendW ); - - if ( legend->frameWidth() > 0 ) - w += d_data->spacing; - - if ( legendH > h ) - legendW += legend->verticalScrollBar()->sizeHint().height(); - - if ( d_data->legendRatio < 1.0 ) - legendW = qMin( legendW, int( w / ( 1.0 - d_data->legendRatio ) ) ); - - w += legendW + d_data->spacing; - } - else // QwtPlot::Top, QwtPlot::Bottom - { - int legendW = qMin( legend->sizeHint().width(), w ); - int legendH = legend->heightForWidth( legendW ); - - if ( legend->frameWidth() > 0 ) - h += d_data->spacing; - - if ( d_data->legendRatio < 1.0 ) - legendH = qMin( legendH, int( h / ( 1.0 - d_data->legendRatio ) ) ); - - h += legendH + d_data->spacing; - } - } - - return QSize( w, h ); -} - -/*! - Find the geometry for the legend - \param options Options how to layout the legend - \param rect Rectangle where to place the legend - \return Geometry for the legend - \sa Options -*/ - -QRectF QwtPlotLayout::layoutLegend( Options options, - const QRectF &rect ) const -{ - const QSize hint( d_data->layoutData.legend.hint ); - - int dim; - if ( d_data->legendPos == QwtPlot::LeftLegend - || d_data->legendPos == QwtPlot::RightLegend ) - { - // We don't allow vertical legends to take more than - // half of the available space. - - dim = qMin( hint.width(), int( rect.width() * d_data->legendRatio ) ); - - if ( !( options & IgnoreScrollbars ) ) - { - if ( hint.height() > rect.height() ) - { - // The legend will need additional - // space for the vertical scrollbar. - - dim += d_data->layoutData.legend.vScrollBarWidth; - } - } - } - else - { - dim = qMin( hint.height(), int( rect.height() * d_data->legendRatio ) ); - dim = qMax( dim, d_data->layoutData.legend.hScrollBarHeight ); - } - - QRectF legendRect = rect; - switch ( d_data->legendPos ) - { - case QwtPlot::LeftLegend: - legendRect.setWidth( dim ); - break; - case QwtPlot::RightLegend: - legendRect.setX( rect.right() - dim ); - legendRect.setWidth( dim ); - break; - case QwtPlot::TopLegend: - legendRect.setHeight( dim ); - break; - case QwtPlot::BottomLegend: - legendRect.setY( rect.bottom() - dim ); - legendRect.setHeight( dim ); - break; - case QwtPlot::ExternalLegend: - break; - } - - return legendRect; -} - -/*! - Align the legend to the canvas - \param canvasRect Geometry of the canvas - \param legendRect Maximum geometry for the legend - \return Geometry for the aligned legend -*/ -QRectF QwtPlotLayout::alignLegend( const QRectF &canvasRect, - const QRectF &legendRect ) const -{ - QRectF alignedRect = legendRect; - - if ( d_data->legendPos == QwtPlot::BottomLegend - || d_data->legendPos == QwtPlot::TopLegend ) - { - if ( d_data->layoutData.legend.hint.width() < canvasRect.width() ) - { - alignedRect.setX( canvasRect.x() ); - alignedRect.setWidth( canvasRect.width() ); - } - } - else - { - if ( d_data->layoutData.legend.hint.height() < canvasRect.height() ) - { - alignedRect.setY( canvasRect.y() ); - alignedRect.setHeight( canvasRect.height() ); - } - } - - return alignedRect; -} - -/*! - Expand all line breaks in text labels, and calculate the height - of their widgets in orientation of the text. - - \param options Options how to layout the legend - \param rect Bounding rect for title, axes and canvas. - \param dimTitle Expanded height of the title widget - \param dimAxis Expanded heights of the axis in axis orientation. - - \sa Options -*/ -void QwtPlotLayout::expandLineBreaks( int options, const QRectF &rect, - int &dimTitle, int dimAxis[QwtPlot::axisCnt] ) const -{ - dimTitle = 0; - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - dimAxis[axis] = 0; - - int backboneOffset[QwtPlot::axisCnt]; - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - { - backboneOffset[axis] = 0; - if ( !d_data->alignCanvasToScales ) - backboneOffset[axis] += d_data->canvasMargin[axis]; - if ( !( options & IgnoreFrames ) ) - backboneOffset[axis] += d_data->layoutData.canvas.frameWidth; - } - - bool done = false; - while ( !done ) - { - done = true; - - // the size for the 4 axis depend on each other. Expanding - // the height of a horizontal axis will shrink the height - // for the vertical axis, shrinking the height of a vertical - // axis will result in a line break what will expand the - // width and results in shrinking the width of a horizontal - // axis what might result in a line break of a horizontal - // axis ... . So we loop as long until no size changes. - - if ( !d_data->layoutData.title.text.isEmpty() ) - { - int w = rect.width(); - - if ( d_data->layoutData.scale[QwtPlot::yLeft].isEnabled - != d_data->layoutData.scale[QwtPlot::yRight].isEnabled ) - { - // center to the canvas - w -= dimAxis[QwtPlot::yLeft] + dimAxis[QwtPlot::yRight]; - } - - int d = qCeil( d_data->layoutData.title.text.heightForWidth( w ) ); - if ( !( options & IgnoreFrames ) ) - d += 2 * d_data->layoutData.title.frameWidth; - - if ( d > dimTitle ) - { - dimTitle = d; - done = false; - } - } - - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - { - const struct LayoutData::t_scaleData &scaleData = - d_data->layoutData.scale[axis]; - - if ( scaleData.isEnabled ) - { - int length; - if ( axis == QwtPlot::xTop || axis == QwtPlot::xBottom ) - { - length = rect.width() - dimAxis[QwtPlot::yLeft] - - dimAxis[QwtPlot::yRight]; - length -= scaleData.start + scaleData.end; - - if ( dimAxis[QwtPlot::yRight] > 0 ) - length -= 1; - - length += qMin( dimAxis[QwtPlot::yLeft], - scaleData.start - backboneOffset[QwtPlot::yLeft] ); - length += qMin( dimAxis[QwtPlot::yRight], - scaleData.end - backboneOffset[QwtPlot::yRight] ); - } - else // QwtPlot::yLeft, QwtPlot::yRight - { - length = rect.height() - dimAxis[QwtPlot::xTop] - - dimAxis[QwtPlot::xBottom]; - length -= scaleData.start + scaleData.end; - length -= 1; - - if ( dimAxis[QwtPlot::xBottom] <= 0 ) - length -= 1; - if ( dimAxis[QwtPlot::xTop] <= 0 ) - length -= 1; - - if ( dimAxis[QwtPlot::xBottom] > 0 ) - { - length += qMin( - d_data->layoutData.scale[QwtPlot::xBottom].tickOffset, - scaleData.start - backboneOffset[QwtPlot::xBottom] ); - } - if ( dimAxis[QwtPlot::xTop] > 0 ) - { - length += qMin( - d_data->layoutData.scale[QwtPlot::xTop].tickOffset, - scaleData.end - backboneOffset[QwtPlot::xTop] ); - } - - if ( dimTitle > 0 ) - length -= dimTitle + d_data->spacing; - } - - int d = scaleData.dimWithoutTitle; - if ( !scaleData.scaleWidget->title().isEmpty() ) - { - d += scaleData.scaleWidget->titleHeightForWidth( length ); - } - - - if ( d > dimAxis[axis] ) - { - dimAxis[axis] = d; - done = false; - } - } - } - } -} - -/*! - Align the ticks of the axis to the canvas borders using - the empty corners. - - \sa Options -*/ - -void QwtPlotLayout::alignScales( int options, - QRectF &canvasRect, QRectF scaleRect[QwtPlot::axisCnt] ) const -{ - int backboneOffset[QwtPlot::axisCnt]; - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - { - backboneOffset[axis] = 0; - if ( !d_data->alignCanvasToScales ) - backboneOffset[axis] += d_data->canvasMargin[axis]; - if ( !( options & IgnoreFrames ) ) - backboneOffset[axis] += d_data->layoutData.canvas.frameWidth; - } - - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - { - if ( !scaleRect[axis].isValid() ) - continue; - - const int startDist = d_data->layoutData.scale[axis].start; - const int endDist = d_data->layoutData.scale[axis].end; - - QRectF &axisRect = scaleRect[axis]; - - if ( axis == QwtPlot::xTop || axis == QwtPlot::xBottom ) - { - const QRectF &leftScaleRect = scaleRect[QwtPlot::yLeft]; - const int leftOffset = - backboneOffset[QwtPlot::yLeft] - startDist; - - if ( leftScaleRect.isValid() ) - { - const int dx = leftOffset + leftScaleRect.width(); - if ( d_data->alignCanvasToScales && dx < 0 ) - { - /* - The axis needs more space than the width - of the left scale. - */ - canvasRect.setLeft( qMax( canvasRect.left(), - axisRect.left() - dx ) ); - } - else - { - const double minLeft = leftScaleRect.left(); - const double left = axisRect.left() + leftOffset; - axisRect.setLeft( qMax( left, minLeft ) ); - } - } - else - { - if ( d_data->alignCanvasToScales && leftOffset < 0 ) - { - canvasRect.setLeft( qMax( canvasRect.left(), - axisRect.left() - leftOffset ) ); - } - else - { - if ( leftOffset > 0 ) - axisRect.setLeft( axisRect.left() + leftOffset ); - } - } - - const QRectF &rightScaleRect = scaleRect[QwtPlot::yRight]; - const int rightOffset = - backboneOffset[QwtPlot::yRight] - endDist + 1; - - if ( rightScaleRect.isValid() ) - { - const int dx = rightOffset + rightScaleRect.width(); - if ( d_data->alignCanvasToScales && dx < 0 ) - { - /* - The axis needs more space than the width - of the right scale. - */ - canvasRect.setRight( qMin( canvasRect.right(), - axisRect.right() + dx ) ); - } - - const double maxRight = rightScaleRect.right(); - const double right = axisRect.right() - rightOffset; - axisRect.setRight( qMin( right, maxRight ) ); - } - else - { - if ( d_data->alignCanvasToScales && rightOffset < 0 ) - { - canvasRect.setRight( qMin( canvasRect.right(), - axisRect.right() + rightOffset ) ); - } - else - { - if ( rightOffset > 0 ) - axisRect.setRight( axisRect.right() - rightOffset ); - } - } - } - else // QwtPlot::yLeft, QwtPlot::yRight - { - const QRectF &bottomScaleRect = scaleRect[QwtPlot::xBottom]; - const int bottomOffset = - backboneOffset[QwtPlot::xBottom] - endDist + 1; - - if ( bottomScaleRect.isValid() ) - { - const int dy = bottomOffset + bottomScaleRect.height(); - if ( d_data->alignCanvasToScales && dy < 0 ) - { - /* - The axis needs more space than the height - of the bottom scale. - */ - canvasRect.setBottom( qMin( canvasRect.bottom(), - axisRect.bottom() + dy ) ); - } - else - { - const double maxBottom = bottomScaleRect.top() + - d_data->layoutData.scale[QwtPlot::xBottom].tickOffset; - const double bottom = axisRect.bottom() - bottomOffset; - axisRect.setBottom( qMin( bottom, maxBottom ) ); - } - } - else - { - if ( d_data->alignCanvasToScales && bottomOffset < 0 ) - { - canvasRect.setBottom( qMin( canvasRect.bottom(), - axisRect.bottom() + bottomOffset ) ); - } - else - { - if ( bottomOffset > 0 ) - axisRect.setBottom( axisRect.bottom() - bottomOffset ); - } - } - - const QRectF &topScaleRect = scaleRect[QwtPlot::xTop]; - const int topOffset = backboneOffset[QwtPlot::xTop] - startDist; - - if ( topScaleRect.isValid() ) - { - const int dy = topOffset + topScaleRect.height(); - if ( d_data->alignCanvasToScales && dy < 0 ) - { - /* - The axis needs more space than the height - of the top scale. - */ - canvasRect.setTop( qMax( canvasRect.top(), - axisRect.top() - dy ) ); - } - else - { - const double minTop = topScaleRect.bottom() - - d_data->layoutData.scale[QwtPlot::xTop].tickOffset; - const double top = axisRect.top() + topOffset; - axisRect.setTop( qMax( top, minTop ) ); - } - } - else - { - if ( d_data->alignCanvasToScales && topOffset < 0 ) - { - canvasRect.setTop( qMax( canvasRect.top(), - axisRect.top() - topOffset ) ); - } - else - { - if ( topOffset > 0 ) - axisRect.setTop( axisRect.top() + topOffset ); - } - } - } - } - - if ( d_data->alignCanvasToScales ) - { - /* - The canvas has been aligned to the scale with largest - border distances. Now we have to realign the other scale. - */ - - int fw = 0; - if ( !( options & IgnoreFrames ) ) - fw = d_data->layoutData.canvas.frameWidth; - - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - { - if ( !scaleRect[axis].isValid() ) - continue; - - if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop ) - { - scaleRect[axis].setLeft( canvasRect.left() + fw - - d_data->layoutData.scale[axis].start ); - scaleRect[axis].setRight( canvasRect.right() - fw - 1 - + d_data->layoutData.scale[axis].end ); - } - else - { - scaleRect[axis].setTop( canvasRect.top() + fw - - d_data->layoutData.scale[axis].start ); - scaleRect[axis].setBottom( canvasRect.bottom() - fw - 1 - + d_data->layoutData.scale[axis].end ); - } - } - - if ( scaleRect[QwtPlot::xTop].isValid() ) - scaleRect[QwtPlot::xTop].setBottom( canvasRect.top() ); - if ( scaleRect[QwtPlot::xBottom].isValid() ) - scaleRect[QwtPlot::xBottom].setTop( canvasRect.bottom() ); - if ( scaleRect[QwtPlot::yLeft].isValid() ) - scaleRect[QwtPlot::yLeft].setRight( canvasRect.left() ); - if ( scaleRect[QwtPlot::yRight].isValid() ) - scaleRect[QwtPlot::yRight].setLeft( canvasRect.right() ); - } -} - -/*! - \brief Recalculate the geometry of all components. - - \param plot Plot to be layout - \param plotRect Rect where to place the components - \param options Layout options - - \sa invalidate(), titleRect(), - legendRect(), scaleRect(), canvasRect() -*/ -void QwtPlotLayout::activate( const QwtPlot *plot, - const QRectF &plotRect, Options options ) -{ - invalidate(); - - QRectF rect( plotRect ); // undistributed rest of the plot rect - - // We extract all layout relevant data from the widgets, - // filter them through pfilter and save them to d_data->layoutData. - - d_data->layoutData.init( plot, rect ); - - if ( !( options & IgnoreLegend ) - && d_data->legendPos != QwtPlot::ExternalLegend - && plot->legend() && !plot->legend()->isEmpty() ) - { - d_data->legendRect = layoutLegend( options, rect ); - - // subtract d_data->legendRect from rect - - const QRegion region( rect.toRect() ); - rect = region.subtract( d_data->legendRect.toRect() ).boundingRect(); - - switch ( d_data->legendPos ) - { - case QwtPlot::LeftLegend: - rect.setLeft( rect.left() + d_data->spacing ); - break; - case QwtPlot::RightLegend: - rect.setRight( rect.right() - d_data->spacing ); - break; - case QwtPlot::TopLegend: - rect.setTop( rect.top() + d_data->spacing ); - break; - case QwtPlot::BottomLegend: - rect.setBottom( rect.bottom() - d_data->spacing ); - break; - case QwtPlot::ExternalLegend: - break; // suppress compiler warning - } - } - - /* - +---+-----------+---+ - | Title | - +---+-----------+---+ - | | Axis | | - +---+-----------+---+ - | A | | A | - | x | Canvas | x | - | i | | i | - | s | | s | - +---+-----------+---+ - | | Axis | | - +---+-----------+---+ - */ - - // axes and title include text labels. The height of each - // label depends on its line breaks, that depend on the width - // for the label. A line break in a horizontal text will reduce - // the available width for vertical texts and vice versa. - // expandLineBreaks finds the height/width for title and axes - // including all line breaks. - - int dimTitle, dimAxes[QwtPlot::axisCnt]; - expandLineBreaks( options, rect, dimTitle, dimAxes ); - - if ( dimTitle > 0 ) - { - d_data->titleRect = QRect( rect.x(), rect.y(), - rect.width(), dimTitle ); - - if ( d_data->layoutData.scale[QwtPlot::yLeft].isEnabled != - d_data->layoutData.scale[QwtPlot::yRight].isEnabled ) - { - // if only one of the y axes is missing we align - // the title centered to the canvas - - d_data->titleRect.setX( rect.x() + dimAxes[QwtPlot::yLeft] ); - d_data->titleRect.setWidth( rect.width() - - dimAxes[QwtPlot::yLeft] - dimAxes[QwtPlot::yRight] ); - } - - // subtract title - rect.setTop( rect.top() + dimTitle + d_data->spacing ); - } - - /*d_data->canvasRect.setRect( - rect.x() + dimAxes[QwtPlot::yLeft], - rect.y() + dimAxes[QwtPlot::xTop], - rect.width() - dimAxes[QwtPlot::yRight] - dimAxes[QwtPlot::yLeft], - rect.height() - dimAxes[QwtPlot::xBottom] - dimAxes[QwtPlot::xTop] );*/ - d_data->canvasRect.setRect( - rect.x() + dimAxes[QwtPlot::yLeft3] + dimAxes[QwtPlot::yLeft2] + dimAxes[QwtPlot::yLeft1] + dimAxes[QwtPlot::yLeft] + 1, - rect.y() + dimAxes[QwtPlot::xTop], - rect.width() - ( - dimAxes[QwtPlot::yRight] + dimAxes[QwtPlot::yRight1] - + dimAxes[QwtPlot::yRight2] + dimAxes[QwtPlot::yRight3] - ) - (dimAxes[QwtPlot::yLeft] + dimAxes[QwtPlot::yLeft1] + - dimAxes[QwtPlot::yLeft2] + dimAxes[QwtPlot::yLeft3]), - rect.height() - dimAxes[QwtPlot::xBottom] - dimAxes[QwtPlot::xTop]); - - - for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) - { - // set the rects for the axes - - if ( dimAxes[axis] ) - { - int dim = dimAxes[axis]; - QRectF &scaleRect = d_data->scaleRect[axis]; - - scaleRect = d_data->canvasRect; - switch ( axis ) - { - case QwtPlot::yLeft3: - scaleRect.setX(d_data->canvasRect.left() - dim - dimAxes[QwtPlot::yLeft] - dimAxes[QwtPlot::yLeft1] - dimAxes[QwtPlot::yLeft2]); - scaleRect.setWidth(dim); - break; - case QwtPlot::yLeft2: - scaleRect.setX(d_data->canvasRect.left() - dim - dimAxes[QwtPlot::yLeft] - dimAxes[QwtPlot::yLeft1]); - scaleRect.setWidth(dim); - break; - case QwtPlot::yLeft1: - scaleRect.setX(d_data->canvasRect.left() - dim - dimAxes[QwtPlot::yLeft]); - scaleRect.setWidth(dim); - break; - - case QwtPlot::yLeft: - scaleRect.setX( d_data->canvasRect.left() - dim ); - scaleRect.setWidth( dim ); - break; - case QwtPlot::yRight: - scaleRect.setX( d_data->canvasRect.right() ); - scaleRect.setWidth( dim ); - break; - - case QwtPlot::yRight1: - scaleRect.setX(d_data->canvasRect.right() + 1 + dimAxes[QwtPlot::yRight]); //working - scaleRect.setWidth(dim); - break; - case QwtPlot::yRight2: - scaleRect.setX(d_data->canvasRect.right() + 1 + dimAxes[QwtPlot::yRight] + dimAxes[QwtPlot::yRight1]); - scaleRect.setWidth(dim); - break; - case QwtPlot::yRight3: - scaleRect.setX(d_data->canvasRect.right() + 1 + dimAxes[QwtPlot::yRight] + dimAxes[QwtPlot::yRight1] + dimAxes[QwtPlot::yRight2]); - scaleRect.setWidth(dim); - break; - - case QwtPlot::xBottom: - scaleRect.setY( d_data->canvasRect.bottom() ); - scaleRect.setHeight( dim ); - break; - case QwtPlot::xTop: - scaleRect.setY( d_data->canvasRect.top() - dim ); - scaleRect.setHeight( dim ); - break; - } - scaleRect = scaleRect.normalized(); - } - } - - // +---+-----------+---+ - // | <- Axis -> | - // +-^-+-----------+-^-+ - // | | | | | | - // | | | | - // | A | | A | - // | x | Canvas | x | - // | i | | i | - // | s | | s | - // | | | | - // | | | | | | - // +-V-+-----------+-V-+ - // | <- Axis -> | - // +---+-----------+---+ - - // The ticks of the axes - not the labels above - should - // be aligned to the canvas. So we try to use the empty - // corners to extend the axes, so that the label texts - // left/right of the min/max ticks are moved into them. - - alignScales( options, d_data->canvasRect, d_data->scaleRect ); - - if ( !d_data->legendRect.isEmpty() ) - { - // We prefer to align the legend to the canvas - not to - // the complete plot - if possible. - - d_data->legendRect = alignLegend( d_data->canvasRect, d_data->legendRect ); - } -} diff --git a/qwt/src/qwt_plot_layout.h b/qwt/src/qwt_plot_layout.h deleted file mode 100644 index 5686513db..000000000 --- a/qwt/src/qwt_plot_layout.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** - * Qwt Widget Library - * Copyright (C) 1997 Josef Wilgen - * Copyright (C) 2002 Uwe Rathmann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the Qwt License, Version 1.0 - *****************************************************************************/ - -#ifndef QWT_PLOT_LAYOUT_H -#define QWT_PLOT_LAYOUT_H - -#include "qwt_global.h" -#include "qwt_plot.h" - -/*! - \brief Layout engine for QwtPlot. - - It is used by the QwtPlot widget to organize its internal widgets - or by QwtPlot::print() to render its content to a QPaintDevice like - a QPrinter, QPixmap/QImage or QSvgRenderer. -*/ - -class QWT_EXPORT QwtPlotLayout -{ -public: - /*! - Options to configure the plot layout engine - \sa activate(), QwtPlotRenderer - */ - enum Option - { - //! Unused - AlignScales = 0x01, - - /*! - Ignore the dimension of the scrollbars. There are no - scrollbars, when the plot is not rendered to widgets. - */ - IgnoreScrollbars = 0x02, - - //! Ignore all frames. - IgnoreFrames = 0x04, - - //! Ignore the legend. - IgnoreLegend = 0x08 - }; - - //! Layout options - typedef QFlags