Version: 8.3.0
YACS::HMI::SchemaInPortItem Class Reference

#include <SchemaInPortItem.hxx>

Inheritance diagram for YACS::HMI::SchemaInPortItem:
Collaboration diagram for YACS::HMI::SchemaInPortItem:

Public Member Functions

 SchemaInPortItem (SchemaItem *parent, QString label, Subject *subject)
 
virtual void update (GuiEvent event, int type, Subject *son)
 
virtual Qt::ItemFlags flags (const QModelIndex &index)
 
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action)
 
virtual void popupMenu (QWidget *caller, const QPoint &globalPos)
 
- Public Member Functions inherited from YACS::HMI::SchemaItem
 SchemaItem (SchemaItem *parent, QString label, Subject *subject)
 
virtual ~SchemaItem ()
 
virtual void appendChild (SchemaItem *child)
 
virtual void removeChild (SchemaItem *child)
 
virtual void insertChild (int row, SchemaItem *child)
 
virtual SchemaItemchild (int row)
 
virtual int childCount () const
 
virtual int columnCount () const
 
virtual QVariant data (int column, int role) const
 
virtual int row () const
 
virtual SchemaItemparent ()
 
virtual SubjectgetSubject ()
 
virtual void select (bool isSelected)
 
virtual void toggleState ()
 
QModelIndex modelIndex (int column=0)
 
virtual ItemMimeDatamimeData (ItemMimeData *mime)
 
virtual void reparent (SchemaItem *parent)
 
virtual void setCaseValue ()
 used in node derived classes More...
 
bool isEmphasized ()
 
void setEmphasize (bool emphasize)
 
- 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 Member Functions

virtual QVariant editionWhatsThis (int column) const
 
- Protected Member Functions inherited from YACS::HMI::SchemaItem
virtual QVariant editionToolTip (int column) const
 
virtual QVariant runToolTip (int column) const
 
virtual QVariant runWhatsThis (int column) const
 
virtual QString getMimeFormat ()
 
virtual void setExecState (int execState)
 

Protected Attributes

bool _isDataStream
 
- Protected Attributes inherited from YACS::HMI::SchemaItem
QList< SchemaItem * > _childItems
 
QList< QVariant > _itemData
 
QList< QVariant > _itemDeco
 
QList< QVariant > _itemForeground
 
QList< QVariant > _itemBackground
 
QList< QVariant > _itemCheckState
 
QList< QVariant > _itemToolTip
 
QList< QVariant > _itemWhatsThis
 
QString _label
 
SchemaItem_parentItem
 
Subject_subject
 
int _execState
 
bool _emphasized
 
- Protected Attributes inherited from YACS::HMI::GuiObserver
std::set< Subject * > _subjectSet
 
bool _destructible
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::HMI::GuiObserver
static std::string eventName (GuiEvent event)
 
static void setEventMap ()
 
- Static Protected Attributes inherited from YACS::HMI::GuiObserver
static std::map< int, std::string > _eventNameMap
 

Detailed Description

Definition at line 29 of file SchemaInPortItem.hxx.

Constructor & Destructor Documentation

SchemaInPortItem::SchemaInPortItem ( SchemaItem parent,
QString  label,
Subject subject 
)

column 1 = name, set in SchemaItem, column 2 = data type, never editable, column 3 = value

Definition at line 47 of file SchemaInPortItem.cxx.

References _isDataStream, YACS::HMI::SchemaItem::_itemData, YACS::HMI::SchemaItem::_itemDeco, YACS::HMI::SchemaItem::_itemForeground, YACS::ENGINE::InPort::edGetNumberOfLinks(), YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::InputPort::edIsManuallyInitialized(), YACS::ENGINE::DataPort::getAsString(), YACS::ENGINE::Port::getNode(), YACS::HMI::SubjectDataPort::getPort(), YACS::HMI::ProcInvoc::getTypeOfNode(), YACS::HMI::ProcInvoc::getTypeOfPort(), YACS::HMI::INPUTDATASTREAMPORT, YACS::HMI::INPUTPORT, YACS::ENGINE::TypeCode::name(), YACS::HMI::STUDYOUTNODE, YACS::HMI::YLabel, YACS::HMI::YType, and YACS::HMI::YValue.

