Hermes2D  2.0
vector_view.h
1 // This file is part of Hermes2D.
2 //
3 // Copyright 2005-2008 Jakub Cerveny <jakub.cerveny@gmail.com>
4 // Copyright 2005-2008 Lenka Dubcova <dubcova@gmail.com>
5 // Copyright 2005-2008 Pavel Solin <solin@unr.edu>
6 //
7 // Hermes2D is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // Hermes2D is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with Hermes2D. If not, see <http://www.gnu.org/licenses/>.
19 
20 // $Id: view.h 1086 2008-10-21 09:05:44Z jakub $
21 
22 #ifndef __H2D_VECTOR_VIEW_H
23 #define __H2D_VECTOR_VIEW_H
24 #include "view.h"
25 namespace Hermes
26 {
27  namespace Hermes2D
28  {
29  namespace Views
30  {
31  // you can define NOGLUT to turn off all OpenGL stuff in Hermes2D
32 #ifndef NOGLUT
33 
38  class HERMES_API VectorView : public View
39  {
40  public:
41 
42  VectorView(const char* title = "VectorView", WinGeom* wg = NULL);
43  VectorView(char* title, WinGeom* wg = NULL);
44  ~VectorView();
45 
46  void show(MeshFunction<double>* vsln, double eps = HERMES_EPS_NORMAL);
47  void show(MeshFunction<double>* xsln, MeshFunction<double>* ysln, double eps = HERMES_EPS_NORMAL);
48  void show(MeshFunction<double>* xsln, MeshFunction<double>* ysln, double eps, int xitem, int yitem);
49 
50  inline void set_grid_type(bool hexa) { this->hexa = hexa; refresh(); };
51  void set_mode(int mode);
52 
54  Vectorizer* get_vectorizer();
55 
56  protected:
59 
60  double gx, gy, gs;
61  bool hexa;
62  int mode;
63  bool lines, pmode;
64  double length_coef;
65 
66  void plot_arrow(double x, double y, double xval, double yval, double max, double min, double gs);
67 
68  virtual void on_display();
69  virtual void on_mouse_move(int x, int y);
70  virtual void on_key_down(unsigned char key, int x, int y);
71  virtual const char* get_help_text() const;
72  };
73 #else
74  class HERMES_API VectorView : public View
75  {
76  public:
77  VectorView(const char* title = "VectorView", WinGeom* wg = NULL) { throw Hermes::Exceptions::Exception("GLUT disabled."); }
78  VectorView(char* title, WinGeom* wg = NULL) { throw Hermes::Exceptions::Exception("GLUT disabled."); }
79 
80  void show(MeshFunction<double>* vsln, double eps = HERMES_EPS_NORMAL) { throw Hermes::Exceptions::Exception("GLUT disabled."); }
81  void show(MeshFunction<double>* xsln, MeshFunction<double>* ysln, double eps = HERMES_EPS_NORMAL) { throw Hermes::Exceptions::Exception("GLUT disabled."); }
82  void show(MeshFunction<double>* xsln, MeshFunction<double>* ysln, double eps, int xitem, int yitem) { throw Hermes::Exceptions::Exception("GLUT disabled."); }
83 
84  inline void set_grid_type(bool hexa) { throw Hermes::Exceptions::Exception("GLUT disabled."); }
85  };
86 #endif
87  }
88  }
89 }
90 #endif