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

Lemon SVN svn at lemon.cs.elte.hu
Tue Nov 21 08:54:24 CET 2006


Author: ladanyi
Date: Tue Nov 21 08:54:20 2006
New Revision: 3079

Added:
   glemon/branches/akos/file_import_window.cc
   glemon/branches/akos/file_import_window.h
Removed:
   glemon/branches/akos/map_window.cc
   glemon/branches/akos/map_window.h
Modified:
   glemon/branches/akos/Makefile.am
   glemon/branches/akos/main_win.cc
   glemon/branches/akos/main_win.h
   glemon/branches/akos/mapstorage.cc
   glemon/branches/akos/nbtab.cc
   glemon/branches/akos/nbtab.h

Log:
First step towards supporting .conf files for gui specific data storage and not hardcoded node and midpoint coordiante map names.

Modified: glemon/branches/akos/Makefile.am
==============================================================================
--- glemon/branches/akos/Makefile.am	(original)
+++ glemon/branches/akos/Makefile.am	Tue Nov 21 08:54:20 2006
@@ -49,8 +49,8 @@
 	dijkstrabox.cc \
 	file_chooser_extra_widget.h \
 	file_chooser_extra_widget.cc \
-	map_window.h \
-	map_window.cc
+	file_import_window.h \
+	file_import_window.cc
 
 glemon_CXXFLAGS = $(GTK_CFLAGS) $(LEMON_CFLAGS)
 # glemon_LDFLAGS = $(GTK_LIBS) $(LEMON_LIBS)

Added: glemon/branches/akos/file_import_window.cc
==============================================================================
--- (empty file)
+++ glemon/branches/akos/file_import_window.cc	Tue Nov 21 08:54:20 2006
@@ -0,0 +1,102 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2006
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#include "file_import_window.h"
+
+FileImportWindow::FileImportWindow(MapStorage *m) :
+  map_storage(m),
+  frCoords("Coordiantes source"),
+  rbNone("None"),
+  rbOneMap("One map"),
+  rbTwoMaps("Two maps")
+{
+  Gtk::VBox* pVBox1 = Gtk::manage(new Gtk::VBox());
+  add(*pVBox1);
+  pVBox1->pack_start(frCoords);
+  //pVBox1->pack_start(swMap);
+  frCoords.show();
+
+  Gtk::RadioButtonGroup g = rbNone.get_group();
+  rbOneMap.set_group(g);
+  rbTwoMaps.set_group(g);
+
+  Gtk::VBox* pVBox2 = Gtk::manage(new Gtk::VBox());
+  frCoords.add(*pVBox2);
+
+  pVBox2->pack_start(rbNone);
+
+  std::cout << "abc" << std::endl;
+
+  Gtk::HBox* pHBox1 = Gtk::manage(new Gtk::HBox());
+  pVBox2->pack_start(*pHBox1);
+  pHBox1->pack_start(rbOneMap);
+  pHBox1->pack_start(cbOneMap);
+
+  Gtk::HBox* pHBox2 = Gtk::manage(new Gtk::HBox());
+  pVBox2->pack_start(*pHBox2);
+  pHBox2->pack_start(rbTwoMaps);
+  Gtk::VBox* pVBox3 = Gtk::manage(new Gtk::VBox());
+  pHBox2->pack_start(*pVBox3);
+  pVBox3->pack_start(cbTwoMapsX);
+  pVBox3->pack_start(cbTwoMapsY);
+
+
+/*
+
+  refMapStore = Gtk::ListStore::create(mapColumns);
+  //refMapStore->signal_row_changed().connect(sigc::mem_fun(*this, &Phy sicalProperties::onChannelChanged));
+
+  std::vector<std::string> edge_maps = map_storage->getEdgeMapList();
+  for (std::vector<std::string>::const_iterator it = edge_maps.begin();
+      it != edge_maps.end(); ++it)
+  {
+    Gtk::TreeModel::Row row = *(refMapStore->append());
+    row[mapColumns.colName] = *it;
+    row[mapColumns.colValue] = "String";
+    row[mapColumns.colType] = "Normal";
+  }
+
+
+  twMap.set_model(refMapStore);
+  twMap.append_column_editable("Name", mapColumns.colName);
+  //twMap.append_column_editable("Value type", mapColumns.colValue);
+  //twMap.append_column_editable("Map type", mapColumns.colType);
+  {
+    Gtk::TreeView::Column* pViewColumn =
+      Gtk::manage(new Gtk::TreeView::Column("Value type", mapColumns.colValue));
+    twMap.append_column(*pViewColumn);
+  }
+  {
+    Gtk::TreeView::Column* pViewColumn =
+      Gtk::manage(new Gtk::TreeView::Column("Map type", mapColumns.colType));
+    twMap.append_column(*pViewColumn);
+  }
+
+
+  swMap.set_size_request(-1, 300);
+  swMap.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+
+  swMap.add(twMap);
+  //add(swMap);
+*/
+  show_all_children();
+}
+
+FileImportWindow::~FileImportWindow()
+{
+}

Added: glemon/branches/akos/file_import_window.h
==============================================================================
--- (empty file)
+++ glemon/branches/akos/file_import_window.h	Tue Nov 21 08:54:20 2006
@@ -0,0 +1,64 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2006
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#ifndef MAP_WINDOW
+#define MAP_WINDOW
+
+#include <gtkmm/window.h>
+#include <gtkmm/liststore.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/radiobutton.h>
+#include <gtkmm/radiobuttongroup.h>
+#include <gtkmm/comboboxtext.h>
+#include "mapstorage.h"
+
+class FileImportWindow : public Gtk::Window
+{
+  struct MapModelColumns : public Gtk::TreeModel::ColumnRecord
+  {
+    MapModelColumns()
+    {
+      add(colName);
+      add(colValue);
+      add(colType);
+    }
+    Gtk::TreeModelColumn<Glib::ustring> colName;
+    Gtk::TreeModelColumn<Glib::ustring> colValue;
+    Gtk::TreeModelColumn<Glib::ustring> colType;
+  };
+  private:
+    MapModelColumns mapColumns;
+    Glib::RefPtr<Gtk::ListStore> refMapStore;
+    Gtk::TreeView twMap;
+    Gtk::ScrolledWindow swMap;
+    MapStorage* map_storage;
+
+    Gtk::Frame frCoords;
+    Gtk::RadioButton rbNone;
+    Gtk::RadioButton rbOneMap;
+    Gtk::RadioButton rbTwoMaps;
+    Gtk::ComboBoxText cbOneMap;
+    Gtk::ComboBoxText cbTwoMapsX;
+    Gtk::ComboBoxText cbTwoMapsY;
+  public:
+    FileImportWindow(MapStorage*);
+    ~FileImportWindow();
+};
+
+#endif

Modified: glemon/branches/akos/main_win.cc
==============================================================================
--- glemon/branches/akos/main_win.cc	(original)
+++ glemon/branches/akos/main_win.cc	Tue Nov 21 08:54:20 2006
@@ -119,6 +119,8 @@
 	   sigc::mem_fun(*this, &MainWin::createMapWin));
   ag->add( Gtk::Action::create("ShowDesign", _("_Design")),
 	   sigc::mem_fun(*this, &MainWin::createDesignWin));
+  ag->add( Gtk::Action::create("ShowMapList", _("Map _List")),
+	   sigc::mem_fun(*this, &MainWin::createMapListWin));
 
   ag->add( Gtk::Action::create("AlgoMenu", _("_Algorithms")) );
   ag->add( Gtk::Action::create("AlgoGeneral", _("_General")),
@@ -177,6 +179,7 @@
       "    <menu action='ShowMenu'>"
       "      <menuitem action='ShowMaps'/>"
       "      <menuitem action='ShowDesign'/>"
+      "      <menuitem action='ShowMapList'/>"
       "    </menu>"
       "    <menu action='AlgoMenu'>"
       "      <menuitem action='AlgoGeneral'/>"
@@ -471,6 +474,14 @@
     }
 }
 
+void MainWin::createMapListWin()
+{
+  if(active_tab!=-1)
+    {
+      tabs[active_tab]->createMapListWin(tabnames[active_tab]);
+    }
+}
+
 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	Tue Nov 21 08:54:20 2006
@@ -155,6 +155,8 @@
   ///\ref GraphDisplayerCanvas
   virtual void zoom100();
 
