source: PSPA/Interface_Web/trunk/pspaWT/src/GWt_LigneFaisceau.cc @ 230

Last change on this file since 230 was 230, checked in by lemeur, 11 years ago

fin implementation fit

File size: 2.3 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(245,245,245));
27  decorationStyle().setBackgroundImage (WApplication::appRoot()+"../icons/background.png");
28  setLayout(hbox_);
29
30  int nElts= nomdElements::getNumberOfElements(); 
31  nObjets_= new Compteur[nElts];
32  for(int k = 0; k < nElts; k++) {
33    typedElement eType= (typedElement)k;
34    acceptDrops(nomdElements::getImageFromType(eType));
35  }
36
37  // add the first drop zone
38  hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false));
39
40  // add a strech element at the end
41  //  hbox_->addStretch(1);
42}
43 
44
45   
46void GWt_LigneFaisceau::restoreElementCollection()
47{
48
49  cout<<"GWt_LigneFaisceau::restoreElementCollection()"<<endl;
50
51  hbox_->clear();
52
53  delete[] nObjets_;
54  int nElements= nomdElements ::getNumberOfElements(); 
55  nObjets_= new Compteur[nElements];
56
57  int nbElem = pspa_->getDataManager()->beamLineSize();
58  unsigned int k;
59
60  // add first dropZone
61  hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false));
62
63  for(k = 0; k < (unsigned)nbElem; k++) 
64    {     
65      abstractElement* ptr = pspa_->getDataManager()->getCollection()->getElementPointerFromIndex(k);
66      GWt_abstractElement* gw = GWt_abstractElement::ajoute(ptr);
67      if(gw == NULL) {
68        cerr << "GWt_LigneFaisceau::restaure element type " << ptr->getNomdElement().getElementName() << " est inconnu " << endl;
69      }
70     
71      gw->setLabelWidget();
72      nObjets_[ptr->getNomdElement().getElementType()].incr();
73      GWt_dropZoneLigneFaiseau* dropZone = new GWt_dropZoneLigneFaiseau(pspa_);
74      dropZone->addElement(gw->getWidget());
75      hbox_->addWidget(dropZone);
76
77      if (k < ((unsigned)nbElem-1)) {
78        hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_));
79      } else {
80        hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false));
81      }
82    } 
83
84  pspa_->updateSelections();
85}
86
Note: See TracBrowser for help on using the repository browser.