Index: /trunk/BNC/bncmap.cpp
===================================================================
--- /trunk/BNC/bncmap.cpp	(revision 2795)
+++ /trunk/BNC/bncmap.cpp	(revision 2796)
@@ -10,17 +10,23 @@
 bncMap::bncMap(QWidget* parent) : QDialog(parent)
 {
-  _scale  = 2.8;    // scale the map
-  _LaOff  =  20;    // shift longitude
-  _mapView = new QGraphicsView();
+  _scale  =  2.8;   // scale the map
+  _LaOff  =   25;   // shift longitude
   _mapScen = new QGraphicsScene();
+  _mapView = new BncMapView();
   _mapView->setScene(_mapScen);
+  _mapView->setMatrix(QMatrix(_scale,0,0,_scale,0,0));
   slotReadMap();
   slotCreateMap();
-
-  setWindowTitle(tr("World Map [*]"));
+  _mapScen->setSceneRect(QRect(0,-90,360,180));
+
+  setWindowTitle(tr("Source-Table Map [*]"));
  
   /* close button */
   QPushButton* buttClose = new QPushButton("Close");
   connect(buttClose, SIGNAL(clicked()), this, SLOT(close()));
+   
+  /* rescale button */
+  QPushButton* buttClean = new QPushButton("Clean");
+  connect(buttClean, SIGNAL(clicked()), this, SLOT(slotCleanMap()));
 
   /* reset button */
@@ -28,13 +34,32 @@
   connect(buttReset, SIGNAL(clicked()), this, SLOT(slotResetMap()));
 
+  /* zoom button */
+  QPushButton* buttZoomIn = new QPushButton("Zoom +");
+  connect(buttZoomIn, SIGNAL(clicked()), this, SLOT(slotZoomIn()));
+
+  /* zoom button */
+  QPushButton* buttZoomOut = new QPushButton("Zoom -");
+  connect(buttZoomOut, SIGNAL(clicked()), this, SLOT(slotZoomOut()));
+
+  /* fit button */
+  QPushButton* buttFit = new QPushButton("Fit");
+  connect(buttFit, SIGNAL(clicked()), this, SLOT(slotFitMap()));
+
   /* layout */
-  QGridLayout *layout = new QGridLayout;
-  layout->setRowMinimumHeight(  0, 250);
-  layout->addWidget(_mapView,                0, 0, 3, 1, Qt::AlignLeft);
-  layout->addWidget(buttReset,               1, 1, 1, 1, Qt::AlignBottom);
-  layout->addWidget(buttClose,               2, 1, 1, 1, Qt::AlignBottom);
-  setLayout(layout);
-  
-//  this->resize(860,400);
+  QVBoxLayout* MapLayout = new QVBoxLayout;
+  QHBoxLayout* ButLayout = new QHBoxLayout;
+   
+  ButLayout->addWidget(buttZoomIn);
+  ButLayout->addWidget(buttZoomOut);
+  ButLayout->addWidget(buttClean);
+  ButLayout->addWidget(buttReset);
+  ButLayout->addWidget(buttFit);
+  ButLayout->addWidget(buttClose);
+   
+  MapLayout->addWidget(_mapView);
+  MapLayout->addLayout(ButLayout);
+   
+  setLayout(MapLayout);
+
   this->show();
 }
@@ -61,8 +86,13 @@
 
     in >> la >> fi;
+
+    // la = 0-360
+    while( la <    0 ){ la += 360; }
+    while( la >= 360 ){ la -= 360; }
+     
+    // fi opposite
     _worldMap << QPointF( la, -fi );
-         
+	 
   }
-
   world.close();
 }
