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

View File

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

View File

@@ -17,6 +17,7 @@
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>. * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "clipboard.h"
#include <gtkmm.h> #include <gtkmm.h>
#include <fstream> #include <fstream>
#include <string> #include <string>
@@ -46,11 +47,18 @@ FlatCurveEditorSubGroup::FlatCurveEditorSubGroup (CurveEditorGroup* prt, Glib::u
Gtk::HBox* CPointsbbox = Gtk::manage (new Gtk::HBox ()); Gtk::HBox* CPointsbbox = Gtk::manage (new Gtk::HBox ());
CPointsbbox->set_spacing(4); 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 = Gtk::manage (new Gtk::Button ());
saveCPoints->add (*Gtk::manage (new RTImage ("gtk-save-large.png"))); saveCPoints->add (*Gtk::manage (new RTImage ("gtk-save-large.png")));
loadCPoints = Gtk::manage (new Gtk::Button ()); loadCPoints = Gtk::manage (new Gtk::Button ());
loadCPoints->add (*Gtk::manage (new RTImage ("gtk-open.png"))); 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 (*saveCPoints, Gtk::PACK_SHRINK, 0);
CPointsbbox->pack_end (*loadCPoints, 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) ); saveCPoints->signal_clicked().connect( sigc::mem_fun(*this, &FlatCurveEditorSubGroup::savePressed) );
loadCPoints->signal_clicked().connect( sigc::mem_fun(*this, &FlatCurveEditorSubGroup::loadPressed) ); 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")); saveCPoints->set_tooltip_text (M("CURVEEDITOR_TOOLTIPSAVE"));
loadCPoints->set_tooltip_text (M("CURVEEDITOR_TOOLTIPLOAD")); 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 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 * 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* saveCPoints;
Gtk::Button* loadCPoints; Gtk::Button* loadCPoints;
Gtk::Button* copyCPoints;
Gtk::Button* pasteCPoints;
public: public:
FlatCurveEditorSubGroup(CurveEditorGroup* prt, Glib::ustring& curveDir); FlatCurveEditorSubGroup(CurveEditorGroup* prt, Glib::ustring& curveDir);
@@ -51,6 +53,8 @@ protected:
void restoreDisplayedHistogram (); void restoreDisplayedHistogram ();
void savePressed (); void savePressed ();
void loadPressed (); void loadPressed ();
void copyPressed ();
void pastePressed ();
bool curveReset (int cType); bool curveReset (int cType);
void removeEditor (); void removeEditor ();
const std::vector<double> getCurveFromGUI (int type); const std::vector<double> getCurveFromGUI (int type);