Version: 9.16.0
YACS::HMI::GuiEditor Class Reference

#include <GuiEditor.hxx>

Collaboration diagram for YACS::HMI::GuiEditor:

Public Member Functions

 GuiEditor ()
 
virtual ~GuiEditor ()
 
void CreateNodeFromCatalog (const ItemMimeData *myData, SubjectComposedNode *cnode, bool createNewComponentInstance)
 
void AddTypeFromCatalog (const ItemMimeData *myData)
 
SubjectNodeCreateNode (std::string typeNode)
 
void CreateBloc ()
 
void CreateForLoop ()
 
void CreateForEachLoop (std::string type)
 
void CreateWhileLoop ()
 
void CreateSwitch ()
 
void CreateOptimizerLoop ()
 
void CreateContainer ()
 
void CreateHPContainer ()
 
void CreateComponentInstance ()
 
SubjectDataPortCreateInputPort (SubjectElementaryNode *seNode, std::string name, YACS::ENGINE::Catalog *catalog, std::string type="double", SubjectDataPort *before=0)
 
SubjectDataPortCreateOutputPort (SubjectElementaryNode *seNode, std::string name, YACS::ENGINE::Catalog *catalog, std::string type="double", SubjectDataPort *before=0)
 
void DeleteSubject ()
 
void DeleteSubject (Subject *parent, Subject *toRemove)
 
void CutSubject ()
 
void CopySubject ()
 
void PasteSubject ()
 
void PutSubjectInBloc ()
 
std::string PutGraphInBloc ()
 
void PutGraphInNode (std::string typeNode)
 
void shrinkExpand (Qt::KeyboardModifiers kbModifiers=Qt::NoModifier)
 
void rebuildLinks ()
 
void arrangeNodes (bool isRecursive)
 
void arrangeProc ()
 
void showUndo (QWidget *parent=0)
 
void showRedo (QWidget *parent=0)
 
QString asciiFilter (const QString &name)
 

Protected Member Functions

SubjectNode_createNode (YACS::ENGINE::Catalog *catalog, SubjectComposedNode *cnode, std::string service, std::string compoName, bool createNewComponentInstance)
 

Protected Attributes

std::string _table
 

Detailed Description

Definition at line 44 of file GuiEditor.hxx.

Constructor & Destructor Documentation

◆ GuiEditor()

GuiEditor::GuiEditor ( )

Definition at line 53 of file GuiEditor.cxx.

54{
55 // approximative conversion from latin1 to US ascii (removing accentuation)
56 DEBTRACE("GuiEditor::GuiEditor");
57 _table = "________________" ; // 0 - 15
58 _table += "________________" ; // 16 - 31
59 _table += " !\"#$%&'()*+,-./" ; // 32 - 47
60 _table += "0123456789:;<=>?" ; // 48 - 63
61 _table += "@ABCDEFGHIJKLMNO" ; // 64 - 79
62 _table += "PQRSTUVWXYZ[\\]^_" ; // 80 - 95
63 _table += "`abcdefghijklmno" ; // 96 - 111
64 _table += "pqrstuvwxyz{|}~_" ; // 112 - 127
65 _table += "________________" ; // 128 - 143
66 _table += "________________" ; // 144 - 159
67 _table += "_icLoY|-_ca-__r-" ; // 160 - 175
68 _table += "-_23'u_..10\"___?" ; // 176 - 191
69 _table += "AAAAAAACEEEEIIII" ; // 192 - 207
70 _table += "DNOOOOOx0UUUUYPB" ; // 208 - 223
71 _table += "aaaaaaaceeeeiiii" ; // 224 - 239
72 _table += "onooooo-0uuuuypy" ; // 240 - 255
73 //_table[167] = char(167); // '§'
74 //_table[176] = char(176); // '°'
75 DEBTRACE(_table.size() << " " << _table);
76}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
std::string _table
Definition: GuiEditor.hxx:100

References _table, and DEBTRACE.

◆ ~GuiEditor()

GuiEditor::~GuiEditor ( )
virtual

Definition at line 78 of file GuiEditor.cxx.

79{
80 DEBTRACE("GuiEditor::~GuiEditor");
81}

References DEBTRACE.

Member Function Documentation

◆ _createNode()

SubjectNode * GuiEditor::_createNode ( YACS::ENGINE::Catalog catalog,
SubjectComposedNode cnode,
std::string  service,
std::string  compoName,
bool  createNewComponentInstance 
)
protected

Definition at line 121 of file GuiEditor.cxx.

