记ProEssentials图表控件在aardio中的使用

By admin at 2020-08-25 • 1人收藏 • 2898人看过

这个图表控件在科学计算、工业控制、金融统计等行业中有着大量的实际应用, 非常Nice

就是我经常使用的实时曲线就有多种模式选择 

支持3d图, 柱状图,饼图, 线图, 极点图,金融图,组合图, 可以任意组合实现不同效果

官方提供的示例非常详细,基本包含了所有的功能演示

此控件可以免注册调用,用com.lite()即可,省去注册时候权限问题的麻烦。

GIF.gif

所以学习一下这个控件还是有很大好处的.


以下是我移植的一个简单的例子

(不要在意代码里好长的那些个常量, 我是懒的找了,一股脑全放进去了)

import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=622;bottom=337)
winform.add(
static={cls="static";text="Static";left=38;top=27;right=570;bottom=284;db=1;dl=1;dr=1;dt=1;notify=1;transparent=1;z=1}
)
/*}}*/



var pe = winform.static.createEmbed("PEGOE.PegoeCtrl.1")
var Pego1 = pe._object
 
 Pego1.setMouseDraggingX(true)
   Pego1.setMouseDraggingY(true)

   // Enable Bar Glass Effect //
   Pego1.setBarGlassEffect(true)

   // Enable Plotting style gradient and bevel features //
   Pego1.setAreaGradientStyle (PEPGS_RADIAL_BOTTOM_RIGHT)
   Pego1.setAreaBevelStyle ( PEBS_MEDIUM_SMOOTH)
   Pego1.setSplineGradientStyle( PEPGS_RADIAL_BOTTOM_RIGHT)
   Pego1.setSplineBevelStyle (PESBS_MEDIUM_SMOOTH)
      
   // Prepare images in memory //
   Pego1.setPrepareImages(true)

   // Pass Data //
   Pego1.setSubsets( 4)
   Pego1.setPoints (12)

   for(s=0;3;1){
   	for(p=0;11;1){
   		Pego1.setYData(s, p, ((p + 1) * 50) + (math.random() * 250) + 2 + 700 - ((s * 140)))
   	}
   }


   // Set DataShadows to show 3D //
   Pego1.setDataShadows(PEDS_SHADOWS)

   Pego1.setMainTitle("Units Sold per Month")
   Pego1.setSubTitle("")
   Pego1.setYAxisLabel("Units Sold")
   Pego1.setXAxisLabel("Month")
   Pego1.setFocalRect(false)
   Pego1.setPlottingMethod(GPM_AREA)
   Pego1.setGridLineControl(PEGLC_BOTH)
   Pego1.setGridStyle(PEGS_DOT)
   Pego1.setAllowRibbon(True)
   Pego1.setAllowZooming(PEAZ_HORZANDVERT)
   Pego1.setZoomStyle(PEZS_RO2_NOT)

   // subset labels //
   Pego1.setSubsetLabels(0,"Texas")
   Pego1.setSubsetLabels(1,"Florida")
   Pego1.setSubsetLabels(2,"Washington")
   Pego1.setSubsetLabels(3,"California")

   // point labels //
   Pego1.setPointLabels(0,"January")
   Pego1.setPointLabels(1,"February")
   Pego1.setPointLabels(2,"March")
   Pego1.setPointLabels(3,"April")
   Pego1.setPointLabels(4,"May")
   Pego1.setPointLabels(5,"June")
   Pego1.setPointLabels(6,"July")
   Pego1.setPointLabels(7,"August")
   Pego1.setPointLabels(8,"September")
   Pego1.setPointLabels(9,"October")
   Pego1.setPointLabels(10,"November")
   Pego1.setPointLabels(11,"December")

   // subset colors //
   Pego1.setSubsetColors(0, Pego1.PEargb(128, 198, 0, 0))
   Pego1.setSubsetColors(1,Pego1.PEargb(128, 0, 198, 198))
   Pego1.setSubsetColors(2,Pego1.PEargb(128, 198, 198, 0))
   Pego1.setSubsetColors(3,Pego1.PEargb(128, 0, 198, 0)) 
   
   // subset line types //
   Pego1.setSubsetLineTypes(0,PELT_MEDIUMSOLID)
   Pego1.setSubsetLineTypes(1,PELT_MEDIUMSOLID)
   Pego1.setSubsetLineTypes(2,PELT_MEDIUMSOLID)
   Pego1.setSubsetLineTypes(3,PELT_MEDIUMSOLID)
   Pego1.setSubsetLineTypes(4,PELT_MEDIUMSOLID)
   Pego1.setSubsetLineTypes(5,PELT_MEDIUMSOLID)
   Pego1.setSubsetLineTypes(6,PELT_MEDIUMSOLID)
   Pego1.setSubsetLineTypes(7,PELT_MEDIUMSOLID)

   // subset point types //
   Pego1.setSubsetPointTypes(0,PEPT_DOTSOLID)
   Pego1.setSubsetPointTypes(1,PEPT_UPTRIANGLESOLID)
   Pego1.setSubsetPointTypes(2,PEPT_SQUARESOLID)
   Pego1.setSubsetPointTypes(3,PEPT_DOWNTRIANGLESOLID)
   Pego1.setSubsetPointTypes(4,PEPT_DOT)
   Pego1.setSubsetPointTypes(5,PEPT_UPTRIANGLE)
   Pego1.setSubsetPointTypes(6,PEPT_SQUARE)
   Pego1.setSubsetPointTypes(7,PEPT_DOWNTRIANGLE)
   
   // Allow stacked type graphs //
   Pego1.setNoStackedData(false)

   // Various other features //
   Pego1.setFixedFonts(true)
   Pego1.setBitmapGradientMode(true)
   Pego1.setQuickStyle(PEQS_MEDIUM_LINE)
   Pego1.setSimplePointLegend(true)
   Pego1.setSimpleLineLegend(true)
   Pego1.setLegendStyle(PELS_1_LINE)
   
   Pego1.setGradientBars(8)
   Pego1.setTextShadows(PETS_BOLD_TEXT)
   Pego1.setMainTitleBold(true)
   Pego1.setSubTitleBold(true)
   Pego1.setLabelBold(true)
   Pego1.setLineShadows(true)
   Pego1.setFontSize(PEFS_LARGE)
   
   Pego1.setDataPrecision(PEDP_ONEDECIMAL)
   Pego1.setGraphPlusTable(PEGPT_BOTH)
   Pego1.setMarkDataPoints(true)
   
   // Improves exports //
   Pego1.setDpiX(600)
   Pego1.setDpiY(600)
   
   Pego1.setRenderEngine(PERE_GDIPLUS)
   Pego1.setAntiAliasGraphics(true)
   Pego1.setAntiAliasText(true)
   
   // Always call PEactions at end **'
   Pego1.setPEactions(REINITIALIZE_RESETIMAGE)
   
winform.show();
win.loopMessage();

这个控件在aardio中调用和别的语言的区别就是所有的属性都用.set括起来了. 这点注意就好了.

在aardio v28.16版本之后, 改进了com调用方式, 现在可以愉快的直接书写属性而不使用.set括起来了.

如用

   Pego1.Subsets = 4
   Pego1.Points =12

代替上面的

   Pego1.setSubsets( 4)
   Pego1.setPoints (12)


运行效果如下:

image.png


ProEssentials的aardio调用示例.zip

ocx.zip


15 个回复 | 最后更新于 2022-01-01
2020-08-28   #1

记录一个大量数据时候的处理:

