/[gzz]/gzz/gfx/librenderables/renderables.py
ViewVC logotype

Diff of /gzz/gfx/librenderables/renderables.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.120 by mudyc, Fri Nov 1 09:35:41 2002 UTC revision 1.121 by mudyc, Fri Nov 1 13:38:22 2002 UTC
# Line 1190  rs = [ Line 1190  rs = [
1190              float scale;              float scale;
1191              ZPt orig;              ZPt orig;
1192                            
1193              Vertexer(Coords &c, float scale, ZPt orig) : c(c), scale(scale), orig(orig) { }              Vertexer(Coords &c, float scale, ZPt orig) :
1194                    c(c), scale(scale), orig(orig) { }
1195    
1196              template<class T> void operator()(const T &x, const T &y) {              template<class T> void operator()(const T &x, const T &y) {
             /*  horiz text 2  
                 ZPt tmp(x + 1, y - orig_y + 1, 0);  
                 tmp.x *= scale; tmp.y *= scale;  
                 tmp.x -= 1; tmp.y += orig_y - 1;  
             */  
             /*  
                 ZPt tmp(x, y, 0);  
                 tmp.x *= scale; tmp.y *= scale;  
                 tmp.x += orig.x; tmp.y += orig.y;  
             */  
               
                 ZPt tmp(x, y, 0);  
1197    
1198                  orig.x *= scale;                  ZPt tmp(x*scale, y*scale, 0);
                 orig.y *= scale;  
1199    
1200                  tmp.x -= orig.x;                  tmp = c.transform(tmp);
                 tmp.y -= orig.y;  
                   
                 tmp.x *= scale;  
                 tmp.y *= scale;  
1201    
1202                  tmp.x += orig.x;                  tmp.x += orig.x;
1203                  tmp.y += orig.y;                  tmp.y += orig.y;
1204    
1205                  c.vertex(tmp);                  // already transformed from coords1, so:
1206                    glVertex3f(tmp.x, tmp.y, tmp.z);
1207              }              }
1208          };          };
1209          """,          """,
# Line 1231  rs = [ Line 1216  rs = [
1216              int weeks = (days + empty_days) / 7;              int weeks = (days + empty_days) / 7;
1217              if ( (days + empty_days) % 7 != 0) weeks++;              if ( (days + empty_days) % 7 != 0) weeks++;
1218    
             // Coordinating system  
             ZPt cs;  
   
1219              glDisable(GL_TEXTURE_2D);              glDisable(GL_TEXTURE_2D);
1220    
1221              glLineWidth(linewidth);              glLineWidth(linewidth);
# Line 1242  rs = [ Line 1224  rs = [
1224              glBegin(GL_LINES);              glBegin(GL_LINES);
1225    
1226                // left -vert                // left -vert
1227                cs = coords1.transform( ZPt(0.0, 0.0, 0.0) );                coords1.vertex( ZPt(0.0, 0.0, 0.0) );
1228                glVertex3f(cs.x, cs.y, cs.z);                coords1.vertex( ZPt(0.0, weeks + weekday_h + month_name_h, 0.0) );
               cs = coords1.transform( ZPt(0.0, weeks + weekday_h + month_name_h, 0.0) );  
               glVertex3f(cs.x, cs.y, cs.z);  
1229    
1230                // right -vert                // right -vert
1231                cs = coords1.transform( ZPt(7.0+ week_num_w, 0.0, 0.0) );                coords1.vertex( ZPt(7.0+ week_num_w, 0.0, 0.0) );
1232                glVertex3f(cs.x, cs.y, cs.z);                coords1.vertex( ZPt(7.0+ week_num_w, weeks + weekday_h + month_name_h, 0.0) );
               cs = coords1.transform( ZPt(7.0+ week_num_w, weeks + weekday_h + month_name_h, 0.0) );  
               glVertex3f(cs.x, cs.y, cs.z);  
