void SectionItem::init() { road_ = roadSection_->getParentRoad(); // Observer Pattern // // road_->attachObserver(this); // SectionHandle (Start) // // if (getTopviewGraph()) // not for profilegraph { sectionHandle_ = new SectionHandle(this); sectionHandle_->setPos(road_->getGlobalPoint(roadSection_->getSStart())); sectionHandle_->setRotation(road_->getGlobalHeading(roadSection_->getSStart())); } // ContextMenu // // hideSectionAction_ = getHideMenu()->addAction(tr("Section")); connect(hideSectionAction_, SIGNAL(triggered()), this, SLOT(hideGraphElement())); hideParentRoadAction_ = getHideMenu()->addAction(tr("Road")); connect(hideParentRoadAction_, SIGNAL(triggered()), this, SLOT(hideParentRoad())); removeSectionAction_ = getRemoveMenu()->addAction(tr("Section")); connect(removeSectionAction_, SIGNAL(triggered()), this, SLOT(removeSection())); removeParentRoadAction_ = getRemoveMenu()->addAction(tr("Road")); connect(removeParentRoadAction_, SIGNAL(triggered()), this, SLOT(removeParentRoad())); }
void JunctionElementItem::init() { // Selection/Highlighting // // setAcceptHoverEvents(true); if (getParentJunctionComponentItem()) { setFlag(QGraphicsItem::ItemIsMovable, false); // move the whole group } else { setFlag(QGraphicsItem::ItemIsMovable, true); } // Color & Path // // updateColor(); createPath(); // ContextMenu // // QAction *hideAction = getHideMenu()->addAction(tr("Track")); connect(hideAction, SIGNAL(triggered()), this, SLOT(hideGraphElement())); if (getParentJunctionComponentItem()) { QAction *hideParentTrackComponentAction = getHideMenu()->addAction(tr("Group")); connect(hideParentTrackComponentAction, SIGNAL(triggered()), this, SLOT(hideParentTrackComponent())); QAction *ungroupAction = getContextMenu()->addAction("Ungroup"); connect(ungroupAction, SIGNAL(triggered()), getParentJunctionComponentItem(), SLOT(ungroupComposite())); } QAction *hideRoadAction = getHideMenu()->addAction(tr("Road")); connect(hideRoadAction, SIGNAL(triggered()), this, SLOT(hideParentRoad())); QAction *removeSectionAction = getRemoveMenu()->addAction(tr("Track(s)")); connect(removeSectionAction, SIGNAL(triggered()), this, SLOT(removeSection())); QAction *removeRoadAction = getRemoveMenu()->addAction(tr("Road")); connect(removeRoadAction, SIGNAL(triggered()), this, SLOT(removeParentRoad())); }
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; }
void OSCItem::init() { // Hover Events // // setAcceptHoverEvents(true); // setSelectable(); setFlag(QGraphicsItem::ItemIsSelectable); setFlag(ItemIsFocusable); // OpenScenario Editor // oscEditor_ = dynamic_cast<OpenScenarioEditor *>(getProjectGraph()->getProjectWidget()->getProjectEditor()); // Context Menu // // QAction *removeElementAction = getRemoveMenu()->addAction(tr("OpenScenario Object")); connect(removeElementAction, SIGNAL(triggered()), this, SLOT(removeElement())); if (getTopviewGraph()) // not for profile graph { // Text // // oscTextItem_ = new OSCTextItem(this, oscObject_, pos_); oscTextItem_->setZValue(1.0); // stack before siblings } road_ = getProjectGraph()->getProjectData()->getRoadSystem()->getRoad(roadID_); closestRoad_ = road_; roadSystemItem_ = oscBaseItem_->getRoadSystemItem(); doPan_ = false; copyPan_ = false; // TODO: get type and object from catalog reference // // const std::string refId = oscObject_->catalogReference->catalogId.getValue(); OpenScenario::oscEntity *entityObject = dynamic_cast<OpenScenario::oscEntity *>(entityCatalog_->getCatalogObject(stoi(refId))); OpenScenario::oscCatalog *catalog; int id = entityObject->objectChoice->vehicle->refId.getValue(); if (id > 0) { createPath = createVehiclePath; catalog = oscEditor_->getCatalog("vehicleCatalog"); catalog->setCatalogType("vehicle"); } if (catalog->getObjectsMap().size() == 0) { //get all catalog object filenames std::vector<bf::path> filenames = catalog->getXoscFilesFromDirectory(catalog->directory->path.getValue()); //parse all files //store object name and filename in map catalog->fastReadCatalogObjects(filenames); } selectedObject_ = catalog->getCatalogObject(id); if (!selectedObject_) { catalog->fullReadCatalogObjectWithName(id); selectedObject_ = catalog->getCatalogObject(id); } createPath(selectedObject_); updateColor("oscVehicle"); updatePosition(); }