Version: 8.3.0
YACS::HMI::SchemaComposedNodeItem Class Reference

#include <SchemaComposedNodeItem.hxx>

Inheritance diagram for YACS::HMI::SchemaComposedNodeItem:
Collaboration diagram for YACS::HMI::SchemaComposedNodeItem:

Public Member Functions

 SchemaComposedNodeItem (SchemaItem *parent, QString label, Subject *subject)
 
virtual ~SchemaComposedNodeItem ()
 
virtual void update (GuiEvent event, int type, Subject *son)
 
std::list< YACS::ENGINE::Node * > getDirectDescendants () const
 
virtual void popupMenu (QWidget *caller, const QPoint &globalPos)
 
virtual Qt::ItemFlags flags (const QModelIndex &index)
 
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action)
 
virtual void setCaseValue ()
 used in node derived classes More...
 
- 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)
 
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 QString getMimeFormat ()
 
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 void setExecState (int execState)
 

Protected Attributes

SchemaDirTypesItem_dirTypesItem
 
SchemaDirContainersItem_dirContainersItem
 
SchemaDirLinksItem_dirLinksItem
 
- 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 33 of file SchemaComposedNodeItem.hxx.

Constructor & Destructor Documentation

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

Definition at line 60 of file SchemaComposedNodeItem.cxx.

References _dirContainersItem, _dirLinksItem, _dirTypesItem, YACS::HMI::SchemaItem::_itemData, YACS::HMI::SchemaItem::_itemDeco, YACS::HMI::BLOC, YACS::HMI::SchemaItem::childCount(), DEBTRACE, YACS::HMI::FOREACHLOOP, YACS::HMI::FORLOOP, YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSchemaModel(), YACS::HMI::SchemaItem::getSubject(), YACS::HMI::Subject::getType(), YACS::HMI::SubjectComposedNode::getValue(), YACS::HMI::SubjectComposedNode::hasValue(), YACS::HMI::SchemaModel::isEdition(), YACS::HMI::SchemaItem::modelIndex(), YACS::HMI::OPTIMIZERLOOP, setCaseValue(), YACS::HMI::SchemaModel::setData(), YACS::HMI::SchemaItem::setExecState(), YACS::HMI::SWITCH, YACS::UNDEFINED, YACS::HMI::WHILELOOP, YASSERT, YACS::HMI::YLabel, and YACS::HMI::YType.

Referenced by update().

61  : SchemaItem(parent, label, subject)
62 {
63  DEBTRACE("SchemaComposedNodeItem::SchemaComposedNodeItem");
64  switch (subject->getType())
65  {
66  case YACS::HMI::BLOC:
67  _itemDeco.replace(YLabel, QIcon("icons:block_node.png"));
68  break;
69  case YACS::HMI::FORLOOP:
73  _itemDeco.replace(YLabel, QIcon("icons:loop_node.png"));
74  break;
75  case YACS::HMI::SWITCH:
76  _itemDeco.replace(YLabel, QIcon("icons:switch_node.png"));
77  break;
78  default:
79  _itemDeco.replace(YLabel, QIcon("icons:block_node.png"));
80  }
81  _dirTypesItem = 0;
83  _dirLinksItem = 0;
84  Subject *son = 0;
85  int nbsons = childCount();
87 
88  model->beginInsertRows(modelIndex(), nbsons, nbsons);
89  if (SubjectProc* sProc = dynamic_cast<SubjectProc*>(subject))
90  {
91  son = new Subject(getSubject());
92  _dirTypesItem = new SchemaDirTypesItem(this, "Types", son);
93  son = new Subject(getSubject());
94  _dirContainersItem = new SchemaDirContainersItem(this, "Containers", son);
95  }
96  son = new Subject(getSubject());
97  _dirLinksItem = new SchemaDirLinksItem(this, "Links", son);
98  model->endInsertRows();
99 
100  if (!model->isEdition())
101  {
103  }
104 
105  SubjectComposedNode *scn = dynamic_cast<SubjectComposedNode*>(subject);
106  YASSERT(scn);
107  if (scn->hasValue())
108  {
109  _itemData.replace(YType, scn->getValue().c_str());
110  model->setData(modelIndex(YType), 0);
111  }
112 
113  setCaseValue();
114 }
SchemaComposedNodeItem::~SchemaComposedNodeItem ( )
virtual

