Esempio n. 1
0
Ecliptic::Ecliptic(SkyComposite *parent ) :
        LineListIndex( parent, i18n("Ecliptic") ),
        m_label( name() )
{
    KStarsData *data = KStarsData::Instance();
    KSNumbers num( data->ut().djd() );
    dms elat(0.0), elng(0.0);

    const double eps    =   0.1;
    const double minRa  =   0.0;
    const double maxRa  =  23.0;
    const double dRa    =   2.0;
    const double dRa2   =  2. / 5.;

    for(double ra = minRa; ra < maxRa; ra += dRa ) {
        LineList* lineList = new LineList();
        for(double ra2 = ra; ra2 <= ra + dRa + eps; ra2 += dRa2 ) {
            elng.setH( ra2 );
            SkyPoint* o = new SkyPoint();
            o->setFromEcliptic( num.obliquity(), elng, elat );
            o->setRA0( o->ra().Hours() );
            o->setDec0( o->dec().Degrees() );
            o->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
            lineList->append( o );
        }
        appendLine( lineList );
    }
}
void Inkscape::LineSnapper::freeSnap(SnappedConstraints &sc,
                                                    Inkscape::SnapPreferences::PointType const &t,
                                                    Geom::Point const &p,
                                                    bool const &/*f*/,
                                                    Geom::OptRect const &/*bbox_to_snap*/,
                                                    std::vector<SPItem const *> const */*it*/,
                                                    std::vector<Geom::Point> */*unselected_nodes*/) const
{
	if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(t) == false) {
        return;
    }

    /* Get the lines that we will try to snap to */
    const LineList lines = _getSnapLines(p);

    // std::cout << "snap point " << p << " to: " << std::endl;

    for (LineList::const_iterator i = lines.begin(); i != lines.end(); i++) {
        Geom::Point const p1 = i->second; // point at guide/grid line
        Geom::Point const p2 = p1 + Geom::rot90(i->first); // 2nd point at guide/grid line
        // std::cout << "  line through " << i->second << " with normal " << i->first;
        g_assert(i->first != Geom::Point(0,0)); // we cannot project on an linesegment of zero length

        Geom::Point const p_proj = project_on_linesegment(p, p1, p2);
        Geom::Coord const dist = Geom::L2(p_proj - p);
        //Store any line that's within snapping range
        if (dist < getSnapperTolerance()) {
            _addSnappedLine(sc, p_proj, dist, i->first, i->second);
            // std::cout << " -> distance = " << dist;
        }
        // std::cout << std::endl;
    }
}
Esempio n. 3
0
//-----------------------------------------------------------------------------
void CGDrawContext::drawLines (const LineList& lines)
{
    if (lines.size () == 0)
        return;
    CGContextRef context = beginCGContext (true, getDrawMode ().integralMode ());
    if (context)
    {
        applyLineStyle (context);

        CGPoint* cgPoints = new CGPoint[lines.size () * 2];
        uint32_t index = 0;
        VSTGUI_RANGE_BASED_FOR_LOOP(LineList, lines, LinePair, line)
        cgPoints[index] = CGPointFromCPoint (line.first);
        cgPoints[index+1] = CGPointFromCPoint (line.second);
        if (getDrawMode ().integralMode ())
        {
            cgPoints[index] = pixelAlligned (cgPoints[index]);
            cgPoints[index+1] = pixelAlligned (cgPoints[index+1]);
        }
        index += 2;
        VSTGUI_RANGE_BASED_FOR_LOOP_END

        if (getDrawMode ().integralMode ())
        {
            int32_t frameWidth = static_cast<int32_t> (currentState.frameWidth);
            if (frameWidth % 2)
                CGContextTranslateCTM (context, 0.5, 0.5);
        }

        CGContextStrokeLineSegments (context, cgPoints, lines.size () * 2);
        delete [] cgPoints;

        releaseCGContext (context);
    }
}
Esempio n. 4
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;
}
Esempio n. 5
0
void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
                                               Inkscape::SnapCandidatePoint const &p,
                                               Geom::OptRect const &/*bbox_to_snap*/,
                                               ConstraintLine const &c,
                                               std::vector<SPItem const *> const */*it*/) const

