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 Types | Private Member Functions | Private Attributes | List of all members
geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl Class Reference
Collaboration diagram for geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl:
Collaboration graph
[legend]

Public Member Functions

 ScriptEditorWidgetImpl (ScriptEditorWidget *pQ, const std::string &title, const std::string &functionName, const std::string &defaultCode)
 
ScriptEditorWidgetImpl operator= (const ScriptEditorWidgetImpl &)=delete
 
 ScriptEditorWidgetImpl (const ScriptEditorWidgetImpl &)=delete
 
 ~ScriptEditorWidgetImpl ()
 
void resetCodeToDefault ()
 
std::string getFunctionName () const
 
std::string getDefaultCode () const
 
std::string getCurrentCode () const
 
void setCurrentCode (const std::string &code)
 
void onScriptEvaluationSucceeded ()
 
void onScriptEvaluationFailed (const std::string &errorMessage)
 
void onLanguageChange ()
 

Private Types

enum  ScriptEvaluationState { ScriptEvaluationState::OK, ScriptEvaluationState::ERROR }
 
enum  ScriptChangesState { ScriptChangesState::READY, ScriptChangesState::UNAPPLIED_CHANGES }
 

Private Member Functions

void populateUi ()
 
void setEvaluationErrorMessage (const std::string &message)
 
void setScriptEvaluationState (const ScriptEvaluationState state)
 
void setScriptChangesState (const ScriptChangesState state)
 
void setLabel (QLabel *label, QPixmap pixmap)
 

Private Attributes

ScriptEditorWidgetq
 
std::unique_ptr
< Ui::ScriptEditorWidget > 
ui
 
const std::string m_functionName
 
const std::string m_defaultCode
 

Member Enumeration Documentation

Enumerator
READY 
UNAPPLIED_CHANGES 
141  {
142  READY,
143  UNAPPLIED_CHANGES
144  };
Enumerator
OK 
ERROR 
114  {
115  OK,
116  ERROR
117  };

Constructor & Destructor Documentation

geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::ScriptEditorWidgetImpl ( ScriptEditorWidget pQ,
const std::string &  title,
const std::string &  functionName,
const std::string &  defaultCode 
)
inline
22  : q{pQ}, ui{std::make_unique<Ui::ScriptEditorWidget>()}, m_functionName{functionName}, m_defaultCode{defaultCode}
23  {
24  ui->setupUi(q);
25  populateUi();
26 
27  q->setTitle(QString::fromStdString(title));
28 
29  const QString contents{QString::fromStdString(defaultCode)};
30  ui->scriptTextEdit->insertPlainText(contents);
31 
32  QFontMetrics metrics(ui->scriptTextEdit->font());
33  const QSize size{metrics.size(0, contents)};
34  const int padding = 30;
35  ui->scriptTextEdit->setMinimumSize(ui->scriptTextEdit->width() + padding, size.height() + padding);
36 
37  q->connect(ui->scriptTextEdit, &QPlainTextEdit::textChanged, [this]() {
39 
40  const std::string code{ui->scriptTextEdit->toPlainText().toStdString()};
42  });
43 
44  q->connect(ui->resetToDefaultButton, &QPushButton::clicked, [this]() {
45  ui->scriptTextEdit->setPlainText(QString::fromStdString(m_defaultCode));
46 
48  });
49 
52  }
void signal_scriptChanged(ScriptEditorWidget *self, const std::string &functionName, const std::string &code)
signal_scriptChanged Signal emitted when the user change the script code of a function.
void setScriptEvaluationState(const ScriptEvaluationState state)
Definition: scripteditorwidget.cpp:124
const std::string m_functionName
Definition: scripteditorwidget.cpp:165
const std::string m_defaultCode
Definition: scripteditorwidget.cpp:166
std::unique_ptr< Ui::ScriptEditorWidget > ui
Definition: scripteditorwidget.cpp:164
void setScriptChangesState(const ScriptChangesState state)
Definition: scripteditorwidget.cpp:146
ScriptEditorWidget * q
Definition: scripteditorwidget.cpp:163
void populateUi()
Definition: scripteditorwidget.cpp:108
void signal_scriptReset(ScriptEditorWidget *self, const std::string &functionName, const std::string &code)
signal_scriptReset Signal emitted when the user hits the reset button, expecting the script to be res...
geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::ScriptEditorWidgetImpl ( const ScriptEditorWidgetImpl )
delete
geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::~ScriptEditorWidgetImpl ( )
inline
57  {
58  }