48  : SchemaItem(parent, label, subject)
49 {
50  SubjectDataPort *subPort = dynamic_cast<SubjectDataPort*>(subject);
51  _isDataStream = false;
52  if (subPort)
53  {
54  DataPort *dport = subPort->getPort();
55  TypeOfElem typort = ProcInvoc::getTypeOfPort(dport);
56  TypeOfElem typnode = ProcInvoc::getTypeOfNode(dport->getNode());
57 // _itemData.replace(YType, dport->edGetType()->getKindRepr());
58  _itemData.replace(YType, dport->edGetType()->name());
59  _itemForeground.replace(YType, QColor("black"));
60  InputPort *inport = 0;
61 
62  if(typnode==YACS::HMI::STUDYOUTNODE)
63  {
64  //It's a study out node
65  if(typort==YACS::HMI::INPUTPORT)
66  {
67  _itemDeco.replace(YLabel, QIcon("icons:in_port.png"));
68  inport = dynamic_cast<InputPort*>(dport);
69  std::string val=inport->getAsString();
70  if(val != "")
71  {
72  _itemData.replace(YValue, val.c_str());
73  if (inport->edGetNumberOfLinks())
74  _itemForeground.replace(YValue, QColor("green"));
75  else
76  _itemForeground.replace(YValue, QColor("red"));
77  }
78  else
79  {
80  _itemData.replace(YValue, "not initialized");
81  _itemForeground.replace(YValue, QColor("red"));
82  }
83  }
84  return;
85  }
86 
87  switch (typort)
88  {
90  _isDataStream = false;
91  _itemDeco.replace(YLabel, QIcon("icons:in_port.png"));
92  inport = dynamic_cast<InputPort*>(dport);
93  if (inport->edIsManuallyInitialized())
94  {
95  _itemData.replace(YValue, inport->getAsString().c_str());
96  _itemForeground.replace(YValue, QColor("green"));
97  }
98  else if (inport->edGetNumberOfLinks())
99  {
100  _itemData.replace(YValue, "linked");
101  _itemForeground.replace(YValue, QColor("blue"));
102  }
103  else
104  {
105  _itemData.replace(YValue, "not initialized");
106  _itemForeground.replace(YValue, QColor("red"));
107  }
108  break;
110  _isDataStream = true;
111  _itemDeco.replace(YLabel, QIcon("icons:in_port.png"));
112  _itemData.replace(YValue, "stream");
113  _itemForeground.replace(YValue, QColor("grey"));
114  break;
115  }
116  }
117 }

Member Function Documentation

bool SchemaInPortItem::dropMimeData ( const QMimeData data,
Qt::DropAction  action 
)
virtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 254 of file SchemaInPortItem.cxx.

References YACS::HMI::SchemaItem::data(), DEBTRACE, YACS::HMI::ItemMimeData::getControl(), YACS::HMI::SubjectDataPort::getPort(), YACS::HMI::ItemMimeData::getSubject(), YACS::HMI::SchemaItem::getSubject(), YACS::HMI::ProcInvoc::getTypeOfPort(), YACS::HMI::INPUTDATASTREAMPORT, YACS::HMI::INPUTPORT, PMMLBasicsTestLauncher::ret, and YACS::HMI::SubjectDataPort::tryCreateLink().

255 {
256  DEBTRACE("SchemaInPortItem::dropMimeData");
257  if (!data) return false;
258  const ItemMimeData* myData = dynamic_cast<const ItemMimeData*>(data);
259  if (!myData) return false;
260  if(!myData->hasFormat("yacs/subjectOutPort")) return false;
261  SubjectDataPort *to = dynamic_cast<SubjectDataPort*>(getSubject());
262  if (!to) return false;
263  InPort *toport = dynamic_cast<InPort*>(to->getPort());
264  if (!toport) return false;
265 
266  bool ret =false;
267  TypeOfElem typort = ProcInvoc::getTypeOfPort(toport);
268  switch (typort)
269  {
272  {
273  ret =true;
274  Subject *sub = myData->getSubject();
275  if (!sub) break;
276  SubjectDataPort* from = dynamic_cast<SubjectDataPort*>(sub);
277  if (from && to)
278  if (!SubjectDataPort::tryCreateLink(from, to,myData->getControl()))
279  Message mess;
280  break;
281  }
282  default:
283  break;
284  }
285  return ret;
286 }
QVariant SchemaInPortItem::editionWhatsThis ( int  column) const
protectedvirtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 294 of file SchemaInPortItem.cxx.

