示例#1
0
def callback():
    import Slash
    ui = Slash.session().ui()

    import CoinPython as Inventor
    import HEPVis

    soPage = ui.findSoPage('Viewer')

    soPage.title.setValue('Python / Detector')

    soRegion = soPage.currentRegion()
    soRegion.color.setValue(Inventor.SbColor(0.8, 0.8, 0.8))
    soSep = soRegion.cast_SoDisplayRegion().getStaticScene()

    soScale = Inventor.SoScale()
    soScale.scaleFactor.setValue(Inventor.SbVec3f(0.1, 0.1, 0.1))
    soSep.addChild(soScale)

    soDet = HEPVis.SoDetectorExample()
    soSep.addChild(soDet)

    w = ui.findWidget('Viewer')
    soViewer = w.cast_ISoViewer()
    soViewer.setDecoration(False)
    soViewer.setViewing(True)

    del soDet
    del soScale
    del soSep
    del soRegion
    del soPage
示例#2
0
def toggle_callback():
    import Slash
    ui = Slash.session().ui()
    value = ui.parameterValue('toggle.set')
    #print(value)
    if value == 'true':
        ui.setParameter('toggle.pixmap', 'logo_LHCb.xpm')
    else:
        ui.setParameter('toggle.pixmap', 'logo_LAL.xpm')
示例#3
0
def button_callback():
    import Slash
    session = Slash.session()
    ui = session.ui()
    value = session.parameterValue('button.related_state')
    #print(value)
    if value == 'off':
        ui.setParameter('button.pixmap', 'logo_LHCb.xpm')
        session.setParameter('button.related_state', 'on')
    else:
        ui.setParameter('button.pixmap', 'logo_LAL.xpm')
        session.setParameter('button.related_state', 'off')
示例#4
0
def callback():
    import Slash
    ui = Slash.session().ui()
    # Create a new menu in the default menu bar :
    ui.createComponent('onx_exa_casc', 'CascadeButton', 'menu_bar')
    ui.setParameter('onx_exa_casc.label', 'MyMenu')
    ui.createComponent('onx_exa_menu', 'Menu', 'onx_exa_casc')
    # Create a first item in the menu :
    ui.createComponent('onx_exa_item_1', 'MenuItem', 'onx_exa_menu')
    ui.setParameter('onx_exa_item_1.label', 'Item 1')
    ui.setCallback('onx_exa_item_1', 'activate', 'Python', 'print(\'Item 1\')')
    # Create a second item in the menu :
    ui.createComponent('onx_exa_item_2', 'MenuItem', 'onx_exa_menu')
    ui.setParameter('onx_exa_item_2.label', 'Item 2')
    ui.setCallback('onx_exa_item_2', 'activate', 'Python', 'print(\'Item 2\')')
示例#5
0
def callback():
    import Slash
    session = Slash.session()
    da = session.accessorManager()  # data accessor.
    da.collect('SceneGraph(Viewer)', 'highlight==true')
    da.filter('name')
    hit = da.handlersIterator()
    print('Picked objects :')
    while 1:
        h = hit.handler()
        if h == None: break
        accessor = h.type()
        obj = h.object()
        # void*
        print('Accessor %s object 0x%lx' % (accessor.name(), obj))
        #print(obj)
        #s = OnX.smanip_p2s(obj)
        #print(s)
        hit.next()
    hit.thisown = 1
    del hit
示例#6
0
#
# The viewer is an Inventor SoExaminerViewer.
#
# There is no HEPVis related code in this example.
#
# Usage :
#   OS> <source osc_vis setup>
#   OS> <setup python>
#   OS> <source osc_vis python setup>
#   OS> <start python>
#   >>> import so_examiner_viewer
#

import Slash
session = Slash.create_session()
ui = session.createUI('so_examiner_viewer.onx')

import CoinPython as Inventor

soViewer = ui.findSoViewer('Viewer')

soNode = soViewer.sceneGraph()
soSep = Slash.cast_SoSeparator(soNode)  #FIXME
#FIXME : soSep = Inventor.cast(soNode,'SoSeparator')

soMaterial = Inventor.SoMaterial()
soMaterial.diffuseColor.setValue(Inventor.SbVec3f(1, 1, 0))
soSep.addChild(soMaterial)

soCylinder = Inventor.SoCylinder()
soCylinder.radius.setValue(5)
示例#7
0
#
# Dump the name of the PageViewer widgets in the GUI.
#
# Usage :
#   OS> <source osc_vis setup>
#   OS> <setup python>
#   OS> <source osc_vis python setup>
#   OS> <start python>
#   >>> import find_widgets
#

import Slash
session = Slash.create_session()
ui = session.createUI('find_widgets.onx')

widgets = ui.findChildren('session', 'nameFromClass', 'PageViewer')
for w in widgets:
    print(w)

ui.steer()

del session
示例#8
0
        if h == None: break
        accessor = h.type()
        obj = h.object()
        # void*
        print('Accessor %s object 0x%lx' % (accessor.name(), obj))
        #print(obj)
        #s = OnX.smanip_p2s(obj)
        #print(s)
        hit.next()
    hit.thisown = 1
    del hit


import Slash

session = Slash.create_session()
ui = session.createUI('shapes.onx')

import CoinPython as Inventor
import HEPVis

ui.executeScript('DLD', 'OnXExas shape_initialize')

da = session.accessorManager()  # data accessor.

soPage = ui.findSoPage('Viewer')
soPage.title.setValue('OnX/Shapes')
soPage.titleVisible.setValue(0)
soRegion = soPage.currentRegion()
soRegion.color.setValue(Inventor.SbColor(0.8, 0.8, 0.8))
del soRegion
示例#9
0
#
#
# Usage :
#   OS> <source osc_vis setup>
#   OS> <setup python>
#   OS> <source osc_vis python setup>
#   OS> <start python>
#   >>> import transparency
#

import Slash

import sys
args = sys.argv
#args.append('-verbose')
session = Slash.create_session(args)

ui = session.createUI('page_viewer.onx')

import CoinPython as Inventor
import HEPVis

soPage = ui.findSoPage('Viewer')

soPage.setTitleVisible(0)
soPage.title.setValue('transparency')

soRegion = soPage.currentRegion()
soRegion.color.setValue(Inventor.SbColor(0, 0, 0))
soSep = soRegion.cast_SoDisplayRegion().getStaticScene()
示例#10
0
#
#  Example to show how to steer the GUI
# but get the hand on the Python prompt.
#
# Usage :
#   OS> <source osc_vis setup>
#   OS> <setup python>
#   OS> <source osc_vis python setup>
#   OS> <start python>
#   >>> import prompt
#

import Slash
session = Slash.create_session()
ui = session.createUI('prompt.onx')

Slash.set_PyOS_InputHook(ui)

#ui.steer() # this is no more needed.

# Since the upper permit to return to the python
# shell then we must not delete session (else the
# GUI will be deleted !).