| 281 | } |
| 282 | |
| 283 | void Viewer::initialize() |
| 284 | { |
| 285 | _window = new ng::Window(this, "Viewer Options"); |
| 286 | _window->set_position(ng::Vector2i(15, 15)); |
| 287 | _window->set_layout(new ng::GroupLayout()); |
| 288 | |
| 289 | // Initialize the standard libraries and color/unit management. |
| 290 | loadStandardLibraries(); |
| 291 | |
| 292 | // Initialize image handler. |
| 293 | _imageHandler = _renderPipeline->createImageHandler(); |
| 294 | #if MATERIALX_BUILD_OIIO |
| 295 | _imageHandler->addLoader(mx::OiioImageLoader::create()); |
| 296 | #endif |
| 297 | _imageHandler->setSearchPath(_searchPath); |
| 298 | |
| 299 | // Initialize user interfaces. |
| 300 | createLoadMeshInterface((ng::ref<ng::Widget>) _window, "Load Mesh"); |
| 301 | createLoadMaterialsInterface((ng::ref<ng::Widget>) _window, "Load Material"); |
| 302 | createLoadEnvironmentInterface((ng::ref<ng::Widget>) _window, "Load Environment"); |
| 303 | createPropertyEditorInterface((ng::ref<ng::Widget>) _window, "Property Editor"); |
| 304 | createAdvancedSettings((ng::ref<ng::Widget>) _window); |
| 305 | |
| 306 | // Create geometry selection box. |
| 307 | _geomLabel = new ng::Label(_window, "Select Geometry"); |
| 308 | _geometrySelectionBox = new ng::ComboBox(_window, { "None" }); |
| 309 | _geometrySelectionBox->set_chevron_icon(-1); |
| 310 | _geometrySelectionBox->set_callback([this](int choice) |
| 311 | { |
| 312 | size_t index = (size_t) choice; |
| 313 | if (index < _geometryList.size()) |
| 314 | { |
| 315 | _selectedGeom = index; |
| 316 | if (_materialAssignments.count(getSelectedGeometry())) |
| 317 | { |
| 318 | setSelectedMaterial(_materialAssignments[getSelectedGeometry()]); |
| 319 | } |
| 320 | updateDisplayedProperties(); |
| 321 | updateMaterialSelectionUI(); |
| 322 | } |
| 323 | }); |
| 324 | |
| 325 | // Create material selection box. |
| 326 | _materialLabel = new ng::Label(_window, "Assigned Material"); |
| 327 | _materialSelectionBox = new ng::ComboBox(_window, { "None" }); |
| 328 | _materialSelectionBox->set_chevron_icon(-1); |
| 329 | _materialSelectionBox->set_callback([this](int choice) |
| 330 | { |
| 331 | size_t index = (size_t) choice; |
| 332 | if (index < _materials.size()) |
| 333 | { |
| 334 | // Update selected material index |
| 335 | _selectedMaterial = index; |
| 336 | |
| 337 | // Assign selected material to geometry |
| 338 | assignMaterial(getSelectedGeometry(), _materials[index]); |
| 339 | } |
| 340 | }); |
no test coverage detected