EdgeMapEditor is on its way, but it is far not yet ready.
authorhegyi
Fri, 15 Jul 2005 21:17:18 +0000
changeset 156273c3f5d0079c
parent 1561 be178ff88711
child 1563 0853ed07a677
EdgeMapEditor is on its way, but it is far not yet ready.
gui/graph_displayer_canvas-event.cc
gui/graph_displayer_canvas.cc
gui/graph_displayer_canvas.h
     1.1 --- a/gui/graph_displayer_canvas-event.cc	Fri Jul 15 16:12:35 2005 +0000
     1.2 +++ b/gui/graph_displayer_canvas-event.cc	Fri Jul 15 21:17:18 2005 +0000
     1.3 @@ -13,51 +13,65 @@
     1.4  
     1.5  void GraphDisplayerCanvas::changeEditorialTool(int newtool)
     1.6  {
     1.7 -  actual_handler.disconnect();
     1.8 +  if(actual_tool!=newtool)
     1.9 +    {
    1.10  
    1.11 -  if(actual_tool==CREATE_EDGE)
    1.12 -    {
    1.13 -	GdkEvent * generated=new GdkEvent();
    1.14 -	generated->type=GDK_BUTTON_RELEASE;
    1.15 -	generated->button.button=3;
    1.16 -	createEdgeEventHandler(generated);      
    1.17 -    }
    1.18 +      actual_handler.disconnect();
    1.19  
    1.20 -  actual_tool=newtool;
    1.21 +      switch(actual_tool)
    1.22 +	{
    1.23 +	case CREATE_EDGE:
    1.24 +	  {
    1.25 +	    GdkEvent * generated=new GdkEvent();
    1.26 +	    generated->type=GDK_BUTTON_RELEASE;
    1.27 +	    generated->button.button=3;
    1.28 +	    createEdgeEventHandler(generated);      
    1.29 +	    break;
    1.30 +	  }
    1.31 +	case EDGE_MAP_EDIT:
    1.32 +	  break;
    1.33 +	default:
    1.34 +	  break;
    1.35 +	}
    1.36  
    1.37 -  active_item=NULL; 
    1.38 -  target_item=NULL; 
    1.39 -  active_edge=INVALID;	
    1.40 -  active_node=INVALID;	
    1.41 +      active_item=NULL; 
    1.42 +      target_item=NULL; 
    1.43 +      active_edge=INVALID;	
    1.44 +      active_node=INVALID;	
    1.45  
    1.46 -  switch(newtool)
    1.47 -    {
    1.48 -    case MOVE:
    1.49 -      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
    1.50 -      break;
    1.51  
    1.52 -    case CREATE_NODE:
    1.53 -      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createNodeEventHandler), false);
    1.54 -      break;
    1.55 +      actual_tool=newtool;
    1.56 +  
    1.57 +      switch(newtool)
    1.58 +	{
    1.59 +	case MOVE:
    1.60 +	  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
    1.61 +	  break;
    1.62  
    1.63 -    case CREATE_EDGE:
    1.64 -      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createEdgeEventHandler), false);
    1.65 -      break;
    1.66 +	case CREATE_NODE:
    1.67 +	  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createNodeEventHandler), false);
    1.68 +	  break;
    1.69  
    1.70 -    case ERASER:
    1.71 -      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraserEventHandler), false);
    1.72 -      break;
    1.73 +	case CREATE_EDGE:
    1.74 +	  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createEdgeEventHandler), false);
    1.75 +	  break;
    1.76  
    1.77 -    case EDGE_MAP_EDIT:
    1.78 -      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::edgeMapEditEventHandler), false);
    1.79 -      break;
    1.80 +	case ERASER:
    1.81 +	  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraserEventHandler), false);
    1.82 +	  break;
    1.83  
    1.84 -    case NODE_MAP_EDIT:
    1.85 -      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::nodeMapEditEventHandler), false);
    1.86 -      break;
    1.87 +	case EDGE_MAP_EDIT:
    1.88 +	  grab_focus();
    1.89 +	  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::edgeMapEditEventHandler), false);
    1.90 +	  break;
    1.91  
    1.92 -    default:
    1.93 -      break;
    1.94 +	case NODE_MAP_EDIT:
    1.95 +	  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::nodeMapEditEventHandler), false);
    1.96 +	  break;
    1.97 +
    1.98 +	default:
    1.99 +	  break;
   1.100 +	}
   1.101      }
   1.102  }
   1.103  
   1.104 @@ -492,35 +506,60 @@
   1.105  {
   1.106    switch(e->type)
   1.107      {
   1.108 +    case GDK_KEY_PRESS:
   1.109 +      {
   1.110 +	std::cout << "Any button was pressed" << std::endl;
   1.111 +	switch(((GdkEventKey*)e)->keyval)
   1.112 +	  {
   1.113 +	  case GDK_A:
   1.114 +	    std::cout << "A button was pressed" << std::endl;
   1.115 +	    break;
   1.116 +	  default:
   1.117 +	    break;
   1.118 +	  }
   1.119 +  
   1.120 +	break;
   1.121 +      }
   1.122      case GDK_BUTTON_PRESS:
   1.123 -      window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   1.124 -      active_item=(get_item_at(clicked_x, clicked_y));
   1.125 -      active_edge=INVALID;
   1.126 -      for (EdgeIt i(g); i!=INVALID; ++i)
   1.127 -	{
   1.128 -	  if(edgesmap[i]==active_item)
   1.129 -	    {
   1.130 -	      active_edge=i;
   1.131 -	    }
   1.132 -	}
   1.133 -      if((active_edge!=INVALID)&&(edgetextmap[active_edge]->property_text().get_value()!=""))
   1.134 -	{
   1.135 -	  if(canvasentrywidget)
   1.136 -	    {
   1.137 -	      delete(canvasentrywidget);
   1.138 -	    }
   1.139 -	  entrywidget.show();
   1.140 -	  entrywidget.set_text(edgetextmap[active_edge]->property_text().get_value());
   1.141 -	  xy<double> entry_coos;
   1.142 -	  entry_coos.x=(edgetextmap[active_edge])->property_x().get_value();
   1.143 -	  entry_coos.x-=edgetextmap[active_edge]->property_text_width().get_value()/2;
   1.144 -	  entry_coos.y=(edgetextmap[active_edge])->property_y().get_value();
   1.145 -	  entry_coos.y-=edgetextmap[active_edge]->property_text_height().get_value()*1.5/2;
   1.146 -	  canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget);
   1.147 -	  canvasentrywidget->property_width().set_value(edgetextmap[active_edge]->property_text_width().get_value()*1.5);
   1.148 -	  canvasentrywidget->property_height().set_value(edgetextmap[active_edge]->property_text_height().get_value()*1.5);
   1.149 -	}
   1.150 -      break;
   1.151 +      {
   1.152 +	window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   1.153 +	active_item=(get_item_at(clicked_x, clicked_y));
   1.154 +	Graph::EdgeIt clicked_edge=INVALID;
   1.155 +	for (EdgeIt i(g); i!=INVALID; ++i)
   1.156 +	  {
   1.157 +	    if(edgesmap[i]==active_item)
   1.158 +	      {
   1.159 +		clicked_edge=i;
   1.160 +	      }
   1.161 +	  }
   1.162 +	if(clicked_edge!=INVALID)
   1.163 +	  {
   1.164 +	    if(edgetextmap[clicked_edge]->property_text().get_value()!="")
   1.165 +	      {
   1.166 +		active_edge=clicked_edge;
   1.167 +		if(canvasentrywidget)
   1.168 +		  {
   1.169 +		    delete(canvasentrywidget);
   1.170 +		  }
   1.171 +		entrywidget.show();
   1.172 +		entrywidget.set_text(edgetextmap[active_edge]->property_text().get_value());
   1.173 +		xy<double> entry_coos;
   1.174 +		entry_coos.x=(edgetextmap[active_edge])->property_x().get_value();
   1.175 +		entry_coos.x-=edgetextmap[active_edge]->property_text_width().get_value()/2;
   1.176 +		entry_coos.y=(edgetextmap[active_edge])->property_y().get_value();
   1.177 +		entry_coos.y-=edgetextmap[active_edge]->property_text_height().get_value()*1.5/2;
   1.178 +		canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget);
   1.179 +		canvasentrywidget->property_width().set_value(edgetextmap[active_edge]->property_text_width().get_value()*1.5);
   1.180 +		canvasentrywidget->property_height().set_value(edgetextmap[active_edge]->property_text_height().get_value()*1.5);
   1.181 +	      }
   1.182 +	  }
   1.183 +	else
   1.184 +	  {
   1.185 +	    //mentse el -> problema, hogy nem tudja melyik map-be
   1.186 +	    entrywidget.hide();
   1.187 +	  }
   1.188 +	break;
   1.189 +      }
   1.190      default:
   1.191        break;
   1.192      }
   1.193 @@ -533,6 +572,14 @@
   1.194    return false;
   1.195  }
   1.196  
   1.197 +bool GraphDisplayerCanvas::entryWidgetChangeHandler(GdkEvent* e)
   1.198 +{
   1.199 +  Glib::ustring mapvalue = entrywidget.get_text();
   1.200 +  std::cout << mapvalue << std::endl;
   1.201 +  e=e;
   1.202 +  return false;
   1.203 +}
   1.204 +
   1.205  void GraphDisplayerCanvas::deleteItem(NodeIt node_to_delete)
   1.206  {
   1.207    delete(nodetextmap[node_to_delete]);
     2.1 --- a/gui/graph_displayer_canvas.cc	Fri Jul 15 16:12:35 2005 +0000
     2.2 +++ b/gui/graph_displayer_canvas.cc	Fri Jul 15 21:17:18 2005 +0000
     2.3 @@ -5,12 +5,16 @@
     2.4  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),canvasentrywidget(NULL),mapstorage(ms),isbutton(0),active_item(NULL),target_item(NULL),mapwin(mw)
     2.5  {
     2.6    
     2.7 +  active_node=INVALID;
     2.8 +  active_edge=INVALID;
     2.9 +
    2.10 +  //setting event handler for the editor widget
    2.11 +  entrywidget.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::entryWidgetChangeHandler), false);
    2.12 +
    2.13 +  //base event handler is move tool
    2.14    actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
    2.15    actual_tool=CREATE_NODE;
    2.16  
    2.17 -  active_node=INVALID;
    2.18 -  active_edge=INVALID;
    2.19 -
    2.20    //set_center_scroll_region(true);
    2.21  
    2.22    //first edges are drawn, to hide joining with nodes later
     3.1 --- a/gui/graph_displayer_canvas.h	Fri Jul 15 16:12:35 2005 +0000
     3.2 +++ b/gui/graph_displayer_canvas.h	Fri Jul 15 21:17:18 2005 +0000
     3.3 @@ -90,6 +90,9 @@
     3.4    ///event handler for the case when node map editor tool is active
     3.5    bool nodeMapEditEventHandler(GdkEvent*);
     3.6  
     3.7 +  ///event handler for the case when the entry widget is changed
     3.8 +  bool entryWidgetChangeHandler(GdkEvent*);
     3.9 +
    3.10  public:
    3.11    ///Moves the text to new place
    3.12    void textReposition(xy<double>);