comparison 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
comparison
equal deleted inserted replaced
45:ecd96e563929 46:766d31dc5716
104 } 104 }
105 }; 105 };
106 106
107 107
108 bool TestWorldSceneWidget::RenderScene(CairoContext& context, 108 bool TestWorldSceneWidget::RenderScene(CairoContext& context,
109 const ViewportGeometry& view) 109 const ViewportGeometry& view)
110 { 110 {
111 cairo_t* cr = context.GetObject(); 111 cairo_t* cr = context.GetObject();
112 112
113 // Clear background 113 // Clear background
114 cairo_set_source_rgb(cr, 0, 0, 0); 114 cairo_set_source_rgb(cr, 0, 0, 0);
115 cairo_paint(cr); 115 cairo_paint(cr);
116 116
117 cairo_set_source_rgb(cr, 0, 1, 0); 117 float color = static_cast<float>(count_ % 16) / 15.0f;
118 cairo_set_source_rgb(cr, 0, 1.0f - color, color);
118 cairo_rectangle(cr, -10, -.5, 20, 1); 119 cairo_rectangle(cr, -10, -.5, 20, 1);
119 cairo_fill(cr); 120 cairo_fill(cr);
120 121
121 return true; 122 return true;
122 } 123 }
123 124
124 125
125 TestWorldSceneWidget::TestWorldSceneWidget() : 126 TestWorldSceneWidget::TestWorldSceneWidget(bool animate) :
126 interactor_(new Interactor) 127 interactor_(new Interactor),
128 animate_(animate),
129 count_(0)
127 { 130 {
128 SetInteractor(*interactor_); 131 SetInteractor(*interactor_);
129 } 132 }
130 133
131 134
137 x1 = -10; 140 x1 = -10;
138 x2 = 10; 141 x2 = 10;
139 y1 = -.5; 142 y1 = -.5;
140 y2 = .5; 143 y2 = .5;
141 } 144 }
145
146
147 void TestWorldSceneWidget::UpdateContent()
148 {
149 if (animate_)
150 {
151 count_++;
152 NotifyChange();
153 }
154 else
155 {
156 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
157 }
158 }
142 } 159 }
143 } 160 }