#include "cmproduct.h"
#include "logic_local_def.h"

char* flatPos_str[] =
{
    "Top",
    "Right",
    "Bottom",
    "Left",
    0,
};
char* cut_type[] =
{
    "Line_Cycle",
    "Side_Cycle",
    0,
};
CMProduct::CMProduct(const QString& name, int32_t id)
    :CProduct(name, id)
{
    m_Variants.add_Variant(Var_MProduct_FlatPos_ID,
                           QObject::trUtf8("FlatPos"), uint(0), false,
                           Variant::TOBOTH, QStringList()
                           << QObject::trUtf8("Top") <<
                           QObject::trUtf8("Right") <<
                           QObject::trUtf8("Bottom") <<
                           QObject::trUtf8("Left"));


    m_Variants.add_Variant(Var_MProduct_FlatLength_ID,
                           QObject::trUtf8("FlatLength"), double(0), false,
                           Variant::TOBOTH);

    m_Variants.add_Variant(Var_MProduct_CutType_ID,
                           QObject::trUtf8("CutType"), uint(0), false,
                           Variant::TOBOTH, QStringList()
                           << QObject::trUtf8("Line_Cycle") <<
                           QObject::trUtf8("Side_Cycle"));

    m_Variants.add_Variant(Var_MProduct_FirstCutb_ID,
                           QObject::trUtf8("FirstCutb"), false, false,
                           Variant::TOBOTH);

    m_Variants.add_Variant(Var_MProduct_FilmThick_ID,
                           QObject::trUtf8("FilmThick"), double(0), false,
                           Variant::TOBOTH);

    m_Variants.add_Variant(Var_MProduct_EnableAlignment_ID,
                           QObject::trUtf8("EnableAlignment"), false, false,
                           Variant::TOXML);

    m_Variants.add_Variant(Var_MProduct_SizeType_ID,
                           QObject::trUtf8("SizeType"), uint(0), false,
                           Variant::TOBOTH, QStringList()
                           << QObject::tr("6inch") <<
                           QObject::tr("8Inch") <<
                           QObject::tr("12Inch"));

    m_Variants.add_Variant(Var_MProduct_ID,
                           QObject::trUtf8("ProductID"), QString(""), false,
                           Variant::TOFILE, QStringList());

    m_Variants.add_Variant(Var_MProduct_MeasureDiameter,
                           QObject::trUtf8("MeasureDiameter"), double(200), false,
                           Variant::TOFILE);

    m_dRealDiameter = 0;
    m_dThickDiff = 0;
}

CMProduct::~CMProduct()
{

}
#if 0
void CMProduct::Serialize(QDataStream &stream, bool bwrite, int iVersion)
{
    //m_Variants.get_VData( Var_MProduct_MeasureDiameter)->setValue(m_Variants.get_VData( Var_Product_Diameter_ID)->toDouble());

    QMap<int, Variant>::Iterator iter = m_Variants.m_mVariantMap.begin();
    for (; iter != m_Variants.m_mVariantMap.end(); iter++) {
        int valueType = (*iter).m_iSerialStyle;
        if (valueType == Variant::TOFILE || valueType == Variant::TOBOTH) {
            if (bwrite) {
                stream << (*iter).m_vVar;
            } else {
#ifdef __DEFINE_NEW_PARAM__
                if ((*iter).m_iID == Var_MProduct_ID)
                    continue;
                if ((*iter).m_iID == Var_MProduct_MeasureDiameter)
                    continue;
#endif // __DEFINE_NEW_PARAM__
                QVariant var;
                stream >> var;
                (*iter).m_vVar = var;
            }
        }
    }
}
#endif

double CMProduct::CutDepthToDefoucsDis(double dCutDepth)
{
    double dThick = m_Variants.get_VData(Var_Product_Thick_ID)->toDouble();
    double dFileThick = m_Variants.get_VData(Var_MProduct_FilmThick_ID)->toDouble();
    //m_dThickDiff 片厚补偿
    return dThick + dFileThick - dCutDepth + m_dThickDiff;
}

double CMProduct::WaferSurfaceToDefoucsDis()
{
    return CutDepthToDefoucsDis(0);
}

