Skip to content

Commit 5b6d334

Browse files
committed
Better way to time resize slot
1 parent f41488f commit 5b6d334

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/Interface/Modules/Render/ViewScene.cc

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ ViewSceneDialog::ViewSceneDialog(const std::string& name, ModuleStateHandle stat
145145
std::string sep;
146146
sep += boost::filesystem::path::preferred_separator;
147147
Modules::Visualization::TextBuilder::setFSStrings(filesystemRoot, sep);
148+
149+
resizeTimer_.setSingleShot(true);
150+
connect(&resizeTimer_, SIGNAL(timeout()), this, SLOT(resizingDone()));
148151
}
149152

150153
void ViewSceneDialog::pullSpecial()
@@ -214,23 +217,17 @@ void ViewSceneDialog::mousePressEvent(QMouseEvent* event)
214217

215218
void ViewSceneDialog::resizeEvent(QResizeEvent *event)
216219
{
217-
static boost::timer timer;
218-
static Mutex lock("VS::resize");
219-
220-
{
221-
Guard g(lock.get());
222-
if (timer.elapsed() > 1)
223-
{
224-
timer.restart();
225-
ViewSceneFeedback vsf;
226-
vsf.windowSize = std::make_tuple(event->size().width(), event->size().height());
227-
state_->setTransientValue(Parameters::GeometryFeedbackInfo, vsf);
228-
}
229-
}
230-
220+
resizeTimer_.start(500);
231221
ModuleDialogGeneric::resizeEvent(event);
232222
}
233223

224+
void ViewSceneDialog::resizingDone()
225+
{
226+
ViewSceneFeedback vsf;
227+
vsf.windowSize = std::make_tuple(size().width(), size().height());
228+
state_->setTransientValue(Parameters::GeometryFeedbackInfo, vsf);
229+
}
230+
234231
std::string ViewSceneDialog::restoreObjColor()
235232
{
236233
LOG_DEBUG("ViewSceneDialog::asyncExecute before locking");

src/Interface/Modules/Render/ViewScene.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace SCIRun {
7070
void newGeometryValueForwarder();
7171
void mousePressSignalForTestingGeometryObjectFeedback(int x, int y, const std::string& selName);
7272

73-
protected Q_SLOTS:
73+
protected Q_SLOTS:
7474
void menuMouseControlChanged(int index);
7575
void autoViewClicked();
7676
void newGeometryValue();
@@ -139,6 +139,7 @@ namespace SCIRun {
139139
void toggleLight1(bool value);
140140
void toggleLight2(bool value);
141141
void toggleLight3(bool value);
142+
void resizingDone();
142143

143144
protected:
144145
void mousePressEvent(QMouseEvent* event) override;
@@ -232,6 +233,7 @@ namespace SCIRun {
232233
class Screenshot* screenshotTaker_;
233234
bool saveScreenshotOnNewGeometry_;
234235
bool pulledSavedVisibility_ {false};
236+
QTimer resizeTimer_;
235237

236238
//geometries
237239
Modules::Visualization::TextBuilder textBuilder_;

0 commit comments

Comments
 (0)