Exemple #1
0
    def create_background_layout_item(self):
        """
        This creates the background specific item content
        :return: 
        """
        layout_units = dict_units[self.arc_doc.PageLayout.Page.Units]
        bounds = self.arc_doc.PageLayout.Page.PrintableBounds

        back_ground_size = "{},{},{}".format(bounds.Width, bounds.Height,
                                             layout_units)

        basic_element = LayoutItem.create_layout_item_basic(self)
        LayoutItem.create_frame_element(self, basic_element)
        LayoutItem.create_background_element(self, basic_element)

        basic_element.setAttribute("size", back_ground_size)
        basic_element.setAttribute("frame", "false")
        basic_element.setAttribute("outlineWidthM",
                                   "0.3,{units}".format(units=layout_units))
        basic_element.setAttribute("positionOnPage",
                                   "0,0,{units}".format(units=layout_units))
        basic_element.setAttribute("position",
                                   "0,0,{units}".format(units=layout_units))

        basic_element.setAttribute("templateUuid",
                                   "{af5f0d73-7e44-42df-93ee-adea0eac5f05}")
        basic_element.setAttribute("uuid",
                                   "{af5f0d73-7e44-42df-93ee-adea0eac5f05}")
        basic_element.setAttribute("type", "65638")

        basic_element.setAttribute("groupUuid", "")
        basic_element.setAttribute("frameJoinStyle", "miter")
Exemple #2
0
 def __init__(self, dom, parent_element, mxd, arc_doc):
     """
     This function creates the BackGroundPageElement
     :param dom: the Document Object Model
     :param parent_element: the main layout element, where to put the layout-items
     :param mxd: the arcpy mxd-document
     :param arc_doc: the ArcObject IMxDocument
     """
     LayoutItem.__init__(self, dom, parent_element, None, mxd, arc_doc)
     self.dom = dom
     self.parent_element = parent_element
     self.mxd = mxd
     self.arc_doc = arc_doc
Exemple #3
0
 def __init__(self, dom, parent_element, line_object, mxd, arc_doc):
     """
     This function creates a Line-Item for the layout
     :param dom: the Document Object Model
     :param parent_element: the main layout element, where to put the layout-items
     :param line_object: the line_object as ArcObject
     :param mxd: the arcpy mxd-document
     :param arc_doc: the ArcObject IMxDocument
     """
     LayoutItem.__init__(self, dom, parent_element, line_object, mxd, arc_doc)
     self.dom = dom
     self.parent_element = parent_element
     self.line_object = line_object
     self.mxd = mxd
     self.arc_doc = arc_doc
Exemple #4
0
 def __init__(self, dom, parent_element, north_arrow_object, mxd, arc_doc):
     """
     This function creates a NorthArrow-item
     :param dom: the Document Object Model
     :param parent_element: the main layout element, where to put the layout-items
     :param north_arrow_object: the northArrow as ArcObject
     :param mxd: the arcpy mxd-document
     :param arc_doc: the ArcObject IMxDocument
     """
     LayoutItem.__init__(self, dom, parent_element, north_arrow_object, mxd, arc_doc)
     self.dom = dom
     self.parent_element = parent_element
     self.north_arrow_object = north_arrow_object
     self.mxd = mxd
     self.arc_doc = arc_doc
Exemple #5
0
    def create_line_element_content(self, line_element_layout):
        """
        This function creats the Line-item specific content
        :param line_element_layout: the layout element in the DOM
        """
        arcpy_item = LayoutItem.get_arcpy_layout_element(self, self.line_object)
        LineElement.set_size_and_position(self, line_element_layout, arcpy_item)

        element_geometry = change_interface(self.line_object, ArcGisModules.module_carto.IElement).Geometry
        poly_ine_symbol = change_interface(element_geometry, ArcGisModules.module_geometry.IPolyline5)
        point_collection = change_interface(poly_ine_symbol, ArcGisModules.module_geometry.IPointCollection)

        line_element_layout.setAttribute('type', '65645')
        line_element_layout.setAttribute("frame", "false")
        line_element_layout.setAttribute("background", "false")

        LineElement.set_uuid_attributes(arcpy_item.name, line_element_layout)

        symbol = self.line_object.Symbol
        symbol_properties = {}

        SymbolPropertiesProvider.get_line_properties(symbol_properties, symbol)

        SimpleSymbol.create_simple_symbol(self.dom, line_element_layout, symbol_properties, 1, '1')

        LineElement.create_nodes(self, line_element_layout, point_collection, arcpy_item)
