Exemplo n.º 1
0
def main(argv):

    
    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        720.0,
        MASK_2D #,
        #osgWidget.WindowManager.WM_USE_RENDERBINS
    )

    notebook1 = Notebook("notebook1")
    notebook2 = Notebook("notebook2")

    notebook2.setOrigin(100.0, 100.0)

    notebook1.attachMoveCallback()
    notebook2.attachMoveCallback()

    wm.addChild(notebook1)
    wm.addChild(notebook2)

    return osgWidget.createExample(viewer, wm)
Exemplo n.º 2
0
def main(argv):

    
    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D,
        osgWidget.WindowManager.WM_PICK_DEBUG
    )

    menu = osgWidget.Box("menu", osgWidget.Box.HORIZONTAL)

    menu.addWidget(ColorLabelMenu("Pick me not "))
    menu.addWidget(ColorLabelMenu("No, wait, pick me not "))
    menu.addWidget(ColorLabelMenu("Don't pick them..."))
    menu.addWidget(ColorLabelMenu("Grarar not ? not "))

    wm.addChild(menu)
    
    menu.getBackground().setColor(1.0, 1.0, 1.0, 0.0)
    menu.resizePercent(100.0)

    model = osgDB.readNodeFile("osgcool.osgt")

    model.setNodeMask(MASK_3D)

    return osgWidget.createExample(viewer, wm, model)
Exemplo n.º 3
0
def main(argv):

    
    theme = "osgWidget/theme-1.png"
    if argc > 1 :
        theme = str(argv[1])

    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D,
        osgWidget.WindowManager.WM_PICK_DEBUG
    )

    frame = createErrorMessage(theme,
                                          "osgWidget/theme-8-shadow.png",
                                          "Error - Critical",
                                          LABEL1,
                                          "Ok",
                                          "fonts/Vera.ttf",
                                          20)
    # Add everything to the WindowManager.
    wm.addChild(frame)
    frame.resizeAdd(30, 30)

    alpha = AlphaSetterVisitor(.8)
    frame.accept(alpha)
    return osgWidget.createExample(viewer, wm, osgDB.readNodeFile("cow.osgt"))
Exemplo n.º 4
0
def main(argv):    
    viewer = osgViewer.Viewer()
    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D,
        osgWidget.WindowManager.WM_PICK_DEBUG
    )
    box = osgWidget.Box("vbox", osgWidget.Box.VERTICAL)
    input_ = osgWidget.Input("input", "", 50)
    input_.setFont("fonts/VeraMono.ttf")
    input_.setFontColor(0.0, 0.0, 0.0, 1.0)
    input_.setFontSize(15)
    input_.setYOffset(input_.calculateBestYOffset("y"))
    input_.setSize(400.0, input_.getText().getCharacterHeight())
    box.addWidget(input_)
    box.setOrigin(200.0, 200.0)
    wm.addChild(box)
    viewer.setUpViewInWindow(
        50,
        50,
        int(wm.getWidth()),
        int(wm.getHeight())
    )
    camera = wm.createParentOrthoCamera()
    viewer.addEventHandler(osgWidget.MouseHandler(wm))
    viewer.addEventHandler(osgWidget.KeyboardHandler(wm))
    viewer.addEventHandler(osgWidget.ResizeHandler(wm, camera))
    viewer.addEventHandler(osgWidget.CameraSwitchHandler(wm, camera))
    viewer.addEventHandler(osgViewer.WindowSizeHandler())
    wm.resizeAllWindows()
    viewer.setSceneData(camera)
    return viewer.run()
def doApp(viewer, node, width, height):

    
    wm = osgWidget.WindowManager(viewer, width, height, 0x12)

    wm.addChild(node)

    return osgWidget.createExample(viewer, wm)
