1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the tools applications of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include "segmentproperties.h"
43 #include "splineeditor.h"
45 SegmentProperties::SegmentProperties(QWidget *parent) :
46 QWidget(parent), m_splineEditor(0), m_blockSignals(false)
48 QVBoxLayout *layout = new QVBoxLayout(this);
50 layout->setSpacing(2);
53 QWidget *widget = new QWidget(this);
54 m_ui_pane_c1.setupUi(widget);
55 m_ui_pane_c1.label->setText("c1");
56 m_ui_pane_c1.smooth->setVisible(false);
57 layout->addWidget(widget);
59 connect(m_ui_pane_c1.p1_x, SIGNAL(valueChanged(double)), this, SLOT(c1Updated()));
60 connect(m_ui_pane_c1.p1_y, SIGNAL(valueChanged(double)), this, SLOT(c1Updated()));
63 QWidget *widget = new QWidget(this);
64 m_ui_pane_c2.setupUi(widget);
65 m_ui_pane_c2.label->setText("c2");
66 m_ui_pane_c2.smooth->setVisible(false);
67 layout->addWidget(widget);
69 connect(m_ui_pane_c2.p1_x, SIGNAL(valueChanged(double)), this, SLOT(c2Updated()));
70 connect(m_ui_pane_c2.p1_y, SIGNAL(valueChanged(double)), this, SLOT(c2Updated()));
73 QWidget *widget = new QWidget(this);
74 m_ui_pane_p.setupUi(widget);
75 m_ui_pane_p.label->setText("p1");
76 layout->addWidget(widget);
78 connect(m_ui_pane_p.smooth, SIGNAL(toggled(bool)), this, SLOT(pUpdated()));
79 connect(m_ui_pane_p.p1_x, SIGNAL(valueChanged(double)), this, SLOT(pUpdated()));
80 connect(m_ui_pane_p.p1_y, SIGNAL(valueChanged(double)), this, SLOT(pUpdated()));
84 void SegmentProperties::c1Updated()
86 if (m_splineEditor && !m_blockSignals) {
87 QPointF c1(m_ui_pane_c1.p1_x->value(), m_ui_pane_c1.p1_y->value());
88 m_splineEditor->setControlPoint(m_segment * 3, c1);
92 void SegmentProperties::c2Updated()
94 if (m_splineEditor && !m_blockSignals) {
95 QPointF c2(m_ui_pane_c2.p1_x->value(), m_ui_pane_c2.p1_y->value());
96 m_splineEditor->setControlPoint(m_segment * 3 + 1, c2);
100 void SegmentProperties::pUpdated()
102 if (m_splineEditor && !m_blockSignals) {
103 QPointF p(m_ui_pane_p.p1_x->value(), m_ui_pane_p.p1_y->value());
104 bool smooth = m_ui_pane_p.smooth->isChecked();
105 m_splineEditor->setControlPoint(m_segment * 3 + 2, p);
106 m_splineEditor->setSmooth(m_segment, smooth);
110 void SegmentProperties::invalidate()
112 m_blockSignals = true;
114 m_ui_pane_p.label->setText(QLatin1String("p") + QString::number(m_segment));
115 m_ui_pane_p.smooth->setChecked(m_smooth);
116 m_ui_pane_p.smooth->parentWidget()->setEnabled(!m_last);
118 m_ui_pane_c1.p1_x->setValue(m_points.at(0).x());
119 m_ui_pane_c1.p1_y->setValue(m_points.at(0).y());
121 m_ui_pane_c2.p1_x->setValue(m_points.at(1).x());
122 m_ui_pane_c2.p1_y->setValue(m_points.at(1).y());
124 m_ui_pane_p.p1_x->setValue(m_points.at(2).x());
125 m_ui_pane_p.p1_y->setValue(m_points.at(2).y());
127 m_blockSignals = false;