1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef TInspectorAPI_PluginParameters_H
17 #define TInspectorAPI_PluginParameters_H
19 #include <NCollection_DataMap.hxx>
20 #include <NCollection_List.hxx>
21 #include <Standard_Version.hxx>
22 #include <Standard_Transient.hxx>
23 #include <TCollection_AsciiString.hxx>
24 #include <TopoDS_Shape.hxx>
26 #include <inspector/TInspectorAPI_PreferencesDataMap.hxx>
28 class TInspectorAPI_PluginParameters;
29 DEFINE_STANDARD_HANDLE (TInspectorAPI_PluginParameters, Standard_Transient)
31 //! The container of parameters for all possible plugins. It stores list of parameters for each plugin, even
32 //! it was not be loaded yet. There is a map of plugin name into plugin parameters.
33 //! The parameters may be:
34 //! - child of Standard_Transient
35 //! - file name to be opened by the plugin
36 class TInspectorAPI_PluginParameters : public Standard_Transient
40 //! Constructs the container.
41 Standard_EXPORT TInspectorAPI_PluginParameters() {}
44 Standard_EXPORT virtual ~TInspectorAPI_PluginParameters() Standard_OVERRIDE {}
46 //! Stores the parameters for plugin
47 //! \param thePluginName a plugin name
48 //! \param theParameters a list of parameters
49 //! \param theToActivatePlugin a state whether the plugin should be immediately activated, to be used in a heir
50 Standard_EXPORT virtual void SetParameters (const TCollection_AsciiString& thePluginName,
51 const NCollection_List<Handle(Standard_Transient)>& theParameters,
52 const Standard_Boolean& theToActivatePlugin = Standard_False);
54 //! Adds a file name for the plugin
55 //! \param thePluginName a plugin name
56 //! \param theFileName a name
57 Standard_EXPORT void AddFileName (const TCollection_AsciiString& thePluginName,
58 const TCollection_AsciiString& theFileName);
60 //! Sets file names for the plugin
61 //! \param thePluginName a plugin name
62 //! \param theFileNames container of names
63 Standard_EXPORT void SetFileNames (const TCollection_AsciiString& thePluginName,
64 const NCollection_List<TCollection_AsciiString>& theFileNames);
66 //! Sets a name of item to be selected in the plugin
67 //! \param thePluginName a plugin name
68 //! \param theItemNames a container of names to be selected
69 Standard_EXPORT void SetSelectedNames (const TCollection_AsciiString& thePluginName,
70 const NCollection_List<TCollection_AsciiString>& theItemNames);
72 //! Sets objects to be selected in the plugin
73 //! \param thePluginName a plugin name
74 //! \param theObjects an objects
75 Standard_EXPORT void SetSelected (const TCollection_AsciiString& thePluginName,
76 const NCollection_List<Handle(Standard_Transient)>& theObjects);
78 //! Returns true if there are parameters set for the given plugin
79 //! \param thePluginName a plugin name
80 //! \return boolean result
81 Standard_EXPORT bool FindParameters (const TCollection_AsciiString& thePluginName);
83 //! Returns parameters set for the given plugin
84 //! \param thePluginName a plugin name
85 //! \return container of objects
86 Standard_EXPORT const NCollection_List<Handle(Standard_Transient)>& Parameters (const TCollection_AsciiString& thePluginName);
88 //! Returns true if there are file names set for the given plugin
89 //! \param thePluginName a plugin name
90 //! \return boolean result
91 Standard_EXPORT bool FindFileNames (const TCollection_AsciiString& thePluginName);
93 //! Returns file names set for the given plugin
94 //! \param thePluginName a plugin name
95 //! \return container of names
96 Standard_EXPORT const NCollection_List<TCollection_AsciiString>& FileNames (const TCollection_AsciiString& thePluginName);
98 //! Returns true if there are file names set for the given plugin
99 //! \param thePluginName a plugin name
100 //! \return boolean result
101 Standard_EXPORT bool FindSelectedNames (const TCollection_AsciiString& thePluginName);
103 //! Returns name to be selected in the plugin
104 //! \param thePluginName a plugin name
105 //! \return container of names
106 Standard_EXPORT const NCollection_List<TCollection_AsciiString>& GetSelectedNames (
107 const TCollection_AsciiString& thePluginName);
109 //! Returns objects set for the given plugin
110 //! \param thePluginName a plugin name
111 //! \return container of objects
112 Standard_EXPORT Standard_Boolean GetSelectedObjects (const TCollection_AsciiString& thePluginName,
113 NCollection_List<Handle(Standard_Transient)>& theObjects);
115 //! Sets path to a directory for temporary plugin files
116 //! \param thePath a path
117 virtual void SetTemporaryDirectory (const TCollection_AsciiString& thePath) { myTemporaryDirectory = thePath; }
119 //! Returns path to a directory for temporary plugin files
121 TCollection_AsciiString GetTemporaryDirectory() const { return myTemporaryDirectory; }
123 //! Returns plugin preferences
124 //! \param thePluginName a plugin name
125 Standard_EXPORT virtual void GetPreferences (const TCollection_AsciiString& thePluginName,
126 TInspectorAPI_PreferencesDataMap& theItem) = 0;
128 //! Stores plugin preferences
129 //! \param thePluginName a plugin name
130 //! \theItem container of plugin preferences values in form: <name, value>
131 Standard_EXPORT virtual void SetPreferences (const TCollection_AsciiString& thePluginName,
132 const TInspectorAPI_PreferencesDataMap& theItem) = 0;
134 //! Converts a Shape parameters excepting TShape into a string value
135 //! \param theShape processed shape
136 //! \return string instance
137 Standard_EXPORT static TCollection_AsciiString ParametersToString (const TopoDS_Shape& theShape);
139 //! Converts a Shape parameters exceptin TShape into a string value
140 //! \param theValue parameters string value (without TShape information)
141 //! \param theShape processed shape
142 Standard_EXPORT static void ParametersToShape (const TCollection_AsciiString& theValue, TopoDS_Shape& theShape);
145 #if OCC_VERSION_HEX <= 0x060901
146 DEFINE_STANDARD_RTTI (TInspectorAPI_PluginParameters)
148 DEFINE_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
151 //! container of parameters
152 NCollection_DataMap<TCollection_AsciiString, NCollection_List<Handle(Standard_Transient)> > myParameters;
153 //! container of names
154 NCollection_DataMap<TCollection_AsciiString, NCollection_List<TCollection_AsciiString> > myFileNames;
155 //! container of select item names
156 NCollection_DataMap<TCollection_AsciiString, NCollection_List<TCollection_AsciiString> > mySelectedItemNames;
157 //! container of select objects
158 NCollection_DataMap<TCollection_AsciiString, NCollection_List<Handle(Standard_Transient)> > mySelectedObjects;
159 //! temporary directory for saving plugin preferences
160 TCollection_AsciiString myTemporaryDirectory;