Ejemplo n.º 1
0
void GraphEditor::handleAddBlock(const Poco::JSON::Object::Ptr &blockDesc, const QPointF &where)
{
    if (not blockDesc) return;
    auto draw = this->getCurrentGraphDraw();
    auto block = new GraphBlock(draw);
    block->setBlockDesc(blockDesc);

    QString hint;
    const auto title = block->getTitle();
    for (int i = 0; i < title.length(); i++)
    {
        if (i == 0 and title.at(i).isNumber()) hint.append(QChar('_'));
        if (title.at(i).isLetterOrNumber() or title.at(i).toLatin1() == '_')
        {
            hint.append(title.at(i));
        }
    }
    block->setId(this->newId(hint));

    //set highest z-index on new block
    block->setZValue(draw->getMaxZValue()+1);

    block->setPos(where);
    block->setRotation(0);
    handleStateChange(GraphState("list-add", tr("Create block %1").arg(title)));
}
Ejemplo n.º 2
0
void Ball::reset()
{
	const Square& roofSquare = getRoofSquare(sgLevel.start.x, sgLevel.start.y);

	mPos.x = roofSquare.mid.x;
	mPos.y = roofSquare.mid.y;
	mPos.z = getMaxZValue(&roofSquare) + 2.5f;

	mVelocity = Vector3(0.0f, 0.0f, 0.0f);
	mAngularRate = Vector3(0.0f, 0.0f, 0.0f);

	mIsBallInPieces = false;
	mHasBallHitGoal = false;
}
Ejemplo n.º 3
0
void GraphEditor::handleInsertGraphWidget(QObject *obj)
{
    auto block = dynamic_cast<GraphBlock *>(obj);
    assert(block != nullptr);
    assert(block->isGraphWidget());

    auto draw = this->getCurrentGraphDraw();
    auto display = new GraphWidget(draw);
    display->setGraphBlock(block);
    display->setId(this->newId("Widget"+block->getId()));
    display->setZValue(draw->getMaxZValue()+1);
    display->setPos(draw->getLastContextMenuPos());
    display->setRotation(0);

    handleStateChange(GraphState("insert-image", tr("Insert widget %1").arg(block->getId())));
}