References _isDataStream, YACS::HMI::SchemaItem::_itemData, YACS::HMI::YLabel, YACS::HMI::YType, and YACS::HMI::YValue.

295 {
296  QString answer;
297  if (_isDataStream)
298  answer = "Edition, DataStream input port ";
299  else
300  answer = "Edition, DataFlow input port ";
301  switch (column)
302  {
303  case YLabel:
304  answer += "name=";
305  answer += _itemData.value(column).toString();
306  answer += "\nInput port is edited in the input panel of the node.\n" \
307  "Select the node to get access to it's input panel.";
308  break;
309  case YType:
310  answer += "type=";
311  answer += _itemData.value(column).toString();
312  answer += "\nInput port is edited in the input panel of the node.\n" \
313  "Select the node to get access to it's input panel.\n" \
314  "Type is not modifiable, you must delete and recreate the port. Existing links will be lost.";
315  break;
316  case YValue:
317  answer += "value=";
318  answer += _itemData.value(column).toString();
319  answer += "\nInput port is edited in the input panel of the node.\n" \
320  "Select the node to get access to it's input panel.\n";
321  if (_isDataStream)
322  answer += "DataStream ports have no editable value, they must be linked to an output DataStream port.";
323  else
324  {
325  answer += "DataFlow ports must be either manually initialized or linked to an output DataFlow port. ";
326  answer += "If the port is manually initialized and linked, the value from the link will prevail ";
327  answer += "if it is available when the node is executed.";
328  }
329  break;
330  }
331  return answer;
332 }
Qt::ItemFlags SchemaInPortItem::flags ( const QModelIndex &  index)
virtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 228 of file SchemaInPortItem.cxx.

References _isDataStream, YACS::HMI::SchemaItem::_subject, YACS::ENGINE::Port::getNode(), YACS::HMI::SubjectDataPort::getPort(), YACS::HMI::QtGuiContext::getQtCurrent(), and YACS::HMI::SchemaItem::parent().

229 {
230  //DEBTRACE("SchemaInPortItem::flags");
231  Qt::ItemFlags pflag = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled;
232 
233  Qt::ItemFlags flagEdit = 0;
234  int column = index.column();
235  switch (column)
236  {
237  case 0:
238  {
239  SubjectDataPort *sdp = dynamic_cast<SubjectDataPort*>(_subject);
240  Node *parent = sdp->getPort()->getNode();
241  if (parent)
242  if ( (dynamic_cast<DataNode*>(parent) || dynamic_cast<InlineNode*>(parent)) &&
243  QtGuiContext::getQtCurrent()->isEdition() )
244  flagEdit = Qt::ItemIsEditable; // --- port name editable
245  }
246  break;
247  case 2:
248  if (!_isDataStream)
249  flagEdit = Qt::ItemIsEditable; // --- port value editable
250  }
251  return pflag | flagEdit;
252 }
void SchemaInPortItem::popupMenu ( QWidget caller,
const QPoint &  globalPos 
)
virtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 288 of file SchemaInPortItem.cxx.

References gui.GraphViewer::m, and YACS::HMI::InPortMenu::popupMenu().

289 {
290  InPortMenu m;
291  m.popupMenu(caller, globalPos);
292 }
void SchemaInPortItem::update ( GuiEvent  event,
int  type,
Subject son 
)
virtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 119 of file SchemaInPortItem.cxx.

