Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNEAdditional.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// A abstract class for representation of additional elements
19/****************************************************************************/
20#include <config.h>
21
23#include <netedit/GNENet.h>
24#include <netedit/GNESegment.h>
43
44#include "GNEAdditional.h"
45#include "GNETAZ.h"
46
47// ===========================================================================
48// member method definitions
49// ===========================================================================
50
51GNEAdditional::GNEAdditional(const std::string& id, GNENet* net, const std::string& filename,
52 SumoXMLTag tag, const std::string& additionalName) :
53 GNEAttributeCarrier(tag, net, filename, id.empty()),
54 GUIGlObject(net->getTagPropertiesDatabase()->getTagProperty(tag, true)->getGLType(), id,
55 GUIIconSubSys::getIcon(net->getTagPropertiesDatabase()->getTagProperty(tag, true)->getGUIIcon())),
56 GNEPathElement(GNEPathElement::Options::ADDITIONAL_ELEMENT),
57 myAdditionalName(additionalName) {
58}
59
60
61GNEAdditional::GNEAdditional(GNEAdditional* additionalParent, SumoXMLTag tag, const std::string& additionalName) :
62 GNEAttributeCarrier(tag, additionalParent->getNet(), additionalParent->getFilename(), false),
63 GUIGlObject(additionalParent->getNet()->getTagPropertiesDatabase()->getTagProperty(tag, true)->getGLType(), additionalParent->getID(),
64 GUIIconSubSys::getIcon(additionalParent->getNet()->getTagPropertiesDatabase()->getTagProperty(tag, true)->getGUIIcon())),
65 GNEPathElement(GNEPathElement::Options::ADDITIONAL_ELEMENT),
66 myAdditionalName(additionalName) {
67}
68
69
71
72
77
78
79void
80GNEAdditional::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
81 // currently there isn't additionals with removable geometry points
82}
83
84
87 return this;
88}
89
90
91const GUIGlObject*
93 return this;
94}
95
96
97const std::string
99 try {
101 } catch (InvalidArgument&) {
102 return "";
103 }
104}
105
106
107const GUIGeometry&
111
112
113void
117
118
119void
123
124
125bool
127 return true;
128}
129
130
131std::string
133 return "";
134}
135
136
137void
139 throw InvalidArgument(getTagStr() + " cannot fix any problem");
140}
141
142
143void
145 throw InvalidArgument(getTagStr() + " doesn't have an additional dialog");
146}
147
148
149double
153
154
159 } else {
161 if (contourBoundary.isInitialised()) {
162 contourBoundary.grow(5);
163 return contourBoundary;
164 } else if (myAdditionalGeometry.getShape().size() > 0) {
166 geometryBoundary.grow(5);
167 return geometryBoundary;
168 } else if (getParentAdditionals().size() > 0) {
169 return getParentAdditionals().front()->getCenteringBoundary();
170 } else {
171 Boundary centerBoundary(0, 0, 0, 0);
172 centerBoundary.grow(5);
173 return centerBoundary;
174 }
175 }
176}
177
178
179bool
181 // get modes and viewParent (for code legibility)
182 const auto& modes = myNet->getViewNet()->getEditModes();
183 const auto& viewParent = myNet->getViewNet()->getViewParent();
184 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
185 // continue depending of current status
186 if (inspectedElements.isInspectingSingleElement()) {
187 const auto inspectedAC = inspectedElements.getFirstAC();
188 // check conditions
189 if (inspectedAC->hasAttribute(SUMO_ATTR_FROM_TAZ)) {
190 return (inspectedAC->getAttribute(SUMO_ATTR_FROM_TAZ) == getID());
191 } else if ((inspectedAC->getTagProperty()->getTag() == SUMO_TAG_TAZREL)) {
192 return (inspectedAC->getAttribute(SUMO_ATTR_FROM) == getID());
193 }
194 } else if (modes.isCurrentSupermodeDemand()) {
195 // get current GNEPlanCreator
196 GNEPlanCreator* planCreator = nullptr;
197 if (modes.demandEditMode == DemandEditMode::DEMAND_PERSON) {
198 planCreator = viewParent->getPersonFrame()->getPlanCreator();
199 } else if (modes.demandEditMode == DemandEditMode::DEMAND_PERSONPLAN) {
200 planCreator = viewParent->getPersonPlanFrame()->getPlanCreator();
201 } else if (modes.demandEditMode == DemandEditMode::DEMAND_CONTAINER) {
202 planCreator = viewParent->getContainerFrame()->getPlanCreator();
203 } else if (modes.demandEditMode == DemandEditMode::DEMAND_CONTAINERPLAN) {
204 planCreator = viewParent->getContainerPlanFrame()->getPlanCreator();
205 }
206 // continue depending of planCreator
207 if (planCreator) {
208 // check if this is the from additional
209 const auto additionalID = getID();
210 if ((planCreator->getPlanParameteres().fromBusStop == additionalID) ||
211 (planCreator->getPlanParameteres().fromTrainStop == additionalID) ||
212 (planCreator->getPlanParameteres().fromContainerStop == additionalID) ||
213 (planCreator->getPlanParameteres().fromChargingStation == additionalID) ||
214 (planCreator->getPlanParameteres().fromParkingArea == additionalID) ||
215 (planCreator->getPlanParameteres().fromTAZ == additionalID)) {
216 return true;
217 }
218 } else if (modes.demandEditMode == DemandEditMode::DEMAND_VEHICLE) {
219 // get selected TAZs
220 const auto& selectedTAZs = viewParent->getVehicleFrame()->getPathCreator()->getSelectedTAZs();
221 // check if this is the first selected TAZ
222 if ((selectedTAZs.size() > 0) && (selectedTAZs.front() == this)) {
223 return true;
224 }
225 }
226 } else if (modes.isCurrentSupermodeData()) {
227 // get TAZRelDataFrame
228 const auto& TAZRelDataFrame = viewParent->getTAZRelDataFrame();
229 if (TAZRelDataFrame->shown() && (TAZRelDataFrame->getFirstTAZ() == this)) {
230 return true;
231 }
232 }
233 // nothing to draw
234 return false;
235}
236
237
238bool
240 // get modes and viewParent (for code legibility)
241 const auto& modes = myNet->getViewNet()->getEditModes();
242 const auto& viewParent = myNet->getViewNet()->getViewParent();
243 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
244 // check conditions
246 return false;
247 } else if (inspectedElements.isInspectingSingleElement()) {
248 const auto inspectedAC = inspectedElements.getFirstAC();
249 // check conditions
250 if (inspectedAC->hasAttribute(SUMO_ATTR_TO_TAZ)) {
251 return (inspectedAC->getAttribute(SUMO_ATTR_TO_TAZ) == getID());
252 } else if (inspectedAC->getTagProperty()->getTag() == SUMO_TAG_TAZREL) {
253 return (inspectedAC->getAttribute(SUMO_ATTR_TO) == getID());
254 } else if (inspectedAC->hasAttribute(GNE_ATTR_PARENT)) {
255 // check all parent tags
256 const auto& parentTags = inspectedAC->getTagProperty()->getXMLParentTags();
257 if (std::find(parentTags.begin(), parentTags.end(), myTagProperty->getTag()) != parentTags.end()) {
258 return (inspectedAC->getAttribute(GNE_ATTR_PARENT) == getID());
259 }
260 }
261 } else if (modes.isCurrentSupermodeDemand()) {
262 // get current GNEPlanCreator
263 GNEPlanCreator* planCreator = nullptr;
264 if (modes.demandEditMode == DemandEditMode::DEMAND_PERSON) {
265 planCreator = viewParent->getPersonFrame()->getPlanCreator();
266 } else if (modes.demandEditMode == DemandEditMode::DEMAND_PERSONPLAN) {
267 planCreator = viewParent->getPersonPlanFrame()->getPlanCreator();
268 } else if (modes.demandEditMode == DemandEditMode::DEMAND_CONTAINER) {
269 planCreator = viewParent->getContainerFrame()->getPlanCreator();
270 } else if (modes.demandEditMode == DemandEditMode::DEMAND_CONTAINERPLAN) {
271 planCreator = viewParent->getContainerPlanFrame()->getPlanCreator();
272 }
273 // continue depending of planCreator
274 if (planCreator) {
275 // check if this is the from additional
276 const auto additionalID = getID();
277 if ((planCreator->getPlanParameteres().toBusStop == additionalID) ||
278 (planCreator->getPlanParameteres().toTrainStop == additionalID) ||
279 (planCreator->getPlanParameteres().toContainerStop == additionalID) ||
280 (planCreator->getPlanParameteres().toChargingStation == additionalID) ||
281 (planCreator->getPlanParameteres().toParkingArea == additionalID) ||
282 (planCreator->getPlanParameteres().toTAZ == additionalID)) {
283 return true;
284 }
285 } else if (modes.demandEditMode == DemandEditMode::DEMAND_VEHICLE) {
286 // get selected TAZs
287 const auto& selectedTAZs = viewParent->getVehicleFrame()->getPathCreator()->getSelectedTAZs();
288 // check if this is the first selected TAZ
289 if ((selectedTAZs.size() > 1) && (selectedTAZs.back() == this)) {
290 return true;
291 }
292 }
293 } else if (modes.isCurrentSupermodeData()) {
294 // get TAZRelDataFrame
295 const auto& TAZRelDataFrame = viewParent->getTAZRelDataFrame();
296 if (TAZRelDataFrame->shown() && (TAZRelDataFrame->getSecondTAZ() == this)) {
297 return true;
298 }
299 }
300 // nothing to draw
301 return false;
302}
303
304
305bool
307 const auto& neteditAttributesEditor = myNet->getViewNet()->getViewParent()->getInspectorFrame()->getAttributesEditor();
308 if (neteditAttributesEditor->isReparenting()) {
309 return neteditAttributesEditor->checkNewParent(this);
310 }
311 // check opened popup
312 if (myNet->getViewNet()->getPopup()) {
313 return myNet->getViewNet()->getPopup()->getGLObject() == this;
314 }
315 return false;
316}
317
318
319bool
321 const auto& modes = myNet->getViewNet()->getEditModes();
323 return false;
324 } else {
325 const auto& viewParent = myNet->getViewNet()->getViewParent();
326 if (modes.isCurrentSupermodeDemand()) {
327 // get current plan selector
328 GNEPlanSelector* planSelector = nullptr;
329 if (modes.demandEditMode == DemandEditMode::DEMAND_PERSON) {
330 planSelector = viewParent->getPersonFrame()->getPlanSelector();
331 } else if (modes.demandEditMode == DemandEditMode::DEMAND_PERSONPLAN) {
332 planSelector = viewParent->getPersonPlanFrame()->getPlanSelector();
333 } else if (modes.demandEditMode == DemandEditMode::DEMAND_CONTAINER) {
334 planSelector = viewParent->getContainerFrame()->getPlanSelector();
335 } else if (modes.demandEditMode == DemandEditMode::DEMAND_CONTAINERPLAN) {
336 planSelector = viewParent->getContainerPlanFrame()->getPlanSelector();
337 }
338 // continue depending of plan selector
339 if (planSelector) {
340 if ((myTagProperty->isStoppingPlace() && planSelector->markStoppingPlaces()) ||
341 (myTagProperty->isTAZElement() && planSelector->markTAZs())) {
342 return true;
343 }
344 } else if (modes.demandEditMode == DemandEditMode::DEMAND_VEHICLE) {
345 // get current vehicle template
346 const auto& vehicleTemplate = viewParent->getVehicleFrame()->getVehicleTagSelector()->getCurrentTemplateAC();
347 // check if vehicle can be placed over from-to TAZs
348 if (vehicleTemplate && vehicleTemplate->getTagProperty()->vehicleTAZs()) {
349 return true;
350 }
351 }
352 } else if (modes.isCurrentSupermodeData()) {
353 // get TAZRelDataFrame
354 const auto& TAZRelDataFrame = viewParent->getTAZRelDataFrame();
355 if (TAZRelDataFrame->shown()) {
356 if (TAZRelDataFrame->getFirstTAZ() && TAZRelDataFrame->getSecondTAZ()) {
357 return false;
358 } else if (TAZRelDataFrame->getFirstTAZ() == this) {
359 return false;
360 } else if (TAZRelDataFrame->getSecondTAZ() == this) {
361 return false;
362 } else {
363 return true;
364 }
365 }
366 }
367 return false;
368 }
369}
370
371
372bool
374 // get edit modes
375 const auto& editModes = myNet->getViewNet()->getEditModes();
376 // check if we're in delete mode
377 if (editModes.isCurrentSupermodeNetwork() && (editModes.networkEditMode == NetworkEditMode::NETWORK_DELETE)) {
379 } else {
380 return false;
381 }
382}
383
384
385bool
387 // get edit modes
388 const auto& editModes = myNet->getViewNet()->getEditModes();
389 // check if we're in delete mode and this additional has a parent
390 if (editModes.isCurrentSupermodeNetwork() && (editModes.networkEditMode == NetworkEditMode::NETWORK_DELETE) && (getParentAdditionals().size() > 0)) {
391 const auto additional = myNet->getViewNet()->getViewObjectsSelector().getAdditionalFront();
392 if (additional && (additional == myNet->getViewNet()->getViewObjectsSelector().getAttributeCarrierFront())) {
393 return (getParentAdditionals().front() == additional);
394 }
395 }
396 return false;
397}
398
399
400bool
402 // get edit modes
403 const auto& editModes = myNet->getViewNet()->getEditModes();
404 // check if we're in select mode
405 if (editModes.isCurrentSupermodeNetwork() && (editModes.networkEditMode == NetworkEditMode::NETWORK_SELECT)) {
407 } else {
408 return false;
409 }
410}
411
412
415 // create popup
416 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
417 // build common options
419 // show option to open additional dialog
420 if (myTagProperty->hasDialog()) {
421 GUIDesigns::buildFXMenuCommand(ret, TL("Open ") + getTagStr() + TL(" Dialog"), getACIcon(), &parent, MID_OPEN_ADDITIONAL_DIALOG);
422 new FXMenuSeparator(ret);
423 }
424 // Show position parameters
427 // Show menu command inner position
429 GUIDesigns::buildFXMenuCommand(ret, TL("Cursor position over additional shape: ") + toString(innerPos), nullptr, nullptr, 0);
430 // If shape isn't empty, show menu command lane position
431 if (myAdditionalGeometry.getShape().size() > 0) {
432 const double lanePos = lane->getLaneShape().nearest_offset_to_point2D(myAdditionalGeometry.getShape().front());
433 GUIDesigns::buildFXMenuCommand(ret, TL("Cursor position over lane: ") + toString(innerPos + lanePos), nullptr, nullptr, 0);
434 }
437 // Show menu command inner position
439 GUIDesigns::buildFXMenuCommand(ret, TL("Cursor position over additional shape: ") + toString(innerPos), nullptr, nullptr, 0);
440 // If shape isn't empty, show menu command edge position
441 if (myAdditionalGeometry.getShape().size() > 0) {
442 const double edgePos = edge->getChildLanes().at(0)->getLaneShape().nearest_offset_to_point2D(myAdditionalGeometry.getShape().front());
443 GUIDesigns::buildFXMenuCommand(ret, TL("Mouse position over edge: ") + toString(innerPos + edgePos), nullptr, nullptr, 0);
444 }
445 } else {
446 const auto mousePos = myNet->getViewNet()->getPositionInformation();
447 GUIDesigns::buildFXMenuCommand(ret, TL("Cursor position in view: ") + toString(mousePos.x()) + "," + toString(mousePos.y()), nullptr, nullptr, 0);
448 }
449 return ret;
450}
451
452
455 // Create table
457 // Iterate over attributes
458 for (const auto& attributeProperty : myTagProperty->getAttributeProperties()) {
459 // Add attribute and set it dynamic if aren't unique
460 if (attributeProperty->isUnique()) {
461 ret->mkItem(attributeProperty->getAttrStr().c_str(), false, getAttribute(attributeProperty->getAttr()));
462 } else {
463 ret->mkItem(attributeProperty->getAttrStr().c_str(), true, getAttribute(attributeProperty->getAttr()));
464 }
465 }
466 // close building
467 ret->closeBuilding();
468 return ret;
469}
470
471
472const std::string&
476
477
478bool
486
487
488void
492
493
494void
498
499
500void
510
511
515
516
517void
519 // Nothing to compute
520}
521
522
523bool
527
528
529void
530GNEAdditional::drawLanePartialGL(const GUIVisualizationSettings& /*s*/, const GNESegment* /*segment*/, const double /*offsetFront*/) const {
531 // Nothing to draw
532}
533
534
535void
536GNEAdditional::drawJunctionPartialGL(const GUIVisualizationSettings& /*s*/, const GNESegment* /*segment*/, const double /*offsetFront*/) const {
537 // Nothing to draw
538}
539
540// ---------------------------------------------------------------------------
541// GNEAdditional - protected methods
542// ---------------------------------------------------------------------------
543
544bool
545GNEAdditional::isValidAdditionalID(const std::string& value) const {
546 if (!isTemplate() && (value == getID())) {
547 return true;
548 } else if (SUMOXMLDefinitions::isValidAdditionalID(value)) {
549 return (myNet->getAttributeCarriers()->retrieveAdditional(myTagProperty->getTag(), value, false) == nullptr);
550 } else {
551 return false;
552 }
553}
554
555
556bool
557GNEAdditional::isValidAdditionalID(const std::vector<SumoXMLTag>& tags, const std::string& value) const {
558 if (isTemplate() && value.empty()) {
559 return true;
560 } else if (!isTemplate() && (value == getID())) {
561 return true;
562 } else if (SUMOXMLDefinitions::isValidAdditionalID(value)) {
563 return (myNet->getAttributeCarriers()->retrieveAdditionals(tags, value, false) == nullptr);
564 } else {
565 return false;
566 }
567}
568
569
570bool
571GNEAdditional::isValidDetectorID(const std::string& value) const {
572 if (isTemplate() && value.empty()) {
573 return true;
574 } else if (!isTemplate() && (value == getID())) {
575 return true;
576 } else if (SUMOXMLDefinitions::isValidDetectorID(value)) {
577 return (myNet->getAttributeCarriers()->retrieveAdditional(myTagProperty->getTag(), value, false) == nullptr);
578 } else {
579 return false;
580 }
581}
582
583
584bool
585GNEAdditional::isValidDetectorID(const std::vector<SumoXMLTag>& tags, const std::string& value) const {
586 if (!isTemplate() && (value == getID())) {
587 return true;
588 } else if (SUMOXMLDefinitions::isValidDetectorID(value)) {
589 return (myNet->getAttributeCarriers()->retrieveAdditionals(tags, value, false) == nullptr);
590 } else {
591 return false;
592 }
593}
594
595
596void
597GNEAdditional::setAdditionalID(const std::string& newID) {
598 // update ID
599 if (isTemplate()) {
600 setMicrosimID(newID);
602 setMicrosimID(newID);
603 } else {
605 }
606 // change IDs of certain children
607 for (const auto& additionalChild : getChildAdditionals()) {
608 // get tag
609 const auto tag = additionalChild->getTagProperty()->getTag();
610 if ((tag == SUMO_TAG_ACCESS) || (tag == SUMO_TAG_PARKING_SPACE) ||
611 (tag == SUMO_TAG_DET_ENTRY) || (tag == SUMO_TAG_DET_EXIT)) {
612 additionalChild->setAdditionalID(getID());
613 }
614 }
615 // enable save demand elements if this additional has children
616 if (getChildDemandElements().size() > 0) {
618 }
619 // enable save data elements if this additional has children
620 if (getChildGenericDatas().size() > 0) {
622 }
623}
624
625
626void
628 if (s.addName.show(this) && (myAdditionalGeometry.getShape().size() > 0)) {
629 // calculate middle point
630 const double middlePoint = (myAdditionalGeometry.getShape().length2D() * 0.5);
631 // calculate position
633 // calculate rotation
635 // draw additional ID
638 } else {
640 }
641 }
642}
643
644
645void
647 if (s.addFullName.show(this) && (myAdditionalGeometry.getShape().size() > 0) && (myAdditionalName != "")) {
648 // calculate middle point
649 const double middlePoint = (myAdditionalGeometry.getShape().length2D() * 0.5);
650 // calculate position
652 // calculate rotation
654 // draw additional name
657 } else {
659 }
660 }
661}
662
663
664void
668
669
670void
675
676
677void
681
682
683void
688
689
690void
691GNEAdditional::replaceAdditionalParent(SumoXMLTag tag, const std::string& value, const int parentIndex) {
692 std::vector<GNEAdditional*> newParentAdditionals;
693 // special case for calibrators and routeprobes
694 if (value.size() > 0) {
695 newParentAdditionals = getParentAdditionals();
696 if ((newParentAdditionals.size() == 0) && (parentIndex == 0)) {
697 newParentAdditionals.push_back(myNet->getAttributeCarriers()->retrieveAdditional(tag, value));
698 } else {
699 newParentAdditionals[parentIndex] = myNet->getAttributeCarriers()->retrieveAdditional(tag, value);
700 }
701 }
702 GNEHierarchicalElement::updateParents(this, newParentAdditionals);
703}
704
705
706void
707GNEAdditional::replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex) {
708 auto newDemandElement = myNet->getAttributeCarriers()->retrieveDemandElement(tag, value);
709 GNEHierarchicalElement::updateParent(this, parentIndex, newDemandElement);
710}
711
712
713void
715 const std::vector<GNELane*> newLanes = {getParentLanes().front()->getParentEdge()->getChildLanes().at(getParentLanes().front()->getIndex() + 1)};
717}
718
719
720void
721GNEAdditional::calculatePerpendicularLine(const double endLaneposition) {
722 if (getParentEdges().empty()) {
723 throw ProcessError(TL("Invalid number of edges"));
724 } else {
725 // get lanes
726 const GNELane* firstLane = getParentEdges().front()->getChildLanes().front();
727 const GNELane* lastLane = getParentEdges().front()->getChildLanes().back();
728 // get first and back lane shapes
729 PositionVector firstLaneShape = firstLane->getLaneShape();
730 PositionVector lastLaneShape = lastLane->getLaneShape();
731 // move shapes
732 firstLaneShape.move2side((firstLane->getParentEdge()->getNBEdge()->getLaneWidth(firstLane->getIndex()) * 0.5) + 1);
733 lastLaneShape.move2side(lastLane->getParentEdge()->getNBEdge()->getLaneWidth(lastLane->getIndex()) * -0.5);
734 // calculate lane postion
735 const double lanePosition = firstLaneShape.length2D() >= endLaneposition ? endLaneposition : firstLaneShape.length2D();
736 // update geometry
737 myAdditionalGeometry.updateGeometry({firstLaneShape.positionAtOffset2D(lanePosition), lastLaneShape.positionAtOffset2D(lanePosition)});
738 }
739}
740
741
742void
743GNEAdditional::drawSquaredAdditional(const GUIVisualizationSettings& s, const Position& pos, const double size, GUITexture texture, GUITexture selectedTexture) const {
744 // draw boundaries
746 // Obtain drawing exaggeration
747 const double exaggeration = getExaggeration(s);
748 // get detail level
749 const auto d = s.getDetailLevel(exaggeration);
750 // draw geometry only if we'rent in drawForObjectUnderCursor mode
752 // Add layer matrix
754 // translate to front
756 // translate to position
757 glTranslated(pos.x(), pos.y(), 0);
758 // scale
759 glScaled(exaggeration, exaggeration, 1);
760 // set White color
761 glColor3d(1, 1, 1);
762 // rotate
763 glRotated(180, 0, 0, 1);
764 // draw texture
765 if (drawUsingSelectColor()) {
767 } else {
769 }
770 // Pop layer matrix
772 // draw lock icon
773 GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), pos, exaggeration, 0.4, 0.5, 0.5);
774 // Draw additional ID
776 // draw additional name
778 // draw dotted contour
780 }
781 // calculate contour
782 myAdditionalContour.calculateContourRectangleShape(s, d, this, pos, size, size, getType(), 0, 0, 0, exaggeration, nullptr);
783}
784
785
786void
787GNEAdditional::drawListedAdditional(const GUIVisualizationSettings& s, const Position& parentPosition, const double offsetX,
788 const double extraOffsetY, const RGBColor baseCol, const RGBColor textCol, GUITexture texture,
789 const std::string text) const {
790 // check if additional has to be drawn
792 // draw boundaries
794 // get detail level
795 const auto d = s.getDetailLevel(1);
796 // declare offsets
797 const double lineOffset = 0.1875;
798 const double baseOffsetX = 6.25;
799 const double baseOffsetY = 0.6;
800 // get draw position index
801 const int drawPositionIndex = getDrawPositionIndex();
802 // calculate lineA position (from parent to middle)
803 Position positionLineA = parentPosition;
804 const double positionLineA_Y = (0 - extraOffsetY + baseOffsetY);
805 // set position depending of indexes
806 positionLineA.add(1 + lineOffset + (baseOffsetX * offsetX), positionLineA_Y, 0);
807 // calculate lineC position (From middle until current listenAdditional
808 Position positionLineB = parentPosition;
809 const double positionLineB_Y = ((drawPositionIndex * -1) - extraOffsetY + baseOffsetY);
810 // set position depending of indexes
811 positionLineB.add(1 + lineOffset + (baseOffsetX * offsetX) + (2 * lineOffset), positionLineB_Y, 0);
812 // calculate signPosition position
813 Position signPosition = parentPosition;
814 // draw geometry only if we'rent in drawForObjectUnderCursor mode
816 // set position depending of indexes
817 signPosition.add(4.5 + (baseOffsetX * offsetX), (drawPositionIndex * -1) - extraOffsetY + 1, 0);
818 // calculate colors
820 const RGBColor secondColor = baseColor.changedBrightness(-30);
822 // Add layer matrix
824 // translate to front
826 // set line color
828 // draw both lines
829 GLHelper::drawBoxLine(positionLineA, 0, 0.1, lineOffset);
830 GLHelper::drawBoxLine(positionLineB, 0, 0.1, lineOffset);
831 // check if draw middle lane
832 if (drawPositionIndex != 0) {
833 // calculate length
834 const double length = std::abs(positionLineA_Y - positionLineB_Y);
835 // push middle lane matrix
837 //move and rotate
838 glTranslated(positionLineA.x() + lineOffset, positionLineA.y(), 0);
839 glRotated(90, 0, 0, 1);
840 glTranslated((length * -0.5), 0, 0);
841 // draw line
842 GLHelper::drawBoxLine(Position(0, 0), 0, 0.1, length * 0.5);
843 // pop middle lane matrix
845 }
846 // draw extern rectangle
847 GLHelper::setColor(secondColor);
848 GLHelper::drawBoxLine(signPosition, 0, 0.96, 2.75);
849 // move to front
850 glTranslated(0, -0.06, 0.1);
851 // draw intern rectangle
852 GLHelper::setColor(baseColor);
853 GLHelper::drawBoxLine(signPosition, 0, 0.84, 2.69);
854 // move position down
855 signPosition.add(-2, -0.43, 0);
856 // draw interval
857 GLHelper::drawText(adjustListedAdditionalText(text), signPosition, .1, 0.5, textColor, 0, (FONS_ALIGN_LEFT | FONS_ALIGN_MIDDLE));
858 // move to icon position
859 signPosition.add(-0.3, 0);
860 // check if draw lock icon or rerouter interval icon
862 // pop layer matrix
864 // draw lock icon
865 GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), signPosition, 1, 0.4, 0.0, -0.05);
866 } else {
867 // translate to front
868 glTranslated(signPosition.x(), signPosition.y(), 0.1);
869 // set White color
870 glColor3d(1, 1, 1);
871 // rotate
872 glRotated(180, 0, 0, 1);
873 // draw texture
875 // pop layer matrix
877 }
878 // draw dotted contour
880 }
881 // calculate contour
882 myAdditionalContour.calculateContourRectangleShape(s, d, this, signPosition, 0.56, 2.75, getType(), 0, -2.3, 0, 1, nullptr);
883 }
884}
885
886
887bool
888GNEAdditional::drawMovingGeometryPoints(const bool ignoreShift) const {
889 // get modes
890 const auto& modes = myNet->getViewNet()->getEditModes();
891 // check conditions
892 if (modes.isCurrentSupermodeNetwork() && (modes.networkEditMode == NetworkEditMode::NETWORK_MOVE) &&
893 (ignoreShift || myNet->getViewNet()->getMouseButtonKeyPressed().shiftKeyPressed())) {
894 return true;
895 } else {
896 return false;
897 }
898}
899
900
901void
903 // draw child demand elements
904 for (const auto& demandElement : getChildDemandElements()) {
905 if (!demandElement->getTagProperty()->isPlacedInRTree()) {
906 demandElement->drawGL(s);
907 }
908 }
909}
910
911
913GNEAdditional::getMoveOperationSingleLane(const double startPos, const double endPos) {
914 // get allow change lane
915 const bool allowChangeLane = myNet->getViewNet()->getViewParent()->getMoveFrame()->getCommonMoveOptions()->getAllowChangeLane();
916 // fist check if we're moving only extremes
918 // get snap radius
920 // get mouse position
921 const Position mousePosition = myNet->getViewNet()->getPositionInformation();
922 // check if we clicked over start or end position
923 if (myAdditionalGeometry.getShape().front().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
924 // move only start position
925 return new GNEMoveOperation(this, getParentLanes().front(), startPos, endPos,
927 } else if (myAdditionalGeometry.getShape().back().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
928 // move only end position
929 return new GNEMoveOperation(this, getParentLanes().front(), startPos, endPos,
931 } else {
932 return nullptr;
933 }
934 } else {
935 // move both start and end positions
936 return new GNEMoveOperation(this, getParentLanes().front(), startPos, endPos,
938 }
939}
940
941
943GNEAdditional::getMoveOperationMultiLane(const double startPos, const double endPos) {
944 // get snap radius
946 // get mouse position
947 const Position mousePosition = myNet->getViewNet()->getPositionInformation();
948 // calculate both geometries
949 GUIGeometry fromGeometry, toGeometry;
950 fromGeometry.updateGeometry(getParentLanes().front()->getLaneGeometry().getShape(), startPos, 0);
951 toGeometry.updateGeometry(getParentLanes().back()->getLaneGeometry().getShape(), endPos, 0);
952 // check if we clicked over start or end position
954 if (fromGeometry.getShape().front().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
955 // move first position
956 return new GNEMoveOperation(this, getParentLanes().front(), startPos, getParentLanes().back(), endPos,
958 } else if (toGeometry.getShape().back().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
959 // move last position
960 return new GNEMoveOperation(this, getParentLanes().front(), startPos, getParentLanes().back(), endPos,
962 }
963 } else {
964 auto segment = gViewObjectsHandler.getSelectedSegment(this);
965 if (segment) {
966 if (segment->getLaneIndex() == 0) {
967 return new GNEMoveOperation(this, getParentLanes().front(), startPos, getParentLanes().back(), endPos,
969 } else if (segment->getLaneIndex() == ((int)getParentLanes().size() - 1)) {
970 return new GNEMoveOperation(this, getParentLanes().front(), startPos, getParentLanes().back(), endPos,
972 }
973 }
974 }
975 return nullptr;
976}
977
978
979std::string
981 // continue depending of tag
982 switch (tag) {
984 return "jupedsim.walkable_area";
986 return "jupedsim.obstacle";
987 default:
988 throw InvalidArgument("Invalid JuPedSim tag");
989 }
990}
991
992
995 // continue depending of tag
996 switch (tag) {
998 return RGBColor(179, 217, 255);
1000 return RGBColor(255, 204, 204);
1001 default:
1002 throw InvalidArgument("Invalid JuPedSim tag");
1003 }
1004}
1005
1006
1007bool
1009 // continue depending of tag
1010 switch (tag) {
1013 return true;
1014 default:
1015 throw InvalidArgument("Invalid JuPedSim tag");
1016 }
1017}
1018
1019
1020double
1022 // continue depending of tag
1023 switch (tag) {
1025 return 1;
1027 return 2;
1028 default:
1029 throw InvalidArgument("Invalid JuPedSim tag");
1030 }
1031}
1032
1033
1034void
1036 const double layer, const double exaggeration, const bool filledShape) const {
1037 // calculate contour depending of contoured shape
1038 if (filledShape) {
1040 } else {
1042 s.neteditSizeSettings.polylineWidth, exaggeration, true, true, 0, nullptr, nullptr);
1043 }
1044 // get edit modes
1045 const auto& editModes = myNet->getViewNet()->getEditModes();
1046 // check if draw geometry points
1047 if (editModes.isCurrentSupermodeNetwork() && !myNet->getViewNet()->getViewParent()->getMoveFrame()->getNetworkMoveOptions()->getMoveWholePolygons()) {
1048 // check if we're in move mode
1049 const bool moveMode = (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE);
1050 // get geometry point radius (size depends if we're in move mode)
1051 const double geometryPointRaidus = s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5);
1052 // calculate contour geometry points
1053 myAdditionalContour.calculateContourAllGeometryPoints(s, d, this, myAdditionalGeometry.getShape(), layer, geometryPointRaidus, exaggeration, moveMode);
1054 }
1055}
1056
1057
1058GNELane*
1060 return getParentLanes().front();
1061}
1062
1063
1064GNELane*
1066 return getParentLanes().back();
1067}
1068
1069
1072 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1073}
1074
1075
1076void
1077GNEAdditional::drawParentChildLines(const GUIVisualizationSettings& s, const RGBColor& color, const bool onlySymbols) const {
1078 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
1079 // check if current additional is inspected, front or selected
1080 const bool currentDrawEntire = inspectedElements.isACInspected(this) || myDrawInFront || isAttributeCarrierSelected();
1081 // push layer matrix
1083 // translate to parentChildLine layer
1084 glTranslated(0, 0, GLO_PARENTCHILDLINE);
1085 // iterate over parent additionals
1086 for (const auto& parent : getParentAdditionals()) {
1087 // get inspected flag
1088 const bool parentInspected = inspectedElements.isACInspected(parent);
1089 // draw parent lines
1090 GUIGeometry::drawParentLine(s, getPositionInView(), parent->getPositionInView(),
1091 (isAttributeCarrierSelected() || parent->isAttributeCarrierSelected()) ? s.additionalSettings.connectionColorSelected : color,
1092 currentDrawEntire || parentInspected || parent->isAttributeCarrierSelected(), .05);
1093 }
1094 // special case for Parking area reroutes
1096 // iterate over rerouter elements
1097 for (const auto& rerouterInterval : getChildAdditionals()) {
1098 for (const auto& rerouterElement : rerouterInterval->getChildAdditionals()) {
1099 if (rerouterElement->getTagProperty()->getTag() == SUMO_TAG_PARKING_AREA_REROUTE) {
1100 // get parking area
1101 const auto parkingArea = rerouterElement->getParentAdditionals().at(1);
1102 // get inspected flag
1103 const bool parkingAreaInspected = inspectedElements.isACInspected(parkingArea);
1104 // draw parent lines
1105 GUIGeometry::drawParentLine(s, getPositionInView(), parkingArea->getPositionInView(),
1106 (isAttributeCarrierSelected() || parkingArea->isAttributeCarrierSelected()) ? s.additionalSettings.connectionColorSelected : color,
1107 currentDrawEntire || parkingAreaInspected || parkingArea->isAttributeCarrierSelected(), .05);
1108 }
1109 }
1110 }
1111 }
1112 // iterate over child additionals
1113 for (const auto& child : getChildAdditionals()) {
1114 // get inspected flag
1115 const bool childInspected = inspectedElements.isACInspected(child);
1116 // special case for parking zone reroute
1117 if (child->getTagProperty()->getTag() == SUMO_TAG_PARKING_AREA_REROUTE) {
1118 // draw child line between parking area and rerouter
1119 GUIGeometry::drawChildLine(s, getPositionInView(), child->getParentAdditionals().front()->getParentAdditionals().front()->getPositionInView(),
1120 (isAttributeCarrierSelected() || child->isAttributeCarrierSelected()) ? s.additionalSettings.connectionColorSelected : color,
1121 currentDrawEntire || childInspected || child->isAttributeCarrierSelected(), .05);
1122 } else if (!onlySymbols || child->getTagProperty()->isSymbol()) {
1123 // draw child line
1124 GUIGeometry::drawChildLine(s, getPositionInView(), child->getPositionInView(),
1125 (isAttributeCarrierSelected() || child->isAttributeCarrierSelected()) ? s.additionalSettings.connectionColorSelected : color,
1126 currentDrawEntire || childInspected || child->isAttributeCarrierSelected(), .05);
1127 }
1128 }
1129 // pop layer matrix
1131}
1132
1133
1134void
1136 const double rot, const RGBColor& baseColor, const bool ignoreShift) const {
1137 drawSemiCircleGeometryPoint(s, d, pos, rot, baseColor, -90, 90, ignoreShift);
1138}
1139
1140void
1142 const double rot, const RGBColor& baseColor, const bool ignoreShift) const {
1143 drawSemiCircleGeometryPoint(s, d, pos, rot, baseColor, 90, 270, ignoreShift);
1144}
1145
1146void
1148 const double rot, const RGBColor& baseColor, const bool ignoreShift) const {
1149 drawSemiCircleGeometryPoint(s, d, pos, rot, baseColor, -90, 90, ignoreShift);
1150}
1151
1152
1153void
1155 const double rot, const RGBColor& baseColor, const bool ignoreShift) const {
1156 drawSemiCircleGeometryPoint(s, d, pos, rot, baseColor, 270, 90, ignoreShift);
1157}
1158
1159
1160int
1162 // filter symbols
1163 std::vector<GNEAdditional*> children;
1164 for (const auto& child : getParentAdditionals().front()->getChildAdditionals()) {
1165 if (!child->getTagProperty()->isSymbol()) {
1166 children.push_back(child);
1167 }
1168 }
1169 // now get index
1170 for (int i = 0; i < (int)children.size(); i++) {
1171 if (children.at(i) == this) {
1172 return i;
1173 }
1174 }
1175 return 0;
1176}
1177
1178
1179bool
1180GNEAdditional::areLaneConsecutives(const std::vector<GNELane*>& lanes) {
1181 // declare lane iterator
1182 int laneIt = 0;
1183 // iterate over all lanes
1184 while (laneIt < ((int)lanes.size() - 1)) {
1185 // we assume that lanes aren't consecutive
1186 bool consecutiveFound = false;
1187 // get lanes
1188 const auto lane = lanes.at(laneIt);
1189 const auto nextLane = lanes.at(laneIt + 1);
1190 // if there is a connection between "from" lane and "to" lane of connection, change connectionFound to true
1191 for (const auto& outgoingEdge : lane->getParentEdge()->getToJunction()->getGNEOutgoingEdges()) {
1192 for (const auto& outgoingLane : outgoingEdge->getChildLanes()) {
1193 if (outgoingLane == nextLane) {
1194 consecutiveFound = true;
1195 }
1196 }
1197 }
1198 // abort if consecutiveFound is false
1199 if (!consecutiveFound) {
1200 return false;
1201 }
1202 // update iterator
1203 laneIt++;
1204 }
1205 // lanes are consecutive, then return true
1206 return true;
1207}
1208
1209
1210bool
1211GNEAdditional::areLaneConnected(const std::vector<GNELane*>& lanes) {
1212 // declare lane iterator
1213 int laneIt = 0;
1214 // iterate over all lanes, and stop if myE2valid is false
1215 while (laneIt < ((int)lanes.size() - 1)) {
1216 // we assume that E2 is invalid
1217 bool connectionFound = false;
1218 // get lanes
1219 const auto lane = lanes.at(laneIt);
1220 const auto nextLane = lanes.at(laneIt + 1);
1221 // check if both lanes are sidewalks
1222 if ((lane->getAttribute(SUMO_ATTR_ALLOW) == "pedestrian") && (nextLane->getAttribute(SUMO_ATTR_ALLOW) == "pedestrian")) {
1223 connectionFound = true;
1224 }
1225 // if there is a connection between "from" lane and "to" lane of connection, change connectionFound to true
1226 for (const auto& connection : lane->getParentEdge()->getNBEdge()->getConnections()) {
1227 if ((connection.toEdge == nextLane->getParentEdge()->getNBEdge()) &&
1228 (connection.fromLane == lane->getIndex()) &&
1229 (connection.toLane == nextLane->getIndex())) {
1230 connectionFound = true;
1231 }
1232 }
1233 // abort if connectionFound is false
1234 if (!connectionFound) {
1235 return false;
1236 }
1237 // update iterator
1238 laneIt++;
1239 }
1240 // there are connections between all lanes, then return true
1241 return true;
1242}
1243
1244
1245bool
1247 // throw exception because this function mus be implemented in child (see GNEE3Detector)
1248 throw ProcessError(StringUtils::format("Calling non-implemented function checkChildAdditionalRestriction during saving of %. It muss be reimplemented in child class", getTagStr()));
1249}
1250
1251
1252void
1254 const Position& pos, const double rot, const RGBColor& baseColor, const double fromAngle, const double toAngle,
1255 const bool /* ignoreShift */) const {
1256 // check if draw geometry point
1258 // push matrix
1260 // translated to front
1261 glTranslated(0, 0, 0.1);
1262 // set color depending if check if mouse is over element
1263 GLHelper::setColor(baseColor.changedBrightness(-50));
1264 // translate and rotate
1265 glTranslated(pos.x(), pos.y(), 0.1);
1266 glRotated(rot, 0, 0, 1);
1267 // draw geometry point
1269 // pop geometry point matrix
1271 }
1272}
1273
1274
1275std::string
1276GNEAdditional::adjustListedAdditionalText(const std::string& text) const {
1277 // 10 + 3 + 10
1278 if (text.size() <= 23) {
1279 return text;
1280 } else {
1281 // get text size
1282 const int textPosition = (int)text.size() - 10;
1283 // declare strings
1284 std::string partA, partB;
1285 // resize
1286 partA.reserve(10);
1287 partB.reserve(10);
1288 // fill both
1289 for (int i = 0; i < 10; i++) {
1290 partA.push_back(text.at(i));
1291 partB.push_back(text.at(textPosition + i));
1292 }
1293 // return composition
1294 return (partA + "..." + partB);
1295 }
1296}
1297
1298/****************************************************************************/
std::vector< ParentType > GNEHierarchicalContainerParents
@ NETWORK_DELETE
mode for deleting network elements
@ NETWORK_MOVE
mode for moving network elements
@ NETWORK_SELECT
mode for selecting network elements
@ DEMAND_PERSONPLAN
Mode for editing person plan.
@ DEMAND_CONTAINER
Mode for editing container.
@ DEMAND_PERSON
Mode for editing person.
@ DEMAND_VEHICLE
Mode for editing vehicles.
@ DEMAND_CONTAINERPLAN
Mode for editing container plan.
@ MID_OPEN_ADDITIONAL_DIALOG
open additional dialog (used in netedit)
Definition GUIAppEnum.h:469
@ GLO_MAX
empty max
@ GLO_PARENTCHILDLINE
line between parent and childrens
GUIViewObjectsHandler gViewObjectsHandler
GUITexture
An enumeration of gifs used by the gui applications.
Definition GUITextures.h:31
#define TL(string)
Definition MsgHandler.h:305
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_REROUTER
A rerouter.
@ SUMO_TAG_ACCESS
An access point for a train stop.
@ SUMO_TAG_PARKING_AREA_REROUTE
entry for an alternative parking zone
@ SUMO_TAG_DET_ENTRY
an e3 entry point
@ SUMO_TAG_PARKING_SPACE
A parking space for a single vehicle within a parking area.
@ GNE_TAG_JPS_OBSTACLE
polygon used for draw juPedSim obstacles
@ SUMO_TAG_DET_EXIT
an e3 exit point
@ SUMO_TAG_VAPORIZER
vaporizer of vehicles
@ SUMO_TAG_TAZREL
a relation between two TAZs
@ GNE_TAG_JPS_WALKABLEAREA
polygon used for draw juPedSim walkable areas
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_LANE
@ SUMO_ATTR_EDGE
@ GNE_ATTR_PARENT
parent of an additional element
@ SUMO_ATTR_NAME
@ SUMO_ATTR_TO_TAZ
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_FROM_TAZ
@ SUMO_ATTR_ID
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
bool isInitialised() const
check if Boundary is Initialised
Definition Boundary.cpp:256
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:340
std::string fromContainerStop
from containerStop
std::string fromTrainStop
from trainStop
std::string toParkingArea
to parkingArea
std::string fromChargingStation
from chargingStation
std::string toChargingStation
to chargingStation
std::string fromParkingArea
from parkingArea
std::string toContainerStop
to containerStop
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void drawBoundary(const GUIVisualizationSettings &s, const Boundary &b)
Draw a boundary (used for debugging)
Definition GLHelper.cpp:958
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:296
static void drawFilledCircleDetailled(const GUIVisualizationSettings::Detail d, const double radius)
Draws a filled circle around (0,0) depending of level of detail.
Definition GLHelper.cpp:534
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
Definition GLHelper.cpp:748
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
virtual const std::string getOptionalName() const
Returns the name of the object (default "")
virtual std::string getAttribute(SumoXMLAttr key) const =0
GNELane * getLastPathLane() const
get last path lane
bool isValidAdditionalID(const std::string &value) const
check if a new additional ID is valid
virtual void updateGeometry()=0
update pre-computed geometry information
void deleteGLObject()
delete element
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
void replaceAdditionalParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace additional parent
static bool areLaneConnected(const std::vector< GNELane * > &lanes)
check if the given lanes are connected
void drawRightGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw right geometry point
virtual bool isAdditionalValid() const =0
check if current additional is valid to be written into XML (by default true, can be reimplemented in...
virtual std::string getAdditionalProblem() const =0
return a string with the current additional problem (by default empty, can be reimplemented in childr...
std::string adjustListedAdditionalText(const std::string &text) const
adjust listed additional text
virtual void openAdditionalDialog()
open Additional Dialog
static std::string getJuPedSimType(SumoXMLTag tag)
get JuPedSim type
bool checkDrawSelectContour() const
check if draw select contour (blue)
void replaceAdditionalChildLanes(const std::string &value)
replace additional child lanes
void drawListedAdditional(const GUIVisualizationSettings &s, const Position &parentPosition, const double offsetX, const double extraOffsetY, const RGBColor baseCol, const RGBColor textCol, GUITexture texture, const std::string text) const
draw listed additional
void setAdditionalID(const std::string &newID)
set additional ID
GNEContour myAdditionalContour
variable used for draw additional contours
bool isPathElementSelected() const
check if path element is selected
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
bool checkDrawFromContour() const
check if draw from contour (green)
void replaceAdditionalParentEdges(const std::string &value)
replace additional parent edges
void drawAdditionalID(const GUIVisualizationSettings &s) const
draw additional ID
GNELane * getFirstPathLane() const
get first path lane
bool isValidDetectorID(const std::string &value) const
check if a new detector ID is valid
void drawUpGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw up geometry point
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
bool checkDrawDeleteContourSmall() const
check if draw delete contour small (pink/white)
void shiftLaneIndex()
shift lane index
virtual Position getAttributePosition(SumoXMLAttr key) const
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void calculatePerpendicularLine(const double endLaneposition)
calculate perpendicular line between lane parents
GNEMoveOperation * getMoveOperationMultiLane(const double startPos, const double endPos)
get moveOperation for an element over multi lane
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
std::string myAdditionalName
name of additional
void selectGLObject()
select element
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
void resetAdditionalContour()
reset additional contour
void drawDemandElementChildren(const GUIVisualizationSettings &s) const
draw demand element children
static double getJuPedSimLayer(SumoXMLTag tag)
get JuPedSim color
void updateGLObject()
update GLObject (geometry, ID, etc.)
void setSpecialColor(const RGBColor *color)
set special color
const RGBColor * mySpecialColor
pointer to special color (used for drawing Additional with a certain color, mainly used for selection...
bool checkDrawToContour() const
check if draw from contour (magenta)
void drawSquaredAdditional(const GUIVisualizationSettings &s, const Position &pos, const double size, GUITexture texture, GUITexture selectedTexture) const
draw squared additional
bool drawMovingGeometryPoints(const bool ignoreShift) const
check if draw additional extrem geometry points
virtual bool checkChildAdditionalRestriction() const
check restriction with the number of children
GNEHierarchicalElement * getHierarchicalElement()
get GNEHierarchicalElement associated with this AttributeCarrier
void drawSemiCircleGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const double fromAngle, const double toAngle, const bool ignoreShift) const
draw geometry point
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
virtual void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
bool isGLObjectLocked() const
check if element is locked
void replaceAdditionalChildEdges(const std::string &value)
replace additional child edges
virtual void computePathElement()
compute pathElement
void calculateContourPolygons(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double layer, const double exaggeration, const bool filledShape) const
calculate contour for polygons
void drawDownGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw down geometry point
static RGBColor getJuPedSimColor(SumoXMLTag tag)
get JuPedSim color
int getDrawPositionIndex() const
get draw position index (used in rerouters and VSS)
const GUIGeometry & getAdditionalGeometry() const
obtain additional geometry
Boundary myAdditionalBoundary
Additional Boundary (used only by additionals placed over grid)
GNEAdditional(const std::string &id, GNENet *net, const std::string &filename, SumoXMLTag tag, const std::string &additionalName)
Constructor.
void drawLeftGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw left geometry point
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
static bool getJuPedSimFill(SumoXMLTag tag)
get JuPedSim fill
~GNEAdditional()
Destructor.
const std::string & getOptionalAdditionalName() const
Returns the additional name.
GNEMoveOperation * getMoveOperationSingleLane(const double startPos, const double endPos)
get moveOperation for an element over single lane
virtual Position getPositionInView() const =0
Returns position of additional in view.
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position (Currently unused in shapes)
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
virtual void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
virtual void fixAdditionalProblem()=0
fix additional problem (by default throw an exception, has to be reimplemented in children)
void drawParentChildLines(const GUIVisualizationSettings &s, const RGBColor &color, const bool onlySymbols=false) const
draw parent and child lines
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void markAsFrontElement()
mark element as front element
bool checkDrawOverContour() const
check if draw over contour (orange)
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
void markForDrawingFront()
mark for drawing front
void selectAttributeCarrier()
select attribute carrier using GUIGlobalSelection
bool myDrawInFront
boolean to check if drawn this AC over other elements
FXIcon * getACIcon() const
get FXIcon associated to this AC
bool mySelected
boolean to check if this AC is selected (more quickly as checking GUIGlObjectStorage)
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
void unselectAttributeCarrier()
unselect attribute carrier using GUIGlobalSelection
const std::string & getTagStr() const
get tag assigned to this object in string format
bool isTemplate() const
check if this AC is template
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
const GNETagProperties * myTagProperty
reference to tagProperty associated with this attribute carrier
bool checkNewParent(const GNEAttributeCarrier *AC) const
check if the given AC can be a new parent
void calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double layer, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset, const GNESegment *segment, const GUIGlObject *boundaryParent, const bool addToSelectedObjects=true) const
calculate contour extruded (used in elements formed by a central shape)
void clearContour() const
void clear contour
void calculateContourClosedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double layer, const double scale, const GUIGlObject *boundaryParent, const bool addToSelectedObjects=true) const
calculate contours
Boundary getContourBoundary() const
get contour boundary
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
void calculateContourAllGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double layer, const double radius, const double scale, const bool calculatePosOverShape) const
calculate contour for all geometry points
void calculateContourRectangleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, const double width, const double height, const double layer, const double offsetX, const double offsetY, const double rot, const double scale, const GUIGlObject *boundaryParent) const
calculate contour (for rectangled elements)
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:829
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
const GNEHierarchicalContainerChildren< GNEGenericData * > & getChildGenericDatas() const
return child generic data elements
static void updateChildren(ElementType element, GNEHierarchicalContainerChildren< ChildType > newChildren)
update all children elements
const GNEHierarchicalContainerChildren< GNELane * > & getChildLanes() const
get child lanes
const GNEHierarchicalContainerChildren< GNEAdditional * > & getChildAdditionals() const
return child additionals
const GNEHierarchicalContainerParents< GNELane * > & getParentLanes() const
get parent lanes
static void updateParent(ElementType element, const int index, ParentType newParent)
update single parent element
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
static void updateParents(ElementType element, GNEHierarchicalContainerParents< ParentType > newParents)
update all parent elements
GNEAttributesEditor * getAttributesEditor() const
get AttributesEditor
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:220
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:650
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:202
bool getAllowChangeLane() const
allow change lane
bool getMoveWholePolygons() const
check if option "move whole polygons" is enabled
CommonMoveOptions * getCommonMoveOptions() const
get common mode options
NetworkMoveOptions * getNetworkMoveOptions() const
get network mode options
move operation
GNELane * retrieveLane(const std::string &id, bool hardFail=true, bool checkVolatileChange=false) const
get lane by id
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
void updateAdditionalID(GNEAdditional *additional, const std::string &newID)
update additional ID in container
GNEAdditional * retrieveAdditionals(const std::vector< SumoXMLTag > types, const std::string &id, bool hardFail=true) const
Returns the named additional.
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
void requireSaveDataElements()
inform that data elements has to be saved
void requireSaveDemandElements()
inform that demand elements has to be saved
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
void deleteAdditional(GNEAdditional *additional, GNEUndoList *undoList)
remove additional
Definition GNENet.cpp:714
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition GNENet.cpp:164
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:146
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2194
const CommonXMLStructure::PlanParameters & getPlanParameteres() const
get plan parameters
bool markTAZs() const
check if mark TAZs with dotted contours
bool markStoppingPlaces() const
check if mark stoppingPlaces with dotted contours
void updateInformationLabel()
update information label
SelectionInformation * getSelectionInformation() const
get modul for selection information
bool isTAZElement() const
return true if tag correspond to a TAZ element
bool isStoppingPlace() const
additional elements
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool hasDialog() const
return true if tag correspond to an element that can be edited using a dialog
const std::vector< const GNEAttributeProperties * > & getAttributeProperties() const
get all attribute properties
bool hasAttribute(SumoXMLAttr attr) const
check if current TagProperties owns the attribute "attr"
const std::vector< SumoXMLTag > & getXMLParentTags() const
get XML parent tags
bool isACInspected(GNEAttributeCarrier *AC) const
GNEAttributeCarrier * getFirstAC() const
bool isObjectLocked(GUIGlObjectType objectType, const bool selected) const
check if given GLObject is locked for inspect, select, delete and move
GNEAttributeCarrier * getAttributeCarrierFront() const
get front attribute carrier or a pointer to nullptr
GNEAdditional * getAdditionalFront() const
get front additional element or a pointer to nullptr
const GUIGlObject * getGUIGlObjectFront() const
get front GUIGLObject or a pointer to nullptr
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
const GNEViewNetHelper::MouseButtonKeyPressed & getMouseButtonKeyPressed() const
get Key Pressed module
GNEViewNetHelper::InspectedElements & getInspectedElements()
get inspected elements
GNEViewParent * getViewParent() const
get the net object
bool checkOverLockedElement(const GUIGlObject *GLObject, const bool isSelected) const
check if given element is locked (used for drawing select and delete contour)
GNEUndoList * getUndoList() const
get the undoList object
const GNEViewNetHelper::ViewObjectsSelector & getViewObjectsSelector() const
get objects under cursor
GNEViewNetHelper::LockManager & getLockManager()
get lock manager
GNEMoveFrame * getMoveFrame() const
get frame for move elements
GNESelectorFrame * getSelectorFrame() const
get frame for select elements
GNEInspectorFrame * getInspectorFrame() const
get frame for inspect elements
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
The popup menu of a globject.
GUIGlObject * getGLObject() const
The object that belongs to this popup-menu.
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawChildLine(const GUIVisualizationSettings &s, const Position &child, const Position &parent, const RGBColor &color, const bool drawEntire, const double lineWidth)
draw line between child and parent (used in netedit)
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
static void drawParentLine(const GUIVisualizationSettings &s, const Position &parent, const Position &child, const RGBColor &color, const bool drawEntire, const double lineWidth)
draw line between parent and children (used in netedit)
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildPopUpMenuCommonOptions(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, GUISUMOAbstractView *parent, const SumoXMLTag tag, const bool selected, bool addSeparator=true)
A window containing a gl-object's parameter.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
GUIGLObjectPopupMenu * getPopup() const
ge the current popup-menu
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
const GNESegment * getSelectedSegment(const GUIGlObject *GLObject) const
get segment associated with the given GLObject (if exist)
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
GUIVisualizationSizeSettings addSize
bool checkDrawAdditional(Detail d, const bool selected) const
check if draw additionals
GUIVisualizationTextSettings addFullName
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
bool drawForViewObjectsHandler
whether drawing is performed for the purpose of selecting objects in view using ViewObjectsHandler
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
double getTextAngle(double objectAngle) const
return an angle that is suitable for reading text aligned with the given angle (degrees)
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
double getLaneWidth() const
Returns the default width of lanes of this edge.
Definition NBEdge.h:642
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double x() const
Returns the x-position.
Definition Position.h:52
void add(const Position &pos)
Adds the given position to this one.
Definition Position.h:129
double y() const
Returns the y-position.
Definition Position.h:57
A list of positions.
double length2D() const
Returns the length.
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
Position positionAtOffset2D(double pos, double lateralOffset=0, bool extrapolateBeyond=false) const
Returns the position at the given length.
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:200
static bool isValidAdditionalID(const std::string &value)
whether the given string is a valid id for an additional object
static bool isValidDetectorID(const std::string &value)
whether the given string is a valid id for an detector
static const std::string format(const std::string &format, T value, Targs... Fargs)
adds a new formatted message
@ FONS_ALIGN_MIDDLE
Definition fontstash.h:47
@ FONS_ALIGN_LEFT
Definition fontstash.h:42
bool showAdditionals() const
check if additionals has to be drawn
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static bool checkDrawing(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const double exaggeration)
check if icon can be drawn
static void drawLockIcon(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool shiftKeyPressed() const
check if SHIFT is pressed during current event
static const RGBColor connectionColor
connection color
static const RGBColor connectionColorSelected
connection color selected
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
static const double segmentWidth
width of dotted contour segments
static const double polygonGeometryPointRadius
moving geometry point radius
static const double additionalGeometryPointRadius
moving additional geometry point radius
static const double polylineWidth
poly line width
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
bool show(const GUIGlObject *o) const
whether to show the text
double scaledSize(double scale, double constFactor=0.1) const
get scale size