{
    if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false) {
        return;
    }

    /* Get the lines that we will try to snap to */
    const LineList lines = _getSnapLines(p.getPoint());

    for (LineList::const_iterator i = lines.begin(); i != lines.end(); i++) {
        if (Geom::L2(c.getDirection()) > 0) { // Can't do a constrained snap without a constraint
            // constraint line
            Geom::Point const point_on_line = c.hasPoint() ? c.getPoint() : p.getPoint();
            Geom::Line line1(point_on_line, point_on_line + c.getDirection());

            // grid/guide line
            Geom::Point const p1 = i->second; // point at guide/grid line
            Geom::Point const p2 = p1 + Geom::rot90(i->first); // 2nd point at guide/grid line
            Geom::Line line2(p1, p2);

            Geom::OptCrossing inters = Geom::OptCrossing(); // empty by default
            try
            {
                inters = Geom::intersection(line1, line2);
            }
            catch (Geom::InfiniteSolutions e)
            {
                // We're probably dealing with parallel lines, so snapping doesn't make any sense here
                continue; // jump to the next iterator in the for-loop
            }

            if (inters) {
                Geom::Point t = line1.pointAt((*inters).ta);
                const Geom::Coord dist = Geom::L2(t - p.getPoint());
                if (dist < getSnapperTolerance()) {
                    // When doing a constrained snap, we're already at an intersection.
                    // This snappoint is therefore fully constrained, so there's no need
                    // to look for additional intersections; just return the snapped point
                    // and forget about the line
                    _addSnappedPoint(sc, t, dist, p.getSourceType(), p.getSourceNum(), true);
                    // For any line that's within range, we will also look at it's "point on line" p1. For guides
                    // this point coincides with its origin; for grids this is of no use, but we cannot
                    // discern between grids and guides here
                    Geom::Coord const dist_p1 = Geom::L2(p1 - p.getPoint());
                    if (dist_p1 < getSnapperTolerance()) {
                        _addSnappedLinesOrigin(sc, p1, dist_p1, p.getSourceType(), p.getSourceNum(), true);
                        // Only relevant for guides; grids don't have an origin per line
                        // Therefore _addSnappedLinesOrigin() will only be implemented for guides
                    }
                }
            }
        }
    }
}
EquatorialCoordinateGrid::EquatorialCoordinateGrid( SkyComposite *parent )
        : CoordinateGrid( parent, i18n("Equatorial Coordinate Grid" ) )
{
    KStarsData *data = KStarsData::Instance();

    intro();

    double eps    =   0.1;
    double minRa  =   0.0;
    double maxRa  =  23.0;
    double dRa    =   2.0;
    double minDec = -80.0;
    double maxDec =  90.0;
    double dDec   =  20.0;
    double dDec2  =   4.0;
    double dRa2   =   0.2;

    double max, dec, dec2, ra, ra2;

    LineList* lineList;

    for ( ra = minRa; ra < maxRa; ra += dRa ) {
        for ( dec = -90.0; dec < maxDec - eps; dec += dDec ) {
            lineList = new LineList();
            max = dec + dDec;
            if ( max > 90.0 ) max = 90.0;
            for ( dec2 = dec; dec2 <= max + eps; dec2 += dDec2 ) {
                SkyPoint* p = new SkyPoint( ra, dec2 );
                p->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
                lineList->append( p );
            }
            appendLine( lineList );
        }
    }

    for ( dec = minDec; dec < maxDec + eps; dec += dDec ) {
        // Do not paint the line on the equator
        if ( dec < 0.1 && dec > -0.1 )
            continue;
        
        // Adjust point density
        int nPoints = int(round( fabs(cos(dec* dms::PI / 180.0)) * dRa / dRa2 ));
        if ( nPoints < 5 )
            nPoints = 5;
        double dRa3 = dRa / nPoints;

        for ( ra = minRa; ra < maxRa + eps; ra += dRa ) {
            lineList = new LineList();
            for ( ra2 = ra; ra2 <= ra + dRa + eps; ra2 += dRa3 ) {
                SkyPoint* p = new SkyPoint( ra2, dec );
                p->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
                lineList->append( p );
            }
            appendLine( lineList );
        }
    }
    
    summary();
}
Esempio n. 7
0
bool wxFileConfig::Flush(bool /* bCurrentOnly */)
{
  if ( LineListIsEmpty() || !m_pRootGroup->IsDirty() || !m_strLocalFile )
    return TRUE;

#ifdef __UNIX__
  // set the umask if needed
  mode_t umaskOld = 0;
  if ( m_umask != -1 )
  {
      umaskOld = umask((mode_t)m_umask);
  }
#endif // __UNIX__

  wxTempFile file(m_strLocalFile);

  if ( !file.IsOpened() ) {
    wxLogError(_("can't open user configuration file."));
    return FALSE;
  }

  // write all strings to file
  for ( LineList *p = m_linesHead; p != NULL; p = p->Next() ) {
    if ( !file.Write(p->Text() + wxTextFile::GetEOL()) ) {
      wxLogError(_("can't write user configuration file."));
      return FALSE;
    }
  }

  bool ret = file.Commit();

#if defined(__WXMAC__) && !defined(__UNIX__)
  if ( ret )
  {
  	FSSpec spec ;
  	
  	wxMacFilename2FSSpec( m_strLocalFile , &spec ) ;
  	FInfo finfo ;
  	if ( FSpGetFInfo( &spec , &finfo ) == noErr )
  	{
  		finfo.fdType = 'TEXT' ;
  		finfo.fdCreator = 'ttxt' ;
  		FSpSetFInfo( &spec , &finfo ) ;
  	}
  }
#endif // __WXMAC__ && !__UNIX__

#ifdef __UNIX__
  // restore the old umask if we changed it
  if ( m_umask != -1 )
  {
      (void)umask(umaskOld);
  }
#endif // __UNIX__

  return ret;
}
Esempio n. 8
0
//-----------------------------------------------------------------------------
void CDrawContext::drawLines (const CPoint* points, const int32_t& numberOfLines)
{
	assert (numberOfLines < 0);
	LineList list (static_cast<uint32_t> (numberOfLines));
	for (int32_t i = 0; i < numberOfLines * 2; i += 2)
	{
		list.push_back (std::make_pair (points[i], points[i+1]));
	}
	drawLines (list);
}
Esempio n. 9
0
// Write file from memory buffer
int WriteOutputFile(LineList &lines, const TCHAR *filename)
{
  FILE *f;
  LineList::const_iterator it;

  f = _wfopen(filename,TEXT("wb+"));
  if (f==NULL) return 1;
  for (it = lines.begin(); it != lines.end(); ++it) fputs(it->c_str(),f);
  fclose(f);
  return 0;
}
Esempio n. 10
0
void wxFileConfig::CleanUp()
{
  delete m_pRootGroup;

  LineList *pCur = m_linesHead;
  while ( pCur != NULL ) {
    LineList *pNext = pCur->Next();
    delete pCur;
    pCur = pNext;
  }
}
Esempio n. 11
0
void ConfigGroup::Rename(const wxString& newName)
{
    m_strName = newName;

    LineList *line = GetGroupLine();
    wxString strFullName;
    strFullName << wxT("[") << (GetFullName().c_str() + 1) << wxT("]"); // +1: no '/'
    line->SetText(strFullName);

    SetDirty();
}
Esempio n. 12
0
// Read input file into memory buffer
int ReadInputFile(LineList &lines, const TCHAR *filename)
{
  FILE *f;
  char linebuf[MAXLINELEN];

  lines.clear();
 
  f = _wfopen(filename,TEXT("rb"));
  if (f==NULL) return 1;
  while (fgets(linebuf,MAXLINELEN,f)!=NULL) lines.push_back(linebuf);
  fclose(f);
  return 0;
}
Esempio n. 13
0
    void visit (LineList& line_list)
    {
      printf ("LineList (material='%s'):\n", line_list.Material ());

      for (size_t i=0; i<line_list.LinesCount (); i++)
      {
        const LineDesc& s = line_list.Lines ()[i];

        printf ("  #%u: position=[%.0f %.0f %.0f]-[%.0f %.0f %.0f] color=[%.2f %.2f %.2f %.2f]-[%.2f %.2f %.2f %.2f] tex_offset=[%.0f %.0f]-[%.0f %.0f]\n",
          i, s.point [0].position.x, s.point [0].position.y, s.point [0].position.z, s.point [1].position.x, s.point [1].position.y, s.point [1].position.z,
             s.point [0].color.x, s.point [0].color.y, s.point [0].color.z, s.point [0].color.w, s.point [1].color.x, s.point [1].color.y, s.point [1].color.z, s.point [1].color.w,
             s.point [0].tex_offset.x, s.point [0].tex_offset.y, s.point [1].tex_offset.x, s.point [1].tex_offset.y);
      }
    }
