//-*-c++-*-
#ifndef _LookForTapiaMarkers_h_
#define _LookForTapiaMarkers_h_

#include "Behaviors/Demos/Tapia/TapiaMarkerData.h"
#include "DualCoding/DualCoding.h"
#include "Sound/SoundManager.h"

using namespace DualCoding;

class LookForTapiaMarkers : public VisualRoutinesBehavior {
public:
  LookForTapiaMarkers() : VisualRoutinesBehavior("LookForTapiaMarkers") {}

  virtual void DoStart() {
    MapBuilderRequest req(MapBuilderRequest::worldMap);
    req.maxDist = 100000;
    req.addObjectColor(markerDataType, "orange");
    req.addObjectColor(markerDataType, "pink");
    req.addObjectColor(markerDataType, "blue");
    req.markerTypes.insert(TapiaMarkerData::tapiaMarkerType);
    
    unsigned int mapreq_id = mapBuilder.executeRequest(req);
    erouter->addListener(this, EventBase::mapbuilderEGID, mapreq_id, EventBase::statusETID);
  }
  
  virtual void processEvent(const EventBase &event) {
    
    NEW_SHAPEVEC(tmarkers, TapiaMarkerData, select_type<TapiaMarkerData>(localShS));
    if ( tmarkers.size() > 0 ) {
      Shape<TapiaMarkerData> &firstmarker = tmarkers[0];
      string const topcol = ProjectInterface::getColorName(firstmarker->topColor);
      string const botcol = ProjectInterface::getColorName(firstmarker->bottomColor);
      cout << "Top marker color is " << ProjectInterface::getColorName(firstmarker->topColor) << endl;
      cout << "Bottom marker color is " << ProjectInterface::getColorName(firstmarker->bottomColor) << endl;
      sndman->speak("Saw a "+topcol+" and "+botcol+" marker");
    }
    cout << "Found " << camShS.allShapes().size() << " cam shapes." << endl;
    SHAPEROOTVEC_ITERATE(camShS, s)
      cout << "   " << s << endl;
    END_ITERATE;
    
    cout << "Created " << tmarkers.size() << " Tapia markers in local space." << endl;
    SHAPEVEC_ITERATE(tmarkers, TapiaMarkerData, s)
      cout << "   " << s << endl;
    END_ITERATE;
  }

};

#endif
