' '---------------------------- '--- Creation information --- '---------------------------- ' 'Name: balplot.ave 'Version: 1.0 'Date: 01/11/97 'Author: Ferdi Hellweger ' Center for Research in Water Resources ' The University of Texas at Austin ' ferdi@crwr.utexas.edu ' '--------------------------- '--- Purpose/Description --- '--------------------------- ' 'This program plots mass balance terms. ' '---------------------------------------- '--- Action if script run from button --- '---------------------------------------- ' buttonrun = false ' if (self.getclass.getclassname = "Button") then ' buttonrun = true ' '--- Get view --- ' theview = av.getactivedoc ' '--- Get themes --- ' theactivethemes = theview.getactivethemes if (theactivethemes.count = 0) then msgbox.error("No active themes found", "BALANCE") exit end if (theactivethemes.count > 0) then lfound = false pfound = false for each activetheme in theactivethemes theftab = activetheme.getftab theshapef = theftab.findfield("shape") theshape = theftab.returnvalue(theshapef,0) if (theshape.getclass.getclassname = "polyline") then theltheme = activetheme lfound = true end if (theshape.getclass.getclassname = "polygon") then theptheme = activetheme pfound = true end end end if ((not lfound) and (not pfound)) then msgbox.error("No valid active themes found", "BALANCE") exit end ' '--- Set up themes --- ' 'line theme ' if (lfound) then lftab = theltheme.getftab if (lftab = nil) then msgbox.error("Can't open line theme","BALANCE") exit end ' lshapef = lftab.findfield("shape") if (lshapef = nil) then msgbox.error("Can't find 'shape' field in line theme","BALANCE") exit end ' qf = lftab.findfield("q") if (qf = nil) then msgbox.error("Can't find 'q' field in line theme","BALANCE") exit end ' fadf = lftab.findfield("fad") if (fadf = nil) then msgbox.error("Can't find 'fad' field in line theme","BALANCE") exit end ' fdif = lftab.findfield("fdi") if (fdif = nil) then msgbox.error("Can't find 'fdi' field in line theme","BALANCE") exit end ' end ' 'polygon theme ' if (pfound) then ' pftab = theptheme.getftab if (pftab = nil) then msgbox.error("Can't open polygon theme","BALANCE") exit end ' pshapef = pftab.findfield("shape") if (pshapef = nil) then msgbox.error("Can't find 'shape' field in polygon theme","BALANCE") exit end ' wnpf = pftab.findfield("wnp") if (wnpf = nil) then msgbox.error("Can't find 'wnp' field in polygon theme","BALANCE") exit end ' watf = pftab.findfield("wat") if (watf = nil) then msgbox.error("Can't find 'wat' field in polygon theme","BALANCE") exit end ' wotf = pftab.findfield("wot") if (wotf = nil) then msgbox.error("Can't find 'wot' field in polygon theme","BALANCE") exit end ' wsef = pftab.findfield("wse") if (wsef = nil) then msgbox.error("Can't find 'wse' field in polygon theme","BALANCE") exit end ' wadf = pftab.findfield("wad") if (wadf = nil) then msgbox.error("Can't find 'wad' field in polygon theme","BALANCE") exit end ' wdif = pftab.findfield("wdi") if (wdif = nil) then msgbox.error("Can't find 'wdi' field in polygon theme","BALANCE") exit end ' wdf = pftab.findfield("wd") if (wdf = nil) then msgbox.error("Can't find 'wd' field in polygon theme","BALANCE") exit end ' end ' end ' '------------------------------------------------- '--- Action if script called from other script --- '------------------------------------------------- ' if (not buttonrun) then theview = self.get(0) theltheme = self.get(1) theptheme = self.get(2) lftab = self.get(3) pftab = self.get(4) lshapef = self.get(5) qf = self.get(6) fadf = self.get(7) fdif = self.get(8) pshapef = self.get(9) wnpf = self.get(10) watf = self.get(11) wotf = self.get(12) wsef = self.get(13) wadf = self.get(14) wdif = self.get(15) wdf = self.get(16) ' lfound = true pfound = true end ' '-------------------- '--- Get graphics --- '-------------------- ' vgraphics = theview.getgraphics ' '---------------------- '--- Clear graphics --- '---------------------- ' i = 1 j = vgraphics.count while (i <= j) vgraphics.removegraphic(vgraphics.get(0)) i = i + 1 end ' '--- Get display extent --- ' len = (theview.getdisplay.returnextent.getwidth)/80 ' '------------------------------------ '--- Set scale factor for vectors --- '------------------------------------ ' if (lfound and ((_pq = 0) or (_pfad) or (_pfdi))) then ' if (((_pqs = 0) and (_pq)) or ((_pfs = 0) and((_pfad) or (_pfdi)))) then qmax = 0 fmax = 0 for each lrec in lftab if (lftab.returnvalue(qf, lrec).abs > qmax) then qmax = lftab.returnvalue(qf, lrec).abs end if (lftab.returnvalue(fadf, lrec).abs > fmax) then fmax = lftab.returnvalue(fadf, lrec).abs end if (lftab.returnvalue(fdif, lrec).abs > fmax) then fmax = lftab.returnvalue(fdif, lrec).abs end end end pqs = theview.getdisplay.returnextent.getwidth / (10 * _pqs) if (_pqs = 0 and _pq) then pqs = theview.getdisplay.returnextent.getwidth / (10 * qmax) end pfs = theview.getdisplay.returnextent.getwidth / (10 * _pfs) if (_pfs = 0 and (_pfad or _pfdi)) then pfs = theview.getdisplay.returnextent.getwidth / (10 * fmax) end ' end ' '---------------------------------------- '--- Set scale factor for load points --- '---------------------------------------- ' if (pfound and ((_pwnp) or (_pwat) or (_pwse) or (_pwot) or (_pwad) or (_pwdi) or (_pwd))) then ' if ((_pws = 0) and ((_pwnp) or (_pwat) or (_pwse) or (_pwot) or (_pwad) or (_pwdi) or (_pwd))) then wmax = 0 for each prec in pftab if (pftab.returnvalue(wnpf, prec).abs > wmax) then wmax = pftab.returnvalue(wnpf, prec).abs end if (pftab.returnvalue(watf, prec).abs > wmax) then wmax = pftab.returnvalue(watf, prec).abs end if (pftab.returnvalue(wsef, prec).abs > wmax) then wmax = pftab.returnvalue(wsef, prec).abs end if (pftab.returnvalue(wotf, prec).abs > wmax) then wmax = pftab.returnvalue(wotf, prec).abs end if (pftab.returnvalue(wadf, prec).abs > wmax) then wmax = pftab.returnvalue(wadf, prec).abs end if (pftab.returnvalue(wdif, prec).abs > wmax) then wmax = pftab.returnvalue(wdif, prec).abs end if (pftab.returnvalue(wdf, prec).abs > wmax) then wmax = pftab.returnvalue(wdf, prec).abs end end end ' pws = theview.getdisplay.returnextent.getwidth / (100 * _pws) cdist = (theview.getdisplay.returnextent.getwidth / 100) * 3 if (_pws = 0) then pws = theview.getdisplay.returnextent.getwidth / (100 * wmax) cdist = (theview.getdisplay.returnextent.getwidth / 100) * 3 end ' end ' '--- Plot flux vectors --- ' if (lfound and ((_pq = 0) or (_pfad) or (_pfdi))) then ' if (_pq or _pfad or _pfdi) then for each lrec in lftab ' 'get flux magnitudes ' pqm = lftab.returnvalue(qf, lrec) pfadm = lftab.returnvalue(fadf, lrec) pfdim = lftab.returnvalue(fdif, lrec) ' if ((pqm.abs > 0) or (pfadm.abs > 0) or (pfdim.abs > 0)) then ' 'get flux plot locations ' lshape = lftab.returnvalue(lshapef, lrec) pointlist = lshape.asmultipoint.aslist fulllength = 0 i = 1 while (i < pointlist.count) fx = pointlist.get(i - 1).getx fy = pointlist.get(i - 1).gety tx = pointlist.get(i).getx ty = pointlist.get(i).gety length = (((fx - tx)^2) + ((fy - ty)^2)^0.5) fulllength = fulllength + length i = i + 1 end partlength = 0 i = 1 qfound = false fadfound = false fdifound = false while (i < pointlist.count) fx = pointlist.get(i - 1).getx fy = pointlist.get(i - 1).gety tx = pointlist.get(i).getx ty = pointlist.get(i).gety length = (((fx - tx)^2) + ((fy - ty)^2)^0.5) partlength = partlength + length if ((partlength >= (fulllength * _pql)) and (not qfound) and _pq and (pqm.abs > 0)) then fraction = ((fulllength * _pql) - partlength + length) / length av.run("balar",{fx,fy,tx,ty,length,fraction,len,pqm,pqs,vgraphics, _pqc}) qfound = true end if ((partlength >= (fulllength * _pfadl)) and (not fadfound) and _pfad and (pfadm.abs > 0)) then fraction = ((fulllength * _pfadl) - partlength + length) / length av.run("balar",{fx,fy,tx,ty,length,fraction,len,pfadm,pfs,vgraphics, _pfadc}) fadfound = true end if ((partlength >= (fulllength * _pfdil)) and (not fdifound) and _pfdi and (pfdim.abs > 0)) then fraction = ((fulllength * _pfdil) - partlength + length) / length av.run("balar",{fx,fy,tx,ty,length,fraction,len,pfdim,pfs,vgraphics, _pfdic}) fdifound = true end i = i + 1 end end end end ' end ' '--- Plot load points --- ' if (pfound and ((_pwnp) or (_pwat) or (_pwse) or (_pwot) or (_pwad) or (_pwdi) or (_pwd))) then ' if (_pwnp or _pwat or _pwse or _pwot or _pwad or _pwdi or _pwd) then for each prec in pftab pshape = pftab.returnvalue(pshapef, prec) pcenter = pshape.returncenter pcenterx = pcenter.getx pcentery = pcenter.gety ' wm = pftab.returnvalue(wnpf, prec) if (_pwnp and (wm <> 0)) then cx = pcenterx + (cdist * _pwnpl.asradians.sin) cy = pcentery + (cdist * _pwnpl.asradians.cos) wr = wm * pws wc = _pwnpc av.run("balcir",{cx, cy, wr, wc, vgraphics}) end ' wm = pftab.returnvalue(watf, prec) if (_pwat and (wm <> 0)) then cx = pcenterx + (cdist * _pwatl.asradians.sin) cy = pcentery + (cdist * _pwatl.asradians.cos) wr = wm * pws wc = _pwatc av.run("balcir",{cx, cy, wr, wc, vgraphics}) end ' wm = pftab.returnvalue(wsef, prec) if (_pwse and (wm <> 0)) then cx = pcenterx + (cdist * _pwsel.asradians.sin) cy = pcentery + (cdist * _pwsel.asradians.cos) wr = wm * pws wc = _pwsec av.run("balcir",{cx, cy, wr, wc, vgraphics}) end ' wm = pftab.returnvalue(wotf, prec) if (_pwot and (wm <> 0)) then cx = pcenterx + (cdist * _pwotl.asradians.sin) cy = pcentery + (cdist * _pwotl.asradians.cos) wr = wm * pws wc = _pwotc av.run("balcir",{cx, cy, wr, wc, vgraphics}) end ' wm = pftab.returnvalue(wadf, prec) if (_pwad and (wm <> 0)) then cx = pcenterx + (cdist * _pwadl.asradians.sin) cy = pcentery + (cdist * _pwadl.asradians.cos) wr = wm * pws wc = _pwadc av.run("balcir",{cx, cy, wr, wc, vgraphics}) end ' wm = pftab.returnvalue(wdif, prec) if (_pwdi and (wm <> 0)) then cx = pcenterx + (cdist * _pwdil.asradians.sin) cy = pcentery + (cdist * _pwdil.asradians.cos) wr = wm * pws wc = _pwdic av.run("balcir",{cx, cy, wr, wc, vgraphics}) end ' wm = pftab.returnvalue(wdf, prec) if (_pwd and (wm <> 0)) then cx = pcenterx + (cdist * _pwdl.asradians.sin) cy = pcentery + (cdist * _pwdl.asradians.cos) wr = wm * pws wc = _pwdc av.run("balcir",{cx, cy, wr, wc, vgraphics}) end end end ' end ' '----------- '--- End --- '----------- '