⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapdisp.cpp

📁 给予QT的qps开源最新源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
   // position relative to the center of the screen
   int x = screenPos.x() - mapdisp->width() / 2;
   int y = screenPos.y() - mapdisp->height() / 2;
   // rotation
   if (mapDispOptions.rotateMap && !mapDispOptions.mode) {
      double angle = deg2rad(-mapOrientation);
      double cosA = cos(angle);
      double sinA = sin(angle);
      double xd = x*cosA - y*sinA;
      double yd = x*sinA + y*cosA;
      x = (int) rint(xd);
      y = (int) rint(yd);
   }   
   // zoom 2x 
   if (mapDispOptions.zoom2x) {
      x /=2;
      y /=2;
   }   
   // add current center of map
   x += centerX;
   y += centerY;

   return QPoint(x,y);
}

QPoint MapDisp::mapToScreen( const QPoint &mapPos )
{
   // position relative to the current center of map
   int x = mapPos.x() - centerX;
   int y = mapPos.y() - centerY;

   // zoom 2x 
   if (mapDispOptions.zoom2x) {
      x *=2;
      y *=2;
   }   
   // rotation
   if (mapDispOptions.rotateMap && !mapDispOptions.mode) {
      double angle = deg2rad(mapOrientation);
      double cosA = cos(angle);
      double sinA = sin(angle);
      double xd = x*cosA - y*sinA;
      double yd = x*sinA + y*cosA;
      x = (int) rint(xd);
      y = (int) rint(yd);
   }   
   // add the center of the screen
   x += mapdisp->width() / 2;
   y += mapdisp->height() / 2;
   
   return QPoint(x,y);
}

AnimateParamsDialog::AnimateParamsDialog(const QString &trackPath, QWidget *parent, const char *name, bool modal,WFlags f) : QDialog(parent,name,modal,f)
{
   resize(220,160);

   QHBox *hBox, *vBox;

   vBox = new QVBox(this);

   hBox = new QHBox(vBox);
   trackFileCB = new QComboBox(hBox);

   QDir	*logdir = new QDir();
   // if trackPathStr exists, change logdir to it
   if ( logdir->exists(trackPath) ) {
      logdir->setPath(trackPath);
      // fill list with new files
      const QFileInfoList *list = logdir->entryInfoList();
      QFileInfoListIterator it( *list );
      QFileInfo *fi;
      while ( (fi = it.current())) {
	      // add file to list
	      if ( fi->fileName()[0] != '.' && fi->fileName() != "places.txt" 
               && fi->fileName() != "places.txt~" ) { 
		      trackFileCB->insertItem(fi->fileName().latin1()); 
	      }
         ++it;
      }
   }

   hBox = new QHBox(vBox);
   AccelL = new QLabel(tr("Time Acceleration:"),hBox);
   AccelLEd = new QLineEdit(hBox);
   AccelLEd->setValidator(new QDoubleValidator(0.01, 10000,3, AccelLEd));
   AccelLS = new QLabel(tr("X"),hBox);
   AccelLEd->setText("100");

   hBox = new QHBox(vBox);
   TZL = new QLabel(tr("Time Zone: GMT +"),hBox);
   TZLEd = new QLineEdit(hBox);
   TZLEd->setValidator(new QIntValidator(-23, 23, TZLEd));
   TZLS = new QLabel(tr("h"),hBox);
   TZLEd->setText("0");

   hBox = new QHBox(vBox);
   scTimeTB = new QCheckBox(hBox);
   scTimeTB->setText(tr("Shortcut large time intervals"));
   scTimeTB->setChecked(TRUE);

   vBox->resize(geometry().size());
}

AnimateParamsDialog::~AnimateParamsDialog() {};

void MapCoordEditorDialog::placeSelected(int ind)
{
	if (ind) {
      Place *place = places->at(ind);
		commMLE->setText(place->comment);  
		DDddB->setChecked(TRUE);
		LatiLEd->setText(tr("%1").arg(place->pos.lat,0,'f'));
		LonLEd->setText(tr("%1").arg(place->pos.lon,0,'f'));
		AltLE->setText(tr("%1").arg(place->altitude.val));
	}
}

MapCoordEditorDialog::MapCoordEditorDialog(PlaceList *pl,
      QWidget * parent, const char * name, bool modal, WFlags fg)
      : QDialog(parent, name, modal, fg), 
      valInt360(-360, 360, this), valInt60(0, 58, this), 
      valDouble360(-360, 360, 8, this), valDouble60(0, 59.9999, 10, this)

{
   resize(250, 305);
   QVBox * vBox = new QVBox(this);
   //    PlaceGB = new QVGroupBox(tr("Place"),vBox);
   //    hBox = new QHBox(PlaceGB);

   QHBox * hBox = new QHBox(vBox);
   mapLatLonCB = new QComboBox(hBox);
   places = pl;
   Place *place;
   for (place = places->first(); place != 0; place = places->next() ) {
      mapLatLonCB->insertItem(place->name);
   }
   connect( mapLatLonCB, SIGNAL(activated(int)),
         this, SLOT(placeSelected(int)) );

   commMLE = new QMultiLineEdit(vBox);
   commMLE->setWordWrap(QMultiLineEdit::WidgetWidth);
   commMLE->setWrapPolicy(QMultiLineEdit::Anywhere);
   commMLE->setReadOnly(true);
   commMLE->setFixedVisibleLines(3);

   QVGroupBox * CoordGB = new QVGroupBox(tr("Coordinates"), vBox);
   LatLonBG = new QButtonGroup(3, Qt::Horizontal, CoordGB);
   DDddB= new QRadioButton("D\260", LatLonBG);
   connect( DDddB, SIGNAL(toggled(bool)), this, SLOT(toggledDDddB(bool)) );
   DDMMmmB = new QRadioButton("D\260M'", LatLonBG);
   connect( DDMMmmB, SIGNAL(toggled(bool)), this, SLOT(toggledDDMMmmB(bool)) );
   DDMMSSssB = new QRadioButton("D\260M'S\"", LatLonBG);
   connect( DDMMSSssB, SIGNAL( toggled(bool) ), this, SLOT( toggledDDMMSSssB(bool) ) );

   hBox = new QHBox(CoordGB);
   LatiL = new QLabel(tr("   Lat:"),hBox);
   LatiLEd = new QLineEdit(hBox);
   connect( LatiLEd, SIGNAL( textChanged ( const QString & ) ), this, SLOT( editedLtLe(const QString &) ) );
   LatiLd = new QLabel(tr("\260 "),hBox);
   QFont f = LatiL->font();

   f.setPixelSize(f.pixelSize()+3);
   LatiLd->setFont(f);
   LatiLEm = new QLineEdit(hBox);
   connect( LatiLEm, SIGNAL( textChanged ( const QString & ) ), this, SLOT( editedLtLe(const QString &) ) );
   LatiLm = new QLabel(tr("\' "),hBox);
   LatiLm->setFont(f);
   LatiLEs = new QLineEdit(hBox);
   connect( LatiLEs, SIGNAL( textChanged ( const QString & ) ), this, SLOT( editedLtLe(const QString &) ) );
   LatiLs = new QLabel(tr("\""),hBox);
   LatiLs->setFont(f);
   LatiLS = new QLabel(tr("N"),hBox);

   hBox = new QHBox(CoordGB);
   LonL = new QLabel(tr("Long:"),hBox);
   LonLEd = new QLineEdit(hBox);
   connect( LonLEd, SIGNAL( textChanged ( const QString & ) ), this, SLOT( editedLtLe(const QString &) ) );
   LonLd = new QLabel(tr("\260 "),hBox);
   LonLd->setFont(f);
   LonLEm = new QLineEdit(hBox);
   connect( LonLEm, SIGNAL( textChanged ( const QString & ) ), this, SLOT( editedLtLe(const QString &) ) );
   LonLm = new QLabel(tr("\' "),hBox);
   LonLm->setFont(f);
   LonLEs = new QLineEdit(hBox);
   connect( LonLEs, SIGNAL( textChanged ( const QString & ) ), this, SLOT( editedLtLe(const QString &) ) );
   LonLs = new QLabel(tr("\""),hBox);
   LonLs->setFont(f);
   LonLS = new QLabel(tr("E"),hBox);

	hBox = new QHBox(CoordGB);
	AltL = new QLabel(tr(" Alitude:"),hBox);
	AltLE = new QLineEdit(hBox);
	AltLE->setText("0"); 
   switch(Altitude::unit)
	{
	case Altitude::None: 
		AltL = new QLabel(tr("... "),hBox);   
		break;
	case Altitude::Feet: 
		AltL = new QLabel(tr(" ft   "),hBox); 
		break;
	case Altitude::FL: 	 
		AltL = new QLabel(tr(" FL   "),hBox); 
		break;
	case Altitude::Meter: 
		AltL = new QLabel(tr(" meter"),hBox);
		break;
	}

   LatiLEm->setText("");
   LatiLEs->setText("");
   LonLEm->setText("");
   LonLEs->setText("");

   //    MapCoordEditorForm(Position::unit);

   switch(Position::unit) {
      case Position::Degree:
         DDddB->setChecked(true);
         break;
      case Position::DegMin:
         DDMMmmB->setChecked(true);
         break;
      case Position::DegMinSec:
         DDMMSSssB->setChecked(true);
         break;
   }
   vBox->resize(geometry().size());
}