def main(argv):

    
    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D,
        osgWidget.WindowManager.WM_PICK_DEBUG
        #osgWidget.WindowManager.WM_NO_INVERT_Y
    )
    
    frame = osgWidget.Frame.createSimpleFrameFromTheme(
        "frame",
        osgDB.readImageFile("osgWidget/theme.png"),
        40.0,
        40.0,
	osgWidget.Frame.FRAME_ALL
    )

    frame.getBackground().setColor(0.0, 0.0, 0.0, 0.0)

    # This is our Transformers box. :)
    box = osgWidget.Box("images", osgWidget.Box.VERTICAL)
    img1 = osgWidget.Widget("im1", 512.0, 512.0)
    img2 = osgWidget.Widget("im2", 512.0, 512.0)
    img3 = osgWidget.Widget("im3", 512.0, 512.0)
    img4 = osgWidget.Widget("im4", 512.0, 512.0)

    img1.setImage("osgWidget/scrolled1.jpg", True)
    img2.setImage("osgWidget/scrolled2.jpg", True)
    img3.setImage("osgWidget/scrolled3.jpg", True)
    img4.setImage("osgWidget/scrolled4.jpg", True)

    img1.setMinimumSize(10.0, 10.0)
    img2.setMinimumSize(10.0, 10.0)
    img3.setMinimumSize(10.0, 10.0)
    img4.setMinimumSize(10.0, 10.0)

    box.addWidget(img1)
    box.addWidget(img2)
    box.addWidget(img3)
    box.addWidget(img4)
    box.setEventMask(osgWidget.EVENT_NONE)

    #frame.getEmbeddedWindow().setWindow(box)
    frame.setWindow(box)
    frame.getEmbeddedWindow().setColor(1.0, 1.0, 1.0, 1.0)
    frame.resize(300.0, 300.0)
    frame.addCallback(osgWidget.Callback(scrollWindow, osgWidget.EVENT_MOUSE_SCROLL))
    frame.addCallback(osgWidget.Callback(changeTheme, osgWidget.EVENT_KEY_DOWN))

    wm.addChild(frame)

    return osgWidget.createExample(viewer, wm)
Exemplo n.º 7
0
def main(argv):

    

    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D,
        osgWidget.WindowManager.WM_PICK_DEBUG
    )

    fontSize = 20
    font = "fonts/arial.ttf"
    buttonTheme = "osgWidget/theme-8-shadow.png"
    borderTheme = "osgWidget/theme-8.png"

    message = MessageBox()
    message.create(borderTheme, 
                   buttonTheme,
                   "Error - Critical",
                   LABEL1,
                   "Quit",
                   font,
                   fontSize)

    alpha = AlphaSetterVisitor(.8)
    message.getWindow().accept(alpha)

    wm.addChild(message.getWindow())

    # center
    w = wm.getWidth()
    h = wm.getHeight()
    ww = message.getWindow().getWidth()
    hw = message.getWindow().getHeight()
    ox = (w - ww) / 2
    oy = (h - hw) / 2
    message.getWindow().setPosition(osgWidget.Point(
        osg.round(ox), osg.round(oy), message.getWindow().getPosition()[2])
    )
#    frame.resizeAdd(30, 30)

#    alpha = AlphaSetterVisitor(.8)
#    frame.accept(alpha)
    return osgWidget.createExample(viewer, wm) #osgDB.readNodeFile("cow.osgt"))
def main(argv):

    
    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D
    )
    
    buttons = AddRemove()

    wm.addChild(buttons)

    createExample = return(viewer, wm)
def main(argv):

    
    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(
        viewer,
        WINDOW_WIDTH,
        WINDOW_HEIGHT,
        MASK_2D
        )

    menu = osgWidget.Box("menu", osgWidget.Box.HORIZONTAL)

    menu.addWidget(ColorLabelMenu("Choose EaseMotion"))
    menu.getBackground().setColor(1.0, 1.0, 1.0, 1.0)
    menu.setPosition(15.0, 15.0, 0.0)

    wm.addChild(menu)

    group = osg.Group()
    geode = osg.Geode()
    mt = osg.MatrixTransform()

    geode.addDrawable(osg.ShapeDrawable(osg.Sphere(osg.Vec3(), 4.0)))

    EASE_MOTION_SAMPLER = EaseMotionSampler(osg.Vec3(50.0, 0.0, 0.0))
    EASE_MOTION_GEODE   = osg.Geode()

    mt.addChild(geode)
    mt.setUpdateCallback(EASE_MOTION_SAMPLER)
    mt.setNodeMask(MASK_3D)

    viewer.setCameraManipulator(osgGA.TrackballManipulator())
    viewer.getCameraManipulator().setHomePosition(
        osg.Vec3d(0.0, 0.0, 200.0),
        osg.Vec3d(20.0, 0.0, 0.0),
        osg.Vec3d(0.0, 1.0, 0.0)
        )
    viewer.home()

    group.addChild(mt)
    group.addChild(EASE_MOTION_GEODE)

    return osgWidget.createExample(viewer, wm, group)
Exemplo n.º 10
0
def main(argv):
    viewer = osgViewer.Viewer()
    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D,
        osgWidget.WindowManager.WM_PICK_DEBUG
    )
    table = osgWidget.Table("table", 3, 3)
    # Here we create our "cells" manually, though it will often be convenient to
    # do so algorithmically. Also, notice how we set the text name of each widget to
    # correspond with it's "index" in the table. This is merely a convenience, which
    # we use later...
    table.addWidget(osgWidget.Widget("0, 0", 100.0, 25.0), 0, 0)
    table.addWidget(osgWidget.Widget("0, 1", 100.0, 25.0), 0, 1)
    table.addWidget(osgWidget.Widget("0, 2", 100.0, 75.0), 0, 2)
    table.addWidget(osgWidget.Widget("1, 0", 200.0, 45.0), 1, 0)
    table.addWidget(osgWidget.Widget("1, 1", 200.0, 45.0), 1, 1)
    table.addWidget(osgWidget.Widget("1, 2", 200.0, 45.0), 1, 2)
    table.addWidget(osgWidget.Widget("2, 0", 300.0, 65.0), 2, 0)
    table.addWidget(osgWidget.Widget("2, 1", 300.0, 65.0), 2, 1)
    table.addWidget(osgWidget.Widget("2, 2", 300.0, 65.0), 2, 2)
    table.getBackground().setColor(0.0, 0.0, 0.5, 1.0)
    table.attachMoveCallback()
    # Use a hackish method of setting the spacing for all Widgets.
    for i in table:
        # for(osgWidget.Table.Iterator i = table.begin() i != table.end() i++)
        i.setPadding(1.0)
    # Now we fetch the very first 0, 0 Widget in the table using an awkward method.
    # This is merely one way to fetch a Widget from a Window, there are many others.
    # The osgWidget.Window.getByName interface will be very handy in scripting languages
    # where users will want to retrieve handles to existing Windows using a useful
    # textual name, such as "MainGUIParent" or something.
    table.getByName("0, 0").setAlignHorizontal(osgWidget.Widget.HA_LEFT)
    table.getByName("0, 0").setAlignVertical(osgWidget.Widget.VA_BOTTOM)
    table.getByName("0, 0").setPadLeft(50.0)
    table.getByName("0, 0").setPadTop(3.0)
    # Change the colors a bit to differentiate this row from the others.
    table.getByName("2, 0").setColor(1.0, 0.0, 0.0, 1.0, osgWidget.Widget.LOWER_LEFT)
    table.getByName("2, 1").setColor(1.0, 0.0, 0.0, 0.5)
    table.getByName("2, 2").setColor(1.0, 0.0, 0.0, 0.5)
    wm.addChild(table)
    createExample = return(viewer, wm)
Exemplo n.º 11
0
def main(argv):

    
    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D
    )

    box = osgWidget.Box("box", osgWidget.Box.VERTICAL)

    widget1 = osgWidget.Widget("w1", 200.0, 200.0)
    widget2 = osgWidget.Widget("w2", 100.0, 100.0)
    widget3 = osgWidget.Widget("w3", 0.0, 0.0)
    # CustomStyled*      cs      = CustomStyled()

    # Yep.
    wm.getStyleManager().addStyle(osgWidget.Style("widget.style1", STYLE1))
    wm.getStyleManager().addStyle(osgWidget.Style("widget.style2", STYLE2))
    wm.getStyleManager().addStyle(osgWidget.Style("spacer", STYLE3))
    wm.getStyleManager().addStyle(osgWidget.Style("window", STYLE4))
    # wm.getStyleManager().addStyle(CustomStyle("widget", ""))

    widget1.setStyle("widget.style1")
    widget2.setStyle("widget.style2")
    widget3.setStyle("spacer")

    box.setStyle("window")

    box.addWidget(widget1)
    box.addWidget(widget2)
    box.addWidget(widget3)

    wm.addChild(box)

    # box.resizePercent(0.0, 100.0)

    return osgWidget.createExample(viewer, wm)
