// CustomCursorTool.cpp
#include "CustomCursorTool.h"
#include <qgsmapcanvas.h>
#include <qgsproject.h>
#include <qgsvectorlayer.h>
#include <qgsrasterlayer.h>
#include <qgsfeatureiterator.h>
#include <qgsgeometry.h>
#include <qgsrasteridentifyresult.h>
#include <QApplication>
#include <qgsmaplayer.h>
#include "qgsmapmouseevent.h"
#include "qgsmaptoolidentify.h"
#include <qgsmapcanvas.h>
#include <qgsvectorlayer.h>
#include <qgsrasterlayer.h>

CustomCursorTool::CustomCursorTool(QgsMapCanvas* canvas)
    : QgsMapToolIdentify(canvas)
{
     canvas->setCursor(Qt::CrossCursor);
}

void CustomCursorTool::canvasMoveEvent(QgsMapMouseEvent* e)
{

    if (!canvas()) return;
    QgsPointXY pointxy= e->pos();
    QList<QgsMapToolIdentify::IdentifyResult> result;
    QList<QgsMapLayer*> allLayers = mCanvas->layers();
    if (allLayers.count() == 0) {
        return;
    }
    QList < QgsMapToolIdentify::IdentifyResult > rasterlayerresult=this->identify(e->x(), e->y(), IdentifyMode::ActiveLayer, allLayers,QgsMapToolIdentify::Type::RasterLayer);
    QList < QgsMapToolIdentify::IdentifyResult > meshlayerresult=this->identify(e->x(), e->y(), IdentifyMode::ActiveLayer, allLayers,  QgsMapToolIdentify::Type::MeshLayer);
    for (int32_t i = 0; i < rasterlayerresult.count(); i++) {
        result.append(rasterlayerresult[i]);
    }
    for (int32_t i = 0; i < meshlayerresult.count(); i++) {
        result.append(meshlayerresult[i]);
    }
    if (result.count() > 0){
        emit identifyResultChange(result);
    }
    else {

    }
  }

 