From 83f70cf9fbb45a62829d5025da95a81cbabf59ca Mon Sep 17 00:00:00 2001 From: Pandagrapher Date: Sat, 30 Mar 2019 17:08:07 +0100 Subject: [PATCH 1/5] Replace Arcellipse widget by Ellipse widget This simplifies spot management because only one widget instead of four is now managed to draw an ellipse Bugfixes: - Mouse cursor is now correctly managed according to widget when mouse-overing - Ellipse radius are now saturated at minimum at 2 to avoid ellipse to disapear at small radius values --- rtgui/controlspotpanel.cc | 405 +++++++++++++++----------------------- rtgui/controlspotpanel.h | 2 +- rtgui/editwidgets.cc | 286 +++++++++++++++++++++++++++ rtgui/editwidgets.h | 29 +++ 4 files changed, 477 insertions(+), 245 deletions(-) diff --git a/rtgui/controlspotpanel.cc b/rtgui/controlspotpanel.cc index e4e71153f..072a8061b 100644 --- a/rtgui/controlspotpanel.cc +++ b/rtgui/controlspotpanel.cc @@ -50,10 +50,10 @@ ControlSpotPanel::ControlSpotPanel(): structexclu_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_STRUCCOL"), 0, 100, 1, 0))), struc_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_THRES"), 1.0, 12.0, 0.1, 4.0))), - locX_(Gtk::manage(new Adjuster(M("TP_LOCAL_WIDTH"), 0, 2250, 1, 250))), - locXL_(Gtk::manage(new Adjuster(M("TP_LOCAL_WIDTH_L"), 0, 2250, 1, 250))), - locY_(Gtk::manage(new Adjuster(M("TP_LOCAL_HEIGHT"), 0, 2250, 1, 250))), - locYT_(Gtk::manage(new Adjuster(M("TP_LOCAL_HEIGHT_T"), 0, 2250, 1, 250))), + locX_(Gtk::manage(new Adjuster(M("TP_LOCAL_WIDTH"), 2, 2250, 1, 250))), + locXL_(Gtk::manage(new Adjuster(M("TP_LOCAL_WIDTH_L"), 2, 2250, 1, 250))), + locY_(Gtk::manage(new Adjuster(M("TP_LOCAL_HEIGHT"), 2, 2250, 1, 250))), + locYT_(Gtk::manage(new Adjuster(M("TP_LOCAL_HEIGHT_T"), 2, 2250, 1, 250))), centerX_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CENTER_X"), -1000, 1000, 1, 0))), centerY_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CENTER_Y"), -1000, 1000, 1, 0))), circrad_(Gtk::manage(new Adjuster(M("TP_LOCALLAB_CIRCRADIUS"), 2, 150, 1, 18))), @@ -1046,40 +1046,22 @@ void ControlSpotPanel::addControlSpotCurve(Gtk::TreeModel::Row row) centerCircle = new Circle(); centerCircle->datum = Geometry::IMAGE; centerCircle->radiusInImageSpace = true; - Arcellipse* arc1; - arc1 = new Arcellipse(); - arc1->innerLineWidth = 0.7; - arc1->datum = Geometry::IMAGE; - arc1->radiusInImageSpace = true; - Arcellipse* arc2; - arc2 = new Arcellipse(); - arc2->innerLineWidth = 0.7; - arc2->datum = Geometry::IMAGE; - arc2->radiusInImageSpace = true; - Arcellipse* arc3; - arc3 = new Arcellipse(); - arc3->innerLineWidth = 0.7; - arc3->datum = Geometry::IMAGE; - arc3->radiusInImageSpace = true; - Arcellipse* arc4; - arc4 = new Arcellipse(); - arc4->innerLineWidth = 0.7; - arc4->datum = Geometry::IMAGE; - arc4->radiusInImageSpace = true; - Rectangle* rec; - rec = new Rectangle(); - rec->innerLineWidth = 0.7; - rec->datum = Geometry::IMAGE; - EditSubscriber::visibleGeometry.push_back(lineX); // (curveid - 1) * 10 - EditSubscriber::visibleGeometry.push_back(lineXL); // (curveid - 1) * 10 + 1 - EditSubscriber::visibleGeometry.push_back(lineY); // (curveid - 1) * 10 + 2 - EditSubscriber::visibleGeometry.push_back(lineYT); // (curveid - 1) * 10 + 3 - EditSubscriber::visibleGeometry.push_back(centerCircle); // (curveid - 1) * 10 + 4 - EditSubscriber::visibleGeometry.push_back(arc1); // (curveid - 1) * 10 + 5 - EditSubscriber::visibleGeometry.push_back(arc2); // (curveid - 1) * 10 + 6 - EditSubscriber::visibleGeometry.push_back(arc3); // (curveid - 1) * 10 + 7 - EditSubscriber::visibleGeometry.push_back(arc4); // (curveid - 1) * 10 + 8 - EditSubscriber::visibleGeometry.push_back(rec); // (curveid - 1) * 10 + 9 + Ellipse* shape_ellipse; + shape_ellipse = new Ellipse(); + shape_ellipse->innerLineWidth = 0.7; + shape_ellipse->datum = Geometry::IMAGE; + shape_ellipse->radiusInImageSpace = true; + Rectangle* shape_rectangle; + shape_rectangle = new Rectangle(); + shape_rectangle->innerLineWidth = 0.7; + shape_rectangle->datum = Geometry::IMAGE; + EditSubscriber::visibleGeometry.push_back(lineX); // (curveid - 1) * 7 + EditSubscriber::visibleGeometry.push_back(lineXL); // (curveid - 1) * 7 + 1 + EditSubscriber::visibleGeometry.push_back(lineY); // (curveid - 1) * 7 + 2 + EditSubscriber::visibleGeometry.push_back(lineYT); // (curveid - 1) * 7 + 3 + EditSubscriber::visibleGeometry.push_back(centerCircle); // (curveid - 1) * 7 + 4 + EditSubscriber::visibleGeometry.push_back(shape_ellipse); // (curveid - 1) * 7 + 5 + EditSubscriber::visibleGeometry.push_back(shape_rectangle); // (curveid - 1) * 7 + 6 // Creation of mouseOverGeometry lineX = new Line(); @@ -1097,62 +1079,32 @@ void ControlSpotPanel::addControlSpotCurve(Gtk::TreeModel::Row row) centerCircle = new Circle(); centerCircle->datum = Geometry::IMAGE; centerCircle->radiusInImageSpace = true; - arc1 = new Arcellipse(); - arc1->innerLineWidth = 0.7; - arc1->datum = Geometry::IMAGE; - arc1->radiusInImageSpace = true; - arc2 = new Arcellipse(); - arc2->innerLineWidth = 0.7; - arc2->datum = Geometry::IMAGE; - arc2->radiusInImageSpace = true; - arc3 = new Arcellipse(); - arc3->innerLineWidth = 0.7; - arc3->datum = Geometry::IMAGE; - arc3->radiusInImageSpace = true; - arc4 = new Arcellipse(); - arc4->innerLineWidth = 0.7; - arc4->datum = Geometry::IMAGE; - arc4->radiusInImageSpace = true; - rec = new Rectangle(); - rec->innerLineWidth = 0.7; - rec->datum = Geometry::IMAGE; - EditSubscriber::mouseOverGeometry.push_back(lineX); // (curveid - 1) * 10 - EditSubscriber::mouseOverGeometry.push_back(lineXL); // (curveid - 1) * 10 + 1 - EditSubscriber::mouseOverGeometry.push_back(lineY); // (curveid - 1) * 10 + 2 - EditSubscriber::mouseOverGeometry.push_back(lineYT); // (curveid - 1) * 10 + 3 - EditSubscriber::mouseOverGeometry.push_back(centerCircle); // (curveid - 1) * 10 + 4 - EditSubscriber::mouseOverGeometry.push_back(arc1); // (curveid - 1) * 10 + 5 - EditSubscriber::mouseOverGeometry.push_back(arc2); // (curveid - 1) * 10 + 6 - EditSubscriber::mouseOverGeometry.push_back(arc3); // (curveid - 1) * 10 + 7 - EditSubscriber::mouseOverGeometry.push_back(arc4); // (curveid - 1) * 10 + 8 - EditSubscriber::mouseOverGeometry.push_back(rec); // (curveid - 1) * 10 + 9 + shape_ellipse = new Ellipse(); + shape_ellipse->innerLineWidth = 0.7; + shape_ellipse->datum = Geometry::IMAGE; + shape_ellipse->radiusInImageSpace = true; + shape_rectangle = new Rectangle(); + shape_rectangle->innerLineWidth = 0.7; + shape_rectangle->datum = Geometry::IMAGE; + EditSubscriber::mouseOverGeometry.push_back(lineX); // (curveid - 1) * 7 + EditSubscriber::mouseOverGeometry.push_back(lineXL); // (curveid - 1) * 7 + 1 + EditSubscriber::mouseOverGeometry.push_back(lineY); // (curveid - 1) * 7 + 2 + EditSubscriber::mouseOverGeometry.push_back(lineYT); // (curveid - 1) * 7 + 3 + EditSubscriber::mouseOverGeometry.push_back(centerCircle); // (curveid - 1) * 7 + 4 + EditSubscriber::mouseOverGeometry.push_back(shape_ellipse); // (curveid - 1) * 7 + 5 + EditSubscriber::mouseOverGeometry.push_back(shape_rectangle); // (curveid - 1) * 7 + 6 - row[spots_.curveid] = EditSubscriber::visibleGeometry.size() / 10; + row[spots_.curveid] = EditSubscriber::visibleGeometry.size() / 7; } void ControlSpotPanel::updateControlSpotCurve(Gtk::TreeModel::Row row) { - const int curveid_ = static_cast(row[spots_.curveid]); - - if (curveid_ == 0) { // Row has no associated curve - return; - } - - const int centerX_ = static_cast(row[spots_.centerX]); - const int centerY_ = static_cast(row[spots_.centerY]); - const int circrad_ = static_cast(row[spots_.circrad]); - const int locX_ = static_cast(row[spots_.locX]); - const int locXL_ = static_cast(row[spots_.locXL]); - const int locY_ = static_cast(row[spots_.locY]); - const int locYT_ = static_cast(row[spots_.locYT]); - const int shape_ = static_cast(row[spots_.shape]); - const bool isvisible_ = static_cast(row[spots_.isvisible]); + const int curveid_ = row[spots_.curveid]; + EditDataProvider* const dataProvider = getEditProvider(); // printf("updateControlSpotCurve: %d\n", curveid_); - EditDataProvider* dataProvider = getEditProvider(); - - if (!dataProvider) { + if (curveid_ == 0 || !dataProvider) { // Row has no associated curve or there is no EditProvider return; } @@ -1160,15 +1112,25 @@ void ControlSpotPanel::updateControlSpotCurve(Gtk::TreeModel::Row row) int imH = 0; dataProvider->getImageSize(imW, imH); - if (!imW || !imH) { + if (!imW || !imH) { // No image loaded return; } - const double decayX = (locX_) * (double (imW)) / 2000.; - const double decayXL = (locXL_) * (double (imW)) / 2000.; - const double decayY = (locY_) * double (imH) / 2000.; - const double decayYT = (locYT_) * double (imH) / 2000.; - rtengine::Coord origin(imW / 2 + centerX_ * imW / 2000.f, imH / 2 + centerY_ * imH / 2000.f); + const int centerX_ = row[spots_.centerX]; + const int centerY_ = row[spots_.centerY]; + const int circrad_ = row[spots_.circrad]; + const int locX_ = row[spots_.locX]; + const int locXL_ = row[spots_.locXL]; + const int locY_ = row[spots_.locY]; + const int locYT_ = row[spots_.locYT]; + const int shape_ = row[spots_.shape]; + const bool isvisible_ = row[spots_.isvisible]; + + const int decayX = locX_ * (imW / 2000); + const int decayXL = locXL_ * (imW / 2000); + const int decayY = locY_ * (imH / 2000); + const int decayYT = locYT_ * (imH / 2000); + rtengine::Coord origin(imW / 2 + centerX_ * imW / 2000, imH / 2 + centerY_ * imH / 2000); const auto updateLineWithDecay = [&](Geometry * geometry, const float radius, const float decal, const float offSetAngle, const double decay) { const auto line = static_cast(geometry); // 180 @@ -1184,147 +1146,117 @@ void ControlSpotPanel::updateControlSpotCurve(Gtk::TreeModel::Row row) circle->radius = circrad_; }; - const auto updateArcellipse = [&](Geometry * geometry, const double dRad_, const double dRad2_, const double begang_, const double endang_) { - const auto arcellipse = static_cast(geometry); - arcellipse->center = origin; - arcellipse->begang = begang_; - arcellipse->endang = endang_; - arcellipse->radius = dRad_; - arcellipse->radius2 = dRad2_; + const auto updateEllipse = [&](Geometry * geometry) { + const auto ellipse = static_cast(geometry); + ellipse->center = origin; + ellipse->radX = decayX; + ellipse->radXL = decayXL; + ellipse->radY = decayY; + ellipse->radYT = decayYT; }; const auto updateRectangle = [&](Geometry * geometry) { const auto rectangle = static_cast(geometry); - rectangle->bottomRight.x = origin.x + (int) decayX; - rectangle->bottomRight.y = origin.y + (int) decayY; - rectangle->topLeft.x = origin.x - (int) decayXL; - rectangle->topLeft.y = origin.y - (int) decayYT; + rectangle->bottomRight.x = origin.x + decayX; + rectangle->bottomRight.y = origin.y + decayY; + rectangle->topLeft.x = origin.x - decayXL; + rectangle->topLeft.y = origin.y - decayYT; }; - updateLineWithDecay(visibleGeometry.at((curveid_ - 1) * 10), 500., 90., 0., decayX); - updateLineWithDecay(mouseOverGeometry.at((curveid_ - 1) * 10), 500., 90., 0., decayX); + updateLineWithDecay(visibleGeometry.at((curveid_ - 1) * 7), 500., 90., 0., decayX); + updateLineWithDecay(mouseOverGeometry.at((curveid_ - 1) * 7), 500., 90., 0., decayX); - updateLineWithDecay(visibleGeometry.at((curveid_ - 1) * 10 + 1), 500., 90., 180., decayXL); - updateLineWithDecay(mouseOverGeometry.at((curveid_ - 1) * 10 + 1), 500., 90., 180., decayXL); + updateLineWithDecay(visibleGeometry.at((curveid_ - 1) * 7 + 1), 500., 90., 180., decayXL); + updateLineWithDecay(mouseOverGeometry.at((curveid_ - 1) * 7 + 1), 500., 90., 180., decayXL); - updateLineWithDecay(visibleGeometry.at((curveid_ - 1) * 10 + 2), 500., 180., 90., decayY); - updateLineWithDecay(mouseOverGeometry.at((curveid_ - 1) * 10 + 2), 500., 180., 90., decayY); + updateLineWithDecay(visibleGeometry.at((curveid_ - 1) * 7 + 2), 500., 180., 90., decayY); + updateLineWithDecay(mouseOverGeometry.at((curveid_ - 1) * 7 + 2), 500., 180., 90., decayY); - updateLineWithDecay(visibleGeometry.at((curveid_ - 1) * 10 + 3), 500., 180., 270., decayYT); - updateLineWithDecay(mouseOverGeometry.at((curveid_ - 1) * 10 + 3), 500., 180., 270., decayYT); + updateLineWithDecay(visibleGeometry.at((curveid_ - 1) * 7 + 3), 500., 180., 270., decayYT); + updateLineWithDecay(mouseOverGeometry.at((curveid_ - 1) * 7 + 3), 500., 180., 270., decayYT); - updateCircle(visibleGeometry.at((curveid_ - 1) * 10 + 4)); - updateCircle(mouseOverGeometry.at((curveid_ - 1) * 10 + 4)); + updateCircle(visibleGeometry.at((curveid_ - 1) * 7 + 4)); + updateCircle(mouseOverGeometry.at((curveid_ - 1) * 7 + 4)); - updateArcellipse(visibleGeometry.at((curveid_ - 1) * 10 + 5), decayX, decayYT, 3 * RT_PI_2, 2 * RT_PI); - updateArcellipse(visibleGeometry.at((curveid_ - 1) * 10 + 6), decayXL, decayYT, RT_PI, 3 * RT_PI_2); - updateArcellipse(visibleGeometry.at((curveid_ - 1) * 10 + 7), decayXL, decayY, RT_PI_2, RT_PI); - updateArcellipse(visibleGeometry.at((curveid_ - 1) * 10 + 8), decayX, decayY, 0., RT_PI_2); - updateArcellipse(mouseOverGeometry.at((curveid_ - 1) * 10 + 5), decayX, decayYT, 3 * RT_PI_2, 2 * RT_PI); - updateArcellipse(mouseOverGeometry.at((curveid_ - 1) * 10 + 6), decayXL, decayYT, RT_PI, 3 * RT_PI_2); - updateArcellipse(mouseOverGeometry.at((curveid_ - 1) * 10 + 7), decayXL, decayY, RT_PI_2, RT_PI); - updateArcellipse(mouseOverGeometry.at((curveid_ - 1) * 10 + 8), decayX, decayY, 0., RT_PI_2); + updateEllipse(visibleGeometry.at((curveid_ - 1) * 7 + 5)); + updateEllipse(mouseOverGeometry.at((curveid_ - 1) * 7 + 5)); - updateRectangle(visibleGeometry.at((curveid_ - 1) * 10 + 9)); - updateRectangle(mouseOverGeometry.at((curveid_ - 1) * 10 + 9)); + updateRectangle(visibleGeometry.at((curveid_ - 1) * 7 + 6)); + updateRectangle(mouseOverGeometry.at((curveid_ - 1) * 7 + 6)); // Update Arcellipse/Rectangle visibility according to shape and visibility if (isvisible_) { - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10)->setActive(true); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 1)->setActive(true); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 2)->setActive(true); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 3)->setActive(true); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 4)->setActive(true); + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7)->setActive(true); + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 1)->setActive(true); + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 2)->setActive(true); + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 3)->setActive(true); + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 4)->setActive(true); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10)->setActive(true); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 1)->setActive(true); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 2)->setActive(true); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 3)->setActive(true); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 4)->setActive(true); + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7)->setActive(true); + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 1)->setActive(true); + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 2)->setActive(true); + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 3)->setActive(true); + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 4)->setActive(true); if (shape_ == 0) { // 0 = Ellipse - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 5)->setActive(true); // arc1 - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 6)->setActive(true); // arc2 - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 7)->setActive(true); // arc3 - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 8)->setActive(true); // arc4 - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 9)->setActive(false); // rec + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 5)->setActive(true); // shape_ellipse + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 6)->setActive(false); // shape_rectangle - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 5)->setActive(true); // arc1 - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 6)->setActive(true); // arc2 - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 7)->setActive(true); // arc3 - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 8)->setActive(true); // arc4 - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 9)->setActive(false); // rec + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 5)->setActive(true); // shape_ellipse + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 6)->setActive(false); // shape_rectangle } else { // 1 = Rectangle - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 5)->setActive(false); // arc1 - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 6)->setActive(false); // arc2 - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 7)->setActive(false); // arc3 - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 8)->setActive(false); // arc4 - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 9)->setActive(true); // rec + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 5)->setActive(false); // shape_ellipse + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 6)->setActive(true); // shape_rectangle - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 5)->setActive(false); // arc1 - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 6)->setActive(false); // arc2 - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 7)->setActive(false); // arc3 - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 8)->setActive(false); // arc4 - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 9)->setActive(true); // rec + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 5)->setActive(false); // shape_ellipse + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 6)->setActive(true); // shape_rectangle } } else { - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 1)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 2)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 3)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 4)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 5)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 6)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 7)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 8)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 10 + 9)->setActive(false); + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7)->setActive(false); + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 1)->setActive(false); + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 2)->setActive(false); + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 3)->setActive(false); + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 4)->setActive(false); + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 5)->setActive(false); + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 6)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 1)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 2)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 3)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 4)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 5)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 6)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 7)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 8)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 10 + 9)->setActive(false); + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7)->setActive(false); + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 1)->setActive(false); + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 2)->setActive(false); + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 3)->setActive(false); + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 4)->setActive(false); + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 5)->setActive(false); + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 6)->setActive(false); } } void ControlSpotPanel::deleteControlSpotCurve(Gtk::TreeModel::Row row) { - const int curveid_ = static_cast(row[spots_.curveid]); + const int curveid_ = row[spots_.curveid]; + + // printf("deleteControlSpotCurve: %d\n", curveid_); if (curveid_ == 0) { // Row has no associated curve return; } - // printf("deleteControlSpotCurve: %d\n", curveid_); - // visibleGeometry - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 9); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 8); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 7); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 6); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 5); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 4); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 3); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 2); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10 + 1); - EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 10); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 7 + 6); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 7 + 5); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 7 + 4); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 7 + 3); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 7 + 2); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 7 + 1); + EditSubscriber::visibleGeometry.erase(EditSubscriber::visibleGeometry.begin() + (curveid_ - 1) * 7); // mouseOverGeometry - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 9); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 8); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 7); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 6); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 5); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 4); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 3); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 2); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10 + 1); - EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 10); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 7 + 6); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 7 + 5); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 7 + 4); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 7 + 3); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 7 + 2); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 7 + 1); + EditSubscriber::mouseOverGeometry.erase(EditSubscriber::mouseOverGeometry.begin() + (curveid_ - 1) * 7); row[spots_.curveid] = 0; // Reset associated curve id @@ -1340,7 +1272,7 @@ void ControlSpotPanel::deleteControlSpotCurve(Gtk::TreeModel::Row row) } } -CursorShape ControlSpotPanel::getCursor(int objectID) +CursorShape ControlSpotPanel::getCursor(int objectID) const { // printf("Object ID: %d\n", objectID); @@ -1350,37 +1282,28 @@ CursorShape ControlSpotPanel::getCursor(int objectID) return CSHandOpen; } - int rem_ = objectID % 10; + int rem_ = objectID % 7; switch (rem_) { - case (0): // LocX: (curveid_ - 1) * 10 + case (0): // LocX: (curveid_ - 1) * 7 return CSMove1DH; - case (1): // LocXL: (curveid_ - 1) * 10 + 1 + case (1): // LocXL: (curveid_ - 1) * 7 + 1 return CSMove1DH; - case (2): // LocY: (curveid_ - 1) * 10 + 2 + case (2): // LocY: (curveid_ - 1) * 7 + 2 return CSMove1DV; - case (3): // LocYT: (curveid_ - 1) * 10 + 3 + case (3): // LocYT: (curveid_ - 1) * 7 + 3 return CSMove1DV; - case (4): // centerCircle: (curveid_ - 1) * 10 + 4 + case (4): // centerCircle: (curveid_ - 1) * 7 + 4 return CSMove2D; - case (5): // arc1: (curveid_ - 1) * 10 + 5 + case (5): // shape_ellipse: (curveid_ - 1) * 7 + 5 return CSMove2D; - case (6): // arc2: (curveid_ - 1) * 10 + 6 - return CSMove2D; - - case (7): // arc3: (curveid_ - 1) * 10 + 7 - return CSMove2D; - - case (8): // arc4: (curveid_ - 1) * 10 + 8 - return CSMove2D; - - case (9): // rec: (curveid_ - 1) * 10 + 9 + case (6): // shape_rectangle: (curveid_ - 1) * 7 + 6 return CSMove2D; default: @@ -1424,8 +1347,8 @@ bool ControlSpotPanel::mouseOver(int modifierKey) return false; } - int curveId_ = object_ / 10 + 1; - int rem = object_ % 10; + int curveId_ = object_ / 7 + 1; + int rem = object_ % 7; // Manage mouseOver preview for TreeView Gtk::TreeModel::Children children = treemodel_->children(); @@ -1440,7 +1363,7 @@ bool ControlSpotPanel::mouseOver(int modifierKey) } for (int it_ = 0; it_ < (int) EditSubscriber::visibleGeometry.size(); it_++) { - if ((it_ < ((curveId_ - 1) * 10)) || (it_ > ((curveId_ - 1) * 10) + 9)) { // it_ does not belong to cursor pointed curve + if ((it_ < ((curveId_ - 1) * 7)) || (it_ > ((curveId_ - 1) * 7) + 6)) { // it_ does not belong to cursor pointed curve EditSubscriber::visibleGeometry.at(it_)->state = Geometry::NORMAL; } } @@ -1449,67 +1372,61 @@ bool ControlSpotPanel::mouseOver(int modifierKey) // LocX if (rem == 0) { - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7)->state = Geometry::PRELIGHT; if (method == 1 || method == 3) { // Symmetrical cases - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 1)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 1)->state = Geometry::PRELIGHT; } } else { - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10)->state = Geometry::NORMAL; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7)->state = Geometry::NORMAL; } // LocXL if (rem == 1) { - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 1)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 1)->state = Geometry::PRELIGHT; if (method == 1 || method == 3) { // Symmetrical cases - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7)->state = Geometry::PRELIGHT; } } else { if (method == 0 || method == 2) { // Independent cases - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 1)->state = Geometry::NORMAL; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 1)->state = Geometry::NORMAL; } } // LocY if (rem == 2) { - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 2)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 2)->state = Geometry::PRELIGHT; if (method == 1 || method == 3) { // Symmetrical cases - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 3)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 3)->state = Geometry::PRELIGHT; } } else { - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 2)->state = Geometry::NORMAL; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 2)->state = Geometry::NORMAL; } // LocYT if (rem == 3) { - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 3)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 3)->state = Geometry::PRELIGHT; if (method == 1 || method == 3) { // Symmetrical cases - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 2)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 2)->state = Geometry::PRELIGHT; } } else { if (method == 0 || method == 2) { // Independent cases - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 3)->state = Geometry::NORMAL; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 3)->state = Geometry::NORMAL; } } // Circle, Arcellipses and Rectangle if (rem >= 4) { - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 4)->state = Geometry::PRELIGHT; - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 5)->state = Geometry::PRELIGHT; - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 6)->state = Geometry::PRELIGHT; - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 7)->state = Geometry::PRELIGHT; - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 8)->state = Geometry::PRELIGHT; - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 9)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 4)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 5)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 6)->state = Geometry::PRELIGHT; } else { - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 4)->state = Geometry::NORMAL; - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 5)->state = Geometry::NORMAL; - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 6)->state = Geometry::NORMAL; - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 7)->state = Geometry::NORMAL; - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 8)->state = Geometry::NORMAL; - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 10 + 9)->state = Geometry::NORMAL; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 4)->state = Geometry::NORMAL; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 5)->state = Geometry::NORMAL; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 6)->state = Geometry::NORMAL; } lastObject_ = object_; @@ -1531,7 +1448,7 @@ bool ControlSpotPanel::button1Pressed(int modifierKey) } // Select associated control spot - int curveId_ = lastObject_ / 10 + 1; + int curveId_ = lastObject_ / 7 + 1; Gtk::TreeModel::Children children = treemodel_->children(); for (auto iter = children.begin(); iter != children.end(); iter++) { @@ -1571,7 +1488,7 @@ bool ControlSpotPanel::drag1(int modifierKey) int imW, imH; provider->getImageSize(imW, imH); - int rem = lastObject_ % 10; + int rem = lastObject_ % 7; int method = shapeMethod_->get_active_row_number(); Coord* newCoord = new Coord(provider->posImage.x + provider->deltaImage.x, provider->posImage.y + provider->deltaImage.y); @@ -1655,7 +1572,7 @@ bool ControlSpotPanel::drag1(int modifierKey) } } - // Circle, Arcellipses and Rectangle + // Circle, Ellipses and Rectangle if (rem >= 4) { double deltaX = (double (newCoord->x) - double (lastCoord_->x)) * 2000. / double (imW); double deltaY = (double (newCoord->y) - double (lastCoord_->y)) * 2000. / double (imH); diff --git a/rtgui/controlspotpanel.h b/rtgui/controlspotpanel.h index 0c9e72d25..47f7a3bc5 100644 --- a/rtgui/controlspotpanel.h +++ b/rtgui/controlspotpanel.h @@ -248,7 +248,7 @@ private: void addControlSpotCurve(Gtk::TreeModel::Row row); void updateControlSpotCurve(Gtk::TreeModel::Row row); void deleteControlSpotCurve(Gtk::TreeModel::Row row); - CursorShape getCursor(int objectID); + CursorShape getCursor(int objectID) const; bool mouseOver(int modifierKey); bool button1Pressed(int modifierKey); bool button1Released(); diff --git a/rtgui/editwidgets.cc b/rtgui/editwidgets.cc index 1bbcc643e..740c2de68 100644 --- a/rtgui/editwidgets.cc +++ b/rtgui/editwidgets.cc @@ -644,6 +644,292 @@ void Rectangle::drawToMOChannel(Cairo::RefPtr &cr, unsigned shor } } +void Ellipse::drawOuterGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +{ + if ((flags & F_VISIBLE) && state != INSENSITIVE) { + RGBColor color; + + if (flags & F_AUTO_COLOR) { + color = getOuterLineColor(); + } else { + color = outerLineColor; + } + + cr->set_source_rgb (color.getR(), color.getG(), color.getB()); + cr->set_line_width ( getOuterLineWidth() ); + + rtengine::Coord center_ = center; + double radYT_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radYT)) : double (radYT); + double radY_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radY)) : double (radY); + double radXL_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radXL)) : double (radXL); + double radX_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radX)) : double (radX); + + if (datum == IMAGE) { + coordSystem.imageCoordToScreen (center.x, center.y, center_.x, center_.y); + } else if (datum == CLICKED_POINT) { + center_ += objectBuffer->getDataProvider()->posScreen; + } else if (datum == CURSOR) { + center_ += objectBuffer->getDataProvider()->posScreen + objectBuffer->getDataProvider()->deltaScreen; + } + + if (radYT_ > 0 && radY_ > 0 && radXL_ > 0 && radX_ > 0) { + // To have an ellipse with radius of (radX, radX), a circle of radius 1. shall be twisted with a scale + // of radX for x-axis, radY for y-axis + // Center of coordinates (x, y) in previous coordinates system becomes (X, Y) = (radX * x, radY * y) in new one + // To go back to previous location, center shall be translated to tx = -X * (1 - 1 / radX) in x-axis (x = tx + X) + // and ty = -Y * (1 - 1 / radY) in y-axis (y = ty + Y) + cr->save(); + + // Drawing bottom-right part + cr->scale (radX_, radY_); + cr->translate(- center_.x * (1 - 1 / radX_), - center_.y * (1 - 1 / radY_)); + cr->arc (center_.x, center_.y, 1.0, 0.0, rtengine::RT_PI_2); + + cr->restore (); + cr->save(); + + // Drawing bottom-left part + cr->scale (radXL_, radY_); + cr->translate(- center_.x * (1 - 1 / radXL_), - center_.y * (1 - 1 / radY_)); + cr->arc (center_.x, center_.y, 1.0, rtengine::RT_PI_2, rtengine::RT_PI); + cr->scale (radXL_, radY_); + + cr->restore (); + cr->save(); + + // Drawing top-left part + cr->scale (radXL_, radYT_); + cr->translate(- center_.x * (1 - 1 / radXL_), - center_.y * (1 - 1 / radYT_)); + cr->arc (center_.x, center_.y, 1.0, rtengine::RT_PI, 3. * rtengine::RT_PI_2); + + cr->restore (); + cr->save(); + + // Drawing top-right part + cr->scale (radX_, radYT_); + cr->translate(- center_.x * (1 - 1 / radX_), - center_.y * (1 - 1 / radYT_)); + cr->arc (center_.x, center_.y, 1.0, 3. * rtengine::RT_PI_2, 2. * rtengine::RT_PI); + + cr->restore (); + cr->stroke (); + } + } +} + +void Ellipse::drawInnerGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +{ + if (flags & F_VISIBLE) { + if (state != INSENSITIVE) { + RGBColor color; + + if (flags & F_AUTO_COLOR) { + color = getInnerLineColor(); + } else { + color = innerLineColor; + } + + cr->set_source_rgb (color.getR(), color.getG(), color.getB()); + } + + cr->set_line_width ( innerLineWidth ); + + rtengine::Coord center_ = center; + double radYT_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radYT)) : double (radYT); + double radY_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radY)) : double (radY); + double radXL_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radXL)) : double (radXL); + double radX_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radX)) : double (radX); + + if (datum == IMAGE) { + coordSystem.imageCoordToScreen (center.x, center.y, center_.x, center_.y); + } else if (datum == CLICKED_POINT) { + center_ += objectBuffer->getDataProvider()->posScreen; + } else if (datum == CURSOR) { + center_ += objectBuffer->getDataProvider()->posScreen + objectBuffer->getDataProvider()->deltaScreen; + } + + if (filled && state != INSENSITIVE) { + if (radYT_ > 0 && radY_ > 0 && radXL_ > 0 && radX_ > 0) { + // To have an ellipse with radius of (radX, radX), a circle of radius 1. shall be twisted with a scale + // of radX for x-axis, radY for y-axis + // Center of coordinates (x, y) in previous coordinates system becomes (X, Y) = (radX * x, radY * y) in new one + // To go back to previous location, center shall be translated to tx = -X * (1 - 1 / radX) in x-axis (x = tx + X) + // and ty = -Y * (1 - 1 / radY) in y-axis (y = ty + Y) + cr->save(); + + // Drawing bottom-right part + cr->scale (radX_, radY_); + cr->translate(- center_.x * (1 - 1 / radX_), - center_.y * (1 - 1 / radY_)); + cr->arc (center_.x, center_.y, 1.0, 0.0, rtengine::RT_PI_2); + + cr->restore (); + cr->save(); + + // Drawing bottom-left part + cr->scale (radXL_, radY_); + cr->translate(- center_.x * (1 - 1 / radXL_), - center_.y * (1 - 1 / radY_)); + cr->arc (center_.x, center_.y, 1.0, rtengine::RT_PI_2, rtengine::RT_PI); + cr->scale (radXL_, radY_); + + cr->restore (); + cr->save(); + + // Drawing top-left part + cr->scale (radXL_, radYT_); + cr->translate(- center_.x * (1 - 1 / radXL_), - center_.y * (1 - 1 / radYT_)); + cr->arc (center_.x, center_.y, 1.0, rtengine::RT_PI, 3. * rtengine::RT_PI_2); + + cr->restore (); + cr->save(); + + // Drawing top-right part + cr->scale (radX_, radYT_); + cr->translate(- center_.x * (1 - 1 / radX_), - center_.y * (1 - 1 / radYT_)); + cr->arc (center_.x, center_.y, 1.0, 3. * rtengine::RT_PI_2, 2. * rtengine::RT_PI); + + cr->restore (); + cr->stroke (); + } + + if (innerLineWidth > 0.) { + cr->fill_preserve(); + cr->stroke(); + } else { + cr->fill(); + } + } else if (innerLineWidth > 0.) { + if (radYT_ > 0 && radY_ > 0 && radXL_ > 0 && radX_ > 0) { + // To have an ellipse with radius of (radX, radX), a circle of radius 1. shall be twisted with a scale + // of radX for x-axis, radY for y-axis + // Center of coordinates (x, y) in previous coordinates system becomes (X, Y) = (radX * x, radY * y) in new one + // To go back to previous location, center shall be translated to tx = -X * (1 - 1 / radX) in x-axis (x = tx + X) + // and ty = -Y * (1 - 1 / radY) in y-axis (y = ty + Y) + cr->save(); + + // Drawing bottom-right part + cr->scale (radX_, radY_); + cr->translate(- center_.x * (1 - 1 / radX_), - center_.y * (1 - 1 / radY_)); + cr->arc (center_.x, center_.y, 1.0, 0.0, rtengine::RT_PI_2); + + cr->restore (); + cr->save(); + + // Drawing bottom-left part + cr->scale (radXL_, radY_); + cr->translate(- center_.x * (1 - 1 / radXL_), - center_.y * (1 - 1 / radY_)); + cr->arc (center_.x, center_.y, 1.0, rtengine::RT_PI_2, rtengine::RT_PI); + cr->scale (radXL_, radY_); + + cr->restore (); + cr->save(); + + // Drawing top-left part + cr->scale (radXL_, radYT_); + cr->translate(- center_.x * (1 - 1 / radXL_), - center_.y * (1 - 1 / radYT_)); + cr->arc (center_.x, center_.y, 1.0, rtengine::RT_PI, 3. * rtengine::RT_PI_2); + + cr->restore (); + cr->save(); + + // Drawing top-right part + cr->scale (radX_, radYT_); + cr->translate(- center_.x * (1 - 1 / radX_), - center_.y * (1 - 1 / radYT_)); + cr->arc (center_.x, center_.y, 1.0, 3. * rtengine::RT_PI_2, 2. * rtengine::RT_PI); + + cr->restore (); + cr->stroke (); + } + + if (state == INSENSITIVE) { + std::valarray ds (1); + ds[0] = 4; + cr->set_source_rgba (1.0, 1.0, 1.0, 0.618); + cr->stroke_preserve(); + cr->set_source_rgba (0.0, 0.0, 0.0, 0.618); + cr->set_dash (ds, 0); + cr->stroke(); + ds.resize (0); + cr->set_dash (ds, 0); + } else { + cr->stroke(); + } + } + } +} + +void Ellipse::drawToMOChannel (Cairo::RefPtr &cr, unsigned short id, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) +{ + if (flags & F_HOVERABLE) { + cr->set_line_width ( getMouseOverLineWidth() ); + + rtengine::Coord center_ = center; + double radYT_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radYT)) : double (radYT); + double radY_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radY)) : double (radY); + double radXL_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radXL)) : double (radXL); + double radX_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radX)) : double (radX); + + if (datum == IMAGE) { + coordSystem.imageCoordToCropCanvas (center.x, center.y, center_.x, center_.y); + } else if (datum == CLICKED_POINT) { + center_ += objectBuffer->getDataProvider()->posScreen; + } else if (datum == CURSOR) { + center_ += objectBuffer->getDataProvider()->posScreen + objectBuffer->getDataProvider()->deltaScreen; + } + + if (radYT_ > 0 && radY_ > 0 && radXL_ > 0 && radX_ > 0) { + // To have an ellipse with radius of (radX, radX), a circle of radius 1. shall be twisted with a scale + // of radX for x-axis, radY for y-axis + // Center of coordinates (x, y) in previous coordinates system becomes (X, Y) = (radX * x, radY * y) in new one + // To go back to previous location, center shall be translated to tx = -X * (1 - 1 / radX) in x-axis (x = tx + X) + // and ty = -Y * (1 - 1 / radY) in y-axis (y = ty + Y) + cr->save(); + + // Drawing bottom-right part + cr->scale (radX_, radY_); + cr->translate(- center_.x * (1 - 1 / radX_), - center_.y * (1 - 1 / radY_)); + cr->arc (center_.x, center_.y, 1.0, 0.0, rtengine::RT_PI_2); + + cr->restore (); + cr->save(); + + // Drawing bottom-left part + cr->scale (radXL_, radY_); + cr->translate(- center_.x * (1 - 1 / radXL_), - center_.y * (1 - 1 / radY_)); + cr->arc (center_.x, center_.y, 1.0, rtengine::RT_PI_2, rtengine::RT_PI); + cr->scale (radXL_, radY_); + + cr->restore (); + cr->save(); + + // Drawing top-left part + cr->scale (radXL_, radYT_); + cr->translate(- center_.x * (1 - 1 / radXL_), - center_.y * (1 - 1 / radYT_)); + cr->arc (center_.x, center_.y, 1.0, rtengine::RT_PI, 3. * rtengine::RT_PI_2); + + cr->restore (); + cr->save(); + + // Drawing top-right part + cr->scale (radX_, radYT_); + cr->translate(- center_.x * (1 - 1 / radX_), - center_.y * (1 - 1 / radYT_)); + cr->arc (center_.x, center_.y, 1.0, 3. * rtengine::RT_PI_2, 2. * rtengine::RT_PI); + + cr->restore (); + cr->stroke (); + } + + if (filled) { + if (innerLineWidth > 0.) { + cr->fill_preserve(); + cr->stroke(); + } else { + cr->fill(); + } + } else { + cr->stroke(); + } + } +} + void Arcellipse::drawOuterGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) { if ((flags & F_VISIBLE) && state != INSENSITIVE) { diff --git a/rtgui/editwidgets.h b/rtgui/editwidgets.h index e6553177f..981fe9b4b 100644 --- a/rtgui/editwidgets.h +++ b/rtgui/editwidgets.h @@ -322,6 +322,25 @@ public: void drawToMOChannel (Cairo::RefPtr &cr, unsigned short id, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) override; }; +class Ellipse : public Geometry +{ +public: + rtengine::Coord center; + int radYT; // Ellipse half-radius for top y-axis + int radY; // Ellipse half-radius for bottom y-axis + int radXL; // Ellipse half-radius for left x-axis + int radX; // Ellipse half-radius for right x-axis + bool filled; + bool radiusInImageSpace; /// If true, the radius depend on the image scale; if false, it is a fixed 'screen' size + + Ellipse (); + Ellipse (rtengine::Coord& center, int radYT, int radY, int radXL, int radX, bool filled = false, bool radiusInImageSpace = false); + + void drawOuterGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) override; + void drawInnerGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) override; + void drawToMOChannel (Cairo::RefPtr &cr, unsigned short id, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) override; +}; + class Arcellipse : public Geometry { public: @@ -545,6 +564,10 @@ inline Line::Line () : begin (10, 10), end (100, 100) { } +inline Ellipse::Ellipse () : + center (100, 100), radYT (5), radY (5), radXL (10), radX (10), filled (false), radiusInImageSpace (false) { +} + inline Arcellipse::Arcellipse () : center (100, 100), radius (10), radius2 (10), translax (0), translay (0), filled (false), radiusInImageSpace ( false) { @@ -570,6 +593,12 @@ inline Line::Line (int beginX, int beginY, int endX, int endY) : begin (beginX, beginY), end (endX, endY) { } +inline Ellipse::Ellipse (rtengine::Coord& center, int radYT, int radY, int radXL, int radX, + bool filled, bool radiusInImageSpace) : + center (center), radYT (radYT), radY (radY), radXL (radXL), radX (radX), filled (filled), + radiusInImageSpace (radiusInImageSpace) { +} + inline Arcellipse::Arcellipse (rtengine::Coord& center, double radius, double radius2, double translax, double translay, double scalx, double scaly, double begang, double endang, bool filled, bool radiusInImageSpace) : center (center), radius (radius), radius2 (radius2), translax (translax), translay (translay), scalx (scalx), scaly (scaly), begang (begang), endang (endang), filled (filled), radiusInImageSpace ( From fe92d596c927ee5806af8fbde0ac32ebf0ef303a Mon Sep 17 00:00:00 2001 From: Pandagrapher Date: Sat, 30 Mar 2019 17:35:23 +0100 Subject: [PATCH 2/5] Removes now useless Arcellipse widget --- rtgui/editwidgets.cc | 189 ------------------------------------------- rtgui/editwidgets.h | 45 ----------- 2 files changed, 234 deletions(-) diff --git a/rtgui/editwidgets.cc b/rtgui/editwidgets.cc index 740c2de68..6c1ef892b 100644 --- a/rtgui/editwidgets.cc +++ b/rtgui/editwidgets.cc @@ -930,195 +930,6 @@ void Ellipse::drawToMOChannel (Cairo::RefPtr &cr, unsigned short } } -void Arcellipse::drawOuterGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) -{ - if ((flags & F_VISIBLE) && state != INSENSITIVE) { - RGBColor color; - - if (flags & F_AUTO_COLOR) { - color = getOuterLineColor(); - } else { - color = outerLineColor; - } - - cr->set_source_rgb (color.getR(), color.getG(), color.getB()); - cr->set_line_width ( getOuterLineWidth() ); - - rtengine::Coord center_ = center; - double radius_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radius)) : double (radius); - double radius2_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radius2)) : double (radius2); - double begang_ = begang; - double endang_ = endang; - - if (datum == IMAGE) { - coordSystem.imageCoordToScreen (center.x, center.y, center_.x, center_.y); - } else if (datum == CLICKED_POINT) { - center_ += objectBuffer->getDataProvider()->posScreen; - } else if (datum == CURSOR) { - center_ += objectBuffer->getDataProvider()->posScreen + objectBuffer->getDataProvider()->deltaScreen; - } - - if (radius_ > 0 && radius2_ > 0.) { - cr->save(); - - // To have an ellipse with radius of (rad1, rad2), a circle of radius rad1 shall be twisted with a scale - // of rad2 / rad1 for y axis - // Center of coordinates (x, y) in previous coordinates system becomes (X, Y) = (x, rad2 / rad1 * y) in new one - // To go back to previous location, center shall be translated to t = -Y * (1 - rad1 / rad2) in y axis - // (Y = rad2 / rad1 * y and y = t + Y) - double scale_ = radius2_ / radius_; - cr->scale (1., scale_); - cr->translate (0., - center_.y * (1 - 1 / scale_)); - - cr->arc (center_.x + 0.5, center_.y + 0.5, radius_, begang_, endang_); - - cr->restore(); - cr->stroke(); - } - } -} - -void Arcellipse::drawInnerGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) -{ - if (flags & F_VISIBLE) { - if (state != INSENSITIVE) { - RGBColor color; - - if (flags & F_AUTO_COLOR) { - color = getInnerLineColor(); - } else { - color = innerLineColor; - } - - cr->set_source_rgb (color.getR(), color.getG(), color.getB()); - } - - cr->set_line_width ( innerLineWidth ); - - rtengine::Coord center_ = center; - double radius_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radius)) : double (radius); - double radius2_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radius2)) : double (radius2); - double begang_ = begang; - double endang_ = endang; - - if (datum == IMAGE) { - coordSystem.imageCoordToScreen (center.x, center.y, center_.x, center_.y); - } else if (datum == CLICKED_POINT) { - center_ += objectBuffer->getDataProvider()->posScreen; - } else if (datum == CURSOR) { - center_ += objectBuffer->getDataProvider()->posScreen + objectBuffer->getDataProvider()->deltaScreen; - } - - if (filled && state != INSENSITIVE) { - if (radius_ > 0 && radius2_ > 0.) { - cr->save(); - - // To have an ellipse with radius of (rad1, rad2), a circle of radius rad1 shall be twisted with a scale - // of rad2 / rad1 for y axis - // Center of coordinates (x, y) in previous coordinates system becomes (X, Y) = (x, rad2 / rad1 * y) in new one - // To go back to previous location, center shall be translated to t = -Y * (1 - rad1 / rad2) in y axis - // (Y = rad2 / rad1 * y and y = t + Y) - double scale_ = radius2_ / radius_; - cr->scale (1., scale_); - cr->translate (0., - center_.y * (1 - 1 / scale_)); - - cr->arc (center_.x + 0.5, center_.y + 0.5, radius_, begang_, endang_); - - cr->restore(); - cr->stroke(); - } - - if (innerLineWidth > 0.) { - cr->fill_preserve(); - cr->stroke(); - } else { - cr->fill(); - } - } else if (innerLineWidth > 0.) { - if (radius_ > 0 && radius2_ > 0.) { - cr->save(); - - // To have an ellipse with radius of (rad1, rad2), a circle of radius rad1 shall be twisted with a scale - // of rad2 / rad1 for y axis - // Center of coordinates (x, y) in previous coordinates system becomes (X, Y) = (x, rad2 / rad1 * y) in new one - // To go back to previous location, center shall be translated to t = -Y * (1 - rad1 / rad2) in y axis - // (Y = rad2 / rad1 * y and y = t + Y) - double scale_ = radius2_ / radius_; - cr->scale (1., scale_); - cr->translate (0., - center_.y * (1 - 1 / scale_)); - - cr->arc (center_.x + 0.5, center_.y + 0.5, radius_, begang_, endang_); - - cr->restore(); - cr->stroke(); - } - - if (state == INSENSITIVE) { - std::valarray ds (1); - ds[0] = 4; - cr->set_source_rgba (1.0, 1.0, 1.0, 0.618); - cr->stroke_preserve(); - cr->set_source_rgba (0.0, 0.0, 0.0, 0.618); - cr->set_dash (ds, 0); - cr->stroke(); - ds.resize (0); - cr->set_dash (ds, 0); - } else { - cr->stroke(); - } - } - } -} - -void Arcellipse::drawToMOChannel (Cairo::RefPtr &cr, unsigned short id, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) -{ - if (flags & F_HOVERABLE) { - cr->set_line_width ( getMouseOverLineWidth() ); - rtengine::Coord center_ = center; - double radius_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radius)) : double (radius); - double radius2_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas (double (radius2)) : double (radius2); - double begang_ = begang; - double endang_ = endang; - - if (datum == IMAGE) { - coordSystem.imageCoordToCropCanvas (center.x, center.y, center_.x, center_.y); - } else if (datum == CLICKED_POINT) { - center_ += objectBuffer->getDataProvider()->posScreen; - } else if (datum == CURSOR) { - center_ += objectBuffer->getDataProvider()->posScreen + objectBuffer->getDataProvider()->deltaScreen; - } - - if (radius_ > 0 && radius2_ > 0.) { - cr->save(); - - // To have an ellipse with radius of (rad1, rad2), a circle of radius rad1 shall be twisted with a scale - // of rad2 / rad1 for y axis - // Center of coordinates (x, y) in previous coordinates system becomes (X, Y) = (x, rad2 / rad1 * y) in new one - // To go back to previous location, center shall be translated to t = -Y * (1 - rad1 / rad2) in y axis - // (Y = rad2 / rad1 * y and y = t + Y) - double scale_ = radius2_ / radius_; - cr->scale (1., scale_); - cr->translate (0., - center_.y * (1 - 1 / scale_)); - - cr->arc (center_.x + 0.5, center_.y + 0.5, radius_, begang_, endang_); - - cr->restore(); - cr->stroke(); - } - - if (filled) { - if (innerLineWidth > 0.) { - cr->fill_preserve(); - cr->stroke(); - } else { - cr->fill(); - } - } else { - cr->stroke(); - } - } -} - void OPIcon::drivenPointToRectangle(const rtengine::Coord &pos, rtengine::Coord &topLeft, rtengine::Coord &bottomRight, int W, int H) { diff --git a/rtgui/editwidgets.h b/rtgui/editwidgets.h index 981fe9b4b..9c8cdacba 100644 --- a/rtgui/editwidgets.h +++ b/rtgui/editwidgets.h @@ -341,33 +341,6 @@ public: void drawToMOChannel (Cairo::RefPtr &cr, unsigned short id, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem) override; }; -class Arcellipse : public Geometry -{ -public: - rtengine::Coord center; - // rtengine::Coord scalx; - // rtengine::Coord scaly; - // TODO translax, translay, scalx and scaly are not used - double radius; - double radius2; - double translax; - double translay; - double scalx; - double scaly; - double begang; - double endang; - bool filled; - bool radiusInImageSpace; /// If true, the radius depend on the image scale; if false, it is a fixed 'screen' size - - Arcellipse (); - Arcellipse (rtengine::Coord& center, double radius, double radius2, double translax, double translay, double scalx, double scaly, double begang, double endang, bool filled = false, bool radiusInImageSpace = false); - Arcellipse (int centerX, int centerY, double radius, double radius2, double translax, double translay, double scalx, double scaly, double begang, double endang, bool filled = false, bool radiusInImageSpace = false); - - void drawOuterGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem); - void drawInnerGeometry (Cairo::RefPtr &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem); - void drawToMOChannel (Cairo::RefPtr &cr, unsigned short id, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem); -}; - class OPIcon : public Geometry // OP stands for "On Preview" { @@ -568,11 +541,6 @@ inline Ellipse::Ellipse () : center (100, 100), radYT (5), radY (5), radXL (10), radX (10), filled (false), radiusInImageSpace (false) { } -inline Arcellipse::Arcellipse () : - center (100, 100), radius (10), radius2 (10), translax (0), translay (0), filled (false), radiusInImageSpace ( - false) { -} - inline Circle::Circle (rtengine::Coord& center, int radius, bool filled, bool radiusInImageSpace) : center (center), radius (radius), filled (filled), radiusInImageSpace ( @@ -599,17 +567,4 @@ inline Ellipse::Ellipse (rtengine::Coord& center, int radYT, int radY, int radXL radiusInImageSpace (radiusInImageSpace) { } -inline Arcellipse::Arcellipse (rtengine::Coord& center, double radius, double radius2, double translax, double translay, double scalx, double scaly, double begang, double endang, bool filled, - bool radiusInImageSpace) : - center (center), radius (radius), radius2 (radius2), translax (translax), translay (translay), scalx (scalx), scaly (scaly), begang (begang), endang (endang), filled (filled), radiusInImageSpace ( - radiusInImageSpace) { -} - -inline Arcellipse::Arcellipse (int centerX, int centerY, double radius, double radius2, double translax, double translay, double scalx, double scaly, double begang, double endang, bool filled, - bool radiusInImageSpace) : - center (centerX, centerY), radius (radius), radius2 (radius2), translax (translax), translay (translay), scalx (scalx), scaly (scaly), begang (begang), endang (endang), filled (filled), radiusInImageSpace ( - radiusInImageSpace) { -} - #endif - From 1725a53f93a69986dc1f9e9cc0e2e62f3e1f5a64 Mon Sep 17 00:00:00 2001 From: Pandagrapher Date: Sun, 31 Mar 2019 18:57:07 +0200 Subject: [PATCH 3/5] Gets Locallab spots more discrete, fixes #5247 Selection lines have been replaced by more discrete selection points Bugfixes/improvements: - Selection points have now priority on ellipse/rectangle and center circle which improves Locallab spot resizing - When mouse-overing a Locallab spot, all the spot becames now orange (even selection spots) --- rtgui/controlspotpanel.cc | 370 +++++++++++++++++++------------------- 1 file changed, 184 insertions(+), 186 deletions(-) diff --git a/rtgui/controlspotpanel.cc b/rtgui/controlspotpanel.cc index 072a8061b..1fb1406e9 100644 --- a/rtgui/controlspotpanel.cc +++ b/rtgui/controlspotpanel.cc @@ -1026,73 +1026,77 @@ void ControlSpotPanel::addControlSpotCurve(Gtk::TreeModel::Row row) } // Creation of visibleGeometry - Line* lineX; - lineX = new Line(); - lineX->innerLineWidth = 2.5; - lineX->datum = Geometry::IMAGE; - Line* lineXL; - lineXL = new Line(); - lineXL->innerLineWidth = 2.5; - lineXL->datum = Geometry::IMAGE; - Line* lineY; - lineY = new Line(); - lineY->innerLineWidth = 2.5; - lineY->datum = Geometry::IMAGE; - Line* lineYT; - lineYT = new Line(); - lineYT->innerLineWidth = 2.5; - lineYT->datum = Geometry::IMAGE; + Circle* cirX; + cirX = new Circle(); + cirX->radius = 4.; + cirX->filled = true; + cirX->datum = Geometry::IMAGE; + Circle* cirXL; + cirXL = new Circle(); + cirXL->radius = 4.; + cirXL->filled = true; + cirXL->datum = Geometry::IMAGE; + Circle* cirY; + cirY = new Circle(); + cirY->radius = 4.; + cirY->filled = true; + cirY->datum = Geometry::IMAGE; + Circle* cirYT; + cirYT = new Circle(); + cirYT->radius = 4.; + cirYT->filled = true; + cirYT->datum = Geometry::IMAGE; Circle* centerCircle; centerCircle = new Circle(); centerCircle->datum = Geometry::IMAGE; centerCircle->radiusInImageSpace = true; Ellipse* shape_ellipse; shape_ellipse = new Ellipse(); - shape_ellipse->innerLineWidth = 0.7; shape_ellipse->datum = Geometry::IMAGE; shape_ellipse->radiusInImageSpace = true; Rectangle* shape_rectangle; shape_rectangle = new Rectangle(); - shape_rectangle->innerLineWidth = 0.7; shape_rectangle->datum = Geometry::IMAGE; - EditSubscriber::visibleGeometry.push_back(lineX); // (curveid - 1) * 7 - EditSubscriber::visibleGeometry.push_back(lineXL); // (curveid - 1) * 7 + 1 - EditSubscriber::visibleGeometry.push_back(lineY); // (curveid - 1) * 7 + 2 - EditSubscriber::visibleGeometry.push_back(lineYT); // (curveid - 1) * 7 + 3 - EditSubscriber::visibleGeometry.push_back(centerCircle); // (curveid - 1) * 7 + 4 - EditSubscriber::visibleGeometry.push_back(shape_ellipse); // (curveid - 1) * 7 + 5 - EditSubscriber::visibleGeometry.push_back(shape_rectangle); // (curveid - 1) * 7 + 6 + EditSubscriber::visibleGeometry.push_back(centerCircle); // (curveid - 1) * 7 + EditSubscriber::visibleGeometry.push_back(shape_ellipse); // (curveid - 1) * 7 + 1 + EditSubscriber::visibleGeometry.push_back(shape_rectangle); // (curveid - 1) * 7 + 2 + EditSubscriber::visibleGeometry.push_back(cirX); // (curveid - 1) * 7 + 3 + EditSubscriber::visibleGeometry.push_back(cirXL); // (curveid - 1) * 7 + 4 + EditSubscriber::visibleGeometry.push_back(cirY); // (curveid - 1) * 7 + 5 + EditSubscriber::visibleGeometry.push_back(cirYT); // (curveid - 1) * 7 + 6 // Creation of mouseOverGeometry - lineX = new Line(); - lineX->innerLineWidth = 2.5; - lineX->datum = Geometry::IMAGE; - lineXL = new Line(); - lineXL->innerLineWidth = 2.5; - lineXL->datum = Geometry::IMAGE; - lineY = new Line(); - lineY->innerLineWidth = 2.5; - lineY->datum = Geometry::IMAGE; - lineYT = new Line(); - lineYT->innerLineWidth = 2.5; - lineYT->datum = Geometry::IMAGE; + cirX = new Circle(); + cirX->radius = 4.; + cirX->filled = true; + cirX->datum = Geometry::IMAGE; + cirXL = new Circle(); + cirXL->radius = 4.; + cirXL->filled = true; + cirXL->datum = Geometry::IMAGE; + cirY = new Circle(); + cirY->radius = 4.; + cirY->filled = true; + cirY->datum = Geometry::IMAGE; + cirYT = new Circle(); + cirYT->radius = 4.; + cirYT->filled = true; + cirYT->datum = Geometry::IMAGE; centerCircle = new Circle(); centerCircle->datum = Geometry::IMAGE; centerCircle->radiusInImageSpace = true; shape_ellipse = new Ellipse(); - shape_ellipse->innerLineWidth = 0.7; shape_ellipse->datum = Geometry::IMAGE; shape_ellipse->radiusInImageSpace = true; shape_rectangle = new Rectangle(); - shape_rectangle->innerLineWidth = 0.7; shape_rectangle->datum = Geometry::IMAGE; - EditSubscriber::mouseOverGeometry.push_back(lineX); // (curveid - 1) * 7 - EditSubscriber::mouseOverGeometry.push_back(lineXL); // (curveid - 1) * 7 + 1 - EditSubscriber::mouseOverGeometry.push_back(lineY); // (curveid - 1) * 7 + 2 - EditSubscriber::mouseOverGeometry.push_back(lineYT); // (curveid - 1) * 7 + 3 - EditSubscriber::mouseOverGeometry.push_back(centerCircle); // (curveid - 1) * 7 + 4 - EditSubscriber::mouseOverGeometry.push_back(shape_ellipse); // (curveid - 1) * 7 + 5 - EditSubscriber::mouseOverGeometry.push_back(shape_rectangle); // (curveid - 1) * 7 + 6 + EditSubscriber::mouseOverGeometry.push_back(centerCircle); // (curveid - 1) * 7 + EditSubscriber::mouseOverGeometry.push_back(shape_ellipse); // (curveid - 1) * 7 + 1 + EditSubscriber::mouseOverGeometry.push_back(shape_rectangle); // (curveid - 1) * 7 + 2 + EditSubscriber::mouseOverGeometry.push_back(cirX); // (curveid - 1) * 7 + 3 + EditSubscriber::mouseOverGeometry.push_back(cirXL); // (curveid - 1) * 7 + 4 + EditSubscriber::mouseOverGeometry.push_back(cirY); // (curveid - 1) * 7 + 5 + EditSubscriber::mouseOverGeometry.push_back(cirYT); // (curveid - 1) * 7 + 6 row[spots_.curveid] = EditSubscriber::visibleGeometry.size() / 7; } @@ -1130,17 +1134,15 @@ void ControlSpotPanel::updateControlSpotCurve(Gtk::TreeModel::Row row) const int decayXL = locXL_ * (imW / 2000); const int decayY = locY_ * (imH / 2000); const int decayYT = locYT_ * (imH / 2000); - rtengine::Coord origin(imW / 2 + centerX_ * imW / 2000, imH / 2 + centerY_ * imH / 2000); + const rtengine::Coord origin(imW / 2 + centerX_ * imW / 2000, imH / 2 + centerY_ * imH / 2000); - const auto updateLineWithDecay = [&](Geometry * geometry, const float radius, const float decal, const float offSetAngle, const double decay) { - const auto line = static_cast(geometry); // 180 - line->begin = PolarCoord(radius, decal) + PolarCoord(decay, offSetAngle); - line->begin += origin; // 0 - line->end = PolarCoord(radius, decal - 180) + PolarCoord(decay, offSetAngle); - line->end += origin; + const auto updateSelectionCircle = [&](Geometry * geometry, const int offsetX, const int offsetY) { + const auto cir = static_cast(geometry); + cir->center.x = origin.x + offsetX; + cir->center.y = origin.y + offsetY; }; - const auto updateCircle = [&](Geometry * geometry) { + const auto updateCenterCircle = [&](Geometry * geometry) { const auto circle = static_cast(geometry); circle->center = origin; circle->radius = circrad_; @@ -1163,70 +1165,70 @@ void ControlSpotPanel::updateControlSpotCurve(Gtk::TreeModel::Row row) rectangle->topLeft.y = origin.y - decayYT; }; - updateLineWithDecay(visibleGeometry.at((curveid_ - 1) * 7), 500., 90., 0., decayX); - updateLineWithDecay(mouseOverGeometry.at((curveid_ - 1) * 7), 500., 90., 0., decayX); + updateCenterCircle(visibleGeometry.at((curveid_ - 1) * 7)); + updateCenterCircle(mouseOverGeometry.at((curveid_ - 1) * 7)); - updateLineWithDecay(visibleGeometry.at((curveid_ - 1) * 7 + 1), 500., 90., 180., decayXL); - updateLineWithDecay(mouseOverGeometry.at((curveid_ - 1) * 7 + 1), 500., 90., 180., decayXL); + updateEllipse(visibleGeometry.at((curveid_ - 1) * 7 + 1)); + updateEllipse(mouseOverGeometry.at((curveid_ - 1) * 7 + 1)); - updateLineWithDecay(visibleGeometry.at((curveid_ - 1) * 7 + 2), 500., 180., 90., decayY); - updateLineWithDecay(mouseOverGeometry.at((curveid_ - 1) * 7 + 2), 500., 180., 90., decayY); + updateRectangle(visibleGeometry.at((curveid_ - 1) * 7 + 2)); + updateRectangle(mouseOverGeometry.at((curveid_ - 1) * 7 + 2)); - updateLineWithDecay(visibleGeometry.at((curveid_ - 1) * 7 + 3), 500., 180., 270., decayYT); - updateLineWithDecay(mouseOverGeometry.at((curveid_ - 1) * 7 + 3), 500., 180., 270., decayYT); + updateSelectionCircle(visibleGeometry.at((curveid_ - 1) * 7 + 3), decayX, 0.); + updateSelectionCircle(mouseOverGeometry.at((curveid_ - 1) * 7 + 3), decayX, 0.); - updateCircle(visibleGeometry.at((curveid_ - 1) * 7 + 4)); - updateCircle(mouseOverGeometry.at((curveid_ - 1) * 7 + 4)); + updateSelectionCircle(visibleGeometry.at((curveid_ - 1) * 7 + 4), -decayXL, 0.); + updateSelectionCircle(mouseOverGeometry.at((curveid_ - 1) * 7 + 4), -decayXL, 0.); - updateEllipse(visibleGeometry.at((curveid_ - 1) * 7 + 5)); - updateEllipse(mouseOverGeometry.at((curveid_ - 1) * 7 + 5)); + updateSelectionCircle(visibleGeometry.at((curveid_ - 1) * 7 + 5), 0., decayY); + updateSelectionCircle(mouseOverGeometry.at((curveid_ - 1) * 7 + 5), 0., decayY); - updateRectangle(visibleGeometry.at((curveid_ - 1) * 7 + 6)); - updateRectangle(mouseOverGeometry.at((curveid_ - 1) * 7 + 6)); + updateSelectionCircle(visibleGeometry.at((curveid_ - 1) * 7 + 6), 0., -decayYT); + updateSelectionCircle(mouseOverGeometry.at((curveid_ - 1) * 7 + 6), 0., -decayYT); // Update Arcellipse/Rectangle visibility according to shape and visibility if (isvisible_) { - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7)->setActive(true); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 1)->setActive(true); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 2)->setActive(true); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 3)->setActive(true); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 4)->setActive(true); + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7)->setActive(true); // centerCircle + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 3)->setActive(true); // cirX + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 4)->setActive(true); // cirXL + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 5)->setActive(true); // cirY + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 6)->setActive(true); // cirYT - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7)->setActive(true); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 1)->setActive(true); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 2)->setActive(true); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 3)->setActive(true); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 4)->setActive(true); + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7)->setActive(true); // centerCircle + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 3)->setActive(true); // cirX + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 4)->setActive(true); // cirXL + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 5)->setActive(true); // cirY + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 6)->setActive(true); // cirYT if (shape_ == 0) { // 0 = Ellipse - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 5)->setActive(true); // shape_ellipse - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 6)->setActive(false); // shape_rectangle + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 1)->setActive(true); // shape_ellipse + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 2)->setActive(false); // shape_rectangle - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 5)->setActive(true); // shape_ellipse - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 6)->setActive(false); // shape_rectangle + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 1)->setActive(true); // shape_ellipse + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 2)->setActive(false); // shape_rectangle } else { // 1 = Rectangle - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 5)->setActive(false); // shape_ellipse - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 6)->setActive(true); // shape_rectangle + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 1)->setActive(false); // shape_ellipse + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 2)->setActive(true); // shape_rectangle - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 5)->setActive(false); // shape_ellipse - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 6)->setActive(true); // shape_rectangle + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 1)->setActive(false); // shape_ellipse + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 2)->setActive(true); // shape_rectangle } } else { - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 1)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 2)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 3)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 4)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 5)->setActive(false); - EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 6)->setActive(false); + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7)->setActive(false); // centerCircle + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 1)->setActive(false); // shape_ellipse + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 2)->setActive(false); // shape_rectangle + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 3)->setActive(false); // cirX + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 4)->setActive(false); // cirXL + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 5)->setActive(false); // cirY + EditSubscriber::visibleGeometry.at((curveid_ - 1) * 7 + 6)->setActive(false); // cirYT - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 1)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 2)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 3)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 4)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 5)->setActive(false); - EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 6)->setActive(false); + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7)->setActive(false); // centerCircle + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 1)->setActive(false); // shape_ellipse + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 2)->setActive(false); // shape_rectangle + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 3)->setActive(false); // cirX + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 4)->setActive(false); // cirXL + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 5)->setActive(false); // cirY + EditSubscriber::mouseOverGeometry.at((curveid_ - 1) * 7 + 6)->setActive(false); // cirYT } } @@ -1285,27 +1287,27 @@ CursorShape ControlSpotPanel::getCursor(int objectID) const int rem_ = objectID % 7; switch (rem_) { - case (0): // LocX: (curveid_ - 1) * 7 + case (0): // centerCircle: (curveid_ - 1) * 7 + return CSMove2D; + + case (1): // shape_ellipse: (curveid_ - 1) * 7 + 1 + return CSMove2D; + + case (2): // shape_rectangle: (curveid_ - 1) * 7 + 2 + return CSMove2D; + + case (3): // cirX: (curveid_ - 1) * 7 + 3 return CSMove1DH; - case (1): // LocXL: (curveid_ - 1) * 7 + 1 + case (4): // cirXL: (curveid_ - 1) * 7 + 4 return CSMove1DH; - case (2): // LocY: (curveid_ - 1) * 7 + 2 + case (5): // cirY: (curveid_ - 1) * 7 + 5 return CSMove1DV; - case (3): // LocYT: (curveid_ - 1) * 7 + 3 + case (6): // cirYT: (curveid_ - 1) * 7 + 6 return CSMove1DV; - case (4): // centerCircle: (curveid_ - 1) * 7 + 4 - return CSMove2D; - - case (5): // shape_ellipse: (curveid_ - 1) * 7 + 5 - return CSMove2D; - - case (6): // shape_rectangle: (curveid_ - 1) * 7 + 6 - return CSMove2D; - default: return CSHandOpen; } @@ -1370,65 +1372,61 @@ bool ControlSpotPanel::mouseOver(int modifierKey) const int method = shapeMethod_->get_active_row_number(); - // LocX - if (rem == 0) { - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7)->state = Geometry::PRELIGHT; - - if (method == 1 || method == 3) { // Symmetrical cases - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 1)->state = Geometry::PRELIGHT; - } - } else { - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7)->state = Geometry::NORMAL; - } - - // LocXL - if (rem == 1) { - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 1)->state = Geometry::PRELIGHT; - - if (method == 1 || method == 3) { // Symmetrical cases - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7)->state = Geometry::PRELIGHT; - } - } else { - if (method == 0 || method == 2) { // Independent cases - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 1)->state = Geometry::NORMAL; - } - } - - // LocY - if (rem == 2) { - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 2)->state = Geometry::PRELIGHT; - - if (method == 1 || method == 3) { // Symmetrical cases - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 3)->state = Geometry::PRELIGHT; - } - } else { - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 2)->state = Geometry::NORMAL; - } - - // LocYT - if (rem == 3) { - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 3)->state = Geometry::PRELIGHT; - - if (method == 1 || method == 3) { // Symmetrical cases - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 2)->state = Geometry::PRELIGHT; - } - } else { - if (method == 0 || method == 2) { // Independent cases - EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 3)->state = Geometry::NORMAL; - } - } - // Circle, Arcellipses and Rectangle - if (rem >= 4) { + if (rem >= 0 && rem < 3) { + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 1)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 2)->state = Geometry::PRELIGHT; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 3)->state = Geometry::PRELIGHT; EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 4)->state = Geometry::PRELIGHT; EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 5)->state = Geometry::PRELIGHT; EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 6)->state = Geometry::PRELIGHT; } else { + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7)->state = Geometry::NORMAL; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 2)->state = Geometry::NORMAL; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 3)->state = Geometry::NORMAL; + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 4)->state = Geometry::NORMAL; EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 4)->state = Geometry::NORMAL; EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 5)->state = Geometry::NORMAL; EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 6)->state = Geometry::NORMAL; } + // cirX + if (rem == 3) { + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 3)->state = Geometry::PRELIGHT; + + if (method == 1 || method == 3) { // Symmetrical cases + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 4)->state = Geometry::PRELIGHT; + } + } + + // cirXL + if (rem == 4) { + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 4)->state = Geometry::PRELIGHT; + + if (method == 1 || method == 3) { // Symmetrical cases + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 3)->state = Geometry::PRELIGHT; + } + } + + // cirY + if (rem == 5) { + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 5)->state = Geometry::PRELIGHT; + + if (method == 1 || method == 3) { // Symmetrical cases + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 6)->state = Geometry::PRELIGHT; + } + } + + // cirYT + if (rem == 6) { + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 6)->state = Geometry::PRELIGHT; + + if (method == 1 || method == 3) { // Symmetrical cases + EditSubscriber::visibleGeometry.at((curveId_ - 1) * 7 + 5)->state = Geometry::PRELIGHT; + } + } + lastObject_ = object_; return true; } @@ -1492,8 +1490,24 @@ bool ControlSpotPanel::drag1(int modifierKey) int method = shapeMethod_->get_active_row_number(); Coord* newCoord = new Coord(provider->posImage.x + provider->deltaImage.x, provider->posImage.y + provider->deltaImage.y); - // LocX - if (rem == 0) { + // Circle, Ellipses and Rectangle + if (rem >= 0 && rem < 3) { + double deltaX = (double (newCoord->x) - double (lastCoord_->x)) * 2000. / double (imW); + double deltaY = (double (newCoord->y) - double (lastCoord_->y)) * 2000. / double (imH); + centerX_->setValue(centerX_->getValue() + deltaX); + centerY_->setValue(centerY_->getValue() + deltaY); + row[spots_.centerX] = (int) centerX_->getValue(); + row[spots_.centerY] = (int) centerY_->getValue(); + + updateControlSpotCurve(row); + + if (listener) { + listener->panelChanged(EvLocallabSpotCenter, "X=" + centerX_->getTextValue() + ", Y=" + centerY_->getTextValue()); + } + } + + // cirX + if (rem == 3) { double deltaX = (double (newCoord->x) - double (lastCoord_->x)) * 2000. / double (imW); locX_->setValue(locX_->getValue() + deltaX); row[spots_.locX] = (int) locX_->getValue(); @@ -1512,8 +1526,8 @@ bool ControlSpotPanel::drag1(int modifierKey) } } - // LocXL - if (rem == 1) { + // cirXL + if (rem == 4) { double deltaXL = (double (lastCoord_->x) - double (newCoord->x)) * 2000. / double (imW); locXL_->setValue(locXL_->getValue() + deltaXL); row[spots_.locXL] = (int) locXL_->getValue(); @@ -1532,8 +1546,8 @@ bool ControlSpotPanel::drag1(int modifierKey) } } - // LocY - if (rem == 2) { + // cirY + if (rem == 5) { double deltaY = (double (newCoord->y) - double (lastCoord_->y)) * 2000. / double (imH); locY_->setValue(locY_->getValue() + deltaY); row[spots_.locY] = (int) locY_->getValue(); @@ -1552,8 +1566,8 @@ bool ControlSpotPanel::drag1(int modifierKey) } } - // LocYT - if (rem == 3) { + // cirYT + if (rem == 6) { double deltaYT = (double (lastCoord_->y) - double (newCoord->y)) * 2000. / double (imH); locYT_->setValue(locYT_->getValue() + deltaYT); row[spots_.locYT] = (int) locYT_->getValue(); @@ -1572,22 +1586,6 @@ bool ControlSpotPanel::drag1(int modifierKey) } } - // Circle, Ellipses and Rectangle - if (rem >= 4) { - double deltaX = (double (newCoord->x) - double (lastCoord_->x)) * 2000. / double (imW); - double deltaY = (double (newCoord->y) - double (lastCoord_->y)) * 2000. / double (imH); - centerX_->setValue(centerX_->getValue() + deltaX); - centerY_->setValue(centerY_->getValue() + deltaY); - row[spots_.centerX] = (int) centerX_->getValue(); - row[spots_.centerY] = (int) centerY_->getValue(); - - updateControlSpotCurve(row); - - if (listener) { - listener->panelChanged(EvLocallabSpotCenter, "X=" + centerX_->getTextValue() + ", Y=" + centerY_->getTextValue()); - } - } - lastCoord_->set(newCoord->x, newCoord->y); return true; } From 0225a7f109e8ca32fd99ee33ccd413c2ff8b05f3 Mon Sep 17 00:00:00 2001 From: Pandagrapher Date: Tue, 2 Apr 2019 19:09:10 +0200 Subject: [PATCH 4/5] Manages Locallab spot opacity according to selected one --- rtgui/controlspotpanel.cc | 20 ++++++++++++++++++++ rtgui/controlspotpanel.h | 1 + rtgui/editwidgets.cc | 20 ++++++++++---------- rtgui/editwidgets.h | 3 ++- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/rtgui/controlspotpanel.cc b/rtgui/controlspotpanel.cc index 1fb1406e9..9b8e618c9 100644 --- a/rtgui/controlspotpanel.cc +++ b/rtgui/controlspotpanel.cc @@ -1274,6 +1274,25 @@ void ControlSpotPanel::deleteControlSpotCurve(Gtk::TreeModel::Row row) } } +void ControlSpotPanel::updateCurveOpacity(Gtk::TreeModel::Row selectedRow) +{ + const int curveid_ = selectedRow[spots_.curveid]; + + // printf("updateCurveOpacity: %d\n", curveid_); + + if (curveid_ == 0) { // Row has no associated curve + return; + } + + for (int it_ = 0; it_ < (int) EditSubscriber::visibleGeometry.size(); it_++) { + if ((it_ < ((curveid_ - 1) * 7)) || (it_ > ((curveid_ - 1) * 7) + 6)) { // it_ does not belong to selected curve + EditSubscriber::visibleGeometry.at(it_)->opacity = 25.; + } else { + EditSubscriber::visibleGeometry.at(it_)->opacity = 75.; + } + } +} + CursorShape ControlSpotPanel::getCursor(int objectID) const { // printf("Object ID: %d\n", objectID); @@ -1698,6 +1717,7 @@ void ControlSpotPanel::setSelectedSpot(int id) treeview_.set_cursor(treemodel_->get_path(row)); load_ControlSpot_param(); updateParamVisibility(); + updateCurveOpacity(row); } } diff --git a/rtgui/controlspotpanel.h b/rtgui/controlspotpanel.h index 47f7a3bc5..45afdb23d 100644 --- a/rtgui/controlspotpanel.h +++ b/rtgui/controlspotpanel.h @@ -248,6 +248,7 @@ private: void addControlSpotCurve(Gtk::TreeModel::Row row); void updateControlSpotCurve(Gtk::TreeModel::Row row); void deleteControlSpotCurve(Gtk::TreeModel::Row row); + void updateCurveOpacity(Gtk::TreeModel::Row selectedRow); CursorShape getCursor(int objectID) const; bool mouseOver(int modifierKey); bool button1Pressed(int modifierKey); diff --git a/rtgui/editwidgets.cc b/rtgui/editwidgets.cc index 6c1ef892b..444ad5a65 100644 --- a/rtgui/editwidgets.cc +++ b/rtgui/editwidgets.cc @@ -74,7 +74,7 @@ void Circle::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuffer color = outerLineColor; } - cr->set_source_rgb (color.getR(), color.getG(), color.getB()); + cr->set_source_rgba (color.getR(), color.getG(), color.getB(), opacity / 100.); cr->set_line_width( getOuterLineWidth() ); rtengine::Coord center_ = center; @@ -105,7 +105,7 @@ void Circle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer color = innerLineColor; } - cr->set_source_rgb(color.getR(), color.getG(), color.getB()); + cr->set_source_rgba(color.getR(), color.getG(), color.getB(), opacity / 100.); } cr->set_line_width( innerLineWidth ); @@ -197,7 +197,7 @@ void Line::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuffer * color = outerLineColor; } - cr->set_source_rgb (color.getR(), color.getG(), color.getB()); + cr->set_source_rgba (color.getR(), color.getG(), color.getB(), opacity / 100.0); cr->set_line_width( getOuterLineWidth() ); rtengine::Coord begin_ = begin; @@ -232,7 +232,7 @@ void Line::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuffer * color = innerLineColor; } - cr->set_source_rgb (color.getR(), color.getG(), color.getB()); + cr->set_source_rgba (color.getR(), color.getG(), color.getB(), opacity / 100.); } cr->set_line_width(innerLineWidth); @@ -311,7 +311,7 @@ void Polyline::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuff color = outerLineColor; } - cr->set_source_rgb (color.getR(), color.getG(), color.getB()); + cr->set_source_rgba (color.getR(), color.getG(), color.getB(), opacity / 100.); cr->set_line_width( getOuterLineWidth() ); rtengine::Coord currPos; @@ -355,7 +355,7 @@ void Polyline::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuff color = innerLineColor; } - cr->set_source_rgb (color.getR(), color.getG(), color.getB()); + cr->set_source_rgba (color.getR(), color.getG(), color.getB(), opacity / 100.); } cr->set_line_width( innerLineWidth ); @@ -504,7 +504,7 @@ void Rectangle::drawOuterGeometry(Cairo::RefPtr &cr, ObjectMOBuf color = outerLineColor; } - cr->set_source_rgb (color.getR(), color.getG(), color.getB()); + cr->set_source_rgba (color.getR(), color.getG(), color.getB(), opacity / 100.); cr->set_line_width( getOuterLineWidth() ); rtengine::Coord tl, br; @@ -548,7 +548,7 @@ void Rectangle::drawInnerGeometry(Cairo::RefPtr &cr, ObjectMOBuf color = innerLineColor; } - cr->set_source_rgb (color.getR(), color.getG(), color.getB()); + cr->set_source_rgba (color.getR(), color.getG(), color.getB(), opacity / 100.); } cr->set_line_width( innerLineWidth ); @@ -655,7 +655,7 @@ void Ellipse::drawOuterGeometry (Cairo::RefPtr &cr, ObjectMOBuff color = outerLineColor; } - cr->set_source_rgb (color.getR(), color.getG(), color.getB()); + cr->set_source_rgba (color.getR(), color.getG(), color.getB(), opacity / 100.); cr->set_line_width ( getOuterLineWidth() ); rtengine::Coord center_ = center; @@ -728,7 +728,7 @@ void Ellipse::drawInnerGeometry (Cairo::RefPtr &cr, ObjectMOBuff color = innerLineColor; } - cr->set_source_rgb (color.getR(), color.getG(), color.getB()); + cr->set_source_rgba (color.getR(), color.getG(), color.getB(), opacity / 100.); } cr->set_line_width ( innerLineWidth ); diff --git a/rtgui/editwidgets.h b/rtgui/editwidgets.h index 9c8cdacba..dda661cfe 100644 --- a/rtgui/editwidgets.h +++ b/rtgui/editwidgets.h @@ -232,6 +232,7 @@ public: float innerLineWidth; // ...outerLineWidth = innerLineWidth+2 Datum datum; State state; // set by the Subscriber + float opacity; // Percentage of opacity Geometry (); virtual ~Geometry() {} @@ -493,7 +494,7 @@ inline Geometry::Geometry () : innerLineColor (char (255), char (255), char (255)), outerLineColor ( char (0), char (0), char (0)), flags ( F_VISIBLE | F_HOVERABLE | F_AUTO_COLOR), innerLineWidth (1.5f), datum ( - IMAGE), state (NORMAL) { + IMAGE), state (NORMAL), opacity(100.) { } inline RGBAColor::RGBAColor () : From 690df79ef262f272a3b60d0a79e2c69f97c3ff34 Mon Sep 17 00:00:00 2001 From: Pandagrapher Date: Wed, 3 Apr 2019 21:00:54 +0200 Subject: [PATCH 5/5] Avoids Locallab spot to disapear when mouse right-clicking This commit also avoids Locallab spot to disapear when adding lockable color picker, pressing toolbar "hand" button, pressing h/H key. However, if another tool button (ex: resizing tool) is pressed, this action is considered --- rtgui/toolbar.cc | 6 +++--- rtgui/toolbar.h | 6 ++++++ rtgui/toolpanelcoord.cc | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/rtgui/toolbar.cc b/rtgui/toolbar.cc index 9bed78768..f0a08b263 100644 --- a/rtgui/toolbar.cc +++ b/rtgui/toolbar.cc @@ -107,7 +107,7 @@ void ToolBar::setTool (ToolMode tool) ConnectionBlocker cropBlocker(cropConn); ConnectionBlocker wbWasBlocked(wbTool, wbConn), cpWasBlocked(colPickerTool, cpConn); - stopEdit = tool == TMHand && handTool->get_active() && editingMode; + stopEdit = tool == TMHand && handTool->get_active() && editingMode && !blockEdit; handTool->set_active (false); @@ -204,7 +204,7 @@ void ToolBar::hand_pressed () ConnectionBlocker cropBlocker(cropConn); ConnectionBlocker wbWasBlocked(wbTool, wbConn), cpWasBlocked(colPickerTool, cpConn); - if (editingMode) { + if (editingMode && !blockEdit) { stopEditMode(); if (listener) { listener->editModeSwitchedOff (); @@ -289,7 +289,7 @@ void ToolBar::colPicker_pressed (GdkEventButton* event) if (current != TMColorPicker) { // Disabling all other tools, enabling the Picker tool and entering the "visible pickers" mode - if (editingMode) { + if (editingMode && !blockEdit) { stopEditMode(); if (listener) { listener->editModeSwitchedOff (); diff --git a/rtgui/toolbar.h b/rtgui/toolbar.h index 2d859eac7..b86aff6ca 100644 --- a/rtgui/toolbar.h +++ b/rtgui/toolbar.h @@ -64,6 +64,7 @@ protected: ToolMode current; bool allowNoTool; bool editingMode; // true if the cursor is being used to remotely edit tool's values + bool blockEdit; // true if edit tool shoudn't be disabled when pressing hand button or h/H key sigc::connection handConn; sigc::connection wbConn; sigc::connection cpConn; @@ -98,6 +99,11 @@ public: bool handleShortcutKey (GdkEventKey* event); void setBatchMode(); + + void blockEditDeactivation(bool cond = true) + { + blockEdit = cond; + } }; #endif diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index 1f8988c03..b3072326e 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -281,8 +281,10 @@ void ToolPanelCoordinator::notebookPageChanged(Gtk::Widget* page, guint page_num // segfault) and locallab panel is active if (photoLoadedOnce) { if (page == locallabPanelSW) { + toolBar->blockEditDeactivation(); // Avoid edit tool deactivation when Locallab page is active (except if pressing other tools button) locallab->subscribe(); } else { + toolBar->blockEditDeactivation(false); locallab->unsubscribe(); } }