BezierSplineEditor::BezierSplineEditor(QWidget* parent) :
QWidget(parent),
m_zoomLevel(0),
+ m_gridLines(3),
m_mode(ModeNormal),
m_currentPointIndex(-1)
{
update();
}
+void BezierSplineEditor::slotGridChange()
+{
+ m_gridLines = (m_gridLines + 1) % 9;
+ update();
+}
+
void BezierSplineEditor::paintEvent(QPaintEvent* event)
{
Q_UNUSED(event);
/*p.setPen(QPen(Qt::gray, 1, Qt::SolidLine));
p.drawLine(QLineF(0, wHeight, wWidth, 0));*/
+ p.setPen(QPen(Qt::gray, 1, Qt::SolidLine));
+
+ /*
+ * Borders
+ */
if (m_zoomLevel != 0) {
- /*
- * Borders
- */
- p.setPen(QPen(Qt::gray, 1, Qt::SolidLine));
p.drawRect(offset, offset, wWidth, wHeight);
}
+ /*
+ * Grid
+ */
+ if (m_gridLines != 0) {
+ double stepH = wWidth / (double)(m_gridLines + 1);
+ double stepV = wHeight / (double)(m_gridLines + 1);
+ for (int i = 1; i <= m_gridLines; ++i) {
+ p.drawLine(QLineF(i * stepH, 0, i * stepH, wHeight).translated(offset, offset));
+ p.drawLine(QLineF(0, i * stepV, wWidth, i * stepV).translated(offset, offset));
+ }
+ }
+
/*
* Spline
*/
public slots:
void slotZoomIn();
void slotZoomOut();
+ void slotGridChange();
protected:
//void keyPressEvent(QKeyEvent *event);
enum point_types { PTypeH1, PTypeP, PTypeH2 };
modes m_mode;
int m_zoomLevel;
+ int m_gridLines;
int m_currentPointIndex;
point_types m_currentPointType;
double m_grabOffsetX;
m_ui.buttonLinkHandles->setEnabled(false);
m_ui.buttonZoomIn->setIcon(KIcon("zoom-in"));
m_ui.buttonZoomOut->setIcon(KIcon("zoom-out"));
+ m_ui.buttonGridChange->setIcon(KIcon("view-grid"));
m_ui.widgetPoint->setEnabled(false);
CubicBezierSpline s;
connect(m_ui.buttonZoomIn, SIGNAL(clicked()), &m_edit, SLOT(slotZoomIn()));
connect(m_ui.buttonZoomOut, SIGNAL(clicked()), &m_edit, SLOT(slotZoomOut()));
+ connect(m_ui.buttonGridChange, SIGNAL(clicked()), &m_edit, SLOT(slotGridChange()));
}
QString BezierSplineWidget::spline()
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="1" column="5" colspan="3">
+ <item row="1" column="5" colspan="4">
<widget class="QWidget" name="widgetPoint" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="9">
</layout>
</widget>
</item>
- <item row="2" column="5">
+ <item row="2" column="6">
<widget class="QToolButton" name="buttonZoomIn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
- <item row="2" column="6">
+ <item row="2" column="7">
<widget class="QToolButton" name="buttonZoomOut">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
- <item row="2" column="7">
+ <item row="2" column="8">
<spacer name="spacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</spacer>
</item>
+ <item row="2" column="5">
+ <widget class="QToolButton" name="buttonGridChange">
+ <property name="toolTip">
+ <string>Increases the number of lines in the grid.<br />After 8 lines it will begin from 0 again.</string>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>