Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
df11766
ignore dev folder
tomvanmele Sep 19, 2021
aeeac41
base artist
tomvanmele Sep 19, 2021
e8e4515
rebase rhino artists
tomvanmele Sep 19, 2021
2ac21c2
rebase blender artists
tomvanmele Sep 19, 2021
e4dc099
rhinoartist instead of baseartist
tomvanmele Sep 19, 2021
97be6e7
clean up
tomvanmele Sep 19, 2021
59c8cc3
log
tomvanmele Sep 19, 2021
042ebb9
add exception for missing artist
tomvanmele Sep 19, 2021
d1f8e36
log
tomvanmele Sep 19, 2021
1143b68
home brewed version of abstractmethod mechanism
tomvanmele Sep 19, 2021
1b04504
stubs for specialised base artists
tomvanmele Sep 19, 2021
25dcfb8
the base mesh implementation
tomvanmele Sep 19, 2021
618f3f6
docstrings
tomvanmele Sep 19, 2021
b8c6886
clean up
tomvanmele Sep 20, 2021
2c435ed
add redraw shortcut
tomvanmele Sep 20, 2021
33c780c
remove abstract redraw
tomvanmele Sep 20, 2021
b64891e
base mesh artist
tomvanmele Sep 20, 2021
1b34a18
base network artists
tomvanmele Sep 20, 2021
4bc62cf
simplify base rhino artist
tomvanmele Sep 20, 2021
76fd2ac
rhino implementations of mesh and network
tomvanmele Sep 20, 2021
03575b4
Merge branch 'main' into artist-factory
tomvanmele Sep 20, 2021
5f6f540
clean up merge
tomvanmele Sep 20, 2021
4618a50
base class for primitive artist
tomvanmele Sep 20, 2021
5673b21
base class for shape artist
tomvanmele Sep 20, 2021
66e8866
base artists for volmeshes
tomvanmele Sep 20, 2021
9ec87ca
unnecessary
tomvanmele Sep 20, 2021
46af2e2
pull up
tomvanmele Sep 20, 2021
11d296a
rebase box artist
tomvanmele Sep 20, 2021
28a5bde
rebasing on base artists
tomvanmele Sep 20, 2021
ea2d083
remove underscore
tomvanmele Sep 20, 2021
78f6e96
cooperative multiple inheritance sand rebase blender artists
tomvanmele Sep 21, 2021
339fc48
move robotmodelartist
tomvanmele Sep 21, 2021
5c49723
default facecolor white
tomvanmele Sep 22, 2021
e528daa
import base artist
tomvanmele Sep 22, 2021
d67c806
add box artist for blender
tomvanmele Sep 22, 2021
45b013f
Merge branch 'main' into artist-factory
tomvanmele Sep 22, 2021
5ee4af5
clean up and add sphere artist to blender
tomvanmele Sep 22, 2021
8144543
add capsule
tomvanmele Sep 22, 2021
c81a9e6
use same function
tomvanmele Sep 22, 2021
ae60fae
update docs
tomvanmele Sep 22, 2021
9157edf
capsule, cone, cylinder, polyhedron
tomvanmele Sep 22, 2021
db3735c
torus artist
tomvanmele Sep 22, 2021
2d735e9
add note about abc
tomvanmele Sep 22, 2021
479e509
convert ghpython artists
tomvanmele Sep 22, 2021
89c7f87
clean up init files
tomvanmele Sep 22, 2021
58671de
rename bae robotmodelartist
tomvanmele Sep 22, 2021
48ba793
rebase plotter artists
tomvanmele Sep 25, 2021
bde413f
lazy registration is necessary to avoid overwriting item-artist assig…
tomvanmele Sep 27, 2021
f14e4f4
replace build and build_as
tomvanmele Sep 28, 2021
29134a3
make collection paths unique to avoid all sorts of mayhem
tomvanmele Sep 28, 2021
3bb98a4
plotter singleton
tomvanmele Sep 28, 2021
dfbd4d6
don't pull up artists
tomvanmele Sep 28, 2021
386b017
refer to plotter singleton for parenting
tomvanmele Sep 28, 2021
3a17361
move collections, vertex size, node size and edge width to base artist
tomvanmele Sep 28, 2021
2609c18
docs consistency
tomvanmele Oct 5, 2021
56b6737
bug fix in cylinder artist parameters
tomvanmele Oct 5, 2021
3e010b2
Merge branch 'main' into artist-factory
tomvanmele Oct 5, 2021
5edf1ce
Allow runtime arbitrary selectors for plugins
gonzalocasas Oct 6, 2021
cd2eafd
Register robot model artist for Ghpython
gonzalocasas Oct 6, 2021
34a73b7
review suggestions
gonzalocasas Oct 7, 2021
b3c80d9
Merge pull request #909 from compas-dev/artist-factory-plugins
gonzalocasas Oct 7, 2021
9d4be79
lint
gonzalocasas Oct 7, 2021
18e8914
overwrite all options in draw call
tomvanmele Oct 7, 2021
359887a
remove debug print
tomvanmele Oct 8, 2021
1d476c4
rhino box artist faces only
tomvanmele Oct 8, 2021
ce4a93f
default to redraw false
tomvanmele Oct 8, 2021
b0588db
capsule and box as disjoint mesh
tomvanmele Oct 8, 2021
1dcdc10
Update CHANGELOG.md
tomvanmele Oct 8, 2021
fe9e997
rhino shapes on par with blender implementation
tomvanmele Oct 8, 2021
b5061d8
Merge remote-tracking branch 'origin/artist-factory' into artist-factory
tomvanmele Oct 8, 2021
dffc7b7
clear and redraw as pluggable drawing utils
tomvanmele Oct 8, 2021
5cbb2b8
rhino implementation for clear and redraw
tomvanmele Oct 8, 2021
7a16821
register artists only once
tomvanmele Oct 8, 2021
50cbead
redraw and clear plugins
tomvanmele Oct 8, 2021
bda3497
Merge branch 'main' into artist-factory
tomvanmele Oct 8, 2021
072f200
variable zstack options
tomvanmele Oct 12, 2021
d4ac48f
Merge remote-tracking branch 'origin/artist-factory' into artist-factory
tomvanmele Oct 12, 2021
a74776f
Implement abstract methods on gh's MeshArtist
gonzalocasas Oct 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added `__add__`, `__sub__`, `__and__` to `compas.geometry.Shape` for boolean operations using binary operators.
* Added `is_closed` to `compas.geometry.Polyhedron`.
* Added `Plane.offset`.
* Added `compas.artists.Artist`.
* Added pluggable `compas.artists.new_artist`.
* Added plugin `compas_rhino.artists.new_artist_rhino`.
* Added plugin `compas_blender.artists.new_artist_blender`.
* Added `compas.artist.DataArtistNotRegistered`.
* Added `draw_node_labels` and `draw_edgelabels` to `compas_blender.artists.NetworkArtist`.
* Added `compas_blender.artists.RobotModelArtist.clear`.
* Added `compas_blender.geometry.booleans` as plugin for boolean pluggables.
Expand All @@ -23,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

