/* LICENSE:
  =========================================================================
    CMPack'04 Source Code Release for OPEN-R SDK
    Copyright (C) 2004 Multirobot Lab [Project Head: Manuela Veloso]
    School of Computer Science, Carnegie Mellon University
    All rights reserved.
  ========================================================================= */

#ifndef INCLUDED_ChokeChainCP_h
#define INCLUDED_ChokeChainCP_h

#include "ChokeChainCP_fl.h"
#include "RLEViewer.h"
#include "GlobalView.h"

class ChokeChainCP : private ChokeChainCP_fl {

 protected:

  void openLogMenuitemCB();
  void openConnectionMenuitemCB();
  void quitMenuitemCB();
  void globalViewMenuitemCB();
  void visionRLEViewMenuitemCB();
  void egoViewMenuitemCB();
  void logSliderCB();
  void autoRunButtonCB();
  void visionActiveButtonCB();
  void visionBallButtonCB();
  void visionMarkersButtonCB();
  void worldModelActiveButtonCB();
  void worldModelOldBallButtonCB();
  void worldModelTeammateBallButtonCB();
  void worldModelRobotsButtonCB();
  void worldModelTeammatesButtonCB();
  void worldModelTeammateRobotsButtonCB();
  void worldTrackerActiveButtonCB();
  void worldTrackerSelfBallButtonCB();
  void worldTrackerSelfBallEllipsesButtonCB();
  void worldTrackerTeammateBallButtonCB();
  void worldTrackerTeammateBallEllipsesButtonCB();
  void worldTrackerSelfBallHypothesesButtonCB();
  void worldTrackerTeammateBallHypothesesButtonCB();
  void wmDebugActiveButtonCB();

  /// The window which will show the RLE images
  RLEViewer *RLE_win;

  /// The window which will show the global view
  GlobalView *global_view_win;

  /// A file descriptor to listen to in order to do updates
  int gui_read_fd;

  /// Width of the RLE data buffer
  int rle_width;

  /// height of the RLE data buffer
  int rle_height;

 public:

  /// Constructor
  ChokeChainCP(int _gui_read_fd,
	       int _rle_width,
	       int _rle_height,
	       int log_position=-1);
	       
  /// Destructor
  virtual ~ChokeChainCP();

  /// Show all the interfaces
  void show();
  /// Hide all the interfaces
  void hide();

  /// Show the RLE window
  void showRLE();
  /// Hide the RLE window
  void hideRLE();

  /// Show the Global window
  void showGlobal();
  /// Hide the Global window
  void hideGlobal();

  /// Update the (active) interfaces
  void update();

  /// Run the control panel
  void run();

  /// Step a logfile
  void stepLog();

  /// The pipe callback function
  static void fdCB(int fd, void *a);
  
  /// Auto run callback function
  static void autorun(void *a);

  // Flags for drawing stuff
  bool visionActive();
  bool visionBall();
  bool visionMarkers();
  bool worldModelActive();
  bool worldModelOldBall();
  bool worldModelTeammateBall();
  bool worldModelRobots();
  bool worldModelTeammates();
  bool worldModelTeammateRobots();
  bool worldTrackerActive();
  bool worldTrackerSelfBall();
  bool worldTrackerSelfBallEllipses();
  bool worldTrackerTeammateBall();
  bool worldTrackerTeammateBallEllipses();
  bool worldTrackerSelfBallHypotheses();
  bool worldTrackerTeammateBallHypotheses();
  bool wmDebugActive();
};

#endif