@@ -72,5 +102,5 @@
 void bncMap::slotCreateMap()
 {  
-//   mapScen->setForegroundBrush(QBrush(Qt::lightGray, Qt::CrossPattern));   // grid
+  //  _mapScen->setForegroundBrush(QBrush(Qt::lightGray, Qt::CrossPattern));   // grid
 
   int begIdx = 0;
@@ -79,9 +109,9 @@
     if( _worldMap.at(i).x() == 0.0 and _worldMap.at(i).y() == 0.0 ){
       if( i > 0 ){
-         endIdx = i-1;
+	 endIdx = i-1;
         while( begIdx < endIdx ){
 
-          int l1 = 0;
-          int l2 = 0;
+ 	  int l1 = 0;
+	  int l2 = 0;
 
           float la1 = _worldMap.at(begIdx+0).x() + _LaOff;
@@ -90,14 +120,14 @@
           float fi2 = _worldMap.at(begIdx+1).y();
           begIdx++;
-            
-          while( la1 <    0 ){ la1 += 360; l1++; }
-          while( la1 >= 360 ){ la1 -= 360; l1--; }
-          while( la2 <    0 ){ la2 += 360; l2++; }
-          while( la2 >= 360 ){ la2 -= 360; l2--; }
-
-          if( l1 != 0 and l2 == 0 ){ continue; } // break this line
-          if( l2 != 0 and l1 == 0 ){ continue; } // break this line
-
-          _mapScen->addLine(la1*_scale, fi1*_scale, la2*_scale, fi2*_scale, QPen(QBrush(Qt::black),1));
+	    
+	  while( la1 <    0 ){ la1 += 360; l1++; }
+	  while( la1 >= 360 ){ la1 -= 360; l1--; }
+	  while( la2 <    0 ){ la2 += 360; l2++; }
+	  while( la2 >= 360 ){ la2 -= 360; l2--; }
+
+	  if( l1 != 0 and l2 == 0 ){ continue; } // break this line
+	  if( l2 != 0 and l1 == 0 ){ continue; } // break this line
+
+          _mapScen->addLine(la1, fi1, la2, fi2, QPen(QBrush(Qt::gray),0.3));
         }
       }
@@ -105,14 +135,46 @@
     }
   }
-  _mapScen->setSceneRect(0*_scale,-90*_scale,360*_scale,180*_scale);
-}
-
-
-// ------------
-void bncMap::slotResetMap()
+}
+
+
+// ------------
+void bncMap::slotCleanMap()
 {
   QMutexLocker locker(&_mutexMap);
   _mapScen->clear();
   slotCreateMap();
+  slotResetMap();
+}
+
+
+// ------------
+void bncMap::slotResetMap()
+{
+  _mapView->setMatrix(QMatrix(_scale,0,0,_scale,0,0));
+}
+
+
+// ------------
+void bncMap::slotZoomIn()
+{  
+  _mapView->scale( 1.2, 1.2 );
+}
+
+
+// ------------
+void bncMap::slotZoomOut()
+{  
+  _mapView->scale( 1/1.2, 1/1.2 );
+}
+
+
+// ------------
+void bncMap::slotFitMap()
+{  
+  QRectF reg = _allPoints.boundingRect().adjusted(-10,-10,10,10);
+   
+  _mapView->updateSceneRect(reg);
+  _mapView->centerOn(reg.center());
+  _mapView->fitInView(reg,Qt::KeepAspectRatio);
 }
 
@@ -121,16 +183,17 @@
 void bncMap::slotNewPoint(QPointF point, QString name, QPen pen)
 {
-  float la = point.x() + _LaOff;
-  float fi = point.y();
+  float la =   point.x() + _LaOff;
+  float fi = - point.y();
    
   while( la <    0 ){ la += 360; }
   while( la >= 360 ){ la -= 360; }
-
-  _mapScen->addEllipse( la*_scale, -fi*_scale, 5, 5, pen );
+   
+  _allPoints << QPointF(la, fi);
+  _mapScen->addEllipse( la, fi, 1.5, 1.5, pen );
 
   if( ! name.isEmpty() ){
     QGraphicsTextItem* nameItem = new QGraphicsTextItem( name );
-    nameItem->setPos( QPointF(la*_scale, -fi*_scale));
-    nameItem->setFont( QFont("Helvetica", 8) );
+    nameItem->setPos( QPointF(la-1, fi-2));
+    nameItem->setFont( QFont("Arial", 2, 1) );
 
     _mapScen->addItem( nameItem );
Index: /trunk/BNC/bncmap.h
===================================================================
--- /trunk/BNC/bncmap.h	(revision 2795)
+++ /trunk/BNC/bncmap.h	(revision 2796)
@@ -7,4 +7,5 @@
 
 #include <QtGui>
+#include "bncmapview.h"
 
 class bncMap : public QDialog
@@ -17,7 +18,11 @@
    
  public slots:
-   void slotNewPoint( QPointF, QString, QPen);
+   void slotNewPoint(QPointF, QString, QPen);
+   void slotResetMap();
+   void slotFitMap();
+   void slotZoomIn();
+   void slotZoomOut();
    void slotCreateMap();
-   void slotResetMap();
+   void slotCleanMap();
    void slotReadMap();
    
@@ -27,7 +32,8 @@
    double          _LaOff;
 
-   QGraphicsView*  _mapView;
+   BncMapView*     _mapView;
    QGraphicsScene* _mapScen;
    QPolygonF       _worldMap;
+   QPolygonF       _allPoints;
    QMutex          _mutexMap;
 
Index: /trunk/BNC/bnctabledlg.cpp
===================================================================
--- /trunk/BNC/bnctabledlg.cpp	(revision 2795)
+++ /trunk/BNC/bnctabledlg.cpp	(revision 2796)
@@ -145,9 +145,9 @@
   connect(_buttonMap, SIGNAL(clicked()), this, SLOT(slotShowMap()));
  
-  _buttonCancel = new QPushButton(tr("Cancel"), this);
-  connect(_buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
-
-  _buttonOK = new QPushButton(tr("OK"), this);
-  connect(_buttonOK, SIGNAL(clicked()), this, SLOT(accept()));
+  _buttonClose = new QPushButton(tr("Close"), this);
+  connect(_buttonClose, SIGNAL(clicked()), this, SLOT(close()));
+
+  _buttonSelect = new QPushButton(tr("Select"), this);
+  connect(_buttonSelect, SIGNAL(clicked()), this, SLOT(select()));
 
   QHBoxLayout* buttonLayout = new QHBoxLayout;
@@ -156,6 +156,6 @@
   buttonLayout->addWidget(_buttonMap);
   buttonLayout->addWidget(_buttonGet);
-  buttonLayout->addWidget(_buttonCancel);
-  buttonLayout->addWidget(_buttonOK);
+  buttonLayout->addWidget(_buttonSelect);
+  buttonLayout->addWidget(_buttonClose);
 
   mainLayout->addLayout(buttonLayout);
@@ -171,6 +171,6 @@
   delete _ntripVersionComboBox;
   delete _buttonGet;
-  delete _buttonCancel;
-  delete _buttonOK;
+  delete _buttonClose;
+  delete _buttonSelect;
   delete _buttonWhatsThis;
   delete _buttonCasterTable;
@@ -303,9 +303,11 @@
 
   bncMap* winMap = new bncMap(this);
-  winMap->setGeometry( x(), int(y()+height()*1.2), 860, 400 );
+  winMap->setGeometry( x(), int(y()+height()*1.3), 880, 440 );
 
   connect(this, SIGNAL(newPoint(QPointF, QString, QPen)),
 	  winMap, SLOT(slotNewPoint(QPointF, QString, QPen)));
-  connect(this, SIGNAL(resetMap()), winMap, SLOT(slotResetMap()));
+      
+  connect(this, SIGNAL(fitMap()),
+	  winMap, SLOT(slotFitMap() ));
       
   _buttonMap->setEnabled(false);
@@ -316,5 +318,7 @@
   disconnect(this, SIGNAL(newPoint(QPointF, QString, QPen)),
 	     winMap, SLOT(slotNewPoint(QPointF, QString, QPen)));
-  disconnect(this, SIGNAL(resetMap()), winMap, SLOT(slotResetMap()));
+   
+  disconnect(this, SIGNAL(fitMap()),
+ 	     winMap, SLOT(slotFitMap() ));
    
   delete winMap;
@@ -335,17 +339,19 @@
     	         point.setY( tmp.at(9).toDouble() );
                  point.setX( tmp.at(10).toDouble() );
+
 	 QString site = tmp.at(1);
 	         site.resize(4);
 
-         emit newPoint(point, site, QPen(QBrush(QColor(0,0,255,180)), 5) );
-       }	     
+         emit newPoint(point, site, QPen(QBrush(QColor(0,0,255,200)), 1.5) );
+       }
      }
    }
