#include <mil.h>
#include <math.h>
#include "ExampleManager.h"
#include "../InspectionTaskBase/InspectionTask.h"
static const MIL_INT MAX_DISPLAY_SIZE_Y = 1080;
static const MIL_INT SAMPLES_BORDER_Y = 10;
static const MIL_INT VIEW_BORDER_X = 40;
static const MIL_INT NB_ARROW_POINT = 7;
static const MIL_DOUBLE ARROW_X[NB_ARROW_POINT] = { 5, 25, 25, 35, 25, 25, 5 };
static const MIL_DOUBLE ARROW_Y[NB_ARROW_POINT] = { -5, -5, -10, 0, 10, 5, 5 };
static const MIL_INT MAX_SAMPLES_PER_GROUP = 1;
static const MIL_DOUBLE DEFAULT_TITLE_POINT_SIZE = 20;
static const MIL_DOUBLE DEFAULT_TEXT_POINT_SIZE = 14;
static MIL_CONST_TEXT_PTR TITLE_FONT = M_FONT_DEFAULT_TTF;
static MIL_CONST_TEXT_PTR TEXT_FONT = M_FONT_DEFAULT_TTF;
MIL_INT MFTYPE MouseMoveFunc(MIL_INT HookType, MIL_ID EventID, void* UserDataPtr)
{
CExampleMngr *pExampleMngr = (CExampleMngr*) UserDataPtr;
MIL_DOUBLE PosX, PosY;
MdispGetHookInfo(EventID, M_MOUSE_POSITION_BUFFER_X, &PosX);
MdispGetHookInfo(EventID, M_MOUSE_POSITION_BUFFER_Y, &PosY);
pExampleMngr->SetHoverImageAt(PosX, PosY);
return 0;
}
MIL_INT MFTYPE MouseLeftClickFunc(MIL_INT HookType, MIL_ID EventID, void* UserDataPtr)
{
CExampleMngr *pExampleMngr = (CExampleMngr*) UserDataPtr;
MIL_DOUBLE PosX, PosY;
MdispGetHookInfo(EventID, M_MOUSE_POSITION_BUFFER_X, &PosX);
MdispGetHookInfo(EventID, M_MOUSE_POSITION_BUFFER_Y, &PosY);
pExampleMngr->SetSelectedImageAt(PosX, PosY);
return 0;
}
CExampleMngr::CExampleMngr(MIL_ID MilSystem)
: m_MilSystem (MilSystem),
m_MilDisplay (M_NULL),
m_MilGraList (M_NULL),
m_MilGraGraphicContext (M_NULL),
m_MilGraTextContext (M_NULL),
m_MilGraSingleContext (M_NULL),
m_MilGraSingleTextContext (M_NULL),
m_MilGraTitleContext (M_NULL),
m_MilViewChildArray (NULL),
m_MilDisplayImage (M_NULL),
m_MilSingleDisplay (M_NULL),
m_MilSingleDisplayChild (M_NULL),
m_NbSamplesToInspect (0),
m_CurProductInfo (NULL),
m_HoverLabel (0),
m_SelectedLabel (0),
m_CurrentGroupIdx (0)
{
MdispAlloc(MilSystem, M_DEFAULT, MIL_TEXT("M_DEFAULT"), M_DEFAULT, &m_MilDisplay);
MdispControl(m_MilDisplay, M_SCALE_DISPLAY, M_ENABLE);
MdispAlloc(MilSystem, M_DEFAULT, MIL_TEXT("M_DEFAULT"), M_DEFAULT, &m_MilSingleDisplay);
MgraAllocList(MilSystem, M_DEFAULT, &m_MilGraList);
MgraAllocList(MilSystem, M_DEFAULT, &m_MilSingleGraList);
MdispControl(m_MilDisplay, M_ASSOCIATED_GRAPHIC_LIST_ID, m_MilGraList);
MdispControl(m_MilSingleDisplay, M_ASSOCIATED_GRAPHIC_LIST_ID, m_MilSingleGraList);
MgraAlloc(MilSystem, &m_MilGraGraphicContext);
MgraAlloc(MilSystem, &m_MilGraSingleContext);
MgraAlloc(MilSystem, &m_MilGraTextContext);
MgraAlloc(MilSystem, &m_MilGraSingleTextContext);
MgraAlloc(MilSystem, &m_MilGraTitleContext);
MgraFont(m_MilGraTextContext, MIL_FONT_NAME(TEXT_FONT));
MgraFont(m_MilGraSingleTextContext, MIL_FONT_NAME(TEXT_FONT));
MgraControl(m_MilGraSingleTextContext, M_FONT_SIZE, DEFAULT_TEXT_POINT_SIZE);
MgraColor(m_MilGraTitleContext, M_COLOR_DARK_GREEN);
MgraFont(m_MilGraTitleContext, MIL_FONT_NAME(TEXT_FONT));
MgraControl(m_MilGraTitleContext, M_TEXT_ALIGN_HORIZONTAL, M_CENTER);
MgraControl(m_MilGraTitleContext, M_DRAW_OFFSET_Y, -SAMPLES_BORDER_Y);
}
CExampleMngr::~CExampleMngr()
{
ResetTasks();
ResetImages();
MgraFree(m_MilGraGraphicContext);
MgraFree(m_MilGraSingleContext);
MgraFree(m_MilGraTextContext);
MgraFree(m_MilGraSingleTextContext);
MgraFree(m_MilGraTitleContext);
MgraFree(m_MilGraList);
MgraFree(m_MilSingleGraList);
MdispFree(m_MilDisplay);
MdispFree(m_MilSingleDisplay);
}
void CExampleMngr::Run(SProductInfo* ProductsInfoList, MIL_INT NbProduct)
{
for(MIL_INT ProductIdx = 0; ProductIdx < NbProduct; ProductIdx++)
{
ResetInspection(ProductsInfoList[ProductIdx]);
for(MIL_INT GroupIdx = 0, SampleIdx =0; GroupIdx < GetNbGroups(); GroupIdx++)
{
LoadGroupImages(GroupIdx);
for(MIL_INT DispSampleIdx = 0; DispSampleIdx < GetNbSamples(GroupIdx); DispSampleIdx++, SampleIdx++)
{
MdispControl(m_MilDisplay, M_UPDATE, M_DISABLE);
MosPrintf(MIL_TEXT("Inspecting sample %i.\n\n"), (int) SampleIdx);
InspectProducts(DispSampleIdx);
DrawResults(DispSampleIdx);
MosPrintf(MIL_TEXT("The results of sample %i are displayed.\n\n"), (int) SampleIdx);
MdispControl(m_MilDisplay, M_UPDATE, M_ENABLE);
}
EnableDisplayHooks();
MosPrintf(MIL_TEXT("Press <Enter> to continue.\n\n"));
MosGetch();
DisableDisplayHooks();
}
}
}
void CExampleMngr::ResetImages()
{
if(m_MilDisplayImage)
{
for(MIL_INT SampleIdx = 0; SampleIdx < m_NbSamplesPerGroup; SampleIdx++)
{
for(MIL_INT ViewIdx = 0; ViewIdx < m_CurProductInfo->NbViews; ViewIdx++)
{
MbufFree(m_MilViewChildArray[SampleIdx][ViewIdx].MilChild);
MgraFree(m_MilViewChildArray[SampleIdx][ViewIdx].MilGraList);
MgraFree(m_MilViewChildArray[SampleIdx][ViewIdx].MilGraTextList);
}
delete [] m_MilViewChildArray[SampleIdx];
}
delete [] m_MilViewChildArray;
MbufFree(m_MilDisplayImage);
m_MilDisplayImage = M_NULL;
MbufFree(m_MilSingleDisplayChild);
MbufFree(m_MilSingleDisplayImage);
}
}
void CExampleMngr::ResetTasks()
{
if(m_CurProductInfo)
{
for(MIL_INT ViewIdx = 0; ViewIdx < m_CurProductInfo->NbViews; ViewIdx++)
{
SImageTaskList &rViewTaskList = m_CurProductInfo->ImageTasksListArray[ViewIdx];
for(MIL_INT TaskIdx = rViewTaskList.NbTasks-1; TaskIdx >=0 ; TaskIdx--)
{ rViewTaskList.TaskList[TaskIdx]->Free(); }
}
}
}
void CExampleMngr::InitializeTasks()
{
for(MIL_INT ViewIdx = 0; ViewIdx < m_CurProductInfo->NbViews; ViewIdx++)
{
SImageTaskList &rViewTaskList = m_CurProductInfo->ImageTasksListArray[ViewIdx];
for(MIL_INT TaskIdx = 0; TaskIdx < rViewTaskList.NbTasks; TaskIdx++)
{ rViewTaskList.TaskList[TaskIdx]->Init(m_MilSystem, m_MilViewChildArray[0][ViewIdx].SizeX, m_MilViewChildArray[0][ViewIdx].SizeY); }
}
}
void CExampleMngr::InitializeDisplayImages()
{
m_NbSamplesToInspect = MbufDiskInquire(m_CurProductInfo->ViewAviFilePathArray[0], M_NUMBER_OF_IMAGES, M_NULL);
m_DisplaySizeX = VIEW_BORDER_X;
m_DisplayGridSizeY = 0;
m_DisplayGridTextSizeY = 0;
m_DisplayGridImageSizeY = 0;
for(MIL_INT ViewIdx = 0; ViewIdx < m_CurProductInfo->NbViews; ViewIdx++)
{
MIL_INT TextSizeY = m_CurProductInfo->ImageTasksListArray[ViewIdx].NbTasks * RESULT_TEXT_LINE_SPACING_Y;
MIL_INT CurSizeX = MbufDiskInquire(m_CurProductInfo->ViewAviFilePathArray[ViewIdx], M_SIZE_X, M_NULL);
MIL_INT CurSizeY = MbufDiskInquire(m_CurProductInfo->ViewAviFilePathArray[ViewIdx], M_SIZE_Y, M_NULL);
m_DisplayGridTextSizeY = (TextSizeY > m_DisplayGridTextSizeY) ? TextSizeY : m_DisplayGridTextSizeY ;
m_DisplayGridImageSizeY = (CurSizeY > m_DisplayGridImageSizeY) ? CurSizeY : m_DisplayGridImageSizeY;
m_DisplaySizeX += CurSizeX + VIEW_BORDER_X;
}
m_DisplayGridSizeY = m_DisplayGridTextSizeY + m_DisplayGridImageSizeY + 2 * SAMPLES_BORDER_Y;
m_NbSamplesPerGroup = (MIL_INT)((MIL_DOUBLE)(MAX_DISPLAY_SIZE_Y-SAMPLES_BORDER_Y) / (m_DisplayGridSizeY));
m_NbSamplesPerGroup = m_NbSamplesPerGroup > m_NbSamplesToInspect ? m_NbSamplesToInspect : m_NbSamplesPerGroup;
m_NbSamplesPerGroup = m_NbSamplesPerGroup > MAX_SAMPLES_PER_GROUP ? MAX_SAMPLES_PER_GROUP : m_NbSamplesPerGroup;
if(m_NbSamplesPerGroup == 0)
{ m_NbSamplesPerGroup = 1; }
m_MilViewChildArray = new SViewChildInfo*[m_NbSamplesPerGroup];
m_DisplaySizeY = (m_DisplayGridSizeY * m_NbSamplesPerGroup) + 2 * SAMPLES_BORDER_Y + TITLE_LINE_SPACING_Y;
MbufAllocColor(m_MilSystem, 3, m_DisplaySizeX, m_DisplaySizeY, 8+M_UNSIGNED, M_IMAGE + M_PROC + M_DISP, &m_MilDisplayImage);
MbufClear(m_MilDisplayImage, M_COLOR_BLACK);
MbufAllocColor(m_MilSystem, 3, m_DisplaySizeX, m_DisplaySizeY, 8+M_UNSIGNED, M_IMAGE + M_PROC + M_DISP, &m_MilSingleDisplayImage);
MbufClear(m_MilSingleDisplayImage, M_COLOR_BLACK);
MbufChild2d(m_MilSingleDisplayImage, 0, 0, 1, 1, &m_MilSingleDisplayChild);
for(MIL_INT SampleIdx = 0, CurrentOffsetY = 2 * SAMPLES_BORDER_Y + TITLE_LINE_SPACING_Y; SampleIdx < m_NbSamplesPerGroup; SampleIdx++, CurrentOffsetY += m_DisplayGridSizeY)
{
m_MilViewChildArray[SampleIdx] = new SViewChildInfo[m_CurProductInfo->NbViews];
for(MIL_INT ViewIdx = 0, CurrentOffsetX = VIEW_BORDER_X; ViewIdx < m_CurProductInfo->NbViews; ViewIdx++)
{
MIL_INT CurSizeX = MbufDiskInquire(m_CurProductInfo->ViewAviFilePathArray[ViewIdx], M_SIZE_X, M_NULL);
MIL_INT CurSizeY = MbufDiskInquire(m_CurProductInfo->ViewAviFilePathArray[ViewIdx], M_SIZE_Y, M_NULL);
SViewChildInfo &rChildInfo = m_MilViewChildArray[SampleIdx][ViewIdx];
rChildInfo.SizeX = CurSizeX;
rChildInfo.SizeY = CurSizeY;
rChildInfo.OffsetX = CurrentOffsetX;
rChildInfo.OffsetY = CurrentOffsetY;
rChildInfo.RealOffsetY = CurrentOffsetY + (m_DisplayGridImageSizeY - CurSizeY)/2;
CurrentOffsetX += CurSizeX + VIEW_BORDER_X;
MbufChild2d(m_MilDisplayImage, rChildInfo.OffsetX, rChildInfo.RealOffsetY, rChildInfo.SizeX, rChildInfo.SizeY, &rChildInfo.MilChild);
MgraAllocList(m_MilSystem, M_DEFAULT, &rChildInfo.MilGraList);
MgraAllocList(m_MilSystem, M_DEFAULT, &rChildInfo.MilGraTextList);
}
}
}
void CExampleMngr::SetImageRect()
{
for(MIL_INT SampleIdx = 0; SampleIdx < GetNbSamples(m_CurrentGroupIdx); SampleIdx++)
{
for(MIL_INT ViewIdx = 0; ViewIdx < m_CurProductInfo->NbViews; ViewIdx++)
{
SViewChildInfo &rChildInfo = m_MilViewChildArray[SampleIdx][ViewIdx];
MgraColor(M_DEFAULT, M_COLOR_WHITE);
MgraControl(M_DEFAULT, M_DRAW_OFFSET_X, 0.0);
MgraControl(M_DEFAULT, M_DRAW_OFFSET_Y, 0.0);
MgraRect(M_DEFAULT, m_MilGraList, rChildInfo.OffsetX, rChildInfo.RealOffsetY, rChildInfo.OffsetX + rChildInfo.SizeX, rChildInfo.RealOffsetY + rChildInfo.SizeY);
MgraInquireList(m_MilGraList, M_LIST, M_DEFAULT, M_LAST_LABEL + M_TYPE_MIL_INT, &rChildInfo.GraRectLabel);
}
}
}
void CExampleMngr::LoadGroupImages(MIL_INT GroupIdx)
{
MdispControl(m_MilDisplay, M_UPDATE, M_DISABLE);
MbufClear(m_MilDisplayImage, 0);
MbufClear(m_MilSingleDisplayImage, 0);
MgraClear(M_DEFAULT, m_MilGraList);
DrawViewsTitles();
m_HoverLabel = -1;
m_SelectedLabel = -1;
for(MIL_INT ViewIdx = 0; ViewIdx < m_CurProductInfo->NbViews; ViewIdx++)
{
for(MIL_INT DispSampleIdx = 0; DispSampleIdx < m_NbSamplesPerGroup ; DispSampleIdx++)
{
MgraClear(M_DEFAULT, m_MilViewChildArray[DispSampleIdx][ViewIdx].MilGraList);
MgraClear(M_DEFAULT, m_MilViewChildArray[DispSampleIdx][ViewIdx].MilGraTextList);
}
}
m_CurrentGroupIdx = GroupIdx;
SetImageRect();
for(MIL_INT ViewIdx = 0; ViewIdx < m_CurProductInfo->NbViews; ViewIdx++)
{
MbufImportSequence(m_CurProductInfo->ViewAviFilePathArray[ViewIdx], M_DEFAULT, M_NULL, M_NULL, M_NULL, M_NULL, M_NULL, M_OPEN);
for(MIL_INT DispSampleIdx = 0, SampleIdx = m_NbSamplesPerGroup * GroupIdx; DispSampleIdx < m_NbSamplesPerGroup && SampleIdx < m_NbSamplesToInspect; DispSampleIdx++, SampleIdx++)
{
MbufImportSequence(m_CurProductInfo->ViewAviFilePathArray[ViewIdx], M_DEFAULT, M_LOAD, M_NULL, &m_MilViewChildArray[DispSampleIdx][ViewIdx].MilChild, SampleIdx, 1, M_READ);
}
MbufImportSequence(m_CurProductInfo->ViewAviFilePathArray[ViewIdx], M_DEFAULT, M_NULL, M_NULL, M_NULL, M_NULL, M_NULL, M_CLOSE);
}
MdispControl(m_MilDisplay, M_UPDATE, M_DISABLE);
}
void CExampleMngr::ResetInspection(SProductInfo &ProductInfo)
{
MosPrintf(MIL_TEXT("Setting up the inspection of the product...\n\n"));
ResetTasks();
ResetImages();
m_CurProductInfo = &ProductInfo;
InitializeDisplayImages();
MdispSelect(m_MilDisplay, m_MilDisplayImage);
CalculateDisplayScaleFactor();
InitializeTasks();
}
void CExampleMngr::EnableDisplayHooks()
{
MdispHookFunction(m_MilDisplay, M_MOUSE_MOVE, MouseMoveFunc, (void*)this);
MdispHookFunction(m_MilDisplay, M_MOUSE_LEFT_BUTTON_UP, MouseLeftClickFunc, (void*)this);
}
void CExampleMngr::DisableDisplayHooks()
{
MdispHookFunction(m_MilDisplay, M_MOUSE_MOVE + M_UNHOOK, MouseMoveFunc, (void*)this);
MdispHookFunction(m_MilDisplay, M_MOUSE_LEFT_BUTTON_UP + M_UNHOOK, MouseLeftClickFunc, (void*)this);
if(MdispInquire(m_MilSingleDisplay, M_SELECTED, M_NULL))
{ MdispSelect(m_MilSingleDisplay, M_NULL); }
}
void CExampleMngr::InspectProducts(MIL_INT SampleIdx)
{
for(MIL_INT ViewIdx = 0; ViewIdx < m_CurProductInfo->NbViews; ViewIdx++)
{
SImageTaskList &rTaskList = m_CurProductInfo->ImageTasksListArray[ViewIdx];
for(MIL_INT TaskIdx = 0; TaskIdx < rTaskList.NbTasks; TaskIdx++)
rTaskList.TaskList[TaskIdx]->InspectImage(m_MilViewChildArray[SampleIdx][ViewIdx].MilChild);
}
}
void CExampleMngr::DrawResults(MIL_INT SampleIdx)
{
for(MIL_INT ViewIdx = 0; ViewIdx < m_CurProductInfo->NbViews; ViewIdx++)
{
SImageTaskList &rTaskList = m_CurProductInfo->ImageTasksListArray[ViewIdx];
SViewChildInfo &rChildInfo = m_MilViewChildArray[SampleIdx][ViewIdx];
MgraControl(m_MilGraTextContext, M_FONT_SIZE, DEFAULT_TEXT_POINT_SIZE * m_DisplayScaleFactor);
MgraControl(m_MilGraTextContext, M_DRAW_OFFSET_X, (MIL_DOUBLE)-(rChildInfo.OffsetX + 5));
MgraControl(m_MilGraTextContext, M_DRAW_OFFSET_Y, (MIL_DOUBLE)-(rChildInfo.RealOffsetY + rChildInfo.SizeY + SAMPLES_BORDER_Y));
MgraControl(m_MilGraSingleTextContext, M_DRAW_OFFSET_X, -5.0);
MgraControl(m_MilGraSingleTextContext, M_DRAW_OFFSET_Y, (MIL_DOUBLE)-(rChildInfo.SizeY + SAMPLES_BORDER_Y));
MgraControl(m_MilGraGraphicContext, M_DRAW_OFFSET_X, (MIL_DOUBLE)(-rChildInfo.OffsetX));
MgraControl(m_MilGraGraphicContext, M_DRAW_OFFSET_Y, (MIL_DOUBLE)(-rChildInfo.RealOffsetY));
MgraControl(m_MilGraSingleContext, M_DRAW_OFFSET_X, 0.0);
MgraControl(m_MilGraSingleContext, M_DRAW_OFFSET_Y, 0.0);
for(MIL_INT TaskIdx = 0; TaskIdx < rTaskList.NbTasks; TaskIdx++)
{
rTaskList.TaskList[TaskIdx]->DrawInspectionGraphicalResult(m_MilGraGraphicContext, m_MilGraList);
rTaskList.TaskList[TaskIdx]->DrawInspectionGraphicalResult(m_MilGraSingleContext, rChildInfo.MilGraList);
rTaskList.TaskList[TaskIdx]->DrawTextResult(m_MilGraTextContext, m_MilGraList);
rTaskList.TaskList[TaskIdx]->DrawTextResult(m_MilGraSingleTextContext, rChildInfo.MilGraTextList);
}
if(m_CurProductInfo->ViewsType == enSequential && ViewIdx < m_CurProductInfo->NbViews-1)
{
MgraControl(M_DEFAULT, M_DRAW_OFFSET_X, (MIL_DOUBLE)-(rChildInfo.OffsetX + rChildInfo.SizeX));
MgraControl(M_DEFAULT, M_DRAW_OFFSET_Y, (MIL_DOUBLE)-(rChildInfo.RealOffsetY + rChildInfo.SizeY / 2));
DrawArrow();
}
}
}
void CExampleMngr::DrawArrow()
{
MgraColor(M_DEFAULT, M_COLOR_DARK_GREEN);
MgraLines(M_DEFAULT, m_MilGraList, NB_ARROW_POINT, ARROW_X, ARROW_Y, M_NULL, M_NULL, M_POLYGON + M_FILLED);
}
void CExampleMngr::DrawViewsTitles()
{
MgraControl(m_MilGraTitleContext, M_FONT_SIZE, (MIL_DOUBLE)DEFAULT_TITLE_POINT_SIZE * m_DisplayScaleFactor);
for(MIL_INT ViewIdx = 0; ViewIdx < m_CurProductInfo->NbViews; ViewIdx++)
{
SViewChildInfo &rChildInfo = m_MilViewChildArray[0][ViewIdx];
MgraText(m_MilGraTitleContext, m_MilGraList, rChildInfo.OffsetX + rChildInfo.SizeX/2, 0, m_CurProductInfo->ImageTasksListArray[ViewIdx].TaskTitle);
}
}
void CExampleMngr::CalculateDisplayScaleFactor()
{
MIL_INT DisplayAreaSizeX = MdispInquire(m_MilDisplay, M_SIZE_X, M_NULL);
MIL_INT DisplayAreaSizeY = MdispInquire(m_MilDisplay, M_SIZE_Y, M_NULL);
if(DisplayAreaSizeX == m_DisplaySizeX)
m_DisplayScaleFactor = (MIL_DOUBLE)DisplayAreaSizeY / m_DisplaySizeY;
else
m_DisplayScaleFactor = (MIL_DOUBLE)DisplayAreaSizeX / m_DisplaySizeX;
}
MIL_INT CExampleMngr::GetNbGroups() const
{
return (MIL_INT)ceil((MIL_DOUBLE)m_NbSamplesToInspect / m_NbSamplesPerGroup);
}
MIL_INT CExampleMngr::GetNbSamples(MIL_INT GroupIdx) const
{
MIL_INT NbSamplesLeft = m_NbSamplesToInspect - GroupIdx * m_NbSamplesPerGroup;
return NbSamplesLeft < m_NbSamplesPerGroup ? NbSamplesLeft : m_NbSamplesPerGroup;
}
void CExampleMngr::SetHoverImageAt(MIL_DOUBLE PosX, MIL_DOUBLE PosY)
{
const SViewChildInfo *pViewChild = GetViewOfPos(PosX, PosY);
if(pViewChild)
{
ResetSpecialLabel(&m_HoverLabel, pViewChild->GraRectLabel, M_COLOR_YELLOW);
}
else
ResetSpecialLabel(&m_HoverLabel, -1, M_COLOR_YELLOW);
}
void CExampleMngr::SetSelectedImageAt(MIL_DOUBLE PosX, MIL_DOUBLE PosY)
{
MIL_INT ViewIdx;
const SViewChildInfo *pViewChild = GetViewOfPos(PosX, PosY, &ViewIdx);
if(pViewChild)
{
UpdateSingleDisplay(pViewChild, ViewIdx);
ResetSpecialLabel(&m_SelectedLabel, pViewChild->GraRectLabel, M_COLOR_WHITE);
if(m_SelectedLabel == m_HoverLabel)
m_HoverLabel = -1;
}
}
void CExampleMngr::ResetSpecialLabel(MIL_INT* pCurrentLabel, MIL_INT NewLabel, MIL_INT Color)
{
if(*pCurrentLabel != NewLabel)
{
if(*pCurrentLabel != -1)
MgraControlList(m_MilGraList, M_GRAPHIC_LABEL(*pCurrentLabel), M_DEFAULT, M_COLOR, M_COLOR_WHITE);
if(NewLabel != -1)
MgraControlList(m_MilGraList, M_GRAPHIC_LABEL(NewLabel), M_DEFAULT, M_COLOR, Color);
*pCurrentLabel = NewLabel;
}
}
const SViewChildInfo* CExampleMngr::GetViewOfPos(MIL_DOUBLE PosX, MIL_DOUBLE PosY, MIL_INT *pViewIdx )
{
for(MIL_INT SampleIdx = 0; SampleIdx < GetNbSamples(m_CurrentGroupIdx); SampleIdx ++)
{
for(MIL_INT ViewIdx = 0; ViewIdx < m_CurProductInfo->NbViews; ViewIdx++)
{
SViewChildInfo &rChildInfo = m_MilViewChildArray[SampleIdx][ViewIdx];
if(PosX >= rChildInfo.OffsetX &&
PosX <= (rChildInfo.OffsetX + rChildInfo.SizeX - 1) &&
PosY >= rChildInfo.RealOffsetY &&
PosY <= (rChildInfo.RealOffsetY + rChildInfo.SizeY - 1))
{
if(pViewIdx)
{ *pViewIdx = ViewIdx; }
return &rChildInfo;
}
}
}
return NULL;
}
void CExampleMngr::UpdateSingleDisplay(const SViewChildInfo *pViewChild, MIL_INT ViewIdx)
{
MdispControl(m_MilSingleDisplay, M_UPDATE, M_DISABLE);
if(MdispInquire(m_MilSingleDisplay, M_SELECTED, M_NULL))
MdispSelect(m_MilSingleDisplay, M_NULL);
MbufChildMove(m_MilSingleDisplayChild, pViewChild->OffsetX, pViewChild->RealOffsetY, pViewChild->SizeX, pViewChild->SizeY + m_DisplayGridTextSizeY + SAMPLES_BORDER_Y, M_DEFAULT);
MbufCopy(pViewChild->MilChild, m_MilSingleDisplayChild);
MdispControl(m_MilSingleDisplay, M_ASSOCIATED_GRAPHIC_LIST_ID, pViewChild->MilGraList);
MgraDraw(pViewChild->MilGraTextList, m_MilSingleDisplayChild, M_DEFAULT);
MdispSelect(m_MilSingleDisplay, m_MilSingleDisplayChild);
MdispControl(m_MilSingleDisplay, M_UPDATE, M_ENABLE);
}