#include #include "GWt_dropZoneLigneFaiseau.h" #include "GWt_LigneFaisceau.h" #include "GWt_drift.h" #include "GWt_rfgun.h" #include "GWt_cell.h" #include "GWt_soleno.h" #include "GWt_bend.h" #include "GWt_dialog.h" #include "mixedTools.h" #include GWt_LigneFaisceau::GWt_LigneFaisceau(PspaApplication* ps) : WContainerWidget(), pspa_(ps), nObjets_(NULL) { cout<<"GWt_LigneFaisceau::GWt_LigneFaisceau() %d"<< this << "<---------------"<< endl; hbox_ = new WHBoxLayout(); // decorationStyle().setBackgroundColor (WColor("orange")); setLayout(hbox_); int nElts= nomdElements::getNumberOfElements(); nObjets_= new Compteur[nElts]; for(int k = 0; k < nElts; k++) { typedElement eType= (typedElement)k; acceptDrops(nomdElements::getImageFromType(eType)); } // add the first drop zone hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false)); // add a strech element at the end // hbox_->addStretch(1); } void GWt_LigneFaisceau::restoreElementCollection() { cout<<"GWt_LigneFaisceau::restoreElementCollection()"<clear(); delete[] nObjets_; int nElements= nomdElements ::getNumberOfElements(); nObjets_= new Compteur[nElements]; int nbElem = pspa_->getDataManager()->beamLineSize(); unsigned int k; // add first dropZone hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false)); for(k = 0; k < (unsigned)nbElem; k++) { abstractElement* ptr = pspa_->getDataManager()->getCollection()->getElementPointer(k); GWt_abstractElement* gw = GWt_abstractElement::ajoute(pspa_,ptr); if(gw == NULL) { cerr << "GWt_LigneFaisceau::restaure element type " << ptr->getName().getElementName() << " est inconnu " << endl; } gw->updateLabelWidget(); nObjets_[ptr->getName().getElementType()].incr(); GWt_dropZoneLigneFaiseau* dropZone = new GWt_dropZoneLigneFaiseau(pspa_); dropZone->addElement(gw->getWidget()); hbox_->addWidget(dropZone); if (k < ((unsigned)nbElem-1)) { hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_)); } else { hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false)); } } pspa_->updateSelections(); }