Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions src/Vizkit3DWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QFileInfo>
#include <QDir>
#include <QRegExp>
#include <QFileDialog>
#include <algorithm>

#include "Vizkit3DBase.hpp"
Expand All @@ -22,6 +23,7 @@

#include <osg/PositionAttitudeTransform>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgQt/GraphicsWindowQt>
#include <osgViewer/ViewerEventHandlers>

Expand Down Expand Up @@ -257,12 +259,32 @@ Vizkit3DWidget::Vizkit3DWidget(QWidget* parent,const QString &world_name,bool au
setCentralWidget(widget);


//Create Layout
QWidget* rightPaneWidget = new QWidget(parent);
QVBoxLayout* rightPaneLayout = new QVBoxLayout();
// create export button
QPushButton *exportButton = new QPushButton( parent );
rightPaneWidget->setLayout(rightPaneLayout);

exportButton->setText("Export Scene");
QVBoxLayout* toolsLayout = new QVBoxLayout();
toolsLayout->addWidget(exportButton);
QWidget* toolsWidget = new QWidget(parent);
toolsWidget->setLayout(toolsLayout);
toolsWidget->setObjectName("ToolsWidget");
toolsWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );

QDockWidget* toolsDocker = new QDockWidget("Tools");
toolsDocker->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetFeature::DockWidgetClosable);
toolsDocker->setWidget(toolsWidget);
addDockWidget(Qt::RightDockWidgetArea, toolsDocker);

// create propertyBrowserWidget
propertyBrowserWidget = new QPropertyBrowserWidget( parent );
propertyBrowserWidget->setObjectName("PropertyBrowser");
propertyBrowserWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
propertyBrowserWidget->resize(200,600);

propertyDocker = new QDockWidget("Properties");
//prop browser should be closed
propertyDocker->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
Expand Down Expand Up @@ -291,6 +313,7 @@ Vizkit3DWidget::Vizkit3DWidget(QWidget* parent,const QString &world_name,bool au
connect(this, SIGNAL(addPlugins(QObject*,QObject*)), this, SLOT(addPluginIntern(QObject*,QObject*)));
connect(this, SIGNAL(removePlugins(QObject*)), this, SLOT(removePluginIntern(QObject*)));
connect( &_timer, SIGNAL(timeout()), this, SLOT(update()) );
connect(exportButton, SIGNAL(clicked()), this, SLOT(exportScene()));

current_frame = QString(root->getName().c_str());

Expand Down Expand Up @@ -1260,6 +1283,26 @@ void Vizkit3DWidget::setCameraManipulator(CAMERA_MANIPULATORS manipulatorType, b
}
}


void Vizkit3DWidget::exportScene() {
QDir directory;

QFileDialog dialog;
QString filename;

dialog.setDirectory( directory.currentPath() );
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setNameFilter("OSG Scene files (*.osg *.osgb)");
dialog.setDefaultSuffix("osgb");
dialog.setWindowTitle("Export OSG scene");
if (dialog.exec()) {
QStringList filenames = dialog.selectedFiles();
filename = filenames.at(0);
osgDB::writeNodeFile(*root, filename.toStdString());
}
}


void Vizkit3DWidget::ObjectMovedHandler::operator()(const osgviz::Object* obj,
const osg::Matrix& motion)
{
Expand Down Expand Up @@ -1384,6 +1427,3 @@ void Vizkit3DWidget::setEnabledManipulators(const bool value)
clickHandler->setEnabled(value);
}




7 changes: 7 additions & 0 deletions src/Vizkit3DWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,13 @@ namespace vizkit3d
* when a frame is clicked. Default: false*/
void setEnabledManipulators(const bool value);

/** Exports current scene to OSG scene file
*
* Opens file dialog and saves currently displayed scene to a
* OSG scene file.
*/
void exportScene();

signals:
void addPlugins(QObject* plugin,QObject* parent);
void removePlugins(QObject* plugin);
Expand Down