Esempio n. 14
0
bool ConfigGroup::DeleteEntry(const wxChar *szName)
{
  ConfigEntry *pEntry = FindEntry(szName);
  wxCHECK( pEntry != NULL, FALSE );  // deleting non existing item?

  LineList *pLine = pEntry->GetLine();
  if ( pLine != NULL ) {
    // notice that we may do this test inside the previous "if" because the
    // last entry's line is surely !NULL
    if ( pEntry == m_pLastEntry ) {
      // our last entry is being deleted - find the last one which stays
      wxASSERT( m_pLine != NULL );  // if we have an entry with !NULL pLine...

      // go back until we find another entry or reach the group's line
      ConfigEntry *pNewLast = NULL;
      size_t n, nEntries = m_aEntries.Count();
      LineList *pl;
      for ( pl = pLine->Prev(); pl != m_pLine; pl = pl->Prev() ) {
        // is it our subgroup?
        for ( n = 0; (pNewLast == NULL) && (n < nEntries); n++ ) {
          if ( m_aEntries[n]->GetLine() == m_pLine )
            pNewLast = m_aEntries[n];
        }

        if ( pNewLast != NULL ) // found?
          break;
      }

      if ( pl == m_pLine ) {
        wxASSERT( !pNewLast );  // how comes it has the same line as we?

        // we've reached the group line without finding any subgroups
        m_pLastEntry = NULL;
      }
      else
        m_pLastEntry = pNewLast;
    }

    m_pConfig->LineListRemove(pLine);
  }

  // we must be written back for the changes to be saved
  SetDirty();

  m_aEntries.Remove(pEntry);
  delete pEntry;

  return TRUE;
}
void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
                                               Inkscape::SnapPreferences::PointType const &t,
                                               Geom::Point const &p,
                                               bool const &/*f*/,
                                               Geom::OptRect const &/*bbox_to_snap*/,
                                               ConstraintLine const &c,
                                               std::vector<SPItem const *> const */*it*/) const

{
    if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(t) == false) {
        return;
    }

    /* Get the lines that we will try to snap to */
    const LineList lines = _getSnapLines(p);

    for (LineList::const_iterator i = lines.begin(); i != lines.end(); i++) {
        if (Geom::L2(c.getDirection()) > 0) { // Can't do a constrained snap without a constraint
            /* Normal to the line we're trying to snap along */
            Geom::Point const n(Geom::rot90(Geom::unit_vector(c.getDirection())));

            Geom::Point const point_on_line = c.hasPoint() ? c.getPoint() : p;

            /* Constant term of the line we're trying to snap along */
            Geom::Coord const q0 = dot(n, point_on_line);
            /* Constant term of the grid or guide line */
            Geom::Coord const q1 = dot(i->first, i->second);

            /* Try to intersect this line with the target line */
            Geom::Point t_2geom(NR_HUGE, NR_HUGE);
            Geom::IntersectorKind const k = Geom::line_intersection(n, q0, i->first, q1, t_2geom);
            Geom::Point t(t_2geom);

            if (k == Geom::intersects) {
                const Geom::Coord dist = L2(t - p);
                if (dist < getSnapperTolerance()) {
    				// When doing a constrained snap, we're already at an intersection.
                    // This snappoint is therefore fully constrained, so there's no need
                    // to look for additional intersections; just return the snapped point
                    // and forget about the line
                    sc.points.push_back(SnappedPoint(t, Inkscape::SNAPTARGET_UNDEFINED, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), true));
                    // The type of the snap target is yet undefined, as we cannot tell whether
                    // we're snapping to grid or the guide lines; must be set by on a higher level
                }
            }
        }
    }
}
Esempio n. 16
0
//-----------------------------------------------------------------------------
void GdiplusDrawContext::drawLines (const LineList& lines)
{
	if (lines.size () == 0)
		return;
	for (const auto& line : lines)
		drawLine (line);
}
Esempio n. 17
0
bool read_from_script(LineList& ll, const char* script)
      {
      FILE* f = popen(script, "r");
      if (!f)
            return true;
      char buffer[LINMAX];
      int n = 0;
      int len;
      for (;;++n) {
            *buffer = 0;
            if ((len = xgets(buffer, LINMAX, f)) < 0)
                  break;
            //
            //    Backstep filtern
            //
            buffer[len] = 0;
            char* s = buffer;
            char* d = buffer;
            while (*s) {
                  if (*s == 0x8) {
                        if (d != buffer) {
                              --d;
                              len-=2;
                              }
                        }
                  else {
                        *d++ = *s;
                        }
                  ++s;
                  }
            ll.push_back(new Line(buffer, len));
            }
      pclose(f);
      return (len == -2);
      }
