예제 #1
0
파일: figexport.py 프로젝트: hmeine/geomap
    def addCircleOverlay(self, circleOverlay, container=True, **attr):
        """Adds and returns fig.Circle for all circles of the given
        overlay, using the overlays' color and width."""

        if container == True:
            container = self.f

        circles = circleOverlay.originalCircles
        attr = dict(attr)
        self._setOverlayColor(circleOverlay, "penColor", attr)

        o = self.offset + attr.get('offset', (0, 0))
        if self.roi:
            o = o - self.roi.begin()  # don't modify in-place!

        result = fig.Compound(container)
        for center, radius in circles:
            if self.roi and not self.roi.contains(center + o):
                continue
            p = intPos(((center[0], center[1]) + o) * self.scale)
            dc = fig.Circle(p, radius * self.scale)
            for a in attr:
                setattr(dc, a, attr[a])
            result.append(dc)

        return result
예제 #2
0
 def mouseMoved(self, x, y):
     if not self._painting: return
     # TODO: update overlay
     x1, y1 = self.startPos
     x, y = intPos((x, y))
     self.setROI(
         Rect2D(min(x1, x), min(y1, y), max(x1, x)+1, max(y1, y)+1))
예제 #3
0
파일: figexport.py 프로젝트: hmeine/geomap
    def addCircleOverlay(self, circleOverlay, container = True, **attr):
        """Adds and returns fig.Circle for all circles of the given
        overlay, using the overlays' color and width."""

        if container == True:
            container = self.f

        circles = circleOverlay.originalCircles
        attr = dict(attr)
        self._setOverlayColor(circleOverlay, "penColor", attr)

        o = self.offset + attr.get('offset', (0,0))
        if self.roi:
            o = o - self.roi.begin() # don't modify in-place!

        result = fig.Compound(container)
        for center, radius in circles:
            if self.roi and not self.roi.contains(center+o):
                continue
            p = intPos(((center[0], center[1]) + o) * self.scale)
            dc = fig.Circle(p, radius * self.scale)
            for a in attr:
                setattr(dc, a, attr[a])
            result.append(dc)

        return result
예제 #4
0
파일: figexport.py 프로젝트: hmeine/geomap
    def addEdge(self, points, simplifyEpsilon = 0.5, container = True,
                figClass = fig.Polygon, **attr):
        """fe.addEdge(points, simplifyEpsilon, ...)

        Adds and returns exactly one fig.Polygon object representing
        the given points.  You will probably want to use
        addClippedPoly() instead.

        If simplifyEpsilon (default: 0.5) is not None, simplifyPolygon
        is called on the *scaled* polygon (i.e. the default is to
        simplify the polygon to 0.5 fig units, which are integer
        anyways)."""

        if container == True:
            container = self.f
        o = self.offset + attr.get('offset', (0,0))
        if self.roi:
            o -= self.roi.begin()
        pp = Polygon([(o + point) * self.scale for point in points])
        if simplifyEpsilon:
            pp = simplifyPolygon(pp, simplifyEpsilon)
        fp = figClass([intPos(v) for v in pp], closed = pp[0] == pp[-1])
        for a in attr:
            if a != "offset":
                setattr(fp, a, attr[a])
        container.append(fp)
        return fp
예제 #5
0
파일: figexport.py 프로젝트: hmeine/geomap
    def addEdge(self,
                points,
                simplifyEpsilon=0.5,
                container=True,
                figClass=fig.Polygon,
                **attr):
        """fe.addEdge(points, simplifyEpsilon, ...)

        Adds and returns exactly one fig.Polygon object representing
        the given points.  You will probably want to use
        addClippedPoly() instead.

        If simplifyEpsilon (default: 0.5) is not None, simplifyPolygon
        is called on the *scaled* polygon (i.e. the default is to
        simplify the polygon to 0.5 fig units, which are integer
        anyways)."""

        if container == True:
            container = self.f
        o = self.offset + attr.get('offset', (0, 0))
        if self.roi:
            o -= self.roi.begin()
        pp = Polygon([(o + point) * self.scale for point in points])
        if simplifyEpsilon:
            pp = simplifyPolygon(pp, simplifyEpsilon)
        fp = figClass([intPos(v) for v in pp], closed=pp[0] == pp[-1])
        for a in attr:
            if a != "offset":
                setattr(fp, a, attr[a])
        container.append(fp)
        return fp
