PSQt/src/DragBase.cpp

Go to the documentation of this file.
00001 //---------------------------------------------------------------------
00002 // File and Version Information:
00003 //   $Id: DragBase.cpp 9841 2015-03-26 18:35:44Z dubrovin@SLAC.STANFORD.EDU $
00004 //
00005 // Author: Mikhail S. Dubrovin
00006 //---------------------------------------------------------------------
00007 
00008 //--------------------------
00009 
00010 #include "PSQt/DragBase.h"
00011 
00012 using namespace std;   // for cout without std::
00013 
00014 namespace PSQt {
00015 
00016 //--------------------------
00017 
00018 DragBase::DragBase(WdgImage* wimg, const QPointF* points, const int& npoints)
00019   : QObject(NULL)
00020   , m_wimg(wimg)
00021   , m_npoints(npoints)
00022   , m_pen_draw(Qt::white, 1, Qt::SolidLine)
00023   , m_pen_move(Qt::red,   2, Qt::SolidLine) // Qt::DashLine)
00024   , m_rpick(10)
00025   , m_center_def(QPointF(100,100)) 
00026 {
00027   //std::cout << "c-tor DragBase()\n";
00028   m_points_raw = new QPointF[m_npoints];
00029   m_points_img = new QPointF[m_npoints];
00030 
00031   this->copyRawPoints(points);
00032   this->setImagePointsFromRaw();
00033 }
00034 
00035 //--------------------------
00036 DragBase::~DragBase()
00037 {
00038   delete [] m_points_raw;
00039   delete [] m_points_img;
00040 }; 
00041 
00042 //--------------------------
00043 
00044 void
00045 DragBase::copyRawPoints(const QPointF* points)
00046 {
00047   for(int i=0; i<m_npoints; ++i) m_points_raw[i] = points[i];
00048 }
00049 
00050 //--------------------------
00051 
00052 void
00053 DragBase::setImagePointsFromRaw()
00054 {
00055   for(int i=0; i<m_npoints; ++i) m_points_img[i] = m_wimg->pointInImage(m_points_raw[i]);
00056 }
00057 
00058 //--------------------------
00059 
00060 void
00061 DragBase::setRawPointsFromImage()
00062 {
00063   for(int i=0; i<m_npoints; ++i) m_points_raw[i] = m_wimg->pointInRaw(m_points_img[i]);
00064 }
00065 
00066 //--------------------------
00067 
00068 void
00069 DragBase::print()
00070 {
00071   stringstream ss; ss << strTimeStamp() << "  DragBase::print():";
00072   for(int i=0; i<m_npoints; ++i) ss <<"\n    x_raw:" << m_points_raw[i].x() << "  y_raw:" << m_points_raw[i].y();
00073   std::cout << ss.str() << '\n';
00074 }
00075 
00076 //--------------------------
00077 
00078 } // namespace PSQt
00079 
00080 //--------------------------
00081 
00082 

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7