Graphic Objects
Graphic Objects
PowerShape refers to graphic objects on a canvas. Each graphic object on canvas has a name and is able to set the property by using scripts.
PowerScene provides the following graphic objects.
- Rectangle
- Ellipse
- Polygon
- Line
- Connection
- Pie
- Arc
- Images
- SVG images
- GIF images
- Gauge
- Trend widget
- Gauge bar
- Multi color expression object(Pie chart, ratio bar)
- Widget - Push button, Combo box, Check box, Tree widget, Date / Time widget, Grid widget
Generally, graphic items are able to change the property through PowerScene Studio. However, to change the property dynamically, the user can use scripts.
<Widget>
Widget is accessible through scripts to receive properties or events.
Use Example)
obj = canvas.getObject(‘PowerShape name’)
obj.setProperty(‘FaceText’, ‘Change to String’)
widgetObj = canvas.getObject(‘widget name’)
Graphic objects set the graphic object by calling methods or changing the value of properties. Every graphic object provides the following methods.
Methods
Return type |
Method |
Description |
str |
Read the ID of objects. |
|
Set the location of objects using x, y coordination. |
||
variant |
Read the property of objects. |
|
Change the property of objects. |
||
Register an event script on objects. |
Read the ID of objects. Example)
obj = canvas.getObject('Rect1') id = obj.getObjectID() print id
|
Set the location of objects using x, y coordination. Example)
obj = canvas.getObject('Rect1') obj.setPos(30.1 , 40 )
|
Obtain the property value of graphic objects. Example)
obj = canvas.getObject('Rect1') width = obj.getProperty('Width') #Read the width of objects
|
Set the property of graphic objects. Example)
obj = canvas.getObject('Rect1') obj.setProperty('PenColor' , QColor(255,0,0,0 ) ) # Change the line color of objects as red.
|
Register an event action dynamically for graphic objects. actionName is the type of event. It can use the following factors.
Example)
def handleMousePressed(): print 'clicked' obj = canvas.createObject('rectShape') #Create a rectangle object. obj.setPos(50,50 ) #Move the object obj.addEventAction('mousepress' , 'handleMousePressed()' ) #Register the mouse pressed event on the object
|