MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/MaterialX / updateContents

Method updateContents

source/MaterialXView/Editor.cpp:638–751  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

636}
637
638void PropertyEditor::updateContents(Viewer* viewer)
639{
640 create(*viewer);
641
642 mx::MaterialPtr material = viewer->getSelectedMaterial();
643 mx::TypedElementPtr elem = material ? material->getElement() : nullptr;
644 if (!material || !elem)
645 {
646 return;
647 }
648
649#ifndef MATERIALXVIEW_METAL_BACKEND
650 // Bind and validate the shader
651 material->bindShader();
652#endif
653
654 // Shading model display
655 mx::NodePtr node = elem->asA<mx::Node>();
656 if (node)
657 {
658 std::string shaderName = node->getCategory();
659 std::vector<mx::NodePtr> shaderNodes = mx::getShaderNodes(node);
660 if (!shaderNodes.empty())
661 {
662 shaderName = shaderNodes[0]->getCategory();
663 }
664 if (!shaderName.empty() && shaderName != "surface")
665 {
666 ng::ref<ng::Widget> twoColumns = new ng::Widget(_container);
667 twoColumns->set_layout(_gridLayout2);
668 ng::ref<ng::Label> modelLabel = new ng::Label(twoColumns, "Shading Model");
669 modelLabel->set_font_size(20);
670 modelLabel->set_font("sans-bold");
671 ng::ref<ng::Label> nameLabel = new ng::Label(twoColumns, shaderName);
672 nameLabel->set_font_size(20);
673 }
674 }
675
676 bool addedItems = false;
677 const mx::VariableBlock* publicUniforms = material->getPublicUniforms();
678 if (publicUniforms)
679 {
680 mx::UIPropertyGroup groups;
681 mx::UIPropertyGroup unnamedGroups;
682 const std::string pathSeparator(":");
683 mx::createUIPropertyGroups(elem->getDocument(), *publicUniforms, groups, unnamedGroups, pathSeparator);
684
685 // First add items with named groups.
686 std::string previousFolder;
687 for (auto it = groups.begin(); it != groups.end(); ++it)
688 {
689 const std::string& folder = it->first;
690 const mx::UIPropertyItem& item = it->second;
691
692 // Verify that the uniform is editable, as some inputs may be optimized out during compilation.
693 if (material->findUniform(item.variable->getPath()))
694 {
695 addItemToForm(item, (previousFolder == folder) ? mx::EMPTY_STRING : folder, _container, viewer, true);

Callers 1

Calls 15

createUIPropertyGroupsFunction · 0.85
getCategoryMethod · 0.80
assignMethod · 0.80
createStringResolverMethod · 0.80
traverseGraphMethod · 0.80
getUpstreamElementMethod · 0.80
addTokenSubstitutionsMethod · 0.80
createFunction · 0.50
getSelectedMaterialMethod · 0.45
getElementMethod · 0.45
bindShaderMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected