Index: trunk/BNC/bncmap.cpp
===================================================================
--- trunk/BNC/bncmap.cpp	(revision 3287)
+++ trunk/BNC/bncmap.cpp	(revision 3288)
@@ -10,10 +10,9 @@
 bncMap::bncMap(QWidget* parent) : QDialog(parent)
 {
-  _scale  =  2.8;   // scale the map
-  _LaOff  =   25;   // shift longitude
+  _LaOff   = 25;   // shift longitude
   _mapScen = new QGraphicsScene();
   _mapView = new BncMapView();
   _mapView->setScene(_mapScen);
-  _mapView->setMatrix(QMatrix(_scale,0,0,_scale,0,0));
+  _mapView->resetScale();
   slotReadMap();
   slotCreateMap();
@@ -27,10 +26,6 @@
    
   /* rescale button */
-  QPushButton* buttClean = new QPushButton("Clean");
-  connect(buttClean, SIGNAL(clicked()), this, SLOT(slotCleanMap()));
-
-  /* reset button */
-  QPushButton* buttReset = new QPushButton("Reset");
-  connect(buttReset, SIGNAL(clicked()), this, SLOT(slotResetMap()));
+//  QPushButton* buttClean = new QPushButton("Clean");
+//  connect(buttClean, SIGNAL(clicked()), this, SLOT(slotCleanMap()));
 
   /* zoom button */
@@ -42,7 +37,15 @@
   connect(buttZoomOut, SIGNAL(clicked()), this, SLOT(slotZoomOut()));
 
+  /* reset button */
+  QPushButton* buttReset = new QPushButton("World");
+  connect(buttReset, SIGNAL(clicked()), this, SLOT(slotResetMap()));
+
   /* fit button */
-  QPushButton* buttFit = new QPushButton("Fit");
+  QPushButton* buttFit = new QPushButton("Fit Map");
   connect(buttFit, SIGNAL(clicked()), this, SLOT(slotFitMap()));
+
+  /* font reset button */
+  QPushButton* buttFont = new QPushButton("Fit Font");
+  connect(buttFont, SIGNAL(clicked()), this, SLOT(slotFitFont()));
 
   /* layout */
@@ -52,7 +55,8 @@
   ButLayout->addWidget(buttZoomIn);
   ButLayout->addWidget(buttZoomOut);
-  ButLayout->addWidget(buttClean);
+//  ButLayout->addWidget(buttClean);
   ButLayout->addWidget(buttReset);
   ButLayout->addWidget(buttFit);
+  ButLayout->addWidget(buttFont);
   ButLayout->addWidget(buttClose);
    
@@ -145,4 +149,5 @@
   slotCreateMap();
   slotResetMap();
+  slotFitFont();
 }
 
@@ -151,19 +156,5 @@
 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 );
+  _mapView->resetScale();
 }
 
@@ -174,12 +165,76 @@
   QRectF reg = _allPoints.boundingRect().adjusted(-10,-10,10,10);
    
+  _mapView->resetScale();
   _mapView->updateSceneRect(reg);
   _mapView->centerOn(reg.center());
   _mapView->fitInView(reg,Qt::KeepAspectRatio);
-}
-
-
-// ------------
-void bncMap::slotNewPoint(QPointF point, QString name, QPen pen)
+
+  slotFitFont();
+}
+
+
+// ------------
+void bncMap::slotFitFont()
+{  
+  _mapScen->clear();
+  slotCreateMap();
+
+  float fontsize  = _mapView->scale_rate();
+  float pointsize = _mapView->scale_rate();
+   
+  QMapIterator<QString, QList<QVariant> >  it(_allNames);
+  while( it.hasNext() ){  
+     
+     it.next();
+     QString name = it.key();     
+     QList<QVariant> tmp = it.value();
+       
+     double la    = tmp.at(0).toPointF().x();
+     double fi    = tmp.at(0).toPointF().y();
+     QPen   pen   = tmp.at(1).value<QPen>();
+     double basPT = tmp.at(2).toDouble();
+     double basFT = tmp.at(3).toDouble();
+     
+     float tmpPT = pointsize * basPT;
+     float tmpFT =  fontsize * basFT;
+     
+     QFont font(QFont("Arial", 2, 1));
+           font.setPointSizeF( tmpFT );
+
+     QGraphicsTextItem* nameItem = new QGraphicsTextItem( name );
+     nameItem->setFont( font );
+     
+     if( floor(fontsize) < 1 ){
+       nameItem->setPos( la - 4.0 - floor(fontsize), fi - 5.0 - floor(fontsize) );
+     }else{
+       nameItem->setPos( la - 1.0 - floor(fontsize), fi - 4.0 - floor(fontsize) );
+     }
+
+     if( tmpPT < 0.25 ) tmpPT = 0.25;
+     pen.setWidthF(tmpPT);
+
+    _mapScen->addItem( nameItem );
+    _mapScen->addEllipse( la, fi, tmpPT, tmpPT, pen );
+  }
+  _mapView->zoom( 1.0 );
+}
+
+
+// ------------
+void bncMap::slotZoomIn()
+{  
+  _mapView->zoom( 1.2 );
+}
+
+
+// ------------
+void bncMap::slotZoomOut()
+{  
+  _mapView->zoom( 1/1.2 );
+}
+
+
+// ------------
+void bncMap::slotNewPoint(QPointF point, QString name, QPen pen, double size)
 {
   float la =   point.x() + _LaOff;
@@ -189,13 +244,14 @@
   while( la >= 360 ){ la -= 360; }
    
-  _allPoints << QPointF(la, fi);
-  _mapScen->addEllipse( la, fi, 1.5, 1.5, pen );
+  QPointF tmppoint(la,fi);
+  _allPoints << tmppoint;
 
   if( ! name.isEmpty() ){
-    QGraphicsTextItem* nameItem = new QGraphicsTextItem( name );
-    nameItem->setPos( QPointF(la-1, fi-2));
-    nameItem->setFont( QFont("Arial", 2, 1) );
-
-    _mapScen->addItem( nameItem );
-  }
-}
+
+    QList<QVariant> tmp;
+    tmp << tmppoint      // QPoint
+        << pen           // QPen
+        << size << 4.5;  // base pointsize, fontsize
+    _allNames.insert( name, tmp );
+  }
+}