예제 #6
0
파일: figexport.py 프로젝트: hmeine/geomap
    def addPointCircles(self,
                        points,
                        radius,
                        returnIndices=False,
                        container=True,
                        **attr):
        """fe.addPointCircles(points, radius, returnIndices = False,...)

        Marks each point in points with a circle of the given radius
        (in pixels) if it is within the clipping rect.  The list of
        fig.Circle objects is returned.  Again, note the possibility
        of setting properties (depth, penColor, lineStyle, lineWidth,
        ...) on all resulting objects via keyword arguments
        (cf. documentation of the FigExporter class).

        By default, circles will be filled, but have lineWidth=0.
        To draw a transparent circle, call:

        fi.addPointCircles([(5.2,5.3)], 2, penColor=fig.Color.Cyan,fillStyle=fig.FillStyle.None,lineWidth=1)

        If returnIndices is set to True (default: False), a list of
        (i, c) pairs is returned instead, where c is the fig.Circle
        object, and i is the index of the corresponding position in
        points."""

        if container == True:
            container = self.f

        attr = dict(attr)
        if "fillStyle" not in attr:
            attr["fillStyle"] = fig.FillStyle.Solid
        if "lineWidth" not in attr and attr["fillStyle"] != fig.FillStyle.None:
            attr["lineWidth"] = 0

        compound = fig.Compound(container)
        if returnIndices:
            result = []
        else:
            result = compound

        o = self.offset + attr.get('offset', (0, 0))
        o2 = self.roi and o - self.roi.begin() or o
        for i, point in enumerate(points):
            if self.roi:
                radiusOff = (radius, radius)
                circleBounds = BoundingBox(o + point - radiusOff,
                                           o + point + radiusOff)
                if not self.roi.contains(circleBounds):
                    continue  # FIXME: add arcs if intersects
            p = intPos((numpy.array((point[0], point[1])) + o2) * self.scale)
            dc = fig.Circle(p, radius * self.scale)
            for a in attr:
                if a != "offset":
                    setattr(dc, a, attr[a])
            if returnIndices:
                result.append((i, dc))
            compound.append(dc)

        return result
예제 #7
0
 def mouseMoved(self, x, y):
     if not self._painting: return
     # TODO: update overlay
     x1, y1 = self.startPos
     x, y = intPos((x, y))
     self.setROI(
         Rect2D(min(x1, x), min(y1, y),
                max(x1, x) + 1,
                max(y1, y) + 1))
예제 #8
0
파일: figexport.py 프로젝트: hmeine/geomap
    def addPointCircles(self, points, radius, returnIndices = False, container = True, **attr):
        """fe.addPointCircles(points, radius, returnIndices = False,...)

        Marks each point in points with a circle of the given radius
        (in pixels) if it is within the clipping rect.  The list of
        fig.Circle objects is returned.  Again, note the possibility
        of setting properties (depth, penColor, lineStyle, lineWidth,
        ...) on all resulting objects via keyword arguments
        (cf. documentation of the FigExporter class).

        By default, circles will be filled, but have lineWidth=0.
        To draw a transparent circle, call:

        fi.addPointCircles([(5.2,5.3)], 2, penColor=fig.Color.Cyan,fillStyle=fig.FillStyle.None,lineWidth=1)

        If returnIndices is set to True (default: False), a list of
        (i, c) pairs is returned instead, where c is the fig.Circle
        object, and i is the index of the corresponding position in
        points."""

        if container == True:
            container = self.f

        attr = dict(attr)
        if "fillStyle" not in attr:
            attr["fillStyle"] = fig.FillStyle.Solid
        if "lineWidth" not in attr and attr["fillStyle"] != fig.FillStyle.None:
            attr["lineWidth"] = 0

        compound = fig.Compound(container)
        if returnIndices:
            result = []
        else:
            result = compound

        o = self.offset + attr.get('offset', (0,0))
        o2 = self.roi and o - self.roi.begin() or o
        for i, point in enumerate(points):
            if self.roi:
                radiusOff = (radius, radius)
                circleBounds = BoundingBox(
                    o + point - radiusOff, o + point + radiusOff)
                if not self.roi.contains(circleBounds):
                    continue # FIXME: add arcs if intersects
            p = intPos((numpy.array((point[0], point[1])) + o2) * self.scale)
            dc = fig.Circle(p, radius*self.scale)
            for a in attr:
                if a != "offset":
                    setattr(dc, a, attr[a])
            if returnIndices:
                result.append((i, dc))
            compound.append(dc)

        return result
예제 #9
0
파일: mapdisplay.py 프로젝트: hmeine/geomap
 def _calculatePoints(self):
     if not self._map():
         self._qpointlist = []
         return
     if self.relativeRadius:
         self.radius = int(self._zoom * self.origRadius + 0.5)
     d0 = (0.5 * (self._zoom-1) - self.radius,
           0.5 * (self._zoom-1) - self.radius)
     w = 2 * self.radius + 1
     self._elSize = QtCore.QSize(w, w)
     self._qpointlist = [None] * self._map().maxNodeLabel()
     for node in self._map().nodeIter():
         ip = intPos(numpy.array(node.position()) * self._zoom + d0)
         self._qpointlist[node.label()] = QtCore.QPoint(ip[0], ip[1])