1233    
1234                // weekday - horiz                // weekday - horiz
1235                cs = coords1.transform( ZPt(0.0, month_name_h, 0.0) );                coords1.vertex( ZPt(0.0, month_name_h, 0.0) );
1236                glVertex3f(cs.x, cs.y, cs.z);                coords1.vertex( ZPt(7.0+week_num_w, month_name_h, 0.0) );
               cs = coords1.transform( ZPt(7.0+week_num_w, month_name_h, 0.0) );  
               glVertex3f(cs.x, cs.y, cs.z);  
   
               // top - horiz line  
               cs = coords1.transform( ZPt(0.0, 0.0, 0.0) );  
               glVertex3f(cs.x, cs.y, cs.z);  
               cs = coords1.transform( ZPt(7.0+week_num_w, 0.0, 0.0) );  
               glVertex3f(cs.x, cs.y, cs.z);  
1237                                
1238                  // top - horiz line
1239                  coords1.vertex( ZPt(0.0, 0.0, 0.0) );
1240                  coords1.vertex( ZPt(7.0+week_num_w, 0.0, 0.0) );
1241    
1242                // Calendar:                // Calendar:
1243                // Vertical lines.                // Vertical lines.
1244                for (int i=0; i<7; i++) {                for (int i=0; i<7; i++) {
1245                    cs = coords1.transform( ZPt(i + week_num_w, month_name_h, 0.0) );                    coords1.vertex( ZPt(i + week_num_w, month_name_h, 0.0) );
1246                    glVertex3f(cs.x, cs.y, cs.z);                    coords1.vertex( ZPt(i + week_num_w, month_name_h + weeks + weekday_h, 0.0) );
   
                   cs = coords1.transform( ZPt(i + week_num_w, month_name_h + weeks + weekday_h, 0.0) );  
                   glVertex3f(cs.x, cs.y, cs.z);  
1247                }                }
1248                // Horizontal lines.                // Horizontal lines.
1249                for (int i=0; i<=weeks; i++) {                for (int i=0; i<=weeks; i++) {
1250                    cs = coords1.transform( ZPt(0.0, i+month_name_h+weekday_h, 0.0) );                    coords1.vertex( ZPt(0.0, i+month_name_h+weekday_h, 0.0) );
1251                    glVertex3f(cs.x, cs.y, cs.z);                    coords1.vertex( ZPt(7.0+week_num_w, i+month_name_h+weekday_h, 0.0) );
   
                   cs = coords1.transform( ZPt(7.0+week_num_w, i+month_name_h+weekday_h, 0.0) );  
                   glVertex3f(cs.x, cs.y, cs.z);  
1252                }                }
1253              glEnd();              glEnd();
1254    
1255              glEnable(GL_TEXTURE_2D);              glEnable(GL_TEXTURE_2D);
   
             ZPt p_text(2,2,0);  
             p_text = coords2.transform(p_text);  
   
             float date_shift = shifts[0];  
1256              float date_scale = scales[0];              float date_scale = scales[0];
1257    
             Vertexer<Coords> v_date(coords1, date_scale, p_text);  
   
1258              for (int i=1; i<=days; i++) {              for (int i=1; i<=days; i++) {
1259                  int column = (empty_days + i -1) % 7;                  int column = (empty_days + i -1) % 7;
1260                  int row  = 1 + (empty_days + i -1) / 7;                  int row  =1+ (empty_days + i -1) / 7;
1261    
1262                  static char buffer[64];                  static char buffer[64];
1263                  sprintf(buffer, "%i", i);                  sprintf(buffer, "%i", i);
1264    
1265                  float fcol, frow;                  float fcol = week_num_w;
1266                    float frow = weekday_h + month_name_h;
                 fcol = week_num_w;  
                 frow = weekday_h + month_name_h;  
1267    
1268                  if (i<10) {                  if (i<10) {
1269                      fcol += column + date_shift + 0.20;                      fcol += column + 0.20;
1270                      frow += row - date_shift - 0.15;                      frow += row - 0.15;
1271                  } else {                  } else {
1272                      fcol += column + date_shift;                      fcol += column;
1273                      frow += row - date_shift - 0.15;                      frow += row - 0.15;
1274                  }                  }
1275    
1276                  glColor3f(1.0, 1.0, 1.0);                  glColor3f(1.0, 1.0, 1.0);
1277    
1278                    Vertexer<Coords> v_date(coords2, date_scale,
1279                                            coords1.transform(ZPt(fcol, frow,0))
1280                    );
1281                                    
1282                  Text::renderIter(*r_date, buffer, buffer+strlen(buffer),                  Text::renderIter(*r_date, buffer, buffer+strlen(buffer),
1283                       fcol*(1/date_scale) , frow*(1/date_scale), v_date                       shifts[0], -shifts[0],
1284                       //fcol, frow, v_date                       v_date
1285                  );                  );
1286    
1287                    // use red for sundays..
1288                  if (column == 6) glColor3f(1.0, 0.0, 0.0);                  if (column == 6) glColor3f(1.0, 0.0, 0.0);
1289                  else  glColor3f(0.0, 0.0, 0.0);                  else  glColor3f(0.0, 0.0, 0.0);
1290    
1291                  Text::renderIter(*r_date, buffer, buffer+strlen(buffer),                  Text::renderIter(*r_date, buffer, buffer+strlen(buffer),
1292                       (fcol + 0.03)*(1/date_scale),                      shifts[0] + 0.03, -shifts[0] + 0.03,
1293                       (frow + 0.03)*(1/date_scale),                      v_date
                      v_date  
1294                  );                  );
1295    
1296              }              }
# Line 1337  rs = [ Line 1299  rs = [
1299    
1300              // Week numbers              // Week numbers
1301              float week_num_scale = scales[1];              float week_num_scale = scales[1];
             Vertexer<Coords> v_week_num(coords1, week_num_scale, p_text);  
   
