Changeset 343 in PSPA for Interface_Web/trunk/pspaWT/sources/userInterface/src
- Timestamp:
- Feb 26, 2013, 2:38:17 PM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT/sources/userInterface/src
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElement.cc
r322 r343 14 14 #include "GWt_beam.h" 15 15 #include "GWt_fit.h" 16 #include "GWt_snapshot.h" 16 17 #include "GWt_draggableImage.h" 17 18 #include "GWt_ligneFaisceau.h" … … 50 51 string* GWt_abstractElement::beginDialog() 51 52 { 52 string* param = abstractElement_-> getParametersString(); 53 54 if ( param == NULL ) 53 string* param = abstractElement_-> getParametersString(); 54 55 if ( param == NULL ) 56 { 57 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 58 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 59 console->addConsoleMessage(" GWt_abstractElement::beginDialog : empty parameter set for element " + abstractElement_->getNomdElement().getElementName()); 60 } 61 } 62 // int compteur = -1; 63 64 // int nbparam = atoi(param[++compteur].c_str()); 65 int nbparam = atoi(param->c_str()); 66 if ( nbparam != abstractElement_->getNbParams()) 55 67 { 56 68 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 57 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 58 console->addConsoleMessage(" GWt_abstractElement::beginDialog : empty parameter set for element " + abstractElement_->getNomdElement().getElementName()); 59 } 60 } 61 // int compteur = -1; 62 63 // int nbparam = atoi(param[++compteur].c_str()); 64 int nbparam = atoi(param->c_str()); 65 if ( nbparam != abstractElement_->getNbParams()) 66 { 67 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 68 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 69 console->addConsoleMessage(" element seems not to be a " + abstractElement_->getNomdElement().getElementName()); 70 } 71 } 72 73 dialog_ = new WDialog("element " + abstractElement_->getNomdElement().getElementName()); 69 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 70 console->addConsoleMessage(" element seems not to be a " + abstractElement_->getNomdElement().getElementName()); 71 } 72 } 73 74 dialog_ = new WDialog("element " + abstractElement_->getNomdElement().getElementName()); 74 75 new WText(" label of the element : ",dialog_->contents()); 75 76 // labelEdit_ = new WLineEdit(param[++compteur].c_str(), dialog_->contents()); … … 88 89 void GWt_abstractElement::clicked() 89 90 { 90 91 91 initilializeDialog(); 92 dialog_->show(); 92 93 } 93 94 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElementFactory.cc
r289 r343 9 9 #include "GWt_abstractElementFactory.h" 10 10 11 GWt_abstractElementFactory::GWt_abstractElementFactory() 12 :isDriftElementEnable(false), 13 isRFGunElementEnable(false), 14 isCellElementEnable(false), 15 isBendElementEnable(false), 16 isSolenoElementEnable(false), 17 isBeamElementEnable(false), 18 isFitElementEnable(false), 19 isSnapshotElementEnable(false) 20 {} 11 21 12 GWt_abstractElementFactory::GWt_abstractElementFactory() 13 :isDriftElementEnable(false), 14 isRFGunElementEnable(false), 15 isCellElementEnable(false), 16 isBendElementEnable(false), 17 isSolenoElementEnable(false), 18 isBeamElementEnable(false), 19 isFitElementEnable(false) 22 GWt_abstractElementFactory::~GWt_abstractElementFactory() 20 23 { 21 24 isDriftElementEnable = false; 25 isRFGunElementEnable = false; 26 isCellElementEnable = false; 27 isBendElementEnable = false; 28 isSolenoElementEnable = false; 29 isBeamElementEnable = false; 30 isFitElementEnable = false; 31 isSnapshotElementEnable = false; 22 32 } 23 33 24 25 GWt_abstractElementFactory::~GWt_abstractElementFactory() { 26 isDriftElementEnable = false; 27 isRFGunElementEnable = false; 28 isCellElementEnable = false; 29 isBendElementEnable = false; 30 isSolenoElementEnable = false; 31 isBeamElementEnable = false; 32 isFitElementEnable = false; 34 GWt_drift* GWt_abstractElementFactory::createDriftElement() 35 { 36 if (isDriftElementEnable) { 37 return new GWt_drift(); 38 } 39 return NULL; 33 40 } 34 41 35 36 GWt_drift* GWt_abstractElementFactory::createDriftElement(){37 if (isDriftElementEnable) {38 return new GWt_drift();39 40 42 GWt_rfgun* GWt_abstractElementFactory::createRFGunElement() 43 { 44 if (isRFGunElementEnable) { 45 return new GWt_rfgun(); 46 } 47 return NULL; 41 48 } 42 49 43 44 GWt_rfgun* GWt_abstractElementFactory::createRFGunElement(){45 if (isRFGunElementEnable) {46 return new GWt_rfgun();47 48 50 GWt_cell* GWt_abstractElementFactory::createCellElement() 51 { 52 if (isCellElementEnable) { 53 return new GWt_cell(); 54 } 55 return NULL; 49 56 } 50 57 51 GWt_cell* GWt_abstractElementFactory::createCellElement() { 52 if (isCellElementEnable) { 53 return new GWt_cell(); 54 } 55 return NULL; 58 GWt_bend* GWt_abstractElementFactory::createBendElement() 59 { 60 if (isBendElementEnable) { 61 return new GWt_bend(); 62 } 63 return NULL; 56 64 } 57 58 59 GWt_bend* GWt_abstractElementFactory::createBendElement() {60 if (isBendElementEnable) {61 return new GWt_bend();62 }63 return NULL;64 }65 66 65 67 66 GWt_soleno* GWt_abstractElementFactory::createSolenoElement() 68 67 { 69 70 71 72 68 if (isSolenoElementEnable) { 69 return new GWt_soleno(); 70 } 71 return NULL; 73 72 } 74 73 75 GWt_beam* GWt_abstractElementFactory::createBeamElement() { 76 if (isBeamElementEnable) { 77 return new GWt_beam(); 78 } 79 return NULL; 74 GWt_beam* GWt_abstractElementFactory::createBeamElement() 75 { 76 if (isBeamElementEnable) { 77 return new GWt_beam(); 78 } 79 return NULL; 80 80 } 81 81 82 83 GWt_fit* GWt_abstractElementFactory::createFitElement(){84 85 86 87 82 GWt_fit* GWt_abstractElementFactory::createFitElement() 83 { 84 if (isFitElementEnable) { 85 return new GWt_fit(); 86 } 87 return NULL; 88 88 } 89 89 90 vector <GWt_abstractElement*> GWt_abstractElementFactory::getAllElements(){ 91 vector <GWt_abstractElement*> elems; 92 if (isDriftElementEnable) { 93 elems.push_back(new GWt_drift()); 94 } 95 if (isBeamElementEnable) { 96 elems.push_back(new GWt_beam()); 97 } 98 if (isBendElementEnable) { 99 elems.push_back(new GWt_bend()); 100 } 101 if (isCellElementEnable) { 102 elems.push_back(new GWt_cell()); 103 } 104 if (isFitElementEnable) { 105 elems.push_back(new GWt_fit()); 106 } 107 if (isRFGunElementEnable) { 108 elems.push_back(new GWt_rfgun()); 109 } 110 if (isSolenoElementEnable) { 111 elems.push_back(new GWt_soleno()); 112 } 113 return elems; 90 GWt_snapshot* GWt_abstractElementFactory::createSnapshotElement() 91 { 92 if (isSnapshotElementEnable) { 93 return new GWt_snapshot(); 94 } 95 return NULL; 114 96 } 97 98 vector <GWt_abstractElement*> GWt_abstractElementFactory::getAllElements() 99 { 100 vector <GWt_abstractElement*> elems; 101 if (isDriftElementEnable) { 102 elems.push_back(new GWt_drift()); 103 } 104 if (isBeamElementEnable) { 105 elems.push_back(new GWt_beam()); 106 } 107 if (isBendElementEnable) { 108 elems.push_back(new GWt_bend()); 109 } 110 if (isCellElementEnable) { 111 elems.push_back(new GWt_cell()); 112 } 113 if (isFitElementEnable) { 114 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 } 122 if (isSnapshotElementEnable) { 123 elems.push_back(new GWt_snapshot()); 124 } 125 126 return elems; 127 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_dropZoneLigneFaisceau.cc
r309 r343 9 9 #include "nomdElements.h" 10 10 11 12 13 11 GWt_dropZoneLigneFaisceau::GWt_dropZoneLigneFaisceau( PspaApplication* pspa) 14 : WContainerWidget(){ 15 initialise(pspa); 12 : WContainerWidget() 13 { 14 initialise(pspa); 16 15 } 17 18 16 19 17 GWt_dropZoneLigneFaisceau::~GWt_dropZoneLigneFaisceau() … … 21 19 } 22 20 23 24 21 void GWt_dropZoneLigneFaisceau::initialise( PspaApplication* pspa) 25 22 { 26 27 // connect mouse events 28 29 mouseWentOver().connect(this, &GWt_dropZoneLigneFaisceau::mouseOver); 30 mouseWentUp().connect(this, &GWt_dropZoneLigneFaisceau::mouseUp); 31 mouseWentDown().connect(this, &GWt_dropZoneLigneFaisceau::mouseDown); 32 mouseWentOut().connect(this, &GWt_dropZoneLigneFaisceau::mouseOut); 33 mouseDragged().connect(this, &GWt_dropZoneLigneFaisceau::mouseIsDragged); 34 35 // accept drops 36 37 vector <GWt_abstractElement*> elems = pspa->getAbstractElementFactory()->getAllElements(); 38 for (int a = 0; a< elems.size(); a++) { 39 acceptDrops(elems[a]->getMimeType()); 40 } 41 setMinimumSize(10,32); 23 24 // connect mouse events 25 mouseWentOver().connect(this, &GWt_dropZoneLigneFaisceau::mouseOver); 26 mouseWentUp().connect(this, &GWt_dropZoneLigneFaisceau::mouseUp); 27 mouseWentDown().connect(this, &GWt_dropZoneLigneFaisceau::mouseDown); 28 mouseWentOut().connect(this, &GWt_dropZoneLigneFaisceau::mouseOut); 29 mouseDragged().connect(this, &GWt_dropZoneLigneFaisceau::mouseIsDragged); 30 31 // accept drops 32 vector <GWt_abstractElement*> elems = pspa->getAbstractElementFactory()->getAllElements(); 33 for(int a = 0; a < elems.size(); a++) { 34 acceptDrops(elems[a]->getMimeType()); 35 } 36 setMinimumSize(10,32); 42 37 } 43 44 38 45 39 void GWt_dropZoneLigneFaisceau::mouseOver(const WMouseEvent& e) … … 49 43 void GWt_dropZoneLigneFaisceau::mouseOut(const WMouseEvent& e) 50 44 { 51 45 decorationStyle().setCursor(ArrowCursor); 52 46 } 53 47 54 48 void GWt_dropZoneLigneFaisceau::mouseIsDragged(const WMouseEvent& e) 55 49 { 56 50 decorationStyle().setCursor(OpenHandCursor); 57 51 } 58 52 … … 67 61 void GWt_dropZoneLigneFaisceau::dropEvent(WDropEvent evt) 68 62 { 69 70 71 72 73 74 75 76 77 78 79 80 63 // get LigneFaiseau widget and add new elementLigneFaiseau 64 GWt_LigneFaisceau* ligneFaisceau = NULL; 65 if ( static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) { 66 ligneFaisceau = static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau")); 67 } else { 68 return; 69 } 70 71 // get the type of element 72 nomdElements e(evt.mimeType()); 73 typedElement eType = e.getElementType(); 74 ligneFaisceau->addElement(eType, this); 81 75 } 82 76 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc
r336 r343 12 12 #include "GWt_beam.h" 13 13 #include "GWt_fit.h" 14 #include "GWt_snapshot.h" 14 15 15 16 … … 26 27 #define PSPA_DEBUG 1 27 28 28 29 29 GWt_elementLigneFaisceau::GWt_elementLigneFaisceau(PspaApplication* pspa) 30 : WContainerWidget(), 31 firstTimeInsertMessage_(NULL), 32 dropZoneLeft_(NULL), 33 dropZoneRight_(NULL), 34 GWt_abstractElement_(NULL), 35 elementLabel_(NULL), 36 pspa_(pspa) 37 { 38 39 initialize_ligneFaisceau(inconnu); 30 : WContainerWidget(), 31 firstTimeInsertMessage_(NULL), 32 dropZoneLeft_(NULL), 33 dropZoneRight_(NULL), 34 GWt_abstractElement_(NULL), 35 elementLabel_(NULL), 36 pspa_(pspa) 37 { 38 initialize_ligneFaisceau(inconnu); 40 39 } 41 40 42 41 43 42 GWt_elementLigneFaisceau::GWt_elementLigneFaisceau(typedElement type, PspaApplication* pspa) 44 : WContainerWidget(), 45 firstTimeInsertMessage_(NULL), 46 dropZoneLeft_(NULL), 47 dropZoneRight_(NULL), 48 GWt_abstractElement_(NULL), 49 elementLabel_(NULL), 50 pspa_(pspa) 51 { 52 // set the css name 53 setObjectName("elementLigneFaisceau"); 54 55 initialize_ligneFaisceau(type); 56 } 57 43 : WContainerWidget(), 44 firstTimeInsertMessage_(NULL), 45 dropZoneLeft_(NULL), 46 dropZoneRight_(NULL), 47 GWt_abstractElement_(NULL), 48 elementLabel_(NULL), 49 pspa_(pspa) 50 { 51 // set the css name 52 setObjectName("elementLigneFaisceau"); 53 initialize_ligneFaisceau(type); 54 } 58 55 59 56 void GWt_elementLigneFaisceau::initialize_ligneFaisceau(typedElement eType) 60 57 { 61 58 62 cout<<"new GWt_elementLigneFaisceau : "<< this << endl; 63 64 // set layout 65 // +----------+--------+---------+ 66 // | (--->) | ELEM | (-----) | 67 // +----------+--------+---------+ 68 // | NAME | 69 // +----------+--------+---------+ 70 71 72 WGridLayout *gridLayout = new WGridLayout(); 73 74 gridLayout->setContentsMargins(0,0,0,0); 75 gridLayout->setHorizontalSpacing (0); 76 gridLayout->setVerticalSpacing (0); 77 78 // add first line : initialize arrow and link images 79 dropZoneLeft_ = new GWt_dropZoneLigneFaisceau(pspa_); 80 dropZoneRight_ = new GWt_dropZoneLigneFaisceau(pspa_); 81 82 // change object name in order to manage css : 83 dropZoneLeft_->resize(10,30); 84 dropZoneRight_->resize(10,30); 85 86 gridLayout->addWidget (dropZoneLeft_,0,0); 87 gridLayout->addWidget (dropZoneRight_,0,2); 88 89 // add the image if present 90 91 switch ( eType ) { 92 case RFgun : 93 GWt_abstractElement_ = new GWt_rfgun(this); 94 break; 95 case drift : 96 GWt_abstractElement_ = new GWt_drift(this); 97 break; 98 case cell : 99 GWt_abstractElement_ = new GWt_cell(this); 100 break; 101 case bend : 102 GWt_abstractElement_ = new GWt_bend(this); 103 break; 104 case soleno : 105 GWt_abstractElement_ = new GWt_soleno(this); 106 break; 107 case beam : 108 GWt_abstractElement_ = new GWt_beam(this); 109 break; 110 case fit : 111 GWt_abstractElement_ = new GWt_fit(this); 112 break; 113 case inconnu : 114 GWt_abstractElement_ = NULL; 59 cout<<"new GWt_elementLigneFaisceau : "<< this << endl; 60 61 // set layout 62 // +----------+--------+---------+ 63 // | (--->) | ELEM | (-----) | 64 // +----------+--------+---------+ 65 // | NAME | 66 // +----------+--------+---------+ 67 68 69 WGridLayout *gridLayout = new WGridLayout(); 70 71 gridLayout->setContentsMargins(0,0,0,0); 72 gridLayout->setHorizontalSpacing(0); 73 gridLayout->setVerticalSpacing(0); 74 75 // add first line : initialize arrow and link images 76 dropZoneLeft_ = new GWt_dropZoneLigneFaisceau(pspa_); 77 dropZoneRight_ = new GWt_dropZoneLigneFaisceau(pspa_); 78 79 // change object name in order to manage css : 80 dropZoneLeft_->resize(10,30); 81 dropZoneRight_->resize(10,30); 82 83 gridLayout->addWidget (dropZoneLeft_,0,0); 84 gridLayout->addWidget (dropZoneRight_,0,2); 85 86 // add the image if present 87 88 switch ( eType ) { 89 case RFgun : 90 GWt_abstractElement_ = new GWt_rfgun(this); 91 break; 92 case drift : 93 GWt_abstractElement_ = new GWt_drift(this); 94 break; 95 case cell : 96 GWt_abstractElement_ = new GWt_cell(this); 97 break; 98 case bend : 99 GWt_abstractElement_ = new GWt_bend(this); 100 break; 101 case soleno : 102 GWt_abstractElement_ = new GWt_soleno(this); 103 break; 104 case beam : 105 GWt_abstractElement_ = new GWt_beam(this); 106 break; 107 case fit : 108 GWt_abstractElement_ = new GWt_fit(this); 109 break; 110 case snapshot : 111 GWt_abstractElement_ = new GWt_snapshot(this); 112 break; 113 case inconnu : 114 GWt_abstractElement_ = NULL; 115 } 116 117 if (GWt_abstractElement_ != NULL) { 118 gridLayout->addWidget(GWt_abstractElement_,0,1); 119 GWt_abstractElement_->setMaximumSize(32,32); 120 GWt_abstractElement_->setMinimumSize(32,32); 121 } 122 123 // add second line 124 if (GWt_abstractElement_ == NULL) { 125 elementLabel_ = new WText(); 126 } else { 127 elementLabel_ = new WText(GWt_abstractElement_->getAbstractElement()->getLabel()); 115 128 } 116 if (GWt_abstractElement_ != NULL) { 117 gridLayout->addWidget (GWt_abstractElement_,0,1); 118 GWt_abstractElement_->setMaximumSize(32,32); 119 GWt_abstractElement_->setMinimumSize(32,32); 120 } 121 122 // add second line 123 if (GWt_abstractElement_ == NULL) { 124 elementLabel_ = new WText(); 125 } else { 126 elementLabel_ = new WText(GWt_abstractElement_->getAbstractElement()->getLabel()); 127 } 128 129 gridLayout->addWidget (elementLabel_,1,0,1,3,Wt::AlignCenter |Wt::AlignMiddle); 129 130 gridLayout->addWidget(elementLabel_,1,0,1,3,Wt::AlignCenter |Wt::AlignMiddle); 130 131 131 132 gridLayout->setColumnStretch (0,1); … … 141 142 } 142 143 143 144 144 void GWt_elementLigneFaisceau::removeDone(GWt_abstractElement* gw) 145 145 { 146 147 148 149 150 } 151 152 153 void GWt_elementLigneFaisceau::addElement(GWt_abstractElement* elem) {154 155 156 157 158 159 160 161 162 163 164 165 146 if (messageDropZone_->result() == WDialog::Accepted) { 147 // FIXME 148 // removeDropZone(); 149 } 150 } 151 152 153 void GWt_elementLigneFaisceau::addElement(GWt_abstractElement* elem) 154 { 155 clear(); 156 GWt_abstractElement_ = elem; 157 addWidget(GWt_abstractElement_); 158 if (static_cast <WContainerWidget*> (parent())) { 159 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 160 WBoxLayout* layout = ((WBoxLayout*)(wc->layout())); 161 layout->setStretchFactor(this,0); 162 } 163 164 165 firstTimeInsertMessage_ = NULL; 166 166 dropZoneLeft_ = NULL; 167 167 } … … 169 169 170 170 std::string GWt_elementLigneFaisceau::getElementNumberInBeamLine(nomdElements elem){ 171 171 string str = ""; 172 172 173 173 if (static_cast <WContainerWidget*> (parent())) { … … 210 210 211 211 void GWt_elementLigneFaisceau::setElementLabel(std::string label) { 212 if (elementLabel_) { 213 elementLabel_->setText(label); 214 } 215 } 216 212 if (elementLabel_) { 213 elementLabel_->setText(label); 214 } 215 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc
r323 r343 3 3 #include "GWt_elementLigneFaisceau.h" 4 4 #include "GWt_ligneFaisceau.h" 5 5 6 #include "GWt_drift.h" 6 7 #include "GWt_rfgun.h" … … 15 16 16 17 GWt_LigneFaisceau::GWt_LigneFaisceau(PspaApplication* ps) : 17 WContainerWidget(), 18 pspa_(ps), 19 nObjets_(NULL) 20 { 21 22 cout<<"GWt_LigneFaisceau::GWt_LigneFaisceau() %d"<< this << "<---------------"<< endl; 23 24 ligneFaisceauLayout_ = new WHBoxLayout(); 25 // decorationStyle().setBackgroundColor (WColor(245,245,245)); 26 setLayout(ligneFaisceauLayout_); 27 ligneFaisceauLayout_->setContentsMargins(0,0,0,0); 28 ligneFaisceauLayout_->setSpacing (0); 29 30 int nElts= nomdElements::getNumberOfElements(); 31 nObjets_= new Compteur[nElts]; 32 33 // set the object name 34 setObjectName("ligneFaisceau"); 35 36 37 clear(); 38 } 39 40 41 void GWt_LigneFaisceau::clear() { 42 ligneFaisceauLayout_->clear(); 43 44 // add the first drop zone 45 decorationStyle().setBorder (WBorder (WBorder::Dotted)); 46 allDropZone_ = new GWt_dropZoneLigneFaisceau(pspa_); 47 WVBoxLayout* fit = new WVBoxLayout(); 48 allDropZone_->setLayout(fit); 49 50 fit->addWidget(new WText("Drag elements here...."),1,Wt::AlignCenter |Wt::AlignMiddle); 51 ligneFaisceauLayout_->addWidget(allDropZone_,1); 18 WContainerWidget(), 19 pspa_(ps), 20 nObjets_(NULL) 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_); 28 ligneFaisceauLayout_->setContentsMargins(0,0,0,0); 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 38 clear(); 39 } 40 41 42 void GWt_LigneFaisceau::clear() 43 { 44 ligneFaisceauLayout_->clear(); 45 46 // add the first drop zone 47 decorationStyle().setBorder (WBorder (WBorder::Dotted)); 48 allDropZone_ = new GWt_dropZoneLigneFaisceau(pspa_); 49 WVBoxLayout* fit = new WVBoxLayout(); 50 allDropZone_->setLayout(fit); 51 52 fit->addWidget(new WText("Drag elements here...."),1,Wt::AlignCenter |Wt::AlignMiddle); 53 ligneFaisceauLayout_->addWidget(allDropZone_,1); 52 54 } 53 55 54 56 55 57 GWt_abstractElement* GWt_LigneFaisceau::addElement(typedElement eType){ 56 return addElement(eType,NULL); 57 } 58 59 60 61 GWt_abstractElement* GWt_LigneFaisceau::addElement(typedElement eType, GWt_dropZoneLigneFaisceau* dropContainer ){ 62 63 GWt_abstractElement* GWtAbstractElem = NULL; 64 65 cout << " Entree addElement element " << nomdElements::getLabelFromType(eType) << endl; 66 67 int nElements= nomdElements ::getNumberOfElements(); 68 nObjets_= new Compteur[nElements]; 69 70 // 3 cases : 71 // -dropContainer is an element of the ligneFaisceauLayout_ 72 // -dropContainer is an element of the GWt_elementLigneFaisceau_ 73 // -dropContainer is NULL, insert in the last element 74 75 if(eType == inconnu) { 76 cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl; 77 return NULL; 78 } 79 80 // add the element to the datamanager 81 82 // first time we insert an element : 83 GWt_elementLigneFaisceau* firstElemIsElement = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(0)->widget()); 84 if ((ligneFaisceauLayout_->count() == 1) && (!firstElemIsElement)) { 85 int index = indexOf (dropContainer); 86 if ((index != -1) || (dropContainer == NULL)){ // found 87 // remove global drop zone 88 ligneFaisceauLayout_->clear(); 89 90 // add first element 91 GWt_elementLigneFaisceau* elemLigneFaisceau = new GWt_elementLigneFaisceau(eType, pspa_); 92 93 ligneFaisceauLayout_->addWidget(elemLigneFaisceau,1); 94 GWtAbstractElem = elemLigneFaisceau->getGWt_AbstractElement(); 95 // remove arrow from begin and end 96 97 } else { // error 98 return NULL; 99 } 58 return addElement(eType,NULL); 59 } 60 61 GWt_abstractElement* GWt_LigneFaisceau::addElement(typedElement eType, GWt_dropZoneLigneFaisceau* dropContainer ) 62 { 63 64 GWt_abstractElement* GWtAbstractElem = NULL; 65 66 cout << " Entree addElement element " << nomdElements::getLabelFromType(eType) << endl; 67 68 int nElements= nomdElements ::getNumberOfElements(); 69 nObjets_= new Compteur[nElements]; 70 71 // 3 cases : 72 // -dropContainer is an element of the ligneFaisceauLayout_ 73 // -dropContainer is an element of the GWt_elementLigneFaisceau_ 74 // -dropContainer is NULL, insert in the last element 75 76 if(eType == inconnu) { 77 cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl; 78 return NULL; 79 } 80 81 // add the element to the datamanager 82 83 // first time we insert an element : 84 GWt_elementLigneFaisceau* firstElemIsElement = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(0)->widget()); 85 if ((ligneFaisceauLayout_->count() == 1) && (!firstElemIsElement)) { 86 int index = indexOf (dropContainer); 87 if ((index != -1) || (dropContainer == NULL)){ // found 88 // remove global drop zone 89 ligneFaisceauLayout_->clear(); 90 91 // add first element 92 GWt_elementLigneFaisceau* elemLigneFaisceau = new GWt_elementLigneFaisceau(eType, pspa_); 93 94 ligneFaisceauLayout_->addWidget(elemLigneFaisceau,1); 95 GWtAbstractElem = elemLigneFaisceau->getGWt_AbstractElement(); 96 // remove arrow from begin and end 97 98 } else { // error 99 return NULL; 100 } 101 } else { 102 int index = -1; 103 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 104 GWt_elementLigneFaisceau* elem = static_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ()); 105 if (elem) { 106 if (elem->getDropZoneLeft() == dropContainer) { 107 index = a; 108 } 109 if (elem->getDropZoneRight() == dropContainer) { 110 index = a+1; 111 } 112 } 113 114 } 115 116 117 // ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau(ptr),0); 118 GWt_elementLigneFaisceau* elemLigneFaisceau = new GWt_elementLigneFaisceau(eType, pspa_); 119 if (index != -1) { 120 // nObjets_[ptr->getNomdElement().getElementType()].incr(); 121 ligneFaisceauLayout_->insertWidget(index,elemLigneFaisceau,1); 122 GWtAbstractElem = elemLigneFaisceau->getGWt_AbstractElement(); 100 123 } else { 101 int index = -1; 102 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 103 GWt_elementLigneFaisceau* elem = static_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ()); 104 if (elem) { 105 if (elem->getDropZoneLeft() == dropContainer) { 106 index = a; 107 } 108 if (elem->getDropZoneRight() == dropContainer) { 109 index = a+1; 110 } 111 } 112 113 } 124 ligneFaisceauLayout_->addWidget(elemLigneFaisceau,1); 125 GWtAbstractElem = elemLigneFaisceau->getGWt_AbstractElement(); 126 } 127 } 128 manageLineFaisceauLayout(); 129 130 return GWtAbstractElem; 131 } 132 133 134 void GWt_LigneFaisceau::manageLineFaisceauLayout() { 135 // special : hide/setVisible arrow : 136 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 137 if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) { 138 139 // update labels 140 elem->getGWt_AbstractElement()->updateLabelAndToolTipWidget(); 141 142 // one element 143 if ((a == 0) && (a == (ligneFaisceauLayout_->count()-1))) { 144 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_transparent"); 145 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_transparent"); 146 147 // first 148 } else if (a == 0){ 149 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_transparent"); 150 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_line"); 151 152 // last 153 } else if (a == (ligneFaisceauLayout_->count()-1)){ 154 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_line"); 155 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_transparent"); 114 156 115 157 116 // ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau(ptr),0); 117 GWt_elementLigneFaisceau* elemLigneFaisceau = new GWt_elementLigneFaisceau(eType, pspa_); 118 if (index != -1) { 119 // nObjets_[ptr->getNomdElement().getElementType()].incr(); 120 ligneFaisceauLayout_->insertWidget(index,elemLigneFaisceau,1); 121 GWtAbstractElem = elemLigneFaisceau->getGWt_AbstractElement(); 122 } else { 123 ligneFaisceauLayout_->addWidget(elemLigneFaisceau,1); 124 GWtAbstractElem = elemLigneFaisceau->getGWt_AbstractElement(); 125 } 126 } 158 // middle elements 159 } else { 160 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_line"); 161 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_line"); 162 } 163 } 164 } 165 166 // insure that there is still the dropzone ! 167 if (ligneFaisceauLayout_->count() == 0) { 168 clear(); 169 } 170 171 pspa_->getExecuteWidget()->updateSelections(); 172 } 173 174 175 176 void GWt_LigneFaisceau::update() { 177 manageLineFaisceauLayout(); 178 } 179 180 181 void GWt_LigneFaisceau::removeElement(GWt_abstractElement* GWt_abstractElement) { 182 if (GWt_abstractElement == NULL) 183 return; 184 185 // remove Widget 186 // - GWt_abstractElement is an element of the GWt_elementLigneFaisceau_ 187 188 int index = -1; 189 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 190 GWt_elementLigneFaisceau* elem = static_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ()); 191 if (elem) { 192 if (elem->getGWt_AbstractElement() == GWt_abstractElement) { 193 index = a; 194 } 195 } 196 } 197 198 if (index != -1) { 199 // remove element from the list 200 // pspa_->getDataManager()->removeElement(GWt_abstractElement->getElement()->getLabel()); 201 202 ligneFaisceauLayout_->removeItem(ligneFaisceauLayout_->itemAt(index)); 203 delete GWt_abstractElement; 204 205 // manage widgets if necessary 127 206 manageLineFaisceauLayout(); 128 129 return GWtAbstractElem; 130 } 131 132 133 void GWt_LigneFaisceau::manageLineFaisceauLayout() { 134 // special : hide/setVisible arrow : 135 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 136 if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) { 137 138 // update labels 139 elem->getGWt_AbstractElement()->updateLabelAndToolTipWidget(); 140 141 // one element 142 if ((a == 0) && (a == (ligneFaisceauLayout_->count()-1))) { 143 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_transparent"); 144 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_transparent"); 145 146 // first 147 } else if (a == 0){ 148 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_transparent"); 149 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_line"); 150 151 // last 152 } else if (a == (ligneFaisceauLayout_->count()-1)){ 153 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_line"); 154 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_transparent"); 155 156 157 // middle elements 158 } else { 159 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_line"); 160 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_line"); 161 } 162 } 163 } 164 165 // insure that there is still the dropzone ! 166 if (ligneFaisceauLayout_->count() == 0) { 167 clear(); 168 } 169 170 pspa_->getExecuteWidget()->updateSelections(); 171 } 172 173 174 175 void GWt_LigneFaisceau::update() { 176 manageLineFaisceauLayout(); 177 } 178 179 180 void GWt_LigneFaisceau::removeElement(GWt_abstractElement* GWt_abstractElement) { 181 if (GWt_abstractElement == NULL) 182 return; 183 184 // remove Widget 185 // - GWt_abstractElement is an element of the GWt_elementLigneFaisceau_ 186 187 int index = -1; 188 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 189 GWt_elementLigneFaisceau* elem = static_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ()); 190 if (elem) { 191 if (elem->getGWt_AbstractElement() == GWt_abstractElement) { 192 index = a; 193 } 194 } 195 } 196 197 if (index != -1) { 198 // remove element from the list 199 // pspa_->getDataManager()->removeElement(GWt_abstractElement->getElement()->getLabel()); 200 201 ligneFaisceauLayout_->removeItem(ligneFaisceauLayout_->itemAt(index)); 202 delete GWt_abstractElement; 203 204 // manage widgets if necessary 205 manageLineFaisceauLayout(); 206 } 207 } 207 208 } 208 209 209 210 210 211 abstractElement* GWt_LigneFaisceau::getAbstractElement(int i){ 211 212 213 214 // i--;215 216 217 218 219 220 221 222 223 224 225 212 int index = 0; 213 214 // first if 1 215 // i--; 216 217 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 218 if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) { 219 if (index == i) { 220 printf("GWt_LigneFaisceau::getAbstractElement %d %s\n",i,elem->getGWt_AbstractElement()->getAbstractElement()->getLabel().c_str()); 221 return elem->getGWt_AbstractElement()->getAbstractElement(); 222 } 223 index ++; 224 } 225 } 226 return NULL; 226 227 } 227 228 228 229 229 230 int GWt_LigneFaisceau::getBeamLineSize() { 230 231 232 233 234 235 236 237 } 238 239 240 vector <abstractElement*> GWt_LigneFaisceau::getAllAbstractElements(){241 242 243 244 245 246 247 248 } 249 231 int count = 0; 232 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 233 if (dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) { 234 count ++; 235 } 236 } 237 return count; 238 } 239 240 vector <abstractElement*> GWt_LigneFaisceau::getAllAbstractElements() 241 { 242 vector <abstractElement*> elems; 243 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 244 if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) { 245 elems.push_back(elem->getGWt_AbstractElement()->getAbstractElement()); 246 } 247 } 248 return elems; 249 } 250 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r341 r343 65 65 abstractElementFactory_->setBeamEnable(true); 66 66 abstractElementFactory_->setFitEnable(true); 67 abstractElementFactory_->setSnapshotEnable(true); 67 68 68 69 // include the styleSheet … … 71 72 dtmanage_ = new dataManager(this); 72 73 // dtmanage_->setWorkingDir(workingDir_); 74 73 75 /* 74 76 * The main layout is a 3x2 grid layout. … … 125 127 126 128 createBeamLine(); 127 129 128 130 WScrollArea* scroll = new WScrollArea(); 129 131 scroll->setWidget(beamLine_); … … 243 245 Wt::WRadioButton *button2= new WRadioButton(" phase space after element"); 244 246 245 choixAbsPhase_ = new WComboBox(); 246 choixAbsPhase_->addItem("x"); 247 choixAbsPhase_->addItem("y"); 248 choixAbsPhase_->addItem("z"); 249 choixAbsPhase_->addItem("xp"); 250 choixAbsPhase_->addItem("yp"); 251 choixAbsPhase_->addItem("dE/E"); 252 choixAbsPhase_->setCurrentIndex(0); 253 254 choixOrdPhase_ = new WComboBox(); 255 choixOrdPhase_->addItem("x"); 256 choixOrdPhase_->addItem("y"); 257 choixOrdPhase_->addItem("z"); 258 choixOrdPhase_->addItem("xp"); 259 choixOrdPhase_->addItem("yp"); 260 choixOrdPhase_->addItem("dE/E"); 261 choixOrdPhase_->setCurrentIndex(3); 262 263 264 247 choixAbsPhase_ = new WComboBox(); 248 choixAbsPhase_->addItem("x"); 249 choixAbsPhase_->addItem("y"); 250 choixAbsPhase_->addItem("z"); 251 choixAbsPhase_->addItem("xp"); 252 choixAbsPhase_->addItem("yp"); 253 choixAbsPhase_->addItem("dE/E"); 254 choixAbsPhase_->setCurrentIndex(0); 255 256 choixOrdPhase_ = new WComboBox(); 257 choixOrdPhase_->addItem("x"); 258 choixOrdPhase_->addItem("y"); 259 choixOrdPhase_->addItem("z"); 260 choixOrdPhase_->addItem("xp"); 261 choixOrdPhase_->addItem("yp"); 262 choixOrdPhase_->addItem("dE/E"); 263 choixOrdPhase_->setCurrentIndex(3); 264 265 265 group_->addButton(button2,2); 266 266 glayout->addWidget(button2,1,1); … … 461 461 choixElementDessin_->clear(); 462 462 choixHistoDessin_->clear(); 463 int nombre = dtmanage_->getBeamLineSize(); 464 cout << " PspaApplication::faireDessin() nb elements : " << nombre << endl;463 464 int nombre = dtmanage_->getBeamLineSize(); 465 465 for(int i = 1; i <= nombre; i++) { 466 choixElementDessin_->addItem(dtmanage_->getLabelFromElementNumero(i)); 467 choixHistoDessin_->addItem(dtmanage_->getLabelFromElementNumero(i)); 466 abstractElement* elPtr = dtmanage_->getElementPointerFromNumero(i); 467 if(elPtr->getNomdElement().getElementType() == snapshot) continue; 468 469 choixElementDessin_->addItem(elPtr->getLabel()); 470 choixHistoDessin_->addItem(elPtr->getLabel()); 468 471 } 469 472 } … … 537 540 envDialog->show(); 538 541 539 // new WText(nameOfCase_ + " : enveloppe", toto);540 542 unsigned nbel = dtmanage_->getBeamLineSize(); 541 543 vector<double> xcor; 542 544 vector<double> ycor; 543 dtmanage_->donneesRmsEnveloppe(type,1, nbel, xcor,ycor); 545 //dtmanage_->donneesRmsEnveloppe(type,1, nbel, xcor,ycor); 546 dtmanage_->donneesRmsEnveloppe(type,nbel,xcor,ycor); 544 547 scatterPlot1D(envDialog->contents(),xcor,ycor); 545 548 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc
r316 r343 21 21 22 22 GWt_softwarePanel::GWt_softwarePanel(dataManager* dataManager,PspaApplication* pspa) 23 : WContainerWidget() { 24 25 dtmanage_ = dataManager; 26 pspa_ = pspa; 27 setMaximumSize(600,150); 28 setMinimumSize(600,150); 29 30 // bouton execute 31 exec_go_ = new WPushButton("execute!"); 32 // exec_go_->setMinimumSize(300,300); 33 exec_go_->setDisabled(true); 34 exec_go_->clicked().connect(this, &GWt_softwarePanel::executer); 35 36 // preparation du bouton add 37 WPushButton* exec_add = new WPushButton("add"); 38 exec_add->clicked().connect(this, &GWt_softwarePanel::addSectionToExecuteW); 39 40 // preparation du bouton delete 41 WPushButton* exec_delete = new WPushButton("delete"); 42 exec_delete->clicked().connect(this, &GWt_softwarePanel::deleteSectionToExecuteW); 43 44 // preparation du bouton push_ok 45 WPushButton* exec_ok = new WPushButton("check/ok"); 46 exec_ok->clicked().connect(this, &GWt_softwarePanel::checkSectionSelection); 47 48 // le panel 49 WPanel *panelLogiciels = new WPanel(this); 50 panelLogiciels->setTitle(" sections of beam Line for executing softwares "); 51 52 contenuSections_ = new WContainerWidget(); 53 contenuSections_->addWidget(exec_add); 54 contenuSections_->addWidget(exec_delete); 55 contenuSections_->addWidget(exec_ok); 56 contenuSections_->addWidget(exec_go_); 57 contenuSections_->addWidget(new WBreak()); 58 contenuSections_->addWidget(new WBreak()); 59 addSectionToExecuteW(); 60 61 panelLogiciels->setCentralWidget(contenuSections_); 62 } 63 23 : WContainerWidget() 24 { 25 dtmanage_ = dataManager; 26 pspa_ = pspa; 27 setMaximumSize(600,150); 28 setMinimumSize(600,150); 29 30 // bouton execute 31 exec_go_ = new WPushButton("execute!"); 32 // exec_go_->setMinimumSize(300,300); 33 exec_go_->setDisabled(true); 34 exec_go_->clicked().connect(this, &GWt_softwarePanel::executer); 35 36 // preparation du bouton add 37 WPushButton* exec_add = new WPushButton("add"); 38 exec_add->clicked().connect(this, &GWt_softwarePanel::addSectionToExecuteW); 39 40 // preparation du bouton delete 41 WPushButton* exec_delete = new WPushButton("delete"); 42 exec_delete->clicked().connect(this, &GWt_softwarePanel::deleteSectionToExecuteW); 43 44 // preparation du bouton push_ok 45 WPushButton* exec_ok = new WPushButton("check/ok"); 46 exec_ok->clicked().connect(this, &GWt_softwarePanel::checkSectionSelection); 47 48 // le panel 49 WPanel *panelLogiciels = new WPanel(this); 50 panelLogiciels->setTitle(" sections of beam Line for executing softwares "); 51 52 contenuSections_ = new WContainerWidget(); 53 contenuSections_->addWidget(exec_add); 54 contenuSections_->addWidget(exec_delete); 55 contenuSections_->addWidget(exec_ok); 56 contenuSections_->addWidget(exec_go_); 57 contenuSections_->addWidget(new WBreak()); 58 contenuSections_->addWidget(new WBreak()); 59 addSectionToExecuteW(); 60 61 panelLogiciels->setCentralWidget(contenuSections_); 62 } 64 63 65 64 GWt_softwarePanel::~GWt_softwarePanel() { 66 65 } 67 66 68 69 67 void GWt_softwarePanel::addSectionToExecuteW() 70 { 71 72 disableSectionExecute(); 73 74 string premierText, dernierText; 75 if(selectedSections_.size() == 0) 76 { 77 premierText = dtmanage_->getLabelFromElementNumero(1); 68 { 69 disableSectionExecute(); 70 71 string premierText, dernierText; 72 if(selectedSections_.size() == 0) { 73 premierText = dtmanage_->getLabelFromElementNumero(1); 74 dernierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize()); 75 } else { 76 dernierText = selectedSections_.back()->fin->text().toUTF8(); 77 int dernierNumero = dtmanage_->getNumeroFromElementLabel(dernierText); 78 dernierNumero++; 79 if ( dernierNumero <= dtmanage_->getBeamLineSize() ) { 80 premierText = dtmanage_->getLabelFromElementNumero(dernierNumero); 81 } else { 82 premierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize()); 83 } 84 dernierText = premierText; 85 } 86 87 // cout << "PspaApplication::addSectionToExecute() : " << premierText << " ââ " << dernierText << endl; 88 89 WContainerWidget* newSection = new WContainerWidget; 90 91 selectedSections_.push_back(new GWt_sectionToExecute); 92 selectedSections_.back()->debut = new WLineEdit(); 93 selectedSections_.back()->debut->setDisabled(true); 94 selectedSections_.back()->debut->setText(premierText); 95 selectedSections_.back()->fin = new WLineEdit(); 96 selectedSections_.back()->fin->changed().connect(this,&GWt_softwarePanel::disableSectionExecute); 97 selectedSections_.back()->fin->setText(dernierText); 98 selectedSections_.back()->selection = new WComboBox(); 99 selectedSections_.back()->ligneDeWidget = newSection; 100 newSection->addWidget(new WText(" from : ")); 101 newSection->addWidget(selectedSections_.back()->debut); 102 newSection->addWidget(new WText(" to : ")); 103 newSection->addWidget(selectedSections_.back()->fin); 104 newSection->addWidget(selectedSections_.back()->selection); 105 106 contenuSections_->addWidget(newSection); 107 unsigned nb = nomDeLogiciel::getNumberOfSoftwares(); 108 unsigned k; 109 for(k = 0; k < nb; k++) { 110 selectedSections_.back()->selection->addItem(nomDeLogiciel(k).getString()); 111 } 112 } 113 114 115 void GWt_softwarePanel::disableSectionExecute() 116 { 117 exec_go_->setDisabled(true); 118 } 119 120 121 void GWt_softwarePanel::checkSectionSelection() 122 { 123 if ( selectedSections_.empty() ) return; 124 125 // traitement de la premiere ligne 126 // on impose le depart du calcul au premier element 127 string premier = dtmanage_->getLabelFromElementNumero(1); 128 (*selectedSections_.begin())->debut->setText(premier); 129 130 string currentString = (*selectedSections_.begin())->fin->text().toUTF8(); 131 int current = dtmanage_->getNumeroFromElementLabel(currentString); 132 133 // si la fin est mal definie on prend toute la config par defaut 134 if ( current <= 0 || current > dtmanage_->getBeamLineSize() ) 135 { 136 current = dtmanage_->getBeamLineSize(); 137 currentString = dtmanage_->getLabelFromElementNumero(current); 138 (*selectedSections_.begin())->fin->setText(currentString); 139 } 140 current++; 141 currentString = dtmanage_->getLabelFromElementNumero(current); 142 143 // traitement des suivantes (on avance d'un cran dans la liste) 144 list<GWt_sectionToExecute*>::iterator itr, itr0; 145 itr0 = selectedSections_.begin(); 146 itr0++; 147 for (itr = itr0; itr != selectedSections_.end(); itr++) 148 { 149 // debut 150 if ( current > dtmanage_->getBeamLineSize() ) 151 { 152 GWt_dialog warningDialog("PSPA :: verification des sections", " bad section definition !", GWt_dialog::Error,true,true); 153 warningDialog.exec(); 154 return; 155 } 156 157 (*itr)->debut->setText(currentString); 158 // fin 159 string finString = (*itr)->fin->text().toUTF8(); 160 161 int numeroFin = dtmanage_->getNumeroFromElementLabel( finString); 162 163 if ( numeroFin < current || numeroFin > dtmanage_->getBeamLineSize()) 164 { 165 GWt_dialog warningDialog("PSPA : Checking of sections", " bad section definition !", GWt_dialog::Error, true,true); 166 warningDialog.exec(); 167 return; 168 } 169 170 // preparation de la ligne suivante 171 current = numeroFin +1; 172 currentString = dtmanage_->getLabelFromElementNumero(current); 173 } 174 175 if (!areDataCoherent()) { 176 GWt_dialog warningDialog("PSPA : verification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true); 177 warningDialog.exec(); 178 } 179 else 180 { 181 exec_go_->setDisabled(false); 182 } 183 } 184 185 186 bool GWt_softwarePanel::areDataCoherent() 187 { 188 bool caMarche = true; 189 dtmanage_->initializeExecution(); 190 191 list<GWt_sectionToExecute*>::iterator itr; 192 for(itr = selectedSections_.begin(); itr != selectedSections_.end(); itr++) 193 { 194 string debString = (*itr)->debut->text().toUTF8(); 195 string finString = (*itr)->fin->text().toUTF8(); 78 196 79 dernierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize()); 80 } 81 else 82 { 83 dernierText = selectedSections_.back()->fin->text().toUTF8(); 84 int dernierNumero = dtmanage_->getNumeroFromElementLabel(dernierText); 85 dernierNumero++; 86 if ( dernierNumero <= dtmanage_->getBeamLineSize() ) 87 { 88 premierText = dtmanage_->getLabelFromElementNumero(dernierNumero); 89 } 90 else 91 { 92 premierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize()); 93 } 94 dernierText = premierText; 95 } 96 97 // cout << "PspaApplication::addSectionToExecute() : " << premierText << " ââ " << dernierText << endl; 98 99 WContainerWidget* newSection = new WContainerWidget; 100 101 selectedSections_.push_back(new GWt_sectionToExecute); 102 selectedSections_.back()->debut = new WLineEdit(); 103 selectedSections_.back()->debut->setDisabled(true); 104 selectedSections_.back()->debut->setText(premierText); 105 selectedSections_.back()->fin = new WLineEdit(); 106 selectedSections_.back()->fin->changed().connect(this,&GWt_softwarePanel::disableSectionExecute); 107 selectedSections_.back()->fin->setText(dernierText); 108 selectedSections_.back()->selection = new WComboBox(); 109 selectedSections_.back()->ligneDeWidget = newSection; 110 newSection->addWidget(new WText(" from : ")); 111 newSection->addWidget(selectedSections_.back()->debut); 112 newSection->addWidget(new WText(" to : ")); 113 newSection->addWidget(selectedSections_.back()->fin); 114 newSection->addWidget(selectedSections_.back()->selection); 115 116 contenuSections_->addWidget(newSection); 117 unsigned nb = nomDeLogiciel::getNumberOfSoftwares(); 118 unsigned k; 119 for(k = 0; k < nb; k++) { 120 selectedSections_.back()->selection->addItem(nomDeLogiciel(k).getString()); 121 } 122 } 123 124 125 void GWt_softwarePanel::disableSectionExecute() 126 { 127 exec_go_->setDisabled(true); 128 } 129 130 131 void GWt_softwarePanel::checkSectionSelection() 132 { 133 if ( selectedSections_.empty() ) return; 134 135 // traitement de la premiere ligne 136 // on impose le depart du calcul au premier element 137 string premier = dtmanage_->getLabelFromElementNumero(1); 138 (*selectedSections_.begin())->debut->setText(premier); 139 140 string currentString = (*selectedSections_.begin())->fin->text().toUTF8(); 141 int current = dtmanage_->getNumeroFromElementLabel( currentString); 142 143 // si la fin est mal definie on prend toute la config par defaut 144 if ( current <= 0 || current > dtmanage_->getBeamLineSize() ) 145 { 146 current = dtmanage_->getBeamLineSize(); 147 currentString = dtmanage_->getLabelFromElementNumero(current); 148 (*selectedSections_.begin())->fin->setText(currentString); 149 } 150 current++; 151 currentString = dtmanage_->getLabelFromElementNumero(current); 152 153 // traitement des suivantes (on avance d'un cran dans la liste) 154 list<GWt_sectionToExecute*>::iterator itr, itr0; 155 itr0 = selectedSections_.begin(); 156 itr0++; 157 for (itr = itr0; itr != selectedSections_.end(); itr++) 158 { 159 // debut 160 if ( current > dtmanage_->getBeamLineSize() ) 161 { 162 GWt_dialog warningDialog("PSPA : VÃrification des sections", " bad section definition !", GWt_dialog::Error,true,true); 163 warningDialog.exec(); 164 return; 165 } 166 167 (*itr)->debut->setText(currentString); 168 // fin 169 string finString = (*itr)->fin->text().toUTF8(); 170 171 int numeroFin = dtmanage_->getNumeroFromElementLabel( finString); 172 173 if ( numeroFin < current || numeroFin > dtmanage_->getBeamLineSize()) 174 { 175 GWt_dialog warningDialog("PSPA : Checking of sections", " bad section definition !", GWt_dialog::Error, true,true); 176 warningDialog.exec(); 177 return; 178 } 179 180 // preparation de la ligne suivante 181 current = numeroFin +1; 182 currentString = dtmanage_->getLabelFromElementNumero(current); 183 } 184 185 if (!areDataCoherent()) { 186 GWt_dialog warningDialog("PSPA : VÃrification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true); 187 warningDialog.exec(); 188 } 189 else 190 { 191 exec_go_->setDisabled(false); 192 } 193 } 194 195 196 bool GWt_softwarePanel::areDataCoherent() 197 { 198 bool caMarche = true; 199 dtmanage_->initializeExecution(); 200 201 list<GWt_sectionToExecute*>::iterator itr; 202 for(itr = selectedSections_.begin(); itr != selectedSections_.end(); itr++) 203 { 204 string debString = (*itr)->debut->text().toUTF8(); 205 string finString = (*itr)->fin->text().toUTF8(); 206 207 208 int debut = dtmanage_->getNumeroFromElementLabel(debString); 209 int fin = dtmanage_->getNumeroFromElementLabel(finString); 210 nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() ); 211 dtmanage_->addSectionToExecute(debut,fin,prog); 212 } 213 214 string diagnostic; 215 trivaluedBool essai = dtmanage_->checkExecute(diagnostic); 216 if ( essai == error ) { 217 caMarche = false; 218 GWt_dialog calculDialog("PSPA check execute : ERROR", diagnostic , GWt_dialog::Error,true,true); 219 calculDialog.exec(); 220 } else if ( essai == warning ) { 221 caMarche = true; 222 GWt_dialog calculDialog("PSPA check execute : warning ", diagnostic , GWt_dialog::Warning, false,true); 223 calculDialog.exec(); 224 } 225 226 return caMarche; 227 } 228 197 int debut = dtmanage_->getNumeroFromElementLabel(debString); 198 int fin = dtmanage_->getNumeroFromElementLabel(finString); 199 nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() ); 200 dtmanage_->addSectionToExecute(debut,fin,prog); 201 } 202 203 string diagnostic; 204 trivaluedBool essai = dtmanage_->checkExecute(diagnostic); 205 if ( essai == error ) { 206 caMarche = false; 207 GWt_dialog calculDialog("PSPA check execute : ERROR", diagnostic , GWt_dialog::Error,true,true); 208 calculDialog.exec(); 209 } else if ( essai == warning ) { 210 caMarche = true; 211 GWt_dialog calculDialog("PSPA check execute : warning ", diagnostic , GWt_dialog::Warning, false,true); 212 calculDialog.exec(); 213 } 214 215 return caMarche; 216 } 229 217 230 218 void GWt_softwarePanel::deleteSectionToExecuteW() 231 219 { 232 233 234 235 236 220 if ( selectedSections_.empty() ) return; 221 disableSectionExecute(); 222 selectedSections_.back()->ligneDeWidget->clear(); 223 delete selectedSections_.back()->ligneDeWidget; 224 selectedSections_.pop_back(); 237 225 } 238 226 … … 240 228 void GWt_softwarePanel::updateSelections() 241 229 { 242 243 244 { 245 246 247 248 249 } 250 251 230 string premierText, dernierText; 231 if ( selectedSections_.size() > 0 ) 232 { 233 premierText = dtmanage_->getLabelFromElementNumero(1); 234 dernierText = dtmanage_->getLabelFromElementNumero( dtmanage_->getBeamLineSize() ); 235 (*selectedSections_.begin())->debut->setText(premierText); 236 (*selectedSections_.begin())->fin->setText(dernierText); 237 } 238 239 cout << "PspaApplication::updateSelections(): " << premierText << " ââ " << dernierText << endl; 252 240 } 253 241 … … 255 243 string GWt_softwarePanel::getSelection() 256 244 { 257 258 259 245 list<GWt_sectionToExecute*>::iterator itr = selectedSections_.begin(); 246 string str = (*itr)->fin->text().toUTF8(); 247 return str; 260 248 } 261 249 … … 263 251 void GWt_softwarePanel::executer() 264 252 { 265 GWt_console* console = NULL; 266 if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { 267 console = static_cast<GWt_console*> (wApp->findWidget ("console")); 268 console->addConsoleMessage(string("on va peut etre y arriver")); 269 } 270 271 272 static_cast<GWt_globalParameters*>(pspa_->getGlobalParam())->updateGlobals(); 273 274 GWt_dialog calculDialog("Calcul en cours", "Veuillez patienter...", GWt_dialog::Wait, true,false); 275 calculDialog.show(); 276 277 wApp->processEvents(); 278 279 // string resultat; 280 if ( !dtmanage_->executeAll()) { 281 GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exÃcution !", GWt_dialog::Error, true,true); 282 warningDialog.exec(); 283 } 284 // cout << " PspaApplication : retour d'execution resultat = " << resultat << endl; 285 286 287 288 // if (console) { 289 // console->addConsoleMessage(resultat); 290 // } 291 // cout << " PspaApplication : affichage console termine " << endl; 292 293 exec_go_->setDisabled(true); 294 295 calculDialog.hide(); 296 297 pspa_->faireDessin(); 298 } 299 300 253 GWt_console* console = NULL; 254 if (static_cast<GWt_console*> (wApp->findWidget ("console"))) { 255 console = static_cast<GWt_console*> (wApp->findWidget ("console")); 256 console->addConsoleMessage(string("on va peut etre y arriver")); 257 } 258 259 static_cast<GWt_globalParameters*>(pspa_->getGlobalParam())->updateGlobals(); 260 261 GWt_dialog calculDialog("Calcul en cours", "Veuillez patienter...", GWt_dialog::Wait, true,false); 262 calculDialog.show(); 263 264 wApp->processEvents(); 265 266 if (!dtmanage_->executeAll()) { 267 GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exÃcution !", GWt_dialog::Error, true,true); 268 warningDialog.exec(); 269 } 270 271 exec_go_->setDisabled(true); 272 calculDialog.hide(); 273 pspa_->faireDessin(); 274 }
Note: See TracChangeset
for help on using the changeset viewer.