Exemplo n.º 12
0
def main(argv):

    
    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D,
        osgWidget.WindowManager.WM_PICK_DEBUG
    )
    
    wm.setPointerFocusMode(osgWidget.WindowManager.PFM_SLOPPY)

    box1 = createBox("HBOX", osgWidget.Box.HORIZONTAL)
    box2 = createBox("VBOX", osgWidget.Box.VERTICAL)
    box3 = createBox("HBOX2", osgWidget.Box.HORIZONTAL)
    box4 = createBox("VBOX2", osgWidget.Box.VERTICAL)

    box1.getBackground().setColor(1.0, 0.0, 0.0, 0.8)
    box1.attachMoveCallback()

    box2.getBackground().setColor(0.0, 1.0, 0.0, 0.8)
    box2.attachMoveCallback()

    box3.getBackground().setColor(0.0, 0.0, 1.0, 0.8)
    box3.attachMoveCallback()

    wm.addChild(box1)
    wm.addChild(box2)
    wm.addChild(box3)
    wm.addChild(box4)

    box4.hide()

    model = osgDB.readNodeFile("spaceship.osgt")

    model.setNodeMask(MASK_3D)

    return osgWidget.createExample(viewer, wm, model)
Exemplo n.º 13
0
def main(argv):

    
    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D,
        osgWidget.WindowManager.WM_PICK_DEBUG
    )
    
    canvas = osgWidget.Canvas("canvas")
    pOutline = osgWidget.Widget("pOutline", 512.0, 64.0)
    pMeter = osgWidget.Widget("pMeter", 0.0, 64.0)
    pLabel = osgWidget.Label("pLabel", "0% Done")

    pOutline.setImage("osgWidget/progress-outline.png", True)
    pOutline.setLayer(osgWidget.Widget.LAYER_MIDDLE, 2)
    
    pMeter.setImage("osgWidget/progress-meter.png")
    pMeter.setColor(0.7, 0.1, 0.1, 0.7)
    pMeter.setLayer(osgWidget.Widget.LAYER_MIDDLE, 1)

    pLabel.setFont("fonts/VeraMono.ttf")
    pLabel.setFontSize(20)
    pLabel.setFontColor(1.0, 1.0, 1.0, 1.0)
    pLabel.setSize(512.0, 64.0)
    pLabel.setLayer(osgWidget.Widget.LAYER_MIDDLE, 3)

    canvas.setOrigin(300.0, 300.0)
    canvas.addWidget(pMeter, 0.0, 0.0)
    canvas.addWidget(pOutline, 0.0, 0.0)
    canvas.addWidget(pLabel, 0.0, 0.0)
    canvas.getBackground().setColor(0.0, 0.0, 0.0, 0.0)
    canvas.setUpdateCallback(UpdateProgressNode())

    wm.addChild(canvas)

    return osgWidget.createExample(viewer, wm, osgDB.readNodeFile("cow.osgt"))
Exemplo n.º 14
0
def main(argv):

    
    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D,
        osgWidget.WindowManager.WM_PICK_DEBUG
    )
    
    table = osgWidget.Table("table", 3, 3)

    # Here we create our "cells" manually, though it will often be convenient to
    # do so algorithmically. Also, notice how we set the text name of each widget to
    # correspond with it's "index" in the table. This is merely a convenience, which
    # we use later...
    table.addWidget(osgWidget.Widget("0, 0", 100.0, 25.0), 0, 0)
    table.addWidget(osgWidget.Widget("0, 1", 100.0, 25.0), 0, 1)
    table.addWidget(osgWidget.Widget("0, 2", 100.0, 75.0), 0, 2)
    
    table.addWidget(osgWidget.Widget("1, 0", 200.0, 45.0), 1, 0)
    table.addWidget(osgWidget.Widget("1, 1", 200.0, 45.0), 1, 1)
    table.addWidget(osgWidget.Widget("1, 2", 200.0, 45.0), 1, 2)
    
    table.addWidget(osgWidget.Widget("2, 0", 300.0, 65.0), 2, 0)
    table.addWidget(osgWidget.Widget("2, 1", 300.0, 65.0), 2, 1)
    table.addWidget(osgWidget.Widget("2, 2", 300.0, 65.0), 2, 2)

    table.getBackground().setColor(0.0, 0.0, 0.5, 1.0)
    table.attachMoveCallback()

    # Use a hackish method of setting the spacing for all Widgets.
    for(osgWidget.Table.Iterator i = table.begin() i  not = table.end() i++)
        i.setPadding(1.0)
