COIN-OR::LEMON - Graph Library

Changeset 1550:4dcbb4ab1d7a in lemon-0.x for gui


Ignore:
Timestamp:
07/12/05 20:21:49 (14 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2046
Message:

Editors are based.

Location:
gui
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • gui/all_include.h

    r1512 r1550  
    1919enum {E_WIDTH, E_COLOR, E_TEXT, EDGE_PROPERTY_NUM}; // edge properties;
    2020enum {N_RADIUS, N_COLOR, N_TEXT, NODE_PROPERTY_NUM}; // node properties;
    21 enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, EDGE_MAP_EDIT, TOOL_NUM}; // tools;
     21enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, EDGE_MAP_EDIT, NODE_MAP_EDIT, TOOL_NUM}; // tools;
    2222#define RANGE 3
    2323#define WIN_WIDTH 900
  • gui/graph_displayer_canvas-event.cc

    r1525 r1550  
    4242    case ERASER:
    4343      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraserEventHandler), false);
     44      break;
     45
     46    case EDGE_MAP_EDIT:
     47      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::edgeMapEditEventHandler), false);
     48      break;
     49
     50    case NODE_MAP_EDIT:
     51      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::nodeMapEditEventHandler), false);
    4452      break;
    4553
     
    211219    case GDK_MOTION_NOTIFY:
    212220      {
    213         double world_motion_x, world_motion_y;
    214221        GdkEvent * generated=new GdkEvent();
    215222        generated->motion.x=e->motion.x;
     
    477484}
    478485
     486bool GraphDisplayerCanvas::edgeMapEditEventHandler(GdkEvent* e)
     487{
     488  switch(e->type)
     489    {
     490    case GDK_BUTTON_PRESS:
     491      window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
     492      active_item=(get_item_at(clicked_x, clicked_y));
     493      active_edge=INVALID;
     494      for (EdgeIt i(g); i!=INVALID; ++i)
     495        {
     496          if(edgesmap[i]==active_item)
     497            {
     498              active_edge=i;
     499            }
     500        }
     501      if(active_edge!=INVALID)
     502        {
     503          if(canvasentrywidget)
     504            {
     505              delete(canvasentrywidget);
     506            }
     507          entrywidget.show();
     508          entrywidget.set_text("Hello!");
     509          //      canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, clicked_x, clicked_y,entrywidget);
     510          canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, e->button.x, e->button.y, entrywidget);
     511          canvasentrywidget->property_width().set_value(70);
     512          canvasentrywidget->property_height().set_value(50);
     513          canvasentrywidget->show();
     514          *(edgesmap[active_edge]) << Gnome::Canvas::Properties::fill_color("red");
     515        }
     516      active_item=NULL;         // !!!!!!!!!!!!!!!!!!!!!!!!!!!
     517      active_edge=INVALID;      // !!!!!!!!!!!!!!!!!!!!!!!!!!!
     518      break;
     519    default:
     520      break;
     521    }
     522  return false; 
     523}
     524
     525bool GraphDisplayerCanvas::nodeMapEditEventHandler(GdkEvent* e)
     526{
     527  e=e;
     528  return false;
     529}
     530
    479531void GraphDisplayerCanvas::deleteItem(NodeIt node_to_delete)
    480532{
     
    537589
    538590}
     591
  • gui/graph_displayer_canvas.cc

    r1525 r1550  
    33#include <math.h>
    44
    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)
     5GraphDisplayerCanvas::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)
    66{
    77 
     
    7171GraphDisplayerCanvas::~GraphDisplayerCanvas()
    7272{
     73  if(canvasentrywidget)
     74    {
     75      delete(canvasentrywidget);
     76    }
    7377
    7478  //writing out the end state of the graph
  • gui/graph_displayer_canvas.h

    r1524 r1550  
    8686  ///event handler for the case when eraser-tool is active
    8787  bool eraserEventHandler(GdkEvent*);
    88   ///event handler for the case when eraser-tool is active
     88  ///event handler for the case when edge map editor tool is active
    8989  bool edgeMapEditEventHandler(GdkEvent*);
     90  ///event handler for the case when node map editor tool is active
     91  bool nodeMapEditEventHandler(GdkEvent*);
    9092
    9193public:
     
    127129  Gnome::Canvas::Group displayed_graph;
    128130
     131  ///Map editor entry
     132  Gtk::Entry entrywidget;
     133
     134  ///GnomeCanvas holder for entry
     135  Gnome::Canvas::Widget * canvasentrywidget;
     136
    129137  ///Here we store the maps that can be displayed through properties.
    130138  MapStorage mapstorage;
  • gui/main_win.cc

    r1512 r1550  
    4646  ag->add( Gtk::Action::create("MoveItem", Gtk::Stock::CONVERT),
    4747      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 0) );
     48  ag->add( Gtk::Action::create("EditEdgeMap", Gtk::Stock::PROPERTIES),
     49      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 4) );
     50  ag->add( Gtk::Action::create("EditNodeMap", Gtk::Stock::PREFERENCES),
     51      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) );
    4852
    4953  uim=Gtk::UIManager::create();
     
    8993      "    <toolitem action='EraseItem' />"
    9094      "    <toolitem action='MoveItem' />"
     95      "    <toolitem action='EditEdgeMap' />"
     96      "    <toolitem action='EditNodeMap' />"
    9197      "  </toolbar>"
    9298      "</ui>";
Note: See TracChangeset for help on using the changeset viewer.