Tulip  6.0.0
Large graphs analysis and drawing
TulipMaterialDesignIcons.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 TULIPMATERIALDESIGNICONS_H
23 #define TULIPMATERIALDESIGNICONS_H
24 
25 #include <tulip/tulipconf.h>
26 
27 #include <vector>
28 
29 #undef linux
30 
31 namespace tlp {
32 
33 /**
34  * @brief Helper class for the configuration of a Material Design Icon glyph.
35  *
36  * @since Tulip 5.0
37  *
38  * Material Design Icons (https://materialdesignicons.com/) :
39  * a growing icon collection allows designers and developers
40  * targeting various platforms to download icons in the format,
41  * color and size they need for any project.
42  *
43  * A glyph has been added to Tulip enabling to use these great icons
44  * as nodes and edges extremities shapes.
45  *
46  * That class offers utility functions and supported icons names constants.
47  *
48  * To set a node glyph as a Material Design icon, the Icon glyph must be associated
49  * to the node through the modification of the "viewShape" integer property attached to the graph.
50  * The name of the icon to use must then be set in the "viewIcon" string property.
51  * As an example, the following code snippet activates the Material Design glyph for all nodes
52  * and sets the "user" icon.
53  *
54  * @code
55  * // graph is a pointer to a tlp::Graph object
56  * tlp::IntegerProperty *viewShape = graph->getProperty<tlp::IntegerProperty>("viewShape");
57  * tlp::StringProperty *viewIcon = graph->getProperty<tlp::StringProperty>("viewIcon");
58  *
59  * // sets the Icon glyph on all nodes
60  * viewShape->setAllNodeValue(tlp::NodeShape::Icon);
61  * // sets the "user" glyph for all nodes
62  * viewIcon->setAllNodeValue("mdi-user");
63  * @endcode
64  **/
65 
66 class TLP_GL_SCOPE TulipMaterialDesignIcons {
67 
68 public:
69  /**
70  * Returns the current Material Design Icons version
71  */
72  static std::string getVersion();
73 
74  /**
75  * Returns the location of the Material Design Icons .ttf file bundled with Tulip
76  */
77  static std::string getTTFLocation();
78 
79  /**
80  * Returns the location of the Material Design Icons .woff2 file bundled with Tulip
81  */
82  static std::string getWOFF2Location();
83 
84  /**
85  * Returns the list of supported Material Design icons names
86  */
87  static const std::vector<std::string> &getSupportedIcons();
88 
89  /**
90  * Checks if the provided Material Design icon name is supported
91  * @param iconName the name of the icon to check support
92  */
93  static bool isIconSupported(const std::string &iconName);
94 
95  /**
96  * Returns the Unicode code point associated to an icon name
97  * @param iconName the name of the icon to get the codepoint
98  */
99  static unsigned int getIconCodePoint(const std::string &iconName);
100 
101  /**
102  * Returns the font family name associated to an icon name
103  * @param iconName the name of the icon
104  */
105  static std::string getIconFamily(const std::string &iconName);
106 
107  /**
108  * Returns the font style name associated to an icon name
109  * @param iconName the name of the icon
110  */
111  static std::string getIconStyle(const std::string &iconName);
112 
113  /**
114  * Returns an UTF-8 encoded string of a Material Design icon
115  * @param iconName a Material Design icon name
116  * @return
117  */
118  static std::string getIconUtf8String(const std::string &iconName);
119 };
120 } // namespace tlp
121 
122 #endif // TULIPMATERIALDESIGNICONS_H
123 
124 ///@endcond