void MapCoordEditorDialog::editedLtLe(const QString &)
{
   if ( LonLEd->edited() || LonLEm->edited()
         || LonLEs->edited()  || LatiLEd->edited()
         || LatiLEm->edited()  || LatiLEs->edited() ) {
      if ( mapLatLonCB->currentItem() != 0 ) {
         mapLatLonCB->setCurrentItem(0);
      }
   }
}

void MapCoordEditorDialog::toggledDDddB(bool state)
{
   if ( state ) {
      double g = LatiLEd->text().toDouble();
      double m = copysign(LatiLEm->text().toDouble(), g);
      double s = copysign(LatiLEs->text().toDouble(), g);
      LatiLEd->setText(tr("%1").arg(dms2deg(g, m, s), 0, 'f'));
      LatiLEm->setText("0");
      LatiLEs->setText("0");

      g = LonLEd->text().toDouble();
      m = copysign(LonLEm->text().toDouble(), g);
      s = copysign(LonLEs->text().toDouble(), g);
      LonLEd->setText(tr("%1").arg(dms2deg(g, m, s), 0, 'f'));
      LonLEm->setText("0");
      LonLEs->setText("0");

      /*  if ( mapLatLonCB->currentItem() != 0 ) {
          mapLatLonCB->setCurrentItem(0);
          }*/

      LatiLEd->setValidator(&valDouble360);
      LonLEd->setValidator(&valDouble360);
      LatiLEm->hide();
      LatiLEs->hide();
      LonLEm->hide();
      LonLEs->hide();
      LatiLm->hide();
      LatiLs->hide();
      LonLm->hide();
      LonLs->hide();
      repaint();
   }
}