+  virtual void createMapListWin();
+
   ///Callback for Show Maps menupoint.
 
   ///It calls the appropriate function in

Modified: glemon/branches/akos/mapstorage.cc
==============================================================================
--- glemon/branches/akos/mapstorage.cc	(original)
+++ glemon/branches/akos/mapstorage.cc	Tue Nov 21 08:54:20 2006
@@ -19,8 +19,12 @@
 #include "mapstorage.h"
 #include "gui_writer.h"
 #include "gui_reader.h"
+#include "i18n.h"
 #include <limits>
 #include <cmath>
+#include <iostream>
+#include <fstream>
+#include <string>
 #include <gtkmm.h>
 
 const double i_d=20;
@@ -244,6 +248,60 @@
 
 int MapStorage::readFromFile(const std::string &filename)
 {
+  // check whether the .conf file exists
+  bool conf_exists = g_file_test((filename + ".conf").c_str(),
+      (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR));
+
+  // check whether the file contains a gui section
+  bool gui_section_exists = false;
+  {
+    std::ifstream ifs(filename.c_str());
+    std::string line;
+    while (getline(ifs, line))
+    {
+      int pos = line.find("@gui");
+      if (pos != std::string::npos)
+      {
+        bool only_whitespace_before = true;
+        for (int i = 0; i < pos; ++i)
+        {
+          if (!std::isspace(line[i]))
+          {
+            only_whitespace_before = false;
+            break;
+          }
+        }
+        if (only_whitespace_before) gui_section_exists = true;
+      }
+    }
+  }
+
+  // ask for user input if both exist
+  bool use_gui_section;
+  if (conf_exists && gui_section_exists)
+  {
+    Gtk::MessageDialog mdialog(_("<b>Found both ") + filename +
+        _(".conf and a gui section in ") + filename + _(".</b>"), true,
+        Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE);
+	  mdialog.add_button(_("Use the ._conf file"), 1);
+	  mdialog.add_button(_("Use the _gui section"), 2);
+    switch (mdialog.run())
+    {
+      case 1:
+        use_gui_section = false;
+        break;
+      case 2:
+        use_gui_section = true;
+        break;
+      case Gtk::RESPONSE_NONE:
+        return 1;
+    }
+  }
+  else
+  {
+    use_gui_section = gui_section_exists;
+  }
+
   bool read_x = false;
   bool read_y = false;
   bool read_edge_id = false;

Modified: glemon/branches/akos/nbtab.cc
==============================================================================
--- glemon/branches/akos/nbtab.cc	(original)
+++ glemon/branches/akos/nbtab.cc	Tue Nov 21 08:54:20 2006
@@ -218,6 +218,16 @@
     }
 }
 
+void NoteBookTab::createMapListWin(std::string name)
+{
+  if (!maplistwinexists)
+  {
+    maplistwin = new FileImportWindow(&mapstorage);
+    maplistwin->show();
+    maplistwinexists = true;
+  }
+}
+
 void NoteBookTab::createMapWin(std::string name)
 {
   if(!mapwinexists)

Modified: glemon/branches/akos/nbtab.h
==============================================================================
--- glemon/branches/akos/nbtab.h	(original)
+++ glemon/branches/akos/nbtab.h	Tue Nov 21 08:54:20 2006
@@ -23,6 +23,7 @@
 
 #include "mapstorage.h"
 #include "map_win.h"
+#include "file_import_window.h"
 #include "design_win.h"
 #include "graph_displayer_canvas.h"
 #include <libgnomecanvasmm.h>
@@ -91,12 +92,15 @@
   ///The graph will be drawn on this \ref GraphDisplayerCanvas
   GraphDisplayerCanvas * gd_canvas;
 
+  bool maplistwinexists;
+
   ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin.
   bool mapwinexists;
 
   ///Indicates whether the \ref DesignWin is opened or not. See \ref designwin.
   bool designwinexists;
 
+  FileImportWindow* maplistwin;
   ///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), 
@@ -173,6 +177,8 @@
   ///\param mapname name of new map
   void registerNewNodeMap(std::string mapname);
 
+  void createMapListWin(std::string);
+
   ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
   
   ///See also



More information about the Lemon-commits mailing list