import 'package:fis_measure/interfaces/process/modes/mode.dart';
import 'package:fis_measure/interfaces/enums/visual_area_type.dart';
import 'package:fis_common/event/event_type.dart';
import 'package:fis_measure/interfaces/process/viewports/viewport.dart';
import 'package:fis_measure/interfaces/process/visuals/visual.dart';
import 'package:fis_measure/interfaces/process/visuals/visual_area.dart';
import 'package:vid/us/vid_us_visual_area_type.dart';

abstract class VisualArea<T extends IViewPort> implements IVisualArea {
  bool _isActive = false;
  late final IVisual _visual;
  late final VidUsVisualAreaType _areaType;
  late final IMode _mode;
  IViewPort? _viewPort;

  VisualArea(IVisual visual, IMode mode) {
    _visual = visual;
    _mode = mode;
  }

  @override
  bool get isActive => _isActive;
  @override
  set isActive(bool value) {
    if (value != _isActive) {
      _isActive = value;
      isActiveChanged.emit(this, value);
    }
  }

  @override
  IMode get mode => _mode;

  @override
  IVisual get visual => _visual;

  @override
  IViewPort? get viewport => _viewPort;
  @override
  set viewport(IViewPort? value) {
    if (value != _viewPort) {
      _viewPort = value;
    }
  }

  @override
  VidUsVisualAreaType get visualAreaType => _areaType;

  @override
  var isActiveChanged = FEventHandler<bool>();
}
