Line data Source code
1 : /****************************************************************************/ 2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3 : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others. 4 : // This program and the accompanying materials are made available under the 5 : // terms of the Eclipse Public License 2.0 which is available at 6 : // https://www.eclipse.org/legal/epl-2.0/ 7 : // This Source Code may also be made available under the following Secondary 8 : // Licenses when the conditions for such availability set forth in the Eclipse 9 : // Public License 2.0 are satisfied: GNU General Public License, version 2 10 : // or later which is available at 11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html 12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later 13 : /****************************************************************************/ 14 : /// @file GUICursorSubSys.cpp 15 : /// @author Pablo Alvarez Lopez 16 : /// @date Nov 2018 17 : /// 18 : // Helper for cursors loading and usage 19 : /****************************************************************************/ 20 : #include <config.h> 21 : 22 : #include <utils/common/UtilExceptions.h> 23 : 24 : #include "GUICursors.h" 25 : #include "GUICursorSubSys.h" 26 : 27 : #include "Delete_cursor.cpp" 28 : #include "Select_cursor.cpp" 29 : #include "SelectLane_cursor.cpp" 30 : #include "Inspect_cursor.cpp" 31 : #include "InspectLane_cursor.cpp" 32 : #include "MoveElement_cursor.cpp" 33 : 34 : // =========================================================================== 35 : // static member variable definitions 36 : // =========================================================================== 37 : 38 : GUICursorSubSys* GUICursorSubSys::myInstance = nullptr; 39 : 40 : // =========================================================================== 41 : // member definitions 42 : // =========================================================================== 43 : 44 7254 : GUICursorSubSys::GUICursorSubSys(FXApp* a) { 45 : // default cursors (already created) 46 7254 : myCursors[GUICursor::DEFAULT] = a->getDefaultCursor(DEF_ARROW_CURSOR); 47 7254 : myCursors[GUICursor::MOVEVIEW] = a->getDefaultCursor(DEF_MOVE_CURSOR); 48 : 49 : // custom cursors (must be created) 50 7254 : myCursors[GUICursor::DELETE_CURSOR] = new FXGIFCursor(a, Delete_cursor, 1, 2); 51 7254 : myCursors[GUICursor::SELECT] = new FXGIFCursor(a, Select_cursor, 1, 1); 52 7254 : myCursors[GUICursor::SELECT_LANE] = new FXGIFCursor(a, SelectLane_cursor, 1, 1); 53 7254 : myCursors[GUICursor::INSPECT] = new FXGIFCursor(a, Inspect_cursor, 1, 2); 54 7254 : myCursors[GUICursor::INSPECT_LANE] = new FXGIFCursor(a, InspectLane_cursor, 1, 2); 55 7254 : myCursors[GUICursor::MOVEELEMENT] = new FXGIFCursor(a, MoveElement_cursor, 1, 2); 56 : 57 : // ... and create them 58 65286 : for (const auto& cursor : myCursors) { 59 58032 : if (cursor.second != nullptr) { 60 58032 : cursor.second->create(); 61 : } 62 : } 63 : 64 7254 : } 65 : 66 : 67 7237 : GUICursorSubSys::~GUICursorSubSys() { 68 : // delete all cursors 69 65133 : for (const auto& cursor : myCursors) { 70 57896 : if (cursor.first != GUICursor::DEFAULT && cursor.first != GUICursor::MOVEVIEW) { 71 43422 : delete cursor.second; 72 : } 73 : } 74 7237 : } 75 : 76 : 77 : void 78 7254 : GUICursorSubSys::initCursors(FXApp* a) { 79 7254 : if (myInstance == nullptr) { 80 7254 : myInstance = new GUICursorSubSys(a); 81 : } else { 82 0 : throw ProcessError("GUICursorSubSys already init"); 83 : } 84 7254 : } 85 : 86 : 87 : FXCursor* 88 0 : GUICursorSubSys::getCursor(GUICursor which) { 89 0 : return myInstance->myCursors[which]; 90 : } 91 : 92 : 93 : void 94 7237 : GUICursorSubSys::close() { 95 : // delete and reset instance 96 7237 : delete myInstance; 97 7237 : myInstance = nullptr; 98 7237 : } 99 : 100 : 101 : /****************************************************************************/