Page MenuHome

Add a Math Vis cleanup menu entry to the Console Menu
ClosedPublic

Authored by Gaia Clary (gaiaclary) on Nov 24 2016, 7:47 PM.

Details

Summary

The problem with Math Vis is when you use it a lot then you can easily get your View_3D polluted with lots of Matrix boxes and Vectors, etc... The only way to get rid of those elements is by deleting the related variables from the Console. But sometimes its just tedious to delete the variables one by one or even remember which variables have been defined at all.

  • The patch adds a new Operator which is called form within the Console Menu. The menu entry is: "Clear Math Vis" This operator deletes all items that can be displayed by MathVis
  • I also added a panel with a list of visualize able items
  • You can hide each item
  • You can lock each item so that it gets not purged when cleaning up the console (see below)
  • you can delete unlocked items
  • The "Hide Names" property allows to suppress the display of item names on the display
  • The "Hide BBoxes" property allows to hide the coordinate system for matrix like items
  • The scale value is for the display size of matrix like items: The original display for a couple of nearby matrices:
    And here the enhanced display:
  • The "Cleanup MathVis Console" operator deletes all local console variables which can be displayed by Math Vis and which have not been locked in the panel
  • I also tweaked the display of text a bit so that for items that are displayed at the 3D Cursor their names are now written in a list (below each other) instead of on top of each other which made no sense at all.

Note: Of course you can still delete and add variables on the console as you like. The variable lock as explained above is only related to the "Cleanup MathVis Console" operator

Diff Detail

Event Timeline

Gaia Clary (gaiaclary) retitled this revision from to Add a Math Vis cleanup menu entry to the Console Menu.
Gaia Clary (gaiaclary) updated this object.
Gaia Clary (gaiaclary) set the repository for this revision to rBA Blender Add-ons.

Moved the redraw tag directly into the operator. This avoids the need to import the draw.py from within the utils.py

Gaia Clary (gaiaclary) updated this revision to Diff 7884.EditedNov 25 2016, 12:14 AM

Found a missing import

btw: I added the imports to the functions, instead of adding them to the top of the file(s)
because that's how it was done in this Addon at other places as well.
I was told that the imports then will happen only when needed.

But on the other side this looks a bit odd to me.
Shall i modify this (add the imports to the top of the file)
or just keep it as it is now?

Removed unnecessary Import.
Tweaked the Z Axis of Matrix coordinate lines. The light blue (positive axis) was hardy to distinguish from the dark blue (negative axis)

I got another idea to improve this a bit more:

What about adding a panel into the tool shelf which displays a list of all console variables added by the user?
Then for each item in the list add a hide button and a delete button.

This panel could also have the "Clear Math Vis " button included which now would just delete all items in the panel list.

I found that the simple "Delete all user variables" is sometimes unpleasant. I found myself wanting to keep a couple of basic variables defined. Therfore i added a panel into the tool shelf that displays all user defined variables which also can be displayed on the 3D View.

However the panel allows me to selectively delete variables and to hide/unhide them.
At the bottom of the panel i added the "Delete all user variables" button
But i also added a variable locker so i can control which variables are kept when i delete "all unlocked vars"

Please see this as a work in progress.
I am happy to hear back your remarks and recommendations for improvements.

cheers,
Gaia

Used wrong name in function call.

Some minor nitpicks with the code mostly Pep8 :)

space_view3d_math_vis/__init__.py
47–52

Spaces around equals

66

prop.key=key spaces around equals and below (lines 70 and 76)

space_view3d_math_vis/utils.py
88–91

spaces around equals
In both cases the assignment is the same. Is that intentional?

Gaia Clary (gaiaclary) updated this object.

I added some properties to scale the display view of matrix like items which makes it more readable:

Gaia Clary (gaiaclary) marked 2 inline comments as done.Nov 27 2016, 3:25 PM

Added some replies to comments

space_view3d_math_vis/utils.py
88–91

yes. I had it first structured a bit different, but i got a hint from another python developer that i should do it like above. I could replace this by an or but wouldnt that make the code less easy to read?

Gaia Clary (gaiaclary) updated this object.

Cleaned up an if-elif construction that looked odd. And improved the Summary text a bit.

Bastien Montagne (mont29) edited edge metadata.

Besides points noted below, patch looks good to me, from quick check.

space_view3d_math_vis/__init__.py
59

vars is builtin in python, better not to override it… use variables instead?

61

type is also builtin in python, better not to override it… use key_type (or even ktype) instead?

67

You still have some issues with spaces around = :p

77

= & spaces again

80–82

again spaces, one after comma…

216

Don’t forget to del bpy.types.Scene.MathVisProp

space_view3d_math_vis/utils.py
91

space before the \

91–92

Use sets rather than lists here ({tuple, list} etc.)

94

= & spaces…

This revision is now accepted and ready to land.Nov 30 2016, 9:48 AM
Gaia Clary (gaiaclary) edited edge metadata.
  • Cleaned up the addon by using autopep8
  • Added preservation of the variable display states when calling F8 (reload addons) This was done because the console variables are intentionally not affected by F8
Gaia Clary (gaiaclary) marked 5 inline comments as done.Nov 30 2016, 10:08 PM
Gaia Clary (gaiaclary) marked 4 inline comments as done.Nov 30 2016, 10:11 PM

Patch applied to Master

Thanks to all who helped:
BatFinger, Lijenstina, LucaRood, Mont29