Changeset 2796 in ntrip
- Timestamp:
- Dec 14, 2010, 3:47:20 PM (14 years ago)
- Location:
- trunk/BNC
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncmap.cpp
r2754 r2796 10 10 bncMap::bncMap(QWidget* parent) : QDialog(parent) 11 11 { 12 _scale = 2.8; // scale the map 13 _LaOff = 20; // shift longitude 14 _mapView = new QGraphicsView(); 12 _scale = 2.8; // scale the map 13 _LaOff = 25; // shift longitude 15 14 _mapScen = new QGraphicsScene(); 15 _mapView = new BncMapView(); 16 16 _mapView->setScene(_mapScen); 17 _mapView->setMatrix(QMatrix(_scale,0,0,_scale,0,0)); 17 18 slotReadMap(); 18 19 slotCreateMap(); 19 20 setWindowTitle(tr("World Map [*]")); 20 _mapScen->setSceneRect(QRect(0,-90,360,180)); 21 22 setWindowTitle(tr("Source-Table Map [*]")); 21 23 22 24 /* close button */ 23 25 QPushButton* buttClose = new QPushButton("Close"); 24 26 connect(buttClose, SIGNAL(clicked()), this, SLOT(close())); 27 28 /* rescale button */ 29 QPushButton* buttClean = new QPushButton("Clean"); 30 connect(buttClean, SIGNAL(clicked()), this, SLOT(slotCleanMap())); 25 31 26 32 /* reset button */ … … 28 34 connect(buttReset, SIGNAL(clicked()), this, SLOT(slotResetMap())); 29 35 36 /* zoom button */ 37 QPushButton* buttZoomIn = new QPushButton("Zoom +"); 38 connect(buttZoomIn, SIGNAL(clicked()), this, SLOT(slotZoomIn())); 39 40 /* zoom button */ 41 QPushButton* buttZoomOut = new QPushButton("Zoom -"); 42 connect(buttZoomOut, SIGNAL(clicked()), this, SLOT(slotZoomOut())); 43 44 /* fit button */ 45 QPushButton* buttFit = new QPushButton("Fit"); 46 connect(buttFit, SIGNAL(clicked()), this, SLOT(slotFitMap())); 47 30 48 /* layout */ 31 QGridLayout *layout = new QGridLayout; 32 layout->setRowMinimumHeight( 0, 250); 33 layout->addWidget(_mapView, 0, 0, 3, 1, Qt::AlignLeft); 34 layout->addWidget(buttReset, 1, 1, 1, 1, Qt::AlignBottom); 35 layout->addWidget(buttClose, 2, 1, 1, 1, Qt::AlignBottom); 36 setLayout(layout); 37 38 // this->resize(860,400); 49 QVBoxLayout* MapLayout = new QVBoxLayout; 50 QHBoxLayout* ButLayout = new QHBoxLayout; 51 52 ButLayout->addWidget(buttZoomIn); 53 ButLayout->addWidget(buttZoomOut); 54 ButLayout->addWidget(buttClean); 55 ButLayout->addWidget(buttReset); 56 ButLayout->addWidget(buttFit); 57 ButLayout->addWidget(buttClose); 58 59 MapLayout->addWidget(_mapView); 60 MapLayout->addLayout(ButLayout); 61 62 setLayout(MapLayout); 63 39 64 this->show(); 40 65 } … … 61 86 62 87 in >> la >> fi; 88 89 // la = 0-360 90 while( la < 0 ){ la += 360; } 91 while( la >= 360 ){ la -= 360; } 92 93 // fi opposite 63 94 _worldMap << QPointF( la, -fi ); 64 95 65 96 } 66 67 97 world.close(); 68 98 } … … 72 102 void bncMap::slotCreateMap() 73 103 { 74 //mapScen->setForegroundBrush(QBrush(Qt::lightGray, Qt::CrossPattern)); // grid104 // _mapScen->setForegroundBrush(QBrush(Qt::lightGray, Qt::CrossPattern)); // grid 75 105 76 106 int begIdx = 0; … … 79 109 if( _worldMap.at(i).x() == 0.0 and _worldMap.at(i).y() == 0.0 ){ 80 110 if( i > 0 ){ 81 111 endIdx = i-1; 82 112 while( begIdx < endIdx ){ 83 113 84 85 114 int l1 = 0; 115 int l2 = 0; 86 116 87 117 float la1 = _worldMap.at(begIdx+0).x() + _LaOff; … … 90 120 float fi2 = _worldMap.at(begIdx+1).y(); 91 121 begIdx++; 92 93 94 95 96 97 98 99 100 101 _mapScen->addLine(la1 *_scale, fi1*_scale, la2*_scale, fi2*_scale, QPen(QBrush(Qt::black),1));122 123 while( la1 < 0 ){ la1 += 360; l1++; } 124 while( la1 >= 360 ){ la1 -= 360; l1--; } 125 while( la2 < 0 ){ la2 += 360; l2++; } 126 while( la2 >= 360 ){ la2 -= 360; l2--; } 127 128 if( l1 != 0 and l2 == 0 ){ continue; } // break this line 129 if( l2 != 0 and l1 == 0 ){ continue; } // break this line 130 131 _mapScen->addLine(la1, fi1, la2, fi2, QPen(QBrush(Qt::gray),0.3)); 102 132 } 103 133 } … … 105 135 } 106 136 } 107 _mapScen->setSceneRect(0*_scale,-90*_scale,360*_scale,180*_scale); 108 } 109 110 111 // ------------ 112 void bncMap::slotResetMap() 137 } 138 139 140 // ------------ 141 void bncMap::slotCleanMap() 113 142 { 114 143 QMutexLocker locker(&_mutexMap); 115 144 _mapScen->clear(); 116 145 slotCreateMap(); 146 slotResetMap(); 147 } 148 149 150 // ------------ 151 void bncMap::slotResetMap() 152 { 153 _mapView->setMatrix(QMatrix(_scale,0,0,_scale,0,0)); 154 } 155 156 157 // ------------ 158 void bncMap::slotZoomIn() 159 { 160 _mapView->scale( 1.2, 1.2 ); 161 } 162 163 164 // ------------ 165 void bncMap::slotZoomOut() 166 { 167 _mapView->scale( 1/1.2, 1/1.2 ); 168 } 169 170 171 // ------------ 172 void bncMap::slotFitMap() 173 { 174 QRectF reg = _allPoints.boundingRect().adjusted(-10,-10,10,10); 175 176 _mapView->updateSceneRect(reg); 177 _mapView->centerOn(reg.center()); 178 _mapView->fitInView(reg,Qt::KeepAspectRatio); 117 179 } 118 180 … … 121 183 void bncMap::slotNewPoint(QPointF point, QString name, QPen pen) 122 184 { 123 float la = point.x() + _LaOff; 124 float fi = point.y(); 185 float la = point.x() + _LaOff; 186 float fi = - point.y(); 125 187 126 188 while( la < 0 ){ la += 360; } 127 189 while( la >= 360 ){ la -= 360; } 128 129 _mapScen->addEllipse( la*_scale, -fi*_scale, 5, 5, pen ); 190 191 _allPoints << QPointF(la, fi); 192 _mapScen->addEllipse( la, fi, 1.5, 1.5, pen ); 130 193 131 194 if( ! name.isEmpty() ){ 132 195 QGraphicsTextItem* nameItem = new QGraphicsTextItem( name ); 133 nameItem->setPos( QPointF(la *_scale, -fi*_scale));134 nameItem->setFont( QFont(" Helvetica", 8) );196 nameItem->setPos( QPointF(la-1, fi-2)); 197 nameItem->setFont( QFont("Arial", 2, 1) ); 135 198 136 199 _mapScen->addItem( nameItem ); -
trunk/BNC/bncmap.h
r2755 r2796 7 7 8 8 #include <QtGui> 9 #include "bncmapview.h" 9 10 10 11 class bncMap : public QDialog … … 17 18 18 19 public slots: 19 void slotNewPoint( QPointF, QString, QPen); 20 void slotNewPoint(QPointF, QString, QPen); 21 void slotResetMap(); 22 void slotFitMap(); 23 void slotZoomIn(); 24 void slotZoomOut(); 20 25 void slotCreateMap(); 21 void slot ResetMap();26 void slotCleanMap(); 22 27 void slotReadMap(); 23 28 … … 27 32 double _LaOff; 28 33 29 QGraphicsView*_mapView;34 BncMapView* _mapView; 30 35 QGraphicsScene* _mapScen; 31 36 QPolygonF _worldMap; 37 QPolygonF _allPoints; 32 38 QMutex _mutexMap; 33 39 -
trunk/BNC/bnctabledlg.cpp
r2755 r2796 145 145 connect(_buttonMap, SIGNAL(clicked()), this, SLOT(slotShowMap())); 146 146 147 _buttonC ancel= new QPushButton(tr("Cancel"), this);148 connect(_buttonC ancel, SIGNAL(clicked()), this, SLOT(reject()));149 150 _button OK= new QPushButton(tr("OK"), this);151 connect(_button OK, SIGNAL(clicked()), this, SLOT(accept()));147 _buttonClose = new QPushButton(tr("Close"), this); 148 connect(_buttonClose, SIGNAL(clicked()), this, SLOT(close())); 149 150 _buttonSelect = new QPushButton(tr("Select"), this); 151 connect(_buttonSelect, SIGNAL(clicked()), this, SLOT(select())); 152 152 153 153 QHBoxLayout* buttonLayout = new QHBoxLayout; … … 156 156 buttonLayout->addWidget(_buttonMap); 157 157 buttonLayout->addWidget(_buttonGet); 158 buttonLayout->addWidget(_button Cancel);159 buttonLayout->addWidget(_button OK);158 buttonLayout->addWidget(_buttonSelect); 159 buttonLayout->addWidget(_buttonClose); 160 160 161 161 mainLayout->addLayout(buttonLayout); … … 171 171 delete _ntripVersionComboBox; 172 172 delete _buttonGet; 173 delete _buttonC ancel;174 delete _button OK;173 delete _buttonClose; 174 delete _buttonSelect; 175 175 delete _buttonWhatsThis; 176 176 delete _buttonCasterTable; … … 303 303 304 304 bncMap* winMap = new bncMap(this); 305 winMap->setGeometry( x(), int(y()+height()*1. 2), 860, 400 );305 winMap->setGeometry( x(), int(y()+height()*1.3), 880, 440 ); 306 306 307 307 connect(this, SIGNAL(newPoint(QPointF, QString, QPen)), 308 308 winMap, SLOT(slotNewPoint(QPointF, QString, QPen))); 309 connect(this, SIGNAL(resetMap()), winMap, SLOT(slotResetMap())); 309 310 connect(this, SIGNAL(fitMap()), 311 winMap, SLOT(slotFitMap() )); 310 312 311 313 _buttonMap->setEnabled(false); … … 316 318 disconnect(this, SIGNAL(newPoint(QPointF, QString, QPen)), 317 319 winMap, SLOT(slotNewPoint(QPointF, QString, QPen))); 318 disconnect(this, SIGNAL(resetMap()), winMap, SLOT(slotResetMap())); 320 321 disconnect(this, SIGNAL(fitMap()), 322 winMap, SLOT(slotFitMap() )); 319 323 320 324 delete winMap; … … 335 339 point.setY( tmp.at(9).toDouble() ); 336 340 point.setX( tmp.at(10).toDouble() ); 341 337 342 QString site = tmp.at(1); 338 343 site.resize(4); 339 344 340 emit newPoint(point, site, QPen(QBrush(QColor(0,0,255, 180)),5) );341 } 345 emit newPoint(point, site, QPen(QBrush(QColor(0,0,255,200)), 1.5) ); 346 } 342 347 } 343 348 } 344 } 345 346 347 // Accept slot 348 //////////////////////////////////////////////////////////////////////////// 349 void bncTableDlg::accept() { 349 emit fitMap(); 350 } 351 352 353 // Select slot 354 //////////////////////////////////////////////////////////////////////////// 355 void bncTableDlg::select() { 350 356 351 357 bncSettings settings; … … 361 367 QStringList* mountPoints = new QStringList; 362 368 if (_table) { 363 // emit resetMap();364 369 for (int ir = 0; ir < _table->rowCount(); ir++) { 365 370 QTableWidgetItem* item = _table->item(ir,0); … … 373 378 if (_table->isItemSelected(item)) { 374 379 url.setPath(item->text()); 375 mountPoints->push_back(url.toString() + " " + format + " " + latitude 380 mountPoints->push_back(url.toString() + " " + format + " " + latitude 376 381 + " " + longitude + " " + nmea + " " + ntripVersion); 377 382 383 site.resize(4); 378 384 emit newPoint(QPointF(longitude.toDouble(),latitude.toDouble()), site, 379 QPen(QBrush(QColor(255,0,0,180)), 13) ); 380 385 QPen(QBrush(QColor(255,0,0,200)), 3) ); 381 386 } 382 387 } 383 388 } 384 389 emit newMountPoints(mountPoints); 385 386 QDialog::accept();387 390 } 388 391 … … 411 414 _buttonWhatsThis->setEnabled(false); 412 415 _buttonGet->setEnabled(false); 413 _buttonC ancel->setEnabled(false);414 _button OK->setEnabled(false);416 _buttonClose->setEnabled(false); 417 _buttonSelect->setEnabled(false); 415 418 416 419 bncCasterTableDlg* dlg = new bncCasterTableDlg(this); … … 429 432 _buttonWhatsThis->setEnabled(true); 430 433 _buttonGet->setEnabled(true); 431 _buttonC ancel->setEnabled(true);432 _button OK->setEnabled(true);434 _buttonClose->setEnabled(true); 435 _buttonSelect->setEnabled(true); 433 436 434 437 } -
trunk/BNC/bnctabledlg.h
r2753 r2796 65 65 void newMountPoints(QStringList* mountPoints); 66 66 void newPoint(QPointF, QString, QPen); 67 void resetMap();67 void fitMap(); 68 68 69 69 private slots: 70 virtual void accept();70 virtual void select(); 71 71 void slotGetTable(); 72 72 void slotShowMap(); … … 88 88 QPushButton* _buttonGet; 89 89 QPushButton* _buttonMap; 90 QPushButton* _buttonC ancel;91 QPushButton* _button OK;90 QPushButton* _buttonClose; 91 QPushButton* _buttonSelect; 92 92 QPushButton* _buttonWhatsThis; 93 93 QPushButton* _buttonCasterTable;
Note:
See TracChangeset
for help on using the changeset viewer.