Esempio n. 18
0
// append a new line to the end of the list
LineList *wxFileConfig::LineListAppend(const wxString& str)
{
  LineList *pLine = new LineList(str);

  if ( m_linesTail == NULL ) {
    // list is empty
    m_linesHead = pLine;
  }
  else {
    // adjust pointers
    m_linesTail->SetNext(pLine);
    pLine->SetPrev(m_linesTail);
  }

  m_linesTail = pLine;
  return m_linesTail;
}
Esempio n. 19
0
void LinePath::growList(LineList &list, int by) {
    QPen pen( getLineColor(), getLineWidth() );
    for (int i = 0; i < by; i++) {
        QCanvasLine * line = new QCanvasLine( getCanvas() );
        line -> setZ( 0 );
        line -> setPen( pen );
        line -> setVisible( true );
        list.append( line );
    }
}
Esempio n. 20
0
void wxFileConfig::LineListRemove(LineList *pLine)
{
  LineList *pPrev = pLine->Prev(),
           *pNext = pLine->Next();

  // first entry?
  if ( pPrev == NULL )
    m_linesHead = pNext;
  else
    pPrev->SetNext(pNext);

  // last entry?
  if ( pNext == NULL )
    m_linesTail = pPrev;
  else
    pNext->SetPrev(pPrev);

  delete pLine;
}
Esempio n. 21
0
Inkscape::GuideSnapper::LineList Inkscape::GuideSnapper::_getSnapLines(Geom::Point const &/*p*/) const
{
    LineList s;

    if ( NULL == _snapmanager->getNamedView() || ThisSnapperMightSnap() == false) {
        return s;
    }

    SPGuide const *guide_to_ignore = _snapmanager->getGuideToIgnore();

    for (GSList const *l = _snapmanager->getNamedView()->guides; l != NULL; l = l->next) {
        SPGuide const *g = SP_GUIDE(l->data);
        if (g != guide_to_ignore) {
            s.push_back(std::make_pair(g->normal_to_line, g->point_on_line));
        }
    }

    return s;
}
Esempio n. 22
0
void GenerateMD5(LineList &lines, md5generators_t *md5s)
{
    
  md5s->a.Init( 0x63e54c01, 0x25adab89, 0x44baecfe, 0x60f25476 );
  md5s->b.Init( 0x41e24d03, 0x23b8ebea, 0x4a4bfc9e, 0x640ed89a );
  md5s->c.Init( 0x61e54e01, 0x22cdab89, 0x48b20cfe, 0x62125476 );
  md5s->d.Init( 0xc1e84fe8, 0x21d1c28a, 0x438e1a12, 0x6c250aee );

  int skipwhitespaces = 1;
  
  LineList::const_iterator it;
  
  for (it = lines.begin(); it != lines.end(); ++it) {
    for (unsigned int i=0; i<(it->length()); ++i) {
      //Skip whitespaces
      if (skipwhitespaces) {
        char c = it->c_str()[i];
        if (c >= 0x20 && c <= 0x7E &&
            c != 0x0D &&
            c != 0x0A &&
            c != 0x24 &&
            c != 0x2A &&
            c != 0x2C &&
            c != 0x21 &&
            c != 0x5C &&
            c != 0x5E &&
            c != 0x7E) ; else continue;
      }
      md5s->a.Update((const unsigned char*)it->c_str()+i, 1);
      md5s->b.Update((const unsigned char*)it->c_str()+i, 1);
      md5s->c.Update((const unsigned char*)it->c_str()+i, 1);
      md5s->d.Update((const unsigned char*)it->c_str()+i, 1);
    }
  }
  md5s->a.Final();
  md5s->b.Final();
  md5s->c.Final();
  md5s->d.Final();
}
Esempio n. 23
0
void Inkscape::LineSnapper::freeSnap(SnappedConstraints &sc,
                                                    Inkscape::SnapCandidatePoint const &p,
                                                    Geom::OptRect const &/*bbox_to_snap*/,
                                                    std::vector<SPItem const *> const */*it*/,
                                                    std::vector<Inkscape::SnapCandidatePoint> */*unselected_nodes*/) const
{
    if (!(_snap_enabled && _snapmanager->snapprefs.getSnapFrom(p.getSourceType())) ) {
        return;
    }

    /* Get the lines that we will try to snap to */
    const LineList lines = _getSnapLines(p.getPoint());

    for (LineList::const_iterator i = lines.begin(); i != lines.end(); i++) {
        Geom::Point const p1 = i->second; // point at guide/grid line
        Geom::Point const p2 = p1 + Geom::rot90(i->first); // 2nd point at guide/grid line
        // std::cout << "  line through " << i->second << " with normal " << i->first;
        g_assert(i->first != Geom::Point(0,0)); // we cannot project on an linesegment of zero length

        Geom::Point const p_proj = Geom::projection(p.getPoint(), Geom::Line(p1, p2));
        Geom::Coord const dist = Geom::L2(p_proj - p.getPoint());
        //Store any line that's within snapping range
        if (dist < getSnapperTolerance()) {
            _addSnappedLine(sc, p_proj, dist, p.getSourceType(), p.getSourceNum(), i->first, i->second);
            // For any line that's within range, we will also look at it's "point on line" p1. For guides
            // this point coincides with its origin; for grids this is of no use, but we cannot
            // discern between grids and guides here
            Geom::Coord const dist_p1 = Geom::L2(p1 - p.getPoint());
            if (dist_p1 < getSnapperTolerance()) {
                _addSnappedLinesOrigin(sc, p1, dist_p1, p.getSourceType(), p.getSourceNum(), false);
                // Only relevant for guides; grids don't have an origin per line
                // Therefore _addSnappedLinesOrigin() will only be implemented for guides
            }
            // std::cout << " -> distance = " << dist;
        }
        // std::cout << std::endl;
    }
}
Esempio n. 24
0
void ProcessLine(LineList & theList, char * theData)
{
    char a[100], *b = 0;
    if ( b=strstr(theData, "BUILDMAJORVER") )
        sscanf(b, "%s %d", a, &MajorVersion);

    else if ( b=strstr(theData, "BUILDMINORVER") )
        sscanf(b, "%s %d", a, &MinorVersion);

    else if ( b=strstr(theData, "BUILDSUBVER") )
        sscanf(b, "%s %d", a, &SubVersion);

    else if ( b=strstr(theData, "BUILDNUMBER") )
    {
        sscanf(b, "%s %d", a, &BuildNumber);
        sprintf(theData, "#define BUILDNUMBER %d", ++BuildNumber);
    }
    else if ( b=strstr(theData, "WORDVER") )
    {
        sprintf(theData, "#define WORDVER %d, %d, %d, %d",
                MajorVersion,
                MinorVersion,
                SubVersion,
                BuildNumber);
    }
    else if ( b=strstr(theData, "DOTTEDVER") )
    {
        sprintf(theData, "#define DOTTEDVER \"%d.%d.%d.%d\"",
                MajorVersion,
                MinorVersion,
                SubVersion,
                BuildNumber);
    }
    else if ( b=strstr(theData, "COMMAVER") )
    {
        sprintf(theData, "#define COMMAVER \"%d, %d, %d, %d\"",
                MajorVersion,
                MinorVersion,
                SubVersion,
                BuildNumber);
    }
    else if ( b=strstr(theData, "BUILDSTRING") )
    {
        sprintf(theData, "#define BUILDSTRING \"Build %d\"", BuildNumber);
    }



    theList.push_back(theData);
}
Esempio n. 25
0
void AddGRecordToBuffer(LineList &lines, md5generators_t *md5s)
{
  std::string str;

  str = "G";
  for (int i=0; i<16; i++) str += md5s->a.digestChars[i];
  str += "\r\n";
  str += "G";
  for (int i=0; i<16; i++) str += md5s->a.digestChars[i+16];
  str += "\r\n";
  lines.push_back(str);

  str = "G";
  for (int i=0; i<16; i++) str += md5s->b.digestChars[i];
  str += "\r\n";
  str += "G";
  for (int i=0; i<16; i++) str += md5s->b.digestChars[i+16];
  str += "\r\n";
  lines.push_back(str);

  str = "G";
  for (int i=0; i<16; i++) str += md5s->c.digestChars[i];
  str += "\r\n";
  str += "G";
  for (int i=0; i<16; i++) str += md5s->c.digestChars[i+16];
  str += "\r\n";
  lines.push_back(str);

  str = "G";
  for (int i=0; i<16; i++) str += md5s->d.digestChars[i];
  str += "\r\n";
  str += "G";
  for (int i=0; i<16; i++) str += md5s->d.digestChars[i+16];
  str += "\r\n";
  lines.push_back(str);
  
}
Esempio n. 26
0
	void writeStream(std::ostream &stream, int tabCount)
	{
		for(ValueMap::iterator vi = values.begin(); vi != values.end(); ++vi)
		{
			writeTabs(stream, tabCount);
			stream << (*vi).first << " = " << (*vi).second.first << std::endl;
		}

		for(GroupMap::iterator gi = groups.begin(); gi != groups.end(); ++gi)
		{
			if((gi != groups.begin()) || (!values.empty()))
				stream << std::endl;

			writeTabs(stream, tabCount);
			stream << (*gi).first << std::endl;

			writeTabs(stream, tabCount);
			stream << "{" << std::endl;

			(*gi).second->writeStream(stream, tabCount + 1),
			
			writeTabs(stream, tabCount);
			stream << "}" << std::endl;			
		}

		if(!lines.empty() && ((!groups.empty() || !values.empty())))
			stream << std::endl;

		for(LineList::iterator li = lines.begin(); li != lines.end(); ++li)
		{
			writeTabs(stream, tabCount);

			std::string &f = (*li);
			stream << (*li) << std::endl;
		}
	}