Definition at line 116 of file SchemaComposedNodeItem.cxx.

References DEBTRACE.

117 {
118  DEBTRACE("SchemaComposedNodeItem::~SchemaComposedNodeItem");
119 }

Member Function Documentation

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

drop in composed nodes are used for add nodes from catalog, or reparent nodes, or control link

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 356 of file SchemaComposedNodeItem.cxx.

References YACS::HMI::GenericGui::_guiEditor, YACS::HMI::Resource::COMPONENT_INSTANCE_NEW, YACS::HMI::GuiEditor::CreateNodeFromCatalog(), YACS::HMI::SchemaItem::data(), DEBTRACE, YACS::HMI::ItemMimeData::getControl(), YACS::HMI::QtGuiContext::getGMain(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::ItemMimeData::getSubject(), YACS::HMI::SchemaItem::getSubject(), YACS::HMI::SubjectNode::reparent(), PMMLBasicsTestLauncher::ret, and YACS::HMI::SubjectNode::tryCreateLink().

357 {
358  DEBTRACE("SchemaComposedNodeItem::dropMimeData");
359  if (!data) return false;
360  const ItemMimeData* myData = dynamic_cast<const ItemMimeData*>(data);
361  if (!myData) return false;
362  bool ret =false;
363  if (myData->hasFormat("yacs/cataService") || myData->hasFormat("yacs/cataNode"))
364  {
365  ret =true;
366  SubjectComposedNode *cnode = dynamic_cast<SubjectComposedNode*>(getSubject());
367  bool createNewComponentInstance=Resource::COMPONENT_INSTANCE_NEW;
368  // by default getControl gives false. In this case we use the user preference COMPONENT_INSTANCE_NEW
369  // to create the node. If getControl gives true we invert the user preference
370  if(myData->getControl())
371  createNewComponentInstance=!Resource::COMPONENT_INSTANCE_NEW;
372  QtGuiContext::getQtCurrent()->getGMain()->_guiEditor->CreateNodeFromCatalog(myData, cnode,createNewComponentInstance);
373  }
374  else if(myData->hasFormat("yacs/subjectNode"))
375  {
376  ret = true;
377  Subject *sub = myData->getSubject();
378  if (!sub) return false;
379  SubjectNode *node = dynamic_cast<SubjectNode*>(sub);
380  if (!node) return false;
381  SubjectComposedNode *cnode = dynamic_cast<SubjectComposedNode*>(getSubject());
382  if (cnode)
383  if (! node->reparent(cnode))
384  Message mess;
385  }
386  else if(myData->hasFormat("yacs/subjectOutGate"))
387  {
388  Subject *subFrom = myData->getSubject();
389  if (!subFrom) return false;
390  SubjectNode* from = dynamic_cast<SubjectNode*>(subFrom);
391 
392  SubjectNode *to = dynamic_cast<SubjectNode*>(getSubject());
393  if (!to) return false;
394 
395  bool ret =false;
396  if (from && to)
397  {
398  ret =true;
399  if (!SubjectNode::tryCreateLink(from, to))
400  Message mess;
401  }
402  }
403  return ret;
404 }
QVariant SchemaComposedNodeItem::editionWhatsThis ( int  column) const
protectedvirtual

Reimplemented from YACS::HMI::SchemaItem.

Reimplemented in YACS::HMI::SchemaProcItem.

Definition at line 438 of file SchemaComposedNodeItem.cxx.

439 {
440  return "<p>To edit the node properties, select the node and use the input panel. <a href=\"modification.html#property-page-for-block-node\">More...</a></p>";
441 }
Qt::ItemFlags SchemaComposedNodeItem::flags ( const QModelIndex &  index)
virtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 332 of file SchemaComposedNodeItem.cxx.

References YACS::HMI::QtGuiContext::getQtCurrent(), and YACS::HMI::YValue.

333 {
334  //DEBTRACE("SchemaComposedNodeItem::flags");
335  Qt::ItemFlags pflag = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
336  if (!QtGuiContext::getQtCurrent() || !QtGuiContext::getQtCurrent()->isEdition())
337  return pflag;
338 
339  Qt::ItemFlags flagEdit = 0;
340  int column = index.column();
341  switch (column)
342  {
343  case YValue:
344  flagEdit = Qt::ItemIsEditable; // --- item value editable in model view (for node case in switch)
345  break;
346  }
347 
348  return pflag | flagEdit;
349 
350 }
std::list< YACS::ENGINE::Node * > SchemaComposedNodeItem::getDirectDescendants ( ) const

Definition at line 317 of file SchemaComposedNodeItem.cxx.

References YACS::HMI::SchemaItem::_subject, YACS::ENGINE::ComposedNode::edGetDirectDescendants(), YACS::HMI::SubjectNode::getNode(), and YASSERT.

318 {
319  SubjectNode* SNode = dynamic_cast<SubjectNode*>(_subject);
320  YASSERT(SNode);
321  ComposedNode* CNode = dynamic_cast<ComposedNode*>(SNode->getNode());
322  YASSERT(CNode);
323  return CNode->edGetDirectDescendants();
324 }
QString SchemaComposedNodeItem::getMimeFormat ( )
protectedvirtual

drag for composed nodes in tree are used for control link with Left Mouse Button and for reparent with Middle Mouse Button

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 410 of file SchemaComposedNodeItem.cxx.

411 {
412  if (QApplication::mouseButtons() == Qt::MidButton)
413  return "yacs/subjectNode";
414  else
415  return "yacs/subjectOutGate";
416 }
void SchemaComposedNodeItem::popupMenu ( QWidget caller,
const QPoint &  globalPos 
)
virtual

Reimplemented from YACS::HMI::SchemaItem.

Reimplemented in YACS::HMI::SchemaProcItem.

Definition at line 326 of file SchemaComposedNodeItem.cxx.

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

327 {
329  m.popupMenu(caller, globalPos);
330 }
void SchemaComposedNodeItem::setCaseValue ( )
virtual

used in node derived classes

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 418 of file SchemaComposedNodeItem.cxx.

References YACS::HMI::SchemaItem::_itemData, YACS::HMI::SchemaItem::_parentItem, YACS::HMI::SchemaItem::_subject, DEBTRACE, YACS::HMI::SubjectNode::getNode(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::ENGINE::Switch::getRankOfNode(), YACS::HMI::QtGuiContext::getSchemaModel(), YACS::HMI::SchemaItem::getSubject(), YACS::HMI::SchemaItem::modelIndex(), YACS::HMI::SchemaModel::setData(), YASSERT, and YACS::HMI::YValue.

Referenced by SchemaComposedNodeItem().

419 {
420  DEBTRACE("SchemaComposedNodeItem::setCaseValue");
421  Subject *sub = _parentItem->getSubject();
422  SubjectSwitch *sSwitch = dynamic_cast<SubjectSwitch*>(sub);
423  if (!sSwitch) return;
424 
426  Switch *aSwitch = dynamic_cast<Switch*>(sSwitch->getNode());
427  YASSERT(aSwitch);
428  SubjectNode *sNode = dynamic_cast<SubjectNode*>(_subject);
429  YASSERT(sNode);
430  int rank = aSwitch->getRankOfNode(sNode->getNode());
431  if (rank == Switch::ID_FOR_DEFAULT_NODE)
432  _itemData.replace(YValue, "default");
433  else
434  _itemData.replace(YValue, rank);
435  model->setData(modelIndex(YValue), 0);
436 }
void SchemaComposedNodeItem::update ( GuiEvent  event,
int  type,
Subject son 
)
virtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 121 of file SchemaComposedNodeItem.cxx.

References _dirContainersItem, _dirLinksItem, _dirTypesItem, YACS::HMI::SchemaItem::_itemData, YACS::HMI::SchemaItem::_itemForeground, YACS::HMI::QtGuiContext::_mapOfSchemaItem, YACS::HMI::GuiContext::_mapOfSubjectNode, YACS::HMI::SchemaItem::_subject, YACS::HMI::ADD, YACS::HMI::SchemaDirContainersItem::addComponentItem(), YACS::HMI::SchemaDirContainersItem::addContainerItem(), YACS::HMI::ADDCONTROLLINK, YACS::HMI::ADDLINK, YACS::HMI::SchemaDirLinksItem::addLinkItem(), YACS::HMI::SchemaDirTypesItem::addTypeItem(), YACS::HMI::BLOC, YACS::HMI::SchemaItem::childCount(), YACS::HMI::COMPONENT, YACS::HMI::CONTAINER, YACS::HMI::CORBANODE, YACS::HMI::CPPNODE, YACS::HMI::CUT, YACS::HMI::DATATYPE, DEBTRACE, YACS::ENGINE::Switch::edGetNode(), YACS::HMI::GuiObserver::eventName(), YACS::HMI::FOREACHLOOP, YACS::HMI::FORLOOP, YACS::HMI::GuiContext::getCurrent(), YACS::HMI::Subject::getName(), YACS::HMI::SubjectNode::getNode(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSchemaModel(), YACS::ENGINE::Node::getState(), YACS::HMI::SubjectComposedNode::getValue(), YACS::HMI::SubjectSwitch::getValue(), YACS::HMI::SubjectComposedNode::hasValue(), YACS::HMI::SubjectSwitch::hasValue(), YACS::HMI::INPUTDATASTREAMPORT, YACS::HMI::INPUTPORT, YACS::INVALID, YACS::HMI::SchemaItem::modelIndex(), YACS::HMI::OPTIMIZERLOOP, YACS::HMI::OUTNODE, YACS::HMI::OUTPUTDATASTREAMPORT, YACS::HMI::OUTPUTPORT, YACS::HMI::PASTE, YACS::HMI::PRESETNODE, YACS::HMI::PYFUNCNODE, YACS::HMI::PYTHONNODE, YACS::READY, YACS::HMI::REMOVE, YACS::HMI::SchemaItem::removeChild(), YACS::HMI::SchemaDirTypesItem::removeTypeItem(), YACS::HMI::SchemaItem::reparent(), YACS::HMI::SchemaItem::row(), YACS::HMI::SALOMENODE, YACS::HMI::SALOMEPYTHONNODE, SchemaComposedNodeItem(), YACS::HMI::SETCASE, YACS::HMI::SchemaItem::setCaseValue(), YACS::HMI::SchemaModel::setData(), YACS::HMI::SchemaItem::setExecState(), YACS::HMI::SETSELECT, YACS::HMI::SETVALUE, YACS::HMI::STUDYINNODE, YACS::HMI::STUDYOUTNODE, YACS::HMI::SWITCH, YACS::HMI::SchemaItem::update(), YACS::HMI::UPDATE, YACS::HMI::UPDATEPROGRESS, YACS::HMI::WHILELOOP, YACS::HMI::XMLNODE, YASSERT, YACS::HMI::YLabel, YACS::HMI::YState, and YACS::HMI::YType.

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

122 {
123  DEBTRACE("SchemaComposedNodeItem::update "<<eventName(event)<<" "<<type<<" "<<son);
125  SchemaItem *item = 0;
126  SubjectNode *snode = 0;
127  SubjectComposedNode *scnode = 0;
128  Node* node = 0;
129  switch (event)
130  {
131  case YACS::HMI::ADD:
132  switch (type)
133  {
134  case YACS::HMI::BLOC:
135  case YACS::HMI::FORLOOP:
137  case YACS::HMI::SWITCH:
140  {
141  int nbsons = childCount();
142  model->beginInsertRows(modelIndex(), nbsons, nbsons);
143  item = new SchemaComposedNodeItem(this,
144  son->getName().c_str(),
145  son);
146  model->endInsertRows();
147  }
148  break;
152  case YACS::HMI::CPPNODE:
155  case YACS::HMI::XMLNODE:
157  case YACS::HMI::OUTNODE:
160  {
161  int nbsons = childCount();
162  model->beginInsertRows(modelIndex(), nbsons, nbsons);
163  item = new SchemaNodeItem(this,
164  son->getName().c_str(),
165  son);
166  model->endInsertRows();
167  }
168  break;
171  {
172  int nbsons = childCount();
173  model->beginInsertRows(modelIndex(), nbsons, nbsons);
174  item = new SchemaInPortItem(this,
175  son->getName().c_str(),
176  son);
177  model->endInsertRows();
178  }
179  break;
182  {
183  int nbsons = childCount();
184  model->beginInsertRows(modelIndex(), nbsons, nbsons);
185  item = new SchemaOutPortItem(this,
186  son->getName().c_str(),
187  son);
188  model->endInsertRows();
189  }
190  break;
192  {
195  }
196  break;
198  {
201  }
202  break;
203  case YACS::HMI::DATATYPE:
204  {
207  }
208  break;
209  }
210  break;
211 
212  case YACS::HMI::REMOVE:
213  switch (type)
214  {
215  case YACS::HMI::DATATYPE:
216  {
219  }
220  break;
221  }
222  break;
223 
224  case YACS::HMI::UPDATE:
225  snode = dynamic_cast<SubjectNode*>(_subject);
226  YASSERT(snode);
227  node = snode->getNode();
228  YASSERT(node);
229  switch (node->getState())
230  {
231  case YACS::INVALID:
232  _itemForeground.replace(YLabel, QColor("red"));
233  model->setData(modelIndex(YLabel), 0);
234  break;
235  case YACS::READY:
236  _itemForeground.replace(YLabel, QColor("blue"));
237  model->setData(modelIndex(YLabel), 0);
238  break;
239  default:
240  break;
241  }
242  break;
243  case YACS::HMI::ADDLINK:
245  {
248  }
249  break;
251  setExecState(type);
252  model->setData(modelIndex(YState), 0);
253  break;
254  case YACS::HMI::SETVALUE:
255  scnode = dynamic_cast<SubjectComposedNode*>(_subject);
256  if (scnode->hasValue())
257  {
258  _itemData.replace(YType, scnode->getValue().c_str());
259  model->setData(modelIndex(YType), 0);
260  }
261  case YACS::HMI::SETCASE:
262  {
263  SubjectSwitch *sSwitch = dynamic_cast<SubjectSwitch*>(_subject);
264  if (sSwitch)
265  {
266  Switch *aSwitch = dynamic_cast<Switch*>(sSwitch->getNode());
267  Node *node = aSwitch->edGetNode(type);
268  if (node)
269  {
270  if (GuiContext::getCurrent()->_mapOfSubjectNode.count(node))
271  {
273  if (QtGuiContext::getQtCurrent()->_mapOfSchemaItem.count(sub))
274  {
276  item->setCaseValue();
277  }
278  }
279  }
280  }
281  }
282  break;
284  {
285  SubjectSwitch *sSwitch = dynamic_cast<SubjectSwitch*>(_subject);
286  if (sSwitch && sSwitch->hasValue())
287  {
288  _itemData.replace(YType, sSwitch->getValue().c_str());
289  model->setData(modelIndex(YType), 0);
290  }
291  }
292  break;
293  case YACS::HMI::CUT:
294  {
296  int position = toMove->row();
297  model->beginRemoveRows(modelIndex(), position, position);
298  removeChild(toMove);
299  model->endRemoveRows();
300  }
301  break;
302  case YACS::HMI::PASTE:
303  {
305  int nbsons = childCount();
306  model->beginInsertRows(modelIndex(), nbsons, nbsons);
307  toPaste->reparent(this);
308  model->endInsertRows();
309  }
310  break;
311  default:
312  //DEBTRACE("SchemaComposedNodeItem::update(), event not handled: "<< eventName(event));
313  SchemaItem::update(event, type, son);
314  }
315 }

Member Data Documentation

SchemaDirContainersItem* YACS::HMI::SchemaComposedNodeItem::_dirContainersItem
protected

Definition at line 48 of file SchemaComposedNodeItem.hxx.

Referenced by SchemaComposedNodeItem(), and update().

SchemaDirLinksItem* YACS::HMI::SchemaComposedNodeItem::_dirLinksItem
protected

Definition at line 49 of file SchemaComposedNodeItem.hxx.

Referenced by SchemaComposedNodeItem(), and update().

SchemaDirTypesItem* YACS::HMI::SchemaComposedNodeItem::_dirTypesItem
protected

Definition at line 47 of file SchemaComposedNodeItem.hxx.

Referenced by SchemaComposedNodeItem(), and update().


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