Add some new features to the On Preview Objects mechanism
This commit is contained in:
@@ -11,7 +11,7 @@ set (RTENGINESOURCEFILES safegtk.cc colortemp.cc curves.cc flatcurves.cc diagona
|
||||
dfmanager.cc ffmanager.cc rawimage.cc image8.cc image16.cc imagefloat.cc imagedata.cc imageio.cc improcfun.cc init.cc dcrop.cc
|
||||
loadinitial.cc procparams.cc rawimagesource.cc demosaic_algos.cc shmap.cc simpleprocess.cc refreshmap.cc
|
||||
fast_demo.cc amaze_demosaic_RT.cc CA_correct_RT.cc cfa_linedn_RT.cc green_equil_RT.cc hilite_recon.cc expo_before_b.cc
|
||||
stdimagesource.cc myfile.cc iccjpeg.cc hlmultipliers.cc improccoordinator.cc editbuffer.cc
|
||||
stdimagesource.cc myfile.cc iccjpeg.cc hlmultipliers.cc improccoordinator.cc editbuffer.cc coord.cc
|
||||
processingjob.cc rtthumbnail.cc utils.cc labimage.cc slicer.cc cieimage.cc
|
||||
iplab2rgb.cc ipsharpen.cc iptransform.cc ipresize.cc ipvibrance.cc
|
||||
imagedimensions.cc jpeg_memsrc.cc jdatasrc.cc iimage.cc
|
||||
|
39
rtengine/coord.cc
Normal file
39
rtengine/coord.cc
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of RawTherapee.
|
||||
*
|
||||
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
|
||||
*
|
||||
* RawTherapee is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* RawTherapee is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "coord.h"
|
||||
|
||||
namespace rtengine
|
||||
{
|
||||
|
||||
void Coord::setFromPolar(PolarCoord polar)
|
||||
{
|
||||
while (polar.angle < 0.f) {
|
||||
polar.angle += 360.f;
|
||||
}
|
||||
|
||||
while (polar.angle > 360.f) {
|
||||
polar.angle -= 360.f;
|
||||
}
|
||||
|
||||
x = polar.radius * cos(polar.angle / 180.f * M_PI);
|
||||
y = polar.radius * sin(polar.angle / 180.f * M_PI);
|
||||
}
|
||||
|
||||
}
|
221
rtengine/coord.h
Normal file
221
rtengine/coord.h
Normal file
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* This file is part of RawTherapee.
|
||||
*
|
||||
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
|
||||
*
|
||||
* RawTherapee is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* RawTherapee is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __COORD__
|
||||
#define __COORD__
|
||||
|
||||
#include "rt_math.h"
|
||||
|
||||
namespace rtengine
|
||||
{
|
||||
|
||||
class PolarCoord;
|
||||
|
||||
// Do not confuse with rtengine::Coord2D, this one is for the GUI
|
||||
class Coord
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
|
||||
Coord() : x(-1), y(-1) {}
|
||||
Coord(int x, int y) : x(x), y(y) {}
|
||||
|
||||
void set (int x, int y)
|
||||
{
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
}
|
||||
|
||||
void setFromPolar(PolarCoord polar);
|
||||
|
||||
/// @brief Clip the coord to stay in the width x height bounds
|
||||
/// @return true if the x or y coordinate has changed
|
||||
bool clip(int width, int height)
|
||||
{
|
||||
int trimmedX = rtengine::LIM<int>(x, 0, width);
|
||||
int trimmedY = rtengine::LIM<int>(y, 0, height);
|
||||
bool retval = trimmedX != x || trimmedY != y;
|
||||
x = trimmedX;
|
||||
y = trimmedY;
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool operator== (const Coord& other) const
|
||||
{
|
||||
return other.x == x && other.y == y;
|
||||
}
|
||||
|
||||
bool operator!= (const Coord& other) const
|
||||
{
|
||||
return other.x != x || other.y != y;
|
||||
}
|
||||
|
||||
void operator+=(const Coord & rhs)
|
||||
{
|
||||
x += rhs.x;
|
||||
y += rhs.y;
|
||||
}
|
||||
void operator-=(const Coord & rhs)
|
||||
{
|
||||
x -= rhs.x;
|
||||
y -= rhs.y;
|
||||
}
|
||||
void operator*=(double scale)
|
||||
{
|
||||
x *= scale;
|
||||
y *= scale;
|
||||
}
|
||||
Coord operator+(Coord & rhs)
|
||||
{
|
||||
Coord result(x + rhs.x, y + rhs.y);
|
||||
return result;
|
||||
}
|
||||
Coord operator-(Coord & rhs)
|
||||
{
|
||||
Coord result(x - rhs.x, y - rhs.y);
|
||||
return result;
|
||||
}
|
||||
Coord operator*(double scale)
|
||||
{
|
||||
Coord result(x * scale, y * scale);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
class PolarCoord
|
||||
{
|
||||
public:
|
||||
double radius;
|
||||
double angle; // degree
|
||||
|
||||
PolarCoord() : radius(1.), angle(0.) {}
|
||||
PolarCoord(double radius, double angle) : radius(radius), angle(angle) {}
|
||||
PolarCoord(Coord start, Coord end) : radius(1.), angle(0.)
|
||||
{
|
||||
setFromCartesian(start, end);
|
||||
}
|
||||
PolarCoord(Coord delta) : radius(1.), angle(0.)
|
||||
{
|
||||
setFromCartesian(delta);
|
||||
}
|
||||
|
||||
void set (double radius, double angle)
|
||||
{
|
||||
this->radius = radius;
|
||||
this->angle = angle;
|
||||
}
|
||||
|
||||
void setFromCartesian(Coord start, Coord end)
|
||||
{
|
||||
Coord delta(end.x - start.x, end.y - start.y);
|
||||
setFromCartesian(delta);
|
||||
}
|
||||
|
||||
void setFromCartesian(Coord delta)
|
||||
{
|
||||
if (!delta.x && !delta.y) {
|
||||
// null vector, we set to a default value
|
||||
radius = 1.;
|
||||
angle = 0.;
|
||||
return;
|
||||
}
|
||||
|
||||
double x_ = double(delta.x);
|
||||
double y_ = double(delta.y);
|
||||
radius = sqrt(x_ * x_ + y_ * y_);
|
||||
|
||||
if (delta.x > 0.) {
|
||||
if (delta.y >= 0.) {
|
||||
angle = atan(y_ / x_) / (2 * M_PI) * 360.;
|
||||
} else if (delta.y < 0.) {
|
||||
angle = (atan(y_ / x_) + 2 * M_PI) / (2 * M_PI) * 360.;
|
||||
}
|
||||
} else if (delta.x < 0.) {
|
||||
angle = (atan(y_ / x_) + M_PI) / (2 * M_PI) * 360.;
|
||||
} else if (delta.x == 0.) {
|
||||
if (delta.y > 0.) {
|
||||
angle = 90.;
|
||||
} else {
|
||||
angle = 270.;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool operator== (const PolarCoord& other) const
|
||||
{
|
||||
return other.radius == radius && other.angle == angle;
|
||||
}
|
||||
|
||||
bool operator!= (const PolarCoord& other) const
|
||||
{
|
||||
return other.radius != radius || other.angle != angle;
|
||||
}
|
||||
|
||||
void operator+=(const PolarCoord & rhs)
|
||||
{
|
||||
Coord thisCoord, rhsCoord;
|
||||
thisCoord.setFromPolar(*this);
|
||||
rhsCoord.setFromPolar(rhs);
|
||||
thisCoord += rhsCoord;
|
||||
setFromCartesian(thisCoord);
|
||||
}
|
||||
void operator-=(const PolarCoord & rhs)
|
||||
{
|
||||
Coord thisCoord, rhsCoord;
|
||||
thisCoord.setFromPolar(*this);
|
||||
rhsCoord.setFromPolar(rhs);
|
||||
thisCoord -= rhsCoord;
|
||||
setFromCartesian(thisCoord);
|
||||
}
|
||||
void operator*=(double scale)
|
||||
{
|
||||
radius *= scale;
|
||||
}
|
||||
PolarCoord operator+(PolarCoord & rhs)
|
||||
{
|
||||
Coord thisCoord, rhsCoord;
|
||||
thisCoord.setFromPolar(*this);
|
||||
rhsCoord.setFromPolar(rhs);
|
||||
thisCoord += rhsCoord;
|
||||
PolarCoord result;
|
||||
result.setFromCartesian(thisCoord);
|
||||
return result;
|
||||
}
|
||||
PolarCoord operator-(PolarCoord & rhs)
|
||||
{
|
||||
Coord thisCoord, rhsCoord;
|
||||
thisCoord.setFromPolar(*this);
|
||||
rhsCoord.setFromPolar(rhs);
|
||||
thisCoord -= rhsCoord;
|
||||
PolarCoord result;
|
||||
result.setFromCartesian(thisCoord);
|
||||
return result;
|
||||
}
|
||||
Coord operator*(double scale)
|
||||
{
|
||||
Coord result(radius * scale, angle);
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@@ -22,6 +22,7 @@
|
||||
#include "../rtgui/edit.h"
|
||||
#include "array2D.h"
|
||||
#include "iimage.h"
|
||||
#include "coord.h"
|
||||
|
||||
namespace rtengine
|
||||
{
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
#include "LUT.h"
|
||||
#include "coord.h"
|
||||
|
||||
class ParamsEdited;
|
||||
|
||||
@@ -1221,7 +1222,7 @@ public:
|
||||
ResizeParams resize; ///< Resize parameters
|
||||
ColorManagementParams icm; ///< profiles/color spaces used during the image processing
|
||||
RAWParams raw; ///< RAW parameters before demosaicing
|
||||
WaveletParams wavelet; ///< wavelet wavelet parameters
|
||||
WaveletParams wavelet; ///< Wavelet parameters
|
||||
DirPyrEqualizerParams dirpyrequalizer; ///< directional pyramid wavelet parameters
|
||||
HSVEqualizerParams hsvequalizer; ///< hsv wavelet parameters
|
||||
FilmSimulationParams filmSimulation; ///< film simulation parameters
|
||||
|
Reference in New Issue
Block a user