17 #include "base_view.h"
21 #include <GL/freeglut.h>
31 template<
typename Scalar>
32 BaseView<Scalar>::BaseView(
const char* title, WinGeom* wg)
33 : ScalarView((char*)title, wg), sln(MeshFunctionSharedPtr<Scalar>(new Solution<Scalar>())), complex_filter(MeshFunctionSharedPtr<double>())
35 this->show_edges =
true;
36 basic_title.assign(title);
39 template<
typename Scalar>
40 BaseView<Scalar>::BaseView(
char* title, WinGeom* wg)
41 : ScalarView(title, wg), sln(MeshFunctionSharedPtr<Scalar>(new Solution<Scalar>())), complex_filter(MeshFunctionSharedPtr<double>())
43 this->show_edges =
true;
44 basic_title.assign(title);
47 template<
typename Scalar>
48 void BaseView<Scalar>::show(SpaceSharedPtr<Scalar> space,
int item)
52 ndof = this->space->get_num_dofs();
59 template<
typename Scalar>
60 void BaseView<Scalar>::free()
65 void BaseView<double>::update_solution()
67 double* coeffs = malloc_with_check<double>(ndof);
68 memset(coeffs, 0,
sizeof(
double)* ndof);
71 if (base_index < ndof)
72 coeffs[base_index] = 1.0;
73 Solution<double>::vector_to_solution(coeffs, space, sln,
false);
77 Solution<double>::vector_to_solution(coeffs, space, sln,
true);
80 ScalarView::show(sln, item);
83 free_with_check(coeffs);
86 void BaseView<std::complex<double> >::update_solution()
88 std::complex<double>* coeffs = malloc_with_check<std::complex<double> >(ndof);
89 memset(coeffs, 0,
sizeof(std::complex<double>) * ndof);
92 if (base_index < ndof) coeffs[base_index] = 1.0;
93 Solution<std::complex<double> >::vector_to_solution(coeffs, space, sln,
false);
97 Solution<std::complex<double> >::vector_to_solution(coeffs, space, sln,
true);
101 ScalarView::show(complex_filter, item);
104 free_with_check(coeffs);
107 template<
typename Scalar>
108 void BaseView<Scalar>::update_title()
110 std::stringstream str;
111 str << basic_title <<
" - dof = " << base_index;
113 str <<
" (Dirichlet lift)";
114 View::set_title(str.str().c_str());
117 template<
typename Scalar>
118 void BaseView<Scalar>::on_special_key(
int key,
int x,
int y)
123 if (base_index > -1) base_index--;
128 if (base_index < ndof - 1) base_index++;
133 ScalarView::on_special_key(key, x, y);
137 template<
typename Scalar>
138 const char* BaseView<Scalar>::get_help_text()
const
143 " Left mouse - pan\n"
144 " Right mouse - zoom\n"
145 " Left arrow - previous basis function\n"
146 " Right arrow - next basis function\n"
147 " 3 - toggle 3D mode\n"
148 " C - center image\n"
149 " F - toggle smooth palette\n"
150 " H - render high-quality frame\n"
152 " P - cycle palettes\n"
153 " S - save screenshot\n"
157 " Left mouse - rotate\n"
158 " Right mouse - zoom\n"
159 " Middle mouse - pan\n"
160 " * - increase Z scale\n"
161 " / - decrease Z scale";
174 template class HERMES_API BaseView < double > ;
175 template class HERMES_API BaseView < std::complex<double> > ;
Common definitions for Hermes2D.
Removes the imaginary part from a function.