PSQt/include/DragStore.h

Go to the documentation of this file.
00001 #ifndef PSQT_DRAGSTORE_H
00002 #define PSQT_DRAGSTORE_H
00003 
00004 //--------------------------
00005 
00006 #include "PSQt/DragBase.h"
00007 
00008 //--------------------------
00009 
00010 namespace PSQt {
00011 
00012 //--------------------------
00013 /**
00014  *  @ingroup PSQt DRAGTYPE
00015  *
00016  *  @brief DRAGTYPE - enumerator for DragBase type objects
00017  */ 
00018 
00019   enum DRAGTYPE {DRAGCIRCLE=0, DRAGCENTER, DRAGLINE, DRAGNONE};
00020 
00021 //--------------------------
00022 /**
00023  *  @ingroup PSQt Record
00024  *
00025  *  @brief DragFig - struct for DragStore
00026  */ 
00027 
00028 struct DragFig {
00029   DragBase* ptr_obj;
00030   DRAGTYPE  type; 
00031   unsigned  flags;
00032 
00033   //std::string strRecordTotal();
00034   //std::string strRecordBrief();
00035   //std::string strRecord();
00036 };
00037 
00038 
00039 /// @addtogroup PSQt PSQt
00040 
00041 /**
00042  *  @ingroup PSQt
00043  *
00044  *  @brief Contains static factory method Create for DragBase objects.
00045  *
00046  *  This software was developed for the LCLS project. If you use all or 
00047  *  part of it, please give an appropriate acknowledgment.
00048  *
00049  *  @version $Id: DragStore.h 9841 2015-03-26 18:35:44Z dubrovin@SLAC.STANFORD.EDU $
00050  *
00051  *  @author Mikhail S. Dubrovin
00052  *
00053  *  @see Drag, DragCspad2x1V1
00054  *
00055  *  @anchor interface
00056  *  @par<interface> Interface Description
00057  * 
00058  *  @li  Includes
00059  *  @code
00060  *  // #include "PSQt/DragBase.h" // already included under DragStore.h
00061  *  #include "PSQt/DragStore.h"
00062  *  typedef PSQt::DragBase DF;
00063  *  @endcode
00064  *
00065  *  @li Instatiation
00066  *  \n
00067  *  Classes like DragCircle containing implementation of the DragBase interface methods are self-sufficient. 
00068  *  Factory method Create should returns the pointer to the DragBase object for specified figure parameter or returns 0-pointer if segname is not recognized (and not implemented).
00069  *  Code below instateates DragBase object using factory static method PSQt::DragStore::Create()
00070  *  @code
00071  *  DRAGTYPE dragfig = DRAGCIRCLE; // or DRAGCENTER, DRAGLINE, etc.;
00072  *  DF* dfigobj = PSQt::DragStore::Create(dragfig);
00073  *  @endcode
00074  *
00075  *  @li Print info
00076  *  @code
00077  *  dfigobj -> print(0377);
00078  *  @endcode
00079  *
00080  *  @li Access methods
00081  *  \n are defined in the interface DragBase and implemented in DragCircle etc.
00082  *  @code
00083  *  // scalar values
00084  *  const DF::size_t array_size = dfigobj -> size(); 
00085  *  @endcode
00086  *
00087  *  @li How to add new segment to the factory
00088  *  \n 1. implement DragBase interface methods in class like DragCircle
00089  *  \n 2. add it to DragStore with unique dragfig
00090  */
00091 
00092 //--------------------------
00093 
00094 class DragStore {
00095 
00096  public:
00097 
00098   DragStore (WdgImage* wimg = 0);
00099   virtual ~DragStore () {}
00100 
00101   void print();
00102   void drawFigs(const DRAGMODE& mode=DRAW);
00103   bool containFigs(const QPointF& p);
00104   void moveFigs(const QPointF& p);
00105   void moveFigsIsCompleted(const QPointF& p);
00106   void addCircle(const float& rad_raw=100, const QPen* pen=0); // QPen(Qt::white, 1, Qt::SolidLine));
00107   void deleteFig();
00108 
00109   /**
00110    *  @brief Static factory method to create object of classes derived from DragBase
00111    *  
00112    *  @param[in] wimg - pointer to WdgImage
00113    *  @param[in] dfigtype - figure enumerated type
00114    *  @param[in] points - array of points which defines initial figure parameters
00115    *  @param[in] npoints - number of points in the array
00116    */
00117   static PSQt::DragBase* Create(WdgImage* wimg, const DRAGTYPE& dfigtype=DRAGCIRCLE, const QPointF* points=0, const int& npoints=0);
00118   static const char* cstrDragType(const DRAGTYPE& dfigtype=DRAGCIRCLE);
00119   static inline const char* _name_(){return "DragStore";} 
00120 
00121   const QPointF& getCenter(){ return v_dragfigs[0].ptr_obj->getCenter(); }
00122   const DragBase* getDragCenter(){ return v_dragfigs[0].ptr_obj; }
00123 
00124 
00125  private:
00126 
00127   WdgImage*            m_wimg;
00128   std::vector<DragFig> v_dragfigs;
00129   DragFig*             p_dragfig_sel;
00130 };
00131 
00132 } // namespace PSQt
00133 
00134 #endif // PSQT_DRAGSTORE_H
00135 
00136 //--------------------------

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7