diff Framework/Widgets/TestWorldSceneWidget.cpp @ 46:766d31dc5716 wasm

removing threads for wasm
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 19 Apr 2017 14:33:06 +0200
parents 7207a407bcd8
children 25befef48c35
line wrap: on
line diff
--- a/Framework/Widgets/TestWorldSceneWidget.cpp	Wed Apr 19 10:28:08 2017 +0200
+++ b/Framework/Widgets/TestWorldSceneWidget.cpp	Wed Apr 19 14:33:06 2017 +0200
@@ -106,7 +106,7 @@
 
 
     bool TestWorldSceneWidget::RenderScene(CairoContext& context,
-                                           const ViewportGeometry& view)
+                                           const ViewportGeometry& view) 
     {
       cairo_t* cr = context.GetObject();
 
@@ -114,7 +114,8 @@
       cairo_set_source_rgb(cr, 0, 0, 0);
       cairo_paint(cr);
 
-      cairo_set_source_rgb(cr, 0, 1, 0);
+      float color = static_cast<float>(count_ % 16) / 15.0f;
+      cairo_set_source_rgb(cr, 0, 1.0f - color, color);
       cairo_rectangle(cr, -10, -.5, 20, 1);
       cairo_fill(cr);
 
@@ -122,8 +123,10 @@
     }
 
 
-    TestWorldSceneWidget::TestWorldSceneWidget() :
-      interactor_(new Interactor)
+    TestWorldSceneWidget::TestWorldSceneWidget(bool animate) :
+      interactor_(new Interactor),
+      animate_(animate),
+      count_(0)
     {
       SetInteractor(*interactor_);
     }
@@ -139,5 +142,19 @@
       y1 = -.5;
       y2 = .5;
     }
+
+
+    void TestWorldSceneWidget::UpdateContent()
+    {
+      if (animate_)
+      {
+        count_++;
+        NotifyChange();
+      }
+      else
+      {
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
+      }
+    }
   }
 }