コード例 #1
0
unsigned layprop::SDLine::nonius(const DBline& short_mark, const DBline& long_mark,
                                 const real step, LineList& llst) const
{
   // prepare the translation matrix for the edge point
   CTM tmtrx;
   tmtrx.Rotate(_angle);
   tmtrx.Translate(_ln.p1().x(), _ln.p1().y());
   unsigned numtics;
   for( numtics = 0 ; (numtics * step) < _length ; numtics++ )
   {
      // for each tick - get the deltas ...
      int4b deltaX = (int4b) rint(numtics * step * _cosinus);
      int4b deltaY = (int4b) rint(numtics * step * _sinus);
      // ... calculate the translation ...
      CTM pmtrx = tmtrx;
      pmtrx.Translate(deltaX, deltaY);
      // ... create a new tick and move it to its position
      if (numtics % 5)
         llst.push_back(DBline(short_mark * pmtrx));
      else
         llst.push_back(DBline(long_mark * pmtrx));
   }
   // don't forget the opposite edge point
   tmtrx.Translate(_ln.p2().x() - _ln.p1().x(), _ln.p2().y() - _ln.p1().y());
   llst.push_back(DBline(long_mark * tmtrx));
   return ++numtics;
}
コード例 #2
0
void layprop::SupplementaryData::getConsts(const CTM& LayCTM, DBline& long_mark, DBline& short_mark, DBline& text_bp, double& scaledpix)
{
   // Side ticks (segments) of the rulers has to be with constant size. The next lines
   // are generating a segment with the size 7/3 screen pixels centered in
   // the {0,0} point of the canvas (logical coords)
   // the coeffitients 1e3/1e-3 are picked ramdomly attempting to reduce the
   // error
   const double ico = 1e3;
   const double dco = 1/ico;
   DBline tick_sample = DBline(TP(0,0),TP(0,7,ico)) * LayCTM;
   double tick_size = ((double)(tick_sample.p2().y()-tick_sample.p1().y()));
   long_mark = DBline(TP(0,-tick_size, dco),TP(0,tick_size, dco));
   
   tick_sample = DBline(TP(0,0),TP(0,3,ico)) * LayCTM;
   tick_size = ((double)(tick_sample.p2().y()-tick_sample.p1().y()));
   short_mark = DBline(TP(0,-tick_size, dco),TP(0,tick_size, dco));
   
   tick_sample = DBline(TP(0,0),TP(0,20,ico)) * LayCTM;
   tick_size = ((double)(tick_sample.p1().y()-tick_sample.p2().y()));
   text_bp = DBline(TP(0,0),TP(0,tick_size, dco));
   
   // now prepare to draw the size
   DBbox pixelbox = DBbox(TP(),TP(15,15)) * LayCTM;
   scaledpix = ((double)(pixelbox.p2().x()-pixelbox.p1().x()));
   
}
コード例 #3
0
ファイル: basetrend.cpp プロジェクト: etihwnad/toped
void trend::TrendBase::genRulerMarks(const CTM& LayCTM, DBline& long_mark, DBline& short_mark, DBline& text_bp, double& scaledpix)
{
    // Side ticks (segments) of the rulers has to be with constant size. The next
    // lines are generating a segment with the size 7/3 screen pixels centred in
    // the {0,0} point of the canvas (logical coordinates)
    // The coefficients 1e3/1e-3 are picked arbitrary in an attempt to reduce the
    // error
    const double ico = 1e3;
    const double dco = 1/ico;
    DBline tick_sample = DBline(TP(0,0),TP(0,7,ico)) * LayCTM;
    double tick_size = ((double)(tick_sample.p2().y()-tick_sample.p1().y()));
    long_mark = DBline(TP(0,-tick_size, dco),TP(0,tick_size, dco));

    tick_sample = DBline(TP(0,0),TP(0,3,ico)) * LayCTM;
    tick_size = ((double)(tick_sample.p2().y()-tick_sample.p1().y()));
    short_mark = DBline(TP(0,-tick_size, dco),TP(0,tick_size, dco));

    tick_sample = DBline(TP(0,0),TP(0,20,ico)) * LayCTM;
    tick_size = ((double)(tick_sample.p1().y()-tick_sample.p2().y()));
    text_bp = DBline(TP(0,0),TP(0,tick_size, dco));

    // now prepare to draw the size
    DBbox pixelbox = DBbox(TP(),TP(15,15)) * LayCTM;
    scaledpix = ((double)(pixelbox.p2().x()-pixelbox.p1().x()));
}