Version: 9.16.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 Qt::ItemFlags flags (const QModelIndex &index)
 
virtual int row () const
 
virtual SchemaItemparent ()
 
virtual SubjectgetSubject ()
 
virtual void update (GuiEvent event, int type, Subject *son)
 
virtual void select (bool isSelected)
 
virtual void toggleState ()
 
QModelIndex modelIndex (int column=0)
 
virtual void popupMenu (QWidget *caller, const QPoint &globalPos)
 
virtual ItemMimeDatamimeData (ItemMimeData *mime)
 
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action)
 
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 select (bool isSelected)
 
virtual void update (GuiEvent event, int type, Subject *son)
 
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 editionWhatsThis (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::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.

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();
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}
TypeCode * edGetType() const
Definition: DataPort.hxx:53
virtual std::string getAsString()
returns port value as a string that can be used in a GUI for example
Definition: DataPort.cxx:84
virtual int edGetNumberOfLinks() const
Returns number of physical backlinks NOT number of user backlinks.
Definition: InPort.cxx:45
Base class for Input Ports.
Definition: InputPort.hxx:44
virtual bool edIsManuallyInitialized() const
Specifies if this port has been manually set by the call of InputPort::edInit.
Definition: InputPort.cxx:76
Node * getNode() const
Definition: Port.hxx:46
virtual const char * name() const
Definition: TypeCode.cxx:72
static TypeOfElem getTypeOfPort(YACS::ENGINE::DataPort *port)
static TypeOfElem getTypeOfNode(YACS::ENGINE::Node *node)
QList< QVariant > _itemDeco
Definition: SchemaItem.hxx:78
virtual SchemaItem * parent()
Definition: SchemaItem.cxx:163
SchemaItem(SchemaItem *parent, QString label, Subject *subject)
Definition: SchemaItem.cxx:39
QList< QVariant > _itemForeground
Definition: SchemaItem.hxx:79
QList< QVariant > _itemData
Definition: SchemaItem.hxx:77
virtual YACS::ENGINE::DataPort * getPort()
@ INPUTDATASTREAMPORT

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.

Member Function Documentation

◆ dropMimeData()

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

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 254 of file SchemaInPortItem.cxx.

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}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
virtual bool getControl() const
virtual Subject * getSubject(int i=0) const
virtual Subject * getSubject()
Definition: SchemaItem.cxx:169
virtual QVariant data(int column, int role) const
Definition: SchemaItem.cxx:123
static bool tryCreateLink(SubjectDataPort *subOutport, SubjectDataPort *subInport, bool control=true)

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

◆ editionWhatsThis()

QVariant SchemaInPortItem::editionWhatsThis ( int  column) const
protectedvirtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 294 of file SchemaInPortItem.cxx.

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}

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

◆ flags()

Qt::ItemFlags SchemaInPortItem::flags ( const QModelIndex &  index)
virtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 228 of file SchemaInPortItem.cxx.

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)) &&
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}
Class for data parameters specification.
Definition: DataNode.hxx:38
Class for calculation node (script) inlined (and executed) in the schema.
Definition: InlineNode.hxx:44
Base class for all nodes.
Definition: Node.hxx:70
static QtGuiContext * getQtCurrent()

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

◆ popupMenu()

void SchemaInPortItem::popupMenu ( QWidget caller,
const QPoint &  globalPos 
)
virtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 288 of file SchemaInPortItem.cxx.

289{
291 m.popupMenu(caller, globalPos);
292}

References gui.GraphViewer::m.

◆ update()

void SchemaInPortItem::update ( GuiEvent  event,
int  type,
Subject son 
)
virtual

Reimplemented from YACS::HMI::SchemaItem.

Definition at line 119 of file SchemaInPortItem.cxx.

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());
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());
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}
YACS::HMI::SchemaModel * getSchemaModel()
QModelIndex modelIndex(int column=0)
Definition: SchemaItem.cxx:253
virtual void update(GuiEvent event, int type, Subject *son)
Definition: SchemaItem.cxx:174
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)

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().

Member Data Documentation

◆ _isDataStream

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: