LUALoriotPro WEB site

LoriotPro scripting documentation
Extensions for LUA language

Table of contents Search function

Print the current page Mail this  link UTUBE Channel version française

lpav.Insert - Insert a new graphical object

LoriotPro has extended the LUA sripting language by providing its own LUA libraries. The new functions provided are dedicated to the creation of monitoring and SNMP automation application.

Syntax 

result = lpav.Insert(x,y,cx,cy,type);

Description

Insert a new graphical object in an Active View. The inserted object become the default object.

Parameters

X The X position of the object, the number of pixel from the right border of the Active View display area (must be positive)
Y The Y position of the object, the number of pixel from the top border the Active View display area (must be positive)
Cx The width of the object in pixel (must be positive)
Cy The high of the object in pixel (must be positive)

type - The type of object defined in the file loriotinit.lua. LoriotPro will choose the icon that fit with this type.

--lpav object type define --lpav_InsertObject

LPAV_OBJ_WORLD =0;
LPAV_OBJ_COUNTRY =1;
LPAV_OBJ_ORGANIZATION =2;
LPAV_OBJ_ORGANIZATION_UNIT = 3;
LPAV_OBJ_NETWORK =4;
LPAV_OBJ_HOST_1 =6;
LPAV_OBJ_ROUTER =7;
LPAV_OBJ_SHORTCUT_1 =8;
LPAV_OBJ_SHORTCUT_2 =9;
LPAV_OBJ_MRTG =10;
LPAV_OBJ_PLUGIN =11;
LPAV_OBJ_BADPLUGIN = 12;
LPAV_OBJ_LORIOTPRO = 13;
LPAV_OBJ_HOST_2_ROUTER = 15;
LPAV_OBJ_HOST_3_SWITCH =16;
LPAV_OBJ_HOST_4 = 17;
LPAV_OBJ_HOST_5 = 18;
LPAV_OBJ_HOST_6 = 19;
LPAV_OBJ_VIEWPLUGIN =20
LPAV_OBJ_HOST_SERVER = 27;
LPAV_OBJ_HOST_IMPRIMANTE =28;
LPAV_OBJ_HOST_PHONE =29;
LPAV_OBJ_RECT = 30; LPAV_OBJ_CIRCLE = 31; LPAV_OBJ_FILL_RECT = 32; LPAV_OBJ_FILL_CIRCLE = 33; LPAV_OBJ_H_LINE = 34; LPAV_OBJ_V_LINE = 35; LPAV_OBJ_DIR_EMF = 36; LPAV_OBJ_TEXT = 37; LPAV_OBJ_FILL_TEXT = 38; LPAV_OBJ_FULL_RECT = 39; LPAV_OBJ_FULL_CIRCLE = 40; LPAV_OBJ_H45_LINE = 41;
LPAV_OBJ_V45_LINE = 42;
LPAV_OBJ_FULL_TEXT = 43;
LPAV_OBJ_BASIC_SHAPE = 44;
LPAV_OBJ_ANALOGIC_METER_01 = 45;
LPAV_OBJ_HOST_HUB = 46;
LPAV_OBJ_CONNECTOR =144;

Return Values

result =1 if the object is correctly inserted either return nil

Example

A complete example that use many graphical function

lp_value = 0;
lp_buffer ="error";

dofile(lp.GetPath().."/config/script/loriotinit.lua");

zz=LPAV_OBJ_ANALOGIC_METER_01;

-- Créé des objects r s
k=0;
for i=0,20 do
lpav.Insert(10*i,1,9,9,zz);
if (k==0) then lpav.SetRef(1,"r"); k=1; else lpav.SetRef(1,"s"); k=0; end
lpav.SetBrush(0,255,0);
lpav.SetFontName("Mistral");
lpav.SetName(i);
lpav.SetClipart( lp.GetPath().."/card/vumeters/vumeter8.emf");
lpav.SetOption(LPAV_UNIT,"%");
end
zz=LPAV_OBJ_FILL_CIRCLE;
-- Créé des objects s r
for i=0,20 do
lpav.Insert(10*i,30,9,9,zz);
if (k==0) then lpav.SetRef(1,"s"); k=1; else lpav.SetRef(1,"r"); k=0; end
lpav.SetBrush(0,255,0);
lpav.SetName("test-r"..i);
lpav.SetOption(LPAV_LINESTYLE,55);
end

lpav.ClearAllSelected()
--lpav.DeleteAllSelected();
i=lpav.FindRef(1,0,"r","a");
if (i>0) then
for j=0, i do
-- lp.Trace("pass"..j);
if lpav.SelectUID(a[j]) then
lpav.SetLineColor(255,45,89);
lpav.SetLineWidth(3);
end
end
end
i=lpav.FindRef(1,0,"s","aa");
if (i>0) then
for j=0, i do
--lp.Trace("pass"..j);
if lpav.SelectUID(aa[j]) then
lpav.SetLineColor(255,45,255);
lpav.SetLineWidth(5);
x,y,x1,y1=lpav.GetPosition();
lpav.SetPosition(x,y+10,x1,y1);
lpav.Insert(1,1,100,100,LPAV_OBJ_CONNECTOR);
lpav.SetOption(LPAV_CONNECTED_TO1,a[j]);
lpav.SetOption(LPAV_CONNECTED_TO2,aa[j]);
lpav.SetOption(LPAV_LINEWIDTH,1);
lpav.SetLineColor(100,45,45);
end
end
end
lp.Trace("fin");
lpav.RefreshMap();




www.loriotpro.com