1 // Copyright (C) 2006-2014 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "EditionComponent.hxx"
21 #include "PropertyEditor.hxx"
22 #include "QtGuiContext.hxx"
23 #include "Container.hxx"
24 #include "ComponentInstance.hxx"
27 #include "YacsTrace.hxx"
32 using namespace YACS::HMI;
33 using namespace YACS::ENGINE;
36 EditionComponent::EditionComponent(Subject* subject,
39 : ItemEdition(subject, parent, name)
42 QHBoxLayout* hboxLayout = new QHBoxLayout();
43 hboxLayout->setSizeConstraint(QLayout::SetDefaultConstraint);
44 QLabel* la_container = new QLabel("Container:");
45 hboxLayout->addWidget(la_container);
46 _cb_container = new ComboBox();
47 hboxLayout->addWidget(_cb_container);
48 _wid->gridLayout1->addLayout(hboxLayout, 3, 0, 1, 1);
49 _propeditor=new PropertyEditor(_subject);
50 _wid->gridLayout1->addWidget(_propeditor);
52 connect(_cb_container, SIGNAL(mousePressed()),
53 this, SLOT(fillContainerPanel()));
54 connect(_cb_container, SIGNAL(activated(int)),
55 this, SLOT(changeContainer(int)));
60 EditionComponent::~EditionComponent()
64 void EditionComponent::update(GuiEvent event, int type, Subject* son)
66 DEBTRACE("EditionComponent::update " <<eventName(event) << " " << type);
68 _propeditor->update();
70 if(event == ADDREF || event == ASSOCIATE)
74 void EditionComponent::fillContainerPanel()
76 Proc* proc = GuiContext::getCurrent()->getProc();
77 _cb_container->clear();
78 std::map<string,Container*>::const_iterator it = proc->containerMap.begin();
79 for(; it != proc->containerMap.end(); ++it)
80 _cb_container->addItem( QString((*it).first.c_str()));
82 SubjectComponent *scompo=dynamic_cast<SubjectComponent*>(_subject);
83 ComponentInstance *compoInst = scompo->getComponent();
84 Container * cont = compoInst->getContainer();
87 int index = _cb_container->findText(cont->getName().c_str());
88 _cb_container->setCurrentIndex(index);
92 void EditionComponent::changeContainer(int index)
94 string contName = _cb_container->itemText(index).toStdString();
96 SubjectComponent *scompo=dynamic_cast<SubjectComponent*>(_subject);
97 ComponentInstance *compoInst = scompo->getComponent();
99 Proc* proc = GuiContext::getCurrent()->getProc();
101 if (proc->containerMap.count(contName)==0)
103 DEBTRACE("-------------> not found : " << contName);
106 Container *newContainer =proc->containerMap[contName];
107 SubjectContainer *scnt = GuiContext::getCurrent()->_mapOfSubjectContainer[newContainer];
108 scompo->associateToContainer(scnt);
109 scompo->select(true);