Version: 8.3.0
YACS::HMI::EditionPyFunc Class Reference

#include <EditionPyFunc.hxx>

Inheritance diagram for YACS::HMI::EditionPyFunc:
Collaboration diagram for YACS::HMI::EditionPyFunc:

Public Slots

virtual void onApply ()
 
virtual void onCancel ()
 
virtual void onFuncNameModified (const QString &text)
 
virtual void onTemplate ()
 
- Public Slots inherited from YACS::HMI::EditionScript
virtual void onApply ()
 
virtual void onCancel ()
 
virtual void onScriptModified ()
 
virtual void onEdit ()
 
virtual void on_tb_options_toggled (bool checked)
 
virtual void on_remote_toggled (bool checked)
 
virtual void fillContainerPanel ()
 
virtual void changeContainer (int)
 
virtual void update (GuiEvent event, int type, Subject *son)
 
- Public Slots inherited from YACS::HMI::EditionElementaryNode
virtual void onApply ()
 
virtual void onCancel ()
 
virtual void onPortIndexChanged (int index)
 
virtual void onCommitData (QWidget *editor)
 

Public Member Functions

 EditionPyFunc (Subject *subject, QWidget *parent=0, const char *name=0)
 
virtual ~EditionPyFunc ()
 
- Public Member Functions inherited from YACS::HMI::EditionScript
 EditionScript (Subject *subject, QWidget *parent=0, const char *name=0)
 
virtual ~EditionScript ()
 
virtual void synchronize ()
 
- Public Member Functions inherited from YACS::HMI::EditionElementaryNode
 EditionElementaryNode (Subject *subject, QWidget *parent=0, const char *name=0)
 
virtual ~EditionElementaryNode ()
 
virtual void setEditablePorts (bool isEditable)
 
- Public Member Functions inherited from YACS::HMI::EditionNode
 EditionNode (Subject *subject, QWidget *parent=0, const char *name=0)
 
virtual ~EditionNode ()
 
virtual void update (GuiEvent event, int type, Subject *son)
 
- Public Member Functions inherited from YACS::HMI::ItemEdition
 ItemEdition (Subject *subject, QWidget *parent=0, const char *name=0)
 
virtual ~ItemEdition ()
 
virtual void select (bool isSelected)
 
virtual void setName (std::string name)
 
virtual void setEdited (bool isEdited)
 
- Public Member Functions inherited from FormEditItem
 FormEditItem (QWidget *parent=0)
 
virtual ~FormEditItem ()
 
- Public Member Functions inherited from YACS::HMI::ItemEditionBase
 ItemEditionBase (Subject *subject)
 
virtual ~ItemEditionBase ()
 
virtual SubjectgetSubject ()
 
- Public Member Functions inherited from YACS::HMI::GuiObserver
 GuiObserver ()
 
virtual ~GuiObserver ()
 
virtual void incrementSubjects (Subject *subject)
 
virtual void decrementSubjects (Subject *subject)
 
int getNbSubjects ()
 
bool isDestructible ()
 

Protected Attributes

SubjectPyFuncNode_subFuncNode
 
std::string _funcName
 
QLineEdit_liFuncName
 
- Protected Attributes inherited from YACS::HMI::EditionScript
SubjectInlineNode_subInlineNode
 
QTextEdit * _sci
 
QVBoxLayout * _glayout
 
QVBoxLayout * _portslayout
 
QPushButton * _editor
 
bool _checked
 
bool _remote
 
QFrame * fr_options
 
QFrame * fr_container
 
ComboBoxcb_container
 
QRadioButton * radiolocal
 
QRadioButton * radioremote
 
FormContainerDecoratorformcontainer
 
- Protected Attributes inherited from YACS::HMI::EditionElementaryNode
SubjectElementaryNode_subElemNode
 
QTabWidget * _twPorts
 
TablePortsEdition_tvInPorts
 
TablePortsEdition_tvOutPorts
 
ValueDelegate_valueDelegate
 
- Protected Attributes inherited from YACS::HMI::EditionNode
QLineEdit_le_fullName
 
SubjectNode_subjectNode
 
- Protected Attributes inherited from YACS::HMI::ItemEdition
bool _isEdited
 
bool _haveScript
 
- Protected Attributes inherited from FormEditItem
WidEditItem_wid
 
- Protected Attributes inherited from YACS::HMI::ItemEditionBase
Subject_subject
 
int _stackId
 
std::string _name
 
std::string _type
 
std::string _category
 
- Protected Attributes inherited from YACS::HMI::GuiObserver
std::set< Subject * > _subjectSet
 
bool _destructible
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::HMI::ItemEdition
static std::string filterName (const std::string &name)
 
- Protected Member Functions inherited from YACS::HMI::EditionElementaryNode
virtual bool hasInputPorts ()
 
virtual bool hasOutputPorts ()
 
virtual void createTablePorts (QLayout *layout)
 
- Static Protected Attributes inherited from YACS::HMI::GuiObserver
static std::map< int, std::string > _eventNameMap
 

Detailed Description

Definition at line 31 of file EditionPyFunc.hxx.

Constructor & Destructor Documentation

EditionPyFunc::EditionPyFunc ( Subject subject,
QWidget parent = 0,
const char *  name = 0 
)

Definition at line 45 of file EditionPyFunc.cxx.

References _funcName, YACS::HMI::EditionScript::_glayout, _liFuncName, YACS::HMI::EditionScript::_sci, _subFuncNode, YACS::HMI::ItemEditionBase::_subject, YACS::ENGINE::InlineFuncNode::getFname(), YACS::HMI::SubjectNode::getNode(), YACS::HMI::QtGuiContext::getQtCurrent(), onFuncNameModified(), onTemplate(), and YASSERT.

48  : EditionScript(subject, parent, name)
49 {
50  _subFuncNode = 0;
51  _funcName ="";
52  _liFuncName = 0;
53 
54  _subFuncNode = dynamic_cast<SubjectPyFuncNode*>(_subject);
56 
59  YASSERT(pyFuncNode);
60 
61  _glayout->removeWidget( _sci );
62 
63  QGridLayout *glt = new QGridLayout();
64  _funcName = pyFuncNode->getFname();
65  QLabel* laFuncName = new QLabel("laFuncName", this );
66  glt->addWidget(laFuncName, 0, 0, 1, 1);
67  laFuncName->setText("Function Name:");
68  _liFuncName = new QLineEdit( "liFuncName", this );
69  glt->addWidget(_liFuncName, 0, 1, 1, 1);
70  _liFuncName->setText(_funcName.c_str());
71  QPushButton* gener_template = new QPushButton("Template",this);
72  connect(gener_template,SIGNAL(clicked()),this, SLOT(onTemplate()));
73  glt->addWidget(gener_template, 0, 2, 1, 1);
74  _glayout->addLayout( glt , 1);
75 
76  _glayout->addWidget( _sci );
77  if (!QtGuiContext::getQtCurrent()->isEdition())
78  {
79  gener_template->setEnabled (false);
80  _liFuncName->setEnabled (false);
81  }
82 
83 
84  connect(_liFuncName, SIGNAL(textChanged(const QString&)),
85  this, SLOT(onFuncNameModified(const QString&)));
86 }
EditionPyFunc::~EditionPyFunc ( )
virtual

Definition at line 88 of file EditionPyFunc.cxx.

89 {
90 }

Member Function Documentation

void EditionPyFunc::onApply ( )
virtualslot

Definition at line 92 of file EditionPyFunc.cxx.

References _funcName, YACS::HMI::ItemEdition::_isEdited, _liFuncName, _subFuncNode, YACS::HMI::EditionScript::onApply(), PMMLBasicsTestLauncher::ret, and YACS::HMI::SubjectPyFuncNode::setFunctionName().

Referenced by onTemplate().

93 {
94  bool funcNameEdited = false;
95  string funcName = _liFuncName->text().toStdString();
96  if (funcName.empty())
97  {
98  _liFuncName->setText(_funcName.c_str());
99  funcName = _funcName;
100  }
101  if (funcName != _funcName)
102  {
103  funcNameEdited = true;
104  bool ret = _subFuncNode->setFunctionName(funcName);
105  if (ret)
106  {
107  funcNameEdited = false;
108  _funcName = funcName;
109  }
110  }
111  _isEdited = _isEdited || funcNameEdited;
113 }
void EditionPyFunc::onCancel ( )
virtualslot

Definition at line 115 of file EditionPyFunc.cxx.

References _funcName, _liFuncName, and YACS::HMI::EditionScript::onCancel().

116 {
117  _liFuncName->setText(_funcName.c_str());
119 }
void EditionPyFunc::onFuncNameModified ( const QString &  text)
virtualslot

Definition at line 121 of file EditionPyFunc.cxx.

References _funcName, and YACS::HMI::ItemEdition::setEdited().

Referenced by EditionPyFunc().

122 {
123  if (_funcName != text.toStdString()) setEdited(true);
124 }
void EditionPyFunc::onTemplate ( )
virtualslot

Definition at line 126 of file EditionPyFunc.cxx.

References _funcName, YACS::HMI::EditionScript::_sci, _subFuncNode, YACS::HMI::SubjectNode::getNode(), YACS::ENGINE::ElementaryNode::getSetOfInputPort(), YACS::ENGINE::ElementaryNode::getSetOfOutputPort(), and onApply().

Referenced by EditionPyFunc().

127 {
128  if(_funcName=="")return;
129 
130  ElementaryNode* node = dynamic_cast<ElementaryNode*>(_subFuncNode->getNode());
131 
132  std::string text;
133  text = "def " + _funcName + "(";
134 
135  std::list<InputPort*> iplist = node->getSetOfInputPort();
136  std::list<InputPort*>::iterator ipos = iplist.begin();
137  for (; ipos != iplist.end(); ipos++)
138  {
139  text = text + (*ipos)->getName() + ",";
140  }
141  text = text + "):\n";
142  text = text + " return ";
143 
144  std::list<OutputPort*> oplist = node->getSetOfOutputPort();
145  std::list<OutputPort*>::iterator opos = oplist.begin();
146  for (; opos != oplist.end(); opos++)
147  {
148  text = text + (*opos)->getName() + ",";
149  }
150  text[text.length()-1]=' ';
151  text = text + "\n";
152  _sci->append(text.c_str());
153  onApply();
154 }

Member Data Documentation

std::string YACS::HMI::EditionPyFunc::_funcName
protected

Definition at line 49 of file EditionPyFunc.hxx.

Referenced by EditionPyFunc(), onApply(), onCancel(), onFuncNameModified(), and onTemplate().

QLineEdit* YACS::HMI::EditionPyFunc::_liFuncName
protected

Definition at line 50 of file EditionPyFunc.hxx.

Referenced by EditionPyFunc(), onApply(), and onCancel().

SubjectPyFuncNode* YACS::HMI::EditionPyFunc::_subFuncNode
protected

Definition at line 48 of file EditionPyFunc.hxx.

Referenced by EditionPyFunc(), onApply(), and onTemplate().


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