Changeset 1823:cb082cdf3667 in lemon-0.x
- Timestamp:
- 11/21/05 19:03:20 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2373
- Location:
- gui
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
gui/Doxyfile
r1736 r1823 26 26 INLINE_INHERITED_MEMB = NO 27 27 FULL_PATH_NAMES = YES 28 STRIP_FROM_PATH = /home/alpar/projects/ETIK/hugo/gui/28 STRIP_FROM_PATH = . 29 29 STRIP_FROM_INC_PATH = 30 30 SHORT_NAMES = NO … … 83 83 # configuration options related to the input files 84 84 #--------------------------------------------------------------------------- 85 INPUT = /home/alpar/projects/ETIK/hugo/gui85 INPUT = . 86 86 FILE_PATTERNS = *.c \ 87 87 *.cc \ -
gui/main_win.cc
r1777 r1823 3 3 4 4 MainWin::MainWin() : 5 newmapwin("Creating new map", gd_canvas), 6 mapwin("Map Setup", mapstorage, gd_canvas, newmapwin), 5 mapwin("Map Setup", mapstorage, gd_canvas), 7 6 gd_canvas(mapstorage, mapwin, (Gtk::Window *)this) 8 7 { … … 122 121 123 122 ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")), 124 sigc::mem_fun ( this->newmapwin, &NewMapWin::show ) );123 sigc::mem_fun (new NewMapWin("NewMapWin", gd_canvas), &NewMapWin::show ) ); 125 124 126 125 uim=Gtk::UIManager::create(); -
gui/main_win.h
r1733 r1823 26 26 27 27 protected: 28 ///We need to store newmapwin, to be able to set the appropriate values for properties of new map.29 NewMapWin newmapwin;30 31 28 ///Window of map-showing setup. Its type is \ref MapWin 32 29 MapWin mapwin; -
gui/map_win.cc
r1737 r1823 11 11 } 12 12 13 MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc , NewMapWin & newmapwin):gdc(grdispc),ms(mapst), nmw(newmapwin)13 MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst) 14 14 { 15 15 set_title(title); … … 24 24 for(int i=0;i<EDGE_PROPERTY_NUM;i++) 25 25 { 26 e_combo_array[i]=new MapSelector(gdc, ms, nmw,i, true);26 e_combo_array[i]=new MapSelector(gdc, ms, i, true); 27 27 28 28 (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); … … 41 41 for(int i=0;i<NODE_PROPERTY_NUM;i++) 42 42 { 43 n_combo_array[i]=new MapSelector(gdc, ms, nmw,i, false);43 n_combo_array[i]=new MapSelector(gdc, ms, i, false); 44 44 45 45 (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); -
gui/map_win.h
r1819 r1823 25 25 ///The \ref MapStorage in which the visualizable maps are stored 26 26 MapStorage & ms; 27 NewMapWin & nmw;28 27 29 28 int id; … … 49 48 public: 50 49 51 MapSelector(GraphDisplayerCanvas &, MapStorage &, NewMapWin &,int, bool);50 MapSelector(GraphDisplayerCanvas &, MapStorage &, int, bool); 52 51 53 52 void update_list(); … … 83 82 MapStorage & ms; 84 83 85 NewMapWin & nmw;86 87 84 Gtk::Table * table; 88 85 … … 95 92 public: 96 93 ///Constructor of MapWin creates the widgets shown in MapWin. 97 MapWin(const std::string& title, MapStorage &, GraphDisplayerCanvas & , NewMapWin &);94 MapWin(const std::string& title, MapStorage &, GraphDisplayerCanvas &); 98 95 99 96 ///This function is created to set the appropriate maps on the newly created node -
gui/mw-mapselector.cc
r1819 r1823 1 1 #include "map_win.h" 2 2 3 MapWin::MapSelector::MapSelector(GraphDisplayerCanvas & grdispc, MapStorage & mapst, NewMapWin & newmapw, int identifier, bool edge):gdc(grdispc),ms(mapst),nmw(newmapw),id(identifier),itisedge(edge),default_state(true),set_new_map(false),node_to_update(INVALID),edge_to_update(INVALID)3 MapWin::MapSelector::MapSelector(GraphDisplayerCanvas & grdispc, MapStorage & mapst, int identifier, bool edge):gdc(grdispc),ms(mapst),id(identifier),itisedge(edge),default_state(true),set_new_map(false),node_to_update(INVALID),edge_to_update(INVALID) 4 4 { 5 5 update_list(); … … 51 51 { 52 52 set_new_map=true; 53 nmw.showByPreChoose(itisedge);53 (new NewMapWin("NewMapWin", gdc, itisedge, false))->run(); 54 54 } 55 55 -
gui/new_map_win.cc
r1819 r1823 10 10 } 11 11 12 NewMapWin::NewMapWin(const std::string& title, GraphDisplayerCanvas & grdispc):gdc(grdispc),node("Create NodeMap"),edge("Create EdgeMap") 13 { 14 set_title(title); 12 NewMapWin::NewMapWin(const std::string& title, GraphDisplayerCanvas & grdispc, bool itisedge, bool edgenode):Gtk::Dialog(title, true, true),gdc(grdispc),node("Create NodeMap"),edge("Create EdgeMap") 13 { 15 14 set_default_size(200, 50); 16 15 17 16 signal_key_press_event().connect(sigc::mem_fun(*this, &NewMapWin::closeIfEscapeIsPressed)); 18 17 18 Gtk::VBox * vbox=get_vbox(); 19 19 20 20 //entries … … 38 38 Gtk::RadioButton::Group group = node.get_group(); 39 39 edge.set_group(group); 40 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); 43 44 vbox.pack_start(*table); 40 41 if(edgenode) 42 { 43 (*table).attach(node,0,1,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3); 44 (*table).attach(edge,1,2,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3); 45 } 46 else 47 { 48 if(itisedge) 49 { 50 edge.set_active(); 51 } 52 else 53 { 54 node.set_active(); 55 } 56 } 57 58 vbox->pack_start(*table); 45 59 46 60 //OK button 47 button=new Gtk::Button("OK"); 48 49 button->signal_clicked().connect 50 ( 51 sigc::mem_fun(*this, &NewMapWin::buttonPressed) 52 ); 53 54 55 vbox.pack_start(*button); 56 57 add(vbox); 61 add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); 58 62 59 63 show_all_children(); … … 61 65 } 62 66 63 void NewMapWin::showByPreChoose(bool itisedge) 64 { 65 if(itisedge) 66 { 67 edge.set_active(); 68 } 69 else 70 { 71 node.set_active(); 72 } 73 node.hide(); 74 edge.hide(); 75 show(); 76 } 77 78 void NewMapWin::buttonPressed() 79 { 80 double def_val=0; 81 82 //get and formulate text 83 std::string def_val_str=default_value.get_text(); 84 std::string polishform=string2Polishform(def_val_str,edge.get_active()); 85 86 //get name of text 87 std::string mapname=name.get_text(); 88 89 if(!mapname.empty()&&!polishform.empty()) 90 { 91 int abortion=0; 92 if(edge.get_active()) 93 { 94 //create the new map 95 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (gdc.mapstorage.graph); 96 97 std::stack<double> polishstack; 67 void NewMapWin::on_response(int response_id) 68 { 69 if(response_id==Gtk::RESPONSE_OK) 70 { 71 double def_val=0; 72 73 //get and formulate text 74 std::string def_val_str=default_value.get_text(); 75 std::string polishform=string2Polishform(def_val_str,edge.get_active()); 76 77 //get name of text 78 std::string mapname=name.get_text(); 79 80 if(!mapname.empty()&&!polishform.empty()) 81 { 82 int abortion=0; 83 if(edge.get_active()) 84 { 85 //create the new map 86 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (gdc.mapstorage.graph); 87 88 std::stack<double> polishstack; 98 89 99 for(EdgeIt k(gdc.mapstorage.graph); k!=INVALID; ++k) 100 { 101 for(int i=0;i<(int)polishform.size();i++) 102 { 103 double op1, op2; 104 bool operation=true; 105 switch(polishform[i]) 90 for(EdgeIt k(gdc.mapstorage.graph); k!=INVALID; ++k) 91 { 92 for(int i=0;i<(int)polishform.size();i++) 106 93 { 107 case '+': 108 case '-': 109 case '/': 110 case '*': 111 op1=polishstack.top(); 112 polishstack.pop(); 113 op2=polishstack.top(); 114 polishstack.pop(); 115 break; 116 default: 117 //substitute variable 118 std::map< std::string,Graph::EdgeMap<double> * > ems=gdc.mapstorage.edgemap_storage; 119 bool itisvar=(ems.find(ch2var[ polishform[i] ])!=ems.end()); 120 if(itisvar) 121 { 122 polishstack.push( (*(gdc.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]); 123 } 124 else 125 { 126 char * def_val_ch=new char [(int)(ch2var[ polishform[i] ].length())]; 127 for(int j=0;j<(int)(ch2var[ polishform[i] ].length());j++) 128 { 129 def_val_ch[j]=ch2var[ polishform[i] ][j]; 130 } 131 polishstack.push(atof(def_val_ch)); 132 } 133 operation=false; 134 break; 135 } 136 if(operation) 137 { 138 double res; 94 double op1, op2; 95 bool operation=true; 139 96 switch(polishform[i]) 140 97 { 141 98 case '+': 142 res=op1+op2;143 break;144 99 case '-': 145 res=op2-op1;146 break;147 100 case '/': 148 res=op2/op1;149 break;150 101 case '*': 151 res=op1*op2; 102 op1=polishstack.top(); 103 polishstack.pop(); 104 op2=polishstack.top(); 105 polishstack.pop(); 152 106 break; 153 107 default: 154 std::cout << "How could we get here?" << std::endl; 108 //substitute variable 109 std::map< std::string,Graph::EdgeMap<double> * > ems=gdc.mapstorage.edgemap_storage; 110 bool itisvar=(ems.find(ch2var[ polishform[i] ])!=ems.end()); 111 if(itisvar) 112 { 113 polishstack.push( (*(gdc.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]); 114 } 115 else 116 { 117 char * def_val_ch=new char [(int)(ch2var[ polishform[i] ].length())]; 118 for(int j=0;j<(int)(ch2var[ polishform[i] ].length());j++) 119 { 120 def_val_ch[j]=ch2var[ polishform[i] ][j]; 121 } 122 polishstack.push(atof(def_val_ch)); 123 } 124 operation=false; 155 125 break; 156 126 } 157 polishstack.push(res); 127 if(operation) 128 { 129 double res; 130 switch(polishform[i]) 131 { 132 case '+': 133 res=op1+op2; 134 break; 135 case '-': 136 res=op2-op1; 137 break; 138 case '/': 139 res=op2/op1; 140 break; 141 case '*': 142 res=op1*op2; 143 break; 144 default: 145 std::cout << "How could we get here?" << std::endl; 146 break; 147 } 148 polishstack.push(res); 149 } 158 150 } 159 } 160 (*emptr)[k]=polishstack.top(); 161 } 162 163 //if addition was not successful addEdgeMap returns one. 164 //cause can be that there is already a map named like the new one 165 if(gdc.mapstorage.addEdgeMap(mapname, emptr, def_val)) 166 { 167 abortion=1; 168 } 169 170 //add it to the list of the displayable maps 171 gdc.mapwin.registerNewEdgeMap(mapname); 172 173 //display it 174 gdc.changeEdgeText(mapname); 175 } 176 else //!edge.get_active() 177 { 178 //create the new map 179 Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (gdc.mapstorage.graph); 180 181 std::stack<double> polishstack; 151 (*emptr)[k]=polishstack.top(); 152 } 153 154 //if addition was not successful addEdgeMap returns one. 155 //cause can be that there is already a map named like the new one 156 if(gdc.mapstorage.addEdgeMap(mapname, emptr, def_val)) 157 { 158 abortion=1; 159 } 160 161 //add it to the list of the displayable maps 162 gdc.mapwin.registerNewEdgeMap(mapname); 163 164 //display it 165 gdc.changeEdgeText(mapname); 166 } 167 else //!edge.get_active() 168 { 169 //create the new map 170 Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (gdc.mapstorage.graph); 171 172 std::stack<double> polishstack; 182 173 183 for(NodeIt k(gdc.mapstorage.graph); k!=INVALID; ++k) 184 { 185 for(int i=0;i<(int)polishform.size();i++) 186 { 187 double op1, op2; 188 bool operation=true; 189 switch(polishform[i]) 174 for(NodeIt k(gdc.mapstorage.graph); k!=INVALID; ++k) 175 { 176 for(int i=0;i<(int)polishform.size();i++) 190 177 { 191 case '+': 192 case '-': 193 case '/': 194 case '*': 195 op1=polishstack.top(); 196 polishstack.pop(); 197 op2=polishstack.top(); 198 polishstack.pop(); 199 break; 200 default: 201 std::map< std::string,Graph::NodeMap<double> * > nms=gdc.mapstorage.nodemap_storage; 202 bool itisvar=(nms.find(ch2var[ polishform[i] ])!=nms.end()); 203 if(itisvar) 204 { 205 polishstack.push( (*(gdc.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]); 206 } 207 else 208 { 209 char * def_val_ch=new char [(int)(ch2var[ polishform[i] ].length())]; 210 for(int j=0;j<(int)(ch2var[ polishform[i] ].length());j++) 211 { 212 def_val_ch[j]=ch2var[ polishform[i] ][j]; 213 } 214 polishstack.push(atof(def_val_ch)); 215 } 216 operation=false; 217 break; 218 } 219 if(operation) 220 { 221 double res; 178 double op1, op2; 179 bool operation=true; 222 180 switch(polishform[i]) 223 181 { 224 182 case '+': 225 res=op1+op2;226 break;227 183 case '-': 228 res=op2-op1;229 break;230 184 case '/': 231 res=op2/op1;232 break;233 185 case '*': 234 res=op1*op2; 186 op1=polishstack.top(); 187 polishstack.pop(); 188 op2=polishstack.top(); 189 polishstack.pop(); 235 190 break; 236 191 default: 237 std::cout << "How could we get here?" << std::endl; 192 std::map< std::string,Graph::NodeMap<double> * > nms=gdc.mapstorage.nodemap_storage; 193 bool itisvar=(nms.find(ch2var[ polishform[i] ])!=nms.end()); 194 if(itisvar) 195 { 196 polishstack.push( (*(gdc.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]); 197 } 198 else 199 { 200 char * def_val_ch=new char [(int)(ch2var[ polishform[i] ].length())]; 201 for(int j=0;j<(int)(ch2var[ polishform[i] ].length());j++) 202 { 203 def_val_ch[j]=ch2var[ polishform[i] ][j]; 204 } 205 polishstack.push(atof(def_val_ch)); 206 } 207 operation=false; 238 208 break; 239 209 } 240 polishstack.push(res); 210 if(operation) 211 { 212 double res; 213 switch(polishform[i]) 214 { 215 case '+': 216 res=op1+op2; 217 break; 218 case '-': 219 res=op2-op1; 220 break; 221 case '/': 222 res=op2/op1; 223 break; 224 case '*': 225 res=op1*op2; 226 break; 227 default: 228 std::cout << "How could we get here?" << std::endl; 229 break; 230 } 231 polishstack.push(res); 232 } 241 233 } 242 } 243 (*emptr)[k]=polishstack.top(); 244 } 245 246 //if addition was not successful addNodeMap returns one. 247 //cause can be that there is already a map named like the new one 248 if(gdc.mapstorage.addNodeMap(mapname,emptr, def_val)) 249 { 250 abortion=1; 251 } 252 253 //add it to the list of the displayable maps 254 gdc.mapwin.registerNewNodeMap(mapname); 255 256 //display it 257 gdc.changeNodeText(mapname); 258 } 259 if(!abortion) 260 { 261 name.set_text(""); 262 default_value.set_text("0"); 263 edge.show(); 264 node.show(); 265 hide(); 266 } 267 } 268 } 234 (*emptr)[k]=polishstack.top(); 235 } 236 237 //if addition was not successful addNodeMap returns one. 238 //cause can be that there is already a map named like the new one 239 if(gdc.mapstorage.addNodeMap(mapname,emptr, def_val)) 240 { 241 abortion=1; 242 } 243 244 //add it to the list of the displayable maps 245 gdc.mapwin.registerNewNodeMap(mapname); 246 247 //display it 248 //gdc.changeNodeText(mapname); 249 } 250 if(!abortion) 251 { 252 name.set_text(""); 253 default_value.set_text("0"); 254 edge.show(); 255 node.show(); 256 hide(); 257 } 258 } 259 } 260 } 261 269 262 270 263 std::string NewMapWin::string2Polishform(std::string rawcommand, bool itisedge) -
gui/new_map_win.h
r1814 r1823 15 15 ///on which the parameters of a new map can be set. 16 16 17 class NewMapWin : public Gtk:: Window17 class NewMapWin : public Gtk::Dialog 18 18 { 19 19 ///The \ref GraphDisplayerCanvas on which the graph will be drawn. … … 32 32 33 33 ///Constructor of NewMapWin creates the widgets shown in NewMapWin. 34 NewMapWin(const std::string& title, GraphDisplayerCanvas &); 35 34 NewMapWin(const std::string& title, GraphDisplayerCanvas &, bool itisedge=true, bool edgenode=true); 36 35 37 36 ///Signal on button is connected to this function, … … 39 38 ///call the map/creatort function, and if yes, it 40 39 //tells it the attributes.(name, default value) 41 virtual void buttonPressed(); 42 43 virtual void showByPreChoose(bool); 40 virtual void on_response(int response_id); 44 41 45 42 virtual bool closeIfEscapeIsPressed(GdkEventKey*); … … 59 56 Gtk::Entry name, default_value; 60 57 61 Gtk::VBox vbox;62 63 Gtk::Button * button;64 65 58 Gtk::Table * table; 66 59 Gtk::Label * label;
Note: See TracChangeset
for help on using the changeset viewer.