bugpyFormex - Bugs: bug #42075, picking from one single object

 
 

bug #42075: picking from one single object

Submitted by:  gianluca de santis <gianlucadesi>
Submitted on:  Tue 08 Apr 2014 08:57:19 PM UTC  
 
Category:  GUI Severity:  3 - Normal
Item Group:  Feature request Status:  Ready For Test
Privacy:  Public Assigned to:  Benedict Verhegghe <bverheg>
Open/Closed:  Open

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Fri 29 Apr 2016 05:27:16 PM UTC, comment #8: 

An explanation to 2) in my previous comment #7:

The resetting of pf.canvas.pickable was not yet in the repository.
It is now in the commit 5bf7ae9, which also adds the pickable argument to the high level draw.pick functions.

Benedict Verhegghe <bverheg>
Project AdministratorIn charge of this item.
Fri 29 Apr 2016 05:21:00 PM UTC, comment #7: 

1) It does not save any memory. The list of actors will really also only be a list of pointers to Actor objects (this is how Python stores a list). And it is much more convenient for the user to directly use the Actor instance, than its index in the pf.canvas.actors list, which he would in most cases have to lookup first.

2) The pf.canvas.pickable list is not intended for the normal user. Furthermore, finishing a picking operation will reset it to None. Setting pf.canvas.pickable should normally only be used
inside a special purpose/higher level picking function, just
prior to the call to a pick function. This is what we want to do with the higher level picking functions in pyFormex, as mentioned in comment #5.
Outside the function, store the list in a normal variable, and pass it as an argument to the function.

Benedict Verhegghe <bverheg>
Project AdministratorIn charge of this item.
Fri 29 Apr 2016 04:45:31 PM UTC, comment #6: 

Great! Two doubts:

1) I wonder why pickable should really be a list of actors. Could not just be a list of actor keys? This would save memory.
In opengl/canvas at line 1392 (in pick_parts) there is:
for i, a in enumerate(self.actors):
   if a in pickable:
      ...
We could do:
for i, a in enumerate(self.actors):
    if a.key in pickablekeys:
    ....

2) If you specify the pf.canvas.pickable you create a pickable list, which is not None and it is remembered after running the script: i.e. you need to set it to None when running another script it otherwise you will have the old pickable. Is it a wanted behaviour?

gianluca de santis <gianlucadesi>
Project Member
Thu 28 Apr 2016 07:45:13 PM UTC, comment #5: 

As of e583e16 an Actor has an attribute pickable (default True).
See example WebGL for its use.

Furthermore, the pick functions return the index in the actors
list. This fixes the highlighting when using a pickable list or
the Actor.pickable attribute.

The function pickSinglePoint in the tools_menu plugin probably still needs some fixing. Gianluca?

Also, we could enable setting the canvas pickable list from an argument in the draw.pick function.

Benedict Verhegghe <bverheg>
Project AdministratorIn charge of this item.
Thu 28 Apr 2016 09:07:13 AM UTC, comment #4: 

After discussion, it seems that best solution is to follow th suggestion written in opengl/canvas.py at line 1380: add a pickable attribute to actors.
When picking the actor number (integer key) is returned if actor.pickable is True, and not the pickable number. Moreover, the pickable list should be destroyed after the picking.

The user would work write:
draw(obj1, pickable = False)
draw(obj2, pickable = True) # default
K = pick()
-> K.keys() will refer to the integer key of the actor

NB: the actor collection has as keys a full range (e.g. 0,1,2,3,4) of integers, but the collection returned by the picking could have a subset of these integers as keys (e.g. 2,4).

gianluca de santis <gianlucadesi>
Project Member
Mon 18 Apr 2016 01:35:53 PM UTC, comment #3: 

The pick returns the wrong actor when pickable is specified!
That is way the wrong point is highlighted.
This should be fixed in def pick() in viewport.py

Actually, the returned actor key is correct only if the pickable actors are drawn at the beginning and the non-pickable are drawn at the end. Why do we rely so on the order of the drawing and not on the actor's name?

gianluca de santis <gianlucadesi>
Project Member
Mon 11 Apr 2016 03:33:06 PM UTC, comment #2: 

If you use 'pickable' the highlighting is wrong:
in the attached example (bug_pickable_highlights.py) if you pick points on the CUBE the WRONG POINTS are HIGHLIGHTED on the SPHERE, but the correct values are returned.

(file #36892)

gianluca de santis <gianlucadesi>
Project Member
Wed 09 Apr 2014 01:16:14 PM UTC, comment #1: 

This is easy to do as a user function (which might then be added to some plugin menu). There are many ways to do it. One might be to use two picking operations: first pick actors, then actor items.

After the first pick, set Canvas.pickable to a list of actors from which can be picked in the second (item) picking (see canvas.pick_parts).
After the picking operation, Canvas.pickable should be reset to None (This should be done automatically, but is currrently forgotten).

Note that all drawn objects have a name (a default one is generated if the user did not specify one). But you could just as well the Actor index as appearing in the pick Collection.

Benedict Verhegghe <bverheg>
Project AdministratorIn charge of this item.
Tue 08 Apr 2014 08:57:19 PM UTC, original submission:  

Would it be possible to pick points/elements from one single object in the view?

The user could display 2 objects (A and B) but wants to pick only points/elements of A. Maybe this could be solved by assigning a name 'A' to the object A and getting only the points/elements of actor 'A' from the Collection?

gianluca de santis <gianlucadesi>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bverheg (Posted a comment)
  • -email is unavailable- added by gianlucadesi (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-04-28 bverheg Severity2 - Minor => 3 - Normal
        StatusIn Progress => Ready For Test
    2016-04-28 gianlucadesi Severity1 - Wish => 2 - Minor
        StatusNone => In Progress
        Assigned toNone => bverheg
    2016-04-11 gianlucadesi Attached File- => Added bug_pickable_highlights.py, #36892

    Back to the top


    Powered by Savane 3.5