Version: 8.3.0
EditionComponent.cxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
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 "EditionComponent.hxx"
21 #include "PropertyEditor.hxx"
22 #include "QtGuiContext.hxx"
23 #include "Container.hxx"
24 #include "ComponentInstance.hxx"
25 
26 //#define _DEVDEBUG_
27 #include "YacsTrace.hxx"
28 
29 using namespace std;
30 
31 using namespace YACS;
32 using namespace YACS::HMI;
33 using namespace YACS::ENGINE;
34 
35 
36 EditionComponent::EditionComponent(Subject* subject,
37  QWidget* parent,
38  const char* name)
39  : ItemEdition(subject, parent, name)
40 {
41 
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);
50  _wid->gridLayout1->addWidget(_propeditor);
51 
52  connect(_cb_container, SIGNAL(mousePressed()),
53  this, SLOT(fillContainerPanel()));
54  connect(_cb_container, SIGNAL(activated(int)),
55  this, SLOT(changeContainer(int)));
56 
58 }
59 
61 {
62 }
63 
64 void EditionComponent::update(GuiEvent event, int type, Subject* son)
65 {
66  DEBTRACE("EditionComponent::update " <<eventName(event) << " " << type);
67  if(event == SETVALUE)
69 
70  if(event == ADDREF || event == ASSOCIATE)
72 }
73 
75 {
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()));
81 
82  SubjectComponent *scompo=dynamic_cast<SubjectComponent*>(_subject);
83  ComponentInstance *compoInst = scompo->getComponent();
84  Container * cont = compoInst->getContainer();
85  if (cont)
86  {
87  int index = _cb_container->findText(cont->getName().c_str());
88  _cb_container->setCurrentIndex(index);
89  }
90 }
91 
93 {
94  string contName = _cb_container->itemText(index).toStdString();
95  DEBTRACE(contName);
96  SubjectComponent *scompo=dynamic_cast<SubjectComponent*>(_subject);
97  ComponentInstance *compoInst = scompo->getComponent();
98 
99  Proc* proc = GuiContext::getCurrent()->getProc();
100 
101  if (proc->containerMap.count(contName)==0)
102  {
103  DEBTRACE("-------------> not found : " << contName);
104  return;
105  }
106  Container *newContainer =proc->containerMap[contName];
108  scompo->associateToContainer(scnt);
109  scompo->select(true);
110 }
111