/* Test the method 'scaleRelative'.*/ TEST_F(PositionVectorTest, test_method_scaleRelative) { PositionVector square; square.push_back(Position(0,0)); square.push_back(Position(1,0)); square.push_back(Position(1,1)); square.push_back(Position(0,1)); square.push_back(Position(0,0)); EXPECT_DOUBLE_EQ(square.area(), 1); square.scaleRelative(3); EXPECT_DOUBLE_EQ(square.area(), 9); PositionVector expected; expected.push_back(Position(-1,-1)); expected.push_back(Position(2,-1)); expected.push_back(Position(2,2)); expected.push_back(Position(-1,2)); expected.push_back(Position(-1,-1)); EXPECT_EQ(expected.getCentroid(), square.getCentroid()); for (size_t i = 0; i < square.size(); i++) { EXPECT_DOUBLE_EQ(expected[i].x(), square[i].x()); EXPECT_DOUBLE_EQ(expected[i].y(), square[i].y()); } }
void GNEJunction::drawGL(const GUIVisualizationSettings& s) const { glPushName(getGlID()); SUMOReal selectionScale = gSelected.isSelected(getType(), getGlID()) ? s.selectionScale : 1; if (s.scale * selectionScale * myMaxSize < 1.) { // draw something simple so that selection still works GLHelper::drawBoxLine(myNBNode.getPosition(), 0, 1, 1); } else { // node shape has been computed and is valid for drawing const bool drawShape = myNBNode.getShape().size() > 0 && s.drawJunctionShape; const bool drawBubble = (!drawShape || myNBNode.getShape().area() < 4) && s.drawJunctionShape; // magic threshold if (drawShape) { glPushMatrix(); setColor(s, false); glTranslated(0, 0, getType()); PositionVector shape = myNBNode.getShape(); shape.closePolygon(); if (selectionScale > 1) { shape.scaleRelative(selectionScale); } if (s.scale * selectionScale * myMaxSize < 40.) { GLHelper::drawFilledPoly(shape, true); } else { GLHelper::drawFilledPolyTesselated(shape, true); } glPopMatrix(); } if (drawBubble) { glPushMatrix(); setColor(s, true); Position pos = myNBNode.getPosition(); glTranslated(pos.x(), pos.y(), getType() - 0.05); GLHelper::drawFilledCircle(myMaxSize * selectionScale, 32); glPopMatrix(); } if (s.editMode == GNE_MODE_TLS && myNBNode.isTLControlled() && !myAmTLSSelected) { // decorate in tls mode if (!TLSDecalInitialized) { FXImage* i = new FXGIFImage(myNet->getApp(), tlslogo, IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP); TLSDecalGlID = GUITexturesHelper::add(i); TLSDecalInitialized = true; delete i; } glPushMatrix(); Position pos = myNBNode.getPosition(); glTranslated(pos.x(), pos.y(), getType() + 0.1); glColor3d(1, 1, 1); const SUMOReal halfWidth = 32 / s.scale; const SUMOReal halfHeight = 64 / s.scale; GUITexturesHelper::drawTexturedBox(TLSDecalGlID, -halfWidth, -halfHeight, halfWidth, halfHeight); glPopMatrix(); } // draw crossings if (s.editMode != GNE_MODE_TLS) { for (std::vector<GNECrossing*>::const_iterator it = myCrossings.begin(); it != myCrossings.end(); it++) { (*it)->drawGL(s); } } // (optional) draw name @todo expose this setting drawName(myNBNode.getPosition(), s.scale, s.junctionName); } glPopName(); }