Changeset 401 in PSPA for Interface_Web/trunk/pspaWT/sources
- Timestamp:
- Mar 27, 2013, 5:47:22 PM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT
- Files:
-
- 20 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT
-
Property
svn:mergeinfo
set to
/Interface_Web/branches/12_03_12-managerComboBox/pspaWT merged eligible
-
Property
svn:mergeinfo
set to
-
Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h
r386 r401 31 31 particleBeam* getDiagnosticBeam(string elementLabel); 32 32 33 void addSectionToExecute( int debut, int fin, nomDeLogicielprog);33 void addSectionToExecute(abstractElement* debut,int debutIndex, abstractElement* fin, int finIndex, abstractSoftware* prog); 34 34 35 35 abstractElement* addElement(typedElement elemType); … … 65 65 bool restoreElements(string inputFileName); 66 66 67 abstractSoftware* createSoftwareConnexion(nomDeLogiciel logi); 68 69 /** return the jobList size 70 */ 71 inline int getJobListSize() { 72 return jobList_.size(); 73 } 67 74 68 75 // si newBeam = true, on cree un nouveau diag … … 76 83 } 77 84 85 /** return a specific jobList index 86 return NULL if the index does not exist 87 */ 88 inline sectionToExecute* getJobListAt(int a) { 89 if (a < 0) return NULL; 90 if (a >= getJobListSize()) return NULL; 91 return jobList_[a]; 92 } 93 94 /** Clear a specific jobList */ 95 void clearSectionToExecute(int a); 78 96 79 97 private: … … 93 111 void removeFile(string nameOfFile); 94 112 void clearSectionToExecute(); 95 abstractSoftware* createSoftwareConnexion(nomDeLogiciel logi);96 113 97 114 }; -
Interface_Web/trunk/pspaWT/sources/controler/include/nomDeLogiciel.h
r316 r401 19 19 }; 20 20 21 21 22 22 private: 23 23 -
Interface_Web/trunk/pspaWT/sources/controler/include/sectionToExecute.h
r312 r401 3 3 4 4 #include "nomDeLogiciel.h" 5 #include "abstractElement.h" 6 #include "abstractSoftware.h" 5 7 6 typedef struct 8 class sectionToExecute 7 9 { 8 unsigned firstElement; // numero premier element 9 unsigned lastElement; // numero dernier element 10 nomDeLogiciel software; 11 } sectionToExecute; 10 public : 11 sectionToExecute(abstractElement*, abstractElement*, abstractSoftware*); 12 13 /** Deprecated : To be removed ! */ 14 sectionToExecute(abstractElement*, int, abstractElement*, int, abstractSoftware*); 15 ~sectionToExecute() {;} 16 17 inline abstractElement* getFirstElement() { 18 return firstElement; 19 } 20 21 inline abstractElement* getLastElement() { 22 return lastElement; 23 } 24 25 /** Deprecated : To be removed ! */ 26 inline int getElementNumberInSection() { 27 return firstElementNumberInBeamLine; 28 } 29 30 /** Deprecated : To be removed ! */ 31 inline int getLastElementNumberInSection() { 32 return lastElementNumberInBeamLine; 33 } 34 inline abstractSoftware* getSoftware() { 35 return software; 36 } 37 38 private : 39 abstractElement* firstElement; 40 abstractElement* lastElement; 41 42 int firstElementNumberInBeamLine; 43 int lastElementNumberInBeamLine; 44 45 abstractSoftware* software; 46 }; 12 47 13 48 #endif -
Interface_Web/trunk/pspaWT/sources/controler/src/abstractElement.cc
r373 r401 117 117 } 118 118 119 if ((tb == TBoolOk) || (tb == TBoolIgnore)) { 119 if (prog == nomDeLogiciel::unknownSoftware){ 120 tb = TBoolOk; 121 } 122 123 if ((tb == TBoolOk) || (tb == TBoolIgnore)) { 120 124 if (prog == nomDeLogiciel::parmela) { 121 125 abstractSoftware_ = new softwareParmela(); -
Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc
r386 r401 64 64 } 65 65 66 void dataManager::addSectionToExecute(int debut, int fin, nomDeLogiciel prog) 67 { 68 jobList_.push_back(new sectionToExecute); 69 jobList_.back()->firstElement = debut; 70 jobList_.back()->lastElement = fin; 71 jobList_.back()->software = prog; 66 void dataManager::addSectionToExecute(abstractElement* debut,int debutIndex, abstractElement* fin, int finIndex, abstractSoftware* prog) 67 { 68 jobList_.push_back(new sectionToExecute(debut, debutIndex, fin, finIndex, prog)); 72 69 } 73 70 … … 77 74 for(k = 0; k < jobList_.size(); k++) 78 75 { 79 if ( jobList_[k] != NULL ) delete jobList_[k];76 if ( jobList_[k] != NULL ) clearSectionToExecute(k); 80 77 } 81 78 jobList_.clear(); 79 } 80 81 82 void dataManager::clearSectionToExecute(int a) { 83 if (a<0) return; 84 if (a>= jobList_.size()) return; 85 delete jobList_[a]; 82 86 } 83 87 … … 123 127 for(unsigned k = 0; k < jobList_.size(); k++) 124 128 { 125 cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]-> software).getString() << endl;126 127 int debut = jobList_[k]-> firstElement;128 int fin = jobList_[k]-> lastElement;129 softw = createSoftwareConnexion(jobList_[k]->software);129 cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->getSoftware()->getName()) << endl; 130 131 int debut = jobList_[k]->getElementNumberInSection(); 132 int fin = jobList_[k]->getLastElementNumberInSection(); 133 softw = jobList_[k]->getSoftware(); 130 134 131 135 if (softw == NULL) { 132 133 134 135 } 136 136 success = false; 137 consoleMessage("dataManager::executeAll : unknown software"); 138 break; 139 } 140 137 141 success = softw->createInputFile(currentBeam_,debut,fin,workingDir); 138 142 if ( success ) { … … 141 145 success = softw->buildBeamAfterElements(workingDir); 142 146 } 143 } 144 147 //======= 148 // success = softw->execute(debut,fin,workingDir); 149 // if ( success ) { 150 // success = softw->buildBeamAfterElements(debut,fin,diagnosticBeam_,workingDir); 151 // } 152 //>>>>>>> .merge-right.r400 153 } 154 145 155 delete softw; 146 156 if ( success ) { … … 306 316 } 307 317 318 308 319 abstractSoftware* dataManager::createSoftwareConnexion(nomDeLogiciel logi) 309 320 { -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_console.h
r272 r401 15 15 16 16 public: 17 GWt_console(); 18 virtual ~GWt_console(); 19 void addConsoleMessage(WString msg); 17 GWt_console(); 18 virtual ~GWt_console(); 19 void addConsoleMessage(WString msg); 20 private: 21 WText* output_; 20 22 }; 21 23 -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_dialog.h
r336 r401 38 38 */ 39 39 GWt_dialog(WString titre, WString message, iconType icon=NoIcon, bool modal=false, bool okButton=false); 40 41 /** Add a v content to this widget 42 */ 43 void addVContent(WContainerWidget* wc); 44 45 private : 46 WVBoxLayout* vDialogLayout_; 40 47 }; 41 48 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_ligneFaisceau.h
r379 r401 54 54 */ 55 55 abstractElement* getAbstractElement(int i); 56 57 /** return the index of the abstract element 58 @param : label of this abstractElement in the beam line 59 */ 60 int getAbstractElementIndexFromLabel(std::string str); 61 56 62 // void restoreElementCollectionFromDataManager(); 57 63 void clickEvent(WContainerWidget*); … … 75 81 void update(int); 76 82 83 void initializeSoftwares(); 84 77 85 private : 78 86 void manageLineFaisceauLayout(); -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h
r393 r401 65 65 WText* createTitle(const WString&); 66 66 WWidget* createPalette(); 67 voidcreateBeamLine();67 WWidget* createBeamLine(); 68 68 WWidget* createGlobalParamWidget(); 69 69 WWidget* createExecuteWidget(); -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_softwarePanel.h
r367 r401 13 13 #include <Wt/WContainerWidget> 14 14 #include <Wt/WPushButton> 15 15 #include "GWt_sectionToExecute.h" 16 16 #include "dataManager.h" 17 17 … … 23 23 class GWt_softwarePanel : public WContainerWidget 24 24 { 25 typedef struct {26 WLineEdit* debut;27 WLineEdit* fin;28 WComboBox* selection;29 WContainerWidget* ligneDeWidget;30 } GWt_sectionToExecute;31 32 25 public : 33 26 GWt_softwarePanel(dataManager*, PspaApplication*); … … 35 28 36 29 void addSectionToExecuteW(); 37 void updateSe lections();30 void updateSections(); 38 31 39 32 private : … … 45 38 void executer(); 46 39 bool areDataCoherent(); 47 48 list<GWt_sectionToExecute*> selectedSections_; 40 void fillComboWithElements(Wt::WComboBox* cBox); 41 void fillComboWithSoftwares(Wt::WComboBox* cBox); 42 Wt::WContainerWidget* createAddDeletePushButtons(); 43 49 44 dataManager* dtmanage_; 50 45 WPushButton *exec_go_; … … 52 47 PspaApplication* pspa_; 53 48 49 std::vector <GWt_sectionToExecute*> sections; 54 50 }; 55 51 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElementFactory.cc
r343 r401 99 99 { 100 100 vector <GWt_abstractElement*> elems; 101 if (is DriftElementEnable) {102 elems.push_back(new GWt_ drift());101 if (isRFGunElementEnable) { 102 elems.push_back(new GWt_rfgun()); 103 103 } 104 104 if (isBeamElementEnable) { 105 105 elems.push_back(new GWt_beam()); 106 } 107 if (isDriftElementEnable) { 108 elems.push_back(new GWt_drift()); 106 109 } 107 110 if (isBendElementEnable) { … … 111 114 elems.push_back(new GWt_cell()); 112 115 } 116 if (isSolenoElementEnable) { 117 elems.push_back(new GWt_soleno()); 118 } 113 119 if (isFitElementEnable) { 114 120 elems.push_back(new GWt_fit()); 115 }116 if (isRFGunElementEnable) {117 elems.push_back(new GWt_rfgun());118 }119 if (isSolenoElementEnable) {120 elems.push_back(new GWt_soleno());121 121 } 122 122 if (isSnapshotElementEnable) { -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_console.cc
r272 r401 3 3 #include <Wt/WApplication> 4 4 #include <Wt/WText> 5 #include <Wt/WBorder> 6 #include <Wt/WLayout> 7 #include <Wt/WPanel> 8 #include <Wt/WScrollArea> 5 9 6 10 GWt_console::GWt_console() … … 8 12 { 9 13 setObjectName("console"); 14 15 // le panel 16 WPanel *panelConsole = new WPanel(this); 17 WScrollArea* container = new WScrollArea(); 18 19 panelConsole->setTitle(" output"); 20 output_ = new WText(this); 21 output_->setTextFormat(PlainText); 22 output_->setInline(false); 23 24 container->setWidget(output_); 25 26 panelConsole->setCentralWidget(container); 27 output_->setMinimumSize(270,100); 28 output_->setMaximumSize(400,400); 29 30 10 31 } 11 32 … … 18 39 void GWt_console::addConsoleMessage(WString msg) { 19 40 20 WText *w = new WText(this); 21 w->setTextFormat(PlainText); 22 w->setText(msg); 23 w->setInline(false); 41 output_->setText(output_->text()+msg); 24 42 25 43 /* 26 44 * Little javascript trick to make sure we scroll along with new content 27 45 */ 28 wApp->doJavaScript( this->jsRef() + ".scrollTop += "29 + this->jsRef() + ".scrollHeight;");46 wApp->doJavaScript(output_->jsRef() + ".scrollTop += " 47 + output_->jsRef() + ".scrollHeight;"); 30 48 31 49 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_dialog.cc
r336 r401 3 3 #include <Wt/WText> 4 4 #include <Wt/WBreak> 5 #include <Wt/WVBoxLayout> 5 6 #include <Wt/WHBoxLayout> 6 7 #include <Wt/WPushButton> … … 19 20 titleBar()->decorationStyle().setBackgroundColor (WColor(70,180,220)); 20 21 21 if (wc != NULL) { 22 WContainerWidget* widgt = new WContainerWidget(contents()); 23 WHBoxLayout* hLayout = new WHBoxLayout(); 24 hLayout->addWidget(wc); 25 widgt->setLayout(hLayout); 26 } 22 WContainerWidget* widgt = new WContainerWidget(contents()); 23 vDialogLayout_ = new WVBoxLayout(); 24 widgt->setLayout(vDialogLayout_); 27 25 28 26 setClosable(true); 29 27 setModal (modal); 28 setResizable(true); 29 show(); 30 31 if (wc != NULL) { 32 addVContent(wc); 33 } 30 34 } 31 35 … … 111 115 112 116 117 void GWt_dialog::addVContent(WContainerWidget* wc) { 113 118 119 if (vDialogLayout_) { 120 vDialogLayout_->addWidget(wc); 121 } 122 } 123 124 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc
r382 r401 18 18 #include <Wt/WSignalMapper> 19 19 #include <Wt/WText> 20 #include <Wt/WImage>21 20 #include <Wt/WHBoxLayout> 22 21 #include <Wt/WGridLayout> … … 210 209 setBGColor(WColor(getGWt_AbstractElement()->getAbstractElement()->getAbstractSoftware()->getColor())); 211 210 softwareName_->setText(getGWt_AbstractElement()->getAbstractElement()->getAbstractSoftware()->getName()); 211 212 // no abstract software 213 } else { 214 setBGColor(WColor("#FFFFFF")); 215 softwareName_->setText(""); 212 216 } 213 217 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_globalParameters.cc
r272 r401 18 18 pspa_ = ps; 19 19 WVBoxLayout* globLayout = new WVBoxLayout(); 20 decorationStyle().setBackgroundColor (WColor("blue"));21 20 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 22 21 WContainerWidget *result = new WContainerWidget(); -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc
r379 r401 9 9 #include "GWt_soleno.h" 10 10 #include "GWt_bend.h" 11 #include "nomDeLogiciel.h" 11 12 12 13 #include "mixedTools.h" … … 24 25 ligneFaisceauLayout_ = new WHBoxLayout(); 25 26 // decorationStyle().setBackgroundColor (WColor(245,245,245)); 26 setLayout(ligneFaisceauLayout_);27 27 ligneFaisceauLayout_->setContentsMargins(0,0,0,0); 28 28 ligneFaisceauLayout_->setSpacing(0); 29 29 30 setLayout(ligneFaisceauLayout_); 31 30 32 // set the object name 31 setObjectName("ligneFaisceau"); 33 setObjectName("ligneFaisceau"); 32 34 clear(); 33 35 } … … 157 159 } 158 160 159 pspa_->getExecuteWidget()->updateSe lections();161 pspa_->getExecuteWidget()->updateSections(); 160 162 } 161 163 … … 203 205 } 204 206 205 // first if 1206 // i--;207 207 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 208 208 if (ligneFaisceauLayout_->itemAt(a)) { … … 222 222 223 223 224 int GWt_LigneFaisceau::getAbstractElementIndexFromLabel(std::string txt){ 225 int index = 0; 226 if (txt == "") { 227 return NULL; 228 } 229 230 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 231 if (ligneFaisceauLayout_->itemAt(a)) { 232 233 if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) { 234 if (elem->getGWt_AbstractElement()) { 235 if (elem->getGWt_AbstractElement()->getAbstractElement()->getLabel() == txt) { 236 return index; 237 } 238 } 239 index ++; 240 } 241 } 242 } 243 return NULL; 244 245 } 246 247 224 248 int GWt_LigneFaisceau::getBeamLineSize() { 225 249 int count = 0; … … 260 284 } 261 285 286 287 void GWt_LigneFaisceau::initializeSoftwares(){ 288 289 vector <abstractElement*> elems = getAllAbstractElements(); 290 for (int a=0; a< elems.size(); a++) { 291 elems[a]->setSoftware(nomDeLogiciel::unknownSoftware); 292 } 293 } 294 295 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r398 r401 77 77 78 78 /* 79 * The main layout is a 3x2grid layout.79 * The main layout is a 4x3 grid layout. 80 80 */ 81 WGridLayout * layout = new WGridLayout();81 WGridLayout *mainGridLayout = new WGridLayout(); 82 82 // layout->addWidget(createTitle("<a href='workingArea/parmin'> Menu (In future)</a>"), 0, 0, 1, 2); 83 83 // layout->addWidget(createTitle("Menu (In future)"), 0, 0, 1, 2); … … 131 131 toolbarLayout->addWidget(new WText("") , 1,Wt::AlignMiddle); 132 132 133 WContainerWidget * layoutContainer = new WContainerWidget();134 layoutContainer->setLayout(toolbarLayout);135 layoutContainer->decorationStyle().setBackgroundImage ("/htdocs/fond_toolbar.png");136 layout->addWidget(layoutContainer, 1, 0, 1, 2);137 layout->addWidget(createPalette(), 2, 0, 4, 1);138 139 createBeamLine(); 133 WContainerWidget * toolbarLayoutContainer = new WContainerWidget(); 134 toolbarLayoutContainer->setLayout(toolbarLayout); 135 toolbarLayoutContainer->decorationStyle().setBackgroundImage ("/htdocs/fond_toolbar.png"); 136 137 mainGridLayout->addWidget(toolbarLayoutContainer, 1, 0, 1, 3); 138 mainGridLayout->addWidget(createPalette(), 2, 0, 4, 1); 139 140 140 141 141 WScrollArea* scroll = new WScrollArea(); 142 scroll->setWidget(beamLine_); 143 layout->addWidget(scroll, 2, 1, 1, 1); 142 scroll->setWidget(createBeamLine()); 143 scroll->setMinimumSize(300,150); 144 145 mainGridLayout->addWidget(scroll, 2, 1, 1, 2); 144 146 145 147 … … 151 153 // console_->setOverflow(WContainerWidget::OverflowAuto); 152 154 153 154 console_ = new GWt_console();155 console_->clear();156 console_->decorationStyle().setBackgroundColor (WColor("lightgray"));157 console_->setMaximumSize(600,200);158 console_->setMinimumSize(300,100);159 console_->setOverflow(WContainerWidget::OverflowAuto);160 layout->addWidget(console_, 3, 2);161 155 162 156 //----------- … … 171 165 executeWidget_ = new GWt_softwarePanel(dtmanage_,this); 172 166 173 layout->addWidget( globalParam_, 3, 1);167 mainGridLayout->addWidget( globalParam_, 3, 1); 174 168 // layout->addWidget( leDessin_, 3, 2); 175 layout->addWidget( executeWidget_ , 4, 1);169 mainGridLayout->addWidget( executeWidget_ , 4, 1); 176 170 //----------- 177 171 178 layout->setColumnResizable(1); 179 layout->setRowResizable(2); 172 console_ = new GWt_console(); 173 174 // manage sizes 175 console_->setMinimumSize(300,100); 176 executeWidget_->setMinimumSize(400,100); 177 178 mainGridLayout->addWidget(console_, 3, 2,2,1); 179 180 180 181 /* 181 182 * Let row 2 and column 1 take the excess space. 182 183 */ 183 layout->setRowStretch(2, 1); 184 layout->setColumnStretch(1, 1); 185 186 widroot->setLayout(layout); 184 mainGridLayout->setRowStretch(4, 1); 185 mainGridLayout->setColumnStretch(2, 1); 186 187 widroot->setLayout(mainGridLayout); 188 189 // set auto scrollbar if needed 190 widroot->setOverflow(WContainerWidget::OverflowAuto); 191 187 192 } 188 193 … … 210 215 } 211 216 212 voidPspaApplication::createBeamLine()217 Wt::WWidget* PspaApplication::createBeamLine() 213 218 { 214 219 extensionFile_= 0; … … 220 225 beamLine_->setMinimumSize(300,100); 221 226 setTitle(applicationDefaultTitle_); 227 228 return beamLine_; 222 229 } 223 230 … … 225 232 { 226 233 WContainerWidget* globalParam = new GWt_globalParameters(this); 227 globalParam->setMaximumSize(600,150);228 globalParam->setMinimumSize(600,150);229 234 return globalParam; 230 235 } … … 980 985 void PspaApplication::removeBeamLine() { 981 986 createBeamLine(); 987 executeWidget_->updateSections(); 982 988 } 983 989 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_serverFileSelector.cc
r347 r401 70 70 WContainerWidget *buttonContainer = new WContainerWidget(); 71 71 WHBoxLayout* hButtonLayout = new WHBoxLayout(); 72 buttonContainer->setLayout(hButtonLayout);73 72 74 73 WPushButton *annule = new WPushButton("cancel"); … … 80 79 submit->clicked().connect(this, &Wt::WDialog::accept); 81 80 81 buttonContainer->setLayout(hButtonLayout); 82 82 83 // overload the container already present83 // add the container already present 84 84 85 WContainerWidget* widgt = new WContainerWidget(contents()); 86 WVBoxLayout* vLayout = new WVBoxLayout(); 87 vLayout->addWidget(treeContainer); 88 vLayout->addWidget(buttonContainer); 89 widgt->setLayout(vLayout); 85 addVContent(treeContainer); 86 addVContent(buttonContainer); 90 87 88 treeContainer->resize(400,300); 89 treeContainer->setOverflow(WContainerWidget::OverflowAuto); 90 91 91 } 92 92 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc
r398 r401 12 12 #include <Wt/WBreak> 13 13 #include <Wt/WApplication> 14 #include <Wt/WVBoxLayout> 14 15 15 16 #include "GWt_softwarePanel.h" … … 17 18 #include "GWt_console.h" 18 19 #include "GWt_globalParameters.h" 20 #include "GWt_sectionToExecute.h" 19 21 20 22 … … 24 26 dtmanage_ = dataManager; 25 27 pspa_ = pspa; 26 setMaximumSize(600,150); 27 setMinimumSize(600,150); 28 28 29 29 // bouton execute 30 30 exec_go_ = new WPushButton("execute!"); … … 33 33 exec_go_->clicked().connect(this, &GWt_softwarePanel::executer); 34 34 35 // preparation du bouton add36 WPushButton* exec_add = new WPushButton("add");37 exec_add->clicked().connect(this, &GWt_softwarePanel::addSectionToExecuteW);38 39 // preparation du bouton delete40 WPushButton* exec_delete = new WPushButton("delete");41 exec_delete->clicked().connect(this, &GWt_softwarePanel::deleteSectionToExecuteW);42 35 43 36 // preparation du bouton push_ok … … 47 40 // le panel 48 41 WPanel *panelLogiciels = new WPanel(this); 49 panelLogiciels->setTitle(" sections of beam Line for executing softwares ");42 panelLogiciels->setTitle(" sections of beam line for executing softwares "); 50 43 51 44 contenuSections_ = new WContainerWidget(); 52 contenuSections_->addWidget(exec_add);53 contenuSections_->addWidget(exec_delete);54 45 // contenuSections_->addWidget(exec_ok); 55 46 contenuSections_->addWidget(exec_go_); … … 66 57 void GWt_softwarePanel::addSectionToExecuteW() 67 58 { 68 // disableSectionExecute(); 69 70 string premierText, dernierText; 71 if(selectedSections_.size() == 0) { 72 premierText = dtmanage_->getLabelFromElementNumero(1); 73 dernierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize()); 59 60 abstractElement* premierElement; 61 abstractElement* dernierElement; 62 63 int premierIndex = 0; 64 int dernierIndex = 0; 65 66 // if this is the first section 67 if(dtmanage_->getJobListSize() == 0) { 68 premierElement = pspa_->getBeamLine()->getAbstractElement(0); 69 dernierElement = pspa_->getBeamLine()->getAbstractElement(pspa_->getBeamLine()->getBeamLineSize()-1); 70 premierIndex = 0; 71 dernierIndex = pspa_->getBeamLine()->getBeamLineSize()-1; 72 73 // if this is not the first : 74 // - first element will be the last of the previous section 75 // (or the same if it is the last of the beam line) 76 // - lastElement will be the last of the beam line 77 // - software will be the first of the list 78 74 79 } else { 75 dernierText = selectedSections_.back()->fin->text().toUTF8(); 76 int dernierNumero = dtmanage_->getNumeroFromElementLabel(dernierText); 77 dernierNumero++; 78 if ( dernierNumero <= dtmanage_->getBeamLineSize() ) { 79 premierText = dtmanage_->getLabelFromElementNumero(dernierNumero); 80 int indexOfLastElementOfLastSection = dtmanage_->getJobListAt(dtmanage_->getJobListSize()-1)->getLastElementNumberInSection(); 81 if (pspa_->getBeamLine()->getAbstractElement(indexOfLastElementOfLastSection+1) != NULL ) { 82 premierIndex = indexOfLastElementOfLastSection+1; 83 premierElement = pspa_->getBeamLine()->getAbstractElement(indexOfLastElementOfLastSection+1); 80 84 } else { 81 premierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize()); 85 premierIndex = indexOfLastElementOfLastSection; 86 premierElement = pspa_->getBeamLine()->getAbstractElement(indexOfLastElementOfLastSection); 87 82 88 } 83 dernierText = premierText; 89 dernierIndex = dtmanage_->getJobListSize()-1; 90 dernierElement = pspa_->getBeamLine()->getAbstractElement(pspa_->getBeamLine()->getBeamLineSize()-1); 84 91 } 85 92 86 93 // cout << "PspaApplication::addSectionToExecute() : " << premierText << " ââ " << dernierText << endl; 87 94 88 WContainerWidget* newSection = new WContainerWidget; 89 90 selectedSections_.push_back(new GWt_sectionToExecute); 91 selectedSections_.back()->debut = new WLineEdit(); 92 selectedSections_.back()->debut->setDisabled(true); 93 selectedSections_.back()->debut->setText(premierText); 94 selectedSections_.back()->fin = new WLineEdit(); 95 // selectedSections_.back()->fin->changed().connect(this,&GWt_softwarePanel::disableSectionExecute); 96 selectedSections_.back()->fin->setText(dernierText); 97 selectedSections_.back()->selection = new WComboBox(); 98 selectedSections_.back()->ligneDeWidget = newSection; 99 newSection->addWidget(new WText(" from : ")); 100 newSection->addWidget(selectedSections_.back()->debut); 101 newSection->addWidget(new WText(" to : ")); 102 newSection->addWidget(selectedSections_.back()->fin); 103 newSection->addWidget(selectedSections_.back()->selection); 104 105 contenuSections_->addWidget(newSection); 106 unsigned nb = nomDeLogiciel::getNumberOfSoftwares(); 107 unsigned k; 108 for(k = 0; k < nb; k++) { 109 selectedSections_.back()->selection->addItem(nomDeLogiciel(k).getString()); 110 } 95 96 abstractSoftware* soft = NULL; 97 dtmanage_->addSectionToExecute(premierElement,premierIndex, dernierElement, dernierIndex, soft); 98 99 std::string premierElementLabel = ""; 100 std::string dernierElementLabel = ""; 101 if (premierElement) { 102 premierElementLabel = premierElement->getLabel(); 103 } 104 105 if (dernierElement) { 106 dernierElementLabel = dernierElement->getLabel(); 107 } 108 109 WComboBox* lineFromCombo = new WComboBox(); 110 WComboBox* lineToCombo = new WComboBox(); 111 fillComboWithElements(lineFromCombo); 112 fillComboWithElements(lineToCombo); 113 114 WComboBox* softCombo = new WComboBox(); 115 fillComboWithSoftwares(softCombo); 116 117 GWt_sectionToExecute* newSection = new GWt_sectionToExecute(lineFromCombo, lineToCombo, softCombo,this); 118 119 // push back on sections vector 120 sections.push_back(newSection); 121 122 Wt::WContainerWidget* container = new Wt::WContainerWidget(); 123 Wt::WGridLayout* containerLayout = new Wt::WGridLayout(); 124 containerLayout->setContentsMargins(0,0,0,0); 125 126 // push back on User interface 127 containerLayout->addWidget(newSection,0,0); 128 129 // add buttons 130 containerLayout->addWidget(createAddDeletePushButtons(),0,1); 131 132 container->setLayout(containerLayout); 133 134 // add to sections 135 contenuSections_->addWidget(container); 111 136 } 112 137 … … 206 231 bool GWt_softwarePanel::updateSectionSelection() 207 232 { 208 if ( selectedSections_.empty()) return false;233 if ( dtmanage_->getJobListSize() == 0 ) return false; 209 234 210 235 // traitement de la premiere ligne 211 236 // on impose le depart du calcul au premier element 212 237 string premier = dtmanage_->getLabelFromElementNumero(1); 213 (*selectedSections_.begin())->debut->setText(premier); 214 215 string currentString = (*selectedSections_.begin())->fin->text().toUTF8(); 216 int current = dtmanage_->getNumeroFromElementLabel(currentString); 217 238 if (sections.size() > 0) { 239 sections[0]->setFirstElementCurrentSelection(premier); 240 } 241 242 Wt::WString currentString = sections[0]->getLastElementCurrentText(); 243 int current = dtmanage_->getNumeroFromElementLabel(currentString.toUTF8()); 244 218 245 // si la fin est mal definie on prend toute la config par defaut 219 246 if ( current <= 0 || current > dtmanage_->getBeamLineSize() ) 220 { 221 current = dtmanage_->getBeamLineSize(); 222 currentString = dtmanage_->getLabelFromElementNumero(current); 223 (*selectedSections_.begin())->fin->setText(currentString); 247 { 248 current = dtmanage_->getBeamLineSize(); 249 currentString = dtmanage_->getLabelFromElementNumero(current); 250 if (sections.size() > 0) { 251 sections[0]->setLastElementCurrentSelection(currentString); 252 //... 224 253 } 254 } 225 255 current++; 226 256 currentString = dtmanage_->getLabelFromElementNumero(current); 227 257 228 258 // traitement des suivantes (on avance d'un cran dans la liste) 229 list<GWt_sectionToExecute*>::iterator itr, itr0; 230 itr0 = selectedSections_.begin(); 231 itr0++; 232 for (itr = itr0; itr != selectedSections_.end(); itr++) 259 for (int a = 1; a< sections.size(); a++) 233 260 { 234 261 // debut 235 262 if ( current > dtmanage_->getBeamLineSize() ) 236 263 { 237 GWt_dialog warningDialog("PSPA :: verification des sections", " bad section definition !", GWt_dialog::Error,true,true);264 GWt_dialog warningDialog("PSPA :: verification des sections", " bad section definition 1 !", GWt_dialog::Error,true,true); 238 265 warningDialog.exec(); 239 266 return false; 240 267 } 241 268 242 (*itr)->debut->setText(currentString); 269 sections[a]->setFirstElementCurrentSelection(currentString); 270 243 271 // fin 244 string finString = (*itr)->fin->text().toUTF8();272 string finString = sections[a]->getLastElementCurrentText().toUTF8(); 245 273 246 274 int numeroFin = dtmanage_->getNumeroFromElementLabel( finString); … … 248 276 if ( numeroFin < current || numeroFin > dtmanage_->getBeamLineSize()) 249 277 { 250 GWt_dialog warningDialog("PSPA : Checking of sections", " bad section definition !", GWt_dialog::Error, true,true);278 GWt_dialog warningDialog("PSPA : Checking of sections", " bad section definition 2 !", GWt_dialog::Error, true,true); 251 279 warningDialog.exec(); 252 280 return false; … … 258 286 } 259 287 // exec_go_->setDisabled(false); 288 289 if (!areDataCoherent()) { 290 exec_go_->disable(); 291 } else { 292 exec_go_->enable(); 293 } 294 260 295 return true; 261 296 } … … 265 300 { 266 301 bool caMarche = true; 267 trivaluedBool tbResume = TBoolOk; 302 303 // initialize dataManager 268 304 dtmanage_->initializeExecution(); 269 string diagnostic; 270 271 list<GWt_sectionToExecute*>::iterator itr; 272 for(itr = selectedSections_.begin(); itr != selectedSections_.end(); itr++) 273 { 274 string debString = (*itr)->debut->text().toUTF8(); 275 string finString = (*itr)->fin->text().toUTF8(); 276 277 int debut = dtmanage_->getNumeroFromElementLabel(debString); 278 int fin = dtmanage_->getNumeroFromElementLabel(finString); 279 nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() ); 280 dtmanage_->addSectionToExecute(debut,fin,prog); 281 282 // check sections 283 for (int i=debut-1; i<fin; i++) { 284 if (pspa_->getBeamLine()) { 285 if (pspa_->getBeamLine()->getAbstractElement(i)) { 286 trivaluedBool tb = pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(prog.getString()); 287 if (tb == TBoolError ) { 288 diagnostic += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementName() + " is not allowed with "+ prog.getString()+"\n "; 289 caMarche = false; 290 tbResume = tb; 291 } else if ( tb == TBoolIgnore ) { 292 diagnostic += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementName() + " will be ignored by "+ prog.getString()+"\n "; 293 if ( tbResume != TBoolError ) tbResume = tb; 294 } else { 295 pspa_->getBeamLine()->update(i); 296 } 297 } 298 } 305 306 // intialize User Interface 307 if (pspa_->getBeamLine()) { 308 pspa_->getBeamLine()->initializeSoftwares(); 309 } 310 311 string diagnosticErrors; 312 string diagnosticWarnings; 313 314 for (int a = 0; a< sections.size(); a++) 315 { 316 string debString = sections[a]->getFirstElementCurrentText().toUTF8(); 317 string finString = sections[a]->getLastElementCurrentText().toUTF8(); 318 319 int debut = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(debString)+1; // FIXME : Should NOT be +1 320 int fin = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(finString)+1; // FIXME : Should NOT be +1 321 322 nomDeLogiciel prog = nomDeLogiciel ( sections[a]->getSoftwareCurrentText().toUTF8()); 323 dtmanage_->addSectionToExecute(pspa_->getBeamLine()->getAbstractElement(debut), 324 debut, 325 pspa_->getBeamLine()->getAbstractElement(fin), 326 fin, 327 dtmanage_->createSoftwareConnexion(prog)); 328 329 diagnosticErrors = ""; 330 diagnosticWarnings = ""; 331 332 // check sections 333 for (int i=debut-1; i<fin; i++) { 334 if (pspa_->getBeamLine()) { 335 if (pspa_->getBeamLine()->getAbstractElement(i)) { 336 trivaluedBool tb = pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(prog.getString()); 337 if (tb == TBoolError ) { 338 diagnosticErrors += pspa_->getBeamLine()->getAbstractElement(i)->getLabel() + " is not allowed with "+ prog.getString()+"<br /> "; 339 340 caMarche = false; 341 342 // intialize thissoftware 343 pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(nomDeLogiciel::unknownSoftware); 344 345 } else if ( tb == TBoolIgnore ) { 346 diagnosticWarnings += pspa_->getBeamLine()->getAbstractElement(i)->getLabel() + " will be ignored by "+ prog.getString()+"<br /> "; 347 348 349 } 350 pspa_->getBeamLine()->update(i); 351 } 299 352 } 300 353 } 301 302 if ( tbResume == TBoolError ) { 303 GWt_dialog calculDialog("PSPA check execute : ERROR", diagnostic , GWt_dialog::Error,true,true); 304 calculDialog.exec(); 305 } else if (tbResume == TBoolIgnore ) { 306 GWt_dialog calculDialog("PSPA check execute : WARNING", diagnostic , GWt_dialog::Warning,false,true); 307 calculDialog.exec(); 308 } 309 310 /* 311 } else if ( essai == warning ) { 312 GWt_dialog calculDialog("PSPA check execute : warning ", diagnostic , GWt_dialog::Warning, false,true); 313 calculDialog.exec(); 314 */ 354 // set errors and warnings 355 sections[a]->setErrors(diagnosticErrors); 356 sections[a]->setWarnings(diagnosticWarnings); 357 } 315 358 316 359 return caMarche; … … 319 362 void GWt_softwarePanel::deleteSectionToExecuteW() 320 363 { 321 if ( selectedSections_.empty() ) return; 322 // disableSectionExecute(); 323 selectedSections_.back()->ligneDeWidget->clear(); 324 delete selectedSections_.back()->ligneDeWidget; 325 selectedSections_.pop_back(); 326 } 327 328 329 void GWt_softwarePanel::updateSelections() 330 { 331 string premierText, dernierText; 332 if ( selectedSections_.size() > 0 ) 333 { 334 premierText = dtmanage_->getLabelFromElementNumero(1); 335 dernierText = dtmanage_->getLabelFromElementNumero( dtmanage_->getBeamLineSize() ); 336 (*selectedSections_.begin())->debut->setText(premierText); 337 (*selectedSections_.begin())->fin->setText(dernierText); 338 } 339 340 cout << "PspaApplication::updateSelections(): " << premierText << " ââ " << dernierText << endl; 341 } 342 343 344 string GWt_softwarePanel::getSelection() 364 if ( dtmanage_->getJobListSize() == 0 ) return; 365 // delete from dataManager 366 dtmanage_->clearSectionToExecute(dtmanage_->getJobListSize()-1); 367 368 // delete from User Interface 369 sections.pop_back(); 370 } 371 372 373 void GWt_softwarePanel::updateSections() 374 { 375 // update all sections in order to manage new/deleted items 376 for (int a = 0; a< sections.size(); a++) { 377 fillComboWithElements(sections[a]->getFirstElement()); 378 fillComboWithElements(sections[a]->getLastElement()); 379 } 380 if (sections.size() == 0) { 381 return; 382 } 383 // the first element will always be the first element of the beamLine 384 sections[0]->getFirstElement()->setCurrentIndex(0); 385 386 // the last element will always be the last element of the beamLine 387 sections[sections.size()-1]->getLastElement()->setCurrentIndex(sections[sections.size()-1]->getLastElement()->count()); 388 389 // set default values 390 391 // update 392 updateSectionSelection(); 393 } 394 395 396 397 /* 398 string GWt_softwarePanel::getSelection() 345 399 { 346 400 list<GWt_sectionToExecute*>::iterator itr = selectedSections_.begin(); … … 348 402 return str; 349 403 } 350 404 */ 351 405 352 406 void GWt_softwarePanel::executer() 353 407 { 354 408 355 if ( !updateSectionSelection() ) return; 356 357 358 if (!areDataCoherent()) { 359 // GWt_dialog warningDialog("PSPA : verification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true); 360 // warningDialog.exec(); 361 // exec_go_->setDisabled(true); 409 if (!areDataCoherent()) { 410 // GWt_dialog warningDialog("PSPA : verification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true); 411 // warningDialog.exec(); 412 // exec_go_->setDisabled(true); 362 413 return; 363 364 414 } 415 365 416 // GWt_console* console = NULL; 366 417 // if (static_cast<GWt_console*> (wApp->findWidget ("console"))) { … … 385 436 pspa_->faireDessin(); 386 437 } 438 439 440 void GWt_softwarePanel::fillComboWithElements(Wt::WComboBox* cBox) { 441 if (cBox == NULL) return; 442 443 // get the last item selected 444 WString selectedString = cBox->currentText (); 445 cBox->clear(); 446 447 for (int a=0; a< pspa_->getBeamLine()->getBeamLineSize(); a++) { 448 abstractElement* abs = pspa_->getBeamLine()->getAbstractElement(a); 449 if (abs != NULL){ 450 cBox->addItem(abs->getLabel()); 451 } 452 } 453 454 for (int a=0; a<cBox->count(); a++) { 455 if (cBox->itemText (a) == selectedString) { 456 cBox->setCurrentIndex(a); 457 } 458 } 459 } 460 461 462 void GWt_softwarePanel::fillComboWithSoftwares(Wt::WComboBox* cBox) { 463 if (cBox == NULL) return; 464 cBox->clear(); 465 466 unsigned nb = nomDeLogiciel::getNumberOfSoftwares(); 467 unsigned k; 468 for(k = 0; k < nb; k++) { 469 cBox->addItem(nomDeLogiciel(k).getString()); 470 } 471 472 } 473 474 475 Wt::WContainerWidget* GWt_softwarePanel::createAddDeletePushButtons() { 476 477 WContainerWidget* buttonContainer= new WContainerWidget(); 478 479 Wt::WHBoxLayout* buttonContainerLayout = new Wt::WHBoxLayout(); 480 buttonContainerLayout->setContentsMargins(0,0,0,0); 481 // preparation du bouton add 482 WPushButton* exec_add = new WPushButton("+"); 483 exec_add->clicked().connect(this, &GWt_softwarePanel::addSectionToExecuteW); 484 exec_add->setStyleClass("roundButton"); 485 exec_add->setMaximumSize(20,20); 486 exec_add->setToolTip("Add new section"); 487 488 // preparation du bouton delete 489 WPushButton* exec_delete = new WPushButton("-"); 490 // warningsContainer_->setStyleClass("warningsContainer"); 491 exec_delete->clicked().connect(this, &GWt_softwarePanel::deleteSectionToExecuteW); 492 exec_delete->setStyleClass("roundButton"); 493 exec_delete->setMaximumSize(20,20); 494 exec_add->setToolTip("Remove this section"); 495 496 buttonContainerLayout->addWidget(exec_add); 497 buttonContainerLayout->addWidget(exec_delete); 498 499 buttonContainer->setLayout(buttonContainerLayout); 500 501 return buttonContainer; 502 }
Note: See TracChangeset
for help on using the changeset viewer.