Clipboard, save/load for curves, on behalf of Wolfgang; see issue #642
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <rtengine.h>
|
||||
#include <mydiagonalcurve.h>
|
||||
|
||||
class Clipboard {
|
||||
|
||||
@@ -28,7 +29,7 @@ class Clipboard {
|
||||
std::vector<rtengine::procparams::IPTCPair> iptc;
|
||||
bool _hasProcParams;
|
||||
rtengine::procparams::ProcParams procParams;
|
||||
bool _hasCurveData;
|
||||
DiagonalCurveType hasCurveDataType;
|
||||
std::vector<double> curve;
|
||||
|
||||
|
||||
@@ -41,9 +42,9 @@ class Clipboard {
|
||||
const rtengine::procparams::ProcParams& getProcParams () { return procParams; }
|
||||
bool hasProcParams () { return _hasProcParams; }
|
||||
|
||||
void setCurveData (std::vector<double>& p ) { curve = p; _hasCurveData = true; return; }
|
||||
void setCurveData (std::vector<double>& p, DiagonalCurveType type ) { curve = p; hasCurveDataType = type; return; }
|
||||
const std::vector<double> & getCurveData () { return curve; }
|
||||
bool hasCurveData () { return _hasCurveData; }
|
||||
DiagonalCurveType hasCurveData () { return hasCurveDataType; }
|
||||
|
||||
|
||||
};
|
||||
|
@@ -54,16 +54,16 @@ DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt)
|
||||
saveCustom->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-save"), Gtk::ICON_SIZE_BUTTON)));
|
||||
loadCustom = Gtk::manage (new Gtk::Button ());
|
||||
loadCustom->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-open"), Gtk::ICON_SIZE_BUTTON)));
|
||||
copyCustom = Gtk::manage (new Gtk::Button ());
|
||||
copyCustom->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-copy"), Gtk::ICON_SIZE_BUTTON)));
|
||||
pasteCustom = Gtk::manage (new Gtk::Button ());
|
||||
pasteCustom->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-paste"), Gtk::ICON_SIZE_BUTTON)));
|
||||
copyCustom = Gtk::manage (new Gtk::Button ());
|
||||
copyCustom->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-copy"), Gtk::ICON_SIZE_BUTTON)));
|
||||
|
||||
|
||||
custombbox->pack_end (*saveCustom, Gtk::PACK_SHRINK, 0);
|
||||
custombbox->pack_end (*loadCustom, Gtk::PACK_SHRINK, 0);
|
||||
custombbox->pack_end (*copyCustom, Gtk::PACK_SHRINK, 0);
|
||||
custombbox->pack_end (*pasteCustom, Gtk::PACK_SHRINK, 0);
|
||||
custombbox->pack_end (*copyCustom, Gtk::PACK_SHRINK, 0);
|
||||
|
||||
|
||||
customCurveBox->pack_end (*custombbox, Gtk::PACK_SHRINK, 0);
|
||||
@@ -78,6 +78,7 @@ DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt)
|
||||
loadCustom->set_tooltip_text (M("CURVEEDITOR_TOOLTIPLOAD"));
|
||||
copyCustom->set_tooltip_text (M("CURVEEDITOR_TOOLTIPCOPY"));
|
||||
pasteCustom->set_tooltip_text (M("CURVEEDITOR_TOOLTIPPASTE"));
|
||||
// Custom curve end
|
||||
|
||||
|
||||
// NURBS curve
|
||||
@@ -86,6 +87,7 @@ DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt)
|
||||
NURBSCurve = Gtk::manage (new MyDiagonalCurve ());
|
||||
NURBSCurve->set_size_request (GRAPH_SIZE+2*RADIUS, GRAPH_SIZE+2*RADIUS);
|
||||
NURBSCurve->setType (DCT_NURBS);
|
||||
|
||||
//customCurve->set_tooltip_text (M("CURVEEDITOR_TOOLTIPMOVESPEED"));
|
||||
NURBSCurveBox->pack_start (*NURBSCurve, Gtk::PACK_EXPAND_WIDGET, 0);
|
||||
|
||||
@@ -95,32 +97,84 @@ DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt)
|
||||
saveNURBS->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-save"), Gtk::ICON_SIZE_BUTTON)));
|
||||
loadNURBS = Gtk::manage (new Gtk::Button ());
|
||||
loadNURBS->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-open"), Gtk::ICON_SIZE_BUTTON)));
|
||||
pasteNURBS = Gtk::manage (new Gtk::Button ());
|
||||
pasteNURBS->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-paste"), Gtk::ICON_SIZE_BUTTON)));
|
||||
copyNURBS = Gtk::manage (new Gtk::Button ());
|
||||
copyNURBS->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-copy"), Gtk::ICON_SIZE_BUTTON)));
|
||||
|
||||
NURBSbbox->pack_end (*saveNURBS, Gtk::PACK_SHRINK, 0);
|
||||
NURBSbbox->pack_end (*loadNURBS, Gtk::PACK_SHRINK, 0);
|
||||
NURBSbbox->pack_end (*pasteNURBS, Gtk::PACK_SHRINK, 0);
|
||||
NURBSbbox->pack_end (*copyNURBS, Gtk::PACK_SHRINK, 0);
|
||||
|
||||
NURBSCurveBox->pack_end (*NURBSbbox, Gtk::PACK_SHRINK, 0);
|
||||
NURBSCurveBox->show_all ();
|
||||
|
||||
saveNURBS->signal_clicked().connect( sigc::mem_fun(*this, &DiagonalCurveEditorSubGroup::savePressed) );
|
||||
loadNURBS->signal_clicked().connect( sigc::mem_fun(*this, &DiagonalCurveEditorSubGroup::loadPressed) );
|
||||
pasteNURBS->signal_clicked().connect( sigc::mem_fun(*this, &DiagonalCurveEditorSubGroup::pastePressed) );
|
||||
copyNURBS->signal_clicked().connect( sigc::mem_fun(*this, &DiagonalCurveEditorSubGroup::copyPressed) );
|
||||
|
||||
saveNURBS->set_tooltip_text (M("CURVEEDITOR_TOOLTIPSAVE"));
|
||||
loadNURBS->set_tooltip_text (M("CURVEEDITOR_TOOLTIPLOAD"));
|
||||
pasteNURBS->set_tooltip_text (M("CURVEEDITOR_TOOLTIPPASTE"));
|
||||
copyNURBS->set_tooltip_text (M("CURVEEDITOR_TOOLTIPCOPY"));
|
||||
// NURBS curve end
|
||||
|
||||
|
||||
// parametric curve
|
||||
paramCurveBox = new Gtk::VBox ();
|
||||
paramCurveBox->set_spacing(4);
|
||||
// Wolfgang START
|
||||
paramInnerBox = new Gtk::HBox ();
|
||||
paramInnerBox->set_spacing(4);
|
||||
// Wolfgang END
|
||||
|
||||
paramCurve = Gtk::manage (new MyDiagonalCurve ());
|
||||
Gtk::Table* paramctab = Gtk::manage (new Gtk::Table (2,1));
|
||||
paramCurve->set_size_request (GRAPH_SIZE+2*RADIUS, GRAPH_SIZE+2*RADIUS);
|
||||
paramCurve->setType (DCT_Parametric);
|
||||
|
||||
shcSelector = Gtk::manage (new SHCSelector ());
|
||||
shcSelector->set_size_request (GRAPH_SIZE, 20);
|
||||
|
||||
paramctab->attach (*paramCurve, 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
|
||||
paramctab->attach (*shcSelector, 0, 1, 1, 2, Gtk::FILL, Gtk::SHRINK, RADIUS, 0);
|
||||
|
||||
paramCurveBox->pack_start (*paramctab, Gtk::PACK_EXPAND_WIDGET, 0);
|
||||
// Wolfgang Change: paramCurveBox->pack_start (*paramctab, Gtk::PACK_EXPAND_WIDGET, 0);
|
||||
paramInnerBox->pack_start (*paramctab, Gtk::PACK_EXPAND_WIDGET, 0);
|
||||
|
||||
// Wolfgang START
|
||||
Gtk::VBox* Parambbox = Gtk::manage (new Gtk::VBox ());
|
||||
Parambbox->set_spacing(4);
|
||||
saveParam = Gtk::manage (new Gtk::Button ());
|
||||
saveParam->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-save"), Gtk::ICON_SIZE_BUTTON)));
|
||||
loadParam = Gtk::manage (new Gtk::Button ());
|
||||
loadParam->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-open"), Gtk::ICON_SIZE_BUTTON)));
|
||||
pasteParam = Gtk::manage (new Gtk::Button ());
|
||||
pasteParam->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-paste"), Gtk::ICON_SIZE_BUTTON)));
|
||||
copyParam = Gtk::manage (new Gtk::Button ());
|
||||
copyParam->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-copy"), Gtk::ICON_SIZE_BUTTON)));
|
||||
|
||||
Parambbox->pack_end (*saveParam, Gtk::PACK_SHRINK, 0);
|
||||
Parambbox->pack_end (*loadParam, Gtk::PACK_SHRINK, 0);
|
||||
Parambbox->pack_end (*pasteParam, Gtk::PACK_SHRINK, 0);
|
||||
Parambbox->pack_end (*copyParam, Gtk::PACK_SHRINK, 0);
|
||||
|
||||
saveParam->signal_clicked().connect( sigc::mem_fun(*this, &DiagonalCurveEditorSubGroup::savePressed) );
|
||||
loadParam->signal_clicked().connect( sigc::mem_fun(*this, &DiagonalCurveEditorSubGroup::loadPressed) );
|
||||
pasteParam->signal_clicked().connect( sigc::mem_fun(*this, &DiagonalCurveEditorSubGroup::pastePressed) );
|
||||
copyParam->signal_clicked().connect( sigc::mem_fun(*this, &DiagonalCurveEditorSubGroup::copyPressed) );
|
||||
|
||||
saveParam->set_tooltip_text (M("CURVEEDITOR_TOOLTIPSAVE"));
|
||||
loadParam->set_tooltip_text (M("CURVEEDITOR_TOOLTIPLOAD"));
|
||||
pasteParam->set_tooltip_text (M("CURVEEDITOR_TOOLTIPPASTE"));
|
||||
copyParam->set_tooltip_text (M("CURVEEDITOR_TOOLTIPCOPY"));
|
||||
|
||||
paramInnerBox->pack_start (*Parambbox, Gtk::PACK_EXPAND_WIDGET, 0);
|
||||
|
||||
paramCurveBox->pack_start (*paramInnerBox, Gtk::PACK_SHRINK, 0);
|
||||
// Wolfgang END
|
||||
|
||||
highlights = Gtk::manage (new Adjuster (M("CURVEEDITOR_HIGHLIGHTS"), -100, 100, 1, 0));
|
||||
lights = Gtk::manage (new Adjuster (M("CURVEEDITOR_LIGHTS"), -100, 100, 1, 0));
|
||||
@@ -142,7 +196,11 @@ DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt)
|
||||
paramCurveBox->pack_start (*evlights);
|
||||
paramCurveBox->pack_start (*evdarks);
|
||||
paramCurveBox->pack_start (*evshadows);
|
||||
|
||||
paramCurveBox->show_all ();
|
||||
// parametric curve end
|
||||
|
||||
|
||||
|
||||
customCurveBox->reference ();
|
||||
paramCurveBox->reference ();
|
||||
@@ -175,6 +233,9 @@ DiagonalCurveEditorSubGroup::~DiagonalCurveEditorSubGroup() {
|
||||
delete customCurveBox;
|
||||
delete paramCurveBox;
|
||||
delete NURBSCurveBox;
|
||||
// Wolfgang START
|
||||
delete paramInnerBox;
|
||||
// Wolfgang END
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -253,12 +314,17 @@ void DiagonalCurveEditorSubGroup::savePressed () {
|
||||
//std::vector<double> p = customCurve->getPoints ();
|
||||
|
||||
switch (parent->displayedCurve->selected) {
|
||||
case DCT_Spline: // custom
|
||||
case DCT_Spline: // custom
|
||||
p = customCurve->getPoints ();
|
||||
break;
|
||||
case DCT_NURBS: // NURBS
|
||||
p = NURBSCurve->getPoints ();
|
||||
break;
|
||||
// Wolfgang Start
|
||||
case DCT_Parametric:
|
||||
p = paramCurve->getPoints ();
|
||||
break;
|
||||
// Wolfgang End
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -270,9 +336,21 @@ void DiagonalCurveEditorSubGroup::savePressed () {
|
||||
f << "Spline\n";
|
||||
else if (p[ix]==(double)(DCT_NURBS))
|
||||
f << "NURBS\n";
|
||||
ix++;
|
||||
for (unsigned int i=0; i<p.size()/2; i++, ix+=2)
|
||||
// Wolfgang Start
|
||||
else if (p[ix]==(double)(DCT_Parametric))
|
||||
f << "Parametric\n";
|
||||
if (p[ix]==(double)(DCT_Parametric)) {
|
||||
ix++;
|
||||
for (unsigned int i=0; i<p.size()-1; i++, ix++)
|
||||
f << p[ix] << std::endl;
|
||||
}
|
||||
// Wolfgang End
|
||||
else {
|
||||
ix++;
|
||||
for (unsigned int i=0; i<p.size()/2; i++, ix+=2)
|
||||
f << p[ix] << ' ' << p[ix+1] << std::endl;
|
||||
}
|
||||
|
||||
f.close ();
|
||||
}
|
||||
}
|
||||
@@ -292,7 +370,10 @@ void DiagonalCurveEditorSubGroup::loadPressed () {
|
||||
p.push_back ((double)(DCT_Spline));
|
||||
else if (s=="NURBS")
|
||||
p.push_back ((double)(DCT_NURBS));
|
||||
else if (s=="Parametric")
|
||||
p.push_back ((double)(DCT_Parametric));
|
||||
else return;
|
||||
|
||||
double x;
|
||||
while (f) {
|
||||
f >> x;
|
||||
@@ -309,34 +390,91 @@ void DiagonalCurveEditorSubGroup::loadPressed () {
|
||||
NURBSCurve->queue_draw ();
|
||||
NURBSCurve->notifyListener ();
|
||||
}
|
||||
else if (p[0] == (double)(DCT_Parametric)) {
|
||||
shcSelector->setPositions (
|
||||
p[1],
|
||||
p[2],
|
||||
p[3] );
|
||||
highlights->setValue (p[4]);
|
||||
lights->setValue (p[5]);
|
||||
darks->setValue (p[6]);
|
||||
shadows->setValue (p[7]);
|
||||
paramCurve->setPoints (p);
|
||||
paramCurve->queue_draw ();
|
||||
paramCurve->notifyListener ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DiagonalCurveEditorSubGroup::copyPressed () {
|
||||
// For compatibility use enum DiagonalCurveType here
|
||||
|
||||
std::vector<double> curve;
|
||||
|
||||
switch (parent->displayedCurve->selected) {
|
||||
case DCT_Spline: // custom
|
||||
curve = customCurve->getPoints ();
|
||||
clipboard.setCurveData (curve);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (parent->displayedCurve->selected) {
|
||||
case DCT_Spline: // custom
|
||||
curve = customCurve->getPoints ();
|
||||
clipboard.setCurveData (curve,DCT_Spline);
|
||||
break;
|
||||
case DCT_Parametric: // parametric
|
||||
// ... do something, first add save/load functions
|
||||
curve = paramCurve->getPoints ();
|
||||
clipboard.setCurveData (curve,DCT_Parametric);
|
||||
break;
|
||||
case DCT_NURBS: // NURBS
|
||||
curve = NURBSCurve->getPoints ();
|
||||
clipboard.setCurveData (curve,DCT_NURBS);
|
||||
break;
|
||||
default: // (DCT_Linear, DCT_Unchanged)
|
||||
// ... do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DiagonalCurveEditorSubGroup::pastePressed () {
|
||||
// For compatibility use enum DiagonalCurveType here
|
||||
|
||||
std::vector<double> curve;
|
||||
DiagonalCurveType type;
|
||||
|
||||
if (!clipboard.hasCurveData()) {
|
||||
return; }
|
||||
curve = clipboard.getCurveData ();
|
||||
type = clipboard.hasCurveData();
|
||||
|
||||
customCurve->setPoints (curve);
|
||||
customCurve->queue_draw ();
|
||||
customCurve->notifyListener ();
|
||||
if (type == (DiagonalCurveType)parent->displayedCurve->selected) {
|
||||
curve = clipboard.getCurveData ();
|
||||
switch (type) {
|
||||
case DCT_Linear: // linear
|
||||
break;
|
||||
case DCT_Spline: // custom
|
||||
customCurve->setPoints (curve);
|
||||
customCurve->queue_draw ();
|
||||
customCurve->notifyListener ();
|
||||
break;
|
||||
case DCT_Parametric: // parametric
|
||||
// ... do something, first add save/load functions
|
||||
shcSelector->setPositions (
|
||||
curve[1],
|
||||
curve[2],
|
||||
curve[3] );
|
||||
highlights->setValue (curve[4]);
|
||||
lights->setValue (curve[5]);
|
||||
darks->setValue (curve[6]);
|
||||
shadows->setValue (curve[7]);
|
||||
paramCurve->setPoints (curve);
|
||||
paramCurve->queue_draw ();
|
||||
paramCurve->notifyListener ();
|
||||
break;
|
||||
case DCT_NURBS: // NURBS
|
||||
NURBSCurve->setPoints (curve);
|
||||
NURBSCurve->queue_draw ();
|
||||
NURBSCurve->notifyListener ();
|
||||
break;
|
||||
default: // (DCT_Linear, DCT_Unchanged)
|
||||
// ... do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -31,6 +31,9 @@ class DiagonalCurveEditorSubGroup : public CurveEditorSubGroup, public SHCListen
|
||||
protected:
|
||||
Gtk::HBox* customCurveBox;
|
||||
Gtk::VBox* paramCurveBox;
|
||||
// Wolfgang Start
|
||||
Gtk::HBox* paramInnerBox;
|
||||
// Wolfgang End
|
||||
Gtk::HBox* NURBSCurveBox;
|
||||
|
||||
MyDiagonalCurve* customCurve;
|
||||
@@ -49,6 +52,12 @@ protected:
|
||||
Gtk::Button* pasteCustom;
|
||||
Gtk::Button* saveNURBS;
|
||||
Gtk::Button* loadNURBS;
|
||||
Gtk::Button* copyNURBS;
|
||||
Gtk::Button* pasteNURBS;
|
||||
Gtk::Button* saveParam;
|
||||
Gtk::Button* loadParam;
|
||||
Gtk::Button* copyParam;
|
||||
Gtk::Button* pasteParam;
|
||||
|
||||
int activeParamControl;
|
||||
|
||||
|
Reference in New Issue
Block a user