src/Screens/SimulatorScreen.cpp
// draw output plots for the currently-focused sim
draw output plots for the currently-focused sim
draw output plots for the currently - focused sim
void drawOutputPlots(
            osc::SimulatorScreen::Impl& impl,
            UiSimulation const& focusedSim,
            Report const& focusedReport,
            OpenSim::Component const& selected) {
        int imguiID = 0;
        ImGui::Columns(2);
        for (auto const& ptr : selected.getOutputs()) {
            OpenSim::AbstractOutput const& ao = *ptr.second;
            ImGui::TextUnformatted(ao.getName().c_str());
            ImGui::NextColumn();
            OpenSim::Output<double> const* odPtr =
                dynamic_cast<OpenSim::Output<double> const*>(&ao);
            if (!odPtr) {
                ImGui::TextUnformatted(ao.getValueAsString(focusedReport.state).c_str());
                ImGui::NextColumn();
                continue;  
            }
            OpenSim::Output<double> const& od = *odPtr;
            size_t npoints = focusedSim.regularReports.size();
            impl.plotscratch.resize(npoints);
            size_t i = 0;
            for (auto const& report : focusedSim.regularReports) {
                double v = od.getValue(report->state);
                impl.plotscratch[i++] = static_cast<float>(v);
            }
            ImGui::PushID(imguiID++);
            ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth());
            ImGui::PlotLines("##nolabel", impl.plotscratch.data(), static_cast<int>(impl.plotscratch.size()), 0, nullptr, FLT_MAX, FLT_MAX, ImVec2{0.0f, 20.0f});
            if (ImGui::BeginPopupContextItem(od.getName().c_str())) {
                if (ImGui::MenuItem("Add to outputs watch")) {
                    impl.mes->desiredOutputs.emplace_back(selected, od);
                }
                ImGui::EndPopup();
            }
            ImGui::PopID();
            ImGui::NextColumn();
        }
        ImGui::Columns();
    }
void drawOutputPlots ( osc :: SimulatorScreen :: Impl & impl , UiSimulation const & focusedSim , Report const & focusedReport , OpenSim :: Component const & selected ) { int imguiID = 0 ; ImGui :: Columns ( 2 ) ; for ( auto const & ptr : selected . getOutputs ( ) ) { OpenSim :: AbstractOutput const & ao = * ptr . second ; ImGui :: TextUnformatted ( ao . getName ( ) . c_str ( ) ) ; ImGui :: NextColumn ( ) ; OpenSim :: Output < double > const * odPtr = dynamic_cast < OpenSim :: Output < double > const * > ( & ao ) ; if ( ! odPtr ) { ImGui :: TextUnformatted ( ao . getValueAsString ( focusedReport . state ) . c_str ( ) ) ; ImGui :: NextColumn ( ) ; continue ; } OpenSim :: Output < double > const & od = * odPtr ; size_t npoints = focusedSim . regularReports . size ( ) ; impl . plotscratch . resize ( npoints ) ; size_t i = 0 ; for ( auto const & report : focusedSim . regularReports ) { double v = od . getValue ( report -> state ) ; impl . plotscratch [ i ++ ] = static_cast < float > ( v ) ; } ImGui :: PushID ( imguiID ++ ) ; ImGui :: SetNextItemWidth ( ImGui :: GetContentRegionAvailWidth ( ) ) ; ImGui :: PlotLines ( " " , impl . plotscratch . data ( ) , static_cast < int > ( impl . plotscratch . size ( ) ) , 0 , nullptr , FLT_MAX , FLT_MAX , ImVec2 { 0.0f , 20.0f } ) ; if ( ImGui :: BeginPopupContextItem ( od . getName ( ) . c_str ( ) ) ) { if ( ImGui :: MenuItem ( " " ) ) { impl . mes -> desiredOutputs . emplace_back ( selected , od ) ; } ImGui :: EndPopup ( ) ; } ImGui :: PopID ( ) ; ImGui :: NextColumn ( ) ; } ImGui :: Columns ( ) ; }
draw output plots for the currently-focused sim
draw output plots for the currently - focused sim
// unplottable