Esempio n. 27
0
	void parseValue(const std::string string, int flags)
	{
		std::string name;
		std::string value;

		if(string == "{")
			return;
		if(string == "}")
			return;

		splitString(string, name, value, '=');
		if(name.empty() || string[0] == '<')
		{
			if(!string.empty())
				lines.push_back(string);

			return;
		}

		values[name].first = value;
		values[name].second = flags;
	}
Esempio n. 28
0
// insert a new line after the given one or in the very beginning if !pLine
LineList *wxFileConfig::LineListInsert(const wxString& str,
                                                     LineList *pLine)
{
  if ( pLine == m_linesTail )
    return LineListAppend(str);

  LineList *pNewLine = new LineList(str);
  if ( pLine == NULL ) {
    // prepend to the list
    pNewLine->SetNext(m_linesHead);
    m_linesHead->SetPrev(pNewLine);
    m_linesHead = pNewLine;
  }
  else {
    // insert before pLine
    LineList *pNext = pLine->Next();
    pNewLine->SetNext(pNext);
    pNewLine->SetPrev(pLine);
    pNext->SetPrev(pNewLine);
    pLine->SetNext(pNewLine);
  }

  return pNewLine;
}
Esempio n. 29
0
int main(int theArgCount, char ** theArgs)
{
    if (theArgCount == 1)
    {
        cout << "File name must be specified\n";
        return 1;
    }

    ifstream aF( theArgs[1], ios::in );

    if ( !aF.is_open() )
    {
        cout << "File not found\n";
        return 1;
    }

    LineList aVect;

    while (true)
    {
        char aData[500];
        aF.getline(aData, sizeof aData);

        ProcessLine(aVect, aData);

        if ( aF.bad() || aF.eof() ) break;
    }

    aF.close();

    if (BuildNumber == 0)
    {
        cout << "#define BUILDNUMBER string not found\n";
        return 1;
    }

    ofstream aFO(theArgs[1], ios::out|ios::trunc);

    if ( !aFO.is_open() )
    {
        cout << "Could not write data back to file\n";
        return 1;
    }



    bool aNewLine = false;
    for (LineIter aIt = aVect.begin(); aIt != aVect.end(); aIt++)
    {
        if (aNewLine)
            aFO << endl;

        aFO << *aIt;

        aNewLine = true;
    }

    aFO.close();

    cout << "Success\n";
    return 0;
}
Esempio n. 30
0
void Inkscape::LineSnapper::constrainedSnap(IntermSnapResults &isr,
                                               Inkscape::SnapCandidatePoint const &p,
                                               Geom::OptRect const &/*bbox_to_snap*/,
                                               SnapConstraint const &c,
                                               std::vector<SPItem const *> const */*it*/,
                                               std::vector<SnapCandidatePoint> */*unselected_nodes*/) const

