"Fossies" - the Fresh Open Source Software Archive

Member "rawtherapee-5.7/rtgui/crophandler.h" (10 Sep 2019, 5383 Bytes) of package /linux/misc/rawtherapee-5.7.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "crophandler.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 5.6_vs_5.7.

    1 /*
    2  *  This file is part of RawTherapee.
    3  *
    4  *  Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
    5  *
    6  *  RawTherapee is free software: you can redistribute it and/or modify
    7  *  it under the terms of the GNU General Public License as published by
    8  *  the Free Software Foundation, either version 3 of the License, or
    9  *  (at your option) any later version.
   10  *
   11  *  RawTherapee is distributed in the hope that it will be useful,
   12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  *  GNU General Public License for more details.
   15  *
   16  *  You should have received a copy of the GNU General Public License
   17  *  along with RawTherapee.  If not, see <https://www.gnu.org/licenses/>.
   18  */
   19 #ifndef __CROPHANDLER__
   20 #define __CROPHANDLER__
   21 
   22 #include <atomic>
   23 #include <vector>
   24 #include <memory>
   25 
   26 #include <gtkmm.h>
   27 
   28 #include "../rtengine/rtengine.h"
   29 #include "editbuffer.h"
   30 
   31 #include "lockablecolorpicker.h"
   32 #include "threadutils.h"
   33 
   34 class EditSubscriber;
   35 
   36 class CropDisplayHandler
   37 {
   38 
   39 public:
   40     virtual ~CropDisplayHandler() {}
   41     virtual void cropImageUpdated    () {}
   42     virtual void cropWindowChanged   () {}
   43     virtual void initialImageArrived () {}
   44     virtual void setDisplayPosition  (int x, int y) {}
   45 };
   46 
   47 /**
   48  *  This class handle the displayed part of the image, ask for the initial data and process it so it can display it.
   49  *  Its position on the preview is handled not set by this class but by the CropHandlerListener (i.e. CropWindow) with which it works closely.
   50  */
   51 class CropHandler final :
   52     public rtengine::DetailedCropListener,
   53     public rtengine::SizeListener
   54 {
   55 public:
   56     CropHandler ();
   57     ~CropHandler () override;
   58 
   59     void    setDisplayHandler (CropDisplayHandler* l)
   60     {
   61         displayHandler = l;
   62     }
   63     void    setEditSubscriber      (EditSubscriber* newSubscriber);
   64 
   65     void    newImage      (rtengine::StagedImageProcessor* ipc_, bool isDetailWindow);
   66     void    setZoom       (int z, int centerx = -1, int centery = -1);
   67     float   getZoomFactor ();
   68     double  getFitZoom    ();
   69     double  getFitCropZoom();
   70     bool    isFullDisplay ();
   71     void    setWSize      (int w, int h);
   72     void    getWSize      (int& w, int &h);
   73     void    getAnchorPosition (int& x, int& y);
   74     void    setAnchorPosition (int x, int y, bool update = true);
   75     void    moveAnchor    (int deltaX, int deltaY, bool update = true);
   76     void    centerAnchor  (bool update = true);
   77     void    getPosition   (int& x, int& y);
   78     void    getSize       (int& w, int& h);
   79     void    getFullImageSize (int& w, int& h);
   80 
   81     void    setEnabled (bool e);
   82     bool    getEnabled ();
   83 
   84     void    colorPick (const rtengine::Coord &pickerPos, float &r, float &g, float &b, float &rpreview, float &gpreview, float &bpreview, LockableColorPicker::Size size);
   85 
   86     rtengine::DetailedCrop* getCrop()
   87     {
   88         return crop;
   89     }
   90 
   91     // DetailedCropListener interface
   92     void setDetailedCrop(
   93         rtengine::IImage8* im,
   94         rtengine::IImage8* imworking,
   95         const rtengine::procparams::ColorManagementParams& cmp,
   96         const rtengine::procparams::CropParams& cp,
   97         int cx,
   98         int cy,
   99         int cw,
  100         int ch,
  101         int skip
  102     ) override;
  103     void getWindow(int& cwx, int& cwy, int& cww, int& cwh, int& cskip) override;
  104 
  105     // SizeListener interface
  106     void    sizeChanged  (int w, int h, int ow, int oh) override;
  107 
  108     void    update  ();
  109 
  110 
  111     const std::unique_ptr<rtengine::procparams::CropParams> cropParams;
  112     const std::unique_ptr<rtengine::procparams::ColorManagementParams> colorParams;
  113     Glib::RefPtr<Gdk::Pixbuf> cropPixbuf;     // image displayed on monitor, using the monitor profile (i.e. lab to monitor profile)
  114     Glib::RefPtr<Gdk::Pixbuf> cropPixbuftrue; // internal image in output color space for analysis (i.e. lab to either Working profile or Output profile, depending on options.rtSettings.HistogramWorking)
  115 
  116     MyMutex cimg;
  117 
  118 private:
  119     void    compDim ();
  120 
  121     int zoom;               // scale factor (e.g. 5 if 1:5 scale) ; if 1:1 scale and bigger, factor is multiplied by 1000  (i.e. 1000 for 1:1 scale, 2000 for 2:1, etc...)
  122     int ww, wh;             // size of the crop's canvas on the screen ; might be bigger than the displayed image, but not smaller
  123     int cax, cay;           // clamped crop anchor's coordinate, i.e. point of the image that coincide to the center of the display area, expressed in image coordinates; cannot be outside the image's bounds; but if cax==cay==-1, designate the center of the image
  124     int cx, cy, cw, ch;     // position and size of the requested crop ; position expressed in image coordinates, so cx and cy might be negative and cw and ch higher than the image's 1:1 size
  125     int cropX, cropY, cropW, cropH; // cropPixbuf's displayed area (position and size), i.e. coordinates in 1:1 scale, i.e. cx, cy, cw & ch trimmed to the image's bounds
  126     bool enabled;
  127     std::vector<unsigned char> cropimg;
  128     std::vector<unsigned char> cropimgtrue;
  129     int cropimg_width, cropimg_height, cix, ciy, ciw, cih, cis;
  130     bool isLowUpdatePriority;
  131 
  132     rtengine::StagedImageProcessor* ipc;
  133     rtengine::DetailedCrop* crop;
  134 
  135     CropDisplayHandler* displayHandler;
  136 
  137     std::atomic<bool> redraw_needed;
  138     std::atomic<bool> initial;
  139 
  140     IdleRegister idle_register;
  141 };
  142 
  143 #endif