void GNEDetectorE1::updateGeometry() { // Clear all containers myGeometry.clearGeometry(); // obtain position over lane myGeometry.shape.push_back(getPositionInView()); // Obtain first position Position f = myGeometry.shape[0] - Position(1, 0); // Obtain next position Position s = myGeometry.shape[0] + Position(1, 0); // Save rotation (angle) of the vector constructed by points f and s myGeometry.shapeRotations.push_back(getLaneParents().front()->getGeometry().shape.rotationDegreeAtOffset(getGeometryPositionOverLane()) * -1); // Set block icon position myBlockIcon.position = myGeometry.shape.getLineCenter(); // Set offset of the block icon myBlockIcon.offset = Position(-1, 0); // Set block icon rotation, and using their rotation for logo myBlockIcon.setRotation(getLaneParents().front()); }
void GNEDemandElement::startGeometryMoving() { // always save original position over view myMove.originalViewPosition = getPositionInView(); // check if position over lane or lanes has to be saved if (myTagProperty.hasAttribute(SUMO_ATTR_LANE)) { if (myTagProperty.canMaskStartEndPos()) { // obtain start and end position myMove.firstOriginalLanePosition = getAttribute(SUMO_ATTR_STARTPOS); myMove.secondOriginalPosition = getAttribute(SUMO_ATTR_ENDPOS); } else { // obtain position attribute myMove.firstOriginalLanePosition = getAttribute(SUMO_ATTR_POSITION); } } else if (myTagProperty.hasAttribute(SUMO_ATTR_LANES)) { // obtain start and end position myMove.firstOriginalLanePosition = getAttribute(SUMO_ATTR_POSITION); myMove.secondOriginalPosition = getAttribute(SUMO_ATTR_ENDPOS); } // save current centering boundary myMove.movingGeometryBoundary = getCenteringBoundary(); // Iterate over demand element childs and start geometry moving for (auto i : getDemandElementChilds()) { i->startGeometryMoving(); } }
void GNECalibrator::drawGL(const GUIVisualizationSettings& s) const { // get values glPushName(getGlID()); glLineWidth(1.0); const double exaggeration = s.addSize.getExaggeration(s, this); // iterate over every Calibrator symbol for (int i = 0; i < (int)myGeometry.shape.size(); ++i) { const Position& pos = myGeometry.shape[i]; double rot = myGeometry.shapeRotations[i]; glPushMatrix(); glTranslated(pos.x(), pos.y(), getType()); glRotated(rot, 0, 0, 1); glTranslated(0, 0, getType()); glScaled(exaggeration, exaggeration, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); if (drawUsingSelectColor()) { GLHelper::setColor(s.selectedAdditionalColor); } else { GLHelper::setColor(RGBColor(255, 204, 0)); } // base glBegin(GL_TRIANGLES); glVertex2d(0 - 1.4, 0); glVertex2d(0 - 1.4, 6); glVertex2d(0 + 1.4, 6); glVertex2d(0 + 1.4, 0); glVertex2d(0 - 1.4, 0); glVertex2d(0 + 1.4, 6); glEnd(); // draw text if isn't being drawn for selecting if ((s.scale * exaggeration >= 1.) && !s.drawForSelecting) { // set color depending of selection status RGBColor textColor = drawUsingSelectColor() ? s.selectionColor : RGBColor::BLACK; // draw "C" GLHelper::drawText("C", Position(0, 1.5), 0.1, 3, textColor, 180); // draw "edge" or "lane " if (getLaneParents().size() > 0) { GLHelper::drawText("lane", Position(0, 3), .1, 1, textColor, 180); } else if (getEdgeParents().size() > 0) { GLHelper::drawText("edge", Position(0, 3), .1, 1, textColor, 180); } else { throw ProcessError("Both myEdge and myLane aren't defined"); } } glPopMatrix(); // check if dotted contour has to be drawn if (!s.drawForSelecting && (myViewNet->getDottedAC() == this)) { GLHelper::drawShapeDottedContour(getType(), pos, 2.8, 6, rot, 0, 3); } } // draw name drawName(getPositionInView(), s.scale, s.addName); // pop name glPopName(); }
GUIGLObjectPopupMenu* GNEDemandElement::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) { GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this); // build header buildPopupHeader(ret, app); // build menu command for center button and copy cursor position to clipboard buildCenterPopupEntry(ret); buildPositionCopyEntry(ret, false); // buld menu commands for names new FXMenuCommand(ret, ("Copy " + getTagStr() + " name to clipboard").c_str(), nullptr, ret, MID_COPY_NAME); new FXMenuCommand(ret, ("Copy " + getTagStr() + " typed name to clipboard").c_str(), nullptr, ret, MID_COPY_TYPED_NAME); new FXMenuSeparator(ret); // build selection and show parameters menu myViewNet->buildSelectionACPopupEntry(ret, this); buildShowParamsPopupEntry(ret); // show option to open demand element dialog if (myTagProperty.hasDialog()) { new FXMenuCommand(ret, ("Open " + getTagStr() + " Dialog").c_str(), getIcon(), &parent, MID_OPEN_ADDITIONAL_DIALOG); new FXMenuSeparator(ret); } new FXMenuCommand(ret, ("Cursor position in view: " + toString(getPositionInView().x()) + "," + toString(getPositionInView().y())).c_str(), nullptr, nullptr, 0); return ret; }
void GNEDetectorE1::drawGL(const GUIVisualizationSettings& s) const { // get values glPushName(getGlID()); double width = (double) 2.0 * s.scale; glLineWidth(1.0); const double exaggeration = s.addSize.getExaggeration(s, this); // set color if (drawUsingSelectColor()) { GLHelper::setColor(s.selectedAdditionalColor); } else { GLHelper::setColor(s.SUMO_color_E1); } // draw shape glPushMatrix(); glTranslated(0, 0, getType()); glTranslated(myGeometry.shape[0].x(), myGeometry.shape[0].y(), 0); glRotated(myGeometry.shapeRotations[0], 0, 0, 1); glScaled(exaggeration, exaggeration, 1); glBegin(GL_QUADS); glVertex2d(-1.0, 2); glVertex2d(-1.0, -2); glVertex2d(1.0, -2); glVertex2d(1.0, 2); glEnd(); glTranslated(0, 0, .01); glBegin(GL_LINES); glVertex2d(0, 2 - .1); glVertex2d(0, -2 + .1); glEnd(); // outline if isn't being drawn for selecting if ((width * exaggeration > 1) && !s.drawForSelecting) { // set color if (drawUsingSelectColor()) { GLHelper::setColor(s.selectionColor); } else { GLHelper::setColor(RGBColor::WHITE); } glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glBegin(GL_QUADS); glVertex2f(-1.0, 2); glVertex2f(-1.0, -2); glVertex2f(1.0, -2); glVertex2f(1.0, 2); glEnd(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } // position indicator if isn't being drawn for selecting if ((width * exaggeration > 1) && !s.drawForSelecting) { // set color if (drawUsingSelectColor()) { GLHelper::setColor(s.selectionColor); } else { GLHelper::setColor(RGBColor::WHITE); } glRotated(90, 0, 0, -1); glBegin(GL_LINES); glVertex2d(0, 1.7); glVertex2d(0, -1.7); glEnd(); } // Pop shape matrix glPopMatrix(); // Check if the distance is enought to draw details and isn't being drawn for selecting if ((s.scale * exaggeration >= 10) && !s.drawForSelecting) { // Push matrix glPushMatrix(); // Traslate to center of detector glTranslated(myGeometry.shape.getLineCenter().x(), myGeometry.shape.getLineCenter().y(), getType() + 0.1); // Rotate depending of myBlockIcon.rotation glRotated(myBlockIcon.rotation, 0, 0, -1); //move to logo position glTranslated(-1, 0, 0); // draw E1 logo if (drawUsingSelectColor()) { GLHelper::drawText("E1", Position(), .1, 1.5, s.selectionColor); } else { GLHelper::drawText("E1", Position(), .1, 1.5, RGBColor::BLACK); } // pop matrix glPopMatrix(); // Show Lock icon depending of the Edit mode myBlockIcon.draw(); } // Finish draw if isn't being drawn for selecting if (!s.drawForSelecting) { drawName(getPositionInView(), s.scale, s.addName); } // check if dotted contour has to be drawn if (!s.drawForSelecting && (myViewNet->getDottedAC() == this)) { GLHelper::drawShapeDottedContour(getType(), myGeometry.shape[0], 2, 4, myGeometry.shapeRotations[0]); } // pop name glPopName(); }
void GNEDetectorE2::drawGL(const GUIVisualizationSettings& s) const { // Start drawing adding an gl identificator glPushName(getGlID()); // Add a draw matrix glPushMatrix(); // Start with the drawing of the area traslating matrix to origin glTranslated(0, 0, getType()); // Set color of the base if (drawUsingSelectColor()) { GLHelper::setColor(s.selectedAdditionalColor); } else { // set color depending if is or isn't valid if (myE2valid) { GLHelper::setColor(s.SUMO_color_E2); } else { GLHelper::setColor(RGBColor::RED); } } // Obtain exaggeration of the draw const double exaggeration = s.addSize.getExaggeration(s, this); // check if we have to drawn a E2 single lane or a E2 multiLane if (myGeometry.shape.size() > 0) { // Draw the area using shape, shapeRotations, shapeLengths and value of exaggeration GLHelper::drawBoxLines(myGeometry.shape, myGeometry.shapeRotations, myGeometry.shapeLengths, exaggeration); } else { // iterate over multishapes for (int i = 0; i < (int)myGeometry.multiShape.size(); i++) { // don't draw shapes over connections if "show connections" is enabled if (!myViewNet->getViewOptions().showConnections() || (i % 2 == 0)) { GLHelper::drawBoxLines(myGeometry.multiShape.at(i), myGeometry.multiShapeRotations.at(i), myGeometry.multiShapeLengths.at(i), exaggeration); } } } // Pop last matrix glPopMatrix(); // Check if the distance is enougth to draw details and isn't being drawn for selecting if ((s.scale * exaggeration >= 10) && !s.drawForSelecting) { // draw logo depending if this is an Multilane E2 detector if (myTagProperty.getTag() == SUMO_TAG_E2DETECTOR) { // Push matrix glPushMatrix(); // Traslate to center of detector glTranslated(myGeometry.shape.getLineCenter().x(), myGeometry.shape.getLineCenter().y(), getType() + 0.1); // Rotate depending of myBlockIcon.rotation glRotated(myBlockIcon.rotation, 0, 0, -1); //move to logo position glTranslated(-0.75, 0, 0); // draw E2 logo if (drawUsingSelectColor()) { GLHelper::drawText("E2", Position(), .1, 1.5, s.selectionColor); } else { GLHelper::drawText("E2", Position(), .1, 1.5, RGBColor::BLACK); } } else { // Push matrix glPushMatrix(); // Traslate to center of detector glTranslated(myBlockIcon.position.x(), myBlockIcon.position.y(), getType() + 0.1); // Rotate depending of myBlockIcon.rotation glRotated(myBlockIcon.rotation, 0, 0, -1); //move to logo position glTranslated(-1.5, 0, 0); // draw E2 logo if (drawUsingSelectColor()) { GLHelper::drawText("E2", Position(), .1, 1.5, s.selectionColor); } else { GLHelper::drawText("E2", Position(), .1, 1.5, RGBColor::BLACK); } //move to logo position glTranslated(1.2, 0, 0); // Rotate depending of myBlockIcon.rotation glRotated(90, 0, 0, 1); if (drawUsingSelectColor()) { GLHelper::drawText("multi", Position(), .1, 0.9, s.selectedAdditionalColor); } else { GLHelper::drawText("multi", Position(), .1, 0.9, RGBColor::BLACK); } } // pop matrix glPopMatrix(); // Show Lock icon depending of the Edit mode myBlockIcon.draw(); } // Draw name if isn't being drawn for selecting if (!s.drawForSelecting) { drawName(getPositionInView(), s.scale, s.addName); } // check if dotted contour has to be drawn if (!s.drawForSelecting && (myViewNet->getDottedAC() == this)) { if (myGeometry.shape.size() > 0) { GLHelper::drawShapeDottedContour(getType(), myGeometry.shape, exaggeration); } else { GLHelper::drawShapeDottedContour(getType(), myGeometry.multiShapeUnified, exaggeration); } } // Pop name glPopName(); }