SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GNEAdditionalFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software; you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation; either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
30 #ifdef HAVE_VERSION_H
31 #include <version.h>
32 #endif
33 
34 #include <iostream>
43 #include "GNEAdditionalFrame.h"
44 #include "GNEViewNet.h"
45 #include "GNEViewParent.h"
46 #include "GNENet.h"
47 #include "GNEJunction.h"
48 #include "GNEEdge.h"
49 #include "GNELane.h"
50 #include "GNECrossing.h"
51 #include "GNEUndoList.h"
52 #include "GNEChange_Selection.h"
53 #include "GNEAttributeCarrier.h"
54 #include "GNEChange_Additional.h"
55 #include "GNEAdditional.h"
56 #include "GNEAdditionalSet.h"
57 #include "GNEAdditionalHandler.h"
58 
59 #ifdef CHECK_MEMORY_LEAKS
60 #include <foreign/nvwa/debug_new.h>
61 #endif // CHECK_MEMORY_LEAKS
62 
63 
64 // ===========================================================================
65 // FOX callback mapping
66 // ===========================================================================
67 
68 FXDEFMAP(GNEAdditionalFrame) GNEAdditionalMap[] = {
70 };
71 
72 FXDEFMAP(GNEAdditionalFrame::additionalParameterList) GNEAdditionalParameterListMap[] = {
75 };
76 
77 FXDEFMAP(GNEAdditionalFrame::additionalParameters) GNEAdditionalParametersMap[] = {
79 };
80 
81 FXDEFMAP(GNEAdditionalFrame::editorParameters) GNEEditorParametersMap[] = {
84 };
85 
86 FXDEFMAP(GNEAdditionalFrame::additionalSet) GNEAdditionalSetMap[] = {
89 };
90 
98 };
99 
107 };
108 
109 // Object implementation
110 FXIMPLEMENT(GNEAdditionalFrame, FXScrollWindow, GNEAdditionalMap, ARRAYNUMBER(GNEAdditionalMap))
111 FXIMPLEMENT(GNEAdditionalFrame::additionalParameterList, FXMatrix, GNEAdditionalParameterListMap, ARRAYNUMBER(GNEAdditionalParameterListMap))
112 FXIMPLEMENT(GNEAdditionalFrame::additionalParameters, FXGroupBox, GNEAdditionalParametersMap, ARRAYNUMBER(GNEAdditionalParametersMap))
113 FXIMPLEMENT(GNEAdditionalFrame::editorParameters, FXGroupBox, GNEEditorParametersMap, ARRAYNUMBER(GNEEditorParametersMap))
114 FXIMPLEMENT(GNEAdditionalFrame::additionalSet, FXGroupBox, GNEAdditionalSetMap, ARRAYNUMBER(GNEAdditionalSetMap))
115 FXIMPLEMENT(GNEAdditionalFrame::edgesSelector, FXGroupBox, GNEEdgesMap, ARRAYNUMBER(GNEEdgesMap))
116 FXIMPLEMENT(GNEAdditionalFrame::lanesSelector, FXGroupBox, GNELanesMap, ARRAYNUMBER(GNELanesMap))
117 
118 // ===========================================================================
119 // method definitions
120 // ===========================================================================
121 
122 GNEAdditionalFrame::GNEAdditionalFrame(FXComposite* parent, GNEViewNet* viewNet):
123  GNEFrame(parent, viewNet, "Additionals"),
124  myActualAdditionalType(SUMO_TAG_NOTHING) {
125 
126  // Create groupBox for myAdditionalMatchBox
127  myGroupBoxForMyAdditionalMatchBox = new FXGroupBox(myContentFrame, "Additional element", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X);
128 
129  // Create FXListBox in myGroupBoxForMyAdditionalMatchBox
130  myAdditionalMatchBox = new FXComboBox(myGroupBoxForMyAdditionalMatchBox, 12, this, MID_GNE_MODE_ADDITIONAL_ITEM, FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC | LAYOUT_CENTER_Y | LAYOUT_FILL_X);
131 
132  // Create additional parameters
133  myAdditionalParameters = new GNEAdditionalFrame::additionalParameters(myContentFrame, this);
134 
135  // Create editor parameter
136  myEditorParameters = new GNEAdditionalFrame::editorParameters(myContentFrame, this);
137 
138  // Create create list for additional Set
139  myAdditionalSet = new GNEAdditionalFrame::additionalSet(myContentFrame, this, myViewNet);
140 
142  myEdgesSelector = new GNEAdditionalFrame::edgesSelector(myContentFrame, myViewNet);
143 
145  myLanesSelector = new GNEAdditionalFrame::lanesSelector(myContentFrame, myViewNet);
146 
147  // Add options to myAdditionalMatchBox
148  const std::vector<SumoXMLTag>& additionalTags = GNEAttributeCarrier::allowedAdditionalTags();
149  for (std::vector<SumoXMLTag>::const_iterator i = additionalTags.begin(); i != additionalTags.end(); i++) {
150  myAdditionalMatchBox->appendItem(toString(*i).c_str());
151  }
152 
153  // Set visible items
154  myAdditionalMatchBox->setNumVisible((int)myAdditionalMatchBox->getNumItems());
155 
156  // If there are additionals
157  if (additionalTags.size() > 0) {
158  // Set myActualAdditionalType and show
159  myActualAdditionalType = additionalTags.front();
160  setParametersOfAdditional(myActualAdditionalType);
161  }
162 }
163 
164 
167 }
168 
169 
170 bool
172  // Declare map to keep values
173  std::map<SumoXMLAttr, std::string> valuesOfElement = myAdditionalParameters->getAttributes();
174 
175  // Declare pointer to netElements
176  GNEJunction* pointed_junction = NULL;
177  GNEEdge* pointed_edge = NULL;
178  GNELane* pointed_lane = NULL;
179  GNECrossing* pointed_crossing = NULL;
180 
181  // Check if additional should be placed over a junction
183  pointed_junction = dynamic_cast<GNEJunction*>(netElement);
184  if (pointed_junction != NULL) {
185  // Get attribute junction
186  valuesOfElement[SUMO_ATTR_JUNCTION] = pointed_junction->getID();
187  // Generate id of element based on the junction
188  valuesOfElement[SUMO_ATTR_ID] = generateID(pointed_junction);
189  } else {
190  return false;
191  }
192  }
193  // Check if additional should be placed over a edge
195  // Due a edge is composed of lanes, its neccesary check if clicked element is an lane
196  if (dynamic_cast<GNELane*>(netElement) != NULL) {
197  pointed_edge = &(dynamic_cast<GNELane*>(netElement)->getParentEdge());
198  }
199  if (pointed_edge != NULL) {
200  // Get attribute edge
201  valuesOfElement[SUMO_ATTR_EDGE] = pointed_edge->getID();
202  // Generate id of element based on the edge
203  valuesOfElement[SUMO_ATTR_ID] = generateID(pointed_edge);
204  } else {
205  return false;
206  }
207  }
208  // Check if additional should be placed over a lane
210  pointed_lane = dynamic_cast<GNELane*>(netElement);
211  if (pointed_lane != NULL) {
212  // Get attribute lane
213  valuesOfElement[SUMO_ATTR_LANE] = pointed_lane->getID();
214  // Generate id of element based on the lane
215  valuesOfElement[SUMO_ATTR_ID] = generateID(pointed_lane);
216  } else {
217  return false;
218  }
219  }
220  // Check if additional should be placed over a crossing
222  pointed_crossing = dynamic_cast<GNECrossing*>(netElement);
223  if (pointed_crossing != NULL) {
224  // Get attribute crossing
225  valuesOfElement[SUMO_ATTR_CROSSING] = pointed_crossing->getID();
226  // Generate id of element based on the crossing
227  valuesOfElement[SUMO_ATTR_ID] = generateID(pointed_crossing);
228  } else {
229  return false;
230  }
231  } else {
232  // Generate id of element
233  valuesOfElement[SUMO_ATTR_ID] = generateID(NULL);
234  }
235 
236  // Obtain position attribute
237  if (pointed_edge) {
238  // Obtain position of the mouse over edge
239  SUMOReal positionOfTheMouseOverEdge = pointed_edge->getLanes().at(0)->getShape().nearest_offset_to_point2D(parent->getPositionInformation());
240  // If element has a StartPosition and EndPosition over edge, extract attributes
242  SUMOReal startPos = setStartPosition(positionOfTheMouseOverEdge, myEditorParameters->getLenght());
243  SUMOReal endPos = setEndPosition(pointed_edge->getLanes().at(0)->getLaneShapeLenght(), positionOfTheMouseOverEdge, myEditorParameters->getLenght());
244  // Only set start position if are valid (!= -1)
245  if (startPos != -1) {
246  valuesOfElement[SUMO_ATTR_STARTPOS] = toString(startPos);
247  } else {
248  WRITE_WARNING("Additonal '" + toString(myActualAdditionalType) + "' cannot be placed over edge. Attribute '" + toString(SUMO_ATTR_STARTPOS) + "' isn't valid");
249  return false;
250  }
251  // Only set end position if are valid (!= -1)
252  if (endPos != -1) {
253  valuesOfElement[SUMO_ATTR_ENDPOS] = toString(endPos);
254  } else {
255  WRITE_WARNING("Additonal '" + toString(myActualAdditionalType) + "' cannot be placed over edge. Attribute '" + toString(SUMO_ATTR_ENDPOS) + "' isn't valid");
256  return false;
257  }
258  }
259  // Extract position of lane
260  valuesOfElement[SUMO_ATTR_POSITION] = toString(positionOfTheMouseOverEdge);
261  } else if (pointed_lane) {
262  // Obtain position of the mouse over lane
263  SUMOReal positionOfTheMouseOverLane = pointed_lane->getShape().nearest_offset_to_point2D(parent->getPositionInformation());
264  // If element has a StartPosition and EndPosition over lane, extract attributes
266  SUMOReal startPos = setStartPosition(positionOfTheMouseOverLane, myEditorParameters->getLenght());
267  SUMOReal endPos = setEndPosition(pointed_lane->getLaneShapeLenght(), positionOfTheMouseOverLane, myEditorParameters->getLenght());
268  // Only set start position if are valid (!= -1)
269  if (startPos != -1) {
270  valuesOfElement[SUMO_ATTR_STARTPOS] = toString(startPos);
271  } else {
272  WRITE_WARNING("Additonal '" + toString(myActualAdditionalType) + "' cannot be placed over lane. Attribute '" + toString(SUMO_ATTR_STARTPOS) + "' isn't valid");
273  return false;
274  }
275  // Only set end position if are valid (!= -1)
276  if (endPos != -1) {
277  valuesOfElement[SUMO_ATTR_ENDPOS] = toString(endPos);
278  } else {
279  WRITE_WARNING("Additonal '" + toString(myActualAdditionalType) + "' cannot be placed over lane. Attribute '" + toString(SUMO_ATTR_ENDPOS) + "' isn't valid");
280  return false;
281  }
282  }
283  // Extract position of lane
284  valuesOfElement[SUMO_ATTR_POSITION] = toString(positionOfTheMouseOverLane);
285  } else {
286  // get position in map
287  valuesOfElement[SUMO_ATTR_POSITION] = toString(parent->getPositionInformation());
288  }
289 
290  // If additional own the attribute SUMO_ATTR_FILE but was't defined, will defined as <ID>.txt
292  valuesOfElement[SUMO_ATTR_FILE] = (valuesOfElement[SUMO_ATTR_ID] + ".txt");
293  }
294 
295  // If additional own the attribute SUMO_ATTR_OUTPUT but was't defined, will defined as <ID>.txt
297  valuesOfElement[SUMO_ATTR_OUTPUT] = (valuesOfElement[SUMO_ATTR_ID] + ".txt");
298  }
299 
300  // Save block value
302 
303  // If element belongst to an additional Set, get id of parent from myAdditionalSet
305  if (myAdditionalSet->getIdSelected() != "") {
306  valuesOfElement[GNE_ATTR_PARENT] = myAdditionalSet->getIdSelected();
307  } else {
308  WRITE_WARNING("A " + toString(myAdditionalSet->getCurrentlyTag()) + " must be selected before insertion of " + toString(myActualAdditionalType) + ".");
309  return false;
310  }
311  }
312 
313  // If element own a list of edgesSelector as attribute
316  // Declare a vector of Id's
317  std::vector<std::string> vectorOfIds;
318  // get Selected edges
319  std::vector<GNEEdge*> selectedEdges = myViewNet->getNet()->retrieveEdges(true);
320  // Iterate over selectedEdges and getId
321  for (std::vector<GNEEdge*>::iterator i = selectedEdges.begin(); i != selectedEdges.end(); i++) {
322  vectorOfIds.push_back((*i)->getID());
323  }
324  // Set saved Ids in attribute edges
325  valuesOfElement[SUMO_ATTR_EDGES] = joinToString(vectorOfIds, " ");
326  } else {
327  valuesOfElement[SUMO_ATTR_EDGES] = myEdgesSelector->getIdsSelected();
328  }
329  // check if attribute has at least an Edge
330  if (valuesOfElement[SUMO_ATTR_EDGES] == "") {
331  WRITE_WARNING("A " + toString(myActualAdditionalType) + " must have at least one edge associated.");
332  return false;
333  }
334  }
335 
336  // If element own a list of lanesSelector as attribute
339  // Declare a vector of Id's
340  std::vector<std::string> vectorOfIds;
341  // get Selected lanes
342  std::vector<GNELane*> selectedLanes = myViewNet->getNet()->retrieveLanes(true);
343  // Iterate over selectedLanes and getId
344  for (std::vector<GNELane*>::iterator i = selectedLanes.begin(); i != selectedLanes.end(); i++) {
345  vectorOfIds.push_back((*i)->getID());
346  }
347  // Set saved Ids in attribute lanes
348  valuesOfElement[SUMO_ATTR_LANES] = joinToString(vectorOfIds, " ");
349  } else {
350  valuesOfElement[SUMO_ATTR_LANES] = myLanesSelector->getIdsSelected();
351  }
352  // check if attribute has at least a lane
353  if (valuesOfElement[SUMO_ATTR_LANES] == "") {
354  WRITE_WARNING("A " + toString(myActualAdditionalType) + " must have at least one lane associated.");
355  return false;
356  }
357  }
358 
359  // Create additional
361 }
362 
363 void
365  myViewNet->getUndoList()->p_begin("delete " + additional->getDescription());
366  myViewNet->getUndoList()->add(new GNEChange_Additional(myViewNet->getNet(), additional, false), true);
368 }
369 
370 
371 long
372 GNEAdditionalFrame::onCmdSelectAdditional(FXObject*, FXSelector, void*) {
373  // set myActualAdditionalType
374  const std::vector<SumoXMLTag>& additionalTags = GNEAttributeCarrier::allowedAdditionalTags();
375  for (std::vector<SumoXMLTag>::const_iterator i = additionalTags.begin(); i != additionalTags.end(); i++) {
376  if (toString(*i) == myAdditionalMatchBox->getText().text()) {
378  }
379  }
380  return 1;
381 }
382 
383 
384 void
386  // Show Scroll window
387  FXScrollWindow::show();
388  // Show Frame Area in which this GNEFrame is placed
390  // Update UseAelectedLane CheckBox
392  // Update UseAelectedLane CheckBox
394 }
395 
396 
397 void
399  // Hide ScrollWindow
400  FXScrollWindow::hide();
401  // Hide Frame Area in which this GNEFrame is placed
403 }
404 
405 
406 void
408  // Set new actualAdditionalType
409  myActualAdditionalType = actualAdditionalType;
410  // Clear default parameters
412  // Hide lenght field and reference point
415  // Obtain attributes of actual myActualAdditionalType
416  std::vector<std::pair <SumoXMLAttr, std::string> > attrs = GNEAttributeCarrier::allowedAttributes(myActualAdditionalType);
417  // Iterate over attributes of myActualAdditionalType
418  for (std::vector<std::pair <SumoXMLAttr, std::string> >::iterator i = attrs.begin(); i != attrs.end(); i++) {
419  if (!GNEAttributeCarrier::isUnique(i->first)) {
421  } else if (i->first == SUMO_ATTR_ENDPOS) {
424  }
425  }
426  // if there are parmeters, show and Recalc groupBox
429  } else {
431  }
432  // Show set parameter if we're adding an additional with parent
435  } else {
437  }
438  // Show edgesSelector if we're adding an additional that own the attribute SUMO_ATTR_EDGES
441  } else {
443  }
444  // Show lanesSelector if we're adding an additional that own the attribute SUMO_ATTR_LANES
447  } else {
449  }
450 }
451 
452 
453 std::string
456  if (netElement) {
457  // generate ID using netElement
458  while (myViewNet->getNet()->getAdditional(myActualAdditionalType, toString(myActualAdditionalType) + "_" + netElement->getID() + "_" + toString(additionalIndex)) != NULL) {
459  additionalIndex++;
460  }
461  return toString(myActualAdditionalType) + "_" + netElement->getID() + "_" + toString(additionalIndex);
462  } else {
463  // generate ID without netElement
464  while (myViewNet->getNet()->getAdditional(myActualAdditionalType, toString(myActualAdditionalType) + "_" + toString(additionalIndex)) != NULL) {
465  additionalIndex++;
466  }
467  return toString(myActualAdditionalType) + "_" + toString(additionalIndex);
468  }
469 }
470 
471 
472 SUMOReal
473 GNEAdditionalFrame::setStartPosition(SUMOReal positionOfTheMouseOverLane, SUMOReal lenghtOfAdditional) {
476  return positionOfTheMouseOverLane;
478  if (positionOfTheMouseOverLane - lenghtOfAdditional >= 0.01) {
479  return positionOfTheMouseOverLane - lenghtOfAdditional;
481  return 0.01;
482  } else {
483  return -1;
484  }
485  }
487  if (positionOfTheMouseOverLane - lenghtOfAdditional / 2 >= 0.01) {
488  return positionOfTheMouseOverLane - lenghtOfAdditional / 2;
490  return 0;
491  } else {
492  return -1;
493  }
494  }
495  default:
496  return -1;
497  }
498 }
499 
500 
501 SUMOReal
502 GNEAdditionalFrame::setEndPosition(SUMOReal laneLenght, SUMOReal positionOfTheMouseOverLane, SUMOReal lenghtOfAdditional) {
505  if (positionOfTheMouseOverLane + lenghtOfAdditional <= laneLenght - 0.01) {
506  return positionOfTheMouseOverLane + lenghtOfAdditional;
508  return laneLenght - 0.01;
509  } else {
510  return -1;
511  }
512  }
514  return positionOfTheMouseOverLane;
516  if (positionOfTheMouseOverLane + lenghtOfAdditional / 2 <= laneLenght - 0.01) {
517  return positionOfTheMouseOverLane + lenghtOfAdditional / 2;
519  return laneLenght - 0.01;
520  } else {
521  return -1;
522  }
523  }
524  default:
525  return -1;
526  }
527 }
528 
529 // ---------------------------------------------------------------------------
530 // GNEAdditionalFrame::additionalParameter - methods
531 // ---------------------------------------------------------------------------
532 
534  FXMatrix(parent, 3, MATRIX_BY_COLUMNS | LAYOUT_FILL_X),
535  myAttr(SUMO_ATTR_NOTHING) {
536  // Create elements
537  myLabel = new FXLabel(this, "name", 0, JUSTIFY_RIGHT | LAYOUT_FIX_WIDTH, 0, 0, 60, 0);
538  myTextField = new FXTextField(this, 10, tgt, MID_GNE_MODE_ADDITIONAL_CHANGEPARAMETER_TEXT, LAYOUT_FILL_COLUMN | LAYOUT_FILL_X);
539  myMenuCheck = new FXMenuCheck(this, "", tgt, MID_GNE_MODE_ADDITIONAL_CHANGEPARAMETER_BOOL, LAYOUT_FIX_WIDTH);
540  // Set widht of menuCheck manually
541  myMenuCheck->setWidth(20);
542  // Hide elements
543  hideParameter();
544 }
545 
546 
548 
549 
550 void
552  myAttr = attr;
553  myLabel->setText(toString(myAttr).c_str());
554  myLabel->show();
555  myTextField->setText(value.c_str());
556  myTextField->show();
557  show();
558 }
559 
560 
561 void
563  myAttr = attr;
564  myLabel->setText(toString(myAttr).c_str());
565  myLabel->show();
566  myTextField->setText(toString(value).c_str());
567  myTextField->show();
568  show();
569 }
570 
571 
572 void
574  myAttr = attr;
575  myLabel->setText(toString(myAttr).c_str());
576  myLabel->show();
577  myTextField->setText(toString(value).c_str());
578  myTextField->show();
579  show();
580 }
581 
582 
583 void
585  myAttr = attr;
586  myLabel->setText(toString(myAttr).c_str());
587  myLabel->show();
588  myMenuCheck->setCheck(value);
589  myMenuCheck->show();
590  show();
591 }
592 
593 
594 void
596  myAttr = SUMO_ATTR_NOTHING;
597  myLabel->hide();
598  myTextField->hide();
599  myMenuCheck->hide();
600  hide();
601 }
602 
603 
606  return myAttr;
607 }
608 
609 
610 std::string
612  if (GNEAttributeCarrier::isBool(myAttr)) {
613  return (myMenuCheck->getCheck() == 1) ? "true" : "false";
614  } else {
615  return myTextField->getText().text();
616  }
617 }
618 
619 // ---------------------------------------------------------------------------
620 // GNEAdditionalFrame::additionalParameterList - methods
621 // ---------------------------------------------------------------------------
622 
624  FXMatrix(parent, 2, MATRIX_BY_COLUMNS | LAYOUT_FILL_X),
625  myAttr(SUMO_ATTR_NOTHING),
626  numberOfVisibleTextfields(1),
627  myMaxNumberOfValuesInParameterList(20) {
628  // Create elements
629  for (int i = 0; i < myMaxNumberOfValuesInParameterList; i++) {
630  myLabels.push_back(new FXLabel(this, "name", 0, JUSTIFY_RIGHT | LAYOUT_FIX_WIDTH, 0, 0, 60, 0));
631  myTextFields.push_back(new FXTextField(this, 10, tgt, MID_GNE_MODE_ADDITIONAL_CHANGEPARAMETER_TEXT, LAYOUT_FILL_COLUMN | LAYOUT_FILL_X));
632  }
633  // Create label Row
634  myLabels.push_back(new FXLabel(this, "Rows", 0, JUSTIFY_RIGHT | LAYOUT_FIX_WIDTH, 0, 0, 60, 0));
635  FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(this, LAYOUT_FILL_COLUMN | LAYOUT_FILL_X);
636  // Create add button
637  add = new FXButton(buttonsFrame, "", GUIIconSubSys::getIcon(ICON_ADD), this, MID_GNE_ADDROW,
638  ICON_BEFORE_TEXT | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT | FRAME_THICK | FRAME_RAISED,
639  0, 0, 20, 20);
640  // Create delete buttons
641  remove = new FXButton(buttonsFrame, "", GUIIconSubSys::getIcon(ICON_REMOVE), this, MID_GNE_REMOVEROW,
642  ICON_BEFORE_TEXT | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT | FRAME_THICK | FRAME_RAISED,
643  0, 0, 20, 20);
644  // Hide all para meters
645  hideParameter();
646 }
647 
648 
650 
651 
652 void
654  myAttr = attr;
655  std::cout << "FINISH" << std::endl;
656 }
657 
658 void
660  myAttr = attr;
661  std::cout << "FINISH" << std::endl;
662 }
663 
664 void
666  myAttr = attr;
667  std::cout << "FINISH" << std::endl;
668 }
669 
670 void
672  if ((int)value.size() < myMaxNumberOfValuesInParameterList) {
673  myAttr = attr;
674  numberOfVisibleTextfields = (int)value.size();
675  if (numberOfVisibleTextfields == 0) {
676  numberOfVisibleTextfields++;
677  }
678  for (int i = 0; i < myMaxNumberOfValuesInParameterList; i++) {
679  myLabels.at(i)->setText((toString(attr) + ": " + toString(i)).c_str());
680  }
681  for (int i = 0; i < numberOfVisibleTextfields; i++) {
682  myLabels.at(i)->show();
683  myTextFields.at(i)->show();
684  }
685  add->show();
686  remove->show();
687  show();
688  }
689 }
690 
691 
692 void
694  myAttr = SUMO_ATTR_NOTHING;
695  for (int i = 0; i < myMaxNumberOfValuesInParameterList; i++) {
696  myLabels.at(i)->hide();
697  myTextFields.at(i)->hide();
698  myTextFields.at(i)->setText("");
699  }
700  add->hide();
701  remove->hide();
702  hide();
703 }
704 
705 
708  return myAttr;
709 }
710 
711 
712 std::string
714  // Declare, fill and return a string with the list values
715  std::string value;
716  for (int i = 0; i < numberOfVisibleTextfields; i++) {
717  if (!myTextFields.at(i)->getText().empty()) {
718  value += (myTextFields.at(i)->getText().text() + std::string(" "));
719  }
720  }
721  return value;
722 }
723 
724 
725 long
727  if (numberOfVisibleTextfields < (myMaxNumberOfValuesInParameterList - 1)) {
728  myLabels.at(numberOfVisibleTextfields)->show();
729  myTextFields.at(numberOfVisibleTextfields)->show();
730  numberOfVisibleTextfields++;
731  getParent()->recalc();
732  }
733  return 1;
734 }
735 
736 
737 long
739  if (numberOfVisibleTextfields > 1) {
740  numberOfVisibleTextfields--;
741  myLabels.at(numberOfVisibleTextfields)->hide();
742  myTextFields.at(numberOfVisibleTextfields)->hide();
743  myTextFields.at(numberOfVisibleTextfields)->setText("");
744 
745  getParent()->recalc();
746  }
747  return 1;
748 }
749 
750 // ---------------------------------------------------------------------------
751 // GNEAdditionalFrame::editorParameters- methods
752 // ---------------------------------------------------------------------------
753 
755  FXGroupBox(parent, "Default parameters", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X),
756  myIndexParameter(0),
757  myIndexParameterList(0),
758  maxNumberOfParameters(GNEAttributeCarrier::getHigherNumberOfAttributes()),
759  maxNumberOfListParameters(2) {
760 
761  // Create widgets for parameters
762  for (int i = 0; i < maxNumberOfParameters; i++) {
763  myVectorOfAdditionalParameter.push_back(new additionalParameter(this, tgt));
764  }
765 
766  // Create widgets for parameters
767  for (int i = 0; i < maxNumberOfListParameters; i++) {
769  }
770 
771  // Create help button
772  helpAdditional = new FXButton(this, "Help", 0, this, MID_HELP);
773 }
774 
775 
777 }
778 
779 
780 void
782  // Hidde al fields
783  for (int i = 0; i < maxNumberOfParameters; i++) {
784  myVectorOfAdditionalParameter.at(i)->hideParameter();
785  }
786 
787  // Hidde al list fields
788  for (int i = 0; i < maxNumberOfListParameters; i++) {
789  myVectorOfAdditionalParameterList.at(i)->hideParameter();
790  }
791 
792  // Reset indexs
793  myIndexParameterList = 0;
794  myIndexParameter = 0;
795 }
796 
797 
798 void
800  // Set current additional
801  myAdditional = additional;
802  // If parameter is of type list
803  if (GNEAttributeCarrier::isList(attribute)) {
804  // If parameter can be show
805  if (myIndexParameterList < maxNumberOfListParameters) {
806  // Check type of attribute list
807  if (GNEAttributeCarrier::isInt(attribute)) {
808  myVectorOfAdditionalParameterList.at(myIndexParameterList)->showListParameter(attribute, GNEAttributeCarrier::getDefaultValue< std::vector<int> >(additional, attribute));
809  } else if (GNEAttributeCarrier::isFloat(attribute)) {
810  myVectorOfAdditionalParameterList.at(myIndexParameterList)->showListParameter(attribute, GNEAttributeCarrier::getDefaultValue< std::vector<SUMOReal> >(additional, attribute));
811  } else if (GNEAttributeCarrier::isBool(attribute)) {
812  myVectorOfAdditionalParameterList.at(myIndexParameterList)->showListParameter(attribute, GNEAttributeCarrier::getDefaultValue< std::vector<bool> >(additional, attribute));
813  } else if (GNEAttributeCarrier::isString(attribute)) {
814  myVectorOfAdditionalParameterList.at(myIndexParameterList)->showListParameter(attribute, GNEAttributeCarrier::getDefaultValue< std::vector<std::string> >(additional, attribute));
815  }
816  // Update index
817  myIndexParameterList++;
818  } else {
819  WRITE_ERROR("Max number of list attributes reached (" + toString(maxNumberOfListParameters) + ").");
820  }
821  } else {
822  if (myIndexParameter < maxNumberOfParameters) {
823  // Check type of attribute list
824  if (GNEAttributeCarrier::isInt(attribute)) {
825  myVectorOfAdditionalParameter.at(myIndexParameter)->showParameter(attribute, GNEAttributeCarrier::getDefaultValue<int>(additional, attribute));
826  } else if (GNEAttributeCarrier::isFloat(attribute)) {
827  myVectorOfAdditionalParameter.at(myIndexParameter)->showParameter(attribute, GNEAttributeCarrier::getDefaultValue<SUMOReal>(additional, attribute));
828  } else if (GNEAttributeCarrier::isBool(attribute)) {
829  myVectorOfAdditionalParameter.at(myIndexParameter)->showParameter(attribute, GNEAttributeCarrier::getDefaultValue<bool>(additional, attribute));
830  } else if (GNEAttributeCarrier::isString(attribute)) {
831  myVectorOfAdditionalParameter.at(myIndexParameter)->showParameter(attribute, GNEAttributeCarrier::getDefaultValue<std::string>(additional, attribute));
832  } else {
833  WRITE_WARNING("Attribute '" + toString(attribute) + "' don't have a defined type. Check definition in GNEAttributeCarrier");
834  }
835  // Update index parameter
836  myIndexParameter++;
837  } else {
838  WRITE_ERROR("Max number of attributes reached (" + toString(maxNumberOfParameters) + ").");
839  }
840  }
841 }
842 
843 
844 void
846  recalc();
847  show();
848 }
849 
850 
851 void
853  hide();
854 }
855 
856 
857 std::map<SumoXMLAttr, std::string>
859  std::map<SumoXMLAttr, std::string> values;
860  // get standar Parameters
861  for (int i = 0; i < myIndexParameter; i++) {
862  values[myVectorOfAdditionalParameter.at(i)->getAttr()] = myVectorOfAdditionalParameter.at(i)->getValue();
863  }
864  // get list parameters
865  for (int i = 0; i < myIndexParameterList; i++) {
866  values[myVectorOfAdditionalParameterList.at(i)->getAttr()] = myVectorOfAdditionalParameterList.at(i)->getListValues();
867  }
868  return values;
869 }
870 
871 
872 int
874  return (myIndexParameter + myIndexParameterList);
875 }
876 
877 
878 long
880  // Create help dialog
881  FXDialogBox* helpDialog = new FXDialogBox(this, ("Parameters of " + toString(myAdditional)).c_str(), DECOR_CLOSE | DECOR_TITLE);
882  // Create FXTable
883  FXTable* myTable = new FXTable(helpDialog, this, MID_TABLE, TABLE_READONLY);
884  myTable->setVisibleRows((FXint)(myIndexParameter + myIndexParameterList));
885  myTable->setVisibleColumns(3);
886  myTable->setTableSize((FXint)(myIndexParameter + myIndexParameterList), 3);
887  myTable->setBackColor(FXRGB(255, 255, 255));
888  myTable->setColumnText(0, "Name");
889  myTable->setColumnText(1, "Value");
890  myTable->setColumnText(2, "Definition");
891  myTable->getRowHeader()->setWidth(0);
892  FXHeader* header = myTable->getColumnHeader();
893  header->setItemJustify(0, JUSTIFY_CENTER_X);
894  header->setItemSize(0, 120);
895  header->setItemJustify(1, JUSTIFY_CENTER_X);
896  header->setItemSize(1, 80);
897  int maxSizeColumnDefinitions = 0;
898  // Iterate over vector of additional parameters
899  for (int i = 0; i < myIndexParameter; i++) {
900  SumoXMLAttr attr = myVectorOfAdditionalParameter.at(i)->getAttr();
901  // Set name of attribute
902  myTable->setItem(i, 0, new FXTableItem(toString(attr).c_str()));
903  // Set type
904  FXTableItem* type = new FXTableItem("");
905  if (GNEAttributeCarrier::isInt(attr)) {
906  type->setText("int");
907  } else if (GNEAttributeCarrier::isFloat(attr)) {
908  type->setText("float");
909  } else if (GNEAttributeCarrier::isBool(attr)) {
910  type->setText("bool");
911  } else if (GNEAttributeCarrier::isString(attr)) {
912  type->setText("string");
913  }
914  type->setJustify(FXTableItem::CENTER_X);
915  myTable->setItem(i, 1, type);
916  // Set definition
917  FXTableItem* definition = new FXTableItem(GNEAttributeCarrier::getDefinition(myAdditional, attr).c_str());
918  definition->setJustify(FXTableItem::LEFT);
919  myTable->setItem(i, 2, definition);
920  if ((int)GNEAttributeCarrier::getDefinition(myAdditional, attr).size() > maxSizeColumnDefinitions) {
921  maxSizeColumnDefinitions = int(GNEAttributeCarrier::getDefinition(myAdditional, attr).size());
922  }
923  }
924  // Iterate over vector of additional parameters list
925  for (int i = 0; i < myIndexParameterList; i++) {
926  SumoXMLAttr attr = myVectorOfAdditionalParameterList.at(i)->getAttr();
927  // Set name of attribute
928  myTable->setItem(i, 0, new FXTableItem(toString(attr).c_str()));
929  // Set type
930  FXTableItem* type = new FXTableItem("");
931  if (GNEAttributeCarrier::isInt(attr)) {
932  type->setText("list of int");
933  } else if (GNEAttributeCarrier::isFloat(attr)) {
934  type->setText("list of float");
935  } else if (GNEAttributeCarrier::isBool(attr)) {
936  type->setText("list of bool");
937  } else if (GNEAttributeCarrier::isString(attr)) {
938  type->setText("list of string");
939  }
940  type->setJustify(FXTableItem::CENTER_X);
941  myTable->setItem(i, 1, type);
942  // Set definition
943  FXTableItem* definition = new FXTableItem(GNEAttributeCarrier::getDefinition(myAdditional, attr).c_str());
944  definition->setJustify(FXTableItem::LEFT);
945  myTable->setItem(i, 2, definition);
946  if ((int)GNEAttributeCarrier::getDefinition(myAdditional, attr).size() > maxSizeColumnDefinitions) {
947  maxSizeColumnDefinitions = int(GNEAttributeCarrier::getDefinition(myAdditional, attr).size());
948  }
949  }
950  // Set size of column
951  header->setItemJustify(2, JUSTIFY_CENTER_X);
952  header->setItemSize(2, maxSizeColumnDefinitions * 6);
953  // Button Close
954  new FXButton(helpDialog, "OK\t\tclose", 0, helpDialog, FXDialogBox::ID_ACCEPT, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 4, 4, 3, 3);
955  helpDialog->create();
956  helpDialog->show();
957  return 1;
958 }
959 
960 // ---------------------------------------------------------------------------
961 // GNEAdditionalFrame::editorParameters- methods
962 // ---------------------------------------------------------------------------
963 
964 GNEAdditionalFrame::editorParameters::editorParameters(FXComposite* parent, FXObject* tgt) :
965  FXGroupBox(parent, "editor parameters", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X),
966  myActualAdditionalReferencePoint(GNE_ADDITIONALREFERENCEPOINT_LEFT) {
967  // Create FXListBox for the reference points
968  myReferencePointMatchBox = new FXComboBox(this, 12, this, MID_GNE_MODE_ADDITIONAL_REFERENCEPOINT,
969  FRAME_SUNKEN | LAYOUT_LEFT | COMBOBOX_STATIC | LAYOUT_FILL_X);
970 
971  // Create Frame for Label and TextField
972  FXHorizontalFrame* lengthFrame = new FXHorizontalFrame(this, LAYOUT_FILL_X | LAYOUT_LEFT);
973 
974  // Create length label
975  myLengthLabel = new FXLabel(lengthFrame, "Length:", 0, JUSTIFY_LEFT | LAYOUT_FILL_X);
976 
977  // Create length text field
978  myLengthTextField = new FXTextField(lengthFrame, 10, tgt, MID_GNE_MODE_ADDITIONAL_CHANGEPARAMETER_TEXT, LAYOUT_FILL_COLUMN | LAYOUT_FILL_X);
979 
980  // Set default value of length
981  myLengthTextField->setText("10");
982 
983  // Create FXMenuCheck for the force option
984  myCheckForcePosition = new FXMenuCheck(this, "Force position", this, MID_GNE_MODE_ADDITIONAL_FORCEPOSITION,
985  LAYOUT_LEFT | LAYOUT_FILL_X);
986 
987  // Create FXMenuCheck for the force option
988  myCheckBlock = new FXMenuCheck(this, "Block movement", this, MID_GNE_SET_BLOCKING,
989  LAYOUT_LEFT | LAYOUT_FILL_X);
990 
991  // Create help button
992  helpReferencePoint = new FXButton(this, "Help", 0, this, MID_HELP);
993 
994  // Add options to myReferencePointMatchBox
995  myReferencePointMatchBox->appendItem("reference left");
996  myReferencePointMatchBox->appendItem("reference right");
997  myReferencePointMatchBox->appendItem("reference center");
998 
999  // Set visible items
1000  myReferencePointMatchBox->setNumVisible((int)myReferencePointMatchBox->getNumItems());
1001 }
1002 
1003 
1005 
1006 
1007 void
1009  myLengthLabel->show();
1010  myLengthTextField->show();
1011 }
1012 
1013 
1014 void
1016  myLengthLabel->hide();
1017  myLengthTextField->hide();
1018 }
1019 
1020 
1021 void
1023  myReferencePointMatchBox->show();
1024  myCheckForcePosition->show();
1025 }
1026 
1027 
1028 void
1030  myReferencePointMatchBox->hide();
1031  myCheckForcePosition->hide();
1032 }
1033 
1034 
1037  return myActualAdditionalReferencePoint;
1038 }
1039 
1040 
1041 SUMOReal
1043  return GNEAttributeCarrier::parse<SUMOReal>(myLengthTextField->getText().text());
1044 }
1045 
1046 
1047 bool
1049  return myCheckBlock->getCheck() == 1 ? true : false;
1050 }
1051 
1052 
1053 bool
1055  return myCheckForcePosition->getCheck() == 1 ? true : false;
1056 }
1057 
1058 
1059 long
1061  // Cast actual reference point type
1062  myActualAdditionalReferencePoint = static_cast<additionalReferencePoint>(myReferencePointMatchBox->getCurrentItem());
1063  return 1;
1064 }
1065 
1066 
1067 long
1069  FXDialogBox* helpDialog = new FXDialogBox(this, "Parameter editor Help", DECOR_CLOSE | DECOR_TITLE);
1070  std::ostringstream help;
1071  help
1072  << "Referece point: Mark the initial position of the additional element.\n"
1073  << "Example: If you want to create a busStop with a lenght of 30 in the point 100 of the lane:\n"
1074  << "- Reference Left will create it with startPos = 70 and endPos = 100.\n"
1075  << "- Reference Right will create it with startPos = 100 and endPos = 130.\n"
1076  << "- Reference Center will create it with startPos = 85 and endPos = 115.\n"
1077  << "\n"
1078  << "Force position: if is enabled, will create the additional adapting size of additional element to lane.\n"
1079  << "Example: If you have a lane with lenght = 100, but you try to create a busStop with size = 50\n"
1080  << "in the position 80 of the lane, a busStop with startPos = 80 and endPos = 100 will be created\n"
1081  << "instead of a busStop with startPos = 80 and endPos = 130.\n"
1082  << "\n"
1083  << "Block movement: if is enabled, the created additional element will be blocked. i.e. cannot be moved with\n"
1084  << "the mouse. This option can be modified with the Inspector.";
1085  new FXLabel(helpDialog, help.str().c_str(), 0, JUSTIFY_LEFT);
1086  // "OK"
1087  new FXButton(helpDialog, "OK\t\tclose", 0, helpDialog, FXDialogBox::ID_ACCEPT,
1088  ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
1089  0, 0, 0, 0, 4, 4, 3, 3);
1090  helpDialog->create();
1091  helpDialog->show();
1092  return 1;
1093 }
1094 
1095 
1096 std::string
1098  // Obtain Id's of list
1099  std::string vectorOfIds;
1100  for (int i = 0; i < list->getNumItems(); i++) {
1101  if (list->isItemSelected(i)) {
1102  if (vectorOfIds.size() > 0) {
1103  vectorOfIds += " ";
1104  }
1105  vectorOfIds += (list->getItem(i)->getText()).text();
1106  }
1107  }
1108  return vectorOfIds;
1109 }
1110 
1111 
1112 
1113 // ---------------------------------------------------------------------------
1114 // GNEAdditionalFrame::additionalSet - methods
1115 // ---------------------------------------------------------------------------
1116 
1117 GNEAdditionalFrame::additionalSet::additionalSet(FXComposite* parent, FXObject* tgt, GNEViewNet* viewNet) :
1118  FXGroupBox(parent, "Additional Set", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X),
1119  myType(SUMO_TAG_NOTHING),
1120  myViewNet(viewNet) {
1121 
1122  // Create label with the type of additionalSet
1123  mySetLabel = new FXLabel(this, "Set Type:", 0, JUSTIFY_LEFT | LAYOUT_FILL_X);
1124 
1125  // Create list
1126  myList = new FXList(this, tgt, MID_GNE_SELECTADDITIONALSET, LAYOUT_FILL_X | LAYOUT_FIX_HEIGHT, 0, 0, 0, 100);
1127 
1128  // Create help button
1129  helpAdditionalSet = new FXButton(this, "Help", 0, this, MID_HELP);
1130 
1131  // Hide List
1132  hideList();
1133 }
1134 
1135 
1137 
1138 
1139 std::string
1141  for (int i = 0; i < myList->getNumItems(); i++) {
1142  if (myList->isItemSelected(i)) {
1143  return myList->getItem(i)->getText().text();
1144  }
1145  }
1146  return "";
1147 }
1148 
1149 
1150 SumoXMLTag
1152  return myType;
1153 }
1154 
1155 
1156 void
1158  myType = type;
1159  mySetLabel->setText(("Type of set: " + toString(myType)).c_str());
1160  myList->clearItems();
1161  const std::vector<GNEAdditional*>& vectorOfAdditionalSets = myViewNet->getNet()->getAdditionals(myType);
1162  for (std::vector<GNEAdditional*>::const_iterator i = vectorOfAdditionalSets.begin(); i != vectorOfAdditionalSets.end(); i++) {
1163  myList->appendItem((*i)->getID().c_str());
1164  }
1165  show();
1166 }
1167 
1168 
1169 void
1171  myType = SUMO_TAG_NOTHING;
1172  hide();
1173 }
1174 
1175 
1176 long
1178  return 1;
1179 }
1180 
1181 
1182 long
1183 GNEAdditionalFrame::additionalSet::onCmdHelp(FXObject*, FXSelector, void*) {
1184  return 1;
1185 }
1186 
1187 
1188 // ---------------------------------------------------------------------------
1189 // GNEAdditionalFrame::edgesSelector - methods
1190 // ---------------------------------------------------------------------------
1191 
1193  FXGroupBox(parent, "Edges", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X),
1194  myViewNet(viewNet) {
1195  // Create CheckBox for selected edges
1196  myUseSelectedEdges = new FXMenuCheck(this, "Use selected Edges", this, MID_GNE_USESELECTEDEDGES);
1197 
1198  // Create search box
1199  myEdgesSearch = new FXTextField(this, 10, this, MID_GNE_SEARCHEDGE, LAYOUT_FILL_X);
1200 
1201  // Create list
1202  myList = new FXList(this, this, MID_GNE_SELECTEDGE, LAYOUT_FILL_X | LAYOUT_FIX_HEIGHT, 0, 0, 0, 100);
1203 
1204  // Create horizontal frame
1205  FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(this, LAYOUT_FILL_X);
1206 
1207  // Create button for clear selection
1208  clearEdgesSelection = new FXButton(buttonsFrame, "clear", 0, this, MID_GNE_CLEAREDGESELECTION);
1209 
1210  // Create button for invert selection
1211  invertEdgesSelection = new FXButton(buttonsFrame, "invert", 0, this, MID_GNE_INVERTEDGESELECTION);
1212 
1213  // Create help button
1214  helpEdges = new FXButton(this, "Help", 0, this, MID_HELP);
1215 
1216  // Hide List
1217  hideList();
1218 }
1219 
1220 
1222 
1223 
1224 std::string
1226  return GNEAdditionalFrame::getIdsSelected(myList);
1227 }
1228 
1229 
1230 void
1232  // FIll list
1233  myList->clearItems();
1234  std::vector<GNEEdge*> vectorOfEdges = myViewNet->getNet()->retrieveEdges(false);
1235  for (std::vector<GNEEdge*>::iterator i = vectorOfEdges.begin(); i != vectorOfEdges.end(); i++) {
1236  if ((*i)->getID().find(search) != std::string::npos) {
1237  myList->appendItem((*i)->getID().c_str());
1238  }
1239  }
1240  // By default, CheckBox for useSelectedEdges isn't checked
1241  myUseSelectedEdges->setCheck(false);
1242  // Recalc Frame
1243  recalc();
1244  // Update Frame
1245  update();
1246  // Show dialog
1247  show();
1248 }
1249 
1250 
1251 void
1253  FXGroupBox::hide();
1254 }
1255 
1256 
1257 void
1259  // Enable or disable use selected edges
1260  if (myViewNet->getNet()->retrieveEdges(true).size() > 0) {
1261  myUseSelectedEdges->enable();
1262  } else {
1263  myUseSelectedEdges->disable();
1264  }
1265 }
1266 
1267 
1268 bool
1270  if (myUseSelectedEdges->getCheck()) {
1271  return true;
1272  } else {
1273  return false;
1274  }
1275 }
1276 
1277 
1278 long
1280  if (myUseSelectedEdges->getCheck()) {
1281  myEdgesSearch->hide();
1282  myList->hide();
1283  clearEdgesSelection->hide();
1284  invertEdgesSelection->hide();
1285  helpEdges->hide();
1286  } else {
1287  myEdgesSearch->show();
1288  myList->show();
1289  clearEdgesSelection->show();
1290  invertEdgesSelection->show();
1291  helpEdges->show();
1292  }
1293  // Recalc Frame
1294  recalc();
1295  // Update Frame
1296  update();
1297  return 1;
1298 }
1299 
1300 
1301 long
1303  // Show only Id's of edgesSelector that contains the searched string
1304  showList(myEdgesSearch->getText().text());
1305  return 1;
1306 }
1307 
1308 
1309 long
1311  return 1;
1312 }
1313 
1314 
1315 long
1317  for (int i = 0; i < myList->getNumItems(); i++) {
1318  if (myList->getItem(i)->isSelected()) {
1319  myList->deselectItem(i);
1320  }
1321  }
1322  return 1;
1323 }
1324 
1325 
1326 long
1328  for (int i = 0; i < myList->getNumItems(); i++) {
1329  if (myList->getItem(i)->isSelected()) {
1330  myList->deselectItem(i);
1331  } else {
1332  myList->selectItem(i);
1333  }
1334  }
1335  return 1;
1336 }
1337 
1338 
1339 long
1340 GNEAdditionalFrame::edgesSelector::onCmdHelp(FXObject*, FXSelector, void*) {
1341  std::cout << "IMPLEMENT" << std::endl;
1342  return 1;
1343 }
1344 
1345 // ---------------------------------------------------------------------------
1346 // GNEAdditionalFrame::lanesSelector - methods
1347 // ---------------------------------------------------------------------------
1348 
1350  FXGroupBox(parent, "lanesSelector", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X),
1351  myViewNet(viewNet) {
1352  // Create CheckBox for selected lanes
1353  myUseSelectedLanes = new FXMenuCheck(this, "Use selected Lanes", this, MID_GNE_USESELECTEDLANES);
1354 
1355  // Create search box
1356  myLanesSearch = new FXTextField(this, 10, this, MID_GNE_SEARCHLANE, LAYOUT_FILL_X);
1357 
1358  // Create list
1359  myList = new FXList(this, this, MID_GNE_SELECTLANE, LAYOUT_FILL_X | LAYOUT_FIX_HEIGHT, 0, 0, 0, 100);
1360 
1361  // Create horizontal frame
1362  FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(this, LAYOUT_FILL_X);
1363 
1364  // Create button for clear selection
1365  clearLanesSelection = new FXButton(buttonsFrame, "clear", 0, this, MID_GNE_CLEARLANESELECTION);
1366 
1367  // Create button for invert selection
1368  invertLanesSelection = new FXButton(buttonsFrame, "invert", 0, this, MID_GNE_INVERTLANESELECTION);
1369 
1370  // Create help button
1371  helpLanes = new FXButton(this, "Help", 0, this, MID_HELP);
1372 
1373  // Hide List
1374  hideList();
1375 }
1376 
1377 
1379 
1380 
1381 std::string
1383  return GNEAdditionalFrame::getIdsSelected(myList);
1384 }
1385 
1386 
1387 void
1389  myList->clearItems();
1390  std::vector<GNELane*> vectorOfLanes = myViewNet->getNet()->retrieveLanes(false);
1391  for (std::vector<GNELane*>::iterator i = vectorOfLanes.begin(); i != vectorOfLanes.end(); i++) {
1392  if ((*i)->getID().find(search) != std::string::npos) {
1393  myList->appendItem((*i)->getID().c_str());
1394  }
1395  }
1396  // By default, CheckBox for useSelectedLanes isn't checked
1397  myUseSelectedLanes->setCheck(false);
1398  // Show list
1399  show();
1400 }
1401 
1402 
1403 void
1405  hide();
1406 }
1407 
1408 
1409 void
1411  // Enable or disable use selected Lanes
1412  if (myViewNet->getNet()->retrieveLanes(true).size() > 0) {
1413  myUseSelectedLanes->enable();
1414  } else {
1415  myUseSelectedLanes->disable();
1416  }
1417 }
1418 
1419 
1420 bool
1422  if (myUseSelectedLanes->getCheck()) {
1423  return true;
1424  } else {
1425  return false;
1426  }
1427 }
1428 
1429 
1430 long
1432  if (myUseSelectedLanes->getCheck()) {
1433  myLanesSearch->hide();
1434  myList->hide();
1435  clearLanesSelection->hide();
1436  invertLanesSelection->hide();
1437  helpLanes->hide();
1438  } else {
1439  myLanesSearch->show();
1440  myList->show();
1441  clearLanesSelection->show();
1442  invertLanesSelection->show();
1443  helpLanes->show();
1444  }
1445  // Recalc Frame
1446  recalc();
1447  // Update Frame
1448  update();
1449  return 1;
1450 }
1451 
1452 
1453 long
1455  // Show only Id's of lanesSelector that contains the searched string
1456  showList(myLanesSearch->getText().text());
1457  return 1;
1458 }
1459 
1460 
1461 long
1463  return 1;
1464 }
1465 
1466 
1467 long
1469  for (int i = 0; i < myList->getNumItems(); i++) {
1470  if (myList->getItem(i)->isSelected()) {
1471  myList->deselectItem(i);
1472  }
1473  }
1474  return 1;
1475 }
1476 
1477 
1478 long
1480  for (int i = 0; i < myList->getNumItems(); i++) {
1481  if (myList->getItem(i)->isSelected()) {
1482  myList->deselectItem(i);
1483  } else {
1484  myList->selectItem(i);
1485  }
1486  }
1487  return 1;
1488 }
1489 
1490 
1491 long
1492 GNEAdditionalFrame::lanesSelector::onCmdHelp(FXObject*, FXSelector, void*) {
1493  return 1;
1494 }
1495 
1496 /****************************************************************************/
static bool isList(SumoXMLAttr attr)
whether an attribute is of type bool
long onCmdSelectReferencePoint(FXObject *, FXSelector, void *)
std::string getValue() const
return value
long onCmdClearSelection(FXObject *, FXSelector, void *)
called when clear selection button is pressed
std::vector< GNELane * > retrieveLanes(bool onlySelected=false)
return all lanes
Definition: GNENet.cpp:729
SumoXMLTag
Numbers representing SUMO-XML - element names.
std::vector< additionalParameterList * > myVectorOfAdditionalParameterList
vector with the additional parameters of type list
FXMenuCheck * myCheckForcePosition
checkBox for the option "force position"
int maxNumberOfListParameters
max number of parameters (Defined in constructor)
void hideFramesArea()
hide frames area if all GNEFrames are hidden
FXLabel * myLabel
lael with the name of the parameter
SumoXMLTag getCurrentlyTag() const
get current tag
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
long onCmdHelp(FXObject *, FXSelector, void *)
Called when help button is pressed.
void addAttribute(SumoXMLTag additional, SumoXMLAttr attribute)
add attribute
long onCmdInvertSelection(FXObject *, FXSelector, void *)
called when invert selection button is pressed
bool isBlockEnabled()
check if block is enabled
int getNumberOfAddedAttributes() const
get number of added attributes
FXDEFMAP(GNEAdditionalFrame) GNEAdditionalMap[]
FXButton * add
Button to increase the number of textFields.
void showFramesArea()
show frames area if at least a GNEFrame is showed
long onCmdHelp(FXObject *, FXSelector, void *)
Called when help button is pressed.
long onCmdHelp(FXObject *, FXSelector, void *)
Called when help button is pressed.
long onCmdSelectEdge(FXObject *, FXSelector, void *)
called when user select a edge of the list
FXButton * clearEdgesSelection
button for clear selection
FXMenuCheck * myUseSelectedEdges
CheckBox for selected edges.
FXTextField * myLengthTextField
textField for lenght
FXButton * helpAdditionalSet
button for help
additionalReferencePoint getActualReferencePoint()
get actual reference point
FXButton * invertEdgesSelection
button for invert selection
static bool buildAdditional(GNEViewNet *viewNet, SumoXMLTag tag, std::map< SumoXMLAttr, std::string > values)
Builds additional / additionalSet.
void remove2Update()
Removes the dialog to be updated.
GNEAdditionalFrame::lanesSelector * myLanesSelector
list of lanesSelector
long onCmdSelectAdditional(FXObject *, FXSelector, void *)
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:55
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:86
bool addAdditional(GNENetElement *netElement, GUISUMOAbstractView *parent)
add additional element
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
GNEViewParent * getViewParent() const
get the net object
Definition: GNEViewNet.cpp:906
bool isUseSelectedLanesEnable() const
get status of checkBox UseSelectedLanes
std::string getIdsSelected() const
get list of selecte id's in string format
GNEAdditionalFrame::additionalParameters * myAdditionalParameters
additional default parameters
static const std::vector< std::pair< SumoXMLAttr, std::string > > & allowedAttributes(SumoXMLTag tag)
get all editable attributes for tag and their default values.
void setParametersOfAdditional(SumoXMLTag actualAdditionalType)
set parameters depending of the new additionalType
void showListParameter(SumoXMLAttr attr, std::vector< int > value)
show name and value of parameters of type int
FXTextField * myLanesSearch
text field for search lane IDs
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
long onCmdInvertSelection(FXObject *, FXSelector, void *)
called when invert selection button is pressed
std::vector< FXLabel * > myLabels
vector with with the name of every parameter
GNEUndoList * getUndoList() const
get the undoList object
Definition: GNEViewNet.cpp:918
additional match box messages
Definition: GUIAppEnum.h:426
std::string getIdSelected() const
get if currently additional Set
void hide()
hidde additional frame
GNEViewNet * myViewNet
the window to inform when the tls is modfied
Definition: GNEFrame.h:85
void showReferencePoint()
show refence point comboBox
FXList * myList
List of lanesSelector.
FXTextField * myTextField
textField to modify the value of parameter
GNEAdditionalFrame::editorParameters * myEditorParameters
editor parameter
SUMOReal setEndPosition(SUMOReal laneLenght, SUMOReal positionOfTheMouseOverLane, SUMOReal lenghtOfAdditional)
obtain the End position values of StoppingPlaces and E2 detector over the lane
long onCmdRemoveRow(FXObject *, FXSelector, void *)
add a new row int the list
SUMOReal getLenght()
get value of lenght
the edges of a route
static bool hasAttribute(SumoXMLTag tag, SumoXMLAttr attr)
check if a element with certain tag has a certain attribute
std::map< SumoXMLAttr, std::string > getAttributes() const
get attributes
The Table.
Definition: GUIAppEnum.h:289
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:51
static bool hasParent(SumoXMLTag tag)
check if a element with certain tag has another additional element as 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:93
FXList * myList
List of edgesSelector.
SumoXMLTag myActualAdditionalType
actual additional type selected in the match Box
virtual std::string getDescription()
how should this attribute carrier be called
void removeAdditional(GNEAdditional *additional)
remove an additional element previously added
long onCmdHelp(FXObject *, FXSelector, void *)
Called when help button is pressed.
static T getDefaultValue(SumoXMLTag tag, SumoXMLAttr attr)
return the default value of the attribute of an element
std::vector< GNEAdditional * > getAdditionals(SumoXMLTag type=SUMO_TAG_NOTHING)
get vector with additionals
Definition: GNENet.cpp:1273
SumoXMLAttr getAttr() const
return attribute of list
void showList(std::string search="")
Show list of edgesSelector.
~GNEAdditionalFrame()
Destructor.
FXButton * helpReferencePoint
Button for help about the reference point.
FXComboBox * myAdditionalMatchBox
combo box with the list of additional elements
int getNumberOfAdditionals(SumoXMLTag type=SUMO_TAG_NOTHING)
Returns the number of additionals of the net.
Definition: GNENet.cpp:1285
long onCmdUseSelectedLanes(FXObject *, FXSelector, void *)
long onCmdAddRow(FXObject *, FXSelector, void *)
GNEAdditionalFrame::additionalSet * myAdditionalSet
list of additional Set
const std::string getID() const
function to support debugging
SUMOReal setStartPosition(SUMOReal positionOfTheMouseOverLane, SUMOReal lenghtOfAdditional)
obtain the Start position values of StoppingPlaces and E2 detector over the lane
FXLabel * myLengthLabel
Label for lenght.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
long onCmdHelp(FXObject *, FXSelector, void *)
FXMenuCheck * myCheckBlock
checkBox for blocking movement
static bool isFloat(SumoXMLAttr attr)
whether an attribute is numerical of type float
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:55
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
std::string getListValues()
return the value of list
bool isForcePositionEnabled()
check if force position is enabled
std::vector< FXTextField * > myTextFields
vector textField to modify the value of parameter
GNEAdditional * getAdditional(SumoXMLTag type, const std::string &id) const
Returns the named additional.
Definition: GNENet.cpp:1250
FXTextField * myEdgesSearch
text field for search edge IDs
FXButton * helpEdges
button for help
std::string generateID(GNENetElement *netElement) const
generate a ID for an additiona element
FXButton * clearLanesSelection
button for clear selection
const PositionVector & getShape() const
returns the shape of the lane
Definition: GNELane.cpp:583
SUMOReal getLaneShapeLenght() const
returns the length of the lane's shape
Definition: GNELane.cpp:687
int myMaxNumberOfValuesInParameterList
Number max of values in a parameter of type list.
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
Definition: GNEEdge.cpp:485
long onCmdUseSelectedEdges(FXObject *, FXSelector, void *)
static const std::vector< SumoXMLTag > & allowedAdditionalTags()
get all editable tags for additionals
void show()
show additional frame
static bool isInt(SumoXMLAttr attr)
whether an attribute is numerical or type int
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Definition: GNENet.cpp:717
FXList * myList
List of additional sets.
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:63
void hideReferencePoint()
hide refence point comboBox
long onCmdTypeInSearchBox(FXObject *, FXSelector, void *)
called when user type in search box
additionalParameter(FXComposite *parent, FXObject *tgt)
constructor
std::vector< additionalParameter * > myVectorOfAdditionalParameter
vector with the additional parameters
SumoXMLAttr getAttr() const
return Attr
long onCmdClearSelection(FXObject *, FXSelector, void *)
called when clear selection button is pressed
void updateUseSelectedEdges()
Update use selectedEdges.
static std::string getDefinition(SumoXMLTag tag, SumoXMLAttr attr)
return definition of a certain SumoXMLAttr
GNENet * getNet() const
get the net object
Definition: GNEViewNet.cpp:912
std::string getIdsSelected() const
get list of selecte id's in string format
FXMenuCheck * myMenuCheck
menuCheck to enable/disable the value of parameter
static SumoXMLTag getParentType(SumoXMLTag tag)
get parent's tag of a certain additional element
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:188
#define SUMOReal
Definition: config.h:214
static bool isUnique(SumoXMLAttr attr)
whether an attribute is unique (may not be edited for a multi-selection)
static bool isString(SumoXMLAttr attr)
whether an attribute is of type string
long onCmdSelectLane(FXObject *, FXSelector, void *)
called when user select a lane of the list
void showList(SumoXMLTag type)
Show list of additionalSet.
void showList(std::string search="")
Show list of lanesSelector.
FXMenuCheck * myUseSelectedLanes
CheckBox for selected lanes.
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
static std::string getIdsSelected(const FXList *list)
get list of selecte id's in string format
bool isUseSelectedEdgesEnable() const
get status of checkBox UseSelectedEdges
int maxNumberOfParameters
max number of parameters (Defined in constructor)
void showParameter(SumoXMLAttr attr, std::string value)
show name and value of attribute of type string
GUISelectedStorage gSelected
A global holder of selected objects.
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
FXLabel * mySetLabel
Label with the name of Set.
static bool isBool(SumoXMLAttr attr)
whether an attribute is of type bool
long onCmdSelectAdditionalSet(FXObject *, FXSelector, void *)
long onCmdTypeInSearchBox(FXObject *, FXSelector, void *)
called when user type in search box
FXButton * invertLanesSelection
button for invert selection
GNEAdditionalFrame::edgesSelector * myEdgesSelector
list of edgesSelector
FXButton * helpLanes
button for help
FXComboBox * myReferencePointMatchBox
match box with the list of reference points