Changed: #1302 The value angle can save in file.

--HG--
branch : gsoc2011-worldeditorqt
This commit is contained in:
dnk-88 2011-08-18 01:37:39 +03:00
parent adbcdcd9f0
commit eb3c9d2b90
4 changed files with 14 additions and 4 deletions

View file

@ -93,7 +93,7 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode
qreal radius = 0; qreal radius = 0;
if (primitive->getPropertyByName ("radius", strRadius)) if (primitive->getPropertyByName ("radius", strRadius))
radius = atof(strRadius.c_str()); radius = atof(strRadius.c_str());
qreal angle = ((2 * NLMISC::Pi - primPoint->Angle) * 180 / NLMISC::Pi);
item = scene->addWorldItemPoint(QPointF(vec->x, -vec->y + cellSize), item = scene->addWorldItemPoint(QPointF(vec->x, -vec->y + cellSize),
primPoint->Angle, radius, showArrow); primPoint->Angle, radius, showArrow);
break; break;
@ -511,8 +511,11 @@ void AbstractWorldItemCommand::updatePrimitiveData(AbstractWorldItem *item)
{ {
case NLLIGO::CPrimitiveClass::Point: case NLLIGO::CPrimitiveClass::Point:
{ {
qreal angle = static_cast<WorldItemPoint *>(item)->angle();
angle = 2 * NLMISC::Pi - (angle * NLMISC::Pi / 180.0);
NLLIGO::CPrimPoint *point = static_cast<NLLIGO::CPrimPoint *>(primitive); NLLIGO::CPrimPoint *point = static_cast<NLLIGO::CPrimPoint *>(primitive);
point->Point = vPoints.front(); point->Point = vPoints.front();
point->Angle = angle;
break; break;
} }
case NLLIGO::CPrimitiveClass::Path: case NLLIGO::CPrimitiveClass::Path:

View file

@ -110,7 +110,7 @@ QString WorldEditorPlugin::name() const
QString WorldEditorPlugin::version() const QString WorldEditorPlugin::version() const
{ {
return "0.0.1"; return "0.1";
} }
QString WorldEditorPlugin::vendor() const QString WorldEditorPlugin::vendor() const

View file

@ -91,7 +91,7 @@ bool AbstractWorldItem::isShapeChanged() const
WorldItemPoint::WorldItemPoint(const QPointF &point, const qreal angle, const qreal radius, WorldItemPoint::WorldItemPoint(const QPointF &point, const qreal angle, const qreal radius,
bool showArrow, QGraphicsItem *parent) bool showArrow, QGraphicsItem *parent)
: AbstractWorldItem(parent), : AbstractWorldItem(parent),
m_angle((2 * NLMISC::Pi - angle) * 180 / NLMISC::Pi), m_angle(angle),
m_radius(radius), m_radius(radius),
m_showArrow(showArrow) m_showArrow(showArrow)
{ {
@ -132,6 +132,11 @@ WorldItemPoint::~WorldItemPoint()
{ {
} }
qreal WorldItemPoint::angle() const
{
return m_angle;
}
void WorldItemPoint::rotateOn(const QPointF &pivot, const qreal deltaAngle) void WorldItemPoint::rotateOn(const QPointF &pivot, const qreal deltaAngle)
{ {
prepareGeometryChange(); prepareGeometryChange();
@ -167,6 +172,7 @@ void WorldItemPoint::scaleOn(const QPointF &pivot, const QPointF &factor)
void WorldItemPoint::turnOn(const qreal angle) void WorldItemPoint::turnOn(const qreal angle)
{ {
m_angle += angle; m_angle += angle;
m_angle -= floor(m_angle / 360) * 360;
update(); update();
} }
@ -873,7 +879,6 @@ void WorldItemSubPoint::scaleOn(const QPointF &pivot, const QPointF &factor)
// TODO // TODO
scaledPolygon.translate(scenePos() - pivot); scaledPolygon.translate(scenePos() - pivot);
//scaledPolygon.translate(-pivot);
QTransform trans; QTransform trans;
trans = trans.scale(factor.x(), factor.y()); trans = trans.scale(factor.x(), factor.y());

View file

@ -113,6 +113,8 @@ public:
bool showArrow, QGraphicsItem *parent = 0); bool showArrow, QGraphicsItem *parent = 0);
virtual ~WorldItemPoint(); virtual ~WorldItemPoint();
qreal angle() const;
virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle);
virtual void scaleOn(const QPointF &pivot, const QPointF &factor); virtual void scaleOn(const QPointF &pivot, const QPointF &factor);
virtual void turnOn(const qreal angle); virtual void turnOn(const qreal angle);