55#include " dataManager.h"
66#include " drawingPass.h"
77
8+ #include < sstream>
9+ #include < iomanip>
10+
811#include < nanogui/window.h>
912#include < nanogui/colorpicker.h>
1013#include < nanogui/combobox.h>
@@ -97,6 +100,7 @@ namespace poncaplot {
97100 b->set_callback ([&] {
98101 auto path = file_dialog (
99102 {{" png" , " PNG image" }}, true );
103+ if (path.empty ()) return ;
100104 std::cout << " Save file to: " << path << std::endl;
101105
102106 size_t factor = 2 ;
@@ -105,6 +109,31 @@ namespace poncaplot {
105109 write_image (tex_width*factor, tex_height*factor, texture, path);
106110 delete [] (texture);
107111 });
112+ b = new Button (tools, " Save sequence (scale)" );
113+ b->set_callback ([&] {
114+ auto path = file_dialog (
115+ {{" " , " basename" }}, true );
116+ if (path.empty ()) return ;
117+ std::cout << " Save sequence to: " << path << std::endl;
118+
119+ size_t factor = 2 ;
120+ float *texture = new float [factor * tex_width * tex_height * 4 ];
121+ auto prev = scaleSlider->value ();
122+ int start {int (scaleSlider->range ().first )};
123+ int end {int (scaleSlider->range ().second )};
124+ int length = end-start;
125+ for (int i = 0 ; i < length; ++i)
126+ {
127+ scaleSlider->callback ()(float (start+i));
128+ std::ostringstream oss;
129+ oss << path << std::setfill (' 0' ) << std::setw (4 ) << i << " .png" ;
130+ renderPassesInternal (factor, texture);
131+ write_image (tex_width*factor, tex_height*factor, texture, oss.str ());
132+ }
133+ scaleSlider->set_value (prev);
134+ scaleSlider->callback ()(prev);
135+ delete [] (texture);
136+ });
108137 }
109138
110139 window = new Window (this , " Fitting Controls" );
@@ -176,10 +205,10 @@ namespace poncaplot {
176205 renderPasses ();
177206 });
178207 new nanogui::Label (genericFitWidget, " Scale" );
179- auto slider = new Slider (genericFitWidget);
180- slider ->set_value (passPlaneFit->params .m_scale ); // init with plane, but sync with current.
181- slider ->set_range ({10 , 750 });
182- slider ->set_callback ([&](float value) {
208+ scaleSlider = new Slider (genericFitWidget);
209+ scaleSlider ->set_value (passPlaneFit->params .m_scale ); // init with plane, but sync with current.
210+ scaleSlider ->set_range ({10 , 750 });
211+ scaleSlider ->set_callback ([&](float value) {
183212 passPlaneFit->params .m_scale = value;
184213 passSphereFit->params .m_scale = value;
185214 passOrientedSphereFit->params .m_scale = value;
0 commit comments