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