SUMO - Simulation of Urban MObility
GNEAdditionalFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // The Widget for add additional elements
16 /****************************************************************************/
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 #include <iostream>
43 #include <netedit/GNENet.h>
46 #include <netedit/GNEUndoList.h>
50 #include <netedit/GNEViewNet.h>
51 #include <netedit/GNEViewParent.h>
52 
53 #include "GNEAdditionalFrame.h"
54 
55 
56 // ===========================================================================
57 // FOX callback mapping
58 // ===========================================================================
59 
60 FXDEFMAP(GNEAdditionalFrame::AdditionalSelector) SelectorAdditionalMap[] = {
62 };
63 
64 FXDEFMAP(GNEAdditionalFrame::AdditionalAttributeSingle) AdditionalAttributeSingleMap[] = {
67 };
68 
69 FXDEFMAP(GNEAdditionalFrame::AdditionalAttributes) AdditionalAttributesMap[] = {
71 };
72 
73 FXDEFMAP(GNEAdditionalFrame::NeteditAttributes) NeteditAttributesMap[] = {
78 };
79 
80 FXDEFMAP(GNEAdditionalFrame::SelectorParentEdges) SelectorParentEdgesMap[] = {
86 };
87 
88 FXDEFMAP(GNEAdditionalFrame::SelectorParentLanes) SelectorParentLanesMap[] = {
94 };
95 
96 // Object implementation
97 FXIMPLEMENT(GNEAdditionalFrame::AdditionalSelector, FXGroupBox, SelectorAdditionalMap, ARRAYNUMBER(SelectorAdditionalMap))
98 FXIMPLEMENT(GNEAdditionalFrame::AdditionalAttributeSingle, FXHorizontalFrame, AdditionalAttributeSingleMap, ARRAYNUMBER(AdditionalAttributeSingleMap))
99 FXIMPLEMENT(GNEAdditionalFrame::AdditionalAttributes, FXGroupBox, AdditionalAttributesMap, ARRAYNUMBER(AdditionalAttributesMap))
100 FXIMPLEMENT(GNEAdditionalFrame::NeteditAttributes, FXGroupBox, NeteditAttributesMap, ARRAYNUMBER(NeteditAttributesMap))
101 FXIMPLEMENT(GNEAdditionalFrame::SelectorParentEdges, FXGroupBox, SelectorParentEdgesMap, ARRAYNUMBER(SelectorParentEdgesMap))
102 FXIMPLEMENT(GNEAdditionalFrame::SelectorParentLanes, FXGroupBox, SelectorParentLanesMap, ARRAYNUMBER(SelectorParentLanesMap))
103 
104 
105 // ---------------------------------------------------------------------------
106 // GNEAdditionalFrame::AdditionalSelector - methods
107 // ---------------------------------------------------------------------------
108 
110  FXGroupBox(additionalFrameParent->myContentFrame, "Additional element", GUIDesignGroupBoxFrame),
111  myAdditionalFrameParent(additionalFrameParent),
112  myCurrentAdditionalType(SUMO_TAG_NOTHING) {
113 
114  // Create FXListBox in myGroupBoxForMyAdditionalMatchBox
115  myAdditionalMatchBox = new FXComboBox(this, GUIDesignComboBoxNCol, this, MID_GNE_SET_TYPE, GUIDesignComboBox);
116 
117  // Add options to myAdditionalMatchBox
118  auto listOfTags = GNEAttributeCarrier::allowedAdditionalTags(true);
119  for (auto i : listOfTags) {
120  myAdditionalMatchBox->appendItem(toString(i).c_str());
121  }
122 
123  // Set visible items
124  myAdditionalMatchBox->setNumVisible((int)myAdditionalMatchBox->getNumItems());
125 
126  // set busstop as default additional
127  myAdditionalMatchBox->setCurrentItem(10);
128 
129  // AdditionalSelector is always shown
130  show();
131 }
132 
133 
135 
136 
140 }
141 
142 
143 void
145  // Set new actualAdditionalType
146  myCurrentAdditionalType = actualAdditionalType;
147  // Check that current additional type is valid
149  // obtain tag property (only for improve code legibility)
151  // first check if additional can block movement, then show neteditParameters
152  if (tagValue.canBlockMovement()) {
154  } else {
156  }
157  // Clear internal attributes
159  // iterate over attributes of myCurrentAdditionalType
160  for (auto i : tagValue) {
161  // only show attributes that aren't uniques
162  if (!i.second.isUnique()) {
164  } else if (i.first == SUMO_ATTR_ENDPOS) {
166  }
167  }
169  // Show myFirstAdditionalParentSelector if we're adding a additional with parent
170  if (tagValue.hasParent()) {
172  } else {
174  }
175  // Show SelectorParentEdges if we're adding an additional that own the attribute SUMO_ATTR_EDGES
176  if (tagValue.hasAttribute(SUMO_ATTR_EDGES)) {
178  } else {
180  }
181  // Show SelectorParentLanes if we're adding an additional that own the attribute SUMO_ATTR_LANES
182  if (tagValue.hasAttribute(SUMO_ATTR_LANES)) {
184  } else {
186  }
187  } else {
188  // hide all groupbox if additional isn't valid
194  }
195 }
196 
197 
198 long
200  // Check if value of myAdditionalMatchBox correspond of an allowed additional tags
201  auto listOfTags = GNEAttributeCarrier::allowedAdditionalTags(false);
202  for (auto i : listOfTags) {
203  if (toString(i) == myAdditionalMatchBox->getText().text()) {
204  myAdditionalMatchBox->setTextColor(FXRGB(0, 0, 0));
206  // Write Warning in console if we're in testing mode
207  WRITE_DEBUG(("Selected additional '" + myAdditionalMatchBox->getText() + "' in AdditionalSelector").text());
208  return 1;
209  }
210  }
211  // if additional name isn't correct, hidde all
213  myAdditionalMatchBox->setTextColor(FXRGB(255, 0, 0));
214  // Write Warning in console if we're in testing mode
215  WRITE_DEBUG("Selected invalid additional in AdditionalSelector");
216  return 1;
217 }
218 
219 // ---------------------------------------------------------------------------
220 // GNEAdditionalFrame::AdditionalAttributeSingle - methods
221 // ---------------------------------------------------------------------------
222 
224  FXHorizontalFrame(additionalAttributesParent, GUIDesignAuxiliarHorizontalFrame),
225  myAdditionalAttributesParent(additionalAttributesParent),
226  myAdditionalAttr(SUMO_ATTR_NOTHING) {
227  // Create visual elements
228  myLabel = new FXLabel(this, "name", 0, GUIDesignLabelAttribute);
232  myBoolCheckButton = new FXCheckButton(this, "Disabled", this, MID_GNE_SET_ATTRIBUTE_BOOL, GUIDesignCheckButtonAttribute);
233  // Hide elements
234  hideParameter();
235 }
236 
237 
239 
240 
241 void
243  myAdditionalAttr = additionalAttr;
244  myInvalidValue = "";
245  myLabel->setText(toString(myAdditionalAttr).c_str());
246  myLabel->show();
247  // Retrieve attribute properties
249  if (attributeProperties.isInt()) {
250  myTextFieldInt->setTextColor(FXRGB(0, 0, 0));
251  myTextFieldInt->setText(toString(value).c_str());
252  myTextFieldInt->show();
253  } else if (attributeProperties.isFloat()) {
254  myTextFieldReal->setTextColor(FXRGB(0, 0, 0));
255  myTextFieldReal->setText(toString(value).c_str());
256  myTextFieldReal->show();
257  } else if (attributeProperties.isBool()) {
258  if (GNEAttributeCarrier::parse<bool>(value)) {
259  myBoolCheckButton->setCheck(true);
260  myBoolCheckButton->setText("true");
261  } else {
262  myBoolCheckButton->setCheck(false);
263  myBoolCheckButton->setText("false");
264  }
265  myBoolCheckButton->show();
266  } else {
267  myTextFieldStrings->setTextColor(FXRGB(0, 0, 0));
268  myTextFieldStrings->setText(value.c_str());
269  myTextFieldStrings->show();
270  }
271  show();
272 }
273 
274 
275 void
278  myLabel->hide();
279  myTextFieldInt->hide();
280  myTextFieldReal->hide();
281  myTextFieldStrings->hide();
282  myBoolCheckButton->hide();
283  hide();
284 }
285 
286 
289  return myAdditionalAttr;
290 }
291 
292 
293 std::string
295  // obtain attribute property (only for improve code legibility)
297  // return value depending of attribute type
298  if (attrValue.isBool()) {
299  return (myBoolCheckButton->getCheck() == 1) ? "true" : "false";
300  } else if (attrValue.isInt()) {
301  return myTextFieldInt->getText().text();
302  } else if (attrValue.isFloat() || attrValue.isTime()) {
303  return myTextFieldReal->getText().text();
304  } else {
305  return myTextFieldStrings->getText().text();
306  }
307 }
308 
309 
310 const std::string&
312  return myInvalidValue;
313 }
314 
315 
316 long
318  // We assume that current value is valid
319  myInvalidValue = "";
320  // get attribute Values (only for improve efficiency)
322  // Check if format of current value of myTextField is correct
323  if (attrValues.isInt()) {
324  if (GNEAttributeCarrier::canParse<int>(myTextFieldInt->getText().text())) {
325  // convert string to int
326  int intValue = GNEAttributeCarrier::parse<int>(myTextFieldInt->getText().text());
327  // Check if int value must be positive
328  if (attrValues.isPositive() && (intValue < 0)) {
329  myInvalidValue = "'" + toString(myAdditionalAttr) + "' cannot be negative";
330  }
331  } else {
332  myInvalidValue = "'" + toString(myAdditionalAttr) + "' doesn't have a valid 'int' format";
333  }
334  } else if (attrValues.isTime()) {
335  // time attributes work as positive doubles
336  if (GNEAttributeCarrier::canParse<double>(myTextFieldReal->getText().text())) {
337  // convert string to double
338  double doubleValue = GNEAttributeCarrier::parse<double>(myTextFieldReal->getText().text());
339  // Check if parsed value is negative
340  if (doubleValue < 0) {
341  myInvalidValue = "'" + toString(myAdditionalAttr) + "' cannot be negative";
342  }
343  } else {
344  myInvalidValue = "'" + toString(myAdditionalAttr) + "' doesn't have a valid 'time' format";
345  }
346  } else if (attrValues.isFloat()) {
347  if (GNEAttributeCarrier::canParse<double>(myTextFieldReal->getText().text())) {
348  // convert string to double
349  double doubleValue = GNEAttributeCarrier::parse<double>(myTextFieldReal->getText().text());
350  // Check if double value must be positive
351  if (attrValues.isPositive() && (doubleValue < 0)) {
352  myInvalidValue = "'" + toString(myAdditionalAttr) + "' cannot be negative";
353  // check if double value is a probability
354  } else if (attrValues.isProbability() && ((doubleValue < 0) || doubleValue > 1)) {
355  myInvalidValue = "'" + toString(myAdditionalAttr) + "' takes only values between 0 and 1";
356  }
357  } else {
358  myInvalidValue = "'" + toString(myAdditionalAttr) + "' doesn't have a valid 'float' format";
359  }
360  } else if (attrValues.isFilename()) {
361  // check if filename format is valid
362  if (SUMOXMLDefinitions::isValidFilename(myTextFieldStrings->getText().text()) == false) {
363  myInvalidValue = "input contains invalid characters for a filename";
364  }
365  } else if (attrValues.isVClass() && attrValues.isList()) {
366  // check if VClasses are valid
367  if (canParseVehicleClasses(myTextFieldStrings->getText().text()) == false) {
368  myInvalidValue = "list of VClass isn't valid";
369  }
370  } else if (myAdditionalAttr == SUMO_ATTR_ROUTEPROBE) {
371  // check if filename format is valid
372  if (!SUMOXMLDefinitions::isValidNetID(myTextFieldStrings->getText().text())) {
373  myInvalidValue = "RouteProbe ID contains invalid characters";
374  }
375  } else if (myAdditionalAttr == SUMO_ATTR_NAME) {
376  // check if filename format is valid
377  if (SUMOXMLDefinitions::isValidAttribute(myTextFieldStrings->getText().text()) == false) {
378  myInvalidValue = "Name contains invalid characters";
379  }
380  } else if (myAdditionalAttr == SUMO_ATTR_VTYPES) {
381  // check if filename format is valid
382  if (SUMOXMLDefinitions::isValidListOfTypeID(myTextFieldStrings->getText().text()) == false) {
383  myInvalidValue = "Ids contains invalid characters for vehicle type ids";
384  }
385  }
386  // change color of text field depending of myCurrentValueValid
387  if (myInvalidValue.size() == 0) {
388  myTextFieldInt->setTextColor(FXRGB(0, 0, 0));
389  myTextFieldInt->killFocus();
390  myTextFieldReal->setTextColor(FXRGB(0, 0, 0));
391  myTextFieldReal->killFocus();
392  myTextFieldStrings->setTextColor(FXRGB(0, 0, 0));
393  myTextFieldStrings->killFocus();
394  } else {
395  // IF value of TextField isn't valid, change their color to Red
396  myTextFieldInt->setTextColor(FXRGB(255, 0, 0));
397  myTextFieldReal->setTextColor(FXRGB(255, 0, 0));
398  myTextFieldStrings->setTextColor(FXRGB(255, 0, 0));
399  }
400  // Update aditional frame
401  update();
402  return 1;
403 }
404 
405 
406 long
408  if (myBoolCheckButton->getCheck()) {
409  myBoolCheckButton->setText("true");
410  } else {
411  myBoolCheckButton->setText("false");
412  }
413  return 0;
414 }
415 
416 // ---------------------------------------------------------------------------
417 // GNEAdditionalFrame::AdditionalAttributes - methods
418 // ---------------------------------------------------------------------------
419 
421  FXGroupBox(additionalFrameParent->myContentFrame, "Internal attributes", GUIDesignGroupBoxFrame),
422  myAdditionalFrameParent(additionalFrameParent) {
423  // Create single parameters
424  for (int i = 0; i < GNEAttributeCarrier::getHigherNumberOfAttributes(); i++) {
426  }
427  // Create help button
428  new FXButton(this, "Help", 0, this, MID_HELP, GUIDesignButtonRectangular);
429 }
430 
431 
433 
434 
435 void
437  // Hide all fields
438  for (int i = 0; i < (int)myVectorOfsingleAdditionalParameter.size(); i++) {
439  myVectorOfsingleAdditionalParameter.at(i)->hideParameter();
440  }
441 }
442 
443 
444 void
446  // obtain attribute property (only for improve code legibility)
447  const auto& attrvalue = GNEAttributeCarrier::getTagProperties(myAdditionalFrameParent->getAdditionalSelector()->getCurrentAdditionalType()).getAttribute(AdditionalAttributeSingle);
448  myVectorOfsingleAdditionalParameter.at(attrvalue.getPositionListed())->showParameter(AdditionalAttributeSingle, attrvalue.getDefaultValue());
449 }
450 
451 
452 void
454  recalc();
455  show();
456 }
457 
458 
459 void
461  hide();
462 }
463 
464 
465 std::map<SumoXMLAttr, std::string>
467  std::map<SumoXMLAttr, std::string> values;
468  // get standard parameters
469  for (int i = 0; i < (int)myVectorOfsingleAdditionalParameter.size(); i++) {
470  if (myVectorOfsingleAdditionalParameter.at(i)->getAttr() != SUMO_ATTR_NOTHING) {
471  values[myVectorOfsingleAdditionalParameter.at(i)->getAttr()] = myVectorOfsingleAdditionalParameter.at(i)->getValue();
472  }
473  }
474  return values;
475 }
476 
477 
478 void
480  std::string errorMessage;
481  // iterate over standard parameters
483  if (errorMessage.empty()) {
484  // Return string with the error if at least one of the parameter isn't valid
485  std::string attributeValue = myVectorOfsingleAdditionalParameter.at(i.second.getPositionListed())->isAttributeValid();
486  if (attributeValue.size() != 0) {
487  errorMessage = attributeValue;
488  }
489  }
490  }
491  // show warning box if input parameters aren't invalid
492  if (extra.size() == 0) {
493  errorMessage = "Invalid input parameter of " + toString(myAdditionalFrameParent->getAdditionalSelector()->getCurrentAdditionalType()) + ": " + errorMessage;
494  } else {
495  errorMessage = "Invalid input parameter of " + toString(myAdditionalFrameParent->getAdditionalSelector()->getCurrentAdditionalType()) + ": " + extra;
496  }
497 
498  // set message in status bar
500  // Write Warning in console if we're in testing mode
501  WRITE_DEBUG(errorMessage);
502 }
503 
504 
505 bool
507  // iterate over standar parameters
509  // Return false if error message of attriuve isn't empty
510  if (myVectorOfsingleAdditionalParameter.at(i.second.getPositionListed())->isAttributeValid().size() != 0) {
511  return false;
512  }
513  }
514  return true;
515 }
516 
517 
521 }
522 
523 
524 long
526  // open Help attributes dialog
528  return 1;
529 }
530 
531 // ---------------------------------------------------------------------------
532 // GNEAdditionalFrame::NeteditAttributes- methods
533 // ---------------------------------------------------------------------------
534 
536  FXGroupBox(additionalFrameParent->myContentFrame, "Netedit attributes", GUIDesignGroupBoxFrame),
537  myActualAdditionalReferencePoint(GNE_ADDITIONALREFERENCEPOINT_LEFT),
538  myCurrentLengthValid(true) {
539  // Create FXListBox for the reference points and fill it
541  myReferencePointMatchBox->appendItem("reference left");
542  myReferencePointMatchBox->appendItem("reference right");
543  myReferencePointMatchBox->appendItem("reference center");
544  // Create Frame for Length Label and textField
545  FXHorizontalFrame* lengthFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
546  myLengthLabel = new FXLabel(lengthFrame, toString(SUMO_ATTR_LENGTH).c_str(), 0, GUIDesignLabelAttribute);
548  myLengthTextField->setText("10");
549  // Create Frame for block movement label and checkBox (By default disabled)
550  FXHorizontalFrame* blockMovement = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
551  myBlockLabel = new FXLabel(blockMovement, "block move", 0, GUIDesignLabelAttribute);
552  myBlockMovementCheckButton = new FXCheckButton(blockMovement, "false", this, MID_GNE_SET_ATTRIBUTE_BOOL, GUIDesignCheckButtonAttribute);
553  myBlockMovementCheckButton->setCheck(false);
554  // Create help button
555  helpReferencePoint = new FXButton(this, "Help", 0, this, MID_HELP, GUIDesignButtonRectangular);
556  // Set visible items
557  myReferencePointMatchBox->setNumVisible((int)myReferencePointMatchBox->getNumItems());
558 }
559 
560 
562 
563 
564 
565 void
567  show();
568  if (includeLengthAndReferencePoint) {
569  myLengthLabel->show();
570  myLengthTextField->show();
571  myReferencePointMatchBox->show();
572  } else {
573  myLengthLabel->hide();
574  myLengthTextField->hide();
575  myReferencePointMatchBox->hide();
576  }
577 }
578 
579 
580 void
582  hide();
583 }
584 
585 
589 }
590 
591 
592 double
594  return GNEAttributeCarrier::parse<double>(myLengthTextField->getText().text());
595 }
596 
597 
598 bool
600  return myBlockMovementCheckButton->getCheck() == 1 ? true : false;
601 }
602 
603 
604 bool
606  return myCurrentLengthValid;
607 }
608 
609 
610 long
612  // change color of text field depending of the input length
613  if (GNEAttributeCarrier::canParse<double>(myLengthTextField->getText().text()) &&
614  GNEAttributeCarrier::parse<double>(myLengthTextField->getText().text()) > 0) {
615  myLengthTextField->setTextColor(FXRGB(0, 0, 0));
616  myLengthTextField->killFocus();
617  myCurrentLengthValid = true;
618  } else {
619  myLengthTextField->setTextColor(FXRGB(255, 0, 0));
620  myCurrentLengthValid = false;
621  }
622  // Update aditional frame
623  update();
624  return 1;
625 }
626 
627 
628 long
630  // Cast actual reference point type
631  if (myReferencePointMatchBox->getText() == "reference left") {
632  myReferencePointMatchBox->setTextColor(FXRGB(0, 0, 0));
634  myLengthTextField->enable();
635  } else if (myReferencePointMatchBox->getText() == "reference right") {
636  myReferencePointMatchBox->setTextColor(FXRGB(0, 0, 0));
638  myLengthTextField->enable();
639  } else if (myReferencePointMatchBox->getText() == "reference center") {
640  myLengthTextField->enable();
641  myReferencePointMatchBox->setTextColor(FXRGB(0, 0, 0));
643  myLengthTextField->enable();
644  } else {
645  myReferencePointMatchBox->setTextColor(FXRGB(255, 0, 0));
647  myLengthTextField->disable();
648  }
649  return 1;
650 }
651 
652 
653 long
655  if (myBlockMovementCheckButton->getCheck()) {
656  myBlockMovementCheckButton->setText("true");
657  } else {
658  myBlockMovementCheckButton->setText("false");
659  }
660  return 1;
661 }
662 
663 
664 long
666  // Create dialog box
667  FXDialogBox* additionalNeteditAttributesHelpDialog = new FXDialogBox(this, "Netedit Parameters Help", GUIDesignDialogBox);
668  additionalNeteditAttributesHelpDialog->setIcon(GUIIconSubSys::getIcon(ICON_MODEADDITIONAL));
669  // set help text
670  std::ostringstream help;
671  help
672  << "- Referece point: Mark the initial position of the additional element.\n"
673  << " Example: If you want to create a busStop with a length of 30 in the point 100 of the lane:\n"
674  << " - Reference Left will create it with startPos = 70 and endPos = 100.\n"
675  << " - Reference Right will create it with startPos = 100 and endPos = 130.\n"
676  << " - Reference Center will create it with startPos = 85 and endPos = 115.\n"
677  << "\n"
678  << "- Block movement: if is enabled, the created additional element will be blocked. i.e. cannot be moved with\n"
679  << " the mouse. This option can be modified inspecting element.";
680  // Create label with the help text
681  new FXLabel(additionalNeteditAttributesHelpDialog, help.str().c_str(), 0, GUIDesignLabelFrameInformation);
682  // Create horizontal separator
683  new FXHorizontalSeparator(additionalNeteditAttributesHelpDialog, GUIDesignHorizontalSeparator);
684  // Create frame for OK Button
685  FXHorizontalFrame* myHorizontalFrameOKButton = new FXHorizontalFrame(additionalNeteditAttributesHelpDialog, GUIDesignAuxiliarHorizontalFrame);
686  // Create Button Close (And two more horizontal frames to center it)
687  new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
688  new FXButton(myHorizontalFrameOKButton, "OK\t\tclose", GUIIconSubSys::getIcon(ICON_ACCEPT), additionalNeteditAttributesHelpDialog, FXDialogBox::ID_ACCEPT, GUIDesignButtonOK);
689  new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
690  // Write Warning in console if we're in testing mode
691  WRITE_DEBUG("Opening NeteditAttributes help dialog");
692  // create Dialog
693  additionalNeteditAttributesHelpDialog->create();
694  // show in the given position
695  additionalNeteditAttributesHelpDialog->show(PLACEMENT_CURSOR);
696  // refresh APP
697  getApp()->refresh();
698  // open as modal dialog (will block all windows until stop() or stopModal() is called)
699  getApp()->runModalFor(additionalNeteditAttributesHelpDialog);
700  // Write Warning in console if we're in testing mode
701  WRITE_DEBUG("Closing NeteditAttributes help dialog");
702  return 1;
703 }
704 
705 
706 std::string
708  // Obtain Id's of list
709  std::string vectorOfIds;
710  for (int i = 0; i < list->getNumItems(); i++) {
711  if (list->isItemSelected(i)) {
712  if (vectorOfIds.size() > 0) {
713  vectorOfIds += " ";
714  }
715  vectorOfIds += (list->getItem(i)->getText()).text();
716  }
717  }
718  return vectorOfIds;
719 }
720 
721 
724  return myAdditionalSelector;
725 }
726 
727 
730  return myAdditionalParameters;
731 }
732 
733 
736  return myNeteditParameters;
737 }
738 
739 
743 }
744 
745 
748  return myEdgeParentsSelector;
749 }
750 
751 
754  return myLaneParentsSelector;
755 }
756 
757 // ---------------------------------------------------------------------------
758 // GNEAdditionalFrame::SelectorParentAdditional - methods
759 // ---------------------------------------------------------------------------
760 
762  FXGroupBox(additionalFrameParent->myContentFrame, "Parent selector", GUIDesignGroupBoxFrame),
763  myAdditionalFrameParent(additionalFrameParent),
764  myAdditionalTypeParent(SUMO_TAG_NOTHING) {
765  // Create label with the type of SelectorParentAdditional
766  myFirstAdditionalParentsLabel = new FXLabel(this, "No additional selected", 0, GUIDesignLabelLeftThick);
767  // Create list
768  myFirstAdditionalParentsList = new FXList(this, this, MID_GNE_SET_TYPE, GUIDesignListSingleElement, 0, 0, 0, 100);
769  // Hide List
771 }
772 
773 
775 
776 
777 std::string
779  for (int i = 0; i < myFirstAdditionalParentsList->getNumItems(); i++) {
780  if (myFirstAdditionalParentsList->isItemSelected(i)) {
781  return myFirstAdditionalParentsList->getItem(i)->getText().text();
782  }
783  }
784  return "";
785 }
786 
787 
788 void
790  // first unselect all
791  for (int i = 0; i < myFirstAdditionalParentsList->getNumItems(); i++) {
792  myFirstAdditionalParentsList->getItem(i)->setSelected(false);
793  }
794  // select element if correspond to given ID
795  for (int i = 0; i < myFirstAdditionalParentsList->getNumItems(); i++) {
796  if (myFirstAdditionalParentsList->getItem(i)->getText().text() == id) {
797  myFirstAdditionalParentsList->getItem(i)->setSelected(true);
798  }
799  }
800  // recalc myFirstAdditionalParentsList
802 }
803 
804 
805 void
807  myAdditionalTypeParent = additionalType;
808  myFirstAdditionalParentsLabel->setText(("Parent type: " + toString(additionalType)).c_str());
810  show();
811 }
812 
813 
814 void
817  hide();
818 }
819 
820 
821 void
823  myFirstAdditionalParentsList->clearItems();
825  // fill list with IDs of additionals
827  myFirstAdditionalParentsList->appendItem(i.first.c_str());
828  }
829  }
830 }
831 
832 // ---------------------------------------------------------------------------
833 // GNEAdditionalFrame::SelectorParentEdges - methods
834 // ---------------------------------------------------------------------------
835 
837  FXGroupBox(additionalFrameParent->myContentFrame, "Edges", GUIDesignGroupBoxFrame),
838  myAdditionalFrameParent(additionalFrameParent) {
839  // Create menuCheck for selected edges
840  myUseSelectedEdgesCheckButton = new FXCheckButton(this, ("Use selected " + toString(SUMO_TAG_EDGE) + "s").c_str(), this, MID_GNE_ADDITIONALFRAME_USESELECTED, GUIDesignCheckButtonAttribute);
841 
842  // Create search box
844 
845  // Create list
846  myList = new FXList(this, this, MID_GNE_ADDITIONALFRAME_SELECT, GUIDesignList, 0, 0, 0, 100);
847 
848  // Create horizontal frame
849  FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
850 
851  // Create button for clear selection
852  myClearEdgesSelection = new FXButton(buttonsFrame, "Clear", 0, this, MID_GNE_ADDITIONALFRAME_CLEARSELECTION, GUIDesignButtonRectangular);
853 
854  // Create button for invert selection
855  myInvertEdgesSelection = new FXButton(buttonsFrame, "Invert", 0, this, MID_GNE_ADDITIONALFRAME_INVERTSELECTION, GUIDesignButtonRectangular);
856 
857  // Hide List
858  hideList();
859 }
860 
861 
863 
864 
865 std::string
868 }
869 
870 
871 void
873  // clear list of egdge ids
874  myList->clearItems();
875  // get all edges of net
877  std::vector<GNEEdge*> vectorOfEdges = myAdditionalFrameParent->getViewNet()->getNet()->retrieveEdges(false);
878  // iterate over edges of net
879  for (auto i : vectorOfEdges) {
880  // If search criterium is correct, then append ittem
881  if (i->getID().find(search) != std::string::npos) {
882  myList->appendItem(i->getID().c_str());
883  }
884  }
885  // By default, CheckBox for useSelectedEdges isn't checked
886  myUseSelectedEdgesCheckButton->setCheck(false);
887  // Recalc Frame
888  recalc();
889  // Update Frame
890  update();
891  // Show dialog
892  show();
893 }
894 
895 
896 void
898  FXGroupBox::hide();
899 }
900 
901 
902 void
904  // Enable or disable use selected edges
905  if (myAdditionalFrameParent->getViewNet()->getNet()->retrieveEdges(true).size() > 0) {
907  } else {
909  }
910 }
911 
912 
913 bool
915  if (myUseSelectedEdgesCheckButton->getCheck()) {
916  return true;
917  } else {
918  return false;
919  }
920 }
921 
922 
923 long
925  if (myUseSelectedEdgesCheckButton->getCheck()) {
926  myEdgesSearch->hide();
927  myList->hide();
928  myClearEdgesSelection->hide();
929  myInvertEdgesSelection->hide();
930  } else {
931  myEdgesSearch->show();
932  myList->show();
933  myClearEdgesSelection->show();
934  myInvertEdgesSelection->show();
935  }
936  // Recalc Frame
937  recalc();
938  // Update Frame
939  update();
940  return 1;
941 }
942 
943 
944 long
946  // Show only Id's of SelectorParentEdges that contains the searched string
947  showList(myEdgesSearch->getText().text());
948  return 1;
949 }
950 
951 
952 long
954  return 1;
955 }
956 
957 
958 long
960  for (int i = 0; i < myList->getNumItems(); i++) {
961  if (myList->getItem(i)->isSelected()) {
962  myList->deselectItem(i);
963  }
964  }
965  return 1;
966 }
967 
968 
969 long
971  for (int i = 0; i < myList->getNumItems(); i++) {
972  if (myList->getItem(i)->isSelected()) {
973  myList->deselectItem(i);
974  } else {
975  myList->selectItem(i);
976  }
977  }
978  return 1;
979 }
980 
981 // ---------------------------------------------------------------------------
982 // GNEAdditionalFrame::SelectorParentLanes - methods
983 // ---------------------------------------------------------------------------
984 
986  FXGroupBox(additionalFrameParent->myContentFrame, "Lanes", GUIDesignGroupBoxFrame),
987  myAdditionalFrameParent(additionalFrameParent) {
988  // Create CheckBox for selected lanes
989  myUseSelectedLanesCheckButton = new FXCheckButton(this, ("Use selected " + toString(SUMO_TAG_LANE) + "s").c_str(), this, MID_GNE_ADDITIONALFRAME_USESELECTED, GUIDesignCheckButtonAttribute);
990 
991  // Create search box
993 
994  // Create list
995  myList = new FXList(this, this, MID_GNE_ADDITIONALFRAME_SELECT, GUIDesignList, 0, 0, 0, 100);
996 
997  // Create horizontal frame
998  FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
999 
1000  // Create button for clear selection
1001  clearLanesSelection = new FXButton(buttonsFrame, "clear", 0, this, MID_GNE_ADDITIONALFRAME_CLEARSELECTION, GUIDesignButtonRectangular);
1002 
1003  // Create button for invert selection
1004  invertLanesSelection = new FXButton(buttonsFrame, "invert", 0, this, MID_GNE_ADDITIONALFRAME_INVERTSELECTION, GUIDesignButtonRectangular);
1005 
1006  // Hide List
1007  hideList();
1008 }
1009 
1010 
1012 
1013 
1014 std::string
1017 }
1018 
1019 
1020 void
1022  myList->clearItems();
1023  std::vector<GNELane*> vectorOfLanes = myAdditionalFrameParent->getViewNet()->getNet()->retrieveLanes(false);
1024  for (auto i : vectorOfLanes) {
1025  if (i->getID().find(search) != std::string::npos) {
1026  myList->appendItem(i->getID().c_str());
1027  }
1028  }
1029  // By default, CheckBox for useSelectedLanes isn't checked
1030  myUseSelectedLanesCheckButton->setCheck(false);
1031  // Show list
1032  show();
1033 }
1034 
1035 
1036 void
1038  hide();
1039 }
1040 
1041 
1042 void
1044  // Enable or disable use selected Lanes
1045  if (myAdditionalFrameParent->getViewNet()->getNet()->retrieveLanes(true).size() > 0) {
1047  } else {
1048  myUseSelectedLanesCheckButton->disable();
1049  }
1050 }
1051 
1052 
1053 bool
1055  if (myUseSelectedLanesCheckButton->getCheck()) {
1056  return true;
1057  } else {
1058  return false;
1059  }
1060 }
1061 
1062 
1063 long
1065  if (myUseSelectedLanesCheckButton->getCheck()) {
1066  myLanesSearch->hide();
1067  myList->hide();
1068  clearLanesSelection->hide();
1069  invertLanesSelection->hide();
1070  } else {
1071  myLanesSearch->show();
1072  myList->show();
1073  clearLanesSelection->show();
1074  invertLanesSelection->show();
1075  }
1076  // Recalc Frame
1077  recalc();
1078  // Update Frame
1079  update();
1080  return 1;
1081 }
1082 
1083 
1084 long
1086  // Show only Id's of SelectorParentLanes that contains the searched string
1087  showList(myLanesSearch->getText().text());
1088  return 1;
1089 }
1090 
1091 
1092 long
1094  return 1;
1095 }
1096 
1097 
1098 long
1100  for (int i = 0; i < myList->getNumItems(); i++) {
1101  if (myList->getItem(i)->isSelected()) {
1102  myList->deselectItem(i);
1103  }
1104  }
1105  return 1;
1106 }
1107 
1108 
1109 long
1111  for (int i = 0; i < myList->getNumItems(); i++) {
1112  if (myList->getItem(i)->isSelected()) {
1113  myList->deselectItem(i);
1114  } else {
1115  myList->selectItem(i);
1116  }
1117  }
1118  return 1;
1119 }
1120 
1121 // ===========================================================================
1122 // method definitions
1123 // ===========================================================================
1124 
1125 GNEAdditionalFrame::GNEAdditionalFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet) :
1126  GNEFrame(horizontalFrameParent, viewNet, "Additionals") {
1127 
1128  // create Additional Selector
1130 
1131  // Create additional parameters
1133 
1134  // Create Netedit parameter
1136 
1137  // Create create list for additional Set
1139 
1142 
1145 
1146  // set BusStop as default additional
1148 }
1149 
1150 
1152 
1153 
1156  // first check that current selected additional is valid
1158  myViewNet->setStatusBarText("Current selected additional isn't valid.");
1160  }
1161  // obtain tag and tagproperty (only for improve code legibility)
1164 
1165  // Declare map to keep values
1166  std::map<SumoXMLAttr, std::string> valuesOfElement = myAdditionalParameters->getAttributesAndValues();
1167 
1168  // limit position depending if show grid is enabled
1170 
1171  // Declare pointer to netElements
1172  GNEJunction* pointed_junction = nullptr;
1173  GNEEdge* pointed_edge = nullptr;
1174  GNELane* pointed_lane = nullptr;
1175  GNECrossing* pointed_crossing = nullptr;
1176 
1177  // If element owns an additional parent, get id of parent from AdditionalParentSelector
1178  if (tagValue.hasParent()) {
1179  // if user click over an additional element parent, mark int in AdditionalParentSelector
1180  if (additionalElement && (additionalElement->getTag() == tagValue.getParentTag())) {
1181  valuesOfElement[GNE_ATTR_PARENT] = additionalElement->getID();
1182  myFirstAdditionalParentSelector->setIDSelected(additionalElement->getID());
1183  }
1184  // stop if currently there isn't a valid selected parent
1187  } else {
1188  myAdditionalParameters->showWarningMessage("A " + toString(tagValue.getParentTag()) + " must be selected before insertion of " + toString(myAdditionalSelector->getCurrentAdditionalType()) + ".");
1190  }
1191  }
1192 
1193  // Check if additional should be placed over a junction
1194  if (tagValue.hasAttribute(SUMO_ATTR_JUNCTION)) {
1195  pointed_junction = dynamic_cast<GNEJunction*>(netElement);
1196  if (pointed_junction != nullptr) {
1197  // show warning dialogbox and stop check if input parameters are valid
1198  if (myAdditionalParameters->areValuesValid() == false) {
1201  }
1202  // Get attribute junction
1203  valuesOfElement[SUMO_ATTR_JUNCTION] = pointed_junction->getID();
1204  // Generate id of element based on the junction
1205  valuesOfElement[SUMO_ATTR_ID] = generateID(pointed_junction);
1206  } else {
1208  }
1209  }
1210  // Check if additional should be placed over a edge
1211  else if (tagValue.hasAttribute(SUMO_ATTR_EDGE) ||
1213  // Due a edge is composed of lanes, its neccesary check if clicked element is an lane
1214  if (dynamic_cast<GNELane*>(netElement) != nullptr) {
1215  pointed_edge = &(dynamic_cast<GNELane*>(netElement)->getParentEdge());
1216  }
1217  if (pointed_edge != nullptr) {
1218  // show warning dialogbox and stop check if input parameters are valid
1219  if (myAdditionalParameters->areValuesValid() == false) {
1222  }
1223  // Get attribute edge
1224  valuesOfElement[SUMO_ATTR_EDGE] = pointed_edge->getID();
1225  // Generate id of element based on the edge
1226  valuesOfElement[SUMO_ATTR_ID] = generateID(pointed_edge);
1227  } else {
1229  }
1230  }
1231  // Check if additional should be placed over a lane
1232  else if (tagValue.hasAttribute(SUMO_ATTR_LANE)) {
1233  pointed_lane = dynamic_cast<GNELane*>(netElement);
1234  if (pointed_lane != nullptr) {
1235  // show warning dialogbox and stop check if input parameters are valid
1236  if (myAdditionalParameters->areValuesValid() == false) {
1239  }
1240  // Get attribute lane
1241  valuesOfElement[SUMO_ATTR_LANE] = pointed_lane->getID();
1242  // Generate id of element based on the lane
1243  valuesOfElement[SUMO_ATTR_ID] = generateID(pointed_lane);
1244  } else {
1246  }
1247  }
1248  // Check if additional should be placed over a crossing
1249  else if (tagValue.hasAttribute(SUMO_ATTR_CROSSING)) {
1250  pointed_crossing = dynamic_cast<GNECrossing*>(netElement);
1251  if (pointed_crossing != nullptr) {
1252  // show warning dialogbox and stop check if input parameters are valid
1253  if (myAdditionalParameters->areValuesValid() == false) {
1256  }
1257  // Get attribute crossing
1258  valuesOfElement[SUMO_ATTR_CROSSING] = pointed_crossing->getID();
1259  // Generate id of element based on the crossing
1260  valuesOfElement[SUMO_ATTR_ID] = generateID(pointed_crossing);
1261  } else {
1263  }
1264  } else {
1265  // Generate id of element
1266  valuesOfElement[SUMO_ATTR_ID] = generateID(nullptr);
1267  }
1268 
1269  // show warning dialogbox and stop check if input parameters are valid
1270  if (myAdditionalParameters->areValuesValid() == false) {
1273  }
1274 
1275  // Obtain position attribute if wasn't previously setted
1276  if (valuesOfElement.find(SUMO_ATTR_POSITION) == valuesOfElement.end()) {
1277  if (pointed_edge) {
1278  // Obtain position of the mouse over edge
1279  double positionOfTheMouseOverEdge = pointed_edge->getLanes().at(0)->getShape().nearest_offset_to_point2D(currentPosition);
1280  // If element has a StartPosition and EndPosition over edge, extract attributes
1281  if (tagValue.hasAttribute(SUMO_ATTR_STARTPOS) && tagValue.hasAttribute(SUMO_ATTR_ENDPOS)) {
1282  // First check that current length is valid
1284  // check if current reference point is valid
1286  myAdditionalParameters->showWarningMessage("Current selected reference point isn't valid");
1288  } else {
1289  // set start and end position
1290  valuesOfElement[SUMO_ATTR_STARTPOS] = toString(setStartPosition(positionOfTheMouseOverEdge, myNeteditParameters->getLength()));
1291  valuesOfElement[SUMO_ATTR_ENDPOS] = toString(setEndPosition(pointed_edge->getLanes().at(0)->getLaneShapeLength(), positionOfTheMouseOverEdge, myNeteditParameters->getLength()));
1292  }
1293  } else {
1295  }
1296  }
1297  // Extract position of lane
1298  valuesOfElement[SUMO_ATTR_POSITION] = toString(positionOfTheMouseOverEdge);
1299  } else if (pointed_lane) {
1300  // Obtain position of the mouse over lane
1301  double positionOfTheMouseOverLane = pointed_lane->getShape().nearest_offset_to_point2D(currentPosition) / pointed_lane->getLengthGeometryFactor();
1302  // If element has a StartPosition and EndPosition over lane, extract attributes
1303  if (tagValue.hasAttribute(SUMO_ATTR_STARTPOS) && tagValue.hasAttribute(SUMO_ATTR_ENDPOS)) {
1304  // First check that current length is valid
1306  // check if current reference point is valid
1308  myAdditionalParameters->showWarningMessage("Current selected reference point isn't valid");
1310  } else {
1311  // set start and end position
1312  valuesOfElement[SUMO_ATTR_STARTPOS] = toString(setStartPosition(positionOfTheMouseOverLane, myNeteditParameters->getLength()));
1313  valuesOfElement[SUMO_ATTR_ENDPOS] = toString(setEndPosition(pointed_lane->getLaneShapeLength(), positionOfTheMouseOverLane, myNeteditParameters->getLength()));
1314  }
1315  } else {
1317  }
1318  }
1319  // Extract position of lane
1320  valuesOfElement[SUMO_ATTR_POSITION] = toString(positionOfTheMouseOverLane);
1321  } else {
1322  // get position in map
1323  valuesOfElement[SUMO_ATTR_POSITION] = toString(currentPosition);
1324  }
1325  }
1326 
1327  // If additional has a interval defined by a begin or end, check that is valid
1328  if (tagValue.hasAttribute(SUMO_ATTR_STARTTIME) && tagValue.hasAttribute(SUMO_ATTR_END)) {
1329  double begin = GNEAttributeCarrier::parse<double>(valuesOfElement[SUMO_ATTR_STARTTIME]);
1330  double end = GNEAttributeCarrier::parse<double>(valuesOfElement[SUMO_ATTR_END]);
1331  if (begin > end) {
1332  myAdditionalParameters->showWarningMessage("Attribute '" + toString(SUMO_ATTR_STARTTIME) + "' cannot be greater than attribute '" + toString(SUMO_ATTR_END) + "'.");
1334  }
1335  }
1336 
1337  // If additional own the attribute SUMO_ATTR_FILE but was't defined, will defined as <ID>.xml
1338  if (GNEAttributeCarrier::getTagProperties(tag).hasAttribute(SUMO_ATTR_FILE) && valuesOfElement[SUMO_ATTR_FILE] == "") {
1339  if (tag != SUMO_TAG_CALIBRATOR && tag != SUMO_TAG_REROUTER) {
1340  // SUMO_ATTR_FILE is optional for calibrators and rerouters (fails to load in sumo when given and the file does not exist)
1341  valuesOfElement[SUMO_ATTR_FILE] = (valuesOfElement[SUMO_ATTR_ID] + ".xml");
1342  }
1343  }
1344 
1345  // Save block value if additional can be blocked
1346  if (tagValue.canBlockMovement()) {
1348  }
1349 
1350  // If element own a list of SelectorParentEdges as attribute
1351  if (tagValue.hasAttribute(SUMO_ATTR_EDGES)) {
1353  // Declare a vector of Id's
1354  std::vector<std::string> vectorOfIds;
1355  // get Selected edges
1356  std::vector<GNEEdge*> selectedEdges = myViewNet->getNet()->retrieveEdges(true);
1357  // Iterate over selectedEdges and getId
1358  for (auto i : selectedEdges) {
1359  vectorOfIds.push_back(i->getID());
1360  }
1361  // Set saved Ids in attribute edges
1362  valuesOfElement[SUMO_ATTR_EDGES] = joinToString(vectorOfIds, " ");
1363  } else {
1365  }
1366  // check if attribute has at least one edge
1367  if (valuesOfElement[SUMO_ATTR_EDGES] == "") {
1368  myAdditionalParameters->showWarningMessage("List of " + toString(SUMO_TAG_EDGE) + "s cannot be empty");
1370  }
1371  }
1372 
1373  // If element own a list of SelectorParentLanes as attribute
1374  if (tagValue.hasAttribute(SUMO_ATTR_LANES)) {
1376  // Declare a vector of Id's
1377  std::vector<std::string> vectorOfIds;
1378  // get Selected lanes
1379  std::vector<GNELane*> selectedLanes = myViewNet->getNet()->retrieveLanes(true);
1380  // Iterate over selectedLanes and getId
1381  for (auto i : selectedLanes) {
1382  vectorOfIds.push_back(i->getID());
1383  }
1384  // Set saved Ids in attribute lanes
1385  valuesOfElement[SUMO_ATTR_LANES] = joinToString(vectorOfIds, " ");
1386  } else {
1388  }
1389  // check if attribute has at least a lane
1390  if (valuesOfElement[SUMO_ATTR_LANES] == "") {
1391  myAdditionalParameters->showWarningMessage("List of " + toString(SUMO_TAG_LANE) + "s cannot be empty");
1393  }
1394  }
1395 
1396  // Create additional
1398  // Refresh additional Parent Selector (For additionals that have a limited number of childs)
1400  // clear selected eddges and lanes
1403  return ADDADDITIONAL_SUCCESS;
1404  } else {
1406  }
1407 }
1408 
1409 void
1411  myViewNet->getUndoList()->p_begin("delete " + toString(additional->getTag()));
1412  // first remove all additional childs of this additional calling this function recursively
1413  while (additional->getAdditionalChilds().size() > 0) {
1414  removeAdditional(additional->getAdditionalChilds().front());
1415  }
1416  // remove additional
1417  myViewNet->getUndoList()->add(new GNEChange_Additional(additional, false), true);
1418  myViewNet->getUndoList()->p_end();
1419 }
1420 
1421 
1422 void
1424  // Show frame
1425  GNEFrame::show();
1426  // Update UseSelectedLane CheckBox
1428  // Update UseSelectedLane CheckBox
1430 }
1431 
1432 
1433 std::string
1435  // obtain current number of additionals to generate a new index faster
1437  std::string currentAdditionalTypeStr = toString(myAdditionalSelector->getCurrentAdditionalType());
1438  if (netElement) {
1439  // generate ID using netElement
1440  while (myViewNet->getNet()->retrieveAdditional(myAdditionalSelector->getCurrentAdditionalType(), currentAdditionalTypeStr + "_" + netElement->getID() + "_" + toString(additionalIndex), false) != nullptr) {
1441  additionalIndex++;
1442  }
1443  return currentAdditionalTypeStr + "_" + netElement->getID() + "_" + toString(additionalIndex);
1444  } else {
1445  // generate ID without netElement
1446  while (myViewNet->getNet()->retrieveAdditional(myAdditionalSelector->getCurrentAdditionalType(), currentAdditionalTypeStr + "_" + toString(additionalIndex), false) != nullptr) {
1447  additionalIndex++;
1448  }
1449  return currentAdditionalTypeStr + "_" + toString(additionalIndex);
1450  }
1451 }
1452 
1453 
1454 double
1455 GNEAdditionalFrame::setStartPosition(double positionOfTheMouseOverLane, double lengthOfAdditional) {
1458  return positionOfTheMouseOverLane;
1460  return positionOfTheMouseOverLane - lengthOfAdditional;
1462  return positionOfTheMouseOverLane - lengthOfAdditional / 2;
1463  default:
1464  throw InvalidArgument("Reference Point invalid");
1465  }
1466 }
1467 
1468 
1469 double
1470 GNEAdditionalFrame::setEndPosition(double /*laneLength*/, double positionOfTheMouseOverLane, double lengthOfAdditional) {
1473  return positionOfTheMouseOverLane + lengthOfAdditional;
1475  return positionOfTheMouseOverLane;
1477  return positionOfTheMouseOverLane + lengthOfAdditional / 2;
1478  default:
1479  throw InvalidArgument("Reference Point invalid");
1480  }
1481 }
1482 
1483 /****************************************************************************/
double setStartPosition(double positionOfTheMouseOverLane, double lengthOfAdditional)
obtain the Start position values of StoppingPlaces and E2 detector over the lane
GNEAdditionalFrame::AdditionalSelector * myAdditionalSelector
additional selector
std::vector< GNELane * > retrieveLanes(bool onlySelected=false)
return all lanes
Definition: GNENet.cpp:1051
SumoXMLTag
Numbers representing SUMO-XML - element names.
long onCmdSelectReferencePoint(FXObject *, FXSelector, void *)
Called when user enters another reference point.
SumoXMLAttr myAdditionalAttr
current XML attribute
additionalReferencePoint myActualAdditionalReferencePoint
actual additional reference point selected in the match Box
#define GUIDesignComboBoxNCol
number of column of every combo box
Definition: GUIDesigns.h:205
text attribute edited
Definition: GUIAppEnum.h:539
clear selection of elements
Definition: GUIAppEnum.h:657
#define GUIDesignCheckButtonAttribute
checkButton without thick extended over the frame used for attributes
Definition: GUIDesigns.h:115
additionalReferencePoint getActualReferencePoint() const
get actual reference point
FXCheckButton * myUseSelectedLanesCheckButton
CheckBox for selected lanes.
static std::vector< SumoXMLTag > allowedAdditionalTags(bool onlyDrawables)
get all editable for tag additional elements
SelectorParentAdditional * getAdditionalParentSelector() const
get additional parent selector
invert selection of eleents
Definition: GUIAppEnum.h:659
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name) ...
static bool isValidListOfTypeID(const std::string &value)
whether the given string is a valid list of ids for an edge or vehicle type (empty aren&#39;t allowed) ...
void showListOfAdditionalParents(SumoXMLTag additionalTypeParent)
Show list of SelectorParentAdditional.
SumoXMLTag getCurrentAdditionalType() const
get current additional type
long onCmdSelectLane(FXObject *, FXSelector, void *)
called when user select a lane of the list
begin/end of the description of a single lane
bool isUseSelectedLanesEnable() const
get status of checkBox UseSelectedLanes
A calibrator placed over edge.
void setCurrentAdditional(SumoXMLTag actualAdditionalType)
set parameters depending of the given additionalType
AddAdditionalResult addAdditional(GNENetElement *netElement, GNEAdditional *additional)
add additional element
FXLabel * myFirstAdditionalParentsLabel
Label with the name of additional.
#define GUIDesignListSingleElement
design for FXLists that only allow a single selected elements
Definition: GUIDesigns.h:493
Position snapToActiveGrid(const Position &pos) const
Returns a position that is mapped to the closest grid point if the grid is active.
FXTextField * myTextFieldStrings
textField to modify the default value of string parameters
FXComboBox * myReferencePointMatchBox
match box with the list of reference points
double setEndPosition(double laneLength, double positionOfTheMouseOverLane, double lengthOfAdditional)
obtain the End position values of StoppingPlaces and E2 detector over the lane
static int getHigherNumberOfAttributes()
return the number of attributes of the tag with the most highter number of attributes ...
FXList * myFirstAdditionalParentsList
List of additional sets.
FXCheckButton * myBoolCheckButton
check button to enable/disable the value of boolean parameters
long onCmdHelp(FXObject *, FXSelector, void *)
FXButton * myClearEdgesSelection
button for clear selection
std::string myInvalidValue
string which indicates the reason due current value is invalid
void hideList()
hide SelectorParentLanes
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:47
GNEAdditionalFrame::SelectorParentEdges * myEdgeParentsSelector
list of SelectorParentEdges
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:78
int getNumberOfAdditionals(SumoXMLTag type=SUMO_TAG_NOTHING) const
Returns the number of additionals of the net.
Definition: GNENet.cpp:1820
FXTextField * myLengthTextField
textField for length
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
bool areValuesValid() const
check if parameters of attributes are valid
void openHelpAttributesDialog(SumoXMLTag tag) const
Open help attributes dialog.
Definition: GNEFrame.cpp:784
long onCmdTypeInSearchBox(FXObject *, FXSelector, void *)
called when user type in search box
GNEViewNet * getViewNet() const
get view net
Definition: GNEFrame.cpp:766
bool myCurrentLengthValid
Flag to check if current length is valid.
FXTextField * myEdgesSearch
text field for search edge IDs
void showList(std::string search="")
Show list of SelectorParentEdges.
AdditionalAttributes * myAdditionalAttributesParent
additional attribute parent
FXButton * myInvertEdgesSelection
button for invert selection
GNEAdditionalFrame * myAdditionalFrameParent
pointer to additional frame parent
void showNeteditAttributes(bool includeLengthAndReferencePoint)
show length field and reference point
std::string getIdSelected() const
get currently additional parent selected
#define GUIDesignComboBox
Definition: GUIDesigns.h:195
GNEViewNet * myViewNet
View Net for changes.
Definition: GNEFrame.h:232
FXCheckButton * myUseSelectedEdgesCheckButton
CheckBox for selected edges.
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
Definition: GNENet.cpp:1787
long onCmdselectAttributeCarrier(FXObject *, FXSelector, void *)
GNEUndoList * getUndoList() const
get the undoList object
FXButton * clearLanesSelection
button for clear selection
SelectorParentLanes * getLaneParentsSelector() const
get lane parents selector
FXDEFMAP(GNEAdditionalFrame::AdditionalSelector) SelectorAdditionalMap[]
#define GUIDesignList
design for FXLists
Definition: GUIDesigns.h:490
GNEAdditionalFrame::NeteditAttributes * myNeteditParameters
Netedit parameter.
FXLabel * myLengthLabel
Label for length.
#define GUIDesignHorizontalSeparator
Definition: GUIDesigns.h:295
SelectorParentAdditional(GNEAdditionalFrame *additionalFrameParent)
constructor
long onCmdSetAttribute(FXObject *, FXSelector, void *)
#define GUIDesignTextField
Definition: GUIDesigns.h:34
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
SelectorParentEdges * getEdgeParentsSelector() const
get edge parents selector
std::map< SumoXMLAttr, std::string > getAttributesAndValues() const
get attributes and their values
FXVerticalFrame * myContentFrame
Vertical frame that holds all widgets of frame.
Definition: GNEFrame.h:235
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:45
bool isCurrentLengthValid() const
check if current length is valid
help button
Definition: GUIAppEnum.h:400
GNEAdditionalFrame * myAdditionalFrameParent
pointer to Additional Frame Parent
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
Definition: GNEUndoList.cpp:85
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames ...
Definition: GUIDesigns.h:258
FXList * myList
List of SelectorParentLanes.
long onCmdUseSelectedEdges(FXObject *, FXSelector, void *)
GNEAdditionalFrame::SelectorParentAdditional * myFirstAdditionalParentSelector
list of additional Set
long onCmdInvertSelection(FXObject *, FXSelector, void *)
called when invert selection button is pressed
FXComboBox * myAdditionalMatchBox
combo box with the list of additional elements
GNEAdditionalFrame::AdditionalAttributes * myAdditionalParameters
additional internal attributes
void removeAdditional(GNEAdditional *additional)
remove an additional element previously added
block movement of a graphic element
void showWarningMessage(std::string extra="") const
show warning message with information about non-valid attributes
GNEAdditionalFrame::SelectorParentLanes * myLaneParentsSelector
list of SelectorParentLanes
invalid attribute
GNEAdditionalFrame * getAdditionalFrameParent() const
get additional frame parent
~GNEAdditionalFrame()
Destructor.
double getLengthGeometryFactor() const
get lenght geometry factor
Definition: GNELane.cpp:1287
FXLabel * myBlockLabel
Label for block movement.
FXTextField * myLanesSearch
text field for search lane IDs
GNEAdditionalFrame * myAdditionalFrameParent
pointer to additionalFrameParent
SumoXMLTag myCurrentAdditionalType
actual additional type selected in the match Box
const std::string getID() const
function to support debugging
SumoXMLTag myAdditionalTypeParent
current additional type parent
long onCmdClearSelection(FXObject *, FXSelector, void *)
called when clear selection button is pressed
GNEAdditionalFrame * myAdditionalFrameParent
pointer to additional frame parent
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:249
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition: GUIDesigns.h:184
#define GUIDesignButtonRectangular
little button rectangular (46x23) used in frames (For example, in "help" buttons) ...
Definition: GUIDesigns.h:60
double getLaneShapeLength() const
returns the length of the lane&#39;s shape
Definition: GNELane.cpp:726
double getLength() const
get value of length
friend class AdditionalAttributeSingle
FOX-declaration.
begin/end of the description of an edge
void addAttribute(SumoXMLAttr AdditionalAttributeSingle)
add attribute
void hideListOfAdditionalParents()
hide SelectorParentAdditional
long onCmdClearSelection(FXObject *, FXSelector, void *)
called when clear selection button is pressed
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
void showList(std::string search="")
Show list of SelectorParentLanes.
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
FXList * myList
List of SelectorParentEdges.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:50
#define GUIDesignTextFieldNCol
Num of column of text field.
Definition: GUIDesigns.h:46
FXLabel * myLabel
lael with the name of the parameter
AddAdditionalResult
enum with all possible values after try to create an additional using frame
long onCmdSetBlocking(FXObject *, FXSelector, void *)
Called when user changes the checkbox "set blocking".
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:613
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
Definition: GNEEdge.cpp:832
virtual void show()
show Frame
Definition: GNEFrame.cpp:741
long onCmdUseSelectedLanes(FXObject *, FXSelector, void *)
#define GUIDesignDialogBox
Definition: GUIDesigns.h:407
void show()
show additional frame and update use selected edges/lanes
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Definition: GNENet.cpp:1038
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:53
#define GUIDesignGroupBoxFrame
Group box design extended over frame.
Definition: GUIDesigns.h:227
static GNEAdditional * buildAdditional(GNEViewNet *viewNet, bool allowUndoRedo, SumoXMLTag tag, std::map< SumoXMLAttr, std::string > values)
Build additionals.
weights: time range end
long onCmdSetBooleanAttribute(FXObject *, FXSelector, void *)
called when user change the value of myBoolCheckButton
void updateUseSelectedEdges()
Update use selectedEdges.
bool isBlockEnabled() const
check if block is enabled
#define GUIDesignTextFieldInt
text field extended over Frame with thick frame and limited to Integers
Definition: GUIDesigns.h:37
vaporizer of vehicles
virtual void hide()
hide Frame
Definition: GNEFrame.cpp:750
std::string generateID(GNENetElement *netElement) const
generate a ID for an additiona element
long onCmdHelp(FXObject *, FXSelector, void *)
Called when user press the help button.
GNEAdditionalFrame * myAdditionalFrameParent
pointer to Additional Frame Parent
GNENet * getNet() const
get the net object
#define GUIDesignTextFieldReal
text field extended over Frame with thick frame and limited to Doubles/doubles
Definition: GUIDesigns.h:40
AdditionalSelector * getAdditionalSelector() const
get additional selector
void hideList()
hide SelectorParentEdges
const std::map< std::string, GNEAdditional * > & getAdditionalByType(SumoXMLTag type) const
get map with IDs and pointers to additionals
Definition: GNENet.cpp:1814
#define GUIDesignButtonOK
Definition: GUIDesigns.h:96
const std::string & isAttributeValid() const
returns a empty string if current value is valid, a string with information about invalid value in ot...
void setStatusBarText(const std::string &text)
set staturBar text
Definition: GNEViewNet.cpp:311
long onCmdInvertSelection(FXObject *, FXSelector, void *)
called when invert selection button is pressed
void setIDSelected(const std::string &id)
select manually a element of the list
bool isUseSelectedEdgesEnable() const
get status of checkBox UseSelectedEdges
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
use selected elements
Definition: GUIAppEnum.h:653
FXButton * invertLanesSelection
button for invert selection
parent of an additional element
used to select a type of element in a combo box
Definition: GUIAppEnum.h:537
static const TagValues & getTagProperties(SumoXMLTag tag)
get Tag Properties
std::string getIdsSelected() const
get list of selecte id&#39;s in string format
FXTextField * myTextFieldInt
textField to modify the default value of int/float/string parameters
bool attribute edited
Definition: GUIAppEnum.h:541
static std::string getIdsSelected(const FXList *list)
get list of selecte id&#39;s in string format
#define GUIDesignLabelAttribute
label extended over the matrix column with thick frame and height of 23
Definition: GUIDesigns.h:166
std::string getIdsSelected() const
get list of selecte id&#39;s in string format
GNEAdditionalFrame(FXHorizontalFrame *horizontalFrameParent, GNEViewNet *viewNet)
Constructor.
long onCmdSetLength(FXObject *, FXSelector, void *)
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
const std::vector< GNEAdditional * > & getAdditionalChilds() const
return vector of additionals that have as Parent this edge (For example, Calibrators) ...
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name) ...
long onCmdTypeInSearchBox(FXObject *, FXSelector, void *)
called when user type in search box
AdditionalAttributes * getAdditionalParameters() const
get additional attributes
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
std::vector< AdditionalAttributeSingle * > myVectorOfsingleAdditionalParameter
vector with the additional parameters
void showParameter(SumoXMLAttr additionalAttr, std::string value)
show name and value of attribute of type string
#define GUIDesignLabelLeftThick
label extended over frame with thick and with text justify to left and height of 23 ...
Definition: GUIDesigns.h:157
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:230
void hideNeteditAttributes()
show length field and reference point
void refreshListOfAdditionalParents()
Refresh list of Additional Parents.
long onCmdSelectEdge(FXObject *, FXSelector, void *)
called when user select a edge of the list
NeteditAttributes * getNeteditAttributes() const
get netedit attributes
FXCheckButton * myBlockMovementCheckButton
checkBox for block movement
FXTextField * myTextFieldReal
textField to modify the default value of real/times parameters
FXButton * helpReferencePoint
Button for help about the reference point.
SumoXMLTag getTag() const
get XML Tag assigned to this object