Changeset 272 in PSPA for Interface_Web/trunk/pspaWT/sources
- Timestamp:
- Jan 24, 2013, 3:32:13 PM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT/sources/userInterface
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_abstractElement.h
r267 r272 18 18 class GWt_abstractElement : public WContainerWidget 19 19 { 20 protected :21 22 abstractElement* abstractElement_;23 24 WDialog* dialog_;25 GWt_draggableImage* dropped_;26 WContainerWidget* wc_;27 WText* wc_item_;28 WLineEdit* labelEdit_;29 30 GWt_abstractElement() {;}31 32 string* beginDialog();33 public :34 35 GWt_abstractElement(abstractElement* ,GWt_elementLigneFaisceau*);36 37 // methode Factory38 static GWt_abstractElement *ajoute(abstractElement* ptr);39 40 void clicked();41 void setLabelWidget();42 void updateLabelWidget();43 // GWt_draggableImage* getImage();44 WContainerWidget* getWidget();45 abstractElement* getElement();46 47 virtual void dialogDone() = 0;48 virtual WImage* getImage() = 0;20 protected : 21 22 abstractElement* abstractElement_; 23 24 WDialog* dialog_; 25 GWt_draggableImage* dropped_; 26 WContainerWidget* wc_; 27 WText* wc_item_; 28 WLineEdit* labelEdit_; 29 30 GWt_abstractElement() {;} 31 32 string* beginDialog(); 33 public : 34 35 GWt_abstractElement(abstractElement* ,GWt_elementLigneFaisceau*); 36 37 // methode Factory 38 static GWt_abstractElement *ajoute(abstractElement* ptr); 39 40 void clicked(); 41 void setLabelWidget(); 42 void updateLabelWidget(); 43 // GWt_draggableImage* getImage(); 44 WContainerWidget* getWidget(); 45 abstractElement* getElement(); 46 47 virtual void dialogDone() = 0; 48 virtual WImage* getImage() = 0; 49 49 50 50 private: -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_beam.h
r266 r272 6 6 7 7 class GWt_beam : public GWt_abstractElement { 8 9 WLineEdit* xEdit_; // cm10 WLineEdit* xpEdit_; // mrad11 WLineEdit* yEdit_; // cm12 WLineEdit* ypEdit_; // mrad13 WLineEdit* dlEdit_; // cm14 WLineEdit* delEdit_; // %15 WLineEdit* p0Edit_; // GeV/c16 17 GWt_beam() {;}18 19 public :20 21 GWt_beam(abstractElement* elem ,GWt_elementLigneFaisceau*);22 ~GWt_beam() {;}23 virtual void dialogDone();24 25 WImage* getImage();26 27 28 WImage* image_;8 9 WLineEdit* xEdit_; // cm 10 WLineEdit* xpEdit_; // mrad 11 WLineEdit* yEdit_; // cm 12 WLineEdit* ypEdit_; // mrad 13 WLineEdit* dlEdit_; // cm 14 WLineEdit* delEdit_; // % 15 WLineEdit* p0Edit_; // GeV/c 16 17 GWt_beam() {;} 18 19 public : 20 21 GWt_beam(abstractElement* elem ,GWt_elementLigneFaisceau*); 22 ~GWt_beam() {;} 23 virtual void dialogDone(); 24 25 WImage* getImage(); 26 27 private: 28 WImage* image_; 29 29 }; 30 30 -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_bend.h
r267 r272 6 6 class GWt_bend : public GWt_abstractElement 7 7 { 8 WLineEdit* angleEdit_; // deg.9 WLineEdit* radiusEdit_; // m10 WLineEdit* xlengthEdit_; // cm11 WLineEdit* apertureEdit_; // cm12 WLineEdit* beta1Edit_; // deg.13 WLineEdit* beta2Edit_; // deg.14 WLineEdit* momentumEdit_; // MeV/c15 16 GWt_bend() {;}17 18 public :19 20 GWt_bend(abstractElement* elem ,GWt_elementLigneFaisceau*);21 ~GWt_bend() {;}22 virtual void dialogDone();23 24 WImage* getImage();25 26 27 WImage* image_;8 WLineEdit* angleEdit_; // deg. 9 WLineEdit* radiusEdit_; // m 10 WLineEdit* xlengthEdit_; // cm 11 WLineEdit* apertureEdit_; // cm 12 WLineEdit* beta1Edit_; // deg. 13 WLineEdit* beta2Edit_; // deg. 14 WLineEdit* momentumEdit_; // MeV/c 15 16 GWt_bend() {;} 17 18 public : 19 20 GWt_bend(abstractElement* elem ,GWt_elementLigneFaisceau*); 21 ~GWt_bend() {;} 22 virtual void dialogDone(); 23 24 WImage* getImage(); 25 26 private: 27 WImage* image_; 28 28 }; 29 29 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_cell.h
r266 r272 15 15 class GWt_cell : public GWt_abstractElement 16 16 { 17 WLineEdit* lenghtElemEdit_; // cm18 WLineEdit* apertureEdit_; // cm19 WLineEdit* initialPhaseEdit_; // degres20 WLineEdit* phaseStepMaxEdit_; // degres21 WLineEdit* acceleratingFieldEdit_; // MV/m22 WLineEdit* acceleratingShapeFileEdit_; // string23 WLineEdit* focusingMagFileEdit_; // string24 WLineEdit* offsetMagEdit_; // cm25 WLineEdit* scaleFactorEdit_;26 27 GWt_cell() {;}28 29 public :30 31 GWt_cell(abstractElement* elem ,GWt_elementLigneFaisceau*);32 ~GWt_cell() {;}33 virtual void dialogDone();34 35 WImage* getImage();36 37 38 WImage* image_;17 WLineEdit* lenghtElemEdit_; // cm 18 WLineEdit* apertureEdit_; // cm 19 WLineEdit* initialPhaseEdit_; // degres 20 WLineEdit* phaseStepMaxEdit_; // degres 21 WLineEdit* acceleratingFieldEdit_; // MV/m 22 WLineEdit* acceleratingShapeFileEdit_; // string 23 WLineEdit* focusingMagFileEdit_; // string 24 WLineEdit* offsetMagEdit_; // cm 25 WLineEdit* scaleFactorEdit_; 26 27 GWt_cell() {;} 28 29 public : 30 31 GWt_cell(abstractElement* elem ,GWt_elementLigneFaisceau*); 32 ~GWt_cell() {;} 33 virtual void dialogDone(); 34 35 WImage* getImage(); 36 37 private: 38 WImage* image_; 39 39 }; 40 40 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_console.h
r260 r272 13 13 class GWt_console : public WContainerWidget 14 14 { 15 16 public: 17 GWt_console();18 virtual ~GWt_console();19 void addConsoleMessage(WString msg);15 16 public: 17 GWt_console(); 18 virtual ~GWt_console(); 19 void addConsoleMessage(WString msg); 20 20 }; 21 21 -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_dialog.h
r260 r272 9 9 10 10 /** 11 12 13 14 15 16 */11 Créer une fenêtre de dialogue et permet de la paramètres facilement 12 @param titre : titre de la fenêtre 13 @param icon : icone à afficher dans le corps de la boite (Warning, Error, Info, Wait, NoIcon) 14 @param modal : true si cette fenêtre doit être bloquante 15 @param okButton : true pour fermer cette fenêtre avec un bouton "ok". false n'affiche aucun bouton 16 */ 17 17 18 18 class GWt_dialog : public WDialog 19 19 { 20 21 public :22 23 enum iconType { Warning, Error, Info, Wait, NoIcon };24 25 /** Add a dialog with the given container inside26 27 28 29 */30 GWt_dialog(WString titre, WContainerWidget* container, bool modal=false);31 32 /** Add a full dialog window configure with title, message, iconType and button33 34 35 36 37 38 */39 GWt_dialog(WString titre, std::string message, iconType icon=NoIcon, bool modal=false, bool okButton=false);20 21 public : 22 23 enum iconType { Warning, Error, Info, Wait, NoIcon }; 24 25 /** Add a dialog with the given container inside 26 @param titre: A title displayed on the window title bar 27 @param message: The message inside this dialog 28 @param container: a valid WContainer 29 */ 30 GWt_dialog(WString titre, WContainerWidget* container, bool modal=false); 31 32 /** Add a full dialog window configure with title, message, iconType and button 33 @param titre: A title displayed on the window title bar 34 @param message: The message inside this dialog 35 @param icon: IconType, could be Warning, Error, Info, Wait or NoIcon 36 @param modal: true for a blocking dialog, false for a non-blocking dialog 37 @param okButton: true if you want a "ok" button at the end 38 */ 39 GWt_dialog(WString titre, std::string message, iconType icon=NoIcon, bool modal=false, bool okButton=false); 40 40 }; 41 41 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_draggableImage.h
r260 r272 9 9 class GWt_draggableImage : public WImage 10 10 { 11 public :12 13 GWt_draggableImage(const WLink &,const WString &,WContainerWidget *parent=0);14 GWt_draggableImage(const WLink &,WContainerWidget *parent=0);15 ~GWt_draggableImage();16 17 18 void mouseOver(const WMouseEvent &e );19 void mouseOut(const WMouseEvent &e );20 void mouseUp(const WMouseEvent &e );21 void mouseDown(const WMouseEvent &e );22 void mouseIsDragged(const WMouseEvent &e );23 void setChangeCursorOnMouseOver(bool);24 25 bool changeCursorOnMouseOver_;26 27 28 void init();11 public : 12 13 GWt_draggableImage(const WLink &,const WString &,WContainerWidget *parent=0); 14 GWt_draggableImage(const WLink &,WContainerWidget *parent=0); 15 ~GWt_draggableImage(); 16 17 protected: 18 void mouseOver(const WMouseEvent &e ); 19 void mouseOut(const WMouseEvent &e ); 20 void mouseUp(const WMouseEvent &e ); 21 void mouseDown(const WMouseEvent &e ); 22 void mouseIsDragged(const WMouseEvent &e ); 23 void setChangeCursorOnMouseOver(bool); 24 25 bool changeCursorOnMouseOver_; 26 27 private: 28 void init(); 29 29 }; 30 30 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_drift.h
r267 r272 14 14 class GWt_drift : public GWt_abstractElement 15 15 { 16 WLineEdit* xlengthEdit_;17 WLineEdit* apertureEdit_;18 19 GWt_drift() {;}20 21 22 23 GWt_drift(abstractElement* elem ,GWt_elementLigneFaisceau*);24 ~GWt_drift() {;}25 virtual void dialogDone();26 WImage* getImage();27 28 29 WImage* image_;16 WLineEdit* xlengthEdit_; 17 WLineEdit* apertureEdit_; 18 19 GWt_drift() {;} 20 21 public: 22 23 GWt_drift(abstractElement* elem ,GWt_elementLigneFaisceau*); 24 ~GWt_drift() {;} 25 virtual void dialogDone(); 26 WImage* getImage(); 27 28 private: 29 WImage* image_; 30 30 }; 31 31 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_dropZoneLigneFaisceau.h
r260 r272 11 11 class GWt_dropZoneLigneFaisceau : public WContainerWidget 12 12 { 13 public :14 15 GWt_dropZoneLigneFaisceau();16 ~GWt_dropZoneLigneFaisceau();17 18 19 void mouseOver(const WMouseEvent &e );20 void mouseOut(const WMouseEvent &e );21 void mouseUp(const WMouseEvent &e );22 void mouseDown(const WMouseEvent &e );23 void mouseIsDragged(const WMouseEvent &e );24 void dropEvent(WDropEvent evt);13 public : 14 15 GWt_dropZoneLigneFaisceau(); 16 ~GWt_dropZoneLigneFaisceau(); 17 18 private: 19 void mouseOver(const WMouseEvent &e ); 20 void mouseOut(const WMouseEvent &e ); 21 void mouseUp(const WMouseEvent &e ); 22 void mouseDown(const WMouseEvent &e ); 23 void mouseIsDragged(const WMouseEvent &e ); 24 void dropEvent(WDropEvent evt); 25 25 }; 26 26 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_elementLigneFaisceau.h
r267 r272 14 14 class GWt_elementLigneFaisceau : public WContainerWidget 15 15 { 16 public :17 /**16 public : 17 /** 18 18 dropZone element 19 19 a drop zone is the basic element for a widget in the ligne faisceau drop zone area 20 20 it should be like this : 21 21 22 22 +----------+--------+---------+ 23 23 | (--->) | ELEM | (-----) | … … 28 28 (----) and (---->) : Droppable zone, contain arrows or line if this element is connected to another 29 29 NAME : editable element name 30 31 At first time, the ELEM element is replace by a message.32 */33 34 GWt_elementLigneFaisceau();35 GWt_elementLigneFaisceau(abstractElement*);36 37 ~GWt_elementLigneFaisceau();38 void addElement(GWt_abstractElement* elem);39 40 inline WText* getElementName() {41 return elementName_;42 }43 44 inline WText* getElementIcon() {45 return elementName_;46 }47 30 31 At first time, the ELEM element is replace by a message. 32 */ 33 34 GWt_elementLigneFaisceau(); 35 GWt_elementLigneFaisceau(abstractElement*); 36 37 ~GWt_elementLigneFaisceau(); 38 void addElement(GWt_abstractElement* elem); 39 40 inline WText* getElementName() { 41 return elementName_; 42 } 43 44 inline WText* getElementIcon() { 45 return elementName_; 46 } 47 48 48 void setElementName(std::string label); 49 49 50 50 private: 51 52 void onClick(GWt_abstractElement*);53 void removeDone(GWt_abstractElement*);54 std::string getElementNumberInBeamLine(nomdElements el);55 void removeOtherDropZone(GWt_elementLigneFaisceau*);56 void initialize_ligneFaisceau(abstractElement*);57 GWt_dialog* messageDropZone_;58 WText* firstTimeInsertMessage_;59 60 GWt_dropZoneLigneFaisceau* arrowImage_;61 WContainerWidget* dragElementZone_;62 GWt_dropZoneLigneFaisceau* lineImage_;63 WText* elementName_;64 65 GWt_abstractElement* abstractElement_;51 52 void onClick(GWt_abstractElement*); 53 void removeDone(GWt_abstractElement*); 54 std::string getElementNumberInBeamLine(nomdElements el); 55 void removeOtherDropZone(GWt_elementLigneFaisceau*); 56 void initialize_ligneFaisceau(abstractElement*); 57 GWt_dialog* messageDropZone_; 58 WText* firstTimeInsertMessage_; 59 60 GWt_dropZoneLigneFaisceau* arrowImage_; 61 WContainerWidget* dragElementZone_; 62 GWt_dropZoneLigneFaisceau* lineImage_; 63 WText* elementName_; 64 65 GWt_abstractElement* abstractElement_; 66 66 }; 67 67 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_fit.h
r267 r272 6 6 class GWt_fit : public GWt_abstractElement 7 7 { 8 9 WComboBox* nameEdit_; // deg.10 WLineEdit* valueEdit_; // m11 WLineEdit* tolerEdit_; // cm12 13 GWt_fit() {;}14 15 public :16 17 GWt_fit(abstractElement* elem ,GWt_elementLigneFaisceau*);18 ~GWt_fit() {;}19 virtual void dialogDone();20 21 WImage* getImage();22 23 24 WImage* image_;8 9 WComboBox* nameEdit_; // deg. 10 WLineEdit* valueEdit_; // m 11 WLineEdit* tolerEdit_; // cm 12 13 GWt_fit() {;} 14 15 public : 16 17 GWt_fit(abstractElement* elem ,GWt_elementLigneFaisceau*); 18 ~GWt_fit() {;} 19 virtual void dialogDone(); 20 21 WImage* getImage(); 22 23 private: 24 WImage* image_; 25 25 }; 26 26 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_globalParameters.h
r260 r272 14 14 class GWt_globalParameters : public WContainerWidget 15 15 { 16 17 PspaApplication* pspa_;18 // dataManager* dtmanage_;19 WLineEdit* frequencyEdit_;20 WLineEdit* stepEdit_;21 WLineEdit* nstepMAxEdit_;22 WLineEdit* nscEdit_;23 24 // vector<WComboBox*> sectionSelection_;25 26 27 /* WLineEdit* origineEdit1_; */28 /* WLineEdit* origineEdit2_; */29 /* WComboBox* selectionBox1_; */30 31 /* WLineEdit* extremiteEdit1_; */32 /* WLineEdit* extremiteEdit2_; */33 /* WComboBox* selectionBox2_; */34 35 // WContainerWidget* contenuSections_;36 16 17 PspaApplication* pspa_; 18 // dataManager* dtmanage_; 19 WLineEdit* frequencyEdit_; 20 WLineEdit* stepEdit_; 21 WLineEdit* nstepMAxEdit_; 22 WLineEdit* nscEdit_; 23 24 // vector<WComboBox*> sectionSelection_; 25 26 27 /* WLineEdit* origineEdit1_; */ 28 /* WLineEdit* origineEdit2_; */ 29 /* WComboBox* selectionBox1_; */ 30 31 /* WLineEdit* extremiteEdit1_; */ 32 /* WLineEdit* extremiteEdit2_; */ 33 /* WComboBox* selectionBox2_; */ 34 35 // WContainerWidget* contenuSections_; 36 37 37 GWt_globalParameters() {;} 38 39 40 41 // GWt_globalParameters(dataManager* dt);38 39 public: 40 41 // GWt_globalParameters(dataManager* dt); 42 42 GWt_globalParameters(PspaApplication* ps); 43 43 44 44 void updateGlobals(); 45 46 45 46 47 47 void renew(); 48 48 49 49 // void addElem(); 50 50 51 51 // void addSection(); 52 52 53 53 // void getExecute(unsigned index, unsigned& first, unsigned& last, int& programm); 54 54 55 55 // void lancerCalcul(); 56 56 57 57 }; 58 58 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_ligneFaisceau.h
r260 r272 16 16 17 17 class Compteur { 18 int n_;19 20 public :21 Compteur() {n_= 0;}22 int incr() {return ++n_;}18 int n_; 19 20 public : 21 Compteur() {n_= 0;} 22 int incr() {return ++n_;} 23 23 }; 24 24 25 25 class GWt_LigneFaisceau : public WContainerWidget 26 26 { 27 WHBoxLayout* ligneFaisceauLayout_;28 PspaApplication* pspa_;29 Compteur *nObjets_;30 31 public :32 33 GWt_LigneFaisceau() {;}34 GWt_LigneFaisceau(PspaApplication*);35 void addElement(typedElement eType);36 37 ~GWt_LigneFaisceau() {38 if(nObjets_ != NULL) delete[] nObjets_;39 }40 41 void restoreElementCollection();42 void clickEvent(WContainerWidget*);43 void deleteElement(WContainerWidget*);44 45 27 WHBoxLayout* ligneFaisceauLayout_; 28 PspaApplication* pspa_; 29 Compteur *nObjets_; 30 31 public : 32 33 GWt_LigneFaisceau() {;} 34 GWt_LigneFaisceau(PspaApplication*); 35 void addElement(typedElement eType); 36 37 ~GWt_LigneFaisceau() { 38 if(nObjets_ != NULL) delete[] nObjets_; 39 } 40 41 void restoreElementCollection(); 42 void clickEvent(WContainerWidget*); 43 void deleteElement(WContainerWidget*); 44 45 46 46 }; 47 47 -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h
r260 r272 28 28 class PspaApplication : public WApplication 29 29 { 30 31 typedef struct {32 WLineEdit* debut;33 WLineEdit* fin;34 WComboBox* selection;35 WContainerWidget* ligneDeWidget;36 } GWt_sectionToExecute;37 38 private :39 40 dataManager* dtmanage_;41 string nameOfCase_;42 string workingDir_;43 WDialog* dialogSave_;44 WDialog* dialogOpen_;45 WLineEdit* saveNameEdit_;46 WLineEdit* openNameEdit_;47 48 49 // WContainerWidget* console_;50 WWidget* globalParam_;51 WWidget* beamLine_;52 // WContainerWidget* leDessin_;53 GWt_dialog* graphicsDialog_;54 55 WPushButton *exec_go_;56 WText* probleme_;57 WComboBox* choixElementDessin_;58 WComboBox* choixTypeDessinFaisceau_;59 WComboBox* choixEnveloppeDessin_;60 WContainerWidget* toto_;61 WContainerWidget* contenuSections_;62 list<GWt_sectionToExecute*> selectedSections_;63 WFileUpload* uploadFileSelectorWidget_;64 GWt_console* console_;65 66 67 WText* createTitle(const WString&);68 WWidget* createPalette();69 WWidget* createBeamLine();70 WWidget* createGlobalParamWidget();71 WWidget* createExecuteWidget();72 WContainerWidget* createDrawingWidget();73 74 void createDragImage(const char *url,const char *smallurl,const char *mimeType,WContainerWidget *p,WString name);75 void executer();76 void sauver();77 void dialogSaveDone(WDialog::DialogCode code);78 void dialogOpenDone(WDialog::DialogCode code);79 void restaurer();80 void chargerConfig();81 void openFileSelector();82 void fileTooLarge();83 void dessiner();84 85 void addSectionToExecuteW();86 void deleteSectionToExecuteW();87 void checkSectionSelection();88 void disableSectionExecute();89 bool areDataCoherent();90 void dialogOnGraphics();91 void faireDessin();92 void faireDessinParmela(WContainerWidget* toto, particleBeam* beam);93 void faireDessinTransport(WContainerWidget* toto, particleBeam* beam);94 95 void dessinerEnveloppe();96 void faireDessinEnveloppe(WContainerWidget* toto, string type);97 void scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor);98 99 bool removeExtensionFromConfigName(string& config);100 101 void dessinerHistogramme();102 103 public :104 105 PspaApplication(const WEnvironment& env);106 107 inline dataManager* getDataManager() const {108 return dtmanage_;109 }110 111 // void addConsoleMessage(WString msg);112 113 void updateSelections();114 string getSelection();30 31 typedef struct { 32 WLineEdit* debut; 33 WLineEdit* fin; 34 WComboBox* selection; 35 WContainerWidget* ligneDeWidget; 36 } GWt_sectionToExecute; 37 38 private : 39 40 dataManager* dtmanage_; 41 string nameOfCase_; 42 string workingDir_; 43 WDialog* dialogSave_; 44 WDialog* dialogOpen_; 45 WLineEdit* saveNameEdit_; 46 WLineEdit* openNameEdit_; 47 48 49 // WContainerWidget* console_; 50 WWidget* globalParam_; 51 WWidget* beamLine_; 52 // WContainerWidget* leDessin_; 53 GWt_dialog* graphicsDialog_; 54 55 WPushButton *exec_go_; 56 WText* probleme_; 57 WComboBox* choixElementDessin_; 58 WComboBox* choixTypeDessinFaisceau_; 59 WComboBox* choixEnveloppeDessin_; 60 WContainerWidget* toto_; 61 WContainerWidget* contenuSections_; 62 list<GWt_sectionToExecute*> selectedSections_; 63 WFileUpload* uploadFileSelectorWidget_; 64 GWt_console* console_; 65 66 67 WText* createTitle(const WString&); 68 WWidget* createPalette(); 69 WWidget* createBeamLine(); 70 WWidget* createGlobalParamWidget(); 71 WWidget* createExecuteWidget(); 72 WContainerWidget* createDrawingWidget(); 73 74 void createDragImage(const char *url,const char *smallurl,const char *mimeType,WContainerWidget *p,WString name); 75 void executer(); 76 void sauver(); 77 void dialogSaveDone(WDialog::DialogCode code); 78 void dialogOpenDone(WDialog::DialogCode code); 79 void restaurer(); 80 void chargerConfig(); 81 void openFileSelector(); 82 void fileTooLarge(); 83 void dessiner(); 84 85 void addSectionToExecuteW(); 86 void deleteSectionToExecuteW(); 87 void checkSectionSelection(); 88 void disableSectionExecute(); 89 bool areDataCoherent(); 90 void dialogOnGraphics(); 91 void faireDessin(); 92 void faireDessinParmela(WContainerWidget* toto, particleBeam* beam); 93 void faireDessinTransport(WContainerWidget* toto, particleBeam* beam); 94 95 void dessinerEnveloppe(); 96 void faireDessinEnveloppe(WContainerWidget* toto, string type); 97 void scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor); 98 99 bool removeExtensionFromConfigName(string& config); 100 101 void dessinerHistogramme(); 102 103 public : 104 105 PspaApplication(const WEnvironment& env); 106 107 inline dataManager* getDataManager() const { 108 return dtmanage_; 109 } 110 111 // void addConsoleMessage(WString msg); 112 113 void updateSelections(); 114 string getSelection(); 115 115 }; 116 116 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_rfgun.h
r267 r272 15 15 class GWt_rfgun : public GWt_abstractElement 16 16 { 17 WLineEdit* nmacropEdit_;18 WLineEdit* sigma_tEdit_; // picoseconds19 WLineEdit* sigma_rEdit_; // cm20 WLineEdit* E_cinEdit_; // MeV21 WLineEdit* sigma_EEdit_; // MeV22 WLineEdit* nb_true_particlesEdit_;23 24 GWt_rfgun() {;}25 26 public :27 28 GWt_rfgun(abstractElement* elem ,GWt_elementLigneFaisceau*);29 ~GWt_rfgun() {;}30 virtual void dialogDone();31 32 WImage* getImage();33 34 35 WImage* image_;36 17 WLineEdit* nmacropEdit_; 18 WLineEdit* sigma_tEdit_; // picoseconds 19 WLineEdit* sigma_rEdit_; // cm 20 WLineEdit* E_cinEdit_; // MeV 21 WLineEdit* sigma_EEdit_; // MeV 22 WLineEdit* nb_true_particlesEdit_; 23 24 GWt_rfgun() {;} 25 26 public : 27 28 GWt_rfgun(abstractElement* elem ,GWt_elementLigneFaisceau*); 29 ~GWt_rfgun() {;} 30 virtual void dialogDone(); 31 32 WImage* getImage(); 33 34 private: 35 WImage* image_; 36 37 37 }; 38 38 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_soleno.h
r267 r272 16 16 class GWt_soleno : public GWt_abstractElement 17 17 { 18 WLineEdit* xlengthEdit_;19 WLineEdit* apertureEdit_;20 WLineEdit* B0Edit_;21 WCheckBox* varyB0Edit_;22 23 GWt_soleno() {;}24 25 void updateB();26 27 public :28 29 GWt_soleno( abstractElement* elem ,GWt_elementLigneFaisceau*);30 ~GWt_soleno() {;}31 virtual void dialogDone();32 33 WImage* getImage();34 35 36 WImage* image_;18 WLineEdit* xlengthEdit_; 19 WLineEdit* apertureEdit_; 20 WLineEdit* B0Edit_; 21 WCheckBox* varyB0Edit_; 22 23 GWt_soleno() {;} 24 25 void updateB(); 26 27 public : 28 29 GWt_soleno( abstractElement* elem ,GWt_elementLigneFaisceau*); 30 ~GWt_soleno() {;} 31 virtual void dialogDone(); 32 33 WImage* getImage(); 34 35 private: 36 WImage* image_; 37 37 }; 38 38 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElement.cc
r267 r272 22 22 23 23 GWt_abstractElement::GWt_abstractElement(abstractElement* elem,GWt_elementLigneFaisceau* elemLigne) 24 24 : WContainerWidget() 25 25 { 26 abstractElement_ = elem;26 abstractElement_ = elem; 27 27 elementLigneFaiseauContainer_ = elemLigne; 28 28 } … … 31 31 string* GWt_abstractElement::beginDialog() 32 32 { 33 string* param = abstractElement_-> getParametersString();34 35 if ( param == NULL )33 string* param = abstractElement_-> getParametersString(); 34 35 if ( param == NULL ) 36 36 { 37 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {38 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));39 console->addConsoleMessage(" GWt_abstractElement::beginDialog : empty parameter set for element " + abstractElement_->getNomdElement().getElementName());40 }37 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 38 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 39 console->addConsoleMessage(" GWt_abstractElement::beginDialog : empty parameter set for element " + abstractElement_->getNomdElement().getElementName()); 40 } 41 41 } 42 // int compteur = -1;43 44 // int nbparam = atoi(param[++compteur].c_str());45 int nbparam = atoi(param->c_str());46 if ( nbparam != abstractElement_->getNbParams())42 // int compteur = -1; 43 44 // int nbparam = atoi(param[++compteur].c_str()); 45 int nbparam = atoi(param->c_str()); 46 if ( nbparam != abstractElement_->getNbParams()) 47 47 { 48 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {49 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));50 console->addConsoleMessage(" element seems not to be a " + abstractElement_->getNomdElement().getElementName());51 }48 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 49 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 50 console->addConsoleMessage(" element seems not to be a " + abstractElement_->getNomdElement().getElementName()); 51 } 52 52 } 53 54 dialog_ = new WDialog("element " + abstractElement_->getNomdElement().getElementName());55 new WText(" label of the element : ",dialog_->contents());56 // labelEdit_ = new WLineEdit(param[++compteur].c_str(), dialog_->contents());57 58 labelEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());59 new WBreak(dialog_->contents());60 return ++param;53 54 dialog_ = new WDialog("element " + abstractElement_->getNomdElement().getElementName()); 55 new WText(" label of the element : ",dialog_->contents()); 56 // labelEdit_ = new WLineEdit(param[++compteur].c_str(), dialog_->contents()); 57 58 labelEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 59 new WBreak(dialog_->contents()); 60 return ++param; 61 61 } 62 62 … … 66 66 67 67 /* string str = abstractElement_->getLabel(); 68 wc_item_->setText(str);69 */68 wc_item_->setText(str); 69 */ 70 70 } 71 71 72 72 void GWt_abstractElement::setLabelWidget() 73 73 { 74 /*75 string str = abstractElement_->getLabel();76 wc_item_ = new WText(str);77 wc_item_->setObjectName("aText");78 wc_->addWidget(wc_item_);79 */74 /* 75 string str = abstractElement_->getLabel(); 76 wc_item_ = new WText(str); 77 wc_item_->setObjectName("aText"); 78 wc_->addWidget(wc_item_); 79 */ 80 80 } 81 81 82 82 void GWt_abstractElement::clicked() 83 83 { 84 cout << "mouse key was clicked on this widget" << endl;85 dialog_->show();84 cout << "mouse key was clicked on this widget" << endl; 85 dialog_->show(); 86 86 } 87 87 88 88 89 89 WContainerWidget* GWt_abstractElement::getWidget() { 90 return wc_;90 return wc_; 91 91 } 92 92 93 93 abstractElement* GWt_abstractElement::getElement() { 94 return abstractElement_;94 return abstractElement_; 95 95 } 96 96 97 97 GWt_abstractElement* GWt_abstractElement::ajoute(abstractElement* ptr) 98 98 { 99 /*100 typedElement eType = ptr->getNomdElement().getElementType();101 102 switch ( eType ) {103 case RFgun : return new GWt_rfgun(ptr);104 case drift : return new GWt_drift(ptr);105 case cell : return new GWt_cell(ptr);106 case bend : return new GWt_bend(ptr);107 case soleno : return new GWt_soleno(ptr);108 case beam : return new GWt_beam(ptr);109 case fit : return new GWt_fit(ptr);110 case inconnu : return NULL;111 default : return NULL;112 }113 */99 /* 100 typedElement eType = ptr->getNomdElement().getElementType(); 101 102 switch ( eType ) { 103 case RFgun : return new GWt_rfgun(ptr); 104 case drift : return new GWt_drift(ptr); 105 case cell : return new GWt_cell(ptr); 106 case bend : return new GWt_bend(ptr); 107 case soleno : return new GWt_soleno(ptr); 108 case beam : return new GWt_beam(ptr); 109 case fit : return new GWt_fit(ptr); 110 case inconnu : return NULL; 111 default : return NULL; 112 } 113 */ 114 114 return NULL; 115 115 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_beam.cc
r266 r272 9 9 10 10 GWt_beam::GWt_beam(abstractElement* elem ,GWt_elementLigneFaisceau* elemLigne) : GWt_abstractElement(elem, elemLigne) { 11 12 13 string* param = beginDialog();14 15 new WText(" 1/2 horizontal beam extend rms (cm) : ",dialog_->contents());16 xEdit_ = new WLineEdit(param->c_str(), dialog_->contents());17 // new WBreak(dialog_->contents());18 19 new WText("1/2 horizontal beam divergence rms (mrad) : ",dialog_->contents());20 xpEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());21 new WBreak(dialog_->contents());22 23 new WText("1/2 vertical beam extend rms (cm) : ",dialog_->contents());24 yEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());25 // new WBreak(dialog_->contents());26 27 new WText("1/2 horizontal beam divergence rms (mrad) : ",dialog_->contents());28 ypEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());29 new WBreak(dialog_->contents());30 31 new WText("1/2 longitudinal beam extend rms (cm) : ",dialog_->contents());32 dlEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());33 // new WBreak(dialog_->contents());34 35 new WText("1/2 momentum spread rms (mrad) : ",dialog_->contents());36 delEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());37 new WBreak(dialog_->contents());38 39 new WText("momentum of the central trajectory (GeV/c) : ",dialog_->contents());40 p0Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());41 new WBreak(dialog_->contents());42 43 WPushButton *submit = new WPushButton("OK",dialog_->contents());44 submit->clicked().connect(dialog_, &Wt::WDialog::accept);45 dialog_->finished().connect(this, &GWt_beam::dialogDone);46 47 // make image48 image_ = new WImage("htdocs/beam.jpg",this);49 50 // activate slots11 12 13 string* param = beginDialog(); 14 15 new WText(" 1/2 horizontal beam extend rms (cm) : ",dialog_->contents()); 16 xEdit_ = new WLineEdit(param->c_str(), dialog_->contents()); 17 // new WBreak(dialog_->contents()); 18 19 new WText("1/2 horizontal beam divergence rms (mrad) : ",dialog_->contents()); 20 xpEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 21 new WBreak(dialog_->contents()); 22 23 new WText("1/2 vertical beam extend rms (cm) : ",dialog_->contents()); 24 yEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 25 // new WBreak(dialog_->contents()); 26 27 new WText("1/2 horizontal beam divergence rms (mrad) : ",dialog_->contents()); 28 ypEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 29 new WBreak(dialog_->contents()); 30 31 new WText("1/2 longitudinal beam extend rms (cm) : ",dialog_->contents()); 32 dlEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 33 // new WBreak(dialog_->contents()); 34 35 new WText("1/2 momentum spread rms (mrad) : ",dialog_->contents()); 36 delEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 37 new WBreak(dialog_->contents()); 38 39 new WText("momentum of the central trajectory (GeV/c) : ",dialog_->contents()); 40 p0Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 41 new WBreak(dialog_->contents()); 42 43 WPushButton *submit = new WPushButton("OK",dialog_->contents()); 44 submit->clicked().connect(dialog_, &Wt::WDialog::accept); 45 dialog_->finished().connect(this, &GWt_beam::dialogDone); 46 47 // make image 48 image_ = new WImage("htdocs/beam.jpg",this); 49 50 // activate slots 51 51 image_->clicked().connect(this,&GWt_abstractElement::clicked); 52 52 53 53 } 54 54 55 55 void GWt_beam::dialogDone() 56 56 { 57 unsigned nbParam = abstractElement_->getNbParams();58 string* envoi = new string[nbParam+1];59 int compteur = -1;60 envoi[++compteur] = mixedTools::intToString(nbParam);61 envoi[++compteur] = labelEdit_->text().toUTF8();62 envoi[++compteur] = xEdit_->text().toUTF8();63 envoi[++compteur] = xpEdit_->text().toUTF8();64 envoi[++compteur] = yEdit_->text().toUTF8();65 envoi[++compteur] = ypEdit_->text().toUTF8();66 envoi[++compteur] = dlEdit_->text().toUTF8();67 envoi[++compteur] = delEdit_->text().toUTF8();68 envoi[++compteur] = p0Edit_->text().toUTF8();69 if ( compteur != (int)nbParam ) {70 cerr << " GWt_beam::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl;71 return;72 }73 abstractElement_->setParametersString(envoi);74 updateLabelWidget();75 delete [] envoi;57 unsigned nbParam = abstractElement_->getNbParams(); 58 string* envoi = new string[nbParam+1]; 59 int compteur = -1; 60 envoi[++compteur] = mixedTools::intToString(nbParam); 61 envoi[++compteur] = labelEdit_->text().toUTF8(); 62 envoi[++compteur] = xEdit_->text().toUTF8(); 63 envoi[++compteur] = xpEdit_->text().toUTF8(); 64 envoi[++compteur] = yEdit_->text().toUTF8(); 65 envoi[++compteur] = ypEdit_->text().toUTF8(); 66 envoi[++compteur] = dlEdit_->text().toUTF8(); 67 envoi[++compteur] = delEdit_->text().toUTF8(); 68 envoi[++compteur] = p0Edit_->text().toUTF8(); 69 if ( compteur != (int)nbParam ) { 70 cerr << " GWt_beam::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; 71 return; 72 } 73 abstractElement_->setParametersString(envoi); 74 updateLabelWidget(); 75 delete [] envoi; 76 76 } 77 77 78 78 WImage* GWt_beam::getImage() { 79 return image_;79 return image_; 80 80 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_bend.cc
r266 r272 11 11 GWt_bend::GWt_bend(abstractElement* elem ,GWt_elementLigneFaisceau* elemLigne) : GWt_abstractElement(elem, elemLigne) 12 12 { 13 14 string* param = beginDialog();15 16 new WText("angle (deg.) : ",dialog_->contents());17 angleEdit_ = new WLineEdit( param->c_str(), dialog_->contents());18 new WBreak(dialog_->contents());19 20 new WText("radius (m) : ",dialog_->contents());21 radiusEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());22 new WBreak(dialog_->contents());23 24 new WText("momentum (MeV/c) : ",dialog_->contents());25 momentumEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());26 new WBreak(dialog_->contents());27 28 new WText("length (cm) : ",dialog_->contents());29 xlengthEdit_ = new WLineEdit("0", dialog_->contents());30 xlengthEdit_->setDisabled(true);31 new WBreak(dialog_->contents());32 33 new WText("aperture (cm) : ",dialog_->contents());34 apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());35 apertureEdit_->setDisabled(true);36 new WBreak(dialog_->contents());37 38 new WText("pole face rotations (deg.) entrance : ",dialog_->contents());39 beta1Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());40 new WText("exit : ",dialog_->contents());41 beta2Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());42 new WBreak(dialog_->contents());43 44 WPushButton *submit = new WPushButton("OK",dialog_->contents());45 submit->clicked().connect(dialog_, &Wt::WDialog::accept);46 dialog_->finished().connect(this, &GWt_bend::dialogDone);47 48 // make image49 image_ = new WImage("htdocs/bend.jpg",this);50 13 14 string* param = beginDialog(); 15 16 new WText("angle (deg.) : ",dialog_->contents()); 17 angleEdit_ = new WLineEdit( param->c_str(), dialog_->contents()); 18 new WBreak(dialog_->contents()); 19 20 new WText("radius (m) : ",dialog_->contents()); 21 radiusEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 22 new WBreak(dialog_->contents()); 23 24 new WText("momentum (MeV/c) : ",dialog_->contents()); 25 momentumEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 26 new WBreak(dialog_->contents()); 27 28 new WText("length (cm) : ",dialog_->contents()); 29 xlengthEdit_ = new WLineEdit("0", dialog_->contents()); 30 xlengthEdit_->setDisabled(true); 31 new WBreak(dialog_->contents()); 32 33 new WText("aperture (cm) : ",dialog_->contents()); 34 apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 35 apertureEdit_->setDisabled(true); 36 new WBreak(dialog_->contents()); 37 38 new WText("pole face rotations (deg.) entrance : ",dialog_->contents()); 39 beta1Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 40 new WText("exit : ",dialog_->contents()); 41 beta2Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 42 new WBreak(dialog_->contents()); 43 44 WPushButton *submit = new WPushButton("OK",dialog_->contents()); 45 submit->clicked().connect(dialog_, &Wt::WDialog::accept); 46 dialog_->finished().connect(this, &GWt_bend::dialogDone); 47 48 // make image 49 image_ = new WImage("htdocs/bend.jpg",this); 50 51 51 // activate slots 52 52 image_->clicked().connect(this,&GWt_abstractElement::clicked); 53 53 54 54 55 55 } 56 56 57 57 void GWt_bend::dialogDone() 58 58 { 59 unsigned nbParam = abstractElement_->getNbParams();60 string* envoi = new string[nbParam+1];61 int compteur = -1;62 envoi[++compteur] = string(mixedTools::intToString(nbParam) );63 envoi[++compteur] = labelEdit_->text().toUTF8();64 cout << " GWt_bend::dialogDone() j'envoie " << envoi[compteur] << endl;65 envoi[++compteur] = angleEdit_->text().toUTF8();66 envoi[++compteur] = radiusEdit_->text().toUTF8();67 envoi[++compteur] = momentumEdit_->text().toUTF8();68 envoi[++compteur] = apertureEdit_->text().toUTF8();69 envoi[++compteur] = beta1Edit_->text().toUTF8();70 envoi[++compteur] = beta2Edit_->text().toUTF8();71 72 if ( compteur != (int)nbParam ) {73 cerr << " GWt_bend::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl;74 return;75 }76 abstractElement_->setParametersString(envoi);77 updateLabelWidget();78 delete [] envoi;59 unsigned nbParam = abstractElement_->getNbParams(); 60 string* envoi = new string[nbParam+1]; 61 int compteur = -1; 62 envoi[++compteur] = string(mixedTools::intToString(nbParam) ); 63 envoi[++compteur] = labelEdit_->text().toUTF8(); 64 cout << " GWt_bend::dialogDone() j'envoie " << envoi[compteur] << endl; 65 envoi[++compteur] = angleEdit_->text().toUTF8(); 66 envoi[++compteur] = radiusEdit_->text().toUTF8(); 67 envoi[++compteur] = momentumEdit_->text().toUTF8(); 68 envoi[++compteur] = apertureEdit_->text().toUTF8(); 69 envoi[++compteur] = beta1Edit_->text().toUTF8(); 70 envoi[++compteur] = beta2Edit_->text().toUTF8(); 71 72 if ( compteur != (int)nbParam ) { 73 cerr << " GWt_bend::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; 74 return; 75 } 76 abstractElement_->setParametersString(envoi); 77 updateLabelWidget(); 78 delete [] envoi; 79 79 } 80 80 81 81 82 82 WImage* GWt_bend::getImage() { 83 return image_;83 return image_; 84 84 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_cell.cc
r266 r272 12 12 GWt_cell::GWt_cell(abstractElement* elem ,GWt_elementLigneFaisceau* elemLigne) : GWt_abstractElement(elem, elemLigne) 13 13 { 14 15 string* param = beginDialog();16 17 new WText("length (cm) : ",dialog_->contents());18 lenghtElemEdit_ = new WLineEdit(param->c_str(), dialog_->contents());19 new WBreak(dialog_->contents());20 21 new WText("aperture (cm) : ",dialog_->contents());22 apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());23 new WBreak(dialog_->contents());24 25 new WText("initial phase (deg.) : ",dialog_->contents());26 initialPhaseEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());27 new WBreak(dialog_->contents());28 29 new WText("max phase step (deg.) : ",dialog_->contents());30 phaseStepMaxEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());31 new WBreak(dialog_->contents());32 33 new WText("max accelerating field (MV/m) : ",dialog_->contents());34 acceleratingFieldEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());35 new WBreak(dialog_->contents());36 37 new WText("name of file for field shape : ",dialog_->contents());38 acceleratingShapeFileEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());39 new WBreak(dialog_->contents());40 41 WPanel *panel = new WPanel(dialog_->contents());42 panel->setTitle(" magnetic focusing ");43 44 WText* t1 = new WText("name of file for focusing mag. field : ",dialog_->contents());45 focusingMagFileEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());46 new WBreak(dialog_->contents());47 48 WText* t2 = new WText(" z-offset for mag. field : ",dialog_->contents());49 offsetMagEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());50 51 WText* t3 = new WText(" scaling factor for mag. field : ",dialog_->contents());52 scaleFactorEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());53 54 WContainerWidget* contenu = new WContainerWidget();55 contenu->addWidget(t1);56 contenu->addWidget(focusingMagFileEdit_);57 contenu->addWidget(new WBreak());58 contenu->addWidget(t2);59 contenu->addWidget(offsetMagEdit_);60 contenu->addWidget(new WBreak());61 contenu->addWidget(t3);62 contenu->addWidget(scaleFactorEdit_);63 64 panel->setCentralWidget(contenu);65 66 WPushButton *submit = new WPushButton("OK",dialog_->contents());67 submit->clicked().connect(dialog_, &Wt::WDialog::accept);68 dialog_->finished().connect(this, &GWt_cell::dialogDone);69 70 // make image71 image_ = new WImage("htdocs/cell.jpg",this);72 14 15 string* param = beginDialog(); 16 17 new WText("length (cm) : ",dialog_->contents()); 18 lenghtElemEdit_ = new WLineEdit(param->c_str(), dialog_->contents()); 19 new WBreak(dialog_->contents()); 20 21 new WText("aperture (cm) : ",dialog_->contents()); 22 apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 23 new WBreak(dialog_->contents()); 24 25 new WText("initial phase (deg.) : ",dialog_->contents()); 26 initialPhaseEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 27 new WBreak(dialog_->contents()); 28 29 new WText("max phase step (deg.) : ",dialog_->contents()); 30 phaseStepMaxEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 31 new WBreak(dialog_->contents()); 32 33 new WText("max accelerating field (MV/m) : ",dialog_->contents()); 34 acceleratingFieldEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 35 new WBreak(dialog_->contents()); 36 37 new WText("name of file for field shape : ",dialog_->contents()); 38 acceleratingShapeFileEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 39 new WBreak(dialog_->contents()); 40 41 WPanel *panel = new WPanel(dialog_->contents()); 42 panel->setTitle(" magnetic focusing "); 43 44 WText* t1 = new WText("name of file for focusing mag. field : ",dialog_->contents()); 45 focusingMagFileEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 46 new WBreak(dialog_->contents()); 47 48 WText* t2 = new WText(" z-offset for mag. field : ",dialog_->contents()); 49 offsetMagEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 50 51 WText* t3 = new WText(" scaling factor for mag. field : ",dialog_->contents()); 52 scaleFactorEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 53 54 WContainerWidget* contenu = new WContainerWidget(); 55 contenu->addWidget(t1); 56 contenu->addWidget(focusingMagFileEdit_); 57 contenu->addWidget(new WBreak()); 58 contenu->addWidget(t2); 59 contenu->addWidget(offsetMagEdit_); 60 contenu->addWidget(new WBreak()); 61 contenu->addWidget(t3); 62 contenu->addWidget(scaleFactorEdit_); 63 64 panel->setCentralWidget(contenu); 65 66 WPushButton *submit = new WPushButton("OK",dialog_->contents()); 67 submit->clicked().connect(dialog_, &Wt::WDialog::accept); 68 dialog_->finished().connect(this, &GWt_cell::dialogDone); 69 70 // make image 71 image_ = new WImage("htdocs/cell.jpg",this); 72 73 73 // activate slots 74 74 image_->clicked().connect(this,&GWt_abstractElement::clicked); 75 75 76 76 77 77 } 78 78 79 79 void GWt_cell::dialogDone() 80 80 { 81 unsigned nbParam = abstractElement_->getNbParams();82 string* envoi = new string[nbParam+1];83 int compteur = -1;84 85 envoi[++compteur] = mixedTools::intToString(nbParam);86 envoi[++compteur] = labelEdit_->text().toUTF8();87 envoi[++compteur] = lenghtElemEdit_->text().toUTF8();88 envoi[++compteur] = apertureEdit_->text().toUTF8();89 envoi[++compteur] = initialPhaseEdit_->text().toUTF8();90 envoi[++compteur] = phaseStepMaxEdit_->text().toUTF8();91 envoi[++compteur] = acceleratingFieldEdit_->text().toUTF8();92 envoi[++compteur] = acceleratingShapeFileEdit_->text().toUTF8();93 envoi[++compteur] = focusingMagFileEdit_->text().toUTF8();94 envoi[++compteur] = offsetMagEdit_->text().toUTF8();95 envoi[++compteur] = scaleFactorEdit_->text().toUTF8();96 if ( compteur != (int)nbParam ) {97 cerr << " GWt_cell::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl;98 return;99 }100 abstractElement_->setParametersString(envoi);101 updateLabelWidget();102 delete [] envoi;81 unsigned nbParam = abstractElement_->getNbParams(); 82 string* envoi = new string[nbParam+1]; 83 int compteur = -1; 84 85 envoi[++compteur] = mixedTools::intToString(nbParam); 86 envoi[++compteur] = labelEdit_->text().toUTF8(); 87 envoi[++compteur] = lenghtElemEdit_->text().toUTF8(); 88 envoi[++compteur] = apertureEdit_->text().toUTF8(); 89 envoi[++compteur] = initialPhaseEdit_->text().toUTF8(); 90 envoi[++compteur] = phaseStepMaxEdit_->text().toUTF8(); 91 envoi[++compteur] = acceleratingFieldEdit_->text().toUTF8(); 92 envoi[++compteur] = acceleratingShapeFileEdit_->text().toUTF8(); 93 envoi[++compteur] = focusingMagFileEdit_->text().toUTF8(); 94 envoi[++compteur] = offsetMagEdit_->text().toUTF8(); 95 envoi[++compteur] = scaleFactorEdit_->text().toUTF8(); 96 if ( compteur != (int)nbParam ) { 97 cerr << " GWt_cell::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; 98 return; 99 } 100 abstractElement_->setParametersString(envoi); 101 updateLabelWidget(); 102 delete [] envoi; 103 103 } 104 104 105 105 106 106 WImage* GWt_cell::getImage() { 107 return image_;107 return image_; 108 108 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_console.cc
r257 r272 7 7 :WContainerWidget() 8 8 { 9 setObjectName("console");9 setObjectName("console"); 10 10 } 11 11 … … 17 17 18 18 void GWt_console::addConsoleMessage(WString msg) { 19 20 WText *w = new WText(this);21 w->setTextFormat(PlainText);22 w->setText(msg);23 w->setInline(false);24 19 20 WText *w = new WText(this); 21 w->setTextFormat(PlainText); 22 w->setText(msg); 23 w->setInline(false); 24 25 25 /* 26 * Little javascript trick to make sure we scroll along with new content27 */28 wApp->doJavaScript(this->jsRef() + ".scrollTop += "29 + this->jsRef() + ".scrollHeight;");30 26 * Little javascript trick to make sure we scroll along with new content 27 */ 28 wApp->doJavaScript(this->jsRef() + ".scrollTop += " 29 + this->jsRef() + ".scrollHeight;"); 30 31 31 } 32 32 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_dialog.cc
r257 r272 9 9 10 10 GWt_dialog::GWt_dialog( 11 WString titre,12 WContainerWidget* wc,13 bool modal14 ):15 11 WString titre, 12 WContainerWidget* wc, 13 bool modal 14 ): 15 WDialog(titre) 16 16 { 17 18 // change the title bar style19 titleBar()->decorationStyle().setBackgroundColor (WColor(70,180,220));20 21 WContainerWidget* widgt = new WContainerWidget(contents());22 WHBoxLayout* hLayout = new WHBoxLayout();23 hLayout->addWidget(wc);24 widgt->setLayout(hLayout);25 26 setClosable(true);27 setModal (modal);17 18 // change the title bar style 19 titleBar()->decorationStyle().setBackgroundColor (WColor(70,180,220)); 20 21 WContainerWidget* widgt = new WContainerWidget(contents()); 22 WHBoxLayout* hLayout = new WHBoxLayout(); 23 hLayout->addWidget(wc); 24 widgt->setLayout(hLayout); 25 26 setClosable(true); 27 setModal (modal); 28 28 } 29 29 … … 31 31 32 32 GWt_dialog::GWt_dialog( 33 WString titre,34 std::string message,35 iconType icon,36 bool modal,37 bool ok38 ):39 33 WString titre, 34 std::string message, 35 iconType icon, 36 bool modal, 37 bool ok 38 ): 39 WDialog(titre) 40 40 { 41 42 // change the title bar style43 titleBar()->decorationStyle().setBackgroundColor (WColor(70,180,220));44 45 WContainerWidget* widgt = new WContainerWidget(contents());46 WHBoxLayout* hLayout = new WHBoxLayout();47 48 WImage* tImg = new WImage("icons/error.png");49 switch (icon) {50 case Warning:51 tImg->setImageLink ("icons/warning.png");52 tImg->setMaximumSize (70,70);53 hLayout->addWidget(tImg);54 break;55 case Error:56 tImg->setImageLink ("icons/error.png");57 tImg->setMaximumSize (70,70);58 hLayout->addWidget(tImg);59 break;60 case Info:61 tImg->setImageLink ("icons/info.png");62 tImg->setMaximumSize (70,70);63 hLayout->addWidget(tImg);64 break;65 case Wait:66 tImg->setImageLink ("icons/patientez.gif");67 tImg->setMaximumSize (70,70);68 hLayout->addWidget(tImg);69 break;70 case NoIcon:71 break;72 default:73 break;74 }75 76 WContainerWidget* right = new WContainerWidget();77 WVBoxLayout* vLayout = new WVBoxLayout();78 79 // changement des "\n" par des <br>80 size_t pos = message.find("\n", 0);81 82 while(pos != std::string::npos) {83 vLayout->addWidget(new Wt::WText(WString::fromUTF8(message.substr(0,pos))));84 message = message.substr(pos+1);85 pos = message.find("\n");86 vLayout->addWidget(new Wt::WBreak());87 }88 vLayout->addWidget(new Wt::WText(WString::fromUTF8(message)));89 90 91 if (ok) {92 vLayout->addWidget(new Wt::WBreak);93 94 Wt::WPushButton *ok = new Wt::WPushButton("Ok");95 vLayout->addWidget(ok);96 97 // this event will accept() the Dialog98 ok->clicked().connect(this, &Wt::WDialog::accept);99 }100 101 right->setLayout(vLayout);102 hLayout->addWidget(right);103 104 widgt->setLayout(hLayout);105 106 setClosable(true);107 setModal (modal);41 42 // change the title bar style 43 titleBar()->decorationStyle().setBackgroundColor (WColor(70,180,220)); 44 45 WContainerWidget* widgt = new WContainerWidget(contents()); 46 WHBoxLayout* hLayout = new WHBoxLayout(); 47 48 WImage* tImg = new WImage("icons/error.png"); 49 switch (icon) { 50 case Warning: 51 tImg->setImageLink ("icons/warning.png"); 52 tImg->setMaximumSize (70,70); 53 hLayout->addWidget(tImg); 54 break; 55 case Error: 56 tImg->setImageLink ("icons/error.png"); 57 tImg->setMaximumSize (70,70); 58 hLayout->addWidget(tImg); 59 break; 60 case Info: 61 tImg->setImageLink ("icons/info.png"); 62 tImg->setMaximumSize (70,70); 63 hLayout->addWidget(tImg); 64 break; 65 case Wait: 66 tImg->setImageLink ("icons/patientez.gif"); 67 tImg->setMaximumSize (70,70); 68 hLayout->addWidget(tImg); 69 break; 70 case NoIcon: 71 break; 72 default: 73 break; 74 } 75 76 WContainerWidget* right = new WContainerWidget(); 77 WVBoxLayout* vLayout = new WVBoxLayout(); 78 79 // changement des "\n" par des <br> 80 size_t pos = message.find("\n", 0); 81 82 while(pos != std::string::npos) { 83 vLayout->addWidget(new Wt::WText(WString::fromUTF8(message.substr(0,pos)))); 84 message = message.substr(pos+1); 85 pos = message.find("\n"); 86 vLayout->addWidget(new Wt::WBreak()); 87 } 88 vLayout->addWidget(new Wt::WText(WString::fromUTF8(message))); 89 90 91 if (ok) { 92 vLayout->addWidget(new Wt::WBreak); 93 94 Wt::WPushButton *ok = new Wt::WPushButton("Ok"); 95 vLayout->addWidget(ok); 96 97 // this event will accept() the Dialog 98 ok->clicked().connect(this, &Wt::WDialog::accept); 99 } 100 101 right->setLayout(vLayout); 102 hLayout->addWidget(right); 103 104 widgt->setLayout(hLayout); 105 106 setClosable(true); 107 setModal (modal); 108 108 } 109 109 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_draggableImage.cc
r257 r272 5 5 6 6 GWt_draggableImage::GWt_draggableImage( 7 const WLink & imageLink,8 const WString & altText,9 WContainerWidget * parent):10 7 const WLink & imageLink, 8 const WString & altText, 9 WContainerWidget * parent): 10 WImage(imageLink,altText,parent) 11 11 { 12 init();12 init(); 13 13 } 14 14 15 15 16 16 GWt_draggableImage::GWt_draggableImage( 17 const WLink & imageLink,18 WContainerWidget * parent):19 17 const WLink & imageLink, 18 WContainerWidget * parent): 19 WImage(imageLink,"Image PSPA",parent) 20 20 { 21 init();21 init(); 22 22 } 23 23 … … 29 29 30 30 void GWt_draggableImage::init(){ 31 changeCursorOnMouseOver_ = true;32 33 // setMouseOverDelay(100);34 mouseWentOver().connect(this, &GWt_draggableImage::mouseOver);35 mouseWentUp().connect(this, &GWt_draggableImage::mouseUp);36 mouseWentDown().connect(this, &GWt_draggableImage::mouseDown);37 mouseWentOut().connect(this, &GWt_draggableImage::mouseOut);38 mouseDragged().connect(this, &GWt_draggableImage::mouseIsDragged);31 changeCursorOnMouseOver_ = true; 32 33 // setMouseOverDelay(100); 34 mouseWentOver().connect(this, &GWt_draggableImage::mouseOver); 35 mouseWentUp().connect(this, &GWt_draggableImage::mouseUp); 36 mouseWentDown().connect(this, &GWt_draggableImage::mouseDown); 37 mouseWentOut().connect(this, &GWt_draggableImage::mouseOut); 38 mouseDragged().connect(this, &GWt_draggableImage::mouseIsDragged); 39 39 } 40 40 41 41 42 42 void GWt_draggableImage::setChangeCursorOnMouseOver(bool change){ 43 changeCursorOnMouseOver_ = change;43 changeCursorOnMouseOver_ = change; 44 44 } 45 45 … … 47 47 void GWt_draggableImage::mouseOver(const WMouseEvent& e) 48 48 { 49 if (changeCursorOnMouseOver_) {50 decorationStyle().setCursor(OpenHandCursor);51 } else {52 decorationStyle().setCursor(ArrowCursor);53 }49 if (changeCursorOnMouseOver_) { 50 decorationStyle().setCursor(OpenHandCursor); 51 } else { 52 decorationStyle().setCursor(ArrowCursor); 53 } 54 54 } 55 55 56 56 void GWt_draggableImage::mouseOut(const WMouseEvent& e) 57 57 { 58 decorationStyle().setCursor(ArrowCursor); 58 decorationStyle().setCursor(ArrowCursor); 59 59 } 60 60 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_drift.cc
r266 r272 11 11 GWt_drift::GWt_drift(abstractElement* elem ,GWt_elementLigneFaisceau* elemLigne) : GWt_abstractElement(elem,elemLigne) 12 12 { 13 14 string* param = beginDialog();15 16 new WText("length (cm) : ",dialog_->contents());17 xlengthEdit_ = new WLineEdit(param->c_str(), dialog_->contents());18 new WBreak(dialog_->contents());19 new WText("aperture (cm) : ",dialog_->contents());20 apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());21 new WBreak(dialog_->contents());22 WPushButton *submit = new WPushButton("OK",dialog_->contents());23 submit->clicked().connect(dialog_, &Wt::WDialog::accept);24 dialog_->finished().connect(this, &GWt_drift::dialogDone);25 26 // make image27 image_ = new WImage("htdocs/drift.jpg",this);13 14 string* param = beginDialog(); 15 16 new WText("length (cm) : ",dialog_->contents()); 17 xlengthEdit_ = new WLineEdit(param->c_str(), dialog_->contents()); 18 new WBreak(dialog_->contents()); 19 new WText("aperture (cm) : ",dialog_->contents()); 20 apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 21 new WBreak(dialog_->contents()); 22 WPushButton *submit = new WPushButton("OK",dialog_->contents()); 23 submit->clicked().connect(dialog_, &Wt::WDialog::accept); 24 dialog_->finished().connect(this, &GWt_drift::dialogDone); 25 26 // make image 27 image_ = new WImage("htdocs/drift.jpg",this); 28 28 29 29 // activate slots … … 34 34 void GWt_drift::dialogDone() 35 35 { 36 unsigned nbParam = abstractElement_->getNbParams();37 string* envoi = new string[nbParam+1];38 int compteur = -1;39 envoi[++compteur] = mixedTools::intToString(nbParam);40 envoi[++compteur] = labelEdit_->text().toUTF8();41 envoi[++compteur] = xlengthEdit_->text().toUTF8();42 envoi[++compteur] = apertureEdit_->text().toUTF8();43 if ( compteur != (int)nbParam ) {44 cerr << " GWt_drift::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl;45 return;46 }47 abstractElement_->setParametersString(envoi);48 updateLabelWidget();49 delete [] envoi;36 unsigned nbParam = abstractElement_->getNbParams(); 37 string* envoi = new string[nbParam+1]; 38 int compteur = -1; 39 envoi[++compteur] = mixedTools::intToString(nbParam); 40 envoi[++compteur] = labelEdit_->text().toUTF8(); 41 envoi[++compteur] = xlengthEdit_->text().toUTF8(); 42 envoi[++compteur] = apertureEdit_->text().toUTF8(); 43 if ( compteur != (int)nbParam ) { 44 cerr << " GWt_drift::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; 45 return; 46 } 47 abstractElement_->setParametersString(envoi); 48 updateLabelWidget(); 49 delete [] envoi; 50 50 } 51 51 52 52 53 53 WImage* GWt_drift::getImage() { 54 return image_;54 return image_; 55 55 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_dropZoneLigneFaisceau.cc
r271 r272 13 13 14 14 GWt_dropZoneLigneFaisceau::GWt_dropZoneLigneFaisceau() 15 16 17 // connect mouse events18 19 mouseWentOver().connect(this, &GWt_dropZoneLigneFaisceau::mouseOver);20 mouseWentUp().connect(this, &GWt_dropZoneLigneFaisceau::mouseUp);21 mouseWentDown().connect(this, &GWt_dropZoneLigneFaisceau::mouseDown);22 mouseWentOut().connect(this, &GWt_dropZoneLigneFaisceau::mouseOut);23 mouseDragged().connect(this, &GWt_dropZoneLigneFaisceau::mouseIsDragged);24 25 //decorationStyle().setBorder (WBorder (WBorder::Dotted));26 27 // accept drops28 acceptDrops("htdocs/beam.jpg");29 acceptDrops("htdocs/rfgun.jpg");30 acceptDrops("htdocs/drift.jpg");31 acceptDrops("htdocs/cell.jpg");32 acceptDrops("htdocs/bend.jpg");33 acceptDrops("htdocs/soleno.jpg");34 acceptDrops("htdocs/fit.jpg");35 15 : WContainerWidget(){ 16 17 // connect mouse events 18 19 mouseWentOver().connect(this, &GWt_dropZoneLigneFaisceau::mouseOver); 20 mouseWentUp().connect(this, &GWt_dropZoneLigneFaisceau::mouseUp); 21 mouseWentDown().connect(this, &GWt_dropZoneLigneFaisceau::mouseDown); 22 mouseWentOut().connect(this, &GWt_dropZoneLigneFaisceau::mouseOut); 23 mouseDragged().connect(this, &GWt_dropZoneLigneFaisceau::mouseIsDragged); 24 25 decorationStyle().setBorder (WBorder (WBorder::Dotted)); 26 27 // accept drops 28 acceptDrops("htdocs/beam.jog"); 29 acceptDrops("htdocs/rfgun.jpg"); 30 acceptDrops("htdocs/drift.jpg"); 31 acceptDrops("htdocs/cell.jpg"); 32 acceptDrops("htdocs/bend.jpg"); 33 acceptDrops("htdocs/soleno.jpg"); 34 acceptDrops("htdocs/fit.jpg"); 35 36 36 } 37 37 … … 44 44 void GWt_dropZoneLigneFaisceau::mouseOver(const WMouseEvent& e) 45 45 { 46 // Add text47 #ifdef PSPA_DEBUG 48 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {49 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));50 console->addConsoleMessage("GWt_dropZoneLigneFaisceau::mouseOver ");51 console->addConsoleMessage("button "+WMouseEvent::LeftButton);52 }46 // Add text 47 #ifdef PSPA_DEBUG 48 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 49 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 50 console->addConsoleMessage("GWt_dropZoneLigneFaisceau::mouseOver "); 51 console->addConsoleMessage("button "+WMouseEvent::LeftButton); 52 } 53 53 #endif 54 54 } … … 57 57 { 58 58 #ifdef PSPA_DEBUG 59 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {60 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));61 console->addConsoleMessage("GWt_dropZoneLigneFaisceau::mouseOut");62 }59 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 60 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 61 console->addConsoleMessage("GWt_dropZoneLigneFaisceau::mouseOut"); 62 } 63 63 #endif 64 64 } … … 67 67 { 68 68 #ifdef PSPA_DEBUG 69 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {70 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));71 console->addConsoleMessage(" GWt_dropZoneLigneFaisceau::mouseDragged");72 }69 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 70 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 71 console->addConsoleMessage(" GWt_dropZoneLigneFaisceau::mouseDragged"); 72 } 73 73 #endif 74 74 } … … 77 77 { 78 78 #ifdef PSPA_DEBUG 79 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {80 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));81 console->addConsoleMessage("GWt_dropZoneLigneFaisceau::mouseOut up");82 }79 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 80 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 81 console->addConsoleMessage("GWt_dropZoneLigneFaisceau::mouseOut up"); 82 } 83 83 #endif 84 84 } … … 87 87 { 88 88 #ifdef PSPA_DEBUG 89 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {90 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));91 console->addConsoleMessage("GWt_dropZoneLigneFaisceau::mouseDown up");92 }89 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 90 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 91 console->addConsoleMessage("GWt_dropZoneLigneFaisceau::mouseDown up"); 92 } 93 93 #endif 94 94 } … … 96 96 void GWt_dropZoneLigneFaisceau::dropEvent(WDropEvent evt) 97 97 { 98 99 #ifdef PSPA_DEBUG 100 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {101 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));102 console->addConsoleMessage(" GWt_dropZoneLigneFaisceau::dropEvent");103 }104 #endif 105 106 // get LigneFaiseau widget and add new elementLigneFaiseau107 GWt_LigneFaisceau* ligneFaisceau = NULL;108 if ( static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) {109 ligneFaisceau = static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"));110 } else {111 return;112 }113 114 // get the type of element115 nomdElements e(evt.mimeType());116 typedElement eType = e.getElementType();117 118 ligneFaisceau->addElement(eType);119 120 121 /*122 nomdElements e(evt.mimeType());123 typedElement eType = e.getElementType();124 125 // update source if necessary126 cout<<"dynamic_cast SOURCE------" << evt.source() << endl;127 if (dynamic_cast <GWt_dropZoneLigneFaisceau*> (evt.source())) {128 cout<<"OKIKKKIIII" << dynamic_cast <GWt_dropZoneLigneFaisceau*> (evt.source()) << endl;129 removeOtherDropZone(dynamic_cast <GWt_dropZoneLigneFaisceau*> (evt.source()));130 }131 132 if(eType == inconnu) {133 cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl;134 return;135 }136 137 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {138 139 140 }141 142 abstractElement* ptr = pspa_->getDataManager()->addElement(eType);143 144 ptr->setLabel(getElementNumberInBeamLine(e));145 146 GWt_abstractElement* insertedAbstractElement = GWt_abstractElement::ajoute(ptr);147 cout << " je vais ajouter l'element " << ptr->getNomdElement().getElementName() << " de type " << ptr->getNomdElement().getElementType() << "ID "<< insertedAbstractElement << endl;148 149 if(insertedAbstractElement == NULL) return;150 insertedAbstractElement->setLabelWidget();151 152 WSignalMapper<GWt_abstractElement *> *mapper= new WSignalMapper<GWt_abstractElement *>(this);153 mapper->mapped().connect(this,&GWt_dropZoneLigneFaisceau::onClick);154 mapper->mapConnect(insertedAbstractElement->getImage()->doubleClicked(),insertedAbstractElement);155 156 //////////////////////////////////////////////////////////////////157 158 // add the dropped widget159 printf("add the dropped widget\n");160 161 // add drop zone before and after162 if (static_cast <WContainerWidget*> (parent())) {163 WContainerWidget* wc = static_cast <WContainerWidget*> (parent());164 165 cout<<"add the dropped parent %d"<< wc << " COUNT:"<< count () <<"<---------------"<< endl;166 // do not insert new element if some element is already present167 168 WBoxLayout* layout = ((WBoxLayout*)(wc->layout()));169 bool replaceElement = false;170 171 if (abstractElement_) {172 173 }174 175 // insert one before176 if (!replaceElement) {177 178 179 180 181 182 183 184 }185 // FIXME Replace186 187 // complete widget188 clear();189 arrowImage_ = NULL;190 abstractElement_ = insertedAbstractElement->getWidget();191 addWidget(abstractElement_);192 // change strech (useful if it was the last one)193 layout->setStretchFactor(this,0);194 195 // change background196 decorationStyle().setBackgroundColor (WColor("white"));197 198 // remove border199 decorationStyle().setBorder (WBorder (WBorder::None));200 201 202 // insert after203 // if it is the last, add a strech factor and no link image204 cout<<" nb elem:"<< layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1 << " COUNT:"<< wc->count () <<"<---------------ID:"<< abstractElement_ << endl;205 if (!replaceElement) {206 207 208 209 210 211 }212 */213 98 99 #ifdef PSPA_DEBUG 100 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 101 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 102 console->addConsoleMessage(" GWt_dropZoneLigneFaisceau::dropEvent"); 103 } 104 #endif 105 106 // get LigneFaiseau widget and add new elementLigneFaiseau 107 GWt_LigneFaisceau* ligneFaisceau = NULL; 108 if ( static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) { 109 ligneFaisceau = static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau")); 110 } else { 111 return; 112 } 113 114 // get the type of element 115 nomdElements e(evt.mimeType()); 116 typedElement eType = e.getElementType(); 117 118 ligneFaisceau->addElement(eType); 119 120 121 /* 122 nomdElements e(evt.mimeType()); 123 typedElement eType = e.getElementType(); 124 125 // update source if necessary 126 cout<<"dynamic_cast SOURCE------" << evt.source() << endl; 127 if (dynamic_cast <GWt_dropZoneLigneFaisceau*> (evt.source())) { 128 cout<<"OKIKKKIIII" << dynamic_cast <GWt_dropZoneLigneFaisceau*> (evt.source()) << endl; 129 removeOtherDropZone(dynamic_cast <GWt_dropZoneLigneFaisceau*> (evt.source())); 130 } 131 132 if(eType == inconnu) { 133 cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl; 134 return; 135 } 136 137 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 138 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 139 console->addConsoleMessage(e.getElementName()); 140 } 141 142 abstractElement* ptr = pspa_->getDataManager()->addElement(eType); 143 144 ptr->setLabel(getElementNumberInBeamLine(e)); 145 146 GWt_abstractElement* insertedAbstractElement = GWt_abstractElement::ajoute(ptr); 147 cout << " je vais ajouter l'element " << ptr->getNomdElement().getElementName() << " de type " << ptr->getNomdElement().getElementType() << "ID "<< insertedAbstractElement << endl; 148 149 if(insertedAbstractElement == NULL) return; 150 insertedAbstractElement->setLabelWidget(); 151 152 WSignalMapper<GWt_abstractElement *> *mapper= new WSignalMapper<GWt_abstractElement *>(this); 153 mapper->mapped().connect(this,&GWt_dropZoneLigneFaisceau::onClick); 154 mapper->mapConnect(insertedAbstractElement->getImage()->doubleClicked(),insertedAbstractElement); 155 156 ////////////////////////////////////////////////////////////////// 157 158 // add the dropped widget 159 printf("add the dropped widget\n"); 160 161 // add drop zone before and after 162 if (static_cast <WContainerWidget*> (parent())) { 163 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 164 165 cout<<"add the dropped parent %d"<< wc << " COUNT:"<< count () <<"<---------------"<< endl; 166 // do not insert new element if some element is already present 167 168 WBoxLayout* layout = ((WBoxLayout*)(wc->layout())); 169 bool replaceElement = false; 170 171 if (abstractElement_) { 172 replaceElement = true; 173 } 174 175 // insert one before 176 if (!replaceElement) { 177 // if it the first element of the beam line 178 if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))) == 0) { 179 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))), new GWt_dropZoneLigneFaisceau(pspa_,false)); 180 181 } else { 182 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))), new GWt_dropZoneLigneFaisceau(pspa_,true)); 183 } 184 } 185 // FIXME Replace 186 187 // complete widget 188 clear(); 189 arrowImage_ = NULL; 190 abstractElement_ = insertedAbstractElement->getWidget(); 191 addWidget(abstractElement_); 192 // change strech (useful if it was the last one) 193 layout->setStretchFactor(this,0); 194 195 // change background 196 decorationStyle().setBackgroundColor (WColor("white")); 197 198 // remove border 199 decorationStyle().setBorder (WBorder (WBorder::None)); 200 201 202 // insert after 203 // if it is the last, add a strech factor and no link image 204 cout<<" nb elem:"<< layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1 << " COUNT:"<< wc->count () <<"<---------------ID:"<< abstractElement_ << endl; 205 if (!replaceElement) { 206 if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1 == wc->count()) { 207 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1, new GWt_dropZoneLigneFaisceau(pspa_,false),1); 208 } else { 209 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1, new GWt_dropZoneLigneFaisceau(pspa_)); 210 } 211 } 212 */ 213 214 214 /* 215 215 * Set the image to be draggable, showing the other image (dragImage) 216 216 * to be used as the widget that is visually dragged. 217 217 */ 218 /*219 WImage *dragImage = new WImage(e.getImageFromType(eType).c_str(),this);220 221 // setDraggable(evt.mimeType(),dragImage,true);//,insertedAbstractElement->getButton(),true);222 abstractElement_->setDraggable(evt.mimeType(),dragImage,true, this);223 224 225 cout<<"add the dropped parent %d"<< wc << " COUNT:"<< wc->count () <<"<---------------"<< endl;226 }227 228 229 230 //insertedAbstractElement->getWidget()->decorationStyle().setBackgroundColor (WColor("blue"));231 pspa_->updateSelections();232 233 */234 } 235 236 218 /* 219 WImage *dragImage = new WImage(e.getImageFromType(eType).c_str(),this); 220 221 // setDraggable(evt.mimeType(),dragImage,true);//,insertedAbstractElement->getButton(),true); 222 abstractElement_->setDraggable(evt.mimeType(),dragImage,true, this); 223 224 225 cout<<"add the dropped parent %d"<< wc << " COUNT:"<< wc->count () <<"<---------------"<< endl; 226 } 227 228 229 230 //insertedAbstractElement->getWidget()->decorationStyle().setBackgroundColor (WColor("blue")); 231 pspa_->updateSelections(); 232 233 */ 234 } 235 236 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc
r267 r272 24 24 #include <Wt/WApplication> 25 25 26 //#define PSPA_DEBUG 126 #define PSPA_DEBUG 1 27 27 28 28 GWt_elementLigneFaisceau::GWt_elementLigneFaisceau() 29 30 31 32 33 29 : WContainerWidget(), 30 firstTimeInsertMessage_(NULL), 31 arrowImage_(NULL), 32 lineImage_(NULL), 33 abstractElement_(NULL) 34 34 { 35 35 // set the css name 36 36 setObjectName("elementLigneFaisceau"); 37 37 38 38 initialize_ligneFaisceau(NULL); 39 39 } … … 41 41 42 42 GWt_elementLigneFaisceau::GWt_elementLigneFaisceau(abstractElement* abstractElement) 43 44 45 46 47 48 43 : WContainerWidget(), 44 firstTimeInsertMessage_(NULL), 45 arrowImage_(NULL), 46 lineImage_(NULL), 47 abstractElement_(NULL), 48 elementName_(NULL) 49 49 { 50 50 initialize_ligneFaisceau(abstractElement); … … 64 64 // +----------+--------+---------+ 65 65 66 66 67 WGridLayout *gridLayout = new WGridLayout(); 67 68 … … 69 70 gridLayout->setHorizontalSpacing (0); 70 71 gridLayout->setVerticalSpacing (0); 71 72 72 73 // add first line : initialize arrow and link images 73 74 arrowImage_ = new GWt_dropZoneLigneFaisceau(); … … 88 89 arrowImage_->addWidget(arrow); 89 90 90 gridLayout->addWidget (arrowImage_,0,0); 91 gridLayout->addWidget (dragElementZone_,0,1); 92 gridLayout->addWidget (lineImage_,0,2); 93 94 // add the image if present 95 if (abstractElement != NULL) { 96 typedElement eType = abstractElement->getNomdElement().getElementType(); 97 98 switch ( eType ) { 99 case RFgun : 100 abstractElement_ = new GWt_rfgun(abstractElement, this); 101 break; 102 case drift : 103 abstractElement_ = new GWt_drift(abstractElement, this); 104 break; 105 case cell : 106 abstractElement_ = new GWt_cell(abstractElement, this); 107 break; 108 case bend : 109 abstractElement_ = new GWt_bend(abstractElement, this); 110 break; 111 case soleno : 112 abstractElement_ = new GWt_soleno(abstractElement, this); 113 break; 114 case beam : 115 abstractElement_ = new GWt_beam(abstractElement, this); 116 break; 117 case fit : 118 abstractElement_ = new GWt_fit(abstractElement, this); 119 break; 120 case inconnu : 121 abstractElement_ = NULL; 122 } 123 if (abstractElement_ != NULL) { 124 dragElementZone_->addWidget(abstractElement_->getImage()); 125 dragElementZone_->setMaximumSize(32,32); 126 dragElementZone_->setMinimumSize(32,32); 127 } 128 } 129 // add second line 130 if (abstractElement == NULL) { 131 elementName_ = new WText(); 132 } else { 133 elementName_ = new WText(abstractElement->getLabel()); 134 } 135 136 gridLayout->addWidget (elementName_,1,0,1,3); 137 138 // decorationStyle().setBorder (WBorder (WBorder::Dotted)); 139 140 // first insert message 91 gridLayout->addWidget (arrowImage_,0,0); 92 gridLayout->addWidget (dragElementZone_,0,1); 93 gridLayout->addWidget (lineImage_,0,2); 94 95 // add the image if present 96 if (abstractElement != NULL) { 97 typedElement eType = abstractElement->getNomdElement().getElementType(); 98 99 switch ( eType ) { 100 case RFgun : 101 abstractElement_ = new GWt_rfgun(abstractElement, this); 102 break; 103 case drift : 104 abstractElement_ = new GWt_drift(abstractElement, this); 105 break; 106 case cell : 107 abstractElement_ = new GWt_cell(abstractElement, this); 108 break; 109 case bend : 110 abstractElement_ = new GWt_bend(abstractElement, this); 111 break; 112 case soleno : 113 abstractElement_ = new GWt_soleno(abstractElement, this); 114 break; 115 case beam : 116 abstractElement_ = new GWt_beam(abstractElement, this); 117 break; 118 case fit : 119 abstractElement_ = new GWt_fit(abstractElement, this); 120 break; 121 case inconnu : 122 abstractElement_ = NULL; 123 } 124 if (abstractElement_ != NULL) { 125 dragElementZone_->addWidget(abstractElement_->getImage()); 126 dragElementZone_->setMaximumSize(32,32); 127 dragElementZone_->setMinimumSize(32,32); 128 } 129 } 130 // add second line 141 131 if (abstractElement == NULL) { 142 firstTimeInsertMessage_ = new WText("Drag elements here"); 143 144 WVBoxLayout* fit = new WVBoxLayout(); 145 fit->addWidget(firstTimeInsertMessage_,1,Wt::AlignCenter |Wt::AlignMiddle); 146 dragElementZone_->setLayout(fit); 147 } 132 elementName_ = new WText(); 133 } else { 134 elementName_ = new WText(abstractElement->getLabel()); 135 } 136 137 gridLayout->addWidget (elementName_,1,0,1,3); 138 139 148 140 149 141 // dragElementZone_->addWidget(firstTimeInsertMessage_); … … 163 155 void GWt_elementLigneFaisceau::onClick(GWt_abstractElement* gw) 164 156 { 165 cout << "mouse key was double clicked on this widget " << gw->getWidget()->id()<< endl;166 167 messageDropZone_ = new GWt_dialog("Question","Are you sure you want to delete the selected item?",GWt_dialog::Warning,true,true);168 169 WSignalMapper<GWt_abstractElement *> *MyMap = new WSignalMapper<GWt_abstractElement *>(this);170 MyMap->mapped().connect(this, &GWt_elementLigneFaisceau::removeDone);171 MyMap->mapConnect(messageDropZone_->finished(),gw);172 messageDropZone_->exec();157 cout << "mouse key was double clicked on this widget " << gw->getWidget()->id()<< endl; 158 159 messageDropZone_ = new GWt_dialog("Question","Are you sure you want to delete the selected item?",GWt_dialog::Warning,true,true); 160 161 WSignalMapper<GWt_abstractElement *> *MyMap = new WSignalMapper<GWt_abstractElement *>(this); 162 MyMap->mapped().connect(this, &GWt_elementLigneFaisceau::removeDone); 163 MyMap->mapConnect(messageDropZone_->finished(),gw); 164 messageDropZone_->exec(); 173 165 } 174 166 … … 176 168 void GWt_elementLigneFaisceau::removeDone(GWt_abstractElement* gw) 177 169 { 178 if (messageDropZone_->result() == WDialog::Accepted) {179 // FIXME180 // removeDropZone();181 }170 if (messageDropZone_->result() == WDialog::Accepted) { 171 // FIXME 172 // removeDropZone(); 173 } 182 174 } 183 175 … … 186 178 void GWt_elementLigneFaisceau::removeOtherDropZone(GWt_elementLigneFaisceau* other) 187 179 { 188 // 3 cases : 189 // - first element : remove elem + link after 190 // - last element : remove elem + link before 191 // - middle element : remove elem + link after/before 192 193 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 194 WBoxLayout* layout = ((WBoxLayout*)(wc->layout())); 195 196 #ifdef PSPA_DEBUG 197 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 198 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 199 console->addConsoleMessage("GWt_elementLigneFaisceau::mouseOut"); 200 console->addConsoleMessage("remove from drag Zone"); 201 } 202 cout << "remove from drag Zone id" << layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (other))) << " count:" << layout->count()<< endl; 203 #endif 204 // first element 205 if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (other))) == 1) { 206 if (layout->itemAt (2)) { 207 layout->removeItem (layout->itemAt(2)); 208 #ifdef PSPA_DEBUG 209 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 180 // 3 cases : 181 // - first element : remove elem + link after 182 // - last element : remove elem + link before 183 // - middle element : remove elem + link after/before 184 185 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 186 WBoxLayout* layout = ((WBoxLayout*)(wc->layout())); 187 188 #ifdef PSPA_DEBUG 189 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 210 190 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 211 console->addConsoleMessage(" remove first link "); 212 } 213 #endif 214 } 215 216 // last and middle 191 console->addConsoleMessage("GWt_elementLigneFaisceau::mouseOut"); 192 console->addConsoleMessage("remove from drag Zone"); 193 } 194 cout << "remove from drag Zone id" << layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (other))) << " count:" << layout->count()<< endl; 195 #endif 196 // first element 197 if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (other))) == 1) { 198 if (layout->itemAt (2)) { 199 layout->removeItem (layout->itemAt(2)); 200 #ifdef PSPA_DEBUG 201 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 202 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 203 console->addConsoleMessage(" remove first link "); 204 } 205 #endif 206 } 207 208 // last and middle 217 209 } else if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (other))) == layout->count()-2) { 218 if (layout->itemAt (layout->count()-3)) { 219 layout->removeItem (layout->itemAt(layout->count()-3)); 220 #ifdef PSPA_DEBUG 221 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 222 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 223 console->addConsoleMessage(" remove first link "); 224 } 210 if (layout->itemAt (layout->count()-3)) { 211 layout->removeItem (layout->itemAt(layout->count()-3)); 212 #ifdef PSPA_DEBUG 213 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 214 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 215 console->addConsoleMessage(" remove first link "); 216 } 217 #endif 218 } 219 } 220 221 // remove the drop zone 222 if (layout->findWidgetItem (other)) { 223 layout->removeItem (layout->itemAt(layout->indexOf((WLayoutItem*)(layout->findWidgetItem (other))))); 224 #ifdef PSPA_DEBUG 225 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 226 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 227 console->addConsoleMessage(" remove drop zone "); 228 } 225 229 #endif 226 230 } 227 } 228 229 // remove the drop zone 230 if (layout->findWidgetItem (other)) { 231 layout->removeItem (layout->itemAt(layout->indexOf((WLayoutItem*)(layout->findWidgetItem (other))))); 232 #ifdef PSPA_DEBUG 233 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 234 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 235 console->addConsoleMessage(" remove drop zone "); 236 } 237 #endif 238 } 239 240 231 232 241 233 // FIXME ne pas passer par un label mais par un abstrastElement 242 234 // pspa_->getDataManager()->getCollection()->eraseElement(label); 243 // pspa_->updateSelections();235 // pspa_->updateSelections(); 244 236 } 245 237 246 238 247 239 void GWt_elementLigneFaisceau::addElement(GWt_abstractElement* elem){ 248 249 clear();250 abstractElement_ = elem;251 addWidget(abstractElement_);252 if (static_cast <WContainerWidget*> (parent())) {253 WContainerWidget* wc = static_cast <WContainerWidget*> (parent());254 WBoxLayout* layout = ((WBoxLayout*)(wc->layout()));255 layout->setStretchFactor(this,0);256 }257 258 259 firstTimeInsertMessage_ = NULL;260 arrowImage_ = NULL;240 241 clear(); 242 abstractElement_ = elem; 243 addWidget(abstractElement_); 244 if (static_cast <WContainerWidget*> (parent())) { 245 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 246 WBoxLayout* layout = ((WBoxLayout*)(wc->layout())); 247 layout->setStretchFactor(this,0); 248 } 249 250 251 firstTimeInsertMessage_ = NULL; 252 arrowImage_ = NULL; 261 253 } 262 254 263 255 std::string GWt_elementLigneFaisceau::getElementNumberInBeamLine(nomdElements elem){ 264 string str = ""; 265 266 if (static_cast <WContainerWidget*> (parent())) { 267 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 268 for (int a=0; a<wc->count(); a++) { 269 if (static_cast <GWt_abstractElement*> (wc->widget (a))) { 270 // GWt_abstractElement* ab = static_cast <GWt_abstractElement*> (wc->widget (a)); 271 /* 272 printf("1--->%d\n",ab->getElement()); 273 printf("2--->%d\n",ab->getElement()->getLenghtOfElement()); 274 printf("3--->%d\n",ab->getElement()->getName().getElementType()); 275 printf("4--->%d\n",elem.getElementType()); 276 277 if (static_cast <GWt_abstractElement*> (wc->widget (a))->getElement()->getName().getElementType() == elem.getElementType()) { 278 pspa_->addConsoleMessage("type trouvé"); 256 string str = ""; 257 258 if (static_cast <WContainerWidget*> (parent())) { 259 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 260 for (int a=0; a<wc->count(); a++) { 261 if (static_cast <GWt_abstractElement*> (wc->widget (a))) { 262 // GWt_abstractElement* ab = static_cast <GWt_abstractElement*> (wc->widget (a)); 263 /* 264 printf("1--->%d\n",ab->getElement()); 265 printf("2--->%d\n",ab->getElement()->getLenghtOfElement()); 266 printf("3--->%d\n",ab->getElement()->getName().getElementType()); 267 printf("4--->%d\n",elem.getElementType()); 268 269 if (static_cast <GWt_abstractElement*> (wc->widget (a))->getElement()->getName().getElementType() == elem.getElementType()) { 270 pspa_->addConsoleMessage("type trouvé"); 271 } else { 272 pspa_->addConsoleMessage("type trouvé NOT "); 273 } 274 */ 275 276 } 277 } 278 279 int n = 999999; 280 281 std::stringstream stream; 282 stream << n ; 283 std::string number(stream.str()); 284 285 if(n < 10) { 286 str= elem.getElementLabel()+"0"+number; 279 287 } else { 280 pspa_->addConsoleMessage("type trouvé NOT "); 281 } 282 */ 283 284 } 285 } 286 287 int n = 999999; 288 289 std::stringstream stream; 290 stream << n ; 291 std::string number(stream.str()); 292 293 if(n < 10) { 294 str= elem.getElementLabel()+"0"+number; 295 } else { 296 str= elem.getElementLabel()+number; 297 } 298 } 299 300 return str; 288 str= elem.getElementLabel()+number; 289 } 290 } 291 292 return str; 301 293 } 302 294 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_fit.cc
r266 r272 11 11 GWt_fit::GWt_fit(abstractElement* elem ,GWt_elementLigneFaisceau* elemLigne) : GWt_abstractElement(elem, elemLigne) 12 12 { 13 14 string* param = beginDialog();15 16 new WText(" variable to fit : ",dialog_->contents());17 nameEdit_ = new WComboBox(dialog_->contents());18 nameEdit_->addItem("R11");19 nameEdit_->addItem("R22");20 nameEdit_->addItem("R12");21 nameEdit_->addItem("R21");22 nameEdit_->addItem("??");23 24 string var = *param;25 if ( var == "R11" ) {26 nameEdit_->setCurrentIndex(0);27 }28 else if ( var == "R22" ) {29 nameEdit_->setCurrentIndex(1);30 }31 else if ( var == "R12" ) {32 nameEdit_->setCurrentIndex(2);33 }34 else if ( var == "R21" ) {35 nameEdit_->setCurrentIndex(3);36 }37 else {38 nameEdit_->setCurrentIndex(4);39 }40 new WText(" value : ",dialog_->contents());41 valueEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());42 new WText(" tolerance : ",dialog_->contents());43 tolerEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());44 new WBreak(dialog_->contents());45 WPushButton *submit = new WPushButton("OK",dialog_->contents());46 submit->clicked().connect(dialog_, &Wt::WDialog::accept);47 dialog_->finished().connect(this, &GWt_fit::dialogDone);48 49 // make image50 image_ = new WImage("htdocs/fit.jpg",this);51 13 14 string* param = beginDialog(); 15 16 new WText(" variable to fit : ",dialog_->contents()); 17 nameEdit_ = new WComboBox(dialog_->contents()); 18 nameEdit_->addItem("R11"); 19 nameEdit_->addItem("R22"); 20 nameEdit_->addItem("R12"); 21 nameEdit_->addItem("R21"); 22 nameEdit_->addItem("??"); 23 24 string var = *param; 25 if ( var == "R11" ) { 26 nameEdit_->setCurrentIndex(0); 27 } 28 else if ( var == "R22" ) { 29 nameEdit_->setCurrentIndex(1); 30 } 31 else if ( var == "R12" ) { 32 nameEdit_->setCurrentIndex(2); 33 } 34 else if ( var == "R21" ) { 35 nameEdit_->setCurrentIndex(3); 36 } 37 else { 38 nameEdit_->setCurrentIndex(4); 39 } 40 new WText(" value : ",dialog_->contents()); 41 valueEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 42 new WText(" tolerance : ",dialog_->contents()); 43 tolerEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 44 new WBreak(dialog_->contents()); 45 WPushButton *submit = new WPushButton("OK",dialog_->contents()); 46 submit->clicked().connect(dialog_, &Wt::WDialog::accept); 47 dialog_->finished().connect(this, &GWt_fit::dialogDone); 48 49 // make image 50 image_ = new WImage("htdocs/fit.jpg",this); 51 52 52 // activate slots 53 53 image_->clicked().connect(this,&GWt_abstractElement::clicked); 54 54 55 55 } 56 56 57 57 void GWt_fit::dialogDone() 58 58 { 59 unsigned nbParam = abstractElement_->getNbParams();60 string* envoi = new string[nbParam+1];61 int compteur = -1;62 envoi[++compteur] = string(mixedTools::intToString(nbParam) );63 64 envoi[++compteur] = labelEdit_->text().toUTF8();65 66 string variableString = nameEdit_->currentText().toUTF8();67 cout << " GWt_fit::dialogDone() variable a fitter : " << variableString << endl;68 envoi[++compteur] = variableString;69 envoi[++compteur] = valueEdit_->text().toUTF8();70 envoi[++compteur] = tolerEdit_->text().toUTF8();71 if ( compteur != (int)nbParam ) {72 cerr << " GWt_fit::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl;73 return;74 }75 abstractElement_->setParametersString(envoi);76 updateLabelWidget();77 delete [] envoi;59 unsigned nbParam = abstractElement_->getNbParams(); 60 string* envoi = new string[nbParam+1]; 61 int compteur = -1; 62 envoi[++compteur] = string(mixedTools::intToString(nbParam) ); 63 64 envoi[++compteur] = labelEdit_->text().toUTF8(); 65 66 string variableString = nameEdit_->currentText().toUTF8(); 67 cout << " GWt_fit::dialogDone() variable a fitter : " << variableString << endl; 68 envoi[++compteur] = variableString; 69 envoi[++compteur] = valueEdit_->text().toUTF8(); 70 envoi[++compteur] = tolerEdit_->text().toUTF8(); 71 if ( compteur != (int)nbParam ) { 72 cerr << " GWt_fit::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; 73 return; 74 } 75 abstractElement_->setParametersString(envoi); 76 updateLabelWidget(); 77 delete [] envoi; 78 78 } 79 79 80 80 81 81 WImage* GWt_fit::getImage() { 82 return image_;82 return image_; 83 83 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_globalParameters.cc
r257 r272 13 13 14 14 15 GWt_globalParameters::GWt_globalParameters(PspaApplication* ps) 16 17 18 15 GWt_globalParameters::GWt_globalParameters(PspaApplication* ps) 16 { 17 18 pspa_ = ps; 19 19 WVBoxLayout* globLayout = new WVBoxLayout(); 20 20 decorationStyle().setBackgroundColor (WColor("blue")); 21 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 21 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 22 22 WContainerWidget *result = new WContainerWidget(); 23 23 WPanel *panel = new WPanel(result); 24 24 panel->setTitle(" global parameters "); 25 26 25 26 27 27 WText* freqText = new WText("frequency (MHz) : "); 28 28 frequencyEdit_ = new WLineEdit(); 29 29 30 30 WText *stepText = new WText("step in phase (deg.) : "); 31 31 stepEdit_ = new WLineEdit(); 32 32 33 33 WText *nstepMaxText = new WText("max step number : "); 34 34 nstepMAxEdit_ = new WLineEdit(); 35 35 36 36 WText *nscText = new WText("periodicity of s.c. computation : "); 37 37 nscEdit_ = new WLineEdit(); 38 39 40 38 39 40 41 41 WContainerWidget* contenu = new WContainerWidget(); 42 42 contenu->addWidget(freqText); … … 51 51 contenu->addWidget(nscText); 52 52 contenu->addWidget(nscEdit_); 53 54 55 53 54 55 56 56 panel->setCentralWidget(contenu); 57 57 // panel->setCollapsible(true); 58 59 58 59 60 60 // WPanel *panelModules = new WPanel(result); 61 61 // panelModules->setTitle(" sections of beam Line for executing softwres "); 62 63 62 63 64 64 // WPushButton* push_add = new WPushButton("add"); 65 66 65 66 67 67 // contenuSections_ = new WContainerWidget(); 68 68 69 69 // addSection(); 70 70 // contenuSections_->addWidget( push_add); 71 72 71 72 73 73 // panelModules->setCentralWidget(contenuSections_); 74 75 74 75 76 76 globLayout->addWidget(result); 77 77 78 78 setLayout(globLayout); 79 80 79 renew(); 80 } 81 81 82 82 // void GWt_globalParameters::addSection() … … 105 105 void GWt_globalParameters::renew() 106 106 { 107 string* param = pspa_->getDataManager()->getGlobalParameters()->getParametersString();108 if ( param == NULL )107 string* param = pspa_->getDataManager()->getGlobalParameters()->getParametersString(); 108 if ( param == NULL ) 109 109 { 110 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {111 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));112 console->addConsoleMessage(" GWt_globalParameters : empty parameter set");113 }110 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 111 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 112 console->addConsoleMessage(" GWt_globalParameters : empty parameter set"); 113 } 114 114 } 115 int nbparam = atoi(param[0].c_str());116 if ( nbparam != 4 )115 int nbparam = atoi(param[0].c_str()); 116 if ( nbparam != 4 ) 117 117 { 118 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {119 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));120 console->addConsoleMessage(" GWt_globalParameters : wrong number of parameters");121 }118 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 119 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 120 console->addConsoleMessage(" GWt_globalParameters : wrong number of parameters"); 121 } 122 122 } 123 frequencyEdit_->setText(param[1].c_str());124 stepEdit_->setText(param[2].c_str());125 nstepMAxEdit_->setText(param[3].c_str());126 nscEdit_->setText(param[4].c_str());123 frequencyEdit_->setText(param[1].c_str()); 124 stepEdit_->setText(param[2].c_str()); 125 nstepMAxEdit_->setText(param[3].c_str()); 126 nscEdit_->setText(param[4].c_str()); 127 127 } 128 128 129 129 void GWt_globalParameters::updateGlobals() 130 130 { 131 131 string envoi[5]; 132 132 envoi[0] = string("4"); … … 136 136 envoi[4] = nscEdit_->text().toUTF8(); 137 137 pspa_->getDataManager()->getGlobalParameters()->setParametersString(envoi); 138 138 } 139 139 140 140 // void GWt_globalParameters::getExecute(unsigned index, unsigned& first, unsigned& last, int& programm) … … 142 142 // string debut; 143 143 // string fin; 144 // if ( index == 1) 144 // if ( index == 1) 145 145 // { 146 146 // debut = origineEdit1_->text().toUTF8(); … … 155 155 // } 156 156 // first = atoi ( debut.c_str() ); 157 // last = atoi ( fin.c_str() ); 157 // last = atoi ( fin.c_str() ); 158 158 // programm++; 159 159 160 160 // } 161 161 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc
r271 r272 16 16 17 17 GWt_LigneFaisceau::GWt_LigneFaisceau(PspaApplication* ps) : 18 19 20 18 WContainerWidget(), 19 pspa_(ps), 20 nObjets_(NULL) 21 21 { 22 23 cout<<"GWt_LigneFaisceau::GWt_LigneFaisceau() %d"<< this << "<---------------"<< endl;24 25 ligneFaisceauLayout_ = new WHBoxLayout();26 // decorationStyle().setBackgroundColor (WColor(245,245,245));27 setLayout(ligneFaisceauLayout_);22 23 cout<<"GWt_LigneFaisceau::GWt_LigneFaisceau() %d"<< this << "<---------------"<< endl; 24 25 ligneFaisceauLayout_ = new WHBoxLayout(); 26 // decorationStyle().setBackgroundColor (WColor(245,245,245)); 27 setLayout(ligneFaisceauLayout_); 28 28 ligneFaisceauLayout_->setContentsMargins(0,0,0,0); 29 29 ligneFaisceauLayout_->setSpacing (0); 30 31 int nElts= nomdElements::getNumberOfElements(); 32 nObjets_= new Compteur[nElts]; 33 34 // set the object name 35 setObjectName("ligneFaisceau"); 36 37 // add the first drop zone 38 addElement(inconnu); 30 31 int nElts= nomdElements::getNumberOfElements(); 32 nObjets_= new Compteur[nElts]; 33 34 // set the object name 35 setObjectName("ligneFaisceau"); 36 37 // add the first drop zone 38 decorationStyle().setBorder (WBorder (WBorder::Dotted)); 39 GWt_dropZoneLigneFaisceau* allDropZone= new GWt_dropZoneLigneFaisceau(); 40 WVBoxLayout* fit = new WVBoxLayout(); 41 allDropZone->setLayout(fit); 42 43 fit->addWidget(new WText("Drag elements here...."),1,Wt::AlignCenter |Wt::AlignMiddle); 44 45 46 47 // GWt_dropZoneLigneFaisceau* allDropZone= new GWt_dropZoneLigneFaisceau(); 48 ligneFaisceauLayout_->addWidget(allDropZone,1); 49 // addElement(inconnu); 50 39 51 // add a last element to push everything 40 ligneFaisceauLayout_->addWidget(new WText("") , 1,Wt::AlignMiddle); 52 // ligneFaisceauLayout_->addWidget(new WText("") , 1,Wt::AlignMiddle); 53 54 55 // add a strech element at the end 56 // ligneFaisceauLayout_->addStretch(1); 57 } 41 58 42 59 43 // add a strech element at the end44 // ligneFaisceauLayout_->addStretch(1);45 }46 47 60 48 49 61 void GWt_LigneFaisceau::restoreElementCollection() 50 62 { 51 52 cout<<"GWt_LigneFaisceau::restoreElementCollection()"<<endl;53 54 ligneFaisceauLayout_->clear();55 56 delete[] nObjets_;57 int nElements= nomdElements ::getNumberOfElements();58 nObjets_= new Compteur[nElements];59 60 int nbElem = pspa_->getDataManager()->beamLineSize();61 unsigned int k;62 63 // add first dropZone64 ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaisceau());65 66 for(k = 0; k < (unsigned)nbElem; k++)63 64 cout<<"GWt_LigneFaisceau::restoreElementCollection()"<<endl; 65 66 ligneFaisceauLayout_->clear(); 67 68 delete[] nObjets_; 69 int nElements= nomdElements ::getNumberOfElements(); 70 nObjets_= new Compteur[nElements]; 71 72 int nbElem = pspa_->getDataManager()->beamLineSize(); 73 unsigned int k; 74 75 // add first dropZone 76 ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaisceau()); 77 78 for(k = 0; k < (unsigned)nbElem; k++) 67 79 { 68 abstractElement* ptr = pspa_->getDataManager()->getCollection()->getElementPointerFromIndex(k);69 /* GWt_abstractElement* gw = GWt_abstractElement::ajoute(ptr);70 if(gw == NULL) {71 72 }73 gw->setLabelWidget();74 */75 nObjets_[ptr->getNomdElement().getElementType()].incr();76 GWt_elementLigneFaisceau* dropZone = new GWt_elementLigneFaisceau(ptr);77 80 abstractElement* ptr = pspa_->getDataManager()->getCollection()->getElementPointerFromIndex(k); 81 /* GWt_abstractElement* gw = GWt_abstractElement::ajoute(ptr); 82 if(gw == NULL) { 83 cerr << "GWt_LigneFaisceau::restaure element type " << ptr->getNomdElement().getElementName() << " est inconnu " << endl; 84 } 85 gw->setLabelWidget(); 86 */ 87 nObjets_[ptr->getNomdElement().getElementType()].incr(); 88 GWt_elementLigneFaisceau* dropZone = new GWt_elementLigneFaisceau(ptr); 89 78 90 /* dropZone->addElement(gw->getWidget()); 79 */91 */ 80 92 ligneFaisceauLayout_->addWidget(dropZone,0); 81 82 93 83 /* if (k < ((unsigned)nbElem-1)) { 84 ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau()); 85 } else { 86 ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau()); 87 } 88 */ 94 95 /* if (k < ((unsigned)nbElem-1)) { 96 ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau()); 97 } else { 98 ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau()); 99 } 100 */ 89 101 } 90 91 pspa_->updateSelections();102 103 pspa_->updateSelections(); 92 104 } 93 105 … … 99 111 ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaisceau()); 100 112 } else { 101 abstractElement* ptr = pspa_->getDataManager()->addElement(eType);102 103 //if(eType == inconnu) {104 //cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl;105 //return;106 //}107 108 109 // ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau(ptr),0);110 ligneFaisceauLayout_->insertWidget(ligneFaisceauLayout_->count()-1,new GWt_elementLigneFaisceau(ptr),0);113 abstractElement* ptr = pspa_->getDataManager()->addElement(eType); 114 115 if(eType == inconnu) { 116 cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl; 117 return; 118 } 119 120 121 // ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau(ptr),0); 122 ligneFaisceauLayout_->insertWidget(ligneFaisceauLayout_->count()-1,new GWt_elementLigneFaisceau(ptr),0); 111 123 } 112 124 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r271 r272 40 40 * constructor so it is typically also an argument for your custom 41 41 * application constructor. 42 */42 */ 43 43 44 44 PspaApplication::PspaApplication(const WEnvironment& env) : WApplication(env) 45 45 { 46 47 workingDir_ = WApplication::docRoot()+ "/"+WORKINGAREA;48 nameOfCase_ = "pspa"; // default49 50 setTitle("portail PSPA"); // application title51 if (!wApp->environment().javaScript()) {52 new WText("<i>This examples requires that javascript support is enabled.</i>",root());53 }54 55 // include the styleSheet56 WContainerWidget *widroot = root();57 useStyleSheet ("htdocs/pspa.css");58 dtmanage_ = new dataManager();59 60 /*61 * The main layout is a 3x2 grid layout.62 */63 WGridLayout *layout = new WGridLayout();64 // layout->addWidget(createTitle("<a href='workingArea/parmin'> Menu (In future)</a>"), 0, 0, 1, 2);65 // layout->addWidget(createTitle("Menu (In future)"), 0, 0, 1, 2);66 67 WHBoxLayout *toolbarLayout = new WHBoxLayout();68 69 WPushButton* boutonSauve = new WPushButton();70 WPushButton* boutonRestaure = new WPushButton();71 WPushButton* boutonLoadNew = new WPushButton();72 WPushButton* boutongraphicalAnalysis = new WPushButton();73 74 boutonSauve->setStyleClass("saveButton");75 boutonRestaure->setStyleClass("restoreButton");76 boutonLoadNew->setStyleClass("loadNewButton");77 boutongraphicalAnalysis->setStyleClass("histoButton");78 79 boutonSauve->setToolTip ("sauvegarder la config");80 boutonRestaure->setToolTip (" restaurer la config");81 boutonLoadNew->setToolTip ("upload config");82 boutongraphicalAnalysis->setToolTip ("analyse graphique");83 84 boutonSauve->setMaximumSize(38,38);85 boutonSauve->setMinimumSize(38,38);86 boutonRestaure->setMaximumSize(38,38);87 boutonRestaure->setMinimumSize(38,38);88 boutonLoadNew->setMaximumSize(38,38);89 boutonLoadNew->setMinimumSize(38,38);90 boutongraphicalAnalysis->setMaximumSize(38,38);91 boutongraphicalAnalysis->setMinimumSize(38,38);92 93 boutonSauve->clicked().connect(this, &PspaApplication::sauver);94 boutonRestaure->clicked().connect(this, &PspaApplication::restaurer);95 // Upload when the button is clicked.96 // React to a succesfull upload.97 boutonLoadNew->clicked().connect(this, &PspaApplication::openFileSelector);98 99 boutongraphicalAnalysis->clicked().connect(this, &PspaApplication::dialogOnGraphics);100 101 102 toolbarLayout->addWidget(boutonSauve , 0,Wt::AlignMiddle);103 toolbarLayout->addWidget(boutonRestaure , 0,Wt::AlignMiddle);104 toolbarLayout->addWidget(boutonLoadNew , 0,Wt::AlignMiddle);105 toolbarLayout->addWidget(boutongraphicalAnalysis , 0,Wt::AlignMiddle);106 toolbarLayout->addWidget(new WText("") , 1,Wt::AlignMiddle);107 108 WContainerWidget * layoutContainer = new WContainerWidget();109 layoutContainer->setLayout(toolbarLayout);110 layoutContainer->decorationStyle().setBackgroundImage ("/htdocs/fond_toolbar.png");111 layout->addWidget(layoutContainer, 1, 0, 1, 2);112 layout->addWidget(createPalette(), 2, 0, 4, 1);113 114 beamLine_ = createBeamLine();115 WScrollArea* scroll = new WScrollArea();116 scroll->setWidget(beamLine_);117 layout->addWidget(scroll, 2, 1, 1, 1);118 119 120 // console_ = new WContainerWidget();121 // console_->decorationStyle().setBackgroundColor (WColor("lightgray"));122 // console_->setMaximumSize(600,200);123 // layout->addWidget(console_, 3, 1);124 // console_->setMinimumSize(300,100);125 // console_->setOverflow(WContainerWidget::OverflowAuto);126 127 128 console_ = new GWt_console();129 console_->clear();130 console_->decorationStyle().setBackgroundColor (WColor("lightgray"));131 console_->setMaximumSize(600,200);132 console_->setMinimumSize(300,100);133 console_->setOverflow(WContainerWidget::OverflowAuto);134 layout->addWidget(console_, 3, 2);135 136 137 138 139 140 //-----------141 // A supprimer et a mettre en fenetre142 globalParam_ = createGlobalParamWidget();143 // leDessin_ = new WContainerWidget();144 // leDessin_ = createDrawingWidget();145 graphicsDialog_ = new GWt_dialog("graphical analysis",createDrawingWidget(),false);146 graphicsDialog_->setMinimumSize(400,400);147 graphicsDialog_->setClosable(true);148 149 150 151 WWidget* executeWidget = createExecuteWidget();152 153 layout->addWidget( globalParam_, 3, 1);154 // layout->addWidget( leDessin_, 3, 2);155 layout->addWidget( executeWidget , 4, 1);156 //-----------157 158 159 160 layout->setColumnResizable(1);161 layout->setRowResizable(2);162 /*163 * Let row 2 and column 1 take the excess space.164 */165 layout->setRowStretch(2, 1);166 layout->setColumnStretch(1, 1);167 168 widroot->setLayout(layout);46 47 workingDir_ = WApplication::docRoot()+ "/"+WORKINGAREA; 48 nameOfCase_ = "pspa"; // default 49 50 setTitle("portail PSPA"); // application title 51 if (!wApp->environment().javaScript()) { 52 new WText("<i>This examples requires that javascript support is enabled.</i>",root()); 53 } 54 55 // include the styleSheet 56 WContainerWidget *widroot = root(); 57 useStyleSheet ("htdocs/pspa.css"); 58 dtmanage_ = new dataManager(); 59 60 /* 61 * The main layout is a 3x2 grid layout. 62 */ 63 WGridLayout *layout = new WGridLayout(); 64 // layout->addWidget(createTitle("<a href='workingArea/parmin'> Menu (In future)</a>"), 0, 0, 1, 2); 65 // layout->addWidget(createTitle("Menu (In future)"), 0, 0, 1, 2); 66 67 WHBoxLayout *toolbarLayout = new WHBoxLayout(); 68 69 WPushButton* boutonSauve = new WPushButton(); 70 WPushButton* boutonRestaure = new WPushButton(); 71 WPushButton* boutonLoadNew = new WPushButton(); 72 WPushButton* boutongraphicalAnalysis = new WPushButton(); 73 74 boutonSauve->setStyleClass("saveButton"); 75 boutonRestaure->setStyleClass("restoreButton"); 76 boutonLoadNew->setStyleClass("loadNewButton"); 77 boutongraphicalAnalysis->setStyleClass("histoButton"); 78 79 boutonSauve->setToolTip ("sauvegarder la config"); 80 boutonRestaure->setToolTip (" restaurer la config"); 81 boutonLoadNew->setToolTip ("upload config"); 82 boutongraphicalAnalysis->setToolTip ("analyse graphique"); 83 84 boutonSauve->setMaximumSize(38,38); 85 boutonSauve->setMinimumSize(38,38); 86 boutonRestaure->setMaximumSize(38,38); 87 boutonRestaure->setMinimumSize(38,38); 88 boutonLoadNew->setMaximumSize(38,38); 89 boutonLoadNew->setMinimumSize(38,38); 90 boutongraphicalAnalysis->setMaximumSize(38,38); 91 boutongraphicalAnalysis->setMinimumSize(38,38); 92 93 boutonSauve->clicked().connect(this, &PspaApplication::sauver); 94 boutonRestaure->clicked().connect(this, &PspaApplication::restaurer); 95 // Upload when the button is clicked. 96 // React to a succesfull upload. 97 boutonLoadNew->clicked().connect(this, &PspaApplication::openFileSelector); 98 99 boutongraphicalAnalysis->clicked().connect(this, &PspaApplication::dialogOnGraphics); 100 101 102 toolbarLayout->addWidget(boutonSauve , 0,Wt::AlignMiddle); 103 toolbarLayout->addWidget(boutonRestaure , 0,Wt::AlignMiddle); 104 toolbarLayout->addWidget(boutonLoadNew , 0,Wt::AlignMiddle); 105 toolbarLayout->addWidget(boutongraphicalAnalysis , 0,Wt::AlignMiddle); 106 toolbarLayout->addWidget(new WText("") , 1,Wt::AlignMiddle); 107 108 WContainerWidget * layoutContainer = new WContainerWidget(); 109 layoutContainer->setLayout(toolbarLayout); 110 layoutContainer->decorationStyle().setBackgroundImage ("/htdocs/fond_toolbar.png"); 111 layout->addWidget(layoutContainer, 1, 0, 1, 2); 112 layout->addWidget(createPalette(), 2, 0, 4, 1); 113 114 beamLine_ = createBeamLine(); 115 WScrollArea* scroll = new WScrollArea(); 116 scroll->setWidget(beamLine_); 117 layout->addWidget(scroll, 2, 1, 1, 1); 118 119 120 // console_ = new WContainerWidget(); 121 // console_->decorationStyle().setBackgroundColor (WColor("lightgray")); 122 // console_->setMaximumSize(600,200); 123 // layout->addWidget(console_, 3, 1); 124 // console_->setMinimumSize(300,100); 125 // console_->setOverflow(WContainerWidget::OverflowAuto); 126 127 128 console_ = new GWt_console(); 129 console_->clear(); 130 console_->decorationStyle().setBackgroundColor (WColor("lightgray")); 131 console_->setMaximumSize(600,200); 132 console_->setMinimumSize(300,100); 133 console_->setOverflow(WContainerWidget::OverflowAuto); 134 layout->addWidget(console_, 3, 2); 135 136 137 138 139 140 //----------- 141 // A supprimer et a mettre en fenetre 142 globalParam_ = createGlobalParamWidget(); 143 // leDessin_ = new WContainerWidget(); 144 // leDessin_ = createDrawingWidget(); 145 graphicsDialog_ = new GWt_dialog("graphical analysis",createDrawingWidget(),false); 146 graphicsDialog_->setMinimumSize(400,400); 147 graphicsDialog_->setClosable(true); 148 149 150 151 WWidget* executeWidget = createExecuteWidget(); 152 153 layout->addWidget( globalParam_, 3, 1); 154 // layout->addWidget( leDessin_, 3, 2); 155 layout->addWidget( executeWidget , 4, 1); 156 //----------- 157 158 159 160 layout->setColumnResizable(1); 161 layout->setRowResizable(2); 162 /* 163 * Let row 2 and column 1 take the excess space. 164 */ 165 layout->setRowStretch(2, 1); 166 layout->setColumnStretch(1, 1); 167 168 widroot->setLayout(layout); 169 169 } 170 170 171 171 WWidget* PspaApplication::createPalette() 172 172 { 173 WContainerWidget* palette=new WContainerWidget(); 174 // palette->setLayout(new WVBoxLayout()); 175 176 // nomdElements *e= new nomdElements(); 177 // int nElts= e->getNumberOfElements(); 178 // delete e; 179 // nomdElements bidon; 180 181 // FIXME a reprendre avec un patern 182 createDragImage("htdocs/beam.jpg","htdocs/beam.jpg","htdocs/beam.jpg",palette,"beam"); 183 new WBreak(palette); 184 createDragImage("htdocs/rfgun.jpg","htdocs/rfgun.jpg","htdocs/rfgun.jpg",palette,"rfgun"); 185 new WBreak(palette); 186 createDragImage("htdocs/drift.jpg","htdocs/drift.jpg","htdocs/drift.jpg",palette,"drift"); 187 new WBreak(palette); 188 createDragImage("htdocs/cell.jpg","htdocs/cell.jpg","htdocs/cell.jpg",palette,"cell"); 189 new WBreak(palette); 190 createDragImage("htdocs/bend.jpg","htdocs/bend.jpg","htdocs/bend.jpg",palette,"bend"); 191 new WBreak(palette); 192 createDragImage("htdocs/soleno.jpg","htdocs/soleno.jpg","htdocs/soleno.jpg",palette,"soleno"); 193 new WBreak(palette); 194 createDragImage("htdocs/fit.jpg","htdocs/fit.jpg","htdocs/fit.jpg",palette,"fit"); 195 new WBreak(palette); 196 197 198 // palette->setMinimumSize(100,300); 199 return palette; 173 WContainerWidget* palette=new WContainerWidget(); 174 // palette->setLayout(new WVBoxLayout()); 175 176 // nomdElements *e= new nomdElements(); 177 // int nElts= e->getNumberOfElements(); 178 // delete e; 179 // nomdElements bidon; 180 181 // FIXME a reprendre avec un patern 182 createDragImage("htdocs/beam.jpg","htdocs/beam.jpg","htdocs/beam.jpg",palette,"beam"); 183 new WBreak(palette); 184 createDragImage("htdocs/rfgun.jpg","htdocs/rfgun.jpg","htdocs/rfgun.jpg",palette,"rfgun"); 185 new WBreak(palette); 186 createDragImage("htdocs/drift.jpg","htdocs/drift.jpg","htdocs/drift.jpg",palette,"drift"); 187 new WBreak(palette); 188 createDragImage("htdocs/cell.jpg","htdocs/cell.jpg","htdocs/cell.jpg",palette,"cell"); 189 new WBreak(palette); 190 createDragImage("htdocs/bend.jpg","htdocs/bend.jpg","htdocs/bend.jpg",palette,"bend"); 191 new WBreak(palette); 192 createDragImage("htdocs/soleno.jpg","htdocs/soleno.jpg","htdocs/soleno.jpg",palette,"soleno"); 193 new WBreak(palette); 194 createDragImage("htdocs/fit.jpg","htdocs/fit.jpg","htdocs/fit.jpg",palette,"fit"); 195 new WBreak(palette); 196 197 198 // palette->setMinimumSize(100,300); 199 return palette; 200 200 201 } 201 202 202 203 void PspaApplication::createDragImage(const char *url,const char *smallurl,const char *mimeType,WContainerWidget *p,WString name) 203 204 { 204 GWt_draggableImage *result = new GWt_draggableImage(url,p);205 WImage *dragImage = new WImage(smallurl,p);206 207 /*208 * Set the image to be draggable, showing the other image (dragImage)209 * to be used as the widget that is visually dragged.210 */211 cout << "createDragImage" << dragImage<<endl;212 result->setDraggable(mimeType,dragImage,true);213 205 GWt_draggableImage *result = new GWt_draggableImage(url,p); 206 WImage *dragImage = new WImage(smallurl,p); 207 208 /* 209 * Set the image to be draggable, showing the other image (dragImage) 210 * to be used as the widget that is visually dragged. 211 */ 212 cout << "createDragImage" << dragImage<<endl; 213 result->setDraggable(mimeType,dragImage,true); 214 214 215 } 215 216 216 217 WWidget* PspaApplication::createBeamLine() 217 218 { 218 WContainerWidget* beamLine = new GWt_LigneFaisceau(this);219 beamLine->setMinimumSize(300,100);220 return beamLine;219 WContainerWidget* beamLine = new GWt_LigneFaisceau(this); 220 beamLine->setMinimumSize(300,100); 221 return beamLine; 221 222 } 222 223 223 224 WWidget* PspaApplication::createGlobalParamWidget() 224 225 { 225 WContainerWidget* globalParam = new GWt_globalParameters(this);226 globalParam->setMaximumSize(600,150);227 globalParam->setMinimumSize(600,150);228 return globalParam;226 WContainerWidget* globalParam = new GWt_globalParameters(this); 227 globalParam->setMaximumSize(600,150); 228 globalParam->setMinimumSize(600,150); 229 return globalParam; 229 230 } 230 231 231 232 WWidget* PspaApplication::createExecuteWidget() 232 233 { 233 234 WContainerWidget* executeW = new WContainerWidget();235 executeW->setMaximumSize(600,150);236 executeW->setMinimumSize(600,150);237 238 // bouton execute239 exec_go_ = new WPushButton("execute!");240 // exec_go_->setMinimumSize(300,300);241 exec_go_->setDisabled(true);242 exec_go_->clicked().connect(this, &PspaApplication::executer);243 244 // preparation du bouton add245 WPushButton* exec_add = new WPushButton("add");246 exec_add->clicked().connect(this, &PspaApplication::addSectionToExecuteW);247 248 // preparation du bouton delete249 WPushButton* exec_delete = new WPushButton("delete");250 exec_delete->clicked().connect(this, &PspaApplication::deleteSectionToExecuteW);251 252 // preparation du bouton push_ok253 WPushButton* exec_ok = new WPushButton("check/ok");254 exec_ok->clicked().connect(this, &PspaApplication::checkSectionSelection);255 256 // le panel257 WPanel *panelLogiciels = new WPanel(executeW);258 panelLogiciels->setTitle(" sections of beam Line for executing softwares ");259 260 contenuSections_ = new WContainerWidget();261 contenuSections_->addWidget(exec_add);262 contenuSections_->addWidget(exec_delete);263 contenuSections_->addWidget(exec_ok);264 contenuSections_->addWidget(exec_go_);265 contenuSections_->addWidget(new WBreak());266 contenuSections_->addWidget(new WBreak());267 addSectionToExecuteW();268 269 panelLogiciels->setCentralWidget(contenuSections_);270 return executeW;234 235 WContainerWidget* executeW = new WContainerWidget(); 236 executeW->setMaximumSize(600,150); 237 executeW->setMinimumSize(600,150); 238 239 // bouton execute 240 exec_go_ = new WPushButton("execute!"); 241 // exec_go_->setMinimumSize(300,300); 242 exec_go_->setDisabled(true); 243 exec_go_->clicked().connect(this, &PspaApplication::executer); 244 245 // preparation du bouton add 246 WPushButton* exec_add = new WPushButton("add"); 247 exec_add->clicked().connect(this, &PspaApplication::addSectionToExecuteW); 248 249 // preparation du bouton delete 250 WPushButton* exec_delete = new WPushButton("delete"); 251 exec_delete->clicked().connect(this, &PspaApplication::deleteSectionToExecuteW); 252 253 // preparation du bouton push_ok 254 WPushButton* exec_ok = new WPushButton("check/ok"); 255 exec_ok->clicked().connect(this, &PspaApplication::checkSectionSelection); 256 257 // le panel 258 WPanel *panelLogiciels = new WPanel(executeW); 259 panelLogiciels->setTitle(" sections of beam Line for executing softwares "); 260 261 contenuSections_ = new WContainerWidget(); 262 contenuSections_->addWidget(exec_add); 263 contenuSections_->addWidget(exec_delete); 264 contenuSections_->addWidget(exec_ok); 265 contenuSections_->addWidget(exec_go_); 266 contenuSections_->addWidget(new WBreak()); 267 contenuSections_->addWidget(new WBreak()); 268 addSectionToExecuteW(); 269 270 panelLogiciels->setCentralWidget(contenuSections_); 271 return executeW; 271 272 } 272 273 273 274 void PspaApplication::dialogOnGraphics() 274 275 { 275 // GWt_dialog* graphicsDialog = new GWt_dialog("graphical analysis",createDrawingWidget(),false);276 // graphicsDialog->setMinimumSize(400,400);277 // graphicsDialog->setClosable(true);278 279 276 // GWt_dialog* graphicsDialog = new GWt_dialog("graphical analysis",createDrawingWidget(),false); 277 // graphicsDialog->setMinimumSize(400,400); 278 // graphicsDialog->setClosable(true); 279 280 280 281 graphicsDialog_->show(); 281 282 282 283 } 283 284 284 285 WContainerWidget* PspaApplication::createDrawingWidget() 285 286 { 286 WContainerWidget* dessin = new WContainerWidget();287 288 289 290 291 choixEnveloppeDessin_ = new WComboBox();292 choixEnveloppeDessin_->addItem("x");293 // choixEnveloppeDessin_->addItem("y");294 WPushButton* okEnv = new WPushButton("draw enveloppe");295 okEnv->clicked().connect(this, &PspaApplication::dessinerEnveloppe);296 297 298 dessin->addWidget(new WText(" enveloppe : "));299 dessin->addWidget(choixEnveloppeDessin_);300 dessin->addWidget(okEnv);301 302 dessin->addWidget(new WBreak());303 304 choixElementDessin_ = new WComboBox();305 306 307 308 choixTypeDessinFaisceau_ = new WComboBox();309 choixTypeDessinFaisceau_->addItem("courant_snyder");310 choixTypeDessinFaisceau_->addItem("macroparticles");311 WPushButton* caroule = new WPushButton("dessiner");312 caroule->clicked().connect(this, &PspaApplication::dessiner);313 314 dessin->addWidget(new WText(" phase space after element : "));315 dessin->addWidget(choixElementDessin_);316 dessin->addWidget(choixTypeDessinFaisceau_);317 dessin->addWidget(caroule);318 dessin->addWidget(new WBreak());319 320 321 322 323 /////////////////////////////////////////////////////////////////////324 dessin->addWidget(new WText(" histogramme : "));325 WPushButton* okHisto = new WPushButton("histogramme");326 dessin->addWidget(okHisto);327 okHisto->clicked().connect(this,&PspaApplication::dessinerHistogramme);328 /////////////////////////////////////////////////////////////////////329 330 toto_ = new WContainerWidget();331 dessin->addWidget(toto_);332 return dessin;287 WContainerWidget* dessin = new WContainerWidget(); 288 289 290 291 292 choixEnveloppeDessin_ = new WComboBox(); 293 choixEnveloppeDessin_->addItem("x"); 294 // choixEnveloppeDessin_->addItem("y"); 295 WPushButton* okEnv = new WPushButton("draw enveloppe"); 296 okEnv->clicked().connect(this, &PspaApplication::dessinerEnveloppe); 297 298 299 dessin->addWidget(new WText(" enveloppe : ")); 300 dessin->addWidget(choixEnveloppeDessin_); 301 dessin->addWidget(okEnv); 302 303 dessin->addWidget(new WBreak()); 304 305 choixElementDessin_ = new WComboBox(); 306 307 308 309 choixTypeDessinFaisceau_ = new WComboBox(); 310 choixTypeDessinFaisceau_->addItem("courant_snyder"); 311 choixTypeDessinFaisceau_->addItem("macroparticles"); 312 WPushButton* caroule = new WPushButton("dessiner"); 313 caroule->clicked().connect(this, &PspaApplication::dessiner); 314 315 dessin->addWidget(new WText(" phase space after element : ")); 316 dessin->addWidget(choixElementDessin_); 317 dessin->addWidget(choixTypeDessinFaisceau_); 318 dessin->addWidget(caroule); 319 dessin->addWidget(new WBreak()); 320 321 322 323 324 ///////////////////////////////////////////////////////////////////// 325 dessin->addWidget(new WText(" histogramme : ")); 326 WPushButton* okHisto = new WPushButton("histogramme"); 327 dessin->addWidget(okHisto); 328 okHisto->clicked().connect(this,&PspaApplication::dessinerHistogramme); 329 ///////////////////////////////////////////////////////////////////// 330 331 toto_ = new WContainerWidget(); 332 dessin->addWidget(toto_); 333 return dessin; 333 334 } 334 335 335 336 void PspaApplication::addSectionToExecuteW() 336 337 { 337 338 disableSectionExecute();339 340 string premierText, dernierText;341 if(selectedSections_.size() == 0)342 { 343 premierText = dtmanage_->getLabelFromElementNumero(1);344 345 dernierText = dtmanage_->getLabelFromElementNumero(dtmanage_->beamLineSize());346 } 347 else348 { 349 dernierText = selectedSections_.back()->fin->text().toUTF8();350 int dernierNumero = dtmanage_->getCollection()->getNumeroFromLabel(dernierText);351 dernierNumero++;352 if ( dernierNumero <= dtmanage_->beamLineSize() )353 354 355 356 else357 358 359 360 dernierText = premierText;361 } 362 363 // cout << "PspaApplication::addSectionToExecute() : " << premierText << " Ã " << dernierText << endl;364 365 WContainerWidget* newSection = new WContainerWidget;366 367 selectedSections_.push_back(new GWt_sectionToExecute);368 selectedSections_.back()->debut = new WLineEdit();369 selectedSections_.back()->debut->setDisabled(true);370 selectedSections_.back()->debut->setText(premierText);371 selectedSections_.back()->fin = new WLineEdit();372 selectedSections_.back()->fin->changed().connect(this,&PspaApplication::disableSectionExecute);373 selectedSections_.back()->fin->setText(dernierText);374 selectedSections_.back()->selection = new WComboBox();375 selectedSections_.back()->ligneDeWidget = newSection;376 newSection->addWidget(new WText(" from : "));377 newSection->addWidget(selectedSections_.back()->debut);378 newSection->addWidget(new WText(" to : "));379 newSection->addWidget(selectedSections_.back()->fin);380 newSection->addWidget(selectedSections_.back()->selection);381 382 contenuSections_->addWidget(newSection);383 unsigned nb = nomDeLogiciel::getNumberOfSoftwares();384 unsigned k;385 for(k = 0; k < nb; k++) {386 selectedSections_.back()->selection->addItem(nomDeLogiciel(k).getString());387 }338 339 disableSectionExecute(); 340 341 string premierText, dernierText; 342 if(selectedSections_.size() == 0) 343 { 344 premierText = dtmanage_->getLabelFromElementNumero(1); 345 346 dernierText = dtmanage_->getLabelFromElementNumero(dtmanage_->beamLineSize()); 347 } 348 else 349 { 350 dernierText = selectedSections_.back()->fin->text().toUTF8(); 351 int dernierNumero = dtmanage_->getCollection()->getNumeroFromLabel(dernierText); 352 dernierNumero++; 353 if ( dernierNumero <= dtmanage_->beamLineSize() ) 354 { 355 premierText = dtmanage_->getLabelFromElementNumero(dernierNumero); 356 } 357 else 358 { 359 premierText = dtmanage_->getLabelFromElementNumero(dtmanage_->beamLineSize()); 360 } 361 dernierText = premierText; 362 } 363 364 // cout << "PspaApplication::addSectionToExecute() : " << premierText << " Ã " << dernierText << endl; 365 366 WContainerWidget* newSection = new WContainerWidget; 367 368 selectedSections_.push_back(new GWt_sectionToExecute); 369 selectedSections_.back()->debut = new WLineEdit(); 370 selectedSections_.back()->debut->setDisabled(true); 371 selectedSections_.back()->debut->setText(premierText); 372 selectedSections_.back()->fin = new WLineEdit(); 373 selectedSections_.back()->fin->changed().connect(this,&PspaApplication::disableSectionExecute); 374 selectedSections_.back()->fin->setText(dernierText); 375 selectedSections_.back()->selection = new WComboBox(); 376 selectedSections_.back()->ligneDeWidget = newSection; 377 newSection->addWidget(new WText(" from : ")); 378 newSection->addWidget(selectedSections_.back()->debut); 379 newSection->addWidget(new WText(" to : ")); 380 newSection->addWidget(selectedSections_.back()->fin); 381 newSection->addWidget(selectedSections_.back()->selection); 382 383 contenuSections_->addWidget(newSection); 384 unsigned nb = nomDeLogiciel::getNumberOfSoftwares(); 385 unsigned k; 386 for(k = 0; k < nb; k++) { 387 selectedSections_.back()->selection->addItem(nomDeLogiciel(k).getString()); 388 } 388 389 } 389 390 390 391 void PspaApplication::disableSectionExecute() 391 392 { 392 exec_go_->setDisabled(true);393 exec_go_->setDisabled(true); 393 394 } 394 395 395 396 void PspaApplication::checkSectionSelection() 396 397 { 397 if ( selectedSections_.empty() ) return;398 399 // traitement de la premiere ligne400 // on impose le depart du calcul au premier element401 string premier = dtmanage_->getLabelFromElementNumero(1);402 (*selectedSections_.begin())->debut->setText(premier);403 404 string currentString = (*selectedSections_.begin())->fin->text().toUTF8();405 int current = dtmanage_->getCollection()->getNumeroFromLabel( currentString);406 407 cout << " numero " << current << endl;408 // si la fin est mal definie on prend toute la config par defaut409 if ( current <= 0 || current > dtmanage_->beamLineSize() )410 { 411 current = dtmanage_->beamLineSize();412 currentString = dtmanage_->getLabelFromElementNumero(current);413 (*selectedSections_.begin())->fin->setText(currentString);414 } 415 current++;416 currentString = dtmanage_->getLabelFromElementNumero(current);417 418 // traitement des suivantes (on avance d'un cran dans la liste)419 list<GWt_sectionToExecute*>::iterator itr, itr0;420 itr0 = selectedSections_.begin();421 itr0++;422 for (itr = itr0; itr != selectedSections_.end(); itr++)423 { 424 // debut425 if ( current >= dtmanage_->beamLineSize() )426 427 428 GWt_dialog warningDialog("PSPA : Vérification des sections", " bad section definition !", GWt_dialog::Error,true,true);429 warningDialog.exec();430 431 432 433 (*itr)->debut->setText(currentString);434 // fin435 string finString = (*itr)->fin->text().toUTF8();436 437 int numeroFin = dtmanage_->getCollection()->getNumeroFromLabel( finString);438 439 if ( numeroFin <= current || numeroFin > dtmanage_->beamLineSize())440 441 442 GWt_dialog warningDialog("PSPA : Vérification des sections", " bad section definition !", GWt_dialog::Error, true,true);443 warningDialog.exec();444 445 446 447 // preparation de la ligne suivante448 current = numeroFin +1;449 currentString = dtmanage_->getLabelFromElementNumero(current);450 } 451 452 if (!areDataCoherent()) {453 GWt_dialog warningDialog("PSPA : Vérification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true);454 warningDialog.exec();455 }456 else457 { 458 exec_go_->setDisabled(false);459 } 460 } 461 462 bool PspaApplication::areDataCoherent() 463 { 464 bool caMarche = true;465 dtmanage_->initializeExecution(workingDir_);466 467 list<GWt_sectionToExecute*>::iterator itr;468 for(itr = selectedSections_.begin(); itr != selectedSections_.end(); itr++)469 { 470 string debString = (*itr)->debut->text().toUTF8();471 string finString = (*itr)->fin->text().toUTF8();472 473 474 int debut = dtmanage_->getCollection()->getNumeroFromLabel(debString);475 int fin = dtmanage_->getCollection()->getNumeroFromLabel(finString);476 nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() );477 dtmanage_->addSectionToExecute(debut,fin,prog);478 } 479 480 string diagnostic;481 trivaluedBool essai = dtmanage_->checkExecute(diagnostic);482 cout << " retour verif , essai = " << essai << endl;483 if ( essai == error ) {484 cout << " appli : erreur " << endl;485 caMarche = false;486 GWt_dialog calculDialog("PSPA check execute : ERROR", diagnostic , GWt_dialog::Error,true,true);487 calculDialog.exec();488 } else if ( essai == warning ) {489 cout << " appli : warnig " << endl;490 caMarche = true;491 GWt_dialog calculDialog("PSPA check execute : warning ", diagnostic , GWt_dialog::Warning, false,true);492 calculDialog.exec();493 }494 495 return caMarche;398 if ( selectedSections_.empty() ) return; 399 400 // traitement de la premiere ligne 401 // on impose le depart du calcul au premier element 402 string premier = dtmanage_->getLabelFromElementNumero(1); 403 (*selectedSections_.begin())->debut->setText(premier); 404 405 string currentString = (*selectedSections_.begin())->fin->text().toUTF8(); 406 int current = dtmanage_->getCollection()->getNumeroFromLabel( currentString); 407 408 cout << " numero " << current << endl; 409 // si la fin est mal definie on prend toute la config par defaut 410 if ( current <= 0 || current > dtmanage_->beamLineSize() ) 411 { 412 current = dtmanage_->beamLineSize(); 413 currentString = dtmanage_->getLabelFromElementNumero(current); 414 (*selectedSections_.begin())->fin->setText(currentString); 415 } 416 current++; 417 currentString = dtmanage_->getLabelFromElementNumero(current); 418 419 // traitement des suivantes (on avance d'un cran dans la liste) 420 list<GWt_sectionToExecute*>::iterator itr, itr0; 421 itr0 = selectedSections_.begin(); 422 itr0++; 423 for (itr = itr0; itr != selectedSections_.end(); itr++) 424 { 425 // debut 426 if ( current >= dtmanage_->beamLineSize() ) 427 { 428 // GWt_tools::addConsoleMessage(" bad section definition ! \n "); 429 GWt_dialog warningDialog("PSPA : Vérification des sections", " bad section definition !", GWt_dialog::Error,true,true); 430 warningDialog.exec(); 431 return; 432 } 433 434 (*itr)->debut->setText(currentString); 435 // fin 436 string finString = (*itr)->fin->text().toUTF8(); 437 438 int numeroFin = dtmanage_->getCollection()->getNumeroFromLabel( finString); 439 440 if ( numeroFin <= current || numeroFin > dtmanage_->beamLineSize()) 441 { 442 // GWt_tools::addConsoleMessage(" bad section definition ! \n "); 443 GWt_dialog warningDialog("PSPA : Vérification des sections", " bad section definition !", GWt_dialog::Error, true,true); 444 warningDialog.exec(); 445 return; 446 } 447 448 // preparation de la ligne suivante 449 current = numeroFin +1; 450 currentString = dtmanage_->getLabelFromElementNumero(current); 451 } 452 453 if (!areDataCoherent()) { 454 GWt_dialog warningDialog("PSPA : Vérification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true); 455 warningDialog.exec(); 456 } 457 else 458 { 459 exec_go_->setDisabled(false); 460 } 461 } 462 463 bool PspaApplication::areDataCoherent() 464 { 465 bool caMarche = true; 466 dtmanage_->initializeExecution(workingDir_); 467 468 list<GWt_sectionToExecute*>::iterator itr; 469 for(itr = selectedSections_.begin(); itr != selectedSections_.end(); itr++) 470 { 471 string debString = (*itr)->debut->text().toUTF8(); 472 string finString = (*itr)->fin->text().toUTF8(); 473 474 475 int debut = dtmanage_->getCollection()->getNumeroFromLabel(debString); 476 int fin = dtmanage_->getCollection()->getNumeroFromLabel(finString); 477 nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() ); 478 dtmanage_->addSectionToExecute(debut,fin,prog); 479 } 480 481 string diagnostic; 482 trivaluedBool essai = dtmanage_->checkExecute(diagnostic); 483 cout << " retour verif , essai = " << essai << endl; 484 if ( essai == error ) { 485 cout << " appli : erreur " << endl; 486 caMarche = false; 487 GWt_dialog calculDialog("PSPA check execute : ERROR", diagnostic , GWt_dialog::Error,true,true); 488 calculDialog.exec(); 489 } else if ( essai == warning ) { 490 cout << " appli : warnig " << endl; 491 caMarche = true; 492 GWt_dialog calculDialog("PSPA check execute : warning ", diagnostic , GWt_dialog::Warning, false,true); 493 calculDialog.exec(); 494 } 495 496 return caMarche; 496 497 } 497 498 498 499 void PspaApplication::deleteSectionToExecuteW() 499 500 { 500 if ( selectedSections_.empty() ) return;501 disableSectionExecute();502 selectedSections_.back()->ligneDeWidget->clear();503 delete selectedSections_.back()->ligneDeWidget;504 selectedSections_.pop_back();501 if ( selectedSections_.empty() ) return; 502 disableSectionExecute(); 503 selectedSections_.back()->ligneDeWidget->clear(); 504 delete selectedSections_.back()->ligneDeWidget; 505 selectedSections_.pop_back(); 505 506 } 506 507 507 508 void PspaApplication::executer() 508 509 { 509 console_->addConsoleMessage(string("on va peut etre y arriver"));510 511 512 static_cast<GWt_globalParameters*>(globalParam_)->updateGlobals();513 514 GWt_dialog calculDialog("Calcul en cours", "Veuillez patienter...", GWt_dialog::Wait, true,false);515 calculDialog.show();516 517 processEvents();518 519 string resultat;520 if ( !dtmanage_->executeAll(workingDir_, resultat)) {521 GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exécution !", GWt_dialog::Error, true,true);522 warningDialog.exec();523 }524 // cout << " PspaApplication : retour d'execution resultat = " << resultat << endl;525 console_->addConsoleMessage(resultat);526 // cout << " PspaApplication : affichage console termine " << endl;527 528 exec_go_->setDisabled(true);529 530 calculDialog.hide();531 532 faireDessin();510 console_->addConsoleMessage(string("on va peut etre y arriver")); 511 512 513 static_cast<GWt_globalParameters*>(globalParam_)->updateGlobals(); 514 515 GWt_dialog calculDialog("Calcul en cours", "Veuillez patienter...", GWt_dialog::Wait, true,false); 516 calculDialog.show(); 517 518 processEvents(); 519 520 string resultat; 521 if ( !dtmanage_->executeAll(workingDir_, resultat)) { 522 GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exécution !", GWt_dialog::Error, true,true); 523 warningDialog.exec(); 524 } 525 // cout << " PspaApplication : retour d'execution resultat = " << resultat << endl; 526 console_->addConsoleMessage(resultat); 527 // cout << " PspaApplication : affichage console termine " << endl; 528 529 exec_go_->setDisabled(true); 530 531 calculDialog.hide(); 532 533 faireDessin(); 533 534 } 534 535 535 536 void PspaApplication::sauver() 536 537 { 537 cout << " on sauve " << endl;538 console_->addConsoleMessage("sauvegarde");539 540 dialogSave_ = new WDialog("save");541 new WText("name of case : ",dialogSave_->contents());542 saveNameEdit_ = new WLineEdit(nameOfCase_.c_str(), dialogSave_->contents());543 WPushButton *annule = new WPushButton("cancel",dialogSave_->contents());544 WPushButton *submit = new WPushButton("OK",dialogSave_->contents());545 annule->clicked().connect(dialogSave_, &Wt::WDialog::reject);546 submit->clicked().connect(dialogSave_, &Wt::WDialog::accept);547 dialogSave_->finished().connect(this, &PspaApplication::dialogSaveDone);548 dialogSave_->show();538 cout << " on sauve " << endl; 539 console_->addConsoleMessage("sauvegarde"); 540 541 dialogSave_ = new WDialog("save"); 542 new WText("name of case : ",dialogSave_->contents()); 543 saveNameEdit_ = new WLineEdit(nameOfCase_.c_str(), dialogSave_->contents()); 544 WPushButton *annule = new WPushButton("cancel",dialogSave_->contents()); 545 WPushButton *submit = new WPushButton("OK",dialogSave_->contents()); 546 annule->clicked().connect(dialogSave_, &Wt::WDialog::reject); 547 submit->clicked().connect(dialogSave_, &Wt::WDialog::accept); 548 dialogSave_->finished().connect(this, &PspaApplication::dialogSaveDone); 549 dialogSave_->show(); 549 550 } 550 551 551 552 void PspaApplication::dialogSaveDone(WDialog::DialogCode code) 552 553 { 553 554 if ( code != Wt::WDialog::Accepted ) { console_->addConsoleMessage(" pas de sauvegarde"); return;}555 else { console_->addConsoleMessage("sauvegarde sur repertoire : " + workingDir_);}556 nameOfCase_ = saveNameEdit_->text().toUTF8();557 cout << " PspaApplication::dialogSaveDone() nameOfCase_= " << nameOfCase_ << endl;558 delete dialogSave_;559 dialogSave_ = NULL;560 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_);561 bibi->updateGlobals();562 // dtmanage_->saveConfiguration(nameOfCase_);563 dtmanage_->saveConfiguration(workingDir_ , nameOfCase_);554 555 if ( code != Wt::WDialog::Accepted ) { console_->addConsoleMessage(" pas de sauvegarde"); return;} 556 else { console_->addConsoleMessage("sauvegarde sur repertoire : " + workingDir_);} 557 nameOfCase_ = saveNameEdit_->text().toUTF8(); 558 cout << " PspaApplication::dialogSaveDone() nameOfCase_= " << nameOfCase_ << endl; 559 delete dialogSave_; 560 dialogSave_ = NULL; 561 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); 562 bibi->updateGlobals(); 563 // dtmanage_->saveConfiguration(nameOfCase_); 564 dtmanage_->saveConfiguration(workingDir_ , nameOfCase_); 564 565 } 565 566 … … 568 569 void PspaApplication::restaurer() 569 570 { 570 console_->addConsoleMessage(string("on va recharger..."));571 dialogOpen_ = new WDialog("open");572 new WText("name of case : ",dialogOpen_->contents());573 openNameEdit_ = new WLineEdit(nameOfCase_.c_str(), dialogOpen_->contents());574 WPushButton *annule = new WPushButton("cancel",dialogOpen_->contents());575 WPushButton *submit = new WPushButton("OK",dialogOpen_->contents());576 annule->clicked().connect(dialogOpen_, &Wt::WDialog::reject);577 submit->clicked().connect(dialogOpen_, &Wt::WDialog::accept);578 dialogOpen_->finished().connect(this, &PspaApplication::dialogOpenDone);579 dialogOpen_->show();571 console_->addConsoleMessage(string("on va recharger...")); 572 dialogOpen_ = new WDialog("open"); 573 new WText("name of case : ",dialogOpen_->contents()); 574 openNameEdit_ = new WLineEdit(nameOfCase_.c_str(), dialogOpen_->contents()); 575 WPushButton *annule = new WPushButton("cancel",dialogOpen_->contents()); 576 WPushButton *submit = new WPushButton("OK",dialogOpen_->contents()); 577 annule->clicked().connect(dialogOpen_, &Wt::WDialog::reject); 578 submit->clicked().connect(dialogOpen_, &Wt::WDialog::accept); 579 dialogOpen_->finished().connect(this, &PspaApplication::dialogOpenDone); 580 dialogOpen_->show(); 580 581 } 581 582 582 583 void PspaApplication::dialogOpenDone(WDialog::DialogCode code) 583 584 { 584 585 if ( code != Wt::WDialog::Accepted ) { console_->addConsoleMessage(" pas de restauration"); return;}586 else { console_->addConsoleMessage("restauration depuis le repertoire " + workingDir_ );}587 588 nameOfCase_ = openNameEdit_->text().toUTF8();589 cout << " PspaApplication::dialogOpenDone() nameOfCase_= " << nameOfCase_ << endl;590 delete dialogOpen_;591 dialogSave_ = NULL;592 593 bool test = dtmanage_->restoreElements(workingDir_, nameOfCase_);594 if ( !test ) {595 596 597 }598 599 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_);600 bibi->renew();601 602 GWt_LigneFaisceau* bobo = static_cast<GWt_LigneFaisceau*>(beamLine_);603 bobo->restoreElementCollection();604 605 console_->addConsoleMessage(string("...terminee"));585 586 if ( code != Wt::WDialog::Accepted ) { console_->addConsoleMessage(" pas de restauration"); return;} 587 else { console_->addConsoleMessage("restauration depuis le repertoire " + workingDir_ );} 588 589 nameOfCase_ = openNameEdit_->text().toUTF8(); 590 cout << " PspaApplication::dialogOpenDone() nameOfCase_= " << nameOfCase_ << endl; 591 delete dialogOpen_; 592 dialogSave_ = NULL; 593 594 bool test = dtmanage_->restoreElements(workingDir_, nameOfCase_); 595 if ( !test ) { 596 GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true); 597 restoreWarning.exec(); 598 } 599 600 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); 601 bibi->renew(); 602 603 GWt_LigneFaisceau* bobo = static_cast<GWt_LigneFaisceau*>(beamLine_); 604 bobo->restoreElementCollection(); 605 606 console_->addConsoleMessage(string("...terminee")); 606 607 } 607 608 … … 609 610 void PspaApplication::openFileSelector() 610 611 { 611 612 WContainerWidget *result = new WContainerWidget();613 WVBoxLayout* myLayout = new WVBoxLayout();614 615 uploadFileSelectorWidget_ = new WFileUpload();616 617 uploadFileSelectorWidget_->setFileTextSize(40);618 619 myLayout->addWidget(new WText("Select the configuration file for pspa : "));620 myLayout->addWidget(uploadFileSelectorWidget_);621 622 result->setLayout (myLayout);623 624 // Upload automatically when the user entered a file.625 uploadFileSelectorWidget_->changed().connect(uploadFileSelectorWidget_, &WFileUpload::upload);626 627 // React to a succesfull upload.628 uploadFileSelectorWidget_->uploaded().connect(this, &PspaApplication::chargerConfig);629 630 // React to a fileupload problem.631 uploadFileSelectorWidget_->fileTooLarge().connect(this, &PspaApplication::fileTooLarge);632 633 634 GWt_dialog* fileSelectorDialog = new GWt_dialog("Load a file",result,false);635 636 fileSelectorDialog->exec();612 613 WContainerWidget *result = new WContainerWidget(); 614 WVBoxLayout* myLayout = new WVBoxLayout(); 615 616 uploadFileSelectorWidget_ = new WFileUpload(); 617 618 uploadFileSelectorWidget_->setFileTextSize(40); 619 620 myLayout->addWidget(new WText("Select the configuration file for pspa : ")); 621 myLayout->addWidget(uploadFileSelectorWidget_); 622 623 result->setLayout (myLayout); 624 625 // Upload automatically when the user entered a file. 626 uploadFileSelectorWidget_->changed().connect(uploadFileSelectorWidget_, &WFileUpload::upload); 627 628 // React to a succesfull upload. 629 uploadFileSelectorWidget_->uploaded().connect(this, &PspaApplication::chargerConfig); 630 631 // React to a fileupload problem. 632 uploadFileSelectorWidget_->fileTooLarge().connect(this, &PspaApplication::fileTooLarge); 633 634 635 GWt_dialog* fileSelectorDialog = new GWt_dialog("Load a file",result,false); 636 637 fileSelectorDialog->exec(); 637 638 } 638 639 … … 640 641 void PspaApplication::chargerConfig() 641 642 { 642 GWt_dialog* message= new GWt_dialog("File successfully upload","The file has been correctly upload to" + uploadFileSelectorWidget_->spoolFileName(),GWt_dialog::Warning,false,true);643 644 string nomDuFichier = (uploadFileSelectorWidget_->clientFileName()).toUTF8();645 cout << " fichier client : " << nomDuFichier << endl;646 bool test = removeExtensionFromConfigName(nomDuFichier);647 cout << " fichier client sans extension : " << nomDuFichier << endl;648 649 if ( test )650 { 651 nameOfCase_ = nomDuFichier;652 console_->addConsoleMessage(string("restauration..."));653 654 if ( !dtmanage_->restoreElements(workingDir_, uploadFileSelectorWidget_->spoolFileName()) ) {655 656 657 }658 659 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_);660 bibi->renew();661 662 GWt_LigneFaisceau* bobo = static_cast<GWt_LigneFaisceau*>(beamLine_);663 bobo->restoreElementCollection();664 665 console_->addConsoleMessage(string("...terminee"));666 message->show();643 GWt_dialog* message= new GWt_dialog("File successfully upload","The file has been correctly upload to" + uploadFileSelectorWidget_->spoolFileName(),GWt_dialog::Warning,false,true); 644 645 string nomDuFichier = (uploadFileSelectorWidget_->clientFileName()).toUTF8(); 646 cout << " fichier client : " << nomDuFichier << endl; 647 bool test = removeExtensionFromConfigName(nomDuFichier); 648 cout << " fichier client sans extension : " << nomDuFichier << endl; 649 650 if ( test ) 651 { 652 nameOfCase_ = nomDuFichier; 653 console_->addConsoleMessage(string("restauration...")); 654 655 if ( !dtmanage_->restoreElements(workingDir_, uploadFileSelectorWidget_->spoolFileName()) ) { 656 GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true); 657 restoreWarning.exec(); 658 } 659 660 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); 661 bibi->renew(); 662 663 GWt_LigneFaisceau* bobo = static_cast<GWt_LigneFaisceau*>(beamLine_); 664 bobo->restoreElementCollection(); 665 666 console_->addConsoleMessage(string("...terminee")); 667 message->show(); 667 668 } 668 669 } … … 671 672 void PspaApplication::fileTooLarge() 672 673 { 673 std::stringstream stream;674 stream << maximumRequestSize ();675 std::string maxRequestSize(stream.str());676 677 std::string message = "This file is too large, please select a one\n";678 message += "Maximum file size is "+ maxRequestSize;679 message += " bytes\n";680 681 GWt_dialog* messageBox= new GWt_dialog("Error during upload file" ,message ,GWt_dialog::Error,false,true);682 683 messageBox->show();674 std::stringstream stream; 675 stream << maximumRequestSize (); 676 std::string maxRequestSize(stream.str()); 677 678 std::string message = "This file is too large, please select a one\n"; 679 message += "Maximum file size is "+ maxRequestSize; 680 message += " bytes\n"; 681 682 GWt_dialog* messageBox= new GWt_dialog("Error during upload file" ,message ,GWt_dialog::Error,false,true); 683 684 messageBox->show(); 684 685 } 685 686 … … 687 688 void PspaApplication::faireDessin() 688 689 { 689 choixElementDessin_->clear();690 int nombre = dtmanage_->beamLineSize();691 for ( int numero =1; numero <= nombre; numero++)692 { 693 choixElementDessin_->addItem(dtmanage_->getLabelFromElementNumero(numero));694 } 695 690 choixElementDessin_->clear(); 691 int nombre = dtmanage_->beamLineSize(); 692 for ( int numero =1; numero <= nombre; numero++) 693 { 694 choixElementDessin_->addItem(dtmanage_->getLabelFromElementNumero(numero)); 695 } 696 696 697 } 697 698 698 699 void PspaApplication::dessiner() 699 700 { 700 701 toto_->clear();702 703 int typeFaisceau = choixTypeDessinFaisceau_->currentIndex();704 705 int index = choixElementDessin_->currentIndex();706 707 708 particleBeam* beam = dtmanage_->getDiagnosticBeam(index);709 710 if ( beam == NULL ) {711 712 713 714 } 715 716 717 if ( typeFaisceau == 0 )718 { 719 if ( !beam->momentRepresentationOk() ) beam->buildMomentRepresentation();720 faireDessinTransport(toto_, beam);721 } 722 else if ( typeFaisceau == 1 )723 { 724 if ( beam->particleRepresentationOk() ) faireDessinParmela(toto_, beam);725 else {726 727 warningBeamState.exec();728 }729 } 730 else {731 732 733 }734 //////////////////////////////////////////701 702 toto_->clear(); 703 704 int typeFaisceau = choixTypeDessinFaisceau_->currentIndex(); 705 706 int index = choixElementDessin_->currentIndex(); 707 708 709 particleBeam* beam = dtmanage_->getDiagnosticBeam(index); 710 711 if ( beam == NULL ) { 712 GWt_dialog warningBeamState(" graphical analysis", "the beam does not exist at the end of this element !", GWt_dialog::Error, false,true); 713 warningBeamState.exec(); 714 return; 715 } 716 717 718 if ( typeFaisceau == 0 ) 719 { 720 if ( !beam->momentRepresentationOk() ) beam->buildMomentRepresentation(); 721 faireDessinTransport(toto_, beam); 722 } 723 else if ( typeFaisceau == 1 ) 724 { 725 if ( beam->particleRepresentationOk() ) faireDessinParmela(toto_, beam); 726 else { 727 GWt_dialog warningBeamState(" graphical analysis", "the beam state does not allow providing a drawing with macroparticles !", GWt_dialog::Error, false,true); 728 warningBeamState.exec(); 729 } 730 } 731 else { 732 GWt_dialog warningTypeDrawing(" graphical analysis", "type of drawing not programmed !", GWt_dialog::Error, false,true); 733 warningTypeDrawing.exec(); 734 } 735 ////////////////////////////////////////// 735 736 } 736 737 737 738 void PspaApplication::dessinerEnveloppe() 738 739 { 739 740 toto_->clear();741 742 int typeEnveloppe = choixEnveloppeDessin_->currentIndex();743 if ( typeEnveloppe == 0 )744 { 745 faireDessinEnveloppe(toto_, "x");746 } 747 else {748 749 750 }751 //////////////////////////////////////////740 741 toto_->clear(); 742 743 int typeEnveloppe = choixEnveloppeDessin_->currentIndex(); 744 if ( typeEnveloppe == 0 ) 745 { 746 faireDessinEnveloppe(toto_, "x"); 747 } 748 else { 749 GWt_dialog warningTypeEnveloppe(" graphical analysis", "type of enveloppe drawing not programmed !", GWt_dialog::Error, false,true); 750 warningTypeEnveloppe.exec(); 751 } 752 ////////////////////////////////////////// 752 753 } 753 754 754 755 void PspaApplication::faireDessinEnveloppe(WContainerWidget* toto, string type) 755 756 { 756 757 GWt_dialog* envDialog = new GWt_dialog("enveloppe",toto_,false);758 envDialog->setMinimumSize(400,400);759 envDialog->setClosable(true);760 envDialog->show();761 762 763 764 // new WText(nameOfCase_ + " : enveloppe", toto);765 766 767 768 vector<double> xcor;769 vector<double> ycor;770 771 772 dtmanage_->donneesRmsEnveloppe(type,1, nbel, xcor,ycor);773 774 scatterPlot1D(envDialog->contents(),xcor,ycor);775 757 758 GWt_dialog* envDialog = new GWt_dialog("enveloppe",toto_,false); 759 envDialog->setMinimumSize(400,400); 760 envDialog->setClosable(true); 761 envDialog->show(); 762 763 764 765 // new WText(nameOfCase_ + " : enveloppe", toto); 766 unsigned nbel = dtmanage_->beamLineSize(); 767 768 769 vector<double> xcor; 770 vector<double> ycor; 771 772 773 dtmanage_->donneesRmsEnveloppe(type,1, nbel, xcor,ycor); 774 775 scatterPlot1D(envDialog->contents(),xcor,ycor); 776 776 777 } 777 778 778 779 void PspaApplication::faireDessinParmela(WContainerWidget* toto, particleBeam* beam) 779 780 { 780 781 GWt_dialog* pointsDialog = new GWt_dialog("space phase",toto,false);782 pointsDialog->setMinimumSize(400,400);783 pointsDialog->setClosable(true);784 // pointsDialog->show();785 786 787 788 vector<bareParticle>& partic = beam->getParticleVector();789 new WText(nameOfCase_ + " : espace de phase x,x' "+ " nb partic. "+ mixedTools::intToString(partic.size()), pointsDialog->contents());790 WStandardItemModel *model = new WStandardItemModel(partic.size(), 3, pointsDialog->contents());791 // model->setHeaderData(0, WString("X"));792 // model->setHeaderData(1, WString("Y = sin(X)"));793 794 795 for (unsigned i = 0; i < partic.size(); ++i) {796 double x= partic.at(i).getPosition().getComponent(0);797 double begamz = partic.at(i).getBetaGamma().getComponent(2);798 double xp = partic.at(i).getBetaGamma().getComponent(0)/begamz;799 // cout << "x = " << x << " xp= " << xp << endl;800 model->setData(i, 0, x);801 model->setData(i, 1,1.e3*xp);802 model->setData(i, 2,2.e3*xp);803 }804 805 WCartesianChart *chart = new WCartesianChart(pointsDialog->contents());806 chart->setModel(model); // set the model807 chart->setXSeriesColumn(0); // set the column that holds the X data808 chart->setLegendEnabled(true); // enable the legend809 810 chart->setType(ScatterPlot); // set type to ScatterPlot811 812 // Typically, for mathematical functions, you want the axes to cross813 // at the 0 mark:814 chart->axis(XAxis).setLocation(ZeroValue);815 chart->axis(YAxis).setLocation(ZeroValue);816 817 // Provide space for the X and Y axis and title.818 chart->setPlotAreaPadding(80, Left);819 chart->setPlotAreaPadding(40, Top | Bottom);820 // Add the curves821 WDataSeries s(1, PointSeries, Y1Axis);822 // s.setShadow(WShadow(3, 3, WColor(0, 0, 0, 127), 3));823 // s.setMarker(SquareMarker);824 // s.setMarkerSize(600.);825 // cout << "le marker est : " << s.marker() << endl;826 827 828 chart->resize(400, 400); // WPaintedWidget must be given explicit size829 830 781 782 GWt_dialog* pointsDialog = new GWt_dialog("space phase",toto,false); 783 pointsDialog->setMinimumSize(400,400); 784 pointsDialog->setClosable(true); 785 // pointsDialog->show(); 786 787 788 789 vector<bareParticle>& partic = beam->getParticleVector(); 790 new WText(nameOfCase_ + " : espace de phase x,x' "+ " nb partic. "+ mixedTools::intToString(partic.size()), pointsDialog->contents()); 791 WStandardItemModel *model = new WStandardItemModel(partic.size(), 3, pointsDialog->contents()); 792 // model->setHeaderData(0, WString("X")); 793 // model->setHeaderData(1, WString("Y = sin(X)")); 794 795 796 for (unsigned i = 0; i < partic.size(); ++i) { 797 double x= partic.at(i).getPosition().getComponent(0); 798 double begamz = partic.at(i).getBetaGamma().getComponent(2); 799 double xp = partic.at(i).getBetaGamma().getComponent(0)/begamz; 800 // cout << "x = " << x << " xp= " << xp << endl; 801 model->setData(i, 0, x); 802 model->setData(i, 1,1.e3*xp); 803 model->setData(i, 2,2.e3*xp); 804 } 805 806 WCartesianChart *chart = new WCartesianChart(pointsDialog->contents()); 807 chart->setModel(model); // set the model 808 chart->setXSeriesColumn(0); // set the column that holds the X data 809 chart->setLegendEnabled(true); // enable the legend 810 811 chart->setType(ScatterPlot); // set type to ScatterPlot 812 813 // Typically, for mathematical functions, you want the axes to cross 814 // at the 0 mark: 815 chart->axis(XAxis).setLocation(ZeroValue); 816 chart->axis(YAxis).setLocation(ZeroValue); 817 818 // Provide space for the X and Y axis and title. 819 chart->setPlotAreaPadding(80, Left); 820 chart->setPlotAreaPadding(40, Top | Bottom); 821 // Add the curves 822 WDataSeries s(1, PointSeries, Y1Axis); 823 // s.setShadow(WShadow(3, 3, WColor(0, 0, 0, 127), 3)); 824 // s.setMarker(SquareMarker); 825 // s.setMarkerSize(600.); 826 // cout << "le marker est : " << s.marker() << endl; 827 chart->addSeries(s); 828 829 chart->resize(400, 400); // WPaintedWidget must be given explicit size 830 831 831 832 #ifdef HAS_IMAGEMAGIC 832 Wt::WRasterImage pngImage("png", 600, 600);833 Wt::WPainter p(&pngImage);834 chart->paint(p);835 std::string name;836 name = workingDir_ + "/chart-"+sessionId ()+".png";837 std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary);838 pngImage.write(f);839 new WText("<a href='workingArea/chart-"+sessionId ()+".png' target='_blank'>Afficher l'image</a>",toto);833 Wt::WRasterImage pngImage("png", 600, 600); 834 Wt::WPainter p(&pngImage); 835 chart->paint(p); 836 std::string name; 837 name = workingDir_ + "/chart-"+sessionId ()+".png"; 838 std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary); 839 pngImage.write(f); 840 new WText("<a href='workingArea/chart-"+sessionId ()+".png' target='_blank'>Afficher l'image</a>",toto); 840 841 #endif 841 842 pointsDialog->show();843 844 // chart->setMargin(10, Top | Bottom); // add margin vertically845 // chart->setMargin(WLength::Auto, Left | Right); // center horizontally842 843 pointsDialog->show(); 844 845 // chart->setMargin(10, Top | Bottom); // add margin vertically 846 // chart->setMargin(WLength::Auto, Left | Right); // center horizontally 846 847 } 847 848 … … 854 855 void PspaApplication::faireDessinTransport(WContainerWidget* toto, particleBeam* beam) 855 856 { 856 // WContainerWidget* toto = static_cast<WContainerWidget*>(leDessin_);857 // toto->clear();858 859 // new WText(nameOfCase_ + " : espace de phase x,x' "+ " nb partic. "+ mixedTools::intToString(partic.size()), toto);860 861 GWt_dialog* ellipseDialog = new GWt_dialog("ellipse",toto,false);862 ellipseDialog->setMinimumSize(400,400);863 ellipseDialog->setClosable(true);864 ellipseDialog->show();865 866 867 new WText(nameOfCase_ + " : emittance x,x' " + mixedTools::doubleToString(beam->getUnnormalizedEmittanceX()) + " pi.mm.mrad" , ellipseDialog->contents());868 new WBreak(ellipseDialog->contents());869 new WText(" xmax = " + mixedTools::doubleToString(beam->getSigmaTransportij(1,1)) + " cm ", ellipseDialog->contents());870 new WBreak(ellipseDialog->contents());871 new WText(" x' max = " + mixedTools::doubleToString(beam->getSigmaTransportij(2,2)) + " mrad ", ellipseDialog->contents());872 new WBreak(ellipseDialog->contents());873 new WText(" corr. 12 = " + mixedTools::doubleToString(beam->getSigmaTransportij(2,1)) + " sqrt(cm.rad) ", ellipseDialog->contents());874 875 vector<double> xcor;876 vector<double> ycor;877 // dtmanage_->getCurrentBeam()->donneesDessinEllipseXxp(xcor,ycor);878 beam->donneesDessinEllipseXxp(xcor,ycor);879 scatterPlot1D(ellipseDialog->contents(),xcor,ycor);880 857 // WContainerWidget* toto = static_cast<WContainerWidget*>(leDessin_); 858 // toto->clear(); 859 860 // new WText(nameOfCase_ + " : espace de phase x,x' "+ " nb partic. "+ mixedTools::intToString(partic.size()), toto); 861 862 GWt_dialog* ellipseDialog = new GWt_dialog("ellipse",toto,false); 863 ellipseDialog->setMinimumSize(400,400); 864 ellipseDialog->setClosable(true); 865 ellipseDialog->show(); 866 867 868 new WText(nameOfCase_ + " : emittance x,x' " + mixedTools::doubleToString(beam->getUnnormalizedEmittanceX()) + " pi.mm.mrad" , ellipseDialog->contents()); 869 new WBreak(ellipseDialog->contents()); 870 new WText(" xmax = " + mixedTools::doubleToString(beam->getSigmaTransportij(1,1)) + " cm ", ellipseDialog->contents()); 871 new WBreak(ellipseDialog->contents()); 872 new WText(" x' max = " + mixedTools::doubleToString(beam->getSigmaTransportij(2,2)) + " mrad ", ellipseDialog->contents()); 873 new WBreak(ellipseDialog->contents()); 874 new WText(" corr. 12 = " + mixedTools::doubleToString(beam->getSigmaTransportij(2,1)) + " sqrt(cm.rad) ", ellipseDialog->contents()); 875 876 vector<double> xcor; 877 vector<double> ycor; 878 // dtmanage_->getCurrentBeam()->donneesDessinEllipseXxp(xcor,ycor); 879 beam->donneesDessinEllipseXxp(xcor,ycor); 880 scatterPlot1D(ellipseDialog->contents(),xcor,ycor); 881 881 882 } 882 883 … … 907 908 // chart->axis(YAxis).setLocation(ZeroValue); 908 909 909 // // Provide space for the X and Y axis and title. 910 // // Provide space for the X and Y axis and title. 910 911 // // chart->setPlotAreaPadding(80, Left); 911 912 // // chart->setPlotAreaPadding(40, Top | Bottom); … … 942 943 void PspaApplication::scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor) 943 944 { 944 int nbpts = xcor.size();945 cout << " PspaApplication::scatterPlot1D nbpts = " << nbpts << endl;946 WStandardItemModel *model = new WStandardItemModel(nbpts, 2, toto);947 for (int i = 0; i < nbpts; ++i) {948 model->setData(i, 0, xcor.at(i));949 model->setData(i, 1, ycor.at(i));950 // cout << " PspaApplication::scatterPlot1D el= " << i+1 << " x= " << xcor.at(i) << " y= " << ycor.at(i) << endl;951 }952 953 WCartesianChart *chart = new WCartesianChart(toto);954 chart->setTitle("titre");955 956 // chart->initLayout();957 958 chart->setModel(model); // set the model959 chart->setXSeriesColumn(0); // set the column that holds the X data960 chart->setLegendEnabled(true); // enable the legend961 962 chart->setType(ScatterPlot); // set type to ScatterPlot963 964 // Typically, for mathematical functions, you want the axes to cross965 // at the 0 mark:966 chart->axis(XAxis).setLocation(ZeroValue);967 chart->axis(YAxis).setLocation(ZeroValue);968 969 // Provide space for the X and Y axis and title.970 // chart->setPlotAreaPadding(80, Left);971 // chart->setPlotAreaPadding(40, Top | Bottom);972 // Add the curves973 WDataSeries s(1, LineSeries, Y1Axis);974 chart->addSeries(s);975 976 // chart->setBackground (WBrush(WColor("blue")));977 chart->resize(500, 300); // WPaintedWidget must be given explicit size978 945 int nbpts = xcor.size(); 946 cout << " PspaApplication::scatterPlot1D nbpts = " << nbpts << endl; 947 WStandardItemModel *model = new WStandardItemModel(nbpts, 2, toto); 948 for (int i = 0; i < nbpts; ++i) { 949 model->setData(i, 0, xcor.at(i)); 950 model->setData(i, 1, ycor.at(i)); 951 // cout << " PspaApplication::scatterPlot1D el= " << i+1 << " x= " << xcor.at(i) << " y= " << ycor.at(i) << endl; 952 } 953 954 WCartesianChart *chart = new WCartesianChart(toto); 955 chart->setTitle("titre"); 956 957 // chart->initLayout(); 958 959 chart->setModel(model); // set the model 960 chart->setXSeriesColumn(0); // set the column that holds the X data 961 chart->setLegendEnabled(true); // enable the legend 962 963 chart->setType(ScatterPlot); // set type to ScatterPlot 964 965 // Typically, for mathematical functions, you want the axes to cross 966 // at the 0 mark: 967 chart->axis(XAxis).setLocation(ZeroValue); 968 chart->axis(YAxis).setLocation(ZeroValue); 969 970 // Provide space for the X and Y axis and title. 971 // chart->setPlotAreaPadding(80, Left); 972 // chart->setPlotAreaPadding(40, Top | Bottom); 973 // Add the curves 974 WDataSeries s(1, LineSeries, Y1Axis); 975 chart->addSeries(s); 976 977 // chart->setBackground (WBrush(WColor("blue"))); 978 chart->resize(500, 300); // WPaintedWidget must be given explicit size 979 979 980 #ifdef HAS_IMAGEMAGIC 980 Wt::WRasterImage pngImage("png", 600, 600);981 Wt::WPainter p(&pngImage);982 983 chart->paint(p);984 std::string name;985 name = workingDir_ + "/chart-"+sessionId ()+".png";986 std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary);987 pngImage.write(f);988 989 new WText("<a href='workingArea/chart-"+sessionId ()+".png' target='_blank'>Afficher l'image</a>",toto);990 991 /*992 Wt::WPdfImage pdfImage("30cm", "30cm");993 Wt::WPainter p1(&pdfImage);994 chart->paint(p1);995 std::ofstream f1("chart.pdf", std::ios::out | std::ios::binary);996 pdfImage.write(f1);997 */981 Wt::WRasterImage pngImage("png", 600, 600); 982 Wt::WPainter p(&pngImage); 983 984 chart->paint(p); 985 std::string name; 986 name = workingDir_ + "/chart-"+sessionId ()+".png"; 987 std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary); 988 pngImage.write(f); 989 990 new WText("<a href='workingArea/chart-"+sessionId ()+".png' target='_blank'>Afficher l'image</a>",toto); 991 992 /* 993 Wt::WPdfImage pdfImage("30cm", "30cm"); 994 Wt::WPainter p1(&pdfImage); 995 chart->paint(p1); 996 std::ofstream f1("chart.pdf", std::ios::out | std::ios::binary); 997 pdfImage.write(f1); 998 */ 998 999 #endif 999 1000 } … … 1001 1002 void PspaApplication::updateSelections() 1002 1003 { 1003 string premierText, dernierText;1004 if ( selectedSections_.size() > 0 )1005 { 1006 premierText = dtmanage_->getLabelFromElementNumero(1);1007 dernierText = dtmanage_->getLabelFromElementNumero( dtmanage_->beamLineSize() );1008 (*selectedSections_.begin())->debut->setText(premierText);1009 (*selectedSections_.begin())->fin->setText(dernierText);1010 } 1011 1012 cout << "PspaApplication::updateSelections(): " << premierText << " Ã " << dernierText << endl;1004 string premierText, dernierText; 1005 if ( selectedSections_.size() > 0 ) 1006 { 1007 premierText = dtmanage_->getLabelFromElementNumero(1); 1008 dernierText = dtmanage_->getLabelFromElementNumero( dtmanage_->beamLineSize() ); 1009 (*selectedSections_.begin())->debut->setText(premierText); 1010 (*selectedSections_.begin())->fin->setText(dernierText); 1011 } 1012 1013 cout << "PspaApplication::updateSelections(): " << premierText << " Ã " << dernierText << endl; 1013 1014 } 1014 1015 1015 1016 string PspaApplication::getSelection() 1016 1017 { 1017 list<GWt_sectionToExecute*>::iterator itr = selectedSections_.begin();1018 string str = (*itr)->fin->text().toUTF8();1019 return str;1020 } 1021 1022 WText* PspaApplication::createTitle(const WString& title) 1023 { 1024 WText *result = new WText(title);1025 result->setInline(false);1026 result->setStyleClass("title");1027 result->setMinimumSize(30,30);1028 1029 return result;1018 list<GWt_sectionToExecute*>::iterator itr = selectedSections_.begin(); 1019 string str = (*itr)->fin->text().toUTF8(); 1020 return str; 1021 } 1022 1023 WText* PspaApplication::createTitle(const WString& title) 1024 { 1025 WText *result = new WText(title); 1026 result->setInline(false); 1027 result->setStyleClass("title"); 1028 result->setMinimumSize(30,30); 1029 1030 return result; 1030 1031 } 1031 1032 … … 1035 1036 // w->setText(msg); 1036 1037 // w->setInline(false); 1037 1038 1038 1039 // /* 1039 1040 // * Little javascript trick to make sure we scroll along with new content … … 1042 1043 // app->doJavaScript(console_->jsRef() + ".scrollTop += " 1043 1044 // + console_->jsRef() + ".scrollHeight;"); 1044 1045 1045 1046 // } 1046 1047 … … 1048 1049 bool PspaApplication::removeExtensionFromConfigName(string& config) 1049 1050 { 1050 // string configName;1051 string extension(".save");1052 bool test = true;1051 // string configName; 1052 string extension(".save"); 1053 bool test = true; 1053 1054 string::size_type nn = config.rfind('.'); 1054 if ( nn == string::npos ) 1055 1056 // pas de point 1057 1058 1055 if ( nn == string::npos ) 1056 { 1057 // pas de point 1058 test = false; 1059 } 1059 1060 string fin = config.substr(nn); 1060 if ( fin != extension ) 1061 1062 1063 1064 1061 if ( fin != extension ) 1062 { 1063 // l'extension n'est pas la bonne 1064 test = false; 1065 } 1065 1066 if ( test ) 1066 1067 1068 1069 1067 { 1068 string::size_type count = config.length() - extension.length(); 1069 config = config.substr(0, count); 1070 } 1070 1071 else 1071 1072 1073 1074 1072 { 1073 GWt_dialog checkConfigNameDialog(" checking config file name", " the file must have the extension " + extension, GWt_dialog::Error,true,true); 1074 checkConfigNameDialog.exec(); 1075 } 1075 1076 return test; 1076 1077 } … … 1081 1082 void PspaApplication::dessinerHistogramme() 1082 1083 { 1083 // pour mon test : histo en energie 1084 toto_->clear(); 1085 1086 GWt_dialog* pourVoir= new GWt_dialog("histogramme",toto_,false); 1087 pourVoir->setMinimumSize(400,400); 1088 pourVoir->setClosable(true); 1089 pourVoir->show(); 1090 1091 1092 particleBeam* beam = dtmanage_->getDiagnosticBeam(1); 1093 vector<double> xcor; 1094 vector<int> hist; 1095 int cnts; 1096 beam->histogramme(xcor,hist,cnts); 1097 1098 cout<<"xcor.size()= "<<xcor.size()<<", hist.size()= "<<hist.size()<<endl; 1099 1100 ////////////////////////////////////////////////////////////////////////////////// 1101 1102 WContainerWidget *w = toto_; 1103 int nbpts= xcor.size()+cnts+1; 1104 WStandardItemModel *model = new WStandardItemModel(nbpts,2,w); 1105 model->setHeaderData(1, WString("energie")); 1106 1107 int j= 0; 1108 if(hist[0] > 0) { 1084 // pour mon test : histo en energie 1085 toto_->clear(); 1086 1087 GWt_dialog* pourVoir= new GWt_dialog("histogramme",toto_,false); 1088 pourVoir->setMinimumSize(400,400); 1089 pourVoir->setClosable(true); 1090 pourVoir->show(); 1091 1092 1093 particleBeam* beam = dtmanage_->getDiagnosticBeam(1); 1094 vector<double> xcor; 1095 vector<int> hist; 1096 int cnts; 1097 beam->histogramme(xcor,hist,cnts); 1098 1099 cout<<"xcor.size()= "<<xcor.size()<<", hist.size()= "<<hist.size()<<endl; 1100 1101 ////////////////////////////////////////////////////////////////////////////////// 1102 1103 WContainerWidget *w = toto_; 1104 int nbpts= xcor.size()+cnts+1; 1105 WStandardItemModel *model = new WStandardItemModel(nbpts,2,w); 1106 model->setHeaderData(1, WString("energie")); 1107 1108 int j= 0; 1109 if(hist[0] > 0) { 1110 model->setData(j,0,xcor[0]); 1111 model->setData(j,1,hist[0]); 1112 j++; 1113 } 1109 1114 model->setData(j,0,xcor[0]); 1110 1115 model->setData(j,1,hist[0]); 1111 1116 j++; 1112 } 1113 model->setData(j,0,xcor[0]); 1114 model->setData(j,1,hist[0]); 1115 j++; 1116 for (int i = 1; i < nbpts; ++i) { 1117 if(hist[i] == 0) { 1118 if(hist[i-1] > 0) { 1119 model->setData(j,0,xcor[i]); 1120 model->setData(j,1,hist[i-1]); 1121 j++; 1122 } 1123 model->setData(j,0,xcor[i]); 1124 model->setData(j,1,hist[i]); 1125 j++; 1126 } 1127 if(hist[i] > 0) { 1128 model->setData(j,0,xcor[i]); 1129 model->setData(j,1,hist[i-1]); 1130 j++; 1131 model->setData(j,0,xcor[i]); 1132 model->setData(j,1,hist[i]); 1133 j++; 1134 } 1135 } 1136 1137 WCartesianChart *chart = new WCartesianChart(w); 1138 chart->setTitle("Histogramme"); 1139 chart->setModel(model); // set the model 1140 chart->setXSeriesColumn(0); // set the column that holds the categories 1141 chart->setLegendEnabled(true); // enable the legend 1142 1143 // Provide space for the X and Y axis and title. 1144 chart->setPlotAreaPadding(200, Right); 1145 chart->setPlotAreaPadding(80, Left); 1146 chart->setPlotAreaPadding(40, Top | Bottom); 1147 1148 chart->setType(ScatterPlot); 1149 1150 WAxis& axis = chart->axis(XAxis); 1151 axis.setLabelFormat("%.3f"); 1152 axis.setGridLinesEnabled(true); 1153 chart->axis(Y1Axis).setGridLinesEnabled(true); 1154 1155 WDataSeries s(1, LineSeries); 1156 chart->addSeries(s); 1157 1158 1159 chart->resize(800, 400); 1160 1161 chart->setMargin(10, Top | Bottom); 1162 chart->setMargin(WLength::Auto, Left | Right); 1163 1164 LegendLocation location = LegendOutside; 1165 Side side = Right; 1166 AlignmentFlag alignment = AlignMiddle; 1167 chart->setLegendLocation(location, side, alignment); 1168 chart->setLegendStyle(chart->legendFont(), WPen(black), WBrush(WColor(0xFF, 0xFA, 0xE5))); 1169 } 1117 for (int i = 1; i < nbpts; ++i) { 1118 if(hist[i] == 0) { 1119 if(hist[i-1] > 0) { 1120 model->setData(j,0,xcor[i]); 1121 model->setData(j,1,hist[i-1]); 1122 j++; 1123 } 1124 model->setData(j,0,xcor[i]); 1125 model->setData(j,1,hist[i]); 1126 j++; 1127 } 1128 if(hist[i] > 0) { 1129 model->setData(j,0,xcor[i]); 1130 model->setData(j,1,hist[i-1]); 1131 j++; 1132 model->setData(j,0,xcor[i]); 1133 model->setData(j,1,hist[i]); 1134 j++; 1135 } 1136 } 1137 1138 WCartesianChart *chart = new WCartesianChart(w); 1139 chart->setTitle("Histogramme"); 1140 chart->setModel(model); // set the model 1141 chart->setXSeriesColumn(0); // set the column that holds the categories 1142 chart->setLegendEnabled(true); // enable the legend 1143 1144 // Provide space for the X and Y axis and title. 1145 chart->setPlotAreaPadding(200, Right); 1146 chart->setPlotAreaPadding(80, Left); 1147 chart->setPlotAreaPadding(40, Top | Bottom); 1148 1149 chart->setType(ScatterPlot); 1150 1151 WAxis& axis = chart->axis(XAxis); 1152 axis.setLabelFormat("%.3f"); 1153 axis.setGridLinesEnabled(true); 1154 chart->axis(Y1Axis).setGridLinesEnabled(true); 1155 1156 WDataSeries s(1, LineSeries); 1157 chart->addSeries(s); 1158 1159 1160 chart->resize(800, 400); 1161 1162 chart->setMargin(10, Top | Bottom); 1163 chart->setMargin(WLength::Auto, Left | Right); 1164 1165 LegendLocation location = LegendOutside; 1166 Side side = Right; 1167 AlignmentFlag alignment = AlignMiddle; 1168 chart->setLegendLocation(location, side, alignment); 1169 chart->setLegendStyle(chart->legendFont(), WPen(black), WBrush(WColor(0xFF, 0xFA, 0xE5))); 1170 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_rfgun.cc
r266 r272 10 10 GWt_rfgun::GWt_rfgun(abstractElement* elem ,GWt_elementLigneFaisceau* elemLigne) : GWt_abstractElement(elem, elemLigne) 11 11 { 12 13 string* param = beginDialog();14 15 new WText("nr of macroparticles : ",dialog_->contents());16 nmacropEdit_ = new WLineEdit(param->c_str(), dialog_->contents());17 new WBreak(dialog_->contents());18 19 new WText("sigma_t (ps) : ",dialog_->contents());20 sigma_tEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());21 new WBreak(dialog_->contents());22 23 new WText("sigma_r (cm) : ",dialog_->contents());24 sigma_rEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());25 new WBreak(dialog_->contents());26 27 new WText("initial kinetic energy (MeV) : ",dialog_->contents());28 E_cinEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());29 new WBreak(dialog_->contents());30 31 new WText("sigma_Ecin (MeV) : ",dialog_->contents());32 sigma_EEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());33 new WBreak(dialog_->contents());34 35 new WText("true number of part. in beam : ",dialog_->contents());36 nb_true_particlesEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());37 new WBreak(dialog_->contents());38 39 // Submit40 WPushButton *submit = new WPushButton("OK",dialog_->contents());41 submit->clicked().connect(dialog_, &Wt::WDialog::accept);42 dialog_->finished().connect(this, &GWt_rfgun::dialogDone);43 44 // make image45 image_ = new WImage("htdocs/rfgun.jpg",this);46 12 13 string* param = beginDialog(); 14 15 new WText("nr of macroparticles : ",dialog_->contents()); 16 nmacropEdit_ = new WLineEdit(param->c_str(), dialog_->contents()); 17 new WBreak(dialog_->contents()); 18 19 new WText("sigma_t (ps) : ",dialog_->contents()); 20 sigma_tEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 21 new WBreak(dialog_->contents()); 22 23 new WText("sigma_r (cm) : ",dialog_->contents()); 24 sigma_rEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 25 new WBreak(dialog_->contents()); 26 27 new WText("initial kinetic energy (MeV) : ",dialog_->contents()); 28 E_cinEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 29 new WBreak(dialog_->contents()); 30 31 new WText("sigma_Ecin (MeV) : ",dialog_->contents()); 32 sigma_EEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 33 new WBreak(dialog_->contents()); 34 35 new WText("true number of part. in beam : ",dialog_->contents()); 36 nb_true_particlesEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 37 new WBreak(dialog_->contents()); 38 39 // Submit 40 WPushButton *submit = new WPushButton("OK",dialog_->contents()); 41 submit->clicked().connect(dialog_, &Wt::WDialog::accept); 42 dialog_->finished().connect(this, &GWt_rfgun::dialogDone); 43 44 // make image 45 image_ = new WImage("htdocs/rfgun.jpg",this); 46 47 47 // activate slots 48 48 image_->clicked().connect(this,&GWt_abstractElement::clicked); … … 52 52 void GWt_rfgun::dialogDone() 53 53 { 54 unsigned nbParam = abstractElement_->getNbParams();55 string* envoi = new string[nbParam+1];56 int compteur = -1;57 envoi[++compteur] = mixedTools::intToString(nbParam);58 envoi[++compteur] = labelEdit_->text().toUTF8();59 envoi[++compteur] = nmacropEdit_->text().toUTF8();60 envoi[++compteur] = sigma_tEdit_->text().toUTF8();61 envoi[++compteur] = sigma_rEdit_->text().toUTF8();62 envoi[++compteur] = E_cinEdit_->text().toUTF8();63 envoi[++compteur] = sigma_EEdit_->text().toUTF8();64 envoi[++compteur] = nb_true_particlesEdit_->text().toUTF8();65 if ( compteur != (int)nbParam ) {66 cerr << " GWt_rfgun::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl;67 return;68 }69 abstractElement_->setParametersString(envoi);70 updateLabelWidget();71 delete [] envoi;54 unsigned nbParam = abstractElement_->getNbParams(); 55 string* envoi = new string[nbParam+1]; 56 int compteur = -1; 57 envoi[++compteur] = mixedTools::intToString(nbParam); 58 envoi[++compteur] = labelEdit_->text().toUTF8(); 59 envoi[++compteur] = nmacropEdit_->text().toUTF8(); 60 envoi[++compteur] = sigma_tEdit_->text().toUTF8(); 61 envoi[++compteur] = sigma_rEdit_->text().toUTF8(); 62 envoi[++compteur] = E_cinEdit_->text().toUTF8(); 63 envoi[++compteur] = sigma_EEdit_->text().toUTF8(); 64 envoi[++compteur] = nb_true_particlesEdit_->text().toUTF8(); 65 if ( compteur != (int)nbParam ) { 66 cerr << " GWt_rfgun::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; 67 return; 68 } 69 abstractElement_->setParametersString(envoi); 70 updateLabelWidget(); 71 delete [] envoi; 72 72 } 73 73 74 74 75 75 WImage* GWt_rfgun::getImage() { 76 return image_;76 return image_; 77 77 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_soleno.cc
r266 r272 10 10 GWt_soleno::GWt_soleno(abstractElement* elem ,GWt_elementLigneFaisceau* elemLigne) : GWt_abstractElement(elem, elemLigne) 11 11 { 12 string* param = beginDialog();13 14 new WText("length (cm) : ",dialog_->contents());15 xlengthEdit_ = new WLineEdit( param->c_str(), dialog_->contents());16 new WBreak(dialog_->contents());17 new WText("aperture (cm) : ",dialog_->contents());18 apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());19 new WBreak(dialog_->contents());20 new WText("field (kG) : ",dialog_->contents());21 B0Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());22 varyB0Edit_ = new WCheckBox(" : may vary ? ", dialog_->contents());23 varyB0Edit_->setChecked(atoi( (++param)->c_str() ) );24 new WBreak(dialog_->contents());25 // Submit26 WPushButton *submit = new WPushButton("OK",dialog_->contents());27 submit->clicked().connect(dialog_, &Wt::WDialog::accept);28 dialog_->finished().connect(this, &GWt_soleno::dialogDone);29 30 // make image31 image_ = new WImage("htdocs/soleno.jpg",this);12 string* param = beginDialog(); 13 14 new WText("length (cm) : ",dialog_->contents()); 15 xlengthEdit_ = new WLineEdit( param->c_str(), dialog_->contents()); 16 new WBreak(dialog_->contents()); 17 new WText("aperture (cm) : ",dialog_->contents()); 18 apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 19 new WBreak(dialog_->contents()); 20 new WText("field (kG) : ",dialog_->contents()); 21 B0Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 22 varyB0Edit_ = new WCheckBox(" : may vary ? ", dialog_->contents()); 23 varyB0Edit_->setChecked(atoi( (++param)->c_str() ) ); 24 new WBreak(dialog_->contents()); 25 // Submit 26 WPushButton *submit = new WPushButton("OK",dialog_->contents()); 27 submit->clicked().connect(dialog_, &Wt::WDialog::accept); 28 dialog_->finished().connect(this, &GWt_soleno::dialogDone); 29 30 // make image 31 image_ = new WImage("htdocs/soleno.jpg",this); 32 32 33 33 // activate slots 34 34 image_->clicked().connect(this,&GWt_abstractElement::clicked); 35 35 36 36 } 37 37 … … 39 39 void GWt_soleno::dialogDone() 40 40 { 41 unsigned nbParam = abstractElement_->getNbParams();42 string* envoi = new string[nbParam+1];43 int compteur = -1;44 envoi[++compteur] = mixedTools::intToString(nbParam);45 envoi[++compteur] = labelEdit_->text().toUTF8();46 envoi[++compteur] = xlengthEdit_->text().toUTF8();47 envoi[++compteur] = apertureEdit_->text().toUTF8();48 envoi[++compteur] = B0Edit_->text().toUTF8();49 int varie;50 if ( varyB0Edit_->checkState() == Checked ) varie = 1;51 else varie = 0;52 envoi[++compteur] = mixedTools::intToString(varie);53 if ( compteur != (int)nbParam ) {54 cerr << " GWt_bend::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl;55 return;56 }57 abstractElement_->setParametersString(envoi);58 updateLabelWidget();59 delete [] envoi;41 unsigned nbParam = abstractElement_->getNbParams(); 42 string* envoi = new string[nbParam+1]; 43 int compteur = -1; 44 envoi[++compteur] = mixedTools::intToString(nbParam); 45 envoi[++compteur] = labelEdit_->text().toUTF8(); 46 envoi[++compteur] = xlengthEdit_->text().toUTF8(); 47 envoi[++compteur] = apertureEdit_->text().toUTF8(); 48 envoi[++compteur] = B0Edit_->text().toUTF8(); 49 int varie; 50 if ( varyB0Edit_->checkState() == Checked ) varie = 1; 51 else varie = 0; 52 envoi[++compteur] = mixedTools::intToString(varie); 53 if ( compteur != (int)nbParam ) { 54 cerr << " GWt_bend::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; 55 return; 56 } 57 abstractElement_->setParametersString(envoi); 58 updateLabelWidget(); 59 delete [] envoi; 60 60 } 61 61 62 62 63 63 WImage* GWt_soleno::getImage() { 64 return image_;64 return image_; 65 65 }
Note: See TracChangeset
for help on using the changeset viewer.