void MapCoordEditorDialog::toggledDDMMmmB(bool state)
{
   if ( state ) {
      double g = LatiLEd->text().toDouble();
      g = g + copysign(LatiLEm->text().toDouble()/60, g) + 
         copysign(LatiLEs->text().toDouble()/3600, g);
      LatiLEd->setText(tr("%1").arg(int(g)));
      double m = fabs(g - int(g))*60;
      LatiLEm->setText(tr("%1").arg(m, 0, 'f', 3));
      LatiLEs->setText("0");

      g = LonLEd->text().toDouble();
      g = g + copysign(LonLEm->text().toDouble()/60, g) + 
         copysign(LonLEs->text().toDouble()/3600, g);
      LonLEd->setText(tr("%1").arg(int(g)));
      m = fabs(g - int(g))*60;
      LonLEm->setText(tr("%1").arg(m, 0, 'f', 3));
      LonLEs->setText("0");

      if ( mapLatLonCB->currentItem() != 0 ) {
         mapLatLonCB->setCurrentItem(0);
      }
      LatiLEd->setValidator(&valInt360);
      LatiLEm->setValidator(&valDouble60);
      LonLEd->setValidator(&valInt360);
      LonLEm->setValidator(&valDouble60);
      LatiLEm->show();
      LatiLEs->hide();
      LonLEm->show();
      LonLEs->hide();
      LatiLm->show();
      LatiLs->hide();
      LonLm->show();
      LonLs->hide();
      repaint();
   }
}

void MapCoordEditorDialog::toggledDDMMSSssB(bool state)
{
   if ( state ) {
      double g = LatiLEd->text().toDouble();
      g = g + copysign(LatiLEm->text().toDouble()/60, g) + 
         copysign(LatiLEs->text().toDouble()/3600, g);
      LatiLEd->setText(tr("%1").arg(int(g)));
      double m = fabs(g - int(g))*60;
      LatiLEm->setText(tr("%1").arg(int(m)));
      double s = fabs(m - int(m))*60;
      LatiLEs->setText(tr("%1").arg(s,0,'f',3));

      g = LonLEd->text().toDouble();
      g = g + copysign(LonLEm->text().toDouble()/60, g) + 
         copysign(LonLEs->text().toDouble()/3600, g);
      LonLEd->setText(tr("%1").arg(int(g)));
      m = fabs(g - int(g))*60;
      LonLEm->setText(tr("%1").arg(int(m)));
      s = fabs(m - int(m))*60;
      LonLEs->setText(tr("%1").arg(s,0,'f',3));

      if ( mapLatLonCB->currentItem() != 0 ) {
         mapLatLonCB->setCurrentItem(0);
      }
      LatiLEd->setValidator(&valInt360);
      LatiLEm->setValidator(&valInt60);
      LatiLEs->setValidator(&valDouble60);
      LonLEd->setValidator(&valInt360);
      LonLEm->setValidator(&valInt60);
      LonLEs->setValidator(&valDouble60);
      LatiLEm->show();
      LatiLEs->show();
      LonLEm->show();
      LonLEs->show();
      LatiLm->show();
      LatiLs->show();
      LonLm->show();
      LonLs->show();
      repaint();
   }
}

Position MapCoordEditorDialog::getPosition()
{
   Position pos;
   double g, m, s;
   g = LatiLEd->text().toDouble();
   m = copysign(LatiLEm->text().toDouble(), g);
   s = copysign(LatiLEs->text().toDouble(), g);
   pos.lat = dms2deg(g, m, s);
   g = LonLEd->text().toDouble();
   m = copysign(LonLEm->text().toDouble(), g);
   s = copysign(LonLEs->text().toDouble(), g);
   pos.lon = dms2deg(g, m, s);
   return pos;
}

double MapCoordEditorDialog::getAltitude()
{
   return AltLE->text().toDouble();
}

MapPlaceEditorDialog::MapPlaceEditorDialog(
      QWidget * parent, const char * name, bool modal, WFlags f)
   : QDialog(parent, name, modal, f)
{
   resize(245, 150);
   QVBox * vBox = new QVBox(this);
   QVGroupBox * PlaceGB = new QVGroupBox(tr("Place name: "), vBox);
   QHBox * hBox = new QHBox(PlaceGB);
   NameLEd = new QLineEdit(hBox);
   PlaceGB1 = new QVGroupBox(tr("Comment: "), vBox);
   hBox = new QHBox(PlaceGB1);
   CommentLEd = new QLineEdit(hBox);
   vBox->resize(geometry().size());
}

// end of file

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -