Python SetSelected() doesn't display until view switched

Bug #1709149 reported by Greg Smith on 2017-08-07
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
KiCad
Wishlist
Tomasz Wlostowski

Bug Description

Windows nightly as of July 31, 2017

Executing the following in Scripting Console:

import pcbnew

for m in pcbnew.GetBoard().GetModules():
 m.GetValue().SetSelected()
 m.GetReference().SetSelected()
 for d in m.GraphicalItems():
  d.SetSelected()

for d in pcbnew.GetBoard().GetDrawings():
 d.SetSelected()

The selected items do not appear in OpenGL view until the view is switch to default and back.

Also, adding DRAWSEGMENTS on the board don't show up until the view is switched.

This also happen in Linux and possibly MacOS and, to a limited extent, in 4.0.6 Stable.

Application: kicad
Version: (2017-07-31 revision 67ae5935d)-makepkg, release build
Libraries: wxWidgets 3.0.2
           libcurl/7.54.0 OpenSSL/1.0.2k zlib/1.2.11 libssh2/1.8.0 nghttp2/1.19.0 librtmp/2.3
Platform: Windows 7 (build 7601, Service Pack 1), 64-bit edition, 64 bit, Little endian, wxMSW
- Build Info -
wxWidgets: 3.0.2 (wchar_t,wx containers,compatible with 2.8)
Boost: 1.63.0
Curl: 7.54.0
KiCad - Compiler: GCC 6.3.0 with C++ ABI 1010
        Settings: USE_WX_GRAPHICS_CONTEXT=OFF
                  USE_WX_OVERLAY=OFF
                  KICAD_SCRIPTING=ON
                  KICAD_SCRIPTING_MODULES=ON
                  KICAD_SCRIPTING_WXPYTHON=ON
                  KICAD_SCRIPTING_ACTION_MENU=ON
                  BUILD_GITHUB_PLUGIN=ON
                  KICAD_USE_OCE=ON

Tomasz Wlostowski (twlostow) wrote :

Hi Greg,

For the moment, selection in GAL is not exposed to Python.

You can try using SELECTION_TOOL::select( BOARD_ITEM* aItem ), but there's no guarantee it will work.

Best,
Tom

Changed in kicad:
importance: Undecided → Wishlist
Greg Smith (gmsmith) wrote :

Tom, OpenGL does seem to recognize. When I switch to default view, then back to OpenGL, the selected items display as selected (brighter than non selected items).

I will also try your suggestion, if I can figure out how to under python.

Tomasz Wlostowski (twlostow) wrote :

SetSelected() is not sufficient. It looks like we'll need to expose some of the GAL selection APIs to Python.

How about:

pcbnew.[Un]Select (items) -> adds/removes items from the current selection.
pcbnew.SetSelection(items) -> clears the current selection and sets it to (items).
pcbnew.GetSelection -> returns a vector of currently selected items.
pcbnew.ClearSelection (obvious)

Changed in kicad:
assignee: nobody → Tomasz Wlostowski (twlostow)
status: New → Confirmed
captain_morgan (morganrallen) wrote :

FWIW this still doesn't appear to work on KiCAD 5 stable

Application: pcbnew
Version: 5.0.2+dfsg1-1, release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.64.0 OpenSSL/1.1.1b zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh/0.8.6/openssl/zlib nghttp2/1.36.0 librtmp/2.3
Platform: Linux 5.0.0-15-generic x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 2.24
    Boost: 1.67.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.61.0
    Compiler: GCC 8.2.0 with C++ ABI 1013

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=OFF
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_WXPYTHON=OFF
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON

Wayne Stambaugh (stambaughw) wrote :

The 5 branch is no longer supported. Please upgrade to 5.1.2 which is the latest stable release. I suspect that this may have already been fixed.

Changed in kicad:
status: Confirmed → Incomplete
captain_morgan (morganrallen) wrote :

OK, got all my versions straight again (ubuntu distro update disabled PPAs...) and this is still an issue.

The plugin I'm working simply saves current selection using IsSelected and restores it again with SetSelection. Interestingly I've also noticed calling IsSelected visually removes the selection while calling it again still returns True. But if I immediately press m expecting those modules to move, they don't. So some kind of selected limbo state.

The scripts I'm working on can be found here https://gitlab.com/morganrallen/kicad_scripts

Application: kicad
Version: 5.1.2-f72e74a~84~ubuntu19.04.1, release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.64.0 OpenSSL/1.1.1b zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh/0.8.6/openssl/zlib nghttp2/1.36.0 librtmp/2.3
Platform: Linux 5.0.0-16-generic x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
    Boost: 1.67.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.64.0
    Compiler: GCC 8.3.0 with C++ ABI 1013

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=ON
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON

Changed in kicad:
status: Incomplete → New
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers