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
soScale.scaleFactor.setValue(Inventor.SbVec3f(0.1, 0.1, 0.1)) soSep.addChild(soScale) # SoPolyhedron : a trd : soSep_trd = Inventor.SoSeparator() soSep.addChild(soSep_trd) soMaterial = Inventor.SoMaterial() soMaterial.diffuseColor.setValue(1, 0, 0) soSep_trd.addChild(soMaterial) soLigthModel = Inventor.SoLightModel() soLigthModel.model.setValue(Inventor.SoLightModel.BASE_COLOR) soSep_trd.addChild(soLigthModel) trd2 = HEPVis.SbPolyhedronTrd2(10, 0, 10, 0, 10) so_trd2 = HEPVis.SoPolyhedron(trd2) so_trd2.solid.setValue(Inventor.FALSE) so_trd2.reducedWireFrame.setValue(Inventor.TRUE) soSep_trd.addChild(so_trd2) # SoPolyhedron : boolean operation : soSep_bool_op = Inventor.SoSeparator() soSep.addChild(soSep_bool_op) soLigthModel = Inventor.SoLightModel() soLigthModel.model.setValue(Inventor.SoLightModel.PHONG) soSep_trd.addChild(soLigthModel) box_1 = HEPVis.SbPolyhedronBox(20, 10, 10) bool_op = HEPVis.SbPolyhedron(box_1)
titleHeight = soPage.titleHeight.getValue() # Detector : h = 1. if titleVisible == 1: h = 1 - titleHeight soRegion = soPage.createRegion(Inventor.SbString("SoDisplayRegion"), 0, 0, 1, h) soRegion.color.setValue(Inventor.SbColor(0.8, 0.8, 0.8)) soSep = soRegion.cast_SoDisplayRegion().getStaticScene() soScale = Inventor.SoScale() soScale.scaleFactor.setValue(0.1, 0.1, 0.1) soSep.addChild(soScale) soDet = HEPVis.SoDetectorExample() soSep.addChild(soDet) del soDet del soSep # Histo region : soRegion = soPage.createRegion(Inventor.SbString("SoPlotterRegion"), 0.01, 0.01, 0.3, 0.3) soPage.highlightRegion(soRegion) soViewportRegion = soRegion.getViewportRegion() soViewportRegion.horizontalBorder.setValue(2) soViewportRegion.verticalBorder.setValue(2) soViewportRegion.borderColor.setValue(Inventor.SbColor(0, 0, 0)) ui.executeScript('DLD', 'OnXLab OnXLab_initialize_AIDA')
#/// Inventor / HEPVis : /////////////////// #/////////////////////////////////////////// import CoinPython as Inventor import HEPVis ip = plotter.cast_Slash_UI_IPlotter() if ip == None: print( 'NOTE : dynamic_cast of AIDA::IPlotter to Slash::UI::IPlotter failed.') # get the SoRegion from another way. ui = aida.ui() soPage = ui.findSoPage('plotter_0') soRegion = soPage.currentRegion() else: soNode = ip.nodeOfInterest('region') soRegion = HEPVis.cast_SoRegion(soNode) soPlotterRegion = soRegion.cast_SoPlotterRegion() soPlotter = soPlotterRegion.getPlotter() soPlotter.getWallStyle().visible.setValue(Inventor.FALSE) soPlotter.getGridStyle().visible.setValue(Inventor.FALSE) #/////////////////////////////////////////// #/////////////////////////////////////////// #/////////////////////////////////////////// plotter.show() plotter.interact() del region
# OS> <setup python> # OS> <source osc_vis python setup> # OS> <start python> # >>> import cube # #///////////////////////////////////////// #/// create the Inventor scene graph : /// #///////////////////////////////////////// import CoinPython as Inventor Inventor.SoDB.init() Inventor.SoNodeKit.init() Inventor.SoInteraction.init() import HEPVis HEPVis.initClasses() sg = Inventor.SoSeparator() soMat = Inventor.SoMaterial() soMat.diffuseColor.setValue(Inventor.SbColor(1, 1, 0)) sg.addChild(soMat) soCube = Inventor.SoCube() soCube.width.setValue(4) # Then no more a cube ! sg.addChild(soCube) #///////////////////////////////////////// #/// create the GUI : //////////////////// #///////////////////////////////////////// from CoinXt import SoXt as SoGUI
import CoinPython as Inventor import HEPVis # create and fill an histogram : import inlib h = inlib.histo_h1d('Rand gauss', 100, -5, 5) import random r = random.Random() for I in range(0, 10000): h.fill(r.gauss(0, 1), 1) #print(h.entries(),h.mean(),h.rms()) soPage = ui.findSoPage('plotter') soRegion = soPage.currentRegion() soPlotterRegion = soRegion.cast_SoPlotterRegion() soPlotterRegion.setStyleROOT_Default() soPlotter = soPlotterRegion.getPlotter() po = HEPVis.h1d2plot('h', h) soPlotter.addPlottableObject(po) ui.steer() del r del h del session