Commit Graph

86 Commits

Author SHA1 Message Date
Ogi Moore b0769f4be9 Use math.radians and math.degrees
Many places in the library were doing radian to degree conversion
via the manual calculation.  Doing timeit benchmarks on my system, I
am able to get a 4x speedup by using math.degrees or math.radians
instead
2021-04-23 22:43:51 -07:00
Ogi Moore f8cefa6284 Use hypot method to avoid over/underflow errors
Use hypot instead of manual calculation
2021-04-23 11:53:00 -07:00
Ogi Moore b0a3849960 Use math module methods for singular values
Using numpy methods that are intended for vectorized operations is
substantially slower than using the math module, so when feasible the
math module methods should be used.
2021-04-23 11:53:00 -07:00
Ogi Moore 342fbb053f Avoid implicit int conversion for mouse buttons 2021-04-15 22:50:50 -07:00
Ogi Moore 314e4eb480 Unescaped sequence and fix typo 2021-04-15 21:02:29 -07:00
KIU Shueng Chuan 4699bbad6b fix keyboard modifiers default value 2021-04-11 09:00:52 +08:00
Martin Chase 0f94c17d86
Fix roi get array region (#1700)
* ROI.py, getArrayRegion: Fix return mapped coordinates

The *getArrayRegion* method is defined as returning a tuple of the points
in the selected region and the mapped coordinates if the
*returnMappedCoords* keyword argument is set to True in the parent class
*ROI*.

In the *EllipseROI* class, *getArrayRegion* was overriden, however it
ignores the *returnMappedCoords* keyword argument, leading to unintended
bugs because of the change in interface between the parent class and
the subclass.

This patch fixes the above bug.
If *returnMappedCoords* is set to False, then only *arr* containing the
array region is returned. If *returnMappedCoords* is set to True, a
tuple of the array region and the mapped coordinates is returned.

NB: At the time of this commit, the same bug is present in several classes
extending *ROI*. This commit only fixes the issue for the *EllipseROI* class.

* ROI.py, PolyLineROI.getArrayRegion: Fix return mapped coordinats

The *getArrayRegion* method is defined as returning a tuple of the
points in the selected region and the mapped coordinates if the
*returnMappedCoords* keyword argument is set to True in the parent class
*ROI*.

In the *PolyLineROI* class, *getArrayRegion* was overriden, however it
ignores the *returnMappedCoords* keyword argument, leading to unintended
bugs because of the change in interface between the parent class and the
subclass.

This patch fixes the above bug.  If *returnMappedCoords* is set to
False, then only *arr* containing the array region is returned. If
*returnMappedCoords* is set to True, a tuple of the array region and the
mapped coordinates is returned.

* remove merge conflict cruft

* lint

Co-authored-by: Malik Olivier Boussejra <malik@boussejra.com>
2021-04-08 13:43:30 -07:00
Martin af82858bc8 make these tiny methods with little excuse to exist private 2021-02-21 22:31:13 -08:00
Martin 7f4f677ce1 lambdas which reference self prevent GC 2021-02-21 06:49:07 -08:00
Martin Chase 5210c55e67
Equilateral Triangle ROI (#1581)
* feature TriangleROI

Added equilateral  TriangleROI.
getArrayRegion is not working yet

* show off (and implicitly test) our new TriangleROI

* the PolyLineROI.getArrayRegion can be used by TriangleROI

refactor the actual logic to live on ROI

* refactors for readability

* variable names
* lint
* docstring type and purpose

Co-authored-by: Fekete Imre <feketeimre87@gmail.com>
2021-02-15 06:06:55 -08:00
Ogi Moore 5bfe8d5a46
Merge pull request #1572 from outofculture/arbitrary-scale-center
Arbitrary scale center ROI
2021-02-14 08:49:03 -08:00
Ogi Moore ff71b6be6b Add actual deprecation warnings 2021-02-11 21:34:02 -08:00
Ogi Moore b54aa3914d
Attempt i18n localization (#1513)
* Trying translate on exporter strings

* Try translate on other misc context menu strings

* First f-string and I screw it up...

* add more translation calls
2021-01-27 11:34:32 -08:00
Martin 219f79947e maintain non-scaling behavior for parallel sides
make sure aspectLocked still gets checked
add example
2021-01-27 10:39:08 -08:00
Valentin Valls 9456d07ae8 Fix scale-rotate ROI handler to allow to use a random scale axis and not only x/y
The code relative to scaleSnap is maybe broken
2021-01-27 09:52:50 -08:00
KIU Shueng Chuan edea696bc3 ROI.py : pyqt6 has no KeyboardModifier class
the correct type to use is actually KeyboardModifiers
2021-01-23 08:29:51 +08:00
KIU Shueng Chuan 0fa4557ad6 don't cast buttons, enums and flags to int 2021-01-23 08:29:44 +08:00
Ogi Moore 78bc0fd3ca
Merge pull request #1495 from pijyoi/future_compat
some fixes for PySide6 future compatibility
2021-01-19 21:05:50 -08:00
KIU Shueng Chuan b6e713c306 bug: AlignCenter should have been AlignHCenter
from the Qt documentation,
- "AlignCenter = AlignVCenter | AlignHCenter"
- "You can use at most one horizontal and one vertical flag at a time.
  Qt::AlignCenter counts as both horizontal and vertical"
- "Conflicting combinations of flags have undefined meanings"

for AxisItem.py, from the code structure, it would appear that the
intent was to use AlignHCenter.

for ROI.py, AlignCenter == AlignCenter | AlignVCenter
2021-01-19 09:45:56 +08:00
KIU Shueng Chuan f863390409 change MidButton to MiddleButton
the former is no longer present in Qt 6 as an alias
2021-01-15 08:25:05 +08:00
Toussaic ae4522109e
User-defined keywords of getArrayRegion (#1416)
The three parameters "shape, vectors, origin" can't be passed as parameters because they are computed, which raise an error when kwds is passed to affineSlice.
2020-10-26 22:04:38 -07:00
Israel Brewster 3878ab6946 Properly retain and use hoverPen argument in PolyLineSegment function of PolyLineROI 2020-07-13 12:10:49 -08:00
Kenneth Lyons 3cf2845743
Improve control over ROI/handle pens (#1285)
* Exposed ability to set pens for handles and hovering for ROIs

* Consistent color format for pen creation

* Exposed ability to set pens for handles and hovering for ROIs

* Consistent color format for pen creation

* Add handleHoverPen arg to ROI and rename Handle arg to hoverPen

Co-authored-by: nmearl <nchlsearl@gmail.com>
2020-06-28 22:44:13 -07:00
Kenneth Lyons 8a3d4bab2f Update doc strings to clarify getArrayRegion API for ROI subclasses 2020-06-28 14:39:12 -07:00
Ogi 8b557af23f Implement diff from PR 317 2020-06-13 21:21:29 -07:00
Ogi 05f8921555 Implement suggested changes in PR 143 2020-06-10 20:50:04 -07:00
Kenneth Lyons 5bebf697b0
Disable remove ROI menu action in handle context menu (#1197) 2020-05-10 08:39:17 -07:00
2xB 8d2c16901b Merge master into develop (#981)
* Information is spelled with an r, even in comments
2019-08-16 20:16:01 -07:00
Ben Mathews dea8a86dfd Fixes https://github.com/pyqtgraph/pyqtgraph/issues/950 (#951)
Moving a scale handle on a ROI object does not fire a sigRegionChangeStarted signal.  This patch adds the signal emit to handleMoveStarted().
2019-06-23 17:05:11 -07:00
2xB e510971d71 RotateFree handle now rotates freely (Code by alguryanow) (#952) 2019-06-23 17:01:32 -07:00
2xB 781e129725 Fix deprecation warning of multi-dimensional tuples (#947) 2019-06-21 21:18:12 -07:00
Matt Liberty c52382c3b9 Moved emits after all method state updates since PySide2 immediately executes signals.
Pull request #907 addressed a specific case where a signal was emitted before a state update.
If an application's slot then calls back into the instance, the instance was in an inconsistent
state.  This commit audits and fixes similar issues throughout the pyqtgraph library.  This
commit fixes several latent issues:

* SignalProxy: flush -> sigDelayed -> signalReceived would have incorrectly resulted in timer.stop().
* ViewBox: resizeEvent -> sigStateChange -> background state
* ViewBox: setRange -> sigStateChange -> autoranging not updated correctly
* ViewBox: updateMatrix -> sigTransformChanged -> any _matrixNeedsUpdate = True -> ignored
* Parameter: Child may have missed state tree messages on insert or received extra on remove
* GraphicsView: updateMatrix -> sigDeviceRangeChanged/sigDeviceTransformChange -> before propagated to locked viewports.
2019-06-01 16:28:23 -04:00
Ogi Moore 1616e99b3a Fix docstring warning 2019-05-30 14:40:39 -07:00
Thomas A Caswell 4fe90bb215
MNT: escape docstrings that have rst escaping in them 2019-02-14 16:39:45 -05:00
Luke Campagnola 6a170519bf minor edits 2018-06-18 13:52:16 -07:00
Luke Campagnola 060d2479f9 minor fixes 2018-06-15 14:18:38 -07:00
Luke Campagnola e78693631b Implement handle-free scale/rotation mouse interaction for ROI 2018-06-15 13:36:33 -07:00
Luke Campagnola 2d2e548f8e delegate ROI mouse drag handling to a separate class 2018-06-15 11:21:17 -07:00
Luke Campagnola c6839b4708 fix: polylineroi segment draws to wrong handle after click 2017-10-17 21:22:55 -07:00
Luke Campagnola 79eebe1c02 code cleanup 2017-10-17 20:42:38 -07:00
Luke Campagnola 60ce541df6 minor argument type checking 2017-09-28 09:05:31 -07:00
Luke Campagnola 0de0bf4c44 Fix: very small ellipse/circle ROIs have bad click areas 2017-09-28 09:05:08 -07:00
Luke Campagnola 97b71a2b28 Add RulerROI 2017-09-28 09:03:47 -07:00
Luke Campagnola 4d0f3b5821 Code cleanup 2017-09-28 09:03:24 -07:00
Luke Campagnola 3c2c970a6b Remove spiral ROI 2017-09-28 09:00:57 -07:00
Luke Campagnola be07979b39 Add returnMappedCoords option to LineSegmentROI.getArrayRegion 2016-09-16 17:16:16 -07:00
Luke Campagnola c17f03ea46 LineSegmentROI.getArrayRegion API correction 2016-09-02 20:03:20 -07:00
Luke Campagnola 67bff6b9ca bugfix in polylineroi.getarrayregion 2016-08-27 15:51:54 -07:00
Luke Campagnola df691596a7 ROI tests pass with row-major axis order 2016-08-25 18:18:15 -07:00
Luke Campagnola a76fc37112 imageAxisOrder config option now accepts "row-major" and "col-major" instead of "normal" and "legacy"
ImageItems can individually control their axis order
image tests pass with axis order check
2016-08-23 09:10:26 -07:00