Changeset 28:fa28f1071bd6 in glemon-0.x
- Timestamp:
- 06/24/05 20:16:12 (20 years ago)
- Branch:
- gui
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@1996
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile.am
r27 r28 8 8 graph_displayer_canvas.cc \ 9 9 graph_displayer_canvas-edge.cc \ 10 graph_displayer_canvas-node.cc \ 10 11 graph_displayer_canvas-event.cc \ 11 12 graph_displayer_canvas-zoom.cc \ -
all_include.h
r23 r28 17 17 #include <lemon/xy.h> 18 18 19 enum {WIDTH, COLOR, TEXT, PROPERTY_NUM}; // edge properties; 19 enum {E_WIDTH, E_COLOR, E_TEXT, EDGE_PROPERTY_NUM}; // edge properties; 20 enum {N_RADIUS, N_COLOR, N_TEXT, NODE_PROPERTY_NUM}; // node properties; 20 21 enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, EDGE_MAP_EDIT, TOOL_NUM}; // tools; 21 22 #define RANGE 3 … … 25 26 26 27 #ifndef MAIN_PART 27 extern std::vector <std::string> property_strings; 28 extern std::vector <double> property_defaults; 28 extern std::vector <std::string> edge_property_strings; 29 extern std::vector <double> edge_property_defaults; 30 extern std::vector <std::string> node_property_strings; 31 extern std::vector <double> node_property_defaults; 29 32 #endif //MAIN_PART 30 33 -
graph-displayer.cc
r24 r28 7 7 #define MAIN_PART 8 8 9 std::vector <std::string> property_strings; 10 std::vector <double> property_defaults; 9 std::vector <std::string> edge_property_strings; 10 std::vector <double> edge_property_defaults; 11 std::vector <std::string> node_property_strings; 12 std::vector <double> node_property_defaults; 11 13 12 14 … … 16 18 //initializing 17 19 18 property_strings.resize(PROPERTY_NUM);19 property_strings[WIDTH]="Width";20 property_strings[COLOR]="Color";21 property_strings[TEXT]="Text";20 edge_property_strings.resize(EDGE_PROPERTY_NUM); 21 edge_property_strings[E_WIDTH]="Edge Width"; 22 edge_property_strings[E_COLOR]="Edge Color"; 23 edge_property_strings[E_TEXT]="Edge Text"; 22 24 23 property_defaults.resize(PROPERTY_NUM); 24 property_defaults[WIDTH]=10.0; 25 property_defaults[COLOR]=100; 26 property_defaults[TEXT]=0; 25 edge_property_defaults.resize(EDGE_PROPERTY_NUM); 26 edge_property_defaults[E_WIDTH]=10.0; 27 edge_property_defaults[E_COLOR]=100; 28 edge_property_defaults[E_TEXT]=0; 29 30 node_property_strings.resize(NODE_PROPERTY_NUM); 31 node_property_strings[N_RADIUS]="Node Radius"; 32 node_property_strings[N_COLOR]="Node Color"; 33 node_property_strings[N_TEXT]="Node Text"; 34 35 node_property_defaults.resize(NODE_PROPERTY_NUM); 36 node_property_defaults[N_RADIUS]=20.0; 37 node_property_defaults[N_COLOR]=100; 38 node_property_defaults[N_TEXT]=0; 27 39 28 40 if(argc<2) -
graph_displayer_canvas-edge.cc
r27 r28 4 4 5 5 6 int GraphDisplayerCanvas::change LineWidth (std::string mapname)6 int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Graph::Edge edge) 7 7 { 8 for (EdgeIt i(g); i!=INVALID; ++i)8 if(edge==INVALID) 9 9 { 10 int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i]; 10 for (EdgeIt i(g); i!=INVALID; ++i) 11 { 12 int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i]; 13 if(w>=0) 14 { 15 edgesmap[i]->property_width_pixels().set_value(w); 16 } 17 } 18 } 19 else 20 { 21 int w=(int)(*(mapstorage.edgemap_storage)[mapname])[edge]; 11 22 if(w>=0) 12 23 { 13 edgesmap[ i]->property_width_pixels().set_value(w);24 edgesmap[edge]->property_width_pixels().set_value(w); 14 25 } 15 26 } … … 17 28 }; 18 29 19 int GraphDisplayerCanvas::change Color (std::string mapname)30 int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Graph::Edge edge) 20 31 { 21 32 … … 23 34 //the minimum of the nodemap to the range of 24 35 //green in RGB 36 if(edge==INVALID) 37 { 25 38 26 for (EdgeIt i(g); i!=INVALID; ++i)27 28 29 30 39 for (EdgeIt i(g); i!=INVALID; ++i) 40 { 41 double w=(*(mapstorage.edgemap_storage)[mapname])[i]; 42 double max=mapstorage.maxOfEdgeMap(mapname); 43 double min=mapstorage.minOfEdgeMap(mapname); 31 44 32 //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl; 33 Gdk::Color color; 34 if(max!=min) 45 //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl; 46 Gdk::Color color; 47 if(max!=min) 48 { 49 color.set_rgb_p (0, 100*(w-min)/(max-min), 0); 50 } 51 else 52 { 53 color.set_rgb_p (0, 100, 0); 54 } 55 56 edgesmap[i]->property_fill_color_gdk().set_value(color); 57 } 58 } 59 else 35 60 { 36 color.set_rgb_p (0, 100*(w-min)/(max-min), 0); 61 double w=(*(mapstorage.edgemap_storage)[mapname])[edge]; 62 double max=mapstorage.maxOfEdgeMap(mapname); 63 double min=mapstorage.minOfEdgeMap(mapname); 64 65 //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl; 66 Gdk::Color color; 67 if(max!=min) 68 { 69 color.set_rgb_p (0, 100*(w-min)/(max-min), 0); 70 } 71 else 72 { 73 color.set_rgb_p (0, 100, 0); 74 } 75 76 edgesmap[edge]->property_fill_color_gdk().set_value(color); 37 77 } 38 else39 {40 color.set_rgb_p (0, 100, 0);41 }42 43 edgesmap[i]->property_fill_color_gdk().set_value(color);44 }45 78 return 0; 46 79 }; 47 80 48 int GraphDisplayerCanvas::change Text (std::string mapname)81 int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Graph::Edge edge) 49 82 { 50 83 … … 55 88 //\todo isn't it a bit woodcutter? 56 89 57 for (EdgeIt i(g); i!=INVALID; ++i)90 if(edge==INVALID) 58 91 { 59 if(mapname!="Text")92 for (EdgeIt i(g); i!=INVALID; ++i) 60 93 { 61 double number=(*(mapstorage.edgemap_storage)[mapname])[i]; 94 if(mapname!=edge_property_strings[E_TEXT]) 95 { 96 double number=(*(mapstorage.edgemap_storage)[mapname])[i]; 97 int length=1; 98 //if number is smaller than one, length would be negative, or invalid 99 if(number>=1) 100 { 101 length=(int)(floor(log(number)/log(10)))+1; 102 } 103 int maxpos=(int)(pow(10,length-1)); 104 int strl=length+1+RANGE; 105 char * str=new char[strl]; 106 str[length]='.'; 107 str[strl]='\0'; 108 109 for(int j=0;j<strl;j++) 110 { 111 if(j!=length) 112 { 113 int digit=(int)(number/maxpos); 114 str[j]=(digit+'0'); 115 number-=digit*maxpos; 116 number*=10; 117 } 118 } 119 120 edgetextmap[i]->property_text().set_value(str); 121 } 122 else 123 { 124 edgetextmap[i]->property_text().set_value(""); 125 } 126 } 127 128 } 129 else 130 { 131 if(mapname!=edge_property_strings[E_TEXT]) 132 { 133 double number=(*(mapstorage.edgemap_storage)[mapname])[edge]; 62 134 int length=1; 63 135 //if number is smaller than one, length would be negative, or invalid … … 83 155 } 84 156 85 edgetextmap[ i]->property_text().set_value(str);157 edgetextmap[edge]->property_text().set_value(str); 86 158 } 87 159 else 88 160 { 89 edgetextmap[ i]->property_text().set_value("");161 edgetextmap[edge]->property_text().set_value(""); 90 162 } 163 91 164 } 165 92 166 return 0; 167 93 168 }; -
graph_displayer_canvas-event.cc
r27 r28 100 100 double dy=e->motion.y-clicked_y; 101 101 102 //repositioning node and its text 102 103 active_item->move(dx, dy); 104 nodetextmap[active_node]->move(dx, dy); 103 105 104 106 clicked_x=e->motion.x; … … 130 132 } 131 133 134 //reposition of edgetext 132 135 xy<double> text_pos=edgesmap[ei]->get_arrow_pos(); 133 136 text_pos+=(xy<double>(10,10)); … … 190 193 *(nodesmap[active_node]) << Gnome::Canvas::Properties::outline_color("black"); 191 194 (nodesmap[active_node])->show(); 195 196 nodetextmap[active_node]=new Gnome::Canvas::Text(displayed_graph, clicked_x+node_property_defaults[N_RADIUS]+5, clicked_y+node_property_defaults[N_RADIUS]+5, ""); 197 nodetextmap[active_node]->property_fill_color().set_value("darkblue"); 198 199 mapwin->update_node(active_node); 200 192 201 break; 193 202 … … 273 282 if(target_node!=INVALID) 274 283 { 275 *(nodesmap[target_node]) << Gnome::Canvas::Properties::fill_color("red"); 276 277 //creating new edge 278 active_edge=EdgeIt(g,g.addEdge(active_node, target_node)); 279 280 //initiating values corresponding to new edge in maps 281 mapstorage.init_maps_for_edge(active_edge); 284 if(target_node!=active_node) 285 { 286 *(nodesmap[target_node]) << Gnome::Canvas::Properties::fill_color("red"); 287 288 //creating new edge 289 active_edge=EdgeIt(g,g.addEdge(active_node, target_node)); 290 291 //initiating values corresponding to new edge in maps 292 mapstorage.init_maps_for_edge(active_edge); 282 293 283 //calculating coordinates of new edge284 Gnome::Canvas::Points coos;285 double x1, x2, y1, y2;294 //calculating coordinates of new edge 295 Gnome::Canvas::Points coos; 296 double x1, x2, y1, y2; 286 297 287 active_item->get_bounds(x1, y1, x2, y2); 288 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 289 290 target_item->get_bounds(x1, y1, x2, y2); 291 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 292 293 //drawing new edge 294 edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos, *this); 295 *(edgesmap[active_edge]) << Gnome::Canvas::Properties::fill_color("green"); 296 edgesmap[active_edge]->property_width_pixels().set_value(10); 297 298 //redraw nodes to blank terminations of the new edge 299 target_item->raise_to_top(); 300 active_item->raise_to_top(); 301 302 //initializing edge-text as well, to empty string 303 xy<double> text_pos=edgesmap[active_edge]->get_arrow_pos(); 304 text_pos+=(xy<double>(10,10)); 305 306 edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); 307 edgetextmap[active_edge]->property_fill_color().set_value("black"); 298 active_item->get_bounds(x1, y1, x2, y2); 299 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 300 301 target_item->get_bounds(x1, y1, x2, y2); 302 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 303 304 //drawing new edge 305 edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos, *this); 306 *(edgesmap[active_edge]) << Gnome::Canvas::Properties::fill_color("green"); 307 edgesmap[active_edge]->property_width_pixels().set_value(10); 308 309 //redraw nodes to blank terminations of the new edge 310 target_item->raise_to_top(); 311 active_item->raise_to_top(); 312 313 //initializing edge-text as well, to empty string 314 xy<double> text_pos=edgesmap[active_edge]->get_arrow_pos(); 315 text_pos+=(xy<double>(10,10)); 316 317 edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); 318 edgetextmap[active_edge]->property_fill_color().set_value("darkgreen"); 319 320 //updating its properties 321 mapwin->update_edge(active_edge); 322 } 323 else 324 { 325 target_node=INVALID; 326 std::cout << "Loop edge is not yet implemented!" << std::endl; 327 } 308 328 } 309 329 //clicked item was not a node. it could be an e.g. edge. we do not deal with it furthermore. … … 436 456 void GraphDisplayerCanvas::delete_item(NodeIt node_to_delete) 437 457 { 458 delete(nodetextmap[node_to_delete]); 438 459 delete(nodesmap[node_to_delete]); 439 460 g.erase(node_to_delete); … … 442 463 void GraphDisplayerCanvas::delete_item(EdgeIt edge_to_delete) 443 464 { 465 delete(edgetextmap[edge_to_delete]); 444 466 delete(edgesmap[edge_to_delete]); 445 467 g.erase(edge_to_delete); … … 448 470 void GraphDisplayerCanvas::delete_item(Graph::Edge edge_to_delete) 449 471 { 472 delete(edgetextmap[edge_to_delete]); 450 473 delete(edgesmap[edge_to_delete]); 451 474 g.erase(edge_to_delete); -
graph_displayer_canvas.cc
r27 r28 3 3 #include <math.h> 4 4 5 GraphDisplayerCanvas::GraphDisplayerCanvas(Graph & gr, CoordinatesMap & cm, MapStorage & ms ):g(gr),nodesmap(g),edgesmap(g),edgetextmap(g),displayed_graph(*(root()), 0, 0),mapstorage(ms),isbutton(0),active_item(NULL),target_item(NULL)5 GraphDisplayerCanvas::GraphDisplayerCanvas(Graph & gr, CoordinatesMap & cm, MapStorage & ms, MapWin * mw):g(gr),nodesmap(g),edgesmap(g),edgetextmap(g),nodetextmap(g),displayed_graph(*(root()), 0, 0),mapstorage(ms),isbutton(0),active_item(NULL),target_item(NULL),mapwin(mw) 6 6 { 7 7 … … 35 35 36 36 edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); 37 edgetextmap[i]->property_fill_color().set_value(" black");37 edgetextmap[i]->property_fill_color().set_value("darkgreen"); 38 38 } 39 39 … … 57 57 *(nodesmap[i]) << Gnome::Canvas::Properties::fill_color("blue"); 58 58 *(nodesmap[i]) << Gnome::Canvas::Properties::outline_color("black"); 59 //!!!!!!! (nodesmap[i])->signal_event().connect(sigc::bind(sigc::mem_fun(*this, &GraphDisplayerCanvas::event_handler),i)); 59 60 //initializing edge-text as well, to empty string 61 62 xy<double> text_pos((cm[i].x+node_property_defaults[N_RADIUS]+5),(cm[i].y+node_property_defaults[N_RADIUS]+5)); 63 64 nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); 65 nodetextmap[i]->property_fill_color().set_value("darkblue"); 60 66 } 61 67 -
graph_displayer_canvas.h
r25 r28 7 7 8 8 #include <all_include.h> 9 #include <map_win.h> 9 10 #include <mapstorage.h> 10 11 #include <broken_edge.h> … … 18 19 19 20 public: 20 GraphDisplayerCanvas(Graph &, CoordinatesMap &, MapStorage & );21 GraphDisplayerCanvas(Graph &, CoordinatesMap &, MapStorage &, MapWin *); 21 22 virtual ~GraphDisplayerCanvas(); 22 23 23 24 ///Changes the linewidth attribute according to the given map. 24 25 ///\param mapname is the name of the map which contains the new values 25 int change LineWidth (std::string mapname);26 int changeEdgeWidth (std::string mapname, Graph::Edge new_item=INVALID); 26 27 27 28 ///Changes the linecolor attribute according to the given map. 28 29 ///\param mapname is the name of the map which contains the new values 29 int change Color (std::string mapname);30 int changeEdgeColor (std::string mapname, Graph::Edge new_item=INVALID); 30 31 31 32 ///Changes the text of line attribute according to the given map. 32 33 ///\param mapname is the name of the map which contains the new values 33 int changeText (std::string mapname); 34 int changeEdgeText (std::string mapname, Graph::Edge new_item=INVALID); 35 36 ///Changes the linewidth attribute according to the given map. 37 ///\param mapname is the name of the map which contains the new values 38 int changeNodeRadius (std::string mapname, Graph::Node new_item=INVALID); 39 40 ///Changes the linecolor attribute according to the given map. 41 ///\param mapname is the name of the map which contains the new values 42 int changeNodeColor (std::string mapname, Graph::Node new_item=INVALID); 43 44 ///Changes the text of line attribute according to the given map. 45 ///\param mapname is the name of the map which contains the new values 46 int changeNodeText (std::string mapname, Graph::Node new_item=INVALID); 34 47 35 48 ///Callback for 'ViewZoomIn' action. … … 108 121 Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap; 109 122 123 ///Map of texts to write on nodes 124 Graph::NodeMap<Gnome::Canvas::Text *> nodetextmap; 125 110 126 ///Group of graphical elements of displayed_graph 111 127 Gnome::Canvas::Group displayed_graph; … … 134 150 static const int zoom_step = 5; 135 151 152 ///We need to store mapwin, to be able to ask the appropriate values for properties of new items. 153 MapWin * mapwin; 154 136 155 }; 137 156 -
main_win.cc
r22 r28 2 2 3 3 MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm, 4 MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),editwin("Editorial Window", gd_canvas),gd_canvas(graph, cm, ms )4 MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),editwin("Editorial Window", gd_canvas),gd_canvas(graph, cm, ms, &mapwin) 5 5 { 6 6 set_title (title); -
map_win.cc
r8 r28 11 11 } 12 12 13 MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst) ,table(PROPERTY_NUM, 2, false)13 MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst) 14 14 { 15 15 set_title(title); … … 18 18 signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::close_if_escape_is_pressed)); 19 19 20 combo_array=new Gtk::Combo [PROPERTY_NUM]; 21 22 for(int i=0;i<PROPERTY_NUM;i++) 20 e_combo_array=new Gtk::Combo [EDGE_PROPERTY_NUM]; 21 22 table=new Gtk::Table(EDGE_PROPERTY_NUM, 2, false); 23 24 for(int i=0;i<EDGE_PROPERTY_NUM;i++) 23 25 { 24 26 … … 36 38 actprop=j; 37 39 } 38 //th is is the other mapsto show for this property39 for(int k=0;k< PROPERTY_NUM;k++)40 //these are the maps NOT to show for this property 41 for(int k=0;k<EDGE_PROPERTY_NUM;k++) 40 42 { 41 43 if(emsi->second==&(ms.default_edgemaps[k])) … … 46 48 emsi++; 47 49 } 48 49 //combo_array[i].set_group(group);50 50 51 51 //filling in combo box with choices … … 65 65 } 66 66 67 combo_array[i].set_popdown_strings(listStrings);67 e_combo_array[i].set_popdown_strings(listStrings); 68 68 69 69 //Restrict it to these choices only: 70 combo_array[i].set_value_in_list();71 72 //binding signal to the wactual entry73 combo_array[i].get_entry()->signal_changed().connect70 e_combo_array[i].set_value_in_list(); 71 72 //binding signal to the actual entry 73 e_combo_array[i].get_entry()->signal_changed().connect 74 74 ( 75 75 sigc::bind 76 76 ( 77 sigc::mem_fun(*this, &MapWin:: combo_changed),77 sigc::mem_fun(*this, &MapWin::e_combo_changed), 78 78 i 79 79 ) … … 83 83 84 84 label=new Gtk::Label; 85 label->set_text(property_strings[i]); 86 87 // labelpluscombo=new Gtk::HBox; 88 // labelpluscombo->pack_start(*label); 89 // labelpluscombo->pack_start(combo_array[i]); 85 label->set_text(edge_property_strings[i]); 90 86 91 table.attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); 92 table.attach(combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); 93 94 /* 95 if(actpos<(ms.numOfEdgeMaps()-PROPERTY_NUM+1)/2) 96 { 97 vbox_r1.pack_start(*labelpluscombo); 98 } 99 else 100 { 101 vbox_r2.pack_start(*labelpluscombo); 102 } 103 actpos++; 104 //*/ 105 106 } 107 108 combos.pack_start(vbox_r1); 109 combos.pack_start(vbox_r2); 110 111 //add(combos); 112 add(table); 87 (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); 88 (*table).attach(e_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); 89 90 91 } 92 93 vbox.pack_start(*(new Gtk::Label("Edge properties"))); 94 95 vbox.pack_start(*table); 96 97 vbox.pack_start(*(new Gtk::HSeparator)); 98 99 n_combo_array=new Gtk::Combo [NODE_PROPERTY_NUM]; 100 101 table=new Gtk::Table(NODE_PROPERTY_NUM, 2, false); 102 103 for(int i=0;i<NODE_PROPERTY_NUM;i++) 104 { 105 106 std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps(); 107 std::set<int> props; 108 109 int actprop; 110 111 //here we find out, which map is the default in MapStorage for this property, which are not 112 for(int j=0;j<ms.numOfNodeMaps();j++) 113 { 114 //these are the maps NOT to show for this property 115 if(emsi->second==&(ms.default_nodemaps[i])) 116 { 117 actprop=j; 118 } 119 //this is the other maps to show for this property 120 for(int k=0;k<NODE_PROPERTY_NUM;k++) 121 { 122 if(emsi->second==&(ms.default_nodemaps[k])) 123 { 124 props.insert(j); 125 } 126 } 127 emsi++; 128 } 129 130 //filling in combo box with choices 131 std::list<Glib::ustring> listStrings; 132 133 listStrings.push_back("Default"); 134 135 emsi=ms.beginOfNodeMaps(); 136 137 for(int j=0;j<ms.numOfNodeMaps();j++) 138 { 139 if( ( props.find(j) )==( props.end() ) ) 140 { 141 listStrings.push_back(emsi->first); 142 } 143 emsi++; 144 } 145 146 n_combo_array[i].set_popdown_strings(listStrings); 147 148 //Restrict it to these choices only: 149 n_combo_array[i].set_value_in_list(); 150 151 //binding signal to thew actual entry 152 n_combo_array[i].get_entry()->signal_changed().connect 153 ( 154 sigc::bind 155 ( 156 sigc::mem_fun(*this, &MapWin::n_combo_changed), 157 i 158 ) 159 ); 160 161 //placing actual entry in the right place 162 163 label=new Gtk::Label; 164 label->set_text(node_property_strings[i]); 165 166 (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); 167 (*table).attach(n_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); 168 169 170 } 171 172 add(vbox); 173 174 vbox.pack_start(*(new Gtk::Label("Node properties"))); 175 176 vbox.pack_start(*table); 113 177 114 178 show_all_children(); … … 116 180 } 117 181 118 void MapWin::combo_changed(int prop) 119 { 120 121 //most nem kommentezem fel, mert ugyis valtozik 122 Gtk::Entry* entry = combo_array[prop].get_entry(); 182 void MapWin::e_combo_changed(int prop) 183 { 184 Gtk::Entry* entry = e_combo_array[prop].get_entry(); 123 185 124 186 if(entry) … … 129 191 if(mapname=="Default") 130 192 { 131 mapname= property_strings[prop];193 mapname=edge_property_strings[prop]; 132 194 } 133 195 … … 136 198 switch(prop) 137 199 { 138 case WIDTH:139 gdc.change LineWidth(mapname);140 break; 141 case COLOR:142 gdc.change Color(mapname);143 break; 144 case TEXT:145 gdc.change Text(mapname);200 case E_WIDTH: 201 gdc.changeEdgeWidth(mapname); 202 break; 203 case E_COLOR: 204 gdc.changeEdgeColor(mapname); 205 break; 206 case E_TEXT: 207 gdc.changeEdgeText(mapname); 146 208 break; 147 209 default: … … 152 214 } 153 215 }; 216 217 void MapWin::n_combo_changed(int prop) 218 { 219 220 Gtk::Entry* entry = n_combo_array[prop].get_entry(); 221 222 if(entry) 223 { 224 Glib::ustring mapname = entry->get_text(); 225 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. 226 { 227 if(mapname=="Default") 228 { 229 mapname=node_property_strings[prop]; 230 } 231 232 if( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) 233 { 234 switch(prop) 235 { 236 case N_RADIUS: 237 gdc.changeNodeRadius(mapname); 238 break; 239 case N_COLOR: 240 gdc.changeNodeColor(mapname); 241 break; 242 case N_TEXT: 243 gdc.changeNodeText(mapname); 244 break; 245 default: 246 std::cout<<"Error\n"; 247 } 248 } 249 } 250 } 251 }; 252 253 void MapWin::update_node(Graph::Node node) 254 { 255 for(int i=0;i<NODE_PROPERTY_NUM;i++) 256 { 257 Gtk::Entry* entry = n_combo_array[i].get_entry(); 258 259 if(entry) 260 { 261 Glib::ustring mapname = entry->get_text(); 262 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. 263 { 264 if(mapname=="Default") 265 { 266 mapname=node_property_strings[i]; 267 } 268 269 if( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) 270 { 271 switch(i) 272 { 273 case N_RADIUS: 274 //gdc.changeNodeRadius(mapname, node); 275 std::cout << "If default map-value problem is solved, uncomment line in MapWin::node_update!" << std::endl; 276 break; 277 case N_COLOR: 278 gdc.changeNodeColor(mapname, node); 279 break; 280 case N_TEXT: 281 gdc.changeNodeText(mapname, node); 282 break; 283 default: 284 std::cout<<"Error\n"; 285 } 286 } 287 } 288 } 289 } 290 } 291 292 void MapWin::update_edge(Graph::Edge edge) 293 { 294 for(int i=0;i<EDGE_PROPERTY_NUM;i++) 295 { 296 297 Gtk::Entry* entry = e_combo_array[i].get_entry(); 298 299 if(entry) 300 { 301 Glib::ustring mapname = entry->get_text(); 302 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. 303 { 304 if(mapname=="Default") 305 { 306 mapname=edge_property_strings[i]; 307 } 308 309 if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) 310 { 311 switch(i) 312 { 313 case E_WIDTH: 314 //gdc.changeEdgeWidth(mapname, edge); 315 std::cout << "If default map-value problem is solved, uncomment line in MapWin::edge_update!" << std::endl; 316 break; 317 case E_COLOR: 318 gdc.changeEdgeColor(mapname, edge); 319 break; 320 case E_TEXT: 321 gdc.changeEdgeText(mapname, edge); 322 break; 323 default: 324 std::cout<<"Error\n"; 325 } 326 } 327 } 328 } 329 } 330 } -
map_win.h
r8 r28 3 3 #ifndef MAP_WIN_H 4 4 #define MAP_WIN_H 5 6 class MapWin; 5 7 6 8 #include <all_include.h> … … 25 27 MapStorage & ms; 26 28 27 Gtk::Table table;29 Gtk::Table * table; 28 30 29 Gtk::HBox combos, * labelpluscombo; 30 Gtk::Combo * combo_array; 31 32 Gtk::VBox vbox_b, vbox_r1, vbox_r2; 31 Gtk::Combo * e_combo_array, * n_combo_array; 33 32 34 33 Gtk::Label * label; 34 35 Gtk::VBox vbox; 35 36 36 37 public: … … 42 43 ///appropriate function of the \ref GraphDisplayerCanvas 43 44 ///to change the visible values of that attribute. 44 virtual void combo_changed(int); 45 virtual void e_combo_changed(int); 46 ///If a radiobutton is clicked, this function determines 47 ///which button was that and after that calls the 48 ///appropriate function of the \ref GraphDisplayerCanvas 49 ///to change the visible values of that attribute. 50 virtual void n_combo_changed(int); 51 52 ///This function is created to set the appropriate maps on the newly created node 53 void update_node(Graph::Node); 54 55 ///This function is created to set the appropriate maps on the newly created edge 56 void update_edge(Graph::Edge); 57 45 58 virtual bool close_if_escape_is_pressed(GdkEventKey*); 46 59 }; -
mapstorage.cc
r26 r28 3 3 MapStorage::MapStorage(Graph & graph):g(graph) 4 4 { 5 for(int i=0;i< PROPERTY_NUM;i++)5 for(int i=0;i<EDGE_PROPERTY_NUM;i++) 6 6 { 7 Graph::EdgeMap<double> emd(g );7 Graph::EdgeMap<double> emd(g,edge_property_defaults[i]); 8 8 default_edgemaps.push_back(emd); 9 Graph::NodeMap<double> nmd(g); 9 } 10 11 for(int i=0;i<NODE_PROPERTY_NUM;i++) 12 { 13 Graph::NodeMap<double> nmd(g,node_property_defaults[i]); 10 14 default_nodemaps.push_back(nmd); 11 15 } 12 for(int i=0;i<PROPERTY_NUM;i++) 16 17 for(int i=0;i<EDGE_PROPERTY_NUM;i++) 13 18 { 14 19 for (EdgeIt j(g); j!=INVALID; ++j) 15 20 { 16 (default_edgemaps[i])[j]= property_defaults[i];21 (default_edgemaps[i])[j]=edge_property_defaults[i]; 17 22 } 18 addEdgeMap(property_strings[i],&(default_edgemaps[i])); 23 addEdgeMap(edge_property_strings[i],&(default_edgemaps[i])); 24 } 25 26 for(int i=0;i<NODE_PROPERTY_NUM;i++) 27 { 28 for (NodeIt j(g); j!=INVALID; ++j) 29 { 30 (default_nodemaps[i])[j]=node_property_defaults[i]; 31 } 32 addNodeMap(node_property_strings[i],&(default_nodemaps[i])); 19 33 } 20 34 … … 100 114 101 115 // g_closure_invoke... 102 // for(int i=0;i< PROPERTY_NUM;i++)116 // for(int i=0;i<EDGE_PROPERTY_NUM;i++) 103 117 // { 104 118 // (default_edgemaps[i])[e]=property_defaults[i];
Note: See TracChangeset
for help on using the changeset viewer.