Salome HOME
92bb0704c72f6f1e6d5d4335a8b703e2df28c612
[modules/shaper.git] / src / ModuleBase / ModuleBase_IconFactory.h
1 // Copyright (C) 2014-2021  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 email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef ModuleBase_IconFactory_H
21 #define ModuleBase_IconFactory_H
22
23 #include "ModuleBase.h"
24 #include <ModelAPI_Object.h>
25
26 #include <QPixmap>
27 #include <QIcon>
28 #include <QImage>
29
30 /**\class ModuleBase_IconFactory
31  * \ingroup GUI
32  * \brief This is a class which provides icons of objects for object browser 
33  */
34 class MODULEBASE_EXPORT ModuleBase_IconFactory
35 {
36 public:
37   virtual ~ModuleBase_IconFactory() {}
38
39   /// Returns icons factory instance
40   static ModuleBase_IconFactory* get();
41
42   /// Returns Icon for the given object
43   /// \param theObj an object
44   virtual QIcon getIcon(ObjectPtr theObj);
45
46   /// Finds an icon for the given value. The icon is loaded: firstly from qrc file,
47   /// then by the icon path. If the path contains ":" , it will be treated as absolute path to
48   /// the icon, or relative path from the plugin library
49   /// \param theValue an icon information
50   /// \return a loaded or empty icon
51   static QIcon loadIcon(const QString& theValue);
52
53   /// Finds a pixmap for the given value. It is loaded: firstly from qrc file,
54   /// then by the absolute path. If the pixmap is not loaded, it is searched in relative plugin path
55   /// \param theValue a pixmap information
56   /// \return a loaded or empty pixmap
57   static QPixmap loadPixmap(const QString& theValue);
58
59   /// Finds an image for the given value. It is loaded: firstly from qrc file,
60   /// then by the absolute path. If the image is not loaded, it is searched in relative plugin path
61   /// \param theValue a image information
62   /// \return a loaded or empty pixmap
63   static QImage loadImage(const QString& theValue);
64
65 protected:
66   ModuleBase_IconFactory();
67
68   /// Set the current icons factory instance
69   /// \param theFactory a new factory
70   static void setFactory(ModuleBase_IconFactory* theFactory);
71 };
72
73 #endif