[Lemon-commits] ladanyi: r3374 - in glemon/branches/akos: . icons
Lemon SVN
svn at lemon.cs.elte.hu
Thu Nov 8 19:18:46 CET 2007
Author: ladanyi
Date: Thu Nov 8 19:18:45 2007
New Revision: 3374
Added:
glemon/branches/akos/eps_win.cc
- copied unchanged from r3203, /glemon/trunk/eps_win.cc
glemon/branches/akos/eps_win.h
- copied unchanged from r3203, /glemon/trunk/eps_win.h
glemon/branches/akos/icons/eps.png
- copied unchanged from r3202, /glemon/trunk/icons/eps.png
Modified:
glemon/branches/akos/Makefile.am
glemon/branches/akos/all_include.h
glemon/branches/akos/main_win.cc
glemon/branches/akos/main_win.h
glemon/branches/akos/mapstorage.cc
glemon/branches/akos/mapstorage.h
glemon/branches/akos/nbtab.cc
glemon/branches/akos/nbtab.h
Log:
Ported r3202, r3203 and r3204 from trunk.
Modified: glemon/branches/akos/Makefile.am
==============================================================================
--- glemon/branches/akos/Makefile.am (original)
+++ glemon/branches/akos/Makefile.am Thu Nov 8 19:18:45 2007
@@ -60,7 +60,9 @@
io_helper.h \
io_helper.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)
@@ -73,7 +75,8 @@
icons/editlink.png \
icons/editnode.png \
icons/move.png \
- icons/newmap.png
+ icons/newmap.png \
+ icons/eps.png
VARIABLES = \
gui_icons_addlink $(srcdir)/icons/addlink.png \
@@ -82,8 +85,9 @@
gui_icons_editlink $(srcdir)/icons/editlink.png \
gui_icons_editnode $(srcdir)/icons/editnode.png \
gui_icons_move $(srcdir)/icons/move.png \
- gui_icons_newmap $(srcdir)/icons/newmap.png
-
+ gui_icons_newmap $(srcdir)/icons/newmap.png \
+ gui_icons_eps $(srcdir)/icons/eps.png
+
guipixbufs.h: $(IMAGES)
gdk-pixbuf-csource \
--raw --build-list $(VARIABLES) > guipixbufs.h || \
Modified: glemon/branches/akos/all_include.h
==============================================================================
--- glemon/branches/akos/all_include.h (original)
+++ glemon/branches/akos/all_include.h Thu Nov 8 19:18:45 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
Modified: glemon/branches/akos/main_win.cc
==============================================================================
--- glemon/branches/akos/main_win.cc (original)
+++ glemon/branches/akos/main_win.cc Thu Nov 8 19:18:45 2007
@@ -49,6 +49,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);
@@ -86,6 +88,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();
@@ -155,6 +163,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());
@@ -212,6 +223,7 @@
" <separator />"
" <toolitem action='AddMap' />"
" <toolitem action='DesignGraph' />"
+ " <toolitem action='Eps' />"
" </toolbar>"
"</ui>";
@@ -620,6 +632,14 @@
dialog.run();
}
+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/branches/akos/main_win.h
==============================================================================
--- glemon/branches/akos/main_win.h (original)
+++ glemon/branches/akos/main_win.h Thu Nov 8 19:18:45 2007
@@ -265,6 +265,8 @@
/// Pops up a SaveDetailsDialog.
void createSaveDetailsDialog();
+ virtual void exportToEPS();
+
void createBackgroundChooser();
};
Modified: glemon/branches/akos/mapstorage.cc
==============================================================================
--- glemon/branches/akos/mapstorage.cc (original)
+++ glemon/branches/akos/mapstorage.cc Thu Nov 8 19:18:45 2007
@@ -29,6 +29,7 @@
#include <algorithm>
#include <gtkmm.h>
#include "file_import_dialog.h"
+#include <lemon/graph_to_eps.h>
const int i_d=20;
const double a_d=0.05;
@@ -1418,3 +1419,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=getNumericNodeMap(active_nodemaps[N_RADIUS]);
+ }
+ if(active_nodemaps[N_COLOR]!="")
+ {
+ for(NodeIt ni(graph);ni!=INVALID;++ni)
+ {
+ _nodeColors[ni]=(int)get(active_nodemaps[N_COLOR], ni);
+ }
+ }
+ if(active_nodemaps[N_TEXT]!="")
+ {
+ for(NodeIt ni(graph);ni!=INVALID;++ni)
+ {
+ std::ostringstream o;
+ o << get(active_nodemaps[N_TEXT], ni);
+ _nodeTextMap[ni]=o.str();
+ }
+ }
+ }
+ if(options[E_MAPS])
+ {
+ if(active_edgemaps[E_WIDTH]!="")
+ {
+ _edgeWidths=getNumericEdgeMap(active_edgemaps[E_WIDTH]);
+ }
+ if(active_edgemaps[E_COLOR]!="")
+ {
+ for(EdgeIt ei(graph);ei!=INVALID;++ei)
+ {
+ _edgeColors[ei]=(int)get(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(node_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/branches/akos/mapstorage.h
==============================================================================
--- glemon/branches/akos/mapstorage.h (original)
+++ glemon/branches/akos/mapstorage.h Thu Nov 8 19:18:45 2007
@@ -530,6 +530,9 @@
const std::string& node_coord_ymap_name,
const std::string& arrow_coord_xmap_name,
const std::string& arrow_coord_ymap_name);
+
+public:
+ void exportGraphToEPS(std::vector<bool>, std::string);
};
#endif //MAPSTORAGE_H
Modified: glemon/branches/akos/nbtab.cc
==============================================================================
--- glemon/branches/akos/nbtab.cc (original)
+++ glemon/branches/akos/nbtab.cc Thu Nov 8 19:18:45 2007
@@ -17,6 +17,7 @@
*/
#include <nbtab.h>
+#include <eps_win.h>
NoteBookTab::NoteBookTab():mapwinexists(false), designwinexists(false), mapstorage(*this)
{
@@ -247,6 +248,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)
@@ -277,6 +289,12 @@
delete mapwin;
}
+void NoteBookTab::closeEpsWin()
+{
+ epswinexists=false;
+ delete epswin;
+}
+
bool NoteBookTab::closeDesignWin(GdkEventAny * e)
{
if(e->type==GDK_DELETE)
@@ -311,3 +329,8 @@
{
mapstorage.broadcastActiveMaps();
}
+
+void NoteBookTab::exportGraphToEPS(std::vector<bool> options, std::string filename)
+{
+ mapstorage.exportGraphToEPS(options, filename);
+}
Modified: glemon/branches/akos/nbtab.h
==============================================================================
--- glemon/branches/akos/nbtab.h (original)
+++ glemon/branches/akos/nbtab.h Thu Nov 8 19:18:45 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