def MouseMoveEvent(self, thePnt2d: gp_Pnt2d, buttons, modifiers):
     self.curPnt2d = self.myAnalyserSnap.MouseMove(thePnt2d)
     if self.myBSplineCurveAction == BSplineCurveAction.Nothing:
         pass
     elif self.myBSplineCurveAction == BSplineCurveAction.Input_1Point:
         pass
     elif self.myBSplineCurveAction == BSplineCurveAction.Input_2Point:
         self.mySecondPoint.SetPnt(
             elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))
         self.myRubberLine.SetPoints(self.myFirstPoint, self.mySecondPoint)
         self.myContext.Redisplay(self.myRubberLine, True)
     elif self.myBSplineCurveAction == BSplineCurveAction.Input_OtherPoints:
         self.myGeom2d_BSplineCurve.SetPole(self.IndexCounter,
                                            self.curPnt2d)
         self.mySecondPoint.SetPnt(
             elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))
         self.myGeom_BSplineCurve.SetPole(self.IndexCounter,
                                          self.mySecondPoint.Pnt())
         ME = BRepBuilderAPI_MakeEdge(self.myGeom_BSplineCurve)
         if ME.IsDone():
             self.curEdge = ME.Edge()
             self.myRubberAIS_Shape.Set(self.curEdge)
             self.myContext.Redisplay(self.myRubberAIS_Shape, True)
         else:
             self.IndexCounter -= 1
 def MouseMoveEvent(self, thePnt2d: gp_Pnt2d, buttons, modifiers):
     if self.myArcCenter2PAction == ArcCenter2PAction.Nothing:
         pass
     elif self.myArcCenter2PAction == ArcCenter2PAction.Input_CenterArc:
         self.curPnt2d = self.myAnalyserSnap.MouseMove(thePnt2d)
     elif self.myArcCenter2PAction == ArcCenter2PAction.Input_1ArcPoint:
         self.curPnt2d = self.myAnalyserSnap.MouseMoveException(
             self.myFirstgp_Pnt2d, thePnt2d, TangentType.Circle_CenterPnt,
             True)
         self.radius = self.myFirstgp_Pnt2d.Distance(self.curPnt2d)
         if self.radius == 0.0:
             self.radius = 1.0
         self.tempGeom_Circle.SetRadius(self.radius)
         self.myContext.Redisplay(self.myRubberCircle, True)
         self.mySecondPoint.SetPnt(
             elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))
     elif self.myArcCenter2PAction == ArcCenter2PAction.Input_2ArcPoint:
         self.curPnt2d = self.myAnalyserSnap.MouseMove(thePnt2d)
         if self.ProjectOnCircle(self.curPnt2d):
             third_Pnt = elclib.To3d(self.curCoordinateSystem.Ax2(),
                                     self.curPnt2d)
             self.myRubberCircle.SetCircle(self.tempGeom_Circle)
             p1 = elclib.Parameter(self.tempGeom_Circle.Circ(),
                                   self.mySecondPoint.Pnt())
             p2 = elclib.Parameter(self.tempGeom_Circle.Circ(), third_Pnt)
             self.myRubberCircle.SetFirstParam(min(p1, p2))
             self.myRubberCircle.SetLastParam(max(p1, p2))
             self.myContext.Redisplay(self.myRubberCircle, True)
             # update text
             degree = "Degree: {}".format(round(p2 * 180 / M_PI))
             self.myAIS_Label.SetText(TCollection_ExtendedString(degree))
             self.myContext.Redisplay(self.myAIS_Label, True)
    def MouseMoveEvent(self, thePnt2d: gp_Pnt2d, buttons, modifiers):
        self.curPnt2d = self.myAnalyserSnap.MouseMove(thePnt2d)
        if self.myArc3PAction == Arc3PAction.Nothing:
            pass
        elif self.myArc3PAction == Arc3PAction.Input_1ArcPoint:
            self.curPnt2d = self.myAnalyserSnap.MouseMove(thePnt2d)
        elif self.myArc3PAction == Arc3PAction.Input_2ArcPoint:
            self.mySecondPoint.SetPnt(elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))
            self.myRubberLine.SetPoints(self.myFirstPoint, self.mySecondPoint)
            self.myContext.Redisplay(self.myRubberLine, True)
        elif self.myArc3PAction == Arc3PAction.Input_3ArcPoint:
            self.third_Pnt = elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d)
            tempMakeCirc = gce_MakeCirc(self.myFirstPoint.Pnt(), self.mySecondPoint.Pnt(), self.third_Pnt)
            if tempMakeCirc.Status() == gce_Done:
                self.tempGeom_Circle.SetCirc(tempMakeCirc.Value())
                self.myRubberCircle.SetCircle(self.tempGeom_Circle)
                self.myRubberCircle.SetFirstParam(
                    elclib.Parameter(self.tempGeom_Circle.Circ(), self.myFirstPoint.Pnt()))
                self.myRubberCircle.SetLastParam(elclib.Parameter(self.tempGeom_Circle.Circ(), self.third_Pnt))
                self.myContext.Redisplay(self.myRubberCircle, True)
        elif self.myArc3PAction == Arc3PAction.Input_PolylineArc:
            self.third_Pnt = elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d)
            self.TempGeom2d_Point.SetPnt2d(self.curPnt2d)
            temp2d_QualifiedCurve = Geom2dGcc_QualifiedCurve(self.temp2dAdaptor_Curve, gccent_Unqualified)
            tempGcc_Circ2d3Tan = Geom2dGcc_Circ2d3Tan(temp2d_QualifiedCurve, self.FirstGeom2d_Point,
                                                      self.TempGeom2d_Point, 1.0e-6, 0)
            if (tempGcc_Circ2d3Tan.IsDone() and tempGcc_Circ2d3Tan.NbSolutions() > 0):
                self.temp2d_Circ = tempGcc_Circ2d3Tan.ThisSolution(1)
                self.u1 = elclib.Parameter(self.temp2d_Circ, self.myFirstgp_Pnt2d)
                self.u2 = elclib.Parameter(self.temp2d_Circ, self.mySecondgp_Pnt2d)

                self.temp_u1 = self.u1 + (self.u2 - self.u1) / 100
                self.temp_u2 = self.u1 - (self.u2 - self.u1) / 100

                self.tempu1_pnt2d = elclib.Value(self.temp_u1, self.temp2d_Circ)
                self.tempu2_pnt2d = elclib.Value(self.temp_u2, self.temp2d_Circ)

                self.dist1 = self.tempu1_pnt2d.Distance(self.midpoint2d)
                self.dist2 = self.tempu2_pnt2d.Distance(self.midpoint2d)

                if self.dist1 < self.dist2:
                    self.tempu1_pnt2d = self.tempu2_pnt2d
                tempMakeCirc = gce_MakeCirc(self.myFirstPoint.Pnt(),
                                            elclib.To3d(self.curCoordinateSystem.Ax2(), self.tempu1_pnt2d),
                                            self.third_Pnt)
                if tempMakeCirc.Status() == gce_Done:
                    self.tempGeom_Circle.SetCirc(tempMakeCirc.Value())
                    self.myRubberCircle.SetFirstParam(
                        elclib.Parameter(self.tempGeom_Circle.Circ(), self.myFirstPoint.Pnt()))
                    self.myRubberCircle.SetLastParam(elclib.Parameter(self.tempGeom_Circle.Circ(), self.third_Pnt))
                    self.myContext.Redisplay(self.myRubberCircle, True)
