Path: blob/main/src/utils/gui/windows/GUIPerspectiveChanger.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 GUIPerspectiveChanger.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @author Michael Behrisch17/// @date Sept 200218///19// A virtual class that allows to steer the visual output in dependence to20/****************************************************************************/21#pragma once22#include <config.h>2324#include <utils/foxtools/fxheader.h>25#include <utils/geom/Boundary.h>26#include <utils/geom/Position.h>27#include "GUISUMOAbstractView.h"282930// ===========================================================================31// class declarations32// ===========================================================================33class GUISUMOAbstractView;343536// ===========================================================================37// class definitions38// ===========================================================================39/**40* @class GUIPerspectiveChanger41* This is the interface for implementation of own classes that handle the42* interaction between the user and a display field.43* While most of our (IVF) interfaces allow zooming by choosing the rectangle44* to show, other types of interaction are possible and have been implemented.45* To differ between the behaviours, all types of interaction between the46* user and the canvas are send to this class: mouse moving, mouse button47* pressing and releasing.48*/49class GUIPerspectiveChanger {50public:51/// @brief mouse states52enum MouseState {53MOUSEBTN_NONE = 0,54MOUSEBTN_LEFT = 1,55MOUSEBTN_RIGHT = 2,56MOUSEBTN_MIDDLE = 457};5859/// @brief Constructor60GUIPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort);6162/// @brief Destructor63virtual ~GUIPerspectiveChanger();6465/// @brief mouse functions66//@{67/// @brief called when user press left button68virtual void onLeftBtnPress(void* data);6970/// @brief called when user releases left button71virtual bool onLeftBtnRelease(void* data);7273/// @brief called when user press middle button74virtual void onMiddleBtnPress(void* data);7576/// @brief called when user releases middle button77virtual bool onMiddleBtnRelease(void* data);7879/// @brief called when user press right button80virtual void onRightBtnPress(void* data);8182/// @brief called when user releases right button83virtual bool onRightBtnRelease(void* data);8485/// @brief called when user click two times86virtual void onDoubleClicked(void* data);8788/// @brief called when user changes mouse wheel89virtual void onMouseWheel(void* data);9091/// @brief called when user moves mouse92virtual void onMouseMove(void* data);9394/// @brief called when user press a key95virtual long onKeyPress(void* data);9697/// @brief called when user releases a key98virtual long onKeyRelease(void* data);99//@}100101/// @brief Returns the rotation of the canvas stored in this changer102virtual double getRotation() const = 0;103104/// @brief Returns the x-offset of the field to show stored in this changer105virtual double getXPos() const = 0;106107/// @brief Returns the y-offset of the field to show stored in this changer108virtual double getYPos() const = 0;109110/// @brief Returns the zoom factor computed stored in this changer111virtual double getZoom() const = 0;112113/// @brief Returns the camera height corresponding to the current zoom factor114virtual double getZPos() const = 0;115116/// @brief Returns the camera height at which the given zoom level is reached117virtual double zoom2ZPos(double zoom) const = 0;118119/// @brief Returns the zoom level that is achieved at a given camera height120virtual double zPos2Zoom(double zPos) const = 0;121122/// @brief Centers the view to the given position, setting it to a size that covers the radius. Used for: Centering of vehicles and junctions */123virtual void centerTo(const Position& pos, double radius, bool applyZoom = true) = 0;124125/// @brief Sets the viewport Used for: Adapting a new viewport126virtual void setViewport(double zoom, double xPos, double yPos) = 0;127128/// @brief Alternative method for setting the viewport129virtual void setViewportFrom(double xPos, double yPos, double zPos) = 0;130131/// @brief Sets the rotation132virtual void setRotation(double rotation) = 0;133134/// @brief Returns the last mouse x-position an event occurred at135FXint getMouseXPosition() const;136137/// @brief Returns the last mouse y-position an event occurred at138FXint getMouseYPosition() const;139140/* @brief Adapts the viewport so that a change in canvass size keeps most of the141* view intact (by showing more / less instead of zooming)142* The canvass is clipped/enlarged on the left side of the screen143*144* @param[in] change The horizontal change in canvas size in pixels145*/146virtual void changeCanvasSizeLeft(int change) = 0;147148/// @brief get viewport149Boundary getViewport(bool fixRatio = true);150151/// @brief set viewport152virtual void setViewport(const Boundary& viewPort);153154protected:155/// @brief The parent window (canvas to scale)156GUISUMOAbstractView& myCallback;157158/// @brief the current mouse position159FXint myMouseXPosition = 0;160FXint myMouseYPosition = 0;161162/// @brief the intended viewport163Boundary myViewPort;164165166private:167/// @brief patched viewPort with the same aspect ratio as the canvas168Boundary patchedViewPort();169170171private:172/// @brief Invalidated copy constructor.173GUIPerspectiveChanger(const GUIPerspectiveChanger&);174175/// @brief Invalidated assignment operator.176GUIPerspectiveChanger& operator=(const GUIPerspectiveChanger&);177};178179180