#include <mil.h>
#include "ThreadInspection.h"
static const MIL_INT NB_FEATURE_TO_DRAW = 6;
static MIL_CONST_TEXT_PTR FEATURES_TO_DRAW[NB_FEATURE_TO_DRAW] =
{
MIL_TEXT("BottomTopSegment"),
MIL_TEXT("ThreadInsideSegment"),
MIL_TEXT("ThreadDiagonalSegment"),
MIL_TEXT("BottomSideSegment"),
MIL_TEXT("ThreadTipEdgels"),
MIL_TEXT("ThreadTipPoint"),
};
static const MIL_INT NB_TOLERANCE_TO_DRAW = 4;
static MIL_CONST_TEXT_PTR TOLERANCES_TO_DRAW[NB_TOLERANCE_TO_DRAW] =
{
MIL_TEXT("BottomWidth"),
MIL_TEXT("ThreadTipWidth"),
MIL_TEXT("BottomToThreadSpacing"),
MIL_TEXT("ThreadAngularity"),
};
CThreadInspection::CThreadInspection(MIL_CONST_TEXT_PTR MetContextPath, MIL_INT ColorConversion , CInspectionTask* FixtureProvider , CInspectionTask* ImageProvider )
: CMetInspectionTask(MetContextPath, ColorConversion, FixtureProvider, ImageProvider)
{
}
CThreadInspection::~CThreadInspection()
{
}
void CThreadInspection::DrawGraphicalResult(MIL_ID MilGraContext, MIL_ID MilDest)
{
for(MIL_INT FeatureIdx = 0; FeatureIdx < NB_FEATURE_TO_DRAW; FeatureIdx++)
CMetInspectionTask::DrawFeatureByName(MilGraContext, FEATURES_TO_DRAW[FeatureIdx], MilDest, M_RGB888(64, 0, 128));
for(MIL_INT ToleranceIdx = 0; ToleranceIdx < NB_TOLERANCE_TO_DRAW; ToleranceIdx++)
CMetInspectionTask::DrawToleranceByName(MilGraContext, TOLERANCES_TO_DRAW[ToleranceIdx], MilDest, M_COLOR_DARK_GREEN, M_COLOR_DARK_RED, M_COLOR_DARK_YELLOW);
}
void CThreadInspection::DrawTextResult(MIL_ID MilGraContext, MIL_ID MilDest)
{
if(GetResultStatus() == eUnknown)
{
MgraColor(MilGraContext, M_COLOR_YELLOW);
MgraText(MilGraContext, MilDest, 0, 0, MIL_TEXT("Thread metrology: UNKNOWN"));
}
else
{
if(IsResultValid())
{
switch(GetOverallStatus())
{
case M_PASS:
MgraColor(MilGraContext, M_COLOR_GREEN);
MgraText(MilGraContext, MilDest, 0, 0, MIL_TEXT("Thread metrology: PASS"));
break;
case M_WARNING:
MgraColor(MilGraContext, M_COLOR_YELLOW);
MgraText(MilGraContext, MilDest, 0, 0, MIL_TEXT("Thread metrology: WARNING"));
break;
default:
case M_FAIL:
MgraColor(MilGraContext, M_COLOR_RED);
MgraText(MilGraContext, MilDest, 0, 0, MIL_TEXT("Thread metrology: FAIL"));
break;
}
}
else
{
MgraColor(MilGraContext, M_COLOR_RED);
MgraText(MilGraContext, MilDest, 0, 0, MIL_TEXT("Thread metrology: FAIL"));
}
}
MoveGraphicContextYOffset(MilGraContext, 1);
}