From: <hba...@us...> - 2011-06-17 14:00:02
|
Revision: 11772 http://plplot.svn.sourceforge.net/plplot/?rev=11772&view=rev Author: hbabcock Date: 2011-06-17 13:59:51 +0000 (Fri, 17 Jun 2011) Log Message: ----------- Add (lightly tested) string length functionality to the Qt driver. Modified Paths: -------------- trunk/bindings/qt_gui/plqt.cpp trunk/drivers/qt.cpp Modified: trunk/bindings/qt_gui/plqt.cpp =================================================================== --- trunk/bindings/qt_gui/plqt.cpp 2011-06-15 17:06:26 UTC (rev 11771) +++ trunk/bindings/qt_gui/plqt.cpp 2011-06-17 13:59:51 UTC (rev 11772) @@ -325,6 +325,7 @@ drawTextInPicture( &p, currentString ); p.end(); + return res; } @@ -356,6 +357,12 @@ QPicture picText = getTextPicture( fci, txt->unicode_array, txt->unicode_array_len, pls->chrht ); picDpi = picText.logicalDpiY(); + if ( pls->get_string_length ) + { + pls->string_length = ((PLFLT) xOffset / picDpi) * 25.4; + return; + } + m_painterP->setClipping( true ); m_painterP->setClipRect( QRect( (int) ( pls->clpxmi * downscale ), (int) ( m_dHeight - pls->clpyma * downscale ), (int) ( ( pls->clpxma - pls->clpxmi ) * downscale ), (int) ( ( pls->clpyma - pls->clpymi ) * downscale ) ), Qt::ReplaceClip ); @@ -874,7 +881,35 @@ void QtPLWidget::drawText( EscText* txt ) { + if ( pls->get_string_length ) + { + PLUNICODE fci; + QPicture picText; + double picDpi; + PLUNICODE *text; + + plgfci( &fci ); + text = new PLUNICODE[txt->unicode_array_len]; + memcpy( text, txt->unicode_array, txt->unicode_array_len * sizeof ( PLUNICODE ) ); + picText = getTextPicture( fci, + text, + txt->unicode_array_len, + pls->chrht); + // + // I'm assuming that y_fact is 1.0 here, as it is impossible + // to know in advance (or so I believe). When the text is + // rendered "for real" it will be: pls->chrht * y_fact. + // + // Hazen 6/2011 + // + picDpi = picText.logicalDpiY(); + pls->string_length = ((PLFLT) xOffset / picDpi) * 25.4; + free(text); + return; + } + BufferElement el; + el.Element = TEXT; el.Data.TextStruct = new struct TextStruct_; el.Data.TextStruct->x = txt->x * downscale; Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2011-06-15 17:06:26 UTC (rev 11771) +++ trunk/drivers/qt.cpp 2011-06-17 13:59:51 UTC (rev 11772) @@ -267,6 +267,7 @@ pls->page = 0; pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode + pls->has_string_length = 1; // Driver supports string length calculations // Needs to be true only because of multi-stream case bool isMaster = initQtApp( true ); @@ -694,6 +695,7 @@ pls->page = 0; pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode + pls->has_string_length = 1; // Driver supports string length calculations // Needs to be true only because of multi-stream case bool isMaster = initQtApp( true ); @@ -978,6 +980,7 @@ pls->page = 0; pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode + pls->has_string_length = 1; // Driver supports string length calculations // QPrinter devices won't create if there is no QApplication declared... // Needs to be true only because of multi-stream case @@ -1288,6 +1291,7 @@ pls->termin = 1; pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode + pls->has_string_length = 1; // Driver supports string length calculations widget->setVisible( true ); widget->resize( plsc->xlength, plsc->ylength ); @@ -1513,6 +1517,7 @@ pls->termin = 0; pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode + pls->has_string_length = 1; // Driver supports string length calculations } // @@ -1708,6 +1713,7 @@ pls->page = 0; pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode + pls->has_string_length = 1; // Driver supports string length calculations // Needs to be true only because of multi-stream case bool isMaster = initQtApp( true ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |