gravatar
deba@inf.elte.hu
deba@inf.elte.hu
MinGW compatibility for graph_to_eps.h
0 1 0
default
1 file changed with 23 insertions and 7 deletions:
↑ Collapse diff ↑
Show white space 48 line context
1 1
/* -*- C++ -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library
4 4
 *
5 5
 * Copyright (C) 2003-2008
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_GRAPH_TO_EPS_H
20 20
#define LEMON_GRAPH_TO_EPS_H
21 21

	
22
#include <sys/time.h>
23

	
24
#ifdef WIN32
25
#include <lemon/bits/mingw32_time.h>
26
#endif
27

	
28 22
#include<iostream>
29 23
#include<fstream>
30 24
#include<sstream>
31 25
#include<algorithm>
32 26
#include<vector>
33 27

	
28
#ifndef WIN32
29
#include<sys/time.h>
34 30
#include<ctime>
31
#else
32
#include<windows.h>
33
#endif
35 34

	
36 35
#include<lemon/math.h>
37 36
#include<lemon/bits/invalid.h>
38 37
#include<lemon/dim2.h>
39 38
#include<lemon/maps.h>
40 39
#include<lemon/color.h>
41 40
#include<lemon/bits/bezier.h>
42 41

	
43 42

	
44 43
///\ingroup eps_io
45 44
///\file
46 45
///\brief A well configurable tool for visualizing graphs
47 46

	
48 47
namespace lemon {
49 48

	
50 49
  namespace _graph_to_eps_bits {
51 50
    template<class MT>
52 51
    class _NegY {
53 52
    public:
54 53
      typedef typename MT::Key Key;
55 54
      typedef typename MT::Value Value;
56 55
      const MT &map;
57 56
      int yscale;
58 57
      _NegY(const MT &m,bool b) : map(m), yscale(1-b*2) {}
... ...
@@ -698,53 +697,70 @@
698 697
public:
699 698
  ~GraphToEps() { }
700 699
  
701 700
  ///Draws the graph.
702 701

	
703 702
  ///Like other functions using
704 703
  ///\ref named-templ-func-param "named template parameters",
705 704
  ///this function calls the algorithm itself, i.e. in this case
706 705
  ///it draws the graph.
707 706
  void run() {
708 707
    //\todo better 'epsilon' would be nice here.
709 708
    const double EPSILON=1e-9;
710 709
    if(dontPrint) return;
711 710
    
712 711
    _graph_to_eps_bits::_NegY<typename T::CoordsMapType>
713 712
      mycoords(_coords,_negY);
714 713

	
715 714
    os << "%!PS-Adobe-2.0 EPSF-2.0\n";
716 715
    if(_title.size()>0) os << "%%Title: " << _title << '\n';
717 716
     if(_copyright.size()>0) os << "%%Copyright: " << _copyright << '\n';
718 717
//        << "%%Copyright: XXXX\n"
719 718
    os << "%%Creator: LEMON, graphToEps()\n";
720 719
    
721 720
    {
722
      char cbuf[50];
721
#ifndef WIN32 
723 722
      timeval tv;
724 723
      gettimeofday(&tv, 0);
724

	
725
      char cbuf[26];
725 726
      ctime_r(&tv.tv_sec,cbuf);
726 727
      os << "%%CreationDate: " << cbuf;
728
#else
729
      SYSTEMTIME time;
730
      char buf1[11], buf2[9], buf3[5];
731
      
732
      GetSystemTime(&time);
733
      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time, 
734
			"ddd MMM dd", buf1, 11) &&
735
	  GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time, 
736
			"HH':'mm':'ss", buf2, 9) &&
737
	  GetDateFormat(LOCALE_USER_DEFAULT, 0, &time, 
738
				"yyyy", buf3, 5)) {
739
	os << "%%CreationDate: " << buf1 << ' ' 
740
	   << buf2 << ' ' << buf3 << std::endl;
741
      }	  
742
#endif
727 743
    }
728 744

	
729 745
    if (_autoArcWidthScale) {
730 746
      double max_w=0;
731 747
      for(ArcIt e(g);e!=INVALID;++e)
732 748
	max_w=std::max(double(_arcWidths[e]),max_w);
733 749
      ///\todo better 'epsilon' would be nice here.
734 750
      if(max_w>EPSILON) {
735 751
	_arcWidthScale/=max_w;
736 752
      }
737 753
    }
738 754

	
739 755
    if (_autoNodeScale) {
740 756
      double max_s=0;
741 757
      for(NodeIt n(g);n!=INVALID;++n)
742 758
	max_s=std::max(double(_nodeSizes[n]),max_s);
743 759
      ///\todo better 'epsilon' would be nice here.
744 760
      if(max_s>EPSILON) {
745 761
	_nodeScale/=max_s;
746 762
      }
747 763
    }
748 764

	
749 765
    double diag_len = 1;
750 766
    if(!(_absoluteNodeSizes&&_absoluteArcWidths)) {
0 comments (0 inline)