Solving issue 1656: "CH and HSV curves lack copy/paste functions"

This commit is contained in:
natureh 510
2013-01-27 17:44:15 +01:00
parent 56dc7284d1
commit cc3458a82f
4 changed files with 74 additions and 12 deletions

View File

@@ -23,6 +23,7 @@
#include "../rtengine/rtengine.h"
#include "../rtengine/procparams.h"
#include "paramsedited.h"
#include "myflatcurve.h"
#include "mydiagonalcurve.h"
class Clipboard {
@@ -30,8 +31,10 @@ class Clipboard {
bool _hasIPTC;
rtengine::procparams::IPTCPairs iptc;
rtengine::procparams::PartialProfile partProfile;
DiagonalCurveType hasCurveDataType;
std::vector<double> curve;
DiagonalCurveType hasDiagonalCurveDataType;
FlatCurveType hasFlatCurveDataType;
std::vector<double> diagonalCurve;
std::vector<double> flatCurve;
public:
@@ -46,9 +49,13 @@ class Clipboard {
bool hasProcParams () { return partProfile.pparams; }
bool hasPEdited () { return partProfile.pedited; }
void setCurveData (std::vector<double>& p, DiagonalCurveType type ) { curve = p; hasCurveDataType = type; return; }
const std::vector<double> & getCurveData () { return curve; }
DiagonalCurveType hasCurveData () { return hasCurveDataType; }
void setDiagonalCurveData (std::vector<double>& p, DiagonalCurveType type ) { diagonalCurve = p; hasDiagonalCurveDataType = type; return; }
const std::vector<double> & getDiagonalCurveData () { return diagonalCurve; }
DiagonalCurveType hasDiagonalCurveData () { return hasDiagonalCurveDataType; }
void setFlatCurveData (std::vector<double>& p, FlatCurveType type ) { flatCurve = p; hasFlatCurveDataType = type; return; }
const std::vector<double> & getFlatCurveData () { return flatCurve; }
FlatCurveType hasFlatCurveData () { return hasFlatCurveDataType; }
Clipboard ();
~Clipboard ();

View File

@@ -483,16 +483,16 @@ void DiagonalCurveEditorSubGroup::copyPressed () {
switch (parent->displayedCurve->selected) {
case DCT_Spline: // custom
curve = customCurve->getPoints ();
clipboard.setCurveData (curve,DCT_Spline);
clipboard.setDiagonalCurveData (curve,DCT_Spline);
break;
case DCT_Parametric: // parametric
// ... do something, first add save/load functions
curve = paramCurve->getPoints ();
clipboard.setCurveData (curve,DCT_Parametric);
clipboard.setDiagonalCurveData (curve,DCT_Parametric);
break;
case DCT_NURBS: // NURBS
curve = NURBSCurve->getPoints ();
clipboard.setCurveData (curve,DCT_NURBS);
clipboard.setDiagonalCurveData (curve,DCT_NURBS);
break;
default: // (DCT_Linear, DCT_Unchanged)
// ... do nothing
@@ -506,13 +506,11 @@ void DiagonalCurveEditorSubGroup::pastePressed () {
std::vector<double> curve;
DiagonalCurveType type;
type = clipboard.hasCurveData();
type = clipboard.hasDiagonalCurveData();
if (type == (DiagonalCurveType)parent->displayedCurve->selected) {
curve = clipboard.getCurveData ();
curve = clipboard.getDiagonalCurveData ();
switch (type) {
case DCT_Linear: // linear
break;
case DCT_Spline: // custom
customCurve->setPoints (curve);
customCurve->queue_draw ();

View File

@@ -17,6 +17,7 @@
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#include "clipboard.h"
#include <gtkmm.h>
#include <fstream>
#include <string>
@@ -46,11 +47,18 @@ FlatCurveEditorSubGroup::FlatCurveEditorSubGroup (CurveEditorGroup* prt, Glib::u
Gtk::HBox* CPointsbbox = Gtk::manage (new Gtk::HBox ());
CPointsbbox->set_spacing(4);
pasteCPoints = Gtk::manage (new Gtk::Button ());
pasteCPoints->add (*Gtk::manage (new RTImage ("edit-paste.png")));
copyCPoints = Gtk::manage (new Gtk::Button ());
copyCPoints->add (*Gtk::manage (new RTImage ("edit-copy.png")));
saveCPoints = Gtk::manage (new Gtk::Button ());
saveCPoints->add (*Gtk::manage (new RTImage ("gtk-save-large.png")));
loadCPoints = Gtk::manage (new Gtk::Button ());
loadCPoints->add (*Gtk::manage (new RTImage ("gtk-open.png")));
CPointsbbox->pack_end (*pasteCPoints, Gtk::PACK_SHRINK, 0);
CPointsbbox->pack_end (*copyCPoints, Gtk::PACK_SHRINK, 0);
CPointsbbox->pack_end (*saveCPoints, Gtk::PACK_SHRINK, 0);
CPointsbbox->pack_end (*loadCPoints, Gtk::PACK_SHRINK, 0);
@@ -59,8 +67,13 @@ FlatCurveEditorSubGroup::FlatCurveEditorSubGroup (CurveEditorGroup* prt, Glib::u
saveCPoints->signal_clicked().connect( sigc::mem_fun(*this, &FlatCurveEditorSubGroup::savePressed) );
loadCPoints->signal_clicked().connect( sigc::mem_fun(*this, &FlatCurveEditorSubGroup::loadPressed) );
copyCPoints->signal_clicked().connect( sigc::mem_fun(*this, &FlatCurveEditorSubGroup::copyPressed) );
pasteCPoints->signal_clicked().connect( sigc::mem_fun(*this, &FlatCurveEditorSubGroup::pastePressed) );
saveCPoints->set_tooltip_text (M("CURVEEDITOR_TOOLTIPSAVE"));
loadCPoints->set_tooltip_text (M("CURVEEDITOR_TOOLTIPLOAD"));
copyCPoints->set_tooltip_text (M("CURVEEDITOR_TOOLTIPCOPY"));
pasteCPoints->set_tooltip_text (M("CURVEEDITOR_TOOLTIPPASTE"));
CPointsCurve->setCurveListener (parent); // Send the message directly to the parent
}
@@ -238,6 +251,46 @@ void FlatCurveEditorSubGroup::loadPressed () {
}
}
void FlatCurveEditorSubGroup::copyPressed () {
// For compatibility use enum FlatCurveType here
std::vector<double> curve;
switch (parent->displayedCurve->selected) {
case FCT_MinMaxCPoints: // custom
curve = CPointsCurve->getPoints ();
clipboard.setFlatCurveData (curve,FCT_MinMaxCPoints);
break;
default: // (DCT_Linear, DCT_Unchanged)
// ... do nothing
break;
}
}
void FlatCurveEditorSubGroup::pastePressed () {
// For compatibility use enum FlatCurveType here
std::vector<double> curve;
FlatCurveType type;
type = clipboard.hasFlatCurveData();
if (type == (FlatCurveType)parent->displayedCurve->selected) {
curve = clipboard.getFlatCurveData ();
switch (type) {
case FCT_MinMaxCPoints: // min/max control points
CPointsCurve->setPoints (curve);
CPointsCurve->queue_draw ();
CPointsCurve->notifyListener ();
break;
default: // (FCT_Linear, FCT_Unchanged)
// ... do nothing
break;
}
}
return;
}
/*
* Store the curves of the currently displayed type from the widgets to the CurveEditor object
*/

View File

@@ -35,6 +35,8 @@ protected:
Gtk::Button* saveCPoints;
Gtk::Button* loadCPoints;
Gtk::Button* copyCPoints;
Gtk::Button* pasteCPoints;
public:
FlatCurveEditorSubGroup(CurveEditorGroup* prt, Glib::ustring& curveDir);
@@ -51,6 +53,8 @@ protected:
void restoreDisplayedHistogram ();
void savePressed ();
void loadPressed ();
void copyPressed ();
void pastePressed ();
bool curveReset (int cType);
void removeEditor ();
const std::vector<double> getCurveFromGUI (int type);