JeVois  1.20
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
GUIconsole.H
Go to the documentation of this file.
1 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2020 by Laurent Itti, the University of Southern
4 // California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5 //
6 // This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7 // redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8 // Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10 // License for more details. You should have received a copy of the GNU General Public License along with this program;
11 // if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12 //
13 // Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14 // Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 /*! \file */
17 
18 #pragma once
19 
20 #ifdef JEVOIS_PRO
21 
23 #include <deque>
24 #include <memory>
25 
26 class ImGuiInputTextCallbackData;
27 
28 namespace jevois
29 {
30  //! Simple console with coloring and completion
31  class GUIconsole : public UserInterface
32  {
33  public:
34  //! Constructor
35  GUIconsole(std::string const & instance);
36 
37  //! Destructor
38  virtual ~GUIconsole();
39 
40  //! Read some bytes if available, and return true and a string when one is complete (RETURN pressed)
41  /*! str is untouched if user input is not yet complete (RETURN not yet pressed). The RETURN (end of line) marker
42  is not copied into str, only the characters received up to the end of line marker. */
43  bool readSome(std::string & str) override;
44 
45  //! Write a string
46  /*! No line terminator should be included in the string, writeString() will add one. In the Serial derived class,
47  this will be using the line termination convention of serial::linestyle to support different styles (CR, CRLF,
48  LF, etc). */
49  void writeString(std::string const & str) override;
50 
51  //! Our type is: GUI
52  Type type() const override;
53 
54  //! Render into ImGui
55  void draw();
56 
57  protected:
58  //! Clear the contents of the window
59  void clear();
60 
61  //void AddLog(const char* fmt, ...) IM_FMTARGS(2);
62 
63 
64  //void ExecCommand(const char* command_line);
65 
66  //int TextEditCallback(ImGuiInputTextCallbackData* data);
67 
68  private:
69  mutable std::mutex itsDataMtx;
70  std::deque<std::pair<bool /* user/jevois */, std::string> > itsData;
71  std::string itsLastInput;
72  char itsInputBuf[1024];
73  std::vector<std::string> itsHistory;
74  int itsHistoryPos = 0;
75 
76  public:
77  int callback(ImGuiInputTextCallbackData * data);
78  };
79 }
80 
81 #endif // JEVOIS_PRO
jevois::GUIconsole::readSome
bool readSome(std::string &str) override
Read some bytes if available, and return true and a string when one is complete (RETURN pressed)
Definition: GUIconsole.C:55
jevois::GUIconsole::~GUIconsole
virtual ~GUIconsole()
Destructor.
Definition: GUIconsole.C:40
jevois::UserInterface
Abstract base class for a string-based user interface.
Definition: UserInterface.H:32
jevois::GUIconsole::callback
int callback(ImGuiInputTextCallbackData *data)
Definition: GUIconsole.C:167
UserInterface.H
jevois
Definition: Concepts.dox:1
jevois::GUIconsole::clear
void clear()
Clear the contents of the window.
Definition: GUIconsole.C:48
jevois::UserInterface::Type
Type
Enum for the interface type.
Definition: UserInterface.H:59
jevois::GUIconsole
Simple console with coloring and completion.
Definition: GUIconsole.H:31
jevois::GUIconsole::type
Type type() const override
Our type is: GUI.
Definition: GUIconsole.C:44
jevois::GUIconsole::draw
void draw()
Render into ImGui.
Definition: GUIconsole.C:84
jevois::GUIconsole::writeString
void writeString(std::string const &str) override
Write a string.
Definition: GUIconsole.C:69
jevois::GUIconsole::GUIconsole
GUIconsole(std::string const &instance)
Constructor.
Definition: GUIconsole.C:26