Exemple #1
0
	def polyDrawer(self,event,x,y,flags,param):
		if event == cv.CV_EVENT_LBUTTONDOWN:
			print "Left button: Point x:%f, y:%f"%(x,y)
			self.newPoly.append(Geometry2D.Point(x,y))
			
		elif event == cv.CV_EVENT_RBUTTONDOWN:
			print "Right button"
			poly = Geometry2D.Polygon(*self.newPoly)
			cvPoly = CVPolygon(self.getDrawColor(),self.front(),poly)
			self.addCVShape(cvPoly)
			self.newPoly = []	
		
		elif len(self.newPoly) > 1:
			startPt = self.newPoly[-1]
			print "StartPoint", startPt
			endPt = Geometry2D.Point(x,y)
			print "End Point"
			line = Geometry2D.LineSegment(startPt,endPt)
			cvLine = CVLineSegment(self.lineColor,self.tempFront(),line)
		 #self.addTempCVShape(cvLine)
		for i, pt in enumerate(self.newPoly):
			self.highlightPt(pt)
			if i > 0:
				startPt = self.newPoly[i-1]
				line = Geometry2D.LineSegment(startPt,pt)
				cvLine = CVLineSegment(self.lineColor,self.tempFront(),line)
				self.addTempCVShape(cvLine)
			elif i == len(self.newPoly)-1:
				endPt = self.newPoly[0]
				line = Geometry2D.LineSegment(pt,endPt)
				cvLine = CVLineSegment(self.lineColor,self.tempFront(), line)
				self.addTempCVShape(cvLine)
Exemple #2
0
    def symmPolyDrawer(self, event, x, y, flags, param):
        if event == cv.CV_EVENT_LBUTTONDOWN:
            self.newPoly.append(Geometry2D.Point(x, y))

        elif event == cv.CV_EVENT_RBUTTONDOWN:
            print "MADE IT"
            backwards = list(self.newPoly)
            backwards.reverse()
            backwards = [pt.toTuple() for pt in backwards]
            for pt in backwards:
                print "Looking at pt"
                newpt = Vector2D.mirror_pt(pt, self.symmline)
                print newpt
                self.newPoly.append(Geometry2D.Point(newpt[0], newpt[1]))
                print "Added pt"
                print len(self.newPoly)
            poly = Geometry2D.Polygon(*self.newPoly)
            cvPoly = CVPolygon(self.getDrawColor(), self.front(), poly)
            self.addCVShape(cvPoly)
            self.newPoly = []

        elif len(self.newPoly) > 0:
            startPt = self.newPoly[-1]
            endPt = Geometry2D.Point(x, y)
            line = Geometry2D.LineSegment(startPt, endPt)
            cvLine = CVLineSegment(self.lineColor, self.tempFront(), line)
            self.addTempCVShape(cvLine)
        for i, pt in enumerate(self.newPoly):
            self.highlightPt(pt)
            if i > 0:
                startPt = self.newPoly[i - 1]
                line = Geometry2D.LineSegment(startPt, pt)
                cvLine = CVLineSegment(self.lineColor, self.tempFront(), line)
                self.addTempCVShape(cvLine)
Exemple #3
0
	def getShape(self):
		((buttonWidth,buttonHeight),baseline) = cv.GetTextSize(self.getText(),self.getFont())
		origin = self.getBottomLeft()
		xMin = origin.x()-4
		xMax = origin.x() + buttonWidth
		yMin = origin.y() - buttonHeight
		yMax = origin.y()+4
		return Geometry2D.Polygon(Geometry2D.Point(xMin,yMin),Geometry2D.Point(xMin,yMax),Geometry2D.Point(xMax,yMax),Geometry2D.Point(xMax,yMin))
Exemple #4
0
 def poly_handler(self,stamped_poly):
     self.poly_frame = stamped_poly.header.frame_id
     self.z_offset = stamped_poly.z_offset
     points = [Geometry2D.Point(point.x,point.y) for point in stamped_poly.vertices]
     vertices = self.center_and_bound(points,500)
     poly = Geometry2D.Polygon(*vertices)
     self.poly_cache = poly
     cvPoly = CVPolygon(Colors.GREEN,self.gui.front(),poly)
     self.gui.clearShapes()
     self.gui.addCVShape(cvPoly)
     self.handle_automatic_folds(vertices)
Exemple #5
0
	def getBar(self):
		(valMin,valMax) = self.getRange()
		value = self.getValue()
		pct = (value - valMin) / (valMax - valMin)
		origin = self.getOrigin()
		barWidth = 5.0
		pt1 = Geometry2D.Point(origin.x()-barWidth/2 + pct*self.getSliderWidth(), origin.y())
		pt2 = Geometry2D.Point(pt1.x(),pt1.y() - self.getSliderHeight())
		pt3 = Geometry2D.Point(pt1.x()+barWidth,pt2.y())
		pt4 = Geometry2D.Point(pt3.x(),pt1.y())
		bar = Geometry2D.Polygon(pt1,pt2,pt3,pt4)
		return CVPolygon(Colors.invertCV(self.getColor()),1,bar)
    def polyDrawer(self, event, x, y, flags, param):
        if event == cv.CV_EVENT_LBUTTONDOWN:
            self.newPoly.append(Geometry2D.Point(x, y))

        elif event == cv.CV_EVENT_RBUTTONDOWN:
            poly = Geometry2D.Polygon(*self.newPoly)
            cvPoly = CVPolygon(self.getDrawColor(), self.front(), poly)
            self.addCVShape(cvPoly)
            self.newPoly = []

        elif len(self.newPoly) > 0:
            startPt = self.newPoly[-1]
            endPt = Geometry2D.Point(x, y)
            line = Geometry2D.LineSegment(startPt, endPt)
            cvLine = CVLineSegment(self.lineColor, self.tempFront(), line)
            self.addTempCVShape(cvLine)
        for i, pt in enumerate(self.newPoly):
            self.highlightPt(pt)
            if i > 0:
                startPt = self.newPoly[i - 1]
                line = Geometry2D.LineSegment(startPt, pt)
                cvLine = CVLineSegment(self.lineColor, self.tempFront(), line)
                self.addTempCVShape(cvLine)
Exemple #7
0
	def getShape(self):
		pt1 = self.getOrigin()
		pt2 = Geometry2D.Point(pt1.x(),pt1.y()-self.getSliderHeight())
		pt3 = Geometry2D.Point(pt2.x()+self.getSliderWidth(),pt2.y())
		pt4 = Geometry2D.Point(pt3.x(),pt1.y())
		return Geometry2D.Polygon(pt1,pt2,pt3,pt4)