示例#1
0
void
ObjectSettings::onEditingFinished()
{
    if (valueChanged_)
    {
        QString filename = ui->nameBox->text();
        QString newId = object_->getId();
        RSystemElementRoad * road = object_->getParentRoad();
        if (filename != object_->getName())
        {
            QStringList parts = object_->getId().split("_");

            if (parts.size() > 2)
            {
                newId = QString("%1_%2_%3").arg(parts.at(0)).arg(parts.at(1)).arg(filename); 
            }
            else
            {
                newId = road->getRoadSystem()->getUniqueId(object_->getId(), filename);
            }
        }

        double repeatLength = ui->repeatLengthSpinBox->value();
        if (repeatLength > road->getLength() - ui->repeatSSpinBox->value())
        {
            repeatLength = road->getLength() - ui->repeatSSpinBox->value();
        }

        SetObjectPropertiesCommand *command = new SetObjectPropertiesCommand(object_, newId, filename, ui->typeBox->text(), ui->tSpinBox->value(), ui->zOffsetSpinBox->value(),
            ui->validLengthSpinBox->value(), (Object::ObjectOrientation)ui->orientationComboBox->currentIndex(), ui->lengthSpinBox->value(), ui->widthSpinBox->value(), ui->radiusSpinBox->value(), ui->heightSpinBox->value(), ui->hdgSpinBox->value(),
            ui->pitchSpinBox->value(), ui->rollSpinBox->value(), ui->poleCheckBox->isChecked(), ui->repeatSSpinBox->value(), repeatLength, ui->repeatDistanceSpinBox->value(), ui->textureLineEdit->text());
        getProjectSettings()->executeCommand(command);

        valueChanged_ = false;
        QWidget * focusWidget = QApplication::focusWidget();
        if (focusWidget)
        {
            focusWidget->clearFocus();
        }
    }
}
示例#2
0
/*! \brief Handles the item's position changes.
*/
QVariant
SignalHandle::itemChange(GraphicsItemChange change, const QVariant &value)
{
    // NOTE: position is relative to parent!!! //
    //

    // Mode 1 //
    //
    if (parentSignalRoadItem_)
    {
        if (change == QGraphicsItem::ItemPositionChange)
        {
            if (moveItem_)
            {
                RSystemElementRoad *road = parentSignalRoadItem_->getRoad();
                double s = road->getSFromGlobalPoint(value.toPointF(), -100.0, road->getLength());
                //				return parentSectionItem_->getRoadSection()->getParentRoad()->getGlobalPoint(s, 0.0);

                /*				MoveRoadSectionCommand * command = new MoveRoadSectionCommand(roadSection, s, parentSectionItem_->getRoadSectionType());
				if(command->isValid())
				{
					roadSection->getUndoStack()->push(command);
				}
				else
				{
					delete command;
				}*/

                return pos(); // no translation
            }
            else
            {
            }
        }
    }

    // Mode 2 //
    //
    //	else
    //	{
    //
    //	}

    return QGraphicsItem::itemChange(change, value);
}