diff --git a/GUI/Qt/Components/ViewPanel3D.cxx b/GUI/Qt/Components/ViewPanel3D.cxx
index 30016be8..88ca673f 100644
--- a/GUI/Qt/Components/ViewPanel3D.cxx
+++ b/GUI/Qt/Components/ViewPanel3D.cxx
@@ -2,6 +2,7 @@
#include "ui_ViewPanel3D.h"
#include "GlobalUIModel.h"
#include "Generic3DModel.h"
+#include "Generic3DRenderer.h"
#include "itkCommand.h"
#include "IRISException.h"
#include "IRISApplication.h"
@@ -50,6 +51,9 @@ ViewPanel3D::ViewPanel3D(QWidget *parent) :
m_DropMenu->addAction(ui->actionSave_Viewpoint);
m_DropMenu->addAction(ui->actionRestore_Viewpoint);
m_DropMenu->addSeparator();
+ m_DropMenu->addAction(ui->actionImport_Viewpoint);
+ m_DropMenu->addAction(ui->actionExport_Viewpoint);
+ m_DropMenu->addSeparator();
m_DropMenu->addAction(ui->actionContinuous_Update);
ui->actionContinuous_Update->setObjectName("actionContinuousUpdate");
m_DropMenu->addSeparator();
@@ -301,6 +305,80 @@ void ViewPanel3D::on_actionRestore_Viewpoint_triggered()
m_Model->RestoreCameraState();
}
+void ViewPanel3D::LoadCameraViewpoint(QString file)
+{
+ try
+ {
+ std::string utf = to_utf8(file);
+ CameraState cam = {};
+ std::ifstream input(utf);
+ input >> cam.position;
+ input >> cam.focal_point;
+ input >> cam.view_up;
+ input >> cam.view_angle;
+ input >> cam.parallel_projection;
+ input >> cam.parallel_scale;
+ input >> cam.clipping_range;
+ m_Model->GetRenderer()->SetCameraState(cam);
+ }
+ catch(std::exception &exc)
+ {
+ ReportNonLethalException(this, exc, "Camera Viewpoint IO Error",
+ QString("Failed to load camera viewpoint from file"));
+ }
+}
+
+void ViewPanel3D::SaveCameraViewpoint(QString file)
+{
+ try
+ {
+ std::string utf = to_utf8(file);
+ CameraState cam = m_Model->GetRenderer()->GetCameraState();
+ std::ofstream output(utf);
+ output << cam.position << std::endl;
+ output << cam.focal_point << std::endl;
+ output << cam.view_up << std::endl;
+ output << cam.view_angle << std::endl;
+ output << cam.parallel_projection << std::endl;
+ output << cam.parallel_scale << std::endl;
+ output << cam.clipping_range << std::endl;
+ }
+ catch(std::exception &exc)
+ {
+ ReportNonLethalException(this, exc, "Camera Viewpoint IO Error",
+ QString("Failed to save camera viewpoint to file"));
+ }
+}
+
+void ViewPanel3D::on_actionImport_Viewpoint_triggered()
+{
+ // Ask for a filename
+ QString selection = ShowSimpleOpenDialogWithHistory(
+ this, m_Model->GetParentUI(), "CameraViewpoint",
+ "Load Camera Viewpoint - ITK-SNAP",
+ "Camera Viewpoint File",
+ "Camera Files (*.vtkcam)");
+
+ // Open the labels from the selection
+ if(selection.length())
+ LoadCameraViewpoint(selection);
+}
+
+void ViewPanel3D::on_actionExport_Viewpoint_triggered()
+{
+ // Ask for a filename
+ QString selection = ShowSimpleSaveDialogWithHistory(
+ this, m_Model->GetParentUI(), "CameraViewpoint",
+ "Save Camera Viewpoint - ITK-SNAP",
+ "Camera Viewpoint File",
+ "Camera Files (*.vtkcam)",
+ true);
+
+ // Open the labels from the selection
+ if(selection.length())
+ SaveCameraViewpoint(selection);
+}
+
void ViewPanel3D::on_actionContinuous_Update_triggered()
{
ui->btnUpdateMesh->setVisible(!ui->actionContinuous_Update->isChecked());
diff --git a/GUI/Qt/Components/ViewPanel3D.h b/GUI/Qt/Components/ViewPanel3D.h
index d4a46a4c..a36ac4f5 100644
--- a/GUI/Qt/Components/ViewPanel3D.h
+++ b/GUI/Qt/Components/ViewPanel3D.h
@@ -65,6 +65,10 @@ private slots:
void on_actionRestore_Viewpoint_triggered();
+ void on_actionImport_Viewpoint_triggered();
+
+ void on_actionExport_Viewpoint_triggered();
+
void on_actionContinuous_Update_triggered();
void on_btnMenu_pressed();
@@ -105,6 +109,12 @@ private slots:
void UpdateActionButtons();
+ // Load camera viewpoint
+ void LoadCameraViewpoint(QString file);
+
+ // Save camera viewpoint
+ void SaveCameraViewpoint(QString file);
+
// Apply color bar visibility based on the active mesh layer type
void ApplyDefaultColorBarVisibility();
diff --git a/GUI/Qt/Components/ViewPanel3D.ui b/GUI/Qt/Components/ViewPanel3D.ui
index 6f604d47..53633c7d 100644
--- a/GUI/Qt/Components/ViewPanel3D.ui
+++ b/GUI/Qt/Components/ViewPanel3D.ui
@@ -325,6 +325,22 @@ font-size: 11px;
Ctrl+K, R
+
+
+ Import Viewpoint
+
+
+ Ctrl+K, I
+
+
+
+
+ Export Viewpoint
+
+
+ Ctrl+K, E
+
+
true