Bug Summary

File:home/HaikuArchives/ArtPaint/addons/AddOns/Wave/Wave.cpp
Warning:line 235, column 13
Value stored to 'floor_x' during its initialization is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-haiku -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name Wave.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /boot/system/lib/clang/12.0.1 -iquote ./ -iquote ../../UtilityClasses/ -iquote ./ -iquote ../../../artpaint/application -iquote ../../../artpaint/controls -iquote ../../../artpaint/layers -iquote ../../../artpaint/paintwindow -iquote ../../../artpaint/tools -iquote ../../../artpaint/viewmanipulators -iquote ../../../artpaint/windows -internal-isystem /system/develop/headers/c++ -internal-isystem /system/develop/headers/c++/x86_64-unknown-haiku -internal-isystem /system/develop/headers/c++/backward -O3 -fdeprecated-macro -fdebug-compilation-dir /boot/home/HaikuArchives/ArtPaint/addons/AddOns/Wave -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /tmp/scan-build-2022-07-02-122529-1240-1 -x c++ Wave.cpp
1/*
2 * Copyright 2003, Heikki Suhonen
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 * Heikki Suhonen <heikki.suhonen@gmail.com>
7 *
8 */
9#include <Bitmap.h>
10#include <Catalog.h>
11#include <math.h>
12#include <LayoutBuilder.h>
13#include <Slider.h>
14#include <StatusBar.h>
15#include <StopWatch.h>
16#include <Window.h>
17
18#include "AddOns.h"
19#include "ManipulatorInformer.h"
20#include "Wave.h"
21#include "PixelOperations.h"
22#include "Selection.h"
23
24#define PI3.14159265358979323846 M_PI3.14159265358979323846
25
26#undef B_TRANSLATION_CONTEXT"AddOns_Wave"
27#define B_TRANSLATION_CONTEXT"AddOns_Wave" "AddOns_Wave"
28
29
30#ifdef __cplusplus201402L
31extern "C" {
32#endif
33 char name[255] = B_TRANSLATE_MARK("Wave" B_UTF8_ELLIPSIS)("Wave" "\xE2\x80\xA6");
34 char menu_help_string[255] = B_TRANSLATE_MARK("Adds a wave to the active layer.")("Adds a wave to the active layer.");
35 int32 add_on_api_version = ADD_ON_API_VERSION;
36 add_on_types add_on_type = DISTORT_ADD_ON;
37#ifdef __cplusplus201402L
38}
39#endif
40
41
42Manipulator* instantiate_add_on(BBitmap *bm,ManipulatorInformer *i)
43{
44 // Here create a view-manipulator. The class should inherit
45 // from WindowGuiManipulator base-class. It will be deleted
46 // in the application program.
47 delete i;
48 return new WaveManipulator(bm);
49}
50
51
52
53WaveManipulator::WaveManipulator(BBitmap *bm)
54 : WindowGUIManipulator()
55{
56 last_calculated_resolution = 8;
57 lowest_available_quality = 8;
58
59 copy_of_the_preview_bitmap = NULL__null;
60 preview_bitmap = NULL__null;
61 config_view = NULL__null;
62
63 SetPreviewBitmap(bm);
64
65 sin_table = new float[720];
66 for (int32 i=0;i<720;i++)
67 sin_table[i] = sin((float)i/720.0*2*PI3.14159265358979323846);
68}
69
70
71WaveManipulator::~WaveManipulator()
72{
73 delete[] sin_table;
74 delete copy_of_the_preview_bitmap;
75
76 if (config_view != NULL__null) {
77 config_view->RemoveSelf();
78 delete config_view;
79 config_view = NULL__null;
80 }
81}
82
83
84BBitmap* WaveManipulator::ManipulateBitmap(ManipulatorSettings *set,BBitmap *original,Selection *selection,BStatusBar *status_bar)
85{
86 WaveManipulatorSettings *new_settings = dynamic_cast<WaveManipulatorSettings*>(set);
87
88 if (new_settings == NULL__null)
89 return NULL__null;
90
91 if (original == NULL__null)
92 return NULL__null;
93
94 BBitmap *source_bitmap;
95 BBitmap *target_bitmap;
96 BBitmap *new_bitmap=NULL__null;
97
98 if (original == preview_bitmap) {
99 target_bitmap = original;
100 source_bitmap = copy_of_the_preview_bitmap;
101 }
102 else {
103 target_bitmap = original;
104 new_bitmap = DuplicateBitmap(original,0);
105 source_bitmap = new_bitmap;
106 }
107
108
109 uint32 *source_bits = (uint32*)source_bitmap->Bits();
110 uint32 *target_bits = (uint32*)target_bitmap->Bits();
111 int32 source_bpr = source_bitmap->BytesPerRow()/4;
112 int32 target_bpr = target_bitmap->BytesPerRow()/4;
113
114 int32 start_y = target_bitmap->Bounds().top;
115 int32 end_y = target_bitmap->Bounds().bottom;
116
117 target_bits += start_y * target_bpr;
118
119 BMessage progress_message = BMessage(B_UPDATE_STATUS_BAR);
120 progress_message.AddFloat("delta",0.0);
121
122 float s = new_settings->wave_length;
123 float A = new_settings->wave_amount;
124 float k = 0;
125 float dx = 0;
126 float dy = 0;
127 float sqrt_x_plus_y;
128 float one_per_sqrt_x_plus_y;
129 float cx,cy;
130 int32 top,bottom;
131 top = start_y;
132 bottom = end_y;
133
134 cx = floor(new_settings->center.x);
135 cy = floor(new_settings->center.y);
136 float R = sqrt(pow(max_c(fabs(cx),target_bpr-fabs(cx))((fabs(cx))>(target_bpr-fabs(cx))?(fabs(cx)):(target_bpr-fabs
(cx)))
,2)+pow(max_c(fabs(cy),end_y-fabs(cy))((fabs(cy))>(end_y-fabs(cy))?(fabs(cy)):(end_y-fabs(cy))),2));
137 float one_per_R = 1.0/R;
138
139 float real_x,real_y;
140 float two_pi_per_s = 2*PI3.14159265358979323846/s;
141
142 union {
143 uint8 bytes[4];
144 uint32 word;
145 } background;
146
147 background.bytes[0] = 0xFF;
148 background.bytes[1] = 0xFF;
149 background.bytes[2] = 0xFF;
150 background.bytes[3] = 0x00;
151
152 if ((selection == NULL__null) || (selection->IsEmpty())) {
153 uint32 p1,p2,p3,p4;
154 float float_end_y = end_y;
155 float float_target_bpr = target_bpr;
156 for (float y=start_y;y<=float_end_y;y++) {
157 for (float x=0;x<float_target_bpr;x++) {
158 real_x = x-cx;
159 real_y = y-cy;
160 uint32 target_value = 0x00000000;
161 if ((real_x != 0) && (real_y != 0)) {
162 sqrt_x_plus_y = sqrt(real_x*real_x+real_y*real_y);
163 dx = real_x/sqrt_x_plus_y*A*sin(sqrt_x_plus_y*two_pi_per_s); // The sin and div are slow.
164 dx = dx*(1-k*sqrt_x_plus_y*one_per_R);
165 dy = dx/real_x*real_y;
166 int32 ceil_y = ceil(y+dy);
167 int32 floor_y = ceil_y -1;
168 int32 floor_x = floor(x+dx);
169 int32 ceil_x = floor_x+1;
170
171 float v = ceil_y-(y+dy);
172 float u = (x+dx)-floor_x;
173 if ((ceil_y <= bottom) && (ceil_y>=top)) {
174 if ((floor_x >= 0) && (floor_x <source_bpr)) {
175 p1 = *(source_bits + ceil_y*source_bpr + floor_x);
176 }
177 else
178 p1 = background.word;
179
180 if ((ceil_x >= 0) && (ceil_x <source_bpr)) {
181 p2 = *(source_bits + ceil_y*source_bpr + ceil_x);
182 }
183 else
184 p2 = background.word;
185 }
186 else {
187 p1 = background.word;
188 p2 = background.word;
189 }
190 if ((floor_y <= bottom) && (floor_y>=top)) {
191 if ((floor_x >= 0) && (floor_x <source_bpr)) {
192 p3 = *(source_bits + floor_y*source_bpr + floor_x);
193 }
194 else
195 p3 = background.word;
196
197 if ((ceil_x >= 0) && (ceil_x <source_bpr)) {
198 p4 = *(source_bits + floor_y*source_bpr + ceil_x);
199 }
200 else
201 p4 = background.word;
202 }
203 else {
204 p3 = background.word;
205 p4 = background.word;
206 }
207 *target_bits++ = bilinear_interpolation(p1,p2,p3,p4,u,v);
208 }
209 else {
210 if (real_x != 0) {
211 sqrt_x_plus_y = sqrt(real_x*real_x);
212 dx = real_x/sqrt_x_plus_y*A*sin(sqrt_x_plus_y*two_pi_per_s);
213 dx = dx*(1-k*sqrt_x_plus_y/R);
214 int32 ceil_y = ceil(y+dy);
215 int32 floor_x = floor(x+dx);
216 int32 ceil_x = floor_x+1;
217 float x_mix_right = (x+dx)-floor_x;
218 if ((ceil_x >= 0) && (ceil_x<target_bpr))
219 p1 = *(source_bits + (int32)y*target_bpr + ceil_x);
220 else
221 p1 = background.word;
222
223 if ((floor_x >= 0) && (floor_x<target_bpr))
224 p2 = *(source_bits + (int32)y*target_bpr + floor_x);
225 else
226 p2 = background.word;
227 *target_bits++ = mix_2_pixels_fixed(p1,p2,32768*x_mix_right);
228 }
229 else if (real_y != 0) {
230 sqrt_x_plus_y = sqrt(real_y*real_y);
231 dy = real_y/sqrt_x_plus_y*A*sin(sqrt_x_plus_y*two_pi_per_s);
232 dy = dy*(1-k*sqrt_x_plus_y/R);
233 int32 ceil_y = ceil(y+dy);
234 int32 floor_y = ceil_y -1;
235 int32 floor_x = floor(x+dx);
Value stored to 'floor_x' during its initialization is never read
236 float y_mix_upper = ceil(y+dy)-(y+dy);
237 if ((ceil_y<=bottom) && (ceil_y >= top))
238 p1 = *(source_bits + (int32)x + ceil_y*target_bpr);
239 else
240 p1 = background.word;
241
242 if ((floor_y<=bottom) && (floor_y >= top))
243 p2 = *(source_bits + (int32)x + floor_y*target_bpr);
244 else
245 p2 = background.word;
246 *target_bits++ = mix_2_pixels_fixed(p2,p1,32768*y_mix_upper);
247 }
248 else {
249 *target_bits++ = *(source_bits + (int32)x + (int32)y*source_bpr);
250 }
251 }
252
253 }
254 // Send a progress-message if required
255 if ((status_bar != NULL__null) && ((int32)y%10 == 0)) {
256 progress_message.ReplaceFloat("delta",100.0/(float)(end_y-start_y)*10.0);
257 status_bar->Window()->PostMessage(&progress_message,status_bar);
258 }
259 }
260 }
261 else {
262 uint32 p1,p2,p3,p4;
263 for (float y=start_y;y<=end_y;y++) {
264 for (float x=0;x<target_bpr;x++) {
265 if (selection->ContainsPoint(x,y) == TRUE1) {
266 real_x = x-cx;
267 real_y = y-cy;
268 uint32 target_value = 0x00000000;
269 if ((real_x != 0) && (real_y != 0)) {
270 sqrt_x_plus_y = sqrt(real_x*real_x+real_y*real_y);
271 dx = real_x/sqrt_x_plus_y*A*sin(sqrt_x_plus_y*two_pi_per_s); // The sin and div are slow.
272 dx = dx*(1-k*sqrt_x_plus_y/R);
273 dy = dx/real_x*real_y;
274 float y_mix_upper = ceil(y+dy)-(y+dy);
275 float x_mix_right = (x+dx)- floor(x+dx);
276 if ((ceil(y+dy) <= bottom) && (ceil(y+dy)>=top)) {
277 if ((floor(x+dx) >= 0) && (floor(x+dx) <source_bpr)) {
278 p1 = *(source_bits + (int32)ceil(y+dy)*source_bpr + (int32)floor(x+dx));
279 }
280 else
281 p1 = background.word;
282
283 if ((ceil(x+dx) >= 0) && (ceil(x+dx) <source_bpr)) {
284 p2 = *(source_bits + (int32)ceil(y+dy)*source_bpr + (int32)ceil(x+dx));
285 }
286 else
287 p2 = background.word;
288 }
289 else {
290 p1 = background.word;
291 p2 = background.word;
292 }
293 if ((floor(y+dy) <= bottom) && (floor(y+dy)>=top)) {
294 if ((floor(x+dx) >= 0) && (floor(x+dx) <source_bpr)) {
295 p3 = *(source_bits + (int32)floor(y+dy)*source_bpr + (int32)floor(x+dx));
296 }
297 else
298 p3 = background.word;
299
300 if ((ceil(x+dx) >= 0) && (ceil(x+dx) <source_bpr)) {
301 p4 = *(source_bits + (int32)floor(y+dy)*source_bpr + (int32)ceil(x+dx));
302 }
303 else
304 p4 = background.word;
305 }
306 else {
307 p3 = background.word;
308 p4 = background.word;
309 }
310 *target_bits++ = combine_4_pixels(p1,p2,p3,p4,(1-y_mix_upper)*(1-x_mix_right),(1-y_mix_upper)*(x_mix_right),(y_mix_upper)*(1-x_mix_right),(y_mix_upper)*(x_mix_right));
311 }
312 else {
313 if (real_x != 0) {
314 sqrt_x_plus_y = sqrt(real_x*real_x);
315 dx = real_x/sqrt_x_plus_y*A*sin(sqrt_x_plus_y*two_pi_per_s);
316 dx = dx*(1-k*sqrt_x_plus_y/R);
317 float x_mix_right = (x+dx)-floor(x+dx);
318 if ((ceil(x+dx) >= 0) && (ceil(x+dx)<target_bpr))
319 p1 = *(source_bits + (int32)y*target_bpr + (int32)ceil((x +dx)));
320 else
321 p1 = background.word;
322
323 if ((floor(x+dx) >= 0) && (floor(x+dx)<target_bpr))
324 p2 = *(source_bits + (int32)y*target_bpr + (int32)floor((x +dx)));
325 else
326 p2 = background.word;
327 *target_bits++ = mix_2_pixels_fixed(p1,p2,32768*x_mix_right);
328 }
329 else if (real_y != 0) {
330 sqrt_x_plus_y = sqrt(real_y*real_y);
331 dy = real_y/sqrt_x_plus_y*A*sin(sqrt_x_plus_y*two_pi_per_s);
332 dy = dy*(1-k*sqrt_x_plus_y/R);
333 float y_mix_upper = ceil(y+dy)-(y+dy);
334 if ((ceil(y+dy)<=bottom) && (ceil(y+dy) >= top))
335 p1 = *(source_bits + (int32)x + (int32)ceil((y + dy))*target_bpr);
336 else
337 p1 = background.word;
338
339 if ((floor(y+dy)<=bottom) && (floor(y+dy) >= top))
340 p2 = *(source_bits + (int32)x + (int32)floor((y + dy))*target_bpr);
341 else
342 p2 = background.word;
343 *target_bits++ = mix_2_pixels_fixed(p2,p1,32768*y_mix_upper);
344 }
345 else {
346 *target_bits++ = *(source_bits + (int32)x + (int32)y*source_bpr);
347 }
348 }
349 }
350 else {
351 *target_bits++ = *(source_bits + (int32)x + (int32)y*source_bpr);
352 }
353 }
354 // Send a progress-message if required
355 if ((status_bar != NULL__null) && ((int32)y%10 == 0)) {
356 progress_message.ReplaceFloat("delta",100.0/(float)(end_y-start_y)*10.0);
357 status_bar->Window()->PostMessage(&progress_message,status_bar);
358 }
359 }
360 }
361
362 if (new_bitmap != NULL__null) {
363 delete new_bitmap;
364 }
365
366 return original;
367}
368
369int32 WaveManipulator::PreviewBitmap(Selection *selection,bool full_quality,BRegion *updated_region)
370{
371 if ((settings == previous_settings) == FALSE0) {
372 previous_settings = settings;
373 last_calculated_resolution = lowest_available_quality;
374 }
375 else {
376 last_calculated_resolution = max_c(highest_available_quality,floor(last_calculated_resolution/2.0))((highest_available_quality)>(floor(last_calculated_resolution
/2.0))?(highest_available_quality):(floor(last_calculated_resolution
/2.0)))
;
377 }
378 if (full_quality == TRUE1)
379 last_calculated_resolution = min_c(last_calculated_resolution,1)((last_calculated_resolution)>(1)?(1):(last_calculated_resolution
))
;
380
381 uint32 *source_bits = (uint32*)copy_of_the_preview_bitmap->Bits();
382 uint32 *target_bits = (uint32*)preview_bitmap->Bits();
383 int32 source_bpr = copy_of_the_preview_bitmap->BytesPerRow()/4;
384 int32 target_bpr = preview_bitmap->BytesPerRow()/4;
385
386 int32 start_y = preview_bitmap->Bounds().top;
387 int32 end_y = preview_bitmap->Bounds().bottom;
388
389 union {
390 uint8 bytes[4];
391 uint32 word;
392 } background;
393
394 background.bytes[0] = 0xFF;
395 background.bytes[1] = 0xFF;
396 background.bytes[2] = 0xFF;
397 background.bytes[3] = 0x00;
398
399 if (last_calculated_resolution > 0) {
400 float real_x;
401 float real_y;
402 float one_per_sqrt_x_plus_y;
403 float sqrt_x_plus_y;
404 float cx = settings.center.x;
405 float cy = settings.center.y;
406 float dx;
407 float dy;
408 float A = settings.wave_amount;
409 float s = settings.wave_length;
410 float two_360_per_s = 720.0/s;
411 float k = 0;
412 float R = sqrt(pow(max_c(fabs(cx),target_bpr-fabs(cx))((fabs(cx))>(target_bpr-fabs(cx))?(fabs(cx)):(target_bpr-fabs
(cx)))
,2)+pow(max_c(fabs(cy),end_y-fabs(cy))((fabs(cy))>(end_y-fabs(cy))?(fabs(cy)):(end_y-fabs(cy))),2));
413 if (selection->IsEmpty()) {
414 for (float y=start_y;y<=end_y;y += last_calculated_resolution) {
415 int32 y_target_bpr = y*target_bpr;
416 for (float x=0;x<source_bpr;x += last_calculated_resolution) {
417 real_x = x-cx;
418 real_y = y-cy;
419 if ((real_x != 0) && (real_y != 0)) {
420 // Let's try the inline assemler function for square root estimation.
421 // On intel this does not yet work and the corresponding function is very slow.
422 #ifdef __POWERPC__
423 one_per_sqrt_x_plus_y = reciprocal_of_square_root(real_x*real_x+real_y*real_y);
424 sqrt_x_plus_y = 1.0/one_per_sqrt_x_plus_y;
425 #else
426// sqrt_x_plus_y = fsqrt(real_x*real_x+real_y*real_y);
427 sqrt_x_plus_y = sqrt(real_x*real_x+real_y*real_y);
428 one_per_sqrt_x_plus_y = 1.0 / sqrt_x_plus_y;
429 #endif
430
431 dx = one_per_sqrt_x_plus_y*A*sin_table[(int32)(sqrt_x_plus_y*two_360_per_s)%720];
432 dx = dx*(1-k*sqrt_x_plus_y/R);
433 dy = dx*real_y;
434 dx = dx*real_x;
435 // This if is quite slow.
436 if (((y+dy) <= end_y) && ((y+dy)>=0) && ((x+dx) >= 0) && ((x+dx)<target_bpr)) {
437 *(target_bits + (int32)x + y_target_bpr) = *(source_bits + (int32)(x+dx) + (int32)(y+dy)*source_bpr);
438 }
439 else {
440 *(target_bits +(int32)x + y_target_bpr) = background.word;
441 }
442 }
443 else {
444 if (real_x != 0) {
445 // We also have to estimate the sqrt here.
446 one_per_sqrt_x_plus_y = reciprocal_of_square_root(real_x*real_x);
447 sqrt_x_plus_y = 1/one_per_sqrt_x_plus_y;
448 dx = one_per_sqrt_x_plus_y*A*sin_table[(int32)(sqrt_x_plus_y*two_360_per_s)%720]*real_x;
449 dx = dx*(1-k*sqrt_x_plus_y/R);
450 if (((x+dx) >= 0) && ((x+dx)<target_bpr))
451 *(target_bits +(int32)x +y_target_bpr) = *(source_bits + (int32)y*target_bpr + (int32)(x +dx));
452 else
453 *(target_bits +(int32)x + y_target_bpr)= background.word;
454 }
455 else if (real_y != 0) {
456 one_per_sqrt_x_plus_y = reciprocal_of_square_root(real_y*real_y);
457 sqrt_x_plus_y = 1/one_per_sqrt_x_plus_y;
458 dy = one_per_sqrt_x_plus_y*A*sin_table[(int32)(sqrt_x_plus_y*two_360_per_s)%720]*real_y;
459 dy = dy*(1-k*sqrt_x_plus_y/R);
460 if (((y+dy)<=end_y) && ((y+dy) >= 0))
461 *(target_bits +(int32)x + y_target_bpr) = *(source_bits + (int32)x + (int32)(y + dy)*source_bpr);
462 else
463 *(target_bits +(int32)x +y_target_bpr) = background.word;
464 }
465 else {
466 *(target_bits +(int32)x +y_target_bpr) = *(source_bits + (int32)x + (int32)y*source_bpr);
467 }
468 }
469 }
470 }
471 }
472 else {
473 for (float y=start_y;y<=end_y;y += last_calculated_resolution) {
474 int32 y_target_bpr = y*target_bpr;
475 for (float x=0;x<source_bpr;x += last_calculated_resolution) {
476 real_x = x-cx;
477 real_y = y-cy;
478 if (selection->ContainsPoint(x,y) == TRUE1) {
479 if ((real_x != 0) && (real_y != 0)) {
480 // Let's try the inline assemler function for square root estimation
481 #ifdef __POWERPC__
482 one_per_sqrt_x_plus_y = reciprocal_of_square_root(real_x*real_x+real_y*real_y);
483 sqrt_x_plus_y = 1.0/one_per_sqrt_x_plus_y;
484 #else
485// sqrt_x_plus_y = fsqrt(real_x*real_x+real_y*real_y);
486 sqrt_x_plus_y = sqrt(real_x*real_x+real_y*real_y);
487 one_per_sqrt_x_plus_y = 1.0 / sqrt_x_plus_y;
488 #endif
489 dx = one_per_sqrt_x_plus_y*A*sin_table[(int32)(sqrt_x_plus_y*two_360_per_s)%720];
490 dx = dx*(1-k*sqrt_x_plus_y/R);
491 dy = dx*real_y;
492 dx = dx*real_x;
493 // This if is quite slow.
494 if (((y+dy) <= end_y) && ((y+dy)>=0) && ((x+dx) >= 0) && ((x+dx)<target_bpr)) {
495 *(target_bits + (int32)x + y_target_bpr) = *(source_bits + (int32)(x+dx) + (int32)(y+dy)*source_bpr);
496 }
497 else {
498 *(target_bits +(int32)x + y_target_bpr) = background.word;
499 }
500 }
501 else {
502 if (real_x != 0) {
503 // We also have to estimate the sqrt here.
504 one_per_sqrt_x_plus_y = reciprocal_of_square_root(real_x*real_x);
505 sqrt_x_plus_y = 1/one_per_sqrt_x_plus_y;
506 dx = one_per_sqrt_x_plus_y*A*sin_table[(int32)(sqrt_x_plus_y*two_360_per_s)%720]*real_x;
507 dx = dx*(1-k*sqrt_x_plus_y/R);
508 if (((x+dx) >= 0) && ((x+dx)<target_bpr))
509 *(target_bits +(int32)x +y_target_bpr) = *(source_bits + (int32)y*target_bpr + (int32)(x +dx));
510 else
511 *(target_bits +(int32)x + y_target_bpr)= background.word;
512 }
513 else if (real_y != 0) {
514 one_per_sqrt_x_plus_y = reciprocal_of_square_root(real_y*real_y);
515 sqrt_x_plus_y = 1/one_per_sqrt_x_plus_y;
516 dy = one_per_sqrt_x_plus_y*A*sin_table[(int32)(sqrt_x_plus_y*two_360_per_s)%720]*real_y;
517 dy = dy*(1-k*sqrt_x_plus_y/R);
518 if (((y+dy)<=end_y) && ((y+dy) >= 0))
519 *(target_bits +(int32)x + y_target_bpr) = *(source_bits + (int32)x + (int32)(y + dy)*source_bpr);
520 else
521 *(target_bits +(int32)x +y_target_bpr) = background.word;
522 }
523 else {
524 *(target_bits +(int32)x +y_target_bpr) = *(source_bits + (int32)x + (int32)y*source_bpr);
525 }
526 }
527 }
528 else {
529 *(target_bits +(int32)x +y_target_bpr) = *(source_bits + (int32)x + (int32)y*source_bpr);
530 }
531 }
532 }
533 }
534 }
535 updated_region->Set(preview_bitmap->Bounds());
536 return last_calculated_resolution;
537}
538
539
540void WaveManipulator::MouseDown(BPoint point,uint32,BView*,bool first_click)
541{
542 if (first_click == TRUE1)
543 previous_settings = settings;
544
545 settings.center = point;
546 if (config_view != NULL__null)
547 config_view->ChangeSettings(&settings);
548}
549
550
551
552
553//int32 WaveManipulator::wave_func(uint32 *target_bits,uint32 *source_bits,int32 target_bpr,int32 source_bpr,int32 start_y,int32 end_y,int32 amount_of_wave,int32 length_of_wave,int32 dampening_of_wave,float center_x, float center_y,float top_of_image,float bottom_of_image)
554//{
555// // First move the bits to right starting positions.
556// // In this manipulator do not move the source bits, because it will be
557// // 'indexed' directly.
558//// source_bits += start_y * source_bpr;
559// target_bits += start_y * target_bpr;
560//
561// BMessage progress_message = BMessage(B_UPDATE_STATUS_BAR);
562// progress_message.AddFloat("delta",0.0);
563//
564// BStopWatch *watch = new BStopWatch("Wave Time");
565//
566// float s = length_of_wave;
567// float A = amount_of_wave;
568// float k = (float)(dampening_of_wave)/(float)MAX_WAVE_DAMPENING;
569// float dx,dy;
570// float sqrt_x_plus_y;
571// float one_per_sqrt_x_plus_y;
572// float cx,cy;
573// float top,bottom;
574// top = top_of_image;
575// bottom = bottom_of_image;
576//
577// cx = floor(center_x);
578// cy = floor(center_y);
579// float R = sqrt(pow(max_c(abs(cx),target_bpr-abs(cx)),2)+pow(max_c(abs(cy),bottom_of_image-abs(cy)),2));
580//
581//
582// float real_x,real_y;
583// float two_pi_per_s = 2*PI/s;
584// float two_360_per_s = 720.0/s;
585//
586// if (preview_level == FULL_CALCULATION) {
587// uint32 p1,p2,p3,p4;
588// for (float y=start_y;y<=end_y;y++) {
589// for (float x=0;x<source_bpr;x++) {
590// real_x = x-cx;
591// real_y = y-cy;
592// uint32 target_value = 0x00000000;
593// if ((real_x != 0) && (real_y != 0)) {
594// sqrt_x_plus_y = sqrt(real_x*real_x+real_y*real_y);
595// dx = real_x/sqrt_x_plus_y*A*sin(sqrt_x_plus_y*two_pi_per_s); // The sin and div are slow.
596// dx = dx*(1-k*sqrt_x_plus_y/R);
597// dy = dx/real_x*real_y;
598// float y_mix_upper = ceil(y+dy)-(y+dy);
599// float x_mix_right = (x+dx)- floor(x+dx);
600// if ((ceil(y+dy) <= bottom) && (ceil(y+dy)>=top)) {
601// if ((floor(x+dx) >= 0) && (floor(x+dx) <source_bpr)) {
602// p1 = *(source_bits + (int32)ceil(y+dy)*source_bpr + (int32)floor(x+dx));
603// }
604// else
605// p1 = 0xFFFFFF00;
606//
607// if ((ceil(x+dx) >= 0) && (ceil(x+dx) <source_bpr)) {
608// p2 = *(source_bits + (int32)ceil(y+dy)*source_bpr + (int32)ceil(x+dx));
609// }
610// else
611// p2 = 0xFFFFFF00;
612// }
613// else {
614// p1 = 0xFFFFFF00;
615// p2 = 0xFFFFFF00;
616// }
617// if ((floor(y+dy) <= bottom) && (floor(y+dy)>=top)) {
618// if ((floor(x+dx) >= 0) && (floor(x+dx) <source_bpr)) {
619// p3 = *(source_bits + (int32)floor(y+dy)*source_bpr + (int32)floor(x+dx));
620// }
621// else
622// p3 = 0xFFFFFF00;
623//
624// if ((ceil(x+dx) >= 0) && (ceil(x+dx) <source_bpr)) {
625// p4 = *(source_bits + (int32)floor(y+dy)*source_bpr + (int32)ceil(x+dx));
626// }
627// else
628// p4 = 0xFFFFFF00;
629// }
630// else {
631// p3 = 0xFFFFFF00;
632// p4 = 0xFFFFFF00;
633// }
634// *target_bits++ = combine_4_pixels(p1,p2,p3,p4,(1-y_mix_upper)*(1-x_mix_right),(1-y_mix_upper)*(x_mix_right),(y_mix_upper)*(1-x_mix_right),(y_mix_upper)*(x_mix_right));
635// }
636// else {
637// if (real_x != 0) {
638// sqrt_x_plus_y = sqrt(real_x*real_x);
639// dx = real_x/sqrt_x_plus_y*A*sin(sqrt_x_plus_y*two_pi_per_s);
640// dx = dx*(1-k*sqrt_x_plus_y/R);
641// float x_mix_right = (x+dx)-floor(x+dx);
642// if ((ceil(x+dx) >= 0) && (ceil(x+dx)<target_bpr))
643// p1 = *(source_bits + (int32)y*target_bpr + (int32)ceil((x +dx)));
644// else
645// p1 = 0xFFFFFF00;
646//
647// if ((floor(x+dx) >= 0) && (floor(x+dx)<target_bpr))
648// p2 = *(source_bits + (int32)y*target_bpr + (int32)floor((x +dx)));
649// else
650// p2 = 0xFFFFFF00;
651// *target_bits++ = mix_2_pixels_fixed(p1,p2,32768*x_mix_right);
652// }
653// else if (real_y != 0) {
654// sqrt_x_plus_y = sqrt(real_y*real_y);
655// dy = real_y/sqrt_x_plus_y*A*sin(sqrt_x_plus_y*two_pi_per_s);
656// dy = dy*(1-k*sqrt_x_plus_y/R);
657// float y_mix_upper = ceil(y+dy)-(y+dy);
658// if ((ceil(y+dy)<=bottom) && (ceil(y+dy) >= top))
659// p1 = *(source_bits + (int32)x + (int32)ceil((y + dy))*target_bpr);
660// else
661// p1 = 0xFFFFFF00;
662//
663// if ((floor(y+dy)<=bottom) && (floor(y+dy) >= top))
664// p2 = *(source_bits + (int32)x + (int32)floor((y + dy))*target_bpr);
665// else
666// p2 = 0xFFFFFF00;
667// *target_bits++ = mix_2_pixels_fixed(p2,p1,32768*y_mix_upper);
668// }
669// else {
670// *target_bits++ = *(source_bits + (int32)x + (int32)y*source_bpr);
671// }
672// }
673//
674// }
675// // Send a progress-message if required
676// if ((status_view != NULL) && ((int32)y%10 == 0)) {
677// progress_message.ReplaceFloat("delta",(100.0*progress_step)/(float)(end_y-start_y)*10.0);
678// status_view->Window()->PostMessage(&progress_message,status_view);
679// }
680// }
681// }
682// else if (preview_level == GOOD_PREVIEW) {
683// for (float y=start_y;y<=end_y;y++) {
684// for (float x=0;x<source_bpr;x++) {
685// real_x = x-cx;
686// real_y = y-cy;
687// if ((real_x != 0) && (real_y != 0)) {
688// // Let's try the inline assemler function for square root estimation
689// one_per_sqrt_x_plus_y = reciprocal_of_square_root(real_x*real_x+real_y*real_y);
690// sqrt_x_plus_y = 1.0/one_per_sqrt_x_plus_y;
691//
692// dx = one_per_sqrt_x_plus_y*A*sin_table[(int32)(sqrt_x_plus_y*two_360_per_s)%720];
693// dx = dx*(1-k*sqrt_x_plus_y/R);
694// dy = dx*real_y;
695// dx = dx*real_x;
696// // This if is quite slow.
697// if (((y+dy) <= bottom) && ((y+dy)>=top) && ((x+dx) >= 0) && ((x+dx)<target_bpr)) {
698// *(target_bits) = *(source_bits + (int32)(x+dx) + (int32)(y+dy)*source_bpr);
699// }
700// else {
701// *target_bits = 0xFFFFFF00;
702// }
703// }
704// else {
705// if (real_x != 0) {
706// // We also have to estimate the sqrt here.
707// one_per_sqrt_x_plus_y = reciprocal_of_square_root(real_x*real_x);
708// sqrt_x_plus_y = 1/one_per_sqrt_x_plus_y;
709// dx = one_per_sqrt_x_plus_y*A*sin_table[(int32)(sqrt_x_plus_y*two_360_per_s)%720]*real_x;
710// dx = dx*(1-k*sqrt_x_plus_y/R);
711// if (((x+dx) >= 0) && ((x+dx)<target_bpr))
712// *target_bits = *(source_bits + (int32)y*target_bpr + (int32)(x +dx));
713// else
714// *target_bits = 0xFFFFFF00;
715// }
716// else if (real_y != 0) {
717// one_per_sqrt_x_plus_y = reciprocal_of_square_root(real_y*real_y);
718// sqrt_x_plus_y = 1/one_per_sqrt_x_plus_y;
719// dy = one_per_sqrt_x_plus_y*A*sin_table[(int32)(sqrt_x_plus_y*two_360_per_s)%720]*real_y;
720// dy = dy*(1-k*sqrt_x_plus_y/R);
721// if (((y+dy)<=bottom) && ((y+dy) >= top))
722// *target_bits = *(source_bits + (int32)x + (int32)(y + dy)*target_bpr);
723// else
724// *target_bits = 0xFFFFFF00;
725// }
726// else {
727// *target_bits = *(source_bits + (int32)x + (int32)y*target_bpr);
728// }
729// }
730// target_bits++;
731// }
732// // Send a progress-message if required
733// if ((status_view != NULL) && ((int32)y%10 == 0)) {
734// progress_message.ReplaceFloat("delta",(100.0*progress_step)/(float)(end_y-start_y)*10.0);
735// status_view->Window()->PostMessage(&progress_message,status_view);
736// }
737// }
738// }
739// else {
740// int32 width = source_bpr/2*2;
741// for (float y=start_y;y<end_y;y+=2) {
742// for (float x=0;x<width;x+=2) {
743// real_x = x-cx;
744// real_y = y-cy;
745// if ((real_x != 0) && (real_y != 0)) {
746// one_per_sqrt_x_plus_y = reciprocal_of_square_root(real_x*real_x+real_y*real_y);
747// sqrt_x_plus_y = 1.0/one_per_sqrt_x_plus_y;
748//
749// dx = one_per_sqrt_x_plus_y*A*sin_table[(int32)(sqrt_x_plus_y*two_360_per_s)%720];
750// dx = dx*(1-k*sqrt_x_plus_y/R);
751// dy = dx*real_y;
752// dx = dx*real_x;
753// // This if is quite slow.
754// if (((y+dy) < bottom) && ((y+dy)>=top) && ((x+dx) >= 0) && ((x+dx)<target_bpr-1)) {
755// uint32 new_value = *(source_bits + (int32)(x+dx) + (int32)(y+dy)*source_bpr);
756// *(target_bits) = new_value;
757// *(target_bits+1) = new_value;
758// *(target_bits+target_bpr) = new_value;
759// *(target_bits+target_bpr+1) = new_value;
760//
761// }
762// else {
763// *target_bits = 0xFFFFFF00;
764// *(target_bits+1) = 0xFFFFFF00;
765// *(target_bits+target_bpr) = 0xFFFFFF00;
766// *(target_bits+target_bpr+1) = 0xFFFFFF00;
767// }
768// }
769// else {
770// if (real_x != 0) {
771// dx = A*sin(real_x*two_pi_per_s);
772// dx = dx*(1-k*real_x/R);
773// if (((x+dx) >= 0) && ((x+dx)<target_bpr)) {
774// uint32 new_value = *(source_bits + (int32)y*target_bpr + (int32)(x +dx));
775// *target_bits = new_value;
776// *(target_bits+1) = new_value;
777// *(target_bits+target_bpr) = new_value;
778// *(target_bits+target_bpr+1) = new_value;
779// }
780// else {
781// *target_bits = 0xFFFFFF00;
782// *(target_bits+1) = 0xFFFFFF00;
783// *(target_bits+target_bpr) = 0xFFFFFF00;
784// *(target_bits+target_bpr+1) = 0xFFFFFF00;
785// }
786// }
787// else if (real_y != 0) {
788// dy = A*sin(real_y*two_pi_per_s);
789// dy = dy*(1-k*real_y/R);
790// if (((y+dy)<=bottom) && ((y+dy) >= top)) {
791// int32 new_value = *(source_bits + (int32)x + (int32)(y + dy)*target_bpr);
792// *target_bits = new_value;
793// *(target_bits+1) = new_value;
794// *(target_bits+target_bpr) = new_value;
795// *(target_bits+target_bpr+1) = new_value;
796// }
797// else {
798// *target_bits = 0xFFFFFF00;
799// *(target_bits+1) = 0xFFFFFF00;
800// *(target_bits+target_bpr) = 0xFFFFFF00;
801// *(target_bits+target_bpr+1) = 0xFFFFFF00;
802// }
803// }
804// else {
805// int32 new_value = *(source_bits + (int32)x + (int32)y*target_bpr);
806// *target_bits = new_value;
807// *(target_bits+1) = new_value;
808// *(target_bits+target_bpr) = new_value;
809// *(target_bits+target_bpr+1) = new_value;
810// }
811// }
812// target_bits+=2;
813// }
814// if ((source_bpr % 2) == 0) {
815// target_bits += target_bpr;
816// }
817// else
818// target_bits += target_bpr + 1;
819// }
820// // Here we handle the last row separately if needed.
821// if ((end_y-start_y)%2 == 0) {
822// float y = end_y;
823// for (float x=0;x<width;x+=2) {
824// real_x = x-cx;
825// real_y = y-cy;
826// if ((real_x != 0) && (real_y != 0)) {
827// one_per_sqrt_x_plus_y = reciprocal_of_square_root(real_x*real_x+real_y*real_y);
828// sqrt_x_plus_y = 1.0/one_per_sqrt_x_plus_y;
829//
830// dx = one_per_sqrt_x_plus_y*A*sin_table[(int32)(sqrt_x_plus_y*two_360_per_s)%720];
831// dx = dx*(1-k*sqrt_x_plus_y/R);
832// dy = dx*real_y;
833// dx = dx*real_x;
834// // This if is quite slow.
835// if (((y+dy) < bottom) && ((y+dy)>=top) && ((x+dx) >= 0) && ((x+dx)<target_bpr-1)) {
836// uint32 new_value = *(source_bits + (int32)(x+dx) + (int32)(y+dy)*source_bpr);
837// *(target_bits) = new_value;
838// *(target_bits+1) = new_value;
839// }
840// else {
841// *target_bits = 0xFFFFFF00;
842// *(target_bits + 1) = 0xFFFFFF00;
843// }
844// }
845// else {
846// if (real_x != 0) {
847// dx = A*sin(real_x*two_pi_per_s);
848// dx = dx*(1-k*real_x/R);
849// if (((x+dx) >= 0) && ((x+dx)<target_bpr)) {
850// uint32 new_value = *(source_bits + (int32)y*target_bpr + (int32)(x +dx));
851// *target_bits = new_value;
852// *(target_bits+1) = new_value;
853// }
854// else {
855// *target_bits = 0xFFFFFF00;
856// *(target_bits+1) = 0xFFFFFF00;
857// }
858// }
859// else if (real_y != 0) {
860// dy = A*sin(real_y*two_pi_per_s);
861// dy = dy*(1-k*real_y/R);
862// if (((y+dy)<=bottom) && ((y+dy) >= top)) {
863// int32 new_value = *(source_bits + (int32)x + (int32)(y + dy)*target_bpr);
864// *target_bits = new_value;
865// *(target_bits+1) = new_value;
866// }
867// else {
868// *target_bits = 0xFFFFFF00;
869// *(target_bits+1) = 0xFFFFFF00;
870// }
871// }
872// else {
873// int32 new_value = *(source_bits + (int32)x + (int32)y*target_bpr);
874// *target_bits = new_value;
875// *(target_bits+1) = new_value;
876// }
877// }
878// target_bits+=2;
879// }
880//
881// }
882// }
883// delete watch;
884// return B_OK;
885//}
886
887
888const char* WaveManipulator::ReturnHelpString()
889{
890 return B_TRANSLATE("Click to set the wave center. Use the sliders to adjust wave.")BLocaleRoster::Default()->GetCatalog()->GetString(("Click to set the wave center. Use the sliders to adjust wave."
), "AddOns_Wave")
;
891}
892
893
894const char* WaveManipulator::ReturnName()
895{
896 return B_TRANSLATE("Wave")BLocaleRoster::Default()->GetCatalog()->GetString(("Wave"
), "AddOns_Wave")
;
897}
898
899
900void WaveManipulator::SetPreviewBitmap(BBitmap *bm)
901{
902 if (preview_bitmap != bm) {
903 delete copy_of_the_preview_bitmap;
904 if (bm != NULL__null) {
905 preview_bitmap = bm;
906 copy_of_the_preview_bitmap = DuplicateBitmap(bm,0);
907 }
908 else {
909 preview_bitmap = NULL__null;
910 copy_of_the_preview_bitmap = NULL__null;
911 }
912 }
913 if (preview_bitmap != NULL__null) {
914 double speed = GetSystemClockSpeed() / 15000;
915
916 BRect bounds = preview_bitmap->Bounds();
917 float num_pixels = (bounds.Width()+1) * (bounds.Height() + 1);
918 lowest_available_quality = 1;
919 while ((2*num_pixels/lowest_available_quality/lowest_available_quality) > speed)
920 lowest_available_quality *= 2;
921
922 lowest_available_quality = min_c(lowest_available_quality,16)((lowest_available_quality)>(16)?(16):(lowest_available_quality
))
;
923 highest_available_quality = max_c(lowest_available_quality/2,1)((lowest_available_quality/2)>(1)?(lowest_available_quality
/2):(1))
;
924 }
925 else {
926 lowest_available_quality = 1;
927 highest_available_quality = 1;
928 }
929 last_calculated_resolution = lowest_available_quality;
930}
931
932
933void WaveManipulator::Reset(Selection*)
934{
935 if (preview_bitmap != NULL__null) {
936 uint32 *source_bits = (uint32*)copy_of_the_preview_bitmap->Bits();
937 uint32 *target_bits = (uint32*)preview_bitmap->Bits();
938
939 int32 bits_length = preview_bitmap->BitsLength()/4;
940
941 for (int32 i=0;i<bits_length;i++)
942 *target_bits++ = *source_bits++;
943 }
944}
945
946BView* WaveManipulator::MakeConfigurationView(const BMessenger& target)
947{
948 config_view = new WaveManipulatorView(BRect(0,0,0,0),this, target);
949 config_view->ChangeSettings(&settings);
950 return config_view;
951}
952
953
954ManipulatorSettings* WaveManipulator::ReturnSettings()
955{
956 return new WaveManipulatorSettings(settings);
957}
958
959void WaveManipulator::ChangeSettings(ManipulatorSettings *s)
960{
961 WaveManipulatorSettings *new_settings = dynamic_cast<WaveManipulatorSettings*>(s);
962 if (new_settings != NULL__null) {
963 previous_settings = settings;
964 settings = *new_settings;
965 }
966}
967
968//-------------
969
970
971WaveManipulatorView::WaveManipulatorView(BRect rect,WaveManipulator *manip,
972 const BMessenger& t)
973 : WindowGUIManipulatorView()
974{
975 manipulator = manip;
976 target = new BMessenger(t);
977 preview_started = FALSE0;
978
979 wave_length_slider = new BSlider("wave_length_slider",
980 B_TRANSLATE("Wavelength:")BLocaleRoster::Default()->GetCatalog()->GetString(("Wavelength:"
), "AddOns_Wave")
, new BMessage(WAVE_LENGTH_CHANGED'Wlec'), MIN_WAVE_LENGTH3,
981 MAX_WAVE_LENGTH200, B_HORIZONTAL, B_TRIANGLE_THUMB);
982 wave_length_slider->SetLimitLabels(B_TRANSLATE("Short")BLocaleRoster::Default()->GetCatalog()->GetString(("Short"
), "AddOns_Wave")
, B_TRANSLATE("Long")BLocaleRoster::Default()->GetCatalog()->GetString(("Long"
), "AddOns_Wave")
);
983 wave_length_slider->SetModificationMessage(new BMessage(WAVE_LENGTH_ADJUSTING_STARTED'Wlas'));
984 wave_length_slider->SetHashMarks(B_HASH_MARKS_BOTTOM);
985 wave_length_slider->SetHashMarkCount(11);
986
987 wave_amount_slider = new BSlider("wave_amount_slider", B_TRANSLATE("Strength:")BLocaleRoster::Default()->GetCatalog()->GetString(("Strength:"
), "AddOns_Wave")
,
988 new BMessage(WAVE_AMOUNT_CHANGED'Wamc'), MIN_WAVE_AMOUNT3, MAX_WAVE_AMOUNT100,
989 B_HORIZONTAL, B_TRIANGLE_THUMB);
990 wave_amount_slider->SetLimitLabels(B_TRANSLATE("Mild")BLocaleRoster::Default()->GetCatalog()->GetString(("Mild"
), "AddOns_Wave")
, B_TRANSLATE("Strong")BLocaleRoster::Default()->GetCatalog()->GetString(("Strong"
), "AddOns_Wave")
);
991 wave_amount_slider->SetModificationMessage(new BMessage(WAVE_AMOUNT_ADJUSTING_STARTED'Waas'));
992 wave_amount_slider->SetHashMarks(B_HASH_MARKS_BOTTOM);
993 wave_amount_slider->SetHashMarkCount(11);
994
995 BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_ITEM_SPACING)
996 .Add(wave_length_slider)
997 .Add(wave_amount_slider)
998 .SetInsets(B_USE_SMALL_INSETS)
999 .End();
1000}
1001
1002
1003WaveManipulatorView::~WaveManipulatorView()
1004{
1005 delete target;
1006}
1007
1008
1009void WaveManipulatorView::AttachedToWindow()
1010{
1011 WindowGUIManipulatorView::AttachedToWindow();
1012
1013 wave_length_slider->SetTarget(BMessenger(this));
1014 wave_amount_slider->SetTarget(BMessenger(this));
1015}
1016
1017
1018void WaveManipulatorView::AllAttached()
1019{
1020 wave_length_slider->SetValue(settings.wave_length);
1021 wave_amount_slider->SetValue(settings.wave_amount);
1022
1023}
1024
1025
1026void WaveManipulatorView::MessageReceived(BMessage *message)
1027{
1028 switch (message->what) {
1029 case WAVE_LENGTH_ADJUSTING_STARTED'Wlas':
1030 if (preview_started == FALSE0) {
1031 preview_started = TRUE1;
1032 target->SendMessage(HS_MANIPULATOR_ADJUSTING_STARTED'Mast');
1033 }
1034 settings.wave_length = wave_length_slider->Value();
1035 manipulator->ChangeSettings(&settings);
1036 break;
1037
1038 case WAVE_LENGTH_CHANGED'Wlec':
1039 preview_started = FALSE0;
1040 settings.wave_length = wave_length_slider->Value();
1041 manipulator->ChangeSettings(&settings);
1042 target->SendMessage(HS_MANIPULATOR_ADJUSTING_FINISHED'Mafi');
1043 break;
1044
1045 case WAVE_AMOUNT_ADJUSTING_STARTED'Waas':
1046 if (preview_started == FALSE0) {
1047 preview_started = TRUE1;
1048 target->SendMessage(HS_MANIPULATOR_ADJUSTING_STARTED'Mast');
1049 }
1050 settings.wave_amount = wave_amount_slider->Value();
1051 manipulator->ChangeSettings(&settings);
1052 break;
1053
1054 case WAVE_AMOUNT_CHANGED'Wamc':
1055 preview_started = FALSE0;
1056 settings.wave_amount = wave_amount_slider->Value();
1057 manipulator->ChangeSettings(&settings);
1058 target->SendMessage(HS_MANIPULATOR_ADJUSTING_FINISHED'Mafi');
1059 break;
1060
1061 default:
1062 WindowGUIManipulatorView::MessageReceived(message);
1063 break;
1064 }
1065}
1066
1067
1068void WaveManipulatorView::ChangeSettings(WaveManipulatorSettings *s)
1069{
1070 settings = *s;
1071 BWindow *window = Window();
1072
1073 if (window != NULL__null) {
1074 window->Lock();
1075
1076 wave_length_slider->SetValue(settings.wave_length);
1077 wave_amount_slider->SetValue(settings.wave_amount);
1078
1079 window->Unlock();
1080 }
1081}