#####################################
### DM2_w22 # AGruber@tugraz.at   ###
### hu_02_setup # alice_and_bob   ###
#####################################

##############################
import rhinoscriptsyntax as rs
import random
##############################

rs.UnitSystem(4)                       
rs.ShowGrid(view=None, show=0)
rs.ShowGridAxes(view=None, show=1)
rs.EnableRedraw(1)
rs.ViewDisplayMode(view=None, mode="Ghosted")
rs.Command("-printDisplay State=On enter", 0)

rs.ShowObjects(rs.AllObjects())
rs.DeleteObjects( rs.AllObjects() )
rs.CurrentLayer("Default")


print "\t   ********\**/************"
print "\t  **********\/entanglement"
print "\t my quantum /\***********"
print "\t***********/**\*********   ver _2022 10 14 11:25\n\n",



layNam = "MY_SETUP"
rs.CurrentLayer(rs.AddLayer(layNam))
rs.LayerPrintColor(layNam, [100,100,100])
rs.LayerPrintWidth(layNam, 1.0)
rs.ClearCommandHistory()

#______base vectors
randi = 100
vecA  = [ random.uniform(-randi,randi), random.uniform(-randi,randi), random.uniform(-randi,-randi*1.5) ]
vecB  = [ random.uniform(-randi,randi), random.uniform(-randi,randi), random.uniform( randi, randi*1.5) ]

def myCoords( a=random.uniform(50,300), mov=vecA ):
    coords = [[0,0,0], [a,0,0], [a,a,0], [0,a,0]]
    rotXYZ = [ random.uniform(-30,30), random.uniform(-30,30), random.uniform(-30,30) ]
    for i in range( len(coords) ):
        coords[i] = rs.VectorAdd(coords[i], mov)
        coords[i] = rs.VectorRotate(coords[i], 30, rotXYZ)
    return coords


coords_a = myCoords(random.uniform(50,300), vecA)
coords_b = myCoords(random.uniform(50,300), vecB)
rs.AddPoints( coords_a+coords_b )
rs.AddCurve ( coords_a+coords_b, 1)
rs.ZoomExtents()
for i,cor in enumerate(coords_a+coords_b): rs.ObjectColor(rs.AddTextDot(str(i-(i>3)*4), cor), [200,0,200])
rs.Sleep(1000)



##############################here you go:
##########################################
##########################################
layNam = "MY_PROJECT"
rs.CurrentLayer(rs.AddLayer(layNam))
rs.LayerPrintColor(layNam, [200,100,100])
rs.LayerVisible("MY_SETUP", 0)

rs.ZoomExtents()
rs.Command("-printDisplay State=Off enter", 0)
rs.CurrentLayer("Default")







##############################here you end
##########################################
##########################################






######################
#______4_lazy_experts:
if 0:
    import time
    rs.ZoomExtents()
    rs.Command("-zoom Factor 0.95 enter", 0)
    rs.Redraw()
    from datetime import datetime
    #print str(datetime.now())[0:19]
    #print datetime.now().strftime('%a %b  / %d.%m.%Y um %Huhr und %Mmin und %Ssec')
    print "\tdate",
    print time.ctime(), "==",
    print time.time(), "seconds since 1 January 1970"
    
    if 0: ### capture images to P:\
        path = "P:/ue_02/images/" ### if there is no folder like this: check your desktop 
        name = "tst"
        rs.Command("-viewCaptureToFile Width=480  Height=360  Scale=1.5 TransparentBackground=Yes "+path+name, 0)
        name = name+"_"+str(int(time.time()))+".jpg"
        rs.Command("-viewCaptureToFile Width=480  Height=360  Scale=2 DrawGrid=No  DrawWorldAxes=No  DrawCPlaneAxes=No TransparentBackground=No  "+path+name, 0)
        print path+name


