Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 16:26
    kmuehlbauer commented #1568
  • Jan 31 2019 16:15
    kmuehlbauer commented #1568
  • Jan 31 2019 15:53
    djhoese commented #1568
  • Jan 31 2019 15:46
    kmuehlbauer edited #1568
  • Jan 31 2019 15:44
    kmuehlbauer opened #1568
  • Jan 31 2019 15:32
    djhoese commented #1566
  • Jan 31 2019 15:30
    djhoese commented #1567
  • Jan 31 2019 14:18
    GuillaumeFavelier commented #1561
  • Jan 31 2019 14:15
    GuillaumeFavelier commented #1561
  • Jan 31 2019 12:46
    opekar synchronize #1130
  • Jan 31 2019 09:54
    kmuehlbauer commented #1567
  • Jan 31 2019 09:53
    kmuehlbauer synchronize #1567
  • Jan 31 2019 09:37
    kmuehlbauer labeled #1567
  • Jan 31 2019 09:37
    kmuehlbauer labeled #1567
  • Jan 31 2019 09:37
    kmuehlbauer labeled #1563
  • Jan 31 2019 09:36
    kmuehlbauer labeled #1563
  • Jan 31 2019 09:28
    kmuehlbauer commented #1567
  • Jan 31 2019 09:27
    kmuehlbauer synchronize #1567
  • Jan 31 2019 09:19
    kmuehlbauer assigned #1563
  • Jan 31 2019 09:17
    kmuehlbauer opened #1567
Omicron91
@Omicron91
test_err1.PNG
test_err2.PNG
sometimes collapse the entire layout
David Hoese
@djhoese
@Omicron91 What version of vispy are you using? We no longer use cassowary as our grid solver. Could you try this with the most recent release of vispy?
Omicron91
@Omicron91
I'm using 0.6.4, i'll try. The team had been working for a while with this version, so i don't know if it could cause problems
David Hoese
@djhoese
It might. Depending on what you/they were using, but it will be hard for us to help with cassowary issues as it has been deprecated for quite a few releases now
Omicron91
@Omicron91
Now i got the last version and It is working as expected by the moment. Now i have another problem. I need to put some annotations in a view with a turntable camera, I'm using vispy.scene.visuals.Text which is a 2D Text which follows the camera rotation, i would like to set a background and i tried by creating a plane, set transform properties then copy the rotation of the camera, but the roll angle is not working on turntable. Is there another way to set a background rectangle for a vispy.scene.visuals.Text?
David Hoese
@djhoese
@Omicron91 Could you make a minimal example? It is hard to guess the best way forward going on just your description
Omicron91
@Omicron91
Captura_.PNG
this is that i want
self.t2 = scene.visuals.Text('Test Text', parent=self.view.scene, color='green')
    self.t2.font_size = 14

    self.plane = scene.visuals.Plane(
        width=1000,
        height=300,
        parent=self.t2
    )

    self.plane.transform = vispy.visuals.transforms.STTransform(translate=(0, 0, 0),
                            scale=(1., 1., 1.)).as_matrix()

    def on_mouse_move(self, event):
        if event.button == 1 and event.is_dragging:
            self.plane.transform.reset()

            self.plane.transform.rotate(self.view.camera.azimuth, (0, 0, 1))
            self.plane.transform.rotate(90 - self.view.camera.elevation, (0, 1, 0))
            self.plane.transform.rotate(self.view.camera.roll, (1, 0, 0))
