void
GUIDanielPerspectiveChanger::centerTo(const Boundary &netBoundary,
                                      Boundary bound,
                                      bool applyZoom) {
    myViewCenter.set(bound.getCenter());
    myViewCenter.sub(netBoundary.getCenter());
    myViewCenter.mul(-1.0);
    if (applyZoom) {
        myZoom =
            bound.getWidth() > bound.getHeight() ?
            (SUMOReal) 100.0 * (SUMOReal) netBoundary.getWidth() / (SUMOReal) bound.getWidth() :
            (SUMOReal) 100.0 * (SUMOReal) netBoundary.getHeight() / (SUMOReal) bound.getHeight();
    }
}
// ===========================================================================
// method definitions
// ===========================================================================
GUIDanielPerspectiveChanger::GUIDanielPerspectiveChanger(
    GUISUMOAbstractView& callBack, const Boundary& viewPort) :
    GUIPerspectiveChanger(callBack, viewPort),
    myOrigWidth(viewPort.getWidth()),
    myOrigHeight(viewPort.getHeight()),
    myRotation(0),
    myMouseButtonState(MOUSEBTN_NONE),
    myMoveOnClick(false),
    myZoomBase(viewPort.getCenter()),
    myDragDelay(0) {
}
void
GUIDanielPerspectiveChanger::centerTo(const Boundary &netBoundary,
                                      const Position2D &pos, SUMOReal radius,
                                      bool applyZoom) {
    myViewCenter.set(pos);
    myViewCenter.sub(netBoundary.getCenter());
    myViewCenter.mul(-1.0);
    if (applyZoom) {
        myZoom =
            netBoundary.getWidth() < netBoundary.getHeight() ?
            (SUMOReal) 25.0 * (SUMOReal) netBoundary.getWidth() / radius :
            (SUMOReal) 25.0 * (SUMOReal) netBoundary.getHeight() / radius;
    }
}
Example #4
0
/* Test the method 'getCenter'*/
TEST(Boundary, test_method_getCenter) {
	Boundary *bound = new Boundary(-2,-4,4,8);
	Position pos = bound->getCenter();
	EXPECT_DOUBLE_EQ(pos.x(), 1);
	EXPECT_DOUBLE_EQ(pos.y(), 2);
}