Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uniform api for 3d graphics renderers #18510

Open
nilesjohnson mannequin opened this issue May 26, 2015 · 34 comments
Open

uniform api for 3d graphics renderers #18510

nilesjohnson mannequin opened this issue May 26, 2015 · 34 comments

Comments

@nilesjohnson
Copy link
Mannequin

nilesjohnson mannequin commented May 26, 2015

Refactor 3d plotting classes to create a uniform interface for rendering with various frontends. Will make it easier to maintain current and implement new rendering frontends. This will also make it possible to implement a new renderer outside of the Sage library, e.g. for prototyping.

Similar in strategy to rich representation as in #17234.

Note: we use 'render' in the most liberal sense. E.g. x3d "renders" to a particular format. Better term is welcome.

Idea: Instead of a repr method for each renderer on each 3d graphics class, put all rendering commands for a given renderer in a single class. Renderers are registered in a global dict, etc.

To do: Figure out precisely how this should interact with the rich_repr framework.

CC: @ohanar @vbraun @haraldschilly @novoselt

Component: graphics

Keywords: graphics3d, rich_repr

Branch/Commit: public/3drenderers @ c590694

Issue created by migration from https://trac.sagemath.org/ticket/18510

@nilesjohnson nilesjohnson mannequin added this to the sage-6.8 milestone May 26, 2015
@nilesjohnson nilesjohnson mannequin added c: graphics labels May 26, 2015
@nilesjohnson
Copy link
Mannequin Author

nilesjohnson mannequin commented May 26, 2015

New commits:

48c7028some stupid broken api code
3ab3f3esome progress, but still mostly broken
f6442famore non-working stubs
df462f4add FaceSequence and VertexSequence helper classes
31e7fb5progress on jmol renderer
485bdf2more progress on jmol renderer

@nilesjohnson
Copy link
Mannequin Author

nilesjohnson mannequin commented May 26, 2015

Commit: 485bdf2

@nilesjohnson
Copy link
Mannequin Author

nilesjohnson mannequin commented May 26, 2015

Changed branch from public/3drenders to public/3drenderers

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Changed commit from 485bdf2 to dd6cdf9

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

dd6cdf9some fixes, some progress

@vbraun
Copy link
Member

vbraun commented May 26, 2015

comment:3

+1 to the idea

Its a variant of the translator pattern, so maybe name things JmolTranslator etc?

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

8305657skeleton files for other renderers
1f756f1more progress
6444541renderers now work correctly for Graphics3dGroup and TransformGroup

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Changed commit from dd6cdf9 to 6444541

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Changed commit from 6444541 to 4e6a7dc

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

4e6a7dcsphere for tachyon

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Changed commit from 4e6a7dc to ae8ccb5

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

ae8ccb5initial idea for rich_repr

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Changed commit from ae8ccb5 to c7def5f

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

9f6d8cfmove some jmol stuff
c7def5fMerge branch 'public/3drenderers' of git://trac.sagemath.org/sage into public/3drenderers

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Changed commit from c7def5f to 98873c0

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

98873c0fix compilation

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

7c3ac01start adding graphics3d preference
5cc7f56register name instead of __name__

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Changed commit from 98873c0 to 5cc7f56

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

b6e0cc1cylinder for tachyon; probably broken
c496e19Merge branch 'public/3drenderers' of git://trac.sagemath.org/sage into public/3drenderers
372c662changes

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Changed commit from 5cc7f56 to 372c662

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Changed commit from 372c662 to 0aeaca6

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 26, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

0aeaca6fix rich output hopefully

@vbraun
Copy link
Member

vbraun commented May 26, 2015

comment:12

The idea behind the rich output is that the backend knows best which implementation to pick. The graphics preferences is just to express some overall preference, but it shouldn't be used to micromanage the implementation. E.g. for 2-d graphics there is a choice between raster and vector graphics, but which raster graphics format (png/jpg/gif/...) is intentionally not specified: Which one of those is best depends on the backend capababilities, e.g. the IPython notebook can't display gif. This is also easier for the user since he doesn't have to know the difference between different implementations nor their support in different backends.

For 3-d graphics there is a logical choice between rendered (2-d bitmap) vs live 3d, but shouldn't offer further controls on the particular implementation. More is just confusing to non-experts (what is jmol and why is it not working [if I don't have java installed]?). Let the backend decide what produces good quality and what doesn't.

@ohanar
Copy link
Member

ohanar commented May 26, 2015

comment:13

Right now the preferences that you can set aren't really publicized, so at the moment, non-experts will never really see the preferences. Moreover, I think that you should support experts who might care about the format that they get (e.g. they always want jpg over png) and that they should be able to set their preferences as such.

Additionally, with the binary choice, I wouldn't be able to implement a renderer outside of the sage library and use it as the default in my own backend, since all of the renderers within the sage library would be preferred over my own.

For instance, SMC does not currently use a backend, but rather monkey patches things because it uses its own threejs based renderer. While this stuff will likely eventually make its way into the sage library, you shouldn't be forced to implement these things in the library itself. If the backend can specify its own preferred renderers, then it is possible implement such things outside of the sage library.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 27, 2015

Changed commit from 0aeaca6 to fb1292f

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 27, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

fb1292ftodays progress

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 27, 2015

Changed commit from fb1292f to b5c7cac

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 27, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

8582fd9set graphics3d preferences for various backends and fix doctests
b5c7cacclear out stubs and move docstrings/tests into apropriate files

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 27, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

80067femake python stop complaining about indentation

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 27, 2015

Changed commit from b5c7cac to 80067fe

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 27, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

85f083emake renderers singleton classes
c590694make register stuff work

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 27, 2015

Changed commit from 80067fe to c590694

@vbraun
Copy link
Member

vbraun commented May 27, 2015

comment:19

No, the preferences are what you access through %display, so they are in fact the easiest and intended way to interact with the display manager. Thats why its user hostile if you name settings after obscure package names, and confusing to boot since not every 3d implementation makes sense for every UI.

If you want to micromanage the format then there is already foo.plot(viewer='jmol') and friends. The keyword name might/should be changed but at least its hidden away so that no ordinary user has to deal with it. An alternative would be foo.save('output.obj').show() and use the file extension to guess the type.

You can't realistically have pluggable arbitrary rich output, the author of the Sage object needs to know what the possibilities are in order to decide on the suitable rich output. Now for the the very special case of just 3d graphics that might make sense, but then you can easily do that by

def _rich_repr_:
    ... try sane defaults first ...
    # if none of the defaults work try the rest 
    for output_type in display_manager.supported_output():
        try:
            return renderer(self, output_type) 
        except:
            pass

and then declare a particular output type as the only supported one from your backend.

@vbraun
Copy link
Member

vbraun commented May 27, 2015

comment:20

PS: "render" has a rather narrow meaning in the 3d graphics context http://en.wikipedia.org/wiki/3D_rendering, IMHO it would be clearer if you chose a different one

@mkoeppe mkoeppe removed this from the sage-6.8 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants