Spot removal : differentiating source/dest, betted cursor handling
+ some code cleanup from floessie (see issue #2239)
This commit is contained in:
@@ -20,7 +20,11 @@
|
||||
#include "editwidgets.h"
|
||||
#include "editbuffer.h"
|
||||
#include "editcallbacks.h"
|
||||
#include "../rtengine/rt_math.h"
|
||||
|
||||
const std::vector<double> Geometry::dash = {3., 1.5};
|
||||
|
||||
#define INNERGEOM_OPACITY 1.
|
||||
#define OUTERGEOM_OPACITY 0.7
|
||||
|
||||
RGBColor Geometry::getInnerLineColor ()
|
||||
{
|
||||
@@ -65,7 +69,8 @@ RGBColor Geometry::getOuterLineColor ()
|
||||
|
||||
void Circle::drawOuterGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem)
|
||||
{
|
||||
if ((flags & F_VISIBLE) && state != INSENSITIVE) {
|
||||
double lineWidth = getOuterLineWidth();
|
||||
if ((flags & F_VISIBLE) && state != INSENSITIVE && lineWidth > 0. && innerLineWidth > 0.) {
|
||||
RGBColor color;
|
||||
|
||||
if (flags & F_AUTO_COLOR) {
|
||||
@@ -74,8 +79,9 @@ void Circle::drawOuterGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuffer
|
||||
color = outerLineColor;
|
||||
}
|
||||
|
||||
cr->set_source_rgb (color.getR(), color.getG(), color.getB());
|
||||
cr->set_line_width( getOuterLineWidth() );
|
||||
cr->set_source_rgba (color.getR(), color.getG(), color.getB(), OUTERGEOM_OPACITY * rtengine::min(innerLineWidth / 2.f, 1.f));
|
||||
cr->set_line_width (lineWidth);
|
||||
cr->set_line_cap(Cairo::LINE_CAP_ROUND);
|
||||
|
||||
rtengine::Coord center_ = center;
|
||||
double radius_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas(double(radius)) : double(radius);
|
||||
@@ -105,10 +111,11 @@ void Circle::drawInnerGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuffer
|
||||
color = innerLineColor;
|
||||
}
|
||||
|
||||
cr->set_source_rgb(color.getR(), color.getG(), color.getB());
|
||||
cr->set_source_rgba (color.getR(), color.getG(), color.getB(), INNERGEOM_OPACITY);
|
||||
}
|
||||
|
||||
cr->set_line_width( innerLineWidth );
|
||||
cr->set_line_width(innerLineWidth);
|
||||
cr->set_line_cap(flags & F_DASHED ? Cairo::LINE_CAP_BUTT : Cairo::LINE_CAP_ROUND);
|
||||
|
||||
rtengine::Coord center_ = center;
|
||||
double radius_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas(double(radius)) : double(radius);
|
||||
@@ -121,9 +128,12 @@ void Circle::drawInnerGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuffer
|
||||
center_ += objectBuffer->getDataProvider()->posScreen + objectBuffer->getDataProvider()->deltaScreen;
|
||||
}
|
||||
|
||||
if (filled && state != INSENSITIVE) {
|
||||
cr->arc(center_.x + 0.5, center_.y + 0.5, radius_, 0., 2.*rtengine::RT_PI);
|
||||
if (flags & F_DASHED) {
|
||||
cr->set_dash(dash, 0.);
|
||||
}
|
||||
|
||||
if (filled) {
|
||||
cr->arc(center_.x + 0.5, center_.y + 0.5, radius_, 0., 2.*rtengine::RT_PI);
|
||||
if (innerLineWidth > 0.) {
|
||||
cr->fill_preserve();
|
||||
cr->stroke();
|
||||
@@ -132,28 +142,20 @@ void Circle::drawInnerGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuffer
|
||||
}
|
||||
} else if (innerLineWidth > 0.) {
|
||||
cr->arc(center_.x + 0.5, center_.y + 0.5, radius_, 0., 2.*rtengine::RT_PI);
|
||||
|
||||
if (state == INSENSITIVE) {
|
||||
std::valarray<double> 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();
|
||||
}
|
||||
cr->stroke();
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & F_DASHED) {
|
||||
cr->unset_dash();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Circle::drawToMOChannel (Cairo::RefPtr<Cairo::Context> &cr, unsigned short id, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem)
|
||||
{
|
||||
if (flags & F_HOVERABLE) {
|
||||
cr->set_line_width( getMouseOverLineWidth() );
|
||||
cr->set_line_cap(Cairo::LINE_CAP_ROUND);
|
||||
rtengine::Coord center_ = center;
|
||||
double radius_ = radiusInImageSpace ? coordSystem.scaleValueToCanvas(double(radius)) : double(radius);
|
||||
|
||||
@@ -188,7 +190,8 @@ void Circle::drawToMOChannel (Cairo::RefPtr<Cairo::Context> &cr, unsigned short
|
||||
|
||||
void Line::drawOuterGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem)
|
||||
{
|
||||
if ((flags & F_VISIBLE) && state != INSENSITIVE) {
|
||||
double lineWidth = getOuterLineWidth();
|
||||
if ((flags & F_VISIBLE) && state != INSENSITIVE && lineWidth > 0. && innerLineWidth > 0.) {
|
||||
RGBColor color;
|
||||
|
||||
if (flags & F_AUTO_COLOR) {
|
||||
@@ -197,8 +200,9 @@ void Line::drawOuterGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuffer *
|
||||
color = outerLineColor;
|
||||
}
|
||||
|
||||
cr->set_source_rgb (color.getR(), color.getG(), color.getB());
|
||||
cr->set_line_width( getOuterLineWidth() );
|
||||
cr->set_source_rgba (color.getR(), color.getG(), color.getB(), OUTERGEOM_OPACITY * rtengine::min(innerLineWidth / 2.f, 1.f));
|
||||
cr->set_line_width (lineWidth);
|
||||
cr->set_line_cap(Cairo::LINE_CAP_ROUND);
|
||||
|
||||
rtengine::Coord begin_ = begin;
|
||||
rtengine::Coord end_ = end;
|
||||
@@ -232,10 +236,11 @@ void Line::drawInnerGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuffer *
|
||||
color = innerLineColor;
|
||||
}
|
||||
|
||||
cr->set_source_rgb (color.getR(), color.getG(), color.getB());
|
||||
cr->set_source_rgba (color.getR(), color.getG(), color.getB(), INNERGEOM_OPACITY);
|
||||
}
|
||||
|
||||
cr->set_line_width(innerLineWidth);
|
||||
cr->set_line_cap(flags & F_DASHED ? Cairo::LINE_CAP_BUTT : Cairo::LINE_CAP_ROUND);
|
||||
|
||||
rtengine::Coord begin_ = begin;
|
||||
rtengine::Coord end_ = end;
|
||||
@@ -251,21 +256,16 @@ void Line::drawInnerGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuffer *
|
||||
end_ += objectBuffer->getDataProvider()->posScreen + objectBuffer->getDataProvider()->deltaScreen;
|
||||
}
|
||||
|
||||
if (flags & F_DASHED) {
|
||||
cr->set_dash(dash, 0.);
|
||||
}
|
||||
|
||||
cr->move_to(begin_.x + 0.5, begin_.y + 0.5);
|
||||
cr->line_to(end_.x + 0.5, end_.y + 0.5);
|
||||
cr->stroke();
|
||||
|
||||
if (state == INSENSITIVE) {
|
||||
std::valarray<double> 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();
|
||||
if (flags & F_DASHED) {
|
||||
cr->unset_dash();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -274,6 +274,7 @@ void Line::drawToMOChannel(Cairo::RefPtr<Cairo::Context> &cr, unsigned short id,
|
||||
{
|
||||
if (flags & F_HOVERABLE) {
|
||||
cr->set_line_width( getMouseOverLineWidth() );
|
||||
cr->set_line_cap(Cairo::LINE_CAP_ROUND);
|
||||
rtengine::Coord begin_ = begin;
|
||||
rtengine::Coord end_ = end;
|
||||
|
||||
@@ -302,7 +303,8 @@ void Line::drawToMOChannel(Cairo::RefPtr<Cairo::Context> &cr, unsigned short id,
|
||||
|
||||
void Polyline::drawOuterGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem)
|
||||
{
|
||||
if ((flags & F_VISIBLE) && state != INSENSITIVE && points.size() > 1) {
|
||||
double lineWidth = getOuterLineWidth();
|
||||
if ((flags & F_VISIBLE) && state != INSENSITIVE && points.size() > 1 && lineWidth > 0.) {
|
||||
RGBColor color;
|
||||
|
||||
if (flags & F_AUTO_COLOR) {
|
||||
@@ -311,8 +313,10 @@ void Polyline::drawOuterGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuff
|
||||
color = outerLineColor;
|
||||
}
|
||||
|
||||
cr->set_source_rgb (color.getR(), color.getG(), color.getB());
|
||||
cr->set_line_width( getOuterLineWidth() );
|
||||
cr->set_source_rgba (color.getR(), color.getG(), color.getB(), OUTERGEOM_OPACITY * rtengine::min(innerLineWidth / 2.f, 1.f));
|
||||
cr->set_line_width (lineWidth);
|
||||
cr->set_line_cap(Cairo::LINE_CAP_ROUND);
|
||||
cr->set_line_join(Cairo::LINE_JOIN_ROUND);
|
||||
|
||||
rtengine::Coord currPos;
|
||||
|
||||
@@ -355,10 +359,16 @@ void Polyline::drawInnerGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuff
|
||||
color = innerLineColor;
|
||||
}
|
||||
|
||||
cr->set_source_rgb (color.getR(), color.getG(), color.getB());
|
||||
cr->set_source_rgba (color.getR(), color.getG(), color.getB(), INNERGEOM_OPACITY);
|
||||
}
|
||||
|
||||
cr->set_line_width( innerLineWidth );
|
||||
cr->set_line_width(innerLineWidth);
|
||||
cr->set_line_cap(flags & F_DASHED ? Cairo::LINE_CAP_BUTT : Cairo::LINE_CAP_ROUND);
|
||||
cr->set_line_join(Cairo::LINE_JOIN_ROUND);
|
||||
|
||||
if (flags & F_DASHED) {
|
||||
cr->set_dash(dash, 0.);
|
||||
}
|
||||
|
||||
if (filled && state != INSENSITIVE) {
|
||||
rtengine::Coord currPos;
|
||||
@@ -407,20 +417,11 @@ void Polyline::drawInnerGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuff
|
||||
cr->line_to(currPos.x + 0.5, currPos.y + 0.5);
|
||||
}
|
||||
}
|
||||
cr->stroke();
|
||||
}
|
||||
|
||||
if (state == INSENSITIVE) {
|
||||
std::valarray<double> 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();
|
||||
}
|
||||
if (flags & F_DASHED) {
|
||||
cr->unset_dash();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -437,8 +438,11 @@ void Polyline::drawToMOChannel (Cairo::RefPtr<Cairo::Context> &cr, unsigned shor
|
||||
cr->set_source_rgba (0., 0., 0., (id + 1) / 65535.);
|
||||
}
|
||||
|
||||
cr->set_line_width( getMouseOverLineWidth() );
|
||||
cr->set_line_cap(Cairo::LINE_CAP_ROUND);
|
||||
cr->set_line_join(Cairo::LINE_JOIN_ROUND);
|
||||
|
||||
for (unsigned int i = 0; i < points.size(); ++i) {
|
||||
cr->set_line_width( getMouseOverLineWidth() );
|
||||
currPos = points.at(i);
|
||||
|
||||
if (datum == IMAGE) {
|
||||
@@ -495,7 +499,8 @@ void Rectangle::setXYXY(rtengine::Coord topLeft, rtengine::Coord bottomRight)
|
||||
|
||||
void Rectangle::drawOuterGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuffer *objectBuffer, EditCoordSystem &coordSystem)
|
||||
{
|
||||
if ((flags & F_VISIBLE) && state != INSENSITIVE) {
|
||||
double lineWidth = getOuterLineWidth();
|
||||
if ((flags & F_VISIBLE) && state != INSENSITIVE && lineWidth > 0. && innerLineWidth > 0.) {
|
||||
RGBColor color;
|
||||
|
||||
if (flags & F_AUTO_COLOR) {
|
||||
@@ -504,8 +509,9 @@ void Rectangle::drawOuterGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuf
|
||||
color = outerLineColor;
|
||||
}
|
||||
|
||||
cr->set_source_rgb (color.getR(), color.getG(), color.getB());
|
||||
cr->set_line_width( getOuterLineWidth() );
|
||||
cr->set_source_rgba (color.getR(), color.getG(), color.getB(), OUTERGEOM_OPACITY * rtengine::min(innerLineWidth / 2.f, 1.f));
|
||||
cr->set_line_width (lineWidth);
|
||||
cr->set_line_join(Cairo::LINE_JOIN_BEVEL);
|
||||
|
||||
rtengine::Coord tl, br;
|
||||
|
||||
@@ -548,10 +554,11 @@ void Rectangle::drawInnerGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuf
|
||||
color = innerLineColor;
|
||||
}
|
||||
|
||||
cr->set_source_rgb (color.getR(), color.getG(), color.getB());
|
||||
cr->set_source_rgba (color.getR(), color.getG(), color.getB(), INNERGEOM_OPACITY);
|
||||
}
|
||||
|
||||
cr->set_line_width( innerLineWidth );
|
||||
cr->set_line_width(innerLineWidth);
|
||||
cr->set_line_join(Cairo::LINE_JOIN_BEVEL);
|
||||
|
||||
rtengine::Coord tl, br;
|
||||
|
||||
@@ -571,7 +578,11 @@ void Rectangle::drawInnerGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuf
|
||||
br = bottomRight + objectBuffer->getDataProvider()->posScreen + objectBuffer->getDataProvider()->deltaScreen;
|
||||
}
|
||||
|
||||
if (filled && state != INSENSITIVE) {
|
||||
if (flags & F_DASHED) {
|
||||
cr->set_dash(dash, 0.);
|
||||
}
|
||||
|
||||
if (filled) {
|
||||
cr->rectangle(tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y);
|
||||
|
||||
if (innerLineWidth > 0.) {
|
||||
@@ -582,20 +593,11 @@ void Rectangle::drawInnerGeometry(Cairo::RefPtr<Cairo::Context> &cr, ObjectMOBuf
|
||||
}
|
||||
} else if (innerLineWidth > 0.) {
|
||||
cr->rectangle(tl.x + 0.5, tl.y + 0.5, br.x - tl.x, br.y - tl.y);
|
||||
cr->stroke();
|
||||
}
|
||||
|
||||
if (state == INSENSITIVE) {
|
||||
std::valarray<double> 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();
|
||||
}
|
||||
if (flags & F_DASHED) {
|
||||
cr->unset_dash();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -604,6 +606,7 @@ void Rectangle::drawToMOChannel(Cairo::RefPtr<Cairo::Context> &cr, unsigned shor
|
||||
{
|
||||
if (flags & F_HOVERABLE) {
|
||||
cr->set_line_width( getMouseOverLineWidth() );
|
||||
cr->set_line_join(Cairo::LINE_JOIN_ROUND);
|
||||
|
||||
rtengine::Coord tl, br;
|
||||
|
||||
|
Reference in New Issue
Block a user