def DrawOverlay(self, x, y): self._pdc.BeginDrawing() self._pdc.SetId(1) self._pdc.DrawBitmap(bmp=self._overlay, x=x, y=y) self._pdc.SetIdBounds(1, Rect(x, y, self._overlay.GetWidth(), self._overlay.GetHeight())) self._pdc.EndDrawing()
def SetRasterNameText(self, name, textId): """Sets text label with map name.""" self.textdict[textId] = { 'bbox': Rect(), 'coords': [10, 10], 'font': self.GetFont(), 'color': wx.BLACK, 'background': wx.LIGHT_GREY, 'rotation': 0, 'text': name, 'active': True }
def SetRasterNameText(self, name, textId): """Sets text label with map name.""" self.textdict[textId] = { "bbox": Rect(), "coords": [10, 10], "font": self.GetFont(), "color": wx.BLACK, "background": wx.LIGHT_GREY, "rotation": 0, "text": name, "active": True, }
def GetSelectedVertex(self, pos): """Get PseudoDC vertex id of selected line Set bounding box for vertices of line. :param pos: position :return: id of center, left and right vertex :return: 0 no line found :return: -1 on error """ returnId = list() # only one object can be selected if len(self.selected["ids"]) != 1 or not self._drawSegments: return returnId startId = 1 line = self.selected["ids"][0] if not self._validLine(line): return -1 ftype = Vect_read_line(self.poMapInfo, self.poPoints, self.poCats, line) minDist = 0.0 Gid = -1 # find the closest vertex (x, y) DCid = 1 points = self.poPoints.contents for idx in range(points.n_points): dist = Vect_points_distance(pos[0], pos[1], 0.0, points.x[idx], points.y[idx], points.z[idx], 0) if idx == 0: minDist = dist Gid = idx else: if minDist > dist: minDist = dist Gid = idx vx, vy = self._cell2Pixel(points.x[idx], points.y[idx], points.z[idx]) rect = Rect(vx, vy, 0, 0) self.dc.SetIdBounds(DCid, rect) DCid += 2 if minDist > self.GetThreshold(): return returnId # translate id DCid = Gid * 2 + 1 # add selected vertex returnId.append(DCid) # left vertex if DCid == startId: returnId.append(-1) else: returnId.append(DCid - 2) # right vertex if DCid == (points.n_points - 1) * 2 + startId: returnId.append(-1) else: returnId.append(DCid + 2) return returnId
def _drawObject(self, robj): """Draw given object to the device The object is defined as robject() from vedit.h. :param robj: object to be rendered :return: 1 on success :return: -1 on failure (vector feature marked as dead, etc.) """ if not self.dc or not self.dcTmp: return -1 Debug.msg( 4, "_drawObject(): line=%d type=%d npoints=%d", robj.fid, robj.type, robj.npoints, ) brush = None if robj.type == TYPE_AREA and self._isSelected( Vect_get_area_centroid(self.poMapInfo, robj.fid)): pdc = self.dcTmp pen = wx.TRANSPARENT_PEN brush = wx.TRANSPARENT_BRUSH dcId = 1 self.topology["highlight"] += 1 if not self._drawSelected: return elif robj.type != TYPE_AREA and self._isSelected(robj.fid): pdc = self.dcTmp if self.settings["highlightDupl"][ "enabled"] and self._isDuplicated(robj.fid): pen = wx.Pen( self.settings["highlightDupl"]["color"], self.settings["lineWidth"], wx.SOLID, ) else: pen = wx.Pen(self.settings["highlight"], self.settings["lineWidth"], wx.SOLID) dcId = 1 self.topology["highlight"] += 1 if not self._drawSelected: return else: pdc = self.dc pen, brush = self._definePen(robj.type) dcId = 0 pdc.SetPen(pen) if brush: pdc.SetBrush(brush) if robj.type & (TYPE_POINT | TYPE_CENTROIDIN | TYPE_CENTROIDOUT | TYPE_CENTROIDDUP | TYPE_NODEONE | TYPE_NODETWO | TYPE_VERTEX): # -> point if dcId > 0: if robj.type == TYPE_VERTEX: dcId = 3 # first vertex elif robj.type & (TYPE_NODEONE | TYPE_NODETWO): if self.firstNode: dcId = 1 self.firstNode = False else: dcId = self.lastNodeId for i in range(robj.npoints): p = robj.point[i] if dcId > 0: pdc.SetId(dcId) dcId += 2 self._drawCross(pdc, p) else: if dcId > 0 and self._drawSegments: self.fisrtNode = True self.lastNodeId = robj.npoints * 2 - 1 dcId = 2 # first segment i = 0 while i < robj.npoints - 1: point_beg = wx.Point(robj.point[i].x, robj.point[i].y) point_end = wx.Point(robj.point[i + 1].x, robj.point[i + 1].y) # set unique id & set bbox for each segment pdc.SetId(dcId) pdc.SetPen(pen) pdc.SetIdBounds(dcId - 1, Rect(point_beg.x, point_beg.y, 0, 0)) pdc.SetIdBounds( dcId, Rect( point_beg.x, point_beg.y, point_end.x - point_beg.x, point_end.y - point_beg.y, ), ) pdc.DrawLine(point_beg.x, point_beg.y, point_end.x, point_end.y) i += 1 dcId += 2 pdc.SetIdBounds( dcId - 1, Rect( robj.point[robj.npoints - 1].x, robj.point[robj.npoints - 1].y, 0, 0, ), ) else: points = list() for i in range(robj.npoints): p = robj.point[i] points.append(wx.Point(p.x, p.y)) if robj.type == TYPE_AREA: pdc.DrawPolygon(points) else: pdc.DrawLines(points)