QwtPlotZoomer.3 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. .TH "QwtPlotZoomer" 3 "Mon Dec 28 2020" "Version 6.1.6" "Qwt User's Guide" \" -*- nroff -*-
  2. .ad l
  3. .nh
  4. .SH NAME
  5. QwtPlotZoomer \- \fBQwtPlotZoomer\fP provides stacked zooming for a plot widget\&.
  6. .SH SYNOPSIS
  7. .br
  8. .PP
  9. .PP
  10. \fC#include <qwt_plot_zoomer\&.h>\fP
  11. .PP
  12. Inherits \fBQwtPlotPicker\fP\&.
  13. .SS "Public Slots"
  14. .in +1c
  15. .ti -1c
  16. .RI "void \fBmoveBy\fP (double dx, double dy)"
  17. .br
  18. .ti -1c
  19. .RI "virtual void \fBmoveTo\fP (const QPointF &)"
  20. .br
  21. .ti -1c
  22. .RI "virtual void \fBzoom\fP (const QRectF &)"
  23. .br
  24. .RI "Zoom in\&. "
  25. .ti -1c
  26. .RI "virtual void \fBzoom\fP (int offset)"
  27. .br
  28. .RI "Zoom in or out\&. "
  29. .in -1c
  30. .SS "Signals"
  31. .in +1c
  32. .ti -1c
  33. .RI "void \fBzoomed\fP (const QRectF &rect)"
  34. .br
  35. .in -1c
  36. .SS "Public Member Functions"
  37. .in +1c
  38. .ti -1c
  39. .RI "\fBQwtPlotZoomer\fP (QWidget *, bool doReplot=true)"
  40. .br
  41. .RI "Create a zoomer for a plot canvas\&. "
  42. .ti -1c
  43. .RI "\fBQwtPlotZoomer\fP (int \fBxAxis\fP, int \fByAxis\fP, QWidget *, bool doReplot=true)"
  44. .br
  45. .RI "Create a zoomer for a plot canvas\&. "
  46. .ti -1c
  47. .RI "virtual void \fBsetZoomBase\fP (bool doReplot=true)"
  48. .br
  49. .ti -1c
  50. .RI "virtual void \fBsetZoomBase\fP (const QRectF &)"
  51. .br
  52. .RI "Set the initial size of the zoomer\&. "
  53. .ti -1c
  54. .RI "QRectF \fBzoomBase\fP () const"
  55. .br
  56. .ti -1c
  57. .RI "QRectF \fBzoomRect\fP () const"
  58. .br
  59. .ti -1c
  60. .RI "virtual void \fBsetAxis\fP (int \fBxAxis\fP, int \fByAxis\fP)"
  61. .br
  62. .ti -1c
  63. .RI "void \fBsetMaxStackDepth\fP (int)"
  64. .br
  65. .RI "Limit the number of recursive zoom operations to depth\&. "
  66. .ti -1c
  67. .RI "int \fBmaxStackDepth\fP () const"
  68. .br
  69. .ti -1c
  70. .RI "const QStack< QRectF > & \fBzoomStack\fP () const"
  71. .br
  72. .ti -1c
  73. .RI "void \fBsetZoomStack\fP (const QStack< QRectF > &, int \fBzoomRectIndex\fP=\-1)"
  74. .br
  75. .RI "Assign a zoom stack\&. "
  76. .ti -1c
  77. .RI "uint \fBzoomRectIndex\fP () const"
  78. .br
  79. .in -1c
  80. .SS "Protected Member Functions"
  81. .in +1c
  82. .ti -1c
  83. .RI "virtual void \fBrescale\fP ()"
  84. .br
  85. .ti -1c
  86. .RI "virtual QSizeF \fBminZoomSize\fP () const"
  87. .br
  88. .RI "Limit zooming by a minimum rectangle\&. "
  89. .ti -1c
  90. .RI "virtual void \fBwidgetMouseReleaseEvent\fP (QMouseEvent *)"
  91. .br
  92. .ti -1c
  93. .RI "virtual void \fBwidgetKeyPressEvent\fP (QKeyEvent *)"
  94. .br
  95. .ti -1c
  96. .RI "virtual void \fBbegin\fP ()"
  97. .br
  98. .ti -1c
  99. .RI "virtual bool \fBend\fP (bool ok=true)"
  100. .br
  101. .ti -1c
  102. .RI "virtual bool \fBaccept\fP (QPolygon &) const"
  103. .br
  104. .RI "Check and correct a selected rectangle\&. "
  105. .in -1c
  106. .SS "Additional Inherited Members"
  107. .SH "Detailed Description"
  108. .PP
  109. \fBQwtPlotZoomer\fP provides stacked zooming for a plot widget\&.
  110. \fBQwtPlotZoomer\fP selects rectangles from user inputs ( mouse or keyboard ) translates them into plot coordinates and adjusts the axes to them\&. The selection is supported by a rubber band and optionally by displaying the coordinates of the current mouse position\&.
  111. .PP
  112. Zooming can be repeated as often as possible, limited only by \fBmaxStackDepth()\fP or \fBminZoomSize()\fP\&. Each rectangle is pushed on a stack\&.
  113. .PP
  114. The default setting how to select rectangles is a \fBQwtPickerDragRectMachine\fP with the following bindings:
  115. .PP
  116. .IP "\(bu" 2
  117. \fBQwtEventPattern::MouseSelect1\fP
  118. .br
  119. The first point of the zoom rectangle is selected by a mouse press, the second point from the position, where the mouse is released\&.
  120. .IP "\(bu" 2
  121. \fBQwtEventPattern::KeySelect1\fP
  122. .br
  123. The first key press selects the first, the second key press selects the second point\&.
  124. .IP "\(bu" 2
  125. \fBQwtEventPattern::KeyAbort\fP
  126. .br
  127. Discard the selection in the state, where the first point is selected\&.
  128. .PP
  129. .PP
  130. To traverse the zoom stack the following bindings are used:
  131. .PP
  132. .IP "\(bu" 2
  133. \fBQwtEventPattern::MouseSelect3\fP, \fBQwtEventPattern::KeyUndo\fP
  134. .br
  135. Zoom out one position on the zoom stack
  136. .IP "\(bu" 2
  137. \fBQwtEventPattern::MouseSelect6\fP, \fBQwtEventPattern::KeyRedo\fP
  138. .br
  139. Zoom in one position on the zoom stack
  140. .IP "\(bu" 2
  141. \fBQwtEventPattern::MouseSelect2\fP, \fBQwtEventPattern::KeyHome\fP
  142. .br
  143. Zoom to the zoom base
  144. .PP
  145. .PP
  146. The \fBsetKeyPattern()\fP and \fBsetMousePattern()\fP functions can be used to configure the zoomer actions\&. The following example shows, how to configure the 'I' and 'O' keys for zooming in and out one position on the zoom stack\&. The 'Home' key is used to 'unzoom' the plot\&.
  147. .PP
  148. .PP
  149. .nf
  150. zoomer = new QwtPlotZoomer( plot );
  151. zoomer->setKeyPattern( QwtEventPattern::KeyRedo, Qt::Key_I, Qt::ShiftModifier );
  152. zoomer->setKeyPattern( QwtEventPattern::KeyUndo, Qt::Key_O, Qt::ShiftModifier );
  153. zoomer->setKeyPattern( QwtEventPattern::KeyHome, Qt::Key_Home );
  154. .fi
  155. .PP
  156. .PP
  157. \fBQwtPlotZoomer\fP is tailored for plots with one x and y axis, but it is allowed to attach a second \fBQwtPlotZoomer\fP ( without rubber band and tracker ) for the other axes\&.
  158. .PP
  159. \fBNote\fP
  160. .RS 4
  161. The realtime example includes an derived zoomer class that adds scrollbars to the plot canvas\&.
  162. .RE
  163. .PP
  164. \fBSee also\fP
  165. .RS 4
  166. \fBQwtPlotPanner\fP, \fBQwtPlotMagnifier\fP
  167. .RE
  168. .PP
  169. .SH "Constructor & Destructor Documentation"
  170. .PP
  171. .SS "QwtPlotZoomer::QwtPlotZoomer (QWidget * canvas, bool doReplot = \fCtrue\fP)\fC [explicit]\fP"
  172. .PP
  173. Create a zoomer for a plot canvas\&. The zoomer is set to those x- and y-axis of the parent plot of the canvas that are enabled\&. If both or no x-axis are enabled, the picker is set to \fBQwtPlot::xBottom\fP\&. If both or no y-axis are enabled, it is set to \fBQwtPlot::yLeft\fP\&.
  174. .PP
  175. The zoomer is initialized with a \fBQwtPickerDragRectMachine\fP, the tracker mode is set to \fBQwtPicker::ActiveOnly\fP and the rubber band is set to \fBQwtPicker::RectRubberBand\fP
  176. .PP
  177. \fBParameters\fP
  178. .RS 4
  179. \fIcanvas\fP Plot canvas to observe, also the parent object
  180. .br
  181. \fIdoReplot\fP Call \fBQwtPlot::replot()\fP for the attached plot before initializing the zoomer with its scales\&. This might be necessary, when the plot is in a state with pending scale changes\&.
  182. .RE
  183. .PP
  184. \fBSee also\fP
  185. .RS 4
  186. \fBQwtPlot::autoReplot()\fP, \fBQwtPlot::replot()\fP, \fBsetZoomBase()\fP
  187. .RE
  188. .PP
  189. .SS "QwtPlotZoomer::QwtPlotZoomer (int xAxis, int yAxis, QWidget * canvas, bool doReplot = \fCtrue\fP)\fC [explicit]\fP"
  190. .PP
  191. Create a zoomer for a plot canvas\&. The zoomer is initialized with a \fBQwtPickerDragRectMachine\fP, the tracker mode is set to \fBQwtPicker::ActiveOnly\fP and the rubber band is set to \fBQwtPicker\fP;;RectRubberBand
  192. .PP
  193. \fBParameters\fP
  194. .RS 4
  195. \fIxAxis\fP X axis of the zoomer
  196. .br
  197. \fIyAxis\fP Y axis of the zoomer
  198. .br
  199. \fIcanvas\fP Plot canvas to observe, also the parent object
  200. .br
  201. \fIdoReplot\fP Call \fBQwtPlot::replot()\fP for the attached plot before initializing the zoomer with its scales\&. This might be necessary, when the plot is in a state with pending scale changes\&.
  202. .RE
  203. .PP
  204. \fBSee also\fP
  205. .RS 4
  206. \fBQwtPlot::autoReplot()\fP, \fBQwtPlot::replot()\fP, \fBsetZoomBase()\fP
  207. .RE
  208. .PP
  209. .SH "Member Function Documentation"
  210. .PP
  211. .SS "bool QwtPlotZoomer::accept (QPolygon & pa) const\fC [protected]\fP, \fC [virtual]\fP"
  212. .PP
  213. Check and correct a selected rectangle\&. Reject rectangles with a height or width < 2, otherwise expand the selected rectangle to a minimum size of 11x11 and accept it\&.
  214. .PP
  215. \fBReturns\fP
  216. .RS 4
  217. true If the rectangle is accepted, or has been changed to an accepted one\&.
  218. .RE
  219. .PP
  220. .PP
  221. Reimplemented from \fBQwtPicker\fP\&.
  222. .SS "void QwtPlotZoomer::begin ()\fC [protected]\fP, \fC [virtual]\fP"
  223. Rejects selections, when the stack depth is too deep, or the zoomed rectangle is \fBminZoomSize()\fP\&.
  224. .PP
  225. \fBSee also\fP
  226. .RS 4
  227. \fBminZoomSize()\fP, \fBmaxStackDepth()\fP
  228. .RE
  229. .PP
  230. .PP
  231. Reimplemented from \fBQwtPicker\fP\&.
  232. .SS "bool QwtPlotZoomer::end (bool ok = \fCtrue\fP)\fC [protected]\fP, \fC [virtual]\fP"
  233. Expand the selected rectangle to \fBminZoomSize()\fP and zoom in if accepted\&.
  234. .PP
  235. \fBParameters\fP
  236. .RS 4
  237. \fIok\fP If true, complete the selection and emit selected signals otherwise discard the selection\&.
  238. .RE
  239. .PP
  240. \fBSee also\fP
  241. .RS 4
  242. \fBaccept()\fP, \fBminZoomSize()\fP
  243. .RE
  244. .PP
  245. \fBReturns\fP
  246. .RS 4
  247. True if the selection has been accepted, false otherwise
  248. .RE
  249. .PP
  250. .PP
  251. Reimplemented from \fBQwtPlotPicker\fP\&.
  252. .SS "int QwtPlotZoomer::maxStackDepth () const"
  253. .PP
  254. \fBReturns\fP
  255. .RS 4
  256. Maximal depth of the zoom stack\&.
  257. .RE
  258. .PP
  259. \fBSee also\fP
  260. .RS 4
  261. \fBsetMaxStackDepth()\fP
  262. .RE
  263. .PP
  264. .SS "QSizeF QwtPlotZoomer::minZoomSize () const\fC [protected]\fP, \fC [virtual]\fP"
  265. .PP
  266. Limit zooming by a minimum rectangle\&.
  267. .PP
  268. \fBReturns\fP
  269. .RS 4
  270. \fBzoomBase()\fP\&.width() / 10e4, \fBzoomBase()\fP\&.height() / 10e4
  271. .RE
  272. .PP
  273. .SS "void QwtPlotZoomer::moveBy (double dx, double dy)\fC [slot]\fP"
  274. Move the current zoom rectangle\&.
  275. .PP
  276. \fBParameters\fP
  277. .RS 4
  278. \fIdx\fP X offset
  279. .br
  280. \fIdy\fP Y offset
  281. .RE
  282. .PP
  283. \fBNote\fP
  284. .RS 4
  285. The changed rectangle is limited by the zoom base
  286. .RE
  287. .PP
  288. .SS "void QwtPlotZoomer::moveTo (const QPointF & pos)\fC [virtual]\fP, \fC [slot]\fP"
  289. Move the the current zoom rectangle\&.
  290. .PP
  291. \fBParameters\fP
  292. .RS 4
  293. \fIpos\fP New position
  294. .RE
  295. .PP
  296. \fBSee also\fP
  297. .RS 4
  298. QRectF::moveTo()
  299. .RE
  300. .PP
  301. \fBNote\fP
  302. .RS 4
  303. The changed rectangle is limited by the zoom base
  304. .RE
  305. .PP
  306. .SS "void QwtPlotZoomer::rescale ()\fC [protected]\fP, \fC [virtual]\fP"
  307. Adjust the observed plot to \fBzoomRect()\fP
  308. .PP
  309. \fBNote\fP
  310. .RS 4
  311. Initiates \fBQwtPlot::replot()\fP
  312. .RE
  313. .PP
  314. .SS "void QwtPlotZoomer::setAxis (int xAxis, int yAxis)\fC [virtual]\fP"
  315. Reinitialize the axes, and set the zoom base to their scales\&.
  316. .PP
  317. \fBParameters\fP
  318. .RS 4
  319. \fIxAxis\fP X axis
  320. .br
  321. \fIyAxis\fP Y axis
  322. .RE
  323. .PP
  324. .PP
  325. Reimplemented from \fBQwtPlotPicker\fP\&.
  326. .SS "void QwtPlotZoomer::setMaxStackDepth (int depth)"
  327. .PP
  328. Limit the number of recursive zoom operations to depth\&. A value of -1 set the depth to unlimited, 0 disables zooming\&. If the current zoom rectangle is below depth, the plot is unzoomed\&.
  329. .PP
  330. \fBParameters\fP
  331. .RS 4
  332. \fIdepth\fP Maximum for the stack depth
  333. .RE
  334. .PP
  335. \fBSee also\fP
  336. .RS 4
  337. \fBmaxStackDepth()\fP
  338. .RE
  339. .PP
  340. \fBNote\fP
  341. .RS 4
  342. depth doesn't include the zoom base, so \fBzoomStack()\fP\&.count() might be \fBmaxStackDepth()\fP + 1\&.
  343. .RE
  344. .PP
  345. .SS "void QwtPlotZoomer::setZoomBase (bool doReplot = \fCtrue\fP)\fC [virtual]\fP"
  346. Reinitialized the zoom stack with \fBscaleRect()\fP as base\&.
  347. .PP
  348. \fBParameters\fP
  349. .RS 4
  350. \fIdoReplot\fP Call \fBQwtPlot::replot()\fP for the attached plot before initializing the zoomer with its scales\&. This might be necessary, when the plot is in a state with pending scale changes\&.
  351. .RE
  352. .PP
  353. \fBSee also\fP
  354. .RS 4
  355. \fBzoomBase()\fP, \fBscaleRect()\fP \fBQwtPlot::autoReplot()\fP, \fBQwtPlot::replot()\fP\&.
  356. .RE
  357. .PP
  358. .SS "void QwtPlotZoomer::setZoomBase (const QRectF & base)\fC [virtual]\fP"
  359. .PP
  360. Set the initial size of the zoomer\&. base is united with the current \fBscaleRect()\fP and the zoom stack is reinitialized with it as zoom base\&. plot is zoomed to \fBscaleRect()\fP\&.
  361. .PP
  362. \fBParameters\fP
  363. .RS 4
  364. \fIbase\fP Zoom base
  365. .RE
  366. .PP
  367. \fBSee also\fP
  368. .RS 4
  369. \fBzoomBase()\fP, \fBscaleRect()\fP
  370. .RE
  371. .PP
  372. .SS "void QwtPlotZoomer::setZoomStack (const QStack< QRectF > & zoomStack, int zoomRectIndex = \fC\-1\fP)"
  373. .PP
  374. Assign a zoom stack\&. In combination with other types of navigation it might be useful to modify to manipulate the complete zoom stack\&.
  375. .PP
  376. \fBParameters\fP
  377. .RS 4
  378. \fIzoomStack\fP New zoom stack
  379. .br
  380. \fIzoomRectIndex\fP Index of the current position of zoom stack\&. In case of -1 the current position is at the top of the stack\&.
  381. .RE
  382. .PP
  383. \fBNote\fP
  384. .RS 4
  385. The zoomed signal might be emitted\&.
  386. .RE
  387. .PP
  388. \fBSee also\fP
  389. .RS 4
  390. \fBzoomStack()\fP, \fBzoomRectIndex()\fP
  391. .RE
  392. .PP
  393. .SS "void QwtPlotZoomer::widgetKeyPressEvent (QKeyEvent * ke)\fC [protected]\fP, \fC [virtual]\fP"
  394. Qt::Key_Plus zooms in, Qt::Key_Minus zooms out one position on the zoom stack, Qt::Key_Escape zooms out to the zoom base\&.
  395. .PP
  396. Changes the current position on the stack, but doesn't pop any rectangle\&.
  397. .PP
  398. \fBNote\fP
  399. .RS 4
  400. The keys codes can be changed, using \fBQwtEventPattern::setKeyPattern\fP: 3, 4, 5
  401. .RE
  402. .PP
  403. .PP
  404. Reimplemented from \fBQwtPicker\fP\&.
  405. .SS "void QwtPlotZoomer::widgetMouseReleaseEvent (QMouseEvent * me)\fC [protected]\fP, \fC [virtual]\fP"
  406. Qt::MidButton zooms out one position on the zoom stack, Qt::RightButton to the zoom base\&.
  407. .PP
  408. Changes the current position on the stack, but doesn't pop any rectangle\&.
  409. .PP
  410. \fBNote\fP
  411. .RS 4
  412. The mouse events can be changed, using \fBQwtEventPattern::setMousePattern\fP: 2, 1
  413. .RE
  414. .PP
  415. .PP
  416. Reimplemented from \fBQwtPicker\fP\&.
  417. .SS "void QwtPlotZoomer::zoom (const QRectF & rect)\fC [virtual]\fP, \fC [slot]\fP"
  418. .PP
  419. Zoom in\&. Clears all rectangles above the current position of the zoom stack and pushes the normalized rectangle on it\&.
  420. .PP
  421. \fBNote\fP
  422. .RS 4
  423. If the maximal stack depth is reached, zoom is ignored\&.
  424. .PP
  425. The zoomed signal is emitted\&.
  426. .RE
  427. .PP
  428. .SS "void QwtPlotZoomer::zoom (int offset)\fC [virtual]\fP, \fC [slot]\fP"
  429. .PP
  430. Zoom in or out\&. Activate a rectangle on the zoom stack with an offset relative to the current position\&. Negative values of offset will zoom out, positive zoom in\&. A value of 0 zooms out to the zoom base\&.
  431. .PP
  432. \fBParameters\fP
  433. .RS 4
  434. \fIoffset\fP Offset relative to the current position of the zoom stack\&.
  435. .RE
  436. .PP
  437. \fBNote\fP
  438. .RS 4
  439. The zoomed signal is emitted\&.
  440. .RE
  441. .PP
  442. \fBSee also\fP
  443. .RS 4
  444. \fBzoomRectIndex()\fP
  445. .RE
  446. .PP
  447. .SS "QRectF QwtPlotZoomer::zoomBase () const"
  448. .PP
  449. \fBReturns\fP
  450. .RS 4
  451. Initial rectangle of the zoomer
  452. .RE
  453. .PP
  454. \fBSee also\fP
  455. .RS 4
  456. \fBsetZoomBase()\fP, \fBzoomRect()\fP
  457. .RE
  458. .PP
  459. .SS "void QwtPlotZoomer::zoomed (const QRectF & rect)\fC [signal]\fP"
  460. A signal emitting the \fBzoomRect()\fP, when the plot has been zoomed in or out\&.
  461. .PP
  462. \fBParameters\fP
  463. .RS 4
  464. \fIrect\fP Current zoom rectangle\&.
  465. .RE
  466. .PP
  467. .SS "QRectF QwtPlotZoomer::zoomRect () const"
  468. .PP
  469. \fBReturns\fP
  470. .RS 4
  471. Rectangle at the current position on the zoom stack\&.
  472. .RE
  473. .PP
  474. \fBSee also\fP
  475. .RS 4
  476. \fBzoomRectIndex()\fP, \fBscaleRect()\fP\&.
  477. .RE
  478. .PP
  479. .SS "uint QwtPlotZoomer::zoomRectIndex () const"
  480. .PP
  481. \fBReturns\fP
  482. .RS 4
  483. Index of current position of zoom stack\&.
  484. .RE
  485. .PP
  486. .SS "const QStack< QRectF > & QwtPlotZoomer::zoomStack () const"
  487. .PP
  488. \fBReturns\fP
  489. .RS 4
  490. The zoom stack\&. \fBzoomStack()\fP[0] is the zoom base, \fBzoomStack()\fP[1] the first zoomed rectangle\&.
  491. .RE
  492. .PP
  493. \fBSee also\fP
  494. .RS 4
  495. \fBsetZoomStack()\fP, \fBzoomRectIndex()\fP
  496. .RE
  497. .PP
  498. .SH "Author"
  499. .PP
  500. Generated automatically by Doxygen for Qwt User's Guide from the source code\&.