Exemplo n.º 4
0
    def MouseInputEvent(self, thePnt2d: gp_Pnt2d, buttons, modifier):
        if self.myCircleCenterRadiusAction == CircleCenterRadiusAction.Nothing:
            pass
        elif self.myCircleCenterRadiusAction == CircleCenterRadiusAction.Input_CenterPoint:
            self.curPnt2d = self.myAnalyserSnap.MouseInput(thePnt2d)
            self.myFirstgp_Pnt2d = gp_Pnt2d(self.curPnt2d.X(),
                                            self.curPnt2d.Y())
            self.myFirstPoint.SetPnt(
                elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))

            self.myCircleAx2d.SetLocation(self.myFirstgp_Pnt2d)
            self.tempGeom_Circle.SetLocation(self.myFirstPoint.Pnt())
            self.tempGeom_Circle.SetRadius(SKETCH_RADIUS)
            self.myRubberCircle.SetCircle(self.tempGeom_Circle)
            self.myContext.Display(self.myRubberCircle, True)

            self.myCircleCenterRadiusAction = CircleCenterRadiusAction.Input_RadiusPoint
        elif self.myCircleCenterRadiusAction == CircleCenterRadiusAction.Input_RadiusPoint:
            self.curPnt2d = self.myAnalyserSnap.MouseInputException(
                self.myFirstgp_Pnt2d, thePnt2d, TangentType.Circle_CenterPnt,
                True)
            self.radius = self.myFirstgp_Pnt2d.Distance(self.curPnt2d)
            self.tempGeom2d_Circle = Geom2d_Circle.DownCast(
                geomapi_To2d(self.tempGeom_Circle,
                             gp_Pln(self.curCoordinateSystem)))
            self.myContext.Remove(self.myRubberCircle, True)

            nurbs = self.ToNurbs_Square(self.myFirstgp_Pnt2d, self.radius)
            self.bspline_node = BsplineNode(nurbs.GetName(), self.rootNode)
            self.bspline_node.setSketchObject(nurbs)
            self.AddObject(self.tempGeom2d_Circle, nurbs.GetAIS_Object(),
                           Sketch_GeometryType.CircleSketchObject)
            self.myCircleCenterRadiusAction = CircleCenterRadiusAction.Nothing

        return False
