diff --git a/autoscoper/src/ui/AutoscoperMainWindow.cpp b/autoscoper/src/ui/AutoscoperMainWindow.cpp index e97f8275..f9e8e1e8 100644 --- a/autoscoper/src/ui/AutoscoperMainWindow.cpp +++ b/autoscoper/src/ui/AutoscoperMainWindow.cpp @@ -1130,6 +1130,7 @@ bool AutoscoperMainWindow::openTrial(QString filename){ try { Trial * trial = new Trial(filename.toStdString().c_str()); tracker->load(*trial); + tracker->SetViewportLogic(this->use_new_viewport_logic_); delete trial; trial_filename = filename.toStdString().c_str(); @@ -1721,6 +1722,13 @@ void AutoscoperMainWindow::on_actionLoad_xml_batch_triggered(bool checked){ } } +void AutoscoperMainWindow::on_actionUse_New_Viewport_Logic_triggered(bool checked) { + this->use_new_viewport_logic_ = checked; + if (tracker != NULL) { + tracker->SetViewportLogic(checked); + } +} + //Edit menu void AutoscoperMainWindow::on_actionUndo_triggered(bool checked){ diff --git a/autoscoper/src/ui/AutoscoperMainWindow.h b/autoscoper/src/ui/AutoscoperMainWindow.h index 0e1496b7..b4e5168d 100644 --- a/autoscoper/src/ui/AutoscoperMainWindow.h +++ b/autoscoper/src/ui/AutoscoperMainWindow.h @@ -159,6 +159,7 @@ class AutoscoperMainWindow : public QMainWindow{ Tracker * tracker; GLTracker * gltracker; QOpenGLContext* shared_glcontext; + bool use_new_viewport_logic_ = false; //Manipulator std::vector manipulator; @@ -222,6 +223,7 @@ class AutoscoperMainWindow : public QMainWindow{ void on_actionSave_Test_Sequence_triggered(bool checked); void on_actionSaveForBatch_triggered(bool checked); void on_actionLoad_xml_batch_triggered(bool checked); + void on_actionUse_New_Viewport_Logic_triggered(bool checked); //Edit void on_actionUndo_triggered(bool checked); diff --git a/autoscoper/src/ui/ui-files/AutoscoperMainWindow.ui b/autoscoper/src/ui/ui-files/AutoscoperMainWindow.ui index 601711f8..648b849c 100644 --- a/autoscoper/src/ui/ui-files/AutoscoperMainWindow.ui +++ b/autoscoper/src/ui/ui-files/AutoscoperMainWindow.ui @@ -432,6 +432,8 @@ Dialog + + @@ -717,6 +719,14 @@ Dialog Thick Line Mode + + + true + + + Use New Viewport Logic + + diff --git a/libautoscoper/src/Tracker.cpp b/libautoscoper/src/Tracker.cpp index 054ff19a..04c43e9a 100644 --- a/libautoscoper/src/Tracker.cpp +++ b/libautoscoper/src/Tracker.cpp @@ -601,8 +601,12 @@ std::vector Tracker::trackFrame(unsigned int volumeID, double* xyzypr) // Calculate the size of the image to render based on the viewport // For more information, see https://github.com/BrownBiomechanics/Autoscoper/issues/203 - unsigned render_width = (trial_.render_width * (viewport[2] + 1)) / 2; - unsigned render_height = (trial_.render_height * (viewport[3] + 1)) / 2; + unsigned render_width = viewport[2] * trial_.render_width / views_[i]->camera()->viewport()[2]; + unsigned render_height = viewport[3] * trial_.render_height / views_[i]->camera()->viewport()[3]; + if (this->use_new_viewport_logic_) { + render_width = ((trial_.render_width * (viewport[2] + 1)) / 2) - ((trial_.render_width * (viewport[0] + 1)) / 2); // (width * (max_x + 1)) / 2 - (width * (min_x + 1)) / 2 + render_height = ((trial_.render_height * (viewport[3] + 1)) / 2) - ((trial_.render_height * (viewport[1] + 1)) / 2); // (height * (max_y + 1)) / 2 - (height * (min_y + 1)) / 2 + } if (render_width > trial_.render_width || render_height > trial_.render_height) { throw std::runtime_error("Tracker::trackFrame(): Rendered image is larger than the viewport buffer!\n" + std::to_string(render_width) + " > " + std::to_string(trial_.render_width) + " || " + std::to_string(render_height) + " > " + std::to_string(trial_.render_height)); @@ -882,6 +886,9 @@ void Tracker::getFullDRR(unsigned int volumeID) const } } +void Tracker::SetViewportLogic(bool use_new) { + this->use_new_viewport_logic_ = use_new; +} diff --git a/libautoscoper/src/Tracker.hpp b/libautoscoper/src/Tracker.hpp index 2156a634..03c34bd4 100644 --- a/libautoscoper/src/Tracker.hpp +++ b/libautoscoper/src/Tracker.hpp @@ -101,6 +101,7 @@ namespace xromm //std::vector trackImplantFrame(unsigned int volumeID, double * xyzypr) const; void getFullDRR(unsigned int volumeID) const; + void SetViewportLogic(bool use_new); private: @@ -111,6 +112,7 @@ namespace xromm Trial trial_; std::vector volumeDescription_; std::vector views_; + bool use_new_viewport_logic_ = false; #if defined(Autoscoper_RENDERING_USE_CUDA_BACKEND) Buffer* rendered_drr_; Buffer* rendered_rad_;