126{
127 SubjectNode* aNewNode = 0;
128
129 // --- find a name not used
130
131 string name = service;
132 if (name == "PresetNode")
133 name = "DataIn";
134 Node *node =cnode->getNode();
135 ComposedNode *father = dynamic_cast<ComposedNode*>(node);
136 YASSERT(father);
137 list<Node*> children = father->edGetDirectDescendants();
138 bool nameInUse = true;
139 std::stringstream tryname;
140 while (nameInUse)
141 {
142 nameInUse = false;
143 long newid = GuiContext::getCurrent()->getNewId();
144 tryname.str("");
145 tryname << name << newid;
146 if (newid > 100000) break;
147 for (list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
148 {
149 if ((*it)->getName() == tryname.str())
150 nameInUse = true;
151 }
152 }
153 name = tryname.str();
154
155 int swCase = 0;
156 SubjectSwitch *aSwitch = dynamic_cast<SubjectSwitch*>(cnode);
157 if (aSwitch)
158 {
159 map<int, SubjectNode*> bodyMap = aSwitch->getBodyMap();
160 if (bodyMap.empty()) swCase = 1;
161 else
162 {
163 map<int, SubjectNode*>::reverse_iterator rit = bodyMap.rbegin();
164 swCase = (*rit).first + 1;
165 }
166 aNewNode = aSwitch->addNode(catalog, compoName, service, name, createNewComponentInstance, swCase);
167 if (!aNewNode)
168 Message mess;
169 }
170 else if (cnode && (dynamic_cast<SubjectBloc*>(cnode) == 0) && cnode->getChild() != 0)
171 {
172 // loop with a body : can't add a node
173 QMessageBox msgBox;
174 std::string msg;
175 msg="This loop has already a body. It is not possible to add directly another node\n";
176 msg=msg+"Do you want to put the existing node in a bloc and add the new node in this bloc ?\n";
177 msgBox.setText(msg.c_str());
178 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No );
179 msgBox.setDefaultButton(QMessageBox::No);
180 int ret = msgBox.exec();
181 if(ret == QMessageBox::Yes)
182 {
183 // User wants to put body node in bloc
184 if (cnode->getChild()->putInComposedNode("Bloc1","Bloc"))
185 {
186 //the bloc has been successfully created. Add the new node
187 SubjectBloc* newbloc = dynamic_cast<SubjectBloc*>(cnode->getChild());
188 aNewNode = newbloc->addNode(catalog, compoName, service, name, createNewComponentInstance);
189 if (!aNewNode)
190 Message mess;
191 }
192 else
193 Message mess;
194 }
195 }
196 else if (cnode)
197 aNewNode = cnode->addNode(catalog, compoName, service, name, createNewComponentInstance);
198 if (!aNewNode)
199 Message mess;
200 return aNewNode;
201}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
Base class for all composed nodes.
virtual std::list< Node * > edGetDirectDescendants() const =0
Base class for all nodes.
Definition: Node.hxx:70
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
long getNewId(YACS::HMI::TypeOfElem type)
Definition: guiContext.cxx:107
virtual SubjectNode * addNode(YACS::ENGINE::Catalog *catalog, std::string compo, std::string type, std::string name, bool newCompoInst)
virtual SubjectNode * addNode(YACS::ENGINE::Catalog *catalog, std::string compo, std::string type, std::string name, bool newCompoInst)
virtual SubjectNode * getChild(YACS::ENGINE::Node *node=0) const
virtual YACS::ENGINE::Node * getNode()
virtual bool putInComposedNode(std::string name, std::string type, bool toSaveRestoreLinks=true)
virtual SubjectNode * addNode(YACS::ENGINE::Catalog *catalog, std::string compo, std::string type, std::string name, bool newCompoInst, int swCase, bool replace=false)
std::map< int, SubjectNode * > getBodyMap()

