void AreaSettingsDialog::restore() { points.clear(); points.push_back(PointWorldCoord( 20.4617, 50.7831)); points.push_back(PointWorldCoord( 20.4627, 50.7828)); points.push_back(PointWorldCoord( 20.4614, 50.782)); points.push_back(PointWorldCoord( 20.4603, 50.7824)); ui->lineEdit_p1->setText(DegMinSec(points.at(0).longitude()).toDMSString() + " x " + DegMinSec(points.at(0).latitude()).toDMSString()); ui->lineEdit_p2->setText(DegMinSec(points.at(1).longitude()).toDMSString() + " x " + DegMinSec(points.at(1).latitude()).toDMSString()); ui->lineEdit_p3->setText(DegMinSec(points.at(2).longitude()).toDMSString() + " x " + DegMinSec(points.at(2).latitude()).toDMSString()); ui->lineEdit_p4->setText(DegMinSec(points.at(3).longitude()).toDMSString() + " x " + DegMinSec(points.at(3).latitude()).toDMSString()); createPolygon(); emit areaChanged(polygon); }
void AreaSettingsDialog::loadFromLineEdits() { qDebug() << "void AreaSettingsDialog::loadFromLineEdits()"; QLineEdit *edit = qobject_cast<QLineEdit *>(sender()); int position = 5; if(edit == ui->lineEdit_p1) position = 0; else if(edit == ui->lineEdit_p2) position = 1; else if(edit == ui->lineEdit_p3) position = 2; else if(edit == ui->lineEdit_p4) position = 3; else return; QRegExp rx("(\\d{1,3})[°dh,\\s]{1,}(\\d{1,3})['m,\\s]{1,}(\\d{1,3}.\\d{1,})[s,'' ]{1,2}[ x,]{1,}(\\d{1,3})[°dh,\\s]{1,}(\\d{1,3})['m,\\s]{1,}(\\d{1,3}.\\d{1,})[s,']{1,2}"); rx.exactMatch(edit->text()); QStringList captured = rx.capturedTexts(); QPalette palette; if(captured.size() == 7 && rx.exactMatch(edit->text())) { qDebug() << "if(captured.size() == 7 && rx.exactMatch(edit->text())) true"; DegMinSec longitude(captured.at(1).toInt(),captured.at(2).toInt(),captured.at(3).toFloat()); DegMinSec latitude(captured.at(4).toInt(),captured.at(5).toInt(),captured.at(6).toFloat()); qDebug() << "lat: " << latitude.toDMSString(); qDebug() << "lon: " << longitude.toDMSString(); points.at(position) = PointWorldCoord(longitude.toDecimalDegress(),latitude.toDecimalDegress()); createPolygon(); emit areaChanged(polygon); palette.setColor(QPalette::Foreground,Qt::black);; } else palette.setColor(QPalette::Foreground,Qt::red); edit->setPalette(palette); }
GeometryWidget::GeometryWidget(const qreal& longitude, const qreal& latitude, QWidget* widget, const int& zoom_minimum, const int& zoom_maximum) : Geometry(Geometry::GeometryType::GeometryWidget, zoom_minimum, zoom_maximum), m_point_coord(PointWorldCoord(longitude, latitude)), m_widget(widget), m_alignment_type(AlignmentType::Middle), m_base_zoom(-1), m_base_size_px(0.0, 0.0), m_draw_minimum_px(-1.0, -1.0), m_draw_maximum_px(-1.0, -1.0) { // Do we have a widget? if(m_widget != nullptr) { // Set the visibility of the widget as well. m_widget->setVisible(true); } }