diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/colors_workspace_settings_page.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/colors_workspace_settings_page.ui deleted file mode 100644 index de6e77901..000000000 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/colors_workspace_settings_page.ui +++ /dev/null @@ -1,44 +0,0 @@ - - - WorldEditorSettingsPage - - - - 0 - 0 - 329 - 239 - - - - Form - - - - - - Colors - - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - - - - diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp index 440382b15..780ea47a9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.cpp @@ -52,13 +52,14 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode { NLLIGO::IPrimitive *primitive = node->primitive(); NLLIGO::CPrimVector *vec = 0; - QGraphicsItem *item; + AbstractWorldItem *item = 0; switch (node->primitiveClass()->Type) { case NLLIGO::CPrimitiveClass::Point: { vec = primitive->getPrimVector(); - item = scene->addWorldItemPoint(QPointF(vec->x, -vec->y + cellSize), 0); + NLLIGO::CPrimPoint *primPoint = static_cast(primitive); + item = scene->addWorldItemPoint(QPointF(vec->x, -vec->y + cellSize), primPoint->Angle); break; } case NLLIGO::CPrimitiveClass::Path: @@ -91,12 +92,44 @@ void addNewGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode break; } } + + if (item != 0) + { + // Get color from world_editor_classes.xml + NLMISC::CRGBA color = Utils::ligoConfig()->getPrimitiveColor(*primitive); + + /* + // Configurations (from world_editor_primitive_configuration.xml) + const std::vector &configurations = Utils::ligoConfig()->getPrimitiveConfiguration(); + + // Look for the configuration + sint search = 0; + bool colorFound = false; + while ((search = theApp.getActiveConfiguration (*primitive, search)) != -1) + { + // Configuration activated ? + if (theApp.Configurations[search].Activated) + { + colorFound = true; + mainColor = configurations[search].Color; + break; + } + search++; + } + + // try to get the primitive color ? + //if (!colorFound)*/ + primitive->getPropertyByName ("Color", color); + + item->setColor(QColor(color.R, color.G, color.B)); + } + QVariant variantNode; variantNode.setValue(node); item->setData(Constants::WORLD_EDITOR_NODE, variantNode); QVariant graphicsData; - graphicsData.setValue(item); + graphicsData.setValue(item); node->setData(Constants::GRAPHICS_DATA_QT4_2D, graphicsData); } @@ -119,7 +152,7 @@ void removeGraphicsItems(const QModelIndex &primIndex, PrimitivesTreeModel *mode case NLLIGO::CPrimitiveClass::Path: case NLLIGO::CPrimitiveClass::Zone: { - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); if (item != 0) scene->removeWorldItem(item); break; @@ -363,8 +396,8 @@ void MoveWorldItemsCommand::undo() for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - qgraphicsitem_cast(item)->moveOn(-m_offset); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->moveOn(-m_offset); } } @@ -375,14 +408,14 @@ void MoveWorldItemsCommand::redo() for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - qgraphicsitem_cast(item)->moveOn(m_offset); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->moveOn(m_offset); } } m_firstRun = false; } -RotateWorldItemsCommand::RotateWorldItemsCommand(const QList &items, const qreal &angle, +RotateWorldItemsCommand::RotateWorldItemsCommand(const QList &items, const qreal angle, const QPointF &pivot, PrimitivesTreeModel *model, QUndoCommand *parent) : QUndoCommand(parent), m_listPaths(graphicsItemsToPaths(items, model)), @@ -391,7 +424,7 @@ RotateWorldItemsCommand::RotateWorldItemsCommand(const QList &i m_model(model), m_firstRun(true) { - setText("Rotate item(s)"); + setText(QString("Rotate item(s) %1").arg(m_angle)); } RotateWorldItemsCommand::~RotateWorldItemsCommand() @@ -403,8 +436,8 @@ void RotateWorldItemsCommand::undo() for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - qgraphicsitem_cast(item)->rotateOn(m_pivot, -m_angle); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->rotateOn(m_pivot, -m_angle); } } @@ -415,8 +448,8 @@ void RotateWorldItemsCommand::redo() for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - qgraphicsitem_cast(item)->rotateOn(m_pivot, m_angle); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->rotateOn(m_pivot, m_angle); } } m_firstRun = false; @@ -444,8 +477,8 @@ void ScaleWorldItemsCommand::undo() for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - qgraphicsitem_cast(item)->scaleOn(m_pivot, m_invertFactor); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->scaleOn(m_pivot, m_invertFactor); } } @@ -456,8 +489,47 @@ void ScaleWorldItemsCommand::redo() for (int i = 0; i < m_listPaths.count(); ++i) { Node *node = m_model->pathToNode(m_listPaths.at(i)); - QGraphicsItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); - qgraphicsitem_cast(item)->scaleOn(m_pivot, m_factor); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->scaleOn(m_pivot, m_factor); + } + } + m_firstRun = false; +} + +TurnWorldItemsCommand::TurnWorldItemsCommand(const QList &items, const qreal angle, + PrimitivesTreeModel *model, QUndoCommand *parent) + : QUndoCommand(parent), + m_listPaths(graphicsItemsToPaths(items, model)), + m_angle(angle), + m_model(model), + m_firstRun(true) +{ + setText(QString("Turn item(s) %1").arg(m_angle)); +} + +TurnWorldItemsCommand::~TurnWorldItemsCommand() +{ +} + +void TurnWorldItemsCommand::undo() +{ + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->turnOn(-m_angle); + } +} + +void TurnWorldItemsCommand::redo() +{ + if (!m_firstRun) + { + for (int i = 0; i < m_listPaths.count(); ++i) + { + Node *node = m_model->pathToNode(m_listPaths.at(i)); + AbstractWorldItem *item = qvariant_cast(node->data(Constants::GRAPHICS_DATA_QT4_2D)); + item->turnOn(m_angle); } } m_firstRun = false; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h index 7fd2015e0..2eda788b4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_actions.h @@ -172,7 +172,7 @@ private: class RotateWorldItemsCommand: public QUndoCommand { public: - RotateWorldItemsCommand(const QList &items, const qreal &angle, + RotateWorldItemsCommand(const QList &items, const qreal angle, const QPointF &pivot, PrimitivesTreeModel *model, QUndoCommand *parent = 0); virtual ~RotateWorldItemsCommand(); @@ -210,6 +210,29 @@ private: bool m_firstRun; }; +/** +@class TurnWorldItemsCommand +@brief +@details +*/ +class TurnWorldItemsCommand: public QUndoCommand +{ +public: + TurnWorldItemsCommand(const QList &items, const qreal angle, + PrimitivesTreeModel *model, QUndoCommand *parent = 0); + virtual ~TurnWorldItemsCommand(); + + virtual void undo(); + virtual void redo(); +private: + + const QList m_listPaths; + const qreal m_angle; + PrimitivesTreeModel *const m_model; + bool m_firstRun; +}; + + } /* namespace WorldEditor */ #endif // WORLD_EDITOR_ACTIONS_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp index 051d403ea..8699bfb67 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_plugin.cpp @@ -77,8 +77,8 @@ bool WorldEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManage // Reset m_ligoConfig.resetPrimitiveConfiguration (); - // Load - m_ligoConfig.readPrimitiveClass ("world_editor_primitive_configuration.xml", true); + // TODO: get file names! from settings + m_ligoConfig.readPrimitiveClass("world_editor_primitive_configuration.xml", true); addAutoReleasedObject(new WorldEditorContext(this)); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp index 7e2ac9c20..d02c047b1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.cpp @@ -59,21 +59,21 @@ WorldEditorScene::~WorldEditorScene() { } -QGraphicsItem *WorldEditorScene::addWorldItemPoint(const QPointF &point, const float angle) +AbstractWorldItem *WorldEditorScene::addWorldItemPoint(const QPointF &point, const float angle) { WorldItemPoint *item = new WorldItemPoint(point, angle); addItem(item); return item; } -QGraphicsItem *WorldEditorScene::addWorldItemPath(const QPolygonF &polyline) +AbstractWorldItem *WorldEditorScene::addWorldItemPath(const QPolygonF &polyline) { WorldItemPath *item = new WorldItemPath(polyline); addItem(item); return item; } -QGraphicsItem *WorldEditorScene::addWorldItemZone(const QPolygonF &polygon) +AbstractWorldItem *WorldEditorScene::addWorldItemZone(const QPolygonF &polygon) { WorldItemZone *item = new WorldItemZone(polygon); addItem(item); @@ -167,11 +167,16 @@ void WorldEditorScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) break; } case WorldEditorScene::RotateMode: + m_angle = 0; + m_pivot = calcBoundingRect(m_selectedItems).center(); break; case WorldEditorScene::ScaleMode: m_scaleFactor = QPointF(1.0, 1.0); + m_pivot = calcBoundingRect(m_selectedItems).center(); break; case WorldEditorScene::TurnMode: + m_angle = 0; + m_pivot = calcBoundingRect(m_selectedItems).center(); break; case WorldEditorScene::RadiusMode: break; @@ -204,24 +209,21 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) } case WorldEditorScene::RotateMode: { - QPointF pivot = calcBoundingRect(m_selectedItems).center(); - // Caluculate angle between two line - QLineF firstLine(pivot, mouseEvent->lastScenePos()); - QLineF secondLine(pivot, mouseEvent->scenePos()); + QLineF firstLine(m_pivot, mouseEvent->lastScenePos()); + QLineF secondLine(m_pivot, mouseEvent->scenePos()); qreal angle = secondLine.angleTo(firstLine); + m_angle += angle; + Q_FOREACH(QGraphicsItem *item, m_selectedItems) { - qgraphicsitem_cast(item)->rotateOn(pivot, angle); + qgraphicsitem_cast(item)->rotateOn(m_pivot, angle); } break; } case WorldEditorScene::ScaleMode: { - // TODO: perfomance - QPointF pivot = calcBoundingRect(m_selectedItems).center(); - // Calculate scale factor if (offset.x() > 0) offset.setX(1.0 + (offset.x() / 5000)); @@ -238,12 +240,26 @@ void WorldEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) Q_FOREACH(QGraphicsItem *item, m_selectedItems) { - qgraphicsitem_cast(item)->scaleOn(pivot, offset); + qgraphicsitem_cast(item)->scaleOn(m_pivot, offset); } break; } case WorldEditorScene::TurnMode: + { + // Caluculate angle between two line + QLineF firstLine(m_pivot, mouseEvent->lastScenePos()); + QLineF secondLine(m_pivot, mouseEvent->scenePos()); + qreal angle = secondLine.angleTo(firstLine); + + m_angle += angle; + + Q_FOREACH(QGraphicsItem *item, m_selectedItems) + { + qgraphicsitem_cast(item)->turnOn(angle); + } + break; + } case WorldEditorScene::RadiusMode: break; }; @@ -276,30 +292,17 @@ void WorldEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) case WorldEditorScene::MoveMode: { QPointF offset = mouseEvent->scenePos() - m_firstPick; - m_undoStack->push(new MoveWorldItemsCommand(m_selectedItems, offset, m_model)); break; } case WorldEditorScene::RotateMode: - { - QPointF pivot = calcBoundingRect(m_selectedItems).center(); - - // Caluculate angle between two line - QLineF firstLine(pivot, m_firstPick); - QLineF secondLine(pivot, mouseEvent->scenePos()); - qreal angle = secondLine.angleTo(firstLine); - - m_undoStack->push(new RotateWorldItemsCommand(m_selectedItems, angle, pivot, m_model)); + m_undoStack->push(new RotateWorldItemsCommand(m_selectedItems, m_angle, m_pivot, m_model)); break; - } case WorldEditorScene::ScaleMode: - { - QPointF pivot = calcBoundingRect(m_selectedItems).center(); - m_undoStack->push(new ScaleWorldItemsCommand(m_selectedItems, m_scaleFactor, pivot, m_model)); - + m_undoStack->push(new ScaleWorldItemsCommand(m_selectedItems, m_scaleFactor, m_pivot, m_model)); break; - } case WorldEditorScene::TurnMode: + m_undoStack->push(new TurnWorldItemsCommand(m_selectedItems, m_angle, m_model)); break; case WorldEditorScene::RadiusMode: break; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h index aa813c5c5..265067469 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene.h @@ -30,6 +30,7 @@ namespace WorldEditor { class PrimitivesTreeModel; +class AbstractWorldItem; /* @class WorldEditorScene @@ -55,9 +56,9 @@ public: QUndoStack *undoStack, QObject *parent = 0); virtual ~WorldEditorScene(); - QGraphicsItem *addWorldItemPoint(const QPointF &point, const float angle); - QGraphicsItem *addWorldItemPath(const QPolygonF &polyline); - QGraphicsItem *addWorldItemZone(const QPolygonF &polygon); + AbstractWorldItem *addWorldItemPoint(const QPointF &point, const float angle); + AbstractWorldItem *addWorldItemPath(const QPolygonF &polyline); + AbstractWorldItem *addWorldItemZone(const QPolygonF &polygon); void removeWorldItem(QGraphicsItem *item); @@ -87,9 +88,9 @@ private: QPen m_pen1, m_pen2; QBrush m_brush1, m_brush2; - QPointF m_firstPick, m_scaleFactor; + QPointF m_firstPick, m_scaleFactor, m_pivot; QRectF m_selectionArea; - qreal m_firstPickX, m_firstPickY; + qreal m_firstPickX, m_firstPickY, m_angle; QList m_selectedItems; bool m_editedSelectedItems, m_firstSelection; uint m_lastPickedPrimitive; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp index 31f63dc05..249ad15e3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.cpp @@ -322,9 +322,9 @@ int AbstractWorldItem::type() const return Type; } -WorldItemPoint::WorldItemPoint(const QPointF &point, const float angle, QGraphicsItem *parent) +WorldItemPoint::WorldItemPoint(const QPointF &point, const qreal angle, QGraphicsItem *parent) : AbstractWorldItem(parent), - m_angle(angle) + m_angle((2 * NLMISC::Pi - angle) * 180 / NLMISC::Pi) { setZValue(WORLD_POINT_LAYER); @@ -343,7 +343,7 @@ WorldItemPoint::WorldItemPoint(const QPointF &point, const float angle, QGraphic m_brush.setColor(QColor(255, 100, 10)); m_brush.setStyle(Qt::SolidPattern); - m_selectedBrush.setColor(QColor(0, 255, 0)); + m_selectedBrush.setColor(Qt::NoPen); m_selectedBrush.setStyle(Qt::SolidPattern); //setFlag(ItemIsSelectable); @@ -396,14 +396,21 @@ void WorldItemPoint::scaleOn(const QPointF &pivot, const QPointF &factor) setPos(scaledPolygon.boundingRect().center()); } -void WorldItemPoint::turnOn(const QPointF &offset) +void WorldItemPoint::turnOn(const qreal angle) { + m_angle += angle; + update(); } void WorldItemPoint::radiusOn(const qreal radius) { } +void WorldItemPoint::setColor(const QColor &color) +{ + m_brush.setColor(color); +} + QPainterPath WorldItemPoint::shape() const { QPainterPath path; @@ -435,6 +442,14 @@ void WorldItemPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *op } painter->drawRect(m_rect); + + painter->setPen(Qt::red); + + painter->rotate(m_angle); + + painter->drawLine(0, 0, SIZE_ARROW, 0); + painter->drawLine(SIZE_ARROW - 2, -2, SIZE_ARROW, 0); + painter->drawLine(SIZE_ARROW - 2, 2, SIZE_ARROW, 0); } QVariant WorldItemPoint::itemChange(GraphicsItemChange change, const QVariant &value) @@ -453,10 +468,10 @@ WorldItemPath::WorldItemPath(const QPolygonF &polygon, QGraphicsItem *parent) setZValue(WORLD_PATH_LAYER); - m_pen.setColor(QColor(0, 0, 0)); + m_pen.setColor(Qt::black); m_pen.setWidth(5); - m_selectedPen.setColor(QColor(255, 0, 0)); + m_selectedPen.setColor(Qt::white); m_selectedPen.setWidth(5); } @@ -499,7 +514,7 @@ void WorldItemPath::scaleOn(const QPointF &pivot, const QPointF &factor) m_polygon.translate(pivot); } -void WorldItemPath::turnOn(const QPointF &offset) +void WorldItemPath::turnOn(const qreal angle) { } @@ -507,6 +522,11 @@ void WorldItemPath::radiusOn(const qreal radius) { } +void WorldItemPath::setColor(const QColor &color) +{ + m_pen.setColor(color); +} + QPainterPath WorldItemPath::shape() const { QPainterPath path; @@ -555,13 +575,13 @@ WorldItemZone::WorldItemZone(const QPolygonF &polygon, QGraphicsItem *parent) m_pen.setColor(QColor(20, 100, 255)); m_pen.setWidth(0); - m_selectedPen.setColor(QColor(255, 0, 0)); + m_selectedPen.setColor(Qt::white); m_selectedPen.setWidth(0); - m_brush.setColor(QColor(20, 100, 255, 28)); + m_brush.setColor(QColor(20, 100, 255, TRANSPARENCY)); m_brush.setStyle(Qt::SolidPattern); - m_selectedBrush.setColor(QColor(255, 0, 0, 128)); + m_selectedBrush.setColor(QColor(255, 255, 255, 100)); m_selectedBrush.setStyle(Qt::SolidPattern); } @@ -604,7 +624,7 @@ void WorldItemZone::scaleOn(const QPointF &pivot, const QPointF &factor) m_polygon.translate(pivot); } -void WorldItemZone::turnOn(const QPointF &offset) +void WorldItemZone::turnOn(const qreal angle) { } @@ -612,6 +632,16 @@ void WorldItemZone::radiusOn(const qreal radius) { } +void WorldItemZone::setColor(const QColor &color) +{ + m_pen.setColor(color); + + QColor brushColor(color); + brushColor.setAlpha(TRANSPARENCY); + + m_brush.setColor(brushColor); +} + QRectF WorldItemZone::boundingRect() const { return m_polygon.boundingRect(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h index 6f1669786..cdc9691b4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_scene_item.h @@ -45,6 +45,7 @@ const int WORLD_PATH_LAYER = 200; const int MIDDLE_POINT_LAYER = 201; const int EDGE_POINT_LAYER = 201; +const int SIZE_ARROW = 20; /* // Deprecated class GraphicsItemNode: public QGraphicsObject @@ -132,9 +133,11 @@ public: virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle) = 0; // TODO: add modes: IgnoreAspectRatio, KeepAspectRatio virtual void scaleOn(const QPointF &pivot, const QPointF &factor) = 0; - virtual void turnOn(const QPointF &offset) = 0; + virtual void turnOn(const qreal angle) = 0; virtual void radiusOn(const qreal radius) = 0; + virtual void setColor(const QColor &color) = 0; + // Enable the use of qgraphicsitem_cast with this item. int type() const; }; @@ -147,15 +150,17 @@ public: class WorldItemPoint: public AbstractWorldItem { public: - WorldItemPoint(const QPointF &point, const float angle, QGraphicsItem *parent = 0); + WorldItemPoint(const QPointF &point, const qreal angle, QGraphicsItem *parent = 0); virtual ~WorldItemPoint(); virtual void moveOn(const QPointF &offset); virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); virtual void scaleOn(const QPointF &pivot, const QPointF &factor); - virtual void turnOn(const QPointF &offset); + virtual void turnOn(const qreal angle); virtual void radiusOn(const qreal radius); + virtual void setColor(const QColor &color); + virtual QRectF boundingRect() const; virtual QPainterPath shape() const; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); @@ -166,13 +171,13 @@ protected: private: // TODO - static const int SIZE_POINT = 7; + static const int SIZE_POINT = 4; QPen m_pen, m_selectedPen; QBrush m_brush, m_selectedBrush; QRectF m_rect; - float m_angle; + qreal m_angle; }; /* @@ -189,9 +194,11 @@ public: virtual void moveOn(const QPointF &offset); virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); virtual void scaleOn(const QPointF &pivot, const QPointF &factor); - virtual void turnOn(const QPointF &offset); + virtual void turnOn(const qreal angle); virtual void radiusOn(const qreal radius); + virtual void setColor(const QColor &color); + virtual QRectF boundingRect() const; virtual QPainterPath shape() const; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); @@ -217,9 +224,11 @@ public: virtual void moveOn(const QPointF &offset); virtual void rotateOn(const QPointF &pivot, const qreal deltaAngle); virtual void scaleOn(const QPointF &pivot, const QPointF &factor); - virtual void turnOn(const QPointF &offset); + virtual void turnOn(const qreal angle); virtual void radiusOn(const qreal radius); + virtual void setColor(const QColor &color); + virtual QRectF boundingRect() const; virtual QPainterPath shape() const; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); @@ -227,6 +236,8 @@ public: protected: virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); + static const int TRANSPARENCY = 28; + QPen m_pen, m_selectedPen; QBrush m_brush, m_selectedBrush; QPolygonF m_polygon; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui index f5dc5f408..c556514b7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/world_editor/world_editor_window.ui @@ -293,7 +293,7 @@ true - false + true