Example #1
0
Employee modifyEmployee(Employee employee, int modOpt) {
    
    if(modOpt == 1) {
        employee.general = getName(employee.general);
    } else if(modOpt == 2) {
        employee.general.address = getStreetName(employee.general.address);
    } else if(modOpt == 3) {
        employee.general.address = getNumber(employee.general.address);
    } else if(modOpt == 4) {
        employee.general.address = getPostalCode(employee.general.address);
    } else if(modOpt == 5) {
        employee.general.address = getCity(employee.general.address);
    } else if(modOpt == 6) {
        employee.general = getPhone(employee.general);
    } else if(modOpt == 7) {
        employee.general = getLevel(employee.general);
    }
    
    return employee;
}
Example #2
0
void
GUIEdge::drawGL(const GUIVisualizationSettings& s) const {
    if (s.hideConnectors && myFunction == MSEdge::EDGEFUNCTION_CONNECTOR) {
        return;
    }
    glPushName(getGlID());
    // draw the lanes
    for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) {
#ifdef HAVE_INTERNAL
        if (MSGlobals::gUseMesoSim) {
            setColor(s);
        }
#endif
        GUILane* l = dynamic_cast<GUILane*>(*i);
        if (l != 0) {
            l->drawGL(s);
        }
    }
#ifdef HAVE_INTERNAL
    if (MSGlobals::gUseMesoSim) {
        if (s.scale * s.vehicleSize.getExaggeration(s) > s.vehicleSize.minSize) {
            drawMesoVehicles(s);
        }
    }
