nortikin / sverchok

Sverchok
http://nortikin.github.io/sverchok/
GNU General Public License v3.0
2.25k stars 233 forks source link

B28 - Stethoscope: the location of minimized nodes vs their nodeview draw location #2597

Closed DolphinDream closed 5 years ago

DolphinDream commented 5 years ago

Similar to a previous issue in 2.79, the Stethoscope seems to still have issues with rendering its display (on mac osx Mojave 10.14.6). Adjusting sverchok preference settings for render scale and location values doesn’t seem to fix the problem. In 2.79 it used to be that a scale/location values of 2 fixed the problem but in 2.80 a value of 2 for these scale/location settings does not fix the problem. I can’t figure out if for 2.80 there are some magical set of values for these settings that would place the text in the right location relative to the stethoscope nodes.

I suspect that if this node has this rendering issues perhaps other nodes that do GL rendering in the node editor window would probably have similar displacement issues.

Personally, for noding and for developing nodes I find it essential to have this rendered text be properly displayed relative to the stethoscope node otherwise it becomes hard to debug a node setup.

SV-Stethoscope-DisplayIssue-B28

DolphinDream commented 5 years ago

Actually it seems that for scale/location setting values of 2 the easing and texture viewer nodes display the rendering in the proper location. I wonder why the stethoscope node seems to have the weird offset along x for the same scale values (which worked fine in 2.79).

SV-Stethoscope-DisplayIssue-B28-2
DolphinDream commented 5 years ago

Well, it seems that (for preference settings scale/location of 2) the text location for stethoscope is fine if the node is expanded.. the issue seems to be with the node when it’s minimized. I wonder if the node width is not reported correctly when the node is minimized, hence the wrong offset.

Screen Shot 2019-10-08 at 11 22 39 PM
zeffii commented 5 years ago

this also bugs me.

i don't think there's an update triggered by blender, that sverchok can interpret/receive to say "hey this node is minimized". Hence, if the node is drawing to nodeview already and the user minimizes using some built in operator, there wouldn't be a last signal to the stethoscope to redraw.

i'll look at it again. also the need to manually set the scale/whatever is not ideal and worth seeing maybe how AN acquires the info. (if i had such hardware i would figure it out myself)

zeffii commented 5 years ago

let me rename the title of this issue to reflect something we don't address yet, the location of minimized nodes vs their nodeview draw location

zeffii commented 5 years ago

this is what we do in stethoscope b28

            scale, location_theta = self.get_preferences()

            ....

            # adjust proposed text location in case node is framed.
            # take into consideration the hidden state
            node_width = (self.width_hidden + 30.0) if self.hide else self.width
            _x, _y = recursive_framed_location_finder(self, self.location[:])
            _x, _y = Vector((_x, _y)) + Vector((node_width + 20, 0))

            # this alters location based on DPI/Scale settings.
            location = adjust_location(_x, _y, location_theta)

and in texture viewer, unceremoniously

    def adjust_position_and_dimensions(self, x, y, width, height):
        """
        this could also return scale for a blf notation in the vacinity of the texture
        """
        scale, multiplier = self.get_preferences()
        x, y = [x * multiplier, y * multiplier]
        width, height = [width * scale, height * scale]
        return x, y, width, height
...

x, y, width, height = self.adjust_position_and_dimensions(x, y, width, height)
zeffii commented 5 years ago

just tested dropping width_hidden usage in stethoscope, works as hoped. pushed. will close this issue

zeffii commented 5 years ago

https://github.com/nortikin/sverchok/pull/2299/commits/3f3d4661c9116ac04633c4b0ff302750fbc5ed6c

i'll dig through the AN source to see how scale and multiplier can be inferred automatically

zeffii commented 5 years ago

in AN they do

def getDpiFactor():
    return getDpi() / 72

def getDpi():
    systemPreferences = bpy.context.user_preferences.system
    retinaFactor = getattr(systemPreferences, "pixel_size", 1)
    return systemPreferences.dpi * retinaFactor

https://github.com/JacquesLucke/animation_nodes/blob/1493e642aa22836032fbb35fb075c2537bde8e1a/animation_nodes/utils/blender_ui.py#L72-L75

zeffii commented 5 years ago

because updating these values isn't continously needed, we might offer a button in the N-Panel to update nodeview drawing parameters when pressed. The operator would then adjust the sverchok preferences. While the XY location of drawing should not be useful to manually set (assuming it is correctly introspected) the Scale of the nodeview drawing is a separate matter - some user driven customization might be desirable (ie wanting to see the stethoscope output slightly larger.. for one stethoscope.. but not all )

zeffii commented 5 years ago

in Blender 2.8 user_preferences was renamed..

import bpy

def getDpiFactor():
    return getDpi() / 72

def getDpi():
    systemPreferences = bpy.context.preferences.system
    retinaFactor = getattr(systemPreferences, "pixel_size", 1)
    return systemPreferences.dpi * retinaFactor

print('dpi factor', getDpiFactor())
print('dpi', getDpi())
>>> dpi factor 1.0
>>> dpi 72.0
zeffii commented 5 years ago

so.. logically, if the scale and multiplier must be manually set to 2 for hires screens (in Sverchok prefs)

then maybe you guys are getting

dpi factor 2.0
dpi 144.0
DolphinDream commented 5 years ago

so.. logically, if the scale and multiplier must be manually set to 2 for hires screens (in Sverchok prefs)

then maybe you guys are getting

dpi factor 2.0
dpi 144.0

yep. that’s what i get..

print('dpi factor', getDpiFactor()) dpi factor 2.0

print('dpi', getDpi()) dpi 144.0

zeffii commented 5 years ago

OK, well that's solved then. about 3 years late :)