Merge branch 'master' of https://github.com/schuellc/libigl
# Conflicts: # include/igl/triangle_triangle_adjacency.h
This commit is contained in:
+18
-28
@@ -421,20 +421,23 @@ igl::viewer::Viewer viewer;
|
||||
|
||||
bool boolVariable = true;
|
||||
float floatVariable = 0.1f;
|
||||
enum Orientation { Up=0,Down,Left,Right } dir = Up;
|
||||
|
||||
// extend viewer menu
|
||||
// Extend viewer menu
|
||||
viewer.callback_init = [&](igl::viewer::Viewer& viewer)
|
||||
{
|
||||
// add new group
|
||||
viewer.ngui->addNewGroup("New Group");
|
||||
// Add new group
|
||||
viewer.ngui->addGroup("New Group");
|
||||
|
||||
// expose variables
|
||||
viewer.ngui->addVariable(boolVariable,"bool");
|
||||
viewer.ngui->addVariable(floatVariable,"float");
|
||||
|
||||
// add button
|
||||
viewer.ngui->addButton("Print Hello",[](){ cout << "Hello\n"; });
|
||||
// Expose a variable directly ...
|
||||
viewer.ngui->addVariable("float",floatVariable);
|
||||
|
||||
// Expose an enumaration type
|
||||
viewer.ngui->addVariable<Orientation>("Direction",dir)->setItems({"Up","Down","Left","Right"});
|
||||
|
||||
// Add a button
|
||||
viewer.ngui->addButton("Print Hello",[](){ std::cout << "Hello\n"; });
|
||||
|
||||
// call to generate menu
|
||||
viewer.ngui->layout();
|
||||
return false;
|
||||
@@ -447,31 +450,18 @@ viewer.launch();
|
||||
If you need a separate new menu window use:
|
||||
|
||||
```cpp
|
||||
viewer.ngui->addNewWindow(Eigen::Vector2i(220,10),"New Window");
|
||||
```
|
||||
|
||||
You can also switch between different orientation of the layout:
|
||||
|
||||
```cpp
|
||||
// horizontal alignment
|
||||
viewer.ngui->addNewGroup("New Group",nanogui::FormScreen::Layout::Horizontal);
|
||||
viewer.ngui->addButton("Print Test1",[](){ cout << "Test1\n"; });
|
||||
viewer.ngui->addButton("Print Test2",[](){ cout << "Test2\n"; });
|
||||
|
||||
// vertical alignment
|
||||
viewer.ngui->setCurrentLayout(nanogui::FormScreen::Layout::Vertical);
|
||||
viewer.ngui->addVariable(boolVariable,"bool");
|
||||
viewer.ngui->addVariable(floatVariable,"float");
|
||||
viewer.ngui->addWindow(Eigen::Vector2i(220,10),"New Window");
|
||||
```
|
||||
|
||||
If you do not want to expose variables directly but rather use the get/set functionality:
|
||||
|
||||
```cpp
|
||||
viewer.ngui->addVariable([&](bool val) {
|
||||
boolVariable = val; // set
|
||||
// ... or using a custom callback
|
||||
viewer.ngui->addVariable<bool>("bool",[&](bool val) {
|
||||
boolVariable = val; // setter
|
||||
},[&]() {
|
||||
return boolVariable; // get
|
||||
},"bool",true);
|
||||
return boolVariable; // getter
|
||||
});
|
||||
```
|
||||
|
||||
) The UI of the viewer can be easily customized.](images/106_ViewerMenu.png)
|
||||
|
||||
Reference in New Issue
Block a user