68 #ifdef CHECK_MEMORY_LEAKS 70 #endif // CHECK_MEMORY_LEAKS 102 FXComposite* tmpParent,
103 FXComposite* actualParent,
106 GNENet* net, FXGLVisual* glVis,
108 FXToolBar* toolBar) :
109 GUISUMOAbstractView(tmpParent, app, viewParent, net->getVisualisationSpeedUp(), glVis, share),
112 myPreviousEditMode(GNE_MODE_MOVE),
113 myCreateEdgeSource(0),
117 myMoveSelection(false),
118 myAmInRectSelect(false),
127 myInspector =
new GNEInspector(actualParent, myUndoList);
129 mySelector =
new GNESelector(actualParent,
this, myUndoList);
131 myConnector =
new GNEConnector(actualParent,
this, myUndoList);
133 myTLSEditor =
new GNETLSEditor(actualParent,
this, myUndoList);
136 reparent(actualParent);
138 buildEditModeControls();
140 myNet->setUpdateTarget(
this);
152 scheme =
GUIColorScheme(
"by selection (lane-/streetwise)",
RGBColor(128, 128, 128, 255),
"unselected",
true);
224 myVisualizationSettings->laneColorer = laneColorer;
248 myVisualizationSettings->junctionColorer = junctionColorer;
277 "\tLocate Junction\tLocate a junction within the network.",
279 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
282 "\tLocate Street\tLocate a street within the network.",
284 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
287 "\tLocate TLS\tLocate a traffic light within the network.",
289 ICON_ABOVE_TEXT | FRAME_THICK | FRAME_RAISED);
319 glMatrixMode(GL_MODELVIEW);
321 glDisable(GL_TEXTURE_2D);
322 glDisable(GL_ALPHA_TEST);
324 glEnable(GL_DEPTH_TEST);
329 glTranslated(0, 0,
GLO_MAX - 1);
332 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
352 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
355 minB[0] = bound.
xmin();
356 minB[1] = bound.
ymin();
357 maxB[0] = bound.
xmax();
358 maxB[1] = bound.
ymax();
360 glEnable(GL_POLYGON_OFFSET_FILL);
361 glEnable(GL_POLYGON_OFFSET_LINE);
376 FXEvent* e = (FXEvent*) data;
395 pointed_edge = (
GNEEdge*)pointed;
398 pointed_lane = (
GNELane*)pointed;
402 pointed_poi = (
GNEPOI*)pointed;
405 pointed_poly = (
GNEPoly*)pointed;
419 if ((e->state & CONTROLMASK) == 0) {
424 if (!pointed_junction) {
445 std::cout <<
"edge created without an open CommandGroup )-:\n";
470 }
else if (pointed_junction) {
477 }
else if (pointed_edge) {
491 if (pointed_junction) {
500 }
else if (pointed_edge) {
507 }
else if (pointed_poi) {
519 if (pointed_junction) {
520 pointedAC = pointed_junction;
521 pointedO = pointed_junction;
522 }
else if (pointed_lane) {
524 pointedAC = pointed_edge;
525 pointedO = pointed_edge;
527 pointedAC = pointed_lane;
528 pointedO = pointed_lane;
530 }
else if (pointed_edge) {
531 pointedAC = pointed_edge;
532 pointedO = pointed_edge;
533 }
else if (pointed_crossing) {
534 pointedAC = pointed_crossing;
535 pointedO = pointed_crossing;
537 std::vector<GNEAttributeCarrier*> selected;
541 }
else if (pointedAC != 0) {
542 selected.push_back(pointedAC);
553 }
else if (pointed) {
569 const bool mayPass = (((FXEvent*)data)->state & SHIFTMASK) != 0;
570 const bool allowConflict = (((FXEvent*)data)->state & CONTROLMASK) != 0;
578 if (pointed_junction) {
617 if (((FXEvent*)data)->state & SHIFTMASK) {
660 if (clearSelection) {
735 FXMessageBox::error(
this, MBOX_OK,
"invalid edit mode",
"%s",
"...");
784 edge = &(((
GNELane*)pointed)->getParentEdge());
814 std::set<GNEEdge*> result;
817 for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); ++it) {
823 result.insert((
GNEEdge*)pointed);
826 result.insert(&(((
GNELane*)pointed)->getParentEdge()));
851 if (edges.size() != 0) {
905 for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
946 for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1006 if (junction != 0) {
1059 FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC | LAYOUT_CENTER_Y);
1062 for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
1068 myChainCreateEdge =
new FXMenuCheck(
myToolbar,
"chain\t\tCreate consecutive edges with a single click (hit ESC to cancel chain).",
this, 0);
1070 "two-way\t\tAutomatically create an edge in the opposite direction",
this, 0);
1071 mySelectEdges =
new FXMenuCheck(
myToolbar,
"select edges\t\tToggle whether clicking should select edges or lanes",
this, 0);
1073 myExtendToEdgeNodes =
new FXMenuCheck(
myToolbar,
"auto-select nodes\t\tToggle whether selecting multiple edges should automatically select their nodes",
this, 0);
1075 myWarnAboutMerge =
new FXMenuCheck(
myToolbar,
"ask for merge\t\tAsk for confirmation before merging junctions.",
this, 0);
1078 myChangeAllPhases =
new FXMenuCheck(
myToolbar,
"apply change to all phases\t\tToggle whether clicking should apply state changes to all phases of the current traffic light plan",
this, 0);
1087 const int addChange = 4;
1096 int widthChange = 0;
1098 widthChange +=
myInspector->getWidth() + addChange;
1103 widthChange +=
mySelector->getWidth() + addChange;
1107 widthChange +=
myConnector->getWidth() + addChange;
1111 widthChange +=
myTLSEditor->getWidth() + addChange;
1124 widthChange -=
myInspector->getWidth() + addChange;
1129 widthChange -=
mySelector->getWidth() + addChange;
1138 widthChange -=
myConnector->getWidth() + addChange;
1142 widthChange -=
myTLSEditor->getWidth() + addChange;
1161 for (std::vector<GNEJunction*>::iterator it = junctions.begin(); it != junctions.end(); it++) {
1173 for (std::vector<GNEEdge*>::iterator it = edges.begin(); it != edges.end(); it++) {
1179 for (std::vector<GNELane*>::iterator it = lanes.begin(); it != lanes.end(); it++) {
1194 selection.
add(newPos);
1195 selection.
grow(0.1);
1198 for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
1216 FXuint answer = FXMessageBox::question(
this, MBOX_YES_NO,
1217 "Confirm Junction Merger",
"%s",
1218 (
"Do you wish to merge junctions '" + moved->
getMicrosimID() +
1221 "' will be eliminated and its roads added to '" +
GNEJunction * splitEdge(GNEEdge *edge, const Position &pos, GNEUndoList *undoList, GNEJunction *newJunction=0)
split edge at position by inserting a new junction
long onCmdResetEdgeEndpoint(FXObject *, FXSelector, void *)
restore geometry endpoint to node position
long onCmdDeleteGeometry(FXObject *, FXSelector, void *)
delete the closes geometry point
void paintGLGrid()
paints a grid
std::vector< GNEJunction * > retrieveJunctions(bool onlySelected=false)
return all junctions
GNEConnector * myConnector
static const RGBColor BLUE
Position moveGeometry(const Position &oldPos, const Position &newPos, bool relative=false)
draw the polygon and also little movement handles
FXDEFMAP(GNEViewNet) GNEViewNetMap[]
std::vector< GNELane * > retrieveLanes(bool onlySelected=false)
return all lanes
FXMenuCheck * mySelectEdges
GNEJunction * getJunctionAtCursorPosition(Position &pos)
try to retrieve a junction at the given position
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
GUICompleteSchemeStorage gSchemeStorage
void abortOperation(bool clearSelection=true)
void deleteSelectedJunctions()
delete all currently selected junctions
const SUMOReal SUMO_const_laneWidth
bool setColorScheme(const std::string &name)
void inspect(const std::vector< GNEAttributeCarrier * > &ACs)
Inspect the given multi-selection.
long onCmdDuplicateLane(FXObject *, FXSelector, void *)
duplicate selected lane
StringBijection< EditMode > myEditModeNames
since we cannot switch on strings we map the mode names to an enum
long onMouseMove(FXObject *, FXSelector, void *)
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
The main window of the Netedit.
SUMORTree * myGrid
The visualization speed-up.
void handleLaneClick(GNELane *lane, bool mayDefinitelyPass, bool allowConflict, bool toggle)
either sets the current lane or toggles the connection of the current lane to this lane (if they shar...
virtual void changeCanvassLeft(int change)=0
void setAllowsNegativeValues(bool value)
void toggleSelection(GUIGlID id)
Toggles selection of an object.
virtual long onMouseMove(FXObject *, FXSelector, void *)
FXMenuCheck * myChainCreateEdge
GUIColorer laneColorer
The lane colorer.
SUMOReal ymin() const
Returns minimum y-coordinate.
long onCmdSplitEdge(FXObject *, FXSelector, void *)
split edge at cursor position
const PositionVector & getShape() const
Returns whether the shape of the polygon.
long onCmdOK(FXObject *, FXSelector, void *)
Called when the user presses the OK-Button saves any connection modifications.
GUIMainWindow * myApp
The application.
FXMenuCheck * myChangeAllPhases
vehicle is a small delivery vehicle
void setEditMode(EditMode mode)
Position moveGeometry(const Position &oldPos, const Position &newPos, bool relative=false)
change the edge geometry without registering undo/redo It is up to the Edge to decide whether an new ...
void computeEverything(GNEApplicationWindow *window, bool force=false)
GNEEdge & getParentEdge()
Returns underlying parent edge.
GNEEdge * getEdgeTemplate()
SUMOReal xmin() const
Returns minimum x-coordinate.
classes which (normally) do not drive on normal roads
void removeAdditionalGLObject(GUIGlObject *o)
Removes an additional object (detector/shape/trigger) from being visualised.
void reverseEdge(GNEEdge *edge, GNEUndoList *undoList)
reverse edge
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void setLineWidth(SUMOReal lineWidth)
set a new shape and update the tesselation
long onCmdNodeShape(FXObject *, FXSelector, void *)
input custom node shape
static const RGBColor ORANGE
std::string getAttribute(SumoXMLAttr key) const
virtual long onLeftBtnPress(FXObject *, FXSelector, void *)
void splitEdgesBidi(const std::set< GNEEdge * > &edges, const Position &pos, GNEUndoList *undoList)
split all edges at position by inserting one new junction
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
A NBNetBuilder extended by visualisation and editing capabilities.
FXComboBox * myEditModesCombo
combo box for selecting the edit mode
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
GNEEdge * createEdge(GNEJunction *src, GNEJunction *dest, GNEEdge *tpl, GNEUndoList *undoList, const std::string &suggestedName="", bool wasSplit=false, bool allowDuplicateGeom=false)
creates a new edge (unless an edge with the same geometry already exists)
int editMode
the current NETEDIT mode (temporary)
void p_begin(const std::string &description)
void setActive(size_t scheme)
void setEditModeFromHotkey(FXushort selid)
sets edit mode (from hotkey)
long onCmdSetEdgeEndpoint(FXObject *, FXSelector, void *)
set non-default geometry endpoint
static const RGBColor BLACK
const SVCPermissions SVCAll
GUIDialog_ViewSettings * myVisualizationChanger
void deleteEdge(GNEEdge *edge, GNEUndoList *undoList)
removes edge
void updateControls()
update control contents after undo/redo or recompute
EditMode myPreviousEditMode
void registerMove(GNEUndoList *undoList)
registers completed movement with the undoList
SUMOReal x() const
Returns the x-position.
GUIGlID getGlID() const
Returns the numerical id of the object.
SUMOReal xmax() const
Returns maximum x-coordinate.
GNEEdge * myEdgeToMove
the edge of which geometry is being moved
A class that stores a 2D geometrical boundary.
long onCmdChangeMode(FXObject *, FXSelector, void *)
sets edit mode via combo box
A single child window which contains a view of the simulation area.
SUMOReal scale
information about a lane's width (temporary, used for a single view)
GNETLSEditor * myTLSEditor
std::vector< std::string > getStrings() const
bool myMoveSelection
whether a selection is being moved
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button discards any connection modifications.
std::vector< GUIGlID > getObjectsAtPosition(Position pos, SUMOReal radius)
returns the ids of the object at position within the given (rectangular) radius using GL_SELECT ...
void insert(const std::string str, const T key, bool checkDuplicates=true)
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildEditModeControls()
adds controls for setting the edit mode
GUIGlID getObjectAtPosition(Position pos)
returns the id of the object at position using GL_SELECT
std::set< GNEEdge * > getEdgesAtCursorPosition(Position &pos)
try to retrieve multiple edges at the given position
long onLeftBtnPress(FXObject *, FXSelector, void *)
const Position & getPosition() const
Returns the position of this node.
long onCmdSimplifyShape(FXObject *, FXSelector, void *)
simply shape of current polygon
static const RGBColor GREEN
static const RGBColor GREY
virtual long onPaint(FXObject *, FXSelector, void *)
const std::set< GUIGlID > & getSelected() const
Returns the list of ids of all selected objects.
ShapeContainer & getShapeContainer()
std::map< GUIGlObject *, int > myAdditionallyDrawn
List of objects for which GUIGlObject::drawGLAdditional is called.
FXMenuCheck * myWarnAboutMerge
whether we should warn about merging junctions
void setCurrentScheme(const std::string &)
Sets the named scheme as the current.
virtual void setStatusBarText(const std::string &)
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
virtual ~GNEViewNet()
destructor
GNEInspector * myInspector
A point in 2D or 3D with translation and scaling methods.
virtual bool removePOI(const std::string &id)
Removes a PoI from the container.
FXToolBar * myToolbar
a reference to the toolbar in myParent
void deleteLane(GNELane *lane, GNEUndoList *undoList)
removes lane
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user presses the Cancel-button discards any modifications.
void deleteGeometryOrEdge(GNEEdge *edge, const Position &pos, GNEUndoList *undoList)
removes geometry when pos is close to a geometry node, deletes the whole edge otherwise ...
bool contains(const std::string &name) const
Returns the information whether a setting with the given name is stored.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
void update()
update the widget
GUIVisualizationSettings & get(const std::string &name)
Returns the named scheme.
const std::string & getString(const T key) const
long onCmdSplitEdgeBidi(FXObject *, FXSelector, void *)
split edge at cursor position
static const RGBColor MAGENTA
NBNode * getNBNode()
returns the internal NBNode
void removeCurrentPoly()
remove the currently edited polygon
GNEJunction * myJunctionToMove
GNELane * getLaneAtCurserPosition(Position &pos)
try to retrieve a lane at the given position
Locate junction - button.
std::vector< GNEAttributeCarrier * > retrieveAttributeCarriers(const std::set< GUIGlID > &ids, GUIGlObjectType type)
get the attribute carriers based on GlIDs
std::string getCurrentScheme() const
Returns the name of the currently chosen scheme.
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
void moveSelection(const Position &moveSrc, const Position &moveDest)
GNEJunction * createJunction(const Position &pos, GNEUndoList *undoList)
creates a new junction
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
void p_abort()
reverts and discards ALL active command groups
const PositionVector & getShape() const
retrieve the junction shape
GUIPerspectiveChanger * myChanger
The perspective changer.
unsigned int addColor(const T &color, const SUMOReal threshold, const std::string &name="")
vehicle is a passenger car (a "normal" car)
void doInit()
called after some features are already initialized
FXMenuCheck * myAutoCreateOppositeEdge
bool mergeJunctions(GNEJunction *moved)
try to merge moved junction with another junction in that spot return true if merging did take place ...
void replaceJunctionByGeometry(GNEJunction *junction, GNEUndoList *undoList)
A road/street connecting two junctions (netedit-version)
FXbool makeCurrent()
A reimplementation due to some internal reasons.
virtual long onLeftBtnRelease(FXObject *, FXSelector, void *)
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
static const RGBColor YELLOW
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
static const RGBColor RED
FXMenuCheck * myExtendToEdgeNodes
static const RGBColor CYAN
bool hasCommandGroup() const
GUIVisualizationSettings * myVisualizationSettings
std::vector< GNEEdge * > retrieveEdges(bool onlySelected=false)
return all edges
Position myMoveSrc
position from which to move edge geometry
void addAdditionalGLObject(GUIGlObject *o)
Adds an additional object (detector/shape/trigger) for visualisation.
SUMOReal m2p(SUMOReal meter) const
meter-to-pixels conversion method
long onCmdReverseEdge(FXObject *, FXSelector, void *)
reverse edge
SUMOReal y() const
Returns the y-position.
int doPaintGL(int mode, const Boundary &bound)
GNEJunction * myCreateEdgeSource
void editJunction(GNEJunction *junction)
edits the traffic light for the given junction
void move(Position pos)
reposition the node at pos and informs the edges
void simplifyShape()
replace the current shape with a rectangle
void clear()
Clears the list of selected objects.
void deleteJunction(GNEJunction *junction, GNEUndoList *undoList)
removes junction and all incident edges
bool showGrid
Information whether a grid shall be shown.
void drawDecals()
Draws the stored decals.
void updateModeSpecificControls()
updates mode specific controls
T get(const std::string &str) const
virtual int Search(const float a_min[2], const float a_max[2], const GUIVisualizationSettings &c) const
Find all within search rectangle.
GNEEdge * addReversedEdge(GNEEdge *edge, GNEUndoList *undoList)
add reversed edge
void setStatusBarText(const std::string &text)
virtual void buildViewToolBars(GUIGlChildWindow &)
builds the view toolbars
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
SUMOReal ymax() const
Returns maximum y-coordinate.
GUIPropertyScheme< RGBColor > GUIColorScheme
static const RGBColor selectionColor
void unblockObject(GUIGlID id)
Marks an object as unblocked.
long onCmdStraightenEdges(FXObject *, FXSelector, void *)
makes selected edges straight
void handleIDs(std::vector< GUIGlID > ids, bool selectEdges, SetOperation setop=SET_DEFAULT)
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
GUIGlID getObjectUnderCursor()
returns the id of the object under the cursor using GL_SELECT
void mergeJunctions(GNEJunction *moved, GNEJunction *target, GNEUndoList *undoList)
merge the given junctions edges between the given junctions will be deleted
GNEEdge * getEdgeAtCursorPosition(Position &pos)
try to retrieve an edge at the given position
long onCmdNodeReplace(FXObject *, FXSelector, void *)
replace node by geometry
long onCmdAddReversedEdge(FXObject *, FXSelector, void *)
add reversed edge
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
void closePolygon()
ensures that the last position equals the first
GNEJunction * getEditedJunction() const
retrieve the junction of which the shape is being edited
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
GUISelectedStorage gSelected
A global holder of selected objects.
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
long onCmdOK(FXObject *, FXSelector, void *)
Called when the user presses the OK-Button saves any modifications.
static FXIcon * getIcon(GUIIcon which)
long onLeftBtnRelease(FXObject *, FXSelector, void *)
Position getSplitPos(const Position &clickPos)
void computeNodeShape(SUMOReal mismatchThreshold)
Compute the junction shape for this node.
void duplicateLane(GNELane *lane, GNEUndoList *undoList)
duplicates lane
void deleteSelectedEdges()
delete all currently selected edges
GNEUndoList * myUndoList
a reference to the undolist maintained in the application
std::vector< GUIGlID > getObjectsInBoundary(const Boundary &bound)
returns the ids of all objects in the given boundary
FXPopup * getLocatorPopup()
void deleteGeometryNear(const Position &pos)
delete the geometry point closest to the given pos
GNEPoly * myPolyToMove
the poly of which geometry is being moved
void finishMoveSelection(GNEUndoList *undoList)
register changes to junction and edge positions with the undoList