Path: blob/main/src/utils/gui/windows/GUIDanielPerspectiveChanger.h
169684 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GUIDanielPerspectiveChanger.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @author Michael Behrisch17/// @date Sept 200218///19// A class that allows to steer the visual output in dependence to20/****************************************************************************/21#pragma once22#include <config.h>2324#include <utils/geom/Position.h>25#include "GUIPerspectiveChanger.h"262728// ===========================================================================29// class declarations30// ===========================================================================31class Boundary;323334// ===========================================================================35// class definitions36// ===========================================================================37/**38* @class GUIDanielPerspectiveChanger39* This changer has the following behaviour:40* - zooming by pressing the right mouse button and moving the41* mouse vertically42* - rotation by pressing the right mouse button and moving the43* mouse horizontally44* - network movement by pressing the left mouse button and45* moving the mouse46*/47class GUIDanielPerspectiveChanger : public GUIPerspectiveChanger {48public:49/* Constructor50* @param[in] callBack The view to be updated upon changes51*/52GUIDanielPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort);5354/// Destructor55~GUIDanielPerspectiveChanger();5657void onLeftBtnPress(void* data);58bool onLeftBtnRelease(void* data);59void onMiddleBtnPress(void* data);60bool onMiddleBtnRelease(void* data);61void onRightBtnPress(void* data);62bool onRightBtnRelease(void* data);63void onMouseWheel(void* data);64void onMouseMove(void* data);65long onKeyPress(void* data);6667/// Returns the rotation of the canvas stored in this changer68virtual double getRotation() const;6970/// Returns the x-offset of the field to show stored in this changer71virtual double getXPos() const;7273/// Returns the y-offset of the field to show stored in this changer74virtual double getYPos() const;7576/// Returns the zoom factor computed stored in this changer77virtual double getZoom() const;7879/// @brief Returns the camera height corresponding to the current zoom factor80virtual double getZPos() const;8182/// @brief Returns the camera height at which the given zoom level is reached83virtual double zoom2ZPos(double zoom) const;8485/// @brief Returns the zoom level that is achieved at a given camera height86virtual double zPos2Zoom(double zPos) const;8788/// Centers the view to the given position, setting it to a size that covers the radius89void centerTo(const Position& pos, double radius, bool applyZoom = true);9091/** @brief Sets the viewport */92void setViewport(double zoom, double xPos, double yPos);93using GUIPerspectiveChanger::setViewport; // to silence the warning C4266 about a hidden function9495/// @brief Alternative method for setting the viewport96void setViewportFrom(double xPos, double yPos, double zPos);9798/// @brief Sets the rotation99void setRotation(double rotation);100101/* @brief Adapts the viewport so that a change in canvass size keeps most of the102* view intact (by showing more / less instead of zooming)103* The canvass is clipped/enlarged on the left side of the screen104*105* @param[in] change The horizontal change in canvas size in pixels106*/107void changeCanvasSizeLeft(int change);108109/* @brief avoid unwanted flicker110* @param[in] delay The minimum time delay in nanoseconds after111* mouseDown after which mouse-movements should be interpreted as zoom/drag112*/113void setDragDelay(FXTime delay) {114myDragDelay = delay;115}116117private:118/* Performs the view movement119* @param[in] xdiff the change to myViewCenter in pixel120* @param[in] ydiff the change to myViewCenter in pixel121*/122void move(int xdiff, int ydiff);123124/// Performs the zooming of the view125void zoom(double factor);126127/// Performs the rotation of the view128void rotate(int diff);129130private:131/// the original viewport dimensions in m which serve as the reference point for 100% zoom132double myOrigWidth, myOrigHeight;133134/// the current rotation135double myRotation;136137/// the current mouse state138int myMouseButtonState;139140/// Information whether the user has moved the cursor while pressing a mouse button141bool myMoveOnClick;142143/// the network location on which to zoom using right click+drag144Position myZoomBase;145146/// avoid flicker147FXTime myDragDelay;148FXlong myMouseDownTime;149150151private:152/// @brief Invalidated copy constructor.153GUIDanielPerspectiveChanger(const GUIDanielPerspectiveChanger&);154155/// @brief Invalidated assignment operator.156GUIDanielPerspectiveChanger& operator=(const GUIDanielPerspectiveChanger&);157158};159160161