Exemplo n.º 15
0
def main(argv):

    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(viewer, 1280.0, 1024.0, MASK_2D)

    canvas = osgWidget.Canvas("canvas")

    canvas.attachMoveCallback()
    canvas.attachScaleCallback()

    canvas.addWidget(createWidget("w1", 0.2, osgWidget.Widget.LAYER_LOW), 0.0,
                     0.0)

    canvas.addWidget(createWidget("w2", 0.4, osgWidget.Widget.LAYER_MIDDLE),
                     200.0, 0.0)

    canvas.addWidget(createWidget("w3", 0.6, osgWidget.Widget.LAYER_HIGH),
                     400.0, 0.0)

    wm.addChild(canvas)

    program = osg.Program()

    program.addShader(
        osg.Shader.readShaderFile(
            osg.Shader.VERTEX,
            osgDB.findDataFile("osgWidget/osgwidgetshader-vert.glsl")))

    program.addShader(
        osg.Shader.readShaderFile(
            osg.Shader.FRAGMENT,
            osgDB.findDataFile("osgWidget/osgwidgetshader-frag.glsl")))

    canvas.getGeode().getOrCreateStateSet().setAttribute(program)

    return osgWidget.createExample(viewer, wm)
Exemplo n.º 16
0
        win = dynamic_cast<osgWidget.Window*>(node)

        w = win.getWidth()
        wmw = win.getWindowManager().getWidth()

        win.setX((wmw - w) + (val * w))
        win.update()



# This is a temporary hack to "prevent" dragging on Widgets and Windows.
bool eatDrag(osgWidget.Event) 
    return True

AnimtkViewerGUI.AnimtkViewerGUI(osgViewer.View* view, float w, float h, unsigned int mask):
    osgWidget.WindowManager(view, w, h, mask, 0) 
    _createButtonBox()
    _createLabelBox()
    _createListBox()

    _labelBox.setAnchorHorizontal(osgWidget.Window.HA_LEFT)
    _labelBox.setY(74.0)
    _labelBox.setVisibilityMode(osgWidget.Window.VM_ENTIRE)

    _listBox.setOrigin(getWidth(), 74.0)

    addChild(_buttonBox)
    addChild(_labelBox)
    addChild(_listBox)

    resizeAllWindows()
Exemplo n.º 17
0
def main(argv):

    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(viewer, 1280.0, 1024.0, MASK_2D,
                                 osgWidget.WindowManager.WM_PICK_DEBUG)

    frame = osgWidget.Frame.createSimpleFrame("frame", 32.0, 32.0, 300.0,
                                              300.0)

    frame2 = osgWidget.Frame.createSimpleFrameFromTheme(
        "frameTheme", osgDB.readImageFile("osgWidget/theme-1.png"), 300.0,
        300.0, osgWidget.Frame.FRAME_ALL)
    frame2.setPosition(300, 100, 0)
    frame2.getBackground().setColor(1.0, 1.0, 1.0, 0.0)

    frame22 = osgWidget.Frame.createSimpleFrameFromTheme(
        "frameTheme", osgDB.readImageFile("osgWidget/theme-2.png"), 300.0,
        300.0, osgWidget.Frame.FRAME_ALL)
    frame22.setPosition(300, 100, 0)
    frame22.getBackground().setColor(1.0, 1.0, 1.0, 0.0)

    frame3 = osgWidget.Frame.createSimpleFrameFromTheme(
        "frameTheme", osgDB.readImageFile("osgWidget/theme-2.png"), 300.0,
        300.0, osgWidget.Frame.FRAME_ALL)
    frame3.setPosition(300, 100, 0)
    frame3.getBackground().setColor(0.0, 0.0, 0.0, 1.0)

    table = osgWidget.Table("table", 2, 2)
    bottom = osgWidget.Box("panel", osgWidget.Box.HORIZONTAL)

    table.addWidget(osgWidget.Widget("red", 300.0, 300.0), 0, 0)
    table.addWidget(osgWidget.Widget("white", 300.0, 300.0), 0, 1)
    table.addWidget(osgWidget.Widget("yellow", 300.0, 300.0), 1, 0)
    table.addWidget(osgWidget.Widget("purple", 300.0, 300.0), 1, 1)
    table.getByRowCol(0, 0).setColor(1.0, 0.0, 0.0, 1.0)
    table.getByRowCol(0, 1).setColor(1.0, 1.0, 1.0, 1.0)
    table.getByRowCol(1, 0).setColor(1.0, 1.0, 0.0, 1.0)
    table.getByRowCol(1, 1).setColor(1.0, 0.0, 1.0, 1.0)
    table.getByRowCol(0, 0).setMinimumSize(100.0, 100.0)
    table.getByRowCol(0, 1).setMinimumSize(100.0, 100.0)
    table.getByRowCol(1, 0).setMinimumSize(100.0, 100.0)
    table.getByRowCol(1, 1).setMinimumSize(100.0, 100.0)

    frame.setWindow(table)

    # Give frame some nice textures.
    # TODO: This has to be done after setWindow() wtf?
    frame.getBackground().setColor(0.0, 0.0, 0.0, 0.0)

    l = frame.getBorder(osgWidget.Frame.BORDER_LEFT)
    r = frame.getBorder(osgWidget.Frame.BORDER_RIGHT)
    t = frame.getBorder(osgWidget.Frame.BORDER_TOP)
    b = frame.getBorder(osgWidget.Frame.BORDER_BOTTOM)

    l.setImage("osgWidget/border-left.tga", True)
    r.setImage("osgWidget/border-right.tga", True)
    t.setImage("osgWidget/border-top.tga", True)
    b.setImage("osgWidget/border-bottom.tga", True)

    l.setTexCoordWrapVertical()
    r.setTexCoordWrapVertical()
    t.setTexCoordWrapHorizontal()
    b.setTexCoordWrapHorizontal()

    # Create the bottom, XArt panel.
    left = osgWidget.Widget("left", 512.0, 256.0)
    center = osgWidget.Widget("center", 256.0, 256.0)
    right = osgWidget.Widget("right", 512.0, 256.0)

    left.setImage("osgWidget/panel-left.tga", True)
    center.setImage("osgWidget/panel-center.tga", True)
    right.setImage("osgWidget/panel-right.tga", True)

    center.setTexCoordWrapHorizontal()

    bottom.addWidget(left)
    bottom.addWidget(center)
    bottom.addWidget(right)
    bottom.getBackground().setColor(0.0, 0.0, 0.0, 0.0)
    bottom.setOrigin(0.0, 1024.0 - 256.0)

    # Add everything to the WindowManager.
    wm.addChild(frame)
    wm.addChild(frame2)
    wm.addChild(frame22)
    wm.addChild(frame3)
    wm.addChild(bottom)

    return osgWidget.createExample(viewer, wm)
