PSQt/include/DragBase.h

Go to the documentation of this file.
00001 #ifndef PSQT_DRAGBASE_H
00002 #define PSQT_DRAGBASE_H
00003 
00004 //--------------------------
00005 #include "PSQt/QGUtils.h"
00006 #include "PSQt/Logger.h"
00007 #include "PSQt/WdgImage.h"
00008 
00009 #include <QtCore>
00010 
00011 //#include <map>
00012 #include <iostream>    // std::cout
00013 #include <fstream>     // std::ifstream(fname)
00014 #include <sstream>     // stringstream
00015 #include <iomanip>     // setw, setfill
00016 
00017 using namespace std;   // cout without std::
00018  
00019 namespace PSQt {
00020 
00021 //--------------------------
00022 /**
00023  *  @ingroup PSQt DRAGMODE
00024  *
00025  *  @brief DRAGMODE - enumerator of modes for DragBase
00026  */ 
00027 
00028   enum DRAGMODE {ZOOM=0, CREATE, DELETE, MOVE, DRAW};
00029 
00030 //--------------------------
00031 
00032 // @addtogroup PSQt DragBase
00033 
00034 /**
00035  *  @ingroup PSQt DragBase
00036  *
00037  *  @brief Base class for draggable figures like circle, line, center, etc on the plot.
00038  *
00039  *  This software was developed for the LCLS project.  If you use all or 
00040  *  part of it, please give an appropriate acknowledgment.
00041  *
00042  *  @see DragStore, DragCenter, DragCircle, WdgImageFigs, WdgImage
00043  *
00044  *  @version $Id: DragBase.h 9841 2015-03-26 18:35:44Z dubrovin@SLAC.STANFORD.EDU $
00045  *
00046  *  @author Mikhail Dubrovin
00047  *
00048  *
00049  *
00050  *
00051  *
00052  *  @anchor interface
00053  *  @par<interface> Interface Description
00054  * 
00055  *  @li  Include
00056  *  @code
00057  *  #include "PSQt/DragBase.h"
00058  *  @endcode
00059  *
00060  *  @li Instatiation
00061  *  \n
00062  *  DragBase is inhereted and used by the class
00063  */
00064 
00065 //--------------------------
00066 
00067 class DragBase : public QObject
00068 {
00069   // Q_OBJECT // macro is needed for connection of signals and slots
00070 
00071  public:
00072 
00073   /**
00074    *  @brief DragBase - base class for draggable figures
00075    *  
00076    *  @param[in] wimg - pointer to WdgImage
00077    *  @param[in] points - array of points which defines initial figure parameters
00078    *  @param[in] npoints - number of points in the array
00079    */ 
00080 
00081     DragBase(WdgImage* wimg, const QPointF* points, const int& npoints=1); 
00082     virtual ~DragBase(); 
00083 
00084     virtual void draw(const DRAGMODE& mode=DRAW) = 0;
00085     virtual bool contains(const QPointF& p) = 0;
00086     virtual void move(const QPointF& p) = 0;
00087     virtual void moveIsCompleted(const QPointF& p) = 0;
00088     virtual void create() = 0;
00089 
00090     virtual const QPointF& getCenter() { return m_center_def; };
00091     virtual void print();
00092 
00093     void setPenMove(const QPen& pen) { m_pen_move = pen; };
00094     void setPenDraw(const QPen& pen) { m_pen_draw = pen; };
00095     void setPickRadius(const float& rpick) { m_rpick = rpick; };
00096 
00097  protected:
00098 
00099     void setImagePointsFromRaw();
00100     void setRawPointsFromImage();
00101 
00102     PSQt::WdgImage* m_wimg;
00103     QPointF*        m_points_raw;
00104     QPointF*        m_points_img;
00105     int             m_npoints;
00106     QPen            m_pen_draw;
00107     QPen            m_pen_move;
00108     float           m_rpick;
00109 
00110  private:
00111     virtual  const char* _name_(){return "DragBase";}
00112     void copyRawPoints(const QPointF* points=0);
00113     QPointF         m_center_def; 
00114 
00115  };
00116 
00117 //--------------------------
00118 
00119 } // namespace PSQt
00120 
00121 #endif // PSQT_DRAGBASE_H
00122 //--------------------------
00123 //--------------------------
00124 //--------------------------
00125 

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7