예제 #10
0
파일: mapdisplay.py 프로젝트: hmeine/geomap
 def _calculatePoints(self):
     if not self._map():
         self._qpointlist = []
         return
     if self.relativeRadius:
         self.radius = int(self._zoom * self.origRadius + 0.5)
     d0 = (0.5 * (self._zoom - 1) - self.radius,
           0.5 * (self._zoom - 1) - self.radius)
     w = 2 * self.radius + 1
     self._elSize = QtCore.QSize(w, w)
     self._qpointlist = [None] * self._map().maxNodeLabel()
     for node in self._map().nodeIter():
         ip = intPos(numpy.array(node.position()) * self._zoom + d0)
         self._qpointlist[node.label()] = QtCore.QPoint(ip[0], ip[1])
예제 #11
0
    def mousePressed(self, x, y, button):
        if self._painting and button == QtCore.Qt.RightButton:
            self._stopPainting()
            self.setROI(self._oldROI)
            return True

        if button != QtCore.Qt.LeftButton or self.activeModifiers():
            return False

        if self.roi:
            mousePos = self._viewer.windowCoordinate(x, y)
            wr = self.windowRect()
            if (mousePos - wr.topLeft()).manhattanLength() < 9:
                self.startPos = self.roi.lowerRight() - (1,1)
            elif (mousePos - wr.bottomRight()).manhattanLength() < 9:
                self.startPos = self.roi.upperLeft()
            else:
                self.startPos = intPos((x, y))
        else:
            self.startPos = intPos((x, y))

        self.mouseMoved(x, y)
        self._startPainting()
        return True
예제 #12
0
    def mousePressed(self, x, y, button):
        if self._painting and button == QtCore.Qt.RightButton:
            self._stopPainting()
            self.setROI(self._oldROI)
            return True

        if button != QtCore.Qt.LeftButton or self.activeModifiers():
            return False

        if self.roi:
            mousePos = self._viewer.windowCoordinate(x, y)
            wr = self.windowRect()
            if (mousePos - wr.topLeft()).manhattanLength() < 9:
                self.startPos = self.roi.lowerRight() - (1, 1)
            elif (mousePos - wr.bottomRight()).manhattanLength() < 9:
                self.startPos = self.roi.upperLeft()
            else:
                self.startPos = intPos((x, y))
        else:
            self.startPos = intPos((x, y))

        self.mouseMoved(x, y)
        self._startPainting()
        return True
예제 #13
0
파일: figexport.py 프로젝트: hmeine/geomap
def visibleROI(imageWindow):
    viewer = hasattr(imageWindow, "viewer") \
             and imageWindow.viewer or imageWindow
    return Rect2D(
        intPos(viewer.toImageCoordinates(0, 0)),
        intPos(viewer.toImageCoordinates(viewer.width(), viewer.height())))
예제 #14
0
파일: figexport.py 프로젝트: hmeine/geomap
def visibleROI(imageWindow):
    viewer = hasattr(imageWindow, "viewer") \
             and imageWindow.viewer or imageWindow
    return Rect2D(
        intPos(viewer.toImageCoordinates(0, 0)),
        intPos(viewer.toImageCoordinates(viewer.width(), viewer.height())))
예제 #15
0
파일: mapdisplay.py 프로젝트: hmeine/geomap
 def _postMergeFacesHook(self, survivor):
     if self._backgroundMode < 3:
         return
     if survivor.label():
         self._redisplayROIImage(intPos(survivor.boundingBox()))
예제 #16
0
파일: mapdisplay.py 프로젝트: hmeine/geomap
 def _preRemoveBridgeHook(self, dart):
     if self._backgroundMode >= 3:
         self._bridgeROI = intPos(dart.edge().boundingBox())
     return True
예제 #17
0
파일: mapdisplay.py 프로젝트: hmeine/geomap
 def _preRemoveBridgeHook(self, dart):
     if self._backgroundMode >= 3:
         self._bridgeROI = intPos(dart.edge().boundingBox())
     return True
예제 #18
0
파일: mapdisplay.py 프로젝트: hmeine/geomap
 def _postMergeFacesHook(self, survivor):
     if self._backgroundMode < 3:
         return
     if survivor.label():
         self._redisplayROIImage(intPos(survivor.boundingBox()))