Version: 9.16.0
EditionSalomeNode.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#include "EditionSalomeNode.hxx"
21#include "PropertyEditor.hxx"
22#include "FormComponent.hxx"
23#include "FormContainer.hxx"
24#include "ServiceNode.hxx"
25#include "ComponentInstance.hxx"
26#include "QtGuiContext.hxx"
27#include "Container.hxx"
28#include "Message.hxx"
29
30#include <cassert>
31#include <map>
32#include <string>
33
34//#define _DEVDEBUG_
35#include "YacsTrace.hxx"
36
37using namespace std;
38
39using namespace YACS;
40using namespace YACS::ENGINE;
41using namespace YACS::HMI;
42
43EditionSalomeNode::EditionSalomeNode(Subject* subject,
44 QWidget* parent,
45 const char* name)
46 : EditionElementaryNode(subject, parent, name)
47{
48 // SubjectServiceNode *ssn = dynamic_cast<SubjectServiceNode*>(_subject);
49 // YASSERT(ssn);
52 // --- create property editor panel
54 _wid->gridLayout1->addWidget(_propeditor);
55
56 // --- create container and component panels
57
59 _wid->gridLayout1->addWidget(_wContainer);
60
61 connect(_wContainer, SIGNAL(resourceMousePressed()), this, SLOT(fillContainerPanel()));
62 connect(_wContainer, SIGNAL(resourceActivated(int)), this, SLOT(changeHost(int)));
63 connect(_wContainer, SIGNAL(containerToggled(bool)), this, SLOT(fillContainerPanel()));
64 // --- to update display of current selection
65
66 _wComponent = new FormComponent(this);
67 _wid->gridLayout1->addWidget(_wComponent);
68
69 connect(_wComponent->cb_instance, SIGNAL(mousePressed()),
70 this, SLOT(fillComponentPanel()));
71 connect(_wComponent->cb_instance, SIGNAL(activated(int)),
72 this, SLOT(changeInstance(int)));
73
74 connect(_wComponent->cb_container, SIGNAL(mousePressed()),
75 this, SLOT(fillContainerPanel()));
76 connect(_wComponent->cb_container, SIGNAL(activated(int)),
77 this, SLOT(changeContainer(int)));
78
79 connect(_wComponent->tb_component, SIGNAL(toggled(bool)),
80 this, SLOT(fillComponentPanel())); // --- to update display of current selection
81 connect(_wComponent->tb_component, SIGNAL(toggled(bool)),
82 this, SLOT(fillContainerPanel())); // --- to update display of current selection
83
84 // --- method
85
86 _hbl_method = new QHBoxLayout();
87 _la_method = new QLabel(this);
88 _hbl_method->addWidget(_la_method);
89 _le_method = new QLineEdit(this);
90 _hbl_method->addWidget(_le_method);
91 _wid->gridLayout1->addLayout(_hbl_method, _wid->gridLayout1->rowCount(), 0, 1, 1);
92 _la_method->setText("Method:");
93
94 _le_method->setText((_servNode->getMethod()).c_str());
95 _le_method->setReadOnly(true);
96
97 // --- fill component panel
98
100
101 createTablePorts(_wid->gridLayout1);
102}
103
105{
106}
107
108void EditionSalomeNode::update(GuiEvent event, int type, Subject* son)
109{
110 DEBTRACE("EditionSalomeNode::update ");
111 EditionElementaryNode::update(event, type, son);
112 SubjectReference* subref= 0;
113 switch (event)
114 {
115 case ADDREF:
116 DEBTRACE("ADDREF");
117 subref = dynamic_cast<SubjectReference*>(son);
118 YASSERT(subref);
119 DEBTRACE(subref->getName() << " " << subref->getReference()->getName());
122 break;
123
124 case ASSOCIATE:
125 DEBTRACE("ASSOCIATE");
127 break;
128
129 case SETVALUE:
131 break;
132
133 default:
134 ;
135 }
136}
137
139{
142 _wComponent->tb_component->setChecked(FormComponent::_checked);
145}
146
151{
153 if (compoInst)
154 {
155 _wComponent->le_name ->setText(compoInst->getCompoName().c_str());
157
158 _wComponent->cb_instance->clear();
159 map<string,ComponentInstance*>::const_iterator it = proc->componentInstanceMap.begin();
160 for(; it != proc->componentInstanceMap.end(); ++it)
161 {
162 ComponentInstance *inst=(*it).second;
163 QString compoName = inst->getCompoName().c_str();
164 if (! QString::compare(compoInst->getCompoName().c_str(), compoName)) // if same component name
165 //instanceMap[inst->getInstanceName()] = inst;
166 _wComponent->cb_instance->addItem( QString(inst->getInstanceName().c_str()));
167 }
168
169 int index = _wComponent->cb_instance->findText(compoInst->getInstanceName().c_str());
170 //DEBTRACE("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " << index);
171 _wComponent->cb_instance->setCurrentIndex(index);
172 }
173}
174
176{
177 DEBTRACE("EditionSalomeNode::fillContainerPanel");
179 if (compoInst)
180 {
182
183 _wComponent->cb_container->clear();
184 map<string,Container*>::const_iterator it = proc->containerMap.begin();
185 for(; it != proc->containerMap.end(); ++it)
186 _wComponent->cb_container->addItem( QString((*it).first.c_str()));
187
188 Container * cont = compoInst->getContainer();
189 if (cont)
190 {
191 int index = _wComponent->cb_container->findText(cont->getName().c_str());
192 _wComponent->cb_container->setCurrentIndex(index);
193 _wContainer->FillPanel(cont);
194 }
195 }
196}
197
198
200{
201 string instName = _wComponent->cb_instance->itemText(index).toStdString();
203 ComponentInstance *newCompoInst = 0;
204 ComponentInstance *oldCompoInst = _servNode->getComponent();
205 if (proc->componentInstanceMap.count(instName))
206 newCompoInst = proc->componentInstanceMap[instName];
207 else DEBTRACE("-------------> not found : " << instName);
208
209 if (newCompoInst && (newCompoInst != oldCompoInst))
210 {
211 YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(newCompoInst));
212 SubjectServiceNode *ssn = dynamic_cast<SubjectServiceNode*>(_subject);
214 Message mess;
215 }
216}
217
219{
220 string contName = _wComponent->cb_container->itemText(index).toStdString();
221 DEBTRACE(contName);
223 Container *oldContainer = compoInst->getContainer();
224
225 Container *newContainer = 0;
227 if (proc->containerMap.count(contName))
228 newContainer = proc->containerMap[contName];
229 if (!newContainer)
230 {
231 DEBTRACE("-------------> not found : " << contName);
232 return;
233 }
234 YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(newContainer));
235 SubjectContainerBase *scnt(GuiContext::getCurrent()->_mapOfSubjectContainer[newContainer]);
236
237 SubjectServiceNode *ssn(dynamic_cast<SubjectServiceNode*>(_subject));
239 YASSERT(sco);
240 sco->associateToContainer(scnt);
241}
242
244{
245 string hostName = _wContainer->getHostName(index);
246 DEBTRACE(hostName);
247}
248
250{
251 DEBTRACE("EditionSalomeNode::onApply");
252 bool edited = true;
253 if (_wContainer->onApply())
254 edited = false;
255 _isEdited = _isEdited || edited;
257}
258
260{
261 DEBTRACE("EditionSalomeNode::onCancel");
263 if (compoInst)
264 {
265 _wContainer->FillPanel(compoInst->getContainer());
266 }
268}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
static bool _checked
void FillPanel(YACS::ENGINE::Container *container)
std::string getHostName(int index) const
WidEditItem * _wid
Base class for all component instances.
const std::string & getInstanceName() const
const std::string & getCompoName() const
virtual std::string getName() const
Definition: Container.hxx:81
Base class for all schema objects.
Definition: Proc.hxx:44
std::map< std::string, Container * > containerMap
Definition: Proc.hxx:91
std::map< std::string, ComponentInstance * > componentInstanceMap
Definition: Proc.hxx:92
Class for calculation node associated with a component service.
Definition: ServiceNode.hxx:35
virtual std::string getMethod()
Definition: ServiceNode.hxx:51
virtual Container * getContainer()
Return the associated container.
virtual ComponentInstance * getComponent()
Return the associated component instance.
virtual void createTablePorts(QLayout *layout)
virtual void update(GuiEvent event, int type, Subject *son)
Definition: EditionNode.cxx:64
FormContainerDecorator * _wContainer
YACS::ENGINE::ServiceNode * _servNode
virtual void changeInstance(int index)
virtual void update(GuiEvent event, int type, Subject *son)
virtual void changeContainer(int index)
virtual void changeHost(int index)
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
std::map< YACS::ENGINE::ComponentInstance *, YACS::HMI::SubjectComponent * > _mapOfSubjectComponent
Definition: guiContext.hxx:74
YACS::ENGINE::Proc * getProc()
Definition: guiContext.hxx:50
A class to edit properties of a subject.
void update()
Update the property items with their values in the subject.
virtual bool associateToContainer(SubjectContainerBase *subcont)
virtual YACS::ENGINE::Node * getNode()
virtual Subject * getReference() const
virtual std::string getName()
virtual SubjectReference * getSubjectReference()
virtual bool associateToComponent(SubjectComponent *subcomp)
virtual std::string getName()