2f18d5d3e72bf80ce96d5558423cacfd5ad9bf6f5e5283e16ca01cb15d7ff82330ad79ac1fafd86475b47a744627113df7152c740be23a2d9ff3b6dd138033 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import * as graphic from '../../util/graphic.js';
  2. import { BrushPanelConfig, BrushControllerEvents, BrushType, BrushAreaRange, BrushDimensionMinMax } from './BrushController.js';
  3. import ExtensionAPI from '../../core/ExtensionAPI.js';
  4. import GridModel from '../../coord/cartesian/GridModel.js';
  5. import GeoModel from '../../coord/geo/GeoModel.js';
  6. import { CoordinateSystemMaster } from '../../coord/CoordinateSystem.js';
  7. import Cartesian2D from '../../coord/cartesian/Cartesian2D.js';
  8. import Geo from '../../coord/geo/Geo.js';
  9. import GlobalModel from '../../model/Global.js';
  10. import { BrushAreaParam, BrushAreaParamInternal } from '../brush/BrushModel.js';
  11. import SeriesModel from '../../model/Series.js';
  12. import { ModelFinderObject } from '../../util/model.js';
  13. declare type COORD_CONVERTS_INDEX = 0 | 1;
  14. declare type BrushableCoordinateSystem = Cartesian2D | Geo;
  15. declare type BrushTargetBuilderKey = 'grid' | 'geo';
  16. /**
  17. * There can be multiple axes in a single targetInfo. Consider the case
  18. * of `grid` component, a targetInfo represents a grid which contains one or more
  19. * cartesian and one or more axes. And consider the case of parallel system,
  20. * which has multiple axes in a coordinate system.
  21. */
  22. interface BrushTargetInfo {
  23. panelId: string;
  24. coordSysModel: CoordinateSystemMaster['model'];
  25. coordSys: BrushableCoordinateSystem;
  26. coordSyses: BrushableCoordinateSystem[];
  27. getPanelRect: GetPanelRect;
  28. }
  29. export interface BrushTargetInfoCartesian2D extends BrushTargetInfo {
  30. gridModel: GridModel;
  31. coordSys: Cartesian2D;
  32. coordSyses: Cartesian2D[];
  33. xAxisDeclared: boolean;
  34. yAxisDeclared: boolean;
  35. }
  36. export interface BrushTargetInfoGeo extends BrushTargetInfo {
  37. geoModel: GeoModel;
  38. coordSysModel: GeoModel;
  39. coordSys: Geo;
  40. coordSyses: Geo[];
  41. }
  42. declare type GetPanelRect = () => graphic.BoundingRect;
  43. declare class BrushTargetManager {
  44. private _targetInfoList;
  45. /**
  46. * @param finder contains Index/Id/Name of xAxis/yAxis/geo/grid
  47. * Each can be {number|Array.<number>}. like: {xAxisIndex: [3, 4]}
  48. * @param opt.include include coordinate system types.
  49. */
  50. constructor(finder: ModelFinderObject, ecModel: GlobalModel, opt?: {
  51. include?: BrushTargetBuilderKey[];
  52. });
  53. setOutputRanges(areas: BrushControllerEvents['brush']['areas'], ecModel: GlobalModel): BrushAreaParam[];
  54. matchOutputRanges<T extends (Parameters<BrushTargetManager['findTargetInfo']>[0] & {
  55. brushType: BrushType;
  56. range: BrushAreaRange;
  57. })>(areas: T[], ecModel: GlobalModel, cb: (area: T, coordRange: ReturnType<ConvertCoord>['values'], coordSys: BrushableCoordinateSystem, ecModel: GlobalModel) => void): void;
  58. /**
  59. * the `areas` is `BrushModel.areas`.
  60. * Called in layout stage.
  61. * convert `area.coordRange` to global range and set panelId to `area.range`.
  62. */
  63. setInputRanges(areas: BrushAreaParamInternal[], ecModel: GlobalModel): void;
  64. makePanelOpts(api: ExtensionAPI, getDefaultBrushType?: (targetInfo: BrushTargetInfo) => BrushType): BrushPanelConfig[];
  65. controlSeries(area: BrushAreaParamInternal, seriesModel: SeriesModel, ecModel: GlobalModel): boolean;
  66. /**
  67. * If return Object, a coord found.
  68. * If reutrn true, global found.
  69. * Otherwise nothing found.
  70. */
  71. findTargetInfo(area: ModelFinderObject & {
  72. panelId?: string;
  73. }, ecModel: GlobalModel): BrushTargetInfo | true;
  74. }
  75. declare type ConvertCoord = (to: COORD_CONVERTS_INDEX, coordSys: BrushableCoordinateSystem, rangeOrCoordRange: BrushAreaRange, clamp?: boolean) => {
  76. values: BrushAreaRange;
  77. xyMinMax: BrushDimensionMinMax[];
  78. };
  79. export default BrushTargetManager;