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

📄 fetchmap.cpp

📁 给予QT的qps开源最新源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
                        tr("Latitude not specified.\n\nYou must specify a latitude."),
                        QMessageBox::Warning,
                        QMessageBox::Ok | QMessageBox::Default,
                        QMessageBox::NoButton,
                        QMessageBox::NoButton );
        mb.exec();
        mb.hide();
        valid = FALSE;
    } else if (scaleCB->currentText().stripWhiteSpace().isEmpty()) {
        QMessageBox mb( tr("Map Download"),
                        tr("Scale not specified.\n\nYou must specify a scale."),
                        QMessageBox::Warning,
                        QMessageBox::Ok | QMessageBox::Default,
                        QMessageBox::NoButton,
                        QMessageBox::NoButton );
        mb.exec();
        mb.hide();
        valid = FALSE;
    }
    else if (nameLE->text().stripWhiteSpace().isEmpty()) {
        QMessageBox mb( tr("Map Download"),
                        tr("Map name not specified.\n"
                        "You must specify a map name.\n\n"
                        "Click 'OK' for a default name."),
                        QMessageBox::Warning,
                        QMessageBox::Ok | QMessageBox::Default,
                        QMessageBox::Cancel,
                        QMessageBox::NoButton );
        mb.exec();
        mb.hide();

        valid = (mb.result() == QMessageBox::Ok);
    }
    return valid;
}

void DownloadSpecificationWidget::setDownloadSpecification(DownloadSpecification *dlSpec)
{
    spec = dlSpec;

    double lat, lon;
    if (spec->latitude < 0) {
        lat = spec->latitude * -1.0;
        latitudeCB->setCurrentItem(1);
    } else {
        lat = spec->latitude;
    }
    if (spec->longitude < 0) {
        lon = spec->longitude * -1.0;
        longitudeCB->setCurrentItem(1);
    } else {
        lon = spec->longitude;
    }

    QString string;
    nameLE->setText(spec->name);
    latitudeLE->setText(string.setNum(lat));
    longitudeLE->setText(string.setNum(lon));
    scaleCB->setEditText(string.setNum(spec->scale));
}

bool DownloadSpecificationWidget::accept()
{
    bool valid = validate();
    if (valid) {
        spec->name = nameLE->text();
        spec->latitude = latitudeLE->text().toDouble();
        spec->longitude = longitudeLE->text().toDouble();
        spec->scale = scaleCB->currentText().toULong();

        if (latitudeCB->currentItem() == 0)
            spec->latHem = DownloadSpecification::NorthernHemisphere;
        else
            spec->latHem = DownloadSpecification::SouthernHemisphere;
        if (longitudeCB->currentItem() == 0)
            spec->lonHem = DownloadSpecification::EasternHemisphere;
        else
            spec->lonHem = DownloadSpecification::WesternHemisphere;

        // user accepted a default name
        if (nameLE->text().stripWhiteSpace().isEmpty()) {
            // no name given, create one based on scale factor and position
            QString str;
            str = "map_" + str.setNum(spec->scale) +"-"+
                  str.setNum(spec->latitude*spec->latHem) +"--"+ str.setNum(spec->longitude*spec->lonHem);
            nameLE->setText(str);
            valid = false;
        }
    }
    return valid;
}

