Commits

Ville Suoranta authored 1179e579666 Merge
Merge pull request #1130 in CASA/casa from CAS-12660 to master

* commit 'c9387f81b90041295e4b7c27417f7b695824f0af': Make plotms RA x-axis descending in all cases Set axis sort direction after range Restore axis scale base for RA/Dec plotms plots Set axis label format for angle (ra/dec)
No tags

code/plotms/Plots/PlotMSPlot.cc

Modified
2137 2137 PlotAxis xPlotAxis,
2138 2138 PlotCanvasPtr canvas,
2139 2139 std::vector<PMS_PP_Axes*>& axesParams,
2140 2140 std::vector<PMS_PP_Cache*>& cacheParams,
2141 2141 std::vector<PMS_PP_Display*>& displayParams,
2142 2142 std::vector<PlotMSPlot*>& plots,
2143 2143 int iteration) {
2144 2144 // Set by user, or manually set by plotms depending on axis
2145 2145 // else autoscale
2146 2146
2147 - // Must set scale before range; NORMAL or TIME scale
2148 - canvas->setAxisScale(xPlotAxis, PMS::axisScale(xAxis));
2149 -
2147 + // Must set scale before range; NORMAL, TIME, or ANGLE scale
2148 + canvas->setAxisScale(xPlotAxis, PMS::axisScale(xAxis), PMS::axisScaleBase(xAxis));
2149 + SortDirection sortDir(SortDirection::ASCENDING);
2150 2150
2151 2151 // x range min/max for all plots
2152 2152 double xming(DBL_MAX), xmaxg(-DBL_MAX); // global xmin/xmax
2153 2153 for (size_t plotindex=0; plotindex<axesParams.size(); ++plotindex) {
2154 2154 for (unsigned int xindex=0; xindex < axesParams[plotindex]->numXAxes(); ++xindex) {
2155 - // Set axis scale direction for Ra/Dec
2155 + // Set axis scale, direction for Ra/Dec
2156 + auto xFrame = cacheParams[plotindex]->xFrame();
2157 + canvas->setAxisScaleAngleFormat(xPlotAxis, PMS::angleFormat(xAxis, xFrame));
2156 2158 if (xAxis == PMS::RA) {
2157 - if (cacheParams[plotindex]->yAxis(xindex) == PMS::DEC) {
2158 - auto xFrame = cacheParams[plotindex]->xFrame();
2159 - SortDirection sortDir;
2160 - switch(xFrame){
2161 - case PMS::CoordSystem::AZELGEO:
2162 - sortDir = SortDirection::ASCENDING;
2163 - break;
2164 - default:
2165 - sortDir = SortDirection::DESCENDING;
2166 - }
2167 - canvas->setAxisScaleSortDirection(xPlotAxis, sortDir);
2159 + switch(xFrame){
2160 + case PMS::CoordSystem::AZELGEO:
2161 + sortDir = SortDirection::ASCENDING;
2162 + break;
2163 + default:
2164 + sortDir = SortDirection::DESCENDING;
2168 2165 }
2169 2166 }
2170 2167
2171 2168 // get min/max from each plot to manually scale
2172 2169 double xmin(DBL_MAX), xmax(-DBL_MAX);
2173 2170 if (axesParams[plotindex]->xRangeSet(xindex)) { // use user setting
2174 2171 xmin = axesParams[plotindex]->xRange(xindex).first;
2175 2172 xmax = axesParams[plotindex]->xRange(xindex).second;
2176 2173 } else if ((xAxis == PMS::TIME) || (xAxis == PMS::RA) || (PMS::axisIsUV(xAxis))) {
2177 2174 // set range manually: get min/max from cache indexer
2209 2206 canvas->setAxisRange(xPlotAxis, xbounds);
2210 2207 } else if (PMS::axisIsUV(xAxis)) {
2211 2208 getAxisBoundsForUV(xming, xmaxg);
2212 2209 pair<double, double> xbounds = make_pair(xming, xmaxg);
2213 2210 canvas->setAxisRange(xPlotAxis, xbounds);
2214 2211 } else {
2215 2212 pair<double, double> xbounds = make_pair(xming, xmaxg);
2216 2213 canvas->setAxisRange(xPlotAxis, xbounds);
2217 2214 }
2218 2215 }
2216 +
2217 + // descending axis direction for RA
2218 + canvas->setAxisScaleSortDirection(xPlotAxis, sortDir);
2219 2219 }
2220 2220
2221 2221 void PlotMSPlot::setXAxisLabel(PlotCanvasPtr canvas,
2222 2222 PMS::Axis xAxis, PMS::DataColumn xColumn, PlotAxis xPlotAxis,
2223 2223 std::vector<PMS_PP_Cache*> cacheParams,
2224 2224 std::vector<PMS_PP_Canvas*> canvasParams,
2225 2225 std::vector<PMS_PP_MSData*> dataParams,
2226 2226 std::vector<PlotMSPlot*>& plots,
2227 2227 int defaultFontSize, int commonCacheType, bool commonPolnRatio) {
2228 2228 // Set x-axis label for single x-axis in single location
2377 2377 void PlotMSPlot::setYAxesRanges(PlotCanvasPtr canvas,
2378 2378 std::vector<PMS_PP_Axes*>& axesParams,
2379 2379 std::vector<PMS_PP_Cache*>& cacheParams,
2380 2380 std::vector<PMS_PP_Display*>& displayParams,
2381 2381 std::vector<PlotMSPlot*>& plots,
2382 2382 int iteration) {
2383 2383 // Set by user, or manually set by plotms depending on axis
2384 2384 // else autoscale
2385 2385
2386 2386 // set axis scales based on axes
2387 - PlotAxisScale axisScaleLeft(DATE_MJ_SEC),
2388 - axisScaleRight(DATE_MJ_SEC);
2387 + PlotAxisScale axisScaleLeft(NORMAL), axisScaleRight(NORMAL);
2388 + AngleFormat angleFormatLeft(AngleFormat::DECIMAL), angleFormatRight(AngleFormat::DECIMAL);
2389 + unsigned int scaleBaseLeft(10), scaleBaseRight(10);
2390 + bool scaleLeftSet(false), scaleRightSet(false);
2389 2391
2390 2392 // determine which axes need range set
2391 2393 double ymingLeft(DBL_MAX), ymaxgLeft(-DBL_MAX); // global ymin/ymax for left axis
2392 2394 double ymingRight(DBL_MAX), ymaxgRight(-DBL_MAX); // global ymin/ymax for right axis
2393 2395 bool hasOverlay(false), hasAtmCurve(false);
2396 +
2394 2397 for (size_t plotindex=0; plotindex < axesParams.size(); ++plotindex) {
2395 2398 for (size_t yindex=0; yindex < cacheParams[plotindex]->numYAxes(); ++yindex) {
2396 2399 PMS::Axis yaxis = cacheParams[plotindex]->yAxis(yindex);
2397 2400 PlotAxis yPlotAxis = axesParams[plotindex]->yAxis(yindex);
2398 2401 PlotAxisScale yAxisScale = PMS::axisScale(yaxis);
2402 + AngleFormat yAngleFormat = PMS::angleFormat(yaxis, cacheParams[plotindex]->yFrame(yindex));
2403 + unsigned int yScaleBase = PMS::axisScaleBase(yaxis);
2399 2404
2400 2405 // scale
2401 2406 if (yPlotAxis == Y_LEFT) {
2402 - if (yAxisScale == NORMAL) {
2403 - axisScaleLeft = NORMAL; // NORMAL unless all TIME scales
2407 + if (!scaleLeftSet) { // use first settings
2408 + axisScaleLeft = yAxisScale;
2409 + angleFormatLeft = yAngleFormat;
2410 + scaleBaseLeft = yScaleBase;
2411 + scaleLeftSet = true;
2412 + } else {
2413 + if (yAxisScale != axisScaleLeft) {
2414 + axisScaleLeft = NORMAL; // use NORMAL if scales differ
2415 + }
2416 + if (yAngleFormat != angleFormatLeft) {
2417 + angleFormatLeft = DECIMAL; // use DECIMAL if scales differ
2418 + }
2419 + if (yScaleBase != scaleBaseLeft) {
2420 + scaleBaseLeft = 10; // use default if scales differ
2421 + }
2404 2422 }
2405 2423 } else {
2406 - if (yAxisScale == NORMAL) {
2407 - axisScaleRight = NORMAL; // NORMAL unless all TIME scales
2424 + if (!scaleRightSet) { // use first setting
2425 + axisScaleRight = yAxisScale;
2426 + angleFormatRight = yAngleFormat;
2427 + scaleBaseRight = yScaleBase;
2428 + scaleRightSet = true;
2429 + } else {
2430 + if (yAxisScale != axisScaleRight) {
2431 + axisScaleRight = NORMAL; // use NORMAL if scales differ
2432 + }
2433 + if (yAngleFormat != angleFormatRight) {
2434 + angleFormatRight = DECIMAL; // use DECIMAL if scales differ
2435 + }
2436 + if (yScaleBase != scaleBaseRight) {
2437 + scaleBaseRight = 10; // use default if scales differ
2438 + }
2408 2439 }
2409 2440 }
2410 2441
2411 2442 // min/max for range
2412 2443 double ymin(DBL_MAX), ymax(-DBL_MAX); // for each plot
2413 2444 if (axesParams[plotindex]->yRangeSet(yindex)) {
2414 2445 ymin = axesParams[plotindex]->yRange(yindex).first;
2415 2446 ymax = axesParams[plotindex]->yRange(yindex).second;
2416 2447 } else if ((yaxis == PMS::TIME) || (yaxis == PMS::RA) ||
2417 2448 (PMS::axisIsUV(yaxis)) || PMS::axisIsOverlay(yaxis)) {
2449 2480 ymingLeft = min(ymingLeft, ymin);
2450 2481 ymaxgLeft = max(ymaxgLeft, ymax);
2451 2482 } else {
2452 2483 ymingRight = min(ymingRight, ymin);
2453 2484 ymaxgRight = max(ymaxgRight, ymax);
2454 2485 }
2455 2486 }
2456 2487 }
2457 2488 }
2458 2489
2459 - // Must set scale before range; NORMAL or TIME scale
2460 - canvas->setAxisScale(Y_LEFT, axisScaleLeft);
2461 - canvas->setAxisScale(Y_RIGHT, axisScaleRight);
2490 + // Must set scale before range; NORMAL, TIME, or ANGLE scale
2491 + canvas->setAxisScale(Y_LEFT, axisScaleLeft, scaleBaseLeft);
2492 + canvas->setAxisScale(Y_RIGHT, axisScaleRight, scaleBaseRight);
2493 + canvas->setAxisScaleAngleFormat(Y_LEFT, angleFormatLeft);
2494 + canvas->setAxisScaleAngleFormat(Y_RIGHT, angleFormatRight);
2462 2495
2463 2496 // no range set means autoscale or no points displayed for this axis
2464 2497 if ((ymingLeft != DBL_MAX) && (ymaxgLeft != -DBL_MAX)) {
2465 2498 pair<double, double> ybounds = make_pair(ymingLeft, ymaxgLeft);
2466 2499 canvas->setAxisRange(Y_LEFT, ybounds);
2467 2500 }
2468 2501 if ((ymingRight != DBL_MAX) && (ymaxgRight != -DBL_MAX)) {
2469 2502 if (hasOverlay) {
2470 2503 getAxisBoundsForOverlay(ymingRight, ymaxgRight);
2471 2504 if (hasAtmCurve) { // limit max percent to 100

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut