Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
TulipFontAwesome.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
7 *
8 * Tulip is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation, either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * Tulip is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
17 *
18 */
19
20///@cond DOXYGEN_HIDDEN
21
22#ifndef TULIPFONTAWESOME_H
23#define TULIPFONTAWESOME_H
24
25#include <tulip/tulipconf.h>
26
27#include <vector>
28
29namespace tlp {
30
31/**
32 * @brief Helper class for the configuration of a Font Awesome glyph.
33 *
34 * Font Awesome is a free iconic font by Dave Gandy (see https://fontawesome.com)
35 * offering more than 500 customizable scalable vector icons.
36 *
37 * A glyph has been added to Tulip enabling to use these great icons
38 * as nodes and edges extremities shapes.
39 *
40 * That class offers utility functions and supported icons names constants.
41 *
42 * To set a node glyph as a Font Awesome icon, the Icon glyph must be associated
43 * to the node through the modification of the "viewShape" integer property attached to the graph.
44 * The name of the icon to use must then be set in the "viewIcon" string property.
45 * As an example, the following code snippet activates the Font Awesome glyph for all nodes
46 * and sets the "user" icon.
47 *
48 * @code
49 * // graph is a pointer to a tlp::Graph object
50 * tlp::IntegerProperty *viewShape = graph->getProperty<tlp::IntegerProperty>("viewShape");
51 * tlp::StringProperty *viewIcon = graph->getProperty<tlp::StringProperty>("viewIcon");
52 *
53 * // sets the Icon glyph on all nodes
54 * viewShape->setAllNodeValue(tlp::NodeShape::Icon);
55 * // sets the "user" glyph for all nodes
56 * viewIcon->setAllNodeValue("fas-user");
57 * @endcode
58 **/
59
60class TLP_GL_SCOPE TulipFontAwesome {
61
62public:
63 /**
64 * Returns the version of the Font Awesome icons bundled with Tulip
65 */
66 static std::string getVersion();
67
68 /**
69 * Returns the location of the Font Awesome .ttf file bundled with Tulip
70 */
71 static std::string getTTFLocation(const std::string &iconName);
72
73 /**
74 * Returns the location of the Font Awesome .woff2 file bundled with Tulip
75 */
76 static std::string getWOFF2Location(const std::string &iconName);
77
78 /**
79 * Returns the list of supported Font Awesome icons names
80 */
81 static const std::vector<std::string> &getSupportedIcons();
82
83 /**
84 * Checks if the provided Font Awesome icon name is supported
85 * @param iconName the name of the icon to check support
86 */
87 static bool isIconSupported(const std::string &iconName);
88
89 /**
90 * Returns the Unicode code point associated to an icon name
91 * @param iconName the name of the icon to get the codepoint
92 */
93 static unsigned int getIconCodePoint(const std::string &iconName);
94
95 /**
96 * Returns the font family name associated to an icon name
97 * @param iconName the name of the icon
98 */
99 static std::string getIconFamily(const std::string &iconName);
100
101 /**
102 * Returns the font style name associated to an icon name
103 * @param iconName the name of the icon
104 */
105 static std::string getIconStyle(const std::string &iconName);
106
107 /**
108 * Returns an UTF-8 encoded string of a Font Awesome icon
109 * @param iconName a Font Awesome icon name
110 * @return
111 */
112 static std::string getIconUtf8String(const std::string &iconName);
113};
114} // namespace tlp
115
116#endif // TULIPFONTAWESOME_H
117
118///@endcond