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

getObjectID()

Read the ID of objects.


setPos( x, y )

Set the location of objects using x, y coordination.

variant

getProperty( propertyName )

Read the property of objects.


setProperty( propertyName, value )

Change the property of objects.


addEventAction( actionName, handler )

Register an event script on objects.


  str getObjectID()

 

  Read the ID of objects.



  Example)

   


       obj =  canvas.getObject('Rect1')

       id = obj.getObjectID()

       print id


   



  setPos( x:x coordination, y:y coordination )

 

  Set the location of objects using x, y coordination.



  Example)

   


       obj =  canvas.getObject('Rect1')

       obj.setPos(30.1 , 40 )


   



  variant  getProperty( property:Properties )

 

  Obtain the property value of graphic objects.



  Example)

   


       obj =  canvas.getObject('Rect1')

       width = obj.getProperty('Width')   #Read the width of objects


   



  setProperty( property:Properties, value:Values )

 

  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.

   




  addEventAction( actionName, handler )

 

  Register an event action dynamically for graphic objects.


   actionName is the type of event. It can use the following factors.

     

    • 'mouserelease' : Mouse released
    • 'mousepress'   : Mouse pressed
    • 'mousehover'   : Mouse hovered
    • 'mouseleave'   : Mouse left
    • 'mousedoubleclick' : Mouse double-clicked



  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