Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/gui/cursors/GUICursorSubSys.cpp
169684 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
GUICursorSubSys::GUICursorSubSys(FXApp* a) {
45
// default cursors (already created)
46
myCursors[GUICursor::DEFAULT] = a->getDefaultCursor(DEF_ARROW_CURSOR);
47
myCursors[GUICursor::MOVEVIEW] = a->getDefaultCursor(DEF_MOVE_CURSOR);
48
49
// custom cursors (must be created)
50
myCursors[GUICursor::DELETE_CURSOR] = new FXGIFCursor(a, Delete_cursor, 1, 2);
51
myCursors[GUICursor::SELECT] = new FXGIFCursor(a, Select_cursor, 1, 1);
52
myCursors[GUICursor::SELECT_LANE] = new FXGIFCursor(a, SelectLane_cursor, 1, 1);
53
myCursors[GUICursor::INSPECT] = new FXGIFCursor(a, Inspect_cursor, 1, 2);
54
myCursors[GUICursor::INSPECT_LANE] = new FXGIFCursor(a, InspectLane_cursor, 1, 2);
55
myCursors[GUICursor::MOVEELEMENT] = new FXGIFCursor(a, MoveElement_cursor, 1, 2);
56
57
// ... and create them
58
for (const auto& cursor : myCursors) {
59
if (cursor.second != nullptr) {
60
cursor.second->create();
61
}
62
}
63
64
}
65
66
67
GUICursorSubSys::~GUICursorSubSys() {
68
// delete all cursors
69
for (const auto& cursor : myCursors) {
70
if (cursor.first != GUICursor::DEFAULT && cursor.first != GUICursor::MOVEVIEW) {
71
delete cursor.second;
72
}
73
}
74
}
75
76
77
void
78
GUICursorSubSys::initCursors(FXApp* a) {
79
if (myInstance == nullptr) {
80
myInstance = new GUICursorSubSys(a);
81
} else {
82
throw ProcessError("GUICursorSubSys already init");
83
}
84
}
85
86
87
FXCursor*
88
GUICursorSubSys::getCursor(GUICursor which) {
89
return myInstance->myCursors[which];
90
}
91
92
93
void
94
GUICursorSubSys::close() {
95
// delete and reset instance
96
delete myInstance;
97
myInstance = nullptr;
98
}
99
100
101
/****************************************************************************/
102
103