1302              for (int i=0; i<weeks; i++) {              for (int i=0; i<weeks; i++) {
1303                    Vertexer<Coords> v_week_num(coords2, week_num_scale,
1304                        coords1.transform(ZPt(0, month_name_h + weekday_h + i,0))
1305                    );
1306                        
1307                  static char buffer[64];                  static char buffer[64];
1308                  sprintf(buffer, "%i", first_week_number + i);                  sprintf(buffer, "%i", first_week_number + i);
1309    
1310                  Text::renderIter(*r, buffer, buffer+strlen(buffer),                  Text::renderIter(*r, buffer, buffer+strlen(buffer),
1311                       (0.1)*(1/week_num_scale),                      0.1, shifts[1],
1312                       (month_name_h + weekday_h + i + shifts[1])*(1/week_num_scale),                      v_week_num
                      v_week_num  
1313                  );                  );
1314                            
1315              }              }
1316    
1317    
1318              // Weekdays              // Weekdays
1319              float weekday_scale = scales[2];              float weekday_scale = scales[2];
             Vertexer<Coords> v_weekday(coords1, weekday_scale, p_text);  
   
1320              for (int i=0; i<7; i++) {              for (int i=0; i<7; i++) {
1321    
1322                    Vertexer<Coords> v_weekday(coords2, weekday_scale,
1323                        coords1.transform(ZPt(week_num_w + i + 0.1, month_name_h + weekday_h - 0.15, 0 ))
1324                    );
1325                
1326                  Text::renderIter(*r, d_txt[i].begin(), d_txt[i].end(),                  Text::renderIter(*r, d_txt[i].begin(), d_txt[i].end(),
1327                       (week_num_w + i+ 0.1)*(1/weekday_scale),                      0, shifts[2],
1328                       (month_name_h + weekday_h - shifts[2]) * (1/weekday_scale),                      v_weekday
                      v_weekday  
1329                  );                  );
1330              }              }
1331    
1332    
1333              // Month name              // Month name
1334              float month_name_scale = scales[3];              float month_name_scale = scales[3];
1335              Vertexer<Coords> v_month(coords1, month_name_scale, p_text);              Vertexer<Coords> v_month(coords2, month_name_scale,
1336                    coords1.transform(ZPt(week_num_w, month_name_h - 0.15, 0))
1337                );
1338    
1339              Text::renderIter(*r, m_txt.begin(), m_txt.end(),              Text::renderIter(*r, m_txt.begin(), m_txt.end(),
1340                  (week_num_w+shifts[3])*(1/month_name_scale),  // x                  shifts[3], 0,
                 (month_name_h-0.15)*(1/month_name_scale), // y  
1341                  v_month                  v_month
1342              );              );
1343                            

Legend:
Removed from v.1.120  
changed lines
  Added in v.1.121

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26