OpenVSP API Documentation 3.51.3
Loading...
Searching...
No Matches
Variable Preset Functions

This group of functions can be used to add, remove, and modify Variable Presets through the API. Click here to return to the main page. More...

Functions

std::string vsp::AddVarPresetGroup (const std::string &group_name)
std::string vsp::AddVarPresetSetting (const std::string &group_id, const std::string &setting_name)
void vsp::AddVarPresetParm (const std::string &group_id, const std::string &parm_id)
void vsp::DeleteAllVarPresetGroups ()
void vsp::DeleteAllVarPresetSettings (const std::string &group_id)
void vsp::DeleteVarPresetParm (const std::string &group_id, const std::string &parm_id)
void vsp::SetVarPresetParmVal (const std::string &group_id, const std::string &setting_id, const std::string &parm_id, double parm_val)
double vsp::GetVarPresetParmVal (const std::string &group_id, const std::string &setting_id, const std::string &parm_id)
std::string vsp::GetGroupName (const std::string &group_id)
std::string vsp::GetSettingName (const std::string &setting_id)
void vsp::SetGroupName (const std::string &group_id, const std::string &group_name)
void vsp::SetSettingName (const std::string &setting_id, const std::string &setting_name)
std::vector< std::string > vsp::GetVarPresetGroups ()
std::vector< std::string > vsp::GetVarPresetSettings (const std::string &group_id)
std::vector< std::string > vsp::GetVarPresetParmIDs (const std::string &group_id)
std::vector< double > vsp::GetVarPresetParmVals (const std::string &setting_id)
void vsp::SetVarPresetParmVals (const std::string &setting_id, const std::vector< double > &parm_vals)
void vsp::SaveVarPresetParmVals (const std::string &group_id, const std::string &setting_id)
void vsp::ApplyVarPresetSetting (const std::string &group_id, const std::string &setting_id)

Detailed Description

Function Documentation

◆ AddVarPresetGroup()

std::string vsp::AddVarPresetGroup ( const std::string & group_name)
extern

Add a Variable Preset Group

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
if ( gid.length() == 0 || gid == "NONE" )
{
Print( "ERROR: AddVarPresetGroup returned no id" );
__failure++;
}
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
std::string AddVarPresetGroup(const std::string &group_name)
Parameters
[in]group_namestring Name for Var Preset Group
Returns
string Var Preset Group ID

◆ AddVarPresetParm()

void vsp::AddVarPresetParm ( const std::string & group_id,
const std::string & parm_id )
extern

Add a Parm to the Variable Preset Group

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
string p1 = FindParm( pod1, "Tess_U", "Shape" );
AddVarPresetParm( gid, p1 );
// The Parm has to show up in the group's list, and only once.
array< string > @parm_ids = GetVarPresetParmIDs( gid );
if ( parm_ids.size() != 1 || parm_ids[0] != p1 )
{
Print( "ERROR: AddVarPresetParm did not add the Parm to the group" );
__failure++;
}
// Adding it again has to be rejected rather than duplicating it.
AddVarPresetParm( gid, p1 );
if ( GetNumTotalErrors() == 0 )
{
Print( "ERROR: AddVarPresetParm accepted the same Parm twice" );
__failure++;
}
if ( GetVarPresetParmIDs( gid ).size() != 1 )
{
Print( "ERROR: AddVarPresetParm added the same Parm twice" );
__failure++;
}
// That error was raised deliberately, so take it back off the queue.
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
std::string FindParm(const std::string &parm_container_id, const std::string &parm_name, const std::string &group_name)
std::string AddVarPresetSetting(const std::string &group_id, const std::string &setting_name)
std::vector< std::string > GetVarPresetParmIDs(const std::string &group_id)
void AddVarPresetParm(const std::string &group_id, const std::string &parm_id)
Parameters
[in]group_idstring Var Preset Group ID
[in]parm_idstring Parm ID

◆ AddVarPresetSetting()

std::string vsp::AddVarPresetSetting ( const std::string & group_id,
const std::string & setting_name )
extern

Add a Setting to the Variable Preset Group

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid =AddVarPresetSetting( gid, "Coarse" );
if ( sid.length() == 0 || sid == "NONE" )
{
Print( "ERROR: AddVarPresetSetting returned no id" );
__failure++;
}
Parameters
[in]group_idstring Var Preset Group ID
[in]setting_namestring Var Preset Setting Name
Returns
string Var Preset Setting ID

◆ ApplyVarPresetSetting()