ProEssentials官方提供了一种处理大量数据的方法, 可以不用每次去设置YData值, 一次性给图表数据

这个方式需要调用它们提供的PEGRP32E.DLL中的函数PEvset

aardio中调用示例如下:

import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=759;bottom=469)
winform.add()
/*}}*/

import console
console.open()

var pe = winform.createEmbed("PEGOE.PegoeCtrl.1")
var Pego1 = pe._object
//设置4条曲线, 每条曲线12个点
Pego1.setSubsets(4)
Pego1.setPoints(12)

//调用dll
var dll=raw.loadDll("PEGRP32E.DLL");
PEvset = dll.api("PEvsetA","long(ADDR hobj,INT npro,pointer data,INT nItems)" )

//定义一个浮点型数组
var buf = { float data[48]={} };
//给数组填充数据
for(s=0;3;1){
	for(p=1;12;1){
		o = (s * 12) + p 
		buf.data[o] = 5 + (math.random() * 10)
	}
}
//包装为指针
var buff =raw.buffer(buf);
//显示数据
console.dumpJson(buf);
//发送数组数据到图表
PEvset(Pego1.hObject, 2140, buff, 48)

winform.show();
win.loopMessage();

image.png

2020-08-28   #2

再来个实时动态显示的例子:

GIF.gif

var F8 = function(){
	// No Shadows //
	
 	Pego1.setDataShadows ( PEDS_NONE)
	// No Flicker //
 	Pego1.setPrepareImages ( true)
 	Pego1.setCacheBmp ( true)
	// Set Subsets and Points //
 	Pego1.setSubsets ( 2      )// set number of subsets
	// Set number data points
 	Pego1.setPoints ( 200     )// number of data points
 	Pego1.setPointsToGraph ( 20)
 	Pego1.setPointsToGraphInit ( PEPTGI_LASTPOINTS)
 	Pego1.setPlottingMethod ( GPM_AREA)
	// Main Title
 	Pego1.setMainTitle ( "Graph Real Time Example")
 	Pego1.setSubTitle ( ""   )// no subtitle
	// Manually configure scales //
 	Pego1.setManualScaleControlY ( PEMSC_MINMAX)
 	Pego1.setManualMinY ( 1)
 	Pego1.setManualMaxY ( 100)
 	Pego1.setManualMinY ( 1)
 	Pego1.setManualMaxDataString ( "000.000")
 	Pego1.setManualMaxPointLabel ( "00:00:00xx")
 	Pego1.setNoStackedData ( true)
 	Pego1.setNoRandomPointsToGraph ( true)
 	Pego1.setAllowHistogram ( false)
 	Pego1.setFocalRect ( false)
 	Pego1.setGridLineControl ( PEGLC_BOTH)
 	Pego1.setDataPrecision ( 1)
	// Needed to allocate point labels so append logic works //
	// Set last point label, Points - 1 //
 	Pego1.setPointLabels(199, "")
 	Pego1.setYData(0, 0, 0)
 	Pego1.setYData(0, 1, 0)
 	Pego1.setYData(0, 2, 0)
 	Pego1.setYData(0, 3, 0)
 	Pego1.setBitmapGradientMode ( false)
 	Pego1.setQuickStyle ( PEQS_DARK_NO_BORDER)
 	Pego1.setFixedFonts ( true)
 	Pego1.setTextShadows ( PETS_BOLD_TEXT)
 	Pego1.setMainTitleBold ( true)
 	Pego1.setSubTitleBold ( true)
 	Pego1.setLabelBold ( true)
 	Pego1.setFontSize ( PEFS_MEDIUM)
	// Improves metafile export //
 	Pego1.setDpiX ( 600)
 	Pego1.setDpiY ( 600)
 	Pego1.setSubsetColors(0,  Pego1.PEargb(128, 0, 198, 0))
 	Pego1.setSubsetColors(1,  Pego1.PEargb(128, 255, 255, 255))
 	Pego1.setRenderEngine ( PERE_HYBRID)
 	Pego1.setAntiAliasText ( true)

	winform.setInterval(
		100,function(){
			ttext = time.now();
   			ttext.format="%H:%M:%S";
   			var tt = tostring(ttext)
   			PEvset(Pego1.hObject, PEP_szaAPPENDPOINTLABELDATA, tt, 1);
			var fNew = {float data[2]={}};
   			// make some random data //
   			fNew.data[1] = math.random()*40 +2;
   			fNew.data[2] = math.random()*40 +6;
			
			var fNewP = raw.buffer(fNew);
   			PEvset(Pego1.hObject, PEP_faAPPENDYDATA, fNewP, 1);
		}
	);

}


2020-08-29   #3

科学图表 scientific , 指示控件名变了,其他同理

image.png

/*基础创建函数{{*/
 var CreateSimpleGraph = function(){
	// Enable middle mouse dragging //
 	Pesgo1.setMouseDraggingX ( true)
 	Pesgo1.setMouseDraggingY ( true)
	// Enable Bar Glass Effect //
 	Pesgo1.setBarGlassEffect ( true)
	// Enable Plotting style gradient and bevel features //
 	Pesgo1.setAreaGradientStyle ( PEPGS_RADIAL_BOTTOM_RIGHT)
 	Pesgo1.setAreaBevelStyle ( PEBS_MEDIUM_SMOOTH)
 	Pesgo1.setSplineGradientStyle ( PEPGS_RADIAL_BOTTOM_RIGHT)
 	Pesgo1.setSplineBevelStyle ( PESBS_MEDIUM_SMOOTH)
	// Set number of Subsets and Points //
 	Pesgo1.setSubsets ( 4)
 	Pesgo1.setPoints ( 12)
	for(s=0;3;1){
		for(p=0;11;1){
 			Pesgo1.setXData(s, p, (p + 1) * 100)
 			Pesgo1.setYData(s, p, (p + 1) * 1 + (math.random() * 250) + 700 - ((s * 140)))
		}
	}
	// Set DataShadows to show shadows
 	Pesgo1.setDataShadows ( PEDS_SHADOWS)
 	Pesgo1.setMainTitle ( "Some Example Data")
 	Pesgo1.setSubTitle ( "" )// no subtitle
 	Pesgo1.setYAxisLabel ( "Units Sold")
 	Pesgo1.setXAxisLabel ( "Month")
 	Pesgo1.setFocalRect ( false)
 	Pesgo1.setPrepareImages ( true)
 	Pesgo1.setCacheBmp ( true)
 	Pesgo1.setPlottingMethod ( SGPM_SPLINE)
 	Pesgo1.setGridLineControl ( PEGLC_BOTH)
 	Pesgo1.setGridStyle ( PEGS_DOT)
 	Pesgo1.setAllowZooming ( PEAZ_HORZANDVERT)
 	Pesgo1.setZoomStyle ( PEZS_RO2_NOT)
	// subset labels
 	Pesgo1.setSubsetLabels(0, "Texas")
 	Pesgo1.setSubsetLabels(1, "Florida")
 	Pesgo1.setSubsetLabels(2, "Washington")
 	Pesgo1.setSubsetLabels(3, "California")
	// subset colors
 	Pesgo1.setSubsetColors(0,  Pesgo1.PEargb(128, 198, 0, 0))
 	Pesgo1.setSubsetColors(1,  Pesgo1.PEargb(128, 0, 198, 198))
 	Pesgo1.setSubsetColors(2,  Pesgo1.PEargb(128, 198, 198, 0))
 	Pesgo1.setSubsetColors(3,  Pesgo1.PEargb(128, 0, 198, 0))
	// subset line types
 	Pesgo1.setSubsetLineTypes(0, PELT_MEDIUM_SOLID)
 	Pesgo1.setSubsetLineTypes(1, PELT_MEDIUM_SOLID)
 	Pesgo1.setSubsetLineTypes(2, PELT_MEDIUM_SOLID)
 	Pesgo1.setSubsetLineTypes(3, PELT_MEDIUM_SOLID)
	// subset point types
 	Pesgo1.setSubsetPointTypes(0, PEPT_DOTSOLID)
 	Pesgo1.setSubsetPointTypes(1, PEPT_UPTRIANGLESOLID)
 	Pesgo1.setSubsetPointTypes(2, PEPT_SQUARESOLID)
 	Pesgo1.setSubsetPointTypes(3, PEPT_DOWNTRIANGLESOLID)
	// Version 4.0 Features //
 	Pesgo1.setFixedFonts ( true)
 	Pesgo1.setSimplePointLegend ( true)
 	Pesgo1.setSimpleLineLegend ( true)
 	Pesgo1.setLegendStyle ( PELS_1_LINE)
 	Pesgo1.setMultiAxisStyle ( PEMAS_SEPARATE_AXES)
	// Set Various Other Properties //
 	Pesgo1.setBitmapGradientMode ( true)
 	Pesgo1.setQuickStyle ( PEQS_MEDIUM_NO_BORDER)
 	Pesgo1.setGradientBars ( 8)
 	Pesgo1.setTextShadows ( PETS_BOLD_TEXT)
 	Pesgo1.setMainTitleBold ( true)
 	Pesgo1.setSubTitleBold ( true)
 	Pesgo1.setLabelBold ( true)
 	Pesgo1.setLineShadows ( true)
 	Pesgo1.setFontSize ( PEFS_LARGE)
 	Pesgo1.setScrollingHorzZoom ( true)
 	Pesgo1.setDataPrecision ( PEDP_ONEDECIMAL)
	// Improves metafile exports //
 	Pesgo1.setDpiX ( 600)
 	Pesgo1.setDpiY ( 600)
 	Pesgo1.setRenderEngine ( PERE_GDIPLUS)
 	Pesgo1.setAntiAliasGraphics ( true)
 	Pesgo1.setAntiAliasText ( true)
	// Set PEactions ( 0 when through setting properties for this control )//
 	Pesgo1.setPEactions ( REINITIALIZE_RESETIMAGE)
 }
 /*}}*/


