/* manipulator.cc This file is part of the Project::OSiRiON world editor and is distributed under the terms and conditions of the GNU General Public License version 2 */ #include "manipulator.h" #include #include #include #include namespace editor { Manipulator::Manipulator(QWidget *parent) : QWidget(parent) { manipulator_mode = None; manipulator_yaw = 0; } void Manipulator::setSize(const QWidget *widget) { const int s = 16; setGeometry( widget->x() - s, widget->y() -s, widget->width() + 2 * s, widget->height() + 2 * s ); } void Manipulator::paintEvent(QPaintEvent *event) { if (mode() == None) return; QColor green; green.setRgb(0, 156, 0); QPen pen(green, 1, Qt::SolidLine); QPainter painter(this); painter.setPen(pen); painter.drawEllipse(0, 0, width() - 1 , height() - 1); const int r = width() / 2; const float dx = r * sin(manipulator_yaw * M_PI / 180.0f); const float dy = r * cos(manipulator_yaw * M_PI / 180.0f); painter.drawLine(width() /2, height() /2, width() /2 - dx, height() /2 - dy); } void Manipulator::setProperties(const EntityProperties *properties) { manipulator_yaw = properties->yaw(); } } // namespace editor