1 | #include <stdio.h> |
---|
2 | #include <string.h> |
---|
3 | #include <stdlib.h> |
---|
4 | #include <vector> |
---|
5 | |
---|
6 | #include <Wt/WLineEdit> |
---|
7 | #include <Wt/WText> |
---|
8 | #include <Wt/WGridLayout> |
---|
9 | #include <Wt/WVBoxLayout> |
---|
10 | #include <Wt/WHBoxLayout> |
---|
11 | #include <Wt/WImage> |
---|
12 | //#include <Wt/WTextArea> |
---|
13 | #include <Wt/WBreak> |
---|
14 | #include <Wt/WStandardItemModel> |
---|
15 | #include <Wt/Chart/WCartesianChart> |
---|
16 | |
---|
17 | #include "GWt_pspaApplication.h" |
---|
18 | #include "GWt_LigneFaisceau.h" |
---|
19 | #include "GWt_globalParameters.h" |
---|
20 | #include "bareParticle.h" |
---|
21 | #include "nomDeLogiciel.h" |
---|
22 | #include "mixedTools.h" |
---|
23 | |
---|
24 | using namespace Wt::Chart; |
---|
25 | |
---|
26 | |
---|
27 | |
---|
28 | |
---|
29 | /* |
---|
30 | * The env argument contains information about the new session, and |
---|
31 | * the initial request. It must be passed to the WApplication |
---|
32 | * constructor so it is typically also an argument for your custom |
---|
33 | * application constructor. |
---|
34 | */ |
---|
35 | |
---|
36 | |
---|
37 | WWidget* PspaApplication::createPalette() |
---|
38 | { |
---|
39 | WContainerWidget* palette=new WContainerWidget(); |
---|
40 | // palette->setLayout(new WVBoxLayout()); |
---|
41 | |
---|
42 | createDragImage("icons/drift.jpg", |
---|
43 | "icons/drift.jpg","icons/drift.jpg", palette,"drift"); |
---|
44 | new WBreak(palette); |
---|
45 | |
---|
46 | createDragImage("icons/cell.jpg", |
---|
47 | "icons/cell.jpg","icons/cell.jpg", palette,"cell"); |
---|
48 | new WBreak(palette); |
---|
49 | |
---|
50 | createDragImage("icons/beam.jpg", |
---|
51 | "icons/beam.jpg","icons/beam.jpg", palette,"beam"); |
---|
52 | new WBreak(palette); |
---|
53 | |
---|
54 | createDragImage("icons/bend.jpg", |
---|
55 | "icons/bend.jpg","icons/bend.jpg", palette,"bend"); |
---|
56 | new WBreak(palette); |
---|
57 | |
---|
58 | createDragImage("icons/final.jpg", |
---|
59 | "icons/final.jpg","icons/final.jpg", palette,"final"); |
---|
60 | new WBreak(palette); |
---|
61 | |
---|
62 | createDragImage("icons/lens.jpg", |
---|
63 | "icons/lens.jpg","icons/lens.jpg", palette,"lens"); |
---|
64 | new WBreak(palette); |
---|
65 | |
---|
66 | palette->setMinimumSize(100,300); |
---|
67 | |
---|
68 | return palette; |
---|
69 | } |
---|
70 | |
---|
71 | WWidget* PspaApplication::createBeamLine() |
---|
72 | { |
---|
73 | WContainerWidget* beamLine=new GWt_LigneFaisceau(this); |
---|
74 | beamLine->setMinimumSize(600,200); |
---|
75 | return beamLine; |
---|
76 | } |
---|
77 | |
---|
78 | WWidget* PspaApplication::createGlobalParamWidget() |
---|
79 | { |
---|
80 | WContainerWidget* globalParam =new GWt_globalParameters(this); |
---|
81 | globalParam->setMaximumSize(600,150); |
---|
82 | globalParam->setMinimumSize(600,150); |
---|
83 | return globalParam; |
---|
84 | } |
---|
85 | |
---|
86 | WWidget* PspaApplication::createExecuteWidget() |
---|
87 | { |
---|
88 | |
---|
89 | WContainerWidget* executeW =new WContainerWidget(); |
---|
90 | |
---|
91 | |
---|
92 | // WVBoxLayout* executeLayout = new WVBoxLayout(); |
---|
93 | |
---|
94 | // executeW->decorationStyle().setBackgroundColor (WColor("yellow")); |
---|
95 | executeW->setMaximumSize(600,150); |
---|
96 | executeW->setMinimumSize(600,150); |
---|
97 | |
---|
98 | |
---|
99 | |
---|
100 | |
---|
101 | // executeLayout->addWidget(boutonGo); |
---|
102 | |
---|
103 | // bouton execute |
---|
104 | exec_go_ = new WPushButton("execute!"); |
---|
105 | // exec_go_->setMinimumSize(300,300); |
---|
106 | exec_go_->setDisabled(true); |
---|
107 | exec_go_->clicked().connect(this, &PspaApplication::executer); |
---|
108 | // preparation du bouton add |
---|
109 | WPushButton* exec_add = new WPushButton("add"); |
---|
110 | exec_add->clicked().connect(this, &PspaApplication::addSectionToExecuteW); |
---|
111 | |
---|
112 | // preparation du bouton delete |
---|
113 | WPushButton* exec_delete = new WPushButton("delete"); |
---|
114 | exec_delete->clicked().connect(this, &PspaApplication::deleteSectionToExecuteW); |
---|
115 | |
---|
116 | // preparation du bouton push_ok |
---|
117 | WPushButton* exec_ok = new WPushButton("check/ok"); |
---|
118 | exec_ok->clicked().connect(this, &PspaApplication::checkSectionSelection); |
---|
119 | |
---|
120 | |
---|
121 | // le panel |
---|
122 | WPanel *panelLogiciels = new WPanel(executeW); |
---|
123 | panelLogiciels->setTitle(" sections of beam Line for executing softwares "); |
---|
124 | |
---|
125 | contenuSections_ = new WContainerWidget(); |
---|
126 | |
---|
127 | contenuSections_->addWidget( exec_add); |
---|
128 | contenuSections_->addWidget( exec_delete); |
---|
129 | contenuSections_->addWidget( exec_ok); |
---|
130 | contenuSections_->addWidget(exec_go_); |
---|
131 | contenuSections_->addWidget(new WBreak()); |
---|
132 | contenuSections_->addWidget(new WBreak()); |
---|
133 | addSectionToExecuteW(); |
---|
134 | |
---|
135 | panelLogiciels->setCentralWidget(contenuSections_); |
---|
136 | //executeLayout->addWidget(executeW); |
---|
137 | |
---|
138 | // executeW->setLayout(executeLayout); |
---|
139 | |
---|
140 | |
---|
141 | return executeW; |
---|
142 | } |
---|
143 | |
---|
144 | void PspaApplication::addSectionToExecuteW() |
---|
145 | { |
---|
146 | unsigned k; |
---|
147 | string premierText, dernierText; |
---|
148 | |
---|
149 | disableSectionExecute(); |
---|
150 | |
---|
151 | |
---|
152 | if ( selectedSections_.size() == 0) |
---|
153 | { |
---|
154 | premierText = "1"; |
---|
155 | dernierText = mixedTools::intToString( dtmanage_->beamLineSize() ); |
---|
156 | } |
---|
157 | else |
---|
158 | { |
---|
159 | dernierText = selectedSections_.back()->fin->text().toUTF8(); |
---|
160 | int dernierNumero = atoi(dernierText.c_str()); |
---|
161 | dernierNumero++; |
---|
162 | if ( dernierNumero <= dtmanage_->beamLineSize() ) |
---|
163 | { |
---|
164 | premierText = mixedTools::intToString(dernierNumero); |
---|
165 | dernierText = premierText; |
---|
166 | } |
---|
167 | else |
---|
168 | { |
---|
169 | premierText = mixedTools::intToString( dtmanage_->beamLineSize() ); |
---|
170 | dernierText = premierText; |
---|
171 | } |
---|
172 | } |
---|
173 | |
---|
174 | |
---|
175 | WContainerWidget* newSection = new WContainerWidget; |
---|
176 | |
---|
177 | selectedSections_.push_back(new GWt_sectionToExecute); |
---|
178 | selectedSections_.back()->debut = new WLineEdit(); |
---|
179 | selectedSections_.back()->debut->setDisabled(true); |
---|
180 | selectedSections_.back()->debut->setText(premierText); |
---|
181 | |
---|
182 | selectedSections_.back()->fin = new WLineEdit(); |
---|
183 | selectedSections_.back()->fin->changed().connect(this, &PspaApplication::disableSectionExecute); |
---|
184 | |
---|
185 | selectedSections_.back()->fin->setText(dernierText); |
---|
186 | selectedSections_.back()->selection = new WComboBox(); |
---|
187 | |
---|
188 | selectedSections_.back()->ligneDeWidget = newSection; |
---|
189 | |
---|
190 | |
---|
191 | // contenuSections_->addWidget(new WText(" from : ")); |
---|
192 | // contenuSections_->addWidget(selectedSections_.back()->debut); |
---|
193 | // contenuSections_->addWidget(new WText(" to : ")); |
---|
194 | // contenuSections_->addWidget(selectedSections_.back()->fin); |
---|
195 | // contenuSections_->addWidget(selectedSections_.back()->selection); |
---|
196 | |
---|
197 | // newSection->addWidget(new WBreak()); |
---|
198 | newSection->addWidget(new WText(" from : ")); |
---|
199 | newSection->addWidget(selectedSections_.back()->debut); |
---|
200 | newSection->addWidget(new WText(" to : ")); |
---|
201 | newSection->addWidget(selectedSections_.back()->fin); |
---|
202 | newSection->addWidget(selectedSections_.back()->selection); |
---|
203 | |
---|
204 | |
---|
205 | contenuSections_->addWidget(newSection); |
---|
206 | |
---|
207 | |
---|
208 | unsigned nb = nomDeLogiciel::getNumberOfSoftwares(); |
---|
209 | for ( k=0; k < nb; k++) selectedSections_.back()->selection->addItem( nomDeLogiciel(k).getString() ); |
---|
210 | } |
---|
211 | |
---|
212 | |
---|
213 | void PspaApplication::disableSectionExecute() |
---|
214 | { |
---|
215 | exec_go_->setDisabled(true); |
---|
216 | } |
---|
217 | |
---|
218 | void PspaApplication::checkSectionSelection() |
---|
219 | { |
---|
220 | if ( selectedSections_.empty() ) return; |
---|
221 | |
---|
222 | // traitement de la premiere ligne |
---|
223 | (*selectedSections_.begin())->debut->setText("1"); |
---|
224 | string currentString = (*selectedSections_.begin())->fin->text().toUTF8(); |
---|
225 | int current = atoi ( currentString.c_str() ); |
---|
226 | if ( current <= 0 ) |
---|
227 | { |
---|
228 | (*selectedSections_.begin())->fin->setText("1"); |
---|
229 | current = 1; |
---|
230 | } |
---|
231 | current++; |
---|
232 | if ( current > dtmanage_->beamLineSize() ) current = dtmanage_->beamLineSize(); |
---|
233 | currentString = mixedTools::intToString(current); |
---|
234 | |
---|
235 | |
---|
236 | // traitement des suivantes (on avance d'un cran dans la liste) |
---|
237 | list<GWt_sectionToExecute*>::iterator itr, itr0; |
---|
238 | itr0= selectedSections_.begin(); |
---|
239 | itr0++; |
---|
240 | for (itr= itr0; itr != selectedSections_.end(); itr++) |
---|
241 | { |
---|
242 | // string debString = (*itr)->debut->text().toUTF8(); |
---|
243 | // debut |
---|
244 | (*itr)->debut->setText( currentString ); |
---|
245 | // fin |
---|
246 | string finString = (*itr)->fin->text().toUTF8(); |
---|
247 | if ( atoi(finString.c_str() ) < current) |
---|
248 | { |
---|
249 | (*itr)->fin->setText( currentString ); |
---|
250 | } |
---|
251 | |
---|
252 | // preparation de la ligne suivante |
---|
253 | finString = (*itr)->fin->text().toUTF8(); |
---|
254 | current = atoi(finString.c_str()) +1; |
---|
255 | if ( current > dtmanage_->beamLineSize() ) current = dtmanage_->beamLineSize(); |
---|
256 | currentString = mixedTools::intToString(current); |
---|
257 | } |
---|
258 | exec_go_->setDisabled(false); |
---|
259 | } |
---|
260 | |
---|
261 | void PspaApplication::deleteSectionToExecuteW() |
---|
262 | { |
---|
263 | if ( selectedSections_.empty() ) return; |
---|
264 | disableSectionExecute(); |
---|
265 | selectedSections_.back()->ligneDeWidget->clear(); |
---|
266 | delete selectedSections_.back()->ligneDeWidget; |
---|
267 | selectedSections_.pop_back(); |
---|
268 | } |
---|
269 | |
---|
270 | PspaApplication::PspaApplication(const WEnvironment& env) |
---|
271 | : WApplication(env) |
---|
272 | { |
---|
273 | setTitle("portail PSPA"); // application title |
---|
274 | |
---|
275 | |
---|
276 | if (wApp->environment().javaScript()) { |
---|
277 | |
---|
278 | dtmanage_ = new dataManager(); |
---|
279 | |
---|
280 | WGridLayout* vBoxLayout = new WGridLayout(); |
---|
281 | |
---|
282 | // WContainerWidget* iconAndBeamLineContainer = new WContainerWidget(); |
---|
283 | |
---|
284 | WGridLayout* calculLayout = new WGridLayout(); |
---|
285 | |
---|
286 | |
---|
287 | WGridLayout *iconAndBeamLineLayout = new WGridLayout(); |
---|
288 | |
---|
289 | |
---|
290 | console_ = new WTextArea(); |
---|
291 | console_->setMaximumSize(600,200); |
---|
292 | |
---|
293 | |
---|
294 | WGridLayout* toolbarLayout = new WGridLayout(); |
---|
295 | |
---|
296 | |
---|
297 | // WPushButton *boutonGo = new WPushButton("execute!"); |
---|
298 | WPushButton* boutonSauve = new WPushButton(" sauvegarder la config"); |
---|
299 | WPushButton* boutonRestaure = new WPushButton(" restaurer la config"); |
---|
300 | // toolbarLayout->addWidget(boutonGo , 0, 0); |
---|
301 | toolbarLayout->addWidget(boutonSauve , 0, 1); |
---|
302 | toolbarLayout->addWidget(boutonRestaure , 0, 2); |
---|
303 | |
---|
304 | // boutonGo->clicked().connect(this, &PspaApplication::executer); |
---|
305 | boutonSauve->clicked().connect(this, &PspaApplication::sauver); |
---|
306 | boutonRestaure->clicked().connect(this, &PspaApplication::restaurer); |
---|
307 | |
---|
308 | beamLine_ = createBeamLine(); |
---|
309 | // calculLayout->addWidget(beamLine_ , 0, 0); |
---|
310 | |
---|
311 | globalParam_ = createGlobalParamWidget(); |
---|
312 | |
---|
313 | WWidget* executeWidget = createExecuteWidget(); |
---|
314 | |
---|
315 | WGridLayout* globLayout = new WGridLayout(); |
---|
316 | |
---|
317 | |
---|
318 | // WContainerWidget* toto = faireDessin(); |
---|
319 | |
---|
320 | leDessin_ = new WContainerWidget(); |
---|
321 | new WText("emittance", leDessin_); |
---|
322 | |
---|
323 | |
---|
324 | globLayout->addWidget(globalParam_,0,0); |
---|
325 | globLayout->addWidget(executeWidget,1,0); |
---|
326 | |
---|
327 | globLayout->addWidget(leDessin_,0,1); |
---|
328 | // calculLayout->addLayout(globLayout,1,0); |
---|
329 | |
---|
330 | // calculLayout->addWidget(globalParam_,1,0); |
---|
331 | |
---|
332 | |
---|
333 | calculLayout->addWidget(beamLine_ , 1, 0); |
---|
334 | calculLayout->addLayout(globLayout,2,0); |
---|
335 | calculLayout->addLayout(toolbarLayout ,0,0); |
---|
336 | iconAndBeamLineLayout->addWidget(createPalette() , 0, 0); |
---|
337 | iconAndBeamLineLayout->addLayout(calculLayout ,0,1); |
---|
338 | |
---|
339 | iconAndBeamLineLayout->setColumnResizable(0); |
---|
340 | iconAndBeamLineLayout->setColumnStretch(1,1); |
---|
341 | |
---|
342 | vBoxLayout->addLayout(iconAndBeamLineLayout,1,0); |
---|
343 | vBoxLayout->addWidget(console_,2,0); |
---|
344 | |
---|
345 | |
---|
346 | vBoxLayout->setRowResizable(0); |
---|
347 | vBoxLayout->setRowStretch(0,1); |
---|
348 | |
---|
349 | root()->setLayout(vBoxLayout); |
---|
350 | |
---|
351 | } else { |
---|
352 | new WText("<i>This examples requires that javascript support is enabled.</i>",root()); |
---|
353 | } |
---|
354 | |
---|
355 | } |
---|
356 | |
---|
357 | void PspaApplication::createDragImage(const char *url, const char *smallurl, |
---|
358 | const char *mimeType, |
---|
359 | WContainerWidget *p,WString name) |
---|
360 | { |
---|
361 | WImage *result = new WImage(url, p,name); |
---|
362 | WImage *dragImage = new WImage(smallurl, p); |
---|
363 | |
---|
364 | /* |
---|
365 | * Set the image to be draggable, showing the other image (dragImage) |
---|
366 | * to be used as the widget that is visually dragged. |
---|
367 | */ |
---|
368 | // printf(" setDraggable %s \n",mimeType); |
---|
369 | result->setDraggable(mimeType, dragImage, true); |
---|
370 | |
---|
371 | } |
---|
372 | |
---|
373 | |
---|
374 | // void PspaApplication::executer() |
---|
375 | // { |
---|
376 | // addConsoleMessage(string("on va peut etre y arriver")); |
---|
377 | // static_cast<GWt_globalParameters*>(globalParam_)->updateGlobals(); |
---|
378 | |
---|
379 | // int debut, fin; |
---|
380 | // nomDeLogiciel prog; |
---|
381 | // dtmanage_->clearSectionToExecute(); |
---|
382 | // list<GWt_sectionToExecute*>::iterator itr; |
---|
383 | // for (itr= selectedSections_.begin(); itr != selectedSections_.end(); itr++) |
---|
384 | // { |
---|
385 | // string debString = (*itr)->debut->text().toUTF8(); |
---|
386 | // string finString = (*itr)->fin->text().toUTF8(); |
---|
387 | // debut = atoi( debString.c_str() ); |
---|
388 | // fin = atoi( finString.c_str() ); |
---|
389 | // prog = nomDeLogiciel ( (*itr)->selection->currentIndex() ); |
---|
390 | // dtmanage_->addSectionToExecute(debut, fin, prog); |
---|
391 | // } |
---|
392 | |
---|
393 | // string resultat = dtmanage_->executeAll(); |
---|
394 | // addConsoleMessage(resultat); |
---|
395 | // faireDessin(); |
---|
396 | // } |
---|
397 | |
---|
398 | void PspaApplication::executer() |
---|
399 | { |
---|
400 | addConsoleMessage(string("on va peut etre y arriver")); |
---|
401 | static_cast<GWt_globalParameters*>(globalParam_)->updateGlobals(); |
---|
402 | |
---|
403 | int debut, fin; |
---|
404 | nomDeLogiciel prog; |
---|
405 | list<GWt_sectionToExecute*>::iterator itr; |
---|
406 | dtmanage_->initializeExecution(); |
---|
407 | for (itr= selectedSections_.begin(); itr != selectedSections_.end(); itr++) |
---|
408 | { |
---|
409 | string debString = (*itr)->debut->text().toUTF8(); |
---|
410 | string finString = (*itr)->fin->text().toUTF8(); |
---|
411 | debut = atoi( debString.c_str() ); |
---|
412 | fin = atoi( finString.c_str() ); |
---|
413 | prog = nomDeLogiciel ( (*itr)->selection->currentIndex() ); |
---|
414 | cout << " PspaApplication::executer() on lance l'execution de : " << prog.getString() << endl; |
---|
415 | string resul; |
---|
416 | if ( prog == nomDeLogiciel::parmela ) |
---|
417 | { |
---|
418 | resul = dtmanage_->executeParmela( debut, fin); |
---|
419 | faireDessin(); |
---|
420 | addConsoleMessage(resul); |
---|
421 | } |
---|
422 | else if ( prog == nomDeLogiciel::transport ) |
---|
423 | { |
---|
424 | resul = dtmanage_->executeTransport( debut, fin); |
---|
425 | faireDessinTransport(); |
---|
426 | addConsoleMessage(resul); |
---|
427 | } |
---|
428 | else |
---|
429 | { |
---|
430 | resul = " unknown software -- STOP \n "; |
---|
431 | addConsoleMessage(resul); |
---|
432 | break; |
---|
433 | } |
---|
434 | } |
---|
435 | } |
---|
436 | |
---|
437 | |
---|
438 | void PspaApplication::sauver() |
---|
439 | { |
---|
440 | cout << " on sauve " << endl; |
---|
441 | addConsoleMessage("sauvegarde"); |
---|
442 | GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); |
---|
443 | bibi->updateGlobals(); |
---|
444 | dtmanage_->saveAll(); |
---|
445 | |
---|
446 | } |
---|
447 | |
---|
448 | void PspaApplication::restaurer() |
---|
449 | { |
---|
450 | |
---|
451 | addConsoleMessage(string("restauration...")); |
---|
452 | |
---|
453 | dtmanage_->restoreAll(); |
---|
454 | |
---|
455 | GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); |
---|
456 | bibi->renew(); |
---|
457 | |
---|
458 | GWt_LigneFaisceau* bobo = static_cast<GWt_LigneFaisceau*>(beamLine_); |
---|
459 | |
---|
460 | bobo->restoreElementCollection(); |
---|
461 | addConsoleMessage(string("...terminee")); |
---|
462 | } |
---|
463 | |
---|
464 | |
---|
465 | |
---|
466 | void PspaApplication::faireDessin() |
---|
467 | { |
---|
468 | WContainerWidget* toto = leDessin_; |
---|
469 | toto->clear(); |
---|
470 | new WText("emittance", toto); |
---|
471 | vector<bareParticle>& partic = dtmanage_->getCurrentBeam().getParticleVector(); |
---|
472 | |
---|
473 | |
---|
474 | WStandardItemModel *model = new WStandardItemModel(partic.size(), 3, toto); |
---|
475 | // model->setHeaderData(0, WString("X")); |
---|
476 | // model->setHeaderData(1, WString("Y = sin(X)")); |
---|
477 | |
---|
478 | |
---|
479 | for (unsigned i = 0; i < partic.size(); ++i) { |
---|
480 | double x= partic.at(i).getPosition().getComponent(0); |
---|
481 | double begamz = partic.at(i).getBetaGamma().getComponent(2); |
---|
482 | double xp = partic.at(i).getBetaGamma().getComponent(0)/begamz; |
---|
483 | // cout << "x = " << x << " xp= " << xp << endl; |
---|
484 | model->setData(i, 0, 10*x); |
---|
485 | model->setData(i, 1,1.e3*xp); |
---|
486 | model->setData(i, 2,2.e3*xp); |
---|
487 | } |
---|
488 | |
---|
489 | WCartesianChart *chart = new WCartesianChart(toto); |
---|
490 | chart->setModel(model); // set the model |
---|
491 | chart->setXSeriesColumn(0); // set the column that holds the X data |
---|
492 | chart->setLegendEnabled(true); // enable the legend |
---|
493 | |
---|
494 | chart->setType(ScatterPlot); // set type to ScatterPlot |
---|
495 | |
---|
496 | // Typically, for mathematical functions, you want the axes to cross |
---|
497 | // at the 0 mark: |
---|
498 | chart->axis(XAxis).setLocation(ZeroValue); |
---|
499 | chart->axis(YAxis).setLocation(ZeroValue); |
---|
500 | |
---|
501 | // Provide space for the X and Y axis and title. |
---|
502 | chart->setPlotAreaPadding(80, Left); |
---|
503 | chart->setPlotAreaPadding(40, Top | Bottom); |
---|
504 | // Add the curves |
---|
505 | WDataSeries s(1, PointSeries, Y1Axis); |
---|
506 | // s.setShadow(WShadow(3, 3, WColor(0, 0, 0, 127), 3)); |
---|
507 | // s.setMarker(SquareMarker); |
---|
508 | // s.setMarkerSize(600.); |
---|
509 | // cout << "le marker est : " << s.marker() << endl; |
---|
510 | chart->addSeries(s); |
---|
511 | |
---|
512 | chart->resize(300, 300); // WPaintedWidget must be given explicit size |
---|
513 | |
---|
514 | // chart->setMargin(10, Top | Bottom); // add margin vertically |
---|
515 | // chart->setMargin(WLength::Auto, Left | Right); // center horizontally |
---|
516 | } |
---|
517 | |
---|
518 | |
---|
519 | // void PspaApplication::addElemToGlobals() |
---|
520 | // { |
---|
521 | // static_cast<GWt_globalParameters*>(globalParam_)->addElem(); |
---|
522 | // } |
---|
523 | |
---|
524 | void PspaApplication::faireDessinTransport() |
---|
525 | { |
---|
526 | WContainerWidget* toto = leDessin_; |
---|
527 | toto->clear(); |
---|
528 | new WText("emittance transport", toto); |
---|
529 | |
---|
530 | vector<double> xcor; |
---|
531 | vector<double> ycor; |
---|
532 | dtmanage_->getCurrentBeam().donneesDessinEllipseXxp(xcor,ycor); |
---|
533 | int nbpts = xcor.size(); |
---|
534 | cout << " PspaApplication::faireDessinTransport() nbpts = " << nbpts << endl; |
---|
535 | WStandardItemModel *model = new WStandardItemModel(nbpts, 2, toto); |
---|
536 | for (int i = 0; i < nbpts; ++i) { |
---|
537 | model->setData(i, 0, xcor.at(i)); |
---|
538 | model->setData(i, 1, ycor.at(i)); |
---|
539 | } |
---|
540 | |
---|
541 | WCartesianChart *chart = new WCartesianChart(toto); |
---|
542 | chart->setModel(model); // set the model |
---|
543 | chart->setXSeriesColumn(0); // set the column that holds the X data |
---|
544 | chart->setLegendEnabled(true); // enable the legend |
---|
545 | |
---|
546 | chart->setType(ScatterPlot); // set type to ScatterPlot |
---|
547 | |
---|
548 | // Typically, for mathematical functions, you want the axes to cross |
---|
549 | // at the 0 mark: |
---|
550 | chart->axis(XAxis).setLocation(ZeroValue); |
---|
551 | chart->axis(YAxis).setLocation(ZeroValue); |
---|
552 | |
---|
553 | // Provide space for the X and Y axis and title. |
---|
554 | chart->setPlotAreaPadding(80, Left); |
---|
555 | chart->setPlotAreaPadding(40, Top | Bottom); |
---|
556 | // Add the curves |
---|
557 | WDataSeries s(1, CurveSeries, Y1Axis); |
---|
558 | chart->addSeries(s); |
---|
559 | |
---|
560 | chart->resize(300, 300); // WPaintedWidget must be given explicit size |
---|
561 | |
---|
562 | } |
---|
563 | |
---|
564 | |
---|
565 | |
---|
566 | |
---|
567 | void PspaApplication::updateSelections() |
---|
568 | { |
---|
569 | string premierText, dernierText; |
---|
570 | if ( selectedSections_.size() > 0 ) |
---|
571 | { |
---|
572 | premierText = "1"; |
---|
573 | dernierText = mixedTools::intToString( dtmanage_->beamLineSize() ); |
---|
574 | (*selectedSections_.begin())->debut->setText(premierText); |
---|
575 | (*selectedSections_.begin())->fin->setText(dernierText); |
---|
576 | } |
---|
577 | |
---|
578 | } |
---|