//------------------------------------------------------------- // Grille GRIB void GribPlot::draw_GridPoints (const DataCode &dtc, QPainter &pnt, const Projection *proj) { if (gribReader == NULL) { return; } // GribRecord *rec = gribReader->getFirstGribRecord (); DataCode dd; if (dtc.dataType == GRB_PRV_WIND_XY2D) dd = DataCode (GRB_WIND_VX, dtc.levelType, dtc.levelValue); else if (dtc.dataType == GRB_PRV_CUR_XY2D) dd = DataCode (GRB_CUR_VX, dtc.levelType, dtc.levelValue); else dd = dtc; GribRecord *rec = gribReader->getRecord (dd, getCurrentDate()); if (! rec) return; int px,py, i,j, dl=2; for (i=0; i<rec->getNi(); i++) for (j=0; j<rec->getNj(); j++) { //if (rec->hasValue(i,j)) { proj->map2screen(rec->getX(i), rec->getY(j), &px,&py); pnt.drawLine(px-dl,py, px+dl,py); pnt.drawLine(px,py-dl, px,py+dl); proj->map2screen(rec->getX(i)-360.0, rec->getY(j), &px,&py); pnt.drawLine(px-dl,py, px+dl,py); pnt.drawLine(px,py-dl, px,py+dl); } } }
//============================================================================= // GUI //============================================================================= void DialogMeteotableOptions::addData ( QString title, uchar grbtype, uchar leveltype, uint level, bool defaultvis, int defaultpos ) { uint grbcode = DataCode (grbtype, leveltype, level).toInt32(); bool visible = Util::getSetting (getSettingName_vis(grbcode), defaultvis).toBool(); int pos = Util::getSetting (getSettingName_pos(grbcode), defaultpos).toInt(); MeteotableOptionItem *item = new MeteotableOptionItem (title, DataCode(grbtype,leveltype,level), pos, visible, currentItemCode); currentItemCode ++; listAllOptionItems.append (item); }
//-------------------------------------------------------------------------- void GribPlot::draw_ColoredMapPlain ( DataCode dtc, bool smooth, QPainter &pnt, const Projection *proj) { if (gribReader == NULL) return; DataColors::setColorDataTypeFunction (dtc); switch (dtc.dataType) { case GRB_PRV_WIND_XY2D : windAltitude = dtc.getAltitude (); drawColorMapGeneric_2D (pnt,proj,smooth, DataCode (GRB_WIND_VX, dtc.levelType,dtc.levelValue), DataCode (GRB_WIND_VY, dtc.levelType,dtc.levelValue), DataColors::function_getColor ); break; case GRB_PRV_CUR_XY2D : currentAltitude = dtc.getAltitude (); drawColorMapGeneric_2D (pnt,proj,smooth, DataCode (GRB_CUR_VX, dtc.levelType,dtc.levelValue), DataCode (GRB_CUR_VY, dtc.levelType,dtc.levelValue), DataColors::function_getColor ); break; case GRB_PRV_DIFF_TEMPDEW : drawColorMapGeneric_Abs_Delta_Data (pnt,proj,smooth, DataCode (GRB_TEMP, dtc.levelType,dtc.levelValue), DataCode (GRB_DEWPOINT, dtc.levelType,dtc.levelValue), DataColors::function_getColor ); break; case GRB_TEMP : case GRB_CLOUD_TOT : case GRB_PRECIP_TOT : case GRB_HUMID_REL : case GRB_TEMP_POT : case GRB_DEWPOINT : case GRB_SNOW_DEPTH : case GRB_SNOW_CATEG : case GRB_FRZRAIN_CATEG : case GRB_CAPE : case GRB_WAV_SIG_HT : case GRB_WAV_MAX_HT : case GRB_WAV_WHITCAP_PROB : drawColorMapGeneric_1D (pnt,proj,smooth, dtc, DataColors::function_getColor); break; default : break; } }
//================================================================================== // Waves arrows //================================================================================== void GribPlot::draw_WAVES_Arrows ( const DataCode &dtc, QPainter &pnt, const Projection *proj ) { if (gribReader == NULL) { return; } QColor waveArrowColor (0,0,0); GribRecord *recDir, *recPer; if (dtc.dataType == GRB_WAV_SIG_HT) { recDir = gribReader->getRecord (DataCode(GRB_WAV_PRIM_DIR,LV_GND_SURF,0), currentDate); recPer = gribReader->getRecord (DataCode(GRB_WAV_PRIM_PER,LV_GND_SURF,0), currentDate); } else if (dtc.dataType == GRB_WAV_MAX_HT) { recDir = gribReader->getRecord (DataCode(GRB_WAV_MAX_DIR,LV_GND_SURF,0), currentDate); recPer = gribReader->getRecord (DataCode(GRB_WAV_MAX_PER,LV_GND_SURF,0), currentDate); } else { recDir = recPer = NULL; } if (recDir==NULL || recPer==NULL) return; int i, j; double x, y, vx, vy; int W = proj->getW(); int H = proj->getH(); int space = 30; space = drawWindArrowsOnGrid ? windArrowSpaceOnGrid : windArrowSpace; if (drawWindArrowsOnGrid) { // Flèches uniquement sur les points de la grille int oldi=-1000, oldj=-1000; for (int gi=0; gi<recDir->getNi(); gi++) { x = recDir->getX(gi); y = recDir->getY(0); proj->map2screen(x,y, &i,&j); if (true || abs(i-oldi)>=space) { oldi = i; for (int gj=0; gj<recDir->getNj(); gj++) { x = recDir->getX(gi); y = recDir->getY(gj); proj->map2screen(x,y, &i,&j); //---------------------------------------------------------------------- if (! recDir->isXInMap(x)) x += 360.0; // tour du monde ? if (recDir->isPointInMap(x,y)) { if (true || abs(j-oldj)>=space) { oldj = j; vx = recDir->getInterpolatedValue(x, y, mustInterpolateValues); vy = recPer->getInterpolatedValue(x, y, mustInterpolateValues); if (vx != GRIB_NOTDEF && vy != GRIB_NOTDEF) { drawWaveArrow (pnt, i,j, vx,vy); } } } } } } } else { // Flèches uniformément réparties sur l'écran for (i=0; i<W; i+=space) { for (j=0; j<H; j+=space) { proj->screen2map(i,j, &x,&y); //---------------------------------------------------------------------- if (! recDir->isXInMap(x)) x += 360.0; // tour du monde ? if (recDir->isPointInMap(x,y)) { vx = recDir->getInterpolatedValue(x, y, mustInterpolateValues); vy = recPer->getInterpolatedValue(x, y, mustInterpolateValues); if (vx != GRIB_NOTDEF && vy != GRIB_NOTDEF) { drawWaveArrow (pnt, i,j, vx,vy); } } //---------------------------------------------------------------------- } } } }
//================================================================================== // Flèches de direction du current //================================================================================== void GribPlot::draw_CURRENT_Arrows ( Altitude altitude, QColor arrowsColor, QPainter &pnt, const Projection *proj ) { if (gribReader == NULL) { return; } currentAltitude = altitude; currentArrowColor = arrowsColor; GribRecord *recx = gribReader->getRecord (DataCode(GRB_CUR_VX,altitude),currentDate); GribRecord *recy = gribReader->getRecord (DataCode(GRB_CUR_VY,altitude),currentDate); if (recx == NULL || recy == NULL) return; int i, j; double x, y, vx, vy; int W = proj->getW(); int H = proj->getH(); int space; space = drawCurrentArrowsOnGrid ? currentArrowSpaceOnGrid : currentArrowSpace; if (drawCurrentArrowsOnGrid) { // Flèches uniquement sur les points de la grille int oldi=-1000, oldj=-1000; for (int gi=0; gi<recx->getNi(); gi++) { x = recx->getX(gi); y = recx->getY(0); proj->map2screen(x,y, &i,&j); if (true || abs(i-oldi)>=space) { oldi = i; for (int gj=0; gj<recx->getNj(); gj++) { x = recx->getX(gi); y = recx->getY(gj); proj->map2screen(x,y, &i,&j); //---------------------------------------------------------------------- if (! recx->isXInMap(x)) x += 360.0; // tour du monde ? if (recx->isPointInMap(x,y)) { if (true || abs(j-oldj)>=space) { oldj = j; vx = recx->getInterpolatedValue(x, y, mustInterpolateValues); vy = recy->getInterpolatedValue(x, y, mustInterpolateValues); if (vx != GRIB_NOTDEF && vy != GRIB_NOTDEF) { drawCurrentArrow(pnt, i,j, vx,vy); } } } } } } } else { // Flèches uniformément réparties sur l'écran for (i=0; i<W; i+=space) { for (j=0; j<H; j+=space) { proj->screen2map(i,j, &x,&y); //---------------------------------------------------------------------- if (! recx->isXInMap(x)) x += 360.0; // tour du monde ? if (recx->isPointInMap(x,y)) { vx = recx->getInterpolatedValue(x, y, mustInterpolateValues); vy = recy->getInterpolatedValue(x, y, mustInterpolateValues); if (vx != GRIB_NOTDEF && vy != GRIB_NOTDEF) { drawCurrentArrow(pnt, i,j, vx,vy); } } //---------------------------------------------------------------------- } } } }
//------------------------------------------------- QString DataCodeStr::toString_name (int dataType) { return toString_name (DataCode(dataType,LV_GND_SURF,0)); }