#endif
    glPopName();
    // (optionally) draw the name and/or the street name
    const bool drawEdgeName = s.edgeName.show && myFunction == EDGEFUNCTION_NORMAL;
    const bool drawInternalEdgeName = s.internalEdgeName.show && myFunction == EDGEFUNCTION_INTERNAL;
    const bool drawCwaEdgeName = s.cwaEdgeName.show && (myFunction == EDGEFUNCTION_CROSSING || myFunction == EDGEFUNCTION_WALKINGAREA);
    const bool drawStreetName = s.streetName.show && myStreetName != "";
    if (drawEdgeName || drawInternalEdgeName || drawCwaEdgeName || drawStreetName) {
        GUILane* lane1 = dynamic_cast<GUILane*>((*myLanes)[0]);
        GUILane* lane2 = dynamic_cast<GUILane*>((*myLanes).back());
        if (lane1 != 0 && lane2 != 0) {
            Position p = lane1->getShape().positionAtOffset(lane1->getShape().length() / (SUMOReal) 2.);
            p.add(lane2->getShape().positionAtOffset(lane2->getShape().length() / (SUMOReal) 2.));
            p.mul(.5);
            SUMOReal angle = lane1->getShape().rotationDegreeAtOffset(lane1->getShape().length() / (SUMOReal) 2.);
            angle += 90;
            if (angle > 90 && angle < 270) {
                angle -= 180;
            }
            if (drawEdgeName) {
                drawName(p, s.scale, s.edgeName, angle);
            } else if (drawInternalEdgeName) {
                drawName(p, s.scale, s.internalEdgeName, angle);
            } else if (drawCwaEdgeName) {
                drawName(p, s.scale, s.cwaEdgeName, angle);
            }
            if (drawStreetName) {
                GLHelper::drawText(getStreetName(), p, GLO_MAX,
                                   s.streetName.size / s.scale, s.streetName.color, angle);
            }
        }
    }
    if (s.scale * s.personSize.getExaggeration(s) > s.personSize.minSize) {
        myLock.lock();
        for (std::set<MSPerson*>::const_iterator i = myPersons.begin(); i != myPersons.end(); ++i) {
            GUIPerson* person = dynamic_cast<GUIPerson*>(*i);
            assert(person != 0);
            person->drawGL(s);
        }
        myLock.unlock();
    }
    if (s.scale * s.containerSize.getExaggeration(s) > s.containerSize.minSize) {
        myLock.lock();
        for (std::set<MSContainer*>::const_iterator i = myContainers.begin(); i != myContainers.end(); ++i) {
            GUIContainer* container = dynamic_cast<GUIContainer*>(*i);
            assert(container != 0);
            container->drawGL(s);
        }
        myLock.unlock();
    }
}
Example #3
0
void GetPathInstructions(vector<unsigned> Path){
    
    
    
    
    // First, draw a box in the graphics window, on which the path instructions 
    // will be displayed. 
    float tempXCenter = get_visible_world().get_xcenter();
    float tempYCenter = get_visible_world().get_ycenter();
    float BoxLeft = tempXCenter + 0.18 * get_visible_world().get_width();
    float BoxRight = tempXCenter + 0.48 * get_visible_world().get_width();
    float BoxBottom = tempYCenter - 0.48 * get_visible_world().get_height();
    float BoxTop = tempYCenter + 0.12 * get_visible_world().get_height();
    t_bound_box HelpBox(BoxLeft, BoxBottom, BoxRight, BoxTop);
    
    // string intro = "Welcome to Map-2-Go"; 
    
    setcolor(246, 246, 246);

    fillrect(HelpBox);

    
    // Draw the borders of the box. 
    setcolor(200, 200, 200);
    setlinewidth(6);

    t_point border[6];
    border[5].x = BoxRight;
    border[5].y = BoxTop;

    
    // Add depth to the box, making the user feel as if he or she is looking 
    // in 3D perspective at the box. 
    border[2].x = BoxLeft + 0.02 * HelpBox.get_width();
    border[2].y = BoxBottom - 0.02 * HelpBox.get_width();

    border[3].x = BoxRight + 0.02 * HelpBox.get_width();
    border[3].y = BoxBottom - 0.02 * HelpBox.get_width();

    border[4].x = BoxRight + 0.02 * HelpBox.get_width();
    border[4].y = BoxTop - 0.02 * HelpBox.get_width();

    border[0].x = BoxRight;
    border[0].y = BoxBottom;

    border[1].x = BoxLeft;
    border[1].y = BoxBottom;

    fillpoly(border, 6);
    setcolor(20, 20, 20);
    setlinewidth(1);

    drawrect(border[1], border[5]);

    drawline(border[1], border[2]);
    drawline(border[2], border[3]);
    drawline(border[3], border[0]);
    drawline(border[4], border[5]);
    drawline(border[4], border[3]);
    
    // From now on, start displaying the path instructions. 
    
    settextrotation(0); 
    setcolor(20,20,20); 
    setfontsize(12); 
    
    string InstructionLabel = "Path Instructions"; 
    
    // Write "Path Instructions" onto the box in the graphics window. 
    drawtext(HelpBox.left() + 0.5 * HelpBox.get_width(), HelpBox.top() - 0.03 * HelpBox.get_height(), InstructionLabel, HelpBox.get_width(), HelpBox.get_height());

    // Draw a line separating the header above from the instructions later on. 
    setlinewidth(2);
    drawline(HelpBox.left() + 0.05 * HelpBox.get_width(), HelpBox.top() - 0.06 * HelpBox.get_height(), HelpBox.right() - 0.05 * HelpBox.get_width(), HelpBox.top() - 0.06 * HelpBox.get_height()); //splitline 

    settextrotation(0); 
    setcolor(20,20,20); 
    setfontsize(10); 
   
    
    /////////////////////////////////////////////////////////
   
    bool differentStreet; // Bool flag to determine if two street segments belong to different streets. 
    bool needExtraLine; // Bool flag to determine if obtained path instruction has too many characters 
    // to fit in the width of the box. 
    
    int numLines = 0; // This counter determines how far down the box each subsequent instruction will be displayed at. 
    int displayStraightInstruction = 0; // When this integer counter is zero, a path instruction that has "Go Straight" 
    // will be displayed once, but if the subsequent instruction is still "Go Straight", the integer counter will have 
    // incremented by one already - thus preventing the redundant instruction rom being displayed. 
    
    // Traverse the vector of street segments, and access the current and current+1 street segment with each iteration. 
    for (unsigned i = 0; i < Path.size()-1; i++){
        
 
        
        int LeftOrRight = 3; // This integer determines whether to turn right, left, or go straight. It is initialized 
        // to 3 for each iteration, so as not to match any of the above cases initially. 
        
        string tempString; // This will store the path instruction. 
        string tempString2; // This will store the remainder of the path instruction, if the instruction is longer than 
        // 50 characters and will potentially be cut off. 
        
        // The bool flags are initially set to false, for each iteration. 
        differentStreet = false; 
        needExtraLine = false; 
        
        // Obtain street name of the first street segment. 
        string StreetName1 = getStreetName(getStreetSegmentStreetID(Path[i])); 
        // Obtain street name of the second street segment. 
        string StreetName2 = getStreetName(getStreetSegmentStreetID(Path[i+1])); 
        
        // If the second segment's street name is "(unknown)" or " ", then do not go and create 
        // a proper path instruction for it. 
        if ((StreetName2 != "(unknown)") && (StreetName2 != " ")){
            
            // If the second segment's street name WAS ACTUALLY a valid name...
            
            // If the two street names are different, the user will then go onto a different street, so 
            // set the flag to true. 
            if (StreetName2!=StreetName1){
                differentStreet = true; 
            }

            // Call TurnLeftOrRight function to determine which way to turn. 
            // If the returned value is 2, turn right; if the value is 0, turn left; 
            // else if the value is 1, go straight. 
            LeftOrRight = TurnLeftOrRight(Path[i],Path[i+1]); 
            if (LeftOrRight==2){
                tempString.append("Turn right");
                //displayStraightInstruction = 0; // If turning right, automatically enable the instruction to be 
                // displayed again, regardless of whether or not the street name remains the same. 
            } 
            else if (LeftOrRight==1){
                tempString.append("Go straight"); 
            } 
            else if (LeftOrRight==0){
                tempString.append("Turn left"); 
                //displayStraightInstruction = 0; // If turning left, automatically enable the instruction to be 
                // displayed again, regardless of whether or not the street name remains the same. 
            } 

            /////////////////////////////////////////////////////////
            
            // If the user does go onto a different street, add " onto " into the instruction. 
            if (differentStreet){
                tempString.append(" onto "); 
                tempString.append(StreetName2);
                displayStraightInstruction = 0; // If different street names, set the displayStraightInstruction counter 
                // back to zero, so that subsequent "Go Straight" instructions can be displayed at least once. 
            }
            else{ // If the user does NOT go onto a different street, add " along " into the instruction. 
                tempString.append(" along "); 
                tempString.append(StreetName2); 
            }
            
            /////////////////////////////////////////////////////////

            // If the string length is two wide to fit onto the box (max 50 characters), 
            // store the remainder of the string into a second string, and print it on the next line. 
            if (tempString.length()>=50){
                needExtraLine = true; 
                size_t pos = tempString.find_last_of(' ',string::npos); // Find the last occurrence of whitespace in the string.  
                tempString2 = tempString.substr(pos+1,30);
                tempString.erase(pos,string::npos); 
            }
            
            /////////////////////////////////////////////////////////
            
            // The following if case only applies to an instruction if it tells the user to "Go Straight". 
            // For the first occurrence of "Go Straight", the instruction will be displayed, but if it appears 
            // consecutively many times afterwards, the instructions will be disabled by incrementing the 
            // displayStraightInstruction counter. 
            if (displayStraightInstruction < 1){
                // Draw the text onto the box. 
                drawtext(HelpBox.left() + 0.5 * HelpBox.get_width(), HelpBox.top() - (0.10 +0.04*numLines) * HelpBox.get_height(), tempString, HelpBox.get_width(), HelpBox.get_height());
                numLines++; // Increment the numLines counter so set the subsequent line further down the box. 
                if (needExtraLine){ // If an extra line is needed, display this instruction too. 
                    drawtext(HelpBox.left() + 0.5 * HelpBox.get_width(), HelpBox.top() - (0.10 +0.04*numLines) * HelpBox.get_height(), tempString2, HelpBox.get_width(), HelpBox.get_height());
                    numLines++; 
                }
            }
            
            // Before iterating the overall for loop again and checking the next two segments, check if 
            // the instruction this time was 
            if (!differentStreet)
                displayStraightInstruction++; 

        }
        
    }
    
    // After exiting the for loop and displaying all instructions, display this message for users to 
    // know how to clear the screen of any displayed path or path instructions. 
    string endMessage = "Press 'Esc' to clear the path instructions. "; 
    drawtext(HelpBox.left() + 0.5 * HelpBox.get_width(), HelpBox.top() - (0.10 +0.04*numLines + 0.015) * HelpBox.get_height(), endMessage, HelpBox.get_width(), HelpBox.get_height());
    // DisplayPathInstructions(InstructionVector); 
    
} 
Example #4
0
void
GUIEdge::drawGL(const GUIVisualizationSettings& s) const {
    if (s.hideConnectors && myFunction == MSEdge::EDGEFUNCTION_CONNECTOR) {
        return;
    }
    if (MSGlobals::gUseMesoSim) {
        glPushName(getGlID());
    }
    // draw the lanes
    for (LaneWrapperVector::const_iterator i = myLaneGeoms.begin(); i != myLaneGeoms.end(); ++i) {
#ifdef HAVE_INTERNAL
        if (MSGlobals::gUseMesoSim) {
            setColor(s);
        }
#endif
        (*i)->drawGL(s);
    }
#ifdef HAVE_INTERNAL
    if (MSGlobals::gUseMesoSim) {
        const GUIVisualizationTextSettings& nameSettings = s.vehicleName;
        GUIMEVehicleControl* vehicleControl = GUINet::getGUIInstance()->getGUIMEVehicleControl();
        if (vehicleControl != 0) {
            // draw the meso vehicles
            vehicleControl->secureVehicles();
            size_t laneIndex = 0;
            MESegment::Queue queue;
            for (LaneWrapperVector::const_iterator l = myLaneGeoms.begin(); l != myLaneGeoms.end(); ++l, ++laneIndex) {
                const PositionVector& shape = (*l)->getShape();
                const std::vector<SUMOReal>& shapeRotations = (*l)->getShapeRotations();
                const std::vector<SUMOReal>& shapeLengths = (*l)->getShapeLengths();
                const Position& laneBeg = shape[0];
                glPushMatrix();
                glTranslated(laneBeg.x(), laneBeg.y(), 0);
                glRotated(shapeRotations[0], 0, 0, 1);
                // go through the vehicles
                int shapeIndex = 0;
                SUMOReal shapeOffset = 0; // ofset at start of current shape
                SUMOReal segmentOffset = 0; // offset at start of current segment
                for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this);
                        segment != 0; segment = segment->getNextSegment()) {
                    const SUMOReal length = segment->getLength();
                    if (laneIndex < segment->numQueues()) {
                        // make a copy so we don't have to worry about synchronization
                        queue = segment->getQueue(laneIndex);
                        const SUMOReal avgCarSize = segment->getOccupancy() / segment->getCarNumber();
                        const size_t queueSize = queue.size();
                        for (size_t i = 0; i < queueSize; i++) {
                            MSBaseVehicle* veh = queue[queueSize - i - 1];
                            setVehicleColor(s, veh);
                            SUMOReal vehiclePosition = segmentOffset + length - i * avgCarSize;
                            SUMOReal xOff = 0.f;
                            while (vehiclePosition < segmentOffset) {
                                // if there is only a single queue for a
                                // multi-lane edge shift vehicles and start
                                // drawing again from the end of the segment
                                vehiclePosition += length;
                                xOff += 0.5f;
                            }
                            while (shapeIndex < (int)shapeRotations.size() - 1 && vehiclePosition > shapeOffset + shapeLengths[shapeIndex]) {
                                glPopMatrix();
                                shapeOffset += shapeLengths[shapeIndex];
                                shapeIndex++;
                                glPushMatrix();
                                glTranslated(shape[shapeIndex].x(), shape[shapeIndex].y(), 0);
                                glRotated(shapeRotations[shapeIndex], 0, 0, 1);
                            }
                            glPushMatrix();
                            glTranslated(xOff, -(vehiclePosition - shapeOffset), GLO_VEHICLE);
                            glPushMatrix();
                            glScaled(1, avgCarSize, 1);
                            glBegin(GL_TRIANGLES);
                            glVertex2d(0, 0);
                            glVertex2d(0 - 1.25, 1);
                            glVertex2d(0 + 1.25, 1);
                            glEnd();
                            glPopMatrix();
                            glPopMatrix();
                            if (nameSettings.show) {
                                GLHelper::drawText(veh->getID(),
                                                   Position(xOff, -(vehiclePosition - shapeOffset)),
                                                   GLO_MAX, nameSettings.size / s.scale, nameSettings.color, 0);
                            }
                        }
                    }
                    segmentOffset += length;
                }
                glPopMatrix();
            }
            vehicleControl->releaseVehicles();
        }
        glPopName();
    }