Member Function Documentation

std::string geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::getCurrentCode ( ) const
inline
77  {
78  return ui->scriptTextEdit->toPlainText().toStdString();
79  }
std::unique_ptr< Ui::ScriptEditorWidget > ui
Definition: scripteditorwidget.cpp:164
std::string geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::getDefaultCode ( ) const
inline
72  {
73  return m_defaultCode;
74  }
const std::string m_defaultCode
Definition: scripteditorwidget.cpp:166
std::string geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::getFunctionName ( ) const
inline
67  {
68  return m_functionName;
69  }
const std::string m_functionName
Definition: scripteditorwidget.cpp:165
void geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::onLanguageChange ( )
inline
102  {
103  ui->retranslateUi(q);
104  populateUi();
105  }
std::unique_ptr< Ui::ScriptEditorWidget > ui
Definition: scripteditorwidget.cpp:164
ScriptEditorWidget * q
Definition: scripteditorwidget.cpp:163
void populateUi()
Definition: scripteditorwidget.cpp:108
void geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::onScriptEvaluationFailed ( const std::string &  errorMessage)
inline
void geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::onScriptEvaluationSucceeded ( )
inline
ScriptEditorWidgetImpl geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::operator= ( const ScriptEditorWidgetImpl )
delete
void geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::populateUi ( )
inlineprivate
109  {
110 
111  }
void geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::resetCodeToDefault ( )
inline
61  {
62  ui->scriptTextEdit->clear();
63  ui->scriptTextEdit->appendPlainText(QString::fromStdString(m_defaultCode));
64  }
const std::string m_defaultCode
Definition: scripteditorwidget.cpp:166
std::unique_ptr< Ui::ScriptEditorWidget > ui
Definition: scripteditorwidget.cpp:164
void geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::setCurrentCode ( const std::string &  code)
inline
82  {
83  ui->scriptTextEdit->clear();
84  ui->scriptTextEdit->appendPlainText(QString::fromStdString(code));
85  }
std::unique_ptr< Ui::ScriptEditorWidget > ui
Definition: scripteditorwidget.cpp:164
void geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::setEvaluationErrorMessage ( const std::string &  message)
inlineprivate
120  {
121  ui->evaluationErrorMessageBox->setText(QString::fromStdString(message));
122  }
std::unique_ptr< Ui::ScriptEditorWidget > ui
Definition: scripteditorwidget.cpp:164
void geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::setLabel ( QLabel *  label,
QPixmap  pixmap 
)
inlineprivate
159  {
160  label->setPixmap(pixmap);
161  }
void geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::setScriptChangesState ( const ScriptChangesState  state)
inlineprivate
147  {
148  switch(state) {
150  setLabel(ui->scriptChangesStateIcon, QPixmap(":/icons/script_go.png"));
151  break;
153  setLabel(ui->scriptChangesStateIcon, QPixmap(":/icons/script_edit.png"));
154  break;
155  }
156  }
void setLabel(QLabel *label, QPixmap pixmap)
Definition: scripteditorwidget.cpp:158
std::unique_ptr< Ui::ScriptEditorWidget > ui
Definition: scripteditorwidget.cpp:164
void geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::setScriptEvaluationState ( const ScriptEvaluationState  state)
inlineprivate
125  {
126  switch(state) {
128  setLabel(ui->scriptEvaluationStateIcon, QPixmap(":/icons/script_green.png"));
129  ui->evaluationErrorMessageBox->setStyleSheet("QTextEdit { color: green }");
130  ui->evaluationErrorMessageBox->setVisible(false);
131  break;
133  setLabel(ui->scriptEvaluationStateIcon, QPixmap(":/icons/script_red.png"));
134  ui->evaluationErrorMessageBox->setStyleSheet("QTextEdit { color: red }");
135  ui->evaluationErrorMessageBox->setVisible(true);
136  break;
137  }
138  }
void setLabel(QLabel *label, QPixmap pixmap)
Definition: scripteditorwidget.cpp:158
std::unique_ptr< Ui::ScriptEditorWidget > ui
Definition: scripteditorwidget.cpp:164

Member Data Documentation

const std::string geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::m_defaultCode
private
const std::string geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::m_functionName
private
ScriptEditorWidget* geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::q
private
std::unique_ptr<Ui::ScriptEditorWidget> geometrize::dialog::ScriptEditorWidget::ScriptEditorWidgetImpl::ui
private

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