Adding Pipette feature for the Parametric curve + bugfix of the SnapTo feature
This commit is contained in:
@@ -471,21 +471,21 @@ void Adjuster::editedToggled () {
|
|||||||
eventPending = false;
|
eventPending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Adjuster::trimValue (double& val) {
|
double Adjuster::trimValue (double val) {
|
||||||
|
|
||||||
if (val > vMax) val = vMax; // shapeValue(vMax) ?
|
if (val > vMax) val = vMax; // shapeValue(vMax) ?
|
||||||
else if (val < vMin) val = vMin; // shapeValue(vMin) ?
|
else if (val < vMin) val = vMin; // shapeValue(vMin) ?
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Adjuster::trimValue (int& val) {
|
int Adjuster::trimValue (int val) {
|
||||||
|
|
||||||
if (val > (int)vMax) val = (int)vMax; // shapeValue(vMax) ?
|
if (val > (int)vMax) val = (int)vMax; // shapeValue(vMax) ?
|
||||||
else if (val < (int)vMin) val = (int)vMin; // shapeValue(vMin) ?
|
else if (val < (int)vMin) val = (int)vMin; // shapeValue(vMin) ?
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Adjuster::trimValue (float& val) {
|
float Adjuster::trimValue (float val) {
|
||||||
|
|
||||||
if (val > (float)vMax) val = (float)vMax; // shapeValue(vMax) ?
|
if (val > (float)vMax) val = (float)vMax; // shapeValue(vMax) ?
|
||||||
else if (val < (float)vMin) val = (float)vMin; // shapeValue(vMin) ?
|
else if (val < (float)vMin) val = (float)vMin; // shapeValue(vMin) ?
|
||||||
|
@@ -126,9 +126,9 @@ class Adjuster : public Gtk::VBox {
|
|||||||
void resetValue (bool toInitial);
|
void resetValue (bool toInitial);
|
||||||
void resetPressed (GdkEventButton* event);
|
void resetPressed (GdkEventButton* event);
|
||||||
void editedToggled ();
|
void editedToggled ();
|
||||||
double trimValue (double& val);
|
double trimValue (double val);
|
||||||
float trimValue (float& val);
|
float trimValue (float val);
|
||||||
int trimValue (int& val);
|
int trimValue (int val);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -612,7 +612,7 @@ void CropWindow::pointerMoved (int bstate, int x, int y) {
|
|||||||
|
|
||||||
Coord oldPosScreen = iarea->posScreen+iarea->deltaScreen;
|
Coord oldPosScreen = iarea->posScreen+iarea->deltaScreen;
|
||||||
//printf(">>> SCR / ScrPrev(%d x %d) = (%d x %d) + (%d x %d)\n", oldPosScreen.x, oldPosScreen.y, iarea->posScreen.x, iarea->posScreen.y, iarea->deltaScreen.x, iarea->deltaScreen.y);
|
//printf(">>> SCR / ScrPrev(%d x %d) = (%d x %d) + (%d x %d)\n", oldPosScreen.x, oldPosScreen.y, iarea->posScreen.x, iarea->posScreen.y, iarea->deltaScreen.x, iarea->deltaScreen.y);
|
||||||
screenCoordToPreview(x, y, currPos.x, currPos.y);
|
currPos.set(x, y);
|
||||||
iarea->deltaScreen = currPos - iarea->posScreen;
|
iarea->deltaScreen = currPos - iarea->posScreen;
|
||||||
iarea->deltaPrevScreen = currPos - oldPosScreen;
|
iarea->deltaPrevScreen = currPos - oldPosScreen;
|
||||||
//printf(" action_ & xy (%d x %d) -> (%d x %d) = (%d x %d) + (%d x %d) / deltaPrev(%d x %d)\n", action_x, action_y, currPos.x, currPos.y, iarea->posScreen.x, iarea->posScreen.y, iarea->deltaScreen.x, iarea->deltaScreen.y, iarea->deltaPrevScreen.x, iarea->deltaPrevScreen.y);
|
//printf(" action_ & xy (%d x %d) -> (%d x %d) = (%d x %d) + (%d x %d) / deltaPrev(%d x %d)\n", action_x, action_y, currPos.x, currPos.y, iarea->posScreen.x, iarea->posScreen.y, iarea->deltaScreen.x, iarea->deltaScreen.y, iarea->deltaPrevScreen.x, iarea->deltaPrevScreen.y);
|
||||||
@@ -1474,7 +1474,6 @@ void CropWindow::screenCoordToPreview (int phyx, int phyy, int& prevx, int& prev
|
|||||||
void CropWindow::imageCoordToScreen (int imgx, int imgy, int& phyx, int& phyy) {
|
void CropWindow::imageCoordToScreen (int imgx, int imgy, int& phyx, int& phyy) {
|
||||||
|
|
||||||
int cropX, cropY;
|
int cropX, cropY;
|
||||||
rtengine::Crop* crop = static_cast<rtengine::Crop*>(cropHandler.getCrop());
|
|
||||||
cropHandler.getPosition (cropX, cropY);
|
cropHandler.getPosition (cropX, cropY);
|
||||||
phyx = (imgx - cropX)*zoomSteps[cropZoom].zoom + xpos + imgX;
|
phyx = (imgx - cropX)*zoomSteps[cropZoom].zoom + xpos + imgX;
|
||||||
phyy = (imgy - cropY)*zoomSteps[cropZoom].zoom + ypos + imgY;
|
phyy = (imgy - cropY)*zoomSteps[cropZoom].zoom + ypos + imgY;
|
||||||
|
@@ -32,6 +32,9 @@
|
|||||||
|
|
||||||
DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt, Glib::ustring& curveDir) : CurveEditorSubGroup(curveDir) {
|
DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt, Glib::ustring& curveDir) : CurveEditorSubGroup(curveDir) {
|
||||||
|
|
||||||
|
editedAdjuster = NULL;
|
||||||
|
editedAdjusterValue = 0;
|
||||||
|
|
||||||
valLinear = (int)DCT_Linear;
|
valLinear = (int)DCT_Linear;
|
||||||
valUnchanged = (int)DCT_Unchanged;
|
valUnchanged = (int)DCT_Unchanged;
|
||||||
parent = prt;
|
parent = prt;
|
||||||
@@ -277,8 +280,53 @@ void DiagonalCurveEditorSubGroup::pipetteMouseOver(EditDataProvider *provider, i
|
|||||||
customCurve->setDirty(true);
|
customCurve->setDirty(true);
|
||||||
break;
|
break;
|
||||||
case (DCT_Parametric):
|
case (DCT_Parametric):
|
||||||
|
{
|
||||||
paramCurve->pipetteMouseOver(provider, modifierKey);
|
paramCurve->pipetteMouseOver(provider, modifierKey);
|
||||||
paramCurve->setDirty(true);
|
paramCurve->setDirty(true);
|
||||||
|
float pipetteVal = 0.f;
|
||||||
|
editedAdjuster = NULL;
|
||||||
|
int n = 0;
|
||||||
|
if (provider->pipetteVal[0] != -1.f) {
|
||||||
|
pipetteVal += provider->pipetteVal[0];
|
||||||
|
++n;
|
||||||
|
}
|
||||||
|
if (provider->pipetteVal[1] != -1.f) {
|
||||||
|
pipetteVal += provider->pipetteVal[1];
|
||||||
|
++n;
|
||||||
|
}
|
||||||
|
if (provider->pipetteVal[2] != -1.f) {
|
||||||
|
pipetteVal += provider->pipetteVal[2];
|
||||||
|
++n;
|
||||||
|
}
|
||||||
|
if (n>1) {
|
||||||
|
pipetteVal /= n;
|
||||||
|
}
|
||||||
|
else if (!n)
|
||||||
|
pipetteVal = -1.f;
|
||||||
|
|
||||||
|
if (pipetteVal != -1.f) {
|
||||||
|
double pos[3];
|
||||||
|
shcSelector->getPositions(pos[0], pos[1], pos[2]);
|
||||||
|
if (pipetteVal>=pos[2]) {
|
||||||
|
editedAdjuster = highlights;
|
||||||
|
paramCurve->setActiveParam(4);
|
||||||
|
}
|
||||||
|
else if(pipetteVal>=pos[1]) {
|
||||||
|
editedAdjuster = lights;
|
||||||
|
paramCurve->setActiveParam(5);
|
||||||
|
}
|
||||||
|
else if(pipetteVal>=pos[0]) {
|
||||||
|
editedAdjuster = darks;
|
||||||
|
paramCurve->setActiveParam(6);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
editedAdjuster = shadows;
|
||||||
|
paramCurve->setActiveParam(7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
paramCurve->setActiveParam(-1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case (DCT_NURBS):
|
case (DCT_NURBS):
|
||||||
NURBSCurve->pipetteMouseOver(provider, modifierKey);
|
NURBSCurve->pipetteMouseOver(provider, modifierKey);
|
||||||
@@ -297,7 +345,8 @@ void DiagonalCurveEditorSubGroup::pipetteButton1Pressed(EditDataProvider *provid
|
|||||||
customCurve->pipetteButton1Pressed(provider, modifierKey);
|
customCurve->pipetteButton1Pressed(provider, modifierKey);
|
||||||
break;
|
break;
|
||||||
case (DCT_Parametric):
|
case (DCT_Parametric):
|
||||||
paramCurve->pipetteButton1Pressed(provider, modifierKey);
|
if (editedAdjuster)
|
||||||
|
editedAdjusterValue = editedAdjuster->getIntValue();
|
||||||
break;
|
break;
|
||||||
case (DCT_NURBS):
|
case (DCT_NURBS):
|
||||||
NURBSCurve->pipetteButton1Pressed(provider, modifierKey);
|
NURBSCurve->pipetteButton1Pressed(provider, modifierKey);
|
||||||
@@ -315,7 +364,7 @@ void DiagonalCurveEditorSubGroup::pipetteButton1Released(EditDataProvider *provi
|
|||||||
customCurve->pipetteButton1Released(provider);
|
customCurve->pipetteButton1Released(provider);
|
||||||
break;
|
break;
|
||||||
case (DCT_Parametric):
|
case (DCT_Parametric):
|
||||||
paramCurve->pipetteButton1Released(provider);
|
editedAdjuster = NULL;
|
||||||
break;
|
break;
|
||||||
case (DCT_NURBS):
|
case (DCT_NURBS):
|
||||||
NURBSCurve->pipetteButton1Released(provider);
|
NURBSCurve->pipetteButton1Released(provider);
|
||||||
@@ -333,7 +382,13 @@ void DiagonalCurveEditorSubGroup::pipetteDrag(EditDataProvider *provider, int mo
|
|||||||
customCurve->pipetteDrag(provider, modifierKey);
|
customCurve->pipetteDrag(provider, modifierKey);
|
||||||
break;
|
break;
|
||||||
case (DCT_Parametric):
|
case (DCT_Parametric):
|
||||||
paramCurve->pipetteDrag(provider, modifierKey);
|
if (editedAdjuster) {
|
||||||
|
int trimmedValue = editedAdjuster->trimValue(editedAdjusterValue-(provider->deltaScreen.y/2));
|
||||||
|
if (trimmedValue != editedAdjuster->getIntValue()) {
|
||||||
|
editedAdjuster->setValue(trimmedValue);
|
||||||
|
adjusterChanged(editedAdjuster, trimmedValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case (DCT_NURBS):
|
case (DCT_NURBS):
|
||||||
NURBSCurve->pipetteDrag(provider, modifierKey);
|
NURBSCurve->pipetteDrag(provider, modifierKey);
|
||||||
|
@@ -43,6 +43,9 @@ protected:
|
|||||||
Adjuster* darks;
|
Adjuster* darks;
|
||||||
Adjuster* shadows;
|
Adjuster* shadows;
|
||||||
|
|
||||||
|
Adjuster *editedAdjuster;
|
||||||
|
int editedAdjusterValue;
|
||||||
|
|
||||||
Gtk::Button* saveCustom;
|
Gtk::Button* saveCustom;
|
||||||
Gtk::Button* loadCustom;
|
Gtk::Button* loadCustom;
|
||||||
Gtk::Button* copyCustom;
|
Gtk::Button* copyCustom;
|
||||||
|
@@ -854,23 +854,27 @@ void MyDiagonalCurve::pipetteButton1Released(EditDataProvider *provider) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MyDiagonalCurve::pipetteDrag(EditDataProvider *provider, int modifierKey) {
|
void MyDiagonalCurve::pipetteDrag(EditDataProvider *provider, int modifierKey) {
|
||||||
|
if (curve.type==DCT_Parametric || graphW<0 || graphH<0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
snapToMinDistY = snapToMinDistX = 10.;
|
||||||
|
snapToValY = snapToValX = 0.;
|
||||||
|
snapToElmt = -100;
|
||||||
|
|
||||||
/* graphW and graphH are the size of the graph */
|
/* graphW and graphH are the size of the graph */
|
||||||
calcDimensions();
|
calcDimensions();
|
||||||
|
|
||||||
double minDistanceX = double(MIN_DISTANCE) / double(graphW-1);
|
//double minDistanceX = double(MIN_DISTANCE) / double(graphW-1);
|
||||||
double minDistanceY = double(MIN_DISTANCE) / double(graphH-1);
|
//double minDistanceY = double(MIN_DISTANCE) / double(graphH-1);
|
||||||
|
|
||||||
if ((graphW < 0) || (graphH < 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
getCursorPosition(Gdk::MOTION_NOTIFY, false, cursorX+graphX, graphY+provider->deltaScreen.y, Gdk::ModifierType(modifierKey));
|
getCursorPosition(Gdk::MOTION_NOTIFY, false, cursorX+graphX, graphY+provider->deltaScreen.y, Gdk::ModifierType(modifierKey));
|
||||||
|
|
||||||
// bounds of the grabbed point
|
// bounds of the grabbed point
|
||||||
double const bottomBound = 0.;
|
//double const bottomBound = 0.;
|
||||||
double const topBound = 1.;
|
//double const topBound = 1.;
|
||||||
|
|
||||||
double bottomDeletionBound = bottomBound - minDistanceY;
|
//double bottomDeletionBound = bottomBound - minDistanceY;
|
||||||
double topDeletionBound = topBound + minDistanceY;
|
//double topDeletionBound = topBound + minDistanceY;
|
||||||
|
|
||||||
// we memorize the previous position of the point, for optimization purpose
|
// we memorize the previous position of the point, for optimization purpose
|
||||||
double prevPosX = curve.x[grab_point];
|
double prevPosX = curve.x[grab_point];
|
||||||
@@ -912,7 +916,7 @@ void MyDiagonalCurve::pipetteDrag(EditDataProvider *provider, int modifierKey) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// nextPosY is in the bounds
|
// nextPosY is in the bounds
|
||||||
curve.y[grab_point] = CLAMP(ugpY, 0.0, 1.0);
|
curve.y[grab_point] = ugpY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curve.x[grab_point] != prevPosX || curve.y[grab_point] != prevPosY) {
|
if (curve.x[grab_point] != prevPosX || curve.y[grab_point] != prevPosY) {
|
||||||
|
@@ -1062,11 +1062,11 @@ void MyFlatCurve::pipetteDrag(EditDataProvider *provider, int modifierKey) {
|
|||||||
getMouseOverArea();
|
getMouseOverArea();
|
||||||
|
|
||||||
if (editedHandle == FCT_EditedHandle_CPointY) {
|
if (editedHandle == FCT_EditedHandle_CPointY) {
|
||||||
movePoint(false, true);
|
movePoint(false, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFlatCurve::movePoint(bool moveX, bool moveY) {
|
void MyFlatCurve::movePoint(bool moveX, bool moveY, bool pipetteDrag) {
|
||||||
|
|
||||||
// bounds of the grabbed point
|
// bounds of the grabbed point
|
||||||
double leftBound;
|
double leftBound;
|
||||||
@@ -1187,6 +1187,10 @@ void MyFlatCurve::movePoint(bool moveX, bool moveY) {
|
|||||||
// we memorize the previous position of the point, for optimization purpose
|
// we memorize the previous position of the point, for optimization purpose
|
||||||
ugpY += deltaY;
|
ugpY += deltaY;
|
||||||
|
|
||||||
|
// the points stay in the bounds (and can't be deleted) in pipette drag mode
|
||||||
|
if (pipetteDrag)
|
||||||
|
ugpY = CLAMP(ugpY, 0.0, 1.0);
|
||||||
|
|
||||||
// snapping point to specific values
|
// snapping point to specific values
|
||||||
if (snapTo && curve.x[lit_point] != -1) {
|
if (snapTo && curve.x[lit_point] != -1) {
|
||||||
|
|
||||||
|
@@ -102,7 +102,7 @@ class MyFlatCurve : public MyCurve {
|
|||||||
enum MouseOverAreas area;
|
enum MouseOverAreas area;
|
||||||
|
|
||||||
void draw ();
|
void draw ();
|
||||||
void movePoint(bool moveX, bool moveY);
|
void movePoint(bool moveX, bool moveY, bool pipetteDrag=false);
|
||||||
void defaultCurve (double iVal=0.5);
|
void defaultCurve (double iVal=0.5);
|
||||||
void interpolate ();
|
void interpolate ();
|
||||||
void getCursorPosition(Gdk::EventType evType, bool isHint, int evX, int evY, Gdk::ModifierType modifier);
|
void getCursorPosition(Gdk::EventType evType, bool isHint, int evX, int evY, Gdk::ModifierType modifier);
|
||||||
|
Reference in New Issue
Block a user