| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | 
| 4 | ** Contact: https://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the tools applications of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ | 
| 9 | ** Commercial License Usage | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 11 | ** accordance with the commercial license agreement provided with the | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 16 | ** | 
| 17 | ** GNU General Public License Usage | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU | 
| 19 | ** General Public License version 3 as published by the Free Software | 
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT | 
| 21 | ** included in the packaging of this file. Please review the following | 
| 22 | ** information to ensure the GNU General Public License requirements will | 
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | 
| 24 | ** | 
| 25 | ** $QT_END_LICENSE$ | 
| 26 | ** | 
| 27 | ****************************************************************************/ | 
| 28 |  | 
| 29 | #include "segmentproperties.h" | 
| 30 | #include "splineeditor.h" | 
| 31 |  | 
| 32 | SegmentProperties::SegmentProperties(QWidget *parent) : | 
| 33 |     QWidget(parent), m_splineEditor(nullptr), m_blockSignals(false) | 
| 34 | { | 
| 35 |     QVBoxLayout *layout = new QVBoxLayout(this); | 
| 36 |     layout->setContentsMargins(QMargins()); | 
| 37 |     layout->setSpacing(2); | 
| 38 |     setLayout(layout); | 
| 39 |     { | 
| 40 |         QWidget *widget = new QWidget(this); | 
| 41 |         m_ui_pane_c1.setupUi(widget); | 
| 42 |         m_ui_pane_c1.label->setText("c1" ); | 
| 43 |         m_ui_pane_c1.smooth->setVisible(false); | 
| 44 |         layout->addWidget(widget); | 
| 45 |  | 
| 46 |         connect(sender: m_ui_pane_c1.p1_x, SIGNAL(valueChanged(double)), receiver: this, SLOT(c1Updated())); | 
| 47 |         connect(sender: m_ui_pane_c1.p1_y, SIGNAL(valueChanged(double)), receiver: this, SLOT(c1Updated())); | 
| 48 |     } | 
| 49 |     { | 
| 50 |         QWidget *widget = new QWidget(this); | 
| 51 |         m_ui_pane_c2.setupUi(widget); | 
| 52 |         m_ui_pane_c2.label->setText("c2" ); | 
| 53 |         m_ui_pane_c2.smooth->setVisible(false); | 
| 54 |         layout->addWidget(widget); | 
| 55 |  | 
| 56 |         connect(sender: m_ui_pane_c2.p1_x, SIGNAL(valueChanged(double)), receiver: this, SLOT(c2Updated())); | 
| 57 |         connect(sender: m_ui_pane_c2.p1_y, SIGNAL(valueChanged(double)), receiver: this, SLOT(c2Updated())); | 
| 58 |     } | 
| 59 |     { | 
| 60 |         QWidget *widget = new QWidget(this); | 
| 61 |         m_ui_pane_p.setupUi(widget); | 
| 62 |         m_ui_pane_p.label->setText("p1" ); | 
| 63 |         layout->addWidget(widget); | 
| 64 |  | 
| 65 |         connect(sender: m_ui_pane_p.smooth, SIGNAL(toggled(bool)), receiver: this, SLOT(pUpdated())); | 
| 66 |         connect(sender: m_ui_pane_p.p1_x, SIGNAL(valueChanged(double)), receiver: this, SLOT(pUpdated())); | 
| 67 |         connect(sender: m_ui_pane_p.p1_y, SIGNAL(valueChanged(double)), receiver: this, SLOT(pUpdated())); | 
| 68 |     } | 
| 69 | } | 
| 70 |  | 
| 71 | void SegmentProperties::c1Updated() | 
| 72 | { | 
| 73 |     if (m_splineEditor && !m_blockSignals) { | 
| 74 |         QPointF c1(m_ui_pane_c1.p1_x->value(), m_ui_pane_c1.p1_y->value()); | 
| 75 |         m_splineEditor->setControlPoint(index: m_segment * 3, point: c1); | 
| 76 |     } | 
| 77 | } | 
| 78 |  | 
| 79 | void SegmentProperties::c2Updated() | 
| 80 | { | 
| 81 |     if (m_splineEditor && !m_blockSignals) { | 
| 82 |         QPointF c2(m_ui_pane_c2.p1_x->value(), m_ui_pane_c2.p1_y->value()); | 
| 83 |         m_splineEditor->setControlPoint(index: m_segment * 3 + 1, point: c2); | 
| 84 |     } | 
| 85 | } | 
| 86 |  | 
| 87 | void SegmentProperties::pUpdated() | 
| 88 | { | 
| 89 |     if (m_splineEditor && !m_blockSignals) { | 
| 90 |         QPointF p(m_ui_pane_p.p1_x->value(), m_ui_pane_p.p1_y->value()); | 
| 91 |         bool smooth = m_ui_pane_p.smooth->isChecked(); | 
| 92 |         m_splineEditor->setControlPoint(index: m_segment * 3 + 2, point: p); | 
| 93 |         m_splineEditor->setSmooth(index: m_segment, smooth); | 
| 94 |     } | 
| 95 | } | 
| 96 |  | 
| 97 | void SegmentProperties::invalidate() | 
| 98 | { | 
| 99 |     m_blockSignals = true; | 
| 100 |  | 
| 101 |      m_ui_pane_p.label->setText(QLatin1Char('p') + QString::number(m_segment)); | 
| 102 |      m_ui_pane_p.smooth->setChecked(m_smooth); | 
| 103 |      m_ui_pane_p.smooth->parentWidget()->setEnabled(!m_last); | 
| 104 |  | 
| 105 |      m_ui_pane_c1.p1_x->setValue(m_points.at(i: 0).x()); | 
| 106 |      m_ui_pane_c1.p1_y->setValue(m_points.at(i: 0).y()); | 
| 107 |  | 
| 108 |      m_ui_pane_c2.p1_x->setValue(m_points.at(i: 1).x()); | 
| 109 |      m_ui_pane_c2.p1_y->setValue(m_points.at(i: 1).y()); | 
| 110 |  | 
| 111 |      m_ui_pane_p.p1_x->setValue(m_points.at(i: 2).x()); | 
| 112 |      m_ui_pane_p.p1_y->setValue(m_points.at(i: 2).y()); | 
| 113 |  | 
| 114 |      m_blockSignals = false; | 
| 115 | } | 
| 116 |  | 
| 117 | #include "moc_segmentproperties.cpp" | 
| 118 |  |