References YACS::HMI::SubjectComposedNode::addNode(), YACS::HMI::SubjectBloc::addNode(), YACS::HMI::SubjectSwitch::addNode(), YACS::ENGINE::ComposedNode::edGetDirectDescendants(), YACS::HMI::SubjectSwitch::getBodyMap(), YACS::HMI::SubjectComposedNode::getChild(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getNewId(), YACS::HMI::SubjectNode::getNode(), YACS::HMI::SubjectNode::putInComposedNode(), and YASSERT.

Referenced by CreateNode(), and CreateNodeFromCatalog().

◆ AddTypeFromCatalog()

void GuiEditor::AddTypeFromCatalog ( const ItemMimeData myData)

Definition at line 203 of file GuiEditor.cxx.

204{
205 DEBTRACE("GuiEditor::AddTypeFromCatalog");
207 int nb = myData->getDataSize();
208 DEBTRACE(nb);
209 for (int i=0; i<nb; i++)
210 {
211 Catalog* catalog = myData->getCatalog(i);
212 DEBTRACE("catalog " << catalog);
213 string aType = myData->getType(i);
214 DEBTRACE(aType);
215 sProc->addDataType(catalog, aType);
216 }
217}
class for YACS catalogs.
Definition: Catalog.hxx:42
YACS::HMI::SubjectProc * getSubjectProc()
Definition: guiContext.hxx:52
virtual int getDataSize() const
virtual std::string getType(int i=0) const
virtual YACS::ENGINE::Catalog * getCatalog(int i=0) const
static QtGuiContext * getQtCurrent()
virtual bool addDataType(YACS::ENGINE::Catalog *catalog, std::string typeName)

References YACS::HMI::SubjectProc::addDataType(), DEBTRACE, YACS::HMI::ItemMimeData::getCatalog(), YACS::HMI::ItemMimeData::getDataSize(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::GuiContext::getSubjectProc(), YACS::HMI::ItemMimeData::getType(), and yacsorb.CORBAEngineTest::i.

Referenced by YACS::HMI::SchemaDirTypesItem::dropMimeData().

◆ arrangeNodes()

void GuiEditor::arrangeNodes ( bool  isRecursive)

Definition at line 659 of file GuiEditor.cxx.

660{
662 if (!sub)
663 {
664 DEBTRACE("GuiEditor::arrangeNodes : invalid selection!");
665 return;
666 }
667 DEBTRACE(sub->getName());
668
669 if (! QtGuiContext::getQtCurrent()->_mapOfSceneItem.count(sub))
670 {
671 DEBTRACE("no scene item corresponding to this subject");
672 return;
673 }
675 SceneComposedNodeItem *sci = dynamic_cast<SceneComposedNodeItem*>(item);
676 if (! sci)
677 {
678 DEBTRACE("no scene composed node item corresponding to this subject");
679 return;
680 }
681 sci->arrangeNodes(isRecursive);
682// if (Scene::_autoComputeLinks && !QtGuiContext::getQtCurrent()->isLoading())
683// {
684// YACS::HMI::SubjectProc* subproc = QtGuiContext::getQtCurrent()->getSubjectProc();
685// SceneItem *item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[subproc];
686// SceneComposedNodeItem *proc = dynamic_cast<SceneComposedNodeItem*>(item);
687// proc->rebuildLinks();
688// }
689}
YACS::HMI::Subject * getSelectedSubject()
std::map< YACS::HMI::Subject *, YACS::HMI::SceneItem * > _mapOfSceneItem
virtual void arrangeNodes(bool isRecursive)
generic method to compute a graph for child nodes. implemented in some derived classes
virtual std::string getName()

References YACS::HMI::QtGuiContext::_mapOfSceneItem, YACS::HMI::SceneComposedNodeItem::arrangeNodes(), DEBTRACE, YACS::HMI::Subject::getName(), YACS::HMI::QtGuiContext::getQtCurrent(), and YACS::HMI::QtGuiContext::getSelectedSubject().

Referenced by YACS::HMI::GenericGui::onArrangeLocalNodes(), YACS::HMI::GenericGui::onArrangeRecurseNodes(), YACS::HMI::GenericGui::onPutGraphInBloc(), and PutGraphInNode().

◆ arrangeProc()

◆ asciiFilter()

QString GuiEditor::asciiFilter ( const QString &  name)

Replace accentuated characters from latin1 to US ascii equivalent without accent. I did not found anything to do that in Qt...

Definition at line 716 of file GuiEditor.cxx.

717{
718 DEBTRACE(name.toStdString());
719 string aName = name.toLatin1().data();
720 DEBTRACE(aName);
721 for (int i=0; i < aName.size(); i++)
722 {
723 int v = (unsigned char)(aName[i]);
724 DEBTRACE(v << " " << _table[v]);
725 aName[i] = _table[v];
726 }
727 DEBTRACE(aName);
728 return aName.c_str();
729}

References _table, DEBTRACE, and yacsorb.CORBAEngineTest::i.

Referenced by YACS::HMI::GenericGui::getSaveFileName().

◆ CopySubject()

void GuiEditor::CopySubject ( )

Definition at line 477 of file GuiEditor.cxx.

478{
479 DEBTRACE("GuiEditor::CopySubject");
480 if (!QtGuiContext::getQtCurrent()->isEdition()) return;
482 if (!sub)
483 {
484 Message mess("GuiEditor::Copy : invalid selection!");
485 return;
486 }
487 DEBTRACE(sub->getName());
489}
void setSubjectToCopy(YACS::HMI::Subject *sub)

References DEBTRACE, YACS::HMI::Subject::getName(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSelectedSubject(), and YACS::HMI::QtGuiContext::setSubjectToCopy().

Referenced by YACS::HMI::GenericGui::onCopyItem().

◆ CreateBloc()

void GuiEditor::CreateBloc ( )

Definition at line 219 of file GuiEditor.cxx.

220{
221 DEBTRACE("GuiEditor::CreateBloc");
222 CreateNode("Bloc");
223}
SubjectNode * CreateNode(std::string typeNode)
Definition: GuiEditor.cxx:98

References CreateNode(), and DEBTRACE.

Referenced by YACS::HMI::GenericGui::onBlockNode().

◆ CreateComponentInstance()

void GuiEditor::CreateComponentInstance ( )

Definition at line 301 of file GuiEditor.cxx.

302{
303 DEBTRACE("GuiEditor::CreateComponentInstance");
305 YASSERT(sproc);
307 SubjectComponent *sco = dynamic_cast<SubjectComponent*>(sub);
308 if (!sco)
309 {
310 DEBTRACE("GuiEditor::CreateComponentInstance: " << "selection is not a component");
311 return;
312 }
313 string compoName = sco->getComponent()->getCompoName();
314 string containerName = sco->getComponent()->getContainer()->getName();
315 sproc->addComponent(compoName, containerName);
316}
const std::string & getCompoName() const
virtual std::string getName() const
Definition: Container.hxx:81
YACS::ENGINE::ComponentInstance * getComponent() const
virtual SubjectComponent * addComponent(std::string compoName, std::string containerName="")

References YACS::HMI::SubjectProc::addComponent(), DEBTRACE, YACS::ENGINE::ComponentInstance::getCompoName(), YACS::HMI::SubjectComponent::getComponent(), YACS::ENGINE::ComponentInstance::getContainer(), YACS::ENGINE::Container::getName(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSelectedSubject(), YACS::HMI::GuiContext::getSubjectProc(), and YASSERT.

Referenced by YACS::HMI::GenericGui::onNewSalomeComponent().

◆ CreateContainer()

void GuiEditor::CreateContainer ( )

Definition at line 267 of file GuiEditor.cxx.

268{
269 DEBTRACE("GuiEditor::CreateContainer");
271 YASSERT(sproc);
272 SubjectContainerBase *scont = 0;
273 while (!scont)
274 {
275 std::stringstream name;
276 long newid = GuiContext::getCurrent()->getNewId();
277 if (newid > 100000) break;
278 name.str("");
279 name << "container" << newid;
280 scont = sproc->addContainer(name.str());
281 }
282}
virtual SubjectContainerBase * addContainer(std::string name, std::string ref="")

References YACS::HMI::SubjectProc::addContainer(), DEBTRACE, YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getNewId(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::GuiContext::getSubjectProc(), and YASSERT.

Referenced by YACS::HMI::GenericGui::onNewContainer().

◆ CreateForEachLoop()

void GuiEditor::CreateForEachLoop ( std::string  type)

Definition at line 231 of file GuiEditor.cxx.

232{
233 DEBTRACE("GuiEditor::CreateForEachLoop");
234 // The ForEachLoop node for datatype type must exist in builtin catalog
235 // So create it in builtin catalog if it does not exist and datatype is loaded in the current Proc
238 std::string typeName="ForEachLoop_"+type;
239 if (!catalog->_composednodeMap.count(typeName))
240 {
241 if(proc->typeMap.count(type))
242 {
243 catalog->_composednodeMap[typeName]=new ForEachLoop(typeName,proc->typeMap[type]);
244 }
245 }
246 CreateNode(typeName);
247}
std::map< std::string, ComposedNode * > _composednodeMap
Definition: Catalog.hxx:52
Loop node for parametric calculation.
Base class for all schema objects.
Definition: Proc.hxx:44
std::map< std::string, TypeCode * > typeMap
Definition: Proc.hxx:90
Catalog * getBuiltinCatalog()
Get the catalog of base nodes (elementary and composed)
Definition: Runtime.cxx:314
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
YACSRUNTIMESALOME_EXPORT RuntimeSALOME * getSALOMERuntime()

References YACS::ENGINE::Catalog::_composednodeMap, CreateNode(), DEBTRACE, YACS::ENGINE::Runtime::getBuiltinCatalog(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getProc(), YACS::ENGINE::getSALOMERuntime(), and YACS::ENGINE::Proc::typeMap.

Referenced by YACS::HMI::GenericGui::createForEachLoop().

◆ CreateForLoop()

void GuiEditor::CreateForLoop ( )

Definition at line 225 of file GuiEditor.cxx.

226{
227 DEBTRACE("GuiEditor::CreateForLoop");
228 CreateNode("ForLoop");
229}

References CreateNode(), and DEBTRACE.

Referenced by YACS::HMI::GenericGui::onFORNode().

◆ CreateHPContainer()

void GuiEditor::CreateHPContainer ( )

Definition at line 284 of file GuiEditor.cxx.

285{
286 DEBTRACE("GuiEditor::CreateHPContainer");
288 YASSERT(sproc);
289 SubjectContainerBase *scont = 0;
290 while (!scont)
291 {
292 std::stringstream name;
293 long newid = GuiContext::getCurrent()->getNewId();
294 if (newid > 100000) break;
295 name.str("");
296 name << "container" << newid;
297 scont = sproc->addHPContainer(name.str());
298 }
299}
virtual SubjectContainerBase * addHPContainer(std::string name, std::string ref="")

References YACS::HMI::SubjectProc::addHPContainer(), DEBTRACE, YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getNewId(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::GuiContext::getSubjectProc(), and YASSERT.

Referenced by YACS::HMI::GenericGui::onNewHPContainer().

◆ CreateInputPort()

SubjectDataPort * GuiEditor::CreateInputPort ( SubjectElementaryNode seNode,
std::string  name,
YACS::ENGINE::Catalog catalog,
std::string  type = "double",
SubjectDataPort before = 0 
)

Definition at line 319 of file GuiEditor.cxx.

324{
325 DEBTRACE("GuiEditor::CreateInputPort");
326 SubjectDataPort *sdp = 0;
327 if (name.empty())
328 {
329 std::stringstream aName;
330 long newid = 0;
331 while (newid < 100000)
332 {
333 newid = GuiContext::getCurrent()->getNewId();
334 aName.str("");
335 aName << "i" << newid;
336 try
337 {
338 seNode->getNode()->getInputPort(aName.str());
339 }
340 catch(Exception& ex)
341 {
342 break;
343 }
344 }
345 sdp = seNode->addInputPort(catalog,type, aName.str());
346 }
347 else
348 sdp = seNode->addInputPort(catalog,type, name);
349 if (!sdp)
350 Message mess;
351 return sdp;
352}
virtual InputPort * getInputPort(const std::string &name) const
Definition: Node.cxx:260
virtual SubjectDataPort * addInputPort(YACS::ENGINE::Catalog *catalog, std::string type, std::string name)

References YACS::HMI::SubjectElementaryNode::addInputPort(), DEBTRACE, testCppPluginInvokation::ex, YACS::HMI::GuiContext::getCurrent(), YACS::ENGINE::Node::getInputPort(), YACS::HMI::GuiContext::getNewId(), and YACS::HMI::SubjectNode::getNode().

Referenced by YACS::HMI::TablePortsEdition::oncb_insert_activated().

◆ CreateNode()

SubjectNode * GuiEditor::CreateNode ( std::string  typeNode)

Definition at line 98 of file GuiEditor.cxx.

99{
100 DEBTRACE("GuiEditor::CreateNode " << typeNode);
102
104 if (!sub)
105 {
106 DEBTRACE("GuiEditor::CreateNode : invalid selection!");
107 return 0;
108 }
109 DEBTRACE(sub->getName());
110
112 if (!cnode)
113 {
114 DEBTRACE("GuiEditor::CreateNode : no ComposedNode selected!");
115 return 0;
116 }
117
118 return _createNode(catalog, cnode, typeNode, "", Resource::COMPONENT_INSTANCE_NEW);
119}
SubjectNode * _createNode(YACS::ENGINE::Catalog *catalog, SubjectComposedNode *cnode, std::string service, std::string compoName, bool createNewComponentInstance)
Definition: GuiEditor.cxx:121
static bool COMPONENT_INSTANCE_NEW
Definition: Resource.hxx:206

References _createNode(), YACS::HMI::Resource::COMPONENT_INSTANCE_NEW, DEBTRACE, YACS::ENGINE::Runtime::getBuiltinCatalog(), YACS::HMI::Subject::getName(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::ENGINE::getSALOMERuntime(), and YACS::HMI::QtGuiContext::getSelectedSubject().

Referenced by CreateBloc(), CreateForEachLoop(), CreateForLoop(), CreateOptimizerLoop(), CreateSwitch(), CreateWhileLoop(), YACS::HMI::GenericGui::onCORBAServiceNode(), YACS::HMI::GenericGui::onCppNode(), YACS::HMI::GenericGui::onInDataNode(), YACS::HMI::GenericGui::onInlineFunctionNode(), YACS::HMI::GenericGui::onInlineScriptNode(), YACS::HMI::GenericGui::onInStudyNode(), YACS::HMI::GenericGui::onOutDataNode(), YACS::HMI::GenericGui::onOutStudyNode(), YACS::HMI::GenericGui::onSalomeServiceNode(), YACS::HMI::GenericGui::onServiceInlineNode(), YACS::HMI::GenericGui::onXMLNode(), and PutGraphInNode().

◆ CreateNodeFromCatalog()

void GuiEditor::CreateNodeFromCatalog ( const ItemMimeData myData,
SubjectComposedNode cnode,
bool  createNewComponentInstance 
)

Definition at line 83 of file GuiEditor.cxx.

84{
85 DEBTRACE("GuiEditor::CreateNodeFromCatalog");
86 int nb = myData->getDataSize();
87 DEBTRACE(nb);
88 for (int i=0; i<nb; i++)
89 {
90 Catalog* catalog = myData->getCatalog(i);
91 string compoName = myData->getCompo(i);
92 string service = myData->getType(i);
93 DEBTRACE(compoName << "/" << service);
94 _createNode(catalog, cnode, service, compoName,createNewComponentInstance);
95 }
96}
virtual std::string getCompo(int i=0) const

References _createNode(), DEBTRACE, YACS::HMI::ItemMimeData::getCatalog(), YACS::HMI::ItemMimeData::getCompo(), YACS::HMI::ItemMimeData::getDataSize(), YACS::HMI::ItemMimeData::getType(), and yacsorb.CORBAEngineTest::i.

Referenced by YACS::HMI::SceneComposedNodeItem::dropEvent(), and YACS::HMI::SchemaComposedNodeItem::dropMimeData().

◆ CreateOptimizerLoop()

void GuiEditor::CreateOptimizerLoop ( )

Definition at line 261 of file GuiEditor.cxx.

262{
263 DEBTRACE("GuiEditor::CreateOptimizerLoop");
264 CreateNode("OptimizerLoop");
265}

References CreateNode(), and DEBTRACE.

Referenced by YACS::HMI::GenericGui::onOptimizerLoop().

◆ CreateOutputPort()

SubjectDataPort * GuiEditor::CreateOutputPort ( SubjectElementaryNode seNode,
std::string  name,
YACS::ENGINE::Catalog catalog,
std::string  type = "double",
SubjectDataPort before = 0 
)

Definition at line 354 of file GuiEditor.cxx.

359{
360 DEBTRACE("GuiEditor::CreateOutputPort");
361 SubjectDataPort *sdp = 0;
362 if (name.empty())
363 {
364 std::stringstream aName;
365 long newid = 0;
366 while (newid < 100000)
367 {
368 newid = GuiContext::getCurrent()->getNewId();
369 aName.str("");
370 aName << "o" << newid;
371 try
372 {
373 seNode->getNode()->getOutputPort(aName.str());
374 }
375 catch(Exception& ex)
376 {
377 break;
378 }
379 }
380 sdp = seNode->addOutputPort(catalog,type, aName.str());
381 }
382 else
383 sdp = seNode->addOutputPort(catalog,type, name);
384 if (!sdp)
385 Message mess;
386 return sdp;
387}
virtual OutputPort * getOutputPort(const std::string &name) const =0
virtual SubjectDataPort * addOutputPort(YACS::ENGINE::Catalog *catalog, std::string type, std::string name)

References YACS::HMI::SubjectElementaryNode::addOutputPort(), DEBTRACE, testCppPluginInvokation::ex, YACS::HMI::GuiContext::getCurrent(), YACS::HMI::GuiContext::getNewId(), YACS::HMI::SubjectNode::getNode(), and YACS::ENGINE::Node::getOutputPort().

Referenced by YACS::HMI::TablePortsEdition::oncb_insert_activated().

◆ CreateSwitch()

void GuiEditor::CreateSwitch ( )

Definition at line 255 of file GuiEditor.cxx.

256{
257 DEBTRACE("GuiEditor::CreateSwitch");
258 CreateNode("Switch");
259}

References CreateNode(), and DEBTRACE.

Referenced by YACS::HMI::GenericGui::onSWITCHNode().

◆ CreateWhileLoop()

void GuiEditor::CreateWhileLoop ( )

Definition at line 249 of file GuiEditor.cxx.

250{
251 DEBTRACE("GuiEditor::CreateWhileLoop");
252 CreateNode("WhileLoop");
253}

References CreateNode(), and DEBTRACE.

Referenced by YACS::HMI::GenericGui::onWHILENode().

◆ CutSubject()

void GuiEditor::CutSubject ( )

Definition at line 463 of file GuiEditor.cxx.

464{
465 DEBTRACE("GuiEditor::CutSubject");
466 if (!QtGuiContext::getQtCurrent()->isEdition()) return;
468 if (!sub)
469 {
470 Message mess("GuiEditor::Cut : invalid selection!");
471 return;
472 }
473 DEBTRACE(sub->getName());
475}
void setSubjectToCut(YACS::HMI::Subject *sub)

References DEBTRACE, YACS::HMI::Subject::getName(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSelectedSubject(), and YACS::HMI::QtGuiContext::setSubjectToCut().

Referenced by YACS::HMI::GenericGui::onCutItem().

◆ DeleteSubject() [1/2]

void GuiEditor::DeleteSubject ( )

Subject destruction, command from popup menu: needs a valid selection

Definition at line 428 of file GuiEditor.cxx.

429{
430 DEBTRACE("GuiEditor::DeleteSubject");
431 if (!QtGuiContext::getQtCurrent()->isEdition()) return;
432 QModelIndexList selList
433 = QtGuiContext::getQtCurrent()->getSelectionModel()->selectedIndexes();
434 if (selList.isEmpty())
435 return;
436
437 QModelIndex selected = selList.front();
438 if (!selected.isValid())
439 return;
440
441 SchemaItem *selItem = static_cast<SchemaItem*>(selected.internalPointer());
442 if (!selItem) return;
443 Subject *subToRemove = selItem->getSubject();
444 Subject *subParent = subToRemove->getParent();
445 DeleteSubject(subParent, subToRemove);
446}
QItemSelectionModel * getSelectionModel()
virtual Subject * getSubject()
Definition: SchemaItem.cxx:169
virtual Subject * getParent()

References DEBTRACE, DeleteSubject(), YACS::HMI::Subject::getParent(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSelectionModel(), and YACS::HMI::SchemaItem::getSubject().

Referenced by DeleteSubject(), YACS::HMI::TablePortsEdition::on_pb_remove_clicked(), and YACS::HMI::GenericGui::onDeleteItem().

◆ DeleteSubject() [2/2]

void GuiEditor::DeleteSubject ( Subject parent,
Subject toRemove 
)

Subject destruction, command from button in port table view or via selection

Definition at line 451 of file GuiEditor.cxx.

453{
454 DEBTRACE("GuiEditor::DeleteSubject "<<parent->getName()<<" "<<toRemove->getName());
455 if (!QtGuiContext::getQtCurrent()->isEdition()) return;
456 toRemove->askRegisterUndoDestroy();
457 if(!parent->destroy(toRemove))
458 Message mess;
459 // Empty the clipboard in order to avoid the copy of a destroyed object.
461}
virtual bool destroy(Subject *son)
From user action in Ihm, destroy an object.

References YACS::HMI::Subject::askRegisterUndoDestroy(), DEBTRACE, YACS::HMI::Subject::destroy(), YACS::HMI::Subject::getName(), YACS::HMI::QtGuiContext::getQtCurrent(), and YACS::HMI::QtGuiContext::setSubjectToCopy().

◆ PasteSubject()

void GuiEditor::PasteSubject ( )

Definition at line 491 of file GuiEditor.cxx.

492{
493 DEBTRACE("GuiEditor::PasteSubject");
494 if (!QtGuiContext::getQtCurrent()->isEdition()) return;
496 if (!newParent)
497 {
498 Message mess("GuiEditor::Paste : invalid selection!");
499 return;
500 }
501 bool isCut = false;
503 if (!sub)
504 {
505 Message mess("Nothing to paste");
506 return;
507 }
508 if (SubjectNode *snode = dynamic_cast<SubjectNode*>(sub))
509 {
510 if (isCut)
511 {
512 DEBTRACE("cut");
513 if (!snode->reparent(newParent))
514 Message mess;
515 }
516 else
517 {
518 DEBTRACE("copy");
519 if (!snode->copy(newParent))
520 Message mess;
521 }
522 return;
523 }
524 Message mess("Paste not possible for this kind of object");
525}
YACS::HMI::Subject * getSubjectToPaste(bool &isCut)

References DEBTRACE, YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSelectedSubject(), and YACS::HMI::QtGuiContext::getSubjectToPaste().

Referenced by YACS::HMI::GenericGui::onPasteItem().

◆ PutGraphInBloc()

std::string GuiEditor::PutGraphInBloc ( )

Definition at line 581 of file GuiEditor.cxx.

582{
584 std::list<Node *> children = proc->edGetDirectDescendants();
585
586 //get the set of children node names
587 std::set<std::string> names;
588 for (std::list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
589 names.insert((*it)->getName());
590
591 //get the next numbered name
592 std::stringstream tryname;
593 long newid = GuiContext::getCurrent()->getNewId();
594 while (newid < 100000)
595 {
596 tryname.str("");
597 tryname << "Bloc" << newid;
598 if(names.find(tryname.str()) == names.end())break;
599 newid++;
600 }
601 std::string blocname = tryname.str();
602
603 //put one by one the child nodes of Proc node into a new Bloc node
604 std::map< std::string, std::pair<QPointF, QPointF> > aMapOfNodePosition;
605 SceneItem *item = 0;
606 SceneNodeItem *inode = 0;
607 SubjectNode * snode = 0;
608 for (std::list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
609 {
611 snode->saveLinks();
613 YASSERT(item);
614 inode = dynamic_cast<SceneNodeItem*>(item);
615 YASSERT(inode);
616 // save current node position to restore it after reparenting
617 aMapOfNodePosition[snode->getName()] = std::make_pair(inode->pos(), QPointF(inode->getExpandedX(), inode->getExpandedY()));
618 // put in Bloc node
619 snode->putInComposedNode(blocname, "Bloc", false);
620 }
621 for (std::list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
622 {
623 snode = 0;
625 snode->restoreLinks();
627 YASSERT(item);
628 inode = dynamic_cast<SceneNodeItem*>(item);
629 YASSERT(inode);
630 // restore node position
631 inode->setPos(aMapOfNodePosition[snode->getName()].first);
632 // update node position for shrink/expand operation
633 inode->setExpandedPos(aMapOfNodePosition[snode->getName()].second);
634 // notify node about position changing
635 inode->checkGeometryChange();
636 }
637 Node* bloc = proc->getChildByShortName(blocname);
640 YASSERT(item);
641 // notify bloc about child position changing
642 item->checkGeometryChange();
643 // select a target bloc
646 return blocname;
647}
Node * getChildByShortName(const std::string &name) const
Definition: Bloc.cxx:279
std::list< Node * > edGetDirectDescendants() const
Definition: Bloc.hxx:58
std::map< YACS::ENGINE::Node *, YACS::HMI::SubjectNode * > _mapOfSubjectNode
Definition: guiContext.hxx:70
void setSelectedSubject(YACS::HMI::Subject *sub)
virtual void checkGeometryChange()
Definition: SceneItem.cxx:248
void setExpandedPos(QPointF epos)
virtual std::string getName()
virtual void restoreLinks()
virtual void saveLinks()

References YACS::HMI::QtGuiContext::_mapOfSceneItem, YACS::HMI::GuiContext::_mapOfSubjectNode, YACS::HMI::SceneItem::checkGeometryChange(), YACS::ENGINE::Bloc::edGetDirectDescendants(), YACS::ENGINE::Bloc::getChildByShortName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::SceneNodeItem::getExpandedX(), YACS::HMI::SceneNodeItem::getExpandedY(), YACS::HMI::SubjectNode::getName(), YACS::HMI::GuiContext::getNewId(), YACS::HMI::GuiContext::getProc(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::GuiContext::getSubjectProc(), yacsorb.CORBAEngineTest::names, YACS::HMI::SubjectNode::putInComposedNode(), YACS::HMI::SubjectNode::restoreLinks(), YACS::HMI::SubjectNode::saveLinks(), YACS::HMI::SceneNodeItem::setExpandedPos(), YACS::HMI::QtGuiContext::setSelectedSubject(), and YASSERT.

Referenced by YACS::HMI::GenericGui::onPutGraphInBloc(), and PutGraphInNode().

◆ PutGraphInNode()

void GuiEditor::PutGraphInNode ( std::string  typeNode)

Definition at line 563 of file GuiEditor.cxx.

564{
565 // put graph in Bloc node before
566 std::string blocname = PutGraphInBloc();
567 // put the built bloc into target node type
569 Node* bloc = proc->getChildByShortName(blocname);
571 // create a target node
572 SubjectNode * snode = CreateNode(typeNode);
573 // put the built bloc into target node
574 sbloc->putInComposedNode(snode->getName(), typeNode);
575 // select a target node
578 arrangeNodes(false);
579}
void arrangeNodes(bool isRecursive)
Definition: GuiEditor.cxx:659
std::string PutGraphInBloc()
Definition: GuiEditor.cxx:581

References YACS::HMI::GuiContext::_mapOfSubjectNode, arrangeNodes(), CreateNode(), YACS::ENGINE::Bloc::getChildByShortName(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::SubjectNode::getName(), YACS::HMI::GuiContext::getProc(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::GuiContext::getSubjectProc(), PutGraphInBloc(), YACS::HMI::SubjectNode::putInComposedNode(), and YACS::HMI::QtGuiContext::setSelectedSubject().

Referenced by YACS::HMI::GenericGui::onPutGraphInForLoop(), YACS::HMI::GenericGui::onPutGraphInOptimizerLoop(), YACS::HMI::GenericGui::onPutGraphInWhileLoop(), and YACS::HMI::GenericGui::putGraphInForeachLoop().

◆ PutSubjectInBloc()

void GuiEditor::PutSubjectInBloc ( )

Definition at line 527 of file GuiEditor.cxx.

528{
530 if (!sub)
531 {
532 Message mess("GuiEditor::PutSubjectInBloc : invalid selection!");
533 return;
534 }
535 if (SubjectNode *snode = dynamic_cast<SubjectNode*>(sub))
536 {
537 //Build the set of children node names
538 Node* node=snode->getNode();
539 ComposedNode* father=node->getFather();
540 std::list<Node*> children = father->edGetDirectDescendants();
541 std::set<std::string> names;
542 for (std::list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
543 names.insert((*it)->getName());
544
545 std::stringstream tryname;
546 long newid=0;
547 while (newid < 100000)
548 {
549 tryname.str("");
550 tryname << "Bloc" << newid;
551 if(names.find(tryname.str()) == names.end())break;
552 newid++;
553 }
554
555 if (!snode->putInComposedNode(tryname.str(),"Bloc"))
556 Message mess;
557
558 return;
559 }
560 Message mess("Put in Bloc not possible for this kind of object");
561}
ComposedNode * getFather() const
Definition: Node.hxx:127

References YACS::ENGINE::ComposedNode::edGetDirectDescendants(), YACS::ENGINE::Node::getFather(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSelectedSubject(), and yacsorb.CORBAEngineTest::names.

Referenced by YACS::HMI::GenericGui::onPutInBloc().

◆ rebuildLinks()

◆ showRedo()

void GuiEditor::showRedo ( QWidget parent = 0)

Definition at line 706 of file GuiEditor.cxx.

707{
708 FormUndoRedo *redo = new FormUndoRedo(parent);
709 redo->tabWidget->setCurrentWidget(redo->redoTab);
710 redo->exec();
711}

Referenced by YACS::HMI::GenericGui::onShowRedo().

◆ showUndo()

void GuiEditor::showUndo ( QWidget parent = 0)

Definition at line 699 of file GuiEditor.cxx.

700{
701 FormUndoRedo *undo = new FormUndoRedo(parent);
702 undo->tabWidget->setCurrentWidget(undo->undoTab);
703 undo->exec();
704}

Referenced by YACS::HMI::GenericGui::onShowUndo().

◆ shrinkExpand()

void GuiEditor::shrinkExpand ( Qt::KeyboardModifiers  kbModifiers = Qt::NoModifier)

Subject shrink or expand, command from popup menu: needs a valid selection

Definition at line 392 of file GuiEditor.cxx.

392 {
393 DEBTRACE("GuiEditor::shrinkExpand");
394
396 if (!sub) {
397 DEBTRACE("GuiEditor::shrinkExpand : invalid selection!");
398 return;
399 };
400
401 if (! QtGuiContext::getQtCurrent()->_mapOfSceneItem.count(sub)) {
402 DEBTRACE("GuiEditor::shrinkExpand: no scene item corresponding to this subject");
403 return;
404 };
405
407 SceneNodeItem *sni = dynamic_cast<SceneNodeItem*>(item);
408 if (!sni) {
409 DEBTRACE("GuiEditor::shrinkExpand: no scene node item corresponding to this subject");
410 return;
411 };
412
413 ShrinkMode aShrinkMode = CurrentNode;
414 if (kbModifiers == Qt::ControlModifier) {
415 aShrinkMode = ElementaryNodes;
416 } else if (kbModifiers == (Qt::ShiftModifier|Qt::ControlModifier)) {
417 aShrinkMode = ChildrenNodes;
418 }
419
420 sni->reorganizeShrinkExpand(aShrinkMode);
421 sni->showOutScopeLinks();
422 sni->updateLinks();
423}
virtual void reorganizeShrinkExpand(ShrinkMode theShrinkMode)
virtual void showOutScopeLinks()
@ ElementaryNodes
Definition: SceneItem.hxx:40
@ ChildrenNodes
Definition: SceneItem.hxx:39

References YACS::HMI::QtGuiContext::_mapOfSceneItem, YACS::HMI::ChildrenNodes, YACS::HMI::CurrentNode, DEBTRACE, YACS::HMI::ElementaryNodes, YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::QtGuiContext::getSelectedSubject(), YACS::HMI::SceneNodeItem::reorganizeShrinkExpand(), YACS::HMI::SceneNodeItem::showOutScopeLinks(), and YACS::HMI::SceneNodeItem::updateLinks().

Referenced by YACS::HMI::SceneNodeItem::mouseDoubleClickEvent(), YACS::HMI::GenericGui::onShrinkExpand(), YACS::HMI::GenericGui::onShrinkExpandChildren(), and YACS::HMI::GenericGui::onShrinkExpandElementaryRecursively().

Member Data Documentation

◆ _table

std::string YACS::HMI::GuiEditor::_table
protected

Definition at line 100 of file GuiEditor.hxx.

Referenced by asciiFilter(), and GuiEditor().


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