2020-08-29   #4

image.png

var F1 = function(){
	CreateSimpleGraph();
	// Create MultiAxes //
 	Pesgo1.setMultiAxesSubsets(0, 2)
 	Pesgo1.setMultiAxesSubsets(1, 2)
 	Pesgo1.setMultiAxesSizing ( true)
 	Pesgo1.setWorkingAxis ( 0 )// Set first y axis parameters
 	Pesgo1.setPlottingMethod ( SGPM_BAR)
 	Pesgo1.setComparisonSubsets ( 1)
 	Pesgo1.setPlottingMethodII ( SGPMII_POINTSPLUSSPLINE)
	// Plot last subset on right //
 	Pesgo1.setWorkingAxis ( 1 )// Set second y axis parameters
 	Pesgo1.setRYAxisComparisonSubsets ( 1)
 	Pesgo1.setPlottingMethod ( SGPM_AREA)
 	Pesgo1.setRYAxisColor (  Pesgo1.PEargb(255, 128, 128, 128))
 	Pesgo1.setWorkingAxis ( 0)
 	Pesgo1.setAnnotationsInFront ( false)
 	Pesgo1.setLineAnnotationTextSize ( 110)
 	Pesgo1.setShowAnnotations ( true)
	/////////////////////////////////
	// Horizontal Line Annotations //
	/////////////////////////////////
 	Pesgo1.setHorzLineAnnotation(0, 820)
 	Pesgo1.setHorzLineAnnotationType(0, PELT_MEDIUMDASH)
 	Pesgo1.setHorzLineAnnotationColor(0,  Pesgo1.PEargb(255, 198, 0, 0))
 	Pesgo1.setHorzLineAnnotationText(0, "")
 	Pesgo1.setHorzLineAnnotationInFront(0, PEAIF_IN_FRONT)
 	Pesgo1.setHorzLineAnnotationAxis(0, 0)
 	Pesgo1.setHorzLineAnnotation(1, 780)
 	Pesgo1.setHorzLineAnnotationType(1, PELT_DASH)
 	Pesgo1.setHorzLineAnnotationColor(1,  Pesgo1.PEargb(255, 0, 198, 0))
 	Pesgo1.setHorzLineAnnotationText(1, "")
 	Pesgo1.setHorzLineAnnotationAxis(1, 0)
 	Pesgo1.setHorzLineAnnotation(2, 740)
 	Pesgo1.setHorzLineAnnotationType(2, PELT_DOT)
 	Pesgo1.setHorzLineAnnotationColor(2,  Pesgo1.PEargb(255, 0, 0, 198))
 	Pesgo1.setHorzLineAnnotationText(2, "")
 	Pesgo1.setHorzLineAnnotationAxis(2, 0)
 	Pesgo1.setHorzLineAnnotation(3, 700)
 	Pesgo1.setHorzLineAnnotationType(3, PELT_MEDIUMSOLID)
 	Pesgo1.setHorzLineAnnotationColor(3,  Pesgo1.PEargb(255, 198, 0, 198))
 	Pesgo1.setHorzLineAnnotationText(3, "")
 	Pesgo1.setHorzLineAnnotationAxis(3, 0)
 	Pesgo1.setHorzLineAnnotation(4, 760)
 	Pesgo1.setHorzLineAnnotationType(4, PELT_THICKSOLID)
 	Pesgo1.setHorzLineAnnotationColor(4,  Pesgo1.PEargb(255, 0, 198, 198))
 	Pesgo1.setHorzLineAnnotationText(4, "")
 	Pesgo1.setHorzLineAnnotationAxis(4, 0)
	// Set right margin to the longest string on right //
 	Pesgo1.setRightMargin ( "String ")
 	Pesgo1.setHorzLineAnnotation(5, 720)
 	Pesgo1.setHorzLineAnnotationType(5, PELT_THINSOLID)
 	Pesgo1.setHorzLineAnnotationColor(5,  Pesgo1.PEargb(255, 198, 0, 0))
 	Pesgo1.setHorzLineAnnotationText(5, "|RTest" + '\n' + "String")
 	Pesgo1.setHorzLineAnnotationAxis(5, 0)
	//  Line annotations on bottom axis //
 	Pesgo1.setHorzLineAnnotation(6, 535)
 	Pesgo1.setHorzLineAnnotationType(6, PELT_MEDIUMSOLID)
 	Pesgo1.setHorzLineAnnotationColor(6,  Pesgo1.PEargb(255, 198, 0, 198))
 	Pesgo1.setHorzLineAnnotationText(6, "Bottom multi-axis with respect to left y axis")
 	Pesgo1.setHorzLineAnnotationAxis(6, 1)
	// Line annotation with respect to right y axis //
 	Pesgo1.setHorzLineAnnotation(7, 475)
 	Pesgo1.setHorzLineAnnotationType(7, PELT_THICKSOLID + 1000)
 	Pesgo1.setHorzLineAnnotationColor(7,  Pesgo1.PEargb(255, 0, 198, 198))
 	Pesgo1.setHorzLineAnnotationText(7, "|rBottom multi-axis with respect to right y axis")
 	Pesgo1.setHorzLineAnnotationAxis(7, 1)
	///////////////////////////////
	// Vertical Line Annotations //
	///////////////////////////////
 	Pesgo1.setVertLineAnnotation(0, 820)
 	Pesgo1.setVertLineAnnotationType(0, PELT_MEDIUMDASH)
 	Pesgo1.setVertLineAnnotationColor(0,  Pesgo1.PEargb(255, 198, 0, 0))
 	Pesgo1.setVertLineAnnotationText(0, "")
 	Pesgo1.setVertLineAnnotationInFront(0, PEAIF_IN_FRONT)
 	Pesgo1.setVertLineAnnotation(1, 780)
 	Pesgo1.setVertLineAnnotationType(1, PELT_DASH)
 	Pesgo1.setVertLineAnnotationColor(1,  Pesgo1.PEargb(255, 0, 198, 0))
 	Pesgo1.setVertLineAnnotationText(1, "")
 	Pesgo1.setVertLineAnnotation(2, 740)
 	Pesgo1.setVertLineAnnotationType(2, PELT_DOT)
 	Pesgo1.setVertLineAnnotationColor(2,  Pesgo1.PEargb(255, 0, 0, 198))
 	Pesgo1.setVertLineAnnotationText(2, "")
 	Pesgo1.setVertLineAnnotation(3, 700)
 	Pesgo1.setVertLineAnnotationType(3, PELT_MEDIUMSOLID)
 	Pesgo1.setVertLineAnnotationColor(3,  Pesgo1.PEargb(255, 198, 0, 198))
 	Pesgo1.setVertLineAnnotationText(3, "")
 	Pesgo1.setVertLineAnnotation(4, 760)
 	Pesgo1.setVertLineAnnotationType(4, PELT_THICKSOLID)
 	Pesgo1.setVertLineAnnotationColor(4,  Pesgo1.PEargb(255, 0, 198, 198))
 	Pesgo1.setVertLineAnnotationText(4, "")
	// Set top margin to the longest string on top //
 	Pesgo1.setTopMargin ( "XX ")
 	Pesgo1.setVertLineAnnotation(5, 720)
 	Pesgo1.setVertLineAnnotationType(5, PELT_THINSOLID)
 	Pesgo1.setVertLineAnnotationColor(5,  Pesgo1.PEargb(255, 198, 0, 0))
 	Pesgo1.setVertLineAnnotationText(5, "|HTest" + '\n' + "String")
	//  Line annotation with top justified text //
 	Pesgo1.setVertLineAnnotation(6, 535)
 	Pesgo1.setVertLineAnnotationType(6, PELT_MEDIUMSOLID)
 	Pesgo1.setVertLineAnnotationColor(6,  Pesgo1.PEargb(255, 198, 0, 198))
 	Pesgo1.setVertLineAnnotationText(6, "|t Top Inside ")
	// Line annotation with bottom justified text //
 	Pesgo1.setVertLineAnnotation(7, 575)
 	Pesgo1.setVertLineAnnotationType(7, PELT_THICKSOLID)
 	Pesgo1.setVertLineAnnotationColor(7,  Pesgo1.PEargb(255, 0, 198, 198))
 	Pesgo1.setVertLineAnnotationText(7, "|b Bottom Inside ")
	// New region annotations, define a top, and bottom graph annotation type and then rect fill //
 	Pesgo1.setGraphAnnotationX(0, 0 /*' ignored for this type'*/)
 	Pesgo1.setGraphAnnotationY(0, 1E+20    /*' some value in outer space'*/)
 	Pesgo1.setGraphAnnotationType(0, PEGAT_TOP)
 	Pesgo1.setGraphAnnotationX(1, 0 /*' ignored for this type'*/)
 	Pesgo1.setGraphAnnotationY(1, 850)
 	Pesgo1.setGraphAnnotationType(1, PEGAT_BOTTOM)
 	Pesgo1.setGraphAnnotationX(2, 850 /*' if text define, located here'*/)
 	Pesgo1.setGraphAnnotationY(2, 850)
 	Pesgo1.setGraphAnnotationType(2, PEGAT_RECT_FILL)
 	Pesgo1.setGraphAnnotationColor(2,  Pesgo1.PEargb(155, 234, 123, 53))
 	Pesgo1.setGraphAnnotationText(2, "")
 	Pesgo1.setShowGraphAnnotations ( true)
	// Set Various Other Properties ///
 	Pesgo1.setSubsetColors(0,  Pesgo1.PEargb(195, 0, 128, 128))
 	Pesgo1.setSubsetColors(2,  Pesgo1.PEargb(195, 128, 128, 0))
 	Pesgo1.setSubsetColors(3,  Pesgo1.PEargb(195, 128, 128, 128))
 	Pesgo1.setGridLineControl ( PEGLC_NONE)
 	Pesgo1.setBitmapGradientMode ( true)
 	Pesgo1.setQuickStyle ( PEQS_DARK_LINE)
 	Pesgo1.setLegendStyle ( PELS_1_LINE_LEFT_OF_AXIS)

}


2020-08-29   #5

image.png

var F2 = function(){
    CreateSimpleGraph();
	// Create 4 separate axes and then overlap all //
 	Pesgo1.setMultiAxesSubsets(0, 1 )// 1 subset on first axis
 	Pesgo1.setMultiAxesSubsets(1, 1 )// 1 subset on second axis
 	Pesgo1.setMultiAxesSubsets(2, 1 )// 1 subset on third axis
 	Pesgo1.setMultiAxesSubsets(3, 1 )// 1 subset on fourth axis
 	Pesgo1.setOverlapMultiAxes(0, 4 )// overlap all 4 axes in one group
	// Match axis color and label to subset label //
 	Pesgo1.setWorkingAxis ( 0)
 	Pesgo1.setYAxisColor (  Pesgo1.PEargb(128, 218, 0, 0))
 	Pesgo1.setYAxisLabel ( "Texas")
 	Pesgo1.setPlottingMethod ( SGPM_BAR)
 	Pesgo1.setWorkingAxis ( 1)
 	Pesgo1.setYAxisColor (  Pesgo1.PEargb(128, 0, 218, 0))
 	Pesgo1.setYAxisLabel ( "Florida")
 	Pesgo1.setPlottingMethod ( SGPM_SPLINE_AREA)
 	Pesgo1.setWorkingAxis ( 2)
 	Pesgo1.setYAxisColor (  Pesgo1.PEargb(128, 0, 0, 218))
 	Pesgo1.setYAxisLabel ( "Washington")
 	Pesgo1.setPlottingMethod ( SGPM_POINTSPLUSLINE)
 	Pesgo1.setWorkingAxis ( 3)
 	Pesgo1.setYAxisColor (  Pesgo1.PEargb(128, 218, 218, 0))
 	Pesgo1.setYAxisLabel ( "California")
 	Pesgo1.setPlottingMethod ( SGPM_POINT)
 	Pesgo1.setWorkingAxis ( 0)
	// Set Various Other Properties //
 	Pesgo1.setBitmapGradientMode ( true)
 	Pesgo1.setQuickStyle ( PEQS_DARK_NO_BORDER)
 	Pesgo1.setMarkDataPoints ( true)
 	Pesgo1.setFontSize ( PEFS_LARGE)
 	Pesgo1.setDataShadows ( PEDS_3D)
	// subset colors //
 	Pesgo1.setSubsetColors(0,  Pesgo1.PEargb(128, 198, 0, 0))
 	Pesgo1.setSubsetColors(1,  Pesgo1.PEargb(64, 0, 198, 0))
 	Pesgo1.setSubsetColors(2,  Pesgo1.PEargb(128, 0, 0, 198))
 	Pesgo1.setSubsetColors(3,  Pesgo1.PEargb(128, 198, 198, 0))
	// subset line types
 	Pesgo1.setSubsetLineTypes(0, PELT_MEDIUM_SOLID)
 	Pesgo1.setSubsetLineTypes(1, PELT_MEDIUM_SOLID)
 	Pesgo1.setSubsetLineTypes(2, PELT_MEDIUM_SOLID)
 	Pesgo1.setSubsetLineTypes(3, PELT_MEDIUM_SOLID)
 	Pesgo1.setScrollingHorzZoom ( true)
 	Pesgo1.setScrollingVertZoom ( true)
 	Pesgo1.setTickColor ( 1)
 	Pesgo1.setMainTitle ( "ZOOM and SCROLL the chart!")
 	Pesgo1.setFontSizeGlobalCntl ( 1.3)
	
}


2020-08-29   #6

image.png

var F3 = function(){
    CreateSimpleGraph();
    // Create 4 separate axes and then overlap in two groups //
 	Pesgo1.setMultiAxesSubsets(0, 1 )// 1 subset on first axis
 	Pesgo1.setMultiAxesSubsets(1, 1 )// 1 subset on second axis
 	Pesgo1.setMultiAxesSubsets(2, 1 )// 1 subset on third axis
 	Pesgo1.setMultiAxesSubsets(3, 1 )// 1 subset on fourth axis
 	Pesgo1.setOverlapMultiAxes(0, 2 )// overlap first two axes in one group
 	Pesgo1.setOverlapMultiAxes(1, 2 )// overlap second two axes in one group
 	Pesgo1.setMultiAxesSizing ( true)
	// Match axis color and label to subset label //
 	Pesgo1.setWorkingAxis ( 0)
 	Pesgo1.setYAxisColor (  Pesgo1.PEargb(255, 0, 0, 0))
 	Pesgo1.setYAxisLabel ( "Texas")
 	Pesgo1.setPlottingMethod ( SGPM_BAR)
 	Pesgo1.setWorkingAxis ( 1)
 	Pesgo1.setYAxisColor (  Pesgo1.PEargb(255, 255, 255, 255))
 	Pesgo1.setYAxisLabel ( "Florida")
 	Pesgo1.setPlottingMethod ( SGPM_SPLINE_AREA)
 	Pesgo1.setWorkingAxis ( 2)
 	Pesgo1.setYAxisColor (  Pesgo1.PEargb(255, 0, 0, 0))
 	Pesgo1.setYAxisLabel ( "Washington")
 	Pesgo1.setPlottingMethod ( SGPM_BAR)
 	Pesgo1.setWorkingAxis ( 3)
 	Pesgo1.setYAxisColor (  Pesgo1.PEargb(255, 255, 255, 255))
 	Pesgo1.setYAxisLabel ( "California")
 	Pesgo1.setPlottingMethod ( SGPM_SPLINE_AREA)
 	Pesgo1.setWorkingAxis ( 0)
	// Set Various Other Properties ///
 	Pesgo1.setFontSize ( PEFS_LARGE)
 	Pesgo1.setSubsetLineTypes(0, PELT_MEDIUMSOLID)
 	Pesgo1.setSubsetLineTypes(1, PELT_MEDIUMSOLID)
 	Pesgo1.setSubsetLineTypes(2, PELT_MEDIUMSOLID)
 	Pesgo1.setSubsetLineTypes(3, PELT_MEDIUMSOLID)
 	Pesgo1.setMarkDataPoints ( true)
 	Pesgo1.setBitmapGradientMode ( false)
 	Pesgo1.setQuickStyle ( PEQS_MEDIUM_INSET)
 	Pesgo1.setLegendStyle ( PELS_1_LINE_TOP_OF_AXIS)
 	Pesgo1.setGridLineControl ( PEGLC_BOTH)
 	Pesgo1.setBorderTypes ( PETAB_INSET)
	// subset colors //
 	Pesgo1.setSubsetColors(0,  Pesgo1.PEargb(128, 0, 0, 140))
 	Pesgo1.setSubsetColors(1,  Pesgo1.PEargb(128, 255, 255, 255))
 	Pesgo1.setSubsetColors(2,  Pesgo1.PEargb(128, 0, 0, 140))
 	Pesgo1.setSubsetColors(3,  Pesgo1.PEargb(128, 255, 255, 255))

}


2020-08-29   #7

科学图表的实时显示:(方式一)

下面的定时器里我用了REINITIALIZE_RESETIMAGE代替官方demo提供的RESET_IMAGE参数, 这样就没问题了,但是根据实际情况考虑的话, 每次更新数据后只需要刷新图片IMAGE即可, 而不需要REInitialize初始化下整个图表.....

这个问题先放一放, 继续下面的实验

var F4 = function(){
    //! Chart fills 100 points autoscaling x axis is it
	//! is filled.  Once 100 point have been passed, the
	//! chart then acts as a strip chart.
 	Pesgo1.setSubsets ( 1)
 	Pesgo1.setPoints ( 100)
	// Set Manual Y scale //'
 	Pesgo1.setManualScaleControlY ( PEMSC_MINMAX)
 	Pesgo1.setManualMinY ( 1)
 	Pesgo1.setManualMaxY ( 100)
	// Clear out default data //'
 	Pesgo1.setXData(0, 0, 0)
 	Pesgo1.setXData(0, 1, 0)
 	Pesgo1.setXData(0, 2, 0)
 	Pesgo1.setXData(0, 3, 0)

 	Pesgo1.setYData(0, 0, 0)
 	Pesgo1.setYData(0, 1, 0)
 	Pesgo1.setYData(0, 2, 0)
 	Pesgo1.setYData(0, 3, 0)

	// Set Various Other Properties ///
 	Pesgo1.setBitmapGradientMode ( false)
 	Pesgo1.setQuickStyle ( PEQS_LIGHT_SHADOW)
	// Set various properties //
 	Pesgo1.setMainTitle ( "Scientific Real-Time Example")
 	Pesgo1.setSubTitle ( "")
 	Pesgo1.setNoRandomPointsToExport ( true)
 	Pesgo1.setFocalRect ( false)
 	Pesgo1.setAllowBar ( false)
 	Pesgo1.setAllowPopup ( false)
 	Pesgo1.setPrepareImages ( true)
 	Pesgo1.setCacheBmp ( true)
 	Pesgo1.setFixedFonts ( true)
 	Pesgo1.setSubsetColors(0,  Pesgo1.PEargb(128, 0, 0, 198))
 	Pesgo1.setGradientBars ( 8)
 	Pesgo1.setTextShadows ( PETS_BOLD_TEXT)
 	Pesgo1.setMainTitleBold ( true)
 	Pesgo1.setSubTitleBold ( true)
 	Pesgo1.setLabelBold ( true)
 	Pesgo1.setLineShadows ( true)
 	Pesgo1.setFontSize ( PEFS_MEDIUM)
	// Improves metafile exports //
 	Pesgo1.setDpiX ( 600)
 	Pesgo1.setDpiY ( 600)
 	Pesgo1.setPEactions ( REINITIALIZE_RESETIMAGE)
  
}

定时器里:

