LCOV - code coverage report
Current view: top level - src/utils/gui/div - GUIMessageWindow.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 0.0 % 15 0
Test Date: 2024-11-20 15:55:46 Functions: 0.0 % 6 0

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2003-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    GUIMessageWindow.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @date    Tue, 25 Nov 2003
      18              : ///
      19              : // A logging window for the gui
      20              : /****************************************************************************/
      21              : #pragma once
      22              : #include <config.h>
      23              : 
      24              : #include <string>
      25              : #include <utils/foxtools/fxheader.h>
      26              : #include <utils/gui/events/GUIEvent.h>
      27              : #include <utils/gui/windows/GUIMainWindow.h>
      28              : #include <utils/iodevices/OutputDevice.h>
      29              : 
      30              : 
      31              : // ===========================================================================
      32              : // class declarations
      33              : // ===========================================================================
      34              : class GUIGlObject;
      35              : 
      36              : 
      37              : // ===========================================================================
      38              : // class definitions
      39              : // ===========================================================================
      40              : /**
      41              :  * @class GUIMessageWindow
      42              :  * @brief A logging window for the gui
      43              :  *
      44              :  * This class displays messages incoming to the gui from either the load or
      45              :  *  the run thread.
      46              :  *
      47              :  * The text is colored in dependence to its type (messages: green, warnings: yellow,
      48              :  *  errors: red)
      49              :  *
      50              :  * Each time a new message is passed, the window is reopened.
      51              :  */
      52              : class GUIMessageWindow : public FXText {
      53            0 :     FXDECLARE(GUIMessageWindow)
      54              : public:
      55              :     /** @brief Constructor
      56              :      *
      57              :      * @param[in] parent The parent window
      58              :      */
      59              :     GUIMessageWindow(FXComposite* parent, GUIMainWindow* mainWindow);
      60              : 
      61              :     /// @brief Destructor
      62              :     ~GUIMessageWindow();
      63              : 
      64              :     /// @brief set cursor position over a certain line
      65              :     virtual void setCursorPos(FXint pos, FXbool notify = FALSE);
      66              : 
      67              :     /** @brief Adds new text to the window
      68              :      *
      69              :      * The type of the text is determined by the first parameter
      70              :      *
      71              :      * @param[in] eType The type of the event the message was generated by
      72              :      * @param[in] msg The message
      73              :      * @see GUIEventType
      74              :      */
      75              :     void appendMsg(GUIEventType eType, const std::string& msg);
      76              : 
      77              :     /// @brief Adds a a separator to this log window
      78              :     void addSeparator();
      79              : 
      80              :     /// @brief Clears the window
      81              :     void clear();
      82              : 
      83              :     /// @brief register message handlers
      84              :     void registerMsgHandlers();
      85              : 
      86              :     /// @brief unregister message handlers
      87              :     void unregisterMsgHandlers();
      88              : 
      89              :     /// @brief switch locate links on and off
      90              :     static void enableLocateLinks(const bool val) {
      91            0 :         myLocateLinks = val;
      92              :     }
      93              : 
      94              :     /// @brief ask whether locate links is enabled
      95              :     static bool locateLinksEnabled() {
      96            0 :         return myLocateLinks;
      97              :     }
      98              : 
      99              :     /// @brief switch locate links on and off
     100              :     static void setBreakPointOffset(SUMOTime val) {
     101            0 :         myBreakPointOffset = val;
     102              :     }
     103              : 
     104              :     /// @brief ask whether locate links is enabled
     105              :     static SUMOTime getBreakPointOffset() {
     106            0 :         return myBreakPointOffset;
     107              :     }
     108              : 
     109              :     /// @brief handle keys
     110              :     long onKeyPress(FXObject* o, FXSelector sel, void* data);
     111              : 
     112              :     /// @brief The text colors used
     113              :     static FXHiliteStyle* getStyles();
     114              : 
     115              : protected:
     116              :     /// @brief FOX needs this
     117              :     FOX_CONSTRUCTOR(GUIMessageWindow)
     118              : 
     119              : private:
     120              :     /// @brief class MsgOutputDevice
     121              :     class MsgOutputDevice : public OutputDevice {
     122              : 
     123              :     public:
     124              :         /// @brief constructor
     125            0 :         MsgOutputDevice(GUIMessageWindow* msgWindow, GUIEventType type) :
     126            0 :             myMsgWindow(msgWindow),
     127            0 :             myType(type) { }
     128              : 
     129              :         /// @brief destructor
     130            0 :         ~MsgOutputDevice() { }
     131              : 
     132              :     protected:
     133              :         /// @brief get Output Stream
     134            0 :         std::ostream& getOStream() {
     135            0 :             return myStream;
     136              :         }
     137              :         /// @brief write hook
     138            0 :         void postWriteHook() {
     139            0 :             myMsgWindow->appendMsg(myType, myStream.str());
     140            0 :             myStream.str("");
     141            0 :         }
     142              : 
     143              :     private:
     144              :         /// @brief pointer to message Windows
     145              :         GUIMessageWindow* myMsgWindow;
     146              : 
     147              :         /// @brief output string stream
     148              :         std::ostringstream myStream;
     149              : 
     150              :         /// @brief type of event
     151              :         GUIEventType myType;
     152              :     };
     153              : 
     154              :     /// @brief get active string object
     155              :     const GUIGlObject* getActiveStringObject(const FXString& text, const FXint pos, const FXint lineS, const FXint lineE) const;
     156              : 
     157              :     /// @brief get time string object
     158              :     SUMOTime getTimeString(const FXString& text, const FXint pos) const;
     159              : 
     160              :     /// @brief fill styles
     161              :     void fillStyles();
     162              : 
     163              :     /// @brief main window
     164              :     GUIMainWindow* myMainWindow;
     165              : 
     166              :     /// @brief whether messages are linked to the GUI elements
     167              :     static bool myLocateLinks;
     168              : 
     169              :     /// @brief Offset when creating breakpoint by clicking on time links
     170              :     static SUMOTime myBreakPointOffset;
     171              : 
     172              :     /// @brief The text colors used
     173              :     static FXHiliteStyle* myStyles;
     174              : 
     175              :     /// @brief The time text to look for
     176              :     static std::string myTimeText;
     177              : 
     178              :     /// @brief The translated type strings text to look for
     179              :     static std::map<std::string, std::string> myTypeStrings;
     180              : 
     181              :     /// @brief The instances of message retriever encapsulations
     182              :     OutputDevice* myErrorRetriever, *myDebugRetriever, *myGLDebugRetriever, *myMessageRetriever, *myWarningRetriever;
     183              : };
        

Generated by: LCOV version 2.0-1