Exemplo n.º 5
0
    def MouseInputEvent(self, thePnt2d: gp_Pnt2d, buttons, modifier):

        if self.myLine2PAction == Line2PAction.Nothing:
            pass
        elif self.myLine2PAction == Line2PAction.Input_FirstPointLine:
            self.curPnt2d = self.myAnalyserSnap.MouseInputException(thePnt2d, thePnt2d, TangentType.Line_FirstPnt, True)
            self.myFirstgp_Pnt2d = gp_Pnt2d(self.curPnt2d.X(),
                                            self.curPnt2d.Y())  # important to create new instance otherwise, this varible will be the copy of self.curPnt2d
            self.myFirstPoint.SetPnt(elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))
            self.myRubberLine.SetPoints(self.myFirstPoint, self.myFirstPoint)
            self.myContext.Display(self.myRubberLine, True)

            self.line = Sketch_Line(self.myContext,self.curCoordinateSystem)
            self.line.AddPoints(self.curPnt2d)

            self.myLine2PAction = Line2PAction.Input_SecondPointLine
        elif self.myLine2PAction == Line2PAction.Input_SecondPointLine:

            self.curPnt2d = self.myAnalyserSnap.MouseInputException(self.myFirstgp_Pnt2d, thePnt2d,
                                                                    TangentType.Line_SecondPnt, False)
            self.mySecondgp_Pn2d = gp_Pnt2d(self.curPnt2d.X(), self.curPnt2d.Y())
            self.line.AddPoints(self.curPnt2d)
            self.line.Compute()
            node = LineNode(self.objectName + str(self.objectCounter), self.rootNode)
            node.setSketchObject(self.line)
            self.AddObject(self.line.GetGeometry2d(),self.line.GetAIS_Object(), Sketch_GeometryType.LineSketchObject)
            if self.myPolylineMode:
                self.myFirstgp_Pnt2d = self.curPnt2d
                self.myFirstPoint.SetPnt(self.mySecondPoint.Pnt())
                self.myRubberLine.SetPoints(self.myFirstPoint, self.myFirstPoint)
                self.myContext.Redisplay(self.myRubberLine, True)
            else:
                self.myContext.Remove(self.myRubberLine, True)
                self.myLine2PAction = Line2PAction.Input_FirstPointLine
        return False
    def MouseInputEvent(self, tempPnt2d: gp_Pnt2d):
        self.curPnt2d = tempPnt2d
        self.curPnt = elclib.To3d(self.curCoordinateSystem.Ax2(),
                                  self.curPnt2d)
        # print("XY:",self.curPnt2d.X(),self.curPnt2d.Y())
        # print("XYZ",self.curPnt.X(),self.curPnt.Y(),self.curPnt.Z())

        self.SelectEvent()
        self.EraseSnap()
        return self.bestPnt2d
    def MouseMoveEvent(self, thePnt2d: gp_Pnt2d, buttons, modifiers):
        if self.myLine2PAction == Line2PAction.Nothing:
            pass
        elif self.myLine2PAction == Line2PAction.Input_FirstPointLine:
            self.curPnt2d = self.myAnalyserSnap.MouseMoveException(thePnt2d, thePnt2d, TangentType.Line_FirstPnt, True)

        elif self.myLine2PAction == Line2PAction.Input_SecondPointLine:
            self.curPnt2d = self.myAnalyserSnap.MouseMoveException(self.myFirstgp_Pnt2d, thePnt2d,
                                                                   TangentType.Line_SecondPnt, False)
            self.mySecondPoint.SetPnt(elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))
    def MouseInputEvent(self, thePnt2d: gp_Pnt2d, buttons, modifier):
        if self.myCircleCenterRadiusAction == CircleCenterRadiusAction.Nothing:
            pass
        elif self.myCircleCenterRadiusAction == CircleCenterRadiusAction.Input_CenterPoint:
            self.curPnt2d = self.myAnalyserSnap.MouseInput(thePnt2d)
            self.myFirstgp_Pnt2d = gp_Pnt2d(self.curPnt2d.X(),
                                            self.curPnt2d.Y())
            self.myFirstPoint.SetPnt(
                elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))

            self.myCircleAx2d.SetLocation(self.myFirstgp_Pnt2d)
            self.tempGeom_Circle.SetLocation(self.myFirstPoint.Pnt())
            self.tempGeom_Circle.SetRadius(SKETCH_RADIUS)
            self.myRubberCircle.SetCircle(self.tempGeom_Circle)
            self.myContext.Display(self.myRubberCircle, True)

            self.myRubberLine.SetPoints(self.myFirstPoint, self.myFirstPoint)
            self.myContext.Display(self.myRubberLine, True)

            self.myCircleCenterRadiusAction = CircleCenterRadiusAction.Input_RadiusPoint
        elif self.myCircleCenterRadiusAction == CircleCenterRadiusAction.Input_RadiusPoint:
            self.curPnt2d = self.myAnalyserSnap.MouseInputException(
                self.myFirstgp_Pnt2d, thePnt2d, TangentType.Circle_CenterPnt,
                True)
            self.radius = self.myFirstgp_Pnt2d.Distance(self.curPnt2d)
            myGeom2d_Circle = Geom2d_Circle(self.myCircleAx2d, self.radius)

            Geom_Circle1 = Geom_Circle(
                elclib.To3d(self.curCoordinateSystem.Ax2(),
                            myGeom2d_Circle.Circ2d()))
            myAIS_Circle = AIS_Circle(Geom_Circle1)
            self.AddObject(myGeom2d_Circle, myAIS_Circle,
                           Sketch_GeometryType.CircleSketchObject)

            self.myContext.Remove(self.myRubberCircle, True)
            self.myContext.Remove(self.myRubberLine, True)
            self.myContext.Display(myAIS_Circle, True)
            self.myCircleCenterRadiusAction = CircleCenterRadiusAction.Input_CenterPoint

        return False
 def MouseMoveEvent(self, thePnt2d: gp_Pnt2d, buttons, modifiers):
     if self.myCircleCenterRadiusAction == CircleCenterRadiusAction.Nothing:
         pass
     elif self.myCircleCenterRadiusAction == CircleCenterRadiusAction.Input_CenterPoint:
         self.curPnt2d = self.myAnalyserSnap.MouseMove(thePnt2d)
     elif self.myCircleCenterRadiusAction == CircleCenterRadiusAction.Input_RadiusPoint:
         self.curPnt2d = self.myAnalyserSnap.MouseMoveException(self.myFirstgp_Pnt2d, thePnt2d,
                                                                TangentType.Circle_CenterPnt, True)
         self.radius = self.myFirstgp_Pnt2d.Distance(self.curPnt2d)
         if self.radius == 0.0:
             self.radius = 1.0
         self.tempGeom_Circle.SetRadius(self.radius)
         self.myContext.Redisplay(self.myRubberCircle, True)
         self.mySecondPoint.SetPnt(elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))
 def SetPolylineMode(self, mode):
     self.myPolylineMode = mode
     if self.myArc3PAction == Arc3PAction.Nothing:
         pass
     elif self.myArc3PAction == Arc3PAction.Input_1ArcPoint:
         pass
     elif self.myArc3PAction == Arc3PAction.Input_2ArcPoint:
         self.findlastSObject()
         self.myContext.Remove(self.myRubberLine, True)
         self.myContext.Display(self.myRubberCircle, True)
     elif self.myArc3PAction == Arc3PAction.Input_3ArcPoint:
         self.findlastSObject()
         self.myContext.Redisplay(self.myRubberCircle, True)
     elif self.myArc3PAction == Arc3PAction.Input_PolylineArc:
         self.mySecondPoint.SetPnt(elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))
         self.myContext.Remove(self.myRubberCircle, True)
         self.myContext.Display(self.myRubberLine, True)
         self.myArc3PAction = Arc3PAction.Input_2ArcPoint
