HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MOT_HelpManager.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: MOT_HelpManager.h ( BR Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __MOT_HelpManager__
12 #define __MOT_HelpManager__
13 
14 #include "MOT_API.h"
15 #include <UT/UT_HelpManager.h>
16 #include <UT/UT_StringArray.h>
17 #include <PY/PY_Result.h>
18 
20 class UT_Signal;
21 class OP_Node;
22 class PRM_Parm;
23 
25 {
26 public:
28  ~MOT_HelpManager() override;
29 
30  /// Opens the table of contenst help page.
31  virtual void openContents() override;
32 
33  /// Opens the special essential-skills page on startup.
34  virtual void openStartup() override;
35 
36  /// Opens a help page defined by the file.
37  virtual void openFile(const char *path) override;
38 
39  /// Opens a URL in the help browser (url can be of forms
40  /// "http://u.r.l", "hdox://u.r.l", "operator:table/name", "tool:name" etc)
41  virtual void openURL(const char *url) override;
42 
43  virtual void openHelpPath(const char *help_path) override;
44 
45  /// Displays the buffer data in help browser.
46  virtual void displayData(const char *data,
47  bool is_html) override;
48 
49  /// Open the requested tooltip in a popup window.
50  /// x,y,w,h represents the native screen position and size of the
51  /// source feel that the tooltip is for. If there is no source feel,
52  /// then pass in (0,0,0,0) for x,y,w,h.
53  /// {
54  void openTooltipWindow(
55  const char *text,
56  int x, int y, int w, int h) const override;
58  const char *url,
59  int x, int y, int w, int h) const override;
60  /// }
61 
62  /// Close all tooltip popup windows.
63  /// Do nothing if there are no open tooltip popup windows.
64  virtual void closeAllTooltipWindows() const override;
65 
66  /// Obtains a tool tip from the help page pointed to by the URL.
67  bool getTooltip(const char *url,
68  UT_String &tooltip) override;
69 
70  /// Obtains a tool tip for the specified parameter.
71  bool getTooltip(const PRM_Parm *parm,
72  UT_String &tooltip) override;
73 
74  /// Obtains a tool tip conained by the full help text. The url serves
75  /// as a caching key.
76  bool getParsedTooltip(const char *url_key,
77  const char *full_help,
78  UT_String &tooltip) override;
79 
80  /// Obtains a plain text version of the help page pointed to by the URL
81  /// (e.g. 'vex:attrib').
82  bool getTextHelp(const char *url,
83  UT_String &text_help) override;
84 
85  /// Return the text help for the given hscript command.
86  UT_StringHolder getCommandHelp(const char *command) override;
87 
88  /// Return the text help for the given hscript expression command.
89  UT_StringHolder getExprCommandHelp(const char *command) override;
90 
91  /// Return an array of hscript commands whose text help contain
92  /// a match for the given keyword.
93  UT_StringArray getCommandsForHelpKeyword(const char *keyword) override;
94 
95  /// Return an array of hscript expression commands whose text help
96  /// conotain a match for the given keyword.
97  UT_StringArray getExprCommandsForHelpKeyword(const char *keyword) override;
98 
99  // Convenience functions for opening the help cards for operators,
100  // nodes, shelf tools, states, etc.
101  virtual void openHelpCard(OP_Node *node) override;
102  virtual void openHelpCard(
103  OP_Operator *op,
104  const char *node_path=nullptr) override;
105  virtual void openHelpCard(BM_State *state) override;
106  virtual void openHelpCard(SHLF_Tool *tool) override;
107  virtual void openHelpCard(
108  const PYP_Interface *interface) override;
109  virtual void openHelpCard(OP_GalleryEntry *entry)
110  override;
111  virtual void openHelpCard(
112  const PRM_ScriptParm *prop) override;
113 
114  // Obtains a URL that points to the help server web page for the given
115  // operator, state, tool, or topic id.
116  void getHelpCardURL(OP_Operator *op,
117  UT_String &str) override;
118  void getHelpCardURL(BM_State *state,
119  UT_String &url) override;
120  void getHelpCardURL(SHLF_Tool *tool,
121  UT_String &url) override;
122  void getHelpCardURL(const PYP_Interface *interface,
123  UT_String &url) override;
124  void getHelpCardURL(OP_GalleryEntry *entry,
125  UT_String &url) override;
126  void getHelpCardURL(const PRM_ScriptParm *prop,
127  UT_String &url) override;
128  void getHelpCardURL(const char *helpTopicId,
129  UT_String &url) override;
130  void getHelpCardURL(const PRM_Parm* parm,
131  UT_String &help_path) override;
132 
133  /// Sets the base URI that is used to disambiguate the relative URLs.
134  void setBaseURI(const char *base_uri) override;
135 
136  /// Returns the baseURI.
137  const UT_String &getBaseURI() const override
138  { return myBaseURI; }
139 
140  /// Returns true if the help manager is using an external help server.
141  /// Returns false otherwise.
142  bool getUseExternalHelp() const override
143  { return myUseExternalHelp; }
144 
145  /// Sets whether the help manager should use an external help server or not.
146  void setUseExternalHelp(bool use_external) override;
147 
148  /// Sets the address the help server should bind to.
149  void setHelpAddress(const char* help_address) override;
150  const UT_StringHolder &getHelpAddress() const override
151  { return myHelpAddress; }
152 
153  /// Sets if the help server can use ipv6
154  void setUseIPv6(bool use_ipv6) override;
155  bool getUseIPv6() const override
156  { return myUseIPv6; }
157 
158  /// Returns the base url for the external help server.
159  /// Returns "" if no external help server is used.
160  const UT_String &getExternalHelpURL() const override
161  { return myExternalHelpURL; };
162 
163  /// Sets the url to the external help server.
164  void setExternalHelpURL(
165  const char *ext_help_url) override;
166 
167  /// Returns the base URL for all of Houdini's help.
168  const UT_String &getHelpBaseURL() override;
169 
170  /// Returns the url for the help startup page.
171  const UT_String &getStartupURL() override;
172 
173  /// Closes the help pane.
174  virtual void closeFloatingPane() override;
175 
176 protected:
177  /// Helper function for getTooltip(const char *, UT_String&).
178  /// Attempts to extract an operator, gallery entry or parameter
179  /// tooltip from the given url.
180  virtual bool extractTooltip(const char *url,
181  UT_String &tooltip);
182 
183  /// Updates all opened web browsers with the current
184  /// help base URL.
185  virtual void updateBaseURLInHelpBrowsersSubclass();
186 
187  /// Count help cards opening times for FS_datalogger.
188  void countHelpCardPress(const char *message);
189 
190  /// Checks whether the help server has the help page under the given URL.
191  bool getServerHasHelp(const char *url);
192 
193  UT_StringArray &getURLStack() { return myURLStack; }
194 
195  /// Prefixes `help_path` with the help server's base url and
196  /// passes back the final url in `url`.
197  void prefixWithHelpBaseURL(const char *help_path,
198  UT_String &url);
199 
200  /// Parses URL and tries to obtain the entity.
201  OP_Operator *getOpFromURL(const char *url);
202  OP_GalleryEntry *getGalleryEntryFromURL(const char *url);
203  const PRM_ScriptParm *getPropFromURL(const char *url);
204 
205  /// Resolve specified help path by expanding variables and translating
206  /// help protocols to help paths.
207  void resolveHelpPath(
208  const char *help_path,
209  UT_String &resolved_path);
210 
211 private:
212 
213  /// Parses the wiki text into an html text.
214  /// NB: the url is needed for caching key by the help server.
215  virtual void parseWikiToHtml(const char *url_key,
216  const char *wiki_help,
217  UT_String & html_help);
218 
219  /// Helper methods to obtain tool tip from the operator or tool.
220  bool getTooltip(OP_Operator *op,
221  UT_String &tooltip);
222  bool getTooltip(OP_GalleryEntry *entry,
223  UT_String &tooltip);
224  bool getTooltip(const PRM_ScriptParm *prop,
225  UT_String &tooltip);
226 
227  /// Helper for running python code (eg evaluating expression and obtaining
228  /// the result of that expression) within the help python context.
229  /// Returns true evaluation went ok, or false if error occured or the
230  /// returned value type does not match the desired type.
231  // NB: the expression can be only a single python statement; no multiline
232  // scripts are allowed (for now at least).
233  bool runPythonExpr(const char *expr,
234  PY_Result::Type desired_result_type,
235  PY_Result &py_result,
236  PY_EvaluationContext *context=nullptr);
237  bool evalPythonExpr(const char *expr,
238  UT_String &result);
239  bool evalPythonExpr(const char *expr,
241  bool evalPythonExpr(const char *expr, int &result);
242  bool evalPythonExpr(const char *expr,
244 
245  /// Initialize the help server using the houdinihelp Python module.
246  bool initializeHelpServer();
247 
248  /// Initialize the help server if we haven't already tried to / do so, and
249  //return whether or not it could be initialized.
250  bool canAccessHelpServer();
251 
252  /// Returns the listen port of the help server.
253  /// Starts the help server if necessary.
254  int getHelpServerPort();
255 
256  bool myCouldInitializeHelpServer;
257  UT_StringArray myURLStack; // followed url links
258  UT_String myBaseURI; // base URI for relative
259  bool myUseExternalHelp;
260  UT_String myExternalHelpURL;
261  UT_String myHelpBaseURL; // html links
262  UT_String myStartupHelpURL;
263 
264  UT_StringHolder myHelpAddress;
265  bool myUseIPv6;
266 
267  /// The help server's listen port number.
268  static int theHelpServerPort;
269 
270  /// The help server's broken pipe signal handler.
271  static UT_Signal *theHelpServerSigHandler;
272 };
273 
274 #endif
275 
276 
virtual void openFile(const char *path)=0
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2543
virtual void setHelpAddress(const char *address)=0
Sets the address the server should bind to.
virtual void setBaseURI(const char *base_uri)=0
virtual bool getTextHelp(const char *url, UT_String &text_help)=0
virtual bool getTooltip(const char *url, UT_String &tooltip)=0
Obtains a tool tip from the help page pointed to by the URL.
const UT_StringHolder & getHelpAddress() const override
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
GLint y
Definition: glcorearb.h:103
virtual void setUseExternalHelp(bool use_external)=0
virtual UT_StringArray getExprCommandsForHelpKeyword(const char *keyword)=0
**But if you need a result
Definition: thread.h:622
virtual void openHelpPath(const char *help_path)=0
virtual void openTooltipURLWindow(const char *url, int x, int y, int w, int h) const =0
UT_StringArray & getURLStack()
#define MOT_API
Definition: MOT_API.h:10
virtual const UT_String & getStartupURL()=0
virtual UT_StringArray getCommandsForHelpKeyword(const char *keyword)=0
virtual bool getParsedTooltip(const char *url_key, const char *full_help, UT_String &tooltip)=0
GLint GLenum GLint x
Definition: glcorearb.h:409
virtual void getHelpCardURL(OP_Operator *op, UT_String &str)=0
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
virtual void displayData(const char *data, bool is_html)=0
virtual void openHelpCard(OP_Node *node)=0
virtual const UT_String & getHelpBaseURL()=0
virtual void openStartup()=0
virtual void closeFloatingPane()=0
bool getUseExternalHelp() const override
virtual void openContents()=0
virtual void openTooltipWindow(const char *text, int x, int y, int w, int h) const =0
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
virtual void setUseIPv6(bool use_ipv6)=0
Whether the help server should use ipv6 or not.
const UT_String & getExternalHelpURL() const override
const UT_String & getBaseURI() const override
Returns the baseURI.
virtual UT_StringHolder getExprCommandHelp(const char *command)=0
Return the text help for the given hscript expression command.
bool getUseIPv6() const override
state
Definition: core.h:2289
virtual void openURL(const char *url)=0
Definition: format.h:1821
virtual UT_StringHolder getCommandHelp(const char *command)=0
Return the text help for the given hscript command.
virtual void closeAllTooltipWindows() const =0
}
virtual void setExternalHelpURL(const char *ext_help_url)=0