|
JMEditorEnvironment
|
#include <SimEnvironment.h>
Public Member Functions | |
| SimEnvironment (SimEnvironment &)=delete | |
| SimEnvironment & | operator= (const SimEnvironment &)=delete |
| SimEnvironment (SimEnvironment &&)=default | |
| SimEnvironment & | operator= (SimEnvironment &&)=default |
| void | setupViewer (JMwindow *Window, float PosX, float PosY, float SizeX, float SizeY) |
| Sets up a 3d environment that renders the objects and allows the user to manipulate them. | |
| void | setupViewer_toGuides (JMwindow *Window, unsigned int x1, unsigned int x2, unsigned int y1, unsigned int y2) |
| Sets up a 3d environment that renders the objects and allows the user to manipulate them. Allignes to pre-existing gui guides. | |
| void | displayViewer () |
| void | setupPropertiesMenu (JMwindow *Window, float PosX, float PosY, float SizeX, float SizeY) |
| Sets up a tabbed menu that displays object properties. Set the "setupNoObjSelectedMenu" function for a custom menu. | |
| void | setupPropertiesMenu_toGuides (JMwindow *Window, unsigned int x1, unsigned int x2, unsigned int y1, unsigned int y2) |
| Sets up a tabbed menu that displays object properties. Allignes to pre-existing gui guides. Set the "setupNoObjSelectedMenu" function for a custom menu. | |
| void | displayPropertiesMenu () |
| void | setupSelector (JMwindow *Window, float PosX, float PosY, float SizeX, float SizeY) |
| Sets up a list menu that displays all existing objects and allows the user to select them. | |
| void | setupSelector_toGuides (JMwindow *Window, unsigned int x1, unsigned int x2, unsigned int y1, unsigned int y2) |
| Sets up a list menu that displays all existing objects and allows the user to select them. Allignes to pre-existing gui guides. | |
| void | displaySelector () |
| void | setupObjectDataWindow (JMwindow *Window, float posX, float posY, float sizeX, float sizeY) |
| Sets up a window to display object data. | |
| void | setupObjectDataWindow_toGuides (JMwindow *Window, unsigned int x1, unsigned int x2, unsigned int y1, unsigned int y2) |
| Sets up a window to display object data. Allignes to pre-existing gui guides. | |
| void | displayObjectDataWindow () |
| void | displayInfoBar (JMwindow *window) |
| Displays an info bar at the bottom of the screen containing basic info about the environment. Width is determined by the position of the first Y guide. | |
| void | addObject (SimObject *obj) |
| Add a new SimObject to the SimEnvironment. | |
| void | deleteObject (SimObject *obj) |
| Deletes the object if its contained in the SimEnvironment. | |
| void | focusViewerOnObject (SimObject *obj) |
| Moves the object viewers camera to the input object if the viewer is setup. | |
| void | selectObject (SimObject *obj) |
| Selects an object. If an object is already selected, the object will be second-selected. | |
| void | selectObject (std::string name) |
| Selects an object by name. If an object is already selected, the object will be second-selected. | |
| void | deselectObject (SimObject *obj) |
| Deselects an object. | |
| void | deselectObject (std::string name) |
| Deselects an object. | |
| void | deselectAll () |
| Deselects all objects. | |
| void | deleteAll () |
| Deletes all the objects. | |
| void | freezeObjects () |
| Disables selection and modification of objects. If objects are selected, they remain selected. | |
| void | unfreezeObjects () |
| Re-enables selection and modification of objects. | |
| bool | objectsFrozen () const |
| Returns true if objects are frozen. | |
| std::string | setObjectName (SimObject *obj, std::string newName) |
| Sets the name for a specific object. Returns the new name, as it might be modified if its a duplicate. | |
| SimObject * | selectedObject () const |
| Returns a pointer to the primary selection. | |
| std::vector< SimObject * > | selectedObjects () const |
| Returns an std::vector of pointers to all of the objects that are second-selected. | |
| std::vector< SimObject * > | selectedObjects (std::string category) const |
| Returns an std::vector of pointers to all of the objects that are second-selected, and who's ObjectCategory string matches the input. | |
| std::vector< SimObject * > | allInCategory (std::string category) const |
| Returns an std::vector of pointers to all of the objects whos ObjectCatagory string matches the input. | |
| std::vector< SimObject * > | copyObjects () const |
| Returns an std::vector of pointers to copies of all of the objects. Note: These copies will not be managed by the sim environment, and must all be deleted to avoid memory leaks. | |
| void | displayGui () |
| Displays all the gui elements that have been set up. | |
| void | renderObjects (JMGraphics *gr) |
| void | addUndoStep () |
| void | undo () |
| void | redo () |
| void | addGuideX (float startPos, float min, float max, JMwindow *window) |
| Adds a gui guide on the x axis. Parameters are in percentage of window width. | |
| void | addGuideX (float startPos, float min, float max, JMwindow *window, unsigned int handleGrabMin, unsigned int handleGrabMax) |
| Adds a gui guide on the x axis. Parameters are in percentage of window width. HandleMin and handleMax are indices of Y guides to limit where this guide can be clicked. | |
| void | addGuideY (float startPos, float min, float max, JMwindow *window) |
| Adds a gui guide on the y axis. Parameters are in percentage of window height. | |
| void | addGuideY (float startPos, float min, float max, JMwindow *window, unsigned int handleGrabMin, unsigned int handleGrabMax) |
| Adds a gui guide on the x axis. Parameters are in percentage of window width. HandleMin and handleMax are indices of X guides to limit where this guide can be clicked. | |
| void | allignToGuides (GuiElementHandler *menu, unsigned int x1, unsigned int x2, unsigned int y1, unsigned int y2) |
| Alligns a gui element handler between two guide lines. Must add guide lines with addGuideX and addGuideY first. | |
| void | allignToGuides (TabbedMenu *menu, unsigned int x1, unsigned int x2, unsigned int y1, unsigned int y2) |
| Alligns a tabbed menu between two guide lines. Must add guide lines with addGuideX and addGuideY first. | |
| void | allignToGuides (ObjectViewer *viewer, unsigned int x1, unsigned int x2, unsigned int y1, unsigned int y2) |
| Alligns a viewer between two guide lines. Must add guide lines with addGuideX and addGuideY first. | |
| bool | saveEnvironment (std::ostream &stream) const |
| Writes the environment and all object to the stream. | |
| bool | loadEnvironment (std::istream &stream) |
| Loads an environment and all objects from a stream. | |
| bool | saveEnvironment (JMwindow *window) |
| Saves the environment to the projectFilePath directory if it isn't empty, or opens a file explorer window if it is. | |
| bool | loadEnvironment (JMwindow *window) |
| Loads the environment from a user selected file. Returns false if the file is invalid/doesn't have the correct extension. | |
| void | setInfoBarMessage (std::string message) |
| bool | saveEnvironmentAs (JMwindow *window) |
| Cleares stored file path and opens a save file dialog. | |
| void | recoverBackup () |
| Loads the backup save file if it exists. | |
| void | saveBackup () |
| Saves a backup file. | |
| void | registerDerivedSimObject (const std::string &objectType, std::function< SimObject *()> constructor) |
| SimResourceManager * | getManager () |
| Returns a pointer to the global resource manager for all SimEnvironments. | |
| glm::dvec3 | extractAngles (glm::dmat4 mat) |
| Returns the Euler angles of rotation from a matrix. | |
Public Attributes | |
| float | guideMargin = 5.0f |
| int | undoSteps = 64 |
| The maximum number of undo steps to store. | |
| int | redoSteps = 16 |
| The maximum number of redo steps to store. | |
| int | simThreadNum = 10 |
| The maximum number of threads to use when simulating. | |
| bool | selectInViewer = true |
| If true, objects can be selected in the viewer by clicking on them. | |
| bool | deselectOnClick = true |
| If true, clicking in empty space in the viewer will deselect all objects. | |
| bool | selectedBox = true |
| If true, a box will be rendered around selected objects in the viewer. | |
| double | distanceScale = 0.01 |
| All distance calculations should be scaled by this. 1.0 = meters. | |
| double | fluxDensityScale = 1.0 |
| All magnetic flux density calculations should be scaled by this. 1.0 = Tesla. | |
| std::string | EnvironmentName = "Simulator" |
| The name of the current project. | |
| std::vector< SimObject * > | allObjects |
| std::function< GuiElementHandler *(TabbedMenu *, SimEnvironment *)> | setupNoObjSelectedMenu = nullptr |
| The function used to setup the menu that is displayed in the properties menu when no object is selected. | |
| GuiElementHandler * | noObjSelectedMenu = nullptr |
| The menu that is displayed in the object properties menu when no object is selected. | |
| TabbedMenu * | propertiesMenu = nullptr |
| GuiElementHandler * | selector = nullptr |
| ListMenu * | selectorList = nullptr |
| ObjectViewer * | viewer = nullptr |
| GuiElementHandler * | objectDataBackground = nullptr |
Contains and manages SimObject instances and the gui elements used to interact with them.
Each gui section needs to be set up if it will be used. They can either be set up at fixed pixel coordinates, or alligned to GuiGuides (recomended), allowing the user to re size them. If guides are used, they must be added first using addGuideX and addGuidY functions, then selected in the _toGuides versions of the setup functions by index.
The gui sections are:\nViewer. A 3D environment that is rendered in a seperate thread where SimObjects can be viewed and interacted with.
PropertiesMenu. A menu where the user can adjust the selected SimObjects properties. By default, a general settings menu for each SimObject exists but SimObject derived classes can more custom properties menus.
Selector. A ListMenu that displays all of the SimObjects in the environment. SimObjects can be selected here as well as the viewer.
ObjectDataWindow. SimObject has setupDataWindow and displayDataWindow virtual functions that can be overriden in derived classes to display custom data here.
| void SimEnvironment::registerDerivedSimObject | ( | const std::string & | objectType, |
| std::function< SimObject *()> | constructor ) |
Adds a derived simObject classes constructor to the internal factory map. Must register all derived classes for saving and loading from a file to work. The first parameter is whatever the derived class sets its ObjectType string to in its constructor. The second parameter must be a function or lambda that returns the new object instace. For example: []() { return new DerivedClass(); }
| std::vector<SimObject*> SimEnvironment::allObjects |
All of the objects currently in the sim environment. DO NOT add to or remove from this directly. This may cause dangling pointers. Use addObject and deleteObject functions.