Exemple #6
0
 def __init__(self, dom, parent_element, map_object, mxd, arc_doc):
     """
     This function creates a frame(Map)-item 
     :param dom: the Document Object Model
     :param parent_element: the main layout element, where to put the layout-items
     :param map_object: The Map item as ArcObject
     :param mxd: the arcpy mxd-document
     :param arc_doc: the ArcObject IMxDocument
     """
     LayoutItem.__init__(self, dom, parent_element, map_object, mxd,
                         arc_doc)
     self.dom = dom
     self.parent_element = parent_element
     self.map_object = map_object
     self.mxd = mxd
     self.arc_doc = arc_doc
Exemple #7
0
 def __init__(self, dom, parent_element, geometry_object, mxd, arc_doc):
     """
     This function creates a geometry layout-item
     :param dom: the Document Object Model
     :param parent_element: the main layout element, where to put the layout-items
     :param geometry_object: the geometry-object itself as ArcObject
     :param mxd: the arcpy mxd-document
     :param arc_doc: the ArcObject IMxDocument
     """
     LayoutItem.__init__(self, dom, parent_element, geometry_object, mxd,
                         arc_doc)
     self.dom = dom
     self.parent_element = parent_element
     self.geometry_object = geometry_object
     self.mxd = mxd
     self.arc_doc = arc_doc
Exemple #8
0
    def create_geometry_element_content(self, geometry_element_layout,
                                        geometry_type):
        """
        This function creates the geometry specific content
        :param geometry_element_layout: the geometry layout element in the DOM
        :param geometry_type: the shape type as string
        """

        arcpy_item = LayoutItem.get_arcpy_layout_element(
            self, self.layout_item_object)

        GeometryElement.set_size_and_position(self, geometry_element_layout,
                                              arcpy_item)

        geometry_element_layout.setAttribute("frame", "false")
        geometry_element_layout.setAttribute("background", "false")

        geometry_element_layout.setAttribute('shapeType',
                                             dict_geometry[geometry_type])
        geometry_element_layout.setAttribute('type', "65643")

        GeometryElement.set_uuid_attributes(arcpy_item.name,
                                            geometry_element_layout)

        symbol = change_interface(
            self.geometry_object,
            ArcGisModules.module_carto.IFillShapeElement).Symbol
        symbol_properties = {}

        SymbolPropertiesProvider.get_polygon_properties(
            symbol_properties, symbol)

        SimpleSymbol.create_simple_symbol(self.dom, geometry_element_layout,
                                          symbol_properties, 1, '1')
