Merge pull request #4857 from Beep6581/abstract-listeners

Turn Listeners into abstract interfaces
This commit is contained in:
Beep6581
2018-10-17 14:22:11 +02:00
committed by GitHub
159 changed files with 1385 additions and 939 deletions

View File

@@ -89,8 +89,7 @@ using LUTd = LUT<double>;
using LUTuc = LUT<uint8_t>;
template<typename T>
class LUT :
public rtengine::NonCopyable
class LUT
{
protected:
// list of variables ordered to improve cache speed
@@ -198,6 +197,8 @@ public:
}
}
explicit LUT(const LUT&) = delete;
void setClip(int flags)
{
clip = flags;
@@ -225,7 +226,7 @@ public:
return size > 0 ? upperBound : 0;
}
LUT<T> & operator=(LUT<T> &rhs)
LUT<T> & operator=(const LUT<T>& rhs)
{
if (this != &rhs) {
if (rhs.size > this->size) {
@@ -257,7 +258,7 @@ public:
// handy to sum up per thread histograms. #pragma omp simd speeds up the loop by about factor 3 for LUTu (uint32_t).
template<typename U = T, typename = typename std::enable_if<std::is_same<U, std::uint32_t>::value>::type>
LUT<T> & operator+=(LUT<T> &rhs)
LUT<T> & operator+=(const LUT<T>& rhs)
{
if (rhs.size == this->size) {
#ifdef _OPENMP

View File

@@ -139,10 +139,10 @@ void Crop::update(int todo)
// give possibility to the listener to modify crop window (as the full image dimensions are already known at this point)
int wx, wy, ww, wh, ws;
bool overrideWindow = false;
const bool overrideWindow = cropImageListener;
if (cropImageListener) {
overrideWindow = cropImageListener->getWindow(wx, wy, ww, wh, ws);
if (overrideWindow) {
cropImageListener->getWindow(wx, wy, ww, wh, ws);
}
// re-allocate sub-images and arrays if their dimensions changed

View File

@@ -21,11 +21,11 @@
//#include <giomm.h>
#include <helpers.h>
class PListener : public rtengine::ProgressListener
class PListener :
public rtengine::ProgressListener
{
public:
void setProgressStr (Glib::ustring str)
void setProgressStr(const Glib::ustring& str)
{
std::cout << str << std::endl;
}
@@ -33,11 +33,16 @@ public:
{
std::cout << p << std::endl;
}
void setProgressState(bool inProcessing)
{
}
void error(const Glib::ustring& descr)
{
}
};
int main (int argc, char* argv[])
{
if (argc < 4) {
std::cout << "Usage: rtcmd <infile> <paramfile> <outfile>" << std::endl;
exit(1);

View File

@@ -39,14 +39,14 @@ class ProfileStoreListener
{
public:
virtual ~ProfileStoreListener() {}
virtual ~ProfileStoreListener() = default;
/** @brief Called whenever the current value has to be stored before update. */
virtual void storeCurrentValue() {}
virtual void storeCurrentValue() = 0;
/** @brief Called whenever the file list has been updated and the content of the listener has to be updated. */
virtual void updateProfileList() = 0;
/** @brief Called whenever the profile list has changed and the old value have to be restored (if possible). */
virtual void restoreValue() {}
virtual void restoreValue() = 0;
};
/// @brief ProfileStoreEntry type (folder or file)

View File

@@ -154,21 +154,20 @@ public:
/** This listener interface is used to indicate the progress of time consuming operations */
class ProgressListener
{
public:
virtual ~ProgressListener() {}
virtual ~ProgressListener() = default;
/** This member function is called when the percentage of the progress has been changed.
* @param p is a number between 0 and 1 */
virtual void setProgress (double p) {}
virtual void setProgress(double p) = 0;
/** This member function is called when a textual information corresponding to the progress has been changed.
* @param str is the textual information corresponding to the progress */
virtual void setProgressStr (Glib::ustring str) {}
virtual void setProgressStr(const Glib::ustring& str) = 0;
/** This member function is called when the state of the processing has been changed.
* @param inProcessing =true if the processing has been started, =false if it has been stopped */
virtual void setProgressState (bool inProcessing) {}
virtual void setProgressState(bool inProcessing) = 0;
/** This member function is called when an error occurs during the operation.
* @param descr is the error message */
virtual void error (Glib::ustring descr) {}
virtual void error(const Glib::ustring& descr) = 0;
};
class ImageSource;
@@ -219,20 +218,20 @@ public:
class PreviewImageListener
{
public:
virtual ~PreviewImageListener() {}
virtual ~PreviewImageListener() = default;
/** With this member function the staged processor notifies the listener that it allocated a new
* image to store the end result of the processing. It can be used in a shared manner.
* @param img is a pointer to the image
* @param scale describes the current scaling applied compared to the 100% size (preview scale)
* @param cp holds the coordinates of the current crop rectangle */
virtual void setImage (IImage8* img, double scale, procparams::CropParams cp) {}
virtual void setImage(IImage8* img, double scale, const procparams::CropParams& cp) = 0;
/** With this member function the staged processor notifies the listener that the image passed as parameter
* will be deleted, and no longer used to store the preview image.
* @param img the pointer to the image to be destroyed. The listener has to free the image! */
virtual void delImage (IImage8* img) {}
virtual void delImage(IImage8* img) = 0;
/** With this member function the staged processor notifies the listener that the preview image has been updated.
* @param cp holds the coordinates of the current crop rectangle */
virtual void imageReady (procparams::CropParams cp) {}
virtual void imageReady(const procparams::CropParams& cp) = 0;
};
/** When the detailed crop image is ready for display during staged processing (thus the changes have been updated),
@@ -242,52 +241,70 @@ public:
class DetailedCropListener
{
public:
virtual ~DetailedCropListener() {}
virtual ~DetailedCropListener() = default;
/** With this member function the staged processor notifies the listener that the detailed crop image has been updated.
* @param img is a pointer to the detailed crop image */
virtual void setDetailedCrop (IImage8* img, IImage8* imgtrue, procparams::ColorManagementParams cmp,
procparams::CropParams cp, int cx, int cy, int cw, int ch, int skip) {}
virtual bool getWindow (int& cx, int& cy, int& cw, int& ch, int& skip)
{
return false;
}
// virtual void setPosition (int x, int y, bool update=true) {}
virtual void setDetailedCrop(
IImage8* img,
IImage8* imgtrue,
const procparams::ColorManagementParams& cmp,
const procparams::CropParams& cp,
int cx,
int cy,
int cw,
int ch,
int skip
) = 0;
virtual void getWindow(int& cx, int& cy, int& cw, int& ch, int& skip) = 0;
};
/** This listener is used when the full size of the final image has been changed (e.g. rotated by 90 deg.) */
class SizeListener
{
public:
virtual ~SizeListener() {}
virtual ~SizeListener() = default;
/** This member function is called when the size of the final image has been changed
* @param w is the width of the final image (without cropping)
* @param h is the height of the final image (without cropping)
* @param ow is the width of the final image (without resizing and cropping)
* @param oh is the height of the final image (without resizing and cropping) */
virtual void sizeChanged (int w, int h, int ow, int oh) {}
virtual void sizeChanged(int w, int h, int ow, int oh) = 0;
};
/** This listener is used when the histogram of the final image has changed. */
class HistogramListener
{
public:
virtual ~HistogramListener() {}
virtual ~HistogramListener() = default;
/** This member function is called when the histogram of the final image has changed.
* @param histRed is the array of size 256 containing the histogram of the red channel
* @param histGreen is the array of size 256 containing the histogram of the green channel
* @param histBlue is the array of size 256 containing the histogram of the blue channel
* @param histLuma is the array of size 256 containing the histogram of the luminance channel
* other for curves backgrounds, histRAW is RAW without colors */
virtual void histogramChanged (LUTu & histRed, LUTu & histGreen, LUTu & histBlue, LUTu & histLuma, LUTu & histToneCurve, LUTu & histLCurve, LUTu & histCCurve,/* LUTu & histCLurve,LUTu & histLLCurve, */LUTu & histLCAM, LUTu & histCCAM,
LUTu & histRedRaw, LUTu & histGreenRaw, LUTu & histBlueRaw, LUTu & histChroma, LUTu & histLRETI) {}
virtual void histogramChanged(
const LUTu& histRed,
const LUTu& histGreen,
const LUTu& histBlue,
const LUTu& histLuma,
const LUTu& histToneCurve,
const LUTu& histLCurve,
const LUTu& histCCurve,
const LUTu& histLCAM,
const LUTu& histCCAM,
const LUTu& histRedRaw,
const LUTu& histGreenRaw,
const LUTu& histBlueRaw,
const LUTu& histChroma,
const LUTu& histLRETI
) = 0;
};
/** This listener is used when the auto exposure has been recomputed (e.g. when the clipping ratio changed). */
class AutoExpListener
{
public:
virtual ~AutoExpListener() {}
virtual ~AutoExpListener() = default;
/** This member function is called when the auto exposure has been recomputed.
* @param brightness is the new brightness value (in logarithmic scale)
* @param bright is the new ...
@@ -296,84 +313,79 @@ public:
* @param hlcompr is the new highlight recovery amount
* @param hlcomprthresh is the new threshold for hlcompr
* @param hlrecons set to true if HighLight Reconstruction is enabled */
virtual void autoExpChanged (double brightness, int bright, int contrast, int black, int hlcompr, int hlcomprthresh, bool hlrecons) {}
virtual void autoExpChanged(double brightness, int bright, int contrast, int black, int hlcompr, int hlcomprthresh, bool hlrecons) = 0;
virtual void autoMatchedToneCurveChanged(procparams::ToneCurveParams::TcMode curveMode, const std::vector<double> &curve) {}
virtual void autoMatchedToneCurveChanged(procparams::ToneCurveParams::TcMode curveMode, const std::vector<double>& curve) = 0;
};
class AutoCamListener
{
public :
virtual ~AutoCamListener() {}
virtual void autoCamChanged (double ccam, double ccamout) {}
virtual void adapCamChanged (double cadap) {}
virtual void ybCamChanged (int yb) {}
virtual ~AutoCamListener() = default;
virtual void autoCamChanged(double ccam, double ccamout) = 0;
virtual void adapCamChanged(double cadap) = 0;
virtual void ybCamChanged(int yb) = 0;
};
class AutoChromaListener
{
public :
virtual ~AutoChromaListener() {}
virtual void chromaChanged (double autchroma, double autred, double autblue) {}
virtual void noiseChanged (double nresid, double highresid) {}
virtual void noiseTilePrev (int tileX, int tileY, int prevX, int prevY, int sizeT, int sizeP) {}
virtual ~AutoChromaListener() = default;
virtual void chromaChanged(double autchroma, double autred, double autblue) = 0;
virtual void noiseChanged(double nresid, double highresid) = 0;
virtual void noiseTilePrev(int tileX, int tileY, int prevX, int prevY, int sizeT, int sizeP) = 0;
};
class RetinexListener
{
public :
virtual ~RetinexListener() {}
virtual void minmaxChanged (double cdma, double cdmin, double mini, double maxi, double Tmean, double Tsigma, double Tmin, double Tmax) {}
public:
virtual ~RetinexListener() = default;
virtual void minmaxChanged(double cdma, double cdmin, double mini, double maxi, double Tmean, double Tsigma, double Tmin, double Tmax) = 0;
};
class AutoColorTonListener
{
public :
virtual ~AutoColorTonListener() {}
virtual void autoColorTonChanged (int bwct, int satthres, int satprot) {}
public:
virtual ~AutoColorTonListener() = default;
virtual void autoColorTonChanged(int bwct, int satthres, int satprot) = 0;
};
class AutoBWListener
{
public :
virtual ~AutoBWListener() {}
virtual void BWChanged (double redbw, double greenbw, double bluebw) {}
public:
virtual ~AutoBWListener() = default;
virtual void BWChanged(double redbw, double greenbw, double bluebw) = 0;
};
class AutoWBListener
{
public :
public:
virtual ~AutoWBListener() = default;
virtual void WBChanged (double temp, double green) = 0;
virtual void WBChanged(double temp, double green) = 0;
};
class FrameCountListener
{
public :
public:
virtual ~FrameCountListener() = default;
virtual void FrameCountChanged (int n, int frameNum) = 0;
virtual void FrameCountChanged(int n, int frameNum) = 0;
};
class ImageTypeListener
{
public :
public:
virtual ~ImageTypeListener() = default;
virtual void imageTypeChanged (bool isRaw, bool isBayer, bool isXtrans, bool is_Mono = false) = 0;
virtual void imageTypeChanged(bool isRaw, bool isBayer, bool isXtrans, bool is_Mono = false) = 0;
};
class WaveletListener
{
public :
virtual ~WaveletListener() {}
virtual void wavChanged (double nlevel) {}
public:
virtual ~WaveletListener() = default;
virtual void wavChanged(double nlevel) = 0;
};
/** This class represents a detailed part of the image (looking through a kind of window).
* It can be created and destroyed with the appropriate members of StagedImageProcessor.
* Several crops can be assigned to the same image. */
@@ -554,8 +566,7 @@ public:
* there is no jobs left.
* @param img is the result of the last ProcessingJob
* @return the next ProcessingJob to process */
virtual ProcessingJob* imageReady (IImagefloat* img) = 0;
virtual void error (Glib::ustring message) = 0;
virtual ProcessingJob* imageReady(IImagefloat* img) = 0;
};
/** This function performs all the image processing steps corresponding to the given ProcessingJob. It runs in the background, thus it returns immediately,
* When it finishes, it calls the BatchProcessingListener with the resulting image and asks for the next job. It the listener gives a new job, it goes on

View File

@@ -21,23 +21,28 @@
//#include <giomm.h>
#include <helpers.h>
class PListener : public rtengine::ProgressListener
class PListener :
public rtengine::ProgressListener
{
public:
void setProgressStr (Glib::ustring str)
void setProgressStr(const Glib::ustring& str)
{
std::cout << str << std::endl;
}
void setProgress (double p)
void setProgress(double p)
{
std::cout << p << std::endl;
}
void setProgressState(bool inProcessing)
{
}
void error(const Glib::ustring& descr)
{
}
};
int main (int argc, char* argv[])
{
if (argc < 4) {
std::cout << "Usage: rtcmd <infile> <paramfile> <outfile>" << std::endl;
exit(1);