canvas
canvas
canvas represents a canvas. canvas object provides canvas methods. Main functions are obtaining graphic items, executing timer, executing animations, maximizing / minimizing canvases.
Methods
Return Type |
Method |
Description |
clearMark( shape ) |
Release the setMark of that object(shape). |
|
Script closes the running canvas. |
||
closeMe() |
Close the currently active canvas. |
|
connectValueChange( func, pointNames ) |
포인트값 변경시 수신되는 이벤트 핸들러를 등록합니다. |
|
PowerShape |
createObject( objType, layerName ) |
Create a graphic object and add it to a specified layer. |
str |
fileName() |
Obtain the file path of the script executed canvas. |
Fit a canvas on the screen. |
||
list[str] |
Obtain the name of all graphic objects on the canvas. |
|
PowerShape |
getObject( targetObj ) |
Obtain the selected graphic object. |
list[str] |
getObjectNamesInLayer( layer ) |
Obtain the name of graphic objects belonging to the specified layer. |
PowerShape |
Obtain the graphic object on the mouse cursor. |
|
boolean |
isLayerVisible( layer ) |
Obtain the state of the layer visible / invisible |
maximize() |
Maximize the canvas. |
|
minimize() |
Minimize the canvas. |
|
moveAnimation( targetObj, xLength, yLength, msec, repeat, curve ) |
Move the selected graphic object(targetObj) for the specified distance for the specified time(msec). |
|
moveAnimation( name, xLength, yLength, msec, repeat, curve ) |
Move the selected graphic object(name) for the specified distance for the specified time(msec). |
|
moveOnCurveAnimation( moveObj, targetObj, dir, msec, repeat ) |
The graphic object(moveObj) moves on the direction of the selected graphic object(targetObj) for the specified time(msec). |
|
opacityAnimation( targetObj, start, end, msec, repeat, curve ) |
Change the transparency of selected graphic object(targetObj). |
|
replacePointName( texts ) |
Change the point name on that canvas. |
|
replacePointName2( objs, texts ) |
Change the point name selecting certain graphic objects. |
|
rotateAnimation( targetObj, angle, x, y, duration, repeat ) |
Maximize / Minimize the selected graphic object to the size of x,y for the specified time(msec). |
|
rotateAnimation2( targetObj, angle, x, y, duration, repeat ) |
Rotate the selected graphic object. |
|
saveScreen( loaction ) |
Capture the current screen and save it in the folder. |
|
scaleAnimation( targetObj, x, y, msec, repeat, ankor ) |
Rotate the selected graphic object by a specified angle. |
|
scrollAnimation( name, direction, msec ) |
Scroll the selected graphic object(name) for the specified direction for the specified time(msec). |
|
pyShape |
Obtain the selected graphic object. |
|
setInterval( functionName, msec ) |
Execute the method regularly for the specified time interval. |
|
setLayerVisible( layer, visible ) |
Set the layer visible / invisible. |
|
setMark( shape ) |
Display the object(shape) on the canvas. |
|
setZoomLevel( level ) |
Set the zoomLevel of canvases. |
|
Display the canvas on the top. |
||
singleShot( functionName, msec ) |
Execute the method once after the specified time(msec). |
|
startBlink( targetObj, msec ) |
Give a blinking effect on the selected graphic object(tatgetObj). |
|
stopBlink( targetObj ) |
Stop the startBlink of the selected object. |
|
stopBlink2( name ) |
Stop the startBlink of the selected object. |
|
stopInterval( functionName ) |
Stop the setInterval method. |
|
stopMoveAnimation( targetObj ) |
Stop the moveAnimation of the selected object. |
|
stopMoveAnimation2( name ) |
Stop the entered moveAnimation. |
|
stopOpacityAnimation( targetObj ) |
Stop the opacityAnimation of the selected object. |
|
stopOpacityAnimation2( name ) |
Stop the opacityAnimation of the selected object. |
|
stopRotateAnimation( targetObj ) |
Stop the rotateAnimation of the selected object. |
|
stopRotateAnimation2( name ) |
Stop the rotateAnimation of the selected object. |
|
stopScaleAnimation( targetObj ) |
Stop the scaleAnimation of the selected object. |
|
stopScaleAnimation2( name ) |
Stop the scaleAnimation of the selected object. |
|
캔버스가 닫힐 때까지 대기합니다. |
||
float |
Read the zoom level of canvases. |
Obtain the graphic object(targetObj). ㆍ The way of entering targetObj is as follows: 1) Single object : Enter 'Graphic name' to targetObj. 2) Group object : Enter 'Group name.Graphic name' to targetObj. Example) 'Group_1.Arc_1' ㆍ The graphic object obtained by getObject is used for the parameter of various functions on the canvas, and could change the state of graphic objects through getProperty, setProperty. ㆍ The detail of graphic objects is introduced in chapter 11.
Example) Change the fill color of a single graphic object.
obj = canvas.getObject('BlueCircle'); << Obtain 'BlueCircle'. obj.setProperty('BrushColor', QColor(255, 0, 0)); << Change the fill color of obtained object as QColor(255,0,0).
|
|
Example) Change the fill color of a group graphic object.
obj = canvas.getObject('GroupA.A'); << Obtain 'A' on the 'GroupA' obj.setProperty('BrushColor', QColor(255, 0, 0)); << Change the fill color of the obtained object as QColor(255,0,0).
|
|
Execute the user-defined expression for every msec time(1000 = 1 second). ㆍ exp is entered as String. ㆍ msec is entered as Numeric. Example)
canvas.setInterval('setDateTime()', 1000); << Execute setDateTime for every second.
|
The following is the result of time displaying using setInterval. |
|
|
Stop the expression that the user set. ㆍ exp is entered as String. Example)
canvas.stopInterval('setDateTime()'); << Stop setDateTime.
|
Stop setDateTime() by stopInterval. |
|
|
Execute the expression that the user set after the setup time(msec 1000 = 1 second) ㆍ exp is entered as String. ㆍ msec is entered as Numeric. Example)
canvas.singleShot('SingleShow()', 1000 ); << Execute SingleShow after a second.
|
singleShot works as follows: |
|
Display the shape object on canvases. ㆍ Enter the graphic object of canvases to shape. Example)
Ob = canvas.getObject('LED2-OFF_1'); << Obtain 'LED2-OFF_1'. canvas.setMark(Ob); << Display the obtained graphic object.
|
The following is an example of How setMark works. |
|
Release the setMark of shape objects on a canvas. ㆍ Enter the graphic object to shape. Example)
Ob = canvas.getObject('LED2-OFF_1'); << Obtain 'LED2-OFF_1' canvas.clearMark(Ob); << Release the setMark of the obtained graphic object.
|
The following is an example of How clearMark works. |
|
Stop the moveAnimation of targetObj. Example)
obj1 = canvas.getObject('Image'); << Obtain 'Image' object.
canvas.stopMoveAnimation(obj1); << Stop the moveAnimation of obtained graphic object.
|
Stop the moveAnimation of graphic objects(name). Example)
canvas.stopMoveAnimation2('Image'); << Stop the moveAnimation of 'Image'.
|
Stop the rotateAnimation of targetObj.
Example)
obj1 = canvas.getObject('Windmill'); << Obtain 'Windmill' object. canvas.stopRotateAnimation(obj1); << Stop the rotateAnimation of the obtained graphic object.
|
Stop the rotateAnimation of graphic objects(name).
Example)
canvas.stopRotateAnimation2('Windmill'); << Stop the rotateAnimation of 'Windmill'.
|
Stop the scaleAnimation of targetObj.
Example)
obj1 = canvas.getObject('Image'); << Obtain 'Image' object. canvas.stopScaleAnimation(obj1); << Stop the scaleAnimation of the obtained object.
|
Stop the scaleAnimation of graphic objects(name).
Example)
canvas.stopScaleAnimation2('Image'); << Stop the scaleAnimation of 'Image'.
|
Stop the opacityAnimation of targetObj.
Example)
obj1 = canvas.getObject('Image'); << Obtain 'Image' canvas.stopOpacityAnimation(obj1); << Stop the opacityAnimation of the obtained object.
|
Stop the opacityAnimation of graphic objects(name).
Example)
canvas.stopOpacityAnimation2('Image'); << Stop the opacityAnimation of 'Image'.
|
Stop the blinking of graphic objects(targetObj).
Example)
obj1 = canvas.getObject('BlueCircle'); << Obtain 'BlueCircle'. canvas.stopBlink(obj1); << Stop the blinking of the graphic object.
|
Stop the blinking of graphic objects(name).
Example)
canvas.stopBlink('BlueCircle'); << Stop the blinking of 'BlueCircle'.
|
Users can change the random point name that the user sets when the data link. ㆍ Available point names are two things. 1) Real point name. 2) User-defined point name. ㆍ When setting a user-defined point name, the user can change it to the real point name using replacePointName. ㆍ Enter String or a list of String to texts. - The format is entered a random point name at the front and a real point name at the back based on a colon( : ). - If 1 point name to change : Enter as String Example) 'Random point name:Station name.Point name' - If more than 2 point names to change : Enter as a list of String Example) ['Random point name1:Station name1.Point name1', 'Random point name2:Station name2.Point name2'] Example) If 1 point name to change - Random point name : A1 - Real point name : Charger 1.Charging state
canvas.replacePointName( 'A1:Charger 1.Charging state' ); << Change 'A1' to 'Charger 1.Charging state'.
|
[ Data link with a random point name ] |
[ Data link with a real point name ] Example) If more than 2 point names to change - Random point name : A1, A2 - Real point name : Charger 1.Charging state, Charger 1.Car SOC
canvas.replacePointName( ['A1:Charger 1.Charging state', 'A2:Charger 1.Car SOC'] ); << Change 'A1' and 'A2' to 'Charger 1.Charging state' and 'Charger 1.Car SOC' respectively.
|
[ Data link with a random point name ] [ Data link with a real point name ] |
Obtain the visible / invisible state of layers. The return type is boolean. ㆍ If the layer is visible, return TRUE(1). ㆍ If the layer is invisible, return FALSE(0).
Example)
Layer1 = canvas.isLayerVisible('Layer 1'); << Obtain the visible / invisible state of 'Layer 1'. Layer2 = canvas.isLayerVisible('Layer 2'); << Obtain the visible / invisible state of 'Layer 2'.
|
This is an example of How isLayerVisible works. |
|
Close the canvas that scripts are running. Example)
canvas.closeCanvas(); << Close the canvas.
|
This is an example of How closeCanvas works. |
|
Read the path of canvas that scripts are running. The return type is String. Example)
canvas_File_Name = canvas.fileName(); << Read the path of canvases.
|
This is an example of output using messageBox. |
|
Read the maximizing / minimizing ratio of canvases. The return type is float. ㆍ The default ratio is 1.0. Example)
Zoom_Value= canvas.zoomLevel(); << Read the maximizing / minimizing ratio of canvases.
|
This is an example of zoomLevel. |
|
Set the maximizing / minimizing zoom level of canvases. level is entered as Numeric. ㆍ The default ratio is 100. Example)
canvas.setZoomLevel(100); << Set the maximizing / minimizing zoom level of the canvas as 100.
|
This is an example of using setZoomLevel on the button. |
|
Maximize the canvas. Example)
canvas.maximize(); << Maximize the canvas.
|
This is an example of How maximize works. |
|
Minimize the canvas. Example)
canvas.minimize(); << Minimize the canvas.
|
This is an example of How minimize works. |
|
Fit the canvas on PowerScene window size to display the whole canvas. Example)
canvas.fitInScreen(); << Fit the canvas on PowerScene window size.
|
This is an example of How fitInScreen works. |
|
Obtain the graphic object user selected. Example)
Obj1 = canvas.selectedObject(); << Obtain the graphic object user selected.
|
This is a screen that text information output of user selected object. |
|
Capture the current canvas screen and save it on the path. ㆍ The file is saved on the path with the name as 'Canvas name_Current hour_Current minute_Current second'. ㆍ Enter the folder path to the location Example)
canvas.saveScreen('c:\'); << Capture the current canvas screen and save it on c:\.
|
This is the result of saving current canvas screen on 'c:\'. |
This is the result of opening the saved image. |
closeMe() |
Close the current active canvas Example)
canvas.closeMe(); << Close the current active canvas.
|
This is the result of closeMe. |
|
Obtain the name of all graphic objects in the canvas. Example)
objList = canvas.getAllObjectNames(); << Obtain the name of all graphic objects as a list.
|
This is the result of getAllObjectNames. |
|
Display the canvas on the forward. When canvases overlaid, showTopLevel brings the canvas to the forward. Example)
canvas.showTopLevel() << Display the canvas on the forward.
|
Read the object on the mouse cursor. Example)
obj = canvas.hoveredObject() << Read the object on the mouse cursor.
|
moveOnCurveAnimation( moveObj:Graphic objects to move, targetObj:Graphic objects, dir:Location, msec:Time, repeat:Repeat times ) |
moveOnCurveAnimation is a moving animation following towards targetObj. ㆍ moveObj is a graphic object to move. ㆍ moveObj moves on the targetObj. ㆍ dir represents the location when 0 entered, moveObj moves from the start point of targetObj to the end point of targetObj. When 1 entered, moves from the end point of targetObj to the start of targetObj. ㆍ Start point : 0 ㆍ End point : 1 ㆍ msec is a time, 1000msec equals a second. ㆍ repeat is the number of repetitions, the default value is 0, when repeat is 0, repeat to infinity. Below is an example of moveOnCurveAnimation. Example)
canvas.moveOnCurveAnimation('arrow', 'Line_1', 0, 3000) << 'arrow' object moves from the start point of 'Line_1' to the end point of 'Line_1' for 3 seconds and repeat to infinity.
|
|
scrollAnimation( name:Graphic objects to move, direction:Direction, msec:Time ) |
Graphic images(name) move to the specified direction for the specified time infinitely. For example, the lower caption of breaking news. ㆍ name is a graphic object to move. ㆍ direction represents a direction, when 0 is entered, move from left to right. When 1 is entered, move from right to left. ㆍ msec represents time, 1000msec equals a second. Below is an example of news object moves from left to right for 3 seconds. Example)
canvas.scrollAnimation('news', 0, 3000) << 'news' object moves from left to right for 3 seconds infinitely.
|
|
입력한 포인트값이 변경될 때 등록된 이벤트 핸들러 함수가 실행됩니다.
ㆍ func 에는 실행될 핸들러 함수를 입력합니다. ㆍ 핸들러 함수의 name 에는 변경된 포인트값의 이름이 전달됩니다. ㆍ 핸들러 함수의 value 에는 변경된 포인트값이 전달됩니다. ㆍ pointNames 에는 포인트명을 리스트형태로 입력합니다. 예)
def handleChange(name, value): if name == 'COM.1 충전상태': batteryObj = canvas.getObject('GroupBattery_1') elif name == 'COM.2 충전상태': batteryObj = canvas.getObject('GroupBattery_2') chargeObj = batteryObj.getObject('GroupCharge') dischargeObj = batteryObj.getObject('RectDischarge') if value == 0: chargeObj.setProperty('Visible', 0) dischargeObj.setProperty('Visible', 1) else: chargeObj.setProperty('Visible', 1) dischargeObj.setProperty('Visible', 0) lst = ['COM.1 충전상태', 'COM.2 충전상태'] canvas.connectValueChange(handleChange, lst) |
'COM.1 충전상태', 'COM.2 충전상태' 포인트값의 변경에 따라 그래픽 개체의 보이기/감추기 속성이 변경됩니다.
|
캔버스 표시모드가 '윈도우 창 띄우기', '팝업' 인 캔버스가 닫힐 때까지 대기합니다. 아래는 추가버튼을 눌러 띄운 사용자 팝업에서 사용자를 추가한 후 사용자 목록을 갱신하는 예시입니다. 예)
# 추가버튼 마우스 누름 스크립트 userAddPopup = canvasManager.open(u'사용자_팝업.pws') # 사용자 추가 팝업을 띄웁니다. userAddPopup.waitForClose() # 사용자 추가 팝업이 종료될때까지 대기합니다. updateUserList(canvas.getObject('TextTable_1')) # 사용자 목록 텍스트테이블을 갱신합니다.
|
추가 버튼을 눌러 사용자 추가 팝업을 띄우면 waitForClose() 에서 팝업 종료까지 대기합니다. 사용자 정보 입력 후 확인을 눌러 팝업이 닫히면 다음 스크립트인 updateUserList() 가 실행됩니다. |