void vsp::ApplyVarPresetSetting ( const std::string & group_id,
const std::string & setting_id )
extern

Apply Parm values for Var Preset Setting

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
string p1 = FindParm( pod1, "Tess_U", "Shape" );
AddVarPresetParm( gid, p1 );
// Store a value in the setting, move the Parm somewhere else, then apply.
double target = GetParmVal( p1 ) + 5.0;
SetVarPresetParmVal( gid, sid, p1, target );
SetParmVal( p1, GetParmVal( p1 ) - 2.0 );
// Applying the setting drives the Parm to the stored value.
if ( !closeTo( GetParmVal( p1 ), target, 1e-9 ) )
{
Print( "ERROR: ApplyVarPresetSetting did not apply the stored value" );
__failure++;
}
double SetParmVal(const std::string &parm_id, double val)
double GetParmVal(const std::string &parm_id)
void SetVarPresetParmVal(const std::string &group_id, const std::string &setting_id, const std::string &parm_id, double parm_val)
void ApplyVarPresetSetting(const std::string &group_id, const std::string &setting_id)
void Update(bool update_managers=true)
Parameters
[in]group_idstring Var Preset Group ID
[in]setting_idstring Var Preset Setting ID

◆ DeleteAllVarPresetGroups()

void vsp::DeleteAllVarPresetGroups ( )
extern

Delete Variable Preset Group (and all contained settings)

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
string p1 = FindParm( pod1, "Tess_U", "Shape" );
AddVarPresetParm( gid, p1 );
int num_before_del = GetVarPresetGroups().length();
DeleteVarPresetGroup( gid );
if ( GetVarPresetGroups().length() >= num_before_del )
{
Print( "ERROR: DeleteVarPresetGroup removed nothing" );
__failure++;
}
std::vector< std::string > GetVarPresetGroups()
Parameters
[in]group_idstring Var Preset Group ID

Delete every Variable Preset Group, along with all the settings they contain

string gid1 = AddVarPresetGroup( "Tess" );
string gid2 = AddVarPresetGroup( "Design" );
if ( GetVarPresetGroups().size() != 2 )
{
Print( "ERROR: the two groups were not both added" );
__failure++;
}
if ( GetVarPresetGroups().size() != 0 )
{
Print( "ERROR: DeleteAllVarPresetGroups left groups behind" );
__failure++;
}
void DeleteAllVarPresetGroups()
See also
AddVarPresetGroup, DeleteVarPresetGroup, GetVarPresetGroups

◆ DeleteAllVarPresetSettings()

void vsp::DeleteAllVarPresetSettings ( const std::string & group_id)
extern

Delete Variable Preset Setting

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
string p1 = FindParm( pod1, "Tess_U", "Shape" );
AddVarPresetParm( gid, p1 );
int num_before_del = GetVarPresetSettings( gid ).length();
DeleteVarPresetSetting( gid, sid );
if ( GetVarPresetSettings( gid ).length() >= num_before_del )
{
Print( "ERROR: DeleteVarPresetSetting removed nothing" );
__failure++;
}
std::vector< std::string > GetVarPresetSettings(const std::string &group_id)
Parameters
[in]group_idstring Var Preset Group ID
[in]setting_idstring Var Preset Setting ID

Delete every setting in a Variable Preset Group, leaving the group itself in place

string gid = AddVarPresetGroup( "Tess" );
AddVarPresetSetting( gid, "Coarse" );
AddVarPresetSetting( gid, "Fine" );
string gid2 = AddVarPresetGroup( "Design" );
AddVarPresetSetting( gid2, "Normal" );
// The group stays; its settings go. The other group is left alone.
if ( GetVarPresetSettings( gid ).size() != 0 )
{
Print( "ERROR: DeleteAllVarPresetSettings left settings behind" );
__failure++;
}
if ( GetVarPresetGroups().size() != 2 )
{
Print( "ERROR: DeleteAllVarPresetSettings removed the group" );
__failure++;
}
if ( GetVarPresetSettings( gid2 ).size() != 1 )
{
Print( "ERROR: DeleteAllVarPresetSettings reached another group" );
__failure++;
}
void DeleteAllVarPresetSettings(const std::string &group_id)
See also
AddVarPresetSetting, DeleteVarPresetSetting, GetVarPresetSettings
Parameters
[in]group_idstring Var Preset Group ID

◆ DeleteVarPresetParm()

void vsp::DeleteVarPresetParm ( const std::string & group_id,
const std::string & parm_id )
extern

