from PySide2.QtCore import QRect
from axipy import provider_manager, Layer, Map, view_manager, Rect, Pnt, LinearUnits, MapReportItem


def openTables(path_tabs):
    list_tabs=[]
    for path in path_tabs:
        list_tabs.append(provider_manager.openfile(path))
    return list_tabs
def createMap(tabs):
    layers=[]
    for tab in tabs:
        layers.append(Layer.create(tab))
    '''
    for layer in layers:
        layer.visible=False
    '''
    map=Map(layers)
    return map
list_tab_path=[r"E:\Support\ImportAxiomaWor\proekt_1690358665\Adm\AdmBorder.TAB",r"E:\Support\ImportAxiomaWor\proekt_1690358665\Land\LandUse.TAB"]
tabs=openTables(list_tab_path)
map=createMap(tabs)
map_view=view_manager.create_mapview(map)
map_view.rect=Rect(0,0, 3642.122, 5149.21)
map_view.coordsystem=tabs[0].coordsystem
map_view.center=Pnt(2377637.675, 593564.0597)
map_view.set_zoom_and_center(42.05,map_view.center,LinearUnits.km)

''''Report '''
report_view = view_manager.create_reportview()
report_view.position=QRect(622, 431, 816, 722)
report=report_view.report
report.unit=LinearUnits.inch
map_item=MapReportItem(Rect(0.0, 0.0, 33.1102, 46.811),map_view.map)
report.items.add(map_item)