def add_constraint(self,constraintclass): from popupcad.filetypes.genericshapes import GenericLine self.undoredo.savesnapshot() items = [] new_constraints = [] for item in self.scene.selectedItems(): if isinstance(item,ReferenceInteractiveVertex): generic = item.get_generic() newgeneric = generic.copy_values(DrawnPoint(),False) newitem = newgeneric.gen_interactive() self.scene.addItem(newitem) items.append(newgeneric) item.setSelected(False) newitem.setSelected(True) new_constraints.append(constraints.fixed.new(newgeneric)) elif isinstance(item,ReferenceInteractiveEdge): generic = item.get_generic() v1 = generic.vertex1.copy_values(ShapeVertex(),False) v2 = generic.vertex2.copy_values(ShapeVertex(),False) new_constraints.append(constraints.fixed.new(v1,v2)) l = GenericLine([v1,v2],[],construction = True) a = l.outputinteractive() # b = v1.gen_interactive() # c = v2.gen_interactive() self.scene.addItem(a) # self.scene.addItem(b) # self.scene.addItem(c) item.setSelected(False) a.setSelected(True) # b.setSelected(True) # c.setSelected(True) items.append(a.selectableedges[0].get_generic()) elif isinstance(item,InteractiveVertex): items.append(item.get_generic()) elif isinstance(item,InteractiveEdge): items.append(item.get_generic()) elif isinstance(item,InteractiveLine): items.append(item.selectableedges[0].get_generic()) elif isinstance(item,StaticLine): items.append(item.selectableedges[0].get_generic()) elif isinstance(item,DrawingPoint): items.append(item.get_generic()) elif isinstance(item,StaticDrawingPoint): items.append(item.get_generic()) new_constraints .append(constraintclass.new(*items)) for constraint in new_constraints: self.sketch.constraintsystem.add_constraint(constraint) self.refreshconstraints()
def add_constraint(self, constraintclass): from popupcad.filetypes.genericshapes import GenericLine self.undoredo.savesnapshot() items = [] new_constraints = [] for item in self.scene.selectedItems(): if isinstance(item, ReferenceInteractiveVertex): generic = item.get_generic() newgeneric = DrawnPoint(generic.getpos(), construction=True) newitem = newgeneric.gen_interactive() self.scene.addItem(newitem) items.append(newgeneric) item.setSelected(False) newitem.setSelected(True) new_constraints.append( constraints.FixedConstraint.new(newgeneric)) elif isinstance(item, ReferenceInteractiveEdge): generic = item.get_generic() v1 = ShapeVertex(generic.vertex1.getpos()) v2 = ShapeVertex(generic.vertex2.getpos()) new_constraints.append(constraints.FixedConstraint.new(v1, v2)) l = GenericLine([v1, v2], [], construction=True) a = l.outputinteractive() self.scene.addItem(a) item.setSelected(False) a.setSelected(True) items.append(a.selectableedges[0].get_generic()) elif isinstance(item, InteractiveVertex): items.append(item.get_generic()) elif isinstance(item, InteractiveEdge): items.append(item.get_generic()) elif isinstance(item, DrawingPoint): items.append(item.get_generic()) new_constraint = constraintclass.new(*items) if new_constraint is not None: new_constraints.append(new_constraint) for constraint in new_constraints: self.sketch.constraintsystem.add_constraint(constraint) self.refreshconstraints()
def add_constraint(self, constraintclass): from popupcad.filetypes.genericshapes import GenericLine self.undoredo.savesnapshot() items = [] new_constraints = [] for item in self.scene.selectedItems(): if isinstance(item, ReferenceInteractiveVertex): generic = item.get_generic() newgeneric = DrawnPoint(generic.getpos(),construction = True) newitem = newgeneric.gen_interactive() self.scene.addItem(newitem) items.append(newgeneric) item.setSelected(False) newitem.setSelected(True) new_constraints.append(constraints.FixedConstraint.new(newgeneric)) elif isinstance(item, ReferenceInteractiveEdge): generic = item.get_generic() v1 = ShapeVertex(generic.vertex1.getpos()) v2 = ShapeVertex(generic.vertex2.getpos()) new_constraints.append(constraints.FixedConstraint.new(v1, v2)) l = GenericLine([v1, v2], [], construction=True) a = l.outputinteractive() self.scene.addItem(a) item.setSelected(False) a.setSelected(True) items.append(a.selectableedges[0].get_generic()) elif isinstance(item, InteractiveVertex): items.append(item.get_generic()) elif isinstance(item, InteractiveEdge): items.append(item.get_generic()) elif isinstance(item, DrawingPoint): items.append(item.get_generic()) new_constraint = constraintclass.new(*items) if new_constraint is not None: new_constraints.append(new_constraint) for constraint in new_constraints: self.sketch.constraintsystem.add_constraint(constraint) self.refreshconstraints()