source: PSPA/Interface_Web/branches/insertionsElements/src/GWt_LigneFaisceau.cc @ 432

Last change on this file since 432 was 239, checked in by garnier, 11 years ago

modifications de la partie Web, a ameliorer

File size: 2.2 KB
Line 
1#include <iostream>
2
3#include "GWt_dropZoneLigneFaiseau.h"
4#include "GWt_LigneFaisceau.h"
5#include "GWt_drift.h"
6#include "GWt_rfgun.h"
7#include "GWt_cell.h"
8#include "GWt_soleno.h"
9#include "GWt_bend.h"
10#include "GWt_dialog.h"
11
12#include "mixedTools.h"
13
14#include <Wt/WVBoxLayout>
15
16
17GWt_LigneFaisceau::GWt_LigneFaisceau(PspaApplication* ps) :
18  WContainerWidget(),
19  pspa_(ps),
20  nObjets_(NULL)
21{
22
23  cout<<"GWt_LigneFaisceau::GWt_LigneFaisceau() %d"<< this << "<---------------"<< endl;
24
25  hbox_ = new WHBoxLayout();
26  //  decorationStyle().setBackgroundColor (WColor("orange"));
27  setLayout(hbox_);
28
29  int nElts= nomdElements::getNumberOfElements(); 
30  nObjets_= new Compteur[nElts];
31  for(int k = 0; k < nElts; k++) {
32    typedElement eType= (typedElement)k;
33    acceptDrops(nomdElements::getImageFromType(eType));
34  }
35
36  // add the first drop zone
37  hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false));
38
39  // add a strech element at the end
40  //  hbox_->addStretch(1);
41}
42 
43
44   
45void GWt_LigneFaisceau::restoreElementCollection()
46{
47
48  cout<<"GWt_LigneFaisceau::restoreElementCollection()"<<endl;
49
50  hbox_->clear();
51
52  delete[] nObjets_;
53  int nElements= nomdElements ::getNumberOfElements(); 
54  nObjets_= new Compteur[nElements];
55
56  int nbElem = pspa_->getDataManager()->beamLineSize();
57  unsigned int k;
58
59  // add first dropZone
60  hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false));
61
62  for(k = 0; k < (unsigned)nbElem; k++) 
63    {     
64      abstractElement* ptr = pspa_->getDataManager()->getCollection()->getElementPointer(k);
65      GWt_abstractElement* gw = GWt_abstractElement::ajoute(pspa_,ptr);
66      if(gw == NULL) {
67        cerr << "GWt_LigneFaisceau::restaure element type " << ptr->getName().getElementName() << " est inconnu " << endl;
68      }
69     
70      gw->updateLabelWidget();
71      nObjets_[ptr->getName().getElementType()].incr();
72      GWt_dropZoneLigneFaiseau* dropZone = new GWt_dropZoneLigneFaiseau(pspa_);
73      dropZone->addElement(gw->getWidget());
74      hbox_->addWidget(dropZone);
75
76      if (k < ((unsigned)nbElem-1)) {
77        hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_));
78      } else {
79        hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false));
80      }
81    } 
82
83  pspa_->updateSelections();
84}
85
Note: See TracBrowser for help on using the repository browser.