Salome HOME
Merge branch 'master' of salome:modules/shaper
[modules/shaper.git] / src / ModuleBase / ModuleBase_IconFactory.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef ModuleBase_IconFactory_H
22 #define ModuleBase_IconFactory_H
23
24 #include "ModuleBase.h"
25 #include <ModelAPI_Object.h>
26
27 #include <QPixmap>
28 #include <QIcon>
29 #include <QImage>
30
31 /**\class ModuleBase_IconFactory
32  * \ingroup GUI
33  * \brief This is a class which provides icons of objects for object browser 
34  */
35 class MODULEBASE_EXPORT ModuleBase_IconFactory
36 {
37 public:
38   /// Returns icons factory instance
39   static ModuleBase_IconFactory* get();
40
41   /// Returns Icon for the given object
42   /// \param theObj an object
43   virtual QIcon getIcon(ObjectPtr theObj);
44
45   /// Finds an icon for the given value. The icon is loaded: firstly from qrc file,
46   /// then by the icon path. If the path contains ":" , it will be treated as absolute path to
47   /// the icon, or relative path from the plugin library
48   /// \param theValue an icon information
49   /// \return a loaded or empty icon
50   static QIcon loadIcon(const QString& theValue);
51
52   /// Finds a pixmap for the given value. It is loaded: firstly from qrc file,
53   /// then by the absolute path. If the pixmap is not loaded, it is searched in relative plugin path
54   /// \param theValue a pixmap information
55   /// \return a loaded or empty pixmap
56   static QPixmap loadPixmap(const QString& theValue);
57
58   /// Finds an image for the given value. It is loaded: firstly from qrc file,
59   /// then by the absolute path. If the image is not loaded, it is searched in relative plugin path
60   /// \param theValue a image information
61   /// \return a loaded or empty pixmap
62   static QImage loadImage(const QString& theValue);
63
64 protected:
65   ModuleBase_IconFactory();
66
67   /// Set the current icons factory instance
68   /// \param theFactory a new factory
69   static void setFactory(ModuleBase_IconFactory* theFactory);
70 };
71
72 #endif