src/gui/map_win.cc
changeset 1412 c7fab5a1174a
equal deleted inserted replaced
-1:000000000000 0:d32fd9595beb
       
     1 #include <map_win.h>
       
     2 #include <set>
       
     3 
       
     4 MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)
       
     5 {
       
     6   set_title(title);
       
     7   set_default_size(400, 200);
       
     8 
       
     9   rb_array=new Gtk::RadioButton * [PROPERTY_NUM];
       
    10   vbox_r1=new Gtk::VBox[PROPERTY_NUM];
       
    11   vbox_r2=new Gtk::VBox[PROPERTY_NUM];
       
    12   radios=new Gtk::HBox[PROPERTY_NUM];
       
    13   for(int i=0;i<PROPERTY_NUM;i++)
       
    14   {
       
    15     rb_array[i]=new Gtk::RadioButton[ms.numOfEdgeMaps()+1];
       
    16 
       
    17     Gtk::RadioButton::Group group;
       
    18 
       
    19     std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
       
    20     std::set<int> props;
       
    21 
       
    22     int actprop;
       
    23     for(int j=0;j<ms.numOfEdgeMaps();j++)
       
    24     {
       
    25 
       
    26       if(emsi->second==&(ms.default_edgemaps[i]))
       
    27       {
       
    28 	actprop=j;
       
    29       }
       
    30       for(int k=0;k<PROPERTY_NUM;k++)
       
    31       {
       
    32 	if(emsi->second==&(ms.default_edgemaps[k]))
       
    33 	{
       
    34 	  props.insert(j);
       
    35 	}
       
    36       }
       
    37       emsi++;
       
    38     }
       
    39 
       
    40     rb_array[i][0].set_group(group);
       
    41     rb_array[i][0].set_label("Default");
       
    42     rb_array[i][0].signal_clicked().connect( sigc::bind( sigc::bind( sigc::mem_fun(*this, &MapWin::radio_click), 0), i) );
       
    43     vbox_r1[i].pack_start(rb_array[i][0]);
       
    44 
       
    45 
       
    46     emsi=ms.beginOfEdgeMaps();
       
    47     int actpos=1;
       
    48     for(int j=0;j<ms.numOfEdgeMaps();j++)
       
    49     {
       
    50       if( ( props.find(j) )==( props.end() ) )
       
    51       {
       
    52 	rb_array[i][actpos].set_group(group);
       
    53 	rb_array[i][actpos].set_label(emsi->first);
       
    54 	rb_array[i][actpos].signal_clicked().connect
       
    55 	  (
       
    56 	   sigc::bind( 
       
    57 	    sigc::bind(
       
    58 	     sigc::mem_fun(*this, &MapWin::radio_click),
       
    59 	     actpos
       
    60 	    ),
       
    61 	    i
       
    62 	   ) 
       
    63 	  );
       
    64 
       
    65     	if(actpos<(ms.numOfEdgeMaps()-PROPERTY_NUM+1)/2)
       
    66         {
       
    67           vbox_r1[i].pack_start(rb_array[i][actpos]);
       
    68 	}
       
    69 	else
       
    70         {
       
    71 	  vbox_r2[i].pack_start(rb_array[i][actpos]);
       
    72 	}
       
    73 	actpos++;
       
    74       }
       
    75       emsi++;
       
    76     }
       
    77     radios[i].pack_start(vbox_r1[i]);
       
    78     radios[i].pack_start(vbox_r2[i]);
       
    79     notebook.append_page(radios[i], property_strings[i]);
       
    80   }
       
    81 
       
    82   add(vbox_b);
       
    83   vbox_b.pack_start(notebook);
       
    84 
       
    85   show_all_children();
       
    86 
       
    87 }
       
    88 
       
    89 void MapWin::radio_click(int prop, int actpos)
       
    90 {
       
    91   if(rb_array[prop][actpos].get_active())
       
    92   {
       
    93 
       
    94     std::string mapname=rb_array[prop][actpos].get_label();
       
    95 
       
    96     if(mapname=="Default")
       
    97     {
       
    98       mapname=property_strings[prop];
       
    99     }
       
   100 
       
   101     switch(prop)
       
   102     {
       
   103       case WIDTH:
       
   104         gdc.changeLineWidth(mapname);
       
   105         break;
       
   106       case COLOR:
       
   107         gdc.changeColor(mapname);
       
   108         break;
       
   109       case TEXT:
       
   110         gdc.changeText(mapname);
       
   111         break;
       
   112       default:
       
   113         std::cout<<"Error\n";
       
   114     }
       
   115   }
       
   116 };