#endif
    // (optionally) draw the name and/or the street name
    const bool drawEdgeName = s.edgeName.show && myFunction == EDGEFUNCTION_NORMAL;
    const bool drawInternalEdgeName = s.internalEdgeName.show && myFunction != EDGEFUNCTION_NORMAL;
    const bool drawStreetName = s.streetName.show && myStreetName != "";
    if (drawEdgeName || drawInternalEdgeName || drawStreetName) {
        GUILaneWrapper* lane1 = myLaneGeoms[0];
        GUILaneWrapper* lane2 = myLaneGeoms[myLaneGeoms.size() - 1];
        Position p = lane1->getShape().positionAtLengthPosition(lane1->getShape().length() / (SUMOReal) 2.);
        p.add(lane2->getShape().positionAtLengthPosition(lane2->getShape().length() / (SUMOReal) 2.));
        p.mul(.5);
        SUMOReal angle = lane1->getShape().rotationDegreeAtLengthPosition(lane1->getShape().length() / (SUMOReal) 2.);
        angle += 90;
        if (angle > 90 && angle < 270) {
            angle -= 180;
        }
        if (drawEdgeName) {
            drawName(p, s.scale, s.edgeName, angle);
        } else if (drawInternalEdgeName) {
            drawName(p, s.scale, s.internalEdgeName, angle);
        }
        if (drawStreetName) {
            GLHelper::drawText(getStreetName(), p, GLO_MAX,
                               s.streetName.size / s.scale, s.streetName.color, angle);
        }
    }
    myLock.lock();
    for (std::set<MSPerson*>::const_iterator i = myPersons.begin(); i != myPersons.end(); ++i) {
        GUIPerson* person = dynamic_cast<GUIPerson*>(*i);
        assert(person != 0);
        person->drawGL(s);
    }
    myLock.unlock();
}