Version: 8.3.0
YACS::HMI::SchemaNodeItem Class Reference

#include <SchemaNodeItem.hxx>

Inheritance diagram for YACS::HMI::SchemaNodeItem:
Collaboration diagram for YACS::HMI::SchemaNodeItem:

Public Member Functions

 SchemaNodeItem (SchemaItem *parent, QString label, Subject *subject)
 
virtual ~SchemaNodeItem ()
 
virtual void update (GuiEvent event, int type, Subject *son)
 
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 toggleState ()
 
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)
 
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)
 

Additional Inherited Members

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

Detailed Description

Definition at line 29 of file SchemaNodeItem.hxx.

Constructor & Destructor Documentation

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

Definition at line 45 of file SchemaNodeItem.cxx.

References YACS::HMI::SchemaItem::_itemCheckState, YACS::HMI::SchemaItem::_itemDeco, DEBTRACE, YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSchemaModel(), YACS::HMI::SchemaModel::isEdition(), setCaseValue(), YACS::HMI::SchemaItem::setExecState(), YACS::UNDEFINED, and YACS::HMI::YLabel.

46  : SchemaItem(parent, label, subject)
47 {
48  DEBTRACE("SchemaNodeItem::SchemaNodeItem");
49  _itemDeco.replace(YLabel, QIcon("icons:node.png"));
51  if (!model->isEdition())
52  {
53  _itemCheckState.replace(YLabel, Qt::Unchecked);
55  }
56  setCaseValue();
57 }
SchemaNodeItem::~SchemaNodeItem ( )
virtual

Definition at line 59 of file SchemaNodeItem.cxx.

References DEBTRACE.

60 {
61  DEBTRACE("SchemaNodeItem::~SchemaNodeItem");
62 }

Member Function Documentation

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

drop in nodes are used for control link

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 237 of file SchemaNodeItem.cxx.

References YACS::HMI::SchemaItem::data(), DEBTRACE, YACS::HMI::ItemMimeData::getSubject(), YACS::HMI::SchemaItem::getSubject(), PMMLBasicsTestLauncher::ret, and YACS::HMI::SubjectNode::tryCreateLink().

238 {
239  DEBTRACE("SchemaNodeItem::dropMimeData");
240  if (!data) return false;
241  const ItemMimeData* myData = dynamic_cast<const ItemMimeData*>(data);
242  if (!myData) return false;
243  if(!myData->hasFormat("yacs/subjectOutGate")) return false;
244 
245  Subject *subFrom = myData->getSubject();
246  if (!subFrom) return false;
247  SubjectNode* from = dynamic_cast<SubjectNode*>(subFrom);
248 
249  SubjectNode *to = dynamic_cast<SubjectNode*>(getSubject());
250  if (!to) return false;
251 
252  bool ret =false;
253  if (from && to)
254  {
255  ret =true;
256  if (!SubjectNode::tryCreateLink(from, to))
257  Message mess;
258  }
259  return ret;
260 }
QVariant SchemaNodeItem::editionWhatsThis ( int  column) const
protectedvirtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 282 of file SchemaNodeItem.cxx.

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

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 185 of file SchemaNodeItem.cxx.

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

186 {
187  Qt::ItemFlags pflag = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsDropEnabled;
188  if ( !QtGuiContext::getQtCurrent() || !QtGuiContext::getQtCurrent()->isEdition())
189  return pflag;
190 
191  if (QtGuiContext::getQtCurrent()->isEdition())
192  pflag = pflag | Qt::ItemIsDragEnabled;
193  Qt::ItemFlags flagEdit = 0;
194  int column = index.column();
195  switch (column)
196  {
197  case YValue:
198  flagEdit = Qt::ItemIsEditable; // --- item value editable in model view (for node case in switch)
199  break;
200  }
201 
202  return pflag | flagEdit;
203 }
QString SchemaNodeItem::getMimeFormat ( )
protectedvirtual

drag for 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 209 of file SchemaNodeItem.cxx.

