Hermes2D  2.0
base_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_BASE_VIEW_H
23 #define __H2D_BASE_VIEW_H
24 
25 #include "../global.h"
26 #include "scalar_view.h"
27 #include "../space/space.h"
28 #include "../shapeset/precalc.h"
29 
30 namespace Hermes
31 {
32  namespace Hermes2D
33  {
34  namespace Views
35  {
36  // you can define NOGLUT to turn off all OpenGL stuff in Hermes2D
37 #ifndef NOGLUT
38 
44  template<typename Scalar>
45  class HERMES_API BaseView : public ScalarView
46  {
47  public:
48 
49  BaseView(const char* title = "BaseView", WinGeom* wg = NULL);
50  BaseView(char* title, WinGeom* wg = NULL);
51 
52  void show(const Space<Scalar>* space, double eps = HERMES_EPS_LOW, int item = H2D_FN_VAL_0);
53 
54  ~BaseView() { free(); }
55 
56  protected:
57 
58  const Space<Scalar>* space;
59  PrecalcShapeset* pss;
60  Solution<Scalar>* sln;
61 
62  double eps;
63  int ndof, item;
64  int base_index;
65 
66  std::string basic_title;
67 
68  void free();
69  void update_solution();
70  void update_title();
71 
72  virtual void on_special_key(int key, int x, int y);
73  virtual const char* get_help_text() const;
74  };
75 #else
76  template<typename Scalar>
77  class HERMES_API BaseView : public ScalarView
78  {
79  public:
80  BaseView(const char* title = "BaseView", WinGeom* wg = NULL) { throw Hermes::Exceptions::Exception("GLUT disabled."); }
81  BaseView(char* title, WinGeom* wg = NULL) { throw Hermes::Exceptions::Exception("GLUT disabled."); }
82 
83  void show(const Space<Scalar>* space, double eps = HERMES_EPS_LOW, int item = H2D_FN_VAL_0) { throw Hermes::Exceptions::Exception("GLUT disabled."); }
84  };
85 
86 #endif
87  }
88  }
89 }
90 #endif