def main(): app = QApplication(sys.argv) utils.addMarkerFromSvg("test.svg", "CUSTOM_MARKER", 40) viewer = quarter.QuarterWidget() root = graphics.InteractionSeparator(viewer.sorendermanager) root.pick_radius = 40 m1 = ConnectionMarker([[-1, -1, -1]]) m2 = ConnectionMarker([[-1, 1, -1]]) m3 = ConnectionMarker([[1, 1, -1]]) m4 = ConnectionMarker([[1, -1, -1]]) m5 = ConnectionMarker([[-1, -1, 1]]) m6 = ConnectionMarker([[-1, 1, 1]]) m7 = ConnectionMarker([[1, 1, 1]]) m8 = ConnectionMarker([[1, -1, 1]]) points = [m1, m2, m3, m4, m5, m6, m7, m8] l01 = ConnectionLine([m1, m2]) l02 = ConnectionLine([m2, m3]) l03 = ConnectionLine([m3, m4]) l04 = ConnectionLine([m4, m1]) l05 = ConnectionLine([m5, m6]) l06 = ConnectionLine([m6, m7]) l07 = ConnectionLine([m7, m8]) l08 = ConnectionLine([m8, m5]) l09 = ConnectionLine([m1, m5]) l10 = ConnectionLine([m2, m6]) l11 = ConnectionLine([m3, m7]) l12 = ConnectionLine([m4, m8]) lines = [l01, l02, l03, l04, l05, l06, l07, l08, l09, l10, l11, l12] p1 = ConnectionPolygon([m1, m2, m3, m4]) p2 = ConnectionPolygon([m8, m7, m6, m5]) p3 = ConnectionPolygon([m5, m6, m2, m1]) p4 = ConnectionPolygon([m6, m7, m3, m2]) p5 = ConnectionPolygon([m7, m8, m4, m3]) p6 = ConnectionPolygon([m8, m5, m1, m4]) polygons = [p1, p2, p3, p4, p5, p6] root += points + lines + polygons root.register() viewer.setSceneGraph(root) viewer.setBackgroundColor(QColor(255, 255, 255)) viewer.setWindowTitle("minimal") viewer.show() sys.exit(app.exec_())
def setup_InteractionSeparator(self): if self.root_inserted: self.sg.removeChild(self.root) self.root = graphics.InteractionSeparator(self.rm) self.root.setName("InteractionSeparator") self.root.pick_radius = 40 self.root.on_drag.append(self.update_curve) # Keyboard callback self._controlCB = self.root.events.addEventCallback(coin.SoKeyboardEvent.getClassTypeId(), self.controlCB) # populate root node self.root += self.points self.build_lines() self.root += self.lines self.root.register() self.sg.addChild(self.root) self.root_inserted = True
def setup_bspline(self): # create a new interaction seperator if hasattr(self, "interaction_sep"): self.interaction_sep.unregister() self.task_separator -= self.interaction_sep self.interaction_sep = graphics.InteractionSeparator(self.rm) self.interaction_sep.selection_changed = self.selection_changed upper_array = self.obj.Proxy.get_upper_array(self.obj) lower_array = self.obj.Proxy.get_lower_array(self.obj) upper_array_1 = copy.copy(upper_array) upper_array_1[:3] *= upper_array_1[3] lower_array_1 = copy.copy(lower_array) lower_array_1[:3] *= lower_array_1[3] self.upper_poles.point.setValues(0, 9, upper_array_1.T) self.lower_poles.point.setValues(0, 9, lower_array_1.T) self.upper_markers = [] self.lower_markers = [] tangent_points = [] k = 0 for i, mat in enumerate([upper_array, lower_array]): if i == 0: poles = self.upper_poles _markers = self.upper_markers upper = True else: poles = self.lower_poles _markers = self.lower_markers upper = False for j, col in enumerate(mat.T): if j in [0, 8]: marker = graphics.Marker([col[:-1]], dynamic=False) elif (j == 1 and i == 0) or (j == 1 and i == 1): marker = ConstrainedXMarker([col[:-1]], col[-1], poles, j, upper, dynamic=True) tangent_points.append(marker) else: marker = ConstrainedMarker([col[:-1]], col[-1], poles, j, upper, dynamic=True) marker.on_drag.append(self.update_table) self.interaction_sep += marker _markers.append(marker) k += 1 tangent_points[0].set_tangent_point(tangent_points[1]) tangent_points[1].set_tangent_point(tangent_points[0]) self.task_separator += self.interaction_sep self.interaction_sep.register() self.update_table() self.upper_pole_table.cellChanged.connect( self.update_upper_points_by_table) self.lower_pole_table.cellChanged.connect( self.update_lower_points_by_table)