My fault, I figured it out (forgot to include a header). This works great, thanks!!<br><br><div class="gmail_quote">On Wed, Feb 8, 2012 at 1:12 PM, Jonathan Morra <span dir="ltr"><<a href="mailto:jonmorra@gmail.com">jonmorra@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When I try this I get <div><div>'vtkImageViewer2::SetRenderWindow' : cannot convert parameter 1 from 'vtkGenericOpenGLRenderWindow *' to 'vtkRenderWindow *'</div>
<div>Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast</div>
<div><br></div><div>Can I just do a static cast?</div><div><div class="h5"><br><div class="gmail_quote">On Wed, Feb 8, 2012 at 12:21 PM, Clinton Stimpson <span dir="ltr"><<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>On Wednesday, February 08, 2012 12:05:35 pm Jonathan Morra wrote:<br>
> I am trying to paint on top of a QVTKWidget and am having trouble doing so.<br>
> I have tried to follow the instructions at<br>
> <a href="http://vtk.1045678.n5.nabble.com/QVTKWidget-paintEvent-td2852642.html" target="_blank">http://vtk.1045678.n5.nabble.com/QVTKWidget-paintEvent-td2852642.html</a>. But<br>
> have since had no luck with QVTKWidget. I tried to swap QVTKWidget with<br>
> QVTKWidget2, but was also unsuccessful there. I was hoping<br>
> 1. If someone could provide a very small example of using QPainter with<br>
> QVTKWidget and vtkImageViewer2.<br>
> 2. A small example of using QVTKWidget2 with vtkImageViewer2.<br>
> 3. A description of what's different between QVTKWidget and QVTKWidget2?<br>
<br>
</div></div>The main difference is that QVTKWidget2 derives from QGLWidget and comes with<br>
the functionality of QGLWidget. For general usage, there probably isn't much<br>
different between the two.<br>
<br>
Here's a way to use QPainter with QVTKWidget2:<br>
<br>
class MyQVTKWidget2 : public QVTKWidget2<br>
{<br>
public:<br>
MyQVTKWidget2(QWidget* p = NULL) : QVTKWidget2(p)<br>
{<br>
// don't clear the scene when QPainter is constructed, since it will be<br>
used to add<br>
// to the scene<br>
setAutoFillBackground(false);<br>
}<br>
<br>
// overload Frame() to add our painting on top of VTK's completed rendering<br>
void Frame()<br>
{<br>
QPainter p(this);<br>
p.drawLine(0,0,100,100);<br>
p.end();<br>
<br>
QVTKWidget2::Frame();<br>
}<br>
};<br>
<br>
<br>
To use that with vtkImageViewer2:<br>
<br>
int main(int argc, char** argv)<br>
{<br>
QApplication app(argc, argv);<br>
<br>
MyQVTKWidget2 widget;<br>
widget.resize(256,256);<br>
<br>
vtkPNGReader* reader = vtkPNGReader::New();<br>
char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv,<br>
"Data/vtk.png");<br>
reader->SetFileName(fname);<br>
delete [] fname;<br>
<br>
vtkImageViewer2* image_view = vtkImageViewer2::New();<br>
image_view->SetInputConnection(reader->GetOutputPort());<br>
<br>
image_view->SetupInteractor(widget.GetRenderWindow()->GetInteractor());<br>
image_view->SetRenderWindow(widget.GetRenderWindow());<br>
<br>
image_view->SetColorLevel(138.5);<br>
image_view->SetColorWindow(233);<br>
<br>
widget.show();<br>
<br>
app.exec();<br>
<br>
image_view->Delete();<br>
reader->Delete();<br>
<br>
return 0;<br>
}<br>
<span><font color="#888888"><br>
<br>
--<br>
Clinton Stimpson<br>
Elemental Technologies, Inc<br>
Computational Simulation Software, LLC<br>
<a href="http://www.csimsoft.com" target="_blank">www.csimsoft.com</a><br>
</font></span></blockquote></div><br></div></div></div>
</blockquote></div><br>