* Fixed bug in `compas_blender.draw_texts`.
* Changed `compas_rhino.artists.BaseArtist` to `compas_rhino.artists.RhinoArtist`.
* Changed `compas_blender.artists.BaseArtist` to `compas_blender.artists.BlenderArtist`.
* Changed default resolution for shape discretisation to 16 for both u and v where relevant.
* Changed base class of `compas.geometry.Primitive` and `compas.geometry.Shape` to `compas.geometry.Geometry`.
* `compas_blender.artists.RobotModelArtist.collection` can be assigned as a Blender collection or a name.
Expand Down
Binary file modified docs/_images/tutorial/plotters_dynamic.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/tutorial/plotters_line-options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/tutorial/plotters_vector-options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions docs/_templates/autosummary/base.rst

This file was deleted.

28 changes: 0 additions & 28 deletions docs/_templates/autosummary/class.rst

This file was deleted.

3 changes: 0 additions & 3 deletions docs/_templates/autosummary/module.rst

This file was deleted.

2 changes: 2 additions & 0 deletions docs/api/compas.artists.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

.. automodule:: compas.artists
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,6 @@ def linkcode_resolve(domain, info):
html_copy_source = False
html_show_sourcelink = False
html_permalinks = False
html_add_permalinks = ""
html_permalinks_icon = ""
html_experimental_html5_writer = True
html_compact_lists = True
8 changes: 5 additions & 3 deletions docs/devguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,12 @@ Advanced options

There are a few additional options that plugins can use:

* ``requires``: List of required python modules. COMPAS will filter out plugins if their
* ``requires``: List of requirements. COMPAS will filter out plugins if their
requirements list is not satisfied at runtime. This allows to have multiple implementations
of the same operation and have them selected based on which packages are installed.
on the system. Eg. `requires=['scipy']`.
of the same operation and have them selected based on different criteria.
The requirement can either be a package name string (e.g. ``requires=['scipy']``) or
a ``callable`` with a boolean return value, in which any arbitrary check can be implemented
(e.g. ``requires=[lambda: is_rhino_active()]``).
* ``tryfirst`` and ``trylast``: Plugins cannot control the exact priority they will have
but they can indicate whether to try to prioritize them or demote them as fallback using
these two boolean parameters.
Expand Down
3 changes: 2 additions & 1 deletion docs/tutorial/plotters_line-options.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
draw_points=True)

