24 #include <GL/freeglut.h>
26 #include "vector_base_view.h"
37 template<
typename Scalar>
38 void VectorBaseView<Scalar>::show(Space<Scalar>* space)
41 pss =
new PrecalcShapeset(space->shapeset);
42 sln =
new Solution<Scalar>();
44 ndof = space->get_num_dofs();
49 template<
typename Scalar>
50 VectorBaseView<Scalar>::VectorBaseView(
const char* title, WinGeom* wg)
51 : VectorView(title, wg) { pss = NULL; sln = NULL; this->lines =
false; basic_title.assign(title); }
53 template<
typename Scalar>
54 VectorBaseView<Scalar>::VectorBaseView(
char* title, WinGeom* wg)
55 : VectorView(title, wg) { pss = NULL; sln = NULL; this->lines =
false; basic_title.assign(title); }
57 template<
typename Scalar>
58 void VectorBaseView<Scalar>::set_title(
const char* t) {
59 if(basic_title.length() == 0)
60 basic_title.assign(t);
64 template<
typename Scalar>
65 VectorBaseView<Scalar>::~VectorBaseView()
70 template<
typename Scalar>
71 void VectorBaseView<Scalar>::free()
73 if(pss != NULL) {
delete pss; pss = NULL; }
74 if(sln != NULL) {
delete sln; sln = NULL; }
78 void VectorBaseView<double>::update_solution()
80 double* coeffs =
new double[ndof + 1];
81 memset(coeffs, 0,
sizeof(
double) * (ndof + 1));
82 if(base_index >= -1 && base_index < ndof)
83 coeffs[base_index + 1] = 1.0;
84 Solution<double>::vector_to_solution(coeffs, space, sln, pss);
86 VectorView::show(sln, sln, 0.001, H2D_FN_VAL_0, H2D_FN_VAL_1);
92 void VectorBaseView<std::complex<double> >::update_solution()
94 std::complex<double> * coeffs =
new std::complex<double>[ndof + 1];
95 memset(coeffs, 0,
sizeof(std::complex<double> ) * (ndof + 1));
96 if(base_index >= -1 && base_index < ndof)
97 coeffs[base_index + 1] = 1.0;
98 Solution<std::complex<double> >::vector_to_solution(coeffs, space, sln, pss);
102 this->VectorView::show(&filter, &filter, 0.001, H2D_FN_VAL_0, H2D_FN_VAL_1);
108 template<
typename Scalar>
109 void VectorBaseView<Scalar>::update_title()
111 std::stringstream str;
112 str << basic_title <<
" - dof = " << base_index;
114 str <<
" (Dirichlet lift)";
115 View::set_title(str.str().c_str());
118 template<
typename Scalar>
119 void VectorBaseView<Scalar>::on_special_key(
int key,
int x,
int y)
124 if(base_index > -1) base_index--;
129 if(base_index < ndof-1) base_index++;
134 VectorView::on_special_key(key, x, y);
138 template<
typename Scalar>
139 const char* VectorBaseView<Scalar>::get_help_text()
const
144 " Left mouse - pan\n"
145 " Right mouse - zoom\n"
146 " Left arrow - previous basis function\n"
147 " Right arrow - next basis function\n"
148 " C - center image\n"
149 " F - toggle smooth palette\n"
150 " X - toggle hexagonal grid\n"
151 " H - render high-quality frame\n"
153 " P - cycle palettes\n"
154 " S - save screenshot\n"
159 template class HERMES_API VectorBaseView<double>;
160 template class HERMES_API VectorBaseView<std::complex<double> >;