var m_nSinCounter,m_nRealTimeCounter = 1,1;
winform.button11.oncommand = function(id,event){
    winform.setInterval(
		20,function(){
			var yy = {float d=0}
			yy.d = 50 + (math.sin(m_nSinCounter * 0.075) * 30) + (math.random() * 15)
			var xx = {float d=1}
			xx.d = m_nRealTimeCounter
			newy = raw.buffer(yy);
			newx = raw.buffer(xx);
			// Append new values  //
			t = PEvset(Pesgo1.hObject, PEP_faAPPENDYDATA, newy, 1)
			t = PEvset(Pesgo1.hObject, PEP_faAPPENDXDATA, newx, 1)
			
			m_nRealTimeCounter++;
			m_nSinCounter++;
			if(m_nSinCounter>30000){
				m_nSinCounter = 1;
			}
		//PEnarg1 to set the width argument	
		//Pesgo1.setPEnarg1(0)
		//PEnarg2 to set the height argument
    		//Pesgo1.setPEnarg2( 0)
    		Pesgo1.setPEactions(REINITIALIZE_RESETIMAGE)//RESET_IMAGE
		}
	);
}

GIF.gif

科学图表实时方式一.zip


2020-08-30   #8

科学图表实时连续数据方式二:

var F5 = function(){
    //! Chart fills 100 points autoscaling x axis is it
	//! is filled.  Once 100 point have been passed, the
	//! chart then acts as a strip chart.
 	Pesgo1.setSubsets ( 1)
 	Pesgo1.setPoints ( 100)
	// Set Manual Y scale //'
 	Pesgo1.setManualScaleControlY ( PEMSC_MINMAX)
 	Pesgo1.setManualMinY ( 1)
 	Pesgo1.setManualMaxY ( 100)
 	// Set Manual X scale 多加了这三行//'
 	Pesgo1.setManualScaleControlX ( PEMSC_MINMAX)
 	Pesgo1.setManualMinX ( 1)
 	Pesgo1.setManualMaxX ( 100)
	// Clear out default data //'
 	Pesgo1.setXData(0, 0, 0)
 	Pesgo1.setXData(0, 1, 0)
 	Pesgo1.setXData(0, 2, 0)
 	Pesgo1.setXData(0, 3, 0)

 	Pesgo1.setYData(0, 0, 0)
 	Pesgo1.setYData(0, 1, 0)
 	Pesgo1.setYData(0, 2, 0)
 	Pesgo1.setYData(0, 3, 0)

	// Set Various Other Properties ///
 	Pesgo1.setBitmapGradientMode ( false)
 	Pesgo1.setQuickStyle ( PEQS_LIGHT_SHADOW)
	// Set various properties //
 	Pesgo1.setMainTitle ( "Scientific Real-Time Example")
 	Pesgo1.setSubTitle ( "")
 	Pesgo1.setNoRandomPointsToExport ( true)
 	Pesgo1.setFocalRect ( false)
 	Pesgo1.setAllowBar ( false)
 	Pesgo1.setAllowPopup ( false)
 	Pesgo1.setPrepareImages ( true)
 	Pesgo1.setCacheBmp ( true)
 	Pesgo1.setFixedFonts ( true)
 	Pesgo1.setSubsetColors(0,  Pesgo1.PEargb(128, 0, 0, 198))
 	Pesgo1.setGradientBars ( 8)
 	Pesgo1.setTextShadows ( PETS_BOLD_TEXT)
 	Pesgo1.setMainTitleBold ( true)
 	Pesgo1.setSubTitleBold ( true)
 	Pesgo1.setLabelBold ( true)
 	Pesgo1.setLineShadows ( true)
 	Pesgo1.setFontSize ( PEFS_MEDIUM)
	// Improves metafile exports //
 	Pesgo1.setDpiX ( 600)
 	Pesgo1.setDpiY ( 600)
 	Pesgo1.setPEactions ( REINITIALIZE_RESETIMAGE)
  
}
//定时器
var m_nSinCounter,m_nRealTimeCounter = 1,1;
winform.button7.oncommand = function(id,event){
	winform.setInterval(
		20,function(){
			var yy = {float d=0}
			yy.d = 50 + (math.sin(m_nSinCounter * 0.075) * 30) + (math.random() * 15)
			var xx = {float d=1}
			xx.d = m_nRealTimeCounter
			newy = raw.buffer(yy);
			newx = raw.buffer(xx);
			// Append new values  //
			t = PEvset(Pesgo1.hObject, PEP_faAPPENDYDATA, newy, 1)
			t = PEvset(Pesgo1.hObject, PEP_faAPPENDXDATA, newx, 1)
			
			m_nRealTimeCounter++;
			//如果到了100个数据那么就设置x轴缩放取消
			if(m_nRealTimeCounter==100){
				Pesgo1.setManualScaleControlX( PEMSC_NONE )	
			}
			m_nSinCounter++;
			if(m_nSinCounter>30000){
				m_nSinCounter = 1;
			}
			
			//Pesgo1.setPEnarg1(0)
    		//Pesgo1.setPEnarg2( 0)
    		Pesgo1.setPEactions(REINITIALIZE_RESETIMAGE)//RESET_IMAGE)
		}
	);
}

GIF2.gif

2020-08-30   #9

科学图表实时显示第三种方式:

var F6 = function(){
    //! Chart fills 100 points autoscaling x axis is it
	//! is filled.  Once 100 point have been passed, the
	//! chart then acts as a strip chart.
 	Pesgo1.setSubsets ( 1)
 	Pesgo1.setPoints ( 100)
	// Set Manual Y scale //'
 	Pesgo1.setManualScaleControlY ( PEMSC_MINMAX)
 	Pesgo1.setManualMinY ( 1)
 	Pesgo1.setManualMaxY ( 100)
 	// Set Manual X scale //'
 	Pesgo1.setManualScaleControlX ( PEMSC_MINMAX)
 	Pesgo1.setManualMinX ( 1)
 	Pesgo1.setManualMaxX ( 100)
 	
 	// Show Annotations //
   Pesgo1.setShowAnnotations(true)
   
	// Clear out default data //'
 	Pesgo1.setXData(0, 0, 0)
 	Pesgo1.setXData(0, 1, 0)
 	Pesgo1.setXData(0, 2, 0)
 	Pesgo1.setXData(0, 3, 0)

 	Pesgo1.setYData(0, 0, 0)
 	Pesgo1.setYData(0, 1, 0)
 	Pesgo1.setYData(0, 2, 0)
 	Pesgo1.setYData(0, 3, 0)

	// Set Various Other Properties ///
 	Pesgo1.setBitmapGradientMode ( false)
 	Pesgo1.setQuickStyle ( PEQS_DARK_LINE)
	// Set various properties //
 	Pesgo1.setMainTitle ( "Scientific Real-Time Example")
 	Pesgo1.setSubTitle ( "")
 	Pesgo1.setNoRandomPointsToExport ( true)
 	Pesgo1.setFocalRect ( false)
 	Pesgo1.setAllowBar ( false)
 	Pesgo1.setAllowPopup ( false)
 	Pesgo1.setPrepareImages ( true)
 	Pesgo1.setCacheBmp ( true)
 	Pesgo1.setFixedFonts ( true)
 	Pesgo1.setSubsetColors(0,  Pesgo1.PEargb(255, 0, 198, 198))
 	Pesgo1.setGradientBars ( 8)
 	Pesgo1.setTextShadows ( PETS_BOLD_TEXT)
 	Pesgo1.setMainTitleBold ( true)
 	Pesgo1.setSubTitleBold ( true)
 	Pesgo1.setLabelBold ( true)
 	Pesgo1.setLineShadows ( true)
 	Pesgo1.setFontSize ( PEFS_MEDIUM)
	// Improves metafile exports //
 	Pesgo1.setDpiX ( 600)
 	Pesgo1.setDpiY ( 600)
 	Pesgo1.setPEactions ( REINITIALIZE_RESETIMAGE)
  
}
var m_nSinCounter,m_nRealTimeCounter = 1,1;
winform.button9.oncommand = function(id,event){
	winform.setInterval(
		20,function(){
			newy = 50 + (math.sin(m_nSinCounter * 0.075) * 30) + (math.random() * 15)
			newx = m_nRealTimeCounter
			// Append new values  //
			Pesgo1.setYData(0, m_nRealTimeCounter, newy)
			Pesgo1.setXData(0, m_nRealTimeCounter, newx)
			
			Pesgo1.setVertLineAnnotation(0,newx)
  			Pesgo1.setVertLineAnnotationType(0,PELT_MEDIUMSOLID)
  			Pesgo1.setVertLineAnnotationColor(0,0x00FE00)

			m_nRealTimeCounter++;
			if(m_nRealTimeCounter==100){
				m_nRealTimeCounter = 0;
			}
			m_nSinCounter++;
			if(m_nSinCounter>30000){
				m_nSinCounter = 1;
			}
			
			Pesgo1.setPEnarg1(0)
    		Pesgo1.setPEnarg2( 0)
    		Pesgo1.setPEactions(REINITIALIZE_RESETIMAGE)//RESET_IMAGE)
		}
	);
}