Exemplo n.º 11
0
 def MouseMoveEvent(self, tempPnt2d: gp_Pnt2d):
     self.curPnt2d = tempPnt2d
     self.SelectEvent()
     if self.findbestPnt2d:
         self.myGeom_Point.SetPnt(
             elclib.To3d(self.curCoordinateSystem.Ax2(), self.bestPnt2d))
         self.myAIS_Point.SetComponent(self.myGeom_Point)
         if self.firstDisplay:
             self.myContext.Display(self.myAIS_Point, True)
             self.DrawRelation()
             self.firstDisplay = False
         else:
             self.myContext.Redisplay(self.myAIS_Point, True)
             self.DrawRelation()
     else:
         self.myContext.Remove(self.myAIS_Point, True)
         self.EraseRelation()
         self.firstDisplay = True
     return self.bestPnt2d
Exemplo n.º 12
0
 def SetPolylineFirstPnt(self, p1: gp_Pnt2d):
     self.myFirstgp_Pnt2d = p1
     self.myFirstPoint.SetPnt(elclib.To3d(self.curCoordinateSystem.Ax2(), p1))
     self.myRubberLine.SetPoints(self.myFirstPoint, self.myFirstPoint)
     self.myContext.Display(self.myRubberLine, 0, -1)
     self.myLine2PAction = Line2PAction.Input_SecondPointLine
 def SetPolylineFirstPnt(self, p1):
     self.myFirstgp_Pnt2d = p1
     self.myFirstPoint.SetPnt(elclib.To3d(self.curCoordinateSystem.Ax2(), p1))
     self.findlastSObject()
     self.myContext.Display(self.myRubberCircle, True)
Exemplo n.º 14
0
def Pnt2dToPnt(pnt2d, theAxis):
    return elclib.To3d(theAxis.Ax2(), pnt2d)
    def MouseInputEvent(self, thePnt2d: gp_Pnt2d, buttons, modifier):
        if self.myArcCenter2PAction == ArcCenter2PAction.Nothing:
            pass
        elif self.myArcCenter2PAction == ArcCenter2PAction.Input_CenterArc:
            self.tempGeom_Circle = Geom_Circle(self.curCoordinateSystem.Ax2(),
                                               SKETCH_RADIUS)

            self.curPnt2d = self.myAnalyserSnap.MouseInput(thePnt2d)
            self.myFirstgp_Pnt2d = gp_Pnt2d(self.curPnt2d.X(),
                                            self.curPnt2d.Y())
            self.myFirstPoint.SetPnt(
                elclib.To3d(self.curCoordinateSystem.Ax2(),
                            self.myFirstgp_Pnt2d))

            self.myCircleAx2d.SetLocation(self.myFirstgp_Pnt2d)
            self.tempGeom_Circle.SetLocation(self.myFirstPoint.Pnt())
            self.tempGeom_Circle.SetRadius(SKETCH_RADIUS)

            self.myRubberCircle.SetCircle(self.tempGeom_Circle)
            self.myRubberCircle.SetFirstParam(0)
            self.myRubberCircle.SetLastParam(M_PI * 2)
            self.myContext.Display(self.myRubberCircle, True)
            self.myArcCenter2PAction = ArcCenter2PAction.Input_1ArcPoint

        elif self.myArcCenter2PAction == ArcCenter2PAction.Input_1ArcPoint:
            self.curPnt2d = self.myAnalyserSnap.MouseInputException(
                self.myFirstgp_Pnt2d, thePnt2d, TangentType.Circle_CenterPnt,
                True)
            self.radius = self.myFirstgp_Pnt2d.Distance(self.curPnt2d)
            self.tempGeom_Circle.SetRadius(self.radius)
            self.myRubberCircle.SetCircle(self.tempGeom_Circle)
            self.tempGeom2d_Circle = Geom2d_Circle.DownCast(
                geomapi_To2d(self.tempGeom_Circle,
                             gp_Pln(self.curCoordinateSystem)))

            self.myContext.Redisplay(self.myRubberCircle, True)
            # update text
            self.myAIS_Label.SetPosition(self.tempGeom_Circle.Location())
            self.myContext.Display(self.myAIS_Label, True)
            self.myArcCenter2PAction = ArcCenter2PAction.Input_2ArcPoint
        elif self.myArcCenter2PAction == ArcCenter2PAction.Input_2ArcPoint:
            self.curPnt2d = self.myAnalyserSnap.MouseMove(thePnt2d)
            if self.ProjectOnCircle(self.curPnt2d):
                third_Pnt = elclib.To3d(self.curCoordinateSystem.Ax2(),
                                        self.curPnt2d)
                self.myRubberCircle.SetCircle(self.tempGeom_Circle)
                p1 = elclib.Parameter(self.tempGeom_Circle.Circ(),
                                      self.mySecondPoint.Pnt())
                p2 = elclib.Parameter(self.tempGeom_Circle.Circ(), third_Pnt)
                self.myRubberCircle.SetFirstParam(min(p1, p2))
                self.myRubberCircle.SetLastParam(max(p1, p2))

                self.myGeomArc = Geom2d_Arc(self.tempGeom2d_Circle.Circ2d())
                self.myGeomArc.SetFirstParam(min(p1, p2))
                self.myGeomArc.SetLastParam(max(p1, p2))
                # Remove text
                self.myContext.Remove(self.myAIS_Label, True)
                self.myContext.Remove(self.myRubberCircle, True)

                nurbs = self.ArcToNurbsArc(min(p1, p2), max(p1, p2))
                self.bspline_node = BsplineNode(nurbs.GetName(), self.rootNode)
                self.bspline_node.setSketchObject(nurbs)
                self.AddObject(self.myGeomArc, nurbs.GetAIS_Object(),
                               Sketch_GeometryType.ArcSketchObject)

            self.myArcCenter2PAction = ArcCenter2PAction.Nothing
        return False
Exemplo n.º 16
0
    def MouseInputEvent(self, thePnt2d: gp_Pnt2d, buttons, modifier):
        self.curPnt2d = self.myAnalyserSnap.MouseInput(thePnt2d)

        if self.myBSplineCurveAction == BSplineCurveAction.Nothing:
            pass
        elif self.myBSplineCurveAction == BSplineCurveAction.Input_1Point:
            self.myFirstgp_Pnt2d = gp_Pnt2d(self.curPnt2d.X(),
                                            self.curPnt2d.Y())
            self.myFirstgp_Pnt = elclib.To3d(self.curCoordinateSystem.Ax2(),
                                             self.curPnt2d)
            self.myFirstPoint.SetPnt(self.myFirstgp_Pnt)
            # self.myRubberLine.SetPoints(self.myFirstPoint, self.myFirstPoint)

            self.Poles2d[0] = gp_Pnt2d(self.curPnt2d.X(), self.curPnt2d.Y())
            self.Poles[0] = gp_Pnt(self.myFirstgp_Pnt.X(),
                                   self.myFirstgp_Pnt.Y(),
                                   self.myFirstgp_Pnt.Z())
            self.CreateBspline()

            self.bspline = Sketch_Bspline(self.myContext,
                                          self.curCoordinateSystem)
            self.bspline.AddPoles(self.curPnt2d)

            # self.myContext.Display(self.myRubberLine, True)
            self.myBSplineCurveAction = BSplineCurveAction.Input_2Point
            self.IndexCounter = 2

        elif self.myBSplineCurveAction == BSplineCurveAction.Input_2Point:
            self.Poles2d[1] = gp_Pnt2d(self.curPnt2d.X(), self.curPnt2d.Y())
            self.tempPnt = elclib.To3d(self.curCoordinateSystem.Ax2(),
                                       self.curPnt2d)
            self.Poles[1] = gp_Pnt(self.tempPnt.X(), self.tempPnt.Y(),
                                   self.tempPnt.Z())
            self.mySecondPoint.SetPnt(self.tempPnt)
            self.CreateBspline()

            ME = BRepBuilderAPI_MakeEdge(self.myFirstgp_Pnt,
                                         self.mySecondPoint.Pnt())
            if ME.IsDone():
                self.bspline.AddPoles(self.curPnt2d)
                self.curEdge = ME.Edge()
                self.myRubberAIS_Shape.Set(self.curEdge)
                # self.myContext.Remove(self.myRubberLine, True)
                self.myContext.Display(self.myRubberAIS_Shape, True)

                self.IndexCounter += 1

                self.Poles2d.append(self.curPnt2d)
                self.Poles.append(self.tempPnt)
                self.Multi, self.Knots = setQuasiUniformKnots(
                    len(self.Poles), self.myDegree)
                self.CreateBspline()

                self.myBSplineCurveAction = BSplineCurveAction.Input_OtherPoints
        elif self.myBSplineCurveAction == BSplineCurveAction.Input_OtherPoints:
            self.Poles2d[self.IndexCounter - 1] = gp_Pnt2d(
                self.curPnt2d.X(), self.curPnt2d.Y())
            self.tempPnt = elclib.To3d(self.curCoordinateSystem.Ax2(),
                                       self.curPnt2d)
            self.Poles[self.IndexCounter - 1] = gp_Pnt(self.tempPnt.X(),
                                                       self.tempPnt.Y(),
                                                       self.tempPnt.Z())
            self.CreateBspline()

            self.mySecondPoint.SetPnt(self.tempPnt)
            ME = BRepBuilderAPI_MakeEdge(self.myGeom_BSplineCurve)
            if ME.IsDone():
                self.bspline.AddPoles(self.curPnt2d)
                self.curEdge = ME.Edge()
                if self.IndexCounter > MAXIMUMPOLES:
                    self.closeBSpline()
                else:
                    self.myRubberAIS_Shape.Set(self.curEdge)
                    self.myContext.Redisplay(self.myRubberAIS_Shape, True)

                    self.Poles2d.append(self.curPnt2d)
                    self.Poles.append(self.tempPnt)
                    self.Multi, self.Knots = setQuasiUniformKnots(
                        len(self.Poles), self.myDegree)
                    self.CreateBspline()
                    self.tempPnt2d = gp_Pnt2d(self.curPnt2d.X(),
                                              self.curPnt2d.Y())
                    self.IndexCounter += 1
        return False
    def MouseInputEvent(self, thePnt2d: gp_Pnt2d, buttons, modifier):
        self.curPnt2d = self.myAnalyserSnap.MouseInput(thePnt2d)

        if self.myBezierCurveAction == BezierCurveAction.Nothing:
            pass
        elif self.myBezierCurveAction == BezierCurveAction.Input_1Point:
            # calculate first 2d and 3d point
            self.myFirstgp_Pnt2d = gp_Pnt2d(self.curPnt2d.X(),
                                            self.curPnt2d.Y())
            self.myFirstgp_Pnt = elclib.To3d(self.curCoordinateSystem.Ax2(),
                                             self.curPnt2d)
            # save first point
            self.myFirstPoint.SetPnt(self.myFirstgp_Pnt)
            # draw first point
            # self.myRubberLine.SetPoints(self.myFirstPoint, self.myFirstPoint)
            # initialize bezier curve data structure created in sketch geometry
            self.bezier_curve = Sketch_BezierCurve(self.myContext,
                                                   self.curCoordinateSystem)
            # render the first point and auxiliry line
            self.bezier_curve.AddPoles(self.curPnt2d)
            # render the rubber line
            # self.myContext.Display(self.myRubberLine, True)
            # ready for 2nd point input
            self.myBezierCurveAction = BezierCurveAction.Input_2Point
            self.IndexCounter = 2

        elif self.myBezierCurveAction == BezierCurveAction.Input_2Point:
            self.myGeom2d_BezierCurve.SetPole(1, self.myFirstgp_Pnt2d)
            self.myGeom2d_BezierCurve.SetPole(self.IndexCounter, self.curPnt2d)

            self.tempPnt = elclib.To3d(self.curCoordinateSystem.Ax2(),
                                       self.curPnt2d)
            self.myGeom_BezierCurve.SetPole(1, self.myFirstgp_Pnt)
            self.myGeom_BezierCurve.SetPole(self.IndexCounter, self.tempPnt)

            self.mySecondPoint.SetPnt(self.tempPnt)
            ME = BRepBuilderAPI_MakeEdge(self.myGeom_BezierCurve,
                                         self.myFirstgp_Pnt, self.tempPnt)
            if ME.IsDone():
                self.bezier_curve.AddPoles(self.curPnt2d)
                self.curEdge = ME.Edge()
                self.myRubberAIS_Shape.Set(self.curEdge)
                # self.myContext.Remove(self.myRubberLine, True)
                self.myContext.Display(self.myRubberAIS_Shape, True)

                self.myGeom2d_BezierCurve.InsertPoleAfter(
                    self.IndexCounter, self.curPnt2d)
                self.myGeom_BezierCurve.InsertPoleAfter(
                    self.IndexCounter, self.tempPnt)

                self.IndexCounter += 1
                self.myBezierCurveAction = BezierCurveAction.Input_OtherPoints
        elif self.myBezierCurveAction == BezierCurveAction.Input_OtherPoints:
            self.myGeom2d_BezierCurve.SetPole(self.IndexCounter, self.curPnt2d)

            self.tempPnt = elclib.To3d(self.curCoordinateSystem.Ax2(),
                                       self.curPnt2d)
            self.myGeom_BezierCurve.SetPole(self.IndexCounter, self.tempPnt)

            self.mySecondPoint.SetPnt(self.tempPnt)
            ME = BRepBuilderAPI_MakeEdge(self.myGeom_BezierCurve)
            if ME.IsDone():
                self.bezier_curve.AddPoles(self.curPnt2d)
                self.curEdge = ME.Edge()
                if self.IndexCounter > MAXIMUMPOLES:
                    self.CloseBezierCurve()
                else:
                    self.myRubberAIS_Shape.Set(self.curEdge)
                    self.myContext.Redisplay(self.myRubberAIS_Shape, True)

                    self.myGeom2d_BezierCurve.InsertPoleAfter(
                        self.IndexCounter, self.curPnt2d)
                    self.myGeom_BezierCurve.InsertPoleAfter(
                        self.IndexCounter, self.tempPnt)
                    self.tempPnt2d = gp_Pnt2d(self.curPnt2d.X(),
                                              self.curPnt2d.Y())
                    self.IndexCounter += 1
        return False
    def MouseInputEvent(self, thePnt2d: gp_Pnt2d, buttons, modifier):
        self.curPnt2d = self.myAnalyserSnap.MouseInput(thePnt2d)
        if self.myArc3PAction == Arc3PAction.Nothing:
            pass
        elif self.myArc3PAction == Arc3PAction.Input_1ArcPoint:
            self.myFirstgp_Pnt2d = gp_Pnt2d(self.curPnt2d.X(),self.curPnt2d.Y())
            self.myFirstPoint.SetPnt(elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))
            if not self.myPolylineMode:
                self.myRubberLine.SetPoints(self.myFirstPoint, self.myFirstPoint)
                self.myContext.Display(self.myRubberLine, True)
                self.myArc3PAction = Arc3PAction.Input_2ArcPoint
            else:
                self.findlastSObject()
                self.myContext.Display(self.myRubberCircle, True)
        elif self.myArc3PAction == Arc3PAction.Input_2ArcPoint:
            self.mySecondgp_Pnt2d =  gp_Pnt2d(self.curPnt2d.X(),self.curPnt2d.Y())
            self.mySecondPoint.SetPnt(elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))
            self.temp_Circ.SetLocation(self.myFirstPoint.Pnt().Scaled(self.mySecondPoint.Pnt(), 0.5))
            self.temp_Circ.SetRadius(self.myFirstgp_Pnt2d.Distance(self.curPnt2d) / 2)

            self.tempGeom_Circle.SetCirc(self.temp_Circ)
            self.myRubberCircle.SetCircle(self.tempGeom_Circle)

            self.u1 = elclib.Parameter(self.temp_Circ, self.myFirstPoint.Pnt())
            self.u2 = elclib.Parameter(self.temp_Circ, self.mySecondPoint.Pnt())

            if self.u1 > self.u2:
                self.myRubberCircle.SetFirstParam(self.u2)
                self.myRubberCircle.SetLastParam(self.u1)
            else:
                self.myRubberCircle.SetFirstParam(self.u1)
                self.myRubberCircle.SetLastParam(self.u2)

            self.myContext.Remove(self.myRubberLine, True)
            self.myContext.Display(self.myRubberCircle, True)
            self.myContext.Redisplay(self.myRubberCircle, True)
            self.myArc3PAction = Arc3PAction.Input_3ArcPoint

        elif self.myArc3PAction == Arc3PAction.Input_3ArcPoint:
            Geom2d_Point1 = Geom2d_CartesianPoint(self.myFirstgp_Pnt2d)
            Geom2d_Point2 = Geom2d_CartesianPoint(self.mySecondgp_Pnt2d)
            Geom2d_Point3 = Geom2d_CartesianPoint(self.curPnt2d)
            tempGcc_Circ2d3Tan = Geom2dGcc_Circ2d3Tan(Geom2d_Point1, Geom2d_Point2, Geom2d_Point3, 1.0e-10)
            if tempGcc_Circ2d3Tan.IsDone() and tempGcc_Circ2d3Tan.NbSolutions() > 0:
                myGeom2d_Arc = Geom2d_Arc(tempGcc_Circ2d3Tan.ThisSolution(1))
                myGeom2d_Arc.SetParam(self.myFirstgp_Pnt2d, self.mySecondgp_Pnt2d, self.curPnt2d)

                Geom_Circle1 = Geom_Circle(elclib.To3d(self.curCoordinateSystem.Ax2(), myGeom2d_Arc.Circ2d()))
                myAIS_Circle = AIS_Circle(Geom_Circle1)

                myAIS_Circle.SetFirstParam(myGeom2d_Arc.FirstParameter())
                myAIS_Circle.SetLastParam(myGeom2d_Arc.LastParameter())

                self.AddObject(myGeom2d_Arc, myAIS_Circle, Sketch_GeometryType.ArcSketchObject)
                self.myContext.Remove(self.myRubberCircle, True)
                self.myContext.Display(myAIS_Circle, True)

                self.myArc3PAction = Arc3PAction.Input_1ArcPoint
            # self.third_Pnt = elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d)
            # tempMakeCirc = gce_MakeCirc(self.myFirstPoint.Pnt(), self.mySecondPoint.Pnt(), self.third_Pnt)
            # if tempMakeCirc.Status() == gce_Done:
            #
            #     Geom_Circle1 = Geom_Circle(tempMakeCirc.Value())
            #     myAIS_Circle = AIS_Circle(Geom_Circle1)
            #
            #     myAIS_Circle.SetFirstParam(
            #         elclib.Parameter(Geom_Circle1.Circ(), self.myFirstPoint.Pnt()))
            #     myAIS_Circle.SetLastParam(elclib.Parameter(Geom_Circle1.Circ(), self.third_Pnt))
            #
            #     self.AddObject(Geom_Circle, myAIS_Circle, Sketch_ObjectTypeOfMethod.Arc3P_Method)
            #     self.myContext.Remove(self.myRubberCircle, True)
            #     self.myContext.Display(myAIS_Circle, True)
            #     self.myArc3PAction = Arc3PAction.Input_1ArcPoint

        elif self.myArc3PAction == Arc3PAction.Input_PolylineArc:
            self.TempGeom2d_Point.SetPnt2d(self.curPnt2d)
            temp2d_QualifiedCurve = Geom2dGcc_QualifiedCurve(self.temp2dAdaptor_Curve, gccent_Unqualified)
            tempGcc_Circ2d3Tan = Geom2dGcc_Circ2d3Tan(temp2d_QualifiedCurve, self.FirstGeom2d_Point,
                                                      self.TempGeom2d_Point, 1.0e-6, 0)
            if (tempGcc_Circ2d3Tan.IsDone() and tempGcc_Circ2d3Tan.NbSolutions() > 0):
                self.temp2d_Circ = tempGcc_Circ2d3Tan.ThisSolution(1)
                self.u1 = elclib.Parameter(self.temp2d_Circ, self.myFirstgp_Pnt2d)
                self.u2 = elclib.Parameter(self.temp2d_Circ, self.curPnt2d)

                self.temp_u1 = self.u1 + (self.u2 - self.u1) / 100
                self.temp_u2 = self.u1 - (self.u2 - self.u1) / 100

                self.tempu1_pnt2d = elclib.Value(self.temp_u1, self.temp2d_Circ)
                self.tempu2_pnt2d = elclib.Value(self.temp_u2, self.temp2d_Circ)

                self.dist1 = self.tempu1_pnt2d.Distance(self.midpoint2d)
                self.dist2 = self.tempu2_pnt2d.Distance(self.midpoint2d)

                if self.dist1 < self.dist2:
                    self.tempu1_pnt2d = self.tempu2_pnt2d
                myGeom2d_Arc = Geom2d_Arc(self.temp2d_Circ)
                myGeom2d_Arc.SetParam(self.myFirstgp_Pnt2d, self.tempu1_pnt2d, self.curPnt2d)

                Geom_Circle1 = Geom_Circle(elclib.To3d(self.curCoordinateSystem.Ax2(), myGeom2d_Arc.Circ2d()))
                myAIS_Circle = AIS_Circle(Geom_Circle1)
                myAIS_Circle.SetFirstParam(myGeom2d_Arc.FirstParameter())
                myAIS_Circle.SetLastParam(myGeom2d_Arc.LastParameter())
                self.myContext.Display(myAIS_Circle, True)

                self.AddObject(myGeom2d_Arc, myAIS_Circle, Sketch_GeometryType.ArcSketchObject)

                self.midpoint2d = myGeom2d_Arc.MiddlePnt()
                self.tempGeom2d_Circle.SetCirc2d(myGeom2d_Arc.Circ2d())
                self.temp2dAdaptor_Curve.Load(self.tempGeom2d_Circle)

                self.myFirstgp_Pnt2d = self.curPnt2d
                self.FirstGeom2d_Point.SetPnt2d(self.myFirstgp_Pnt2d)
                self.myFirstPoint.SetPnt(elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))

                self.tempGeom_Circle.SetRadius(0)
                self.myRubberCircle.SetCircle(self.tempGeom_Circle)
                self.myContext.Redisplay(self.myRubberCircle, True)
        return False