Empty graph is (strongly) connected.
1 #include <new_map_win.h>
3 bool NewMapWin::closeIfEscapeIsPressed(GdkEventKey* e)
5 if(e->keyval==GDK_Escape)
12 NewMapWin::NewMapWin(const std::string& title, GraphDisplayerCanvas & grdispc):gdc(grdispc),node("Create NodeMap"),edge("Create EdgeMap")
15 set_default_size(200, 50);
17 signal_key_press_event().connect(sigc::mem_fun(*this, &NewMapWin::closeIfEscapeIsPressed));
21 table=new Gtk::Table(3, 2, false);
24 label->set_text("Name of new map:");
27 (*table).attach(*label,0,1,0,1,Gtk::SHRINK,Gtk::SHRINK,10,3);
28 (*table).attach(name,1,2,0,1,Gtk::SHRINK,Gtk::SHRINK,10,3);
31 label->set_text("Default value in the map:");
32 default_value.set_text("0");
34 (*table).attach(*label,0,1,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
35 (*table).attach(default_value,1,2,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
37 //node vs. edge map selector
38 Gtk::RadioButton::Group group = node.get_group();
39 edge.set_group(group);
41 (*table).attach(node,0,1,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3);
42 (*table).attach(edge,1,2,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3);
44 vbox.pack_start(*table);
47 button=new Gtk::Button("OK");
49 button->signal_clicked().connect
51 sigc::mem_fun(*this, &NewMapWin::buttonPressed)
55 vbox.pack_start(*button);
63 void NewMapWin::showByPreChoose(bool itisedge)
78 void NewMapWin::buttonPressed()
80 bool valid_double=true;
83 std::string def_val_str=default_value.get_text();
84 char * def_val_ch=new char [def_val_str.length()];
85 for(int i=0;i<(int)(def_val_str.length());i++)
87 if(((def_val_str[i]<'0')||(def_val_str[i]>'9'))&&(def_val_str[i]!='.'))
93 if(def_val_str[i]=='.')
98 def_val_ch[i]=def_val_str[i];
101 double def_val=atof(def_val_ch);
103 std::string mapname=name.get_text();
105 if((point_num<=1)&&(valid_double)&&(!mapname.empty()))
108 if(edge.get_active())
110 abortion=gdc.addNewEdgeMap(def_val,mapname);
114 abortion=gdc.addNewNodeMap(def_val,mapname);
119 default_value.set_text("0");