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 "GWt_soleno.h" |
---|
7 | #include <iostream> |
---|
8 | #include "nomdElements.h" |
---|
9 | |
---|
10 | |
---|
11 | #include <Wt/WComboBox> |
---|
12 | #include <Wt/WVBoxLayout> |
---|
13 | |
---|
14 | |
---|
15 | GWt_LigneFaisceau::GWt_LigneFaisceau(PspaApplication* ps): |
---|
16 | pspa_(ps) |
---|
17 | { |
---|
18 | |
---|
19 | beamLayout_ = new WHBoxLayout(); |
---|
20 | decorationStyle().setBackgroundColor (WColor("orange")); |
---|
21 | |
---|
22 | |
---|
23 | setLayout(beamLayout_); |
---|
24 | |
---|
25 | acceptDrops("icons/beam.jpg"); |
---|
26 | acceptDrops("icons/bend.jpg"); |
---|
27 | acceptDrops("icons/cell.jpg"); |
---|
28 | acceptDrops("icons/drift.jpg"); |
---|
29 | acceptDrops("icons/final.jpg"); |
---|
30 | acceptDrops("icons/lens.jpg"); |
---|
31 | |
---|
32 | |
---|
33 | |
---|
34 | // dtmanage_ = new dataManager(); |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | void GWt_LigneFaisceau::dropEvent(WDropEvent evt) |
---|
39 | { |
---|
40 | // pspa_->addConsoleMessage(WString(" GWt_LigneFaisceau::dropEvent")+evt.mimeType().c_str()); |
---|
41 | |
---|
42 | |
---|
43 | WPushButton* dropped = NULL; |
---|
44 | |
---|
45 | |
---|
46 | |
---|
47 | if ( strstr(evt.mimeType().c_str() , "drift") ) |
---|
48 | { |
---|
49 | pspa_->addConsoleMessage(" DRIFT"); |
---|
50 | abstractElement* newDrift = pspa_->getDataManager()->addDrift(); |
---|
51 | GWt_drift* gdrift = new GWt_drift(pspa_,newDrift, evt.mimeType()); |
---|
52 | dropped = gdrift->getButton(); |
---|
53 | } |
---|
54 | else if ( strstr(evt.mimeType().c_str() , "beam") ) |
---|
55 | { |
---|
56 | pspa_->addConsoleMessage(" INITIAL_BEAM"); |
---|
57 | abstractElement* newInitialBeam = pspa_->getDataManager()->addInitialBeam(); |
---|
58 | GWt_initialBeam* gwInitialBeam = new GWt_initialBeam(pspa_,newInitialBeam, evt.mimeType()); |
---|
59 | |
---|
60 | dropped = gwInitialBeam->getButton(); |
---|
61 | } |
---|
62 | else if ( strstr(evt.mimeType().c_str() , "cell") ) |
---|
63 | { |
---|
64 | pspa_->addConsoleMessage(" CELL"); |
---|
65 | abstractElement* newCell = pspa_->getDataManager()->addCell(); |
---|
66 | GWt_cell* gwCell = new GWt_cell(pspa_,newCell, evt.mimeType()); |
---|
67 | dropped = gwCell->getButton(); |
---|
68 | } |
---|
69 | else if ( strstr(evt.mimeType().c_str() , "lens") ) |
---|
70 | { |
---|
71 | pspa_->addConsoleMessage("SOLENOID"); |
---|
72 | abstractElement* newSoleno = pspa_->getDataManager()->addSoleno(); |
---|
73 | GWt_soleno* gwSoleno = new GWt_soleno(pspa_,newSoleno, evt.mimeType()); |
---|
74 | dropped = gwSoleno->getButton(); |
---|
75 | } |
---|
76 | else |
---|
77 | { |
---|
78 | pspa_->addConsoleMessage(" RIEN trouve"); |
---|
79 | } |
---|
80 | |
---|
81 | beamLayout_->addWidget(dropped); |
---|
82 | } |
---|
83 | |
---|
84 | |
---|
85 | void GWt_LigneFaisceau::restoreElementCollection() |
---|
86 | { |
---|
87 | int nbElem = pspa_->getDataManager()->beamLineSize(); |
---|
88 | unsigned int k; |
---|
89 | beamLayout_->clear(); |
---|
90 | for ( k=0; k < (unsigned)nbElem; k++) |
---|
91 | { |
---|
92 | abstractElement* ptr = pspa_->getDataManager()->getCollection()->getElementPointer(k); |
---|
93 | nomdElement nom = ptr->getName(); |
---|
94 | switch (nom) |
---|
95 | { |
---|
96 | case initialBeam : |
---|
97 | { |
---|
98 | GWt_initialBeam* gwInitialBeam = new GWt_initialBeam(pspa_,ptr, string("icons/beam.jpg")); |
---|
99 | beamLayout_->addWidget(gwInitialBeam->getButton()); |
---|
100 | break; |
---|
101 | } |
---|
102 | case drift : |
---|
103 | { |
---|
104 | GWt_drift* gdrift = new GWt_drift(pspa_,ptr, string("icons/drift.jpg")); |
---|
105 | beamLayout_->addWidget(gdrift->getButton()); |
---|
106 | break; |
---|
107 | } |
---|
108 | case cell : |
---|
109 | { |
---|
110 | GWt_cell* gwCell = new GWt_cell(pspa_,ptr, string("icons/cell.jpg")); |
---|
111 | beamLayout_->addWidget(gwCell->getButton()); |
---|
112 | break; |
---|
113 | } |
---|
114 | |
---|
115 | case soleno : |
---|
116 | { |
---|
117 | GWt_soleno* gwSoleno = new GWt_soleno(pspa_,ptr, string("icons/lens.jpg")); |
---|
118 | beamLayout_->addWidget(gwSoleno->getButton()); |
---|
119 | break; |
---|
120 | } |
---|
121 | default : |
---|
122 | { |
---|
123 | cerr << " GWt_LigneFaisceau element type " << nom << " inconnu " << endl; |
---|
124 | break; |
---|
125 | } |
---|
126 | } |
---|
127 | |
---|
128 | } |
---|
129 | |
---|
130 | } |
---|