Exemplo n.º 18
0
    widget.addCallback(osgWidget.Callback(colorWidgetLeave, osgWidget.EVENT_MOUSE_LEAVE))
    widget.addCallback(osgWidget.Callback(widgetMouseOver, osgWidget.EVENT_MOUSE_OVER))
    widget.setColor(col, col, col, 0.5)
    widget.setLayer(layer)
    
    return widget

def main(argv):

    
    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D,
        osgWidget.WindowManager.WM_PICK_DEBUG
    )
    
    canvas = osgWidget.Canvas("canvas")

    canvas.addCallback(osgWidget.Callback(windowMouseOver, osgWidget.EVENT_MOUSE_OVER))
    canvas.attachMoveCallback()
    canvas.attachRotateCallback()
    canvas.attachScaleCallback()

    canvas.addWidget(
        createWidget("w1", 0.2, osgWidget.Widget.LAYER_LOW),
        0.0,
        0.0
Exemplo n.º 19
0
def main(argv):

    
    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D,
        # osgWidget.WindowManager.WM_USE_RENDERBINS |
        osgWidget.WindowManager.WM_PICK_DEBUG
    )
    
    box = osgWidget.Box("HBOX", osgWidget.Box.HORIZONTAL)
    vbox = osgWidget.Box("vbox", osgWidget.Box.VERTICAL)
    label1 = createLabel(LABEL1)
    label2 = createLabel(LABEL2)

    # Setup the labels for horizontal box.
    label1.setPadding(10.0)
    label2.setPadding(10.0)

    label1.addSize(21.0, 22.0)
    label2.addSize(21.0, 22.0)

    label1.setColor(1.0, 0.5, 0.0, 0.0)
    label2.setColor(1.0, 0.5, 0.0, 0.5)

    label2.setImage("Images/Brick-Norman-Brown.TGA", True)

    box.addWidget(label1)
    box.addWidget(label2)
    box.attachMoveCallback()
    box.attachScaleCallback()
    box.attachRotateCallback()

    # Setup the labels for the vertical box.
    label3 = createLabel("Label 3", 80)
    label4 = createLabel("Label 4", 60)
    label5 = createLabel("ABCDEFGHIJK", 93)

    label3.setPadding(3.0)
    label4.setPadding(3.0)
    label5.setPadding(3.0)

    label3.setColor(0.0, 0.0, 0.5, 0.5)
    label4.setColor(0.0, 0.0, 0.5, 0.5)
    label5.setColor(0.0, 0.0, 0.5, 0.5)
    
    #label5.setAlignHorizontal(osgWidget.Widget.HA_LEFT)
    #label5.setAlignVertical(osgWidget.Widget.VA_BOTTOM)

    # Test our label copy construction...
    label6 = osg.clone(label5, "label6", osg.CopyOp.DEEP_COPY_ALL)

    label6.setLabel("abcdefghijklmnopqrs")

    vbox.addWidget(label3)
    vbox.addWidget(label4)
    vbox.addWidget(label5)
    vbox.addWidget(label6)
    vbox.attachMoveCallback()
    vbox.attachScaleCallback()

    vbox.resize()

    # vbox.setVisibilityMode(osgWidget.Window.VM_ENTIRE)
    # vbox.setVisibleArea(50, 50, 500, 200)
    # vbox.setAnchorVertical(osgWidget.Window.VA_TOP)
    # vbox.setAnchorHorizontal(osgWidget.Window.HA_RIGHT)

    # Test our label-in-window copy construction...
    clonedBox = osg.clone(box, "HBOX-", osg.CopyOp.DEEP_COPY_ALL)()
    
    clonedBox.getBackground().setColor(0.0, 1.0, 0.0, 0.5)

    wm.addChild(box)
    wm.addChild(vbox)
    wm.addChild(clonedBox)

    return osgWidget.createExample(viewer, wm)
