[Lemon-commits] ladanyi: r3368 - glemon/branches/akos

Lemon SVN svn at lemon.cs.elte.hu
Thu Nov 8 17:36:15 CET 2007


Author: ladanyi
Date: Thu Nov  8 17:36:14 2007
New Revision: 3368

Added:
   glemon/branches/akos/background_chooser_dialog.cc
      - copied unchanged from r3125, /glemon/trunk/background_chooser_dialog.cc
   glemon/branches/akos/background_chooser_dialog.h
      - copied unchanged from r3125, /glemon/trunk/background_chooser_dialog.h
Modified:
   glemon/branches/akos/Makefile.am
   glemon/branches/akos/graph_displayer_canvas.cc
   glemon/branches/akos/graph_displayer_canvas.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

Log:
Ported r3125 from trunk.

Modified: glemon/branches/akos/Makefile.am
==============================================================================
--- glemon/branches/akos/Makefile.am	(original)
+++ glemon/branches/akos/Makefile.am	Thu Nov  8 17:36:14 2007
@@ -60,7 +60,9 @@
 	save_details_dialog.h \
 	save_details_dialog.cc \
 	io_helper.h \
-	io_helper.cc
+	io_helper.cc \
+	background_chooser_dialog.h \
+	background_chooser_dialog.cc
 
 glemon_CXXFLAGS = $(GTK_CFLAGS) $(LEMON_CFLAGS)
 # glemon_LDFLAGS = $(GTK_LIBS) $(LEMON_LIBS)

Modified: glemon/branches/akos/graph_displayer_canvas.cc
==============================================================================
--- glemon/branches/akos/graph_displayer_canvas.cc	(original)
+++ glemon/branches/akos/graph_displayer_canvas.cc	Thu Nov  8 17:36:14 2007
@@ -25,7 +25,8 @@
   nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
   isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
   edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), edge_width(10),
-  was_redesigned(false), is_drawn(false), mytab(mainw)
+  was_redesigned(false), is_drawn(false), mytab(mainw),
+  background_set(false)
 {
   //base event handler is move tool
   actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
@@ -34,6 +35,32 @@
   active_node=INVALID;
   active_edge=INVALID;
   forming_edge=INVALID;
+
+  setBackground();
+}
+
+void GraphDisplayerCanvas::setBackground()
+{
+  if (background_set)
+  {
+    delete background;
+  }
+  if (mytab.mapstorage.isBackgroundSet())
+  {
+    background_set = true;
+    refBackground = Gdk::Pixbuf::create_from_file(
+      mytab.mapstorage.getBackgroundFilename());
+    background = new Gnome::Canvas::Pixbuf(
+        *(root()),
+        0.0 - refBackground->get_width() / 2.0,
+        0.0 - refBackground->get_height() / 2.0,
+        refBackground);
+    background->lower_to_bottom();
+  }
+  else
+  {
+    background_set = false;
+  }
 }
 
 GraphDisplayerCanvas::~GraphDisplayerCanvas()

Modified: glemon/branches/akos/graph_displayer_canvas.h
==============================================================================
--- glemon/branches/akos/graph_displayer_canvas.h	(original)
+++ glemon/branches/akos/graph_displayer_canvas.h	Thu Nov  8 17:36:14 2007
@@ -441,6 +441,12 @@
   NoteBookTab & mytab;
 
   XY calcArrowPos(XY, XY, XY, XY, int);
+
+  bool background_set;
+  Glib::RefPtr<Gdk::Pixbuf> refBackground;
+  Gnome::Canvas::Pixbuf *background;
+public:
+  void setBackground();
 };
 
 #endif //GRAPH_DISPLAYER_CANVAS_H

Modified: glemon/branches/akos/main_win.cc
==============================================================================
--- glemon/branches/akos/main_win.cc	(original)
+++ glemon/branches/akos/main_win.cc	Thu Nov  8 17:36:14 2007
@@ -23,6 +23,7 @@
 #include "main_win.h"
 #include "guipixbufs.h"
 #include "save_details_dialog.h"
+#include "background_chooser_dialog.h"
 
 #include "i18n.h"
 
@@ -116,6 +117,8 @@
       sigc::mem_fun(*this, &MainWin::zoomFit));
   ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
       sigc::mem_fun(*this, &MainWin::zoom100));
+  ag->add( Gtk::Action::create("SetBackground", _("Set Background...")),
+	    sigc::mem_fun(*this, &MainWin::createBackgroundChooser));
   
   ag->add( Gtk::Action::create("ShowMenu", _("_Show")) );
   ag->add( Gtk::Action::create("ShowMaps", _("_Maps")),
@@ -177,6 +180,7 @@
       "      <menuitem action='ViewZoomOut' />"
       "      <menuitem action='ViewZoom100' />"
       "      <menuitem action='ViewZoomFit' />"
+      "      <menuitem action='SetBackground' />"
       "    </menu>"
       "    <menu action='ShowMenu'>"
       "      <menuitem action='ShowMaps'/>"
@@ -590,3 +594,9 @@
   SaveDetailsDialog dialog(&(tabs[active_tab]->mapstorage));
   dialog.run();
 }
