1 /*
2 * This file is part of RawTherapee.
3 *
4 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
5 *
6 * RawTherapee is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * RawTherapee is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "clipboard.h"
21 #include <gtkmm.h>
22 #include <fstream>
23 #include <string>
24 #include "guiutils.h"
25 #include "multilangmgr.h"
26 #include "guiutils.h"
27 #include "mycurve.h"
28 #include "shcselector.h"
29 #include "adjuster.h"
30 #include "mycurve.h"
31 #include "myflatcurve.h"
32 #include "curveeditor.h"
33 #include "flatcurveeditorsubgroup.h"
34 #include "rtimage.h"
35
36 #include "../rtengine/curves.h"
37
FlatCurveEditorSubGroup(CurveEditorGroup * prt,Glib::ustring & curveDir,float curvesRatio)38 FlatCurveEditorSubGroup::FlatCurveEditorSubGroup (CurveEditorGroup* prt, Glib::ustring& curveDir, float curvesRatio) : CurveEditorSubGroup(curveDir)
39 {
40
41 valLinear = (int)FCT_Linear;
42 valUnchanged = (int)FCT_Unchanged;
43 parent = prt;
44
45 Gtk::PositionType sideStart = options.curvebboxpos == 0 || options.curvebboxpos == 2 ? Gtk::POS_LEFT : Gtk::POS_TOP;
46 Gtk::PositionType sideEnd = options.curvebboxpos == 0 || options.curvebboxpos == 2 ? Gtk::POS_RIGHT : Gtk::POS_BOTTOM;
47
48 // ControlPoints curve
49 CPointsCurveGrid = new Gtk::Grid ();
50 CPointsCurveGrid->set_orientation(Gtk::ORIENTATION_VERTICAL);
51 CPointsCurveGrid->get_style_context()->add_class("curve-mainbox");
52
53 CPointsCurve = Gtk::manage (new MyFlatCurve ());
54 CPointsCurve->setType (FCT_MinMaxCPoints);
55 CPointsCurve->setRatio(curvesRatio);
56
57 Gtk::Grid* CPointsCurveBox = Gtk::manage (new Gtk::Grid ());
58 CPointsCurveBox->get_style_context()->add_class("curve-curvebox");
59 CPointsCurveBox->add(*CPointsCurve);
60
61 Gtk::Grid* CPointsbbox = Gtk::manage (new Gtk::Grid ()); // curvebboxpos 0=above, 1=right, 2=below, 3=left
62 CPointsbbox->get_style_context()->add_class("curve-buttonbox");
63
64 if (options.curvebboxpos == 0) {
65 CPointsbbox->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
66 setExpandAlignProperties(CPointsbbox, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER);
67 CPointsCurveGrid->get_style_context()->add_class("top");
68 } else if (options.curvebboxpos == 2) {
69 CPointsbbox->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
70 setExpandAlignProperties(CPointsbbox, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER);
71 CPointsCurveGrid->get_style_context()->add_class("bottom");
72 } else if (options.curvebboxpos == 1) {
73 CPointsbbox->set_orientation(Gtk::ORIENTATION_VERTICAL);
74 setExpandAlignProperties(CPointsbbox, false, true, Gtk::ALIGN_CENTER, Gtk::ALIGN_FILL);
75 CPointsCurveGrid->get_style_context()->add_class("right");
76 } else if (options.curvebboxpos == 3){
77 CPointsbbox->set_orientation(Gtk::ORIENTATION_VERTICAL);
78 setExpandAlignProperties(CPointsbbox, false, true, Gtk::ALIGN_CENTER, Gtk::ALIGN_FILL);
79 CPointsCurveGrid->get_style_context()->add_class("left");
80 }
81
82 editCPoints = Gtk::manage (new Gtk::ToggleButton());
83 initButton(*editCPoints, Glib::ustring("crosshair-node-curve.png"), Gtk::ALIGN_START, false, "EDIT_PIPETTE_TOOLTIP");
84 editPointCPoints = Gtk::manage (new Gtk::ToggleButton ());
85 initButton(*editPointCPoints, Glib::ustring("edit-point.png"), Gtk::ALIGN_START, false, "CURVEEDITOR_EDITPOINT_HINT");
86 copyCPoints = Gtk::manage (new Gtk::Button ());
87 initButton(*copyCPoints, Glib::ustring("copy.png"), Gtk::ALIGN_END, true);
88 pasteCPoints = Gtk::manage (new Gtk::Button ());
89 initButton(*pasteCPoints, Glib::ustring("paste.png"), Gtk::ALIGN_END, false);
90 loadCPoints = Gtk::manage (new Gtk::Button ());
91 initButton(*loadCPoints, Glib::ustring("folder-open.png"), Gtk::ALIGN_END, false);
92 saveCPoints = Gtk::manage (new Gtk::Button ());
93 initButton(*saveCPoints, Glib::ustring("save.png"), Gtk::ALIGN_END, false);
94
95 CPointsbbox->attach_next_to(*editPointCPoints, sideStart, 1, 1);
96 CPointsbbox->attach_next_to(*editCPoints, sideStart, 1, 1);
97 CPointsbbox->attach_next_to(*copyCPoints, sideEnd, 1, 1);
98 CPointsbbox->attach_next_to(*pasteCPoints, sideEnd, 1, 1);
99 CPointsbbox->attach_next_to(*loadCPoints, sideEnd, 1, 1);
100 CPointsbbox->attach_next_to(*saveCPoints, sideEnd, 1, 1);
101
102 {
103 std::vector<Axis> axis;
104 axis.resize(4);
105 axis.at(0).setValues(M("CURVEEDITOR_AXIS_IN"), 5, 0.001, 0.01, 0., 1.);
106 axis.at(1).setValues(M("CURVEEDITOR_AXIS_OUT"), 5, 0.001, 0.01, 0., 1.);
107 axis.at(2).setValues(M("CURVEEDITOR_AXIS_LEFT_TAN"), 5, 0.01, 0.1, 0., 1.);
108 axis.at(3).setValues(M("CURVEEDITOR_AXIS_RIGHT_TAN"), 5, 0.01, 0.1, 0., 1.);
109 CPointsCoordAdjuster = Gtk::manage (new CoordinateAdjuster(CPointsCurve, this, axis));
110 CPointsCoordAdjuster->get_style_context()->add_class("curve-spinbuttonbox");
111 }
112
113 // Button box position: 0=above, 1=right, 2=below, 3=left
114 CPointsCurveGrid->add(*CPointsCurveBox);
115 CPointsCurve->set_hexpand(true);
116
117 if (options.curvebboxpos == 0) {
118 CPointsCurveGrid->attach_next_to(*CPointsbbox, *CPointsCurveBox, Gtk::POS_TOP, 1, 1);
119 CPointsCurveGrid->attach_next_to(*CPointsCoordAdjuster, *CPointsCurveBox, Gtk::POS_BOTTOM, 1, 1);
120 } else if (options.curvebboxpos == 1) {
121 CPointsCurveGrid->attach_next_to(*CPointsbbox, *CPointsCurveBox, Gtk::POS_RIGHT, 1, 1);
122 CPointsCurveGrid->attach_next_to(*CPointsCoordAdjuster, *CPointsCurveBox, Gtk::POS_BOTTOM, 2, 1);
123 } else if (options.curvebboxpos == 2) {
124 CPointsCurveGrid->attach_next_to(*CPointsCoordAdjuster, *CPointsCurveBox, Gtk::POS_BOTTOM, 1, 1);
125 CPointsCurveGrid->attach_next_to(*CPointsbbox, *CPointsCoordAdjuster, Gtk::POS_BOTTOM, 1, 1);
126 } else if (options.curvebboxpos == 3) {
127 CPointsCurveGrid->attach_next_to(*CPointsbbox, *CPointsCurveBox, Gtk::POS_LEFT, 1, 1);
128 CPointsCurveGrid->attach_next_to(*CPointsCoordAdjuster, *CPointsbbox, Gtk::POS_BOTTOM, 2, 1);
129 }
130
131 CPointsCurveGrid->show_all ();
132 CPointsCoordAdjuster->hide();
133
134 saveCPoints->signal_clicked().connect( sigc::mem_fun(*this, &FlatCurveEditorSubGroup::savePressed) );
135 loadCPoints->signal_clicked().connect( sigc::mem_fun(*this, &FlatCurveEditorSubGroup::loadPressed) );
136 copyCPoints->signal_clicked().connect( sigc::mem_fun(*this, &FlatCurveEditorSubGroup::copyPressed) );
137 pasteCPoints->signal_clicked().connect( sigc::mem_fun(*this, &FlatCurveEditorSubGroup::pastePressed) );
138 editPointCPointsConn = editPointCPoints->signal_toggled().connect( sigc::bind(sigc::mem_fun(*this, &FlatCurveEditorSubGroup::editPointToggled), editPointCPoints) );
139 editCPointsConn = editCPoints->signal_toggled().connect( sigc::bind(sigc::mem_fun(*this, &FlatCurveEditorSubGroup::editToggled), editCPoints) );
140
141 saveCPoints->set_tooltip_text (M("CURVEEDITOR_TOOLTIPSAVE"));
142 loadCPoints->set_tooltip_text (M("CURVEEDITOR_TOOLTIPLOAD"));
143 copyCPoints->set_tooltip_text (M("CURVEEDITOR_TOOLTIPCOPY"));
144 pasteCPoints->set_tooltip_text (M("CURVEEDITOR_TOOLTIPPASTE"));
145
146 CPointsCurve->setCurveListener (parent); // Send the message directly to the parent
147 }
148
~FlatCurveEditorSubGroup()149 FlatCurveEditorSubGroup::~FlatCurveEditorSubGroup()
150 {
151 delete CPointsCurveGrid;
152 }
153
154 /*
155 * Add a new curve to the curves list
156 */
addCurve(Glib::ustring curveLabel,bool isPeriodic)157 FlatCurveEditor* FlatCurveEditorSubGroup::addCurve(Glib::ustring curveLabel, bool isPeriodic)
158 {
159 FlatCurveEditor* newCE = new FlatCurveEditor(curveLabel, parent, this, isPeriodic);
160
161 // Initialization of the new curve
162 storeCurveValues(newCE, getCurveFromGUI(FCT_MinMaxCPoints));
163 return newCE;
164 }
165
showCoordinateAdjuster(CoordinateProvider * provider)166 void FlatCurveEditorSubGroup::showCoordinateAdjuster(CoordinateProvider *provider)
167 {
168 if (provider == CPointsCurve) {
169 if (!editPointCPoints->get_active()) {
170 editPointCPoints->set_active(true);
171 }
172 }
173 }
174
stopNumericalAdjustment()175 void FlatCurveEditorSubGroup::stopNumericalAdjustment()
176 {
177 CPointsCurve->stopNumericalAdjustment();
178 }
179
180
181 /*
182 * Force the resize of the curve editor, if the displayed one is the requested one
183 */
refresh(CurveEditor * curveToRefresh)184 void FlatCurveEditorSubGroup::refresh(CurveEditor *curveToRefresh)
185 {
186 if (curveToRefresh != nullptr && curveToRefresh == static_cast<FlatCurveEditor*>(parent->displayedCurve)) {
187 switch(FlatCurveType(curveToRefresh->curveType->getSelected())) {
188 case (FCT_MinMaxCPoints):
189 CPointsCurve->refresh();
190 break;
191
192 default: // (DCT_Linear, DCT_Unchanged)
193 // ... do nothing
194 break;
195 }
196 }
197 }
198
199 /*
200 * Switch off the edit button
201 */
editModeSwitchedOff()202 void FlatCurveEditorSubGroup::editModeSwitchedOff ()
203 {
204 // toggling off all edit buttons, even if only one is toggle on
205 bool prevState = editCPointsConn.block(true);
206 editCPoints->set_active(false);
207 CPointsCurve->pipetteMouseOver(nullptr, nullptr, 0);
208 CPointsCurve->setDirty(true);
209
210 if (!prevState) {
211 editCPointsConn.block(false);
212 }
213 }
214
pipetteMouseOver(EditDataProvider * provider,int modifierKey)215 void FlatCurveEditorSubGroup::pipetteMouseOver(EditDataProvider *provider, int modifierKey)
216 {
217 CurveEditor *curveEditor = static_cast<FlatCurveEditor*>(parent->displayedCurve);
218
219 switch((FlatCurveType)(curveEditor->curveType->getSelected())) {
220 case (FCT_MinMaxCPoints):
221 CPointsCurve->pipetteMouseOver(curveEditor, provider, modifierKey);
222 CPointsCurve->setDirty(true);
223 break;
224
225 default: // (DCT_Linear, DCT_Unchanged)
226 // ... do nothing
227 break;
228 }
229 }
230
pipetteButton1Pressed(EditDataProvider * provider,int modifierKey)231 bool FlatCurveEditorSubGroup::pipetteButton1Pressed(EditDataProvider *provider, int modifierKey)
232 {
233 CurveEditor *curveEditor = static_cast<FlatCurveEditor*>(parent->displayedCurve);
234
235 bool isDragging = false;
236
237 switch((FlatCurveType)(curveEditor->curveType->getSelected())) {
238 case (FCT_MinMaxCPoints):
239 isDragging = CPointsCurve->pipetteButton1Pressed(provider, modifierKey);
240 CPointsCurve->setDirty(true);
241 break;
242
243 default: // (DCT_Linear, DCT_Unchanged)
244 // ... do nothing
245 break;
246 }
247
248 return isDragging;
249 }
250
pipetteButton1Released(EditDataProvider * provider)251 void FlatCurveEditorSubGroup::pipetteButton1Released(EditDataProvider *provider)
252 {
253 CurveEditor *curveEditor = static_cast<FlatCurveEditor*>(parent->displayedCurve);
254
255 switch((FlatCurveType)(curveEditor->curveType->getSelected())) {
256 case (FCT_MinMaxCPoints):
257 CPointsCurve->pipetteButton1Released(provider);
258 CPointsCurve->setDirty(true);
259 break;
260
261 default: // (DCT_Linear, DCT_Unchanged)
262 // ... do nothing
263 break;
264 }
265 }
266
pipetteDrag(EditDataProvider * provider,int modifierKey)267 void FlatCurveEditorSubGroup::pipetteDrag(EditDataProvider *provider, int modifierKey)
268 {
269 CurveEditor *curveEditor = static_cast<FlatCurveEditor*>(parent->displayedCurve);
270
271 switch((FlatCurveType)(curveEditor->curveType->getSelected())) {
272 case (FCT_MinMaxCPoints):
273 CPointsCurve->pipetteDrag(provider, modifierKey);
274 CPointsCurve->setDirty(true);
275 break;
276
277 default: // (DCT_Linear, DCT_Unchanged)
278 // ... do nothing
279 break;
280 }
281 }
282
283 /*
284 * Switch the editor widgets to the currently edited curve
285 */
switchGUI()286 void FlatCurveEditorSubGroup::switchGUI()
287 {
288
289 removeEditor();
290
291 FlatCurveEditor* dCurve = static_cast<FlatCurveEditor*>(parent->displayedCurve);
292
293 if (dCurve) {
294
295 // Initializing GUI values + repacking the appropriated widget
296 //dCurve->typeconn.block(true);
297
298 // first we update the colored bar
299
300 ColorProvider *barColorProvider = dCurve->getLeftBarColorProvider();
301 std::vector<GradientMilestone> bgGradient = dCurve->getLeftBarBgGradient();
302
303 if (barColorProvider == nullptr && bgGradient.size() == 0) {
304 // dCurve has no left colored bar, so we delete the object
305 if (leftBar) {
306 delete leftBar;
307 leftBar = nullptr;
308 }
309 } else {
310 // dCurve has a ColorProvider or a background gradient defined, so we create/update the object
311 if (!leftBar) {
312 leftBar = new ColoredBar(RTO_Bottom2Top);
313 }
314
315 if (barColorProvider) {
316 bgGradient.clear();
317 leftBar->setColorProvider(barColorProvider, dCurve->getLeftBarCallerId());
318 leftBar->setBgGradient (bgGradient);
319 } else {
320 leftBar->setColorProvider(nullptr, -1);
321 leftBar->setBgGradient (bgGradient);
322 }
323 }
324
325 barColorProvider = dCurve->getBottomBarColorProvider();
326 bgGradient = dCurve->getBottomBarBgGradient();
327
328 if (barColorProvider == nullptr && bgGradient.size() == 0) {
329 // dCurve has no bottom colored bar, so we delete the object
330 if (bottomBar) {
331 delete bottomBar;
332 bottomBar = nullptr;
333 }
334 } else {
335 // dCurve ave a ColorProvider or a background gradient defined, so we create/update the object
336 if (!bottomBar) {
337 bottomBar = new ColoredBar(RTO_Left2Right);
338 }
339
340 if (barColorProvider) {
341 bgGradient.clear();
342 bottomBar->setColorProvider(barColorProvider, dCurve->getBottomBarCallerId());
343 bottomBar->setBgGradient (bgGradient);
344 } else {
345 bottomBar->setColorProvider(nullptr, -1);
346 bottomBar->setBgGradient (bgGradient);
347 }
348 }
349
350 switch((FlatCurveType)(dCurve->curveType->getSelected())) {
351 case (FCT_MinMaxCPoints):
352 CPointsCurve->setPeriodicity(dCurve->periodic); // Setting Periodicity before setting points
353 CPointsCurve->setPoints (dCurve->controlPointsCurveEd);
354 CPointsCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId());
355 CPointsCurve->setColoredBar(leftBar, bottomBar);
356 CPointsCurve->queue_resize_no_redraw();
357 updateEditButton(dCurve, editCPoints, editCPointsConn);
358 parent->attachCurve (CPointsCurveGrid);
359 CPointsCurveGrid->check_resize();
360 break;
361
362 default: // (DCT_Linear, DCT_Unchanged)
363 // ... do nothing
364 break;
365 }
366
367 //dCurve->typeconn.block(false);
368 }
369 }
370
savePressed()371 void FlatCurveEditorSubGroup::savePressed ()
372 {
373
374 Glib::ustring fname = outputFile();
375
376 if (fname.size()) {
377 std::ofstream f (fname.c_str());
378 std::vector<double> p;
379 //std::vector<double> p = customCurve->getPoints ();
380
381 switch (parent->displayedCurve->selected) {
382 case FCT_MinMaxCPoints: // Control points
383 p = CPointsCurve->getPoints ();
384 break;
385
386 default:
387 break;
388 }
389
390 int ix = 0;
391
392 if (p[ix] == (double)(FCT_Linear)) {
393 f << "Linear" << std::endl;
394 } else if (p[ix] == (double)(FCT_MinMaxCPoints)) {
395 f << "ControlPoints" << std::endl;
396 }
397
398 ix++;
399
400 for (unsigned int i = 0; i < p.size() / 2; i++, ix += 2) {
401 f << p[ix] << ' ' << p[ix + 1] << std::endl;
402 }
403
404 f.close ();
405 }
406 }
407
loadPressed()408 void FlatCurveEditorSubGroup::loadPressed ()
409 {
410
411 Glib::ustring fname = inputFile();
412
413 if (fname.size()) {
414 std::ifstream f (fname.c_str());
415
416 if (f) {
417 std::vector<double> p;
418 std::string s;
419 f >> s;
420
421 if (s == "Linear") {
422 p.push_back ((double)(FCT_Linear));
423 } else if (s == "ControlPoints") {
424 p.push_back ((double)(FCT_MinMaxCPoints));
425 } else {
426 return;
427 }
428
429 double x;
430
431 while (f) {
432 f >> x;
433
434 if (f) {
435 p.push_back (x);
436 }
437 }
438
439 rtengine::sanitizeCurve(p);
440
441 if (p[0] == (double)(FCT_MinMaxCPoints)) {
442 CPointsCurve->setPoints (p);
443 CPointsCurve->queue_draw ();
444 CPointsCurve->notifyListener ();
445 }
446 }
447 }
448 }
449
copyPressed()450 void FlatCurveEditorSubGroup::copyPressed ()
451 {
452 // For compatibility use enum FlatCurveType here
453
454 std::vector<double> curve;
455
456 switch (parent->displayedCurve->selected) {
457 case FCT_MinMaxCPoints: // custom
458 curve = CPointsCurve->getPoints ();
459 clipboard.setFlatCurveData (curve, FCT_MinMaxCPoints);
460 break;
461
462 default: // (DCT_Linear, DCT_Unchanged)
463 // ... do nothing
464 break;
465 }
466 }
467
pastePressed()468 void FlatCurveEditorSubGroup::pastePressed ()
469 {
470 // For compatibility use enum FlatCurveType here
471
472 std::vector<double> curve;
473 FlatCurveType type;
474
475 type = clipboard.hasFlatCurveData();
476
477 if (type == (FlatCurveType)parent->displayedCurve->selected) {
478 curve = clipboard.getFlatCurveData ();
479
480 switch (type) {
481 case FCT_MinMaxCPoints: // min/max control points
482 CPointsCurve->setPoints (curve);
483 CPointsCurve->queue_draw ();
484 CPointsCurve->notifyListener ();
485 break;
486
487 default: // (FCT_Linear, FCT_Unchanged)
488 // ... do nothing
489 break;
490 }
491 }
492
493 return;
494 }
495
editPointToggled(Gtk::ToggleButton * button)496 void FlatCurveEditorSubGroup::editPointToggled(Gtk::ToggleButton *button)
497 {
498 if (button->get_active()) {
499 CPointsCoordAdjuster->show();
500 } else {
501 CPointsCurve->stopNumericalAdjustment();
502 CPointsCoordAdjuster->hide();
503 }
504 }
505
editToggled(Gtk::ToggleButton * button)506 void FlatCurveEditorSubGroup::editToggled (Gtk::ToggleButton *button)
507 {
508 FlatCurveEditor* dCurve = static_cast<FlatCurveEditor*>(parent->displayedCurve);
509
510 if (!dCurve)
511 // should never happen!
512 {
513 return;
514 }
515
516 if (button->get_active()) {
517 dCurve->subscribe();
518 CPointsCurve->notifyListener ();
519
520 } else {
521 dCurve->unsubscribe();
522 }
523 }
524
525
526 /*
527 * Store the curves of the currently displayed type from the widgets to the CurveEditor object
528 */
storeDisplayedCurve()529 void FlatCurveEditorSubGroup::storeDisplayedCurve()
530 {
531 if (parent->displayedCurve) {
532 switch (parent->displayedCurve->selected) {
533 /*case (FCT_Parametric):
534 storeCurveValues(parent->displayedCurve, getCurveFromGUI(FCT_Parametric));
535 break;*/
536 case (FCT_MinMaxCPoints):
537 storeCurveValues(parent->displayedCurve, getCurveFromGUI(FCT_MinMaxCPoints));
538 break;
539
540 default:
541 break;
542 }
543 }
544 }
545
546 /*
547 * Restore the histogram to all types from the CurveEditor object to the widgets
548 */
restoreDisplayedHistogram()549 void FlatCurveEditorSubGroup::restoreDisplayedHistogram()
550 {
551 if (parent->displayedCurve) {
552 //paramCurve->updateBackgroundHistogram (parent->displayedCurve->histogram);
553 CPointsCurve->updateBackgroundHistogram (parent->displayedCurve->histogram);
554 }
555
556 }
557
storeCurveValues(CurveEditor * ce,const std::vector<double> & p)558 void FlatCurveEditorSubGroup::storeCurveValues (CurveEditor* ce, const std::vector<double>& p)
559 {
560 if (!p.empty()) {
561 FlatCurveType t = static_cast<FlatCurveType>(p[0]);
562
563 switch (t) {
564 case (FCT_MinMaxCPoints):
565 static_cast<FlatCurveEditor*>(ce)->controlPointsCurveEd = p;
566 break;
567
568 default:
569 break;
570 }
571 }
572 }
573
574 /*
575 * Called to update the parametric curve graph with new slider values
576 */
getCurveFromGUI(int type)577 const std::vector<double> FlatCurveEditorSubGroup::getCurveFromGUI (int type)
578 {
579 switch ((FlatCurveType)type) {
580 case (FCT_MinMaxCPoints):
581 return CPointsCurve->getPoints ();
582
583 default: {
584 // linear and other solutions
585 std::vector<double> lcurve (1);
586 lcurve[0] = (double)(FCT_Linear);
587 return lcurve;
588 }
589 }
590 }
591
592 /*
593 * Unlink the tree editor widgets from their parent box to hide them
594 */
removeEditor()595 void FlatCurveEditorSubGroup::removeEditor ()
596 {
597 removeIfThere (parent, CPointsCurveGrid, false);
598 }
599
curveReset(CurveEditor * ce)600 bool FlatCurveEditorSubGroup::curveReset(CurveEditor *ce)
601 {
602 if (!ce) {
603 return false;
604 }
605
606 FlatCurveEditor *fce = static_cast<FlatCurveEditor*>(ce);
607
608 switch (FlatCurveType(ce->selected)) {
609 case (FCT_MinMaxCPoints) : // = Control cage
610 CPointsCurve->reset (fce->controlPointsResetCurve, fce->getIdentityValue());
611 return true;
612 break;
613
614 /*case (FCT_Parametric) :
615 highlights->resetPressed();
616 lights->resetPressed();
617 darks->resetPressed();
618 shadows->resetPressed();
619 shcSelector->reset();
620 paramCurve->reset ();
621 return true;
622 break;*/
623 default:
624 return false;
625 break;
626 }
627
628 return true;
629 }
630
631
showEditButton(bool yes)632 void FlatCurveEditorSubGroup::showEditButton(bool yes)
633 {
634 editCPoints->set_visible(yes);
635 }
636
637 /*void FlatCurveEditorSubGroup::updateBackgroundHistogram (CurveEditor* ce) {
638 CurveEditor* fce = (CurveEditor*)ce;
639 if (fce==displayedCurve) {
640 paramCurve->updateBackgroundHistogram (fce->bgHistValid ? fce->histogram : NULL);
641 customCurve->updateBackgroundHistogram (fce->bgHistValid ? fce->histogram : NULL);
642 NURBSCurve->updateBackgroundHistogram (fce->bgHistValid ? fce->histogram : NULL);
643 }
644 }*/
645