Exemplo n.º 20
0
def main(argv):

    
    viewer = osgViewer.Viewer()
    
    # Let's get busy not  The WindowManager class is actually an osg.Switch,
    # so you can add it to (ideally) an orthographic camera and have it behave as
    # expected. Note that you create a WindowManager with a NodeMask--it is very important
    # that this be unique for picking to work properly. This also makes it possible to have
    # multiple WindowManagers each operating on their own, unique set of Window objects.
    # The final bool argument is a group of flags that introduce optional functionality
    # for the WindowManager. In our case we include the flags USE_PYTHON and USE_LUA,
    # to demonstrate (and test) their usage. Finally, we pass the temporary WM_NO_BETA_WARN
    # argument, which prevents creating the orange warning window. :) It will be shown
    # in other examples...
    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D,
        osgWidget.WindowManager.WM_USE_LUA |
        osgWidget.WindowManager.WM_USE_PYTHON |
        osgWidget.WindowManager.WM_PICK_DEBUG
    )

    # An actual osgWidget.Window is pure virtual, so we've got to use the osgWidget.Box
    # implementation for now. At a later time, support for Tables and other kinds of
    # advanced layout Window types will be added.
    box = osgWidget.Box("box", osgWidget.Box.HORIZONTAL)

    # Now we actually attach our two types of callbacks to the box instance. The first
    # uses the simple function signature, the second uses a bound method, passing "this"
    # as the second argument to the Callback constructor.
    # Object obj

    static str data = "lol ur face not "

    #
