COIN-OR::LEMON - Graph Library

Changeset 41:06f1f9a8d51f in glemon-0.x


Ignore:
Timestamp:
07/26/05 23:19:41 (19 years ago)
Author:
Hegyi Péter
Branch:
gui
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@2096
Message:

EdgeMap? and NodeMap? creation is done, at last. Bach 4ever.

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • Makefile.am

    r28 r41  
    2222        edit_win.h \
    2323        broken_edge.cc \
    24         broken_edge.h
    25 
     24        broken_edge.h \
     25        new_map_win.cc \
     26        new_map_win.h
    2627
    2728gd_CXXFLAGS = $(GTK_CFLAGS)
  • graph_displayer_canvas-event.cc

    r40 r41  
    671671            case GDK_Return:
    672672              {
    673                 Glib::ustring mapvalue = entrywidget.get_text();
    674 
    675                 double double_map_fract_value=0;
    676                 double double_map_value=0;
    677                 int offset=0;
    678                 int found_letter=0;
    679                 //converting text to double
    680                 for(int i=0;i<(int)(mapvalue.length());i++)
     673                bool valid_double=true;
     674                int point_num=0;
     675                Glib::ustring mapvalue_str = entrywidget.get_text();
     676
     677                char * mapvalue_ch=new char [mapvalue_str.length()];
     678                for(int i=0;i<(int)(mapvalue_str.length());i++)
    681679                  {
    682                     if(((mapvalue[i]<='9')&&(mapvalue[i]>='0'))||(mapvalue[i]=='.'))
     680                    if(((mapvalue_str[i]<'0')||(mapvalue_str[i]>'9'))&&(mapvalue_str[i]!='.'))
    683681                      {
    684                         if(mapvalue[i]=='.')
    685                           {
    686                             //for calculating non-integer part of double we step backward from the end
    687                             //after each step the number will be divided by ten, and the new value will be added
    688                             //to step backward from the end until the point the actual character of the string is the following:
    689                             // mapvalue.length()-(i-position_of_point)
    690                             //if i was the number of the first character after the decimal point the selected character will be the last
    691                             //if i was the number of the last character, the selected character will be the first after the decimal point
    692                             offset=mapvalue.length()+i;
    693                           }
    694                         else
    695                           {
    696                             if(!offset)
    697                               {
    698                                 double_map_value=10*double_map_value+mapvalue[i]-'0';
    699                               }
    700                             else
    701                               {
    702                                 double_map_fract_value=double_map_fract_value/10+(double)(mapvalue[offset-i]-'0')/10;
    703                               }
    704                           }
     682                        valid_double=false;
    705683                      }
    706684                    else
    707685                      {
    708                         found_letter++;
    709                         continue;
     686                        if(mapvalue_str[i]=='.')
     687                          {
     688                            point_num++;
     689                          }
    710690                      }
     691                    mapvalue_ch[i]=mapvalue_str[i];
    711692                  }
    712 
    713                 if(!found_letter)
     693 
     694                double mapvalue_d=atof(mapvalue_ch);
     695
     696//              double double_map_fract_value=0;
     697//              double double_map_value=0;
     698//              int offset=0;
     699//              int found_letter=0;
     700                //converting text to double
     701//              for(int i=0;i<(int)(mapvalue.length());i++)
     702//                {
     703//                  if(((mapvalue[i]<='9')&&(mapvalue[i]>='0'))||(mapvalue[i]=='.'))
     704//                    {
     705//                      if(mapvalue[i]=='.')
     706//                        {
     707//                          //for calculating non-integer part of double we step backward from the end
     708//                          //after each step the number will be divided by ten, and the new value will be added
     709//                          //to step backward from the end until the point the actual character of the string is the following:
     710//                          // mapvalue.length()-(i-position_of_point)
     711//                          //if i was the number of the first character after the decimal point the selected character will be the last
     712//                          //if i was the number of the last character, the selected character will be the first after the decimal point
     713//                          offset=mapvalue.length()+i;
     714//                        }
     715//                      else
     716//                        {
     717//                          if(!offset)
     718//                            {
     719//                              double_map_value=10*double_map_value+mapvalue[i]-'0';
     720//                            }
     721//                          else
     722//                            {
     723//                              double_map_fract_value=double_map_fract_value/10+(double)(mapvalue[offset-i]-'0')/10;
     724//                            }
     725//                        }
     726//                    }
     727//                  else
     728//                    {
     729//                      found_letter++;
     730//                      continue;
     731//                    }
     732//                }
     733
     734                if((point_num<=1)&&(valid_double))
    714735                  {
    715736                    switch(actual_tool)
    716737                      {
    717738                      case EDGE_MAP_EDIT:
    718                         edgetextmap[active_edge]->property_text().set_value(mapvalue);
    719                         (*(mapstorage.edgemap_storage)[edgemap_to_edit])[active_edge]=double_map_value+double_map_fract_value;
     739                        edgetextmap[active_edge]->property_text().set_value(mapvalue_str);
     740                        (*(mapstorage.edgemap_storage)[edgemap_to_edit])[active_edge]=mapvalue_d;
    720741                        break;
    721742                      case NODE_MAP_EDIT:
    722                         nodetextmap[active_node]->property_text().set_value(mapvalue);
    723                         (*(mapstorage.nodemap_storage)[nodemap_to_edit])[active_node]=double_map_value+double_map_fract_value;
     743                        nodetextmap[active_node]->property_text().set_value(mapvalue_str);
     744                        (*(mapstorage.nodemap_storage)[nodemap_to_edit])[active_node]=mapvalue_d;
    724745                        break;
    725746                      default:
     
    804825}
    805826
    806 void GraphDisplayerCanvas::addNewEdgeMap()
    807 {
    808   Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (g,20);
    809   mapstorage.addEdgeMap("NewEdgeMap",emptr);
    810   mapwin->registerNewEdgeMap("NewEdgeMap");
    811   changeEdgeText("NewEdgeMap");
    812 }
    813 
    814 void GraphDisplayerCanvas::addNewNodeMap()
    815 {
    816   std::cout << "Add New NodeMap is not yet implemented." << std::endl;
    817 }
    818 
     827void GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname)
     828{
     829  Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (g,default_value);
     830  mapstorage.addEdgeMap(mapname,emptr);
     831  mapwin->registerNewEdgeMap(mapname);
     832  changeEdgeText(mapname);
     833}
     834
     835void GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname)
     836{
     837  Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (g,default_value);
     838  mapstorage.addNodeMap(mapname,emptr);
     839  mapwin->registerNewNodeMap(mapname);
     840  changeNodeText(mapname);
     841}
     842
  • graph_displayer_canvas.cc

    r36 r41  
    66{
    77 
    8  
     8  //Initializing values.
    99  active_node=INVALID;
    1010  active_edge=INVALID;
  • graph_displayer_canvas.h

    r40 r41  
    111111
    112112  ///creates a new Nodemap
    113   void addNewNodeMap();
     113  void addNewNodeMap(double,std::string);
    114114  ///creates a new Edgemap
    115   void addNewEdgeMap();
     115  void addNewEdgeMap(double,std::string);
    116116
    117117private:
  • main_win.cc

    r37 r41  
    22
    33MainWin::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, &mapwin)
     4    MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),editwin("Editorial Window", gd_canvas),newmapwin("Creating new map",gd_canvas),gd_canvas(graph, cm, ms, &mapwin)
    55{
     6  //Creating a window for setting new maps.
     7//   newmapwin=new NewMapWi("Creating new map",*this);
     8
     9
    610  set_title (title);
    711  set_default_size(WIN_WIDTH,WIN_HEIGHT);
     
    5054  ag->add( Gtk::Action::create("EditNodeMap", Gtk::Stock::PREFERENCES),
    5155      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) );
    52   ag->add( Gtk::Action::create("AddEdgeMap", Gtk::Stock::NEW),
    53       sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::addNewEdgeMap ) );
    54   ag->add( Gtk::Action::create("AddNodeMap", Gtk::Stock::NEW),
    55       sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::addNewNodeMap ) );
     56  ag->add( Gtk::Action::create("AddMap", Gtk::Stock::NEW),
     57      sigc::mem_fun ( this->newmapwin, &NewMapWin::show ) );
    5658
    5759  uim=Gtk::UIManager::create();
     
    99101      "    <toolitem action='EditEdgeMap' />"
    100102      "    <toolitem action='EditNodeMap' />"
    101       "    <toolitem action='AddEdgeMap' />"
    102       "    <toolitem action='AddNodeMap' />"
     103      "    <toolitem action='AddMap' />"
    103104      "  </toolbar>"
    104105      "</ui>";
  • main_win.h

    r9 r41  
    77#include <mapstorage.h>
    88#include <map_win.h>
     9#include <new_map_win.h>
    910#include <edit_win.h>
    1011#include <libgnomecanvasmm.h>
     
    2930  ///Window of editorial tools. Its type is \ref EditWin
    3031  EditWin editwin;
     32
     33  ///We need to store newmapwin, to be able to set the appropriate values for properties of new map.
     34  NewMapWin newmapwin;
    3135
    3236  ///The graph will be drawn on this \ref GraphDisplayerCanvas
  • map_win.cc

    r40 r41  
    266266void MapWin::registerNewNodeMap(std::string newmapname)
    267267{
    268   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
     268  for(int i=0;i<NODE_PROPERTY_NUM;i++)
    269269  {
    270270    //filling in combo box with choices
     
    273273    n_combo_array[i].set_popdown_strings(listStrings);
    274274  }
    275 }
     275  Gtk::Entry* entry = n_combo_array[N_TEXT].get_entry();
     276  entry->set_text((Glib::ustring)newmapname);
     277}
Note: See TracChangeset for help on using the changeset viewer.