10#include <simgear/compiler.h>
15#include <simgear/sg_inlines.h>
16#include <simgear/debug/logstream.hxx>
17#include <simgear/math/sg_random.hxx>
18#include <simgear/io/iostreams/sgstream.hxx>
19#include <simgear/scene/material/mat.hxx>
20#include <simgear/scene/material/matlib.hxx>
21#include <simgear/structure/exception.hxx>
22#include <simgear/structure/commands.hxx>
23#include <simgear/props/props.hxx>
24#include <simgear/props/props_io.hxx>
25#include <simgear/structure/event_mgr.hxx>
26#include <simgear/sound/soundmgr.hxx>
27#include <simgear/timing/sg_time.hxx>
58# include <google/profiler.h>
76do_exit (
const SGPropertyNode * arg, SGPropertyNode * root)
78 SG_LOG(SG_INPUT, SG_INFO,
"Program exit requested.");
81 fgOSExit(arg->getIntValue(
"status", 0));
90do_reset (
const SGPropertyNode * arg, SGPropertyNode * root)
103 fgSetString(
"/sim/aircraft", arg->getStringValue(
"aircraft"));
115 fgGetNode(
"/sim")->removeChild(
"aircraft-dir");
141 std::string panel_path = arg->getStringValue(
"path");
142 if (!panel_path.empty()) {
144 fgSetString(
"/sim/panel/path", panel_path.c_str());
163 SG_LOG(SG_GENERAL, SG_ALERT,
"preferences-load command is deprecated and non-functional");
190 simgear::reload_shaders();
206 double lon_deg =
fgGetDouble(
"/position/longitude-deg");
207 double lat_deg =
fgGetDouble(
"/position/latitude-deg");
208 SGGeod geodPos = SGGeod::fromDegFt(lon_deg, lat_deg, 0.0);
209 SGVec3d zero = SGVec3d::fromGeod(geodPos);
211 SG_LOG(SG_INPUT, SG_INFO,
"Model parameters:");
212 SG_LOG(SG_INPUT, SG_INFO,
"Center: " << zero.x() <<
", " << zero.y() <<
", " << zero.z() );
213 SG_LOG(SG_INPUT, SG_INFO,
"Rotation: " << lat_deg <<
", " << lon_deg );
241 SGPropertyNode *master_freeze =
fgGetNode(
"/sim/freeze/master");
242 bool freeze = master_freeze->getBoolValue();
243 SG_LOG(SG_INPUT, SG_INFO,
"ReIniting TileCache");
245 master_freeze->setBoolValue(
true);
251 master_freeze->setBoolValue(
false);
262 SG_LOG(SG_INPUT, SG_INFO,
"Reloading Materials");
263 SGMaterialLib* new_matlib =
new SGMaterialLib;
264 SGPath mpath(
globals->get_fg_root() );
265 mpath.append(
fgGetString(
"/sim/rendering/materials-file") );
266 bool loaded = new_matlib->load(
globals->get_fg_root(),
271 SG_LOG( SG_GENERAL, SG_ALERT,
272 "Error loading materials file " << mpath );
276 globals->set_matlib(new_matlib);
318 gui->
showDialog(arg->getStringValue(
"dialog-name"));
343 if(arg->hasValue(
"dialog-name"))
344 return gui->
closeDialog(arg->getStringValue(
"dialog-name"));
345 return gui->closeActiveDialog();
359 if (arg->hasValue(
"dialog-name"))
360 dialog = gui->getDialog(arg->getStringValue(
"dialog-name"));
362 dialog = gui->getActiveDialog();
365 dialog->updateValues(arg->getStringValue(
"object-name"));
376 if (arg->hasValue(
"path"))
377 path = arg->getStringValue(
"path");
379 if (arg->hasValue(
"url"))
380 path = arg->getStringValue(
"url");
412 if (arg->hasValue(
"dialog-name"))
413 dialog = gui->getDialog(arg->getStringValue(
"dialog-name"));
415 dialog = gui->getActiveDialog();
418 dialog->applyValues(arg->getStringValue(
"object-name"));
446 SGPropertyNode * model =
fgGetNode(
"models",
true);
448 for (
i = 0; model->hasChild(
"model",
i);
i++);
449 model = model->getChild(
"model",
i,
true);
450 copyProperties(arg, model);
451 if (model->hasValue(
"elevation-m"))
452 model->setDoubleValue(
"elevation-ft", model->getDoubleValue(
"elevation-m")
454 model->getNode(
"load",
true);
455 model->removeChildren(
"load");
456 const_cast<SGPropertyNode *
>(arg)->setStringValue(
"property", model->getPath());
466 if (
fgGetBool(
"/sim/initialized",
false)) {
481 const std::string prefix = arg->getStringValue(
"prefix");
483 if (arg->getBoolValue(
"guarded") &&
fgGetDouble((prefix +
"-guard").c_str()) < 1)
486 std::string prop = prefix +
"-button";
489 if (arg->getBoolValue(
"latching"))
495 fgSetBool(arg->getStringValue(
"discrete"), value > 0);
503 const std::string prefix = arg->getStringValue(
"prefix");
505 if (arg->getBoolValue(
"guarded")) {
506 std::string prop = prefix +
"-guard";
513 if (! arg->getBoolValue(
"latching")) {
515 fgSetBool(arg->getStringValue(
"discrete"),
false);
576 SG_LOG(SG_GENERAL, SG_BULK,
"Initializing scene built-in commands:");
An XML-configured dialog box.
void materialLibChanged()
XML-configured GUI subsystem.
virtual bool closeDialog(const std::string &name)
Close a named dialog, if it is open.
virtual bool showDialog(const std::string &name)
Display a dialog box.
virtual bool toggleDialog(const std::string &name)
Toggle display of a dialog box.
virtual void redraw()
Redraw the GUI picking up new GUI colors.
virtual void newDialog(SGPropertyNode *node)
Creates a new dialog box, using the same property format as the gui/dialogs configuration files.
static CameraGroup * getDefault()
Get the default CameraGroup.
static struct @067026177365276227015073311113211264353134373250 built_ins[]
Table of built-in commands.
SGCommandMgr::command_t command
std::string fgGetString(const char *name, const char *defaultValue)
Get a string value for a property.
static bool do_open_launcher(const SGPropertyNode *, SGPropertyNode *)
static bool do_preferences_load(const SGPropertyNode *arg, SGPropertyNode *root)
Built-in command: (re)load preferences.
static bool do_press_cockpit_button(const SGPropertyNode *arg, SGPropertyNode *root)
static bool do_reset(const SGPropertyNode *arg, SGPropertyNode *root)
Reset FlightGear (Shift-Escape or Menu->File->Reset)
static bool do_toggle_fullscreen(const SGPropertyNode *, SGPropertyNode *)
An fgcommand to toggle fullscreen mode.
static bool do_print_visible_scene_info(const SGPropertyNode *, SGPropertyNode *)
void fgInitSceneCommands()
Initialize the default built-in commands.
static bool do_switch_aircraft(const SGPropertyNode *arg, SGPropertyNode *root)
Change aircraft.
static bool do_panel_load(const SGPropertyNode *arg, SGPropertyNode *root)
Built-in command: (re)load the panel.
static bool do_tile_cache_reload(const SGPropertyNode *arg, SGPropertyNode *root)
Reload the tile cache.
static bool do_reposition(const SGPropertyNode *arg, SGPropertyNode *root)
static bool do_dialog_toggle(const SGPropertyNode *arg, SGPropertyNode *root)
Built-in command: Show an XML-configured dialog.
static bool do_open_browser(const SGPropertyNode *arg, SGPropertyNode *root)
static bool do_dialog_show(const SGPropertyNode *arg, SGPropertyNode *root)
Built-in command: Show an XML-configured dialog.
static bool do_exit(const SGPropertyNode *arg, SGPropertyNode *root)
Built-in command: exit FlightGear.
static bool do_dialog_update(const SGPropertyNode *arg, SGPropertyNode *root)
Update a value in the active XML-configured dialog.
static bool do_dialog_new(const SGPropertyNode *arg, SGPropertyNode *root)
Built-in command: Add a dialog to the GUI system.
static bool do_materials_reload(const SGPropertyNode *arg, SGPropertyNode *root)
Reload the materials definition.
static bool do_dialog_close(const SGPropertyNode *arg, SGPropertyNode *root)
Built-in Command: Hide the active XML-configured dialog.
static bool do_dump_terrain_branch(const SGPropertyNode *, SGPropertyNode *)
static bool do_release_cockpit_button(const SGPropertyNode *arg, SGPropertyNode *root)
static bool do_dialog_apply(const SGPropertyNode *arg, SGPropertyNode *root)
Apply a value in the active XML-configured dialog.
static bool do_dump_scene_graph(const SGPropertyNode *, SGPropertyNode *)
static bool do_presets_commit(const SGPropertyNode *arg, SGPropertyNode *root)
Built-in command: commit presets (read from in /sim/presets/)
static bool do_add_model(const SGPropertyNode *arg, SGPropertyNode *root)
Adds model to the scenery.
static bool do_reload_shaders(const SGPropertyNode *, SGPropertyNode *)
static bool do_screen_capture(const SGPropertyNode *, SGPropertyNode *)
Built-in command: capture screen.
static bool do_reload_compositor(const SGPropertyNode *, SGPropertyNode *)
Reload all Compositor instances in the default CameraGroup.
static bool do_gui_redraw(const SGPropertyNode *arg, SGPropertyNode *root)
Redraw GUI (applying new widget colors).
void fgDumpTerrainBranch()
void fgPrintVisibleSceneInfoCommand()
bool openBrowser(const std::string &address)
bool runInAppLauncherDialog()
void reloadCompositors(CameraGroup *cgroup)
Force a reload of all Compositor instances in the CameraGroup, except the one used by the GUI camera.
bool fgSetDouble(const char *name, double defaultValue)
Set a double value for a property.
bool fgGetBool(char const *name, bool def)
Get a bool value for a property.
bool fgSetBool(char const *name, bool val)
Set a bool value for a property.
double fgGetDouble(const char *name, double defaultValue)
Get a double value for a property.
bool fgSetString(char const *name, char const *str)
Set a string value for a property.
SGPropertyNode * fgGetNode(const char *path, bool create)
Get a property node.