Esempio n. 1
0
HRESULT CKeyProp::OnInitDialog()
{
    HRESULT hr;

    // KeyType Property
    DWORD dwKey = DXTKEY_RGB;
    hr = GetNumericVal(TEXT("KeyType"), &dwKey);
    if (SUCCEEDED(hr))
    {
        m_iKey = dwKey;
    }

    // Hue Property
    SetWindowTextFromProp(GetDlgItem(m_hDlg, IDC_KEY_HUE), TEXT("Hue"));

    // Luminance Property
    SetWindowTextFromProp(GetDlgItem(m_hDlg, IDC_KEY_LUMA), TEXT("Luminance"));

    // Similarity Property
    SetWindowTextFromProp(GetDlgItem(m_hDlg, IDC_KEY_SIMILAR), TEXT("Similarity"));

    // RGB Property
    DWORD dwColor = 0;
    hr = GetNumericVal(TEXT("RGB"), &dwColor, 16);
    if (SUCCEEDED(hr))
    {
        m_dwColor = SwapRGB(dwColor); 
    }

    // Invert Property
    DWORD dwInvert = 0;
    hr = GetNumericVal(TEXT("Invert"), &dwInvert);
    if (SUCCEEDED(hr))
    {
        CheckDlgButton(m_hDlg, IDC_KEY_INVERT, (dwInvert ? BST_CHECKED : BST_UNCHECKED));
    }

    // Populate the list of key types in order of the key-type enums

    HWND hList = GetDlgItem(m_hDlg, IDC_KEY_TYPE);

    const int iNumKeys = 5;
    TCHAR* szKeyNames[] = {
        TEXT("Chroma"), TEXT("Non-Red"), TEXT("Luminance"), TEXT("Alpha"), TEXT("Hue")
    };

    for (int i = 0; i < iNumKeys; i++)
    {
        SendMessage(hList, CB_ADDSTRING, 0, (LPARAM)szKeyNames[i]);
    }

    // Select the current key type
    SendMessage(hList, CB_SETCURSEL, m_iKey, 0);

    UpdateControls();

    return S_OK;
}
Esempio n. 2
0
HRESULT CWipeProp::OnInitDialog()
{
    // Get the current SMPTE wipe number.
    DWORD dwWipeNum = 0;
    HRESULT hr = GetNumericVal(TEXT("MaskNum"), &dwWipeNum);

    // Populate the list of SMPTE wipe names
    int iSel = 0;

    for (int i = 0; i < g_iNumWipes; i++)
    {
        SendDlgItemMessage(m_hDlg, IDC_SMPTE_MASKNUM, CB_ADDSTRING, 
            0, (LPARAM)g_SMPTEWipes[i].szName);

        // This one matches the current MaskNum property ... 
        // remember this value for when we set the list box selection.
        if (g_SMPTEWipes[i].num == (int) dwWipeNum)
        {
            iSel = i;
        }

    }

    // Set the list box selection.
    SendDlgItemMessage(m_hDlg, IDC_SMPTE_MASKNUM, CB_SETCURSEL, iSel, 0);

    // Set the remaining properties...
    SetWindowTextFromProp(GetDlgItem(m_hDlg, IDC_SMPTE_SOFTNESS), TEXT("BorderSoftness"));
    SetWindowTextFromProp(GetDlgItem(m_hDlg, IDC_SMPTE_WIDTH), TEXT("BorderWidth"));

    SetWindowTextFromProp(GetDlgItem(m_hDlg, IDC_SMPTE_OFFSETX), TEXT("OffsetX"));
    SetWindowTextFromProp(GetDlgItem(m_hDlg, IDC_SMPTE_OFFSETY), TEXT("OffsetY"));
    SetWindowTextFromProp(GetDlgItem(m_hDlg, IDC_SMPTE_REPLICATEX), TEXT("ReplicateX"));
    SetWindowTextFromProp(GetDlgItem(m_hDlg, IDC_SMPTE_REPLICATEY), TEXT("ReplicateY"));

    // The next two are floating-point values. A better UI would take % values
    // from 0 - 100 and convert to 0.0 - 1.0.

    SetWindowTextFromProp(GetDlgItem(m_hDlg, IDC_SMPTE_SCALEX), TEXT("ScaleX"));
    SetWindowTextFromProp(GetDlgItem(m_hDlg, IDC_SMPTE_SCALEY), TEXT("ScaleY"));

    // For the color, we convert the string "0xRRGGBB" to a DWORD, convert
    // to B-G-R format, and use that to paint the color swatch.

    DWORD dwColor = 0;
    hr = GetNumericVal(TEXT("BorderColor"), &dwColor, 16);
    if (SUCCEEDED(hr))
    {
        m_dwBorderColor = SwapRGB(dwColor); 
    }

    return S_OK;
}
Esempio n. 3
0
HRESULT CPipProp::OnInitDialog()
{
    // Set bounding boxes for the sizer control
    RECT rcSrcBound = { 10, 10, 110, 110 };  // WAG
    RECT rcDestBound = { 120, 10, 220, 110 };

    RECT rcSrc, rcDest, rcVid;

    // Get the video rectangle
    GetClientRect(GetDlgItem(m_hwnd, IDC_VIDWIN), &rcVid);

    // Set default Src and Dest rectangles
    CopyRect(&rcSrc, &rcVid);
    InflateRect(&rcSrc, - 10, - 10);
    CopyRect(&rcDest, &rcSrc);

    DWORD dwVal = 0;
    if (SUCCEEDED(GetNumericVal(TEXT("SrcOffsetY"), &dwVal)))
    {
        rcSrc.top = rcSrc.bottom = dwVal;
    }
    if (SUCCEEDED(GetNumericVal(TEXT("SrcOffsetX"), &dwVal)))
    {
        rcSrc.left = rcSrc.right = dwVal;
    }
    if (SUCCEEDED(GetNumericVal(TEXT("SrcHeight"), &dwVal)))
    {
        rcSrc.bottom += dwVal;
    }
    if (SUCCEEDED(GetNumericVal(TEXT("SrcWidth"), &dwVal)))
    {
        rcSrc.right += dwVal;
    }

    if (SUCCEEDED(GetNumericVal(TEXT("OffsetY"), &dwVal)))
    {
        rcDest.top = rcDest.bottom = dwVal;
    }
    if (SUCCEEDED(GetNumericVal(TEXT("OffsetX"), &dwVal)))
    {
        rcDest.left = rcDest.right = dwVal;
    }
    if (SUCCEEDED(GetNumericVal(TEXT("Height"), &dwVal)))
    {
        rcDest.bottom += dwVal;
    }
    if (SUCCEEDED(GetNumericVal(TEXT("Width"), &dwVal)))
    {
        rcDest.right += dwVal;
    }
    
    m_Src.Init(rcSrcBound, rcVid, rcSrc);
    m_Dest.Init(rcDestBound, rcVid, rcDest);

    return S_OK;
}
// ****************************************************************************
//  Method: avtCylindricalRadiusExpression::ProcessArguments
//
//  Purpose:
//      Parses optional arguments. 
//      Allows the user to pass a string constaint specifying the cylinder
//      axis (default = z ) or a vector that defines the cylinder axis.
// 
//
//  Programmer:   Cyrus Harrison 
//  Creation:     March 31, 2008
//
//  Modifications:
//
// ****************************************************************************
void
avtCylindricalRadiusExpression::ProcessArguments(
    ArgsExpr *args, ExprPipelineState *state)
{
    axisVector[0] = 0;
    axisVector[1] = 0;
    axisVector[2] = 1;
    
    // Check the number of arguments
    std::vector<ArgExpr*> *arguments = args->GetArgs();
    size_t nargs = arguments->size();
    if (nargs == 0)
    {
        EXCEPTION2(ExpressionException, outputVariableName, 
                  "avtCylindricalRadiusExpression: No arguments given.");
    }

    // First arg should be a mesh name, let it gen is filters. 
    ArgExpr *first_arg = (*arguments)[0];
    avtExprNode *first_tree = dynamic_cast<avtExprNode*>(first_arg->GetExpr());
    first_tree->CreateFilters(state);

    // If we only have two arguments, we expect a string const or vector const 
    if (nargs == 2)
    {
        ArgExpr *second_arg = (*arguments)[1];
        ExprParseTreeNode *second_tree = second_arg->GetExpr();
        std::string arg_type = second_tree->GetTypeName();
        
        std::string error_msg = "avtCylindricalRadiusExpression: "
                           "Invalid second argument."
                           "Expected \"x\", \"y\", or \"z\"";

        if (arg_type != "StringConst" && arg_type != "Vector" )
        {
            debug5 << error_msg << endl;
            EXCEPTION2(ExpressionException, outputVariableName, 
                       error_msg.c_str());
        }
        
        if (arg_type == "StringConst")
        {
            // string case
            std::string val = dynamic_cast<StringConstExpr*>(second_tree)->GetValue();

            if ( ! ( val == "x" || val == "y"  || val == "z"))
            {
                error_msg += "\nPassed value \"" + val + "\"";
                debug5 << error_msg << endl;
                EXCEPTION2(ExpressionException, outputVariableName, 
                           error_msg.c_str());
            }
        
            debug5 << "avtCylindricalCoordinatesExpression:" 
                   << "Using " << val << " as Cylinder Axis." << endl;
            if(val == "x")
            {
                axisVector[0] = 1;
                axisVector[1] = 0;
                axisVector[2] = 0;
            }
            else if(val == "y")
            {
                axisVector[0] = 0;
                axisVector[1] = 1;
                axisVector[2] = 0;
            }
            else if(val == "z")
            {
                axisVector[0] = 0;
                axisVector[1] = 0;
                axisVector[2] = 1;
            }
        }
        else if(arg_type == "Vector")
        {
            VectorExpr *vec = dynamic_cast<VectorExpr*>(second_tree);
            
            if(!vec->Z())
            {
                error_msg += "\nVector missing z-component.";
                debug5 << error_msg << endl;
                EXCEPTION2(ExpressionException, outputVariableName, 
                           error_msg.c_str());
            }
            
            // get the vector 
            double val = 0;
            
            if(GetNumericVal(vec->X(),val))
            {
                axisVector[0] = val;
            }
            else
            {                
                error_msg += "\nVector x-component is not a floating point number.";
                debug5 << error_msg << endl;
                EXCEPTION2(ExpressionException, outputVariableName, 
                           error_msg.c_str());
            }
            
            if(GetNumericVal(vec->Y(),val))
            {
                axisVector[1] = val;
            }
            else
            {                
                error_msg += "\nVector z-component is not a floating point number.";
                debug5 << error_msg << endl;
                EXCEPTION2(ExpressionException, outputVariableName, 
                           error_msg.c_str());
            }
            
            if(GetNumericVal(vec->Z(),val))
            {
                axisVector[2] = val;
            }
            else
            {                
                error_msg += "\nVector z-component is not a floating point number.";
                debug5 << error_msg << endl;
                EXCEPTION2(ExpressionException, outputVariableName, 
                           error_msg.c_str());
            }

            if ( axisVector[0] == 0 && axisVector[1] == 0 && axisVector[2] == 0 )
            {
                error_msg += "\nDegenerate vector {0,0,0}.";
                debug5 << error_msg << endl;
                EXCEPTION2(ExpressionException, outputVariableName, 
                           error_msg.c_str());
            }
        }
        
    }
}