[GEM-cvs] Gem/src/Base TextBase.cpp,1.19,1.20
Brought to you by:
zmoelnig
From: IOhannes m z. <zmo...@us...> - 2005-09-22 17:42:03
|
Update of /cvsroot/pd-gem/Gem/src/Base In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31855 Modified Files: TextBase.cpp Log Message: added fix to be able to display floats as numbers again (instead of "float") Index: TextBase.cpp =================================================================== RCS file: /cvsroot/pd-gem/Gem/src/Base/TextBase.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** TextBase.cpp 22 Sep 2005 08:32:06 -0000 1.19 --- TextBase.cpp 22 Sep 2005 17:41:44 -0000 1.20 *************** *** 50,54 **** } ! ///////////////////////////////////////////////////////// // render // --- 50,54 ---- } ! //////////////////////////////////////////////////////// // render // *************** *** 64,83 **** // step through the lines for(i=0; i<m_theText.size(); i++) ! { ! m_font->BBox(m_theText[i].c_str(), x1, y1, z1, x2, y2, z2); // FTGL ! y_offset = m_lineDist[i]*m_fontSize; ! glPushMatrix(); ! glNormal3f(0.0, 0.0, 1.0); ! justifyFont(x1, y1, z1, x2, y2, z2, y_offset); ! m_font->Render(m_theText[i].c_str()); ! glPopMatrix(); ! } } ! ///////////////////////////////////////////////////////// // setFontSize // ! ///////////////////////////////////////////////////////// void TextBase :: setFontSize(t_float size){ m_fontSize = size; --- 64,83 ---- // step through the lines for(i=0; i<m_theText.size(); i++) ! { ! m_font->BBox(m_theText[i].c_str(), x1, y1, z1, x2, y2, z2); // FTGL ! y_offset = m_lineDist[i]*m_fontSize; ! glPushMatrix(); ! glNormal3f(0.0, 0.0, 1.0); ! justifyFont(x1, y1, z1, x2, y2, z2, y_offset); ! m_font->Render(m_theText[i].c_str()); ! glPopMatrix(); ! } } ! //////////////////////////////////////////////////////// // setFontSize // ! //////////////////////////////////////////////////////// void TextBase :: setFontSize(t_float size){ m_fontSize = size; *************** *** 88,95 **** setModified(); } ! ///////////////////////////////////////////////////////// // setPrecision // ! ///////////////////////////////////////////////////////// void TextBase :: setPrecision(float prec) { --- 88,95 ---- setModified(); } ! //////////////////////////////////////////////////////// // setPrecision // ! //////////////////////////////////////////////////////// void TextBase :: setPrecision(float prec) { *************** *** 98,105 **** } ! ///////////////////////////////////////////////////////// // fontNameMess // ! ///////////////////////////////////////////////////////// void TextBase :: fontNameMess(const char *filename){ m_valid = 0; --- 98,105 ---- } ! //////////////////////////////////////////////////////// // fontNameMess // ! //////////////////////////////////////////////////////// void TextBase :: fontNameMess(const char *filename){ m_valid = 0; *************** *** 284,288 **** void TextBase :: justifyFont(float x1, float y1, float z1, ! float x2, float y2, float z2, float y_offset) { float width = 0.f; --- 284,288 ---- void TextBase :: justifyFont(float x1, float y1, float z1, ! float x2, float y2, float z2, float y_offset) { float width = 0.f; *************** *** 294,297 **** --- 294,298 ---- float ascender = m_font->Ascender(); #else + // we don't have any ascender when not using FTGL float ascender = m_fontSize; #endif *************** *** 302,309 **** else if (m_widthJus == BASEW) width = 0; ! // if (m_heightJus == BOTTOM) height = y1; ! // else if (m_heightJus == TOP) height = y2-y1; ! // else if (m_heightJus == MIDDLE)height = y2 / 2.f; ! // else if (m_heightJus == BASEH) height = 0; if (m_heightJus == BOTTOM || m_heightJus == BASEH) --- 303,310 ---- else if (m_widthJus == BASEW) width = 0; ! // if (m_heightJus == BOTTOM) height = y1; ! // else if (m_heightJus == TOP) height = y2-y1; ! // else if (m_heightJus == MIDDLE)height = y2 / 2.f; ! // else if (m_heightJus == BASEH) height = 0; if (m_heightJus == BOTTOM || m_heightJus == BASEH) *************** *** 347,350 **** --- 348,352 ---- { m_theText.clear(); + char tmp_char[MAXPDSTRING]; if ( argc < 1 ) {return; } *************** *** 356,362 **** for (i = 0; i < argc; ++i) { ! string newtext = atom_getsymbol(&argv[i])->s_name; ! line += newtext; ! if(argc-1>i)line += " "; } breakLine(line); --- 358,370 ---- for (i = 0; i < argc; ++i) { ! string newtext; ! if (A_FLOAT == argv[i].a_type) { ! atom_string(&argv[i], tmp_char, MAXPDSTRING); ! newtext = tmp_char; ! } else { ! newtext = atom_getsymbol(&argv[i])->s_name; ! } ! line += newtext; ! if(argc-1>i)line += " "; } breakLine(line); *************** *** 372,392 **** m_lineDist.clear(); if (m_heightJus == BOTTOM || m_heightJus == BASEH) ! { ! // so the offset will be a simple ! // [0 1 2 3 ... n] sequence ! for(i=0; i<m_theText.size(); i++) ! m_lineDist.push_back(i); ! return; ! } if (m_heightJus == TOP) ! { ! // now in the other direction: ! // [-n ... -2 -1 0] ! for(i=m_theText.size()-1; i>=0; i--){ ! m_lineDist.push_back(-i); } - return; - } // else: --- 380,400 ---- m_lineDist.clear(); if (m_heightJus == BOTTOM || m_heightJus == BASEH) ! { ! // so the offset will be a simple ! // [0 1 2 3 ... n] sequence ! for(i=0; i<m_theText.size(); i++) ! m_lineDist.push_back(i); ! return; ! } if (m_heightJus == TOP) ! { ! // now in the other direction: ! // [-n ... -2 -1 0] ! for(i=m_theText.size()-1; i>=0; i--){ ! m_lineDist.push_back(-i); ! } ! return; } // else: *************** *** 394,403 **** // that the text will be centered: /*lines y-offset calculation ! 1: 0 = 0- 0 ! 2: -0.5 0.5 = [0 1] - 0.5 ! 3: -1 0 1 = [0 1 2] - 1 ! 4: -1.5 -0.5 0.5 1.5 = [0 1 2 3] - 1.5 ! 5: -2 -1 0 1 2 = [0 1 2 3 4] - 2 ! ... */ --- 402,411 ---- // that the text will be centered: /*lines y-offset calculation ! 1: 0 = 0- 0 ! 2: -0.5 0.5 = [0 1] - 0.5 ! 3: -1 0 1 = [0 1 2] - 1 ! 4: -1.5 -0.5 0.5 1.5 = [0 1 2 3] - 1.5 ! 5: -2 -1 0 1 2 = [0 1 2 3 4] - 2 ! ... */ *************** *** 409,412 **** --- 417,423 ---- //-- moocow: modified version of "textMess" for float lists + // this can be used with moocow's pd-string external + // available at http://www.ling.uni-potsdam.de/~moocow/projects/pd/#externs + // it works like this: a string is represented as a list of ASCII-values ///////////////////////////////////////////////////////// // stringMess |