-}
-
-
-// Accept slot
-////////////////////////////////////////////////////////////////////////////
-void bncTableDlg::accept() {
+   emit fitMap();
+}
+
+
+// Select slot
+////////////////////////////////////////////////////////////////////////////
+void bncTableDlg::select() {
 
   bncSettings settings;
@@ -361,5 +367,4 @@
   QStringList* mountPoints = new QStringList;
   if (_table) {
-//  emit resetMap();
     for (int ir = 0; ir < _table->rowCount(); ir++) {
       QTableWidgetItem* item   = _table->item(ir,0);
@@ -373,16 +378,14 @@
       if (_table->isItemSelected(item)) {
         url.setPath(item->text());
-        mountPoints->push_back(url.toString() + " " + format + " " + latitude 
+        mountPoints->push_back(url.toString() + " " + format + " " + latitude
                         + " " + longitude + " " + nmea + " " + ntripVersion);
 	 
+        site.resize(4);
 	emit newPoint(QPointF(longitude.toDouble(),latitude.toDouble()), site,
-		      QPen(QBrush(QColor(255,0,0,180)), 13) );
-
+		      QPen(QBrush(QColor(255,0,0,200)), 3) );
       }
     }
   }
   emit newMountPoints(mountPoints);
-
-  QDialog::accept();
 }
 
@@ -411,6 +414,6 @@
   _buttonWhatsThis->setEnabled(false);
   _buttonGet->setEnabled(false);
-  _buttonCancel->setEnabled(false);
-  _buttonOK->setEnabled(false);
+  _buttonClose->setEnabled(false);
+  _buttonSelect->setEnabled(false);
 
   bncCasterTableDlg* dlg = new bncCasterTableDlg(this);
@@ -429,6 +432,6 @@
   _buttonWhatsThis->setEnabled(true);
   _buttonGet->setEnabled(true);
-  _buttonCancel->setEnabled(true);
-  _buttonOK->setEnabled(true);
+  _buttonClose->setEnabled(true);
+  _buttonSelect->setEnabled(true);
 
 }
Index: /trunk/BNC/bnctabledlg.h
===================================================================
--- /trunk/BNC/bnctabledlg.h	(revision 2795)
+++ /trunk/BNC/bnctabledlg.h	(revision 2796)
@@ -65,8 +65,8 @@
     void newMountPoints(QStringList* mountPoints);
     void newPoint(QPointF, QString, QPen);
-    void resetMap();
+    void fitMap();
 
   private slots:
-    virtual void accept();
+    virtual void select();
     void slotGetTable();
     void slotShowMap();
@@ -88,6 +88,6 @@
     QPushButton* _buttonGet;
     QPushButton* _buttonMap;
-    QPushButton* _buttonCancel;
-    QPushButton* _buttonOK;
+    QPushButton* _buttonClose;
+    QPushButton* _buttonSelect;
     QPushButton* _buttonWhatsThis;
     QPushButton* _buttonCasterTable;
