mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-13 08:09:39 +00:00
Add ability to save view to file
This commit is contained in:
parent
84dd757778
commit
bcfb3de40d
@ -1985,7 +1985,7 @@ void GLArea::initializeShot(Shotm &shot)
|
||||
shot.Extrinsics.SetIdentity();
|
||||
}
|
||||
|
||||
bool GLArea::viewFromFile()
|
||||
bool GLArea::readViewFromFile()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Load Project"), "./", tr("Xml Files (*.xml)"));
|
||||
|
||||
@ -2014,6 +2014,52 @@ bool GLArea::viewFromFile()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GLArea::saveViewToFile()
|
||||
{
|
||||
QFileDialog* saveDiag = new QFileDialog(this,tr("Save View To File"), "./", tr("View file (*.xml)"));
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
saveDiag->setOption(QFileDialog::DontUseNativeDialog);
|
||||
#endif
|
||||
saveDiag->setAcceptMode(QFileDialog::AcceptSave);
|
||||
saveDiag->exec();
|
||||
QStringList files = saveDiag->selectedFiles();
|
||||
if (files.size() != 1)
|
||||
return;
|
||||
QString fileName = files[0];
|
||||
QFileInfo fi(fileName);
|
||||
if (fi.isDir())
|
||||
return;
|
||||
if (fi.suffix().isEmpty())
|
||||
{
|
||||
QRegExp reg("\\.\\w+");
|
||||
saveDiag->selectedNameFilter().indexOf(reg);
|
||||
QString ext = reg.cap();
|
||||
fileName.append(ext);
|
||||
fi.setFile(fileName);
|
||||
}
|
||||
QDir::setCurrent(fi.absoluteDir().absolutePath());
|
||||
|
||||
bool ret = false;
|
||||
qDebug("Saving a file %s\n", qUtf8Printable(fileName));
|
||||
if (fileName.isEmpty()) return;
|
||||
else
|
||||
{
|
||||
QFile qFile(fileName);
|
||||
if (qFile.open(QIODevice::WriteOnly)) {
|
||||
QTextStream out(&qFile); out << this->viewToText();
|
||||
qFile.close();
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!ret)
|
||||
QMessageBox::critical(this, tr("Meshlab Saving Error"), QString("Unable to save view file %1\n").arg(fileName));
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GLArea::loadShotFromTextAlignFile(const QDomDocument &doc)
|
||||
{
|
||||
QDomElement root = doc.documentElement();
|
||||
|
||||
@ -523,16 +523,17 @@ private:
|
||||
public:
|
||||
QPair<Shotm, float > shotFromTrackball();
|
||||
void viewFromCurrentShot(QString kind);
|
||||
bool viewFromFile();
|
||||
bool saveViewToFile();
|
||||
bool readViewFromFile();
|
||||
void createOrthoView(QString);
|
||||
void toggleOrtho();
|
||||
void trackballStep(QString);
|
||||
void toggleOrtho();
|
||||
void trackballStep(QString);
|
||||
void viewToClipboard();
|
||||
QString viewToText();
|
||||
void viewFromClipboard();
|
||||
void loadShot(const QPair<Shotm, float> &) ;
|
||||
void loadShotFromTextAlignFile(const QDomDocument &doc);
|
||||
void loadViewFromViewStateFile(const QDomDocument &doc);
|
||||
void loadShotFromTextAlignFile(const QDomDocument &doc);
|
||||
void loadViewFromViewStateFile(const QDomDocument &doc);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@ -217,9 +217,10 @@ private slots:
|
||||
void setUnsplit();
|
||||
void linkViewers();
|
||||
void viewFrom(QAction *qa);
|
||||
void toggleOrtho();
|
||||
void trackballStep(QAction *qa);
|
||||
void toggleOrtho();
|
||||
void trackballStep(QAction *qa);
|
||||
void readViewFromFile();
|
||||
void saveViewToFile();
|
||||
void viewFromCurrentMeshShot();
|
||||
void viewFromCurrentRasterShot();
|
||||
void copyViewToClipBoard();
|
||||
@ -507,6 +508,7 @@ private:
|
||||
QAction *viewFromMeshAct;
|
||||
QAction *viewFromRasterAct;
|
||||
QAction *viewFromFileAct;
|
||||
QAction *viewToFileAct;
|
||||
|
||||
QAction *toggleOrthoAct;
|
||||
|
||||
|
||||
@ -392,10 +392,12 @@ connectRenderModeActionList(rendlist);*/
|
||||
viewFromMeshAct = new QAction(tr("View from Mesh Camera"), this);
|
||||
viewFromRasterAct = new QAction(tr("View from Raster Camera"), this);
|
||||
viewFromRasterAct->setShortcut(Qt::CTRL + Qt::Key_J);
|
||||
viewFromFileAct = new QAction(tr("View from file"), this);
|
||||
connect(viewFromFileAct, SIGNAL(triggered()), this, SLOT(readViewFromFile()));
|
||||
viewFromFileAct = new QAction(tr("Read view from file"), this);
|
||||
viewToFileAct = new QAction(tr("Save view to file"), this);
|
||||
connect(viewFromMeshAct, SIGNAL(triggered()), this, SLOT(viewFromCurrentMeshShot()));
|
||||
connect(viewFromRasterAct, SIGNAL(triggered()), this, SLOT(viewFromCurrentRasterShot()));
|
||||
connect(viewFromFileAct, SIGNAL(triggered()), this, SLOT(readViewFromFile()));
|
||||
connect(viewToFileAct, SIGNAL(triggered()), this, SLOT(saveViewToFile()));
|
||||
|
||||
copyShotToClipboardAct = new QAction(tr("Copy shot"), this);
|
||||
connect(copyShotToClipboardAct, SIGNAL(triggered()), this, SLOT(copyViewToClipBoard()));
|
||||
|
||||
@ -212,6 +212,7 @@ void MainWindow::updateWindowMenu()
|
||||
|
||||
// View From File act
|
||||
windowsMenu->addAction(viewFromFileAct);
|
||||
windowsMenu->addAction(viewToFileAct);
|
||||
windowsMenu->addAction(viewFromMeshAct);
|
||||
windowsMenu->addAction(viewFromRasterAct);
|
||||
|
||||
@ -733,10 +734,15 @@ void MainWindow::trackballStep(QAction *qa)
|
||||
|
||||
void MainWindow::readViewFromFile()
|
||||
{
|
||||
if(GLA()) GLA()->viewFromFile();
|
||||
if(GLA()) GLA()->readViewFromFile();
|
||||
updateMenus();
|
||||
}
|
||||
|
||||
void MainWindow::saveViewToFile()
|
||||
{
|
||||
if(GLA()) GLA()->saveViewToFile();
|
||||
}
|
||||
|
||||
void MainWindow::viewFromCurrentMeshShot()
|
||||
{
|
||||
if(GLA()) GLA()->viewFromCurrentShot("Mesh");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user