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_Transient.hxx>
22 #include <TCollection_AsciiString.hxx>
23 #include <TopoDS_Shape.hxx>
25 #include <inspector/TInspectorAPI_PreferencesDataMap.hxx>
27 //! The container of parameters for all possible plugins. It stores list of parameters for each plugin, even
28 //! it was not be loaded yet. There is a map of plugin name into plugin parameters.
29 //! The parameters may be:
30 //! - child of Standard_Transient
31 //! - file name to be opened by the plugin
32 class TInspectorAPI_PluginParameters : public Standard_Transient
36 //! Constructs the container.
37 Standard_EXPORT TInspectorAPI_PluginParameters() {}
40 Standard_EXPORT virtual ~TInspectorAPI_PluginParameters() {}
42 //! Stores the parameters for plugin
43 //! \param thePluginName a plugin name
44 //! \param theParameters a list of parameters
45 //! \param theToActivatePlugin a state whether the plugin should be immediately activated, to be used in a heir
46 Standard_EXPORT virtual void SetParameters (const TCollection_AsciiString& thePluginName,
47 const NCollection_List<Handle(Standard_Transient)>& theParameters,
48 const Standard_Boolean& theToActivatePlugin = Standard_False);
50 //! Adds a file name for the plugin
51 //! \param thePluginName a plugin name
52 //! \param theFileName a name
53 Standard_EXPORT void AddFileName (const TCollection_AsciiString& thePluginName,
54 const TCollection_AsciiString& theFileName);
56 //! Sets file names for the plugin
57 //! \param thePluginName a plugin name
58 //! \param theFileNames container of names
59 Standard_EXPORT void SetFileNames (const TCollection_AsciiString& thePluginName,
60 const NCollection_List<TCollection_AsciiString>& theFileNames);
62 //! Sets a name of item to be selected in the plugin
63 //! \param thePluginName a plugin name
64 //! \param theItemNames a container of names to be selected
65 Standard_EXPORT void SetSelectedNames (const TCollection_AsciiString& thePluginName,
66 const NCollection_List<TCollection_AsciiString>& theItemNames);
68 //! Sets objects to be selected in the plugin
69 //! \param thePluginName a plugin name
70 //! \param theObjects an objects
71 Standard_EXPORT void SetSelected (const TCollection_AsciiString& thePluginName,
72 const NCollection_List<Handle(Standard_Transient)>& theObjects);
74 //! Returns true if there are parameters set for the given plugin
75 //! \param thePluginName a plugin name
76 //! \return boolean result
77 Standard_EXPORT bool FindParameters (const TCollection_AsciiString& thePluginName);
79 //! Returns parameters set for the given plugin
80 //! \param thePluginName a plugin name
81 //! \return container of objects
82 Standard_EXPORT const NCollection_List<Handle(Standard_Transient)>& Parameters (const TCollection_AsciiString& thePluginName);
84 //! Returns true if there are file names set for the given plugin
85 //! \param thePluginName a plugin name
86 //! \return boolean result
87 Standard_EXPORT bool FindFileNames (const TCollection_AsciiString& thePluginName);
89 //! Returns file names set for the given plugin
90 //! \param thePluginName a plugin name
91 //! \return container of names
92 Standard_EXPORT const NCollection_List<TCollection_AsciiString>& FileNames (const TCollection_AsciiString& thePluginName);
94 //! Returns true if there are file names set for the given plugin
95 //! \param thePluginName a plugin name
96 //! \return boolean result
97 Standard_EXPORT bool FindSelectedNames (const TCollection_AsciiString& thePluginName);
99 //! Returns name to be selected in the plugin
100 //! \param thePluginName a plugin name
101 //! \return container of names
102 Standard_EXPORT const NCollection_List<TCollection_AsciiString>& GetSelectedNames (
103 const TCollection_AsciiString& thePluginName);
105 //! Returns objects set for the given plugin
106 //! \param thePluginName a plugin name
107 //! \return container of objects
108 Standard_EXPORT Standard_Boolean GetSelectedObjects (const TCollection_AsciiString& thePluginName,
109 NCollection_List<Handle(Standard_Transient)>& theObjects);
111 //! Sets path to a directory for temporary plugin files
112 //! \param thePath a path
113 virtual void SetTemporaryDirectory (const TCollection_AsciiString& thePath) { myTemporaryDirectory = thePath; }
115 //! Returns path to a directory for temporary plugin files
117 TCollection_AsciiString GetTemporaryDirectory() const { return myTemporaryDirectory; }
119 //! Returns plugin preferences
120 //! \param thePluginName a plugin name
121 Standard_EXPORT virtual void GetPreferences (const TCollection_AsciiString& thePluginName,
122 TInspectorAPI_PreferencesDataMap& theItem) = 0;
124 //! Stores plugin preferences
125 //! \param thePluginName a plugin name
126 //! \theItem container of plugin preferences values in form: <name, value>
127 Standard_EXPORT virtual void SetPreferences (const TCollection_AsciiString& thePluginName,
128 const TInspectorAPI_PreferencesDataMap& theItem) = 0;
130 //! Stores plugin preferences into a preferences file
131 Standard_EXPORT virtual void StorePreferences() = 0;
133 //! Converts a Shape parameters excepting TShape into a string value
134 //! \param theShape processed shape
135 //! \return string instance
136 Standard_EXPORT static TCollection_AsciiString ParametersToString (const TopoDS_Shape& theShape);
138 //! Converts a Shape parameters excepting TShape into a string value
139 //! \param theValue parameters string value (without TShape information)
140 //! \param theShape processed shape
141 Standard_EXPORT static void ParametersToShape (const TCollection_AsciiString& theValue, TopoDS_Shape& theShape);
144 DEFINE_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
146 //! container of parameters
147 NCollection_DataMap<TCollection_AsciiString, NCollection_List<Handle(Standard_Transient)> > myParameters;
148 //! container of names
149 NCollection_DataMap<TCollection_AsciiString, NCollection_List<TCollection_AsciiString> > myFileNames;
150 //! container of select item names
151 NCollection_DataMap<TCollection_AsciiString, NCollection_List<TCollection_AsciiString> > mySelectedItemNames;
152 //! container of select objects
153 NCollection_DataMap<TCollection_AsciiString, NCollection_List<Handle(Standard_Transient)> > mySelectedObjects;
154 //! temporary directory for saving plugin preferences
155 TCollection_AsciiString myTemporaryDirectory;