[Lemon-commits] hegyi: r3202 - in glemon/trunk: . icons
Lemon SVN
svn at lemon.cs.elte.hu
Tue Feb 27 18:18:19 CET 2007
Author: hegyi
Date: Tue Feb 27 18:18:19 2007
New Revision: 3202
Added:
glemon/trunk/icons/eps.png (contents, props changed)
Modified:
glemon/trunk/Makefile.am
glemon/trunk/all_include.h
glemon/trunk/main_win.cc
glemon/trunk/main_win.h
glemon/trunk/mapstorage.cc
glemon/trunk/mapstorage.h
glemon/trunk/nbtab.cc
glemon/trunk/nbtab.h
Log:
GUI can now export graph to EPS.
Modified: glemon/trunk/Makefile.am
==============================================================================
--- glemon/trunk/Makefile.am (original)
+++ glemon/trunk/Makefile.am Tue Feb 27 18:18:19 2007
@@ -48,7 +48,9 @@
dijkstrabox.h \
dijkstrabox.cc \
background_chooser_dialog.h \
- background_chooser_dialog.cc
+ background_chooser_dialog.cc \
+ eps_win.h \
+ eps_win.cc
glemon_CXXFLAGS = $(GTK_CFLAGS) $(LEMON_CFLAGS)
# glemon_LDFLAGS = $(GTK_LIBS) $(LEMON_LIBS)
Modified: glemon/trunk/all_include.h
==============================================================================
--- glemon/trunk/all_include.h (original)
+++ glemon/trunk/all_include.h Tue Feb 27 18:18:19 2007
@@ -34,6 +34,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 {N_MAPS, E_MAPS, ARROWS, PAR, EPS_PROPERTY_NUM}; // eps properties;
enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, MAP_EDIT, TOOL_NUM}; // tools;
#define RANGE 3
#define WIN_WIDTH 900
Added: glemon/trunk/icons/eps.png
==============================================================================
Binary file. No diff available.
Modified: glemon/trunk/main_win.cc
==============================================================================
--- glemon/trunk/main_win.cc (original)
+++ glemon/trunk/main_win.cc Tue Feb 27 18:18:19 2007
@@ -48,6 +48,8 @@
2328, gui_icons_editlink);
Glib::RefPtr<Gdk::Pixbuf> p_newmap_pixbuf = Gdk::Pixbuf::create_from_inline(
2328, gui_icons_newmap);
+ Glib::RefPtr<Gdk::Pixbuf> p_eps_pixbuf = Gdk::Pixbuf::create_from_inline(
+ 2328, gui_icons_eps);
Gtk::IconSource move_icon_source;
move_icon_source.set_pixbuf(p_move_pixbuf);
@@ -85,6 +87,12 @@
newmap_icon_set.add_source(newmap_icon_source);
p_icon_factory->add(Gtk::StockID("gd-newmap"), newmap_icon_set);
+ Gtk::IconSource eps_icon_source;
+ eps_icon_source.set_pixbuf(p_eps_pixbuf);
+ Gtk::IconSet eps_icon_set;
+ eps_icon_set.add_source(eps_icon_source);
+ p_icon_factory->add(Gtk::StockID("gd-eps"), eps_icon_set);
+
p_icon_factory->add_default();
ag=Gtk::ActionGroup::create();
@@ -152,6 +160,9 @@
ag->add( Gtk::Action::create("DesignGraph", Gtk::Stock::REFRESH),
sigc::mem_fun ( *this , &MainWin::reDesignGraph ) );
+ ag->add( Gtk::Action::create("Eps", Gtk::StockID("gd-eps")),
+ sigc::mem_fun ( *this , &MainWin::exportToEPS ) );
+
uim=Gtk::UIManager::create();
uim->insert_action_group(ag);
add_accel_group(uim->get_accel_group());
@@ -208,6 +219,7 @@
" <separator />"
" <toolitem action='AddMap' />"
" <toolitem action='DesignGraph' />"
+ " <toolitem action='Eps' />"
" </toolbar>"
"</ui>";
@@ -610,6 +622,14 @@
tabs[active_tab]->reDesignGraph();
}
+void MainWin::exportToEPS()
+{
+ if(active_tab!=-1)
+ {
+ tabs[active_tab]->createExportToEPSWin(tabnames[active_tab]);
+ }
+}
+
void MainWin::createBackgroundChooser()
{
BackgroundChooserDialog dialog(&(tabs[active_tab]->mapstorage));
Modified: glemon/trunk/main_win.h
==============================================================================
--- glemon/trunk/main_win.h (original)
+++ glemon/trunk/main_win.h Tue Feb 27 18:18:19 2007
@@ -262,6 +262,8 @@
virtual void reDesignGraph();
+ virtual void exportToEPS();
+
void createBackgroundChooser();
};
Modified: glemon/trunk/mapstorage.cc
==============================================================================
--- glemon/trunk/mapstorage.cc (original)
+++ glemon/trunk/mapstorage.cc Tue Feb 27 18:18:19 2007
@@ -23,8 +23,9 @@
#include <limits>
#include <cmath>
#include <gtkmm.h>
+#include<lemon/graph_to_eps.h>
-const double i_d=20;
+const int i_d=20;
const double a_d=0.05;
const double p_d=40000;
@@ -589,3 +590,74 @@
{
background_scaling = scaling;
}
+
+void MapStorage::exportGraphToEPS(std::vector<bool> options, std::string filename)
+{
+ Graph::NodeMap<int> _nodeColors(graph, 0);
+ Graph::EdgeMap<int> _edgeColors(graph, 0);
+ Graph::NodeMap<double> _nodeSizes(graph, 6.0);
+ Graph::EdgeMap<double> _edgeWidths(graph, 1.0);
+ bool _drawArrows=options[ARROWS];
+ bool _enableParallel=options[PAR];
+
+ std::string emptyString="";
+ Graph::NodeMap<std::string> _nodeTextMap(graph,emptyString);
+
+ //_nodeTextMap=(Graph::NodeMap<void> *)&emptyStringMap;
+
+ if(options[N_MAPS])
+ {
+ if(active_nodemaps[N_RADIUS]!="")
+ {
+ _nodeSizes=*(nodemap_storage[active_nodemaps[N_RADIUS]]);
+ }
+ if(active_nodemaps[N_COLOR]!="")
+ {
+ for(NodeIt ni(graph);ni!=INVALID;++ni)
+ {
+ _nodeColors[ni]=(int)((*(nodemap_storage[active_nodemaps[N_COLOR]]))[ni]);
+ }
+ }
+ if(active_nodemaps[N_TEXT]!="")
+ {
+ for(NodeIt ni(graph);ni!=INVALID;++ni)
+ {
+ std::ostringstream o;
+ o << ((*(nodemap_storage[active_nodemaps[N_TEXT]]))[ni]);
+ _nodeTextMap[ni]=o.str();
+ }
+ }
+ }
+ if(options[E_MAPS])
+ {
+ if(active_edgemaps[E_WIDTH]!="")
+ {
+ _edgeWidths=*(edgemap_storage[active_edgemaps[E_WIDTH]]);
+ }
+ if(active_edgemaps[E_COLOR]!="")
+ {
+ for(EdgeIt ei(graph);ei!=INVALID;++ei)
+ {
+ _edgeColors[ei]=(int)((*(edgemap_storage[active_edgemaps[E_COLOR]]))[ei]);
+ }
+ }
+ }
+
+ Palette palette;
+ Palette paletteW(true);
+
+ graphToEps(graph,filename).
+ title("Sample .eps figure (fits to A4)").
+ copyright("(C) 2006 LEMON Project").
+ absoluteNodeSizes().absoluteEdgeWidths().
+ nodeScale(2).nodeSizes(_nodeSizes).
+ coords(coords).
+ nodeColors(composeMap(paletteW,_nodeColors)).
+ edgeColors(composeMap(palette,_edgeColors)).
+ edgeWidthScale(0.3).edgeWidths(_edgeWidths).
+ nodeTexts(_nodeTextMap).nodeTextSize(7).
+ enableParallel(_enableParallel).parEdgeDist(4).
+ drawArrows(_drawArrows).arrowWidth(7).arrowLength(7).
+ run();
+
+}
Modified: glemon/trunk/mapstorage.h
==============================================================================
--- glemon/trunk/mapstorage.h (original)
+++ glemon/trunk/mapstorage.h Tue Feb 27 18:18:19 2007
@@ -291,6 +291,8 @@
void set_iteration(int);
void redesign_data_changed();
+
+ void exportGraphToEPS(std::vector<bool>, std::string);
};
#endif //MAPSTORAGE_H
Modified: glemon/trunk/nbtab.cc
==============================================================================
--- glemon/trunk/nbtab.cc (original)
+++ glemon/trunk/nbtab.cc Tue Feb 27 18:18:19 2007
@@ -17,6 +17,7 @@
*/
#include <nbtab.h>
+#include <eps_win.h>
NoteBookTab::NoteBookTab():mapwinexists(false), designwinexists(false), mapstorage(*this)
{
@@ -226,6 +227,17 @@
}
}
+void NoteBookTab::createExportToEPSWin(std::string name)
+{
+ if(!epswinexists)
+ {
+ epswin=new EpsWin("Export to EPS - "+name, *this);
+ epswin->show();
+ epswinexists=true;
+ }
+}
+
+
void NoteBookTab::createDesignWin(std::string name)
{
if(!designwinexists)
@@ -256,6 +268,12 @@
delete mapwin;
}
+void NoteBookTab::closeEpsWin()
+{
+ epswinexists=false;
+ delete epswin;
+}
+
bool NoteBookTab::closeDesignWin(GdkEventAny * e)
{
if(e->type==GDK_DELETE)
@@ -290,3 +308,8 @@
{
mapstorage.broadcastActiveMaps();
}
+
+void NoteBookTab::exportGraphToEPS(std::vector<bool> options, std::string filename)
+{
+ mapstorage.exportGraphToEPS(options, filename);
+}
Modified: glemon/trunk/nbtab.h
==============================================================================
--- glemon/trunk/nbtab.h (original)
+++ glemon/trunk/nbtab.h Tue Feb 27 18:18:19 2007
@@ -23,6 +23,8 @@
#include "mapstorage.h"
#include "map_win.h"
+//#include "eps_win.h"
+class EpsWin;
#include "design_win.h"
#include "graph_displayer_canvas.h"
#include <libgnomecanvasmm.h>
@@ -97,6 +99,9 @@
///Indicates whether the \ref DesignWin is opened or not. See \ref designwin.
bool designwinexists;
+ ///Indicates whether the \ref EpsWin is opened or not. See \ref epswin.
+ bool epswinexists;
+
///Address of the only \ref MapWin that the \ref NoteBookTab can open.
///Only one of this window can be opened at the same time (\ref mapwinexists),
@@ -113,6 +118,13 @@
///more complicated to synchronize them.
DesignWin * designwin;
+ ///Address of the only \ref EpsWin that the \ref NoteBookTab can open.
+
+ ///Only one of this window can be opened at the same time (\ref epswinexists),
+ ///because there is no need for more, one per tab is enough.
+ ///There won't be benefit of more than one.
+ EpsWin * epswin;
+
public:
///Callback for 'FileNew' action.
virtual void newFile();
@@ -185,14 +197,29 @@
///\ref mapwin.
void createDesignWin(std::string);
+ ///Pops up a window, that can dump graph to EPS
+
+ ///Different parameters can be set here.
+ void createExportToEPSWin(std::string);
+
///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
///See also
///\ref mapwin.
void closeMapWin();
+ ///Closes and deregistrates the \ref DesignWin of \ref NoteBookTab.
+
+ ///See also
+ ///\ref designwin.
bool closeDesignWin(GdkEventAny *);
+ ///Closes and deregistrates the \ref EpsWin of \ref NoteBookTab.
+
+ ///See also
+ ///\ref epswin.
+ void closeEpsWin();
+
///Sets node representation settings
void setView(bool, bool, double, double);
@@ -202,6 +229,9 @@
///Let the graph redesign, based on gravity and edge elasticity.
void reDesignGraph();
+ ///Lets Mapstorage export the graph to EPS
+ void exportGraphToEPS(std::vector<bool>, std::string);
+
///\ref MapWin calls this function when it updates the maplist in comboboxes.
void active_maps_needed();
More information about the Lemon-commits
mailing list