+
+void MainWin::createBackgroundChooser()
+{
+  BackgroundChooserDialog dialog(&(tabs[active_tab]->mapstorage));
+  dialog.run();
+}

Modified: glemon/branches/akos/main_win.h
==============================================================================
--- glemon/branches/akos/main_win.h	(original)
+++ glemon/branches/akos/main_win.h	Thu Nov  8 17:36:14 2007
@@ -264,6 +264,8 @@
 
   /// Pops up a SaveDetailsDialog.
   void createSaveDetailsDialog();
+
+  void createBackgroundChooser();
 };
 
 #endif //MAIN_WIN_H

Modified: glemon/branches/akos/mapstorage.cc
==============================================================================
--- glemon/branches/akos/mapstorage.cc	(original)
+++ glemon/branches/akos/mapstorage.cc	Thu Nov  8 17:36:14 2007
@@ -17,6 +17,7 @@
  */
 
 #include "mapstorage.h"
+#include "nbtab.h"
 #include "gui_writer.h"
 #include "gui_reader.h"
 #include "i18n.h"
@@ -33,7 +34,8 @@
 const double a_d=0.05;
 const double p_d=40000;
 
-MapStorage::MapStorage() :
+MapStorage::MapStorage(NoteBookTab& tab) :
+  mytab(tab),
   gui_sect_save_dest(LGF_FILE),
   node_coords_save_dest(SpecMapSaveOpts::GUI_SECT),
   arrow_coords_save_dest(SpecMapSaveOpts::GUI_SECT),
@@ -55,7 +57,8 @@
   arrow_coords_x(graph),
   arrow_coords_y(graph),
   node_label(graph),
-  edge_label(graph)
+  edge_label(graph),
+  background_set(false)
 {
   node_coords.setXMap(node_coords_x);
   node_coords.setYMap(node_coords_y);
@@ -829,6 +832,7 @@
   modified = false;
   max_node_label = 0;
   max_edge_label = 0;
+  background_set = false;
 
   gui_sect_save_dest = LGF_FILE;
   node_coords_save_dest = SpecMapSaveOpts::GUI_SECT;
@@ -1378,3 +1382,39 @@
 
   greader.run();
 }
+
+void MapStorage::setBackground(const std::string& file_name)
+{
+  if (file_name == background_file_name) return;
+  if (file_name == "")
+  {
+    background_file_name = "";
+    background_set = false;
+  }
+  else
+  {
+    background_file_name = file_name;
+    background_set = true;
+  }
+  mytab.gd_canvas->setBackground();
+}
+
+const std::string& MapStorage::getBackgroundFilename()
+{
+  return background_file_name;
+}
+
+bool MapStorage::isBackgroundSet()
+{
+  return background_set;
+}
+
+double MapStorage::getBackgroundScaling()
+{
+  return background_scaling;
+}
+
+void MapStorage::setBackgroundScaling(double scaling)
+{
+  background_scaling = scaling;
+}

Modified: glemon/branches/akos/mapstorage.h
==============================================================================
--- glemon/branches/akos/mapstorage.h	(original)
+++ glemon/branches/akos/mapstorage.h	Thu Nov  8 17:36:14 2007
@@ -30,6 +30,8 @@
 #include "map_value.h"
 #include "map_value_map.h"
 
+class NoteBookTab;
+
 ///class MapStorage handles NodeMaps and EdgeMaps.
 
 ///Class MapStorage is responsible for storing
@@ -43,6 +45,11 @@
 ///\todo too many things are public!!
 class MapStorage
 {
+private:
+  std::string background_file_name;
+  bool background_set;
+  double background_scaling;
+  NoteBookTab& mytab;
 public:
   class NonexistentMap : public std::exception
   {
@@ -58,6 +65,11 @@
       ~NonexistentMap() throw() {}
   };
 
+  void setBackground(const std::string& file_name);
+  const std::string& getBackgroundFilename();
+  bool isBackgroundSet();
+  double getBackgroundScaling();
+  void setBackgroundScaling(double scaling);
   class MapAlreadyExists : public std::exception
   {
     private:
@@ -340,7 +352,7 @@
 
   ///Its all activity is initializing default values
   ///for different visualization attributes.
-  MapStorage();
+  MapStorage(NoteBookTab& tab);
 
   ///Destructor of MapStorage
 

Modified: glemon/branches/akos/nbtab.cc
==============================================================================
--- glemon/branches/akos/nbtab.cc	(original)
+++ glemon/branches/akos/nbtab.cc	Thu Nov  8 17:36:14 2007
@@ -19,7 +19,7 @@
 #include <nbtab.h>
 #include "file_chooser_extra_widget.h"
 
-NoteBookTab::NoteBookTab():mapwinexists(false), designwinexists(false)
+NoteBookTab::NoteBookTab():mapwinexists(false), designwinexists(false), mapstorage(*this)
 {
   Gtk::ScrolledWindow *pScrolledWindow = manage(new Gtk::ScrolledWindow);
   gd_canvas=new GraphDisplayerCanvas(*this);



More information about the Lemon-commits mailing list