20 #include <GL/freeglut.h>
22 #include "base_view.h"
31 template<
typename Scalar>
32 BaseView<Scalar>::BaseView(
const char* title, WinGeom* wg)
33 : ScalarView((char*) title, wg)
38 this->show_edges =
true;
39 basic_title.assign(title);
42 template<
typename Scalar>
43 BaseView<Scalar>::BaseView(
char* title, WinGeom* wg)
44 : ScalarView(title, wg)
49 this->show_edges =
true;
50 basic_title.assign(title);
53 template<
typename Scalar>
54 void BaseView<Scalar>::show(
const Space<Scalar>* space,
double eps,
int item)
58 pss =
new PrecalcShapeset(space->shapeset);
59 sln =
new Solution<Scalar>();
60 ndof = this->space->get_num_dofs();
67 template<
typename Scalar>
68 void BaseView<Scalar>::free()
70 if(pss != NULL) {
delete pss; pss = NULL; }
71 if(sln != NULL) {
delete sln; sln = NULL; }
75 void BaseView<double>::update_solution()
77 double* coeffs =
new double[ndof];
78 memset(coeffs, 0,
sizeof(
double) * ndof);
81 if(base_index < ndof) coeffs[base_index] = 1.0;
82 Solution<double>::vector_to_solution(coeffs, space, sln, pss,
false);
86 Solution<double>::vector_to_solution(coeffs, space, sln, pss,
true);
89 ScalarView::show(sln, eps, item);
95 void BaseView<std::complex<double> >::update_solution()
97 std::complex<double>* coeffs =
new std::complex<double>[ndof];
98 memset(coeffs, 0,
sizeof(std::complex<double>) * ndof);
101 if(base_index < ndof) coeffs[base_index] = 1.0;
102 Solution<std::complex<double> >::vector_to_solution(coeffs, space, sln, pss,
false);
106 Solution<std::complex<double> >::vector_to_solution(coeffs, space, sln, pss,
true);
111 ScalarView::show(&filter, eps, item);
117 template<
typename Scalar>
118 void BaseView<Scalar>::update_title()
120 std::stringstream str;
121 str << basic_title <<
" - dof = " << base_index;
123 str <<
" (Dirichlet lift)";
124 View::set_title(str.str().c_str());
127 template<
typename Scalar>
128 void BaseView<Scalar>::on_special_key(
int key,
int x,
int y)
133 if(base_index > -1) base_index--;
138 if(base_index < ndof-1) base_index++;
143 ScalarView::on_special_key(key, x, y);
147 template<
typename Scalar>
148 const char* BaseView<Scalar>::get_help_text()
const
153 " Left mouse - pan\n"
154 " Right mouse - zoom\n"
155 " Left arrow - previous basis function\n"
156 " Right arrow - next basis function\n"
157 " 3 - toggle 3D mode\n"
158 " C - center image\n"
159 " F - toggle smooth palette\n"
160 " H - render high-quality frame\n"
162 " P - cycle palettes\n"
163 " S - save screenshot\n"
167 " Left mouse - rotate\n"
168 " Right mouse - zoom\n"
169 " Middle mouse - pan\n"
170 " * - increase Z scale\n"
171 " / - decrease Z scale";
174 template class HERMES_API BaseView<double>;
175 template class HERMES_API BaseView<std::complex<double> >;