Exemple #1
0
    createData()
    box = constructWorldBox(gBBox)

    # Create the default scene graph
    gRoot = VisusGroup.construct()
    if not gRoot.setValue(gBBox):
        print "Error occurred setting bbox"
    gRoot.mapToWorldBox(box)
    gRoot.drawBoundingBox(True)
    gFocus = gRoot

    isoValue = VisusIsoValue(1.0)

    iso = addIsoSurface(gRoot)
    iso.setValue(isoValue)

    font = VisusFont()
    font.fontSize(3)

    gIsoValueLabel = VisusLabelNode.construct()
    gIsoValueLabel.position(0.8, -0.9)
    gIsoValueLabel.setValue(font)
    gRoot.attachSubTree(gIsoValueLabel)

    updateIso(isoValue)

    gValues.append(gRoot)

    # Run The Main
    glutMainLoop()
    def __init__(self,
                 dataArray,
                 heightDataArray=[],
                 isoDataArray=[],
                 mask=0,
                 title=None,
                 usrAttribs=dict(),
                 root=None,
                 newWindow=True):
        mask = 1
        # Creating the default root within the __init__ call somehow
        # causes the root variable to persist and only a single root to be
        # created for multiple scenes. To avoid this we use the explicit
        # None initialization
        if root == None:
            root = VisusGroup.construct()

        # Create a root node (or get one from the user)
        self._root = root
        self._root.drawBoundingBox(False)

        # Create the attributes
        self._attribs = dict()

        # Create the heightattributes
        self._heightattribs = dict()

        # Create the iso attributes
        self._isoattribs = dict()

        # Set whether we mask the ocean, the land, or nothing
        self._mask = mask

        # Create a radius object
        self._radius = VisusEarthRadius()

        # Create an earth node
        self._earth = VisusEarthNode.construct()

        # Create a node for the background image
        self._bgEarth = VisusEarthNode.construct()

        # Set the radius of the earth
        self.setEarthRadius(100.0)

        # Set the data that we have
        self._haveHeightData = True
        if (len(heightDataArray) == 0):
            self._haveHeightData = False
        self._haveIsoData = True
        if (len(isoDataArray) == 0):
            self._haveIsoData = False

        # Create the extractor, data description and update attribs
        self.setData(dataArray, heightDataArray, isoDataArray, usrAttribs)

        # Attach the texture extractor to the earth
        self._earth.attachSubTree(self._extractortexture, True)

        # Add the isosurface
        if (self._haveIsoData):
            self._isosurface = self.addIso(self._extractoriso)

            # Set the isoValue
            self._isoValue = VisusIsoValue(40)
            self._isosurface.setValue(self._isoValue)

            # Attach the iso extractor to the earth
            self._earth.attachSubTree(self._extractoriso, True)

        # Attach the height extractor to the earth
        if (self._haveHeightData):
            self._earth.attachSubTree(self._extractorheight, True)

        # Finally attach the earth node to the root
        self._root.attachSubTree(self._earth, True)

        # Create the drawing window
        if newWindow:
            createWindow(self._root)

        # If masking is enabled, set it up
        if self._mask != 0:
            self.setUpMasking()

        # Connect the extractor which is a VisusProducer
        # (which is really a VisusAxisAlignedExtractor)
        if not self._earth.connectTexture(self._extractortexture):
            raise RuntimeError(
                "Unable to connect extractor as EarthNode input")

        # Connect the height extractor which is a VisusProducer
        # (which is really a VisusAxisAlignedExtractor)
        if (self._haveHeightData):
            if not self._earth.connectHeight(self._extractorheight):
                raise RuntimeError(
                    "Unable to connect extractor as EarthNode input")

        # Set the earth as periodic
        self._earth.periodic(True)

        # Rotate the hole to the top
        self.rotateEarth(0.0, -1.0)

        # Set the colormap
        self.setColorMap(banded())

        # Create the colorbar for the colormap
        self._colorBar = VisusColorBar.construct()

        # Set the annotations for the scene
        self.setAnnote()

        self._earth.attachSubTree(self._colorBar, True)
        self._colorBar.inherit(8, True)

        # Position the colorbar
        self._colorBar.position(-.5, -0.8)

        # Add a title to the scene
        if (title == None):
            if "name" in self._attribs:
                title = self._attribs["name"].replace("_", " ")
            else:
                title = "Title"

        font = VisusFont()
        font.fontSize(12)
        self._title = VisusLabelNode.construct()
        self._title.text(title)
        self._title.setValue(font)
        self._title.position(0, 0.92)
        self._earth.attachSubTree(self._title)

        self._extractortexture.propagateUpwards(VISUS_GLOBALTIME_TYPEID)
    isoValue = VisusIsoValue(7.0)

    iso = addIsoSurface(gRoot)
    iso.setValue(isoValue)

    font = VisusFont()
    font.fontSize(3)

    gColorBar = VisusColorBar.construct()
    gColorBar.position(-1, -0.8)
    gColorBar.setValue(gColorMap)
    axis = gColorBar.axis()
    axis.drawLegend(False)
    axis.labelFont(font)
    axis.minValue(gMinValue)
    axis.maxValue(gMaxValue)
    gColorBar.axis(axis)
    gRoot.attachSubTree(gColorBar)

    gIsoValueLabel = VisusLabelNode.construct()
    gIsoValueLabel.position(0.8, -0.9)
    gIsoValueLabel.setValue(font)
    gRoot.attachSubTree(gIsoValueLabel)

    updateIso(isoValue)

    gValues.extend([gRoot, gColorBar, gIsoValueLabel])

    # Run The Main
    glutMainLoop()
