SUMO - Simulation of Urban MObility
GNEDeleteFrame.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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // The Widget for remove network-elements
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 #include <iostream>
43 
44 #include "GNEAdditionalFrame.h"
45 #include "GNEAttributeCarrier.h"
46 #include "GNEChange_Selection.h"
47 #include "GNEConnection.h"
48 #include "GNECrossing.h"
49 #include "GNEDeleteFrame.h"
50 #include "GNEEdge.h"
51 #include "GNEInspectorFrame.h"
52 #include "GNEJunction.h"
53 #include "GNELane.h"
54 #include "GNENet.h"
55 #include "GNEPOI.h"
56 #include "GNEPoly.h"
57 #include "GNEUndoList.h"
58 #include "GNEViewNet.h"
59 #include "GNEViewParent.h"
60 #include "GNERerouter.h"
61 
62 // ===========================================================================
63 // FOX callback mapping
64 // ===========================================================================
65 
66 FXDEFMAP(GNEDeleteFrame) GNEDeleteFrameMap[] = {
67  FXMAPFUNC(SEL_RIGHTBUTTONRELEASE, MID_GNE_DELETEFRAME_CHILDS, GNEDeleteFrame::onCmdShowChildMenu),
71 };
72 
73 // Object implementation
74 FXIMPLEMENT(GNEDeleteFrame, FXVerticalFrame, GNEDeleteFrameMap, ARRAYNUMBER(GNEDeleteFrameMap))
75 
76 // ===========================================================================
77 // method definitions
78 // ===========================================================================
79 
80 GNEDeleteFrame::GNEDeleteFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet) :
81  GNEFrame(horizontalFrameParent, viewNet, "Delete"),
82  myMarkedAC(NULL) {
83  // Create Groupbox for current element
84  myGroupBoxCurrentElement = new FXGroupBox(myContentFrame, "Current element", GUIDesignGroupBoxFrame);
85  myCurrentElementLabel = new FXLabel(myGroupBoxCurrentElement, "No item under cursor", 0, GUIDesignLabelFrameInformation);
86 
87  // Create Groupbox for current element
88  myGroupBoxOptions = new FXGroupBox(myContentFrame, "Options", GUIDesignGroupBoxFrame);
89 
90  // Create checkbox for enabling/disabling automatic deletion of additionals childs (by default, enabled)
91  myAutomaticallyDeleteAdditionalsCheckButton = new FXCheckButton(myGroupBoxOptions, "Force deletion of additionals", this, MID_GNE_DELETEFRAME_AUTODELETEADDITIONALS, GUIDesignCheckButtonAttribute);
92  myAutomaticallyDeleteAdditionalsCheckButton->setCheck(true);
93 
94  // Create checkbox for enabling/disabling delete only geomtery point(by default, disabled)
95  myDeleteOnlyGeometryPoints = new FXCheckButton(myGroupBoxOptions, "Delete only geometryPoints", this, MID_GNE_DELETEFRAME_ONLYGEOMETRYPOINTS, GUIDesignCheckButtonAttribute);
96  myDeleteOnlyGeometryPoints->setCheck(false);
97 
98  // Create groupbox for tree list
99  myGroupBoxTreeList = new FXGroupBox(myContentFrame, "Childs", GUIDesignGroupBoxFrame);
100  myMarkedElementLabel = new FXLabel(myGroupBoxTreeList, "No item marked", 0, GUIDesignLabelFrameInformation);
101  myTreelist = new FXTreeList(myGroupBoxTreeList, this, MID_GNE_DELETEFRAME_CHILDS, GUIDesignTreeListFrame);
102 
103  // Create groupbox for help
104  myGroupBoxInformation = new FXGroupBox(myContentFrame, "Information", GUIDesignGroupBoxFrame);
105  myInformationLabel = new FXLabel(myGroupBoxInformation, " - Left click to delete element.\n - Hold <CTRL> and left click\n to mark element.\n - Left click in another element\n dismark marked element.", 0, GUIDesignLabelFrameInformation);
106 }
107 
108 
110 
111 
112 void
114  // clear items
115  myTreelist->clearItems();
116  myTreeItemToACMap.clear();
117  myTreeItemsWithoutAC.clear();
118  // Switch gl type of ac
119  if (myMarkedAC) {
120  switch (myMarkedAC->getGUIGLObject()->getType()) {
121  case GLO_JUNCTION: {
122  // insert junction root
123  GNEJunction* junction = dynamic_cast<GNEJunction*>(myMarkedAC);
124  FXTreeItem* junctionItem = myTreelist->insertItem(0, 0, toString(junction->getTag()).c_str(), junction->getIcon(), junction->getIcon());
125  myTreeItemToACMap[junctionItem] = junction;
126  junctionItem->setExpanded(true);
127  // insert edges
128  for (int i = 0; i < (int)junction->getGNEEdges().size(); i++) {
129  GNEEdge* edge = junction->getGNEEdges().at(i);
130  FXTreeItem* edgeItem = myTreelist->insertItem(0, junctionItem, (toString(edge->getTag()) + " " + toString(i)).c_str(), edge->getIcon(), edge->getIcon());
131  myTreeItemToACMap[edgeItem] = edge;
132  edgeItem->setExpanded(true);
133  // insert lanes
134  for (int j = 0; j < (int)edge->getLanes().size(); j++) {
135  GNELane* lane = edge->getLanes().at(j);
136  FXTreeItem* laneItem = myTreelist->insertItem(0, edgeItem, (toString(lane->getTag()) + " " + toString(j)).c_str(), lane->getIcon(), lane->getIcon());
137  myTreeItemToACMap[laneItem] = lane;
138  laneItem->setExpanded(true);
139  // insert additionals of lanes
140  for (int k = 0; k < (int)lane->getAdditionalChilds().size(); k++) {
141  GNEAdditional* additional = lane->getAdditionalChilds().at(k);
142  FXTreeItem* additionalItem = myTreelist->insertItem(0, laneItem, (toString(additional->getTag()) + " " + toString(k)).c_str(), additional->getIcon(), additional->getIcon());
143  myTreeItemToACMap[additionalItem] = additional;
144  additionalItem->setExpanded(true);
145  }
146  // insert incoming connections of lanes (by default isn't expanded)
147  if (lane->getGNEIncomingConnections().size() > 0) {
148  FXTreeItem* incomingConnections = myTreelist->insertItem(0, laneItem, "Incomings", lane->getGNEIncomingConnections().front()->getIcon(), lane->getGNEIncomingConnections().front()->getIcon());
149  myTreeItemsWithoutAC.insert(incomingConnections);
150  incomingConnections->setExpanded(false);
151  for (int k = 0; k < (int)lane->getGNEIncomingConnections().size(); k++) {
152  GNEConnection* connection = lane->getGNEIncomingConnections().at(k);
153  FXTreeItem* connectionItem = myTreelist->insertItem(0, incomingConnections, (toString(connection->getTag()) + " " + toString(k)).c_str(), connection->getIcon(), connection->getIcon());
154  myTreeItemToACMap[connectionItem] = connection;
155  connectionItem->setExpanded(true);
156  }
157  }
158  // insert outcoming connections of lanes (by default isn't expanded)
159  if (lane->getGNEOutcomingConnections().size() > 0) {
160  FXTreeItem* outgoingConnections = myTreelist->insertItem(0, laneItem, "Outcomings", lane->getGNEOutcomingConnections().front()->getIcon(), lane->getGNEOutcomingConnections().front()->getIcon());
161  myTreeItemsWithoutAC.insert(outgoingConnections);
162  outgoingConnections->setExpanded(false);
163  for (int k = 0; k < (int)lane->getGNEOutcomingConnections().size(); k++) {
164  GNEConnection* connection = lane->getGNEOutcomingConnections().at(k);
165  FXTreeItem* connectionItem = myTreelist->insertItem(0, outgoingConnections, (toString(connection->getTag()) + " " + toString(k)).c_str(), connection->getIcon(), connection->getIcon());
166  myTreeItemToACMap[connectionItem] = connection;
167  connectionItem->setExpanded(true);
168  }
169  }
170  }
171  // insert additionals of edge
172  for (int j = 0; j < (int)edge->getAdditionalChilds().size(); j++) {
173  GNEAdditional* additional = edge->getAdditionalChilds().at(j);
174  FXTreeItem* additionalItem = myTreelist->insertItem(0, edgeItem, (toString(additional->getTag()) + " " + toString(j)).c_str(), additional->getIcon(), additional->getIcon());
175  myTreeItemToACMap[additionalItem] = additional;
176  additionalItem->setExpanded(true);
177  }
178 
179  }
180  // insert crossings
181  for (int i = 0; i < (int)junction->getGNECrossings().size(); i++) {
182  GNECrossing* crossing = junction->getGNECrossings().at(i);
183  FXTreeItem* crossingItem = myTreelist->insertItem(0, junctionItem, (toString(crossing->getTag()) + " " + toString(i)).c_str(), crossing->getIcon(), crossing->getIcon());
184  myTreeItemToACMap[crossingItem] = crossing;
185  crossingItem->setExpanded(true);
186  }
187  break;
188  }
189  case GLO_EDGE: {
190  // insert edge root
191  GNEEdge* edge = dynamic_cast<GNEEdge*>(myMarkedAC);
192  FXTreeItem* edgeItem = myTreelist->insertItem(0, 0, toString(edge->getTag()).c_str(), edge->getIcon(), edge->getIcon());
193  myTreeItemToACMap[edgeItem] = edge;
194  edgeItem->setExpanded(true);
195  // insert lanes
196  for (int i = 0; i < (int)edge->getLanes().size(); i++) {
197  GNELane* lane = edge->getLanes().at(i);
198  FXTreeItem* laneItem = myTreelist->insertItem(0, edgeItem, (toString(lane->getTag()) + " " + toString(i)).c_str(), lane->getIcon(), lane->getIcon());
199  myTreeItemToACMap[laneItem] = lane;
200  laneItem->setExpanded(true);
201  // insert additionals of lanes
202  for (int j = 0; j < (int)lane->getAdditionalChilds().size(); j++) {
203  GNEAdditional* additional = lane->getAdditionalChilds().at(j);
204  FXTreeItem* additionalItem = myTreelist->insertItem(0, laneItem, (toString(additional->getTag()) + " " + toString(j)).c_str(), additional->getIcon(), additional->getIcon());
205  myTreeItemToACMap[additionalItem] = additional;
206  additionalItem->setExpanded(true);
207  }
208  // insert incoming connections of lanes (by default isn't expanded)
209  if (lane->getGNEIncomingConnections().size() > 0) {
210  FXTreeItem* incomingConnections = myTreelist->insertItem(0, laneItem, "Incomings", lane->getGNEIncomingConnections().front()->getIcon(), lane->getGNEIncomingConnections().front()->getIcon());
211  myTreeItemsWithoutAC.insert(incomingConnections);
212  incomingConnections->setExpanded(false);
213  for (int j = 0; j < (int)lane->getGNEIncomingConnections().size(); j++) {
214  GNEConnection* connection = lane->getGNEIncomingConnections().at(j);
215  FXTreeItem* connectionItem = myTreelist->insertItem(0, incomingConnections, (toString(connection->getTag()) + " " + toString(j)).c_str(), connection->getIcon(), connection->getIcon());
216  myTreeItemToACMap[connectionItem] = connection;
217  connectionItem->setExpanded(true);
218  }
219  }
220  // insert outcoming connections of lanes (by default isn't expanded)
221  if (lane->getGNEOutcomingConnections().size() > 0) {
222  FXTreeItem* outgoingConnections = myTreelist->insertItem(0, laneItem, "Outcomings", lane->getGNEOutcomingConnections().front()->getIcon(), lane->getGNEOutcomingConnections().front()->getIcon());
223  myTreeItemsWithoutAC.insert(outgoingConnections);
224  outgoingConnections->setExpanded(false);
225  for (int j = 0; j < (int)lane->getGNEOutcomingConnections().size(); j++) {
226  GNEConnection* connection = lane->getGNEOutcomingConnections().at(j);
227  FXTreeItem* connectionItem = myTreelist->insertItem(0, outgoingConnections, (toString(connection->getTag()) + " " + toString(j)).c_str(), connection->getIcon(), connection->getIcon());
228  myTreeItemToACMap[connectionItem] = connection;
229  connectionItem->setExpanded(true);
230  }
231  }
232  }
233  // insert additionals of edge
234  for (int i = 0; i < (int)edge->getAdditionalChilds().size(); i++) {
235  GNEAdditional* additionalChild = edge->getAdditionalChilds().at(i);
236  FXTreeItem* additionalItem = myTreelist->insertItem(0, edgeItem, (toString(additionalChild->getTag()) + " " + toString(i)).c_str(), additionalChild->getIcon(), additionalChild->getIcon());
237  myTreeItemToACMap[additionalItem] = additionalChild;
238  additionalItem->setExpanded(true);
239  }
240  // add a extra section for additional parent in which this edge is part
241  if (edge->getAdditionalParents().size() > 0) {
242  FXTreeItem* additionalParents = myTreelist->insertItem(0, edgeItem, "part of", 0, 0);
243  myTreeItemsWithoutAC.insert(additionalParents);
244  additionalParents->setExpanded(true);
245  // insert reroutes of edge
246  for (int i = 0; i < (int)edge->getAdditionalParents().size(); i++) {
247  GNEAdditional* additionalParent = edge->getAdditionalParents().at(i);
248  FXTreeItem* additionalItem = myTreelist->insertItem(0, additionalParents, (toString(additionalParent->getTag()) + " " + toString(i)).c_str(), additionalParent->getIcon(), additionalParent->getIcon());
249  myTreeItemToACMap[additionalItem] = additionalParent;
250  additionalItem->setExpanded(true);
251  }
252  }
253  break;
254  }
255  case GLO_LANE: {
256  // insert lane root
257  GNELane* lane = dynamic_cast<GNELane*>(myMarkedAC);
258  FXTreeItem* laneItem = myTreelist->insertItem(0, 0, toString(lane->getTag()).c_str(), lane->getIcon(), lane->getIcon());
259  myTreeItemToACMap[laneItem] = lane;
260  laneItem->setExpanded(true);
261  // insert additionals of lanes
262  for (int i = 0; i < (int)lane->getAdditionalChilds().size(); i++) {
263  GNEAdditional* additional = lane->getAdditionalChilds().at(i);
264  FXTreeItem* additionalItem = myTreelist->insertItem(0, laneItem, (toString(additional->getTag()) + " " + toString(i)).c_str(), additional->getIcon(), additional->getIcon());
265  myTreeItemToACMap[additionalItem] = additional;
266  additionalItem->setExpanded(true);
267  }
268  // insert incoming connections of lanes (by default isn't expanded)
269  if (lane->getGNEIncomingConnections().size() > 0) {
270  FXTreeItem* incomingConnections = myTreelist->insertItem(0, laneItem, "Incomings", lane->getGNEIncomingConnections().front()->getIcon(), lane->getGNEIncomingConnections().front()->getIcon());
271  myTreeItemsWithoutAC.insert(incomingConnections);
272  incomingConnections->setExpanded(false);
273  for (int i = 0; i < (int)lane->getGNEIncomingConnections().size(); i++) {
274  GNEConnection* connection = lane->getGNEIncomingConnections().at(i);
275  FXTreeItem* connectionItem = myTreelist->insertItem(0, incomingConnections, (toString(connection->getTag()) + " " + toString(i)).c_str(), connection->getIcon(), connection->getIcon());
276  myTreeItemToACMap[connectionItem] = connection;
277  connectionItem->setExpanded(true);
278  }
279  }
280  // insert outcoming connections of lanes (by default isn't expanded)
281  if (lane->getGNEOutcomingConnections().size() > 0) {
282  FXTreeItem* outgoingConnections = myTreelist->insertItem(0, laneItem, "Outcomings", lane->getGNEOutcomingConnections().front()->getIcon(), lane->getGNEOutcomingConnections().front()->getIcon());
283  myTreeItemsWithoutAC.insert(outgoingConnections);
284  outgoingConnections->setExpanded(false);
285  for (int i = 0; i < (int)lane->getGNEOutcomingConnections().size(); i++) {
286  GNEConnection* connection = lane->getGNEOutcomingConnections().at(i);
287  FXTreeItem* connectionItem = myTreelist->insertItem(0, outgoingConnections, (toString(connection->getTag()) + " " + toString(i)).c_str(), connection->getIcon(), connection->getIcon());
288  myTreeItemToACMap[connectionItem] = connection;
289  connectionItem->setExpanded(true);
290  }
291  }
292  break;
293  }
294  case GLO_POI: {
295  // insert POI root
296  GNEPOI* POI = dynamic_cast<GNEPOI*>(myMarkedAC);
297  FXTreeItem* POIItem = myTreelist->insertItem(0, 0, toString(POI->getTag()).c_str(), POI->getIcon(), POI->getIcon());
298  myTreeItemToACMap[POIItem] = POI;
299  POIItem->setExpanded(true);
300  break;
301  }
302  case GLO_POLYGON: {
303  // insert polygon root
304  GNEPoly* polygon = dynamic_cast<GNEPoly*>(myMarkedAC);
305  FXTreeItem* polygonItem = myTreelist->insertItem(0, 0, toString(polygon->getTag()).c_str(), polygon->getIcon(), polygon->getIcon());
306  myTreeItemToACMap[polygonItem] = polygon;
307  polygonItem->setExpanded(true);
308  break;
309  }
310  case GLO_CROSSING: {
311  // insert crossing root
312  GNECrossing* crossing = dynamic_cast<GNECrossing*>(myMarkedAC);
313  FXTreeItem* crossingItem = myTreelist->insertItem(0, 0, toString(crossing->getTag()).c_str(), crossing->getIcon(), crossing->getIcon());
314  myTreeItemToACMap[crossingItem] = crossing;
315  crossingItem->setExpanded(true);
316  break;
317  }
318  case GLO_ADDITIONAL: {
319  // insert additional root
320  GNEAdditional* additional = dynamic_cast<GNEAdditional*>(myMarkedAC);
321  FXTreeItem* additionalItem = myTreelist->insertItem(0, 0, toString(additional->getTag()).c_str(), additional->getIcon(), additional->getIcon());
322  myTreeItemToACMap[additionalItem] = additional;
323  additionalItem->setExpanded(true);
324  break;
325  }
326  case GLO_CONNECTION: {
327  // insert connection root
328  GNEConnection* connection = dynamic_cast<GNEConnection*>(myMarkedAC);
329  FXTreeItem* connectionItem = myTreelist->insertItem(0, 0, toString(connection->getTag()).c_str(), connection->getIcon(), connection->getIcon());
330  myTreeItemToACMap[connectionItem] = connection;
331  connectionItem->setExpanded(true);
332  break;
333  }
334  default: {
335  break;
336  }
337  }
338  }
339 }
340 
341 
342 void
344  // obtain clicked position
345  Position clickedPosition = myViewNet->getPositionInformation();
346  // To remove an attribute carrier deleteFrame must be visible
347  if (shown() == false) {
348  // Hide inspector frame and show delete frame
350  show();
351  } else if (myDeleteOnlyGeometryPoints->getCheck()) {
352  // check type of of GL object
353  switch (ac->getGUIGLObject()->getType()) {
354  case GLO_EDGE: {
355  GNEEdge* edge = dynamic_cast<GNEEdge*>(ac);
356  if (edge->getVertexIndex(clickedPosition, false) != -1) {
357  edge->deleteGeometryPoint(clickedPosition);
358  }
359  break;
360  }
361  case GLO_POLYGON: {
362  GNEPoly* polygon = dynamic_cast<GNEPoly*>(ac);
363  if (polygon->getVertexIndex(clickedPosition, false) != -1) {
364  polygon->deleteGeometryPoint(clickedPosition);
365  }
366  break;
367  }
368  default: {
369  break;
370  }
371  }
372  } else {
373  // check type of of GL object
374  switch (ac->getGUIGLObject()->getType()) {
375  case GLO_JUNCTION: {
376  GNEJunction* junction = dynamic_cast<GNEJunction*>(ac);
377  // obtain number of additionals of junction's childs
378  int numberOfAdditionals = 0;
379  for (auto i : junction->getGNEEdges()) {
380  numberOfAdditionals += (int)i->getAdditionalChilds().size();
381  for (auto j : i->getLanes()) {
382  UNUSED_PARAMETER(j);
383  numberOfAdditionals += (int)i->getAdditionalChilds().size();
384  }
385  }
386  // Check if junction can be deleted
389  } else {
390  if (numberOfAdditionals > 0) {
391  // write warning if netedit is running in testing mode
392  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
393  WRITE_WARNING("Opening FXMessageBox 'Force deletion needed'");
394  }
395  std::string plural = numberOfAdditionals > 1 ? "s" : "";
396  // Open warning DialogBox
397  FXMessageBox::warning(getViewNet()->getApp(), MBOX_OK, ("Problem deleting " + toString(junction->getTag())).c_str(), "%s",
398  (toString(junction->getTag()) + " '" + junction->getID() + "' cannot be deleted because owns " +
399  toString(numberOfAdditionals) + " additional child" + plural + ".\n Check 'Force deletion of additionals' to force deletion.").c_str());
400  // write warning if netedit is running in testing mode
401  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
402  WRITE_WARNING("Closed FXMessageBox 'Force deletion needed' with 'OK'");
403  }
404  } else {
406  }
407  }
408  break;
409  }
410  case GLO_EDGE: {
411  GNEEdge* edge = dynamic_cast<GNEEdge*>(ac);
412  // check if click was over a geometry point or over a shape's edge
413  if (edge->getVertexIndex(clickedPosition, false) != -1) {
414  edge->deleteGeometryPoint(clickedPosition);
415  } else {
416  int numberOfAdditionalChilds = (int)edge->getAdditionalChilds().size();
417  int numberOfAdditionalParents = (int)edge->getAdditionalParents().size();
418  // Iterate over lanes and obtain total number of additional childs
419  for (auto i : edge->getLanes()) {
420  numberOfAdditionalChilds += (int)i->getAdditionalChilds().size();
421  }
422  // Check if edge can be deleted
425  } else {
426  if (numberOfAdditionalChilds > 0) {
427  // write warning if netedit is running in testing mode
428  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
429  WRITE_WARNING("Opening FXMessageBox 'Force deletion needed'");
430  }
431  std::string plural = numberOfAdditionalChilds > 1 ? "s" : "";
432  // Open warning DialogBox
433  FXMessageBox::warning(getViewNet()->getApp(), MBOX_OK, ("Problem deleting " + toString(edge->getTag())).c_str(), "%s",
434  (toString(edge->getTag()) + " '" + edge->getID() + "' cannot be deleted because owns " +
435  toString(numberOfAdditionalChilds) + " additional" + plural + ".\n Check 'Force deletion of additionals' to force deletion.").c_str());
436  // write warning if netedit is running in testing mode
437  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
438  WRITE_WARNING("Closed FXMessageBox 'Force deletion needed' with 'OK'");
439  }
440  } else if (numberOfAdditionalParents > 0) {
441  // write warning if netedit is running in testing mode
442  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
443  WRITE_WARNING("Opening FXMessageBox 'Force deletion needed'");
444  }
445  std::string plural = numberOfAdditionalParents > 1 ? "s" : "";
446  // Open warning DialogBox
447  FXMessageBox::warning(getViewNet()->getApp(), MBOX_OK, ("Problem deleting " + toString(edge->getTag())).c_str(), "%s",
448  (toString(edge->getTag()) + " '" + edge->getID() + "' cannot be deleted because is part of " +
449  toString(numberOfAdditionalParents) + " additional" + plural + ".\n Check 'Force deletion of additionals' to force deletion.").c_str());
450  // write warning if netedit is running in testing mode
451  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
452  WRITE_WARNING("Closed FXMessageBox 'Force deletion needed' with 'OK'");
453  }
454  } else {
456  }
457  }
458  }
459  break;
460  }
461  case GLO_LANE: {
462  GNELane* lane = dynamic_cast<GNELane*>(ac);
463  // Check if lane can be deleted
466  } else {
467  if (lane->getAdditionalChilds().size() == 0) {
469  } else {
470  // write warning if netedit is running in testing mode
471  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
472  WRITE_WARNING("Opening FXMessageBox 'Force deletion needed'");
473  }
474  // open warning box
475  FXMessageBox::warning(getViewNet()->getApp(), MBOX_OK, ("Problem deleting " + toString(lane->getTag())).c_str(), "%s",
476  (toString(lane->getTag()) + " '" + lane->getID() + "' cannot be deleted because it has " +
477  toString(lane->getAdditionalChilds().size()) + " additional childs.\n Check 'Force deletion of Additionals' to force deletion.").c_str());
478  // write warning if netedit is running in testing mode
479  if (OptionsCont::getOptions().getBool("gui-testing-debug")) {
480  WRITE_WARNING("Closed FXMessageBox 'Force deletion needed' with 'OK'");
481  }
482  }
483  }
484  break;
485  }
486  case GLO_POLYGON:
487  case GLO_POI: {
488  myViewNet->getNet()->deleteShape(dynamic_cast<GNEShape*>(ac), myViewNet->getUndoList());
489  break;
490  }
491  case GLO_CROSSING: {
492  myViewNet->getNet()->deleteCrossing(dynamic_cast<GNECrossing*>(ac), myViewNet->getUndoList());
493  break;
494  }
495  case GLO_ADDITIONAL: {
496  myViewNet->getViewParent()->getAdditionalFrame()->removeAdditional(dynamic_cast<GNEAdditional*>(ac));
497  break;
498  }
499  case GLO_CONNECTION: {
500  myViewNet->getNet()->deleteConnection(dynamic_cast<GNEConnection*>(ac), myViewNet->getUndoList());
501  break;
502  }
503  default: {
504  break;
505  }
506  }
507  }
508  // update view to show changes
509  myViewNet->update();
510 }
511 
512 
513 void
515  // Check if under cursor there are an Attribute Carrier
516  if (ac != NULL) {
517  myMarkedElementLabel->setText((" " + toString(ac->getTag()) + " '" + ac->getID() + "'").c_str());
518  myMarkedElementLabel->setIcon(ac->getIcon());
519  } else {
520  myMarkedElementLabel->setText("No item marked");
522  }
523  // mark ac
524  myMarkedAC = ac;
525 }
526 
527 
528 void
530  // change label
531  if (ac != NULL) {
532  myCurrentElementLabel->setText((toString(ac->getTag()) + " '" + ac->getID() + "'").c_str());
533  myCurrentElementLabel->setIcon(ac->getIcon());
534  } else {
535  myCurrentElementLabel->setText("No item under cursor");
537  }
538 }
539 
540 
543  return myMarkedAC;
544 }
545 
546 
547 long
548 GNEDeleteFrame::onCmdShowChildMenu(FXObject*, FXSelector, void* eventData) {
549  // Obtain event
550  FXEvent* e = (FXEvent*) eventData;
551  FXTreeItem* item = myTreelist->getItemAt(e->win_x, e->win_y);
552  // Check if there are an item in the position and create pop-up menu
553  if (item && (myTreeItemsWithoutAC.find(item) == myTreeItemsWithoutAC.end())) {
554  createPopUpMenu(e->root_x, e->root_y, myTreeItemToACMap[myTreelist->getItemAt(e->win_x, e->win_y)]);
555  }
556  return 1;
557 }
558 
559 
560 long
561 GNEDeleteFrame::onCmdCenterChildItem(FXObject*, FXSelector, void*) {
563  myViewNet->update();
564  return 1;
565 }
566 
567 
568 long
569 GNEDeleteFrame::onCmdInspectChildItem(FXObject*, FXSelector, void*) {
570  if (myMarkedAC != NULL) {
573  // Hide delete frame and show inspector frame
574  hide();
575  }
576  return 1;
577 }
578 
579 
580 long
581 GNEDeleteFrame::onCmdDeleteChildItem(FXObject*, FXSelector, void*) {
583  return 1;
584 }
585 
586 
587 void
589  // create FXMenuPane
590  FXMenuPane* pane = new FXMenuPane(myTreelist);
591  // set current clicked AC
592  myClickedAC = ac;
593  // set name
595  new FXMenuSeparator(pane);
596  // Fill FXMenuCommand
597  new FXMenuCommand(pane, "Center", GUIIconSubSys::getIcon(ICON_RECENTERVIEW), this, MID_GNE_DELETEFRAME_CENTER);
598  new FXMenuCommand(pane, "Inspect", GUIIconSubSys::getIcon(ICON_MODEINSPECT), this, MID_GNE_DELETEFRAME_INSPECT);
599  new FXMenuCommand(pane, "Delete", GUIIconSubSys::getIcon(ICON_MODEDELETE), this, MID_GNE_DELETEFRAME_DELETE);
600  // Center in the mouse position and create pane
601  pane->setX(X);
602  pane->setY(Y);
603  pane->create();
604  pane->show();
605 }
606 
607 
608 /****************************************************************************/
In GNEDeleteFrame, center element.
Definition: GUIAppEnum.h:362
a tl-logic
GNEInspectorFrame * getInspectorFrame() const
get frame for GNE_MODE_INSPECT
#define GUIDesignCheckButtonAttribute
checkButton without thick extended over the frame used for attributes
Definition: GUIDesigns.h:116
long onCmdCenterChildItem(FXObject *, FXSelector, void *)
called when user select option "center item" of child Menu
a polygon
std::set< FXTreeItem * > myTreeItemsWithoutAC
set used to save tree items without AC assigned (for example, Incoming/Outcoming connections) ...
FXDEFMAP(GNEDeleteFrame) GNEDeleteFrameMap[]
FXCheckButton * myDeleteOnlyGeometryPoints
checkbox for enable/disable delete only geometry points
void removeAttributeCarrier(GNEAttributeCarrier *ac)
remove attribute carrier (element)
FXTreeList * myTreelist
tree list to show the childs of the element to erase
void inspectFromDeleteFrame(GNEAttributeCarrier *AC, GNEAttributeCarrier *previousElement, bool previousElementWasMarked)
inspect called from DeleteFrame
Definition: GNEPOI.h:46
void updateCurrentLabel(GNEAttributeCarrier *ac)
update current label
a connection
GNEViewParent * getViewParent() const
get the net object
int getVertexIndex(const Position &pos, bool createIfNoExist=true)
return index of a vertex of shape, or of a new vertex if position is over an shape&#39;s edge ...
Definition: GNEPoly.cpp:333
void deleteShape(GNEShape *shape, GNEUndoList *undoList)
remove shape
Definition: GNENet.cpp:608
FXIcon * getIcon() const
get FXIcon assigned to this object
void deleteConnection(GNEConnection *connection, GNEUndoList *undoList)
remove connection
Definition: GNENet.cpp:570
In GNEDeleteFrame, inspect element.
Definition: GUIAppEnum.h:364
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:53
void showChildsOfMarkedAttributeCarrier()
show childs of marked attribute carrier
FXLabel * myCurrentElementLabel
label for current element
#define GUIDesignTreeListFrame
Tree list used in frames to represent childs of elements.
Definition: GUIDesigns.h:418
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
automatically delete additional childs
Definition: GUIAppEnum.h:370
void deleteEdge(GNEEdge *edge, GNEUndoList *undoList)
removes edge
Definition: GNENet.cpp:430
long onCmdShowChildMenu(FXObject *, FXSelector, void *eventData)
const std::vector< GNEEdge * > & getGNEEdges() const
Returns all GNEEdges vinculated with this Junction.
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
GNEViewNet * getViewNet() const
get view net
Definition: GNEFrame.cpp:571
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition: GNEEdge.cpp:245
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
GNEViewNet * myViewNet
View Net for changes.
Definition: GNEFrame.h:337
GNEAdditionalFrame * getAdditionalFrame() const
get frame for GNE_MODE_ADDITIONAL
int getVertexIndex(const Position &pos, bool createIfNoExist=true)
return index of a vertex of shape, or of a new vertex if position is over an shape&#39;s edge ...
Definition: GNEEdge.cpp:143
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
GNEUndoList * getUndoList() const
get the undoList object
const std::vector< GNEAdditional * > & getAdditionalParents() const
return vector of additionals that have as Parameter this edge (For example, Rerouters) ...
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:51
~GNEDeleteFrame()
Destructor.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
void deleteLane(GNELane *lane, GNEUndoList *undoList)
removes lane
Definition: GNENet.cpp:528
FXCheckButton * myAutomaticallyDeleteAdditionalsCheckButton
checkbox for enable/disable automatically delete additionals childs
virtual void centerTo(GUIGlID id, bool applyZoom, double zoomDist=20)
centers to the chosen artifact
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition: GNELane.cpp:1127
void removeAdditional(GNEAdditional *additional)
remove an additional element previously added
FXFont * getBoldFont()
void markAttributeCarrier(GNEAttributeCarrier *ac)
mark attribute carrier (element)
GNEAttributeCarrier * myClickedAC
current attribute carrier selected in three
void deleteCrossing(GNECrossing *crossing, GNEUndoList *undoList)
remove crossing
Definition: GNENet.cpp:590
const std::string getID() const
function to support debugging
void deleteGeometryPoint(const Position &pos, bool allowUndo=true)
delete the geometry point closest to the given pos
Definition: GNEPoly.cpp:350
GNEAttributeCarrier * myMarkedAC
pointer to marked attributeCarrier (element)
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition: GNELane.cpp:1148
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition: GUIDesigns.h:182
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:56
compound additional
long onCmdDeleteChildItem(FXObject *, FXSelector, void *)
called when user select option "delte item" of child menu
long onCmdInspectChildItem(FXObject *, FXSelector, void *)
called when user select option "inspect item" of child menu
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
Definition: GNEEdge.cpp:653
virtual void show()
show Frame
Definition: GNEFrame.cpp:546
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:59
#define GUIDesignGroupBoxFrame
Group box design extended over frame.
Definition: GUIDesigns.h:221
GUIMainWindow * getApp() const
get App (GUIMainWindow)
an edge
virtual void hide()
hide Frame
Definition: GNEFrame.cpp:555
void deleteJunction(GNEJunction *junction, GNEUndoList *undoList)
removes junction and all incident edges
Definition: GNENet.cpp:378
void show()
show inspector frame
GNENet * getNet() const
get the net object
GUIGlID getGlID() const
Returns the numerical id of the object.
const std::vector< GNEAdditional * > & getAdditionalChilds() const
return vector of additionals that have as Parent this edge (For example, Calibrators) ...
Position getPositionInformation() const
Returns the cursor&#39;s x/y position within the network.
GNEAttributeCarrier * getMarkedAttributeCarrier() const
returns marked atrribute carrier
delete only geometry points
Definition: GUIAppEnum.h:368
std::map< FXTreeItem *, GNEAttributeCarrier * > myTreeItemToACMap
map used to save the Tree items with their AC
C++ TraCI client API implementation.
Definition: POI.h:42
In GNEDeleteFrame, delete element.
Definition: GUIAppEnum.h:366
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
FXLabel * myMarkedElementLabel
label for marked element
void createPopUpMenu(int X, int Y, GNEAttributeCarrier *ac)
const GUIGlObject * getGUIGLObject() const
get const pointer to GUIGlObject vinculated with this Attribute Carrier
a junction
SumoXMLTag getTag() const
get XML Tag assigned to this object