COIN-OR::LEMON - Graph Library

Changeset 1501:39d59aee2a1a in lemon-0.x for gui


Ignore:
Timestamp:
06/17/05 14:25:53 (14 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1982
Message:

Very small bug is corrected: if node creator tool is active, the small red arrows won't move, if you click on them and if you drag the newly created node... 'was hard to notice it :-)

Location:
gui
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • gui/all_include.h

    r1485 r1501  
    1818
    1919enum {WIDTH, COLOR, TEXT, PROPERTY_NUM}; // edge properties;
    20 enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, TOOL_NUM}; // tools;
     20enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, EDGE_MAP_EDIT, TOOL_NUM}; // tools;
    2121#define RANGE 3
    2222#define WIN_WIDTH 900
  • gui/broken_edge.cc

    r1500 r1501  
    33#include <math.h>
    44
    5 BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p) : Line(g), isbutton(false)
     5BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p, GraphDisplayerCanvas & gc) : Line(g), gdc(gc), isbutton(false)
    66{
    77  my_points=new Gnome::Art::Point[3];
     
    111111    case GDK_BUTTON_PRESS:
    112112      //we mark the location of the event to be able to calculate parameters of dragging
    113       clicked_x=e->button.x;
    114       clicked_y=e->button.y;
    115       isbutton=true;
     113      if(gdc.get_actual_tool()!=CREATE_NODE)
     114        {
     115          clicked_x=e->button.x;
     116          clicked_y=e->button.y;
     117          isbutton=true;
     118        }
    116119      break;
    117120    case GDK_BUTTON_RELEASE:
  • gui/broken_edge.h

    r1500 r1501  
    44#define BROKEN_EDGE_H
    55
     6class BrokenEdge;
     7
    68#include <all_include.h>
    79#include <libgnomecanvasmm.h>
    810#include <libgnomecanvasmm/polygon.h>
     11#include <graph_displayer_canvas.h>
    912
    1013class BrokenEdge : public Gnome::Canvas::Line
    1114{
     15  GraphDisplayerCanvas & gdc;
    1216  Gnome::Canvas::Polygon * arrow;
    1317  Gnome::Art::Point * my_points;
     18
    1419
    1520  ///Indicates whether the button of mouse is pressed or not
     
    2328  bool edge_former_event_handler(GdkEvent*);
    2429 public:
    25   BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points);
     30  BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points, GraphDisplayerCanvas &);
    2631  ~BrokenEdge();
    2732  void set_points(Gnome::Canvas::Points, bool move=false);
  • gui/graph_displayer_canvas.cc

    r1500 r1501  
    66{
    77 
    8   actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_edge_event_handler), false);
     8  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_node_event_handler), false);
     9  actual_tool=CREATE_NODE;
    910
    1011  active_node=INVALID;
     
    2425    coos.push_back(Gnome::Art::Point(cm[g.target(i)].x,cm[g.target(i)].y));
    2526   
    26     edgesmap[i]=new BrokenEdge(displayed_graph, coos);
     27    edgesmap[i]=new BrokenEdge(displayed_graph, coos, *this);
    2728    *(edgesmap[i]) << Gnome::Canvas::Properties::fill_color("green");
    2829    edgesmap[i]->property_width_pixels().set_value(10);   
     
    310311  actual_handler.disconnect();
    311312
     313  if(actual_tool==CREATE_EDGE)
     314    {
     315        GdkEvent * generated=new GdkEvent();
     316        generated->type=GDK_BUTTON_RELEASE;
     317        generated->button.button=3;
     318        create_edge_event_handler(generated);     
     319    }
     320
     321  actual_tool=newtool;
     322
    312323  switch(newtool)
    313324    {
     
    332343      break;
    333344    }
     345}
     346
     347int GraphDisplayerCanvas::get_actual_tool()
     348{
     349  return actual_tool;
    334350}
    335351
     
    565581
    566582                  //drawing new edge
    567                   edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos);
     583                  edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos, *this);
    568584                  *(edgesmap[active_edge]) << Gnome::Canvas::Properties::fill_color("green");
    569585                  edgesmap[active_edge]->property_width_pixels().set_value(10);
  • gui/graph_displayer_canvas.h

    r1500 r1501  
    33#ifndef GRAPH_DISPLAYER_CANVAS_H
    44#define GRAPH_DISPLAYER_CANVAS_H
     5
     6class GraphDisplayerCanvas;
    57
    68#include <all_include.h>
     
    7072  ///event handler for the case when eraser-tool is active
    7173  bool eraser_event_handler(GdkEvent*);
     74  ///event handler for the case when eraser-tool is active
     75  bool edge_map_edit_event_handler(GdkEvent*);
    7276
     77public:
     78  ///\return the actual tool in hand
     79  int get_actual_tool();
     80
     81private:
    7382  ///Deletes the given element.
    7483  void delete_item(NodeIt);
     
    7786  ///Deletes the given element.
    7887  void delete_item(Graph::Edge);
     88
     89private:
    7990
    8091  ///The graph, on which we work
     
    99110  int isbutton;
    100111
     112  ///Stores the actual tool in hand
     113  int actual_tool;
     114
    101115  ///At this location was the mousebutton pressed.
    102116  ///It helps to calculate the distance of dragging.
Note: See TracChangeset for help on using the changeset viewer.