f2d8633878430d58e372f26bce133ccfb8c0a2fc
[occt.git] / tools / TInspector / TInspector_Communicator.hxx
1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement. 
15
16 #ifndef TInspector_Communicator_H
17 #define TInspector_Communicator_H
18
19 #include <inspector/TInspector_Window.hxx>
20 #include <inspector/TInspectorAPI_PluginParameters.hxx>
21
22 #include <NCollection_List.hxx>
23 #include <Standard.hxx>
24 #include <Standard_Transient.hxx>
25 #include <TCollection_AsciiString.hxx>
26
27 class QPushButton;
28
29 //! \class TInspector_Communicator.
30 //! \brief This is a connector from TInspector window to:
31 //! - register tool plugin
32 //! - give parameters into plugin
33 class TInspector_Communicator
34 {
35 public:
36
37   //! Constructor
38   Standard_EXPORT TInspector_Communicator();
39
40   //! Destructor
41   virtual ~TInspector_Communicator() {}
42
43   //! Registers plugin into TInspector window
44   //! \param thePluginName a name of the plugin
45   void RegisterPlugin (const TCollection_AsciiString& thePluginName) { myWindow->RegisterPlugin (thePluginName); }
46
47   //! Returns list of registered plugins
48   //! \return container of plugin names
49   NCollection_List<TCollection_AsciiString> RegisteredPlugins() const { return myWindow->RegisteredPlugins(); }
50
51   //! Stores parameters for the plugin
52   //! \param theParameters container of parameters(e.g. AIS_InteractiveContext, TDocStd_Application)
53   //! \param theAppend boolean state whethe the parameters should be added to existing
54   void Init (const NCollection_List<Handle(Standard_Transient)>& theParameters,
55              const Standard_Boolean theAppend = Standard_False)
56     { myWindow->Init ("", theParameters, theAppend); }
57
58   //! Stores parameters for the plugin
59   //! \param thePluginName a name of the plugin
60   //! \param theParameters container of parameters(e.g. AIS_InteractiveContext, TDocStd_Application)
61   //! \param theAppend boolean state whethe the parameters should be added to existing
62   void Init (const TCollection_AsciiString& thePluginName,
63              const NCollection_List<Handle(Standard_Transient)>& theParameters,
64              const Standard_Boolean theAppend = Standard_False)
65   { myWindow->Init (thePluginName, theParameters, theAppend); }
66
67   //! Updates content for the TInspector window
68   void UpdateContent() { myWindow->UpdateContent(); }
69
70   //! Sets open button for the TInspector window
71   void SetOpenButton (QPushButton* theButton) { myWindow->SetOpenButton (theButton); }
72
73   //! Opens file in TInspector window
74   void OpenFile (const TCollection_AsciiString& thePluginName, const TCollection_AsciiString& theFileName)
75   { myWindow->OpenFile (thePluginName, theFileName); }
76
77   //! Activates plugin
78   //! \param thePluginName a name of the plugin
79   void Activate (const TCollection_AsciiString& thePluginName) { myWindow->ActivateTool (thePluginName); }
80
81   //! Sets item selected in the active plugin
82   //! \param theItemName a containerr of name of items in plugin that should become selected
83   void SetSelected (const NCollection_List<TCollection_AsciiString>& theItemNames) { myWindow->SetSelected (theItemNames); }
84
85   //! Sets objects to be selected in the plugin
86   //! \param theObjects an objects
87   void SetSelected (const NCollection_List<Handle(Standard_Transient)>& theObjects) { myWindow->SetSelected (theObjects); }
88
89   //! Sets path to a directory for temporary plugin files
90   //! \param thePath a path
91   void SetTemporaryDirectory (const TCollection_AsciiString& thePath) { myWindow->SetTemporaryDirectory (thePath); }
92
93   //! Returns path to a directory for temporary plugin files
94   //! \return path
95   TCollection_AsciiString GetTemporaryDirectory() const { return myWindow->GetTemporaryDirectory(); }
96
97   //! Changes window visibility
98   //! \param theVisible boolean state
99   Standard_EXPORT virtual void SetVisible (const bool theVisible);
100
101   //! Changes window position
102   //! \param theX X pixel position of top left corner of the window
103   //! \param theY Y pixel position
104   Standard_EXPORT virtual void Move (const int theXPosition, const int theYPosition);
105
106   //! Puts in the stream information about communicator
107   //! \param theStream stream for output
108   void Dump (Standard_OStream& theStream) const { return myWindow->Dump (theStream); }
109
110   //! Returns plugins parameters container
111   Handle(TInspectorAPI_PluginParameters) const GetPluginParameters() { return myWindow->GetPluginParameters(); }
112
113 private:
114   TInspector_Window* myWindow; //!< current window
115 };
116
117 #endif