Exemple #4
0
	glutDisplayFunc( display )
	glutReshapeFunc( reshape )
	glutMouseFunc( mouse )
	glutKeyboardFunc( keyboard )
	glutMotionFunc( motion )
	glutIdleFunc( idle )

        # Create the default scene graph 
        gRoot = VisusSceneNode.construct()
	gFocus = gRoot

        # Create Sphere
	sphere = VisusSphereNode.construct()
	gRoot.attachSubTree(sphere)

        # Create Text
	font = VisusFont()
        font.fontSize(5);

        text = VisusLabelNode.construct();
        text.text("Visus 2.0 sphere test");
        text.setValue(font);
        text.translate(0.01,0);
        gRoot.attachSubTree(text);

        # Run The Main
	glutMainLoop()


Exemple #5
0
  def __init__( self, dataArray, heightDataArray=[], isoDataArray=[], mask=0, title=None, usrAttribs=dict(), 
                root=None, newWindow = True):
    mask = 1
    # Creating the default root within the __init__ call somehow
    # causes the root variable to persist and only a single root to be
    # created for multiple scenes. To avoid this we use the explicit
    # None initialization
    if root == None:
      root = VisusGroup.construct()

    # Create a root node (or get one from the user)
    self._root = root
    self._root.drawBoundingBox(False)  
    
    # Create the attributes
    self._attribs = dict()
    
    # Create the heightattributes
    self._heightattribs = dict()
    
    # Create the iso attributes
    self._isoattribs = dict()

    # Set whether we mask the ocean, the land, or nothing
    self._mask = mask
    
    # Create a radius object
    self._radius = VisusEarthRadius()
    
    # Create an earth node 
    self._earth = VisusEarthNode.construct()
    
    # Create a node for the background image
    self._bgEarth = VisusEarthNode.construct()
    
    # Set the radius of the earth  
    self.setEarthRadius(100.0)

    # Set the data that we have
    self._haveHeightData = True
    if(len(heightDataArray) == 0):
      self._haveHeightData = False
    self._haveIsoData = True
    if(len(isoDataArray)== 0):
      self._haveIsoData = False

    # Create the extractor, data description and update attribs 
    self.setData(dataArray, heightDataArray, isoDataArray, usrAttribs)
    
    # Attach the texture extractor to the earth
    self._earth.attachSubTree(self._extractortexture, True) 

    # Add the isosurface
    if(self._haveIsoData):
      self._isosurface = self.addIso(self._extractoriso)
    
      # Set the isoValue
      self._isoValue = VisusIsoValue(40)
      self._isosurface.setValue(self._isoValue)
    
      # Attach the iso extractor to the earth
      self._earth.attachSubTree(self._extractoriso, True)
     
    # Attach the height extractor to the earth
    if(self._haveHeightData):
      self._earth.attachSubTree(self._extractorheight, True)

    # Finally attach the earth node to the root
    self._root.attachSubTree(self._earth,True);
        
    # Create the drawing window
    if newWindow:
      createWindow(self._root)

    # If masking is enabled, set it up
    if self._mask != 0:
      self.setUpMasking()

    # Connect the extractor which is a VisusProducer 
    # (which is really a VisusAxisAlignedExtractor)
    if not self._earth.connectTexture(self._extractortexture):
      raise RuntimeError("Unable to connect extractor as EarthNode input")

    # Connect the height extractor which is a VisusProducer 
    # (which is really a VisusAxisAlignedExtractor) 
    if(self._haveHeightData):
      if not self._earth.connectHeight(self._extractorheight):
        raise RuntimeError("Unable to connect extractor as EarthNode input")
    
    # Set the earth as periodic
    self._earth.periodic(True)

    # Rotate the hole to the top
    self.rotateEarth(0.0, -1.0)
    
    # Set the colormap
    self.setColorMap(banded())

    # Create the colorbar for the colormap
    self._colorBar = VisusColorBar.construct()

    # Set the annotations for the scene
    self.setAnnote()
        
    self._earth.attachSubTree(self._colorBar, True)
    self._colorBar.inherit(8, True)

    # Position the colorbar
    self._colorBar.position(-.5,-0.8)

    # Add a title to the scene
    if(title==None):
      if "name" in self._attribs:
        title = self._attribs["name"].replace("_", " ")
      else:
        title = "Title"

    font = VisusFont()
    font.fontSize(12);
    self._title = VisusLabelNode.construct()
    self._title.text(title)
    self._title.setValue(font)
    self._title.position( 0, 0.92)
    self._earth.attachSubTree(self._title)

    self._extractortexture.propagateUpwards(VISUS_GLOBALTIME_TYPEID);