Delete Parm from Variable Preset Group

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
string p1 = FindParm( pod1, "Tess_U", "Shape" );
AddVarPresetParm( gid, p1 );
int num_before_del = GetVarPresetParmIDs( gid ).length();
if ( GetVarPresetParmIDs( gid ).length() >= num_before_del )
{
Print( "ERROR: DeleteVarPresetParm removed nothing" );
__failure++;
}
void DeleteVarPresetParm(const std::string &group_id, const std::string &parm_id)
Parameters
[in]group_idstring Var Preset Group ID
[in]parm_idstring Var Parm ID

◆ GetGroupName()

std::string vsp::GetGroupName ( const std::string & group_id)
extern

Get Variable Preset group name

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string name = GetGroupName( gid );
if ( name.length() == 0 )
{
Print( "ERROR: GetGroupName returned nothing" );
__failure++;
}
std::string GetGroupName(const std::string &group_id)
Parameters
[in]group_idstring Var Preset Group ID
Returns
string Var Preset Group name

◆ GetSettingName()

std::string vsp::GetSettingName ( const std::string & setting_id)
extern

Get Variable Preset Setting name

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
string name = GetSettingName( sid );
if ( name.length() == 0 )
{
Print( "ERROR: GetSettingName returned nothing" );
__failure++;
}
std::string GetSettingName(const std::string &setting_id)
Parameters
[in]setting_idstring Var Preset Setting ID
Returns
string Var Preset Setting name

◆ GetVarPresetGroups()

std::vector< std::string > vsp::GetVarPresetGroups ( )
extern

Get group_ids for Variable Preset Groups

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
string p1 = FindParm( pod1, "Tess_U", "Shape" );
AddVarPresetParm( gid, p1 );
array <string> group_ids = GetVarPresetGroups();
if ( group_ids.length() == 0 )
{
Print( "ERROR: GetVarPresetGroups returned nothing" );
__failure++;
}
Returns
array<string> Array of Variable Preset Group IDs

◆ GetVarPresetParmIDs()

std::vector< std::string > vsp::GetVarPresetParmIDs ( const std::string & group_id)
extern

Get ParmIDs for Variable Preset Group

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
string p1 = FindParm( pod1, "Tess_U", "Shape" );
AddVarPresetParm( gid, p1 );
array <string> parmids = GetVarPresetParmIDs( gid );
if ( parmids.length() == 0 )
{
Print( "ERROR: GetVarPresetParmIDs returned nothing" );
__failure++;
}
Parameters
[in]group_idstring Var Preset Group ID
Returns
array<string> Array of Variable Preset Group ParmIDs

◆ GetVarPresetParmVal()

double vsp::GetVarPresetParmVal ( const std::string & group_id,
const std::string & setting_id,
const std::string & parm_id )
extern

Get value for Parm in Var Preset Setting

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
string p1 = FindParm( pod1, "Tess_U", "Shape" );
AddVarPresetParm( gid, p1 );
double val = GetVarPresetParmVal( gid, sid, p1 );
// A Parm joins the group at its current value.
if ( !closeTo( val, GetParmVal( p1 ), 1e-9 ) )
{
Print( "ERROR: GetVarPresetParmVal does not match the Parm" );
__failure++;
}
// Storing a different value has to be what comes back, without disturbing
// the Parm itself.
SetVarPresetParmVal( gid, sid, p1, val + 3.0 );
if ( !closeTo( GetVarPresetParmVal( gid, sid, p1 ), val + 3.0, 1e-9 ) )
{
Print( "ERROR: GetVarPresetParmVal did not follow SetVarPresetParmVal" );
__failure++;
}
if ( !closeTo( GetParmVal( p1 ), val, 1e-9 ) )
{
Print( "ERROR: storing a preset value changed the Parm" );
__failure++;
}
double GetVarPresetParmVal(const std::string &group_id, const std::string &setting_id, const std::string &parm_id)
Parameters
[in]group_idstring Var Preset Group ID
[in]setting_idstring Var Preset Setting ID
[in]parm_idstring Var Parm ID
Returns
double Var Preset Parm value

◆ GetVarPresetParmVals()

std::vector< double > vsp::GetVarPresetParmVals ( const std::string & setting_id)
extern

Get Parm values for Variable Preset Setting

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
string p1 = FindParm( pod1, "Tess_U", "Shape" );
AddVarPresetParm( gid, p1 );
array < double > parmval_vec = GetVarPresetParmVals( sid );
if ( parmval_vec.length() == 0 )
{
Print( "ERROR: GetVarPresetParmVals returned nothing" );
__failure++;
}
std::vector< double > GetVarPresetParmVals(const std::string &setting_id)
Parameters
[in]setting_idstring Var Preset Setting ID
Returns
array<double> Var Preset Parm values for Setting