References YACS::HMI::SchemaItem::_itemData, YACS::HMI::SchemaItem::_itemForeground, YACS::HMI::SchemaItem::_subject, DEBTRACE, YACS::ENGINE::InPort::edGetNumberOfLinks(), YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::InputPort::edIsManuallyInitialized(), YACS::ENGINE::DataPort::getAsString(), YACS::HMI::SubjectDataPort::getExecValue(), YACS::ENGINE::Port::getNode(), YACS::HMI::SubjectDataPort::getPort(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSchemaModel(), YACS::HMI::ProcInvoc::getTypeOfNode(), YACS::HMI::ProcInvoc::getTypeOfPort(), YACS::HMI::SchemaItem::modelIndex(), YACS::ENGINE::TypeCode::name(), YACS::HMI::SchemaModel::setData(), YACS::HMI::SETVALUE, YACS::HMI::STUDYOUTNODE, YACS::HMI::SchemaItem::update(), YACS::HMI::UPDATE, YACS::HMI::UPDATEPROGRESS, YACS::HMI::YType, and YACS::HMI::YValue.

Referenced by gui.graph.MyCanvas::customEvent().

120 {
121  DEBTRACE("SchemaInPortItem::update");
122  SchemaItem::update(event, type, son);
123  QModelIndex index = QModelIndex();
125  switch (event)
126  {
127  case SETVALUE:
128  {
129  SubjectInputPort *sip = dynamic_cast<SubjectInputPort*>(son);
130  if (sip)
131  {
132  InputPort* port = dynamic_cast<InputPort*>(sip->getPort());
133  TypeOfElem typnode = ProcInvoc::getTypeOfNode(port->getNode());
134  DEBTRACE(port->getAsString());
135  if(typnode==YACS::HMI::STUDYOUTNODE)
136  {
137  if(port->getAsString().empty())
138  {
139  _itemData.replace(YValue, "not initialized");
140  if (port->edGetNumberOfLinks())
141  _itemForeground.replace(YValue, QColor("blue"));
142  else
143  _itemForeground.replace(YValue, QColor("red"));
144  }
145  else
146  {
147  _itemData.replace(YValue, port->getAsString().c_str());
148  if (port->edGetNumberOfLinks())
149  _itemForeground.replace(YValue, QColor("green"));
150  else
151  _itemForeground.replace(YValue, QColor("red"));
152  }
153  }
154  else
155  {
156  _itemData.replace(YValue, port->getAsString().c_str());
157  _itemForeground.replace(YValue, QColor("green"));
158  }
159  model->setData(modelIndex(YValue), 0); // --- to emit dataChanged signal
160  }
161  }
162  break;
163  case UPDATE:
164  {
165  SubjectInputPort *sip = dynamic_cast<SubjectInputPort*>(_subject);
166  if (sip)
167  {
168  InputPort* port = dynamic_cast<InputPort*>(sip->getPort());
169  TypeOfElem typnode = ProcInvoc::getTypeOfNode(port->getNode());
170  TypeOfElem typort = ProcInvoc::getTypeOfPort(port);
171  _itemData.replace(YType, port->edGetType()->name());
172  _itemForeground.replace(YType, QColor("black"));
173  if(typnode==YACS::HMI::STUDYOUTNODE)
174  {
175  if(port->getAsString().empty())
176  {
177  _itemData.replace(YValue, "not initialized");
178  if (port->edGetNumberOfLinks())
179  _itemForeground.replace(YValue, QColor("blue"));
180  else
181  _itemForeground.replace(YValue, QColor("red"));
182  }
183  else
184  {
185  _itemData.replace(YValue, port->getAsString().c_str());
186  if (port->edGetNumberOfLinks())
187  _itemForeground.replace(YValue, QColor("green"));
188  else
189  _itemForeground.replace(YValue, QColor("red"));
190  }
191  }
192  else
193  {
194  if (port->edGetNumberOfLinks())
195  {
196  _itemData.replace(YValue, "linked");
197  _itemForeground.replace(YValue, QColor("blue"));
198  }
199  else if (port->edIsManuallyInitialized())
200  {
201  _itemData.replace(YValue, port->getAsString().c_str());
202  _itemForeground.replace(YValue, QColor("green"));
203  }
204  else
205  {
206  _itemData.replace(YValue, "not initialized");
207  _itemForeground.replace(YValue, QColor("red"));
208  }
209  }
210  model->setData(modelIndex(YValue), 0); // --- to emit dataChanged signal
211  }
212  }
213  break;
214  case UPDATEPROGRESS:
215  {
216  SubjectInputPort *sip = dynamic_cast<SubjectInputPort*>(son);
217  if (sip)
218  {
219  _itemData.replace(YValue, sip->getExecValue().c_str());
220  _itemForeground.replace(YValue, QColor("darkCyan"));
221  model->setData(modelIndex(YValue), 0); // --- to emit dataChanged signal
222  }
223  }
224  break;
225  }
226 }

Member Data Documentation

bool YACS::HMI::SchemaInPortItem::_isDataStream
protected

Definition at line 40 of file SchemaInPortItem.hxx.

Referenced by editionWhatsThis(), flags(), and SchemaInPortItem().


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