#include "GWt_LigneFaisceau.h" //#include "driftDefinition.h" #include "GWt_drift.h" #include "GWt_initialBeam.h" #include "GWt_cell.h" #include #include "nomdElements.h" #include #include GWt_LigneFaisceau::GWt_LigneFaisceau(PspaApplication* ps): pspa_(ps) { beamLayout_ = new WHBoxLayout(); decorationStyle().setBackgroundColor (WColor(55,10,10,250)); setLayout(beamLayout_); acceptDrops("icons/beam.jpg"); acceptDrops("icons/bend.jpg"); acceptDrops("icons/cell.jpg"); acceptDrops("icons/drift.jpg"); acceptDrops("icons/final.jpg"); acceptDrops("icons/lens.jpg"); // dtmanage_ = new dataManager(); } void GWt_LigneFaisceau::dropEvent(WDropEvent evt) { // pspa_->addConsoleMessage(WString(" GWt_LigneFaisceau::dropEvent")+evt.mimeType().c_str()); WPushButton* dropped = NULL; if ( strstr(evt.mimeType().c_str() , "drift") ) { pspa_->addConsoleMessage(" DRIFT"); abstractElement* newDrift = pspa_->getDataManager()->addDrift(); GWt_drift* gdrift = new GWt_drift(pspa_,newDrift, evt.mimeType()); dropped = gdrift->getButton(); // WDialog* driftDialog = gdrift->getDialog(); // beamLayout_->addWidget(dropped); } else { if ( strstr(evt.mimeType().c_str() , "beam") ) { pspa_->addConsoleMessage(" INITIAL_BEAM"); abstractElement* newInitialBeam = pspa_->getDataManager()->addInitialBeam(); GWt_initialBeam* gwInitialBeam = new GWt_initialBeam(pspa_,newInitialBeam, evt.mimeType()); dropped = gwInitialBeam->getButton(); // beamLayout_->addWidget(dropped); } else { if ( strstr(evt.mimeType().c_str() , "cell") ) { pspa_->addConsoleMessage(" CELL"); abstractElement* newCell = pspa_->getDataManager()->addCell(); GWt_cell* gwCell = new GWt_cell(pspa_,newCell, evt.mimeType()); dropped = gwCell->getButton(); // beamLayout_->addWidget(dropped); } else { pspa_->addConsoleMessage(" RIEN trouve"); } } } // WVBoxLayout* tempVBox = new WVBoxLayout(); // if (!dropped) { // dropped = new WPushButton(); // dropped->setIcon(evt.mimeType()); // dropped->setMaximumSize(50,50); // } // WComboBox *selectionBox = new WComboBox(); // selectionBox->addItem("Parmela"); // selectionBox->addItem("Transport"); // selectionBox->addItem("Autre"); // selectionBox->setCurrentIndex(1); // Parmela // // selectionBox->activated().connect(this, &MyWidget::comboChanged); // tempVBox->addWidget(dropped); // tempVBox->addWidget(selectionBox); // WContainerWidget* tempWidget = new WContainerWidget(); // tempWidget->setLayout(tempVBox); // beamLayout_->addWidget(tempWidget); beamLayout_->addWidget(dropped); } void GWt_LigneFaisceau::restoreElementCollection() { int nbElem = pspa_->getDataManager()->beamLineSize(); unsigned int k; beamLayout_->clear(); for ( k=0; k < (unsigned)nbElem; k++) { abstractElement* ptr = pspa_->getDataManager()->getCollection()->getElementPointer(k); nomdElement nom = ptr->getName(); switch (nom) { case initialBeam : { GWt_initialBeam* gwInitialBeam = new GWt_initialBeam(pspa_,ptr, string("icons/beam.jpg")); // dropped = gwInitialBeam->getButton(); beamLayout_->addWidget(gwInitialBeam->getButton()); break; } case drift : { GWt_drift* gdrift = new GWt_drift(pspa_,ptr, string("icons/drift.jpg")); // dropped = gdrift->getButton(); beamLayout_->addWidget(gdrift->getButton()); break; } case cell : { GWt_cell* gwCell = new GWt_cell(pspa_,ptr, string("icons/cell.jpg")); // dropped = gwCell->getButton(); beamLayout_->addWidget(gwCell->getButton()); break; } default : { cerr << " GWt_LigneFaisceau element type " << nom << " inconnu " << endl; break; } } } }