plotter.zoom_extents()
plotter.save('docs/_images/tutorial/plotters_line-options.png', dpi=300)
plotter.show()
# plotter.save('docs/_images/tutorial/plotters_line-options.png', dpi=300)
3 changes: 2 additions & 1 deletion docs/tutorial/plotters_point-options.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
for point in pointcloud:
plotter.add(point, size=random.randint(1, 10), edgecolor=i_to_rgb(random.random(), normalize=True))
plotter.zoom_extents()
plotter.save('docs/_images/tutorial/plotters_point-options.png', dpi=300)
plotter.show()
# plotter.save('docs/_images/tutorial/plotters_point-options.png', dpi=300)
3 changes: 2 additions & 1 deletion docs/tutorial/plotters_polygon-options.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
plotter.add(poly2, linestyle='dashed', facecolor=(1.0, 0.8, 0.8), edgecolor=(1.0, 0.0, 0.0))
plotter.add(poly3, alpha=0.5)
plotter.zoom_extents()
plotter.save('docs/_images/tutorial/plotters_polygon-options.png', dpi=300)
plotter.show()
# plotter.save('docs/_images/tutorial/plotters_polygon-options.png', dpi=300)
1 change: 1 addition & 0 deletions docs/tutorial/plotters_vector-options.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
plotter.add(b, size=10, edgecolor=(1, 0, 0))

plotter.zoom_extents()
plotter.show()
plotter.save('docs/_images/tutorial/plotters_vector-options.png', dpi=300)
1 change: 1 addition & 0 deletions src/compas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:maxdepth: 1
:titlesonly:

compas.artists
compas.data
compas.datastructures
compas.files
Expand Down
58 changes: 58 additions & 0 deletions src/compas/artists/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""
********************************************************************************
artists
********************************************************************************

.. currentmodule:: compas.artists

Classes
=======

.. autosummary::
:toctree: generated/
:nosignatures:

Artist
RobotModelArtist
MeshArtist
NetworkArtist
PrimitiveArtist
ShapeArtist
VolMeshArtist


Exceptions
==========

.. autosummary::
:toctree: generated/
:nosignatures:

DataArtistNotRegistered

"""
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

from .exceptions import DataArtistNotRegistered
from .artist import Artist
from .meshartist import MeshArtist
from .networkartist import NetworkArtist
from .primitiveartist import PrimitiveArtist
from .robotmodelartist import RobotModelArtist
from .shapeartist import ShapeArtist
from .volmeshartist import VolMeshArtist

BaseRobotModelArtist = RobotModelArtist
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add an internal deprecation note. Not sure if this specific suggestion is the way, but we should come up with a way to tag all these things that we intend to get rid of before 2.0 so that we can do a search-all-files at the right time.

Suggested change
BaseRobotModelArtist = RobotModelArtist
# NOTE: deprecated, will be removed in the next major release
BaseRobotModelArtist = RobotModelArtist


__all__ = [
'DataArtistNotRegistered',
'Artist',
'MeshArtist',
'NetworkArtist',
'PrimitiveArtist',
'RobotModelArtist',
'ShapeArtist',
'VolMeshArtist',
]
51 changes: 51 additions & 0 deletions src/compas/artists/artist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from abc import abstractmethod
from compas.plugins import pluggable


@pluggable(category='drawing-utils')
def clear():
raise NotImplementedError


@pluggable(category='drawing-utils')
def redraw():
raise NotImplementedError


@pluggable(category='factories')
def new_artist(cls, *args, **kwargs):
raise NotImplementedError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as in #888: maybe these things should not throw NotImplementedError but something that clearly signals (both to the user of compas and also to the developer/user reading code to understand) that this is an interface and the plugin is actually implemented (most likely) but just not here. So, something like compas.plugins.NoPluggableImplFound or similar.



class Artist(object):
"""Base class for all artists.
"""

ITEM_ARTIST = {}

def __new__(cls, *args, **kwargs):
return new_artist(cls, *args, **kwargs)

@staticmethod
def clear():
return clear()

@staticmethod
def redraw():
return redraw()

@staticmethod
def register(item_type, artist_type):
Artist.ITEM_ARTIST[item_type] = artist_type

@abstractmethod
def draw(self):
raise NotImplementedError

@staticmethod
def draw_collection(collection):
raise NotImplementedError
Comment on lines +49 to +51
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused why this is on the base Artist and not on the BlenderArtist.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha perhaps the name is confusing. was mean to be a static method to draw many objects at the same time. is not related to the "collection" of blender. but since there is no implementation for it anywhere, perhaps it can just be removed...

Empty file.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from ._artist import * # noqa: F401 F403

__all__ = [name for name in dir() if not name.startswith('_')]
class DataArtistNotRegistered(Exception):
pass
Loading