Example #1
0
def display(shp, color=None, deep=True, scene=None):
    if scene is None:
        scene = default_scene()

    if default_scene() is None:
        # TODO: Add another stubs
        if isinstance(shp, evalcache.LazyObject):
            return stub_controller(shp.unlazy())
        else:
            return stub_controller(shp)

    if isinstance(shp, evalcache.LazyObject):
        shp = evalcache.unlazy(shp)

    if isinstance(shp, list) or isinstance(shp, tuple):
        lst = []
        for s in shp:
            lst.append(display(s, color=color, deep=deep, scene=scene))

        return lst

    if isinstance(shp, zencad.assemble.unit):
        return shp.bind_scene(scene, color=color, deep=deep)

    if color is None:
        color = default_color

    if scene is None:
        return pyservoce.interactive_object(shp, color)

    return scene.add(shp, color)
Example #2
0
def engineroom_scene():
    scene = Scene()
    disp(scene=scene, shp=top_assemble_unit())  #.up(bottom_z+top_z))
    scene.add(unlazy(control_body().up(bottom_z + top_z + control_z)),
              Color(1, 0, 0))
    disp(scene=scene, shp=bottom_full_scene_unit())
    return scene
Example #3
0
def display(shp, color=Color(0.6, 0.6, 0.8), deep=True):
    if isinstance(shp, evalcache.LazyObject):
        shp = evalcache.unlazy(shp)

    if isinstance(shp, zencad.assemble.unit):
        return shp.bind_scene(default_scene, color=color, deep=deep)

    return default_scene.add(shp, color)
Example #4
0
def bottom_full_scene_unit():
    u = zencad.assemble.unit()

    u.add(unlazy(bottom_model()), Color(0.6, 0.8, 0.6))
    u.add(unlazy(accumholder_model().up(bottom_wall_thikness)), Color(1, 1, 1))
    u.add(unlazy(m_wheel.quadro()), Color(1, 1, 1))
    u.add(unlazy(usb_charger_position(usb_charger())), Color(1, 1, 1))
    u.add(
        unlazy(
            usb_charger_position(usb_charger_protect().up(usb_charger_upper))),
        Color(1, 0, 0))
    u.add(unlazy(voltregul.position_0(voltregul.plate)), Color(1, 1, 1))
    u.add(unlazy(voltregul.position_1(voltregul.plate)), Color(1, 1, 1))

    return u
Example #5
0
def display(shp, color=Color(0.6, 0.6, 0.8)):
    if isinstance(shp, evalcache.LazyObject):
        return default_scene.add(evalcache.unlazy(shp), color)
    else:
        return default_scene.add(shp, color)
Example #6
0
#!/usr/bin/env python3

import sys

import zencad
import zencad.gui.viewadaptor
import evalcache

from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *

scn = zencad.Scene()
scn.add(evalcache.unlazy(zencad.box(10)))

app = QApplication(sys.argv[:1])
zencad.opengl.init_opengl()
widget = zencad.gui.viewadaptor.DisplayWidget(scn)

widget.show()
app.exec()
Example #7
0
def unlazy_if_need(obj):
    if isinstance(obj, LazyObject):
        return evalcache.unlazy(obj)
    else:
        return obj
Example #8
0

def sncb(root, obj):
    arrs = evalcache.lazy.tree_needeval(root)
    print("toload:{} toeval:{}".format(len(arrs.toload), len(arrs.toeval)))


def ftcb(root):
    pass
    #print("ftcb")


def fncb(root, obj):
    arrs = evalcache.lazy.tree_needeval(root)
    print("toload:{} toeval:{}".format(len(arrs.toload), len(arrs.toeval)))
    #print("fncb")


lazy.set_start_tree_evaluation_callback(stcb)
lazy.set_start_node_evaluation_callback(sncb)
lazy.set_fini_tree_evaluation_callback(ftcb)
lazy.set_fini_node_evaluation_callback(fncb)

a = lazy(1)
b = lazy(2)
c = lazy(3)

d = a + b + c

evalcache.unlazy(d)