def drawit(self, p): '''Draw beachball into painter.''' h = self.height() w = self.width() s = min(h,w)*0.9 xproj = Projection() xproj.set_in_range(-1.,1.) xproj.set_out_range((w-s)/2.,w-(w-s)/2.) yproj = Projection() yproj.set_in_range(-1.,1.) yproj.set_out_range(h-(h-s)/2.,(h-s)/2.) pos, neg = self.beachball.get_projected_nodallines() color = (0,0,0) pen = QPen(QColor(*color)) pen.setWidth(2) p.setPen(pen) for line in pos, neg: x = xproj(num.array(line[0])) y = yproj(num.array(line[1])) points = make_QPolygonF(x,y) p.drawPolyline( points ) p.drawEllipse(QRectF(QPointF(xproj(-1.), yproj(-1.)), QPointF(xproj(1.), yproj(1.))))
def drawit(self, p): '''Draw beachball into painter.''' h = self.height() w = self.width() s = min(h, w) * 0.9 xproj = Projection() xproj.set_in_range(-1., 1.) xproj.set_out_range((w - s) / 2., w - (w - s) / 2.) yproj = Projection() yproj.set_in_range(-1., 1.) yproj.set_out_range(h - (h - s) / 2., (h - s) / 2.) #m = mtm.symmat6(*(num.random.random(6)*2.-1.)) #mtm.MomentTensor(m=m) mt = self._mt mt_devi = mt.deviatoric() eig = mt_devi.eigensystem() group_to_color = {'P': plot.graph_colors[0], 'T': plot.graph_colors[1]} for (group, patches, patches_lower, patches_upper, lines, lines_lower, lines_upper) in beachball.eig2gx(eig): color = group_to_color[group] brush = QBrush(QColor(*color)) p.setBrush(brush) pen = QPen(QColor(*color)) pen.setWidth(1) p.setPen(pen) for poly in patches_lower: px, py, pz = poly.T points = make_QPolygonF(xproj(px), yproj(py)) p.drawPolygon(points) color = (0, 0, 0) pen = QPen(QColor(*color)) pen.setWidth(2) p.setPen(pen) for poly in lines_lower: px, py, pz = poly.T points = make_QPolygonF(xproj(px), yproj(py)) p.drawPolyline(points)