{
    if (_snap_enabled == false || _snapmanager->snapprefs.isSourceSnappable(p.getSourceType()) == false) {
        return;
    }

    // project the mouse pointer onto the constraint. Only the projected point will be considered for snapping
    Geom::Point pp = c.projection(p.getPoint());

    /* Get the lines that we will try to snap to */
    const LineList lines = _getSnapLines(pp);

    for (LineList::const_iterator i = lines.begin(); i != lines.end(); ++i) {
        Geom::Point const point_on_line = c.hasPoint() ? c.getPoint() : pp;
        Geom::Line gridguide_line(i->second, i->second + Geom::rot90(i->first));

        if (c.isCircular()) {
            // Find the intersections between the line and the circular constraint
            // First, project the origin of the circle onto the line
            Geom::Point const origin = c.getPoint();
            Geom::Point const p_proj = Geom::projection(origin, gridguide_line);
            Geom::Coord dist = Geom::L2(p_proj - origin); // distance from circle origin to constraint line
            Geom::Coord radius = c.getRadius();
            if (dist == radius) {
                // Only one point of intersection;
                _addSnappedPoint(isr, p_proj, Geom::L2(pp - p_proj), p.getSourceType(), p.getSourceNum(), true);
            } else if (dist < radius) {
                // Two points of intersection, symmetrical with respect to the projected point
                // Calculate half the length of the linesegment between the two points of intersection
                Geom::Coord l = sqrt(radius*radius - dist*dist);
                Geom::Coord d = Geom::L2(gridguide_line.versor()); // length of versor, needed to normalize the versor
                if (d > 0) {
                    Geom::Point v = l*gridguide_line.versor()/d;
                    _addSnappedPoint(isr, p_proj + v, Geom::L2(p.getPoint() - (p_proj + v)), p.getSourceType(), p.getSourceNum(), true);
                    _addSnappedPoint(isr, p_proj - v, Geom::L2(p.getPoint() - (p_proj - v)), p.getSourceType(), p.getSourceNum(), true);
                }
            }
        } else {
            // Find the intersections between the line and the linear constraint
            Geom::Line constraint_line(point_on_line, point_on_line + c.getDirection());
            Geom::OptCrossing inters = Geom::OptCrossing(); // empty by default
            try
            {
                inters = Geom::intersection(constraint_line, gridguide_line);
            }
            catch (Geom::InfiniteSolutions &e)
            {
                // We're probably dealing with parallel lines, so snapping doesn't make any sense here
                continue; // jump to the next iterator in the for-loop
            }

            if (inters) {
                Geom::Point t = constraint_line.pointAt((*inters).ta);
                const Geom::Coord dist = Geom::L2(t - p.getPoint());
                if (dist < getSnapperTolerance()) {
                    // When doing a constrained snap, we're already at an intersection.
                    // This snappoint is therefore fully constrained, so there's no need
                    // to look for additional intersections; just return the snapped point
                    // and forget about the line
                    _addSnappedPoint(isr, t, dist, p.getSourceType(), p.getSourceNum(), true);
                }
            }
        }
    }
}