Geen omschrijving

index.tex 15KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. Below is a brief overview of and guide to the classes and their relations. If you are new to \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} and just want to start using it, it\textquotesingle{}s recommended to look at the tutorials and examples at
  2. \href{http://www.qcustomplot.com/}{\tt http\+://www.\+qcustomplot.\+com/}
  3. This documentation is especially helpful as a reference, when you\textquotesingle{}re familiar with the basic concept of how to use Q\+Custom\+Plot and you wish to learn more about specific functionality. See the \hyperlink{classoverview}{class overview} for diagrams explaining the relationships between the most important classes of the \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} library.
  4. The central widget which displays the plottables and axes on its surface is \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot}. Every \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} contains four axes by default. They can be accessed via the members x\+Axis, y\+Axis, x\+Axis2 and y\+Axis2, and are of type \hyperlink{class_q_c_p_axis}{Q\+C\+P\+Axis}. \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} supports an arbitrary number of axes and axis rects, see the documentation of \hyperlink{class_q_c_p_axis_rect}{Q\+C\+P\+Axis\+Rect} for details.\hypertarget{index_mainpage-plottables}{}\section{Plottables}\label{index_mainpage-plottables}
  5. {\itshape Plottables} are classes that display any kind of data inside the \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot}. They all derive from \hyperlink{class_q_c_p_abstract_plottable}{Q\+C\+P\+Abstract\+Plottable}. For example, the \hyperlink{class_q_c_p_graph}{Q\+C\+P\+Graph} class is a plottable that displays a graph inside the plot with different line styles, scatter styles, filling etc.
  6. Since plotting graphs is such a dominant use case, \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} has a special interface for working with \hyperlink{class_q_c_p_graph}{Q\+C\+P\+Graph} plottables, that makes it very easy to handle them\+:~\newline
  7. You create a new graph with \hyperlink{class_q_custom_plot_a6fb2873d35a8a8089842d81a70a54167}{Q\+Custom\+Plot\+::add\+Graph} and access them with \hyperlink{class_q_custom_plot_a6d3ed93c2bf46ab7fa670d66be4cddaf}{Q\+Custom\+Plot\+::graph}.
  8. For all other plottables, you need to use the normal plottable interface\+:~\newline
  9. First, you create an instance of the plottable you want, e.\+g.
  10. \begin{DoxyCode}
  11. \hyperlink{class_q_c_p_curve}{QCPCurve} *newCurve = \textcolor{keyword}{new} \hyperlink{class_q_c_p_curve}{QCPCurve}(customPlot->xAxis, customPlot->yAxis);
  12. \end{DoxyCode}
  13. add it to the custom\+Plot\+:
  14. \begin{DoxyCode}
  15. customPlot->addPlottable(newCurve);
  16. \end{DoxyCode}
  17. and then modify the properties of the newly created plottable via the {\ttfamily new\+Curve} pointer.
  18. Plottables (including graphs) can be retrieved via \hyperlink{class_q_custom_plot_a32de81ff53e263e785b83b52ecd99d6f}{Q\+Custom\+Plot\+::plottable}. Since the return type of that function is the abstract base class of all plottables, \hyperlink{class_q_c_p_abstract_plottable}{Q\+C\+P\+Abstract\+Plottable}, you will probably want to qobject\+\_\+cast the returned pointer to the respective plottable subclass. (As usual, if the cast returns zero, the plottable wasn\textquotesingle{}t of that specific subclass.)
  19. All further interfacing with plottables (e.\+g how to set data) is specific to the plottable type. See the documentations of the subclasses\+: \hyperlink{class_q_c_p_graph}{Q\+C\+P\+Graph}, \hyperlink{class_q_c_p_curve}{Q\+C\+P\+Curve}, \hyperlink{class_q_c_p_bars}{Q\+C\+P\+Bars}, \hyperlink{class_q_c_p_statistical_box}{Q\+C\+P\+Statistical\+Box}.\hypertarget{index_mainpage-axes}{}\section{Controlling the Axes}\label{index_mainpage-axes}
  20. As mentioned, \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} has four axes by default\+: {\itshape x\+Axis} (bottom), {\itshape y\+Axis} (left), {\itshape x\+Axis2} (top), {\itshape y\+Axis2} (right).
  21. Their range is handled by the simple \hyperlink{class_q_c_p_range}{Q\+C\+P\+Range} class. You can set the range with the \hyperlink{class_q_c_p_axis_aebdfea5d44c3a0ad2b4700cd4d25b641}{Q\+C\+P\+Axis\+::set\+Range} function. By default, the axes represent a linear scale. To set a logarithmic scale, set \hyperlink{class_q_c_p_axis_adb6c5c45bdf899ea221881dd3b43b406}{Q\+C\+P\+Axis\+::set\+Scale\+Type} to \hyperlink{class_q_c_p_axis_a36d8e8658dbaa179bf2aeb973db2d6f0abf5b785ad976618816dc6f79b73216d4}{Q\+C\+P\+Axis\+::st\+Logarithmic}. The logarithm base can be set freely with \hyperlink{class_q_c_p_axis_a726186054be90487885a748aa1b42188}{Q\+C\+P\+Axis\+::set\+Scale\+Log\+Base}.
  22. By default, an axis automatically creates and labels ticks in a sensible manner. See the following functions for tick manipulation\+:~\newline
  23. \hyperlink{class_q_c_p_axis_ac891409315bc379e3b1abdb162c1a011}{Q\+C\+P\+Axis\+::set\+Ticks}, \hyperlink{class_q_c_p_axis_ae867c23d3a6a7bd4d09cc66c5d018f63}{Q\+C\+P\+Axis\+::set\+Auto\+Ticks}, \hyperlink{class_q_c_p_axis_a7c7111cbeac9ec5fcb40f93a1ef51a0b}{Q\+C\+P\+Axis\+::set\+Auto\+Tick\+Count}, \hyperlink{class_q_c_p_axis_a99fe77b034e06f5b723995beab96e741}{Q\+C\+P\+Axis\+::set\+Auto\+Tick\+Step}, \hyperlink{class_q_c_p_axis_a04ba16e1f6f78d70f938519576ed32c8}{Q\+C\+P\+Axis\+::set\+Tick\+Labels}, \hyperlink{class_q_c_p_axis_a54f24f5ce8feea25209388a863d7e448}{Q\+C\+P\+Axis\+::set\+Tick\+Label\+Type}, \hyperlink{class_q_c_p_axis_a1bddd4413df8a576b7ad4b067fb33375}{Q\+C\+P\+Axis\+::set\+Tick\+Label\+Rotation}, \hyperlink{class_q_c_p_axis_af727db0acc6492c4c774c0700e738205}{Q\+C\+P\+Axis\+::set\+Tick\+Step}, \hyperlink{class_q_c_p_axis_a62ec40bebe3540e9c1479a8fd2be3b0d}{Q\+C\+P\+Axis\+::set\+Tick\+Length},...
  24. Each axis can be given an axis label (e.\+g. \char`\"{}\+Voltage (m\+V)\char`\"{}) with \hyperlink{class_q_c_p_axis_a33bcc382c111c9f31bb0687352a2dea4}{Q\+C\+P\+Axis\+::set\+Label}.
  25. The distance of an axis backbone to the respective viewport border is called its margin. Normally, the margins are calculated automatically. To change this, set \hyperlink{class_q_c_p_layout_element_accfda49994e3e6d51ed14504abf9d27d}{Q\+C\+P\+Axis\+Rect\+::set\+Auto\+Margins} to exclude the respective margin sides, set the margins manually with \hyperlink{class_q_c_p_layout_element_a8f450b1f3f992ad576fce2c63d8b79cf}{Q\+C\+P\+Axis\+Rect\+::set\+Margins}. The main axis rect can be reached with \hyperlink{class_q_custom_plot_a4a37a1add5fe63060ac518cf0a4c4050}{Q\+Custom\+Plot\+::axis\+Rect()}.\hypertarget{index_mainpage-legend}{}\section{Plot Legend}\label{index_mainpage-legend}
  26. Every \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} owns one \hyperlink{class_q_c_p_legend}{Q\+C\+P\+Legend} (as {\itshape legend}) by default. A legend is a small layout element inside the plot which lists the plottables with an icon of the plottable line/symbol and a description. The Description is retrieved from the plottable name (\hyperlink{class_q_c_p_abstract_plottable_ab79c7ba76bc7fa89a4b3580e12149f1f}{Q\+C\+P\+Abstract\+Plottable\+::set\+Name}). Plottables can be added and removed from the legend via \hyperlink{class_q_c_p_abstract_plottable_a70f8cabfd808f7d5204b9f18c45c13f5}{Q\+C\+P\+Abstract\+Plottable\+::add\+To\+Legend} and \hyperlink{class_q_c_p_abstract_plottable_aa1f350e510326d012b9a9c9249736c83}{Q\+C\+P\+Abstract\+Plottable\+::remove\+From\+Legend}. By default, adding a plottable to \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} automatically adds it to the legend, too. This behaviour can be modified with the \hyperlink{class_q_custom_plot_ad8858410c2db47b7104040a3aa61c3fc}{Q\+Custom\+Plot\+::set\+Auto\+Add\+Plottable\+To\+Legend} property.
  27. The \hyperlink{class_q_c_p_legend}{Q\+C\+P\+Legend} provides an interface to access, add and remove legend items directly, too. See \hyperlink{class_q_c_p_legend_a454272d7094437beb3278a2294006da5}{Q\+C\+P\+Legend\+::item}, \hyperlink{class_q_c_p_legend_a5ee80cf83f65e3b6dd386942ee3cc1ee}{Q\+C\+P\+Legend\+::item\+With\+Plottable}, \hyperlink{class_q_c_p_legend_a3ab274de52d2951faea45a6d975e6b3f}{Q\+C\+P\+Legend\+::add\+Item}, \hyperlink{class_q_c_p_legend_ac91595c3eaa746fe6321d2eb952c63bb}{Q\+C\+P\+Legend\+::remove\+Item} for example.
  28. Multiple legends are supported via the layout system (as a \hyperlink{class_q_c_p_legend}{Q\+C\+P\+Legend} simply is a normal layout element).\hypertarget{index_mainpage-userinteraction}{}\section{User Interactions}\label{index_mainpage-userinteraction}
  29. \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} supports dragging axis ranges with the mouse (\hyperlink{class_q_c_p_axis_rect_ae6aef2f7211ba6097c925dcd26008418}{Q\+C\+P\+Axis\+Rect\+::set\+Range\+Drag}), zooming axis ranges with the mouse wheel (\hyperlink{class_q_c_p_axis_rect_a7960a9d222f1c31d558b064b60f86a31}{Q\+C\+P\+Axis\+Rect\+::set\+Range\+Zoom}) and a complete selection mechanism.
  30. The availability of these interactions is controlled with \hyperlink{class_q_custom_plot_a5ee1e2f6ae27419deca53e75907c27e5}{Q\+Custom\+Plot\+::set\+Interactions}. For details about the interaction system, see the documentation there.
  31. Further, \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} always emits corresponding signals, when objects are clicked or double\+Clicked. See \hyperlink{class_q_custom_plot_a57e5efa8a854620e9bf62d31fc139f53}{Q\+Custom\+Plot\+::plottable\+Click}, \hyperlink{class_q_custom_plot_af2e6f1cea923dae437681d01ce7d0c31}{Q\+Custom\+Plot\+::plottable\+Double\+Click} and \hyperlink{class_q_custom_plot_abf635f8b56ab5c16d5de9f358543e82b}{Q\+Custom\+Plot\+::axis\+Click} for example.\hypertarget{index_mainpage-items}{}\section{Items}\label{index_mainpage-items}
  32. Apart from plottables there is another category of plot objects that are important\+: Items. The base class of all items is \hyperlink{class_q_c_p_abstract_item}{Q\+C\+P\+Abstract\+Item}. An item sets itself apart from plottables in that it\textquotesingle{}s not necessarily bound to any axes. This means it may also be positioned in absolute pixel coordinates or placed at a relative position on an axis rect. Further, it usually doesn\textquotesingle{}t represent data directly, but acts as decoration, emphasis, description etc.
  33. Multiple items can be arranged in a parent-\/child-\/hierarchy allowing for dynamical behaviour. For example, you could place the head of an arrow at a fixed plot coordinate, so it always points to some important area in the plot. The tail of the arrow can be anchored to a text item which always resides in the top center of the axis rect, independent of where the user drags the axis ranges. This way the arrow stretches and turns so it always points from the label to the specified plot coordinate, without any further code necessary.
  34. For a more detailed introduction, see the \hyperlink{class_q_c_p_abstract_item}{Q\+C\+P\+Abstract\+Item} documentation, and from there the documentations of the individual built-\/in items, to find out how to use them.\hypertarget{index_mainpage-layoutelements}{}\section{Layout elements and layouts}\label{index_mainpage-layoutelements}
  35. \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} uses an internal layout system to provide dynamic sizing and positioning of objects like the axis rect(s), legends and the plot title. They are all based on \hyperlink{class_q_c_p_layout_element}{Q\+C\+P\+Layout\+Element} and are arranged by placing them inside a \hyperlink{class_q_c_p_layout}{Q\+C\+P\+Layout}.
  36. Details on this topic are given on the dedicated page about \hyperlink{thelayoutsystem}{the layout system}.\hypertarget{index_mainpage-performancetweaks}{}\section{Performance Tweaks}\label{index_mainpage-performancetweaks}
  37. Although \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} is quite fast, some features like translucent fills, antialiasing and thick lines can cause a significant slow down. If you notice this in your application, here are some thoughts on how to increase performance. By far the most time is spent in the drawing functions, specifically the drawing of graphs. For maximum performance, consider the following (most recommended/effective measures first)\+:
  38. \begin{DoxyItemize}
  39. \item use Qt 4.\+8.\+0 and up. Performance has doubled or tripled with respect to Qt 4.\+7.\+4. However Q\+Painter was broken and drawing pixel precise things, e.\+g. scatters, isn\textquotesingle{}t possible with Qt $>$= 4.\+8.\+0. So it\textquotesingle{}s a performance vs. plot quality tradeoff when switching to Qt 4.\+8. \item To increase responsiveness during dragging, consider setting \hyperlink{class_q_custom_plot_a775bdcb6329d44701aeaa6135b0e5265}{Q\+Custom\+Plot\+::set\+No\+Antialiasing\+On\+Drag} to true. \item On X11 (G\+N\+U/\+Linux), avoid the slow native drawing system, use raster by supplying \char`\"{}-\/graphicssystem raster\char`\"{} as command line argument or calling Q\+Application\+::set\+Graphics\+System(\char`\"{}raster\char`\"{}) before creating the Q\+Application object. (Only available for Qt versions before 5.\+0) \item On all operating systems, use Open\+G\+L hardware acceleration by supplying \char`\"{}-\/graphicssystem
  40. opengl\char`\"{} as command line argument or calling Q\+Application\+::set\+Graphics\+System(\char`\"{}opengl\char`\"{}) (Only available for Qt versions before 5.\+0). If Open\+G\+L is available, this will slightly decrease the quality of antialiasing, but extremely increase performance especially with alpha (semi-\/transparent) fills, much antialiasing and a large \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} drawing surface. Note however, that the maximum frame rate might be constrained by the vertical sync frequency of your monitor (V\+Sync can be disabled in the graphics card driver configuration). So for simple plots (where the potential framerate is far above 60 frames per second), Open\+G\+L acceleration might achieve numerically lower frame rates than the other graphics systems, because they are not capped at the V\+Sync frequency. \item Avoid any kind of alpha (transparency), especially in fills \item Avoid lines with a pen width greater than one \item Avoid any kind of antialiasing, especially in graph lines (see \hyperlink{class_q_custom_plot_ae10d685b5eabea2999fb8775ca173c24}{Q\+Custom\+Plot\+::set\+Not\+Antialiased\+Elements}) \item Avoid repeatedly setting the complete data set with \hyperlink{class_q_c_p_graph_a1df2fd710545c8ba3b2c99a39a27bf8b}{Q\+C\+P\+Graph\+::set\+Data}. Use \hyperlink{class_q_c_p_graph_aa5c6181d84db72ce4dbe9dc15a34ef4f}{Q\+C\+P\+Graph\+::add\+Data} instead, if most data points stay unchanged, e.\+g. in a running measurement. \item Set the {\itshape copy} parameter of the set\+Data functions to false, so only pointers get transferred. (Relevant only if preparing data maps with a large number of points, i.\+e. over 10000)\end{DoxyItemize}
  41. \hypertarget{index_mainpage-flags}{}\section{Preprocessor Define Flags}\label{index_mainpage-flags}
  42. \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} understands some preprocessor defines that are useful for debugging and compilation\+:
  43. \begin{DoxyDescription}
  44. \item[{\ttfamily Q\+C\+U\+S\+T\+O\+M\+P\+L\+O\+T\+\_\+\+C\+O\+M\+P\+I\+L\+E\+\_\+\+L\+I\+B\+R\+A\+R\+Y} ]Define this flag when you compile \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} as a shared library (.so/.dll)
  45. \item[{\ttfamily Q\+C\+U\+S\+T\+O\+M\+P\+L\+O\+T\+\_\+\+U\+S\+E\+\_\+\+L\+I\+B\+R\+A\+R\+Y} ]Define this flag before including the header, when using \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} as a shared library
  46. \item[{\ttfamily Q\+C\+U\+S\+T\+O\+M\+P\+L\+O\+T\+\_\+\+C\+H\+E\+C\+K\+\_\+\+D\+A\+T\+A} ]If this flag is defined, the \hyperlink{class_q_custom_plot}{Q\+Custom\+Plot} plottables will perform data validity checks on every redraw. This means they will give q\+Debug output when you plot {\itshape inf} or {\itshape nan} values, they will not fix your data.
  47. \end{DoxyDescription}