Exemple #9
0
    def create_map_content(self, layout_item_base_element):
        """
        This function creats the frame-item specific content
        :param layout_item_base_element: the layout element in the DOM
        """
        arcpy_item = LayoutItem.get_arcpy_layout_element(
            self, self.layout_item_object)
        LayoutItemFrame.set_size_and_position(self, layout_item_base_element,
                                              arcpy_item)
        frame_properties = change_interface(
            self.map_object, ArcGisModules.module_carto.IFrameProperties)

        border = frame_properties.Border
        background = frame_properties.Background
        LayoutItemFrame.create_background_and_frame(self, border, background,
                                                    layout_item_base_element)

        layout_item_base_element.setAttribute("type", "65639")
        layout_item_base_element.setAttribute("marginX", "0")
        layout_item_base_element.setAttribute("marginY", "0")
        layout_item_base_element.setAttribute("excludeFromExports", "0")
        layout_item_base_element.setAttribute("drawCanvasItems", "true")
        layout_item_base_element.setAttribute("rotation",
                                              unicode(arcpy_item.rotation))

        if self.layout_item_object.Map.Name not in LayoutUuidProvider.uuid_dict:
            LayoutUuidProvider.create_uuid(self.layout_item_object.Map.Name)
        uuid = unicode(
            LayoutUuidProvider.uuid_dict[self.layout_item_object.Map.Name])
        layout_item_base_element.setAttribute("uuid", uuid)
        layout_item_base_element.setAttribute("templateUuid", uuid)

        layout_item_base_element.setAttribute("followPreset", 'true')
        layout_item_base_element.setAttribute("followPresetName",
                                              arcpy_item.name)

        extent_element = self.dom.createElement("Extent")
        extent_element.setAttribute('ymax',
                                    "{}".format(arcpy_item.extent.YMax))
        extent_element.setAttribute('ymin',
                                    "{}".format(arcpy_item.extent.YMin))
        extent_element.setAttribute('xmax',
                                    "{}".format(arcpy_item.extent.XMax))
        extent_element.setAttribute('xmin',
                                    "{}".format(arcpy_item.extent.XMin))
        layout_item_base_element.appendChild(extent_element)
    def create_text_content(self, layout_item_base_element):
        """
        This function creats the Text-item specific content
        :param layout_item_base_element: the layout element in the DOM
        """
        arcpy_item = LayoutItem.get_arcpy_layout_element(
            self, self.layout_item_object)
        LayoutItemText.set_size_and_position(self, layout_item_base_element,
                                             arcpy_item)

        font_symbol = self.text_object.Symbol

        layout_item_base_element.setAttribute("frame", "false")
        layout_item_base_element.setAttribute("background", "false")
        layout_item_base_element.setAttribute("type", "65641")
        layout_item_base_element.setAttribute("labelText", font_symbol.Text)
        layout_item_base_element.setAttribute("marginX", "0")
        layout_item_base_element.setAttribute("marginY", "0")
        layout_item_base_element.setAttribute(
            "halign", TextSymbol.textSymbolHorizontalAlign[
                font_symbol.HorizontalAlignment])
        layout_item_base_element.setAttribute(
            "valign",
            TextSymbol.textSymbolVerticalAlign[font_symbol.VerticalAlignment])

        LayoutItemText.set_uuid_attributes(arcpy_item.text[:5],
                                           layout_item_base_element)
        label_font_description = LayoutItemText.get_label_font_description(
            font_symbol)

        label_font_element = self.dom.createElement("LabelFont")
        label_font_element.setAttribute("description", label_font_description)
        layout_item_base_element.appendChild(label_font_element)

        font_color = convert_int_to_rgb_string(
            font_symbol.Color.RGB).split(",")
        font_color_element = self.dom.createElement("FontColor")
        font_color_element.setAttribute('red', font_color[0])
        font_color_element.setAttribute('green', font_color[1])
        font_color_element.setAttribute('blue', font_color[2])
        font_color_element.setAttribute('alpha', font_color[3])
        layout_item_base_element.appendChild(font_color_element)
Exemple #11
0
    def create_north_arrow_content(self, layout_item_base_element):
        """
        This function creats the northArrow-item specific content
        :param layout_item_base_element: the layout element in the DOM
        """
        border = self.north_arrow_object.Border
        background = self.north_arrow_object.Background

        NorthArrowElement.create_background_and_frame(self, border, background, layout_item_base_element)

        arcpy_item = LayoutItem.get_arcpy_layout_element(self, self.layout_item_object)
        NorthArrowElement.set_size_and_position(self, layout_item_base_element, arcpy_item)

        NorthArrowElement.set_uuid_attributes(self.layout_item_object.MapSurround.Name, layout_item_base_element)

        layout_item_base_element.setAttribute('file', ":/images/north_arrows/layout_default_north_arrow.svg")
        layout_item_base_element.setAttribute('type', "65640")
        north_arrow = change_interface(self.north_arrow_object.MapSurround, ArcGisModules.module_carto.INorthArrow)
        layout_item_base_element.setAttribute('northOffset', unicode(north_arrow.CalibrationAngle))
        layout_item_base_element.setAttribute('svgBorderColor', convert_int_to_rgb_string(north_arrow.Color.RGB))
        layout_item_base_element.setAttribute('svgFillColor', "255,255,255,255")