DownLoadDialog::DownLoadDialog(Position &pos, MapSelector *maps, QWidget *parent,
                               const char *name, bool modal,WFlags f):
        QDialog(parent,name,modal,f)
{
    QVBox *vBox;
    vBox = new QVBox(this);

    MapSourceFile mapSrcF(maps->mapPathStr() + "/sources.txt");
    mapSrcL = mapSrcF.makeMapSourceList();
    mapSrcW = new MapSourceWidget(vBox);
    mapSrcW->setMapSourceList(mapSrcL);

    spec = new DownloadSpecification(pos, maps); // pass the current gps data in here for suggested lat,long,name!
    dlSpecW = new DownloadSpecificationWidget(spec, vBox);

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

DownLoadDialog::~DownLoadDialog(){};

void DownLoadDialog::accept()
{
    if (dlSpecW->accept()) {
        spec->download(mapSrcL->at(mapSrcW->getSourceIndex()));
        QDialog::accept();
    }
}

ImportMapDialog::ImportMapDialog(MapSelector*, QWidget *parent,
                                 const char *name, bool modal,WFlags f):
        QDialog(parent,name,modal,f)
{
    imageSelected = FALSE;
    vBox = new QVBox(this);
#ifndef DESKTOP
    imageDialog = new FileSelector( "image/*", vBox, tr("image dialog"), FALSE, FALSE );
#else
    imageDialog = new QFileDialog ( ".", "", vBox, tr("image dialog"), TRUE);
#endif

    bg = new QVButtonGroup("",vBox);
    cpOrg = new QRadioButton(tr("copy image"),bg);
    delOrg = new QRadioButton(tr("remove original image"),bg);
    bg->setButton(1);


    connect(imageDialog, SIGNAL(fileSelected(const DocLnk& )),
            this, SLOT(docLnkSelected(const DocLnk&)));
    resize(parent->geometry().size());
    vBox->resize(geometry().size());
}
void ImportMapDialog::docLnkSelected(const DocLnk &d)
{
    imageSelected = TRUE;
    mapImageLnk = d;
}

ImportMapDialog::~ImportMapDialog(){};

MapParDialog::MapParDialog(MapBase *, QWidget *parent,
                           const char *name, bool modal,WFlags f):
        QDialog(parent,name,modal,f)
{
    vBox = new QVBox(this);
    mapView = new MapInfoView(vBox);

    // this typecasting of parent is bad and this is why
    //mapWidget->resize(((FetchMap*)parent)->image->width(), ((FetchMap*)parent)->image->height());
    //mapWidget->setBackgroundPixmap(*(((FetchMap*)parent)->image));
    mapView->setMap(((MapInfo*)parent)->mapView->selectedMap);

    hBox = new QHBox(vBox);
    projectionCB = new QComboBox(hBox);
    projectionCB->insertItem("LINEAR");
    projectionCB->insertItem("CEA");
    projectionCB->insertItem("UTM");
    projectionCB->insertItem("TM");
    projectionCB->insertItem("MERCATOR");
    projectionCB->insertItem("LAMBERT");
    projectionCB->insertItem("FRITZ");

    scaleL = new QLabel(tr("  scale 1:"),hBox);
    scaleLE = new QLineEdit("10000",hBox);
    scaleLE->setValidator(new QIntValidator(1,100000000,scaleLE));

    point1HB = new QHBox(vBox);
    p1xyLVB = new QVBox(point1HB);
    x1L = new QLabel(tr(" x1"),p1xyLVB);
    y1L = new QLabel(tr(" y1"),p1xyLVB);
    p1xyLEVB = new QVBox(point1HB);
    x1LE = new QLineEdit("",p1xyLEVB);
    x1LE->setMaximumHeight(x1LE->fontMetrics().height()+2);
    //x1LE->setValidator(new QIntValidator(0,((FetchMap*)parent)->image->width(),x1LE));
    x1LE->setValidator(new QIntValidator(0,((MapInfo*)parent)->image->width(),x1LE));
    y1LE = new QLineEdit("",p1xyLEVB);
    y1LE->setMaximumHeight(y1LE->fontMetrics().height()+2);
    //y1LE->setValidator(new QIntValidator(0,((FetchMap*)parent)->image->height(),y1LE));
    y1LE->setValidator(new QIntValidator(0,((MapInfo*)parent)->image->height(),y1LE));
    p1llLVB = new QVBox(point1HB);
    lg1L = new QLabel(tr(" long1"),p1llLVB);
    lt1L = new QLabel(tr(" lat1"),p1llLVB);
    p1llLEVB = new QVBox(point1HB);
    lg1LE = new QLineEdit("",p1llLEVB);
    lg1LE->setMaximumHeight(lg1LE->fontMetrics().height()+2);
    //lg1LE->setValidator(new QDoubleValidator(-180,180,7,lg1LE));
    // FIXME: write validators vor lat/longitude
    lt1LE = new QLineEdit("",p1llLEVB);
    lt1LE->setMaximumHeight(lt1LE->fontMetrics().height()+2);
    //lt1LE->setValidator(new QDoubleValidator(-90,90,7,lt1LE));
    // FIXME: write validators vor lat/longitude

    point2HB = new QHBox(vBox);
    p2xyLVB = new QVBox(point2HB);
    x2L = new QLabel(tr(" x2"),p2xyLVB);
    y2L = new QLabel(tr(" y2"),p2xyLVB);
    p2xyLEVB = new QVBox(point2HB);
    x2LE = new QLineEdit("",p2xyLEVB);
    x2LE->setMaximumHeight(x2LE->fontMetrics().height()+2);
    //x2LE->setValidator(new QIntValidator(0,((FetchMap*)parent)->image->width(),x2LE));
    x2LE->setValidator(new QIntValidator(0,((MapInfo*)parent)->image->width(),x2LE));
    y2LE = new QLineEdit("",p2xyLEVB);
    y2LE->setMaximumHeight(y2LE->fontMetrics().height()+2);
    //y2LE->setValidator(new QIntValidator(0,((FetchMap*)parent)->image->height(),y2LE));
    y2LE->setValidator(new QIntValidator(0,((MapInfo*)parent)->image->height(),y2LE));
    p2llLVB = new QVBox(point2HB);
    lg2L = new QLabel(tr(" long2"),p2llLVB);
    lt2L = new QLabel(tr(" lat2"),p2llLVB);
    p2llLEVB = new QVBox(point2HB);
    lg2LE = new QLineEdit("",p2llLEVB);
    lg2LE->setMaximumHeight(lg2LE->fontMetrics().height()+2);
    //lg2LE->setValidator(new QDoubleValidator(-180,180,7,lg2LE));
    // FIXME: write validators for lat/longitude
    lt2LE = new QLineEdit("",p2llLEVB);
    lt2LE->setMaximumHeight(lt2LE->fontMetrics().height()+2);
    //lt2LE->setValidator(new QDoubleValidator(-90,90,7,lt2LE));
    // FIXME: write validators for lat/longitude

    stdLat12HB = new QHBox(vBox);
    stdLat1L = new QLabel(tr("stdLat1"),stdLat12HB);
    stdLat1LE = new QLineEdit("",stdLat12HB);
    stdLat1LE->setMaximumHeight(stdLat1LE->fontMetrics().height()+2);
    //stdLat1LE->setValidator(new QDoubleValidator(-90,90,7,stdLat1LE));
    // FIXME: write validators for lat/longitude
    stdLat2L = new QLabel(tr("stdLat2"),stdLat12HB);
    stdLat2LE = new QLineEdit("",stdLat12HB);
    stdLat2LE->setMaximumHeight(stdLat2LE->fontMetrics().height()+2);
    //stdLat2LE->setValidator(new QDoubleValidator(-90,90,7,stdLat2LE));
    // FIXME: write validators for lat/longitude
    refLongL = new QLabel(tr("refLong"),stdLat12HB);
    refLongLE = new QLineEdit("",stdLat12HB);
    refLongLE->setMaximumHeight(refLongLE->fontMetrics().height()+2);
    //refLongLE->setValidator(new QDoubleValidator(-180,180,7,refLongLE));
    // FIXME: write validators for lat/longitude


    stdLongHB = new QHBox(vBox);
    stdLongL = new QLabel(tr("stdLongitude"),stdLongHB);
    stdLongLE = new QLineEdit("",stdLongHB);
    stdLongLE->setMaximumHeight(stdLongLE->fontMetrics().height()+2);
    //stdLongLE->setValidator(new QDoubleValidator(-180,180,7,stdLongLE));
    // FIXME: write validators for lat/longitude

    centerHB = new QHBox(vBox);
    centerLatL = new QLabel(tr("center latitude"),centerHB);
    centerLatLE = new QLineEdit("",centerHB);
    //centerLatLE->setValidator(new QDoubleValidator(-90,90,7,centerLatLE));
    // FIXME: write validators for lat/longitude
    centerLongL = new QLabel(tr(" longitude"),centerHB);
    centerLongLE = new QLineEdit("",centerHB);
    //centerLongLE->setValidator(new QDoubleValidator(-180,180,7,centerLongLE));
    // FIXME: write validators for lat/longitude

    utmHB = new QHBox(vBox);
    zoneL = new QLabel(tr("Zone"),utmHB);
    zoneLE = new QLineEdit("",utmHB);

    connect(projectionCB, SIGNAL(highlighted(int)),
            this, SLOT(showProjectionPar(int)));
    connect(mapView, SIGNAL(mouseClick(int, int)),
            SLOT(clickPosition(int, int)) );

    projectionCB->setCurrentItem(6);

    resize(parent->geometry().size());
    vBox->resize(geometry().size());
    scaleLE->setFocus();
}
MapParDialog::~MapParDialog(){};

void MapParDialog::showProjectionPar(int idx)
{
    // hide all
    point1HB->hide();
    point2HB->hide();
    stdLongHB->hide();
    stdLat12HB->hide();
    centerHB->hide();
    utmHB->hide();
    lt1L->setText(tr("lat1"));
    lg1L->setText(tr("long1"));
    lt2L->setText(tr("lat2"));
    lg2L->setText(tr("long2"));

    switch(idx)
    {
    case 0:
    case 1:
    case 4:
        // 2 ref points
        point1HB->show();
        point2HB->show();

        break;

    case 2:
        // UTM
        utmHB->show();
        point1HB->show();
        point2HB->show();
        lt1L->setText(tr("north1"));
        lg1L->setText(tr("east1"));
        lt2L->setText(tr("north2"));
        lg2L->setText(tr("east2"));
        break;

    case 3:
        // TM: 2 points + stdLong
        point1HB->show();
        point2HB->show();
        stdLongHB->show();
        break;

    case 5:
        // Lambert: 2 points + std1Lat, std2Lat, refLong
        point1HB->show();
        point2HB->show();
        stdLat12HB->show();
        break;

    case 6:
        // Fritz: center_latitude, center_longitude
        centerHB->show();
        break;
    }
}

void MapParDialog::clickPosition(int x,int y)
{
    if(x1LE->hasFocus() || y1LE->hasFocus())
    {
        x1LE->setText(tr("%1").arg(x));
        y1LE->setText(tr("%1").arg(y));
    }
    else if(x2LE->hasFocus() || y2LE->hasFocus() )
    {
        x2LE->setText(tr("%1").arg(x));
        y2LE->setText(tr("%1").arg(y));
    }

⌨️ 快捷键说明

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