Commit d4e774de authored by vpalladi's avatar vpalladi

temporary

parent 874fe9bb
......@@ -14,7 +14,7 @@ from wafer import *
class Panel :
def __init__(self, wafer_side ) :
self.wafer_side = wafer_side
self.wafer_width = math.sqrt(3.)*wafer_side
self.wafers = {}
......@@ -22,10 +22,15 @@ class Panel :
xStep = self.wafer_width
yStep = (3./2.)*self.wafer_side
for row in range( 0, 2 ) :
self.nRow = 2
self.nCol = 3
##vito self.wafers[0] = {}
##vito self.wafers[0][0] = ZoltanWafer(self.wafer_side, wafer_type='LG')
for row in range( 0, self.nRow ) :
self.wafers[row] = {}
for col in range( 0, 3 ) :
for col in range( 0, self.nCol ) :
centre = Point2D(-self.wafer_width, -self.wafer_side)
centre.x = centre.x + col * xStep
......@@ -34,23 +39,32 @@ class Panel :
if (row%2) == 0 :
centre.x = centre.x + self.wafer_width/2
self.wafers[row][col] = Wafer(self.wafer_side, wafer_type='LG', centre=centre)
# self.wafers[row][col] = Wafer(self.wafer_side, wafer_type='LG', centre=centre)
self.wafers[row][col] = ZoltanWafer(self.wafer_side, wafer_type='LG', centre=centre)
def draw( self ) :
for row in range( 0, 2 ) :
for col in range( 0, 3 ) :
for row in range( 0, self.nRow ) :
for col in range( 0, self.nCol ) :
self.wafers[row][col].draw()
self.wafers[row][col].draw_cells()
self.wafers[row][col].draw_trigger_cells()
#self.wafers[row][col].draw_cells_id()
#self.wafers[row][col].draw_trigger_cells()
# GUI
def on_click( self, event ) :
p = Point2D( event.xdata, event.ydata )
for row in self.wafers :
for col in self.wafers[row] :
if self.wafers[row][col].contains_point( p.get_list() ) :
self.wafers[row][col].on_click(event)
def gui_reset( self, event ) :
for row in self.wafers :
for col in self.wafers[row] :
self.wafers[row][col].gui_reset()
#def add_event( self, event ) :
# for row in self.wafers :
# for col in self.wafers[row] :
......@@ -5,8 +5,8 @@ class Point2D :
def __init__(self, x, y) :
self.x = x
self.y = y
self.u = self.x/2+math.sqrt(3)*self.y/2
self.v = -(self.x/2-math.sqrt(3)*self.y/2)
#self.u = self.x/2+math.sqrt(3)*self.y/2
#self.v = -(self.x/2-math.sqrt(3)*self.y/2)
def __add__(self, other) :
return Point2D(self.x+other.x, self.y+other.y)
......@@ -37,6 +37,20 @@ class Point2D :
self.x = x*cos - y*sin
self.y = x*sin + y*cos
#self.u = self.x/2+math.sqrt(3)*self.y/2
#self.v = -(self.x/2-math.sqrt(3)*self.y/2)
def get_u(self) :
sin = math.sin(math.pi/6)
cos = math.cos(math.pi/6)
return self.x*cos+self.y*sin
def get_v(self) :
sin = math.sin(math.pi/6)
cos = math.cos(math.pi/6)
return -self.x*sin+self.y*cos
class Point3D :
def __init__(self, x, y, z) :
......
#!/usr/bin/python
import matplotlib.path as mplPath
import matplotlib.pyplot as plt
import matplotlib.figure as pfig
from matplotlib.widgets import Button
#red = [255/255, 200/255, 200/255]
#green = [200/255, 255/255, 200/255]
blue = [200/255, 200/255, 255/255]
yellow = [255/255, 255/255, 200/255]
class SeedButton :
status = 'nonSeed'
def __init__( self ) :
print 'create button to switch between seeds and non seeds'
def build(self) :
baxes = plt.axes([0.3, 0.8, 0.07, 0.05])
self.b = Button( baxes, self.status )
self.b.color = blue
self.b.hovercolor = self.b.color
self.b.on_clicked( self.change )
#self.b.color = blue
def change(self, event) :
if self.b.color == blue :
self.b.color = yellow
self.status = 'Seed'
else :
self.b.color = blue
self.status = 'nonSeed'
self.b.hovercolor = self.b.color
self.b.label.set_text( self.status )
print 'in the class',self.status
fig, ax = plt.subplots()
fig.canvas.draw()
......@@ -52,17 +52,20 @@ class base_shape :
# return
# geometry handling
### contains a point
def contains_point(self, point):
if mplPath.Path( np.array( self.get_coo_list() ) ).contains_point(point) :
if mplPath.Path( np.array( self.get_coo_list() ) ).contains_point( point ) :
return True
return False
### contains all the corners of a shape
def contains_shape(self, shape) :
for point in shape.get_coo_list() :
if not self.contains_point(point) :
return False
return True
### contains at least a corner of the shape
def contains_shape_corner(self, shape) :
for point in shape.get_coo_list() :
if self.contains_point(point) :
......@@ -96,18 +99,18 @@ class side_square(base_shape) :
s3 = math.sqrt(3.)
w_width = s3*w_side/2
c_width = s3*c_side/2
w_width = s3*w_side
c_width = s3*c_side
# p1 = Point2D( (s3 / 2.) * w_side - c_side * (s3/2+1), -w_side / 2. + 2*c_side )
# p2 = Point2D( (s3 / 2.) * w_side , -w_side / 2. + c_side / 2. )
# p3 = Point2D( (s3 / 2.) * w_side , w_side / 2. - c_side / 2. )
# p4 = Point2D( (s3 / 2.) * w_side - c_side * (s3/2+1), w_side / 2. - 2*c_side )
p1 = Point2D( w_width - c_width/2, -w_side / 2. + c_side/2 )
p2 = Point2D( w_width + c_width/2, -w_side / 2. + c_side/2 )
p3 = Point2D( w_width + c_width/2, w_side / 2. - c_side/2 )
p4 = Point2D( w_width - c_width/2, w_side / 2. - c_side/2 )
p1 = Point2D( w_width/2 - c_width/4, -w_side / 2. + c_side/2 )
p2 = Point2D( w_width/2 + c_width/4, -w_side / 2. + c_side/2 )
p3 = Point2D( w_width/2 + c_width/4, w_side / 2. - c_side/2 )
p4 = Point2D( w_width/2 - c_width/4, w_side / 2. - c_side/2 )
self.coo = [ p1, p2, p3, p4 ]
......@@ -130,6 +133,38 @@ class side_square(base_shape) :
self.coo = [ Point2D(cos*p.x-sin*p.y, sin*p.x+cos*p.y) for p in self.coo ]
#class corner_hexagon :
#
# def __init__(self, w_side, c_side, corner_id='A') :
#
# s3 = math.sqrt(3.)
#
# w_width = s3*w_side
# c_width = s3*c_side
#
#
# if corner_id=='A' :
# self.centre = Point2D(0, w_side)
# elif corner_id=='B' :
# self.centre = Point2D(w_width/2, w_side/2.)
# elif corner_id=='C' :
# self.centre = Point2D(w_width/2, w_side/2.)
# elif corner_id=='D' :
# self.centre = Point2D(0, -w_side)
# elif corner_id=='E' :
# self.centre = Point2D(-w_width/2, -w_side/2.)
# elif corner_id=='F' :
# self.centre = Point2D(-w_width/2, +w_side/2.)
#
# self.circle = plt.Ellipse( centre.get_list(), width=c_side/2, height=c_side/2 )
#
# ### contains at least a corner of the shape
# def contains_shape_corner(self, shape) :
# for point in shape.get_coo_list() :
# if self.contains_point(point) :
# return True
# return False
class tc_square(base_shape) :
def __init__(self, s, rot=0, trs=Point2D(0,0) ) :
......@@ -161,7 +196,7 @@ class hexagon(base_shape) :
self.D = Point2D( 0., -1. )
self.E = Point2D( -self.s3/2., -0.5 )
self.F = Point2D( -self.s3/2., 0.5 )
self.build_shape()
def build_shape(self) :
......@@ -179,7 +214,7 @@ class half_hexagon(hexagon) :
self.coo = [self.A, self.B, self.C, self.F]
self.coo = [ (point*self.side) for point in self.coo ]
self.rotate(self.rot)
self.place(self.centre)
......@@ -193,7 +228,7 @@ class hexagon_flatside_long(hexagon) :
self.coo = [self.A, self.B, self.C, self.D, self.E, self.F]
self.coo = [ (point*self.side) for point in self.coo ]
self.rotate(self.rot)
self.place(self.centre)
......@@ -206,7 +241,7 @@ class hexagon_flatside_short(hexagon) :
self.coo = [self.A, self.B, self.C, self.D, self.E, self.F]
self.coo = [ (point*self.side) for point in self.coo ]
self.rotate(self.rot)
self.place(self.centre)
......@@ -225,6 +260,7 @@ class penthagon_corner(base_shape) :
self.coo = [A, B, C, D, E]
self.coo = [ (point*side) for point in self.coo ]
self.rotate(rotation_rad)
if mirror==1 :
self.mirror()
......
......@@ -31,7 +31,6 @@ class TriggerCell(BaseCell) :
def build_cell(self):
# hexagons corners
self.shape = four_cells(self.side, self.centre, rotation_rad=self.rotation)
# # geom
# def translate(self, trans) :
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment