[Lemon-commits] [lemon_svn] hegyi: r2950 - glemon/trunk
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 21:51:26 CET 2006
Author: hegyi
Date: Tue Sep 19 09:43:55 2006
New Revision: 2950
Modified:
glemon/trunk/all_include.h
glemon/trunk/graph_displayer_canvas-event.cc
glemon/trunk/graph_displayer_canvas.cc
glemon/trunk/graph_displayer_canvas.h
glemon/trunk/main_win.cc
Log:
Node and edge editor button are the same furthermore.
Modified: glemon/trunk/all_include.h
==============================================================================
--- glemon/trunk/all_include.h (original)
+++ glemon/trunk/all_include.h Tue Sep 19 09:43:55 2006
@@ -18,7 +18,7 @@
enum {E_WIDTH, E_COLOR, E_TEXT, EDGE_PROPERTY_NUM}; // edge properties;
enum {N_RADIUS, N_COLOR, N_TEXT, NODE_PROPERTY_NUM}; // node properties;
-enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, EDGE_MAP_EDIT, NODE_MAP_EDIT, TOOL_NUM}; // tools;
+enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, MAP_EDIT, TOOL_NUM}; // tools;
#define RANGE 3
#define WIN_WIDTH 900
#define WIN_HEIGHT 600
Modified: glemon/trunk/graph_displayer_canvas-event.cc
==============================================================================
--- glemon/trunk/graph_displayer_canvas-event.cc (original)
+++ glemon/trunk/graph_displayer_canvas-event.cc Tue Sep 19 09:43:55 2006
@@ -27,9 +27,7 @@
createEdgeEventHandler(generated);
break;
}
- case EDGE_MAP_EDIT:
- //has to do the same thing as in the case of NODE_MAP_EDIT
- case NODE_MAP_EDIT:
+ case MAP_EDIT:
{
break;
}
@@ -63,13 +61,9 @@
actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraserEventHandler), false);
break;
- case EDGE_MAP_EDIT:
+ case MAP_EDIT:
grab_focus();
- actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::edgeMapEditEventHandler), false);
- break;
-
- case NODE_MAP_EDIT:
- actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::nodeMapEditEventHandler), false);
+ actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false);
break;
default:
@@ -622,179 +616,163 @@
return false;
}
-bool GraphDisplayerCanvas::edgeMapEditEventHandler(GdkEvent* e)
-{
- if(actual_tool==EDGE_MAP_EDIT)
- {
- switch(e->type)
- {
- case GDK_BUTTON_PRESS:
- {
- //for determine, whether it was an edge
- Edge clicked_edge=INVALID;
-
- window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
- active_item=(get_item_at(clicked_x, clicked_y));
-
- //find the activated item between texts
- for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
- {
- //at the same time only one can be active
- if(edgetextmap[i]==active_item)
- {
- clicked_edge=i;
- }
- }
-
- //if it was not between texts, search for it between edges
- if(clicked_edge==INVALID)
- {
- for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
- {
- //at the same time only one can be active
- if((edgesmap[i]==active_item)||(edgetextmap[i]==active_item))
- {
- clicked_edge=i;
- }
- }
- }
-
- //if it was really an edge...
- if(clicked_edge!=INVALID)
- {
- // the id map is not editable
- if (edgemap_to_edit == "label") return 0;
-
- //and there is activated map
- if(edgetextmap[clicked_edge]->property_text().get_value()!="")
- {
- //activate the general variable for it
- active_edge=clicked_edge;
-
- //create a dialog
- Gtk::Dialog dialog("Edit value", true);
- dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
- Gtk::VBox* vbox = dialog.get_vbox();
- Gtk::SpinButton spin(0.0, 4);
- spin.set_increments(1.0, 10.0);
- spin.set_range(-1000000.0, 1000000.0);
- spin.set_numeric(true);
- vbox->add(spin);
- spin.show();
- switch (dialog.run())
- {
- case Gtk::RESPONSE_NONE:
- case Gtk::RESPONSE_CANCEL:
- break;
- case Gtk::RESPONSE_ACCEPT:
- double new_value = spin.get_value();
- (*(mytab.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] =
- new_value;
- std::ostringstream ostr;
- ostr << new_value;
- edgetextmap[active_edge]->property_text().set_value(
- ostr.str());
- //mapwin.updateEdge(active_edge);
-// mapwin.updateEdge(Edge(INVALID));
- propertyUpdate(Edge(INVALID));
- }
- }
- }
- break;
- }
- default:
- break;
- }
- }
- return false;
-}
-
-bool GraphDisplayerCanvas::nodeMapEditEventHandler(GdkEvent* e)
+bool GraphDisplayerCanvas::mapEditEventHandler(GdkEvent* e)
{
- if(actual_tool==NODE_MAP_EDIT)
- {
- switch(e->type)
+ if(actual_tool==MAP_EDIT)
{
- case GDK_BUTTON_PRESS:
- {
- //for determine, whether it was a node
- Node clicked_node=INVALID;
-
- window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
- active_item=(get_item_at(clicked_x, clicked_y));
-
- //find the activated item between texts
- for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
- {
- //at the same time only one can be active
- if(nodetextmap[i]==active_item)
- {
- clicked_node=i;
- }
- }
-
- //if there was not, search for it between nodes
- if(clicked_node==INVALID)
- {
- for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
- {
- //at the same time only one can be active
- if(nodesmap[i]==active_item)
- {
- clicked_node=i;
- }
- }
- }
-
- //if it was really a node...
- if(clicked_node!=INVALID)
- {
- // the id map is not editable
- if (nodemap_to_edit == "label") return 0;
+ switch(e->type)
+ {
+ case GDK_BUTTON_PRESS:
+ {
+ //for determine, whether it was an edge
+ Edge clicked_edge=INVALID;
+ //for determine, whether it was a node
+ Node clicked_node=INVALID;
+
+ window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
+ active_item=(get_item_at(clicked_x, clicked_y));
+
+ //find the activated item between text of nodes
+ for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
+ {
+ //at the same time only one can be active
+ if(nodetextmap[i]==active_item)
+ {
+ clicked_node=i;
+ }
+ }
+
+ //if there was not, search for it between nodes
+ if(clicked_node==INVALID)
+ {
+ for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
+ {
+ //at the same time only one can be active
+ if(nodesmap[i]==active_item)
+ {
+ clicked_node=i;
+ }
+ }
+ }
+
+ if(clicked_node==INVALID)
+ {
+ //find the activated item between texts
+ for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
+ {
+ //at the same time only one can be active
+ if(edgetextmap[i]==active_item)
+ {
+ clicked_edge=i;
+ }
+ }
+
+ //if it was not between texts, search for it between edges
+ if(clicked_edge==INVALID)
+ {
+ for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
+ {
+ //at the same time only one can be active
+ if((edgesmap[i]->getLine())==active_item)
+ {
+ clicked_edge=i;
+ }
+ }
+ }
+ }
+
+ //if it was really a node...
+ if(clicked_node!=INVALID)
+ {
+ // the id map is not editable
+ if (nodemap_to_edit == "label") return 0;
+
+ //and there is activated map
+ if(nodetextmap[clicked_node]->property_text().get_value()!="")
+ {
+ //activate the general variable for it
+ active_node=clicked_node;
+
+ //create a dialog
+ Gtk::Dialog dialog("Edit value", true);
+ dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+ dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
+ Gtk::VBox* vbox = dialog.get_vbox();
+ Gtk::SpinButton spin(0.0, 4);
+ spin.set_increments(1.0, 10.0);
+ spin.set_range(-1000000.0, 1000000.0);
+ spin.set_numeric(true);
+ spin.set_value(atof(nodetextmap[active_node]->property_text().get_value().c_str()));
+ vbox->add(spin);
+ spin.show();
+ switch (dialog.run())
+ {
+ case Gtk::RESPONSE_NONE:
+ case Gtk::RESPONSE_CANCEL:
+ break;
+ case Gtk::RESPONSE_ACCEPT:
+ double new_value = spin.get_value();
+ (*(mytab.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] =
+ new_value;
+ std::ostringstream ostr;
+ ostr << new_value;
+ nodetextmap[active_node]->property_text().set_value(ostr.str());
+ //mapwin.updateNode(active_node);
+ //mapwin.updateNode(Node(INVALID));
+ propertyUpdate(Node(INVALID));
+ }
+ }
+ }
+ else
+ //if it was really an edge...
+ if(clicked_edge!=INVALID)
+ {
+ // the id map is not editable
+ if (edgemap_to_edit == "label") return 0;
- //and there is activated map
- if(nodetextmap[clicked_node]->property_text().get_value()!="")
- {
- //activate the general variable for it
- active_node=clicked_node;
+ //and there is activated map
+ if(edgetextmap[clicked_edge]->property_text().get_value()!="")
+ {
+ //activate the general variable for it
+ active_edge=clicked_edge;
- //create a dialog
- Gtk::Dialog dialog("Edit value", true);
- dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
- Gtk::VBox* vbox = dialog.get_vbox();
- Gtk::SpinButton spin(0.0, 4);
- spin.set_increments(1.0, 10.0);
- spin.set_range(-1000000.0, 1000000.0);
- spin.set_numeric(true);
- vbox->add(spin);
- spin.show();
- switch (dialog.run())
- {
- case Gtk::RESPONSE_NONE:
- case Gtk::RESPONSE_CANCEL:
- break;
- case Gtk::RESPONSE_ACCEPT:
- double new_value = spin.get_value();
- (*(mytab.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] =
- new_value;
- std::ostringstream ostr;
- ostr << new_value;
- nodetextmap[active_node]->property_text().set_value(
- ostr.str());
- //mapwin.updateNode(active_node);
-// mapwin.updateNode(Node(INVALID));
- propertyUpdate(Node(INVALID));
- }
- }
- }
- break;
- }
- default:
- break;
+ //create a dialog
+ Gtk::Dialog dialog("Edit value", true);
+ dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+ dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
+ Gtk::VBox* vbox = dialog.get_vbox();
+ Gtk::SpinButton spin(0.0, 4);
+ spin.set_increments(1.0, 10.0);
+ spin.set_range(-1000000.0, 1000000.0);
+ spin.set_numeric(true);
+ spin.set_value(atof(edgetextmap[active_edge]->property_text().get_value().c_str()));
+ vbox->add(spin);
+ spin.show();
+ switch (dialog.run())
+ {
+ case Gtk::RESPONSE_NONE:
+ case Gtk::RESPONSE_CANCEL:
+ break;
+ case Gtk::RESPONSE_ACCEPT:
+ double new_value = spin.get_value();
+ (*(mytab.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] =
+ new_value;
+ std::ostringstream ostr;
+ ostr << new_value;
+ edgetextmap[active_edge]->property_text().set_value(
+ ostr.str());
+ //mapwin.updateEdge(active_edge);
+ // mapwin.updateEdge(Edge(INVALID));
+ propertyUpdate(Edge(INVALID));
+ }
+ }
+ }
+ break;
+ }
+ default:
+ break;
+ }
}
- }
return false;
}
Modified: glemon/trunk/graph_displayer_canvas.cc
==============================================================================
--- glemon/trunk/graph_displayer_canvas.cc (original)
+++ glemon/trunk/graph_displayer_canvas.cc Tue Sep 19 09:43:55 2006
@@ -177,7 +177,7 @@
edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
edgetextmap[i]->property_fill_color().set_value("darkgreen");
- edgetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::edgeMapEditEventHandler), false);
+ edgetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false);
edgetextmap[i]->raise_to_top();
}
@@ -206,7 +206,7 @@
nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph,
text_pos.x, text_pos.y, "");
nodetextmap[i]->property_fill_color().set_value("darkblue");
- nodetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::nodeMapEditEventHandler), false);
+ nodetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false);
nodetextmap[i]->raise_to_top();
}
Modified: glemon/trunk/graph_displayer_canvas.h
==============================================================================
--- glemon/trunk/graph_displayer_canvas.h (original)
+++ glemon/trunk/graph_displayer_canvas.h Tue Sep 19 09:43:55 2006
@@ -43,6 +43,7 @@
virtual void draw() = 0;
virtual void setLineWidth(int) = 0;
virtual void setFillColor(Gdk::Color) = 0;
+ virtual Gnome::Canvas::Item * getLine() = 0;
};
///Edge displayer class
@@ -97,6 +98,8 @@
void setLineWidth(int);
void setFillColor(Gdk::Color);
+
+ Gnome::Canvas::Item * getLine() { return (Gnome::Canvas::Item *)(&line); };
};
class LoopEdge : public EdgeBase
@@ -109,6 +112,7 @@
void draw();
void setLineWidth(int);
void setFillColor(Gdk::Color);
+ Gnome::Canvas::Item * getLine() { return (Gnome::Canvas::Item *)(&line); };
};
///Type of canvas, on which the graph is drawn
@@ -259,10 +263,8 @@
bool createEdgeEventHandler(GdkEvent*);
///event handler for the case when eraser-tool is active
bool eraserEventHandler(GdkEvent*);
- ///event handler for the case when edge map editor tool is active
- bool edgeMapEditEventHandler(GdkEvent*);
- ///event handler for the case when node map editor tool is active
- bool nodeMapEditEventHandler(GdkEvent*);
+ ///event handler for the case when map editor tool is active
+ bool mapEditEventHandler(GdkEvent*);
public:
///Moves the text to new place
Modified: glemon/trunk/main_win.cc
==============================================================================
--- glemon/trunk/main_win.cc (original)
+++ glemon/trunk/main_win.cc Tue Sep 19 09:43:55 2006
@@ -26,8 +26,6 @@
2328, gui_icons_delete);
Glib::RefPtr<Gdk::Pixbuf> p_editlink_pixbuf = Gdk::Pixbuf::create_from_inline(
2328, gui_icons_editlink);
- Glib::RefPtr<Gdk::Pixbuf> p_editnode_pixbuf = Gdk::Pixbuf::create_from_inline(
- 2328, gui_icons_editnode);
Glib::RefPtr<Gdk::Pixbuf> p_newmap_pixbuf = Gdk::Pixbuf::create_from_inline(
2328, gui_icons_newmap);
@@ -61,12 +59,6 @@
editlink_icon_set.add_source(editlink_icon_source);
p_icon_factory->add(Gtk::StockID("gd-editlink"), editlink_icon_set);
- Gtk::IconSource editnode_icon_source;
- editnode_icon_source.set_pixbuf(p_editnode_pixbuf);
- Gtk::IconSet editnode_icon_set;
- editnode_icon_set.add_source(editnode_icon_source);
- p_icon_factory->add(Gtk::StockID("gd-editnode"), editnode_icon_set);
-
Gtk::IconSource newmap_icon_source;
newmap_icon_source.set_pixbuf(p_newmap_pixbuf);
Gtk::IconSet newmap_icon_set;
@@ -125,8 +117,6 @@
ag->add( Gtk::RadioAction::create(tool_group, "EditEdgeMap", Gtk::StockID("gd-editlink"), _("Edit edge map")),
sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 4) );
- ag->add( Gtk::RadioAction::create(tool_group, "EditNodeMap", Gtk::StockID("gd-editnode"), _("Edit node map")),
- sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 5) );
ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")),
sigc::mem_fun ( *this , &MainWin::createNewMapWin ) );
@@ -180,7 +170,6 @@
" <toolitem action='CreateEdge' />"
" <toolitem action='EraseItem' />"
" <toolitem action='EditEdgeMap' />"
- " <toolitem action='EditNodeMap' />"
" <separator />"
" <toolitem action='AddMap' />"
" </toolbar>"
More information about the Lemon-commits
mailing list