def _create_control(self): ctrl = QGraphicsView() ctrl.setRenderHints(QPainter.Antialiasing) scene = QGraphicsScene() ctrl.setScene(scene) scene.setBackgroundBrush(QBrush(QColor(237, 237, 237))) ctrl.setStyleSheet("border: 0px") w, h = 150, 150 ctrl.setMinimumHeight(h + 22) ctrl.setMinimumWidth(w + 22) cx, cy = w / 2, h / 2. ex, ey = cx, cy + 20 pen = QPen() pen.setStyle(Qt.NoPen) # pen.setColor(QColor(237, 237, 237)) bounding_rect = scene.addRect(0, 0, w, h, pen=pen) bounding_rect.setFlag(QGraphicsItem.ItemClipsChildrenToShape) self.animation = QSequentialAnimationGroup() self._add_laser_logo(scene, bounding_rect, ex, ey, cx, cy, w, h) self._add_bullet(scene, bounding_rect,ex, ey, cx, cy) self._add_fragments(scene, bounding_rect, ex, ey) self.animation.setLoopCount(-1) return ctrl
def _create_control(self): ctrl = QGraphicsView() ctrl.setRenderHints(QPainter.Antialiasing) scene = QGraphicsScene() ctrl.setScene(scene) scene.setBackgroundBrush(QBrush(QColor(237, 237, 237))) ctrl.setStyleSheet("border: 0px") w, h = 150, 150 ctrl.setMinimumHeight(h + 22) ctrl.setMinimumWidth(w + 22) cx, cy = w / 2, h / 2. ex, ey = cx, cy + 20 pen = QPen() pen.setStyle(Qt.NoPen) # pen.setColor(QColor(237, 237, 237)) bounding_rect = scene.addRect(0, 0, w, h, pen=pen) bounding_rect.setFlag(QGraphicsItem.ItemClipsChildrenToShape) self.animation = QSequentialAnimationGroup() self._add_laser_logo(scene, bounding_rect, ex, ey, cx, cy, w, h) self._add_bullet(scene, bounding_rect, ex, ey, cx, cy) self._add_fragments(scene, bounding_rect, ex, ey) self.animation.setLoopCount(-1) return ctrl
def _create_control(self): ctrl = QGraphicsView() scene = QGraphicsScene() ctrl.setScene(scene) scene.setBackgroundBrush(QBrush(QColor(237, 237, 237))) ctrl.setStyleSheet("border: 0px") md = self._dimension * 3 + self._spacing * 4 ctrl.setMaximumWidth(md) ctrl.setMaximumHeight(md) layout = QVBoxLayout() layout.addWidget(ctrl) self._scene = scene self.control = QWidget() self.control.setLayout(layout)
def __init__(self, parent=None): super(ExplicitBezierCurveWidget, self).__init__(parent) graphics_view = QGraphicsView() def graphics_view_resize_event(event): assert isinstance(event, QResizeEvent) graphics_view.fitInView(QRectF(0, -SCENE_SIZE_2, SCENE_SIZE, SCENE_SIZE), Qt.KeepAspectRatio) super(QGraphicsView, graphics_view).resizeEvent(event) graphics_view.resizeEvent = graphics_view_resize_event self.explicit_bezier_curve_scene = ExplicitBezierCurveScene(self) graphics_view.setScene(self.explicit_bezier_curve_scene) graphics_view.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform) properties_group_box = QGroupBox() properties_group_box.setTitle("Properties") properties_group_box_layout = QVBoxLayout() properties_group_box.setLayout(properties_group_box_layout) # Degree degree_layout = QHBoxLayout() properties_group_box_layout.addLayout(degree_layout) degree_label = QLabel("Polynomial degree") self.degree_spinbox = QSpinBox() self.degree_spinbox.setRange(MIN_POLYNOMIAL_DEGREE, MAX_POLYNOMIAL_DEGREE) self.degree_spinbox.setValue(POLYNOMIAL_DEGREE_DEFAULT) self.degree_spinbox.valueChanged.connect(self.process_degree_changed) degree_label.setBuddy(self.degree_spinbox) degree_layout.addWidget(degree_label) degree_layout.addWidget(self.degree_spinbox) # X - range x_layout = QHBoxLayout() x_label = QLabel("X:") x_layout.addWidget(x_label) properties_group_box_layout.addLayout(x_layout) min_x_value_label = QLabel("Min") x_layout.addWidget(min_x_value_label) self.min_x_value_spinbox = QDoubleSpinBox() x_layout.addWidget(self.min_x_value_spinbox) self.min_x_value_spinbox.setRange(MIN_X_VALUE, DEFAULT_MAX_X_VALUE-MIN_X_RANGE) self.min_x_value_spinbox.setValue(DEFAULT_MIN_X_VALUE) self.min_x_value_spinbox.valueChanged.connect(self.process_min_x_value_changed) max_x_value_label = QLabel("Max") x_layout.addWidget(max_x_value_label) self.max_x_value_spinbox = QDoubleSpinBox() x_layout.addWidget(self.max_x_value_spinbox) self.max_x_value_spinbox.setRange(DEFAULT_MIN_X_VALUE - MIN_X_RANGE, MAX_X_VALUE) self.max_x_value_spinbox.setValue(DEFAULT_MAX_X_VALUE) self.max_x_value_spinbox.valueChanged.connect(self.process_max_x_value_changed) # Y - range y_layout = QHBoxLayout() properties_group_box_layout.addLayout(y_layout) y_label = QLabel("Y:") y_layout.addWidget(y_label) min_y_value_label = QLabel("Min") y_layout.addWidget(min_y_value_label) self.min_y_value_spinbox = QDoubleSpinBox() self.min_y_value_spinbox.setRange(MIN_Y_VALUE, DEFAULT_MAX_Y_VALUE-MIN_Y_RANGE) self.min_y_value_spinbox.setValue(DEFAULT_MIN_Y_VALUE) self.min_y_value_spinbox.valueChanged.connect(self.process_min_value_changed) min_y_value_label.setBuddy(self.min_y_value_spinbox) y_layout.addWidget(self.min_y_value_spinbox) max_y_value_label = QLabel("Max") y_layout.addWidget(max_y_value_label) self.max_y_value_spinbox = QDoubleSpinBox() self.max_y_value_spinbox.setRange(DEFAULT_MIN_Y_VALUE - MIN_Y_RANGE, MAX_Y_VALUE) self.max_y_value_spinbox.setValue(DEFAULT_MAX_Y_VALUE) self.max_y_value_spinbox.valueChanged.connect(self.process_max_value_changed) max_y_value_label.setBuddy(self.max_y_value_spinbox) y_layout.addWidget(self.max_y_value_spinbox) properties_group_box_layout.addStretch() self.polynom_widget = LatexLabelWidget() main_layout = QVBoxLayout() upper_layout = QVBoxLayout() upper_layout.addWidget(graphics_view) upper_layout.addWidget(properties_group_box) main_layout.addLayout(upper_layout) main_layout.addWidget(self.polynom_widget) self.setLayout(main_layout) self.process_control_points_changed()