def onMouseDown(self, e): self.f = pyHPolylineFigure() p = pyHPoint(e.getX(), e.getY()) self.f.addPoint(p) p = pyHPoint(e.getX(), e.getY()) self.f.addPoint(p) self.view.getDrawing().addFigure(self.f)
def onMouseDown(self,e): self.f=pyHPolylineFigure() p=pyHPoint(e.getX(),e.getY()) self.f.addPoint(p) p=pyHPoint(e.getX(),e.getY()) self.f.addPoint(p) self.view.getDrawing().addFigure(self.f)
def _addZigzagForm(self): points = self.getPoints() p0 = points[0] pl = points[-1] self.removeLastPoint() p_new1 = pyHPoint(p0.getX() + 100, p0.getY()) p_new2 = pyHPoint(pl.getX() - 50, pl.getY()) self.addPoint(p_new1) self.addPoint(p_new2) self.addPoint(pl)
def _set_zigzag_form(self): """ Dota al conector de una figura de zigzag. :return: """ start_point = self.getConnectorStart().locate() end_point = self.getConnectorEnd().locate() new_point_0 = pyHPoint(start_point.getX() + 100, start_point.getY()) new_point_1 = pyHPoint(end_point.getX() - 50, end_point.getY()) self.points = [start_point, new_point_0, new_point_1, end_point]
def getHandles(self): handles=[] r=self.getDisplayBox() x=r.getX() y=r.getY() w=r.getWidth() h=r.getHeight() handles.append(pyHNullHandle(self,pyHPoint(x,y))) handles.append(pyHNullHandle(self,pyHPoint(x+w,y))) handles.append(pyHNullHandle(self,pyHPoint(x,y+h))) handles.append(pyHNullHandle(self,pyHPoint(x+w,y+h))) return handles
def getHandles(self): r = self.getDisplayBox() x = r.getX() y = r.getY() w = r.getWidth() h = r.getHeight() h0 = pyHNullHandle(self, pyHPoint(x + w, y - 20)) h1 = pyHNullHandle(self, pyHPoint(x + w, y + h)) h2 = pyHNullHandle(self, pyHPoint(x - 20, y - 20)) h3 = pyHNullHandle(self, pyHPoint(x - 20, y + h)) return [h0, h1, h2, h3]
def openDXF(self,fileName): d=self.getView().getDrawing() for et in dxfreader.getEtt(fileName): if et["0"]=="LINE": x0=float(et["10"]) y0=float(et["20"]) p0=pyHPoint(x0,y0) x1=float(et["11"]) y1=float(et["21"]) p1=pyHPoint(x1,y1) l=pyHPolylineFigure() l.addPoint(p0) l.addPoint(p1) d.addFigure(l) if et["0"]=="CIRCLE": x0=float(et["10"]) y0=float(et["20"]) r =float(et["40"]) c=pyHEllipseFigure(x0-r,y0-r,2*r,2*r) d.addFigure(c) if et["0"]=="POINT": x0=float(et["10"]) y0=float(et["20"]) r =2 c=pyHEllipseFigure(x0-r,y0-r,2*r,2*r) d.addFigure(c) if et["0"]=="ARC": x0=float(et["10"]) y0=float(et["20"]) r =float(et["40"]) ans=float(et["50"]) ane=float(et["51"]) c=pyHArcFigure(x0-r,y0-r,2*r,2*r,ans,ane) d.addFigure(c) if et["0"]=="LWPOLYLINE": xs=et["10"] ys=et["20"] c=pyHPolylineFigure() for i,x in enumerate(xs): p=pyHPoint(float(x),float(ys[i])) c.addPoint(p) d.addFigure(c) if et["0"]=="SPLINE": xs=et["10"] ys=et["20"] c=pyHSplineFigure() for i,x in enumerate(xs): p=pyHPoint(float(x),float(ys[i])) c.addPoint(p) d.addFigure(c) self.fillTree()
def openDXF(self, fileName): d = self.getView().getDrawing() for et in dxfreader.getEtt(fileName): if et["0"] == "LINE": x0 = float(et["10"]) y0 = float(et["20"]) p0 = pyHPoint(x0, y0) x1 = float(et["11"]) y1 = float(et["21"]) p1 = pyHPoint(x1, y1) l = pyHPolylineFigure() l.addPoint(p0) l.addPoint(p1) d.addFigure(l) if et["0"] == "CIRCLE": x0 = float(et["10"]) y0 = float(et["20"]) r = float(et["40"]) c = pyHEllipseFigure(x0 - r, y0 - r, 2 * r, 2 * r) d.addFigure(c) if et["0"] == "POINT": x0 = float(et["10"]) y0 = float(et["20"]) r = 2 c = pyHEllipseFigure(x0 - r, y0 - r, 2 * r, 2 * r) d.addFigure(c) if et["0"] == "ARC": x0 = float(et["10"]) y0 = float(et["20"]) r = float(et["40"]) ans = float(et["50"]) ane = float(et["51"]) c = pyHArcFigure(x0 - r, y0 - r, 2 * r, 2 * r, ans, ane) d.addFigure(c) if et["0"] == "LWPOLYLINE": xs = et["10"] ys = et["20"] c = pyHPolylineFigure() for i, x in enumerate(xs): p = pyHPoint(float(x), float(ys[i])) c.addPoint(p) d.addFigure(c) if et["0"] == "SPLINE": xs = et["10"] ys = et["20"] c = pyHSplineFigure() for i, x in enumerate(xs): p = pyHPoint(float(x), float(ys[i])) c.addPoint(p) d.addFigure(c) self.fillTree()
def onMouseDown(self,e): p=pyHPoint(e.getX(),e.getY()) if e.getPyHButton()==pyHStandardEvent.LeftButton: try: h=self.view.findHandle(p) print "Handle found" self.delegateTool=h except (pyHHandleNotFound): try: f=self.view.findFigure(p) if not self.view.isThisFigureInSelectedFigures(f): self.getView().clearSelectedFigures() self.getView().selectFigure(f) print "Found NOT selected figure" self.delegateTool=pyHFigureMoveTool(self.view) else: print "Found selected figure" self.getView().getSelectionFigure().removeFigure(f) self.delegateTool=pyHAbstractTool(self.view) except (pyHFigureNotFound): print "Selecting Area" self.delegateTool=pyHAreaSelectionTool(self.view) if e.getPyHButton()==pyHStandardEvent.RightButton: self.delegateTool=pyHViewTranslationTool(self.view) self.delegateTool.onMouseDown(e)
def onMouseDobleClick(self, e): if e.isLeftClick(): actual_value = self.getView() p = pyHPoint(e.getX(), e.getY()) try: figure = actual_value.findFigure(p) if isinstance(figure, NodeFigure): if figure.is_input(): container_figure = figure.figures[0] color = container_figure.getAttribute('COLOR') container_figure.setColor( pyHAttributeColor(90, 90, 90, 255)) node = figure.get_node() actual_value = node.getValue() if node else "" dialog = AssignValuesDialog(self.getView(), figure.get_text(), actual_value) pos = self.getView().cursor().pos() dialog.move(pos.x() + 30, pos.y() - 70) if dialog.exec(): actual_value = dialog.get_value() if actual_value: figure.setValue(actual_value) figure.set_text(dialog.get_name()) container_figure.setColor(color) except pyHFigureNotFound: pass
def onMouseDown(self,e): p=pyHPoint(e.getX(),e.getY()) self.f.addPoint(p) if(self.f.getLenght()==1): # p=pyHPoint(e.getX(),e.getY()) # self.f.addPoint(p) self.view.getDrawing().addFigure(self.f)
def onMouseDown(self, e): p = pyHPoint(e.getX(), e.getY()) self.f.addPoint(p) if (self.f.getLenght() == 1): # p=pyHPoint(e.getX(),e.getY()) # self.f.addPoint(p) self.view.getDrawing().addFigure(self.f)
def onMouseUp(self, e): print("mouseUp pyHConnectionTool") p = pyHPoint(e.getX(), e.getY()) try: f = self.view.findFigureReversed(p) if f == self.createdFigure: raise pyHFigureNotFound("Figure is the connection Figure") #if not 'imageChanged' in set(dir(f)): # raise pyHFigureNotFound("Figure is not an image observer") f.setImageSourceFigure( self.createdFigure.getConnectorStart().getOwner()) #self.createdFigure.getConnectorStart().getOwner().addChangedImageObserver(f) print(dir(f)) print('imageChanged' in set(dir(f))) cEnd = f.findConnector(p) self.createdFigure.setConnectorEnd(cEnd) pl = cEnd.findEnd(self.createdFigure) lp = self.createdFigure.getLastPoint() lp.setX(pl.getX()) lp.setY(pl.getY()) #self.createdFigure.getConnectorStart().getOwner().addChangedFigureObserver(self.createdFigure) #self.createdFigure.getConnectorEnd().getOwner().addChangedFigureObserver(self.createdFigure) self.figureClicked = False except (pyHFigureNotFound): print("No figure clicked on mouseUP pyHConnectionTool") self.view.getDrawing().removeFigure(self.createdFigure)
def getHandles(self): r = self.getDecoratedFigure().getDisplayBox() x = r.getX() y = r.getY() w = r.getWidth() h = r.getHeight() h0 = pyHBackwardHandle(self, pyHPoint(x + w, y - 20)) h0.handle_figure.setAttribute('FILL', pyHAttributeFillColor(255, 0, 0, 200)) h1 = pyHForwardHandle(self, pyHPoint(x + w, y + h)) h1.handle_figure.setAttribute('FILL', pyHAttributeFillColor(0, 0, 255, 200)) handles = [h0, h1] return handles
def onMouseMove(self,e): print "mouseMove ppyHNullHandle" p=pyHPoint(e.getX(),e.getY()) dx=e.getX()-self.anchorPoint.getX() dy=e.getY()-self.anchorPoint.getY() self.owner.move(dx,dy) self.anchorPoint=p
def onMouseDown(self, e): p = pyHPoint(e.getX(), e.getY()) try: h = self.view.findHandle(p) # h.owner.removeExpresionsInfo() self.delegateTool = h except pyHHandleNotFound: try: f = self.view.findFigure(p) f = pyHHandleInfoDecorator(f, self.view) if not self.view.isThisFigureInSelectedFigures(f): for fs in self.getView().getSelectionFigure().getFigures(): fs.removeFigure() self.getView().clearSelectedFigures() self.getView().selectFigure(f) self.getView().getEditor().moveFront() # pyHBackwardInfoDecorator(f).getBackwardExpresions() else: # desseleccionar Figura self.getView().clearSelectedFigures() #f.removeExpresionsInfo() self.getView().update() self.delegateTool = AbstractTool(self.view) except pyHFigureNotFound: self.delegateTool = AbstractTool(self.view) self.delegateTool.onMouseDown(e)
def onMouseMove(self, e): p = pyHPoint(e.getX(), e.getY()) dx = e.getX() - self.anchorPoint.getX() dy = e.getY() - self.anchorPoint.getY() for f in self.getView().getSelectedFigures(): f.move(dx, dy) self.anchorPoint = p
def onMouseUp(self,e): print "mouseUp pyHConnectionTool" p=pyHPoint(e.getX(),e.getY()) try: f=self.view.findFigureReversed(p) if f==self.createdFigure: raise pyHFigureNotFound("Figure is the connection Figure") #if not 'imageChanged' in set(dir(f)): # raise pyHFigureNotFound("Figure is not an image observer") f.setImageSourceFigure(self.createdFigure.getConnectorStart().getOwner()) #self.createdFigure.getConnectorStart().getOwner().addChangedImageObserver(f) print dir(f) print 'imageChanged' in set(dir(f)) cEnd=f.findConnector(p) self.createdFigure.setConnectorEnd(cEnd) pl=cEnd.findEnd(self.createdFigure) lp=self.createdFigure.getLastPoint() lp.setX(pl.getX()) lp.setY(pl.getY()) #self.createdFigure.getConnectorStart().getOwner().addChangedFigureObserver(self.createdFigure) #self.createdFigure.getConnectorEnd().getOwner().addChangedFigureObserver(self.createdFigure) self.figureClicked=False except (pyHFigureNotFound): print "No figure clicked on mouseUP pyHConnectionTool" self.view.getDrawing().removeFigure(self.createdFigure)
def onMouseMove(self,e): print "mouseMove ppyHFigureMovetool" p=pyHPoint(e.getX(),e.getY()) dx=e.getX()-self.anchorPoint.getX() dy=e.getY()-self.anchorPoint.getY() for f in self.getView().getSelectedFigures(): f.move(dx,dy) self.anchorPoint=p
def addFigure(self, f): l = self.getLength() nextCol = l % self.cols nextRow = l // self.cols if self.updown: gridPos = pyHPoint( nextCol * self.cellWidth, self.height - self.cellHeight - nextRow * self.cellHeight) else: gridPos = pyHPoint(nextCol * self.cellWidth, nextRow * self.cellHeight) sr = self.rf.getDisplayBox() drawPos = sr.getOriginPoint() + gridPos fr = f.getDisplayBox() offsetPos = drawPos - fr.getOriginPoint() f.move(offsetPos.getX(), offsetPos.getY()) pyHCompositeFigure.addFigure(self, f)
def setConnectorStart(self, connector): connector = connector[0] if isinstance(connector, list) else connector self.connectorStart = connector p0 = connector.findStart(self) self.points[0] = p0 self.points[1] = pyHPoint(p0.getX() + self.lenline, p0.getY()) connector.getOwner().addChangedFigureObserver(self)
def onMouseDobleClick(self,e): v=self.getView() p=pyHPoint(e.getX(),e.getY()) try: f=v.findFigure(p) r=f.getDisplayBox() v.setTransformFitToRectangle(r) except (pyHFigureNotFound): v.setTransformFitToDrawing()
def onMouseDobleClick(self, e): v = self.getView() p = pyHPoint(e.getX(), e.getY()) try: f = v.findFigure(p) r = f.getDisplayBox() v.setTransformFitToRectangle(r) except (pyHFigureNotFound): v.setTransformFitToDrawing()
def onMouseMove(self, e): p = pyHPoint(e.getX(), e.getY()) try: f = self.view.findFigure(p) if self.fig == f: self.fig.setAttribute('WIDTH', pyHAttributeWidth(4)) else: self.fig.setAttribute('WIDTH', pyHAttributeWidth(2)) except pyHFigureNotFound: self.fig.setAttribute('WIDTH', pyHAttributeWidth(2))
def openPLT(self, fileName): d = self.getView().getDrawing() f = pyHPolylineFigure() for t in pltreader.getPLT(fileName): if len(t) == 3: c, x, y = t if pltreader.isPU(c): if f: if len(f.getPoints()) > 1: d.addFigure(f) f = pyHPolylineFigure() xf = float(x) * 0.025 yf = float(y) * 0.025 p = pyHPoint(xf, yf) f.addPoint(p) elif pltreader.isPD(c): xf = float(x) * 0.025 yf = float(y) * 0.025 p = pyHPoint(xf, yf) f.addPoint(p)
def openPLT(self,fileName): d=self.getView().getDrawing() f=pyHPolylineFigure() for t in pltreader.getPLT(fileName): if len(t)==3: c,x,y=t if pltreader.isPU(c): if f: if len(f.getPoints())>1: d.addFigure(f) f=pyHPolylineFigure() xf=float(x)*0.025 yf=float(y)*0.025 p=pyHPoint(xf,yf) f.addPoint(p) elif pltreader.isPD(c): xf=float(x)*0.025 yf=float(y)*0.025 p=pyHPoint(xf,yf) f.addPoint(p)
def getHandles(self): #handles=super(pyHNodePoseFigure,self).getHandles() handles = [] r = self.getDisplayBox() x = r.getX() y = r.getY() w = r.getWidth() h = r.getHeight() handles.append( pyHCreateLandMarkMeasureHandle(self, pyHPoint(x, y + h / 2))) return handles
def onMouseDown(self,e): if e.isLeftClick(): self.figureClicked = False click_point = pyHPoint(e.getX(), e.getY()) start_socket = self._search_output_socket_on_point(click_point) if start_socket and start_socket.is_free(): self.figureClicked = True self.created_link = copy.deepcopy(self.prototype) self.created_link.set_start_socket(start_socket) self._add_figure_to_drawing(self.created_link)
def onMouseMove(self,e): click_point = pyHPoint(e.getX(), e.getY()) found_socket = self._find_socket_to_emphasize(click_point) if found_socket and not self.conexion_socket: self._emphasize_socket(found_socket, EMPHASIS_FACTOR) elif not found_socket and self.conexion_socket: self._deemphasize_socket(EMPHASIS_FACTOR) if self.created_link: self._update_link(click_point)
def findConnector(self,p): minD=1e90 for c in self.getConnectors(): r=c.getDisplayBox() pc=pyHPoint(r.getX()+r.getWidth()/2,r.getY()+r.getHeight()/2) #central point of connector dx=pc.getX()-p.getX() dy=pc.getY()-p.getY() d=math.sqrt(dx*dx+dy*dy) if d<minD: minD=d closestConnector=c return closestConnector
def onMouseDown(self, e): p = pyHPoint(e.getX(), e.getY()) try: f = self.view.findFigure(p) self.createdFigure = f except (pyHFigureNotFound): self.createdFigure = copy.deepcopy(self.prototype) r = self.createdFigure.getDisplayBox() self.createdFigure.move(e.getX() - r.getWidth() / 2, e.getY() - r.getHeight() / 2) self.view.getDrawing().addFigure(self.createdFigure) self.view.update()
def onMouseDobleClick(self,e): #Not delegation is done v=self.getView() p=pyHPoint(e.getX(),e.getY()) try: f=v.findFigure(p) if not self.view.isThisFigureInSelectedFigures(f): r=f.getDisplayBox() else: r=v.getSelectionFigure().getDisplayBox() v.setTransformFitToRectangle(r) except (pyHFigureNotFound): v.setTransformFitToDrawing()
def findConnector(self, p): minD = 1e90 for c in self.getConnectors(): r = c.getDisplayBox() pc = pyHPoint(r.getX() + r.getWidth() / 2, r.getY() + r.getHeight() / 2) #central point of connector dx = pc.getX() - p.getX() dy = pc.getY() - p.getY() d = math.sqrt(dx * dx + dy * dy) if d < minD: minD = d closestConnector = c return closestConnector
def fill(self): for i in range(2 * self.n + 1): a = pi / self.n * i xs = cos(a + pi / 2) # first tip start at 90 degrees i mean poining up ys = sin(a + pi / 2) if i % 2 == 0: xs *= self.ro ys *= self.ro else: xs *= self.ri ys *= self.ri p = pyHPoint(self.x + xs, self.y + ys) self.addPoint(p)
def onMouseUp(self, e): click_point = pyHPoint(e.getX(), e.getY()) input_socket = self._search_input_socket_on_point(click_point) if input_socket and input_socket.is_free(): if not self._same_owner_as_link_start(input_socket): self.created_link.set_end_socket(input_socket) self.figureClicked = False self.created_link = None self.view.save_state(self.state) self._deemphasize_socket(EMPHASIS_FACTOR) self.state = self.view.actual_state() else: self._onMouseUpError() else: self._onMouseUpError()
def onMouseUp(self,e): print "mouseUp pyHConnectionImageFilterTool" p=pyHPoint(e.getX(),e.getY()) try: f=self.view.findFigureReversed(p) if f==self.createdFigure: raise pyHFigureNotFound("Figure is the connection Figure") cEnd=f.findConnector(p) self.createdFigure.setConnectorEnd(cEnd) pl=cEnd.findEnd(self.createdFigure) lp=self.createdFigure.getLastPoint() lp.setX(pl.getX()) lp.setY(pl.getY()) self.createdFigure.getConnectorStart().getOwner().addChangedFigureObserver(self.createdFigure) self.createdFigure.getConnectorEnd().getOwner().addChangedFigureObserver(self.createdFigure) self.figureClicked=False except (pyHFigureNotFound): print "No figure found on mouseUP position in pyHConnectionImageFilterTool" self.view.getDrawing().removeFigure(self.createdFigure)
def onMouseMove(self, e): ex = e.getX() ey = e.getY() d = self.view.getDrawing() d.removeFigure(self.f) try: nf = self.view.findFigure(pyHPoint(ex, ey)) if isinstance(nf, pyHNodeLandMarkFigure): self.f.setColor(0, 0, 255) else: if isinstance(nf, pyHNodePoseFigure): self.f.setColor(0, 255, 0) except pyHFigureNotFound: self.f.setColor(0, 0, 0) if (self.f.getLenght() > 0): p = self.f.getLastPoint() p.setX(e.getX()) p.setY(e.getY()) d.addFigure(self.f)
def onMouseUp(self, e): ex = e.getX() ey = e.getY() d = self.view.getDrawing() d.removeFigure(self.f) try: nf = self.view.findFigure(pyHPoint(ex, ey)) if isinstance(nf, pyHNodeLandMarkFigure): cnf = nf.getDisplayBox().getCenterPoint() cow = self.owner.getDisplayBox().getCenterPoint() pf = cnf * 0.5 + cow * 0.5 lmmf = pyHNodeLandMarkMeasureFigure(pf.getX() - 1, pf.getY() - 1, 2, 2, "?") d.addFigure(lmmf) cf = pyHConnectionFigure() cf.setColor(0, 0, 255, 100) cf.connectFigures(self.owner, lmmf) d.addFigure(cf) cf = pyHConnectionFigure() cf.setColor(100, 0, 0, 100) cf.connectFigures(lmmf, nf) d.addFigure(cf) lmmf.setText(nf.getText()) d.addFigure(cf) if isinstance(nf, pyHNodePoseFigure): cnf = nf.getDisplayBox().getCenterPoint() cow = self.owner.getDisplayBox().getCenterPoint() pf = cnf * 0.5 + cow * 0.5 npf = pyHNodePoseFigure(pf.getX() - 1, pf.getY() - 1, 2, 2, "?") d.addFigure(npf) cf = pyHConnectionFigure() cf.setColor(0, 0, 255, 100) cf.connectFigures(self.owner, npf) d.addFigure(cf) cf = pyHConnectionFigure() cf.setColor(100, 0, 0, 100) cf.connectFigures(npf, nf) d.addFigure(cf) npf.setText(nf.getText()) d.addFigure(cf) except pyHFigureNotFound: print "No figure found"
def onMouseDown(self,e): print "mouseDown pyHConnectionImageFilterTool" self.figureClicked=False p=pyHPoint(e.getX(),e.getY()) try: f=self.view.findFigure(p) cStart=f.findConnector(p) print dir(f) self.figureClicked=True self.createdFigure=copy.deepcopy(self.prototype) self.createdFigure.setConnectorStart(cStart) self.view.getDrawing().addFigure(self.createdFigure) #two points in order to do feedback with the second one p0=cStart.findStart(self.createdFigure) p1=cStart.findStart(self.createdFigure) self.createdFigure.addPoint(p0) self.createdFigure.addPoint(p1) except (pyHFigureNotFound): print "No figure clicked"
def onMouseDown(self,e): print "mouseDown pyHConnectionTool" self.figureClicked=False p=pyHPoint(e.getX(),e.getY()) try: f=self.view.findFigure(p) #if not 'notifyImageChanged' in set(dir(f)): # raise pyHFigureNotFound("Figure is not an image source") cStart=f.findConnector(p) print dir(f) print 'notifyImageChanged' in set(dir(f)) self.figureClicked='notifyImageChanged' in set(dir(f)) self.createdFigure=copy.deepcopy(self.prototype) self.createdFigure.setConnectorStart(cStart) self.view.getDrawing().addFigure(self.createdFigure) #two points in order to do feedback with the second one p0=cStart.findStart(self.createdFigure) p1=cStart.findStart(self.createdFigure) self.createdFigure.addPoint(p0) self.createdFigure.addPoint(p1) except (pyHFigureNotFound): print "No figure clicked"
def onMouseDown(self,e): p=pyHPoint(e.getX(),e.getY()) try: h=self.view.findHandle(p) print "handle encontrado" self.delegateTool=h except (pyHHandleNotFound): try: f=self.view.findFigure(p) if not self.view.isThisFigureInSelectedFigures(f): self.getView().clearSelectedFigures() self.getView().selectFigure(f) print "figura encontrada" self.delegateTool=pyHFigureMoveTool(self.view) else: print "figura deseleccionada" self.getView().getSelectionFigure().removeFigure(f) self.delegateTool=pyHAbstractTool(self.view) except (pyHFigureNotFound): print "seleccionando Area" self.delegateTool=pyHAreaSelectionTool(self.view) self.delegateTool.onMouseDown(e)
def locate(self,figure): r=figure.getDisplayBox() return pyHPoint(r.getX()+r.getWidth()*self.rx,r.getY()+r.getHeight()*self.ry)
def onMouseDown(self,e): self.p=pyHPoint(e.getX(),e.getY())
def onMouseDown(self,e): self.anchorPoint=pyHPoint(e.getX(),e.getY())
def __init__(self): super(pyHStandardEditor, self).__init__() pyHAbstractEditor.__init__(self) self.initActionMenuToolBars() self.statusBar() self.initUI() d=self.getView().getDrawing() txt=pyHTextFigure(0,0,20,20,"Hola Caracola") d.addFigure(txt) cam1=pyHCameraFigure(0,200,50,50,1) d.addFigure(cam1) imgc1=pyHImageDottedFigure(150,250,320,240) imgc1.setPoints([pyHPoint(20,20),pyHPoint(30,30)]) d.addFigure(imgc1) cam1.addChangedImageObserver(imgc1) cam=pyHCameraFigure(0,100,50,50,0) d.addFigure(cam) img0=pyHImageFigure(50,10,320,240) d.addFigure(img0) cam.addChangedImageObserver(img0) img1=pyHImageFigure(400,10,320,240) d.addFigure(img1) fimg=pyHImageFilterFigure(300,300,40,40) d.addFigure(fimg) cam.addChangedImageObserver(fimg) fimg.addChangedImageObserver(img1) #img2=pyHImageFigure(0,300,320,240) #d.addFigure(img2) img3=pyHImageFigure(400,10,320,240) d.addFigure(img3) fimg1=pyHImageFilterFigure(300,400,40,40) d.addFigure(fimg1) fimg1.setFilter(Gaussian()) cam.addChangedImageObserver(fimg1) fimg1.addChangedImageObserver(img3) fimgH=pyHImageFilterFigure(400,500,30,30) d.addFigure(fimgH) fimgH.setFilter(HistogramColor()) fimg1.addChangedImageObserver(fimgH) imgH=pyHImageFigure(500,0,256,150) d.addFigure(imgH) fimgH.addChangedImageObserver(imgH) fimg2=pyHImageFilterFigure(300,500,40,40) d.addFigure(fimg2) fimg2.setFilter(SobelX()) fimg1.addChangedImageObserver(fimg2) img4=pyHImageFigure(0,300,320,240) d.addFigure(img4) fimg2.addChangedImageObserver(img4) fimg2y=pyHImageFilterFigure(240,300,40,40) d.addFigure(fimg2y) fimg2y.setFilter(SobelY()) fimg1.addChangedImageObserver(fimg2y) img4y=pyHImageFigure(240,300,320,240) d.addFigure(img4y) fimg2y.addChangedImageObserver(img4y) img4=pyHImageFigure(10,600,320,240) d.addFigure(img4) fimg4=pyHImageFilterFigure(0,600,40,40) d.addFigure(fimg4) fimg4.setFilter(OpticalFlow()) cam.addChangedImageObserver(fimg4) fimg4.addChangedImageObserver(img4) img5=pyHImageFigure(400,600,320,240) d.addFigure(img5) fimg5=pyHImageFilterFigure(400,600,40,40) d.addFigure(fimg5) fimg5.setFilter(FastFeatureDetector()) cam.addChangedImageObserver(fimg5) img5.setImageSourceFigure(fimg5) # #imgCm1=pyHImage('/Users/paco/Pictures/sfm/urjcMostolesMobilLG440-15011301/CAM00295.jpg') # imgCm1=pyHImage('/media/francisco/Packard Bell/Users/paco/Pictures/sfm/pistaTenis/CAM00698.jpg') # #imgCm1=pyHImage('../images/im2.png') # ifcm1=pyHImageDottedFigure(0,0,240,320,imgCm1) # ifcm1.setPoints([pyHPoint(400,690),pyHPoint(1776,690),pyHPoint(1394,560),pyHPoint(737,560)]) # d.addFigure(ifcm1) # # fd=FeatureDetector("SIFT") # imgCvCm1Fd=fd.process(imgCm1.data) # #imgCm1=pyHImage('../images/im2.png') # imgCm1Fd=pyHImage() # imgCm1Fd.setData(imgCvCm1Fd) # ifcm1Fd=pyHImageFigure(0,320,240,320,imgCm1Fd) # d.addFigure(ifcm1Fd) # # #imgCm2=pyHImage('/Users/paco/Pictures/sfm/urjcMostolesMobilLG440-15011301/CAM00294.jpg') # imgCm2=pyHImage('/media/francisco/Packard Bell/Users/paco/Pictures/sfm/pistaTenis/CAM00699.jpg') # #imgCm1=pyHImage('../images/im2.png') # ifcm2=pyHImageDottedFigure(240,0,240,320,imgCm2) # ifcm2.setPoints([pyHPoint(400,690),pyHPoint(1776,690),pyHPoint(1394,560),pyHPoint(737,560)]) # d.addFigure(ifcm2) # # imgCvCm2Fd=fd.process(imgCm2.data) # imgCm2Fd=pyHImage() # imgCm2Fd.setData(cv2.addWeighted(imgCvCm1Fd,0.5,imgCvCm2Fd,0.5,0)) # ifcm2Fd=pyHImageFigure(0,0,240,320,imgCm2Fd) # d.addFigure(ifcm2Fd) # #imgCm10=pyHImage('/media/francisco/Packard Bell/Users/paco/Dropbox/Tranquinet/I+D+I/Electronica/robotica/software/tracking/tranquiTrack/images/logitech/shot_0_000.bmp') #imgCm11=pyHImage('/media/francisco/Packard Bell/Users/paco/Dropbox/Tranquinet/I+D+I/Electronica/robotica/software/tracking/tranquiTrack/images/logitech/shot_0_001.bmp') imgCm10=pyHImage('/Users/paco/Dropbox/Tranquinet/I+D+I/Electronica/robotica/software/tracking/tranquiTrack/images/logitech/shot_0_000.bmp') imgCm11=pyHImage('/Users/paco/Dropbox/Tranquinet/I+D+I/Electronica/robotica/software/tracking/tranquiTrack/images/logitech/shot_0_001.bmp') #fm=FlannMacher() fm=FundamentalMatrix() #fm=HomographyMatrix() fm.imgcv1=imgCm10.data fm.imgcv2=imgCm11.data #fm.imgcv1=cam1.getImage().data #fm.imgcv2=cam.getImage().data imgCm5=pyHImage() imgCm5.setData(fm.process()) ifcm5=pyHImageFigure(0,0,640,240,imgCm5) d.addFigure(ifcm5) immf=pyHImagesMixedFigure(20,20,640,240,imgCm10) immf.setImage2(imgCm11) immf.setFilter(fm) immf.setImageSourceFigure1(cam) immf.setImageSourceFigure2(cam1) d.addFigure(immf) imsf=pyHImageSecFilterFigure(300,20,50,50) imsf.setFilter(fm) imfsec=pyHImageFigure(330,20,640,240) imsf.addChangedImageObserver(imfsec) cam.addChangedImageObserver(imsf) d.addFigure(imsf) d.addFigure(imfsec)
def __init__(self): super(pyHCVEditor, self).__init__() pyHAbstractEditor.__init__(self) self.initActionMenuToolBars() self.statusBar() self.initUI() d=self.getView().getDrawing() txt=pyHTextFigure(0,400,20,20,"Hola Caracola") d.addFigure(txt) #cam1=pyHCameraFigure(0,200,50,50,0) #d.addFigure(cam1) cam=pyHCameraFigure(0,100,50,50,0) d.addFigure(cam) imgc1=pyHImageDottedFigure(150,250,320,240) imgc1.setPoints([pyHPoint(20,20),pyHPoint(30,30)]) d.addFigure(imgc1) cam.addChangedImageObserver(imgc1) img0=pyHImageFigure(50,10,320,240) d.addFigure(img0) cam.addChangedImageObserver(img0) img1=pyHImageFigure(400,10,320,240) d.addFigure(img1) fimg=pyHImageFilterFigure(300,300,40,40) d.addFigure(fimg) cam.addChangedImageObserver(fimg) fimg.addChangedImageObserver(img1) #img2=pyHImageFigure(0,300,320,240) #d.addFigure(img2) img3=pyHImageFigure(400,10,320,240) d.addFigure(img3) fimg1=pyHImageFilterFigure(300,400,40,40) d.addFigure(fimg1) fimg1.setFilter(Gaussian()) cam.addChangedImageObserver(fimg1) fimg1.addChangedImageObserver(img3) fimgH=pyHImageFilterFigure(400,500,30,30) d.addFigure(fimgH) fimgH.setFilter(HistogramColor()) fimg1.addChangedImageObserver(fimgH) imgH=pyHImageFigure(500,0,256,150) d.addFigure(imgH) fimgH.addChangedImageObserver(imgH) fimg2=pyHImageFilterFigure(300,500,40,40) d.addFigure(fimg2) fimg2.setFilter(SobelX()) fimg1.addChangedImageObserver(fimg2) img4=pyHImageFigure(0,300,320,240) d.addFigure(img4) fimg2.addChangedImageObserver(img4) fimg2y=pyHImageFilterFigure(240,300,40,40) d.addFigure(fimg2y) fimg2y.setFilter(SobelY()) fimg1.addChangedImageObserver(fimg2y) img4y=pyHImageFigure(240,300,320,240) d.addFigure(img4y) fimg2y.addChangedImageObserver(img4y) img4=pyHImageFigure(10,600,320,240) d.addFigure(img4) fimg4=pyHImageFilterFigure(0,600,40,40) d.addFigure(fimg4) fimg4.setFilter(OpticalFlow()) cam.addChangedImageObserver(fimg4) fimg4.addChangedImageObserver(img4) img5=pyHImageFigure(400,600,320,240) d.addFigure(img5) fimg5=pyHImageFilterFigure(400,600,40,40) d.addFigure(fimg5) fimg5.setFilter(FastFeatureDetector()) cam.addChangedImageObserver(fimg5) img5.setImageSourceFigure(fimg5)