def set_previous_direction(self): if self.prev_object == None: return if self.prev_object.GetType() == cad.OBJECT_TYPE_SKETCH_LINE: undoable = SetPreviousDirection( self, self.prev_object.B - self.prev_object.A) cad.PyIncref(undoable) cad.DoUndoable(undoable) elif self.prev_object.GetType() == cad.OBJECT_TYPE_SKETCH_ARC: undoable = SetPreviousDirection( self, (self.prev_object.axis ^ (self.prev_object.B - self.prev_object.C)).Normalized()) cad.PyIncref(undoable) cad.DoUndoable(undoable)
def __init__(self, title, value_name, object, recalculate=None): t = cad.PROPERTY_TYPE_INVALID a = getattr(object, value_name) tt = type(a) if tt == bool: t = cad.PROPERTY_TYPE_CHECK elif tt == int: t = cad.PROPERTY_TYPE_INT elif tt == float: t = cad.PROPERTY_TYPE_DOUBLE elif tt == str: t = cad.PROPERTY_TYPE_STRING elif tt == geom.Point: t = cad.PROPERTY_TYPE_LIST self.children = [] self.children.append(PyPropertyLength('X', 'x', a, object)) self.children.append(PyPropertyLength('Y', 'y', a, object)) elif tt == geom.Point3D: t = cad.PROPERTY_TYPE_LIST self.children = [] self.children.append(PyPropertyLength('X', 'x', a, object)) self.children.append(PyPropertyLength('Y', 'y', a, object)) self.children.append(PyPropertyLength('Z', 'z', a, object)) heeksobj = None if isinstance(object, cad.Object): heeksobj = object cad.Property.__init__(self, t, title, heeksobj) self.value_name = value_name self.title = title self.type = t self.recalc = recalculate self.pyobj = object cad.PyIncref( self ) # never delete any PyProperty objects. They are needed for undo/redo operations. To do - add these to a list belonging to the App and clear the list when the undo list is cleared.
def __init__(self, type, id_named=False): cad.BaseObject.__init__(self, type) cad.PyIncref(self) self.box = geom.Box3D() self.id_named = id_named if self.id_named: self.title = self.TypeName() self.title_made_from_id = True
def calculate_item(self, end): if self.number_of_steps() > 1 and self.start_pos.type == cad.DigitizeType.DIGITIZE_NO_ITEM_TYPE: return False if end.type == cad.DigitizeType.DIGITIZE_NO_ITEM_TYPE: return False if self.drawing_mode == EllipseDrawingMode: if self.draw_step == 1: # add a circle for graphics c_rad = self.start_pos.point.Dist(end.point) if self.TempObject() == None: self.AddToTempObjects(cad.NewCircle(self.start_pos.point, geom.Point3D(0, 0, 1), c_rad)) else: self.TempObject().radius = c_rad else: # draw_step = 2 if (self.TempObject() != None) and (self.TempObject().GetType() != step.GetEllipseType()): self.ClearObjectsMade() if self.TempObject() == None: new_object = step.Ellipse(self.before_start_pos, self.start_pos, end) cad.PyIncref(new_object) self.AddToTempObjects(new_object) else: self.TempObject().SetFromDigitized(self.before_start_pos, self.start_pos, end) return True if self.drawing_mode == SplineDrawingMode: if (self.TempObject() != None) and (self.TempObject().GetType() != step.GetSplineType()): self.ClearObjectsMade() # # Handle_Geom_BSplineCurve spline; # switch (spline_mode) # { # case CubicSplineMode: # DigitizedPointGetCubicSpline(GetBeforeBeforeStartPos(), GetBeforeStartPos(), GetStartPos(), end, spline); # break; # case QuarticSplineMode: # DigitizedPointGetQuarticSpline(GetBeforeStartPos(), GetStartPos(), end, spline); # break; # case RationalSplineMode: # DigitizedPointGetRationalSpline(spline_points, end, spline); # break; # } # # if (TempObject() == NULL){ # AddToTempObjects(new HSpline(spline, &theApp->GetCurrentColor())); # } # else{ # ((HSpline*)TempObject())->m_spline = spline; # } # # return true; return False
def __init__(self, title, value_name, choices, object, alternative_values=None, recalculate=None): self.title = title # to do, remove this GetTitle should use base class method self.value_name = value_name self.choices = choices self.alternative_values = alternative_values self.recalc = recalculate self.pyobj = object cad.Property.__init__(self, cad.PROPERTY_TYPE_CHOICE, title, object) cad.PyIncref(self)
def __init__(self, title, value_name, pyobj, heeksobj=None, recalculate=None): if heeksobj == None: heeksobj = pyobj if not isinstance(heeksobj, cad.Object): heeksobj = None t = cad.PROPERTY_TYPE_LENGTH cad.Property.__init__(self, t, title, heeksobj) self.value_name = value_name self.title = title self.type = t self.recalc = recalculate self.pyobj = pyobj cad.PyIncref(self)
def MakeACopy(self): copy = Profile(self.sketch) cad.PyIncref(copy) copy.CopyFrom(self) return copy
def ClearToolpath(self): cad.StartHistory('Clear Toolpath') blank_nc = NcCode.NcCode() cad.PyIncref(blank_nc) wx.GetApp().CopyUndoablyWithChildren(wx.GetApp().program.nccode, blank_nc) self.EndHistory()
def CopyUndoably(self, object, copy_with_new_data): copy_undoable = CopyObjectUndoable(object, copy_with_new_data) cad.PyIncref(copy_undoable) cad.DoUndoable(copy_undoable)
def calculate_item(self, end): if self.number_of_steps( ) > 1 and self.start_pos.type == cad.DigitizeType.DIGITIZE_NO_ITEM_TYPE: return False if end.type == cad.DigitizeType.DIGITIZE_NO_ITEM_TYPE: return False if self.drawing_mode == LineDrawingMode: if self.TempObject() != None and self.TempObject().GetType( ) != cad.OBJECT_TYPE_SKETCH_LINE: self.ClearObjectsMade() #DigitizeMode::GetLinePoints(GetStartPos(), end, p1, p2); p1 = self.start_pos.point p2 = end.point if p1 == p2: return False end.point = p2 if self.TempObject() == None: self.AddToTempObjects(cad.NewLine(p1, p2)) else: self.TempObject().A = p1 self.TempObject().B = p2 return True elif self.drawing_mode == ArcDrawingMode: # tangential arcs if (self.TempObject() != None) and (self.TempObject().GetType() != cad.OBJECT_TYPE_SKETCH_ARC): self.ClearObjectsMade() #Point3d centre; #Point3d axis; #Point3d p1, p2; #bool arc_found = DigitizeMode::GetArcPoints(GetStartPos(), m_previous_direction_set ? (&m_previous_direction) : NULL, end, p1, p2, centre, axis); arc_found = True p1 = self.start_pos.point p2 = end.point if p1 == p2: return False if self.previous_direction == None: return False if arc_found: tangent_arc_found, centre, axis = cad.TangentialArc( p1, self.previous_direction, p2) if tangent_arc_found: # arc if self.TempObject() == None: self.AddToTempObjects(cad.NewArc(p1, p2, axis, centre)) else: self.TempObject().axis = axis self.TempObject().C = centre self.TempObject().A = p1 self.TempObject().B = p2 else: # line if (self.TempObject() != None) and self.TempObject( ).GetType() != cad.OBJECT_TYPE_SKETCH_LINE: self.ClearObjectsMade() if self.TempObject() == None: self.AddToTempObjects(cad.NewLine(p1, p2)) else: self.TempObject().A = p1 self.TempObject().B = p2 return True elif self.drawing_mode == ILineDrawingMode: if self.TempObject( ) and self.TempObject().GetType() != cad.OBJECT_TYPE_ILINE: self.ClearObjectsMade() #DigitizeMode::GetLinePoints(GetStartPos(), end, p1, p2); p1 = self.start_pos.point p2 = end.point if p1 == p2: return False if self.TempObject() == None: new_object = cad.ILine(p1, p2) cad.PyIncref(new_object) self.AddToTempObjects(new_object) else: self.TempObject().A = p1 self.TempObject().B = p2 return True elif self.drawing_mode == CircleDrawingMode: if self.TempObject( ) and self.TempObject().GetType() != cad.OBJECT_TYPE_CIRCLE: self.ClearObjectsMade() if self.circle_mode == CentreAndPointCircleMode: # Point3d p1, p2, centre; # Point3d axis; # DigitizeMode::GetArcPoints(GetStartPos(), NULL, end, p1, p2, centre, axis); p1 = self.start_pos.point p2 = end.point self.radius_for_circle = p1.Dist(p2) if self.TempObject() == None: self.AddToTempObjects( cad.NewCircle(p1, geom.Point3D(0, 0, 1), self.radius_for_circle)) else: self.TempObject().C = p1 self.TempObject().radius = self.radius_for_circle return True elif self.circle_mode == ThreePointsCircleMode: if self.draw_step == 1: # add a line for graphics if self.TempObject() == None: self.AddToTempObjects( cad.NewLine(self.start_pos.point, end.point)) else: self.TempObject().A = self.start_pos.point self.TempObject().B = end.point else: # draw_step = 2 # add the circle found, c = cad.GetTangentCircle(self.before_start_pos, self.start_pos, end) if self.TempObject() == None: self.AddToTempObjects( cad.NewCircle(geom.Point3D(c.c.x, c.c.y, 0.0), geom.Point3D(0, 0, 1), c.radius)) else: self.TempObject().SetCircle(c) return True elif self.circle_mode == TwoPointsCircleMode: found, c = cad.GetCircleBetween(self.start_pos, end) if found: if self.TempObject() == None: self.AddToTempObjects( cad.NewCircle(geom.Point3D(c.c.x, c.c.y, 0.0), geom.Point3D(0, 0, 1), c.radius)) else: self.TempObject().SetCircle(c) return True elif self.circle_mode == CentreAndRadiusCircleMode: if self.TempObject() == None: self.AddToTempObjects( cad.NewCircle(end.point, geom.Point3D(0, 0, 1), self.radius_for_circle)) else: self.TempObject().C = end.point self.TempObject().radius = self.radius_for_circle return True
def SetStartPosUndoable(self, pos): undoable = SetDrawingPosition(self, pos) cad.PyIncref(undoable) cad.DoUndoable(undoable)
def SetDrawStepUndoable(self, s): undoable = SetDrawingDrawStep(self, s) cad.PyIncref(undoable) cad.DoUndoable(undoable)