Find intersect area at grid mode second depth 90/283790/1
authorulgal-park <ulgal.park@samsung.com>
Tue, 4 Oct 2022 04:29:09 +0000 (13:29 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Thu, 3 Nov 2022 05:44:38 +0000 (14:44 +0900)
Change-Id: Ib2a78e0d5223c33a9e86ad38e20b0ca7df3265ae

src/mmimgr/iu/VoiceTouchEngine.cpp
src/mmimgr/iu/VoiceTouchEngine.h

index 8b6028d..d150312 100644 (file)
@@ -297,6 +297,27 @@ Eina_Bool VoiceTouchEngine::makeClickableItemResultCallback(void *data)
        return ECORE_CALLBACK_CANCEL;
 }
 
+void VoiceTouchEngine::findIntersectArea(ClickableItem *command)
+{
+       int xMin = command->coordX, yMin = command->coordY, xMax = command->coordX + command->width, yMax = command->coordY + command->height;
+       _D("[VoiceTouchEngine] GRID mode selected area: [%d, %d, %d, %d]", xMin, yMin, xMax, yMax);
+       int areaMax = 0;
+       for (auto &item : __itemList) {
+               int dx = min(xMax, item.coordX + item.width) - max(xMin, item.coordX);
+               int dy = min(yMax, item.coordY + item.height) - max(yMin, item.coordY);
+               if (dx >= 0 && dy >= 0) {
+                       _D("[VoiceTouchEngine] %s intersected(%d): [%d, %d, %d, %d]", item.label.c_str(), item.index, item.coordX, item.coordY, item.coordX + item.width, item.coordY + item.height);
+                       _D("[VoiceTouchEngine] intersected area: %d", dx*dy);
+                       _D("[VoiceTouchEngine] current max intersect area: %d", areaMax);
+                       if (areaMax < dx*dy) {
+                               _D("[VoiceTouchEngine] updated");
+                               areaMax = dx*dy;
+                               *command = item;
+                       }
+               }
+       }
+}
+
 Eina_Bool VoiceTouchEngine::findCommandCallback(void *data)
 {
        VoiceTouchEngine *engine = static_cast<VoiceTouchEngine *>(data);
@@ -325,6 +346,10 @@ Eina_Bool VoiceTouchEngine::findCommandCallback(void *data)
                return ECORE_CALLBACK_CANCEL;
        }
 
+       if (engine->__currentMode == VOICE_TOUCH_MODE_GRID && engine->__currentGridInfo.currentStep == 1) {
+               engine->findIntersectArea(command);
+       }
+
        _I("[VoiceTouchEngine] Command. object ID(%s)", command->objectId.c_str());
        engine->makeTouchModality(*command, timestamp);
        engine->invokeOutputModalityCallback(&engine->__touchModality);
index 298a929..127cffd 100644 (file)
@@ -106,6 +106,8 @@ private:
        void invokeOutputResultCallback(std::string outputResult);
        void invokeOutputModalityCallback(void* outputModality);
 
+       void findIntersectArea(ClickableItem *command);
+
 private:
        static const int __MAXIMUM_GRID_STEP = 2;