當前位置: 首頁>>代碼示例>>Python>>正文


Python QgsLayoutGridSettings.setResolution方法代碼示例

本文整理匯總了Python中qgis.core.QgsLayoutGridSettings.setResolution方法的典型用法代碼示例。如果您正苦於以下問題:Python QgsLayoutGridSettings.setResolution方法的具體用法?Python QgsLayoutGridSettings.setResolution怎麽用?Python QgsLayoutGridSettings.setResolution使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在qgis.core.QgsLayoutGridSettings的用法示例。


在下文中一共展示了QgsLayoutGridSettings.setResolution方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testGettersSetters

# 需要導入模塊: from qgis.core import QgsLayoutGridSettings [as 別名]
# 或者: from qgis.core.QgsLayoutGridSettings import setResolution [as 別名]
    def testGettersSetters(self):
        p = QgsProject()
        l = QgsLayout(p)
        s = QgsLayoutGridSettings(l)
        s.setResolution(QgsLayoutMeasurement(5, QgsUnitTypes.LayoutPoints))
        self.assertEqual(s.resolution().length(), 5.0)
        self.assertEqual(s.resolution().units(), QgsUnitTypes.LayoutPoints)

        s.setOffset(QgsLayoutPoint(6, 7, QgsUnitTypes.LayoutPixels))
        self.assertEqual(s.offset().x(), 6.0)
        self.assertEqual(s.offset().y(), 7.0)
        self.assertEqual(s.offset().units(), QgsUnitTypes.LayoutPixels)

        s.setPen(QPen(QColor(255, 0, 255)))
        self.assertEqual(s.pen().color().name(), QColor(255, 0, 255).name())

        s.setStyle(QgsLayoutGridSettings.StyleDots)
        self.assertEqual(s.style(), QgsLayoutGridSettings.StyleDots)
開發者ID:sbrunner,項目名稱:QGIS,代碼行數:20,代碼來源:test_qgslayoutgridsettings.py

示例2: testReadWriteXml

# 需要導入模塊: from qgis.core import QgsLayoutGridSettings [as 別名]
# 或者: from qgis.core.QgsLayoutGridSettings import setResolution [as 別名]
    def testReadWriteXml(self):
        p = QgsProject()
        l = QgsLayout(p)
        s = QgsLayoutGridSettings(l)
        s.setResolution(QgsLayoutMeasurement(5, QgsUnitTypes.LayoutPoints))
        s.setOffset(QgsLayoutPoint(6, 7, QgsUnitTypes.LayoutPixels))

        doc = QDomDocument("testdoc")
        elem = doc.createElement("test")
        self.assertTrue(s.writeXml(elem, doc, QgsReadWriteContext()))

        s2 = QgsLayoutGridSettings(l)
        self.assertTrue(s2.readXml(elem.firstChildElement(), doc, QgsReadWriteContext()))

        self.assertEqual(s2.resolution().length(), 5.0)
        self.assertEqual(s2.resolution().units(), QgsUnitTypes.LayoutPoints)
        self.assertEqual(s2.offset().x(), 6.0)
        self.assertEqual(s2.offset().y(), 7.0)
        self.assertEqual(s2.offset().units(), QgsUnitTypes.LayoutPixels)
開發者ID:sbrunner,項目名稱:QGIS,代碼行數:21,代碼來源:test_qgslayoutgridsettings.py

示例3: createComposition

# 需要導入模塊: from qgis.core import QgsLayoutGridSettings [as 別名]
# 或者: from qgis.core.QgsLayoutGridSettings import setResolution [as 別名]
    def createComposition(self):
        '''
        Create a print Layout
        '''
        c = QgsPrintLayout(self.mProject)
        c.initializeDefaults()
        c.setUnits(QgsUnitTypes.LayoutMillimeters)

        g=QgsLayoutGridSettings(c)
        g.setOffset( QgsLayoutPoint(3.5, 0, QgsUnitTypes.LayoutMillimeters)   )
        g.setResolution( QgsLayoutMeasurement(2.5) )

        # Set page number
        self.getPageNumberNeeded()
        # Set main properties
        for i in range(1, self.numPages):
            p=QgsLayoutItemPage(c)
            #page.setPageSize('A6')
            p.setPageSize( QgsLayoutSize(self.pageWidth, self.pageHeight, QgsUnitTypes.LayoutMillimeters) )
            c.pageCollection().addPage(p)

        # Set the global currentComposition
        self.currentComposition = c
開發者ID:rldhont,項目名稱:QgisCadastrePlugin,代碼行數:25,代碼來源:cadastre_export.py


注:本文中的qgis.core.QgsLayoutGridSettings.setResolution方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。