This is what i tried
in the code of vispy the roll camera angle appears as 'not implemented' :(
David Hoese
@djhoese
And if you don't do any of that custom self.plane.transform stuff (not even setting it) then what happens? The Plane rotates with the camera but the text stays "2D"?
Omicron91
@Omicron91
The text is ok, always i can seen when i move the camera, the main problem is with the plane, I can't achieve to follow the text rotation, so it could look like a frame
David Hoese
@djhoese
And you say that self.view.camera.roll raises a not implemented error?
Omicron91
@Omicron91
nop, but in the code is there a comment that says that roll is not yet implemented. Is there any easy way to give a background color for a text? i need to visualize the text as the expected image in any angle, like a nameplate's player in a MMORPG game
David Hoese
@djhoese
I understand what you're going for. I just don't understand what is going wrong. I don't have a lot of experience with the TurntableCamera but if you could provide me an end to end example (a small example that I can copy/paste and run locally) then I might have some ideas. So far I'm not really sure exactly how it is wrong since I haven't played with it myself
Omicron91
@Omicron91
import numpy as np
import vispy.scene
from vispy.scene import visuals
from vispy.visuals import text

class CustomCanvas(vispy.scene.SceneCanvas):

    def __init__(self):
        super(CustomCanvas, self).__init__(keys='interactive', show=True)

        self.unfreeze()

        self.view = self.central_widget.add_view()

        self.xyz_top = None
        self.textLabelMax = None
        self.backgroundLabelMax = None

        self.events.mouse_move.connect(self.on_mouse_move)

        self.freeze()

    def on_mouse_move(self, event):

        if(event.button == 1 and event.is_dragging):

            self.backgroundLabelMax.transform.reset()

            self.backgroundLabelMax.transform.rotate(self.view.camera.azimuth, (0, 0, 1))
            self.backgroundLabelMax.transform.rotate(90 - self.view.camera.elevation, (1, 0, 0))

            self.backgroundLabelMax.transform.translate(self.xyz_top)

    def draw_cloud_points(self):

        pos = np.random.normal(size=(100000, 3), scale=0.2)
        # one could stop here for the data generation, the rest is just to make the
        # data look more interesting. Copied over from magnify.py
        centers = np.random.normal(size=(50, 3))
        indexes = np.random.normal(size=100000, loc=centers.shape[0]/2.,
                                scale=centers.shape[0]/3.)
        indexes = np.clip(indexes, 0, centers.shape[0]-1).astype(int)
        scales = 10**(np.linspace(-2, 0.5, centers.shape[0]))[indexes][:, np.newaxis]
        pos *= scales
        pos += centers[indexes]

        # create scatter object and fill in the data
        scatter = visuals.Markers()
        scatter.set_data(pos, edge_color=None, face_color=(1, 1, 1, .5), size=5)
        self.view.add(scatter)

        # Adding text label at center / top (Z axis)

        self.xyz_top = (pos[:,0].max(), pos[:,1].max(), pos[:,2].max())
        self.textLabelMax = visuals.Text(pos=self.xyz_top, text="Test_Label_Max", font_size=24, color="white", parent=self.view.scene)

        # Adding plane as background for texts
        self.backgroundLabelMax = visuals.Plane(width=5, height = 1, color=(1, 0, 0, 0.4), parent=self.view.scene)
        self.backgroundLabelMax.transform = vispy.scene.transforms.STTransform(
            scale=(1, 1, 1),
            translate=self.xyz_top
        ).as_matrix()

        # Adding turntable with ortographic view
        self.view.camera = vispy.scene.TurntableCamera(fov=0, azimuth=0, elevation=90, roll=0)

        # Auto focus
        self.view.camera.set_range()

def main():
    custom_canvas = CustomCanvas()
    custom_canvas.draw_cloud_points()

if __name__ == '__main__':
    import sys
    if sys.flags.interactive != 1:
        main()
        vispy.app.run()
David Hoese
@djhoese
although that isn't accurate, it is kind of a cool effect
I'll try to find time to look into this more today or sometime this week
David Hoese
@djhoese
There has to be math operation (np.dot or something) but it isn't coming to me.
Surprisingly doing self.backgroundLabelMax.transform.matrix = self.view.camera.transform.matrix and self.backgroundLabelMax.transform.translate(self.xyz_top) gets it pretty close...somehow
Omicron91
@Omicron91
Oh nice, that's what I was looking for. This should be enough. Thanks for helping!
Omicron91
@Omicron91
Now it's working. I think this is very usefull when u want to visualize annotations over 3D things
import numpy as np
import vispy.scene
from vispy.scene import visuals
from vispy.visuals import text

class CustomCanvas(vispy.scene.SceneCanvas):

    def __init__(self):
        super(CustomCanvas, self).__init__(keys='interactive', show=True)

        self.unfreeze()

        self.view = self.central_widget.add_view()

        self.xyz_top = None
        self.textLabelMax = None
        self.backgroundLabelMax = None
        self.bgScale = [1, 1, 1]
        self.events.mouse_move.connect(self.on_mouse_move)
        self.events.mouse_wheel.connect(self.on_mouse_wheel)

        self.freeze()

    def on_mouse_move(self, event):

        if(event.button == 1 and event.is_dragging):
            self.backgroundLabelMax.transform.reset()
            self.backgroundLabelMax.transform.matrix = self.view.camera.transform.matrix
            self.backgroundLabelMax.transform.translate(self.xyz_top)


    def on_mouse_wheel(self, event):
        pass
    """
        self.backgroundLabelMax.transform.reset()
        delta = event.delta[1]

        if(delta < 0):
            print(delta)
            if self.view.camera.scale_factor >= 30:
                self.view.camera.scale_factor = 30

        else:

            if self.view.camera.scale_factor <= 10:
                self.view.camera.scale_factor = 10

        self.backgroundLabelMax.transform.matrix = self.view.camera.transform.matrix
        self.backgroundLabelMax.transform.scale(self.bgScale)    
        self.backgroundLabelMax.transform.translate(self.xyz_top)
    """

    def draw_cloud_points(self):

        pos = np.random.normal(size=(100000, 3), scale=0.2)
        # one could stop here for the data generation, the rest is just to make the
        # data look more interesting. Copied over from magnify.py
        centers = np.random.normal(size=(50, 3))
        indexes = np.random.normal(size=100000, loc=centers.shape[0]/2.,
                                scale=centers.shape[0]/3.)
        indexes = np.clip(indexes, 0, centers.shape[0]-1).astype(int)
        scales = 10**(np.linspace(-2, 0.5, centers.shape[0]))[indexes][:, np.newaxis]
        pos *= scales
        pos += centers[indexes]

        # create scatter object and fill in the data
        scatter = visuals.Markers()
        scatter.set_data(pos, edge_color=None, face_color=(1, 1, 1, .5), size=5)
        self.view.add(scatter)

        # Adding turntable with ortographic view
        self.view.camera = vispy.scene.TurntableCamera(fov=0)

        # Adding plane as background for texts
        self.backgroundLabelMax = visuals.Rectangle(center = (0, 0, 0), width=3.5, height = 1, color=(1, 0, 0, 0.4), radius=0.3, parent=self.view.scene)
        # Adding text label at center / top (Z axis)

        self.xyz_top = (pos[:,0].max(), pos[:,1].max(), pos[:,2].max())
        self.textLabelMax = visuals.Text(pos=(0, 0, 0), text="Test_Label_Max", font_size=18, color="white", parent=self.backgroundLabelMax)

        self.backgroundLabelMax.transform = vispy.scene.transforms.STTransform(
            scale=(1, 1, 1),
            translate=(0, 0, 0)
        ).as_matrix()
        self.backgroundLabelMax.transform.matrix = self.view.camera.transform.matrix
        self.backgroundLabelMax.transform.translate(self.xyz_top)
        # Auto focus
        self.view.camera.set_range()

def main():
    custom_canvas = CustomCanvas()
    custom_canvas.draw_cloud_points()

if __name__ == '__main__':
    import sys
    if sys.flags.interactive != 1:
        main()
        vispy.app.run()
m3atwad
@m3atwad
Do we have to build the documentation like this example recommends?
m3atwad
@m3atwad
if so what directory do I need to be in to do this?
David Hoese
@djhoese
@m3atwad What do you mean "like this example recommends"? Are you making a contribution to the documentation and want to verify it? Otherwise, is there a reason you want to generate the documentation locally?
Looking at the README in that directory, that command is probably out dated. It should be as "easy" as running make html in the docdirectory. Note however that by default it will run all of the gallery examples which can take a long time. There is a way to make it not do that but I don't remember off the top of my head
m3atwad
@m3atwad
@djhoese Really I'm just looking for documentation to read and it seems sparse. I stumbled on that folder in the repo and thought I had to build the docs myself to get documentation I can learn from. Where would you say the best docs to learn vispy are? I also noticed multiple blogs and wiki's on the website are linked but the links are dead.
sreenath1994s
@sreenath1994s

Screenshot 2022-01-26 170245.png

Hello devs, I have a problem that after updating vispy from 0.6.6 to 0.9.4 my surfaceplot looks very dark.

Lorenzo Gaifas
@brisvag
@m3atwad yeah the documentation is sometimes a bit outdated. The generated one you can find on vispy.org; the most complete is probably in the API section. In terms of tutorials and guides your best bet is probably the examples folder!
@sreenath1994s a lot of things have changed since then, so it's hard to tell what's the issue without some code. Can you reproduce the change with a small snippet of code?
sreenath1994s
@sreenath1994s
# -*- coding: utf-8 -*-
# vispy: gallery 30
# -----------------------------------------------------------------------------
# Copyright (c) Vispy Development Team. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
# -----------------------------------------------------------------------------
"""
Draw a SurfacePlot
==================
This example demonstrates the use of the SurfacePlot visual.
"""

import sys
import numpy as np

from vispy import app, scene
from vispy.util.filter import gaussian_filter


canvas = scene.SceneCanvas(keys='interactive', bgcolor='w')
view = canvas.central_widget.add_view()
view.camera = scene.TurntableCamera(up='z', fov=60)

# Simple surface plot example
# x, y values are not specified, so assumed to be 0:50
z = np.random.normal(size=(250, 250), scale=200)
z[100, 100] += 50000
z = gaussian_filter(z, (10, 10))
p1 = scene.visuals.SurfacePlot(z=z, color=(0.3, 0.3, 1, 1), shading='smooth')
p1.transform = scene.transforms.MatrixTransform()
p1.transform.scale([1/249., 1/249., 1/249.])
p1.transform.translate([-0.5, -0.5, 0])

view.add(p1)

xax = scene.Axis(pos=[[-0.5, -0.5], [0.5, -0.5]], tick_direction=(0, -1),
                 font_size=16, axis_color='k', tick_color='k', text_color='k',
                 parent=view.scene)
xax.transform = scene.STTransform(translate=(0, 0, -0.2))

yax = scene.Axis(pos=[[-0.5, -0.5], [-0.5, 0.5]], tick_direction=(-1, 0),
                 font_size=16, axis_color='k', tick_color='k', text_color='k',
                 parent=view.scene)
yax.transform = scene.STTransform(translate=(0, 0, -0.2))

# Add a 3D axis to keep us oriented
axis = scene.visuals.XYZAxis(parent=view.scene)

if __name__ == '__main__':
    canvas.show()
    if sys.flags.interactive == 0:
        app.run()
@brisvag The above is a sample code from vispy github and these are the results with old and new versions of the library.
sreenath1994s
@sreenath1994s
Screenshot 2022-01-26 184247.png
These are the results with the 'Old' and 'New' library. Can somebody kindly help me in modifying the code so that the output from the 'New' version looks similar to the 'Old' version.
Lorenzo Gaifas
@brisvag

@sreenath1994s it seems that the crux of the issue is that the default light direction changed. Not sure why or when; you problem can be easily fixed by changing the light direction to something better. In the example above:

p1.shading_filter.light_dir = 1, 1, 1

this should be close enought to what you had before. If not, play around with the number until you're happy :)

sreenath1994s
@sreenath1994s
Thank you so much @brisvag it worked. One more question. In the old version, some kind of beautiful reflection exists. Which parameter I must adjust to enable that reflection.
Lorenzo Gaifas
@brisvag
Great! Not sure what you mean. Can you show me a screenshot with/without?
You can probably get what you want by playign around with the shading filter parameters
if you're in ipython, you can do p1.shading_filter? and it will give you the documentation for it
you can change specular light, shininess and so on
sreenath1994s
@sreenath1994s
Screenshot 2022-01-26 184247.png
@brisvag I was referring to the above reflection in the old version. I will go through the documentaion of shading_filter.
Thank you for the suggestion.
Lorenzo Gaifas
@brisvag
I see; that indeed looks like a specular highlight, so you can probably get it by changing those parameters.
David Hoese
@djhoese
@brisvag The lighting changes were mostly by @asnt after a huge refactor to the MeshVisual. I wonder if the SurfacePlot should be updated to have a different default light direction
Lorenzo Gaifas
@brisvag
Seems reasonable!
David Hoese
@djhoese
VisPy 0.9.5 has been released on PyPI! conda-forge should be later tonight
Lorenzo Gaifas
@brisvag
<3
David Hoese
@djhoese
I ended making a 0.9.6 release too. Hopefully fixes an issue @jni was seeing