"Fossies" - the Fresh Open Source Software Archive

Member "fityk-1.3.1/wxgui/drag.h" (13 May 2016, 1908 Bytes) of package /linux/misc/fityk-1.3.1.tar.gz:


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 "drag.h" see the Fossies "Dox" file reference documentation.

    1 // This file is part of fityk program. Copyright 2001-2013 Marcin Wojdyr
    2 // Licence: GNU General Public License ver. 2+
    3 
    4 /// DraggedFunc - used for dragging function in MainPlot
    5 
    6 #ifndef FITYK_WX_FDRAG_H_
    7 #define FITYK_WX_FDRAG_H_
    8 
    9 #include <string>
   10 
   11 namespace fityk { class Function; class ModelManager; }
   12 
   13 class DraggedFuncObserver
   14 {
   15 public:
   16     virtual ~DraggedFuncObserver() {}
   17     virtual void change_parameter_value(int idx, double value) = 0;
   18 };
   19 
   20 class DraggedFunc
   21 {
   22 public:
   23     enum DragType
   24     {
   25         no_drag,
   26         relative_value, //eg. for area
   27         absolute_value,  //eg. for width
   28         absolute_pixels
   29     };
   30 
   31     struct Drag
   32     {
   33         DragType how;
   34         int parameter_idx;
   35         std::string parameter_name;
   36         std::string variable_name; /// name of variable that are to be changed
   37         double value; /// current value of parameter
   38         double ini_value; /// initial value of parameter
   39         double multiplier; /// increases or decreases changing rate
   40         double ini_x;
   41 
   42         Drag() : how(no_drag) {}
   43     };
   44 
   45     DraggedFunc(const fityk::ModelManager& mgr)
   46         : mgr_(mgr), has_changed_(false) {}
   47     void start(const fityk::Function* p, int X, int Y, double x, double y,
   48                DraggedFuncObserver* callback);
   49     void move(bool shift, int X, int Y, double x, double y);
   50     void stop();
   51     const std::string& status() const { return status_; }
   52     bool has_changed() { return has_changed_; }
   53     std::string get_cmd() const;
   54 
   55 private:
   56     const fityk::ModelManager& mgr_;
   57     DraggedFuncObserver* callback_;
   58     Drag drag_x_; ///for horizontal dragging (x axis)
   59     Drag drag_y_; /// y axis
   60     Drag drag_shift_x_; ///x with [shift]
   61     Drag drag_shift_y_; ///y with [shift]
   62     double px_, py_;
   63     int pX_, pY_;
   64     std::string status_;
   65     bool has_changed_;
   66 
   67     void change_value(Drag *drag, double x, double dx, int dX);
   68 };
   69 
   70 #endif
   71