vedo.settings
1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3import os 4 5__docformat__ = "google" 6 7 8class Settings: 9 """ 10 General settings to modify the global behavior 11 12 Usage Example: 13 ```python 14 from vedo import settings, Cube 15 settings.use_parallel_projection = True 16 Cube().color('g').show().close() 17 ``` 18 19 List of available properties: 20 21 ```python 22 # Set a default for the font to be used for axes, comments etc. 23 default_font = 'Normografo' # check font options in shapes.Text 24 25 # Palette number when using an integer to choose a color 26 palette = 0 27 28 screenshot_transparent_background = False 29 screeshot_large_image = False # Sometimes setting this to True gives better results 30 31 # [DISABLED] Allow to continuously interact with scene during interactive() execution 32 allow_interaction = True 33 34 # Enable tracking pipeline functionality: 35 # allows to show a graph with the pipeline of action which let to a final object 36 # this is achieved by calling "myobj.pipeline.show()" (a new window will pop up) 37 self.enable_pipeline = True 38 39 # Set up default mouse and keyboard functionalities 40 enable_default_mouse_callbacks = True 41 enable_default_keyboard_callbacks = True 42 43 # If False, when multiple renderers are present do not render each one for separate 44 # but do it just once at the end (when interactive() is called) 45 immediate_rendering = True 46 47 # Show a gray frame margin in multirendering windows 48 renderer_frame_color = None 49 renderer_frame_alpha = 0.5 50 renderer_frame_width = 0.5 51 renderer_frame_padding = 0.0001 52 53 # In multirendering mode set the position of the horizontal of vertical splitting [0,1] 54 window_splitting_position = None 55 56 # Enable / disable color printing by printc() 57 enable_print_color = True 58 59 # Wrap lines in tubes 60 render_lines_as_tubes = False 61 62 # Smoothing options 63 point_smoothing = False 64 line_smoothing = False 65 polygon_smoothing = False 66 67 # Remove hidden lines when in wireframe mode 68 hidden_line_removal = False 69 70 # Turn on/off the automatic repositioning of lights as the camera moves. 71 light_follows_camera = False 72 two_sided_lighting = True 73 74 # Turn on/off rendering of translucent material with depth peeling technique. 75 use_depth_peeling = False 76 alpha_bit_planes = True # options only active if useDepthPeeling=True 77 multi_samples = 8 # force to not pick a framebuffer with a multisample buffer 78 max_number_of_peels= 4 # maximum number of rendering passes 79 occlusion_ratio = 0.0 # occlusion ratio, 0 = exact image. 80 81 # Turn on/off nvidia FXAA post-process anti-aliasing, if supported. 82 use_fxaa = False # either True or False 83 84 # By default, the depth buffer is reset for each renderer. 85 # If True, use the existing depth buffer 86 preserve_depth_buffer = False 87 88 # Use a polygon/edges offset to possibly resolve conflicts in rendering 89 use_polygon_offset = False 90 polygon_offset_factor = 0.1 91 polygon_offset_units = 0.1 92 93 # Interpolate scalars to render them smoothly 94 interpolate_scalars_before_mapping = True 95 96 # Set parallel projection On or Off (place camera to infinity, no perspective effects) 97 use_parallel_projection = False 98 99 # Set orientation type when reading TIFF files (volumes): 100 # TOPLEFT 1 (row 0 top, col 0 lhs) TOPRIGHT 2 (row 0 top, col 0 rhs) 101 # BOTRIGHT 3 (row 0 bottom, col 0 rhs) BOTLEFT 4 (row 0 bottom, col 0 lhs) 102 # LEFTTOP 5 (row 0 lhs, col 0 top) RIGHTTOP 6 (row 0 rhs, col 0 top) 103 # RIGHTBOT 7 (row 0 rhs, col 0 bottom) LEFTBOT 8 (row 0 lhs, col 0 bottom) 104 tiff_orientation_type = 1 105 106 # Annotated cube axis type nr. 5 options: 107 annotated_cube_color = (0.75, 0.75, 0.75) 108 annotated_cube_text_color = None # use default, otherwise specify a single color 109 annotated_cube_text_scale = 0.2 110 annotated_cube_texts = ["right","left ", "front","back ", " top ", "bttom"] 111 112 # Automatically close the Plotter instance after show() in jupyter sessions 113 # setting it to False will keep the current Plotter instance active 114 backend_autoclose = True 115 116 # k3d settings for jupyter notebooks 117 k3d_menu_visibility = True 118 k3d_plot_height = 512 119 k3d_antialias = True 120 k3d_lighting = 1.5 121 k3d_camera_autofit = True 122 k3d_grid_autofit= True 123 k3d_axes_color = "gray4" 124 k3d_axes_helper = 1.0 # size of the small triad of axes on the bottom right 125 k3d_point_shader= "mesh" # others are '3d', '3dSpecular', 'dot', 'flat' 126 k3d_line_shader = "thick" # others are 'flat', 'mesh' 127 ``` 128 """ 129 130 # Restrict the attributes so accidental typos will generate an AttributeError exception 131 __slots__ = [ 132 "_level", 133 "default_font", 134 "default_backend", 135 "palette", 136 "remember_last_figure_format", 137 "screenshot_transparent_background", 138 "screeshot_large_image", 139 "allow_interaction", 140 "hack_call_screen_size", 141 "enable_default_mouse_callbacks", 142 "enable_default_keyboard_callbacks", 143 "enable_pipeline", 144 "immediate_rendering", 145 "renderer_frame_color", 146 "renderer_frame_alpha", 147 "renderer_frame_width", 148 "renderer_frame_padding", 149 "render_lines_as_tubes", 150 "hidden_line_removal", 151 "point_smoothing", 152 "line_smoothing", 153 "polygon_smoothing", 154 "visible_grid_edges", 155 "light_follows_camera", 156 "two_sided_lighting", 157 "use_depth_peeling", 158 "multi_samples", 159 "alpha_bit_planes", 160 "max_number_of_peels", 161 "occlusion_ratio", 162 "use_fxaa", 163 "preserve_depth_buffer", 164 "use_polygon_offset", 165 "polygon_offset_factor", 166 "polygon_offset_units", 167 "interpolate_scalars_before_mapping", 168 "use_parallel_projection", 169 "window_splitting_position", 170 "tiff_orientation_type", 171 "annotated_cube_color", 172 "annotated_cube_text_color", 173 "annotated_cube_text_scale", 174 "annotated_cube_texts", 175 "enable_print_color", 176 "backend_autoclose", 177 "k3d_menu_visibility", 178 "k3d_plot_height", 179 "k3d_antialias", 180 "k3d_lighting", 181 "k3d_camera_autofit", 182 "k3d_grid_autofit", 183 "k3d_axes_color", 184 "k3d_axes_helper", 185 "k3d_point_shader", 186 "k3d_line_shader", 187 "font_parameters", 188 ] 189 190 def __init__(self, level=0): 191 192 self._level = level 193 194 # Default font 195 self.default_font = "Normografo" 196 197 # Default backend engine in jupyter notebooks 198 self.default_backend = "vtk" 199 200 # enable tracking pipeline functionality 201 self.enable_pipeline = True 202 203 if any(["SPYDER" in name for name in os.environ]): 204 self.default_backend = "vtk" 205 else: 206 try: 207 get_ipython() 208 self.default_backend = "2d" 209 except NameError: 210 pass 211 212 # Palette number when using an integer to choose a color 213 self.palette = 0 214 215 self.remember_last_figure_format = False 216 217 self.screenshot_transparent_background = False 218 self.screeshot_large_image = False 219 220 # [DISABLED] Allow to continuously interact with scene during interactor.Start() execution 221 self.allow_interaction = True 222 223 # BUG in vtk9.0 (if true close works but sometimes vtk crashes, if false doesnt crash but cannot close) 224 # see plotter.py line 555 225 self.hack_call_screen_size = True 226 227 # Set up default mouse and keyboard functionalities 228 self.enable_default_mouse_callbacks = True 229 self.enable_default_keyboard_callbacks = True 230 231 # When multiple renderers are present do not render each one for separate. 232 # but do it just once at the end (when interactive() is called) 233 self.immediate_rendering = True 234 235 # Show a gray frame margin in multirendering windows 236 self.renderer_frame_color = None 237 self.renderer_frame_alpha = 0.5 238 self.renderer_frame_width = 0.5 239 self.renderer_frame_padding = 0.0001 240 241 # Wrap lines in tubes 242 self.render_lines_as_tubes = False 243 244 # Remove hidden lines when in wireframe mode 245 self.hidden_line_removal = False 246 247 # Smoothing options 248 self.point_smoothing = False 249 self.line_smoothing = False 250 self.polygon_smoothing = False 251 252 # For Structured and RectilinearGrid: show internal edges not only outline 253 self.visible_grid_edges = False 254 255 # Turn on/off the automatic repositioning of lights as the camera moves. 256 self.light_follows_camera = False 257 self.two_sided_lighting = True 258 259 # Turn on/off rendering of translucent material with depth peeling technique. 260 self.use_depth_peeling = False 261 self.multi_samples = 8 262 self.alpha_bit_planes = 1 263 self.max_number_of_peels = 4 264 self.occlusion_ratio = 0.1 265 266 # Turn on/off nvidia FXAA anti-aliasing, if supported. 267 self.use_fxaa = False # either True or False 268 269 # By default, the depth buffer is reset for each renderer. If true, use the existing depth buffer 270 self.preserve_depth_buffer = False 271 272 # Use a polygon/edges offset to possibly resolve conflicts in rendering 273 self.use_polygon_offset = True 274 self.polygon_offset_factor = 0.1 275 self.polygon_offset_units = 0.1 276 277 # Interpolate scalars to render them smoothly 278 self.interpolate_scalars_before_mapping = True 279 280 # Set parallel projection On or Off (place camera to infinity, no perspective effects) 281 self.use_parallel_projection = False 282 283 # In multirendering mode set the position of the horizontal of vertical splitting [0,1] 284 self.window_splitting_position = None 285 286 # Set orientation type when reading TIFF files (volumes): 287 # TOPLEFT 1 (row 0 top, col 0 lhs) TOPRIGHT 2 (row 0 top, col 0 rhs) 288 # BOTRIGHT 3 (row 0 bottom, col 0 rhs) BOTLEFT 4 (row 0 bottom, col 0 lhs) 289 # LEFTTOP 5 (row 0 lhs, col 0 top) RIGHTTOP 6 (row 0 rhs, col 0 top) 290 # RIGHTBOT 7 (row 0 rhs, col 0 bottom) LEFTBOT 8 (row 0 lhs, col 0 bottom) 291 self.tiff_orientation_type = 1 292 293 # AnnotatedCube axis (type 5) customization: 294 self.annotated_cube_color = (0.75, 0.75, 0.75) 295 self.annotated_cube_text_color = None # use default, otherwise specify a single color 296 self.annotated_cube_text_scale = 0.2 297 self.annotated_cube_texts = ["right", "left ", "front", "back ", " top ", "bttom"] 298 299 # enable / disable color printing 300 self.enable_print_color = True 301 302 #################################################################################### 303 # Automatically close the Plotter instance after show() in jupyter sessions, 304 # setting it to False will keep the current Plotter instance active 305 self.backend_autoclose = True 306 307 # k3d settings for jupyter notebooks 308 self.k3d_menu_visibility = True 309 self.k3d_plot_height = 512 310 self.k3d_antialias = True 311 self.k3d_lighting = 1.5 312 self.k3d_camera_autofit = True 313 self.k3d_grid_autofit= True 314 self.k3d_axes_color = "k4" 315 self.k3d_axes_helper = 1.0 # size of the small triad of axes on the bottom right 316 self.k3d_point_shader= "mesh" # others are '3d', '3dSpecular', 'dot', 'flat' 317 self.k3d_line_shader = "thick" # others are 'flat', 'mesh' 318 319 #################################################################################### 320 #################################################################################### 321 # mono # means that all letters occupy the same space slot horizontally 322 # hspacing # an horizontal stretching factor (affects both letters and words) 323 # lspacing # horizontal spacing inbetween letters (not words) 324 # islocal # is locally stored in /fonts, otherwise it's on vedo.embl.es/fonts 325 # 326 self.font_parameters = dict( 327 Normografo=dict( 328 mono=False, 329 fscale=0.75, 330 hspacing=1, 331 lspacing=0.2, 332 dotsep="~×", 333 islocal=True, 334 ), 335 Bongas=dict( 336 mono=False, 337 fscale=0.875, 338 hspacing=0.52, 339 lspacing=0.25, 340 dotsep="·", 341 islocal=True, 342 ), 343 Calco=dict( 344 mono=True, 345 fscale=0.8, 346 hspacing=1, 347 lspacing=0.1, 348 dotsep="×", 349 islocal=True, 350 ), 351 Comae=dict( 352 mono=False, 353 fscale=0.75, 354 lspacing=0.2, 355 hspacing=1, 356 dotsep="~×", 357 islocal=True, 358 ), 359 ComicMono=dict( 360 mono=True, 361 fscale=0.8, 362 hspacing=1, 363 lspacing=0.1, 364 dotsep="x", 365 islocal=False, 366 ), 367 Edo=dict( 368 mono=False, 369 fscale=0.75, 370 hspacing=1, 371 lspacing=0.2, 372 dotsep="~x ", 373 islocal=False, 374 ), 375 FiraMonoMedium=dict( 376 mono=True, 377 fscale=0.8, 378 hspacing=1, 379 lspacing=0.1, 380 dotsep="×", 381 islocal=False, 382 ), 383 FiraMonoBold=dict( 384 mono=True, 385 fscale=0.8, 386 hspacing=1, 387 lspacing=0.1, 388 dotsep="×", 389 islocal=False, 390 ), 391 Glasgo=dict( 392 mono=True, 393 fscale=0.75, 394 lspacing=0.1, 395 hspacing=1, 396 dotsep="~×", 397 islocal=True, 398 ), 399 Kanopus=dict( 400 mono=False, 401 fscale=0.75, 402 lspacing=0.15, 403 hspacing=0.75, 404 dotsep="~×", 405 islocal=True, 406 ), 407 LogoType=dict( 408 mono=False, 409 fscale=0.75, 410 hspacing=1, 411 lspacing=0.2, 412 dotsep="~×", 413 islocal=False, 414 ), 415 Quikhand=dict( 416 mono=False, 417 fscale=0.8, 418 hspacing=0.6, 419 lspacing=0.15, 420 dotsep="~~×~", 421 islocal=True, 422 ), 423 SmartCouric=dict( 424 mono=True, 425 fscale=0.8, 426 hspacing=1.05, 427 lspacing=0.1, 428 dotsep="×", 429 islocal=True, 430 ), 431 Spears=dict( 432 mono=False, 433 fscale=0.8, 434 hspacing=0.5, 435 lspacing=0.2, 436 dotsep="~×", 437 islocal=False, 438 ), 439 Theemim=dict( 440 mono=False, 441 fscale=0.825, 442 hspacing=0.52, 443 lspacing=0.3, 444 dotsep="~~×", 445 islocal=True, 446 ), 447 VictorMono=dict( 448 mono=True, 449 fscale=0.725, 450 hspacing=1, 451 lspacing=0.1, 452 dotsep="×", 453 islocal=True, 454 ), 455 Justino1=dict( 456 mono=True, 457 fscale=0.725, 458 hspacing=1, 459 lspacing=0.1, 460 dotsep="×", 461 islocal=False, 462 ), 463 Justino2=dict( 464 mono=True, 465 fscale=0.725, 466 hspacing=1, 467 lspacing=0.1, 468 dotsep="×", 469 islocal=False, 470 ), 471 Justino3=dict( 472 mono=True, 473 fscale=0.725, 474 hspacing=1, 475 lspacing=0.1, 476 dotsep="×", 477 islocal=False, 478 ), 479 Calibri=dict( 480 mono=False, 481 fscale=0.75, 482 hspacing=1, 483 lspacing=0.2, 484 dotsep="~×", 485 islocal=False, 486 ), 487 Capsmall=dict( 488 mono=False, 489 fscale=0.8, 490 hspacing=0.75, 491 lspacing=0.15, 492 dotsep="~×", 493 islocal=False, 494 ), 495 Cartoons123=dict( 496 mono=False, 497 fscale=0.8, 498 hspacing=0.75, 499 lspacing=0.15, 500 dotsep="x", 501 islocal=False, 502 ), 503 Vega=dict( 504 mono=False, 505 fscale=0.8, 506 hspacing=0.75, 507 lspacing=0.15, 508 dotsep="×", 509 islocal=False, 510 ), 511 Meson=dict( 512 mono=False, 513 fscale=0.8, 514 hspacing=0.9, 515 lspacing=0.225, 516 dotsep="~×", 517 islocal=False, 518 ), 519 Komika=dict( 520 mono=False, 521 fscale=0.7, 522 hspacing=0.75, 523 lspacing=0.225, 524 dotsep="~×", 525 islocal=False, 526 ), 527 Vogue=dict( 528 mono=False, 529 fscale=0.7, 530 hspacing=0.75, 531 lspacing=0.225, 532 dotsep="~x", 533 islocal=False, 534 ), 535 Brachium=dict( 536 mono=True, 537 fscale=0.8, 538 hspacing=1, 539 lspacing=0.1, 540 dotsep="x", 541 islocal=False, 542 ), 543 Dalim=dict( 544 mono=False, 545 fscale=0.75, 546 lspacing=0.2, 547 hspacing=1, 548 dotsep="~×", 549 islocal=False, 550 ), 551 Miro=dict( 552 mono=False, 553 fscale=0.75, 554 lspacing=0.2, 555 hspacing=1, 556 dotsep="~×", 557 islocal=False, 558 ), 559 Ubuntu=dict( 560 mono=False, 561 fscale=0.75, 562 lspacing=0.2, 563 hspacing=1, 564 dotsep="~×", 565 islocal=False, 566 ), 567 Mizar=dict( 568 mono=False, 569 fscale=0.75, 570 lspacing=0.2, 571 hspacing=0.75, 572 dotsep="~×", 573 islocal=False, 574 ), 575 LiberationSans=dict( 576 mono=False, 577 fscale=0.75, 578 lspacing=0.2, 579 hspacing=1, 580 dotsep="~×", 581 islocal=False, 582 ), 583 DejavuSansMono=dict( 584 mono=True, 585 fscale=0.725, 586 hspacing=1, 587 lspacing=0.1, 588 dotsep="~×", 589 islocal=False, 590 ), 591 SunflowerHighway=dict( 592 mono=False, 593 fscale=0.75, 594 lspacing=0.2, 595 hspacing=1, 596 dotsep="~×", 597 islocal=False, 598 ), 599 Swansea=dict( 600 mono=False, 601 fscale=0.75, 602 lspacing=0.2, 603 hspacing=1, 604 dotsep="~×", 605 islocal=False, 606 ), 607 Housekeeper=dict( # support chinese glyphs 608 mono=False, 609 fscale=0.75, 610 hspacing=1, 611 lspacing=0.2, 612 dotsep="~×", 613 islocal=False, 614 ), 615 Wananti=dict( # support chinese glyphs 616 mono=False, 617 fscale=0.75, 618 hspacing=1, 619 lspacing=0.2, 620 dotsep="~x", 621 islocal=False, 622 ), 623 AnimeAce=dict( 624 mono=False, 625 fscale=0.75, 626 hspacing=1, 627 lspacing=0.2, 628 dotsep="~x", 629 islocal=False, 630 ), 631 AnimeAceBold=dict( 632 mono=False, 633 fscale=0.75, 634 hspacing=1, 635 lspacing=0.2, 636 dotsep="~x", 637 islocal=False, 638 ), 639 ) 640 641 #################################################################################### 642 def reset(self): 643 """Reset all settings to their default status.""" 644 self.__init__() 645 646 def print(self): 647 """Print function.""" 648 print(" " + "-" * 80) 649 s = Settings.__doc__.replace(" ", "") 650 s = s.replace(".. code-block:: python\n", "") 651 try: 652 from pygments import highlight 653 from pygments.lexers import Python3Lexer 654 from pygments.formatters import Terminal256Formatter 655 656 s = highlight(s, Python3Lexer(), Terminal256Formatter(style="zenburn")) 657 print(s, end="") 658 659 except ModuleNotFoundError: 660 print("\x1b[33;1m" + s + "\x1b[0m") 661 662 def __getitem__(self, key): 663 """Make the class work like a dictionary too""" 664 return getattr(self, key) 665 666 def __setitem__(self, key, value): 667 """Make the class work like a dictionary too""" 668 setattr(self, key, value) 669 670 671 def init_colab(self, enable_k3d=True): 672 """ 673 Initialize colab environment 674 """ 675 print("setting up colab environment (can take a minute) ...", end='') 676 677 res = os.system('which Xvfb') 678 if res: 679 os.system('apt-get install xvfb') 680 681 os.system('pip install pyvirtualdisplay') 682 683 from pyvirtualdisplay import Display 684 Display(visible=0).start() 685 686 if enable_k3d: 687 os.system('pip install k3d') 688 689 from google.colab import output 690 output.enable_custom_widget_manager() 691 692 if enable_k3d: 693 import k3d 694 try: 695 print("installing k3d...", end='') 696 os.system("jupyter nbextension install --py --user k3d") 697 os.system("jupyter nbextension enable --py --user k3d") 698 k3d.switch_to_text_protocol() 699 self.default_backend = 'k3d' 700 self.backend_autoclose = False 701 except: 702 print("(FAILED) ... ", end='') 703 704 print(" setup completed.") 705 706 707 def start_xvfb(self): 708 """ 709 Start xvfb. 710 711 Xvfb or X virtual framebuffer is a display server implementing 712 the X11 display server protocol. In contrast to other display servers, 713 Xvfb performs all graphical operations in virtual memory 714 without showing any screen output. 715 """ 716 print("starting xvfb (can take a minute) ...", end='') 717 res = os.system('which Xvfb') 718 if res: 719 os.system('apt-get install xvfb') 720 os.system('set -x') 721 os.system('export DISPLAY=:99.0') 722 os.system('Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &') 723 os.system('sleep 3') 724 os.system('set +x') 725 os.system('exec "$@"') 726 print(" xvfb started.")
class
Settings:
9class Settings: 10 """ 11 General settings to modify the global behavior 12 13 Usage Example: 14 ```python 15 from vedo import settings, Cube 16 settings.use_parallel_projection = True 17 Cube().color('g').show().close() 18 ``` 19 20 List of available properties: 21 22 ```python 23 # Set a default for the font to be used for axes, comments etc. 24 default_font = 'Normografo' # check font options in shapes.Text 25 26 # Palette number when using an integer to choose a color 27 palette = 0 28 29 screenshot_transparent_background = False 30 screeshot_large_image = False # Sometimes setting this to True gives better results 31 32 # [DISABLED] Allow to continuously interact with scene during interactive() execution 33 allow_interaction = True 34 35 # Enable tracking pipeline functionality: 36 # allows to show a graph with the pipeline of action which let to a final object 37 # this is achieved by calling "myobj.pipeline.show()" (a new window will pop up) 38 self.enable_pipeline = True 39 40 # Set up default mouse and keyboard functionalities 41 enable_default_mouse_callbacks = True 42 enable_default_keyboard_callbacks = True 43 44 # If False, when multiple renderers are present do not render each one for separate 45 # but do it just once at the end (when interactive() is called) 46 immediate_rendering = True 47 48 # Show a gray frame margin in multirendering windows 49 renderer_frame_color = None 50 renderer_frame_alpha = 0.5 51 renderer_frame_width = 0.5 52 renderer_frame_padding = 0.0001 53 54 # In multirendering mode set the position of the horizontal of vertical splitting [0,1] 55 window_splitting_position = None 56 57 # Enable / disable color printing by printc() 58 enable_print_color = True 59 60 # Wrap lines in tubes 61 render_lines_as_tubes = False 62 63 # Smoothing options 64 point_smoothing = False 65 line_smoothing = False 66 polygon_smoothing = False 67 68 # Remove hidden lines when in wireframe mode 69 hidden_line_removal = False 70 71 # Turn on/off the automatic repositioning of lights as the camera moves. 72 light_follows_camera = False 73 two_sided_lighting = True 74 75 # Turn on/off rendering of translucent material with depth peeling technique. 76 use_depth_peeling = False 77 alpha_bit_planes = True # options only active if useDepthPeeling=True 78 multi_samples = 8 # force to not pick a framebuffer with a multisample buffer 79 max_number_of_peels= 4 # maximum number of rendering passes 80 occlusion_ratio = 0.0 # occlusion ratio, 0 = exact image. 81 82 # Turn on/off nvidia FXAA post-process anti-aliasing, if supported. 83 use_fxaa = False # either True or False 84 85 # By default, the depth buffer is reset for each renderer. 86 # If True, use the existing depth buffer 87 preserve_depth_buffer = False 88 89 # Use a polygon/edges offset to possibly resolve conflicts in rendering 90 use_polygon_offset = False 91 polygon_offset_factor = 0.1 92 polygon_offset_units = 0.1 93 94 # Interpolate scalars to render them smoothly 95 interpolate_scalars_before_mapping = True 96 97 # Set parallel projection On or Off (place camera to infinity, no perspective effects) 98 use_parallel_projection = False 99 100 # Set orientation type when reading TIFF files (volumes): 101 # TOPLEFT 1 (row 0 top, col 0 lhs) TOPRIGHT 2 (row 0 top, col 0 rhs) 102 # BOTRIGHT 3 (row 0 bottom, col 0 rhs) BOTLEFT 4 (row 0 bottom, col 0 lhs) 103 # LEFTTOP 5 (row 0 lhs, col 0 top) RIGHTTOP 6 (row 0 rhs, col 0 top) 104 # RIGHTBOT 7 (row 0 rhs, col 0 bottom) LEFTBOT 8 (row 0 lhs, col 0 bottom) 105 tiff_orientation_type = 1 106 107 # Annotated cube axis type nr. 5 options: 108 annotated_cube_color = (0.75, 0.75, 0.75) 109 annotated_cube_text_color = None # use default, otherwise specify a single color 110 annotated_cube_text_scale = 0.2 111 annotated_cube_texts = ["right","left ", "front","back ", " top ", "bttom"] 112 113 # Automatically close the Plotter instance after show() in jupyter sessions 114 # setting it to False will keep the current Plotter instance active 115 backend_autoclose = True 116 117 # k3d settings for jupyter notebooks 118 k3d_menu_visibility = True 119 k3d_plot_height = 512 120 k3d_antialias = True 121 k3d_lighting = 1.5 122 k3d_camera_autofit = True 123 k3d_grid_autofit= True 124 k3d_axes_color = "gray4" 125 k3d_axes_helper = 1.0 # size of the small triad of axes on the bottom right 126 k3d_point_shader= "mesh" # others are '3d', '3dSpecular', 'dot', 'flat' 127 k3d_line_shader = "thick" # others are 'flat', 'mesh' 128 ``` 129 """ 130 131 # Restrict the attributes so accidental typos will generate an AttributeError exception 132 __slots__ = [ 133 "_level", 134 "default_font", 135 "default_backend", 136 "palette", 137 "remember_last_figure_format", 138 "screenshot_transparent_background", 139 "screeshot_large_image", 140 "allow_interaction", 141 "hack_call_screen_size", 142 "enable_default_mouse_callbacks", 143 "enable_default_keyboard_callbacks", 144 "enable_pipeline", 145 "immediate_rendering", 146 "renderer_frame_color", 147 "renderer_frame_alpha", 148 "renderer_frame_width", 149 "renderer_frame_padding", 150 "render_lines_as_tubes", 151 "hidden_line_removal", 152 "point_smoothing", 153 "line_smoothing", 154 "polygon_smoothing", 155 "visible_grid_edges", 156 "light_follows_camera", 157 "two_sided_lighting", 158 "use_depth_peeling", 159 "multi_samples", 160 "alpha_bit_planes", 161 "max_number_of_peels", 162 "occlusion_ratio", 163 "use_fxaa", 164 "preserve_depth_buffer", 165 "use_polygon_offset", 166 "polygon_offset_factor", 167 "polygon_offset_units", 168 "interpolate_scalars_before_mapping", 169 "use_parallel_projection", 170 "window_splitting_position", 171 "tiff_orientation_type", 172 "annotated_cube_color", 173 "annotated_cube_text_color", 174 "annotated_cube_text_scale", 175 "annotated_cube_texts", 176 "enable_print_color", 177 "backend_autoclose", 178 "k3d_menu_visibility", 179 "k3d_plot_height", 180 "k3d_antialias", 181 "k3d_lighting", 182 "k3d_camera_autofit", 183 "k3d_grid_autofit", 184 "k3d_axes_color", 185 "k3d_axes_helper", 186 "k3d_point_shader", 187 "k3d_line_shader", 188 "font_parameters", 189 ] 190 191 def __init__(self, level=0): 192 193 self._level = level 194 195 # Default font 196 self.default_font = "Normografo" 197 198 # Default backend engine in jupyter notebooks 199 self.default_backend = "vtk" 200 201 # enable tracking pipeline functionality 202 self.enable_pipeline = True 203 204 if any(["SPYDER" in name for name in os.environ]): 205 self.default_backend = "vtk" 206 else: 207 try: 208 get_ipython() 209 self.default_backend = "2d" 210 except NameError: 211 pass 212 213 # Palette number when using an integer to choose a color 214 self.palette = 0 215 216 self.remember_last_figure_format = False 217 218 self.screenshot_transparent_background = False 219 self.screeshot_large_image = False 220 221 # [DISABLED] Allow to continuously interact with scene during interactor.Start() execution 222 self.allow_interaction = True 223 224 # BUG in vtk9.0 (if true close works but sometimes vtk crashes, if false doesnt crash but cannot close) 225 # see plotter.py line 555 226 self.hack_call_screen_size = True 227 228 # Set up default mouse and keyboard functionalities 229 self.enable_default_mouse_callbacks = True 230 self.enable_default_keyboard_callbacks = True 231 232 # When multiple renderers are present do not render each one for separate. 233 # but do it just once at the end (when interactive() is called) 234 self.immediate_rendering = True 235 236 # Show a gray frame margin in multirendering windows 237 self.renderer_frame_color = None 238 self.renderer_frame_alpha = 0.5 239 self.renderer_frame_width = 0.5 240 self.renderer_frame_padding = 0.0001 241 242 # Wrap lines in tubes 243 self.render_lines_as_tubes = False 244 245 # Remove hidden lines when in wireframe mode 246 self.hidden_line_removal = False 247 248 # Smoothing options 249 self.point_smoothing = False 250 self.line_smoothing = False 251 self.polygon_smoothing = False 252 253 # For Structured and RectilinearGrid: show internal edges not only outline 254 self.visible_grid_edges = False 255 256 # Turn on/off the automatic repositioning of lights as the camera moves. 257 self.light_follows_camera = False 258 self.two_sided_lighting = True 259 260 # Turn on/off rendering of translucent material with depth peeling technique. 261 self.use_depth_peeling = False 262 self.multi_samples = 8 263 self.alpha_bit_planes = 1 264 self.max_number_of_peels = 4 265 self.occlusion_ratio = 0.1 266 267 # Turn on/off nvidia FXAA anti-aliasing, if supported. 268 self.use_fxaa = False # either True or False 269 270 # By default, the depth buffer is reset for each renderer. If true, use the existing depth buffer 271 self.preserve_depth_buffer = False 272 273 # Use a polygon/edges offset to possibly resolve conflicts in rendering 274 self.use_polygon_offset = True 275 self.polygon_offset_factor = 0.1 276 self.polygon_offset_units = 0.1 277 278 # Interpolate scalars to render them smoothly 279 self.interpolate_scalars_before_mapping = True 280 281 # Set parallel projection On or Off (place camera to infinity, no perspective effects) 282 self.use_parallel_projection = False 283 284 # In multirendering mode set the position of the horizontal of vertical splitting [0,1] 285 self.window_splitting_position = None 286 287 # Set orientation type when reading TIFF files (volumes): 288 # TOPLEFT 1 (row 0 top, col 0 lhs) TOPRIGHT 2 (row 0 top, col 0 rhs) 289 # BOTRIGHT 3 (row 0 bottom, col 0 rhs) BOTLEFT 4 (row 0 bottom, col 0 lhs) 290 # LEFTTOP 5 (row 0 lhs, col 0 top) RIGHTTOP 6 (row 0 rhs, col 0 top) 291 # RIGHTBOT 7 (row 0 rhs, col 0 bottom) LEFTBOT 8 (row 0 lhs, col 0 bottom) 292 self.tiff_orientation_type = 1 293 294 # AnnotatedCube axis (type 5) customization: 295 self.annotated_cube_color = (0.75, 0.75, 0.75) 296 self.annotated_cube_text_color = None # use default, otherwise specify a single color 297 self.annotated_cube_text_scale = 0.2 298 self.annotated_cube_texts = ["right", "left ", "front", "back ", " top ", "bttom"] 299 300 # enable / disable color printing 301 self.enable_print_color = True 302 303 #################################################################################### 304 # Automatically close the Plotter instance after show() in jupyter sessions, 305 # setting it to False will keep the current Plotter instance active 306 self.backend_autoclose = True 307 308 # k3d settings for jupyter notebooks 309 self.k3d_menu_visibility = True 310 self.k3d_plot_height = 512 311 self.k3d_antialias = True 312 self.k3d_lighting = 1.5 313 self.k3d_camera_autofit = True 314 self.k3d_grid_autofit= True 315 self.k3d_axes_color = "k4" 316 self.k3d_axes_helper = 1.0 # size of the small triad of axes on the bottom right 317 self.k3d_point_shader= "mesh" # others are '3d', '3dSpecular', 'dot', 'flat' 318 self.k3d_line_shader = "thick" # others are 'flat', 'mesh' 319 320 #################################################################################### 321 #################################################################################### 322 # mono # means that all letters occupy the same space slot horizontally 323 # hspacing # an horizontal stretching factor (affects both letters and words) 324 # lspacing # horizontal spacing inbetween letters (not words) 325 # islocal # is locally stored in /fonts, otherwise it's on vedo.embl.es/fonts 326 # 327 self.font_parameters = dict( 328 Normografo=dict( 329 mono=False, 330 fscale=0.75, 331 hspacing=1, 332 lspacing=0.2, 333 dotsep="~×", 334 islocal=True, 335 ), 336 Bongas=dict( 337 mono=False, 338 fscale=0.875, 339 hspacing=0.52, 340 lspacing=0.25, 341 dotsep="·", 342 islocal=True, 343 ), 344 Calco=dict( 345 mono=True, 346 fscale=0.8, 347 hspacing=1, 348 lspacing=0.1, 349 dotsep="×", 350 islocal=True, 351 ), 352 Comae=dict( 353 mono=False, 354 fscale=0.75, 355 lspacing=0.2, 356 hspacing=1, 357 dotsep="~×", 358 islocal=True, 359 ), 360 ComicMono=dict( 361 mono=True, 362 fscale=0.8, 363 hspacing=1, 364 lspacing=0.1, 365 dotsep="x", 366 islocal=False, 367 ), 368 Edo=dict( 369 mono=False, 370 fscale=0.75, 371 hspacing=1, 372 lspacing=0.2, 373 dotsep="~x ", 374 islocal=False, 375 ), 376 FiraMonoMedium=dict( 377 mono=True, 378 fscale=0.8, 379 hspacing=1, 380 lspacing=0.1, 381 dotsep="×", 382 islocal=False, 383 ), 384 FiraMonoBold=dict( 385 mono=True, 386 fscale=0.8, 387 hspacing=1, 388 lspacing=0.1, 389 dotsep="×", 390 islocal=False, 391 ), 392 Glasgo=dict( 393 mono=True, 394 fscale=0.75, 395 lspacing=0.1, 396 hspacing=1, 397 dotsep="~×", 398 islocal=True, 399 ), 400 Kanopus=dict( 401 mono=False, 402 fscale=0.75, 403 lspacing=0.15, 404 hspacing=0.75, 405 dotsep="~×", 406 islocal=True, 407 ), 408 LogoType=dict( 409 mono=False, 410 fscale=0.75, 411 hspacing=1, 412 lspacing=0.2, 413 dotsep="~×", 414 islocal=False, 415 ), 416 Quikhand=dict( 417 mono=False, 418 fscale=0.8, 419 hspacing=0.6, 420 lspacing=0.15, 421 dotsep="~~×~", 422 islocal=True, 423 ), 424 SmartCouric=dict( 425 mono=True, 426 fscale=0.8, 427 hspacing=1.05, 428 lspacing=0.1, 429 dotsep="×", 430 islocal=True, 431 ), 432 Spears=dict( 433 mono=False, 434 fscale=0.8, 435 hspacing=0.5, 436 lspacing=0.2, 437 dotsep="~×", 438 islocal=False, 439 ), 440 Theemim=dict( 441 mono=False, 442 fscale=0.825, 443 hspacing=0.52, 444 lspacing=0.3, 445 dotsep="~~×", 446 islocal=True, 447 ), 448 VictorMono=dict( 449 mono=True, 450 fscale=0.725, 451 hspacing=1, 452 lspacing=0.1, 453 dotsep="×", 454 islocal=True, 455 ), 456 Justino1=dict( 457 mono=True, 458 fscale=0.725, 459 hspacing=1, 460 lspacing=0.1, 461 dotsep="×", 462 islocal=False, 463 ), 464 Justino2=dict( 465 mono=True, 466 fscale=0.725, 467 hspacing=1, 468 lspacing=0.1, 469 dotsep="×", 470 islocal=False, 471 ), 472 Justino3=dict( 473 mono=True, 474 fscale=0.725, 475 hspacing=1, 476 lspacing=0.1, 477 dotsep="×", 478 islocal=False, 479 ), 480 Calibri=dict( 481 mono=False, 482 fscale=0.75, 483 hspacing=1, 484 lspacing=0.2, 485 dotsep="~×", 486 islocal=False, 487 ), 488 Capsmall=dict( 489 mono=False, 490 fscale=0.8, 491 hspacing=0.75, 492 lspacing=0.15, 493 dotsep="~×", 494 islocal=False, 495 ), 496 Cartoons123=dict( 497 mono=False, 498 fscale=0.8, 499 hspacing=0.75, 500 lspacing=0.15, 501 dotsep="x", 502 islocal=False, 503 ), 504 Vega=dict( 505 mono=False, 506 fscale=0.8, 507 hspacing=0.75, 508 lspacing=0.15, 509 dotsep="×", 510 islocal=False, 511 ), 512 Meson=dict( 513 mono=False, 514 fscale=0.8, 515 hspacing=0.9, 516 lspacing=0.225, 517 dotsep="~×", 518 islocal=False, 519 ), 520 Komika=dict( 521 mono=False, 522 fscale=0.7, 523 hspacing=0.75, 524 lspacing=0.225, 525 dotsep="~×", 526 islocal=False, 527 ), 528 Vogue=dict( 529 mono=False, 530 fscale=0.7, 531 hspacing=0.75, 532 lspacing=0.225, 533 dotsep="~x", 534 islocal=False, 535 ), 536 Brachium=dict( 537 mono=True, 538 fscale=0.8, 539 hspacing=1, 540 lspacing=0.1, 541 dotsep="x", 542 islocal=False, 543 ), 544 Dalim=dict( 545 mono=False, 546 fscale=0.75, 547 lspacing=0.2, 548 hspacing=1, 549 dotsep="~×", 550 islocal=False, 551 ), 552 Miro=dict( 553 mono=False, 554 fscale=0.75, 555 lspacing=0.2, 556 hspacing=1, 557 dotsep="~×", 558 islocal=False, 559 ), 560 Ubuntu=dict( 561 mono=False, 562 fscale=0.75, 563 lspacing=0.2, 564 hspacing=1, 565 dotsep="~×", 566 islocal=False, 567 ), 568 Mizar=dict( 569 mono=False, 570 fscale=0.75, 571 lspacing=0.2, 572 hspacing=0.75, 573 dotsep="~×", 574 islocal=False, 575 ), 576 LiberationSans=dict( 577 mono=False, 578 fscale=0.75, 579 lspacing=0.2, 580 hspacing=1, 581 dotsep="~×", 582 islocal=False, 583 ), 584 DejavuSansMono=dict( 585 mono=True, 586 fscale=0.725, 587 hspacing=1, 588 lspacing=0.1, 589 dotsep="~×", 590 islocal=False, 591 ), 592 SunflowerHighway=dict( 593 mono=False, 594 fscale=0.75, 595 lspacing=0.2, 596 hspacing=1, 597 dotsep="~×", 598 islocal=False, 599 ), 600 Swansea=dict( 601 mono=False, 602 fscale=0.75, 603 lspacing=0.2, 604 hspacing=1, 605 dotsep="~×", 606 islocal=False, 607 ), 608 Housekeeper=dict( # support chinese glyphs 609 mono=False, 610 fscale=0.75, 611 hspacing=1, 612 lspacing=0.2, 613 dotsep="~×", 614 islocal=False, 615 ), 616 Wananti=dict( # support chinese glyphs 617 mono=False, 618 fscale=0.75, 619 hspacing=1, 620 lspacing=0.2, 621 dotsep="~x", 622 islocal=False, 623 ), 624 AnimeAce=dict( 625 mono=False, 626 fscale=0.75, 627 hspacing=1, 628 lspacing=0.2, 629 dotsep="~x", 630 islocal=False, 631 ), 632 AnimeAceBold=dict( 633 mono=False, 634 fscale=0.75, 635 hspacing=1, 636 lspacing=0.2, 637 dotsep="~x", 638 islocal=False, 639 ), 640 ) 641 642 #################################################################################### 643 def reset(self): 644 """Reset all settings to their default status.""" 645 self.__init__() 646 647 def print(self): 648 """Print function.""" 649 print(" " + "-" * 80) 650 s = Settings.__doc__.replace(" ", "") 651 s = s.replace(".. code-block:: python\n", "") 652 try: 653 from pygments import highlight 654 from pygments.lexers import Python3Lexer 655 from pygments.formatters import Terminal256Formatter 656 657 s = highlight(s, Python3Lexer(), Terminal256Formatter(style="zenburn")) 658 print(s, end="") 659 660 except ModuleNotFoundError: 661 print("\x1b[33;1m" + s + "\x1b[0m") 662 663 def __getitem__(self, key): 664 """Make the class work like a dictionary too""" 665 return getattr(self, key) 666 667 def __setitem__(self, key, value): 668 """Make the class work like a dictionary too""" 669 setattr(self, key, value) 670 671 672 def init_colab(self, enable_k3d=True): 673 """ 674 Initialize colab environment 675 """ 676 print("setting up colab environment (can take a minute) ...", end='') 677 678 res = os.system('which Xvfb') 679 if res: 680 os.system('apt-get install xvfb') 681 682 os.system('pip install pyvirtualdisplay') 683 684 from pyvirtualdisplay import Display 685 Display(visible=0).start() 686 687 if enable_k3d: 688 os.system('pip install k3d') 689 690 from google.colab import output 691 output.enable_custom_widget_manager() 692 693 if enable_k3d: 694 import k3d 695 try: 696 print("installing k3d...", end='') 697 os.system("jupyter nbextension install --py --user k3d") 698 os.system("jupyter nbextension enable --py --user k3d") 699 k3d.switch_to_text_protocol() 700 self.default_backend = 'k3d' 701 self.backend_autoclose = False 702 except: 703 print("(FAILED) ... ", end='') 704 705 print(" setup completed.") 706 707 708 def start_xvfb(self): 709 """ 710 Start xvfb. 711 712 Xvfb or X virtual framebuffer is a display server implementing 713 the X11 display server protocol. In contrast to other display servers, 714 Xvfb performs all graphical operations in virtual memory 715 without showing any screen output. 716 """ 717 print("starting xvfb (can take a minute) ...", end='') 718 res = os.system('which Xvfb') 719 if res: 720 os.system('apt-get install xvfb') 721 os.system('set -x') 722 os.system('export DISPLAY=:99.0') 723 os.system('Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &') 724 os.system('sleep 3') 725 os.system('set +x') 726 os.system('exec "$@"') 727 print(" xvfb started.")
General settings to modify the global behavior
Usage Example:
from vedo import settings, Cube settings.use_parallel_projection = True Cube().color('g').show().close()
List of available properties:
# Set a default for the font to be used for axes, comments etc.
default_font = 'Normografo' # check font options in shapes.Text
# Palette number when using an integer to choose a color
palette = 0
screenshot_transparent_background = False
screeshot_large_image = False # Sometimes setting this to True gives better results
# [DISABLED] Allow to continuously interact with scene during interactive() execution
allow_interaction = True
# Enable tracking pipeline functionality:
# allows to show a graph with the pipeline of action which let to a final object
# this is achieved by calling "myobj.pipeline.show()" (a new window will pop up)
self.enable_pipeline = True
# Set up default mouse and keyboard functionalities
enable_default_mouse_callbacks = True
enable_default_keyboard_callbacks = True
# If False, when multiple renderers are present do not render each one for separate
# but do it just once at the end (when interactive() is called)
immediate_rendering = True
# Show a gray frame margin in multirendering windows
renderer_frame_color = None
renderer_frame_alpha = 0.5
renderer_frame_width = 0.5
renderer_frame_padding = 0.0001
# In multirendering mode set the position of the horizontal of vertical splitting [0,1]
window_splitting_position = None
# Enable / disable color printing by printc()
enable_print_color = True
# Wrap lines in tubes
render_lines_as_tubes = False
# Smoothing options
point_smoothing = False
line_smoothing = False
polygon_smoothing = False
# Remove hidden lines when in wireframe mode
hidden_line_removal = False
# Turn on/off the automatic repositioning of lights as the camera moves.
light_follows_camera = False
two_sided_lighting = True
# Turn on/off rendering of translucent material with depth peeling technique.
use_depth_peeling = False
alpha_bit_planes = True # options only active if useDepthPeeling=True
multi_samples = 8 # force to not pick a framebuffer with a multisample buffer
max_number_of_peels= 4 # maximum number of rendering passes
occlusion_ratio = 0.0 # occlusion ratio, 0 = exact image.
# Turn on/off nvidia FXAA post-process anti-aliasing, if supported.
use_fxaa = False # either True or False
# By default, the depth buffer is reset for each renderer.
# If True, use the existing depth buffer
preserve_depth_buffer = False
# Use a polygon/edges offset to possibly resolve conflicts in rendering
use_polygon_offset = False
polygon_offset_factor = 0.1
polygon_offset_units = 0.1
# Interpolate scalars to render them smoothly
interpolate_scalars_before_mapping = True
# Set parallel projection On or Off (place camera to infinity, no perspective effects)
use_parallel_projection = False
# Set orientation type when reading TIFF files (volumes):
# TOPLEFT 1 (row 0 top, col 0 lhs) TOPRIGHT 2 (row 0 top, col 0 rhs)
# BOTRIGHT 3 (row 0 bottom, col 0 rhs) BOTLEFT 4 (row 0 bottom, col 0 lhs)
# LEFTTOP 5 (row 0 lhs, col 0 top) RIGHTTOP 6 (row 0 rhs, col 0 top)
# RIGHTBOT 7 (row 0 rhs, col 0 bottom) LEFTBOT 8 (row 0 lhs, col 0 bottom)
tiff_orientation_type = 1
# Annotated cube axis type nr. 5 options:
annotated_cube_color = (0.75, 0.75, 0.75)
annotated_cube_text_color = None # use default, otherwise specify a single color
annotated_cube_text_scale = 0.2
annotated_cube_texts = ["right","left ", "front","back ", " top ", "bttom"]
# Automatically close the Plotter instance after show() in jupyter sessions
# setting it to False will keep the current Plotter instance active
backend_autoclose = True
# k3d settings for jupyter notebooks
k3d_menu_visibility = True
k3d_plot_height = 512
k3d_antialias = True
k3d_lighting = 1.5
k3d_camera_autofit = True
k3d_grid_autofit= True
k3d_axes_color = "gray4"
k3d_axes_helper = 1.0 # size of the small triad of axes on the bottom right
k3d_point_shader= "mesh" # others are '3d', '3dSpecular', 'dot', 'flat'
k3d_line_shader = "thick" # others are 'flat', 'mesh'
Settings(level=0)
191 def __init__(self, level=0): 192 193 self._level = level 194 195 # Default font 196 self.default_font = "Normografo" 197 198 # Default backend engine in jupyter notebooks 199 self.default_backend = "vtk" 200 201 # enable tracking pipeline functionality 202 self.enable_pipeline = True 203 204 if any(["SPYDER" in name for name in os.environ]): 205 self.default_backend = "vtk" 206 else: 207 try: 208 get_ipython() 209 self.default_backend = "2d" 210 except NameError: 211 pass 212 213 # Palette number when using an integer to choose a color 214 self.palette = 0 215 216 self.remember_last_figure_format = False 217 218 self.screenshot_transparent_background = False 219 self.screeshot_large_image = False 220 221 # [DISABLED] Allow to continuously interact with scene during interactor.Start() execution 222 self.allow_interaction = True 223 224 # BUG in vtk9.0 (if true close works but sometimes vtk crashes, if false doesnt crash but cannot close) 225 # see plotter.py line 555 226 self.hack_call_screen_size = True 227 228 # Set up default mouse and keyboard functionalities 229 self.enable_default_mouse_callbacks = True 230 self.enable_default_keyboard_callbacks = True 231 232 # When multiple renderers are present do not render each one for separate. 233 # but do it just once at the end (when interactive() is called) 234 self.immediate_rendering = True 235 236 # Show a gray frame margin in multirendering windows 237 self.renderer_frame_color = None 238 self.renderer_frame_alpha = 0.5 239 self.renderer_frame_width = 0.5 240 self.renderer_frame_padding = 0.0001 241 242 # Wrap lines in tubes 243 self.render_lines_as_tubes = False 244 245 # Remove hidden lines when in wireframe mode 246 self.hidden_line_removal = False 247 248 # Smoothing options 249 self.point_smoothing = False 250 self.line_smoothing = False 251 self.polygon_smoothing = False 252 253 # For Structured and RectilinearGrid: show internal edges not only outline 254 self.visible_grid_edges = False 255 256 # Turn on/off the automatic repositioning of lights as the camera moves. 257 self.light_follows_camera = False 258 self.two_sided_lighting = True 259 260 # Turn on/off rendering of translucent material with depth peeling technique. 261 self.use_depth_peeling = False 262 self.multi_samples = 8 263 self.alpha_bit_planes = 1 264 self.max_number_of_peels = 4 265 self.occlusion_ratio = 0.1 266 267 # Turn on/off nvidia FXAA anti-aliasing, if supported. 268 self.use_fxaa = False # either True or False 269 270 # By default, the depth buffer is reset for each renderer. If true, use the existing depth buffer 271 self.preserve_depth_buffer = False 272 273 # Use a polygon/edges offset to possibly resolve conflicts in rendering 274 self.use_polygon_offset = True 275 self.polygon_offset_factor = 0.1 276 self.polygon_offset_units = 0.1 277 278 # Interpolate scalars to render them smoothly 279 self.interpolate_scalars_before_mapping = True 280 281 # Set parallel projection On or Off (place camera to infinity, no perspective effects) 282 self.use_parallel_projection = False 283 284 # In multirendering mode set the position of the horizontal of vertical splitting [0,1] 285 self.window_splitting_position = None 286 287 # Set orientation type when reading TIFF files (volumes): 288 # TOPLEFT 1 (row 0 top, col 0 lhs) TOPRIGHT 2 (row 0 top, col 0 rhs) 289 # BOTRIGHT 3 (row 0 bottom, col 0 rhs) BOTLEFT 4 (row 0 bottom, col 0 lhs) 290 # LEFTTOP 5 (row 0 lhs, col 0 top) RIGHTTOP 6 (row 0 rhs, col 0 top) 291 # RIGHTBOT 7 (row 0 rhs, col 0 bottom) LEFTBOT 8 (row 0 lhs, col 0 bottom) 292 self.tiff_orientation_type = 1 293 294 # AnnotatedCube axis (type 5) customization: 295 self.annotated_cube_color = (0.75, 0.75, 0.75) 296 self.annotated_cube_text_color = None # use default, otherwise specify a single color 297 self.annotated_cube_text_scale = 0.2 298 self.annotated_cube_texts = ["right", "left ", "front", "back ", " top ", "bttom"] 299 300 # enable / disable color printing 301 self.enable_print_color = True 302 303 #################################################################################### 304 # Automatically close the Plotter instance after show() in jupyter sessions, 305 # setting it to False will keep the current Plotter instance active 306 self.backend_autoclose = True 307 308 # k3d settings for jupyter notebooks 309 self.k3d_menu_visibility = True 310 self.k3d_plot_height = 512 311 self.k3d_antialias = True 312 self.k3d_lighting = 1.5 313 self.k3d_camera_autofit = True 314 self.k3d_grid_autofit= True 315 self.k3d_axes_color = "k4" 316 self.k3d_axes_helper = 1.0 # size of the small triad of axes on the bottom right 317 self.k3d_point_shader= "mesh" # others are '3d', '3dSpecular', 'dot', 'flat' 318 self.k3d_line_shader = "thick" # others are 'flat', 'mesh' 319 320 #################################################################################### 321 #################################################################################### 322 # mono # means that all letters occupy the same space slot horizontally 323 # hspacing # an horizontal stretching factor (affects both letters and words) 324 # lspacing # horizontal spacing inbetween letters (not words) 325 # islocal # is locally stored in /fonts, otherwise it's on vedo.embl.es/fonts 326 # 327 self.font_parameters = dict( 328 Normografo=dict( 329 mono=False, 330 fscale=0.75, 331 hspacing=1, 332 lspacing=0.2, 333 dotsep="~×", 334 islocal=True, 335 ), 336 Bongas=dict( 337 mono=False, 338 fscale=0.875, 339 hspacing=0.52, 340 lspacing=0.25, 341 dotsep="·", 342 islocal=True, 343 ), 344 Calco=dict( 345 mono=True, 346 fscale=0.8, 347 hspacing=1, 348 lspacing=0.1, 349 dotsep="×", 350 islocal=True, 351 ), 352 Comae=dict( 353 mono=False, 354 fscale=0.75, 355 lspacing=0.2, 356 hspacing=1, 357 dotsep="~×", 358 islocal=True, 359 ), 360 ComicMono=dict( 361 mono=True, 362 fscale=0.8, 363 hspacing=1, 364 lspacing=0.1, 365 dotsep="x", 366 islocal=False, 367 ), 368 Edo=dict( 369 mono=False, 370 fscale=0.75, 371 hspacing=1, 372 lspacing=0.2, 373 dotsep="~x ", 374 islocal=False, 375 ), 376 FiraMonoMedium=dict( 377 mono=True, 378 fscale=0.8, 379 hspacing=1, 380 lspacing=0.1, 381 dotsep="×", 382 islocal=False, 383 ), 384 FiraMonoBold=dict( 385 mono=True, 386 fscale=0.8, 387 hspacing=1, 388 lspacing=0.1, 389 dotsep="×", 390 islocal=False, 391 ), 392 Glasgo=dict( 393 mono=True, 394 fscale=0.75, 395 lspacing=0.1, 396 hspacing=1, 397 dotsep="~×", 398 islocal=True, 399 ), 400 Kanopus=dict( 401 mono=False, 402 fscale=0.75, 403 lspacing=0.15, 404 hspacing=0.75, 405 dotsep="~×", 406 islocal=True, 407 ), 408 LogoType=dict( 409 mono=False, 410 fscale=0.75, 411 hspacing=1, 412 lspacing=0.2, 413 dotsep="~×", 414 islocal=False, 415 ), 416 Quikhand=dict( 417 mono=False, 418 fscale=0.8, 419 hspacing=0.6, 420 lspacing=0.15, 421 dotsep="~~×~", 422 islocal=True, 423 ), 424 SmartCouric=dict( 425 mono=True, 426 fscale=0.8, 427 hspacing=1.05, 428 lspacing=0.1, 429 dotsep="×", 430 islocal=True, 431 ), 432 Spears=dict( 433 mono=False, 434 fscale=0.8, 435 hspacing=0.5, 436 lspacing=0.2, 437 dotsep="~×", 438 islocal=False, 439 ), 440 Theemim=dict( 441 mono=False, 442 fscale=0.825, 443 hspacing=0.52, 444 lspacing=0.3, 445 dotsep="~~×", 446 islocal=True, 447 ), 448 VictorMono=dict( 449 mono=True, 450 fscale=0.725, 451 hspacing=1, 452 lspacing=0.1, 453 dotsep="×", 454 islocal=True, 455 ), 456 Justino1=dict( 457 mono=True, 458 fscale=0.725, 459 hspacing=1, 460 lspacing=0.1, 461 dotsep="×", 462 islocal=False, 463 ), 464 Justino2=dict( 465 mono=True, 466 fscale=0.725, 467 hspacing=1, 468 lspacing=0.1, 469 dotsep="×", 470 islocal=False, 471 ), 472 Justino3=dict( 473 mono=True, 474 fscale=0.725, 475 hspacing=1, 476 lspacing=0.1, 477 dotsep="×", 478 islocal=False, 479 ), 480 Calibri=dict( 481 mono=False, 482 fscale=0.75, 483 hspacing=1, 484 lspacing=0.2, 485 dotsep="~×", 486 islocal=False, 487 ), 488 Capsmall=dict( 489 mono=False, 490 fscale=0.8, 491 hspacing=0.75, 492 lspacing=0.15, 493 dotsep="~×", 494 islocal=False, 495 ), 496 Cartoons123=dict( 497 mono=False, 498 fscale=0.8, 499 hspacing=0.75, 500 lspacing=0.15, 501 dotsep="x", 502 islocal=False, 503 ), 504 Vega=dict( 505 mono=False, 506 fscale=0.8, 507 hspacing=0.75, 508 lspacing=0.15, 509 dotsep="×", 510 islocal=False, 511 ), 512 Meson=dict( 513 mono=False, 514 fscale=0.8, 515 hspacing=0.9, 516 lspacing=0.225, 517 dotsep="~×", 518 islocal=False, 519 ), 520 Komika=dict( 521 mono=False, 522 fscale=0.7, 523 hspacing=0.75, 524 lspacing=0.225, 525 dotsep="~×", 526 islocal=False, 527 ), 528 Vogue=dict( 529 mono=False, 530 fscale=0.7, 531 hspacing=0.75, 532 lspacing=0.225, 533 dotsep="~x", 534 islocal=False, 535 ), 536 Brachium=dict( 537 mono=True, 538 fscale=0.8, 539 hspacing=1, 540 lspacing=0.1, 541 dotsep="x", 542 islocal=False, 543 ), 544 Dalim=dict( 545 mono=False, 546 fscale=0.75, 547 lspacing=0.2, 548 hspacing=1, 549 dotsep="~×", 550 islocal=False, 551 ), 552 Miro=dict( 553 mono=False, 554 fscale=0.75, 555 lspacing=0.2, 556 hspacing=1, 557 dotsep="~×", 558 islocal=False, 559 ), 560 Ubuntu=dict( 561 mono=False, 562 fscale=0.75, 563 lspacing=0.2, 564 hspacing=1, 565 dotsep="~×", 566 islocal=False, 567 ), 568 Mizar=dict( 569 mono=False, 570 fscale=0.75, 571 lspacing=0.2, 572 hspacing=0.75, 573 dotsep="~×", 574 islocal=False, 575 ), 576 LiberationSans=dict( 577 mono=False, 578 fscale=0.75, 579 lspacing=0.2, 580 hspacing=1, 581 dotsep="~×", 582 islocal=False, 583 ), 584 DejavuSansMono=dict( 585 mono=True, 586 fscale=0.725, 587 hspacing=1, 588 lspacing=0.1, 589 dotsep="~×", 590 islocal=False, 591 ), 592 SunflowerHighway=dict( 593 mono=False, 594 fscale=0.75, 595 lspacing=0.2, 596 hspacing=1, 597 dotsep="~×", 598 islocal=False, 599 ), 600 Swansea=dict( 601 mono=False, 602 fscale=0.75, 603 lspacing=0.2, 604 hspacing=1, 605 dotsep="~×", 606 islocal=False, 607 ), 608 Housekeeper=dict( # support chinese glyphs 609 mono=False, 610 fscale=0.75, 611 hspacing=1, 612 lspacing=0.2, 613 dotsep="~×", 614 islocal=False, 615 ), 616 Wananti=dict( # support chinese glyphs 617 mono=False, 618 fscale=0.75, 619 hspacing=1, 620 lspacing=0.2, 621 dotsep="~x", 622 islocal=False, 623 ), 624 AnimeAce=dict( 625 mono=False, 626 fscale=0.75, 627 hspacing=1, 628 lspacing=0.2, 629 dotsep="~x", 630 islocal=False, 631 ), 632 AnimeAceBold=dict( 633 mono=False, 634 fscale=0.75, 635 hspacing=1, 636 lspacing=0.2, 637 dotsep="~x", 638 islocal=False, 639 ), 640 )
def
print(self):
647 def print(self): 648 """Print function.""" 649 print(" " + "-" * 80) 650 s = Settings.__doc__.replace(" ", "") 651 s = s.replace(".. code-block:: python\n", "") 652 try: 653 from pygments import highlight 654 from pygments.lexers import Python3Lexer 655 from pygments.formatters import Terminal256Formatter 656 657 s = highlight(s, Python3Lexer(), Terminal256Formatter(style="zenburn")) 658 print(s, end="") 659 660 except ModuleNotFoundError: 661 print("\x1b[33;1m" + s + "\x1b[0m")
Print function.
def
init_colab(self, enable_k3d=True):
672 def init_colab(self, enable_k3d=True): 673 """ 674 Initialize colab environment 675 """ 676 print("setting up colab environment (can take a minute) ...", end='') 677 678 res = os.system('which Xvfb') 679 if res: 680 os.system('apt-get install xvfb') 681 682 os.system('pip install pyvirtualdisplay') 683 684 from pyvirtualdisplay import Display 685 Display(visible=0).start() 686 687 if enable_k3d: 688 os.system('pip install k3d') 689 690 from google.colab import output 691 output.enable_custom_widget_manager() 692 693 if enable_k3d: 694 import k3d 695 try: 696 print("installing k3d...", end='') 697 os.system("jupyter nbextension install --py --user k3d") 698 os.system("jupyter nbextension enable --py --user k3d") 699 k3d.switch_to_text_protocol() 700 self.default_backend = 'k3d' 701 self.backend_autoclose = False 702 except: 703 print("(FAILED) ... ", end='') 704 705 print(" setup completed.")
Initialize colab environment
def
start_xvfb(self):
708 def start_xvfb(self): 709 """ 710 Start xvfb. 711 712 Xvfb or X virtual framebuffer is a display server implementing 713 the X11 display server protocol. In contrast to other display servers, 714 Xvfb performs all graphical operations in virtual memory 715 without showing any screen output. 716 """ 717 print("starting xvfb (can take a minute) ...", end='') 718 res = os.system('which Xvfb') 719 if res: 720 os.system('apt-get install xvfb') 721 os.system('set -x') 722 os.system('export DISPLAY=:99.0') 723 os.system('Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &') 724 os.system('sleep 3') 725 os.system('set +x') 726 os.system('exec "$@"') 727 print(" xvfb started.")
Start xvfb.
Xvfb or X virtual framebuffer is a display server implementing the X11 display server protocol. In contrast to other display servers, Xvfb performs all graphical operations in virtual memory without showing any screen output.