| 137 | } |
| 138 | |
| 139 | static void fcall_selectinputs( lk::invoke_t &cxt ) |
| 140 | { |
| 141 | LK_DOC("select_inputs", "Shows the input variable window with an optional title and writes a list of checked variable names to the array argument.", "(array:checked, [string:title]):boolean") |
| 142 | |
| 143 | cxt.result().assign( 0.0 ); |
| 144 | |
| 145 | Case *cc = CurrentCase(); |
| 146 | if ( !cc ) |
| 147 | { |
| 148 | cxt.error("no active case");; |
| 149 | return; |
| 150 | } |
| 151 | |
| 152 | wxArrayString names; |
| 153 | wxArrayString labels; |
| 154 | |
| 155 | auto ci = cc->GetConfiguration(); |
| 156 | for (size_t ndxHybrid = 0; ndxHybrid < ci->Technology.size(); ndxHybrid++) { |
| 157 | VarInfoLookup& vil = ci->Variables[ndxHybrid]; |
| 158 | |
| 159 | for (VarInfoLookup::iterator it = vil.begin(); it != vil.end(); ++it) { |
| 160 | wxString name = it->first; |
| 161 | if (ci->Technology.size() > 1) name = ci->Technology[ndxHybrid].Lower() + "_" + name; |
| 162 | VarInfo& vi = *(it->second); |
| 163 | |
| 164 | // update to select only "Parametric" variables and NOT calculated variables |
| 165 | if ((vi.Flags & VF_PARAMETRIC) && !(vi.Flags & VF_INDICATOR) && !(vi.Flags & VF_CALCULATED)) |
| 166 | { |
| 167 | wxString label = SelectVariableDialog::PrettyPrintLabel(name, vi); |
| 168 | labels.Add(label); |
| 169 | names.Add(name); |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | wxSortByLabels(names, labels); |
| 175 | |
| 176 | wxArrayString list; |
| 177 | lk::vardata_t &inlist = cxt.arg(0).deref(); |
| 178 | for( size_t i=0;i<inlist.length();i++ ) |
| 179 | list.Add( inlist.index(i)->as_string() ); |
| 180 | |
| 181 | wxString title("Select input variables"); |
| 182 | if (cxt.arg_count() > 1 ) title = cxt.arg(1).as_string(); |
| 183 | |
| 184 | if ( SelectVariableDialog::Run(title, names, labels, list) ) |
| 185 | { |
| 186 | inlist.empty_vector(); |
| 187 | for( size_t i=0;i<list.size();i++ ) |
| 188 | inlist.vec_append( list[i] ); |
| 189 | |
| 190 | cxt.result().assign( 1.0 ); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | |
| 195 | static bool UpdateVarNameNdxHybrid(Case* c, const wxString& input_name, wxString* var_name, size_t* ndx_hybrid) |
nothing calls this directly
no test coverage detected