Exemple #1
0
    def __init__(self, name):
        self.data = []
        self.rootNode: Node = None
        self.objectName = name
        self.objectCounter = 0
        self.curCoordinateSystem = gp_Ax3(gp.XOY())

        self.myType = Sketch_ObjectType.MainSketchType
        self.myColor = Quantity_Color(Quantity_NOC_YELLOW)
        self.myStyle = Aspect_TOL_SOLID
        self.myWidth = 1.0
        self.myPrs3dAspect = Prs3d_LineAspect(self.myColor, self.myStyle,
                                              self.myWidth)

        self.myPolylineMode = False
        self.curPnt2d = gp.Origin2d()
        self.myFirstgp_Pnt2d = gp.Origin2d()
        self.mySecondgp_Pn2d = gp.Origin2d()

        self.myFirstPoint: Geom_CartesianPoint = Geom_CartesianPoint(
            gp.Origin())
        self.mySecondPoint: Geom_CartesianPoint = Geom_CartesianPoint(
            gp.Origin())
        self.myRubberLine = AIS_Line(self.myFirstPoint, self.mySecondPoint)
        self.myRubberLine.SetColor(Quantity_Color(Quantity_NOC_LIGHTPINK1))
    def __init__(self):
        self.data = []
        self.curHilightedObj = None
        self.ProjectOnCurve = Geom2dAPI_ProjectPointOnCurve()

        self.curCoordinateSystem = gp_Ax3(gp.XOY())
        self.FirstEdge = TopoDS_Edge()
        self.SecondEdge = TopoDS_Edge()

        self.curPnt2d = gp.Origin2d()
        self.objectPnt2d = gp.Origin2d()
        self.bestPnt2d = gp.Origin2d()
        self.findbestPnt2d = False

        self.firstDisplay = True
        self.myGeom_Point = Geom_CartesianPoint(gp.Origin())
        self.myAIS_Point = AIS_Point(self.myGeom_Point)
        self.myAIS_Point.SetColor(Quantity_Color(Quantity_NOC_YELLOW))
        self.myAIS_Point.SetWidth(5.0)
        self.myAIS_Point.SetMarker(Aspect_TOM_O_POINT)

        self.minimumSnapDistance = MINIMUMSNAP
        self.minDistance = 0
        self.curDistance = 0
        self.curGeom2d_Point = Geom2d_CartesianPoint(self.curPnt2d)
        self.myPlane = Geom_Plane(self.curCoordinateSystem)
Exemple #3
0
    def __init__(self, point, color):
        if isinstance(point, point3):
            pnt = point.Pnt()
            point = Geom_CartesianPoint(pnt)

        self.point = point
        super().__init__(AIS_Point(point), color=color)
Exemple #4
0
 def GetGeometry(self):
     if not self.firstPnt2d.IsEqual(self.tempPnt2d, 1.0e-6):
         self.firstPnt2d = self.tempPnt2d
         self.curGeom2d_Point.SetPnt2d(self.firstPnt2d)
         newGeom_Point = Geom_CartesianPoint(
             elclib.To3d(self.myCoordinateSystem.Ax2(), self.firstPnt2d))
         newAIS_Point = AIS_Point(newGeom_Point)
         self.myContext.Remove(self.myAIS_Object, True)
         self.myAIS_Object = newAIS_Point
         return True
     return False
 def GetGeometry(self):
     # print("first point", self.firstPnt2d.X(), self.firstPnt2d.Y(), self.tempPnt2d.X(), self.tempPnt2d.Y())
     # print("second point", self.secondPnt2d.X(), self.secondPnt2d.Y(), self.temp2Pnt2d.X(), self.temp2Pnt2d.Y())
     if (not self.firstPnt2d.IsEqual(self.tempPnt2d, 1.0e-6)) or (
             not self.secondPnt2d.IsEqual(self.temp2Pnt2d, 1.0e-6)):
         if self.curGeom2d_Edge.SetPoints(self.tempPnt2d, self.temp2Pnt2d):
             self.firstPnt2d.SetX(self.tempPnt2d.X())
             self.firstPnt2d.SetY(self.tempPnt2d.Y())
             self.secondPnt2d.SetX(self.temp2Pnt2d.X())
             self.secondPnt2d.SetY(self.temp2Pnt2d.Y())
             Geom_Point1 = Geom_CartesianPoint(
                 elclib.To3d(self.myCoordinateSystem.Ax2(),
                             self.firstPnt2d))
             Geom_Point2 = Geom_CartesianPoint(
                 elclib.To3d(self.myCoordinateSystem.Ax2(),
                             self.secondPnt2d))
             myAIS_Line = AIS_Line(Geom_Point1, Geom_Point2)
             # edge = BRepBuilderAPI_MakeEdge(Geom_Point1.Pnt(), Geom_Point2.Pnt())
             # myAIS_Line = AIS_Shape(edge.Shape())
             self.myContext.Remove(self.myAIS_Object, True)
             self.myAIS_Object = myAIS_Line
             self.SetLineLength()
             return True
     return False
