This functions grouped here are used to create and manipulate Custom Components. Custom components are defined in \*.vsppart files in a CustomScripts directory. Examples of Custom Components are in the CustomScripts directory installed with OpenVSP. OpenVSP reads the CustomScripts folder in three places, in this order, once when it starts: the working directory, the home directory, and the directory of the VSP executable. Note, these functions are specific to defining Custom Components and can't be called from standard API scripts (i.e. \*.vspscript). However, a Custom Component can be created as a \*.vsppart file and then accessed through secondary API scripts. Click here to return to the main page. More...
Classes | |
| class | CustomGeomMgrSingleton |
| class | CustomXSec |
| class | CustomGeom |
Functions | |
| string | CustomGeomMgrSingleton::GetCurrCustomGeom () |
| string | CustomGeomMgrSingleton::AddParm (int type, const string &name, const string &group) |
| string | CustomGeomMgrSingleton::GetCustomParm (int index) |
| int | CustomGeomMgrSingleton::AddGui (int type, const string &arg1=string(), const string &arg2=string(), const string &arg3=string(), double arg4=10, const string &arg5=string()) |
| void | CustomGeomMgrSingleton::AddUpdateGui (int gui_id, const string &parm_id) |
| void | CustomGeomMgrSingleton::AddUpdateGui (int gui_id, const string &parm_id, const string &parm_id2, int input) |
| bool | CustomGeomMgrSingleton::CheckClearTriggerEvent (int gui_id) |
| string | CustomGeomMgrSingleton::AddXSecSurf () |
| void | CustomGeomMgrSingleton::RemoveXSecSurf (const string &id) |
| void | CustomGeomMgrSingleton::ClearXSecSurfs () |
| void | CustomGeomMgrSingleton::SkinXSecSurf (bool closed_flag) |
| void | CustomGeomMgrSingleton::TransformSurf (int index, Matrix4d &mat) |
| void | CustomGeomMgrSingleton::CloneSurf (int index, Matrix4d &mat) |
| void | CustomGeomMgrSingleton::SetVspSurfType (int type, int surf_id=-1) |
| void | CustomGeomMgrSingleton::SetVspSurfCfdType (int type, int surf_id=-1) |
| void | CustomGeomMgrSingleton::SetupCustomDefaultSource (int type, int surf_index, double l1, double r1, double u1, double w1, double l2=0, double r2=0, double u2=0, double w2=0) |
| void | CustomGeomMgrSingleton::ClearAllCustomDefaultSources () |
| void | CustomGeomMgrSingleton::SetCustomCenter (double x, double y, double z) |
| void | CustomGeomMgrSingleton::SetCustomXSecLoc (const string &xsec_id, const vec3d &loc) |
| vec3d | CustomGeomMgrSingleton::GetCustomXSecLoc (const string &xsec_id) |
| void | CustomGeomMgrSingleton::SetCustomXSecRot (const string &xsec_id, const vec3d &rot) |
| vec3d | CustomGeomMgrSingleton::GetCustomXSecRot (const string &xsec_id) |
| string | CustomGeomMgrSingleton::AppendCustomXSec (const string &xsec_surf_id, int type) |
| void | CustomGeomMgrSingleton::CutCustomXSec (const string &xsec_surf_id, int index) |
| void | CustomGeomMgrSingleton::CopyCustomXSec (const string &xsec_surf_id, int index) |
| void | CustomGeomMgrSingleton::PasteCustomXSec (const string &xsec_surf_id, int index) |
| string | CustomGeomMgrSingleton::InsertCustomXSec (const string &xsec_surf_id, int type, int index) |
| class CustomGeomMgrSingleton |
CustomGeomMgrSingleton is what a custom component script talks to. Every function in this group is registered with AngelScript as a global bound to this object, so a .vsppart file calls AddParm or AddXSecSurf directly without naming the manager. Called from an ordinary script, outside the building of a component, they return an empty result and raise no error.
Definition at line 57 of file CustomGeom.h.
Public Member Functions | |
|---|---|
| void | InitGeom (const string &id, const string &module_name, const string &display_name) |
| void | SetCurrCustomGeom (const string &id) |
| string | GetCurrCustomGeom () |
| void | ReadCustomScripts (Vehicle *veh) |
| vector< GeomType > | GetCustomTypes () |
| string | AddParm (int type, const string &name, const string &group) |
| string | GetCustomParm (int index) |
| int | AddGui (int type, const string &arg1=string(), const string &arg2=string(), const string &arg3=string(), double arg4=10, const string &arg5=string()) |
| vector< GuiDef > | GetGuiDefVec (const string &geom_id) |
| void | AddUpdateGui (int gui_id, const string &parm_id) |
| void | AddUpdateGui (int gui_id, const string &parm_id, const string &parm_id2, int input) |
| vector< GuiUpdate > | GetGuiUpdateVec () |
| bool | CheckClearTriggerEvent (int gui_id) |
| string | AddXSecSurf () |
| void | RemoveXSecSurf (const string &id) |
| void | ClearXSecSurfs () |
| void | SkinXSecSurf (bool closed_flag) |
| void | TransformSurf (int index, Matrix4d &mat) |
| void | CloneSurf (int index, Matrix4d &mat) |
| void | SetVspSurfType (int type, int surf_id=-1) |
| void | SetVspSurfCfdType (int type, int surf_id=-1) |
| void | SetupCustomDefaultSource (int type, int surf_index, double l1, double r1, double u1, double w1, double l2=0, double r2=0, double u2=0, double w2=0) |
| void | ClearAllCustomDefaultSources () |
| void | SetCustomCenter (double x, double y, double z) |
| void | SetCustomXSecLoc (const string &xsec_id, const vec3d &loc) |
| vec3d | GetCustomXSecLoc (const string &xsec_id) |
| void | SetCustomXSecRot (const string &xsec_id, const vec3d &rot) |
| vec3d | GetCustomXSecRot (const string &xsec_id) |
| string | AppendCustomXSec (const string &xsec_surf_id, int type) |
| void | CutCustomXSec (const string &xsec_surf_id, int index) |
| void | CopyCustomXSec (const string &xsec_surf_id, int index) |
| void | PasteCustomXSec (const string &xsec_surf_id, int index) |
| string | InsertCustomXSec (const string &xsec_surf_id, int type, int index) |
| vector< string > | GetCustomScriptModuleNames () |
Static Public Member Functions | |
| static CustomGeomMgrSingleton & | getInstance () |
| static void | Init () |
| static int | SaveScriptContentToFile (const string &module_name, const string &file_name) |
Private Member Functions | |
| CustomGeomMgrSingleton (CustomGeomMgrSingleton const ©)=delete | |
| CustomGeomMgrSingleton & | operator= (CustomGeomMgrSingleton const ©)=delete |
Private Attributes | |
| string | m_CurrGeom |
| vector< GeomType > | m_CustomTypeVec |
| unordered_map< string, string > | m_ModuleGeomIDMap |
|
inline |
Definition at line 87 of file CustomGeom.h.
|
inlinestatic |
Definition at line 60 of file CustomGeom.h.
|
inlinestatic |
Definition at line 65 of file CustomGeom.h.
|
inline |
Definition at line 69 of file CustomGeom.h.
|
private |
Definition at line 626 of file CustomGeom.h.
|
private |
Definition at line 627 of file CustomGeom.h.
|
private |
Definition at line 628 of file CustomGeom.h.
| class CustomXSec |
A cross section belonging to a custom component. Created through AppendCustomXSec or InsertCustomXSec rather than directly, and positioned with SetCustomXSecLoc and SetCustomXSecRot.
Definition at line 648 of file CustomGeom.h.
Public Member Functions | |
|---|---|
| CustomXSec (XSecCurve *xsc) | |
| virtual void | Update () |
| virtual void | CopyBasePos (XSec *xs) |
| virtual void | SetLoc (const vec3d &loc) |
| virtual vec3d | GetLoc () |
| virtual void | SetRot (const vec3d &rot) |
| virtual vec3d | GetRot () |
| virtual double | GetScale () |
Protected Attributes | |
| vec3d | m_Loc |
| vec3d | m_Rot |
|
inlinevirtual |
Definition at line 658 of file CustomGeom.h.
|
inlinevirtual |
Definition at line 660 of file CustomGeom.h.
|
protected |
Definition at line 666 of file CustomGeom.h.
|
protected |
Definition at line 667 of file CustomGeom.h.
| class CustomGeom |
The component a .vsppart file builds. OpenVSP calls the script's Init function once to declare the Parms and the GUI, and its Update function whenever something changes, which is where the cross sections are placed and SkinXSecSurf is called.
Definition at line 686 of file CustomGeom.h.
Public Member Functions | |
|---|---|
| CustomGeom (Vehicle *vehicle_ptr) | |
| void | Clear () |
| void | InitGeom () |
| void | SetScriptModuleName (const string &name) |
| string | GetScriptModuleName () |
| void | SetDisplayName (const string &name) |
| string | GetDisplayName () |
| string | AddParm (int type, const string &name, const string &group) |
| string | FindParmID (int index) |
| int | AddGui (const GuiDef &gd) |
| vector< GuiDef > | GetGuiDefVec () |
| void | AddGuiTriggerEvent (int gui_index) |
| bool | CheckClearTriggerEvent (int gui_index) |
| void | AddUpdateGui (const GuiUpdate &gu) |
| vector< GuiUpdate > | GetGuiUpdateVec () |
| string | AddXSecSurf () |
| void | RemoveXSecSurf (const string &id) |
| void | ClearXSecSurfs () |
| virtual int | GetNumXSecSurfs () const |
| virtual XSecSurf * | GetXSecSurf (int index) |
| virtual void | SkinXSecSurf (bool closed_flag) |
| virtual void | CloneSurf (int index, Matrix4d &mat) |
| virtual void | TransformSurf (int index, Matrix4d &mat) |
| virtual xmlNodePtr | EncodeXml (xmlNodePtr &node) |
| virtual xmlNodePtr | DecodeXml (xmlNodePtr &node) |
| virtual void | SetVspSurfType (int type, int surf_id=-1) |
| virtual void | SetVspSurfCfdType (int type, int surf_id=-1) |
| virtual void | AddDefaultSources (double base_len=1.0) |
| virtual void | SetUpDefaultSource (SourceData &sd) |
| virtual void | ClearAllDefaultSources () |
| virtual void | ComputeCenter () |
| virtual void | ApplyScale (double currentScale) |
| virtual void | OffsetXSecs (double off) |
Protected Member Functions | |
| virtual void | UpdateSurf () |
| virtual void | UpdateFlags () |
| virtual void | ApplyConformalOffset (double off) |
Protected Attributes | |
| bool | m_InitGeomFlag |
| string | m_ScriptModuleName |
| string | m_DisplayName |
| vector< Parm * > | m_CustomGeomParmVec |
| vector< GuiDef > | m_GuiDefVec |
| vector< GuiUpdate > | m_UpdateGuiVec |
| vector< XSecSurf * > | m_XSecSurfVec |
| vector< int > | m_TriggerVec |
| vector< SourceData > | m_DefaultSourceVec |
| int | m_VspSurfType |
| unordered_map< int, int > | m_VspSurfTypeMap |
| int | m_VspSurfCfdType |
| unordered_map< int, int > | m_VspSurfCfdTypeMap |
| bool | m_ConformalFlag |
| double | m_ConformalOffset |
|
inlinevirtual |
Definition at line 736 of file CustomGeom.h.
|
inline |
Definition at line 697 of file CustomGeom.h.
|
inline |
Definition at line 705 of file CustomGeom.h.
|
inlinevirtual |
Definition at line 717 of file CustomGeom.h.
|
inline |
Definition at line 695 of file CustomGeom.h.
|
inline |
Definition at line 696 of file CustomGeom.h.
|
inline |
Definition at line 694 of file CustomGeom.h.
|
inlinevirtual |
Definition at line 735 of file CustomGeom.h.
|
protected |
Definition at line 768 of file CustomGeom.h.
|
protected |
Definition at line 769 of file CustomGeom.h.
|
protected |
Definition at line 750 of file CustomGeom.h.
|
protected |
Definition at line 755 of file CustomGeom.h.
|
protected |
Definition at line 748 of file CustomGeom.h.
|
protected |
Definition at line 751 of file CustomGeom.h.
|
protected |
Definition at line 746 of file CustomGeom.h.
|
protected |
Definition at line 747 of file CustomGeom.h.
|
protected |
Definition at line 754 of file CustomGeom.h.
|
protected |
Definition at line 752 of file CustomGeom.h.
|
protected |
Definition at line 759 of file CustomGeom.h.
|
protected |
Definition at line 760 of file CustomGeom.h.
|
protected |
Definition at line 757 of file CustomGeom.h.
|
protected |
Definition at line 758 of file CustomGeom.h.
|
protected |
Definition at line 753 of file CustomGeom.h.
| int CustomGeomMgrSingleton::AddGui | ( | int | type, |
| const string & | arg1 = string(), | ||
| const string & | arg2 = string(), | ||
| const string & | arg3 = string(), | ||
| double | arg4 = 10, | ||
| const string & | arg5 = string() ) |
Add a control to the custom component's GUI. The value it returns identifies the control, which matters for the ones that report back, such as a trigger button. What each argument means depends on type. Arguments may be left off from the end; to give a later one, pass empty strings for the string arguments before it, and 10.0 for arg4.
A control that shows a Parm (a slider, input, output, button, counter, index selector, choice or radio group) takes its label as arg1 and the Parm's name and group as arg2 and arg3; a slider takes its range as arg4. A control given no Parm is tied to one with AddUpdateGui. An index selector and a radio group show no label. A GDEV_SLIDER_ADJ_RANGE_TWO_INPUT shows the Parm arg2 in its first input and the Parm arg5, in the same group, in its second, as a Fuselage's end cap length shows its Rel and Abs values; the first drives the slider unless AddUpdateGui says otherwise. It always shows two Parms: arg2 without arg5 is an error, and the slider is not added. A GDEV_ADD_CHOICE_ITEM adds an item labelled arg1 to the last GDEV_CHOICE or GDEV_TOGGLE_RADIO_GROUP added. Its value is its place in the list, from 0, unless arg5 holds an integer, which is then the value: AddGui( GDEV_ADD_CHOICE_ITEM, "Abs", "", "", 10.0, "0" ). arg2 and arg3 are not used. An arg5 that is not an integer is an error, and the item keeps its place as its value. GDEV_TAB, GDEV_SCROLL_TAB and GDEV_DIVIDER_BOX take their title as arg1, and GDEV_SET_FORMAT a C format such as "%5.2f". GDEV_FORCE_WIDTH takes a whole number of pixels as arg1. GDEV_YGAP, GDEV_BEGIN_SAME_LINE and GDEV_END_SAME_LINE take no arguments. GDEV_ADD_X, GDEV_SET_BUTTON_WIDTH and GDEV_SET_CHOICE_BUTTON_WIDTH take a width as arg1, a sum of terms, each a number of pixels or one of the layout's widths, W, INPUT, BUTTON, CHOICE_BUTTON or RANGE_BUTTON, with an optional count and '*': "W-2*INPUT" is the line less two inputs. A line between GDEV_BEGIN_SAME_LINE and GDEV_END_SAME_LINE that moves with GDEV_ADD_X keeps its widths, where any other is stretched to fill the line.
| [in] | type | int GUI device type enum (GDEV_SLIDER, GDEV_SLIDER_ADJ_RANGE, GDEV_BUTTON and so on) |
| [in] | arg1 | string Label of most controls; title, width or format of the others |
| [in] | arg2 | string Name of the Parm a control shows |
| [in] | arg3 | string Name of the group of the Parm in arg2 |
| [in] | arg4 | double Range of a slider |
| [in] | arg5 | string Name of the Parm in a two input slider's second input, or the integer value of a choice item |
| string CustomGeomMgrSingleton::AddParm | ( | int | type, |
| const string & | name, | ||
| const string & | group ) |
Add a Parm to the custom component being built. Call this from the component's Init function; the ID that comes back is what SetParmVal and the GUI definitions refer to later.
| [in] | type | int Parm type enum (PARM_DOUBLE_TYPE, PARM_INT_TYPE, PARM_BOOL_TYPE or PARM_FRACTION_TYPE) |
| [in] | name | string Name of the Parm |
| [in] | group | string Name of the group the Parm belongs to |
| void CustomGeomMgrSingleton::AddUpdateGui | ( | int | gui_id, |
| const string & | parm_id ) |
Tie a GUI control to a Parm, so the control follows the Parm when it changes.
| [in] | gui_id | int GUI device index, as returned by AddGui |
| [in] | parm_id | string Parm ID |
| void CustomGeomMgrSingleton::AddUpdateGui | ( | int | gui_id, |
| const string & | parm_id, | ||
| const string & | parm_id2, | ||
| int | input ) |
Tie a two input slider to its two Parms, and choose the input that drives the slider, 1 or 2. The other input shows its Parm and is inactive, as a Fuselage's end cap length shows its Rel and Abs values.
| [in] | gui_id | int GUI device index, as returned by AddGui |
| [in] | parm_id | string ID of the Parm in the first input |
| [in] | parm_id2 | string ID of the Parm in the second input |
| [in] | input | int The input that drives the slider, 1 or 2 |
| string CustomGeomMgrSingleton::AddXSecSurf | ( | ) |
Add a cross section surface to the custom component. The cross sections appended to it become the skinned surface.
| string CustomGeomMgrSingleton::AppendCustomXSec | ( | const string & | xsec_surf_id, |
| int | type ) |
Add a cross section to the end of one of the component's cross section surfaces.
| [in] | xsec_surf_id | string XSecSurf ID |
| [in] | type | int XSec type enum (XS_CIRCLE, XS_ELLIPSE, XS_SUPER_ELLIPSE and so on) |
| bool CustomGeomMgrSingleton::CheckClearTriggerEvent | ( | int | gui_id | ) |
Test whether a trigger control has been pressed since the last check, and clear it. Returns true once per press, so it can drive an action from the component's Update function.
| [in] | gui_id | int GUI device index, as returned by AddGui |
| void CustomGeomMgrSingleton::ClearAllCustomDefaultSources | ( | ) |
Remove every default CFD Mesh source from the custom component.
| void CustomGeomMgrSingleton::ClearXSecSurfs | ( | ) |
Remove every cross section surface from the custom component.
| void CustomGeomMgrSingleton::CloneSurf | ( | int | index, |
| Matrix4d & | mat ) |
Copy one of the component's surfaces and place the copy by a transformation. Useful for a component made of several instances of the same shape.
| [in] | index | int Index of the surface to copy |
| [in] | mat | Matrix4d Transformation placing the copy |
| void CustomGeomMgrSingleton::CopyCustomXSec | ( | const string & | xsec_surf_id, |
| int | index ) |
Copy one of the component's cross sections to the clipboard, leaving it in place.
| [in] | xsec_surf_id | string XSecSurf ID |
| [in] | index | int Index of the cross section |
| void CustomGeomMgrSingleton::CutCustomXSec | ( | const string & | xsec_surf_id, |
| int | index ) |
Cut a cross section out of one of the component's cross section surfaces and put it on the clipboard, from where PasteCustomXSec can retrieve it.
| [in] | xsec_surf_id | string XSecSurf ID |
| [in] | index | int Index of the cross section |
|
inline |
Get the ID of the custom component currently being built. Empty when no component is being built, which is the case in an ordinary script.
Definition at line 84 of file CustomGeom.h.
| string CustomGeomMgrSingleton::GetCustomParm | ( | int | index | ) |
Get the ID of a Parm of the custom component by the order it was added in.
| [in] | index | int Index of the Parm, in the order the Parms were added |
| vec3d CustomGeomMgrSingleton::GetCustomXSecLoc | ( | const string & | xsec_id | ) |
Get the location of one of the component's cross sections.
| [in] | xsec_id | string XSec ID |
| vec3d CustomGeomMgrSingleton::GetCustomXSecRot | ( | const string & | xsec_id | ) |
Get the rotation of one of the component's cross sections.
| [in] | xsec_id | string XSec ID |
| string CustomGeomMgrSingleton::InsertCustomXSec | ( | const string & | xsec_surf_id, |
| int | type, | ||
| int | index ) |
Insert a cross section into one of the component's cross section surfaces, after a given index.
| [in] | xsec_surf_id | string XSecSurf ID |
| [in] | type | int XSec type enum (XS_CIRCLE, XS_ELLIPSE, XS_SUPER_ELLIPSE and so on) |
| [in] | index | int Index to insert after |
| void CustomGeomMgrSingleton::PasteCustomXSec | ( | const string & | xsec_surf_id, |
| int | index ) |
Paste the cross section on the clipboard over one of the component's cross sections.
| [in] | xsec_surf_id | string XSecSurf ID |
| [in] | index | int Index of the cross section to paste over |
| void CustomGeomMgrSingleton::RemoveXSecSurf | ( | const string & | id | ) |
Remove one cross section surface from the custom component.
| [in] | id | string XSecSurf ID |
| void CustomGeomMgrSingleton::SetCustomCenter | ( | double | x, |
| double | y, | ||
| double | z ) |
Set the centre of rotation of the custom component.
| [in] | x | double X coordinate of the centre |
| [in] | y | double Y coordinate of the centre |
| [in] | z | double Z coordinate of the centre |
| void CustomGeomMgrSingleton::SetCustomXSecLoc | ( | const string & | xsec_id, |
| const vec3d & | loc ) |
Move one of the component's cross sections to a location.
| [in] | xsec_id | string XSec ID |
| [in] | loc | vec3d Location to move the cross section to |
| void CustomGeomMgrSingleton::SetCustomXSecRot | ( | const string & | xsec_id, |
| const vec3d & | rot ) |
Rotate one of the component's cross sections.
| [in] | xsec_id | string XSec ID |
| [in] | rot | vec3d Rotation angles about X, Y and Z, in degrees |
| void CustomGeomMgrSingleton::SetupCustomDefaultSource | ( | int | type, |
| int | surf_index, | ||
| double | l1, | ||
| double | r1, | ||
| double | u1, | ||
| double | w1, | ||
| double | l2 = 0, | ||
| double | r2 = 0, | ||
| double | u2 = 0, | ||
| double | w2 = 0 ) |
Give the custom component a default CFD Mesh source, so a mesh of it is refined sensibly without the user having to add sources by hand.
| [in] | type | int Source type enum (POINT_SOURCE, LINE_SOURCE, BOX_SOURCE) |
| [in] | surf_index | int Index of the surface the source belongs to |
| [in] | l1 | double Source length at the first end |
| [in] | r1 | double Source radius at the first end |
| [in] | u1 | double U location of the first end |
| [in] | w1 | double W location of the first end |
| [in] | l2 | double Source length at the second end, for a line or box source |
| [in] | r2 | double Source radius at the second end, for a line or box source |
| [in] | u2 | double U location of the second end, for a line or box source |
| [in] | w2 | double W location of the second end, for a line or box source |
| void CustomGeomMgrSingleton::SetVspSurfCfdType | ( | int | type, |
| int | surf_id = -1 ) |
Set how one of the component's surfaces is treated by CFD Mesh – as a normal surface, as a transparent one, or as something to be stamped out of another.
| [in] | type | int CFD surface type enum (CFD_NORMAL, CFD_NEGATIVE, CFD_TRANSPARENT and so on) |
| [in] | surf_id | int Index of the surface, or -1 for all of them |
| void CustomGeomMgrSingleton::SetVspSurfType | ( | int | type, |
| int | surf_id = -1 ) |
Set the surface type of one of the component's surfaces, or of all of them. The type is what tells the rest of OpenVSP whether the surface is a wing, a body, or something else.
| [in] | type | int Surface type enum (NORMAL_SURF, WING_SURF, DISK_SURF, PROP_SURF) |
| [in] | surf_id | int Index of the surface, or -1 for all of them |
| void CustomGeomMgrSingleton::SkinXSecSurf | ( | bool | closed_flag | ) |
Skin a surface through the cross sections that have been appended, which is what turns them into geometry. Call this from the component's Update function.
| [in] | closed_flag | bool True to close the surface back onto the first cross section |
| void CustomGeomMgrSingleton::TransformSurf | ( | int | index, |
| Matrix4d & | mat ) |
Apply a transformation to one of the component's surfaces.
| [in] | index | int Index of the surface |
| [in] | mat | Matrix4d Transformation to apply |