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