[Lemon-commits] ladanyi: r3313 - glemon/branches/akos
Lemon SVN
svn at lemon.cs.elte.hu
Mon Sep 17 07:25:36 CEST 2007
Author: ladanyi
Date: Mon Sep 17 07:25:33 2007
New Revision: 3313
Modified:
glemon/branches/akos/graph_displayer_canvas-edge.cc
glemon/branches/akos/graph_displayer_canvas-event.cc
glemon/branches/akos/main_win.cc
glemon/branches/akos/main_win.h
glemon/branches/akos/map_value.h
glemon/branches/akos/map_win.cc
glemon/branches/akos/mapselector.cc
glemon/branches/akos/mapselector.h
glemon/branches/akos/mapstorage.cc
glemon/branches/akos/mapstorage.h
glemon/branches/akos/nbtab.cc
glemon/branches/akos/nbtab.h
glemon/branches/akos/new_map_win.cc
Log:
Bugfixes.
Modified: glemon/branches/akos/graph_displayer_canvas-edge.cc
==============================================================================
--- glemon/branches/akos/graph_displayer_canvas-edge.cc (original)
+++ glemon/branches/akos/graph_displayer_canvas-edge.cc Mon Sep 17 07:25:33 2007
@@ -247,30 +247,23 @@
//EXCEPT when the name of the map is Default, because
//in that case empty string will be written, because
//that is the deleter map
-
+
if(edge==INVALID)
+ {
+ for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
{
- for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
- {
- edgemap_to_edit=mapname;
- double number=mytab.mapstorage.get(mapname, i);
-
- std::ostringstream ostr;
- ostr << number;
-
- edgetextmap[i]->property_text().set_value(ostr.str());
- }
+ edgemap_to_edit=mapname;
+ edgetextmap[i]->property_text().set_value(
+ static_cast<std::string>(mytab.mapstorage.get(mapname, i)));
}
- else
- {
- double number=mytab.mapstorage.get(mapname, edge);
- std::ostringstream ostr;
- ostr << number;
-
- edgetextmap[edge]->property_text().set_value(ostr.str());
- }
+ }
+ else
+ {
+ edgetextmap[edge]->property_text().set_value(
+ static_cast<std::string>(mytab.mapstorage.get(mapname, edge)));
+ }
return 0;
@@ -282,20 +275,20 @@
//EXCEPT when the name of the map is Default, because
//in that case empty string will be written, because
//that is the deleter map
-
+
if(edge==INVALID)
+ {
+ for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
{
- for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
- {
- edgemap_to_edit="";
- edgetextmap[i]->property_text().set_value("");
- }
-
+ edgemap_to_edit="";
+ edgetextmap[i]->property_text().set_value("");
}
+
+ }
else
- {
- edgetextmap[edge]->property_text().set_value("");
- }
+ {
+ edgetextmap[edge]->property_text().set_value("");
+ }
return 0;
Modified: glemon/branches/akos/graph_displayer_canvas-event.cc
==============================================================================
--- glemon/branches/akos/graph_displayer_canvas-event.cc (original)
+++ glemon/branches/akos/graph_displayer_canvas-event.cc Mon Sep 17 07:25:33 2007
@@ -611,6 +611,8 @@
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);
@@ -618,17 +620,36 @@
spin.set_value(atof(nodetextmap[active_node]->property_text().get_value().c_str()));
vbox->add(spin);
spin.show();
+ */
+ Gtk::Entry entry;
+ entry.set_text(nodetextmap[active_node]->property_text().get_value());
+ vbox->add(entry);
+ entry.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.set(nodemap_to_edit, active_node, new_value);
- std::ostringstream ostr;
- ostr << new_value;
- nodetextmap[active_node]->property_text().set_value(ostr.str());
+ switch (mytab.mapstorage.getNodeMapElementType(nodemap_to_edit))
+ {
+ case MapValue::INTEGER:
+ mytab.mapstorage.set(nodemap_to_edit, active_node,
+ atoi(entry.get_text().c_str()));
+ break;
+ case MapValue::SCALAR:
+ mytab.mapstorage.set(nodemap_to_edit, active_node,
+ atof(entry.get_text().c_str()));
+ break;
+ case MapValue::STRING:
+ mytab.mapstorage.set(nodemap_to_edit, active_node,
+ static_cast<std::string>(entry.get_text()));
+ break;
+ }
+ nodetextmap[active_node]->property_text().set_value(
+ static_cast<std::string>(mytab.mapstorage.get(nodemap_to_edit, active_node)));
+
//mapwin.updateNode(active_node);
//mapwin.updateNode(Node(INVALID));
propertyUpdate(Node(INVALID));
@@ -653,6 +674,8 @@
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);
@@ -660,18 +683,37 @@
spin.set_value(atof(edgetextmap[active_edge]->property_text().get_value().c_str()));
vbox->add(spin);
spin.show();
+ */
+ Gtk::Entry entry;
+ entry.set_text(edgetextmap[active_edge]->property_text().get_value());
+ vbox->add(entry);
+ entry.show();
+
+ std::cout << edgemap_to_edit << std::endl;
switch (dialog.run())
{
case Gtk::RESPONSE_NONE:
case Gtk::RESPONSE_CANCEL:
break;
case Gtk::RESPONSE_ACCEPT:
- double new_value = spin.get_value();
- mytab.mapstorage.set(edgemap_to_edit, active_edge, new_value);
- std::ostringstream ostr;
- ostr << new_value;
+ switch (mytab.mapstorage.getNodeMapElementType(edgemap_to_edit))
+ {
+ case MapValue::INTEGER:
+ mytab.mapstorage.set(edgemap_to_edit, active_edge,
+ atoi(entry.get_text().c_str()));
+ break;
+ case MapValue::SCALAR:
+ mytab.mapstorage.set(edgemap_to_edit, active_edge,
+ atof(entry.get_text().c_str()));
+ break;
+ case MapValue::STRING:
+ mytab.mapstorage.set(edgemap_to_edit, active_edge,
+ static_cast<std::string>(entry.get_text()));
+ break;
+ }
edgetextmap[active_edge]->property_text().set_value(
- ostr.str());
+ static_cast<std::string>(mytab.mapstorage.get(edgemap_to_edit, active_edge)));
+
//mapwin.updateEdge(active_edge);
// mapwin.updateEdge(Edge(INVALID));
propertyUpdate(Edge(INVALID));
Modified: glemon/branches/akos/main_win.cc
==============================================================================
--- glemon/branches/akos/main_win.cc (original)
+++ glemon/branches/akos/main_win.cc Mon Sep 17 07:25:33 2007
@@ -152,6 +152,9 @@
ag->add( Gtk::Action::create("DesignGraph", Gtk::Stock::REFRESH),
sigc::mem_fun ( *this , &MainWin::reDesignGraph ) );
+ ag->add( Gtk::Action::create("DumpMaps", Gtk::Stock::ABOUT),
+ sigc::mem_fun ( *this , &MainWin::dumpMaps ) );
+
uim=Gtk::UIManager::create();
uim->insert_action_group(ag);
add_accel_group(uim->get_accel_group());
@@ -208,6 +211,7 @@
" <separator />"
" <toolitem action='AddMap' />"
" <toolitem action='DesignGraph' />"
+ " <toolitem action='DumpMaps' />"
" </toolbar>"
"</ui>";
@@ -475,6 +479,15 @@
}
}
+void MainWin::dumpMaps()
+{
+ if(active_tab==-1)
+ {
+ newTab();
+ }
+ tabs[active_tab]->dumpMaps();
+}
+
void MainWin::createMapWin()
{
if(active_tab!=-1)
Modified: glemon/branches/akos/main_win.h
==============================================================================
--- glemon/branches/akos/main_win.h (original)
+++ glemon/branches/akos/main_win.h Mon Sep 17 07:25:33 2007
@@ -132,6 +132,8 @@
///Callback for 'Close' action.
virtual void close();
+ void dumpMaps();
+
//Toolbar
///Callback for 'zoomIn' action.
Modified: glemon/branches/akos/map_value.h
==============================================================================
--- glemon/branches/akos/map_value.h (original)
+++ glemon/branches/akos/map_value.h Mon Sep 17 07:25:33 2007
@@ -18,7 +18,12 @@
return "Illegal operation.";
}
};
- typedef enum { INTEGER, SCALAR, STRING } Type;
+ typedef enum
+ {
+ INTEGER = 1 << 0,
+ SCALAR = 1 << 1,
+ STRING = 1 << 2
+ } Type;
private:
bool has_value;
void* p_value;
Modified: glemon/branches/akos/map_win.cc
==============================================================================
--- glemon/branches/akos/map_win.cc (original)
+++ glemon/branches/akos/map_win.cc Mon Sep 17 07:25:33 2007
@@ -46,7 +46,7 @@
for(int i=0;i<EDGE_PROPERTY_NUM;i++)
{
- e_combo_array[i]=new MapSelector(&mytab.mapstorage, mytab.getActiveEdgeMap(i), edge_property_strings[i], true);
+ e_combo_array[i]=new MapSelector(edge_property_strings[i], true, mytab.getActiveEdgeMap(i));
(*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
@@ -66,7 +66,7 @@
for(int i=0;i<NODE_PROPERTY_NUM;i++)
{
- n_combo_array[i]=new MapSelector(&mytab.mapstorage, mytab.getActiveNodeMap(i), node_property_strings[i], false);
+ n_combo_array[i]=new MapSelector(node_property_strings[i], false, mytab.getActiveNodeMap(i));
(*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
@@ -80,6 +80,8 @@
vbox.pack_start(*table);
+ update();
+
show_all_children();
}
Modified: glemon/branches/akos/mapselector.cc
==============================================================================
--- glemon/branches/akos/mapselector.cc (original)
+++ glemon/branches/akos/mapselector.cc Mon Sep 17 07:25:33 2007
@@ -18,77 +18,59 @@
#include "mapselector.h"
-MapSelector::MapSelector(std::string labeltext, bool edge, bool d,
- MapType type) :
+MapSelector::MapSelector(std::string labeltext, bool
+ edge, std::string act, bool d, MapType type) :
def(d),
itisedge(edge),
set_new_map(false),
+ label(labeltext),
map_type(type),
newbut(Gtk::Stock::NEW)
{
set_sensitive(false);
- default_state = false;
- init();
-}
-
-MapSelector::MapSelector(MapStorage* mapstorage, std::string act,
- std::string labeltext, bool edge, bool d, MapType type) :
- def(d),
- itisedge(edge),
- set_new_map(false),
- map_type(type),
- newbut(Gtk::Stock::NEW)
-{
- update_list(mapstorage);
-
if(act=="")
- {
- cbt.set_active(0);
- default_state=true;
- }
+ {
+ cbt.set_active(0);
+ default_state=true;
+ }
else
- {
- cbt.set_active_text((Glib::ustring)act);
- default_state=false;
- }
-
- init();
-}
+ {
+ cbt.set_active_text((Glib::ustring)act);
+ default_state=false;
+ }
-void MapSelector::init()
-{
//binding signal to the actual entry
cbt.signal_changed().connect
(
sigc::mem_fun((*this), &MapSelector::comboChanged),
false
- );
-
+ );
+
label.set_width_chars(longest_property_string_length);
if(def)
- {
- defbut.set_label("Reset");
- defbut.signal_pressed().connect
- (
- sigc::mem_fun(*this, &MapSelector::reset)
- );
- }
+ {
+ defbut.set_label("Reset");
+ defbut.signal_pressed().connect
+ (
+ sigc::mem_fun(*this, &MapSelector::reset)
+ );
+ }
newbut.signal_pressed().connect
(
sigc::mem_fun(*this, &MapSelector::new_but_pressed)
- );
+ );
add(label);
add(cbt);
if(def)
- {
- add(defbut);
- }
+ {
+ add(defbut);
+ }
add(newbut);
}
@@ -99,27 +81,26 @@
signal_newmapwin.emit(itisedge);
}
-void MapSelector::update_list( MapStorage* ms )
+void MapSelector::update_list(MapStorage* ms)
{
- using std::string;
- using std::vector;
set_sensitive();
+
int prev_act=cbt.get_active_row_number();
cbt.clear();
cbt_content.clear();
- vector<string> v;
+ std::vector<std::string> ml;
if (itisedge)
- v = ms->getEdgeMapList(map_type);
+ ml = ms->getEdgeMaps();
else
- v = ms->getNodeMapList(map_type);
-
- for (vector<string>::const_iterator it = v.begin(); it != v.end(); ++it)
- {
- cbt.append_text(*it);
- cbt_content.push_back(*it);
- }
+ ml = ms->getNodeMaps();
+ std::vector< std::string >::iterator emsi=ml.begin();
+ for(;emsi!=ml.end();emsi++)
+ {
+ cbt.append_text(*emsi);
+ cbt_content.push_back(*emsi);
+ }
if(def)
{
cbt.prepend_text("Default values");
Modified: glemon/branches/akos/mapselector.h
==============================================================================
--- glemon/branches/akos/mapselector.h (original)
+++ glemon/branches/akos/mapselector.h Mon Sep 17 07:25:33 2007
@@ -93,17 +93,12 @@
///It is visible only if \ref def is true.
Gtk::Button defbut;
- ///Container in which GUI elements are packed.
- Gtk::HBox hbox;
-
///Shows purpose of \ref MapSelector piece.
Gtk::Label label;
/// Which types of maps (integer, string, ...) to display.
MapType map_type;
- void init();
-
public:
///Constructor of \ref MapSelector
@@ -115,9 +110,8 @@
///\param itisedge do \ref MapSelector contains edgemap names or nodemapnames.
///\param def do we need 'Default' option. See \ref def.
///\param type Specifies which types of maps to display.
- MapSelector(MapStorage* mapstorage, std::string act, std::string purpose, bool itisedge, bool def=true, MapType type = ALL);
-
- MapSelector(std::string labeltext, bool edge, bool d, MapType type);
+ MapSelector(std::string purpose, bool itisedge, std::string act = std::string(),
+ bool def=true, MapType type = ALL);
///Returns signal emitted if the user has changed the selection. (\ref signal_cbt)
sigc::signal<void, std::string> signal_cbt_ch();
@@ -130,7 +124,7 @@
///Fills in \ref cbt with names, taking
///into account that the previously selected option
///has to be set back after the operation.
- void update_list( MapStorage* );
+ void update_list(MapStorage* ms);
///Handles changement in \ref cbt.
Modified: glemon/branches/akos/mapstorage.cc
==============================================================================
--- glemon/branches/akos/mapstorage.cc (original)
+++ glemon/branches/akos/mapstorage.cc Mon Sep 17 07:25:33 2007
@@ -916,3 +916,81 @@
else
return true;
}
+
+void MapStorage::dumpMaps()
+{
+ using std::cout;
+ using std::endl;
+
+ cout << "Node maps:" << endl;
+ for (NodeMapStore::const_iterator it = nodemaps.begin(); it != nodemaps.end(); ++it)
+ {
+ cout << it->first << " ";
+ switch (it->second->type())
+ {
+ case MapValue::INTEGER:
+ cout << "INTEGER" << endl;
+ break;
+ case MapValue::SCALAR:
+ cout << "SCALAR" << endl;
+ break;
+ case MapValue::STRING:
+ cout << "STRING" << endl;
+ break;
+ }
+ for (Graph::NodeIt n(graph); n != INVALID; ++n)
+ {
+ cout << it->second->get(n) << " ";
+ }
+ cout << endl;
+ }
+
+ cout << "Edge maps:" << endl;
+ for (EdgeMapStore::const_iterator it = edgemaps.begin(); it != edgemaps.end(); ++it)
+ {
+ cout << it->first << " ";
+ switch (it->second->type())
+ {
+ case MapValue::INTEGER:
+ cout << "INTEGER" << endl;
+ break;
+ case MapValue::SCALAR:
+ cout << "SCALAR" << endl;
+ break;
+ case MapValue::STRING:
+ cout << "STRING" << endl;
+ break;
+ }
+ for (Graph::EdgeIt e(graph); e != INVALID; ++e)
+ {
+ cout << it->second->get(e) << " ";
+ }
+ cout << endl;
+ }
+}
+
+std::vector<std::string> MapStorage::getEdgeMaps(MapType type)
+{
+ std::vector<std::string> maps;
+ for (EdgeMapStore::const_iterator it = edgemaps.begin(); it != edgemaps.end(); ++it)
+ {
+ if (it->second->type() & type)
+ {
+ maps.push_back(it->first);
+ }
+ }
+ return maps;
+}
+
+std::vector<std::string> MapStorage::getNodeMaps(MapType type)
+{
+ std::vector<std::string> maps;
+ for (NodeMapStore::const_iterator it = nodemaps.begin(); it != nodemaps.end(); ++it)
+ {
+ if (it->second->type() & type)
+ {
+ maps.push_back(it->first);
+ }
+ }
+ return maps;
+}
Modified: glemon/branches/akos/mapstorage.h
==============================================================================
--- glemon/branches/akos/mapstorage.h (original)
+++ glemon/branches/akos/mapstorage.h Mon Sep 17 07:25:33 2007
@@ -87,7 +87,7 @@
void set(Edge e, MapValue v) { map.set(e, v.getAsInt()); }
IntegerEdgeMapData(Graph& g, int def_val) :
EdgeMapData(MapValue(def_val)),
- map(g)
+ map(g, def_val)
{}
};
struct ScalarEdgeMapData : public EdgeMapData
@@ -98,7 +98,7 @@
void set(Edge e, MapValue v) { map.set(e, v.getAsDouble()); }
ScalarEdgeMapData(Graph& g, double def_val) :
EdgeMapData(MapValue(def_val)),
- map(g)
+ map(g, def_val)
{}
};
struct StringEdgeMapData : public EdgeMapData
@@ -109,7 +109,7 @@
void set(Edge e, MapValue v) { map.set(e, v.getAsString()); }
StringEdgeMapData(Graph& g, std::string def_val) :
EdgeMapData(MapValue(def_val)),
- map(g)
+ map(g, def_val)
{}
};
struct NodeMapData
@@ -135,7 +135,7 @@
void set(Node e, MapValue v) { map.set(e, v.getAsInt()); }
IntegerNodeMapData(Graph& g, int def_val) :
NodeMapData(MapValue(def_val)),
- map(g)
+ map(g, def_val)
{}
};
struct ScalarNodeMapData : public NodeMapData
@@ -146,7 +146,7 @@
void set(Node e, MapValue v) { map.set(e, v.getAsDouble()); }
ScalarNodeMapData(Graph& g, double def_val) :
NodeMapData(MapValue(def_val)),
- map(g)
+ map(g, def_val)
{}
};
struct StringNodeMapData : public NodeMapData
@@ -157,7 +157,7 @@
void set(Node e, MapValue v) { map.set(e, v.getAsString()); }
StringNodeMapData(Graph& g, std::string def_val) :
NodeMapData(MapValue(def_val)),
- map(g)
+ map(g, def_val)
{}
};
enum GuiSectSaveDestination { LGF_FILE, CONF_FILE };
@@ -394,6 +394,10 @@
bool nodeMapExists(std::string name);
bool edgeMapExists(std::string name);
+ std::vector<std::string> getEdgeMaps(MapType type = ALL);
+ std::vector<std::string> getNodeMaps(MapType type = ALL);
+
+ void dumpMaps();
private:
EdgeMapData* getEdgeMapData(std::string name) const;
NodeMapData* getNodeMapData(std::string name) const;
Modified: glemon/branches/akos/nbtab.cc
==============================================================================
--- glemon/branches/akos/nbtab.cc (original)
+++ glemon/branches/akos/nbtab.cc Mon Sep 17 07:25:33 2007
@@ -293,3 +293,8 @@
{
mapstorage.broadcastActiveMaps();
}
+
+void NoteBookTab::dumpMaps()
+{
+ mapstorage.dumpMaps();
+}
Modified: glemon/branches/akos/nbtab.h
==============================================================================
--- glemon/branches/akos/nbtab.h (original)
+++ glemon/branches/akos/nbtab.h Mon Sep 17 07:25:33 2007
@@ -114,6 +114,8 @@
DesignWin * designwin;
public:
+ void dumpMaps();
+
///Callback for 'FileNew' action.
virtual void newFile();
///Callback for 'FileOpen' action.
Modified: glemon/branches/akos/new_map_win.cc
==============================================================================
--- glemon/branches/akos/new_map_win.cc (original)
+++ glemon/branches/akos/new_map_win.cc Mon Sep 17 07:25:33 2007
@@ -48,9 +48,9 @@
lblType.set_label("Element type:");
if (map_type & INT)
cbType.append_text("integer");
- else if (map_type & SCAL)
+ if (map_type & SCAL)
cbType.append_text("scalar");
- else if (map_type & STR)
+ if (map_type & STR)
cbType.append_text("string");
(*table).attach(lblType,0,1,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
@@ -202,6 +202,14 @@
if (text == "integer")
{
// TODO
+ int i;
+ i = atoi(def_val.c_str());
+ if (edge.get_active())
+ mytab.mapstorage.createEdgeMap(map_name, MapValue::INTEGER,
+ MapValue(i));
+ else
+ mytab.mapstorage.createNodeMap(map_name, MapValue::INTEGER,
+ MapValue(i));
}
else if (text == "scalar")
{
@@ -220,10 +228,17 @@
}
else
{
+ // TODO
+ if (edge.get_active())
+ mytab.mapstorage.createEdgeMap(map_name, MapValue::SCALAR,
+ MapValue(0.0));
+ else
+ mytab.mapstorage.createNodeMap(map_name, MapValue::SCALAR,
+ MapValue(0.0));
// let't try to evaluate the string as an arithmetic expression
+ /*
std::vector<double>* values;
values = evaluate_expr(string2Polishform(def_val, edge.get_active()));
- // TODO
if (edge.get_active())
{
mytab.mapstorage.createEdgeMap(map_name, MapValue::SCALAR,
@@ -247,6 +262,7 @@
}
}
delete values;
+ */
}
}
else if (text == "string")
More information about the Lemon-commits
mailing list