This functions grouped here are used to create and manipulate Custom Components. Custom components are defined in \*.vsppart files included in the /"Custom Scripts/" directory. Examples of Custom Components are available in the directory for reference. OpenVSP looks in 3 locations for the /"Custom Scripts/" folder, where Custom Components are loaded: the root directory, the VSP executable directory, and the home directory. 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 |
| 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 &label=string(), const string &parm_name=string(), const string &group_name=string(), double range=10) |
| vector< GuiDef > | GetGuiDefVec (const string &geom_id) |
| void | AddUpdateGui (int gui_id, const string &parm_id) |
| 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 579 of file CustomGeom.h.
|
private |
Definition at line 580 of file CustomGeom.h.
|
private |
Definition at line 581 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 601 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 611 of file CustomGeom.h.
|
inlinevirtual |
Definition at line 613 of file CustomGeom.h.
|
protected |
Definition at line 619 of file CustomGeom.h.
|
protected |
Definition at line 620 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 639 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 689 of file CustomGeom.h.
|
inline |
Definition at line 650 of file CustomGeom.h.
|
inline |
Definition at line 658 of file CustomGeom.h.
|
inlinevirtual |
Definition at line 670 of file CustomGeom.h.
|
inline |
Definition at line 648 of file CustomGeom.h.
|
inline |
Definition at line 649 of file CustomGeom.h.
|
inline |
Definition at line 647 of file CustomGeom.h.
|
inlinevirtual |
Definition at line 688 of file CustomGeom.h.
|
protected |
Definition at line 721 of file CustomGeom.h.
|
protected |
Definition at line 722 of file CustomGeom.h.
|
protected |
Definition at line 703 of file CustomGeom.h.
|
protected |
Definition at line 708 of file CustomGeom.h.
|
protected |
Definition at line 701 of file CustomGeom.h.
|
protected |
Definition at line 704 of file CustomGeom.h.
|
protected |
Definition at line 699 of file CustomGeom.h.
|
protected |
Definition at line 700 of file CustomGeom.h.
|
protected |
Definition at line 707 of file CustomGeom.h.
|
protected |
Definition at line 705 of file CustomGeom.h.
|
protected |
Definition at line 712 of file CustomGeom.h.
|
protected |
Definition at line 713 of file CustomGeom.h.
|
protected |
Definition at line 710 of file CustomGeom.h.
|
protected |
Definition at line 711 of file CustomGeom.h.
|
protected |
Definition at line 706 of file CustomGeom.h.
| int CustomGeomMgrSingleton::AddGui | ( | int | type, |
| const string & | label = string(), | ||
| const string & | parm_name = string(), | ||
| const string & | group_name = string(), | ||
| double | range = 10 ) |
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.
| [in] | type | int GUI device type enum (GDEV_SLIDER, GDEV_SLIDER_ADJ_RANGE, GDEV_BUTTON and so on) |
| [in] | label | string Label shown next to the control |
| [in] | parm_name | string Name of the Parm the control drives |
| [in] | group_name | string Name of the group the Parm belongs to |
| [in] | range | double Range of the slider |
| 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 |
| 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 |