210 {
211  if (QApplication::mouseButtons() == Qt::MidButton)
212  return "yacs/subjectNode";
213  else
214  return "yacs/subjectOutGate";
215 }
void SchemaNodeItem::popupMenu ( QWidget caller,
const QPoint &  globalPos 
)
virtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 179 of file SchemaNodeItem.cxx.

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

180 {
182  m.popupMenu(caller, globalPos);
183 }
void SchemaNodeItem::setCaseValue ( )
virtual

used in node derived classes

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 262 of file SchemaNodeItem.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 SchemaNodeItem().

263 {
264  DEBTRACE("SchemaNodeItem::setCaseValue");
265  Subject *sub = _parentItem->getSubject();
266  SubjectSwitch *sSwitch = dynamic_cast<SubjectSwitch*>(sub);
267  if (!sSwitch) return;
268 
270  Switch *aSwitch = dynamic_cast<Switch*>(sSwitch->getNode());
271  YASSERT(aSwitch);
272  SubjectNode *sNode = dynamic_cast<SubjectNode*>(_subject);
273  YASSERT(sNode);
274  int rank = aSwitch->getRankOfNode(sNode->getNode());
275  if (rank == Switch::ID_FOR_DEFAULT_NODE)
276  _itemData.replace(YValue, "default");
277  else
278  _itemData.replace(YValue, rank);
279  model->setData(modelIndex(YValue), 0);
280 }
void SchemaNodeItem::toggleState ( )
virtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 217 of file SchemaNodeItem.cxx.

