vtkPVOptions.h 9.46 KB
Newer Older
1
/*=========================================================================
2

3 4 5 6 7 8 9 10 11 12 13 14
  Program:   ParaView
  Module:    vtkPVOptions.h

  Copyright (c) Kitware, Inc.
  All rights reserved.
  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
15 16 17 18 19 20 21 22 23
/**
 * @class   vtkPVOptions
 * @brief   ParaView options storage
 *
 * An object of this class represents a storage for ParaView options
 *
 * These options can be retrieved during run-time, set using configuration file
 * or using Command Line Arguments.
*/
24

25 26
#ifndef vtkPVOptions_h
#define vtkPVOptions_h
27

28
#include "vtkCommandOptions.h"
29
#include "vtkPVClientServerCoreCoreModule.h" //needed for exports
30

31
#include <string>  // used for ivar
32 33 34
#include <utility> // needed for pair
#include <vector>  // needed for vector

35 36
class vtkPVOptionsInternal;

37
class VTKPVCLIENTSERVERCORECORE_EXPORT vtkPVOptions : public vtkCommandOptions
38
{
39 40
protected:
  friend class vtkPVOptionsXMLParser;
41

42
public:
43
  static vtkPVOptions* New();
44
  vtkTypeMacro(vtkPVOptions, vtkCommandOptions);
45
  void PrintSelf(ostream& os, vtkIndent indent) override;
46

47 48 49 50
  //@{
  /**
   * Convenience method to get the local process's host name.
   */
51
  vtkGetStringMacro(HostName);
52
  //@}
53

54 55
  vtkGetMacro(ConnectID, int);
  vtkGetMacro(UseStereoRendering, int);
56
  vtkGetStringMacro(StereoType);
57

58 59 60
  vtkGetMacro(ReverseConnection, int);
  vtkGetMacro(UseRenderingGroup, int);
  vtkGetVector2Macro(TileDimensions, int);
61
  vtkGetVector2Macro(TileMullions, int);
62

63 64 65 66 67
  /**
   * Returns the egl device index. -1 indicates that no value was specified.
   */
  vtkGetMacro(EGLDeviceIndex, int);

68 69 70 71 72 73
  //@{
  /**
   * This is the argument specified by --data on the command line. Additionally,
   * this can also correspond to the last argument specified on the command
   * line if the argument is unknown.
   */
74
  vtkGetStringMacro(ParaViewDataName);
75
  //@}
76

77 78 79 80 81
  //@{
  /**
   * Servers file to load on startup.
   */
  vtkGetStringMacro(ServersFileName);
82
  //@}
83 84 85 86 87 88 89

  //@{
  /**
   * Valid on PVSERVER and PVDATA_SERVER only. It denotes the time (in minutes)
   * since the time that the connection was established with the server that the
   * server may timeout. timeout <= 0 means no timeout.
   */
90
  vtkGetMacro(Timeout, int);
91
  //@}
92

93 94 95 96 97
  //@{
  /**
   * Clients need to set the ConnectID so they can handle server connections
   * after the client has started.
   */
98
  vtkSetMacro(ConnectID, int);
99
  //@}
100

101 102 103 104
  //@{
  /**
   * Log filename.
   */
105 106
  vtkSetStringMacro(LogFileName);
  vtkGetStringMacro(LogFileName);
107
  //@}
108

109 110 111 112
  //@{
  /**
   * vtkPVProcessModule needs to set this.
   */
113
  vtkSetVector2Macro(TileDimensions, int);
114
  vtkSetVector2Macro(TileMullions, int);
115
  vtkSetMacro(UseOffscreenRendering, int);
116
  //@}
117

118 119 120 121 122
  /**
   * Is this server was started for collaboration meaning that it allow
   * several clients to connect to the same server and share the same
   * pipeline and visualization.
   */
123
  virtual int GetMultiClientMode()
124 125 126
  {
    return (this->MultiClientMode || this->MultiClientModeWithErrorMacro) ? 1 : 0;
  }
127
  virtual int IsMultiClientModeDebug() { return this->MultiClientModeWithErrorMacro; }
128

129 130 131 132 133 134 135
  //@{
  /**
   * Returns if this server does not allow connection after the first client.
   */
  vtkGetMacro(DisableFurtherConnections, int);
  //@}

136 137 138 139
  //@{
  /**
   * Is this client allow multiple server connection in parallel
   */
140
  vtkGetMacro(MultiServerMode, int);
141 142 143 144 145 146 147 148 149 150
  //@}

  //@{
  /**
   * Indicates if the application is in symmetric mpi mode.
   * This is applicable only to PVBATCH type of processes.
   * Typically, when set to true, the python script is run on satellites as
   * well, otherwise only the root node processes the python script. Disabled by
   * default.
   */
151 152
  vtkGetMacro(SymmetricMPIMode, int);
  vtkSetMacro(SymmetricMPIMode, int);
153
  //@}
154

155 156 157 158
  //@{
  /**
   * Should this run print the version numbers and exit.
   */
159
  vtkGetMacro(TellVersion, int);
160
  //@}
161

162 163 164
  /// Provides access to server-url if specified on the command line.
  vtkGetStringMacro(ServerURL);

165 166 167 168
  /// Provides access to the Catalyst Live port if specified on the command line.
  /// A value of -1 indicates that no value was set.
  vtkGetMacro(CatalystLivePort, int);

169 170 171 172
  //@{
  /**
   * This is used when user want to open a file at startup
   */
173
  vtkSetStringMacro(ParaViewDataName);
174
  //@}
175

176 177 178 179 180
  //@{
  /**
   * Until streaming becomes mainstream, we enable streaming support by passing
   * a command line argument to all processes.
   */
181
  vtkGetMacro(EnableStreaming, int);
182
  //@}
183

184 185 186 187
  //@{
  /**
   * Include originating process id text into server to client messages.
   */
188
  vtkSetMacro(SatelliteMessageIds, int);
189
  vtkGetMacro(SatelliteMessageIds, int);
190
  //@}
191

192 193 194 195
  //@{
  /**
   * Should this process just print monitor information and exit?
   */
196
  vtkGetMacro(PrintMonitors, int);
197
  //@}
198

199 200 201 202
  //@{
  /**
   * Adding ability to test plugins by loading them at command line
   */
203 204
  vtkGetStringMacro(TestPlugin);
  vtkGetStringMacro(TestPluginPath);
205
  //@}
206

207 208 209 210 211
  //@{
  /**
   * Flag for controlling auto generation of stack trace on POSIX
   * systems after crash.
   */
212 213
  vtkGetMacro(EnableStackTrace, int);
  vtkSetMacro(EnableStackTrace, int);
214
  //@}
215

216 217 218 219 220
  //@{
  /**
   * Flag for disabling loading of options and settings stored by the
   * application. Often used for testing.
   */
221
  vtkGetMacro(DisableRegistry, int);
222 223 224 225 226 227 228 229 230 231
  //@}

  //@{
  /**
   * XDisplay test on server processes during initialization sometimes happens
   * too early and may result in remote rendering prematurely disabled. When
   * this flag is set, ParaView will skip such X-display tests. Note, if the
   * display is truly inaccessible when ParaView tries to connect to the server,
   * we will indeed get runtimes errors, including segfaults.
   */
232
  vtkGetMacro(DisableXDisplayTests, int);
233
  //@}
234

235 236 237 238 239 240 241 242 243 244 245
  /**
   * When set to true, ParaView will create headless only render windows on the
   * current process.
   */
  vtkGetMacro(ForceOffscreenRendering, int);

  /**
   * When set to true, ParaView will create on-screen render windows.
   */
  vtkGetMacro(ForceOnscreenRendering, int);

246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
  //@{
  /**
   * Get/Set the ForceNoMPIInitOnClient flag.
   */
  vtkGetMacro(ForceNoMPIInitOnClient, int);
  vtkSetMacro(ForceNoMPIInitOnClient, int);
  vtkBooleanMacro(ForceNoMPIInitOnClient, int);
  //@}

  //@{
  /**
   * Get/Set the ForceMPIInitOnClient flag.
   */
  vtkGetMacro(ForceMPIInitOnClient, int);
  vtkSetMacro(ForceMPIInitOnClient, int);
  vtkBooleanMacro(ForceMPIInitOnClient, int);
  //@}

264 265 266 267 268 269 270 271
  //@{
  /**
   * Returns the verbosity level for stderr output chosen.
   * Is set to vtkLogger::VERBOSITY_INVALID if not specified.
   */
  vtkGetMacro(LogStdErrVerbosity, int);
  //@}

272
  enum ProcessTypeEnum
273
  {
274 275 276 277 278 279
    PARAVIEW = 0x2,
    PVCLIENT = 0x4,
    PVSERVER = 0x8,
    PVRENDER_SERVER = 0x10,
    PVDATA_SERVER = 0x20,
    PVBATCH = 0x40,
280 281
    ALLPROCESS = PARAVIEW | PVCLIENT | PVSERVER | PVRENDER_SERVER | PVDATA_SERVER | PVBATCH
  };
282

283
protected:
284 285 286
  /**
   * Default constructor.
   */
287 288
  vtkPVOptions();

289 290 291
  /**
   * Destructor.
   */
292
  ~vtkPVOptions() override;
293

294 295 296
  /**
   * Initialize arguments.
   */
297
  void Initialize() override;
298

299 300 301
  /**
   * After parsing, process extra option dependencies.
   */
302
  int PostProcess(int argc, const char* const* argv) override;
303

304 305 306 307
  /**
   * This method is called when wrong argument is found. If it returns 0, then
   * the parsing will fail.
   */
308
  int WrongArgument(const char* argument) override;
309

310 311 312 313
  /**
   * This method is called when a deprecated argument is found. If it returns 0, then
   * the parsing will fail.
   */
314
  int DeprecatedArgument(const char* argument) override;
315

316 317 318 319
  //@{
  /**
   * Subclasses may need to access these
   */
320
  char* ParaViewDataName;
321
  char* ServerURL; // server URL information
322
  int ServerMode;
323
  int ClientMode;
324
  int RenderServerMode;
325
  int MultiClientMode;
326
  int DisableFurtherConnections;
327
  int MultiClientModeWithErrorMacro;
328
  int MultiServerMode;
329
  int SymmetricMPIMode;
330
  char* ServersFileName;
331
  char* TestPlugin; // to load plugins from command line for tests
332
  char* TestPluginPath;
333
  int DisableXDisplayTests;
334 335
  int
    CatalystLivePort; // currently only set through the GUI but may eventually be set in any client
336
  //@}
337

338 339
  // inline setters
  vtkSetStringMacro(ServerURL);
340
  vtkSetStringMacro(ServersFileName);
341 342
  vtkSetStringMacro(TestPlugin);
  vtkSetStringMacro(TestPluginPath);
343

344
private:
345 346
  int ConnectID;
  int UseOffscreenRendering;
347
  int EGLDeviceIndex;
348 349 350
  int UseStereoRendering;
  int ReverseConnection;
  int TileDimensions[2];
351
  int TileMullions[2];
352
  int UseRenderingGroup;
353
  int Timeout;
354
  char* LogFileName;
355
  int TellVersion;
356
  char* StereoType;
357
  int EnableStreaming;
358
  int SatelliteMessageIds;
359
  int PrintMonitors;
360
  int EnableStackTrace;
361
  int DisableRegistry;
362 363
  int ForceMPIInitOnClient;
  int ForceNoMPIInitOnClient;
364
  int DummyMesaFlag;
365 366
  int ForceOffscreenRendering;
  int ForceOnscreenRendering;
367 368 369

  // inline setters
  vtkSetStringMacro(StereoType);
370

371
private:
372 373
  vtkPVOptions(const vtkPVOptions&) = delete;
  void operator=(const vtkPVOptions&) = delete;
374 375

  vtkSetStringMacro(HostName);
376
  char* HostName;
377 378 379 380 381 382
  int LogStdErrVerbosity;

  std::vector<std::pair<std::string, int> > LogFiles;

  static int VerbosityArgumentHandler(const char* argument, const char* value, void* call_data);
  static int LogArgumentHandler(const char* argument, const char* value, void* call_data);
383 384
};

385
#endif