def __init__(self, iface: QgisInterface, layer): QgsMapToolAdvancedDigitizing.__init__(self, iface.mapCanvas(), iface.cadDockWidget()) self.iface = iface self.canvas = iface.mapCanvas() self.layer = layer self.rubberband = QgepRubberBand3D(iface.mapCanvas(), layer.geometryType()) self.rubberband.setColor(QColor("#ee5555")) self.rubberband.setWidth(1) self.temp_rubberband = QgsRubberBand(iface.mapCanvas(), layer.geometryType()) self.temp_rubberband.setColor(QColor("#ee5555")) self.temp_rubberband.setWidth(1) self.temp_rubberband.setLineStyle(Qt.DotLine)
def __init__(self, iface: QgisInterface, button, network_analyzer: QgepGraphManager = None): QgsMapTool.__init__(self, iface.mapCanvas()) self.canvas = iface.mapCanvas() self.cursor = QCursor(Qt.CrossCursor) self.button = button self.msgBar = iface.messageBar() self.network_analyzer = network_analyzer settings = QSettings() current_profile_color = settings.value( "/QGEP/CurrentProfileColor", '#FF9500') self.rubberBand = QgsRubberBand(self.canvas) self.rubberBand.setColor(QColor(current_profile_color)) self.rubberBand.setWidth(3)
def __init__(self, iface: QgisInterface = None): """" :param iface: QGIS interface, given when on the main thread (which will display/trigger results), None otherwise """ super().__init__() self.iface = iface self.settings = Settings() # following properties will only be used in main thread self.rubber_band = None self.map_canvas: QgsMapCanvas = None self.transform_ch = None self.current_timer = None self.result_found = False self.nam_fetch_feature = None if iface is not None: # happens only in main thread self.map_canvas = iface.mapCanvas() self.map_canvas.destinationCrsChanged.connect( self.create_transforms) self.rubber_band = QgsRubberBand( self.map_canvas, QgsWkbTypes.PolygonGeometry) self.rubber_band.setColor(QColor(255, 50, 50, 200)) self.rubber_band.setFillColor(QColor(255, 255, 50, 160)) self.rubber_band.setBrushStyle(Qt.SolidPattern) self.rubber_band.setLineStyle(Qt.SolidLine) self.rubber_band.setIcon(self.rubber_band.ICON_CIRCLE) self.rubber_band.setIconSize(15) self.rubber_band.setWidth(4) self.rubber_band.setBrushStyle(Qt.NoBrush) self.create_transforms()
def __init__(self, filter_type: FilterType, iface: QgisInterface = None, crs: str = None): """" :param filter_type: the type of filter :param locale_lang: the language of the locale. :param iface: QGIS interface, given when on the main thread (which will display/trigger results), None otherwise :param crs: if iface is not given, it shall be provided, see clone() """ super().__init__() self.type = filter_type self.rubber_band = None self.feature_rubber_band = None self.iface = iface self.map_canvas = None self.settings = Settings() self.transform_ch = None self.transform_4326 = None self.map_tip = None self.current_timer = None self.crs = None self.event_loop = None self.result_found = False self.access_managers = {} self.nam_map_tip = None self.nam_fetch_feature = None if crs: self.crs = crs self.lang = get_language() self.searchable_layers = searchable_layers(self.lang, restrict=True) if iface is not None: # happens only in main thread self.map_canvas = iface.mapCanvas() self.map_canvas.destinationCrsChanged.connect( self.create_transforms) self.rubber_band = QgsRubberBand(self.map_canvas, QgsWkbTypes.PointGeometry) self.rubber_band.setColor(QColor(255, 255, 50, 200)) self.rubber_band.setIcon(self.rubber_band.ICON_CIRCLE) self.rubber_band.setIconSize(15) self.rubber_band.setWidth(4) self.rubber_band.setBrushStyle(Qt.NoBrush) self.feature_rubber_band = QgsRubberBand( self.map_canvas, QgsWkbTypes.PolygonGeometry) self.feature_rubber_band.setColor(QColor(255, 50, 50, 200)) self.feature_rubber_band.setFillColor(QColor(255, 255, 50, 160)) self.feature_rubber_band.setBrushStyle(Qt.SolidPattern) self.feature_rubber_band.setLineStyle(Qt.SolidLine) self.feature_rubber_band.setWidth(4) self.create_transforms()
def __init__(self, service: Service, iface: QgisInterface = None): super().__init__() self.service = service.clone() self.rubberband = None self.iface = None self.map_canvas = None self.current_timer = None self.settings = Settings() self.crs = QgsCoordinateReferenceSystem(self.service.crs) # only get map_canvas on main thread, not when cloning if iface is not None: self.iface = iface self.map_canvas = iface.mapCanvas() self.rubberband = QgsRubberBand(self.map_canvas) self.reset_rubberband()
def __init__(self, iface: QgisInterface, parent=None): """Constructor.""" super(QuickApiDialog, self).__init__(parent) self.setupUi(self) self.iface = iface # Instantiate a network access manager self.nominatim = Nominatim() self.point_tool = PointTool(iface.mapCanvas()) self.last_map_tool: QgsMapTool = None # Set up widgets self.map_button.setIcon( QIcon(":images/themes/default/cursors/mCapturePoint.svg")) self.crs_input.setCrs(QgsCoordinateReferenceSystem("EPSG:4326")) # Set up callbacks self.finished.connect(self.request_geocoder) self.map_button.clicked.connect(self._on_map_click) self.point_tool.canvasClicked.connect(self._write_line_widget) self.point_tool.deactivated.connect( lambda: QApplication.restoreOverrideCursor())
def __init__(self, iface: QgisInterface = None): super().__init__() self.rubber_band = None self.settings = Settings() self.iface = None self.map_canvas = None self.current_timer = None self.transform = None # only get map_canvas on main thread, not when cloning if iface is not None: self.iface = iface self.map_canvas = iface.mapCanvas() self.map_canvas.destinationCrsChanged.connect( self.create_transform) self.rubber_band = QgsRubberBand(self.map_canvas) self.rubber_band.setColor(QColor(255, 255, 50, 200)) self.rubber_band.setIcon(self.rubber_band.ICON_CIRCLE) self.rubber_band.setIconSize(15) self.rubber_band.setWidth(4) self.rubber_band.setBrushStyle(Qt.NoBrush) self.create_transform()
def __init__(self, iface: QgisInterface, html: str, point: QgsPointXY): super().__init__() self.map_canvas = iface.mapCanvas() self.point = point self.web_view = QWebView(self) self.dbg_info('map position: {}'.format(point.asWkt())) self.web_view.page().setLinkDelegationPolicy( QWebPage.DelegateAllLinks) # Handle link clicks by yourself self.web_view.setContextMenuPolicy( Qt.NoContextMenu ) # No context menu is allowed if you don't need it self.web_view.linkClicked.connect(self.on_link_clicked) self.web_view.page().settings().setAttribute( QWebSettings.DeveloperExtrasEnabled, True) self.web_view.page().settings().setAttribute( QWebSettings.JavascriptEnabled, True) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.setWidget(self.web_view) # assure the map tip is never larger than half the map canvas max_width = int(self.map_canvas.geometry().width() / 1.8) max_height = int(self.map_canvas.geometry().height() / 1.8) self.dbg_info('max size {} {}'.format(max_height, max_width)) self.setMaximumSize(max_width, max_height) # start with 0 size, # the content will automatically make it grow up to MaximumSize self.resize(300, 200) background_color = self.palette().base().color() background_color.setAlpha(235) stroke_color = self.palette().shadow().color() #self.setStyleSheet(".QDocWidget{{ border: 1px solid {stroke}; background-color: {bg} }}" # .format(stroke=stroke_color.name(QColor.HexArgb), # bg=background_color.name(QColor.HexArgb))) palette = self.web_view.palette() palette.setBrush(QPalette.Base, Qt.transparent) palette.setBrush(QPalette.Base, background_color) self.web_view.page().setPalette(palette) self.web_view.setAttribute(Qt.WA_OpaquePaintEvent, False) body_style = "background-color: {bg}; margin: 0".format( bg=background_color) container_style = "display: inline-block; margin: 0px" body_html = "<html><body style='{body_style}'>" \ "<div id='QgsWebViewContainer' style='{container_style}'>{html}</div><" \ "/body></html>".format(body_style=body_style, container_style=container_style, html=html) self.web_view.setHtml(body_html) scrollbar_width = self.web_view.page().mainFrame().scrollBarGeometry( Qt.Vertical).width() scrollbar_height = self.web_view.page().mainFrame().scrollBarGeometry( Qt.Horizontal).height() if scrollbar_width > 0 or scrollbar_height > 0: # Get the content size container = self.web_view.page().mainFrame().findFirstElement( "#QgsWebViewContainer") width = container.geometry().width() + 25 + scrollbar_width height = container.geometry().height() + 25 + scrollbar_height #self.resize(width, height) iface.addDockWidget(Qt.RightDockWidgetArea, self) self.setFeatures(QDockWidget.AllDockWidgetFeatures) self.setFloating(True) self.setWindowOpacity(0.9) self.move_to_point()