References YACS::HMI::SchemaItem::_itemCheckState, YACS::HMI::GuiExecutor::addBreakpoint(), DEBTRACE, YACS::ENGINE::ComposedNode::getChildName(), YACS::HMI::QtGuiContext::getGuiExecutor(), YACS::HMI::SubjectNode::getNode(), YACS::HMI::GuiContext::getProc(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::SchemaItem::getSubject(), YACS::HMI::GuiExecutor::removeBreakpoint(), YACS::HMI::SchemaItem::toggleState(), YASSERT, and YACS::HMI::YLabel.

218 {
219  DEBTRACE("SchemaNodeItem::toggleState");
222  YASSERT(guiExec);
223  SubjectNode *subjectNode = dynamic_cast<SubjectNode*>(getSubject());
224  YASSERT(subjectNode);
225  string nodeName = QtGuiContext::getQtCurrent()->getProc()->getChildName(subjectNode->getNode());
226  DEBTRACE("nodeName=" << nodeName);
227 
228  if (_itemCheckState.value(YLabel) == Qt::Checked) // already toggled
229  guiExec->addBreakpoint(nodeName);
230  else
231  guiExec->removeBreakpoint(nodeName);
232 }
void SchemaNodeItem::update ( GuiEvent  event,
int  type,
Subject son 
)
virtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 64 of file SchemaNodeItem.cxx.

References YACS::HMI::SchemaItem::_itemForeground, YACS::HMI::QtGuiContext::_mapOfSchemaItem, YACS::HMI::GuiContext::_mapOfSubjectDataPort, YACS::HMI::SchemaItem::_subject, YACS::HMI::ADD, YACS::HMI::SchemaItem::appendChild(), YACS::HMI::SchemaItem::child(), YACS::HMI::SchemaItem::childCount(), DEBTRACE, YACS::HMI::GuiObserver::eventName(), YACS::HMI::Subject::getName(), YACS::HMI::SubjectNode::getNode(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSchemaModel(), YACS::ENGINE::ElementaryNode::getSetOfInputPort(), YACS::ENGINE::ElementaryNode::getSetOfOutputPort(), YACS::ENGINE::Node::getState(), CORBAEngineTest::i, YACS::HMI::INPUTDATASTREAMPORT, YACS::HMI::INPUTPORT, YACS::INVALID, YACS::HMI::SchemaItem::modelIndex(), YACS::HMI::ORDER, YACS::HMI::OUTPUTDATASTREAMPORT, YACS::HMI::OUTPUTPORT, YACS::READY, YACS::HMI::SchemaItem::removeChild(), YACS::HMI::SchemaModel::setData(), YACS::HMI::SchemaItem::setExecState(), YACS::HMI::SchemaItem::update(), YACS::HMI::UPDATE, YACS::HMI::UPDATEPROGRESS, YASSERT, YACS::HMI::YLabel, and YACS::HMI::YState.

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

65 {
66  DEBTRACE("SchemaNodeItem::update "<<eventName(event)<<" "<<type<<" "<<son);
68  SchemaItem *item = 0;
69  SubjectNode *snode = 0;
70  Node* node = 0;
71  switch (event)
72  {
73  case YACS::HMI::ADD:
74  switch (type)
75  {
78  {
79  int nbsons = childCount();
80  model->beginInsertRows(modelIndex(), nbsons, nbsons);
81  item = new SchemaInPortItem(this,
82  son->getName().c_str(),
83  son);
84  model->endInsertRows();
85  }
86  break;
89  {
90  int nbsons = childCount();
91  model->beginInsertRows(modelIndex(), nbsons, nbsons);
92  item = new SchemaOutPortItem(this,
93  son->getName().c_str(),
94  son);
95  model->endInsertRows();
96  }
97  break;
98 // default:
99 // DEBTRACE("SchemaNodeItem::update(), ADD, type not handled: " << type);
100  }
101  break;
102  case YACS::HMI::ORDER:
103  {
104  YASSERT(QtGuiContext::getQtCurrent()->_mapOfSchemaItem.count(son));
105  //bool isInput = dynamic_cast<SubjectInputPort*>(son);
106 
107  snode = dynamic_cast<SubjectNode*>(_subject);
108  YASSERT(snode);
109  Node* node = snode->getNode();
110  ElementaryNode* father = dynamic_cast<ElementaryNode*>(node);
111  YASSERT(father);
112  int nbChildren = childCount();
113 
114  model->beginRemoveRows(modelIndex(), 0, nbChildren-1);
115  for (int i = nbChildren; i >= 0; i--)
116  removeChild(child(i));
117  model->endRemoveRows();
118 
119  list<InputPort*> plisti = father->getSetOfInputPort();
120  int nbIn = plisti.size();
121  if (nbIn)
122  {
123  model->beginInsertRows(modelIndex(), 0, nbIn-1);
124  list<InputPort*>::iterator iti = plisti.begin();
125  for(; iti != plisti.end(); iti++)
126  {
129  appendChild(item);
130  }
131  model->endInsertRows();
132  }
133 
134  list<OutputPort*> plisto = father->getSetOfOutputPort();
135  int nbOut = plisto.size();
136  if (nbOut)
137  {
138  model->beginInsertRows(modelIndex(), nbIn, nbIn + nbOut -1);
139  list<OutputPort*>::iterator ito = plisto.begin();
140  for(; ito != plisto.end(); ito++)
141  {
144  appendChild(item);
145  }
146  model->endInsertRows();
147  }
148  }
149  break;
150  case YACS::HMI::UPDATE:
151  snode = dynamic_cast<SubjectNode*>(_subject);
152  YASSERT(snode);
153  node = snode->getNode();
154  YASSERT(node);
155  switch (node->getState())
156  {
157  case YACS::INVALID:
158  _itemForeground.replace(YLabel, QColor("red"));
159  model->setData(modelIndex(YLabel), 0); // --- to emit dataChanged signal
160  break;
161  case YACS::READY:
162  _itemForeground.replace(YLabel, QColor("blue"));
163  model->setData(modelIndex(YLabel), 0);
164  break;
165  default:
166  break;
167  }
168  break;
170  setExecState(type);
171  model->setData(modelIndex(YState), 0);
172  break;
173  default:
174  //DEBTRACE("SchemaNodeItem::update(), event not handled: " << eventName(event));
175  SchemaItem::update(event, type, son);
176  }
177 }

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