Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Public Member Functions | Private Member Functions | Private Attributes | List of all members
geometrize::dialog::ScriptConsole::ScriptConsoleImpl Class Reference
Collaboration diagram for geometrize::dialog::ScriptConsole::ScriptConsoleImpl:
Collaboration graph
[legend]

Public Member Functions

 ScriptConsoleImpl (ScriptConsole *pQ)
 
ScriptConsoleImpl operator= (const ScriptConsoleImpl &)=delete
 
 ScriptConsoleImpl (const ScriptConsoleImpl &)=delete
 
 ~ScriptConsoleImpl ()
 
void setEngine (chaiscript::ChaiScript *engine)
 
std::vector< std::string > getHistory () const
 
void setHistory (const std::vector< std::string > &history)
 
void append (const QString &message)
 
void onLanguageChange ()
 

Private Member Functions

void populateUi ()
 
void setCompletionList (chaiscript::ChaiScript *engine)
 

Private Attributes

ScriptConsoleq
 
std::unique_ptr
< Ui::ScriptConsole > 
ui
 
chaiscript::ChaiScript * m_engine
 
std::vector< std::string > m_history
 

Constructor & Destructor Documentation

geometrize::dialog::ScriptConsole::ScriptConsoleImpl::ScriptConsoleImpl ( ScriptConsole pQ)
inline
20  : q{pQ}, ui{std::make_unique<Ui::ScriptConsole>()}, m_engine{nullptr}
21  {
22  ui->setupUi(q);
23  ui->outputView->append("ChaiScript " + QString(chaiscript::compiler_name));
24  ui->outputView->append(tr("Type 'help' in console for a list of commands", "Instructional text shown in the command/scripting console. The 'help' string should not be translated"));
25  populateUi();
26 
27  connect(ui->commandLine, &geometrize::dialog::CommandLineEdit::signal_commandSubmitted, [this](const std::string& command) {
28 
29  ui->outputView->append(QString::fromStdString(command));
30 
31  if(command.empty()) {
32  return;
33  }
34 
35  if(m_engine != nullptr) {
36  if(command == "help") {
37  const std::vector<std::string> functions{script::getEngineFunctionNames(*m_engine)};
38  for(const std::string& f : functions) {
39  append(QString::fromStdString(f));
40  }
41  } else if(command == "clearHistory") {
42  ui->commandLine->clearHistory();
43  } else if(command == "history") {
44  const std::vector<std::string> history{ui->commandLine->getHistory()};
45  for(const std::string& command : history) {
46  ui->outputView->append(QString::fromStdString(command));
47  }
48  } else if(command == "clear") {
49  ui->outputView->clear();
50  } else {
51  script::runScript(command, *m_engine);
52  }
53  } else {
54  ui->outputView->append(tr("No script engine is set up on this console, commands won't be handled"));
55  }
56  });
57  }
std::unique_ptr< Ui::ScriptConsole > ui
Definition: scriptconsole.cpp:109
void populateUi()
Definition: scriptconsole.cpp:94
void append(const QString &message)
Definition: scriptconsole.cpp:82
std::vector< std::string > getEngineFunctionNames(const chaiscript::ChaiScript &engine)
getEngineFunctionNames Gets the names of the functions registered with the given engine.
Definition: scriptutil.cpp:48
void runScript(const std::string &code, chaiscript::ChaiScript &runner)
runScript Evaluates the provided script code.
Definition: scriptrunner.cpp:16
chaiscript::ChaiScript * m_engine
Definition: scriptconsole.cpp:110
ScriptConsole * q
Definition: scriptconsole.cpp:108
void signal_commandSubmitted(const std::string &)
signal_commandSubmitted is fired when a command is submitted by the user (e.g. after pressing return)...
geometrize::dialog::ScriptConsole::ScriptConsoleImpl::ScriptConsoleImpl ( const ScriptConsoleImpl )
delete
geometrize::dialog::ScriptConsole::ScriptConsoleImpl::~ScriptConsoleImpl ( )
inline
62  {
63 
64  }

Member Function Documentation

void geometrize::dialog::ScriptConsole::ScriptConsoleImpl::append ( const QString &  message)
inline
83  {
84  ui->outputView->append(message);
85  }
std::unique_ptr< Ui::ScriptConsole > ui
Definition: scriptconsole.cpp:109
std::vector<std::string> geometrize::dialog::ScriptConsole::ScriptConsoleImpl::getHistory ( ) const
inline
73  {
74  return ui->commandLine->getHistory();
75  }
std::unique_ptr< Ui::ScriptConsole > ui
Definition: scriptconsole.cpp:109
void geometrize::dialog::ScriptConsole::ScriptConsoleImpl::onLanguageChange ( )
inline
88  {
89  ui->retranslateUi(q);
90  populateUi();
91  }
std::unique_ptr< Ui::ScriptConsole > ui
Definition: scriptconsole.cpp:109
void populateUi()
Definition: scriptconsole.cpp:94
ScriptConsole * q
Definition: scriptconsole.cpp:108

Here is the call graph for this function:

ScriptConsoleImpl geometrize::dialog::ScriptConsole::ScriptConsoleImpl::operator= ( const ScriptConsoleImpl )
delete
void geometrize::dialog::ScriptConsole::ScriptConsoleImpl::populateUi ( )
inlineprivate
95  {
96 
97  }

Here is the caller graph for this function:

void geometrize::dialog::ScriptConsole::ScriptConsoleImpl::setCompletionList ( chaiscript::ChaiScript *  engine)
inlineprivate
100  {
101  if(m_engine == nullptr) {
102  ui->commandLine->setCompletionList({});
103  } else {
104  ui->commandLine->setCompletionList(script::getEngineFunctionNames(*engine));
105  }
106  }
std::unique_ptr< Ui::ScriptConsole > ui
Definition: scriptconsole.cpp:109
std::vector< std::string > getEngineFunctionNames(const chaiscript::ChaiScript &engine)
getEngineFunctionNames Gets the names of the functions registered with the given engine.
Definition: scriptutil.cpp:48
chaiscript::ChaiScript * m_engine
Definition: scriptconsole.cpp:110

Here is the call graph for this function:

Here is the caller graph for this function:

void geometrize::dialog::ScriptConsole::ScriptConsoleImpl::setEngine ( chaiscript::ChaiScript *  engine)
inline
67  {
68  m_engine = engine;
69  setCompletionList(engine);
70  }
void setCompletionList(chaiscript::ChaiScript *engine)
Definition: scriptconsole.cpp:99
chaiscript::ChaiScript * m_engine
Definition: scriptconsole.cpp:110

Here is the call graph for this function:

void geometrize::dialog::ScriptConsole::ScriptConsoleImpl::setHistory ( const std::vector< std::string > &  history)
inline
78  {
79  ui->commandLine->setHistory(history);
80  }
std::unique_ptr< Ui::ScriptConsole > ui
Definition: scriptconsole.cpp:109

Member Data Documentation

chaiscript::ChaiScript* geometrize::dialog::ScriptConsole::ScriptConsoleImpl::m_engine
private
std::vector<std::string> geometrize::dialog::ScriptConsole::ScriptConsoleImpl::m_history
private
ScriptConsole* geometrize::dialog::ScriptConsole::ScriptConsoleImpl::q
private
std::unique_ptr<Ui::ScriptConsole> geometrize::dialog::ScriptConsole::ScriptConsoleImpl::ui
private

The documentation for this class was generated from the following file: