Hi,<br><br>I am updating Mokka (<a href="http://b-tk.googlecode.com/svn/web/mokka/index.html" target="_blank">http://b-tk.googlecode.com/svn/web/mokka/index.html</a> - a software used in Biomechanics) from VTK 5.6.1 to VTK 5.10 and everything is fine except the text rendering in the charts.<br>
<br>As there is is lots of differences in the charts module between vtk 5.6.1 and vtk 5.10, I checked if the problem came from my code. For that, I created a small executable based on the example "Line plot" but embedded in a QVTKWidget.<br>
<br>The following link (<a href="http://derp.co.uk/c040e" target="_blank">http://derp.co.uk/c040e</a>) gives you the result for VTK 5.6.1 and VTK 5.10. Both version were compiled with Qt 4.7.3 and with the same options (VTK_USE_QT, VTK_USE_QVTK_QTOPENGL)<br>
<br>As you can see the text rendering is not the same and in the case of vtk-5.10, the method <span style="font-family:courier new,monospace">vtkOpenGLContextDevice2D::</span><span style="font-family:courier new,monospace">SetStringRendererToQt</span>() returns false (and then "No Qt rendering" is displayed in the title). I tested under Windows 7 and MacOS X (Leopard - 10.5.8) and I have each time the same problem.<br>
<br>Is there anything special to do in VTK 5.10 to have a Qt text rendering in the charts? Should I use QVTKWidget2?<br>
<br>Regards,<br><br>Arnaud<br><br>The code is joined in the ZIP file, but if necessary, here is the source code and the CMake project<br><br><u>main.cpp</u><br><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#include <vtkRenderWindow.h></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">#include <vtkSmartPointer.h></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#include <vtkChartXY.h></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">#include <vtkPlot.h></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#include <vtkPen.h></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">#include <vtkTable.h></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#include <vtkFloatArray.h></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">#include <vtkContextView.h></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#include <vtkContextScene.h></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">#include <vtkContext2D.h></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#include <vtkOpenGLContextDevice2D.h></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">#include <vtkVersion.h></span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#include <QApplication></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">#include <QVTKWidget.h></span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#define VTK_CREATE(type, name) \</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> vtkSmartPointer<type> name = vtkSmartPointer<type>::New()</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">int main(int argc, char *argv[])</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">{</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> QApplication app(argc,argv);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> QVTKWidget widget;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> widget.resize(640,480);</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> // Set up a 2D scene, add an XY chart to it</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> VTK_CREATE(vtkContextView, view);</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> VTK_CREATE(vtkChartXY, chart);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> view->GetScene()->AddItem(chart);</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> // Link the view with the widget</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> view->SetInteractor(widget.GetInteractor());</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> widget.SetRenderWindow(view->GetRenderWindow());</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> // Create a table with some points in it</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> VTK_CREATE(vtkTable, table);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> VTK_CREATE(vtkFloatArray, arrX);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> arrX->SetName("X Axis");</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> table->AddColumn(arrX);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> VTK_CREATE(vtkFloatArray, arrC);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> arrC->SetName("Cosine");</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> table->AddColumn(arrC);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> VTK_CREATE(vtkFloatArray, arrS);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> arrS->SetName("Sine");</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> table->AddColumn(arrS);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> // Fill in the table with some example values</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> int numPoints = 69;</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> float inc = 7.5 / (numPoints-1);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> table->SetNumberOfRows(numPoints);</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> for (int i = 0; i < numPoints; ++i)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> {</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> table->SetValue(i, 0, i * inc);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> table->SetValue(i, 1, cos(i * inc));</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> table->SetValue(i, 2, sin(i * inc));</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> }</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> // Add multiple line plots, setting the colors etc</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> vtkPlot *line = chart->AddPlot(vtkChart::LINE);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#if VTK_MAJOR_VERSION <= 5</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> line->SetInput(table, 0, 1);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#else</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> line->SetInputData(table, 0, 1);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#endif</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> line->SetColor(0, 255, 0, 255);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> line->SetWidth(1.0);</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> line = chart->AddPlot(vtkChart::LINE);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#if VTK_MAJOR_VERSION <= 5</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> line->SetInput(table, 0, 2);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#else</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> line->SetInputData(table, 0, 2);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#endif</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> line->SetColor(255, 0, 0, 255);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> line->SetWidth(5.0);</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> line->GetPen()->SetLineType(2);//For dotted line, can be from 2 to 5 for different dot patterns</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> std::string vtkVersion = vtkVersion::GetVTKVersion();</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> std::string qtVersion = qVersion();</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> std::string title = "VTK-" + vtkVersion + " & Qt-" + qtVersion + ": ";</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> if (!vtkOpenGLContextDevice2D::SafeDownCast(view->GetContext()->GetDevice())->SetStringRendererToQt())</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> title += "No Qt Rendering";</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> else</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> title += "Qt Rendering";</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> chart->SetTitle(title.c_str());</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> widget.show();</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> app.exec();</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> return EXIT_SUCCESS;</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">}</span><br><br><u>CMakeLists.txt</u><br><br><span style="font-family:courier new,monospace">cmake_minimum_required(VERSION 2.6)</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">PROJECT(vtkChartQtTextRendering)</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">FIND_PACKAGE(VTK)</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">INCLUDE(${VTK_USE_FILE})</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">SET(QT_QMAKE_EXECUTABLE ${VTK_QT_QMAKE_EXECUTABLE} CACHE FILEPATH "")</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">SET(QT_MOC_EXECUTABLE ${VTK_QT_MOC_EXECUTABLE} CACHE FILEPATH "")</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">SET(QT_UIC_EXECUTABLE ${VTK_QT_UIC_EXECUTABLE} CACHE FILEPATH "")</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">FIND_PACKAGE(Qt4 REQUIRED)</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">INCLUDE(${QT_USE_FILE})</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"># Use the include path and library for Qt that is used by VTK.</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> ${QT_QTGUI_INCLUDE_DIR}</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> ${QT_QTCORE_INCLUDE_DIR})</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">ADD_EXECUTABLE(vtkChartQtTextRendering main.cpp)</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">TARGET_LINK_LIBRARIES(vtkChartQtTextRendering</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> QVTK</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> ${QT_LIBRARIES}</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> vtkCharts</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">)</span><br>