GIF4.gif

2020-09-08   #10

看起来比ST_Curve好用呀

2020-11-29   #11

实用界面设置:

import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=1213;bottom=627)
winform.add(
button={cls="button";text="del";left=1100;top=593;right=1214;bottom=626;db=1;dr=1;z=2};
button2={cls="button";text="add";left=983;top=593;right=1097;bottom=626;db=1;dr=1;z=3};
button3={cls="button";text="create";left=866;top=593;right=980;bottom=626;db=1;dr=1;z=4};
static={cls="static";left=0;top=0;right=1214;bottom=592;bgcolor=8421376;db=1;dl=1;dr=1;dt=1;z=1}
)
/*}}*/

var pe = winform.static.createEmbed("PESGOE.PesgoeCtrl.1")
var Pesgo1 = pe._object;

//调用dll
var dll=raw.loadDll("PEGRP32E.DLL");
PEvset = dll.api("PEvsetA","long(ADDR hobj,INT npro,pointer data,INT nItems)" )

Pesgo1.setSubsets ( 1)
Pesgo1.setPoints ( 10000)
// Set Manual Y scale //'
//Pesgo1.setManualScaleControlY (0);//PEMSC_MINMAX)
//Pesgo1.setManualMinY ( 1)
//Pesgo1.setManualMaxY ( 100)
// Clear out default data //'
Pesgo1.setXData(0, 0, 0)
Pesgo1.setXData(0, 1, 0)
Pesgo1.setXData(0, 2, 0)
Pesgo1.setXData(0, 3, 0)

Pesgo1.setYData(0, 0, 0)
Pesgo1.setYData(0, 1, 0)
Pesgo1.setYData(0, 2, 0)
Pesgo1.setYData(0, 3, 0)

// Set Various Other Properties ///
Pesgo1.setBitmapGradientMode ( false)
Pesgo1.setBorderTypes ( 1);
// Set various properties //
Pesgo1.setMainTitle ( "Scientific Real-Time Example")
Pesgo1.setSubTitle ( "")
Pesgo1.setYAxisLabel ( "Y轴")
Pesgo1.setXAxisLabel ( "X轴")
Pesgo1.setNoRandomPointsToExport ( true)
Pesgo1.setFocalRect ( false)
Pesgo1.setAllowBar ( false)
Pesgo1.setAllowPopup ( true)
Pesgo1.setPrepareImages ( true)
Pesgo1.setCacheBmp ( true)
Pesgo1.setFixedFonts ( true)
Pesgo1.setSubsetColors(0,  Pesgo1.PEargb(128, 0, 0, 198))
Pesgo1.setGradientBars ( 8)
Pesgo1.setDpiX ( 600)
Pesgo1.setDpiY ( 600)
Pesgo1.setPEactions ( 0)

var insertData = function(x,y){
	var yy = {float d=0}
	yy.d = y;
	var xx = {float d=1}
	xx.d = x;
	newy = raw.buffer(yy);
	newx = raw.buffer(xx);
	// Append new values  //
	t = PEvset(Pesgo1.hObject, 3276, newy, 1)
	t = PEvset(Pesgo1.hObject, 3658, newx, 1)
	Pesgo1.setPEactions(0)
}

var index = 1;
winform.button2.oncommand = function(id,event){
	insertData(index,math.random(1,100));
	index++;
}

winform.show();
win.loopMessage();

image.png

增加辅助线:

	Pesgo1.setAnnotationsInFront(false)
   	Pesgo1.setLineAnnotationTextSize(110)
	Pesgo1.setShowAnnotations(true)
	Pesgo1.setHorzLineAnnotation(0,70)
	Pesgo1.setHorzLineAnnotationType(0,2)
	Pesgo1.setHorzLineAnnotationColor(0, Pesgo1.PEargb(255, 0, 0, 198))
	Pesgo1.setHorzLineAnnotationText(0,"合格线")
	Pesgo1.setHorzLineAnnotationAxis(0,0)

image.png


工程下载: pppp.zip

注意自己手动注册下里面的ocx

2020-11-29   #12

经典使用示例:

import win.ui;
/*DSG{{*/
var winform = win.form(text="波形图";right=871;bottom=372)
winform.add(
static={cls="static";left=0;top=0;right=872;bottom=373;bgcolor=8421376;db=1;dl=1;dr=1;dt=1;notify=1;z=1}
)
/*}}*/

var pe = winform.static.createEmbed("PESGOE.PesgoeCtrl.1")
var Pesgo1 = pe._object;
 
//调用dll
var dll=raw.loadDll("PEGRP32E.DLL");
PEvset = dll.api("PEvsetA","long(ADDR hobj,INT npro,pointer data,INT nItems)" )

var initPe = function(num=100,title=""){
    Pesgo1.PEreset();
	Pesgo1.setSubsets ( 1)
	Pesgo1.setPoints ( num)
	// Set Manual Y scale //'
	//Pesgo1.setManualScaleControlY (0);//PEMSC_MINMAX)
	//Pesgo1.setManualMinY ( 1)
	//Pesgo1.setManualMaxY ( 100)
	// Clear out default data //'
	Pesgo1.setXData(0, 0, 0)
	Pesgo1.setXData(0, 1, 0)
	Pesgo1.setXData(0, 2, 0)
	Pesgo1.setXData(0, 3, 0)
 	
	Pesgo1.setYData(0, 0, 0)
	Pesgo1.setYData(0, 1, 0)
	Pesgo1.setYData(0, 2, 0)
	Pesgo1.setYData(0, 3, 0)
 	
	// Set Various Other Properties ///
	Pesgo1.setBitmapGradientMode ( false)
	Pesgo1.setBorderTypes ( 1);
	// Set various properties //
	Pesgo1.setMainTitle ( title)
	Pesgo1.setSubTitle ( "")
	Pesgo1.setYAxisLabel ( "")
	Pesgo1.setXAxisLabel ( "")
	Pesgo1.setNoRandomPointsToExport ( true)
	Pesgo1.setFocalRect ( false)
	Pesgo1.setAllowBar ( false)
	Pesgo1.setAllowPopup ( false)
	Pesgo1.setPrepareImages ( true)
	Pesgo1.setCacheBmp ( true)
	Pesgo1.setFixedFonts ( true)
	Pesgo1.setSubsetColors(0,  Pesgo1.PEargb(128, 0, 0, 198))
	Pesgo1.setGradientBars ( 8)
	Pesgo1.setDpiX ( 600)
	Pesgo1.setDpiY ( 600)
	Pesgo1.setPEactions ( 0)
}

var subLine = function(vData,title="合格线"){
	Pesgo1.setAnnotationsInFront(false)
    Pesgo1.setLineAnnotationTextSize(110)
    Pesgo1.setShowAnnotations(true)
    Pesgo1.setHorzLineAnnotation(0,vData)
    Pesgo1.setHorzLineAnnotationType(0,2)
    Pesgo1.setHorzLineAnnotationColor(0, Pesgo1.PEargb(255, 0, 0, 198))
    Pesgo1.setHorzLineAnnotationText(0,title)
    Pesgo1.setHorzLineAnnotationAxis(0,0)
}

var insertData = function(x,y){
    var yy = {float d=0}
    yy.d = y;
    var xx = {float d=1}
    xx.d = x;
    newy = raw.buffer(yy);
    newx = raw.buffer(xx);
    // Append new values  //
    t = PEvset(Pesgo1.hObject, 3276, newy, 1)
    t = PEvset(Pesgo1.hObject, 3658, newx, 1)
    Pesgo1.setPEactions(0)
}

initPe(100,"实时功率计");

import thread.command;
var thFun = thread.command();
thFun.initCurve = function(num,title){
	initPe(num,title);
}
thFun.insertLine = function(vData,title){
	subLine(vData,title);
}
thFun.addData = function(x,y){
	insertData(x,y);
}

winform.show();
win.loopMessage();
return winform;


2021-05-01   #13

3D波形图演示

image.png

import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=759;bottom=469)
winform.add(
button={cls="button";text="Button";left=0;top=433;right=136;bottom=470;db=1;dl=1;z=2};
static={cls="static";text="Static";left=0;top=0;right=760;bottom=426;db=1;dl=1;dr=1;dt=1;transparent=1;z=1}
)
/*}}*/

import console
console.open()


//调用dll
var dll=raw.loadDll("PEGRP32E.DLL","PEGRP32E");
PEvset = dll.api("PEvsetA","long(ADDR hobj,INT npro,pointer data,INT nItems)" )


var Tdctrl = winform.static.createEmbed("PE3DOE.Pe3doeCtrl.1");
var Pe3do1 = Tdctrl._object;
Pe3do1.PEreset()



Pe3do1.setMouseDraggingX ( true)
Pe3do1.setMouseDraggingY ( true)
var index = 0;
var xbuf = { float data[10000]={} };
var zbuf = { float data[10000]={} };
var ybuf = { float data[10000]={} };
for(Row=0;99;1){
	for(Col=1;100;1){
		index = (Row * 100) + Col;
		xbuf.data[index] = Col;
		zbuf.data[index] = Row;
		ybuf.data[index] =  math.random()*1000;
	}
}


Pe3do1.setSubsets(100)
Pe3do1.setPoints(100)


var newx = raw.buffer(xbuf);
var newz = raw.buffer(zbuf);
var newy = raw.buffer(ybuf);

PEvset(Pe3do1.hObject, 2135, newx, 10000);
PEvset(Pe3do1.hObject, 2140, newy, 10000);
PEvset(Pe3do1.hObject, 2900, newz, 10000);

Pe3do1.setXZBackColor ( 1)
Pe3do1.setYBackColor ( 1)

Pe3do1.setPlottingMethod ( 1)
// Set various other properties //
Pe3do1.setBitmapGradientMode ( true)
Pe3do1.setQuickStyle ( 11)//PEQS_DARK_LINE
Pe3do1.setSimplePointLegend ( true)
Pe3do1.setSimpleLineLegend ( true)
Pe3do1.setLegendStyle (1 )//PELS_1_LINE
Pe3do1.setMainTitle ( "3d demo in aardio")
Pe3do1.setSubTitle ( "chengxu.xyz")
Pe3do1.setViewingHeight ( 20)
Pe3do1.setDegreeOfRotation ( 275)
Pe3do1.setFixedFonts ( true)
Pe3do1.setFontSize (0 )//PEFS_LARGE
Pe3do1.setPrepareImages ( true)
Pe3do1.setCacheBmp ( true)
Pe3do1.setFocalRect ( false)
Pe3do1.setShadingStyle (0 )//PESS_WHITESHADING
Pe3do1.setShowBoundingBox (2 )//PESBB_NEVER
Pe3do1.setTextShadows (1 )//PETS_BOLD_TEXT
Pe3do1.setMainTitleBold ( true)
Pe3do1.setSubTitleBold ( true)
Pe3do1.setLabelBold ( true)
// Improves metafile exports //
Pe3do1.setDpiX ( 600)
Pe3do1.setDpiY ( 600)
Pe3do1.setRenderEngine (0 )//PERE_GDIPLUS
Pe3do1.setAntiAliasGraphics ( true)
Pe3do1.setAntiAliasText ( true)


winform.button.oncommand = function(id,event){
	var index = 0;
var xbuf = { float data[10000]={} };
var zbuf = { float data[10000]={} };
var ybuf = { float data[10000]={} };
for(Row=0;99;1){
	for(Col=1;100;1){
		index = (Row * 100) + Col;
		xbuf.data[index] = Col;
		zbuf.data[index] = Row;
		ybuf.data[index] = math.random()*1000;
	}
}

var newx = raw.buffer(xbuf);
var newz = raw.buffer(zbuf);
var newy = raw.buffer(ybuf);

PEvset(Pe3do1.hObject, 2135, newx, 10000);
PEvset(Pe3do1.hObject, 2140, newy, 10000);
PEvset(Pe3do1.hObject, 2900, newz, 10000);

Pe3do1.PEreconstruct3dpolygons();
Pe3do1.setPEactions(2);
Pe3do1.setPEactions(3);

}




winform.show();
win.loopMessage();


2021-05-02   #14

再更新一点.

最近用光束分析仪的时候了解了结构体struct的使用, 所以这里的PEvset

也可以用结构体定义, 这样省的用raw.buff包装了.

//调用dll
var dll=raw.loadDll("PEGRP32E.DLL","PEGRP32E");
PEvset = dll.api("PEvsetA","long(ADDR hobj,INT npro,struct data,INT nItems)" )

image.png

这个3d图表生成静态速度蛮快的, 但是如果按照上面的方式做成动态显示速度就不行了.

2022-01-01   #15

2021最新版ProEssentials Pro v9.8 版本下载:

链接:https://pan.baidu.com/s/1Le6zNBdqJaRMpYOc-ZJfHQ 

提取码:k0mc

image.png

登录后方可回帖

登 录
信息栏
 私人小站

本站域名

ChengXu.XYZ

投诉联系:  popdes@126.com



快速上位机开发学习,本站主要记录了学习过程中遇到的问题和解决办法及上位机代码分享

这里主要专注于学习交流和经验分享.
纯私人站,当笔记本用的,学到哪写到哪.
如果侵权,联系 Popdes@126.com

友情链接
Aardio官方
Aardio资源网


才仁机械


网站地图SiteMap

Loading...