|
25 | 25 |
|
26 | 26 | #include <implot.h>
|
27 | 27 | #include <sofa/helper/map.h>
|
| 28 | +#include <sofa/helper/OptionsGroup.h> |
| 29 | + |
28 | 30 |
|
29 | 31 | namespace sofaimgui
|
30 | 32 | {
|
@@ -480,6 +482,31 @@ void DataWidget<std::map<std::string, type::vector<float> > >::showWidget(MyData
|
480 | 482 | showWidgetT(data);
|
481 | 483 | }
|
482 | 484 |
|
| 485 | +/*********************************************************************************************************************** |
| 486 | + * OptionsGroup |
| 487 | + **********************************************************************************************************************/ |
| 488 | + |
| 489 | +template<> |
| 490 | +void DataWidget<helper::OptionsGroup>::showWidget(MyData& data) |
| 491 | +{ |
| 492 | + const auto& label = data.getName(); |
| 493 | + const auto id = data.getName() + data.getOwner()->getPathName(); |
| 494 | + |
| 495 | + const auto& optionsGroup = data.getValue(); |
| 496 | + int selectedOption = static_cast<int>(optionsGroup.getSelectedId()); |
| 497 | + |
| 498 | + std::unique_ptr<const char*[]> charArray(new const char*[optionsGroup.size()]); |
| 499 | + for (unsigned int i = 0; i < optionsGroup.size(); ++i) |
| 500 | + { |
| 501 | + charArray[i] = optionsGroup[i].c_str(); |
| 502 | + } |
| 503 | + |
| 504 | + if (ImGui::Combo((label + "##" + id).c_str(), &selectedOption, charArray.get(), static_cast<int>(optionsGroup.size()))) |
| 505 | + { |
| 506 | + helper::WriteAccessor(data)->setSelectedItem(selectedOption); |
| 507 | + } |
| 508 | +} |
| 509 | + |
483 | 510 | /***********************************************************************************************************************
|
484 | 511 | * Factory
|
485 | 512 | **********************************************************************************************************************/
|
@@ -539,4 +566,6 @@ const bool dw_vector_tri = DataWidgetFactory::Add<type::vector<topology::Triangl
|
539 | 566 | const bool dw_map_vectorf = DataWidgetFactory::Add<std::map<std::string, type::vector<float> > >();
|
540 | 567 | const bool dw_map_vectord = DataWidgetFactory::Add<std::map<std::string, type::vector<double> > >();
|
541 | 568 |
|
| 569 | +const bool dw_optionsGroup = DataWidgetFactory::Add<helper::OptionsGroup>(); |
| 570 | + |
542 | 571 | }
|
0 commit comments