def _onMouseMove(self, evt): if self.drawmode: cpt = self.computeWorldPosition( evt.picked2d) # make this 2d-screen point 3d if self.cpoints and mag(cpt - self.cpoints[-1] ) < self.mesh.diagonalSize() * self.tol: return # new point is too close to the last one. skip self.cpoints.append(cpt) if len(self.cpoints) > 2: self.remove( [self.points, self.spline, self.jline, self.topline]) self.points = Points(self.cpoints, r=self.linewidth).c( self.pointcolor).pickable(0) if self.splined: self.spline = Spline(self.cpoints, res=len(self.cpoints) * 4) # not closed here else: self.spline = Line(self.cpoints) if evt.actor: self.top_pts.append(evt.picked3d) # self.topline = Line(self.top_pts) # self.topline.lw(self.linewidth-1).c(self.linecolor).pickable(False) self.topline = Points(self.top_pts, r=self.linewidth) self.topline.c(self.linecolor).pickable(False) self.spline.lw(self.linewidth).c( self.linecolor).pickable(False) self.txt2d.background(self.linecolor) self.jline = Line(self.cpoints[0], self.cpoints[-1], lw=1, c=self.linecolor).pickable(0) self.add([self.points, self.spline, self.jline, self.topline])
def _onRightClick(self, evt): self.drawmode = not self.drawmode # toggle mode if self.drawmode: self.txt2d.background(self.linecolor, self.alpha) else: self.txt2d.background(self.color, self.alpha) if len(self.cpoints) > 2: self.remove([self.spline, self.jline]) if self.splined: # show the spline closed self.spline = Spline(self.cpoints, closed=True, res=len(self.cpoints)*4) else: self.spline = Line(self.cpoints, closed=True) self.spline.lw(self.linewidth).c(self.linecolor).pickable(False) self.add(self.spline)
def init(self, initpoints): if isinstance(initpoints, Points): self.cpoints = initpoints.points() else: self.cpoints = np.array(initpoints) self.points = Points(self.cpoints, r=self.linewidth).c(self.pointcolor).pickable(0) if self.splined: self.spline = Spline(self.cpoints, res=len(self.cpoints)*4) else: self.spline = Line(self.cpoints) self.spline.lw(self.linewidth).c(self.linecolor).pickable(False) self.jline = Line(self.cpoints[0], self.cpoints[-1], lw=1, c=self.linecolor).pickable(0) self.add([self.points, self.spline, self.jline], render=False) return self