bool NatLightAssemblyClassDesc::IsValidSun( ClassDesc& cd) 
{
	bool bValidSun = ((cd.ClassID() == NatLightAssembly::GetStandardSunClass()) != FALSE);
	if (!bValidSun)
	{
		INaturalLightClass* pNC = GetNaturalLightClassInterface(&cd);
		if (pNC != NULL && (pNC->GetDesc()->flags & FP_STATIC_METHODS)) 
		{
			bValidSun = (pNC->IsSun() != FALSE);
		}
	}
	return bValidSun;
}
Beispiel #2
0
bool VDMClassDesc::IsCompatibleWithRenderer(ClassDesc& rendererClassDesc) {

	Class_ID classID = rendererClassDesc.ClassID();

	if((classID == MRRENDERER_CLASSID) /* || (classID == SCANLINERENDERER_CLASS_ID) */ ) {
		return true;
	}
	else {
		// Return 'true' only if the renderer doesn't implement the compatibility interface.
		// This ensures that we are compatible with all renderers unless they specify the contrary.
		IMtlRender_Compatibility_Renderer* rendererCompatibility = Get_IMtlRender_Compatibility_Renderer(rendererClassDesc);
		return (rendererCompatibility == NULL);
	}
}
Beispiel #3
0
void plComponentDlg::IOpenRightClickMenu()
{
    HWND hTree = GetDlgItem(fhDlg, IDC_TREE);

    // Get the position of the cursor in screen and tree client coords
    POINT point, localPoint;
    GetCursorPos(&point);
    localPoint = point;
    ScreenToClient(hTree, &localPoint);

    // Check if there is a tree item at that point
    TVHITTESTINFO hitTest;
    hitTest.pt = localPoint;
    TreeView_HitTest(hTree, &hitTest);
    if (!(hitTest.flags & TVHT_ONITEMLABEL))
        return;

    // Check if the tree item has an lParam (is a component)
    TVITEM item;
    item.mask = TVIF_PARAM;
    item.hItem = hitTest.hItem;
    TreeView_GetItem(hTree, &item);

    HMENU menu = nil;
    if (IIsComponent(item.lParam))
        menu = fCompMenu;
    else if (IIsType(item.lParam))
        menu = fTypeMenu;
    else
        return;

    // Select the item we're working with, so the user isn't confused
    TreeView_SelectItem(hTree, item.hItem);

    // Create the popup menu and get the option the user selects
    SetForegroundWindow(fhDlg);
    int sel = TrackPopupMenu(menu, TPM_NONOTIFY | TPM_RETURNCMD, point.x, point.y, 0, fhDlg, NULL);
    switch(sel)
    {
    case kMenuDelete:
        IDeleteComponent((plMaxNode*)item.lParam);
        break;

    case kMenuRename:
        TreeView_EditLabel(hTree, hitTest.hItem);
        break;

    case kMenuCopy:
        {
            // Component to copy
            INode *node = (INode*)item.lParam;
            INodeTab tab;
            tab.Append(1, &node);

            // Copy
            INodeTab copy;

            // Make the copy
            fInterface->CloneNodes(tab, Point3(0,0,0), true, NODE_COPY, NULL, &copy);

            // Delete the targets for the copy and add it to the tree
            plMaxNode *newNode = (plMaxNode*)copy[0];
            newNode->ConvertToComponent()->DeleteAllTargets();
            HTREEITEM hItem = IAddComponent(GetDlgItem(fhDlg, IDC_TREE), newNode);
            TreeView_SelectItem(GetDlgItem(fhDlg, IDC_TREE), hItem);
        }
        break;

    case kMenuHide:
        {
            ClassDesc *desc = plComponentMgr::Inst().Get(item.lParam-1);

            std::vector<Class_ID>::iterator it;
            it = std::find(fHiddenComps.begin(), fHiddenComps.end(), desc->ClassID());

            TSTR name = desc->ClassName();
            if (it == fHiddenComps.end())
            {
                fHiddenComps.push_back(desc->ClassID());
                name.Append(" (Hidden)");
            }
            else
                fHiddenComps.erase(it);

            item.mask = TVIF_TEXT;
            item.pszText = name;
            TreeView_SetItem(GetDlgItem(fhDlg, IDC_TREE), &item);

            plComponentUtil::Instance().IUpdateRollups();
        }
        break;
    }

    PostMessage(fhDlg, WM_USER, 0, 0);
}
Beispiel #4
0
BOOL plComponentDlg::DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
    case WM_INITDIALOG:
        fhDlg = hDlg;
        IAddComponentsRecur(GetDlgItem(hDlg, IDC_TREE), (plMaxNode*)GetCOREInterface()->GetRootNode());

        ICreateMenu();
        ICreateRightClickMenu();
        return TRUE;

    case WM_SIZING:
        IPositionControls((RECT*)lParam, wParam);
        return TRUE;

    case WM_ACTIVATE:
        if (LOWORD(wParam) == WA_INACTIVE)
            plMaxAccelerators::Enable();
        else
            plMaxAccelerators::Disable();
        return TRUE;

    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDCANCEL)
        {
            ShowWindow(hDlg, SW_HIDE);
            fInterface->UnRegisterDlgWnd(hDlg);
            return TRUE;
        }
        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_ATTACH)
        {
            IAttachTreeSelection();
            return TRUE;
        }
        else if (HIWORD(wParam) == EN_KILLFOCUS && LOWORD(wParam) == IDC_COMMENTS)
        {
            IGetComment();
            return TRUE;
        }
        // "Refresh" menu item
        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == ID_REFRESH)
        {
            IRefreshTree();
            return TRUE;
        }
        // "Remove unused components" menu item
        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == ID_REMOVE_UNUSED)
        {
            IRemoveUnusedComps();
            return TRUE;
        }
        // Item selected from 'New' menu
        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) >= MENU_ID_START)
        {
            ClassDesc *desc = plComponentMgr::Inst().Get(LOWORD(wParam)-MENU_ID_START);
            // If this is a component type (not a category)
            if (desc)
            {
                // Create an object of that type and a node to reference it
                Object *obj = (Object*)GetCOREInterface()->CreateInstance(desc->SuperClassID(), desc->ClassID());
                INode *node = GetCOREInterface()->CreateObjectNode(obj);

                plComponentBase *comp = (plComponentBase*)obj;
                node->Hide(!comp->AllowUnhide());
                node->Freeze(TRUE);

                // Add the new component to the tree
                HWND hTree = GetDlgItem(hDlg, IDC_TREE);
                HTREEITEM item = IAddComponent(hTree, (plMaxNode*)node);
                TreeView_SelectItem(hTree, item);
                TreeView_EnsureVisible(hTree, item);
            }
        }
        break;

    case WM_NOTIFY:
        NMHDR *nmhdr = (NMHDR*)lParam;
        if (nmhdr->idFrom == IDC_TREE)
        {
            switch (nmhdr->code)
            {
            case TVN_SELCHANGED:
                {
                    NMTREEVIEW *tv = (NMTREEVIEW*)lParam;

                    IGetComment();

                    bool isComponent = IIsComponent(tv->itemNew.lParam);

                    // If the new selection is a component, enable the attach button and comment field
                    EnableWindow(GetDlgItem(hDlg, IDC_ATTACH), isComponent);
                    SendDlgItemMessage(hDlg, IDC_COMMENTS, EM_SETREADONLY, !isComponent, 0);

                    if (isComponent)
                    {
                        fCommentNode = (plMaxNode*)tv->itemNew.lParam;
                        
                        TSTR buf;
                        fCommentNode->GetUserPropBuffer(buf);
                        SetDlgItemText(hDlg, IDC_COMMENTS, buf);
                    }
                    else
                    {
                        fCommentNode = nil;
                        SetDlgItemText(hDlg, IDC_COMMENTS, "");
                    }

                    return TRUE;
                }
                break;

            case TVN_BEGINLABELEDIT:
                // If this isn't a component, don't allow the edit
                if (!IIsComponent(((NMTVDISPINFO*)lParam)->item.lParam))
                {
                    SetWindowLong(hDlg, DWL_MSGRESULT, TRUE);
                    return TRUE;
                }

                // The edit box this creates kills the focus on our window, causing
                // accelerators to be enabled.  Add an extra disable to counteract that.
                plMaxAccelerators::Disable();

                return TRUE;

            // Finishing changing the name of a component
            case TVN_ENDLABELEDIT:
                {
                    NMTVDISPINFO *di = (NMTVDISPINFO*)lParam;
                    char* text = di->item.pszText;
                    // If the name was changed...
                    if (text && *text != '\0')
                    {
                        // Update the name of the node
                        plMaxNode *node = IGetTreeSelection();
                        node->SetName(text);

                        // Update the name in the panel too
                        if (plComponentUtil::Instance().IsOpen())
                            plComponentUtil::Instance().IUpdateNodeName(node);

                        // Make sure Max knows the file was changed
                        SetSaveRequiredFlag();

                        // Return true to keep the changes
                        SetWindowLong(hDlg, DWL_MSGRESULT, TRUE);
                    }

                    plMaxAccelerators::Enable();
                }
                return TRUE;

            // User double-clicked.  Select the objects the selected component is attached to.
            case NM_DBLCLK:
                ISelectTreeSelection();
                return TRUE;

            case NM_RCLICK:
                IOpenRightClickMenu();
                return TRUE;
                
            case TVN_KEYDOWN:
                // User pressed delete
                if (((NMTVKEYDOWN*)lParam)->wVKey == VK_DELETE)
                {
                    IDeleteComponent(IGetTreeSelection());
                    return TRUE;
                }
                break;
            }
        }
        break;
    }

    return FALSE;
}
Beispiel #5
0
bool mrTwoSidedShader::mrShaderTwoSidedShader_ClassDesc::IsCompatibleWithRenderer(ClassDesc& rendererClassDesc) {

	// Compatible only with the mental ray renderer
	return ((rendererClassDesc.ClassID() == MRRENDERER_CLASSID) != 0);
}
	// From IMtlRender_Compatibility_MtlBase
	bool IsCompatibleWithRenderer(ClassDesc& rendererClassDesc) 
	{
		// Only compatible with mental ray and harmony
		return ((rendererClassDesc.ClassID() == MRRENDERER_CLASSID) != 0);
	}