<div dir="ltr">In both openFile() and saveFile()<br><br>filename is out of scope. you shouls be using fileName.toLatin1() instead.<br><br>Jothy<br><br><div class="gmail_quote">On Fri, Aug 17, 2012 at 1:57 PM, Agata Krasoń <span dir="ltr"><<a href="mailto:agatakrason@gmail.com" target="_blank">agatakrason@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<div><br></div><div>I have one more question to You a propos de qt:</div><div>I created qui (I send You screen).</div>
<div>I made 2 slots openFile() and saveFile()</div><div><br></div><div>I can't call well all .</div>
<div><br></div><div>For the moment Could You look at this code ?</div><div>Principally on constructor : I think that it is something wrong with it..</div><div><br></div><div><br></div><div><div>#include "ui_SimpleViewUI.h"</div>
<div>#include "SimpleViewUI.h"</div><div> </div><div>#include <vtkPolyDataMapper.h></div><div>#include <vtkRenderer.h></div><div>#include <vtkPolyData.h></div><div>#include <vtkRenderWindow.h></div>
<div>#include <vtkSphereSource.h></div><div>#include <vtkXMLPolyDataReader.h></div><div>#include <vtkXMLPolyDataWriter.h></div><div>#include "vtkSmartPointer.h"</div><div><br></div><div>#include <QString></div>
<div>#include <QFileDialog></div><div>#include <QMessageBox></div><div>#include <QFile></div><div> </div><div>// Constructor</div><div class="im"><div>SimpleView::SimpleView() </div><div>{</div><div> this->ui = new Ui_SimpleView;</div>
<div> this->ui->setupUi(this);</div><div><br></div><div><br></div><div><br></div></div><div class="im"><div><font color="#cc0000"> // VTK Renderer</font></div><div><font color="#cc0000"> vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();</font></div>
<div><font color="#cc0000"> </font></div></div><div class="im"><div><font color="#cc0000"> // VTK/Qt wedded</font></div><div><font color="#cc0000"> this->ui->qvtkWidget->GetRenderWindow()->AddRenderer(renderer);</font></div>
<div>
<font color="#cc0000"><br></font></div></div><div><font color="#cc0000"> // vtkXMLPolyDataReader* reader = vtkXMLPolyDataReader::New();</font></div><div class="im"><div><font color="#cc0000"><br></font></div><div><font color="#cc0000"> vtkPolyData* polydata = vtkPolyData::New();</font></div>
<div><font color="#cc0000"> polydata = reader->GetOutput();</font></div><div><font color="#cc0000"><br></font></div><div><font color="#cc0000"> vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();</font></div>
<div><font color="#cc0000"> mapper->SetInput(polydata);</font></div><div><font color="#cc0000"> vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();</font></div><div><font color="#cc0000"> actor->SetMapper(mapper);</font></div>
</div><div><font color="#cc0000"> renderer->AddActor(actor);</font></div><div class="im"><div><font color="#cc0000"><br></font></div><div><font color="#cc0000"> </font></div><div><font color="#cc0000"> // Set up action signals and slots</font></div>
<div><font color="#cc0000"> connect(this->ui->actionExit, SIGNAL(triggered()), this, SLOT(slotExit()));</font></div><div><font color="#cc0000"> connect(this->ui->openButton, SIGNAL(clicked()), this, SLOT(openFile()));</font></div>
<div><font color="#cc0000"> connect(this->ui->saveButton, SIGNAL(clicked()), this, SLOT(saveFile()));</font></div><div><font color="#cc0000"> </font></div><div><font color="#cc0000"> setWindowTitle("Display Model - Mesh - Surface");</font></div>
<div> </div><div> </div><div>}</div><div> </div></div><div>void SimpleView::slotExit() </div><div>{</div><div> qApp->exit();</div><div>}</div><div><br></div><div>void SimpleView::openFile()</div><div>{</div><div><br>
</div><div>
<span style="white-space:pre-wrap">        </span> QString fileName = QFileDialog::getOpenFileName(this, tr("Open file with model/mesh"), "", tr("files (*.vtp);;All Files (*)"));</div><div class="im">
<div><br></div><div><span style="white-space:pre-wrap">        </span> std::string filename = fileName.toLatin1();</div></div><div><span style="white-space:pre-wrap">        </span> vtkXMLPolyDataReader* reader = vtkXMLPolyDataReader::New();</div>
<div><span style="white-space:pre-wrap">        </span> reader->SetFileName(filename.c_str());</div><div> reader->Update();</div><div><br></div><div><span style="white-space:pre-wrap">        </span></div>
<div> </div><div>}</div><div><br></div><div>void SimpleView::saveFile()</div><div>{</div><div><span style="white-space:pre-wrap">        </span> // std::cout <<" save file "<<std::endl;</div>
<div><span style="white-space:pre-wrap">        </span> QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), " ",tr("Images/models (*.vtp)"));</div><div class="im"><div><br></div>
<div> std::string filename = fileName.toLatin1();</div></div><div><span style="white-space:pre-wrap">        </span> vtkXMLPolyDataWriter* writer = vtkXMLPolyDataWriter::New();</div><div> writer->SetInputConnection(reader->GetOutputPort());</div>
<div> writer->SetFileName(filename.c_str());</div><div> writer->Write();</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span> </div>
<div><br></div><div>}</div><div><br></div><div><br></div><div>SimpleView::~SimpleView(){}<span style="white-space:pre-wrap">        </span></div><div><br></div><div>I would appreciate for any help please.</div>
</div><div><br></div><div><br></div><div>agata</div><div><br><div class="gmail_quote">2012/8/17 Jothybasu Selvaraj <span dir="ltr"><<a href="mailto:jothybasu@gmail.com" target="_blank">jothybasu@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">And post your code, it seems to that you are not seeting the file name properly.<br><br><br><br><div class="gmail_quote">
<div><div>On Fri, Aug 17, 2012 at 12:36 PM, agatte <span dir="ltr"><<a href="mailto:agatakrason@gmail.com" target="_blank">agatakrason@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>Hi ;)<br>
<br>
I launch program. I can't open&load a vtp file and save.<br>
I received error info :<br>
<br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\IO\vtkXMLReader.cxx, line 204<br>
vtkXMLPolyDataReader (07809840): File name not specified<div class="im"><br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\Filtering\vtkExecutive.cxx, line 756<br></div>
vtkStreamingDemandDrivenPipeline (0780AFF0): Algorithm<br>
vtkXMLPolyDataReader(07809840) returned failure for request: vtkInformation<br>
(0783C218)<br>
Debug: Off<br>
Modified Time: 1556<div class="im"><br>
Reference Count: 1<br>
Registered Events: (none)<br>
Request: REQUEST_INFORMATION<br></div>
FORWARD_DIRECTION: 0<br>
ALGORITHM_AFTER_FORWARD: 1<br>
FROM_OUTPUT_PORT: 0<br>
<br>
<br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\IO\vtkXMLReader.cxx, line 204<br>
vtkXMLPolyDataReader (07809840): File name not specified<div class="im"><br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\Filtering\vtkExecutive.cxx, line 756<br></div>
vtkStreamingDemandDrivenPipeline (0780AFF0): Algorithm<br>
vtkXMLPolyDataReader(07809840) returned failure for request: vtkInformation<br>
(0782D208)<br>
Debug: Off<br>
Modified Time: 1687<div class="im"><br>
Reference Count: 1<br>
Registered Events: (none)<br>
Request: REQUEST_DATA<br></div>
FORWARD_DIRECTION: 0<br>
ALGORITHM_AFTER_FORWARD: 1<br>
FROM_OUTPUT_PORT: 0<div class="im"><br>
<br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\IO\vtkXMLReader.cxx, line 219<br></div>
vtkXMLPolyDataReader (0782C818): Error opening file XM€<div class="im"><br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\Filtering\vtkExecutive.cxx, line 756<br></div>
vtkStreamingDemandDrivenPipeline (078302F0): Algorithm<br>
vtkXMLPolyDataReader(0782C818) returned failure for request: vtkInformation<br>
(0C67E420)<br>
Debug: Off<br>
Modified Time: 1976<div class="im"><br>
Reference Count: 1<br>
Registered Events: (none)<br>
Request: REQUEST_INFORMATION<br></div>
FORWARD_DIRECTION: 0<br>
ALGORITHM_AFTER_FORWARD: 1<br>
<br>
<br>
<br>
<br>
<br>
<br><span class="HOEnZb"><font color="#888888">
<br></font></span></div></div><span class="HOEnZb"><font color="#888888">
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/Example-VTK-with-Qt-Load-and-Save-VTP-file-tp5715374p5715378.html" target="_blank">http://vtk.1045678.n5.nabble.com/Example-VTK-with-Qt-Load-and-Save-VTP-file-tp5715374p5715378.html</a></font></span><div class="im">
<br>
Sent from the VTK - Users mailing list archive at Nabble.com.</div><div><br><div class="im">
<div><div>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</div></div></div></div></blockquote></div><span><font color="#888888"><br><br clear="all"><br><div class="im">-- <br><div dir="ltr">Jothybasu Selvaraj<br>PhD Student<br>University of Liverpool<br>UK<br></div><br>
</div></font></span></div>
</blockquote></div><br></div>
</blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">Jothybasu Selvaraj<br>PhD Student<br>University of Liverpool<br>UK<br></div><br>
</div>