PageRenderTime 51ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/Fltk/colorbarWindow.cpp

https://bitbucket.org/lge/gmsh
C++ | 628 lines | 552 code | 47 blank | 29 comment | 178 complexity | 416dac8b56a98bda0648dbbf44110cc9 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, BSD-3-Clause
  1. // Gmsh - Copyright (C) 1997-2012 C. Geuzaine, J.-F. Remacle
  2. //
  3. // See the LICENSE.txt file for license information. Please report all
  4. // bugs and problems to <gmsh@geuz.org>.
  5. // This class was inspired by the colorbar widget provided in Vis5d, a
  6. // program for visualizing five dimensional gridded data sets
  7. // Copyright (C) 1990 - 1995 Bill Hibbard, Brian Paul, Dave Santek,
  8. // and Andre Battaiola.
  9. #include <FL/fl_draw.H>
  10. #include "colorbarWindow.h"
  11. #include "ColorTable.h"
  12. #include "Context.h"
  13. #define EPS 1.e-10
  14. colorbarWindow::colorbarWindow(int x, int y, int w, int h, const char *l)
  15. : Fl_Window(x, y, w, h, l)
  16. {
  17. ct = NULL;
  18. label = NULL;
  19. help_flag = 1;
  20. font_height = FL_NORMAL_SIZE - 1; // use slightly smaller font
  21. marker_height = font_height;
  22. wedge_height = marker_height;
  23. marker_pos = 0;
  24. minval = maxval = 0.0;
  25. }
  26. int colorbarWindow::x_to_index(int x)
  27. {
  28. int index;
  29. index = (int)(x * (double)ct->size / (double)w());
  30. if(index < 0)
  31. index = 0;
  32. else if(index >= ct->size)
  33. index = ct->size - 1;
  34. return index;
  35. }
  36. int colorbarWindow::index_to_x(int index)
  37. {
  38. int x;
  39. x = (int)(index * (double)w() / (double)(ct->size - 1));
  40. if(x >= w())
  41. x = w() - 1;
  42. return x;
  43. }
  44. int colorbarWindow::y_to_intensity(int y)
  45. {
  46. int intensity;
  47. intensity = (int)((wedge_y - y) * 255. / (double)wedge_y);
  48. if(intensity < 0)
  49. intensity = 0;
  50. else if(intensity > 255)
  51. intensity = 255;
  52. return intensity;
  53. }
  54. int colorbarWindow::intensity_to_y(int intensity)
  55. {
  56. int y;
  57. y = (int)(wedge_y - intensity * (double)wedge_y / 255.);
  58. if(y < 0)
  59. y = 0;
  60. else if(y >= wedge_y)
  61. y = wedge_y - 1;
  62. return y;
  63. }
  64. void colorbarWindow::redraw_range(int a, int b)
  65. {
  66. int i;
  67. int x, y, px = 0, py = 0;
  68. int x1, y1, x2, y2;
  69. int intensity = 0;
  70. double H, S, V;
  71. make_current();
  72. if(a < 0)
  73. a = 0;
  74. if(b >= ct->size)
  75. b = ct->size - 1;
  76. // calculate region to update
  77. x1 = index_to_x(a);
  78. x2 = index_to_x(b);
  79. y1 = intensity_to_y(255);
  80. y2 = intensity_to_y(0);
  81. // erase region
  82. fl_color(color_bg);
  83. fl_rectf(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
  84. // redraw region of entries in interval [a,b]
  85. if(a > 0)
  86. a--;
  87. if(b < ct->size - 1)
  88. b++;
  89. // draw red or hue levels
  90. for(i = a; i <= b; i++) {
  91. x = index_to_x(i);
  92. if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_RGB)
  93. intensity = CTX::instance()->unpackRed(ct->table[i]);
  94. else if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_HSV) {
  95. RGB_to_HSV(CTX::instance()->unpackRed(ct->table[i]) / 255.,
  96. CTX::instance()->unpackGreen(ct->table[i]) / 255.,
  97. CTX::instance()->unpackBlue(ct->table[i]) / 255., &H, &S, &V);
  98. intensity = (int)(H / 6. * 255. + EPS);
  99. }
  100. y = intensity_to_y(intensity);
  101. if(i != a) {
  102. fl_color(FL_RED);
  103. fl_line(px, py, x, y);
  104. }
  105. px = x;
  106. py = y;
  107. }
  108. // draw green or saturation levels
  109. for(i = a; i <= b; i++) {
  110. x = index_to_x(i);
  111. if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_RGB)
  112. intensity = CTX::instance()->unpackGreen(ct->table[i]);
  113. else if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_HSV) {
  114. RGB_to_HSV(CTX::instance()->unpackRed(ct->table[i]) / 255.,
  115. CTX::instance()->unpackGreen(ct->table[i]) / 255.,
  116. CTX::instance()->unpackBlue(ct->table[i]) / 255., &H, &S, &V);
  117. intensity = (int)(S * 255.);
  118. }
  119. y = intensity_to_y(intensity);
  120. if(i != a) {
  121. fl_color(FL_GREEN);
  122. fl_line(px, py, x, y);
  123. }
  124. px = x;
  125. py = y;
  126. }
  127. // draw blue or value levels
  128. for(i = a; i <= b; i++) {
  129. x = index_to_x(i);
  130. if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_RGB)
  131. intensity = CTX::instance()->unpackBlue(ct->table[i]);
  132. else if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_HSV) {
  133. RGB_to_HSV(CTX::instance()->unpackRed(ct->table[i]) / 255.,
  134. CTX::instance()->unpackGreen(ct->table[i]) / 255.,
  135. CTX::instance()->unpackBlue(ct->table[i]) / 255., &H, &S, &V);
  136. intensity = (int)(V * 255.);
  137. }
  138. y = intensity_to_y(intensity);
  139. if(i != a) {
  140. fl_color(FL_BLUE);
  141. fl_line(px, py, x, y);
  142. }
  143. px = x;
  144. py = y;
  145. }
  146. // draw alpha levels
  147. for(i = a; i <= b; i++) {
  148. x = index_to_x(i);
  149. y = intensity_to_y(CTX::instance()->unpackAlpha(ct->table[i]));
  150. if(i != a) {
  151. fl_color(fl_contrast(FL_BLACK, color_bg));
  152. fl_line(px, py, x, y);
  153. }
  154. px = x;
  155. py = y;
  156. }
  157. // draw the color bar
  158. for(x = x1; x <= x2; x++) {
  159. int r, g, b;
  160. unsigned int color;
  161. i = x_to_index(x);
  162. color = ct->table[i];
  163. r = CTX::instance()->unpackRed(color);
  164. g = CTX::instance()->unpackGreen(color);
  165. b = CTX::instance()->unpackBlue(color);
  166. fl_color(r, g, b);
  167. fl_line(x, wedge_y, x, wedge_y + wedge_height - 1);
  168. }
  169. // print colortable mode and help
  170. fl_font(FL_HELVETICA, font_height);
  171. fl_color(fl_contrast(FL_BLACK, color_bg));
  172. int xx0 = 6, xx1 = 11 * font_height, yy0 = 10;
  173. if(help_flag) {
  174. i = 0;
  175. fl_draw("1, 2, ..., Ctrl+1, ...", xx0, yy0 + (i + 1) * font_height);
  176. fl_draw("Select predefined colormap", xx1, yy0 + (i + 1) * font_height);
  177. i++;
  178. fl_draw("mouse1", xx0, yy0 + (i + 1) * font_height);
  179. fl_draw("Draw red or hue channel", xx1, yy0 + (i + 1) * font_height);
  180. i++;
  181. fl_draw("mouse2", xx0, yy0 + (i + 1) * font_height);
  182. fl_draw("Draw green or saturation channel", xx1, yy0 + (i + 1) * font_height);
  183. i++;
  184. fl_draw("mouse3", xx0, yy0 + (i + 1) * font_height);
  185. fl_draw("Draw blue or value channel", xx1, yy0 + (i + 1) * font_height);
  186. i++;
  187. fl_draw("Ctrl+mouse1", xx0, yy0 + (i + 1) * font_height);
  188. fl_draw("Draw alpha channel", xx1, yy0 + (i + 1) * font_height);
  189. i++;
  190. fl_draw("Ctrl+c, Ctrl+v, r", xx0, yy0 + (i + 1) * font_height);
  191. fl_draw("Copy, paste or reset colormap", xx1, yy0 + (i + 1) * font_height);
  192. i++;
  193. fl_draw("m", xx0, yy0 + (i + 1) * font_height);
  194. fl_draw("Toggle RGB/HSV mode", xx1, yy0 + (i + 1) * font_height);
  195. i++;
  196. fl_draw("left, right", xx0, yy0 + (i + 1) * font_height);
  197. fl_draw("Translate abscissa", xx1, yy0 + (i + 1) * font_height);
  198. i++;
  199. fl_draw("Ctrl+left, Ctrl+right", xx0, yy0 + (i + 1) * font_height);
  200. fl_draw("Rotate abscissa", xx1, yy0 + (i + 1) * font_height);
  201. i++;
  202. fl_draw("i, Ctrl+i", xx0, yy0 + (i + 1) * font_height);
  203. fl_draw("Invert abscissa or ordinate", xx1, yy0 + (i + 1) * font_height);
  204. i++;
  205. fl_draw("up, down", xx0, yy0 + (i + 1) * font_height);
  206. fl_draw("Modify color channel curvature", xx1, yy0 + (i + 1) * font_height);
  207. i++;
  208. fl_draw("a, Ctrl+a", xx0, yy0 + (i + 1) * font_height);
  209. fl_draw("Modify alpha coefficient", xx1, yy0 + (i + 1) * font_height);
  210. i++;
  211. fl_draw("p, Ctrl+p", xx0, yy0 + (i + 1) * font_height);
  212. fl_draw("Modify alpha channel power law", xx1, yy0 + (i + 1) * font_height);
  213. i++;
  214. fl_draw("b, Ctrl+b", xx0, yy0 + (i + 1) * font_height);
  215. fl_draw("Modify gamma correction", xx1, yy0 + (i + 1) * font_height);
  216. i++;
  217. fl_draw("h", xx0, yy0 + (i + 1) * font_height);
  218. fl_draw("Show this help message", xx1, yy0 + (i + 1) * font_height);
  219. i++;
  220. }
  221. else if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_RGB)
  222. fl_draw("RGB", xx0, yy0 + font_height);
  223. else if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_HSV)
  224. fl_draw("HSV", xx0, yy0 + font_height);
  225. }
  226. void colorbarWindow::redraw_marker()
  227. {
  228. int x, y0, y1;
  229. char str[50];
  230. double val;
  231. make_current();
  232. y0 = marker_y;
  233. y1 = h() - 1;
  234. fl_color(color_bg);
  235. fl_rectf(0, y0, w(), y1 - y0 + 1);
  236. // draw marker below color wedge
  237. x = index_to_x(marker_pos);
  238. fl_color(fl_contrast(FL_BLACK, color_bg));
  239. fl_line(x, marker_y, x, marker_y + marker_height);
  240. fl_line(x, marker_y, x - 3, marker_y + 6);
  241. fl_line(x, marker_y, x + 3, marker_y + 6);
  242. // draw marker value
  243. fl_font(FL_HELVETICA, font_height);
  244. val =
  245. minval + (maxval - minval) * ((double)marker_pos / (double)(ct->size - 1));
  246. sprintf(str, "%g", val);
  247. fl_draw(str, 10, label_y);
  248. }
  249. void colorbarWindow::draw()
  250. {
  251. if(!ct) return;
  252. label_y = h() - 5;
  253. marker_y = label_y - marker_height - font_height;
  254. wedge_y = marker_y - wedge_height;
  255. color_bg = fl_color_cube(CTX::instance()->unpackRed(CTX::instance()->color.bg) *
  256. FL_NUM_RED / 256,
  257. CTX::instance()->unpackGreen(CTX::instance()->color.bg) *
  258. FL_NUM_GREEN / 256,
  259. CTX::instance()->unpackBlue(CTX::instance()->color.bg) *
  260. FL_NUM_BLUE / 256);
  261. redraw_range(0, ct->size - 1);
  262. redraw_marker();
  263. }
  264. void colorbarWindow::update(const char *name, double min, double max,
  265. GmshColorTable *table, bool *changed)
  266. {
  267. label = name;
  268. ct = table;
  269. viewchanged = changed;
  270. minval = min;
  271. maxval = max;
  272. redraw();
  273. }
  274. int colorbarWindow::handle(int event)
  275. {
  276. if(!ct) return Fl_Window::handle(event);
  277. static int p1 = 0, p2 = 0, p3 = 0, p4 = 0;
  278. static int pentry, move_marker;
  279. int i, ibut, xpos, ypos, modify, entry, compute;
  280. modify = 0;
  281. compute = 0;
  282. switch (event) {
  283. case FL_FOCUS: // accept focus events when asked
  284. case FL_UNFOCUS:
  285. return 1;
  286. case FL_ENTER:
  287. take_focus(); // force keyboard focus as soon as the mouse enters
  288. return 1;
  289. case FL_LEAVE:
  290. return 1;
  291. case FL_SHORTCUT:
  292. case FL_KEYBOARD:
  293. if(Fl::test_shortcut('0')) {
  294. ColorTable_InitParam(0, ct);
  295. compute = 1;
  296. }
  297. else if(Fl::test_shortcut('1')) {
  298. ColorTable_InitParam(1, ct);
  299. compute = 1;
  300. }
  301. else if(Fl::test_shortcut('2')) {
  302. ColorTable_InitParam(2, ct);
  303. compute = 1;
  304. }
  305. else if(Fl::test_shortcut('3')) {
  306. ColorTable_InitParam(3, ct);
  307. compute = 1;
  308. }
  309. else if(Fl::test_shortcut('4')) {
  310. ColorTable_InitParam(4, ct);
  311. compute = 1;
  312. }
  313. else if(Fl::test_shortcut('5')) {
  314. ColorTable_InitParam(5, ct);
  315. compute = 1;
  316. }
  317. else if(Fl::test_shortcut('6')) {
  318. ColorTable_InitParam(6, ct);
  319. compute = 1;
  320. }
  321. else if(Fl::test_shortcut('7')) {
  322. ColorTable_InitParam(7, ct);
  323. compute = 1;
  324. }
  325. else if(Fl::test_shortcut('8')) {
  326. ColorTable_InitParam(8, ct);
  327. compute = 1;
  328. }
  329. else if(Fl::test_shortcut('9')) {
  330. ColorTable_InitParam(9, ct);
  331. compute = 1;
  332. }
  333. else if(Fl::test_shortcut(FL_CTRL + '0')) {
  334. ColorTable_InitParam(10, ct);
  335. compute = 1;
  336. }
  337. else if(Fl::test_shortcut(FL_CTRL + '1')) {
  338. ColorTable_InitParam(11, ct);
  339. compute = 1;
  340. }
  341. else if(Fl::test_shortcut(FL_CTRL + '2')) {
  342. ColorTable_InitParam(12, ct);
  343. compute = 1;
  344. }
  345. else if(Fl::test_shortcut(FL_CTRL + '3')) {
  346. ColorTable_InitParam(13, ct);
  347. compute = 1;
  348. }
  349. else if(Fl::test_shortcut(FL_CTRL + '4')) {
  350. ColorTable_InitParam(14, ct);
  351. compute = 1;
  352. }
  353. else if(Fl::test_shortcut(FL_CTRL + '5')) {
  354. ColorTable_InitParam(15, ct);
  355. compute = 1;
  356. }
  357. else if(Fl::test_shortcut(FL_CTRL + '6')) {
  358. ColorTable_InitParam(16, ct);
  359. compute = 1;
  360. }
  361. else if(Fl::test_shortcut(FL_CTRL + '7')) {
  362. ColorTable_InitParam(17, ct);
  363. compute = 1;
  364. }
  365. else if(Fl::test_shortcut(FL_CTRL + '8')) {
  366. ColorTable_InitParam(18, ct);
  367. compute = 1;
  368. }
  369. else if(Fl::test_shortcut(FL_CTRL + '9')) {
  370. ColorTable_InitParam(19, ct);
  371. compute = 1;
  372. }
  373. else if(Fl::test_shortcut(FL_CTRL + 'c')) {
  374. ColorTable_Copy(ct);
  375. }
  376. else if(Fl::test_shortcut(FL_CTRL + 'v')) {
  377. ColorTable_Paste(ct);
  378. redraw();
  379. *viewchanged = true;
  380. }
  381. else if(Fl::test_shortcut('h')) {
  382. help_flag = !help_flag;
  383. redraw();
  384. }
  385. else if(Fl::test_shortcut('r')) {
  386. ColorTable_InitParam(ct->ipar[COLORTABLE_NUMBER], ct);
  387. compute = 1;
  388. }
  389. else if(Fl::test_shortcut('m')) {
  390. if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_RGB)
  391. ct->ipar[COLORTABLE_MODE] = COLORTABLE_HSV;
  392. else
  393. ct->ipar[COLORTABLE_MODE] = COLORTABLE_RGB;
  394. redraw();
  395. }
  396. else if(Fl::test_shortcut('i')) {
  397. ct->ipar[COLORTABLE_SWAP] = !ct->ipar[COLORTABLE_SWAP];
  398. compute = 1;
  399. }
  400. else if(Fl::test_shortcut(FL_CTRL + 'i')) {
  401. ct->ipar[COLORTABLE_INVERT] = !ct->ipar[COLORTABLE_INVERT];
  402. compute = 1;
  403. }
  404. else if(Fl::test_shortcut('b')) {
  405. ct->dpar[COLORTABLE_BETA] += 0.05;
  406. if(ct->dpar[COLORTABLE_BETA] > 1.0)
  407. ct->dpar[COLORTABLE_BETA] = 1.0;
  408. compute = 1;
  409. }
  410. else if(Fl::test_shortcut(FL_CTRL + 'b')) {
  411. ct->dpar[COLORTABLE_BETA] -= 0.05;
  412. if(ct->dpar[COLORTABLE_BETA] < -1.0)
  413. ct->dpar[COLORTABLE_BETA] = -1.0;
  414. compute = 1;
  415. }
  416. else if(Fl::test_shortcut('a')) {
  417. ct->dpar[COLORTABLE_ALPHA] -= 0.05;
  418. if(ct->dpar[COLORTABLE_ALPHA] < 0.0)
  419. ct->dpar[COLORTABLE_ALPHA] = 0.0;
  420. compute = 1;
  421. }
  422. else if(Fl::test_shortcut(FL_CTRL + 'a')) {
  423. ct->dpar[COLORTABLE_ALPHA] += 0.05;
  424. if(ct->dpar[COLORTABLE_ALPHA] > 1.0)
  425. ct->dpar[COLORTABLE_ALPHA] = 1.0;
  426. compute = 1;
  427. }
  428. else if(Fl::test_shortcut('p')) {
  429. ct->dpar[COLORTABLE_ALPHAPOW] += 0.05;
  430. compute = 1;
  431. }
  432. else if(Fl::test_shortcut(FL_CTRL + 'p')) {
  433. ct->dpar[COLORTABLE_ALPHAPOW] -= 0.05;
  434. compute = 1;
  435. }
  436. else if(Fl::test_shortcut(FL_Left)) {
  437. ct->dpar[COLORTABLE_BIAS] -= 0.05;
  438. compute = 1;
  439. }
  440. else if(Fl::test_shortcut(FL_CTRL + FL_Left)) {
  441. ct->ipar[COLORTABLE_ROTATION] += 5;
  442. if(ct->ipar[COLORTABLE_ROTATION] > ct->size - 1)
  443. ct->ipar[COLORTABLE_ROTATION] -= ct->size - 1;
  444. compute = 1;
  445. }
  446. else if(Fl::test_shortcut(FL_Right)) {
  447. ct->dpar[COLORTABLE_BIAS] += 0.05;
  448. compute = 1;
  449. }
  450. else if(Fl::test_shortcut(FL_CTRL + FL_Right)) {
  451. ct->ipar[COLORTABLE_ROTATION] -= 5;
  452. if(ct->ipar[COLORTABLE_ROTATION] < -(ct->size - 1))
  453. ct->ipar[COLORTABLE_ROTATION] += ct->size - 1;
  454. compute = 1;
  455. }
  456. else if(Fl::test_shortcut(FL_Up)) {
  457. ct->dpar[COLORTABLE_CURVATURE] -= 0.05;
  458. compute = 1;
  459. }
  460. else if(Fl::test_shortcut(FL_Down)) {
  461. ct->dpar[COLORTABLE_CURVATURE] += 0.05;
  462. compute = 1;
  463. }
  464. else {
  465. return Fl_Window::handle(event);
  466. }
  467. if(compute) {
  468. ColorTable_Recompute(ct);
  469. redraw();
  470. *viewchanged = true;
  471. do_callback();
  472. }
  473. return 1;
  474. case FL_PUSH:
  475. ibut = Fl::event_button();
  476. xpos = Fl::event_x();
  477. ypos = Fl::event_y();
  478. if(help_flag) {
  479. help_flag = 0;
  480. redraw();
  481. }
  482. // change color function or marker position
  483. if(ypos < wedge_y)
  484. move_marker = 0;
  485. else
  486. move_marker = 1;
  487. // determine which curve to modify
  488. if(Fl::event_state(FL_CTRL))
  489. p4 = 1;
  490. else if(ibut == 1 && !Fl::event_state(FL_SHIFT)
  491. && !Fl::event_state(FL_ALT))
  492. p1 = 1;
  493. else if(ibut == 2 || (ibut == 1 && Fl::event_state(FL_SHIFT)))
  494. p2 = 1;
  495. else
  496. p3 = 1;
  497. pentry = x_to_index(xpos);
  498. modify = 1;
  499. break;
  500. case FL_RELEASE:
  501. ibut = Fl::event_button();
  502. xpos = Fl::event_x();
  503. ypos = Fl::event_y();
  504. p1 = 0;
  505. p2 = 0;
  506. p3 = 0;
  507. p4 = 0;
  508. if(*viewchanged) do_callback();
  509. break;
  510. case FL_DRAG:
  511. ibut = Fl::event_button();
  512. xpos = Fl::event_x();
  513. ypos = Fl::event_y();
  514. modify = 1;
  515. break;
  516. default:
  517. // don't know what to do with the event: passing it to parent
  518. return Fl_Window::handle(event);
  519. }
  520. // Modify one or more of the color curves
  521. if(modify && (p1 || p2 || p3 || p4)) {
  522. // calculate which entry in color table to change
  523. entry = x_to_index(xpos);
  524. // update
  525. if(move_marker) {
  526. // changing marker position
  527. marker_pos = entry;
  528. redraw_marker();
  529. }
  530. else {
  531. // changing color graph
  532. int a, b, value;
  533. value = y_to_intensity(ypos);
  534. if(pentry <= entry) {
  535. a = pentry;
  536. b = entry;
  537. }
  538. else {
  539. a = entry;
  540. b = pentry;
  541. }
  542. // update entries from 'pentry' to 'entry'
  543. for(i = a; i <= b; i++) {
  544. int red, green, blue, alpha;
  545. double R, G, B, H, S, V;
  546. red = CTX::instance()->unpackRed(ct->table[i]);
  547. green = CTX::instance()->unpackGreen(ct->table[i]);
  548. blue = CTX::instance()->unpackBlue(ct->table[i]);
  549. alpha = CTX::instance()->unpackAlpha(ct->table[i]);
  550. if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_RGB) {
  551. if(p1) red = value;
  552. if(p2) green = value;
  553. if(p3) blue = value;
  554. if(p4) alpha = value;
  555. }
  556. else if(ct->ipar[COLORTABLE_MODE] == COLORTABLE_HSV) {
  557. RGB_to_HSV((double)red / 255., (double)green / 255.,
  558. (double)blue / 255., &H, &S, &V);
  559. if(p1) H = 6. * (double)value / 255. + EPS;
  560. if(p2) S = (double)value / 255.;
  561. if(p3) V = (double)value / 255.;
  562. if(p4) alpha = value;
  563. HSV_to_RGB(H, S, V, &R, &G, &B);
  564. red = (int)(255 * R);
  565. green = (int)(255 * G);
  566. blue = (int)(255 * B);
  567. }
  568. ct->table[i] = CTX::instance()->packColor(red, green, blue, alpha);
  569. }
  570. // redraw the color curves
  571. if(pentry < entry)
  572. redraw_range(pentry - 1, entry + 1);
  573. else
  574. redraw_range(entry - 1, pentry + 1);
  575. pentry = entry;
  576. *viewchanged = true;
  577. }
  578. return 1;
  579. }
  580. return 1;
  581. }