1 | #include <stdio.h> |
---|
2 | #include <string.h> |
---|
3 | #include <vector> |
---|
4 | |
---|
5 | #include "GWt_pspaApplication.h" |
---|
6 | #include "GWt_ligneFaisceau.h" |
---|
7 | #include "GWt_softwarePanel.h" |
---|
8 | #include "GWt_globalParameters.h" |
---|
9 | // #include "GWt_dialog.h" |
---|
10 | #include "GWt_draggableImage.h" |
---|
11 | #include "particleBeam.h" |
---|
12 | #include "bareParticle.h" |
---|
13 | #include "nomDeLogiciel.h" |
---|
14 | #include "mixedTools.h" |
---|
15 | #include "nomdElements.h" |
---|
16 | #include "environmentVariables.h" |
---|
17 | #include "GWt_console.h" |
---|
18 | #include "GWt_serverFileSelector.h" |
---|
19 | #include "trivaluedBool.h" |
---|
20 | |
---|
21 | #include <Wt/WGridLayout> |
---|
22 | #include <Wt/WVBoxLayout> |
---|
23 | #include <Wt/WHBoxLayout> |
---|
24 | #include <Wt/WImage> |
---|
25 | #include <Wt/WMenu> |
---|
26 | #include <Wt/WStackedWidget> |
---|
27 | #include <Wt/WBreak> |
---|
28 | #include <Wt/WDialog> |
---|
29 | #include <Wt/WStandardItemModel> |
---|
30 | #include <Wt/WFileUpload> |
---|
31 | #include <Wt/WPainter> |
---|
32 | #include <Wt/WPdfImage> |
---|
33 | #include <Wt/WRasterImage> |
---|
34 | #include <Wt/WScrollArea> |
---|
35 | #include <Wt/WLineEdit> |
---|
36 | #include <Wt/WRadioButton> |
---|
37 | |
---|
38 | using namespace Wt::Chart; |
---|
39 | |
---|
40 | /* |
---|
41 | * The env argument contains information about the new session, and |
---|
42 | * the initial request. It must be passed to the WApplication |
---|
43 | * constructor so it is typically also an argument for your custom |
---|
44 | * application constructor. |
---|
45 | */ |
---|
46 | |
---|
47 | PspaApplication::PspaApplication(const WEnvironment& env) : |
---|
48 | WApplication(env), |
---|
49 | applicationDefaultTitle_("portail PSPA"), |
---|
50 | beamLine_(NULL), |
---|
51 | extensionFile_(0) |
---|
52 | { |
---|
53 | workingDir_ = WApplication::docRoot()+ "/"+WORKINGAREA; |
---|
54 | nameOfCase_ = "pspa"; // default |
---|
55 | |
---|
56 | setTitle(applicationDefaultTitle_); // application title |
---|
57 | if (!wApp->environment().javaScript()) { |
---|
58 | new WText("<i>This examples requires that javascript support is enabled.</i>",root()); |
---|
59 | } |
---|
60 | |
---|
61 | // register the absractElementFactory |
---|
62 | abstractElementFactory_ = new GWt_abstractElementFactory(); |
---|
63 | abstractElementFactory_->setRFGunEnable(true); |
---|
64 | abstractElementFactory_->setDriftEnable(true); |
---|
65 | abstractElementFactory_->setCellEnable(true); |
---|
66 | abstractElementFactory_->setBendEnable(true); |
---|
67 | abstractElementFactory_->setSolenoEnable(true); |
---|
68 | abstractElementFactory_->setBeamEnable(true); |
---|
69 | abstractElementFactory_->setFitEnable(true); |
---|
70 | abstractElementFactory_->setSnapshotEnable(true); |
---|
71 | |
---|
72 | // include the styleSheet |
---|
73 | WContainerWidget *widroot = root(); |
---|
74 | useStyleSheet("htdocs/pspa.css"); |
---|
75 | dtmanage_ = new dataManager(this); |
---|
76 | // dtmanage_->setWorkingDir(workingDir_); |
---|
77 | |
---|
78 | /* |
---|
79 | * The main layout is a 3x2 grid layout. |
---|
80 | */ |
---|
81 | WGridLayout *layout = new WGridLayout(); |
---|
82 | // layout->addWidget(createTitle("<a href='workingArea/parmin'> Menu (In future)</a>"), 0, 0, 1, 2); |
---|
83 | // layout->addWidget(createTitle("Menu (In future)"), 0, 0, 1, 2); |
---|
84 | |
---|
85 | WHBoxLayout *toolbarLayout = new WHBoxLayout(); |
---|
86 | |
---|
87 | WPushButton* boutonSauve = new WPushButton(); |
---|
88 | WPushButton* boutonRestaure = new WPushButton(); |
---|
89 | WPushButton* boutonLoadNew = new WPushButton(); |
---|
90 | WPushButton* boutongraphicalAnalysis = new WPushButton(); |
---|
91 | WPushButton* boutonTrash = new WPushButton(); |
---|
92 | |
---|
93 | boutonSauve->setStyleClass("saveButton"); |
---|
94 | boutonRestaure->setStyleClass("restoreButton"); |
---|
95 | boutonLoadNew->setStyleClass("loadNewButton"); |
---|
96 | boutongraphicalAnalysis->setStyleClass("histoButton"); |
---|
97 | boutonTrash->setStyleClass("trashButton"); |
---|
98 | |
---|
99 | boutonSauve->setToolTip ("sauvegarder votre configuration"); |
---|
100 | boutonRestaure->setToolTip (" restaurer la configuration depuis le serveur"); |
---|
101 | boutonLoadNew->setToolTip ("charger une configuration"); |
---|
102 | boutongraphicalAnalysis->setToolTip ("analyse graphique"); |
---|
103 | boutonTrash->setToolTip ("tout effacer"); |
---|
104 | |
---|
105 | boutonSauve->setMaximumSize(38,38); |
---|
106 | boutonSauve->setMinimumSize(38,38); |
---|
107 | boutonRestaure->setMaximumSize(38,38); |
---|
108 | boutonRestaure->setMinimumSize(38,38); |
---|
109 | boutonLoadNew->setMaximumSize(38,38); |
---|
110 | boutonLoadNew->setMinimumSize(38,38); |
---|
111 | boutongraphicalAnalysis->setMaximumSize(38,38); |
---|
112 | boutongraphicalAnalysis->setMinimumSize(38,38); |
---|
113 | boutonTrash->setMaximumSize(38,38); |
---|
114 | boutonTrash->setMinimumSize(38,38); |
---|
115 | |
---|
116 | boutonSauve->clicked().connect(this, &PspaApplication::sauver); |
---|
117 | boutonRestaure->clicked().connect(this, &PspaApplication::restaurer); |
---|
118 | // Upload when the button is clicked. |
---|
119 | // React to a succesfull upload. |
---|
120 | boutonLoadNew->clicked().connect(this, &PspaApplication::openFileSelector); |
---|
121 | |
---|
122 | boutongraphicalAnalysis->clicked().connect(this, &PspaApplication::dialogOnGraphics); |
---|
123 | |
---|
124 | boutonTrash->clicked().connect(this, &PspaApplication::removeBeamLine); |
---|
125 | |
---|
126 | toolbarLayout->addWidget(boutonSauve , 0,Wt::AlignMiddle); |
---|
127 | toolbarLayout->addWidget(boutonRestaure , 0,Wt::AlignMiddle); |
---|
128 | toolbarLayout->addWidget(boutonLoadNew , 0,Wt::AlignMiddle); |
---|
129 | toolbarLayout->addWidget(boutongraphicalAnalysis , 0,Wt::AlignMiddle); |
---|
130 | toolbarLayout->addWidget(boutonTrash , 0,Wt::AlignMiddle); |
---|
131 | toolbarLayout->addWidget(new WText("") , 1,Wt::AlignMiddle); |
---|
132 | |
---|
133 | WContainerWidget * layoutContainer = new WContainerWidget(); |
---|
134 | layoutContainer->setLayout(toolbarLayout); |
---|
135 | layoutContainer->decorationStyle().setBackgroundImage ("/htdocs/fond_toolbar.png"); |
---|
136 | layout->addWidget(layoutContainer, 1, 0, 1, 2); |
---|
137 | layout->addWidget(createPalette(), 2, 0, 4, 1); |
---|
138 | |
---|
139 | createBeamLine(); |
---|
140 | |
---|
141 | WScrollArea* scroll = new WScrollArea(); |
---|
142 | scroll->setWidget(beamLine_); |
---|
143 | layout->addWidget(scroll, 2, 1, 1, 1); |
---|
144 | |
---|
145 | |
---|
146 | // console_ = new WContainerWidget(); |
---|
147 | // console_->decorationStyle().setBackgroundColor (WColor("lightgray")); |
---|
148 | // console_->setMaximumSize(600,200); |
---|
149 | // layout->addWidget(console_, 3, 1); |
---|
150 | // console_->setMinimumSize(300,100); |
---|
151 | // console_->setOverflow(WContainerWidget::OverflowAuto); |
---|
152 | |
---|
153 | |
---|
154 | console_ = new GWt_console(); |
---|
155 | console_->clear(); |
---|
156 | console_->decorationStyle().setBackgroundColor (WColor("lightgray")); |
---|
157 | console_->setMaximumSize(600,200); |
---|
158 | console_->setMinimumSize(300,100); |
---|
159 | console_->setOverflow(WContainerWidget::OverflowAuto); |
---|
160 | layout->addWidget(console_, 3, 2); |
---|
161 | |
---|
162 | //----------- |
---|
163 | // A supprimer et a mettre en fenetre |
---|
164 | globalParam_ = createGlobalParamWidget(); |
---|
165 | // leDessin_ = new WContainerWidget(); |
---|
166 | // leDessin_ = createDrawingWidget(); |
---|
167 | graphicsDialog_ = new GWt_dialog("graphical analysis",createDrawingWidget(),false); |
---|
168 | graphicsDialog_->setMinimumSize(400,400); |
---|
169 | graphicsDialog_->setClosable(true); |
---|
170 | |
---|
171 | executeWidget_ = new GWt_softwarePanel(dtmanage_,this); |
---|
172 | |
---|
173 | layout->addWidget( globalParam_, 3, 1); |
---|
174 | // layout->addWidget( leDessin_, 3, 2); |
---|
175 | layout->addWidget( executeWidget_ , 4, 1); |
---|
176 | //----------- |
---|
177 | |
---|
178 | layout->setColumnResizable(1); |
---|
179 | layout->setRowResizable(2); |
---|
180 | /* |
---|
181 | * Let row 2 and column 1 take the excess space. |
---|
182 | */ |
---|
183 | layout->setRowStretch(2, 1); |
---|
184 | layout->setColumnStretch(1, 1); |
---|
185 | |
---|
186 | widroot->setLayout(layout); |
---|
187 | } |
---|
188 | |
---|
189 | WWidget* PspaApplication::createPalette() |
---|
190 | { |
---|
191 | WContainerWidget* palette = new WContainerWidget(); |
---|
192 | vector <GWt_abstractElement*> elems = abstractElementFactory_->getAllElements(); |
---|
193 | for (unsigned a = 0; a < elems.size(); a++) { |
---|
194 | elems[a]->createDragImage(palette); |
---|
195 | new WBreak(palette); |
---|
196 | } |
---|
197 | |
---|
198 | return palette; |
---|
199 | } |
---|
200 | |
---|
201 | void PspaApplication::createDragImage(const char *url,const char *smallurl,const char *mimeType,WContainerWidget *p,WString()) |
---|
202 | { |
---|
203 | GWt_draggableImage *result = new GWt_draggableImage(url,p); |
---|
204 | |
---|
205 | /* |
---|
206 | * Set the image to be draggable, showing the other image (dragImage) |
---|
207 | * to be used as the widget that is visually dragged. |
---|
208 | */ |
---|
209 | result->setDraggable(mimeType,new WImage(smallurl,p),true); |
---|
210 | } |
---|
211 | |
---|
212 | void PspaApplication::createBeamLine() |
---|
213 | { |
---|
214 | extensionFile_= 0; |
---|
215 | if (!beamLine_) { |
---|
216 | beamLine_ = new GWt_LigneFaisceau(this); |
---|
217 | } else { |
---|
218 | beamLine_->clear(); |
---|
219 | } |
---|
220 | beamLine_->setMinimumSize(300,100); |
---|
221 | setTitle(applicationDefaultTitle_); |
---|
222 | } |
---|
223 | |
---|
224 | WWidget* PspaApplication::createGlobalParamWidget() |
---|
225 | { |
---|
226 | WContainerWidget* globalParam = new GWt_globalParameters(this); |
---|
227 | globalParam->setMaximumSize(600,150); |
---|
228 | globalParam->setMinimumSize(600,150); |
---|
229 | return globalParam; |
---|
230 | } |
---|
231 | |
---|
232 | |
---|
233 | void PspaApplication::dialogOnGraphics() |
---|
234 | { |
---|
235 | graphicsDialog_->show(); |
---|
236 | } |
---|
237 | |
---|
238 | WContainerWidget* PspaApplication::createDrawingWidget() |
---|
239 | { |
---|
240 | WGridLayout *glayout= new WGridLayout(); |
---|
241 | WContainerWidget* dessin = new WContainerWidget(); |
---|
242 | dessin->setLayout(glayout); |
---|
243 | |
---|
244 | group_ = new Wt::WButtonGroup(this); |
---|
245 | |
---|
246 | ///////////////////////////////////////////////////////////////////// |
---|
247 | |
---|
248 | choixEnveloppeDessin_ = new WComboBox(); |
---|
249 | choixEnveloppeDessin_->addItem("x"); |
---|
250 | // choixEnveloppeDessin_->addItem("y"); |
---|
251 | Wt::WRadioButton *button1= new WRadioButton(" enveloppe"); |
---|
252 | group_->addButton(button1,1); |
---|
253 | glayout->addWidget(button1,0,1); |
---|
254 | glayout->addWidget(choixEnveloppeDessin_,0,2); |
---|
255 | ///////////////////////////////////////////////////////////////////// |
---|
256 | |
---|
257 | choixElementDessin_ = new WComboBox(); |
---|
258 | choixElementDessin_->setMinimumSize(50,10); |
---|
259 | choixTypeDessinFaisceau_ = new WComboBox(); |
---|
260 | choixTypeDessinFaisceau_->addItem("courant_snyder"); |
---|
261 | choixTypeDessinFaisceau_->addItem("macroparticles"); |
---|
262 | Wt::WRadioButton *button2= new WRadioButton(" phase space after element"); |
---|
263 | |
---|
264 | choixAbsPhase_ = new WComboBox(); |
---|
265 | choixAbsPhase_->addItem("x"); |
---|
266 | choixAbsPhase_->addItem("y"); |
---|
267 | choixAbsPhase_->addItem("dz"); |
---|
268 | choixAbsPhase_->addItem("xp"); |
---|
269 | choixAbsPhase_->addItem("yp"); |
---|
270 | choixAbsPhase_->addItem("dE/E"); |
---|
271 | choixAbsPhase_->setCurrentIndex(0); |
---|
272 | |
---|
273 | choixOrdPhase_ = new WComboBox(); |
---|
274 | choixOrdPhase_->addItem("x"); |
---|
275 | choixOrdPhase_->addItem("y"); |
---|
276 | choixOrdPhase_->addItem("dz"); |
---|
277 | choixOrdPhase_->addItem("xp"); |
---|
278 | choixOrdPhase_->addItem("yp"); |
---|
279 | choixOrdPhase_->addItem("dE/E"); |
---|
280 | choixOrdPhase_->setCurrentIndex(3); |
---|
281 | |
---|
282 | group_->addButton(button2,2); |
---|
283 | glayout->addWidget(button2,1,1); |
---|
284 | glayout->addWidget(choixElementDessin_,1,2); |
---|
285 | glayout->addWidget(choixTypeDessinFaisceau_,1,3); |
---|
286 | // glayout->addWidget(new WText("abs. :"),2,2); |
---|
287 | glayout->addWidget(choixAbsPhase_,2,2); |
---|
288 | // glayout->addWidget(new WText("ord. :"),2,4); |
---|
289 | glayout->addWidget(choixOrdPhase_,2,3); |
---|
290 | ///////////////////////////////////////////////////////////////////// |
---|
291 | |
---|
292 | choixVariableHisto_= new WComboBox(); |
---|
293 | choixVariableHisto_->addItem("x"); |
---|
294 | choixVariableHisto_->addItem("y"); |
---|
295 | choixVariableHisto_->addItem("z"); |
---|
296 | choixVariableHisto_->addItem("xp"); |
---|
297 | choixVariableHisto_->addItem("yp"); |
---|
298 | choixVariableHisto_->addItem("dE/E"); |
---|
299 | choixVariableHisto_->setCurrentIndex(5); |
---|
300 | |
---|
301 | choixHistoDessin_ = new WComboBox(); |
---|
302 | Wt::WRadioButton *button3= new WRadioButton(" histogram after element "); |
---|
303 | group_->addButton(button3,3); |
---|
304 | |
---|
305 | glayout->addWidget(button3,3,1); |
---|
306 | glayout->addWidget(choixHistoDessin_,3,2); |
---|
307 | glayout->addWidget(choixVariableHisto_,3,3); |
---|
308 | ///////////////////////////////////////////////////////////////////// |
---|
309 | |
---|
310 | WPushButton *close= new WPushButton("close"); |
---|
311 | glayout->addWidget(close,4,1); |
---|
312 | close->clicked().connect(this,&PspaApplication::closeGraphicDialog); |
---|
313 | |
---|
314 | WPushButton *draw= new WPushButton("draw"); |
---|
315 | glayout->addWidget(draw,4,2,2,1); |
---|
316 | draw->clicked().connect(this,&PspaApplication::dessiner); |
---|
317 | ///////////////////////////////////////////////////////////////////// |
---|
318 | |
---|
319 | toto_ = new WContainerWidget(); |
---|
320 | dessin->addWidget(toto_); |
---|
321 | return dessin; |
---|
322 | } |
---|
323 | |
---|
324 | void PspaApplication::closeGraphicDialog() |
---|
325 | { |
---|
326 | cout << " close graphicsDialog_" << endl; |
---|
327 | for(unsigned i = 0; i < eDialog_.size(); i++) eDialog_[i]->done(WDialog::Rejected); |
---|
328 | eDialog_.clear(); |
---|
329 | graphicsDialog_->done(WDialog::Rejected); |
---|
330 | } |
---|
331 | |
---|
332 | void PspaApplication::dessiner() |
---|
333 | { |
---|
334 | int k= group_->checkedId(); |
---|
335 | cout << "dessiner k= " << k << endl; |
---|
336 | |
---|
337 | switch(k) { |
---|
338 | case 1: |
---|
339 | dessinerEnveloppe(); |
---|
340 | break; |
---|
341 | case 2: |
---|
342 | dessinerPhaseSpace(); |
---|
343 | break; |
---|
344 | case 3: |
---|
345 | dessinerHistogramme(); |
---|
346 | break; |
---|
347 | default: |
---|
348 | GWt_dialog graphicalWarning("graphical analysis","select a button",GWt_dialog::Warning,false,true); |
---|
349 | graphicalWarning.exec(); |
---|
350 | break; |
---|
351 | } |
---|
352 | } |
---|
353 | |
---|
354 | |
---|
355 | void PspaApplication::sauver() |
---|
356 | { |
---|
357 | cout << " on sauve " << endl; |
---|
358 | console_->addConsoleMessage("sauvegarde"); |
---|
359 | |
---|
360 | dialogSave_ = new WDialog("save"); |
---|
361 | new WText("name of case : ",dialogSave_->contents()); |
---|
362 | saveNameEdit_ = new WLineEdit(nameOfCase_.c_str(), dialogSave_->contents()); |
---|
363 | WPushButton *annule = new WPushButton("cancel",dialogSave_->contents()); |
---|
364 | WPushButton *submit = new WPushButton("OK",dialogSave_->contents()); |
---|
365 | annule->clicked().connect(dialogSave_, &Wt::WDialog::reject); |
---|
366 | submit->clicked().connect(dialogSave_, &Wt::WDialog::accept); |
---|
367 | dialogSave_->finished().connect(this, &PspaApplication::dialogSaveDone); |
---|
368 | dialogSave_->show(); |
---|
369 | } |
---|
370 | |
---|
371 | |
---|
372 | void PspaApplication::dialogSaveDone(WDialog::DialogCode code) |
---|
373 | { |
---|
374 | if ( code != Wt::WDialog::Accepted ) { |
---|
375 | return; |
---|
376 | } |
---|
377 | nameOfCase_ = saveNameEdit_->text().toUTF8(); |
---|
378 | delete dialogSave_; |
---|
379 | dialogSave_ = NULL; |
---|
380 | |
---|
381 | GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); |
---|
382 | bibi->updateGlobals(); |
---|
383 | // dtmanage_->saveConfiguration(nameOfCase_); |
---|
384 | dtmanage_->saveConfiguration(sessionId(),nameOfCase_); |
---|
385 | } |
---|
386 | |
---|
387 | |
---|
388 | void PspaApplication::restaurer() |
---|
389 | { |
---|
390 | GWt_serverFileSelector * fs = new GWt_serverFileSelector("Select a configuration file",workingDir_); |
---|
391 | string fileName = fs->exec(); |
---|
392 | nameOfCase_ = fileName; |
---|
393 | if (fileName == "") { |
---|
394 | return; |
---|
395 | } |
---|
396 | |
---|
397 | removePathFromConfigName(nameOfCase_ ); |
---|
398 | cout << " nom sans path " << nameOfCase_ << endl; |
---|
399 | removeExtensionFromConfigName(nameOfCase_); |
---|
400 | cout << " nom sans extension " << nameOfCase_ << endl; |
---|
401 | if (nameOfCase_ == "") |
---|
402 | return; |
---|
403 | cout << " je restaure le fichier " << fileName << endl; |
---|
404 | dialogSave_ = NULL; |
---|
405 | |
---|
406 | bool test = dtmanage_->restoreElements(fileName); |
---|
407 | if ( !test ) { |
---|
408 | GWt_dialog restoreWarning(" element restoring", "failure in restoring elements from file : " + fileName , GWt_dialog::Error, false,true); |
---|
409 | restoreWarning.exec(); |
---|
410 | } else { |
---|
411 | // Change the window title |
---|
412 | unsigned long found = fileName.find_last_of("/"); |
---|
413 | setTitle(applicationDefaultTitle_+" : "+fileName.substr(found+1)); |
---|
414 | } |
---|
415 | |
---|
416 | GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); |
---|
417 | bibi->renew(); |
---|
418 | |
---|
419 | console_->addConsoleMessage(string("...terminee")); |
---|
420 | } |
---|
421 | |
---|
422 | void PspaApplication::openFileSelector() |
---|
423 | { |
---|
424 | |
---|
425 | WContainerWidget *result = new WContainerWidget(); |
---|
426 | WVBoxLayout* myLayout = new WVBoxLayout(); |
---|
427 | |
---|
428 | uploadFileSelectorWidget_ = new WFileUpload(); |
---|
429 | |
---|
430 | uploadFileSelectorWidget_->setFileTextSize(40); |
---|
431 | |
---|
432 | myLayout->addWidget(new WText("Select the configuration file for pspa : ")); |
---|
433 | myLayout->addWidget(uploadFileSelectorWidget_); |
---|
434 | |
---|
435 | result->setLayout (myLayout); |
---|
436 | |
---|
437 | // Upload automatically when the user entered a file. |
---|
438 | uploadFileSelectorWidget_->changed().connect(uploadFileSelectorWidget_, &WFileUpload::upload); |
---|
439 | |
---|
440 | // React to a succesfull upload. |
---|
441 | uploadFileSelectorWidget_->uploaded().connect(this, &PspaApplication::chargerConfig); |
---|
442 | |
---|
443 | // React to a fileupload problem. |
---|
444 | uploadFileSelectorWidget_->fileTooLarge().connect(this, &PspaApplication::fileTooLarge); |
---|
445 | |
---|
446 | |
---|
447 | GWt_dialog* fileSelectorDialog = new GWt_dialog("Load a file",result,false); |
---|
448 | |
---|
449 | fileSelectorDialog->exec(); |
---|
450 | } |
---|
451 | |
---|
452 | void PspaApplication::chargerConfig() |
---|
453 | { |
---|
454 | GWt_dialog* message= new GWt_dialog("File successfully upload","The file has been correctly upload to" + uploadFileSelectorWidget_->spoolFileName(),GWt_dialog::Warning,false,true); |
---|
455 | |
---|
456 | string nomDuFichier = (uploadFileSelectorWidget_->clientFileName()).toUTF8(); |
---|
457 | cout << " fichier client : " << nomDuFichier << endl; |
---|
458 | bool test = removeExtensionFromConfigName(nomDuFichier); |
---|
459 | cout << " fichier client sans extension : " << nomDuFichier << endl; |
---|
460 | |
---|
461 | if ( test ) |
---|
462 | { |
---|
463 | nameOfCase_ = nomDuFichier; |
---|
464 | console_->addConsoleMessage(string("restauration...")); |
---|
465 | |
---|
466 | if ( !dtmanage_->restoreElements(uploadFileSelectorWidget_->spoolFileName()) ) { |
---|
467 | GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true); |
---|
468 | restoreWarning.exec(); |
---|
469 | } |
---|
470 | |
---|
471 | GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); |
---|
472 | bibi->renew(); |
---|
473 | |
---|
474 | console_->addConsoleMessage(string("...terminee")); |
---|
475 | message->show(); |
---|
476 | } |
---|
477 | } |
---|
478 | |
---|
479 | void PspaApplication::fileTooLarge() |
---|
480 | { |
---|
481 | std::stringstream stream; |
---|
482 | stream << maximumRequestSize (); |
---|
483 | std::string maxRequestSize(stream.str()); |
---|
484 | |
---|
485 | std::string message = "This file is too large, please select a one\n"; |
---|
486 | message += "Maximum file size is "+ maxRequestSize; |
---|
487 | message += " bytes\n"; |
---|
488 | |
---|
489 | GWt_dialog* messageBox= new GWt_dialog("Error during upload file" ,message ,GWt_dialog::Error,false,true); |
---|
490 | |
---|
491 | messageBox->show(); |
---|
492 | } |
---|
493 | |
---|
494 | void PspaApplication::faireDessin() |
---|
495 | { |
---|
496 | choixElementDessin_->clear(); |
---|
497 | choixHistoDessin_->clear(); |
---|
498 | |
---|
499 | int nombre = dtmanage_->getBeamLineSize(); |
---|
500 | for(int i = 1; i <= nombre; i++) { |
---|
501 | abstractElement* elPtr = dtmanage_->getElementPointerFromNumero(i); |
---|
502 | if(elPtr->getNomdElement().getElementType() == snapshot) continue; |
---|
503 | |
---|
504 | choixElementDessin_->addItem(elPtr->getLabel()); |
---|
505 | choixHistoDessin_->addItem(elPtr->getLabel()); |
---|
506 | } |
---|
507 | } |
---|
508 | |
---|
509 | void PspaApplication::dessinerPhaseSpace() |
---|
510 | { |
---|
511 | |
---|
512 | int typeFaisceau = choixTypeDessinFaisceau_->currentIndex(); |
---|
513 | int index = choixElementDessin_->currentIndex(); |
---|
514 | string nameAbs = choixAbsPhase_->currentText().toUTF8(); |
---|
515 | string nameOrd = choixOrdPhase_->currentText().toUTF8(); |
---|
516 | if ( nameAbs == nameOrd ) { |
---|
517 | GWt_dialog phaseSpaceError(" graphical analysis", "the beam coordinates must be different !", GWt_dialog::Error, false,true); |
---|
518 | phaseSpaceError.exec(); |
---|
519 | return; |
---|
520 | } |
---|
521 | |
---|
522 | particleBeam* beam = dtmanage_->getDiagnosticBeam(index); |
---|
523 | |
---|
524 | if ( beam == NULL ) { |
---|
525 | GWt_dialog warningBeamState(" graphical analysis", "the beam does not exist at the end of this element !", GWt_dialog::Error, false,true); |
---|
526 | warningBeamState.exec(); |
---|
527 | return; |
---|
528 | } |
---|
529 | |
---|
530 | toto_->clear(); |
---|
531 | faireDessinPhaseSpace(toto_, beam, nameAbs, nameOrd, typeFaisceau); |
---|
532 | |
---|
533 | // if ( typeFaisceau == 0 ) |
---|
534 | // { |
---|
535 | // if ( !beam->momentRepresentationOk() ) beam->buildMomentRepresentation(); |
---|
536 | // faireDessinTransport(toto_, beam, nameAbs, nameOrd ); |
---|
537 | // } |
---|
538 | // else if ( typeFaisceau == 1 ) |
---|
539 | // { |
---|
540 | // if ( beam->particleRepresentationOk() ) faireDessinParmela(toto_, beam, nameAbs, nameOrd ); |
---|
541 | // else { |
---|
542 | // GWt_dialog warningBeamState(" graphical analysis", "the beam state does not allow providing a drawing with macroparticles !", GWt_dialog::Error, false,true); |
---|
543 | // warningBeamState.exec(); |
---|
544 | // } |
---|
545 | // } |
---|
546 | // else { |
---|
547 | // GWt_dialog warningTypeDrawing(" graphical analysis", "type of drawing not programmed !", GWt_dialog::Error, false,true); |
---|
548 | // warningTypeDrawing.exec(); |
---|
549 | // } |
---|
550 | } |
---|
551 | |
---|
552 | void PspaApplication::dessinerEnveloppe() |
---|
553 | { |
---|
554 | toto_->clear(); |
---|
555 | |
---|
556 | int typeEnveloppe = choixEnveloppeDessin_->currentIndex(); |
---|
557 | if ( typeEnveloppe == 0 ) |
---|
558 | { |
---|
559 | faireDessinEnveloppe(toto_, "x"); |
---|
560 | } |
---|
561 | else { |
---|
562 | GWt_dialog warningTypeEnveloppe(" graphical analysis", "type of enveloppe drawing not programmed !", GWt_dialog::Error, false,true); |
---|
563 | warningTypeEnveloppe.exec(); |
---|
564 | } |
---|
565 | } |
---|
566 | |
---|
567 | void PspaApplication::faireDessinEnveloppe(WContainerWidget* toto, string type) |
---|
568 | { |
---|
569 | |
---|
570 | GWt_dialog* envDialog = new GWt_dialog("enveloppe",toto,false); |
---|
571 | eDialog_.push_back(envDialog); |
---|
572 | envDialog->setMinimumSize(400,400); |
---|
573 | envDialog->setClosable(true); |
---|
574 | envDialog->show(); |
---|
575 | |
---|
576 | // unsigned nbel = dtmanage_->getBeamLineSize(); |
---|
577 | vector<double> xcor; |
---|
578 | vector<double> ycor; |
---|
579 | string titre; |
---|
580 | string legendx; |
---|
581 | string legendy; |
---|
582 | dtmanage_->donneesRmsEnveloppe(type,xcor,ycor, titre, legendx, legendy); |
---|
583 | chartPlot2vec(envDialog->contents(), xcor, ycor, false,titre, legendx, legendy,500,300); |
---|
584 | |
---|
585 | } |
---|
586 | |
---|
587 | void PspaApplication::faireDessinPhaseSpace(WContainerWidget* toto, particleBeam* beam, string namex, string namey, int typeFaisceau) |
---|
588 | { |
---|
589 | |
---|
590 | vector<double> xcor; |
---|
591 | vector<double> ycor; |
---|
592 | vector<string> legende; |
---|
593 | string titre; |
---|
594 | bool pointsDrawing; |
---|
595 | if ( typeFaisceau == 0 ) { |
---|
596 | pointsDrawing = false; |
---|
597 | titre = "phase space rms"; |
---|
598 | beam->donneesDessinEllipse(xcor,ycor,legende, namex, namey); |
---|
599 | } else if ( typeFaisceau == 1 ) { |
---|
600 | pointsDrawing = true; |
---|
601 | titre = " phase space "; |
---|
602 | beam->particlesPhaseSpaceData(xcor, ycor, legende, namex, namey); |
---|
603 | } else { |
---|
604 | GWt_dialog warningBeamState(" graphical analysis", "the beam state does not allow providing a drawing with macroparticles !", GWt_dialog::Error, false,true); |
---|
605 | warningBeamState.exec(); |
---|
606 | return; |
---|
607 | } |
---|
608 | |
---|
609 | |
---|
610 | GWt_dialog* phaseSpaceDialog = new GWt_dialog("phase space",toto,false); |
---|
611 | eDialog_.push_back(phaseSpaceDialog); |
---|
612 | phaseSpaceDialog->setMinimumSize(400,400); |
---|
613 | phaseSpaceDialog->setClosable(true); |
---|
614 | new WText(nameOfCase_, phaseSpaceDialog->contents()); |
---|
615 | |
---|
616 | |
---|
617 | for (int k=0 ; k < legende.size(); k++) { |
---|
618 | new WBreak(phaseSpaceDialog->contents()); |
---|
619 | new WText(legende.at(k), phaseSpaceDialog->contents()); |
---|
620 | } |
---|
621 | chartPlot2vec(phaseSpaceDialog->contents(), xcor, ycor,pointsDrawing ,titre, namex, namey,500,300); |
---|
622 | phaseSpaceDialog->show(); |
---|
623 | |
---|
624 | } |
---|
625 | |
---|
626 | |
---|
627 | |
---|
628 | void PspaApplication::faireDessinParmela(WContainerWidget* toto, particleBeam* beam, string namex, string namey ) |
---|
629 | { |
---|
630 | cout << " faireDessinParmela " << endl; |
---|
631 | GWt_dialog* pointsDialog = new GWt_dialog("space phase",toto,false); |
---|
632 | eDialog_.push_back(pointsDialog); |
---|
633 | pointsDialog->setMinimumSize(400,400); |
---|
634 | pointsDialog->setClosable(true); |
---|
635 | // pointsDialog->show(); |
---|
636 | |
---|
637 | new WText(nameOfCase_, pointsDialog->contents()); |
---|
638 | |
---|
639 | |
---|
640 | vector<double> xcor; |
---|
641 | vector<double> ycor; |
---|
642 | vector<string> legende; |
---|
643 | beam->particlesPhaseSpaceData(xcor, ycor, legende, namex, namey); |
---|
644 | for (int k=0 ; k < legende.size(); k++) { |
---|
645 | new WBreak(pointsDialog->contents()); |
---|
646 | new WText(legende.at(k), pointsDialog->contents()); |
---|
647 | } |
---|
648 | string titre = " phase space "; |
---|
649 | chartPlot2vec(pointsDialog->contents(), xcor, ycor, true,titre,namex, namey,400,400); |
---|
650 | |
---|
651 | |
---|
652 | |
---|
653 | pointsDialog->show(); |
---|
654 | |
---|
655 | // chart->setMargin(10, Top | Bottom); // add margin vertically |
---|
656 | // chart->setMargin(WLength::Auto, Left | Right); // center horizontally |
---|
657 | } |
---|
658 | |
---|
659 | void PspaApplication::faireDessinTransport(WContainerWidget* toto, particleBeam* beam, string namex, string namey) |
---|
660 | { |
---|
661 | GWt_dialog* ellipseDialog = new GWt_dialog("ellipse",toto,false); |
---|
662 | eDialog_.push_back(ellipseDialog); |
---|
663 | ellipseDialog->setMinimumSize(400,400); |
---|
664 | ellipseDialog->setClosable(true); |
---|
665 | ellipseDialog->show(); |
---|
666 | new WText(nameOfCase_, ellipseDialog->contents()); |
---|
667 | |
---|
668 | vector<double> xcor; |
---|
669 | vector<double> ycor; |
---|
670 | vector<string> legende; |
---|
671 | beam->donneesDessinEllipse(xcor,ycor,legende, namex, namey); |
---|
672 | |
---|
673 | for (int k=0 ; k < legende.size(); k++) { |
---|
674 | new WBreak(ellipseDialog->contents()); |
---|
675 | new WText(legende.at(k), ellipseDialog->contents()); |
---|
676 | } |
---|
677 | string titre = "phase space rms"; |
---|
678 | chartPlot2vec(ellipseDialog->contents(), xcor, ycor, false,titre, namex, namey,500,300); |
---|
679 | } |
---|
680 | |
---|
681 | |
---|
682 | // parametre drawPoints : true = on trace des points (phase space) ; false = on trace des lignes (enveloppes...) |
---|
683 | void PspaApplication::chartPlot2vec(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor, bool drawPoints,string title,string legendx, string legendy,int width, int height, bool makeIcon) |
---|
684 | { |
---|
685 | int nbpts = xcor.size(); |
---|
686 | cout << " PspaApplication::chartPlot2vec nbpts = " << nbpts << endl; |
---|
687 | WStandardItemModel *model = new WStandardItemModel(nbpts, 2, toto); |
---|
688 | for (int i = 0; i < nbpts; ++i) { |
---|
689 | model->setData(i, 0, xcor.at(i)); |
---|
690 | model->setData(i, 1, ycor.at(i)); |
---|
691 | // cout << " PspaApplication::chartPlot2vec el= " << i+1 << " x= " << xcor.at(i) << " y= " << ycor.at(i) << endl; |
---|
692 | } |
---|
693 | |
---|
694 | WCartesianChart *chart = new WCartesianChart(toto); |
---|
695 | if (!makeIcon) { |
---|
696 | chart->setTitle(title); |
---|
697 | } |
---|
698 | chart->initLayout(); |
---|
699 | |
---|
700 | chart->setModel(model); // set the model |
---|
701 | chart->setXSeriesColumn(0); // set the column that holds the X data |
---|
702 | if (!makeIcon) { |
---|
703 | chart->setLegendEnabled(true); // enable the legend |
---|
704 | } else { |
---|
705 | chart->setLegendEnabled(false); // enable the legend |
---|
706 | } |
---|
707 | |
---|
708 | chart->setType(ScatterPlot); // set type to ScatterPlot |
---|
709 | |
---|
710 | // Typically, for mathematical functions, you want the axes to cross |
---|
711 | // at the 0 mark: |
---|
712 | chart->axis(XAxis).setLocation(ZeroValue); |
---|
713 | chart->axis(YAxis).setLocation(ZeroValue); |
---|
714 | |
---|
715 | // Provide space for the X and Y axis and title. |
---|
716 | chart->setPlotAreaPadding(80, Left); // ? |
---|
717 | chart->setPlotAreaPadding(40, Bottom); |
---|
718 | chart->setPlotAreaPadding(60, Top); |
---|
719 | if ( drawPoints ) { |
---|
720 | WDataSeries s(1, PointSeries, Y1Axis); |
---|
721 | chart->addSeries(s); |
---|
722 | } else { |
---|
723 | WDataSeries s(1, LineSeries, Y1Axis); |
---|
724 | chart->addSeries(s); |
---|
725 | } |
---|
726 | chart->resize(width, height); // WPaintedWidget must be given explicit size |
---|
727 | |
---|
728 | |
---|
729 | WAxis& axis = chart->axis(XAxis); |
---|
730 | axis.setLabelFormat("%.3f"); |
---|
731 | // axis.setGridLinesEnabled(true); |
---|
732 | axis.setTitle(legendx); |
---|
733 | |
---|
734 | WAxis& axey = chart->axis(YAxis); |
---|
735 | axey.setTitle(legendy); |
---|
736 | // axis = chart->axis(YAxis); |
---|
737 | // axis.setLabelFormat("%.3f"); |
---|
738 | // axis.setGridLinesEnabled(true); |
---|
739 | // axis.setTitle(legendy); |
---|
740 | |
---|
741 | if (makeIcon) { |
---|
742 | chart->setPlotAreaPadding(0); |
---|
743 | chart->setAxisPadding(0); |
---|
744 | WFont xAxisFont = chart->axis(XAxis).labelFont(); |
---|
745 | xAxisFont.setSize(8); |
---|
746 | WFont yAxisFont = chart->axis(YAxis).labelFont(); |
---|
747 | yAxisFont.setSize(8); |
---|
748 | chart->axis(XAxis).setLabelFont(xAxisFont); |
---|
749 | chart->axis(YAxis).setLabelFont(yAxisFont); |
---|
750 | } |
---|
751 | |
---|
752 | #ifdef HAS_IMAGEMAGIC |
---|
753 | Wt::WRasterImage pngImage("png", 600, 600); |
---|
754 | Wt::WPainter p(&pngImage); |
---|
755 | chart->paint(p); |
---|
756 | std::string name; |
---|
757 | name = workingDir_ + "/chart-"+sessionId ()+".png"; |
---|
758 | std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary); |
---|
759 | pngImage.write(f); |
---|
760 | new WText("<a href='workingArea/chart-"+sessionId ()+".png' target='_blank'>Afficher l'image</a>",toto); |
---|
761 | |
---|
762 | Wt::WPdfImage pdfImage("30cm", "30cm"); |
---|
763 | Wt::WPainter p1(&pdfImage); |
---|
764 | pdfImage.init(); |
---|
765 | chart->paint(p1); |
---|
766 | name = workingDir_ + "/chart-"+sessionId ()+".pdf"; |
---|
767 | std::ofstream f1(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary); |
---|
768 | pdfImage.write(f1); |
---|
769 | #endif |
---|
770 | } |
---|
771 | |
---|
772 | |
---|
773 | WText* PspaApplication::createTitle(const WString& title) |
---|
774 | { |
---|
775 | WText *result = new WText(title); |
---|
776 | result->setInline(false); |
---|
777 | result->setStyleClass("title"); |
---|
778 | result->setMinimumSize(30,30); |
---|
779 | |
---|
780 | return result; |
---|
781 | } |
---|
782 | |
---|
783 | // void PspaApplication::addConsoleMessage(WString msg) { |
---|
784 | // WText *w = new WText(console_); |
---|
785 | // w->setTextFormat(PlainText); |
---|
786 | // w->setText(msg); |
---|
787 | // w->setInline(false); |
---|
788 | |
---|
789 | // /* |
---|
790 | // * Little javascript trick to make sure we scroll along with new content |
---|
791 | // */ |
---|
792 | // WApplication *app = WApplication::instance(); |
---|
793 | // app->doJavaScript(console_->jsRef() + ".scrollTop += " |
---|
794 | // + console_->jsRef() + ".scrollHeight;"); |
---|
795 | |
---|
796 | // } |
---|
797 | |
---|
798 | bool PspaApplication::removePathFromConfigName(string& config) { |
---|
799 | string toExtract = workingDir_ + "/"; |
---|
800 | string::size_type nn = config.find(toExtract); |
---|
801 | if ( nn == string::npos ) { |
---|
802 | GWt_dialog checkremovePath(" checking config file name", " failed to recognize path name for file " + config, GWt_dialog::Error,true,true); |
---|
803 | checkremovePath.exec(); |
---|
804 | return false; |
---|
805 | } |
---|
806 | config.replace(nn, toExtract.size(), ""); |
---|
807 | return true; |
---|
808 | } |
---|
809 | |
---|
810 | bool PspaApplication::removeExtensionFromConfigName(string& config) |
---|
811 | { |
---|
812 | // string configName; |
---|
813 | string extension(".save"); |
---|
814 | bool test = true; |
---|
815 | string::size_type nn = config.rfind('.'); |
---|
816 | if ( nn == string::npos ) |
---|
817 | { |
---|
818 | // pas de point |
---|
819 | test = false; |
---|
820 | } |
---|
821 | string fin = config.substr(nn); |
---|
822 | if ( fin != extension ) |
---|
823 | { |
---|
824 | // l'extension n'est pas la bonne |
---|
825 | test = false; |
---|
826 | } |
---|
827 | if ( test ) |
---|
828 | { |
---|
829 | string::size_type count = config.length() - extension.length(); |
---|
830 | config = config.substr(0, count); |
---|
831 | } |
---|
832 | else |
---|
833 | { |
---|
834 | GWt_dialog checkConfigNameDialog(" checking config file name", " the file must have the extension " + extension, GWt_dialog::Error,true,true); |
---|
835 | checkConfigNameDialog.exec(); |
---|
836 | } |
---|
837 | return test; |
---|
838 | } |
---|
839 | |
---|
840 | void PspaApplication::dessinerHistogramme() |
---|
841 | { |
---|
842 | // pour mon test : histo en energie |
---|
843 | toto_->clear(); |
---|
844 | |
---|
845 | GWt_dialog* histoDialog = new GWt_dialog("histogramme",toto_,false); |
---|
846 | eDialog_.push_back(histoDialog); |
---|
847 | histoDialog->setMinimumSize(400,400); |
---|
848 | histoDialog->setClosable(true); |
---|
849 | |
---|
850 | int index = choixHistoDessin_->currentIndex(); |
---|
851 | particleBeam* beam = dtmanage_->getDiagnosticBeam(index); |
---|
852 | if (beam == NULL) { |
---|
853 | GWt_dialog warningBeamState("histogram","the beam does not exist at the end of this element !", GWt_dialog::Error, false,true); |
---|
854 | warningBeamState.exec(); |
---|
855 | return; |
---|
856 | } |
---|
857 | |
---|
858 | if (!beam->particleRepresentationOk()) { |
---|
859 | GWt_dialog warningBeamState("histogram", "the beam state does not allow providing a drawing with macroparticles !", GWt_dialog::Error, false,true); |
---|
860 | warningBeamState.exec(); |
---|
861 | return; |
---|
862 | } |
---|
863 | |
---|
864 | histoDialog->show(); |
---|
865 | vector<double> xcor; |
---|
866 | vector<int> hist; |
---|
867 | double out[3]= {0.0}; |
---|
868 | |
---|
869 | unsigned iabs= choixVariableHisto_->currentIndex(); |
---|
870 | beam->histogramme(iabs,xcor,hist,out); |
---|
871 | |
---|
872 | cout<<"xcor.size()= "<<xcor.size()<<", hist.size()= "<<hist.size()<<endl; |
---|
873 | ////////////////////////////////////////////////////////////////////////////////// |
---|
874 | |
---|
875 | WContainerWidget *w= histoDialog->contents(); |
---|
876 | int n = hist.size(); |
---|
877 | int nbpts= 2*(n+1); |
---|
878 | WStandardItemModel *model = new WStandardItemModel(nbpts,2,w); |
---|
879 | |
---|
880 | int j= 0; |
---|
881 | model->setData(j,0,xcor[0]); |
---|
882 | model->setData(j,1,0.0); |
---|
883 | j++; |
---|
884 | model->setData(j,0,xcor[0]); |
---|
885 | model->setData(j,1,hist[0]); |
---|
886 | j++; |
---|
887 | |
---|
888 | for (int i = 1; i < n; ++i) { |
---|
889 | model->setData(j,0,xcor[i]); |
---|
890 | model->setData(j,1,hist[i-1]); |
---|
891 | j++; |
---|
892 | model->setData(j,0,xcor[i]); |
---|
893 | model->setData(j,1,hist[i]); |
---|
894 | j++; |
---|
895 | } |
---|
896 | |
---|
897 | model->setData(j,0,xcor[n]); |
---|
898 | model->setData(j,1,hist[n-1]); |
---|
899 | j++; |
---|
900 | model->setData(j,0,xcor[n]); |
---|
901 | model->setData(j,1,0.0); |
---|
902 | |
---|
903 | // legendes |
---|
904 | string unites[2]; |
---|
905 | if(iabs == 0 || iabs == 1 || iabs == 2) { |
---|
906 | unites[0]= unites[1]= " mm"; |
---|
907 | } |
---|
908 | if(iabs == 3 || iabs == 4) { |
---|
909 | unites[0]= unites[1]= " mrad"; |
---|
910 | } |
---|
911 | if(iabs == 5) { |
---|
912 | unites[0]= " MeV"; unites[1]= " KeV"; |
---|
913 | } |
---|
914 | |
---|
915 | new WText(" entries : "+ mixedTools::intToString((int)out[0]),w); |
---|
916 | new WBreak(w); |
---|
917 | new WText(" mean : "+ mixedTools::doubleToString(out[1])+unites[0],w); |
---|
918 | new WBreak(w); |
---|
919 | new WText(" sigma rms : "+ mixedTools::doubleToString(out[2])+unites[1],w); |
---|
920 | |
---|
921 | WCartesianChart *chart = new WCartesianChart(w); |
---|
922 | |
---|
923 | if(iabs == 0) chart->setTitle("x-coordinate"); |
---|
924 | if(iabs == 1) chart->setTitle("y-coordinate"); |
---|
925 | if(iabs == 2) chart->setTitle("z-coordinate"); |
---|
926 | if(iabs == 3) chart->setTitle("xp-divergence"); |
---|
927 | if(iabs == 4) chart->setTitle("yp-devergence"); |
---|
928 | if(iabs == 5) chart->setTitle("kinetic energy"); |
---|
929 | |
---|
930 | chart->setModel(model); // set the model |
---|
931 | chart->setXSeriesColumn(0); // set the column that holds the categories |
---|
932 | chart->setLegendEnabled(false); // enable the legend |
---|
933 | |
---|
934 | // Provide space for the X and Y axis and title. |
---|
935 | chart->setPlotAreaPadding(200, Right); |
---|
936 | chart->setPlotAreaPadding(80, Left); |
---|
937 | chart->setPlotAreaPadding(40, Top | Bottom); |
---|
938 | |
---|
939 | chart->setType(ScatterPlot); |
---|
940 | |
---|
941 | WAxis& axis = chart->axis(XAxis); |
---|
942 | axis.setLabelFormat("%.3f"); |
---|
943 | axis.setGridLinesEnabled(true); |
---|
944 | |
---|
945 | if(iabs == 0) axis.setTitle(WString(" x (mm)")); |
---|
946 | if(iabs == 1) axis.setTitle(WString(" y (mm)")); |
---|
947 | if(iabs == 2) axis.setTitle(WString(" z (mm)")); |
---|
948 | if(iabs == 3) axis.setTitle(WString(" xp (mrad)")); |
---|
949 | if(iabs == 4) axis.setTitle(WString(" yp (mrad)")); |
---|
950 | if(iabs == 5) axis.setTitle(WString(" dEcin/Ecin (%)")); |
---|
951 | |
---|
952 | chart->axis(Y1Axis).setGridLinesEnabled(true); |
---|
953 | //chart->axis(Y1Axis).setTitle(WString("legende y")); |
---|
954 | |
---|
955 | WDataSeries s(1, LineSeries); |
---|
956 | s.setFillRange(ZeroValueFill); |
---|
957 | chart->addSeries(s); |
---|
958 | |
---|
959 | chart->resize(800, 400); |
---|
960 | chart->setMargin(10, Top | Bottom); |
---|
961 | chart->setMargin(WLength::Auto, Left | Right); |
---|
962 | |
---|
963 | LegendLocation location = LegendOutside; |
---|
964 | Side side = Right; |
---|
965 | AlignmentFlag alignment = AlignMiddle; |
---|
966 | chart->setLegendLocation(location, side, alignment); |
---|
967 | chart->setLegendStyle(chart->legendFont(), WPen(black), WBrush(WColor(0xFF, 0xFA, 0xE5))); |
---|
968 | } |
---|
969 | |
---|
970 | void PspaApplication::removeBeamLine() { |
---|
971 | createBeamLine(); |
---|
972 | } |
---|