def plane_slice_plotting(window_number, axis_number, label, images, timestamp): """ Copy the Mesh, Pseudocolor, and Contour plots into a new VisIt window and slice through the proper axis. Input: ______ window_number: int The number of the window to open (2,3, or 4). axis_number: int The number of the axis to slice through (0 for X, 1 for Y, 2 for Z). label: str The title of the plane slice. images: boolean Whether or not to save images of the plot windows. timestamp: boolean Whether or not to keep the timestamp on plot window images. Returns: ________ none """ # Open a new window with all three plots. Vi.AddWindow() Vi.CopyPlotsToWindow(1, window_number) # Create the plane slice plot by activating the mesh, pseudocolor, and contour plots. Vi.SetActiveWindow(window_number) Vi.SetActivePlots((0, 1, 2)) # Remove the clip and slice operators from previous plot windows. Vi.RemoveAllOperators() # Add a slice through the proper axis. Vi.AddOperator("Slice", 1) s = Vi.SliceAttributes() s.axisType = axis_number Vi.SetOperatorOptions(s) # Include a label for each plane slice plot. banner = Vi.CreateAnnotationObject("Text2D") banner.position = (0.45, 0.92) banner.text = label banner.height = 0.05 # Include the CNERG logo in the bottom left corner of the plot. image = Vi.CreateAnnotationObject("Image") image.image = os.path.dirname(os.path.abspath(__file__)) + "/cnerg.jpg" image.position = (0.02, 0.02) image.width = 10 image.height = 10 Vi.DrawPlots() if images: if timestamp: attributes = Vi.GetAnnotationAttributes() attributes.userInfoFlag = 0 Vi.SetAnnotationAttributes(attributes) Vi.SaveWindow()
def SetTimeText(timeTextInfo): # add text "Time=???" if set==True if timeTextInfo.set: text = visit.CreateAnnotationObject("Text2D") text.visible = 1 text.active = 1 text.position = (timeTextInfo.xlo, timeTextInfo.ylo) text.height = timeTextInfo.height text.text = "Time=$time"
def writeTime(self, round=None): self.setActiveWindow(vrc.rcParams['time.window']) if self.time_annot is None: ta = v.CreateAnnotationObject("Text2D") ta.position = vrc.rcParams['time.location'] ta.height = vrc.rcParams['time.fontheight'] ta.fontFamily = vrc.getDefaultFont() self.time_annot = ta if round is None: round = vrc.rcParams['time.round'] self.time_annot.text = vt.visitTime(round)
def test_visit(): import visit VISIT_ARGS = os.environ.get('VISIT_ARGS', ["-nosplash"]) if isinstance(VISIT_ARGS, str): VISIT_ARGS = VISIT_ARGS.split() for arg in VISIT_ARGS: visit.AddArgument(arg) visit.Launch() print "visit is installed in", os.path.dirname(visit.__file__) print "visit version", visit.Version() visit.ResetView() v3D = visit.GetView3D() v3D.SetViewUp(0, 0, 1) v3D.SetViewNormal(-0.5, -0.8, 0.4) v3D.SetImageZoom(1.0) visit.SetView3D(v3D) aa = visit.AnnotationAttributes() aa.SetAxesType(2) # outside edges aa.SetDatabaseInfoFlag(False) aa.SetUserInfoFlag(False) visit.SetAnnotationAttributes(aa) t = visit.CreateAnnotationObject("Text2D") t.SetText("Hello VisIt!") t.SetPosition(0.4, 0.9) # (0,0) is lower left corner t.SetFontFamily(0) # 0: Arial, 1: Courier, 2: Times t.SetWidth(0.25) # 25% t.SetTextColor((0, 0, 0)) t.SetUseForegroundForTextColor(False) t.SetVisible(True) visit.OpenDatabase("tmp_.vtk") visit.AddPlot("Mesh", "scalars") ma = visit.MeshAttributes() visit.SetPlotOptions(ma) visit.AddPlot("Pseudocolor", "scalars") pa = visit.PseudocolorAttributes() visit.SetPlotOptions(pa) visit.RedrawWindow() visit.DrawPlots() wait()
def __init__(self, pname, ptype, patts, varname=None): """Plot class""" self.pname = pname self.varname = varname self.ptype = ptype self.patts = patts self.operators = [] self.annot = v.GetAnnotationObject(pname) self.annot.fontFamily = vrc.getDefaultFont() self.annot.fontHeight = vrc.rcParams['legend.fontheight'] self.annot.managePosition = 0 self.annot.xScale = vrc.rcParams['legend.scale'][0] self.annot.yScale = vrc.rcParams['legend.scale'][1] self.annot.position = vrc.rcParams['legend.position'] self.annot.drawMinMax = vrc.rcParams['legend.minmax'] if varname is not None: self.annot.drawTitle = 0 self.title = v.CreateAnnotationObject("Text2D") self.title.text = varname self.title.fontFamily = vrc.getDefaultFont() self.title.height = vrc.rcParams['legend.title.fontheight'] self.title.position = vrc.rcParams['legend.title.position']
def viewit(): tl = visit.CreateAnnotationObject("Text2D") tl.position = (.08, .93) tl.height = .026 tl.fontFamily = 0 tl.fontBold = 1 tl.fontShadow = 1 visit.DeleteAllPlots() k = 30000 kMax = 40001 while k < kMax: filename = "scalar" + str(k) + ".Point3D" print "opening database file: " + filename status = visit.OpenDatabase(filename, 0, "Point3D") if status != 1: print "Could not open " + filename return status = visit.AddPlot("Pseudocolor", "density") visit.DrawPlots() pca = visit.GetPlotOptions() pca.colorTableName = "density" pca.invertColorTable = 1 pca.minFlag = 1 pca.maxFlag = 1 pca.min = -.21 pca.max = .21 # visit.SetPlotOptions(pca) names = visit.GetAnnotationObjectNames() print names lastName = names[-1] print "lastName = " + lastName legend = visit.GetAnnotationObject(lastName) legend.numTicks = 3 legend.managePosition = 0 legend.position = (.1, .88) legend.orientation = 1 legend.drawMinMax = 0 legend.drawTitle = 0 legend.drawLabels = "Labels" legend.suppliedLabels = (" -.15", " 0.", " .15") legend.fontHeight = .024 legend.numberFormat = "%#-9.2g" legend.fontFamily = 2 legend.fontBold = 1 tl.text = "Density Fluctuation - Step " + str(k) tl.visible = 1 visit.SaveWindow() k = k + 1000 if k < kMax: tl.visible = 0 visit.DeleteAllPlots() visit.CloseDatabase(filename)
def visit_config(geometry_file, data_file, args): """ Convert geometry file to stl, convert data file to vtk, load each file into VisIt, and create and load a session file containing four plot windows. 1) A cube with a slice through an octant. 2) XY plane slice through the centroid. 3) XZ plane slice through the centroid. 4) YZ plane slice through the centroid. Each window has a mesh plot with the "STL_mesh" variable, a Pseudocolor plot with the "TALLY_TAG" variable, and the second, third, and fourth windows have Contour plots with the "ERROR_TAG" variable. If the user has indicated to, launch VisIt and load the session file. Input: ______ geometry_file: h5m file User supplied geometry file. data_file: h5m or vtk file User supplied data file. args: Namespace User supplied geometry file location, data file location, and indication if the user wants images of the plot windows with a timestamp and the session file saved and opened in VisIt. Returns: ________ None """ # Create a list of dictionaries indicating the data, plot, and variable in VisIt. Files = [{ "file_name": data_file, "plot_type": "Pseudocolor", "data_tag": "TALLY_TAG" }, { "file_name": data_file, "plot_type": "Contour", "data_tag": "ERROR_TAG" }, { "file_name": geometry_file, "plot_type": "Mesh", "data_tag": "STL_mesh" }] # Launch VisIt and add appropriate plots. Vi.LaunchNowin() for file in Files: Vi.OpenDatabase(file["file_name"]) Vi.AddPlot(file["plot_type"], file["data_tag"]) # Hide the contour plot in the first plot window. Vi.SetActivePlots(1) Vi.HideActivePlots() # Create the plot of the cube by activating the mesh and pseudocolor plots. Vi.SetActivePlots((0, 2)) # Set the view normal to the first octant. v = Vi.GetView3D() v.viewNormal = (1, 1, 1) Vi.SetView3D(v) # Apply a clip through the first octant. Vi.AddOperator("Clip") c = Vi.ClipAttributes() c.plane1Origin = (40, 40, 40) c.plane1Normal = (1, 1, 1) Vi.SetOperatorOptions(c) # Include the CNERG logo in the bottom left corner of the plot. image = Vi.CreateAnnotationObject("Image") image.image = os.path.dirname(os.path.abspath(__file__)) + "/cnerg.jpg" image.position = (0.02, 0.02) image.width = 10 image.height = 10 Vi.DrawPlots() if args.images: if args.timestamp: attributes = Vi.GetAnnotationAttributes() attributes.userInfoFlag = 0 Vi.SetAnnotationAttributes(attributes) Vi.SaveWindow() # Create the second plot of the XY plane slice. plane_slice_plotting(2, 2, "XY Plane", args.images, args.timestamp) # Create the third plot of the XZ plane slice. plane_slice_plotting(3, 1, "XZ Plane", args.images, args.timestamp) # Create the fourth plot of the YZ plane slice. plane_slice_plotting(4, 0, "ZY Plane", args.images, args.timestamp) # Display the four windows in a 2x2 grid. Vi.SetWindowLayout(4) # Save the session file with the default VisIt output to the current directory. visit_output = "VisitDefaultOutput.session" Vi.SaveSession(visit_output) Vi.Close() # Retrieve the path to the VisIt session file. session_file_path = os.path.join(os.getcwd(), visit_output) # If the user has indicated to, open the session file with the VisIt GUI. if args.openvisit: os.system("visit -sessionfile {} &".format(session_file_path)) # If the user has indicated to, remove the session file after VisIt has opened. if not args.sessionfile: os.system("sleep 10; rm {}".format(session_file_path))
Vi.SetActivePlots((0, 1)) # Set the view normal to the first octant. v = Vi.GetView3D() v.viewNormal = (1, 1, 1) Vi.SetView3D(v) # Apply a clip through the first octant. Vi.AddOperator("Clip") c = Vi.ClipAttributes() c.plane1Origin = (40, 40, 40) c.plane1Normal = (1, 1, 1) Vi.SetOperatorOptions(c) # Include the CNERG logo in the bottom left corner of the plot. image = Vi.CreateAnnotationObject("Image") image.image = os.path.dirname(os.path.abspath(__file__)) + "/cnerg.jpg" image.position = (0.02, 0.02) image.width = 10 image.height = 10 Vi.DrawPlots() if images: Vi.SaveWindow() # Create the second plot of the XY plane slice. plane_slice_plotting(2, 2, "XY Plane", images) # Create the third plot of the XZ plane slice. plane_slice_plotting(3, 1, "XZ Plane", images)