コード例 #1
0
ファイル: envroomtemplate.cpp プロジェクト: jaxzin/firebox
void EnvRoomTemplate::LoadData(const QString & filename)
{

    QFile file( filename );
    if (!file.open( QIODevice::ReadOnly | QIODevice::Text )) {
        return;
    }

    //set base path (for loading resources in same dir)
    QTextStream ifs(&file);

    //get num colliders
    QStringList eachline = ifs.readLine().split(" ");
    const int nColliders = eachline.last().toInt();

    //read rectangular colliders
    for (int i=0; i<nColliders; ++i) {

        eachline = ifs.readLine().split(" ");

        if (eachline[0].compare("CIRCLE") == 0) {

            CircCollider c;

            c.pos = QPointF(eachline[1].toFloat(), eachline[2].toFloat());
            c.rad = eachline[3].toFloat();
            if (eachline[4].compare("IN") == 0) {
                c.rad -= 1.0f;
                c.stay_inside = true;
            }
            else {
                c.rad += 1.0f;
                c.stay_inside = false;
            }

            circ_colliders.push_back(c);

        }
        else {

            const float x1 = eachline[0].toFloat();
            const float y1 = eachline[1].toFloat();
            const float x2 = eachline[2].toFloat();
            const float y2 = eachline[3].toFloat();

            //NOTE: colliders are padded by 1 unit to enforce player's size and prevent viewplane clipping
            QRectF c;
            c.setBottomLeft(QPointF(qMin(x1, x2) - 1, qMin(y1, y2) - 1));
            c.setTopRight(QPointF(qMax(x1, x2) + 1, qMax(y1, y2) + 1));
            colliders.push_back(c);

        }

    }

    //read mount points
    eachline = ifs.readLine().split(" ");
    const int nMounts = eachline.last().toInt();

    for (int i=0; i<nMounts; ++i) {

        eachline = ifs.readLine().split(" ");

        const float px = eachline[0].toFloat();
        const float py = eachline[1].toFloat();
        const float pz = eachline[2].toFloat();

        const float dx = eachline[3].toFloat();
        const float dy = eachline[4].toFloat();
        const float dz = eachline[5].toFloat();

        mount_pts.push_back(QVector3D(px, py, pz));
        mount_dirs.push_back(QVector3D(dx, dy, dz));

    }

    file.close();
}
コード例 #2
0
void OverlayEditorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
	QGraphicsScene::mouseMoveEvent(event);

	if (event->isAccepted())
		return;

	if (qgpiSelected && (event->buttons() & Qt::LeftButton)) {
		event->accept();

		if (wfsHover == Qt::NoSection)
			return;

		QPointF delta = event->scenePos() - event->buttonDownScenePos(Qt::LeftButton);

		bool square = event->modifiers() & Qt::ShiftModifier;

		QRectF orig = selectedRect();
		switch (wfsHover) {
			case Qt::TitleBarArea:
				orig.translate(delta);
				break;
			case Qt::TopSection:
				orig.setTop(orig.top() + delta.y());
				if (orig.height() < 8.0f)
					orig.setTop(orig.bottom() - 8.0f);
				if (square)
					orig.setRight(orig.left() + orig.height());
				break;
			case Qt::BottomSection:
				orig.setBottom(orig.bottom() + delta.y());
				if (orig.height() < 8.0f)
					orig.setBottom(orig.top() + 8.0f);
				if (square)
					orig.setRight(orig.left() + orig.height());
				break;
			case Qt::LeftSection:
				orig.setLeft(orig.left() + delta.x());
				if (orig.width() < 8.0f)
					orig.setLeft(orig.right() - 8.0f);
				if (square)
					orig.setBottom(orig.top() + orig.width());
				break;
			case Qt::RightSection:
				orig.setRight(orig.right() + delta.x());
				if (orig.width() < 8.0f)
					orig.setRight(orig.left() + 8.0f);
				if (square)
					orig.setBottom(orig.top() + orig.width());
				break;
			case Qt::TopLeftSection:
				orig.setTopLeft(orig.topLeft() + delta);
				if (orig.height() < 8.0f)
					orig.setTop(orig.bottom() - 8.0f);
				if (orig.width() < 8.0f)
					orig.setLeft(orig.right() - 8.0f);
				if (square) {
					qreal size = qMin(orig.width(), orig.height());
					QPointF sz(-size, -size);
					orig.setTopLeft(orig.bottomRight() + sz);
				}
				break;
			case Qt::TopRightSection:
				orig.setTopRight(orig.topRight() + delta);
				if (orig.height() < 8.0f)
					orig.setTop(orig.bottom() - 8.0f);
				if (orig.width() < 8.0f)
					orig.setRight(orig.left() + 8.0f);
				if (square) {
					qreal size = qMin(orig.width(), orig.height());
					QPointF sz(size, -size);
					orig.setTopRight(orig.bottomLeft() + sz);
				}
				break;
			case Qt::BottomLeftSection:
				orig.setBottomLeft(orig.bottomLeft() + delta);
				if (orig.height() < 8.0f)
					orig.setBottom(orig.top() + 8.0f);
				if (orig.width() < 8.0f)
					orig.setLeft(orig.right() - 8.0f);
				if (square) {
					qreal size = qMin(orig.width(), orig.height());
					QPointF sz(-size, size);
					orig.setBottomLeft(orig.topRight() + sz);
				}
				break;
			case Qt::BottomRightSection:
				orig.setBottomRight(orig.bottomRight() + delta);
				if (orig.height() < 8.0f)
					orig.setBottom(orig.top() + 8.0f);
				if (orig.width() < 8.0f)
					orig.setRight(orig.left() + 8.0f);
				if (square) {
					qreal size = qMin(orig.width(), orig.height());
					QPointF sz(size, size);
					orig.setBottomRight(orig.topLeft() + sz);
				}
				break;
		}

		qgriSelected->setRect(orig);
	} else {
		updateCursorShape(event->scenePos());
	}
}
コード例 #3
0
void KUnitItem::slotMouseMove(QGraphicsSceneMouseEvent *event)
{
    if (myMode == MouseMode_RESIZE)
    {
        QPointF curPoint(event->scenePos());
        QPointF curPointItem = this->mapFromScene(curPoint);

        bool flagx = lastPoint.x() > oppositePos.x();
        bool flagx1 = curPointItem.x() > oppositePos.x();
        bool flagy = lastPoint.y() > oppositePos.y();
        bool flagy1 = curPointItem.y() > oppositePos.y();


        qreal dist = 0;

        QRectF rectf;
        rectf.setRect(m_frame.x()
                      , m_frame.y()
                      , m_frame.width()
                      , m_frame.height());


        KResizeFocus::PosInHost pos = curResizeFocus->getInHost();
        if (pos == KResizeFocus::NORTH_MIDDLE)
        {
            QPointF br = dashRect->rect().bottomRight();
            dist = Util::GetPointDistLine(oppositePos,br,curPointItem);

            if (dist < 20 || flagy != flagy1)
            {
                if (flagy)
                {
                    curPointItem.setY(oppositePos.y() + 20);
                }
                else
                {
                    curPointItem.setY(oppositePos.y() - 20);
                }
                dist = 20;
            }
            rectf.setY(curPointItem.y());
            rectf.setHeight(dist);
        }
        else if(pos == KResizeFocus::SOUTH_MIDDLE)
        {
            QPointF br = dashRect->rect().topRight();
            dist = Util::GetPointDistLine(oppositePos,br,curPointItem);

            if (dist < 20 || flagy != flagy1)
            {
                if (flagy)
                {
                    curPointItem.setY(oppositePos.y() + 20);
                }
                else
                {
                    curPointItem.setY(oppositePos.y() - 20);
                }
                dist = 20;
            }
            rectf.setHeight(dist);
        }
        else if(pos == KResizeFocus::EAST_MIDDLE)
        {
            QPointF br = dashRect->rect().bottomLeft();
            dist = Util::GetPointDistLine(oppositePos,br,curPointItem);

            if (dist < 20 || flagx != flagx1)
            {
                if (flagx)
                {
                    curPointItem.setX(oppositePos.x() + 20);
                }
                else
                {
                    curPointItem.setX(oppositePos.x() - 20);
                }
                dist = 20;
            }
            rectf.setWidth(dist);
        }
        else if(pos == KResizeFocus::WEST_MIDDLE)
        {
            QPointF br = dashRect->rect().bottomRight();
            dist = Util::GetPointDistLine(oppositePos,br,curPointItem);

            if (dist < 20 || flagx != flagx1)
            {
                if (flagx)
                {
                    curPointItem.setX(oppositePos.x() + 20);
                }
                else
                {
                    curPointItem.setX(oppositePos.x() - 20);
                }
                dist = 20;
            }
            rectf.setX(curPointItem.x());
            rectf.setWidth(dist);
        }
        else if(pos == KResizeFocus::NORTH_WEST)
        {
            QPointF topRight = dashRect->rect().topRight();
            QPointF bottomLeft = dashRect->rect().bottomLeft();

            qreal distx = Util::GetPointDistLine(oppositePos,topRight,curPointItem);
            qreal disty = Util::GetPointDistLine(oppositePos,bottomLeft,curPointItem);

            if (distx < 20 || flagx != flagx1)
            {
                if (flagx)
                {
                    curPointItem.setX(oppositePos.x() + 20);
                }
                else
                {
                    curPointItem.setX(oppositePos.x() - 20);
                }
                distx = 20;
            }
            if (disty < 20 || flagy != flagy1)
            {
                if (flagy)
                {
                    curPointItem.setY(oppositePos.y() + 20);
                }
                else
                {
                    curPointItem.setY(oppositePos.y() - 20);
                }
                disty = 20;
            }

            rectf.setTopLeft(curPointItem);
        }
        else if(pos == KResizeFocus::NORTH_EAST)
        {
            QPointF topLeft = dashRect->rect().topLeft();
            QPointF bottomRight = dashRect->rect().bottomRight();

            qreal distx = Util::GetPointDistLine(oppositePos,topLeft,curPointItem);
            qreal disty = Util::GetPointDistLine(oppositePos,bottomRight,curPointItem);

            if (distx < 20 || flagx != flagx1)
            {
                if (flagx)
                {
                    curPointItem.setX(oppositePos.x() + 20);
                }
                else
                {
                    curPointItem.setX(oppositePos.x() - 20);
                }
                distx = 20;
            }
            if (disty < 20 || flagy != flagy1)
            {
                if (flagy)
                {
                    curPointItem.setY(oppositePos.y() + 20);
                }
                else
                {
                    curPointItem.setY(oppositePos.y() - 20);
                }
                disty = 20;
            }

            rectf.setTopRight(curPointItem);
        }
        else if(pos == KResizeFocus::SOUTH_EAST)
        {
            QPointF topRight = dashRect->rect().topRight();
            QPointF bottomLeft = dashRect->rect().bottomLeft();

            qreal disty = Util::GetPointDistLine(oppositePos,topRight,curPointItem);
            qreal distx = Util::GetPointDistLine(oppositePos,bottomLeft,curPointItem);

            if (distx < 20 || flagx != flagx1)
            {
                if (flagx)
                {
                    curPointItem.setX(oppositePos.x() + 20);
                }
                else
                {
                    curPointItem.setX(oppositePos.x() - 20);
                }
                distx = 20;
            }
            if (disty < 20 || flagy != flagy1)
            {
                if (flagy)
                {
                    curPointItem.setY(oppositePos.y() + 20);
                }
                else
                {
                    curPointItem.setY(oppositePos.y() - 20);
                }
                disty = 20;
            }

            rectf.setBottomRight(curPointItem);
        }
        else if(pos == KResizeFocus::SOUTH_WEST)
        {
            QPointF topLeft = dashRect->rect().topLeft();
            QPointF bottomRight = dashRect->rect().bottomRight();

            qreal disty = Util::GetPointDistLine(oppositePos,topLeft,curPointItem);
            qreal distx = Util::GetPointDistLine(oppositePos,bottomRight,curPointItem);

            if (distx < 20 || flagx != flagx1)
            {
                if (flagx)
                {
                    curPointItem.setX(oppositePos.x() + 20);
                }
                else
                {
                    curPointItem.setX(oppositePos.x() - 20);
                }
                distx = 20;
            }
            if (disty < 20 || flagy != flagy1)
            {
                if (flagy)
                {
                    curPointItem.setY(oppositePos.y() + 20);
                }
                else
                {
                    curPointItem.setY(oppositePos.y() - 20);
                }
                disty = 20;
            }
            rectf.setBottomLeft(curPointItem);
        }

        dashRect->setRect(rectf);
    }
    else if(myMode == MouseMode_ROTATE)
    {
        QPointF curPos = event->scenePos();
        QPointF cpos = this->mapToScene(frame().center());
//        qDebug()<<cpos;
		qreal angleLast = Util::ComputeAngle(mLastRotatePoint, cpos);
		qreal angleCur = Util::ComputeAngle(curPos, cpos);
        qreal angle = angleCur - angleLast;

        setAngle(angle);
        mLastRotatePoint = curPos;
        onRotate();
    }
    else if(myMode == MouseMode_MOVE)
    {
        onMoving();
    }
    else
    {
        QGraphicsItem::mouseMoveEvent(event);
    }
}
コード例 #4
0
ファイル: Level.cpp プロジェクト: adderly/VoltAir
void Level::rubeB2DLevel(b2dJson& mBox2dJson)
{
    if(mJsonFilePath.isEmpty()){
        qDebug() << " mJsonFilePath is empty ";
    }

    if(!Util::fileExists(mJsonFilePath)){
        qDebug() << " Level: "  << mJsonFilePath << " does not exists. ";
        return;
    }
    std::string worldJson = Util::readFileAsStdString(mJsonFilePath);

    std::string errorstring;
    b2World* w = mBox2dJson.readFromString(worldJson,errorstring,mWorld.get());

    if(w){
        //custom properties to be read
        int useWorldGravity = mBox2dJson.getCustomInt(w,"use_world_gravity",0);
        float grav_x ;
        float grav_y ;
        if(useWorldGravity){
            grav_x = mBox2dJson.getCustomFloat(w,"world_gravity_x",0);
            grav_y = mBox2dJson.getCustomFloat(w,"world_gravity_y",0);
             w->SetGravity(b2Vec2(grav_x,grav_y));
        }

        qDebug() << " Reading jsonfile Complete!  \n\t ";


        //check if there is a camera body
        //used for camera bounds. (Square body)
        b2Body* cam_body = mBox2dJson.getBodyByName("camera");
        if(cam_body){
            b2Fixture* cam_fixture = cam_body->GetFixtureList();
            if(cam_fixture){
                QRectF bbox = Box2dUtil::toQRectF(cam_fixture->GetAABB(0));
                this->setCameraBoundary(bbox);
                cam_body->SetActive(false);
#ifdef D_PARSE
                qDebug() << "Bounding box "<< bbox;
#endif
            }
#ifdef D_PARSE
            qDebug() << "camera found!";
#endif
        }

        //TODO: this is sooooo lazy,
        for(QVariant v:mLevelActorMapping){
            QMap<QString,QVariant> tmp = v.toMap();
            qDebug() << " Mapped LevelActorrr  " << tmp;

            mLevelActorMap.insert(tmp.firstKey(),tmp.first().toString());
        }


        Engine* engine = Engine::getInstance();
        QQmlEngine* qmlEngine = engine->getQmlEngine();

        // Check if bodies are referenced in the Actor Mapping Category
        Body* b = nullptr;
        std::string actorTypeString;
        b2Body* body = mWorld->GetBodyList();
        while(body){
            actorTypeString = mBox2dJson.getCustomString(body,"actorType");
            if(actorTypeString.empty() || actorTypeString == "none"){
                b = Body::BodyFromb2Body(body);
                if(b) b->setParent(this);
            }else{
                actorFromMapping(body,actorTypeString,qmlEngine);
            }
            body = body->GetNext();
        }

        // Use Nodes for parsing the specific type of node
        //QList<LevelNode*> nodes = findChildren<LevelNode*>();
        for(LevelNode* node: findChildren<LevelNode*>())  {
            switch(node->type())  {
                case LevelNode::BODY_REFERENCE:{
                    actorReferenceBody(node);
                }break;
                case LevelNode::ACTOR_COMPONENT_W_BODY:{
                    actorComponentWithBody(node,qmlEngine);
                }break;
                default:{
                    qDebug() << " unknown LevelNode type = " << node->type();
                }
            }
        }

       //check for images associated with the body.
       int imageCount = 0;
       body = nullptr;
       b = nullptr;
       QString image_path;
       Actor* actor = nullptr;
       ImageRenderer* img_renderer = nullptr;
       std::vector<b2dJsonImage*> world_images;
       imageCount = mBox2dJson.getAllImages(world_images);

       for(b2dJsonImage* img: world_images)
       {
           if((body = img->body))
           {
               b = static_cast<Body*>(img->body->GetUserData());
               if(b)
               {
                   image_path = Util::getPathToLevel(QString::fromStdString(img->file));
                   actor = new Actor(b);
                   actor->setPosition(b->getPosition());
                   actor->setParent(this);
                   actor->setParentItem(this);
                   img_renderer = new ImageRenderer(actor);
                   img_renderer->setSource(image_path);
                   img_renderer->setSizeScale(img->scale);
                   img_renderer->setVisible(true);
                   img_renderer->setCacheRenderParams(body->GetType() == Body::StaticBody);

                   QRectF c;
                   c.setTopLeft(Box2dUtil::toQPointF(img->corners[0]));
                   c.setTopRight(Box2dUtil::toQPointF(img->corners[1]));
                   c.setBottomRight(Box2dUtil::toQPointF(img->corners[2]));
                   c.setBottomLeft(Box2dUtil::toQPointF(img->corners[3]));
                   img_renderer->setCustomLocalBox(c);

#ifdef D_PARSE
                   qDebug() << image_path << " box2d " << Box2dUtil::toQPointF(img->corners[0]);
                   qDebug() << image_path << " box2d " << Box2dUtil::toQPointF(img->corners[1]);
                   qDebug() << image_path << " box2d " << Box2dUtil::toQPointF(img->corners[2]);
                   qDebug() << image_path << " box2d " << Box2dUtil::toQPointF(img->corners[3]);
                   qDebug() << image_path << " render localbox " << c;
                   //TODO: fixe the scale ratio, to match box2d.
                   b2AABB aabb = img->getAABB();
                   qDebug() <<"Image aabb = " << Box2dUtil::toQRectF(aabb);
                  // img_renderer->setPosition(QPointF(img->center.x,img->center.y ));
                   qDebug() << "Image pos = " <<img_renderer->position();
#endif
               }
           }
       }
    }else{
        qDebug() << "World null, Error Reading jsonfile: \n\t " << errorstring.c_str();
    }
    w = nullptr;
}
コード例 #5
0
void AbstractGraphicsRectItem::updateBottomLeft(const QPointF &newPos)
{
    QRectF r = rect();
    r.setBottomLeft(mapFromScene(newPos));
    updateRect(r);
}
コード例 #6
0
ファイル: node.cpp プロジェクト: nanox/tupi
void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    QPointF newPos(event->scenePos());

    if (k->notChange) {
        k->notChange = false;
    } else {
        if (k->action == Scale) {
            QRectF rect = k->parent->sceneBoundingRect();
            QRectF parentRect  = k->parent->sceneBoundingRect();
            QRectF parentSquare  = k->parent->boundingRect();
            
            // SQA: Lines for debugging purposes
            /*
            scene()->addRect(rect, QPen(Qt::red));
            scene()->addRect(parentRect, QPen(Qt::green));
            */
            
            switch (k->typeNode) {
                    case TopLeft:
                    {
                         k->manager->setAnchor(parentSquare.bottomRight());
                         rect.setTopLeft(newPos);
                         break;
                    }
                    case TopRight:
                    {
                         k->manager->setAnchor(parentSquare.bottomLeft());
                         rect.setTopRight(newPos);
                         break;
                    }
                    case BottomRight:
                    {
                         k->manager->setAnchor(parentSquare.topLeft());
                         rect.setBottomRight(newPos);
                         break;
                    }
                    case BottomLeft:
                    {
                         k->manager->setAnchor(parentSquare.topRight());
                         rect.setBottomLeft(newPos);
                         break;
                    }
                    case Center:
                    {
                         break;
                    }
            };
            
            float sx = 1, sy = 1;
            sx = static_cast<float>(rect.width()) / static_cast<float>(parentRect.width());
            sy = static_cast<float>(rect.height()) / static_cast<float>(parentRect.height());

            if (k->manager->proportionalScale()) {
                k->manager->scale(sx, sx);
            } else {
                if (sx > 0 && sy > 0) {
                    k->manager->scale(sx, sy);
                } else {
                    if (sx > 0)
                        k->manager->scale(sx, 1);

                    if (sy > 0)
                        k->manager->scale(1, sy);
                }
            }
        } else if (k->action == Rotate) {
                   QPointF p1 = newPos;
                   QPointF p2 = k->parent->sceneBoundingRect().center();
                   k->manager->setAnchor(k->parent->boundingRect().center());
                
                   double a = (180 * TupGraphicalAlgorithm::angleForPos(p1, p2)) / M_PI;
                   k->manager->rotate(a-45);
        }
    }

    if (k->typeNode == Center) {
        k->parent->moveBy(event->scenePos().x() - scenePos().x() , event->scenePos().y() - scenePos().y());
        event->accept();
    }
}
コード例 #7
0
void ItemHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
{
    QGraphicsItem::mouseMoveEvent( e );
    if (!(m_itemView && m_active && e->buttons() & Qt::LeftButton))
        return;

    const QPointF rp = e->scenePos();
    const QPointF d = rp - m_origPressPos;

    switch (m_type) {

    case LeftTop: {
        m_geom.setTopLeft(m_origGeom.topLeft() + d);
        QRectF rect = convertUnit(m_geom, Pixel, m_itemView->coreItem()->page()->unit(), m_itemView->coreItem()->page()->dpi());
        QRectF orig = m_itemView->coreItem()->geometry();

        // TODO: optimize
        if (m_useMagnets) {
            QRectF absoluteGeometry = m_itemView->coreItem()->absoluteGeometry();
            absoluteGeometry.setTopLeft(absoluteGeometry.topLeft() + (rect.topLeft() - orig.topLeft()));
            QList<QPointF> pointsList;
            QList<CuteReport::BaseItemInterface*> excludeItems;
            pointsList << absoluteGeometry.topLeft();
            excludeItems << m_itemView->coreItem();
            QPointF point = m_sel->pageGUI()->magnets()->delta(pointsList, excludeItems, Magnets::HVDirection);

            orig.setTopLeft(rect.topLeft() + point);
        } else
            orig.setTopLeft(rect.topLeft());

        m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig);

    } break;

    case Top: {
        m_geom.setTop(m_origGeom.top() + d.y());
        QRectF rect = convertUnit(m_geom, Pixel, m_itemView->coreItem()->page()->unit(), m_itemView->coreItem()->page()->dpi());
        QRectF orig = m_itemView->coreItem()->geometry();

        // TODO: optimize
        if (m_useMagnets) {
            QRectF absoluteGeometry = m_itemView->coreItem()->absoluteGeometry();
            absoluteGeometry.setTop(absoluteGeometry.top() + (rect.top() - orig.top()));
            QList<QPointF> pointsList;
            QList<CuteReport::BaseItemInterface*> excludeItems;
            pointsList << absoluteGeometry.topLeft();
            excludeItems << m_itemView->coreItem();
            QPointF point = m_sel->pageGUI()->magnets()->delta(pointsList, excludeItems, Magnets::VDirection);

            orig.setTop(rect.top()+ point.y());
        } else
            orig.setTop(rect.top());

        m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig);
    } break;

    case RightTop: {
        m_geom.setTopRight(m_origGeom.topRight() + d);
        QRectF rect = convertUnit(m_geom, Pixel, m_itemView->coreItem()->page()->unit(), m_itemView->coreItem()->page()->dpi());
        QRectF orig = m_itemView->coreItem()->geometry();

        // TODO: optimize
        if (m_useMagnets) {
            QRectF absoluteGeometry = m_itemView->coreItem()->absoluteGeometry();
            absoluteGeometry.setTopRight(absoluteGeometry.topRight() + (rect.topRight() - orig.topRight()));
            QList<QPointF> pointsList;
            QList<CuteReport::BaseItemInterface*> excludeItems;
            pointsList << absoluteGeometry.topRight();
            excludeItems << m_itemView->coreItem();
            QPointF point = m_sel->pageGUI()->magnets()->delta(pointsList, excludeItems, Magnets::HVDirection);

            orig.setTopRight(rect.topRight()+ point);
        } else
            orig.setTopRight(rect.topRight());

        m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig);

    } break;

    case Right: {
        m_geom.setWidth(m_origGeom.width() + d.x());
        QRectF rect = convertUnit(m_geom, Pixel, m_itemView->coreItem()->page()->unit(), m_itemView->coreItem()->page()->dpi());
        QRectF orig = m_itemView->coreItem()->geometry();

        // TODO: optimize
        if (m_useMagnets) {
            QRectF absoluteGeometry = m_itemView->coreItem()->absoluteGeometry();
            absoluteGeometry.setRight(absoluteGeometry.right() + (rect.right() - orig.right()));
            QList<QPointF> pointsList;
            QList<CuteReport::BaseItemInterface*> excludeItems;
            pointsList << absoluteGeometry.bottomRight();
            excludeItems << m_itemView->coreItem();
            QPointF point = m_sel->pageGUI()->magnets()->delta(pointsList, excludeItems, Magnets::HDirection);

            orig.setRight(rect.right()+ point.x());
        } else
            orig.setRight(rect.right());

        m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig);    } break;

    case RightBottom: {
        m_geom.setBottomRight(m_origGeom.bottomRight() + d);
        QRectF rect = convertUnit(m_geom, Pixel, m_itemView->coreItem()->page()->unit(), m_itemView->coreItem()->page()->dpi());
        QRectF orig = m_itemView->coreItem()->geometry();

        // TODO: optimize
        if (m_useMagnets) {
            QRectF absoluteGeometry = m_itemView->coreItem()->absoluteGeometry();
            absoluteGeometry.setBottomRight(absoluteGeometry.bottomRight() + (rect.bottomRight() - orig.bottomRight()));
            QList<QPointF> pointsList;
            QList<CuteReport::BaseItemInterface*> excludeItems;
            pointsList << absoluteGeometry.bottomRight();
            excludeItems << m_itemView->coreItem();
            QPointF point = m_sel->pageGUI()->magnets()->delta(pointsList, excludeItems, Magnets::HVDirection);

            orig.setBottomRight(rect.bottomRight() +point);
        } else
            orig.setBottomRight(rect.bottomRight());

        m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig);
    } break;

    case Bottom: {
        m_geom.setHeight(m_origGeom.height() + d.y());
        QRectF rect = convertUnit(m_geom, Pixel, m_itemView->coreItem()->page()->unit(), m_itemView->coreItem()->page()->dpi());
        QRectF orig = m_itemView->coreItem()->geometry();

        // TODO: optimize
        if (m_useMagnets) {
            QRectF absoluteGeometry = m_itemView->coreItem()->absoluteGeometry();
            absoluteGeometry.setBottom(absoluteGeometry.bottom() + (rect.bottom() - orig.bottom()));
            QList<QPointF> pointsList;
            QList<CuteReport::BaseItemInterface*> excludeItems;
            pointsList << absoluteGeometry.bottomLeft();
            excludeItems << m_itemView->coreItem();
            QPointF point = m_sel->pageGUI()->magnets()->delta(pointsList, excludeItems, Magnets::VDirection);

            orig.setBottom(rect.bottom()+ point.y());
        } else
            orig.setBottom(rect.bottom());

        m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig);
    } break;

    case LeftBottom: {
        m_geom.setBottomLeft(m_origGeom.bottomLeft()+ d);
        QRectF rect = convertUnit(m_geom, Pixel, m_itemView->coreItem()->page()->unit(), m_itemView->coreItem()->page()->dpi());
        QRectF orig = m_itemView->coreItem()->geometry();

        // TODO: optimize
        if (m_useMagnets) {
            QRectF absoluteGeometry = m_itemView->coreItem()->absoluteGeometry();
            absoluteGeometry.setBottomLeft(absoluteGeometry.bottomLeft() + (rect.bottomLeft() - orig.bottomLeft()));
            QList<QPointF> pointsList;
            QList<CuteReport::BaseItemInterface*> excludeItems;
            pointsList << absoluteGeometry.bottomLeft();
            excludeItems << m_itemView->coreItem();
            QPointF point = m_sel->pageGUI()->magnets()->delta(pointsList, excludeItems, Magnets::HVDirection);

            orig.setBottomLeft(rect.bottomLeft() + point);
        } else
            orig.setBottomLeft(rect.bottomLeft());

        m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig);
    } break;

    case Left: {
        m_geom.setLeft(m_origGeom.left() + d.x());
        QRectF rect = convertUnit(m_geom, Pixel, m_itemView->coreItem()->page()->unit(), m_itemView->coreItem()->page()->dpi());
        QRectF orig = m_itemView->coreItem()->geometry();

        // TODO: optimize
        if (m_useMagnets) {
            QRectF absoluteGeometry = m_itemView->coreItem()->absoluteGeometry();
            absoluteGeometry.setLeft(absoluteGeometry.left() + (rect.left() - orig.left()));
            QList<QPointF> pointsList;
            QList<CuteReport::BaseItemInterface*> excludeItems;
            pointsList << absoluteGeometry.bottomLeft();
            excludeItems << m_itemView->coreItem();
            QPointF point = m_sel->pageGUI()->magnets()->delta(pointsList, excludeItems, Magnets::HDirection);

            orig.setLeft(rect.left()+ point.x());
        } else
            orig.setLeft(rect.left());

        m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig);

        //        orig.setLeft(rect.left());
        //        m_sel->pageGUI()->setItemAjustedGeometry(m_itemView->coreItem(), orig);
    } break;

    default: break;

    } // end switch

}