pythonCascade Sample Problems

self.Initialize()
if
self.NbActiveLights >= self.myGraphicDriver.InquireLightLimit():
print
"You have reached the limit number of active lights :" +
`self.myGraphicDriver.InquireLightLimit()`
print
"Clear lights to create new ones."
return
self.myCurrentMode = CurAction3d_BeginDirectionalLight
sb =
self.frame.GetStatusBar().SetStatusText("Pick the first position")
# in OnLeftButtonEvent
elif
self.myCurrentMode == CurAction3d_BeginDirectionalLight:
x,y =
self.ConvertEventCoords(event)
self.p1 = self.ConvertClickToPoint(x,y,self.view)
self.p2 = gp_Pnt(self.p1.X(),self.p1.Y(),self.p1.Z()+1.)
MakeEdge =
BRepBuilderAPI_MakeEdge(self.p1, self.p2)
self.directionalEdgeShape = AIS_Shape(TopoDS_Edge())
self.directionalEdgeShape.Set(MakeEdge.Edge())
self.interactive_context.Display(self.directionalEdgeShape,1);
self.myCurrent_DirectionalLight = V3d_DirectionalLight(self.viewer,
self.p1.X(),self.p1.Y(),self.p1.Z(),0.,0.,1.)
self.view.SetLightOn(self.myCurrent_DirectionalLight)
self.NbActiveLights = self.NbActiveLights + 1
self.frame.GetStatusBar().SetStatusText("Pick the target
point")
self.myCurrentMode = CurAction3d_EndDirectionalLight
elif
self.myCurrentMode == CurAction3d_EndDirectionalLight:
self.frame.GetStatusBar().SetStatusText("Ready")
self.myCurrentMode = CurAction3d_Nothing
self.interactive_context.Erase(self.directionalEdgeShape,1,0)
# in MouseMove
elif
self.myCurrentMode == CurAction3d_EndDirectionalLight:
x,y =
self.ConvertEventCoords(event)
self.p2 = self.ConvertClickToPoint(x,y,self.view)
if
self.p1.Distance(self.p2) > Precision.Confusion():
MakeEdge = BRepBuilderAPI_MakeEdge(self.p1, self.p2)
self.directionalEdgeShape.Set(MakeEdge.Edge())
self.interactive_context.Redisplay(self.directionalEdgeShape,1,0)
self.myCurrent_DirectionalLight.SetDirection(self.p2.X()-self.p1.X(),self.p2.Y()-self.p1.Y(),self.p2.Z()-self.p1.Z())
self.view.UpdateLights()