Beispiel #1
0
void
TileSystem::addTile(Tile *tile)
{
    if (getProjectData())
    {
        // Id //
        //
        QString name = tile->getName();
        QString id = getUniqueId(tile->getID(), name);
        if (id != tile->getID())
        {
            tile->setID(id);
            if (name != tile->getName())
            {
                tile->setName(name);
            }
        }
    }

    // Insert //
    //
    tile->setTileSystem(this);

    tiles_.insert(tile->getID(), tile);
    addTileSystemChanges(TileSystem::CTS_TileChange);

    setCurrentTile(tile);
}
Beispiel #2
0
void CConfigData::vReadConfigFile()
{
    UCHAR pCheckSum,fChecksum;
    if (getCheckSum(m_omStrCurrFileName ,& pCheckSum, &fChecksum))
    {
        if (pCheckSum == fChecksum)
        {
            if (doDataStorageOperation(OPEN) == 0)
            {
                ProjectData sTempData;
                getProjectData(m_strCurrProjName, sTempData);
                if (sTempData.applicationUniqueId != BUSMASTER_UNIQUE_ID)
                {
                    AfxMessageBox (_("The configuration file is not compatible"),
                                   MB_OK | MB_ICONERROR);
                    doDataStorageOperation(CLOSE);
                }
            }
            else
            {
                AfxMessageBox (_("The configuration file is not valid"),
                               MB_OK | MB_ICONERROR);
                doDataStorageOperation(CLOSE);
            }
        }
        else
        {
            AfxMessageBox (_("Configuration file changed outside the application"),
                           MB_OK | MB_ICONERROR);
        }
    }
}
Beispiel #3
0
void
JunctionElementItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    if (event->button() == Qt::LeftButton)
    {
        ODD::ToolId tool = getJunctionEditor()->getCurrentTool();
        if (tool == ODD::TTE_ROAD_DELETE)
        {
            removeParentRoad();
            return;
        }
        else if (tool == ODD::TTE_DELETE)
        {
            removeSection();
            return;
        }
        else if (tool == ODD::TJE_SPLIT)
        {
            RSystemElementRoad *road = trackElement_->getParentRoad();
            double s = road->getSFromGlobalPoint(event->scenePos(), trackElement_->getSStart(), trackElement_->getSEnd());

            getProjectData()->getUndoStack()->beginMacro(QObject::tr("Split Track and Road"));

            // Split Track //
            //
            SplitTrackComponentCommand *splitTrackCommand = new SplitTrackComponentCommand(trackElement_, s, NULL);
            getProjectGraph()->executeCommand(splitTrackCommand);

            // Split Road //
            //
            SplitRoadCommand *splitRoadCommand = new SplitRoadCommand(road, s, NULL);
            getProjectGraph()->executeCommand(splitRoadCommand);

            getProjectData()->getUndoStack()->endMacro();
            return;
        }
        //		else if(tool == ODD::TTE_MOVE)
        //		{
        //			return; // does nothing
        //		}
    }

    // parent: selection //
    JunctionComponentItem::mouseReleaseEvent(event); // pass to baseclass
}
Beispiel #4
0
void
RoadSettings::on_addButton_released()
{
    // Open a dialog asking for the junction //
    //
    QStringList junctions;
    foreach (RSystemElementJunction *junction, getProjectData()->getRoadSystem()->getJunctions())
    {
        junctions.append(junction->getID());
    }
Beispiel #5
0
void
BridgeItem::init()
{
    // Hover Events //
    //
    setAcceptHoverEvents(true);
    setSelectable();
	setFlag(ItemIsFocusable);

	// Save a tunnel 
	//
	tunnel_ = dynamic_cast<Tunnel *>(bridge_);
    // Signal Editor
    //
    signalEditor_ = dynamic_cast<SignalEditor *>(getProjectGraph()->getProjectWidget()->getProjectEditor());

	// Signal Manager
	//
	signalManager_ = getProjectData()->getProjectWidget()->getMainWindow()->getSignalManager();

	// Category Size
	//
	categorySize_ = signalManager_->getCategoriesSize();

    // Context Menu //
    //

    QAction *removeRoadAction = getRemoveMenu()->addAction(tr("Bridge"));
    connect(removeRoadAction, SIGNAL(triggered()), this, SLOT(removeBridge()));

    if (getTopviewGraph()) // not for profile graph
    {
        // Text //
        //
        bridgeTextItem_ = new BridgeTextItem(this, bridge_);
        bridgeTextItem_->setZValue(1.0); // stack before siblings
    }

	road_ = bridge_->getParentRoad(); 
	closestRoad_ = road_;
	pos_ = road_->getGlobalPoint(bridge_->getSStart());

    updateColor();
    updatePosition();
    createPath();

	doPan_ = false;
	copyPan_ = false;
}
Beispiel #6
0
void
	ObjectSettings::updateS(double s)
{

	MoveRoadSectionCommand *moveSectionCommand = new MoveRoadSectionCommand(object_, s, RSystemElementRoad::DRS_ObjectSection);
	if (moveSectionCommand->isValid())
	{
		getProjectData()->getUndoStack()->beginMacro(QObject::tr("Change Start Values"));
		getProjectSettings()->executeCommand(moveSectionCommand);

		SetObjectPropertiesCommand *setPropertiesCommand = new SetObjectPropertiesCommand(object_, object_->getId(), object_->getName(), object_->getType(), object_->getT(), object_->getzOffset(), object_->getValidLength(), object_->getOrientation(), object_->getLength(), object_->getWidth(), object_->getRadius(), object_->getHeight(), object_->getHeading(), object_->getPitch(), object_->getRoll(), object_->getPole(), object_->getSStart(), object_->getRepeatLength(), object_->getRepeatDistance(), object_->getTextureFileName());
		getProjectSettings()->executeCommand(setPropertiesCommand);

		getProjectData()->getUndoStack()->endMacro();
	}

	valueChanged_ = false;

	QWidget * focusWidget = QApplication::focusWidget();
	if (focusWidget)
	{
		focusWidget->clearFocus();
	}
}
Beispiel #7
0
void
RoadTypeEditor::init()
{
    if (!roadSystemItem_)
    {
        // Root item //
        //
        roadSystemItem_ = new RoadTypeRoadSystemItem(getTopviewGraph(), getProjectData()->getRoadSystem());
        getTopviewGraph()->getScene()->addItem(roadSystemItem_);

        // Section Handle //
        //
        insertSectionHandle_ = new SectionHandle(roadSystemItem_);
        insertSectionHandle_->hide();
    }
}
Beispiel #8
0
void
ElevationSettings::on_slopeSpinBox_editingFinished()
{
    if (elevationSection_->getDegree() > 1)
    {
        updateProperties();
        return;
    }

    QList<ElevationSection *> endPointSections;
    QList<ElevationSection *> startPointSections;
    endPointSections.append(elevationSection_);
    ElevationSection *sectionNext = elevationSection_->getParentRoad()->getElevationSectionNext(elevationSection_->getSStart());
    if (sectionNext)
    {
        if (sectionNext->getDegree() > 1)
        {
            return;
        }
        else
        {
            startPointSections.append(sectionNext);
        }
    }

    // Command //
    //
    double s = 100 * abs(elevationSection_->getElevation(elevationSection_->getSStart()) - elevationSection_->getElevation(elevationSection_->getSEnd())) / ui->slopeSpinBox->value() + elevationSection_->getSStart();
    if (s < elevationSection_->getParentRoad()->getLength())
    {
        QPointF dPos = QPointF(s - sectionNext->getSStart(), 0.0);
        ElevationMovePointsCommand *command = new ElevationMovePointsCommand(endPointSections, startPointSections, dPos, NULL);

        if (command->isValid())
        {
            getProjectData()->getUndoStack()->push(command);
        }
        else
        {
            delete command;
        }
    }
}
Beispiel #9
0
void
ElevationSettings::on_sSpinBox_editingFinished()
{
    if (elevationSection_->getDegree() > 1)
    {
        updateProperties();
        return;
    }

    QList<ElevationSection *> endPointSections;
    QList<ElevationSection *> startPointSections;
    startPointSections.append(elevationSection_);
    ElevationSection *sectionBefore = elevationSection_->getParentRoad()->getElevationSectionBefore(elevationSection_->getSStart());

    if (sectionBefore)
    {
        if (sectionBefore->getDegree() > 1)
        {
            updateProperties();
            return;
        }
        else
        {
            endPointSections.append(sectionBefore);
        }
    }

    // Command //
    //
    QPointF dPos = QPointF(ui->sSpinBox->value() - elevationSection_->getSStart(), 0.0);
    ElevationMovePointsCommand *command = new ElevationMovePointsCommand(endPointSections, startPointSections, dPos, NULL);

    if (command->isValid())
    {
        getProjectData()->getUndoStack()->push(command);
    }
    else
    {
        delete command;
    }
}
Beispiel #10
0
/*! \brief .
*
*/
void
RoadTypeEditor::toolAction(ToolAction *toolAction)
{
    // Parent //
    //
    ProjectEditor::toolAction(toolAction);

    if (getCurrentTool() == ODD::TRT_SELECT)
    {
        // does nothing //
    }
    else if (getCurrentTool() == ODD::TRT_ADD)
    {
        // does nothing //
    }
    else if (getCurrentTool() == ODD::TRT_DEL)
    {
        // Problem: The ToolAction is resent, after a warning message has been clicked away. (Due to resend on getting the focus back?)

        //		QList<QGraphicsItem *> selectedItems = getTopviewGraph()->graphScene()->selectedItems();
        //
        //		// Macro Command //
        //		//
        //		int numberOfSelectedItems = selectedItems.size();
        //		if(numberOfSelectedItems > 1)
        //		{
        //			getProjectData()->getUndoStack()->beginMacro(QObject::tr("Delete Road Type Sections"));
        //		}
        //
        //		// Delete selected items //
        //		//
        //		foreach(QGraphicsItem * item, getTopviewGraph()->graphScene()->selectedItems())
        //		{
        //			TypeSectionItem * typeSectionItem = dynamic_cast<TypeSectionItem *>(item);
        //			if(typeSectionItem)
        //			{
        //				typeSectionItem->setSelected(false);
        //				typeSectionItem->deleteTypeSection();
        //			}
        //		}
        //
        //		// Macro Command //
        //		//
        //		if(numberOfSelectedItems > 1)
        //		{
        //			getProjectData()->getUndoStack()->endMacro();
        //		}
    }

    // RoadType //
    //
    TypeEditorToolAction *typeEditorToolAction = dynamic_cast<TypeEditorToolAction *>(toolAction);
    if (typeEditorToolAction)
    {
        // Set RoadType //
        //
        TypeSection::RoadType roadType = typeEditorToolAction->getRoadType();
        if (roadType != TypeSection::RTP_NONE)
        {
            if (typeEditorToolAction->isApplyingRoadType())
            {
                QList<QGraphicsItem *> selectedItems = getTopviewGraph()->getScene()->selectedItems();

                // Macro Command //
                //
                int numberOfSelectedItems = selectedItems.size();
                if (numberOfSelectedItems > 1)
                {
                    getProjectData()->getUndoStack()->beginMacro(QObject::tr("Set Road Type"));
                }

                // Change types of selected items //
                //
                foreach (QGraphicsItem *item, selectedItems)
                {
                    TypeSectionItem *typeSectionItem = dynamic_cast<TypeSectionItem *>(item);
                    if (typeSectionItem)
                    {
                        typeSectionItem->changeRoadType(roadType);
                    }
                }

                // Macro Command //
                //
                if (numberOfSelectedItems > 1)
                {
                    getProjectData()->getUndoStack()->endMacro();
                }
            }
            else
            {
Beispiel #11
0
BOOL CConfigData::bGetCurrProjInfo(ProjectData& ProjData)
{
    return getProjectData(m_strCurrProjName, ProjData);
}