src/Screens/ModelEditorScreen.cpp
// draw contextual actions (buttons, sliders) for a selected joint
draw contextual actions (buttons, sliders) for a selected joint
draw contextual actions ( buttons sliders ) for a selected joint
void drawHCFContextualActions(UndoableUiModel& uim) {
        OpenSim::HuntCrossleyForce const* hcf = uim.getSelectedAs<OpenSim::HuntCrossleyForce>();
        if (!hcf) {
            return;
        }
        if (hcf->get_contact_parameters().getSize() > 1) {
            ImGui::Text("cannot edit: has more than one HuntCrossleyForce::Parameter");
            return;
        }
        if (hcf->get_contact_parameters().getSize() == 0) {
            uim.updSelectedAs<OpenSim::HuntCrossleyForce>()->updContactParametersSet().adoptAndAppend(new OpenSim::HuntCrossleyForce::ContactParameters());
        }
        OpenSim::HuntCrossleyForce::ContactParameters const& params = hcf->get_contact_parameters()[0];
        ImGui::Columns(2);
        ImGui::TextUnformatted("add contact geometry");
        ImGui::SameLine();
        DrawHelpMarker("Add OpenSim::ContactGeometry to this OpenSim::HuntCrossleyForce.\n\nCollisions are evaluated for all OpenSim::ContactGeometry attached to the OpenSim::HuntCrossleyForce. E.g. if you want an OpenSim::ContactSphere component to collide with an OpenSim::ContactHalfSpace component during a simulation then you should add both of those components to this force");
        ImGui::NextColumn();
        {
            if (ImGui::Button("add contact geometry")) {
                ImGui::OpenPopup("select contact geometry");
            }
            OpenSim::ContactGeometry const* added =
                SelectComponentPopup<OpenSim::ContactGeometry>{}.draw("select contact geometry", uim.getModel());
            if (added) {
                uim.updSelectedAs<OpenSim::HuntCrossleyForce>()->updContactParametersSet()[0].updGeometry().appendValue(added->getName());
            }
        }
        ImGui::NextColumn();
        ImGui::Columns();
        {
            auto easyToHandleProps = std::array<int, 6>{
                params.PropertyIndex_geometry,
                params.PropertyIndex_stiffness,
                params.PropertyIndex_dissipation,
                params.PropertyIndex_static_friction,
                params.PropertyIndex_dynamic_friction,
                params.PropertyIndex_viscous_friction,
            };
            ObjectPropertiesEditor st;
            auto maybe_updater = st.draw(params, easyToHandleProps);
            if (maybe_updater) {
                uim.setDirty(true);
                maybe_updater->updater(const_cast<OpenSim::AbstractProperty&>(maybe_updater->prop));
            }
        }
    }
void drawHCFContextualActions ( UndoableUiModel & uim ) { OpenSim :: HuntCrossleyForce const * hcf = uim . getSelectedAs < OpenSim :: HuntCrossleyForce > ( ) ; if ( ! hcf ) { return ; } if ( hcf -> get_contact_parameters ( ) . getSize ( ) > 1 ) { ImGui :: Text ( " " ) ; return ; } if ( hcf -> get_contact_parameters ( ) . getSize ( ) == 0 ) { uim . updSelectedAs < OpenSim :: HuntCrossleyForce > ( ) -> updContactParametersSet ( ) . adoptAndAppend ( new OpenSim :: HuntCrossleyForce :: ContactParameters ( ) ) ; } OpenSim :: HuntCrossleyForce :: ContactParameters const & params = hcf -> get_contact_parameters ( ) [ 0 ] ; ImGui :: Columns ( 2 ) ; ImGui :: TextUnformatted ( " " ) ; ImGui :: SameLine ( ) ; DrawHelpMarker ( " \n \n " ) ; ImGui :: NextColumn ( ) ; { if ( ImGui :: Button ( " " ) ) { ImGui :: OpenPopup ( " " ) ; } OpenSim :: ContactGeometry const * added = SelectComponentPopup < OpenSim :: ContactGeometry > { } . draw ( " " , uim . getModel ( ) ) ; if ( added ) { uim . updSelectedAs < OpenSim :: HuntCrossleyForce > ( ) -> updContactParametersSet ( ) [ 0 ] . updGeometry ( ) . appendValue ( added -> getName ( ) ) ; } } ImGui :: NextColumn ( ) ; ImGui :: Columns ( ) ; { auto easyToHandleProps = std :: array < int , 6 > { params . PropertyIndex_geometry , params . PropertyIndex_stiffness , params . PropertyIndex_dissipation , params . PropertyIndex_static_friction , params . PropertyIndex_dynamic_friction , params . PropertyIndex_viscous_friction , } ; ObjectPropertiesEditor st ; auto maybe_updater = st . draw ( params , easyToHandleProps ) ; if ( maybe_updater ) { uim . setDirty ( true ) ; maybe_updater -> updater ( const_cast < OpenSim :: AbstractProperty & > ( maybe_updater -> prop ) ) ; } } }
draw contextual actions (buttons, sliders) for a selected joint
draw contextual actions ( buttons sliders ) for a selected joint
// HACK: if it has no parameters, give it some. The HuntCrossleyForce implementation effectively // does this internally anyway to satisfy its own API (e.g. `getStaticFriction` requires that // the HuntCrossleyForce has a parameter) // allow user to add geom // render standard, easy to render, props of the contact params // render readonly contact geometry list with the option for deletion