Exemple #6
0
def pnt():
    # create a point
    for idx in range(10):
        for idy in range(10):
            for idz, aspect in enumerate(ALL_ASPECTS):
                x = 0 + idx * 0.1
                y = 0 + idy * 0.1
                z = 0 + idz / len(ALL_ASPECTS)
                p = Geom_CartesianPoint(gp_Pnt(x, y, z))
                color = Quantity_Color(x / len(ALL_ASPECTS), 0, z,
                                       Quantity_TOC_RGB)
                ais_point = AIS_Point(p)

                drawer = ais_point.Attributes()
                asp = Prs3d_PointAspect(aspect, color, 3)
                drawer.SetPointAspect(asp)
                ais_point.SetAttributes(drawer)

                display.Context.Display(ais_point, False)
    display.FitAll()
    start_display()
Exemple #7
0
 def makePoint(self, point):
     geom_point = Geom_CartesianPoint(point)
     ais_point = AIS_Point(geom_point)
     self._display.Context.Display(ais_point, True)
class Sketch_Snap(object):
    def __init__(self):
        self.data = []
        self.curHilightedObj = None
        self.ProjectOnCurve = Geom2dAPI_ProjectPointOnCurve()

        self.curCoordinateSystem = gp_Ax3(gp.XOY())
        self.FirstEdge = TopoDS_Edge()
        self.SecondEdge = TopoDS_Edge()

        self.curPnt2d = gp.Origin2d()
        self.objectPnt2d = gp.Origin2d()
        self.bestPnt2d = gp.Origin2d()
        self.findbestPnt2d = False

        self.firstDisplay = True
        self.myGeom_Point = Geom_CartesianPoint(gp.Origin())
        self.myAIS_Point = AIS_Point(self.myGeom_Point)
        self.myAIS_Point.SetColor(Quantity_Color(Quantity_NOC_YELLOW))
        self.myAIS_Point.SetWidth(5.0)
        self.myAIS_Point.SetMarker(Aspect_TOM_O_POINT)

        self.minimumSnapDistance = MINIMUMSNAP
        self.minDistance = 0
        self.curDistance = 0
        self.curGeom2d_Point = Geom2d_CartesianPoint(self.curPnt2d)
        self.myPlane = Geom_Plane(self.curCoordinateSystem)

    def SetContext(self, theContext: AIS_InteractiveContext):
        self.myContext = theContext

    def SetData(self, theData: TColStd_HSequenceOfTransient):
        self.data = theData

    def SetAx3(self, theAx3: gp_Ax3):
        self.curCoordinateSystem = theAx3

    def SetMinDistance(self, aPrecise):
        self.minDistance = aPrecise

    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, 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

    def EraseSnap(self):
        self.firstDisplay = True
        self.myContext.Remove(self.myAIS_Point, True)
        self.EraseRelation()

    def AnalyserEvent(self, tempPnt2d: gp_Pnt2d):
        self.curPnt2d = tempPnt2d
        self.SelectEvent()
        newPnt2d = self.bestPnt2d
        dist = self.minDistance
        type = self.GetSnapType()
        return self.findbestPnt2d, newPnt2d, dist, type

    def DrawRelation(self):
        self.myContext.SetSelected(self.curHilightedObj, True)

    def EraseRelation(self):
        self.myContext.ClearSelected(True)

    def countProject(self):
        if self.ProjectOnCurve.NbPoints() > 0:
            self.objectPnt2d = self.ProjectOnCurve.NearestPoint()
            return self.count()
        else:
            return False

    def count(self):
        curDistance = self.objectPnt2d.Distance(self.curPnt2d)
        if self.minDistance > curDistance:
            self.minDistance = curDistance
            return True
        else:
            return False

    def setFirstPnt(self, p: gp_Pnt2d, ttype: TangentType = None):
        pass

    def GetSnapType(self) -> Sketcher_SnapType:
        pass

    def SelectEvent(self):
        pass
Exemple #9
0
 def drawLine(self, objName, gpPnt1, gpPnt2):
     geomPnt1 = Geom_CartesianPoint(gpPnt1)
     geomPnt2 = Geom_CartesianPoint(gpPnt2)
     nativeObj = AIS_Line(geomPnt1, geomPnt2)
     sc._drawNative(objName, nativeObj)
Exemple #10
0
 def drawPoint(self, objName, gpPnt):
     geomPnt = Geom_CartesianPoint(gpPnt)
     nativeObj = AIS_Point(geomPnt)
     sc._drawNative(objName, nativeObj)
Exemple #11
0
def to_GeomPoint(arg):
    return Geom_CartesianPoint(to_Pnt(arg))
Exemple #12
0
 def _drawPoint(self, pnt, style):
     ais = AIS_Point(Geom_CartesianPoint(pnt))
     self._drawAis(ais, style)
Exemple #13
0
 def set_points(self, p1, p2):
     self.p1 = point3(p1)
     self.p2 = point3(p2)
     p1 = Geom_CartesianPoint(to_Pnt(self.p1))
     p2 = Geom_CartesianPoint(to_Pnt(self.p2))
     self.ais_object.SetPoints(p1, p2)
Exemple #14
0
 def make_ais(self):
     p1 = Geom_CartesianPoint(to_Pnt(self.p1))
     p2 = Geom_CartesianPoint(to_Pnt(self.p2))
     return AIS_Line(p1, p2)