Exemple #12
0
    def create_picture_content(self, picture_element_base_layout):
        """
        This function creats the Picture-item specific content
        :param picture_element_base_layout: the layout element in the DOM
        """
        arcpy_item = LayoutItem.get_arcpy_layout_element(
            self, self.picture_object)
        PictureElement.set_size_and_position(self, picture_element_base_layout,
                                             arcpy_item)

        frame_properties = change_interface(
            self.picture_object, ArcGisModules.module_carto.IFrameProperties)

        border = frame_properties.Border
        background = frame_properties.Background
        PictureElement.create_background_and_frame(
            self, border, background, picture_element_base_layout)

        PictureElement.set_uuid_attributes(arcpy_item.name,
                                           picture_element_base_layout)
        picture_element_base_layout.setAttribute('type', "65640")
        picture_element_base_layout.setAttribute(
            'file', arcpy_item.sourceImage.replace('\\', '/'))
    def create_scale_bar_content(self, layout_item_base_element):
        """
        This function creats the ScaleBar-item specific content
        :param layout_item_base_element: the layout element in the DOM
        """

        border = self.scale_bar_object.Border
        background = self.scale_bar_object.Background

        ScaleBarElement.create_background_and_frame(self, border, background,
                                                    layout_item_base_element)

        arcpy_item = LayoutItem.get_arcpy_layout_element(
            self, self.layout_item_object)
        ScaleBarElement.set_size_and_position(self, layout_item_base_element,
                                              arcpy_item)

        scale_bar = change_interface(self.scale_bar_object.MapSurround,
                                     ArcGisModules.module_carto.IScaleBar)
        scale_marks = change_interface(self.scale_bar_object.MapSurround,
                                       ArcGisModules.module_carto.IScaleMarks)

        layout_item_base_element.setAttribute('unitType',
                                              dict_units[scale_bar.Units])
        layout_item_base_element.setAttribute('unitLabel', scale_bar.UnitLabel)

        ScaleBarElement.set_uuid_attributes(
            self.layout_item_object.MapSurround.Name, layout_item_base_element)

        try:
            layout_item_base_element.setAttribute(
                'mapUuid',
                unicode(LayoutUuidProvider.uuid_dict[
                    self.layout_item_object.MapSurround.Map.Name]))
        except KeyError:
            LayoutUuidProvider.create_uuid(
                self.layout_item_object.MapSurround.Map.Name)
            layout_item_base_element.setAttribute(
                'mapUuid',
                unicode(LayoutUuidProvider.uuid_dict[
                    self.layout_item_object.MapSurround.Map.Name]))

        layout_item_base_element.setAttribute('type', "65646")
        layout_item_base_element.setAttribute(
            'numSegments',
            unicode(scale_bar.Divisions - scale_bar.DivisionsBeforeZero))
        if scale_bar.DivisionsBeforeZero > 0:
            layout_item_base_element.setAttribute(
                'numSegmentsLeft', unicode(scale_bar.Subdivisions))
        else:
            layout_item_base_element.setAttribute('numSegmentsLeft', '0')
        layout_item_base_element.setAttribute('numUnitsPerSegment',
                                              unicode(scale_bar.Division))
        layout_item_base_element.setAttribute(
            'labelVerticalPlacement',
            dict_vertical_position[scale_bar.LabelPosition])
        layout_item_base_element.setAttribute('labelBarSpace',
                                              unicode(scale_bar.LabelGap))
        if str(scale_bar.Name).startswith('Double'):
            layout_item_base_element.setAttribute('style', "Double Box")
        else:
            layout_item_base_element.setAttribute('style', "Single Box")

        scale_line = change_interface(scale_bar,
                                      ArcGisModules.module_carto.IScaleLine)
        if scale_line:
            num_segments = unicode(
                (scale_bar.Divisions - scale_bar.DivisionsBeforeZero) *
                scale_bar.Subdivisions
            ) if scale_bar.Subdivisions > 0 else unicode(
                scale_bar.Divisions - scale_bar.DivisionsBeforeZero)
            layout_item_base_element.setAttribute('numSegments', num_segments)
            num_units_per_segment = unicode(scale_bar.Division / scale_bar.Subdivisions) \
                if not scale_bar.Subdivisions == 0 else unicode(scale_bar.Division)
            layout_item_base_element.setAttribute(
                'numUnitsPerSegment', unicode(num_units_per_segment))
            layout_item_base_element.setAttribute(
                'style', dict_line_style[scale_marks.MarkPosition])

        double_fill_scale_bar = change_interface(
            scale_bar, ArcGisModules.module_carto.IDoubleFillScaleBar)

        if double_fill_scale_bar:
            fill_color_1 = convert_int_to_rgb_string(
                double_fill_scale_bar.FillSymbol1.Color.RGB).split(",")
            fill_color_2 = convert_int_to_rgb_string(
                double_fill_scale_bar.FillSymbol2.Color.RGB).split(",")
            if double_fill_scale_bar.FillSymbol1.Color.NullColor and double_fill_scale_bar.FillSymbol2.Color.NullColor:
                layout_item_base_element.setAttribute('style', 'hollow')

            symbol_properties_1 = {}
            fill_symbol_1_element = self.dom.createElement('fillSymbol1')
            SymbolPropertiesProvider.get_polygon_properties(
                symbol_properties_1, double_fill_scale_bar.FillSymbol1)
            SimpleSymbol.create_simple_symbol(self.dom, fill_symbol_1_element,
                                              symbol_properties_1, '', '1')
            layout_item_base_element.appendChild(fill_symbol_1_element)

            symbol_properties_2 = {}
            fill_symbol_2_element = self.dom.createElement('fillSymbol2')
            SymbolPropertiesProvider.get_polygon_properties(
                symbol_properties_2, double_fill_scale_bar.FillSymbol2)
            SimpleSymbol.create_simple_symbol(self.dom, fill_symbol_2_element,
                                              symbol_properties_2, '', '1')
            layout_item_base_element.appendChild(fill_symbol_2_element)
        else:
            fill_color_1 = convert_int_to_rgb_string(
                scale_bar.BarColor.RGB).split(',')
            fill_color_2 = "255,255,255,255"

        fill_color_1_element = self.dom.createElement('fillColor')
        fill_color_1_element.setAttribute('red', fill_color_1[0])
        fill_color_1_element.setAttribute('green', fill_color_1[1])
        fill_color_1_element.setAttribute('blue', fill_color_1[2])
        fill_color_1_element.setAttribute('alpha', fill_color_1[3])
        layout_item_base_element.appendChild(fill_color_1_element)

        fill_color_2_element = self.dom.createElement('fillColor2')
        fill_color_2_element.setAttribute('red', fill_color_2[0])
        fill_color_2_element.setAttribute('green', fill_color_2[1])
        fill_color_2_element.setAttribute('blue', fill_color_2[2])
        fill_color_2_element.setAttribute('alpha', fill_color_2[3])
        layout_item_base_element.appendChild(fill_color_2_element)
    def create_legend_content(self, layout_item_base_element):
        """
        This function creates the legend specific content
        :param layout_item_base_element: the layout element in the DOM
        """
        border = self.legend_object.Border

        background = self.legend_object.Background
        LegendElement.create_background_and_frame(self, border, background,
                                                  layout_item_base_element)

        try:
            layout_item_base_element.setAttribute(
                'mapUuid',
                unicode(LayoutUuidProvider.uuid_dict[
                    self.layout_item_object.MapSurround.Map.Name]))
        except KeyError:
            LayoutUuidProvider.create_uuid(
                self.layout_item_object.MapSurround.Map.Name)
            layout_item_base_element.setAttribute(
                'mapUuid',
                unicode(LayoutUuidProvider.uuid_dict[
                    self.layout_item_object.MapSurround.Map.Name]))

        LegendElement.set_uuid_attributes(
            self.layout_item_object.MapSurround.Name, layout_item_base_element)

        layout_item_base_element.setAttribute('type', "65642")
        layout_item_base_element.setAttribute('legendFilterByAtlas', "0")
        layout_item_base_element.setAttribute('equalColumnWidth', "0")
        layout_item_base_element.setAttribute('resizeToContents', "1")

        arcpy_item = LayoutItem.get_arcpy_layout_element(
            self, self.layout_item_object)
        LegendElement.set_size_and_position(self, layout_item_base_element,
                                            arcpy_item)

        legend_frame = change_interface(self.legend_object.MapSurround,
                                        ArcGisModules.module_carto.ILegend2)
        legend_format = legend_frame.Format

        if legend_format.ShowTitle:
            layout_item_base_element.setAttribute('title', legend_frame.Title)

        layout_item_base_element.setAttribute(
            'symbolHeight', unicode(legend_format.DefaultPatchHeight / 2.835))
        layout_item_base_element.setAttribute(
            'symbolWidth', unicode(legend_format.DefaultPatchWidth / 2.835))

        layout_item_base_element.setAttribute(
            'columnSpace', unicode(legend_format.HorizontalItemGap / 2.835))
        if self.legend_object.Border:
            layout_item_base_element.setAttribute(
                'boxSpace', unicode(self.legend_object.Border.Gap / 2.835))
        layout_item_base_element.setAttribute(
            'lineSpace', unicode(legend_format.VerticalItemGap / 2.835))

        LegendElement.create_style_element(self, legend_format, legend_frame,
                                           layout_item_base_element)
        LegendElement.create_layer_tree_element(self, legend_frame,
                                                layout_item_base_element)

        column_count = 0
        for index in range(0, legend_frame.ItemCount):
            if legend_frame[index].NewColumn:
                column_count += 1
        layout_item_base_element.setAttribute('columnCount',
                                              unicode(column_count))