Flat curve editor widget, HSV tool modified to use it.
Usage : - click & drag a control point to move it in X&Y direction - click & drag a vertical line to move it in horizontal or vertical direction (the very first move will be used to determine the motion direction) - click & drag the yellow or blue square handle to modify the tangent of the same color
This commit is contained in:
@@ -25,6 +25,58 @@
|
||||
|
||||
extern Glib::ustring argv0;
|
||||
|
||||
DiagonalCurveEditor::DiagonalCurveEditor (Glib::ustring text, CurveEditorGroup* ceGroup, CurveEditorSubGroup* ceSubGroup) : CurveEditor::CurveEditor(text, (CurveEditorGroup*) ceGroup, ceSubGroup) {
|
||||
|
||||
// Order set in the same order than "enum DiagonalCurveType". Shouldn't change, for compatibility reason
|
||||
curveType->addEntry(argv0+"/images/curveType-linear.png", M("CURVEEDITOR_LINEAR")); // 0 Linear
|
||||
curveType->addEntry(argv0+"/images/curveType-spline.png", M("CURVEEDITOR_CUSTOM")); // 1 Spline
|
||||
curveType->addEntry(argv0+"/images/curveType-parametric.png", M("CURVEEDITOR_PARAMETRIC")); // 2 Parametric
|
||||
curveType->addEntry(argv0+"/images/curveType-NURBS.png", M("CURVEEDITOR_NURBS")); // 3 NURBS
|
||||
curveType->setSelected(DCT_Linear);
|
||||
curveType->show();
|
||||
}
|
||||
|
||||
std::vector<double> DiagonalCurveEditor::getCurve () {
|
||||
std::vector<double> curve;
|
||||
|
||||
switch (selected) {
|
||||
case (DCT_Spline):
|
||||
return curve = customCurveEd;
|
||||
case (DCT_Parametric):
|
||||
return curve = paramCurveEd;
|
||||
case (DCT_NURBS):
|
||||
return curve = NURBSCurveEd;
|
||||
default:
|
||||
// returning Linear or Unchanged
|
||||
curve.push_back((double)(selected));
|
||||
return curve;
|
||||
}
|
||||
}
|
||||
|
||||
FlatCurveEditor::FlatCurveEditor (Glib::ustring text, CurveEditorGroup* ceGroup, CurveEditorSubGroup* ceSubGroup) : CurveEditor::CurveEditor(text, (CurveEditorGroup*) ceGroup, ceSubGroup) {
|
||||
|
||||
// Order set in the same order than "enum FlatCurveType". Shouldn't change, for compatibility reason
|
||||
curveType->addEntry(argv0+"/images/curveType-flatLinear.png", M("CURVEEDITOR_LINEAR")); // 0 Linear
|
||||
curveType->addEntry(argv0+"/images/curveType-controlPoints.png", M("CURVEEDITOR_MINMAXCPOINTS")); // 1 Min/Max ControlPoints
|
||||
curveType->setSelected(FCT_Linear);
|
||||
curveType->show();
|
||||
}
|
||||
|
||||
std::vector<double> FlatCurveEditor::getCurve () {
|
||||
std::vector<double> curve;
|
||||
|
||||
switch (selected) {
|
||||
//case (Parametric):
|
||||
// return curve = paramCurveEd;
|
||||
case (FCT_MinMaxCPoints):
|
||||
return curve = controlPointsCurveEd;
|
||||
default:
|
||||
// returning Linear or Unchanged
|
||||
curve.push_back((double)(selected));
|
||||
return curve;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* CurveEditor (CurveEditorGroup* ceGroup, Glib::ustring text)
|
||||
*
|
||||
@@ -32,32 +84,25 @@ extern Glib::ustring argv0;
|
||||
* ceGroup = NULL or the address of the Widget that will receive the CurveTypeToggleButton
|
||||
* text = (optional) label of the curve, displayed in the CurveTypeToggleButton, next to the image
|
||||
*/
|
||||
CurveEditor::CurveEditor (Glib::ustring text, CurveEditorGroup* ceGroup) {
|
||||
CurveEditor::CurveEditor (Glib::ustring text, CurveEditorGroup* ceGroup, CurveEditorSubGroup* ceSubGroup) {
|
||||
|
||||
bgHistValid = false;
|
||||
selected = Linear;
|
||||
selected = DCT_Linear;
|
||||
|
||||
histogram = new unsigned int[256]; // histogram values
|
||||
|
||||
group = ceGroup;
|
||||
subGroup = ceSubGroup;
|
||||
|
||||
if (group && text.size())
|
||||
curveType = Gtk::manage (new PopUpToggleButton(text + ":"));
|
||||
else
|
||||
curveType = Gtk::manage (new PopUpToggleButton());
|
||||
|
||||
// Order set in the same order than "enum CurveType". Shouldn't change, for compatibility reason
|
||||
curveType->addEntry(argv0+"/images/curveType-linear.png", M("CURVEEDITOR_LINEAR")); // 0 Linear
|
||||
curveType->addEntry(argv0+"/images/curveType-spline.png", M("CURVEEDITOR_CUSTOM")); // 1 Spline
|
||||
curveType->addEntry(argv0+"/images/curveType-parametric.png", M("CURVEEDITOR_PARAMETRIC")); // 2 Parametric
|
||||
curveType->addEntry(argv0+"/images/curveType-NURBS.png", M("CURVEEDITOR_NURBS")); // 3 NURBS
|
||||
curveType->setSelected(Linear);
|
||||
curveType->set_tooltip_text(M("CURVEEDITOR_TYPE"));
|
||||
// TODO: Does this signal have to be blocked when on curve type change ?
|
||||
curveType->signal_toggled().connect ( sigc::mem_fun(*this, &CurveEditor::curveTypeToggled) );
|
||||
typeconn = curveType->signal_changed().connect (sigc::mem_fun(*this, &CurveEditor::typeSelectionChanged) );
|
||||
|
||||
curveType->show();
|
||||
}
|
||||
|
||||
CurveEditor::~CurveEditor () {
|
||||
@@ -65,29 +110,11 @@ CurveEditor::~CurveEditor () {
|
||||
delete [] histogram;
|
||||
}
|
||||
|
||||
|
||||
void CurveEditor::setCurve (const std::vector<double>& p) {
|
||||
tempCurve = p;
|
||||
group->setCurveExternal(this, p);
|
||||
}
|
||||
|
||||
std::vector<double> CurveEditor::getCurve () {
|
||||
std::vector<double> curve;
|
||||
|
||||
switch (selected) {
|
||||
case (Spline):
|
||||
return curve = customCurveEd;
|
||||
case (Parametric):
|
||||
return curve = paramCurveEd;
|
||||
case (NURBS):
|
||||
return curve = NURBSCurveEd;
|
||||
default:
|
||||
// returning Linear or Unchanged
|
||||
curve.push_back((double)(selected));
|
||||
return curve;
|
||||
}
|
||||
}
|
||||
|
||||
void CurveEditor::typeSelectionChanged (int n) {
|
||||
group->typeSelectionChanged(this, n);
|
||||
}
|
||||
@@ -97,7 +124,7 @@ void CurveEditor::curveTypeToggled() {
|
||||
}
|
||||
|
||||
bool CurveEditor::isUnChanged () {
|
||||
return curveType->getSelected()==Unchanged;
|
||||
return curveType->getSelected()==subGroup->getValUnchanged();
|
||||
}
|
||||
|
||||
void CurveEditor::setUnChanged (bool uc) {
|
||||
@@ -117,5 +144,5 @@ void CurveEditor::updateBackgroundHistogram (unsigned int* hist) {
|
||||
bgHistValid = false;
|
||||
|
||||
// Then call the curve editor group to eventually update the histogram
|
||||
group->updateBackgroundHistogram (this);
|
||||
subGroup->updateBackgroundHistogram (this);
|
||||
}
|
||||
|
Reference in New Issue
Block a user