Skip to content
Snippets Groups Projects
Plugin.h 3.92 KiB
Newer Older
Christophe Geuzaine's avatar
Christophe Geuzaine committed
// Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle
Christophe Geuzaine's avatar
Christophe Geuzaine committed
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.

Jean-François Remacle's avatar
Jean-François Remacle committed
#ifndef _PLUGIN_H_
#define _PLUGIN_H_
Christophe Geuzaine's avatar
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
// To create a plugin:
// 1) Create a dynamic lib containing GMSH_RegisterPlugin();
// 2) When there is an unacceptable error in the plugin, just throw
//    this, the plugin manager will be able to catch the exception.
//  Some Plugins are default gmsh plugins and are insterted directly
//  in the executable. I think that it's a good way to start.
Christophe Geuzaine's avatar
Christophe Geuzaine committed

#include <string.h>
#include <stdio.h>
#include "Options.h"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#include "PView.h"
#include "PViewDataList.h"
#include "GmshMatrix.h"
class PluginDialogBox;
class Vertex;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Jean-François Remacle's avatar
Jean-François Remacle committed
class GMSH_Plugin
{
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
 public :
  // 4 kinds of plugins
  typedef enum {
    GMSH_CAD_PLUGIN, 
    GMSH_MESH_PLUGIN, 
    GMSH_POST_PLUGIN, 
Christophe Geuzaine's avatar
Christophe Geuzaine committed
    GMSH_SOLVER_PLUGIN 
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  } GMSH_PLUGIN_TYPE;

  // a dialog box for the user interface
  PluginDialogBox *dialogBox;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // for internal use by PluginManager
Jean-François Remacle's avatar
Jean-François Remacle committed
  void *hlib;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  GMSH_Plugin() : dialogBox(0), hlib(0) {}
  virtual ~GMSH_Plugin(){}

  // return plugin type, name and info
Jean-François Remacle's avatar
Jean-François Remacle committed
  virtual GMSH_PLUGIN_TYPE getType() const = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual void getName(char *name) const = 0;
  virtual void getInfos(char *author, char *copyright, char *helpText) const = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // when an error is thrown by the plugin, the plugin manager will
  // show the message and hopefully continue
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual void catchErrorMessage(char *errorMessage) const = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // gmsh-style numeric options
  virtual int getNbOptions() const = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual StringXNumber *getOption(int iopt) = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // gmsh-style string options
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual int getNbOptionsStr() const = 0;
  virtual StringXString *getOptionStr(int iopt) = 0;

  // run the plugin
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual void run() = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
// The base class for post-processing plugins. The user can either
// modify or duplicate a post-processing view
Christophe Geuzaine's avatar
Christophe Geuzaine committed
class GMSH_PostPlugin : public GMSH_Plugin
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
 public:
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  inline GMSH_PLUGIN_TYPE getType() const { return GMSH_Plugin::GMSH_POST_PLUGIN; }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual int getNbOptionsStr() const { return 0; }
  virtual StringXString *getOptionStr(int iopt) { return NULL; }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual void run(){ execute(0); }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // if the returned pointer is the same as the argument, then the
  // view is simply modified, else, a new view is added in the view
  // list
  virtual PView *execute(PView *) = 0;
  // get the view given an index and a default value
  virtual PView *getView(int index, PView *view);
  // get the data in list format
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  virtual PViewDataList *getDataList(PView *view, bool showError=true);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual void assignSpecificVisibility() const {}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual bool geometricalFilter(gmshMatrix<double> *) const { return true; }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
};
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
// The base class for solver plugins. The idea is to be able to
// associate some properties to physical entities, so that we can
// interface gmsh with a solver (ABAQUS...), i.e., create the input
// file for the solver
Christophe Geuzaine's avatar
Christophe Geuzaine committed
class GMSH_SolverPlugin : public GMSH_Plugin
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
 public:
  virtual int getNbOptionsStr() const { return 0; }
  virtual StringXString *getOptionStr(int iopt) { return 0; }
  virtual int getNbOptions() const { return 0; }
  virtual StringXNumber *getOption(int iopt) { return 0; };
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  inline GMSH_PLUGIN_TYPE getType() const { return GMSH_Plugin::GMSH_SOLVER_PLUGIN; }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual void run() {} // do nothing
  // popup dialog box
  virtual void popupPropertiesForPhysicalEntity(int dim) = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // add the given group to the solver data
  virtual void receiveNewPhysicalGroup(int dim, int id) = 0;
  // load the solver input file related to the gmsh geo file
  virtual void readSolverFile(const char *) = 0;
  // save the solver file  
  virtual void writeSolverFile(const char *) const = 0;
  // enhance graphics for a giver geo point
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual bool GL_enhancePoint(Vertex *v) { return false; }
  // enhance graphics for a giver geo line
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  virtual bool GL_enhanceLine(int CurveId, Vertex *v1, Vertex *v2) { return false; }
Jean-François Remacle's avatar
Jean-François Remacle committed
#endif