#    box.addCallback(osgWidget.Callback(windowClicked, osgWidget.EVENT_MOUSE_PUSH, data))
#    box.addCallback(osgWidget.Callback(windowScrolled, osgWidget.EVENT_MOUSE_SCROLL))
#    box.addCallback(osgWidget.Callback(
#        Object.windowClicked,
#        obj,
#        osgWidget.EVENT_MOUSE_PUSH
#    ))
#    

    box.addCallback(CallbackObject(osgWidget.EVENT_MOUSE_PUSH))

    # Create some of our "testing" Widgets included are two Widget subclasses I made
    # during testing which I've kept around for testing purposes. You'll notice
    # that you cannot move the box using the NullWidget, and that the NotifyWidget
    # is a bit verbose. :)
    widget1 = osgWidget.NotifyWidget("widget1", 300.0, 100.0)
    widget2 = osgWidget.NullWidget("widget2", 400.0, 75.0)
    widget3 = osgWidget.Widget("widget3", 100.0, 100.0)
    # Set the colors of widget1 and widget3 to green.
    widget1.setColor(0.0, 1.0, 0.0, 1.0)
    widget1.setCanFill(True)
    widget3.setColor(0.0, 1.0, 0.0, 1.0)

    widget1.setImage(osgDB.readImageFile("Images/Saturn.TGA"), True)

    # Set the color of widget2, to differentiate it and make it sassy. This is
    # like a poor man's gradient not 
    widget2.setColor(0.9, 0.0, 0.0, 0.9, osgWidget.Widget.LOWER_LEFT)
    widget2.setColor(0.9, 0.0, 0.0, 0.9, osgWidget.Widget.LOWER_RIGHT)
    widget2.setColor(0.0, 0.0, 0.9, 0.9, osgWidget.Widget.UPPER_RIGHT)
    widget2.setColor(0.0, 0.0, 0.9, 0.9, osgWidget.Widget.UPPER_LEFT)

    # Now add our newly created widgets to our box.
    box.addWidget(widget1)
    box.addWidget(widget2)
    box.addWidget(widget3)

    # For maximum efficiency, Windows don't automatically reallocate their geometry
    # and internal positioning every time a widget is added. Thus, we either have to
    # call the WindowManger.resizeAllWindows method or manually call
    # Window.resize when we're ready.
    box.resize()

    # Now, lets clone our existing box and create a copy of of it, also adding that
    # to the WindowManager. This demonstrates the usages of OSG's .clone() support,
    # though that is abstracted by our META_UIObject macro.
    boxCopy = osg.clone(box, "newBox", osg.CopyOp.DEEP_COPY_ALL)

    # Move our copy to make it visible.
    boxCopy.setOrigin(0.0, 125.0)

    boxCopy.getByName("widget1").setColor(0.5, 0.0, 1.0, 1.0)
    boxCopy.getByName("widget3").setColor(0.5, 0.0, 1.0, 1.0)

    # Add the successfully created Box (if we get this far) into the WindowManager, so
    # that they can receive events.
    wm.addChild(box)
    wm.addChild(boxCopy)

    # Now, ask our box to be 100% the width of the WindowManager.
    boxCopy.resizePercent(100.0, 0.0)

    # Here we demonstrate the use of osgWidget/io_utils. This is really only useful for
    # debugging at the moment.
    # print *box, *boxCopy

    # Setup our OSG objects for our scene note the use of the utility function
    # createOrthoCamera, which is just a helper for setting up a proper viewing area.
    # An alternative (and a MUCH easier alternative at that not ) is to
    # simply use the createParentOrthoCamera method of the WindowManager class,
    # which will wrap the calls to createOrthoCamera and addChild for us not  Check out
    # some of the other examples to see this in action...
    group = osg.Group()
    camera = osgWidget.createOrthoCamera(1280.0, 1024.0)
    model = osgDB.readNodeFile("cow.osgt")

    # Add our event handler is this better as a MatrixManipulator? Add a few other
    # helpful ViewerEventHandlers.
    viewer.addEventHandler(osgWidget.MouseHandler(wm))
    viewer.addEventHandler(osgWidget.KeyboardHandler(wm))
    viewer.addEventHandler(osgWidget.ResizeHandler(wm, camera))
    viewer.addEventHandler(osgWidget.CameraSwitchHandler(wm, camera))
    viewer.addEventHandler(osgViewer.StatsHandler())
    viewer.addEventHandler(osgViewer.WindowSizeHandler())
    viewer.addEventHandler(osgGA.StateSetManipulator(
        viewer.getCamera().getOrCreateStateSet()
    ))

    # Set our first non-UI node to be something other than the mask we created our
    # WindowManager with to avoid picking.
    # TODO: Do I need to create a mechanism for doing this automatically, or should
    # that be the responsibility of the users of osgWidget?
    model.setNodeMask(MASK_3D)

    # Add the WindowManager instance to the 2D camera. This isn't strictly necessary,
    # and you can get some cool results putting the WindowManager directly into a
    # 3D scene. This is not necessary if you use WindowManager.createParentOrthoCamera.
    camera.addChild(wm)

    # Add our camera and a testing 3D model to the scene.
    group.addChild(camera)
    group.addChild(model)

    # Here we show how to both run simple strings of code AND run entire files. These
    # assume that you're running the osgwidgetwindow example from the build directory,
    # otherwise you'll need to adjust the file path below in the call to runFile().
    wm.getLuaEngine().eval("window = osgwidget.newWindow()")
    wm.getLuaEngine().runFile("osgWidget/osgwidgetwindow.lua")

    wm.getPythonEngine().eval("import osgwidget")
    wm.getPythonEngine().runFile("osgWidget/osgwidgetwindow.py")

    viewer.setUpViewInWindow(0, 0, 1280, 1024)
    viewer.setSceneData(group)

    #
#    cameras = osgViewer.Viewer.Cameras() 
#    viewer.getCameras(cameras)
#    c = cameras[0]
#    s = osg.Matrix.scale(1.0, -1.0, 1.0)
#    c.setProjectionMatrix(s * c.getProjectionMatrix())
#    

    return viewer.run()