◆ GetVarPresetSettings()

std::vector< std::string > vsp::GetVarPresetSettings ( const std::string & group_id)
extern

Get Setting IDs for Variable Preset Group

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
string p1 = FindParm( pod1, "Tess_U", "Shape" );
AddVarPresetParm( gid, p1 );
array <string> settingids = GetVarPresetSettings( gid );
if ( settingids.length() == 0 )
{
Print( "ERROR: GetVarPresetSettings returned nothing" );
__failure++;
}
Parameters
[in]group_idstring Var Preset Group ID
Returns
array<string> Array of Variable Preset Group ParmIDs

◆ SaveVarPresetParmVals()

void vsp::SaveVarPresetParmVals ( const std::string & group_id,
const std::string & setting_id )
extern

Save current Parm values to Variable Preset Setting

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
string p1 = FindParm( pod1, "Tess_U", "Shape" );
AddVarPresetParm( gid, p1 );
// Move the Parm away from whatever the setting holds, then save.
SetParmVal( p1, GetParmVal( p1 ) + 4.0 );
// The setting now holds the Parm's current value.
if ( !closeTo( GetVarPresetParmVal( gid, sid, p1 ), GetParmVal( p1 ), 1e-9 ) )
{
Print( "ERROR: SaveVarPresetParmVals did not capture the current value" );
__failure++;
}
void SaveVarPresetParmVals(const std::string &group_id, const std::string &setting_id)
Parameters
[in]group_idstring Var Preset Group ID
[in]setting_idstring Var Preset Setting ID

◆ SetGroupName()

void vsp::SetGroupName ( const std::string & group_id,
const std::string & group_name )
extern

Set Variable Preset group name

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
SetGroupName( gid, "Resolution" );
if ( GetGroupName( gid ) != "Resolution" )
{
Print( "ERROR: SetGroupName did not take" );
__failure++;
}
void SetGroupName(const std::string &group_id, const std::string &group_name)
Parameters
[in]group_idstring Var Preset Group ID
[in]group_namestring New Var Preset Group name

◆ SetSettingName()

void vsp::SetSettingName ( const std::string & setting_id,
const std::string & setting_name )
extern

Set Variable Preset Setting name

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
SetSettingName( sid, "Low" );
if ( GetSettingName( sid ) != "Low" )
{
Print( "ERROR: SetSettingName did not take" );
__failure++;
}
void SetSettingName(const std::string &setting_id, const std::string &setting_name)
Parameters
[in]setting_idstring Var Preset Setting ID
[in]setting_namestring New Var Preset Setting name

◆ SetVarPresetParmVal()

void vsp::SetVarPresetParmVal ( const std::string & group_id,
const std::string & setting_id,
const std::string & parm_id,
double parm_val )
extern

Set value for Parm in Var Preset Setting

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
string p1 = FindParm( pod1, "Tess_U", "Shape" );
AddVarPresetParm( gid, p1 );
SetVarPresetParmVal( gid, sid, p1, 51 );
if ( !closeTo( GetVarPresetParmVal( gid, sid, p1 ), 51, 1e-9 ) )
{
Print( "ERROR: SetVarPresetParmVal did not take" );
__failure++;
}
Parameters
[in]group_idstring Var Preset Group ID
[in]setting_idstring Var Preset Setting ID
[in]parm_idstring Var Parm ID
[in]parm_valdouble Parm value

◆ SetVarPresetParmVals()

void vsp::SetVarPresetParmVals ( const std::string & setting_id,
const std::vector< double > & parm_vals )
extern

Set Parm values for Variable Preset Setting

// Add Pod Geom
string pod1 = AddGeom( "POD", "" );
string gid = AddVarPresetGroup( "Tess" );
string sid = AddVarPresetSetting( gid, "Coarse" );
string p1 = FindParm( pod1, "Tess_U", "Shape" );
AddVarPresetParm( gid, p1 );
array <double> vals = { 45 };
SetVarPresetParmVals( sid, vals );
if ( GetVarPresetParmVals( sid ) != vals )
{
Print( "ERROR: SetVarPresetParmVals did not take" );
__failure++;
}
void SetVarPresetParmVals(const std::string &setting_id, const std::vector< double > &parm_vals)
Parameters
[in]setting_idstring Var Preset Setting ID
[in]parm_valsarray<double> Array of Variable Preset Group Parm values