Select inside polygon behaviour

Issue #23 resolved
Angus Yeh repo owner created an issue

(Reported by Thomas) Some polygons failed to select all blocks inside the polygon.

Comments (3)

  1. Angus Yeh reporter

    It is noticed that it mostly happens with polygons with concave sections.

    At the moment this is using Qt.ContainsItemShape, which "contains only items whose shape is fully contained inside the selection area". This is probably because by default Qt implement QGraphicsItem.shape() as simple bounding rectangle. This can be reimplemented to return a more accurate shape for non-rectangular items.

    See:

    http://qt-project.org/doc/qt-4.8/qt.html#ItemSelectionMode-enum

    http://qt-project.org/doc/qt-4.8/qgraphicsitem.html#shape

  2. Angus Yeh reporter

    QGraphicsScene.items() does not behave as expected when using Qt.ContainsItemShape mode, I tried re-implementing QGraphicsItem.shape(), but it didn't make a difference.

    This was solved by using Qt.IntersectsItemShape with .items() and then narrow down to final list by using QGraphicsItem.collidesWithPath() with Qt.ContainsItemShape.

    Also tried to remove text item as child of polygon... still the same.

  3. Log in to comment