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

Last change on this file since 61 was 61, checked in by garnier, 12 years ago

changement de couleur

File size: 3.9 KB
Line 
1#include "GWt_LigneFaisceau.h"
2//#include "driftDefinition.h"
3#include "GWt_drift.h"
4#include "GWt_initialBeam.h"
5#include "GWt_cell.h"
6#include <iostream>
7#include "nomdElements.h"
8
9
10#include <Wt/WComboBox>
11#include <Wt/WVBoxLayout>
12
13
14GWt_LigneFaisceau::GWt_LigneFaisceau(PspaApplication* ps):
15  pspa_(ps)
16{
17
18  beamLayout_ = new WHBoxLayout();
19  decorationStyle().setBackgroundColor (WColor(55,10,10,250));
20
21  setLayout(beamLayout_);
22
23  acceptDrops("icons/beam.jpg");
24  acceptDrops("icons/bend.jpg");
25  acceptDrops("icons/cell.jpg");
26  acceptDrops("icons/drift.jpg");
27  acceptDrops("icons/final.jpg");
28  acceptDrops("icons/lens.jpg");
29
30
31
32  //  dtmanage_ = new dataManager();
33}
34
35
36void GWt_LigneFaisceau::dropEvent(WDropEvent evt)
37{
38  //  pspa_->addConsoleMessage(WString(" GWt_LigneFaisceau::dropEvent")+evt.mimeType().c_str());
39
40
41  WPushButton* dropped = NULL;
42
43
44
45  if ( strstr(evt.mimeType().c_str() , "drift") ) 
46    {
47      pspa_->addConsoleMessage(" DRIFT");
48      abstractElement* newDrift = pspa_->getDataManager()->addDrift();
49      GWt_drift* gdrift = new GWt_drift(pspa_,newDrift, evt.mimeType());
50
51      dropped = gdrift->getButton();
52      //      WDialog* driftDialog = gdrift->getDialog();
53      //     beamLayout_->addWidget(dropped);
54    }
55  else
56    {
57      if ( strstr(evt.mimeType().c_str() , "beam") ) 
58        {
59          pspa_->addConsoleMessage(" INITIAL_BEAM");
60          abstractElement* newInitialBeam = pspa_->getDataManager()->addInitialBeam();
61          GWt_initialBeam* gwInitialBeam = new GWt_initialBeam(pspa_,newInitialBeam, evt.mimeType());
62
63          dropped = gwInitialBeam->getButton();
64          //              beamLayout_->addWidget(dropped);
65        }
66      else
67        {
68          if ( strstr(evt.mimeType().c_str() , "cell") ) 
69            {
70              pspa_->addConsoleMessage(" CELL");
71              abstractElement* newCell = pspa_->getDataManager()->addCell();
72              GWt_cell* gwCell = new GWt_cell(pspa_,newCell, evt.mimeType());
73              dropped = gwCell->getButton();
74              //              beamLayout_->addWidget(dropped);
75            }
76          else
77            {
78              pspa_->addConsoleMessage(" RIEN trouve");
79            }
80        }
81    }
82
83 //  WVBoxLayout* tempVBox = new WVBoxLayout();
84
85 //  if (!dropped) {
86 //    dropped = new WPushButton();
87 //    dropped->setIcon(evt.mimeType());
88 //    dropped->setMaximumSize(50,50);
89 //  }
90
91 // WComboBox *selectionBox = new WComboBox();
92 //  selectionBox->addItem("Parmela");
93 //  selectionBox->addItem("Transport");
94 //  selectionBox->addItem("Autre");
95 
96 //  selectionBox->setCurrentIndex(1); // Parmela
97 //  //  selectionBox->activated().connect(this, &MyWidget::comboChanged);
98
99 //  tempVBox->addWidget(dropped);
100 //  tempVBox->addWidget(selectionBox);
101
102  //  WContainerWidget* tempWidget = new WContainerWidget();
103  // tempWidget->setLayout(tempVBox);
104  //  beamLayout_->addWidget(tempWidget);
105beamLayout_->addWidget(dropped);
106}
107
108
109void GWt_LigneFaisceau::restoreElementCollection()
110{
111  int nbElem = pspa_->getDataManager()->beamLineSize();
112  unsigned int k;
113  beamLayout_->clear();
114  for ( k=0; k < (unsigned)nbElem; k++) 
115    {     
116      abstractElement* ptr = pspa_->getDataManager()->getCollection()->getElementPointer(k);
117      nomdElement nom = ptr->getName();
118      switch (nom)
119        {
120        case initialBeam :
121          {
122            GWt_initialBeam* gwInitialBeam = new GWt_initialBeam(pspa_,ptr, string("icons/beam.jpg"));
123            //      dropped = gwInitialBeam->getButton();
124            beamLayout_->addWidget(gwInitialBeam->getButton());
125            break;
126          }
127        case drift :
128          {
129            GWt_drift* gdrift = new GWt_drift(pspa_,ptr, string("icons/drift.jpg"));     
130            //      dropped = gdrift->getButton();
131            beamLayout_->addWidget(gdrift->getButton());
132            break;
133          }
134        case cell :
135          {
136              GWt_cell* gwCell = new GWt_cell(pspa_,ptr, string("icons/cell.jpg"));
137              //              dropped = gwCell->getButton();
138              beamLayout_->addWidget(gwCell->getButton());
139              break;
140          }
141        default :
142          {
143            cerr << "  GWt_LigneFaisceau element type " << nom << " inconnu " << endl;
144            break;
145          }
146     }
147
148    }
149
150}
Note: See TracBrowser for help on using the repository browser.