LCOV - code coverage report
Current view: top level - src/gui/dialogs - GUIDialog_AppSettings.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 90 0.0 %
Date: 2024-09-16 15:39:55 Functions: 0 8 0.0 %

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
       4             : // This program and the accompanying materials are made available under the
       5             : // terms of the Eclipse Public License 2.0 which is available at
       6             : // https://www.eclipse.org/legal/epl-2.0/
       7             : // This Source Code may also be made available under the following Secondary
       8             : // Licenses when the conditions for such availability set forth in the Eclipse
       9             : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10             : // or later which is available at
      11             : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12             : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13             : /****************************************************************************/
      14             : /// @file    GUIDialog_AppSettings.cpp
      15             : /// @author  Daniel Krajzewicz
      16             : /// @author  Michael Behrisch
      17             : /// @date    Mon, 08.03.2004
      18             : ///
      19             : // The application-settings dialog
      20             : /****************************************************************************/
      21             : #include <config.h>
      22             : 
      23             : #include <utils/common/MsgHandler.h>
      24             : #include <utils/gui/images/GUIIconSubSys.h>
      25             : #include <utils/gui/images/GUITexturesHelper.h>
      26             : #include <utils/gui/windows/GUIAppEnum.h>
      27             : #include <utils/gui/div/GUIMessageWindow.h>
      28             : #include <utils/gui/div/GUIDesigns.h>
      29             : #include <gui/GUIGlobals.h>
      30             : #include "GUIDialog_AppSettings.h"
      31             : 
      32             : 
      33             : // ===========================================================================
      34             : // FOX callback mapping
      35             : // ===========================================================================
      36             : FXDEFMAP(GUIDialog_AppSettings) GUIDialog_AppSettingsMap[] = {
      37             :     FXMAPFUNC(SEL_COMMAND, MID_QUITONSIMEND,    GUIDialog_AppSettings::onCmdSelect),
      38             :     FXMAPFUNC(SEL_COMMAND, MID_AUTOSTART,       GUIDialog_AppSettings::onCmdSelect),
      39             :     FXMAPFUNC(SEL_COMMAND, MID_DEMO,            GUIDialog_AppSettings::onCmdSelect),
      40             :     FXMAPFUNC(SEL_COMMAND, MID_ALLOWTEXTURES,   GUIDialog_AppSettings::onCmdSelect),
      41             :     FXMAPFUNC(SEL_COMMAND, MID_LOCATELINKS,     GUIDialog_AppSettings::onCmdSelect),
      42             :     FXMAPFUNC(SEL_COMMAND, MID_SETTINGS_OK,     GUIDialog_AppSettings::onCmdOk),
      43             :     FXMAPFUNC(SEL_COMMAND, MID_SETTINGS_CANCEL, GUIDialog_AppSettings::onCmdCancel),
      44             : };
      45             : 
      46           0 : FXIMPLEMENT(GUIDialog_AppSettings, FXDialogBox, GUIDialog_AppSettingsMap, ARRAYNUMBER(GUIDialog_AppSettingsMap))
      47             : 
      48             : 
      49             : // ===========================================================================
      50             : // method definitions
      51             : // ===========================================================================
      52           0 : GUIDialog_AppSettings::GUIDialog_AppSettings(GUIMainWindow* parent)
      53           0 :     : FXDialogBox(parent, TL("Application Settings")),
      54           0 :       myParent(parent),
      55           0 :       myAppQuitOnEnd(GUIGlobals::gQuitOnEnd),
      56           0 :       myAppAutoStart(GUIGlobals::gRunAfterLoad),
      57           0 :       myAppDemo(GUIGlobals::gDemoAutoReload),
      58           0 :       myAllowTextures(GUITexturesHelper::texturesAllowed()),
      59           0 :       myLocateLinks(GUIMessageWindow::locateLinksEnabled()) {
      60             :     FXCheckButton* b = nullptr;
      61           0 :     FXVerticalFrame* f1 = new FXVerticalFrame(this, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0);
      62           0 :     b = new FXCheckButton(f1, TL("Quit on Simulation End"), this, MID_QUITONSIMEND);
      63           0 :     b->setCheck(myAppQuitOnEnd);
      64           0 :     b = new FXCheckButton(f1, TL("Autostart Simulation on Load and Reload"), this, MID_AUTOSTART);
      65           0 :     b->setCheck(myAppAutoStart);
      66           0 :     b = new FXCheckButton(f1, TL("Reload Simulation after finish (Demo mode)"), this, MID_DEMO);
      67           0 :     b->setCheck(myAppDemo);
      68           0 :     b = new FXCheckButton(f1, TL("Locate elements when clicking on messages"), this, MID_LOCATELINKS);
      69           0 :     b->setCheck(myLocateLinks);
      70             : 
      71           0 :     FXMatrix* m1 = new FXMatrix(f1, 2, (LAYOUT_FILL_X | LAYOUT_LEFT | MATRIX_BY_COLUMNS), 0, 0, 0, 0, 10, 10, 10, 10, 5, 5);
      72           0 :     myBreakPointOffset = new FXRealSpinner(m1, 5, this, MID_TIMELINK_BREAKPOINT, GUIDesignViewSettingsSpinDial2 | SPIN_NOMIN);
      73           0 :     myBreakPointOffset->setValue(STEPS2TIME(GUIMessageWindow::getBreakPointOffset()));
      74           0 :     new FXLabel(m1, TL("Breakpoint offset when clicking on time message"), nullptr, GUIDesignViewSettingsLabel1);
      75           0 :     myTable = new FXTable(f1, this, MID_TABLE, GUIDesignBreakpointTable);
      76             :     const auto& onlineMaps = parent->getOnlineMaps();
      77           0 :     const int numRows = (int)onlineMaps.size() + 1;
      78           0 :     myTable->setVisibleRows(numRows);
      79           0 :     myTable->setVisibleColumns(2);
      80           0 :     myTable->setTableSize(numRows, 2);
      81           0 :     myTable->setBackColor(FXRGB(255, 255, 255));
      82           0 :     myTable->getRowHeader()->setWidth(0);
      83           0 :     myTable->setTableSize(numRows, 2);
      84           0 :     myTable->setColumnText(0, "Name");
      85           0 :     myTable->setColumnText(1, "URL");
      86           0 :     FXHeader* header = myTable->getColumnHeader();
      87           0 :     header->setHeight(GUIDesignHeight);
      88           0 :     header->setItemSize(0, 60);
      89           0 :     header->setItemSize(1, 275);
      90             :     int row = 0;
      91           0 :     for (const auto& item : onlineMaps) {
      92           0 :         myTable->setItemText(row, 0, item.first.c_str());
      93           0 :         myTable->setItemText(row, 1, item.second.c_str());
      94           0 :         row++;
      95             :     }
      96             : 
      97           0 :     new FXHorizontalSeparator(f1, SEPARATOR_GROOVE | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X);
      98           0 :     b = new FXCheckButton(f1, TL("Allow Textures"), this, MID_ALLOWTEXTURES);
      99           0 :     b->setCheck(myAllowTextures);
     100           0 :     FXHorizontalFrame* f2 = new FXHorizontalFrame(f1, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 10, 10, 5, 5);
     101           0 :     FXButton* initial = GUIDesigns::buildFXButton(f2, TL("&OK"), "", "", nullptr, this, MID_SETTINGS_OK, BUTTON_INITIAL | BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X, 0, 0, 0, 0, 30, 30, 4, 4);
     102           0 :     GUIDesigns::buildFXButton(f2, TL("&Cancel"), "", "", nullptr, this, MID_SETTINGS_CANCEL, BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X, 0, 0, 0, 0, 30, 30, 4, 4);
     103           0 :     initial->setFocus();
     104           0 :     setIcon(GUIIconSubSys::getIcon(GUIIcon::EMPTY));
     105           0 : }
     106             : 
     107             : 
     108           0 : GUIDialog_AppSettings::~GUIDialog_AppSettings() {}
     109             : 
     110             : 
     111             : long
     112           0 : GUIDialog_AppSettings::onCmdOk(FXObject*, FXSelector, void*) {
     113           0 :     GUIGlobals::gQuitOnEnd = myAppQuitOnEnd;
     114           0 :     GUIGlobals::gRunAfterLoad = myAppAutoStart;
     115           0 :     GUIGlobals::gDemoAutoReload = myAppDemo;
     116           0 :     GUIGlobals::gRunAfterLoad = myAppAutoStart;
     117           0 :     GUITexturesHelper::allowTextures(myAllowTextures);
     118           0 :     GUIMessageWindow::enableLocateLinks(myLocateLinks);
     119           0 :     GUIMessageWindow::setBreakPointOffset(TIME2STEPS(myBreakPointOffset->getValue()));
     120           0 :     FXString maps;
     121           0 :     for (int r = 0; r < myTable->getNumRows(); r++) {
     122           0 :         if (myTable->getItem(r, 0) != nullptr && myTable->getItem(r, 1) != nullptr) {
     123           0 :             myParent->addOnlineMap(myTable->getItem(r, 0)->getText().text(), myTable->getItem(r, 1)->getText().text());
     124           0 :             if (!maps.empty()) {
     125           0 :                 maps += "\n";
     126             :             }
     127           0 :             maps += myTable->getItem(r, 0)->getText() + "\t" + myTable->getItem(r, 1)->getText();
     128             :         }
     129             :     }
     130           0 :     getApp()->reg().writeStringEntry("gui", "onlineMaps", maps.text());
     131           0 :     destroy();
     132           0 :     return 1;
     133           0 : }
     134             : 
     135             : 
     136             : long
     137           0 : GUIDialog_AppSettings::onCmdCancel(FXObject*, FXSelector, void*) {
     138           0 :     destroy();
     139           0 :     return 1;
     140             : }
     141             : 
     142             : long
     143           0 : GUIDialog_AppSettings::onCmdSelect(FXObject*, FXSelector sel, void*) {
     144           0 :     switch (FXSELID(sel)) {
     145           0 :         case MID_QUITONSIMEND:
     146           0 :             myAppQuitOnEnd = !myAppQuitOnEnd;
     147           0 :             break;
     148           0 :         case MID_AUTOSTART:
     149           0 :             myAppAutoStart = !myAppAutoStart;
     150           0 :             break;
     151           0 :         case MID_DEMO:
     152           0 :             myAppDemo = !myAppDemo;
     153           0 :             break;
     154           0 :         case MID_LOCATELINKS:
     155           0 :             myLocateLinks = !myLocateLinks;
     156           0 :             break;
     157           0 :         case MID_ALLOWTEXTURES:
     158           0 :             myAllowTextures = !myAllowTextures;
     159           0 :             break;
     160             :     }
     161           0 :     return 1;
     162             : }
     163             : 
     164             : 
     165             : /****************************************************************************/

Generated by: LCOV version 1.14