Commit 557bf7f2 authored by Inge Wallin's avatar Inge Wallin

Separate the base graphicsitems into their own .h and .cc files.

This is the first of a small set of cleanup patches that I want to do because
there were some refactorings necessary in the frameworks branch. And if I do
them there only, it will be very difficult to forward port any bugfixes later.
parent a988f68b
......@@ -11,6 +11,7 @@ set(step_SRCS
undobrowser.cc
itempalette.cc
worldfactory.cc
stepgraphicsitem.cc
particlegraphics.cc
polygongraphics.cc
gasgraphics.cc
......
......@@ -51,7 +51,7 @@ bool GasCreator::sceneEvent(QEvent* event)
if(event->type() == QEvent::GraphicsSceneMousePress && mouseEvent->button() == Qt::LeftButton) {
QPointF pos = mouseEvent->scenePos();
QVariant vpos = QVariant::fromValue(WorldGraphicsItem::pointToVector(pos));
QVariant vpos = QVariant::fromValue(StepGraphicsItem::pointToVector(pos));
_worldModel->simulationPause();
_worldModel->beginMacro(i18n("Create %1", _worldModel->newItemName(_className)));
......@@ -67,7 +67,7 @@ bool GasCreator::sceneEvent(QEvent* event)
_worldModel->setProperty(ljforce, "depth", 0.1);
_worldModel->setProperty(ljforce, "rmin", 0.1);
_topLeft = WorldGraphicsItem::pointToVector(pos);
_topLeft = StepGraphicsItem::pointToVector(pos);
showMessage(MessageFrame::Information,
i18n("Move mouse and release left mouse button to position\nbottom right corner of the region for %1", classNameTr()));
......@@ -77,7 +77,7 @@ bool GasCreator::sceneEvent(QEvent* event)
mouseEvent->buttons() & Qt::LeftButton) {
_worldModel->simulationPause();
StepCore::Vector2d pos = WorldGraphicsItem::pointToVector(mouseEvent->scenePos());
StepCore::Vector2d pos = StepGraphicsItem::pointToVector(mouseEvent->scenePos());
StepCore::Vector2d position = (_topLeft + pos) / 2.0;
StepCore::Vector2d size = _topLeft - pos;
_worldModel->setProperty(_item, "measureRectCenter", QVariant::fromValue(position));
......@@ -88,7 +88,7 @@ bool GasCreator::sceneEvent(QEvent* event)
mouseEvent->button() == Qt::LeftButton) {
_worldModel->simulationPause();
StepCore::Vector2d pos = WorldGraphicsItem::pointToVector(mouseEvent->scenePos());
StepCore::Vector2d pos = StepGraphicsItem::pointToVector(mouseEvent->scenePos());
StepCore::Vector2d position = (_topLeft + pos) / 2.0;
StepCore::Vector2d size = _topLeft - pos;
if(size[0] == 0 && size[1] == 0) { size[0] = size[1] = 1; }
......@@ -176,7 +176,7 @@ void GasVertexHandlerGraphicsItem::setValue(const StepCore::Vector2d& value)
}
GasGraphicsItem::GasGraphicsItem(StepCore::Item* item, WorldModel* worldModel)
: WorldGraphicsItem(item, worldModel)
: StepGraphicsItem(item, worldModel)
{
Q_ASSERT(dynamic_cast<StepCore::Gas*>(_item) != NULL);
setFlag(QGraphicsItem::ItemIsSelectable);
......
......@@ -20,6 +20,7 @@
#define STEP_GASGRAPHICS_H
#include "worldgraphics.h"
#include "stepgraphicsitem.h"
#include <kaction.h>
namespace StepCore {
......@@ -57,7 +58,7 @@ protected:
void setValue(const StepCore::Vector2d& value);
};
class GasGraphicsItem: public WorldGraphicsItem {
class GasGraphicsItem: public StepGraphicsItem {
public:
GasGraphicsItem(StepCore::Item* item, WorldModel* worldModel);
......
......@@ -29,7 +29,7 @@
#include <KLocale>
AnchorGraphicsItem::AnchorGraphicsItem(StepCore::Item* item, WorldModel* worldModel)
: WorldGraphicsItem(item, worldModel)
: StepGraphicsItem(item, worldModel)
{
Q_ASSERT(dynamic_cast<StepCore::Anchor*>(_item) != NULL);
setFlag(QGraphicsItem::ItemIsSelectable);
......@@ -96,7 +96,7 @@ void AnchorGraphicsItem::worldDataChanged(bool dynamicOnly)
//////////////////////////////////////////////////////////////////////////
PinGraphicsItem::PinGraphicsItem(StepCore::Item* item, WorldModel* worldModel)
: WorldGraphicsItem(item, worldModel)
: StepGraphicsItem(item, worldModel)
{
Q_ASSERT(dynamic_cast<StepCore::Pin*>(_item) != NULL);
setFlag(QGraphicsItem::ItemIsSelectable);
......@@ -163,7 +163,7 @@ void PinGraphicsItem::worldDataChanged(bool dynamicOnly)
StickHandlerGraphicsItem::StickHandlerGraphicsItem(StepCore::Item* item, WorldModel* worldModel,
QGraphicsItem* parent, int num)
: WorldGraphicsItem(item, worldModel, parent), _num(num)
: StepGraphicsItem(item, worldModel, parent), _num(num)
{
Q_ASSERT(_num == 1 || _num == 2);
setFlag(QGraphicsItem::ItemIsMovable);
......@@ -200,7 +200,7 @@ void StickHandlerGraphicsItem::mouseSetPos(const QPointF& pos, const QPointF&, M
}
StickGraphicsItem::StickGraphicsItem(StepCore::Item* item, WorldModel* worldModel)
: WorldGraphicsItem(item, worldModel)
: StepGraphicsItem(item, worldModel)
{
Q_ASSERT(dynamic_cast<StepCore::Stick*>(_item) != NULL);
setFlag(QGraphicsItem::ItemIsSelectable);
......@@ -331,7 +331,7 @@ void StickGraphicsItem::mouseSetPos(const QPointF& /*pos*/, const QPointF& diff,
if(stick()->body1()) {
Q_ASSERT(stick()->body1()->metaObject()->inherits<StepCore::Item>());
WorldGraphicsItem* gItem = static_cast<WorldScene*>(
StepGraphicsItem* gItem = static_cast<WorldScene*>(
scene())->graphicsFromItem(static_cast<StepCore::Item*>(stick()->body1()));
Q_ASSERT(gItem != NULL);
if(!gItem->isSelected()) {
......@@ -347,7 +347,7 @@ void StickGraphicsItem::mouseSetPos(const QPointF& /*pos*/, const QPointF& diff,
if(stick()->body2()) {
Q_ASSERT(stick()->body2()->metaObject()->inherits<StepCore::Item>());
WorldGraphicsItem* gItem = static_cast<WorldScene*>(
StepGraphicsItem* gItem = static_cast<WorldScene*>(
scene())->graphicsFromItem(static_cast<StepCore::Item*>(stick()->body2()));
Q_ASSERT(gItem != NULL);
if(!gItem->isSelected()) {
......
......@@ -20,6 +20,7 @@
#define STEP_JOINTGRAPHICS_H
#include "worldgraphics.h"
#include "stepgraphicsitem.h"
#include <stepcore/joint.h>
class AnchorCreator: public AttachableItemCreator
......@@ -31,7 +32,7 @@ public:
WorldScene::SnapSetPosition | WorldScene::SnapSetAngle, 0) {}
};
class AnchorGraphicsItem: public WorldGraphicsItem
class AnchorGraphicsItem : public StepGraphicsItem
{
public:
AnchorGraphicsItem(StepCore::Item* item, WorldModel* worldModel);
......@@ -57,7 +58,7 @@ public:
WorldScene::SnapSetPosition | WorldScene::SnapSetLocalPosition, 0) {}
};
class PinGraphicsItem: public WorldGraphicsItem
class PinGraphicsItem: public StepGraphicsItem
{
public:
PinGraphicsItem(StepCore::Item* item, WorldModel* worldModel);
......@@ -84,7 +85,7 @@ public:
WorldScene::SnapSetLocalPosition, 0, true) {}
};
class StickHandlerGraphicsItem: public WorldGraphicsItem
class StickHandlerGraphicsItem: public StepGraphicsItem
{
public:
StickHandlerGraphicsItem(StepCore::Item* item, WorldModel* worldModel,
......@@ -97,7 +98,7 @@ protected:
int _num;
};
class StickGraphicsItem: public WorldGraphicsItem
class StickGraphicsItem: public StepGraphicsItem
{
public:
StickGraphicsItem(StepCore::Item* item, WorldModel* worldModel);
......
......@@ -35,7 +35,7 @@ bool LinearMotorCreator::sceneEvent(QEvent* event)
QGraphicsSceneMouseEvent* mouseEvent = static_cast<QGraphicsSceneMouseEvent*>(event);
if(event->type() == QEvent::GraphicsSceneMousePress && mouseEvent->button() == Qt::LeftButton) {
QPointF pos = mouseEvent->scenePos();
QVariant vpos = QVariant::fromValue(WorldGraphicsItem::pointToVector(pos));
QVariant vpos = QVariant::fromValue(StepGraphicsItem::pointToVector(pos));
_worldModel->simulationPause();
_worldModel->beginMacro(i18n("Create %1", _worldModel->newItemName(_className)));
......@@ -65,7 +65,7 @@ void LinearMotorCreator::tryAttach(const QPointF& pos)
StepCore::Vector2d lPos(0, 0);
if(dynamic_cast<StepCore::RigidBody*>(item))
lPos = dynamic_cast<StepCore::RigidBody*>(item)->pointWorldToLocal(WorldGraphicsItem::pointToVector(pos));
lPos = dynamic_cast<StepCore::RigidBody*>(item)->pointWorldToLocal(StepGraphicsItem::pointToVector(pos));
_worldModel->setProperty(_item, "localPosition", QVariant::fromValue(lPos));
break;
......@@ -74,7 +74,7 @@ void LinearMotorCreator::tryAttach(const QPointF& pos)
}
LinearMotorGraphicsItem::LinearMotorGraphicsItem(StepCore::Item* item, WorldModel* worldModel)
: WorldGraphicsItem(item, worldModel), _moving(false)
: StepGraphicsItem(item, worldModel), _moving(false)
{
Q_ASSERT(dynamic_cast<StepCore::LinearMotor*>(_item) != NULL);
setFlag(QGraphicsItem::ItemIsSelectable);
......@@ -132,7 +132,7 @@ void LinearMotorGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
StepCore::Vector2d lPos(0, 0);
if(dynamic_cast<StepCore::RigidBody*>(item))
lPos = dynamic_cast<StepCore::RigidBody*>(item)->pointWorldToLocal(WorldGraphicsItem::pointToVector(pos));
lPos = dynamic_cast<StepCore::RigidBody*>(item)->pointWorldToLocal(StepGraphicsItem::pointToVector(pos));
_worldModel->setProperty(_item, "localPosition", QVariant::fromValue(lPos));
......@@ -142,7 +142,7 @@ void LinearMotorGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
_moving = false;
_worldModel->endMacro();
} else WorldGraphicsItem::mouseReleaseEvent(event);
} else StepGraphicsItem::mouseReleaseEvent(event);
}
......@@ -216,7 +216,7 @@ bool CircularMotorCreator::sceneEvent(QEvent* event)
QGraphicsSceneMouseEvent* mouseEvent = static_cast<QGraphicsSceneMouseEvent*>(event);
if(event->type() == QEvent::GraphicsSceneMousePress && mouseEvent->button() == Qt::LeftButton) {
QPointF pos = mouseEvent->scenePos();
QVariant vpos = QVariant::fromValue(WorldGraphicsItem::pointToVector(pos));
QVariant vpos = QVariant::fromValue(StepGraphicsItem::pointToVector(pos));
_worldModel->simulationPause();
_worldModel->beginMacro(i18n("Create %1", _worldModel->newItemName(_className)));
......@@ -245,7 +245,7 @@ void CircularMotorCreator::tryAttach(const QPointF& pos)
QVariant::fromValue<StepCore::Object*>(item), WorldModel::UndoNoMerge);
StepCore::Vector2d lPos(0, 0);
lPos = dynamic_cast<StepCore::RigidBody*>(item)->pointWorldToLocal(WorldGraphicsItem::pointToVector(pos));
lPos = dynamic_cast<StepCore::RigidBody*>(item)->pointWorldToLocal(StepGraphicsItem::pointToVector(pos));
_worldModel->setProperty(_item, "localPosition", QVariant::fromValue(lPos));
break;
}
......@@ -253,7 +253,7 @@ void CircularMotorCreator::tryAttach(const QPointF& pos)
}
CircularMotorGraphicsItem::CircularMotorGraphicsItem(StepCore::Item* item, WorldModel* worldModel)
: WorldGraphicsItem(item, worldModel), _moving(false)
: StepGraphicsItem(item, worldModel), _moving(false)
{
Q_ASSERT(dynamic_cast<StepCore::CircularMotor*>(_item) != NULL);
setFlag(QGraphicsItem::ItemIsSelectable);
......@@ -310,7 +310,7 @@ void CircularMotorGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *even
StepCore::Vector2d lPos(0, 0);
if(dynamic_cast<StepCore::RigidBody*>(item))
lPos = dynamic_cast<StepCore::RigidBody*>(item)->pointWorldToLocal(WorldGraphicsItem::pointToVector(pos));
lPos = dynamic_cast<StepCore::RigidBody*>(item)->pointWorldToLocal(StepGraphicsItem::pointToVector(pos));
_worldModel->setProperty(_item, "localPosition", QVariant::fromValue(lPos));
......@@ -320,7 +320,7 @@ void CircularMotorGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *even
_moving = false;
_worldModel->endMacro();
} else WorldGraphicsItem::mouseReleaseEvent(event);
} else StepGraphicsItem::mouseReleaseEvent(event);
}
......
......@@ -19,6 +19,7 @@
#define STEP_MOTORGRAPHICS_H
#include "worldgraphics.h"
#include "stepgraphicsitem.h"
#include <QGraphicsTextItem>
#include <QAbstractItemModel>
#include <QWidget>
......@@ -48,7 +49,7 @@ protected:
void tryAttach(const QPointF& pos);
};
class LinearMotorGraphicsItem: public WorldGraphicsItem
class LinearMotorGraphicsItem: public StepGraphicsItem
{
public:
LinearMotorGraphicsItem(StepCore::Item* item, WorldModel* worldModel);
......@@ -83,7 +84,7 @@ protected:
void tryAttach(const QPointF& pos);
};
class CircularMotorGraphicsItem: public WorldGraphicsItem
class CircularMotorGraphicsItem: public StepGraphicsItem
{
public:
CircularMotorGraphicsItem(StepCore::Item* item, WorldModel* worldModel);
......
......@@ -29,7 +29,7 @@
#include <KLocale>
ParticleGraphicsItem::ParticleGraphicsItem(StepCore::Item* item, WorldModel* worldModel)
: WorldGraphicsItem(item, worldModel)
: StepGraphicsItem(item, worldModel)
{
Q_ASSERT(dynamic_cast<StepCore::Particle*>(_item) != NULL);
setFlag(QGraphicsItem::ItemIsSelectable);
......
......@@ -20,9 +20,11 @@
#define STEP_PARTICLEGRAPHICS_H
#include "worldgraphics.h"
#include "stepgraphicsitem.h"
#include <stepcore/particle.h>
class ParticleGraphicsItem: public WorldGraphicsItem {
class ParticleGraphicsItem: public StepGraphicsItem {
public:
ParticleGraphicsItem(StepCore::Item* item, WorldModel* worldModel);
......
......@@ -35,7 +35,7 @@
#include <KDebug>
RigidBodyGraphicsItem::RigidBodyGraphicsItem(StepCore::Item* item, WorldModel* worldModel)
: WorldGraphicsItem(item, worldModel)
: StepGraphicsItem(item, worldModel)
{
Q_ASSERT(dynamic_cast<StepCore::RigidBody*>(_item) != NULL);
setFlag(QGraphicsItem::ItemIsSelectable);
......@@ -156,7 +156,7 @@ bool DiskCreator::sceneEvent(QEvent* event)
if(event->type() == QEvent::GraphicsSceneMousePress && mouseEvent->button() == Qt::LeftButton) {
QPointF pos = mouseEvent->scenePos();
QVariant vpos = QVariant::fromValue(WorldGraphicsItem::pointToVector(pos));
QVariant vpos = QVariant::fromValue(StepGraphicsItem::pointToVector(pos));
_worldModel->simulationPause();
_worldModel->beginMacro(i18n("Create %1", _worldModel->newItemName(_className)));
......@@ -175,7 +175,7 @@ bool DiskCreator::sceneEvent(QEvent* event)
mouseEvent->buttons() & Qt::LeftButton) {
_worldModel->simulationPause();
StepCore::Vector2d pos = WorldGraphicsItem::pointToVector(mouseEvent->scenePos());
StepCore::Vector2d pos = StepGraphicsItem::pointToVector(mouseEvent->scenePos());
double radius = (pos - static_cast<StepCore::Disk*>(_item)->position()).norm();
_worldModel->setProperty(_item, "radius", QVariant::fromValue(radius));
return true;
......@@ -184,7 +184,7 @@ bool DiskCreator::sceneEvent(QEvent* event)
mouseEvent->button() == Qt::LeftButton) {
_worldModel->simulationPause();
StepCore::Vector2d pos = WorldGraphicsItem::pointToVector(mouseEvent->scenePos());
StepCore::Vector2d pos = StepGraphicsItem::pointToVector(mouseEvent->scenePos());
StepCore::Disk* disk = static_cast<StepCore::Disk*>(_item);
double radius = (pos - disk->position()).norm();
if(radius == 0) radius = 0.5;
......@@ -281,7 +281,7 @@ bool BoxCreator::sceneEvent(QEvent* event)
if(event->type() == QEvent::GraphicsSceneMousePress && mouseEvent->button() == Qt::LeftButton) {
QPointF pos = mouseEvent->scenePos();
QVariant vpos = QVariant::fromValue(WorldGraphicsItem::pointToVector(pos));
QVariant vpos = QVariant::fromValue(StepGraphicsItem::pointToVector(pos));
_worldModel->simulationPause();
_worldModel->beginMacro(i18n("Create %1", _worldModel->newItemName(_className)));
......@@ -291,7 +291,7 @@ bool BoxCreator::sceneEvent(QEvent* event)
_worldModel->addItem(_item);
_worldModel->selectionModel()->setCurrentIndex(_worldModel->objectIndex(_item),
QItemSelectionModel::ClearAndSelect);
_topLeft = WorldGraphicsItem::pointToVector(pos);
_topLeft = StepGraphicsItem::pointToVector(pos);
showMessage(MessageFrame::Information,
i18n("Move mouse and release left mouse button to position\nbottom right corner of the %1", classNameTr()));
......@@ -301,7 +301,7 @@ bool BoxCreator::sceneEvent(QEvent* event)
mouseEvent->buttons() & Qt::LeftButton) {
_worldModel->simulationPause();
StepCore::Vector2d pos = WorldGraphicsItem::pointToVector(mouseEvent->scenePos());
StepCore::Vector2d pos = StepGraphicsItem::pointToVector(mouseEvent->scenePos());
StepCore::Vector2d position = (_topLeft + pos) / 2.0;
StepCore::Vector2d size = _topLeft - pos;
_worldModel->setProperty(_item, "position", QVariant::fromValue(position));
......@@ -312,7 +312,7 @@ bool BoxCreator::sceneEvent(QEvent* event)
mouseEvent->button() == Qt::LeftButton) {
_worldModel->simulationPause();
StepCore::Vector2d pos = WorldGraphicsItem::pointToVector(mouseEvent->scenePos());
StepCore::Vector2d pos = StepGraphicsItem::pointToVector(mouseEvent->scenePos());
StepCore::Box* box = static_cast<StepCore::Box*>(_item);
StepCore::Vector2d position = (_topLeft + pos) / 2.0;
StepCore::Vector2d size = _topLeft - pos;
......@@ -426,7 +426,7 @@ bool PolygonCreator::sceneEvent(QEvent* event)
if(!_item && event->type() == QEvent::GraphicsSceneMousePress && mouseEvent->button() == Qt::LeftButton) {
QPointF pos = mouseEvent->scenePos();
QVariant vpos = QVariant::fromValue(WorldGraphicsItem::pointToVector(pos));
QVariant vpos = QVariant::fromValue(StepGraphicsItem::pointToVector(pos));
_worldModel->simulationPause();
_worldModel->beginMacro(i18n("Create %1", _worldModel->newItemName(_className)));
......@@ -447,7 +447,7 @@ bool PolygonCreator::sceneEvent(QEvent* event)
mouseEvent->button() == Qt::LeftButton))) {
QPointF pos = mouseEvent->scenePos();
StepCore::Vector2d v = WorldGraphicsItem::pointToVector(pos);
StepCore::Vector2d v = StepGraphicsItem::pointToVector(pos);
_worldModel->simulationPause();
// XXX: don't use strings !
......
......@@ -24,6 +24,8 @@
*/
#include "worldgraphics.h"
#include "stepgraphicsitem.h"
#include <QPainterPath>
#include <QPointer>
......@@ -37,7 +39,7 @@ namespace StepCore {
/////////////////////////////////////////////////////////////////////////////////////////
class RigidBodyGraphicsItem: public WorldGraphicsItem
class RigidBodyGraphicsItem : public StepGraphicsItem
{
public:
RigidBodyGraphicsItem(StepCore::Item* item, WorldModel* worldModel);
......
......@@ -51,7 +51,7 @@ bool SoftBodyCreator::sceneEvent(QEvent* event)
if (event->type() == QEvent::GraphicsSceneMousePress &&
mouseEvent->button() == Qt::LeftButton) {
QPointF pos = mouseEvent->scenePos();
StepCore::Vector2d position = WorldGraphicsItem::pointToVector(pos);
StepCore::Vector2d position = StepGraphicsItem::pointToVector(pos);
_worldModel->simulationPause();
_worldModel->beginMacro(i18n("Create %1",
......@@ -189,7 +189,7 @@ void SoftBodyMenuHandler::createSoftBodyItemsApply()
/////////////////////////////////////////////////
SoftBodyGraphicsItem::SoftBodyGraphicsItem(StepCore::Item* item, WorldModel* worldModel)
: WorldGraphicsItem(item, worldModel)
: StepGraphicsItem(item, worldModel)
{
Q_ASSERT(dynamic_cast<StepCore::SoftBody*>(_item) != NULL);
setFlag(QGraphicsItem::ItemIsSelectable);
......
......@@ -72,7 +72,7 @@ protected:
// bool _confChanged;
};
class SoftBodyGraphicsItem: public WorldGraphicsItem
class SoftBodyGraphicsItem: public StepGraphicsItem
{
public:
SoftBodyGraphicsItem(StepCore::Item* item, WorldModel* worldModel);
......
......@@ -33,7 +33,7 @@
SpringHandlerGraphicsItem::SpringHandlerGraphicsItem(StepCore::Item* item, WorldModel* worldModel,
QGraphicsItem* parent, int num)
: WorldGraphicsItem(item, worldModel, parent), _num(num)
: StepGraphicsItem(item, worldModel, parent), _num(num)
{
Q_ASSERT(_num == 1 || _num == 2);
setFlag(QGraphicsItem::ItemIsMovable);
......@@ -66,7 +66,7 @@ void SpringHandlerGraphicsItem::mouseSetPos(const QPointF& pos, const QPointF&,
}
SpringGraphicsItem::SpringGraphicsItem(StepCore::Item* item, WorldModel* worldModel)
: WorldGraphicsItem(item, worldModel)
: StepGraphicsItem(item, worldModel)
{
Q_ASSERT(dynamic_cast<StepCore::Spring*>(_item) != NULL);
setFlag(QGraphicsItem::ItemIsSelectable);
......@@ -205,7 +205,7 @@ void SpringGraphicsItem::mouseSetPos(const QPointF& /*pos*/, const QPointF& diff
if(spring()->body1()) {
Q_ASSERT(spring()->body1()->metaObject()->inherits<StepCore::Item>());
WorldGraphicsItem* gItem = static_cast<WorldScene*>(
StepGraphicsItem* gItem = static_cast<WorldScene*>(
scene())->graphicsFromItem(static_cast<StepCore::Item*>(spring()->body1()));
Q_ASSERT(gItem != NULL);
if(!gItem->isSelected()) {
......@@ -221,7 +221,7 @@ void SpringGraphicsItem::mouseSetPos(const QPointF& /*pos*/, const QPointF& diff
if(spring()->body2()) {
Q_ASSERT(spring()->body2()->metaObject()->inherits<StepCore::Item>());
WorldGraphicsItem* gItem = static_cast<WorldScene*>(
StepGraphicsItem* gItem = static_cast<WorldScene*>(
scene())->graphicsFromItem(static_cast<StepCore::Item*>(spring()->body2()));
Q_ASSERT(gItem != NULL);
if(!gItem->isSelected()) {
......
......@@ -20,6 +20,7 @@
#define STEP_SPRINGGRAPHICS_H
#include "worldgraphics.h"
#include "stepgraphicsitem.h"
#include <stepcore/spring.h>
class SpringCreator: public AttachableItemCreator
......@@ -31,7 +32,7 @@ public:
WorldScene::SnapSetLocalPosition, 0, true) {}
};
class SpringHandlerGraphicsItem: public WorldGraphicsItem {
class SpringHandlerGraphicsItem : public StepGraphicsItem {
public:
SpringHandlerGraphicsItem(StepCore::Item* item, WorldModel* worldModel,
QGraphicsItem* parent, int num);
......@@ -44,7 +45,7 @@ protected:
int _num;
};
class SpringGraphicsItem: public WorldGraphicsItem {
class SpringGraphicsItem: public StepGraphicsItem {
public:
SpringGraphicsItem(StepCore::Item* item, WorldModel* worldModel);
......
This diff is collapsed.
This diff is collapsed.
......@@ -121,7 +121,7 @@ void WidgetVertexHandlerGraphicsItem::setValue(const StepCore::Vector2d& value)
}
WidgetGraphicsItem::WidgetGraphicsItem(StepCore::Item* item, WorldModel* worldModel)
: WorldGraphicsItem(item, worldModel), _centralWidget(0)
: StepGraphicsItem(item, worldModel), _centralWidget(0)
{
setFlag(QGraphicsItem::ItemIsSelectable);
setFlag(QGraphicsItem::ItemIsMovable);
......@@ -1717,7 +1717,7 @@ void ControllerMenuHandler::incTriggered()
////////////////////////////////////////////////////
TracerGraphicsItem::TracerGraphicsItem(StepCore::Item* item, WorldModel* worldModel)
: WorldGraphicsItem(item, worldModel), _moving(false), _movingDelta(0,0)
: StepGraphicsItem(item, worldModel), _moving(false), _movingDelta(0,0)
{
Q_ASSERT(dynamic_cast<StepCore::Tracer*>(_item) != NULL);
setFlag(QGraphicsItem::ItemIsSelectable);
......
......@@ -20,6 +20,7 @@
#define STEP_TOOLGRAPHICS_H
#include "worldgraphics.h"
#include "stepgraphicsitem.h"
#include <QGraphicsTextItem>
#include <QAbstractItemModel>
#include <QWidget>
......@@ -69,7 +70,7 @@ protected:
StepCore::Vector2d value();
};
class WidgetGraphicsItem: public QObject, public WorldGraphicsItem
class WidgetGraphicsItem: public QObject, public StepGraphicsItem
{
Q_OBJECT
......@@ -375,7 +376,7 @@ public:
WorldScene::SnapSetLocalPosition, 0) {}
};
class TracerGraphicsItem: public WorldGraphicsItem
class TracerGraphicsItem: public StepGraphicsItem
{
public:
TracerGraphicsItem(StepCore::Item* item, WorldModel* worldModel);
......
......@@ -58,7 +58,7 @@ ItemCreator* newItemCreatorHelper(const QString& className,
}
template<typename T>
WorldGraphicsItem* newGraphicsItemHelper(StepCore::Item* item, WorldModel* worldModel)
StepGraphicsItem* newGraphicsItemHelper(StepCore::Item* item, WorldModel* worldModel)
{
return new T(item, worldModel);
}
......@@ -225,7 +225,7 @@ ItemCreator* WorldFactory::newItemCreator(const QString& className,
else return new ItemCreator(className, worldModel, worldScene);
}
WorldGraphicsItem* WorldFactory::newGraphicsItem(StepCore::Item* item, WorldModel* worldModel) const
StepGraphicsItem* WorldFactory::newGraphicsItem(StepCore::Item* item, WorldModel* worldModel) const
{
const ExtMetaObject *extMetaObject = _extMetaObjects.value(item->metaObject(), NULL);
if(extMetaObject && extMetaObject->newGraphicsItem)
......
......@@ -25,7 +25,7 @@ class QGraphicsItem;
class QGraphicsScene;
class WorldModel;
class WorldScene;
class WorldGraphicsItem;
class StepGraphicsItem;
class ItemCreator;
class ItemMenuHandler;
class KIcon;
......@@ -38,7 +38,7 @@ struct ExtMetaObject
{
ItemCreator* (*newItemCreator)(const QString& className,
WorldModel* worldModel, WorldScene* worldScene);
WorldGraphicsItem* (*newGraphicsItem)(StepCore::Item*, WorldModel*);
StepGraphicsItem* (*newGraphicsItem)(StepCore::Item*, WorldModel*);
ItemMenuHandler* (*newItemMenuHandler)(StepCore::Object*, WorldModel*, QObject*);
bool hasIcon;
......@@ -65,8 +65,8 @@ public:
ItemCreator* newItemCreator(const QString& className,
WorldModel* worldModel, WorldScene* worldScene) const;
/** Create WorldGraphicsItem for given item */
WorldGraphicsItem* newGraphicsItem(StepCore::Item* item, WorldModel* worldModel) const;
/** Create StepGraphicsItem for given item */
StepGraphicsItem *newGraphicsItem(StepCore::Item* item, WorldModel* worldModel) const;
/** Create ItemMenuHandler for given object */
ItemMenuHandler* newItemMenuHandler(StepCore::Object* object,
......
This diff is collapsed.
This diff is collapsed.
......@@ -21,6 +21,7 @@
#endif
#include "worldscene.h"
#include "worldscene.moc"
#include "settings.h"
......@@ -28,6 +29,7 @@
#include "arrow.h"
#include "worldmodel.h"
#include "worldfactory.h"
#include "stepgraphicsitem.h"
#include "worldgraphics.h"
#include <stepcore/world.h>
......@@ -177,13 +179,13 @@ WorldScene::~WorldScene()
StepCore::Item* WorldScene::itemFromGraphics(const QGraphicsItem* graphicsItem) const
{
const WorldGraphicsItem* worldGraphicsItem =
dynamic_cast<const WorldGraphicsItem*>(graphicsItem);
const StepGraphicsItem* worldGraphicsItem =
dynamic_cast<const StepGraphicsItem*>(graphicsItem);
if(worldGraphicsItem != NULL) return worldGraphicsItem->item();
else return NULL;
}
WorldGraphicsItem* WorldScene::graphicsFromItem(const StepCore::Item* item) const
StepGraphicsItem* WorldScene::graphicsFromItem(const StepCore::Item* item) const
{
return _itemsHash.value(item, NULL);
}
......@@ -323,7 +325,7 @@ void WorldScene::worldRowsInserted(const QModelIndex& parent, int start, int end
StepCore::Item* item = _worldModel->item(index);
if(!item) continue;
WorldGraphicsItem* graphicsItem =
StepGraphicsItem* graphicsItem =
_worldModel->worldFactory()->newGraphicsItem(item, _worldModel);
if(!graphicsItem) continue;
......@@ -333,7 +335,7 @@ void WorldScene::worldRowsInserted(const QModelIndex& parent, int start, int end
graphicsItem->worldDataChanged(false);
foreach(QGraphicsItem *item, items()) {
if(graphicsItem->isAncestorOf(item)) {
WorldGraphicsItem* gItem = dynamic_cast<WorldGraphicsItem*>(item);
StepGraphicsItem* gItem = dynamic_cast<StepGraphicsItem*>(item);
if(gItem) gItem->viewScaleChanged();
}
}
......@@ -392,7 +394,7 @@ void WorldScene::worldDataChanged(bool dynamicOnly)
}