/[escript]/trunk/cusplibrary/cusp/opengl/spy/detail/matrix_data_panel.inl
ViewVC logotype

Contents of /trunk/cusplibrary/cusp/opengl/spy/detail/matrix_data_panel.inl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5148 - (show annotations)
Mon Sep 15 01:25:23 2014 UTC (6 years ago) by caltinay
File size: 3245 byte(s)
Merging ripley diagonal storage + CUDA support into trunk.
Options file version has been incremented due to new options
'cuda' and 'nvccflags'.

1 /*
2 * Copyright 2008-2013 Steven Dalton
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /**
18 * @file matrix_data_panel.cc
19 * The implementation file attached to the matrix_data_panel class.
20 */
21
22 /*
23 * David Gleich
24 * 22 November 2006
25 * Copyright, Stanford University
26 */
27
28 #pragma once
29
30 #include <cusp/opengl/spy/matrix_data_panel.h>
31
32 namespace cusp
33 {
34 namespace opengl
35 {
36 namespace spy
37 {
38
39 matrix_data_panel::matrix_data_panel(int parent_id,
40 int w, int h, int x, int y)
41 : parent_glut_id(parent_id)
42 {
43 set_background_color(0.25f,0.25f,0.25f);
44 set_border_color(0.0f,1.0f,0.0f);
45 set_text_color(1.0f,1.0f,1.0f);
46 super::glut_id = glutCreateSubWindow(parent_glut_id,
47 x,y,w,h);
48 super::register_with_glut();
49 }
50
51 void matrix_data_panel::display()
52 {
53 //glClearColor(0.0f, 0.0f, 1.0f, 0.8f);
54 glutSetWindow(super::get_glut_window_id());
55
56 glClearColor (background_color[0], background_color[1], background_color[2], 0.0);
57
58 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
59
60 //char str[300];
61 //snprintf(str, 300, "row [%d]: ", matrix->rperm[vy]);
62 //string rs = str + matrix->rlabels[matrix->rperm[vy]];
63
64 //std::string rs = "row: " +
65 std::ostringstream row_oss;
66 row_oss << row;
67
68 std::ostringstream col_oss;
69 col_oss << col;
70
71 std::ostringstream val_oss;
72 val_oss.precision(3);
73 val_oss << val;
74
75 glColor3f(text_color[0],text_color[1],text_color[2]);
76
77 draw_text(5,15,"row", GL_U_TEXT_SCREEN_COORDS);
78 draw_text(5,30,"column", GL_U_TEXT_SCREEN_COORDS);
79 draw_text(5,45,"value", GL_U_TEXT_SCREEN_COORDS);
80
81 draw_text(70,15,row_oss.str().c_str(), GL_U_TEXT_SCREEN_COORDS);
82 draw_text(70,30,col_oss.str().c_str(), GL_U_TEXT_SCREEN_COORDS);
83 draw_text(70,45,val_oss.str().c_str(), GL_U_TEXT_SCREEN_COORDS);
84
85 draw_text(200,15,rlabel.c_str(), GL_U_TEXT_SCREEN_COORDS);
86 draw_text(200,30,clabel.c_str(), GL_U_TEXT_SCREEN_COORDS);
87
88 //draw_text(5,15, row_oss.str().c_str(), GL_U_TEXT_SCREEN_COORDS);
89 //draw_text(5,30, col_oss.str().c_str(), GL_U_TEXT_SCREEN_COORDS);
90 //draw_text(5,45, val_oss.str().c_str(), GL_U_TEXT_SCREEN_COORDS);
91
92 glColor3f (border_color[0],border_color[1],border_color[2]);
93 glBegin (GL_LINE_LOOP);
94 glVertex2f (0.0F, 0.0F);
95 glVertex2f (0.0F, 0.99F);
96 glVertex2f (0.999F, 0.99F);
97 glVertex2f (0.999F, 0.0F);
98 glEnd ();
99
100 glutSwapBuffers();
101 }
102
103 void matrix_data_panel::reshape(int w, int h)
104 {
105 glViewport (0, 0, w, h);
106 glMatrixMode (GL_PROJECTION);
107 glLoadIdentity ();
108 gluOrtho2D (0.0F, 1.0F, 0.0F, 1.0F);
109
110 width = w;
111 height = h;
112 }
113
114 } // end spy
115 } // end opengl
116 } // end cusp

  ViewVC Help
Powered by ViewVC 1.1.26